From 9c6778fe93e40193b308124bc654590f0edd4e8d Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandre.savard@savoirfairelinux.net>
Date: Mon, 24 Aug 2009 13:58:26 -0400
Subject: [PATCH] [#2006] Add Detach participant method

---
 sflphone-client-gnome/src/actions.c           |  6 ++--
 .../src/dbus/callmanager-introspec.xml        |  8 +++++
 sflphone-client-gnome/src/dbus/dbus.c         | 32 +++++++++----------
 sflphone-client-gnome/src/toolbar.c           | 21 ++++++------
 sflphone-client-gnome/src/toolbar.h           |  2 +-
 .../src/dbus/callmanager-introspec.xml        |  8 +++++
 sflphone-common/src/dbus/callmanager.cpp      | 10 ++++++
 sflphone-common/src/dbus/callmanager.h        |  1 +
 sflphone-common/src/managerimpl.cpp           |  4 +--
 9 files changed, 61 insertions(+), 31 deletions(-)

diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c
index ea6076d0fb..77fcb0f8bd 100644
--- a/sflphone-client-gnome/src/actions.c
+++ b/sflphone-client-gnome/src/actions.c
@@ -833,12 +833,12 @@ sflphone_get_current_codec_name()
 }
 
     void
-sflphone_add_participant()
+sflphone_detach_participant()
 {
-    DEBUG("sflphone add participant to conference");
+    DEBUG("sflphone detach participant from conference");
 
     callable_obj_t * selectedCall = calltab_get_selected_call(current_calls);
-    dbus_add_participant(selectedCall);
+    dbus_detach_participant(selectedCall);
 }
 
     void
diff --git a/sflphone-client-gnome/src/dbus/callmanager-introspec.xml b/sflphone-client-gnome/src/dbus/callmanager-introspec.xml
index 62b9d5db61..f627cd73dd 100644
--- a/sflphone-client-gnome/src/dbus/callmanager-introspec.xml
+++ b/sflphone-client-gnome/src/dbus/callmanager-introspec.xml
@@ -61,6 +61,14 @@
       <arg type="s" name="drag_callID" direction="in"/>
     </method>
 
+    <method name="detachParticipant">
+      <arg type="s" name="callID" direction="in"/>
+    </method>
+
+    <signal name="displayCoference">
+      <arg type="s" name="confID" direction="out"/>
+    </signal>
+
     <method name="setRecording">
       <arg type="s" name="callID" direction="in"/>
     </method>
diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c
index 02cbc3fad4..bf3a03d2bb 100644
--- a/sflphone-client-gnome/src/dbus/dbus.c
+++ b/sflphone-client-gnome/src/dbus/dbus.c
@@ -1242,17 +1242,19 @@ dbus_set_volume_controls(  )
     }
 }
 
