[ekiga] Made Opal::Bank a better Ekiga::Cluster



commit a69561c997acfd4f495fa7ec4caa1d24c466a932
Author: Julien Puydt <jpuydt free fr>
Date:   Sun Feb 16 20:25:31 2014 +0100

    Made Opal::Bank a better Ekiga::Cluster
    
    That should make the roster update better when adding and removing accounts

 lib/engine/components/opal/opal-bank.cpp |   18 ++++++++++++++++--
 lib/engine/components/opal/opal-bank.h   |    2 ++
 2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-bank.cpp b/lib/engine/components/opal/opal-bank.cpp
index 5f7f4d1..b4bd207 100644
--- a/lib/engine/components/opal/opal-bank.cpp
+++ b/lib/engine/components/opal/opal-bank.cpp
@@ -84,13 +84,15 @@ Opal::Bank::Bank (Ekiga::ServiceCore& core):
                                                      personal_details, audiooutput_core, opal_component,
                                                      boost::bind(&Opal::Bank::existing_groups, this), 
child));
 
-      add_account (account);
       Ekiga::BankImpl<Account>::add_connection (account, account->presentity_added.connect (boost::bind 
(boost::ref(presentity_added), account, _1)));
       Ekiga::BankImpl<Account>::add_connection (account, account->presentity_updated.connect (boost::bind 
(boost::ref(presentity_updated), account, _1)));
       Ekiga::BankImpl<Account>::add_connection (account, account->presentity_removed.connect (boost::bind 
(boost::ref(presentity_removed), account, _1)));
       Ekiga::BankImpl<Account>::add_connection (account, account->trigger_saving.connect (boost::bind 
(&Opal::Bank::save, this)));
       Ekiga::BankImpl<Account>::add_connection (account, account->presence_received.connect (boost::ref 
(presence_received)));
       Ekiga::BankImpl<Account>::add_connection (account, account->status_received.connect (boost::ref 
(status_received)));
+      Ekiga::BankImpl<Account>::add_connection (account, account->removed.connect (boost::bind 
(&Opal::Bank::on_account_removed, this, account)));
+      add_account (account);
+      heap_added (account);
     }
   }
 
@@ -310,10 +312,15 @@ Opal::Bank::add (Account::Type acc_type,
                                    opal_component,
                                    boost::bind(&Opal::Bank::existing_groups, this),
                                    child));
-  add_account (account);
+  Ekiga::BankImpl<Account>::add_connection (account, account->presentity_added.connect (boost::bind 
(boost::ref(presentity_added), account, _1)));
+  Ekiga::BankImpl<Account>::add_connection (account, account->presentity_updated.connect (boost::bind 
(boost::ref(presentity_updated), account, _1)));
+  Ekiga::BankImpl<Account>::add_connection (account, account->presentity_removed.connect (boost::bind 
(boost::ref(presentity_removed), account, _1)));
   Ekiga::BankImpl<Account>::add_connection (account, account->trigger_saving.connect (boost::bind 
(&Opal::Bank::save, this)));
   Ekiga::BankImpl<Account>::add_connection (account, account->presence_received.connect (boost::ref 
(presence_received)));
   Ekiga::BankImpl<Account>::add_connection (account, account->status_received.connect (boost::ref 
(status_received)));
+  Ekiga::BankImpl<Account>::add_connection (account, account->removed.connect (boost::bind 
(&Opal::Bank::on_account_removed, this, account)));
+  add_account (account);
+  heap_added (account);
 
   if (is_call_manager_ready && enabled)
     account->enable ();
@@ -364,6 +371,13 @@ Opal::Bank::save () const
   xmlFree (buffer);
 }
 
+void
+Opal::Bank::on_account_removed (boost::shared_ptr<Account> account)
+{
+  heap_removed (account);
+  remove_account (account);
+}
+
 
 void
 Opal::Bank::publish (const Ekiga::PersonalDetails& details)
diff --git a/lib/engine/components/opal/opal-bank.h b/lib/engine/components/opal/opal-bank.h
index 0269d8c..9cf3752 100644
--- a/lib/engine/components/opal/opal-bank.h
+++ b/lib/engine/components/opal/opal-bank.h
@@ -155,6 +155,8 @@ private:
 
     void save () const;
 
+    void on_account_removed (boost::shared_ptr<Account> account);
+
     void on_registration_event (std::string aor,
                                Opal::Account::RegistrationState state,
                                std::string msg);


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