Blob Blame History Raw
From 769465494c5e3e4299a2dfdf6e0c835be4e04ab7 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Thu, 19 Mar 2020 06:12:34 +0000
Subject: [PATCH 9/9] channel-main: Handle some detailed error for
 VD_AGENT_FILE_XFER_STATUS_ERROR

Detect presence of detail on VD_AGENT_FILE_XFER_STATUS_ERROR and
if the error is supported give more detailed information, otherwise
fallback to the old generic error.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
(cherry picked from commit d79b05dcff83792c8415cafbb288d614de9d3101)
---
 src/channel-main.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/channel-main.c b/src/channel-main.c
index c4fe02b..d845fda 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -1913,10 +1913,26 @@ static void main_agent_handle_xfer_status(SpiceMainChannel *channel,
         error = g_error_new_literal(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
                                     _("The spice agent cancelled the file transfer"));
         break;
-    case VD_AGENT_FILE_XFER_STATUS_ERROR:
-        error = g_error_new_literal(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
-                                    _("The spice agent reported an error during the file transfer"));
+    case VD_AGENT_FILE_XFER_STATUS_ERROR: {
+        const VDAgentFileXferStatusError *err = (VDAgentFileXferStatusError *) msg->data;
+        if (test_agent_cap(channel, VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS) &&
+            msg_hdr->size >= sizeof(*msg) + sizeof(*err) &&
+            err->error_type == VD_AGENT_FILE_XFER_STATUS_ERROR_GLIB_IO) {
+
+            switch (err->error_code) {
+            case G_IO_ERROR_INVALID_FILENAME:
+                error = g_error_new_literal(G_IO_ERROR, err->error_code,
+                                            _("Invalid filename of transferred file"));
+                break;
+            }
+        }
+        if (error == NULL) {
+            error = g_error_new_literal(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
+                                        _("The spice agent reported an error "
+                                          "during the file transfer"));
+        }
         break;
+    }
     case VD_AGENT_FILE_XFER_STATUS_NOT_ENOUGH_SPACE: {
         const VDAgentFileXferStatusNotEnoughSpace *err =
             (VDAgentFileXferStatusNotEnoughSpace*) msg->data;
-- 
2.26.2