mirror of
https://github.com/HamletDuFromage/aio-switch-updater.git
synced 2024-11-24 18:42:05 +00:00
Download all the links at once
This commit is contained in:
parent
811eb4c18c
commit
25dffbf611
14 changed files with 37 additions and 38 deletions
|
@ -11,7 +11,7 @@ private:
|
|||
brls::Label* description;
|
||||
int size = 0;
|
||||
bool erista;
|
||||
nlohmann::ordered_json cfws = {};
|
||||
nlohmann::ordered_json hekate;
|
||||
std::string GetRepoName(const std::string& repo);
|
||||
std::set<std::string> GetLastDownloadedModules(const std::string& json_path);
|
||||
void CreateStagedFrames(const std::string& text, const std::string& url, const std::string& operation, bool erista, bool hekate = false, const std::string& text_hekate = "", const std::string& hekate_url = "");
|
||||
|
@ -20,7 +20,7 @@ private:
|
|||
void ShowCustomDeepseaBuilder(nlohmann::ordered_json& modules);
|
||||
|
||||
public:
|
||||
AmsTab(const bool erista = true, const bool hideStandardEntries = false);
|
||||
AmsTab(const nlohmann::json& nxlinks, const bool erista = true, const bool hideStandardEntries = false);
|
||||
brls::View* getDefaultFocus() override;
|
||||
};
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ constexpr const char APP_URL[] = "https://github.com/HamletDuFromage/aio-switch-
|
|||
constexpr const char TAGS_INFO[] = "https://api.github.com/repos/HamletDuFromage/aio-switch-updater/releases/latest";
|
||||
constexpr const char APP_FILENAME[] = "/config/aio-switch-updater/app.zip";
|
||||
|
||||
constexpr const char NXLINKS_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/nx-links.json";
|
||||
|
||||
constexpr const char SIGPATCHES_URL[] = "https://raw.githubusercontent.com/HamletDuFromage/nx-links/master/sigpatches.json";
|
||||
constexpr const char SIGPATCHES_FILENAME[] = "/config/aio-switch-updater/sigpatches.zip";
|
||||
constexpr const char HEKATE_IPL_PATH[] = "/bootloader/hekate_ipl.ini";
|
||||
|
@ -107,7 +109,7 @@ enum class archiveType
|
|||
cheats,
|
||||
fw,
|
||||
app,
|
||||
cfw,
|
||||
bootloaders,
|
||||
ams_cfw,
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <borealis.hpp>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
class DialoguePage : public brls::View
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <borealis.hpp>
|
||||
#include <json.hpp>
|
||||
|
||||
class DownloadPayloadPage : public brls::AppletFrame
|
||||
{
|
||||
|
@ -11,5 +12,5 @@ private:
|
|||
brls::ListItem* listItem;
|
||||
|
||||
public:
|
||||
DownloadPayloadPage();
|
||||
DownloadPayloadPage(const nlohmann::ordered_json& payloads);
|
||||
};
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <borealis.hpp>
|
||||
#include <json.hpp>
|
||||
|
||||
#include "constants.hpp"
|
||||
|
||||
|
@ -18,6 +19,6 @@ private:
|
|||
void creategbatempItem();
|
||||
|
||||
public:
|
||||
ListDownloadTab(const archiveType type);
|
||||
ListDownloadTab(const archiveType type, const nlohmann::ordered_json& nxlinks = nlohmann::ordered_json::object());
|
||||
brls::View* getDefaultFocus() override;
|
||||
};
|
|
@ -25,5 +25,5 @@ private:
|
|||
brls::StagedAppletFrame* stagedFrame;
|
||||
|
||||
public:
|
||||
ToolsTab(const std::string& tag, bool erista = true, const nlohmann::json& hideStatus = {});
|
||||
ToolsTab(const std::string& tag, const nlohmann::ordered_json& payloads, bool erista = true, const nlohmann::json& hideStatus = {});
|
||||
};
|
|
@ -15,15 +15,16 @@
|
|||
namespace i18n = brls::i18n;
|
||||
using namespace i18n::literals;
|
||||
|
||||
AmsTab::AmsTab(const bool erista, const bool hideStandardEntries) : brls::List()
|
||||
AmsTab::AmsTab(const nlohmann::json& nxlinks, const bool erista, const bool hideStandardEntries) : brls::List()
|
||||
{
|
||||
this->erista = erista;
|
||||
download::getRequest(AMS_URL, cfws);
|
||||
this->hekate = nxlinks["hekate"];
|
||||
auto cfws = nxlinks["cfws"];
|
||||
|
||||
if (!hideStandardEntries) {
|
||||
this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "menus/main/ams_text"_i18n + (CurrentCfw::running_cfw == CFW::ams ? "\n" + "menus/ams_update/current_ams"_i18n + CurrentCfw::getAmsInfo() : "") + (erista ? "\n" + "menus/ams_update/erista_rev"_i18n : "\n" + "menus/ams_update/mariko_rev"_i18n), true);
|
||||
this->addView(description);
|
||||
CreateDownloadItems(cfws.find("Atmosphere") != cfws.end() ? cfws.at("Atmosphere") : nlohmann::ordered_json::object());
|
||||
CreateDownloadItems(cfws.find("Atmosphere") != cfws.end() ? (nlohmann::ordered_json) cfws.at("Atmosphere") : nlohmann::ordered_json::object());
|
||||
|
||||
description = new brls::Label(
|
||||
brls::LabelStyle::DESCRIPTION,
|
||||
|
@ -40,7 +41,7 @@ AmsTab::AmsTab(const bool erista, const bool hideStandardEntries) : brls::List()
|
|||
});
|
||||
this->addView(listItem);
|
||||
|
||||
CreateDownloadItems(cfws.find("DeepSea") != cfws.end() ? cfws.at("DeepSea") : nlohmann::ordered_json::object());
|
||||
CreateDownloadItems(cfws.find("DeepSea") != cfws.end() ? (nlohmann::ordered_json) cfws.at("DeepSea") : nlohmann::ordered_json::object());
|
||||
}
|
||||
|
||||
auto custom_pack = fs::parseJsonFile(CUSTOM_PACKS_PATH);
|
||||
|
@ -61,7 +62,7 @@ void AmsTab::CreateDownloadItems(const nlohmann::ordered_json& cfw_links, bool h
|
|||
std::vector<std::pair<std::string, std::string>> links;
|
||||
links = download::getLinksFromJson(cfw_links);
|
||||
if (links.size()) {
|
||||
auto hekate_link = download::getLinks(HEKATE_URL);
|
||||
auto hekate_link = download::getLinksFromJson(this->hekate);
|
||||
std::string hekate_url = hekate_link[0].second;
|
||||
std::string text_hekate = "menus/common/download"_i18n + hekate_link[0].first;
|
||||
|
||||
|
@ -106,9 +107,9 @@ void AmsTab::CreateStagedFrames(const std::string& text, const std::string& url,
|
|||
stagedFrame->addStage(
|
||||
new DialoguePage_ams(stagedFrame, text_hekate, erista));
|
||||
stagedFrame->addStage(
|
||||
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [hekate_url]() { util::downloadArchive(hekate_url, archiveType::cfw); }));
|
||||
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [hekate_url]() { util::downloadArchive(hekate_url, archiveType::bootloaders); }));
|
||||
stagedFrame->addStage(
|
||||
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, []() { util::extractArchive(archiveType::cfw); }));
|
||||
new WorkerPage(stagedFrame, "menus/common/extracting"_i18n, []() { util::extractArchive(archiveType::bootloaders); }));
|
||||
}
|
||||
stagedFrame->addStage(
|
||||
new ConfirmPage(stagedFrame, "menus/ams_update/reboot_rcm"_i18n, false, true, erista));
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <regex>
|
||||
|
||||
#include "confirm_page.hpp"
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
|
||||
#include "fs.hpp"
|
||||
#include "main_frame.hpp"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace i18n = brls::i18n;
|
||||
using namespace i18n::literals;
|
||||
DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true)
|
||||
DownloadPayloadPage::DownloadPayloadPage(const nlohmann::ordered_json& payloads) : AppletFrame(true, true)
|
||||
{
|
||||
this->setTitle("menus/payloads/dl_payloads"_i18n);
|
||||
list = new brls::List();
|
||||
|
@ -18,7 +18,7 @@ DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true)
|
|||
true);
|
||||
list->addView(label);
|
||||
|
||||
auto links = download::getLinks(PAYLOAD_URL);
|
||||
auto links = download::getLinksFromJson(payloads);
|
||||
if (links.size()) {
|
||||
for (const auto& link : links) {
|
||||
std::string url = link.second;
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
namespace i18n = brls::i18n;
|
||||
using namespace i18n::literals;
|
||||
|
||||
ListDownloadTab::ListDownloadTab(const archiveType type) : brls::List()
|
||||
ListDownloadTab::ListDownloadTab(const archiveType type, const nlohmann::ordered_json& nxlinks) : brls::List()
|
||||
{
|
||||
//std::vector<std::pair<std::string, std::string>> links, sxoslinks;
|
||||
std::vector<std::pair<std::string, std::string>> links;
|
||||
std::vector<std::pair<std::string, std::string>> links = download::getLinksFromJson(nxlinks);
|
||||
std::string operation("menus/main/getting"_i18n);
|
||||
std::string firmwareText("menus/main/firmware_text"_i18n);
|
||||
|
||||
|
@ -30,13 +30,11 @@ ListDownloadTab::ListDownloadTab(const archiveType type) : brls::List()
|
|||
this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "", true);
|
||||
switch (type) {
|
||||
case archiveType::sigpatches:
|
||||
links = download::getLinks(SIGPATCHES_URL);
|
||||
operation += "menus/main/sigpatches"_i18n;
|
||||
this->description->setText(
|
||||
"menus/main/sigpatches_text"_i18n);
|
||||
break;
|
||||
case archiveType::fw:
|
||||
links = download::getLinks(FIRMWARE_URL);
|
||||
operation += "menus/main/firmware"_i18n;
|
||||
SetSysFirmwareVersion ver;
|
||||
if (R_SUCCEEDED(setsysGetFirmwareVersion(&ver)))
|
||||
|
@ -49,11 +47,7 @@ ListDownloadTab::ListDownloadTab(const archiveType type) : brls::List()
|
|||
links.push_back(std::make_pair("menus/main/latest_cheats"_i18n, APP_URL));
|
||||
operation += "menus/main/app"_i18n;
|
||||
break;
|
||||
case archiveType::cfw:
|
||||
links = download::getLinks(CFW_URL);
|
||||
// sxos is dead anyways
|
||||
/* sxoslinks = download::getLinks(SXOS_URL);
|
||||
links.insert(links.end(), sxoslinks.begin(), sxoslinks.end()); */
|
||||
case archiveType::bootloaders:
|
||||
operation += "menus/main/cfw"_i18n;
|
||||
this->description->setText(
|
||||
"menus/main/bootloaders_text"_i18n);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "about_tab.hpp"
|
||||
#include "ams_tab.hpp"
|
||||
#include "download.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "list_download_tab.hpp"
|
||||
#include "tools_tab.hpp"
|
||||
|
@ -31,6 +32,8 @@ MainFrame::MainFrame() : TabFrame()
|
|||
R_SUCCEEDED(fs::getFreeStorageSD(freeStorage)) ? (float)freeStorage / 0x40000000 : -1));
|
||||
|
||||
json hideStatus = fs::parseJsonFile(HIDE_TABS_JSON);
|
||||
nlohmann::ordered_json nxlinks;
|
||||
download::getRequest(NXLINKS_URL, nxlinks);
|
||||
|
||||
bool erista = util::isErista();
|
||||
|
||||
|
@ -38,22 +41,22 @@ MainFrame::MainFrame() : TabFrame()
|
|||
this->addTab("menus/main/about"_i18n, new AboutTab());
|
||||
|
||||
if (!util::getBoolValue(hideStatus, "atmosphere"))
|
||||
this->addTab("menus/main/update_ams"_i18n, new AmsTab(erista, util::getBoolValue(hideStatus, "atmosphereentries")));
|
||||
this->addTab("menus/main/update_ams"_i18n, new AmsTab(nxlinks, erista, util::getBoolValue(hideStatus, "atmosphereentries")));
|
||||
|
||||
if (!util::getBoolValue(hideStatus, "cfw"))
|
||||
this->addTab("menus/main/update_bootloaders"_i18n, new ListDownloadTab(archiveType::cfw));
|
||||
this->addTab("menus/main/update_bootloaders"_i18n, new ListDownloadTab(archiveType::bootloaders, nxlinks["bootloaders"]));
|
||||
|
||||
if (!util::getBoolValue(hideStatus, "sigpatches"))
|
||||
this->addTab("menus/main/update_sigpatches"_i18n, new ListDownloadTab(archiveType::sigpatches));
|
||||
this->addTab("menus/main/update_sigpatches"_i18n, new ListDownloadTab(archiveType::sigpatches, nxlinks["sigpatches"]));
|
||||
|
||||
if (!util::getBoolValue(hideStatus, "firmwares"))
|
||||
this->addTab("menus/main/download_firmware"_i18n, new ListDownloadTab(archiveType::fw));
|
||||
this->addTab("menus/main/download_firmware"_i18n, new ListDownloadTab(archiveType::fw, nxlinks["firmwares"]));
|
||||
|
||||
if (!util::getBoolValue(hideStatus, "cheats"))
|
||||
this->addTab("menus/main/download_cheats"_i18n, new ListDownloadTab(archiveType::cheats));
|
||||
|
||||
if (!util::getBoolValue(hideStatus, "tools"))
|
||||
this->addTab("menus/main/tools"_i18n, new ToolsTab(tag, erista, hideStatus));
|
||||
this->addTab("menus/main/tools"_i18n, new ToolsTab(tag, nxlinks["payloads"], erista, hideStatus));
|
||||
|
||||
this->registerAction("", brls::Key::B, [this] { return true; });
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace {
|
|||
constexpr const char AppVersion[] = APP_VERSION;
|
||||
}
|
||||
|
||||
ToolsTab::ToolsTab(const std::string& tag, bool erista, const nlohmann::json& hideStatus) : brls::List()
|
||||
ToolsTab::ToolsTab(const std::string& tag, const nlohmann::ordered_json& payloads, bool erista, const nlohmann::json& hideStatus) : brls::List()
|
||||
{
|
||||
if (!tag.empty() && tag != AppVersion) {
|
||||
updateApp = new brls::ListItem("menus/tools/update_app"_i18n + tag + ")");
|
||||
|
@ -66,8 +66,8 @@ ToolsTab::ToolsTab(const std::string& tag, bool erista, const nlohmann::json& hi
|
|||
PCcolor->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
downloadPayload = new brls::ListItem("menus/tools/dl_payloads"_i18n + std::string(BOOTLOADER_PL_PATH));
|
||||
downloadPayload->getClickEvent()->subscribe([&](brls::View* view) {
|
||||
brls::Application::pushView(new DownloadPayloadPage());
|
||||
downloadPayload->getClickEvent()->subscribe([&, payloads](brls::View* view) {
|
||||
brls::Application::pushView(new DownloadPayloadPage(payloads));
|
||||
});
|
||||
downloadPayload->setHeight(LISTITEM_HEIGHT);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace util {
|
|||
case archiveType::app:
|
||||
status_code = download::downloadFile(url, APP_FILENAME, OFF);
|
||||
break;
|
||||
case archiveType::cfw:
|
||||
case archiveType::bootloaders:
|
||||
status_code = download::downloadFile(url, CFW_FILENAME, OFF);
|
||||
break;
|
||||
case archiveType::ams_cfw:
|
||||
|
@ -151,7 +151,7 @@ namespace util {
|
|||
romfsExit();
|
||||
brls::Application::quit();
|
||||
break;
|
||||
case archiveType::cfw:
|
||||
case archiveType::bootloaders:
|
||||
if (isArchive(CFW_FILENAME)) {
|
||||
overwriteInis = showDialogBox("menus/utils/overwrite_inis"_i18n, "menus/common/no"_i18n, "menus/common/yes"_i18n);
|
||||
extract::extract(CFW_FILENAME, ROOT_PATH, overwriteInis);
|
||||
|
@ -171,7 +171,7 @@ namespace util {
|
|||
}
|
||||
break;
|
||||
}
|
||||
if (type == archiveType::ams_cfw || type == archiveType::cfw)
|
||||
if (type == archiveType::ams_cfw || type == archiveType::bootloaders)
|
||||
fs::copyFiles(COPY_FILES_TXT);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue