ekiga r7478 - in trunk: lib/engine/account/skel lib/engine/components/opal src/gui



Author: jpuydt
Date: Tue Dec 23 20:17:38 2008
New Revision: 7478
URL: http://svn.gnome.org/viewvc/ekiga?rev=7478&view=rev

Log:
Pushed the find_account method to Opal::Bank

Modified:
   trunk/lib/engine/account/skel/account-core.cpp
   trunk/lib/engine/account/skel/account-core.h
   trunk/lib/engine/account/skel/bank-impl.h
   trunk/lib/engine/account/skel/bank.h
   trunk/lib/engine/components/opal/opal-bank.cpp
   trunk/lib/engine/components/opal/opal-bank.h
   trunk/lib/engine/components/opal/sip-endpoint.cpp
   trunk/lib/engine/components/opal/sip-endpoint.h
   trunk/src/gui/assistant.cpp

Modified: trunk/lib/engine/account/skel/account-core.cpp
==============================================================================
--- trunk/lib/engine/account/skel/account-core.cpp	(original)
+++ trunk/lib/engine/account/skel/account-core.cpp	Tue Dec 23 20:17:38 2008
@@ -65,19 +65,6 @@
 }
 
 
-Ekiga::Account *Ekiga::AccountCore::find_account (const std::string & aor)
-{
-  for (bank_iterator iter = banks.begin ();
-       iter != banks.end ();
-       iter++) {
-    if (Ekiga::Account *account = (*iter)->find_account (aor))
-      return account;
-  }
-
-  return NULL;
-}
-
-
 void Ekiga::AccountCore::add_bank (Bank &bank)
 {
   banks.insert (&bank);

Modified: trunk/lib/engine/account/skel/account-core.h
==============================================================================
--- trunk/lib/engine/account/skel/account-core.h	(original)
+++ trunk/lib/engine/account/skel/account-core.h	Tue Dec 23 20:17:38 2008
@@ -147,14 +147,6 @@
   public:
     typedef enum { Processing, Registered, Unregistered, RegistrationFailed, UnregistrationFailed } RegistrationState;
 
-    /** Find the account with the given address of record in the Bank
-     * @param aor is the address of record of the Account or the host to look 
-     *        for
-     * @return The Ekiga::Account if an Account was found, false otherwise.
-     *         The returned account should not be freed.
-     */
-    Ekiga::Account *find_account (const std::string & aor);
-
 
     /** Create the menu for the AccountCore and its actions.
      * @param A MenuBuilder object to populate.

Modified: trunk/lib/engine/account/skel/bank-impl.h
==============================================================================
--- trunk/lib/engine/account/skel/bank-impl.h	(original)
+++ trunk/lib/engine/account/skel/bank-impl.h	Tue Dec 23 20:17:38 2008
@@ -101,14 +101,6 @@
      */
     void visit_accounts (sigc::slot1<bool, Account &> visitor);
 
-    /** Find the account with the given address of record in the Bank
-     * @param aor is the address of record of the Account or the host to search 
-     *        for
-     * @return The Account corresponding to the find result
-     *         The returned account should not be freed.
-     */
-    Ekiga::Account *find_account (const std::string & aor);
-
     /** This function be called when a new account has to be added to the Bank.
      */
     void new_account ();
@@ -229,29 +221,6 @@
 
 
 template<typename T>
-Ekiga::Account *Ekiga::BankImpl<T>::find_account (const std::string & aor)
-{
-  for (typename Ekiga::BankImpl<T>::iterator it = Lister<T>::begin ();
-       it != Lister<T>::end ();
-       it++) {
-
-    if (aor.find ("@") != std::string::npos) {
-      if (it->get_aor () == aor) {
-        return (&(*it));
-      }
-    }
-    else {
-      if (it->get_host () == aor) {
-        return (&(*it));
-      }
-    }
-  }
-
-  return NULL;
-}
-
-
-template<typename T>
 typename Ekiga::BankImpl<T>::iterator
 Ekiga::BankImpl<T>::begin ()
 {

Modified: trunk/lib/engine/account/skel/bank.h
==============================================================================
--- trunk/lib/engine/account/skel/bank.h	(original)
+++ trunk/lib/engine/account/skel/bank.h	Tue Dec 23 20:17:38 2008
@@ -66,13 +66,6 @@
     virtual void visit_accounts (sigc::slot1<bool, Account &> visitor) = 0;
 
 
-    /** Find the account with the given address of record in the Bank
-     * @param aor is the address of record of the Account
-     * @return The Account corresponding to the find result
-     */
-    virtual Ekiga::Account *find_account (const std::string & aor) = 0;
-
-
     /** Create the menu for that Bank and its actions.
      * This function is purely virtual and should be implemented by
      * the descendant of the Ekiga::Bank.

Modified: trunk/lib/engine/components/opal/opal-bank.cpp
==============================================================================
--- trunk/lib/engine/components/opal/opal-bank.cpp	(original)
+++ trunk/lib/engine/components/opal/opal-bank.cpp	Tue Dec 23 20:17:38 2008
@@ -127,6 +127,25 @@
     }
 }
 
+Opal::Account*
+Opal::Bank::find_account (const std::string aor)
+{
+  for (iterator it = begin (); it != end (); it++) {
+
+    if (aor.find ("@") != std::string::npos) {
+      if (it->get_aor () == aor) {
+        return (&(*it));
+      }
+    }
+    else {
+      if (it->get_host () == aor) {
+        return (&(*it));
+      }
+    }
+  }
+
+  return NULL;
+}
 
 void Opal::Bank::on_new_account_form_submitted (bool submitted,
 						Ekiga::Form &result,

Modified: trunk/lib/engine/components/opal/opal-bank.h
==============================================================================
--- trunk/lib/engine/components/opal/opal-bank.h	(original)
+++ trunk/lib/engine/components/opal/opal-bank.h	Tue Dec 23 20:17:38 2008
@@ -70,6 +70,14 @@
                       std::string username = "",
                       std::string password = "");
 
+    /** Find the account with the given address of record in the Bank
+     * @param aor is the address of record of the Account or the host to look 
+     *        for
+     * @return The Ekiga::Account if an Account was found, false otherwise.
+     *         The returned account should not be freed.
+     */
+    Account* find_account (const std::string aor);
+
 private:
     void on_new_account_form_submitted (bool submitted,
 					Ekiga::Form& form,

Modified: trunk/lib/engine/components/opal/sip-endpoint.cpp
==============================================================================
--- trunk/lib/engine/components/opal/sip-endpoint.cpp	(original)
+++ trunk/lib/engine/components/opal/sip-endpoint.cpp	Tue Dec 23 20:17:38 2008
@@ -45,10 +45,8 @@
 
 #include "sip-endpoint.h"
 
-#include "opal-bank.h"
 #include "opal-call.h"
 
-#include "account-core.h"
 #include "chat-core.h"
 #include "personal-details.h"
 #include "opal-account.h"
@@ -129,9 +127,9 @@
     runtime = &*smart;
   }
   {
-    gmref_ptr<Ekiga::AccountCore> smart = core.get ("account-core");
+    gmref_ptr<Bank> smart = core.get ("opal-account-store");
     smart->reference (); // take a reference in the main thread
-    account_core = &*smart;
+    bank = &*smart;
   }
 
 
@@ -171,7 +169,7 @@
 Opal::Sip::EndPoint::~EndPoint ()
 {
   runtime->unreference (); // leave a reference in the main thread
-  account_core->unreference (); // leave a reference in the main thread
+  bank->unreference (); // leave a reference in the main thread
   dialect->unreference (); // leave a reference in the main thread
 }
 
@@ -207,8 +205,6 @@
 
   if (uri.find ("@") == string::npos) {
 
-    gmref_ptr<Opal::Bank> bank = core.get ("opal-account-store");
-
     if (bank) {
 
       for (Opal::Bank::iterator it = bank->begin ();
@@ -666,7 +662,7 @@
     Subscribe (SIPSubscribe::MessageSummary, 3600, aor);
 
   /* Signal */
-  Ekiga::Account *account = account_core->find_account (strm.str ());
+  Account* account = bank->find_account (strm.str ());
   if (account)
     runtime->run_in_main (sigc::bind (account->registration_event.make_slot (),
 				      was_registering ? Ekiga::AccountCore::Registered : Ekiga::AccountCore::Unregistered,
@@ -899,7 +895,7 @@
   SIPEndPoint::OnRegistrationFailed (strm.str ().c_str (), r, wasRegistering);
 
   /* Signal */
-  Ekiga::Account *account = account_core->find_account (strm.str ());
+  Account* account = bank->find_account (strm.str ());
   if (account)
     runtime->run_in_main (sigc::bind (account->registration_event.make_slot (),
 				      wasRegistering ? Ekiga::AccountCore::RegistrationFailed : Ekiga::AccountCore::UnregistrationFailed,
@@ -915,7 +911,7 @@
     mwi = "0/0";
 
   /* Signal */
-  Ekiga::Account *account = account_core->find_account (party);
+  Account* account = bank->find_account (party);
   if (account)
     runtime->run_in_main (sigc::bind (account->mwi_event.make_slot (), info));
 }
@@ -1027,7 +1023,7 @@
      */
     if (host.GetHostAddress ().GetIpAndPort (address, port) && !manager.IsLocalAddress (address)) {
 
-      Ekiga::Account *account = account_core->find_account ("ekiga.net");
+      Account* account = bank->find_account ("ekiga.net");
 
       if (account)
         return SIPURL ("\"" + GetDefaultDisplayName () + "\" <" + PString(account->get_aor ()) + ">");

Modified: trunk/lib/engine/components/opal/sip-endpoint.h
==============================================================================
--- trunk/lib/engine/components/opal/sip-endpoint.h	(original)
+++ trunk/lib/engine/components/opal/sip-endpoint.h	Tue Dec 23 20:17:38 2008
@@ -44,8 +44,7 @@
 #include "presence-core.h"
 #include "call-manager.h"
 #include "call-protocol-manager.h"
-#include "account-core.h"
-#include "opal-account.h"
+#include "opal-bank.h"
 #include "sip-dialect.h"
 #include "call-core.h"
 #include "contact-core.h"
@@ -182,7 +181,7 @@
       std::list<std::string> aors;               // List of registered aor
       Ekiga::ServiceCore & core;
       Ekiga::Runtime* runtime;
-      Ekiga::AccountCore* account_core;
+      Bank* bank;
 
       Ekiga::CallProtocolManager::Interface listen_iface;
 

Modified: trunk/src/gui/assistant.cpp
==============================================================================
--- trunk/src/gui/assistant.cpp	(original)
+++ trunk/src/gui/assistant.cpp	Tue Dec 23 20:17:38 2008
@@ -633,9 +633,9 @@
 static void
 prepare_ekiga_net_page (EkigaAssistant *assistant)
 {
-  gmref_ptr<Ekiga::AccountCore> account_core
-    = assistant->priv->core->get ("account-core");
-  Ekiga::Account *account = account_core->find_account ("ekiga.net");
+  gmref_ptr<Opal::Bank> bank
+    = assistant->priv->core->get ("opal-account-store");
+  Opal::Account* 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 ());
@@ -651,24 +651,21 @@
 static void
 apply_ekiga_net_page (EkigaAssistant *assistant)
 {
-  gmref_ptr<Ekiga::AccountCore> account_core
-    = assistant->priv->core->get ("account-core");
-
   /* Some specific Opal stuff for the Ekiga.net account */
-  gmref_ptr<Opal::Bank> opal_bank =
+  gmref_ptr<Opal::Bank> bank =
     assistant->priv->core->get ("opal-account-store");
-  Opal::Account* account = dynamic_cast<Opal::Account*>(account_core->find_account ("ekiga.net"));
+  Opal::Account* account = bank->find_account ("ekiga.net");
 
   bool new_account = (account == NULL);
 
   if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (assistant->priv->skip_ekiga_net))) {
 	if (new_account)
-	  opal_bank->new_account (Opal::Account::Ekiga,
-							  gtk_entry_get_text (GTK_ENTRY (assistant->priv->username)),
-							  gtk_entry_get_text (GTK_ENTRY (assistant->priv->password)));
+	  bank->new_account (Opal::Account::Ekiga,
+			     gtk_entry_get_text (GTK_ENTRY (assistant->priv->username)),
+			     gtk_entry_get_text (GTK_ENTRY (assistant->priv->password)));
 	else
 	  account->set_authentication_settings (gtk_entry_get_text (GTK_ENTRY (assistant->priv->username)),
-											gtk_entry_get_text (GTK_ENTRY (assistant->priv->password)));
+						gtk_entry_get_text (GTK_ENTRY (assistant->priv->password)));
   }
 }
 
@@ -784,9 +781,9 @@
 static void
 prepare_ekiga_out_page (EkigaAssistant *assistant)
 {
-  gmref_ptr<Ekiga::AccountCore> account_core
-    = assistant->priv->core->get ("account-core");
-  Ekiga::Account *account = account_core->find_account ("sip.diamondcard.us");
+  gmref_ptr<Opal::Bank> bank
+    = assistant->priv->core->get ("opal-account-store");
+  Opal::Account* account = bank->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 ());
@@ -802,24 +799,21 @@
 static void
 apply_ekiga_out_page (EkigaAssistant *assistant)
 {
-  gmref_ptr<Ekiga::AccountCore> account_core
-    = assistant->priv->core->get ("account-core");
-
   /* Some specific Opal stuff for the Ekiga.net account */
-  gmref_ptr<Opal::Bank> opal_bank
+  gmref_ptr<Opal::Bank> bank
     = assistant->priv->core->get ("opal-account-store");
-  Opal::Account* account = dynamic_cast<Opal::Account*> (account_core->find_account ("sip.diamondcard.us"));
+  Opal::Account* account = bank->find_account ("sip.diamondcard.us");
 
   bool new_account = (account == NULL);
 
   if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (assistant->priv->skip_ekiga_out))) {
 	if (new_account)
-	  opal_bank->new_account (Opal::Account::DiamondCard,
-							  gtk_entry_get_text (GTK_ENTRY (assistant->priv->dusername)),
-							  gtk_entry_get_text (GTK_ENTRY (assistant->priv->dpassword)));
+	  bank->new_account (Opal::Account::DiamondCard,
+			     gtk_entry_get_text (GTK_ENTRY (assistant->priv->dusername)),
+			     gtk_entry_get_text (GTK_ENTRY (assistant->priv->dpassword)));
 	else
 	  account->set_authentication_settings (gtk_entry_get_text (GTK_ENTRY (assistant->priv->dusername)),
-											gtk_entry_get_text (GTK_ENTRY (assistant->priv->dpassword)));
+						gtk_entry_get_text (GTK_ENTRY (assistant->priv->dpassword)));
   }
 }
 



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