From 395a7982b5386268cfc45053ddf132490ba8d19d Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Fri, 24 May 2013 11:29:33 -0400
Subject: [PATCH] * #24789: callmanager: accept/refuse now return bool

---
 daemon/src/dbus/callmanager-introspec.xml | 28 ++++++++++-------------
 daemon/src/dbus/callmanager.cpp           | 17 +++++++-------
 daemon/src/dbus/callmanager.h             |  8 +++----
 daemon/src/managerimpl.cpp                | 12 +++++++---
 daemon/src/managerimpl.h                  |  2 +-
 gnome/src/dbus/callmanager-introspec.xml  | 28 ++++++++++-------------
 gnome/src/dbus/dbus.c                     | 13 +++++++----
 7 files changed, 56 insertions(+), 52 deletions(-)

diff --git a/daemon/src/dbus/callmanager-introspec.xml b/daemon/src/dbus/callmanager-introspec.xml
index 8a4d324c82..2382dfbc60 100644
--- a/daemon/src/dbus/callmanager-introspec.xml
+++ b/daemon/src/dbus/callmanager-introspec.xml
@@ -58,6 +58,8 @@
                 The callID.
               </tp:docstring>
             </arg>
+            <arg type="b" name="refuseSucceeded" direction="out">
+            </arg>
 
         </method>
 
@@ -70,6 +72,8 @@
                 The callID.
               </tp:docstring>
             </arg>
+            <arg type="b" name="acceptSucceeded" direction="out">
+            </arg>
         </method>
 
         <method name="hangUp" tp:name-for-bindings="hangUp">
@@ -81,10 +85,7 @@
                 The callID.
               </tp:docstring>
             </arg>
-            <arg type="b" name="isHungUp" direction="out">
-              <tp:docstring>
-                Returns true is the call has been hungup. False otherwise.
-              </tp:docstring>
+            <arg type="b" name="hangupSucceeded" direction="out">
             </arg>
         </method>
 
@@ -98,10 +99,7 @@
                 The unique conference ID.
               </tp:docstring>
             </arg>
-            <arg type="b" name="isHungUp" direction="out">
-              <tp:docstring>
-                Returns true is the conference has been hungup. False otherwise.
-              </tp:docstring>
+            <arg type="b" name="hangupSucceeded" direction="out">
             </arg>
         </method>
 
@@ -114,10 +112,7 @@
                 The callID.
               </tp:docstring>
             </arg>
-            <arg type="b" name="isOnHold" direction="out">
-              <tp:docstring>
-                Returns true is the call has been put on hold. False otherwise.
-              </tp:docstring>
+            <arg type="b" name="holdSucceeded" direction="out">
             </arg>
         </method>
 
@@ -130,10 +125,7 @@
                 The callID.
               </tp:docstring>
             </arg>
-            <arg type="b" name="isOffHold" direction="out">
-              <tp:docstring>
-                Returns true is the call has been taken off hold. False otherwise.
-              </tp:docstring>
+            <arg type="b" name="offHoldSucceeded" direction="out">
             </arg>
         </method>
 
@@ -151,6 +143,8 @@
                 The phone number to which the call will be transferred.
               </tp:docstring>
             </arg>
+            <arg type="b" name="transferSucceeded" direction="out">
+            </arg>
         </method>
 
         <method name="attendedTransfer" tp:name-for-bindings="attendedTransfer">
@@ -167,6 +161,8 @@
                 The callID of the target call.
               </tp:docstring>
             </arg>
+            <arg type="b" name="transferSucceeded" direction="out">
+            </arg>
         </method>
 
         <method name="playDTMF" tp:name-for-bindings="playDTMF">
diff --git a/daemon/src/dbus/callmanager.cpp b/daemon/src/dbus/callmanager.cpp
index 744962c36e..671ae2d9cf 100644
--- a/daemon/src/dbus/callmanager.cpp
+++ b/daemon/src/dbus/callmanager.cpp
@@ -84,16 +84,16 @@ void CallManager::placeCallFirstAccount(const std::string& callID,
     }
 }
 
-void
+bool
 CallManager::refuse(const std::string& callID)
 {
-    Manager::instance().refuseCall(callID);
+    return Manager::instance().refuseCall(callID);
 }
 
-void
+bool
 CallManager::accept(const std::string& callID)
 {
-    Manager::instance().answerCall(callID);
+    return Manager::instance().answerCall(callID);
 }
 
 bool
