Skip to content

Commit

Permalink
Remove the almost unused fwupd_device_get_description()
Browse files Browse the repository at this point in the history
  • Loading branch information
hughsie committed Feb 19, 2024
1 parent bb3f4bb commit 940d0c0
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 113 deletions.
64 changes: 0 additions & 64 deletions libfwupd/fwupd-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ typedef struct {
gchar *serial;
gchar *summary;
gchar *branch;
gchar *description;
gchar *vendor;
gchar *vendor_id; /* for compat only */
gchar *homepage;
Expand Down Expand Up @@ -984,47 +983,6 @@ fwupd_device_add_vendor_id(FwupdDevice *self, const gchar *vendor_id)
priv->vendor_id = g_strjoinv("|", vendor_ids_tmp);
}

/**
* fwupd_device_get_description:
* @self: a #FwupdDevice
*
* Gets the device description in AppStream markup format.
*
* Returns: the device description, or %NULL if unset
*
* Since: 0.9.3
**/
const gchar *
fwupd_device_get_description(FwupdDevice *self)
{
FwupdDevicePrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(FWUPD_IS_DEVICE(self), NULL);
return priv->description;
}

/**
* fwupd_device_set_description:
* @self: a #FwupdDevice
* @description: (nullable): the description in AppStream markup format
*
* Sets the device description.
*
* Since: 0.9.3
**/
void
fwupd_device_set_description(FwupdDevice *self, const gchar *description)
{
FwupdDevicePrivate *priv = GET_PRIVATE(self);
g_return_if_fail(FWUPD_IS_DEVICE(self));

/* not changed */
if (g_strcmp0(priv->description, description) == 0)
return;

g_free(priv->description);
priv->description = g_strdup(description);
}

/**
* fwupd_device_get_version:
* @self: a #FwupdDevice
Expand Down Expand Up @@ -1905,8 +1863,6 @@ fwupd_device_incorporate(FwupdDevice *self, FwupdDevice *donor)
fwupd_device_set_install_duration(self, priv_donor->install_duration);
if (priv->update_state == FWUPD_UPDATE_STATE_UNKNOWN)
fwupd_device_set_update_state(self, priv_donor->update_state);
if (priv->description == NULL)
fwupd_device_set_description(self, priv_donor->description);
if (priv->id == NULL)
fwupd_device_set_id(self, priv_donor->id);
if (priv->parent_id == NULL)
Expand Down Expand Up @@ -2091,12 +2047,6 @@ fwupd_device_to_variant_full(FwupdDevice *self, FwupdDeviceFlags flags)
g_variant_new_uint64(priv->version_build_date));
}

if (priv->description != NULL) {
g_variant_builder_add(&builder,
"{sv}",
FWUPD_RESULT_KEY_DESCRIPTION,
g_variant_new_string(priv->description));
}
if (priv->summary != NULL) {
g_variant_builder_add(&builder,
"{sv}",
Expand Down Expand Up @@ -2397,10 +2347,6 @@ fwupd_device_from_key_value(FwupdDevice *self, const gchar *key, GVariant *value
fwupd_device_set_branch(self, g_variant_get_string(value, NULL));
return;
}
if (g_strcmp0(key, FWUPD_RESULT_KEY_DESCRIPTION) == 0) {
fwupd_device_set_description(self, g_variant_get_string(value, NULL));
return;
}
if (g_strcmp0(key, FWUPD_RESULT_KEY_CHECKSUM) == 0) {
const gchar *checksums = g_variant_get_string(value, NULL);
if (checksums != NULL) {
Expand Down Expand Up @@ -3001,7 +2947,6 @@ fwupd_device_to_json_full(FwupdDevice *self, JsonBuilder *builder, FwupdDeviceFl
if (flags & FWUPD_DEVICE_FLAG_TRUSTED)
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_SERIAL, priv->serial);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_SUMMARY, priv->summary);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_DESCRIPTION, priv->description);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_BRANCH, priv->branch);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_PLUGIN, priv->plugin);
if (priv->protocols->len > 0) {
Expand Down Expand Up @@ -3236,13 +3181,6 @@ fwupd_device_from_json(FwupdDevice *self, JsonNode *json_node, GError **error)
json_object_get_string_member_with_default(obj, FWUPD_RESULT_KEY_SUMMARY, NULL);
fwupd_device_set_summary(self, tmp);
}
if (json_object_has_member(obj, FWUPD_RESULT_KEY_DESCRIPTION)) {
const gchar *tmp =
json_object_get_string_member_with_default(obj,
FWUPD_RESULT_KEY_DESCRIPTION,
NULL);
fwupd_device_set_description(self, tmp);
}
if (json_object_has_member(obj, FWUPD_RESULT_KEY_BRANCH)) {
const gchar *tmp =
json_object_get_string_member_with_default(obj, FWUPD_RESULT_KEY_BRANCH, NULL);
Expand Down Expand Up @@ -3568,7 +3506,6 @@ fwupd_device_to_string(FwupdDevice *self)

fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_SERIAL, priv->serial);
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_SUMMARY, priv->summary);
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_DESCRIPTION, priv->description);
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_BRANCH, priv->branch);
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_PLUGIN, priv->plugin);
for (guint i = 0; i < priv->protocols->len; i++) {
Expand Down Expand Up @@ -4013,7 +3950,6 @@ fwupd_device_finalize(GObject *object)
g_object_weak_unref(G_OBJECT(child), fwupd_device_child_finalized_cb, self);
}

g_free(priv->description);
g_free(priv->id);
g_free(priv->parent_id);
g_free(priv->composite_id);
Expand Down
4 changes: 0 additions & 4 deletions libfwupd/fwupd-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ fwupd_device_get_branch(FwupdDevice *self) G_GNUC_NON_NULL(1);
void
fwupd_device_set_branch(FwupdDevice *self, const gchar *branch) G_GNUC_NON_NULL(1);
const gchar *
fwupd_device_get_description(FwupdDevice *self) G_GNUC_NON_NULL(1);
void
fwupd_device_set_description(FwupdDevice *self, const gchar *description) G_GNUC_NON_NULL(1);
const gchar *
fwupd_device_get_version(FwupdDevice *self) G_GNUC_NON_NULL(1);
void
fwupd_device_set_version(FwupdDevice *self, const gchar *version) G_GNUC_NON_NULL(1);
Expand Down
2 changes: 0 additions & 2 deletions libfwupd/fwupd.map
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ LIBFWUPD_0.9.3 {
fwupd_device_add_guid;
fwupd_device_get_checksums;
fwupd_device_get_created;
fwupd_device_get_description;
fwupd_device_get_flags;
fwupd_device_get_flashes_left;
fwupd_device_get_guid_default;
Expand All @@ -83,7 +82,6 @@ LIBFWUPD_0.9.3 {
fwupd_device_new;
fwupd_device_remove_flag;
fwupd_device_set_created;
fwupd_device_set_description;
fwupd_device_set_flags;
fwupd_device_set_flashes_left;
fwupd_device_set_id;
Expand Down
2 changes: 1 addition & 1 deletion plugins/redfish/fu-redfish-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ fu_redfish_device_probe(FuDevice *dev, GError **error)
if (json_object_has_member(member, "Description")) {
const gchar *tmp = json_object_get_string_member(member, "Description");
if (tmp != NULL && tmp[0] != '\0')
fu_device_set_description(dev, tmp);
fu_device_set_summary(dev, tmp);
}

/* reasons why the device might not be updatable */
Expand Down
31 changes: 0 additions & 31 deletions src/fu-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,25 +462,6 @@ fu_engine_device_changed_cb(FuDeviceList *device_list, FuDevice *device, FuEngin
fu_engine_acquiesce_reset(self);
}

