ekiga r7296 - in trunk: . lib/engine/addressbook/call-history lib/engine/protocol/skel lib/gui src/endpoints src/gui



Author: dsandras
Date: Mon Oct 27 21:32:13 2008
New Revision: 7296
URL: http://svn.gnome.org/viewvc/ekiga?rev=7296&view=rev

Log:
Use gmref memory management for the Ekiga::Call objects. The principle is 
simple, OPAL does not free OpalCall objects itself. When the Opal component 
thinks the object should be deleted, it emits the "removed" signal on the 
Opal::Call object, which triggers the disconnection of signals and the 
automatic deletion when the ref count reaches zero.
It fixes, among others, potential problems due to the OpalCall object being
deleted too early by OPAL and still being accessed by the GUI.


Modified:
   trunk/ChangeLog
   trunk/lib/engine/addressbook/call-history/history-book.cpp
   trunk/lib/engine/addressbook/call-history/history-book.h
   trunk/lib/engine/protocol/skel/call-core.cpp
   trunk/lib/engine/protocol/skel/call-core.h
   trunk/lib/engine/protocol/skel/call.h
   trunk/lib/gui/Makefile.am
   trunk/src/endpoints/h323-endpoint.cpp
   trunk/src/endpoints/manager.cpp
   trunk/src/endpoints/manager.h
   trunk/src/endpoints/sip-endpoint.cpp
   trunk/src/endpoints/sip-endpoint.h
   trunk/src/gui/main.cpp
   trunk/src/gui/statusicon.cpp

Modified: trunk/lib/engine/addressbook/call-history/history-book.cpp
==============================================================================
--- trunk/lib/engine/addressbook/call-history/history-book.cpp	(original)
+++ trunk/lib/engine/addressbook/call-history/history-book.cpp	Mon Oct 27 21:32:13 2008
@@ -201,23 +201,23 @@
 
 void
 History::Book::on_missed_call (Ekiga::CallManager &/*manager*/,
-			       Ekiga::Call &call)
+			       gmref_ptr<Ekiga::Call> call)
 {
-  add (call.get_remote_party_name (),
-       call.get_remote_uri (),
-       call.get_start_time (),
-       call.get_duration (),
+  add (call->get_remote_party_name (),
+       call->get_remote_uri (),
+       call->get_start_time (),
+       call->get_duration (),
        MISSED);
 }
 
 void
 History::Book::on_cleared_call (Ekiga::CallManager &/*manager*/,
-				Ekiga::Call &call,
+				gmref_ptr<Ekiga::Call> call,
 				std::string /*message*/)
 {
-  add (call.get_remote_party_name (),
-       call.get_remote_uri (),
-       call.get_start_time (),
-       call.get_duration (),
-       (call.is_outgoing ()?PLACED:RECEIVED));
+  add (call->get_remote_party_name (),
+       call->get_remote_uri (),
+       call->get_start_time (),
+       call->get_duration (),
+       (call->is_outgoing ()?PLACED:RECEIVED));
 }

Modified: trunk/lib/engine/addressbook/call-history/history-book.h
==============================================================================
--- trunk/lib/engine/addressbook/call-history/history-book.h	(original)
+++ trunk/lib/engine/addressbook/call-history/history-book.h	Mon Oct 27 21:32:13 2008
@@ -99,10 +99,10 @@
     void common_add (Contact &contact);
 
     void on_missed_call (Ekiga::CallManager &manager,
-			 Ekiga::Call &call);
+			 gmref_ptr<Ekiga::Call> call);
 
     void on_cleared_call (Ekiga::CallManager &manager,
-			  Ekiga::Call &call,
+			  gmref_ptr<Ekiga::Call> call,
 			  std::string message);
 
     Ekiga::ServiceCore &core;

Modified: trunk/lib/engine/protocol/skel/call-core.cpp
==============================================================================
--- trunk/lib/engine/protocol/skel/call-core.cpp	(original)
+++ trunk/lib/engine/protocol/skel/call-core.cpp	Mon Oct 27 21:32:13 2008
@@ -92,85 +92,104 @@
 }
 
 
