From b79320b2c33eb5d24aa866b429ee7599f5c7edf3 Mon Sep 17 00:00:00 2001
From: Alexandre Savard <alexandre.savard@savoirfairelinux.net>
Date: Thu, 6 Aug 2009 11:23:49 -0400
Subject: [PATCH] [#1883] Add sflphone-client "addParticipant" button for
 conference Which send a signal through DBUS

---
 sflphone-client-gnome/src/actions.c           |  9 +++++++++
 sflphone-client-gnome/src/actions.h           |  2 ++
 .../src/dbus/callmanager-introspec.xml        |  4 ++++
 sflphone-client-gnome/src/dbus/dbus.c         | 19 ++++++++++++++++++
 sflphone-client-gnome/src/dbus/dbus.h         |  2 ++
 sflphone-client-gnome/src/toolbar.c           | 20 +++++++++++++++++++
 sflphone-client-gnome/src/toolbar.h           |  1 +
 sflphone-common/src/conference.cpp            |  2 +-
 .../src/dbus/callmanager-introspec.xml        |  4 ++++
 sflphone-common/src/dbus/callmanager.cpp      |  7 +++++++
 sflphone-common/src/dbus/callmanager.h        |  1 +
 sflphone-common/src/managerimpl.cpp           |  7 +++++++
 sflphone-common/src/managerimpl.h             |  2 ++
 13 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c
index d8903ad6fd..ea6076d0fb 100644
--- a/sflphone-client-gnome/src/actions.c
+++ b/sflphone-client-gnome/src/actions.c
@@ -832,6 +832,15 @@ sflphone_get_current_codec_name()
     return dbus_get_current_codec_name(selectedCall);
 }
 
+    void
+sflphone_add_participant()
+{
+    DEBUG("sflphone add participant to conference");
+
+    callable_obj_t * selectedCall = calltab_get_selected_call(current_calls);
+    dbus_add_participant(selectedCall);
+}
+
     void
 sflphone_rec_call()
 {
diff --git a/sflphone-client-gnome/src/actions.h b/sflphone-client-gnome/src/actions.h
index 4c1951d541..bdddd5bf7e 100644
--- a/sflphone-client-gnome/src/actions.h
+++ b/sflphone-client-gnome/src/actions.h
@@ -166,6 +166,8 @@ void sflphone_set_current_account();
  */
 void sflphone_fill_codec_list();
 
+void sflphone_add_participant();
+
 void sflphone_record (callable_obj_t *c);
 
 void sflphone_rec_call (void);
diff --git a/sflphone-client-gnome/src/dbus/callmanager-introspec.xml b/sflphone-client-gnome/src/dbus/callmanager-introspec.xml
index 539c13b6e7..6af63fcc61 100644
--- a/sflphone-client-gnome/src/dbus/callmanager-introspec.xml
+++ b/sflphone-client-gnome/src/dbus/callmanager-introspec.xml
@@ -52,6 +52,10 @@
       <arg type="d" name="value" direction="out"/>
     </method>
 
+    <method name="addParticipant">
+      <arg type="s" name="callID" direction="in"/>
+    </method>
+
     <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 b4ad2226df..bd70aa5c0f 100644
--- a/sflphone-client-gnome/src/dbus/dbus.c
+++ b/sflphone-client-gnome/src/dbus/dbus.c
@@ -1228,6 +1228,25 @@ dbus_set_volume_controls(  )
     }
 }
 
+    void
+dbus_add_participant(const callable_obj_t * c)
+{
+
+    DEBUG("calling dbus_add_participant on CallManager");
+    DEBUG("CallID : %s", c->_callID);
+
+    GError* error = NULL;
+    org_sflphone_SFLphone_CallManager_add_participant(
+            callManagerProxy,
+            c->_callID,
+            &error);
+    if(error)
+    {
+        g_error_free(error);
+    }
+    
+}
+
 
     void
 dbus_set_record(const callable_obj_t * c)
diff --git a/sflphone-client-gnome/src/dbus/dbus.h b/sflphone-client-gnome/src/dbus/dbus.h
index 0c46d263da..7e241c9cf7 100644
--- a/sflphone-client-gnome/src/dbus/dbus.h
+++ b/sflphone-client-gnome/src/dbus/dbus.h
@@ -447,6 +447,8 @@ void dbus_set_stun_server( gchar* server);
 gint dbus_stun_is_enabled (void);
 void dbus_enable_stun (void);
 
+void dbus_add_participant(const callable_obj_t * c);
+
 void dbus_set_record (const callable_obj_t * c);
 
 void dbus_set_record_path (const gchar *path);
diff --git a/sflphone-client-gnome/src/toolbar.c b/sflphone-client-gnome/src/toolbar.c
index 428e829c49..6b250973db 100644
--- a/sflphone-client-gnome/src/toolbar.c
+++ b/sflphone-client-gnome/src/toolbar.c
@@ -26,6 +26,15 @@ is_inserted( GtkWidget* button )
     return ( GTK_WIDGET(button)->parent == GTK_WIDGET( toolbar ) );
 }
 
