trivial: Unify ambiguity between bios-attrs and bios-settings

These are currently used interchangeably since there was indecisiveness
which to use as the feature was being developed.

As outward facing it will be named with "settings", change all uses
in the code to match this.
This commit is contained in:
Mario Limonciello 2022-08-24 00:14:39 -05:00 committed by Mario Limonciello
parent 8b63023aaf
commit b7b0ce533d
48 changed files with 1286 additions and 1260 deletions

View File

@ -32,6 +32,6 @@ def populate_translations(path):
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) != 2: if len(sys.argv) != 2:
print("path to bios attributes directory required") print("path to bios settings directory required")
sys.exit(1) sys.exit(1)
populate_translations(sys.argv[1]) populate_translations(sys.argv[1])

View File

@ -25,7 +25,7 @@ def _minimize_json(json_str: str) -> str:
nodes = json.loads(json_str) nodes = json.loads(json_str)
new_attrs: List[Dict[str, Any]] = [] new_attrs: List[Dict[str, Any]] = []
new_devices: List[Dict[str, Any]] = [] new_devices: List[Dict[str, Any]] = []
new_bios_attrs: List[Dict[str, Any]] = [] new_bios_settings: List[Dict[str, Any]] = []
try: try:
for attr in nodes["SecurityAttributes"]: for attr in nodes["SecurityAttributes"]:
new_attr: Dict[str, Any] = {} new_attr: Dict[str, Any] = {}
@ -45,19 +45,19 @@ def _minimize_json(json_str: str) -> str:
except KeyError: except KeyError:
pass pass
try: try:
for device in nodes["BiosAttributes"]: for device in nodes["BiosSettings"]:
new_attr: Dict[str, Any] = {} new_attr: Dict[str, Any] = {}
for key in device: for key in device:
if key not in ["Filename"]: if key not in ["Filename"]:
new_attr[key] = device[key] new_attr[key] = device[key]
new_bios_attrs.append(new_attr) new_bios_settings.append(new_attr)
except KeyError: except KeyError:
pass pass
return json.dumps( return json.dumps(
{ {
"SecurityAttributes": new_attrs, "SecurityAttributes": new_attrs,
"Devices": new_devices, "Devices": new_devices,
"BiosAttributes": new_bios_attrs, "BiosSettings": new_bios_settings,
}, },
indent=2, indent=2,
separators=(",", " : "), separators=(",", " : "),
@ -99,13 +99,13 @@ def _get_host_devices_and_attrs() -> str:
builder.end_object() builder.end_object()
builder.end_array() builder.end_array()
# add BIOS attributes # add BIOS settings
try: try:
attrs = client.get_bios_attrs() attrs = client.get_bios_settings()
except GLib.GError as e: except GLib.GError as e:
print("ignoring {}".format(e)) print("ignoring {}".format(e))
else: else:
builder.set_member_name("BiosAttributes") builder.set_member_name("BiosSettings")
builder.begin_array() builder.begin_array()
for attr in attrs: for attr in attrs:
builder.begin_object() builder.begin_object()

View File

@ -104,23 +104,23 @@ _show_modifiers()
COMPREPLY+=( $(compgen -W '${_fwupdmgr_opts[@]}' -- "$cur") ) COMPREPLY+=( $(compgen -W '${_fwupdmgr_opts[@]}' -- "$cur") )
} }
_show_bios_attrs() _show_bios_settings()
{ {
if ! command -v jq &> /dev/null; then if ! command -v jq &> /dev/null; then
return 0 return 0
fi fi
local attr local attr
attr="$(command fwupdmgr get-bios-setting --json --no-authenticate 2>/dev/null | jq '.BiosAttributes | .[] | .Name')" attr="$(command fwupdmgr get-bios-setting --json --no-authenticate 2>/dev/null | jq '.BiosSettings | .[] | .Name')"
COMPREPLY+=( $(compgen -W "${attr}" -- "$cur") ) COMPREPLY+=( $(compgen -W "${attr}" -- "$cur") )
} }
_show_bios_attrs_possible() _show_bios_settings_possible()
{ {
if ! command -v jq &> /dev/null; then if ! command -v jq &> /dev/null; then
return 0 return 0
fi fi
local attr local attr
attr="$(command fwupdmgr get-bios-setting "$1" --json --no-authenticate 2>/dev/null | jq '.BiosAttributes | .[] | .BiosAttrPossibleValues | .[]')" attr="$(command fwupdmgr get-bios-setting "$1" --json --no-authenticate 2>/dev/null | jq '.BiosSettings | .[] | .BiosSettingPossibleValues | .[]')"
COMPREPLY+=( $(compgen -W "${attr}" -- "$cur") ) COMPREPLY+=( $(compgen -W "${attr}" -- "$cur") )
} }
@ -174,8 +174,8 @@ _fwupdmgr()
fi fi
;; ;;
get-bios-settings|get-bios-setting) get-bios-settings|get-bios-setting)
#bios attrs (no limit) #bios settings (no limit)
_show_bios_attrs _show_bios_settings
_show_bios_get_modifiers _show_bios_get_modifiers
return 0 return 0
;; ;;
@ -185,13 +185,13 @@ _fwupdmgr()
return 0 return 0
fi fi
count=$(($((args)) % 2)) count=$(($((args)) % 2))
#allow setting a single bios attr at a time #allow setting a single bios setting at a time
if [[ $count == 0 ]]; then if [[ $count == 0 ]]; then
_show_bios_attrs _show_bios_settings
fi fi
#possible values (only works for enumeration though) #possible values (only works for enumeration though)
if [[ $count == 1 ]]; then if [[ $count == 1 ]]; then
_show_bios_attrs_possible "$prev" _show_bios_settings_possible "$prev"
return 0 return 0
fi fi
_show_bios_set_modifiers _show_bios_set_modifiers

View File

@ -1,18 +0,0 @@
/*
* Copyright (C) 2022 Mario Limonciello <mario.limonciello@amd.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#include <json-glib/json-glib.h>
#include "fwupd-bios-attr.h"
#pragma once
GVariant *
fwupd_bios_attr_to_variant(FwupdBiosAttr *self, gboolean trusted);
void
fwupd_bios_attr_to_json(FwupdBiosAttr *self, JsonBuilder *builder);
gboolean
fwupd_bios_attr_from_json(FwupdBiosAttr *self, JsonNode *json_node, GError **error);

View File

@ -1,118 +0,0 @@
/*
* Copyright (C) 2022 Mario Limonciello <mario.limonciello@amd.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <glib-object.h>
#include "fwupd-enums.h"
G_BEGIN_DECLS
#define FWUPD_TYPE_BIOS_ATTR (fwupd_bios_attr_get_type())
G_DECLARE_DERIVABLE_TYPE(FwupdBiosAttr, fwupd_bios_attr, FWUPD, BIOS_ATTR, GObject)
struct _FwupdBiosAttrClass {
GObjectClass parent_class;
/*< private >*/
void (*_fwupd_reserved1)(void);
void (*_fwupd_reserved2)(void);
void (*_fwupd_reserved3)(void);
void (*_fwupd_reserved4)(void);
void (*_fwupd_reserved5)(void);
void (*_fwupd_reserved6)(void);
void (*_fwupd_reserved7)(void);
};
/* special attributes */
#define FWUPD_BIOS_ATTR_PENDING_REBOOT "pending_reboot"
#define FWUPD_BIOS_ATTR_RESET_BIOS "reset_bios"
#define FWUPD_BIOS_ATTR_DEBUG_CMD "debug_cmd"
/**
* FwupdBiosAttrKind:
* @FWUPD_BIOS_ATTR_KIND_UNKNOWN: BIOS attribute type is unknown
* @FWUPD_BIOS_ATTR_KIND_ENUMERATION: BIOS attribute that has enumerated possible values
* @FWUPD_BIOS_ATTR_KIND_INTEGER: BIOS attribute that is an integer
* @FWUPD_BIOS_ATTR_KIND_STRING: BIOS attribute that accepts a string
*
* The type of BIOS attribute.
**/
typedef enum {
FWUPD_BIOS_ATTR_KIND_UNKNOWN = 0, /* Since: 1.8.4 */
FWUPD_BIOS_ATTR_KIND_ENUMERATION = 1, /* Since: 1.8.4 */
FWUPD_BIOS_ATTR_KIND_INTEGER = 2, /* Since: 1.8.4 */
FWUPD_BIOS_ATTR_KIND_STRING = 3, /* Since: 1.8.4 */
/*< private >*/
FWUPD_BIOS_ATTR_KIND_LAST = 4 /* perhaps increased in the future */
} FwupdBiosAttrKind;
FwupdBiosAttr *
fwupd_bios_attr_new(const gchar *name, const gchar *path);
gchar *
fwupd_bios_attr_to_string(FwupdBiosAttr *self);
gboolean
fwupd_bios_attr_get_read_only(FwupdBiosAttr *self);
void
fwupd_bios_attr_set_read_only(FwupdBiosAttr *self, gboolean val);
guint64
fwupd_bios_attr_get_upper_bound(FwupdBiosAttr *self);
guint64
fwupd_bios_attr_get_lower_bound(FwupdBiosAttr *self);
guint64
fwupd_bios_attr_get_scalar_increment(FwupdBiosAttr *self);
void
fwupd_bios_attr_set_upper_bound(FwupdBiosAttr *self, guint64 val);
void
fwupd_bios_attr_set_lower_bound(FwupdBiosAttr *self, guint64 val);
void
fwupd_bios_attr_set_scalar_increment(FwupdBiosAttr *self, guint64 val);
void
fwupd_bios_attr_set_kind(FwupdBiosAttr *self, FwupdBiosAttrKind type);
void
fwupd_bios_attr_set_name(FwupdBiosAttr *self, const gchar *name);
void
fwupd_bios_attr_set_path(FwupdBiosAttr *self, const gchar *path);
void
fwupd_bios_attr_set_description(FwupdBiosAttr *self, const gchar *description);
FwupdBiosAttrKind
fwupd_bios_attr_get_kind(FwupdBiosAttr *self);
const gchar *
fwupd_bios_attr_get_name(FwupdBiosAttr *self);
const gchar *
fwupd_bios_attr_get_path(FwupdBiosAttr *self);
const gchar *
fwupd_bios_attr_get_description(FwupdBiosAttr *self);
const gchar *
fwupd_bios_attr_map_possible_value(FwupdBiosAttr *self, const gchar *key, GError **error);
gboolean
fwupd_bios_attr_has_possible_value(FwupdBiosAttr *self, const gchar *val);
void
fwupd_bios_attr_add_possible_value(FwupdBiosAttr *self, const gchar *possible_value);
GPtrArray *
fwupd_bios_attr_get_possible_values(FwupdBiosAttr *self);
FwupdBiosAttr *
fwupd_bios_attr_from_variant(GVariant *value);
GPtrArray *
fwupd_bios_attr_array_from_variant(GVariant *value);
const gchar *
fwupd_bios_attr_get_current_value(FwupdBiosAttr *self);
void
fwupd_bios_attr_set_current_value(FwupdBiosAttr *self, const gchar *value);
const gchar *
fwupd_bios_attr_get_id(FwupdBiosAttr *self);
void
fwupd_bios_attr_set_id(FwupdBiosAttr *self, const gchar *id);
G_END_DECLS

View File

@ -0,0 +1,18 @@
/*
* Copyright (C) 2022 Mario Limonciello <mario.limonciello@amd.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#include <json-glib/json-glib.h>
#include "fwupd-bios-setting.h"
#pragma once
GVariant *
fwupd_bios_setting_to_variant(FwupdBiosSetting *self, gboolean trusted);
void
fwupd_bios_setting_to_json(FwupdBiosSetting *self, JsonBuilder *builder);
gboolean
fwupd_bios_setting_from_json(FwupdBiosSetting *self, JsonNode *json_node, GError **error);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,119 @@
/*
* Copyright (C) 2022 Mario Limonciello <mario.limonciello@amd.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <glib-object.h>
#include "fwupd-enums.h"
G_BEGIN_DECLS
#define FWUPD_TYPE_BIOS_SETTING (fwupd_bios_setting_get_type())
G_DECLARE_DERIVABLE_TYPE(FwupdBiosSetting, fwupd_bios_setting, FWUPD, BIOS_SETTING, GObject)
struct _FwupdBiosSettingClass {
GObjectClass parent_class;
/*< private >*/
void (*_fwupd_reserved1)(void);
void (*_fwupd_reserved2)(void);
void (*_fwupd_reserved3)(void);
void (*_fwupd_reserved4)(void);
void (*_fwupd_reserved5)(void);
void (*_fwupd_reserved6)(void);
void (*_fwupd_reserved7)(void);
};
/* special attributes */
#define FWUPD_BIOS_SETTING_PENDING_REBOOT "pending_reboot"
#define FWUPD_BIOS_SETTING_RESET_BIOS "reset_bios"
#define FWUPD_BIOS_SETTING_DEBUG_CMD "debug_cmd"
/**
* FwupdBiosSettingKind:
* @FWUPD_BIOS_SETTING_KIND_UNKNOWN: BIOS setting type is unknown
* @FWUPD_BIOS_SETTING_KIND_ENUMERATION: BIOS setting that has enumerated possible
*values
* @FWUPD_BIOS_SETTING_KIND_INTEGER: BIOS setting that is an integer
* @FWUPD_BIOS_SETTING_KIND_STRING: BIOS setting that accepts a string
*
* The type of BIOS setting.
**/
typedef enum {
FWUPD_BIOS_SETTING_KIND_UNKNOWN = 0, /* Since: 1.8.4 */
FWUPD_BIOS_SETTING_KIND_ENUMERATION = 1, /* Since: 1.8.4 */
FWUPD_BIOS_SETTING_KIND_INTEGER = 2, /* Since: 1.8.4 */
FWUPD_BIOS_SETTING_KIND_STRING = 3, /* Since: 1.8.4 */
/*< private >*/
FWUPD_BIOS_SETTING_KIND_LAST = 4 /* perhaps increased in the future */
} FwupdBiosSettingKind;
FwupdBiosSetting *
fwupd_bios_setting_new(const gchar *name, const gchar *path);
gchar *
fwupd_bios_setting_to_string(FwupdBiosSetting *self);
gboolean
fwupd_bios_setting_get_read_only(FwupdBiosSetting *self);
void
fwupd_bios_setting_set_read_only(FwupdBiosSetting *self, gboolean val);
guint64
fwupd_bios_setting_get_upper_bound(FwupdBiosSetting *self);
guint64
fwupd_bios_setting_get_lower_bound(FwupdBiosSetting *self);
guint64
fwupd_bios_setting_get_scalar_increment(FwupdBiosSetting *self);
void
fwupd_bios_setting_set_upper_bound(FwupdBiosSetting *self, guint64 val);
void
fwupd_bios_setting_set_lower_bound(FwupdBiosSetting *self, guint64 val);
void
fwupd_bios_setting_set_scalar_increment(FwupdBiosSetting *self, guint64 val);
void
fwupd_bios_setting_set_kind(FwupdBiosSetting *self, FwupdBiosSettingKind type);
void
fwupd_bios_setting_set_name(FwupdBiosSetting *self, const gchar *name);
void
fwupd_bios_setting_set_path(FwupdBiosSetting *self, const gchar *path);
void
fwupd_bios_setting_set_description(FwupdBiosSetting *self, const gchar *description);
FwupdBiosSettingKind
fwupd_bios_setting_get_kind(FwupdBiosSetting *self);
const gchar *
fwupd_bios_setting_get_name(FwupdBiosSetting *self);
const gchar *
fwupd_bios_setting_get_path(FwupdBiosSetting *self);
const gchar *
fwupd_bios_setting_get_description(FwupdBiosSetting *self);
const gchar *
fwupd_bios_setting_map_possible_value(FwupdBiosSetting *self, const gchar *key, GError **error);
gboolean
fwupd_bios_setting_has_possible_value(FwupdBiosSetting *self, const gchar *val);
void
fwupd_bios_setting_add_possible_value(FwupdBiosSetting *self, const gchar *possible_value);
GPtrArray *
fwupd_bios_setting_get_possible_values(FwupdBiosSetting *self);
FwupdBiosSetting *
fwupd_bios_setting_from_variant(GVariant *value);
GPtrArray *
fwupd_bios_setting_array_from_variant(GVariant *value);
const gchar *
fwupd_bios_setting_get_current_value(FwupdBiosSetting *self);
void
fwupd_bios_setting_set_current_value(FwupdBiosSetting *self, const gchar *value);
const gchar *
fwupd_bios_setting_get_id(FwupdBiosSetting *self);
void
fwupd_bios_setting_set_id(FwupdBiosSetting *self, const gchar *id);
G_END_DECLS

View File

