[ekiga/ds-gtk-application] Call Core: Fixed call & transfer actions validity check.



commit 4a9ab71205eb4dee2ebd3ef4299ba470aa7af374
Author: Damien Sandras <dsandras beip be>
Date:   Sat Mar 29 17:20:49 2014 +0100

    Call Core: Fixed call & transfer actions validity check.
    
    We should only be able to call when there is no active call.
    We should only be able to transfer when there is one active call.

 lib/engine/protocol/call-core.cpp |   16 ++++++++++++++--
 lib/engine/protocol/call-core.h   |    3 ++-
 2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/lib/engine/protocol/call-core.cpp b/lib/engine/protocol/call-core.cpp
index 6f68b00..bdfc1e7 100644
--- a/lib/engine/protocol/call-core.cpp
+++ b/lib/engine/protocol/call-core.cpp
@@ -154,10 +154,10 @@ void CallCore::register_actions (boost::shared_ptr<ContactCore> _contact_core)
   contact_core = _contact_core;
   ActionPtr call (new ContactAction ("call", _("Call"),
                                      boost::bind (&CallCore::dial, this, _2),
-                                     boost::bind (&CallCore::is_supported_uri, this, _2)));
+                                     boost::bind (&CallCore::can_call, this, _2)));
   ActionPtr xfer (new ContactAction ("transfer", _("Transfer"),
                                      boost::bind (&CallCore::transfer, this, _2, false),
-                                     boost::bind (&CallCore::is_supported_uri, this, _2)));
+                                     boost::bind (&CallCore::can_transfer, this, _2)));
   ActionPtr msg (new ContactAction ("message", _("Message"),
                                     boost::bind (&CallCore::message, this, _1, _2),
                                     boost::bind (&CallCore::is_supported_uri, this, _2)));
@@ -285,3 +285,15 @@ void CallCore::on_call_removed (boost::shared_ptr<Call> call)
 {
   remove_call (call);
 }
+
+
+bool CallCore::can_call (const std::string & uri)
+{
+  return (is_supported_uri (uri) && call_connections.size () == 0);
+}
+
+
+bool CallCore::can_transfer (const std::string & uri)
+{
+  return (is_supported_uri (uri) && call_connections.size () > 0);
+}
diff --git a/lib/engine/protocol/call-core.h b/lib/engine/protocol/call-core.h
index eb6bab2..6acc19e 100644
--- a/lib/engine/protocol/call-core.h
+++ b/lib/engine/protocol/call-core.h
@@ -218,7 +218,8 @@ namespace Ekiga
       void on_manager_ready (boost::shared_ptr<CallManager> manager);
 
       void on_call_removed (boost::shared_ptr<Call> call);
-
+      bool can_call (const std::string & uri);
+      bool can_transfer (const std::string & uri);
 
       std::set<boost::shared_ptr<CallManager> > managers;
       std::map<std::string, boost::shared_ptr<Ekiga::scoped_connections> > call_connections;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]