mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2025-01-01 12:16:02 +00:00
Added safety checks, set default payload and changelog
This commit is contained in:
parent
025bcc2ed0
commit
250c1a9f29
11 changed files with 164 additions and 15 deletions
14
README.md
14
README.md
|
@ -2,7 +2,8 @@
|
||||||
![releases](https://img.shields.io/github/downloads/HamletDuFromage/AIO-switch-updater/total)
|
![releases](https://img.shields.io/github/downloads/HamletDuFromage/AIO-switch-updater/total)
|
||||||
![tag](https://img.shields.io/github/v/release/HamletDuFromage/AIO-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)
|
![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
|
All-in-One Nintendo Switch Updater
|
||||||
|
@ -46,13 +47,6 @@ Downloads and extracts daily-updated cheat code. The program will only extract c
|
||||||
## Disclaimer
|
## 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.
|
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?
|
||||||
|
|
||||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
|
||||||
<input type="hidden" name="cmd" value="_s-xclick" />
|
|
||||||
<input type="hidden" name="hosted_button_id" value="L6LJAV6FVHNKA" />
|
|
||||||
<input type="image" src="https://www.paypalobjects.com/en_US/FR/i/btn/btn_donateCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" />
|
|
||||||
<img alt="" border="0" src="https://www.paypal.com/en_FR/i/scr/pixel.gif" width="1" height="1" />
|
|
||||||
</form>
|
|
||||||
|
|
||||||
|
|
||||||
|
[//]: [![5cbed8a433a3f45a772abaf5_SupportMe_blue-p-500](https://user-images.githubusercontent.com/61667930/93899702-1a2b2680-fce4-11ea-9eaa-4e2b44eebe86.png)](https://ko-fi.com/hamletdufromage)
|
||||||
|
|
13
include/changelog_page.hpp
Normal file
13
include/changelog_page.hpp
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <borealis.hpp>
|
||||||
|
|
||||||
|
class ChangelogPage : public brls::AppletFrame
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
brls::List* list;
|
||||||
|
std::vector<brls::ListItem*> items;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ChangelogPage();
|
||||||
|
};
|
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
#define PAYLOAD_PATH "/payloads/"
|
#define PAYLOAD_PATH "/payloads/"
|
||||||
#define BOOTLOADER_PL_PATH "/bootloader/payloads/"
|
#define BOOTLOADER_PL_PATH "/bootloader/payloads/"
|
||||||
|
#define REBOOT_PAYLOAD_PATH "/atmosphere/reboot_payload.bin"
|
||||||
|
|
||||||
|
|
||||||
enum archiveType{
|
enum archiveType{
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "app_page.hpp"
|
#include "app_page.hpp"
|
||||||
#include "payload_page.hpp"
|
#include "payload_page.hpp"
|
||||||
#include "download_payload_page.hpp"
|
#include "download_payload_page.hpp"
|
||||||
|
#include "changelog_page.hpp"
|
||||||
#include "JC_page.hpp"
|
#include "JC_page.hpp"
|
||||||
#include "extract.hpp"
|
#include "extract.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
@ -20,6 +21,7 @@ class ToolsTab : public brls::List
|
||||||
brls::ListItem* updateApp;
|
brls::ListItem* updateApp;
|
||||||
brls::ListItem* rebootPayload;
|
brls::ListItem* rebootPayload;
|
||||||
brls::ListItem* downloadPaysload;
|
brls::ListItem* downloadPaysload;
|
||||||
|
brls::ListItem* changelog;
|
||||||
brls::StagedAppletFrame* stagedFrame;
|
brls::StagedAppletFrame* stagedFrame;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -26,4 +26,5 @@ std::vector<std::string> fetchPayloads();
|
||||||
void shut_down(bool reboot = false);
|
void shut_down(bool reboot = false);
|
||||||
int showDialogBox(std::string text, std::string opt);
|
int showDialogBox(std::string text, std::string opt);
|
||||||
int showDialogBox(std::string text, std::string opt1, std::string opt2);
|
int showDialogBox(std::string text, std::string opt1, std::string opt2);
|
||||||
std::string getLatestTag(const char *url);
|
std::string getLatestTag(const char *url);
|
||||||
|
Result CopyFile(const char src_path[FS_MAX_PATH], const char dest_path[FS_MAX_PATH]);
|
48
source/changelog_page.cpp
Normal file
48
source/changelog_page.cpp
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#include "changelog_page.hpp"
|
||||||
|
|
||||||
|
ChangelogPage::ChangelogPage() : AppletFrame(true, true)
|
||||||
|
{
|
||||||
|
this->setTitle("Changelog");
|
||||||
|
list = new brls::List();
|
||||||
|
std::vector<std::string> verTitles;
|
||||||
|
std::string change;
|
||||||
|
std::vector<std::string> 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);
|
||||||
|
}
|
|
@ -46,6 +46,11 @@ DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true)
|
||||||
);
|
);
|
||||||
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
|
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
|
||||||
list->addView(notFound);
|
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);
|
this->setContentView(list);
|
||||||
}
|
}
|
|
@ -63,8 +63,8 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
std::get<0>(links).push_back("Test");
|
/* std::get<0>(links).push_back("Test");
|
||||||
std::get<1>(links).push_back("https://github.com");
|
std::get<1>(links).push_back("https://github.com"); */
|
||||||
this->addView(description);
|
this->addView(description);
|
||||||
|
|
||||||
int nbLinks = std::get<0>(links).size();
|
int nbLinks = std::get<0>(links).size();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
PayloadPage::PayloadPage() : AppletFrame(true, true)
|
PayloadPage::PayloadPage() : AppletFrame(true, true)
|
||||||
{
|
{
|
||||||
|
CFW cfw = getCFW();
|
||||||
this->setTitle("Reboot menu");
|
this->setTitle("Reboot menu");
|
||||||
list = new brls::List();
|
list = new brls::List();
|
||||||
label = new brls::Label(
|
label = new brls::Label(
|
||||||
|
@ -21,7 +21,22 @@ PayloadPage::PayloadPage() : AppletFrame(true, true)
|
||||||
reboot_to_payload(payload.c_str());
|
reboot_to_payload(payload.c_str());
|
||||||
brls::Application::popView();
|
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(items[i]);
|
||||||
|
|
||||||
}
|
}
|
||||||
list->addView(new brls::ListItemGroupSpacing(true));
|
list->addView(new brls::ListItemGroupSpacing(true));
|
||||||
|
|
||||||
|
@ -38,6 +53,7 @@ PayloadPage::PayloadPage() : AppletFrame(true, true)
|
||||||
brls::Application::popView();
|
brls::Application::popView();
|
||||||
});
|
});
|
||||||
list->addView(reboot);
|
list->addView(reboot);
|
||||||
|
|
||||||
this->setContentView(list);
|
this->setContentView(list);
|
||||||
|
|
||||||
}
|
}
|
|
@ -37,7 +37,7 @@ ToolsTab::ToolsTab() : brls::List()
|
||||||
});
|
});
|
||||||
this->addView(downloadPaysload);
|
this->addView(downloadPaysload);
|
||||||
|
|
||||||
rebootPayload = new brls::ListItem("Shut down / Inject payload");
|
rebootPayload = new brls::ListItem("Inject payload");
|
||||||
rebootPayload->getClickEvent()->subscribe([&](brls::View* view){
|
rebootPayload->getClickEvent()->subscribe([&](brls::View* view){
|
||||||
brls::Application::pushView(new PayloadPage());
|
brls::Application::pushView(new PayloadPage());
|
||||||
});
|
});
|
||||||
|
@ -66,4 +66,10 @@ ToolsTab::ToolsTab() : brls::List()
|
||||||
});
|
});
|
||||||
this->addView(updateApp);
|
this->addView(updateApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changelog = new brls::ListItem("Changelog");
|
||||||
|
changelog->getClickEvent()->subscribe([&](brls::View* view){
|
||||||
|
brls::Application::pushView(new ChangelogPage());
|
||||||
|
});
|
||||||
|
this->addView(changelog);
|
||||||
}
|
}
|
|
@ -264,4 +264,67 @@ std::string getLatestTag(const char *url){
|
||||||
catch (...){
|
catch (...){
|
||||||
return "";
|
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;
|
||||||
}
|
}
|
Loading…
Reference in a new issue