[empathy/mc5] Add a new _ensure_account API



commit 25bd33610962da0a8ff8dba645ac84e9f84d7e4f
Author: Sjoerd Simons <sjoerd simons collabora co uk>
Date:   Sun Aug 23 23:13:12 2009 +0100

    Add a new _ensure_account API
    
    Have one call which only gets the account if it exists and a different one
    which creates the account on the given path when needed.

 libempathy/empathy-account-manager.c |   16 +++++++++++++---
 libempathy/empathy-account-manager.h |    3 +++
 libempathy/empathy-dispatcher.c      |    2 +-
 3 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c
index 2f0f134..20facd3 100644
--- a/libempathy/empathy-account-manager.c
+++ b/libempathy/empathy-account-manager.c
@@ -337,6 +337,15 @@ empathy_account_manager_get_account (EmpathyAccountManager *manager,
   const gchar *path)
 {
   EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
+
+  return g_hash_table_lookup (priv->accounts, path);
+}
+
+EmpathyAccount *
+empathy_account_manager_ensure_account (EmpathyAccountManager *manager,
+  const gchar *path)
+{
+  EmpathyAccountManagerPriv *priv = GET_PRIV (manager);
   EmpathyAccount *account;
 
   account = g_hash_table_lookup (priv->accounts, path);
@@ -352,6 +361,7 @@ empathy_account_manager_get_account (EmpathyAccountManager *manager,
   return account;
 }
 
+
 static void
 account_manager_got_all_cb (TpProxy *proxy,
     GHashTable *properties,
@@ -378,7 +388,7 @@ account_manager_got_all_cb (TpProxy *proxy,
         {
           gchar *name = g_ptr_array_index (accounts, i);
 
-          empathy_account_manager_get_account (manager, name);
+          empathy_account_manager_ensure_account (manager, name);
         }
     }
 
@@ -397,7 +407,7 @@ account_validity_changed_cb (TpAccountManager *proxy,
   if (!valid)
     return;
 
-  empathy_account_manager_get_account (manager, path);
+  empathy_account_manager_ensure_account (manager, path);
 }
 
 static void
@@ -909,7 +919,7 @@ empathy_account_manager_created_cb (TpAccountManager *proxy,
       return;
     }
 
-  account = empathy_account_manager_get_account (manager, account_path);
+  account = empathy_account_manager_ensure_account (manager, account_path);
 
   g_hash_table_insert (priv->create_results, account, my_res);
 }
diff --git a/libempathy/empathy-account-manager.h b/libempathy/empathy-account-manager.h
index e0ec937..25adfdb 100644
--- a/libempathy/empathy-account-manager.h
+++ b/libempathy/empathy-account-manager.h
@@ -69,6 +69,9 @@ int                     empathy_account_manager_get_count
 EmpathyAccount *        empathy_account_manager_get_account_for_connection
                                 (EmpathyAccountManager *manager,
                                  TpConnection          *connection);
+EmpathyAccount *        empathy_account_manager_ensure_account
+                                (EmpathyAccountManager *manager,
+                                 const gchar *unique_name);
 EmpathyAccount *        empathy_account_manager_get_account
                                 (EmpathyAccountManager *manager,
                                  const gchar *unique_name);
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index 7e1492d..465f23b 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -1800,7 +1800,7 @@ empathy_dispatcher_handle_channels (TpSvcClientHandler *self,
   EmpathyAccount *account;
   TpConnection *connection;
 
-  account = empathy_account_manager_get_account (priv->account_manager,
+  account = empathy_account_manager_ensure_account (priv->account_manager,
     account_path);
   g_assert (account != NULL);
 



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