[Spice-devel] [spice-gtk PATCH 7/9] usb-device-manager: Windows: spice_usb_device_equal_libdev: compare vid:pid
Uri Lublin
uril at redhat.com
Mon Mar 25 03:01:28 PDT 2013
When comparing spice_usb_device with a libusb_device on Windows clients,
use vid:pid instead of bus.address
It seems that a device bus.address may change when WinUSB driver
is being installed.
---
gtk/usb-device-manager.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index 0a561f1..a1399ee 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -1608,6 +1608,7 @@ static void spice_usb_device_unref(SpiceUsbDevice *device)
}
}
+#ifndef G_OS_WIN32 /* Linux -- compare bus.addr */
static gboolean
spice_usb_device_equal_libdev(SpiceUsbDevice *device,
libusb_device *libdev)
@@ -1624,6 +1625,26 @@ spice_usb_device_equal_libdev(SpiceUsbDevice *device,
return ((bus1 == bus2) && (addr1 == addr2));
}
+#else /* Windows -- compare vid:pid of device and libdev */
+static gboolean
+spice_usb_device_equal_libdev(SpiceUsbDevice *device,
+ libusb_device *libdev)
+{
+ int vid1, vid2, pid1, pid2;
+
+ if ((device == NULL) || (libdev == NULL))
+ return FALSE;
+
+ vid1 = spice_usb_device_get_vid(device);
+ pid1 = spice_usb_device_get_pid(device);
+
+ if (!spice_usb_device_manager_get_libdev_vid_pid(libdev, &vid2, &pid2)) {
+ return FALSE;
+ }
+
+ return ((vid1 == vid2) && (pid1 == pid2));
+}
+#endif
/*
* Caller must libusb_unref_device the libusb_device returned by this function.
--
1.8.1.4
More information about the Spice-devel
mailing list