From dfb0566000ed08fe11c1502372385db5f7e32471 Mon Sep 17 00:00:00 2001 From: flb Date: Mon, 15 Feb 2021 15:19:49 +0100 Subject: [PATCH] few tweaks and added dialogue to delete /atmosphere/contents/ --- README.md | 4 +++- aiosu-forwarder/source/main.cpp | 14 ++++++++++---- include/utils.hpp | 3 ++- source/app_page.cpp | 2 +- source/confirm_page.cpp | 3 +-- source/download_cheats_page.cpp | 21 +++++++++++++++++++-- source/tools_tab.cpp | 10 +++------- source/utils.cpp | 30 +++++++++++++++++++++--------- 8 files changed, 60 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 1253daa..c621864 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # AIO-switch-updater ![releases](https://img.shields.io/github/downloads/HamletDuFromage/AIO-switch-updater/total) -![GitHub Workflow Status](https://img.shields.io/github/workflow/status/HamletDuFromage/AIO-switch-updater/Build%20AIO-switch-updater) + +[//]: + ![tag](https://img.shields.io/github/v/release/HamletDuFromage/AIO-switch-updater) ![GitHub](https://img.shields.io/github/license/HamletDuFromage/aio-switch-updater) diff --git a/aiosu-forwarder/source/main.cpp b/aiosu-forwarder/source/main.cpp index c24dd17..dd07538 100644 --- a/aiosu-forwarder/source/main.cpp +++ b/aiosu-forwarder/source/main.cpp @@ -9,9 +9,17 @@ #define PREFIX "/switch/aio-switch-updater/aio-switch-updater-v" #define FORWARDER_PATH "/config/aio-switch-updater/aiosu-forwarder.nro" +int removeDir(const char* path) +{ + Result ret = 0; + FsFileSystem *fs = fsdevGetDeviceFileSystem("sdmc"); + if (R_FAILED(ret = fsFsDeleteDirectoryRecursively(fs, path))) { + return ret; + } + return 0; +} int main(int argc, char* argv[]) - { std::filesystem::create_directory(PATH); for (const auto & entry : std::filesystem::directory_iterator(PATH)){ @@ -25,9 +33,7 @@ int main(int argc, char* argv[]) std::filesystem::create_directory(PATH); std::filesystem::remove(FULL_PATH); std::filesystem::rename(CONFIG_PATH, FULL_PATH); - std::filesystem::remove_all("/config/aio-switch-updater/switch/aio-switch-updater/"); - rmdir("/config/aio-switch-updater/switch/aio-switch-updater/"); - rmdir("/config/aio-switch-updater/switch/"); + removeDir("/config/aio-switch-updater/switch/"); } std::filesystem::remove(FORWARDER_PATH); diff --git a/include/utils.hpp b/include/utils.hpp index d1f70b1..1e957e9 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -37,4 +37,5 @@ Result CopyFile(const char src_path[FS_MAX_PATH], const char dest_path[FS_MAX_PA void saveVersion(std::string version, const char* path); std::string readVersion(const char* path); void cp(const char *to, const char *from); -std::string copyFiles(const char* path); \ No newline at end of file +std::string copyFiles(const char* path); +int removeDir(const char* path); \ No newline at end of file diff --git a/source/app_page.cpp b/source/app_page.cpp index 4e89e03..235d45d 100644 --- a/source/app_page.cpp +++ b/source/app_page.cpp @@ -55,7 +55,7 @@ AppPage::AppPage(const bool cheatSlips) : AppletFrame(true, true) continue; } - listItem = new brls::ListItem(formatListItemTitle(std::string(langEntry->name)), "", formatApplicationId(tid)); + listItem = new brls::ListItem(std::string(langEntry->name), "", formatApplicationId(tid)); listItem->setThumbnail(controlData.icon, sizeof(controlData.icon)); if(cheatSlips){ listItem->getClickEvent()->subscribe([&, tid](brls::View* view) { diff --git a/source/confirm_page.cpp b/source/confirm_page.cpp index 49ef455..c9840d1 100644 --- a/source/confirm_page.cpp +++ b/source/confirm_page.cpp @@ -26,8 +26,7 @@ ConfirmPage::ConfirmPage(brls::StagedAppletFrame* frame, std::string text, bool this->label->setHorizontalAlign(NVG_ALIGN_CENTER); this->label->setParent(this); - this->registerAction("menus/Back"_i18n , brls::Key::B, [this] { - brls::Application::popView(); + this->registerAction("", brls::Key::B, [this] { return true; }); } diff --git a/source/download_cheats_page.cpp b/source/download_cheats_page.cpp index 045b740..26d3ea8 100644 --- a/source/download_cheats_page.cpp +++ b/source/download_cheats_page.cpp @@ -109,7 +109,24 @@ DownloadCheatsPage::DownloadCheatsPage(uint64_t tid) : AppletFrame(true, true) dialog->open(); } } - if(error == 0) brls::Application::popView(); + if(error == 0) { + /* brls::Dialog* dialog = new brls::Dialog("menus/cheatslips_success"_i18n); + bool dialogResult = false; + bool result = false; + brls::GenericEvent::Callback callback = [dialog, &dialogResult](brls::View* view) { + dialogResult = true; + dialog->close(); + }; + dialog->addButton("menus/Ok_button"_i18n , callback); + dialog->setCancelable(true); + dialog->open(); + while(result == false){ + usleep(1); + result = dialogResult; + } + dialogResult = false; */ + brls::Application::popView(); + } return true; }); @@ -180,7 +197,7 @@ std::string DownloadCheatsPage::GetCheatsTitle(json cheat) { } res.erase(res.length() - 3); if(res.size() > 80){ - res = res.substr(0, 79) + "..."; + res = res.substr(0, 79) + "\u2026"; } return res; } diff --git a/source/tools_tab.cpp b/source/tools_tab.cpp index effacfd..71915d9 100644 --- a/source/tools_tab.cpp +++ b/source/tools_tab.cpp @@ -14,7 +14,6 @@ #include "json.hpp" #include #include -#include namespace i18n = brls::i18n; using namespace i18n::literals; @@ -179,12 +178,9 @@ ToolsTab::ToolsTab(std::string tag) : brls::List() std::filesystem::remove(FW_ZIP_PATH); std::filesystem::remove(CHEATS_ZIP_PATH); std::filesystem::remove(SIGPATCHES_ZIP_PATH); - std::filesystem::remove_all(AMS_DIRECTORY_PATH); - rmdir(AMS_DIRECTORY_PATH); - std::filesystem::remove_all(SEPT_DIRECTORY_PATH); - rmdir(SEPT_DIRECTORY_PATH); - std::filesystem::remove_all(FW_DIRECTORY_PATH); - rmdir(FW_DIRECTORY_PATH); + removeDir(AMS_DIRECTORY_PATH); + removeDir(SEPT_DIRECTORY_PATH); + removeDir(FW_DIRECTORY_PATH); brls::Dialog* dialog = new brls::Dialog("menus/All_done"_i18n); brls::GenericEvent::Callback callback = [dialog](brls::View* view) { dialog->close(); diff --git a/source/utils.cpp b/source/utils.cpp index f0da8b3..48654c6 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -8,6 +8,7 @@ #include "main_frame.hpp" #include #include +#include namespace i18n = brls::i18n; using namespace i18n::literals; @@ -77,12 +78,12 @@ void downloadArchive(std::string url, archiveType type){ } } -int dialogResult = -1; int showDialogBox(std::string text, std::string opt){ + int dialogResult = -1; int result = -1; brls::Dialog* dialog = new brls::Dialog(text); - brls::GenericEvent::Callback callback = [dialog](brls::View* view) { + brls::GenericEvent::Callback callback = [dialog, &dialogResult](brls::View* view) { dialogResult = 0; dialog->close(); }; @@ -93,18 +94,18 @@ int showDialogBox(std::string text, std::string opt){ usleep(1); result = dialogResult; } - dialogResult = -1; return result; } int showDialogBox(std::string text, std::string opt1, std::string opt2){ + int dialogResult = -1; int result = -1; brls::Dialog* dialog = new brls::Dialog(text); - brls::GenericEvent::Callback callback1 = [dialog](brls::View* view) { + brls::GenericEvent::Callback callback1 = [dialog, &dialogResult](brls::View* view) { dialogResult = 0; dialog->close(); }; - brls::GenericEvent::Callback callback2 = [dialog](brls::View* view) { + brls::GenericEvent::Callback callback2 = [dialog, &dialogResult](brls::View* view) { dialogResult = 1; dialog->close(); }; @@ -116,7 +117,6 @@ int showDialogBox(std::string text, std::string opt1, std::string opt2){ usleep(1); result = dialogResult; } - dialogResult = -1; return result; } @@ -128,8 +128,8 @@ void extractArchive(archiveType type, std::string tag){ switch(type){ case sigpatches: if(isArchive(SIGPATCHES_FILENAME)) { - std::string backup(HEKATE_IPL_PATH); - backup += ".old"; + /* std::string backup(HEKATE_IPL_PATH); + backup += ".old"; */ if(std::filesystem::exists(HEKATE_IPL_PATH)){ overwriteInis = showDialogBox("menus/utils_do"_i18n + std::string(HEKATE_IPL_PATH) +"?", "menus/utils_no"_i18n , "menus/utils_yes"_i18n ); if(overwriteInis == 0){ @@ -181,11 +181,14 @@ void extractArchive(archiveType type, std::string tag){ case ams_cfw: if(isArchive(AMS_FILENAME)){ overwriteInis = showDialogBox("menus/ultils_overwrite"_i18n , "menus/utils_no"_i18n , "menus/utils_yes"_i18n ); + if(showDialogBox("menus/ultils_overwrite"_i18n , "menus/utils_no"_i18n , "menus/utils_yes"_i18n) == 0) + removeDir(AMS_CONTENTS); extract(AMS_FILENAME, ROOT_PATH, overwriteInis); } + break; + } if(std::filesystem::exists(MOVE_FILES_JSON)) copyFiles(MOVE_FILES_JSON); - } } void progressTest(std::string url, archiveType type){ @@ -384,3 +387,12 @@ std::string copyFiles(const char* path) { } return error; } + +int removeDir(const char* path) { + Result ret = 0; + FsFileSystem *fs = fsdevGetDeviceFileSystem("sdmc"); + if (R_FAILED(ret = fsFsDeleteDirectoryRecursively(fs, path))) { + return ret; + } + return 0; +}