@@ -120,15 +120,16 @@ CallManager::unhold(const std::string& callID)
     return Manager::instance().offHoldCall(callID);
 }
 
-void
+bool
 CallManager::transfer(const std::string& callID, const std::string& to)
 {
-    Manager::instance().transferCall(callID, to);
+    return Manager::instance().transferCall(callID, to);
 }
 
-void CallManager::attendedTransfer(const std::string& transferID, const std::string& targetID)
+bool
+CallManager::attendedTransfer(const std::string& transferID, const std::string& targetID)
 {
-    Manager::instance().attendedTransfer(transferID, targetID);
+    return Manager::instance().attendedTransfer(transferID, targetID);
 }
 
 void CallManager::setVolume(const std::string& device, const double& value)
diff --git a/daemon/src/dbus/callmanager.h b/daemon/src/dbus/callmanager.h
index 63254f74ec..66abbc84de 100644
--- a/daemon/src/dbus/callmanager.h
+++ b/daemon/src/dbus/callmanager.h
@@ -76,13 +76,13 @@ class CallManager
         void placeCall(const std::string& accountID, const std::string& callID, const std::string& to);
         void placeCallFirstAccount(const std::string& callID, const std::string& to);
 
-        void refuse(const std::string& callID);
-        void accept(const std::string& callID);
+        bool refuse(const std::string& callID);
+        bool accept(const std::string& callID);
         bool hangUp(const std::string& callID);
         bool hold(const std::string& callID);
         bool unhold(const std::string& callID);
-        void transfer(const std::string& callID, const std::string& to);
-        void attendedTransfer(const std::string& transferID, const std::string& targetID);
+        bool transfer(const std::string& callID, const std::string& to);
+        bool attendedTransfer(const std::string& transferID, const std::string& targetID);
         std::map< std::string, std::string > getCallDetails(const std::string& callID);
         std::vector< std::string > getCallList();
         bool isValidCall(const std::string &callID);
diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index f2a5a00b86..3ba8670d32 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -325,6 +325,7 @@ bool ManagerImpl::outgoingCall(const std::string& account_id,
 //THREAD=Main : for outgoing Call
 bool ManagerImpl::answerCall(const std::string& call_id)
 {
+    bool result = true;
     Call *call = getCallFromCallID(call_id);
 
     if (call == NULL) {
@@ -364,6 +365,7 @@ bool ManagerImpl::answerCall(const std::string& call_id)
             link->answer(call);
     } catch (const std::runtime_error &e) {
         ERROR("%s", e.what());
+        result = false;
     }
 
     // if it was waiting, it's waiting no more
@@ -386,7 +388,7 @@ bool ManagerImpl::answerCall(const std::string& call_id)
 
     // update call state on client side
     dbus_.getCallManager()->callStateChanged(call_id, "CURRENT");
-    return true;
+    return result;
 }
 
 //THREAD=Main
@@ -631,8 +633,11 @@ bool ManagerImpl::attendedTransfer(const std::string& transferID, const std::str
 }
 
 //THREAD=Main : Call:Incoming
-void ManagerImpl::refuseCall(const std::string& id)
+bool ManagerImpl::refuseCall(const std::string& id)
 {
+    if (!isValidCall(id))
+        return false;
+
     stopTone();
 
     if (getCallList().size() <= 1) {
@@ -649,7 +654,7 @@ void ManagerImpl::refuseCall(const std::string& id)
         std::string accountid = getAccountFromCall(id);
 
         if (accountid.empty())
-            return;
+            return false;
 
         getAccountLink(accountid)->refuse(id);
 
@@ -663,6 +668,7 @@ void ManagerImpl::refuseCall(const std::string& id)
     removeStream(id);
 
     getMainBuffer().dumpInfo();
+    return true;
 }
 
 Conference*
diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h
index 7cb53c5b4f..f0a673be24 100644
--- a/daemon/src/managerimpl.h
+++ b/daemon/src/managerimpl.h
@@ -232,7 +232,7 @@ class ManagerImpl {
          * Refuse the call
          * @param id  The call identifier
          */
-        void refuseCall(const std::string& id);
+        bool refuseCall(const std::string& id);
 
         /**
          * Create a new conference given two participant
diff --git a/gnome/src/dbus/callmanager-introspec.xml b/gnome/src/dbus/callmanager-introspec.xml
index 8a4d324c82..2382dfbc60 100644
--- a/gnome/src/dbus/callmanager-introspec.xml
+++ b/gnome/src/dbus/callmanager-introspec.xml
@@ -58,6 +58,8 @@
                 The callID.
               </tp:docstring>
             </arg>
+            <arg type="b" name="refuseSucceeded" direction="out">
+            </arg>
 
         </method>
 
@@ -70,6 +72,8 @@
                 The callID.
               </tp:docstring>
             </arg>
+            <arg type="b" name="acceptSucceeded" direction="out">
+            </arg>
         </method>
 
         <method name="hangUp" tp:name-for-bindings="hangUp">
@@ -81,10 +85,7 @@
                 The callID.
               </tp:docstring>
             </arg>
-            <arg type="b" name="isHungUp" direction="out">
-              <tp:docstring>
-                Returns true is the call has been hungup. False otherwise.
-              </tp:docstring>
+            <arg type="b" name="hangupSucceeded" direction="out">
             </arg>
         </method>
 
@@ -98,10 +99,7 @@
                 The unique conference ID.
               </tp:docstring>
             </arg>
-            <arg type="b" name="isHungUp" direction="out">
-              <tp:docstring>
-                Returns true is the conference has been hungup. False otherwise.
-              </tp:docstring>
+            <arg type="b" name="hangupSucceeded" direction="out">
             </arg>
         </method>
 
@@ -114,10 +112,7 @@
                 The callID.
               </tp:docstring>
             </arg>
-            <arg type="b" name="isOnHold" direction="out">
-              <tp:docstring>
-                Returns true is the call has been put on hold. False otherwise.
-              </tp:docstring>
+            <arg type="b" name="holdSucceeded" direction="out">
             </arg>
         </method>
 
@@ -130,10 +125,7 @@
                 The callID.
               </tp:docstring>
             </arg>
-            <arg type="b" name="isOffHold" direction="out">
-              <tp:docstring>
-                Returns true is the call has been taken off hold. False otherwise.
-              </tp:docstring>
+            <arg type="b" name="offHoldSucceeded" direction="out">
             </arg>
         </method>
 
@@ -151,6 +143,8 @@
                 The phone number to which the call will be transferred.
               </tp:docstring>
             </arg>
+            <arg type="b" name="transferSucceeded" direction="out">
+            </arg>
         </method>
 
         <method name="attendedTransfer" tp:name-for-bindings="attendedTransfer">
@@ -167,6 +161,8 @@
                 The callID of the target call.
               </tp:docstring>
             </arg>
+            <arg type="b" name="transferSucceeded" direction="out">
+            </arg>
         </method>
 
         <method name="playDTMF" tp:name-for-bindings="playDTMF">
diff --git a/gnome/src/dbus/dbus.c b/gnome/src/dbus/dbus.c
index 35ae9fd310..98bd6c1d42 100644
--- a/gnome/src/dbus/dbus.c
+++ b/gnome/src/dbus/dbus.c
@@ -997,7 +997,9 @@ void
 dbus_transfer(const callable_obj_t *c)
 {
     GError *error = NULL;
-    org_sflphone_SFLphone_CallManager_transfer(call_proxy, c->_callID, c->_trsft_to, &error);
+    gboolean result;
+    org_sflphone_SFLphone_CallManager_transfer(call_proxy, c->_callID,
+            c->_trsft_to, &result, &error);
     check_error(error);
 }
 
@@ -1005,8 +1007,9 @@ void
 dbus_attended_transfer(const callable_obj_t *transfer, const callable_obj_t *target)
 {
     GError *error = NULL;
+    gboolean result;
     org_sflphone_SFLphone_CallManager_attended_transfer(call_proxy, transfer->_callID,
-                           target->_callID, &error);
+                           target->_callID, &result, &error);
     check_error(error);
 }
 
@@ -1015,7 +1018,8 @@ dbus_accept(const callable_obj_t *c)
 {
     status_tray_icon_blink(FALSE);
     GError *error = NULL;
-    org_sflphone_SFLphone_CallManager_accept(call_proxy, c->_callID, &error);
+    gboolean result;
+    org_sflphone_SFLphone_CallManager_accept(call_proxy, c->_callID, &result, &error);
     check_error(error);
 }
 
@@ -1024,7 +1028,8 @@ dbus_refuse(const callable_obj_t *c)
 {
     status_tray_icon_blink(FALSE);
     GError *error = NULL;
-    org_sflphone_SFLphone_CallManager_refuse(call_proxy, c->_callID, &error);
+    gboolean result;
+    org_sflphone_SFLphone_CallManager_refuse(call_proxy, c->_callID, &result, &error);
     check_error(error);
 }
 
-- 
GitLab