-    void
-dbus_add_participant(const callable_obj_t * c)
+
+dbus_join_participant(const callable_obj_t * c_sel, const callable_obj_t * c_drag)
 {
 
-    DEBUG("dbus_add_participant %s\n", c->_callID);
+    DEBUG("dbus_join_participant %s and %s\n", c_sel->_callID, c_drag->_callID);
 
     GError* error = NULL;
-    org_sflphone_SFLphone_CallManager_add_participant(
-            callManagerProxy,
-            c->_callID,
-            &error);
+    
+    org_sflphone_SFLphone_CallManager_join_participant (
+             callManagerProxy, 
+	     c_sel->_callID, 
+	     c_drag->_callID, 
+	     &error);
     if(error)
     {
         g_error_free(error);
@@ -1260,19 +1262,17 @@ dbus_add_participant(const callable_obj_t * c)
     
 }
 
-
-dbus_join_participant(const callable_obj_t * c_sel, const callable_obj_t * c_drag)
+    void
+dbus_detach_participant(const callable_obj_t * c)
 {
 
-    DEBUG("dbus_join_participant %s and %s\n", c_sel->_callID, c_drag->_callID);
+    DEBUG("dbus_detach_participant %s\n", c->_callID);
 
     GError* error = NULL;
-    
-    org_sflphone_SFLphone_CallManager_join_participant (
-             callManagerProxy, 
-	     c_sel->_callID, 
-	     c_drag->_callID, 
-	     &error);
+    org_sflphone_SFLphone_CallManager_detach_participant(
+            callManagerProxy,
+            c->_callID,
+            &error);
     if(error)
     {
         g_error_free(error);
diff --git a/sflphone-client-gnome/src/toolbar.c b/sflphone-client-gnome/src/toolbar.c
index b88d67fd13..35995dbb2e 100644
--- a/sflphone-client-gnome/src/toolbar.c
+++ b/sflphone-client-gnome/src/toolbar.c
@@ -30,9 +30,9 @@ is_inserted( GtkWidget* button )
  * Static create_conference
  */
     static void
-conference_button( GtkWidget *widget UNUSED, gpointer   data UNUSED)
+detach_button( GtkWidget *widget UNUSED, gpointer   data UNUSED)
 {
-    sflphone_add_participant();
+    sflphone_detach_participant();
 }
 
 /**
@@ -165,6 +165,7 @@ GtkWidget *create_toolbar ()
 {
     GtkWidget *ret;
     GtkWidget *image;
+    const gchar *label_detach;
 
     ret = gtk_toolbar_new();
     toolbar = ret;
@@ -277,14 +278,16 @@ GtkWidget *create_toolbar ()
     gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(recButton), -1);
 
 
-    conferenceButton = gtk_tool_button_new_from_stock (GTK_STOCK_MEDIA_RECORD);
+    detachButton = gtk_tool_button_new_from_stock (GTK_STOCK_MEDIA_RECORD);
+    label_detach = "Detach";
+    gtk_button_set_label(GTK_BUTTON(detachButton), label_detach);
 #if GTK_CHECK_VERSION(2,12,0)
-    gtk_widget_set_tooltip_text(GTK_WIDGET(conferenceButton), _("Conference"));
+    gtk_widget_set_tooltip_text(GTK_WIDGET(detachButton), _("Detach"));
 #endif
-    gtk_widget_set_state( GTK_WIDGET(conferenceButton), GTK_STATE_INSENSITIVE);
-    g_signal_connect (G_OBJECT (conferenceButton), "clicked",
-            G_CALLBACK (conference_button), NULL);
-    gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(conferenceButton), -1);
+    gtk_widget_set_state( GTK_WIDGET(detachButton), GTK_STATE_INSENSITIVE);
+    g_signal_connect (G_OBJECT (detachButton), "clicked",
+            G_CALLBACK (detach_button), NULL);
+    gtk_toolbar_insert(GTK_TOOLBAR(ret), GTK_TOOL_ITEM(detachButton), -1);
     
 
     return ret;
@@ -334,7 +337,7 @@ toolbar_update_buttons ()
             case CALL_STATE_INCOMING:
                 gtk_widget_set_sensitive( GTK_WIDGET(pickupButton),     TRUE);
                 gtk_widget_set_sensitive( GTK_WIDGET(hangupButton), TRUE);
-		gtk_widget_set_sensitive( GTK_WIDGET(conferenceButton), TRUE);
+		gtk_widget_set_sensitive( GTK_WIDGET(detachButton), TRUE);
                 g_object_ref(callButton);
                 gtk_container_remove(GTK_CONTAINER(toolbar), GTK_WIDGET(callButton));
                 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), pickupButton, 0);
diff --git a/sflphone-client-gnome/src/toolbar.h b/sflphone-client-gnome/src/toolbar.h
index fa9c1b8c23..7c539f34fa 100644
--- a/sflphone-client-gnome/src/toolbar.h
+++ b/sflphone-client-gnome/src/toolbar.h
@@ -34,7 +34,7 @@ GtkToolItem * holdButton;
 GtkToolItem * transfertButton;
 GtkToolItem * unholdButton;
 GtkToolItem * mailboxButton;
-GtkToolItem * conferenceButton;
+GtkToolItem * detachButton;
 GtkToolItem * recButton;
 GtkToolItem * historyButton;
 GtkToolItem * contactButton;
diff --git a/sflphone-common/src/dbus/callmanager-introspec.xml b/sflphone-common/src/dbus/callmanager-introspec.xml
index fe0e6ee099..8777adce85 100644
--- a/sflphone-common/src/dbus/callmanager-introspec.xml
+++ b/sflphone-common/src/dbus/callmanager-introspec.xml
@@ -61,6 +61,14 @@
       <arg type="s" name="drag_callID" direction="in"/>
     </method>
 
+    <method name="detachParticipant">
+      <arg type="s" name="callID" direction="in"/>
+    </method>
+
+    <signal name="displayCoference">
+      <arg type="s" name="confID" direction="out"/>
+    </signal>
+
     <method name="setRecording">
       <arg type="s" name="callID" direction="in"/>
     </method>
diff --git a/sflphone-common/src/dbus/callmanager.cpp b/sflphone-common/src/dbus/callmanager.cpp
index ed4ebe3741..f8d7593fb0 100644
--- a/sflphone-common/src/dbus/callmanager.cpp
+++ b/sflphone-common/src/dbus/callmanager.cpp
@@ -131,6 +131,16 @@ CallManager::joinParticipant (const std::string& sel_callID, const std::string&
     Manager::instance().joinParticipant(sel_callID, drag_callID);
 }
 
+void
+CallManager::detachParticipant (const std::string& callID)
+{
+    _debug ("CallManager::detachParticipant received %s\n", callID.c_str());
+    // Manager::instance().detachParticipant(callID);
+}
+
+
+
+
 void
 CallManager::setRecording (const std::string& callID)
 {
diff --git a/sflphone-common/src/dbus/callmanager.h b/sflphone-common/src/dbus/callmanager.h
index 31da18b455..ea54252e14 100644
--- a/sflphone-common/src/dbus/callmanager.h
+++ b/sflphone-common/src/dbus/callmanager.h
@@ -50,6 +50,7 @@ public:
     double getVolume( const std::string& device );
     void addParticipant( const std::string& callID );
     void joinParticipant( const std::string& sel_callID, const std::string& drag_callID );
+    void detachParticipant( const std::string& callID );
     void setRecording( const std::string& callID );
     bool getIsRecording(const std::string& callID);
     std::string getCurrentCodecName(const std::string& callID);
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index 59f1a42888..828bff1c2f 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -775,7 +775,7 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
 	}
 	else if(iter->second == "INCOMING")
 	{
-	    _debug("    INCOMING %s\n", call_id1.c_str());
+	    _debug("    ANSWER %s\n", call_id1.c_str());
 	    answerCall(call_id1);
 	}
 
@@ -789,7 +789,7 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
 	}
 	else if(iter->second == "INCOMING")
 	{
-	    _debug("    INCOMING %s\n", call_id2.c_str());
+	    _debug("    ANSWER %s\n", call_id2.c_str());
 	    answerCall(call_id2);
 	}
 	
-- 
GitLab