1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-11-09 12:01:44 +00:00
This commit is contained in:
flb 2021-03-16 00:37:38 +01:00
parent 521cef3a22
commit cf6b7e2b1f
4 changed files with 13 additions and 15 deletions

View file

@ -9,7 +9,7 @@ class NetPage : public brls::AppletFrame
private:
brls::List* list;
brls::Label* label;
std::vector<brls::ListItem*> listItems;
brls::ListItem* listItem;
brls::ListItem* cancel;
public:

View file

@ -7,7 +7,7 @@ class PayloadPage : public brls::AppletFrame
private:
brls::Label* label;
brls::List* list;
std::vector<brls::ListItem*> items;
brls::ListItem* listItem;
brls::ListItem* reboot;
brls::ListItem* shutDown;

View file

@ -35,6 +35,8 @@ NetPage::NetPage() : AppletFrame(true, true)
+"\nSubnet Mask: " + ipToString(profile.ip_setting_data.ip_address_setting.subnet_mask.addr)
+"\nGateway: " + ipToString(profile.ip_setting_data.ip_address_setting.gateway.addr);
}
struct in_addr addr = {(in_addr_t) gethostid()};
labelText += "\n Local IP addr" + std::string(inet_ntoa(addr));
labelText += "\nMTU: " + std::to_string(unsigned(profile.ip_setting_data.mtu));
if(profile.ip_setting_data.dns_setting.is_automatic){
@ -113,15 +115,12 @@ NetPage::NetPage() : AppletFrame(true, true)
{"name", "ACNH lan-play"}
}));
int nbProfiles = profiles.size();
listItems.reserve(nbProfiles);
int iter = 0;
for (const auto& p : profiles.items()){
json values = p.value();
if(values.find("name") != values.end()) listItems[iter] = new brls::ListItem(values["name"]);
else listItems[iter] = new brls::ListItem("Unnamed");
listItems[iter]->getClickEvent()->subscribe([&, values](brls::View* view){
if(values.find("name") != values.end()) listItem = new brls::ListItem(values["name"]);
else listItem = new brls::ListItem("Unnamed");
listItem->getClickEvent()->subscribe([&, values](brls::View* view){
brls::Dialog* dialog = new brls::Dialog(values.dump(0).substr(1, values.dump(0).size() - 2));
brls::GenericEvent::Callback callbackOk = [&, dialog, values](brls::View* view) {
nifmInitialize(NifmServiceType_Admin);
@ -188,7 +187,7 @@ NetPage::NetPage() : AppletFrame(true, true)
dialog->setCancelable(false);
dialog->open();
});
list->addView(listItems[iter]);
list->addView(listItem);
iter++;
}
}

View file

@ -18,16 +18,15 @@ PayloadPage::PayloadPage() : AppletFrame(true, true)
list->addView(label);
std::vector<std::string> payloads = fetchPayloads();
int nbPayloads = payloads.size();
items.reserve(nbPayloads);
for (int i = 0; i < nbPayloads; i++){
std::string payload = payloads[i];
items[i] = new brls::ListItem(payload);
items[i]->getClickEvent()->subscribe([&, payload](brls::View* view) {
listItem = new brls::ListItem(payload);
listItem->getClickEvent()->subscribe([&, payload](brls::View* view) {
reboot_to_payload(payload.c_str());
brls::Application::popView();
});
if(running_cfw == ams){
items[i]->registerAction("menus/payloads/set_reboot_payload"_i18n, brls::Key::X, [this, payload] {
listItem->registerAction("menus/payloads/set_reboot_payload"_i18n, brls::Key::X, [this, payload] {
std::string res1;
if(R_SUCCEEDED(CopyFile(payload.c_str(), REBOOT_PAYLOAD_PATH))){
res1 += "menus/payloads/copy_success"_i18n + payload + "menus/payloads/to"_i18n + std::string(REBOOT_PAYLOAD_PATH) + "'.";
@ -46,7 +45,7 @@ PayloadPage::PayloadPage() : AppletFrame(true, true)
return true;
});
}
items[i]->registerAction("menus/payloads/set_reboot_payload_up"_i18n, brls::Key::Y, [this, payload] {
listItem->registerAction("menus/payloads/set_reboot_payload_up"_i18n, brls::Key::Y, [this, payload] {
std::string res2;
if(R_SUCCEEDED(CopyFile(payload.c_str(), UPDATE_BIN_PATH))){
res2 += "menus/payloads/copy_success"_i18n + payload + "menus/payloads/to"_i18n + std::string(UPDATE_BIN_PATH) + "'.";
@ -63,7 +62,7 @@ PayloadPage::PayloadPage() : AppletFrame(true, true)
dialog->open();
return true;
});
list->addView(items[i]);
list->addView(listItem);
}
list->addView(new brls::ListItemGroupSpacing(true));