From a906eff26130ee79e19aab9e644cce2c7d755ecd Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Wed, 12 Oct 2011 13:28:34 -0400
Subject: [PATCH] * #7131: remove underscore prefix in voiplink classes

---
 daemon/src/iax/iaxvoiplink.cpp | 12 ++---
 daemon/src/voiplink.cpp        | 28 +++++------
 daemon/src/voiplink.h          | 18 ++++---
 daemon/test/siptest.cpp        | 89 +++++++++++-----------------------
 4 files changed, 57 insertions(+), 90 deletions(-)

diff --git a/daemon/src/iax/iaxvoiplink.cpp b/daemon/src/iax/iaxvoiplink.cpp
index f334409395..f89e3301dc 100644
--- a/daemon/src/iax/iaxvoiplink.cpp
+++ b/daemon/src/iax/iaxvoiplink.cpp
@@ -82,9 +82,9 @@ IAXVoIPLink::terminate()
     if (!initDone_)
         return;
 
-    ost::MutexLock m(_callMapMutex);
+    ost::MutexLock m(callMapMutex_);
 
-    for (CallMap::iterator iter = _callMap.begin(); iter != _callMap.end(); ++iter) {
+    for (CallMap::iterator iter = callMap_.begin(); iter != callMap_.end(); ++iter) {
         IAXCall *call = dynamic_cast<IAXCall*>(iter->second);
 
         if (call) {
@@ -94,7 +94,7 @@ IAXVoIPLink::terminate()
         }
     }
 
-    _callMap.clear();
+    callMap_.clear();
 
     initDone_ = false;
 }