static gchar *
fu_engine_request_get_localized_xpath(FuEngineRequest *request, const gchar *element)
{
GString *xpath = g_string_new(element);
const gchar *locale = NULL;

/* optional; not set in tests */
if (request != NULL)
locale = fu_engine_request_get_locale(request);

/* prefer the users locale if set */
if (locale != NULL) {
g_autofree gchar *xpath_locale = NULL;
xpath_locale = g_strdup_printf("%s[@xml:lang='%s']|", element, locale);
g_string_prepend(xpath, xpath_locale);
}
return g_string_free(xpath, FALSE);
}

/* add any client-side BKC tags */
static gboolean
fu_engine_add_local_release_metadata(FuEngine *self, FuRelease *release, GError **error)
Expand Down Expand Up @@ -4497,14 +4478,12 @@ fu_engine_get_result_from_component(FuEngine *self,
XbNode *component,
GError **error)
{
g_autofree gchar *description_xpath = NULL;
g_autoptr(FuDevice) dev = NULL;
g_autoptr(FuRelease) release = fu_release_new();
g_autoptr(GError) error_local = NULL;
g_autoptr(GError) error_reqs = NULL;
g_autoptr(GPtrArray) provides = NULL;
g_autoptr(GPtrArray) tags = NULL;
g_autoptr(XbNode) description = NULL;
g_autoptr(XbNode) rel = NULL;
g_autoptr(XbQuery) query = NULL;

Expand Down Expand Up @@ -4588,16 +4567,6 @@ fu_engine_get_result_from_component(FuEngine *self,
/* continue */
}

/* create a result with all the metadata in */
description_xpath = fu_engine_request_get_localized_xpath(request, "description");
description = xb_node_query_first(component, description_xpath, NULL);
if (description != NULL) {
g_autofree gchar *xml = NULL;
xml = xb_node_export(description, XB_NODE_EXPORT_FLAG_ONLY_CHILDREN, NULL);
if (xml != NULL)
fu_device_set_description(dev, xml);
}

/* success */
fu_device_add_release(dev, FWUPD_RELEASE(release));
return g_steal_pointer(&dev);
Expand Down
1 change: 1 addition & 0 deletions src/fu-release.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fu_release_new(void);
#define fu_release_add_tag(r, v) fwupd_release_add_tag(FWUPD_RELEASE(r), v)
#define fu_release_add_metadata(r, v) fwupd_release_add_metadata(FWUPD_RELEASE(r), v)
#define fu_release_set_branch(r, v) fwupd_release_set_branch(FWUPD_RELEASE(r), v)
#define fu_release_set_description(r, v) fwupd_release_set_description(FWUPD_RELEASE(r), v)
#define fu_release_set_flags(r, v) fwupd_release_set_flags(FWUPD_RELEASE(r), v)

gchar *
Expand Down
11 changes: 0 additions & 11 deletions src/fu-util-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,17 +1348,6 @@ fu_util_device_to_string(FwupdClient *client, FwupdDevice *dev, guint idt)
fu_string_append(str, idt + 1, _("Summary"), tmp);
}

/* description */
tmp = fwupd_device_get_description(dev);
if (tmp != NULL) {
g_autofree gchar *desc = NULL;
desc = fu_util_convert_description(tmp, NULL);
if (desc == NULL)
desc = g_strdup(tmp);
/* TRANSLATORS: multiline description of device */
fu_string_append(str, idt + 1, _("Description"), desc);
}

/* versions */
tmp = fwupd_device_get_version(dev);
if (tmp != NULL) {
Expand Down

0 comments on commit 940d0c0

Please sign in to comment.