mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-06 14:32:56 +00:00
trivial: Add fu_plugin_set_config_value() for future usage
This commit is contained in:
parent
1a6414c41f
commit
33a24c77b7
@ -2339,6 +2339,36 @@ fu_plugin_get_config_value(FuPlugin *self, const gchar *key)
|
|||||||
return g_key_file_get_string(keyfile, fu_plugin_get_name(self), key, NULL);
|
return g_key_file_get_string(keyfile, fu_plugin_get_name(self), key, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fu_plugin_set_config_value:
|
||||||
|
* @self: a #FuPlugin
|
||||||
|
* @key: a settings key
|
||||||
|
* @value: (nullable): a settings value
|
||||||
|
* @error: (nullable): optional return location for an error
|
||||||
|
*
|
||||||
|
* Sets a plugin config value.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE for success
|
||||||
|
*
|
||||||
|
* Since: 1.7.0
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
fu_plugin_set_config_value(FuPlugin *self, const gchar *key, const gchar *value, GError **error)
|
||||||
|
{
|
||||||
|
g_autofree gchar *conf_path = fu_plugin_get_config_filename(self);
|
||||||
|
g_autoptr(GKeyFile) keyfile = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail(FU_IS_PLUGIN(self), FALSE);
|
||||||
|
g_return_val_if_fail(key != NULL, FALSE);
|
||||||
|
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
|
keyfile = g_key_file_new();
|
||||||
|
if (!g_key_file_load_from_file(keyfile, conf_path, G_KEY_FILE_KEEP_COMMENTS, error))
|
||||||
|
return FALSE;
|
||||||
|
g_key_file_set_string(keyfile, fu_plugin_get_name(self), key, value);
|
||||||
|
return g_key_file_save_to_file(keyfile, conf_path, error);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fu_plugin_get_config_value_boolean:
|
* fu_plugin_get_config_value_boolean:
|
||||||
* @self: a #FuPlugin
|
* @self: a #FuPlugin
|
||||||
|
@ -131,4 +131,6 @@ fu_plugin_get_config_value(FuPlugin *self, const gchar *key);
|
|||||||
gboolean
|
gboolean
|
||||||
fu_plugin_get_config_value_boolean(FuPlugin *self, const gchar *key);
|
fu_plugin_get_config_value_boolean(FuPlugin *self, const gchar *key);
|
||||||
gboolean
|
gboolean
|
||||||
|
fu_plugin_set_config_value(FuPlugin *self, const gchar *key, const gchar *value, GError **error);
|
||||||
|
gboolean
|
||||||
fu_plugin_has_custom_flag(FuPlugin *self, const gchar *flag);
|
fu_plugin_has_custom_flag(FuPlugin *self, const gchar *flag);
|
||||||
|
@ -873,5 +873,6 @@ LIBFWUPDPLUGIN_1.7.0 {
|
|||||||
fu_plugin_runner_prepare;
|
fu_plugin_runner_prepare;
|
||||||
fu_plugin_runner_reload;
|
fu_plugin_runner_reload;
|
||||||
fu_plugin_runner_write_firmware;
|
fu_plugin_runner_write_firmware;
|
||||||
|
fu_plugin_set_config_value;
|
||||||
local: *;
|
local: *;
|
||||||
} LIBFWUPDPLUGIN_1.6.2;
|
} LIBFWUPDPLUGIN_1.6.2;
|
||||||
|
Loading…
Reference in New Issue
Block a user