ekiga r6704 - in trunk: . src/endpoints src/gui



Author: dsandras
Date: Mon Aug 25 20:43:24 2008
New Revision: 6704
URL: http://svn.gnome.org/viewvc/ekiga?rev=6704&view=rev

Log:
Fixed crash reported by Matthias when calling things like 123.


Modified:
   trunk/ChangeLog
   trunk/src/endpoints/opal-call.cpp
   trunk/src/endpoints/opal-call.h
   trunk/src/gui/main.cpp

Modified: trunk/src/endpoints/opal-call.cpp
==============================================================================
--- trunk/src/endpoints/opal-call.cpp	(original)
+++ trunk/src/endpoints/opal-call.cpp	Mon Aug 25 20:43:24 2008
@@ -58,7 +58,7 @@
 Opal::Call::Call (OpalManager & _manager, Ekiga::ServiceCore & _core)
   : OpalCall (_manager), Ekiga::Call (), core (_core),
     runtime (*dynamic_cast<Ekiga::Runtime*>(core.get ("runtime"))),
-    outgoing(true), jitter(0)
+    call_setup(false),outgoing(true),jitter(0)
 {
   re_a_bytes = tr_a_bytes = re_v_bytes = tr_v_bytes = 0.0;
   last_v_tick = last_a_tick = PTime ();
@@ -77,6 +77,10 @@
 }
 
 
+Opal::Call::~Call ()
+{
+}
+
 void
 Opal::Call::hangup ()
 {
@@ -260,6 +264,13 @@
 }
 
 
