mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-07 12:25:38 +00:00
Add fwupd_device_has_checksum() for future usage
This commit is contained in:
parent
a12a5053b6
commit
48557a428e
@ -113,6 +113,33 @@ fwupd_device_get_checksums(FwupdDevice *self)
|
|||||||
return priv->checksums;
|
return priv->checksums;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fwupd_device_has_checksum:
|
||||||
|
* @self: a #FwupdDevice
|
||||||
|
* @checksum: (not nullable): the device checksum
|
||||||
|
*
|
||||||
|
* Finds out if the device has this specific checksum.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the checksum name is found
|
||||||
|
*
|
||||||
|
* Since: 1.8.7
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
fwupd_device_has_checksum(FwupdDevice *self, const gchar *checksum)
|
||||||
|
{
|
||||||
|
FwupdDevicePrivate *priv = GET_PRIVATE(self);
|
||||||
|
|
||||||
|
g_return_val_if_fail(FWUPD_IS_DEVICE(self), FALSE);
|
||||||
|
g_return_val_if_fail(checksum != NULL, FALSE);
|
||||||
|
|
||||||
|
for (guint i = 0; i < priv->checksums->len; i++) {
|
||||||
|
const gchar *checksum_tmp = g_ptr_array_index(priv->checksums, i);
|
||||||
|
if (g_strcmp0(checksum, checksum_tmp) == 0)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fwupd_device_add_checksum:
|
* fwupd_device_add_checksum:
|
||||||
* @self: a #FwupdDevice
|
* @self: a #FwupdDevice
|
||||||
@ -128,11 +155,9 @@ fwupd_device_add_checksum(FwupdDevice *self, const gchar *checksum)
|
|||||||
FwupdDevicePrivate *priv = GET_PRIVATE(self);
|
FwupdDevicePrivate *priv = GET_PRIVATE(self);
|
||||||
g_return_if_fail(FWUPD_IS_DEVICE(self));
|
g_return_if_fail(FWUPD_IS_DEVICE(self));
|
||||||
g_return_if_fail(checksum != NULL);
|
g_return_if_fail(checksum != NULL);
|
||||||
for (guint i = 0; i < priv->checksums->len; i++) {
|
|
||||||
const gchar *checksum_tmp = g_ptr_array_index(priv->checksums, i);
|
if (fwupd_device_has_checksum(self, checksum))
|
||||||
if (g_strcmp0(checksum_tmp, checksum) == 0)
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
g_ptr_array_add(priv->checksums, g_strdup(checksum));
|
g_ptr_array_add(priv->checksums, g_strdup(checksum));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +157,8 @@ GPtrArray *
|
|||||||
fwupd_device_get_checksums(FwupdDevice *self);
|
fwupd_device_get_checksums(FwupdDevice *self);
|
||||||
void
|
void
|
||||||
fwupd_device_add_checksum(FwupdDevice *self, const gchar *checksum);
|
fwupd_device_add_checksum(FwupdDevice *self, const gchar *checksum);
|
||||||
|
gboolean
|
||||||
|
fwupd_device_has_checksum(FwupdDevice *self, const gchar *checksum);
|
||||||
const gchar *
|
const gchar *
|
||||||
fwupd_device_get_plugin(FwupdDevice *self);
|
fwupd_device_get_plugin(FwupdDevice *self);
|
||||||
void
|
void
|
||||||
|
@ -861,3 +861,9 @@ LIBFWUPD_1.8.6 {
|
|||||||
fwupd_request_set_flags;
|
fwupd_request_set_flags;
|
||||||
local: *;
|
local: *;
|
||||||
} LIBFWUPD_1.8.4;
|
} LIBFWUPD_1.8.4;
|
||||||
|
|
||||||
|
LIBFWUPD_1.8.7 {
|
||||||
|
global:
|
||||||
|
fwupd_device_has_checksum;
|
||||||
|
local: *;
|
||||||
|
} LIBFWUPD_1.8.6;
|
||||||
|
@ -142,6 +142,7 @@ fu_device_new(FuContext *ctx);
|
|||||||
#define fu_device_has_instance_id(d, v) fwupd_device_has_instance_id(FWUPD_DEVICE(d), v)
|
#define fu_device_has_instance_id(d, v) fwupd_device_has_instance_id(FWUPD_DEVICE(d), v)
|
||||||
#define fu_device_has_vendor_id(d, v) fwupd_device_has_vendor_id(FWUPD_DEVICE(d), v)
|
#define fu_device_has_vendor_id(d, v) fwupd_device_has_vendor_id(FWUPD_DEVICE(d), v)
|
||||||
#define fu_device_has_protocol(d, v) fwupd_device_has_protocol(FWUPD_DEVICE(d), v)
|
#define fu_device_has_protocol(d, v) fwupd_device_has_protocol(FWUPD_DEVICE(d), v)
|
||||||
|
#define fu_device_has_checksum(d, v) fwupd_device_has_checksum(FWUPD_DEVICE(d), v)
|
||||||
#define fu_device_add_checksum(d, v) fwupd_device_add_checksum(FWUPD_DEVICE(d), v)
|
#define fu_device_add_checksum(d, v) fwupd_device_add_checksum(FWUPD_DEVICE(d), v)
|
||||||
#define fu_device_add_release(d, v) fwupd_device_add_release(FWUPD_DEVICE(d), v)
|
#define fu_device_add_release(d, v) fwupd_device_add_release(FWUPD_DEVICE(d), v)
|
||||||
#define fu_device_add_icon(d, v) fwupd_device_add_icon(FWUPD_DEVICE(d), v)
|
#define fu_device_add_icon(d, v) fwupd_device_add_icon(FWUPD_DEVICE(d), v)
|
||||||
|
Loading…
Reference in New Issue
Block a user