]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-dispatch-operation.c
Updated Basque language
[empathy.git] / libempathy / empathy-dispatch-operation.c
index 8f6fffe4ef32a862dd7d91d14c4d19b9d99c7816..d7afcbea6f88b3e0dc1bf9f5b24ace626d2a25bd 100644 (file)
@@ -22,6 +22,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <telepathy-glib/interfaces.h>
+
 #include "empathy-dispatch-operation.h"
 #include <libempathy/empathy-enum-types.h>
 #include <libempathy/empathy-tp-contact-factory.h>
@@ -198,6 +200,26 @@ dispatcher_operation_got_contact_cb (EmpathyTpContactFactory *factory,
     empathy_dispatch_operation_channel_ready_cb, self);
 }
 
+static void
+dispatch_operation_connection_ready (TpConnection *connection,
+    const GError *error,
+    gpointer user_data)
+{
+  EmpathyDispatchOperation *self = EMPATHY_DISPATCH_OPERATION (user_data);
+  EmpathyDispatchOperationPriv *priv = GET_PRIV (self);
+  EmpathyTpContactFactory *factory;
+  TpHandle handle;
+
+  handle = tp_channel_get_handle (priv->channel, NULL);
+
+  factory = empathy_tp_contact_factory_dup_singleton (priv->connection);
+
+  empathy_tp_contact_factory_get_from_handle (factory, handle,
+      dispatcher_operation_got_contact_cb, NULL, NULL, G_OBJECT (self));
+
+  g_object_unref (factory);
+}
+
 static void
 empathy_dispatch_operation_constructed (GObject *object)
 {
@@ -215,14 +237,10 @@ empathy_dispatch_operation_constructed (GObject *object)
 
   handle = tp_channel_get_handle (priv->channel, &handle_type);
 
-  if (handle_type == TP_CONN_HANDLE_TYPE_CONTACT && priv->contact == NULL)
+  if (handle_type == TP_HANDLE_TYPE_CONTACT && priv->contact == NULL)
     {
-      EmpathyTpContactFactory *factory;
-
-      factory = empathy_tp_contact_factory_dup_singleton (priv->connection);
-      empathy_tp_contact_factory_get_from_handle (factory, handle,
-       dispatcher_operation_got_contact_cb, NULL, NULL, object);
-      g_object_unref (factory);
+      tp_connection_call_when_ready (priv->connection,
+          dispatch_operation_connection_ready, object);
       return;
     }
 
@@ -405,23 +423,6 @@ empathy_dispatcher_operation_tp_chat_ready_cb (GObject *object,
     EMPATHY_DISPATCHER_OPERATION_STATE_PENDING);
 }
 
-static void
-empathy_dispatcher_operation_tp_file_ready_cb (GObject *object,
-  GParamSpec *spec, gpointer user_data)
-{
-  EmpathyDispatchOperation *self = EMPATHY_DISPATCH_OPERATION (user_data);
-  EmpathyDispatchOperationPriv *priv = GET_PRIV (self);
-
-  if (!empathy_tp_file_is_ready (EMPATHY_TP_FILE (priv->channel_wrapper)))
-    return;
-
-  g_signal_handler_disconnect (priv->channel_wrapper, priv->ready_handler);
-  priv->ready_handler = 0;
-
-  empathy_dispatch_operation_set_status (self,
-    EMPATHY_DISPATCHER_OPERATION_STATE_PENDING);
-}
-
 static void
 empathy_dispatch_operation_channel_ready_cb (TpChannel *channel,
   const GError *error, gpointer user_data)
@@ -461,15 +462,8 @@ empathy_dispatch_operation_channel_ready_cb (TpChannel *channel,
     }
   else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER)
     {
-      EmpathyTpFile *file = empathy_tp_file_new (channel);
-      priv->channel_wrapper = G_OBJECT (file);
-
-      if (!empathy_tp_file_is_ready (file))
-        {
-          priv->ready_handler = g_signal_connect (file, "notify::ready",
-            G_CALLBACK (empathy_dispatcher_operation_tp_file_ready_cb), self);
-          return;
-        }
+       EmpathyTpFile *file = empathy_tp_file_new (channel, priv->incoming);
+       priv->channel_wrapper = G_OBJECT (file);
     }
 
 ready:
@@ -587,7 +581,7 @@ empathy_dispatch_operation_get_tp_connection (
 
   priv = GET_PRIV (operation);
 
-  return g_object_ref (priv->connection);
+  return priv->connection;
 }
 
 TpChannel *