From be2f093db39ba5ff951bb5f39c0eaffe55ae7d62 Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandre.savard@savoirfairelinux.net>
Date: Fri, 4 Sep 2009 15:31:57 -0400
Subject: [PATCH] [#2006] Add joinConference capabilities

---
 sflphone-client-gnome/src/actions.c           |  2 +-
 sflphone-client-gnome/src/contacts/calltree.c |  2 ++
 sflphone-common/src/dbus/callmanager.cpp      |  2 +-
 sflphone-common/src/managerimpl.cpp           | 23 +++++++++++++++++--
 4 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c
index 45311edcf8..95147667d3 100644
--- a/sflphone-client-gnome/src/actions.c
+++ b/sflphone-client-gnome/src/actions.c
@@ -901,7 +901,7 @@ sflphone_add_conference()
 sflphone_join_conference(const gchar* sel_confID, const gchar* drag_confID)
 {
     DEBUG("sflphone join two conference");
-    dbus_join_conference(sel_confID, sel_confID);
+    dbus_join_conference(sel_confID, drag_confID);
 }
 
 void
diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c
index 4d56c41a68..9c94b8e09d 100644
--- a/sflphone-client-gnome/src/contacts/calltree.c
+++ b/sflphone-client-gnome/src/contacts/calltree.c
@@ -1136,6 +1136,7 @@ void drag_data_received_cb(GtkWidget *widget, GdkDragContext *context, gint x, g
 		else
 		{
 		    dragged_call_id = ((conference_obj_t*)g_value_get_pointer(&val))->_confID;
+		    dragged_conf = (conference_obj_t*)g_value_get_pointer(&val);
 		}
                 g_print("    INTO_OR_AFTER dragged_path %s, dragged_call_id %s, dragged_path_depth %i\n", dragged_path, dragged_call_id, dragged_path_depth);
                 break;
@@ -1159,6 +1160,7 @@ void drag_data_received_cb(GtkWidget *widget, GdkDragContext *context, gint x, g
 		else
 		{
 		    dragged_call_id = ((conference_obj_t*)g_value_get_pointer(&val))->_confID;
+		    dragged_conf = (conference_obj_t*)g_value_get_pointer(&val);
 		}
                 g_print("    INTO_OR_BEFORE dragged_path %s, dragged_call_id %s, dragged_path_depth %i\n", dragged_path, dragged_call_id, dragged_path_depth);
                 break;
diff --git a/sflphone-common/src/dbus/callmanager.cpp b/sflphone-common/src/dbus/callmanager.cpp
index ffb0facf70..f3324dfc79 100644
--- a/sflphone-common/src/dbus/callmanager.cpp
+++ b/sflphone-common/src/dbus/callmanager.cpp
@@ -157,7 +157,7 @@ CallManager::detachParticipant (const std::string& callID)
 void
 CallManager::joinConference (const std::string& sel_confID, const std::string& drag_confID)
 {
-    _debug ("CallManager::joinParticipant received %s, %s\n", sel_confID.c_str(), drag_confID.c_str());
+    _debug ("CallManager::joinConference received %s, %s\n", sel_confID.c_str(), drag_confID.c_str());
     Manager::instance().joinConference(sel_confID, drag_confID);
 }
 
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index 7dc8a1830d..4874cb0bab 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -979,6 +979,7 @@ ManagerImpl::addParticipant(const CallID& call_id, const CallID& conference_id)
     // store the current call id (it will change in offHoldCall or in answerCall)
     CallID current_call_id = getCurrentCallId();
 
+    _debug("    addParticipant: enter main process\n");
     if(iter != _conferencemap.end()) {
 
 	Conference* conf = iter->second;
@@ -1022,6 +1023,9 @@ ManagerImpl::addParticipant(const CallID& call_id, const CallID& conference_id)
 
 	_dbus->getCallManager()->conferenceChanged(conference_id, conf->getStateStr());
     }
+    {
+	_debug("    addParticipant: Error, conference %s conference_id not found!\n", conference_id.c_str());
+    }
 
 
     // bind main participant to conference after adding new participant 
@@ -1362,10 +1366,12 @@ ManagerImpl::processRemainingParticipant(CallID current_call_id, Conference *con
 void
 ManagerImpl::joinConference(const CallID& conf_id1, const CallID& conf_id2)
 {
+    _debug("ManagerImpl::joinConference(%s, %s)\n", conf_id1.c_str(), conf_id2.c_str());
+    
     ConferenceMap::iterator iter;
 
-    Conference *conf1;
-    Conference *conf2;
+    Conference *conf1 = NULL;
+    Conference *conf2 = NULL;
 
     iter = _conferencemap.find(conf_id1);
     
@@ -1377,6 +1383,19 @@ ManagerImpl::joinConference(const CallID& conf_id1, const CallID& conf_id2)
     if(iter != _conferencemap.end())
 	conf2 = iter->second;
 
+    ParticipantSet participants = conf1->getParticipantList();
+
+    ParticipantSet::iterator iter_participant = participants.begin();
+
+    while(iter_participant != participants.end())
+    {
+	detachParticipant(*iter_participant, "");
+	addParticipant(*iter_participant, conf_id2);
+
+	iter_participant++;
+    }
+
+    // detachParticipant(default_id, "");
     
 }
 
-- 
GitLab