reformat code
This commit is contained in:
parent
ba57710eb1
commit
48015449c2
@ -38,7 +38,7 @@ namespace tin::data
|
|||||||
{
|
{
|
||||||
std::atomic_bool isFinalized = false;
|
std::atomic_bool isFinalized = false;
|
||||||
u64 writeOffset = 0;
|
u64 writeOffset = 0;
|
||||||
u8 data[BUFFER_SEGMENT_DATA_SIZE] = {0};
|
u8 data[BUFFER_SEGMENT_DATA_SIZE] = { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
// Receives data in a circular buffer split into 8MB segments
|
// Receives data in a circular buffer split into 8MB segments
|
||||||
|
@ -34,7 +34,7 @@ namespace tin::data
|
|||||||
std::vector<u8> m_buffer;
|
std::vector<u8> m_buffer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ByteBuffer(size_t reserveSize=0);
|
ByteBuffer(size_t reserveSize = 0);
|
||||||
|
|
||||||
size_t GetSize();
|
size_t GetSize();
|
||||||
u8* GetData(); // TODO: Remove this, it shouldn't be needed
|
u8* GetData(); // TODO: Remove this, it shouldn't be needed
|
||||||
|
@ -28,29 +28,29 @@ namespace tin::install
|
|||||||
|
|
||||||
static_assert(sizeof(HFS0BaseHeader) == 0x10, "HFS0BaseHeader must be 0x10");
|
static_assert(sizeof(HFS0BaseHeader) == 0x10, "HFS0BaseHeader must be 0x10");
|
||||||
|
|
||||||
NX_INLINE const HFS0FileEntry *hfs0GetFileEntry(const HFS0BaseHeader *header, u32 i)
|
NX_INLINE const HFS0FileEntry* hfs0GetFileEntry(const HFS0BaseHeader* header, u32 i)
|
||||||
{
|
{
|
||||||
if (i >= header->numFiles)
|
if (i >= header->numFiles)
|
||||||
return NULL;
|
return NULL;
|
||||||
return (const HFS0FileEntry*)(header + 0x1 + i * 0x4);
|
return (const HFS0FileEntry*)(header + 0x1 + i * 0x4);
|
||||||
}
|
}
|
||||||
|
|
||||||
NX_INLINE const char *hfs0GetStringTable(const HFS0BaseHeader *header)
|
NX_INLINE const char* hfs0GetStringTable(const HFS0BaseHeader* header)
|
||||||
{
|
{
|
||||||
return (const char*)(header + 0x1 + header->numFiles * 0x4);
|
return (const char*)(header + 0x1 + header->numFiles * 0x4);
|
||||||
}
|
}
|
||||||
|
|
||||||
NX_INLINE u64 hfs0GetHeaderSize(const HFS0BaseHeader *header)
|
NX_INLINE u64 hfs0GetHeaderSize(const HFS0BaseHeader* header)
|
||||||
{
|
{
|
||||||
return 0x1 + header->numFiles * 0x4 + header->stringTableSize;
|
return 0x1 + header->numFiles * 0x4 + header->stringTableSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
NX_INLINE const char *hfs0GetFileName(const HFS0BaseHeader *header, u32 i)
|
NX_INLINE const char* hfs0GetFileName(const HFS0BaseHeader* header, u32 i)
|
||||||
{
|
{
|
||||||
return hfs0GetStringTable(header) + hfs0GetFileEntry(header, i)->stringTableOffset;
|
return hfs0GetStringTable(header) + hfs0GetFileEntry(header, i)->stringTableOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
NX_INLINE const char *hfs0GetFileName(const HFS0BaseHeader *header, const HFS0FileEntry *entry)
|
NX_INLINE const char* hfs0GetFileName(const HFS0BaseHeader* header, const HFS0FileEntry* entry)
|
||||||
{
|
{
|
||||||
return hfs0GetStringTable(header) + entry->stringTableOffset;
|
return hfs0GetStringTable(header) + entry->stringTableOffset;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ namespace tin::install
|
|||||||
virtual void InstallContentMetaRecords(tin::data::ByteBuffer& installContentMetaBuf, int i);
|
virtual void InstallContentMetaRecords(tin::data::ByteBuffer& installContentMetaBuf, int i);
|
||||||
virtual void InstallApplicationRecord(int i);
|
virtual void InstallApplicationRecord(int i);
|
||||||
virtual void InstallTicketCert() = 0;
|
virtual void InstallTicketCert() = 0;
|
||||||
virtual void InstallNCA(const NcmContentId &ncaId) = 0;
|
virtual void InstallNCA(const NcmContentId& ncaId) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~Install();
|
virtual ~Install();
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
namespace sig {
|
namespace sig {
|
||||||
void installSigPatches ();
|
void installSigPatches();
|
||||||
}
|
}
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
namespace Crypto
|
namespace Crypto
|
||||||
{
|
{
|
||||||
#define RSA_2048_BYTES 0x100
|
#define RSA_2048_BYTES 0x100
|
||||||
#define RSA_2048_BITS (RSA_2048_BYTES*8)
|
#define RSA_2048_BITS (RSA_2048_BYTES*8)
|
||||||
static const unsigned char NCAHeaderSignature[0x100] = { /* Fixed RSA key used to validate NCA signature 0. */
|
static const unsigned char NCAHeaderSignature[0x100] = { /* Fixed RSA key used to validate NCA signature 0. */
|
||||||
0xBF, 0xBE, 0x40, 0x6C, 0xF4, 0xA7, 0x80, 0xE9, 0xF0, 0x7D, 0x0C, 0x99, 0x61, 0x1D, 0x77, 0x2F,
|
0xBF, 0xBE, 0x40, 0x6C, 0xF4, 0xA7, 0x80, 0xE9, 0xF0, 0x7D, 0x0C, 0x99, 0x61, 0x1D, 0x77, 0x2F,
|
||||||
0x96, 0xBC, 0x4B, 0x9E, 0x58, 0x38, 0x1B, 0x03, 0xAB, 0xB1, 0x75, 0x49, 0x9F, 0x2B, 0x4D, 0x58,
|
0x96, 0xBC, 0x4B, 0x9E, 0x58, 0x38, 0x1B, 0x03, 0xAB, 0xB1, 0x75, 0x49, 0x9F, 0x2B, 0x4D, 0x58,
|
||||||
@ -45,7 +45,7 @@ namespace Crypto
|
|||||||
};
|
};
|
||||||
|
|
||||||
void calculateMGF1andXOR(unsigned char* data, size_t data_size, const void* source, size_t source_size);
|
void calculateMGF1andXOR(unsigned char* data, size_t data_size, const void* source, size_t source_size);
|
||||||
bool rsa2048PssVerify(const void *data, size_t len, const unsigned char *signature, const unsigned char *modulus);
|
bool rsa2048PssVerify(const void* data, size_t len, const unsigned char* signature, const unsigned char* modulus);
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T swapEndian(T s)
|
T swapEndian(T s)
|
||||||
@ -98,12 +98,12 @@ namespace Crypto
|
|||||||
aes128CtrContextResetCtr(&ctx, &counter);
|
aes128CtrContextResetCtr(&ctx, &counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void encrypt(void *dst, const void *src, size_t l)
|
void encrypt(void* dst, const void* src, size_t l)
|
||||||
{
|
{
|
||||||
aes128CtrCrypt(&ctx, dst, src, l);
|
aes128CtrCrypt(&ctx, dst, src, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
void decrypt(void *dst, const void *src, size_t l)
|
void decrypt(void* dst, const void* src, size_t l)
|
||||||
{
|
{
|
||||||
encrypt(dst, src, l);
|
encrypt(dst, src, l);
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ namespace Crypto
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void encrypt(void *dst, const void *src, size_t l, size_t sector, size_t sector_size)
|
void encrypt(void* dst, const void* src, size_t l, size_t sector, size_t sector_size)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < l; i += sector_size)
|
for (size_t i = 0; i < l; i += sector_size)
|
||||||
{
|
{
|
||||||
@ -137,7 +137,7 @@ namespace Crypto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void decrypt(void *dst, const void *src, size_t l, size_t sector, size_t sector_size)
|
void decrypt(void* dst, const void* src, size_t l, size_t sector, size_t sector_size)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < l; i += sector_size)
|
for (size_t i = 0; i < l; i += sector_size)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace inst::curl {
|
namespace inst::curl {
|
||||||
bool downloadFile(const std::string ourUrl, const char *pagefilename, long timeout = 5000, bool writeProgress = false);
|
bool downloadFile(const std::string ourUrl, const char* pagefilename, long timeout = 5000, bool writeProgress = false);
|
||||||
std::string downloadToBuffer (const std::string ourUrl, int firstRange = -1, int secondRange = -1, long timeout = 5000);
|
std::string downloadToBuffer(const std::string ourUrl, int firstRange = -1, int secondRange = -1, long timeout = 5000);
|
||||||
}
|
}
|
@ -29,7 +29,7 @@ extern "C" {
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <switch/types.h>
|
#include <switch/types.h>
|
||||||
|
|
||||||
void printBytes(u8 *bytes, size_t size, bool includeHeader);
|
void printBytes(u8* bytes, size_t size, bool includeHeader);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -23,6 +23,6 @@ namespace Language {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string operator ""_lang (const char* key, size_t size) {
|
inline std::string operator ""_lang(const char* key, size_t size) {
|
||||||
return Language::LanguageEntry(std::string(key, size));
|
return Language::LanguageEntry(std::string(key, size));
|
||||||
}
|
}
|
@ -74,8 +74,8 @@ namespace tin::network
|
|||||||
public:
|
public:
|
||||||
HTTPDownload(std::string url);
|
HTTPDownload(std::string url);
|
||||||
|
|
||||||
void BufferDataRange(void* buffer, size_t offset, size_t size, std::function<void (size_t sizeRead)> progressFunc);
|
void BufferDataRange(void* buffer, size_t offset, size_t size, std::function<void(size_t sizeRead)> progressFunc);
|
||||||
int StreamDataRange(size_t offset, size_t size, std::function<size_t (u8* bytes, size_t size)> streamFunc);
|
int StreamDataRange(size_t offset, size_t size, std::function<size_t(u8* bytes, size_t size)> streamFunc);
|
||||||
};
|
};
|
||||||
|
|
||||||
void NSULDrop(std::string url);
|
void NSULDrop(std::string url);
|
||||||
|
@ -12,35 +12,35 @@ extern "C" {
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "switch/types.h"
|
#include "switch/types.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u8 bInterfaceClass;
|
u8 bInterfaceClass;
|
||||||
u8 bInterfaceSubClass;
|
u8 bInterfaceSubClass;
|
||||||
u8 bInterfaceProtocol;
|
u8 bInterfaceProtocol;
|
||||||
} awoo_UsbCommsInterfaceInfo;
|
} awoo_UsbCommsInterfaceInfo;
|
||||||
|
|
||||||
/// Initializes usbComms with the default number of interfaces (1)
|
/// Initializes usbComms with the default number of interfaces (1)
|
||||||
Result awoo_usbCommsInitialize(void);
|
Result awoo_usbCommsInitialize(void);
|
||||||
|
|
||||||
/// Initializes usbComms with a specific number of interfaces.
|
/// Initializes usbComms with a specific number of interfaces.
|
||||||
Result awoo_usbCommsInitializeEx(u32 num_interfaces, const awoo_UsbCommsInterfaceInfo *infos);
|
Result awoo_usbCommsInitializeEx(u32 num_interfaces, const awoo_UsbCommsInterfaceInfo* infos);
|
||||||
|
|
||||||
/// Exits usbComms.
|
/// Exits usbComms.
|
||||||
void awoo_usbCommsExit(void);
|
void awoo_usbCommsExit(void);
|
||||||
|
|
||||||
/// Sets whether to throw a fatal error in usbComms{Read/Write}* on failure, or just return the transferred size. By default (false) the latter is used.
|
/// Sets whether to throw a fatal error in usbComms{Read/Write}* on failure, or just return the transferred size. By default (false) the latter is used.
|
||||||
void awoo_usbCommsSetErrorHandling(bool flag);
|
void awoo_usbCommsSetErrorHandling(bool flag);
|
||||||
|
|
||||||
/// Read data with the default interface.
|
/// Read data with the default interface.
|
||||||
size_t awoo_usbCommsRead(void* buffer, size_t size, u64 timeout);
|
size_t awoo_usbCommsRead(void* buffer, size_t size, u64 timeout);
|
||||||
|
|
||||||
/// Write data with the default interface.
|
/// Write data with the default interface.
|
||||||
size_t awoo_usbCommsWrite(const void* buffer, size_t size, u64 timeout);
|
size_t awoo_usbCommsWrite(const void* buffer, size_t size, u64 timeout);
|
||||||
|
|
||||||
/// Same as usbCommsRead except with the specified interface.
|
/// Same as usbCommsRead except with the specified interface.
|
||||||
size_t awoo_usbCommsReadEx(void* buffer, size_t size, u32 interface, u64 timeout);
|
size_t awoo_usbCommsReadEx(void* buffer, size_t size, u32 interface, u64 timeout);
|
||||||
|
|
||||||
/// Same as usbCommsWrite except with the specified interface.
|
/// Same as usbCommsWrite except with the specified interface.
|
||||||
size_t awoo_usbCommsWriteEx(const void* buffer, size_t size, u32 interface, u64 timeout);
|
size_t awoo_usbCommsWriteEx(const void* buffer, size_t size, u32 interface, u64 timeout);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,10 @@ namespace tin::util
|
|||||||
{
|
{
|
||||||
u32 magic;
|
u32 magic;
|
||||||
USBCmdType type;
|
USBCmdType type;
|
||||||
u8 padding[0x3] = {0};
|
u8 padding[0x3] = { 0 };
|
||||||
u32 cmdId;
|
u32 cmdId;
|
||||||
u64 dataSize;
|
u64 dataSize;
|
||||||
u8 reserved[0xC] = {0};
|
u8 reserved[0xC] = { 0 };
|
||||||
} PACKED;
|
} PACKED;
|
||||||
|
|
||||||
static_assert(sizeof(USBCmdHeader) == 0x20, "USBCmdHeader must be 0x20!");
|
static_assert(sizeof(USBCmdHeader) == 0x20, "USBCmdHeader must be 0x20!");
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace inst::util {
|
namespace inst::util {
|
||||||
void initApp ();
|
void initApp();
|
||||||
void deinitApp ();
|
void deinitApp();
|
||||||
void initInstallServices();
|
void initInstallServices();
|
||||||
void deinitInstallServices();
|
void deinitInstallServices();
|
||||||
bool ignoreCaseCompare(const std::string &a, const std::string &b);
|
bool ignoreCaseCompare(const std::string& a, const std::string& b);
|
||||||
std::vector<std::filesystem::path> getDirectoryFiles(const std::string & dir, const std::vector<std::string> & extensions);
|
std::vector<std::filesystem::path> getDirectoryFiles(const std::string& dir, const std::vector<std::string>& extensions);
|
||||||
std::vector<std::filesystem::path> getDirsAtPath(const std::string & dir);
|
std::vector<std::filesystem::path> getDirsAtPath(const std::string& dir);
|
||||||
bool removeDirectory(std::string dir);
|
bool removeDirectory(std::string dir);
|
||||||
bool copyFile(std::string inFile, std::string outFile);
|
bool copyFile(std::string inFile, std::string outFile);
|
||||||
std::string formatUrlString(std::string ourString);
|
std::string formatUrlString(std::string ourString);
|
||||||
|
@ -43,7 +43,7 @@ SOFTWARE.
|
|||||||
#include "ui/instPage.hpp"
|
#include "ui/instPage.hpp"
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace nspInstStuff_B {
|
namespace nspInstStuff_B {
|
||||||
@ -74,7 +74,8 @@ namespace nspInstStuff_B {
|
|||||||
if (ourTitleList[titleItr].extension() == ".xci" || ourTitleList[titleItr].extension() == ".xcz") {
|
if (ourTitleList[titleItr].extension() == ".xci" || ourTitleList[titleItr].extension() == ".xcz") {
|
||||||
auto sdmcXCI = std::make_shared<tin::install::xci::SDMCXCI>(ourTitleList[titleItr]);
|
auto sdmcXCI = std::make_shared<tin::install::xci::SDMCXCI>(ourTitleList[titleItr]);
|
||||||
installTask = std::make_unique<tin::install::xci::XCIInstallTask>(m_destStorageId, inst::config::ignoreReqVers, sdmcXCI);
|
installTask = std::make_unique<tin::install::xci::XCIInstallTask>(m_destStorageId, inst::config::ignoreReqVers, sdmcXCI);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
auto sdmcNSP = std::make_shared<tin::install::nsp::SDMCNSP>(ourTitleList[titleItr]);
|
auto sdmcNSP = std::make_shared<tin::install::nsp::SDMCNSP>(ourTitleList[titleItr]);
|
||||||
installTask = std::make_unique<tin::install::nsp::NSPInstall>(m_destStorageId, inst::config::ignoreReqVers, sdmcNSP);
|
installTask = std::make_unique<tin::install::nsp::NSPInstall>(m_destStorageId, inst::config::ignoreReqVers, sdmcNSP);
|
||||||
}
|
}
|
||||||
@ -100,8 +101,8 @@ namespace nspInstStuff_B {
|
|||||||
else {
|
else {
|
||||||
audioPath = "romfs:/audio/bark.wav";
|
audioPath = "romfs:/audio/bark.wav";
|
||||||
}
|
}
|
||||||
std::thread audioThread(inst::util::playAudio,audioPath);
|
std::thread audioThread(inst::util::playAudio, audioPath);
|
||||||
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true);
|
||||||
audioThread.join();
|
audioThread.join();
|
||||||
nspInstalled = false;
|
nspInstalled = false;
|
||||||
}
|
}
|
||||||
@ -112,7 +113,7 @@ namespace nspInstStuff_B {
|
|||||||
inst::util::setClockSpeed(2, previousClockValues[2]);
|
inst::util::setClockSpeed(2, previousClockValues[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nspInstalled) {
|
if (nspInstalled) {
|
||||||
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
|
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
|
||||||
inst::ui::instPage::setInstBarPerc(100);
|
inst::ui::instPage::setInstBarPerc(100);
|
||||||
std::string audioPath = "";
|
std::string audioPath = "";
|
||||||
@ -123,20 +124,23 @@ namespace nspInstStuff_B {
|
|||||||
else {
|
else {
|
||||||
audioPath = "romfs:/audio/ameizing.mp3";
|
audioPath = "romfs:/audio/ameizing.mp3";
|
||||||
}
|
}
|
||||||
std::thread audioThread(inst::util::playAudio,audioPath);
|
std::thread audioThread(inst::util::playAudio, audioPath);
|
||||||
|
|
||||||
if (ourTitleList.size() > 1) {
|
if (ourTitleList.size() > 1) {
|
||||||
if (inst::config::deletePrompt) {
|
if (inst::config::deletePrompt) {
|
||||||
if(inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.hd.delete_info_multi"_lang, "inst.hd.delete_desc"_lang, {"common.no"_lang,"common.yes"_lang}, false) == 1) {
|
if (inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.hd.delete_info_multi"_lang, "inst.hd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false) == 1) {
|
||||||
for (long unsigned int i = 0; i < ourTitleList.size(); i++) {
|
for (long unsigned int i = 0; i < ourTitleList.size(); i++) {
|
||||||
if (std::filesystem::exists(ourTitleList[i])) std::filesystem::remove(ourTitleList[i]);
|
if (std::filesystem::exists(ourTitleList[i])) std::filesystem::remove(ourTitleList[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
|
}
|
||||||
} else {
|
else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (inst::config::deletePrompt) {
|
if (inst::config::deletePrompt) {
|
||||||
if(inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + "inst.hd.delete_info"_lang, "inst.hd.delete_desc"_lang, {"common.no"_lang,"common.yes"_lang}, false) == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]);
|
if (inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + "inst.hd.delete_info"_lang, "inst.hd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false) == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]);
|
||||||
} else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
|
}
|
||||||
|
else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
audioThread.join();
|
audioThread.join();
|
||||||
|
@ -126,7 +126,7 @@ namespace tin::install::nsp
|
|||||||
|
|
||||||
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||||
|
|
||||||
inst::ui::instPage::setInstInfoText("inst.info_page.downloading"_lang + inst::util::formatUrlString(ncaFileName) + "inst.info_page.at"_lang + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
inst::ui::instPage::setInstInfoText("inst.info_page.downloading"_lang + inst::util::formatUrlString(ncaFileName) + "inst.info_page.at"_lang + std::to_string(speed).substr(0, std::to_string(speed).size() - 4) + "MB/s");
|
||||||
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
|
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,31 +121,31 @@ namespace tin::install::xci
|
|||||||
startTime = newTime;
|
startTime = newTime;
|
||||||
startSizeBuffered = newSizeBuffered;
|
startSizeBuffered = newSizeBuffered;
|
||||||
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||||
#ifdef NXLINK_DEBUG
|
#ifdef NXLINK_DEBUG
|
||||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||||
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
|
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
|
||||||
LOG_DEBUG("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
|
LOG_DEBUG("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inst::ui::instPage::setInstInfoText("inst.info_page.downloading"_lang + inst::util::formatUrlString(ncaFileName) + "inst.info_page.at"_lang + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
inst::ui::instPage::setInstInfoText("inst.info_page.downloading"_lang + inst::util::formatUrlString(ncaFileName) + "inst.info_page.at"_lang + std::to_string(speed).substr(0, std::to_string(speed).size() - 4) + "MB/s");
|
||||||
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
|
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inst::ui::instPage::setInstBarPerc(100);
|
inst::ui::instPage::setInstBarPerc(100);
|
||||||
|
|
||||||
#ifdef NXLINK_DEBUG
|
#ifdef NXLINK_DEBUG
|
||||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
|
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
|
||||||
inst::ui::instPage::setInstBarPerc(0);
|
inst::ui::instPage::setInstBarPerc(0);
|
||||||
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsHttpXci)
|
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsHttpXci)
|
||||||
{
|
{
|
||||||
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||||
#ifdef NXLINK_DEBUG
|
#ifdef NXLINK_DEBUG
|
||||||
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
||||||
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
|
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
|
||||||
#endif
|
#endif
|
||||||
inst::ui::instPage::setInstBarPerc((double)installProgress);
|
inst::ui::instPage::setInstBarPerc((double)installProgress);
|
||||||
}
|
}
|
||||||
inst::ui::instPage::setInstBarPerc(100);
|
inst::ui::instPage::setInstBarPerc(100);
|
||||||
|
@ -129,7 +129,7 @@ namespace tin::install
|
|||||||
LOG_DEBUG("WARNING: Ticket installation failed! This may not be an issue, depending on your use case.\nProceed with caution!\n");
|
LOG_DEBUG("WARNING: Ticket installation failed! This may not be an issue, depending on your use case.\nProceed with caution!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (nx::ncm::ContentMeta contentMeta: m_contentMeta) {
|
for (nx::ncm::ContentMeta contentMeta : m_contentMeta) {
|
||||||
LOG_DEBUG("Installing NCAs...\n");
|
LOG_DEBUG("Installing NCAs...\n");
|
||||||
for (auto& record : contentMeta.GetContentInfos())
|
for (auto& record : contentMeta.GetContentInfos())
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ SOFTWARE.
|
|||||||
#include "ui/MainApplication.hpp"
|
#include "ui/MainApplication.hpp"
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace tin::install::nsp
|
namespace tin::install::nsp
|
||||||
@ -72,7 +72,7 @@ namespace tin::install::nsp
|
|||||||
*(u64*)&cnmtContentInfo.size = cnmtNcaSize & 0xFFFFFFFFFFFF;
|
*(u64*)&cnmtContentInfo.size = cnmtNcaSize & 0xFFFFFFFFFFFF;
|
||||||
cnmtContentInfo.content_type = NcmContentType_Meta;
|
cnmtContentInfo.content_type = NcmContentType_Meta;
|
||||||
|
|
||||||
CNMTList.push_back( { tin::util::GetContentMetaFromNCA(cnmtNCAFullPath), cnmtContentInfo } );
|
CNMTList.push_back({ tin::util::GetContentMetaFromNCA(cnmtNCAFullPath), cnmtContentInfo });
|
||||||
}
|
}
|
||||||
|
|
||||||
return CNMTList;
|
return CNMTList;
|
||||||
@ -83,10 +83,10 @@ namespace tin::install::nsp
|
|||||||
const PFS0FileEntry* fileEntry = m_NSP->GetFileEntryByNcaId(ncaId);
|
const PFS0FileEntry* fileEntry = m_NSP->GetFileEntryByNcaId(ncaId);
|
||||||
std::string ncaFileName = m_NSP->GetFileEntryName(fileEntry);
|
std::string ncaFileName = m_NSP->GetFileEntryName(fileEntry);
|
||||||
|
|
||||||
#ifdef NXLINK_DEBUG
|
#ifdef NXLINK_DEBUG
|
||||||
size_t ncaSize = fileEntry->fileSize;
|
size_t ncaSize = fileEntry->fileSize;
|
||||||
LOG_DEBUG("Installing %s to storage Id %u\n", ncaFileName.c_str(), m_destStorageId);
|
LOG_DEBUG("Installing %s to storage Id %u\n", ncaFileName.c_str(), m_destStorageId);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::shared_ptr<nx::ncm::ContentStorage> contentStorage(new nx::ncm::ContentStorage(m_destStorageId));
|
std::shared_ptr<nx::ncm::ContentStorage> contentStorage(new nx::ncm::ContentStorage(m_destStorageId));
|
||||||
|
|
||||||
@ -114,8 +114,8 @@ namespace tin::install::nsp
|
|||||||
std::string audioPath = "romfs:/audio/bark.wav";
|
std::string audioPath = "romfs:/audio/bark.wav";
|
||||||
if (inst::config::gayMode) audioPath = "";
|
if (inst::config::gayMode) audioPath = "";
|
||||||
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
||||||
std::thread audioThread(inst::util::playAudio,audioPath);
|
std::thread audioThread(inst::util::playAudio, audioPath);
|
||||||
int rc = inst::ui::mainApp->CreateShowDialog("inst.nca_verify.title"_lang, "inst.nca_verify.desc"_lang, {"common.cancel"_lang, "inst.nca_verify.opt1"_lang}, false);
|
int rc = inst::ui::mainApp->CreateShowDialog("inst.nca_verify.title"_lang, "inst.nca_verify.desc"_lang, { "common.cancel"_lang, "inst.nca_verify.opt1"_lang }, false);
|
||||||
audioThread.join();
|
audioThread.join();
|
||||||
if (rc != 1)
|
if (rc != 1)
|
||||||
THROW_FORMAT(("inst.nca_verify.error"_lang + tin::util::GetNcaIdString(ncaId)).c_str());
|
THROW_FORMAT(("inst.nca_verify.error"_lang + tin::util::GetNcaIdString(ncaId)).c_str());
|
||||||
|
@ -35,7 +35,7 @@ SOFTWARE.
|
|||||||
#include "ui/MainApplication.hpp"
|
#include "ui/MainApplication.hpp"
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace tin::install::xci
|
namespace tin::install::xci
|
||||||
@ -68,7 +68,7 @@ namespace tin::install::xci
|
|||||||
*(u64*)&cnmtContentInfo.size = cnmtNcaSize & 0xFFFFFFFFFFFF;
|
*(u64*)&cnmtContentInfo.size = cnmtNcaSize & 0xFFFFFFFFFFFF;
|
||||||
cnmtContentInfo.content_type = NcmContentType_Meta;
|
cnmtContentInfo.content_type = NcmContentType_Meta;
|
||||||
|
|
||||||
CNMTList.push_back( { tin::util::GetContentMetaFromNCA(cnmtNCAFullPath), cnmtContentInfo } );
|
CNMTList.push_back({ tin::util::GetContentMetaFromNCA(cnmtNCAFullPath), cnmtContentInfo });
|
||||||
}
|
}
|
||||||
|
|
||||||
return CNMTList;
|
return CNMTList;
|
||||||
@ -79,10 +79,10 @@ namespace tin::install::xci
|
|||||||
const HFS0FileEntry* fileEntry = m_xci->GetFileEntryByNcaId(ncaId);
|
const HFS0FileEntry* fileEntry = m_xci->GetFileEntryByNcaId(ncaId);
|
||||||
std::string ncaFileName = m_xci->GetFileEntryName(fileEntry);
|
std::string ncaFileName = m_xci->GetFileEntryName(fileEntry);
|
||||||
|
|
||||||
#ifdef NXLINK_DEBUG
|
#ifdef NXLINK_DEBUG
|
||||||
size_t ncaSize = fileEntry->fileSize;
|
size_t ncaSize = fileEntry->fileSize;
|
||||||
LOG_DEBUG("Installing %s to storage Id %u\n", ncaFileName.c_str(), m_destStorageId);
|
LOG_DEBUG("Installing %s to storage Id %u\n", ncaFileName.c_str(), m_destStorageId);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::shared_ptr<nx::ncm::ContentStorage> contentStorage(new nx::ncm::ContentStorage(m_destStorageId));
|
std::shared_ptr<nx::ncm::ContentStorage> contentStorage(new nx::ncm::ContentStorage(m_destStorageId));
|
||||||
|
|
||||||
@ -110,8 +110,8 @@ namespace tin::install::xci
|
|||||||
std::string audioPath = "romfs:/audio/bark.wav";
|
std::string audioPath = "romfs:/audio/bark.wav";
|
||||||
if (inst::config::gayMode) audioPath = "";
|
if (inst::config::gayMode) audioPath = "";
|
||||||
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
||||||
std::thread audioThread(inst::util::playAudio,audioPath);
|
std::thread audioThread(inst::util::playAudio, audioPath);
|
||||||
int rc = inst::ui::mainApp->CreateShowDialog("inst.nca_verify.title"_lang, "inst.nca_verify.desc"_lang, {"common.cancel"_lang, "inst.nca_verify.opt1"_lang}, false);
|
int rc = inst::ui::mainApp->CreateShowDialog("inst.nca_verify.title"_lang, "inst.nca_verify.desc"_lang, { "common.cancel"_lang, "inst.nca_verify.opt1"_lang }, false);
|
||||||
audioThread.join();
|
audioThread.join();
|
||||||
if (rc != 1)
|
if (rc != 1)
|
||||||
THROW_FORMAT(("inst.nca_verify.error"_lang + tin::util::GetNcaIdString(ncaId)).c_str());
|
THROW_FORMAT(("inst.nca_verify.error"_lang + tin::util::GetNcaIdString(ncaId)).c_str());
|
||||||
|
@ -42,7 +42,7 @@ namespace tin::install::nsp
|
|||||||
inst::ui::instPage::setInstBarPerc(0);
|
inst::ui::instPage::setInstBarPerc(0);
|
||||||
while (fileOff < ncaSize)
|
while (fileOff < ncaSize)
|
||||||
{
|
{
|
||||||
progress = (float) fileOff / (float) ncaSize;
|
progress = (float)fileOff / (float)ncaSize;
|
||||||
|
|
||||||
if (fileOff % (0x400000 * 3) == 0) {
|
if (fileOff % (0x400000 * 3) == 0) {
|
||||||
LOG_DEBUG("> Progress: %lu/%lu MB (%d%s)\r", (fileOff / 1000000), (ncaSize / 1000000), (int)(progress * 100.0), "%");
|
LOG_DEBUG("> Progress: %lu/%lu MB (%d%s)\r", (fileOff / 1000000), (ncaSize / 1000000), (int)(progress * 100.0), "%");
|
||||||
|
@ -42,7 +42,7 @@ namespace tin::install::xci
|
|||||||
inst::ui::instPage::setInstBarPerc(0);
|
inst::ui::instPage::setInstBarPerc(0);
|
||||||
while (fileOff < ncaSize)
|
while (fileOff < ncaSize)
|
||||||
{
|
{
|
||||||
progress = (float) fileOff / (float) ncaSize;
|
progress = (float)fileOff / (float)ncaSize;
|
||||||
|
|
||||||
if (fileOff % (0x400000 * 3) == 0) {
|
if (fileOff % (0x400000 * 3) == 0) {
|
||||||
LOG_DEBUG("> Progress: %lu/%lu MB (%d%s)\r", (fileOff / 1000000), (ncaSize / 1000000), (int)(progress * 100.0), "%");
|
LOG_DEBUG("> Progress: %lu/%lu MB (%d%s)\r", (fileOff / 1000000), (ncaSize / 1000000), (int)(progress * 100.0), "%");
|
||||||
|
@ -30,7 +30,7 @@ SOFTWARE.
|
|||||||
namespace tin::install::nsp
|
namespace tin::install::nsp
|
||||||
{
|
{
|
||||||
SimpleFileSystem::SimpleFileSystem(nx::fs::IFileSystem& fileSystem, std::string rootPath, std::string absoluteRootPath) :
|
SimpleFileSystem::SimpleFileSystem(nx::fs::IFileSystem& fileSystem, std::string rootPath, std::string absoluteRootPath) :
|
||||||
m_fileSystem(&fileSystem) , m_rootPath(rootPath), m_absoluteRootPath(absoluteRootPath)
|
m_fileSystem(&fileSystem), m_rootPath(rootPath), m_absoluteRootPath(absoluteRootPath)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
SimpleFileSystem::~SimpleFileSystem() {}
|
SimpleFileSystem::~SimpleFileSystem() {}
|
||||||
|
@ -147,31 +147,31 @@ namespace tin::install::nsp
|
|||||||
startTime = newTime;
|
startTime = newTime;
|
||||||
startSizeBuffered = newSizeBuffered;
|
startSizeBuffered = newSizeBuffered;
|
||||||
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||||
#ifdef NXLINK_DEBUG
|
#ifdef NXLINK_DEBUG
|
||||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||||
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
|
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
|
||||||
LOG_DEBUG("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
|
LOG_DEBUG("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inst::ui::instPage::setInstInfoText("inst.info_page.downloading"_lang + inst::util::formatUrlString(ncaFileName) + "inst.info_page.at"_lang + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
inst::ui::instPage::setInstInfoText("inst.info_page.downloading"_lang + inst::util::formatUrlString(ncaFileName) + "inst.info_page.at"_lang + std::to_string(speed).substr(0, std::to_string(speed).size() - 4) + "MB/s");
|
||||||
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
|
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inst::ui::instPage::setInstBarPerc(100);
|
inst::ui::instPage::setInstBarPerc(100);
|
||||||
|
|
||||||
#ifdef NXLINK_DEBUG
|
#ifdef NXLINK_DEBUG
|
||||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
|
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
|
||||||
inst::ui::instPage::setInstBarPerc(0);
|
inst::ui::instPage::setInstBarPerc(0);
|
||||||
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbNsp)
|
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbNsp)
|
||||||
{
|
{
|
||||||
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||||
#ifdef NXLINK_DEBUG
|
#ifdef NXLINK_DEBUG
|
||||||
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
||||||
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
|
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
|
||||||
#endif
|
#endif
|
||||||
inst::ui::instPage::setInstBarPerc((double)installProgress);
|
inst::ui::instPage::setInstBarPerc((double)installProgress);
|
||||||
}
|
}
|
||||||
inst::ui::instPage::setInstBarPerc(100);
|
inst::ui::instPage::setInstBarPerc(100);
|
||||||
|
@ -146,31 +146,31 @@ namespace tin::install::xci
|
|||||||
startTime = newTime;
|
startTime = newTime;
|
||||||
startSizeBuffered = newSizeBuffered;
|
startSizeBuffered = newSizeBuffered;
|
||||||
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||||
#ifdef NXLINK_DEBUG
|
#ifdef NXLINK_DEBUG
|
||||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||||
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
|
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
|
||||||
LOG_DEBUG("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
|
LOG_DEBUG("> Download Progress: %lu/%lu MB (%i%s) (%.2f MB/s)\r", downloadSizeMB, totalSizeMB, downloadProgress, "%", speed);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inst::ui::instPage::setInstInfoText("inst.info_page.downloading"_lang + inst::util::formatUrlString(ncaFileName) + "inst.info_page.at"_lang + std::to_string(speed).substr(0, std::to_string(speed).size()-4) + "MB/s");
|
inst::ui::instPage::setInstInfoText("inst.info_page.downloading"_lang + inst::util::formatUrlString(ncaFileName) + "inst.info_page.at"_lang + std::to_string(speed).substr(0, std::to_string(speed).size() - 4) + "MB/s");
|
||||||
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
|
inst::ui::instPage::setInstBarPerc((double)downloadProgress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inst::ui::instPage::setInstBarPerc(100);
|
inst::ui::instPage::setInstBarPerc(100);
|
||||||
|
|
||||||
#ifdef NXLINK_DEBUG
|
#ifdef NXLINK_DEBUG
|
||||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
|
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
|
||||||
inst::ui::instPage::setInstBarPerc(0);
|
inst::ui::instPage::setInstBarPerc(0);
|
||||||
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbXci)
|
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbXci)
|
||||||
{
|
{
|
||||||
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||||
#ifdef NXLINK_DEBUG
|
#ifdef NXLINK_DEBUG
|
||||||
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
||||||
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
|
LOG_DEBUG("> Install Progress: %lu/%lu MB (%i%s)\r", installSizeMB, totalSizeMB, installProgress, "%");
|
||||||
#endif
|
#endif
|
||||||
inst::ui::instPage::setInstBarPerc((double)installProgress);
|
inst::ui::instPage::setInstBarPerc((double)installProgress);
|
||||||
}
|
}
|
||||||
inst::ui::instPage::setInstBarPerc(100);
|
inst::ui::instPage::setInstBarPerc(100);
|
||||||
|
@ -47,7 +47,7 @@ namespace tin::install::xci
|
|||||||
printBytes(m_headerBytes.data(), sizeof(HFS0BaseHeader), true);
|
printBytes(m_headerBytes.data(), sizeof(HFS0BaseHeader), true);
|
||||||
|
|
||||||
// Retrieve full header
|
// Retrieve full header
|
||||||
HFS0BaseHeader *header = reinterpret_cast<HFS0BaseHeader*>(m_headerBytes.data());
|
HFS0BaseHeader* header = reinterpret_cast<HFS0BaseHeader*>(m_headerBytes.data());
|
||||||
if (header->magic != MAGIC_HFS0)
|
if (header->magic != MAGIC_HFS0)
|
||||||
THROW_FORMAT("hfs0 magic doesn't match at 0x%lx\n", hfs0Offset);
|
THROW_FORMAT("hfs0 magic doesn't match at 0x%lx\n", hfs0Offset);
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ namespace tin::install::xci
|
|||||||
header = reinterpret_cast<HFS0BaseHeader*>(m_headerBytes.data());
|
header = reinterpret_cast<HFS0BaseHeader*>(m_headerBytes.data());
|
||||||
for (unsigned int i = 0; i < header->numFiles; i++)
|
for (unsigned int i = 0; i < header->numFiles; i++)
|
||||||
{
|
{
|
||||||
const HFS0FileEntry *entry = hfs0GetFileEntry(header, i);
|
const HFS0FileEntry* entry = hfs0GetFileEntry(header, i);
|
||||||
std::string entryName(hfs0GetFileName(header, entry));
|
std::string entryName(hfs0GetFileName(header, entry));
|
||||||
|
|
||||||
if (entryName != "secure")
|
if (entryName != "secure")
|
||||||
|
@ -17,7 +17,8 @@ int main(int argc, char* argv[])
|
|||||||
main->Prepare();
|
main->Prepare();
|
||||||
main->ShowWithFadeIn();
|
main->ShowWithFadeIn();
|
||||||
updateThread.join();
|
updateThread.join();
|
||||||
} catch (std::exception& e) {
|
}
|
||||||
|
catch (std::exception& e) {
|
||||||
LOG_DEBUG("An error occurred:\n%s", e.what());
|
LOG_DEBUG("An error occurred:\n%s", e.what());
|
||||||
}
|
}
|
||||||
inst::util::deinitApp();
|
inst::util::deinitApp();
|
||||||
|
@ -50,10 +50,10 @@ static int m_serverSocket = 0;
|
|||||||
static int m_clientSocket = 0;
|
static int m_clientSocket = 0;
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace netInstStuff{
|
namespace netInstStuff {
|
||||||
|
|
||||||
void InitializeServerSocket() try
|
void InitializeServerSocket() try
|
||||||
{
|
{
|
||||||
@ -70,7 +70,7 @@ namespace netInstStuff{
|
|||||||
server.sin_port = htons(REMOTE_INSTALL_PORT);
|
server.sin_port = htons(REMOTE_INSTALL_PORT);
|
||||||
server.sin_addr.s_addr = htonl(INADDR_ANY);
|
server.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||||
|
|
||||||
if (bind(m_serverSocket, (struct sockaddr*) &server, sizeof(server)) < 0)
|
if (bind(m_serverSocket, (struct sockaddr*)&server, sizeof(server)) < 0)
|
||||||
{
|
{
|
||||||
THROW_FORMAT("Failed to bind server socket. Error code: %u\n", errno);
|
THROW_FORMAT("Failed to bind server socket. Error code: %u\n", errno);
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ namespace netInstStuff{
|
|||||||
close(m_serverSocket);
|
close(m_serverSocket);
|
||||||
m_serverSocket = 0;
|
m_serverSocket = 0;
|
||||||
}
|
}
|
||||||
inst::ui::mainApp->CreateShowDialog("Failed to initialize server socket!", (std::string)e.what(), {"OK"}, true);
|
inst::ui::mainApp->CreateShowDialog("Failed to initialize server socket!", (std::string)e.what(), { "OK" }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnUnwound()
|
void OnUnwound()
|
||||||
@ -133,7 +133,8 @@ namespace netInstStuff{
|
|||||||
for (long unsigned int i = 0; i < urlListAltNames.size(); i++) {
|
for (long unsigned int i = 0; i < urlListAltNames.size(); i++) {
|
||||||
urlNames.push_back(inst::util::shortenString(urlListAltNames[i], 38, true));
|
urlNames.push_back(inst::util::shortenString(urlListAltNames[i], 38, true));
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
for (long unsigned int i = 0; i < ourUrlList.size(); i++) {
|
for (long unsigned int i = 0; i < ourUrlList.size(); i++) {
|
||||||
urlNames.push_back(inst::util::shortenString(inst::util::formatUrlString(ourUrlList[i]), 38, true));
|
urlNames.push_back(inst::util::shortenString(inst::util::formatUrlString(ourUrlList[i]), 38, true));
|
||||||
}
|
}
|
||||||
@ -155,7 +156,8 @@ namespace netInstStuff{
|
|||||||
if (inst::curl::downloadToBuffer(ourUrlList[urlItr], 0x100, 0x103) == "HEAD") {
|
if (inst::curl::downloadToBuffer(ourUrlList[urlItr], 0x100, 0x103) == "HEAD") {
|
||||||
auto httpXCI = std::make_shared<tin::install::xci::HTTPXCI>(ourUrlList[urlItr]);
|
auto httpXCI = std::make_shared<tin::install::xci::HTTPXCI>(ourUrlList[urlItr]);
|
||||||
installTask = std::make_unique<tin::install::xci::XCIInstallTask>(m_destStorageId, inst::config::ignoreReqVers, httpXCI);
|
installTask = std::make_unique<tin::install::xci::XCIInstallTask>(m_destStorageId, inst::config::ignoreReqVers, httpXCI);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
auto httpNSP = std::make_shared<tin::install::nsp::HTTPNSP>(ourUrlList[urlItr]);
|
auto httpNSP = std::make_shared<tin::install::nsp::HTTPNSP>(ourUrlList[urlItr]);
|
||||||
installTask = std::make_unique<tin::install::nsp::NSPInstall>(m_destStorageId, inst::config::ignoreReqVers, httpNSP);
|
installTask = std::make_unique<tin::install::nsp::NSPInstall>(m_destStorageId, inst::config::ignoreReqVers, httpNSP);
|
||||||
}
|
}
|
||||||
@ -176,8 +178,8 @@ namespace netInstStuff{
|
|||||||
std::string audioPath = "romfs:/audio/bark.wav";
|
std::string audioPath = "romfs:/audio/bark.wav";
|
||||||
if (inst::config::gayMode) audioPath = "";
|
if (inst::config::gayMode) audioPath = "";
|
||||||
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
||||||
std::thread audioThread(inst::util::playAudio,audioPath);
|
std::thread audioThread(inst::util::playAudio, audioPath);
|
||||||
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + urlNames[urlItr] + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + urlNames[urlItr] + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true);
|
||||||
audioThread.join();
|
audioThread.join();
|
||||||
nspInstalled = false;
|
nspInstalled = false;
|
||||||
}
|
}
|
||||||
@ -191,15 +193,15 @@ namespace netInstStuff{
|
|||||||
sendExitCommands(inst::util::formatUrlLink(ourUrlList[0]));
|
sendExitCommands(inst::util::formatUrlLink(ourUrlList[0]));
|
||||||
OnUnwound();
|
OnUnwound();
|
||||||
|
|
||||||
if(nspInstalled) {
|
if (nspInstalled) {
|
||||||
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
|
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
|
||||||
inst::ui::instPage::setInstBarPerc(100);
|
inst::ui::instPage::setInstBarPerc(100);
|
||||||
std::string audioPath = "romfs:/audio/awoo.wav";
|
std::string audioPath = "romfs:/audio/awoo.wav";
|
||||||
if (inst::config::gayMode) audioPath = "";
|
if (inst::config::gayMode) audioPath = "";
|
||||||
if (std::filesystem::exists(inst::config::appDir + "/awoo.wav")) audioPath = inst::config::appDir + "/awoo.wav";
|
if (std::filesystem::exists(inst::config::appDir + "/awoo.wav")) audioPath = inst::config::appDir + "/awoo.wav";
|
||||||
std::thread audioThread(inst::util::playAudio,audioPath);
|
std::thread audioThread(inst::util::playAudio, audioPath);
|
||||||
if (ourUrlList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
|
if (ourUrlList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true);
|
||||||
else inst::ui::mainApp->CreateShowDialog(urlNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
|
else inst::ui::mainApp->CreateShowDialog(urlNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true);
|
||||||
audioThread.join();
|
audioThread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,11 +258,11 @@ namespace netInstStuff{
|
|||||||
}
|
}
|
||||||
if (kDown & HidNpadButton_Y)
|
if (kDown & HidNpadButton_Y)
|
||||||
{
|
{
|
||||||
return {"supplyUrl"};
|
return { "supplyUrl" };
|
||||||
}
|
}
|
||||||
if (kDown & HidNpadButton_X)
|
if (kDown & HidNpadButton_X)
|
||||||
{
|
{
|
||||||
inst::ui::mainApp->CreateShowDialog("inst.net.help.title"_lang, "inst.net.help.desc"_lang, {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("inst.net.help.title"_lang, "inst.net.help.desc"_lang, { "common.ok"_lang }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sockaddr_in client;
|
struct sockaddr_in client;
|
||||||
@ -283,8 +285,8 @@ namespace netInstStuff{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the last string is null terminated
|
// Make sure the last string is null terminated
|
||||||
auto urlBuf = std::make_unique<char[]>(size+1);
|
auto urlBuf = std::make_unique<char[]>(size + 1);
|
||||||
memset(urlBuf.get(), 0, size+1);
|
memset(urlBuf.get(), 0, size + 1);
|
||||||
|
|
||||||
tin::network::WaitReceiveNetworkData(m_clientSocket, urlBuf.get(), size);
|
tin::network::WaitReceiveNetworkData(m_clientSocket, urlBuf.get(), size);
|
||||||
|
|
||||||
@ -311,7 +313,7 @@ namespace netInstStuff{
|
|||||||
LOG_DEBUG("Failed to perform remote install!\n");
|
LOG_DEBUG("Failed to perform remote install!\n");
|
||||||
LOG_DEBUG("%s", e.what());
|
LOG_DEBUG("%s", e.what());
|
||||||
fprintf(stdout, "%s", e.what());
|
fprintf(stdout, "%s", e.what());
|
||||||
inst::ui::mainApp->CreateShowDialog("inst.net.failed"_lang, (std::string)e.what(), {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("inst.net.failed"_lang, (std::string)e.what(), { "common.ok"_lang }, true);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ void esExit(void) {
|
|||||||
serviceClose(&g_esSrv);
|
serviceClose(&g_esSrv);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result esImportTicket(void const *tikBuf, size_t tikSize, void const *certBuf, size_t certSize) {
|
Result esImportTicket(void const* tikBuf, size_t tikSize, void const* certBuf, size_t certSize) {
|
||||||
return serviceDispatch(&g_esSrv, 1,
|
return serviceDispatch(&g_esSrv, 1,
|
||||||
.buffer_attrs = {
|
.buffer_attrs = {
|
||||||
SfBufferAttr_HipcMapAlias | SfBufferAttr_In,
|
SfBufferAttr_HipcMapAlias | SfBufferAttr_In,
|
||||||
|
@ -30,9 +30,10 @@ Result nsextInitialize(void) {
|
|||||||
Result rc = nsInitialize();
|
Result rc = nsInitialize();
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
if(hosversionBefore(3,0,0)) {
|
if (hosversionBefore(3, 0, 0)) {
|
||||||
g_nsAppManSrv = *nsGetServiceSession_ApplicationManagerInterface();
|
g_nsAppManSrv = *nsGetServiceSession_ApplicationManagerInterface();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
rc = nsGetApplicationManagerInterface(&g_nsAppManSrv);
|
rc = nsGetApplicationManagerInterface(&g_nsAppManSrv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,12 +42,12 @@ Result nsextInitialize(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void nsextExit(void) {
|
void nsextExit(void) {
|
||||||
if(hosversionAtLeast(3,0,0))
|
if (hosversionAtLeast(3, 0, 0))
|
||||||
serviceClose(&g_nsAppManSrv);
|
serviceClose(&g_nsAppManSrv);
|
||||||
nsExit();
|
nsExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result nsPushApplicationRecord(u64 application_id, NsApplicationRecordType last_modified_event, ContentStorageRecord *content_records, u32 count) {
|
Result nsPushApplicationRecord(u64 application_id, NsApplicationRecordType last_modified_event, ContentStorageRecord* content_records, u32 count) {
|
||||||
struct {
|
struct {
|
||||||
u8 last_modified_event;
|
u8 last_modified_event;
|
||||||
u64 application_id;
|
u64 application_id;
|
||||||
|
@ -42,7 +42,7 @@ SOFTWARE.
|
|||||||
#include "ui/instPage.hpp"
|
#include "ui/instPage.hpp"
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace nspInstStuff {
|
namespace nspInstStuff {
|
||||||
@ -73,7 +73,8 @@ namespace nspInstStuff {
|
|||||||
if (ourTitleList[titleItr].extension() == ".xci" || ourTitleList[titleItr].extension() == ".xcz") {
|
if (ourTitleList[titleItr].extension() == ".xci" || ourTitleList[titleItr].extension() == ".xcz") {
|
||||||
auto sdmcXCI = std::make_shared<tin::install::xci::SDMCXCI>(ourTitleList[titleItr]);
|
auto sdmcXCI = std::make_shared<tin::install::xci::SDMCXCI>(ourTitleList[titleItr]);
|
||||||
installTask = std::make_unique<tin::install::xci::XCIInstallTask>(m_destStorageId, inst::config::ignoreReqVers, sdmcXCI);
|
installTask = std::make_unique<tin::install::xci::XCIInstallTask>(m_destStorageId, inst::config::ignoreReqVers, sdmcXCI);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
auto sdmcNSP = std::make_shared<tin::install::nsp::SDMCNSP>(ourTitleList[titleItr]);
|
auto sdmcNSP = std::make_shared<tin::install::nsp::SDMCNSP>(ourTitleList[titleItr]);
|
||||||
installTask = std::make_unique<tin::install::nsp::NSPInstall>(m_destStorageId, inst::config::ignoreReqVers, sdmcNSP);
|
installTask = std::make_unique<tin::install::nsp::NSPInstall>(m_destStorageId, inst::config::ignoreReqVers, sdmcNSP);
|
||||||
}
|
}
|
||||||
@ -95,8 +96,8 @@ namespace nspInstStuff {
|
|||||||
std::string audioPath = "romfs:/audio/bark.wav";
|
std::string audioPath = "romfs:/audio/bark.wav";
|
||||||
if (inst::config::gayMode) audioPath = "";
|
if (inst::config::gayMode) audioPath = "";
|
||||||
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
||||||
std::thread audioThread(inst::util::playAudio,audioPath);
|
std::thread audioThread(inst::util::playAudio, audioPath);
|
||||||
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true);
|
||||||
audioThread.join();
|
audioThread.join();
|
||||||
nspInstalled = false;
|
nspInstalled = false;
|
||||||
}
|
}
|
||||||
@ -107,35 +108,40 @@ namespace nspInstStuff {
|
|||||||
inst::util::setClockSpeed(2, previousClockValues[2]);
|
inst::util::setClockSpeed(2, previousClockValues[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nspInstalled) {
|
if (nspInstalled) {
|
||||||
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
|
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
|
||||||
inst::ui::instPage::setInstBarPerc(100);
|
inst::ui::instPage::setInstBarPerc(100);
|
||||||
std::string audioPath = "romfs:/audio/awoo.wav";
|
std::string audioPath = "romfs:/audio/awoo.wav";
|
||||||
if (inst::config::gayMode) audioPath = "";
|
if (inst::config::gayMode) audioPath = "";
|
||||||
if (std::filesystem::exists(inst::config::appDir + "/awoo.wav")) audioPath = inst::config::appDir + "/awoo.wav";
|
if (std::filesystem::exists(inst::config::appDir + "/awoo.wav")) audioPath = inst::config::appDir + "/awoo.wav";
|
||||||
std::thread audioThread(inst::util::playAudio,audioPath);
|
std::thread audioThread(inst::util::playAudio, audioPath);
|
||||||
if (ourTitleList.size() > 1) {
|
if (ourTitleList.size() > 1) {
|
||||||
if (inst::config::deletePrompt) {
|
if (inst::config::deletePrompt) {
|
||||||
if(inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.sd.delete_info_multi"_lang, "inst.sd.delete_desc"_lang, {"common.no"_lang,"common.yes"_lang}, false) == 1) {
|
if (inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.sd.delete_info_multi"_lang, "inst.sd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false) == 1) {
|
||||||
for (long unsigned int i = 0; i < ourTitleList.size(); i++) {
|
for (long unsigned int i = 0; i < ourTitleList.size(); i++) {
|
||||||
if (std::filesystem::exists(ourTitleList[i])) {
|
if (std::filesystem::exists(ourTitleList[i])) {
|
||||||
try {
|
try {
|
||||||
std::filesystem::remove(ourTitleList[i]);
|
std::filesystem::remove(ourTitleList[i]);
|
||||||
} catch (...){ };
|
}
|
||||||
|
catch (...) {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
|
}
|
||||||
} else {
|
else inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (inst::config::deletePrompt) {
|
if (inst::config::deletePrompt) {
|
||||||
if(inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + "inst.sd.delete_info"_lang, "inst.sd.delete_desc"_lang, {"common.no"_lang,"common.yes"_lang}, false) == 1) {
|
if (inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + "inst.sd.delete_info"_lang, "inst.sd.delete_desc"_lang, { "common.no"_lang,"common.yes"_lang }, false) == 1) {
|
||||||
if (std::filesystem::exists(ourTitleList[0])) {
|
if (std::filesystem::exists(ourTitleList[0])) {
|
||||||
try {
|
try {
|
||||||
std::filesystem::remove(ourTitleList[0]);
|
std::filesystem::remove(ourTitleList[0]);
|
||||||
} catch (...){ };
|
}
|
||||||
|
catch (...) {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
|
}
|
||||||
|
else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true);
|
||||||
}
|
}
|
||||||
audioThread.join();
|
audioThread.join();
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
#include "util/lang.hpp"
|
#include "util/lang.hpp"
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace sig {
|
namespace sig {
|
||||||
void installSigPatches () {
|
void installSigPatches() {
|
||||||
bpcInitialize();
|
bpcInitialize();
|
||||||
try {
|
try {
|
||||||
std::string patchesVersion = inst::util::readTextFromFile("sdmc:/atmosphere/exefs_patches/es_patches/patches.txt");
|
std::string patchesVersion = inst::util::readTextFromFile("sdmc:/atmosphere/exefs_patches/es_patches/patches.txt");
|
||||||
@ -22,21 +22,21 @@ namespace sig {
|
|||||||
versionText = "\n\n" + "sig.version_text"_lang + patchesVersion + ".";
|
versionText = "\n\n" + "sig.version_text"_lang + patchesVersion + ".";
|
||||||
installButtonText = "sig.update"_lang;
|
installButtonText = "sig.update"_lang;
|
||||||
}
|
}
|
||||||
int ourResult = inst::ui::mainApp->CreateShowDialog("sig.title0"_lang, "sig.desc0"_lang + versionText, {installButtonText, "sig.uninstall"_lang, "common.cancel"_lang}, true);
|
int ourResult = inst::ui::mainApp->CreateShowDialog("sig.title0"_lang, "sig.desc0"_lang + versionText, { installButtonText, "sig.uninstall"_lang, "common.cancel"_lang }, true);
|
||||||
if (ourResult == 0) {
|
if (ourResult == 0) {
|
||||||
if (inst::util::getIPAddress() == "1.0.0.127") {
|
if (inst::util::getIPAddress() == "1.0.0.127") {
|
||||||
inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!inst::util::copyFile("sdmc:/bootloader/patches.ini", inst::config::appDir + "/patches.ini.old")) {
|
if (!inst::util::copyFile("sdmc:/bootloader/patches.ini", inst::config::appDir + "/patches.ini.old")) {
|
||||||
if (inst::ui::mainApp->CreateShowDialog("sig.backup_failed"_lang, "sig.backup_failed_desc"_lang, {"common.yes"_lang, "common.no"_lang}, false)) return;
|
if (inst::ui::mainApp->CreateShowDialog("sig.backup_failed"_lang, "sig.backup_failed_desc"_lang, { "common.yes"_lang, "common.no"_lang }, false)) return;
|
||||||
}
|
}
|
||||||
std::string ourPath = inst::config::appDir + "/patches.zip";
|
std::string ourPath = inst::config::appDir + "/patches.zip";
|
||||||
bool didDownload = inst::curl::downloadFile(inst::config::sigPatchesUrl, ourPath.c_str());
|
bool didDownload = inst::curl::downloadFile(inst::config::sigPatchesUrl, ourPath.c_str());
|
||||||
bool didExtract = false;
|
bool didExtract = false;
|
||||||
if (didDownload) didExtract = inst::zip::extractFile(ourPath, "sdmc:/");
|
if (didDownload) didExtract = inst::zip::extractFile(ourPath, "sdmc:/");
|
||||||
else {
|
else {
|
||||||
inst::ui::mainApp->CreateShowDialog("sig.download_failed"_lang, "sig.download_failed_desc"_lang, {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("sig.download_failed"_lang, "sig.download_failed_desc"_lang, { "common.ok"_lang }, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::filesystem::remove(ourPath);
|
std::filesystem::remove(ourPath);
|
||||||
@ -44,29 +44,32 @@ namespace sig {
|
|||||||
patchesVersion = inst::util::readTextFromFile("sdmc:/atmosphere/exefs_patches/es_patches/patches.txt");
|
patchesVersion = inst::util::readTextFromFile("sdmc:/atmosphere/exefs_patches/es_patches/patches.txt");
|
||||||
versionText = "";
|
versionText = "";
|
||||||
if (patchesVersion != "") versionText = "sig.version_text2"_lang + patchesVersion + "! ";
|
if (patchesVersion != "") versionText = "sig.version_text2"_lang + patchesVersion + "! ";
|
||||||
if (inst::ui::mainApp->CreateShowDialog("sig.install_complete"_lang, versionText + "\n\n" + "sig.complete_desc"_lang, {"sig.restart"_lang, "sig.later"_lang}, false) == 0) bpcRebootSystem();
|
if (inst::ui::mainApp->CreateShowDialog("sig.install_complete"_lang, versionText + "\n\n" + "sig.complete_desc"_lang, { "sig.restart"_lang, "sig.later"_lang }, false) == 0) bpcRebootSystem();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
inst::ui::mainApp->CreateShowDialog("sig.extract_failed"_lang, "", {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("sig.extract_failed"_lang, "", { "common.ok"_lang }, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (ourResult == 1) {
|
}
|
||||||
if (!inst::util::copyFile( inst::config::appDir + "/patches.ini.old", "sdmc:/bootloader/patches.ini")) {
|
else if (ourResult == 1) {
|
||||||
if (inst::ui::mainApp->CreateShowDialog("sig.restore_failed"_lang, "", {"common.yes"_lang, "common.no"_lang}, false)) return;
|
if (!inst::util::copyFile(inst::config::appDir + "/patches.ini.old", "sdmc:/bootloader/patches.ini")) {
|
||||||
} else std::filesystem::remove(inst::config::appDir + "/patches.ini.old");
|
if (inst::ui::mainApp->CreateShowDialog("sig.restore_failed"_lang, "", { "common.yes"_lang, "common.no"_lang }, false)) return;
|
||||||
|
}
|
||||||
|
else std::filesystem::remove(inst::config::appDir + "/patches.ini.old");
|
||||||
if (inst::util::removeDirectory("sdmc:/atmosphere/exefs_patches/es_patches")) {
|
if (inst::util::removeDirectory("sdmc:/atmosphere/exefs_patches/es_patches")) {
|
||||||
if (inst::ui::mainApp->CreateShowDialog("sig.uninstall_complete"_lang, "sig.complete_desc"_lang, {"sig.restart"_lang, "sig.later"_lang}, false) == 0) bpcRebootSystem();
|
if (inst::ui::mainApp->CreateShowDialog("sig.uninstall_complete"_lang, "sig.complete_desc"_lang, { "sig.restart"_lang, "sig.later"_lang }, false) == 0) bpcRebootSystem();
|
||||||
}
|
}
|
||||||
else inst::ui::mainApp->CreateShowDialog("sig.remove_failed"_lang, "sig.remove_failed_desc"_lang, {"common.ok"_lang}, true);
|
else inst::ui::mainApp->CreateShowDialog("sig.remove_failed"_lang, "sig.remove_failed_desc"_lang, { "common.ok"_lang }, true);
|
||||||
} else return;
|
}
|
||||||
|
else return;
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
LOG_DEBUG("Failed to install Signature Patches");
|
LOG_DEBUG("Failed to install Signature Patches");
|
||||||
LOG_DEBUG("%s", e.what());
|
LOG_DEBUG("%s", e.what());
|
||||||
fprintf(stdout, "%s", e.what());
|
fprintf(stdout, "%s", e.what());
|
||||||
inst::ui::mainApp->CreateShowDialog("sig.generic_error"_lang, (std::string)e.what(), {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("sig.generic_error"_lang, (std::string)e.what(), { "common.ok"_lang }, true);
|
||||||
}
|
}
|
||||||
bpcExit();
|
bpcExit();
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
|
|
||||||
HDInstPage::HDInstPage() : Layout::Layout() {
|
HDInstPage::HDInstPage() : Layout::Layout() {
|
||||||
this->SetBackgroundColor(COLOR("#670000FF"));
|
this->SetBackgroundColor(COLOR("#670000FF"));
|
||||||
@ -43,9 +43,9 @@ namespace inst::ui {
|
|||||||
this->currentDir = ourPath;
|
this->currentDir = ourPath;
|
||||||
|
|
||||||
auto pathStr = this->currentDir.string();
|
auto pathStr = this->currentDir.string();
|
||||||
if(pathStr.length())
|
if (pathStr.length())
|
||||||
{
|
{
|
||||||
if(pathStr[pathStr.length() - 1] == ':')
|
if (pathStr[pathStr.length() - 1] == ':')
|
||||||
{
|
{
|
||||||
this->currentDir = this->currentDir / "";
|
this->currentDir = this->currentDir / "";
|
||||||
}
|
}
|
||||||
@ -54,8 +54,9 @@ namespace inst::ui {
|
|||||||
this->menu->ClearItems();
|
this->menu->ClearItems();
|
||||||
try {
|
try {
|
||||||
this->ourDirectories = util::getDirsAtPath(this->currentDir);
|
this->ourDirectories = util::getDirsAtPath(this->currentDir);
|
||||||
this->ourFiles = util::getDirectoryFiles(this->currentDir, {".nsp", ".nsz", ".xci", ".xcz"});
|
this->ourFiles = util::getDirectoryFiles(this->currentDir, { ".nsp", ".nsz", ".xci", ".xcz" });
|
||||||
} catch (std::exception& e) {
|
}
|
||||||
|
catch (std::exception& e) {
|
||||||
this->drawMenuItems(false, this->currentDir.parent_path());
|
this->drawMenuItems(false, this->currentDir.parent_path());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -66,7 +67,7 @@ namespace inst::ui {
|
|||||||
ourEntry->SetIcon("romfs:/images/icons/folder-upload.png");
|
ourEntry->SetIcon("romfs:/images/icons/folder-upload.png");
|
||||||
this->menu->AddItem(ourEntry);
|
this->menu->AddItem(ourEntry);
|
||||||
|
|
||||||
for (auto& file: this->ourDirectories) {
|
for (auto& file : this->ourDirectories) {
|
||||||
if (file == "..") break;
|
if (file == "..") break;
|
||||||
std::string itm = file.filename().string();
|
std::string itm = file.filename().string();
|
||||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||||
@ -74,7 +75,7 @@ namespace inst::ui {
|
|||||||
ourEntry->SetIcon("romfs:/images/icons/folder.png");
|
ourEntry->SetIcon("romfs:/images/icons/folder.png");
|
||||||
this->menu->AddItem(ourEntry);
|
this->menu->AddItem(ourEntry);
|
||||||
}
|
}
|
||||||
for (auto& file: this->ourFiles) {
|
for (auto& file : this->ourFiles) {
|
||||||
std::string itm = file.filename().string();
|
std::string itm = file.filename().string();
|
||||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||||
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
||||||
@ -98,7 +99,8 @@ namespace inst::ui {
|
|||||||
if (selectedIndex < dirListSize) {
|
if (selectedIndex < dirListSize) {
|
||||||
if (this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetName() == ".." && this->menu->GetSelectedIndex() == 0) {
|
if (this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetName() == ".." && this->menu->GetSelectedIndex() == 0) {
|
||||||
this->drawMenuItems(true, this->currentDir.parent_path());
|
this->drawMenuItems(true, this->currentDir.parent_path());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
this->drawMenuItems(true, this->ourDirectories[selectedIndex]);
|
this->drawMenuItems(true, this->ourDirectories[selectedIndex]);
|
||||||
}
|
}
|
||||||
this->menu->SetSelectedIndex(0);
|
this->menu->SetSelectedIndex(0);
|
||||||
@ -113,7 +115,8 @@ namespace inst::ui {
|
|||||||
for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) {
|
for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) {
|
||||||
if (this->selectedTitles[i] == this->ourFiles[selectedIndex - dirListSize]) this->selectedTitles.erase(this->selectedTitles.begin() + i);
|
if (this->selectedTitles[i] == this->ourFiles[selectedIndex - dirListSize]) this->selectedTitles.erase(this->selectedTitles.begin() + i);
|
||||||
}
|
}
|
||||||
} else if (this->menu->GetItems()[selectedIndex]->GetIcon() == "romfs:/images/icons/checkbox-blank-outline.png") this->selectedTitles.push_back(this->ourFiles[selectedIndex - dirListSize]);
|
}
|
||||||
|
else if (this->menu->GetItems()[selectedIndex]->GetIcon() == "romfs:/images/icons/checkbox-blank-outline.png") this->selectedTitles.push_back(this->ourFiles[selectedIndex - dirListSize]);
|
||||||
else {
|
else {
|
||||||
this->followDirectory();
|
this->followDirectory();
|
||||||
return;
|
return;
|
||||||
@ -124,8 +127,9 @@ namespace inst::ui {
|
|||||||
void HDInstPage::startInstall() {
|
void HDInstPage::startInstall() {
|
||||||
int dialogResult = -1;
|
int dialogResult = -1;
|
||||||
if (this->selectedTitles.size() == 1) {
|
if (this->selectedTitles.size() == 1) {
|
||||||
dialogResult = mainApp->CreateShowDialog("inst.target.desc0"_lang + inst::util::shortenString(std::filesystem::path(this->selectedTitles[0]).filename().string(), 32, true) + "inst.target.desc1"_lang, "common.cancel_desc"_lang, {"inst.target.opt0"_lang, "inst.target.opt1"_lang}, false);
|
dialogResult = mainApp->CreateShowDialog("inst.target.desc0"_lang + inst::util::shortenString(std::filesystem::path(this->selectedTitles[0]).filename().string(), 32, true) + "inst.target.desc1"_lang, "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false);
|
||||||
} else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedTitles.size()) + "inst.target.desc01"_lang, "common.cancel_desc"_lang, {"inst.target.opt0"_lang, "inst.target.opt1"_lang}, false);
|
}
|
||||||
|
else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedTitles.size()) + "inst.target.desc01"_lang, "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false);
|
||||||
if (dialogResult == -1) return;
|
if (dialogResult == -1) return;
|
||||||
nspInstStuff_B::installNspFromFile(this->selectedTitles, dialogResult);
|
nspInstStuff_B::installNspFromFile(this->selectedTitles, dialogResult);
|
||||||
}
|
}
|
||||||
@ -153,7 +157,7 @@ namespace inst::ui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((Down & HidNpadButton_X)) {
|
if ((Down & HidNpadButton_X)) {
|
||||||
inst::ui::mainApp->CreateShowDialog("inst.hd.help.title"_lang, "inst.hd.help.desc"_lang, {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("inst.hd.help.title"_lang, "inst.hd.help.desc"_lang, { "common.ok"_lang }, true);
|
||||||
}
|
}
|
||||||
if (Down & HidNpadButton_Plus) {
|
if (Down & HidNpadButton_Plus) {
|
||||||
if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIcon() == "romfs:/images/icons/checkbox-blank-outline.png") {
|
if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIcon() == "romfs:/images/icons/checkbox-blank-outline.png") {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "util/lang.hpp"
|
#include "util/lang.hpp"
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
MainApplication *mainApp;
|
MainApplication* mainApp;
|
||||||
|
|
||||||
void MainApplication::OnLoad() {
|
void MainApplication::OnLoad() {
|
||||||
mainApp = this;
|
mainApp = this;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
|
|
||||||
instPage::instPage() : Layout::Layout() {
|
instPage::instPage() : Layout::Layout() {
|
||||||
this->SetBackgroundColor(COLOR("#670000FF"));
|
this->SetBackgroundColor(COLOR("#670000FF"));
|
||||||
@ -36,27 +36,27 @@ namespace inst::ui {
|
|||||||
if (inst::config::gayMode) this->awooImage->SetVisible(false);
|
if (inst::config::gayMode) this->awooImage->SetVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void instPage::setTopInstInfoText(std::string ourText){
|
void instPage::setTopInstInfoText(std::string ourText) {
|
||||||
mainApp->instpage->pageInfoText->SetText(ourText);
|
mainApp->instpage->pageInfoText->SetText(ourText);
|
||||||
mainApp->CallForRender();
|
mainApp->CallForRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
void instPage::setInstInfoText(std::string ourText){
|
void instPage::setInstInfoText(std::string ourText) {
|
||||||
mainApp->instpage->installInfoText->SetText(ourText);
|
mainApp->instpage->installInfoText->SetText(ourText);
|
||||||
mainApp->CallForRender();
|
mainApp->CallForRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
void instPage::setInstBarPerc(double ourPercent){
|
void instPage::setInstBarPerc(double ourPercent) {
|
||||||
mainApp->instpage->installBar->SetVisible(true);
|
mainApp->instpage->installBar->SetVisible(true);
|
||||||
mainApp->instpage->installBar->SetProgress(ourPercent);
|
mainApp->instpage->installBar->SetProgress(ourPercent);
|
||||||
mainApp->CallForRender();
|
mainApp->CallForRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
void instPage::loadMainMenu(){
|
void instPage::loadMainMenu() {
|
||||||
mainApp->LoadLayout(mainApp->mainPage);
|
mainApp->LoadLayout(mainApp->mainPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void instPage::loadInstallScreen(){
|
void instPage::loadInstallScreen() {
|
||||||
mainApp->instpage->pageInfoText->SetText("");
|
mainApp->instpage->pageInfoText->SetText("");
|
||||||
mainApp->instpage->installInfoText->SetText("");
|
mainApp->instpage->installInfoText->SetText("");
|
||||||
mainApp->instpage->installBar->SetProgress(0);
|
mainApp->instpage->installBar->SetProgress(0);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
bool appletFinished = false;
|
bool appletFinished = false;
|
||||||
bool updateFinished = false;
|
bool updateFinished = false;
|
||||||
|
|
||||||
@ -24,9 +24,10 @@ namespace inst::ui {
|
|||||||
tin::data::NUM_BUFFER_SEGMENTS = 2;
|
tin::data::NUM_BUFFER_SEGMENTS = 2;
|
||||||
if (menuLoaded) {
|
if (menuLoaded) {
|
||||||
inst::ui::appletFinished = true;
|
inst::ui::appletFinished = true;
|
||||||
mainApp->CreateShowDialog("main.applet.title"_lang, "main.applet.desc"_lang, {"common.ok"_lang}, true);
|
mainApp->CreateShowDialog("main.applet.title"_lang, "main.applet.desc"_lang, { "common.ok"_lang }, true);
|
||||||
}
|
}
|
||||||
} else if (!appletFinished) {
|
}
|
||||||
|
else if (!appletFinished) {
|
||||||
inst::ui::appletFinished = true;
|
inst::ui::appletFinished = true;
|
||||||
tin::data::NUM_BUFFER_SEGMENTS = 128;
|
tin::data::NUM_BUFFER_SEGMENTS = 128;
|
||||||
}
|
}
|
||||||
@ -99,7 +100,7 @@ namespace inst::ui {
|
|||||||
|
|
||||||
void MainPage::netInstallMenuItem_Click() {
|
void MainPage::netInstallMenuItem_Click() {
|
||||||
if (inst::util::getIPAddress() == "1.0.0.127") {
|
if (inst::util::getIPAddress() == "1.0.0.127") {
|
||||||
inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mainApp->netinstPage->startNetwork();
|
mainApp->netinstPage->startNetwork();
|
||||||
@ -107,13 +108,13 @@ namespace inst::ui {
|
|||||||
|
|
||||||
void MainPage::usbInstallMenuItem_Click() {
|
void MainPage::usbInstallMenuItem_Click() {
|
||||||
if (!inst::config::usbAck) {
|
if (!inst::config::usbAck) {
|
||||||
if (mainApp->CreateShowDialog("main.usb.warn.title"_lang, "main.usb.warn.desc"_lang, {"common.ok"_lang, "main.usb.warn.opt1"_lang}, false) == 1) {
|
if (mainApp->CreateShowDialog("main.usb.warn.title"_lang, "main.usb.warn.desc"_lang, { "common.ok"_lang, "main.usb.warn.opt1"_lang }, false) == 1) {
|
||||||
inst::config::usbAck = true;
|
inst::config::usbAck = true;
|
||||||
inst::config::setConfig();
|
inst::config::setConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inst::util::usbIsConnected()) mainApp->usbinstPage->startUsb();
|
if (inst::util::usbIsConnected()) mainApp->usbinstPage->startUsb();
|
||||||
else mainApp->CreateShowDialog("main.usb.error.title"_lang, "main.usb.error.desc"_lang, {"common.ok"_lang}, false);
|
else mainApp->CreateShowDialog("main.usb.error.title"_lang, "main.usb.error.desc"_lang, { "common.ok"_lang }, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPage::sigPatchesMenuItem_Click() {
|
void MainPage::sigPatchesMenuItem_Click() {
|
||||||
@ -121,12 +122,13 @@ namespace inst::ui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainPage::hddInstallMenuItem_Click() {
|
void MainPage::hddInstallMenuItem_Click() {
|
||||||
if(nx::hdd::count() && nx::hdd::rootPath()) {
|
if (nx::hdd::count() && nx::hdd::rootPath()) {
|
||||||
mainApp->HDinstPage->drawMenuItems(true, nx::hdd::rootPath());
|
mainApp->HDinstPage->drawMenuItems(true, nx::hdd::rootPath());
|
||||||
mainApp->HDinstPage->menu->SetSelectedIndex(0);
|
mainApp->HDinstPage->menu->SetSelectedIndex(0);
|
||||||
mainApp->LoadLayout(mainApp->HDinstPage);
|
mainApp->LoadLayout(mainApp->HDinstPage);
|
||||||
} else {
|
}
|
||||||
inst::ui::mainApp->CreateShowDialog("main.hdd.title"_lang, "main.hdd.notfound"_lang, {"common.ok"_lang}, true);
|
else {
|
||||||
|
inst::ui::mainApp->CreateShowDialog("main.hdd.title"_lang, "main.hdd.notfound"_lang, { "common.ok"_lang }, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
|
|
||||||
std::string lastFileID = "";
|
std::string lastFileID = "";
|
||||||
std::string sourceString = "";
|
std::string sourceString = "";
|
||||||
@ -50,7 +50,7 @@ namespace inst::ui {
|
|||||||
if (clearItems) this->selectedUrls = {};
|
if (clearItems) this->selectedUrls = {};
|
||||||
if (clearItems) this->alternativeNames = {};
|
if (clearItems) this->alternativeNames = {};
|
||||||
this->menu->ClearItems();
|
this->menu->ClearItems();
|
||||||
for (auto& url: this->ourUrls) {
|
for (auto& url : this->ourUrls) {
|
||||||
std::string itm = inst::util::shortenString(inst::util::formatUrlString(url), 56, true);
|
std::string itm = inst::util::shortenString(inst::util::formatUrlString(url), 56, true);
|
||||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||||
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
||||||
@ -69,7 +69,8 @@ namespace inst::ui {
|
|||||||
for (long unsigned int i = 0; i < this->selectedUrls.size(); i++) {
|
for (long unsigned int i = 0; i < this->selectedUrls.size(); i++) {
|
||||||
if (this->selectedUrls[i] == this->ourUrls[selectedIndex]) this->selectedUrls.erase(this->selectedUrls.begin() + i);
|
if (this->selectedUrls[i] == this->ourUrls[selectedIndex]) this->selectedUrls.erase(this->selectedUrls.begin() + i);
|
||||||
}
|
}
|
||||||
} else this->selectedUrls.push_back(this->ourUrls[selectedIndex]);
|
}
|
||||||
|
else this->selectedUrls.push_back(this->ourUrls[selectedIndex]);
|
||||||
this->drawMenuItems(false);
|
this->drawMenuItems(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,20 +84,21 @@ namespace inst::ui {
|
|||||||
if (!this->ourUrls.size()) {
|
if (!this->ourUrls.size()) {
|
||||||
mainApp->LoadLayout(mainApp->mainPage);
|
mainApp->LoadLayout(mainApp->mainPage);
|
||||||
return;
|
return;
|
||||||
} else if (this->ourUrls[0] == "supplyUrl") {
|
}
|
||||||
|
else if (this->ourUrls[0] == "supplyUrl") {
|
||||||
std::string keyboardResult;
|
std::string keyboardResult;
|
||||||
switch (mainApp->CreateShowDialog("inst.net.src.title"_lang, "common.cancel_desc"_lang, {"inst.net.src.opt0"_lang, "inst.net.src.opt1"_lang}, false)) {
|
switch (mainApp->CreateShowDialog("inst.net.src.title"_lang, "common.cancel_desc"_lang, { "inst.net.src.opt0"_lang, "inst.net.src.opt1"_lang }, false)) {
|
||||||
case 0:
|
case 0:
|
||||||
keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, inst::config::lastNetUrl, 500);
|
keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, inst::config::lastNetUrl, 500);
|
||||||
if (keyboardResult.size() > 0) {
|
if (keyboardResult.size() > 0) {
|
||||||
if (inst::util::formatUrlString(keyboardResult) == "" || keyboardResult == "https://" || keyboardResult == "http://") {
|
if (inst::util::formatUrlString(keyboardResult) == "" || keyboardResult == "https://" || keyboardResult == "http://") {
|
||||||
mainApp->CreateShowDialog("inst.net.url.invalid"_lang, "", {"common.ok"_lang}, false);
|
mainApp->CreateShowDialog("inst.net.url.invalid"_lang, "", { "common.ok"_lang }, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
inst::config::lastNetUrl = keyboardResult;
|
inst::config::lastNetUrl = keyboardResult;
|
||||||
inst::config::setConfig();
|
inst::config::setConfig();
|
||||||
sourceString = "inst.net.url.source_string"_lang;
|
sourceString = "inst.net.url.source_string"_lang;
|
||||||
this->selectedUrls = {keyboardResult};
|
this->selectedUrls = { keyboardResult };
|
||||||
this->startInstall(true);
|
this->startInstall(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -106,10 +108,10 @@ namespace inst::ui {
|
|||||||
if (keyboardResult.size() > 0) {
|
if (keyboardResult.size() > 0) {
|
||||||
lastFileID = keyboardResult;
|
lastFileID = keyboardResult;
|
||||||
std::string fileName = inst::util::getDriveFileName(keyboardResult);
|
std::string fileName = inst::util::getDriveFileName(keyboardResult);
|
||||||
if (fileName.size() > 0) this->alternativeNames = {fileName};
|
if (fileName.size() > 0) this->alternativeNames = { fileName };
|
||||||
else this->alternativeNames = {"inst.net.gdrive.alt_name"_lang};
|
else this->alternativeNames = { "inst.net.gdrive.alt_name"_lang };
|
||||||
sourceString = "inst.net.gdrive.source_string"_lang;
|
sourceString = "inst.net.gdrive.source_string"_lang;
|
||||||
this->selectedUrls = {"https://www.googleapis.com/drive/v3/files/" + keyboardResult + "?key=" + inst::config::gAuthKey + "&alt=media"};
|
this->selectedUrls = { "https://www.googleapis.com/drive/v3/files/" + keyboardResult + "?key=" + inst::config::gAuthKey + "&alt=media" };
|
||||||
this->startInstall(true);
|
this->startInstall(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -117,7 +119,8 @@ namespace inst::ui {
|
|||||||
}
|
}
|
||||||
this->startNetwork();
|
this->startNetwork();
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
mainApp->CallForRender(); // If we re-render a few times during this process the main screen won't flicker
|
mainApp->CallForRender(); // If we re-render a few times during this process the main screen won't flicker
|
||||||
sourceString = "inst.net.source_string"_lang;
|
sourceString = "inst.net.source_string"_lang;
|
||||||
this->pageInfoText->SetText("inst.net.top_info"_lang);
|
this->pageInfoText->SetText("inst.net.top_info"_lang);
|
||||||
@ -137,8 +140,9 @@ namespace inst::ui {
|
|||||||
std::string ourUrlString;
|
std::string ourUrlString;
|
||||||
if (this->alternativeNames.size() > 0) ourUrlString = inst::util::shortenString(this->alternativeNames[0], 32, true);
|
if (this->alternativeNames.size() > 0) ourUrlString = inst::util::shortenString(this->alternativeNames[0], 32, true);
|
||||||
else ourUrlString = inst::util::shortenString(inst::util::formatUrlString(this->selectedUrls[0]), 32, true);
|
else ourUrlString = inst::util::shortenString(inst::util::formatUrlString(this->selectedUrls[0]), 32, true);
|
||||||
dialogResult = mainApp->CreateShowDialog("inst.target.desc0"_lang + ourUrlString + "inst.target.desc1"_lang, "common.cancel_desc"_lang, {"inst.target.opt0"_lang, "inst.target.opt1"_lang}, false);
|
dialogResult = mainApp->CreateShowDialog("inst.target.desc0"_lang + ourUrlString + "inst.target.desc1"_lang, "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false);
|
||||||
} else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedUrls.size()) + "inst.target.desc01"_lang, "common.cancel_desc"_lang, {"inst.target.opt0"_lang, "inst.target.opt1"_lang}, false);
|
}
|
||||||
|
else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedUrls.size()) + "inst.target.desc01"_lang, "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false);
|
||||||
if (dialogResult == -1 && !urlMode) return;
|
if (dialogResult == -1 && !urlMode) return;
|
||||||
else if (dialogResult == -1 && urlMode) {
|
else if (dialogResult == -1 && urlMode) {
|
||||||
this->startNetwork();
|
this->startNetwork();
|
||||||
@ -150,7 +154,7 @@ namespace inst::ui {
|
|||||||
|
|
||||||
void netInstPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos) {
|
void netInstPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos) {
|
||||||
if (Down & HidNpadButton_B) {
|
if (Down & HidNpadButton_B) {
|
||||||
if (this->menu->GetItems().size() > 0){
|
if (this->menu->GetItems().size() > 0) {
|
||||||
if (this->selectedUrls.size() == 0) {
|
if (this->selectedUrls.size() == 0) {
|
||||||
this->selectTitle(this->menu->GetSelectedIndex());
|
this->selectTitle(this->menu->GetSelectedIndex());
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
|
|
||||||
std::vector<std::string> languageStrings = {"English", "日本語", "Français", "Deutsch", "Italiano", "Español", "Português", "Русский", "簡体中文","繁體中文"};
|
std::vector<std::string> languageStrings = { "English", "日本語", "Français", "Deutsch", "Italiano", "Español", "Português", "Русский", "簡体中文", "繁體中文" };
|
||||||
|
|
||||||
optionsPage::optionsPage() : Layout::Layout() {
|
optionsPage::optionsPage() : Layout::Layout() {
|
||||||
this->SetBackgroundColor(COLOR("#670000FF"));
|
this->SetBackgroundColor(COLOR("#670000FF"));
|
||||||
@ -53,7 +53,7 @@ namespace inst::ui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void optionsPage::askToUpdate(std::vector<std::string> updateInfo) {
|
void optionsPage::askToUpdate(std::vector<std::string> updateInfo) {
|
||||||
if (!mainApp->CreateShowDialog("options.update.title"_lang, "options.update.desc0"_lang + updateInfo[0] + "options.update.desc1"_lang, {"options.update.opt0"_lang, "common.cancel"_lang}, false)) {
|
if (!mainApp->CreateShowDialog("options.update.title"_lang, "options.update.desc0"_lang + updateInfo[0] + "options.update.desc1"_lang, { "options.update.opt0"_lang, "common.cancel"_lang }, false)) {
|
||||||
inst::ui::instPage::loadInstallScreen();
|
inst::ui::instPage::loadInstallScreen();
|
||||||
inst::ui::instPage::setTopInstInfoText("options.update.top_info"_lang + updateInfo[0]);
|
inst::ui::instPage::setTopInstInfoText("options.update.top_info"_lang + updateInfo[0]);
|
||||||
inst::ui::instPage::setInstBarPerc(0);
|
inst::ui::instPage::setInstBarPerc(0);
|
||||||
@ -65,9 +65,10 @@ namespace inst::ui {
|
|||||||
inst::ui::instPage::setInstInfoText("options.update.bot_info2"_lang + updateInfo[0]);
|
inst::ui::instPage::setInstInfoText("options.update.bot_info2"_lang + updateInfo[0]);
|
||||||
inst::zip::extractFile(downloadName, "sdmc:/");
|
inst::zip::extractFile(downloadName, "sdmc:/");
|
||||||
std::filesystem::remove(downloadName);
|
std::filesystem::remove(downloadName);
|
||||||
mainApp->CreateShowDialog("options.update.complete"_lang, "options.update.end_desc"_lang, {"common.ok"_lang}, false);
|
mainApp->CreateShowDialog("options.update.complete"_lang, "options.update.end_desc"_lang, { "common.ok"_lang }, false);
|
||||||
} catch (...) {
|
}
|
||||||
mainApp->CreateShowDialog("options.update.failed"_lang, "options.update.end_desc"_lang, {"common.ok"_lang}, false);
|
catch (...) {
|
||||||
|
mainApp->CreateShowDialog("options.update.failed"_lang, "options.update.end_desc"_lang, { "common.ok"_lang }, false);
|
||||||
}
|
}
|
||||||
mainApp->FadeOut();
|
mainApp->FadeOut();
|
||||||
mainApp->Close();
|
mainApp->Close();
|
||||||
@ -76,7 +77,7 @@ namespace inst::ui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string optionsPage::getMenuOptionIcon(bool ourBool) {
|
std::string optionsPage::getMenuOptionIcon(bool ourBool) {
|
||||||
if(ourBool) return "romfs:/images/icons/check-box-outline.png";
|
if (ourBool) return "romfs:/images/icons/check-box-outline.png";
|
||||||
else return "romfs:/images/icons/checkbox-blank-outline.png";
|
else return "romfs:/images/icons/checkbox-blank-outline.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,8 +167,9 @@ namespace inst::ui {
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (inst::config::validateNCAs) {
|
if (inst::config::validateNCAs) {
|
||||||
if (inst::ui::mainApp->CreateShowDialog("options.nca_warn.title"_lang, "options.nca_warn.desc"_lang, {"common.cancel"_lang, "options.nca_warn.opt1"_lang}, false) == 1) inst::config::validateNCAs = false;
|
if (inst::ui::mainApp->CreateShowDialog("options.nca_warn.title"_lang, "options.nca_warn.desc"_lang, { "common.cancel"_lang, "options.nca_warn.opt1"_lang }, false) == 1) inst::config::validateNCAs = false;
|
||||||
} else inst::config::validateNCAs = true;
|
}
|
||||||
|
else inst::config::validateNCAs = true;
|
||||||
inst::config::setConfig();
|
inst::config::setConfig();
|
||||||
this->setMenuText();
|
this->setMenuText();
|
||||||
break;
|
break;
|
||||||
@ -255,18 +257,18 @@ namespace inst::ui {
|
|||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
if (inst::util::getIPAddress() == "1.0.0.127") {
|
if (inst::util::getIPAddress() == "1.0.0.127") {
|
||||||
inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, { "common.ok"_lang }, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
downloadUrl = inst::util::checkForAppUpdate();
|
downloadUrl = inst::util::checkForAppUpdate();
|
||||||
if (!downloadUrl.size()) {
|
if (!downloadUrl.size()) {
|
||||||
mainApp->CreateShowDialog("options.update.title_check_fail"_lang, "options.update.desc_check_fail"_lang, {"common.ok"_lang}, false);
|
mainApp->CreateShowDialog("options.update.title_check_fail"_lang, "options.update.desc_check_fail"_lang, { "common.ok"_lang }, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this->askToUpdate(downloadUrl);
|
this->askToUpdate(downloadUrl);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
inst::ui::mainApp->CreateShowDialog("options.credits.title"_lang, "options.credits.desc"_lang, {"common.close"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("options.credits.title"_lang, "options.credits.desc"_lang, { "common.close"_lang }, true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
|
|
||||||
sdInstPage::sdInstPage() : Layout::Layout() {
|
sdInstPage::sdInstPage() : Layout::Layout() {
|
||||||
this->SetBackgroundColor(COLOR("#670000FF"));
|
this->SetBackgroundColor(COLOR("#670000FF"));
|
||||||
@ -46,8 +46,9 @@ namespace inst::ui {
|
|||||||
this->menu->ClearItems();
|
this->menu->ClearItems();
|
||||||
try {
|
try {
|
||||||
this->ourDirectories = util::getDirsAtPath(this->currentDir);
|
this->ourDirectories = util::getDirsAtPath(this->currentDir);
|
||||||
this->ourFiles = util::getDirectoryFiles(this->currentDir, {".nsp", ".nsz", ".xci", ".xcz"});
|
this->ourFiles = util::getDirectoryFiles(this->currentDir, { ".nsp", ".nsz", ".xci", ".xcz" });
|
||||||
} catch (std::exception& e) {
|
}
|
||||||
|
catch (std::exception& e) {
|
||||||
this->drawMenuItems(false, this->currentDir.parent_path());
|
this->drawMenuItems(false, this->currentDir.parent_path());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -58,7 +59,7 @@ namespace inst::ui {
|
|||||||
ourEntry->SetIcon("romfs:/images/icons/folder-upload.png");
|
ourEntry->SetIcon("romfs:/images/icons/folder-upload.png");
|
||||||
this->menu->AddItem(ourEntry);
|
this->menu->AddItem(ourEntry);
|
||||||
}
|
}
|
||||||
for (auto& file: this->ourDirectories) {
|
for (auto& file : this->ourDirectories) {
|
||||||
if (file == "..") break;
|
if (file == "..") break;
|
||||||
std::string itm = file.filename().string();
|
std::string itm = file.filename().string();
|
||||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||||
@ -66,7 +67,7 @@ namespace inst::ui {
|
|||||||
ourEntry->SetIcon("romfs:/images/icons/folder.png");
|
ourEntry->SetIcon("romfs:/images/icons/folder.png");
|
||||||
this->menu->AddItem(ourEntry);
|
this->menu->AddItem(ourEntry);
|
||||||
}
|
}
|
||||||
for (auto& file: this->ourFiles) {
|
for (auto& file : this->ourFiles) {
|
||||||
std::string itm = file.filename().string();
|
std::string itm = file.filename().string();
|
||||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||||
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
||||||
@ -90,7 +91,8 @@ namespace inst::ui {
|
|||||||
if (selectedIndex < dirListSize) {
|
if (selectedIndex < dirListSize) {
|
||||||
if (this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetName() == ".." && this->menu->GetSelectedIndex() == 0) {
|
if (this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetName() == ".." && this->menu->GetSelectedIndex() == 0) {
|
||||||
this->drawMenuItems(true, this->currentDir.parent_path());
|
this->drawMenuItems(true, this->currentDir.parent_path());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
this->drawMenuItems(true, this->ourDirectories[selectedIndex]);
|
this->drawMenuItems(true, this->ourDirectories[selectedIndex]);
|
||||||
}
|
}
|
||||||
this->menu->SetSelectedIndex(0);
|
this->menu->SetSelectedIndex(0);
|
||||||
@ -104,7 +106,8 @@ namespace inst::ui {
|
|||||||
for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) {
|
for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) {
|
||||||
if (this->selectedTitles[i] == this->ourFiles[selectedIndex - dirListSize]) this->selectedTitles.erase(this->selectedTitles.begin() + i);
|
if (this->selectedTitles[i] == this->ourFiles[selectedIndex - dirListSize]) this->selectedTitles.erase(this->selectedTitles.begin() + i);
|
||||||
}
|
}
|
||||||
} else if (this->menu->GetItems()[selectedIndex]->GetIcon() == "romfs:/images/icons/checkbox-blank-outline.png") this->selectedTitles.push_back(this->ourFiles[selectedIndex - dirListSize]);
|
}
|
||||||
|
else if (this->menu->GetItems()[selectedIndex]->GetIcon() == "romfs:/images/icons/checkbox-blank-outline.png") this->selectedTitles.push_back(this->ourFiles[selectedIndex - dirListSize]);
|
||||||
else {
|
else {
|
||||||
this->followDirectory();
|
this->followDirectory();
|
||||||
return;
|
return;
|
||||||
@ -115,8 +118,9 @@ namespace inst::ui {
|
|||||||
void sdInstPage::startInstall() {
|
void sdInstPage::startInstall() {
|
||||||
int dialogResult = -1;
|
int dialogResult = -1;
|
||||||
if (this->selectedTitles.size() == 1) {
|
if (this->selectedTitles.size() == 1) {
|
||||||
dialogResult = mainApp->CreateShowDialog("inst.target.desc0"_lang + inst::util::shortenString(std::filesystem::path(this->selectedTitles[0]).filename().string(), 32, true) + "inst.target.desc1"_lang, "common.cancel_desc"_lang, {"inst.target.opt0"_lang, "inst.target.opt1"_lang}, false);
|
dialogResult = mainApp->CreateShowDialog("inst.target.desc0"_lang + inst::util::shortenString(std::filesystem::path(this->selectedTitles[0]).filename().string(), 32, true) + "inst.target.desc1"_lang, "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false);
|
||||||
} else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedTitles.size()) + "inst.target.desc01"_lang, "common.cancel_desc"_lang, {"inst.target.opt0"_lang, "inst.target.opt1"_lang}, false);
|
}
|
||||||
|
else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedTitles.size()) + "inst.target.desc01"_lang, "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false);
|
||||||
if (dialogResult == -1) return;
|
if (dialogResult == -1) return;
|
||||||
nspInstStuff::installNspFromFile(this->selectedTitles, dialogResult);
|
nspInstStuff::installNspFromFile(this->selectedTitles, dialogResult);
|
||||||
}
|
}
|
||||||
@ -144,7 +148,7 @@ namespace inst::ui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((Down & HidNpadButton_A)) {
|
if ((Down & HidNpadButton_A)) {
|
||||||
inst::ui::mainApp->CreateShowDialog("inst.sd.help.title"_lang, "inst.sd.help.desc"_lang, {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("inst.sd.help.title"_lang, "inst.sd.help.desc"_lang, { "common.ok"_lang }, true);
|
||||||
}
|
}
|
||||||
if (Down & HidNpadButton_Plus) {
|
if (Down & HidNpadButton_Plus) {
|
||||||
if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIcon() == "romfs:/images/icons/checkbox-blank-outline.png") {
|
if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIcon() == "romfs:/images/icons/checkbox-blank-outline.png") {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
|
|
||||||
usbInstPage::usbInstPage() : Layout::Layout() {
|
usbInstPage::usbInstPage() : Layout::Layout() {
|
||||||
this->SetBackgroundColor(COLOR("#670000FF"));
|
this->SetBackgroundColor(COLOR("#670000FF"));
|
||||||
@ -44,7 +44,7 @@ namespace inst::ui {
|
|||||||
void usbInstPage::drawMenuItems(bool clearItems) {
|
void usbInstPage::drawMenuItems(bool clearItems) {
|
||||||
if (clearItems) this->selectedTitles = {};
|
if (clearItems) this->selectedTitles = {};
|
||||||
this->menu->ClearItems();
|
this->menu->ClearItems();
|
||||||
for (auto& url: this->ourTitles) {
|
for (auto& url : this->ourTitles) {
|
||||||
std::string itm = inst::util::shortenString(inst::util::formatUrlString(url), 56, true);
|
std::string itm = inst::util::shortenString(inst::util::formatUrlString(url), 56, true);
|
||||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||||
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
||||||
@ -63,7 +63,8 @@ namespace inst::ui {
|
|||||||
for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) {
|
for (long unsigned int i = 0; i < this->selectedTitles.size(); i++) {
|
||||||
if (this->selectedTitles[i] == this->ourTitles[selectedIndex]) this->selectedTitles.erase(this->selectedTitles.begin() + i);
|
if (this->selectedTitles[i] == this->ourTitles[selectedIndex]) this->selectedTitles.erase(this->selectedTitles.begin() + i);
|
||||||
}
|
}
|
||||||
} else this->selectedTitles.push_back(this->ourTitles[selectedIndex]);
|
}
|
||||||
|
else this->selectedTitles.push_back(this->ourTitles[selectedIndex]);
|
||||||
this->drawMenuItems(false);
|
this->drawMenuItems(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +80,8 @@ namespace inst::ui {
|
|||||||
if (!this->ourTitles.size()) {
|
if (!this->ourTitles.size()) {
|
||||||
mainApp->LoadLayout(mainApp->mainPage);
|
mainApp->LoadLayout(mainApp->mainPage);
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
mainApp->CallForRender(); // If we re-render a few times during this process the main screen won't flicker
|
mainApp->CallForRender(); // If we re-render a few times during this process the main screen won't flicker
|
||||||
this->pageInfoText->SetText("inst.usb.top_info2"_lang);
|
this->pageInfoText->SetText("inst.usb.top_info2"_lang);
|
||||||
this->butText->SetText("inst.usb.buttons2"_lang);
|
this->butText->SetText("inst.usb.buttons2"_lang);
|
||||||
@ -94,8 +96,8 @@ namespace inst::ui {
|
|||||||
|
|
||||||
void usbInstPage::startInstall() {
|
void usbInstPage::startInstall() {
|
||||||
int dialogResult = -1;
|
int dialogResult = -1;
|
||||||
if (this->selectedTitles.size() == 1) dialogResult = mainApp->CreateShowDialog("inst.target.desc0"_lang + inst::util::shortenString(inst::util::formatUrlString(this->selectedTitles[0]), 32, true) + "inst.target.desc1"_lang, "common.cancel_desc"_lang, {"inst.target.opt0"_lang, "inst.target.opt1"_lang}, false);
|
if (this->selectedTitles.size() == 1) dialogResult = mainApp->CreateShowDialog("inst.target.desc0"_lang + inst::util::shortenString(inst::util::formatUrlString(this->selectedTitles[0]), 32, true) + "inst.target.desc1"_lang, "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false);
|
||||||
else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedTitles.size()) + "inst.target.desc01"_lang, "common.cancel_desc"_lang, {"inst.target.opt0"_lang, "inst.target.opt1"_lang}, false);
|
else dialogResult = mainApp->CreateShowDialog("inst.target.desc00"_lang + std::to_string(this->selectedTitles.size()) + "inst.target.desc01"_lang, "common.cancel_desc"_lang, { "inst.target.opt0"_lang, "inst.target.opt1"_lang }, false);
|
||||||
if (dialogResult == -1) return;
|
if (dialogResult == -1) return;
|
||||||
usbInstStuff::installTitleUsb(this->selectedTitles, dialogResult);
|
usbInstStuff::installTitleUsb(this->selectedTitles, dialogResult);
|
||||||
return;
|
return;
|
||||||
|
@ -38,7 +38,7 @@ SOFTWARE.
|
|||||||
#include "ui/instPage.hpp"
|
#include "ui/instPage.hpp"
|
||||||
|
|
||||||
namespace inst::ui {
|
namespace inst::ui {
|
||||||
extern MainApplication *mainApp;
|
extern MainApplication* mainApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace usbInstStuff {
|
namespace usbInstStuff {
|
||||||
@ -62,7 +62,7 @@ namespace usbInstStuff {
|
|||||||
TUSHeader header;
|
TUSHeader header;
|
||||||
u64 freq = armGetSystemTickFreq();
|
u64 freq = armGetSystemTickFreq();
|
||||||
u64 startTime = armGetSystemTick();
|
u64 startTime = armGetSystemTick();
|
||||||
while(true) {
|
while (true) {
|
||||||
// If we don't update the UI occasionally the Switch basically crashes on this screen if you press the home button
|
// If we don't update the UI occasionally the Switch basically crashes on this screen if you press the home button
|
||||||
u64 newTime = armGetSystemTick();
|
u64 newTime = armGetSystemTick();
|
||||||
if (newTime - startTime >= freq * 0.25) {
|
if (newTime - startTime >= freq * 0.25) {
|
||||||
@ -73,7 +73,7 @@ namespace usbInstStuff {
|
|||||||
if (bufferData(&header, sizeof(TUSHeader), 500000000) != 0) break;
|
if (bufferData(&header, sizeof(TUSHeader), 500000000) != 0) break;
|
||||||
u64 kDown = inst::ui::mainApp->GetButtonsDown();
|
u64 kDown = inst::ui::mainApp->GetButtonsDown();
|
||||||
if (kDown & HidNpadButton_B) return {};
|
if (kDown & HidNpadButton_B) return {};
|
||||||
if (kDown & HidNpadButton_X) inst::ui::mainApp->CreateShowDialog("inst.usb.help.title"_lang, "inst.usb.help.desc"_lang, {"common.ok"_lang}, true);
|
if (kDown & HidNpadButton_X) inst::ui::mainApp->CreateShowDialog("inst.usb.help.title"_lang, "inst.usb.help.desc"_lang, { "common.ok"_lang }, true);
|
||||||
if (!inst::util::usbIsConnected()) return {};
|
if (!inst::util::usbIsConnected()) return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,8 @@ namespace usbInstStuff {
|
|||||||
if (ourTitleList[fileItr].compare(ourTitleList[fileItr].size() - 3, 2, "xc") == 0) {
|
if (ourTitleList[fileItr].compare(ourTitleList[fileItr].size() - 3, 2, "xc") == 0) {
|
||||||
auto usbXCI = std::make_shared<tin::install::xci::USBXCI>(ourTitleList[fileItr]);
|
auto usbXCI = std::make_shared<tin::install::xci::USBXCI>(ourTitleList[fileItr]);
|
||||||
installTask = std::make_unique<tin::install::xci::XCIInstallTask>(m_destStorageId, inst::config::ignoreReqVers, usbXCI);
|
installTask = std::make_unique<tin::install::xci::XCIInstallTask>(m_destStorageId, inst::config::ignoreReqVers, usbXCI);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
auto usbNSP = std::make_shared<tin::install::nsp::USBNSP>(ourTitleList[fileItr]);
|
auto usbNSP = std::make_shared<tin::install::nsp::USBNSP>(ourTitleList[fileItr]);
|
||||||
installTask = std::make_unique<tin::install::nsp::NSPInstall>(m_destStorageId, inst::config::ignoreReqVers, usbNSP);
|
installTask = std::make_unique<tin::install::nsp::NSPInstall>(m_destStorageId, inst::config::ignoreReqVers, usbNSP);
|
||||||
}
|
}
|
||||||
@ -147,8 +148,8 @@ namespace usbInstStuff {
|
|||||||
std::string audioPath = "romfs:/audio/bark.wav";
|
std::string audioPath = "romfs:/audio/bark.wav";
|
||||||
if (inst::config::gayMode) audioPath = "";
|
if (inst::config::gayMode) audioPath = "";
|
||||||
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
||||||
std::thread audioThread(inst::util::playAudio,audioPath);
|
std::thread audioThread(inst::util::playAudio, audioPath);
|
||||||
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + fileNames[fileItr] + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), {"common.ok"_lang}, true);
|
inst::ui::mainApp->CreateShowDialog("inst.info_page.failed"_lang + fileNames[fileItr] + "!", "inst.info_page.failed_desc"_lang + "\n\n" + (std::string)e.what(), { "common.ok"_lang }, true);
|
||||||
audioThread.join();
|
audioThread.join();
|
||||||
nspInstalled = false;
|
nspInstalled = false;
|
||||||
}
|
}
|
||||||
@ -159,16 +160,16 @@ namespace usbInstStuff {
|
|||||||
inst::util::setClockSpeed(2, previousClockValues[2]);
|
inst::util::setClockSpeed(2, previousClockValues[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nspInstalled) {
|
if (nspInstalled) {
|
||||||
tin::util::USBCmdManager::SendExitCmd();
|
tin::util::USBCmdManager::SendExitCmd();
|
||||||
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
|
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
|
||||||
inst::ui::instPage::setInstBarPerc(100);
|
inst::ui::instPage::setInstBarPerc(100);
|
||||||
std::string audioPath = "romfs:/audio/awoo.wav";
|
std::string audioPath = "romfs:/audio/awoo.wav";
|
||||||
if (inst::config::gayMode) audioPath = "";
|
if (inst::config::gayMode) audioPath = "";
|
||||||
if (std::filesystem::exists(inst::config::appDir + "/awoo.wav")) audioPath = inst::config::appDir + "/awoo.wav";
|
if (std::filesystem::exists(inst::config::appDir + "/awoo.wav")) audioPath = inst::config::appDir + "/awoo.wav";
|
||||||
std::thread audioThread(inst::util::playAudio,audioPath);
|
std::thread audioThread(inst::util::playAudio, audioPath);
|
||||||
if (ourTitleList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
|
if (ourTitleList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + "inst.info_page.desc0"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true);
|
||||||
else inst::ui::mainApp->CreateShowDialog(fileNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
|
else inst::ui::mainApp->CreateShowDialog(fileNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true);
|
||||||
audioThread.join();
|
audioThread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ namespace inst::config {
|
|||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
// If loading values from the config fails, we just load the defaults and overwrite the old config
|
// If loading values from the config fails, we just load the defaults and overwrite the old config
|
||||||
gAuthKey = {0x41,0x49,0x7a,0x61,0x53,0x79,0x42,0x4d,0x71,0x76,0x34,0x64,0x58,0x6e,0x54,0x4a,0x4f,0x47,0x51,0x74,0x5a,0x5a,0x53,0x33,0x43,0x42,0x6a,0x76,0x66,0x37,0x34,0x38,0x51,0x76,0x78,0x53,0x7a,0x46,0x30};
|
gAuthKey = { 0x41,0x49,0x7a,0x61,0x53,0x79,0x42,0x4d,0x71,0x76,0x34,0x64,0x58,0x6e,0x54,0x4a,0x4f,0x47,0x51,0x74,0x5a,0x5a,0x53,0x33,0x43,0x42,0x6a,0x76,0x66,0x37,0x34,0x38,0x51,0x76,0x78,0x53,0x7a,0x46,0x30 };
|
||||||
sigPatchesUrl = "https://github.com/Huntereb/Awoo-Installer/releases/download/SignaturePatches/patches.zip";
|
sigPatchesUrl = "https://github.com/Huntereb/Awoo-Installer/releases/download/SignaturePatches/patches.zip";
|
||||||
languageSetting = 99;
|
languageSetting = 99;
|
||||||
autoUpdate = true;
|
autoUpdate = true;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <mbedtls/bignum.h>
|
#include <mbedtls/bignum.h>
|
||||||
|
|
||||||
void Crypto::calculateMGF1andXOR(unsigned char* data, size_t data_size, const void* source, size_t source_size) {
|
void Crypto::calculateMGF1andXOR(unsigned char* data, size_t data_size, const void* source, size_t source_size) {
|
||||||
unsigned char h_buf[RSA_2048_BYTES] = {0};
|
unsigned char h_buf[RSA_2048_BYTES] = { 0 };
|
||||||
memcpy(h_buf, source, source_size);
|
memcpy(h_buf, source, source_size);
|
||||||
|
|
||||||
unsigned char mgf1_buf[0x20];
|
unsigned char mgf1_buf[0x20];
|
||||||
@ -24,7 +24,7 @@ void Crypto::calculateMGF1andXOR(unsigned char* data, size_t data_size, const vo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Crypto::rsa2048PssVerify(const void *data, size_t len, const unsigned char *signature, const unsigned char *modulus) {
|
bool Crypto::rsa2048PssVerify(const void* data, size_t len, const unsigned char* signature, const unsigned char* modulus) {
|
||||||
mbedtls_mpi signature_mpi;
|
mbedtls_mpi signature_mpi;
|
||||||
mbedtls_mpi modulus_mpi;
|
mbedtls_mpi modulus_mpi;
|
||||||
mbedtls_mpi e_mpi;
|
mbedtls_mpi e_mpi;
|
||||||
@ -38,7 +38,7 @@ bool Crypto::rsa2048PssVerify(const void *data, size_t len, const unsigned char
|
|||||||
|
|
||||||
unsigned char m_buf[RSA_2048_BYTES];
|
unsigned char m_buf[RSA_2048_BYTES];
|
||||||
unsigned char h_buf[0x24];
|
unsigned char h_buf[0x24];
|
||||||
const unsigned char E[3] = {1, 0, 1};
|
const unsigned char E[3] = { 1, 0, 1 };
|
||||||
|
|
||||||
mbedtls_mpi_read_binary(&e_mpi, E, 3);
|
mbedtls_mpi_read_binary(&e_mpi, E, 3);
|
||||||
mbedtls_mpi_read_binary(&signature_mpi, signature, RSA_2048_BYTES);
|
mbedtls_mpi_read_binary(&signature_mpi, signature, RSA_2048_BYTES);
|
||||||
@ -55,7 +55,7 @@ bool Crypto::rsa2048PssVerify(const void *data, size_t len, const unsigned char
|
|||||||
mbedtls_mpi_free(&message_mpi);
|
mbedtls_mpi_free(&message_mpi);
|
||||||
|
|
||||||
/* There's no automated PSS verification as far as I can tell. */
|
/* There's no automated PSS verification as far as I can tell. */
|
||||||
if (m_buf[RSA_2048_BYTES-1] != 0xBC) {
|
if (m_buf[RSA_2048_BYTES - 1] != 0xBC) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,23 +7,24 @@
|
|||||||
#include "util/error.hpp"
|
#include "util/error.hpp"
|
||||||
#include "ui/instPage.hpp"
|
#include "ui/instPage.hpp"
|
||||||
|
|
||||||
static size_t writeDataFile(void *ptr, size_t size, size_t nmemb, void *stream) {
|
static size_t writeDataFile(void* ptr, size_t size, size_t nmemb, void* stream) {
|
||||||
size_t written = fwrite(ptr, size, nmemb, (FILE *)stream);
|
size_t written = fwrite(ptr, size, nmemb, (FILE*)stream);
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t writeDataBuffer(char *ptr, size_t size, size_t nmemb, void *userdata) {
|
size_t writeDataBuffer(char* ptr, size_t size, size_t nmemb, void* userdata) {
|
||||||
std::ostringstream *stream = (std::ostringstream*)userdata;
|
std::ostringstream* stream = (std::ostringstream*)userdata;
|
||||||
size_t count = size * nmemb;
|
size_t count = size * nmemb;
|
||||||
stream->write(ptr, count);
|
stream->write(ptr, count);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int progress_callback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) {
|
int progress_callback(void* clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) {
|
||||||
if (ultotal) {
|
if (ultotal) {
|
||||||
int uploadProgress = (int)(((double)ulnow / (double)ultotal) * 100.0);
|
int uploadProgress = (int)(((double)ulnow / (double)ultotal) * 100.0);
|
||||||
inst::ui::instPage::setInstBarPerc(uploadProgress);
|
inst::ui::instPage::setInstBarPerc(uploadProgress);
|
||||||
} else if (dltotal) {
|
}
|
||||||
|
else if (dltotal) {
|
||||||
int downloadProgress = (int)(((double)dlnow / (double)dltotal) * 100.0);
|
int downloadProgress = (int)(((double)dlnow / (double)dltotal) * 100.0);
|
||||||
inst::ui::instPage::setInstBarPerc(downloadProgress);
|
inst::ui::instPage::setInstBarPerc(downloadProgress);
|
||||||
}
|
}
|
||||||
@ -31,10 +32,10 @@ int progress_callback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace inst::curl {
|
namespace inst::curl {
|
||||||
bool downloadFile (const std::string ourUrl, const char *pagefilename, long timeout, bool writeProgress) {
|
bool downloadFile(const std::string ourUrl, const char* pagefilename, long timeout, bool writeProgress) {
|
||||||
CURL *curl_handle;
|
CURL* curl_handle;
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
FILE *pagefile;
|
FILE* pagefile;
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
curl_handle = curl_easy_init();
|
curl_handle = curl_easy_init();
|
||||||
@ -65,8 +66,8 @@ namespace inst::curl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string downloadToBuffer (const std::string ourUrl, int firstRange, int secondRange, long timeout) {
|
std::string downloadToBuffer(const std::string ourUrl, int firstRange, int secondRange, long timeout) {
|
||||||
CURL *curl_handle;
|
CURL* curl_handle;
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ namespace inst::curl {
|
|||||||
curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT_MS, timeout);
|
curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT_MS, timeout);
|
||||||
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writeDataBuffer);
|
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, writeDataBuffer);
|
||||||
if (firstRange && secondRange) {
|
if (firstRange && secondRange) {
|
||||||
const char * ourRange = (std::to_string(firstRange) + "-" + std::to_string(secondRange)).c_str();
|
const char* ourRange = (std::to_string(firstRange) + "-" + std::to_string(secondRange)).c_str();
|
||||||
curl_easy_setopt(curl_handle, CURLOPT_RANGE, ourRange);
|
curl_easy_setopt(curl_handle, CURLOPT_RANGE, ourRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ SOFTWARE.
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
void printBytes(u8 *bytes, size_t size, bool includeHeader)
|
void printBytes(u8* bytes, size_t size, bool includeHeader)
|
||||||
{
|
{
|
||||||
#ifdef NXLINK_DEBUG
|
#ifdef NXLINK_DEBUG
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -158,7 +158,7 @@ namespace tin::network
|
|||||||
|
|
||||||
size_t HTTPDownload::ParseHTMLData(char* bytes, size_t size, size_t numItems, void* userData)
|
size_t HTTPDownload::ParseHTMLData(char* bytes, size_t size, size_t numItems, void* userData)
|
||||||
{
|
{
|
||||||
auto streamFunc = *reinterpret_cast<std::function<size_t (u8* bytes, size_t size)>*>(userData);
|
auto streamFunc = *reinterpret_cast<std::function<size_t(u8* bytes, size_t size)>*>(userData);
|
||||||
size_t numBytes = size * numItems;
|
size_t numBytes = size * numItems;
|
||||||
|
|
||||||
if (streamFunc != nullptr)
|
if (streamFunc != nullptr)
|
||||||
@ -167,7 +167,7 @@ namespace tin::network
|
|||||||
return numBytes;
|
return numBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTPDownload::BufferDataRange(void* buffer, size_t offset, size_t size, std::function<void (size_t sizeRead)> progressFunc)
|
void HTTPDownload::BufferDataRange(void* buffer, size_t offset, size_t size, std::function<void(size_t sizeRead)> progressFunc)
|
||||||
{
|
{
|
||||||
size_t sizeRead = 0;
|
size_t sizeRead = 0;
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ namespace tin::network
|
|||||||
this->StreamDataRange(offset, size, streamFunc);
|
this->StreamDataRange(offset, size, streamFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int HTTPDownload::StreamDataRange(size_t offset, size_t size, std::function<size_t (u8* bytes, size_t size)> streamFunc)
|
int HTTPDownload::StreamDataRange(size_t offset, size_t size, std::function<size_t(u8* bytes, size_t size)> streamFunc)
|
||||||
{
|
{
|
||||||
if (!m_rangesSupported)
|
if (!m_rangesSupported)
|
||||||
{
|
{
|
||||||
@ -256,8 +256,8 @@ namespace tin::network
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
ret = send(sockfd, (u8*)buf + written, len - written, 0);
|
ret = send(sockfd, (u8*)buf + written, len - written, 0);
|
||||||
|
|
||||||
if (ret < 0){ // If error
|
if (ret < 0) { // If error
|
||||||
if (errno == EWOULDBLOCK || errno == EAGAIN){ // Is it because other side is busy?
|
if (errno == EWOULDBLOCK || errno == EAGAIN) { // Is it because other side is busy?
|
||||||
sleep(5);
|
sleep(5);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -29,33 +29,33 @@ namespace tin::util
|
|||||||
{
|
{
|
||||||
u64 GetRightsIdTid(FsRightsId rightsId)
|
u64 GetRightsIdTid(FsRightsId rightsId)
|
||||||
{
|
{
|
||||||
return __bswap64(*(u64 *)rightsId.c);
|
return __bswap64(*(u64*)rightsId.c);
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 GetRightsIdKeyGen(FsRightsId rightsId)
|
u64 GetRightsIdKeyGen(FsRightsId rightsId)
|
||||||
{
|
{
|
||||||
return __bswap64(*(u64 *)(rightsId.c + 8));
|
return __bswap64(*(u64*)(rightsId.c + 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetNcaIdString(const NcmContentId& ncaId)
|
std::string GetNcaIdString(const NcmContentId& ncaId)
|
||||||
{
|
{
|
||||||
char ncaIdStr[FS_MAX_PATH] = {0};
|
char ncaIdStr[FS_MAX_PATH] = { 0 };
|
||||||
u64 ncaIdLower = __bswap64(*(u64 *)ncaId.c);
|
u64 ncaIdLower = __bswap64(*(u64*)ncaId.c);
|
||||||
u64 ncaIdUpper = __bswap64(*(u64 *)(ncaId.c + 0x8));
|
u64 ncaIdUpper = __bswap64(*(u64*)(ncaId.c + 0x8));
|
||||||
snprintf(ncaIdStr, FS_MAX_PATH, "%016lx%016lx", ncaIdLower, ncaIdUpper);
|
snprintf(ncaIdStr, FS_MAX_PATH, "%016lx%016lx", ncaIdLower, ncaIdUpper);
|
||||||
return std::string(ncaIdStr);
|
return std::string(ncaIdStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
NcmContentId GetNcaIdFromString(std::string ncaIdStr)
|
NcmContentId GetNcaIdFromString(std::string ncaIdStr)
|
||||||
{
|
{
|
||||||
NcmContentId ncaId = {0};
|
NcmContentId ncaId = { 0 };
|
||||||
char lowerU64[17] = {0};
|
char lowerU64[17] = { 0 };
|
||||||
char upperU64[17] = {0};
|
char upperU64[17] = { 0 };
|
||||||
memcpy(lowerU64, ncaIdStr.c_str(), 16);
|
memcpy(lowerU64, ncaIdStr.c_str(), 16);
|
||||||
memcpy(upperU64, ncaIdStr.c_str() + 16, 16);
|
memcpy(upperU64, ncaIdStr.c_str() + 16, 16);
|
||||||
|
|
||||||
*(u64 *)ncaId.c = __bswap64(strtoul(lowerU64, NULL, 16));
|
*(u64*)ncaId.c = __bswap64(strtoul(lowerU64, NULL, 16));
|
||||||
*(u64 *)(ncaId.c + 8) = __bswap64(strtoul(upperU64, NULL, 16));
|
*(u64*)(ncaId.c + 8) = __bswap64(strtoul(upperU64, NULL, 16));
|
||||||
|
|
||||||
return ncaId;
|
return ncaId;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ namespace tin::util
|
|||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
NacpLanguageEntry *languageEntry;
|
NacpLanguageEntry* languageEntry;
|
||||||
|
|
||||||
if (R_FAILED(rc = nacpGetLanguageEntry(&appControlData.nacp, &languageEntry)))
|
if (R_FAILED(rc = nacpGetLanguageEntry(&appControlData.nacp, &languageEntry)))
|
||||||
{
|
{
|
||||||
|
@ -9,13 +9,13 @@
|
|||||||
|
|
||||||
// https://github.com/AtlasNX/Kosmos-Updater/blob/master/source/FileManager.cpp
|
// https://github.com/AtlasNX/Kosmos-Updater/blob/master/source/FileManager.cpp
|
||||||
|
|
||||||
unz_file_info_s * _getFileInfo(unzFile unz) {
|
unz_file_info_s* _getFileInfo(unzFile unz) {
|
||||||
unz_file_info_s * fileInfo = (unz_file_info_s*) malloc(sizeof(unz_file_info_s));
|
unz_file_info_s* fileInfo = (unz_file_info_s*)malloc(sizeof(unz_file_info_s));
|
||||||
unzGetCurrentFileInfo(unz, fileInfo, NULL, 0, NULL, 0, NULL, 0);
|
unzGetCurrentFileInfo(unz, fileInfo, NULL, 0, NULL, 0, NULL, 0);
|
||||||
return fileInfo;
|
return fileInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string _getFullFileName(unzFile unz, unz_file_info_s * fileInfo) {
|
std::string _getFullFileName(unzFile unz, unz_file_info_s* fileInfo) {
|
||||||
char filePath[fileInfo->size_filename + 1];
|
char filePath[fileInfo->size_filename + 1];
|
||||||
|
|
||||||
unzGetCurrentFileInfo(unz, fileInfo, filePath, fileInfo->size_filename, NULL, 0, NULL, 0);
|
unzGetCurrentFileInfo(unz, fileInfo, filePath, fileInfo->size_filename, NULL, 0, NULL, 0);
|
||||||
@ -31,13 +31,13 @@ bool _makeDirectoryParents(std::string path)
|
|||||||
{
|
{
|
||||||
bool bSuccess = false;
|
bool bSuccess = false;
|
||||||
int nRC = ::mkdir(path.c_str(), 0775);
|
int nRC = ::mkdir(path.c_str(), 0775);
|
||||||
if(nRC == -1)
|
if (nRC == -1)
|
||||||
{
|
{
|
||||||
switch(errno)
|
switch (errno)
|
||||||
{
|
{
|
||||||
case ENOENT:
|
case ENOENT:
|
||||||
//parent didn't exist, try to create it
|
//parent didn't exist, try to create it
|
||||||
if( _makeDirectoryParents(path.substr(0, path.find_last_of('/'))))
|
if (_makeDirectoryParents(path.substr(0, path.find_last_of('/'))))
|
||||||
//Now, try to create again.
|
//Now, try to create again.
|
||||||
bSuccess = 0 == ::mkdir(path.c_str(), 0775);
|
bSuccess = 0 == ::mkdir(path.c_str(), 0775);
|
||||||
else
|
else
|
||||||
@ -58,7 +58,7 @@ bool _makeDirectoryParents(std::string path)
|
|||||||
return bSuccess;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _extractFile(const char * path, unzFile unz, unz_file_info_s * fileInfo) {
|
int _extractFile(const char* path, unzFile unz, unz_file_info_s* fileInfo) {
|
||||||
//check to make sure filepath or fileInfo isnt null
|
//check to make sure filepath or fileInfo isnt null
|
||||||
if (path == NULL || fileInfo == NULL)
|
if (path == NULL || fileInfo == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -68,19 +68,19 @@ int _extractFile(const char * path, unzFile unz, unz_file_info_s * fileInfo) {
|
|||||||
|
|
||||||
char folderPath[strlen(path) + 1];
|
char folderPath[strlen(path) + 1];
|
||||||
strcpy(folderPath, path);
|
strcpy(folderPath, path);
|
||||||
char * pos = strrchr(folderPath, '/');
|
char* pos = strrchr(folderPath, '/');
|
||||||
if (pos != NULL) {
|
if (pos != NULL) {
|
||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
_makeDirectoryParents(std::string(folderPath));
|
_makeDirectoryParents(std::string(folderPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 blocksize = 0x8000;
|
u32 blocksize = 0x8000;
|
||||||
u8 * buffer = (u8*) malloc(blocksize);
|
u8* buffer = (u8*)malloc(blocksize);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return -3;
|
return -3;
|
||||||
u32 done = 0;
|
u32 done = 0;
|
||||||
int writeBytes = 0;
|
int writeBytes = 0;
|
||||||
FILE * fp = fopen(path, "w");
|
FILE* fp = fopen(path, "w");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return -4;
|
return -4;
|
||||||
@ -119,19 +119,21 @@ namespace inst::zip {
|
|||||||
int code;
|
int code;
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
code = unzGoToFirstFile(unz);
|
code = unzGoToFirstFile(unz);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
code = unzGoToNextFile(unz);
|
code = unzGoToNextFile(unz);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (code == UNZ_END_OF_LIST_OF_FILE) {
|
if (code == UNZ_END_OF_LIST_OF_FILE) {
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
unz_file_pos pos;
|
unz_file_pos pos;
|
||||||
unzGetFilePos(unz, &pos);
|
unzGetFilePos(unz, &pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
unz_file_info_s * fileInfo = _getFileInfo(unz);
|
unz_file_info_s* fileInfo = _getFileInfo(unz);
|
||||||
|
|
||||||
std::string fileName = destination;
|
std::string fileName = destination;
|
||||||
fileName += _getFullFileName(unz, fileInfo);
|
fileName += _getFullFileName(unz, fileInfo);
|
||||||
|
@ -16,9 +16,9 @@ typedef struct {
|
|||||||
bool initialized;
|
bool initialized;
|
||||||
|
|
||||||
UsbDsInterface* interface;
|
UsbDsInterface* interface;
|
||||||
UsbDsEndpoint *endpoint_in, *endpoint_out;
|
UsbDsEndpoint* endpoint_in, * endpoint_out;
|
||||||
|
|
||||||
u8 *endpoint_in_buffer, *endpoint_out_buffer;
|
u8* endpoint_in_buffer, * endpoint_out_buffer;
|
||||||
} usbCommsInterface;
|
} usbCommsInterface;
|
||||||
|
|
||||||
static bool g_usbCommsInitialized = false;
|
static bool g_usbCommsInitialized = false;
|
||||||
@ -29,13 +29,13 @@ static bool g_usbCommsErrorHandling = 0;
|
|||||||
|
|
||||||
static RwLock g_usbCommsLock;
|
static RwLock g_usbCommsLock;
|
||||||
|
|
||||||
static Result _usbCommsInterfaceInit1x(u32 intf_ind, const awoo_UsbCommsInterfaceInfo *info);
|
static Result _usbCommsInterfaceInit1x(u32 intf_ind, const awoo_UsbCommsInterfaceInfo* info);
|
||||||
static Result _usbCommsInterfaceInit5x(u32 intf_ind, const awoo_UsbCommsInterfaceInfo *info);
|
static Result _usbCommsInterfaceInit5x(u32 intf_ind, const awoo_UsbCommsInterfaceInfo* info);
|
||||||
static Result _usbCommsInterfaceInit(u32 intf_ind, const awoo_UsbCommsInterfaceInfo *info);
|
static Result _usbCommsInterfaceInit(u32 intf_ind, const awoo_UsbCommsInterfaceInfo* info);
|
||||||
|
|
||||||
static Result _usbCommsWrite(usbCommsInterface *interface, const void* buffer, size_t size, size_t *transferredSize, u64 timeout);
|
static Result _usbCommsWrite(usbCommsInterface* interface, const void* buffer, size_t size, size_t* transferredSize, u64 timeout);
|
||||||
|
|
||||||
static void _usbCommsUpdateInterfaceDescriptor(struct usb_interface_descriptor *desc, const awoo_UsbCommsInterfaceInfo *info) {
|
static void _usbCommsUpdateInterfaceDescriptor(struct usb_interface_descriptor* desc, const awoo_UsbCommsInterfaceInfo* info) {
|
||||||
if (info != NULL) {
|
if (info != NULL) {
|
||||||
desc->bInterfaceClass = info->bInterfaceClass;
|
desc->bInterfaceClass = info->bInterfaceClass;
|
||||||
desc->bInterfaceSubClass = info->bInterfaceSubClass;
|
desc->bInterfaceSubClass = info->bInterfaceSubClass;
|
||||||
@ -43,24 +43,26 @@ static void _usbCommsUpdateInterfaceDescriptor(struct usb_interface_descriptor *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result awoo_usbCommsInitializeEx(u32 num_interfaces, const awoo_UsbCommsInterfaceInfo *infos)
|
Result awoo_usbCommsInitializeEx(u32 num_interfaces, const awoo_UsbCommsInterfaceInfo* infos)
|
||||||
{
|
{
|
||||||
Result rc = 0;
|
Result rc = 0;
|
||||||
rwlockWriteLock(&g_usbCommsLock);
|
rwlockWriteLock(&g_usbCommsLock);
|
||||||
|
|
||||||
if (g_usbCommsInitialized) {
|
if (g_usbCommsInitialized) {
|
||||||
rc = MAKERESULT(Module_Libnx, LibnxError_AlreadyInitialized);
|
rc = MAKERESULT(Module_Libnx, LibnxError_AlreadyInitialized);
|
||||||
} else if (num_interfaces > TOTAL_INTERFACES) {
|
}
|
||||||
|
else if (num_interfaces > TOTAL_INTERFACES) {
|
||||||
rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
rc = usbDsInitialize();
|
rc = usbDsInitialize();
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
if (hosversionAtLeast(5,0,0)) {
|
if (hosversionAtLeast(5, 0, 0)) {
|
||||||
u8 iManufacturer, iProduct, iSerialNumber;
|
u8 iManufacturer, iProduct, iSerialNumber;
|
||||||
static const u16 supported_langs[1] = {0x0409};
|
static const u16 supported_langs[1] = { 0x0409 };
|
||||||
// Send language descriptor
|
// Send language descriptor
|
||||||
rc = usbDsAddUsbLanguageStringDescriptor(NULL, supported_langs, sizeof(supported_langs)/sizeof(u16));
|
rc = usbDsAddUsbLanguageStringDescriptor(NULL, supported_langs, sizeof(supported_langs) / sizeof(u16));
|
||||||
// Send manufacturer
|
// Send manufacturer
|
||||||
if (R_SUCCEEDED(rc)) rc = usbDsAddUsbStringDescriptor(&iManufacturer, "Nintendo");
|
if (R_SUCCEEDED(rc)) rc = usbDsAddUsbStringDescriptor(&iManufacturer, "Nintendo");
|
||||||
// Send product
|
// Send product
|
||||||
@ -122,7 +124,7 @@ Result awoo_usbCommsInitializeEx(u32 num_interfaces, const awoo_UsbCommsInterfac
|
|||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
for (u32 i = 0; i < num_interfaces; i++) {
|
for (u32 i = 0; i < num_interfaces; i++) {
|
||||||
usbCommsInterface *intf = &g_usbCommsInterfaces[i];
|
usbCommsInterface* intf = &g_usbCommsInterfaces[i];
|
||||||
rwlockWriteLock(&intf->lock);
|
rwlockWriteLock(&intf->lock);
|
||||||
rwlockWriteLock(&intf->lock_in);
|
rwlockWriteLock(&intf->lock_in);
|
||||||
rwlockWriteLock(&intf->lock_out);
|
rwlockWriteLock(&intf->lock_out);
|
||||||
@ -137,7 +139,7 @@ Result awoo_usbCommsInitializeEx(u32 num_interfaces, const awoo_UsbCommsInterfac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc) && hosversionAtLeast(5,0,0)) {
|
if (R_SUCCEEDED(rc) && hosversionAtLeast(5, 0, 0)) {
|
||||||
rc = usbDsEnable();
|
rc = usbDsEnable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +163,7 @@ Result awoo_usbCommsInitialize(void)
|
|||||||
return awoo_usbCommsInitializeEx(1, NULL);
|
return awoo_usbCommsInitializeEx(1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _usbCommsInterfaceFree(usbCommsInterface *interface)
|
static void _usbCommsInterfaceFree(usbCommsInterface* interface)
|
||||||
{
|
{
|
||||||
rwlockWriteLock(&interface->lock);
|
rwlockWriteLock(&interface->lock);
|
||||||
if (!interface->initialized) {
|
if (!interface->initialized) {
|
||||||
@ -201,25 +203,26 @@ void awoo_usbCommsExit(void)
|
|||||||
|
|
||||||
rwlockWriteUnlock(&g_usbCommsLock);
|
rwlockWriteUnlock(&g_usbCommsLock);
|
||||||
|
|
||||||
for (i=0; i<TOTAL_INTERFACES; i++)
|
for (i = 0; i < TOTAL_INTERFACES; i++)
|
||||||
{
|
{
|
||||||
_usbCommsInterfaceFree(&g_usbCommsInterfaces[i]);
|
_usbCommsInterfaceFree(&g_usbCommsInterfaces[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _usbCommsInterfaceInit(u32 intf_ind, const awoo_UsbCommsInterfaceInfo *info)
|
static Result _usbCommsInterfaceInit(u32 intf_ind, const awoo_UsbCommsInterfaceInfo* info)
|
||||||
{
|
{
|
||||||
if (hosversionAtLeast(5,0,0)) {
|
if (hosversionAtLeast(5, 0, 0)) {
|
||||||
return _usbCommsInterfaceInit5x(intf_ind, info);
|
return _usbCommsInterfaceInit5x(intf_ind, info);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return _usbCommsInterfaceInit1x(intf_ind, info);
|
return _usbCommsInterfaceInit1x(intf_ind, info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _usbCommsInterfaceInit5x(u32 intf_ind, const awoo_UsbCommsInterfaceInfo *info)
|
static Result _usbCommsInterfaceInit5x(u32 intf_ind, const awoo_UsbCommsInterfaceInfo* info)
|
||||||
{
|
{
|
||||||
Result rc = 0;
|
Result rc = 0;
|
||||||
usbCommsInterface *interface = &g_usbCommsInterfaces[intf_ind];
|
usbCommsInterface* interface = &g_usbCommsInterfaces[intf_ind];
|
||||||
|
|
||||||
struct usb_interface_descriptor interface_descriptor = {
|
struct usb_interface_descriptor interface_descriptor = {
|
||||||
.bLength = USB_DT_INTERFACE_SIZE,
|
.bLength = USB_DT_INTERFACE_SIZE,
|
||||||
@ -260,11 +263,11 @@ static Result _usbCommsInterfaceInit5x(u32 intf_ind, const awoo_UsbCommsInterfac
|
|||||||
|
|
||||||
//The buffer for PostBufferAsync commands must be 0x1000-byte aligned.
|
//The buffer for PostBufferAsync commands must be 0x1000-byte aligned.
|
||||||
interface->endpoint_in_buffer = memalign(0x1000, 0x1000);
|
interface->endpoint_in_buffer = memalign(0x1000, 0x1000);
|
||||||
if (interface->endpoint_in_buffer==NULL) rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
if (interface->endpoint_in_buffer == NULL) rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
interface->endpoint_out_buffer = memalign(0x1000, 0x1000);
|
interface->endpoint_out_buffer = memalign(0x1000, 0x1000);
|
||||||
if (interface->endpoint_out_buffer==NULL) rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
if (interface->endpoint_out_buffer == NULL) rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
@ -327,10 +330,10 @@ static Result _usbCommsInterfaceInit5x(u32 intf_ind, const awoo_UsbCommsInterfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Result _usbCommsInterfaceInit1x(u32 intf_ind, const awoo_UsbCommsInterfaceInfo *info)
|
static Result _usbCommsInterfaceInit1x(u32 intf_ind, const awoo_UsbCommsInterfaceInfo* info)
|
||||||
{
|
{
|
||||||
Result rc = 0;
|
Result rc = 0;
|
||||||
usbCommsInterface *interface = &g_usbCommsInterfaces[intf_ind];
|
usbCommsInterface* interface = &g_usbCommsInterfaces[intf_ind];
|
||||||
|
|
||||||
struct usb_interface_descriptor interface_descriptor = {
|
struct usb_interface_descriptor interface_descriptor = {
|
||||||
.bLength = USB_DT_INTERFACE_SIZE,
|
.bLength = USB_DT_INTERFACE_SIZE,
|
||||||
@ -362,11 +365,11 @@ static Result _usbCommsInterfaceInit1x(u32 intf_ind, const awoo_UsbCommsInterfac
|
|||||||
|
|
||||||
//The buffer for PostBufferAsync commands must be 0x1000-byte aligned.
|
//The buffer for PostBufferAsync commands must be 0x1000-byte aligned.
|
||||||
interface->endpoint_in_buffer = memalign(0x1000, 0x1000);
|
interface->endpoint_in_buffer = memalign(0x1000, 0x1000);
|
||||||
if (interface->endpoint_in_buffer==NULL) rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
if (interface->endpoint_in_buffer == NULL) rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
interface->endpoint_out_buffer = memalign(0x1000, 0x1000);
|
interface->endpoint_out_buffer = memalign(0x1000, 0x1000);
|
||||||
if (interface->endpoint_out_buffer==NULL) rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
if (interface->endpoint_out_buffer == NULL) rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
@ -397,32 +400,32 @@ void awoo_usbCommsSetErrorHandling(bool flag) {
|
|||||||
g_usbCommsErrorHandling = flag;
|
g_usbCommsErrorHandling = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _usbCommsRead(usbCommsInterface *interface, void* buffer, size_t size, size_t *transferredSize, u64 timeout)
|
static Result _usbCommsRead(usbCommsInterface* interface, void* buffer, size_t size, size_t* transferredSize, u64 timeout)
|
||||||
{
|
{
|
||||||
Result rc=0;
|
Result rc = 0;
|
||||||
u32 urbId=0;
|
u32 urbId = 0;
|
||||||
u8 *bufptr = (u8*)buffer;
|
u8* bufptr = (u8*)buffer;
|
||||||
u8 *transfer_buffer = NULL;
|
u8* transfer_buffer = NULL;
|
||||||
u8 transfer_type=0;
|
u8 transfer_type = 0;
|
||||||
u32 chunksize=0;
|
u32 chunksize = 0;
|
||||||
u32 tmp_transferredSize = 0;
|
u32 tmp_transferredSize = 0;
|
||||||
size_t total_transferredSize=0;
|
size_t total_transferredSize = 0;
|
||||||
UsbDsReportData reportdata;
|
UsbDsReportData reportdata;
|
||||||
|
|
||||||
//Makes sure endpoints are ready for data-transfer / wait for init if needed.
|
//Makes sure endpoints are ready for data-transfer / wait for init if needed.
|
||||||
rc = usbDsWaitReady(timeout);
|
rc = usbDsWaitReady(timeout);
|
||||||
if (R_FAILED(rc)) return rc;
|
if (R_FAILED(rc)) return rc;
|
||||||
|
|
||||||
while(size)
|
while (size)
|
||||||
{
|
{
|
||||||
if(((u64)bufptr) & 0xfff)//When bufptr isn't page-aligned copy the data into g_usbComms_endpoint_in_buffer and transfer that, otherwise use the bufptr directly.
|
if (((u64)bufptr) & 0xfff)//When bufptr isn't page-aligned copy the data into g_usbComms_endpoint_in_buffer and transfer that, otherwise use the bufptr directly.
|
||||||
{
|
{
|
||||||
transfer_buffer = interface->endpoint_out_buffer;
|
transfer_buffer = interface->endpoint_out_buffer;
|
||||||
memset(interface->endpoint_out_buffer, 0, 0x1000);
|
memset(interface->endpoint_out_buffer, 0, 0x1000);
|
||||||
|
|
||||||
chunksize = 0x1000;
|
chunksize = 0x1000;
|
||||||
chunksize-= ((u64)bufptr) & 0xfff;//After this transfer, bufptr will be page-aligned(if size is large enough for another transfer).
|
chunksize -= ((u64)bufptr) & 0xfff;//After this transfer, bufptr will be page-aligned(if size is large enough for another transfer).
|
||||||
if (size<chunksize) chunksize = size;
|
if (size < chunksize) chunksize = size;
|
||||||
|
|
||||||
transfer_type = 0;
|
transfer_type = 0;
|
||||||
}
|
}
|
||||||
@ -455,13 +458,13 @@ static Result _usbCommsRead(usbCommsInterface *interface, void* buffer, size_t s
|
|||||||
if (R_FAILED(rc)) return rc;
|
if (R_FAILED(rc)) return rc;
|
||||||
|
|
||||||
if (tmp_transferredSize > chunksize) tmp_transferredSize = chunksize;
|
if (tmp_transferredSize > chunksize) tmp_transferredSize = chunksize;
|
||||||
total_transferredSize+= (size_t)tmp_transferredSize;
|
total_transferredSize += (size_t)tmp_transferredSize;
|
||||||
|
|
||||||
if (transfer_type==0) memcpy(bufptr, transfer_buffer, tmp_transferredSize);
|
if (transfer_type == 0) memcpy(bufptr, transfer_buffer, tmp_transferredSize);
|
||||||
bufptr+= tmp_transferredSize;
|
bufptr += tmp_transferredSize;
|
||||||
size-= tmp_transferredSize;
|
size -= tmp_transferredSize;
|
||||||
|
|
||||||
if(tmp_transferredSize < chunksize)break;
|
if (tmp_transferredSize < chunksize)break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transferredSize) *transferredSize = total_transferredSize;
|
if (transferredSize) *transferredSize = total_transferredSize;
|
||||||
@ -469,31 +472,31 @@ static Result _usbCommsRead(usbCommsInterface *interface, void* buffer, size_t s
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result _usbCommsWrite(usbCommsInterface *interface, const void* buffer, size_t size, size_t *transferredSize, u64 timeout)
|
static Result _usbCommsWrite(usbCommsInterface* interface, const void* buffer, size_t size, size_t* transferredSize, u64 timeout)
|
||||||
{
|
{
|
||||||
Result rc=0;
|
Result rc = 0;
|
||||||
u32 urbId=0;
|
u32 urbId = 0;
|
||||||
u32 chunksize=0;
|
u32 chunksize = 0;
|
||||||
u8 *bufptr = (u8*)buffer;
|
u8* bufptr = (u8*)buffer;
|
||||||
u8 *transfer_buffer = NULL;
|
u8* transfer_buffer = NULL;
|
||||||
u32 tmp_transferredSize = 0;
|
u32 tmp_transferredSize = 0;
|
||||||
size_t total_transferredSize=0;
|
size_t total_transferredSize = 0;
|
||||||
UsbDsReportData reportdata;
|
UsbDsReportData reportdata;
|
||||||
|
|
||||||
//Makes sure endpoints are ready for data-transfer / wait for init if needed.
|
//Makes sure endpoints are ready for data-transfer / wait for init if needed.
|
||||||
rc = usbDsWaitReady(timeout);
|
rc = usbDsWaitReady(timeout);
|
||||||
if (R_FAILED(rc)) return rc;
|
if (R_FAILED(rc)) return rc;
|
||||||
|
|
||||||
while(size)
|
while (size)
|
||||||
{
|
{
|
||||||
if(((u64)bufptr) & 0xfff)//When bufptr isn't page-aligned copy the data into g_usbComms_endpoint_in_buffer and transfer that, otherwise use the bufptr directly.
|
if (((u64)bufptr) & 0xfff)//When bufptr isn't page-aligned copy the data into g_usbComms_endpoint_in_buffer and transfer that, otherwise use the bufptr directly.
|
||||||
{
|
{
|
||||||
transfer_buffer = interface->endpoint_in_buffer;
|
transfer_buffer = interface->endpoint_in_buffer;
|
||||||
memset(interface->endpoint_in_buffer, 0, 0x1000);
|
memset(interface->endpoint_in_buffer, 0, 0x1000);
|
||||||
|
|
||||||
chunksize = 0x1000;
|
chunksize = 0x1000;
|
||||||
chunksize-= ((u64)bufptr) & 0xfff;//After this transfer, bufptr will be page-aligned(if size is large enough for another transfer).
|
chunksize -= ((u64)bufptr) & 0xfff;//After this transfer, bufptr will be page-aligned(if size is large enough for another transfer).
|
||||||
if (size<chunksize) chunksize = size;
|
if (size < chunksize) chunksize = size;
|
||||||
|
|
||||||
memcpy(interface->endpoint_in_buffer, bufptr, chunksize);
|
memcpy(interface->endpoint_in_buffer, bufptr, chunksize);
|
||||||
}
|
}
|
||||||
@ -505,7 +508,7 @@ static Result _usbCommsWrite(usbCommsInterface *interface, const void* buffer, s
|
|||||||
|
|
||||||
//Start a device->host transfer.
|
//Start a device->host transfer.
|
||||||
rc = usbDsEndpoint_PostBufferAsync(interface->endpoint_in, transfer_buffer, chunksize, &urbId);
|
rc = usbDsEndpoint_PostBufferAsync(interface->endpoint_in, transfer_buffer, chunksize, &urbId);
|
||||||
if(R_FAILED(rc))return rc;
|
if (R_FAILED(rc))return rc;
|
||||||
|
|
||||||
//Wait for the transfer to finish.
|
//Wait for the transfer to finish.
|
||||||
rc = eventWait(&interface->endpoint_in->CompletionEvent, timeout);
|
rc = eventWait(&interface->endpoint_in->CompletionEvent, timeout);
|
||||||
@ -526,10 +529,10 @@ static Result _usbCommsWrite(usbCommsInterface *interface, const void* buffer, s
|
|||||||
|
|
||||||
if (tmp_transferredSize > chunksize) tmp_transferredSize = chunksize;
|
if (tmp_transferredSize > chunksize) tmp_transferredSize = chunksize;
|
||||||
|
|
||||||
total_transferredSize+= (size_t)tmp_transferredSize;
|
total_transferredSize += (size_t)tmp_transferredSize;
|
||||||
|
|
||||||
bufptr+= tmp_transferredSize;
|
bufptr += tmp_transferredSize;
|
||||||
size-= tmp_transferredSize;
|
size -= tmp_transferredSize;
|
||||||
|
|
||||||
if (tmp_transferredSize < chunksize) break;
|
if (tmp_transferredSize < chunksize) break;
|
||||||
}
|
}
|
||||||
@ -541,12 +544,12 @@ static Result _usbCommsWrite(usbCommsInterface *interface, const void* buffer, s
|
|||||||
|
|
||||||
size_t awoo_usbCommsReadEx(void* buffer, size_t size, u32 interface, u64 timeout)
|
size_t awoo_usbCommsReadEx(void* buffer, size_t size, u32 interface, u64 timeout)
|
||||||
{
|
{
|
||||||
size_t transferredSize=0;
|
size_t transferredSize = 0;
|
||||||
Result rc;
|
Result rc;
|
||||||
usbCommsInterface *inter = &g_usbCommsInterfaces[interface];
|
usbCommsInterface* inter = &g_usbCommsInterfaces[interface];
|
||||||
bool initialized;
|
bool initialized;
|
||||||
|
|
||||||
if (interface>=TOTAL_INTERFACES) return 0;
|
if (interface >= TOTAL_INTERFACES) return 0;
|
||||||
|
|
||||||
rwlockReadLock(&inter->lock);
|
rwlockReadLock(&inter->lock);
|
||||||
initialized = inter->initialized;
|
initialized = inter->initialized;
|
||||||
@ -568,12 +571,12 @@ size_t awoo_usbCommsRead(void* buffer, size_t size, u64 timeout)
|
|||||||
|
|
||||||
size_t awoo_usbCommsWriteEx(const void* buffer, size_t size, u32 interface, u64 timeout)
|
size_t awoo_usbCommsWriteEx(const void* buffer, size_t size, u32 interface, u64 timeout)
|
||||||
{
|
{
|
||||||
size_t transferredSize=0;
|
size_t transferredSize = 0;
|
||||||
Result rc;
|
Result rc;
|
||||||
usbCommsInterface *inter = &g_usbCommsInterfaces[interface];
|
usbCommsInterface* inter = &g_usbCommsInterfaces[interface];
|
||||||
bool initialized;
|
bool initialized;
|
||||||
|
|
||||||
if (interface>=TOTAL_INTERFACES) return 0;
|
if (interface >= TOTAL_INTERFACES) return 0;
|
||||||
|
|
||||||
rwlockReadLock(&inter->lock);
|
rwlockReadLock(&inter->lock);
|
||||||
initialized = inter->initialized;
|
initialized = inter->initialized;
|
||||||
|
@ -88,7 +88,7 @@ namespace tin::util
|
|||||||
|
|
||||||
size_t USBWrite(const void* in, size_t len, u64 timeout)
|
size_t USBWrite(const void* in, size_t len, u64 timeout)
|
||||||
{
|
{
|
||||||
const u8 *bufptr = (const u8 *)in;
|
const u8* bufptr = (const u8*)in;
|
||||||
size_t cursize = len;
|
size_t cursize = len;
|
||||||
size_t tmpsize = 0;
|
size_t tmpsize = 0;
|
||||||
|
|
||||||
|
@ -18,20 +18,20 @@
|
|||||||
#include "util/json.hpp"
|
#include "util/json.hpp"
|
||||||
|
|
||||||
namespace inst::util {
|
namespace inst::util {
|
||||||
void initApp () {
|
void initApp() {
|
||||||
// Seethe
|
// Seethe
|
||||||
if (!std::filesystem::exists("sdmc:/switch")) std::filesystem::create_directory("sdmc:/switch");
|
if (!std::filesystem::exists("sdmc:/switch")) std::filesystem::create_directory("sdmc:/switch");
|
||||||
if (!std::filesystem::exists(inst::config::appDir)) std::filesystem::create_directory(inst::config::appDir);
|
if (!std::filesystem::exists(inst::config::appDir)) std::filesystem::create_directory(inst::config::appDir);
|
||||||
inst::config::parseConfig();
|
inst::config::parseConfig();
|
||||||
|
|
||||||
socketInitializeDefault();
|
socketInitializeDefault();
|
||||||
#ifdef __DEBUG__
|
#ifdef __DEBUG__
|
||||||
nxlinkStdio();
|
nxlinkStdio();
|
||||||
#endif
|
#endif
|
||||||
awoo_usbCommsInitialize();
|
awoo_usbCommsInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void deinitApp () {
|
void deinitApp() {
|
||||||
socketExit();
|
socketExit();
|
||||||
awoo_usbCommsExit();
|
awoo_usbCommsExit();
|
||||||
}
|
}
|
||||||
@ -52,19 +52,19 @@ namespace inst::util {
|
|||||||
splExit();
|
splExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct caseInsensitiveLess : public std::binary_function< char,char,bool > {
|
struct caseInsensitiveLess : public std::binary_function< char, char, bool > {
|
||||||
bool operator () (char x, char y) const {
|
bool operator () (char x, char y) const {
|
||||||
return toupper(static_cast< unsigned char >(x)) < toupper(static_cast< unsigned char >(y));
|
return toupper(static_cast<unsigned char>(x)) < toupper(static_cast<unsigned char>(y));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ignoreCaseCompare(const std::string &a, const std::string &b) {
|
bool ignoreCaseCompare(const std::string& a, const std::string& b) {
|
||||||
return std::lexicographical_compare(a.begin(), a.end() , b.begin() ,b.end() , caseInsensitiveLess());
|
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end(), caseInsensitiveLess());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::filesystem::path> getDirectoryFiles(const std::string & dir, const std::vector<std::string> & extensions) {
|
std::vector<std::filesystem::path> getDirectoryFiles(const std::string& dir, const std::vector<std::string>& extensions) {
|
||||||
std::vector<std::filesystem::path> files;
|
std::vector<std::filesystem::path> files;
|
||||||
for(auto & p: std::filesystem::directory_iterator(dir))
|
for (auto& p : std::filesystem::directory_iterator(dir))
|
||||||
{
|
{
|
||||||
if (std::filesystem::is_regular_file(p))
|
if (std::filesystem::is_regular_file(p))
|
||||||
{
|
{
|
||||||
@ -80,9 +80,9 @@ namespace inst::util {
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::filesystem::path> getDirsAtPath(const std::string & dir) {
|
std::vector<std::filesystem::path> getDirsAtPath(const std::string& dir) {
|
||||||
std::vector<std::filesystem::path> files;
|
std::vector<std::filesystem::path> files;
|
||||||
for(auto & p: std::filesystem::directory_iterator(dir))
|
for (auto& p : std::filesystem::directory_iterator(dir))
|
||||||
{
|
{
|
||||||
if (std::filesystem::is_directory(p))
|
if (std::filesystem::is_directory(p))
|
||||||
{
|
{
|
||||||
@ -95,7 +95,7 @@ namespace inst::util {
|
|||||||
|
|
||||||
bool removeDirectory(std::string dir) {
|
bool removeDirectory(std::string dir) {
|
||||||
try {
|
try {
|
||||||
for(auto & p: std::filesystem::recursive_directory_iterator(dir))
|
for (auto& p : std::filesystem::recursive_directory_iterator(dir))
|
||||||
{
|
{
|
||||||
if (std::filesystem::is_regular_file(p))
|
if (std::filesystem::is_regular_file(p))
|
||||||
{
|
{
|
||||||
@ -105,7 +105,7 @@ namespace inst::util {
|
|||||||
rmdir(dir.c_str());
|
rmdir(dir.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (std::filesystem::filesystem_error & e) {
|
catch (std::filesystem::filesystem_error& e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,9 +115,9 @@ namespace inst::util {
|
|||||||
std::ifstream f1(inFile);
|
std::ifstream f1(inFile);
|
||||||
std::ofstream f2(outFile);
|
std::ofstream f2(outFile);
|
||||||
|
|
||||||
if(!f1 || !f2) return false;
|
if (!f1 || !f2) return false;
|
||||||
|
|
||||||
while(f1 && f1.get(ch)) f2.put(ch);
|
while (f1 && f1.get(ch)) f2.put(ch);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,11 +126,11 @@ namespace inst::util {
|
|||||||
std::string segment;
|
std::string segment;
|
||||||
std::vector<std::string> seglist;
|
std::vector<std::string> seglist;
|
||||||
|
|
||||||
while(std::getline(ourStream, segment, '/')) {
|
while (std::getline(ourStream, segment, '/')) {
|
||||||
seglist.push_back(segment);
|
seglist.push_back(segment);
|
||||||
}
|
}
|
||||||
|
|
||||||
CURL *curl = curl_easy_init();
|
CURL* curl = curl_easy_init();
|
||||||
int outlength;
|
int outlength;
|
||||||
std::string finalString = curl_easy_unescape(curl, seglist[seglist.size() - 1].c_str(), seglist[seglist.size() - 1].length(), &outlength);
|
std::string finalString = curl_easy_unescape(curl, seglist[seglist.size() - 1].c_str(), seglist[seglist.size() - 1].length(), &outlength);
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
@ -138,7 +138,7 @@ namespace inst::util {
|
|||||||
return finalString;
|
return finalString;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string formatUrlLink(std::string ourString){
|
std::string formatUrlLink(std::string ourString) {
|
||||||
std::string::size_type pos = ourString.find('/');
|
std::string::size_type pos = ourString.find('/');
|
||||||
if (pos != std::string::npos)
|
if (pos != std::string::npos)
|
||||||
return ourString.substr(0, pos);
|
return ourString.substr(0, pos);
|
||||||
@ -150,14 +150,15 @@ namespace inst::util {
|
|||||||
std::filesystem::path ourStringAsAPath = ourString;
|
std::filesystem::path ourStringAsAPath = ourString;
|
||||||
std::string ourExtension = ourStringAsAPath.extension().string();
|
std::string ourExtension = ourStringAsAPath.extension().string();
|
||||||
if (ourString.size() - ourExtension.size() > (unsigned long)ourLength) {
|
if (ourString.size() - ourExtension.size() > (unsigned long)ourLength) {
|
||||||
if(isFile) return (std::string)ourString.substr(0,ourLength) + "(...)" + ourExtension;
|
if (isFile) return (std::string)ourString.substr(0, ourLength) + "(...)" + ourExtension;
|
||||||
else return (std::string)ourString.substr(0,ourLength) + "...";
|
else return (std::string)ourString.substr(0, ourLength) + "...";
|
||||||
} else return ourString;
|
}
|
||||||
|
else return ourString;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string readTextFromFile(std::string ourFile) {
|
std::string readTextFromFile(std::string ourFile) {
|
||||||
if (std::filesystem::exists(ourFile)) {
|
if (std::filesystem::exists(ourFile)) {
|
||||||
FILE * file = fopen(ourFile.c_str(), "r");
|
FILE* file = fopen(ourFile.c_str(), "r");
|
||||||
char line[1024];
|
char line[1024];
|
||||||
fgets(line, 1024, file);
|
fgets(line, 1024, file);
|
||||||
std::string url = line;
|
std::string url = line;
|
||||||
@ -169,9 +170,9 @@ namespace inst::util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string softwareKeyboard(std::string guideText, std::string initialText, int LenMax) {
|
std::string softwareKeyboard(std::string guideText, std::string initialText, int LenMax) {
|
||||||
Result rc=0;
|
Result rc = 0;
|
||||||
SwkbdConfig kbd;
|
SwkbdConfig kbd;
|
||||||
char tmpoutstr[LenMax + 1] = {0};
|
char tmpoutstr[LenMax + 1] = { 0 };
|
||||||
rc = swkbdCreate(&kbd, 0);
|
rc = swkbdCreate(&kbd, 0);
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
swkbdConfigMakePresetDefault(&kbd);
|
swkbdConfigMakePresetDefault(&kbd);
|
||||||
@ -203,10 +204,10 @@ namespace inst::util {
|
|||||||
uint32_t hz = 0;
|
uint32_t hz = 0;
|
||||||
uint32_t previousHz = 0;
|
uint32_t previousHz = 0;
|
||||||
|
|
||||||
if (deviceToClock > 2 || deviceToClock < 0) return {0,0};
|
if (deviceToClock > 2 || deviceToClock < 0) return { 0,0 };
|
||||||
|
|
||||||
if(hosversionAtLeast(8,0,0)) {
|
if (hosversionAtLeast(8, 0, 0)) {
|
||||||
ClkrstSession session = {0};
|
ClkrstSession session = { 0 };
|
||||||
PcvModuleId pcvModuleId;
|
PcvModuleId pcvModuleId;
|
||||||
pcvInitialize();
|
pcvInitialize();
|
||||||
clkrstInitialize();
|
clkrstInitialize();
|
||||||
@ -232,8 +233,9 @@ namespace inst::util {
|
|||||||
clkrstCloseSession(&session);
|
clkrstCloseSession(&session);
|
||||||
clkrstExit();
|
clkrstExit();
|
||||||
|
|
||||||
return {previousHz, hz};
|
return { previousHz, hz };
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
PcvModule pcvModule;
|
PcvModule pcvModule;
|
||||||
pcvInitialize();
|
pcvInitialize();
|
||||||
|
|
||||||
@ -255,12 +257,12 @@ namespace inst::util {
|
|||||||
|
|
||||||
pcvExit();
|
pcvExit();
|
||||||
|
|
||||||
return {previousHz, hz};
|
return { previousHz, hz };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getIPAddress() {
|
std::string getIPAddress() {
|
||||||
struct in_addr addr = {(in_addr_t) gethostid()};
|
struct in_addr addr = { (in_addr_t)gethostid() };
|
||||||
return inet_ntoa(addr);
|
return inet_ntoa(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,24 +278,24 @@ namespace inst::util {
|
|||||||
int audio_channels = 2;
|
int audio_channels = 2;
|
||||||
int audio_buffers = 4096;
|
int audio_buffers = 4096;
|
||||||
|
|
||||||
if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) return;
|
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) return;
|
||||||
|
|
||||||
Mix_Chunk *sound = NULL;
|
Mix_Chunk* sound = NULL;
|
||||||
sound = Mix_LoadWAV(audioPath.c_str());
|
sound = Mix_LoadWAV(audioPath.c_str());
|
||||||
if(sound == NULL) {
|
if (sound == NULL) {
|
||||||
Mix_FreeChunk(sound);
|
Mix_FreeChunk(sound);
|
||||||
Mix_CloseAudio();
|
Mix_CloseAudio();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int channel = Mix_PlayChannel(-1, sound, 0);
|
int channel = Mix_PlayChannel(-1, sound, 0);
|
||||||
if(channel == -1) {
|
if (channel == -1) {
|
||||||
Mix_FreeChunk(sound);
|
Mix_FreeChunk(sound);
|
||||||
Mix_CloseAudio();
|
Mix_CloseAudio();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(Mix_Playing(channel) != 0);
|
while (Mix_Playing(channel) != 0);
|
||||||
|
|
||||||
Mix_FreeChunk(sound);
|
Mix_FreeChunk(sound);
|
||||||
Mix_CloseAudio();
|
Mix_CloseAudio();
|
||||||
@ -301,17 +303,18 @@ namespace inst::util {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> checkForAppUpdate () {
|
std::vector<std::string> checkForAppUpdate() {
|
||||||
try {
|
try {
|
||||||
std::string jsonData = inst::curl::downloadToBuffer("https://api.github.com/repos/Huntereb/Awoo-Installer/releases/latest", 0, 0, 1000L);
|
std::string jsonData = inst::curl::downloadToBuffer("https://api.github.com/repos/Huntereb/Awoo-Installer/releases/latest", 0, 0, 1000L);
|
||||||
if (jsonData.size() == 0) return {};
|
if (jsonData.size() == 0) return {};
|
||||||
nlohmann::json ourJson = nlohmann::json::parse(jsonData);
|
nlohmann::json ourJson = nlohmann::json::parse(jsonData);
|
||||||
if (ourJson["tag_name"].get<std::string>() != inst::config::appVersion) {
|
if (ourJson["tag_name"].get<std::string>() != inst::config::appVersion) {
|
||||||
std::vector<std::string> ourUpdateInfo = {ourJson["tag_name"].get<std::string>(), ourJson["assets"][0]["browser_download_url"].get<std::string>()};
|
std::vector<std::string> ourUpdateInfo = { ourJson["tag_name"].get<std::string>(), ourJson["assets"][0]["browser_download_url"].get<std::string>() };
|
||||||
inst::config::updateInfo = ourUpdateInfo;
|
inst::config::updateInfo = ourUpdateInfo;
|
||||||
return ourUpdateInfo;
|
return ourUpdateInfo;
|
||||||
}
|
}
|
||||||
} catch (...) {}
|
}
|
||||||
|
catch (...) {}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user