FuDeviceLocker: fwupd Reference Manual

## FuDeviceLocker FuDeviceLocker — a device helper object |

## Functions

gboolean | (*FuDeviceLockerFunc) ()
FuDeviceLocker * | fu_device_locker_new ()
FuDeviceLocker * | fu_device_locker_new_full ()

## Types and Values

#define | FU_TYPE_DEVICE_LOCKER
| FuDeviceLocker

## Description

An object that makes it easy to close a device when an object goes out of scope.

See also: FuDevice

## Functions

### FuDeviceLockerFunc ()

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

### 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 | A GError, or `NULL` |

#### Returns

a FuDeviceLocker, or `NULL` if the `open_func` failed.

### 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 | A GError, or `NULL` |

#### Returns

a FuDeviceLocker, or `NULL` if the `open_func` failed.

## Types and Values

### FU_TYPE_DEVICE_LOCKER

    #define FU_TYPE_DEVICE_LOCKER (fu_device_locker_get_type ())

### FuDeviceLocker

    typedef struct _FuDeviceLocker FuDeviceLocker;