-void CallCore::add_call (Call *call, CallManager *manager)
+void CallCore::add_call (gmref_ptr<Call> call, CallManager *manager)
 {
-  call->ringing.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_ringing_call), call, manager));
-  call->setup.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_setup_call), call, manager));
-  call->missed.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_missed_call), call, manager));
-  call->cleared.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_cleared_call), call, manager));
-  call->established.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_established_call), call, manager));
-  call->held.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_held_call), call, manager));
-  call->retrieved.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_retrieved_call), call, manager));
-  call->stream_opened.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_stream_opened), call, manager));
-  call->stream_closed.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_stream_closed), call, manager));
-  call->stream_paused.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_stream_paused), call, manager));
-  call->stream_resumed.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_stream_resumed), call, manager));
+  std::list<sigc::connection> conns;
+
+  conns.push_back (call->ringing.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_ringing_call), call, manager)));
+  conns.push_back (call->setup.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_setup_call), call, manager)));
+  conns.push_back (call->missed.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_missed_call), call, manager)));
+  conns.push_back (call->cleared.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_cleared_call), call, manager)));
+  conns.push_back (call->established.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_established_call), call, manager)));
+  conns.push_back (call->held.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_held_call), call, manager)));
+  conns.push_back (call->retrieved.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_retrieved_call), call, manager)));
+  conns.push_back (call->stream_opened.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_stream_opened), call, manager)));
+  conns.push_back (call->stream_closed.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_stream_closed), call, manager)));
+  conns.push_back (call->stream_paused.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_stream_paused), call, manager)));
+  conns.push_back (call->stream_resumed.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_stream_resumed), call, manager)));
+  conns.push_back (call->removed.connect (sigc::bind (sigc::mem_fun (this, &CallCore::on_call_removed), call)));
+
+  calls[call->get_id ()] = conns;
+}
+
+
+void CallCore::remove_call (gmref_ptr<Call> call)
+{
+  while (calls.begin () != calls.end ()) {
+
+    for (std::list<sigc::connection>::iterator iter2 = calls.begin()->second.begin ();
+         iter2 != calls.begin()->second.end ();
+	 ++iter2)
+      iter2->disconnect ();
+
+    calls.erase (calls.begin()->first);
+  }
 }
 
 
-void CallCore::on_ringing_call (Call *call, CallManager *manager)
+void CallCore::on_ringing_call (gmref_ptr<Call> call, CallManager *manager)
 {
-  ringing_call.emit (*manager, *call);
+  ringing_call.emit (*manager, call);
 }
 
 
-void CallCore::on_setup_call (Call *call, CallManager *manager)
+void CallCore::on_setup_call (gmref_ptr<Call> call, CallManager *manager)
 {
-  setup_call.emit (*manager, *call);
+  setup_call.emit (*manager, call);
 }
 
 
-void CallCore::on_missed_call (Call *call, CallManager *manager)
+void CallCore::on_missed_call (gmref_ptr<Call> call, CallManager *manager)
 {
-  missed_call.emit (*manager, *call);
+  missed_call.emit (*manager, call);
 }
 
 
-void CallCore::on_cleared_call (std::string reason, Call *call, CallManager *manager)
+void CallCore::on_cleared_call (std::string reason, gmref_ptr<Call> call, CallManager *manager)
 {
-  cleared_call.emit (*manager, *call, reason);
+  cleared_call.emit (*manager, call, reason); 
 }
 
 
-void CallCore::on_established_call (Call *call, CallManager *manager)
+void CallCore::on_established_call (gmref_ptr<Call> call, CallManager *manager)
 {
-  established_call.emit (*manager, *call);
+  established_call.emit (*manager, call);
 }
 
 
-void CallCore::on_held_call (Call *call, CallManager *manager)
+void CallCore::on_held_call (gmref_ptr<Call> call, CallManager *manager)
 {
-  held_call.emit (*manager, *call);
+  held_call.emit (*manager, call);
 }
 
 
-void CallCore::on_retrieved_call (Call *call, CallManager *manager)
+void CallCore::on_retrieved_call (gmref_ptr<Call> call, CallManager *manager)
 {
-  retrieved_call.emit (*manager, *call);
+  retrieved_call.emit (*manager, call);
 }
 
 
-void CallCore::on_stream_opened (std::string name, Call::StreamType type, bool is_transmitting, Call *call, CallManager *manager)
+void CallCore::on_stream_opened (std::string name, Call::StreamType type, bool is_transmitting, gmref_ptr<Call> call, CallManager *manager)
 {
-  stream_opened.emit (*manager, *call, name, type, is_transmitting);
+  stream_opened.emit (*manager, call, name, type, is_transmitting);
 }
 
 
-void CallCore::on_stream_closed (std::string name, Call::StreamType type, bool is_transmitting, Call *call, CallManager *manager)
+void CallCore::on_stream_closed (std::string name, Call::StreamType type, bool is_transmitting, gmref_ptr<Call> call, CallManager *manager)
 {
-  stream_closed.emit (*manager, *call, name, type, is_transmitting);
+  stream_closed.emit (*manager, call, name, type, is_transmitting);
 }
 
 
-void CallCore::on_stream_paused (std::string name, Call::StreamType type, Call *call, CallManager *manager)
+void CallCore::on_stream_paused (std::string name, Call::StreamType type, gmref_ptr<Call> call, CallManager *manager)
 {
-  stream_paused.emit (*manager, *call, name, type);
+  stream_paused.emit (*manager, call, name, type);
 }
 
 
-void CallCore::on_stream_resumed (std::string name, Call::StreamType type, Call *call, CallManager *manager)
+void CallCore::on_stream_resumed (std::string name, Call::StreamType type, gmref_ptr<Call> call, CallManager *manager)
 {
-  stream_resumed.emit (*manager, *call, name, type);
+  stream_resumed.emit (*manager, call, name, type);
 }
 
 
