From e7f0ec30540551d4c0bb15bd5c687ca8540bfa21 Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandre.savard@savoirfairelinux.net>
Date: Mon, 31 Aug 2009 15:05:37 -0400
Subject: [PATCH] [#2006] Detach a partcipant from drag n drop

---
 sflphone-client-gnome/src/contacts/calltree.c |  7 +-
 sflphone-common/src/managerimpl.cpp           | 65 ++++++++++---------
 2 files changed, 40 insertions(+), 32 deletions(-)

diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c
index d497534105..62f7139524 100644
--- a/sflphone-client-gnome/src/contacts/calltree.c
+++ b/sflphone-client-gnome/src/contacts/calltree.c
@@ -983,7 +983,12 @@ static void drag_end_cb(GtkWidget * widget, GdkDragContext * context, gpointer d
 	{
 	    // TODO: dragged a conference call on a call
 	    // TODO: dragged a conference call on a conference
-	    // TODO: dragged a conference call on a NULL element
+
+	    else if(selected_type == A_CONFERENCE && dragged_type == NULL)
+	    {
+		// TODO: dragged a conference call on a NULL element
+		sflphone_detach_participant(selected_call_id);
+	    }
 	}
 	else // dragged_path_depth == 2
 	{
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index aee0a42e0d..c7f2761bf3 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -821,15 +821,23 @@ ManagerImpl::addParticipant(const CallID& call_id, const CallID& conference_id)
 	iter_details = call_details.find("CALL_STATE");
 
 	if (iter_details->second == "HOLD")
-	 {
-	     _debug("    OFFHOLD %s\n", call_id.c_str());
-	     offHoldCall(call_id);
-	 }
+	{
+	    _debug("    OFFHOLD %s\n", call_id.c_str());
+	    offHoldCall(call_id);
+	}
 	 else if(iter_details->second == "INCOMING")
-	 {
-	     _debug("    ANSWER %s\n", call_id.c_str());
-	     answerCall(call_id);
-	 }
+	{
+	    _debug("    ANSWER %s\n", call_id.c_str());
+	    answerCall(call_id);
+	}
+
+	AccountID currentAccountId;
+
+        Call* call = NULL;
+
+	currentAccountId = getAccountFromCall (call_id);
+	call = getAccountLink (currentAccountId)->getCall (conference_id);
+	call->setConfId (default_conf);
 
 	_dbus->getCallManager()->conferenceChanged(conference_id);
     }
@@ -883,13 +891,24 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
 	     _debug("    ANSWER %s\n", call_id2.c_str());
 	     answerCall(call_id2);
 	 }
-	
-        
+
+	 AccountID currentAccountId;
+
+	 Call* call = NULL;
+
+	 currentAccountId = getAccountFromCall (call_id1);
+	 call = getAccountLink (currentAccountId)->getCall (call_id1);
+	 call->setConfId (default_conf);
+
+	 currentAccountId = getAccountFromCall (call_id2);
+	 call = getAccountLink (currentAccountId)->getCall (call_id2);
+	 call->setConfId (default_conf);      
 
     }
     else {
 
-	 _debug("ALREADY A CONFERENCE CREATED, ADD PARTICIPANT TO IT\n");
+	 _debug("ALREADY A CONFERENCE CREATED\n");
+	 /*
 	 Conference* conf = iter->second;
 	 conf->add(call_id1);
 	 _conferencecall.insert(pair<CallID, Conference*>(call_id1, conf));
@@ -905,6 +924,7 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
 	     _debug("    Add INCOMING call to conference\n");
 	     answerCall(call_id1);
 	 }
+	 */
 
 	 /*
 	 iter_details = call2_details.find("CALL_STATE");
@@ -919,17 +939,6 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
 	 */
     }
 
-    AccountID currentAccountId;
-
-    Call* call = NULL;
-
-    currentAccountId = getAccountFromCall (call_id1);
-    call = getAccountLink (currentAccountId)->getCall (call_id1);
-    call->setConfId (default_conf);
-
-    currentAccountId = getAccountFromCall (call_id2);
-    call = getAccountLink (currentAccountId)->getCall (call_id2);
-    call->setConfId (default_conf);
 }
 
 
@@ -946,7 +955,7 @@ ManagerImpl::detachParticipant(const CallID& call_id)
 
     }
     else {
-	_debug("ALREADY A CONFERENCE CREATED, ADD PARTICIPANT TO IT\n");
+	_debug("ManagerImpl::detachParticipant detach participant %s\n", call_id.c_str());
 	// Conference* conf = iter->second;
 
 	// conf->remove(call_id);
@@ -955,15 +964,9 @@ ManagerImpl::detachParticipant(const CallID& call_id)
 	removeParticipant(call_id);
 
 	onHoldCall(call_id);
-    }
-
-    AccountID currentAccountId;
 
-    Call* call = NULL;
-
-    currentAccountId = getAccountFromCall (call_id);
-    call = getAccountLink (currentAccountId)->getCall (default_conf);
-    call->setConfId (default_conf);
+	// _dbus->getCallManager()->conferenceChanged(conference_id);
+    }
     
 }
 
-- 
GitLab