-
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.
Fixed bug where the screen wouldn't update when a button is pressed
- Loading branch information
Showing
9 changed files
with
136 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#define CALCULATOR_NX_PATH "/switch/Calculator_NX" | ||
|
||
#define CONFIG_PATH "/config/Calculator_NX" | ||
#define DOWNLOAD_PATH "/config/Calculator_NX/download" | ||
|
||
#define TAGS_API_LINK "https://api.github.com/repos/EmreTech/Calculator_NX/tags" | ||
#define LATEST_RELEASE_API_LINK "https://api.github.com/repos/EmreTech/Calculator_NX/releases/latest" | ||
|
||
#define BASE_DOWNLOAD_URL "https://github.com/EmreTech/Calculator_NX/releases/download/{}/Calculator_NX.nro" |
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 <curl/curl.h> | ||
|
||
#include <iostream> | ||
#include <fstream> | ||
#include <string> | ||
#include <cstdio> | ||
|
||
#define API_AGENT "EmreTech" | ||
|
||
CURLcode downloadFile(const std::string &url, const std::string &filename); | ||
|
||
std::string getLatestTag(bool nightly); | ||
std::string getLatestDownload(bool nightly); |
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 @@ | ||
<brls:AppletFrame | ||
title="@i18n/text/update_title" | ||
icon="@res/icon/Calculator_NX_Icon_Alt.jpg"> | ||
|
||
<UpdaterTab /> | ||
|
||
</brls:AppletFrame> |
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,14 @@ | ||
<brls:Box | ||
width="auto" | ||
height="auto" | ||
alignItems="center" | ||
justifyContent="center"> | ||
|
||
<brls:Label | ||
width="auto" | ||
height="auto" | ||
horizontalAlign="center" | ||
fontSize="35" | ||
text="@i18n/text/updater/starting_update"/> | ||
|
||
</brls:Box> |
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,80 @@ | ||
#include <download.hpp> | ||
|
||
#include <nlohmann/json.hpp> | ||
#include <fmt/core.h> | ||
|
||
#include <constants.hpp> | ||
|
||
size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) | ||
{ | ||
size_t written = fwrite(ptr, size, nmemb, stream); | ||
return written; | ||
} | ||
CURLcode downloadFile(const std::string &url, const std::string &filename) | ||
{ | ||
CURL *curl; | ||
FILE *fp; | ||
CURLcode res; | ||
|
||
curl = curl_easy_init(); | ||
if (curl) | ||
{ | ||
fp = fopen(filename.c_str(), "wb"); | ||
|
||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); | ||
|
||
curl_easy_setopt(curl, CURLOPT_USERAGENT, API_AGENT); | ||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); | ||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); | ||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); | ||
|
||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); | ||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); | ||
|
||
res = curl_easy_perform(curl); | ||
curl_easy_cleanup(curl); | ||
|
||
fclose(fp); | ||
} | ||
|
||
return res; | ||
} | ||
|
||
std::string getLatestTag(bool nightly) | ||
{ | ||
downloadFile( | ||
(nightly ? TAGS_API_LINK : LATEST_RELEASE_API_LINK), DOWNLOAD_PATH + std::string("/github_api.json") | ||
); | ||
|
||
nlohmann::json api_data; | ||
std::ifstream api_file(DOWNLOAD_PATH + std::string("/github_api.json")); | ||
|
||
api_file >> api_data; | ||
api_file.close(); | ||
|
||
if (nightly) | ||
return api_data[0]["name"].get<std::string>(); | ||
|
||
return api_data["tag_name"]; | ||
} | ||
|
||
std::string getLatestDownload(bool nightly) | ||
{ | ||
if (nightly) | ||
{ | ||
std::string latestTag = getLatestTag(nightly); | ||
return fmt::format(BASE_DOWNLOAD_URL, latestTag); | ||
} | ||
|
||
downloadFile( | ||
LATEST_RELEASE_API_LINK, DOWNLOAD_PATH + std::string("/github_api_two.json") | ||
); | ||
|
||
nlohmann::json api_data; | ||
std::ifstream api_file(DOWNLOAD_PATH + std::string("/github_api_two.json")); | ||
|
||
api_file >> api_data; | ||
api_file.close(); | ||
|
||
return api_data["assets"][12/*"browser_download_url"*/]; | ||
} |
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,5 +1,4 @@ | ||
#include <borealis.hpp> | ||
#include <nlohmann/json.hpp> | ||
|
||
#include <calculatorTab.hpp> | ||
#include <aboutTab.hpp> | ||
|