+bool 
+Opal::Call::is_outgoing () const
+{
+  return outgoing; 
+}
+
+
 void
 Opal::Call::parse_info (OpalConnection & connection)
 {
@@ -268,11 +279,16 @@
   std::string::size_type idx;
   std::string party_name;
   std::string app;
-  std::string uri;
 
-  uri = (const char *) connection.GetRemotePartyCallbackURL ();
-  if (remote_uri.empty () && !uri.empty ())
-    remote_uri = uri;
+  if (PIsDescendant(&connection, OpalPCSSConnection)) {
+
+    outgoing = connection.IsOriginating ();
+
+    if (outgoing)
+      remote_uri = (const char *) connection.GetCall().GetPartyB ();
+    else
+      remote_uri = (const char *) connection.GetRemotePartyCallbackURL ();
+  }
 
   if (!PIsDescendant(&connection, OpalPCSSConnection)) {
 
@@ -336,116 +352,116 @@
 }
 
 
-void
+void 
 Opal::Call::OnReleased (OpalConnection & connection)
 {
+  parse_info (connection);
+
+  OpalCall::OnReleased (connection);
+}
+
+
+void
+Opal::Call::OnCleared ()
+{
   std::string reason;
 
   NoAnswerTimer.Stop (false);
 
-  /** TODO
-   * the Call could be destroyed before the signal callback has been executed
-   * maybe create a copy constructor
-   */
-  if (!PIsDescendant(&connection, OpalPCSSConnection)) {
+  OpalCall::OnCleared ();
 
-    parse_info (connection);
+  // TODO find a better way than that
+  while (!call_setup)
+    PThread::Current ()->Sleep (100);
 
-    if (!IsEstablished ()
-        && !is_outgoing ()
-        && connection.GetCallEndReason () != OpalConnection::EndedByAnswerDenied) {
+  if (!IsEstablished ()
+      && !is_outgoing ()
+      && GetCallEndReason () != OpalConnection::EndedByAnswerDenied) {
 
-      runtime.run_in_main (missed.make_slot ());
-    }
-    else {
-
-      switch (connection.GetCallEndReason ()) {
+    runtime.run_in_main (missed.make_slot ());
+  }
+  else {
 
-      case OpalConnection::EndedByLocalUser :
-        reason = _("Local user cleared the call");
-        break;
-      case OpalConnection::EndedByNoAccept :
-        reason = _("Local user rejected the call");
-        break;
-      case OpalConnection::EndedByAnswerDenied :
-        reason = _("Local user rejected the call");
-        break;
-      case OpalConnection::EndedByRemoteUser :
-        reason = _("Remote user cleared the call");
-        break;
-      case OpalConnection::EndedByRefusal :
-        reason = _("Remote user rejected the call");
-        break;
-      case OpalConnection::EndedByCallerAbort :
-        reason = _("Remote user has stopped calling");
-        break;
-      case OpalConnection::EndedByTransportFail :
-        reason = _("Abnormal call termination");
-        break;
-      case OpalConnection::EndedByConnectFail :
-        reason = _("Could not connect to remote host");
-        break;
-      case OpalConnection::EndedByGatekeeper :
-        reason = _("The Gatekeeper cleared the call");
-        break;
-      case OpalConnection::EndedByNoUser :
-        reason = _("User not found");
-        break;
-      case OpalConnection::EndedByNoBandwidth :
-        reason = _("Insufficient bandwidth");
-        break;
-      case OpalConnection::EndedByCapabilityExchange :
-        reason = _("No common codec");
-        break;
-      case OpalConnection::EndedByCallForwarded :
-        reason = _("Call forwarded");
-        break;
-      case OpalConnection::EndedBySecurityDenial :
-        reason = _("Security check failed");
-        break;
-      case OpalConnection::EndedByLocalBusy :
-        reason = _("Local user is busy");
-        break;
-      case OpalConnection::EndedByLocalCongestion :
-        reason = _("Congested link to remote party");
-        break;
-      case OpalConnection::EndedByRemoteBusy :
-        reason = _("Remote user is busy");
-        break;
-      case OpalConnection::EndedByRemoteCongestion :
-        reason = _("Congested link to remote party");
-        break;
-      case OpalConnection::EndedByHostOffline :
-        reason = _("Remote host is offline");
-        break;
-      case OpalConnection::EndedByTemporaryFailure :
-      case OpalConnection::EndedByUnreachable :
-      case OpalConnection::EndedByNoEndPoint :
-      case OpalConnection::EndedByNoAnswer :
-        if (connection.IsOriginating ())
-          reason = _("Remote user is not available");
-        else
-          reason = _("Local user is not available");
-        break;
-
-      case OpalConnection::EndedByQ931Cause:
-      case OpalConnection::EndedByDurationLimit:
-      case OpalConnection::EndedByInvalidConferenceID:
-      case OpalConnection::EndedByNoDialTone:
-      case OpalConnection::EndedByNoRingBackTone:
-      case OpalConnection::EndedByOutOfService:
-      case OpalConnection::EndedByAcceptingCallWaiting:
-      case OpalConnection::EndedWithQ931Code:
-      case OpalConnection::NumCallEndReasons:
-      default :
-        reason = _("Call completed");
-      }
+    switch (GetCallEndReason ()) {
 
-      runtime.run_in_main (sigc::bind (cleared.make_slot (), reason));
+    case OpalConnection::EndedByLocalUser :
+      reason = _("Local user cleared the call");
+      break;
+    case OpalConnection::EndedByNoAccept :
+      reason = _("Local user rejected the call");
+      break;
+    case OpalConnection::EndedByAnswerDenied :
+      reason = _("Local user rejected the call");
+      break;
+    case OpalConnection::EndedByRemoteUser :
+      reason = _("Remote user cleared the call");
+      break;
+    case OpalConnection::EndedByRefusal :
+      reason = _("Remote user rejected the call");
+      break;
+    case OpalConnection::EndedByCallerAbort :
+      reason = _("Remote user has stopped calling");
+      break;
+    case OpalConnection::EndedByTransportFail :
+      reason = _("Abnormal call termination");
+      break;
+    case OpalConnection::EndedByConnectFail :
+      reason = _("Could not connect to remote host");
+      break;
+    case OpalConnection::EndedByGatekeeper :
+      reason = _("The Gatekeeper cleared the call");
+      break;
+    case OpalConnection::EndedByNoUser :
+      reason = _("User not found");
+      break;
+    case OpalConnection::EndedByNoBandwidth :
+      reason = _("Insufficient bandwidth");
+      break;
+    case OpalConnection::EndedByCapabilityExchange :
+      reason = _("No common codec");
+      break;
+    case OpalConnection::EndedByCallForwarded :
+      reason = _("Call forwarded");
+      break;
+    case OpalConnection::EndedBySecurityDenial :
+      reason = _("Security check failed");
+      break;
+    case OpalConnection::EndedByLocalBusy :
+      reason = _("Local user is busy");
+      break;
+    case OpalConnection::EndedByLocalCongestion :
+      reason = _("Congested link to remote party");
+      break;
+    case OpalConnection::EndedByRemoteBusy :
+      reason = _("Remote user is busy");
+      break;
+    case OpalConnection::EndedByRemoteCongestion :
+      reason = _("Congested link to remote party");
+      break;
+    case OpalConnection::EndedByHostOffline :
+      reason = _("Remote host is offline");
+      break;
+    case OpalConnection::EndedByTemporaryFailure :
+    case OpalConnection::EndedByUnreachable :
+    case OpalConnection::EndedByNoEndPoint :
+    case OpalConnection::EndedByNoAnswer :
+      reason = _("User is not available");
+      break;
+    case OpalConnection::EndedByQ931Cause:
+    case OpalConnection::EndedByDurationLimit:
+    case OpalConnection::EndedByInvalidConferenceID:
+    case OpalConnection::EndedByNoDialTone:
+    case OpalConnection::EndedByNoRingBackTone:
+    case OpalConnection::EndedByOutOfService:
+    case OpalConnection::EndedByAcceptingCallWaiting:
+    case OpalConnection::EndedWithQ931Code:
+    case OpalConnection::NumCallEndReasons:
+    default :
+      reason = _("Call completed");
     }
-  }
 
-  OpalCall::OnReleased (connection);
+    runtime.run_in_main (sigc::bind (cleared.make_slot (), reason));
+  }
 }
 
 
@@ -457,8 +473,6 @@
 
   parse_info (connection);
 
-  outgoing = false;
-
   return OpalCall::OnAnswerCall (connection, caller);
 }
 
@@ -470,25 +484,17 @@
 
   parse_info (connection);
 
-  outgoing = PIsDescendant(&connection, OpalPCSSConnection);
-
   runtime.run_in_main (setup.make_slot ());
+  call_setup = true;
 
   return res;
 }
 
 
