mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-08 14:36:33 +00:00
Allow devices to have multiple assigned GUIDs
This commit is contained in:
parent
069392c82c
commit
99147f180b
@ -37,7 +37,7 @@ static void fwupd_result_finalize (GObject *object);
|
|||||||
* Private #FwupdResult data
|
* Private #FwupdResult data
|
||||||
**/
|
**/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *guid;
|
GPtrArray *guids;
|
||||||
|
|
||||||
/* device-specific */
|
/* device-specific */
|
||||||
gchar *device_checksum;
|
gchar *device_checksum;
|
||||||
@ -122,6 +122,90 @@ fwupd_result_set_device_id (FwupdResult *result, const gchar *device_id)
|
|||||||
priv->device_id = g_strdup (device_id);
|
priv->device_id = g_strdup (device_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fwupd_result_get_guids:
|
||||||
|
* @result: A #FwupdResult
|
||||||
|
*
|
||||||
|
* Gets the GUIDs.
|
||||||
|
*
|
||||||
|
* Returns: (element-type utf8) (transfer none): the GUIDs
|
||||||
|
*
|
||||||
|
* Since: 0.7.2
|
||||||
|
**/
|
||||||
|
GPtrArray *
|
||||||
|
fwupd_result_get_guids (FwupdResult *result)
|
||||||
|
{
|
||||||
|
FwupdResultPrivate *priv = GET_PRIVATE (result);
|
||||||
|
g_return_val_if_fail (FWUPD_IS_RESULT (result), NULL);
|
||||||
|
return priv->guids;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fwupd_result_has_guid:
|
||||||
|
* @result: A #FwupdResult
|
||||||
|
* @guid: the GUID, e.g. "2082b5e0-7a64-478a-b1b2-e3404fab6dad"
|
||||||
|
*
|
||||||
|
* Finds out if the device has this specific GUID.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the GUID is found
|
||||||
|
*
|
||||||
|
* Since: 0.7.2
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
fwupd_result_has_guid (FwupdResult *result, const gchar *guid)
|
||||||
|
{
|
||||||
|
FwupdResultPrivate *priv = GET_PRIVATE (result);
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
g_return_val_if_fail (FWUPD_IS_RESULT (result), FALSE);
|
||||||
|
|
||||||
|
for (i = 0; i < priv->guids->len; i++) {
|
||||||
|
const gchar *guid_tmp = g_ptr_array_index (priv->guids, i);
|
||||||
|
if (g_strcmp0 (guid, guid_tmp) == 0)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fwupd_result_add_guid:
|
||||||
|
* @result: A #FwupdResult
|
||||||
|
* @guid: the GUID, e.g. "2082b5e0-7a64-478a-b1b2-e3404fab6dad"
|
||||||
|
*
|
||||||
|
* Adds the GUID if it does not already exist.
|
||||||
|
*
|
||||||
|
* Since: 0.7.2
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
fwupd_result_add_guid (FwupdResult *result, const gchar *guid)
|
||||||
|
{
|
||||||
|
FwupdResultPrivate *priv = GET_PRIVATE (result);
|
||||||
|
g_return_if_fail (FWUPD_IS_RESULT (result));
|
||||||
|
if (fwupd_result_has_guid (result, guid))
|
||||||
|
return;
|
||||||
|
g_ptr_array_add (priv->guids, g_strdup (guid));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fwupd_result_get_guid_default:
|
||||||
|
* @result: A #FwupdResult
|
||||||
|
*
|
||||||
|
* Gets the default GUID.
|
||||||
|
*
|
||||||
|
* Returns: the GUID, or %NULL if unset
|
||||||
|
*
|
||||||
|
* Since: 0.7.2
|
||||||
|
**/
|
||||||
|
const gchar *
|
||||||
|
fwupd_result_get_guid_default (FwupdResult *result)
|
||||||
|
{
|
||||||
|
FwupdResultPrivate *priv = GET_PRIVATE (result);
|
||||||
|
g_return_val_if_fail (FWUPD_IS_RESULT (result), NULL);
|
||||||
|
if (priv->guids->len == 0)
|
||||||
|
return NULL;
|
||||||
|
return g_ptr_array_index (priv->guids, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fwupd_result_get_guid:
|
* fwupd_result_get_guid:
|
||||||
* @result: A #FwupdResult
|
* @result: A #FwupdResult
|
||||||
@ -130,14 +214,14 @@ fwupd_result_set_device_id (FwupdResult *result, const gchar *device_id)
|
|||||||
*
|
*
|
||||||
* Returns: the GUID, or %NULL if unset
|
* Returns: the GUID, or %NULL if unset
|
||||||
*
|
*
|
||||||
|
* This function has been deprecated since 0.7.2.
|
||||||
|
*
|
||||||
* Since: 0.7.0
|
* Since: 0.7.0
|
||||||
**/
|
**/
|
||||||
const gchar *
|
const gchar *
|
||||||
fwupd_result_get_guid (FwupdResult *result)
|
fwupd_result_get_guid (FwupdResult *result)
|
||||||
{
|
{
|
||||||
FwupdResultPrivate *priv = GET_PRIVATE (result);
|
return fwupd_result_get_guid_default (result);
|
||||||
g_return_val_if_fail (FWUPD_IS_RESULT (result), NULL);
|
|
||||||
return priv->guid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,15 +231,14 @@ fwupd_result_get_guid (FwupdResult *result)
|
|||||||
*
|
*
|
||||||
* Sets the GUID.
|
* Sets the GUID.
|
||||||
*
|
*
|
||||||
|
* This function has been deprecated since 0.7.2.
|
||||||
|
*
|
||||||
* Since: 0.7.0
|
* Since: 0.7.0
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
fwupd_result_set_guid (FwupdResult *result, const gchar *guid)
|
fwupd_result_set_guid (FwupdResult *result, const gchar *guid)
|
||||||
{
|
{
|
||||||
FwupdResultPrivate *priv = GET_PRIVATE (result);
|
fwupd_result_add_guid (result, guid);
|
||||||
g_return_if_fail (FWUPD_IS_RESULT (result));
|
|
||||||
g_free (priv->guid);
|
|
||||||
priv->guid = g_strdup (guid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1216,10 +1299,18 @@ fwupd_result_to_data (FwupdResult *result, const gchar *type_string)
|
|||||||
|
|
||||||
/* create an array with all the metadata in */
|
/* create an array with all the metadata in */
|
||||||
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
|
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
|
||||||
if (priv->guid != NULL) {
|
if (priv->guids->len > 0) {
|
||||||
|
guint i;
|
||||||
|
g_autoptr(GString) str = g_string_new ("");
|
||||||
|
for (i = 0; i < priv->guids->len; i++) {
|
||||||
|
const gchar *guid = g_ptr_array_index (priv->guids, i);
|
||||||
|
g_string_append_printf (str, "%s,", guid);
|
||||||
|
}
|
||||||
|
if (str->len > 0)
|
||||||
|
g_string_truncate (str, str->len - 1);
|
||||||
g_variant_builder_add (&builder, "{sv}",
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
FWUPD_RESULT_KEY_GUID,
|
FWUPD_RESULT_KEY_GUID,
|
||||||
g_variant_new_string (priv->guid));
|
g_variant_new_string (str->str));
|
||||||
}
|
}
|
||||||
if (priv->device_name != NULL) {
|
if (priv->device_name != NULL) {
|
||||||
g_variant_builder_add (&builder, "{sv}",
|
g_variant_builder_add (&builder, "{sv}",
|
||||||
@ -1386,7 +1477,11 @@ fwupd_result_from_kv (FwupdResult *result, const gchar *key, GVariant *value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (g_strcmp0 (key, FWUPD_RESULT_KEY_GUID) == 0) {
|
if (g_strcmp0 (key, FWUPD_RESULT_KEY_GUID) == 0) {
|
||||||
fwupd_result_set_guid (result, g_variant_get_string (value, NULL));
|
guint i;
|
||||||
|
const gchar *guids = g_variant_get_string (value, NULL);
|
||||||
|
g_auto(GStrv) split = g_strsplit (guids, ",", -1);
|
||||||
|
for (i = 0; split[i] != NULL; i++)
|
||||||
|
fwupd_result_add_guid (result, split[i]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (g_strcmp0 (key, FWUPD_RESULT_KEY_DEVICE_NAME) == 0) {
|
if (g_strcmp0 (key, FWUPD_RESULT_KEY_DEVICE_NAME) == 0) {
|
||||||
@ -1653,6 +1748,7 @@ fwupd_result_to_string (FwupdResult *result)
|
|||||||
{
|
{
|
||||||
FwupdResultPrivate *priv = GET_PRIVATE (result);
|
FwupdResultPrivate *priv = GET_PRIVATE (result);
|
||||||
GString *str;
|
GString *str;
|
||||||
|
guint i;
|
||||||
|
|
||||||
g_return_val_if_fail (FWUPD_IS_RESULT (result), NULL);
|
g_return_val_if_fail (FWUPD_IS_RESULT (result), NULL);
|
||||||
|
|
||||||
@ -1665,7 +1761,10 @@ fwupd_result_to_string (FwupdResult *result)
|
|||||||
g_string_append_printf (str, "%s\n", "Unknown Device");
|
g_string_append_printf (str, "%s\n", "Unknown Device");
|
||||||
|
|
||||||
/* device */
|
/* device */
|
||||||
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_GUID, priv->guid);
|
for (i = 0; i < priv->guids->len; i++) {
|
||||||
|
const gchar *guid = g_ptr_array_index (priv->guids, i);
|
||||||
|
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_GUID, guid);
|
||||||
|
}
|
||||||
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_DEVICE_ID, priv->device_id);
|
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_DEVICE_ID, priv->device_id);
|
||||||
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_DEVICE_DESCRIPTION, priv->device_description);
|
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_DEVICE_DESCRIPTION, priv->device_description);
|
||||||
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_DEVICE_PROVIDER, priv->device_provider);
|
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_DEVICE_PROVIDER, priv->device_provider);
|
||||||
@ -1778,6 +1877,7 @@ fwupd_result_init (FwupdResult *result)
|
|||||||
FwupdResultPrivate *priv = GET_PRIVATE (result);
|
FwupdResultPrivate *priv = GET_PRIVATE (result);
|
||||||
priv->device_checksum_kind = G_CHECKSUM_SHA1;
|
priv->device_checksum_kind = G_CHECKSUM_SHA1;
|
||||||
priv->update_checksum_kind = G_CHECKSUM_SHA1;
|
priv->update_checksum_kind = G_CHECKSUM_SHA1;
|
||||||
|
priv->guids = g_ptr_array_new_with_free_func (g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1789,6 +1889,7 @@ fwupd_result_finalize (GObject *object)
|
|||||||
FwupdResult *result = FWUPD_RESULT (object);
|
FwupdResult *result = FWUPD_RESULT (object);
|
||||||
FwupdResultPrivate *priv = GET_PRIVATE (result);
|
FwupdResultPrivate *priv = GET_PRIVATE (result);
|
||||||
|
|
||||||
|
g_ptr_array_unref (priv->guids);
|
||||||
g_free (priv->device_description);
|
g_free (priv->device_description);
|
||||||
g_free (priv->device_checksum);
|
g_free (priv->device_checksum);
|
||||||
g_free (priv->device_id);
|
g_free (priv->device_id);
|
||||||
@ -1797,7 +1898,6 @@ fwupd_result_finalize (GObject *object)
|
|||||||
g_free (priv->device_provider);
|
g_free (priv->device_provider);
|
||||||
g_free (priv->device_version);
|
g_free (priv->device_version);
|
||||||
g_free (priv->device_version_lowest);
|
g_free (priv->device_version_lowest);
|
||||||
g_free (priv->guid);
|
|
||||||
g_free (priv->update_description);
|
g_free (priv->update_description);
|
||||||
g_free (priv->update_error);
|
g_free (priv->update_error);
|
||||||
g_free (priv->update_filename);
|
g_free (priv->update_filename);
|
||||||
|
@ -47,10 +47,15 @@ struct _FwupdResultClass
|
|||||||
FwupdResult *fwupd_result_new (void);
|
FwupdResult *fwupd_result_new (void);
|
||||||
FwupdResult *fwupd_result_new_from_data (GVariant *data);
|
FwupdResult *fwupd_result_new_from_data (GVariant *data);
|
||||||
|
|
||||||
/* device-specific */
|
/* matches */
|
||||||
const gchar *fwupd_result_get_guid (FwupdResult *result);
|
void fwupd_result_add_guid (FwupdResult *result,
|
||||||
void fwupd_result_set_guid (FwupdResult *result,
|
|
||||||
const gchar *guid);
|
const gchar *guid);
|
||||||
|
gboolean fwupd_result_has_guid (FwupdResult *result,
|
||||||
|
const gchar *guid);
|
||||||
|
GPtrArray *fwupd_result_get_guids (FwupdResult *result);
|
||||||
|
const gchar *fwupd_result_get_guid_default (FwupdResult *result);
|
||||||
|
|
||||||
|
/* device-specific */
|
||||||
const gchar *fwupd_result_get_device_id (FwupdResult *result);
|
const gchar *fwupd_result_get_device_id (FwupdResult *result);
|
||||||
void fwupd_result_set_device_id (FwupdResult *result,
|
void fwupd_result_set_device_id (FwupdResult *result,
|
||||||
const gchar *device_id);
|
const gchar *device_id);
|
||||||
@ -150,6 +155,13 @@ GVariant *fwupd_result_to_data (FwupdResult *result,
|
|||||||
const gchar *type_string);
|
const gchar *type_string);
|
||||||
gchar *fwupd_result_to_string (FwupdResult *result);
|
gchar *fwupd_result_to_string (FwupdResult *result);
|
||||||
|
|
||||||
|
/* deprecated */
|
||||||
|
G_DEPRECATED_FOR(fwupd_result_get_guids)
|
||||||
|
const gchar *fwupd_result_get_guid (FwupdResult *result);
|
||||||
|
G_DEPRECATED_FOR(fwupd_result_add_guid)
|
||||||
|
void fwupd_result_set_guid (FwupdResult *result,
|
||||||
|
const gchar *guid);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __FWUPD_RESULT_H */
|
#endif /* __FWUPD_RESULT_H */
|
||||||
|
@ -112,7 +112,8 @@ fwupd_result_func (void)
|
|||||||
fwupd_result_set_device_id (result, "USB:foo");
|
fwupd_result_set_device_id (result, "USB:foo");
|
||||||
fwupd_result_set_device_modified (result, 60 * 60 * 24);
|
fwupd_result_set_device_modified (result, 60 * 60 * 24);
|
||||||
fwupd_result_set_device_name (result, "ColorHug2");
|
fwupd_result_set_device_name (result, "ColorHug2");
|
||||||
fwupd_result_set_guid (result, "2082b5e0-7a64-478a-b1b2-e3404fab6dad");
|
fwupd_result_add_guid (result, "2082b5e0-7a64-478a-b1b2-e3404fab6dad");
|
||||||
|
fwupd_result_add_guid (result, "00000000-0000-0000-0000-000000000000");
|
||||||
fwupd_result_set_update_checksum (result, "deadbeef");
|
fwupd_result_set_update_checksum (result, "deadbeef");
|
||||||
fwupd_result_set_update_description (result, "<p>Hi there!</p>");
|
fwupd_result_set_update_description (result, "<p>Hi there!</p>");
|
||||||
fwupd_result_set_update_filename (result, "firmware.bin");
|
fwupd_result_set_update_filename (result, "firmware.bin");
|
||||||
@ -125,9 +126,15 @@ fwupd_result_func (void)
|
|||||||
str = fwupd_result_to_string (result);
|
str = fwupd_result_to_string (result);
|
||||||
g_print ("\n%s", str);
|
g_print ("\n%s", str);
|
||||||
|
|
||||||
|
/* check GUIDs */
|
||||||
|
g_assert (fwupd_result_has_guid (result, "2082b5e0-7a64-478a-b1b2-e3404fab6dad"));
|
||||||
|
g_assert (fwupd_result_has_guid (result, "00000000-0000-0000-0000-000000000000"));
|
||||||
|
g_assert (!fwupd_result_has_guid (result, "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"));
|
||||||
|
|
||||||
ret = as_test_compare_lines (str,
|
ret = as_test_compare_lines (str,
|
||||||
"ColorHug2\n"
|
"ColorHug2\n"
|
||||||
" Guid: 2082b5e0-7a64-478a-b1b2-e3404fab6dad\n"
|
" Guid: 2082b5e0-7a64-478a-b1b2-e3404fab6dad\n"
|
||||||
|
" Guid: 00000000-0000-0000-0000-000000000000\n"
|
||||||
" DeviceID: USB:foo\n"
|
" DeviceID: USB:foo\n"
|
||||||
" Flags: allow-offline|require-ac\n"
|
" Flags: allow-offline|require-ac\n"
|
||||||
" FirmwareHash: beefdead\n"
|
" FirmwareHash: beefdead\n"
|
||||||
@ -167,7 +174,7 @@ fwupd_client_devices_func (void)
|
|||||||
/* check device */
|
/* check device */
|
||||||
res = g_ptr_array_index (array, 0);
|
res = g_ptr_array_index (array, 0);
|
||||||
g_assert (FWUPD_IS_RESULT (res));
|
g_assert (FWUPD_IS_RESULT (res));
|
||||||
g_assert_cmpstr (fwupd_result_get_guid (res), !=, NULL);
|
g_assert_cmpstr (fwupd_result_get_guid_default (res), !=, NULL);
|
||||||
g_assert_cmpstr (fwupd_result_get_device_id (res), !=, NULL);
|
g_assert_cmpstr (fwupd_result_get_device_id (res), !=, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +198,7 @@ fwupd_client_updates_func (void)
|
|||||||
/* check device */
|
/* check device */
|
||||||
res = g_ptr_array_index (array, 0);
|
res = g_ptr_array_index (array, 0);
|
||||||
g_assert (FWUPD_IS_RESULT (res));
|
g_assert (FWUPD_IS_RESULT (res));
|
||||||
g_assert_cmpstr (fwupd_result_get_guid (res), !=, NULL);
|
g_assert_cmpstr (fwupd_result_get_guid_default (res), !=, NULL);
|
||||||
g_assert_cmpstr (fwupd_result_get_device_id (res), !=, NULL);
|
g_assert_cmpstr (fwupd_result_get_device_id (res), !=, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,8 @@ FuDevice *fu_device_new (void);
|
|||||||
#define fu_device_set_created(d,v) fwupd_result_set_device_created(FWUPD_RESULT(d),v)
|
#define fu_device_set_created(d,v) fwupd_result_set_device_created(FWUPD_RESULT(d),v)
|
||||||
#define fu_device_set_description(d,v) fwupd_result_set_device_description(FWUPD_RESULT(d),v)
|
#define fu_device_set_description(d,v) fwupd_result_set_device_description(FWUPD_RESULT(d),v)
|
||||||
#define fu_device_set_flags(d,v) fwupd_result_set_device_flags(FWUPD_RESULT(d),v)
|
#define fu_device_set_flags(d,v) fwupd_result_set_device_flags(FWUPD_RESULT(d),v)
|
||||||
#define fu_device_set_guid(d,v) fwupd_result_set_guid(FWUPD_RESULT(d),v)
|
#define fu_device_add_guid(d,v) fwupd_result_add_guid(FWUPD_RESULT(d),v)
|
||||||
|
#define fu_device_has_guid(d,v) fwupd_result_has_guid(FWUPD_RESULT(d),v)
|
||||||
#define fu_device_set_id(d,v) fwupd_result_set_device_id(FWUPD_RESULT(d),v)
|
#define fu_device_set_id(d,v) fwupd_result_set_device_id(FWUPD_RESULT(d),v)
|
||||||
#define fu_device_set_modified(d,v) fwupd_result_set_device_modified(FWUPD_RESULT(d),v)
|
#define fu_device_set_modified(d,v) fwupd_result_set_device_modified(FWUPD_RESULT(d),v)
|
||||||
#define fu_device_set_provider(d,v) fwupd_result_set_device_provider(FWUPD_RESULT(d),v)
|
#define fu_device_set_provider(d,v) fwupd_result_set_device_provider(FWUPD_RESULT(d),v)
|
||||||
@ -73,7 +74,8 @@ FuDevice *fu_device_new (void);
|
|||||||
/* compat getters */
|
/* compat getters */
|
||||||
#define fu_device_get_checksum(d) fwupd_result_get_device_checksum(FWUPD_RESULT(d))
|
#define fu_device_get_checksum(d) fwupd_result_get_device_checksum(FWUPD_RESULT(d))
|
||||||
#define fu_device_get_flags(d) fwupd_result_get_device_flags(FWUPD_RESULT(d))
|
#define fu_device_get_flags(d) fwupd_result_get_device_flags(FWUPD_RESULT(d))
|
||||||
#define fu_device_get_guid(d) fwupd_result_get_guid(FWUPD_RESULT(d))
|
#define fu_device_get_guids(d) fwupd_result_get_guids(FWUPD_RESULT(d))
|
||||||
|
#define fu_device_get_guid_default(d) fwupd_result_get_guid_default(FWUPD_RESULT(d))
|
||||||
#define fu_device_get_name(d) fwupd_result_get_device_name(FWUPD_RESULT(d))
|
#define fu_device_get_name(d) fwupd_result_get_device_name(FWUPD_RESULT(d))
|
||||||
#define fu_device_get_id(d) fwupd_result_get_device_id(FWUPD_RESULT(d))
|
#define fu_device_get_id(d) fwupd_result_get_device_id(FWUPD_RESULT(d))
|
||||||
#define fu_device_get_provider(d) fwupd_result_get_device_provider(FWUPD_RESULT(d))
|
#define fu_device_get_provider(d) fwupd_result_get_device_provider(FWUPD_RESULT(d))
|
||||||
|
@ -357,7 +357,7 @@ fu_main_get_item_by_guid (FuMainPrivate *priv, const gchar *guid)
|
|||||||
|
|
||||||
for (i = 0; i < priv->devices->len; i++) {
|
for (i = 0; i < priv->devices->len; i++) {
|
||||||
item = g_ptr_array_index (priv->devices, i);
|
item = g_ptr_array_index (priv->devices, i);
|
||||||
if (g_strcmp0 (fu_device_get_guid (item->device), guid) == 0)
|
if (fu_device_has_guid (item->device, guid))
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -727,6 +727,27 @@ fu_main_vendor_quirk_release_version (AsApp *app)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fu_main_store_get_app_by_guids:
|
||||||
|
**/
|
||||||
|
static AsApp *
|
||||||
|
fu_main_store_get_app_by_guids (AsStore *store, FuDevice *device)
|
||||||
|
{
|
||||||
|
GPtrArray *guids;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
guids = fu_device_get_guids (device);
|
||||||
|
for (i = 0; i < guids->len; i++) {
|
||||||
|
AsApp *app = NULL;
|
||||||
|
app = as_store_get_app_by_provide (store,
|
||||||
|
AS_PROVIDE_KIND_FIRMWARE_FLASHED,
|
||||||
|
g_ptr_array_index (guids, i));
|
||||||
|
if (app != NULL)
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fu_main_update_helper:
|
* fu_main_update_helper:
|
||||||
**/
|
**/
|
||||||
@ -751,9 +772,7 @@ fu_main_update_helper (FuMainAuthHelper *helper, GError **error)
|
|||||||
for (i = 0; i < helper->priv->devices->len; i++) {
|
for (i = 0; i < helper->priv->devices->len; i++) {
|
||||||
FuDeviceItem *item;
|
FuDeviceItem *item;
|
||||||
item = g_ptr_array_index (helper->priv->devices, i);
|
item = g_ptr_array_index (helper->priv->devices, i);
|
||||||
app = as_store_get_app_by_provide (helper->store,
|
app = fu_main_store_get_app_by_guids (helper->store, item->device);
|
||||||
AS_PROVIDE_KIND_FIRMWARE_FLASHED,
|
|
||||||
fu_device_get_guid (item->device));
|
|
||||||
if (app != NULL) {
|
if (app != NULL) {
|
||||||
helper->device = g_object_ref (item->device);
|
helper->device = g_object_ref (item->device);
|
||||||
break;
|
break;
|
||||||
@ -774,9 +793,7 @@ fu_main_update_helper (FuMainAuthHelper *helper, GError **error)
|
|||||||
} else {
|
} else {
|
||||||
/* find an application from the cabinet 'store' for the
|
/* find an application from the cabinet 'store' for the
|
||||||
* chosen device */
|
* chosen device */
|
||||||
app = as_store_get_app_by_provide (helper->store,
|
app = fu_main_store_get_app_by_guids (helper->store, helper->device);
|
||||||
AS_PROVIDE_KIND_FIRMWARE_FLASHED,
|
|
||||||
fu_device_get_guid (helper->device));
|
|
||||||
if (app == NULL) {
|
if (app == NULL) {
|
||||||
g_autofree gchar *guid = NULL;
|
g_autofree gchar *guid = NULL;
|
||||||
guid = fu_main_get_guids_from_store (helper->store);
|
guid = fu_main_get_guids_from_store (helper->store);
|
||||||
@ -784,7 +801,7 @@ fu_main_update_helper (FuMainAuthHelper *helper, GError **error)
|
|||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_INVALID_FILE,
|
FWUPD_ERROR_INVALID_FILE,
|
||||||
"firmware is not for this hw: required %s got %s",
|
"firmware is not for this hw: required %s got %s",
|
||||||
fu_device_get_guid (helper->device), guid);
|
fu_device_get_guid_default (helper->device), guid);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1164,10 +1181,8 @@ fu_main_get_updates_item_update (FuMainPrivate *priv, FuDeviceItem *item)
|
|||||||
if (version == NULL)
|
if (version == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* match the GUID in the XML */
|
/* match the GUIDs in the XML */
|
||||||
app = as_store_get_app_by_provide (priv->store,
|
app = fu_main_store_get_app_by_guids (priv->store, item->device);
|
||||||
AS_PROVIDE_KIND_FIRMWARE_FLASHED,
|
|
||||||
fu_device_get_guid (item->device));
|
|
||||||
if (app == NULL)
|
if (app == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -1521,9 +1536,7 @@ fu_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* find component in metadata */
|
/* find component in metadata */
|
||||||
app = as_store_get_app_by_provide (priv->store,
|
app = fu_main_store_get_app_by_guids (priv->store, item->device);
|
||||||
AS_PROVIDE_KIND_FIRMWARE_FLASHED,
|
|
||||||
fu_device_get_guid (item->device));
|
|
||||||
if (app == NULL) {
|
if (app == NULL) {
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (invocation,
|
||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
@ -1769,9 +1782,7 @@ fu_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
|
|||||||
* so try to find the first thing that's installed */
|
* so try to find the first thing that's installed */
|
||||||
for (i = 0; i < priv->devices->len; i++) {
|
for (i = 0; i < priv->devices->len; i++) {
|
||||||
item = g_ptr_array_index (priv->devices, i);
|
item = g_ptr_array_index (priv->devices, i);
|
||||||
app = as_store_get_app_by_provide (store,
|
app = fu_main_store_get_app_by_guids (store, item->device);
|
||||||
AS_PROVIDE_KIND_FIRMWARE_FLASHED,
|
|
||||||
fu_device_get_guid (item->device));
|
|
||||||
if (app != NULL)
|
if (app != NULL)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2092,9 +2103,7 @@ cd_main_provider_device_added_cb (FuProvider *provider,
|
|||||||
g_ptr_array_add (priv->devices, item);
|
g_ptr_array_add (priv->devices, item);
|
||||||
|
|
||||||
/* does this match anything in the AppStream data */
|
/* does this match anything in the AppStream data */
|
||||||
app = as_store_get_app_by_provide (priv->store,
|
app = fu_main_store_get_app_by_guids (priv->store, item->device);
|
||||||
AS_PROVIDE_KIND_FIRMWARE_FLASHED,
|
|
||||||
fu_device_get_guid (item->device));
|
|
||||||
if (app != NULL) {
|
if (app != NULL) {
|
||||||
const gchar *tmp;
|
const gchar *tmp;
|
||||||
tmp = as_app_get_metadata_item (app, FU_DEVICE_KEY_FWUPD_PLUGIN);
|
tmp = as_app_get_metadata_item (app, FU_DEVICE_KEY_FWUPD_PLUGIN);
|
||||||
|
@ -491,7 +491,7 @@ fu_provider_chug_device_added_cb (GUsbContext *ctx,
|
|||||||
fu_device_set_id (item->device, device_key);
|
fu_device_set_id (item->device, device_key);
|
||||||
fu_device_set_equivalent_id (item->device,
|
fu_device_set_equivalent_id (item->device,
|
||||||
g_usb_device_get_platform_id (device));
|
g_usb_device_get_platform_id (device));
|
||||||
fu_device_set_guid (item->device, ch_device_get_guid (device));
|
fu_device_add_guid (item->device, ch_device_get_guid (device));
|
||||||
fu_device_add_flag (item->device, FU_DEVICE_FLAG_ALLOW_OFFLINE);
|
fu_device_add_flag (item->device, FU_DEVICE_FLAG_ALLOW_OFFLINE);
|
||||||
fu_device_add_flag (item->device, FU_DEVICE_FLAG_ALLOW_ONLINE);
|
fu_device_add_flag (item->device, FU_DEVICE_FLAG_ALLOW_ONLINE);
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ fu_provider_dfu_device_update (FuProviderDfu *provider_dfu,
|
|||||||
dfu_device_get_runtime_pid (device));
|
dfu_device_get_runtime_pid (device));
|
||||||
guid = as_utils_guid_from_string (vid_pid);
|
guid = as_utils_guid_from_string (vid_pid);
|
||||||
g_debug ("using %s for %s", guid, vid_pid);
|
g_debug ("using %s for %s", guid, vid_pid);
|
||||||
fu_device_set_guid (dev, guid);
|
fu_device_add_guid (dev, guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,7 +71,7 @@ fu_provider_fake_coldplug (FuProvider *provider, GError **error)
|
|||||||
g_autoptr(FuDevice) device = NULL;
|
g_autoptr(FuDevice) device = NULL;
|
||||||
device = fu_device_new ();
|
device = fu_device_new ();
|
||||||
fu_device_set_id (device, "FakeDevice");
|
fu_device_set_id (device, "FakeDevice");
|
||||||
fu_device_set_guid (device, "00000000-0000-0000-0000-000000000000");
|
fu_device_add_guid (device, "00000000-0000-0000-0000-000000000000");
|
||||||
fu_device_set_name (device, "Integrated_Webcam(TM)");
|
fu_device_set_name (device, "Integrated_Webcam(TM)");
|
||||||
fu_provider_device_add (provider, device);
|
fu_provider_device_add (provider, device);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -296,7 +296,7 @@ fu_provider_rpi_coldplug (FuProvider *provider, GError **error)
|
|||||||
device = fu_device_new ();
|
device = fu_device_new ();
|
||||||
fu_device_set_id (device, "raspberry-pi");
|
fu_device_set_id (device, "raspberry-pi");
|
||||||
guid = as_utils_guid_from_string ("raspberrypi");
|
guid = as_utils_guid_from_string ("raspberrypi");
|
||||||
fu_device_set_guid (device, guid);
|
fu_device_add_guid (device, guid);
|
||||||
fu_device_set_name (device, "Raspberry Pi");
|
fu_device_set_name (device, "Raspberry Pi");
|
||||||
fu_device_add_flag (device, FU_DEVICE_FLAG_INTERNAL);
|
fu_device_add_flag (device, FU_DEVICE_FLAG_INTERNAL);
|
||||||
fu_device_add_flag (device, FU_DEVICE_FLAG_ALLOW_OFFLINE);
|
fu_device_add_flag (device, FU_DEVICE_FLAG_ALLOW_OFFLINE);
|
||||||
|
@ -102,17 +102,11 @@ fu_provider_udev_unlock (FuProvider *provider,
|
|||||||
fu_device_set_version (device, fu_rom_get_version (rom));
|
fu_device_set_version (device, fu_rom_get_version (rom));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prefer the GUID from the firmware rather than the
|
/* Also add the GUID from the firmware as the firmware may be more
|
||||||
* hardware as the firmware may be more generic, which
|
* generic, which also allows us to match the GUID when doing 'verify'
|
||||||
* also allows us to match the GUID when doing 'verify'
|
|
||||||
* on a device with a different PID to the firmware */
|
* on a device with a different PID to the firmware */
|
||||||
if (g_strcmp0 (fu_device_get_guid (device), fu_rom_get_guid (rom)) != 0) {
|
fu_device_add_guid (device, fu_rom_get_guid (rom));
|
||||||
fu_device_set_guid (device, fu_rom_get_guid (rom));
|
|
||||||
g_debug ("changing GUID of %s from %s to %s",
|
|
||||||
fu_device_get_id (device),
|
|
||||||
fu_device_get_guid (device),
|
|
||||||
fu_rom_get_guid (rom));
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +200,7 @@ fu_provider_udev_client_add (FuProviderUdev *provider_udev, GUdevDevice *device)
|
|||||||
dev = fu_device_new ();
|
dev = fu_device_new ();
|
||||||
fu_device_add_flag (dev, FU_DEVICE_FLAG_INTERNAL);
|
fu_device_add_flag (dev, FU_DEVICE_FLAG_INTERNAL);
|
||||||
fu_device_set_id (dev, id);
|
fu_device_set_id (dev, id);
|
||||||
fu_device_set_guid (dev, guid_new);
|
fu_device_add_guid (dev, guid_new);
|
||||||
display_name = g_udev_device_get_property (device, "FWUPD_MODEL");
|
display_name = g_udev_device_get_property (device, "FWUPD_MODEL");
|
||||||
if (display_name == NULL)
|
if (display_name == NULL)
|
||||||
display_name = g_udev_device_get_property (device, "ID_MODEL_FROM_DATABASE");
|
display_name = g_udev_device_get_property (device, "ID_MODEL_FROM_DATABASE");
|
||||||
|
@ -110,7 +110,7 @@ fu_provider_uefi_clear_results (FuProvider *provider, FuDevice *device, GError *
|
|||||||
|
|
||||||
/* get the hardware we're referencing */
|
/* get the hardware we're referencing */
|
||||||
fwup_resource_iter_create (&iter);
|
fwup_resource_iter_create (&iter);
|
||||||
re = fu_provider_uefi_find (iter, fu_device_get_guid (device), error);
|
re = fu_provider_uefi_find (iter, fu_device_get_guid_default (device), error);
|
||||||
if (re == NULL)
|
if (re == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (fwup_clear_status (re) < 0) {
|
if (fwup_clear_status (re) < 0) {
|
||||||
@ -118,7 +118,7 @@ fu_provider_uefi_clear_results (FuProvider *provider, FuDevice *device, GError *
|
|||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_INTERNAL,
|
FWUPD_ERROR_INTERNAL,
|
||||||
"Cannot create clear UEFI status for %s",
|
"Cannot create clear UEFI status for %s",
|
||||||
fu_device_get_guid (device));
|
fu_device_get_guid_default (device));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -177,7 +177,7 @@ fu_provider_uefi_get_results (FuProvider *provider, FuDevice *device, GError **e
|
|||||||
|
|
||||||
/* get the hardware we're referencing */
|
/* get the hardware we're referencing */
|
||||||
fwup_resource_iter_create (&iter);
|
fwup_resource_iter_create (&iter);
|
||||||
re = fu_provider_uefi_find (iter, fu_device_get_guid (device), error);
|
re = fu_provider_uefi_find (iter, fu_device_get_guid_default (device), error);
|
||||||
if (re == NULL)
|
if (re == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (fwup_get_last_attempt_info (re, &version, &status, &when) < 0) {
|
if (fwup_get_last_attempt_info (re, &version, &status, &when) < 0) {
|
||||||
@ -185,7 +185,7 @@ fu_provider_uefi_get_results (FuProvider *provider, FuDevice *device, GError **e
|
|||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_INTERNAL,
|
FWUPD_ERROR_INTERNAL,
|
||||||
"Cannot get UEFI status for %s",
|
"Cannot get UEFI status for %s",
|
||||||
fu_device_get_guid (device));
|
fu_device_get_guid_default (device));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
version_str = g_strdup_printf ("%u", version);
|
version_str = g_strdup_printf ("%u", version);
|
||||||
@ -219,7 +219,7 @@ fu_provider_uefi_update (FuProvider *provider,
|
|||||||
|
|
||||||
/* get the hardware we're referencing */
|
/* get the hardware we're referencing */
|
||||||
fwup_resource_iter_create (&iter);
|
fwup_resource_iter_create (&iter);
|
||||||
re = fu_provider_uefi_find (iter, fu_device_get_guid (device), error);
|
re = fu_provider_uefi_find (iter, fu_device_get_guid_default (device), error);
|
||||||
if (re == NULL)
|
if (re == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ fu_provider_uefi_coldplug (FuProvider *provider, GError **error)
|
|||||||
if (supported >= 2) {
|
if (supported >= 2) {
|
||||||
dev = fu_device_new ();
|
dev = fu_device_new ();
|
||||||
fu_device_set_id (dev, "UEFI-dummy-dev0");
|
fu_device_set_id (dev, "UEFI-dummy-dev0");
|
||||||
fu_device_set_guid (dev, "2d47f29b-83a2-4f31-a2e8-63474f4d4c2e");
|
fu_device_add_guid (dev, "2d47f29b-83a2-4f31-a2e8-63474f4d4c2e");
|
||||||
fu_device_set_version (dev, "0");
|
fu_device_set_version (dev, "0");
|
||||||
fu_device_add_flag (dev, FU_DEVICE_FLAG_ALLOW_ONLINE);
|
fu_device_add_flag (dev, FU_DEVICE_FLAG_ALLOW_ONLINE);
|
||||||
fu_device_add_flag (dev, FU_DEVICE_FLAG_LOCKED);
|
fu_device_add_flag (dev, FU_DEVICE_FLAG_LOCKED);
|
||||||
@ -373,7 +373,7 @@ fu_provider_uefi_coldplug (FuProvider *provider, GError **error)
|
|||||||
|
|
||||||
dev = fu_device_new ();
|
dev = fu_device_new ();
|
||||||
fu_device_set_id (dev, id);
|
fu_device_set_id (dev, id);
|
||||||
fu_device_set_guid (dev, guid);
|
fu_device_add_guid (dev, guid);
|
||||||
fu_device_set_version (dev, version);
|
fu_device_set_version (dev, version);
|
||||||
if (display_name != NULL)
|
if (display_name != NULL)
|
||||||
fu_device_set_name(dev, display_name);
|
fu_device_set_name(dev, display_name);
|
||||||
|
@ -134,7 +134,7 @@ fu_provider_usb_device_added (FuProviderUsb *provider_usb, GUsbDevice *device)
|
|||||||
g_usb_device_get_pid (device));
|
g_usb_device_get_pid (device));
|
||||||
guid = as_utils_guid_from_string (vid_pid);
|
guid = as_utils_guid_from_string (vid_pid);
|
||||||
}
|
}
|
||||||
fu_device_set_guid (dev, guid);
|
fu_device_add_guid (dev, guid);
|
||||||
|
|
||||||
/* we're done here */
|
/* we're done here */
|
||||||
if (!g_usb_device_close (device, &error))
|
if (!g_usb_device_close (device, &error))
|
||||||
|
@ -208,7 +208,7 @@ fu_provider_func (void)
|
|||||||
g_assert_cmpint (cnt, ==, 0);
|
g_assert_cmpint (cnt, ==, 0);
|
||||||
g_assert (device != NULL);
|
g_assert (device != NULL);
|
||||||
g_assert_cmpstr (fu_device_get_id (device), ==, "FakeDevice");
|
g_assert_cmpstr (fu_device_get_id (device), ==, "FakeDevice");
|
||||||
g_assert_cmpstr (fu_device_get_guid (device), ==,
|
g_assert_cmpstr (fu_device_get_guid_default (device), ==,
|
||||||
"00000000-0000-0000-0000-000000000000");
|
"00000000-0000-0000-0000-000000000000");
|
||||||
g_assert_cmpstr (fu_device_get_name (device), ==,
|
g_assert_cmpstr (fu_device_get_name (device), ==,
|
||||||
"Integrated Webcam™");
|
"Integrated Webcam™");
|
||||||
@ -316,7 +316,7 @@ fu_provider_rpi_func (void)
|
|||||||
g_assert_cmpint (cnt, ==, 0);
|
g_assert_cmpint (cnt, ==, 0);
|
||||||
g_assert (device != NULL);
|
g_assert (device != NULL);
|
||||||
g_assert_cmpstr (fu_device_get_id (device), ==, "raspberry-pi");
|
g_assert_cmpstr (fu_device_get_id (device), ==, "raspberry-pi");
|
||||||
g_assert_cmpstr (fu_device_get_guid (device), ==,
|
g_assert_cmpstr (fu_device_get_guid_default (device), ==,
|
||||||
"91dd7368-8640-5d72-a217-a505c034dd0b");
|
"91dd7368-8640-5d72-a217-a505c034dd0b");
|
||||||
g_assert_cmpstr (fu_device_get_version (device), ==,
|
g_assert_cmpstr (fu_device_get_version (device), ==,
|
||||||
"20150803");
|
"20150803");
|
||||||
|
@ -885,12 +885,12 @@ fu_util_verify_all (FuUtilPrivate *priv, GError **error)
|
|||||||
NULL,
|
NULL,
|
||||||
&error_local)) {
|
&error_local)) {
|
||||||
g_print ("%s\tFAILED: %s\n",
|
g_print ("%s\tFAILED: %s\n",
|
||||||
fwupd_result_get_guid (res),
|
fwupd_result_get_guid_default (res),
|
||||||
error_local->message);
|
error_local->message);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
g_print ("%s\t%s\n",
|
g_print ("%s\t%s\n",
|
||||||
fwupd_result_get_guid (res),
|
fwupd_result_get_guid_default (res),
|
||||||
_("OK"));
|
_("OK"));
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -981,9 +981,10 @@ fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
{
|
{
|
||||||
FwupdResult *res;
|
FwupdResult *res;
|
||||||
GPtrArray *results = NULL;
|
GPtrArray *results = NULL;
|
||||||
|
GPtrArray *guids;
|
||||||
GChecksumType checksum_type;
|
GChecksumType checksum_type;
|
||||||
const gchar *tmp;
|
const gchar *tmp;
|
||||||
guint i;
|
guint i, j;
|
||||||
|
|
||||||
/* print any updates */
|
/* print any updates */
|
||||||
results = fwupd_client_get_updates (priv->client, NULL, error);
|
results = fwupd_client_get_updates (priv->client, NULL, error);
|
||||||
@ -1000,7 +1001,11 @@ fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
fu_util_print_data (_("ID"), fwupd_result_get_update_id (res));
|
fu_util_print_data (_("ID"), fwupd_result_get_update_id (res));
|
||||||
|
|
||||||
/* TRANSLATORS: a GUID for the hardware */
|
/* TRANSLATORS: a GUID for the hardware */
|
||||||
fu_util_print_data (_("GUID"), fwupd_result_get_guid (res));
|
guids = fwupd_result_get_guids (res);
|
||||||
|
for (j = 0; j < guids->len; j++) {
|
||||||
|
tmp = g_ptr_array_index (guids, j);
|
||||||
|
fu_util_print_data (_("GUID"), tmp);
|
||||||
|
}
|
||||||
|
|
||||||
/* TRANSLATORS: section header for firmware version */
|
/* TRANSLATORS: section header for firmware version */
|
||||||
fu_util_print_data (_("Update Version"),
|
fu_util_print_data (_("Update Version"),
|
||||||
|
Loading…
Reference in New Issue
Block a user