[ekiga] Fixed regression concerning several call features.



commit aa06836a30517eb8859d4f925f6513d813205f90
Author: Damien Sandras <dsandras seconix com>
Date:   Tue Sep 1 19:50:18 2009 +0200

    Fixed regression concerning several call features.
    
    Hopefully, it also fixes possible crashes when manipulating connections.

 lib/engine/components/opal/opal-call.cpp |   17 +++++++++--------
 lib/engine/components/opal/opal-call.h   |   14 ++++++++++++++
 2 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-call.cpp b/lib/engine/components/opal/opal-call.cpp
index df4004e..72814b4 100644
--- a/lib/engine/components/opal/opal-call.cpp
+++ b/lib/engine/components/opal/opal-call.cpp
@@ -144,8 +144,8 @@ Opal::Call::answer ()
 void
 Opal::Call::transfer (std::string uri)
 {
-  PSafePtr<OpalPCSSConnection> connection = GetConnectionAs<OpalPCSSConnection>();
-  if (connection)
+  PSafePtr<OpalConnection> connection = get_remote_connection ();
+  if (connection != NULL)
     connection->TransferConnection (uri);
 }
 
@@ -154,8 +154,8 @@ void
 Opal::Call::toggle_hold ()
 {
   bool on_hold = false;
-  PSafePtr<OpalPCSSConnection> connection = GetConnectionAs<OpalPCSSConnection>();
-  if (connection) {
+  PSafePtr<OpalConnection> connection = get_remote_connection ();
+  if (connection != NULL) {
 
     on_hold = connection->IsConnectionOnHold ();
     if (!on_hold)
@@ -175,7 +175,7 @@ Opal::Call::toggle_stream_pause (StreamType type)
 
   bool paused = false;
 
-  PSafePtr<OpalPCSSConnection> connection = GetConnectionAs<OpalPCSSConnection>();
+  PSafePtr<OpalConnection> connection = get_remote_connection ();
   if (connection != NULL) {
 
     stream = connection->GetMediaStream ((type == Audio) ? OpalMediaType::Audio () : OpalMediaType::Video (), false);
@@ -198,9 +198,10 @@ Opal::Call::toggle_stream_pause (StreamType type)
 void
 Opal::Call::send_dtmf (const char dtmf)
 {
-  PSafePtr<OpalPCSSConnection> connection = GetConnectionAs<OpalPCSSConnection>();
-  if (connection != NULL)
+  PSafePtr<OpalConnection> connection = get_remote_connection ();
+  if (connection != NULL) {
     connection->SendUserInputTone (dtmf, 180);
+  }
 }
 
 
@@ -637,7 +638,7 @@ Opal::Call::OnNoAnswerTimeout (PTimer &,
 
     if (!forward_uri.empty ()) {
 
-      PSafePtr<OpalPCSSConnection> connection = GetConnectionAs<OpalPCSSConnection>();
+      PSafePtr<OpalConnection> connection = get_remote_connection ();
       if (connection != NULL)
         connection->ForwardCall (forward_uri);
     }
diff --git a/lib/engine/components/opal/opal-call.h b/lib/engine/components/opal/opal-call.h
index 5a19599..b7c9f44 100644
--- a/lib/engine/components/opal/opal-call.h
+++ b/lib/engine/components/opal/opal-call.h
@@ -195,6 +195,20 @@ private:
      */
     void parse_info (OpalConnection & connection);
 
+    PSafePtr<OpalConnection> get_remote_connection ()
+    {
+      PSafePtr<OpalConnection> connection;
+      for (PSafePtr<OpalConnection> iterConn (connectionsActive, PSafeReference); iterConn != NULL; ++iterConn) {
+        if (PSafePtrCast<OpalConnection, OpalPCSSConnection> (iterConn) == NULL) {
+          connection = iterConn;
+          if (!connection.SetSafetyMode(PSafeReadWrite))
+            connection.SetNULL();
+          break;
+        }
+      }
+      return connection;
+    }
+
     /*
      *
      */



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