mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-28 07:57:08 +00:00
libdfu: Call the progress callback when doing detach
This allows the UI to show something sane, and also allows fwupd to start any timeout for ignoring detach:replug.
This commit is contained in:
parent
a11d6efc58
commit
f048fbc703
@ -638,6 +638,14 @@ dfu_device_upload (DfuDevice *device,
|
||||
|
||||
/* APP -> DFU */
|
||||
if (flags & DFU_TARGET_TRANSFER_FLAG_DETACH) {
|
||||
|
||||
/* inform UI there's going to be a detach:attach */
|
||||
if (progress_cb != NULL) {
|
||||
progress_cb (DFU_STATE_APP_DETACH, 0, 0,
|
||||
progress_cb_data);
|
||||
}
|
||||
|
||||
/* detach and USB reset */
|
||||
target_default = dfu_device_get_target_default (device, error);
|
||||
if (target_default == NULL)
|
||||
return NULL;
|
||||
@ -685,6 +693,14 @@ dfu_device_upload (DfuDevice *device,
|
||||
/* boot to runtime */
|
||||
if (flags & DFU_TARGET_TRANSFER_FLAG_BOOT_RUNTIME) {
|
||||
g_debug ("booting to runtime");
|
||||
|
||||
/* inform UI there's going to be a detach:attach */
|
||||
if (progress_cb != NULL) {
|
||||
progress_cb (DFU_STATE_APP_DETACH, 0, 0,
|
||||
progress_cb_data);
|
||||
}
|
||||
|
||||
/* DFU -> APP */
|
||||
if (!dfu_device_wait_for_replug (device, 2000, cancellable, error))
|
||||
return NULL;
|
||||
}
|
||||
@ -767,6 +783,14 @@ dfu_device_download (DfuDevice *device,
|
||||
|
||||
/* APP -> DFU */
|
||||
if (flags & DFU_TARGET_TRANSFER_FLAG_DETACH) {
|
||||
|
||||
/* inform UI there's going to be a detach:attach */
|
||||
if (progress_cb != NULL) {
|
||||
progress_cb (DFU_STATE_APP_DETACH, 0, 0,
|
||||
progress_cb_data);
|
||||
}
|
||||
|
||||
/* detach and USB reset */
|
||||
target_default = dfu_device_get_target_default (device, error);
|
||||
if (target_default == NULL)
|
||||
return FALSE;
|
||||
@ -823,6 +847,14 @@ dfu_device_download (DfuDevice *device,
|
||||
/* boot to runtime */
|
||||
if (flags & DFU_TARGET_TRANSFER_FLAG_BOOT_RUNTIME) {
|
||||
g_debug ("booting to runtime to set auto-boot");
|
||||
|
||||
/* inform UI there's going to be a detach:attach */
|
||||
if (progress_cb != NULL) {
|
||||
progress_cb (DFU_STATE_APP_DETACH, 0, 0,
|
||||
progress_cb_data);
|
||||
}
|
||||
|
||||
/* DFU -> APP */
|
||||
if (!dfu_device_wait_for_replug (device, 2000, cancellable, error))
|
||||
return FALSE;
|
||||
target_default = dfu_device_get_target_default (device, error);
|
||||
|
@ -871,16 +871,28 @@ fu_tool_transfer_progress_cb (DfuState state, goffset current,
|
||||
/* changed state */
|
||||
if (state != helper->last_state) {
|
||||
const gchar *title = NULL;
|
||||
|
||||
/* detach was left hanging... */
|
||||
if (helper->last_state == DFU_STATE_APP_DETACH) {
|
||||
/* TRANSLATORS: when an action has completed */
|
||||
g_print ("%s\n", _("OK"));
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case DFU_STATE_APP_DETACH:
|
||||
/* TRANSLATORS: when moving from APP to DFU mode */
|
||||
title = _("Detatching");
|
||||
break;
|
||||
case DFU_STATE_DFU_DNLOAD_IDLE:
|
||||
/* TRANSLATORS: this is when moving from host to device */
|
||||
/* TRANSLATORS: when copying from host to device */
|
||||
title = _("Downloading");
|
||||
break;
|
||||
case DFU_STATE_DFU_UPLOAD_IDLE:
|
||||
/* TRANSLATORS: this is when moving from device to host */
|
||||
/* TRANSLATORS: when copying from device to host */
|
||||
title = _("Verifying");
|
||||
break;
|
||||
default:
|
||||
g_debug ("ignoring %s", dfu_state_to_string (state));
|
||||
break;
|
||||
}
|
||||
/* show title and then pad */
|
||||
@ -894,6 +906,10 @@ fu_tool_transfer_progress_cb (DfuState state, goffset current,
|
||||
helper->last_state = state;
|
||||
}
|
||||
|
||||
/* not known yet */
|
||||
if (total == 0)
|
||||
return;
|
||||
|
||||
/* add any sections */
|
||||
marks_now = current * helper->marks_total / total;
|
||||
for (i = helper->marks_shown; i < marks_now; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user