From 576db0dce1be44931e78d7a0ecc6225e1ecb65ae Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandresavard@msavard.(none)>
Date: Wed, 15 Jun 2011 18:13:27 -0400
Subject: [PATCH] #6167: Fix participant list NULL ending

---
 sflphone-client-gnome/src/conference_obj.c    |  5 +++++
 sflphone-client-gnome/src/contacts/calltree.c |  3 +++
 sflphone-client-gnome/src/dbus/dbus.c         |  1 +
 sflphone-common/src/audio/gaincontrol.cpp     |  2 +-
 sflphone-common/src/managerimpl.cpp           | 22 ++++++++++++-------
 sflphone-common/src/managerimpl.h             |  5 +++--
 6 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/sflphone-client-gnome/src/conference_obj.c b/sflphone-client-gnome/src/conference_obj.c
index 2200ab8252..3649d996f6 100644
--- a/sflphone-client-gnome/src/conference_obj.c
+++ b/sflphone-client-gnome/src/conference_obj.c
@@ -154,6 +154,11 @@ void conference_participant_list_update (gchar** participants, conference_obj_t*
 
     DEBUG ("Conference: Participant list update");
 
+    if(conf == NULL) {
+    	ERROR("Conference: Error: Conference is NULL");
+        return;
+    }
+
     if (conf->participant_list) {
         g_slist_free (conf->participant_list);
         conf->participant_list = NULL;
diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c
index 83b6cb7994..80e32bd82c 100644
--- a/sflphone-client-gnome/src/contacts/calltree.c
+++ b/sflphone-client-gnome/src/contacts/calltree.c
@@ -320,6 +320,9 @@ calltree_create_conf_from_participant_list(GSList *list) {
 	c++;
     }
 
+    participant_list = (void *) realloc(participant_list, (c+1) *sizeof(void*));
+    *(participant_list+c) = NULL;
+
     dbus_create_conf_from_participant_list(participant_list);
 }
 
diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c
index 3bbd36d940..c2b0c19cc0 100644
--- a/sflphone-client-gnome/src/dbus/dbus.c
+++ b/sflphone-client-gnome/src/dbus/dbus.c
@@ -346,6 +346,7 @@ conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo
         call->_confID = g_strdup (confID);
     }
 
+
     set_timestamp(&new_conf->_time_start);
 
     conferencelist_add (new_conf);
diff --git a/sflphone-common/src/audio/gaincontrol.cpp b/sflphone-common/src/audio/gaincontrol.cpp
index 495ae12cfb..569191f483 100644
--- a/sflphone-common/src/audio/gaincontrol.cpp
+++ b/sflphone-common/src/audio/gaincontrol.cpp
@@ -30,7 +30,7 @@ GainControl::GainControl(double sr, double target) : averager(sr, SFL_GAIN_ATTAC
     maxIncreaseStep = exp(0.11513 * 12. * 160 / 8000); // Computed on 12 frames (240 ms)
     maxDecreaseStep = exp(-0.11513 * 40. * 160 / 8000); // Computed on 40 frames (800 ms)
 
-    _debug("GainControl: Target gain %d dB (%d linear)", targetLeveldB, targetLevelLinear);
+    _debug("GainControl: Target gain %f dB (%f linear)", targetLeveldB, targetLevelLinear);
 
 }
 
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index 36adb6312f..30a4a6e76c 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -236,7 +236,7 @@ void ManagerImpl::switchCall (const CallID& id)
 /* Main Thread */
 
 bool ManagerImpl::outgoingCall (const std::string& account_id,
-                                const CallID& call_id, const std::string& to)
+                                const CallID& call_id, const std::string& to, const std::string& conf_id)
 {
 
     std::string pattern, to_cleaned;
@@ -309,13 +309,17 @@ bool ManagerImpl::outgoingCall (const std::string& account_id,
     	_warn("Manager: Warning: Could not associate call id %s to account id %s", call_id.c_str(), account_id.c_str());
     }
 
-    if (getAccountLink (account_id)->newOutgoingCall (call_id, to_cleaned)) {
+    Call *call = NULL;
+    call = getAccountLink(account_id)->newOutgoingCall (call_id, to_cleaned);
+    if (call) {
         switchCall (call_id);
     } else {
         callFailure (call_id);
         _debug ("Manager: Error: An error occur, the call was not created");
     }
 
+    call->setConfId(conf_id);
+
     getMainBuffer()->stateInfo();
 
     return true;
@@ -1048,7 +1052,7 @@ bool ManagerImpl::isConference (const CallID& id)
 
 bool ManagerImpl::participToConference (const CallID& call_id)
 {
-	AccountID accountId = getAccountFromCall (call_id);
+    AccountID accountId = getAccountFromCall (call_id);
     Call *call = getAccountLink (accountId)->getCall (call_id);
 
     if (call == NULL) {
@@ -1325,17 +1329,21 @@ void ManagerImpl::createConfFromParticipantList(const std::vector< std::string >
     */
     
     std::string generatedCallID = "callid";
-    std::string tostr = "147";
     std::string accountstr = "Account:1307562458";
 
     for(unsigned int i = 0; i < participantList.size(); i++) {
-        _debug("PARTICIPANT LIST %s", participantList[i].c_str());
+        _debug("********************************************************************* PARTICIPANT LIST %s", participantList[i].c_str());
+	std::string tostr = participantList[i].c_str();
 	generatedCallID = generatedCallID + participantList[i];
-	outgoingCall(accountstr, generatedCallID, tostr);	
 	conf->add(generatedCallID);
+	outgoingCall(accountstr, generatedCallID, tostr, conf->getConfID());	
     }
 
     _conferencemap.insert(std::pair<CallID, Conference *> (conf->getConfID(), conf));
+    
+    if (_dbus) {
+        _dbus->getCallManager()->conferenceCreated (conf->getConfID());
+    }
 
     
 }
@@ -1555,8 +1563,6 @@ void ManagerImpl::joinConference (const CallID& conf_id1,
         iter_participant++;
     }
 
-    // detachParticipant(default_id, "");
-
 }
 
 void ManagerImpl::addStream (const CallID& call_id)
diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h
index c8890d0e00..da0e1cda0b 100644
--- a/sflphone-common/src/managerimpl.h
+++ b/sflphone-common/src/managerimpl.h
@@ -194,12 +194,13 @@ class ManagerImpl
          * Functions which occur with a user's action
          * Place a new call
          * @param accountId	The account to make tha call with
-         * @param id  The call identifier
+         * @param call_id  The call identifier
          * @param to  The recipient of the call
+	 * @param conf_id The conference identifier if any
          * @return bool true on success
          *		  false otherwise
          */
-        bool outgoingCall (const AccountID& accountId, const CallID& id, const std::string& to);
+        bool outgoingCall (const AccountID&, const CallID&, const std::string&, const std::string& = "");
 
         /**
          * Functions which occur with a user's action
-- 
GitLab