1
/* $Id: types.cpp 4742 2014-02-12 05:18:31Z bennylp $ */
3
* Copyright (C) 2013 Teluu Inc. (http://www.teluu.com)
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
#include <pjsua2/types.hpp>
25
#define THIS_FILE "types.cpp"
27
///////////////////////////////////////////////////////////////////////////////
30
: status(PJ_SUCCESS), srcLine(0)
34
Error::Error( pj_status_t prm_status,
35
const string &prm_title,
36
const string &prm_reason,
37
const string &prm_src_file,
39
: status(prm_status), title(prm_title), reason(prm_reason),
40
srcFile(prm_src_file), srcLine(prm_src_line)
42
if (this->status != PJ_SUCCESS && prm_reason.empty()) {
43
char errmsg[PJ_ERR_MSG_SIZE];
44
pj_strerror(this->status, errmsg, sizeof(errmsg));
45
this->reason = errmsg;
49
string Error::info(bool multi_line) const
53
if (status==PJ_SUCCESS) {
55
} else if (!multi_line) {
59
output += title + " error: ";
61
snprintf(temp, sizeof(temp), " (status=%d)", status);
62
output += reason + temp;
63
if (!srcFile.empty()) {
66
snprintf(temp, sizeof(temp), ":%d]", srcLine);
73
output += string("Title: ") + title + "\n";
76
snprintf(temp, sizeof(temp), "%d\n", status);
77
output += string("Code: ") + temp;
78
output += string("Description: ") + reason + "\n";
79
if (!srcFile.empty()) {
80
snprintf(temp, sizeof(temp), ":%d\n", srcLine);
81
output += string("Location: ") + srcFile + temp;
88
///////////////////////////////////////////////////////////////////////////////
90
void TimeVal::fromPj(const pj_time_val &prm)
93
this->msec = prm.msec;