1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-11-08 11:31:43 +00:00

Added tool to automatically copy files

This commit is contained in:
flb 2021-02-12 23:20:16 +01:00
parent 618fde49dd
commit 3cf43a5445
13 changed files with 89 additions and 36 deletions

View file

@ -22,7 +22,7 @@ DATA := data
INCLUDES := include lib/zipper/include
APP_TITLE := All-in-One Switch Updater
APP_AUTHOR := HamletDuFromage
APP_VERSION := 2.2.1
APP_VERSION := 2.3.0
TARGET := $(notdir $(CURDIR))
ROMFS := resources

View file

@ -18,5 +18,5 @@ class AppPage : public brls::AppletFrame
std::set<std::string> titles;
public:
AppPage(bool cheatSlips = false);
AppPage(const bool cheatSlips = false);
};

View file

@ -76,6 +76,7 @@
#define FW_DIRECTORY_PATH "/firmware/"
#define HIDE_TABS_JSON "/config/aio-switch-updater/hide_tabs.json"
#define MOVE_FILES_JSON "/config/aio-switch-updater/move_files.json"
#define ROMFS_FORWARDER "romfs:/aiosu-forwarder.nro"
#define FORWARDER_PATH "/config/aio-switch-updater/aiosu-forwarder.nro"

View file

@ -4,4 +4,4 @@
bool isServiceRunning(const char *serviceName);
CFW getCFW();
extern CFW running_cfw;
const extern CFW running_cfw;

View file

@ -12,6 +12,6 @@ class ListDownloadTab : public brls::List
brls::Label *description;
brls::Label *cheatSlipLabel;
public:
ListDownloadTab(archiveType type);
ListDownloadTab(const archiveType type);
~ListDownloadTab();
};

View file

@ -16,8 +16,9 @@ class ToolsTab : public brls::List
brls::ListItem* language;
brls::ListItem* cleanUp;
brls::ListItem* hideTabs;
brls::ListItem* ntcp;
//brls::ListItem* ntcp;
brls::ListItem* netSettings;
brls::ListItem* moveFiles;
brls::ListItem* browser;
brls::StagedAppletFrame* stagedFrame;

4
move_files.json Normal file
View file

@ -0,0 +1,4 @@
{
/* "source/path/to/file": "/destination/path/to/file", */
"/atmosphere/reboot_payload.bin": "/bootloader/payloads/payload.bin"
}

View file

@ -229,7 +229,11 @@
"net_settings": "Internet settings",
"go_back" : "Go back",
"Confirm_button" : "Confirm",
"Cancel_button" : "Cancel"
"Cancel_button" : "Cancel",
"tool_copyFiles": "Batch copy files",
"files_not_found": "The following files were not found and couldn't be copied:\n",
"move_files_not_found": ""

View file

