[Spice-devel] [spice-gtk Win32 v4 14/17] usb-device-manager: add 'state' field to SpiceUsbDeviceInfo

Uri Lublin uril at redhat.com
Thu Jul 5 13:44:06 PDT 2012


To be used on Win32 to ignore extra udev events
received during driver install/uninstall.
---
 gtk/usb-device-manager.c |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index b4bf7ac..1821c58 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -110,12 +110,24 @@ struct _SpiceUsbDeviceManagerPrivate {
     GPtrArray *channels;
 };

+enum {
+    SPICE_USB_DEVICE_STATE_NONE = 0, /* this is also DISCONNECTED */
+    SPICE_USB_DEVICE_STATE_CONNECTING,
+    SPICE_USB_DEVICE_STATE_CONNECTED,
+    SPICE_USB_DEVICE_STATE_DISCONNECTING,
+    SPICE_USB_DEVICE_STATE_INSTALLING,
+    SPICE_USB_DEVICE_STATE_UNINSTALLING,
+    SPICE_USB_DEVICE_STATE_MAX
+};
+
 typedef struct _SpiceUsbDeviceInfo {
 #ifdef USE_USBREDIR
     guint8  busnum;
     guint8  devaddr;
     guint16 vid;
     guint16 pid;
+    guint8  state;
+    guint8  reserved;
     int     ref;
 #endif
 } SpiceUsbDeviceInfo;
@@ -136,6 +148,11 @@ static SpiceUsbDeviceInfo *spice_usb_device_set_info(libusb_device *libdev);
 static SpiceUsbDevice *spice_usb_device_ref(SpiceUsbDevice *device);
 static void spice_usb_device_unref(SpiceUsbDevice *device);

+#ifdef G_OS_WIN32
+static guint8 spice_usb_device_get_state(SpiceUsbDevice *device);
+static void  spice_usb_device_set_state(SpiceUsbDevice *device, guint8 s);
+#endif
+
 static gboolean spice_usb_device_equal_libdev(SpiceUsbDevice *device,
                                               libusb_device *libdev);
 static SpiceUsbDevice *
@@ -1377,6 +1394,26 @@ guint16 spice_usb_device_get_pid(SpiceUsbDevice *device)
     return info->pid;
 }

+#ifdef G_OS_WIN32
+void spice_usb_device_set_state(SpiceUsbDevice *device, guint8 state)
+{
+    SpiceUsbDeviceInfo *info = (SpiceUsbDeviceInfo *)device;
+
+    g_return_if_fail(info != NULL);
+
+    info->state = state;
+}
+
+guint8 spice_usb_device_get_state(SpiceUsbDevice *device)
+{
+    SpiceUsbDeviceInfo *info = (SpiceUsbDeviceInfo *)device;
+
+    g_return_val_if_fail(info != NULL, 0);
+
+    return info->state;
+}
+#endif
+
 static SpiceUsbDevice *spice_usb_device_ref(SpiceUsbDevice *device)
 {
     SpiceUsbDeviceInfo *info = (SpiceUsbDeviceInfo *)device;
-- 
1.7.7.6



More information about the Spice-devel mailing list