- Timestamp:
- Oct 23, 2013 5:34:48 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/account.cpp
r4608 r4631 18 18 */ 19 19 #include <pjsua2/account.hpp> 20 #include <pjsua2/endpoint.hpp> 20 21 #include <pj/ctype.h> 21 22 #include "util.hpp" … … 330 331 } 331 332 332 333 /////////////////////////////////////////////////////////////////////////////// 334 335 void AccountInfo::fromPj(const pjsua_acc_info &pai) 336 { 337 id = pai.id; 338 isDefault = pai.is_default != 0; 339 uri = pj2Str(pai.acc_uri); 340 regIsConfigured = pai.has_registration != 0; 341 regIsActive = pai.has_registration && pai.expires > 0 && 342 (pai.status / 100 == 2); 343 regExpiresSec = pai.expires; 344 regStatus = pai.status; 345 regStatusText = pj2Str(pai.status_text); 346 regLastErr = pai.reg_last_err; 347 onlineStatus = pai.online_status != 0; 348 onlineStatusText = pj2Str(pai.online_status_text); 349 } 350 351 /////////////////////////////////////////////////////////////////////////////// 352 353 Account::Account(AccountCallback *param_cb, Token user_data) 354 : id(PJSUA_INVALID_ID), cb(param_cb), userData(user_data) 355 { 356 cb->setAccount(this); 357 } 358 359 Account::~Account() 360 { 361 delete cb; 362 } 363 364 void Account::create(const AccountConfig &acc_cfg, 365 bool make_default) throw(Error) 366 { 367 pjsua_acc_config pj_acc_cfg = acc_cfg.toPj(); 368 369 PJSUA2_CHECK_EXPR( pjsua_acc_add(&pj_acc_cfg, make_default, &id) ); 370 } 371 372 void Account::modify(const AccountConfig &acc_cfg) throw(Error) 373 { 374 pjsua_acc_config pj_acc_cfg = acc_cfg.toPj(); 375 376 PJSUA2_CHECK_EXPR( pjsua_acc_modify(id, &pj_acc_cfg) ); 377 } 378 379 bool Account::isValid() const 380 { 381 return pjsua_acc_is_valid(id) != 0; 382 } 383 384 void Account::setDefault() throw(Error) 385 { 386 PJSUA2_CHECK_EXPR( pjsua_acc_set_default(id) ); 387 } 388 389 bool Account::isDefault() const 390 { 391 return pjsua_acc_get_default() == id; 392 } 393 394 int Account::getIndex() const 395 { 396 return id; 397 } 398 399 void Account::setUserData(Token user_data) 400 { 401 userData = user_data; 402 } 403 404 Token Account::getUserData() const 405 { 406 return userData; 407 } 408 409 AccountInfo Account::getInfo() const throw(Error) 410 { 411 pjsua_acc_info pj_ai; 412 AccountInfo ai; 413 414 PJSUA2_CHECK_EXPR( pjsua_acc_get_info(id, &pj_ai) ); 415 ai.fromPj(pj_ai); 416 return ai; 417 } 418 419 void Account::setRegistration(bool renew) throw(Error) 420 { 421 PJSUA2_CHECK_EXPR( pjsua_acc_set_registration(id, renew) ); 422 } 423 424 void 425 Account::setOnlineStatus(const AccountPresenceStatus &pres_st) throw(Error) 426 { 427 pjrpid_element pj_rpid; 428 429 pj_bzero(&pj_rpid, sizeof(pj_rpid)); 430 pj_rpid.type = PJRPID_ELEMENT_TYPE_PERSON; 431 pj_rpid.activity = pres_st.activity; 432 pj_rpid.id = str2Pj(pres_st.rpidId); 433 pj_rpid.note = str2Pj(pres_st.note); 434 435 PJSUA2_CHECK_EXPR( pjsua_acc_set_online_status2(id, pres_st.isOnline, 436 &pj_rpid) ); 437 } 438 439 void Account::setTransport(TransportId tp_id) throw(Error) 440 { 441 PJSUA2_CHECK_EXPR( pjsua_acc_set_transport(id, tp_id) ); 442 } 443
Note: See TracChangeset
for help on using the changeset viewer.