@ -10,7 +10,7 @@
namespace i18n = brls::i18n;
using namespace i18n::literals;
AppPage::AppPage(bool cheatSlips) : AppletFrame(true, true)
AppPage::AppPage(const bool cheatSlips) : AppletFrame(true, true)
{
this->setTitle(cheatSlips ? "menus/cheastlips_title"_i18n : "menus/app_title"_i18n );
list = new brls::List();

View file

@ -13,7 +13,7 @@
namespace i18n = brls::i18n;
using namespace i18n::literals;
ListDownloadTab::ListDownloadTab(archiveType type) :
ListDownloadTab::ListDownloadTab(const archiveType type) :
brls::List()
{
std::vector<std::pair<std::string, std::string>> links;

View file

@ -13,7 +13,7 @@ using namespace i18n::literals;
//TimeServiceType __nx_time_service_type = TimeServiceType_System;
CFW running_cfw = getCFW();
const CFW running_cfw = getCFW();
int main(int argc, char* argv[])
{

View file

@ -11,12 +11,41 @@
#include "extract.hpp"
#include "utils.hpp"
#include "hide_tabs_page.hpp"
#include "json.hpp"
#include <filesystem>
#include <fstream>
#include <iostream>
namespace i18n = brls::i18n;
using namespace i18n::literals;
using json = nlohmann::json;
ToolsTab::ToolsTab(std::string tag) : brls::List()
{
if(!tag.empty() && tag != APP_VERSION){
updateApp = new brls::ListItem("menus/tool_update"_i18n + tag +")");
std::string text("menus/tool_DownLoad"_i18n + std::string(APP_URL));
updateApp->getClickEvent()->subscribe([&, text, tag](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("menus/tool_updating"_i18n );
stagedFrame->addStage(
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/tool_downloading"_i18n , [](){downloadArchive(APP_URL, app);})
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/tool_extracting"_i18n , [tag](){extractArchive(app, tag);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "menus/tool_all_done"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
updateApp->setHeight(LISTITEM_HEIGHT);
this->addView(updateApp);
}
cheats = new brls::ListItem("menus/tool_cheats"_i18n );
cheats->getClickEvent()->subscribe([&](brls::View* view){
brls::Application::pushView(new CheatsPage());
@ -121,6 +150,45 @@ ToolsTab::ToolsTab(std::string tag) : brls::List()
browser->setHeight(LISTITEM_HEIGHT);
this->addView(browser);
moveFiles = new brls::ListItem("menus/tool_copyFiles"_i18n );
moveFiles->getClickEvent()->subscribe([&](brls::View* view){
chdir("/");
std::string error = "";
if(std::filesystem::exists(MOVE_FILES_JSON)){
json toMove;
std::ifstream f(MOVE_FILES_JSON);
f >> toMove;
f.close();
for (auto it = toMove.begin(); it != toMove.end(); ++it) {
if(std::filesystem::exists(it.key())) {
createTree(std::string(std::filesystem::path(it.value().get<std::string>()).parent_path()) + "/");
cp(it.key().c_str(), it.value().get<std::string>().c_str());
}
else {
error += it.key() + "\n";
}
}
if(error == "") {
error = "menus/All_done"_i18n;
}
else {
error = "menus/files_not_found"_i18n + error;
}
}
else{
error = "menus/move_files_not_found"_i18n;
}
brls::Dialog* dialog = new brls::Dialog(error);
brls::GenericEvent::Callback callback = [dialog](brls::View* view) {
dialog->close();
};
dialog->addButton("menus/Ok_button"_i18n , callback);
dialog->setCancelable(true);
dialog->open();
});
moveFiles->setHeight(LISTITEM_HEIGHT);
this->addView(moveFiles);
cleanUp = new brls::ListItem("menus/tool_cleanUp"_i18n );
cleanUp->getClickEvent()->subscribe([&](brls::View* view){
std::filesystem::remove(AMS_ZIP_PATH);
@ -152,31 +220,6 @@ ToolsTab::ToolsTab(std::string tag) : brls::List()
});
hideTabs->setHeight(LISTITEM_HEIGHT);
this->addView(hideTabs);
//tag = "1.TEST"
if(!tag.empty() && tag != APP_VERSION){
updateApp = new brls::ListItem("menus/tool_update"_i18n + tag +")");
std::string text("menus/tool_DownLoad"_i18n + std::string(APP_URL));
updateApp->getClickEvent()->subscribe([&, text, tag](brls::View* view) {
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("menus/tool_updating"_i18n );
stagedFrame->addStage(
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/tool_downloading"_i18n , [](){downloadArchive(APP_URL, app);})
);
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/tool_extracting"_i18n , [tag](){extractArchive(app, tag);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "menus/tool_all_done"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
updateApp->setHeight(LISTITEM_HEIGHT);
this->addView(updateApp);
}
changelog = new brls::ListItem("menus/tool_changelog"_i18n );
changelog->getClickEvent()->subscribe([&](brls::View* view){

View file

@ -63,8 +63,8 @@ void downloadArchive(std::string url, archiveType type){
downloadFile(url.c_str(), FIRMWARE_FILENAME, OFF);
}
else{
showDialogBox("menus/utils_because"_i18n , "utils_ok"_i18n );
brls::Application::pushView(new MainFrame());
showDialogBox("menus/utils_because"_i18n , "menus/utils_ok"_i18n );
brls::Application::popView();
}
break;
case app: