[ekiga] Made the opal accounts retain a reference to the SIP endpoint, and unsubscribe on destructor call



commit 663789e504ae32a338eaed8759220bd697707d82
Author: Julien Puydt <jpuydt newton localdomain>
Date:   Wed Sep 21 22:25:01 2011 +0200

    Made the opal accounts retain a reference to the SIP endpoint, and unsubscribe on destructor call
    
    Why that doesn't fix bug #622001 is a mystery for now... but its end is nigh.

 lib/engine/components/opal/opal-account.cpp |    9 +++------
 lib/engine/components/opal/opal-account.h   |    4 ++++
 2 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index 51da80c..04e58e4 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -63,6 +63,7 @@ Opal::Account::Account (Ekiga::ServiceCore & _core,
                         const std::string & account)
   : core (_core)
 {
+  endpoint = core.get<Sip::EndPoint> ("opal-sip-endpoint");
   dead = false;
   state = Unregistered;
   status = _("Unregistered");
@@ -177,6 +178,8 @@ Opal::Account::Account (Ekiga::ServiceCore & _core,
 
 Opal::Account::~Account ()
 {
+  if (state == Registered)
+    endpoint->unsubscribe (*this);
 }
 
 
@@ -293,7 +296,6 @@ void Opal::Account::enable ()
 {
   enabled = true;
 
-  boost::shared_ptr<Sip::EndPoint> endpoint = core.get<Sip::EndPoint> ("opal-sip-endpoint");
   endpoint->subscribe (*this);
   if (presentity) {
 
@@ -315,7 +317,6 @@ void Opal::Account::disable ()
 {
   enabled = false;
 
-  boost::shared_ptr<Sip::EndPoint> endpoint = core.get<Sip::EndPoint> ("opal-sip-endpoint");
   endpoint->unsubscribe (*this);
 
   if (presentity)
@@ -352,7 +353,6 @@ void Opal::Account::remove ()
   enabled = false;
   dead = true;
 
-  boost::shared_ptr<Sip::EndPoint> endpoint = core.get<Sip::EndPoint> ("opal-sip-endpoint");
   endpoint->unsubscribe (*this);
 
   trigger_saving ();
@@ -543,7 +543,6 @@ void
 Opal::Account::handle_registration_event (RegistrationState state_,
 					  const std::string info) const
 {
-  boost::shared_ptr<Sip::EndPoint> endpoint;
   switch (state_) {
 
   case Registered:
@@ -589,14 +588,12 @@ Opal::Account::handle_registration_event (RegistrationState state_,
       // FullyCompliant did not work, try next compat mode
       compat_mode = SIPRegister::e_CannotRegisterMultipleContacts;
       PTRACE (4, "Register failed in FullyCompliant mode, retrying in CannotRegisterMultipleContacts mode");
-      endpoint = core.get<Sip::EndPoint> ("opal-sip-endpoint");
       endpoint->subscribe (*this);
       break;
     case SIPRegister::e_CannotRegisterMultipleContacts:
       // CannotRegMC did not work, try next compat mode
       compat_mode = SIPRegister::e_CannotRegisterPrivateContacts;
       PTRACE (4, "Register failed in CannotRegisterMultipleContacts mode, retrying in CannotRegisterPrivateContacts mode");
-      endpoint = core.get<Sip::EndPoint> ("opal-sip-endpoint");
       endpoint->subscribe (*this);
       break;
     case SIPRegister::e_CannotRegisterPrivateContacts:
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index 394bef3..3d3a9fb 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -47,6 +47,9 @@
 
 namespace Opal
 {
+  // forward declaration:
+  namespace Sip { class EndPoint; };
+
   /**
    * @addtogroup accounts
    * @internal
@@ -202,6 +205,7 @@ private:
 				  std::string status);
 
     Ekiga::ServiceCore & core;
+    boost::shared_ptr<Sip::EndPoint> endpoint;
   };
 
   typedef boost::shared_ptr<Account> AccountPtr;



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