[Spice-devel] [spice-gtk Win32 v5 09/22] spice_usb_device_get_description: use device-descriptor only to get <vid, pid>
Uri Lublin
uril at redhat.com
Mon Jul 9 05:14:52 PDT 2012
In preparation for a different SpiceUsbDevice.
With the new SpiceUsbDeviceInfo, <vid,pid> will be provided by
SpiceUsbDevice, and not by the device_descriptor (from libusb)
---
gtk/usb-device-manager.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index 9f29c76..04c3169 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -1031,25 +1031,30 @@ gchar *spice_usb_device_get_description(SpiceUsbDevice *_device, const gchar *fo
#ifdef USE_USBREDIR
libusb_device *device = (libusb_device *)_device;
struct libusb_device_descriptor desc;
- int bus, address;
+ int bus, address, vid, pid;
gchar *description, *descriptor, *manufacturer = NULL, *product = NULL;
g_return_val_if_fail(device != NULL, NULL);
bus = libusb_get_bus_number(device);
address = libusb_get_device_address(device);
+ vid = -1;
+ pid = -1;
if (libusb_get_device_descriptor(device, &desc) == LIBUSB_SUCCESS) {
- spice_usb_util_get_device_strings(bus, address,
- desc.idVendor, desc.idProduct,
- &manufacturer, &product);
+ vid = desc.idVendor;
+ pid = desc.idProduct;
+ }
+
+ if ((vid > 0) && (pid > 0)) {
descriptor = g_strdup_printf("[%04x:%04x]", desc.idVendor, desc.idProduct);
} else {
- spice_usb_util_get_device_strings(bus, address, -1, -1,
- &manufacturer, &product);
descriptor = g_strdup("");
}
+ spice_usb_util_get_device_strings(bus, address, vid, pid,
+ &manufacturer, &product);
+
if (!format)
format = _("%s %s %s at %d-%d");
--
1.7.1
More information about the Spice-devel
mailing list