[empathy/gnome-2-34] Set FileTransfer.URI when accepting a file (#641707)



commit f4b9ea4f2748b0c9e69133d10ded0c0a8d594667
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Mon Feb 7 11:33:39 2011 +0100

    Set FileTransfer.URI when accepting a file (#641707)

 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 25a8c40..a9ef227 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, &nothing);
+
+  tp_cli_channel_type_file_transfer_call_accept_file (priv->channel,
+      -1, priv->socket_address_type, priv->socket_access_control,
+      &nothing, 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, &nothing);
+  /* 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,
-      &nothing, 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]