From 97842d0d8955e5e3e6179683b04dfd212d671bd6 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 5 Jan 2015 15:59:36 +0000 Subject: device: Add g_usb_device_get_vid_as_str() --- gusb/gusb-device.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'gusb/gusb-device.c') diff --git a/gusb/gusb-device.c b/gusb/gusb-device.c index 62d48b0..3814b14 100644 --- a/gusb/gusb-device.c +++ b/gusb/gusb-device.c @@ -34,6 +34,7 @@ #include #include "gusb-context.h" +#include "gusb-context-private.h" #include "gusb-util.h" #include "gusb-device.h" #include "gusb-device-private.h" @@ -1439,6 +1440,45 @@ g_usb_device_get_pid (GUsbDevice *device) return device->priv->desc.idProduct; } +/** + * g_usb_device_get_vid_as_str: + * @device: a #GUsbDevice + * + * Gets the vendor ID for the device as a string. + * + * Return value: an string ID, or %NULL if not available. + * + * Since: 0.2.4 + **/ +const gchar * +g_usb_device_get_vid_as_str (GUsbDevice *device) +{ + g_return_val_if_fail (G_USB_IS_DEVICE (device), NULL); + return _g_usb_context_lookup_vendor (device->priv->context, + device->priv->desc.idVendor, + NULL); +} + +/** + * g_usb_device_get_pid_as_str: + * @device: a #GUsbDevice + * + * Gets the product ID for the device as a string. + * + * Return value: an string ID, or %NULL if not available. + * + * Since: 0.2.4 + **/ +const gchar * +g_usb_device_get_pid_as_str (GUsbDevice *device) +{ + g_return_val_if_fail (G_USB_IS_DEVICE (device), NULL); + return _g_usb_context_lookup_product (device->priv->context, + device->priv->desc.idVendor, + device->priv->desc.idProduct, + NULL); +} + /** * g_usb_device_get_manufacturer_index: * @device: a #GUsbDevice -- cgit v1.2.1