@@ -182,3 +201,10 @@
   if (nr_ready >= managers.size ())
     ready.emit ();
 }
+
+
+void CallCore::on_call_removed (gmref_ptr<Call> call)
+{
+  std::cout << "on_call_removed " << std::endl << std::flush;
+  remove_call (call);
+}

Modified: trunk/lib/engine/protocol/skel/call-core.h
==============================================================================
--- trunk/lib/engine/protocol/skel/call-core.h	(original)
+++ trunk/lib/engine/protocol/skel/call-core.h	Mon Oct 27 21:32:13 2008
@@ -41,6 +41,7 @@
 #include "chain-of-responsibility.h"
 #include "services.h"
 #include "call.h"
+#include "gmref.h"
 
 #include <sigc++/sigc++.h>
 #include <set>
@@ -95,7 +96,12 @@
        * @param call is the call to be added.
        * @param manager is the CallManager handling it.
        */
-      void add_call (Call *call, CallManager *manager);
+      void add_call (gmref_ptr<Call> call, CallManager *manager);
+
+      /** Remove a call handled by the CallCore serice.
+       * @param call is the call to be removed.
+       */
+      void remove_call (gmref_ptr<Call> call);
 
       /** Adds a CallManager to the CallCore service.
        * @param The manager to be added.
@@ -132,17 +138,17 @@
       
       /** See call.h for the API
        */
-      sigc::signal<void, CallManager &, Call &> ringing_call;
-      sigc::signal<void, CallManager &, Call &> setup_call;
-      sigc::signal<void, CallManager &, Call &> missed_call;
-      sigc::signal<void, CallManager &, Call &, std::string> cleared_call;
-      sigc::signal<void, CallManager &, Call &> established_call;
-      sigc::signal<void, CallManager &, Call &> held_call;
-      sigc::signal<void, CallManager &, Call &> retrieved_call;
-      sigc::signal<void, CallManager &, Call &, std::string, Call::StreamType, bool> stream_opened;
-      sigc::signal<void, CallManager &, Call &, std::string, Call::StreamType, bool> stream_closed;
-      sigc::signal<void, CallManager &, Call &, std::string, Call::StreamType> stream_paused;
-      sigc::signal<void, CallManager &, Call &, std::string, Call::StreamType> stream_resumed;
+      sigc::signal<void, CallManager &, gmref_ptr<Call> > ringing_call;
+      sigc::signal<void, CallManager &, gmref_ptr<Call> > setup_call;
+      sigc::signal<void, CallManager &, gmref_ptr<Call> > missed_call;
+      sigc::signal<void, CallManager &, gmref_ptr<Call>, std::string> cleared_call;
+      sigc::signal<void, CallManager &, gmref_ptr<Call> > established_call;
+      sigc::signal<void, CallManager &, gmref_ptr<Call> > held_call;
+      sigc::signal<void, CallManager &, gmref_ptr<Call> > retrieved_call;
+      sigc::signal<void, CallManager &, gmref_ptr<Call>, std::string, Call::StreamType, bool> stream_opened;
+      sigc::signal<void, CallManager &, gmref_ptr<Call>, std::string, Call::StreamType, bool> stream_closed;
+      sigc::signal<void, CallManager &, gmref_ptr<Call>, std::string, Call::StreamType> stream_paused;
+      sigc::signal<void, CallManager &, gmref_ptr<Call>, std::string, Call::StreamType> stream_resumed;
 
       /*** Misc ***/
       sigc::signal<void, CallManager &> manager_ready;
@@ -153,18 +159,18 @@
       ChainOfResponsibility<std::string> errors;
 
   private:
-      void on_new_call (Call *call, CallManager *manager);
-      void on_ringing_call (Call *call, CallManager *manager);
-      void on_setup_call (Call *call, CallManager *manager);
-      void on_missed_call (Call *call, CallManager *manager);
-      void on_cleared_call (std::string, Call *call, CallManager *manager);
-      void on_established_call (Call *call, CallManager *manager);
-      void on_held_call (Call *call, CallManager *manager);
-      void on_retrieved_call (Call *call, CallManager *manager);
-      void on_stream_opened (std::string name, Call::StreamType type, bool is_transmitting, Call *call, CallManager *manager);
-      void on_stream_closed (std::string name, Call::StreamType type, bool is_transmitting, Call *call, CallManager *manager);
-      void on_stream_paused (std::string name, Call::StreamType type, Call *call, CallManager *manager);
-      void on_stream_resumed (std::string name, Call::StreamType type, Call *call, CallManager *manager);
+      void on_new_call (gmref_ptr<Call> call, CallManager *manager);
+      void on_ringing_call (gmref_ptr<Call> call, CallManager *manager);
+      void on_setup_call (gmref_ptr<Call> call, CallManager *manager);
+      void on_missed_call (gmref_ptr<Call> call, CallManager *manager);
+      void on_cleared_call (std::string, gmref_ptr<Call> call, CallManager *manager);
+      void on_established_call (gmref_ptr<Call> call, CallManager *manager);
+      void on_held_call (gmref_ptr<Call> call, CallManager *manager);
+      void on_retrieved_call (gmref_ptr<Call> call, CallManager *manager);
+      void on_stream_opened (std::string name, Call::StreamType type, bool is_transmitting, gmref_ptr<Call> call, CallManager *manager);
+      void on_stream_closed (std::string name, Call::StreamType type, bool is_transmitting, gmref_ptr<Call> call, CallManager *manager);
+      void on_stream_paused (std::string name, Call::StreamType type, gmref_ptr<Call> call, CallManager *manager);
+      void on_stream_resumed (std::string name, Call::StreamType type, gmref_ptr<Call> call, CallManager *manager);
 
       void on_im_failed (std::string, std::string, CallManager *manager);
       void on_im_sent (std::string, std::string, CallManager *manager);
