FwupdDevice: fwupd Reference Manual

## FwupdDevice FwupdDevice — a hardware device |

## Functions

FwupdDevice * | fwupd_device_new ()
gchar * | fwupd_device_to_string ()
const gchar * | fwupd_device_get_id ()
void | fwupd_device_set_id ()
const gchar * | fwupd_device_get_parent_id ()
void | fwupd_device_set_parent_id ()
FwupdDevice * | fwupd_device_get_parent ()
void | fwupd_device_set_parent ()
const gchar * | fwupd_device_get_name ()
void | fwupd_device_set_name ()
const gchar * | fwupd_device_get_serial ()
void | fwupd_device_set_serial ()
const gchar * | fwupd_device_get_summary ()
void | fwupd_device_set_summary ()
const gchar * | fwupd_device_get_description ()
void | fwupd_device_set_description ()
const gchar * | fwupd_device_get_version ()
void | fwupd_device_set_version ()
const gchar * | fwupd_device_get_version_lowest ()
void | fwupd_device_set_version_lowest ()
const gchar * | fwupd_device_get_version_bootloader ()
void | fwupd_device_set_version_bootloader ()
guint32 | fwupd_device_get_flashes_left ()
void | fwupd_device_set_flashes_left ()
guint32 | fwupd_device_get_install_duration ()
void | fwupd_device_set_install_duration ()
guint64 | fwupd_device_get_flags ()
void | fwupd_device_set_flags ()
void | fwupd_device_add_flag ()
void | fwupd_device_remove_flag ()
gboolean | fwupd_device_has_flag ()
guint64 | fwupd_device_get_created ()
void | fwupd_device_set_created ()
guint64 | fwupd_device_get_modified ()
void | fwupd_device_set_modified ()
GPtrArray * | fwupd_device_get_checksums ()
void | fwupd_device_add_checksum ()
const gchar * | fwupd_device_get_plugin ()
void | fwupd_device_set_plugin ()
const gchar * | fwupd_device_get_vendor ()
void | fwupd_device_set_vendor ()
const gchar * | fwupd_device_get_vendor_id ()
void | fwupd_device_set_vendor_id ()
void | fwupd_device_add_guid ()
gboolean | fwupd_device_has_guid ()
GPtrArray * | fwupd_device_get_guids ()
const gchar * | fwupd_device_get_guid_default ()
void | fwupd_device_add_instance_id ()
gboolean | fwupd_device_has_instance_id ()
GPtrArray * | fwupd_device_get_instance_ids ()
void | fwupd_device_add_icon ()
GPtrArray * | fwupd_device_get_icons ()
FwupdUpdateState | fwupd_device_get_update_state ()
void | fwupd_device_set_update_state ()
const gchar * | fwupd_device_get_update_error ()
void | fwupd_device_set_update_error ()
const gchar * | fwupd_device_get_update_message ()
void | fwupd_device_set_update_message ()
void | fwupd_device_add_release ()
GPtrArray * | fwupd_device_get_releases ()
FwupdRelease * | fwupd_device_get_release_default ()
gint | fwupd_device_compare ()

## Types and Values

#define | FWUPD_TYPE_DEVICE
struct | FwupdDeviceClass
| FwupdDevice

## Description

An object that represents a physical device on the host.

See also: FwupdRelease

## Functions

### fwupd_device_new ()

    FwupdDevice *
    fwupd_device_new (void);

Creates a new device.

#### Returns

a new FwupdDevice

Since: 0.9.3

### fwupd_device_to_string ()

    gchar *
    fwupd_device_to_string (FwupdDevice *device);

Builds a text representation of the object.

#### Parameters

device | A FwupdDevice |

#### Returns

text, or `NULL` for invalid

Since: 0.9.3

### fwupd_device_get_id ()

    const gchar *
    fwupd_device_get_id (FwupdDevice *device);

Gets the ID.

#### Parameters

device | A FwupdDevice |

#### Returns

the ID, or `NULL` if unset

Since: 0.9.3

### fwupd_device_set_id ()

    void
    fwupd_device_set_id (FwupdDevice *device,
                         const gchar *id);

Sets the ID.

#### Parameters

device | A FwupdDevice |
id | the device ID, e.g. `USB:foo` |

Since: 0.9.3

### fwupd_device_get_parent_id ()

    const gchar *
    fwupd_device_get_parent_id (FwupdDevice *device);

