mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-14 20:24:36 +00:00
trivial: Allow plugins to add metadata to the uploaded reports
This commit is contained in:
parent
473c520e38
commit
80b79bb9aa
@ -29,6 +29,16 @@
|
|||||||
|
|
||||||
#include "fu-colorhug-device.h"
|
#include "fu-colorhug-device.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
fu_plugin_init (FuPlugin *plugin)
|
||||||
|
{
|
||||||
|
g_autofree gchar *tmp = g_strdup_printf ("%i.%i.%i",
|
||||||
|
CH_MAJOR_VERSION,
|
||||||
|
CH_MINOR_VERSION,
|
||||||
|
CH_MICRO_VERSION);
|
||||||
|
fu_plugin_add_report_metadata (plugin, "ColorhugVersion", tmp);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
fu_plugin_update_detach (FuPlugin *plugin, FuDevice *device, GError **error)
|
fu_plugin_update_detach (FuPlugin *plugin, FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
|
@ -37,6 +37,7 @@ void
|
|||||||
fu_plugin_init (FuPlugin *plugin)
|
fu_plugin_init (FuPlugin *plugin)
|
||||||
{
|
{
|
||||||
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_RUN_AFTER, "upower");
|
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_RUN_AFTER, "upower");
|
||||||
|
//fu_plugin_add_report_metadata (plugin, "FwupdateVersion", LIBFWUP_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
|
@ -1489,6 +1489,8 @@ fu_engine_install (FuEngine *self,
|
|||||||
/* build the version metadata */
|
/* build the version metadata */
|
||||||
metadata_hash = fu_engine_get_report_metadata (self);
|
metadata_hash = fu_engine_get_report_metadata (self);
|
||||||
fwupd_release_add_metadata (release_history, metadata_hash);
|
fwupd_release_add_metadata (release_history, metadata_hash);
|
||||||
|
fwupd_release_add_metadata (release_history,
|
||||||
|
fu_plugin_get_report_metadata (plugin));
|
||||||
|
|
||||||
/* add device to database */
|
/* add device to database */
|
||||||
checksum = g_compute_checksum_for_bytes (G_CHECKSUM_SHA1, blob_cab);
|
checksum = g_compute_checksum_for_bytes (G_CHECKSUM_SHA1, blob_cab);
|
||||||
|
@ -49,6 +49,7 @@ void fu_plugin_set_name (FuPlugin *plugin,
|
|||||||
const gchar *name);
|
const gchar *name);
|
||||||
GPtrArray *fu_plugin_get_rules (FuPlugin *plugin,
|
GPtrArray *fu_plugin_get_rules (FuPlugin *plugin,
|
||||||
FuPluginRule rule);
|
FuPluginRule rule);
|
||||||
|
GHashTable *fu_plugin_get_report_metadata (FuPlugin *plugin);
|
||||||
gboolean fu_plugin_open (FuPlugin *plugin,
|
gboolean fu_plugin_open (FuPlugin *plugin,
|
||||||
const gchar *filename,
|
const gchar *filename,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
@ -61,6 +61,7 @@ typedef struct {
|
|||||||
FuSmbios *smbios;
|
FuSmbios *smbios;
|
||||||
GHashTable *devices; /* platform_id:GObject */
|
GHashTable *devices; /* platform_id:GObject */
|
||||||
GHashTable *devices_delay; /* FuDevice:FuPluginHelper */
|
GHashTable *devices_delay; /* FuDevice:FuPluginHelper */
|
||||||
|
GHashTable *report_metadata; /* key:value */
|
||||||
FuPluginData *data;
|
FuPluginData *data;
|
||||||
} FuPluginPrivate;
|
} FuPluginPrivate;
|
||||||
|
|
||||||
@ -1426,6 +1427,40 @@ fu_plugin_get_rules (FuPlugin *plugin, FuPluginRule rule)
|
|||||||
return priv->rules[rule];
|
return priv->rules[rule];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fu_plugin_add_report_metadata:
|
||||||
|
* @plugin: a #FuPlugin
|
||||||
|
* @key: a string, e.g. `FwupdateVersion`
|
||||||
|
* @value: a string, e.g. `10`
|
||||||
|
*
|
||||||
|
* Sets any additional metadata to be included in the firmware report to aid
|
||||||
|
* debugging problems.
|
||||||
|
*
|
||||||
|
* Any data included here will be sent to the metadata server after user
|
||||||
|
* confirmation.
|
||||||
|
**/
|
||||||
|
void
|
||||||
|
fu_plugin_add_report_metadata (FuPlugin *plugin, const gchar *key, const gchar *value)
|
||||||
|
{
|
||||||
|
FuPluginPrivate *priv = fu_plugin_get_instance_private (plugin);
|
||||||
|
g_hash_table_insert (priv->report_metadata, g_strdup (key), g_strdup (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fu_plugin_get_report_metadata:
|
||||||
|
* @plugin: a #FuPlugin
|
||||||
|
*
|
||||||
|
* Returns the list of additional metadata to be added when filing a report.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): the map of report metadata
|
||||||
|
**/
|
||||||
|
GHashTable *
|
||||||
|
fu_plugin_get_report_metadata (FuPlugin *plugin)
|
||||||
|
{
|
||||||
|
FuPluginPrivate *priv = fu_plugin_get_instance_private (plugin);
|
||||||
|
return priv->report_metadata;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fu_plugin_class_init (FuPluginClass *klass)
|
fu_plugin_class_init (FuPluginClass *klass)
|
||||||
{
|
{
|
||||||
@ -1471,6 +1506,7 @@ fu_plugin_init (FuPlugin *plugin)
|
|||||||
priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal,
|
priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||||
g_free, (GDestroyNotify) g_object_unref);
|
g_free, (GDestroyNotify) g_object_unref);
|
||||||
priv->devices_delay = g_hash_table_new (g_direct_hash, g_direct_equal);
|
priv->devices_delay = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||||
|
priv->report_metadata = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||||
for (guint i = 0; i < FU_PLUGIN_RULE_LAST; i++)
|
for (guint i = 0; i < FU_PLUGIN_RULE_LAST; i++)
|
||||||
priv->rules[i] = g_ptr_array_new_with_free_func (g_free);
|
priv->rules[i] = g_ptr_array_new_with_free_func (g_free);
|
||||||
}
|
}
|
||||||
@ -1510,6 +1546,7 @@ fu_plugin_finalize (GObject *object)
|
|||||||
#endif
|
#endif
|
||||||
g_hash_table_unref (priv->devices);
|
g_hash_table_unref (priv->devices);
|
||||||
g_hash_table_unref (priv->devices_delay);
|
g_hash_table_unref (priv->devices_delay);
|
||||||
|
g_hash_table_unref (priv->report_metadata);
|
||||||
g_free (priv->name);
|
g_free (priv->name);
|
||||||
g_free (priv->data);
|
g_free (priv->data);
|
||||||
|
|
||||||
|
@ -144,6 +144,9 @@ const gchar *fu_plugin_lookup_quirk_by_id (FuPlugin *plugin,
|
|||||||
const gchar *fu_plugin_lookup_quirk_by_usb_device (FuPlugin *plugin,
|
const gchar *fu_plugin_lookup_quirk_by_usb_device (FuPlugin *plugin,
|
||||||
const gchar *prefix,
|
const gchar *prefix,
|
||||||
GUsbDevice *dev);
|
GUsbDevice *dev);
|
||||||
|
void fu_plugin_add_report_metadata (FuPlugin *plugin,
|
||||||
|
const gchar *key,
|
||||||
|
const gchar *value);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user