-void
-Opal::Call::OnNewConnection (OpalConnection & connection)
-{
-  if (remote_uri.empty ())
-    remote_uri = (const char *) connection.GetCall().GetPartyB ();
-}
-
-
-void Opal::Call::OnHold (OpalConnection & /*connection*/, 
-                         bool /*from_remote*/, 
-                         bool on_hold)
+void 
+Opal::Call::OnHold (OpalConnection & /*connection*/, 
+                    bool /*from_remote*/, 
+                    bool on_hold)
 {
   if (on_hold)
     runtime.run_in_main (held.make_slot ());

Modified: trunk/src/endpoints/opal-call.h
==============================================================================
--- trunk/src/endpoints/opal-call.h	(original)
+++ trunk/src/endpoints/opal-call.h	Mon Aug 25 20:43:24 2008
@@ -60,7 +60,7 @@
 
     Call (OpalManager & _manager, Ekiga::ServiceCore & _core);
 
-    ~Call () { };
+    ~Call ();
 
     /*
      * Call Management
@@ -148,7 +148,7 @@
     /* Implementation of inherited methods
     */
 
-    bool is_outgoing () const { return outgoing; }
+    bool is_outgoing () const;
     double get_received_audio_bandwidth () const { return re_a_bw; }
     double get_transmitted_audio_bandwidth () const { return tr_a_bw; }
     double get_received_video_bandwidth () const { return re_v_bw; }
@@ -176,12 +176,12 @@
 
     void OnReleased (OpalConnection & connection);
 
+    void OnCleared ();
+
     OpalConnection::AnswerCallResponse OnAnswerCall (OpalConnection & connection, const PString & caller);
 
     PBoolean OnSetUp (OpalConnection & connection);
 
-    void OnNewConnection (OpalConnection & connection);
-
     PDECLARE_NOTIFIER (PThread, Opal::Call, OnAnswer);
 
     PDECLARE_NOTIFIER (PThread, Opal::Call, OnHangup);
@@ -205,14 +205,14 @@
     Ekiga::Runtime & runtime;
 
 
+    bool call_setup;
+    bool outgoing;
     std::string remote_party_name;
     std::string remote_uri;
     std::string remote_application;
 
     std::string forward_uri;
 
-    bool outgoing;
-
     double re_a_bw;
     double tr_a_bw;
     double re_v_bw;

Modified: trunk/src/gui/main.cpp
==============================================================================
--- trunk/src/gui/main.cpp	(original)
+++ trunk/src/gui/main.cpp	Mon Aug 25 20:43:24 2008
@@ -166,6 +166,7 @@
   GdkGC* video_widget_gc;
 #endif
 
+  unsigned int calling_state;
   unsigned int missed_calls;
   unsigned int total_mwi;
   bool audio_transmission_active;
@@ -637,7 +638,7 @@
 
   GmMainWindow *mw = gm_mw_get_mw (GTK_WIDGET (self));
   
-  if (mw->current_call) {
+  if (mw->calling_state == Connected && mw->current_call) {
 
     Ekiga::VideoOutputStats videooutput_stats;
     Ekiga::VideoOutputCore *videooutput_core = dynamic_cast<Ekiga::VideoOutputCore *> (mw->core.get ("videooutput-core"));
@@ -651,8 +652,7 @@
                            videooutput_stats.tx_fps,
                            videooutput_stats.rx_fps);
     gm_main_window_push_info_message (GTK_WIDGET (self), msg);
-    if (mw->current_call)
-      gm_main_window_set_call_duration (GTK_WIDGET (self), mw->current_call->get_duration ().c_str ());
+    gm_main_window_set_call_duration (GTK_WIDGET (self), mw->current_call->get_duration ().c_str ());
     g_free (msg);
 
     int jitter_quality = 0;
@@ -1129,7 +1129,7 @@
 			       device.GetString().c_str ());
   gm_main_window_flash_message (GTK_WIDGET (self), "%s", message);
   g_free (message);
-  if (!isDesired && !mw->current_call) 
+  if (!isDesired && mw->calling_state == Standby && !mw->current_call) 
     gm_main_window_add_device_dialog_show (GTK_WIDGET (self), device, VideoInput);
 }
 
@@ -1251,7 +1251,7 @@
 			     device.GetString().c_str ());
   gm_main_window_flash_message (GTK_WIDGET (self), "%s", message);
   g_free (message);
-  if (!isDesired  && !mw->current_call)
+  if (!isDesired  && mw->calling_state == Standby && !mw->current_call)
     gm_main_window_add_device_dialog_show (GTK_WIDGET (self), device,  AudioInput);
     
 }
@@ -1368,7 +1368,7 @@
   message = g_strdup_printf (_("Added audio output device %s"), device.GetString().c_str ());
   gm_main_window_flash_message (GTK_WIDGET (self), "%s", message);
   g_free (message);
-  if (!isDesired && !mw->current_call)
+  if (!isDesired && mw->calling_state == Standby && !mw->current_call)
     gm_main_window_add_device_dialog_show (GTK_WIDGET (self), device, AudioOutput);
 }
 
@@ -1522,7 +1522,7 @@
 
   mw = gm_mw_get_mw (GTK_WIDGET (data));
 
-  if (!mw->current_call) {
+  if (mw->calling_state == Standby && !mw->current_call) {
 
     size_t pos;
 
@@ -1537,6 +1537,8 @@
       mw->accounts.remove (host);
       mw->accounts.push_front (host);
     }
+
+    gm_main_window_update_calling_state (GTK_WIDGET (data), Calling);
   }
 }
 
@@ -3261,6 +3263,8 @@
     default:
       break;
     }
+
+  mw->calling_state = calling_state;
 }
 
 



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