Gets the ID.

#### Parameters

device | A FwupdDevice |

#### Returns

the parent ID, or `NULL` if unset

Since: 1.0.8

### fwupd_device_set_parent_id ()

    void
    fwupd_device_set_parent_id (FwupdDevice *device,
                                const gchar *parent_id);

Sets the parent ID.

#### Parameters

device | A FwupdDevice |
parent_id | the device ID, e.g. `USB:foo` |

Since: 1.0.8

### fwupd_device_get_parent ()

    FwupdDevice *
    fwupd_device_get_parent (FwupdDevice *device);

Gets the parent.

#### Parameters

device | A FwupdDevice |

#### Returns

the parent device, or `NULL` if unset.

[transfer none]

Since: 1.0.8

### fwupd_device_set_parent ()

    void
    fwupd_device_set_parent (FwupdDevice *device,
                             FwupdDevice *parent);

Sets the parent. Only used internally.

#### Parameters

device | A FwupdDevice |
parent | another FwupdDevice, or `NULL` |

Since: 1.0.8

### fwupd_device_get_name ()

    const gchar *
    fwupd_device_get_name (FwupdDevice *device);

Gets the device name.

#### Parameters

device | A FwupdDevice |

#### Returns

the device name, or `NULL` if unset

Since: 0.9.3

### fwupd_device_set_name ()

    void
    fwupd_device_set_name (FwupdDevice *device,
                           const gchar *name);

Sets the device name.

#### Parameters

device | A FwupdDevice |
name | the device name, e.g. `ColorHug2` |

Since: 0.9.3

### fwupd_device_get_serial ()

    const gchar *
    fwupd_device_get_serial (FwupdDevice *device);

Gets the serial number for the device.

#### Parameters

device | A FwupdDevice |

#### Returns

a string value, or `NULL` if never set.

Since: 1.1.2

### fwupd_device_set_serial ()

    void
    fwupd_device_set_serial (FwupdDevice *device,
                             const gchar *serial);

Sets the serial number for the device.

#### Parameters

device | A FwupdDevice |
serial | the device serial number |

Since: 1.1.2

### fwupd_device_get_summary ()

    const gchar *
    fwupd_device_get_summary (FwupdDevice *device);

Gets the device summary.

#### Parameters

device | A FwupdDevice |

#### Returns

the device summary, or `NULL` if unset

Since: 0.9.3

### fwupd_device_set_summary ()

    void
    fwupd_device_set_summary (FwupdDevice *device,
                              const gchar *summary);

Sets the device summary.

#### Parameters

device | A FwupdDevice |
summary | the device one line summary |

Since: 0.9.3

### fwupd_device_get_description ()

    const gchar *
    fwupd_device_get_description (FwupdDevice *device);

Gets the device description in AppStream markup format.

#### Parameters

device | A FwupdDevice |

#### Returns

the device description, or `NULL` if unset

Since: 0.9.3

### fwupd_device_set_description ()

    void
    fwupd_device_set_description (FwupdDevice *device,
                                  const gchar *description);

Sets the device description.

#### Parameters

device | A FwupdDevice |
description | the description in AppStream markup format |

Since: 0.9.3

### fwupd_device_get_version ()

    const gchar *
    fwupd_device_get_version (FwupdDevice *device);

Gets the device version.

#### Parameters

device | A FwupdDevice |

#### Returns

the device version, or `NULL` if unset

Since: 0.9.3

### fwupd_device_set_version ()

    void
    fwupd_device_set_version (FwupdDevice *device,
                              const gchar *version);

Sets the device version.

#### Parameters

device | A FwupdDevice |
version | the device version, e.g. `1.2.3` |

Since: 0.9.3

### fwupd_device_get_version_lowest ()

    const gchar *
    fwupd_device_get_version_lowest (FwupdDevice *device);

Gets the lowest version of firmware the device will accept.

#### Parameters

device | A FwupdDevice |

#### Returns

the device version_lowest, or `NULL` if unset

Since: 0.9.3

### fwupd_device_set_version_lowest ()

    void
    fwupd_device_set_version_lowest (FwupdDevice *device,
                                     const gchar *version_lowest);

Sets the lowest version of firmware the device will accept.

#### Parameters

device | A FwupdDevice |
version_lowest | the description |

Since: 0.9.3

