diff --git a/libdfu/dfu-device.c b/libdfu/dfu-device.c index 0c2b3340e..26365243f 100644 --- a/libdfu/dfu-device.c +++ b/libdfu/dfu-device.c @@ -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); diff --git a/libdfu/dfu-tool.c b/libdfu/dfu-tool.c index 69c4c1420..53d29df60 100644 --- a/libdfu/dfu-tool.c +++ b/libdfu/dfu-tool.c @@ -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++)