[ekiga/gnome-2-26] Reworked the account stack (now uses gmref_ptr)



commit a448b775076d9ea2bcc6cdc5b94cc65a2b65b844
Author: Julien Puydt <jpuydt src gnome org>
Date:   Tue Mar 31 19:37:34 2009 +0000

    Reworked the account stack (now uses gmref_ptr)
    
    svn path=/trunk/; revision=7839
---
 lib/engine/account/account-core.cpp          |   51 ++++-----
 lib/engine/account/account-core.h            |   91 ++++++++--------
 lib/engine/account/account.h                 |   33 +++---
 lib/engine/account/bank-impl.h               |  151 +++++++++-----------------
 lib/engine/account/bank.h                    |   34 +++---
 lib/engine/components/opal/h323-endpoint.cpp |    8 +-
 lib/engine/components/opal/h323-endpoint.h   |    2 +-
 lib/engine/components/opal/opal-account.cpp  |    9 +-
 lib/engine/components/opal/opal-account.h    |    4 +-
 lib/engine/components/opal/opal-bank.cpp     |  106 ++++++++++++++-----
 lib/engine/components/opal/opal-bank.h       |   17 ++-
 lib/engine/components/opal/opal-main.cpp     |    4 +-
 lib/engine/components/opal/sip-endpoint.cpp  |   20 ++--
 lib/engine/components/opal/sip-endpoint.h    |    2 +-
 lib/engine/presence/presence-core.cpp        |    7 +-
 lib/engine/presence/presence-core.h          |    5 +-
 src/gui/accounts.cpp                         |  124 +++++++++++----------
 src/gui/assistant.cpp                        |   12 +-
 src/gui/main.cpp                             |   28 +++---
 19 files changed, 365 insertions(+), 343 deletions(-)

diff --git a/lib/engine/account/account-core.cpp b/lib/engine/account/account-core.cpp
index 8e458a7..9b6cd21 100644
--- a/lib/engine/account/account-core.cpp
+++ b/lib/engine/account/account-core.cpp
@@ -50,7 +50,8 @@ Ekiga::AccountCore::~AccountCore ()
 }
 
 
-bool Ekiga::AccountCore::populate_menu (MenuBuilder & builder)
+bool
+Ekiga::AccountCore::populate_menu (MenuBuilder & builder)
 {
   bool populated = false;
 
@@ -65,58 +66,54 @@ bool Ekiga::AccountCore::populate_menu (MenuBuilder & builder)
 }
 
 
-void Ekiga::AccountCore::add_bank (Bank &bank)
+void
+Ekiga::AccountCore::add_bank (BankPtr bank)
 {
-  banks.insert (&bank);
+  banks.push_back (bank);
 
-  bank.account_added.connect (account_added.make_slot ());
-  bank.account_removed.connect (account_removed.make_slot ());
-  bank.account_updated.connect (account_updated.make_slot ());
+  bank->account_added.connect (sigc::bind<0>(account_added.make_slot (), bank));
+  bank->account_removed.connect (sigc::bind<0>(account_removed.make_slot (), bank));
+  bank->account_updated.connect (sigc::bind<0>(account_updated.make_slot (), bank));
 
   bank_added.emit (bank);
 
-  bank.questions.add_handler (questions.make_slot ());
-  bank.registration_event.connect (sigc::mem_fun (this, &Ekiga::AccountCore::on_registration_event));
+  bank->questions.add_handler (questions.make_slot ());
+  bank->registration_event.connect (sigc::bind<0> (sigc::mem_fun (this, &Ekiga::AccountCore::on_registration_event), bank));
 }
 
 
-void Ekiga::AccountCore::remove_bank (Bank &bank)
-{
-  banks.erase (&bank);
-
-  bank_removed.emit (bank);
-
-  bank.questions.add_handler (questions.make_slot ());
-}
-
-
-void Ekiga::AccountCore::visit_banks (sigc::slot1<bool, Bank &> visitor)
+void
+Ekiga::AccountCore::visit_banks (sigc::slot1<bool, BankPtr> visitor)
 {
   bool go_on = true;
 
   for (bank_iterator iter = banks.begin ();
        iter != banks.end () && go_on;
        iter++)
-    go_on = visitor (*(*iter));
+    go_on = visitor (*iter);
 }
 
 
-void Ekiga::AccountCore::add_account_subscriber (AccountSubscriber &subscriber)
+void
+Ekiga::AccountCore::add_account_subscriber (AccountSubscriber &subscriber)
 {
   account_subscribers.insert (&subscriber);
 }
 
 
-void Ekiga::AccountCore::on_registration_event (const Ekiga::Account *account,
-                                                Ekiga::AccountCore::RegistrationState state,
-                                                const std::string info)
+void
+Ekiga::AccountCore::on_registration_event (BankPtr bank,
+					   AccountPtr account,
+					   Ekiga::Account::RegistrationState state,
+					   const std::string info)
 {
-  registration_event.emit (*account, state, info);
+  registration_event.emit (bank, account, state, info);
 }
 
 
