[ekiga] Made the sip endpoint used a shared pointer instead of a weak one for the opal account store



commit 6eff3c5a0dde1a293ed7c9f17b6b6476e9d045aa
Author: Julien Puydt <jpuydt free fr>
Date:   Tue Jan 22 23:06:23 2013 +0100

    Made the sip endpoint used a shared pointer instead of a weak one for the opal account store

 lib/engine/components/opal/sip-endpoint.cpp |   43 ++++++++------------------
 lib/engine/components/opal/sip-endpoint.h   |    2 +-
 2 files changed, 14 insertions(+), 31 deletions(-)
---
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index ff50314..de06234 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -180,10 +180,6 @@ Opal::Sip::EndPoint::menu_builder_add_actions (const std::string& fullname,
 					       Ekiga::MenuBuilder & builder)
 {
   bool populated = false;
-  boost::shared_ptr<Opal::Bank> bk = bank.lock ();
-
-  if (!bk)
-    return false;
 
   std::list<std::string> uris;
   std::list<std::string> accounts_list;
@@ -193,8 +189,8 @@ Opal::Sip::EndPoint::menu_builder_add_actions (const std::string& fullname,
 
   if (uri.find ("@") == string::npos) {
 
-    for (Opal::Bank::iterator it = bk->begin ();
-	 it != bk->end ();
+    for (Opal::Bank::iterator it = bank->begin ();
+	 it != bank->end ();
 	 it++) {
 
       if ((*it)->get_protocol_name () == "SIP" && (*it)->is_enabled ()) {
@@ -995,13 +991,10 @@ Opal::Sip::EndPoint::registration_event_in_main (const std::string aor,
 						 Opal::Account::RegistrationState state,
 						 const std::string msg)
 {
-  if (boost::shared_ptr<Opal::Bank> bk = bank.lock ()) {
-
-    AccountPtr account = bk->find_account (aor);
+  AccountPtr account = bank->find_account (aor);
 
-    if (account)
-      account->handle_registration_event (state, msg);
-  }
+  if (account)
+    account->handle_registration_event (state, msg);
 }
 
 void
@@ -1024,14 +1017,11 @@ void
 Opal::Sip::EndPoint::mwi_received_in_main (const std::string aor,
 					   const std::string info)
 {
-  if (boost::shared_ptr<Opal::Bank> bk = bank.lock ()) {
-
-    AccountPtr account = bk->find_account (aor);
+  AccountPtr account = bank->find_account (aor);
 
-    if (account) {
+  if (account) {
 
-      account->handle_message_waiting_information (info);
-    }
+    account->handle_message_waiting_information (info);
   }
 }
 
@@ -1039,13 +1029,10 @@ void
 Opal::Sip::EndPoint::update_bank ()
 {
   bank = core.get<Opal::Bank> ("opal-account-store");
-  if (boost::shared_ptr<Opal::Bank> bk = bank.lock ()) { // should always happen, but still
-
-    bk->account_added.connect (boost::bind (&Opal::Sip::EndPoint::account_added, this, _1));
-    bk->account_updated.connect (boost::bind (&Opal::Sip::EndPoint::account_updated_or_removed, this, _1));
-    bk->account_removed.connect (boost::bind (&Opal::Sip::EndPoint::account_updated_or_removed, this, _1));
-    account_updated_or_removed (Ekiga::AccountPtr ()/* unused*/);
-  }
+  bank->account_added.connect (boost::bind (&Opal::Sip::EndPoint::account_added, this, _1));
+  bank->account_updated.connect (boost::bind (&Opal::Sip::EndPoint::account_updated_or_removed, this, _1));
+  bank->account_removed.connect (boost::bind (&Opal::Sip::EndPoint::account_updated_or_removed, this, _1));
+  account_updated_or_removed (Ekiga::AccountPtr ()/* unused*/);
 }
 
 void
@@ -1062,11 +1049,7 @@ Opal::Sip::EndPoint::account_updated_or_removed (Ekiga::AccountPtr /*account*/)
     accounts.clear ();
   }
   { // ... because here we call something which will want that very same mutex!
-    bank = core.get<Opal::Bank> ("opal-account-store");
-    if (boost::shared_ptr<Opal::Bank> bk = bank.lock ()) { // should always happen, but still
-
-      bk->visit_accounts (boost::bind (&Opal::Sip::EndPoint::visit_account, this, _1));
-    }
+    bank->visit_accounts (boost::bind (&Opal::Sip::EndPoint::visit_account, this, _1));
   }
 }
 
diff --git a/lib/engine/components/opal/sip-endpoint.h b/lib/engine/components/opal/sip-endpoint.h
index e133e16..71e43b3 100644
--- a/lib/engine/components/opal/sip-endpoint.h
+++ b/lib/engine/components/opal/sip-endpoint.h
@@ -210,7 +210,7 @@ namespace Opal {
 
       unsigned listen_port;
 
-      boost::weak_ptr<Opal::Bank> bank;
+      boost::shared_ptr<Opal::Bank> bank;
       boost::shared_ptr<SIP::Dialect> dialect;
     };
   };



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