mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-14 16:11:22 +00:00
trivial: Add a to_string() vfunc for any objects subclassing FuDevice
This commit is contained in:
parent
55f8f236a9
commit
fa34bcffa3
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
gchar *fu_device_to_string (FuDevice *device);
|
|
||||||
const gchar *fu_device_get_version_new (FuDevice *device);
|
const gchar *fu_device_get_version_new (FuDevice *device);
|
||||||
void fu_device_set_version_new (FuDevice *device,
|
void fu_device_set_version_new (FuDevice *device,
|
||||||
const gchar *version_new);
|
const gchar *version_new);
|
||||||
|
@ -626,6 +626,7 @@ fu_device_set_progress (FuDevice *device, guint progress)
|
|||||||
gchar *
|
gchar *
|
||||||
fu_device_to_string (FuDevice *device)
|
fu_device_to_string (FuDevice *device)
|
||||||
{
|
{
|
||||||
|
FuDeviceClass *klass = FU_DEVICE_GET_CLASS (device);
|
||||||
FuDevicePrivate *priv = GET_PRIVATE (device);
|
FuDevicePrivate *priv = GET_PRIVATE (device);
|
||||||
GString *str = g_string_new ("");
|
GString *str = g_string_new ("");
|
||||||
g_autofree gchar *tmp = NULL;
|
g_autofree gchar *tmp = NULL;
|
||||||
@ -648,6 +649,11 @@ fu_device_to_string (FuDevice *device)
|
|||||||
const gchar *value = g_hash_table_lookup (priv->metadata, key);
|
const gchar *value = g_hash_table_lookup (priv->metadata, key);
|
||||||
fwupd_pad_kv_str (str, key, value);
|
fwupd_pad_kv_str (str, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* subclassed */
|
||||||
|
if (klass->to_string != NULL)
|
||||||
|
klass->to_string (device, str);
|
||||||
|
|
||||||
return g_string_free (str, FALSE);
|
return g_string_free (str, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@ G_DECLARE_DERIVABLE_TYPE (FuDevice, fu_device, FU, DEVICE, FwupdDevice)
|
|||||||
struct _FuDeviceClass
|
struct _FuDeviceClass
|
||||||
{
|
{
|
||||||
FwupdDeviceClass parent_class;
|
FwupdDeviceClass parent_class;
|
||||||
|
void (*to_string) (FuDevice *device,
|
||||||
|
GString *str);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,6 +96,7 @@ FuDevice *fu_device_new (void);
|
|||||||
#define fu_device_get_flashes_left(d) fwupd_device_get_flashes_left(FWUPD_DEVICE(d))
|
#define fu_device_get_flashes_left(d) fwupd_device_get_flashes_left(FWUPD_DEVICE(d))
|
||||||
|
|
||||||
/* accessors */
|
/* accessors */
|
||||||
|
gchar *fu_device_to_string (FuDevice *device);
|
||||||
const gchar *fu_device_get_equivalent_id (FuDevice *device);
|
const gchar *fu_device_get_equivalent_id (FuDevice *device);
|
||||||
void fu_device_set_equivalent_id (FuDevice *device,
|
void fu_device_set_equivalent_id (FuDevice *device,
|
||||||
const gchar *equivalent_id);
|
const gchar *equivalent_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user