-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the updater (COMPILATION BROKEN)
Don't try to compile this yet, there will be a very long linker error that I haven't figured out yet. If you know how to fix it, send me a Pull Request.
- Loading branch information
Showing
13 changed files
with
182 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
#define ROOT_PATH "/" | ||
|
||
#define NRO_PATH_1 "/switch/Calculator_NX.nro" | ||
#define NRO_PATH_2 "/switch/Calculator_NX/Calculator_NX.nro" | ||
#define NRO_PATH_1 "/switch/Calculator_NX.nro" // This is for if the user manually got this app from my GitHub | ||
#define NRO_PATH_2 "/switch/Calculator_NX/Calculator_NX.nro" // This is for if the user downloaded this app from HB App Store | ||
|
||
#define CONFIG_PATH "/config/Calculator_NX/" | ||
#define GUI_DEFAULT_FILE "gui_default.txt" | ||
#define CMD_DEFAULT_FILE "cmd_default.txt" | ||
|
||
#define DOWNLOAD_PATH "/config/Calculator_NX/download/" | ||
#define API_URL "https://api.github.com/repos/EmreTech/Calculator_NX/releases/latest" | ||
|
||
|
||
|
||
|
||
|
||
#define JSON_DOWNLOAD_FILE "latest-tag.json" | ||
#define JSON_DOWNLOAD_PATH "/config/Calculator_NX/download/latest-tag.json" | ||
|
||
#define NRO_DOWNLOAD_PATH "/config/Calculator_NX/download/Calculator_NX.nro" | ||
|
||
#define API_URL "https://api.github.com/repos/EmreTech/Calculator_NX/releases/latest" | ||
#define APP_VERSION "v1.3.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
#include <borealis.hpp> | ||
|
||
struct updateActivity : public brls::Activity { | ||
CONTENT_FROM_XML_RES("activity/update.xml"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <borealis.hpp> | ||
|
||
struct UpdaterTab : public brls::Box { | ||
UpdaterTab(); | ||
|
||
static brls::View* create(); | ||
|
||
private: | ||
bool onYesButtonClicked(brls::View* view); | ||
bool onNoButtonClicked(brls::View* view); | ||
|
||
BRLS_BIND(brls::Label, verboseLabel, "verbose_label"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "updateActivity.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "updaterTab.hpp" | ||
|
||
#include "utils.hpp" | ||
#include "constants.hpp" | ||
#include <string> | ||
#include <filesystem> | ||
|
||
UpdaterTab::UpdaterTab() { | ||
this->inflateFromXMLRes("xml/tabs/updater.xml"); | ||
|
||
BRLS_REGISTER_CLICK_BY_ID("yes", this->onYesButtonClicked); | ||
BRLS_REGISTER_CLICK_BY_ID("no", this->onNoButtonClicked); | ||
} | ||
|
||
bool UpdaterTab::onYesButtonClicked(brls::View* view) { | ||
//TODO: Actually update the app | ||
this->verboseLabel->setText("Finding the URL for the app..."); | ||
std::string url_download = getLatestDownload(API_URL); | ||
|
||
this->verboseLabel->setText("URL found! Downloading from URL..."); | ||
downloadFile(url_download.c_str(), NRO_DOWNLOAD_PATH); | ||
|
||
this->verboseLabel->setText("File downloaded! Moving to the /switch folder..."); | ||
if (std::filesystem::exists(NRO_PATH_1)) | ||
std::filesystem::copy_file(NRO_DOWNLOAD_PATH, NRO_PATH_1); | ||
else | ||
std::filesystem::copy_file(NRO_DOWNLOAD_PATH, NRO_PATH_2); | ||
|
||
return true; | ||
} | ||
|
||
bool UpdaterTab::onNoButtonClicked(brls::View* view) { | ||
//TODO: Add a way to ignore an update. Until then, it'll excute the same code from onYesButtonClicked | ||
this->verboseLabel->setText("Finding the URL for the app..."); | ||
std::string url_download = getLatestDownload(API_URL); | ||
|
||
this->verboseLabel->setText("URL found! Downloading from URL..."); | ||
downloadFile(url_download.c_str(), NRO_DOWNLOAD_PATH); | ||
|
||
this->verboseLabel->setText("File downloaded! Moving to the /switch folder..."); | ||
if (std::filesystem::exists(NRO_PATH_1)) | ||
std::filesystem::copy_file(NRO_DOWNLOAD_PATH, NRO_PATH_1); | ||
else | ||
std::filesystem::copy_file(NRO_DOWNLOAD_PATH, NRO_PATH_2); | ||
|
||
return true; | ||
} | ||
|
||
brls::View* UpdaterTab::create() { | ||
return new UpdaterTab(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<brls:TabFrame | ||
title="@i18n/nxgui/title" | ||
icon="@res/icon/Calculator_NX_Icon_Alt.jpg"> | ||
|
||
<!-- Main tab for the update activity --> | ||
<brls:Tab label="@i18n/nxgui/tabs/update" > | ||
<UpdaterTab/> | ||
</brls:Tab> | ||
|
||
</brls:TabFrame> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<brls:Box | ||
width="auto" | ||
height="auto" | ||
axis="column" | ||
justifyContent="center"> | ||
|
||
<brls:Box | ||
width="auto" | ||
height="auto" | ||
axis="column" | ||
paddingLeft="@style/brls/tab_frame/content_padding_sides" | ||
paddingRight="@style/brls/tab_frame/content_padding_sides" | ||
paddingTop="@style/brls/tab_frame/content_padding_top_bottom" | ||
paddingBottom="@style/brls/tab_frame/content_padding_top_bottom"> | ||
|
||
<brls:Label | ||
width="auto" | ||
height="auto" | ||
textAlign="center" | ||
fontSize="20" | ||
marginBottom="25px" | ||
text="@i18n/nxgui/components/update_reminder"/> | ||
|
||
<brls:Button | ||
id="yes" | ||
width="auto" | ||
height="auto" | ||
shrink="1.0" | ||
style="primary" | ||
text="@i18n/nxgui/components/yes"/> | ||
|
||
<brls:Button | ||
id="no" | ||
width="auto" | ||
height="auto" | ||
shrink="1.0" | ||
style="primary" | ||
text="@i18n/nxgui/components/no"/> | ||
|
||
<brls:Label | ||
id="verbose_label" | ||
width="auto" | ||
height="auto" | ||
textAlign="center" | ||
fontSize="20" | ||
marginBottom="25px" | ||
text="Waiting for response from user..."/> | ||
|
||
</brls:Box> | ||
|
||
</brls:Box> |