mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-07 12:25:38 +00:00
trivial: Add fu_device_has_custom_flag()
This splits the custom flags and checks if one of them exists.
This commit is contained in:
parent
63b173046d
commit
ac11be65f3
@ -721,6 +721,37 @@ fu_device_get_custom_flags (FuDevice *device)
|
|||||||
return fu_device_get_metadata (device, "CustomFlags");
|
return fu_device_get_metadata (device, "CustomFlags");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fu_device_has_custom_flag:
|
||||||
|
* @device: A #FuDevice
|
||||||
|
* @hint: A string, e.g. "bootloader"
|
||||||
|
*
|
||||||
|
* Checks if the custom flag exists for the device from the quirk system.
|
||||||
|
*
|
||||||
|
* It may be more efficient to call fu_device_get_custom_flags() and split the
|
||||||
|
* string locally if checking for lots of different flags.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the hint exists
|
||||||
|
*
|
||||||
|
* Since: 1.1.0
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
fu_device_has_custom_flag (FuDevice *device, const gchar *hint)
|
||||||
|
{
|
||||||
|
const gchar *hint_str;
|
||||||
|
g_auto(GStrv) hints = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (FU_IS_DEVICE (device), FALSE);
|
||||||
|
g_return_val_if_fail (hint != NULL, FALSE);
|
||||||
|
|
||||||
|
/* no hint is perfectly valid */
|
||||||
|
hint_str = fu_device_get_custom_flags (device);
|
||||||
|
if (hint_str == NULL)
|
||||||
|
return FALSE;
|
||||||
|
hints = g_strsplit (hint_str, ",", -1);
|
||||||
|
return g_strv_contains ((const gchar * const *) hints, hint);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fu_device_set_platform_id:
|
* fu_device_set_platform_id:
|
||||||
* @device: A #FuDevice
|
* @device: A #FuDevice
|
||||||
|
@ -138,6 +138,8 @@ const gchar *fu_device_get_serial (FuDevice *device);
|
|||||||
void fu_device_set_serial (FuDevice *device,
|
void fu_device_set_serial (FuDevice *device,
|
||||||
const gchar *serial);
|
const gchar *serial);
|
||||||
const gchar *fu_device_get_custom_flags (FuDevice *device);
|
const gchar *fu_device_get_custom_flags (FuDevice *device);
|
||||||
|
gboolean fu_device_has_custom_flag (FuDevice *device,
|
||||||
|
const gchar *hint);
|
||||||
void fu_device_set_custom_flags (FuDevice *device,
|
void fu_device_set_custom_flags (FuDevice *device,
|
||||||
const gchar *custom_flags);
|
const gchar *custom_flags);
|
||||||
void fu_device_set_name (FuDevice *device,
|
void fu_device_set_name (FuDevice *device,
|
||||||
|
Loading…
Reference in New Issue
Block a user