-void Ekiga::AccountCore::on_mwi_event (const Ekiga::Account *account,
+void Ekiga::AccountCore::on_mwi_event (BankPtr bank,
+				       AccountPtr account,
                                        const std::string & info)
 {
-  mwi_event.emit (*account, info);
+  mwi_event.emit (bank, account, info);
 }
diff --git a/lib/engine/account/account-core.h b/lib/engine/account/account-core.h
index ab5add2..03e3d2c 100644
--- a/lib/engine/account/account-core.h
+++ b/lib/engine/account/account-core.h
@@ -36,7 +36,7 @@
 #ifndef __ACCOUNT_CORE_H__
 #define __ACCOUNT_CORE_H__
 
-#include <set>
+#include <list>
 #include <iostream>
 
 #include "menu-builder.h"
@@ -44,18 +44,21 @@
 #include "chain-of-responsibility.h"
 #include "services.h"
 
+#include "bank.h"
 
 /* declaration of a few helper classes */
 namespace Ekiga
 {
-  class AccountSubscriber;
-  class Bank;
-  class Account;
+  class AccountSubscriber
+  {
+  public:
+    virtual ~AccountSubscriber () {}
+  };
 
-/**
- * @defgroup accounts 
- * @{
- */
+  /**
+   * @defgroup accounts
+   * @{
+   */
 
   /** Core object for address account support.
    *
@@ -96,12 +99,7 @@ namespace Ekiga
     /** Adds a bank to the AccountCore service.
      * @param The bank to be added.
      */
-    void add_bank (Bank &bank);
-
-    /** Remove a bank to the AccountCore service.
-     * @param The bank to be removed.
-     */
-    void remove_bank (Bank &bank);
+    void add_bank (BankPtr bank);
 
 
     /** Triggers a callback for all Ekiga::Bank banks of the
@@ -109,44 +107,42 @@ namespace Ekiga
      * @param The callback (the return value means "go on" and allows
      *  stopping the visit)
      */
-    void visit_banks (sigc::slot1<bool, Bank &> visitor);
+    void visit_banks (sigc::slot1<bool, BankPtr> visitor);
 
 
     /** This signal is emitted when a bank has been added to the core
      */
-    sigc::signal1<void, Bank &> bank_added;
+    sigc::signal1<void, BankPtr> bank_added;
 
     /** This signal is emitted when a bank has been removed from the core
      */
-    sigc::signal1<void, Bank &> bank_removed;
+    sigc::signal1<void, BankPtr> bank_removed;
 
     /** This signal is emitted when a account has been added to one of
      * the banks
      */
-    sigc::signal1<void, Account &> account_added;
+    sigc::signal2<void, BankPtr, AccountPtr> account_added;
 
     /** This signal is emitted when a account has been removed from one of
      * the banks
      */
-    sigc::signal1<void, Account &> account_removed;
+    sigc::signal2<void, BankPtr, AccountPtr> account_removed;
 
     /** This signal is emitted when a account has been updated in one of
      * the banks
      */
-    sigc::signal1<void, Account &> account_updated;
+    sigc::signal2<void, BankPtr, AccountPtr> account_updated;
 
   private:
 
-    std::set<Bank *> banks;
-    typedef std::set<Bank *>::iterator bank_iterator;
-    typedef std::set<Bank *>::const_iterator bank_const_iterator;
+    std::list<BankPtr> banks;
+    typedef std::list<BankPtr>::iterator bank_iterator;
+    typedef std::list<BankPtr>::const_iterator bank_const_iterator;
 
 
     /*** Misc ***/
 
   public:
-    typedef enum { Processing, Registered, Unregistered, RegistrationFailed, UnregistrationFailed } RegistrationState;
-
 
     /** Create the menu for the AccountCore and its actions.
      * @param A MenuBuilder object to populate.
@@ -166,18 +162,18 @@ namespace Ekiga
 
 
     /** This signal is emitted when there is a new registration event
-     * @param: account is the account 
+     * @param: account is the account
      *         state is the state
      *         info contains information about the registration status
      */
-    sigc::signal3<void, const Ekiga::Account &, Ekiga::AccountCore::RegistrationState, std::string> registration_event;
+    sigc::signal4<void, BankPtr, AccountPtr, Account::RegistrationState, std::string> registration_event;
 
 
     /** This signal is emitted when there is a new message waiting event
-     * @param: account is the account 
-     *         info contains information about the indication 
+     * @param: account is the account
+     *         info contains information about the indication
      */
-    sigc::signal2<void, const Ekiga::Account &, std::string> mwi_event;
+    sigc::signal3<void, BankPtr, AccountPtr, std::string> mwi_event;
 
 
     /*** Account Subscriber API ***/
@@ -195,40 +191,36 @@ namespace Ekiga
     std::set<AccountSubscriber *> account_subscribers;
     typedef std::set<AccountSubscriber *>::iterator subscriber_iterator;
     typedef std::set<AccountSubscriber *>::const_iterator subscriber_const_iterator;
-    void on_registration_event (const Ekiga::Account *account,
-                                Ekiga::AccountCore::RegistrationState state,
+    void on_registration_event (BankPtr bank,
+				AccountPtr account,
+                                Account::RegistrationState state,
                                 const std::string info);
-    void on_mwi_event (const Ekiga::Account *account,
+    void on_mwi_event (BankPtr bank,
+		       AccountPtr account,
                        const std::string & info);
   };
 
 
-  class AccountSubscriber 
-  {
-public:
-    virtual ~AccountSubscriber () {}
-  };
-
-
   template<class T = Account>
   class AccountSubscriberImpl : public AccountSubscriber
   {
-public:
+  public:
     virtual ~AccountSubscriberImpl () {}
 
     virtual bool subscribe (const T & /*account*/);
     virtual bool unsubscribe (const T & /*account*/);
   };
 
-/**
- * @}
- */
+  /**
+   * @}
+   */
 };
 
 
 
 template<class T>
-bool Ekiga::AccountCore::subscribe_account (const T &account)
+bool
+Ekiga::AccountCore::subscribe_account (const T &account)
 {
   for (subscriber_iterator iter = account_subscribers.begin ();
        iter != account_subscribers.end ();
@@ -245,7 +237,8 @@ bool Ekiga::AccountCore::subscribe_account (const T &account)
 
 
 template<class T>
-bool Ekiga::AccountCore::unsubscribe_account (const T &account)
+bool
+Ekiga::AccountCore::unsubscribe_account (const T &account)
 {
   for (subscriber_iterator iter = account_subscribers.begin ();
        iter != account_subscribers.end ();
@@ -262,14 +255,16 @@ bool Ekiga::AccountCore::unsubscribe_account (const T &account)
 
 
 template<class T>
-bool Ekiga::AccountSubscriberImpl<T>::subscribe (const T & /*account*/)
+bool
+Ekiga::AccountSubscriberImpl<T>::subscribe (const T & /*account*/)
 {
   return false;
 }
 
 
 template<class T>
-bool Ekiga::AccountSubscriberImpl<T>::unsubscribe (const T & /*account*/)
+bool
+Ekiga::AccountSubscriberImpl<T>::unsubscribe (const T & /*account*/)
 {
   return false;
 }
diff --git a/lib/engine/account/account.h b/lib/engine/account/account.h
index feac75f..912590d 100644
--- a/lib/engine/account/account.h
+++ b/lib/engine/account/account.h
@@ -29,7 +29,7 @@
  *                         ------------------------------------------
  *   begin                : written in 2008 by Damien Sandras
  *   copyright            : (c) 2008 by Damien Sandras
- *   description          : declaration of the interface of an AccountManager 
+ *   description          : declaration of the interface of an AccountManager
  *                          Account
  *
  */
@@ -41,8 +41,7 @@
 #include <map>
 #include <string>
 
-#include "account-core.h"
-
+#include "gmref.h"
 #include "chain-of-responsibility.h"
 #include "form-request.h"
 #include "menu-builder.h"
@@ -50,15 +49,17 @@
 namespace Ekiga
 {
 
-/**
- * @addtogroup accounts 
- * @{
- */
+  /**
+   * @addtogroup accounts
+   * @{
+   */
 
-  class Account
+  class Account: public virtual GmRefCounted
   {
   public:
 
+    typedef enum { Processing, Registered, Unregistered, RegistrationFailed, UnregistrationFailed } RegistrationState;
+
 
     /** The destructor.
      */
@@ -115,8 +116,8 @@ namespace Ekiga
      * Ekiga::Account descendant.
      */
     virtual bool is_active () const = 0;
-    
-    
+
+
     /** Create the menu for that account and its actions.
      * This function is purely virtual and should be implemented by
      * the descendant of the Ekiga::Contact.
@@ -139,12 +140,12 @@ namespace Ekiga
     sigc::signal0<void> removed;
 
 
-    /** This signal is emitted when there is a new registration event for 
+    /** This signal is emitted when there is a new registration event for
      *  the Account.
      * @param: state is the state
      *         info contains information about the registration status
      */
-    sigc::signal2<void, Ekiga::AccountCore::RegistrationState, std::string> registration_event;
+    sigc::signal2<void, RegistrationState, std::string> registration_event;
 
 
     /** This signal is emitted when there is a new message waiting indication
@@ -158,9 +159,11 @@ namespace Ekiga
     ChainOfResponsibility<FormRequest*> questions;
   };
 
-/**
- * @}
- */
+  typedef gmref_ptr<Account> AccountPtr;
+
+  /**
+   * @}
+   */
 
 };
 #endif
diff --git a/lib/engine/account/bank-impl.h b/lib/engine/account/bank-impl.h
index 21c1e95..ce47fe2 100644
--- a/lib/engine/account/bank-impl.h
+++ b/lib/engine/account/bank-impl.h
@@ -37,17 +37,12 @@
 #ifndef __BANK_IMPL_H__
 #define __BANK_IMPL_H__
 
-#include "config.h"
-#include "lister.h"
-#include "account-core.h"
-#include "account.h"
+#include "reflister.h"
 #include "bank.h"
-#include "gmconf.h"
+
 
 namespace Ekiga
 {
-  class AccountCore;
-
 /**
  * @addtogroup accounts
  * @{
@@ -59,7 +54,7 @@ namespace Ekiga
    * bank: it will take care of implementing the external api, you
    * just have to decide when to add and remove accounts.
    *
-   * Any deleted BankImpl is automatically removed from the AccountCore. 
+   * Any deleted BankImpl is automatically removed from the AccountCore.
    * The implementor should not have to take care about that.
    *
    * You can remove a Account from an Ekiga::BankImpl in two ways:
@@ -76,36 +71,36 @@ namespace Ekiga
    *    calling the appropriate api function to delete the account in your
    *    backend.
    */
-  template<class T = Account>
+  template<class AccountType = Account>
   class BankImpl:
     public Bank,
     public sigc::trackable,
-    protected Lister<T>
+    protected RefLister<AccountType>
   {
 
   public:
 
-    typedef typename Lister<T>::iterator iterator;
-    typedef typename Lister<T>::const_iterator const_iterator;
+    typedef typename RefLister<AccountType>::iterator iterator;
+    typedef typename RefLister<AccountType>::const_iterator const_iterator;
 
     /** The constructor
      */
-    BankImpl (ServiceCore &core);
+    BankImpl ();
 
     /** The destructor.
      */
-    virtual ~BankImpl ();
+    ~BankImpl ();
 
     /** Visit all accounts of the bank and trigger the given callback.
      * @param The callback (the return value means "go on" and allows
      *  stopping the visit)
      */
-    void visit_accounts (sigc::slot1<bool, Account &> visitor);
+    void visit_accounts (sigc::slot1<bool, AccountPtr> visitor);
 
-    /** This function be called when a new account has to be added to the Bank.
+    /** This function is called when a new account has to be added to the Bank.
      */
     void new_account ();
-  
+
     /** Returns an iterator to the first Account of the collection
      */
     iterator begin ();
@@ -131,24 +126,21 @@ namespace Ekiga
      * when the account has been updated and the Ekiga::BankImpl 'account_removed' signal
      * will be emitted when the account has been removed from the Ekiga::BankImpl.
      */
-    void add_account (T &account);
+    void add_account (gmref_ptr<AccountType> account);
 
     /** Removes a account from the Ekiga::BankImpl.
      * @param: The account to be removed.
      * @return: The Ekiga::BankImpl 'account_removed' signal is emitted when the account
      * has been removed.
      */
-    void remove_account (T &account);
-
-    /** Save the bank to the GmConf key.
-     */
-    void save () const;
+    void remove_account (gmref_ptr<AccountType> account);
 
-  protected:
-    ServiceCore & core;
+    using RefLister<AccountType>::add_connection;
 
   private:
-    void on_registration_event (Ekiga::AccountCore::RegistrationState, std::string info, Ekiga::Account *account);
+    void on_registration_event (Ekiga::Account::RegistrationState,
+				std::string info,
+				gmref_ptr<AccountType> account);
   };
 
 /**
@@ -160,121 +152,86 @@ namespace Ekiga
 
 /* here begins the code from the template functions */
 
-template<typename T>
-Ekiga::BankImpl<T>::BankImpl (Ekiga::ServiceCore & _core) : core (_core)
+template<typename AccountType>
+Ekiga::BankImpl<AccountType>::BankImpl ()
 {
   /* this is signal forwarding */
-  Lister<T>::object_added.connect (account_added.make_slot ());
-  Lister<T>::object_removed.connect (account_removed.make_slot ());
-  Lister<T>::object_updated.connect (account_updated.make_slot ());
-
-  GSList *accounts = gm_conf_get_string_list ("/apps/" PACKAGE_NAME "/protocols/accounts_list");
-  GSList *accounts_iter = accounts;
-
-  while (accounts_iter) {
-
-    T *account = new T (core, (char *) accounts_iter->data);
-    add_account (*account);
-
-    accounts_iter = g_slist_next (accounts_iter);
-  }
-
-  g_slist_foreach (accounts, (GFunc) g_free, NULL);
-  g_slist_free (accounts);
-}
-
-
-template<typename T>
-Ekiga::BankImpl<T>::~BankImpl ()
-{
+  RefLister<AccountType>::object_added.connect (account_added.make_slot ());
+  RefLister<AccountType>::object_removed.connect (account_removed.make_slot ());
+  RefLister<AccountType>::object_updated.connect (account_updated.make_slot ());
 }
 
 
-template<typename T>
-void
-Ekiga::BankImpl<T>::save () const
+template<typename AccountType>
+Ekiga::BankImpl<AccountType>::~BankImpl ()
 {
-  GSList *accounts = NULL;
-
-  for (const_iterator it = begin ();
-       it != end ();
-       it++) {
-
-    std::string acct_str = (*it).as_string ();
-    if (!acct_str.empty ())
-      accounts = g_slist_append (accounts, g_strdup (acct_str.c_str ()));
-  }
-
-  gm_conf_set_string_list ("/apps/" PACKAGE_NAME "/protocols/accounts_list", accounts);
-
-  g_slist_foreach (accounts, (GFunc) g_free, NULL);
-  g_slist_free (accounts);
 }
 
 
-template<typename T>
+template<typename AccountType>
 void
-Ekiga::BankImpl<T>::visit_accounts (sigc::slot1<bool, Account &> visitor)
+Ekiga::BankImpl<AccountType>::visit_accounts (sigc::slot1<bool, AccountPtr> visitor)
 {
-  Lister<T>::visit_objects (visitor);
+  RefLister<AccountType>::visit_objects (visitor);
 }
 
 
-template<typename T>
-typename Ekiga::BankImpl<T>::iterator
-Ekiga::BankImpl<T>::begin ()
+template<typename AccountType>
+typename Ekiga::BankImpl<AccountType>::iterator
+Ekiga::BankImpl<AccountType>::begin ()
 {
-  return Lister<T>::begin ();
+  return RefLister<AccountType>::begin ();
 }
 
 
-template<typename T>
-typename Ekiga::BankImpl<T>::iterator
-Ekiga::BankImpl<T>::end ()
+template<typename AccountType>
+typename Ekiga::BankImpl<AccountType>::iterator
+Ekiga::BankImpl<AccountType>::end ()
 {
-  return Lister<T>::end ();
+  return RefLister<AccountType>::end ();
 }
 
 
-template<typename T>
-typename Ekiga::BankImpl<T>::const_iterator
-Ekiga::BankImpl<T>::begin () const
+template<typename AccountType>
+typename Ekiga::BankImpl<AccountType>::const_iterator
+Ekiga::BankImpl<AccountType>::begin () const
 {
-  return Lister<T>::begin ();
+  return RefLister<AccountType>::begin ();
 }
 
 
-template<typename T>
-typename Ekiga::BankImpl<T>::const_iterator
-Ekiga::BankImpl<T>::end () const
+template<typename AccountType>
+typename Ekiga::BankImpl<AccountType>::const_iterator
+Ekiga::BankImpl<AccountType>::end () const
 {
-  return Lister<T>::end ();
+  return RefLister<AccountType>::end ();
 }
 
 
-template<typename T>
+template<typename AccountType>
 void
-Ekiga::BankImpl<T>::add_account (T &account)
+Ekiga::BankImpl<AccountType>::add_account (gmref_ptr<AccountType> account)
 {
   add_object (account);
 
-  account.questions.add_handler (questions.make_slot ());
-  account.trigger_saving.connect (sigc::mem_fun (this, &Ekiga::BankImpl<T>::save));
-  account.registration_event.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::BankImpl<T>::on_registration_event), &account));
+  account->questions.add_handler (questions.make_slot ());
+  account->registration_event.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::BankImpl<AccountType>::on_registration_event), account));
 }
 
 
-template<typename T>
+template<typename AccountType>
 void
-Ekiga::BankImpl<T>::remove_account (T &account)
+Ekiga::BankImpl<AccountType>::remove_account (gmref_ptr<AccountType> account)
 {
   remove_object (account);
 }
 
 
-template<typename T>
+template<typename AccountType>
 void
-Ekiga::BankImpl<T>::on_registration_event (Ekiga::AccountCore::RegistrationState state, std::string info, Ekiga::Account *account)
+Ekiga::BankImpl<AccountType>::on_registration_event (Ekiga::Account::RegistrationState state,
+						     std::string info,
+						     gmref_ptr<AccountType> account)
 {
   registration_event.emit (account, state, info);
 }
diff --git a/lib/engine/account/bank.h b/lib/engine/account/bank.h
index c791f20..11f45c2 100644
--- a/lib/engine/account/bank.h
+++ b/lib/engine/account/bank.h
@@ -38,20 +38,18 @@
 #define __BANK_H__
 
 #include "lister.h"
-#include "account-core.h"
 #include "account.h"
-#include "gmconf.h"
 
 namespace Ekiga
 {
   class AccountCore;
 
-/**
- * @addtogroup accounts
- * @{
- */
+  /**
+   * @addtogroup accounts
+   * @{
+   */
 
-  class Bank 
+  class Bank: public virtual GmRefCounted
   {
   public:
 
@@ -63,7 +61,7 @@ namespace Ekiga
      * @param The callback (the return value means "go on" and allows
      *  stopping the visit)
      */
-    virtual void visit_accounts (sigc::slot1<bool, Account &> visitor) = 0;
+    virtual void visit_accounts (sigc::slot1<bool, AccountPtr> visitor) = 0;
 
 
     /** Create the menu for that Bank and its actions.
@@ -72,35 +70,37 @@ namespace Ekiga
      * @param A MenuBuilder object to populate.
      */
     virtual bool populate_menu (MenuBuilder &) = 0;
-      
+
 
     /** This signal is emitted when a account has been added.
      */
-    sigc::signal1<void, Account &> account_added;
+    sigc::signal1<void, AccountPtr> account_added;
 
     /** This signal is emitted when a account has been removed.
      */
-    sigc::signal1<void, Account &> account_removed;
+    sigc::signal1<void, AccountPtr> account_removed;
 
     /** This signal is emitted when a account has been updated.
      */
-    sigc::signal1<void, Account &> account_updated;
+    sigc::signal1<void, AccountPtr> account_updated;
 
     /** This signal is emitted when there is a new registration event
-     * @param: account is the account 
+     * @param: account is the account
      *         state is the state
      *         info contains information about the registration status
      */
-    sigc::signal3<void, const Ekiga::Account *, Ekiga::AccountCore::RegistrationState, std::string> registration_event;
+    sigc::signal3<void, Ekiga::AccountPtr, Account::RegistrationState, std::string> registration_event;
 
     /** This chain allows the BankImpl to present forms to the user
      */
     ChainOfResponsibility<FormRequest*> questions;
   };
 
-/**
- * @}
- */
+  typedef gmref_ptr<Bank> BankPtr;
+
+  /**
+   * @}
+   */
 
 };
 #endif
diff --git a/lib/engine/components/opal/h323-endpoint.cpp b/lib/engine/components/opal/h323-endpoint.cpp
index 40452e4..fdcf64a 100644
--- a/lib/engine/components/opal/h323-endpoint.cpp
+++ b/lib/engine/components/opal/h323-endpoint.cpp
@@ -333,14 +333,14 @@ Opal::H323::EndPoint::Register (const Opal::Account& account)
       /* Signal */
       Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &Opal::H323::EndPoint::registration_event_in_main),
 					       account,
-					       Ekiga::AccountCore::RegistrationFailed,
+					       Ekiga::Account::RegistrationFailed,
 					       info));
     }
     else {
 
       Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &Opal::H323::EndPoint::registration_event_in_main),
 					       account,
