[ekiga] Use real shared_ptr instead of weak_ptr in the opal account code now we know there will be no loops



commit 8e24a17237081ae7fd8a4b66bfeb4a0ca2acff79
Author: Julien Puydt <jpuydt free fr>
Date:   Fri Feb 8 15:09:36 2013 +0100

    Use real shared_ptr instead of weak_ptr in the opal account code now we know there will be no loops

 lib/engine/components/opal/opal-account.cpp |   36 +++++++++-----------------
 lib/engine/components/opal/opal-account.h   |    4 +-
 2 files changed, 15 insertions(+), 25 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index 96ded16..dce5293 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -332,15 +332,12 @@ void Opal::Account::enable ()
   state = Processing;
   status = _("Processing...");
 #ifdef HAVE_H323
-  boost::shared_ptr<Opal::H323::EndPoint> h323 = h323_endpoint.lock ();
-  if (type == Account::H323 && h323)
-    h323->subscribe (*this, presentity);
+  if (type == Account::H323)
+    h323_endpoint->subscribe (*this, presentity);
   else
 #endif
     {
-      boost::shared_ptr<Opal::Sip::EndPoint> sip = sip_endpoint.lock ();
-      if (sip)
-	sip->subscribe (*this, presentity);
+      sip_endpoint->subscribe (*this, presentity);
     }
 
   updated ();
@@ -361,19 +358,15 @@ void Opal::Account::disable ()
     }
   }
 #ifdef HAVE_H323
-  boost::shared_ptr<Opal::H323::EndPoint> h323 = h323_endpoint.lock ();
-  if (type == Account::H323 && h323)
-    h323->unsubscribe (*this, presentity);
+  if (type == Account::H323)
+    h323_endpoint->unsubscribe (*this, presentity);
   else
 #endif
     {
-      boost::shared_ptr<Opal::Sip::EndPoint> sip = sip_endpoint.lock ();
-      if (sip) {
-
-	sip->unsubscribe (*this, presentity);
-	sip->Unsubscribe (SIPSubscribe::MessageSummary, get_aor ());
-      }
+      sip_endpoint->unsubscribe (*this, presentity);
+      sip_endpoint->Unsubscribe (SIPSubscribe::MessageSummary, get_aor ());
     }
+
   // Translators: this is a state, not an action, i.e. it should be read as
   // "(you are) unregistered", and not as "(you have been) unregistered"
   status = _("Unregistered");
@@ -719,7 +712,7 @@ Opal::Account::handle_registration_event (RegistrationState state_,
       // "(you are) registered", and not as "(you have been) registered"
       status = _("Registered");
       if (presentity) {
-	boost::shared_ptr<Opal::Sip::EndPoint> sip = sip_endpoint.lock ();
+
         for (std::set<std::string>::iterator iter = watched_uris.begin ();
              iter != watched_uris.end (); ++iter) {
           PTRACE(4, "Ekiga\tSubscribeToPresence for " << iter->c_str () << " (Account Registered)");
@@ -727,7 +720,7 @@ Opal::Account::handle_registration_event (RegistrationState state_,
         }
         presentity->SetLocalPresence (personal_state, presence_status);
         if (type != Account::H323) {
-          sip->Subscribe (SIPSubscribe::MessageSummary, 3600, get_aor ());
+          sip_endpoint->Subscribe (SIPSubscribe::MessageSummary, 3600, get_aor ());
         }
       }
       boost::shared_ptr<Ekiga::PresenceCore> pcore = presence_core.lock ();
@@ -780,27 +773,24 @@ Opal::Account::handle_registration_event (RegistrationState state_,
     }
     else {
 #endif
-      boost::shared_ptr<Opal::Sip::EndPoint> sip = sip_endpoint.lock ();
-      if (!sip)
-	return;
       switch (compat_mode) {
       case SIPRegister::e_FullyCompliant:
         // FullyCompliant did not work, try next compat mode
         compat_mode = SIPRegister::e_CannotRegisterMultipleContacts;
         PTRACE (4, "Register failed in FullyCompliant mode, retrying in CannotRegisterMultipleContacts mode");
-        sip->subscribe (*this, presentity);
+        sip_endpoint->subscribe (*this, presentity);
         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");
-        sip->subscribe (*this, presentity);
+        sip_endpoint->subscribe (*this, presentity);
         break;
       case SIPRegister::e_CannotRegisterPrivateContacts:
         // CannotRegMC did not work, try next compat mode
         compat_mode = SIPRegister::e_HasApplicationLayerGateway;
         PTRACE (4, "Register failed in CannotRegisterMultipleContacts mode, retrying in HasApplicationLayerGateway mode");
-        sip->subscribe (*this, presentity);
+        sip_endpoint->subscribe (*this, presentity);
         break;
       case SIPRegister::e_HasApplicationLayerGateway:
         // HasAppLG did not work, stop registration with error
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index cdbb164..dc00492 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -236,9 +236,9 @@ private:
 				  std::string presence,
 				  std::string status);
 
-    boost::weak_ptr<Opal::Sip::EndPoint> sip_endpoint;
+    boost::shared_ptr<Opal::Sip::EndPoint> sip_endpoint;
 #ifdef HAVE_H323
-    boost::weak_ptr<Opal::H323::EndPoint> h323_endpoint;
+    boost::shared_ptr<Opal::H323::EndPoint> h323_endpoint;
 #endif
     boost::weak_ptr<Ekiga::PresenceCore> presence_core;
     boost::weak_ptr<Ekiga::NotificationCore> notification_core;


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