[ekiga] Revert "Made the SIP endpoint only retain a weak reference on the opal bank to avoid a loop"



commit a82676c34ad665a9d3c51490ab820b5c4a060863
Author: Damien Sandras <dsandras beip be>
Date:   Sat Jan 26 13:18:01 2013 +0100

    Revert "Made the SIP endpoint only retain a weak reference on the opal bank to avoid a loop"
    
    This reverts commit cf00a2bfb4eec60f150c65f517c9f85abcefd5ff.
    
    It seems the bank can not be accessed to check if registration works or
    not. Temporarily reverting.

 lib/engine/components/opal/sip-endpoint.cpp |   35 ++++++++------------------
 lib/engine/components/opal/sip-endpoint.h   |    2 +-
 2 files changed, 12 insertions(+), 25 deletions(-)
---
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index aa0f0c1..de06234 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -120,7 +120,6 @@ Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
 	core (_core)
 {
   boost::shared_ptr<Ekiga::ChatCore> chat_core = core.get<Ekiga::ChatCore> ("chat-core");
-  bank = core.get<Opal::Bank> ("opal-account-store");
 
   protocol_name = "sip";
   uri_prefix = "sip:";
@@ -180,7 +179,6 @@ Opal::Sip::EndPoint::menu_builder_add_actions (const std::string& fullname,
 					       const std::string& uri,
 					       Ekiga::MenuBuilder & builder)
 {
-  boost::shared_ptr<Opal::Bank> bk = bank.lock ();
   bool populated = false;
 
   std::list<std::string> uris;
@@ -189,10 +187,10 @@ Opal::Sip::EndPoint::menu_builder_add_actions (const std::string& fullname,
   if (!(uri.find ("sip:") == 0 || uri.find (":") == string::npos))
     return false;
 
-  if (uri.find ("@") == string::npos && bk) {
+  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 ()) {
@@ -993,10 +991,7 @@ Opal::Sip::EndPoint::registration_event_in_main (const std::string aor,
 						 Opal::Account::RegistrationState state,
 						 const std::string msg)
 {
-  boost::shared_ptr<Opal::Bank> bk = bank.lock ();
-  if (!bk)
-    return;
-  AccountPtr account = bk->find_account (aor);
+  AccountPtr account = bank->find_account (aor);
 
   if (account)
     account->handle_registration_event (state, msg);
@@ -1022,10 +1017,7 @@ void
 Opal::Sip::EndPoint::mwi_received_in_main (const std::string aor,
 					   const std::string info)
 {
-  boost::shared_ptr<Opal::Bank> bk = bank.lock ();
-  if (!bk)
-    return;
-  AccountPtr account = bk->find_account (aor);
+  AccountPtr account = bank->find_account (aor);
 
   if (account) {
 
@@ -1036,14 +1028,11 @@ Opal::Sip::EndPoint::mwi_received_in_main (const std::string aor,
 void
 Opal::Sip::EndPoint::update_bank ()
 {
-  boost::shared_ptr<Opal::Bank> bk = bank.lock ();
-  if (bk) {
-
-    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 = core.get<Opal::Bank> ("opal-account-store");
+  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
@@ -1060,9 +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!
-    boost::shared_ptr<Opal::Bank> bk = bank.lock ();
-    if (bk)
-      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]