/** * mcd_channel_new_from_properties: * @connection: the #TpConnection on which the channel exists. * @object_path: the D-Bus object path of an existing channel. * @properties: #GHashTable of immutable channel properties. * * Creates a #McdChannel with an associated #TpChannel proxy for the channel * located at @object_path. * * Returns: a new #McdChannel if the #TpChannel was created successfully, %NULL * otherwise. */ McdChannel * mcd_channel_new_from_properties (TpConnection *connection, const gchar *object_path, const GHashTable *properties) { McdChannel *channel; TpChannel *tp_chan; GError *error = NULL; tp_chan = tp_channel_new_from_properties (connection, object_path, properties, &error); if (G_UNLIKELY (error)) { g_warning ("%s: got error: %s", G_STRFUNC, error->message); g_error_free (error); return NULL; } channel = g_object_new (MCD_TYPE_CHANNEL, "tp-channel", tp_chan, NULL); g_object_unref (tp_chan); return channel; }
static void create_ft_channel_cb (TpConnection *conn, const char *object_path, GHashTable *properties, const GError *in_error, gpointer user_data, GObject *weak_obj) { GError *error = NULL; handle_error (in_error); TpChannel *channel = tp_channel_new_from_properties (conn, object_path, properties, &error); handle_error (error); tp_channel_call_when_ready (channel, file_transfer_channel_ready, NULL); }
static void create_contact_list_channel_cb (TpConnection *conn, gboolean yours, const char *object_path, GHashTable *properties, const GError *in_error, gpointer user_data, GObject *weak_obj) { char **argv = (char **) user_data; GError *error = NULL; handle_error (in_error); TpChannel *channel = tp_channel_new_from_properties (conn, object_path, properties, &error); handle_error (error); tp_channel_call_when_ready (channel, contact_list_channel_ready, argv); }
static void list_ensure_channel_cb (TpConnection *conn, gboolean yours, const gchar *path, GHashTable *properties, const GError *error, gpointer user_data, GObject *weak_object) { EmpathyTpContactList *list = user_data; TpChannel *channel; if (error != NULL) { DEBUG ("failed: %s\n", error->message); return; } channel = tp_channel_new_from_properties (conn, path, properties, NULL); got_list_channel (list, channel); g_object_unref (channel); }
static void tp_contact_list_group_add_channel (EmpathyTpContactList *list, const gchar *object_path, GHashTable *properties) { EmpathyTpContactListPriv *priv = GET_PRIV (list); TpChannel *channel; GError *error = NULL; channel = tp_channel_new_from_properties (priv->connection, object_path, properties, &error); if (channel == NULL) { DEBUG ("Failed to create group channel: %s", error->message); g_error_free (error); return; } /* Give the ref to the callback */ tp_channel_call_when_ready (channel, tp_contact_list_group_ready_cb, list); }
static void remmina_tp_channel_handler_connection_ready(TpConnection *connection, const GError *connection_error, gpointer user_data) { RemminaTpChannelHandler *chandler = (RemminaTpChannelHandler *) user_data; GError *error = NULL; if (connection_error != NULL) { g_print("remmina_tp_channel_handler_connection_ready: %s\n", connection_error->message); remmina_tp_channel_handler_free(chandler); return; } chandler->channel = tp_channel_new_from_properties(connection, chandler->channel_path, chandler->channel_properties, &error); if (chandler->channel == NULL) { g_print("tp_channel_new_from_properties: %s\n", error->message); remmina_tp_channel_handler_free(chandler); return; } tp_channel_call_when_ready(chandler->channel, remmina_tp_channel_handler_channel_ready, chandler); }
/** * mcd_channel_create_proxy: * @channel: the #McdChannel. * @connection: the #TpConnection on which the channel exists. * @object_path: the D-Bus object path of an existing channel. * @properties: #GHashTable of immutable channel properties, or %NULL. * * This method makes @channel create a #TpChannel object for @object_path. * It must not be called if @channel has already a #TpChannel associated with * it. * * Returns: %TRUE if the #TpChannel has been created, %FALSE otherwise. */ gboolean _mcd_channel_create_proxy (McdChannel *channel, TpConnection *connection, const gchar *object_path, const GHashTable *properties) { TpChannel *tp_chan; GError *error = NULL; g_return_val_if_fail (MCD_IS_CHANNEL (channel), FALSE); tp_chan = tp_channel_new_from_properties (connection, object_path, properties, &error); if (G_UNLIKELY (error)) { g_warning ("%s: got error: %s", G_STRFUNC, error->message); g_error_free (error); return FALSE; } g_object_set (channel, "tp-channel", tp_chan, NULL); g_object_unref (tp_chan); return TRUE; }
EmpathyTpTube * empathy_tp_tube_new_stream_tube (EmpathyContact *contact, TpSocketAddressType type, const gchar *hostname, guint port, const gchar *service, GHashTable *parameters) { MissionControl *mc; McAccount *account; TpConnection *connection; TpChannel *channel; gchar *object_path; GHashTable *params; GValue *address; GValue *control_param; EmpathyTpTube *tube = NULL; GError *error = NULL; GHashTable *request; GHashTable *channel_properties; GValue *value; g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); g_return_val_if_fail (hostname != NULL, NULL); g_return_val_if_fail (service != NULL, NULL); mc = empathy_mission_control_dup_singleton (); account = empathy_contact_get_account (contact); connection = mission_control_get_tpconnection (mc, account, NULL); g_object_unref (mc); tp_connection_run_until_ready (connection, FALSE, NULL, NULL); request = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) tp_g_value_slice_free); /* org.freedesktop.Telepathy.Channel.ChannelType */ value = tp_g_value_slice_new (G_TYPE_STRING); g_value_set_string (value, EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE); g_hash_table_insert (request, TP_IFACE_CHANNEL ".ChannelType", value); /* org.freedesktop.Telepathy.Channel.TargetHandleType */ value = tp_g_value_slice_new (G_TYPE_UINT); g_value_set_uint (value, TP_HANDLE_TYPE_CONTACT); g_hash_table_insert (request, TP_IFACE_CHANNEL ".TargetHandleType", value); /* org.freedesktop.Telepathy.Channel.TargetHandleType */ value = tp_g_value_slice_new (G_TYPE_UINT); g_value_set_uint (value, empathy_contact_get_handle (contact)); g_hash_table_insert (request, TP_IFACE_CHANNEL ".TargetHandle", value); /* org.freedesktop.Telepathy.Channel.Type.StreamTube.Service */ value = tp_g_value_slice_new (G_TYPE_STRING); g_value_set_string (value, service); g_hash_table_insert (request, EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE ".Service", value); if (!tp_cli_connection_interface_requests_run_create_channel (connection, -1, request, &object_path, &channel_properties, &error, NULL)) { DEBUG ("Error requesting channel: %s", error->message); g_clear_error (&error); g_object_unref (connection); return NULL; } DEBUG ("Offering a new stream tube"); channel = tp_channel_new_from_properties (connection, object_path, channel_properties, NULL); tp_channel_run_until_ready (channel, NULL, NULL); #define ADDRESS_TYPE dbus_g_type_get_struct ("GValueArray",\ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID) params = g_hash_table_new (g_str_hash, g_str_equal); address = tp_g_value_slice_new (ADDRESS_TYPE); g_value_take_boxed (address, dbus_g_type_specialized_construct (ADDRESS_TYPE)); dbus_g_type_struct_set (address, 0, hostname, 1, port, G_MAXUINT); control_param = tp_g_value_slice_new (G_TYPE_STRING); if (!emp_cli_channel_type_stream_tube_run_offer_stream_tube ( TP_PROXY(channel), -1, type, address, TP_SOCKET_ACCESS_CONTROL_LOCALHOST, control_param, parameters, &error, NULL)) { DEBUG ("Couldn't offer tube: %s", error->message); g_clear_error (&error); goto OUT; } DEBUG ("Stream tube offered"); tube = empathy_tp_tube_new (channel); OUT: g_object_unref (channel); g_free (object_path); g_hash_table_destroy (request); g_hash_table_destroy (channel_properties); tp_g_value_slice_free (address); tp_g_value_slice_free (control_param); g_object_unref (connection); return tube; }