From 89c68ad0a9f178fb4230fdb10a6ad9bf2c7cc74f Mon Sep 17 00:00:00 2001 From: Huntereb Date: Tue, 29 Oct 2019 21:58:53 -0400 Subject: [PATCH] New patches location, patches version checking, include fixes, string fixes --- config/config.ini | 2 +- include/nspInstall.hpp | 1 - include/util/config.hpp | 1 - include/util/error.hpp | 2 +- include/util/unzip.hpp | 3 --- include/util/util.hpp | 2 +- source/main.cpp | 3 +-- source/netInstall.cpp | 2 +- source/nspInstall.cpp | 3 ++- source/sigInstall.cpp | 14 +++++++++++--- source/ui/optionsPage.cpp | 2 +- source/util/config.cpp | 4 ++-- source/util/debug.c | 2 +- source/util/util.cpp | 13 +++++++++++++ 14 files changed, 35 insertions(+), 19 deletions(-) diff --git a/config/config.ini b/config/config.ini index fbb9ac4..5d8756c 100755 --- a/config/config.ini +++ b/config/config.ini @@ -1,4 +1,4 @@ [settings] ignoreReqVers=1 gayMode=0 -sigPatchesUrl=http://github.com/Joonie86/hekate/releases/download/5.0.0J/Kosmos_patches_10_09_2019.zip +sigPatchesUrl=https://github.com/Huntereb/Awoo-Installer/releases/download/SignaturePatches/patches.zip diff --git a/include/nspInstall.hpp b/include/nspInstall.hpp index 9578f18..05fa389 100755 --- a/include/nspInstall.hpp +++ b/include/nspInstall.hpp @@ -1,5 +1,4 @@ #pragma once -#include namespace inst::ui { void setTopInstInfoText(std::string ourText); diff --git a/include/util/config.hpp b/include/util/config.hpp index 9b23dac..16bf286 100755 --- a/include/util/config.hpp +++ b/include/util/config.hpp @@ -1,5 +1,4 @@ #pragma once -#include namespace inst::config { extern const std::string appDir; diff --git a/include/util/error.hpp b/include/util/error.hpp index 0f9e8fd..6f7b36e 100755 --- a/include/util/error.hpp +++ b/include/util/error.hpp @@ -3,7 +3,7 @@ #include #include #include -#include "debug.h" +#include "util/debug.h" #define ASSERT_OK(rc_out, desc) if (R_FAILED(rc_out)) { char msg[256] = {0}; snprintf(msg, 256-1, "%s:%u: %s. Error code: 0x%08x\n", __func__, __LINE__, desc, rc_out); throw std::runtime_error(msg); } #define THROW_FORMAT(format, ...) { char error_prefix[512] = {0}; snprintf(error_prefix, 256-1, "%s:%u: ", __func__, __LINE__);\ diff --git a/include/util/unzip.hpp b/include/util/unzip.hpp index 291210a..745894e 100755 --- a/include/util/unzip.hpp +++ b/include/util/unzip.hpp @@ -1,6 +1,3 @@ -#include -#include - namespace inst::zip { bool extractFile(const std::string filename, const std::string destination); } \ No newline at end of file diff --git a/include/util/util.hpp b/include/util/util.hpp index 15fa989..7d0e50f 100755 --- a/include/util/util.hpp +++ b/include/util/util.hpp @@ -1,5 +1,4 @@ #pragma once -#include #include namespace inst::util { @@ -10,4 +9,5 @@ namespace inst::util { bool copyFile(std::string inFile, std::string outFile); std::string formatUrlString(std::string ourString); std::string shortenString(std::string ourString, int ourLength, bool isFile); + std::string readTextFromFile(std::string ourFile); } \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index 3c6243f..105097e 100755 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,7 +1,6 @@ #include "switch.h" #include "ui/MainApplication.hpp" -#include "util.hpp" -#include +#include "util/util.hpp" using namespace pu::ui::render; int main(int argc, char* argv[]) diff --git a/source/netInstall.cpp b/source/netInstall.cpp index d986ad0..da1dc08 100755 --- a/source/netInstall.cpp +++ b/source/netInstall.cpp @@ -13,7 +13,7 @@ #include "install/http_nsp.hpp" #include "install/install.hpp" #include "util/error.hpp" -#include "netInstall.hpp" + #include "ui/MainApplication.hpp" #include "netInstall.hpp" #include "nspInstall.hpp" diff --git a/source/nspInstall.cpp b/source/nspInstall.cpp index 70a89fb..ab48c28 100755 --- a/source/nspInstall.cpp +++ b/source/nspInstall.cpp @@ -1,14 +1,15 @@ #include #include #include + #include "install/install_nsp.hpp" #include "nx/fs.hpp" #include "util/file_util.hpp" #include "util/title_util.hpp" #include "util/error.hpp" -#include "nspInstall.hpp" #include "ui/MainApplication.hpp" +#include "nspInstall.hpp" #include "util/config.hpp" #include "util/util.hpp" diff --git a/source/sigInstall.cpp b/source/sigInstall.cpp index 484a7ee..97c2e33 100755 --- a/source/sigInstall.cpp +++ b/source/sigInstall.cpp @@ -2,7 +2,7 @@ #include "util/curl.hpp" #include "util/util.hpp" #include "util/unzip.hpp" -#include "config.hpp" +#include "util/config.hpp" namespace inst::ui { extern MainApplication *mainApp; @@ -11,7 +11,10 @@ namespace inst::ui { namespace sig { void installSigPatches () { try { - int ourResult = inst::ui::mainApp->CreateShowDialog("Install signature patches?", "Signature patches are required for installing and playing NSP contents!", {"Install", "Uninstall", "Cancel"}, true); + std::string patchesVersion = inst::util::readTextFromFile("sdmc:/atmosphere/exefs_patches/es_patches/patches.txt"); + std::string versionText = ""; + if (patchesVersion != "") versionText = "You currently have signature patches installed for HOS version " + patchesVersion; + int ourResult = inst::ui::mainApp->CreateShowDialog("Install signature patches?", "Signature patches are required for installing and playing NSP contents." + versionText, {"Install", "Uninstall", "Cancel"}, true); if (ourResult == 0) { if (!inst::util::copyFile("sdmc:/bootloader/patches.ini", inst::config::appDir + "/patches.ini.old")) { if (inst::ui::mainApp->CreateShowDialog("Could not back up old Hekate patches.ini! Install anyway?", "", {"Yes", "No"}, false)) return; @@ -25,7 +28,12 @@ namespace sig { return; } std::filesystem::remove(ourPath); - if (didExtract) inst::ui::mainApp->CreateShowDialog("Install complete!", "Restart your console to apply!", {"OK"}, true); + if (didExtract) { + patchesVersion = inst::util::readTextFromFile("sdmc:/atmosphere/exefs_patches/es_patches/patches.txt"); + versionText = ""; + if (patchesVersion != "") versionText = " Your signature patches have been updated for HOS version " + patchesVersion + "!"; + inst::ui::mainApp->CreateShowDialog("Install complete!" + versionText, "Restart your console to apply!", {"OK"}, true); + } else { inst::ui::mainApp->CreateShowDialog("Could not extract files!", "", {"OK"}, true); return; diff --git a/source/ui/optionsPage.cpp b/source/ui/optionsPage.cpp index 441c5b1..6cc56d6 100755 --- a/source/ui/optionsPage.cpp +++ b/source/ui/optionsPage.cpp @@ -105,7 +105,7 @@ namespace inst::ui { } break; case 3: - inst::ui::mainApp->CreateShowDialog("Thanks to the following people for helping me!\n\n-HookedBehemoth for screen-nx (A great reference!)\n-Adubbz for Tinfoil\n-XorTroll for Plutonium and Goldleaf\n-The kind folks at the AtlasNX Discuck\n-The also kind folks at the RetroNX Discuck\n-namako8982 for the Momiji art\n-TheXzoron for being a baka", "", {"Close"}, true); + inst::ui::mainApp->CreateShowDialog("Thanks to the following people for helping me!\n\n- HookedBehemoth for screen-nx and his Plutonium fork\n- Adubbz and other contributors for Tinfoil\n- XorTroll for Plutonium and Goldleaf\n- The kind folks at the AtlasNX Discuck\n- The also kind folks at the RetroNX Discuck\n- namako8982 for the Momiji art\n- TheXzoron for being a baka", "", {"Close"}, true); break; default: break; diff --git a/source/util/config.cpp b/source/util/config.cpp index b055cf1..bf587e8 100755 --- a/source/util/config.cpp +++ b/source/util/config.cpp @@ -1,12 +1,12 @@ #include #include #include "util/INIReader.h" -#include "config.hpp" +#include "util/config.hpp" namespace inst::config { const std::string appDir = "sdmc:/switch/Awoo-Installer"; const std::string configPath = appDir + "/config.ini"; - std::string sigPatchesUrl = "http://github.com/Joonie86/hekate/releases/download/5.0.0J/Kosmos_patches_10_09_2019.zip"; + std::string sigPatchesUrl = "https://github.com/Huntereb/Awoo-Installer/releases/download/SignaturePatches/patches.zip"; bool ignoreReqVers = true; bool gayMode = false; diff --git a/source/util/debug.c b/source/util/debug.c index a59269c..ee058ef 100755 --- a/source/util/debug.c +++ b/source/util/debug.c @@ -1,4 +1,4 @@ -#include "debug.h" +#include "util/debug.h" #include diff --git a/source/util/util.cpp b/source/util/util.cpp index 2a3e87a..52ad3a8 100755 --- a/source/util/util.cpp +++ b/source/util/util.cpp @@ -108,4 +108,17 @@ namespace inst::util { else return (std::string)ourString.substr(0,ourLength) + "..."; } else return ourString; } + + std::string readTextFromFile(std::string ourFile) { + if (std::filesystem::exists(ourFile)) { + FILE * file = fopen(ourFile.c_str(), "r"); + char line[1024]; + fgets(line, 1024, file); + std::string url = line; + fflush(file); + fclose(file); + return url; + } + return ""; + } } \ No newline at end of file