From c5a61b1ded92560d417a40d31c21e0562bc2ac1d Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandresavard@alexandresavard-desktop.(none)>
Date: Mon, 8 Feb 2010 12:22:03 -0500
Subject: [PATCH] [#2588] Add DBUS method to make call with first registered
 account

---
 sflphone-common/src/dbus/callmanager.cpp      | 29 +++++++++++++++++++
 sflphone-common/src/dbus/callmanager.h        |  2 ++
 .../src/dbus/configurationmanager.cpp         |  8 ++---
 sflphone-common/src/sip/sipvoiplink.cpp       |  2 --
 4 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/sflphone-common/src/dbus/callmanager.cpp b/sflphone-common/src/dbus/callmanager.cpp
index f3aa16c175..fb41bec4c2 100644
--- a/sflphone-common/src/dbus/callmanager.cpp
+++ b/sflphone-common/src/dbus/callmanager.cpp
@@ -18,6 +18,8 @@
  *  along with this program; if not, write to the Free Software
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+#include <vector>
+
 #include "global.h"
 #include "callmanager.h"
 
@@ -45,6 +47,33 @@ CallManager::placeCall (const std::string& accountID,
     else            Manager::instance().outgoingCall (accountID, callID, to);
 }
 
+void
+CallManager::placeCallFirstAccount (const std::string& callID,
+				    const std::string& to)
+{
+    if (to == "") {
+        _warn("No number entered - Call stopped");
+	return;
+    }
+
+    std::vector< std::string > accountIdList = Manager::instance().getAccountList();
+    std::vector< std::string >::iterator iter = accountIdList.begin();
+
+    Account *account;
+    while(iter != accountIdList.end()) {
+        account = Manager::instance().getAccount(*iter);
+	if(account->isEnabled()) {
+	    Manager::instance().outgoingCall (*iter, callID, to);
+	    return;
+	}
+
+	iter++;
+    }
+
+    _warn("No enabled account found - Call stopped\n");
+    
+}
+
 void
 CallManager::refuse (const std::string& callID)
 {
diff --git a/sflphone-common/src/dbus/callmanager.h b/sflphone-common/src/dbus/callmanager.h
index 8c3bab14c0..c49f9c9c28 100644
--- a/sflphone-common/src/dbus/callmanager.h
+++ b/sflphone-common/src/dbus/callmanager.h
@@ -53,6 +53,8 @@ class CallManager
 
 	/* Call related methods */
         void placeCall( const std::string& accountID, const std::string& callID, const std::string& to );
+	void placeCallFirstAccount( const std::string& callID, const std::string& to );
+
         void refuse( const std::string& callID );
         void accept( const std::string& callID );
         void hangUp( const std::string& callID );
diff --git a/sflphone-common/src/dbus/configurationmanager.cpp b/sflphone-common/src/dbus/configurationmanager.cpp
index 8b19492e8f..7575cc3676 100644
--- a/sflphone-common/src/dbus/configurationmanager.cpp
+++ b/sflphone-common/src/dbus/configurationmanager.cpp
@@ -439,7 +439,7 @@ std::vector<std::string> ConfigurationManager::getCodecDetails (const int32_t& p
 
 std::vector<std::string> ConfigurationManager::getActiveCodecList (const std::string& accountID) {
 
-    _warn ("Send active codec list for account %s", accountID.c_str ());
+    _debug("Send active codec list for account %s", accountID.c_str ());
 
     std::vector< std::string > v;
 	Account *acc;
@@ -449,11 +449,9 @@ std::vector<std::string> ConfigurationManager::getActiveCodecList (const std::st
 
 	acc = Manager::instance ().getAccount (accountID);
 	if (acc != NULL) {
-		_warn ("Et un compte, un !");
 		active = acc->getActiveCodecs ();
 		size = active.size();
 		while (i<size) {
-			_warn ("Et un codec, un !");
 			std::stringstream ss;
 			ss << active[i];
 			v.push_back ( (ss.str()).data());
@@ -468,11 +466,9 @@ std::vector<std::string> ConfigurationManager::getActiveCodecList (const std::st
 void ConfigurationManager::setActiveCodecList (const std::vector< std::string >& list, const std::string& accountID)
 {
 
-    _debug ("ConfigurationManager::setActiveCodecList received");
+        _debug ("ConfigurationManager::setActiveCodecList received");
 
 	Account *acc;
-    unsigned int i=0;
-	size_t size;
 
 	// Save the codecs list per account
 	acc = Manager::instance ().getAccount (accountID);
diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp
index f49cbc0668..9b2a1e510a 100644
--- a/sflphone-common/src/sip/sipvoiplink.cpp
+++ b/sflphone-common/src/sip/sipvoiplink.cpp
@@ -380,7 +380,6 @@ std::string SIPVoIPLink::getInterfaceAddrFromName(std::string ifaceName) {
 
     struct ifreq ifr;
     int fd;
-    int rval = 0;
     int err;
 
     struct sockaddr_in *saddr_in;
@@ -1806,7 +1805,6 @@ bool SIPVoIPLink::pjsip_init()
 {
     pj_status_t status;
     int errPjsip = 0;
-    int port;
     pjsip_inv_callback inv_cb;
     pj_str_t accepted;
     std::string name_mod;
-- 
GitLab