fu-device-locker

fu-device-locker

Functions

Types and Values

Description

Functions

FuDeviceLockerFunc ()

gboolean
(*FuDeviceLockerFunc) (GObject *device,
                       GError **error);

Callback to use when opening and closing using [ctorDeviceLocker.new_full ].


fu_device_locker_new ()

FuDeviceLocker *
fu_device_locker_new (gpointer device,
                      GError **error);

Opens the device for use. When the FuDeviceLocker is deallocated the device will be closed and any error will just be directed to the console. This object is typically called using g_autoptr() but the device can also be manually closed using g_clear_object().

The functions used for opening and closing the device are set automatically. If the device is not a type or supertype of GUsbDevice or FuDevice then this function will not work.

For custom objects please use fu_device_locker_new_full().

NOTE: If the open_func failed then the close_func will not be called.

Think of this object as the device ownership.

Parameters

device

a GObject

 

error

optional return location for an error.

[nullable]

Returns

a device locker, or NULL if the open_func failed.

Since: 1.0.0


fu_device_locker_new_full ()

FuDeviceLocker *
fu_device_locker_new_full (gpointer device,
                           FuDeviceLockerFunc open_func,
                           FuDeviceLockerFunc close_func,
                           GError **error);

Opens the device for use. When the FuDeviceLocker is deallocated the device will be closed and any error will just be directed to the console. This object is typically called using g_autoptr() but the device can also be manually closed using g_clear_object().

NOTE: If the open_func failed then the close_func will not be called.

Think of this object as the device ownership.

Parameters

device

a GObject

 

open_func

a function to open the device.

[scope async]

close_func

a function to close the device.

[scope async]

error

optional return location for an error.

[nullable]

Returns

a device locker, or NULL if the open_func failed.

Since: 1.0.0


fu_device_locker_close ()

gboolean
fu_device_locker_close (FuDeviceLocker *self,
                        GError **error);

Closes the locker before it gets cleaned up.

This function can be used to manually close a device managed by a locker, and allows the caller to properly handle the error.

Parameters

self

a FuDeviceLocker

 

error

optional return location for an error.

[nullable]

Returns

TRUE for success

Since: 1.4.0

Types and Values

FU_TYPE_DEVICE_LOCKER

#define FU_TYPE_DEVICE_LOCKER (fu_device_locker_get_type())

FuDeviceLocker

typedef struct _FuDeviceLocker FuDeviceLocker;

Easily close a shared resource (such as a device) when an object goes out of scope.

See also: [classFuDevice ]