ekiga r6481 - in trunk: . lib/engine/account/skel lib/engine/protocol/skel src/endpoints src/gui



Author: dsandras
Date: Tue Jul 22 19:37:39 2008
New Revision: 6481
URL: http://svn.gnome.org/viewvc/ekiga?rev=6481&view=rev

Log:
Fixed possible crashes on exit. Remove the Bank from the AccountCore
when destroying it. Committed a few cleanups.


Modified:
   trunk/ChangeLog
   trunk/lib/engine/account/skel/account-core.cpp
   trunk/lib/engine/account/skel/account-core.h
   trunk/lib/engine/account/skel/bank-impl.h
   trunk/lib/engine/account/skel/bank.h
   trunk/lib/engine/protocol/skel/call-core.h
   trunk/src/endpoints/opal-bank.h
   trunk/src/endpoints/opal-main.cpp
   trunk/src/endpoints/sip.cpp
   trunk/src/endpoints/sip.h
   trunk/src/gui/main.cpp
   trunk/src/gui/statusicon.cpp

Modified: trunk/lib/engine/account/skel/account-core.cpp
==============================================================================
--- trunk/lib/engine/account/skel/account-core.cpp	(original)
+++ trunk/lib/engine/account/skel/account-core.cpp	Tue Jul 22 19:37:39 2008
@@ -92,6 +92,16 @@
 }
 
 
+void Ekiga::AccountCore::remove_bank (Bank &bank)
+{
+  banks.erase (&bank);
+
+  bank_removed.emit (bank);
+
+  bank.questions.add_handler (questions.make_slot ());
+}
+
+
 void Ekiga::AccountCore::visit_banks (sigc::slot<bool, Bank &> visitor)
 {
   bool go_on = true;

Modified: trunk/lib/engine/account/skel/account-core.h
==============================================================================
--- trunk/lib/engine/account/skel/account-core.h	(original)
+++ trunk/lib/engine/account/skel/account-core.h	Tue Jul 22 19:37:39 2008
@@ -98,6 +98,11 @@
      */
     void add_bank (Bank &bank);
 
+    /** Remove a bank to the AccountCore service.
+     * @param The bank to be removed.
+     */
+    void remove_bank (Bank &bank);
+
 
     /** Triggers a callback for all Ekiga::Bank banks of the
      * AccountCore service.
@@ -111,6 +116,10 @@
      */
     sigc::signal<void, Bank &> bank_added;
 
+    /** This signal is emitted when a bank has been removed from the core
+     */
+    sigc::signal<void, Bank &> bank_removed;
+
     /** This signal is emitted when a account has been added to one of
      * the banks
      */

Modified: trunk/lib/engine/account/skel/bank-impl.h
==============================================================================
--- trunk/lib/engine/account/skel/bank-impl.h	(original)
+++ trunk/lib/engine/account/skel/bank-impl.h	Tue Jul 22 19:37:39 2008
@@ -58,6 +58,9 @@
    * bank: it will take care of implementing the external api, you
    * just have to decide when to add and remove accounts.
    *
+   * Any deleted BankImpl is automatically removed from the AccountCore. 
+   * The implementor should not have to take care about that.
+   *
    * You can remove a Account from an Ekiga::BankImpl in two ways:
    *  - either by calling the remove_account method,
    *  - or by emission of the account's removed signal.
@@ -90,7 +93,7 @@
 
     /** The destructor.
      */
-    ~BankImpl ();
+    virtual ~BankImpl ();
 
     /** Visit all accounts of the bank and trigger the given callback.
      * @param The callback (the return value means "go on" and allows
@@ -192,6 +195,7 @@
 template<typename T>
 Ekiga::BankImpl<T>::~BankImpl ()
 {
+  account_core->remove_bank (*this);
 }
 
 

Modified: trunk/lib/engine/account/skel/bank.h
==============================================================================
--- trunk/lib/engine/account/skel/bank.h	(original)
+++ trunk/lib/engine/account/skel/bank.h	Tue Jul 22 19:37:39 2008
@@ -55,6 +55,10 @@
   {
   public:
 
+
+    virtual ~Bank () { }
+
+
     /** Visit all accounts of the bank and trigger the given callback.
      * @param The callback (the return value means "go on" and allows
      *  stopping the visit)

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	Tue Jul 22 19:37:39 2008
@@ -43,6 +43,7 @@
 #include <sigc++/sigc++.h>
 #include <set>
 #include <map>
+#include <iostream>
 
 
 namespace Ekiga
@@ -65,11 +66,11 @@
 
       /** The constructor
        */
-      CallCore () {}
+      CallCore () { }
 
       /** The destructor
        */
-      ~CallCore () {}
+      ~CallCore () { }
 
 
       /*** Service Implementation ***/

Modified: trunk/src/endpoints/opal-bank.h
==============================================================================
--- trunk/src/endpoints/opal-bank.h	(original)
+++ trunk/src/endpoints/opal-bank.h	Tue Jul 22 19:37:39 2008
@@ -56,6 +56,8 @@
 public:
     Bank (Ekiga::ServiceCore &_core) : Ekiga::BankImpl<Opal::Account> (_core) {}
 
+    virtual ~Bank () { }
+
     bool populate_menu (Ekiga::MenuBuilder & builder);
 
     const std::string get_name () const

Modified: trunk/src/endpoints/opal-main.cpp
==============================================================================
--- trunk/src/endpoints/opal-main.cpp	(original)
+++ trunk/src/endpoints/opal-main.cpp	Tue Jul 22 19:37:39 2008
@@ -64,10 +64,9 @@
 on_call_manager_ready_cb (Ekiga::ServiceCore *core)
 {
   Ekiga::AccountCore *account_core = dynamic_cast<Ekiga::AccountCore *> (core->get ("account-core"));
-
   Opal::Bank *bank = new Bank (*core);
+
   account_core->add_bank (*bank);
-  core->add (*bank);
 }
 
 bool

Modified: trunk/src/endpoints/sip.cpp
==============================================================================
--- trunk/src/endpoints/sip.cpp	(original)
+++ trunk/src/endpoints/sip.cpp	Tue Jul 22 19:37:39 2008
@@ -164,6 +164,7 @@
   delete dialect;
 }
 
