]> git.0d.be Git - empathy.git/commitdiff
empathy_dispatcher_chat_with_contact_id: get a TpAccount instead of a TpConnection
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 11 Aug 2010 12:48:40 +0000 (14:48 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 11 Aug 2010 12:48:40 +0000 (14:48 +0200)
libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-new-message-dialog.c
libempathy/empathy-dispatcher.c
libempathy/empathy-dispatcher.h
src/empathy-chat-manager.c
src/empathy-chat-window.c

index 399f0cc9bc82e2cdbcc56b2152020d99748f7036..9c6a632bcc882fee7ad6014253550988f1719fc4 100644 (file)
@@ -228,18 +228,11 @@ chat_set_property (GObject      *object,
 }
 
 static void
-reconnected_connection_ready_cb (TpConnection *connection,
-                       const GError *error,
-                       gpointer user_data)
+account_reconnected (EmpathyChat *chat,
+                       TpAccount *account)
 {
-       EmpathyChat *chat = user_data;
        EmpathyChatPriv *priv = GET_PRIV (chat);
 
-       if (error != NULL) {
-               DEBUG ("connection is not ready: %s", error->message);
-               goto out;
-       }
-
        DEBUG ("Account reconnected, request a new Text channel");
 
        /* FIXME: Ideally we should ask to handle ourself the channel so we can
@@ -248,10 +241,10 @@ reconnected_connection_ready_cb (TpConnection *connection,
        switch (priv->handle_type) {
                case TP_HANDLE_TYPE_CONTACT:
                        empathy_dispatcher_chat_with_contact_id (
-                               connection, priv->id, EMPATHY_DISPATCHER_NON_USER_ACTION);
+                               account, priv->id, EMPATHY_DISPATCHER_NON_USER_ACTION);
                        break;
                case TP_HANDLE_TYPE_ROOM:
-                       empathy_dispatcher_join_muc (connection,
+                       empathy_dispatcher_join_muc (tp_account_get_connection (account),
                                priv->id, EMPATHY_DISPATCHER_NON_USER_ACTION);
                        break;
                case TP_HANDLE_TYPE_NONE:
@@ -262,7 +255,6 @@ reconnected_connection_ready_cb (TpConnection *connection,
                        break;
        }
 
-out:
        g_object_unref (chat);
 }
 
@@ -289,8 +281,8 @@ chat_new_connection_cb (TpAccount   *account,
                return;
 
        g_object_ref (chat);
-       tp_connection_call_when_ready (connection, reconnected_connection_ready_cb,
-                                  chat);
+
+       account_reconnected (chat, account);
 }
 
 static void
index 6cdab465487a3ea69f9df5ee8068a72f406b126b..a174814376f9e10f0dfd56d4f4290614cdb71941 100644 (file)
@@ -60,17 +60,17 @@ G_DEFINE_TYPE(EmpathyNewMessageDialog, empathy_new_message_dialog,
 static void
 empathy_new_message_dialog_response (GtkDialog *dialog, int response_id)
 {
-  TpConnection *connection;
+  TpAccount *account;
   const gchar *contact_id;
 
   if (response_id != GTK_RESPONSE_ACCEPT) goto out;
 
   contact_id = empathy_contact_selector_dialog_get_selected (
-      EMPATHY_CONTACT_SELECTOR_DIALOG (dialog), &connection, NULL);
+      EMPATHY_CONTACT_SELECTOR_DIALOG (dialog), NULL, &account);
 
-  if (EMP_STR_EMPTY (contact_id) || connection == NULL) goto out;
+  if (EMP_STR_EMPTY (contact_id) || account == NULL) goto out;
 
-  empathy_dispatcher_chat_with_contact_id (connection, contact_id,
+  empathy_dispatcher_chat_with_contact_id (account, contact_id,
       gtk_get_current_event_time ());
 
 out:
index 09630e67467a85a1bbd561e73ba078f1601ece15..5e31fa71c6432efb64809c68dddce184a51d82c6 100644 (file)
@@ -1307,16 +1307,21 @@ dispatcher_chat_with_contact_id_cb (TpConnection            *connection,
 }
 
 void
-empathy_dispatcher_chat_with_contact_id (TpConnection *connection,
-                                         const gchar *contact_id,
-                                         gint64 timestamp)
+empathy_dispatcher_chat_with_contact_id (TpAccount *account,
+    const gchar *contact_id,
+    gint64 timestamp)
 {
   EmpathyDispatcher *self;
   ChatWithContactIdData *data;
+  TpConnection *connection;
 
-  g_return_if_fail (TP_IS_CONNECTION (connection));
+  g_return_if_fail (TP_IS_ACCOUNT (account));
   g_return_if_fail (!EMP_STR_EMPTY (contact_id));
 
+  connection = tp_account_get_connection (account);
+  if (connection == NULL)
+    return;
+
   self = empathy_dispatcher_dup_singleton ();
   data = g_slice_new0 (ChatWithContactIdData);
   data->dispatcher = self;
index d49aa2dad498cd80460ce4f75da57d99b990b750..1fa6387f7c6fa5b2e3e925c6f998bc91ff2a4072 100644 (file)
@@ -75,7 +75,7 @@ void empathy_dispatcher_create_channel (EmpathyDispatcher *dispatcher,
   gpointer user_data);
 
 /* Requesting 1 to 1 text channels */
-void empathy_dispatcher_chat_with_contact_id (TpConnection *connection,
+void empathy_dispatcher_chat_with_contact_id (TpAccount *account,
   const gchar *contact_id,
   gint64 timestamp);
 
index 0a16be90def411161ab642a2c4f0f349206fc695..a3177a3f7ac960547689b49fcc490a7c9196ddec 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <libempathy/empathy-chatroom-manager.h>
 #include <libempathy/empathy-dispatcher.h>
+#include <libempathy/empathy-utils.h>
 
 #include "empathy-chat-window.h"
 
@@ -385,13 +386,16 @@ connection_ready_cb (TpConnection *connection,
 
   priv = GET_PRIV (self);
 
+  /* FIXME: Once empathy_dispatcher_join_muc will take a TpAccount instead of
+   * a TpConnection we won't have to prepare the connection any more. */
   if (error == NULL)
     {
       if (data->room)
         empathy_dispatcher_join_muc (connection, data->id,
           EMPATHY_DISPATCHER_NON_USER_ACTION);
       else
-        empathy_dispatcher_chat_with_contact_id (connection, data->id,
+        empathy_dispatcher_chat_with_contact_id (
+            empathy_get_account_for_connection (connection), data->id,
             EMPATHY_DISPATCHER_NON_USER_ACTION);
 
       g_signal_emit (self, signals[CHATS_CHANGED], 0,
index 93c1ab773b090f72c656d9c93b47d7f6bcf5ed4a..27d6dd8746bc9a91af750a93f91ae0cc6172ac4d 100644 (file)
@@ -1738,14 +1738,8 @@ chat_window_drag_data_received (GtkWidget        *widget,
                }
 
                if (!chat) {
-                       TpConnection *connection;
-
-                       connection = tp_account_get_connection (account);
-
-                       if (connection) {
-                               empathy_dispatcher_chat_with_contact_id (
-                                       connection, contact_id, gtk_get_current_event_time ());
-                       }
+                       empathy_dispatcher_chat_with_contact_id (
+                               account, contact_id, gtk_get_current_event_time ());
 
                        g_strfreev (strv);
                        return;