### fwupd_device_get_version_bootloader ()

    const gchar *
    fwupd_device_get_version_bootloader (FwupdDevice *device);

Gets the version of the bootloader.

#### Parameters

device | A FwupdDevice |

#### Returns

the device version_bootloader, or `NULL` if unset

Since: 0.9.3

### fwupd_device_set_version_bootloader ()

    void
    fwupd_device_set_version_bootloader (FwupdDevice *device,
                                         const gchar *version_bootloader);

Sets the bootloader version.

#### Parameters

device | A FwupdDevice |
version_bootloader | the description |

Since: 0.9.3

### fwupd_device_get_flashes_left ()

    guint32
    fwupd_device_get_flashes_left (FwupdDevice *device);

Gets the number of flash cycles left on the device

#### Parameters

device | A FwupdDevice |

#### Returns

the flash cycles left, or `NULL` if unset

Since: 0.9.3

### fwupd_device_set_flashes_left ()

    void
    fwupd_device_set_flashes_left (FwupdDevice *device,
                                   guint32 flashes_left);

Sets the number of flash cycles left on the device

#### Parameters

device | A FwupdDevice |
flashes_left | the description |

Since: 0.9.3

### fwupd_device_get_install_duration ()

    guint32
    fwupd_device_get_install_duration (FwupdDevice *device);

Gets the time estimate for firmware installation (in seconds)

#### Parameters

device | A FwupdDevice |

#### Returns

the estimated time to flash this device (or 0 if unset)

Since: 1.1.3

### fwupd_device_set_install_duration ()

    void
    fwupd_device_set_install_duration (FwupdDevice *device,
                                       guint32 duration);

Sets the time estimate for firmware installation (in seconds)

#### Parameters

device | A FwupdDevice |
duration | The amount of time |

Since: 1.1.3

### fwupd_device_get_flags ()

    guint64
    fwupd_device_get_flags (FwupdDevice *device);

Gets the device flags.

#### Parameters

device | A FwupdDevice |

#### Returns

the device flags, or 0 if unset

Since: 0.9.3

### fwupd_device_set_flags ()

    void
    fwupd_device_set_flags (FwupdDevice *device,
                            guint64 flags);

Sets the device flags.

#### Parameters

device | A FwupdDevice |
flags | the device flags, e.g. `FWUPD_DEVICE_FLAG_REQUIRE_AC` |

Since: 0.9.3

### fwupd_device_add_flag ()

    void
    fwupd_device_add_flag (FwupdDevice *device,
                           FwupdDeviceFlags flag);

Adds a specific device flag to the device.

#### Parameters

device | A FwupdDevice |
flag | the FwupdDeviceFlags |

Since: 0.9.3

### fwupd_device_remove_flag ()

    void
    fwupd_device_remove_flag (FwupdDevice *device,
                              FwupdDeviceFlags flag);

Removes a specific device flag from the device.

#### Parameters

device | A FwupdDevice |
flag | the FwupdDeviceFlags |

Since: 0.9.3

### fwupd_device_has_flag ()

    gboolean
    fwupd_device_has_flag (FwupdDevice *device,
                           FwupdDeviceFlags flag);

Finds if the device has a specific device flag.

#### Parameters

device | A FwupdDevice |
flag | the FwupdDeviceFlags |

#### Returns

`TRUE` if the flag is set

Since: 0.9.3

### fwupd_device_get_created ()

    guint64
    fwupd_device_get_created (FwupdDevice *device);

Gets when the device was created.

#### Parameters

device | A FwupdDevice |

#### Returns

the UNIX time, or 0 if unset

Since: 0.9.3

### fwupd_device_set_created ()

    void
    fwupd_device_set_created (FwupdDevice *device,
                              guint64 created);

Sets when the device was created.

#### Parameters

device | A FwupdDevice |
created | the UNIX time |

Since: 0.9.3

### fwupd_device_get_modified ()

    guint64
    fwupd_device_get_modified (FwupdDevice *device);

Gets when the device was modified.

#### Parameters

device | A FwupdDevice |

#### Returns

the UNIX time, or 0 if unset

Since: 0.9.3

### fwupd_device_set_modified ()

    void
    fwupd_device_set_modified (FwupdDevice *device,
                               guint64 modified);

Sets when the device was modified.

#### Parameters

device | A FwupdDevice |
modified | the UNIX time |

Since: 0.9.3

