diff --git a/sflphone-common/src/dbus/configurationmanager.cpp b/sflphone-common/src/dbus/configurationmanager.cpp index d43e955fa547aa8ac93bbb22e2b70f354cd611fe..4945baa168433c87f0218aacb86c123de4c9d936 100644 --- a/sflphone-common/src/dbus/configurationmanager.cpp +++ b/sflphone-common/src/dbus/configurationmanager.cpp @@ -803,38 +803,17 @@ void ConfigurationManager::setHistory (const std::vector<std::string>& entries) std::string ConfigurationManager::getAddrFromInterfaceName ( const std::string& interface) { - - std::string address = SIPVoIPLink::instance ("")->getInterfaceAddrFromName ( - interface); - - return address; + return SIPVoIPLink::instance()->getInterfaceAddrFromName (interface); } std::vector<std::string> ConfigurationManager::getAllIpInterface (void) { - - std::vector<std::string> vector; - SIPVoIPLink * sipLink = NULL; - sipLink = SIPVoIPLink::instance (""); - - if (sipLink != NULL) { - vector = sipLink->getAllIpInterface(); - } - - return vector; + return SIPVoIPLink::instance()->getAllIpInterface(); } std::vector<std::string> ConfigurationManager::getAllIpInterfaceByName (void) { - std::vector<std::string> vector; - SIPVoIPLink * sipLink = NULL; - sipLink = SIPVoIPLink::instance (""); - - if (sipLink != NULL) { - vector = sipLink->getAllIpInterfaceByName(); - } - - return vector; + return SIPVoIPLink::instance()->getAllIpInterfaceByName(); } diff --git a/sflphone-common/src/iax/iaxvoiplink.cpp b/sflphone-common/src/iax/iaxvoiplink.cpp index 1c11da65cb703ee843d27e415840c20cc403f5ca..18cbf04dfdc043845d6fc2bd138c54e531d603f8 100644 --- a/sflphone-common/src/iax/iaxvoiplink.cpp +++ b/sflphone-common/src/iax/iaxvoiplink.cpp @@ -57,7 +57,7 @@ namespace { const char * const URLHOOK_COMMAND = "Hooks.url_command"; } // end anonymous namespace -IAXVoIPLink::IAXVoIPLink (const std::string& accountID) : VoIPLink (accountID) +IAXVoIPLink::IAXVoIPLink (const std::string& accountID) : VoIPLink () , _evThread (NULL) , _regSession (NULL) , _nextRefreshStamp (0) @@ -70,6 +70,7 @@ IAXVoIPLink::IAXVoIPLink (const std::string& accountID) : VoIPLink (accountID) , converter (NULL) , converterSamplingRate (0) , urlhook (NULL) + , _accountID(accountID) { _evThread = new EventThread (this); @@ -764,8 +765,8 @@ IAXVoIPLink::iaxOutgoingInvite (IAXCall* call) wait = 0; /** @todo Make preference dynamic, and configurable */ - audio_format_preferred = call->getFirstMatchingFormat (call->getSupportedFormat (getAccountID()), getAccountID()); - audio_format_capability = call->getSupportedFormat (getAccountID()); + audio_format_preferred = call->getFirstMatchingFormat (call->getSupportedFormat (_accountID), _accountID); + audio_format_capability = call->getSupportedFormat (_accountID); _debug ("IAX New call: %s", strNum.c_str()); iax_call (newsession, username.c_str(), username.c_str(), strNum.c_str(), lang, wait, audio_format_preferred, audio_format_capability); @@ -1073,8 +1074,7 @@ IAXVoIPLink::iaxHandleRegReply (iax_event* event) std::string account_id; IAXAccount *account; - account_id = getAccountID(); - account = dynamic_cast<IAXAccount *> (Manager::instance().getAccount (account_id)); + account = dynamic_cast<IAXAccount *> (Manager::instance().getAccount (_accountID)); if (event->etype == IAX_EVENT_REGREJ) { /* Authentication failed! */ @@ -1184,14 +1184,14 @@ IAXVoIPLink::iaxHandlePrecallEvent (iax_event* event) // if peerNumber exist append it to the name string call->initRecFileName (std::string (event->ies.calling_number)); - if (Manager::instance().incomingCall (call, getAccountID())) { + if (Manager::instance().incomingCall (call, _accountID)) { /** @todo Faudra considérer éventuellement le champ CODEC PREFS pour * l'établissement du codec de transmission */ // Remote lists its capabilities - int format = call->getFirstMatchingFormat (event->ies.capability, getAccountID()); + int format = call->getFirstMatchingFormat (event->ies.capability, _accountID); // Remote asks for preferred codec voiceformat - int pref_format = call->getFirstMatchingFormat (event->ies.format, getAccountID()); + int pref_format = call->getFirstMatchingFormat (event->ies.format, _accountID); // Priority to remote's suggestion. In case it's a forwarding, no transcoding // will be needed from the server, thus less latency. @@ -1248,3 +1248,7 @@ void IAXVoIPLink::updateAudiolayer (void) _mutexIAX.leaveMutex(); } +Account* IAXVoIPLink::getAccountPtr (void) +{ + return Manager::instance().getAccount (_accountID); +} diff --git a/sflphone-common/src/iax/iaxvoiplink.h b/sflphone-common/src/iax/iaxvoiplink.h index 98196c15df0ee90910ab34c917175fc8dab829ab..0935f95b28d7ab51383a81113595f7a9db7d7964 100644 --- a/sflphone-common/src/iax/iaxvoiplink.h +++ b/sflphone-common/src/iax/iaxvoiplink.h @@ -218,6 +218,8 @@ class IAXVoIPLink : public VoIPLink private: + Account* getAccountPtr (void); + /* * Decode the message count IAX send. * Returns only the new messages number @@ -324,6 +326,8 @@ class IAXVoIPLink : public VoIPLink /* URL hook */ UrlHook *urlhook; + + const std::string _accountID; }; #endif diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 99cefe7d5db3981881dfad29aba66aaa1e6174d5..154b176169a9bda530069d505f4d81a1bd7ed883 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -285,7 +285,7 @@ bool ManagerImpl::outgoingCall (const std::string& account_id, if (callConfig == Call::IPtoIP) { _debug ("Manager: Start IP2IP call"); /* We need to retrieve the sip voiplink instance */ - siplink = SIPVoIPLink::instance (""); + siplink = SIPVoIPLink::instance (); if (siplink->SIPNewIpToIpCall(call_id, to_cleaned)) { switchCall (call_id); @@ -473,7 +473,7 @@ bool ManagerImpl::hangupCall (const CallID& callId) if (getConfigFromCall (callId) == Call::IPtoIP) { /* Direct IP to IP call */ - returnValue = SIPVoIPLink::instance ("")->hangup (callId); + returnValue = SIPVoIPLink::instance ()->hangup (callId); } else { std::string accountId = getAccountFromCall (callId); @@ -529,7 +529,7 @@ bool ManagerImpl::cancelCall (const CallID& id) /* Direct IP to IP call */ if (getConfigFromCall (id) == Call::IPtoIP) { - returnValue = SIPVoIPLink::instance ("")->cancel (id); + returnValue = SIPVoIPLink::instance ()->cancel (id); } /* Classic call, attached to an account */ @@ -574,7 +574,7 @@ bool ManagerImpl::onHoldCall (const CallID& callId) if (getConfigFromCall (callId) == Call::IPtoIP) { /* Direct IP to IP call */ - returnValue = SIPVoIPLink::instance ("")-> onhold (callId); + returnValue = SIPVoIPLink::instance ()-> onhold (callId); } else { /* Classic call, attached to an account */ @@ -646,8 +646,8 @@ bool ManagerImpl::offHoldCall (const CallID& callId) /* Direct IP to IP call */ if (getConfigFromCall (callId) == Call::IPtoIP) { - // is_rec = SIPVoIPLink::instance ("")-> isRecording (call_id); - returnValue = SIPVoIPLink::instance ("")-> offhold (callId); + // is_rec = SIPVoIPLink::instance ()-> isRecording (call_id); + returnValue = SIPVoIPLink::instance ()-> offhold (callId); } /* Classic call, attached to an account */ else { @@ -716,7 +716,7 @@ bool ManagerImpl::transferCall (const CallID& callId, const std::string& to) // Direct IP to IP call if (getConfigFromCall (callId) == Call::IPtoIP) { - returnValue = SIPVoIPLink::instance ("")-> transfer (callId, to); + returnValue = SIPVoIPLink::instance ()-> transfer (callId, to); } // Classic call, attached to an account else { @@ -767,7 +767,7 @@ bool ManagerImpl::attendedTransfer(const CallID& transferID, const CallID& targe // Direct IP to IP call if (getConfigFromCall (transferID) == Call::IPtoIP) { - returnValue = SIPVoIPLink::instance ("")-> attendedTransfer(transferID, targetID); + returnValue = SIPVoIPLink::instance ()-> attendedTransfer(transferID, targetID); } else { // Classic call, attached to an account @@ -812,7 +812,7 @@ bool ManagerImpl::refuseCall (const CallID& id) /* Direct IP to IP call */ if (getConfigFromCall (id) == Call::IPtoIP) { - returnValue = SIPVoIPLink::instance ("")-> refuse (id); + returnValue = SIPVoIPLink::instance ()-> refuse (id); } /* Classic call, attached to an account */ @@ -2155,7 +2155,7 @@ void ManagerImpl::peerHungupCall (const CallID& call_id) /* Direct IP to IP call */ if (getConfigFromCall (call_id) == Call::IPtoIP) { - SIPVoIPLink::instance ("")->hangup (call_id); + SIPVoIPLink::instance ()->hangup (call_id); } else { account_id = getAccountFromCall (call_id); @@ -4236,7 +4236,6 @@ void ManagerImpl::loadIptoipProfile() // We need the IP2IP settings to be loaded at this time as they are used // for default sip transport - // _directIpAccount->setVoIPLink(SIPVoIPLink::instance ("")); _directIpAccount->setVoIPLink(); } diff --git a/sflphone-common/src/managerimpl_registration.cpp b/sflphone-common/src/managerimpl_registration.cpp index 70df970390564a14c66989f5ee341da7169debf6..b2b1c3385b3404daebeef7e850a21f793730712d 100644 --- a/sflphone-common/src/managerimpl_registration.cpp +++ b/sflphone-common/src/managerimpl_registration.cpp @@ -154,7 +154,7 @@ void ManagerImpl::restartPJSIP (void) if (siplink) { _debug ("ManagerImpl::Terminate sip\n"); siplink->terminate (); - siplink = SIPVoIPLink::instance (""); + siplink = SIPVoIPLink::instance (); _debug ("ManagerImpl::Init new sip\n"); siplink->init (); } @@ -176,7 +176,7 @@ VoIPLink* ManagerImpl::getAccountLink (const std::string& accountID) return 0; } else - return SIPVoIPLink::instance (""); + return SIPVoIPLink::instance (); } VoIPLink* ManagerImpl::getSIPAccountLink() diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index e64a91dd45ba3b361451d91f299cfed7097ca150..d0bce5bb150998b33a9407884cd919c00187ea64 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -553,7 +553,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const void SIPAccount::setVoIPLink() { - _link = SIPVoIPLink::instance (""); + _link = SIPVoIPLink::instance (); dynamic_cast<SIPVoIPLink*> (_link)->incrementClients(); } diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index f9b147d537f410573bf893fcaf23d1611f6c1f56..df33ccc8cea293216d8aa081fd7cabe97bd20cae 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -289,8 +289,8 @@ void onCallTransfered (pjsip_inv_session *inv, pjsip_rx_data *rdata); SIPVoIPLink* SIPVoIPLink::_instance = NULL; -SIPVoIPLink::SIPVoIPLink (const std::string& accountID) - : VoIPLink (accountID) +SIPVoIPLink::SIPVoIPLink () + : VoIPLink () , _nbTryListenAddr (2) // number of times to try to start SIP listener , _regPort (atoi (DEFAULT_SIP_PORT)) , _clients (0) @@ -314,12 +314,12 @@ SIPVoIPLink::~SIPVoIPLink() } -SIPVoIPLink* SIPVoIPLink::instance (const std::string& id) +SIPVoIPLink* SIPVoIPLink::instance () { if (!_instance) { _debug ("UserAgent: Create new SIPVoIPLink instance"); - _instance = new SIPVoIPLink (id); + _instance = new SIPVoIPLink; } return _instance; @@ -3162,7 +3162,7 @@ void invite_session_state_changed_cb (pjsip_inv_session *inv, pjsip_event *e) // If the call is a direct IP-to-IP call SIPVoIPLink * link = NULL; if (call->getCallConfiguration () == Call::IPtoIP) { - link = SIPVoIPLink::instance (""); + link = SIPVoIPLink::instance (); } else { std::string accId = Manager::instance().getAccountFromCall (call->getCallId()); link = dynamic_cast<SIPVoIPLink *> (Manager::instance().getAccountLink (accId)); @@ -3741,7 +3741,7 @@ void registration_cb (struct pjsip_regc_cbparam *param) // shutdown this transport since useless // if(account->getAccountTransport() != _localUDPTransport) { - SIPVoIPLink::instance ("")->shutdownSipTransport (account->getAccountID()); + SIPVoIPLink::instance ()->shutdownSipTransport (account->getAccountID()); //} } else { @@ -3752,7 +3752,7 @@ void registration_cb (struct pjsip_regc_cbparam *param) account->setRegistrationState (Unregistered); account->setRegister (false); - SIPVoIPLink::instance ("")->shutdownSipTransport (account->getAccountID()); + SIPVoIPLink::instance ()->shutdownSipTransport (account->getAccountID()); // pjsip_regc_destroy(param->regc); // account->setRegistrationInfo(NULL); @@ -3762,7 +3762,7 @@ void registration_cb (struct pjsip_regc_cbparam *param) account->setRegistrationState (ErrorAuth); account->setRegister (false); - SIPVoIPLink::instance ("")->shutdownSipTransport (account->getAccountID()); + SIPVoIPLink::instance ()->shutdownSipTransport (account->getAccountID()); } } @@ -3938,7 +3938,7 @@ transaction_request_cb (pjsip_rx_data *rdata) // May use the published address as well - addrToUse = SIPVoIPLink::instance ("")->getInterfaceAddrFromName (account->getLocalInterface ()); + addrToUse = SIPVoIPLink::instance ()->getInterfaceAddrFromName (account->getLocalInterface ()); account->isStunEnabled () ? addrSdp = account->getPublishedAddress () : addrSdp = addrToUse; // Set the appropriate transport to have the right VIA header link->initTransportSelector (account->getAccountTransport (), &tp, call->getMemoryPool()); @@ -4353,7 +4353,7 @@ void onCallTransfered (pjsip_inv_session *inv, pjsip_rx_data *rdata) CallID newCallId = Manager::instance().getNewCallID(); - Call *newCall = SIPVoIPLink::instance(IP2IP_PROFILE)->newOutgoingCall(newCallId, sipUri); + Call *newCall = SIPVoIPLink::instance()->newOutgoingCall(newCallId, sipUri); // if (!Manager::instance().outgoingCall (accId, newCallId, sipUri)) { if(newCall == NULL) { diff --git a/sflphone-common/src/sip/sipvoiplink.h b/sflphone-common/src/sip/sipvoiplink.h index 63116e7f230af21a119f51fb5fef42d4bcbeefc5..0a9085d6e44eae0d25fc503e8a64d9704f62c48d 100644 --- a/sflphone-common/src/sip/sipvoiplink.h +++ b/sflphone-common/src/sip/sipvoiplink.h @@ -90,7 +90,7 @@ class SIPVoIPLink : public VoIPLink * Singleton method. Enable to retrieve the unique static instance * @return SIPVoIPLink* A pointer on the object */ - static SIPVoIPLink* instance (const std::string& id); + static SIPVoIPLink* instance (); /** * Increment the number of SIP account connected to this link @@ -405,11 +405,7 @@ class SIPVoIPLink : public VoIPLink int _nbTryListenAddr; private: - /** - * Constructor - * @param accountID The account identifier - */ - SIPVoIPLink (const std::string& accountID); + SIPVoIPLink (); /* The singleton instance */ static SIPVoIPLink* _instance; diff --git a/sflphone-common/src/voiplink.cpp b/sflphone-common/src/voiplink.cpp index 34a53c4b2145ee43a836b90c72fc0fa042abd2d5..da5d8b649d20ba3d863aaeda4af49bf69c4aae4e 100644 --- a/sflphone-common/src/voiplink.cpp +++ b/sflphone-common/src/voiplink.cpp @@ -34,7 +34,7 @@ #include "voiplink.h" #include "manager.h" -VoIPLink::VoIPLink (const std::string& accountID) : _accountID (accountID), _localPort (0), _initDone (false) +VoIPLink::VoIPLink () : _localPort (0), _initDone (false) { } @@ -99,8 +99,3 @@ bool VoIPLink::clearCallMap() return true; } - -Account* VoIPLink::getAccountPtr (void) -{ - return Manager::instance().getAccount (_accountID); -} diff --git a/sflphone-common/src/voiplink.h b/sflphone-common/src/voiplink.h index 2a0339b21fee44ea2b5f8fb30942547d952a7f1c..2e1952e80894559ab48e09023d47e5cae7b524d2 100644 --- a/sflphone-common/src/voiplink.h +++ b/sflphone-common/src/voiplink.h @@ -59,9 +59,8 @@ class VoIPLink public: /** * Constructor - * @param accountID The account identifier */ - VoIPLink (const std::string& accountID); + VoIPLink (); /** * Virtual destructor @@ -222,15 +221,6 @@ class VoIPLink */ bool clearCallMap(); - /** - * @return std::string parent Account's ID - */ - std::string& getAccountID (void) { - return _accountID; - } - - Account* getAccountPtr (void); - /** * Get the call pointer from the call map (protected by mutex) * @param id A Call ID @@ -238,12 +228,6 @@ class VoIPLink */ Call* getCall (const CallID& id); - private: - /** - * ID of parent's Account - */ - std::string _accountID; - protected: /** Contains all the calls for this Link, protected by mutex */ CallMap _callMap; diff --git a/sflphone-common/test/siptest.cpp b/sflphone-common/test/siptest.cpp index 8fed03d09e37d0a5535de587cdbc906b20c1cea1..f57070580c6ddff3ce98ffd365a53b284c45d673 100644 --- a/sflphone-common/test/siptest.cpp +++ b/sflphone-common/test/siptest.cpp @@ -202,7 +202,7 @@ void SIPTest::testSimpleIncomingIpCall () sleep(2); // gtrab call id from sipvoiplink - SIPVoIPLink *siplink = SIPVoIPLink::instance (""); + SIPVoIPLink *siplink = SIPVoIPLink::instance (); CPPUNIT_ASSERT(siplink->_callMap.size() == 1); CallMap::iterator iterCallId = siplink->_callMap.begin(); @@ -318,7 +318,7 @@ void SIPTest::testTwoIncomingIpCall () sleep(1); // gtrab call id from sipvoiplink - SIPVoIPLink *sipLink = SIPVoIPLink::instance (""); + SIPVoIPLink *sipLink = SIPVoIPLink::instance (); CPPUNIT_ASSERT(sipLink->_callMap.size() == 1); CallMap::iterator iterCallId = sipLink->_callMap.begin(); @@ -428,7 +428,7 @@ void SIPTest::testIncomingIpCallSdp () sleep(2); // gtrab call id from sipvoiplink - SIPVoIPLink *siplink = SIPVoIPLink::instance (""); + SIPVoIPLink *siplink = SIPVoIPLink::instance (); CPPUNIT_ASSERT(siplink->_callMap.size() == 1); CallMap::iterator iterCallId = siplink->_callMap.begin();