]> git.0d.be Git - empathy.git/blobdiff - src/empathy-tube-dispatch.c
Add en_GB in gitignore
[empathy.git] / src / empathy-tube-dispatch.c
index 0392b118ddaf5e895d8581550581d12f11fda927..b1e7bce6d18d13c3ec1ef4efc087b4393a25afb6 100644 (file)
@@ -37,6 +37,8 @@
 #include "empathy-tube-dispatch.h"
 #include "empathy-tube-dispatch-enumtypes.h"
 
+#define DEBUG_FLAG EMPATHY_DEBUG_DISPATCHER
+#include <libempathy/empathy-debug.h>
 
 G_DEFINE_TYPE(EmpathyTubeDispatch, empathy_tube_dispatch, G_TYPE_OBJECT)
 
@@ -93,12 +95,14 @@ empathy_tube_dispatch_list_activatable_names_cb (TpDBusDaemon *proxy,
     {
       if (!tp_strdiff (*name, priv->bus_name))
         {
+          DEBUG ("Found tube handler. Can dispatch it");
           empathy_tube_dispatch_set_ability (self,
             EMPATHY_TUBE_DISPATCHABILITY_POSSIBLE);
           return;
         }
     }
 
+  DEBUG ("Didn't find tube handler. Can't dispatch it");
   empathy_tube_dispatch_set_ability (self,
     EMPATHY_TUBE_DISPATCHABILITY_IMPOSSIBLE);
 }
@@ -113,6 +117,7 @@ empathy_tube_dispatch_name_has_owner_cb (TpDBusDaemon *proxy,
 
   if (error != NULL)
     {
+      DEBUG ("NameHasOwner failed. Can't dispatch tube");
       empathy_tube_dispatch_set_ability (self,
         EMPATHY_TUBE_DISPATCHABILITY_IMPOSSIBLE);
       return;
@@ -120,11 +125,13 @@ empathy_tube_dispatch_name_has_owner_cb (TpDBusDaemon *proxy,
 
   if (has_owner)
     {
+      DEBUG ("Tube handler is running. Can dispatch it");
       empathy_tube_dispatch_set_ability (self,
         EMPATHY_TUBE_DISPATCHABILITY_POSSIBLE);
     }
   else
     {
+      DEBUG ("Tube handler is not running. Calling ListActivatableNames");
       tp_cli_dbus_daemon_call_list_activatable_names (priv->dbus, -1,
         empathy_tube_dispatch_list_activatable_names_cb, NULL, NULL,
         G_OBJECT (self));
@@ -139,25 +146,46 @@ empathy_tube_dispatch_constructed (GObject *object)
   TpChannel *channel;
   GHashTable *properties;
   const gchar *service;
+  const gchar *channel_type;
+  TpTubeType type;
 
   priv->dbus = tp_dbus_daemon_new (tp_get_bus());
 
   channel = empathy_dispatch_operation_get_channel (priv->operation);
   properties = tp_channel_borrow_immutable_properties (channel);
 
-  service = tp_asv_get_string (properties,
-    EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE  ".Service");
+  channel_type = tp_asv_get_string (properties,
+    TP_IFACE_CHANNEL ".ChannelType");
+  if (channel_type == NULL)
+    goto failed;
+
+  if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE))
+    {
+      type = TP_TUBE_TYPE_STREAM;
+      service = tp_asv_get_string (properties,
+        EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE  ".Service");
+    }
+  else if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_DBUS_TUBE))
+    {
+      type = TP_TUBE_TYPE_DBUS;
+      service = tp_asv_get_string (properties,
+        EMP_IFACE_CHANNEL_TYPE_DBUS_TUBE  ".ServiceName");
+    }
+  else
+    {
+      goto failed;
+    }
+
 
   if (service == NULL)
     goto failed;
 
-  priv->bus_name = empathy_tube_handler_build_bus_name (
-    TP_TUBE_TYPE_STREAM, service);
-  priv->object_path =
-    empathy_tube_handler_build_object_path (TP_TUBE_TYPE_STREAM, service);
+  priv->bus_name = empathy_tube_handler_build_bus_name (type, service);
+  priv->object_path = empathy_tube_handler_build_object_path (type, service);
 
   priv->service = g_strdup (service);
 
+  DEBUG ("Look for tube handler %s\n", priv->bus_name);
   tp_cli_dbus_daemon_call_name_has_owner (priv->dbus, -1, priv->bus_name,
     empathy_tube_dispatch_name_has_owner_cb, NULL, NULL, G_OBJECT (self));
 
@@ -316,7 +344,7 @@ empathy_tube_dispatch_show_error (EmpathyTubeDispatch *self, gchar *message)
   GtkWidget *dialog;
 
   dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
-      GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, message);
+      GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, "%s", message);
 
   gtk_dialog_run (GTK_DIALOG (dialog));
 
@@ -404,8 +432,8 @@ empathy_tube_dispatch_handle (EmpathyTubeDispatch *tube_dispatch)
       channel = empathy_dispatch_operation_get_channel (priv->operation);
 
       msg = g_strdup_printf (
-        _(" An invitation was offered for service %s, but you don't have the"
-          " needed application to handle it "), priv->service);
+        _("An invitation was offered for service %s, but you don't have the "
+          "needed application to handle it"), priv->service);
 
       empathy_tube_dispatch_show_error (tube_dispatch, msg);