mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2024-11-26 04:02:11 +00:00
OptionsTab: check if an Internet connection is available before starting an update.
This commit is contained in:
parent
841fd73fbf
commit
bc842d8905
6 changed files with 32 additions and 8 deletions
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <borealis.hpp>
|
||||
|
||||
#include "download_task.hpp"
|
||||
#include "tasks.hpp"
|
||||
|
||||
namespace nxdt::views
|
||||
{
|
||||
|
@ -70,13 +70,15 @@ namespace nxdt::views
|
|||
class OptionsTab: public brls::List
|
||||
{
|
||||
private:
|
||||
nxdt::tasks::StatusInfoTask *status_info_task = nullptr;
|
||||
|
||||
bool display_notification = true;
|
||||
brls::menu_timer_t notification_timer = 0.0f;
|
||||
brls::menu_timer_ctx_entry_t notification_timer_ctx = {0};
|
||||
|
||||
void DisplayNotification(std::string str);
|
||||
public:
|
||||
OptionsTab(void);
|
||||
OptionsTab(nxdt::tasks::StatusInfoTask *status_info_task);
|
||||
~OptionsTab(void);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "core/title.h"
|
||||
#include "core/ums.h"
|
||||
#include "core/usb.h"
|
||||
#include "download_task.hpp"
|
||||
|
||||
namespace nxdt::tasks
|
||||
{
|
||||
|
@ -71,6 +72,8 @@ namespace nxdt::tasks
|
|||
StatusInfoTask(void);
|
||||
~StatusInfoTask(void);
|
||||
|
||||
const StatusInfoData* GetStatusInfoData(void);
|
||||
|
||||
ALWAYS_INLINE StatusInfoEvent::Subscription RegisterListener(StatusInfoEvent::Callback cb)
|
||||
{
|
||||
return this->status_info_event.subscribe(cb);
|
||||
|
|
|
@ -31,9 +31,10 @@
|
|||
},
|
||||
|
||||
"notifications": {
|
||||
"is_nso": "The application is running as an NSO. Unable to update.",
|
||||
"already_updated": "The application has already been updated. Please reload.",
|
||||
"no_internet_connection": "Internet connection unavailable. Unable to update.",
|
||||
"update_failed": "Update failed! For more information, please check the logfile.",
|
||||
"nswdb_xml_updated": "NSWDB XML successfully updated!"
|
||||
"nswdb_xml_updated": "NSWDB XML successfully updated!",
|
||||
"is_nso": "The application is running as an NSO. Unable to update.",
|
||||
"already_updated": "The application has already been updated. Please reload."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ namespace nxdt::views
|
|||
return true;
|
||||
}
|
||||
|
||||
OptionsTab::OptionsTab(void) : brls::List()
|
||||
OptionsTab::OptionsTab(nxdt::tasks::StatusInfoTask *status_info_task) : brls::List(), status_info_task(status_info_task)
|
||||
{
|
||||
/* Set custom spacing. */
|
||||
this->setSpacing(this->getSpacing() / 2);
|
||||
|
@ -241,6 +241,13 @@ namespace nxdt::views
|
|||
brls::ListItem *update_nswdb_xml = new brls::ListItem("options_tab/update_nswdb_xml/label"_i18n, "options_tab/update_nswdb_xml/description"_i18n);
|
||||
|
||||
update_nswdb_xml->getClickEvent()->subscribe([this](brls::View* view) {
|
||||
if (!this->status_info_task->GetStatusInfoData()->ip_addr)
|
||||
{
|
||||
/* Display a notification if no Internet connection is available. */
|
||||
this->DisplayNotification("options_tab/notifications/no_internet_connection"_i18n);
|
||||
return;
|
||||
}
|
||||
|
||||
OptionsTabUpdateFileDialog *dialog = new OptionsTabUpdateFileDialog(NSWDB_XML_PATH, NSWDB_XML_URL, false, "options_tab/notifications/nswdb_xml_updated"_i18n);
|
||||
dialog->open(false);
|
||||
});
|
||||
|
@ -257,7 +264,13 @@ namespace nxdt::views
|
|||
this->DisplayNotification("options_tab/notifications/is_nso"_i18n);
|
||||
return;
|
||||
} else
|
||||
if (false)
|
||||
if (!this->status_info_task->GetStatusInfoData()->ip_addr)
|
||||
{
|
||||
/* Display a notification if no Internet connection is available. */
|
||||
this->DisplayNotification("options_tab/notifications/no_internet_connection"_i18n);
|
||||
return;
|
||||
} else
|
||||
if (false) /// TODO: add a proper check here
|
||||
{
|
||||
/* Display a notification if the application has already been updated. */
|
||||
this->DisplayNotification("options_tab/notifications/already_updated"_i18n);
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace nxdt::views
|
|||
|
||||
this->addSeparator();
|
||||
|
||||
this->addTab("root_view/tabs/options"_i18n, new OptionsTab());
|
||||
this->addTab("root_view/tabs/options"_i18n, new OptionsTab(this->status_info_task));
|
||||
|
||||
this->addSeparator();
|
||||
|
||||
|
|
|
@ -42,6 +42,11 @@ namespace nxdt::tasks
|
|||
brls::Logger::debug("Status info task stopped.");
|
||||
}
|
||||
|
||||
const StatusInfoData* StatusInfoTask::GetStatusInfoData(void)
|
||||
{
|
||||
return &(this->status_info_data);
|
||||
}
|
||||
|
||||
void StatusInfoTask::run(retro_time_t current_time)
|
||||
{
|
||||
brls::RepeatingTask::run(current_time);
|
||||
|
|
Loading…
Reference in a new issue