### fwupd_device_get_checksums ()

    GPtrArray *
    fwupd_device_get_checksums (FwupdDevice *device);

Gets the device checksums.

#### Parameters

device | A FwupdDevice |

#### Returns

the checksums, which may be empty.

[element-type utf8][transfer none]

Since: 0.9.3

### fwupd_device_add_checksum ()

    void
    fwupd_device_add_checksum (FwupdDevice *device,
                               const gchar *checksum);

Sets the device checksum.

#### Parameters

device | A FwupdDevice |
checksum | the device checksum |

Since: 0.9.3

### fwupd_device_get_plugin ()

    const gchar *
    fwupd_device_get_plugin (FwupdDevice *device);

Gets the plugin that created the device.

#### Parameters

device | A FwupdDevice |

#### Returns

the plugin name, or `NULL` if unset

Since: 1.0.0

### fwupd_device_set_plugin ()

    void
    fwupd_device_set_plugin (FwupdDevice *device,
                             const gchar *plugin);

Sets the plugin that created the device.

#### Parameters

device | A FwupdDevice |
plugin | the plugin name, e.g. `colorhug` |

Since: 1.0.0

### fwupd_device_get_vendor ()

    const gchar *
    fwupd_device_get_vendor (FwupdDevice *device);

Gets the device vendor.

#### Parameters

device | A FwupdDevice |

#### Returns

the device vendor, or `NULL` if unset

Since: 0.9.3

### fwupd_device_set_vendor ()

    void
    fwupd_device_set_vendor (FwupdDevice *device,
                             const gchar *vendor);

Sets the device vendor.

#### Parameters

device | A FwupdDevice |
vendor | the description |

Since: 0.9.3

### fwupd_device_get_vendor_id ()

    const gchar *
    fwupd_device_get_vendor_id (FwupdDevice *device);

Gets the device vendor ID.

#### Parameters

device | A FwupdDevice |

#### Returns

the device vendor, e.g. 'USB:0x1234', or `NULL` if unset

Since: 0.9.4

### fwupd_device_set_vendor_id ()

    void
    fwupd_device_set_vendor_id (FwupdDevice *device,
                                const gchar *vendor_id);

Sets the device vendor ID.

#### Parameters

device | A FwupdDevice |
vendor_id | the ID, e.g. 'USB:0x1234' |

Since: 0.9.4

### fwupd_device_add_guid ()

    void
    fwupd_device_add_guid (FwupdDevice *device,
                           const gchar *guid);

Adds the GUID if it does not already exist.

#### Parameters

device | A FwupdDevice |
guid | the GUID, e.g. `2082b5e0-7a64-478a-b1b2-e3404fab6dad` |

Since: 0.9.3

### fwupd_device_has_guid ()

    gboolean
    fwupd_device_has_guid (FwupdDevice *device,
                           const gchar *guid);

Finds out if the device has this specific GUID.

#### Parameters

device | A FwupdDevice |
guid | the GUID, e.g. `2082b5e0-7a64-478a-b1b2-e3404fab6dad` |

#### Returns

`TRUE` if the GUID is found

Since: 0.9.3

### fwupd_device_get_guids ()

    GPtrArray *
    fwupd_device_get_guids (FwupdDevice *device);

Gets the GUIDs.

#### Parameters

device | A FwupdDevice |

#### Returns

the GUIDs.

[element-type utf8][transfer none]

Since: 0.9.3

### fwupd_device_get_guid_default ()

    const gchar *
    fwupd_device_get_guid_default (FwupdDevice *device);

Gets the default GUID.

#### Parameters

device | A FwupdDevice |

#### Returns

the GUID, or `NULL` if unset

Since: 0.9.3

### fwupd_device_add_instance_id ()

    void
    fwupd_device_add_instance_id (FwupdDevice *device,
                                  const gchar *instance_id);

Adds the InstanceID if it does not already exist.

#### Parameters

device | A FwupdDevice |
instance_id | the GUID, e.g. `PCI\VEN_10EC&amp;DEV_525A` |

Since: 1.2.5

### fwupd_device_has_instance_id ()

    gboolean
    fwupd_device_has_instance_id (FwupdDevice *device,
                                  const gchar *instance_id);

Finds out if the device has this specific InstanceID.

#### Parameters

device | A FwupdDevice |
instance_id | the InstanceID, e.g. `PCI\VEN_10EC&amp;DEV_525A` |

#### Returns

