[Spice-devel] [PATCH spice-gtk 1/3] usb-device-manager: Cleanup USB manufacturer and product strings
Marc-André Lureau
marcandre.lureau at gmail.com
Mon Jan 30 10:00:25 PST 2012
ack
On Mon, Jan 30, 2012 at 2:33 PM, Hans de Goede <hdegoede at redhat.com> wrote:
> The strings returned by devices sometimes can benefit from some clean-up.
>
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
> gtk/usb-device-manager.c | 13 +++++++++++++
> 1 files changed, 13 insertions(+), 0 deletions(-)
>
> diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
> index 2a3b753..c5062b7 100644
> --- a/gtk/usb-device-manager.c
> +++ b/gtk/usb-device-manager.c
> @@ -985,6 +985,19 @@ gchar *spice_usb_device_get_description(SpiceUsbDevice *_device, const gchar *fo
> if (!product)
> product = g_strdup(_("Device"));
>
> + /* Some devices have unwanted whitespace in their strings */
> + g_strstrip(manufacturer);
> + g_strstrip(product);
> +
> + /* Some devices repeat the manufacturer at the beginning of product */
> + if (g_str_has_prefix(product, manufacturer) &&
> + strlen(product) > strlen(manufacturer)) {
> + gchar *tmp = g_strdup(product + strlen(manufacturer));
> + g_free(product);
> + product = tmp;
> + g_strstrip(product);
> + }
> +
> if (libusb_get_device_descriptor(device, &desc) == LIBUSB_SUCCESS)
> descriptor = g_strdup_printf("[%04x:%04x]", desc.idVendor, desc.idProduct);
> else
> --
> 1.7.7.6
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
--
Marc-André Lureau
More information about the Spice-devel
mailing list