trivial: Add fu_plugin_set_config_value() for future usage

This commit is contained in:
Richard Hughes 2021-09-06 21:24:08 +01:00
parent 1a6414c41f
commit 33a24c77b7
3 changed files with 33 additions and 0 deletions

View File

@ -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);
}
/**
* 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:
* @self: a #FuPlugin

View File

@ -131,4 +131,6 @@ fu_plugin_get_config_value(FuPlugin *self, const gchar *key);
gboolean
fu_plugin_get_config_value_boolean(FuPlugin *self, const gchar *key);
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);

View File

@ -873,5 +873,6 @@ LIBFWUPDPLUGIN_1.7.0 {
fu_plugin_runner_prepare;
fu_plugin_runner_reload;
fu_plugin_runner_write_firmware;
fu_plugin_set_config_value;
local: *;
} LIBFWUPDPLUGIN_1.6.2;