void empathy_tube_dispatch_dispose (GObject *object) { EmpathyTubeDispatch *self = EMPATHY_TUBE_DISPATCH (object); EmpathyTubeDispatchPriv *priv = GET_PRIV (self); if (priv->dispose_has_run) return; priv->dispose_has_run = TRUE; /* release any references held by the object here */ if (priv->operation != NULL) g_object_unref (priv->operation); priv->operation = NULL; if (priv->dbus != NULL) g_object_unref (priv->dbus); priv->dbus = NULL; if (G_OBJECT_CLASS (empathy_tube_dispatch_parent_class)->dispose) G_OBJECT_CLASS (empathy_tube_dispatch_parent_class)->dispose (object); }
static void empathy_tube_dispatch_name_has_owner_cb (TpDBusDaemon *proxy, gboolean has_owner, const GError *error, gpointer user_data, GObject *object) { EmpathyTubeDispatch *self = EMPATHY_TUBE_DISPATCH (object); EmpathyTubeDispatchPriv *priv = GET_PRIV (self); 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)); } }
static void empathy_tube_dispatch_name_has_owner_cb (TpDBusDaemon *proxy, gboolean has_owner, const GError *error, gpointer user_data, GObject *object) { EmpathyTubeDispatch *self = EMPATHY_TUBE_DISPATCH (object); EmpathyTubeDispatchPriv *priv = GET_PRIV (self); if (error != NULL) { empathy_tube_dispatch_set_ability (self, EMPATHY_TUBE_DISPATCHABILITY_IMPOSSIBLE); return; } if (has_owner) { empathy_tube_dispatch_set_ability (self, EMPATHY_TUBE_DISPATCHABILITY_POSSIBLE); } else { tp_cli_dbus_daemon_call_list_activatable_names (priv->dbus, -1, empathy_tube_dispatch_list_activatable_names_cb, NULL, NULL, G_OBJECT (self)); } }
static void empathy_tube_dispatch_constructed (GObject *object) { EmpathyTubeDispatch *self = EMPATHY_TUBE_DISPATCH (object); EmpathyTubeDispatchPriv *priv = GET_PRIV (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); 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 (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)); return; failed: empathy_tube_dispatch_set_ability (self, EMPATHY_TUBE_DISPATCHABILITY_IMPOSSIBLE); }
void empathy_tube_dispatch_finalize (GObject *object) { EmpathyTubeDispatch *self = EMPATHY_TUBE_DISPATCH (object); EmpathyTubeDispatchPriv *priv = GET_PRIV (self); g_free (priv->bus_name); g_free (priv->object_path); g_free (priv->service); /* free any data held directly by the object here */ G_OBJECT_CLASS (empathy_tube_dispatch_parent_class)->finalize (object); }
static void empathy_tube_dispatch_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { EmpathyTubeDispatch *tube_dispatch = EMPATHY_TUBE_DISPATCH (object); EmpathyTubeDispatchPriv *priv = GET_PRIV (tube_dispatch); switch (property_id) { case PROP_OPERATION: priv->operation = g_value_dup_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void empathy_tube_dispatch_handle_tube_cb (TpProxy *proxy, const GError *error, gpointer user_data, GObject *object) { EmpathyTubeDispatch *self = EMPATHY_TUBE_DISPATCH (object); EmpathyTubeDispatchPriv *priv = GET_PRIV (self); if (error != NULL) { gchar *msg = g_strdup_printf ( _("Unable to start application for service %s: %s"), priv->service, error->message); empathy_tube_dispatch_show_error (self, msg); g_free (msg); } /* Remove the ref we were holding because of the dispatching */ g_object_unref (object); }
static void empathy_tube_dispatch_list_activatable_names_cb (TpDBusDaemon *proxy, const gchar **names, const GError *error, gpointer user_data, GObject *object) { EmpathyTubeDispatch *self = EMPATHY_TUBE_DISPATCH (object); EmpathyTubeDispatchPriv *priv = GET_PRIV (self); gchar **name; for (name = (gchar **) names; *name != NULL; name++) { if (!tp_strdiff (*name, priv->bus_name)) { empathy_tube_dispatch_set_ability (self, EMPATHY_TUBE_DISPATCHABILITY_POSSIBLE); return; } } empathy_tube_dispatch_set_ability (self, EMPATHY_TUBE_DISPATCHABILITY_IMPOSSIBLE); }
EmpathyTubeDispatch * empathy_tube_dispatch_new (EmpathyDispatchOperation *operation) { return EMPATHY_TUBE_DISPATCH (g_object_new (EMPATHY_TYPE_TUBE_DISPATCH, "operation", operation, NULL)); }