ekiga r6316 - in trunk: . lib/engine/protocol/skel src/endpoints



Author: dsandras
Date: Sun May 25 10:11:46 2008
New Revision: 6316
URL: http://svn.gnome.org/viewvc/ekiga?rev=6316&view=rev

Log:
Added back support for call forward on busy/no answer/always at the
Opal::Call level, this feature is indeed not possible with all types
of Calls. Added support for reject after a given delay.


Modified:
   trunk/ChangeLog
   trunk/lib/engine/protocol/skel/call.h
   trunk/src/endpoints/manager.cpp
   trunk/src/endpoints/manager.h
   trunk/src/endpoints/opal-call.cpp
   trunk/src/endpoints/opal-call.h
   trunk/src/endpoints/opal-gmconf-bridge.cpp
   trunk/src/endpoints/sip.cpp
   trunk/src/endpoints/sip.h

Modified: trunk/lib/engine/protocol/skel/call.h
==============================================================================
--- trunk/lib/engine/protocol/skel/call.h	(original)
+++ trunk/lib/engine/protocol/skel/call.h	Sun May 25 10:11:46 2008
@@ -44,10 +44,10 @@
 namespace Ekiga
 {
 
-/**
- * @addtogroup calls
- * @{
- */
+  /**
+   * @addtogroup calls
+   * @{
+   */
 
   /*
    * Everything is handled asynchronously and signaled through the
@@ -71,11 +71,11 @@
        */
 
       /** Hangup the call
-       */
+      */
       virtual void hangup () = 0;
 
       /** Answer an incoming call
-       */
+      */
       virtual void answer () = 0;
 
       /** Transfer the call to the specified uri
@@ -84,7 +84,7 @@
       virtual void transfer (std::string uri) = 0;
 
       /** Put the call on hold or retrieve it
-       */
+      */
       virtual void toggle_hold () = 0;
 
       /** Toggle the stream transmission (if any)
@@ -97,6 +97,12 @@
        */
       virtual void send_dtmf (const char dtmf) = 0;
 
+      /** Reject an incoming call after the given delay
+       * @param delay the delay after which reject the call
+       */
+      virtual void set_reject_delay (unsigned delay) = 0;
+
+
       /*
        * Call Information
        */

Modified: trunk/src/endpoints/manager.cpp
==============================================================================
--- trunk/src/endpoints/manager.cpp	(original)
+++ trunk/src/endpoints/manager.cpp	Sun May 25 10:11:46 2008
@@ -106,12 +106,19 @@
   /* Initialise the endpoint paramaters */
   PIPSocket::SetDefaultIpAddressFamilyV4();
   autoStartTransmitVideo = autoStartReceiveVideo = true;
+  SetUDPPorts (5000, 5100);
+  SetTCPPorts (30000, 30100);
+  SetRtpIpPorts (5000, 5100);
   
   manager = NULL;
 
   h323EP = NULL;
   pcssEP = NULL;
 
+  forward_on_no_answer = false;
+  forward_on_busy = false;
+  unconditional_forward = false;
+
   // Create video devices
   PVideoDevice::OpenArgs video = GetVideoOutputDevice();
   video.deviceName = "EKIGAOUT";
@@ -145,7 +152,7 @@
   call_core = dynamic_cast<Ekiga::CallCore *> (core.get ("call-core"));
 
   // Ready
-  new StunDetector ("stun.ekiga.net", *this, runtime);
+  new StunDetector ("stun.voxgratia.org", *this, runtime);
 }
 
 
@@ -420,13 +427,34 @@
   return list;
 }
 
+void GMManager::set_forward_on_no_answer (bool enabled)
+{
+  forward_on_no_answer = enabled;
+}
+
+bool GMManager::get_forward_on_no_answer ()
+{
+  return forward_on_no_answer;
+}
+
 void GMManager::set_forward_on_busy (bool enabled)
 {
+  forward_on_busy = enabled;
 }
 
+bool GMManager::get_forward_on_busy ()
+{
+  return forward_on_busy;
+}
 
 void GMManager::set_unconditional_forward (bool enabled)
 {
+  unconditional_forward = enabled;
+}
+
+bool GMManager::get_unconditional_forward ()
+{
+  return unconditional_forward;
 }
 
 void GMManager::set_udp_ports (unsigned min_port, 

Modified: trunk/src/endpoints/manager.h
==============================================================================
--- trunk/src/endpoints/manager.h	(original)
+++ trunk/src/endpoints/manager.h	Sun May 25 10:11:46 2008
@@ -118,7 +118,14 @@
 
   /* Extended stuff, OPAL CallManager specific */
   void set_forward_on_busy (bool enabled);
+  bool get_forward_on_busy ();
+
+  void set_forward_on_no_answer (bool enabled);
+  bool get_forward_on_no_answer ();
+
   void set_unconditional_forward (bool enabled);
+  bool get_unconditional_forward ();
+
   void set_udp_ports (unsigned min_port, 
                       unsigned max_port);
 
@@ -192,6 +199,9 @@
 
   std::string display_name;
   unsigned reject_delay;
+  bool forward_on_busy;
+  bool unconditional_forward;
+  bool forward_on_no_answer;
 };
 
 #endif

