From f4b9ea4f2748b0c9e69133d10ded0c0a8d594667 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 7 Feb 2011 11:33:39 +0100 Subject: Set FileTransfer.URI when accepting a file (#641707) --- libempathy/empathy-tp-file.c | 49 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 10 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c index 25a8c40bc..a9ef227c6 100644 --- a/libempathy/empathy-tp-file.c +++ b/libempathy/empathy-tp-file.c @@ -615,20 +615,49 @@ file_read_async_cb (GObject *source, NULL, NULL, G_OBJECT (tp_file)); } +static void +file_transfer_set_uri_cb (TpProxy *proxy, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + GValue nothing = { 0 }; + EmpathyTpFile *self = (EmpathyTpFile *) weak_object; + EmpathyTpFilePriv *priv = GET_PRIV (self); + + if (error != NULL) + { + DEBUG ("Failed to set FileTransfer.URI: %s", error->message); + /* We don't return as that's not a big issue */ + } + + /* we don't impose specific interface/port requirements even + * if we're not using UNIX sockets. + */ + initialize_empty_ac_variant (priv->socket_access_control, ¬hing); + + tp_cli_channel_type_file_transfer_call_accept_file (priv->channel, + -1, priv->socket_address_type, priv->socket_access_control, + ¬hing, priv->offset, + ft_operation_provide_or_accept_file_cb, NULL, NULL, weak_object); +} + static void file_replace_async_cb (GObject *source, GAsyncResult *res, gpointer user_data) { - GValue nothing = { 0 }; EmpathyTpFile *tp_file = user_data; EmpathyTpFilePriv *priv; GError *error = NULL; GFileOutputStream *out_stream; + GFile *file = G_FILE (source); + gchar *uri; + GValue *value; priv = GET_PRIV (tp_file); - out_stream = g_file_replace_finish (G_FILE (source), res, &error); + out_stream = g_file_replace_finish (file, res, &error); if (error != NULL) { @@ -640,15 +669,15 @@ file_replace_async_cb (GObject *source, priv->out_stream = G_OUTPUT_STREAM (out_stream); - /* we don't impose specific interface/port requirements even - * if we're not using UNIX sockets. - */ - initialize_empty_ac_variant (priv->socket_access_control, ¬hing); + /* Try setting FileTranfer.URI before accepting the file */ + uri = g_file_get_uri (file); + value = tp_g_value_slice_new_take_string (uri); - tp_cli_channel_type_file_transfer_call_accept_file (priv->channel, - -1, priv->socket_address_type, priv->socket_access_control, - ¬hing, priv->offset, - ft_operation_provide_or_accept_file_cb, NULL, NULL, G_OBJECT (tp_file)); + tp_cli_dbus_properties_call_set (priv->channel, -1, + TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, "URI", value, + file_transfer_set_uri_cb, NULL, NULL, G_OBJECT (tp_file)); + + tp_g_value_slice_free (value); } static void -- cgit v1.2.3