+/**
+ * Static create_conference
+ */
+    static void
+conference_button( GtkWidget *widget UNUSED, gpointer   data UNUSED)
+{
+    sflphone_add_participant();
+}
+
 /**
  * Static rec_button
  */
@@ -268,6 +277,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);
+#if GTK_CHECK_VERSION(2,12,0)
+    gtk_widget_set_tooltip_text(GTK_WIDGET(conferenceButton), _("Conference"));
+#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);
+    
+
     return ret;
 }
 
@@ -344,6 +363,7 @@ toolbar_update_buttons ()
                 gtk_widget_set_sensitive( GTK_WIDGET(transfertButton),  TRUE);
                 gtk_widget_set_sensitive( GTK_WIDGET(callButton),       TRUE);
                 gtk_widget_set_sensitive( GTK_WIDGET(recButton),        TRUE);
+		gtk_widget_set_sensitive( GTK_WIDGET(conferenceButton), TRUE);
                 break;
             case CALL_STATE_BUSY:
             case CALL_STATE_FAILURE:
diff --git a/sflphone-client-gnome/src/toolbar.h b/sflphone-client-gnome/src/toolbar.h
index 5af6e834e9..fa9c1b8c23 100644
--- a/sflphone-client-gnome/src/toolbar.h
+++ b/sflphone-client-gnome/src/toolbar.h
@@ -34,6 +34,7 @@ GtkToolItem * holdButton;
 GtkToolItem * transfertButton;
 GtkToolItem * unholdButton;
 GtkToolItem * mailboxButton;
+GtkToolItem * conferenceButton;
 GtkToolItem * recButton;
 GtkToolItem * historyButton;
 GtkToolItem * contactButton;
diff --git a/sflphone-common/src/conference.cpp b/sflphone-common/src/conference.cpp
index db8e1a3489..62a4112c86 100644
--- a/sflphone-common/src/conference.cpp
+++ b/sflphone-common/src/conference.cpp
@@ -60,7 +60,7 @@ void Conference::remove(CallID participant_id)
 	ParticipantSet::iterator iter = _participants.begin();
 
 	for(iter = _participants.begin(); iter != _participants.end(); iter++)
-	    Manager::instance().getAudioDriver()->getMainBuffer()->bindCallID(participant_id, *iter);
+	    Manager::instance().getAudioDriver()->getMainBuffer()->unBindCallID(participant_id, *iter);
     }
 
     _participants.erase(participant_id);
diff --git a/sflphone-common/src/dbus/callmanager-introspec.xml b/sflphone-common/src/dbus/callmanager-introspec.xml
index dd7df126a9..f405c4de1b 100644
--- a/sflphone-common/src/dbus/callmanager-introspec.xml
+++ b/sflphone-common/src/dbus/callmanager-introspec.xml
@@ -52,6 +52,10 @@
       <arg type="d" name="value" direction="out"/>
     </method>
 
+    <method name="addParticipant">
+      <arg type="s" name="callID" direction="in"/>
+    </method>
+
     <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 88f2e349a1..4d536a50cf 100644
--- a/sflphone-common/src/dbus/callmanager.cpp
+++ b/sflphone-common/src/dbus/callmanager.cpp
@@ -117,6 +117,13 @@ CallManager::getVolume (const std::string& device)
     return 0;
 }
 
+void
+CallManager::addParticipant (const std::string& callID)
+{
+    _debug ("CallManager::addParticipant received %s\n", callID.c_str());
+    // Manager::instance().setRecordingCall (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 0d8a93a9a3..60f5df15af 100644
--- a/sflphone-common/src/dbus/callmanager.h
+++ b/sflphone-common/src/dbus/callmanager.h
@@ -48,6 +48,7 @@ public:
     void transfert( const std::string& callID, const std::string& to );
     void setVolume( const std::string& device, const double& value );
     double getVolume( const std::string& device );
+    void addParticipant( 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 3fc1494d63..484df3e8e5 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -622,6 +622,13 @@ ManagerImpl::refuseCall (const CallID& id)
     return returnValue;
 }
 
+
+void
+ManagerImpl::createConference()
+{
+    _debug("ManagerImpl::createConference()\n");
+}
+
 //THREAD=Main
 bool
 ManagerImpl::saveConfig (void)
diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h
index eef8c251f6..286e765263 100644
--- a/sflphone-common/src/managerimpl.h
+++ b/sflphone-common/src/managerimpl.h
@@ -175,6 +175,8 @@ class ManagerImpl {
      */
     bool refuseCall(const CallID& id);
 
+    void createConference();
+
     /**
      * Save config to file
      * @return true on success
-- 
GitLab