reformat code
This commit is contained in:
parent
ba57710eb1
commit
48015449c2
@ -38,7 +38,7 @@ namespace tin::data
|
||||
{
|
||||
std::atomic_bool isFinalized = false;
|
||||
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
|
||||
|
@ -34,7 +34,7 @@ namespace tin::data
|
||||
std::vector<u8> m_buffer;
|
||||
|
||||
public:
|
||||
ByteBuffer(size_t reserveSize=0);
|
||||
ByteBuffer(size_t reserveSize = 0);
|
||||
|
||||
size_t GetSize();
|
||||
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");
|
||||
|
||||
NX_INLINE const HFS0FileEntry *hfs0GetFileEntry(const HFS0BaseHeader *header, u32 i)
|
||||
NX_INLINE const HFS0FileEntry* hfs0GetFileEntry(const HFS0BaseHeader* header, u32 i)
|
||||
{
|
||||
if (i >= header->numFiles)
|
||||
return NULL;
|
||||
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);
|
||||
}
|
||||
|
||||
NX_INLINE u64 hfs0GetHeaderSize(const HFS0BaseHeader *header)
|
||||
NX_INLINE u64 hfs0GetHeaderSize(const HFS0BaseHeader* header)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ namespace tin::install
|
||||
virtual void InstallContentMetaRecords(tin::data::ByteBuffer& installContentMetaBuf, int i);
|
||||
virtual void InstallApplicationRecord(int i);
|
||||
virtual void InstallTicketCert() = 0;
|
||||
virtual void InstallNCA(const NcmContentId &ncaId) = 0;
|
||||
virtual void InstallNCA(const NcmContentId& ncaId) = 0;
|
||||
|
||||
public:
|
||||
virtual ~Install();
|
||||
|
@ -1,3 +1,3 @@
|
||||
namespace sig {
|
||||
void installSigPatches ();
|
||||
void installSigPatches();
|
||||
}
|
@ -5,8 +5,8 @@
|
||||
|
||||
namespace Crypto
|
||||
{
|
||||
#define RSA_2048_BYTES 0x100
|
||||
#define RSA_2048_BITS (RSA_2048_BYTES*8)
|
||||
#define RSA_2048_BYTES 0x100
|
||||
#define RSA_2048_BITS (RSA_2048_BYTES*8)
|
||||
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,
|
||||
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);
|
||||
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>
|
||||
T swapEndian(T s)
|
||||
@ -98,12 +98,12 @@ namespace Crypto
|
||||
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);
|
||||
}
|
||||
|
||||
void decrypt(void *dst, const void *src, size_t l)
|
||||
void decrypt(void* dst, const void* src, size_t 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)
|
||||
{
|
||||
@ -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)
|
||||
{
|
||||
|
@ -2,6 +2,6 @@
|
||||
#include <string>
|
||||
|
||||
namespace inst::curl {
|
||||
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);
|
||||
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);
|
||||
}
|
@ -29,7 +29,7 @@ extern "C" {
|
||||
#include <stdio.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
|
||||
}
|
||||
|
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));
|
||||
}
|
@ -74,8 +74,8 @@ namespace tin::network
|
||||
public:
|
||||
HTTPDownload(std::string url);
|
||||
|
||||
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);
|
||||
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);
|
||||
};
|
||||
|
||||
void NSULDrop(std::string url);
|
||||
|
@ -12,35 +12,35 @@ extern "C" {
|
||||
#pragma once
|
||||
#include "switch/types.h"
|
||||
|
||||
typedef struct {
|
||||
typedef struct {
|
||||
u8 bInterfaceClass;
|
||||
u8 bInterfaceSubClass;
|
||||
u8 bInterfaceProtocol;
|
||||
} awoo_UsbCommsInterfaceInfo;
|
||||
} awoo_UsbCommsInterfaceInfo;
|
||||
|
||||
/// Initializes usbComms with the default number of interfaces (1)
|
||||
Result awoo_usbCommsInitialize(void);
|
||||
/// Initializes usbComms with the default number of interfaces (1)
|
||||
Result awoo_usbCommsInitialize(void);
|
||||
|
||||
/// Initializes usbComms with a specific number of interfaces.
|
||||
Result awoo_usbCommsInitializeEx(u32 num_interfaces, const awoo_UsbCommsInterfaceInfo *infos);
|
||||
/// Initializes usbComms with a specific number of interfaces.
|
||||
Result awoo_usbCommsInitializeEx(u32 num_interfaces, const awoo_UsbCommsInterfaceInfo* infos);
|
||||
|
||||
/// Exits usbComms.
|
||||
void awoo_usbCommsExit(void);
|
||||
/// Exits usbComms.
|
||||
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.
|
||||
void awoo_usbCommsSetErrorHandling(bool flag);
|
||||
/// 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);
|
||||
|
||||
/// Read data with the default interface.
|
||||
size_t awoo_usbCommsRead(void* buffer, size_t size, u64 timeout);
|
||||
/// Read data with the default interface.
|
||||
size_t awoo_usbCommsRead(void* buffer, size_t size, u64 timeout);
|
||||
|
||||
/// Write data with the default interface.
|
||||
size_t awoo_usbCommsWrite(const void* buffer, size_t size, u64 timeout);
|
||||
/// Write data with the default interface.
|
||||
size_t awoo_usbCommsWrite(const void* buffer, size_t size, u64 timeout);
|
||||
|
||||
/// Same as usbCommsRead except with the specified interface.
|
||||
size_t awoo_usbCommsReadEx(void* buffer, size_t size, u32 interface, u64 timeout);
|
||||
/// Same as usbCommsRead except with the specified interface.
|
||||
size_t awoo_usbCommsReadEx(void* buffer, size_t size, u32 interface, u64 timeout);
|
||||
|
||||
/// Same as usbCommsWrite except with the specified interface.
|
||||
size_t awoo_usbCommsWriteEx(const void* buffer, size_t size, u32 interface, u64 timeout);
|
||||
/// Same as usbCommsWrite except with the specified interface.
|
||||
size_t awoo_usbCommsWriteEx(const void* buffer, size_t size, u32 interface, u64 timeout);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -37,10 +37,10 @@ namespace tin::util
|
||||
{
|
||||
u32 magic;
|
||||
USBCmdType type;
|
||||
u8 padding[0x3] = {0};
|
||||
u8 padding[0x3] = { 0 };
|
||||
u32 cmdId;
|
||||
u64 dataSize;
|
||||
u8 reserved[0xC] = {0};
|
||||
u8 reserved[0xC] = { 0 };
|
||||
} PACKED;
|
||||
|
||||
static_assert(sizeof(USBCmdHeader) == 0x20, "USBCmdHeader must be 0x20!");
|
||||
|
@ -2,13 +2,13 @@
|
||||
#include <filesystem>
|
||||
|
||||
namespace inst::util {
|
||||
void initApp ();
|
||||
void deinitApp ();
|
||||
void initApp();
|
||||
void deinitApp();
|
||||
void initInstallServices();
|
||||
void deinitInstallServices();
|
||||
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> getDirsAtPath(const std::string & dir);
|
||||
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> getDirsAtPath(const std::string& dir);
|
||||
bool removeDirectory(std::string dir);
|
||||
bool copyFile(std::string inFile, std::string outFile);
|
||||
std::string formatUrlString(std::string ourString);
|
||||
|
@ -43,7 +43,7 @@ SOFTWARE.
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
}
|
||||
|
||||
namespace nspInstStuff_B {
|
||||
@ -74,7 +74,8 @@ namespace nspInstStuff_B {
|
||||
if (ourTitleList[titleItr].extension() == ".xci" || ourTitleList[titleItr].extension() == ".xcz") {
|
||||
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);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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);
|
||||
}
|
||||
@ -100,8 +101,8 @@ namespace nspInstStuff_B {
|
||||
else {
|
||||
audioPath = "romfs:/audio/bark.wav";
|
||||
}
|
||||
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);
|
||||
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);
|
||||
audioThread.join();
|
||||
nspInstalled = false;
|
||||
}
|
||||
@ -112,7 +113,7 @@ namespace nspInstStuff_B {
|
||||
inst::util::setClockSpeed(2, previousClockValues[2]);
|
||||
}
|
||||
|
||||
if(nspInstalled) {
|
||||
if (nspInstalled) {
|
||||
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
std::string audioPath = "";
|
||||
@ -123,20 +124,23 @@ namespace nspInstStuff_B {
|
||||
else {
|
||||
audioPath = "romfs:/audio/ameizing.mp3";
|
||||
}
|
||||
std::thread audioThread(inst::util::playAudio,audioPath);
|
||||
std::thread audioThread(inst::util::playAudio, audioPath);
|
||||
|
||||
if (ourTitleList.size() > 1) {
|
||||
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++) {
|
||||
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::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);
|
||||
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);
|
||||
}
|
||||
|
||||
audioThread.join();
|
||||
|
@ -126,7 +126,7 @@ namespace tin::install::nsp
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -121,31 +121,31 @@ namespace tin::install::xci
|
||||
startTime = newTime;
|
||||
startSizeBuffered = newSizeBuffered;
|
||||
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
#ifdef NXLINK_DEBUG
|
||||
#ifdef NXLINK_DEBUG
|
||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
|
||||
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(100);
|
||||
|
||||
#ifdef NXLINK_DEBUG
|
||||
#ifdef NXLINK_DEBUG
|
||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsHttpXci)
|
||||
{
|
||||
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
#ifdef NXLINK_DEBUG
|
||||
#ifdef NXLINK_DEBUG
|
||||
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
||||
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(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");
|
||||
}
|
||||
|
||||
for (nx::ncm::ContentMeta contentMeta: m_contentMeta) {
|
||||
for (nx::ncm::ContentMeta contentMeta : m_contentMeta) {
|
||||
LOG_DEBUG("Installing NCAs...\n");
|
||||
for (auto& record : contentMeta.GetContentInfos())
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ SOFTWARE.
|
||||
#include "ui/MainApplication.hpp"
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
}
|
||||
|
||||
namespace tin::install::nsp
|
||||
@ -72,7 +72,7 @@ namespace tin::install::nsp
|
||||
*(u64*)&cnmtContentInfo.size = cnmtNcaSize & 0xFFFFFFFFFFFF;
|
||||
cnmtContentInfo.content_type = NcmContentType_Meta;
|
||||
|
||||
CNMTList.push_back( { tin::util::GetContentMetaFromNCA(cnmtNCAFullPath), cnmtContentInfo } );
|
||||
CNMTList.push_back({ tin::util::GetContentMetaFromNCA(cnmtNCAFullPath), cnmtContentInfo });
|
||||
}
|
||||
|
||||
return CNMTList;
|
||||
@ -83,10 +83,10 @@ namespace tin::install::nsp
|
||||
const PFS0FileEntry* fileEntry = m_NSP->GetFileEntryByNcaId(ncaId);
|
||||
std::string ncaFileName = m_NSP->GetFileEntryName(fileEntry);
|
||||
|
||||
#ifdef NXLINK_DEBUG
|
||||
#ifdef NXLINK_DEBUG
|
||||
size_t ncaSize = fileEntry->fileSize;
|
||||
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));
|
||||
|
||||
@ -114,8 +114,8 @@ namespace tin::install::nsp
|
||||
std::string audioPath = "romfs:/audio/bark.wav";
|
||||
if (inst::config::gayMode) audioPath = "";
|
||||
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
||||
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);
|
||||
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);
|
||||
audioThread.join();
|
||||
if (rc != 1)
|
||||
THROW_FORMAT(("inst.nca_verify.error"_lang + tin::util::GetNcaIdString(ncaId)).c_str());
|
||||
|
@ -35,7 +35,7 @@ SOFTWARE.
|
||||
#include "ui/MainApplication.hpp"
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
}
|
||||
|
||||
namespace tin::install::xci
|
||||
@ -68,7 +68,7 @@ namespace tin::install::xci
|
||||
*(u64*)&cnmtContentInfo.size = cnmtNcaSize & 0xFFFFFFFFFFFF;
|
||||
cnmtContentInfo.content_type = NcmContentType_Meta;
|
||||
|
||||
CNMTList.push_back( { tin::util::GetContentMetaFromNCA(cnmtNCAFullPath), cnmtContentInfo } );
|
||||
CNMTList.push_back({ tin::util::GetContentMetaFromNCA(cnmtNCAFullPath), cnmtContentInfo });
|
||||
}
|
||||
|
||||
return CNMTList;
|
||||
@ -79,10 +79,10 @@ namespace tin::install::xci
|
||||
const HFS0FileEntry* fileEntry = m_xci->GetFileEntryByNcaId(ncaId);
|
||||
std::string ncaFileName = m_xci->GetFileEntryName(fileEntry);
|
||||
|
||||
#ifdef NXLINK_DEBUG
|
||||
#ifdef NXLINK_DEBUG
|
||||
size_t ncaSize = fileEntry->fileSize;
|
||||
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));
|
||||
|
||||
@ -110,8 +110,8 @@ namespace tin::install::xci
|
||||
std::string audioPath = "romfs:/audio/bark.wav";
|
||||
if (inst::config::gayMode) audioPath = "";
|
||||
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
||||
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);
|
||||
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);
|
||||
audioThread.join();
|
||||
if (rc != 1)
|
||||
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);
|
||||
while (fileOff < ncaSize)
|
||||
{
|
||||
progress = (float) fileOff / (float) ncaSize;
|
||||
progress = (float)fileOff / (float)ncaSize;
|
||||
|
||||
if (fileOff % (0x400000 * 3) == 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);
|
||||
while (fileOff < ncaSize)
|
||||
{
|
||||
progress = (float) fileOff / (float) ncaSize;
|
||||
progress = (float)fileOff / (float)ncaSize;
|
||||
|
||||
if (fileOff % (0x400000 * 3) == 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
|
||||
{
|
||||
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() {}
|
||||
|
@ -147,31 +147,31 @@ namespace tin::install::nsp
|
||||
startTime = newTime;
|
||||
startSizeBuffered = newSizeBuffered;
|
||||
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
#ifdef NXLINK_DEBUG
|
||||
#ifdef NXLINK_DEBUG
|
||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
|
||||
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(100);
|
||||
|
||||
#ifdef NXLINK_DEBUG
|
||||
#ifdef NXLINK_DEBUG
|
||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbNsp)
|
||||
{
|
||||
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
#ifdef NXLINK_DEBUG
|
||||
#ifdef NXLINK_DEBUG
|
||||
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
||||
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(100);
|
||||
|
@ -146,31 +146,31 @@ namespace tin::install::xci
|
||||
startTime = newTime;
|
||||
startSizeBuffered = newSizeBuffered;
|
||||
int downloadProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeBuffered() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
#ifdef NXLINK_DEBUG
|
||||
#ifdef NXLINK_DEBUG
|
||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||
u64 downloadSizeMB = bufferedPlaceholderWriter.GetSizeBuffered() / 1000000;
|
||||
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(100);
|
||||
|
||||
#ifdef NXLINK_DEBUG
|
||||
#ifdef NXLINK_DEBUG
|
||||
u64 totalSizeMB = bufferedPlaceholderWriter.GetTotalDataSize() / 1000000;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
inst::ui::instPage::setInstInfoText("inst.info_page.top_info0"_lang + ncaFileName + "...");
|
||||
inst::ui::instPage::setInstBarPerc(0);
|
||||
while (!bufferedPlaceholderWriter.IsPlaceholderComplete() && !stopThreadsUsbXci)
|
||||
{
|
||||
int installProgress = (int)(((double)bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / (double)bufferedPlaceholderWriter.GetTotalDataSize()) * 100.0);
|
||||
#ifdef NXLINK_DEBUG
|
||||
#ifdef NXLINK_DEBUG
|
||||
u64 installSizeMB = bufferedPlaceholderWriter.GetSizeWrittenToPlaceholder() / 1000000;
|
||||
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(100);
|
||||
|
@ -47,7 +47,7 @@ namespace tin::install::xci
|
||||
printBytes(m_headerBytes.data(), sizeof(HFS0BaseHeader), true);
|
||||
|
||||
// Retrieve full header
|
||||
HFS0BaseHeader *header = reinterpret_cast<HFS0BaseHeader*>(m_headerBytes.data());
|
||||
HFS0BaseHeader* header = reinterpret_cast<HFS0BaseHeader*>(m_headerBytes.data());
|
||||
if (header->magic != MAGIC_HFS0)
|
||||
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());
|
||||
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));
|
||||
|
||||
if (entryName != "secure")
|
||||
|
@ -17,7 +17,8 @@ int main(int argc, char* argv[])
|
||||
main->Prepare();
|
||||
main->ShowWithFadeIn();
|
||||
updateThread.join();
|
||||
} catch (std::exception& e) {
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
LOG_DEBUG("An error occurred:\n%s", e.what());
|
||||
}
|
||||
inst::util::deinitApp();
|
||||
|
@ -50,10 +50,10 @@ static int m_serverSocket = 0;
|
||||
static int m_clientSocket = 0;
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
}
|
||||
|
||||
namespace netInstStuff{
|
||||
namespace netInstStuff {
|
||||
|
||||
void InitializeServerSocket() try
|
||||
{
|
||||
@ -70,7 +70,7 @@ namespace netInstStuff{
|
||||
server.sin_port = htons(REMOTE_INSTALL_PORT);
|
||||
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);
|
||||
}
|
||||
@ -93,7 +93,7 @@ namespace netInstStuff{
|
||||
close(m_serverSocket);
|
||||
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()
|
||||
@ -133,7 +133,8 @@ namespace netInstStuff{
|
||||
for (long unsigned int i = 0; i < urlListAltNames.size(); i++) {
|
||||
urlNames.push_back(inst::util::shortenString(urlListAltNames[i], 38, true));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for (long unsigned int i = 0; i < ourUrlList.size(); i++) {
|
||||
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") {
|
||||
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);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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);
|
||||
}
|
||||
@ -176,8 +178,8 @@ namespace netInstStuff{
|
||||
std::string audioPath = "romfs:/audio/bark.wav";
|
||||
if (inst::config::gayMode) audioPath = "";
|
||||
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
||||
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);
|
||||
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);
|
||||
audioThread.join();
|
||||
nspInstalled = false;
|
||||
}
|
||||
@ -191,15 +193,15 @@ namespace netInstStuff{
|
||||
sendExitCommands(inst::util::formatUrlLink(ourUrlList[0]));
|
||||
OnUnwound();
|
||||
|
||||
if(nspInstalled) {
|
||||
if (nspInstalled) {
|
||||
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
std::string audioPath = "romfs:/audio/awoo.wav";
|
||||
if (inst::config::gayMode) audioPath = "";
|
||||
if (std::filesystem::exists(inst::config::appDir + "/awoo.wav")) audioPath = inst::config::appDir + "/awoo.wav";
|
||||
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);
|
||||
else inst::ui::mainApp->CreateShowDialog(urlNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
|
||||
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);
|
||||
else inst::ui::mainApp->CreateShowDialog(urlNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true);
|
||||
audioThread.join();
|
||||
}
|
||||
|
||||
@ -256,11 +258,11 @@ namespace netInstStuff{
|
||||
}
|
||||
if (kDown & HidNpadButton_Y)
|
||||
{
|
||||
return {"supplyUrl"};
|
||||
return { "supplyUrl" };
|
||||
}
|
||||
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;
|
||||
@ -283,8 +285,8 @@ namespace netInstStuff{
|
||||
}
|
||||
|
||||
// Make sure the last string is null terminated
|
||||
auto urlBuf = std::make_unique<char[]>(size+1);
|
||||
memset(urlBuf.get(), 0, size+1);
|
||||
auto urlBuf = std::make_unique<char[]>(size + 1);
|
||||
memset(urlBuf.get(), 0, size + 1);
|
||||
|
||||
tin::network::WaitReceiveNetworkData(m_clientSocket, urlBuf.get(), size);
|
||||
|
||||
@ -311,7 +313,7 @@ namespace netInstStuff{
|
||||
LOG_DEBUG("Failed to perform remote install!\n");
|
||||
LOG_DEBUG("%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 {};
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ void esExit(void) {
|
||||
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,
|
||||
.buffer_attrs = {
|
||||
SfBufferAttr_HipcMapAlias | SfBufferAttr_In,
|
||||
|
@ -30,9 +30,10 @@ Result nsextInitialize(void) {
|
||||
Result rc = nsInitialize();
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if(hosversionBefore(3,0,0)) {
|
||||
if (hosversionBefore(3, 0, 0)) {
|
||||
g_nsAppManSrv = *nsGetServiceSession_ApplicationManagerInterface();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
rc = nsGetApplicationManagerInterface(&g_nsAppManSrv);
|
||||
}
|
||||
}
|
||||
@ -41,12 +42,12 @@ Result nsextInitialize(void) {
|
||||
}
|
||||
|
||||
void nsextExit(void) {
|
||||
if(hosversionAtLeast(3,0,0))
|
||||
if (hosversionAtLeast(3, 0, 0))
|
||||
serviceClose(&g_nsAppManSrv);
|
||||
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 {
|
||||
u8 last_modified_event;
|
||||
u64 application_id;
|
||||
|
@ -42,7 +42,7 @@ SOFTWARE.
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
}
|
||||
|
||||
namespace nspInstStuff {
|
||||
@ -73,7 +73,8 @@ namespace nspInstStuff {
|
||||
if (ourTitleList[titleItr].extension() == ".xci" || ourTitleList[titleItr].extension() == ".xcz") {
|
||||
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);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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);
|
||||
}
|
||||
@ -95,8 +96,8 @@ namespace nspInstStuff {
|
||||
std::string audioPath = "romfs:/audio/bark.wav";
|
||||
if (inst::config::gayMode) audioPath = "";
|
||||
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
||||
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);
|
||||
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);
|
||||
audioThread.join();
|
||||
nspInstalled = false;
|
||||
}
|
||||
@ -107,35 +108,40 @@ namespace nspInstStuff {
|
||||
inst::util::setClockSpeed(2, previousClockValues[2]);
|
||||
}
|
||||
|
||||
if(nspInstalled) {
|
||||
if (nspInstalled) {
|
||||
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
std::string audioPath = "romfs:/audio/awoo.wav";
|
||||
if (inst::config::gayMode) audioPath = "";
|
||||
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 (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++) {
|
||||
if (std::filesystem::exists(ourTitleList[i])) {
|
||||
try {
|
||||
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::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])) {
|
||||
try {
|
||||
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();
|
||||
}
|
||||
|
@ -8,11 +8,11 @@
|
||||
#include "util/lang.hpp"
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
}
|
||||
|
||||
namespace sig {
|
||||
void installSigPatches () {
|
||||
void installSigPatches() {
|
||||
bpcInitialize();
|
||||
try {
|
||||
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 + ".";
|
||||
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 (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;
|
||||
}
|
||||
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";
|
||||
bool didDownload = inst::curl::downloadFile(inst::config::sigPatchesUrl, ourPath.c_str());
|
||||
bool didExtract = false;
|
||||
if (didDownload) didExtract = inst::zip::extractFile(ourPath, "sdmc:/");
|
||||
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;
|
||||
}
|
||||
std::filesystem::remove(ourPath);
|
||||
@ -44,29 +44,32 @@ namespace sig {
|
||||
patchesVersion = inst::util::readTextFromFile("sdmc:/atmosphere/exefs_patches/es_patches/patches.txt");
|
||||
versionText = "";
|
||||
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 {
|
||||
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;
|
||||
} else if (ourResult == 1) {
|
||||
if (!inst::util::copyFile( inst::config::appDir + "/patches.ini.old", "sdmc:/bootloader/patches.ini")) {
|
||||
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");
|
||||
}
|
||||
else if (ourResult == 1) {
|
||||
if (!inst::util::copyFile(inst::config::appDir + "/patches.ini.old", "sdmc:/bootloader/patches.ini")) {
|
||||
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::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 return;
|
||||
else inst::ui::mainApp->CreateShowDialog("sig.remove_failed"_lang, "sig.remove_failed_desc"_lang, { "common.ok"_lang }, true);
|
||||
}
|
||||
else return;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_DEBUG("Failed to install Signature Patches");
|
||||
LOG_DEBUG("%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();
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
|
||||
HDInstPage::HDInstPage() : Layout::Layout() {
|
||||
this->SetBackgroundColor(COLOR("#670000FF"));
|
||||
@ -43,9 +43,9 @@ namespace inst::ui {
|
||||
this->currentDir = ourPath;
|
||||
|
||||
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 / "";
|
||||
}
|
||||
@ -54,8 +54,9 @@ namespace inst::ui {
|
||||
this->menu->ClearItems();
|
||||
try {
|
||||
this->ourDirectories = util::getDirsAtPath(this->currentDir);
|
||||
this->ourFiles = util::getDirectoryFiles(this->currentDir, {".nsp", ".nsz", ".xci", ".xcz"});
|
||||
} catch (std::exception& e) {
|
||||
this->ourFiles = util::getDirectoryFiles(this->currentDir, { ".nsp", ".nsz", ".xci", ".xcz" });
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
this->drawMenuItems(false, this->currentDir.parent_path());
|
||||
return;
|
||||
}
|
||||
@ -66,7 +67,7 @@ namespace inst::ui {
|
||||
ourEntry->SetIcon("romfs:/images/icons/folder-upload.png");
|
||||
this->menu->AddItem(ourEntry);
|
||||
|
||||
for (auto& file: this->ourDirectories) {
|
||||
for (auto& file : this->ourDirectories) {
|
||||
if (file == "..") break;
|
||||
std::string itm = file.filename().string();
|
||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||
@ -74,7 +75,7 @@ namespace inst::ui {
|
||||
ourEntry->SetIcon("romfs:/images/icons/folder.png");
|
||||
this->menu->AddItem(ourEntry);
|
||||
}
|
||||
for (auto& file: this->ourFiles) {
|
||||
for (auto& file : this->ourFiles) {
|
||||
std::string itm = file.filename().string();
|
||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
||||
@ -98,7 +99,8 @@ namespace inst::ui {
|
||||
if (selectedIndex < dirListSize) {
|
||||
if (this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetName() == ".." && this->menu->GetSelectedIndex() == 0) {
|
||||
this->drawMenuItems(true, this->currentDir.parent_path());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this->drawMenuItems(true, this->ourDirectories[selectedIndex]);
|
||||
}
|
||||
this->menu->SetSelectedIndex(0);
|
||||
@ -113,7 +115,8 @@ namespace inst::ui {
|
||||
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);
|
||||
}
|
||||
} 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 {
|
||||
this->followDirectory();
|
||||
return;
|
||||
@ -124,8 +127,9 @@ namespace inst::ui {
|
||||
void HDInstPage::startInstall() {
|
||||
int dialogResult = -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);
|
||||
} 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);
|
||||
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);
|
||||
if (dialogResult == -1) return;
|
||||
nspInstStuff_B::installNspFromFile(this->selectedTitles, dialogResult);
|
||||
}
|
||||
@ -153,7 +157,7 @@ namespace inst::ui {
|
||||
}
|
||||
}
|
||||
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 (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"
|
||||
|
||||
namespace inst::ui {
|
||||
MainApplication *mainApp;
|
||||
MainApplication* mainApp;
|
||||
|
||||
void MainApplication::OnLoad() {
|
||||
mainApp = this;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
|
||||
instPage::instPage() : Layout::Layout() {
|
||||
this->SetBackgroundColor(COLOR("#670000FF"));
|
||||
@ -36,27 +36,27 @@ namespace inst::ui {
|
||||
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->CallForRender();
|
||||
}
|
||||
|
||||
void instPage::setInstInfoText(std::string ourText){
|
||||
void instPage::setInstInfoText(std::string ourText) {
|
||||
mainApp->instpage->installInfoText->SetText(ourText);
|
||||
mainApp->CallForRender();
|
||||
}
|
||||
|
||||
void instPage::setInstBarPerc(double ourPercent){
|
||||
void instPage::setInstBarPerc(double ourPercent) {
|
||||
mainApp->instpage->installBar->SetVisible(true);
|
||||
mainApp->instpage->installBar->SetProgress(ourPercent);
|
||||
mainApp->CallForRender();
|
||||
}
|
||||
|
||||
void instPage::loadMainMenu(){
|
||||
void instPage::loadMainMenu() {
|
||||
mainApp->LoadLayout(mainApp->mainPage);
|
||||
}
|
||||
|
||||
void instPage::loadInstallScreen(){
|
||||
void instPage::loadInstallScreen() {
|
||||
mainApp->instpage->pageInfoText->SetText("");
|
||||
mainApp->instpage->installInfoText->SetText("");
|
||||
mainApp->instpage->installBar->SetProgress(0);
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
bool appletFinished = false;
|
||||
bool updateFinished = false;
|
||||
|
||||
@ -24,9 +24,10 @@ namespace inst::ui {
|
||||
tin::data::NUM_BUFFER_SEGMENTS = 2;
|
||||
if (menuLoaded) {
|
||||
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;
|
||||
tin::data::NUM_BUFFER_SEGMENTS = 128;
|
||||
}
|
||||
@ -99,7 +100,7 @@ namespace inst::ui {
|
||||
|
||||
void MainPage::netInstallMenuItem_Click() {
|
||||
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;
|
||||
}
|
||||
mainApp->netinstPage->startNetwork();
|
||||
@ -107,13 +108,13 @@ namespace inst::ui {
|
||||
|
||||
void MainPage::usbInstallMenuItem_Click() {
|
||||
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::setConfig();
|
||||
}
|
||||
}
|
||||
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() {
|
||||
@ -121,12 +122,13 @@ namespace inst::ui {
|
||||
}
|
||||
|
||||
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->menu->SetSelectedIndex(0);
|
||||
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)
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
|
||||
std::string lastFileID = "";
|
||||
std::string sourceString = "";
|
||||
@ -50,7 +50,7 @@ namespace inst::ui {
|
||||
if (clearItems) this->selectedUrls = {};
|
||||
if (clearItems) this->alternativeNames = {};
|
||||
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);
|
||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
||||
@ -69,7 +69,8 @@ namespace inst::ui {
|
||||
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);
|
||||
}
|
||||
} else this->selectedUrls.push_back(this->ourUrls[selectedIndex]);
|
||||
}
|
||||
else this->selectedUrls.push_back(this->ourUrls[selectedIndex]);
|
||||
this->drawMenuItems(false);
|
||||
}
|
||||
|
||||
@ -83,20 +84,21 @@ namespace inst::ui {
|
||||
if (!this->ourUrls.size()) {
|
||||
mainApp->LoadLayout(mainApp->mainPage);
|
||||
return;
|
||||
} else if (this->ourUrls[0] == "supplyUrl") {
|
||||
}
|
||||
else if (this->ourUrls[0] == "supplyUrl") {
|
||||
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:
|
||||
keyboardResult = inst::util::softwareKeyboard("inst.net.url.hint"_lang, inst::config::lastNetUrl, 500);
|
||||
if (keyboardResult.size() > 0) {
|
||||
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;
|
||||
}
|
||||
inst::config::lastNetUrl = keyboardResult;
|
||||
inst::config::setConfig();
|
||||
sourceString = "inst.net.url.source_string"_lang;
|
||||
this->selectedUrls = {keyboardResult};
|
||||
this->selectedUrls = { keyboardResult };
|
||||
this->startInstall(true);
|
||||
return;
|
||||
}
|
||||
@ -106,10 +108,10 @@ namespace inst::ui {
|
||||
if (keyboardResult.size() > 0) {
|
||||
lastFileID = keyboardResult;
|
||||
std::string fileName = inst::util::getDriveFileName(keyboardResult);
|
||||
if (fileName.size() > 0) this->alternativeNames = {fileName};
|
||||
else this->alternativeNames = {"inst.net.gdrive.alt_name"_lang};
|
||||
if (fileName.size() > 0) this->alternativeNames = { fileName };
|
||||
else this->alternativeNames = { "inst.net.gdrive.alt_name"_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);
|
||||
return;
|
||||
}
|
||||
@ -117,7 +119,8 @@ namespace inst::ui {
|
||||
}
|
||||
this->startNetwork();
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mainApp->CallForRender(); // If we re-render a few times during this process the main screen won't flicker
|
||||
sourceString = "inst.net.source_string"_lang;
|
||||
this->pageInfoText->SetText("inst.net.top_info"_lang);
|
||||
@ -137,8 +140,9 @@ namespace inst::ui {
|
||||
std::string ourUrlString;
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
if (dialogResult == -1 && !urlMode) return;
|
||||
else if (dialogResult == -1 && urlMode) {
|
||||
this->startNetwork();
|
||||
@ -150,7 +154,7 @@ namespace inst::ui {
|
||||
|
||||
void netInstPage::onInput(u64 Down, u64 Up, u64 Held, pu::ui::Touch Pos) {
|
||||
if (Down & HidNpadButton_B) {
|
||||
if (this->menu->GetItems().size() > 0){
|
||||
if (this->menu->GetItems().size() > 0) {
|
||||
if (this->selectedUrls.size() == 0) {
|
||||
this->selectTitle(this->menu->GetSelectedIndex());
|
||||
}
|
||||
|
@ -14,9 +14,9 @@
|
||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||
|
||||
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() {
|
||||
this->SetBackgroundColor(COLOR("#670000FF"));
|
||||
@ -53,7 +53,7 @@ namespace inst::ui {
|
||||
}
|
||||
|
||||
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::setTopInstInfoText("options.update.top_info"_lang + updateInfo[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::zip::extractFile(downloadName, "sdmc:/");
|
||||
std::filesystem::remove(downloadName);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
mainApp->FadeOut();
|
||||
mainApp->Close();
|
||||
@ -76,7 +77,7 @@ namespace inst::ui {
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
@ -166,8 +167,9 @@ namespace inst::ui {
|
||||
break;
|
||||
case 1:
|
||||
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;
|
||||
} else inst::config::validateNCAs = true;
|
||||
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;
|
||||
inst::config::setConfig();
|
||||
this->setMenuText();
|
||||
break;
|
||||
@ -255,18 +257,18 @@ namespace inst::ui {
|
||||
break;
|
||||
case 7:
|
||||
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;
|
||||
}
|
||||
downloadUrl = inst::util::checkForAppUpdate();
|
||||
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;
|
||||
}
|
||||
this->askToUpdate(downloadUrl);
|
||||
break;
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define COLOR(hex) pu::ui::Color::FromHex(hex)
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
|
||||
sdInstPage::sdInstPage() : Layout::Layout() {
|
||||
this->SetBackgroundColor(COLOR("#670000FF"));
|
||||
@ -46,8 +46,9 @@ namespace inst::ui {
|
||||
this->menu->ClearItems();
|
||||
try {
|
||||
this->ourDirectories = util::getDirsAtPath(this->currentDir);
|
||||
this->ourFiles = util::getDirectoryFiles(this->currentDir, {".nsp", ".nsz", ".xci", ".xcz"});
|
||||
} catch (std::exception& e) {
|
||||
this->ourFiles = util::getDirectoryFiles(this->currentDir, { ".nsp", ".nsz", ".xci", ".xcz" });
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
this->drawMenuItems(false, this->currentDir.parent_path());
|
||||
return;
|
||||
}
|
||||
@ -58,7 +59,7 @@ namespace inst::ui {
|
||||
ourEntry->SetIcon("romfs:/images/icons/folder-upload.png");
|
||||
this->menu->AddItem(ourEntry);
|
||||
}
|
||||
for (auto& file: this->ourDirectories) {
|
||||
for (auto& file : this->ourDirectories) {
|
||||
if (file == "..") break;
|
||||
std::string itm = file.filename().string();
|
||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||
@ -66,7 +67,7 @@ namespace inst::ui {
|
||||
ourEntry->SetIcon("romfs:/images/icons/folder.png");
|
||||
this->menu->AddItem(ourEntry);
|
||||
}
|
||||
for (auto& file: this->ourFiles) {
|
||||
for (auto& file : this->ourFiles) {
|
||||
std::string itm = file.filename().string();
|
||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
||||
@ -90,7 +91,8 @@ namespace inst::ui {
|
||||
if (selectedIndex < dirListSize) {
|
||||
if (this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetName() == ".." && this->menu->GetSelectedIndex() == 0) {
|
||||
this->drawMenuItems(true, this->currentDir.parent_path());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this->drawMenuItems(true, this->ourDirectories[selectedIndex]);
|
||||
}
|
||||
this->menu->SetSelectedIndex(0);
|
||||
@ -104,7 +106,8 @@ namespace inst::ui {
|
||||
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);
|
||||
}
|
||||
} 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 {
|
||||
this->followDirectory();
|
||||
return;
|
||||
@ -115,8 +118,9 @@ namespace inst::ui {
|
||||
void sdInstPage::startInstall() {
|
||||
int dialogResult = -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);
|
||||
} 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);
|
||||
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);
|
||||
if (dialogResult == -1) return;
|
||||
nspInstStuff::installNspFromFile(this->selectedTitles, dialogResult);
|
||||
}
|
||||
@ -144,7 +148,7 @@ namespace inst::ui {
|
||||
}
|
||||
}
|
||||
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 (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)
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
|
||||
usbInstPage::usbInstPage() : Layout::Layout() {
|
||||
this->SetBackgroundColor(COLOR("#670000FF"));
|
||||
@ -44,7 +44,7 @@ namespace inst::ui {
|
||||
void usbInstPage::drawMenuItems(bool clearItems) {
|
||||
if (clearItems) this->selectedTitles = {};
|
||||
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);
|
||||
auto ourEntry = pu::ui::elm::MenuItem::New(itm);
|
||||
ourEntry->SetColor(COLOR("#FFFFFFFF"));
|
||||
@ -63,7 +63,8 @@ namespace inst::ui {
|
||||
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);
|
||||
}
|
||||
} else this->selectedTitles.push_back(this->ourTitles[selectedIndex]);
|
||||
}
|
||||
else this->selectedTitles.push_back(this->ourTitles[selectedIndex]);
|
||||
this->drawMenuItems(false);
|
||||
}
|
||||
|
||||
@ -79,7 +80,8 @@ namespace inst::ui {
|
||||
if (!this->ourTitles.size()) {
|
||||
mainApp->LoadLayout(mainApp->mainPage);
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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->butText->SetText("inst.usb.buttons2"_lang);
|
||||
@ -94,8 +96,8 @@ namespace inst::ui {
|
||||
|
||||
void usbInstPage::startInstall() {
|
||||
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);
|
||||
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 (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);
|
||||
if (dialogResult == -1) return;
|
||||
usbInstStuff::installTitleUsb(this->selectedTitles, dialogResult);
|
||||
return;
|
||||
|
@ -38,7 +38,7 @@ SOFTWARE.
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
namespace inst::ui {
|
||||
extern MainApplication *mainApp;
|
||||
extern MainApplication* mainApp;
|
||||
}
|
||||
|
||||
namespace usbInstStuff {
|
||||
@ -62,7 +62,7 @@ namespace usbInstStuff {
|
||||
TUSHeader header;
|
||||
u64 freq = armGetSystemTickFreq();
|
||||
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
|
||||
u64 newTime = armGetSystemTick();
|
||||
if (newTime - startTime >= freq * 0.25) {
|
||||
@ -73,7 +73,7 @@ namespace usbInstStuff {
|
||||
if (bufferData(&header, sizeof(TUSHeader), 500000000) != 0) break;
|
||||
u64 kDown = inst::ui::mainApp->GetButtonsDown();
|
||||
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 {};
|
||||
}
|
||||
|
||||
@ -125,7 +125,8 @@ namespace usbInstStuff {
|
||||
if (ourTitleList[fileItr].compare(ourTitleList[fileItr].size() - 3, 2, "xc") == 0) {
|
||||
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);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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);
|
||||
}
|
||||
@ -147,8 +148,8 @@ namespace usbInstStuff {
|
||||
std::string audioPath = "romfs:/audio/bark.wav";
|
||||
if (inst::config::gayMode) audioPath = "";
|
||||
if (std::filesystem::exists(inst::config::appDir + "/bark.wav")) audioPath = inst::config::appDir + "/bark.wav";
|
||||
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);
|
||||
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);
|
||||
audioThread.join();
|
||||
nspInstalled = false;
|
||||
}
|
||||
@ -159,16 +160,16 @@ namespace usbInstStuff {
|
||||
inst::util::setClockSpeed(2, previousClockValues[2]);
|
||||
}
|
||||
|
||||
if(nspInstalled) {
|
||||
if (nspInstalled) {
|
||||
tin::util::USBCmdManager::SendExitCmd();
|
||||
inst::ui::instPage::setInstInfoText("inst.info_page.complete"_lang);
|
||||
inst::ui::instPage::setInstBarPerc(100);
|
||||
std::string audioPath = "romfs:/audio/awoo.wav";
|
||||
if (inst::config::gayMode) audioPath = "";
|
||||
if (std::filesystem::exists(inst::config::appDir + "/awoo.wav")) audioPath = inst::config::appDir + "/awoo.wav";
|
||||
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);
|
||||
else inst::ui::mainApp->CreateShowDialog(fileNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), {"common.ok"_lang}, true);
|
||||
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);
|
||||
else inst::ui::mainApp->CreateShowDialog(fileNames[0] + "inst.info_page.desc1"_lang, Language::GetRandomMsg(), { "common.ok"_lang }, true);
|
||||
audioThread.join();
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace inst::config {
|
||||
}
|
||||
catch (...) {
|
||||
// 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";
|
||||
languageSetting = 99;
|
||||
autoUpdate = true;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <mbedtls/bignum.h>
|
||||
|
||||
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);
|
||||
|
||||
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 modulus_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 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(&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);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
@ -7,23 +7,24 @@
|
||||
#include "util/error.hpp"
|
||||
#include "ui/instPage.hpp"
|
||||
|
||||
static size_t writeDataFile(void *ptr, size_t size, size_t nmemb, void *stream) {
|
||||
size_t written = fwrite(ptr, size, nmemb, (FILE *)stream);
|
||||
static size_t writeDataFile(void* ptr, size_t size, size_t nmemb, void* stream) {
|
||||
size_t written = fwrite(ptr, size, nmemb, (FILE*)stream);
|
||||
return written;
|
||||
}
|
||||
|
||||
size_t writeDataBuffer(char *ptr, size_t size, size_t nmemb, void *userdata) {
|
||||
std::ostringstream *stream = (std::ostringstream*)userdata;
|
||||
size_t writeDataBuffer(char* ptr, size_t size, size_t nmemb, void* userdata) {
|
||||
std::ostringstream* stream = (std::ostringstream*)userdata;
|
||||
size_t count = size * nmemb;
|
||||
stream->write(ptr, 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) {
|
||||
int uploadProgress = (int)(((double)ulnow / (double)ultotal) * 100.0);
|
||||
inst::ui::instPage::setInstBarPerc(uploadProgress);
|
||||
} else if (dltotal) {
|
||||
}
|
||||
else if (dltotal) {
|
||||
int downloadProgress = (int)(((double)dlnow / (double)dltotal) * 100.0);
|
||||
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 {
|
||||
bool downloadFile (const std::string ourUrl, const char *pagefilename, long timeout, bool writeProgress) {
|
||||
CURL *curl_handle;
|
||||
bool downloadFile(const std::string ourUrl, const char* pagefilename, long timeout, bool writeProgress) {
|
||||
CURL* curl_handle;
|
||||
CURLcode result;
|
||||
FILE *pagefile;
|
||||
FILE* pagefile;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
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) {
|
||||
CURL *curl_handle;
|
||||
std::string downloadToBuffer(const std::string ourUrl, int firstRange, int secondRange, long timeout) {
|
||||
CURL* curl_handle;
|
||||
CURLcode result;
|
||||
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_WRITEFUNCTION, writeDataBuffer);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ SOFTWARE.
|
||||
#include <arpa/inet.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
|
||||
int count = 0;
|
||||
|
@ -158,7 +158,7 @@ namespace tin::network
|
||||
|
||||
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;
|
||||
|
||||
if (streamFunc != nullptr)
|
||||
@ -167,7 +167,7 @@ namespace tin::network
|
||||
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;
|
||||
|
||||
@ -190,7 +190,7 @@ namespace tin::network
|
||||
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)
|
||||
{
|
||||
@ -256,8 +256,8 @@ namespace tin::network
|
||||
errno = 0;
|
||||
ret = send(sockfd, (u8*)buf + written, len - written, 0);
|
||||
|
||||
if (ret < 0){ // If error
|
||||
if (errno == EWOULDBLOCK || errno == EAGAIN){ // Is it because other side is busy?
|
||||
if (ret < 0) { // If error
|
||||
if (errno == EWOULDBLOCK || errno == EAGAIN) { // Is it because other side is busy?
|
||||
sleep(5);
|
||||
continue;
|
||||
}
|
||||
|
@ -29,33 +29,33 @@ namespace tin::util
|
||||
{
|
||||
u64 GetRightsIdTid(FsRightsId rightsId)
|
||||
{
|
||||
return __bswap64(*(u64 *)rightsId.c);
|
||||
return __bswap64(*(u64*)rightsId.c);
|
||||
}
|
||||
|
||||
u64 GetRightsIdKeyGen(FsRightsId rightsId)
|
||||
{
|
||||
return __bswap64(*(u64 *)(rightsId.c + 8));
|
||||
return __bswap64(*(u64*)(rightsId.c + 8));
|
||||
}
|
||||
|
||||
std::string GetNcaIdString(const NcmContentId& ncaId)
|
||||
{
|
||||
char ncaIdStr[FS_MAX_PATH] = {0};
|
||||
u64 ncaIdLower = __bswap64(*(u64 *)ncaId.c);
|
||||
u64 ncaIdUpper = __bswap64(*(u64 *)(ncaId.c + 0x8));
|
||||
char ncaIdStr[FS_MAX_PATH] = { 0 };
|
||||
u64 ncaIdLower = __bswap64(*(u64*)ncaId.c);
|
||||
u64 ncaIdUpper = __bswap64(*(u64*)(ncaId.c + 0x8));
|
||||
snprintf(ncaIdStr, FS_MAX_PATH, "%016lx%016lx", ncaIdLower, ncaIdUpper);
|
||||
return std::string(ncaIdStr);
|
||||
}
|
||||
|
||||
NcmContentId GetNcaIdFromString(std::string ncaIdStr)
|
||||
{
|
||||
NcmContentId ncaId = {0};
|
||||
char lowerU64[17] = {0};
|
||||
char upperU64[17] = {0};
|
||||
NcmContentId ncaId = { 0 };
|
||||
char lowerU64[17] = { 0 };
|
||||
char upperU64[17] = { 0 };
|
||||
memcpy(lowerU64, ncaIdStr.c_str(), 16);
|
||||
memcpy(upperU64, ncaIdStr.c_str() + 16, 16);
|
||||
|
||||
*(u64 *)ncaId.c = __bswap64(strtoul(lowerU64, NULL, 16));
|
||||
*(u64 *)(ncaId.c + 8) = __bswap64(strtoul(upperU64, NULL, 16));
|
||||
*(u64*)ncaId.c = __bswap64(strtoul(lowerU64, NULL, 16));
|
||||
*(u64*)(ncaId.c + 8) = __bswap64(strtoul(upperU64, NULL, 16));
|
||||
|
||||
return ncaId;
|
||||
}
|
||||
@ -93,7 +93,7 @@ namespace tin::util
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
NacpLanguageEntry *languageEntry;
|
||||
NacpLanguageEntry* languageEntry;
|
||||
|
||||
if (R_FAILED(rc = nacpGetLanguageEntry(&appControlData.nacp, &languageEntry)))
|
||||
{
|
||||
|
@ -9,13 +9,13 @@
|
||||
|
||||
// https://github.com/AtlasNX/Kosmos-Updater/blob/master/source/FileManager.cpp
|
||||
|
||||
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* _getFileInfo(unzFile unz) {
|
||||
unz_file_info_s* fileInfo = (unz_file_info_s*)malloc(sizeof(unz_file_info_s));
|
||||
unzGetCurrentFileInfo(unz, fileInfo, NULL, 0, NULL, 0, NULL, 0);
|
||||
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];
|
||||
|
||||
unzGetCurrentFileInfo(unz, fileInfo, filePath, fileInfo->size_filename, NULL, 0, NULL, 0);
|
||||
@ -31,13 +31,13 @@ bool _makeDirectoryParents(std::string path)
|
||||
{
|
||||
bool bSuccess = false;
|
||||
int nRC = ::mkdir(path.c_str(), 0775);
|
||||
if(nRC == -1)
|
||||
if (nRC == -1)
|
||||
{
|
||||
switch(errno)
|
||||
switch (errno)
|
||||
{
|
||||
case ENOENT:
|
||||
//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.
|
||||
bSuccess = 0 == ::mkdir(path.c_str(), 0775);
|
||||
else
|
||||
@ -58,7 +58,7 @@ bool _makeDirectoryParents(std::string path)
|
||||
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
|
||||
if (path == NULL || fileInfo == NULL)
|
||||
return -1;
|
||||
@ -68,19 +68,19 @@ int _extractFile(const char * path, unzFile unz, unz_file_info_s * fileInfo) {
|
||||
|
||||
char folderPath[strlen(path) + 1];
|
||||
strcpy(folderPath, path);
|
||||
char * pos = strrchr(folderPath, '/');
|
||||
char* pos = strrchr(folderPath, '/');
|
||||
if (pos != NULL) {
|
||||
*pos = '\0';
|
||||
_makeDirectoryParents(std::string(folderPath));
|
||||
}
|
||||
|
||||
u32 blocksize = 0x8000;
|
||||
u8 * buffer = (u8*) malloc(blocksize);
|
||||
u8* buffer = (u8*)malloc(blocksize);
|
||||
if (buffer == NULL)
|
||||
return -3;
|
||||
u32 done = 0;
|
||||
int writeBytes = 0;
|
||||
FILE * fp = fopen(path, "w");
|
||||
FILE* fp = fopen(path, "w");
|
||||
if (fp == NULL) {
|
||||
free(buffer);
|
||||
return -4;
|
||||
@ -119,19 +119,21 @@ namespace inst::zip {
|
||||
int code;
|
||||
if (i == 0) {
|
||||
code = unzGoToFirstFile(unz);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
code = unzGoToNextFile(unz);
|
||||
}
|
||||
i++;
|
||||
|
||||
if (code == UNZ_END_OF_LIST_OF_FILE) {
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
unz_file_pos pos;
|
||||
unzGetFilePos(unz, &pos);
|
||||
}
|
||||
|
||||
unz_file_info_s * fileInfo = _getFileInfo(unz);
|
||||
unz_file_info_s* fileInfo = _getFileInfo(unz);
|
||||
|
||||
std::string fileName = destination;
|
||||
fileName += _getFullFileName(unz, fileInfo);
|
||||
|
@ -16,9 +16,9 @@ typedef struct {
|
||||
bool initialized;
|
||||
|
||||
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;
|
||||
|
||||
static bool g_usbCommsInitialized = false;
|
||||
@ -29,13 +29,13 @@ static bool g_usbCommsErrorHandling = 0;
|
||||
|
||||
static RwLock g_usbCommsLock;
|
||||
|
||||
static Result _usbCommsInterfaceInit1x(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 _usbCommsInterfaceInit1x(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 _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) {
|
||||
desc->bInterfaceClass = info->bInterfaceClass;
|
||||
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;
|
||||
rwlockWriteLock(&g_usbCommsLock);
|
||||
|
||||
if (g_usbCommsInitialized) {
|
||||
rc = MAKERESULT(Module_Libnx, LibnxError_AlreadyInitialized);
|
||||
} else if (num_interfaces > TOTAL_INTERFACES) {
|
||||
}
|
||||
else if (num_interfaces > TOTAL_INTERFACES) {
|
||||
rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
rc = usbDsInitialize();
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (hosversionAtLeast(5,0,0)) {
|
||||
if (hosversionAtLeast(5, 0, 0)) {
|
||||
u8 iManufacturer, iProduct, iSerialNumber;
|
||||
static const u16 supported_langs[1] = {0x0409};
|
||||
static const u16 supported_langs[1] = { 0x0409 };
|
||||
// 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
|
||||
if (R_SUCCEEDED(rc)) rc = usbDsAddUsbStringDescriptor(&iManufacturer, "Nintendo");
|
||||
// Send product
|
||||
@ -122,7 +124,7 @@ Result awoo_usbCommsInitializeEx(u32 num_interfaces, const awoo_UsbCommsInterfac
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
for (u32 i = 0; i < num_interfaces; i++) {
|
||||
usbCommsInterface *intf = &g_usbCommsInterfaces[i];
|
||||
usbCommsInterface* intf = &g_usbCommsInterfaces[i];
|
||||
rwlockWriteLock(&intf->lock);
|
||||
rwlockWriteLock(&intf->lock_in);
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -161,7 +163,7 @@ Result awoo_usbCommsInitialize(void)
|
||||
return awoo_usbCommsInitializeEx(1, NULL);
|
||||
}
|
||||
|
||||
static void _usbCommsInterfaceFree(usbCommsInterface *interface)
|
||||
static void _usbCommsInterfaceFree(usbCommsInterface* interface)
|
||||
{
|
||||
rwlockWriteLock(&interface->lock);
|
||||
if (!interface->initialized) {
|
||||
@ -201,25 +203,26 @@ void awoo_usbCommsExit(void)
|
||||
|
||||
rwlockWriteUnlock(&g_usbCommsLock);
|
||||
|
||||
for (i=0; i<TOTAL_INTERFACES; i++)
|
||||
for (i = 0; i < TOTAL_INTERFACES; 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);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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;
|
||||
usbCommsInterface *interface = &g_usbCommsInterfaces[intf_ind];
|
||||
usbCommsInterface* interface = &g_usbCommsInterfaces[intf_ind];
|
||||
|
||||
struct usb_interface_descriptor interface_descriptor = {
|
||||
.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.
|
||||
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)) {
|
||||
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)) {
|
||||
@ -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;
|
||||
usbCommsInterface *interface = &g_usbCommsInterfaces[intf_ind];
|
||||
usbCommsInterface* interface = &g_usbCommsInterfaces[intf_ind];
|
||||
|
||||
struct usb_interface_descriptor interface_descriptor = {
|
||||
.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.
|
||||
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)) {
|
||||
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)) {
|
||||
@ -397,32 +400,32 @@ void awoo_usbCommsSetErrorHandling(bool 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;
|
||||
u32 urbId=0;
|
||||
u8 *bufptr = (u8*)buffer;
|
||||
u8 *transfer_buffer = NULL;
|
||||
u8 transfer_type=0;
|
||||
u32 chunksize=0;
|
||||
Result rc = 0;
|
||||
u32 urbId = 0;
|
||||
u8* bufptr = (u8*)buffer;
|
||||
u8* transfer_buffer = NULL;
|
||||
u8 transfer_type = 0;
|
||||
u32 chunksize = 0;
|
||||
u32 tmp_transferredSize = 0;
|
||||
size_t total_transferredSize=0;
|
||||
size_t total_transferredSize = 0;
|
||||
UsbDsReportData reportdata;
|
||||
|
||||
//Makes sure endpoints are ready for data-transfer / wait for init if needed.
|
||||
rc = usbDsWaitReady(timeout);
|
||||
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;
|
||||
memset(interface->endpoint_out_buffer, 0, 0x1000);
|
||||
|
||||
chunksize = 0x1000;
|
||||
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;
|
||||
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;
|
||||
|
||||
transfer_type = 0;
|
||||
}
|
||||
@ -455,13 +458,13 @@ static Result _usbCommsRead(usbCommsInterface *interface, void* buffer, size_t s
|
||||
if (R_FAILED(rc)) return rc;
|
||||
|
||||
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);
|
||||
bufptr+= tmp_transferredSize;
|
||||
size-= tmp_transferredSize;
|
||||
if (transfer_type == 0) memcpy(bufptr, transfer_buffer, tmp_transferredSize);
|
||||
bufptr += tmp_transferredSize;
|
||||
size -= tmp_transferredSize;
|
||||
|
||||
if(tmp_transferredSize < chunksize)break;
|
||||
if (tmp_transferredSize < chunksize)break;
|
||||
}
|
||||
|
||||
if (transferredSize) *transferredSize = total_transferredSize;
|
||||
@ -469,31 +472,31 @@ static Result _usbCommsRead(usbCommsInterface *interface, void* buffer, size_t s
|
||||
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;
|
||||
u32 urbId=0;
|
||||
u32 chunksize=0;
|
||||
u8 *bufptr = (u8*)buffer;
|
||||
u8 *transfer_buffer = NULL;
|
||||
Result rc = 0;
|
||||
u32 urbId = 0;
|
||||
u32 chunksize = 0;
|
||||
u8* bufptr = (u8*)buffer;
|
||||
u8* transfer_buffer = NULL;
|
||||
u32 tmp_transferredSize = 0;
|
||||
size_t total_transferredSize=0;
|
||||
size_t total_transferredSize = 0;
|
||||
UsbDsReportData reportdata;
|
||||
|
||||
//Makes sure endpoints are ready for data-transfer / wait for init if needed.
|
||||
rc = usbDsWaitReady(timeout);
|
||||
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;
|
||||
memset(interface->endpoint_in_buffer, 0, 0x1000);
|
||||
|
||||
chunksize = 0x1000;
|
||||
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;
|
||||
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;
|
||||
|
||||
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.
|
||||
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.
|
||||
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;
|
||||
|
||||
total_transferredSize+= (size_t)tmp_transferredSize;
|
||||
total_transferredSize += (size_t)tmp_transferredSize;
|
||||
|
||||
bufptr+= tmp_transferredSize;
|
||||
size-= tmp_transferredSize;
|
||||
bufptr += tmp_transferredSize;
|
||||
size -= tmp_transferredSize;
|
||||
|
||||
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 transferredSize=0;
|
||||
size_t transferredSize = 0;
|
||||
Result rc;
|
||||
usbCommsInterface *inter = &g_usbCommsInterfaces[interface];
|
||||
usbCommsInterface* inter = &g_usbCommsInterfaces[interface];
|
||||
bool initialized;
|
||||
|
||||
if (interface>=TOTAL_INTERFACES) return 0;
|
||||
if (interface >= TOTAL_INTERFACES) return 0;
|
||||
|
||||
rwlockReadLock(&inter->lock);
|
||||
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 transferredSize=0;
|
||||
size_t transferredSize = 0;
|
||||
Result rc;
|
||||
usbCommsInterface *inter = &g_usbCommsInterfaces[interface];
|
||||
usbCommsInterface* inter = &g_usbCommsInterfaces[interface];
|
||||
bool initialized;
|
||||
|
||||
if (interface>=TOTAL_INTERFACES) return 0;
|
||||
if (interface >= TOTAL_INTERFACES) return 0;
|
||||
|
||||
rwlockReadLock(&inter->lock);
|
||||
initialized = inter->initialized;
|
||||
|
@ -88,7 +88,7 @@ namespace tin::util
|
||||
|
||||
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 tmpsize = 0;
|
||||
|
||||
|
@ -18,20 +18,20 @@
|
||||
#include "util/json.hpp"
|
||||
|
||||
namespace inst::util {
|
||||
void initApp () {
|
||||
void initApp() {
|
||||
// Seethe
|
||||
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);
|
||||
inst::config::parseConfig();
|
||||
|
||||
socketInitializeDefault();
|
||||
#ifdef __DEBUG__
|
||||
#ifdef __DEBUG__
|
||||
nxlinkStdio();
|
||||
#endif
|
||||
#endif
|
||||
awoo_usbCommsInitialize();
|
||||
}
|
||||
|
||||
void deinitApp () {
|
||||
void deinitApp() {
|
||||
socketExit();
|
||||
awoo_usbCommsExit();
|
||||
}
|
||||
@ -52,19 +52,19 @@ namespace inst::util {
|
||||
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 {
|
||||
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) {
|
||||
return std::lexicographical_compare(a.begin(), a.end() , b.begin() ,b.end() , caseInsensitiveLess());
|
||||
bool ignoreCaseCompare(const std::string& a, const std::string& b) {
|
||||
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;
|
||||
for(auto & p: std::filesystem::directory_iterator(dir))
|
||||
for (auto& p : std::filesystem::directory_iterator(dir))
|
||||
{
|
||||
if (std::filesystem::is_regular_file(p))
|
||||
{
|
||||
@ -80,9 +80,9 @@ namespace inst::util {
|
||||
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;
|
||||
for(auto & p: std::filesystem::directory_iterator(dir))
|
||||
for (auto& p : std::filesystem::directory_iterator(dir))
|
||||
{
|
||||
if (std::filesystem::is_directory(p))
|
||||
{
|
||||
@ -95,7 +95,7 @@ namespace inst::util {
|
||||
|
||||
bool removeDirectory(std::string dir) {
|
||||
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))
|
||||
{
|
||||
@ -105,7 +105,7 @@ namespace inst::util {
|
||||
rmdir(dir.c_str());
|
||||
return true;
|
||||
}
|
||||
catch (std::filesystem::filesystem_error & e) {
|
||||
catch (std::filesystem::filesystem_error& e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -115,9 +115,9 @@ namespace inst::util {
|
||||
std::ifstream f1(inFile);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -126,11 +126,11 @@ namespace inst::util {
|
||||
std::string segment;
|
||||
std::vector<std::string> seglist;
|
||||
|
||||
while(std::getline(ourStream, segment, '/')) {
|
||||
while (std::getline(ourStream, segment, '/')) {
|
||||
seglist.push_back(segment);
|
||||
}
|
||||
|
||||
CURL *curl = curl_easy_init();
|
||||
CURL* curl = curl_easy_init();
|
||||
int outlength;
|
||||
std::string finalString = curl_easy_unescape(curl, seglist[seglist.size() - 1].c_str(), seglist[seglist.size() - 1].length(), &outlength);
|
||||
curl_easy_cleanup(curl);
|
||||
@ -138,7 +138,7 @@ namespace inst::util {
|
||||
return finalString;
|
||||
}
|
||||
|
||||
std::string formatUrlLink(std::string ourString){
|
||||
std::string formatUrlLink(std::string ourString) {
|
||||
std::string::size_type pos = ourString.find('/');
|
||||
if (pos != std::string::npos)
|
||||
return ourString.substr(0, pos);
|
||||
@ -150,14 +150,15 @@ namespace inst::util {
|
||||
std::filesystem::path ourStringAsAPath = ourString;
|
||||
std::string ourExtension = ourStringAsAPath.extension().string();
|
||||
if (ourString.size() - ourExtension.size() > (unsigned long)ourLength) {
|
||||
if(isFile) return (std::string)ourString.substr(0,ourLength) + "(...)" + ourExtension;
|
||||
else return (std::string)ourString.substr(0,ourLength) + "...";
|
||||
} else return ourString;
|
||||
if (isFile) return (std::string)ourString.substr(0, ourLength) + "(...)" + ourExtension;
|
||||
else return (std::string)ourString.substr(0, ourLength) + "...";
|
||||
}
|
||||
else return ourString;
|
||||
}
|
||||
|
||||
std::string readTextFromFile(std::string ourFile) {
|
||||
if (std::filesystem::exists(ourFile)) {
|
||||
FILE * file = fopen(ourFile.c_str(), "r");
|
||||
FILE* file = fopen(ourFile.c_str(), "r");
|
||||
char line[1024];
|
||||
fgets(line, 1024, file);
|
||||
std::string url = line;
|
||||
@ -169,9 +170,9 @@ namespace inst::util {
|
||||
}
|
||||
|
||||
std::string softwareKeyboard(std::string guideText, std::string initialText, int LenMax) {
|
||||
Result rc=0;
|
||||
Result rc = 0;
|
||||
SwkbdConfig kbd;
|
||||
char tmpoutstr[LenMax + 1] = {0};
|
||||
char tmpoutstr[LenMax + 1] = { 0 };
|
||||
rc = swkbdCreate(&kbd, 0);
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
swkbdConfigMakePresetDefault(&kbd);
|
||||
@ -203,10 +204,10 @@ namespace inst::util {
|
||||
uint32_t hz = 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)) {
|
||||
ClkrstSession session = {0};
|
||||
if (hosversionAtLeast(8, 0, 0)) {
|
||||
ClkrstSession session = { 0 };
|
||||
PcvModuleId pcvModuleId;
|
||||
pcvInitialize();
|
||||
clkrstInitialize();
|
||||
@ -232,8 +233,9 @@ namespace inst::util {
|
||||
clkrstCloseSession(&session);
|
||||
clkrstExit();
|
||||
|
||||
return {previousHz, hz};
|
||||
} else {
|
||||
return { previousHz, hz };
|
||||
}
|
||||
else {
|
||||
PcvModule pcvModule;
|
||||
pcvInitialize();
|
||||
|
||||
@ -255,12 +257,12 @@ namespace inst::util {
|
||||
|
||||
pcvExit();
|
||||
|
||||
return {previousHz, hz};
|
||||
return { previousHz, hz };
|
||||
}
|
||||
}
|
||||
|
||||
std::string getIPAddress() {
|
||||
struct in_addr addr = {(in_addr_t) gethostid()};
|
||||
struct in_addr addr = { (in_addr_t)gethostid() };
|
||||
return inet_ntoa(addr);
|
||||
}
|
||||
|
||||
@ -276,24 +278,24 @@ namespace inst::util {
|
||||
int audio_channels = 2;
|
||||
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());
|
||||
if(sound == NULL) {
|
||||
if (sound == NULL) {
|
||||
Mix_FreeChunk(sound);
|
||||
Mix_CloseAudio();
|
||||
return;
|
||||
}
|
||||
|
||||
int channel = Mix_PlayChannel(-1, sound, 0);
|
||||
if(channel == -1) {
|
||||
if (channel == -1) {
|
||||
Mix_FreeChunk(sound);
|
||||
Mix_CloseAudio();
|
||||
return;
|
||||
}
|
||||
|
||||
while(Mix_Playing(channel) != 0);
|
||||
while (Mix_Playing(channel) != 0);
|
||||
|
||||
Mix_FreeChunk(sound);
|
||||
Mix_CloseAudio();
|
||||
@ -301,17 +303,18 @@ namespace inst::util {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> checkForAppUpdate () {
|
||||
std::vector<std::string> checkForAppUpdate() {
|
||||
try {
|
||||
std::string jsonData = inst::curl::downloadToBuffer("https://api.github.com/repos/Huntereb/Awoo-Installer/releases/latest", 0, 0, 1000L);
|
||||
if (jsonData.size() == 0) return {};
|
||||
nlohmann::json ourJson = nlohmann::json::parse(jsonData);
|
||||
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;
|
||||
return ourUpdateInfo;
|
||||
}
|
||||
} catch (...) {}
|
||||
}
|
||||
catch (...) {}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user