diff --git a/source/ui/error.c b/source/ui/error.c index f26e473..057caa6 100644 --- a/source/ui/error.c +++ b/source/ui/error.c @@ -564,7 +564,6 @@ static const char* description_to_string(Result res) { typedef struct { char fullText[4096]; void* data; - volatile bool* dismissed; void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2); } error_data; @@ -577,24 +576,17 @@ static void error_draw_top(ui_view* view, void* data, float x1, float y1, float } static void error_onresponse(ui_view* view, void* data, bool response) { - error_data* errorData = (error_data*) data; - - if(errorData->dismissed != NULL) { - *errorData->dismissed = true; - } - free(data); } -void error_display(volatile bool* dismissed, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), const char* text, ...) { +ui_view* error_display(void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), const char* text, ...) { error_data* errorData = (error_data*) calloc(1, sizeof(error_data)); if(errorData == NULL) { // No use trying to spawn another if we're out of memory. - return; + return NULL; } errorData->data = data; - errorData->dismissed = dismissed; errorData->drawTop = drawTop; va_list list; @@ -602,18 +594,17 @@ void error_display(volatile bool* dismissed, void* data, void (*drawTop)(ui_view vsnprintf(errorData->fullText, 4096, text, list); va_end(list); - prompt_display("Error", errorData->fullText, COLOR_TEXT, false, errorData, error_draw_top, error_onresponse); + return prompt_display("Error", errorData->fullText, COLOR_TEXT, false, errorData, error_draw_top, error_onresponse); } -void error_display_res(volatile bool* dismissed, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), Result result, const char* text, ...) { +ui_view* error_display_res(void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), Result result, const char* text, ...) { error_data* errorData = (error_data*) calloc(1, sizeof(error_data)); if(errorData == NULL) { // No use trying to spawn another if we're out of memory. - return; + return NULL; } errorData->data = data; - errorData->dismissed = dismissed; errorData->drawTop = drawTop; char textBuf[1024]; @@ -628,18 +619,17 @@ void error_display_res(volatile bool* dismissed, void* data, void (*drawTop)(ui_ int description = R_DESCRIPTION(result); snprintf(errorData->fullText, 4096, "%s\nResult code: 0x%08lX\nLevel: %s (%d)\nSummary: %s (%d)\nModule: %s (%d)\nDesc: %s (%d)", textBuf, result, level_to_string(result), level, summary_to_string(result), summary, module_to_string(result), module, description_to_string(result), description); - prompt_display("Error", errorData->fullText, COLOR_TEXT, false, errorData, error_draw_top, error_onresponse); + return prompt_display("Error", errorData->fullText, COLOR_TEXT, false, errorData, error_draw_top, error_onresponse); } -void error_display_errno(volatile bool* dismissed, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), int err, const char* text, ...) { +ui_view* error_display_errno(void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), int err, const char* text, ...) { error_data* errorData = (error_data*) calloc(1, sizeof(error_data)); if(errorData == NULL) { // No use trying to spawn another if we're out of memory. - return; + return NULL; } errorData->data = data; - errorData->dismissed = dismissed; errorData->drawTop = drawTop; char textBuf[1024]; @@ -654,5 +644,5 @@ void error_display_errno(volatile bool* dismissed, void* data, void (*drawTop)(u snprintf(errorData->fullText, 4096, "%s\nI/O Error: %s (%d)", textBuf, strerror(err), err); - prompt_display("Error", errorData->fullText, COLOR_TEXT, false, errorData, error_draw_top, error_onresponse); + return prompt_display("Error", errorData->fullText, COLOR_TEXT, false, errorData, error_draw_top, error_onresponse); } \ No newline at end of file diff --git a/source/ui/error.h b/source/ui/error.h index b3d738c..d64d8be 100644 --- a/source/ui/error.h +++ b/source/ui/error.h @@ -15,6 +15,6 @@ typedef struct ui_view_s ui_view; -void error_display(volatile bool* dismissed, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), const char* text, ...); -void error_display_res(volatile bool* dismissed, void* data, void (* drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), Result result, const char* text, ...); -void error_display_errno(volatile bool* dismissed, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), int err, const char* text, ...); \ No newline at end of file +ui_view* error_display(void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), const char* text, ...); +ui_view* error_display_res(void* data, void (* drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), Result result, const char* text, ...); +ui_view* error_display_errno(void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), int err, const char* text, ...); \ No newline at end of file diff --git a/source/ui/info.c b/source/ui/info.c index 1d6b1f4..004c78e 100644 --- a/source/ui/info.c +++ b/source/ui/info.c @@ -67,13 +67,13 @@ static void info_draw_bottom(ui_view* view, void* data, float x1, float y1, floa screen_draw_string(infoData->text, textX, textY, 0.5f, 0.5f, COLOR_TEXT, true); } -void info_display(const char* name, const char* info, bool bar, void* data, void (*update)(ui_view* view, void* data, float* progress, char* text), +ui_view* info_display(const char* name, const char* info, bool bar, void* data, void (*update)(ui_view* view, void* data, float* progress, char* text), void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2)) { info_data* infoData = (info_data*) calloc(1, sizeof(info_data)); if(infoData == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate info data."); + error_display(NULL, NULL, "Failed to allocate info data."); - return; + return NULL; } infoData->bar = bar; @@ -83,14 +83,7 @@ void info_display(const char* name, const char* info, bool bar, void* data, void infoData->update = update; infoData->drawTop = drawTop; - ui_view* view = (ui_view*) calloc(1, sizeof(ui_view)); - if(view == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate UI view."); - - free(infoData); - return; - } - + ui_view* view = ui_create(); view->name = name; view->info = info; view->data = infoData; @@ -98,9 +91,13 @@ void info_display(const char* name, const char* info, bool bar, void* data, void view->drawTop = info_draw_top; view->drawBottom = info_draw_bottom; ui_push(view); + + return view; } void info_destroy(ui_view* view) { - free(view->data); - free(view); + if(view != NULL) { + free(view->data); + ui_destroy(view); + } } \ No newline at end of file diff --git a/source/ui/info.h b/source/ui/info.h index 43d17b7..ed325d0 100644 --- a/source/ui/info.h +++ b/source/ui/info.h @@ -4,6 +4,6 @@ typedef struct ui_view_s ui_view; -void info_display(const char* name, const char* info, bool bar, void* data, void (*update)(ui_view* view, void* data, float* progress, char* text), - void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2)); +ui_view* info_display(const char* name, const char* info, bool bar, void* data, void (*update)(ui_view* view, void* data, float* progress, char* text), + void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2)); void info_destroy(ui_view* view); \ No newline at end of file diff --git a/source/ui/kbd.c b/source/ui/kbd.c index 02bdfdd..661c42a 100644 --- a/source/ui/kbd.c +++ b/source/ui/kbd.c @@ -63,7 +63,7 @@ static void kbd_cancel(ui_view* view, kbd_data* data) { } free(data); - free(view); + ui_destroy(view); } static void kbd_finish(ui_view* view, kbd_data* data) { @@ -74,7 +74,7 @@ static void kbd_finish(ui_view* view, kbd_data* data) { } free(data); - free(view); + ui_destroy(view); } #define NUM_KEYS 56 @@ -332,13 +332,13 @@ static void kbd_draw_bottom(ui_view* view, void* data, float x1, float y1, float } } -void kbd_display(const char* name, const char* initialInput, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), - void (*finished)(void* data, char* input), - void (*canceled)(void* data)) { +ui_view* kbd_display(const char* name, const char* initialInput, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), + void (*finished)(void* data, char* input), + void (*canceled)(void* data)) { kbd_data* kbdData = (kbd_data*) calloc(1, sizeof(kbd_data)); if(kbdData == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate info data."); - return; + error_display(NULL, NULL, "Failed to allocate info data."); + return NULL; } memset(kbdData->input, '\0', MAX_INPUT_SIZE); @@ -363,14 +363,7 @@ void kbd_display(const char* name, const char* initialInput, void* data, void (* kbdData->finished = finished; kbdData->canceled = canceled; - ui_view* view = (ui_view*) calloc(1, sizeof(ui_view)); - if(view == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate UI view."); - - free(kbdData); - return; - } - + ui_view* view = ui_create(); view->name = name; view->info = ""; view->data = kbdData; @@ -378,4 +371,6 @@ void kbd_display(const char* name, const char* initialInput, void* data, void (* view->drawTop = kbd_draw_top; view->drawBottom = kbd_draw_bottom; ui_push(view); + + return view; } \ No newline at end of file diff --git a/source/ui/kbd.h b/source/ui/kbd.h index 7fc1076..8e9c6fa 100644 --- a/source/ui/kbd.h +++ b/source/ui/kbd.h @@ -2,6 +2,6 @@ typedef struct ui_view_s ui_view; -void kbd_display(const char* name, const char* initialInput, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), - void (*finished)(void* data, char* input), - void (*canceled)(void* data)); \ No newline at end of file +ui_view* kbd_display(const char* name, const char* initialInput, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), + void (*finished)(void* data, char* input), + void (*canceled)(void* data)); \ No newline at end of file diff --git a/source/ui/list.c b/source/ui/list.c index bc89d48..7020bb4 100644 --- a/source/ui/list.c +++ b/source/ui/list.c @@ -267,13 +267,13 @@ static void list_draw_bottom(ui_view* view, void* data, float x1, float y1, floa } } -void list_display(const char* name, const char* info, void* data, void (*update)(ui_view* view, void* data, linked_list* items, list_item* selected, bool selectedTouched), - void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2, list_item* selected)) { +ui_view* list_display(const char* name, const char* info, void* data, void (*update)(ui_view* view, void* data, linked_list* items, list_item* selected, bool selectedTouched), + void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2, list_item* selected)) { list_data* listData = (list_data*) calloc(1, sizeof(list_data)); if(listData == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate list data."); + error_display(NULL, NULL, "Failed to allocate list data."); - return; + return NULL; } listData->data = data; @@ -286,14 +286,7 @@ void list_display(const char* name, const char* info, void* data, void (*update) listData->update = update; listData->drawTop = drawTop; - ui_view* view = (ui_view*) calloc(1, sizeof(ui_view)); - if(view == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate UI view."); - - free(listData); - return; - } - + ui_view* view = ui_create(); view->name = name; view->info = info; view->data = listData; @@ -301,11 +294,15 @@ void list_display(const char* name, const char* info, void* data, void (*update) view->drawTop = list_draw_top; view->drawBottom = list_draw_bottom; ui_push(view); + + return view; } void list_destroy(ui_view* view) { - linked_list_destroy(&((list_data*) view->data)->items); + if(view != NULL) { + linked_list_destroy(&((list_data*) view->data)->items); - free(view->data); - free(view); + free(view->data); + ui_destroy(view); + } } \ No newline at end of file diff --git a/source/ui/list.h b/source/ui/list.h index af620b6..d478aaa 100644 --- a/source/ui/list.h +++ b/source/ui/list.h @@ -11,6 +11,6 @@ typedef struct list_item_s { void* data; } list_item; -void list_display(const char* name, const char* info, void* data, void (*update)(ui_view* view, void* data, linked_list* items, list_item* selected, bool selectedTouched), - void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2, list_item* selected)); +ui_view* list_display(const char* name, const char* info, void* data, void (*update)(ui_view* view, void* data, linked_list* items, list_item* selected, bool selectedTouched), + void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2, list_item* selected)); void list_destroy(ui_view* view); \ No newline at end of file diff --git a/source/ui/prompt.c b/source/ui/prompt.c index c4452fa..cf89d3b 100644 --- a/source/ui/prompt.c +++ b/source/ui/prompt.c @@ -24,7 +24,7 @@ static void prompt_notify_response(ui_view* view, prompt_data* promptData, bool } free(promptData); - free(view); + ui_destroy(view); } static void prompt_update(ui_view* view, void* data, float bx1, float by1, float bx2, float by2) { @@ -134,13 +134,13 @@ static void prompt_draw_bottom(ui_view* view, void* data, float x1, float y1, fl screen_draw_string(promptData->text, x1 + (x2 - x1 - textWidth) / 2, y1 + (y2 - 5 - buttonHeight - y1 - textHeight) / 2, 0.5f, 0.5f, promptData->color, true); } -void prompt_display(const char* name, const char* text, u32 color, bool option, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), - void (*onResponse)(ui_view* view, void* data, bool response)) { +ui_view* prompt_display(const char* name, const char* text, u32 color, bool option, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), + void (*onResponse)(ui_view* view, void* data, bool response)) { prompt_data* promptData = (prompt_data*) calloc(1, sizeof(prompt_data)); if(promptData == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate prompt data."); + error_display(NULL, NULL, "Failed to allocate prompt data."); - return; + return NULL; } promptData->text = text; @@ -150,14 +150,7 @@ void prompt_display(const char* name, const char* text, u32 color, bool option, promptData->drawTop = drawTop; promptData->onResponse = onResponse; - ui_view* view = (ui_view*) calloc(1, sizeof(ui_view)); - if(view == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate UI view."); - - free(promptData); - return; - } - + ui_view* view = ui_create(); view->name = name; view->info = ""; view->data = promptData; @@ -165,4 +158,6 @@ void prompt_display(const char* name, const char* text, u32 color, bool option, view->drawTop = prompt_draw_top; view->drawBottom = prompt_draw_bottom; ui_push(view); + + return view; } \ No newline at end of file diff --git a/source/ui/prompt.h b/source/ui/prompt.h index 3951540..9ea7a84 100644 --- a/source/ui/prompt.h +++ b/source/ui/prompt.h @@ -2,5 +2,5 @@ typedef struct ui_view_s ui_view; -void prompt_display(const char* name, const char* text, u32 color, bool option, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), - void (*onResponse)(ui_view* view, void* data, bool response)); \ No newline at end of file +ui_view* prompt_display(const char* name, const char* text, u32 color, bool option, void* data, void (*drawTop)(ui_view* view, void* data, float x1, float y1, float x2, float y2), + void (*onResponse)(ui_view* view, void* data, bool response)); \ No newline at end of file diff --git a/source/ui/section/action/deletecontents.c b/source/ui/section/action/deletecontents.c index d982349..aa92944 100644 --- a/source/ui/section/action/deletecontents.c +++ b/source/ui/section/action/deletecontents.c @@ -88,11 +88,9 @@ static bool action_delete_error(void* data, u32 index, Result res) { prompt_display("Failure", "Delete cancelled.", COLOR_TEXT, false, NULL, NULL, NULL); return false; } else { - volatile bool dismissed = false; - error_display_res(&dismissed, data, action_delete_draw_top, res, "Failed to delete content."); - - while(!dismissed) { - svcSleepThread(1000000); + ui_view* view = error_display_res(data, action_delete_draw_top, res, "Failed to delete content."); + if(view != NULL) { + svcWaitSynchronization(view->active, U64_MAX); } } @@ -139,7 +137,7 @@ static void action_delete_onresponse(ui_view* view, void* data, bool response) { if(R_SUCCEEDED(res)) { info_display("Deleting", "Press B to cancel.", true, data, action_delete_update, action_delete_draw_top); } else { - error_display_res(NULL, deleteData->target, ui_draw_file_info, res, "Failed to initiate delete operation."); + error_display_res(deleteData->target, ui_draw_file_info, res, "Failed to initiate delete operation."); action_delete_free_data(deleteData); } @@ -151,7 +149,7 @@ static void action_delete_onresponse(ui_view* view, void* data, bool response) { static void action_delete_internal(linked_list* items, list_item* selected, const char* message, bool recursive, bool includeBase, bool ciasOnly, bool ticketsOnly) { delete_data* data = (delete_data*) calloc(1, sizeof(delete_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate delete data."); + error_display(NULL, NULL, "Failed to allocate delete data."); return; } @@ -185,7 +183,7 @@ static void action_delete_internal(linked_list* items, list_item* selected, cons Result listRes = task_populate_files(&popData); if(R_FAILED(listRes)) { - error_display_res(NULL, NULL, NULL, listRes, "Failed to initiate content list population."); + error_display_res(NULL, NULL, listRes, "Failed to initiate content list population."); action_delete_free_data(data); return; @@ -196,7 +194,7 @@ static void action_delete_internal(linked_list* items, list_item* selected, cons } if(R_FAILED(popData.result)) { - error_display_res(NULL, NULL, NULL, popData.result, "Failed to populate content list."); + error_display_res(NULL, NULL, popData.result, "Failed to populate content list."); action_delete_free_data(data); return; diff --git a/source/ui/section/action/deleteextsavedata.c b/source/ui/section/action/deleteextsavedata.c index 9d78391..aa7d9a1 100644 --- a/source/ui/section/action/deleteextsavedata.c +++ b/source/ui/section/action/deleteextsavedata.c @@ -32,7 +32,7 @@ static void action_delete_ext_save_data_update(ui_view* view, void* data, float* info_destroy(view); if(R_FAILED(res)) { - error_display_res(NULL, info, ui_draw_ext_save_data_info, res, "Failed to delete ext save data."); + error_display_res(info, ui_draw_ext_save_data_info, res, "Failed to delete ext save data."); } else { linked_list_remove(deleteData->items, deleteData->selected); task_free_ext_save_data(deleteData->selected); @@ -54,7 +54,7 @@ static void action_delete_ext_save_data_onresponse(ui_view* view, void* data, bo void action_delete_ext_save_data(linked_list* items, list_item* selected) { delete_ext_save_data_data* data = (delete_ext_save_data_data*) calloc(1, sizeof(delete_ext_save_data_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate delete ext save data data."); + error_display(NULL, NULL, "Failed to allocate delete ext save data data."); return; } diff --git a/source/ui/section/action/deletependingtitles.c b/source/ui/section/action/deletependingtitles.c index 2abccde..a2a4419 100644 --- a/source/ui/section/action/deletependingtitles.c +++ b/source/ui/section/action/deletependingtitles.c @@ -73,11 +73,9 @@ static bool action_delete_pending_titles_error(void* data, u32 index, Result res prompt_display("Failure", "Delete cancelled.", COLOR_TEXT, false, NULL, NULL, NULL); return false; } else { - volatile bool dismissed = false; - error_display_res(&dismissed, data, action_delete_pending_titles_draw_top, res, "Failed to delete pending title."); - - while(!dismissed) { - svcSleepThread(1000000); + 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); } } @@ -122,7 +120,7 @@ static void action_delete_pending_titles_onresponse(ui_view* view, void* data, b if(R_SUCCEEDED(res)) { info_display("Deleting Pending Title(s)", "Press B to cancel.", true, data, action_delete_pending_titles_update, action_delete_pending_titles_draw_top); } else { - error_display_res(NULL, NULL, NULL, res, "Failed to initiate delete operation."); + error_display_res(NULL, NULL, res, "Failed to initiate delete operation."); action_delete_pending_titles_free_data(deleteData); } @@ -134,7 +132,7 @@ static void action_delete_pending_titles_onresponse(ui_view* view, void* data, b void action_delete_pending_titles(linked_list* items, list_item* selected, const char* message, bool all) { delete_pending_titles_data* data = (delete_pending_titles_data*) calloc(1, sizeof(delete_pending_titles_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate delete pending titles data."); + error_display(NULL, NULL, "Failed to allocate delete pending titles data."); return; } @@ -163,7 +161,7 @@ void action_delete_pending_titles(linked_list* items, list_item* selected, const Result listRes = task_populate_pending_titles(&popData); if(R_FAILED(listRes)) { - error_display_res(NULL, NULL, NULL, listRes, "Failed to initiate pending title list population."); + error_display_res(NULL, NULL, listRes, "Failed to initiate pending title list population."); action_delete_pending_titles_free_data(data); return; @@ -174,7 +172,7 @@ void action_delete_pending_titles(linked_list* items, list_item* selected, const } if(R_FAILED(popData.result)) { - error_display_res(NULL, NULL, NULL, popData.result, "Failed to populate pending title list."); + error_display_res(NULL, NULL, popData.result, "Failed to populate pending title list."); action_delete_pending_titles_free_data(data); return; diff --git a/source/ui/section/action/deletesecurevalue.c b/source/ui/section/action/deletesecurevalue.c index 66bf00e..da4485f 100644 --- a/source/ui/section/action/deletesecurevalue.c +++ b/source/ui/section/action/deletesecurevalue.c @@ -23,7 +23,7 @@ static void action_delete_secure_value_update(ui_view* view, void* data, float* info_destroy(view); if(R_FAILED(res)) { - error_display_res(NULL, info, ui_draw_title_info, res, "Failed to delete secure value."); + error_display_res(info, ui_draw_title_info, res, "Failed to delete secure value."); } else { prompt_display("Success", "Secure value deleted.", COLOR_TEXT, false, info, ui_draw_title_info, NULL); } diff --git a/source/ui/section/action/deletesystemsavedata.c b/source/ui/section/action/deletesystemsavedata.c index 3938fc2..8fb688e 100644 --- a/source/ui/section/action/deletesystemsavedata.c +++ b/source/ui/section/action/deletesystemsavedata.c @@ -33,7 +33,7 @@ static void action_delete_system_save_data_update(ui_view* view, void* data, flo info_destroy(view); if(R_FAILED(res)) { - error_display_res(NULL, info, ui_draw_system_save_data_info, res, "Failed to delete system save data."); + error_display_res(info, ui_draw_system_save_data_info, res, "Failed to delete system save data."); } else { linked_list_remove(deleteData->items, deleteData->selected); task_free_system_save_data(deleteData->selected); @@ -55,7 +55,7 @@ static void action_delete_system_save_data_onresponse(ui_view* view, void* data, void action_delete_system_save_data(linked_list* items, list_item* selected) { delete_system_save_data_data* data = (delete_system_save_data_data*) calloc(1, sizeof(delete_system_save_data_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate delete system save data data."); + error_display(NULL, NULL, "Failed to allocate delete system save data data."); return; } diff --git a/source/ui/section/action/deleteticket.c b/source/ui/section/action/deleteticket.c index 61773ec..066e683 100644 --- a/source/ui/section/action/deleteticket.c +++ b/source/ui/section/action/deleteticket.c @@ -32,7 +32,7 @@ static void action_delete_ticket_update(ui_view* view, void* data, float* progre info_destroy(view); if(R_FAILED(res)) { - error_display_res(NULL, info, ui_draw_ticket_info, res, "Failed to delete ticket."); + error_display_res(info, ui_draw_ticket_info, res, "Failed to delete ticket."); } else { linked_list_remove(deleteData->items, deleteData->selected); task_free_ticket(deleteData->selected); @@ -54,7 +54,7 @@ static void action_delete_ticket_onresponse(ui_view* view, void* data, bool resp void action_delete_ticket(linked_list* items, list_item* selected) { delete_ticket_data* data = (delete_ticket_data*) calloc(1, sizeof(delete_ticket_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate delete ticket data."); + error_display(NULL, NULL, "Failed to allocate delete ticket data."); return; } diff --git a/source/ui/section/action/deletetitle.c b/source/ui/section/action/deletetitle.c index 5e9149b..69b2cce 100644 --- a/source/ui/section/action/deletetitle.c +++ b/source/ui/section/action/deletetitle.c @@ -32,7 +32,7 @@ static void action_delete_title_update(ui_view* view, void* data, float* progres info_destroy(view); if(R_FAILED(res)) { - error_display_res(NULL, info, ui_draw_title_info, res, "Failed to delete title."); + error_display_res(info, ui_draw_title_info, res, "Failed to delete title."); } else { linked_list_remove(deleteData->items, deleteData->selected); task_free_title(deleteData->selected); @@ -54,7 +54,7 @@ static void action_delete_title_onresponse(ui_view* view, void* data, bool respo void action_delete_title(linked_list* items, list_item* selected) { delete_title_data* data = (delete_title_data*) calloc(1, sizeof(delete_title_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate delete title data."); + error_display(NULL, NULL, "Failed to allocate delete title data."); return; } diff --git a/source/ui/section/action/exportsecurevalue.c b/source/ui/section/action/exportsecurevalue.c index 7550f22..89d9bdb 100644 --- a/source/ui/section/action/exportsecurevalue.c +++ b/source/ui/section/action/exportsecurevalue.c @@ -61,7 +61,7 @@ static void action_export_secure_value_update(ui_view* view, void* data, float* if(R_SUCCEEDED(res)) { prompt_display("Success", "Secure value exported.", COLOR_TEXT, false, info, ui_draw_title_info, NULL); } else { - error_display_res(NULL, info, ui_draw_title_info, res, "Failed to export secure value."); + error_display_res(info, ui_draw_title_info, res, "Failed to export secure value."); } } diff --git a/source/ui/section/action/exporttwlsave.c b/source/ui/section/action/exporttwlsave.c index 5f568d9..b43352c 100644 --- a/source/ui/section/action/exporttwlsave.c +++ b/source/ui/section/action/exporttwlsave.c @@ -114,7 +114,7 @@ static bool action_export_twl_save_error(void* data, u32 index, Result res) { if(res == R_FBI_CANCELLED) { prompt_display("Failure", "Export cancelled.", COLOR_TEXT, false, exportData->title, ui_draw_title_info, NULL); } else { - error_display_res(NULL, exportData->title, ui_draw_title_info, res, "Failed to export save."); + error_display_res(exportData->title, ui_draw_title_info, res, "Failed to export save."); } return false; @@ -152,7 +152,7 @@ static void action_export_twl_save_onresponse(ui_view* view, void* data, bool re if(R_SUCCEEDED(res)) { info_display("Exporting Save", "Press B to cancel.", true, data, action_export_twl_save_update, action_export_twl_save_draw_top); } else { - error_display_res(NULL, exportData->title, ui_draw_title_info, res, "Failed to initiate save export."); + error_display_res(exportData->title, ui_draw_title_info, res, "Failed to initiate save export."); free(data); } } else { @@ -163,7 +163,7 @@ static void action_export_twl_save_onresponse(ui_view* view, void* data, bool re void action_export_twl_save(linked_list* items, list_item* selected) { export_twl_save_data* data = (export_twl_save_data*) calloc(1, sizeof(export_twl_save_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate export TWL save data."); + error_display(NULL, NULL, "Failed to allocate export TWL save data."); return; } diff --git a/source/ui/section/action/extractsmdh.c b/source/ui/section/action/extractsmdh.c index eeea5f1..30a5bad 100644 --- a/source/ui/section/action/extractsmdh.c +++ b/source/ui/section/action/extractsmdh.c @@ -67,7 +67,7 @@ static void action_extract_smdh_update(ui_view* view, void* data, float* progres if(R_SUCCEEDED(res)) { prompt_display("Success", "SMDH extracted.", COLOR_TEXT, false, info, ui_draw_title_info, NULL); } else { - error_display_res(NULL, info, ui_draw_title_info, res, "Failed to extract SMDH."); + error_display_res(info, ui_draw_title_info, res, "Failed to extract SMDH."); } } diff --git a/source/ui/section/action/importsecurevalue.c b/source/ui/section/action/importsecurevalue.c index 22c129b..53c5658 100644 --- a/source/ui/section/action/importsecurevalue.c +++ b/source/ui/section/action/importsecurevalue.c @@ -45,7 +45,7 @@ static void action_import_secure_value_update(ui_view* view, void* data, float* if(R_SUCCEEDED(res)) { prompt_display("Success", "Secure value imported.", COLOR_TEXT, false, info, ui_draw_title_info, NULL); } else { - error_display_res(NULL, info, ui_draw_title_info, res, "Failed to import secure value."); + error_display_res(info, ui_draw_title_info, res, "Failed to import secure value."); } } diff --git a/source/ui/section/action/importseed.c b/source/ui/section/action/importseed.c index 9b6e888..253fb2d 100644 --- a/source/ui/section/action/importseed.c +++ b/source/ui/section/action/importseed.c @@ -24,7 +24,7 @@ static void action_import_seed_update(ui_view* view, void* data, float* progress if(R_SUCCEEDED(res)) { prompt_display("Success", "Seed imported.", COLOR_TEXT, false, info, ui_draw_title_info, NULL); } else { - error_display_res(NULL, info, ui_draw_title_info, res, "Failed to import seed."); + error_display_res(info, ui_draw_title_info, res, "Failed to import seed."); } } diff --git a/source/ui/section/action/importtwlsave.c b/source/ui/section/action/importtwlsave.c index 6ff4d1b..cc68f3b 100644 --- a/source/ui/section/action/importtwlsave.c +++ b/source/ui/section/action/importtwlsave.c @@ -100,7 +100,7 @@ static bool action_import_twl_save_error(void* data, u32 index, Result res) { if(res == R_FBI_CANCELLED) { prompt_display("Failure", "Import cancelled.", COLOR_TEXT, false, importData->title, ui_draw_title_info, NULL); } else { - error_display_res(NULL, importData->title, ui_draw_title_info, res, "Failed to import save."); + error_display_res(importData->title, ui_draw_title_info, res, "Failed to import save."); } return false; @@ -138,7 +138,7 @@ static void action_import_twl_save_onresponse(ui_view* view, void* data, bool re if(R_SUCCEEDED(res)) { info_display("Importing Save", "Press B to cancel.", true, data, action_import_twl_save_update, action_import_twl_save_draw_top); } else { - error_display_res(NULL, importData->title, ui_draw_title_info, res, "Failed to initiate save import."); + error_display_res(importData->title, ui_draw_title_info, res, "Failed to initiate save import."); free(data); } } else { @@ -149,7 +149,7 @@ static void action_import_twl_save_onresponse(ui_view* view, void* data, bool re void action_import_twl_save(linked_list* items, list_item* selected) { import_twl_save_data* data = (import_twl_save_data*) calloc(1, sizeof(import_twl_save_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate import TWL save data."); + error_display(NULL, NULL, "Failed to allocate import TWL save data."); return; } diff --git a/source/ui/section/action/installcdn.c b/source/ui/section/action/installcdn.c index f5463ac..1d496f6 100644 --- a/source/ui/section/action/installcdn.c +++ b/source/ui/section/action/installcdn.c @@ -184,9 +184,9 @@ bool action_install_cdn_error(void* data, u32 index, Result res) { if(res == R_FBI_CANCELLED) { prompt_display("Failure", "Install cancelled.", COLOR_TEXT, false, installData->ticket, ui_draw_ticket_info, NULL); } else if(res == R_FBI_HTTP_RESPONSE_CODE) { - error_display(NULL, installData->ticket, ui_draw_ticket_info, "Failed to install CDN title.\nHTTP server returned response code %d", installData->responseCode); + error_display(installData->ticket, ui_draw_ticket_info, "Failed to install CDN title.\nHTTP server returned response code %d", installData->responseCode); } else { - error_display_res(NULL, installData->ticket, ui_draw_ticket_info, res, "Failed to install CDN title."); + error_display_res(installData->ticket, ui_draw_ticket_info, res, "Failed to install CDN title."); } return false; @@ -232,7 +232,7 @@ static void action_install_cdn_update(ui_view* view, void* data, float* progress AM_InstallTitleAbort(); if(R_FAILED(res)) { - error_display_res(NULL, installData->ticket, ui_draw_ticket_info, res, "Failed to install CDN title."); + error_display_res(installData->ticket, ui_draw_ticket_info, res, "Failed to install CDN title."); } } @@ -252,7 +252,7 @@ static void action_install_cdn_update(ui_view* view, void* data, float* progress void action_install_cdn_noprompt(volatile bool* done, ticket_info* info, bool finishedPrompt) { install_cdn_data* data = (install_cdn_data*) calloc(1, sizeof(install_cdn_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate install CDN data."); + error_display(NULL, NULL, "Failed to allocate install CDN data."); return; } @@ -317,7 +317,7 @@ void action_install_cdn_noprompt(volatile bool* done, ticket_info* info, bool fi } if(R_FAILED(res)) { - error_display_res(NULL, data->ticket, ui_draw_ticket_info, res, "Failed to initiate CDN title installation."); + error_display_res(data->ticket, ui_draw_ticket_info, res, "Failed to initiate CDN title installation."); action_install_cdn_free_data(data); } diff --git a/source/ui/section/action/installcias.c b/source/ui/section/action/installcias.c index c39df80..13735fc 100644 --- a/source/ui/section/action/installcias.c +++ b/source/ui/section/action/installcias.c @@ -187,11 +187,9 @@ bool action_install_cias_error(void* data, u32 index, Result res) { prompt_display("Failure", "Install cancelled.", COLOR_TEXT, false, NULL, NULL, NULL); return false; } else { - volatile bool dismissed = false; - error_display_res(&dismissed, data, action_install_cias_draw_top, res, "Failed to install CIA file."); - - while(!dismissed) { - svcSleepThread(1000000); + 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); } } @@ -240,7 +238,7 @@ static void action_install_cias_onresponse(ui_view* view, void* data, bool respo if(R_SUCCEEDED(res)) { info_display("Installing CIA(s)", "Press B to cancel.", true, data, action_install_cias_update, action_install_cias_draw_top); } else { - error_display_res(NULL, NULL, NULL, res, "Failed to initiate CIA installation."); + error_display_res(NULL, NULL, res, "Failed to initiate CIA installation."); action_install_cias_free_data(installData); } @@ -252,7 +250,7 @@ static void action_install_cias_onresponse(ui_view* view, void* data, bool respo static void action_install_cias_internal(linked_list* items, list_item* selected, const char* message, bool delete) { install_cias_data* data = (install_cias_data*) calloc(1, sizeof(install_cias_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate install CIAs data."); + error_display(NULL, NULL, "Failed to allocate install CIAs data."); return; } @@ -306,7 +304,7 @@ static void action_install_cias_internal(linked_list* items, list_item* selected Result listRes = task_populate_files(&popData); if(R_FAILED(listRes)) { - error_display_res(NULL, NULL, NULL, listRes, "Failed to initiate CIA list population."); + error_display_res(NULL, NULL, listRes, "Failed to initiate CIA list population."); action_install_cias_free_data(data); return; @@ -317,7 +315,7 @@ static void action_install_cias_internal(linked_list* items, list_item* selected } if(R_FAILED(popData.result)) { - error_display_res(NULL, NULL, NULL, popData.result, "Failed to populate CIA list."); + error_display_res(NULL, NULL, popData.result, "Failed to populate CIA list."); action_install_cias_free_data(data); return; diff --git a/source/ui/section/action/installtickets.c b/source/ui/section/action/installtickets.c index 862b546..810347c 100644 --- a/source/ui/section/action/installtickets.c +++ b/source/ui/section/action/installtickets.c @@ -160,11 +160,9 @@ static bool action_install_tickets_error(void* data, u32 index, Result res) { prompt_display("Failure", "Install cancelled.", COLOR_TEXT, false, NULL, NULL, NULL); return false; } else { - volatile bool dismissed = false; - error_display_res(&dismissed, data, action_install_tickets_draw_top, res, "Failed to install ticket."); - - while(!dismissed) { - svcSleepThread(1000000); + 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); } } @@ -214,7 +212,7 @@ static void action_install_tickets_cdn_check_onresponse(ui_view* view, void* dat if(R_SUCCEEDED(res)) { info_display("Installing ticket(s)", "Press B to cancel.", true, data, action_install_tickets_update, action_install_tickets_draw_top); } else { - error_display_res(NULL, NULL, NULL, res, "Failed to initiate ticket installation."); + error_display_res(NULL, NULL, res, "Failed to initiate ticket installation."); action_install_tickets_free_data(installData); } @@ -231,7 +229,7 @@ static void action_install_tickets_onresponse(ui_view* view, void* data, bool re static void action_install_tickets_internal(linked_list* items, list_item* selected, const char* message, bool delete) { install_tickets_data* data = (install_tickets_data*) calloc(1, sizeof(install_tickets_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate install tickets data."); + error_display(NULL, NULL, "Failed to allocate install tickets data."); return; } @@ -283,7 +281,7 @@ static void action_install_tickets_internal(linked_list* items, list_item* selec Result listRes = task_populate_files(&popData); if(R_FAILED(listRes)) { - error_display_res(NULL, NULL, NULL, listRes, "Failed to initiate ticket file list population."); + error_display_res(NULL, NULL, listRes, "Failed to initiate ticket file list population."); action_install_tickets_free_data(data); return; @@ -294,7 +292,7 @@ static void action_install_tickets_internal(linked_list* items, list_item* selec } if(R_FAILED(popData.result)) { - error_display_res(NULL, NULL, NULL, popData.result, "Failed to populate ticket file list."); + error_display_res(NULL, NULL, popData.result, "Failed to populate ticket file list."); action_install_tickets_free_data(data); return; diff --git a/source/ui/section/action/launchtitle.c b/source/ui/section/action/launchtitle.c index 35919c9..2c69e4e 100644 --- a/source/ui/section/action/launchtitle.c +++ b/source/ui/section/action/launchtitle.c @@ -29,7 +29,7 @@ static void action_launch_title_update(ui_view* view, void* data, float* progres ui_pop(); info_destroy(view); - error_display_res(NULL, info, ui_draw_title_info, res, "Failed to launch title."); + error_display_res(info, ui_draw_title_info, res, "Failed to launch title."); } } diff --git a/source/ui/section/action/newfolder.c b/source/ui/section/action/newfolder.c index 7d36f73..7a01118 100644 --- a/source/ui/section/action/newfolder.c +++ b/source/ui/section/action/newfolder.c @@ -25,7 +25,7 @@ static void action_new_folder_kbd_finished(void* data, char* input) { new_folder_data* newFolderData = (new_folder_data*) data; if(strlen(input) == 0) { - error_display(NULL, NULL, NULL, "No name specified."); + error_display(NULL, NULL, "No name specified."); } Result res = 0; @@ -51,7 +51,7 @@ static void action_new_folder_kbd_finished(void* data, char* input) { prompt_display("Success", "Folder created.", COLOR_TEXT, false, NULL, NULL, NULL); } else { - error_display_res(NULL, NULL, NULL, res, "Failed to create folder."); + error_display_res(NULL, NULL, res, "Failed to create folder."); } free(data); @@ -64,7 +64,7 @@ static void action_new_folder_kbd_canceled(void* data) { void action_new_folder(linked_list* items, list_item* selected) { new_folder_data* data = (new_folder_data*) calloc(1, sizeof(new_folder_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate new folder data."); + error_display(NULL, NULL, "Failed to allocate new folder data."); return; } diff --git a/source/ui/section/action/pastefiles.c b/source/ui/section/action/pastefiles.c index fef6ede..9770a24 100644 --- a/source/ui/section/action/pastefiles.c +++ b/source/ui/section/action/pastefiles.c @@ -208,11 +208,9 @@ static bool action_paste_files_error(void* data, u32 index, Result res) { prompt_display("Failure", "Paste cancelled.", COLOR_TEXT, false, NULL, NULL, NULL); return false; } else { - volatile bool dismissed = false; - error_display_res(&dismissed, data, action_paste_files_draw_top, res, "Failed to paste content."); - - while(!dismissed) { - svcSleepThread(1000000); + ui_view* view = error_display_res(data, action_paste_files_draw_top, res, "Failed to paste content."); + if(view != NULL) { + svcWaitSynchronization(view->active, U64_MAX); } } @@ -260,7 +258,7 @@ static void action_paste_files_onresponse(ui_view* view, void* data, bool respon if(R_SUCCEEDED(res)) { info_display("Pasting Contents", "Press B to cancel.", true, data, action_paste_files_update, action_paste_files_draw_top); } else { - error_display_res(NULL, pasteData->target, ui_draw_file_info, res, "Failed to initiate paste operation."); + error_display_res(pasteData->target, ui_draw_file_info, res, "Failed to initiate paste operation."); action_paste_files_free_data(pasteData); } @@ -277,7 +275,7 @@ void action_paste_contents(linked_list* items, list_item* selected) { paste_files_data* data = (paste_files_data*) calloc(1, sizeof(paste_files_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate paste files data."); + error_display(NULL, NULL, "Failed to allocate paste files data."); return; } @@ -317,7 +315,7 @@ void action_paste_contents(linked_list* items, list_item* selected) { list_item* clipboardItem = NULL; Result createRes = 0; if(R_FAILED(createRes = task_create_file_item(&clipboardItem, clipboard_get_archive(), clipboard_get_path()))) { - error_display_res(NULL, NULL, NULL, createRes, "Failed to retrieve clipboard content info."); + error_display_res(NULL, NULL, createRes, "Failed to retrieve clipboard content info."); action_paste_files_free_data(data); return; @@ -336,7 +334,7 @@ void action_paste_contents(linked_list* items, list_item* selected) { Result listRes = task_populate_files(&popData); if(R_FAILED(listRes)) { - error_display_res(NULL, NULL, NULL, listRes, "Failed to initiate clipboard content list population."); + error_display_res(NULL, NULL, listRes, "Failed to initiate clipboard content list population."); task_free_file(clipboardItem); action_paste_files_free_data(data); @@ -350,7 +348,7 @@ void action_paste_contents(linked_list* items, list_item* selected) { task_free_file(clipboardItem); if(R_FAILED(popData.result)) { - error_display_res(NULL, NULL, NULL, popData.result, "Failed to populate clipboard content list."); + error_display_res(NULL, NULL, popData.result, "Failed to populate clipboard content list."); action_paste_files_free_data(data); return; diff --git a/source/ui/section/action/rename.c b/source/ui/section/action/rename.c index 035df35..e2e23f1 100644 --- a/source/ui/section/action/rename.c +++ b/source/ui/section/action/rename.c @@ -25,7 +25,7 @@ static void action_rename_kbd_finished(void* data, char* input) { rename_data* renameData = (rename_data*) data; if(strlen(input) == 0) { - error_display(NULL, NULL, NULL, "No name specified."); + error_display(NULL, NULL, "No name specified."); } file_info* targetInfo = (file_info*) renameData->target->data; @@ -70,7 +70,7 @@ static void action_rename_kbd_finished(void* data, char* input) { prompt_display("Success", "Renamed.", COLOR_TEXT, false, NULL, NULL, NULL); } else { - error_display_res(NULL, NULL, NULL, res, "Failed to perform rename."); + error_display_res(NULL, NULL, res, "Failed to perform rename."); } free(data); @@ -83,7 +83,7 @@ static void action_rename_kbd_canceled(void* data) { void action_rename(linked_list* items, list_item* selected) { rename_data* data = (rename_data*) calloc(1, sizeof(rename_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate rename data."); + error_display(NULL, NULL, "Failed to allocate rename data."); return; } diff --git a/source/ui/section/dumpnand.c b/source/ui/section/dumpnand.c index 8b0ed3e..def4e00 100644 --- a/source/ui/section/dumpnand.c +++ b/source/ui/section/dumpnand.c @@ -69,7 +69,7 @@ static bool dumpnand_error(void* data, u32 index, Result res) { if(res == R_FBI_CANCELLED) { prompt_display("Failure", "Dump cancelled.", COLOR_TEXT, false, NULL, NULL, NULL); } else { - error_display_res(NULL, NULL, NULL, res, "Failed to dump NAND."); + error_display_res(NULL, NULL, res, "Failed to dump NAND."); } return false; @@ -107,7 +107,7 @@ static void dumpnand_onresponse(ui_view* view, void* data, bool response) { if(R_SUCCEEDED(res)) { info_display("Dumping NAND", "Press B to cancel.", true, data, dumpnand_update, NULL); } else { - error_display_res(NULL, NULL, NULL, res, "Failed to initiate NAND dump."); + error_display_res(NULL, NULL, res, "Failed to initiate NAND dump."); free(data); } } else { @@ -118,7 +118,7 @@ static void dumpnand_onresponse(ui_view* view, void* data, bool response) { void dumpnand_open() { data_op_data* data = (data_op_data*) calloc(1, sizeof(data_op_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate dump NAND data."); + error_display(NULL, NULL, "Failed to allocate dump NAND data."); return; } diff --git a/source/ui/section/extsavedata.c b/source/ui/section/extsavedata.c index b12ca5a..f8397e0 100644 --- a/source/ui/section/extsavedata.c +++ b/source/ui/section/extsavedata.c @@ -69,7 +69,7 @@ static void extsavedata_action_update(ui_view* view, void* data, linked_list* it static void extsavedata_action_open(linked_list* items, list_item* selected) { extsavedata_action_data* data = (extsavedata_action_data*) calloc(1, sizeof(extsavedata_action_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate ext save data action data."); + error_display(NULL, NULL, "Failed to allocate ext save data action data."); return; } @@ -170,14 +170,14 @@ static void extsavedata_update(ui_view* view, void* data, linked_list* items, li listData->populateData.items = items; Result res = task_populate_ext_save_data(&listData->populateData); if(R_FAILED(res)) { - error_display_res(NULL, NULL, NULL, res, "Failed to initiate ext save data list population."); + error_display_res(NULL, NULL, res, "Failed to initiate ext save data list population."); } listData->populated = true; } if(listData->populateData.finished && R_FAILED(listData->populateData.result)) { - error_display_res(NULL, NULL, NULL, listData->populateData.result, "Failed to populate ext save data list."); + error_display_res(NULL, NULL, listData->populateData.result, "Failed to populate ext save data list."); listData->populateData.result = 0; } @@ -201,7 +201,7 @@ static bool extsavedata_filter(void* data, u64 titleId, FS_MediaType mediaType) void extsavedata_open() { extsavedata_data* data = (extsavedata_data*) calloc(1, sizeof(extsavedata_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate ext save data data."); + error_display(NULL, NULL, "Failed to allocate ext save data data."); return; } diff --git a/source/ui/section/files.c b/source/ui/section/files.c index 291e888..a5b7736 100644 --- a/source/ui/section/files.c +++ b/source/ui/section/files.c @@ -97,7 +97,7 @@ static void files_action_update(ui_view* view, void* data, linked_list* items, l if(R_SUCCEEDED(res = clipboard_set_contents(actionData->parent->archive, info->path, selected == ©_all_contents))) { prompt_display("Success", selected == ©_all_contents ? "Current directory contents copied to clipboard." : info->isDirectory ? "Current directory copied to clipboard." : "File copied to clipboard.", COLOR_TEXT, false, info, ui_draw_file_info, NULL); } else { - error_display_res(NULL, info, ui_draw_file_info, res, "Failed to copy to clipboard."); + error_display_res(info, ui_draw_file_info, res, "Failed to copy to clipboard."); } } else { action(actionData->items, actionData->selected); @@ -153,7 +153,7 @@ static void files_action_update(ui_view* view, void* data, linked_list* items, l static void files_action_open(linked_list* items, list_item* selected, files_data* parent) { files_action_data* data = (files_action_data*) calloc(1, sizeof(files_action_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate files action data."); + error_display(NULL, NULL, "Failed to allocate files action data."); return; } @@ -252,7 +252,7 @@ static void files_repopulate(files_data* listData, linked_list* items) { Result res = task_populate_files(&listData->populateData); if(R_FAILED(res)) { - error_display_res(NULL, NULL, NULL, res, "Failed to initiate file list population."); + error_display_res(NULL, NULL, res, "Failed to initiate file list population."); } listData->populated = true; @@ -342,7 +342,7 @@ static void files_update(ui_view* view, void* data, linked_list* items, list_ite } if(listData->populateData.finished && R_FAILED(listData->populateData.result)) { - error_display_res(NULL, NULL, NULL, listData->populateData.result, "Failed to populate file list."); + error_display_res(NULL, NULL, listData->populateData.result, "Failed to populate file list."); listData->populateData.result = 0; } @@ -373,7 +373,7 @@ static bool files_filter(void* data, const char* name, u32 attributes) { void files_open(FS_ArchiveID archiveId, FS_Path archivePath) { files_data* data = (files_data*) calloc(1, sizeof(files_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate files data."); + error_display(NULL, NULL, "Failed to allocate files data."); return; } @@ -400,7 +400,7 @@ void files_open(FS_ArchiveID archiveId, FS_Path archivePath) { if(archivePath.data != NULL) { data->archivePath.data = calloc(1, data->archivePath.size); if(data->archivePath.data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate files data."); + error_display(NULL, NULL, "Failed to allocate files data."); files_free_data(data); return; @@ -415,7 +415,7 @@ void files_open(FS_ArchiveID archiveId, FS_Path archivePath) { Result res = 0; if(R_FAILED(res = util_open_archive(&data->archive, archiveId, archivePath))) { - error_display_res(NULL, NULL, NULL, res, "Failed to open file listing archive."); + error_display_res(NULL, NULL, res, "Failed to open file listing archive."); files_free_data(data); return; diff --git a/source/ui/section/networkinstall.c b/source/ui/section/networkinstall.c index b2d8e80..3224aef 100644 --- a/source/ui/section/networkinstall.c +++ b/source/ui/section/networkinstall.c @@ -22,10 +22,11 @@ typedef struct { int serverSocket; int clientSocket; - u64 currTitleId; - bool ticket; - bool cdn; + bool cdnDecided; + + bool ticket; + u64 currTitleId; ticket_info ticketInfo; data_op_data installInfo; @@ -55,6 +56,13 @@ static int sendwait(int sockfd, void* buf, size_t len, int flags) { return ret < 0 ? ret : (int) written; } +static void networkinstall_cdn_check_onresponse(ui_view* view, void* data, bool response) { + network_install_data* qrInstallData = (network_install_data*) data; + + qrInstallData->cdn = response; + qrInstallData->cdnDecided = true; +} + static Result networkinstall_is_src_directory(void* data, u32 index, bool* isDirectory) { *isDirectory = false; return 0; @@ -108,7 +116,18 @@ static Result networkinstall_open_dst(void* data, u32 index, void* initialReadBl Result res = 0; + networkInstallData->ticket = false; + networkInstallData->currTitleId = 0; + memset(&networkInstallData->ticketInfo, 0, sizeof(networkInstallData->ticketInfo)); + if(*(u16*) initialReadBlock == 0x0100) { + if(!networkInstallData->cdnDecided) { + ui_view* view = prompt_display("Optional", "Install ticket titles from CDN?", COLOR_TEXT, true, data, NULL, networkinstall_cdn_check_onresponse); + if(view != NULL) { + svcWaitSynchronization(view->active, U64_MAX); + } + } + networkInstallData->ticket = true; networkInstallData->ticketInfo.titleId = util_get_ticket_title_id((u8*) initialReadBlock); @@ -207,9 +226,9 @@ static bool networkinstall_error(void* data, u32 index, Result res) { if(res == R_FBI_CANCELLED) { prompt_display("Failure", "Install cancelled.", COLOR_TEXT, false, NULL, NULL, NULL); } else if(res == R_FBI_ERRNO) { - error_display_errno(NULL, NULL, NULL, errno, "Failed to install over the network."); + error_display_errno(NULL, NULL, errno, "Failed to install over the network."); } else { - error_display_res(NULL, NULL, NULL, res, "Failed to install over the network."); + error_display_res(NULL, NULL, res, "Failed to install over the network."); } return false; @@ -224,7 +243,12 @@ static void networkinstall_close_client(network_install_data* data) { data->clientSocket = 0; } + data->cdn = false; + data->cdnDecided = false; + + data->ticket = false; data->currTitleId = 0; + memset(&data->ticketInfo, 0, sizeof(data->ticketInfo)); } static void networkinstall_free_data(network_install_data* data) { @@ -262,26 +286,20 @@ static void networkinstall_install_update(ui_view* view, void* data, float* prog snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f %s / %.2f %s", networkInstallData->installInfo.processed, networkInstallData->installInfo.total, util_get_display_size(networkInstallData->installInfo.currProcessed), util_get_display_size_units(networkInstallData->installInfo.currProcessed), util_get_display_size(networkInstallData->installInfo.currTotal), util_get_display_size_units(networkInstallData->installInfo.currTotal)); } -static void networkinstall_cdn_check_onresponse(ui_view* view, void* data, bool response) { +static void networkinstall_confirm_onresponse(ui_view* view, void* data, bool response) { network_install_data* networkInstallData = (network_install_data*) data; - networkInstallData->cdn = response; - - Result res = task_data_op(&networkInstallData->installInfo); - if(R_SUCCEEDED(res)) { - info_display("Installing Received Files", "Press B to cancel.", true, data, networkinstall_install_update, NULL); - } else { - error_display_res(NULL, NULL, NULL, res, "Failed to initiate installation."); - - networkinstall_close_client(networkInstallData); - } -} - -static void networkinstall_confirm_onresponse(ui_view* view, void* data, bool response) { if(response) { - prompt_display("Optional", "Install ticket titles from CDN?", COLOR_TEXT, true, data, NULL, networkinstall_cdn_check_onresponse); + Result res = task_data_op(&networkInstallData->installInfo); + if(R_SUCCEEDED(res)) { + info_display("Installing Received File(s)", "Press B to cancel.", true, data, networkinstall_install_update, NULL); + } else { + error_display_res(NULL, NULL, res, "Failed to initiate installation."); + + networkinstall_close_client(networkInstallData); + } } else { - networkinstall_close_client((network_install_data*) data); + networkinstall_close_client(networkInstallData); } } @@ -305,7 +323,7 @@ static void networkinstall_wait_update(ui_view* view, void* data, float* progres if(recvwait(sock, &networkInstallData->installInfo.total, sizeof(networkInstallData->installInfo.total), 0) < 0) { close(sock); - error_display_errno(NULL, NULL, NULL, errno, "Failed to read file count."); + error_display_errno(NULL, NULL, errno, "Failed to read file count."); return; } @@ -319,7 +337,7 @@ static void networkinstall_wait_update(ui_view* view, void* data, float* progres info_destroy(view); } - error_display_errno(NULL, NULL, NULL, errno, "Failed to open socket."); + error_display_errno(NULL, NULL, errno, "Failed to open socket."); if(errno == 22 || errno == 115) { networkinstall_free_data(networkInstallData); @@ -335,15 +353,19 @@ static void networkinstall_wait_update(ui_view* view, void* data, float* progres void networkinstall_open() { network_install_data* data = (network_install_data*) calloc(1, sizeof(network_install_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate network install data."); + error_display(NULL, NULL, "Failed to allocate network install data."); return; } data->clientSocket = 0; - data->currTitleId = 0; + data->cdn = false; + data->cdnDecided = false; + data->ticket = false; + data->currTitleId = 0; + memset(&data->ticketInfo, 0, sizeof(data->ticketInfo)); data->installInfo.data = data; @@ -376,7 +398,7 @@ void networkinstall_open() { int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); if(sock < 0) { - error_display_errno(NULL, NULL, NULL, errno, "Failed to open server socket."); + error_display_errno(NULL, NULL, errno, "Failed to open server socket."); networkinstall_free_data(data); return; @@ -393,7 +415,7 @@ void networkinstall_open() { server.sin_addr.s_addr = (in_addr_t) gethostid(); if(bind(data->serverSocket, (struct sockaddr*) &server, sizeof(server)) < 0) { - error_display_errno(NULL, NULL, NULL, errno, "Failed to bind server socket."); + error_display_errno(NULL, NULL, errno, "Failed to bind server socket."); networkinstall_free_data(data); return; @@ -402,7 +424,7 @@ void networkinstall_open() { fcntl(data->serverSocket, F_SETFL, fcntl(data->serverSocket, F_GETFL, 0) | O_NONBLOCK); if(listen(data->serverSocket, 5) < 0) { - error_display_errno(NULL, NULL, NULL, errno, "Failed to listen on server socket."); + error_display_errno(NULL, NULL, errno, "Failed to listen on server socket."); networkinstall_free_data(data); return; diff --git a/source/ui/section/pendingtitles.c b/source/ui/section/pendingtitles.c index 70c5cf3..d72aca2 100644 --- a/source/ui/section/pendingtitles.c +++ b/source/ui/section/pendingtitles.c @@ -64,7 +64,7 @@ static void pendingtitles_action_update(ui_view* view, void* data, linked_list* static void pendingtitles_action_open(linked_list* items, list_item* selected) { pendingtitles_action_data* data = (pendingtitles_action_data*) calloc(1, sizeof(pendingtitles_action_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate pending titles action data."); + error_display(NULL, NULL, "Failed to allocate pending titles action data."); return; } @@ -112,14 +112,14 @@ static void pendingtitles_update(ui_view* view, void* data, linked_list* items, listData->populateData.items = items; Result res = task_populate_pending_titles(&listData->populateData); if(R_FAILED(res)) { - error_display_res(NULL, NULL, NULL, res, "Failed to initiate pending title list population."); + error_display_res(NULL, NULL, res, "Failed to initiate pending title list population."); } listData->populated = true; } if(listData->populateData.finished && R_FAILED(listData->populateData.result)) { - error_display_res(NULL, NULL, NULL, listData->populateData.result, "Failed to populate pending title list."); + error_display_res(NULL, NULL, listData->populateData.result, "Failed to populate pending title list."); listData->populateData.result = 0; } @@ -133,7 +133,7 @@ static void pendingtitles_update(ui_view* view, void* data, linked_list* items, void pendingtitles_open() { pendingtitles_data* data = (pendingtitles_data*) calloc(1, sizeof(pendingtitles_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate pending titles data."); + error_display(NULL, NULL, "Failed to allocate pending titles data."); return; } diff --git a/source/ui/section/qrinstall.c b/source/ui/section/qrinstall.c index 1a81614..3ff6f76 100644 --- a/source/ui/section/qrinstall.c +++ b/source/ui/section/qrinstall.c @@ -28,17 +28,25 @@ typedef struct { u32 tex; - u32 responseCode; - u64 currTitleId; - bool ticket; - bool cdn; + bool cdnDecided; + + u32 responseCode; + bool ticket; + u64 currTitleId; ticket_info ticketInfo; capture_cam_data captureInfo; data_op_data installInfo; } qr_install_data; +static void qrinstall_cdn_check_onresponse(ui_view* view, void* data, bool response) { + qr_install_data* qrInstallData = (qr_install_data*) data; + + qrInstallData->cdn = response; + qrInstallData->cdnDecided = true; +} + static Result qrinstall_is_src_directory(void* data, u32 index, bool* isDirectory) { *isDirectory = false; return 0; @@ -109,7 +117,19 @@ static Result qrinstall_open_dst(void* data, u32 index, void* initialReadBlock, Result res = 0; + qrInstallData->responseCode = 0; + qrInstallData->ticket = false; + qrInstallData->currTitleId = 0; + memset(&qrInstallData->ticketInfo, 0, sizeof(qrInstallData->ticketInfo)); + if(*(u16*) initialReadBlock == 0x0100) { + if(!qrInstallData->cdnDecided) { + ui_view* view = prompt_display("Optional", "Install ticket titles from CDN?", COLOR_TEXT, true, data, NULL, qrinstall_cdn_check_onresponse); + if(view != NULL) { + svcWaitSynchronization(view->active, U64_MAX); + } + } + qrInstallData->ticket = true; qrInstallData->ticketInfo.titleId = util_get_ticket_title_id((u8*) initialReadBlock); @@ -213,23 +233,24 @@ static bool qrinstall_error(void* data, u32 index, Result res) { } else { char* url = qrInstallData->urls[index]; - volatile bool dismissed = false; + ui_view* view = NULL; + if(res == R_FBI_HTTP_RESPONSE_CODE) { if(strlen(url) > 38) { - error_display(&dismissed, NULL, NULL, "Failed to install from URL.\n%.35s...\nHTTP server returned response code %d", url, qrInstallData->responseCode); + view = error_display(NULL, NULL, "Failed to install from URL.\n%.35s...\nHTTP server returned response code %d", url, qrInstallData->responseCode); } else { - error_display(&dismissed, NULL, NULL, "Failed to install from URL.\n%.38s\nHTTP server returned response code %d", url, qrInstallData->responseCode); + view = error_display(NULL, NULL, "Failed to install from URL.\n%.38s\nHTTP server returned response code %d", url, qrInstallData->responseCode); } } else { if(strlen(url) > 38) { - error_display_res(&dismissed, NULL, NULL, res, "Failed to install from URL.\n%.35s...", url); + view = error_display_res(NULL, NULL, res, "Failed to install from URL.\n%.35s...", url); } else { - error_display_res(&dismissed, NULL, NULL, res, "Failed to install from URL.\n%.38s", url); + view = error_display_res(NULL, NULL, res, "Failed to install from URL.\n%.38s", url); } } - while(!dismissed) { - svcSleepThread(1000000); + if(view != NULL) { + svcWaitSynchronization(view->active, U64_MAX); } } @@ -251,6 +272,14 @@ static void qrinstall_install_update(ui_view* view, void* data, float* progress, memset(qrInstallData->urls[i], '\0', URL_MAX); } + qrInstallData->cdn = false; + qrInstallData->cdnDecided = false; + + qrInstallData->responseCode = 0; + qrInstallData->ticket = false; + qrInstallData->currTitleId = 0; + memset(&qrInstallData->ticketInfo, 0, sizeof(qrInstallData->ticketInfo)); + return; } @@ -262,22 +291,16 @@ static void qrinstall_install_update(ui_view* view, void* data, float* progress, snprintf(text, PROGRESS_TEXT_MAX, "%lu / %lu\n%.2f %s / %.2f %s", qrInstallData->installInfo.processed, qrInstallData->installInfo.total, util_get_display_size(qrInstallData->installInfo.currProcessed), util_get_display_size_units(qrInstallData->installInfo.currProcessed), util_get_display_size(qrInstallData->installInfo.currTotal), util_get_display_size_units(qrInstallData->installInfo.currTotal)); } -static void qrinstall_cdn_check_onresponse(ui_view* view, void* data, bool response) { +static void qrinstall_confirm_onresponse(ui_view* view, void* data, bool response) { qr_install_data* qrInstallData = (qr_install_data*) data; - qrInstallData->cdn = response; - - Result res = task_data_op(&qrInstallData->installInfo); - if(R_SUCCEEDED(res)) { - info_display("Installing From URL(s)", "Press B to cancel.", true, data, qrinstall_install_update, NULL); - } else { - error_display_res(NULL, NULL, NULL, res, "Failed to initiate installation."); - } -} - -static void qrinstall_confirm_onresponse(ui_view* view, void* data, bool response) { if(response) { - prompt_display("Optional", "Install ticket titles from CDN?", COLOR_TEXT, true, data, NULL, qrinstall_cdn_check_onresponse); + Result res = task_data_op(&qrInstallData->installInfo); + if(R_SUCCEEDED(res)) { + info_display("Installing From URL(s)", "Press B to cancel.", true, data, qrinstall_install_update, NULL); + } else { + error_display_res(NULL, NULL, res, "Failed to initiate installation."); + } } } @@ -381,7 +404,7 @@ static void qrinstall_wait_update(ui_view* view, void* data, float* progress, ch info_destroy(view); if(R_FAILED(qrInstallData->captureInfo.result)) { - error_display_res(NULL, NULL, NULL, qrInstallData->captureInfo.result, "Error while capturing camera frames."); + error_display_res(NULL, NULL, qrInstallData->captureInfo.result, "Error while capturing camera frames."); } qrinstall_free_data(qrInstallData); @@ -439,16 +462,20 @@ static void qrinstall_wait_update(ui_view* view, void* data, float* progress, ch void qrinstall_open() { qr_install_data* data = (qr_install_data*) calloc(1, sizeof(qr_install_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate QR install data."); + error_display(NULL, NULL, "Failed to allocate QR install data."); return; } data->tex = 0; + data->cdn = false; + data->cdnDecided = false; + data->responseCode = 0; - data->currTitleId = 0; data->ticket = false; + data->currTitleId = 0; + memset(&data->ticketInfo, 0, sizeof(data->ticketInfo)); data->installInfo.data = data; @@ -488,14 +515,14 @@ void qrinstall_open() { data->qrContext = quirc_new(); if(data->qrContext == NULL) { - error_display(NULL, NULL, NULL, "Failed to create QR context."); + error_display(NULL, NULL, "Failed to create QR context."); qrinstall_free_data(data); return; } if(quirc_resize(data->qrContext, IMAGE_WIDTH, IMAGE_HEIGHT) != 0) { - error_display(NULL, NULL, NULL, "Failed to resize QR context."); + error_display(NULL, NULL, "Failed to resize QR context."); qrinstall_free_data(data); return; @@ -503,7 +530,7 @@ void qrinstall_open() { data->captureInfo.buffer = (u16*) calloc(1, IMAGE_WIDTH * IMAGE_HEIGHT * sizeof(u16)); if(data->captureInfo.buffer == NULL) { - error_display(NULL, NULL, NULL, "Failed to create image buffer."); + error_display(NULL, NULL, "Failed to create image buffer."); qrinstall_free_data(data); return; @@ -511,7 +538,7 @@ void qrinstall_open() { Result capRes = task_capture_cam(&data->captureInfo); if(R_FAILED(capRes)) { - error_display_res(NULL, NULL, NULL, capRes, "Failed to start camera capture."); + error_display_res(NULL, NULL, capRes, "Failed to start camera capture."); qrinstall_free_data(data); return; diff --git a/source/ui/section/systemsavedata.c b/source/ui/section/systemsavedata.c index 510c994..ca34c70 100644 --- a/source/ui/section/systemsavedata.c +++ b/source/ui/section/systemsavedata.c @@ -64,7 +64,7 @@ static void systemsavedata_action_update(ui_view* view, void* data, linked_list* static void systemsavedata_action_open(linked_list* items, list_item* selected) { systemsavedata_action_data* data = (systemsavedata_action_data*) calloc(1, sizeof(systemsavedata_action_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate system save data action data."); + error_display(NULL, NULL, "Failed to allocate system save data action data."); return; } @@ -112,14 +112,14 @@ static void systemsavedata_update(ui_view* view, void* data, linked_list* items, listData->populateData.items = items; Result res = task_populate_system_save_data(&listData->populateData); if(R_FAILED(res)) { - error_display_res(NULL, NULL, NULL, res, "Failed to initiate system save data list population."); + error_display_res(NULL, NULL, res, "Failed to initiate system save data list population."); } listData->populated = true; } if(listData->populateData.finished && R_FAILED(listData->populateData.result)) { - error_display_res(NULL, NULL, NULL, listData->populateData.result, "Failed to populate system save data list."); + error_display_res(NULL, NULL, listData->populateData.result, "Failed to populate system save data list."); listData->populateData.result = 0; } @@ -133,7 +133,7 @@ static void systemsavedata_update(ui_view* view, void* data, linked_list* items, void systemsavedata_open() { systemsavedata_data* data = (systemsavedata_data*) calloc(1, sizeof(systemsavedata_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate system save data data."); + error_display(NULL, NULL, "Failed to allocate system save data data."); return; } diff --git a/source/ui/section/tickets.c b/source/ui/section/tickets.c index 9d6f319..c86a2da 100644 --- a/source/ui/section/tickets.c +++ b/source/ui/section/tickets.c @@ -64,7 +64,7 @@ static void tickets_action_update(ui_view* view, void* data, linked_list* items, static void tickets_action_open(linked_list* items, list_item* selected) { tickets_action_data* data = (tickets_action_data*) calloc(1, sizeof(tickets_action_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate tickets action data."); + error_display(NULL, NULL, "Failed to allocate tickets action data."); return; } @@ -112,14 +112,14 @@ static void tickets_update(ui_view* view, void* data, linked_list* items, list_i listData->populateData.items = items; Result res = task_populate_tickets(&listData->populateData); if(R_FAILED(res)) { - error_display_res(NULL, NULL, NULL, res, "Failed to initiate ticket list population."); + error_display_res(NULL, NULL, res, "Failed to initiate ticket list population."); } listData->populated = true; } if(listData->populateData.finished && R_FAILED(listData->populateData.result)) { - error_display_res(NULL, NULL, NULL, listData->populateData.result, "Failed to populate ticket list."); + error_display_res(NULL, NULL, listData->populateData.result, "Failed to populate ticket list."); listData->populateData.result = 0; } @@ -133,7 +133,7 @@ static void tickets_update(ui_view* view, void* data, linked_list* items, list_i void tickets_open() { tickets_data* data = (tickets_data*) calloc(1, sizeof(tickets_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate tickets data."); + error_display(NULL, NULL, "Failed to allocate tickets data."); return; } diff --git a/source/ui/section/titles.c b/source/ui/section/titles.c index 500f0fb..31f1ef9 100644 --- a/source/ui/section/titles.c +++ b/source/ui/section/titles.c @@ -100,7 +100,7 @@ static void titles_action_update(ui_view* view, void* data, linked_list* items, static void titles_action_open(linked_list* items, list_item* selected) { titles_action_data* data = (titles_action_data*) calloc(1, sizeof(titles_action_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate titles action data."); + error_display(NULL, NULL, "Failed to allocate titles action data."); return; } @@ -202,14 +202,14 @@ static void titles_update(ui_view* view, void* data, linked_list* items, list_it listData->populateData.items = items; Result res = task_populate_titles(&listData->populateData); if(R_FAILED(res)) { - error_display_res(NULL, NULL, NULL, res, "Failed to initiate title list population."); + error_display_res(NULL, NULL, res, "Failed to initiate title list population."); } listData->populated = true; } if(listData->populateData.finished && R_FAILED(listData->populateData.result)) { - error_display_res(NULL, NULL, NULL, listData->populateData.result, "Failed to populate title list."); + error_display_res(NULL, NULL, listData->populateData.result, "Failed to populate title list."); listData->populateData.result = 0; } @@ -235,7 +235,7 @@ static bool titles_filter(void* data, u64 titleId, FS_MediaType mediaType) { void titles_open() { titles_data* data = (titles_data*) calloc(1, sizeof(titles_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate titles data."); + error_display(NULL, NULL, "Failed to allocate titles data."); return; } diff --git a/source/ui/section/update.c b/source/ui/section/update.c index 46a0858..62729f3 100644 --- a/source/ui/section/update.c +++ b/source/ui/section/update.c @@ -142,9 +142,9 @@ static bool update_error(void* data, u32 index, Result res) { if(res == R_FBI_CANCELLED) { prompt_display("Failure", "Install cancelled.", COLOR_TEXT, false, NULL, NULL, NULL); } else if(res == R_FBI_HTTP_RESPONSE_CODE) { - error_display(NULL, NULL, NULL, "Failed to update FBI.\nHTTP server returned response code %d", updateData->responseCode); + error_display(NULL, NULL, "Failed to update FBI.\nHTTP server returned response code %d", updateData->responseCode); } else { - error_display_res(NULL, NULL, NULL, res, "Failed to update FBI."); + error_display_res(NULL, NULL, res, "Failed to update FBI."); } return false; @@ -274,14 +274,14 @@ static void update_check_update(ui_view* view, void* data, float* progress, char if(R_SUCCEEDED(res = task_data_op(&updateData->installInfo))) { info_display("Updating FBI", "Press B to cancel.", true, data, update_install_update, NULL); } else { - error_display_res(NULL, NULL, NULL, res, "Failed to begin update."); + error_display_res(NULL, NULL, res, "Failed to begin update."); } } else { if(R_FAILED(res)) { if(res == R_FBI_HTTP_RESPONSE_CODE) { - error_display(NULL, NULL, NULL, "Failed to check for update.\nHTTP server returned response code %d", responseCode); + error_display(NULL, NULL, "Failed to check for update.\nHTTP server returned response code %d", responseCode); } else { - error_display_res(NULL, NULL, NULL, res, "Failed to check for update."); + error_display_res(NULL, NULL, res, "Failed to check for update."); } } else { prompt_display("Success", "No updates available.", COLOR_TEXT, false, NULL, NULL, NULL); @@ -302,7 +302,7 @@ static void update_onresponse(ui_view* view, void* data, bool response) { void update_open() { update_data* data = (update_data*) calloc(1, sizeof(update_data)); if(data == NULL) { - error_display(NULL, NULL, NULL, "Failed to allocate update check data."); + error_display(NULL, NULL, "Failed to allocate update check data."); return; } diff --git a/source/ui/ui.c b/source/ui/ui.c index 69ca43b..5986f99 100644 --- a/source/ui/ui.c +++ b/source/ui/ui.c @@ -3,6 +3,7 @@ #include #include <3ds.h> +#include #include "ui.h" #include "section/task/task.h" @@ -29,6 +30,31 @@ void ui_exit() { } } +ui_view* ui_create() { + ui_view* view = (ui_view*) calloc(1, sizeof(ui_view)); + if(view == NULL) { + util_panic("Failed to allocate UI view."); + return NULL; + } + + Result res = 0; + if(R_FAILED(res = svcCreateEvent(&view->active, 1))) { + util_panic("Failed to create view active event: 0x%08lX", res); + + free(view); + return NULL; + } + + return view; +} + +void ui_destroy(ui_view* view) { + if(view != NULL) { + svcCloseHandle(view->active); + free(view); + } +} + ui_view* ui_top() { svcWaitSynchronization(ui_stack_mutex, U64_MAX); @@ -52,6 +78,8 @@ bool ui_push(ui_view* view) { bool space = ui_stack_top < MAX_UI_VIEWS - 1; if(space) { ui_stack[++ui_stack_top] = view; + + svcClearEvent(view->active); } svcReleaseMutex(ui_stack_mutex); @@ -63,6 +91,8 @@ void ui_pop() { svcWaitSynchronization(ui_stack_mutex, U64_MAX); if(ui_stack_top >= 0) { + svcSignalEvent(ui_stack[ui_stack_top]->active); + ui_stack[ui_stack_top--] = NULL; } diff --git a/source/ui/ui.h b/source/ui/ui.h index ca22f97..d647b50 100644 --- a/source/ui/ui.h +++ b/source/ui/ui.h @@ -9,11 +9,16 @@ typedef struct ui_view_s { void (*update)(struct ui_view_s* view, void* data, float bx1, float by1, float bx2, float by2); void (*drawTop)(struct ui_view_s* view, void* data, float x1, float y1, float x2, float y2); void (*drawBottom)(struct ui_view_s* view, void* data, float x1, float y1, float x2, float y2); + + Handle active; } ui_view; void ui_init(); void ui_exit(); +ui_view* ui_create(); +void ui_destroy(ui_view* view); + ui_view* ui_top(); bool ui_push(ui_view* view); void ui_pop();