@ -888,22 +888,22 @@ fwupd_client_get_results(FwupdClient *self,
} }
static void static void
fwupd_client_modify_bios_attr_cb(GObject *source, GAsyncResult *res, gpointer user_data) fwupd_client_modify_bios_setting_cb(GObject *source, GAsyncResult *res, gpointer user_data)
{ {
FwupdClientHelper *helper = (FwupdClientHelper *)user_data; FwupdClientHelper *helper = (FwupdClientHelper *)user_data;
helper->ret = helper->ret =
fwupd_client_modify_bios_attr_finish(FWUPD_CLIENT(source), res, &helper->error); fwupd_client_modify_bios_setting_finish(FWUPD_CLIENT(source), res, &helper->error);
g_main_loop_quit(helper->loop); g_main_loop_quit(helper->loop);
} }
/** /**
* fwupd_client_modify_bios_attr * fwupd_client_modify_bios_setting
* @self: a #FwupdClient * @self: a #FwupdClient
* @settings: (transfer container): BIOS settings * @settings: (transfer container): BIOS settings
* @cancellable: (nullable): optional #GCancellable * @cancellable: (nullable): optional #GCancellable
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Modifies a BIOS attribute using kernel API. * Modifies a BIOS setting using kernel API.
* The daemon will only respond to this request with proper permissions. * The daemon will only respond to this request with proper permissions.
* *
* Returns: %TRUE for success * Returns: %TRUE for success
@ -911,7 +911,7 @@ fwupd_client_modify_bios_attr_cb(GObject *source, GAsyncResult *res, gpointer us
* Since: 1.8.4 * Since: 1.8.4
**/ **/
gboolean gboolean
fwupd_client_modify_bios_attr(FwupdClient *self, fwupd_client_modify_bios_setting(FwupdClient *self,
GHashTable *settings, GHashTable *settings,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
@ -929,10 +929,10 @@ fwupd_client_modify_bios_attr(FwupdClient *self,
/* call async version and run loop until complete */ /* call async version and run loop until complete */
helper = fwupd_client_helper_new(self); helper = fwupd_client_helper_new(self);
fwupd_client_modify_bios_attr_async(self, fwupd_client_modify_bios_setting_async(self,
settings, settings,
cancellable, cancellable,
fwupd_client_modify_bios_attr_cb, fwupd_client_modify_bios_setting_cb,
helper); helper);
g_main_loop_run(helper->loop); g_main_loop_run(helper->loop);
if (!helper->ret) { if (!helper->ret) {
@ -943,28 +943,28 @@ fwupd_client_modify_bios_attr(FwupdClient *self,
} }
static void static void
fwupd_client_get_bios_attrs_cb(GObject *source, GAsyncResult *res, gpointer user_data) fwupd_client_get_bios_settings_cb(GObject *source, GAsyncResult *res, gpointer user_data)
{ {
FwupdClientHelper *helper = (FwupdClientHelper *)user_data; FwupdClientHelper *helper = (FwupdClientHelper *)user_data;
helper->array = helper->array =
fwupd_client_get_bios_attrs_finish(FWUPD_CLIENT(source), res, &helper->error); fwupd_client_get_bios_settings_finish(FWUPD_CLIENT(source), res, &helper->error);
g_main_loop_quit(helper->loop); g_main_loop_quit(helper->loop);
} }
/** /**
* fwupd_client_get_bios_attrs: * fwupd_client_get_bios_settings:
* @self: a #FwupdClient * @self: a #FwupdClient
* @cancellable: (nullable): optional #GCancellable * @cancellable: (nullable): optional #GCancellable
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets all the BIOS attributes from the daemon. * Gets all the BIOS settings from the daemon.
* *
* Returns: (element-type FwupdBiosAttr) (transfer container): attributes * Returns: (element-type FwupdBiosSetting) (transfer container): attributes
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
GPtrArray * GPtrArray *
fwupd_client_get_bios_attrs(FwupdClient *self, GCancellable *cancellable, GError **error) fwupd_client_get_bios_settings(FwupdClient *self, GCancellable *cancellable, GError **error)
{ {
g_autoptr(FwupdClientHelper) helper = NULL; g_autoptr(FwupdClientHelper) helper = NULL;
@ -978,9 +978,9 @@ fwupd_client_get_bios_attrs(FwupdClient *self, GCancellable *cancellable, GError
/* call async version and run loop until complete */ /* call async version and run loop until complete */
helper = fwupd_client_helper_new(self); helper = fwupd_client_helper_new(self);
fwupd_client_get_bios_attrs_async(self, fwupd_client_get_bios_settings_async(self,
cancellable, cancellable,
fwupd_client_get_bios_attrs_cb, fwupd_client_get_bios_settings_cb,
helper); helper);
g_main_loop_run(helper->loop); g_main_loop_run(helper->loop);
if (helper->array == NULL) { if (helper->array == NULL) {

View File

@ -88,12 +88,12 @@ fwupd_client_get_results(FwupdClient *self,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) G_GNUC_WARN_UNUSED_RESULT; GError **error) G_GNUC_WARN_UNUSED_RESULT;
gboolean gboolean
fwupd_client_modify_bios_attr(FwupdClient *self, fwupd_client_modify_bios_setting(FwupdClient *self,
GHashTable *settings, GHashTable *settings,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
GPtrArray * GPtrArray *
fwupd_client_get_bios_attrs(FwupdClient *self, fwupd_client_get_bios_settings(FwupdClient *self,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) G_GNUC_WARN_UNUSED_RESULT; GError **error) G_GNUC_WARN_UNUSED_RESULT;
GPtrArray * GPtrArray *

View File

@ -20,7 +20,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include "fwupd-bios-attr-private.h" #include "fwupd-bios-setting-private.h"
#include "fwupd-client-private.h" #include "fwupd-client-private.h"
#include "fwupd-client-sync.h" #include "fwupd-client-sync.h"
#include "fwupd-common-private.h" #include "fwupd-common-private.h"
@ -1086,7 +1086,7 @@ fwupd_client_get_host_security_attrs_finish(FwupdClient *self, GAsyncResult *res
} }
static void static void
fwupd_client_modify_bios_attr_cb(GObject *source, GAsyncResult *res, gpointer user_data) fwupd_client_modify_bios_setting_cb(GObject *source, GAsyncResult *res, gpointer user_data)
{ {
g_autoptr(GTask) task = G_TASK(user_data); g_autoptr(GTask) task = G_TASK(user_data);
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
@ -1104,20 +1104,20 @@ fwupd_client_modify_bios_attr_cb(GObject *source, GAsyncResult *res, gpointer us
} }
/** /**
* fwupd_client_modify_bios_attr_async: * fwupd_client_modify_bios_setting_async:
* @self: a #FwupdClient * @self: a #FwupdClient
* @settings: (transfer container): BIOS settings * @settings: (transfer container): BIOS settings
* @cancellable: (nullable): optional #GCancellable * @cancellable: (nullable): optional #GCancellable
* @callback: the function to run on completion * @callback: the function to run on completion
* @callback_data: the data to pass to @callback * @callback_data: the data to pass to @callback
* *
* Modifies a BIOS attribute using kernel API. * Modifies a BIOS setting using kernel API.
* The daemon will only respond to this request with proper permissions. * The daemon will only respond to this request with proper permissions.
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
void void
fwupd_client_modify_bios_attr_async(FwupdClient *self, fwupd_client_modify_bios_setting_async(FwupdClient *self,
GHashTable *settings, GHashTable *settings,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
@ -1145,29 +1145,29 @@ fwupd_client_modify_bios_attr_async(FwupdClient *self,
g_variant_builder_add(&builder, "{ss}", (const gchar *)key, (const gchar *)value); g_variant_builder_add(&builder, "{ss}", (const gchar *)key, (const gchar *)value);
} }
g_dbus_proxy_call(priv->proxy, g_dbus_proxy_call(priv->proxy,
"SetBiosAttrs", "SetBiosSettings",
g_variant_new("(a{ss})", &builder), g_variant_new("(a{ss})", &builder),
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
FWUPD_CLIENT_DBUS_PROXY_TIMEOUT, FWUPD_CLIENT_DBUS_PROXY_TIMEOUT,
cancellable, cancellable,
fwupd_client_modify_bios_attr_cb, fwupd_client_modify_bios_setting_cb,
g_steal_pointer(&task)); g_steal_pointer(&task));
} }
/** /**
* fwupd_client_modify_bios_attr_finish: * fwupd_client_modify_bios_setting_finish:
* @self: a #FwupdClient * @self: a #FwupdClient
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of [method@FwupdClient.modify_bios_attr_async]. * Gets the result of [method@FwupdClient.modify_bios_setting_async].
* *
* Returns: %TRUE for success * Returns: %TRUE for success
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
gboolean gboolean
fwupd_client_modify_bios_attr_finish(FwupdClient *self, GAsyncResult *res, GError **error) fwupd_client_modify_bios_setting_finish(FwupdClient *self, GAsyncResult *res, GError **error)
{ {
g_return_val_if_fail(FWUPD_IS_CLIENT(self), FALSE); g_return_val_if_fail(FWUPD_IS_CLIENT(self), FALSE);
g_return_val_if_fail(g_task_is_valid(res, self), FALSE); g_return_val_if_fail(g_task_is_valid(res, self), FALSE);
@ -1176,7 +1176,7 @@ fwupd_client_modify_bios_attr_finish(FwupdClient *self, GAsyncResult *res, GErro
} }
static void static void
fwupd_client_get_bios_attrs_cb(GObject *source, GAsyncResult *res, gpointer user_data) fwupd_client_get_bios_settings_cb(GObject *source, GAsyncResult *res, gpointer user_data)
{ {
g_autoptr(GTask) task = G_TASK(user_data); g_autoptr(GTask) task = G_TASK(user_data);
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
@ -1191,12 +1191,12 @@ fwupd_client_get_bios_attrs_cb(GObject *source, GAsyncResult *res, gpointer user
/* success */ /* success */
g_task_return_pointer(task, g_task_return_pointer(task,
fwupd_bios_attr_array_from_variant(val), fwupd_bios_setting_array_from_variant(val),
(GDestroyNotify)g_ptr_array_unref); (GDestroyNotify)g_ptr_array_unref);
} }
/** /**
* fwupd_client_get_bios_attrs_async: * fwupd_client_get_bios_settings_async:
* @self: a #FwupdClient * @self: a #FwupdClient
* @cancellable: (nullable): optional #GCancellable * @cancellable: (nullable): optional #GCancellable
* @callback: the function to run on completion * @callback: the function to run on completion
@ -1210,7 +1210,7 @@ fwupd_client_get_bios_attrs_cb(GObject *source, GAsyncResult *res, gpointer user
* Since: 1.8.4 * Since: 1.8.4
**/ **/
void void
fwupd_client_get_bios_attrs_async(FwupdClient *self, fwupd_client_get_bios_settings_async(FwupdClient *self,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer callback_data) gpointer callback_data)
@ -1225,29 +1225,29 @@ fwupd_client_get_bios_attrs_async(FwupdClient *self,
/* call into daemon */ /* call into daemon */
task = g_task_new(self, cancellable, callback, callback_data); task = g_task_new(self, cancellable, callback, callback_data);
g_dbus_proxy_call(priv->proxy, g_dbus_proxy_call(priv->proxy,
"GetBiosAttrs", "GetBiosSettings",
NULL, NULL,
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
FWUPD_CLIENT_DBUS_PROXY_TIMEOUT, FWUPD_CLIENT_DBUS_PROXY_TIMEOUT,
cancellable, cancellable,
fwupd_client_get_bios_attrs_cb, fwupd_client_get_bios_settings_cb,
g_steal_pointer(&task)); g_steal_pointer(&task));
} }
/** /**
* fwupd_client_get_bios_attrs_finish: * fwupd_client_get_bios_settings_finish:
* @self: a #FwupdClient * @self: a #FwupdClient
* @res: the asynchronous result * @res: the asynchronous result
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Gets the result of [method@FwupdClient.get_bios_attrs_async]. * Gets the result of [method@FwupdClient.get_bios_settings_async].
* *
* Returns: (element-type FwupdBiosAttr) (transfer container): attributes * Returns: (element-type FwupdBiosSetting) (transfer container): attributes
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
GPtrArray * GPtrArray *
fwupd_client_get_bios_attrs_finish(FwupdClient *self, GAsyncResult *res, GError **error) fwupd_client_get_bios_settings_finish(FwupdClient *self, GAsyncResult *res, GError **error)
{ {
g_return_val_if_fail(FWUPD_IS_CLIENT(self), NULL); g_return_val_if_fail(FWUPD_IS_CLIENT(self), NULL);
g_return_val_if_fail(g_task_is_valid(res, self), NULL); g_return_val_if_fail(g_task_is_valid(res, self), NULL);

View File

@ -220,20 +220,20 @@ fwupd_client_get_results_finish(FwupdClient *self,
GAsyncResult *res, GAsyncResult *res,
GError **error) G_GNUC_WARN_UNUSED_RESULT; GError **error) G_GNUC_WARN_UNUSED_RESULT;
void void
fwupd_client_modify_bios_attr_async(FwupdClient *self, fwupd_client_modify_bios_setting_async(FwupdClient *self,
GHashTable *settings, GHashTable *settings,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer callback_data); gpointer callback_data);
gboolean gboolean
fwupd_client_modify_bios_attr_finish(FwupdClient *self, GAsyncResult *res, GError **error); fwupd_client_modify_bios_setting_finish(FwupdClient *self, GAsyncResult *res, GError **error);
void void
fwupd_client_get_bios_attrs_async(FwupdClient *self, fwupd_client_get_bios_settings_async(FwupdClient *self,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer callback_data); gpointer callback_data);
GPtrArray * GPtrArray *
fwupd_client_get_bios_attrs_finish(FwupdClient *self, fwupd_client_get_bios_settings_finish(FwupdClient *self,
GAsyncResult *res, GAsyncResult *res,
GError **error) G_GNUC_WARN_UNUSED_RESULT; GError **error) G_GNUC_WARN_UNUSED_RESULT;
void void

View File

@ -509,78 +509,78 @@ G_BEGIN_DECLS
**/ **/
#define FWUPD_RESULT_KEY_BATTERY_THRESHOLD "BatteryThreshold" #define FWUPD_RESULT_KEY_BATTERY_THRESHOLD "BatteryThreshold"
/** /**
* FWUPD_RESULT_KEY_BIOS_ATTR_ID: * FWUPD_RESULT_KEY_BIOS_SETTING_ID:
* *
* Result key to represent the unique identifier of the BIOS attribute. * Result key to represent the unique identifier of the BIOS setting.
* *
* The D-Bus type signature string is 's' i.e. a string. * The D-Bus type signature string is 's' i.e. a string.
**/ **/
#define FWUPD_RESULT_KEY_BIOS_ATTR_ID "BiosAttrId" #define FWUPD_RESULT_KEY_BIOS_SETTING_ID "BiosSettingId"
/** /**
* FWUPD_RESULT_KEY_BIOS_ATTR_TARGET_VALUE: * FWUPD_RESULT_KEY_BIOS_SETTING_TARGET_VALUE:
* *
* Result key to represent the value that would enable this attribute. * Result key to represent the value that would enable this attribute.
* *
* The D-Bus type signature string is 's' i.e. a string. * The D-Bus type signature string is 's' i.e. a string.
**/ **/
#define FWUPD_RESULT_KEY_BIOS_ATTR_TARGET_VALUE "BiosAttrTargetValue" #define FWUPD_RESULT_KEY_BIOS_SETTING_TARGET_VALUE "BiosSettingTargetValue"
/** /**
* FWUPD_RESULT_KEY_BIOS_ATTR_CURRENT_VALUE: * FWUPD_RESULT_KEY_BIOS_SETTING_CURRENT_VALUE:
* *
* Result key to represent the current value of BIOS attribute. * Result key to represent the current value of BIOS setting.
* *
* The D-Bus type signature string is 's' i.e. a string. * The D-Bus type signature string is 's' i.e. a string.
**/ **/
#define FWUPD_RESULT_KEY_BIOS_ATTR_CURRENT_VALUE "BiosAttrCurrentValue" #define FWUPD_RESULT_KEY_BIOS_SETTING_CURRENT_VALUE "BiosSettingCurrentValue"
/** /**
* FWUPD_RESULT_KEY_BIOS_ATTR_TYPE: * FWUPD_RESULT_KEY_BIOS_SETTING_TYPE:
* *
* Result key to represent the type of BIOS attribute. * Result key to represent the type of BIOS setting.
* 0 is invalid, 1+ represent an attribute type * 0 is invalid, 1+ represent an attribute type
* *
* The D-Bus type signature string is 't' i.e. a unsigned 64 bit integer. * The D-Bus type signature string is 't' i.e. a unsigned 64 bit integer.
**/ **/
#define FWUPD_RESULT_KEY_BIOS_ATTR_TYPE "BiosAttrType" #define FWUPD_RESULT_KEY_BIOS_SETTING_TYPE "BiosSettingType"
/** /**
* FWUPD_RESULT_KEY_BIOS_ATTR_POSSIBLE_VALUES: * FWUPD_RESULT_KEY_BIOS_SETTING_POSSIBLE_VALUES:
* *
* Result key to represent possible values * Result key to represent possible values
* *
* The D-Bus type signature string is 'as' i.e. an array of strings. * The D-Bus type signature string is 'as' i.e. an array of strings.
**/ **/
#define FWUPD_RESULT_KEY_BIOS_ATTR_POSSIBLE_VALUES "BiosAttrPossibleValues" #define FWUPD_RESULT_KEY_BIOS_SETTING_POSSIBLE_VALUES "BiosSettingPossibleValues"
/** /**
* FWUPD_RESULT_KEY_BIOS_ATTR_LOWER_BOUND: * FWUPD_RESULT_KEY_BIOS_SETTING_LOWER_BOUND:
* *
* Result key to represent the upper bound for an integer BIOS attribute. * Result key to represent the upper bound for an integer BIOS setting.
* or minimum length for string BIOS attribute. * or minimum length for string BIOS setting.
* The D-Bus type signature string is 't' i.e. a unsigned 64 bit integer. * The D-Bus type signature string is 't' i.e. a unsigned 64 bit integer.
**/ **/
#define FWUPD_RESULT_KEY_BIOS_ATTR_LOWER_BOUND "BiosAttrLowerBound" #define FWUPD_RESULT_KEY_BIOS_SETTING_LOWER_BOUND "BiosSettingLowerBound"
/** /**
* FWUPD_RESULT_KEY_BIOS_ATTR_UPPER_BOUND: * FWUPD_RESULT_KEY_BIOS_SETTING_UPPER_BOUND:
* *
* Result key to represent the lower bound for an integer BIOS attribute * Result key to represent the lower bound for an integer BIOS setting
* or maximum length for string BIOS attribute. * or maximum length for string BIOS setting.
* *
* The D-Bus type signature string is 't' i.e. a unsigned 64 bit integer. * The D-Bus type signature string is 't' i.e. a unsigned 64 bit integer.
**/ **/
#define FWUPD_RESULT_KEY_BIOS_ATTR_UPPER_BOUND "BiosAttrUpperBound" #define FWUPD_RESULT_KEY_BIOS_SETTING_UPPER_BOUND "BiosSettingUpperBound"
/** /**
* FWUPD_RESULT_KEY_BIOS_ATTR_SCALAR_INCREMENT: * FWUPD_RESULT_KEY_BIOS_SETTING_SCALAR_INCREMENT:
* *
* Result key to represent the scalar increment for an integer BIOS attribute. * Result key to represent the scalar increment for an integer BIOS setting.
* *
* The D-Bus type signature string is 't' i.e. a unsigned 64 bit integer. * The D-Bus type signature string is 't' i.e. a unsigned 64 bit integer.
**/ **/
#define FWUPD_RESULT_KEY_BIOS_ATTR_SCALAR_INCREMENT "BiosAttrScalarIncrement" #define FWUPD_RESULT_KEY_BIOS_SETTING_SCALAR_INCREMENT "BiosSettingScalarIncrement"
/** /**
* FWUPD_RESULT_KEY_BIOS_ATTR_READ_ONLY: * FWUPD_RESULT_KEY_BIOS_SETTING_READ_ONLY:
* *
* Result key to represent whether BIOS attribute is read only * Result key to represent whether BIOS setting is read only
* *
* The D-Bus type signature string is 'b' i.e. a boolean. * The D-Bus type signature string is 'b' i.e. a boolean.
**/ **/
#define FWUPD_RESULT_KEY_BIOS_ATTR_READ_ONLY "BiosAttrReadOnly" #define FWUPD_RESULT_KEY_BIOS_SETTING_READ_ONLY "BiosSettingReadOnly"
G_END_DECLS G_END_DECLS

View File

@ -38,9 +38,9 @@ typedef struct {
FwupdSecurityAttrResult result; FwupdSecurityAttrResult result;
FwupdSecurityAttrResult result_fallback; FwupdSecurityAttrResult result_fallback;
FwupdSecurityAttrFlags flags; FwupdSecurityAttrFlags flags;
gchar *bios_attr_id; gchar *bios_setting_id;
gchar *bios_attr_target_value; gchar *bios_setting_target_value;
gchar *bios_attr_current_value; gchar *bios_setting_current_value;
} FwupdSecurityAttrPrivate; } FwupdSecurityAttrPrivate;
G_DEFINE_TYPE_WITH_PRIVATE(FwupdSecurityAttr, fwupd_security_attr, G_TYPE_OBJECT) G_DEFINE_TYPE_WITH_PRIVATE(FwupdSecurityAttr, fwupd_security_attr, G_TYPE_OBJECT)
@ -227,43 +227,43 @@ fwupd_security_attr_flag_to_suffix(FwupdSecurityAttrFlags flag)
} }
/** /**
* fwupd_security_attr_get_bios_attr_id: * fwupd_security_attr_get_bios_setting_id:
* @self: a #FwupdSecurityAttr * @self: a #FwupdSecurityAttr
* *
* Gets the #FwupdBiosAttr that can be used to improve this * Gets the #FwupdBiosSetting that can be used to improve this
* #FwupdSecurityAttr. * #FwupdSecurityAttr.
* *
* Returns: The unique ID used for #FwupdBiosAttr or NULL * Returns: The unique ID used for #FwupdBiosSetting or NULL
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
const gchar * const gchar *
fwupd_security_attr_get_bios_attr_id(FwupdSecurityAttr *self) fwupd_security_attr_get_bios_setting_id(FwupdSecurityAttr *self)
{ {
FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self); FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(FWUPD_IS_SECURITY_ATTR(self), NULL); g_return_val_if_fail(FWUPD_IS_SECURITY_ATTR(self), NULL);
return priv->bios_attr_id; return priv->bios_setting_id;
} }
/** /**
* fwupd_security_attr_set_bios_attr_id: * fwupd_security_attr_set_bios_setting_id:
* @self: a #FwupdSecurityAttr * @self: a #FwupdSecurityAttr
* @id: Unique identifier used for #FwupdBiosAttr * @id: Unique identifier used for #FwupdBiosSetting
* *
* Sets the #FwupdBiosAttr that can be used to improve this * Sets the #FwupdBiosSetting that can be used to improve this
* #FwupdSecurityAttr. * #FwupdSecurityAttr.
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
void void
fwupd_security_attr_set_bios_attr_id(FwupdSecurityAttr *self, const gchar *id) fwupd_security_attr_set_bios_setting_id(FwupdSecurityAttr *self, const gchar *id)
{ {
FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self); FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self);
g_return_if_fail(FWUPD_IS_SECURITY_ATTR(self)); g_return_if_fail(FWUPD_IS_SECURITY_ATTR(self));
if (priv->bios_attr_id == id) if (priv->bios_setting_id == id)
return; return;
g_free(priv->bios_attr_id); g_free(priv->bios_setting_id);
priv->bios_attr_id = g_strdup(id); priv->bios_setting_id = g_strdup(id);
} }
/** /**
@ -503,7 +503,7 @@ fwupd_security_attr_set_name(FwupdSecurityAttr *self, const gchar *name)
} }
/** /**
* fwupd_security_attr_get_bios_attr_target_value: * fwupd_security_attr_get_bios_setting_target_value:
* @self: a #FwupdSecurityAttr * @self: a #FwupdSecurityAttr
* *
* Gets the value that when written to an attribute would activate it or satisfy * Gets the value that when written to an attribute would activate it or satisfy
@ -514,15 +514,15 @@ fwupd_security_attr_set_name(FwupdSecurityAttr *self, const gchar *name)
* Since: 1.8.4 * Since: 1.8.4
**/ **/
const gchar * const gchar *
fwupd_security_attr_get_bios_attr_target_value(FwupdSecurityAttr *self) fwupd_security_attr_get_bios_setting_target_value(FwupdSecurityAttr *self)
{ {
FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self); FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(FWUPD_IS_SECURITY_ATTR(self), NULL); g_return_val_if_fail(FWUPD_IS_SECURITY_ATTR(self), NULL);
return priv->bios_attr_target_value; return priv->bios_setting_target_value;
} }
/** /**
* fwupd_security_attr_set_bios_attr_target_value: * fwupd_security_attr_set_bios_setting_target_value:
* @self: a #FwupdSecurityAttr * @self: a #FwupdSecurityAttr
* @value: The string to set target value to * @value: The string to set target value to
* *
@ -531,56 +531,56 @@ fwupd_security_attr_get_bios_attr_target_value(FwupdSecurityAttr *self)
* Since: 1.8.4 * Since: 1.8.4
**/ **/
void void
fwupd_security_attr_set_bios_attr_target_value(FwupdSecurityAttr *self, const gchar *value) fwupd_security_attr_set_bios_setting_target_value(FwupdSecurityAttr *self, const gchar *value)
{ {
FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self); FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self);
/* not changed */ /* not changed */
if (g_strcmp0(priv->bios_attr_target_value, value) == 0) if (g_strcmp0(priv->bios_setting_target_value, value) == 0)
return; return;
g_free(priv->bios_attr_target_value); g_free(priv->bios_setting_target_value);
priv->bios_attr_target_value = g_strdup(value); priv->bios_setting_target_value = g_strdup(value);
} }
/** /**
* fwupd_security_attr_get_bios_attr_current_value: * fwupd_security_attr_get_bios_setting_current_value:
* @self: a #FwupdSecurityAttr * @self: a #FwupdSecurityAttr
* *
* Gets the current value of the BIOS attribute that can be changed. * Gets the current value of the BIOS setting that can be changed.
* *
* Returns: the current value of the attribute. * Returns: the current value of the attribute.
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
const gchar * const gchar *
fwupd_security_attr_get_bios_attr_current_value(FwupdSecurityAttr *self) fwupd_security_attr_get_bios_setting_current_value(FwupdSecurityAttr *self)
{ {
FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self); FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(FWUPD_IS_SECURITY_ATTR(self), NULL); g_return_val_if_fail(FWUPD_IS_SECURITY_ATTR(self), NULL);
return priv->bios_attr_current_value; return priv->bios_setting_current_value;
} }
/** /**
* fwupd_security_attr_set_bios_attr_current_value: * fwupd_security_attr_set_bios_setting_current_value:
* @self: a #FwupdSecurityAttr * @self: a #FwupdSecurityAttr
* @value: The string to set current value to * @value: The string to set current value to
* *
* Sets the current value of the BIOS attribute that can be changed. * Sets the current value of the BIOS setting that can be changed.
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
void void
fwupd_security_attr_set_bios_attr_current_value(FwupdSecurityAttr *self, const gchar *value) fwupd_security_attr_set_bios_setting_current_value(FwupdSecurityAttr *self, const gchar *value)
{ {
FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self); FwupdSecurityAttrPrivate *priv = GET_PRIVATE(self);
/* not changed */ /* not changed */
if (g_strcmp0(priv->bios_attr_current_value, value) == 0) if (g_strcmp0(priv->bios_setting_current_value, value) == 0)
return; return;
g_free(priv->bios_attr_current_value); g_free(priv->bios_setting_current_value);
priv->bios_attr_current_value = g_strdup(value); priv->bios_setting_current_value = g_strdup(value);
} }
/** /**
@ -1096,23 +1096,23 @@ fwupd_security_attr_to_variant(FwupdSecurityAttr *self)
FWUPD_RESULT_KEY_METADATA, FWUPD_RESULT_KEY_METADATA,
fwupd_hash_kv_to_variant(priv->metadata)); fwupd_hash_kv_to_variant(priv->metadata));
} }
if (priv->bios_attr_id != NULL) { if (priv->bios_setting_id != NULL) {
g_variant_builder_add(&builder, g_variant_builder_add(&builder,
"{sv}", "{sv}",
FWUPD_RESULT_KEY_BIOS_ATTR_ID, FWUPD_RESULT_KEY_BIOS_SETTING_ID,
g_variant_new_string(priv->bios_attr_id)); g_variant_new_string(priv->bios_setting_id));
} }
if (priv->bios_attr_target_value != NULL) { if (priv->bios_setting_target_value != NULL) {
g_variant_builder_add(&builder, g_variant_builder_add(&builder,
"{sv}", "{sv}",
FWUPD_RESULT_KEY_BIOS_ATTR_TARGET_VALUE, FWUPD_RESULT_KEY_BIOS_SETTING_TARGET_VALUE,
g_variant_new_string(priv->bios_attr_target_value)); g_variant_new_string(priv->bios_setting_target_value));
} }
if (priv->bios_attr_current_value != NULL) { if (priv->bios_setting_current_value != NULL) {
g_variant_builder_add(&builder, g_variant_builder_add(&builder,
"{sv}", "{sv}",
FWUPD_RESULT_KEY_BIOS_ATTR_CURRENT_VALUE, FWUPD_RESULT_KEY_BIOS_SETTING_CURRENT_VALUE,
g_variant_new_string(priv->bios_attr_current_value)); g_variant_new_string(priv->bios_setting_current_value));
} }
return g_variant_new("a{sv}", &builder); return g_variant_new("a{sv}", &builder);
} }
@ -1226,17 +1226,19 @@ fwupd_security_attr_from_key_value(FwupdSecurityAttr *self, const gchar *key, GV
priv->metadata = fwupd_variant_to_hash_kv(value); priv->metadata = fwupd_variant_to_hash_kv(value);
return; return;
} }
if (g_strcmp0(key, FWUPD_RESULT_KEY_BIOS_ATTR_ID) == 0) { if (g_strcmp0(key, FWUPD_RESULT_KEY_BIOS_SETTING_ID) == 0) {
fwupd_security_attr_set_bios_attr_id(self, g_variant_get_string(value, NULL)); fwupd_security_attr_set_bios_setting_id(self, g_variant_get_string(value, NULL));
return; return;
} }
if (g_strcmp0(key, FWUPD_RESULT_KEY_BIOS_ATTR_TARGET_VALUE) == 0) { if (g_strcmp0(key, FWUPD_RESULT_KEY_BIOS_SETTING_TARGET_VALUE) == 0) {
fwupd_security_attr_set_bios_attr_target_value(self, fwupd_security_attr_set_bios_setting_target_value(
self,
g_variant_get_string(value, NULL)); g_variant_get_string(value, NULL));
return; return;
} }
if (g_strcmp0(key, FWUPD_RESULT_KEY_BIOS_ATTR_CURRENT_VALUE) == 0) { if (g_strcmp0(key, FWUPD_RESULT_KEY_BIOS_SETTING_CURRENT_VALUE) == 0) {
fwupd_security_attr_set_bios_attr_current_value(self, fwupd_security_attr_set_bios_setting_current_value(
self,
g_variant_get_string(value, NULL)); g_variant_get_string(value, NULL));
return; return;
} }
@ -1321,18 +1323,20 @@ fwupd_security_attr_from_json(FwupdSecurityAttr *self, JsonNode *json_node, GErr
fwupd_security_attr_set_created( fwupd_security_attr_set_created(
self, self,
json_object_get_int_member_with_default(obj, FWUPD_RESULT_KEY_CREATED, 0)); json_object_get_int_member_with_default(obj, FWUPD_RESULT_KEY_CREATED, 0));
fwupd_security_attr_set_bios_attr_id( fwupd_security_attr_set_bios_setting_id(
self,
json_object_get_string_member_with_default(obj, FWUPD_RESULT_KEY_BIOS_ATTR_ID, NULL));
fwupd_security_attr_set_bios_attr_target_value(
self, self,
json_object_get_string_member_with_default(obj, json_object_get_string_member_with_default(obj,
FWUPD_RESULT_KEY_BIOS_ATTR_TARGET_VALUE, FWUPD_RESULT_KEY_BIOS_SETTING_ID,
NULL)); NULL));
fwupd_security_attr_set_bios_attr_current_value( fwupd_security_attr_set_bios_setting_target_value(
self, self,
json_object_get_string_member_with_default(obj, json_object_get_string_member_with_default(obj,
FWUPD_RESULT_KEY_BIOS_ATTR_CURRENT_VALUE, FWUPD_RESULT_KEY_BIOS_SETTING_TARGET_VALUE,
NULL));
fwupd_security_attr_set_bios_setting_current_value(
self,
json_object_get_string_member_with_default(obj,
FWUPD_RESULT_KEY_BIOS_SETTING_CURRENT_VALUE,
NULL)); NULL));
/* also optional */ /* also optional */
@ -1413,12 +1417,14 @@ fwupd_security_attr_to_json(FwupdSecurityAttr *self, JsonBuilder *builder)
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_PLUGIN, priv->plugin); fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_PLUGIN, priv->plugin);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_URI, priv->url); fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_URI, priv->url);
fwupd_common_json_add_string(builder, fwupd_common_json_add_string(builder,
FWUPD_RESULT_KEY_BIOS_ATTR_TARGET_VALUE, FWUPD_RESULT_KEY_BIOS_SETTING_TARGET_VALUE,
priv->bios_attr_target_value); priv->bios_setting_target_value);
fwupd_common_json_add_string(builder, fwupd_common_json_add_string(builder,
FWUPD_RESULT_KEY_BIOS_ATTR_CURRENT_VALUE, FWUPD_RESULT_KEY_BIOS_SETTING_CURRENT_VALUE,
priv->bios_attr_current_value); priv->bios_setting_current_value);
fwupd_common_json_add_string(builder, FWUPD_RESULT_KEY_BIOS_ATTR_ID, priv->bios_attr_id); fwupd_common_json_add_string(builder,
FWUPD_RESULT_KEY_BIOS_SETTING_ID,
priv->bios_setting_id);
if (priv->flags != FWUPD_SECURITY_ATTR_FLAG_NONE) { if (priv->flags != FWUPD_SECURITY_ATTR_FLAG_NONE) {
json_builder_set_member_name(builder, FWUPD_RESULT_KEY_FLAGS); json_builder_set_member_name(builder, FWUPD_RESULT_KEY_FLAGS);
@ -1487,13 +1493,13 @@ fwupd_security_attr_to_string(FwupdSecurityAttr *self)
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_DESCRIPTION, priv->description); fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_DESCRIPTION, priv->description);
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_PLUGIN, priv->plugin); fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_PLUGIN, priv->plugin);
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_URI, priv->url); fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_URI, priv->url);
fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_BIOS_ATTR_ID, priv->bios_attr_id); fwupd_pad_kv_str(str, FWUPD_RESULT_KEY_BIOS_SETTING_ID, priv->bios_setting_id);
fwupd_pad_kv_str(str, fwupd_pad_kv_str(str,
FWUPD_RESULT_KEY_BIOS_ATTR_TARGET_VALUE, FWUPD_RESULT_KEY_BIOS_SETTING_TARGET_VALUE,
priv->bios_attr_target_value); priv->bios_setting_target_value);
fwupd_pad_kv_str(str, fwupd_pad_kv_str(str,
FWUPD_RESULT_KEY_BIOS_ATTR_CURRENT_VALUE, FWUPD_RESULT_KEY_BIOS_SETTING_CURRENT_VALUE,
priv->bios_attr_current_value); priv->bios_setting_current_value);
for (guint i = 0; i < priv->obsoletes->len; i++) { for (guint i = 0; i < priv->obsoletes->len; i++) {
const gchar *appstream_id = g_ptr_array_index(priv->obsoletes, i); const gchar *appstream_id = g_ptr_array_index(priv->obsoletes, i);
@ -1540,9 +1546,9 @@ fwupd_security_attr_finalize(GObject *object)
if (priv->metadata != NULL) if (priv->metadata != NULL)
g_hash_table_unref(priv->metadata); g_hash_table_unref(priv->metadata);
g_free(priv->bios_attr_id); g_free(priv->bios_setting_id);
g_free(priv->bios_attr_target_value); g_free(priv->bios_setting_target_value);
g_free(priv->bios_attr_current_value); g_free(priv->bios_setting_current_value);
g_free(priv->appstream_id); g_free(priv->appstream_id);
g_free(priv->name); g_free(priv->name);
g_free(priv->title); g_free(priv->title);
@ -1661,7 +1667,7 @@ fwupd_security_attr_copy(FwupdSecurityAttr *self)
fwupd_security_attr_set_flags(new, priv->flags); fwupd_security_attr_set_flags(new, priv->flags);
fwupd_security_attr_set_result(new, priv->result); fwupd_security_attr_set_result(new, priv->result);
fwupd_security_attr_set_created(new, priv->created); fwupd_security_attr_set_created(new, priv->created);
fwupd_security_attr_set_bios_attr_id(new, priv->bios_attr_id); fwupd_security_attr_set_bios_setting_id(new, priv->bios_setting_id);
for (guint i = 0; i < priv->guids->len; i++) { for (guint i = 0; i < priv->guids->len; i++) {
const gchar *guid = g_ptr_array_index(priv->guids, i); const gchar *guid = g_ptr_array_index(priv->guids, i);

View File

@ -127,17 +127,17 @@ gchar *
fwupd_security_attr_to_string(FwupdSecurityAttr *self); fwupd_security_attr_to_string(FwupdSecurityAttr *self);
const gchar * const gchar *
fwupd_security_attr_get_bios_attr_id(FwupdSecurityAttr *self); fwupd_security_attr_get_bios_setting_id(FwupdSecurityAttr *self);
void void
fwupd_security_attr_set_bios_attr_id(FwupdSecurityAttr *self, const gchar *id); fwupd_security_attr_set_bios_setting_id(FwupdSecurityAttr *self, const gchar *id);
const gchar * const gchar *
fwupd_security_attr_get_bios_attr_target_value(FwupdSecurityAttr *self); fwupd_security_attr_get_bios_setting_target_value(FwupdSecurityAttr *self);
void void
fwupd_security_attr_set_bios_attr_target_value(FwupdSecurityAttr *self, const gchar *value); fwupd_security_attr_set_bios_setting_target_value(FwupdSecurityAttr *self, const gchar *value);
const gchar * const gchar *
fwupd_security_attr_get_bios_attr_current_value(FwupdSecurityAttr *self); fwupd_security_attr_get_bios_setting_current_value(FwupdSecurityAttr *self);
void void
fwupd_security_attr_set_bios_attr_current_value(FwupdSecurityAttr *self, const gchar *value); fwupd_security_attr_set_bios_setting_current_value(FwupdSecurityAttr *self, const gchar *value);
const gchar * const gchar *
fwupd_security_attr_get_appstream_id(FwupdSecurityAttr *self); fwupd_security_attr_get_appstream_id(FwupdSecurityAttr *self);

View File

@ -12,7 +12,7 @@
#include <fnmatch.h> #include <fnmatch.h>
#endif #endif
#include "fwupd-bios-attr-private.h" #include "fwupd-bios-setting-private.h"
#include "fwupd-client-sync.h" #include "fwupd-client-sync.h"
#include "fwupd-client.h" #include "fwupd-client.h"
#include "fwupd-common.h" #include "fwupd-common.h"
@ -1218,8 +1218,8 @@ fwupd_attr_to_json_string(GObject *attr, GError **error)
json_builder_begin_object(builder); json_builder_begin_object(builder);
if (FWUPD_IS_SECURITY_ATTR(attr)) if (FWUPD_IS_SECURITY_ATTR(attr))
fwupd_security_attr_to_json(FWUPD_SECURITY_ATTR(attr), builder); fwupd_security_attr_to_json(FWUPD_SECURITY_ATTR(attr), builder);
else if (FWUPD_IS_BIOS_ATTR(attr)) else if (FWUPD_IS_BIOS_SETTING(attr))
fwupd_bios_attr_to_json(FWUPD_BIOS_ATTR(attr), builder); fwupd_bios_setting_to_json(FWUPD_BIOS_SETTING(attr), builder);
json_builder_end_object(builder); json_builder_end_object(builder);
json_root = json_builder_get_root(builder); json_root = json_builder_get_root(builder);
json_generator = json_generator_new(); json_generator = json_generator_new();
@ -1377,7 +1377,7 @@ fwupd_security_attr_func(void)
} }
static void static void
fwupd_bios_attrs_func(void) fwupd_bios_settings_func(void)
{ {
gboolean ret; gboolean ret;
g_autofree gchar *str1 = NULL; g_autofree gchar *str1 = NULL;
@ -1385,57 +1385,59 @@ fwupd_bios_attrs_func(void)
g_autofree gchar *str3 = NULL; g_autofree gchar *str3 = NULL;
g_autofree gchar *json1 = NULL; g_autofree gchar *json1 = NULL;
g_autofree gchar *json2 = NULL; g_autofree gchar *json2 = NULL;
g_autoptr(FwupdBiosAttr) attr1 = fwupd_bios_attr_new("foo", "/path/to/bar"); g_autoptr(FwupdBiosSetting) attr1 = fwupd_bios_setting_new("foo", "/path/to/bar");
g_autoptr(FwupdBiosAttr) attr2 = NULL; g_autoptr(FwupdBiosSetting) attr2 = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(GVariant) data1 = NULL; g_autoptr(GVariant) data1 = NULL;
g_autoptr(GVariant) data2 = NULL; g_autoptr(GVariant) data2 = NULL;
g_autoptr(JsonParser) parser = json_parser_new(); g_autoptr(JsonParser) parser = json_parser_new();
g_assert_cmpstr(fwupd_bios_attr_get_name(attr1), ==, "foo"); g_assert_cmpstr(fwupd_bios_setting_get_name(attr1), ==, "foo");
fwupd_bios_attr_set_name(attr1, "UEFISecureBoot"); fwupd_bios_setting_set_name(attr1, "UEFISecureBoot");
g_assert_cmpstr(fwupd_bios_attr_get_name(attr1), ==, "UEFISecureBoot"); g_assert_cmpstr(fwupd_bios_setting_get_name(attr1), ==, "UEFISecureBoot");
fwupd_bios_attr_set_kind(attr1, FWUPD_BIOS_ATTR_KIND_ENUMERATION); fwupd_bios_setting_set_kind(attr1, FWUPD_BIOS_SETTING_KIND_ENUMERATION);
g_assert_cmpint(fwupd_bios_attr_get_kind(attr1), ==, FWUPD_BIOS_ATTR_KIND_ENUMERATION); g_assert_cmpint(fwupd_bios_setting_get_kind(attr1),
==,
FWUPD_BIOS_SETTING_KIND_ENUMERATION);
fwupd_bios_attr_set_description(attr1, "Controls Secure boot"); fwupd_bios_setting_set_description(attr1, "Controls Secure boot");
g_assert_cmpstr(fwupd_bios_attr_get_description(attr1), ==, "Controls Secure boot"); g_assert_cmpstr(fwupd_bios_setting_get_description(attr1), ==, "Controls Secure boot");
fwupd_bios_attr_set_current_value(attr1, "Disabled"); fwupd_bios_setting_set_current_value(attr1, "Disabled");
g_assert_cmpstr(fwupd_bios_attr_get_current_value(attr1), ==, "Disabled"); g_assert_cmpstr(fwupd_bios_setting_get_current_value(attr1), ==, "Disabled");
fwupd_bios_attr_add_possible_value(attr1, "Disabled"); fwupd_bios_setting_add_possible_value(attr1, "Disabled");
fwupd_bios_attr_add_possible_value(attr1, "Enabled"); fwupd_bios_setting_add_possible_value(attr1, "Enabled");
g_assert_true(fwupd_bios_attr_has_possible_value(attr1, "Disabled")); g_assert_true(fwupd_bios_setting_has_possible_value(attr1, "Disabled"));
g_assert_false(fwupd_bios_attr_has_possible_value(attr1, "NOT_GOING_TO_EXIST")); g_assert_false(fwupd_bios_setting_has_possible_value(attr1, "NOT_GOING_TO_EXIST"));
str1 = fwupd_bios_attr_to_string(attr1); str1 = fwupd_bios_setting_to_string(attr1);
ret = fu_test_compare_lines(str1, ret = fu_test_compare_lines(str1,
" Name: UEFISecureBoot\n" " Name: UEFISecureBoot\n"
" Description: Controls Secure boot\n" " Description: Controls Secure boot\n"
" Filename: /path/to/bar\n" " Filename: /path/to/bar\n"
" BiosAttrType: 1\n" " BiosSettingType: 1\n"
" BiosAttrCurrentValue: Disabled\n" " BiosSettingCurrentValue: Disabled\n"
" BiosAttrReadOnly: False\n" " BiosSettingReadOnly: False\n"
" BiosAttrPossibleValues: Disabled\n" " BiosSettingPossibleValues: Disabled\n"
" BiosAttrPossibleValues: Enabled\n", " BiosSettingPossibleValues: Enabled\n",
&error); &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
/* roundtrip GVariant */ /* roundtrip GVariant */
data1 = fwupd_bios_attr_to_variant(attr1, TRUE); data1 = fwupd_bios_setting_to_variant(attr1, TRUE);
attr2 = fwupd_bios_attr_from_variant(data1); attr2 = fwupd_bios_setting_from_variant(data1);
str2 = fwupd_bios_attr_to_string(attr2); str2 = fwupd_bios_setting_to_string(attr2);
ret = fu_test_compare_lines(str2, ret = fu_test_compare_lines(str2,
" Name: UEFISecureBoot\n" " Name: UEFISecureBoot\n"
" Description: Controls Secure boot\n" " Description: Controls Secure boot\n"
" Filename: /path/to/bar\n" " Filename: /path/to/bar\n"
" BiosAttrType: 1\n" " BiosSettingType: 1\n"
" BiosAttrCurrentValue: Disabled\n" " BiosSettingCurrentValue: Disabled\n"
" BiosAttrReadOnly: False\n" " BiosSettingReadOnly: False\n"
" BiosAttrPossibleValues: Disabled\n" " BiosSettingPossibleValues: Disabled\n"
" BiosAttrPossibleValues: Enabled\n", " BiosSettingPossibleValues: Enabled\n",
&error); &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
@ -1446,13 +1448,13 @@ fwupd_bios_attrs_func(void)
g_assert_nonnull(json1); g_assert_nonnull(json1);
ret = fu_test_compare_lines(json1, ret = fu_test_compare_lines(json1,
"{\n" "{\n"
" \"BiosAttrReadOnly\" : \"false\",\n" " \"BiosSettingReadOnly\" : \"false\",\n"
" \"BiosAttrType\" : 1,\n" " \"BiosSettingType\" : 1,\n"
" \"Name\" : \"UEFISecureBoot\",\n" " \"Name\" : \"UEFISecureBoot\",\n"
" \"Description\" : \"Controls Secure boot\",\n" " \"Description\" : \"Controls Secure boot\",\n"
" \"Filename\" : \"/path/to/bar\",\n" " \"Filename\" : \"/path/to/bar\",\n"
" \"BiosAttrCurrentValue\" : \"Disabled\",\n" " \"BiosSettingCurrentValue\" : \"Disabled\",\n"
" \"BiosAttrPossibleValues\" : [\n" " \"BiosSettingPossibleValues\" : [\n"
" \"Disabled\",\n" " \"Disabled\",\n"
" \"Enabled\"\n" " \"Enabled\"\n"
" ]\n" " ]\n"
@ -1465,7 +1467,7 @@ fwupd_bios_attrs_func(void)
ret = json_parser_load_from_data(parser, json1, -1, &error); ret = json_parser_load_from_data(parser, json1, -1, &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
ret = fwupd_bios_attr_from_json(attr2, json_parser_get_root(parser), &error); ret = fwupd_bios_setting_from_json(attr2, json_parser_get_root(parser), &error);
if (g_error_matches(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED)) { if (g_error_matches(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED)) {
g_test_skip(error->message); g_test_skip(error->message);
return; return;
@ -1473,24 +1475,24 @@ fwupd_bios_attrs_func(void)
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
str3 = fwupd_bios_attr_to_string(attr2); str3 = fwupd_bios_setting_to_string(attr2);
ret = fu_test_compare_lines(str3, str1, &error); ret = fu_test_compare_lines(str3, str1, &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
/* make sure we filter CurrentValue if not trusted */ /* make sure we filter CurrentValue if not trusted */
data2 = fwupd_bios_attr_to_variant(attr1, TRUE); data2 = fwupd_bios_setting_to_variant(attr1, TRUE);
json2 = fwupd_attr_to_json_string(G_OBJECT(attr1), &error); json2 = fwupd_attr_to_json_string(G_OBJECT(attr1), &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_nonnull(json2); g_assert_nonnull(json2);
ret = fu_test_compare_lines(json2, ret = fu_test_compare_lines(json2,
"{\n" "{\n"
" \"BiosAttrReadOnly\" : \"false\",\n" " \"BiosSettingReadOnly\" : \"false\",\n"
" \"BiosAttrType\" : 1,\n" " \"BiosSettingType\" : 1,\n"
" \"Name\" : \"UEFISecureBoot\",\n" " \"Name\" : \"UEFISecureBoot\",\n"
" \"Description\" : \"Controls Secure boot\",\n" " \"Description\" : \"Controls Secure boot\",\n"
" \"Filename\" : \"/path/to/bar\",\n" " \"Filename\" : \"/path/to/bar\",\n"
" \"BiosAttrPossibleValues\" : [\n" " \"BiosSettingPossibleValues\" : [\n"
" \"Disabled\",\n" " \"Disabled\",\n"
" \"Enabled\"\n" " \"Enabled\"\n"
" ]\n" " ]\n"
@ -1524,7 +1526,7 @@ main(int argc, char **argv)
g_test_add_func("/fwupd/remote{local}", fwupd_remote_local_func); g_test_add_func("/fwupd/remote{local}", fwupd_remote_local_func);
g_test_add_func("/fwupd/remote{duplicate}", fwupd_remote_duplicate_func); g_test_add_func("/fwupd/remote{duplicate}", fwupd_remote_duplicate_func);
g_test_add_func("/fwupd/remote{auth}", fwupd_remote_auth_func); g_test_add_func("/fwupd/remote{auth}", fwupd_remote_auth_func);
g_test_add_func("/fwupd/bios-attrs", fwupd_bios_attrs_func); g_test_add_func("/fwupd/bios-attrs", fwupd_bios_settings_func);
if (fwupd_has_system_bus()) { if (fwupd_has_system_bus()) {
g_test_add_func("/fwupd/client{remotes}", fwupd_client_remotes_func); g_test_add_func("/fwupd/client{remotes}", fwupd_client_remotes_func);
g_test_add_func("/fwupd/client{devices}", fwupd_client_devices_func); g_test_add_func("/fwupd/client{devices}", fwupd_client_devices_func);

View File

@ -8,7 +8,7 @@
#define __FWUPD_H_INSIDE__ #define __FWUPD_H_INSIDE__
#include <libfwupd/fwupd-bios-attr.h> #include <libfwupd/fwupd-bios-setting.h>
#include <libfwupd/fwupd-client-sync.h> #include <libfwupd/fwupd-client-sync.h>
#include <libfwupd/fwupd-client.h> #include <libfwupd/fwupd-client.h>
#include <libfwupd/fwupd-common.h> #include <libfwupd/fwupd-common.h>

View File

@ -803,49 +803,49 @@ LIBFWUPD_1.8.3 {
LIBFWUPD_1.8.4 { LIBFWUPD_1.8.4 {
global: global:
fwupd_bios_attr_add_possible_value; fwupd_bios_setting_add_possible_value;
fwupd_bios_attr_array_from_variant; fwupd_bios_setting_array_from_variant;
fwupd_bios_attr_from_json; fwupd_bios_setting_from_json;
fwupd_bios_attr_from_variant; fwupd_bios_setting_from_variant;
fwupd_bios_attr_get_current_value; fwupd_bios_setting_get_current_value;
fwupd_bios_attr_get_description; fwupd_bios_setting_get_description;
fwupd_bios_attr_get_id; fwupd_bios_setting_get_id;
fwupd_bios_attr_get_kind; fwupd_bios_setting_get_kind;
fwupd_bios_attr_get_lower_bound; fwupd_bios_setting_get_lower_bound;
fwupd_bios_attr_get_name; fwupd_bios_setting_get_name;
fwupd_bios_attr_get_path; fwupd_bios_setting_get_path;
fwupd_bios_attr_get_possible_values; fwupd_bios_setting_get_possible_values;
fwupd_bios_attr_get_read_only; fwupd_bios_setting_get_read_only;
fwupd_bios_attr_get_scalar_increment; fwupd_bios_setting_get_scalar_increment;
fwupd_bios_attr_get_type; fwupd_bios_setting_get_type;
fwupd_bios_attr_get_upper_bound; fwupd_bios_setting_get_upper_bound;
fwupd_bios_attr_has_possible_value; fwupd_bios_setting_has_possible_value;
fwupd_bios_attr_map_possible_value; fwupd_bios_setting_map_possible_value;
fwupd_bios_attr_new; fwupd_bios_setting_new;
fwupd_bios_attr_set_current_value; fwupd_bios_setting_set_current_value;
fwupd_bios_attr_set_description; fwupd_bios_setting_set_description;
fwupd_bios_attr_set_id; fwupd_bios_setting_set_id;
fwupd_bios_attr_set_kind; fwupd_bios_setting_set_kind;
fwupd_bios_attr_set_lower_bound; fwupd_bios_setting_set_lower_bound;
fwupd_bios_attr_set_name; fwupd_bios_setting_set_name;
fwupd_bios_attr_set_path; fwupd_bios_setting_set_path;
fwupd_bios_attr_set_read_only; fwupd_bios_setting_set_read_only;
fwupd_bios_attr_set_scalar_increment; fwupd_bios_setting_set_scalar_increment;
fwupd_bios_attr_set_upper_bound; fwupd_bios_setting_set_upper_bound;
fwupd_bios_attr_to_json; fwupd_bios_setting_to_json;
fwupd_bios_attr_to_string; fwupd_bios_setting_to_string;
fwupd_bios_attr_to_variant; fwupd_bios_setting_to_variant;
fwupd_client_get_bios_attrs; fwupd_client_get_bios_settings;
fwupd_client_get_bios_attrs_async; fwupd_client_get_bios_settings_async;
fwupd_client_get_bios_attrs_finish; fwupd_client_get_bios_settings_finish;
fwupd_client_modify_bios_attr; fwupd_client_modify_bios_setting;
fwupd_client_modify_bios_attr_async; fwupd_client_modify_bios_setting_async;
fwupd_client_modify_bios_attr_finish; fwupd_client_modify_bios_setting_finish;
fwupd_security_attr_get_bios_attr_current_value; fwupd_security_attr_get_bios_setting_current_value;
fwupd_security_attr_get_bios_attr_id; fwupd_security_attr_get_bios_setting_id;
fwupd_security_attr_get_bios_attr_target_value; fwupd_security_attr_get_bios_setting_target_value;
fwupd_security_attr_set_bios_attr_current_value; fwupd_security_attr_set_bios_setting_current_value;
fwupd_security_attr_set_bios_attr_id; fwupd_security_attr_set_bios_setting_id;
fwupd_security_attr_set_bios_attr_target_value; fwupd_security_attr_set_bios_setting_target_value;
local: *; local: *;
} LIBFWUPD_1.8.3; } LIBFWUPD_1.8.3;

View File

@ -23,7 +23,7 @@ install_headers([
'fwupd-error.h', 'fwupd-error.h',
'fwupd-remote.h', 'fwupd-remote.h',
'fwupd-request.h', 'fwupd-request.h',
'fwupd-bios-attr.h', 'fwupd-bios-setting.h',
'fwupd-security-attr.h', 'fwupd-security-attr.h',
'fwupd-release.h', 'fwupd-release.h',
'fwupd-plugin.h', 'fwupd-plugin.h',
@ -47,7 +47,7 @@ libfwupd_src = [
'fwupd-device.c', # fuzzing 'fwupd-device.c', # fuzzing
'fwupd-enums.c', # fuzzing 'fwupd-enums.c', # fuzzing
'fwupd-error.c', # fuzzing 'fwupd-error.c', # fuzzing
'fwupd-bios-attr.c', # fuzzing 'fwupd-bios-setting.c', # fuzzing
'fwupd-security-attr.c', # fuzzing 'fwupd-security-attr.c', # fuzzing
'fwupd-release.c', # fuzzing 'fwupd-release.c', # fuzzing
'fwupd-plugin.c', 'fwupd-plugin.c',
@ -113,9 +113,9 @@ if introspection.allowed()
'fwupd-enums-private.h', 'fwupd-enums-private.h',
'fwupd-error.c', 'fwupd-error.c',
'fwupd-error.h', 'fwupd-error.h',
'fwupd-bios-attr.c', 'fwupd-bios-setting.c',
'fwupd-bios-attr.h', 'fwupd-bios-setting.h',
'fwupd-bios-attr-private.h', 'fwupd-bios-setting-private.h',
'fwupd-security-attr.c', 'fwupd-security-attr.c',
'fwupd-security-attr.h', 'fwupd-security-attr.h',
'fwupd-security-attr-private.h', 'fwupd-security-attr-private.h',

View File

@ -1,22 +0,0 @@
/*
* Copyright (C) 2022 Mario Limonciello <mario.limonciello@amd.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <json-glib/json-glib.h>
#include "fu-bios-attrs.h"
gboolean
fu_bios_attrs_setup(FuBiosAttrs *self, GError **error);
GPtrArray *
fu_bios_attrs_get_all(FuBiosAttrs *self);
GVariant *
fu_bios_attrs_to_variant(FuBiosAttrs *self, gboolean trusted);
gboolean
fu_bios_attrs_from_json(FuBiosAttrs *self, JsonNode *json_node, GError **error);

View File

@ -1,20 +0,0 @@
/*
* Copyright (C) 2022 Mario Limonciello <mario.limonciello@amd.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <libfwupd/fwupd-bios-attr.h>
#define FU_TYPE_FIRMWARE_ATTRS (fu_bios_attrs_get_type())
G_DECLARE_FINAL_TYPE(FuBiosAttrs, fu_bios_attrs, FU, BIOS_ATTRS, GObject)
FuBiosAttrs *
fu_bios_attrs_new(void);
gboolean
fu_bios_attrs_get_pending_reboot(FuBiosAttrs *self, gboolean *result, GError **error);
FwupdBiosAttr *
fu_bios_attrs_get_attr(FuBiosAttrs *self, const gchar *val);

View File

@ -0,0 +1,22 @@
/*
* Copyright (C) 2022 Mario Limonciello <mario.limonciello@amd.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <json-glib/json-glib.h>
#include "fu-bios-settings.h"
gboolean
fu_bios_settings_setup(FuBiosSettings *self, GError **error);
GPtrArray *
fu_bios_settings_get_all(FuBiosSettings *self);
GVariant *
fu_bios_settings_to_variant(FuBiosSettings *self, gboolean trusted);
gboolean
fu_bios_settings_from_json(FuBiosSettings *self, JsonNode *json_node, GError **error);

View File

@ -4,48 +4,48 @@
* SPDX-License-Identifier: LGPL-2.1+ * SPDX-License-Identifier: LGPL-2.1+
*/ */
#define G_LOG_DOMAIN "FuBiosAttrs" #define G_LOG_DOMAIN "FuBiosSettings"
#include "config.h" #include "config.h"
#include "fwupd-bios-attr-private.h" #include "fwupd-bios-setting-private.h"
#include "fwupd-error.h" #include "fwupd-error.h"
#include "fu-bios-attrs-private.h" #include "fu-bios-settings-private.h"
#include "fu-path.h" #include "fu-path.h"
#include "fu-string.h" #include "fu-string.h"
struct _FuBiosAttrs { struct _FuBiosSettings {
GObject parent_instance; GObject parent_instance;
GPtrArray *attrs; GPtrArray *attrs;
}; };
G_DEFINE_TYPE(FuBiosAttrs, fu_bios_attrs, G_TYPE_OBJECT) G_DEFINE_TYPE(FuBiosSettings, fu_bios_settings, G_TYPE_OBJECT)
static void static void
fu_bios_attrs_finalize(GObject *obj) fu_bios_settings_finalize(GObject *obj)
{ {
FuBiosAttrs *self = FU_BIOS_ATTRS(obj); FuBiosSettings *self = FU_BIOS_SETTINGS(obj);
g_ptr_array_unref(self->attrs); g_ptr_array_unref(self->attrs);
G_OBJECT_CLASS(fu_bios_attrs_parent_class)->finalize(obj); G_OBJECT_CLASS(fu_bios_settings_parent_class)->finalize(obj);
} }
static void static void
fu_bios_attrs_class_init(FuBiosAttrsClass *klass) fu_bios_settings_class_init(FuBiosSettingsClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS(klass); GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->finalize = fu_bios_attrs_finalize; object_class->finalize = fu_bios_settings_finalize;
} }
static gboolean static gboolean
fu_bios_attr_get_key(FwupdBiosAttr *attr, const gchar *key, gchar **value_out, GError **error) fu_bios_setting_get_key(FwupdBiosSetting *attr, const gchar *key, gchar **value_out, GError **error)
{ {
g_autofree gchar *tmp = NULL; g_autofree gchar *tmp = NULL;
g_return_val_if_fail(FWUPD_IS_BIOS_ATTR(attr), FALSE); g_return_val_if_fail(FWUPD_IS_BIOS_SETTING(attr), FALSE);
g_return_val_if_fail(&value_out != NULL, FALSE); g_return_val_if_fail(&value_out != NULL, FALSE);
tmp = g_build_filename(fwupd_bios_attr_get_path(attr), key, NULL); tmp = g_build_filename(fwupd_bios_setting_get_path(attr), key, NULL);
if (!g_file_get_contents(tmp, value_out, NULL, error)) { if (!g_file_get_contents(tmp, value_out, NULL, error)) {
g_prefix_error(error, "failed to load %s: ", key); g_prefix_error(error, "failed to load %s: ", key);
return FALSE; return FALSE;
@ -55,26 +55,26 @@ fu_bios_attr_get_key(FwupdBiosAttr *attr, const gchar *key, gchar **value_out, G
} }
static gboolean static gboolean
fu_bios_attr_set_description(FwupdBiosAttr *attr, GError **error) fu_bios_setting_set_description(FwupdBiosSetting *attr, GError **error)
{ {
g_autofree gchar *data = NULL; g_autofree gchar *data = NULL;
g_return_val_if_fail(FWUPD_IS_BIOS_ATTR(attr), FALSE); g_return_val_if_fail(FWUPD_IS_BIOS_SETTING(attr), FALSE);
if (!fu_bios_attr_get_key(attr, "display_name", &data, error)) if (!fu_bios_setting_get_key(attr, "display_name", &data, error))
return FALSE; return FALSE;
fwupd_bios_attr_set_description(attr, data); fwupd_bios_setting_set_description(attr, data);
return TRUE; return TRUE;
} }
static guint64 static guint64
fu_bios_attr_get_key_as_integer(FwupdBiosAttr *attr, const gchar *key, GError **error) fu_bios_setting_get_key_as_integer(FwupdBiosSetting *attr, const gchar *key, GError **error)
{ {
g_autofree gchar *str = NULL; g_autofree gchar *str = NULL;
guint64 tmp; guint64 tmp;
if (!fu_bios_attr_get_key(attr, key, &str, error)) if (!fu_bios_setting_get_key(attr, key, &str, error))
return G_MAXUINT64; return G_MAXUINT64;
if (!fu_strtoull(str, &tmp, 0, G_MAXUINT64, error)) { if (!fu_strtoull(str, &tmp, 0, G_MAXUINT64, error)) {
g_prefix_error(error, "failed to convert %s to integer: ", key); g_prefix_error(error, "failed to convert %s to integer: ", key);
@ -84,12 +84,12 @@ fu_bios_attr_get_key_as_integer(FwupdBiosAttr *attr, const gchar *key, GError **
} }
static gboolean static gboolean
fu_bios_attr_set_enumeration_attrs(FwupdBiosAttr *attr, GError **error) fu_bios_setting_set_enumeration_attrs(FwupdBiosSetting *attr, GError **error)
{ {
const gchar *delimiters[] = {",", ";", NULL}; const gchar *delimiters[] = {",", ";", NULL};
g_autofree gchar *str = NULL; g_autofree gchar *str = NULL;
if (!fu_bios_attr_get_key(attr, "possible_values", &str, error)) if (!fu_bios_setting_get_key(attr, "possible_values", &str, error))
return FALSE; return FALSE;
for (guint j = 0; delimiters[j] != NULL; j++) { for (guint j = 0; delimiters[j] != NULL; j++) {
g_auto(GStrv) vals = NULL; g_auto(GStrv) vals = NULL;
@ -97,59 +97,59 @@ fu_bios_attr_set_enumeration_attrs(FwupdBiosAttr *attr, GError **error)
continue; continue;
vals = fu_strsplit(str, strlen(str), delimiters[j], -1); vals = fu_strsplit(str, strlen(str), delimiters[j], -1);
if (vals[0] != NULL) if (vals[0] != NULL)
fwupd_bios_attr_set_kind(attr, FWUPD_BIOS_ATTR_KIND_ENUMERATION); fwupd_bios_setting_set_kind(attr, FWUPD_BIOS_SETTING_KIND_ENUMERATION);
for (guint i = 0; vals[i] != NULL && vals[i][0] != '\0'; i++) for (guint i = 0; vals[i] != NULL && vals[i][0] != '\0'; i++)
fwupd_bios_attr_add_possible_value(attr, vals[i]); fwupd_bios_setting_add_possible_value(attr, vals[i]);
} }
return TRUE; return TRUE;
} }
static gboolean static gboolean
fu_bios_attr_set_string_attrs(FwupdBiosAttr *attr, GError **error) fu_bios_setting_set_string_attrs(FwupdBiosSetting *attr, GError **error)
{ {
guint64 tmp; guint64 tmp;
tmp = fu_bios_attr_get_key_as_integer(attr, "min_length", error); tmp = fu_bios_setting_get_key_as_integer(attr, "min_length", error);
if (tmp == G_MAXUINT64) if (tmp == G_MAXUINT64)
return FALSE; return FALSE;
fwupd_bios_attr_set_lower_bound(attr, tmp); fwupd_bios_setting_set_lower_bound(attr, tmp);
tmp = fu_bios_attr_get_key_as_integer(attr, "max_length", error); tmp = fu_bios_setting_get_key_as_integer(attr, "max_length", error);
if (tmp == G_MAXUINT64) if (tmp == G_MAXUINT64)
return FALSE; return FALSE;
fwupd_bios_attr_set_upper_bound(attr, tmp); fwupd_bios_setting_set_upper_bound(attr, tmp);
fwupd_bios_attr_set_kind(attr, FWUPD_BIOS_ATTR_KIND_STRING); fwupd_bios_setting_set_kind(attr, FWUPD_BIOS_SETTING_KIND_STRING);
return TRUE; return TRUE;
} }
static gboolean static gboolean
fu_bios_attr_set_integer_attrs(FwupdBiosAttr *attr, GError **error) fu_bios_setting_set_integer_attrs(FwupdBiosSetting *attr, GError **error)
{ {
guint64 tmp; guint64 tmp;
tmp = fu_bios_attr_get_key_as_integer(attr, "min_value", error); tmp = fu_bios_setting_get_key_as_integer(attr, "min_value", error);
if (tmp == G_MAXUINT64) if (tmp == G_MAXUINT64)
return FALSE; return FALSE;
fwupd_bios_attr_set_lower_bound(attr, tmp); fwupd_bios_setting_set_lower_bound(attr, tmp);
tmp = fu_bios_attr_get_key_as_integer(attr, "max_value", error); tmp = fu_bios_setting_get_key_as_integer(attr, "max_value", error);
if (tmp == G_MAXUINT64) if (tmp == G_MAXUINT64)
return FALSE; return FALSE;
fwupd_bios_attr_set_upper_bound(attr, tmp); fwupd_bios_setting_set_upper_bound(attr, tmp);
tmp = fu_bios_attr_get_key_as_integer(attr, "scalar_increment", error); tmp = fu_bios_setting_get_key_as_integer(attr, "scalar_increment", error);
if (tmp == G_MAXUINT64) if (tmp == G_MAXUINT64)
return FALSE; return FALSE;
fwupd_bios_attr_set_scalar_increment(attr, tmp); fwupd_bios_setting_set_scalar_increment(attr, tmp);
fwupd_bios_attr_set_kind(attr, FWUPD_BIOS_ATTR_KIND_INTEGER); fwupd_bios_setting_set_kind(attr, FWUPD_BIOS_SETTING_KIND_INTEGER);
return TRUE; return TRUE;
} }
static gboolean static gboolean
fu_bios_attr_set_current_value(FwupdBiosAttr *attr, GError **error) fu_bios_setting_set_current_value(FwupdBiosSetting *attr, GError **error)
{ {
g_autofree gchar *str = NULL; g_autofree gchar *str = NULL;
if (!fu_bios_attr_get_key(attr, "current_value", &str, error)) if (!fu_bios_setting_get_key(attr, "current_value", &str, error))
return FALSE; return FALSE;
fwupd_bios_attr_set_current_value(attr, str); fwupd_bios_setting_set_current_value(attr, str);
return TRUE; return TRUE;
} }
@ -158,24 +158,24 @@ fu_bios_attr_set_current_value(FwupdBiosAttr *attr, GError **error)
#define LENOVO_EXCLUDED "[Excluded from boot order:" #define LENOVO_EXCLUDED "[Excluded from boot order:"
static void static void
fu_bios_attr_fixup_read_only(FwupdBiosAttr *attr) fu_bios_setting_fixup_read_only(FwupdBiosSetting *attr)
{ {
if (fwupd_bios_attr_get_kind(attr) == FWUPD_BIOS_ATTR_KIND_ENUMERATION) { if (fwupd_bios_setting_get_kind(attr) == FWUPD_BIOS_SETTING_KIND_ENUMERATION) {
struct { struct {
const gchar *id; const gchar *id;
const gchar *value; const gchar *value;
} read_only_map[] = {{"com.thinklmi.SecureBoot", "Enable"}, } read_only_map[] = {{"com.thinklmi.SecureBoot", "Enable"},
{"com.dell-wmi-sysman.SecureBoot", "Enabled"}, {"com.dell-wmi-sysman.SecureBoot", "Enabled"},
{NULL, NULL}}; {NULL, NULL}};
const gchar *id = fwupd_bios_attr_get_id(attr); const gchar *id = fwupd_bios_setting_get_id(attr);
const gchar *tmp = fwupd_bios_attr_get_current_value(attr); const gchar *tmp = fwupd_bios_setting_get_current_value(attr);
for (guint i = 0; read_only_map[i].id != NULL; i++) { for (guint i = 0; read_only_map[i].id != NULL; i++) {
if (g_strcmp0(id, read_only_map[i].id) != 0) if (g_strcmp0(id, read_only_map[i].id) != 0)
continue; continue;
if (read_only_map[i].value == NULL || if (read_only_map[i].value == NULL ||
g_strcmp0(tmp, read_only_map[i].value) == 0) { g_strcmp0(tmp, read_only_map[i].value) == 0) {
fwupd_bios_attr_set_read_only(attr, TRUE); fwupd_bios_setting_set_read_only(attr, TRUE);
return; return;
} }
} }
@ -183,9 +183,9 @@ fu_bios_attr_fixup_read_only(FwupdBiosAttr *attr)
} }
static gboolean static gboolean
fu_bios_attr_fixup_lenovo_thinklmi_bug(FwupdBiosAttr *attr, GError **error) fu_bios_setting_fixup_lenovo_thinklmi_bug(FwupdBiosSetting *attr, GError **error)
{ {
const gchar *current_value = fwupd_bios_attr_get_current_value(attr); const gchar *current_value = fwupd_bios_setting_get_current_value(attr);
const gchar *tmp; const gchar *tmp;
g_autoptr(GString) str = NULL; g_autoptr(GString) str = NULL;
g_autoptr(GString) right_str = NULL; g_autoptr(GString) right_str = NULL;
@ -193,14 +193,14 @@ fu_bios_attr_fixup_lenovo_thinklmi_bug(FwupdBiosAttr *attr, GError **error)
if (g_getenv("FWUPD_BIOS_SETTING_VERBOSE") != NULL) { if (g_getenv("FWUPD_BIOS_SETTING_VERBOSE") != NULL) {
g_debug("Processing %s: (%s)", g_debug("Processing %s: (%s)",
fwupd_bios_attr_get_name(attr), fwupd_bios_setting_get_name(attr),
fwupd_bios_attr_get_current_value(attr)); fwupd_bios_setting_get_current_value(attr));
} }
/* We have read only */ /* We have read only */
tmp = g_strrstr(current_value, LENOVO_READ_ONLY_NEEDLE); tmp = g_strrstr(current_value, LENOVO_READ_ONLY_NEEDLE);
if (tmp != NULL) { if (tmp != NULL) {
fwupd_bios_attr_set_read_only(attr, TRUE); fwupd_bios_setting_set_read_only(attr, TRUE);
str = g_string_new_len(current_value, tmp - current_value); str = g_string_new_len(current_value, tmp - current_value);
} else { } else {
str = g_string_new(current_value); str = g_string_new(current_value);
@ -214,7 +214,7 @@ fu_bios_attr_fixup_lenovo_thinklmi_bug(FwupdBiosAttr *attr, GError **error)
vals = fu_strsplit(str->str, str->len, ";", 2); vals = fu_strsplit(str->str, str->len, ";", 2);
/* use left half for current value */ /* use left half for current value */
fwupd_bios_attr_set_current_value(attr, vals[0]); fwupd_bios_setting_set_current_value(attr, vals[0]);
if (vals[1] == NULL) if (vals[1] == NULL)
return TRUE; return TRUE;
@ -233,7 +233,7 @@ fu_bios_attr_fixup_lenovo_thinklmi_bug(FwupdBiosAttr *attr, GError **error)
g_string_erase(right_str, 0, strlen(LENOVO_POSSIBLE_NEEDLE)); g_string_erase(right_str, 0, strlen(LENOVO_POSSIBLE_NEEDLE));
possible_vals = fu_strsplit(right_str->str, right_str->len, ",", -1); possible_vals = fu_strsplit(right_str->str, right_str->len, ",", -1);
if (possible_vals[0] != NULL) if (possible_vals[0] != NULL)
fwupd_bios_attr_set_kind(attr, FWUPD_BIOS_ATTR_KIND_ENUMERATION); fwupd_bios_setting_set_kind(attr, FWUPD_BIOS_SETTING_KIND_ENUMERATION);
for (guint i = 0; possible_vals[i] != NULL && possible_vals[i][0] != '\0'; i++) { for (guint i = 0; possible_vals[i] != NULL && possible_vals[i][0] != '\0'; i++) {
/* last string */ /* last string */
if (possible_vals[i + 1] == NULL && if (possible_vals[i + 1] == NULL &&
@ -242,36 +242,36 @@ fu_bios_attr_fixup_lenovo_thinklmi_bug(FwupdBiosAttr *attr, GError **error)
strlen(possible_vals[i]), strlen(possible_vals[i]),
"]", "]",
-1); -1);
fwupd_bios_attr_add_possible_value(attr, stripped_vals[0]); fwupd_bios_setting_add_possible_value(attr, stripped_vals[0]);
continue; continue;
} }
fwupd_bios_attr_add_possible_value(attr, possible_vals[i]); fwupd_bios_setting_add_possible_value(attr, possible_vals[i]);
} }
} }
return TRUE; return TRUE;
} }
static gboolean static gboolean
fu_bios_attrs_run_folder_fixups(FwupdBiosAttr *attr, GError **error) fu_bios_settings_run_folder_fixups(FwupdBiosSetting *attr, GError **error)
{ {
if (fwupd_bios_attr_get_kind(attr) == FWUPD_BIOS_ATTR_KIND_UNKNOWN) if (fwupd_bios_setting_get_kind(attr) == FWUPD_BIOS_SETTING_KIND_UNKNOWN)
return fu_bios_attr_fixup_lenovo_thinklmi_bug(attr, error); return fu_bios_setting_fixup_lenovo_thinklmi_bug(attr, error);
return TRUE; return TRUE;
} }
static gboolean static gboolean
fu_bios_attr_set_type(FuBiosAttrs *self, FwupdBiosAttr *attr, GError **error) fu_bios_setting_set_type(FuBiosSettings *self, FwupdBiosSetting *attr, GError **error)
{ {
gboolean kernel_bug = FALSE; gboolean kernel_bug = FALSE;
g_autofree gchar *data = NULL; g_autofree gchar *data = NULL;
g_autoptr(GError) error_key = NULL; g_autoptr(GError) error_key = NULL;
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
g_return_val_if_fail(FU_IS_BIOS_ATTRS(self), FALSE); g_return_val_if_fail(FU_IS_BIOS_SETTINGS(self), FALSE);
g_return_val_if_fail(FWUPD_IS_BIOS_ATTR(attr), FALSE); g_return_val_if_fail(FWUPD_IS_BIOS_SETTING(attr), FALSE);
/* lenovo thinklmi seems to be missing it even though it's mandatory :/ */ /* lenovo thinklmi seems to be missing it even though it's mandatory :/ */
if (!fu_bios_attr_get_key(attr, "type", &data, &error_key)) { if (!fu_bios_setting_get_key(attr, "type", &data, &error_key)) {
#if GLIB_CHECK_VERSION(2, 64, 0) #if GLIB_CHECK_VERSION(2, 64, 0)
g_warning_once("KERNEL BUG: 'type' attribute not exported: (%s)", g_warning_once("KERNEL BUG: 'type' attribute not exported: (%s)",
error_key->message); error_key->message);
@ -282,18 +282,18 @@ fu_bios_attr_set_type(FuBiosAttrs *self, FwupdBiosAttr *attr, GError **error)
} }
if (g_strcmp0(data, "enumeration") == 0 || kernel_bug) { if (g_strcmp0(data, "enumeration") == 0 || kernel_bug) {
if (!fu_bios_attr_set_enumeration_attrs(attr, &error_local)) { if (!fu_bios_setting_set_enumeration_attrs(attr, &error_local)) {
if (g_getenv("FWUPD_BIOS_SETTING_VERBOSE") != NULL) if (g_getenv("FWUPD_BIOS_SETTING_VERBOSE") != NULL)
g_debug("failed to add enumeration attrs: %s", g_debug("failed to add enumeration attrs: %s",
error_local->message); error_local->message);
} }
} else if (g_strcmp0(data, "integer") == 0) { } else if (g_strcmp0(data, "integer") == 0) {
if (!fu_bios_attr_set_integer_attrs(attr, &error_local)) { if (!fu_bios_setting_set_integer_attrs(attr, &error_local)) {
if (g_getenv("FWUPD_BIOS_SETTING_VERBOSE") != NULL) if (g_getenv("FWUPD_BIOS_SETTING_VERBOSE") != NULL)
g_debug("failed to add integer attrs: %s", error_local->message); g_debug("failed to add integer attrs: %s", error_local->message);
} }
} else if (g_strcmp0(data, "string") == 0) { } else if (g_strcmp0(data, "string") == 0) {
if (!fu_bios_attr_set_string_attrs(attr, &error_local)) { if (!fu_bios_setting_set_string_attrs(attr, &error_local)) {
if (g_getenv("FWUPD_BIOS_SETTING_VERBOSE") != NULL) if (g_getenv("FWUPD_BIOS_SETTING_VERBOSE") != NULL)
g_debug("failed to add string attrs: %s", error_local->message); g_debug("failed to add string attrs: %s", error_local->message);
} }
@ -305,70 +305,70 @@ fu_bios_attr_set_type(FuBiosAttrs *self, FwupdBiosAttr *attr, GError **error)
* https://github.com/torvalds/linux/blob/v5.18/Documentation/ABI/testing/sysfs-class-firmware-attributes#L300 * https://github.com/torvalds/linux/blob/v5.18/Documentation/ABI/testing/sysfs-class-firmware-attributes#L300
*/ */
static gboolean static gboolean
fu_bios_attr_set_file_attributes(FwupdBiosAttr *attr, GError **error) fu_bios_setting_set_file_attributes(FwupdBiosSetting *attr, GError **error)
{ {
g_autofree gchar *value = NULL; g_autofree gchar *value = NULL;
if (g_strcmp0(fwupd_bios_attr_get_name(attr), FWUPD_BIOS_ATTR_PENDING_REBOOT) != 0) { if (g_strcmp0(fwupd_bios_setting_get_name(attr), FWUPD_BIOS_SETTING_PENDING_REBOOT) != 0) {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
"%s attribute is not supported", "%s attribute is not supported",
fwupd_bios_attr_get_name(attr)); fwupd_bios_setting_get_name(attr));
return FALSE; return FALSE;
} }
if (!fu_bios_attr_get_key(attr, NULL, &value, error)) if (!fu_bios_setting_get_key(attr, NULL, &value, error))
return FALSE; return FALSE;
fwupd_bios_attr_set_current_value(attr, value); fwupd_bios_setting_set_current_value(attr, value);
fwupd_bios_attr_set_read_only(attr, TRUE); fwupd_bios_setting_set_read_only(attr, TRUE);
return TRUE; return TRUE;
} }
static gboolean static gboolean
fu_bios_attrs_set_folder_attributes(FuBiosAttrs *self, FwupdBiosAttr *attr, GError **error) fu_bios_settings_set_folder_attributes(FuBiosSettings *self, FwupdBiosSetting *attr, GError **error)
{ {
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
if (!fu_bios_attr_set_type(self, attr, error)) if (!fu_bios_setting_set_type(self, attr, error))
return FALSE; return FALSE;
if (!fu_bios_attr_set_current_value(attr, error)) if (!fu_bios_setting_set_current_value(attr, error))
return FALSE; return FALSE;
if (!fu_bios_attr_set_description(attr, &error_local)) if (!fu_bios_setting_set_description(attr, &error_local))
g_debug("%s", error_local->message); g_debug("%s", error_local->message);
if (!fu_bios_attrs_run_folder_fixups(attr, error)) if (!fu_bios_settings_run_folder_fixups(attr, error))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
static gboolean static gboolean
fu_bios_attrs_populate_attribute(FuBiosAttrs *self, fu_bios_settings_populate_attribute(FuBiosSettings *self,
const gchar *driver, const gchar *driver,
const gchar *path, const gchar *path,
const gchar *name, const gchar *name,
GError **error) GError **error)
{ {
g_autoptr(FwupdBiosAttr) attr = NULL; g_autoptr(FwupdBiosSetting) attr = NULL;
g_autofree gchar *id = NULL; g_autofree gchar *id = NULL;
g_return_val_if_fail(FU_IS_BIOS_ATTRS(self), FALSE); g_return_val_if_fail(FU_IS_BIOS_SETTINGS(self), FALSE);
g_return_val_if_fail(name != NULL, FALSE); g_return_val_if_fail(name != NULL, FALSE);
g_return_val_if_fail(path != NULL, FALSE); g_return_val_if_fail(path != NULL, FALSE);
g_return_val_if_fail(driver != NULL, FALSE); g_return_val_if_fail(driver != NULL, FALSE);
attr = fwupd_bios_attr_new(name, path); attr = fwupd_bios_setting_new(name, path);
if (g_file_test(path, G_FILE_TEST_IS_DIR)) { if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
if (!fu_bios_attrs_set_folder_attributes(self, attr, error)) if (!fu_bios_settings_set_folder_attributes(self, attr, error))
return FALSE; return FALSE;
} else { } else {
if (!fu_bios_attr_set_file_attributes(attr, error)) if (!fu_bios_setting_set_file_attributes(attr, error))
return FALSE; return FALSE;
} }
id = g_strdup_printf("com.%s.%s", driver, name); id = g_strdup_printf("com.%s.%s", driver, name);
fwupd_bios_attr_set_id(attr, id); fwupd_bios_setting_set_id(attr, id);
fu_bios_attr_fixup_read_only(attr); fu_bios_setting_fixup_read_only(attr);
g_ptr_array_add(self->attrs, g_object_ref(attr)); g_ptr_array_add(self->attrs, g_object_ref(attr));
@ -376,8 +376,8 @@ fu_bios_attrs_populate_attribute(FuBiosAttrs *self,
} }
/** /**
* fu_bios_attrs_setup: * fu_bios_settings_setup:
* @self: a #FuBiosAttrs * @self: a #FuBiosSettings
* *
* Clears all attributes and re-initializes them. * Clears all attributes and re-initializes them.
* Mostly used for the test suite, but could potentially be connected to udev * Mostly used for the test suite, but could potentially be connected to udev
@ -386,13 +386,13 @@ fu_bios_attrs_populate_attribute(FuBiosAttrs *self,
* Since: 1.8.4 * Since: 1.8.4
**/ **/
gboolean gboolean
fu_bios_attrs_setup(FuBiosAttrs *self, GError **error) fu_bios_settings_setup(FuBiosSettings *self, GError **error)
{ {
guint count = 0; guint count = 0;
g_autofree gchar *sysfsfwdir = NULL; g_autofree gchar *sysfsfwdir = NULL;
g_autoptr(GDir) class_dir = NULL; g_autoptr(GDir) class_dir = NULL;
g_return_val_if_fail(FU_IS_BIOS_ATTRS(self), FALSE); g_return_val_if_fail(FU_IS_BIOS_SETTINGS(self), FALSE);
if (self->attrs->len > 0) { if (self->attrs->len > 0) {
g_debug("re-initializing attributes"); g_debug("re-initializing attributes");
@ -425,7 +425,7 @@ fu_bios_attrs_setup(FuBiosAttrs *self, GError **error)
if (name == NULL) if (name == NULL)
break; break;
full_path = g_build_filename(path, name, NULL); full_path = g_build_filename(path, name, NULL);
if (!fu_bios_attrs_populate_attribute(self, if (!fu_bios_settings_populate_attribute(self,
driver, driver,
full_path, full_path,
name, name,
@ -447,30 +447,30 @@ fu_bios_attrs_setup(FuBiosAttrs *self, GError **error)
} }
static void static void
fu_bios_attrs_init(FuBiosAttrs *self) fu_bios_settings_init(FuBiosSettings *self)
{ {
self->attrs = g_ptr_array_new_with_free_func((GDestroyNotify)g_object_unref); self->attrs = g_ptr_array_new_with_free_func((GDestroyNotify)g_object_unref);
} }
/** /**
* fu_bios_attrs_get_attr: * fu_bios_settings_get_attr:
* @self: a #FuBiosAttrs * @self: a #FuBiosSettings
* @val: the attribute ID or name to check for * @val: the attribute ID or name to check for
* *
* Returns: (transfer none): the attribute with the given ID or name or NULL if it doesn't exist. * Returns: (transfer none): the attribute with the given ID or name or NULL if it doesn't exist.
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
FwupdBiosAttr * FwupdBiosSetting *
fu_bios_attrs_get_attr(FuBiosAttrs *self, const gchar *val) fu_bios_settings_get_attr(FuBiosSettings *self, const gchar *val)
{ {
g_return_val_if_fail(FU_IS_BIOS_ATTRS(self), NULL); g_return_val_if_fail(FU_IS_BIOS_SETTINGS(self), NULL);
g_return_val_if_fail(val != NULL, NULL); g_return_val_if_fail(val != NULL, NULL);
for (guint i = 0; i < self->attrs->len; i++) { for (guint i = 0; i < self->attrs->len; i++) {
FwupdBiosAttr *attr = g_ptr_array_index(self->attrs, i); FwupdBiosSetting *attr = g_ptr_array_index(self->attrs, i);
const gchar *tmp_id = fwupd_bios_attr_get_id(attr); const gchar *tmp_id = fwupd_bios_setting_get_id(attr);
const gchar *tmp_name = fwupd_bios_attr_get_name(attr); const gchar *tmp_name = fwupd_bios_setting_get_name(attr);
if (g_strcmp0(val, tmp_id) == 0 || g_strcmp0(val, tmp_name) == 0) if (g_strcmp0(val, tmp_id) == 0 || g_strcmp0(val, tmp_name) == 0)
return attr; return attr;
} }
@ -478,25 +478,25 @@ fu_bios_attrs_get_attr(FuBiosAttrs *self, const gchar *val)
} }
/** /**
* fu_bios_attrs_get_all: * fu_bios_settings_get_all:
* @self: a #FuBiosAttrs * @self: a #FuBiosSettings
* *
* Gets all the attributes in the object. * Gets all the attributes in the object.
* *
* Returns: (transfer container) (element-type FwupdBiosAttr): attributes * Returns: (transfer container) (element-type FwupdBiosSetting): attributes
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
GPtrArray * GPtrArray *
fu_bios_attrs_get_all(FuBiosAttrs *self) fu_bios_settings_get_all(FuBiosSettings *self)
{ {
g_return_val_if_fail(FU_IS_BIOS_ATTRS(self), NULL); g_return_val_if_fail(FU_IS_BIOS_SETTINGS(self), NULL);
return g_ptr_array_ref(self->attrs); return g_ptr_array_ref(self->attrs);
} }
/** /**
* fu_bios_attrs_get_pending_reboot: * fu_bios_settings_get_pending_reboot:
* @self: a #FuBiosAttrs * @self: a #FuBiosSettings
* @result: (out): Whether a reboot is pending * @result: (out): Whether a reboot is pending
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
@ -505,21 +505,21 @@ fu_bios_attrs_get_all(FuBiosAttrs *self)
* Since: 1.8.4 * Since: 1.8.4
**/ **/
gboolean gboolean
fu_bios_attrs_get_pending_reboot(FuBiosAttrs *self, gboolean *result, GError **error) fu_bios_settings_get_pending_reboot(FuBiosSettings *self, gboolean *result, GError **error)
{ {
FwupdBiosAttr *attr; FwupdBiosSetting *attr;
const gchar *data; const gchar *data;
guint64 val = 0; guint64 val = 0;
g_return_val_if_fail(result != NULL, FALSE); g_return_val_if_fail(result != NULL, FALSE);
g_return_val_if_fail(FU_IS_BIOS_ATTRS(self), FALSE); g_return_val_if_fail(FU_IS_BIOS_SETTINGS(self), FALSE);
for (guint i = 0; i < self->attrs->len; i++) { for (guint i = 0; i < self->attrs->len; i++) {
const gchar *tmp; const gchar *tmp;
attr = g_ptr_array_index(self->attrs, i); attr = g_ptr_array_index(self->attrs, i);
tmp = fwupd_bios_attr_get_name(attr); tmp = fwupd_bios_setting_get_name(attr);
if (g_strcmp0(tmp, FWUPD_BIOS_ATTR_PENDING_REBOOT) == 0) if (g_strcmp0(tmp, FWUPD_BIOS_SETTING_PENDING_REBOOT) == 0)
break; break;
attr = NULL; attr = NULL;
} }
@ -532,7 +532,7 @@ fu_bios_attrs_get_pending_reboot(FuBiosAttrs *self, gboolean *result, GError **e
return FALSE; return FALSE;
} }
data = fwupd_bios_attr_get_current_value(attr); data = fwupd_bios_setting_get_current_value(attr);
if (!fu_strtoull(data, &val, 0, G_MAXUINT32, error)) if (!fu_strtoull(data, &val, 0, G_MAXUINT32, error))
return FALSE; return FALSE;
@ -542,44 +542,44 @@ fu_bios_attrs_get_pending_reboot(FuBiosAttrs *self, gboolean *result, GError **e
} }
/** /**
* fu_bios_attrs_to_variant: * fu_bios_settings_to_variant:
* @self: a #FuBiosAttrs * @self: a #FuBiosSettings
* @trusted: whether the caller should receive trusted values * @trusted: whether the caller should receive trusted values
* *
* Serializes the #FwupdBiosAttr objects. * Serializes the #FwupdBiosSetting objects.
* *
* Returns: a #GVariant or %NULL * Returns: a #GVariant or %NULL
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
GVariant * GVariant *
fu_bios_attrs_to_variant(FuBiosAttrs *self, gboolean trusted) fu_bios_settings_to_variant(FuBiosSettings *self, gboolean trusted)
{ {
GVariantBuilder builder; GVariantBuilder builder;
g_return_val_if_fail(FU_IS_BIOS_ATTRS(self), NULL); g_return_val_if_fail(FU_IS_BIOS_SETTINGS(self), NULL);
g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}")); g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
for (guint i = 0; i < self->attrs->len; i++) { for (guint i = 0; i < self->attrs->len; i++) {
FwupdBiosAttr *bios_attr = g_ptr_array_index(self->attrs, i); FwupdBiosSetting *bios_setting = g_ptr_array_index(self->attrs, i);
g_variant_builder_add_value(&builder, g_variant_builder_add_value(&builder,
fwupd_bios_attr_to_variant(bios_attr, trusted)); fwupd_bios_setting_to_variant(bios_setting, trusted));
} }
return g_variant_new("(aa{sv})", &builder); return g_variant_new("(aa{sv})", &builder);
} }
/** /**
* fu_bios_attrs_from_json: * fu_bios_settings_from_json:
* @self: a #FuBiosAttrs * @self: a #FuBiosSettings
* *
* Loads #FwupdBiosAttr objects from a JSON node. * Loads #FwupdBiosSetting objects from a JSON node.
* *
* Returns: TRUE if the objects were imported * Returns: TRUE if the objects were imported
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
gboolean gboolean
fu_bios_attrs_from_json(FuBiosAttrs *self, JsonNode *json_node, GError **error) fu_bios_settings_from_json(FuBiosSettings *self, JsonNode *json_node, GError **error)
{ {
JsonArray *array; JsonArray *array;
JsonObject *obj; JsonObject *obj;
@ -592,18 +592,18 @@ fu_bios_attrs_from_json(FuBiosAttrs *self, JsonNode *json_node, GError **error)
obj = json_node_get_object(json_node); obj = json_node_get_object(json_node);
/* this has to exist */ /* this has to exist */
if (!json_object_has_member(obj, "BiosAttributes")) { if (!json_object_has_member(obj, "BiosSettings")) {
g_set_error_literal(error, g_set_error_literal(error,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_INVALID_DATA, G_IO_ERROR_INVALID_DATA,
"no BiosAttributes property in object"); "no BiosSettings property in object");
return FALSE; return FALSE;
} }
array = json_object_get_array_member(obj, "BiosAttributes"); array = json_object_get_array_member(obj, "BiosSettings");
for (guint i = 0; i < json_array_get_length(array); i++) { for (guint i = 0; i < json_array_get_length(array); i++) {
JsonNode *node_tmp = json_array_get_element(array, i); JsonNode *node_tmp = json_array_get_element(array, i);
g_autoptr(FwupdBiosAttr) attr = fwupd_bios_attr_new(NULL, NULL); g_autoptr(FwupdBiosSetting) attr = fwupd_bios_setting_new(NULL, NULL);
if (!fwupd_bios_attr_from_json(attr, node_tmp, error)) if (!fwupd_bios_setting_from_json(attr, node_tmp, error))
return FALSE; return FALSE;
g_ptr_array_add(self->attrs, g_steal_pointer(&attr)); g_ptr_array_add(self->attrs, g_steal_pointer(&attr));
} }
@ -613,14 +613,14 @@ fu_bios_attrs_from_json(FuBiosAttrs *self, JsonNode *json_node, GError **error)
} }
/** /**
* fu_bios_attrs_new: * fu_bios_settings_new:
* *
* Returns: #FuBiosAttrs * Returns: #FuBiosSettings
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
FuBiosAttrs * FuBiosSettings *
fu_bios_attrs_new(void) fu_bios_settings_new(void)
{ {
return g_object_new(FU_TYPE_FIRMWARE_ATTRS, NULL); return g_object_new(FU_TYPE_FIRMWARE_ATTRS, NULL);
} }

View File

@ -0,0 +1,20 @@
/*
* Copyright (C) 2022 Mario Limonciello <mario.limonciello@amd.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <libfwupd/fwupd-bios-setting.h>
#define FU_TYPE_FIRMWARE_ATTRS (fu_bios_settings_get_type())
G_DECLARE_FINAL_TYPE(FuBiosSettings, fu_bios_settings, FU, BIOS_SETTINGS, GObject)
FuBiosSettings *
fu_bios_settings_new(void);
gboolean
fu_bios_settings_get_pending_reboot(FuBiosSettings *self, gboolean *result, GError **error);
FwupdBiosSetting *
fu_bios_settings_get_attr(FuBiosSettings *self, const gchar *val);

View File

@ -13,7 +13,7 @@
FuContext * FuContext *
fu_context_new(void); fu_context_new(void);
gboolean gboolean
fu_context_reload_bios_attrs(FuContext *self, GError **error); fu_context_reload_bios_settings(FuContext *self, GError **error);
gboolean gboolean
fu_context_load_hwinfo(FuContext *self, GError **error); fu_context_load_hwinfo(FuContext *self, GError **error);
gboolean gboolean

View File

@ -8,7 +8,7 @@
#include "config.h" #include "config.h"
#include "fu-bios-attrs-private.h" #include "fu-bios-settings-private.h"
#include "fu-context-private.h" #include "fu-context-private.h"
#include "fu-hwids.h" #include "fu-hwids.h"
#include "fu-smbios-private.h" #include "fu-smbios-private.h"
@ -33,7 +33,7 @@ typedef struct {
FuLidState lid_state; FuLidState lid_state;
guint battery_level; guint battery_level;
guint battery_threshold; guint battery_threshold;
FuBiosAttrs *host_bios_attrs; FuBiosSettings *host_bios_settings;
} FuContextPrivate; } FuContextPrivate;
enum { SIGNAL_SECURITY_CHANGED, SIGNAL_LAST }; enum { SIGNAL_SECURITY_CHANGED, SIGNAL_LAST };
@ -119,7 +119,7 @@ fu_context_get_smbios_integer(FuContext *self, guint8 type, guint8 offset)
} }
/** /**
* fu_context_reload_bios_attrs: * fu_context_reload_bios_settings:
* @self: a #FuContext * @self: a #FuContext
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
@ -128,68 +128,68 @@ fu_context_get_smbios_integer(FuContext *self, guint8 type, guint8 offset)
* Since: 1.8.4 * Since: 1.8.4
**/ **/
gboolean gboolean
fu_context_reload_bios_attrs(FuContext *self, GError **error) fu_context_reload_bios_settings(FuContext *self, GError **error)
{ {
FuContextPrivate *priv = GET_PRIVATE(self); FuContextPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(FU_IS_CONTEXT(self), FALSE); g_return_val_if_fail(FU_IS_CONTEXT(self), FALSE);
return fu_bios_attrs_setup(priv->host_bios_attrs, error); return fu_bios_settings_setup(priv->host_bios_settings, error);
} }
/** /**
* fu_context_get_bios_attrs: * fu_context_get_bios_settings:
* @self: a #FuContext * @self: a #FuContext
* *
* Returns all the firmware attributes defined in the system. * Returns all the firmware attributes defined in the system.
* *
* Returns: (transfer full): A #FuBiosAttrs * Returns: (transfer full): A #FuBiosSettings
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
FuBiosAttrs * FuBiosSettings *
fu_context_get_bios_attrs(FuContext *self) fu_context_get_bios_settings(FuContext *self)
{ {
FuContextPrivate *priv = GET_PRIVATE(self); FuContextPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(FU_IS_CONTEXT(self), NULL); g_return_val_if_fail(FU_IS_CONTEXT(self), NULL);
return g_object_ref(priv->host_bios_attrs); return g_object_ref(priv->host_bios_settings);
} }
/** /**
* fu_context_get_bios_attr: * fu_context_get_bios_setting:
* @self: a #FuContext * @self: a #FuContext
* @name: a BIOS attribute title, e.g. `BootOrderLock` * @name: a BIOS setting title, e.g. `BootOrderLock`
* *
* Finds out if a system supports a given BIOS attribute. * Finds out if a system supports a given BIOS setting.
* *
* Returns: (transfer none): #FwupdBiosAttr if the attr exists. * Returns: (transfer none): #FwupdBiosSetting if the attr exists.
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
FwupdBiosAttr * FwupdBiosSetting *
fu_context_get_bios_attr(FuContext *self, const gchar *name) fu_context_get_bios_setting(FuContext *self, const gchar *name)
{ {
FuContextPrivate *priv = GET_PRIVATE(self); FuContextPrivate *priv = GET_PRIVATE(self);
g_return_val_if_fail(FU_IS_CONTEXT(self), NULL); g_return_val_if_fail(FU_IS_CONTEXT(self), NULL);
g_return_val_if_fail(name != NULL, NULL); g_return_val_if_fail(name != NULL, NULL);
return fu_bios_attrs_get_attr(priv->host_bios_attrs, name); return fu_bios_settings_get_attr(priv->host_bios_settings, name);
} }
/** /**
* fu_context_get_bios_attr_pending_reboot: * fu_context_get_bios_setting_pending_reboot:
* @self: a #FuContext * @self: a #FuContext
* *
* Determine if updates to BIOS attributes are pending until next boot. * Determine if updates to BIOS settings are pending until next boot.
* *
* Returns: %TRUE if updates are pending. * Returns: %TRUE if updates are pending.
* *
* Since: 1.8.4 * Since: 1.8.4
**/ **/
gboolean gboolean
fu_context_get_bios_attr_pending_reboot(FuContext *self) fu_context_get_bios_setting_pending_reboot(FuContext *self)
{ {
FuContextPrivate *priv = GET_PRIVATE(self); FuContextPrivate *priv = GET_PRIVATE(self);
gboolean ret; gboolean ret;
g_return_val_if_fail(FU_IS_CONTEXT(self), FALSE); g_return_val_if_fail(FU_IS_CONTEXT(self), FALSE);
fu_bios_attrs_get_pending_reboot(priv->host_bios_attrs, &ret, NULL); fu_bios_settings_get_pending_reboot(priv->host_bios_settings, &ret, NULL);
return ret; return ret;
} }
@ -889,7 +889,7 @@ fu_context_finalize(GObject *object)
g_hash_table_unref(priv->hwid_flags); g_hash_table_unref(priv->hwid_flags);
g_object_unref(priv->quirks); g_object_unref(priv->quirks);
g_object_unref(priv->smbios); g_object_unref(priv->smbios);
g_object_unref(priv->host_bios_attrs); g_object_unref(priv->host_bios_settings);
g_hash_table_unref(priv->firmware_gtypes); g_hash_table_unref(priv->firmware_gtypes);
g_ptr_array_unref(priv->udev_subsystems); g_ptr_array_unref(priv->udev_subsystems);
@ -1004,7 +1004,7 @@ fu_context_init(FuContext *self)
priv->udev_subsystems = g_ptr_array_new_with_free_func(g_free); priv->udev_subsystems = g_ptr_array_new_with_free_func(g_free);
priv->firmware_gtypes = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); priv->firmware_gtypes = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
priv->quirks = fu_quirks_new(); priv->quirks = fu_quirks_new();
priv->host_bios_attrs = fu_bios_attrs_new(); priv->host_bios_settings = fu_bios_settings_new();
} }
/** /**

View File

@ -8,7 +8,7 @@
#include <gio/gio.h> #include <gio/gio.h>
#include "fu-bios-attrs.h" #include "fu-bios-settings.h"
#include "fu-common.h" #include "fu-common.h"
#define FU_TYPE_CONTEXT (fu_context_get_type()) #define FU_TYPE_CONTEXT (fu_context_get_type())
@ -87,9 +87,9 @@ fu_context_get_battery_threshold(FuContext *self);
void void
fu_context_set_battery_threshold(FuContext *self, guint battery_threshold); fu_context_set_battery_threshold(FuContext *self, guint battery_threshold);
FuBiosAttrs * FuBiosSettings *
fu_context_get_bios_attrs(FuContext *self); fu_context_get_bios_settings(FuContext *self);
gboolean gboolean
fu_context_get_bios_attr_pending_reboot(FuContext *self); fu_context_get_bios_setting_pending_reboot(FuContext *self);
FwupdBiosAttr * FwupdBiosSetting *
fu_context_get_bios_attr(FuContext *self, const gchar *name); fu_context_get_bios_setting(FuContext *self, const gchar *name);

View File

@ -21,7 +21,7 @@ G_DEFINE_TYPE_WITH_PRIVATE(FuSecurityAttr, fu_security_attr, FWUPD_TYPE_SECURITY
/** /**
* fu_security_attr_add_bios_target_value: * fu_security_attr_add_bios_target_value:
* @attr: a #FwupdSecurityAttr * @attr: a #FwupdSecurityAttr
* @id: a #FwupdBiosAttr ID or name * @id: a #FwupdBiosSetting ID or name
* @needle: The substring of a target value * @needle: The substring of a target value
* *
* Checks all configured possible values of an enumeration attribute and * Checks all configured possible values of an enumeration attribute and
@ -36,26 +36,26 @@ fu_security_attr_add_bios_target_value(FwupdSecurityAttr *attr,
{ {
FuSecurityAttr *self = FU_SECURITY_ATTR(attr); FuSecurityAttr *self = FU_SECURITY_ATTR(attr);
FuSecurityAttrPrivate *priv = GET_PRIVATE(self); FuSecurityAttrPrivate *priv = GET_PRIVATE(self);
FwupdBiosAttr *bios_attr; FwupdBiosSetting *bios_setting;
GPtrArray *values; GPtrArray *values;
bios_attr = fu_context_get_bios_attr(priv->ctx, id); bios_setting = fu_context_get_bios_setting(priv->ctx, id);
if (bios_attr == NULL) if (bios_setting == NULL)
return; return;
fwupd_security_attr_set_bios_attr_id(attr, fwupd_bios_attr_get_id(bios_attr)); fwupd_security_attr_set_bios_setting_id(attr, fwupd_bios_setting_get_id(bios_setting));
fwupd_security_attr_set_bios_attr_current_value( fwupd_security_attr_set_bios_setting_current_value(
attr, attr,
fwupd_bios_attr_get_current_value(bios_attr)); fwupd_bios_setting_get_current_value(bios_setting));
if (fwupd_bios_attr_get_kind(bios_attr) != FWUPD_BIOS_ATTR_KIND_ENUMERATION) if (fwupd_bios_setting_get_kind(bios_setting) != FWUPD_BIOS_SETTING_KIND_ENUMERATION)
return; return;
if (fwupd_bios_attr_get_read_only(bios_attr)) if (fwupd_bios_setting_get_read_only(bios_setting))
return; return;
values = fwupd_bios_attr_get_possible_values(bios_attr); values = fwupd_bios_setting_get_possible_values(bios_setting);
for (guint i = 0; i < values->len; i++) { for (guint i = 0; i < values->len; i++) {
const gchar *possible = g_ptr_array_index(values, i); const gchar *possible = g_ptr_array_index(values, i);
g_autofree gchar *lower = g_utf8_strdown(possible, -1); g_autofree gchar *lower = g_utf8_strdown(possible, -1);
if (g_strrstr(lower, needle)) { if (g_strrstr(lower, needle)) {
fwupd_security_attr_set_bios_attr_target_value(attr, possible); fwupd_security_attr_set_bios_setting_target_value(attr, possible);
return; return;
} }
} }

View File

@ -12,10 +12,10 @@
#include <libgcab.h> #include <libgcab.h>
#include <string.h> #include <string.h>
#include "fwupd-bios-attr-private.h" #include "fwupd-bios-setting-private.h"
#include "fwupd-security-attr-private.h" #include "fwupd-security-attr-private.h"
#include "fu-bios-attrs-private.h" #include "fu-bios-settings-private.h"
#include "fu-cabinet.h" #include "fu-cabinet.h"
#include "fu-common-private.h" #include "fu-common-private.h"
#include "fu-context-private.h" #include "fu-context-private.h"
@ -2911,52 +2911,52 @@ fu_device_retry_hardware_func(void)
} }
static void static void
fu_bios_attrs_load_func(void) fu_bios_settings_load_func(void)
{ {
gboolean ret; gboolean ret;
gint integer; gint integer;
const gchar *tmp; const gchar *tmp;
GPtrArray *values; GPtrArray *values;
FwupdBiosAttr *attr; FwupdBiosSetting *setting;
FwupdBiosAttrKind kind; FwupdBiosSettingKind kind;
g_autofree gchar *test_dir = NULL; g_autofree gchar *test_dir = NULL;
g_autoptr(FuContext) ctx = fu_context_new(); g_autoptr(FuContext) ctx = fu_context_new();
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(FuBiosAttrs) p620_attrs = NULL; g_autoptr(FuBiosSettings) p620_settings = NULL;
g_autoptr(FuBiosAttrs) p14s_attrs = NULL; g_autoptr(FuBiosSettings) p14s_settings = NULL;
g_autoptr(FuBiosAttrs) xps9310_attrs = NULL; g_autoptr(FuBiosSettings) xp29310_settings = NULL;
g_autoptr(GPtrArray) p14s_items = NULL; g_autoptr(GPtrArray) p14s_items = NULL;
g_autoptr(GPtrArray) p620_items = NULL; g_autoptr(GPtrArray) p620_items = NULL;
g_autoptr(GPtrArray) xps9310_items = NULL; g_autoptr(GPtrArray) xps9310_items = NULL;
/* Load attrs from a Lenovo P620 (with thinklmi driver problems) */ /* load BIOS settings from a Lenovo P620 (with thinklmi driver problems) */
test_dir = g_test_build_filename(G_TEST_DIST, "tests", "bios-attrs", "lenovo-p620", NULL); test_dir = g_test_build_filename(G_TEST_DIST, "tests", "bios-attrs", "lenovo-p620", NULL);
(void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE); (void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE);
g_test_expect_message("FuBiosAttrs", G_LOG_LEVEL_WARNING, "*BUG*"); g_test_expect_message("FuBiosSettings", G_LOG_LEVEL_WARNING, "*BUG*");
ret = fu_context_reload_bios_attrs(ctx, &error); ret = fu_context_reload_bios_settings(ctx, &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
g_test_assert_expected_messages(); g_test_assert_expected_messages();
p620_attrs = fu_context_get_bios_attrs(ctx); p620_settings = fu_context_get_bios_settings(ctx);
p620_items = fu_bios_attrs_get_all(p620_attrs); p620_items = fu_bios_settings_get_all(p620_settings);
g_assert_cmpint(p620_items->len, ==, 128); g_assert_cmpint(p620_items->len, ==, 128);
/* make sure nothing pending */ /* make sure nothing pending */
ret = fu_context_get_bios_attr_pending_reboot(ctx); ret = fu_context_get_bios_setting_pending_reboot(ctx);
g_assert_false(ret); g_assert_false(ret);
/* check an attribute reads from kernel as expected by fwupd today */ /* check a BIOS setting reads from kernel as expected by fwupd today */
attr = fu_context_get_bios_attr(ctx, "com.thinklmi.AMDMemoryGuard"); setting = fu_context_get_bios_setting(ctx, "com.thinklmi.AMDMemoryGuard");
g_assert_nonnull(attr); g_assert_nonnull(setting);
tmp = fwupd_bios_attr_get_name(attr); tmp = fwupd_bios_setting_get_name(setting);
g_assert_cmpstr(tmp, ==, "AMDMemoryGuard"); g_assert_cmpstr(tmp, ==, "AMDMemoryGuard");
tmp = fwupd_bios_attr_get_description(attr); tmp = fwupd_bios_setting_get_description(setting);
g_assert_cmpstr(tmp, ==, "AMDMemoryGuard"); g_assert_cmpstr(tmp, ==, "AMDMemoryGuard");
tmp = fwupd_bios_attr_get_current_value(attr); tmp = fwupd_bios_setting_get_current_value(setting);
g_assert_cmpstr(tmp, ==, "Disable"); g_assert_cmpstr(tmp, ==, "Disable");
values = fwupd_bios_attr_get_possible_values(attr); values = fwupd_bios_setting_get_possible_values(setting);
for (guint i = 0; i < values->len; i++) { for (guint i = 0; i < values->len; i++) {
const gchar *possible = g_ptr_array_index(values, i); const gchar *possible = g_ptr_array_index(values, i);
if (i == 0) if (i == 0)
@ -2965,14 +2965,14 @@ fu_bios_attrs_load_func(void)
g_assert_cmpstr(possible, ==, "Enable"); g_assert_cmpstr(possible, ==, "Enable");
} }
/* try to read an attribute known to have ][Status] to make sure we worked /* try to read an BIOS setting known to have ][Status] to make sure we worked
* around the thinklmi bug sufficiently * around the thinklmi bug sufficiently
*/ */
attr = fu_context_get_bios_attr(ctx, "com.thinklmi.StartupSequence"); setting = fu_context_get_bios_setting(ctx, "com.thinklmi.StartupSequence");
g_assert_nonnull(attr); g_assert_nonnull(setting);
tmp = fwupd_bios_attr_get_current_value(attr); tmp = fwupd_bios_setting_get_current_value(setting);
g_assert_cmpstr(tmp, ==, "Primary"); g_assert_cmpstr(tmp, ==, "Primary");
values = fwupd_bios_attr_get_possible_values(attr); values = fwupd_bios_setting_get_possible_values(setting);
for (guint i = 0; i < values->len; i++) { for (guint i = 0; i < values->len; i++) {
const gchar *possible = g_ptr_array_index(values, i); const gchar *possible = g_ptr_array_index(values, i);
if (i == 0) if (i == 0)
@ -2981,40 +2981,40 @@ fu_bios_attrs_load_func(void)
g_assert_cmpstr(possible, ==, "Automatic"); g_assert_cmpstr(possible, ==, "Automatic");
} }
/* check no attributes have [Status in them */ /* check no BIOS settings have [Status in them */
for (guint i = 0; i < p620_items->len; i++) { for (guint i = 0; i < p620_items->len; i++) {
attr = g_ptr_array_index(p620_items, i); setting = g_ptr_array_index(p620_items, i);
tmp = fwupd_bios_attr_get_current_value(attr); tmp = fwupd_bios_setting_get_current_value(setting);
g_debug("%s", tmp); g_debug("%s", tmp);
g_assert_null(g_strrstr(tmp, "[Status")); g_assert_null(g_strrstr(tmp, "[Status"));
} }
g_free(test_dir); g_free(test_dir);
/* Load attrs from a Lenovo P14s Gen1 */ /* load BIOS settings from a Lenovo P14s Gen1 */
test_dir = test_dir =
g_test_build_filename(G_TEST_DIST, "tests", "bios-attrs", "lenovo-p14s-gen1", NULL); g_test_build_filename(G_TEST_DIST, "tests", "bios-attrs", "lenovo-p14s-gen1", NULL);
(void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE); (void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE);
ret = fu_context_reload_bios_attrs(ctx, &error); ret = fu_context_reload_bios_settings(ctx, &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
p14s_attrs = fu_context_get_bios_attrs(ctx); p14s_settings = fu_context_get_bios_settings(ctx);
p14s_items = fu_bios_attrs_get_all(p14s_attrs); p14s_items = fu_bios_settings_get_all(p14s_settings);
g_assert_cmpint(p14s_items->len, ==, 75); g_assert_cmpint(p14s_items->len, ==, 75);
/* reboot should be pending on this one */ /* reboot should be pending on this one */
ret = fu_context_get_bios_attr_pending_reboot(ctx); ret = fu_context_get_bios_setting_pending_reboot(ctx);
g_assert_true(ret); g_assert_true(ret);
/* look for an enumeration attribute with a space */ /* look for an enumeration BIOS setting with a space */
attr = fu_context_get_bios_attr(ctx, "com.thinklmi.SleepState"); setting = fu_context_get_bios_setting(ctx, "com.thinklmi.SleepState");
g_assert_nonnull(attr); g_assert_nonnull(setting);
tmp = fwupd_bios_attr_get_name(attr); tmp = fwupd_bios_setting_get_name(setting);
g_assert_cmpstr(tmp, ==, "SleepState"); g_assert_cmpstr(tmp, ==, "SleepState");
tmp = fwupd_bios_attr_get_description(attr); tmp = fwupd_bios_setting_get_description(setting);
g_assert_cmpstr(tmp, ==, "SleepState"); g_assert_cmpstr(tmp, ==, "SleepState");
values = fwupd_bios_attr_get_possible_values(attr); values = fwupd_bios_setting_get_possible_values(setting);
for (guint i = 0; i < values->len; i++) { for (guint i = 0; i < values->len; i++) {
const gchar *possible = g_ptr_array_index(values, i); const gchar *possible = g_ptr_array_index(values, i);
if (i == 0) if (i == 0)
@ -3024,57 +3024,57 @@ fu_bios_attrs_load_func(void)
} }
/* make sure we defaulted UEFI Secure boot to read only if enabled */ /* make sure we defaulted UEFI Secure boot to read only if enabled */
attr = fu_context_get_bios_attr(ctx, "com.thinklmi.SecureBoot"); setting = fu_context_get_bios_setting(ctx, "com.thinklmi.SecureBoot");
g_assert_nonnull(attr); g_assert_nonnull(setting);
ret = fwupd_bios_attr_get_read_only(attr); ret = fwupd_bios_setting_get_read_only(setting);
g_assert_true(ret); g_assert_true(ret);
g_free(test_dir); g_free(test_dir);
/* load attrs from a Dell XPS 9310 */ /* load BIOS settings from a Dell XPS 9310 */
test_dir = test_dir =
g_test_build_filename(G_TEST_DIST, "tests", "bios-attrs", "dell-xps13-9310", NULL); g_test_build_filename(G_TEST_DIST, "tests", "bios-attrs", "dell-xps13-9310", NULL);
(void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE); (void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE);
ret = fu_context_reload_bios_attrs(ctx, &error); ret = fu_context_reload_bios_settings(ctx, &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
xps9310_attrs = fu_context_get_bios_attrs(ctx); xp29310_settings = fu_context_get_bios_settings(ctx);
xps9310_items = fu_bios_attrs_get_all(xps9310_attrs); xps9310_items = fu_bios_settings_get_all(xp29310_settings);
g_assert_cmpint(xps9310_items->len, ==, 109); g_assert_cmpint(xps9310_items->len, ==, 109);
/* make sure that we DIDN'T parse reset_bios attribute */ /* make sure that we DIDN'T parse reset_bios setting */
attr = fu_context_get_bios_attr(ctx, FWUPD_BIOS_ATTR_RESET_BIOS); setting = fu_context_get_bios_setting(ctx, FWUPD_BIOS_SETTING_RESET_BIOS);
g_assert_null(attr); g_assert_null(setting);
/* look at a integer attribute */ /* look at a integer BIOS setting */
attr = fu_context_get_bios_attr(ctx, "com.dell-wmi-sysman.CustomChargeStop"); setting = fu_context_get_bios_setting(ctx, "com.dell-wmi-sysman.CustomChargeStop");
g_assert_nonnull(attr); g_assert_nonnull(setting);
kind = fwupd_bios_attr_get_kind(attr); kind = fwupd_bios_setting_get_kind(setting);
g_assert_cmpint(kind, ==, FWUPD_BIOS_ATTR_KIND_INTEGER); g_assert_cmpint(kind, ==, FWUPD_BIOS_SETTING_KIND_INTEGER);
integer = fwupd_bios_attr_get_lower_bound(attr); integer = fwupd_bios_setting_get_lower_bound(setting);
g_assert_cmpint(integer, ==, 55); g_assert_cmpint(integer, ==, 55);
integer = fwupd_bios_attr_get_upper_bound(attr); integer = fwupd_bios_setting_get_upper_bound(setting);
g_assert_cmpint(integer, ==, 100); g_assert_cmpint(integer, ==, 100);
integer = fwupd_bios_attr_get_scalar_increment(attr); integer = fwupd_bios_setting_get_scalar_increment(setting);
g_assert_cmpint(integer, ==, 1); g_assert_cmpint(integer, ==, 1);
/* look at a string attribute */ /* look at a string BIOS setting */
attr = fu_context_get_bios_attr(ctx, "com.dell-wmi-sysman.Asset"); setting = fu_context_get_bios_setting(ctx, "com.dell-wmi-sysman.Asset");
g_assert_nonnull(attr); g_assert_nonnull(setting);
integer = fwupd_bios_attr_get_lower_bound(attr); integer = fwupd_bios_setting_get_lower_bound(setting);
g_assert_cmpint(integer, ==, 1); g_assert_cmpint(integer, ==, 1);
integer = fwupd_bios_attr_get_upper_bound(attr); integer = fwupd_bios_setting_get_upper_bound(setting);
g_assert_cmpint(integer, ==, 64); g_assert_cmpint(integer, ==, 64);
tmp = fwupd_bios_attr_get_description(attr); tmp = fwupd_bios_setting_get_description(setting);
g_assert_cmpstr(tmp, ==, "Asset Tag"); g_assert_cmpstr(tmp, ==, "Asset Tag");
/* look at a enumeration attribute */ /* look at a enumeration BIOS setting */
attr = fu_context_get_bios_attr(ctx, "com.dell-wmi-sysman.BiosRcvrFrmHdd"); setting = fu_context_get_bios_setting(ctx, "com.dell-wmi-sysman.BiosRcvrFrmHdd");
g_assert_nonnull(attr); g_assert_nonnull(setting);
kind = fwupd_bios_attr_get_kind(attr); kind = fwupd_bios_setting_get_kind(setting);
g_assert_cmpint(kind, ==, FWUPD_BIOS_ATTR_KIND_ENUMERATION); g_assert_cmpint(kind, ==, FWUPD_BIOS_SETTING_KIND_ENUMERATION);
values = fwupd_bios_attr_get_possible_values(attr); values = fwupd_bios_setting_get_possible_values(setting);
for (guint i = 0; i < values->len; i++) { for (guint i = 0; i < values->len; i++) {
const gchar *possible = g_ptr_array_index(values, i); const gchar *possible = g_ptr_array_index(values, i);
if (i == 0) if (i == 0)
@ -3084,9 +3084,9 @@ fu_bios_attrs_load_func(void)
} }
/* make sure we defaulted UEFI Secure boot to read only if enabled */ /* make sure we defaulted UEFI Secure boot to read only if enabled */
attr = fu_context_get_bios_attr(ctx, "com.dell-wmi-sysman.SecureBoot"); setting = fu_context_get_bios_setting(ctx, "com.dell-wmi-sysman.SecureBoot");
g_assert_nonnull(attr); g_assert_nonnull(setting);
ret = fwupd_bios_attr_get_read_only(attr); ret = fwupd_bios_setting_get_read_only(setting);
g_assert_true(ret); g_assert_true(ret);
} }
@ -3586,7 +3586,7 @@ main(int argc, char **argv)
g_test_add_func("/fwupd/progress{parent-1-step}", fu_progress_parent_one_step_proxy_func); g_test_add_func("/fwupd/progress{parent-1-step}", fu_progress_parent_one_step_proxy_func);
g_test_add_func("/fwupd/progress{no-equal}", fu_progress_non_equal_steps_func); g_test_add_func("/fwupd/progress{no-equal}", fu_progress_non_equal_steps_func);
g_test_add_func("/fwupd/progress{finish}", fu_progress_finish_func); g_test_add_func("/fwupd/progress{finish}", fu_progress_finish_func);
g_test_add_func("/fwupd/bios-attrs{load}", fu_bios_attrs_load_func); g_test_add_func("/fwupd/bios-attrs{load}", fu_bios_settings_load_func);
g_test_add_func("/fwupd/security-attrs{hsi}", fu_security_attrs_hsi_func); g_test_add_func("/fwupd/security-attrs{hsi}", fu_security_attrs_hsi_func);
g_test_add_func("/fwupd/plugin{devices}", fu_plugin_devices_func); g_test_add_func("/fwupd/plugin{devices}", fu_plugin_devices_func);
g_test_add_func("/fwupd/plugin{device-inhibit-children}", g_test_add_func("/fwupd/plugin{device-inhibit-children}",

View File

@ -12,7 +12,7 @@
#include <libfwupdplugin/fu-archive-firmware.h> #include <libfwupdplugin/fu-archive-firmware.h>
#include <libfwupdplugin/fu-archive.h> #include <libfwupdplugin/fu-archive.h>
#include <libfwupdplugin/fu-backend.h> #include <libfwupdplugin/fu-backend.h>
#include <libfwupdplugin/fu-bios-attrs.h> #include <libfwupdplugin/fu-bios-settings.h>
#include <libfwupdplugin/fu-bluez-device.h> #include <libfwupdplugin/fu-bluez-device.h>
#include <libfwupdplugin/fu-byte-array.h> #include <libfwupdplugin/fu-byte-array.h>
#include <libfwupdplugin/fu-bytes.h> #include <libfwupdplugin/fu-bytes.h>

View File

@ -1071,18 +1071,18 @@ LIBFWUPDPLUGIN_1.8.3 {
LIBFWUPDPLUGIN_1.8.4 { LIBFWUPDPLUGIN_1.8.4 {
global: global:
fu_backend_add_string; fu_backend_add_string;
fu_bios_attrs_from_json; fu_bios_settings_from_json;
fu_bios_attrs_get_all; fu_bios_settings_get_all;
fu_bios_attrs_get_attr; fu_bios_settings_get_attr;
fu_bios_attrs_get_pending_reboot; fu_bios_settings_get_pending_reboot;
fu_bios_attrs_get_type; fu_bios_settings_get_type;
fu_bios_attrs_new; fu_bios_settings_new;
fu_bios_attrs_setup; fu_bios_settings_setup;
fu_bios_attrs_to_variant; fu_bios_settings_to_variant;
fu_context_get_bios_attr; fu_context_get_bios_setting;
fu_context_get_bios_attr_pending_reboot; fu_context_get_bios_setting_pending_reboot;
fu_context_get_bios_attrs; fu_context_get_bios_settings;
fu_context_reload_bios_attrs; fu_context_reload_bios_settings;
fu_device_security_attr_new; fu_device_security_attr_new;
fu_plugin_add_string; fu_plugin_add_string;
fu_plugin_security_attr_new; fu_plugin_security_attr_new;

View File

@ -41,7 +41,7 @@ fwupdplugin_src = [
'fu-cfu-payload.c', # fuzzing 'fu-cfu-payload.c', # fuzzing
'fu-volume.c', # fuzzing 'fu-volume.c', # fuzzing
'fu-firmware.c', # fuzzing 'fu-firmware.c', # fuzzing
'fu-bios-attrs.c', # fuzzing 'fu-bios-settings.c', # fuzzing
'fu-firmware-common.c', # fuzzing 'fu-firmware-common.c', # fuzzing
'fu-dfuse-firmware.c', # fuzzing 'fu-dfuse-firmware.c', # fuzzing
'fu-fmap-firmware.c', # fuzzing 'fu-fmap-firmware.c', # fuzzing
@ -145,7 +145,7 @@ fwupdplugin_headers = [
'fu-linear-firmware.h', 'fu-linear-firmware.h',
'fu-volume.h', 'fu-volume.h',
'fu-firmware.h', 'fu-firmware.h',
'fu-bios-attrs.h', 'fu-bios-settings.h',
'fu-firmware-common.h', 'fu-firmware-common.h',
'fu-fmap-firmware.h', 'fu-fmap-firmware.h',
'fu-dfuse-firmware.h', 'fu-dfuse-firmware.h',
@ -193,7 +193,7 @@ fwupdplugin_headers_private = [
'fu-device-private.h', 'fu-device-private.h',
'fu-kenv.h', 'fu-kenv.h',
'fu-plugin-private.h', 'fu-plugin-private.h',
'fu-bios-attrs-private.h', 'fu-bios-settings-private.h',
'fu-security-attrs-private.h', 'fu-security-attrs-private.h',
'fu-smbios-private.h', 'fu-smbios-private.h',
'fu-udev-device-private.h', 'fu-udev-device-private.h',

View File

@ -15,7 +15,7 @@ fu_plugin_lenovo_thinklmi_startup(FuPlugin *plugin, FuProgress *progress, GError
{ {
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
if (fu_context_get_bios_attr(ctx, BOOT_ORDER_LOCK) == NULL) { if (fu_context_get_bios_setting(ctx, BOOT_ORDER_LOCK) == NULL) {
g_set_error_literal(error, g_set_error_literal(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
@ -30,25 +30,25 @@ static void
fu_plugin_lenovo_thinklmi_device_registered(FuPlugin *plugin, FuDevice *device) fu_plugin_lenovo_thinklmi_device_registered(FuPlugin *plugin, FuDevice *device)
{ {
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
FwupdBiosAttr *attr; FwupdBiosSetting *attr;
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
if (g_strcmp0(fu_device_get_plugin(device), "uefi_capsule") != 0) if (g_strcmp0(fu_device_get_plugin(device), "uefi_capsule") != 0)
return; return;
/* check if boot order lock is turned on */ /* check if boot order lock is turned on */
attr = fu_context_get_bios_attr(ctx, BOOT_ORDER_LOCK); attr = fu_context_get_bios_setting(ctx, BOOT_ORDER_LOCK);
if (!attr) { if (!attr) {
g_debug("failed to find %s in cache\n", BOOT_ORDER_LOCK); g_debug("failed to find %s in cache\n", BOOT_ORDER_LOCK);
return; return;
} }
if (g_strcmp0(fwupd_bios_attr_get_current_value(attr), "Enable") == 0) if (g_strcmp0(fwupd_bios_setting_get_current_value(attr), "Enable") == 0)
fu_device_inhibit(device, fu_device_inhibit(device,
"uefi-capsule-bootorder", "uefi-capsule-bootorder",
"BootOrder is locked in firmware setup"); "BootOrder is locked in firmware setup");
/* check if we're pending for a reboot */ /* check if we're pending for a reboot */
if (fu_context_get_bios_attr_pending_reboot(ctx)) if (fu_context_get_bios_setting_pending_reboot(ctx))
fu_device_inhibit(device, fu_device_inhibit(device,
"uefi-capsule-pending-reboot", "uefi-capsule-pending-reboot",
"UEFI BIOS settings update pending reboot"); "UEFI BIOS settings update pending reboot");

View File

@ -11,7 +11,7 @@
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "fu-bios-attrs-private.h" #include "fu-bios-settings-private.h"
#include "fu-context-private.h" #include "fu-context-private.h"
#include "fu-device-private.h" #include "fu-device-private.h"
#include "fu-plugin-private.h" #include "fu-plugin-private.h"
@ -39,7 +39,7 @@ fu_test_self_init(FuTest *self, GError **error_global)
g_autofree gchar *pluginfn_uefi = NULL; g_autofree gchar *pluginfn_uefi = NULL;
g_autofree gchar *pluginfn_lenovo = NULL; g_autofree gchar *pluginfn_lenovo = NULL;
g_test_expect_message("FuBiosAttrs", G_LOG_LEVEL_WARNING, "*KERNEL*BUG*"); g_test_expect_message("FuBiosSettings", G_LOG_LEVEL_WARNING, "*KERNEL*BUG*");
ret = fu_context_load_quirks(ctx, ret = fu_context_load_quirks(ctx,
FU_QUIRKS_LOAD_FLAG_NO_CACHE | FU_QUIRKS_LOAD_FLAG_NO_VERIFY, FU_QUIRKS_LOAD_FLAG_NO_CACHE | FU_QUIRKS_LOAD_FLAG_NO_VERIFY,
@ -49,7 +49,7 @@ fu_test_self_init(FuTest *self, GError **error_global)
ret = fu_context_load_hwinfo(ctx, &error); ret = fu_context_load_hwinfo(ctx, &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
ret = fu_context_reload_bios_attrs(ctx, &error); ret = fu_context_reload_bios_settings(ctx, &error);
g_assert_true(ret); g_assert_true(ret);
g_assert_no_error(error); g_assert_no_error(error);
g_test_assert_expected_messages(); g_test_assert_expected_messages();
@ -123,7 +123,7 @@ fu_plugin_lenovo_thinklmi_bootorder_locked(gconstpointer user_data)
g_test_build_filename(G_TEST_DIST, "tests", "firmware-attributes", "locked", NULL); g_test_build_filename(G_TEST_DIST, "tests", "firmware-attributes", "locked", NULL);
(void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE); (void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE);
ret = fu_context_reload_bios_attrs(self->ctx, &error); ret = fu_context_reload_bios_settings(self->ctx, &error);
g_assert_true(ret); g_assert_true(ret);
g_assert_no_error(error); g_assert_no_error(error);
@ -143,7 +143,7 @@ fu_plugin_lenovo_thinklmi_bootorder_unlocked(gconstpointer user_data)
g_test_build_filename(G_TEST_DIST, "tests", "firmware-attributes", "unlocked", NULL); g_test_build_filename(G_TEST_DIST, "tests", "firmware-attributes", "unlocked", NULL);
(void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE); (void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE);
ret = fu_context_reload_bios_attrs(self->ctx, &error); ret = fu_context_reload_bios_settings(self->ctx, &error);
g_assert_true(ret); g_assert_true(ret);
g_assert_no_error(error); g_assert_no_error(error);
dev = fu_test_probe_fake_esrt(self); dev = fu_test_probe_fake_esrt(self);
@ -165,7 +165,7 @@ fu_plugin_lenovo_thinklmi_reboot_pending(gconstpointer user_data)
NULL); NULL);
(void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE); (void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE);
ret = fu_context_reload_bios_attrs(self->ctx, &error); ret = fu_context_reload_bios_settings(self->ctx, &error);
g_assert_true(ret); g_assert_true(ret);
g_assert_no_error(error); g_assert_no_error(error);
dev = fu_test_probe_fake_esrt(self); dev = fu_test_probe_fake_esrt(self);

View File

@ -16,5 +16,5 @@ src/fu-remote-list.c
src/fu-security-attr-common.c src/fu-security-attr-common.c
src/fu-tool.c src/fu-tool.c
src/fu-util.c src/fu-util.c
src/fu-util-bios-attr.c src/fu-util-bios-setting.c
src/fu-util-common.c src/fu-util-common.c

View File

@ -184,10 +184,10 @@
</defaults> </defaults>
</action> </action>
<action id="org.freedesktop.fwupd.get-bios-attributes"> <action id="org.freedesktop.fwupd.get-bios-settings">
<description>Get BIOS attributes</description> <description>Get BIOS settings</description>
<!-- TRANSLATORS: this is the PolicyKit modal dialog --> <!-- TRANSLATORS: this is the PolicyKit modal dialog -->
<message>Authentication is required to read BIOS attributes</message> <message>Authentication is required to read BIOS settings</message>
<defaults> <defaults>
<allow_any>auth_admin</allow_any> <allow_any>auth_admin</allow_any>
<allow_inactive>no</allow_inactive> <allow_inactive>no</allow_inactive>
@ -195,8 +195,8 @@
</defaults> </defaults>
</action> </action>
<action id="org.freedesktop.fwupd.set-bios-attribute"> <action id="org.freedesktop.fwupd.set-bios-settings">
<description>Set a BIOS attribute</description> <description>Set one or more BIOS settings</description>
<!-- TRANSLATORS: this is the PolicyKit modal dialog --> <!-- TRANSLATORS: this is the PolicyKit modal dialog -->
<message>Authentication is required to modify BIOS settings</message> <message>Authentication is required to modify BIOS settings</message>
<defaults> <defaults>
@ -204,7 +204,7 @@
<allow_inactive>no</allow_inactive> <allow_inactive>no</allow_inactive>
<allow_active>auth_admin</allow_active> <allow_active>auth_admin</allow_active>
</defaults> </defaults>
<annotate key="org.freedesktop.policykit.imply">org.freedesktop.fwupd.get-bios-attributes</annotate> <annotate key="org.freedesktop.policykit.imply">org.freedesktop.fwupd.get-bios-settings</annotate>
</action> </action>
</policyconfig> </policyconfig>

View File

@ -18,7 +18,7 @@
#endif #endif
#include <jcat.h> #include <jcat.h>
#include "fwupd-bios-attr-private.h" #include "fwupd-bios-setting-private.h"
#include "fwupd-device-private.h" #include "fwupd-device-private.h"
#include "fwupd-enums-private.h" #include "fwupd-enums-private.h"
#include "fwupd-plugin-private.h" #include "fwupd-plugin-private.h"
@ -27,7 +27,7 @@
#include "fwupd-request-private.h" #include "fwupd-request-private.h"
#include "fwupd-security-attr-private.h" #include "fwupd-security-attr-private.h"
#include "fu-bios-attrs-private.h" #include "fu-bios-settings-private.h"
#include "fu-daemon.h" #include "fu-daemon.h"
#include "fu-device-private.h" #include "fu-device-private.h"
#include "fu-engine.h" #include "fu-engine.h"
@ -505,11 +505,11 @@ fu_daemon_authorize_unlock_cb(GObject *source, GAsyncResult *res, gpointer user_
} }
static void static void
fu_daemon_authorize_get_bios_attrs_cb(GObject *source, GAsyncResult *res, gpointer user_data) fu_daemon_authorize_get_bios_settings_cb(GObject *source, GAsyncResult *res, gpointer user_data)
{ {
g_autoptr(FuMainAuthHelper) helper = (FuMainAuthHelper *)user_data; g_autoptr(FuMainAuthHelper) helper = (FuMainAuthHelper *)user_data;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(FuBiosAttrs) attrs = NULL; g_autoptr(FuBiosSettings) attrs = NULL;
FuContext *ctx; FuContext *ctx;
GVariant *val = NULL; GVariant *val = NULL;
#ifdef HAVE_POLKIT #ifdef HAVE_POLKIT
@ -530,13 +530,13 @@ fu_daemon_authorize_get_bios_attrs_cb(GObject *source, GAsyncResult *res, gpoint
/* authenticated */ /* authenticated */
ctx = fu_engine_get_context(helper->self->engine); ctx = fu_engine_get_context(helper->self->engine);
attrs = fu_context_get_bios_attrs(ctx); attrs = fu_context_get_bios_settings(ctx);
val = fu_bios_attrs_to_variant(attrs, TRUE); val = fu_bios_settings_to_variant(attrs, TRUE);
g_dbus_method_invocation_return_value(helper->invocation, val); g_dbus_method_invocation_return_value(helper->invocation, val);
} }
static void static void
fu_daemon_authorize_set_bios_attrs_cb(GObject *source, GAsyncResult *res, gpointer user_data) fu_daemon_authorize_set_bios_settings_cb(GObject *source, GAsyncResult *res, gpointer user_data)
{ {
g_autoptr(FuMainAuthHelper) helper = (FuMainAuthHelper *)user_data; g_autoptr(FuMainAuthHelper) helper = (FuMainAuthHelper *)user_data;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
@ -557,7 +557,7 @@ fu_daemon_authorize_set_bios_attrs_cb(GObject *source, GAsyncResult *res, gpoint
#endif /* HAVE_POLKIT */ #endif /* HAVE_POLKIT */
/* authenticated */ /* authenticated */
if (!fu_engine_modify_bios_attrs(helper->self->engine, helper->bios_settings, &error)) { if (!fu_engine_modify_bios_settings(helper->self->engine, helper->bios_settings, &error)) {
g_dbus_method_invocation_return_gerror(helper->invocation, error); g_dbus_method_invocation_return_gerror(helper->invocation, error);
return; return;
} }
@ -1987,15 +1987,16 @@ fu_daemon_daemon_method_call(GDBusConnection *connection,
#endif /* HAVE_GIO_UNIX */ #endif /* HAVE_GIO_UNIX */
return; return;
} }
if (g_strcmp0(method_name, "GetBiosAttrs") == 0) { if (g_strcmp0(method_name, "GetBiosSettings") == 0) {
gboolean authenticate = fu_engine_request_get_feature_flags(request) & gboolean authenticate = fu_engine_request_get_feature_flags(request) &
FWUPD_FEATURE_FLAG_ALLOW_AUTHENTICATION; FWUPD_FEATURE_FLAG_ALLOW_AUTHENTICATION;
g_debug("Called %s", method_name); g_debug("Called %s", method_name);
if (!authenticate) { if (!authenticate) {
g_autoptr(FuBiosAttrs) attrs = g_autoptr(FuBiosSettings) attrs =
fu_context_get_bios_attrs(fu_engine_get_context(self->engine)); fu_context_get_bios_settings(fu_engine_get_context(self->engine));
val = fu_bios_attrs_to_variant(attrs, val = fu_bios_settings_to_variant(
attrs,
fu_engine_request_get_device_flags(request) & fu_engine_request_get_device_flags(request) &
FWUPD_DEVICE_FLAG_TRUSTED); FWUPD_DEVICE_FLAG_TRUSTED);
g_dbus_method_invocation_return_value(invocation, val); g_dbus_method_invocation_return_value(invocation, val);
@ -2015,19 +2016,21 @@ fu_daemon_daemon_method_call(GDBusConnection *connection,
polkit_authority_check_authorization( polkit_authority_check_authorization(
self->authority, self->authority,
subject, subject,
"org.freedesktop.fwupd.get-bios-attributes", "org.freedesktop.fwupd.get-bios-settings",
NULL, NULL,
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
NULL, NULL,
fu_daemon_authorize_get_bios_attrs_cb, fu_daemon_authorize_get_bios_settings_cb,
g_steal_pointer(&helper)); g_steal_pointer(&helper));
#else #else
fu_daemon_authorize_get_bios_attrs_cb(NULL, NULL, g_steal_pointer(&helper)); fu_daemon_authorize_get_bios_settings_cb(NULL,
NULL,
g_steal_pointer(&helper));
#endif /* HAVE_POLKIT */ #endif /* HAVE_POLKIT */
} }
return; return;
} }
if (g_strcmp0(method_name, "SetBiosAttrs") == 0) { if (g_strcmp0(method_name, "SetBiosSettings") == 0) {
g_autoptr(FuMainAuthHelper) helper = NULL; g_autoptr(FuMainAuthHelper) helper = NULL;
const gchar *key; const gchar *key;
const gchar *value; const gchar *value;
@ -2056,14 +2059,14 @@ fu_daemon_daemon_method_call(GDBusConnection *connection,
polkit_authority_check_authorization( polkit_authority_check_authorization(
self->authority, self->authority,
subject, subject,
"org.freedesktop.fwupd.set-bios-attribute", "org.freedesktop.fwupd.set-bios-settings",
NULL, NULL,
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
NULL, NULL,
fu_daemon_authorize_set_bios_attrs_cb, fu_daemon_authorize_set_bios_settings_cb,
g_steal_pointer(&helper)); g_steal_pointer(&helper));
#else #else
fu_daemon_authorize_set_bios_attrs_cb(NULL, NULL, g_steal_pointer(&helper)); fu_daemon_authorize_set_bios_settings_cb(NULL, NULL, g_steal_pointer(&helper));
#endif /* HAVE_POLKIT */ #endif /* HAVE_POLKIT */
return; return;

View File

@ -28,7 +28,7 @@
#include <fwupdplugin.h> #include <fwupdplugin.h>
#include "fwupd-bios-attr-private.h" #include "fwupd-bios-setting-private.h"
#include "fwupd-common-private.h" #include "fwupd-common-private.h"
#include "fwupd-device-private.h" #include "fwupd-device-private.h"
#include "fwupd-enums-private.h" #include "fwupd-enums-private.h"
@ -37,7 +37,7 @@
#include "fwupd-resources.h" #include "fwupd-resources.h"
#include "fwupd-security-attr-private.h" #include "fwupd-security-attr-private.h"
#include "fu-bios-attrs-private.h" #include "fu-bios-settings-private.h"
#include "fu-cabinet.h" #include "fu-cabinet.h"
#include "fu-context-private.h" #include "fu-context-private.h"
#include "fu-coswid-firmware.h" #include "fu-coswid-firmware.h"
@ -728,15 +728,15 @@ fu_engine_modify_remote(FuEngine *self,
} }
static gboolean static gboolean
fu_engine_update_bios_attr(FwupdBiosAttr *attr, const gchar *value, GError **error) fu_engine_update_bios_setting(FwupdBiosSetting *attr, const gchar *value, GError **error)
{ {
int fd; int fd;
g_autofree gchar *fn = g_autofree gchar *fn =
g_build_filename(fwupd_bios_attr_get_path(attr), "current_value", NULL); g_build_filename(fwupd_bios_setting_get_path(attr), "current_value", NULL);
g_autoptr(FuIOChannel) io = NULL; g_autoptr(FuIOChannel) io = NULL;
if (g_strcmp0(fwupd_bios_attr_get_current_value(attr), value) == 0) { if (g_strcmp0(fwupd_bios_setting_get_current_value(attr), value) == 0) {
g_debug("%s is already set to %s", fwupd_bios_attr_get_id(attr), value); g_debug("%s is already set to %s", fwupd_bios_setting_get_id(attr), value);
return TRUE; return TRUE;
} }
@ -762,9 +762,9 @@ fu_engine_update_bios_attr(FwupdBiosAttr *attr, const gchar *value, GError **err
FU_IO_CHANNEL_FLAG_NONE, FU_IO_CHANNEL_FLAG_NONE,
error)) error))
return FALSE; return FALSE;
fwupd_bios_attr_set_current_value(attr, value); fwupd_bios_setting_set_current_value(attr, value);
g_debug("set %s to %s", fwupd_bios_attr_get_id(attr), value); g_debug("set %s to %s", fwupd_bios_setting_get_id(attr), value);
return TRUE; return TRUE;
} }
@ -774,7 +774,7 @@ fu_engine_update_bios_attr(FwupdBiosAttr *attr, const gchar *value, GError **err
* error messages * error messages
*/ */
static gboolean static gboolean
fu_engine_validate_bios_attr_input(FwupdBiosAttr *attr, const gchar **value, GError **error) fu_engine_validate_bios_setting_input(FwupdBiosSetting *attr, const gchar **value, GError **error)
{ {
guint64 tmp = 0; guint64 tmp = 0;
@ -788,17 +788,17 @@ fu_engine_validate_bios_attr_input(FwupdBiosAttr *attr, const gchar **value, GEr
"attribute not found"); "attribute not found");
return FALSE; return FALSE;
} }
if (fwupd_bios_attr_get_read_only(attr)) { if (fwupd_bios_setting_get_read_only(attr)) {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
"%s is read only", "%s is read only",
fwupd_bios_attr_get_name(attr)); fwupd_bios_setting_get_name(attr));
return FALSE; return FALSE;
} else if (fwupd_bios_attr_get_kind(attr) == FWUPD_BIOS_ATTR_KIND_INTEGER) { } else if (fwupd_bios_setting_get_kind(attr) == FWUPD_BIOS_SETTING_KIND_INTEGER) {
if (!fu_strtoull(*value, &tmp, 0, G_MAXUINT64, error)) if (!fu_strtoull(*value, &tmp, 0, G_MAXUINT64, error))
return FALSE; return FALSE;
if (tmp < fwupd_bios_attr_get_lower_bound(attr)) { if (tmp < fwupd_bios_setting_get_lower_bound(attr)) {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
@ -806,10 +806,10 @@ fu_engine_validate_bios_attr_input(FwupdBiosAttr *attr, const gchar **value, GEr
"); expected at least %" G_GUINT64_FORMAT, "); expected at least %" G_GUINT64_FORMAT,
*value, *value,
tmp, tmp,
fwupd_bios_attr_get_lower_bound(attr)); fwupd_bios_setting_get_lower_bound(attr));
return FALSE; return FALSE;
} }
if (tmp > fwupd_bios_attr_get_upper_bound(attr)) { if (tmp > fwupd_bios_setting_get_upper_bound(attr)) {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
@ -817,12 +817,12 @@ fu_engine_validate_bios_attr_input(FwupdBiosAttr *attr, const gchar **value, GEr
"); expected no more than %" G_GUINT64_FORMAT, "); expected no more than %" G_GUINT64_FORMAT,
*value, *value,
tmp, tmp,
fwupd_bios_attr_get_upper_bound(attr)); fwupd_bios_setting_get_upper_bound(attr));
return FALSE; return FALSE;
} }
} else if (fwupd_bios_attr_get_kind(attr) == FWUPD_BIOS_ATTR_KIND_STRING) { } else if (fwupd_bios_setting_get_kind(attr) == FWUPD_BIOS_SETTING_KIND_STRING) {
tmp = strlen(*value); tmp = strlen(*value);
if (tmp < fwupd_bios_attr_get_lower_bound(attr)) { if (tmp < fwupd_bios_setting_get_lower_bound(attr)) {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
@ -830,10 +830,10 @@ fu_engine_validate_bios_attr_input(FwupdBiosAttr *attr, const gchar **value, GEr
"); expected at least %" G_GUINT64_FORMAT, "); expected at least %" G_GUINT64_FORMAT,
*value, *value,
tmp, tmp,
fwupd_bios_attr_get_lower_bound(attr)); fwupd_bios_setting_get_lower_bound(attr));
return FALSE; return FALSE;
} }
if (tmp > fwupd_bios_attr_get_upper_bound(attr)) { if (tmp > fwupd_bios_setting_get_upper_bound(attr)) {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
@ -841,11 +841,11 @@ fu_engine_validate_bios_attr_input(FwupdBiosAttr *attr, const gchar **value, GEr
"); expected no more than %" G_GUINT64_FORMAT, "); expected no more than %" G_GUINT64_FORMAT,
*value, *value,
tmp, tmp,
fwupd_bios_attr_get_upper_bound(attr)); fwupd_bios_setting_get_upper_bound(attr));
return FALSE; return FALSE;
} }
} else if (fwupd_bios_attr_get_kind(attr) == FWUPD_BIOS_ATTR_KIND_ENUMERATION) { } else if (fwupd_bios_setting_get_kind(attr) == FWUPD_BIOS_SETTING_KIND_ENUMERATION) {
const gchar *result = fwupd_bios_attr_map_possible_value(attr, *value, error); const gchar *result = fwupd_bios_setting_map_possible_value(attr, *value, error);
if (result == NULL) if (result == NULL)
return FALSE; return FALSE;
*value = result; *value = result;
@ -860,34 +860,34 @@ fu_engine_validate_bios_attr_input(FwupdBiosAttr *attr, const gchar **value, GEr
} }
static gboolean static gboolean
fu_engine_modify_single_bios_attr(FuEngine *self, fu_engine_modify_single_bios_setting(FuEngine *self,
const gchar *key, const gchar *key,
const gchar *value, const gchar *value,
GError **error) GError **error)
{ {
FwupdBiosAttr *attr = fu_context_get_bios_attr(self->ctx, key); FwupdBiosSetting *attr = fu_context_get_bios_setting(self->ctx, key);
const gchar *tmp = value; const gchar *tmp = value;
if (!fu_engine_validate_bios_attr_input(attr, &tmp, error)) if (!fu_engine_validate_bios_setting_input(attr, &tmp, error))
return FALSE; return FALSE;
return fu_engine_update_bios_attr(attr, tmp, error); return fu_engine_update_bios_setting(attr, tmp, error);
} }
/** /**
* fu_engine_modify_bios_attrs: * fu_engine_modify_bios_settings:
* @self: a #FuEngine * @self: a #FuEngine
* @settings: Hashtable of settings/values to configure * @settings: Hashtable of settings/values to configure
* @error: (nullable): optional return location for an error * @error: (nullable): optional return location for an error
* *
* Use the kernel API to set one or more BIOS attributes. * Use the kernel API to set one or more BIOS settings.
* *
* Returns: %TRUE for success * Returns: %TRUE for success
**/ **/
gboolean gboolean
fu_engine_modify_bios_attrs(FuEngine *self, GHashTable *settings, GError **error) fu_engine_modify_bios_settings(FuEngine *self, GHashTable *settings, GError **error)
{ {
FwupdBiosAttr *pending; FwupdBiosSetting *pending;
GHashTableIter iter; GHashTableIter iter;
gpointer key, value; gpointer key, value;
@ -905,20 +905,20 @@ fu_engine_modify_bios_attrs(FuEngine *self, GHashTable *settings, GError **error
(const gchar *)key); (const gchar *)key);
return FALSE; return FALSE;
} }
if (!fu_engine_modify_single_bios_attr(self, key, value, error)) if (!fu_engine_modify_single_bios_setting(self, key, value, error))
return FALSE; return FALSE;
} }
pending = fu_context_get_bios_attr(self->ctx, FWUPD_BIOS_ATTR_PENDING_REBOOT); pending = fu_context_get_bios_setting(self->ctx, FWUPD_BIOS_SETTING_PENDING_REBOOT);
if (pending == NULL) { if (pending == NULL) {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_FOUND, FWUPD_ERROR_NOT_FOUND,
"attribute %s not found", "attribute %s not found",
FWUPD_BIOS_ATTR_PENDING_REBOOT); FWUPD_BIOS_SETTING_PENDING_REBOOT);
return FALSE; return FALSE;
} }
fwupd_bios_attr_set_current_value(pending, "1"); fwupd_bios_setting_set_current_value(pending, "1");
return TRUE; return TRUE;
} }
@ -6505,10 +6505,10 @@ fu_engine_security_attrs_from_json(FuEngine *self, JsonNode *json_node, GError *
} }
static gboolean static gboolean
fu_engine_bios_attrs_from_json(FuEngine *self, JsonNode *json_node, GError **error) fu_engine_bios_settings_from_json(FuEngine *self, JsonNode *json_node, GError **error)
{ {
JsonObject *obj; JsonObject *obj;
g_autoptr(FuBiosAttrs) bios_attrs = fu_context_get_bios_attrs(self->ctx); g_autoptr(FuBiosSettings) bios_settings = fu_context_get_bios_settings(self->ctx);
/* sanity check */ /* sanity check */
if (!JSON_NODE_HOLDS_OBJECT(json_node)) { if (!JSON_NODE_HOLDS_OBJECT(json_node)) {
@ -6518,9 +6518,9 @@ fu_engine_bios_attrs_from_json(FuEngine *self, JsonNode *json_node, GError **err
/* not supplied */ /* not supplied */
obj = json_node_get_object(json_node); obj = json_node_get_object(json_node);
if (!json_object_has_member(obj, "BiosAttributes")) if (!json_object_has_member(obj, "BiosSettings"))
return TRUE; return TRUE;
if (!fu_bios_attrs_from_json(bios_attrs, json_node, error)) if (!fu_bios_settings_from_json(bios_settings, json_node, error))
return FALSE; return FALSE;
/* success */ /* success */
@ -6595,7 +6595,7 @@ fu_engine_load_host_emulation(FuEngine *self, const gchar *fn, GError **error)
return FALSE; return FALSE;
if (!fu_engine_security_attrs_from_json(self, json_parser_get_root(parser), error)) if (!fu_engine_security_attrs_from_json(self, json_parser_get_root(parser), error))
return FALSE; return FALSE;
if (!fu_engine_bios_attrs_from_json(self, json_parser_get_root(parser), error)) if (!fu_engine_bios_settings_from_json(self, json_parser_get_root(parser), error))
return FALSE; return FALSE;
#ifdef HAVE_HSI #ifdef HAVE_HSI
@ -6893,7 +6893,7 @@ fu_engine_check_firmware_attributes(FuEngine *self, FuDevice *device)
subsystem = fu_udev_device_get_subsystem(FU_UDEV_DEVICE(device)); subsystem = fu_udev_device_get_subsystem(FU_UDEV_DEVICE(device));
if (g_strcmp0(subsystem, "firmware-attributes") == 0) { if (g_strcmp0(subsystem, "firmware-attributes") == 0) {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
if (!fu_context_reload_bios_attrs(self->ctx, &error)) if (!fu_context_reload_bios_settings(self->ctx, &error))
g_debug("%s", error->message); g_debug("%s", error->message);
} }
} }

View File

@ -244,4 +244,4 @@ fu_engine_schedule_update(FuEngine *self,
GError * GError *
fu_engine_error_array_get_best(GPtrArray *errors); fu_engine_error_array_get_best(GPtrArray *errors);
gboolean gboolean
fu_engine_modify_bios_attrs(FuEngine *self, GHashTable *settings, GError **error); fu_engine_modify_bios_settings(FuEngine *self, GHashTable *settings, GError **error);

View File

@ -13,10 +13,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "fwupd-bios-attr-private.h" #include "fwupd-bios-setting-private.h"
#include "fwupd-security-attr-private.h" #include "fwupd-security-attr-private.h"
#include "fu-bios-attrs-private.h" #include "fu-bios-settings-private.h"
#include "fu-cabinet-common.h" #include "fu-cabinet-common.h"
#include "fu-config.h" #include "fu-config.h"
#include "fu-context-private.h" #include "fu-context-private.h"
@ -4475,18 +4475,18 @@ fu_common_store_cab_error_wrong_checksum_func(void)
} }
static void static void
fu_engine_modify_bios_attrs_func(void) fu_engine_modify_bios_settings_func(void)
{ {
gboolean ret; gboolean ret;
const gchar *current; const gchar *current;
FwupdBiosAttr *attr1; FwupdBiosSetting *attr1;
FwupdBiosAttr *attr2; FwupdBiosSetting *attr2;
FwupdBiosAttr *attr3; FwupdBiosSetting *attr3;
FwupdBiosAttr *attr4; FwupdBiosSetting *attr4;
g_autofree gchar *test_dir = NULL; g_autofree gchar *test_dir = NULL;
g_autoptr(FuEngine) engine = fu_engine_new(); g_autoptr(FuEngine) engine = fu_engine_new();
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_autoptr(FuBiosAttrs) attrs = NULL; g_autoptr(FuBiosSettings) attrs = NULL;
g_autoptr(GPtrArray) items = NULL; g_autoptr(GPtrArray) items = NULL;
g_autoptr(GHashTable) bios_settings = g_autoptr(GHashTable) bios_settings =
g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
@ -4495,59 +4495,60 @@ fu_engine_modify_bios_attrs_func(void)
test_dir = g_test_build_filename(G_TEST_DIST, "tests", "bios-attrs", NULL); test_dir = g_test_build_filename(G_TEST_DIST, "tests", "bios-attrs", NULL);
(void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE); (void)g_setenv("FWUPD_SYSFSFWATTRIBDIR", test_dir, TRUE);
ret = fu_context_reload_bios_attrs(fu_engine_get_context(engine), &error); ret = fu_context_reload_bios_settings(fu_engine_get_context(engine), &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
attrs = fu_context_get_bios_attrs(fu_engine_get_context(engine)); attrs = fu_context_get_bios_settings(fu_engine_get_context(engine));
items = fu_bios_attrs_get_all(attrs); items = fu_bios_settings_get_all(attrs);
g_assert_cmpint(items->len, ==, 4); g_assert_cmpint(items->len, ==, 4);
/* enumeration */ /* enumeration */
attr1 = attr1 = fu_context_get_bios_setting(fu_engine_get_context(engine),
fu_context_get_bios_attr(fu_engine_get_context(engine), "com.fwupd-internal.Absolute"); "com.fwupd-internal.Absolute");
g_assert_nonnull(attr1); g_assert_nonnull(attr1);
current = fwupd_bios_attr_get_current_value(attr1); current = fwupd_bios_setting_get_current_value(attr1);
g_assert_nonnull(current); g_assert_nonnull(current);
g_hash_table_insert(bios_settings, g_strdup("Absolute"), g_strdup("Disabled")); g_hash_table_insert(bios_settings, g_strdup("Absolute"), g_strdup("Disabled"));
ret = fu_engine_modify_bios_attrs(engine, bios_settings, &error); ret = fu_engine_modify_bios_settings(engine, bios_settings, &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
g_hash_table_remove_all(bios_settings); g_hash_table_remove_all(bios_settings);
g_hash_table_insert(bios_settings, g_strdup("Absolute"), g_strdup("off")); g_hash_table_insert(bios_settings, g_strdup("Absolute"), g_strdup("off"));
ret = fu_engine_modify_bios_attrs(engine, bios_settings, &error); ret = fu_engine_modify_bios_settings(engine, bios_settings, &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
g_hash_table_remove_all(bios_settings); g_hash_table_remove_all(bios_settings);
g_hash_table_insert(bios_settings, g_strdup("Absolute"), g_strdup("FOO")); g_hash_table_insert(bios_settings, g_strdup("Absolute"), g_strdup("FOO"));
ret = fu_engine_modify_bios_attrs(engine, bios_settings, &error); ret = fu_engine_modify_bios_settings(engine, bios_settings, &error);
g_assert_false(ret); g_assert_false(ret);
g_assert_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED); g_assert_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED);
g_clear_error(&error); g_clear_error(&error);
/* use BiosAttrId instead */ /* use BiosSettingId instead */
g_hash_table_remove_all(bios_settings); g_hash_table_remove_all(bios_settings);
g_hash_table_insert(bios_settings, g_hash_table_insert(bios_settings,
g_strdup("com.fwupd-internal.Absolute"), g_strdup("com.fwupd-internal.Absolute"),
g_strdup(current)); g_strdup(current));
ret = fu_engine_modify_bios_attrs(engine, bios_settings, &error); ret = fu_engine_modify_bios_settings(engine, bios_settings, &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
/* string */ /* string */
attr2 = fu_context_get_bios_attr(fu_engine_get_context(engine), "com.fwupd-internal.Asset"); attr2 =
fu_context_get_bios_setting(fu_engine_get_context(engine), "com.fwupd-internal.Asset");
g_assert_nonnull(attr2); g_assert_nonnull(attr2);
current = fwupd_bios_attr_get_current_value(attr2); current = fwupd_bios_setting_get_current_value(attr2);
g_assert_nonnull(current); g_assert_nonnull(current);
g_hash_table_remove_all(bios_settings); g_hash_table_remove_all(bios_settings);
g_hash_table_insert(bios_settings, g_strdup("Asset"), g_strdup("1")); g_hash_table_insert(bios_settings, g_strdup("Asset"), g_strdup("1"));
ret = fu_engine_modify_bios_attrs(engine, bios_settings, &error); ret = fu_engine_modify_bios_settings(engine, bios_settings, &error);
g_assert_no_error(error); g_assert_no_error(error);
g_assert_true(ret); g_assert_true(ret);
@ -4556,55 +4557,55 @@ fu_engine_modify_bios_attrs_func(void)
bios_settings, bios_settings,
g_strdup("Absolute"), g_strdup("Absolute"),
g_strdup("1234567891123456789112345678911234567891123456789112345678911111")); g_strdup("1234567891123456789112345678911234567891123456789112345678911111"));
ret = fu_engine_modify_bios_attrs(engine, bios_settings, &error); ret = fu_engine_modify_bios_settings(engine, bios_settings, &error);
g_assert_false(ret); g_assert_false(ret);
g_assert_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED); g_assert_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED);
g_clear_error(&error); g_clear_error(&error);
/* integer */ /* integer */
attr3 = fu_context_get_bios_attr(fu_engine_get_context(engine), attr3 = fu_context_get_bios_setting(fu_engine_get_context(engine),
"com.fwupd-internal.CustomChargeStop"); "com.fwupd-internal.CustomChargeStop");
g_assert_nonnull(attr3); g_assert_nonnull(attr3);
current = fwupd_bios_attr_get_current_value(attr3); current = fwupd_bios_setting_get_current_value(attr3);
g_assert_nonnull(current); g_assert_nonnull(current);
g_hash_table_remove_all(bios_settings); g_hash_table_remove_all(bios_settings);
g_hash_table_insert(bios_settings, g_strdup("CustomChargeStop"), g_strdup("70")); g_hash_table_insert(bios_settings, g_strdup("CustomChargeStop"), g_strdup("70"));
ret = fu_engine_modify_bios_attrs(engine, bios_settings, &error); ret = fu_engine_modify_bios_settings(engine, bios_settings, &error);
g_assert_true(ret); g_assert_true(ret);
g_hash_table_remove_all(bios_settings); g_hash_table_remove_all(bios_settings);
g_hash_table_insert(bios_settings, g_strdup("CustomChargeStop"), g_strdup("110")); g_hash_table_insert(bios_settings, g_strdup("CustomChargeStop"), g_strdup("110"));
ret = fu_engine_modify_bios_attrs(engine, bios_settings, &error); ret = fu_engine_modify_bios_settings(engine, bios_settings, &error);
g_assert_false(ret); g_assert_false(ret);
g_assert_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED); g_assert_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED);
g_clear_error(&error); g_clear_error(&error);
g_hash_table_remove_all(bios_settings); g_hash_table_remove_all(bios_settings);
g_hash_table_insert(bios_settings, g_strdup("CustomChargeStop"), g_strdup("1")); g_hash_table_insert(bios_settings, g_strdup("CustomChargeStop"), g_strdup("1"));
ret = fu_engine_modify_bios_attrs(engine, bios_settings, &error); ret = fu_engine_modify_bios_settings(engine, bios_settings, &error);
g_assert_false(ret); g_assert_false(ret);
g_assert_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED); g_assert_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED);
g_clear_error(&error); g_clear_error(&error);
g_hash_table_remove_all(bios_settings); g_hash_table_remove_all(bios_settings);
g_hash_table_insert(bios_settings, g_strdup("CustomChargeStop"), g_strdup(current)); g_hash_table_insert(bios_settings, g_strdup("CustomChargeStop"), g_strdup(current));
ret = fu_engine_modify_bios_attrs(engine, bios_settings, &error); ret = fu_engine_modify_bios_settings(engine, bios_settings, &error);
g_assert_true(ret); g_assert_true(ret);
g_assert_no_error(error); g_assert_no_error(error);
/* Read Only */ /* Read Only */
attr4 = fu_context_get_bios_attr(fu_engine_get_context(engine), attr4 = fu_context_get_bios_setting(fu_engine_get_context(engine),
"com.fwupd-internal.pending_reboot"); "com.fwupd-internal.pending_reboot");
g_assert_nonnull(attr4); g_assert_nonnull(attr4);
current = fwupd_bios_attr_get_current_value(attr4); current = fwupd_bios_setting_get_current_value(attr4);
g_assert_nonnull(current); g_assert_nonnull(current);
g_hash_table_remove_all(bios_settings); g_hash_table_remove_all(bios_settings);
g_hash_table_insert(bios_settings, g_strdup("pending_reboot"), g_strdup("foo")); g_hash_table_insert(bios_settings, g_strdup("pending_reboot"), g_strdup("foo"));
ret = fu_engine_modify_bios_attrs(engine, bios_settings, &error); ret = fu_engine_modify_bios_settings(engine, bios_settings, &error);
g_assert_false(ret); g_assert_false(ret);
g_assert_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED); g_assert_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED);
g_clear_error(&error); g_clear_error(&error);
@ -4793,6 +4794,6 @@ main(int argc, char **argv)
g_test_add_func("/fwupd/common{cab-error-missing-file}", g_test_add_func("/fwupd/common{cab-error-missing-file}",
fu_common_store_cab_error_missing_file_func); fu_common_store_cab_error_missing_file_func);
g_test_add_func("/fwupd/common{cab-error-size}", fu_common_store_cab_error_size_func); g_test_add_func("/fwupd/common{cab-error-size}", fu_common_store_cab_error_size_func);
g_test_add_func("/fwupd/write-bios-attrs", fu_engine_modify_bios_attrs_func); g_test_add_func("/fwupd/write-bios-attrs", fu_engine_modify_bios_settings_func);
return g_test_run(); return g_test_run();
} }

View File

@ -21,12 +21,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include "fwupd-bios-attr-private.h" #include "fwupd-bios-setting-private.h"
#include "fwupd-common-private.h" #include "fwupd-common-private.h"
#include "fwupd-device-private.h" #include "fwupd-device-private.h"
#include "fwupd-plugin-private.h" #include "fwupd-plugin-private.h"
#include "fu-bios-attrs-private.h" #include "fu-bios-settings-private.h"
#include "fu-cabinet.h" #include "fu-cabinet.h"
#include "fu-context-private.h" #include "fu-context-private.h"
#include "fu-debug.h" #include "fu-debug.h"
@ -39,7 +39,7 @@
#include "fu-security-attr-common.h" #include "fu-security-attr-common.h"
#include "fu-security-attrs-private.h" #include "fu-security-attrs-private.h"
#include "fu-smbios-private.h" #include "fu-smbios-private.h"
#include "fu-util-bios-attr.h" #include "fu-util-bios-setting.h"
#include "fu-util-common.h" #include "fu-util-common.h"
#ifdef HAVE_SYSTEMD #ifdef HAVE_SYSTEMD
@ -3224,9 +3224,9 @@ fu_util_switch_branch(FuUtilPrivate *priv, gchar **values, GError **error)
} }
static gboolean static gboolean
fu_util_set_bios_attr(FuUtilPrivate *priv, gchar **input, GError **error) fu_util_set_bios_setting(FuUtilPrivate *priv, gchar **input, GError **error)
{ {
g_autoptr(GHashTable) settings = fu_util_bios_attrs_parse_argv(input, error); g_autoptr(GHashTable) settings = fu_util_bios_settings_parse_argv(input, error);
if (settings == NULL) if (settings == NULL)
return FALSE; return FALSE;
@ -3237,8 +3237,8 @@ fu_util_set_bios_attr(FuUtilPrivate *priv, gchar **input, GError **error)
error)) error))
return FALSE; return FALSE;
if (!fu_engine_modify_bios_attrs(priv->engine, settings, error)) { if (!fu_engine_modify_bios_settings(priv->engine, settings, error)) {
g_prefix_error(error, "failed to set BIOS attribute: "); g_prefix_error(error, "failed to set BIOS setting: ");
return FALSE; return FALSE;
} }
@ -3250,7 +3250,7 @@ fu_util_set_bios_attr(FuUtilPrivate *priv, gchar **input, GError **error)
while (g_hash_table_iter_next(&iter, &key, &value)) { while (g_hash_table_iter_next(&iter, &key, &value)) {
g_autofree gchar *msg = g_autofree gchar *msg =
/* TRANSLATORS: Configured a BIOS setting to a value */ /* TRANSLATORS: Configured a BIOS setting to a value */
g_strdup_printf(_("Set BIOS attribute '%s' using '%s'."), g_strdup_printf(_("Set BIOS setting '%s' using '%s'."),
(const gchar *)key, (const gchar *)key,
(const gchar *)value); (const gchar *)value);
g_print("\n%s\n", msg); g_print("\n%s\n", msg);
@ -3267,9 +3267,9 @@ fu_util_set_bios_attr(FuUtilPrivate *priv, gchar **input, GError **error)
} }
static gboolean static gboolean
fu_util_get_bios_attr(FuUtilPrivate *priv, gchar **values, GError **error) fu_util_get_bios_setting(FuUtilPrivate *priv, gchar **values, GError **error)
{ {
g_autoptr(FuBiosAttrs) attrs = NULL; g_autoptr(FuBiosSettings) attrs = NULL;
g_autoptr(GPtrArray) items = NULL; g_autoptr(GPtrArray) items = NULL;
FuContext *ctx = fu_engine_get_context(priv->engine); FuContext *ctx = fu_engine_get_context(priv->engine);
gboolean found = FALSE; gboolean found = FALSE;
@ -3281,15 +3281,15 @@ fu_util_get_bios_attr(FuUtilPrivate *priv, gchar **values, GError **error)
error)) error))
return FALSE; return FALSE;
attrs = fu_context_get_bios_attrs(ctx); attrs = fu_context_get_bios_settings(ctx);
items = fu_bios_attrs_get_all(attrs); items = fu_bios_settings_get_all(attrs);
if (priv->as_json) if (priv->as_json)
return fu_util_get_bios_attr_as_json(values, items, error); return fu_util_get_bios_setting_as_json(values, items, error);
for (guint i = 0; i < items->len; i++) { for (guint i = 0; i < items->len; i++) {
FwupdBiosAttr *attr = g_ptr_array_index(items, i); FwupdBiosSetting *attr = g_ptr_array_index(items, i);
if (fu_util_bios_attr_matches_args(attr, values)) { if (fu_util_bios_setting_matches_args(attr, values)) {
g_autofree gchar *tmp = fu_util_bios_attr_to_string(attr, 0); g_autofree gchar *tmp = fu_util_bios_setting_to_string(attr, 0);
g_print("%s\n", tmp); g_print("%s\n", tmp);
found = TRUE; found = TRUE;
} }
@ -3848,14 +3848,14 @@ main(int argc, char *argv[])
_("[SETTING1] [ SETTING2]..."), _("[SETTING1] [ SETTING2]..."),
/* TRANSLATORS: command description */ /* TRANSLATORS: command description */
_("Retrieve BIOS settings. If no arguments are passed all settings are returned"), _("Retrieve BIOS settings. If no arguments are passed all settings are returned"),
fu_util_get_bios_attr); fu_util_get_bios_setting);
fu_util_cmd_array_add(cmd_array, fu_util_cmd_array_add(cmd_array,
"set-bios-setting", "set-bios-setting",
/* TRANSLATORS: command argument: uppercase, spaces->dashes */ /* TRANSLATORS: command argument: uppercase, spaces->dashes */
_("SETTING VALUE"), _("SETTING VALUE"),
/* TRANSLATORS: command description */ /* TRANSLATORS: command description */
_("Set a BIOS setting"), _("Set a BIOS setting"),
fu_util_set_bios_attr); fu_util_set_bios_setting);
/* do stuff on ctrl+c */ /* do stuff on ctrl+c */
priv->cancellable = g_cancellable_new(); priv->cancellable = g_cancellable_new();

View File

@ -1,20 +0,0 @@
/*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <fwupdplugin.h>
#include "fwupd-bios-attr-private.h"
gchar *
fu_util_bios_attr_to_string(FwupdBiosAttr *attr, guint idt);
gboolean
fu_util_bios_attr_matches_args(FwupdBiosAttr *attr, gchar **values);
gboolean
fu_util_get_bios_attr_as_json(gchar **values, GPtrArray *attrs, GError **error);
GHashTable *
fu_util_bios_attrs_parse_argv(gchar **input, GError **error);

View File

@ -10,29 +10,29 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include "fu-bios-attrs-private.h" #include "fu-bios-settings-private.h"
#include "fu-util-bios-attr.h" #include "fu-util-bios-setting.h"
#include "fu-util-common.h" #include "fu-util-common.h"
static gboolean static gboolean
fu_util_bios_attr_dup_fields(const gchar *name, const gchar *desc) fu_util_bios_setting_dup_fields(const gchar *name, const gchar *desc)
{ {
return g_strcmp0(name, desc) == 0; return g_strcmp0(name, desc) == 0;
} }
static void static void
fu_util_bios_attr_update_description(FwupdBiosAttr *attr) fu_util_bios_setting_update_description(FwupdBiosSetting *setting)
{ {
const gchar *name = fwupd_bios_attr_get_name(attr); const gchar *name = fwupd_bios_setting_get_name(setting);
const gchar *old = fwupd_bios_attr_get_description(attr); const gchar *old = fwupd_bios_setting_get_description(setting);
const gchar *new = NULL; const gchar *new = NULL;
if (g_strcmp0(name, FWUPD_BIOS_ATTR_PENDING_REBOOT) == 0) { if (g_strcmp0(name, FWUPD_BIOS_SETTING_PENDING_REBOOT) == 0) {
/* TRANSLATORS: Settings refers to BIOS settings in this context */ /* TRANSLATORS: Settings refers to BIOS settings in this context */
new = _("Settings will apply after system reboots"); new = _("Settings will apply after system reboots");
} }
/* For providing a better description on a number of Lenovo systems */ /* For providing a better description on a number of Lenovo systems */
if (fu_util_bios_attr_dup_fields(name, old)) { if (fu_util_bios_setting_dup_fields(name, old)) {
if (g_strcmp0(old, "WindowsUEFIFirmwareUpdate") == 0) { if (g_strcmp0(old, "WindowsUEFIFirmwareUpdate") == 0) {
/* TRANSLATORS: description of a BIOS setting */ /* TRANSLATORS: description of a BIOS setting */
new = _("BIOS updates delivered via LVFS or Windows Update"); new = _("BIOS updates delivered via LVFS or Windows Update");
@ -42,21 +42,21 @@ fu_util_bios_attr_update_description(FwupdBiosAttr *attr)
new = gettext(old); new = gettext(old);
} }
if (new != NULL) if (new != NULL)
fwupd_bios_attr_set_description(attr, new); fwupd_bios_setting_set_description(setting, new);
} }
static const gchar * static const gchar *
fu_util_bios_attr_kind_to_string(FwupdBiosAttrKind kind) fu_util_bios_setting_kind_to_string(FwupdBiosSettingKind kind)
{ {
if (kind == FWUPD_BIOS_ATTR_KIND_ENUMERATION) { if (kind == FWUPD_BIOS_SETTING_KIND_ENUMERATION) {
/* TRANSLATORS: The BIOS setting can only be changed to fixed values */ /* TRANSLATORS: The BIOS setting can only be changed to fixed values */
return _("Enumeration"); return _("Enumeration");
} }
if (kind == FWUPD_BIOS_ATTR_KIND_INTEGER) { if (kind == FWUPD_BIOS_SETTING_KIND_INTEGER) {
/* TRANSLATORS: The BIOS setting only accepts integers in a fixed range */ /* TRANSLATORS: The BIOS setting only accepts integers in a fixed range */
return _("Integer"); return _("Integer");
} }
if (kind == FWUPD_BIOS_ATTR_KIND_STRING) { if (kind == FWUPD_BIOS_SETTING_KIND_STRING) {
/* TRANSLATORS: The BIOS setting accepts strings */ /* TRANSLATORS: The BIOS setting accepts strings */
return _("String"); return _("String");
} }
@ -64,14 +64,14 @@ fu_util_bios_attr_kind_to_string(FwupdBiosAttrKind kind)
} }
gboolean gboolean
fu_util_bios_attr_matches_args(FwupdBiosAttr *attr, gchar **values) fu_util_bios_setting_matches_args(FwupdBiosSetting *setting, gchar **values)
{ {
const gchar *name; const gchar *name;
/* no arguments set */ /* no arguments set */
if (g_strv_length(values) == 0) if (g_strv_length(values) == 0)
return TRUE; return TRUE;
name = fwupd_bios_attr_get_name(attr); name = fwupd_bios_setting_get_name(setting);
/* check all arguments */ /* check all arguments */
for (guint j = 0; j < g_strv_length(values); j++) { for (guint j = 0; j < g_strv_length(values); j++) {
@ -82,19 +82,19 @@ fu_util_bios_attr_matches_args(FwupdBiosAttr *attr, gchar **values)
} }
gboolean gboolean
fu_util_get_bios_attr_as_json(gchar **values, GPtrArray *attrs, GError **error) fu_util_get_bios_setting_as_json(gchar **values, GPtrArray *settings, GError **error)
{ {
g_autoptr(JsonBuilder) builder = json_builder_new(); g_autoptr(JsonBuilder) builder = json_builder_new();
json_builder_begin_object(builder); json_builder_begin_object(builder);
json_builder_set_member_name(builder, "BiosAttributes"); json_builder_set_member_name(builder, "BiosSettings");
json_builder_begin_array(builder); json_builder_begin_array(builder);
for (guint i = 0; i < attrs->len; i++) { for (guint i = 0; i < settings->len; i++) {
FwupdBiosAttr *attr = g_ptr_array_index(attrs, i); FwupdBiosSetting *setting = g_ptr_array_index(settings, i);
if (fu_util_bios_attr_matches_args(attr, values)) { if (fu_util_bios_setting_matches_args(setting, values)) {
fu_util_bios_attr_update_description(attr); fu_util_bios_setting_update_description(setting);
json_builder_begin_object(builder); json_builder_begin_object(builder);
fwupd_bios_attr_to_json(attr, builder); fwupd_bios_setting_to_json(setting, builder);
json_builder_end_object(builder); json_builder_end_object(builder);
} }
} }
@ -104,31 +104,31 @@ fu_util_get_bios_attr_as_json(gchar **values, GPtrArray *attrs, GError **error)
} }
gchar * gchar *
fu_util_bios_attr_to_string(FwupdBiosAttr *attr, guint idt) fu_util_bios_setting_to_string(FwupdBiosSetting *setting, guint idt)
{ {
const gchar *tmp; const gchar *tmp;
FwupdBiosAttrKind type; FwupdBiosSettingKind type;
g_autofree gchar *current_value = NULL; g_autofree gchar *current_value = NULL;
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
g_autoptr(GString) str = g_string_new(NULL); g_autoptr(GString) str = g_string_new(NULL);
if (g_getenv("FWUPD_VERBOSE") != NULL) { if (g_getenv("FWUPD_VERBOSE") != NULL) {
g_autofree gchar *debug_str = NULL; g_autofree gchar *debug_str = NULL;
debug_str = fwupd_bios_attr_to_string(attr); debug_str = fwupd_bios_setting_to_string(setting);
g_debug("%s", debug_str); g_debug("%s", debug_str);
return NULL; return NULL;
} }
tmp = fwupd_bios_attr_get_name(attr); tmp = fwupd_bios_setting_get_name(setting);
fu_string_append(str, idt, tmp, NULL); fu_string_append(str, idt, tmp, NULL);
type = fwupd_bios_attr_get_kind(attr); type = fwupd_bios_setting_get_kind(setting);
tmp = fu_util_bios_attr_kind_to_string(type); tmp = fu_util_bios_setting_kind_to_string(type);
if (tmp != NULL) { if (tmp != NULL) {
/* TRANSLATORS: type of BIOS setting */ /* TRANSLATORS: type of BIOS setting */
fu_string_append(str, idt + 1, _("Setting type"), tmp); fu_string_append(str, idt + 1, _("Setting type"), tmp);
} }
tmp = fwupd_bios_attr_get_current_value(attr); tmp = fwupd_bios_setting_get_current_value(setting);
if (tmp != NULL) { if (tmp != NULL) {
current_value = g_strdup(tmp); current_value = g_strdup(tmp);
} else { } else {
@ -138,14 +138,14 @@ fu_util_bios_attr_to_string(FwupdBiosAttr *attr, guint idt)
/* TRANSLATORS: current value of a BIOS setting */ /* TRANSLATORS: current value of a BIOS setting */
fu_string_append(str, idt + 1, _("Current Value"), current_value); fu_string_append(str, idt + 1, _("Current Value"), current_value);
fu_util_bios_attr_update_description(attr); fu_util_bios_setting_update_description(setting);
tmp = fwupd_bios_attr_get_description(attr); tmp = fwupd_bios_setting_get_description(setting);
if (tmp != NULL) { if (tmp != NULL) {
/* TRANSLATORS: description of BIOS setting */ /* TRANSLATORS: description of BIOS setting */
fu_string_append(str, idt + 1, _("Description"), tmp); fu_string_append(str, idt + 1, _("Description"), tmp);
} }
if (fwupd_bios_attr_get_read_only(attr)) { if (fwupd_bios_setting_get_read_only(setting)) {
/* TRANSLATORS: item is TRUE */ /* TRANSLATORS: item is TRUE */
tmp = _("True"); tmp = _("True");
} else { } else {
@ -155,15 +155,17 @@ fu_util_bios_attr_to_string(FwupdBiosAttr *attr, guint idt)
/* TRANSLATORS: BIOS setting is read only */ /* TRANSLATORS: BIOS setting is read only */
fu_string_append(str, idt + 1, _("Read Only"), tmp); fu_string_append(str, idt + 1, _("Read Only"), tmp);
if (type == FWUPD_BIOS_ATTR_KIND_INTEGER || type == FWUPD_BIOS_ATTR_KIND_STRING) { if (type == FWUPD_BIOS_SETTING_KIND_INTEGER || type == FWUPD_BIOS_SETTING_KIND_STRING) {
g_autofree gchar *lower = g_autofree gchar *lower =
g_strdup_printf("%" G_GUINT64_FORMAT, fwupd_bios_attr_get_lower_bound(attr)); g_strdup_printf("%" G_GUINT64_FORMAT,
fwupd_bios_setting_get_lower_bound(setting));
g_autofree gchar *upper = g_autofree gchar *upper =
g_strdup_printf("%" G_GUINT64_FORMAT, fwupd_bios_attr_get_upper_bound(attr)); g_strdup_printf("%" G_GUINT64_FORMAT,
if (type == FWUPD_BIOS_ATTR_KIND_INTEGER) { fwupd_bios_setting_get_upper_bound(setting));
if (type == FWUPD_BIOS_SETTING_KIND_INTEGER) {
g_autofree gchar *scalar = g_autofree gchar *scalar =
g_strdup_printf("%" G_GUINT64_FORMAT, g_strdup_printf("%" G_GUINT64_FORMAT,
fwupd_bios_attr_get_scalar_increment(attr)); fwupd_bios_setting_get_scalar_increment(setting));
if (lower != NULL) { if (lower != NULL) {
/* TRANSLATORS: Lowest valid integer for BIOS setting */ /* TRANSLATORS: Lowest valid integer for BIOS setting */
fu_string_append(str, idt + 1, _("Minimum value"), lower); fu_string_append(str, idt + 1, _("Minimum value"), lower);
@ -186,8 +188,8 @@ fu_util_bios_attr_to_string(FwupdBiosAttr *attr, guint idt)
fu_string_append(str, idt + 1, _("Maximum length"), upper); fu_string_append(str, idt + 1, _("Maximum length"), upper);
} }
} }
} else if (type == FWUPD_BIOS_ATTR_KIND_ENUMERATION) { } else if (type == FWUPD_BIOS_SETTING_KIND_ENUMERATION) {
GPtrArray *values = fwupd_bios_attr_get_possible_values(attr); GPtrArray *values = fwupd_bios_setting_get_possible_values(setting);
if (values != NULL && values->len > 0) { if (values != NULL && values->len > 0) {
/* TRANSLATORS: Possible values for a bios setting */ /* TRANSLATORS: Possible values for a bios setting */
fu_string_append(str, idt + 1, _("Possible Values"), NULL); fu_string_append(str, idt + 1, _("Possible Values"), NULL);
@ -202,7 +204,7 @@ fu_util_bios_attr_to_string(FwupdBiosAttr *attr, guint idt)
} }
GHashTable * GHashTable *
fu_util_bios_attrs_parse_argv(gchar **input, GError **error) fu_util_bios_settings_parse_argv(gchar **input, GError **error)
{ {
g_autoptr(GHashTable) bios_settings = g_autoptr(GHashTable) bios_settings =
g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
@ -220,7 +222,7 @@ fu_util_bios_attrs_parse_argv(gchar **input, GError **error)
if (g_strv_length(input) == 1) { if (g_strv_length(input) == 1) {
g_autofree gchar *data = NULL; g_autofree gchar *data = NULL;
g_autoptr(JsonParser) parser = json_parser_new(); g_autoptr(JsonParser) parser = json_parser_new();
g_autoptr(FuBiosAttrs) new_bios_attrs = fu_bios_attrs_new(); g_autoptr(FuBiosSettings) new_bios_settings = fu_bios_settings_new();
g_autoptr(GPtrArray) new_items = NULL; g_autoptr(GPtrArray) new_items = NULL;
if (!g_file_get_contents(input[0], &data, NULL, error)) if (!g_file_get_contents(input[0], &data, NULL, error))
@ -230,15 +232,18 @@ fu_util_bios_attrs_parse_argv(gchar **input, GError **error)
return NULL; return NULL;
} }
if (!fu_bios_attrs_from_json(new_bios_attrs, json_parser_get_root(parser), error)) if (!fu_bios_settings_from_json(new_bios_settings,
json_parser_get_root(parser),
error))
return NULL; return NULL;
new_items = fu_bios_attrs_get_all(new_bios_attrs); new_items = fu_bios_settings_get_all(new_bios_settings);
for (guint i = 0; i < new_items->len; i++) { for (guint i = 0; i < new_items->len; i++) {
FwupdBiosAttr *item_attr = g_ptr_array_index(new_items, i); FwupdBiosSetting *item_setting = g_ptr_array_index(new_items, i);
g_hash_table_insert(bios_settings, g_hash_table_insert(
g_strdup(fwupd_bios_attr_get_id(item_attr)), bios_settings,
g_strdup(fwupd_bios_attr_get_current_value(item_attr))); g_strdup(fwupd_bios_setting_get_id(item_setting)),
g_strdup(fwupd_bios_setting_get_current_value(item_setting)));
} }
} else { } else {
for (guint i = 0; i < g_strv_length(input); i += 2) for (guint i = 0; i < g_strv_length(input); i += 2)

View File

@ -0,0 +1,20 @@
/*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <fwupdplugin.h>
#include "fwupd-bios-setting-private.h"
gchar *
fu_util_bios_setting_to_string(FwupdBiosSetting *setting, guint idt);
gboolean
fu_util_bios_setting_matches_args(FwupdBiosSetting *setting, gchar **values);
gboolean
fu_util_get_bios_setting_as_json(gchar **values, GPtrArray *settings, GError **error);
GHashTable *
fu_util_bios_settings_parse_argv(gchar **input, GError **error);

View File

@ -10,7 +10,7 @@
#include <json-glib/json-glib.h> #include <json-glib/json-glib.h>
#include "fwupd-bios-attr-private.h" #include "fwupd-bios-setting-private.h"
#include "fwupd-security-attr-private.h" #include "fwupd-security-attr-private.h"
/* this is only valid for tools */ /* this is only valid for tools */

View File

@ -30,7 +30,7 @@
#include "fu-plugin-private.h" #include "fu-plugin-private.h"
#include "fu-polkit-agent.h" #include "fu-polkit-agent.h"
#include "fu-progressbar.h" #include "fu-progressbar.h"
#include "fu-util-bios-attr.h" #include "fu-util-bios-setting.h"
#include "fu-util-common.h" #include "fu-util-common.h"
#ifdef HAVE_SYSTEMD #ifdef HAVE_SYSTEMD
@ -3387,7 +3387,7 @@ fu_util_sync_bkc(FuUtilPrivate *priv, gchar **values, GError **error)
} }
static gboolean static gboolean
fu_util_security_modify_bios_attr(FuUtilPrivate *priv, FwupdSecurityAttr *attr, GError **error) fu_util_security_modify_bios_setting(FuUtilPrivate *priv, FwupdSecurityAttr *attr, GError **error)
{ {
g_autoptr(GString) body = g_string_new(NULL); g_autoptr(GString) body = g_string_new(NULL);
g_autoptr(GString) title = g_string_new(NULL); g_autoptr(GString) title = g_string_new(NULL);
@ -3408,9 +3408,9 @@ fu_util_security_modify_bios_attr(FuUtilPrivate *priv, FwupdSecurityAttr *attr,
_("This tool can change the BIOS setting '%s' from '%s' to '%s' " _("This tool can change the BIOS setting '%s' from '%s' to '%s' "
"automatically, but it will only be active after restarting the " "automatically, but it will only be active after restarting the "
"computer."), "computer."),
fwupd_security_attr_get_bios_attr_id(attr), fwupd_security_attr_get_bios_setting_id(attr),
fwupd_security_attr_get_bios_attr_current_value(attr), fwupd_security_attr_get_bios_setting_current_value(attr),
fwupd_security_attr_get_bios_attr_target_value(attr)); fwupd_security_attr_get_bios_setting_target_value(attr));
g_string_append(body, "\n\n"); g_string_append(body, "\n\n");
g_string_append_printf(body, g_string_append_printf(body,
/* TRANSLATORS: the user has to manually recover; we can't do it */ /* TRANSLATORS: the user has to manually recover; we can't do it */
@ -3426,9 +3426,12 @@ fu_util_security_modify_bios_attr(FuUtilPrivate *priv, FwupdSecurityAttr *attr,
if (!fu_util_prompt_for_boolean(FALSE)) if (!fu_util_prompt_for_boolean(FALSE))
return TRUE; return TRUE;
g_hash_table_insert(bios_settings, g_hash_table_insert(bios_settings,
g_strdup(fwupd_security_attr_get_bios_attr_id(attr)), g_strdup(fwupd_security_attr_get_bios_setting_id(attr)),
g_strdup(fwupd_security_attr_get_bios_attr_target_value(attr))); g_strdup(fwupd_security_attr_get_bios_setting_target_value(attr)));
if (!fwupd_client_modify_bios_attr(priv->client, bios_settings, priv->cancellable, error)) if (!fwupd_client_modify_bios_setting(priv->client,
bios_settings,
priv->cancellable,
error))
return FALSE; return FALSE;
/* do not offer to upload the report */ /* do not offer to upload the report */
@ -3534,10 +3537,10 @@ fu_util_security(FuUtilPrivate *priv, gchar **values, GError **error)
for (guint j = 0; j < attrs->len; j++) { for (guint j = 0; j < attrs->len; j++) {
FwupdSecurityAttr *attr = g_ptr_array_index(attrs, j); FwupdSecurityAttr *attr = g_ptr_array_index(attrs, j);
if (!fwupd_security_attr_has_flag(attr, FWUPD_SECURITY_ATTR_FLAG_SUCCESS) && if (!fwupd_security_attr_has_flag(attr, FWUPD_SECURITY_ATTR_FLAG_SUCCESS) &&
fwupd_security_attr_get_bios_attr_id(attr) != NULL && fwupd_security_attr_get_bios_setting_id(attr) != NULL &&
fwupd_security_attr_get_bios_attr_current_value(attr) != NULL && fwupd_security_attr_get_bios_setting_current_value(attr) != NULL &&
fwupd_security_attr_get_bios_attr_target_value(attr) != NULL) { fwupd_security_attr_get_bios_setting_target_value(attr) != NULL) {
if (!fu_util_security_modify_bios_attr(priv, attr, error)) if (!fu_util_security_modify_bios_setting(priv, attr, error))
return FALSE; return FALSE;
} }
} }
@ -3866,15 +3869,15 @@ fu_util_show_plugin_warnings(FuUtilPrivate *priv)
} }
static gboolean static gboolean
fu_util_set_bios_attr(FuUtilPrivate *priv, gchar **input, GError **error) fu_util_set_bios_setting(FuUtilPrivate *priv, gchar **input, GError **error)
{ {
g_autoptr(GHashTable) settings = fu_util_bios_attrs_parse_argv(input, error); g_autoptr(GHashTable) settings = fu_util_bios_settings_parse_argv(input, error);
if (settings == NULL) if (settings == NULL)
return FALSE; return FALSE;
if (!fwupd_client_modify_bios_attr(priv->client, settings, priv->cancellable, error)) { if (!fwupd_client_modify_bios_setting(priv->client, settings, priv->cancellable, error)) {
g_prefix_error(error, "failed to set BIOS attribute: "); g_prefix_error(error, "failed to set BIOS setting: ");
return FALSE; return FALSE;
} }
@ -3886,7 +3889,7 @@ fu_util_set_bios_attr(FuUtilPrivate *priv, gchar **input, GError **error)
while (g_hash_table_iter_next(&iter, &key, &value)) { while (g_hash_table_iter_next(&iter, &key, &value)) {
g_autofree gchar *msg = g_autofree gchar *msg =
/* TRANSLATORS: Configured a BIOS setting to a value */ /* TRANSLATORS: Configured a BIOS setting to a value */
g_strdup_printf(_("Set BIOS attribute '%s' using '%s'."), g_strdup_printf(_("Set BIOS setting '%s' using '%s'."),
(const gchar *)key, (const gchar *)key,
(const gchar *)value); (const gchar *)value);
g_print("\n%s\n", msg); g_print("\n%s\n", msg);
@ -3903,21 +3906,21 @@ fu_util_set_bios_attr(FuUtilPrivate *priv, gchar **input, GError **error)
} }
static gboolean static gboolean
fu_util_get_bios_attr(FuUtilPrivate *priv, gchar **values, GError **error) fu_util_get_bios_setting(FuUtilPrivate *priv, gchar **values, GError **error)
{ {
g_autoptr(GPtrArray) attrs = NULL; g_autoptr(GPtrArray) attrs = NULL;
gboolean found = FALSE; gboolean found = FALSE;
attrs = fwupd_client_get_bios_attrs(priv->client, priv->cancellable, error); attrs = fwupd_client_get_bios_settings(priv->client, priv->cancellable, error);
if (attrs == NULL) if (attrs == NULL)
return FALSE; return FALSE;
if (priv->as_json) if (priv->as_json)
return fu_util_get_bios_attr_as_json(values, attrs, error); return fu_util_get_bios_setting_as_json(values, attrs, error);
for (guint i = 0; i < attrs->len; i++) { for (guint i = 0; i < attrs->len; i++) {
FwupdBiosAttr *attr = g_ptr_array_index(attrs, i); FwupdBiosSetting *attr = g_ptr_array_index(attrs, i);
if (fu_util_bios_attr_matches_args(attr, values)) { if (fu_util_bios_setting_matches_args(attr, values)) {
g_autofree gchar *tmp = fu_util_bios_attr_to_string(attr, 0); g_autofree gchar *tmp = fu_util_bios_setting_to_string(attr, 0);
g_print("\n%s\n", tmp); g_print("\n%s\n", tmp);
found = TRUE; found = TRUE;
} }
@ -4446,14 +4449,14 @@ main(int argc, char *argv[])
_("[SETTING1] [SETTING2] [--no-authenticate]"), _("[SETTING1] [SETTING2] [--no-authenticate]"),
/* TRANSLATORS: command description */ /* TRANSLATORS: command description */
_("Retrieve BIOS settings. If no arguments are passed all settings are returned"), _("Retrieve BIOS settings. If no arguments are passed all settings are returned"),
fu_util_get_bios_attr); fu_util_get_bios_setting);
fu_util_cmd_array_add(cmd_array, fu_util_cmd_array_add(cmd_array,
"set-bios-setting", "set-bios-setting",
/* TRANSLATORS: command argument: uppercase, spaces->dashes */ /* TRANSLATORS: command argument: uppercase, spaces->dashes */
_("SETTING1 VALUE1 [SETTING2] [VALUE2]"), _("SETTING1 VALUE1 [SETTING2] [VALUE2]"),
/* TRANSLATORS: command description */ /* TRANSLATORS: command description */
_("Sets one or more BIOS settings"), _("Sets one or more BIOS settings"),
fu_util_set_bios_attr); fu_util_set_bios_setting);
/* do stuff on ctrl+c */ /* do stuff on ctrl+c */
priv->cancellable = g_cancellable_new(); priv->cancellable = g_cancellable_new();

View File

@ -85,7 +85,7 @@ fwupdmgr = executable(
'fu-history.c', 'fu-history.c',
'fu-progressbar.c', 'fu-progressbar.c',
'fu-security-attr-common.c', 'fu-security-attr-common.c',
'fu-util-bios-attr.c', 'fu-util-bios-setting.c',
'fu-util-common.c', 'fu-util-common.c',
client_src, client_src,
systemd_src systemd_src
@ -188,7 +188,7 @@ fwupdtool = executable(
'fu-tool.c', 'fu-tool.c',
'fu-progressbar.c', 'fu-progressbar.c',
'fu-util-common.c', 'fu-util-common.c',
'fu-util-bios-attr.c', 'fu-util-bios-setting.c',
daemon_src, daemon_src,
], ],
include_directories: [ include_directories: [

View File

@ -866,35 +866,35 @@
</method> </method>
<!--***********************************************************--> <!--***********************************************************-->
<method name='SetBiosAttrs'> <method name='SetBiosSettings'>
<doc:doc> <doc:doc>
<doc:description> <doc:description>
<doc:para> <doc:para>
Modify BIOS attribute Modify BIOS setting
</doc:para> </doc:para>
</doc:description> </doc:description>
</doc:doc> </doc:doc>
<arg type='a{ss}' name='settings' direction='in'> <arg type='a{ss}' name='settings' direction='in'>
<doc:doc> <doc:doc>
<doc:summary> <doc:summary>
<doc:para>An array of BIOS attributes and their new values.</doc:para> <doc:para>An array of BIOS settings and their new values.</doc:para>
</doc:summary> </doc:summary>
</doc:doc> </doc:doc>
</arg> </arg>
</method> </method>
<method name='GetBiosAttrs'> <method name='GetBiosSettings'>
<doc:doc> <doc:doc>
<doc:description> <doc:description>
<doc:para> <doc:para>
Gets a list of all the BIOS attributes. Gets a list of all the BIOS settings.
</doc:para> </doc:para>
</doc:description> </doc:description>
</doc:doc> </doc:doc>
<arg type='aa{sv}' name='attrs' direction='out'> <arg type='aa{sv}' name='attrs' direction='out'>
<doc:doc> <doc:doc>
<doc:summary> <doc:summary>
<doc:para>An array of BIOS attributes, with any properties set on each.</doc:para> <doc:para>An array of BIOS settings, with any properties set on each.</doc:para>
</doc:summary> </doc:summary>
</doc:doc> </doc:doc>
</arg> </arg>