mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-15 18:08:21 +00:00
trivial: Use FwupdStatus in the dfu plugin
This commit is contained in:
parent
e0bd53e439
commit
b73ff8a346
@ -48,6 +48,10 @@ fwupd_status_to_string (FwupdStatus status)
|
|||||||
return "device-restart";
|
return "device-restart";
|
||||||
if (status == FWUPD_STATUS_DEVICE_WRITE)
|
if (status == FWUPD_STATUS_DEVICE_WRITE)
|
||||||
return "device-write";
|
return "device-write";
|
||||||
|
if (status == FWUPD_STATUS_DEVICE_READ)
|
||||||
|
return "device-read";
|
||||||
|
if (status == FWUPD_STATUS_DEVICE_ERASE)
|
||||||
|
return "device-erase";
|
||||||
if (status == FWUPD_STATUS_DEVICE_VERIFY)
|
if (status == FWUPD_STATUS_DEVICE_VERIFY)
|
||||||
return "device-verify";
|
return "device-verify";
|
||||||
if (status == FWUPD_STATUS_SCHEDULING)
|
if (status == FWUPD_STATUS_SCHEDULING)
|
||||||
@ -88,6 +92,10 @@ fwupd_status_from_string (const gchar *status)
|
|||||||
return FWUPD_STATUS_SCHEDULING;
|
return FWUPD_STATUS_SCHEDULING;
|
||||||
if (g_strcmp0 (status, "downloading") == 0)
|
if (g_strcmp0 (status, "downloading") == 0)
|
||||||
return FWUPD_STATUS_DOWNLOADING;
|
return FWUPD_STATUS_DOWNLOADING;
|
||||||
|
if (g_strcmp0 (status, "device-read") == 0)
|
||||||
|
return FWUPD_STATUS_DEVICE_READ;
|
||||||
|
if (g_strcmp0 (status, "device-erase") == 0)
|
||||||
|
return FWUPD_STATUS_DEVICE_ERASE;
|
||||||
return FWUPD_STATUS_LAST;
|
return FWUPD_STATUS_LAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,8 @@ typedef enum {
|
|||||||
FWUPD_STATUS_DEVICE_VERIFY, /* Since: 0.1.1 */
|
FWUPD_STATUS_DEVICE_VERIFY, /* Since: 0.1.1 */
|
||||||
FWUPD_STATUS_SCHEDULING, /* Since: 0.1.1 */
|
FWUPD_STATUS_SCHEDULING, /* Since: 0.1.1 */
|
||||||
FWUPD_STATUS_DOWNLOADING, /* Since: 0.9.4 */
|
FWUPD_STATUS_DOWNLOADING, /* Since: 0.9.4 */
|
||||||
|
FWUPD_STATUS_DEVICE_READ, /* Since: 1.0.0 */
|
||||||
|
FWUPD_STATUS_DEVICE_ERASE, /* Since: 1.0.0 */
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
FWUPD_STATUS_LAST
|
FWUPD_STATUS_LAST
|
||||||
} FwupdStatus;
|
} FwupdStatus;
|
||||||
|
@ -169,31 +169,3 @@ dfu_version_to_string (DfuVersion version)
|
|||||||
return "DfuSe";
|
return "DfuSe";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* dfu_action_to_string:
|
|
||||||
* @action: a #DfuAction, e.g. %DFU_ACTION_VERIFY
|
|
||||||
*
|
|
||||||
* Converts an enumerated value to a string.
|
|
||||||
*
|
|
||||||
* Return value: a string
|
|
||||||
**/
|
|
||||||
const gchar *
|
|
||||||
dfu_action_to_string (DfuAction action)
|
|
||||||
{
|
|
||||||
if (action == DFU_ACTION_IDLE)
|
|
||||||
return "idle";
|
|
||||||
if (action == DFU_ACTION_READ)
|
|
||||||
return "read";
|
|
||||||
if (action == DFU_ACTION_WRITE)
|
|
||||||
return "write";
|
|
||||||
if (action == DFU_ACTION_VERIFY)
|
|
||||||
return "verify";
|
|
||||||
if (action == DFU_ACTION_ERASE)
|
|
||||||
return "erase";
|
|
||||||
if (action == DFU_ACTION_DETACH)
|
|
||||||
return "detach";
|
|
||||||
if (action == DFU_ACTION_ATTACH)
|
|
||||||
return "attach";
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
@ -175,32 +175,6 @@ typedef enum {
|
|||||||
DFU_VERSION_LAST
|
DFU_VERSION_LAST
|
||||||
} DfuVersion;
|
} DfuVersion;
|
||||||
|
|
||||||
/**
|
|
||||||
* DfuAction:
|
|
||||||
* @DFU_ACTION_UNKNOWN: No progress state
|
|
||||||
* @DFU_ACTION_IDLE: Device is idle
|
|
||||||
* @DFU_ACTION_READ: Reading from the device
|
|
||||||
* @DFU_ACTION_WRITE: Writing to the device
|
|
||||||
* @DFU_ACTION_VERIFY: Verifying the write
|
|
||||||
* @DFU_ACTION_ERASE: Erasing the device
|
|
||||||
* @DFU_ACTION_DETACH: Detach into DFU mode
|
|
||||||
* @DFU_ACTION_ATTACH: Attach into APP mode
|
|
||||||
*
|
|
||||||
* The device DFU attributes.
|
|
||||||
**/
|
|
||||||
typedef enum {
|
|
||||||
DFU_ACTION_UNKNOWN,
|
|
||||||
DFU_ACTION_IDLE,
|
|
||||||
DFU_ACTION_READ,
|
|
||||||
DFU_ACTION_WRITE,
|
|
||||||
DFU_ACTION_VERIFY,
|
|
||||||
DFU_ACTION_ERASE,
|
|
||||||
DFU_ACTION_DETACH,
|
|
||||||
DFU_ACTION_ATTACH,
|
|
||||||
/*< private >*/
|
|
||||||
DFU_ACTION_LAST
|
|
||||||
} DfuAction;
|
|
||||||
|
|
||||||
#define DFU_METADATA_KEY_LICENSE "License"
|
#define DFU_METADATA_KEY_LICENSE "License"
|
||||||
#define DFU_METADATA_KEY_COPYRIGHT "Copyright"
|
#define DFU_METADATA_KEY_COPYRIGHT "Copyright"
|
||||||
#define DFU_METADATA_KEY_CIPHER_KIND "CipherKind"
|
#define DFU_METADATA_KEY_CIPHER_KIND "CipherKind"
|
||||||
@ -210,7 +184,6 @@ const gchar *dfu_status_to_string (DfuStatus status);
|
|||||||
const gchar *dfu_mode_to_string (DfuMode mode);
|
const gchar *dfu_mode_to_string (DfuMode mode);
|
||||||
const gchar *dfu_cipher_kind_to_string (DfuCipherKind cipher_kind);
|
const gchar *dfu_cipher_kind_to_string (DfuCipherKind cipher_kind);
|
||||||
const gchar *dfu_version_to_string (DfuVersion version);
|
const gchar *dfu_version_to_string (DfuVersion version);
|
||||||
const gchar *dfu_action_to_string (DfuAction action);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ typedef struct {
|
|||||||
DfuMode mode;
|
DfuMode mode;
|
||||||
DfuState state;
|
DfuState state;
|
||||||
DfuStatus status;
|
DfuStatus status;
|
||||||
DfuAction action_last;
|
FwupdStatus action_last;
|
||||||
GPtrArray *targets;
|
GPtrArray *targets;
|
||||||
GUsbDevice *dev;
|
GUsbDevice *dev;
|
||||||
FuDeviceLocker *dev_locker;
|
FuDeviceLocker *dev_locker;
|
||||||
@ -139,7 +139,7 @@ dfu_device_class_init (DfuDeviceClass *klass)
|
|||||||
/**
|
/**
|
||||||
* DfuDevice::action-changed:
|
* DfuDevice::action-changed:
|
||||||
* @device: the #DfuDevice instance that emitted the signal
|
* @device: the #DfuDevice instance that emitted the signal
|
||||||
* @action: the new #DfuAction
|
* @action: the new #FwupdStatus
|
||||||
*
|
*
|
||||||
* The ::action-changed signal is emitted when the high level action changes.
|
* The ::action-changed signal is emitted when the high level action changes.
|
||||||
**/
|
**/
|
||||||
@ -169,7 +169,7 @@ dfu_device_init (DfuDevice *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dfu_device_set_action (DfuDevice *device, DfuAction action)
|
dfu_device_set_action (DfuDevice *device, FwupdStatus action)
|
||||||
{
|
{
|
||||||
DfuDevicePrivate *priv = GET_PRIVATE (device);
|
DfuDevicePrivate *priv = GET_PRIVATE (device);
|
||||||
if (action == priv->action_last)
|
if (action == priv->action_last)
|
||||||
@ -1090,7 +1090,7 @@ dfu_device_detach (DfuDevice *device, GCancellable *cancellable, GError **error)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* inform UI there's going to be a detach:attach */
|
/* inform UI there's going to be a detach:attach */
|
||||||
dfu_device_set_action (device, DFU_ACTION_DETACH);
|
dfu_device_set_action (device, FWUPD_STATUS_DEVICE_RESTART);
|
||||||
|
|
||||||
if (!g_usb_device_control_transfer (priv->dev,
|
if (!g_usb_device_control_transfer (priv->dev,
|
||||||
G_USB_DEVICE_DIRECTION_HOST_TO_DEVICE,
|
G_USB_DEVICE_DIRECTION_HOST_TO_DEVICE,
|
||||||
@ -1121,7 +1121,7 @@ dfu_device_detach (DfuDevice *device, GCancellable *cancellable, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
dfu_device_set_action (device, DFU_ACTION_IDLE);
|
dfu_device_set_action (device, FWUPD_STATUS_IDLE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1587,7 +1587,7 @@ dfu_device_wait_for_replug (DfuDevice *device, guint timeout,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
dfu_device_set_action (device, DFU_ACTION_IDLE);
|
dfu_device_set_action (device, FWUPD_STATUS_IDLE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1662,7 +1662,7 @@ dfu_device_attach (DfuDevice *device, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* inform UI there's going to be a re-attach */
|
/* inform UI there's going to be a re-attach */
|
||||||
dfu_device_set_action (device, DFU_ACTION_ATTACH);
|
dfu_device_set_action (device, FWUPD_STATUS_DEVICE_RESTART);
|
||||||
|
|
||||||
/* handle m-stack DFU bootloaders */
|
/* handle m-stack DFU bootloaders */
|
||||||
if (!priv->done_upload_or_download &&
|
if (!priv->done_upload_or_download &&
|
||||||
@ -1697,7 +1697,7 @@ dfu_device_attach (DfuDevice *device, GError **error)
|
|||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
dfu_device_set_action (device, DFU_ACTION_IDLE);
|
dfu_device_set_action (device, FWUPD_STATUS_IDLE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1706,7 +1706,7 @@ dfu_device_attach (DfuDevice *device, GError **error)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
dfu_device_set_action (device, DFU_ACTION_IDLE);
|
dfu_device_set_action (device, FWUPD_STATUS_IDLE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1718,7 +1718,7 @@ dfu_device_percentage_cb (DfuTarget *target, guint percentage, DfuDevice *device
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dfu_device_action_cb (DfuTarget *target, DfuAction action, DfuDevice *device)
|
dfu_device_action_cb (DfuTarget *target, FwupdStatus action, DfuDevice *device)
|
||||||
{
|
{
|
||||||
dfu_device_set_action (device, action);
|
dfu_device_set_action (device, action);
|
||||||
}
|
}
|
||||||
@ -1846,7 +1846,7 @@ dfu_device_upload (DfuDevice *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
dfu_device_set_action (device, DFU_ACTION_IDLE);
|
dfu_device_set_action (device, FWUPD_STATUS_IDLE);
|
||||||
return g_object_ref (firmware);
|
return g_object_ref (firmware);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2082,7 +2082,7 @@ dfu_device_download (DfuDevice *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
dfu_device_set_action (device, DFU_ACTION_IDLE);
|
dfu_device_set_action (device, FWUPD_STATUS_IDLE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ struct _DfuDeviceClass
|
|||||||
void (*percentage_changed) (DfuDevice *device,
|
void (*percentage_changed) (DfuDevice *device,
|
||||||
guint percentage);
|
guint percentage);
|
||||||
void (*action_changed) (DfuDevice *device,
|
void (*action_changed) (DfuDevice *device,
|
||||||
DfuAction action);
|
FwupdStatus action);
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
/* Padding for future expansion */
|
/* Padding for future expansion */
|
||||||
void (*_dfu_device_reserved1) (void);
|
void (*_dfu_device_reserved1) (void);
|
||||||
|
@ -65,7 +65,7 @@ typedef struct {
|
|||||||
gchar *alt_name_for_display;
|
gchar *alt_name_for_display;
|
||||||
GPtrArray *sectors; /* of DfuSector */
|
GPtrArray *sectors; /* of DfuSector */
|
||||||
guint old_percentage;
|
guint old_percentage;
|
||||||
DfuAction old_action;
|
FwupdStatus old_action;
|
||||||
} DfuTargetPrivate;
|
} DfuTargetPrivate;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -101,7 +101,7 @@ dfu_target_class_init (DfuTargetClass *klass)
|
|||||||
/**
|
/**
|
||||||
* DfuTarget::action-changed:
|
* DfuTarget::action-changed:
|
||||||
* @device: the #DfuTarget instance that emitted the signal
|
* @device: the #DfuTarget instance that emitted the signal
|
||||||
* @action: the new DfuAction
|
* @action: the new FwupdStatus
|
||||||
*
|
*
|
||||||
* The ::action-changed signal is emitted when the high level action changes.
|
* The ::action-changed signal is emitted when the high level action changes.
|
||||||
**/
|
**/
|
||||||
@ -121,7 +121,7 @@ dfu_target_init (DfuTarget *target)
|
|||||||
DfuTargetPrivate *priv = GET_PRIVATE (target);
|
DfuTargetPrivate *priv = GET_PRIVATE (target);
|
||||||
priv->sectors = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
|
priv->sectors = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
|
||||||
priv->old_percentage = G_MAXUINT;
|
priv->old_percentage = G_MAXUINT;
|
||||||
priv->old_action = DFU_ACTION_IDLE;
|
priv->old_action = FWUPD_STATUS_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -900,21 +900,21 @@ dfu_target_upload_chunk (DfuTarget *target, guint8 index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dfu_target_set_action (DfuTarget *target, DfuAction action)
|
dfu_target_set_action (DfuTarget *target, FwupdStatus action)
|
||||||
{
|
{
|
||||||
DfuTargetPrivate *priv = GET_PRIVATE (target);
|
DfuTargetPrivate *priv = GET_PRIVATE (target);
|
||||||
|
|
||||||
/* unchanged */
|
/* unchanged */
|
||||||
if (priv->old_action == action)
|
if (priv->old_action == action)
|
||||||
return;
|
return;
|
||||||
if (priv->old_action != DFU_ACTION_IDLE &&
|
if (priv->old_action != FWUPD_STATUS_IDLE &&
|
||||||
action != DFU_ACTION_IDLE) {
|
action != FWUPD_STATUS_IDLE) {
|
||||||
g_debug ("ignoring action %s as %s already set and not idle",
|
g_debug ("ignoring action %s as %s already set and not idle",
|
||||||
dfu_action_to_string (action),
|
fwupd_status_to_string (action),
|
||||||
dfu_action_to_string (priv->old_action));
|
fwupd_status_to_string (priv->old_action));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g_debug ("setting action %s", dfu_action_to_string (action));
|
g_debug ("setting action %s", fwupd_status_to_string (action));
|
||||||
g_signal_emit (target, signals[SIGNAL_ACTION_CHANGED], 0, action);
|
g_signal_emit (target, signals[SIGNAL_ACTION_CHANGED], 0, action);
|
||||||
priv->old_action = action;
|
priv->old_action = action;
|
||||||
}
|
}
|
||||||
@ -926,7 +926,7 @@ dfu_target_set_percentage_raw (DfuTarget *target, guint percentage)
|
|||||||
if (percentage == priv->old_percentage)
|
if (percentage == priv->old_percentage)
|
||||||
return;
|
return;
|
||||||
g_debug ("setting percentage %u%% of %s",
|
g_debug ("setting percentage %u%% of %s",
|
||||||
percentage, dfu_action_to_string (priv->old_action));
|
percentage, fwupd_status_to_string (priv->old_action));
|
||||||
g_signal_emit (target,
|
g_signal_emit (target,
|
||||||
signals[SIGNAL_PERCENTAGE_CHANGED],
|
signals[SIGNAL_PERCENTAGE_CHANGED],
|
||||||
0, percentage);
|
0, percentage);
|
||||||
@ -1017,7 +1017,7 @@ dfu_target_upload_element_dfuse (DfuTarget *target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* update UI */
|
/* update UI */
|
||||||
dfu_target_set_action (target, DFU_ACTION_READ);
|
dfu_target_set_action (target, FWUPD_STATUS_DEVICE_READ);
|
||||||
|
|
||||||
/* manually set the sector address */
|
/* manually set the sector address */
|
||||||
g_debug ("setting DfuSe address to 0x%04x", (guint) offset);
|
g_debug ("setting DfuSe address to 0x%04x", (guint) offset);
|
||||||
@ -1087,7 +1087,7 @@ dfu_target_upload_element_dfuse (DfuTarget *target,
|
|||||||
|
|
||||||
/* done */
|
/* done */
|
||||||
dfu_target_set_percentage_raw (target, 100);
|
dfu_target_set_percentage_raw (target, 100);
|
||||||
dfu_target_set_action (target, DFU_ACTION_IDLE);
|
dfu_target_set_action (target, FWUPD_STATUS_IDLE);
|
||||||
|
|
||||||
/* create new image */
|
/* create new image */
|
||||||
contents = _g_bytes_array_join (chunks);
|
contents = _g_bytes_array_join (chunks);
|
||||||
@ -1120,7 +1120,7 @@ dfu_target_upload_element_dfu (DfuTarget *target,
|
|||||||
g_autoptr(GPtrArray) chunks = NULL;
|
g_autoptr(GPtrArray) chunks = NULL;
|
||||||
|
|
||||||
/* update UI */
|
/* update UI */
|
||||||
dfu_target_set_action (target, DFU_ACTION_READ);
|
dfu_target_set_action (target, FWUPD_STATUS_DEVICE_READ);
|
||||||
|
|
||||||
/* get all the chunks from the hardware */
|
/* get all the chunks from the hardware */
|
||||||
chunks = g_ptr_array_new_with_free_func ((GDestroyNotify) g_bytes_unref);
|
chunks = g_ptr_array_new_with_free_func ((GDestroyNotify) g_bytes_unref);
|
||||||
@ -1169,7 +1169,7 @@ dfu_target_upload_element_dfu (DfuTarget *target,
|
|||||||
|
|
||||||
/* done */
|
/* done */
|
||||||
dfu_target_set_percentage_raw (target, 100);
|
dfu_target_set_percentage_raw (target, 100);
|
||||||
dfu_target_set_action (target, DFU_ACTION_IDLE);
|
dfu_target_set_action (target, FWUPD_STATUS_IDLE);
|
||||||
|
|
||||||
/* create new image */
|
/* create new image */
|
||||||
contents = _g_bytes_array_join (chunks);
|
contents = _g_bytes_array_join (chunks);
|
||||||
@ -1378,7 +1378,7 @@ dfu_target_download_element_dfu (DfuTarget *target,
|
|||||||
"zero-length firmware");
|
"zero-length firmware");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
dfu_target_set_action (target, DFU_ACTION_WRITE);
|
dfu_target_set_action (target, FWUPD_STATUS_DEVICE_WRITE);
|
||||||
for (guint i = 0; i < nr_chunks + 1; i++) {
|
for (guint i = 0; i < nr_chunks + 1; i++) {
|
||||||
gsize length;
|
gsize length;
|
||||||
guint32 offset;
|
guint32 offset;
|
||||||
@ -1411,7 +1411,7 @@ dfu_target_download_element_dfu (DfuTarget *target,
|
|||||||
|
|
||||||
/* done */
|
/* done */
|
||||||
dfu_target_set_percentage_raw (target, 100);
|
dfu_target_set_percentage_raw (target, 100);
|
||||||
dfu_target_set_action (target, DFU_ACTION_IDLE);
|
dfu_target_set_action (target, FWUPD_STATUS_IDLE);
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1486,7 +1486,7 @@ dfu_target_download_element_dfuse (DfuTarget *target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 2nd pass: actually erase sectors */
|
/* 2nd pass: actually erase sectors */
|
||||||
dfu_target_set_action (target, DFU_ACTION_ERASE);
|
dfu_target_set_action (target, FWUPD_STATUS_DEVICE_ERASE);
|
||||||
for (guint i = 0; i < sectors_array->len; i++) {
|
for (guint i = 0; i < sectors_array->len; i++) {
|
||||||
sector = g_ptr_array_index (sectors_array, i);
|
sector = g_ptr_array_index (sectors_array, i);
|
||||||
g_debug ("erasing sector at 0x%04x",
|
g_debug ("erasing sector at 0x%04x",
|
||||||
@ -1499,10 +1499,10 @@ dfu_target_download_element_dfuse (DfuTarget *target,
|
|||||||
dfu_target_set_percentage (target, i + 1, sectors_array->len);
|
dfu_target_set_percentage (target, i + 1, sectors_array->len);
|
||||||
}
|
}
|
||||||
dfu_target_set_percentage_raw (target, 100);
|
dfu_target_set_percentage_raw (target, 100);
|
||||||
dfu_target_set_action (target, DFU_ACTION_IDLE);
|
dfu_target_set_action (target, FWUPD_STATUS_IDLE);
|
||||||
|
|
||||||
/* 3rd pass: write data */
|
/* 3rd pass: write data */
|
||||||
dfu_target_set_action (target, DFU_ACTION_WRITE);
|
dfu_target_set_action (target, FWUPD_STATUS_DEVICE_WRITE);
|
||||||
for (guint i = 0; i < nr_chunks; i++) {
|
for (guint i = 0; i < nr_chunks; i++) {
|
||||||
gsize length;
|
gsize length;
|
||||||
guint32 offset;
|
guint32 offset;
|
||||||
@ -1555,7 +1555,7 @@ dfu_target_download_element_dfuse (DfuTarget *target,
|
|||||||
|
|
||||||
/* done */
|
/* done */
|
||||||
dfu_target_set_percentage_raw (target, 100);
|
dfu_target_set_percentage_raw (target, 100);
|
||||||
dfu_target_set_action (target, DFU_ACTION_IDLE);
|
dfu_target_set_action (target, FWUPD_STATUS_IDLE);
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1592,7 +1592,7 @@ dfu_target_download_element (DfuTarget *target,
|
|||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
GBytes *bytes_tmp;
|
GBytes *bytes_tmp;
|
||||||
g_autoptr(DfuElement) element_tmp = NULL;
|
g_autoptr(DfuElement) element_tmp = NULL;
|
||||||
dfu_target_set_action (target, DFU_ACTION_VERIFY);
|
dfu_target_set_action (target, FWUPD_STATUS_DEVICE_VERIFY);
|
||||||
bytes = dfu_element_get_contents (element);
|
bytes = dfu_element_get_contents (element);
|
||||||
element_tmp = dfu_target_upload_element (target,
|
element_tmp = dfu_target_upload_element (target,
|
||||||
dfu_element_get_address (element),
|
dfu_element_get_address (element),
|
||||||
@ -1613,7 +1613,7 @@ dfu_target_download_element (DfuTarget *target,
|
|||||||
bytes_cmp_str);
|
bytes_cmp_str);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
dfu_target_set_action (target, DFU_ACTION_IDLE);
|
dfu_target_set_action (target, FWUPD_STATUS_IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include "dfu-common.h"
|
#include "dfu-common.h"
|
||||||
#include "dfu-image.h"
|
#include "dfu-image.h"
|
||||||
|
|
||||||
|
#include "fwupd-enums.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define DFU_TYPE_TARGET (dfu_target_get_type ())
|
#define DFU_TYPE_TARGET (dfu_target_get_type ())
|
||||||
@ -40,7 +42,7 @@ struct _DfuTargetClass
|
|||||||
void (*percentage_changed) (DfuTarget *target,
|
void (*percentage_changed) (DfuTarget *target,
|
||||||
guint percentage);
|
guint percentage);
|
||||||
void (*action_changed) (DfuTarget *target,
|
void (*action_changed) (DfuTarget *target,
|
||||||
DfuAction action);
|
FwupdStatus action);
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
/* Padding for future expansion */
|
/* Padding for future expansion */
|
||||||
void (*_dfu_target_reserved1) (void);
|
void (*_dfu_target_reserved1) (void);
|
||||||
|
@ -1213,50 +1213,44 @@ fu_tool_percentage_changed_cb (DfuDevice *device,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
fu_tool_action_changed_cb (DfuDevice *device,
|
fu_tool_action_changed_cb (DfuDevice *device,
|
||||||
DfuAction action,
|
FwupdStatus action,
|
||||||
DfuToolPrivate *priv)
|
DfuToolPrivate *priv)
|
||||||
{
|
{
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case DFU_ACTION_IDLE:
|
case FWUPD_STATUS_IDLE:
|
||||||
dfu_progress_bar_set_percentage (priv->progress_bar, 100);
|
dfu_progress_bar_set_percentage (priv->progress_bar, 100);
|
||||||
dfu_progress_bar_end (priv->progress_bar);
|
dfu_progress_bar_end (priv->progress_bar);
|
||||||
break;
|
break;
|
||||||
case DFU_ACTION_READ:
|
case FWUPD_STATUS_DEVICE_READ:
|
||||||
dfu_progress_bar_start (priv->progress_bar,
|
dfu_progress_bar_start (priv->progress_bar,
|
||||||
/* TRANSLATORS: read from device to host */
|
/* TRANSLATORS: read from device to host */
|
||||||
_("Reading"));
|
_("Reading"));
|
||||||
dfu_progress_bar_set_percentage (priv->progress_bar, 0);
|
dfu_progress_bar_set_percentage (priv->progress_bar, 0);
|
||||||
break;
|
break;
|
||||||
case DFU_ACTION_WRITE:
|
case FWUPD_STATUS_DEVICE_WRITE:
|
||||||
dfu_progress_bar_start (priv->progress_bar,
|
dfu_progress_bar_start (priv->progress_bar,
|
||||||
/* TRANSLATORS: write from host to device */
|
/* TRANSLATORS: write from host to device */
|
||||||
_("Writing"));
|
_("Writing"));
|
||||||
dfu_progress_bar_set_percentage (priv->progress_bar, 0);
|
dfu_progress_bar_set_percentage (priv->progress_bar, 0);
|
||||||
break;
|
break;
|
||||||
case DFU_ACTION_VERIFY:
|
case FWUPD_STATUS_DEVICE_VERIFY:
|
||||||
dfu_progress_bar_start (priv->progress_bar,
|
dfu_progress_bar_start (priv->progress_bar,
|
||||||
/* TRANSLATORS: read from device to host */
|
/* TRANSLATORS: read from device to host */
|
||||||
_("Verifying"));
|
_("Verifying"));
|
||||||
dfu_progress_bar_set_percentage (priv->progress_bar, 0);
|
dfu_progress_bar_set_percentage (priv->progress_bar, 0);
|
||||||
break;
|
break;
|
||||||
case DFU_ACTION_ERASE:
|
case FWUPD_STATUS_DEVICE_ERASE:
|
||||||
dfu_progress_bar_start (priv->progress_bar,
|
dfu_progress_bar_start (priv->progress_bar,
|
||||||
/* TRANSLATORS: read from device to host */
|
/* TRANSLATORS: read from device to host */
|
||||||
_("Erasing"));
|
_("Erasing"));
|
||||||
dfu_progress_bar_set_percentage (priv->progress_bar, 0);
|
dfu_progress_bar_set_percentage (priv->progress_bar, 0);
|
||||||
break;
|
break;
|
||||||
case DFU_ACTION_DETACH:
|
case FWUPD_STATUS_DEVICE_RESTART:
|
||||||
dfu_progress_bar_start (priv->progress_bar,
|
dfu_progress_bar_start (priv->progress_bar,
|
||||||
/* TRANSLATORS: waiting for device */
|
/* TRANSLATORS: waiting for device */
|
||||||
_("Detaching"));
|
_("Detaching"));
|
||||||
dfu_progress_bar_set_percentage (priv->progress_bar, -1);
|
dfu_progress_bar_set_percentage (priv->progress_bar, -1);
|
||||||
break;
|
break;
|
||||||
case DFU_ACTION_ATTACH:
|
|
||||||
dfu_progress_bar_start (priv->progress_bar,
|
|
||||||
/* TRANSLATORS: waiting for device */
|
|
||||||
_("Attaching"));
|
|
||||||
dfu_progress_bar_set_percentage (priv->progress_bar, -1);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -63,10 +63,18 @@ fu_progressbar_status_to_string (FwupdStatus status)
|
|||||||
/* TRANSLATORS: restarting the device to pick up new F/W */
|
/* TRANSLATORS: restarting the device to pick up new F/W */
|
||||||
return _("Restarting device…");
|
return _("Restarting device…");
|
||||||
break;
|
break;
|
||||||
|
case FWUPD_STATUS_DEVICE_READ:
|
||||||
|
/* TRANSLATORS: reading from the flash chips */
|
||||||
|
return _("Reading…");
|
||||||
|
break;
|
||||||
case FWUPD_STATUS_DEVICE_WRITE:
|
case FWUPD_STATUS_DEVICE_WRITE:
|
||||||
/* TRANSLATORS: writing to the flash chips */
|
/* TRANSLATORS: writing to the flash chips */
|
||||||
return _("Writing…");
|
return _("Writing…");
|
||||||
break;
|
break;
|
||||||
|
case FWUPD_STATUS_DEVICE_ERASE:
|
||||||
|
/* TRANSLATORS: erasing contents of the flash chips */
|
||||||
|
return _("Erasing…");
|
||||||
|
break;
|
||||||
case FWUPD_STATUS_DEVICE_VERIFY:
|
case FWUPD_STATUS_DEVICE_VERIFY:
|
||||||
/* TRANSLATORS: verifying we wrote the firmware correctly */
|
/* TRANSLATORS: verifying we wrote the firmware correctly */
|
||||||
return _("Verifying…");
|
return _("Verifying…");
|
||||||
|
Loading…
Reference in New Issue
Block a user