[Spice-devel] [PATCH spice-gtk] main: Handle disabled file transfer

Pavel Grunt pgrunt at redhat.com
Fri Mar 10 07:20:53 UTC 2017


File transfer can be disabled by the server or agent, it is
signalized by the VD_AGENT_CAP_FILE_XFER_DISABLED set.

Do not try to transfer files when the capability is set.

Resolves: rhbz#1373725
---
Sending to show usage of the cap proposed in:
https://lists.freedesktop.org/archives/spice-devel/2017-February/036106.html
---
 src/channel-main.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/channel-main.c b/src/channel-main.c
index cd3dee7..fd9764b 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -225,6 +225,7 @@ static const char *agent_caps[] = {
     [ VD_AGENT_CAP_MAX_CLIPBOARD       ] = "max-clipboard",
     [ VD_AGENT_CAP_AUDIO_VOLUME_SYNC   ] = "volume-sync",
     [ VD_AGENT_CAP_MONITORS_CONFIG_POSITION ] = "monitors config position",
+    [ VD_AGENT_CAP_FILE_XFER_DISABLED ] = "file transfer disabled",
 };
 #define NAME(_a, _i) ((_i) < SPICE_N_ELEMENTS(_a) ? (_a[(_i)] ?: "?") : "?")
 
@@ -3097,6 +3098,17 @@ void spice_main_file_copy_async(SpiceMainChannel *channel,
         return;
     }
 
+    if (test_agent_cap(channel, VD_AGENT_CAP_FILE_XFER_DISABLED)) {
+        g_task_report_new_error(channel,
+                                callback,
+                                user_data,
+                                spice_main_file_copy_async,
+                                SPICE_CLIENT_ERROR,
+                                SPICE_CLIENT_ERROR_FAILED,
+                                "The file transfer is disabled");
+        return;
+    }
+
     xfer_op = g_new0(FileTransferOperation, 1);
     xfer_op->channel = channel;
     xfer_op->progress_callback = progress_callback;
-- 
2.12.0



More information about the Spice-devel mailing list