FuContext: fwupd Reference Manual

## FuContext FuContext |

## Functions

void | (*FuContextLookupIter) ()
const gchar * | fu_context_get_smbios_string ()
guint | fu_context_get_smbios_integer ()
GBytes * | fu_context_get_smbios_data ()
gboolean | fu_context_has_hwid_guid ()
GPtrArray * | fu_context_get_hwid_guids ()
gboolean | fu_context_has_hwid_flag ()
const gchar * | fu_context_get_hwid_value ()
gchar * | fu_context_get_hwid_replace_value ()
void | fu_context_add_runtime_version ()
void | fu_context_add_compile_version ()
const gchar * | fu_context_lookup_quirk_by_id ()
gboolean | fu_context_lookup_quirk_by_id_iter ()
void | fu_context_add_quirk_key ()
void | fu_context_security_changed ()
FuBatteryState | fu_context_get_battery_state ()
void | fu_context_set_battery_state ()
FuLidState | fu_context_get_lid_state ()
void | fu_context_set_lid_state ()
guint | fu_context_get_battery_level ()
void | fu_context_set_battery_level ()
guint | fu_context_get_battery_threshold ()
void | fu_context_set_battery_threshold ()

## Types and Values

#define | FU_TYPE_CONTEXT
struct | FuContextClass
| FuContext

## Description

## Functions

### FuContextLookupIter ()

    void
    (*FuContextLookupIter) (FuContext *self,
                            const gchar *key,
                            const gchar *value,
                            gpointer user_data);

The context lookup iteration callback.

#### Parameters

self | a FuContext |
key | a key |
value | a value |
user_data | user data |

### fu_context_get_smbios_string ()

    const gchar *
    fu_context_get_smbios_string (FuContext *self,
                                  guint8 structure_type,
                                  guint8 offset);

Gets a hardware SMBIOS string.

The `type` and `offset` can be referenced from the DMTF SMBIOS specification: https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf

#### Parameters

self | a FuContext |
structure_type | a SMBIOS structure type, e.g. `FU_SMBIOS_STRUCTURE_TYPE_BIOS` |
offset | a SMBIOS offset |

#### Returns

a string, or `NULL`

Since: 1.6.0

### fu_context_get_smbios_integer ()

    guint
    fu_context_get_smbios_integer (FuContext *self,
                                   guint8 type,
                                   guint8 offset);

Reads an integer value from the SMBIOS string table of a specific structure.

The `type` and `offset` can be referenced from the DMTF SMBIOS specification: https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf

#### Parameters

self | a FuContext |
type | a structure type, e.g. `FU_SMBIOS_STRUCTURE_TYPE_BIOS` |
offset | a structure offset |

#### Returns

an integer, or `G_MAXUINT` if invalid or not found

Since: 1.6.0

### fu_context_get_smbios_data ()

    GBytes *
    fu_context_get_smbios_data (FuContext *self,
                                guint8 structure_type);

Gets a hardware SMBIOS data.

#### Parameters

self | a FuContext |
structure_type | a SMBIOS structure type, e.g. `FU_SMBIOS_STRUCTURE_TYPE_BIOS` |

#### Returns

a GBytes, or `NULL`.

[transfer full]

Since: 1.6.0

### fu_context_has_hwid_guid ()

    gboolean
    fu_context_has_hwid_guid (FuContext *self,
                              const gchar *guid);

Finds out if a hardware GUID exists.

#### Parameters

self | a FuContext |
guid | a GUID, e.g. `059eb22d-6dc7-59af-abd3-94bbe017f67c` |

#### Returns

`TRUE` if the GUID exists

Since: 1.6.0

### fu_context_get_hwid_guids ()

    GPtrArray *
    fu_context_get_hwid_guids (FuContext *self);

Returns all the HWIDs defined in the system. All hardware IDs on a specific system can be shown using the `fwupdmgr hwids` command.

#### Parameters

self | a FuContext |

#### Returns

an array of GUIDs.

[transfer none][element-type utf8]

Since: 1.6.0

### fu_context_has_hwid_flag ()

    gboolean
    fu_context_has_hwid_flag (FuContext *self,
                              const gchar *flag);

Returns if a HwId custom flag exists, typically added from a DMI quirk.

#### Parameters

self | a FuContext |
flag | flag, e.g. `use-legacy-bootmgr-desc` |

#### Returns

`TRUE` if the flag exists

Since: 1.7.2

### fu_context_get_hwid_value ()

    const gchar *
    fu_context_get_hwid_value (FuContext *self,
                               const gchar *key);

Gets the cached value for one specific key that is valid ASCII and suitable for display.

#### Parameters

self | a FuContext |
key | a DMI ID, e.g. `BiosVersion` |

#### Returns

the string, e.g. `1.2.3`, or `NULL` if not found

Since: 1.6.0

### fu_context_get_hwid_replace_value ()

    gchar *
    fu_context_get_hwid_replace_value (FuContext *self,
                                       const gchar *keys,
                                       GError **error);

Gets the replacement value for a specific key. All hardware IDs on a specific system can be shown using the `fwupdmgr hwids` command.

#### Parameters

self | a FuContext |
keys | a key, e.g. `HardwareID-3` or `FU_HWIDS_KEY_PRODUCT_SKU` |
error | optional return location for an error. | [nullable]

#### Returns

