fwupd/plugins/logitech-hidpp/fu-logitech-hidpp-device.h
Richard Hughes 40cd18fa97 Allow using a per-device global percentage completion
It's actually quite hard to build a front-end for fwupd at the moment
as you're never sure when the progress bar is going to zip back to 0%
and start all over again. Some plugins go 0..100% for write, others
go 0..100% for erase, then again for write, then *again* for verify.

By creating a helper object we can easily split up the progress of the
specific task, e.g. write_firmware().

We can encode at the plugin level "the erase takes 50% of the time, the
write takes 40% and the read takes 10%". This means we can have a
progressbar which goes up just once at a consistent speed.
2021-09-13 14:28:15 +01:00

93 lines
2.1 KiB
C

/*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <fwupdplugin.h>
#define FU_TYPE_HIDPP_DEVICE (fu_logitech_hidpp_device_get_type())
G_DECLARE_DERIVABLE_TYPE(FuLogitechHidPpDevice,
fu_logitech_hidpp_device,
FU,
HIDPP_DEVICE,
FuUdevDevice)
struct _FuLogitechHidPpDeviceClass {
FuUdevDeviceClass parent_class;
/* TODO: overridable methods */
};
/**
* FU_LOGITECH_HIDPP_DEVICE_FLAG_FORCE_RECEIVER_ID:
*
* Device is a unifying or Bolt receiver.
*
* Since: 1.7.0
*/
#define FU_LOGITECH_HIDPP_DEVICE_FLAG_FORCE_RECEIVER_ID (1 << 0)
/**
* FU_LOGITECH_HIDPP_DEVICE_FLAG_BLE:
*
* Device is connected using Bluetooth Low Energy.
*
* Since: 1.7.0
*/
#define FU_LOGITECH_HIDPP_DEVICE_FLAG_BLE (1 << 1)
/**
* FU_LOGITECH_HIDPP_DEVICE_FLAG_REBIND_ATTACH:
*
* The device file is automatically unbound and re-bound after the
* device is attached.
*
* Since: 1.7.0
*/
#define FU_LOGITECH_HIDPP_DEVICE_FLAG_REBIND_ATTACH (1 << 2)
/**
* FU_LOGITECH_HIDPP_DEVICE_FLAG_NO_REQUEST_REQUIRED:
*
* No user-action is required for detach and attach.
*
* Since: 1.7.0
*/
#define FU_LOGITECH_HIDPP_DEVICE_FLAG_NO_REQUEST_REQUIRED (1 << 3)
/**
* FU_LOGITECH_HIDPP_DEVICE_FLAG_BOLT_PERIPHERAL:
*
* The device is handled through a Bolt receiver.
*
* Since: 1.7.0
*/
#define FU_LOGITECH_HIDPP_DEVICE_FLAG_BOLT_PERIPHERAL (1 << 4)
/**
* FU_LOGITECH_HIDPP_DEVICE_FLAG_ADD_RADIO:
*
* The device should add a softdevice (index 0x5), typically a radio.
*
* Since: 1.7.0
*/
#define FU_LOGITECH_HIDPP_DEVICE_FLAG_ADD_RADIO (1 << 5)
void
fu_logitech_hidpp_device_set_device_idx(FuLogitechHidPpDevice *self, guint8 device_idx);
guint16
fu_logitech_hidpp_device_get_hidpp_pid(FuLogitechHidPpDevice *self);
void
fu_logitech_hidpp_device_set_hidpp_pid(FuLogitechHidPpDevice *self, guint16 hidpp_pid);
const gchar *
fu_logitech_hidpp_device_get_model_id(FuLogitechHidPpDevice *self);
gboolean
fu_logitech_hidpp_device_attach(FuLogitechHidPpDevice *self,
guint8 entity,
FuProgress *progress,
GError **error);
FuLogitechHidPpDevice *
fu_logitech_hidpp_device_new(FuUdevDevice *parent);