diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-02-07 18:33:39 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-02-07 18:33:39 +0800 |
commit | 4f54a4e0ecb21b56c22efb1756f174eacd8c17f5 (patch) | |
tree | 99e80093bceee0e9a95e5efe0893bf108a223e0c | |
parent | 7e67efc0b94e62d2a5f48412abc5f71c43ca764b (diff) | |
download | gsoc2013-empathy-4f54a4e0ecb21b56c22efb1756f174eacd8c17f5.tar gsoc2013-empathy-4f54a4e0ecb21b56c22efb1756f174eacd8c17f5.tar.gz gsoc2013-empathy-4f54a4e0ecb21b56c22efb1756f174eacd8c17f5.tar.bz2 gsoc2013-empathy-4f54a4e0ecb21b56c22efb1756f174eacd8c17f5.tar.lz gsoc2013-empathy-4f54a4e0ecb21b56c22efb1756f174eacd8c17f5.tar.xz gsoc2013-empathy-4f54a4e0ecb21b56c22efb1756f174eacd8c17f5.tar.zst gsoc2013-empathy-4f54a4e0ecb21b56c22efb1756f174eacd8c17f5.zip |
Set FileTransfer.URI when accepting a file (#641707)
-rw-r--r-- | libempathy/empathy-tp-file.c | 49 |
1 files changed, 39 insertions, 10 deletions
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 @@ -616,19 +616,48 @@ file_read_async_cb (GObject *source, } 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 |