diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-07-30 23:35:38 +0800 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-07-30 23:35:38 +0800 |
commit | c9ef23052d2e5007e6120dcc881d6c382fcf48d3 (patch) | |
tree | 04092618e0d66d391e2f0b8cf6c190e4b45fb84e /libempathy | |
parent | 237c4ac2d8d1b008a0c34aa24fc63eb3a1c0c91d (diff) | |
download | gsoc2013-empathy-c9ef23052d2e5007e6120dcc881d6c382fcf48d3.tar gsoc2013-empathy-c9ef23052d2e5007e6120dcc881d6c382fcf48d3.tar.gz gsoc2013-empathy-c9ef23052d2e5007e6120dcc881d6c382fcf48d3.tar.bz2 gsoc2013-empathy-c9ef23052d2e5007e6120dcc881d6c382fcf48d3.tar.lz gsoc2013-empathy-c9ef23052d2e5007e6120dcc881d6c382fcf48d3.tar.xz gsoc2013-empathy-c9ef23052d2e5007e6120dcc881d6c382fcf48d3.tar.zst gsoc2013-empathy-c9ef23052d2e5007e6120dcc881d6c382fcf48d3.zip |
Chang the API of AccountManager to have the get lookup the account by name
EmpathyAccountManager used to have a _lookup function that looked up accounts
by name and a _get function that lookup up accounts by connection. This is
confusing, as looking up an account for a connection is less common rename have
the _get_account be the same _lookup (but without returning a ref) and add a
_get_account_for_connection function lookup by account
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-account-manager.c | 15 | ||||
-rw-r--r-- | libempathy/empathy-account-manager.h | 4 | ||||
-rw-r--r-- | libempathy/empathy-chatroom-manager.c | 8 | ||||
-rw-r--r-- | libempathy/empathy-contact.c | 3 | ||||
-rw-r--r-- | libempathy/empathy-dispatcher.c | 4 | ||||
-rw-r--r-- | libempathy/empathy-log-store-empathy.c | 4 |
6 files changed, 17 insertions, 21 deletions
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c index 7339acb9f..c199e1d3e 100644 --- a/libempathy/empathy-account-manager.c +++ b/libempathy/empathy-account-manager.c @@ -665,8 +665,9 @@ empathy_account_manager_get_count (EmpathyAccountManager *manager) } EmpathyAccount * -empathy_account_manager_get_account (EmpathyAccountManager *manager, - TpConnection *connection) +empathy_account_manager_get_account_for_connection ( + EmpathyAccountManager *manager, + TpConnection *connection) { EmpathyAccountManagerPriv *priv; GHashTableIter iter; @@ -689,18 +690,12 @@ empathy_account_manager_get_account (EmpathyAccountManager *manager, } EmpathyAccount * -empathy_account_manager_lookup (EmpathyAccountManager *manager, +empathy_account_manager_get_account (EmpathyAccountManager *manager, const gchar *unique_name) { EmpathyAccountManagerPriv *priv = GET_PRIV (manager); - EmpathyAccount *account; - - account = g_hash_table_lookup (priv->accounts, unique_name); - if (account != NULL) - g_object_ref (account); - - return account; + return g_hash_table_lookup (priv->accounts, unique_name); } GList * diff --git a/libempathy/empathy-account-manager.h b/libempathy/empathy-account-manager.h index 953d8bc75..1f73f635e 100644 --- a/libempathy/empathy-account-manager.h +++ b/libempathy/empathy-account-manager.h @@ -66,10 +66,10 @@ int empathy_account_manager_get_connecting_accounts (EmpathyAccountManager *manager); int empathy_account_manager_get_count (EmpathyAccountManager *manager); -EmpathyAccount * empathy_account_manager_get_account +EmpathyAccount * empathy_account_manager_get_account_for_connection (EmpathyAccountManager *manager, TpConnection *connection); -EmpathyAccount * empathy_account_manager_lookup +EmpathyAccount * empathy_account_manager_get_account (EmpathyAccountManager *manager, const gchar *unique_name); GList * empathy_account_manager_dup_accounts diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c index c5f9864a1..7c3559e2f 100644 --- a/libempathy/empathy-chatroom-manager.c +++ b/libempathy/empathy-chatroom-manager.c @@ -223,7 +223,8 @@ chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager, xmlFree (str); } - account = empathy_account_manager_lookup (priv->account_manager, account_id); + account = empathy_account_manager_get_account (priv->account_manager, + account_id); if (!account) { g_free (name); g_free (room); @@ -236,7 +237,6 @@ chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager, add_chatroom (manager, chatroom); g_signal_emit (manager, signals[CHATROOM_ADDED], 0, chatroom); - g_object_unref (account); g_free (name); g_free (room); g_free (account_id); @@ -704,8 +704,8 @@ chatroom_manager_observe_channel_cb (EmpathyDispatcher *dispatcher, chat = EMPATHY_TP_CHAT ( empathy_dispatch_operation_get_channel_wrapper (operation)); connection = empathy_tp_chat_get_connection (chat); - account = empathy_account_manager_get_account (priv->account_manager, - connection); + account = empathy_account_manager_get_account_for_connection ( + priv->account_manager, connection); roomname = empathy_tp_chat_get_id (chat); diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index c82ecd467..bbce927b7 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -570,7 +570,8 @@ empathy_contact_get_account (EmpathyContact *contact) /* FIXME: This assume the account manager already exists */ manager = empathy_account_manager_dup_singleton (); connection = tp_contact_get_connection (priv->tp_contact); - priv->account = empathy_account_manager_get_account (manager, connection); + priv->account = empathy_account_manager_get_account_for_connection ( + manager, connection); g_object_ref (priv->account); g_object_unref (manager); } diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c index 0b2a74a2e..fe330256d 100644 --- a/libempathy/empathy-dispatcher.c +++ b/libempathy/empathy-dispatcher.c @@ -1801,7 +1801,7 @@ empathy_dispatcher_handle_channels (TpSvcClientHandler *self, EmpathyAccount *account; TpConnection *connection; - account = empathy_account_manager_lookup (priv->account_manager, + account = empathy_account_manager_get_account (priv->account_manager, account_path); /* FIXME */ g_assert (account != NULL); @@ -1824,8 +1824,6 @@ empathy_dispatcher_handle_channels (TpSvcClientHandler *self, } tp_svc_client_handler_return_from_handle_channels (context); - - g_object_unref (account); } static void diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c index 4bb17e428..81cbcade7 100644 --- a/libempathy/empathy-log-store-empathy.c +++ b/libempathy/empathy-log-store-empathy.c @@ -405,8 +405,10 @@ log_store_empathy_search_hit_new (EmpathyLogStore *self, unescaped = g_strdup_printf ("/%s", g_strdelimit (account_name, "%", '/')); - hit->account = empathy_account_manager_lookup (priv->account_manager, + hit->account = empathy_account_manager_get_account (priv->account_manager, unescaped); + if (hit->account != NULL) + g_object_ref (hit->account); hit->filename = g_strdup (filename); g_free (unescaped); |