2020-09-21 19:36:46 +01:00
|
|
|
#include "download_payload_page.hpp"
|
2020-10-05 23:53:12 +01:00
|
|
|
|
|
|
|
namespace i18n = brls::i18n;
|
|
|
|
using namespace i18n::literals;
|
2020-09-21 19:36:46 +01:00
|
|
|
DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true)
|
|
|
|
{
|
2020-10-05 23:53:12 +01:00
|
|
|
this->setTitle("menus/Download_payloads"_i18n );
|
2020-09-21 19:36:46 +01:00
|
|
|
list = new brls::List();
|
|
|
|
label = new brls::Label(
|
|
|
|
brls::LabelStyle::DESCRIPTION,
|
2020-10-05 23:53:12 +01:00
|
|
|
"menus/select"_i18n + std::string(BOOTLOADER_PL_PATH) + "." ,
|
2020-09-21 19:36:46 +01:00
|
|
|
true
|
|
|
|
);
|
|
|
|
list->addView(label);
|
|
|
|
std::tuple<std::vector<std::string>, std::vector<std::string>> links = fetchLinks(PAYLOAD_URL);
|
|
|
|
int nbLinks = std::get<0>(links).size();
|
|
|
|
if(nbLinks){
|
|
|
|
items.reserve(nbLinks);
|
|
|
|
for (int i = 0; i<nbLinks; i++){
|
|
|
|
std::string url = std::get<1>(links)[i];
|
|
|
|
std::string path = std::string(BOOTLOADER_PL_PATH) + std::get<0>(links)[i];
|
2020-10-05 23:53:12 +01:00
|
|
|
std::string text("menus/Download"_i18n + std::get<0>(links)[i] + "menus/from"_i18n + url);
|
2020-09-21 19:36:46 +01:00
|
|
|
items[i] = new brls::ListItem(std::get<0>(links)[i]);
|
|
|
|
items[i]->getClickEvent()->subscribe([&, text, url, path](brls::View* view) {
|
|
|
|
createTree(BOOTLOADER_PL_PATH);
|
|
|
|
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
|
2020-10-05 23:53:12 +01:00
|
|
|
stagedFrame->setTitle("menus/getting_paylaod"_i18n );
|
2020-09-21 19:36:46 +01:00
|
|
|
stagedFrame->addStage(
|
|
|
|
new ConfirmPage(stagedFrame, text)
|
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2020-10-05 23:53:12 +01:00
|
|
|
new WorkerPage(stagedFrame, "menus/down"_i18n , [url, path](){downloadFile(url.c_str(), path.c_str(), OFF);})
|
2020-09-21 19:36:46 +01:00
|
|
|
);
|
|
|
|
stagedFrame->addStage(
|
2020-10-05 23:53:12 +01:00
|
|
|
new ConfirmPage(stagedFrame, "menus/download_all_done"_i18n , true)
|
2020-09-21 19:36:46 +01:00
|
|
|
);
|
|
|
|
brls::Application::pushView(stagedFrame);
|
|
|
|
});
|
|
|
|
list->addView(items[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
notFound = new brls::Label(
|
|
|
|
brls::LabelStyle::DESCRIPTION,
|
2020-10-05 23:53:12 +01:00
|
|
|
"menus/description"_i18n ,
|
2020-09-21 19:36:46 +01:00
|
|
|
true
|
|
|
|
);
|
|
|
|
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
|
|
|
|
list->addView(notFound);
|
2020-10-05 23:53:12 +01:00
|
|
|
brls::ListItem* back = new brls::ListItem("menus/back"_i18n );
|
2020-09-23 12:21:05 +01:00
|
|
|
back->getClickEvent()->subscribe([&](brls::View* view) {
|
|
|
|
brls::Application::popView();
|
|
|
|
});
|
|
|
|
list->addView(back);
|
2020-09-21 19:36:46 +01:00
|
|
|
}
|
|
|
|
this->setContentView(list);
|
|
|
|
}
|