diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index cd93c73643efd5908ecd1963122a7b69d32fd43c..2197e9a09184ea2b29403e524d7fcc75fbb5d2e0 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -2768,23 +2768,6 @@ ManagerImpl::getAllAccounts() const return all; } -std::string -ManagerImpl::getAccountIdFromNameAndServer(const std::string &userName, - const std::string &server) const -{ - DEBUG("username = %s, server = %s", userName.c_str(), server.c_str()); - // Try to find the account id from username and server name by full match - - AccountMap allAccounts(getAllAccounts()); - for (AccountMap::const_iterator iter = allAccounts.begin(); iter != allAccounts.end(); ++iter) { - SIPAccount *account = static_cast<SIPAccount *>(iter->second); - if (account and account->matches(userName, server)) - return iter->first; - } - - DEBUG("Username %s or server %s doesn't match any account, using IP2IP", userName.c_str(), server.c_str()); - return SIPAccount::IP2IP_PROFILE; -} std::map<std::string, int32_t> ManagerImpl::getAddressbookSettings() const { diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index b241830368b9a4549e73f4735c401f10f1e8765e..8a944447ee68172ce52b1f175b6336c90dd50b76 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -1104,8 +1104,6 @@ class ManagerImpl { */ VoIPLink* getAccountLink(const std::string& accountID); - std::string getAccountIdFromNameAndServer(const std::string& userName, const std::string& server) const; - std::string getStunServer() const; void setStunServer(const std::string &server); diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index a6c189c90a5cfb0fa8fcdf70ad678b71ae5cc2a5..5173123d06dab354fc9885497cfa3e4d16b55d82 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -217,7 +217,7 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata) } std::string userName(sip_to_uri->user.ptr, sip_to_uri->user.slen); std::string server(sip_from_uri->host.ptr, sip_from_uri->host.slen); - std::string account_id(Manager::instance().getAccountIdFromNameAndServer(userName, server)); + std::string account_id(SIPVoIPLink::instance()->getAccountIdFromNameAndServer(userName, server)); std::string displayName(sip_utils::parseDisplayName(rdata->msg_info.msg_buf)); @@ -540,6 +540,23 @@ void SIPVoIPLink::destroy() instance_ = 0; } +std::string +SIPVoIPLink::getAccountIdFromNameAndServer(const std::string &userName, + const std::string &server) const +{ + DEBUG("username = %s, server = %s", userName.c_str(), server.c_str()); + // Try to find the account id from username and server name by full match + + for (AccountMap::const_iterator iter = sipAccountMap_.begin(); iter != sipAccountMap_.end(); ++iter) { + SIPAccount *account = static_cast<SIPAccount*>(iter->second); + if (account and account->matches(userName, server)) + return iter->first; + } + + DEBUG("Username %s or server %s doesn't match any account, using IP2IP", userName.c_str(), server.c_str()); + return SIPAccount::IP2IP_PROFILE; +} + void SIPVoIPLink::setSipLogLevel() { char *envvar = getenv(SIPLOGLEVEL); diff --git a/daemon/src/sip/sipvoiplink.h b/daemon/src/sip/sipvoiplink.h index f261df94206b37fc197cb665d30fa3b75ff8dfd8..732a4a1dea6799cfbd6f06c7f2589cd0a6d61bba 100644 --- a/daemon/src/sip/sipvoiplink.h +++ b/daemon/src/sip/sipvoiplink.h @@ -69,6 +69,7 @@ typedef std::map<std::string, SIPCall*> SipCallMap; */ class SIPVoIPLink : public VoIPLink { + public: /** @@ -97,7 +98,8 @@ class SIPVoIPLink : public VoIPLink { /** * Return the internal account map for this VOIP link */ - AccountMap &getAccounts() { return sipAccountMap_; } + AccountMap & + getAccounts() { return sipAccountMap_; } /** * Build and send SIP registration request @@ -288,6 +290,11 @@ class SIPVoIPLink : public VoIPLink { #ifdef SFL_VIDEO static void enqueueKeyframeRequest(const std::string &callID); #endif + + std::string + getAccountIdFromNameAndServer(const std::string &userName, + const std::string &server) const; + private: NON_COPYABLE(SIPVoIPLink);