@@ -138,7 +138,7 @@ IAXVoIPLink::getEvent()
 void
 IAXVoIPLink::sendAudioFromMic(void)
 {
-    for (CallMap::const_iterator iter = _callMap.begin(); iter != _callMap.end() ; ++iter) {
+    for (CallMap::const_iterator iter = callMap_.begin(); iter != callMap_.end() ; ++iter) {
         IAXCall *currentCall = dynamic_cast<IAXCall*>(iter->second);
 
         if (!currentCall or currentCall->getState() != Call::Active)
@@ -441,9 +441,9 @@ IAXVoIPLink::iaxOutgoingInvite(IAXCall* call)
 IAXCall*
 IAXVoIPLink::iaxFindCallBySession(struct iax_session* session)
 {
-    ost::MutexLock m(_callMapMutex);
+    ost::MutexLock m(callMapMutex_);
 
-    for (CallMap::const_iterator iter = _callMap.begin(); iter != _callMap.end(); ++iter) {
+    for (CallMap::const_iterator iter = callMap_.begin(); iter != callMap_.end(); ++iter) {
         IAXCall* call = dynamic_cast<IAXCall*>(iter->second);
 
         if (call and call->session == session)
diff --git a/daemon/src/voiplink.cpp b/daemon/src/voiplink.cpp
index f2c2ce70e6..696de53963 100644
--- a/daemon/src/voiplink.cpp
+++ b/daemon/src/voiplink.cpp
@@ -31,45 +31,45 @@
  *  as that of the covered work.
  */
 
+#include "call.h"
 #include "voiplink.h"
-#include "manager.h"
 
-VoIPLink::~VoIPLink(void)
+VoIPLink::~VoIPLink()
 {
-    ost::MutexLock m(_callMapMutex);
+    ost::MutexLock m(callMapMutex_);
 
-    for (CallMap::const_iterator iter = _callMap.begin();
-            iter != _callMap.end(); ++iter)
+    for (CallMap::const_iterator iter = callMap_.begin();
+            iter != callMap_.end(); ++iter)
         delete iter->second;
 
-    _callMap.clear();
+    callMap_.clear();
 
 }
 
 void VoIPLink::addCall(Call* call)
 {
     if (call and getCall(call->getCallId()) == NULL) {
-        ost::MutexLock m(_callMapMutex);
-        _callMap[call->getCallId()] = call;
+        ost::MutexLock m(callMapMutex_);
+        callMap_[call->getCallId()] = call;
     }
 }
 
 void VoIPLink::removeCall(const std::string& id)
 {
-    ost::MutexLock m(_callMapMutex);
+    ost::MutexLock m(callMapMutex_);
 
     _debug("VoipLink: removing call %s from list", id.c_str());
 
-    delete _callMap[id];
-    _callMap.erase(id);
+    delete callMap_[id];
+    callMap_.erase(id);
 }
 
 Call* VoIPLink::getCall(const std::string& id)
 {
-    ost::MutexLock m(_callMapMutex);
-    CallMap::iterator iter = _callMap.find(id);
+    ost::MutexLock m(callMapMutex_);
+    CallMap::iterator iter = callMap_.find(id);
 
-    if (iter != _callMap.end())
+    if (iter != callMap_.end())
         return iter->second;
     else
         return NULL;
diff --git a/daemon/src/voiplink.h b/daemon/src/voiplink.h
index 1718d43ca2..5095d2a1d3 100644
--- a/daemon/src/voiplink.h
+++ b/daemon/src/voiplink.h
@@ -35,10 +35,12 @@
 #define __VOIP_LINK_H__
 
 #include <stdexcept>
+#include <map>
+#include <cc++/thread.h> // for ost::Mutex
 
-#include "call.h"
-
+class Call;
 class Account;
+
 namespace sfl {
 class InstantMessaging;
 };
@@ -48,7 +50,7 @@ typedef std::map<std::string, Call*> CallMap;
 
 class VoipLinkException : public std::runtime_error {
     public:
-        VoipLinkException(const std::string& str="") :
+        VoipLinkException(const std::string& str = "") :
             std::runtime_error("UserAgent: VoipLinkException occured: " + str) {}
 };
 
@@ -61,20 +63,20 @@ class VoIPLink {
         /**
          * Virtual destructor
          */
-        virtual ~VoIPLink(void);
+        virtual ~VoIPLink();
 
 
         /**
          * Virtual method
          * Event listener. Each event send by the call manager is received and handled from here
          */
-        virtual void getEvent(void) = 0;
+        virtual void getEvent() = 0;
 
         /**
          * Virtual method
          * Try to initiate the communication layer and set config
          */
-        virtual void init(void) = 0;
+        virtual void init() = 0;
 
         /**
          * Virtual method
@@ -187,10 +189,10 @@ class VoIPLink {
 
     protected:
         /** Contains all the calls for this Link, protected by mutex */
-        CallMap _callMap;
+        CallMap callMap_;
 
         /** Mutex to protect call map */
-        ost::Mutex _callMapMutex;
+        ost::Mutex callMapMutex_;
 
         /** Remove a call from the call map (protected by mutex)
          * @param id A Call ID
diff --git a/daemon/test/siptest.cpp b/daemon/test/siptest.cpp
index da6effb3f2..0e0d952199 100644
--- a/daemon/test/siptest.cpp
+++ b/daemon/test/siptest.cpp
@@ -43,14 +43,15 @@
 using std::cout;
 using std::endl;
 
+// anonymous namespace
+namespace {
 pthread_mutex_t count_mutex;
 pthread_cond_t count_nb_thread;
 int counter = 0;
-
+}
 
 void *sippThreadWithCount(void *str)
 {
-
     pthread_mutex_lock(&count_mutex);
     counter++;
     pthread_mutex_unlock(&count_mutex);
@@ -79,13 +80,11 @@ void *sippThreadWithCount(void *str)
     pthread_mutex_unlock(&count_mutex);
 
     pthread_exit(NULL);
-
 }
 
 
 void *sippThread(void *str)
 {
-
     std::string *command = (std::string *)(str);
 
     std::cout << "SIPTest: " << command << std::endl;
@@ -102,7 +101,6 @@ void *sippThread(void *str)
     CPPUNIT_ASSERT(i==0);
 
     pthread_exit(NULL);
-
 }
 
 
@@ -128,16 +126,14 @@ void SIPTest::tearDown()
 void SIPTest::testSimpleOutgoingIpCall()
 {
     pthread_t thethread;
-    void *status;
 
     // command to be executed by the thread, user agent server waiting for a call
     std::string command("sipp -sn uas -i 127.0.0.1 -p 5062 -m 1");
 
     int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command));
 
-    if (rc) {
+    if (rc)
         std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
-    }
 
     std::string testaccount("IP2IP");
     std::string testcallid("callid1234");
@@ -175,20 +171,18 @@ void SIPTest::testSimpleOutgoingIpCall()
 
     Manager::instance().hangupCall(testcallid);
 
+    void *status;
     rc = pthread_join(thethread, &status);
 
-    if (rc) {
+    if (rc)
         std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
-    } else
+    else
         std::cout << "SIPTest: completed join with thread" << std::endl;
-
-
 }
 
 
 void SIPTest::testSimpleIncomingIpCall()
 {
-
     pthread_t thethread;
     void *status;
 
@@ -197,10 +191,8 @@ void SIPTest::testSimpleIncomingIpCall()
 
     int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command));
 
-    if (rc) {
+    if (rc)
         std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
-    }
-
 
     // sleep a while to make sure that sipp insdtance is initialized and sflphoned received
     // the incoming invite.
@@ -209,8 +201,8 @@ void SIPTest::testSimpleIncomingIpCall()
     // gtrab call id from sipvoiplink
     SIPVoIPLink *siplink = SIPVoIPLink::instance();
 
-    CPPUNIT_ASSERT(siplink->_callMap.size() == 1);
-    CallMap::iterator iterCallId = siplink->_callMap.begin();
+    CPPUNIT_ASSERT(siplink->callMap_.size() == 1);
+    CallMap::iterator iterCallId = siplink->callMap_.begin();
     std::string testcallid = iterCallId->first;
 
     // TODO: hmmm, should IP2IP call be stored in call list....
@@ -219,14 +211,13 @@ void SIPTest::testSimpleIncomingIpCall()
     // Answer this call
     CPPUNIT_ASSERT(Manager::instance().answerCall(testcallid));
 
-
     sleep(1);
 
     rc = pthread_join(thethread, &status);
 
-    if (rc) {
+    if (rc)
         std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
-    } else
+    else
         std::cout << "SIPTest: completed join with thread" << std::endl;
 }
 
@@ -244,15 +235,13 @@ void SIPTest::testTwoOutgoingIpCall()
 
     int rc = pthread_create(&firstCallThread, NULL, sippThread, (void *)(&firstCallCommand));
 
-    if (rc) {
+    if (rc)
         std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
-    }
 
     rc = pthread_create(&secondCallThread, NULL, sippThread, (void *)(&secondCallCommand));
 
-    if (rc) {
+    if (rc)
         std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
-    }
 
     sleep(1);
 
@@ -281,9 +270,8 @@ void SIPTest::testTwoOutgoingIpCall()
 
     rc = pthread_join(firstCallThread, &status);
 
-    if (rc) {
+    if (rc)
         std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
-    }
 
     std::cout << "SIPTest: completed join with thread" << std::endl;
 
@@ -291,15 +279,14 @@ void SIPTest::testTwoOutgoingIpCall()
 
     rc = pthread_join(secondCallThread, &status);
 
-    if (rc) {
+    if (rc)
         std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
-    } else
+    else
         std::cout << "SIPTest: completed join with thread" << std::endl;
 }
 
 void SIPTest::testTwoIncomingIpCall()
 {
-
     pthread_mutex_init(&count_mutex, NULL);
     pthread_cond_init(&count_nb_thread, NULL);
 
@@ -318,10 +305,8 @@ void SIPTest::testTwoIncomingIpCall()
 
     int rc = pthread_create(&firstCallThread, &attr, sippThreadWithCount, (void *)(&firstCallCommand));
 
-    if (rc) {
+    if (rc)
         std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
-    }
-
 
     // sleep a while to make sure that sipp insdtance is initialized and sflphoned received
     // the incoming invite.
@@ -330,8 +315,8 @@ void SIPTest::testTwoIncomingIpCall()
     // gtrab call id from sipvoiplink
     SIPVoIPLink *sipLink = SIPVoIPLink::instance();
 
-    CPPUNIT_ASSERT(sipLink->_callMap.size() == 1);
-    CallMap::iterator iterCallId = sipLink->_callMap.begin();
+    CPPUNIT_ASSERT(sipLink->callMap_.size() == 1);
+    CallMap::iterator iterCallId = sipLink->callMap_.begin();
     std::string firstCallID = iterCallId->first;
 
     // Answer this call
@@ -347,8 +332,8 @@ void SIPTest::testTwoIncomingIpCall()
 
     sleep(1);
 
-    CPPUNIT_ASSERT(sipLink->_callMap.size() == 2);
-    iterCallId = sipLink->_callMap.begin();
+    CPPUNIT_ASSERT(sipLink->callMap_.size() == 2);
+    iterCallId = sipLink->callMap_.begin();
 
     if (iterCallId->first == firstCallID)
         iterCallId++;
@@ -366,25 +351,8 @@ void SIPTest::testTwoIncomingIpCall()
 
     pthread_mutex_unlock(&count_mutex);
 
-    /*
-    rc = pthread_join(firstCallThread, &status);
-    if (rc) {
-        std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
-    }
-    else
-        std::cout << "SIPTest: completed join with thread 1" << std::endl;
-
-    rc = pthread_join(secondCallThread, &status);
-    if (rc) {
-        std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
-    }
-    else
-        std::cout << "SIPTest: completed join with thread 2" << std::endl;
-    */
-
     pthread_mutex_destroy(&count_mutex);
     pthread_cond_destroy(&count_nb_thread);
-
 }
 
 
@@ -425,7 +393,6 @@ void SIPTest::testHoldIpCall()
 
 void SIPTest::testIncomingIpCallSdp()
 {
-
     pthread_t thethread;
     void *status;
 
@@ -434,10 +401,8 @@ void SIPTest::testIncomingIpCallSdp()
 
     int rc = pthread_create(&thethread, NULL, sippThread, (void *)(&command));
 
-    if (rc) {
+    if (rc)
         std::cout << "SIPTest: ERROR; return code from pthread_create()" << std::endl;
-    }
-
 
     // sleep a while to make sure that sipp insdtance is initialized and sflphoned received
     // the incoming invite.
@@ -446,8 +411,8 @@ void SIPTest::testIncomingIpCallSdp()
     // gtrab call id from sipvoiplink
     SIPVoIPLink *siplink = SIPVoIPLink::instance();
 
-    CPPUNIT_ASSERT(siplink->_callMap.size() == 1);
-    CallMap::iterator iterCallId = siplink->_callMap.begin();
+    CPPUNIT_ASSERT(siplink->callMap_.size() == 1);
+    CallMap::iterator iterCallId = siplink->callMap_.begin();
     std::string testcallid = iterCallId->first;
 
     // TODO: hmmm, should IP2IP call be stored in call list....
@@ -461,8 +426,8 @@ void SIPTest::testIncomingIpCallSdp()
 
     rc = pthread_join(thethread, &status);
 
-    if (rc) {
+    if (rc)
         std::cout << "SIPTest: ERROR; return code from pthread_join(): " << rc << std::endl;
-    } else
+    else
         std::cout << "SIPTest: completed join with thread" << std::endl;
 }
-- 
GitLab