diff --git a/README.md b/README.md index f9fb508..0210ae5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ ![releases](https://img.shields.io/github/downloads/HamletDuFromage/AIO-switch-updater/total) ![tag](https://img.shields.io/github/v/release/HamletDuFromage/AIO-switch-updater) ![GitHub](https://img.shields.io/github/license/HamletDuFromage/aio-switch-updater) -[![ko-fi](https://img.shields.io/badge/paypal-donate-blue)](https://www.paypal.com/donate?token=El4U5IrRyplctLb9D0jcbitsx-B0oOoWcyetXtaG0hHfIDsruvhUMKqKKR4fz_TzYwvj3tugFhrux_3j) + +[//]: ([![ko-fi](https://img.shields.io/badge/ko--fi-buy%20me%20a%20coffee-ff69b4)](https://ko-fi.com/hamletdufromage)) All-in-One Nintendo Switch Updater @@ -46,13 +47,6 @@ Downloads and extracts daily-updated cheat code. The program will only extract c ## Disclaimer I do not own, host nor distribute any of the files that can be downloaded with this homebrew tool. At the owner's request, I will immediately remove the ability to download the problematic files. -## Like the app? - -
- - - - -
- +### Like the app? +[//]: [![5cbed8a433a3f45a772abaf5_SupportMe_blue-p-500](https://user-images.githubusercontent.com/61667930/93899702-1a2b2680-fce4-11ea-9eaa-4e2b44eebe86.png)](https://ko-fi.com/hamletdufromage) diff --git a/include/changelog_page.hpp b/include/changelog_page.hpp new file mode 100644 index 0000000..be676fd --- /dev/null +++ b/include/changelog_page.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include + +class ChangelogPage : public brls::AppletFrame +{ + private: + brls::List* list; + std::vector items; + + public: + ChangelogPage(); +}; \ No newline at end of file diff --git a/include/constants.hpp b/include/constants.hpp index a7af3b3..5582094 100644 --- a/include/constants.hpp +++ b/include/constants.hpp @@ -40,6 +40,7 @@ #define PAYLOAD_PATH "/payloads/" #define BOOTLOADER_PL_PATH "/bootloader/payloads/" +#define REBOOT_PAYLOAD_PATH "/atmosphere/reboot_payload.bin" enum archiveType{ diff --git a/include/tools_tab.hpp b/include/tools_tab.hpp index 695a20b..50b3764 100644 --- a/include/tools_tab.hpp +++ b/include/tools_tab.hpp @@ -6,6 +6,7 @@ #include "app_page.hpp" #include "payload_page.hpp" #include "download_payload_page.hpp" +#include "changelog_page.hpp" #include "JC_page.hpp" #include "extract.hpp" #include "utils.hpp" @@ -20,6 +21,7 @@ class ToolsTab : public brls::List brls::ListItem* updateApp; brls::ListItem* rebootPayload; brls::ListItem* downloadPaysload; + brls::ListItem* changelog; brls::StagedAppletFrame* stagedFrame; public: diff --git a/include/utils.hpp b/include/utils.hpp index ab56e9f..97e114e 100644 --- a/include/utils.hpp +++ b/include/utils.hpp @@ -26,4 +26,5 @@ std::vector fetchPayloads(); void shut_down(bool reboot = false); int showDialogBox(std::string text, std::string opt); int showDialogBox(std::string text, std::string opt1, std::string opt2); -std::string getLatestTag(const char *url); \ No newline at end of file +std::string getLatestTag(const char *url); +Result CopyFile(const char src_path[FS_MAX_PATH], const char dest_path[FS_MAX_PATH]); \ No newline at end of file diff --git a/source/changelog_page.cpp b/source/changelog_page.cpp new file mode 100644 index 0000000..4be6388 --- /dev/null +++ b/source/changelog_page.cpp @@ -0,0 +1,48 @@ +#include "changelog_page.hpp" + +ChangelogPage::ChangelogPage() : AppletFrame(true, true) +{ + this->setTitle("Changelog"); + list = new brls::List(); + std::vector verTitles; + std::string change; + std::vector changes; + + verTitles.push_back("v1.0.1"); + changes.push_back("\uE016 Added dialogue box asking about ini files.\n"\ + "\uE016 Fixed update app link when not connected to the internet.\n"\ + "\uE016 Minor fixes here and there."); + + verTitles.push_back("v1.0.2"); + changes.push_back("\uE016 Fixed .ini files being handled poorly when installing sigpatches. Now prompts the user if they want to replace hetake_ipl.ini."); + + verTitles.push_back("v1.0.3"); + changes.push_back("\uE016 Fixed progress bar sometimes being stuck when extracting."); + + verTitles.push_back("v1.1.0"); + changes.push_back("\uE016 Added an option to download payloads to /bootloader/payloads.\n"\ + "\uE016 Cleaned up some stuff, made .ini overwriting cleaner.\n"); + + verTitles.push_back("v1.1.1"); + changes.push_back("\uE016 Added some safety checks before downloading/extracting.\n"\ + "\uE016 Added the possibility to copy a payload to '/atmosphere/reboot_payload.bin'\n"\ + "\uE016 Added changelog in 'Tools'\n"); + + int nbVersions = verTitles.size(); + items.reserve(nbVersions); + for(int i = nbVersions -1 ; i >= 0; i--){ + items[i] = new brls::ListItem(verTitles[i]); + change = changes[i]; + items[i]->getClickEvent()->subscribe([&, change](brls::View* view){ + brls::Dialog* dialog = new brls::Dialog(change); + brls::GenericEvent::Callback callback = [dialog](brls::View* view) { + dialog->close(); + }; + dialog->addButton("Ok", callback); + dialog->setCancelable(true); + dialog->open(); + }); + list->addView(items[i]); + } + this->setContentView(list); +} \ No newline at end of file diff --git a/source/download_payload_page.cpp b/source/download_payload_page.cpp index 9231d3a..7c6c0e8 100644 --- a/source/download_payload_page.cpp +++ b/source/download_payload_page.cpp @@ -46,6 +46,11 @@ DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true) ); notFound->setHorizontalAlign(NVG_ALIGN_CENTER); list->addView(notFound); + brls::ListItem* back = new brls::ListItem("Back"); + back->getClickEvent()->subscribe([&](brls::View* view) { + brls::Application::popView(); + }); + list->addView(back); } this->setContentView(list); } \ No newline at end of file diff --git a/source/list_download_tab.cpp b/source/list_download_tab.cpp index eaa7762..4f1bbb7 100644 --- a/source/list_download_tab.cpp +++ b/source/list_download_tab.cpp @@ -63,8 +63,8 @@ ListDownloadTab::ListDownloadTab(archiveType type) : ); break; } - std::get<0>(links).push_back("Test"); - std::get<1>(links).push_back("https://github.com"); +/* std::get<0>(links).push_back("Test"); + std::get<1>(links).push_back("https://github.com"); */ this->addView(description); int nbLinks = std::get<0>(links).size(); diff --git a/source/payload_page.cpp b/source/payload_page.cpp index 7097276..2415b32 100644 --- a/source/payload_page.cpp +++ b/source/payload_page.cpp @@ -2,7 +2,7 @@ PayloadPage::PayloadPage() : AppletFrame(true, true) { - + CFW cfw = getCFW(); this->setTitle("Reboot menu"); list = new brls::List(); label = new brls::Label( @@ -21,7 +21,22 @@ PayloadPage::PayloadPage() : AppletFrame(true, true) reboot_to_payload(payload.c_str()); brls::Application::popView(); }); + if(cfw == ams){ + items[i]->registerAction("Set as reboot_payload.bin", brls::Key::X, [this, payload] { + if(R_SUCCEEDED(CopyFile(payload.c_str(), REBOOT_PAYLOAD_PATH))){ + brls::Dialog* dialog = new brls::Dialog("Successfully copied '" + payload + "' to '" + std::string(REBOOT_PAYLOAD_PATH) + "'."); + brls::GenericEvent::Callback callback = [dialog](brls::View* view) { + dialog->close(); + }; + dialog->addButton("Ok", callback); + dialog->setCancelable(true); + dialog->open(); + } + return true; + }); + } list->addView(items[i]); + } list->addView(new brls::ListItemGroupSpacing(true)); @@ -38,6 +53,7 @@ PayloadPage::PayloadPage() : AppletFrame(true, true) brls::Application::popView(); }); list->addView(reboot); + this->setContentView(list); } \ No newline at end of file diff --git a/source/tools_tab.cpp b/source/tools_tab.cpp index 38cd8cb..4a1b35e 100644 --- a/source/tools_tab.cpp +++ b/source/tools_tab.cpp @@ -37,7 +37,7 @@ ToolsTab::ToolsTab() : brls::List() }); this->addView(downloadPaysload); - rebootPayload = new brls::ListItem("Shut down / Inject payload"); + rebootPayload = new brls::ListItem("Inject payload"); rebootPayload->getClickEvent()->subscribe([&](brls::View* view){ brls::Application::pushView(new PayloadPage()); }); @@ -66,4 +66,10 @@ ToolsTab::ToolsTab() : brls::List() }); this->addView(updateApp); } + + changelog = new brls::ListItem("Changelog"); + changelog->getClickEvent()->subscribe([&](brls::View* view){ + brls::Application::pushView(new ChangelogPage()); + }); + this->addView(changelog); } \ No newline at end of file diff --git a/source/utils.cpp b/source/utils.cpp index 8623620..8b78590 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -264,4 +264,67 @@ std::string getLatestTag(const char *url){ catch (...){ return ""; } +} + +Result CopyFile(const char src_path[FS_MAX_PATH], const char dest_path[FS_MAX_PATH]) { + FsFileSystem *fs; + Result ret = 0; + FsFile src_handle, dest_handle; + int PREVIOUS_BROWSE_STATE = 0; + FsFileSystem devices[4]; + devices[0] = *fsdevGetDeviceFileSystem("sdmc"); + fs = &devices[0]; + + ret = fsFsOpenFile(&devices[PREVIOUS_BROWSE_STATE], src_path, FsOpenMode_Read, &src_handle); + if (R_FAILED(ret)) { + return ret; + } + + s64 size = 0; + ret = fsFileGetSize(&src_handle, &size); + if (R_FAILED(ret)){ + fsFileClose(&src_handle); + return ret; + } + + if (!std::filesystem::exists(dest_path)) + fsFsCreateFile(fs, dest_path, size, 0); + + ret = fsFsOpenFile(fs, dest_path, FsOpenMode_Write, &dest_handle); + if (R_FAILED(ret)){ + fsFileClose(&src_handle); + return ret; + } + + uint64_t bytes_read = 0; + const u64 buf_size = 0x10000; + s64 offset = 0; + unsigned char *buf = new unsigned char[buf_size]; + std::string filename = std::filesystem::path(src_path).filename(); + + do { + std::memset(buf, 0, buf_size); + + ret = fsFileRead(&src_handle, offset, buf, buf_size, FsReadOption_None, &bytes_read); + if (R_FAILED(ret)) { + delete[] buf; + fsFileClose(&src_handle); + fsFileClose(&dest_handle); + return ret; + } + ret = fsFileWrite(&dest_handle, offset, buf, bytes_read, FsWriteOption_Flush); + if (R_FAILED(ret)) { + delete[] buf; + fsFileClose(&src_handle); + fsFileClose(&dest_handle); + return ret; + } + + offset += bytes_read; + } while(offset < size); + + delete[] buf; + fsFileClose(&src_handle); + fsFileClose(&dest_handle); + return 0; } \ No newline at end of file