[Spice-commits] configure.ac gtk/channel-usbredir.c gtk/spice-client.h

Hans de Goede jwrdegoede at kemper.freedesktop.org
Thu Mar 8 02:35:21 PST 2012


 configure.ac           |    2 +-
 gtk/channel-usbredir.c |   24 +++++++++++++++++++++---
 gtk/spice-client.h     |    2 ++
 3 files changed, 24 insertions(+), 4 deletions(-)

New commits:
commit 662b1dda7f0a51244b42dcfc616e43d3887e1e48
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Tue Mar 6 19:29:46 2012 +0100

    channel-usbredir: Handle some more usbredirhost_read_guest_data errors
    
    Signed-off-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/configure.ac b/configure.ac
index 1d24773..13f33e6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -346,7 +346,7 @@ if test "x$enable_usbredir" = "xno"; then
   have_usbredir="no"
 else
   PKG_CHECK_MODULES([USBREDIR],
-                    [gudev-1.0 libusb-1.0 >= 1.0.9 libusbredirhost >= 0.4 libusbredirparser >= 0.4],
+                    [gudev-1.0 libusb-1.0 >= 1.0.9 libusbredirhost >= 0.4.2 libusbredirparser >= 0.4],
                     [have_usbredir=yes],
                     [have_usbredir=no])
   if test "x$have_usbredir" = "xno" && test "x$enable_usbredir" = "xyes"; then
diff --git a/gtk/channel-usbredir.c b/gtk/channel-usbredir.c
index eb81fe5..ddc6922 100644
--- a/gtk/channel-usbredir.c
+++ b/gtk/channel-usbredir.c
@@ -22,6 +22,7 @@
 #include "config.h"
 
 #ifdef USE_USBREDIR
+#include <glib/gi18n.h>
 #include <usbredirhost.h>
 #if USE_POLKIT
 #include "usb-acl-helper.h"
@@ -606,7 +607,7 @@ static void usbredir_handle_msg(SpiceChannel *c, SpiceMsgIn *in)
     priv->read_buf_size = size;
 
     r = usbredirhost_read_guest_data(priv->host);
-    if (r == usbredirhost_read_device_rejected) {
+    if (r != 0) {
         libusb_device *device = priv->device;
         gchar *desc;
         GError *err;
@@ -615,8 +616,25 @@ static void usbredir_handle_msg(SpiceChannel *c, SpiceMsgIn *in)
 
         desc = spice_usb_device_get_description((SpiceUsbDevice *)device,
                                                 NULL);
-        err  = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
-                           "%s rejected by host", desc);
+        switch (r) {
+        case usbredirhost_read_parse_error:
+            err = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
+                              _("usbredir protocol parse error for %s"), desc);
+            break;
+        case usbredirhost_read_device_rejected:
+            err = g_error_new(SPICE_CLIENT_ERROR,
+                              SPICE_CLIENT_USB_DEVICE_REJECTED,
+                              _("%s rejected by host"), desc);
+            break;
+        case usbredirhost_read_device_lost:
+            err = g_error_new(SPICE_CLIENT_ERROR,
+                              SPICE_CLIENT_USB_DEVICE_LOST,
+                              _("%s disconnected (fatal IO error)"), desc);
+            break;
+        default:
+            err = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
+                              _("Unknown error (%d) for %s"), r, desc);
+        }
         g_free(desc);
 
         SPICE_DEBUG("%s", err->message);
diff --git a/gtk/spice-client.h b/gtk/spice-client.h
index 2d7c622..5c05ebb 100644
--- a/gtk/spice-client.h
+++ b/gtk/spice-client.h
@@ -58,6 +58,8 @@ G_BEGIN_DECLS
 typedef enum
 {
     SPICE_CLIENT_ERROR_FAILED,
+    SPICE_CLIENT_USB_DEVICE_REJECTED,
+    SPICE_CLIENT_USB_DEVICE_LOST,
 } SpiceClientError;
 
 GQuark spice_client_error_quark(void);


More information about the Spice-commits mailing list