mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-05-03 06:46:35 +08:00
Clean up data op error reporting, add retry option.
This commit is contained in:
parent
089f7ca782
commit
8d4748b526
@ -83,20 +83,9 @@ static Result action_delete_restore(void* data, u32 index) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool action_delete_error(void* data, u32 index, Result res) {
|
static bool action_delete_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||||
delete_data* deleteData = (delete_data*) data;
|
*errorView = error_display_res(data, action_delete_draw_top, res, "Failed to delete content.");
|
||||||
|
return true;
|
||||||
if(res == R_FBI_CANCELLED) {
|
|
||||||
prompt_display_notify("Failure", "Delete cancelled.", COLOR_TEXT, NULL, NULL, NULL);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
ui_view* view = error_display_res(data, action_delete_draw_top, res, "Failed to delete content.");
|
|
||||||
if(view != NULL) {
|
|
||||||
svcWaitSynchronization(view->active, U64_MAX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return index < deleteData->deleteInfo.total - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_delete_free_data(delete_data* data) {
|
static void action_delete_free_data(delete_data* data) {
|
||||||
|
@ -67,20 +67,9 @@ static Result action_delete_pending_titles_restore(void* data, u32 index) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool action_delete_pending_titles_error(void* data, u32 index, Result res) {
|
static bool action_delete_pending_titles_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||||
delete_pending_titles_data* deleteData = (delete_pending_titles_data*) data;
|
*errorView = error_display_res(data, action_delete_pending_titles_draw_top, res, "Failed to delete pending title.");
|
||||||
|
return true;
|
||||||
if(res == R_FBI_CANCELLED) {
|
|
||||||
prompt_display_notify("Failure", "Delete cancelled.", COLOR_TEXT, NULL, NULL, NULL);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
ui_view* view = error_display_res(data, action_delete_pending_titles_draw_top, res, "Failed to delete pending title.");
|
|
||||||
if(view != NULL) {
|
|
||||||
svcWaitSynchronization(view->active, U64_MAX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return index < deleteData->deleteInfo.total - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_delete_pending_titles_free_data(delete_pending_titles_data* data) {
|
static void action_delete_pending_titles_free_data(delete_pending_titles_data* data) {
|
||||||
|
@ -63,20 +63,9 @@ static Result action_delete_tickets_restore(void* data, u32 index) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool action_delete_tickets_error(void* data, u32 index, Result res) {
|
static bool action_delete_tickets_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||||
delete_tickets_data* deleteData = (delete_tickets_data*) data;
|
*errorView = error_display_res(data, action_delete_tickets_draw_top, res, "Failed to delete ticket(s).");
|
||||||
|
return true;
|
||||||
if(res == R_FBI_CANCELLED) {
|
|
||||||
prompt_display_notify("Failure", "Delete cancelled.", COLOR_TEXT, NULL, NULL, NULL);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
ui_view* view = error_display_res(data, action_delete_tickets_draw_top, res, "Failed to delete ticket(s).");
|
|
||||||
if(view != NULL) {
|
|
||||||
svcWaitSynchronization(view->active, U64_MAX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return index < deleteData->deleteInfo.total - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_delete_tickets_free_data(delete_tickets_data* data) {
|
static void action_delete_tickets_free_data(delete_tickets_data* data) {
|
||||||
|
@ -89,16 +89,9 @@ static Result action_erase_twl_save_restore(void* data, u32 index) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool action_erase_twl_save_error(void* data, u32 index, Result res) {
|
static bool action_erase_twl_save_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||||
erase_twl_save_data* eraseData = (erase_twl_save_data*) data;
|
*errorView = error_display_res(((erase_twl_save_data*) data)->title, ui_draw_title_info, res, "Failed to erase save.");
|
||||||
|
return true;
|
||||||
if(res == R_FBI_CANCELLED) {
|
|
||||||
prompt_display_notify("Failure", "Erase cancelled.", COLOR_TEXT, eraseData->title, ui_draw_title_info, NULL);
|
|
||||||
} else {
|
|
||||||
error_display_res(eraseData->title, ui_draw_title_info, res, "Failed to erase save.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_erase_twl_save_update(ui_view* view, void* data, float* progress, char* text) {
|
static void action_erase_twl_save_update(ui_view* view, void* data, float* progress, char* text) {
|
||||||
|
@ -111,16 +111,9 @@ static Result action_export_twl_save_restore(void* data, u32 index) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool action_export_twl_save_error(void* data, u32 index, Result res) {
|
static bool action_export_twl_save_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||||
export_twl_save_data* exportData = (export_twl_save_data*) data;
|
*errorView = error_display_res(((export_twl_save_data*) data)->title, ui_draw_title_info, res, "Failed to export save.");
|
||||||
|
return true;
|
||||||
if(res == R_FBI_CANCELLED) {
|
|
||||||
prompt_display_notify("Failure", "Export cancelled.", COLOR_TEXT, exportData->title, ui_draw_title_info, NULL);
|
|
||||||
} else {
|
|
||||||
error_display_res(exportData->title, ui_draw_title_info, res, "Failed to export save.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_export_twl_save_update(ui_view* view, void* data, float* progress, char* text) {
|
static void action_export_twl_save_update(ui_view* view, void* data, float* progress, char* text) {
|
||||||
|
@ -97,16 +97,9 @@ static Result action_import_twl_save_restore(void* data, u32 index) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool action_import_twl_save_error(void* data, u32 index, Result res) {
|
static bool action_import_twl_save_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||||
import_twl_save_data* importData = (import_twl_save_data*) data;
|
*errorView = error_display_res(((import_twl_save_data*) data)->title, ui_draw_title_info, res, "Failed to import save.");
|
||||||
|
return true;
|
||||||
if(res == R_FBI_CANCELLED) {
|
|
||||||
prompt_display_notify("Failure", "Import cancelled.", COLOR_TEXT, importData->title, ui_draw_title_info, NULL);
|
|
||||||
} else {
|
|
||||||
error_display_res(importData->title, ui_draw_title_info, res, "Failed to import save.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_import_twl_save_update(ui_view* view, void* data, float* progress, char* text) {
|
static void action_import_twl_save_update(ui_view* view, void* data, float* progress, char* text) {
|
||||||
|
@ -173,15 +173,14 @@ static Result action_install_cdn_restore(void* data, u32 index) {
|
|||||||
return AM_InstallTitleResume(util_get_title_destination(installData->ticket->titleId), installData->ticket->titleId);
|
return AM_InstallTitleResume(util_get_title_destination(installData->ticket->titleId), installData->ticket->titleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool action_install_cdn_error(void* data, u32 index, Result res) {
|
bool action_install_cdn_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||||
install_cdn_data* installData = (install_cdn_data*) data;
|
install_cdn_data* installData = (install_cdn_data*) data;
|
||||||
|
|
||||||
if(res == R_FBI_CANCELLED) {
|
const char* itemType = index == 0 ? "TMD" : "content";
|
||||||
prompt_display_notify("Failure", "Install cancelled.", COLOR_TEXT, installData->ticket, ui_draw_ticket_info, NULL);
|
if(res == R_FBI_HTTP_RESPONSE_CODE) {
|
||||||
} else if(res == R_FBI_HTTP_RESPONSE_CODE) {
|
*errorView = error_display(installData->ticket, ui_draw_ticket_info, "Failed to install %s from CDN.\nHTTP server returned response code %d", itemType, installData->responseCode);
|
||||||
error_display(installData->ticket, ui_draw_ticket_info, "Failed to install CDN title.\nHTTP server returned response code %d", installData->responseCode);
|
|
||||||
} else {
|
} else {
|
||||||
error_display_res(installData->ticket, ui_draw_ticket_info, res, "Failed to install CDN title.");
|
*errorView = error_display_res(installData->ticket, ui_draw_ticket_info, res, "Failed to install %s from CDN.", itemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -193,20 +193,9 @@ static Result action_install_cias_restore(void* data, u32 index) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool action_install_cias_error(void* data, u32 index, Result res) {
|
bool action_install_cias_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||||
install_cias_data* installData = (install_cias_data*) data;
|
*errorView = error_display_res(data, action_install_cias_draw_top, res, "Failed to install CIA file.");
|
||||||
|
return true;
|
||||||
if(res == R_FBI_CANCELLED) {
|
|
||||||
prompt_display_notify("Failure", "Install cancelled.", COLOR_TEXT, NULL, NULL, NULL);
|
|
||||||
return false;
|
|
||||||
} else if(res != R_FBI_WRONG_SYSTEM) {
|
|
||||||
ui_view* view = error_display_res(data, action_install_cias_draw_top, res, "Failed to install CIA file.");
|
|
||||||
if(view != NULL) {
|
|
||||||
svcWaitSynchronization(view->active, U64_MAX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return index < installData->installInfo.total - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_install_cias_free_data(install_cias_data* data) {
|
static void action_install_cias_free_data(install_cias_data* data) {
|
||||||
|
@ -156,20 +156,9 @@ static Result action_install_tickets_restore(void* data, u32 index) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool action_install_tickets_error(void* data, u32 index, Result res) {
|
static bool action_install_tickets_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||||
install_tickets_data* installData = (install_tickets_data*) data;
|
*errorView = error_display_res(data, action_install_tickets_draw_top, res, "Failed to install ticket.");
|
||||||
|
return true;
|
||||||
if(res == R_FBI_CANCELLED) {
|
|
||||||
prompt_display_notify("Failure", "Install cancelled.", COLOR_TEXT, NULL, NULL, NULL);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
ui_view* view = error_display_res(data, action_install_tickets_draw_top, res, "Failed to install ticket.");
|
|
||||||
if(view != NULL) {
|
|
||||||
svcWaitSynchronization(view->active, U64_MAX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return index < installData->installInfo.total - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_install_tickets_free_data(install_tickets_data* data) {
|
static void action_install_tickets_free_data(install_tickets_data* data) {
|
||||||
|
@ -324,37 +324,27 @@ static Result action_install_url_restore(void* data, u32 index) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool action_install_url_error(void* data, u32 index, Result res) {
|
static bool action_install_url_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||||
install_url_data* installData = (install_url_data*) data;
|
install_url_data* installData = (install_url_data*) data;
|
||||||
|
|
||||||
if(res == R_FBI_CANCELLED) {
|
if(res != R_FBI_WRONG_SYSTEM) {
|
||||||
prompt_display_notify("Failure", "Install cancelled.", COLOR_TEXT, NULL, NULL, NULL);
|
|
||||||
return false;
|
|
||||||
} else if(res != R_FBI_WRONG_SYSTEM) {
|
|
||||||
char* url = installData->urls[index];
|
char* url = installData->urls[index];
|
||||||
|
|
||||||
ui_view* view = NULL;
|
|
||||||
|
|
||||||
if(res == R_FBI_HTTP_RESPONSE_CODE) {
|
if(res == R_FBI_HTTP_RESPONSE_CODE) {
|
||||||
if(strlen(url) > 38) {
|
if(strlen(url) > 38) {
|
||||||
view = error_display(data, action_install_url_draw_top, "Failed to install from URL.\n%.35s...\nHTTP server returned response code %d", url, installData->responseCode);
|
*errorView = error_display(data, action_install_url_draw_top, "Failed to install from URL.\n%.35s...\nHTTP server returned response code %d", url, installData->responseCode);
|
||||||
} else {
|
} else {
|
||||||
view = error_display(data, action_install_url_draw_top, "Failed to install from URL.\n%.38s\nHTTP server returned response code %d", url, installData->responseCode);
|
*errorView = error_display(data, action_install_url_draw_top, "Failed to install from URL.\n%.38s\nHTTP server returned response code %d", url, installData->responseCode);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(strlen(url) > 38) {
|
if(strlen(url) > 38) {
|
||||||
view = error_display_res(data, action_install_url_draw_top, res, "Failed to install from URL.\n%.35s...", url);
|
*errorView = error_display_res(data, action_install_url_draw_top, res, "Failed to install from URL.\n%.35s...", url);
|
||||||
} else {
|
} else {
|
||||||
view = error_display_res(data, action_install_url_draw_top, res, "Failed to install from URL.\n%.38s", url);
|
*errorView = error_display_res(data, action_install_url_draw_top, res, "Failed to install from URL.\n%.38s", url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(view != NULL) {
|
|
||||||
svcWaitSynchronization(view->active, U64_MAX);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return index < installData->installInfo.total - 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_install_url_install_update(ui_view* view, void* data, float* progress, char* text) {
|
static void action_install_url_install_update(ui_view* view, void* data, float* progress, char* text) {
|
||||||
|
@ -225,20 +225,9 @@ static Result action_paste_contents_restore(void* data, u32 index) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool action_paste_contents_error(void* data, u32 index, Result res) {
|
static bool action_paste_contents_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||||
paste_contents_data* pasteData = (paste_contents_data*) data;
|
*errorView = error_display_res(data, action_paste_contents_draw_top, res, "Failed to paste content.");
|
||||||
|
return true;
|
||||||
if(res == R_FBI_CANCELLED) {
|
|
||||||
prompt_display_notify("Failure", "Paste cancelled.", COLOR_TEXT, NULL, NULL, NULL);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
ui_view* view = error_display_res(data, action_paste_contents_draw_top, res, "Failed to paste content.");
|
|
||||||
if(view != NULL) {
|
|
||||||
svcWaitSynchronization(view->active, U64_MAX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return index < pasteData->pasteInfo.total - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void action_paste_contents_free_data(paste_contents_data* data) {
|
static void action_paste_contents_free_data(paste_contents_data* data) {
|
||||||
|
@ -91,14 +91,9 @@ static Result dumpnand_restore(void* data, u32 index) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dumpnand_error(void* data, u32 index, Result res) {
|
static bool dumpnand_error(void* data, u32 index, Result res, ui_view** errorView) {
|
||||||
if(res == R_FBI_CANCELLED) {
|
*errorView = error_display_res(NULL, NULL, res, "Failed to dump NAND.");
|
||||||
prompt_display_notify("Failure", "Dump cancelled.", COLOR_TEXT, NULL, NULL, NULL);
|
return true;
|
||||||
} else {
|
|
||||||
error_display_res(NULL, NULL, res, "Failed to dump NAND.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dumpnand_update(ui_view* view, void* data, float* progress, char* text) {
|
static void dumpnand_update(ui_view* view, void* data, float* progress, char* text) {
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "../../error.h"
|
#include "../../error.h"
|
||||||
|
#include "../../prompt.h"
|
||||||
|
#include "../../ui.h"
|
||||||
|
#include "../../../core/screen.h"
|
||||||
|
|
||||||
static Result task_data_op_check_running(data_op_data* data, u32 index, u32* srcHandle, u32* dstHandle) {
|
static Result task_data_op_check_running(data_op_data* data, u32 index, u32* srcHandle, u32* dstHandle) {
|
||||||
Result res = 0;
|
Result res = 0;
|
||||||
@ -146,6 +149,10 @@ static Result task_data_op_delete(data_op_data* data, u32 index) {
|
|||||||
return data->delete(data->data, index);
|
return data->delete(data->data, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void task_data_op_retry_onresponse(ui_view* view, void* data, u32 response) {
|
||||||
|
((data_op_data*) data)->retryResponse = response == PROMPT_YES;
|
||||||
|
}
|
||||||
|
|
||||||
static void task_data_op_thread(void* arg) {
|
static void task_data_op_thread(void* arg) {
|
||||||
data_op_data* data = (data_op_data*) arg;
|
data_op_data* data = (data_op_data*) arg;
|
||||||
|
|
||||||
@ -167,8 +174,29 @@ static void task_data_op_thread(void* arg) {
|
|||||||
|
|
||||||
data->result = res;
|
data->result = res;
|
||||||
|
|
||||||
if(R_FAILED(res) && !data->error(data->data, data->processed, res)) {
|
if(R_FAILED(res)) {
|
||||||
break;
|
if(res != R_FBI_CANCELLED) {
|
||||||
|
ui_view* errorView = NULL;
|
||||||
|
bool proceed = data->error(data->data, data->processed, res, &errorView);
|
||||||
|
|
||||||
|
if(errorView != NULL) {
|
||||||
|
svcWaitSynchronization(errorView->active, U64_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_view* retryView = prompt_display_yes_no("Confirmation", "Retry?", COLOR_TEXT, data, NULL, task_data_op_retry_onresponse);
|
||||||
|
if(retryView != NULL) {
|
||||||
|
svcWaitSynchronization(retryView->active, U64_MAX);
|
||||||
|
|
||||||
|
if(data->retryResponse) {
|
||||||
|
data->processed--;
|
||||||
|
} else if(!proceed) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prompt_display_notify("Failure", "Operation cancelled.", COLOR_TEXT, NULL, NULL, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
typedef struct linked_list_s linked_list;
|
typedef struct linked_list_s linked_list;
|
||||||
typedef struct list_item_s list_item;
|
typedef struct list_item_s list_item;
|
||||||
|
typedef struct ui_view_s ui_view;
|
||||||
|
|
||||||
typedef struct meta_info_s {
|
typedef struct meta_info_s {
|
||||||
char shortDescription[0x100];
|
char shortDescription[0x100];
|
||||||
@ -147,12 +148,15 @@ typedef struct data_op_data_s {
|
|||||||
Result (*restore)(void* data, u32 index);
|
Result (*restore)(void* data, u32 index);
|
||||||
|
|
||||||
// Errors
|
// Errors
|
||||||
bool (*error)(void* data, u32 index, Result res);
|
bool (*error)(void* data, u32 index, Result res, ui_view** errorView);
|
||||||
|
|
||||||
// General
|
// General
|
||||||
volatile bool finished;
|
volatile bool finished;
|
||||||
Result result;
|
Result result;
|
||||||
Handle cancelEvent;
|
Handle cancelEvent;
|
||||||
|
|
||||||
|
// Internal
|
||||||
|
volatile bool retryResponse;
|
||||||
} data_op_data;
|
} data_op_data;
|
||||||
|
|
||||||
typedef struct populate_ext_save_data_data_s {
|
typedef struct populate_ext_save_data_data_s {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user