mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-07 10:27:36 +00:00
Add fu_device_remove_backend_tag() for future use
This commit is contained in:
parent
8f4604a14a
commit
83c6b33778
@ -1293,6 +1293,33 @@ fu_device_add_backend_tag(FuDevice *self, const gchar *backend_tag)
|
|||||||
g_object_notify(G_OBJECT(self), "backend-tags");
|
g_object_notify(G_OBJECT(self), "backend-tags");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fu_device_remove_backend_tag:
|
||||||
|
* @self: a #FuDevice
|
||||||
|
* @backend_tag: a tag, for example `bootloader` or `runtime-reload`
|
||||||
|
*
|
||||||
|
* Removes a backend tag, which allows the backend to identify the specific device for a specific
|
||||||
|
* phase.
|
||||||
|
*
|
||||||
|
* Since: 1.8.11
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
fu_device_remove_backend_tag(FuDevice *self, const gchar *backend_tag)
|
||||||
|
{
|
||||||
|
FuDevicePrivate *priv = GET_PRIVATE(self);
|
||||||
|
g_return_if_fail(FU_IS_DEVICE(self));
|
||||||
|
g_return_if_fail(backend_tag != NULL);
|
||||||
|
|
||||||
|
for (guint i = 0; i < priv->backend_tags->len; i++) {
|
||||||
|
const gchar *backend_tag_tmp = g_ptr_array_index(priv->backend_tags, i);
|
||||||
|
if (g_strcmp0(backend_tag_tmp, backend_tag) == 0) {
|
||||||
|
g_ptr_array_remove_index(priv->backend_tags, i);
|
||||||
|
g_object_notify(G_OBJECT(self), "backend-tags");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fu_device_has_backend_tag:
|
* fu_device_has_backend_tag:
|
||||||
* @self: a #FuDevice
|
* @self: a #FuDevice
|
||||||
|
@ -547,6 +547,8 @@ void
|
|||||||
fu_device_set_version_from_uint64(FuDevice *self, guint64 version_raw);
|
fu_device_set_version_from_uint64(FuDevice *self, guint64 version_raw);
|
||||||
void
|
void
|
||||||
fu_device_add_backend_tag(FuDevice *self, const gchar *backend_tag);
|
fu_device_add_backend_tag(FuDevice *self, const gchar *backend_tag);
|
||||||
|
void
|
||||||
|
fu_device_remove_backend_tag(FuDevice *self, const gchar *backend_tag);
|
||||||
gboolean
|
gboolean
|
||||||
fu_device_has_backend_tag(FuDevice *self, const gchar *backend_tag);
|
fu_device_has_backend_tag(FuDevice *self, const gchar *backend_tag);
|
||||||
GPtrArray *
|
GPtrArray *
|
||||||
|
@ -1217,6 +1217,8 @@ fu_device_func(void)
|
|||||||
g_assert_cmpint(fu_device_get_backend_tags(device)->len, ==, 2);
|
g_assert_cmpint(fu_device_get_backend_tags(device)->len, ==, 2);
|
||||||
g_assert_true(fu_device_has_backend_tag(device, "foo"));
|
g_assert_true(fu_device_has_backend_tag(device, "foo"));
|
||||||
g_assert_false(fu_device_has_backend_tag(device, "bazbazbazbazbaz"));
|
g_assert_false(fu_device_has_backend_tag(device, "bazbazbazbazbaz"));
|
||||||
|
fu_device_remove_backend_tag(device, "foo");
|
||||||
|
g_assert_false(fu_device_has_backend_tag(device, "foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -86,15 +86,23 @@ fu_usb_device_finalize(GObject *object)
|
|||||||
G_OBJECT_CLASS(fu_usb_device_parent_class)->finalize(object);
|
G_OBJECT_CLASS(fu_usb_device_parent_class)->finalize(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if G_USB_CHECK_VERSION(0, 4, 1)
|
#if G_USB_CHECK_VERSION(0, 4, 4)
|
||||||
static void
|
static void
|
||||||
fu_usb_device_backend_tags_notify_cb(GObject *object, GParamSpec *pspec, FuUsbDevice *device)
|
fu_usb_device_backend_tags_notify_cb(GObject *object, GParamSpec *pspec, FuUsbDevice *device)
|
||||||
{
|
{
|
||||||
FuUsbDevicePrivate *priv = GET_PRIVATE(device);
|
FuUsbDevicePrivate *priv = GET_PRIVATE(device);
|
||||||
GPtrArray *backend_tags = fu_device_get_backend_tags(FU_DEVICE(device));
|
GPtrArray *backend_tags = fu_device_get_backend_tags(FU_DEVICE(device));
|
||||||
|
g_autoptr(GPtrArray) usb_device_tags = g_usb_device_get_tags(priv->usb_device);
|
||||||
|
|
||||||
|
for (guint i = 0; i < usb_device_tags->len; i++) {
|
||||||
|
const gchar *tag = g_ptr_array_index(usb_device_tags, i);
|
||||||
|
if (!fu_device_has_backend_tag(FU_DEVICE(device), tag))
|
||||||
|
g_usb_device_remove_tag(priv->usb_device, tag);
|
||||||
|
}
|
||||||
for (guint i = 0; i < backend_tags->len; i++) {
|
for (guint i = 0; i < backend_tags->len; i++) {
|
||||||
const gchar *backend_tag = g_ptr_array_index(backend_tags, i);
|
const gchar *tag = g_ptr_array_index(backend_tags, i);
|
||||||
g_usb_device_add_tag(priv->usb_device, backend_tag);
|
if (!g_usb_device_has_tag(priv->usb_device, tag))
|
||||||
|
g_usb_device_add_tag(priv->usb_device, tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -116,7 +124,7 @@ fu_usb_device_init(FuUsbDevice *device)
|
|||||||
NULL);
|
NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if G_USB_CHECK_VERSION(0, 4, 1)
|
#if G_USB_CHECK_VERSION(0, 4, 4)
|
||||||
/* copy this to the GUsbDevice */
|
/* copy this to the GUsbDevice */
|
||||||
g_signal_connect(FU_DEVICE(device),
|
g_signal_connect(FU_DEVICE(device),
|
||||||
"notify::backend-tags",
|
"notify::backend-tags",
|
||||||
|
@ -1162,3 +1162,9 @@ LIBFWUPDPLUGIN_1.8.10 {
|
|||||||
fu_pefile_firmware_new;
|
fu_pefile_firmware_new;
|
||||||
local: *;
|
local: *;
|
||||||
} LIBFWUPDPLUGIN_1.8.9;
|
} LIBFWUPDPLUGIN_1.8.9;
|
||||||
|
|
||||||
|
LIBFWUPDPLUGIN_1.8.11 {
|
||||||
|
global:
|
||||||
|
fu_device_remove_backend_tag;
|
||||||
|
local: *;
|
||||||
|
} LIBFWUPDPLUGIN_1.8.10;
|
||||||
|
Loading…
Reference in New Issue
Block a user