@@ -172,8 +178,12 @@
       void on_new_chat (std::string, std::string, CallManager *manager);
 
       void on_manager_ready (CallManager *manager);
+
+      void on_call_removed (gmref_ptr<Call> call);
+
       
       std::set<CallManager *> managers;
+      std::map<std::string, std::list<sigc::connection> > calls;
       unsigned nr_ready;
     };
 

Modified: trunk/lib/engine/protocol/skel/call.h
==============================================================================
--- trunk/lib/engine/protocol/skel/call.h	(original)
+++ trunk/lib/engine/protocol/skel/call.h	Mon Oct 27 21:32:13 2008
@@ -38,10 +38,13 @@
 #ifndef __CALL_H__
 #define __CALL_H__
 
+#include "gmref.h"
+
 #include <sigc++/sigc++.h>
 #include <time.h>
 #include <string>
 #include <sstream>
+#include <iostream>
 
 namespace Ekiga
 {
@@ -55,7 +58,7 @@
    * Everything is handled asynchronously and signaled through the
    * Ekiga::CallManager
    */
-  class Call
+  class Call : public virtual GmRefCounted
     {
 
   public:
@@ -64,7 +67,7 @@
         {
         }
 
-      virtual ~Call () {};
+      virtual ~Call () { };
 
       enum StreamType { Audio, Video };
 
@@ -257,6 +260,10 @@
        */
       sigc::signal<void, std::string, StreamType> stream_resumed;
 
+      /** This signal is emitted when the Call is removed.
+       */
+      sigc::signal<void> removed;
+     
     };
 
 /**

Modified: trunk/lib/gui/Makefile.am
==============================================================================
--- trunk/lib/gui/Makefile.am	(original)
+++ trunk/lib/gui/Makefile.am	Mon Oct 27 21:32:13 2008
@@ -77,7 +77,7 @@
 	-I$(top_srcdir)/lib/pixops
 endif
 
-AM_CXXFLAGS = $(GTK_CFLAGS) $(GLIB_CFLAGS) $(OPAL_CFLAGS) $(PTLIB_CFLAGS) $(XV_CFLAGS) $(DX_CFLAGS) $(SIGC_CFLAGS) -I ../../lib/engine/protocol/skel/ -I ../../lib/engine/framework/
+AM_CXXFLAGS = $(GTK_CFLAGS) $(GLIB_CFLAGS) $(OPAL_CFLAGS) $(PTLIB_CFLAGS) $(XV_CFLAGS) $(DX_CFLAGS) $(SIGC_CFLAGS) -I ../../lib/engine/protocol/skel/ -I ../../lib/engine/framework/ -I ../../lib/gmref/
 AM_CFLAGS = $(GTK_CFLAGS) $(GLIB_CFLAGS) $(GNOME_CFLAGS)
 AM_LIBS = $(GTK_LIBS) $(GLIB_LIBS) $(OPAL_LIBS) $(PTLIB_LIBS) $(XV_LIBS) $(DX_LIBS) $(GNOME_LIBS) $(SIGC_LIBS)
 

Modified: trunk/src/endpoints/h323-endpoint.cpp
==============================================================================
--- trunk/src/endpoints/h323-endpoint.cpp	(original)
+++ trunk/src/endpoints/h323-endpoint.cpp	Mon Oct 27 21:32:13 2008
@@ -48,31 +48,6 @@
 
   namespace H323 {
 
-    class dialer : public PThread
-    {
-      PCLASSINFO(dialer, PThread);
-
-  public:
-
-      dialer (const std::string & uri, Opal::CallManager & _manager) 
-        : PThread (1000, AutoDeleteThread), 
-        dial_uri (uri),
-        manager (_manager) 
-      {
-        this->Resume ();
-      };
-
-      void Main () 
-        {
-          PString token;
-          manager.SetUpCall ("pc:*", dial_uri, token);
-        };
-
-  private:
-      const std::string dial_uri;
-      Opal::CallManager & manager;
-    };
-
     class subscriber : public PThread
     {
       PCLASSINFO(subscriber, PThread);
@@ -170,7 +145,8 @@
 {
   if (uri.find ("h323:") == 0) {
 
-    new Opal::H323::dialer (uri, manager);
+    PString token;
+    manager.SetUpCall("pc:*", uri, token);
 
     return true;
   }

Modified: trunk/src/endpoints/manager.cpp
==============================================================================
--- trunk/src/endpoints/manager.cpp	(original)
+++ trunk/src/endpoints/manager.cpp	Mon Oct 27 21:32:13 2008
@@ -140,6 +140,11 @@
   SetMediaFormatMask (PStringArray ());
 
   call_core = core.get ("call-core");
+  {
+    gmref_ptr<Ekiga::Runtime> smart = core.get ("runtime");
+    gmref_inc (smart); // take a reference in the main thread
+    runtime = &*smart;
+  }
 
   // used to communicate with the StunDetector
 #if GLIB_CHECK_VERSION(2,16,0)
@@ -154,9 +159,10 @@
 
 CallManager::~CallManager ()
 {
-  ClearAllCalls (OpalConnection::EndedByLocalUser, false);
+  ClearAllCalls (OpalConnection::EndedByLocalUser, true);
 
   g_async_queue_unref (queue);
+  gmref_dec (runtime);
 }
 
 
@@ -166,7 +172,6 @@
   new StunDetector (stun_server, *this, queue);
 
   patience = 20;
-  gmref_ptr<Ekiga::Runtime> runtime = core.get ("runtime");
   runtime->run_in_main (sigc::mem_fun (this, &CallManager::HandleSTUNResult), 1);
 }
 
@@ -623,12 +628,21 @@
 
 OpalCall *CallManager::CreateCall ()
 {
-  Ekiga::Call *call = NULL;
+  gmref_ptr<Ekiga::Call> call = NULL;
 
-  call = new Opal::Call (*this, core);
+  call = gmref_ptr<Ekiga::Call> (new Opal::Call (*this, core));
   call_core->add_call (call, this);
 
-  return dynamic_cast<OpalCall *> (call);
+  return dynamic_cast<OpalCall *> (&*call);
+}
+
+
+void
+CallManager::DestroyCall (OpalCall *_call)
+{
+  Ekiga::Call *call = dynamic_cast<Ekiga::Call *> (_call);
+
+  runtime->emit_signal_in_main(call->removed);
 }
 
 
@@ -719,7 +733,6 @@
   } else {
 
       patience--;
-      gmref_ptr<Ekiga::Runtime> runtime = core.get ("runtime");
       runtime->run_in_main (sigc::mem_fun (this,
 					  &CallManager::HandleSTUNResult),
 			    1);
@@ -732,7 +745,6 @@
   // notice we're in for an infinite loop if nobody ever reports to the user!
   if ( !call_core->errors.handle_request (error)) {
 
-    gmref_ptr<Ekiga::Runtime> runtime = core.get ("runtime");
     runtime->run_in_main (sigc::bind (sigc::mem_fun (this,
 						     &CallManager::ReportSTUNError),
 				      error),

Modified: trunk/src/endpoints/manager.h
==============================================================================
--- trunk/src/endpoints/manager.h	(original)
+++ trunk/src/endpoints/manager.h	Mon Oct 27 21:32:13 2008
@@ -149,6 +149,7 @@
 
 private:
     OpalCall *CreateCall ();
+    void DestroyCall (OpalCall *);
 
     bool OnOpenMediaStream (OpalConnection &,
                             OpalMediaStream &);
@@ -168,6 +169,7 @@
        variables */
     PMutex manager_access_mutex;
 
+    Ekiga::Runtime *runtime;
     Ekiga::ServiceCore & core;
     Ekiga::CodecList codecs; 
     gmref_ptr<Ekiga::CallCore> call_core; // FIXME: is it threaded in there?

Modified: trunk/src/endpoints/sip-endpoint.cpp
==============================================================================
--- trunk/src/endpoints/sip-endpoint.cpp	(original)
+++ trunk/src/endpoints/sip-endpoint.cpp	Mon Oct 27 21:32:13 2008
@@ -83,32 +83,6 @@
 
   namespace Sip {
 
-    class dialer : public PThread
-    {
-      PCLASSINFO(dialer, PThread);
-
-  public:
-
-      dialer (const std::string & uri, Opal::CallManager & _manager) 
-        : PThread (1000, AutoDeleteThread), 
-        dial_uri (uri),
-        manager (_manager) 
-      {
-        this->Resume ();
-      };
-
-      void Main () 
-        {
-          PString token;
-          manager.SetUpCall ("pc:*", dial_uri, token);
-        };
-
-  private:
-      const std::string dial_uri;
-      Opal::CallManager & manager;
-    };
-
-
     class subscriber : public PThread
     {
       PCLASSINFO(subscriber, PThread);
@@ -429,7 +403,8 @@
     else
       ustr << uri;
 
-    new Opal::Sip::dialer (ustr.str (), manager);
+    PString token;
+    manager.SetUpCall("pc:*", ustr.str(), token);
 
     return true;
   }
@@ -580,22 +555,6 @@
 }
 
 
-void Opal::Sip::EndPoint::ShutDown ()
-{
-  listeners.RemoveAll ();
-
-  for (PSafePtr<SIPTransaction> transaction(transactions, PSafeReference);      transaction != NULL; ++transaction)
-    transaction->WaitForCompletion();
-
-  while (activeSIPHandlers.GetSize() > 0) {
-    PSafePtr<SIPHandler> handler = activeSIPHandlers;
-    activeSIPHandlers.Remove(handler);
-  }
-
-  SIPEndPoint::ShutDown ();
-}
-
-
 void Opal::Sip::EndPoint::Register (const Opal::Account & account)
 {
   PString _aor;

Modified: trunk/src/endpoints/sip-endpoint.h
==============================================================================
--- trunk/src/endpoints/sip-endpoint.h	(original)
+++ trunk/src/endpoints/sip-endpoint.h	Mon Oct 27 21:32:13 2008
@@ -133,8 +133,6 @@
 
 
       /* OPAL Methods */
-      void ShutDown ();
-
       void Register (const Opal::Account & account);
 
       void OnRegistered (const PString & aor,

Modified: trunk/src/gui/main.cpp
==============================================================================
--- trunk/src/gui/main.cpp	(original)
+++ trunk/src/gui/main.cpp	Mon Oct 27 21:32:13 2008
@@ -181,7 +181,7 @@
   GtkWidget *transfer_call_popup;
 
   /* Calls */
-  Ekiga::Call *current_call;
+  gmref_ptr<Ekiga::Call> current_call;
   unsigned timeout_id;
   unsigned calling_state;
   bool audio_transmission_active;
@@ -250,11 +250,11 @@
 static void ekiga_main_window_selected_presentity_build_menu (EkigaMainWindow *mw);
 
 static void ekiga_main_window_incoming_call_dialog_show (EkigaMainWindow *mw,
-                                                      Ekiga::Call & call);
+                                                      gmref_ptr<Ekiga::Call>  call);
 
 #ifdef HAVE_NOTIFY
 static void ekiga_main_window_incoming_call_notify (EkigaMainWindow *mw,
-                                                    Ekiga::Call & call);
+                                                    gmref_ptr<Ekiga::Call>  call);
 #endif
 
 
@@ -542,14 +542,14 @@
 
 
 static void on_setup_call_cb (Ekiga::CallManager & /*manager*/,
-                              Ekiga::Call & call,
+                              gmref_ptr<Ekiga::Call>  call,
                               gpointer self)
 {
   EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (self);
   gmref_ptr<Ekiga::AudioOutputCore> audiooutput_core
     = mw->priv->core->get ("audiooutput-core");
 
-  if (!call.is_outgoing ()) {
+  if (!call->is_outgoing ()) {
     ekiga_main_window_update_calling_state (mw, Called);
     audiooutput_core->start_play_event ("incoming_call_sound", 4000, 256);
 #ifdef HAVE_NOTIFY
@@ -560,22 +560,22 @@
   }
   else {
     ekiga_main_window_update_calling_state (mw, Calling);
-    if (!call.get_remote_uri ().empty ())
-      ekiga_main_window_set_call_url (mw, call.get_remote_uri ().c_str());
-    mw->priv->current_call = &call;
+    if (!call->get_remote_uri ().empty ())
+      ekiga_main_window_set_call_url (mw, call->get_remote_uri ().c_str());
+    mw->priv->current_call = call;
   }
 }
 
 
 static void on_ringing_call_cb (Ekiga::CallManager & /*manager*/,
-                                Ekiga::Call & call,
+                                gmref_ptr<Ekiga::Call>  call,
                                 gpointer self)
 {
   EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (self);
   gmref_ptr<Ekiga::AudioOutputCore> audiooutput_core
     = mw->priv->core->get ("audiooutput-core");
 
-  if (call.is_outgoing ()) {
+  if (call->is_outgoing ()) {
     audiooutput_core->start_play_event("ring_tone_sound", 3000, 256);
   }
 }
@@ -635,17 +635,17 @@
 }
 
 static void on_established_call_cb (Ekiga::CallManager & /*manager*/,
-                                    Ekiga::Call & call,
+                                    gmref_ptr<Ekiga::Call>  call,
                                     gpointer self)
 {
   EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (self);
   gchar* info = NULL;
 
   info = g_strdup_printf (_("Connected with %s"),
-			  call.get_remote_party_name ().c_str ());
+			  call->get_remote_party_name ().c_str ());
 
-  if (!call.get_remote_uri ().empty ())
-    ekiga_main_window_set_call_url (mw, call.get_remote_uri ().c_str());
+  if (!call->get_remote_uri ().empty ())
+    ekiga_main_window_set_call_url (mw, call->get_remote_uri ().c_str());
   if (gm_conf_get_bool (VIDEO_DISPLAY_KEY "stay_on_top"))
     ekiga_main_window_set_stay_on_top (mw, TRUE);
   ekiga_main_window_set_status (mw, info);
@@ -654,7 +654,7 @@
     ekiga_main_window_show_call_panel (mw);
   ekiga_main_window_update_calling_state (mw, Connected);
 
-  mw->priv->current_call = &call;
+  mw->priv->current_call = call;
 
   mw->priv->timeout_id = g_timeout_add (1000, on_stats_refresh_cb, self);
 
@@ -669,7 +669,7 @@
 
 
 static void on_cleared_call_cb (Ekiga::CallManager & /*manager*/,
-                                Ekiga::Call & call,
+                                gmref_ptr<Ekiga::Call>  call,
                                 std::string reason, 
                                 gpointer self)
 {
@@ -687,8 +687,7 @@
   ekiga_main_window_push_message (mw, "%s", reason.c_str ());
   ekiga_main_window_update_logo_have_window (mw);
 
-  if (mw->priv->current_call && mw->priv->current_call->get_id () == call.get_id ()) {
-
+  if (mw->priv->current_call && mw->priv->current_call->get_id () == call->get_id ()) {
     mw->priv->current_call = NULL;
     g_source_remove (mw->priv->timeout_id);
     mw->priv->timeout_id = -1;
@@ -732,7 +731,7 @@
 
 
 static void on_held_call_cb (Ekiga::CallManager & /*manager*/,
-                             Ekiga::Call & /*call*/,
+                             gmref_ptr<Ekiga::Call>  /*call*/,
                              gpointer self)
 {
   EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (self);
@@ -743,7 +742,7 @@
 
 
 static void on_retrieved_call_cb (Ekiga::CallManager & /*manager*/,
-                                  Ekiga::Call & /*call*/,
+                                  gmref_ptr<Ekiga::Call>  /*call*/,
                                   gpointer self)
 {
   EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (self);
@@ -754,7 +753,7 @@
 
 
 static void on_missed_call_cb (Ekiga::CallManager & /*manager*/,
-                               Ekiga::Call & call,
+                               gmref_ptr<Ekiga::Call>  call,
                                gpointer self)
 {
   EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (self);
@@ -766,14 +765,14 @@
 
   gchar* info = NULL;
   info = g_strdup_printf (_("Missed call from %s"),
-			  call.get_remote_party_name ().c_str ());
+			  call->get_remote_party_name ().c_str ());
   ekiga_main_window_push_message (mw, "%s", info);
   g_free (info);
 }
 
 
 static void on_stream_opened_cb (Ekiga::CallManager & /*manager*/,
-                                 Ekiga::Call & /* call */,
+                                 gmref_ptr<Ekiga::Call>  /* call */,
                                  std::string name,
                                  Ekiga::Call::StreamType type,
                                  bool is_transmitting,
@@ -822,7 +821,7 @@
 
 
 static void on_stream_closed_cb (Ekiga::CallManager & /*manager*/,
-                                 Ekiga::Call & /* call */,
+                                 gmref_ptr<Ekiga::Call>  /* call */,
                                  std::string name,
                                  Ekiga::Call::StreamType type,
                                  bool is_transmitting,
@@ -871,7 +870,7 @@
 
 
 static void on_stream_paused_cb (Ekiga::CallManager & /*manager*/,
-                                 Ekiga::Call & /*call*/,
+                                 gmref_ptr<Ekiga::Call>  /*call*/,
                                  std::string /*name*/,
                                  Ekiga::Call::StreamType type,
                                  gpointer self)
@@ -881,7 +880,7 @@
 
 
 static void on_stream_resumed_cb (Ekiga::CallManager & /*manager*/,
-                                  Ekiga::Call & /*call*/,
+                                  gmref_ptr<Ekiga::Call>  /*call*/,
                                   std::string /*name*/,
                                   Ekiga::Call::StreamType type,
                                   gpointer self)
@@ -972,7 +971,7 @@
   dialog_title =
   g_strdup_printf (_("Error while initializing video output"));
 
-  tmp_msg = g_strdup (_("No video will be displayed during this call."));
+  tmp_msg = g_strdup (_("No video will be displayed during this call->"));
   switch (error_code) {
 
     case Ekiga::VO_ERROR_NONE:
@@ -1484,11 +1483,8 @@
 {
   EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (data);
 
-  if (mw->priv->current_call) {
-
+  if (mw->priv->current_call)
     mw->priv->current_call->hangup ();
-    mw->priv->current_call = NULL;
-  }
 }
 
 
@@ -2590,7 +2586,7 @@
 
 static void
 ekiga_main_window_incoming_call_dialog_show (EkigaMainWindow *mw,
-                                             Ekiga::Call & call)
+                                             gmref_ptr<Ekiga::Call>  call)
 {
   GdkPixbuf *pixbuf = NULL;
 
@@ -2603,10 +2599,10 @@
   gchar *msg = NULL;
 
   // FIXME could the call become invalid ?
-  const char *utf8_name = call.get_remote_party_name ().c_str ();
-  const char *utf8_app = call.get_remote_application ().c_str ();
-  const char *utf8_url = call.get_remote_uri ().c_str ();
-  const char *utf8_local = call.get_local_party_name ().c_str ();
+  const char *utf8_name = call->get_remote_party_name ().c_str ();
+  const char *utf8_app = call->get_remote_application ().c_str ();
+  const char *utf8_url = call->get_remote_uri ().c_str ();
+  const char *utf8_local = call->get_local_party_name ().c_str ();
 
   g_return_if_fail (EKIGA_IS_MAIN_WINDOW (mw));
 
@@ -2687,9 +2683,9 @@
   g_signal_connect (G_OBJECT (incoming_call_popup), "response",
                     GTK_SIGNAL_FUNC (incoming_call_response_cb), &call);
 
-  call.cleared.connect (sigc::bind (sigc::ptr_fun (on_cleared_incoming_call_cb),
+  call->cleared.connect (sigc::bind (sigc::ptr_fun (on_cleared_incoming_call_cb),
                                     (gpointer) incoming_call_popup));
-  call.missed.connect (sigc::bind (sigc::ptr_fun (on_missed_incoming_call_cb), 
+  call->missed.connect (sigc::bind (sigc::ptr_fun (on_missed_incoming_call_cb), 
                                    (gpointer) incoming_call_popup));
 }
 
@@ -2732,7 +2728,7 @@
 
 static void
 ekiga_main_window_incoming_call_notify (EkigaMainWindow *mw,
-                                        Ekiga::Call & call)
+                                        gmref_ptr<Ekiga::Call>  call)
 {
   NotifyNotification *notify = NULL;
   
@@ -2747,10 +2743,10 @@
   statusicon = GTK_STATUS_ICON (GnomeMeeting::Process ()->GetStatusicon ());
 
   // FIXME could the call become invalid ?
-  const char *utf8_name = call.get_remote_party_name ().c_str ();
-  const char *utf8_app = call.get_remote_application ().c_str ();
-  const char *utf8_url = call.get_remote_uri ().c_str ();
-  const char *utf8_local = call.get_local_party_name ().c_str ();
+  const char *utf8_name = call->get_remote_party_name ().c_str ();
+  const char *utf8_app = call->get_remote_application ().c_str ();
+  const char *utf8_url = call->get_remote_uri ().c_str ();
+  const char *utf8_local = call->get_local_party_name ().c_str ();
 
   title = g_strdup_printf ("%s %s", _("Incoming call from"), (const char*) utf8_name);
 
@@ -2773,9 +2769,9 @@
     ekiga_main_window_incoming_call_dialog_show (mw, call);
   }
   else {
-    call.cleared.connect (sigc::bind (sigc::ptr_fun (on_cleared_incoming_call_cb),
+    call->cleared.connect (sigc::bind (sigc::ptr_fun (on_cleared_incoming_call_cb),
                                       (gpointer) notify));
-    call.missed.connect (sigc::bind (sigc::ptr_fun (on_missed_incoming_call_cb), 
+    call->missed.connect (sigc::bind (sigc::ptr_fun (on_missed_incoming_call_cb), 
                                      (gpointer) notify));
   }
 

Modified: trunk/src/gui/statusicon.cpp
==============================================================================
--- trunk/src/gui/statusicon.cpp	(original)
+++ trunk/src/gui/statusicon.cpp	Mon Oct 27 21:32:13 2008
@@ -127,12 +127,12 @@
 
 static void 
 established_call_cb (Ekiga::CallManager & manager,
-                     Ekiga::Call & call,
+                     gmref_ptr<Ekiga::Call>  call,
                      gpointer self);
 
 static void 
 cleared_call_cb (Ekiga::CallManager & manager,
-                 Ekiga::Call & call,
+                 gmref_ptr<Ekiga::Call>  call,
                  std::string reason,
                  gpointer self);
 
@@ -356,7 +356,7 @@
 
 static void 
 established_call_cb (Ekiga::CallManager & /*manager*/,
-                     Ekiga::Call & /*call*/,
+                     gmref_ptr<Ekiga::Call>  /*call*/,
                      gpointer self)
 {
   statusicon_set_inacall (STATUSICON (self), true);
@@ -365,7 +365,7 @@
 
 static void 
 cleared_call_cb (Ekiga::CallManager & /*manager*/,
-                 Ekiga::Call & /*call*/,
+                 gmref_ptr<Ekiga::Call>  /*call*/,
                  std::string /*reason*/,
                  gpointer self)
 {



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