]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-tube-handler.c
Updated Basque language
[empathy.git] / libempathy / empathy-tube-handler.c
index ec12d18ba7f0f9c49b79d1c59e8542cb3dcb9548..2b50ec852ed8ffbc20d6064952d08897dbed3bd7 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- * 
+ *
  * Authors: Xavier Claessens <xclaesse@gmail.com>
  *          Elliot Fairweather <elliot.fairweather@collabora.co.uk>
  */
@@ -31,7 +31,6 @@
 
 #include <extensions/extensions.h>
 
-#include "empathy-tp-tube.h"
 #include "empathy-tube-handler.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
@@ -59,20 +58,9 @@ typedef struct
   gchar *channel;
   guint handle_type;
   guint handle;
-  EmpathyTpTube *tube;
+  TpChannel *tube;
 } IdleData;
 
-static void
-tube_ready_cb (EmpathyTpTube *tube,
-    const GError *error,
-    gpointer user_data,
-    GObject *weak_object)
-{
-  IdleData *idle_data = user_data;
-
-  g_signal_emit (idle_data->thandler, signals[NEW_TUBE], 0, tube);
-}
-
 static void
 tube_ready_destroy_notify (gpointer data)
 {
@@ -85,10 +73,30 @@ tube_ready_destroy_notify (gpointer data)
   g_slice_free (IdleData, idle_data);
 }
 
+static void
+channel_ready_cb (TpChannel *channel,
+    const GError *error,
+    gpointer data)
+{
+  IdleData *idle_data = data;
+
+  if (error != NULL)
+    {
+      DEBUG ("channel has been invalidated: %s", error->message);
+      tube_ready_destroy_notify (data);
+      g_object_unref (channel);
+      return;
+    }
+
+  g_signal_emit (idle_data->thandler, signals[NEW_TUBE], 0, idle_data->tube);
+
+  g_object_unref (channel);
+}
+
 static void
 connection_ready_cb (TpConnection *connection,
-                     const GError *error,
-                     gpointer data)
+    const GError *error,
+    gpointer data)
 {
   TpChannel *channel;
   IdleData *idle_data = data;
@@ -96,19 +104,16 @@ connection_ready_cb (TpConnection *connection,
   if (error != NULL)
     {
       DEBUG ("connection has been invalidated: %s", error->message);
+      tube_ready_destroy_notify (data);
+      g_object_unref (connection);
       return;
     }
 
   channel = tp_channel_new (connection, idle_data->channel,
       TP_IFACE_CHANNEL_TYPE_TUBES, idle_data->handle_type,
       idle_data->handle, NULL);
-  tp_channel_run_until_ready (channel, NULL, NULL);
+  tp_channel_call_when_ready (channel, channel_ready_cb, idle_data);
 
-  idle_data->tube = empathy_tp_tube_new (channel);
-  empathy_tp_tube_call_when_ready (idle_data->tube, tube_ready_cb, idle_data,
-      tube_ready_destroy_notify, NULL);
-
-  g_object_unref (channel);
   g_object_unref (connection);
 }
 
@@ -134,12 +139,12 @@ tube_handler_handle_tube_idle_cb (gpointer data)
 
 static void
 tube_handler_handle_tube (EmpSvcTubeHandler *self,
-                          const gchar *bus_name,
-                          const gchar *connection,
-                          const gchar *channel,
-                          guint handle_type,
-                          guint handle,
-                          DBusGMethodInvocation *context)
+    const gchar *bus_name,
+    const gchar *connection,
+    const gchar *channel,
+    guint handle_type,
+    guint handle,
+    DBusGMethodInvocation *context)
 {
   EmpathyTubeHandler *thandler = EMPATHY_TUBE_HANDLER (self);
   IdleData *data;
@@ -164,7 +169,7 @@ empathy_tube_handler_class_init (EmpathyTubeHandlerClass *klass)
   signals[NEW_TUBE] =
       g_signal_new ("new-tube", G_OBJECT_CLASS_TYPE (klass),
       G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
-      G_TYPE_NONE, 1, EMPATHY_TYPE_TP_TUBE);
+      G_TYPE_NONE, 1, TP_TYPE_CHANNEL);
 }
 
 static void
@@ -180,7 +185,8 @@ empathy_tube_handler_init (EmpathyTubeHandler *thandler)
 }
 
 EmpathyTubeHandler *
-empathy_tube_handler_new (TpTubeType type, const gchar *service)
+empathy_tube_handler_new (TpTubeType type,
+    const gchar *service)
 {
   EmpathyTubeHandler *thandler = NULL;
   DBusGProxy *proxy;
@@ -280,4 +286,3 @@ empathy_tube_handler_build_object_path (TpTubeType type,
 
   return str;
 }
-