[ekiga/ds-gtk-application] Opal::Call: Added Actor actions.



commit decf3900928b808d4f2a71e83e0d6e3637b80d8d
Author: Damien Sandras <dsandras seconix com>
Date:   Sun Nov 2 16:07:15 2014 +0100

    Opal::Call: Added Actor actions.
    
    - hangup: to hangup the current call
    - transfer: to transfer the current call. A popup is displayed to ask
      the user about the transfer uri. The uri domain is optional.
    - hold: to hold the current call.

 lib/engine/components/opal/opal-call.cpp |   65 +++++++++++++++++++++++++++++-
 lib/engine/components/opal/opal-call.h   |   13 +++++-
 2 files changed, 76 insertions(+), 2 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-call.cpp b/lib/engine/components/opal/opal-call.cpp
index bae3533..7a47b9d 100644
--- a/lib/engine/components/opal/opal-call.cpp
+++ b/lib/engine/components/opal/opal-call.cpp
@@ -114,6 +114,16 @@ Opal::Call::Call (Opal::CallManager& _manager,
   re_a_bw = tr_a_bw = re_v_bw = tr_v_bw = 0.0;
 
   NoAnswerTimer.SetNotifier (PCREATE_NOTIFIER (OnNoAnswerTimeout));
+
+  add_action (Ekiga::ActionPtr (new Ekiga::Action ("hangup", _("Hangup"),
+                                                   boost::bind (&Call::hang_up, this))));
+}
+
+Opal::Call::~Call ()
+{
+  remove_action ("hangup");
+  remove_action ("transfer");
+  remove_action ("hold");
 }
 
 void
@@ -147,6 +157,24 @@ Opal::Call::answer ()
 
 
 void
+Opal::Call::transfer ()
+{
+  boost::shared_ptr<Ekiga::FormRequestSimple> request =
+    boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind 
(&Opal::Call::on_transfer_form_submitted, this, _1, _2, _3)));
+
+  request->title (_("Transfer Call"));
+  request->action (_("Transfer"));
+  request->text ("uri", _("Remote URI"),
+                 "",
+                 _("sip:username ekiga net"),
+                 Ekiga::FormVisitor::STANDARD,
+                 false, false);
+
+  Ekiga::Call::questions (request);
+}
+
+
+void
 Opal::Call::transfer (std::string uri)
 {
   PSafePtr<OpalConnection> connection = get_remote_connection ();
@@ -155,6 +183,36 @@ Opal::Call::transfer (std::string uri)
 }
 
 
+bool
+Opal::Call::on_transfer_form_submitted (bool submitted,
+                                        Ekiga::Form& result,
+                                        std::string& error)
+{
+  std::string::size_type idx;
+
+  if (!submitted)
+    return false;
+
+  std::string uri = result.text ("uri");
+
+  /* If the user did not provide a full URI,
+   * use the same "domain" than the call local address
+   */
+  idx = uri.find_first_of ("@");
+  if (idx == std::string::npos)
+    uri = uri + "@" + (const char *) PURL (remote_uri).GetHostName ();
+  if (manager.is_supported_uri (uri)) {
+
+    transfer (uri);
+    return true;
+  }
+  else
+    error = _("You supplied an unsupported address");
+
+  return false;
+}
+
+
 void
 Opal::Call::toggle_hold ()
 {
@@ -356,6 +414,10 @@ Opal::Call::OnEstablished (OpalConnection & connection)
 
   if (!PIsDescendant(&connection, OpalPCSSConnection)) {
 
+    add_action (Ekiga::ActionPtr (new Ekiga::Action ("hold", _("Hold"),
+                                                     boost::bind (&Call::toggle_hold, this))));
+    add_action (Ekiga::ActionPtr (new Ekiga::Action ("transfer", _("Transfer"),
+                                                     boost::bind (&Call::transfer, this))));
     parse_info (connection);
     Ekiga::Runtime::run_in_main (boost::bind (&Opal::Call::emit_established_in_main, this));
   }
@@ -525,8 +587,8 @@ Opal::Call::OnSetUp (OpalConnection & connection)
   outgoing = !IsNetworkOriginated ();
   parse_info (connection);
 
-  Ekiga::Runtime::run_in_main (boost::bind (&Opal::Call::emit_setup_in_main, this));
   call_setup = true;
+  Ekiga::Runtime::run_in_main (boost::bind (&Opal::Call::emit_setup_in_main, this));
 
   new CallSetup (*this, connection);
 
@@ -672,6 +734,7 @@ Opal::Call::OnNoAnswerTimeout (PTimer &,
 void
 Opal::Call::emit_established_in_main ()
 {
+  std::cout << "Call Established " << this << std::endl << std::flush;
   established ();
 }
 
diff --git a/lib/engine/components/opal/opal-call.h b/lib/engine/components/opal/opal-call.h
index 6968419..264eefd 100644
--- a/lib/engine/components/opal/opal-call.h
+++ b/lib/engine/components/opal/opal-call.h
@@ -41,6 +41,7 @@
 #include "call.h"
 
 #include "notification-core.h"
+#include "form-request-simple.h"
 
 #ifndef __OPAL_CALL_H__
 #define __OPAL_CALL_H__
@@ -64,6 +65,7 @@ public:
 
     Call (CallManager &_manager,
           const std::string & uri);
+    ~Call ();
 
     /*
      * Call Management
@@ -77,6 +79,11 @@ public:
     */
     void answer ();
 
+    /** Transfer the call.
+     * Opens a popup to ask what uri to transfer to.
+     */
+    void transfer ();
+
     /** Transfer the call to the specified uri
      * @param: uri: where to transfer the call
      */
@@ -89,7 +96,7 @@ public:
     /** Toggle stream transmission (if any)
      * @param type the stream type
      */
-    void toggle_stream_pause (StreamType type);
+    void toggle_stream_pause (Ekiga::Call::StreamType type);
 
     /** Send the given DTMF
      * @param the dtmf (one char)
@@ -199,6 +206,10 @@ private:
     /*
      * Helper methods
      */
+    bool on_transfer_form_submitted (bool submitted,
+                                     Ekiga::Form& result,
+                                     std::string& error);
+
     void parse_info (OpalConnection & connection);
 
     PSafePtr<OpalConnection> get_remote_connection ()


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