`TRUE` if the InstanceID is found

Since: 1.2.5

### fwupd_device_get_instance_ids ()

    GPtrArray *
    fwupd_device_get_instance_ids (FwupdDevice *device);

Gets the InstanceIDs.

#### Parameters

device | A FwupdDevice |

#### Returns

the InstanceID.

[element-type utf8][transfer none]

Since: 1.2.5

### fwupd_device_add_icon ()

    void
    fwupd_device_add_icon (FwupdDevice *device,
                           const gchar *icon);

Adds the icon name if it does not already exist.

#### Parameters

device | A FwupdDevice |
icon | the name, e.g. `input-mouse` or `/usr/share/icons/foo.png` |

Since: 0.9.8

### fwupd_device_get_icons ()

    GPtrArray *
    fwupd_device_get_icons (FwupdDevice *device);

Gets the icon names to use for the device.

NOTE: Icons specified without a full path are stock icons and should be loaded from the users icon theme.

#### Parameters

device | A FwupdDevice |

#### Returns

an array of icon names.

[element-type utf8][transfer none]

Since: 0.9.8

### fwupd_device_get_update_state ()

    FwupdUpdateState
    fwupd_device_get_update_state (FwupdDevice *device);

Gets the update state.

#### Parameters

device | A FwupdDevice |

#### Returns

the update state, or `FWUPD_UPDATE_STATE_UNKNOWN` if unset

Since: 0.9.8

### fwupd_device_set_update_state ()

    void
    fwupd_device_set_update_state (FwupdDevice *device,
                                   FwupdUpdateState update_state);

Sets the update state.

#### Parameters

device | A FwupdDevice |
update_state | the state, e.g. `FWUPD_UPDATE_STATE_PENDING` |

Since: 0.9.8

### fwupd_device_get_update_error ()

    const gchar *
    fwupd_device_get_update_error (FwupdDevice *device);

Gets the update error.

#### Parameters

device | A FwupdDevice |

#### Returns

the update error, or `NULL` if unset

Since: 0.9.8

### fwupd_device_set_update_error ()

    void
    fwupd_device_set_update_error (FwupdDevice *device,
                                   const gchar *update_error);

Sets the update error.

#### Parameters

device | A FwupdDevice |
update_error | the update error string |

Since: 0.9.8

### fwupd_device_get_update_message ()

    const gchar *
    fwupd_device_get_update_message (FwupdDevice *device);

Gets the update message.

#### Parameters

device | A FwupdDevice |

#### Returns

the update message, or `NULL` if unset

Since: 1.2.4

### fwupd_device_set_update_message ()

    void
    fwupd_device_set_update_message (FwupdDevice *device,
                                     const gchar *update_message);

Sets the update message.

#### Parameters

device | A FwupdDevice |
update_message | the update message string |

Since: 1.2.4

### fwupd_device_add_release ()

    void
    fwupd_device_add_release (FwupdDevice *device,
                              FwupdRelease *release);

Adds a release for this device.

#### Parameters

device | A FwupdDevice |
release | a FwupdRelease |

Since: 0.9.8

### fwupd_device_get_releases ()

    GPtrArray *
    fwupd_device_get_releases (FwupdDevice *device);

Gets all the releases for this device.

#### Parameters

device | A FwupdDevice |

#### Returns

array of releases.

[transfer none][element-type FwupdRelease]

Since: 0.9.8

### fwupd_device_get_release_default ()

    FwupdRelease *
    fwupd_device_get_release_default (FwupdDevice *device);

Gets the default release for this device.

#### Parameters

device | A FwupdDevice |

#### Returns

the FwupdRelease, or `NULL` if not set.

[transfer none]

Since: 0.9.8

### fwupd_device_compare ()

    gint
    fwupd_device_compare (FwupdDevice *device1,
                          FwupdDevice *device2);

Comparison function for comparing two FwupdDevice objects.

#### Parameters

device1 | a FwupdDevice |
device2 | a FwupdDevice |

#### Returns

negative, 0 or positive

Since: 1.1.1

## Types and Values

### FWUPD_TYPE_DEVICE

    #define FWUPD_TYPE_DEVICE (fwupd_device_get_type ())

### struct FwupdDeviceClass

    struct FwupdDeviceClass {
    	GObjectClass			 parent_class;
    };

### FwupdDevice

    typedef struct _FwupdDevice FwupdDevice;