]> git.0d.be Git - empathy.git/commitdiff
Chang the API of AccountManager to have the get lookup the account by name
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Thu, 30 Jul 2009 15:35:38 +0000 (17:35 +0200)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Thu, 30 Jul 2009 15:35:38 +0000 (17:35 +0200)
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

libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-contact-list-view.c
libempathy/empathy-account-manager.c
libempathy/empathy-account-manager.h
libempathy/empathy-chatroom-manager.c
libempathy/empathy-contact.c
libempathy/empathy-dispatcher.c
libempathy/empathy-log-store-empathy.c
megaphone/src/megaphone-applet.c
src/empathy-chat-window.c
src/empathy.c

index 0358b0ada14f4da1a3d333d3ad16351fcd8fe97e..d52d7af939cd6013dc704900e9a837a2e7772e1d 100644 (file)
@@ -203,7 +203,8 @@ chat_new_connection_cb (EmpathyAccountManager *manager,
        EmpathyChatPriv *priv = GET_PRIV (chat);
        EmpathyAccount *account;
 
        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)) {
        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->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);
 
                                                             connection);
        g_object_ref (priv->account);
 
index 783d986d098ab0550af5da1a837469168c63b9a8..2ff27b1305eedf72eff1cf09c234bca0eac94d25 100644 (file)
@@ -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_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;
 
        if (account) {
                TpConnection *connection;
 
index 7339acb9f80353b472beb2b5265ff55b0ca03b41..c199e1d3e02c0b30e014b617106aeb422c393f4e 100644 (file)
@@ -665,8 +665,9 @@ empathy_account_manager_get_count (EmpathyAccountManager *manager)
 }
 
 EmpathyAccount *
 }
 
 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;
 {
   EmpathyAccountManagerPriv *priv;
   GHashTableIter iter;
@@ -689,18 +690,12 @@ empathy_account_manager_get_account (EmpathyAccountManager *manager,
 }
 
 EmpathyAccount *
 }
 
 EmpathyAccount *
-empathy_account_manager_lookup (EmpathyAccountManager *manager,
+empathy_account_manager_get_account (EmpathyAccountManager *manager,
     const gchar *unique_name)
 {
   EmpathyAccountManagerPriv *priv = GET_PRIV (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 *
 }
 
 GList *
index 953d8bc75b5545c5a25890cdb0571a60826524d6..1f73f635e71329140c253349737c29bc18cb0df5 100644 (file)
@@ -66,10 +66,10 @@ int                     empathy_account_manager_get_connecting_accounts
                                 (EmpathyAccountManager *manager);
 int                     empathy_account_manager_get_count
                                 (EmpathyAccountManager *manager);
                                 (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);
                                 (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
                                 (EmpathyAccountManager *manager,
                                  const gchar *unique_name);
 GList *                 empathy_account_manager_dup_accounts
index c5f9864a1411c64791424cb55478c91077bff812..7c3559e2f4de0814063b445ac791166081e1a83e 100644 (file)
@@ -223,7 +223,8 @@ chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager,
                xmlFree (str);
        }
 
                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);
        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);
 
        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);
        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);
   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);
 
 
   roomname = empathy_tp_chat_get_id (chat);
 
index c82ecd46714a2580715430107dfeea1348b331b2..bbce927b7a9843843d71760f175804d9d760bf94 100644 (file)
@@ -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);
       /* 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);
     }
       g_object_ref (priv->account);
       g_object_unref (manager);
     }
index 0b2a74a2ebf9afc0258a40e4df60bc5367b6b6dc..fe330256de479ba74b868c726a096029ea8889a7 100644 (file)
@@ -1801,7 +1801,7 @@ empathy_dispatcher_handle_channels (TpSvcClientHandler *self,
   EmpathyAccount *account;
   TpConnection *connection;
 
   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);
     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);
     }
 
   tp_svc_client_handler_return_from_handle_channels (context);
-
-  g_object_unref (account);
 }
 
 static void
 }
 
 static void
index 4bb17e4289700e1564bdedcd3ee149b3690e44d6..81cbcade763f8fad492aa0962fb8ec86da6496dd 100644 (file)
@@ -405,8 +405,10 @@ log_store_empathy_search_hit_new (EmpathyLogStore *self,
 
   unescaped = g_strdup_printf ("/%s", g_strdelimit (account_name, "%", '/'));
 
 
   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);
     unescaped);
+  if (hit->account != NULL)
+    g_object_ref (hit->account);
   hit->filename = g_strdup (filename);
 
   g_free (unescaped);
   hit->filename = g_strdup (filename);
 
   g_free (unescaped);
index 1ef88ebc173bacc97d2612a0eb7f36bad6b7efaf..c269c7c7de7884e0d01f05f73693ea8d15b01af9 100644 (file)
@@ -443,7 +443,7 @@ megaphone_applet_set_contact (MegaphoneApplet *applet,
        /* Lookup the new contact */
        if (str) {
                strv = g_strsplit (str, "/", 2);
        /* 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]);
                        strv[0]);
                priv->id = strv[1];
                g_free (strv[0]);
@@ -451,6 +451,7 @@ megaphone_applet_set_contact (MegaphoneApplet *applet,
        }
 
        if (priv->account) {
        }
 
        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,
                connection = empathy_account_get_connection (priv->account);
                if (connection) {
                        megaphone_applet_new_connection_cb (priv->account_manager,
index 9694a653c86293698b14ba70aeac244a539b7a09..47ef37c42871b2d81e886af93793f42861861d63 100644 (file)
@@ -1269,7 +1269,7 @@ chat_window_drag_data_received (GtkWidget        *widget,
                strv = g_strsplit (id, "/", 2);
                account_id = strv[0];
                contact_id = strv[1];
                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) {
                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);
                        }
 
                                        connection, contact_id, NULL, NULL);
                        }
 
-                       g_object_unref (account);
                        g_strfreev (strv);
                        return;
                }
                        g_strfreev (strv);
                        return;
                }
-               g_object_unref (account);
                g_object_unref (account_manager);
                g_strfreev (strv);
 
                g_object_unref (account_manager);
                g_strfreev (strv);
 
index 4e824bcb4e23640357cf5294edaab951afeb8ff1..956b05e5fd8183319fced83ac5e8ab691daa9693 100644 (file)
@@ -113,7 +113,7 @@ dispatch_cb (EmpathyDispatcher *dispatcher,
 
                        manager = empathy_account_manager_dup_singleton ();
                        connection = empathy_tp_chat_get_connection (tp_chat);
 
                        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);
                                                                       connection);
                        chat = empathy_chat_window_find_chat (account, id);
                        g_object_unref (manager);