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

Pavel Grunt pgrunt at redhat.com
Tue Dec 20 19:39:33 UTC 2016


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
---
 configure.ac       |  2 +-
 src/channel-main.c | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index f3e7f8d..aa60e91 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,7 +69,7 @@ AC_CHECK_LIBM
 AC_SUBST(LIBM)
 
 AC_CONFIG_SUBDIRS([spice-common])
-PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= 0.12.12])
+PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= 0.12.13])
 
 COMMON_CFLAGS='-I${top_builddir}/spice-common/ -I${top_srcdir}/spice-common/ ${SPICE_PROTOCOL_CFLAGS}'
 AC_SUBST(COMMON_CFLAGS)
diff --git a/src/channel-main.c b/src/channel-main.c
index ed5d611..d91a749 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)] ?: "?") : "?")
 
@@ -3092,6 +3093,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.11.0



More information about the Spice-devel mailing list