2020-12-12 15:41:56 +00:00
|
|
|
#include "ams_tab.hpp"
|
2021-02-10 16:28:47 +00:00
|
|
|
#include <string>
|
|
|
|
#include "download.hpp"
|
|
|
|
#include "extract.hpp"
|
|
|
|
#include "confirm_page.hpp"
|
|
|
|
#include "dialogue_page.hpp"
|
|
|
|
#include "worker_page.hpp"
|
|
|
|
#include "utils.hpp"
|
2020-12-12 15:41:56 +00:00
|
|
|
|
|
|
|
namespace i18n = brls::i18n;
|
|
|
|
using namespace i18n::literals;
|
|
|
|
|
|
|
|
AmsTab::AmsTab() :
|
|
|
|
brls::List()
|
|
|
|
{
|
2021-02-08 20:30:58 +00:00
|
|
|
std::vector<std::pair<std::string, std::string>> links;
|
2020-12-12 15:41:56 +00:00
|
|
|
std::string operation = "menus/Getting"_i18n ;
|
|
|
|
this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "", true);
|
2021-02-08 20:30:58 +00:00
|
|
|
links = getLinks(AMS_URL);
|
2020-12-12 15:41:56 +00:00
|
|
|
operation += "menus/list_cfw"_i18n ;
|
|
|
|
this->description->setText(
|
|
|
|
"menus/list_ams"_i18n
|
|
|
|
);
|
|
|
|
|
|
|
|
this->addView(description);
|
|
|
|
|
2020-12-13 13:52:51 +00:00
|
|
|
|
2020-12-12 15:41:56 +00:00
|
|
|
|
2021-02-08 20:30:58 +00:00
|
|
|
int nbLinks = links.size();
|
2020-12-12 15:41:56 +00:00
|
|
|
if(nbLinks){
|
2021-02-08 20:30:58 +00:00
|
|
|
auto hekate_link = getLinks(HEKATE_URL);
|
2021-02-10 02:57:42 +00:00
|
|
|
std::string hekate_url = hekate_link[0].second;
|
|
|
|
std::string text_hekate = "menus/list_down"_i18n + hekate_link[0].first;
|
2020-12-13 13:52:51 +00:00
|
|
|
|
2021-02-08 20:30:58 +00:00
|
|
|
for (int i = 0; i < nbLinks; i++){
|
|
|
|
std::string url = links[i].second;
|
|
|
|
std::string text("menus/list_down"_i18n + links[i].first + "menus/list_from"_i18n + url);
|
|
|
|
listItem = new brls::ListItem(links[i].first);
|
2021-02-06 17:24:47 +00:00
|
|
|
listItem->setHeight(LISTITEM_HEIGHT);
|
|
|
|
listItem->getClickEvent()->subscribe([&, text, text_hekate, url, hekate_url, operation](brls::View* view) {
|
2020-12-12 15:41:56 +00:00
|
|
|
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
|
|
|
stagedFrame->setTitle(operation);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new ConfirmPage(stagedFrame, text)
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new WorkerPage(stagedFrame, "menus/list_downing"_i18n , [url](){downloadArchive(url, ams_cfw);})
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new WorkerPage(stagedFrame, "menus/list_extracting"_i18n , [](){extractArchive(ams_cfw);})
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new DialoguePage(stagedFrame, text_hekate)
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new WorkerPage(stagedFrame, "menus/list_downing"_i18n , [hekate_url](){downloadArchive(hekate_url, cfw);})
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new WorkerPage(stagedFrame, "menus/list_extracting"_i18n , [](){extractArchive(cfw);})
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
|
|
|
new ConfirmPage(stagedFrame, "menus/reboot_rcm"_i18n , false, true)
|
|
|
|
);
|
|
|
|
brls::Application::pushView(stagedFrame);
|
|
|
|
});
|
2021-02-06 17:24:47 +00:00
|
|
|
this->addView(listItem);
|
2020-12-12 15:41:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
notFound = new brls::Label(
|
|
|
|
brls::LabelStyle::DESCRIPTION,
|
|
|
|
"menus/list_could_done"_i18n ,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
|
|
|
|
this->addView(notFound);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
AmsTab::~AmsTab(){
|
|
|
|
|
|
|
|
}
|