#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)
{
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);
}
if (error != NULL)
{
+ DEBUG ("NameHasOwner failed. Can't dispatch tube");
empathy_tube_dispatch_set_ability (self,
EMPATHY_TUBE_DISPATCHABILITY_IMPOSSIBLE);
return;
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));
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))
+ {
+ GError *error = NULL;
+
+ type = TP_TUBE_TYPE_DBUS;
+ service = tp_asv_get_string (properties,
+ EMP_IFACE_CHANNEL_TYPE_DBUS_TUBE ".ServiceName");
+
+ if (!tp_dbus_check_valid_bus_name (service, TP_DBUS_NAME_TYPE_WELL_KNOWN,
+ &error))
+ {
+ DEBUG ("Can't dispatch tube; invalid ServiceName %s: %s", service,
+ error->message);
+ g_error_free (error);
+ goto failed;
+ }
+ }
+ 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));
-
- g_object_unref (channel);
return;
failed:
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));
channel = empathy_dispatch_operation_get_channel (priv->operation);
-
/* Create the proxy for the tube handler */
thandler = g_object_new (TP_TYPE_PROXY,
"dbus-connection", tp_get_bus (),
object_path, handle_type, handle,
empathy_tube_dispatch_handle_tube_cb, NULL, NULL, G_OBJECT (self));
- g_object_unref (channel);
g_object_unref (thandler);
g_object_unref (connection);
g_free (object_path);
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);
g_free (msg);
tp_cli_channel_call_close (channel, -1, NULL, NULL, NULL, NULL);
- g_object_unref (channel);
goto done;
}