From cf6b7e2b1f9e6e0ab7cfeb38b9764673f95df70a Mon Sep 17 00:00:00 2001 From: flb Date: Tue, 16 Mar 2021 00:37:38 +0100 Subject: [PATCH] cleanup --- include/net_page.hpp | 2 +- include/payload_page.hpp | 2 +- source/net_page.cpp | 13 ++++++------- source/payload_page.cpp | 11 +++++------ 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/include/net_page.hpp b/include/net_page.hpp index cb0323e..898818b 100644 --- a/include/net_page.hpp +++ b/include/net_page.hpp @@ -9,7 +9,7 @@ class NetPage : public brls::AppletFrame private: brls::List* list; brls::Label* label; - std::vector listItems; + brls::ListItem* listItem; brls::ListItem* cancel; public: diff --git a/include/payload_page.hpp b/include/payload_page.hpp index d2b87fb..7160b33 100644 --- a/include/payload_page.hpp +++ b/include/payload_page.hpp @@ -7,7 +7,7 @@ class PayloadPage : public brls::AppletFrame private: brls::Label* label; brls::List* list; - std::vector items; + brls::ListItem* listItem; brls::ListItem* reboot; brls::ListItem* shutDown; diff --git a/source/net_page.cpp b/source/net_page.cpp index e35b23c..dbdcaad 100644 --- a/source/net_page.cpp +++ b/source/net_page.cpp @@ -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++; } } diff --git a/source/payload_page.cpp b/source/payload_page.cpp index 2d7bbd6..d1e3736 100644 --- a/source/payload_page.cpp +++ b/source/payload_page.cpp @@ -18,16 +18,15 @@ PayloadPage::PayloadPage() : AppletFrame(true, true) list->addView(label); std::vector 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));