From 139f36429296226807c21bf17feff0314a57a29c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?=
 <rafael.carre@savoirfairelinux.com>
Date: Thu, 28 Jul 2011 17:59:39 -0400
Subject: [PATCH] * #6554 : access the SIPVoIPLink directly, not per account

---
 sflphone-common/src/managerimpl.h             |  2 -
 .../src/managerimpl_registration.cpp          | 40 +++----------------
 2 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h
index b4c84ae836..11f0782e06 100644
--- a/sflphone-common/src/managerimpl.h
+++ b/sflphone-common/src/managerimpl.h
@@ -1445,8 +1445,6 @@ class ManagerImpl
          */
         VoIPLink* getAccountLink (const std::string& accountID="");
 
-        VoIPLink* getSIPAccountLink (void);
-
         std::string getAccountIdFromNameAndServer (const std::string& userName, const std::string& server);
 
         int getLocalIp2IpPort();
diff --git a/sflphone-common/src/managerimpl_registration.cpp b/sflphone-common/src/managerimpl_registration.cpp
index b2b1c3385b..0bc38122a8 100644
--- a/sflphone-common/src/managerimpl_registration.cpp
+++ b/sflphone-common/src/managerimpl_registration.cpp
@@ -139,25 +139,17 @@ ManagerImpl::initRegisterAccounts()
 void ManagerImpl::restartPJSIP (void)
 {
     _debug ("ManagerImpl::restartPJSIP\n");
-    VoIPLink *link = getSIPAccountLink();
-    SIPVoIPLink *siplink = NULL;
-
-    if (link) {
-        siplink = dynamic_cast<SIPVoIPLink*> (getSIPAccountLink ());
-    }
-
+    SIPVoIPLink *siplink = SIPVoIPLink::instance ();
     _debug ("ManagerImpl::unregister sip account\n");
 
     this->unregisterCurSIPAccounts();
     /* Terminate and initialize the PJSIP library */
 
-    if (siplink) {
-        _debug ("ManagerImpl::Terminate sip\n");
-        siplink->terminate ();
-        siplink = SIPVoIPLink::instance ();
-        _debug ("ManagerImpl::Init new sip\n");
-        siplink->init ();
-    }
+	_debug ("ManagerImpl::Terminate sip\n");
+	siplink->terminate ();
+	siplink = SIPVoIPLink::instance ();
+	_debug ("ManagerImpl::Init new sip\n");
+	siplink->init ();
 
     _debug ("ManagerImpl::register sip account\n");
 
@@ -179,26 +171,6 @@ VoIPLink* ManagerImpl::getAccountLink (const std::string& accountID)
         return SIPVoIPLink::instance ();
 }
 
-VoIPLink* ManagerImpl::getSIPAccountLink()
-{
-    /* We are looking for the first SIP account we met because all the SIP accounts have the same voiplink */
-    Account *account;
-    AccountMap::iterator iter = _accountMap.begin();
-
-    while (iter != _accountMap.end()) {
-
-        account = iter->second;
-
-        if (account->getType() == "sip") {
-            return account->getVoIPLink();
-        }
-
-        ++iter;
-    }
-
-    return NULL;
-}
-
 pjsip_regc *getSipRegcFromID (const std::string& id UNUSED)
 {
     /*SIPAccount *tmp = dynamic_cast<SIPAccount *>getAccount(id);
-- 
GitLab