-					       Ekiga::AccountCore::Registered,
+					       Ekiga::Account::Registered,
 					       std::string ()));
     }
   }
@@ -352,7 +352,7 @@ Opal::H323::EndPoint::Register (const Opal::Account& account)
     /* Signal */
     Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &Opal::H323::EndPoint::registration_event_in_main),
 					     account,
-					     Ekiga::AccountCore::Unregistered,
+					     Ekiga::Account::Unregistered,
 					     std::string ()));
   }
 }
@@ -446,7 +446,7 @@ Opal::H323::EndPoint::on_transfer (std::string uri)
 
 void
 Opal::H323::EndPoint::registration_event_in_main (Opal::Account& account,
-						  Ekiga::AccountCore::RegistrationState state,
+						  Ekiga::Account::RegistrationState state,
 						  const std::string msg)
 {
   account.registration_event.emit (state, msg);
diff --git a/lib/engine/components/opal/h323-endpoint.h b/lib/engine/components/opal/h323-endpoint.h
index 0ac4a60..a745bf9 100644
--- a/lib/engine/components/opal/h323-endpoint.h
+++ b/lib/engine/components/opal/h323-endpoint.h
@@ -125,7 +125,7 @@ namespace Opal {
       void on_transfer (std::string uri);
 
       void registration_event_in_main (Opal::Account& account,
-				       Ekiga::AccountCore::RegistrationState state,
+				       Ekiga::Account::RegistrationState state,
 				       const std::string msg);
 
       CallManager & manager;
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index 3f86c45..0691361 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -442,15 +442,18 @@ void Opal::Account::on_edit_form_submitted (bool submitted,
 }
 
 
-void Opal::Account::on_consult (const std::string url)
+void
+Opal::Account::on_consult (const std::string url)
 {
   gm_open_uri (url.c_str ());
 }
 
-void Opal::Account::on_registration_event (Ekiga::AccountCore::RegistrationState state, std::string /*info*/)
+void
+Opal::Account::on_registration_event (Ekiga::Account::RegistrationState state,
+				      std::string /*info*/)
 {
   active = false;
 
-  if (state == Ekiga::AccountCore::Registered)
+  if (state == Ekiga::Account::Registered)
     active = true;
 }
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index 0fc590d..2cf551d 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -140,7 +140,7 @@ private:
     void on_consult (const std::string url);
     
     // Triggered for our own event
-    void on_registration_event (Ekiga::AccountCore::RegistrationState state, std::string info);
+    void on_registration_event (Ekiga::Account::RegistrationState state, std::string info);
 
     bool dead;
     bool active;
@@ -158,6 +158,8 @@ private:
     Ekiga::ServiceCore & core;
   };
 
+  typedef gmref_ptr<Account> AccountPtr;
+
   /**
    * @}
    */
diff --git a/lib/engine/components/opal/opal-bank.cpp b/lib/engine/components/opal/opal-bank.cpp
index 3fea410..1e75205 100644
--- a/lib/engine/components/opal/opal-bank.cpp
+++ b/lib/engine/components/opal/opal-bank.cpp
@@ -35,6 +35,8 @@
  *
  */
 
+#include "config.h"
+
 #include <string.h>
 #include <stdlib.h>
 #include <iostream>
@@ -42,13 +44,33 @@
 
 #include <glib/gi18n.h>
 
+#include "gmconf.h"
 #include "menu-builder.h"
 
 #include "opal-bank.h"
 #include "form-request-simple.h"
 
+Opal::Bank::Bank (Ekiga::ServiceCore &_core): core(_core)
+{
+  GSList *accounts = gm_conf_get_string_list ("/apps/" PACKAGE_NAME "/protocols/accounts_list");
+  GSList *accounts_iter = accounts;
+
+  while (accounts_iter) {
+
+    gmref_ptr<Account> account = gmref_ptr<Account> (new Account (core, (char *)accounts_iter->data));
+
+    add_account (account);
+    Ekiga::BankImpl<Account>::add_connection (account, account->trigger_saving.connect (sigc::mem_fun (this, &Opal::Bank::save)));
+    accounts_iter = g_slist_next (accounts_iter);
+  }
+
+  g_slist_foreach (accounts, (GFunc) g_free, NULL);
+  g_slist_free (accounts);
+}
 
-bool Opal::Bank::populate_menu (Ekiga::MenuBuilder & builder)
+
+bool
+Opal::Bank::populate_menu (Ekiga::MenuBuilder & builder)
 {
   builder.add_action ("add", _("_Add an Ekiga.net Account"),
 		      sigc::bind (sigc::mem_fun (this, &Opal::Bank::new_account), Opal::Account::Ekiga, "", ""));
@@ -63,16 +85,17 @@ bool Opal::Bank::populate_menu (Ekiga::MenuBuilder & builder)
 }
 
 
-void Opal::Bank::new_account (Account::Type t,
-                              std::string username,
-                              std::string password)
+void
+Opal::Bank::new_account (Account::Type acc_type,
+			 std::string username,
+			 std::string password)
 {
-  Ekiga::FormRequestSimple request(sigc::bind (sigc::mem_fun (this, &Opal::Bank::on_new_account_form_submitted), t));
+  Ekiga::FormRequestSimple request(sigc::bind (sigc::mem_fun (this, &Opal::Bank::on_new_account_form_submitted), acc_type));
 
   request.title (_("Edit account"));
   request.instructions (_("Please update the following fields."));
 
-  switch (t) {
+  switch (acc_type) {
 
   case Opal::Account::Ekiga:
     request.link (_("Get an Ekiga.net SIP account"), "http://www.ekiga.net";);
@@ -122,7 +145,7 @@ void Opal::Bank::new_account (Account::Type t,
     if (!questions.handle_request (&request)) {
 #ifdef __GNUC__
       std::cout << "Unhandled form request in "
-        << __PRETTY_FUNCTION__ << std::endl;
+		<< __PRETTY_FUNCTION__ << std::endl;
 #endif
     }
 }
@@ -130,30 +153,33 @@ void Opal::Bank::new_account (Account::Type t,
 
 void Opal::Bank::on_new_account_form_submitted (bool submitted,
 						Ekiga::Form &result,
-                                                Account::Type t)
+                                                Account::Type acc_type)
 {
   if (!submitted)
     return;
 
   try {
 
-    Ekiga::FormRequestSimple request(sigc::bind (sigc::mem_fun (this, &Opal::Bank::on_new_account_form_submitted) ,t));
+    Ekiga::FormRequestSimple request(sigc::bind (sigc::mem_fun (this, &Opal::Bank::on_new_account_form_submitted) ,acc_type));
 
     std::string error;
-    std::string new_name = (t == Opal::Account::SIP || t == Opal::Account::H323) ? result.text ("name") : result.hidden ("name");
-    std::string new_host = (t == Opal::Account::SIP || t == Opal::Account::H323) ? result.text ("host") : result.hidden ("host");
+    std::string new_name = (acc_type == Opal::Account::SIP
+			    || acc_type == Opal::Account::H323) ? result.text ("name") : result.hidden ("name");
+    std::string new_host = (acc_type == Opal::Account::SIP
+			    || acc_type == Opal::Account::H323) ? result.text ("host") : result.hidden ("host");
     std::string new_user = result.text ("user");
-    std::string new_authentication_user = (t == Opal::Account::SIP) ? result.text ("authentication_user") : new_user;
+    std::string new_authentication_user = (acc_type == Opal::Account::SIP) ? result.text ("authentication_user") : new_user;
     std::string new_password = result.private_text ("password");
     bool new_enabled = result.boolean ("enabled");
-    unsigned new_timeout = atoi ((t == Opal::Account::SIP || t == Opal::Account::H323) ? 
+    unsigned new_timeout = atoi ((acc_type == Opal::Account::SIP
+				  || acc_type == Opal::Account::H323) ?
                                  result.text ("timeout").c_str () : result.hidden ("timeout").c_str ());
 
     result.visit (request);
 
-    if (new_name.empty ()) 
+    if (new_name.empty ())
       error = _("You did not supply a name for that account.");
-    else if (new_host.empty ()) 
+    else if (new_host.empty ())
       error = _("You did not supply a host to register to.");
     else if (new_user.empty ())
       error = _("You did not supply a user name for that account.");
@@ -166,13 +192,14 @@ void Opal::Bank::on_new_account_form_submitted (bool submitted,
       if (!questions.handle_request (&request)) {
 #ifdef __GNUC__
         std::cout << "Unhandled form request in "
-          << __PRETTY_FUNCTION__ << std::endl;
+		  << __PRETTY_FUNCTION__ << std::endl;
 #endif
       }
     }
     else {
 
-      add (t, new_name, new_host, new_user, new_authentication_user, new_password, new_enabled, new_timeout);
+      add (acc_type, new_name, new_host, new_user, new_authentication_user,
+	   new_password, new_enabled, new_timeout);
       save ();
     }
 
@@ -183,8 +210,8 @@ void Opal::Bank::on_new_account_form_submitted (bool submitted,
 }
 
 
-void Opal::Bank::add (Account::Type t,
-                      std::string name, 
+void Opal::Bank::add (Account::Type acc_type,
+                      std::string name,
                       std::string host,
                       std::string user,
                       std::string auth_user,
@@ -192,8 +219,13 @@ void Opal::Bank::add (Account::Type t,
                       bool enabled,
                       unsigned timeout)
 {
-  Opal::Account *account = new Opal::Account (core, t, name, host, user, auth_user, password, enabled, timeout);
-  add_account (*account);
+  AccountPtr account = AccountPtr(new Opal::Account (core, acc_type, name,
+						     host, user, auth_user,
+						     password, enabled,
+						     timeout));
+  add_account (account);
+  Ekiga::BankImpl<Account>::add_connection (account, account->trigger_saving.connect (sigc::mem_fun (this, &Opal::Bank::save)));
+
   account->mwi_event.connect (sigc::bind<0> (mwi_event.make_slot (), account));
 }
 
@@ -204,27 +236,47 @@ Opal::Bank::call_manager_ready ()
        iter != end ();
        ++iter) {
 
-    if (iter->is_enabled ())
-      iter->enable ();
+    if ((*iter)->is_enabled ())
+      (*iter)->enable ();
   }
 }
 
-Opal::Account*
+Opal::AccountPtr
 Opal::Bank::find_account (const std::string& aor)
 {
-  Opal::Account* result = NULL;
+  AccountPtr result;
   bool found = false;
 
   for (iterator iter = begin ();
        !found && iter != end ();
        ++iter) {
 
-    if (iter->get_aor () == aor) {
+    if ((*iter)->get_aor () == aor) {
 
       found = true;
-      result = &*iter;
+      result = *iter;
     }
   }
 
   return result;
 }
+
+void
+Opal::Bank::save () const
+{
+  GSList *accounts = NULL;
+
+  for (const_iterator it = begin ();
+       it != end ();
+       it++) {
+
+    std::string acct_str = (*it)->as_string ();
+    if ( !acct_str.empty ())
+      accounts = g_slist_append (accounts, g_strdup (acct_str.c_str ()));
+  }
+
+  gm_conf_set_string_list ("/apps/" PACKAGE_NAME "/protocols/accounts_list", accounts);
+
+  g_slist_foreach (accounts, (GFunc) g_free, NULL);
+  g_slist_free (accounts);
+}
diff --git a/lib/engine/components/opal/opal-bank.h b/lib/engine/components/opal/opal-bank.h
index b253b59..110da89 100644
--- a/lib/engine/components/opal/opal-bank.h
+++ b/lib/engine/components/opal/opal-bank.h
@@ -54,7 +54,8 @@ namespace Opal
       public Ekiga::Service
   {
 public:
-    Bank (Ekiga::ServiceCore &_core) : Ekiga::BankImpl<Opal::Account> (_core) {}
+
+    Bank (Ekiga::ServiceCore &_core);
 
     virtual ~Bank () { }
 
@@ -66,7 +67,7 @@ public:
     const std::string get_description () const
     { return "\tStores the opal accounts"; }
 
-    void new_account (Account::Type t,
+    void new_account (Account::Type acc_type,
                       std::string username = "",
                       std::string password = "");
 
@@ -76,7 +77,7 @@ public:
      * @return The Opal::Account if an Account was found, false otherwise.
      *         The returned account should not be freed.
      */
-    Opal::Account* find_account (const std::string& aor);
+    AccountPtr find_account (const std::string& aor);
 
 
     void call_manager_ready ();
@@ -85,14 +86,16 @@ public:
      * @param: account is the account 
      *         info contains information about the indication 
      */
-    sigc::signal2<void, const Ekiga::Account *, std::string> mwi_event;
+    sigc::signal2<void, AccountPtr, std::string> mwi_event;
 
 private:
+    Ekiga::ServiceCore &core;
+
     void on_new_account_form_submitted (bool submitted,
 					Ekiga::Form& form,
-					Account::Type t);
+					Account::Type acc_type);
 
-    void add (Account::Type t,
+    void add (Account::Type acc_type,
               std::string name, 
               std::string host,
               std::string user,
@@ -100,6 +103,8 @@ private:
               std::string password,
               bool enabled,
               unsigned timeout);
+
+    void save () const;
   };
 
   /**
diff --git a/lib/engine/components/opal/opal-main.cpp b/lib/engine/components/opal/opal-main.cpp
index 2b19e92..67e4988 100644
--- a/lib/engine/components/opal/opal-main.cpp
+++ b/lib/engine/components/opal/opal-main.cpp
@@ -108,9 +108,9 @@ struct OPALSpark: public Ekiga::Spark
 
       gmref_ptr<Opal::Bank> bank (new Bank (core));
 
-      account_core->add_bank (*bank);
+      account_core->add_bank (bank);
       core.add (bank);
-      call_manager->ready.connect (sigc::mem_fun (*bank, &Opal::Bank::call_manager_ready));
+      call_manager->ready.connect (sigc::mem_fun (&*bank, &Opal::Bank::call_manager_ready));
 
 #ifdef HAVE_SIP
       unsigned sip_port = gm_conf_get_int (SIP_KEY "listen_port");
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index ede2505..f189376 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -181,7 +181,7 @@ Opal::Sip::EndPoint::menu_builder_add_actions (const std::string& fullname,
 	 it != bank->end ();
 	 it++) {
 
-      if (it->get_protocol_name () == "SIP" && it->is_active ()) {
+      if ((*it)->get_protocol_name () == "SIP" && (*it)->is_active ()) {
 
 	std::stringstream uristr;
 	std::string str = uri;
@@ -199,10 +199,10 @@ Opal::Sip::EndPoint::menu_builder_add_actions (const std::string& fullname,
 	else
 	  uristr << str;
 
-	uristr << "@" << it->get_host ();
+	uristr << "@" << (*it)->get_host ();
 
 	uris.push_back (uristr.str ());
-	accounts.push_back (it->get_name ());
+	accounts.push_back ((*it)->get_name ());
       }
     }
   } else {
@@ -675,7 +675,7 @@ Opal::Sip::EndPoint::OnRegistered (const PString & _aor,
   Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this,
 							  &Opal::Sip::EndPoint::registration_event_in_main),
 					   strm.str (),
-					   was_registering ? Ekiga::AccountCore::Registered : Ekiga::AccountCore::Unregistered,
+					   was_registering ? Ekiga::Account::Registered : Ekiga::Account::Unregistered,
 					   std::string ()));
 }
 
@@ -913,7 +913,7 @@ Opal::Sip::EndPoint::OnRegistrationFailed (const PString & _aor,
     Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this,
 							    &Opal::Sip::EndPoint::registration_event_in_main),
 					     strm.str (),
-					     wasRegistering ? Ekiga::AccountCore::RegistrationFailed : Ekiga::AccountCore::UnregistrationFailed,
+					     wasRegistering ? Ekiga::Account::RegistrationFailed : Ekiga::Account::UnregistrationFailed,
 					     info));
   }
 }
@@ -1048,7 +1048,7 @@ Opal::Sip::EndPoint::GetRegisteredPartyName (const SIPURL & host,
       /* FIXME: this is the only place where we use the bank in a thread
        * can't we just return GetDefaultDisplayName () ?
        */
-      Opal::Account *account = bank->find_account ("Ekiga.net");
+      AccountPtr account = bank->find_account ("Ekiga.net");
 
       if (account)
         return SIPURL ("\"" + GetDefaultDisplayName () + "\" <" + PString(account->get_aor ()) + ">");
@@ -1187,12 +1187,12 @@ void Opal::Sip::EndPoint::on_transfer (std::string uri)
 
 void
 Opal::Sip::EndPoint::registration_event_in_main (const std::string aor,
-						 Ekiga::AccountCore::RegistrationState state,
+						 Ekiga::Account::RegistrationState state,
 						 const std::string msg)
 {
-  Opal::Account* account = bank->find_account (aor);
+  AccountPtr account = bank->find_account (aor);
 
-  if (account != 0) {
+  if (account) {
 
     account->registration_event.emit (state, msg);
   }
@@ -1228,7 +1228,7 @@ void
 Opal::Sip::EndPoint::mwi_received_in_main (const std::string aor,
 					   const std::string info)
 {
-  Opal::Account* account = bank->find_account (aor);
+  AccountPtr account = bank->find_account (aor);
 
   if (account) {
 
diff --git a/lib/engine/components/opal/sip-endpoint.h b/lib/engine/components/opal/sip-endpoint.h
index 39f808b..0c864dd 100644
--- a/lib/engine/components/opal/sip-endpoint.h
+++ b/lib/engine/components/opal/sip-endpoint.h
@@ -194,7 +194,7 @@ namespace Opal {
       void on_transfer (std::string uri);
 
       void registration_event_in_main (const std::string aor,
-				       Ekiga::AccountCore::RegistrationState state,
+				       Ekiga::Account::RegistrationState state,
 				       const std::string msg);
 
       void presence_status_in_main (std::string uri,
diff --git a/lib/engine/presence/presence-core.cpp b/lib/engine/presence/presence-core.cpp
index 6901097..33f4671 100644
--- a/lib/engine/presence/presence-core.cpp
+++ b/lib/engine/presence/presence-core.cpp
@@ -259,11 +259,12 @@ Ekiga::PresenceCore::add_supported_uri (sigc::slot1<bool,std::string> tester)
 }
 
 void
-Ekiga::PresenceCore::on_registration_event (const Ekiga::Account& /*account*/,
-					    Ekiga::AccountCore::RegistrationState state,
+Ekiga::PresenceCore::on_registration_event (Ekiga::BankPtr /*bank*/,
+					    Ekiga::AccountPtr /*account*/,
+					    Ekiga::Account::RegistrationState state,
 					    std::string /*info*/,
 					    gmref_ptr<Ekiga::PersonalDetails> details)
 {
-  if (state == Ekiga::AccountCore::Registered)
+  if (state == Ekiga::Account::Registered)
     publish (details);
 }
diff --git a/lib/engine/presence/presence-core.h b/lib/engine/presence/presence-core.h
index 4d311b3..f82ab06 100644
--- a/lib/engine/presence/presence-core.h
+++ b/lib/engine/presence/presence-core.h
@@ -288,8 +288,9 @@ namespace Ekiga
     std::list<gmref_ptr<PresencePublisher> > presence_publishers;
     void publish (gmref_ptr<PersonalDetails> details);
     void on_personal_details_updated (PersonalDetails &details);
-    void on_registration_event (const Ekiga::Account & account,
-				Ekiga::AccountCore::RegistrationState state,
+    void on_registration_event (Ekiga::BankPtr bank,
+				Ekiga::AccountPtr account,
+				Ekiga::Account::RegistrationState state,
                                 std::string info,
                                 gmref_ptr<Ekiga::PersonalDetails> details);
 
diff --git a/src/gui/accounts.cpp b/src/gui/accounts.cpp
index 734de63..0838ceb 100644
--- a/src/gui/accounts.cpp
+++ b/src/gui/accounts.cpp
@@ -83,7 +83,7 @@ static void gm_aw_destroy (gpointer aw);
 /* DESCRIPTION  : /
  * BEHAVIOR     : Returns a pointer to the private GmAccountsWindow structure
  *                used by the preferences window GMObject.
- * PRE          : The given GtkWidget pointer must be a preferences window 
+ * PRE          : The given GtkWidget pointer must be a preferences window
  * 		  GMObject.
  */
 static GmAccountsWindow *gm_aw_get_aw (GtkWidget *account_window);
@@ -150,7 +150,7 @@ gm_aw_get_aw (GtkWidget *accounts_window)
 bool
 gm_accounts_window_update_account_state (GtkWidget *accounts_window,
 					 gboolean refreshing,
-                                         const Ekiga::Account & _account,
+					 Ekiga::AccountPtr _account,
 					 const gchar *status,
 					 const gchar *voicemails)
 {
@@ -181,7 +181,7 @@ gm_accounts_window_update_account_state (GtkWidget *accounts_window,
 			  COLUMN_ACCOUNT, &account,
 			  -1);
 
-      if (account == &_account) {
+      if (account == _account.get ()) {
 
         gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
                             COLUMN_ACCOUNT_ERROR_MESSAGE, &error,
@@ -202,7 +202,7 @@ gm_accounts_window_update_account_state (GtkWidget *accounts_window,
 			      COLUMN_ACCOUNT_VOICEMAILS, voicemails, -1);
           mwi_modified = (mwi == NULL) || strcmp (voicemails, mwi);
         }
-      
+
         g_free (error);
         g_free (mwi);
       }
@@ -215,9 +215,10 @@ gm_accounts_window_update_account_state (GtkWidget *accounts_window,
 
 
 /* Engine callbacks */
-static void 
-on_registration_event (const Ekiga::Account & account,
-                       Ekiga::AccountCore::RegistrationState state,
+static void
+on_registration_event (Ekiga::BankPtr /*bank*/,
+		       Ekiga::AccountPtr account,
+                       Ekiga::Account::RegistrationState state,
                        std::string info,
                        gpointer window)
 {
@@ -225,43 +226,43 @@ on_registration_event (const Ekiga::Account & account,
   std::string status;
 
   switch (state) {
-  case Ekiga::AccountCore::Registered:
+  case Ekiga::Account::Registered:
     status = _("Registered");
     break;
 
-  case Ekiga::AccountCore::Unregistered:
+  case Ekiga::Account::Unregistered:
     status = _("Unregistered");
     break;
 
-  case Ekiga::AccountCore::UnregistrationFailed:
+  case Ekiga::Account::UnregistrationFailed:
     status = _("Could not unregister");
     if (!info.empty ())
       status = status + " (" + info + ")";
     break;
 
-  case Ekiga::AccountCore::RegistrationFailed:
+  case Ekiga::Account::RegistrationFailed:
     status = _("Could not register");
     if (!info.empty ())
       status = status + " (" + info + ")";
     break;
 
-  case Ekiga::AccountCore::Processing:
+  case Ekiga::Account::Processing:
     status = _("Processing...");
     is_processing = true;
   default:
     break;
   }
 
-  gm_accounts_window_update_account_state (GTK_WIDGET (window), is_processing, account, status.c_str (), NULL); 
+  gm_accounts_window_update_account_state (GTK_WIDGET (window), is_processing, account, status.c_str (), NULL);
 }
 
 
-static void 
-on_mwi_event (const Ekiga::Account* account,
+static void
+on_mwi_event (Ekiga::AccountPtr account,
               std::string mwi,
               gpointer self)
 {
-  if (gm_accounts_window_update_account_state (GTK_WIDGET (self), false, *account, NULL, mwi.c_str ())) {
+  if (gm_accounts_window_update_account_state (GTK_WIDGET (self), false, account, NULL, mwi.c_str ())) {
 
     std::string::size_type loc = mwi.find ("/", 0);
     if (loc != std::string::npos) {
@@ -433,7 +434,7 @@ account_toggled_cb (G_GNUC_UNUSED GtkCellRendererToggle *cell,
 
     if (fixed)
       account->disable ();
-    else 
+    else
       account->enable ();
 
     gtk_list_store_set (GTK_LIST_STORE (model), &iter,
@@ -446,9 +447,9 @@ account_toggled_cb (G_GNUC_UNUSED GtkCellRendererToggle *cell,
 }
 
 
-static void 
+static void
 gm_accounts_window_add_account (GtkWidget *window,
-                                Ekiga::Account & account)
+                                Ekiga::AccountPtr account)
 {
   GmAccountsWindow *aw = NULL;
   GtkTreeModel *model = NULL;
@@ -462,18 +463,18 @@ gm_accounts_window_add_account (GtkWidget *window,
   model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->accounts_list));
 
   gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-  gtk_list_store_set (GTK_LIST_STORE (model), &iter, 
-                      COLUMN_ACCOUNT, &account,
+  gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+                      COLUMN_ACCOUNT, account.get (),
                       COLUMN_ACCOUNT_WEIGHT, PANGO_WEIGHT_NORMAL,
-                      COLUMN_ACCOUNT_ENABLED, account.is_enabled (),
-                      COLUMN_ACCOUNT_ACCOUNT_NAME, account.get_name ().c_str (),
-                      -1); 
+                      COLUMN_ACCOUNT_ENABLED, account->is_enabled (),
+                      COLUMN_ACCOUNT_ACCOUNT_NAME, account->get_name ().c_str (),
+                      -1);
 }
 
 
 void
 gm_accounts_window_update_account (GtkWidget *accounts_window,
-                                   Ekiga::Account & account)
+                                   Ekiga::AccountPtr account)
 {
   Ekiga::Account *caccount = NULL;
 
@@ -495,15 +496,15 @@ gm_accounts_window_update_account (GtkWidget *accounts_window,
 
       gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
 			  COLUMN_ACCOUNT, &caccount, -1);
-      
-      if (caccount == &account) {
 
-        gtk_list_store_set (GTK_LIST_STORE (model), &iter, 
-                            COLUMN_ACCOUNT, &account,
+      if (caccount == account.get ()) {
+
+        gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+                            COLUMN_ACCOUNT, account.get (),
                             COLUMN_ACCOUNT_WEIGHT, PANGO_WEIGHT_NORMAL,
-                            COLUMN_ACCOUNT_ENABLED, account.is_enabled (),
-                            COLUMN_ACCOUNT_ACCOUNT_NAME, account.get_name ().c_str (),
-                            -1); 
+                            COLUMN_ACCOUNT_ENABLED, account->is_enabled (),
+                            COLUMN_ACCOUNT_ACCOUNT_NAME, account->get_name ().c_str (),
+                            -1);
         break;
       }
     } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
@@ -513,7 +514,7 @@ gm_accounts_window_update_account (GtkWidget *accounts_window,
 
 void
 gm_accounts_window_remove_account (GtkWidget *accounts_window,
-                                   Ekiga::Account & account)
+                                   Ekiga::AccountPtr account)
 {
   Ekiga::Account *caccount = NULL;
 
@@ -535,8 +536,8 @@ gm_accounts_window_remove_account (GtkWidget *accounts_window,
 
       gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
 			  COLUMN_ACCOUNT, &caccount, -1);
-      
-      if (caccount == &account) {
+
+      if (caccount == account.get ()) {
 
         gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
         break;
@@ -546,8 +547,8 @@ gm_accounts_window_remove_account (GtkWidget *accounts_window,
 }
 
 
-static bool 
-visit_accounts (Ekiga::Account & account,
+static bool
+visit_accounts (Ekiga::AccountPtr account,
                 gpointer data)
 {
   gm_accounts_window_add_account (GTK_WIDGET (data), account);
@@ -557,34 +558,37 @@ visit_accounts (Ekiga::Account & account,
 
 
 static void
-on_account_added (Ekiga::Account & account,
+on_account_added (Ekiga::BankPtr /*bank*/,
+		  Ekiga::AccountPtr account,
                   gpointer data)
 {
   gm_accounts_window_add_account (GTK_WIDGET (data), account);
 }
 
 
-static void 
-on_account_updated (Ekiga::Account & account,
+static void
+on_account_updated (Ekiga::BankPtr /*bank*/,
+		    Ekiga::AccountPtr account,
                     gpointer data)
 {
   gm_accounts_window_update_account (GTK_WIDGET (data), account);
 }
 
 
-static void 
-on_account_removed (Ekiga::Account & account,
+static void
+on_account_removed (Ekiga::BankPtr /*bank*/,
+		    Ekiga::AccountPtr account,
                     gpointer data)
 {
   gm_accounts_window_remove_account (GTK_WIDGET (data), account);
 }
 
 
-static void 
-on_bank_added (Ekiga::Bank & bank,
+static void
+on_bank_added (Ekiga::BankPtr bank,
                gpointer data)
 {
-  bank.visit_accounts (sigc::bind (sigc::ptr_fun (visit_accounts), data));
+  bank->visit_accounts (sigc::bind (sigc::ptr_fun (visit_accounts), data));
   populate_menu (GTK_WIDGET (data));
 }
 
@@ -646,7 +650,7 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
   gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
 
   aw = new GmAccountsWindow (core);
-  g_object_set_data_full (G_OBJECT (window), "GMObject", 
+  g_object_set_data_full (G_OBJECT (window), "GMObject",
 			  aw, gm_aw_destroy);
 
   /* The menu */
@@ -675,8 +679,8 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
 				   G_TYPE_INT,
 				   G_TYPE_BOOLEAN, /* Enabled? */
 				   G_TYPE_STRING,  /* Account Name */
-				   G_TYPE_STRING,  /* VoiceMails */  
-				   G_TYPE_STRING,  /* Error Message */  
+				   G_TYPE_STRING,  /* VoiceMails */
+				   G_TYPE_STRING,  /* Error Message */
 				   G_TYPE_INT);    /* State */
 
   aw->accounts_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
@@ -695,7 +699,7 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
    */
   column = gtk_tree_view_column_new_with_attributes (_("A"),
 						     renderer,
-						     "active", 
+						     "active",
 						     COLUMN_ACCOUNT_ENABLED,
 						     NULL);
   gtk_tree_view_column_set_fixed_width (GTK_TREE_VIEW_COLUMN (column), 25);
@@ -706,14 +710,14 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
   		    (gpointer) window);
 
 
-  /* Add all text renderers, ie all except the 
+  /* Add all text renderers, ie all except the
    * "ACCOUNT_ENABLED/DEFAULT" columns */
   for (int i = COLUMN_ACCOUNT_ACCOUNT_NAME ; i < COLUMN_ACCOUNT_NUMBER - 1 ; i++) {
 
     renderer = gtk_cell_renderer_text_new ();
     column = gtk_tree_view_column_new_with_attributes (column_names [i],
 						       renderer,
-						       "text", 
+						       "text",
 						       i,
 						       "weight",
 						       COLUMN_ACCOUNT_WEIGHT,
@@ -727,11 +731,11 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
 
   g_signal_connect (G_OBJECT (aw->accounts_list), "event_after",
 		    G_CALLBACK (account_clicked_cb), window);
-  
+
   /* The scrolled window with the accounts list store */
   scroll_window = gtk_scrolled_window_new (FALSE, FALSE);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_window), 
-				  GTK_POLICY_AUTOMATIC, 
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_window),
+				  GTK_POLICY_AUTOMATIC,
 				  GTK_POLICY_AUTOMATIC);
 
   event_box = gtk_event_box_new ();
@@ -741,7 +745,7 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
 
   frame = gtk_frame_new (NULL);
   gtk_widget_set_size_request (GTK_WIDGET (frame), 250, 150);
-  gtk_container_set_border_width (GTK_CONTAINER (frame), 
+  gtk_container_set_border_width (GTK_CONTAINER (frame),
 				  2 * GNOMEMEETING_PAD_SMALL);
   gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
   gtk_container_add (GTK_CONTAINER (frame), scroll_window);
@@ -755,17 +759,17 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
 
 
   /* Generic signals */
-  g_signal_connect_swapped (GTK_OBJECT (window), 
-			    "response", 
+  g_signal_connect_swapped (GTK_OBJECT (window),
+			    "response",
 			    G_CALLBACK (gnomemeeting_window_hide),
 			    (gpointer) window);
 
-  g_signal_connect (GTK_OBJECT (window), "delete-event", 
+  g_signal_connect (GTK_OBJECT (window), "delete-event",
 		    G_CALLBACK (delete_window_cb), NULL);
 
   gtk_widget_show_all (GTK_WIDGET (GTK_DIALOG (window)->vbox));
 
-  
+
   /* Engine Signals callbacks */
   // FIXME sigc::connection conn;
 
@@ -780,6 +784,6 @@ gm_accounts_window_new (Ekiga::ServiceCore &core)
   bank->mwi_event.connect (sigc::bind (sigc::ptr_fun (on_mwi_event), (gpointer) window));
 
   account_core->visit_banks (sigc::bind_return (sigc::bind (sigc::ptr_fun (on_bank_added), window), true));
-  
+
   return window;
 }
diff --git a/src/gui/assistant.cpp b/src/gui/assistant.cpp
index e40da86..7636386 100644
--- a/src/gui/assistant.cpp
+++ b/src/gui/assistant.cpp
@@ -639,7 +639,7 @@ static void
 prepare_ekiga_net_page (EkigaAssistant *assistant)
 {
   gmref_ptr<Opal::Bank> bank = assistant->priv->core->get ("opal-account-store");
-  Opal::Account* account = bank->find_account ("ekiga.net");
+  Opal::AccountPtr account = bank->find_account ("ekiga.net");
 
   if (account && !account->get_username ().empty ())
     gtk_entry_set_text (GTK_ENTRY (assistant->priv->username), account->get_username ().c_str ());
@@ -656,8 +656,8 @@ static void
 apply_ekiga_net_page (EkigaAssistant *assistant)
 {
   gmref_ptr<Opal::Bank> bank = assistant->priv->core->get ("opal-account-store");
-  Opal::Account* account = bank->find_account ("ekiga.net");
-  bool new_account = (account == NULL);
+  Opal::AccountPtr account = bank->find_account ("ekiga.net");
+  bool new_account = !account;
 
   if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (assistant->priv->skip_ekiga_net))) {
 	if (new_account)
@@ -783,7 +783,7 @@ static void
 prepare_ekiga_out_page (EkigaAssistant *assistant)
 {
   gmref_ptr<Opal::Bank> account_core = assistant->priv->core->get ("opal-account-store");
-  Opal::Account* account = account_core->find_account ("sip.diamondcard.us");
+  Opal::AccountPtr account = account_core->find_account ("sip.diamondcard.us");
 
   if (account && !account->get_username ().empty ())
     gtk_entry_set_text (GTK_ENTRY (assistant->priv->dusername), account->get_username ().c_str ());
@@ -801,8 +801,8 @@ apply_ekiga_out_page (EkigaAssistant *assistant)
 {
   /* Some specific Opal stuff for the Ekiga.net account */
   gmref_ptr<Opal::Bank> bank = assistant->priv->core->get ("opal-account-store");
-  Opal::Account* account = bank->find_account ("sip.diamondcard.us");
-  bool new_account = (account == NULL);
+  Opal::AccountPtr account = bank->find_account ("sip.diamondcard.us");
+  bool new_account = !account;
 
   if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (assistant->priv->skip_ekiga_out))) {
 	if (new_account)
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
index 213b413..9bf2c16 100644
--- a/src/gui/main.cpp
+++ b/src/gui/main.cpp
@@ -500,42 +500,44 @@ static void ekiga_main_window_add_device_dialog_show (EkigaMainWindow *main_wind
 /* 
  * Engine Callbacks 
  */
-static void on_registration_event (const Ekiga::Account & account,
-                                   Ekiga::AccountCore::RegistrationState state,
-                                   std::string /*info*/,
-                                   gpointer self)
+static void
+on_registration_event (Ekiga::BankPtr /*bank*/,
+		       Ekiga::AccountPtr account,
+		       Ekiga::Account::RegistrationState state,
+		       std::string /*info*/,
+		       gpointer self)
 {
   EkigaMainWindow *mw = NULL;
 
   gchar *msg = NULL;
-  std::string aor = account.get_aor ();
+  std::string aor = account->get_aor ();
 
   g_return_if_fail (EKIGA_IS_MAIN_WINDOW (self));
   mw = EKIGA_MAIN_WINDOW (self);
 
   switch (state) {
-  case Ekiga::AccountCore::Registered:
+  case Ekiga::Account::Registered:
     /* Translators: Is displayed once an account "%s" is registered. */
     msg = g_strdup_printf (_("Registered %s"), aor.c_str ()); 
-    if (std::find (mw->priv->accounts.begin (), mw->priv->accounts.end (), account.get_host ()) == mw->priv->accounts.end ())
-      mw->priv->accounts.push_back (account.get_host ());
+    if (std::find (mw->priv->accounts.begin (), mw->priv->accounts.end (), account->get_host ()) == mw->priv->accounts.end ())
+      mw->priv->accounts.push_back (account->get_host ());
     break;
 
-  case Ekiga::AccountCore::Unregistered:
+  case Ekiga::Account::Unregistered:
     /* Translators: Is displayed once an account "%s" is unregistered. */
     msg = g_strdup_printf (_("Unregistered %s"), aor.c_str ());
-    mw->priv->accounts.remove (account.get_host ());
+    mw->priv->accounts.remove (account->get_host ());
     break;
 
-  case Ekiga::AccountCore::UnregistrationFailed:
+  case Ekiga::Account::UnregistrationFailed:
     msg = g_strdup_printf (_("Could not unregister %s"), aor.c_str ());
     break;
 
-  case Ekiga::AccountCore::RegistrationFailed:
+  case Ekiga::Account::RegistrationFailed:
     msg = g_strdup_printf (_("Could not register %s"), aor.c_str ());
     break;
 
-  case Ekiga::AccountCore::Processing:
+  case Ekiga::Account::Processing:
   default:
     break;
   }



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