a string, or `NULL` for error.

[transfer full]

Since: 1.6.0

### fu_context_add_runtime_version ()

    void
    fu_context_add_runtime_version (FuContext *self,
                                    const gchar *component_id,
                                    const gchar *version);

Sets a runtime version of a specific dependency.

#### Parameters

self | a FuContext |
component_id | an AppStream component id, e.g. `org.gnome.Software` |
version | a version string, e.g. `1.2.3` |

Since: 1.6.0

### fu_context_add_compile_version ()

    void
    fu_context_add_compile_version (FuContext *self,
                                    const gchar *component_id,
                                    const gchar *version);

Sets a compile-time version of a specific dependency.

#### Parameters

self | a FuContext |
component_id | an AppStream component id, e.g. `org.gnome.Software` |
version | a version string, e.g. `1.2.3` |

Since: 1.6.0

### fu_context_lookup_quirk_by_id ()

    const gchar *
    fu_context_lookup_quirk_by_id (FuContext *self,
                                   const gchar *guid,
                                   const gchar *key);

Looks up an entry in the hardware database using a string value.

#### Parameters

self | a FuContext |
guid | GUID to lookup |
key | an ID to match the entry, e.g. `Summary` |

#### Returns

values from the database, or `NULL` if not found.

[transfer none]

Since: 1.6.0

### fu_context_lookup_quirk_by_id_iter ()

    gboolean
    fu_context_lookup_quirk_by_id_iter (FuContext *self,
                                        const gchar *guid,
                                        FuContextLookupIter iter_cb,
                                        gpointer user_data);

Looks up all entries in the hardware database using a GUID value.

#### Parameters

self | a FuContext |
guid | GUID to lookup |
iter_cb | a function to call for each result. | [scope async]
user_data | user data passed to `iter_cb` |

#### Returns

`TRUE` if the ID was found, and `iter` was called

Since: 1.6.0

### fu_context_add_quirk_key ()

    void
    fu_context_add_quirk_key (FuContext *self,
                              const gchar *key);

Adds a possible quirk key. If added by a plugin it should be namespaced using the plugin name, where possible.

Plugins can use this method only in `fu_plugin_init()`

#### Parameters

self | a FuContext |
key | a quirk string, e.g. `DfuVersion` |

Since: 1.6.0

### fu_context_security_changed ()

    void
    fu_context_security_changed (FuContext *self);

Informs the daemon that the HSI state may have changed.

#### Parameters

self | a FuContext |

Since: 1.6.0

### fu_context_get_battery_state ()

    FuBatteryState
    fu_context_get_battery_state (FuContext *self);

Gets if the system is on battery power, e.g. UPS or laptop battery.

#### Parameters

self | a FuContext |

#### Returns

a battery state, e.g. `FU_BATTERY_STATE_DISCHARGING`

Since: 1.6.0

### fu_context_set_battery_state ()

    void
    fu_context_set_battery_state (FuContext *self,
                                  FuBatteryState battery_state);

Sets if the system is on battery power, e.g. UPS or laptop battery.

#### Parameters

self | a FuContext |
battery_state | a battery state, e.g. `FU_BATTERY_STATE_DISCHARGING` |

Since: 1.6.0

### fu_context_get_lid_state ()

    FuLidState
    fu_context_get_lid_state (FuContext *self);

Gets the laptop lid state, if applicable.

#### Parameters

self | a FuContext |

#### Returns

a battery state, e.g. `FU_LID_STATE_CLOSED`

Since: 1.7.4

### fu_context_set_lid_state ()

    void
    fu_context_set_lid_state (FuContext *self,
                              FuLidState lid_state);

Sets the laptop lid state, if applicable.

#### Parameters

self | a FuContext |
lid_state | a battery state, e.g. `FU_LID_STATE_CLOSED` |

Since: 1.7.4

### fu_context_get_battery_level ()

    guint
    fu_context_get_battery_level (FuContext *self);

Gets the system battery level in percent.

#### Parameters

self | a FuContext |

#### Returns

percentage value, or `FU_BATTERY_VALUE_INVALID` for unknown

Since: 1.6.0

### fu_context_set_battery_level ()

    void
    fu_context_set_battery_level (FuContext *self,
                                  guint battery_level);

Sets the system battery level in percent.

#### Parameters

self | a FuContext |
battery_level | value |

Since: 1.6.0

### fu_context_get_battery_threshold ()

    guint
    fu_context_get_battery_threshold (FuContext *self);

Gets the system battery threshold in percent.

#### Parameters

self | a FuContext |

#### Returns

percentage value, or `FU_BATTERY_VALUE_INVALID` for unknown

Since: 1.6.0

### fu_context_set_battery_threshold ()

    void
    fu_context_set_battery_threshold (FuContext *self,
                                      guint battery_threshold);

Sets the system battery threshold in percent.

#### Parameters

self | a FuContext |
battery_threshold | value |

Since: 1.6.0

## Types and Values

### FU_TYPE_CONTEXT

    #define FU_TYPE_CONTEXT (fu_context_get_type())

### struct FuContextClass

    struct FuContextClass {
    	GObjectClass parent_class;
    	/* signals */
    	void (*security_changed)(FuContext *self);
    };

### FuContext

    typedef struct _FuContext FuContext;

A context that represents the shared system state. This object is shared between the engine, the plugins and the devices.