aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-07-30 23:35:38 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-07-30 23:35:38 +0800
commitc9ef23052d2e5007e6120dcc881d6c382fcf48d3 (patch)
tree04092618e0d66d391e2f0b8cf6c190e4b45fb84e
parent237c4ac2d8d1b008a0c34aa24fc63eb3a1c0c91d (diff)
downloadgsoc2013-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
-rw-r--r--libempathy-gtk/empathy-chat.c6
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c2
-rw-r--r--libempathy/empathy-account-manager.c15
-rw-r--r--libempathy/empathy-account-manager.h4
-rw-r--r--libempathy/empathy-chatroom-manager.c8
-rw-r--r--libempathy/empathy-contact.c3
-rw-r--r--libempathy/empathy-dispatcher.c4
-rw-r--r--libempathy/empathy-log-store-empathy.c4
-rw-r--r--megaphone/src/megaphone-applet.c3
-rw-r--r--src/empathy-chat-window.c4
-rw-r--r--src/empathy.c2
11 files changed, 26 insertions, 29 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 0358b0ada..d52d7af93 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -203,7 +203,8 @@ chat_new_connection_cb (EmpathyAccountManager *manager,
EmpathyChatPriv *priv = GET_PRIV (chat);
EmpathyAccount *account;
- account = empathy_account_manager_get_account (manager, connection);
+ account = empathy_account_manager_get_account_for_connection (manager,
+ connection);
if (!priv->tp_chat && account == priv->account &&
priv->handle_type != TP_HANDLE_TYPE_NONE &&
!EMP_STR_EMPTY (priv->id)) {
@@ -1766,7 +1767,8 @@ empathy_chat_set_tp_chat (EmpathyChat *chat,
priv->tp_chat = g_object_ref (tp_chat);
connection = empathy_tp_chat_get_connection (priv->tp_chat);
- priv->account = empathy_account_manager_get_account (priv->account_manager,
+ priv->account = empathy_account_manager_get_account_for_connection (
+ priv->account_manager,
connection);
g_object_ref (priv->account);
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 783d986d0..2ff27b130 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -302,7 +302,7 @@ contact_list_view_drag_data_received (GtkWidget *view,
account_id = strv[0];
contact_id = strv[1];
account_manager = empathy_account_manager_dup_singleton ();
- account = empathy_account_manager_lookup (account_manager, account_id);
+ account = empathy_account_manager_get_account (account_manager, account_id);
if (account) {
TpConnection *connection;
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);
diff --git a/megaphone/src/megaphone-applet.c b/megaphone/src/megaphone-applet.c
index 1ef88ebc1..c269c7c7d 100644
--- a/megaphone/src/megaphone-applet.c
+++ b/megaphone/src/megaphone-applet.c
@@ -443,7 +443,7 @@ megaphone_applet_set_contact (MegaphoneApplet *applet,
/* Lookup the new contact */
if (str) {
strv = g_strsplit (str, "/", 2);
- priv->account = empathy_account_manager_lookup (priv->account_manager,
+ priv->account = empathy_account_manager_get_account (priv->account_manager,
strv[0]);
priv->id = strv[1];
g_free (strv[0]);
@@ -451,6 +451,7 @@ megaphone_applet_set_contact (MegaphoneApplet *applet,
}
if (priv->account) {
+ g_object_ref (priv->account);
connection = empathy_account_get_connection (priv->account);
if (connection) {
megaphone_applet_new_connection_cb (priv->account_manager,
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 9694a653c..47ef37c42 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -1269,7 +1269,7 @@ chat_window_drag_data_received (GtkWidget *widget,
strv = g_strsplit (id, "/", 2);
account_id = strv[0];
contact_id = strv[1];
- account = empathy_account_manager_lookup (account_manager, account_id);
+ account = empathy_account_manager_get_account (account_manager, account_id);
chat = empathy_chat_window_find_chat (account, contact_id);
if (!chat) {
@@ -1282,11 +1282,9 @@ chat_window_drag_data_received (GtkWidget *widget,
connection, contact_id, NULL, NULL);
}
- g_object_unref (account);
g_strfreev (strv);
return;
}
- g_object_unref (account);
g_object_unref (account_manager);
g_strfreev (strv);
diff --git a/src/empathy.c b/src/empathy.c
index 4e824bcb4..956b05e5f 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -113,7 +113,7 @@ dispatch_cb (EmpathyDispatcher *dispatcher,
manager = empathy_account_manager_dup_singleton ();
connection = empathy_tp_chat_get_connection (tp_chat);
- account = empathy_account_manager_get_account (manager,
+ account = empathy_account_manager_get_account_for_connection (manager,
connection);
chat = empathy_chat_window_find_chat (account, id);
g_object_unref (manager);