[ekiga] Changed the way the opal SIP endpoint manages the bank



commit 95a1dd4ce8afcbc5c84795fe7e4013f087ae4856
Author: Julien Puydt <jpuydt newton localdomain>
Date:   Wed Sep 21 22:22:44 2011 +0200

    Changed the way the opal SIP endpoint manages the bank
    
    I don't understand 100% why it even does what it does, but that should still be better

 lib/engine/components/opal/opal-main.cpp    |   11 ++---
 lib/engine/components/opal/sip-endpoint.cpp |   59 ++++++++++++++-------------
 lib/engine/components/opal/sip-endpoint.h   |    2 +
 3 files changed, 38 insertions(+), 34 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-main.cpp b/lib/engine/components/opal/opal-main.cpp
index 1f40dcf..c1dbb76 100644
--- a/lib/engine/components/opal/opal-main.cpp
+++ b/lib/engine/components/opal/opal-main.cpp
@@ -108,12 +108,6 @@ struct OPALSpark: public Ekiga::Spark
       boost::shared_ptr<CallManager> call_manager (new CallManager (core));
       core.add (call_manager);
 
-      boost::shared_ptr<Bank> bank (new Bank (core));
-
-      account_core->add_bank (bank);
-      core.add (bank);
-      call_manager->ready.connect (boost::bind (&Opal::Bank::call_manager_ready, &*bank));
-
       unsigned sip_port = gm_conf_get_int (SIP_KEY "listen_port");
       boost::shared_ptr<Sip::EndPoint> sip_manager (new Sip::EndPoint (*call_manager, core, sip_port));
       core.add (sip_manager);
@@ -122,6 +116,11 @@ struct OPALSpark: public Ekiga::Spark
       contact_core->add_contact_decorator (sip_manager);
       presence_core->add_presentity_decorator (sip_manager);
 
+      boost::shared_ptr<Bank> bank (new Bank (core));
+      account_core->add_bank (bank);
+      core.add (bank);
+      sip_manager->update_bank ();
+      call_manager->ready.connect (boost::bind (&Opal::Bank::call_manager_ready, &*bank));
       presence_core->add_presence_publisher (bank);
       presence_core->add_presence_fetcher (bank);
 
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index 82eaeb3..620b7c5 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -133,14 +133,6 @@ Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
   dialect = boost::shared_ptr<SIP::Dialect>(new SIP::Dialect (core, boost::bind (&Opal::Sip::EndPoint::send_message, this, _1, _2)));
   chat_core->add_dialect (dialect);
 
-  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::on_bank_updated, this, _1));
-    bk->account_removed.connect (boost::bind (&Opal::Sip::EndPoint::on_bank_updated, this, _1));
-    bk->account_updated.connect (boost::bind (&Opal::Sip::EndPoint::on_bank_updated, this, _1));
-  }
-
   /* Timeouts */
   SetAckTimeout (PTimeInterval (0, 32));
   SetPduCleanUpTimeout (PTimeInterval (0, 1));
@@ -1024,26 +1016,6 @@ void Opal::Sip::EndPoint::on_transfer (std::string uri)
 
 
 void
-Opal::Sip::EndPoint::on_bank_updated (Ekiga::AccountPtr /*account*/)
-{
-  if (boost::shared_ptr<Opal::Bank> bk = bank.lock ())
-    bk->visit_accounts (boost::bind (&Opal::Sip::EndPoint::visit_accounts, this, _1));
-}
-
-
-bool
-Opal::Sip::EndPoint::visit_accounts (Ekiga::AccountPtr account_)
-{
-  Opal::AccountPtr account = boost::dynamic_pointer_cast<Opal::Account> (account_);
-
-  PWaitAndSignal m(aorMutex);
-  accounts[account->get_host ()] = account->get_aor ();
-
-  return true;
-}
-
-
-void
 Opal::Sip::EndPoint::registration_event_in_main (const std::string aor,
 						 Opal::Account::RegistrationState state,
 						 const std::string msg)
@@ -1087,3 +1059,34 @@ Opal::Sip::EndPoint::mwi_received_in_main (const std::string aor,
     }
   }
 }
+
+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::on_bank_updated, this, _1));
+    bk->account_removed.connect (boost::bind (&Opal::Sip::EndPoint::on_bank_updated, this, _1));
+    bk->account_updated.connect (boost::bind (&Opal::Sip::EndPoint::on_bank_updated, this, _1));
+  }
+}
+
+void
+Opal::Sip::EndPoint::on_bank_updated (Ekiga::AccountPtr /*account*/)
+{
+  if (boost::shared_ptr<Opal::Bank> bk = bank.lock ())
+    bk->visit_accounts (boost::bind (&Opal::Sip::EndPoint::visit_accounts, this, _1));
+}
+
+
+bool
+Opal::Sip::EndPoint::visit_accounts (Ekiga::AccountPtr account_)
+{
+  Opal::AccountPtr account = boost::dynamic_pointer_cast<Opal::Account> (account_);
+
+  PWaitAndSignal m(aorMutex);
+  accounts[account->get_host ()] = account->get_aor ();
+
+  return true;
+}
diff --git a/lib/engine/components/opal/sip-endpoint.h b/lib/engine/components/opal/sip-endpoint.h
index 64f04c1..519f271 100644
--- a/lib/engine/components/opal/sip-endpoint.h
+++ b/lib/engine/components/opal/sip-endpoint.h
@@ -133,6 +133,8 @@ namespace Opal {
       /* Helper */
       static std::string get_aor_domain (const std::string & aor);
 
+      /* FIXME: doesn't look 100% right */
+      void update_bank ();
 
       /* OPAL Methods */
       void Register (const std::string username,



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