aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-08-24 06:13:12 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-08-24 06:21:56 +0800
commit25bd33610962da0a8ff8dba645ac84e9f84d7e4f (patch)
tree45ac6baef883b5194cedcaea3f27653920ccf726
parent74bba154cc8476d831140e27148d4897633e2d18 (diff)
downloadgsoc2013-empathy-25bd33610962da0a8ff8dba645ac84e9f84d7e4f.tar
gsoc2013-empathy-25bd33610962da0a8ff8dba645ac84e9f84d7e4f.tar.gz
gsoc2013-empathy-25bd33610962da0a8ff8dba645ac84e9f84d7e4f.tar.bz2
gsoc2013-empathy-25bd33610962da0a8ff8dba645ac84e9f84d7e4f.tar.lz
gsoc2013-empathy-25bd33610962da0a8ff8dba645ac84e9f84d7e4f.tar.xz
gsoc2013-empathy-25bd33610962da0a8ff8dba645ac84e9f84d7e4f.tar.zst
gsoc2013-empathy-25bd33610962da0a8ff8dba645ac84e9f84d7e4f.zip
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.
-rw-r--r--libempathy/empathy-account-manager.c16
-rw-r--r--libempathy/empathy-account-manager.h3
-rw-r--r--libempathy/empathy-dispatcher.c2
3 files changed, 17 insertions, 4 deletions
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c
index 2f0f13415..20facd379 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 e0ec93761..25adfdbeb 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 7e1492de8..465f23b75 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);