From c81d508cd10e8196a0fc56912bb8518d8540ea07 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Fri, 24 May 2013 13:49:58 -0400
Subject: [PATCH] * #24789: callmanager: return bools in detachParticipant

---
 daemon/src/dbus/callmanager-introspec.xml |  2 ++
 daemon/src/dbus/callmanager.cpp           |  4 ++--
 daemon/src/dbus/callmanager.h             |  2 +-
 daemon/src/managerimpl.cpp                | 21 +++++++++++----------
 daemon/src/managerimpl.h                  |  3 ++-
 gnome/src/dbus/callmanager-introspec.xml  |  2 ++
 gnome/src/dbus/dbus.c                     |  4 +++-
 7 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/daemon/src/dbus/callmanager-introspec.xml b/daemon/src/dbus/callmanager-introspec.xml
index 9f155ce5ad..ea9e3c76da 100644
--- a/daemon/src/dbus/callmanager-introspec.xml
+++ b/daemon/src/dbus/callmanager-introspec.xml
@@ -298,6 +298,8 @@
                 The call ID
               </tp:docstring>
             </arg>
+            <arg type="b" name="detachSucceeded" direction="out">
+            </arg>
         </method>
 
         <method name="joinConference" tp:name-for-bindings="joinConference">
diff --git a/daemon/src/dbus/callmanager.cpp b/daemon/src/dbus/callmanager.cpp
index 988596369e..cd26482769 100644
--- a/daemon/src/dbus/callmanager.cpp
+++ b/daemon/src/dbus/callmanager.cpp
@@ -194,10 +194,10 @@ CallManager::addMainParticipant(const std::string& confID)
     return Manager::instance().addMainParticipant(confID);
 }
 
-void
+bool
 CallManager::detachParticipant(const std::string& callID)
 {
-    Manager::instance().detachParticipant(callID, "");
+    return Manager::instance().detachParticipant(callID, "");
 }
 
 void
diff --git a/daemon/src/dbus/callmanager.h b/daemon/src/dbus/callmanager.h
index 3f95dcf4a8..445cc23512 100644
--- a/daemon/src/dbus/callmanager.h
+++ b/daemon/src/dbus/callmanager.h
@@ -92,7 +92,7 @@ class CallManager
         void createConfFromParticipantList(const std::vector< std::string >& participants);
         bool addParticipant(const std::string& callID, const std::string& confID);
         bool addMainParticipant(const std::string& confID);
-        void detachParticipant(const std::string& callID);
+        bool detachParticipant(const std::string& callID);
         void joinConference(const std::string& sel_confID, const std::string& drag_confID);
         bool hangUpConference(const std::string& confID);
         bool holdConference(const std::string& confID);
diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index cd23d063ab..ff7e95ee8d 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -1106,26 +1106,25 @@ void ManagerImpl::createConfFromParticipantList(const std::vector< std::string >
     }
 }
 
-void ManagerImpl::detachParticipant(const std::string& call_id,
-                                    const std::string& current_id)
+bool
+ManagerImpl::detachParticipant(const std::string& call_id,
+                               const std::string& current_id)
 {
-    DEBUG("Detach participant %s (current id: %s)", call_id.c_str(),
-           current_id.c_str());
-    std::string current_call_id(getCurrentCallId());
+    const std::string current_call_id(getCurrentCallId());
 
     if (call_id != MainBuffer::DEFAULT_ID) {
         Call *call = getCallFromCallID(call_id);
 
         if (call == NULL) {
             ERROR("Could not find call %s", call_id.c_str());
-            return;
+            return false;
         }
 
         Conference *conf = getConferenceFromCallID(call_id);
 
         if (conf == NULL) {
             ERROR("Call is not conferencing, cannot detach");
-            return;
+            return false;
         }
 
         std::map<std::string, std::string> call_details(getCallDetails(call_id));
@@ -1133,7 +1132,7 @@ void ManagerImpl::detachParticipant(const std::string& call_id,
 
         if (iter_details == call_details.end()) {
             ERROR("Could not find CALL_STATE");
-            return;
+            return false;
         }
 
         if (iter_details->second == "RINGING") {
@@ -1150,7 +1149,7 @@ void ManagerImpl::detachParticipant(const std::string& call_id,
 
         if (not isConference(current_call_id)) {
             ERROR("Current call id (%s) is not a conference", current_call_id.c_str());
-            return;
+            return false;
         }
 
         ConferenceMap::iterator iter = conferenceMap_.find(current_call_id);
@@ -1158,7 +1157,7 @@ void ManagerImpl::detachParticipant(const std::string& call_id,
         Conference *conf = iter->second;
         if (iter == conferenceMap_.end() or conf == 0) {
             DEBUG("Conference is NULL");
-            return;
+            return false;
         }
 
         if (conf->getState() == Conference::ACTIVE_ATTACHED)
@@ -1173,6 +1172,8 @@ void ManagerImpl::detachParticipant(const std::string& call_id,
 
         unsetCurrentCall();
     }
+
+    return true;
 }
 
 void ManagerImpl::removeParticipant(const std::string& call_id)
diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h
index 987b23327c..83cf10c195 100644
--- a/daemon/src/managerimpl.h
+++ b/daemon/src/managerimpl.h
@@ -308,7 +308,8 @@ class ManagerImpl {
          * @param call id
          * @param the current call id
          */
-        void detachParticipant(const std::string& call_id, const std::string& current_call_id);
+        bool detachParticipant(const std::string& call_id,
+                               const std::string& current_call_id);
 
         /**
          * Remove the conference participant from a conference
diff --git a/gnome/src/dbus/callmanager-introspec.xml b/gnome/src/dbus/callmanager-introspec.xml
index 9f155ce5ad..ea9e3c76da 100644
--- a/gnome/src/dbus/callmanager-introspec.xml
+++ b/gnome/src/dbus/callmanager-introspec.xml
@@ -298,6 +298,8 @@
                 The call ID
               </tp:docstring>
             </arg>
+            <arg type="b" name="detachSucceeded" direction="out">
+            </arg>
         </method>
 
         <method name="joinConference" tp:name-for-bindings="joinConference">
diff --git a/gnome/src/dbus/dbus.c b/gnome/src/dbus/dbus.c
index 64061885ef..7b69b57234 100644
--- a/gnome/src/dbus/dbus.c
+++ b/gnome/src/dbus/dbus.c
@@ -1509,7 +1509,9 @@ void
 dbus_detach_participant(const gchar *callID)
 {
     GError *error = NULL;
-    org_sflphone_SFLphone_CallManager_detach_participant(call_proxy, callID, &error);
+    gboolean result;
+    org_sflphone_SFLphone_CallManager_detach_participant(call_proxy, callID,
+            &result, &error);
     check_error(error);
 }
 
-- 
GitLab