From 71e409acfb2075c46bcc481ad64637c3717dd01d Mon Sep 17 00:00:00 2001 From: Tristan Matthews <tristan.matthews@savoirfairelinux.com> Date: Wed, 29 Aug 2012 15:40:43 -0400 Subject: [PATCH] * #14529: sip: move getAccountIdFrom... to sipvoiplink Manager never uses it and it should only be needed by SIP anyway. --- daemon/src/managerimpl.cpp | 17 ----------------- daemon/src/managerimpl.h | 2 -- daemon/src/sip/sipvoiplink.cpp | 19 ++++++++++++++++++- daemon/src/sip/sipvoiplink.h | 9 ++++++++- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index cd93c73643..2197e9a091 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 b241830368..8a944447ee 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 a6c189c90a..5173123d06 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 f261df9420..732a4a1dea 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); -- GitLab