diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index b985e0c52d893f12e7d77656914eef3cd45b265a..4cedeb474dcdea6462d364e36ffc1381ea17985d 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -93,7 +93,6 @@ SIPAccount::SIPAccount (const AccountID& accountID) : Account (accountID, "SIP") , _routeSet ("") , _pool (NULL) - , _regc (NULL) , _bRegister (false) , _registrationExpire ("") , _interface ("default") @@ -147,7 +146,6 @@ SIPAccount::~SIPAccount() dynamic_cast<SIPVoIPLink*> (_link)->decrementClients(); /* Delete accounts-related information */ - _regc = NULL; free_cred(_cred); delete _tlsSetting; } @@ -665,7 +663,6 @@ int SIPAccount::unregisterVoIPLink() try { _link->sendUnregister (_accountID); - setRegistrationInfo (NULL); } catch(VoipLinkException &e) { _error("SIPAccount: %s", e.what()); diff --git a/sflphone-common/src/sip/sipaccount.h b/sflphone-common/src/sip/sipaccount.h index fa30b0fe4270e6556fa13991aaa976572faa5689..3e4557498f8ee428e85e241c34f6d0528a035c6c 100644 --- a/sflphone-common/src/sip/sipaccount.h +++ b/sflphone-common/src/sip/sipaccount.h @@ -283,27 +283,6 @@ class SIPAccount : public Account _bRegister = result; } - /** - * Get the registration stucture that is used - * for PJSIP in the registration process. - * Settings are loaded from configuration file. - * @param void - * @return pjsip_regc* A pointer to the registration structure - */ - pjsip_regc* getRegistrationInfo (void) const { - return _regc; - } - - /** - * Set the registration structure that is used - * for PJSIP in the registration process; - * @pram A pointer to the new registration structure - * @return void - */ - void setRegistrationInfo (pjsip_regc *regc) { - _regc = regc; - } - /** * Get the number of credentials defined for * this account. @@ -762,8 +741,6 @@ class SIPAccount : public Account pj_pool_t *_pool; - // The pjsip client registration information - pjsip_regc *_regc; // To check if the account is registered bool _bRegister; diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index 38c3b9dc053b514b9d8f43db7eda22213a02e022..9e036cd9c639b967b9de6429ac4dab9336f9a4a3 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -404,7 +404,6 @@ void SIPVoIPLink::sendRegister (AccountID id) throw(VoipLinkException) std::string tmp, hostname, username, password; SIPAccount *account = NULL; - pjsip_regc *regc; pjsip_hdr hdr_list; account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (id)); @@ -469,8 +468,6 @@ void SIPVoIPLink::sendRegister (AccountID id) throw(VoipLinkException) _mutexSIP.enterMutex(); - // Get the client registration information for this particular account - regc = account->getRegistrationInfo(); account->setRegister (true); // Set the expire value of the message from the config file @@ -485,8 +482,7 @@ void SIPVoIPLink::sendRegister (AccountID id) throw(VoipLinkException) account->setRegistrationState (Trying); // Create the registration according to the account ID - // status = pjsip_regc_create (_endpt, (void*) account, ®istration_cb, ®c); - status = pjsip_regc_create (_endpt, (void *) &account->getAccountID(), ®istration_cb, ®c); + status = pjsip_regc_create (_endpt, (void *) &account->getAccountID(), ®istration_cb, &_regc); if (status != PJ_SUCCESS) { _mutexSIP.leaveMutex(); @@ -522,7 +518,7 @@ void SIPVoIPLink::sendRegister (AccountID id) throw(VoipLinkException) pj_cstr (&pjSrv, srvUri.c_str()); // Initializes registration - status = pjsip_regc_init (regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, expire_value); + status = pjsip_regc_init (_regc, &pjSrv, &pjFrom, &pjFrom, 1, &pjContact, expire_value); if (status != PJ_SUCCESS) { _mutexSIP.leaveMutex(); throw VoipLinkException("Unable to initialize account registration structure"); @@ -531,13 +527,13 @@ void SIPVoIPLink::sendRegister (AccountID id) throw(VoipLinkException) // Fill route set if (! (account->getServiceRoute().empty())) { pjsip_route_hdr *route_set = createRouteSet(account, _pool); - pjsip_regc_set_route_set (regc, route_set); + pjsip_regc_set_route_set (_regc, route_set); } pjsip_cred_info *cred = account->getCredInfo(); unsigned credential_count = account->getCredentialCount(); _debug ("UserAgent: setting %u credentials in sendRegister", credential_count); - pjsip_regc_set_credentials (regc, credential_count, cred); + pjsip_regc_set_credentials (_regc, credential_count, cred); // Add User-Agent Header pj_list_init (&hdr_list); @@ -547,10 +543,10 @@ void SIPVoIPLink::sendRegister (AccountID id) throw(VoipLinkException) pjsip_generic_string_hdr *h = pjsip_generic_string_hdr_create (_pool, &STR_USER_AGENT, &useragent); pj_list_push_back (&hdr_list, (pjsip_hdr*) h); - pjsip_regc_add_headers (regc, &hdr_list); + pjsip_regc_add_headers (_regc, &hdr_list); - if ((status = pjsip_regc_register (regc, PJ_TRUE, &tdata)) != PJ_SUCCESS) { + if ((status = pjsip_regc_register (_regc, PJ_TRUE, &tdata)) != PJ_SUCCESS) { _mutexSIP.leaveMutex(); throw VoipLinkException("Unable to initialize transaction data for account registration"); } @@ -560,7 +556,7 @@ void SIPVoIPLink::sendRegister (AccountID id) throw(VoipLinkException) initTransportSelector (account->getAccountTransport (), &tp, _pool); // pjsip_regc_set_transport increments transport ref count by one - status = pjsip_regc_set_transport (regc, tp); + status = pjsip_regc_set_transport (_regc, tp); if (account->getAccountTransport()) { // decrease transport's ref count, counter icrementation is @@ -580,7 +576,7 @@ void SIPVoIPLink::sendRegister (AccountID id) throw(VoipLinkException) // Send registration request // pjsip_regc_send increment the transport ref count by one, - status = pjsip_regc_send (regc, tdata); + status = pjsip_regc_send (_regc, tdata); if (account->getAccountTransport()) { // Decrease transport's ref count, since coresponding reference counter decrementation @@ -596,8 +592,6 @@ void SIPVoIPLink::sendRegister (AccountID id) throw(VoipLinkException) _mutexSIP.leaveMutex(); - account->setRegistrationInfo (regc); - if (account->getAccountTransport()) { _debug ("Sent account registration using transport: %s %s (refcnt=%d)", @@ -632,17 +626,13 @@ void SIPVoIPLink::sendUnregister (AccountID id) throw(VoipLinkException) return; } - pjsip_regc *regc = account->getRegistrationInfo(); - if(regc == NULL) { - throw VoipLinkException("Registration structure is NULL"); - } - - status = pjsip_regc_unregister (regc, &tdata); + status = pjsip_regc_unregister (_regc, &tdata); + _regc = NULL; if (status != PJ_SUCCESS) { throw VoipLinkException("Unable to unregister sip account"); } - status = pjsip_regc_send (regc, tdata); + status = pjsip_regc_send (_regc, tdata); if (status != PJ_SUCCESS) { throw VoipLinkException("Unable to send request to unregister sip account"); diff --git a/sflphone-common/src/sip/sipvoiplink.h b/sflphone-common/src/sip/sipvoiplink.h index 66f1eac77b2be1ce7546316d34769e05acdfc74a..f08be6fc25a9cfcddb58e42f933233132c08b769 100644 --- a/sflphone-common/src/sip/sipvoiplink.h +++ b/sflphone-common/src/sip/sipvoiplink.h @@ -568,6 +568,8 @@ class SIPVoIPLink : public VoIPLink */ int _clients; + // The pjsip client registration information + pjsip_regc *_regc; friend class SIPTest; };