From fa2556b755343dfd973b05ac101ba2c8b20645db Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 26 Oct 2022 09:10:31 +0100 Subject: Export g_usb_device_has_tag() --- gusb/gusb-context.c | 4 ++-- gusb/gusb-device-private.h | 2 -- gusb/gusb-device.c | 15 +++++++++++++-- gusb/gusb-device.h | 2 ++ gusb/libgusb.ver | 6 ++++++ 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gusb/gusb-context.c b/gusb/gusb-context.c index 0a37b17..e7a49b4 100644 --- a/gusb/gusb-context.c +++ b/gusb/gusb-context.c @@ -425,7 +425,7 @@ g_usb_context_load_with_tag(GUsbContext *self, g_object_new(G_USB_TYPE_DEVICE, "context", self, NULL); if (!_g_usb_device_load(device, obj_tmp, error)) return FALSE; - if (tag != NULL && !_g_usb_device_has_tag(device, tag)) + if (tag != NULL && !g_usb_device_has_tag(device, tag)) continue; g_ptr_array_add(priv->devices, g_object_ref(device)); g_signal_emit(self, signals[DEVICE_ADDED_SIGNAL], 0, device); @@ -493,7 +493,7 @@ g_usb_context_save_with_tag(GUsbContext *self, } for (guint i = 0; i < priv->devices->len; i++) { GUsbDevice *device = g_ptr_array_index(priv->devices, i); - if (tag != NULL && !_g_usb_device_has_tag(device, tag)) + if (tag != NULL && !g_usb_device_has_tag(device, tag)) continue; if (!_g_usb_device_save(device, json_builder, error)) return FALSE; diff --git a/gusb/gusb-device-private.h b/gusb/gusb-device-private.h index e772c9e..70218b2 100644 --- a/gusb/gusb-device-private.h +++ b/gusb/gusb-device-private.h @@ -22,7 +22,5 @@ libusb_device * _g_usb_device_get_device(GUsbDevice *self); gboolean _g_usb_device_open_internal(GUsbDevice *self, GError **error); -gboolean -_g_usb_device_has_tag(GUsbDevice *self, const gchar *tag); G_END_DECLS diff --git a/gusb/gusb-device.c b/gusb/gusb-device.c index 601e5d6..773b3bc 100644 --- a/gusb/gusb-device.c +++ b/gusb/gusb-device.c @@ -448,8 +448,19 @@ _g_usb_device_save(GUsbDevice *self, JsonBuilder *json_builder, GError **error) return TRUE; } +/** + * g_usb_device_has_tag: + * @self: a #GUsbDevice + * @tag: a tag, for example `bootloader` or `runtime-reload` + * + * Checks if a tag has been used to identify the specific device. + * + * Return value: %TRUE on success + * + * Since: 0.4.3 + **/ gboolean -_g_usb_device_has_tag(GUsbDevice *self, const gchar *tag) +g_usb_device_has_tag(GUsbDevice *self, const gchar *tag) { GUsbDevicePrivate *priv = GET_PRIVATE(self); @@ -485,7 +496,7 @@ g_usb_device_add_tag(GUsbDevice *self, const gchar *tag) g_return_if_fail(G_USB_IS_DEVICE(self)); g_return_if_fail(tag != NULL); - if (_g_usb_device_has_tag(self, tag)) + if (g_usb_device_has_tag(self, tag)) return; g_ptr_array_add(priv->tags, g_strdup(tag)); } diff --git a/gusb/gusb-device.h b/gusb/gusb-device.h index 850fc8d..5c5a3d6 100644 --- a/gusb/gusb-device.h +++ b/gusb/gusb-device.h @@ -172,6 +172,8 @@ g_usb_device_get_device_protocol(GUsbDevice *self); void g_usb_device_add_tag(GUsbDevice *self, const gchar *tag); +gboolean +g_usb_device_has_tag(GUsbDevice *self, const gchar *tag); guint8 g_usb_device_get_configuration_index(GUsbDevice *self); diff --git a/gusb/libgusb.ver b/gusb/libgusb.ver index 4a4a731..9862f86 100644 --- a/gusb/libgusb.ver +++ b/gusb/libgusb.ver @@ -193,3 +193,9 @@ LIBGUSB_0.4.1 { g_usb_device_add_tag; local: *; } LIBGUSB_0.4.0; + +LIBGUSB_0.4.3 { + global: + g_usb_device_has_tag; + local: *; +} LIBGUSB_0.4.1; -- cgit v1.2.1