From 6c6e8d3ab86b881933dc0fca36e02c4939e86ccd Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Sat, 9 Sep 2017 21:35:15 +0100 Subject: [PATCH] Add an 'Summary' property to each device This was already exported in the libfwupd API, but it had no way of being set from devices or passed from daemon to client. --- libfwupd/fwupd-device.c | 10 ++++++++++ libfwupd/fwupd-enums-private.h | 1 + src/fu-device.h | 1 + 3 files changed, 12 insertions(+) diff --git a/libfwupd/fwupd-device.c b/libfwupd/fwupd-device.c index 29aaeb2dc..5fee0f81f 100644 --- a/libfwupd/fwupd-device.c +++ b/libfwupd/fwupd-device.c @@ -788,6 +788,11 @@ fwupd_device_to_variant_builder (FwupdDevice *device, GVariantBuilder *builder) FWUPD_RESULT_KEY_DEVICE_DESCRIPTION, g_variant_new_string (priv->description)); } + if (priv->summary != NULL) { + g_variant_builder_add (builder, "{sv}", + FWUPD_RESULT_KEY_DEVICE_SUMMARY, + g_variant_new_string (priv->summary)); + } if (priv->checksums->len > 0) { g_autoptr(GString) str = g_string_new (""); for (guint i = 0; i < priv->checksums->len; i++) { @@ -893,6 +898,10 @@ fwupd_device_from_key_value (FwupdDevice *device, const gchar *key, GVariant *va fwupd_device_set_vendor_id (device, g_variant_get_string (value, NULL)); return; } + if (g_strcmp0 (key, FWUPD_RESULT_KEY_DEVICE_SUMMARY) == 0) { + fwupd_device_set_summary (device, g_variant_get_string (value, NULL)); + return; + } if (g_strcmp0 (key, FWUPD_RESULT_KEY_DEVICE_DESCRIPTION) == 0) { fwupd_device_set_description (device, g_variant_get_string (value, NULL)); return; @@ -1015,6 +1024,7 @@ fwupd_device_to_string (FwupdDevice *device) 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_SUMMARY, priv->summary); fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_DEVICE_DESCRIPTION, priv->description); fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_DEVICE_PLUGIN, priv->provider); fwupd_pad_kv_dfl (str, FWUPD_RESULT_KEY_DEVICE_FLAGS, priv->flags); diff --git a/libfwupd/fwupd-enums-private.h b/libfwupd/fwupd-enums-private.h index b3b31edd6..4e4725f48 100644 --- a/libfwupd/fwupd-enums-private.h +++ b/libfwupd/fwupd-enums-private.h @@ -24,6 +24,7 @@ /* FIXME: change the keys to the new names when we bump major version */ #define FWUPD_RESULT_KEY_DEVICE_CREATED "Created" /* t */ +#define FWUPD_RESULT_KEY_DEVICE_SUMMARY "Summary" /* s */ #define FWUPD_RESULT_KEY_DEVICE_DESCRIPTION "Description" /* s */ #define FWUPD_RESULT_KEY_DEVICE_FLAGS "Flags" /* t */ #define FWUPD_RESULT_KEY_DEVICE_CHECKSUM "FirmwareHash" /* s */ diff --git a/src/fu-device.h b/src/fu-device.h index 9353f77ca..ef9d7e692 100644 --- a/src/fu-device.h +++ b/src/fu-device.h @@ -49,6 +49,7 @@ FuDevice *fu_device_new (void); #define fu_device_set_id(d,v) fwupd_device_set_id(fwupd_result_get_device(FWUPD_RESULT(d)),v) #define fu_device_set_modified(d,v) fwupd_device_set_modified(fwupd_result_get_device(FWUPD_RESULT(d)),v) #define fu_device_set_plugin(d,v) fwupd_device_set_provider(fwupd_result_get_device(FWUPD_RESULT(d)),v) +#define fu_device_set_summary(d,v) fwupd_device_set_summary(fwupd_result_get_device(FWUPD_RESULT(d)),v) #define fu_device_set_unique_id(d,v) fwupd_result_set_unique_id(FWUPD_RESULT(d),v) #define fu_device_set_update_description(d,v) fwupd_release_set_description(fwupd_result_get_release(FWUPD_RESULT(d)),v) #define fu_device_set_update_error(d,v) fwupd_result_set_update_error(FWUPD_RESULT(d),v)