1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2025-01-30 10:03:46 +00:00

headers cleanup

This commit is contained in:
flb 2021-02-10 17:28:47 +01:00
parent db07d8f165
commit 7baa9e1350
50 changed files with 208 additions and 249 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.1.2
APP_VERSION := 2.2.0
TARGET := $(notdir $(CURDIR))
ROMFS := resources

View file

@ -1,16 +1,5 @@
#pragma once
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <filesystem>
#include <tuple>
#include <switch.h>
#include "constants.hpp"
#include "progress_event.hpp"
#include "utils.hpp"
#include "json.hpp"
int hexToBGR(std::string hex);

View file

@ -1,8 +1,6 @@
#pragma once
#include "JC_color_swapper.hpp"
#include "confirm_page.hpp"
#include "worker_page.hpp"
#include <borealis.hpp>
class JCPage : public brls::AppletFrame
{

View file

@ -1,16 +1,5 @@
#pragma once
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <filesystem>
#include <tuple>
#include <switch.h>
#include "constants.hpp"
#include "progress_event.hpp"
#include "utils.hpp"
#include "json.hpp"
namespace pc{

View file

@ -1,8 +1,6 @@
#pragma once
#include "PC_color_swapper.hpp"
#include "confirm_page.hpp"
#include "worker_page.hpp"
#include <borealis.hpp>
class PCPage : public brls::AppletFrame
{

View file

@ -1,12 +1,6 @@
#pragma once
#include <borealis.hpp>
#include <string>
#include "download.hpp"
#include "extract.hpp"
#include "confirm_page.hpp"
#include "dialogue_page.hpp"
#include "worker_page.hpp"
class AmsTab : public brls::List
{

View file

@ -1,15 +1,8 @@
#pragma once
#include <borealis.hpp>
#include <switch.h>
#include "utils.hpp"
#include <filesystem>
#include <fstream>
#include <algorithm>
#include "worker_page.hpp"
#include "confirm_page.hpp"
#include "download_cheats_page.hpp"
#include <set>
typedef struct app App;

View file

@ -1,8 +1,6 @@
#pragma once
#include <borealis.hpp>
#include "app_page.hpp"
#include "exclude_page.hpp"
class CheatsPage : public brls::AppletFrame
{

View file

@ -2,11 +2,6 @@
#include <borealis.hpp>
#include <chrono>
#include <algorithm>
#include "utils.hpp"
#include "main_frame.hpp"
#include "reboot_payload.h"
class ConfirmPage : public brls::View
{

7
include/current_cfw.hpp Normal file
View file

@ -0,0 +1,7 @@
#pragma once
#include "constants.hpp"
bool isServiceRunning(const char *serviceName);
CFW getCFW();
static CFW running_cfw = ams;

View file

@ -2,10 +2,6 @@
#include <borealis.hpp>
#include <utils.hpp>
#include "reboot_payload.h"
class DialoguePage : public brls::View
{
private:

View file

@ -3,15 +3,6 @@
#define ON 1
#define OFF 0
#include <time.h>
#include <math.h>
#include <curl/curl.h>
#include <string>
#include <regex>
#include <switch.h>
#include "progress_event.hpp"
#include "json.hpp"
void downloadFile(const char *url, const char *output, int api);

View file

@ -2,8 +2,6 @@
#include <borealis.hpp>
#include <switch.h>
#include "download.hpp"
#include "utils.hpp"
#include "json.hpp"
class DownloadCheatsPage : public brls::AppletFrame

View file

@ -1,8 +1,6 @@
#pragma once
#include "utils.hpp"
#include "confirm_page.hpp"
#include "worker_page.hpp"
#include <borealis.hpp>
class DownloadPayloadPage : public brls::AppletFrame
{

View file

@ -1,14 +1,8 @@
#pragma once
#include <borealis.hpp>
#include <switch.h>
#include "utils.hpp"
#include <filesystem>
#include <fstream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <set>
typedef struct app App;

View file

@ -1,22 +1,10 @@
#pragma once
#include "constants.hpp"
#include <switch.h>
#include <set>
#include <string>
#include <vector>
#include <switch.h>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <iterator>
#include <filesystem>
#include <fstream>
#include <set>
#include <unzipper.h>
#include <borealis.hpp>
#include "progress_event.hpp"
#include "constants.hpp"
static constexpr u32 MaxTitleCount = 64000;

View file

@ -1,9 +1,6 @@
#pragma once
#include <borealis.hpp>
#include "json.hpp"
#include "constants.hpp"
#include <fstream>
class HideTabsPage : public brls::AppletFrame
{

View file

@ -1,19 +0,0 @@
#pragma once
#include <borealis.hpp>
#include "app_page.hpp"
#include "exclude_page.hpp"
class LanguageOptionPage : public brls::AppletFrame
{
private:
brls::List* list;
brls::ListItem* English;
brls::ListItem* Chinese;
brls::ListItem* French;
brls::StagedAppletFrame* stagedFrame;
public:
LanguageOptionPage();
};

View file

@ -1,11 +1,7 @@
#pragma once
#include <borealis.hpp>
#include <string>
#include "download.hpp"
#include "extract.hpp"
#include "confirm_page.hpp"
#include "worker_page.hpp"
#include "constants.hpp"
class ListDownloadTab : public brls::List
{

View file

@ -2,12 +2,6 @@
#include <borealis.hpp>
#include "about_tab.hpp"
#include "list_download_tab.hpp"
#include "ams_tab.hpp"
#include "tools_tab.hpp"
#include "json.hpp"
class MainFrame : public brls::TabFrame
{
private:

View file

@ -1,14 +1,6 @@
#pragma once
#include <borealis.hpp>
#include <switch.h>
#include <json.hpp>
#include "constants.hpp"
#include "main_frame.hpp"
#include <fstream>
#include <filesystem>
#include <tuple>
#include <iomanip>
#define AF_INET 2
@ -22,7 +14,7 @@ class NetPage : public brls::AppletFrame
public:
NetPage();
std::string ipToString(u8* ip);
int stringToIp(std::string ip, u8* out);
std::string ipToString(unsigned char* ip);
int stringToIp(std::string ip, unsigned char* out);
};

View file

@ -1,7 +1,6 @@
#pragma once
#include "utils.hpp"
#include "reboot_payload.h"
#include <borealis.hpp>
class PayloadPage : public brls::AppletFrame
{

View file

@ -1,19 +1,6 @@
#pragma once
#include <borealis.hpp>
#include "confirm_page.hpp"
#include "worker_page.hpp"
#include "cheats_page.hpp"
#include "payload_page.hpp"
#include "download_payload_page.hpp"
#include "changelog_page.hpp"
#include "language_option_page.hpp"
#include "JC_page.hpp"
#include "PC_page.hpp"
#include "net_page.hpp"
#include "extract.hpp"
#include "utils.hpp"
#include "hide_tabs_page.hpp"
//#include "ntcp.hpp"
class ToolsTab : public brls::List

View file

@ -3,12 +3,9 @@
#include <regex>
#include <set>
#include <switch.h>
#include "download.hpp"
#include "extract.hpp"
#include "constants.hpp"
#include "progress_event.hpp"
#include "json.hpp"
#include "main_frame.hpp"
#include <borealis.hpp>
typedef char NsApplicationName[0x201];
typedef uint8_t NsApplicationIcon[0x20000];
@ -21,8 +18,6 @@ struct app
brls::ListItem* listItem;
};
CFW getCFW();
bool isServiceRunning(const char *serviceName);
std::vector<std::string> htmlProcess(std::string s, std::regex rgx);
void createTree(std::string path);
void clearConsole();

View file

@ -2,14 +2,7 @@
#include <borealis.hpp>
#include <thread>
#include <string>
#include <functional>
#include "utils.hpp"
#include "download.hpp"
#include "extract.hpp"
#include "constants.hpp"
#include "progress_event.hpp"
typedef std::function<void()> worker_func_t;

View file

@ -1,4 +1,14 @@
#include "JC_color_swapper.hpp"
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <filesystem>
#include <tuple>
#include "constants.hpp"
#include "progress_event.hpp"
#include "utils.hpp"
using json = nlohmann::json;

View file

@ -1,4 +1,8 @@
#include "JC_page.hpp"
#include "JC_color_swapper.hpp"
#include "confirm_page.hpp"
#include "worker_page.hpp"
#include "constants.hpp"
namespace i18n = brls::i18n;
using namespace i18n::literals;

View file

@ -1,4 +1,15 @@
#include "PC_color_swapper.hpp"
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <filesystem>
#include <tuple>
#include <switch.h>
#include "constants.hpp"
#include "progress_event.hpp"
#include "utils.hpp"
using json = nlohmann::json;

View file

@ -1,4 +1,8 @@
#include "PC_page.hpp"
#include "PC_color_swapper.hpp"
#include "confirm_page.hpp"
#include "worker_page.hpp"
#include "constants.hpp"
namespace i18n = brls::i18n;
using namespace i18n::literals;

View file

@ -1,4 +1,11 @@
#include "ams_tab.hpp"
#include <string>
#include "download.hpp"
#include "extract.hpp"
#include "confirm_page.hpp"
#include "dialogue_page.hpp"
#include "worker_page.hpp"
#include "utils.hpp"
namespace i18n = brls::i18n;
using namespace i18n::literals;

View file

@ -1,4 +1,12 @@
#include "app_page.hpp"
#include <switch.h>
#include "utils.hpp"
#include <filesystem>
#include <fstream>
#include "current_cfw.hpp"
#include "worker_page.hpp"
#include "confirm_page.hpp"
#include "download_cheats_page.hpp"
namespace i18n = brls::i18n;
using namespace i18n::literals;
@ -61,7 +69,7 @@ AppPage::AppPage(bool cheatSlips) : AppletFrame(true, true)
}
std::string text("menus/text_download"_i18n);
std::string url = "";
switch(getCFW()){
switch(running_cfw){
case ams:
url += CHEATS_URL_CONTENTS;
break;

View file

@ -1,4 +1,10 @@
#include "cheats_page.hpp"
#include "app_page.hpp"
#include "exclude_page.hpp"
#include "worker_page.hpp"
#include "confirm_page.hpp"
#include "current_cfw.hpp"
#include "extract.hpp"
namespace i18n = brls::i18n;
using namespace i18n::literals;
@ -25,7 +31,7 @@ CheatsPage::CheatsPage() : AppletFrame(true, true)
stagedFrame = new brls::StagedAppletFrame();
stagedFrame->setTitle("menus/cheat_delete_all_cheat"_i18n );
stagedFrame->addStage(
new WorkerPage(stagedFrame, "menus/cheat_Deleting"_i18n , [](){removeCheats(getCFW());})
new WorkerPage(stagedFrame, "menus/cheat_Deleting"_i18n , [](){removeCheats(running_cfw);})
);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "menus/cheat_All_done"_i18n , true)

View file

@ -1,4 +1,8 @@
#include "confirm_page.hpp"
#include "utils.hpp"
#include "main_frame.hpp"
#include "reboot_payload.h"
#include <algorithm>
namespace i18n = brls::i18n;
using namespace i18n::literals;

19
source/current_cfw.cpp Normal file
View file

@ -0,0 +1,19 @@
#include "current_cfw.hpp"
#include <switch.h>
bool isServiceRunning(const char *serviceName) {
Handle handle;
SmServiceName service_name = smEncodeName(serviceName);
bool running = R_FAILED(smRegisterService(&handle, service_name, false, 1));
svcCloseHandle(handle);
if (!running)
smUnregisterService(service_name);
return running;
};
CFW getCFW(){
if(isServiceRunning("rnx")) return rnx;
else if(isServiceRunning("tx")) return sxos;
else return ams;
};

View file

@ -1,4 +1,7 @@
#include "dialogue_page.hpp"
#include "utils.hpp"
#include "reboot_payload.h"
#include "main_frame.hpp"
namespace i18n = brls::i18n;
using namespace i18n::literals;

View file

@ -1,6 +1,15 @@
#include "download.hpp"
#include "utils.hpp"
#include <algorithm>
#include <time.h>
#include <math.h>
#include <curl/curl.h>
#include <string>
#include <regex>
#include <switch.h>
#include "progress_event.hpp"
#define API_AGENT "HamletDuFromage"
#define _1MiB 0x100000

View file

@ -1,5 +1,10 @@
#include "download_cheats_page.hpp"
#include "constants.hpp"
#include "download.hpp"
#include "utils.hpp"
#include "current_cfw.hpp"
#include <fstream>
#include <filesystem>
namespace i18n = brls::i18n;
using namespace i18n::literals;
@ -151,7 +156,7 @@ std::string DownloadCheatsPage::GetCheatsTitle(json cheat) {
void DownloadCheatsPage::WriteCheats(uint64_t tid, std::string bid, std::string cheatContent) {
std::string path;
std::string tidstr = formatApplicationId(tid);
switch(getCFW()){
switch(running_cfw){
case ams:
path = std::string(AMS_PATH) + std::string(CONTENTS_PATH);
break;
@ -175,7 +180,7 @@ void DownloadCheatsPage::WriteCheats(uint64_t tid, std::string bid, std::string
void DownloadCheatsPage::DeleteCheats(uint64_t tid, std::string bid) {
std::string path;
switch(getCFW()){
switch(running_cfw){
case ams:
path = std::string(AMS_PATH) + std::string(CONTENTS_PATH);
break;

View file

@ -1,4 +1,8 @@
#include "download_payload_page.hpp"
#include "utils.hpp"
#include "confirm_page.hpp"
#include "worker_page.hpp"
#include "download.hpp"
namespace i18n = brls::i18n;
using namespace i18n::literals;

View file

@ -1,4 +1,10 @@
#include "exclude_page.hpp"
#include <switch.h>
#include "utils.hpp"
#include "extract.hpp"
#include <filesystem>
#include <fstream>
#include <algorithm>
namespace i18n = brls::i18n;
using namespace i18n::literals;

View file

@ -1,6 +1,19 @@
#include "extract.hpp"
#include "utils.hpp"
#include "download.hpp"
#include <string>
#include <vector>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <iterator>
#include <filesystem>
#include <fstream>
#include <set>
#include <unzipper.h>
#include "progress_event.hpp"
#include "current_cfw.hpp"
namespace i18n = brls::i18n;
using namespace i18n::literals;

View file

@ -1,4 +1,7 @@
#include "hide_tabs_page.hpp"
#include "json.hpp"
#include "constants.hpp"
#include <fstream>
namespace i18n = brls::i18n;
using namespace i18n::literals;

View file

@ -1,60 +0,0 @@
#include "language_option_page.hpp"
#include <cstdio>
namespace i18n = brls::i18n;
using namespace i18n::literals;
//this page is for language page
LanguageOptionPage::LanguageOptionPage() : AppletFrame(true, true)
{
/* this->setTitle("menus/Language_Option"_i18n );
list = new brls::List();
English = new brls::ListItem("English");
English->getClickEvent()->subscribe([&](brls::View* view){
nlohmann::json json_file;
json_file["language"]=(int)lang::Language::English;
std::ofstream o(APP_LANG);
o<<std::setw(4)<<json_file<<std::endl;
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "menus/reset_machine"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
list->addView(English);
Chinese = new brls::ListItem("中文");
Chinese->getClickEvent()->subscribe([&](brls::View* view){
nlohmann::json json_file;
json_file["language"]=(int)lang::Language::Chinese;
std::ofstream o(APP_LANG);
o<<std::setw(4)<<json_file<<std::endl;
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "menus/reset_machine"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
list->addView(Chinese);
French = new brls::ListItem("Français");
French->getClickEvent()->subscribe([&](brls::View* view){
nlohmann::json json_file;
json_file["language"]=(int)lang::Language::French;
std::ofstream o(APP_LANG);
o<<std::setw(4)<<json_file<<std::endl;
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
stagedFrame->addStage(
new ConfirmPage(stagedFrame, "menus/reset_machine"_i18n , true)
);
brls::Application::pushView(stagedFrame);
});
list->addView(French);
this->setContentView(list); */
}

View file

@ -1,4 +1,14 @@
#include "list_download_tab.hpp"
#include <string>
#include "download.hpp"
#include "extract.hpp"
#include "confirm_page.hpp"
#include "worker_page.hpp"
#include "current_cfw.hpp"
#include "utils.hpp"
#include "app_page.hpp"
#include <filesystem>
#include <fstream>
namespace i18n = brls::i18n;
using namespace i18n::literals;
@ -47,7 +57,7 @@ ListDownloadTab::ListDownloadTab(archiveType type) :
case cheats:
std::string cheatsVer = fetchTitle(CHEATS_RELEASE_URL);
if(cheatsVer != "-1"){
switch(getCFW()){
switch(running_cfw){
case sxos:
links.push_back(std::make_pair("menus/list_latest_ver"_i18n + cheatsVer + ")", CHEATS_URL_TITLES));
break;

View file

@ -2,9 +2,7 @@
//#include <stdlib.h>
#include <string>
#include <switch.h>
#include <borealis.hpp>
#include "main_frame.hpp"
#include "constants.hpp"
#include "utils.hpp"

View file

@ -1,4 +1,12 @@
#include "main_frame.hpp"
#include "current_cfw.hpp"
#include "about_tab.hpp"
#include "list_download_tab.hpp"
#include "ams_tab.hpp"
#include "tools_tab.hpp"
#include "json.hpp"
#include <fstream>
#include "utils.hpp"
namespace i18n = brls::i18n;
using namespace i18n::literals;
@ -15,6 +23,8 @@ MainFrame::MainFrame() : TabFrame()
else
this->setFooterText("v" + std::string(APP_VERSION));
static CFW running_cfw = getCFW();
json hideStatus;
std::ifstream hideFile(HIDE_TABS_JSON);

View file

@ -1,5 +1,13 @@
#include "net_page.hpp"
#include <arpa/inet.h>
#include <switch.h>
#include <json.hpp>
#include "constants.hpp"
#include "main_frame.hpp"
#include <fstream>
#include <filesystem>
#include <tuple>
#include <iomanip>
namespace i18n = brls::i18n;
using namespace i18n::literals;

View file

@ -1,10 +1,13 @@
#include "payload_page.hpp"
#include "utils.hpp"
#include "reboot_payload.h"
#include "current_cfw.hpp"
#include "utils.hpp"
namespace i18n = brls::i18n;
using namespace i18n::literals;
PayloadPage::PayloadPage() : AppletFrame(true, true)
{
CFW cfw = getCFW();
this->setTitle("menus/payload_reboot"_i18n );
list = new brls::List();
label = new brls::Label(
@ -23,7 +26,7 @@ PayloadPage::PayloadPage() : AppletFrame(true, true)
reboot_to_payload(payload.c_str());
brls::Application::popView();
});
if(cfw == ams){
if(running_cfw == ams){
items[i]->registerAction("menus/payload_set"_i18n , brls::Key::X, [this, payload] {
std::string res1;
if(R_SUCCEEDED(CopyFile(payload.c_str(), REBOOT_PAYLOAD_PATH))){

View file

@ -1,4 +1,17 @@
#include "tools_tab.hpp"
#include "confirm_page.hpp"
#include "worker_page.hpp"
#include "cheats_page.hpp"
#include "payload_page.hpp"
#include "download_payload_page.hpp"
#include "changelog_page.hpp"
#include "JC_page.hpp"
#include "PC_page.hpp"
#include "net_page.hpp"
#include "extract.hpp"
#include "utils.hpp"
#include "hide_tabs_page.hpp"
#include <filesystem>
namespace i18n = brls::i18n;
using namespace i18n::literals;

View file

@ -1,23 +1,16 @@
#include "utils.hpp"
#include "current_cfw.hpp"
#include <switch.h>
#include "download.hpp"
#include "extract.hpp"
#include "progress_event.hpp"
#include "json.hpp"
#include "main_frame.hpp"
#include <filesystem>
#include <fstream>
namespace i18n = brls::i18n;
using namespace i18n::literals;
bool isServiceRunning(const char *serviceName) {
Handle handle;
SmServiceName service_name = smEncodeName(serviceName);
bool running = R_FAILED(smRegisterService(&handle, service_name, false, 1));
svcCloseHandle(handle);
if (!running)
smUnregisterService(service_name);
return running;
}
CFW getCFW(){
if(isServiceRunning("rnx")) return rnx;
else if(isServiceRunning("tx")) return sxos;
else return ams;
}
std::vector<std::string> htmlProcess(std::string s, std::regex rgx){
//std::vector<std::regex> rgx = {std::regex(">(?:(?!>).)*?</a>"), std::regex(">(?:(?!>).)*?</a>")};
@ -159,7 +152,7 @@ void extractArchive(archiveType type, std::string tag){
case cheats:
titles = getInstalledTitlesNs();
titles = excludeTitles(CHEATS_EXCLUDE, titles);
extractCheats(CHEATS_FILENAME, titles, getCFW());
extractCheats(CHEATS_FILENAME, titles, running_cfw);
break;
case fw:
if(std::filesystem::file_size(FIRMWARE_FILENAME) < 200000){

View file

@ -1,4 +1,12 @@
#include "worker_page.hpp"
#include <string>
#include <functional>
#include "utils.hpp"
#include "download.hpp"
#include "extract.hpp"
#include "constants.hpp"
#include "progress_event.hpp"
WorkerPage::WorkerPage(brls::StagedAppletFrame* frame, const std::string& text, worker_func_t worker_func): frame(frame), workerFunc(worker_func)
{