[Spice-devel] [PATCH spice-gtk] widget: Inform about transfer failure

Pavel Grunt pgrunt at redhat.com
Wed Sep 14 08:03:31 UTC 2016


Call spice_main_file_copy_finish to get result of the transfer
---
 src/spice-widget.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/spice-widget.c b/src/spice-widget.c
index 9c8f7d1..cc89f22 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -499,6 +499,22 @@ static gboolean grab_broken(SpiceDisplay *self, GdkEventGrabBroken *event,
     return false;
 }
 
+static void file_transfer_callback(GObject *source_object,
+                                   GAsyncResult *result,
+                                   gpointer user_data G_GNUC_UNUSED)
+{
+    SpiceMainChannel *channel = SPICE_MAIN_CHANNEL(source_object);
+    GError *error = NULL;
+
+    if (spice_main_file_copy_finish(channel, result, &error))
+        return;
+
+    if (error != NULL && error->message != NULL)
+        g_warning("File transfer failed with error: %s", error->message);
+
+    g_error_free(error);
+}
+
 static void drag_data_received_callback(SpiceDisplay *self,
                                         GdkDragContext *drag_context,
                                         gint x,
@@ -531,7 +547,7 @@ static void drag_data_received_callback(SpiceDisplay *self,
     g_strfreev(file_urls);
 
     spice_main_file_copy_async(d->main, files, 0, NULL, NULL,
-                               NULL, NULL, NULL);
+                               NULL, file_transfer_callback, NULL);
     for (i = 0; i < n_files; i++) {
         g_object_unref(files[i]);
     }
-- 
2.10.0



More information about the Spice-devel mailing list