Modified: trunk/src/endpoints/opal-call.cpp
==============================================================================
--- trunk/src/endpoints/opal-call.cpp	(original)
+++ trunk/src/endpoints/opal-call.cpp	Sun May 25 10:11:46 2008
@@ -184,6 +184,20 @@
 }
 
 
+void Opal::Call::set_no_answer_forward (unsigned delay, const std::string & uri)
+{
+  forward_uri = uri;
+
+  NoAnswerTimer.SetInterval (0, PMIN (delay, 60));
+}
+
+
+void Opal::Call::set_reject_delay (unsigned delay)
+{
+  NoAnswerTimer.SetInterval (0, PMIN (delay, 60));
+}
+
+
 const std::string
 Opal::Call::get_id () const
 {
@@ -441,9 +455,6 @@
 
   runtime.run_in_main (setup.make_slot ());
 
-  if (!outgoing)
-    NoAnswerTimer.SetInterval (0, PMIN (10, 60));
-
   return OpalCall::OnSetUp (connection);
 }
 
@@ -551,8 +562,6 @@
 Opal::Call::OnAnswer (PThread &, INT /*param*/)
 {
   PSafePtr<OpalConnection> connection = NULL;
-  PSafePtr<OpalPCSSConnection> conn = NULL;
-
   int i = 0;
 
   if (!is_outgoing () && !IsEstablished ()) {
@@ -574,24 +583,22 @@
 Opal::Call::OnNoAnswerTimeout (PTimer &,
                                INT) 
 {
-  //FIXME
+  PSafePtr<OpalConnection> connection = NULL;
+  int i = 0;
+
   if (!is_outgoing ()) {
-    std::cout << "should clear or forward" << std::endl << std::flush;
-  }
-  else
-    std::cout << "should not clear or forward" << std::endl << std::flush;
-  //if (!forward_uri.empty ()) {
 
+    if (!forward_uri.empty ()) {
+
+      do {
+        connection = GetConnection (i);
+        i++;
+      }  while (PIsDescendant(&(*connection), OpalPCSSConnection));
 
-    /*
-       PSafePtr<OpalCall> call = 
-       endpoint.FindCallWithLock (endpoint.GetCurrentCallToken ());
-       PSafePtr<OpalConnection> con = 
-       endpoint.GetConnection (call, TRUE);
-
-       con->ForwardCall (forward_uri.c_str ());
-       */
- // }
- // else
-  //  ClearAllCalls (OpalConnection::EndedByNoAnswer, FALSE);
+      if (!PIsDescendant(&(*connection), OpalPCSSConnection)) 
+        connection->ForwardCall (forward_uri);
+    }
+    else
+      Clear (OpalConnection::EndedByAnswerDenied);
+  }
 }

Modified: trunk/src/endpoints/opal-call.h
==============================================================================
--- trunk/src/endpoints/opal-call.h	(original)
+++ trunk/src/endpoints/opal-call.h	Sun May 25 10:11:46 2008
@@ -93,6 +93,17 @@
      */
     void send_dtmf (const char dtmf);
 
+    /** Forward an incoming call after the given delay
+     * @param delay the delay after which we forward
+     * @param uri is the uri to forward to 
+     */
+    void set_no_answer_forward (unsigned delay, const std::string & uri);
+
+    /** Reject an incoming call after the given delay
+     * @param delay the delay after which reject the call
+     */
+    void set_reject_delay (unsigned delay);
+
 
     /*
      * Call Information
@@ -194,6 +205,8 @@
     std::string remote_uri;
     std::string remote_application;
 
+    std::string forward_uri;
+
     bool outgoing;
 
     double re_a_bw;

Modified: trunk/src/endpoints/opal-gmconf-bridge.cpp
==============================================================================
--- trunk/src/endpoints/opal-gmconf-bridge.cpp	(original)
+++ trunk/src/endpoints/opal-gmconf-bridge.cpp	Sun May 25 10:11:46 2008
@@ -53,6 +53,9 @@
   Ekiga::ConfKeys keys;
   property_changed.connect (sigc::mem_fun (this, &ConfBridge::on_property_changed));
 
+  keys.push_back (PORTS_KEY "udp_port_range");
+  keys.push_back (PORTS_KEY "tcp_port_range");
+
   keys.push_back (AUDIO_CODECS_KEY "enable_silence_detection");
   keys.push_back (AUDIO_CODECS_KEY "enable_echo_cancelation");
 
@@ -76,6 +79,7 @@
 
   keys.push_back (PERSONAL_DATA_KEY "full_name");
 
+  keys.push_back (CALL_FORWARDING_KEY "forward_on_no_answer");
   keys.push_back (CALL_FORWARDING_KEY "forward_on_busy");
   keys.push_back (CALL_FORWARDING_KEY "always_forward");
   keys.push_back (CALL_OPTIONS_KEY "no_answer_timeout");
@@ -84,9 +88,6 @@
   keys.push_back (H323_KEY "enable_early_h245");
   keys.push_back (H323_KEY "enable_fast_start");
 
-  keys.push_back (PORTS_KEY "udp_port_range");
-  keys.push_back (PORTS_KEY "tcp_port_range");
-
   load (keys);
 }
 
@@ -296,6 +297,10 @@
   //
   // Misc keys
   //
+  else if (key == CALL_FORWARDING_KEY "forward_on_no_answer") {
+
+    manager.set_forward_on_no_answer (gm_conf_entry_get_bool (entry));
+  }
   else if (key == CALL_FORWARDING_KEY "forward_on_busy") {
 
     manager.set_forward_on_busy (gm_conf_entry_get_bool (entry));

Modified: trunk/src/endpoints/sip.cpp
==============================================================================
--- trunk/src/endpoints/sip.cpp	(original)
+++ trunk/src/endpoints/sip.cpp	Sun May 25 10:11:46 2008
@@ -43,6 +43,8 @@
 
 #include "sip.h"
 
+#include "opal-call.h"
+
 #include "presence-core.h"
 #include "personal-details.h"
 
@@ -83,8 +85,6 @@
 {
   protocol_name = "sip";
   uri_prefix = "sip:";
-  udp_min = 5000;
-  udp_max = 5100; 
   listen_port = 5060;
 
   /* Timeouts */
@@ -228,8 +228,10 @@
 
     data += "<note>";
     data += short_status.c_str ();
-    data += " - ";
-    data += long_status.c_str ();
+    if (!long_status.empty ()) {
+      data += " - ";
+      data += long_status.c_str ();
+    }
     data += "</note>\r\n";
 
     data += "<status>\r\n";
@@ -348,8 +350,13 @@
 
 bool GMSIPEndpoint::set_listen_port (unsigned port)
 {
+  unsigned udp_min, udp_max;
+
   interface.protocol = "udp";
   interface.interface = "*";
+
+  endpoint.get_udp_ports (udp_min, udp_max);
+
   if (port > 0 && port >= udp_min && port <= udp_max) {
 
     std::stringstream str;
@@ -745,18 +752,29 @@
 {
   PTRACE (3, "GMSIPEndpoint\tIncoming connection");
 
-  if (!forward_uri.empty () && unconditional_forward)
+  if (!forward_uri.empty () && endpoint.get_unconditional_forward ())
     connection.ForwardCall (forward_uri);
   else if (endpoint.GetCallsNumber () > 1) { 
 
-    if (!forward_uri.empty () && forward_on_busy)
+    if (!forward_uri.empty () && endpoint.get_forward_on_busy ())
       connection.ForwardCall (forward_uri);
     else {
       connection.ClearCall (OpalConnection::EndedByLocalBusy);
     }
   }
-  else 
+  else {
+
+      Opal::Call *call = dynamic_cast<Opal::Call *> (&connection.GetCall ());
+      if (call) {
+
+        if (!forward_uri.empty () && endpoint.get_forward_on_no_answer ()) 
+          call->set_no_answer_forward (endpoint.get_reject_delay (), forward_uri);
+        else
+          call->set_reject_delay (endpoint.get_reject_delay ());
+      }
+
     return SIPEndPoint::OnIncomingConnection (connection, options, stroptions);
+  }
   
   return false;
 }

Modified: trunk/src/endpoints/sip.h
==============================================================================
--- trunk/src/endpoints/sip.h	(original)
+++ trunk/src/endpoints/sip.h	Sun May 25 10:11:46 2008
@@ -178,13 +178,6 @@
   std::string forward_uri;
   std::string outbound_proxy;
 
-  bool forward_on_busy;
-  bool unconditional_forward;
-  bool forward_on_no_answer;
-
-  unsigned no_answer_timeout;
-  unsigned udp_min;
-  unsigned udp_max;
   unsigned listen_port;
 };
 #endif



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