+
 bool CallProtocolManager::populate_menu (Ekiga::Contact &contact,
                                          Ekiga::MenuBuilder &builder)
 {
@@ -484,6 +485,22 @@
 }
 
 
+void CallProtocolManager::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 CallProtocolManager::Register (const Ekiga::Account & account)
 {
   std::stringstream aor;
@@ -908,8 +925,7 @@
      */
     if (host.GetHostAddress ().GetIpAndPort (address, port) && !manager.IsLocalAddress (address)) {
 
-      Ekiga::AccountCore *account_core = dynamic_cast<Ekiga::AccountCore *> (core.get ("account-core"));
-      Ekiga::Account *account = account_core->find_account ("ekiga.net");
+      Ekiga::Account *account = account_core.find_account ("ekiga.net");
 
       if (account)
         return SIPURL ("\"" + GetDefaultDisplayName () + "\" <" + account->get_aor () + ">");

Modified: trunk/src/endpoints/sip.h
==============================================================================
--- trunk/src/endpoints/sip.h	(original)
+++ trunk/src/endpoints/sip.h	Tue Jul 22 19:37:39 2008
@@ -134,6 +134,8 @@
 
 
       /* OPAL Methods */
+      void ShutDown ();
+
       void Register (const Ekiga::Account & account);
 
       void OnRegistered (const PString & aor,

Modified: trunk/src/gui/main.cpp
==============================================================================
--- trunk/src/gui/main.cpp	(original)
+++ trunk/src/gui/main.cpp	Tue Jul 22 19:37:39 2008
@@ -1,4 +1,4 @@
- 
+
 /* Ekiga -- A VoIP and Video-Conferencing application
  * Copyright (C) 2000-2006 Damien Sandras
  *
@@ -122,7 +122,7 @@
   GtkWidget *video_settings_window;
 
   GtkListStore *completion;
-  
+
   GtkTooltips *tips;
   GtkAccelGroup *accel;
 
@@ -3674,7 +3674,6 @@
 GtkWidget *
 gm_main_window_new (Ekiga::ServiceCore & core)
 {
-  Opal::CallManager *ep = NULL;
   GmMainWindow *mw = NULL;
 
   GtkWidget *window = NULL;
@@ -3714,9 +3713,6 @@
   g_object_set_data_full (G_OBJECT (window), "GMObject", 
 			  mw, (GDestroyNotify) gm_mw_destroy);
 
-  /* Get the manager */
-  ep = dynamic_cast<Opal::CallManager *> (core.get ("opal-component"));
-
 #ifndef WIN32
   mw->video_widget_gc = NULL;
 #endif

Modified: trunk/src/gui/statusicon.cpp
==============================================================================
--- trunk/src/gui/statusicon.cpp	(original)
+++ trunk/src/gui/statusicon.cpp	Tue Jul 22 19:37:39 2008
@@ -540,7 +540,6 @@
                 const char *key)
 {
   StatusIcon *self = NULL;
-  Opal::CallManager *manager = NULL;
 
   sigc::connection conn;
 
@@ -558,9 +557,6 @@
 
   g_object_set (self, "key", key, NULL);
 
-  manager = dynamic_cast<Opal::CallManager *> (core.get ("opal-component"));
-//  conn = manager->call_event.connect (sigc::bind (sigc::ptr_fun (on_call_event_cb), self));
-  //self->priv->connections.push_back (conn); // TODO Announce all events here
   GtkFrontend *frontend = dynamic_cast<GtkFrontend*>(core.get ("gtk-frontend"));
   GtkWidget *chat_window = GTK_WIDGET (frontend->get_chat_window ());
 



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