From b07e9efba4e9c1f952f14c99ebd529f71bfe630b Mon Sep 17 00:00:00 2001 From: MythicalPlayz <57963367+MythicalPlayz@users.noreply.github.com> Date: Tue, 11 Oct 2022 04:04:47 +0200 Subject: [PATCH] Add support for choosing network service (incl Pretendo+Custom) (#302) --- .gitignore | 1 + src/Cafe/IOSU/legacy/iosu_boss.cpp | 22 ++++++++- src/Cemu/napi/napi_ec.cpp | 67 ++++++++++++++++++++++++-- src/Cemu/napi/napi_helper.cpp | 12 +++-- src/Cemu/napi/napi_idbe.cpp | 35 +++++++++++++- src/Cemu/napi/napi_version.cpp | 19 +++++++- src/config/ActiveSettings.cpp | 6 ++- src/config/ActiveSettings.h | 3 +- src/config/CMakeLists.txt | 2 + src/config/CemuConfig.cpp | 4 +- src/config/CemuConfig.h | 1 + src/config/LaunchSettings.cpp | 24 ++++++++++ src/config/LaunchSettings.h | 5 +- src/config/NetworkSettings.cpp | 43 +++++++++++++++++ src/config/NetworkSettings.h | 77 ++++++++++++++++++++++++++++++ src/gui/GeneralSettings2.cpp | 23 +++++++++ src/gui/GeneralSettings2.h | 2 + src/gui/guiWrapper.cpp | 14 +++++- src/main.cpp | 7 ++- 19 files changed, 345 insertions(+), 22 deletions(-) create mode 100644 src/config/NetworkSettings.cpp create mode 100644 src/config/NetworkSettings.h diff --git a/.gitignore b/.gitignore index 293864a8..e252f4cb 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ bin/Cemu_*.ilk bin/Cemu.exe.backup bin/mlc01/* bin/settings.xml +bin/network_services.xml bin/title_list_cache.xml bin/debugger/* bin/sdcard/* diff --git a/src/Cafe/IOSU/legacy/iosu_boss.cpp b/src/Cafe/IOSU/legacy/iosu_boss.cpp index 7280ac53..d93d7284 100644 --- a/src/Cafe/IOSU/legacy/iosu_boss.cpp +++ b/src/Cafe/IOSU/legacy/iosu_boss.cpp @@ -10,6 +10,7 @@ #include #include "config/ActiveSettings.h" +#include "config/NetworkSettings.h" #include "curl/curl.h" #include "openssl/bn.h" #include "openssl/x509.h" @@ -497,9 +498,13 @@ namespace iosu curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, task_header_callback); curl_easy_setopt(curl, CURLOPT_HEADERDATA, &(*it)); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 0x3C); + if (GetNetworkConfig().disablesslver.GetValue() && ActiveSettings::GetNetworkService() == NetworkService::Custom || ActiveSettings::GetNetworkService() == NetworkService::Pretendo){ //Remove Pretendo Function once SSL is in the Service + curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,0L); + } else { curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, task_sslctx_function); curl_easy_setopt(curl, CURLOPT_SSL_CTX_DATA, &it->task_settings); curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_0); + } char url[512]; if(it->task_settings.taskType == kRawDlTaskSetting) @@ -561,8 +566,21 @@ namespace iosu char boss_code[0x20]; strncpy(boss_code, (char*)&it->task_settings.settings[TaskSetting::kBossCode], TaskSetting::kBossCodeLen); - - sprintf(url, "https://npts.app.nintendo.net/p01/tasksheet/%s/%s/%s?c=%s&l=%s", "1", boss_code, it->task_id, countryCode, languageCode); + switch (ActiveSettings::GetNetworkService()) + { + case NetworkService::Nintendo: + sprintf(url, NintendoURLs::BOSSURL.append("/%s/%s/%s?c=%s&l=%s").c_str(), "1", boss_code, it->task_id, countryCode, languageCode); + break; + case NetworkService::Pretendo: + sprintf(url, PretendoURLs::BOSSURL.append("/%s/%s/%s?c=%s&l=%s").c_str(), "1", boss_code, it->task_id, countryCode, languageCode); + break; + case NetworkService::Custom: + sprintf(url, GetNetworkConfig().urls.BOSS.GetValue().append("/%s/%s/%s?c=%s&l=%s").c_str(), "1", boss_code, it->task_id, countryCode, languageCode); + break; + default: + sprintf(url, NintendoURLs::BOSSURL.append("/%s/%s/%s?c=%s&l=%s").c_str(), "1", boss_code, it->task_id, countryCode, languageCode); + break; + } } curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list_headerParam); diff --git a/src/Cemu/napi/napi_ec.cpp b/src/Cemu/napi/napi_ec.cpp index 2d559e81..c355da4f 100644 --- a/src/Cemu/napi/napi_ec.cpp +++ b/src/Cemu/napi/napi_ec.cpp @@ -8,7 +8,8 @@ #include "Cemu/ncrypto/ncrypto.h" #include "util/crypto/md5.h" #include "config/LaunchSettings.h" - +#include "config/ActiveSettings.h" +#include "config/NetworkSettings.h" #include "pugixml.hpp" #include @@ -26,14 +27,42 @@ namespace NAPI { if (!s_serviceURL_NusURL.empty()) return s_serviceURL_NusURL; - return "https://nus.wup.shop.nintendo.net/nus/services/NetUpdateSOAP"; + switch (ActiveSettings::GetNetworkService()) + { + case NetworkService::Nintendo: + return NintendoURLs::NUSURL; + break; + case NetworkService::Pretendo: + return PretendoURLs::NUSURL; + break; + case NetworkService::Custom: + return GetNetworkConfig().urls.NUS; + break; + default: + return NintendoURLs::NUSURL; + break; + } } std::string _getIASUrl() { if (!s_serviceURL_IasURL.empty()) return s_serviceURL_IasURL; - return "https://ias.wup.shop.nintendo.net/ias/services/IdentityAuthenticationSOAP"; + switch (ActiveSettings::GetNetworkService()) + { + case NetworkService::Nintendo: + return NintendoURLs::IASURL; + break; + case NetworkService::Pretendo: + return PretendoURLs::IASURL; + break; + case NetworkService::Custom: + return GetNetworkConfig().urls.IAS; + break; + default: + return NintendoURLs::IASURL; + break; + } } std::string _getECSUrl() @@ -48,14 +77,42 @@ namespace NAPI { if (!s_serviceURL_UncachedContentPrefixURL.empty()) return s_serviceURL_UncachedContentPrefixURL; - return "https://ccs.wup.shop.nintendo.net/ccs/download"; + switch (ActiveSettings::GetNetworkService()) + { + case NetworkService::Nintendo: + return NintendoURLs::CCSUURL; + break; + case NetworkService::Pretendo: + return PretendoURLs::CCSUURL; + break; + case NetworkService::Custom: + return GetNetworkConfig().urls.CCSU; + break; + default: + return NintendoURLs::CCSUURL; + break; + } } std::string _getCCSUrl() // used for game data downloads { if (!s_serviceURL_ContentPrefixURL.empty()) return s_serviceURL_ContentPrefixURL; - return "http://ccs.cdn.wup.shop.nintendo.net/ccs/download"; + switch (ActiveSettings::GetNetworkService()) + { + case NetworkService::Nintendo: + return NintendoURLs::CCSURL; + break; + case NetworkService::Pretendo: + return PretendoURLs::CCSURL; + break; + case NetworkService::Custom: + return GetNetworkConfig().urls.CCS; + break; + default: + return NintendoURLs::CCSURL; + break; + } } /* NUS */ diff --git a/src/Cemu/napi/napi_helper.cpp b/src/Cemu/napi/napi_helper.cpp index 188c8840..016fc597 100644 --- a/src/Cemu/napi/napi_helper.cpp +++ b/src/Cemu/napi/napi_helper.cpp @@ -7,7 +7,9 @@ #include "Cemu/ncrypto/ncrypto.h" #include "napi_helper.h" #include "util/highresolutiontimer/HighResolutionTimer.h" - +#include "config/ActiveSettings.h" +#include "config/NetworkSettings.h" +#include "config/LaunchSettings.h" #include "pugixml.hpp" #include @@ -97,7 +99,10 @@ void CurlRequestHelper::initate(std::string url, SERVER_SSL_CONTEXT sslContext) curl_easy_setopt(m_curl, CURLOPT_TIMEOUT, 60); // SSL - if (sslContext == SERVER_SSL_CONTEXT::ACT || sslContext == SERVER_SSL_CONTEXT::TAGAYA) + if (GetNetworkConfig().disablesslver.GetValue() && ActiveSettings::GetNetworkService() == NetworkService::Custom || ActiveSettings::GetNetworkService() == NetworkService::Pretendo){ //Remove once Pretendo has SSL + curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYPEER, 0L); + } + else if (sslContext == SERVER_SSL_CONTEXT::ACT || sslContext == SERVER_SSL_CONTEXT::TAGAYA) { curl_easy_setopt(m_curl, CURLOPT_SSL_CTX_FUNCTION, _sslctx_function_NUS); curl_easy_setopt(m_curl, CURLOPT_SSL_CTX_DATA, NULL); @@ -219,9 +224,10 @@ CurlSOAPHelper::CurlSOAPHelper() curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, this); // SSL + if (!GetNetworkConfig().disablesslver.GetValue() && ActiveSettings::GetNetworkService() != NetworkService::Pretendo && ActiveSettings::GetNetworkService() != NetworkService::Custom) { //Remove once Pretendo has SSL curl_easy_setopt(m_curl, CURLOPT_SSL_CTX_FUNCTION, _sslctx_function_SOAP); curl_easy_setopt(m_curl, CURLOPT_SSL_CTX_DATA, NULL); - + } if(GetConfig().proxy_server.GetValue() != "") { curl_easy_setopt(m_curl, CURLOPT_PROXY, GetConfig().proxy_server.GetValue().c_str()); diff --git a/src/Cemu/napi/napi_idbe.cpp b/src/Cemu/napi/napi_idbe.cpp index 90c9c2f2..6832bf73 100644 --- a/src/Cemu/napi/napi_idbe.cpp +++ b/src/Cemu/napi/napi_idbe.cpp @@ -10,6 +10,8 @@ #include "openssl/sha.h" #include "util/crypto/aes128.h" #include "util/helpers/StringHelpers.h" +#include "config/ActiveSettings.h" +#include "config/NetworkSettings.h" namespace NAPI { @@ -55,7 +57,21 @@ namespace NAPI std::vector IDBE_RequestRawEncrypted(uint64 titleId) { CurlRequestHelper req; - req.initate(fmt::format("https://idbe-wup.cdn.nintendo.net/icondata/{0:02X}/{1:016X}.idbe", (uint32)((titleId >> 8) & 0xFF), titleId), CurlRequestHelper::SERVER_SSL_CONTEXT::IDBE); + switch (ActiveSettings::GetNetworkService()) + { + case NetworkService::Nintendo: + req.initate(fmt::format(fmt::runtime(NintendoURLs::IDBEURL + "/{0:02X}/{1:016X}.idbe"), (uint32)((titleId >> 8) & 0xFF), titleId), CurlRequestHelper::SERVER_SSL_CONTEXT::IDBE); + break; + case NetworkService::Pretendo: + req.initate(fmt::format(fmt::runtime(PretendoURLs::IDBEURL + "/{0:02X}/{1:016X}.idbe"), (uint32)((titleId >> 8) & 0xFF), titleId), CurlRequestHelper::SERVER_SSL_CONTEXT::IDBE); + break; + case NetworkService::Custom: + req.initate(fmt::format(fmt::runtime(GetNetworkConfig().urls.IDBE.GetValue() + "/{0:02X}/{1:016X}.idbe"), (uint32)((titleId >> 8) & 0xFF), titleId), CurlRequestHelper::SERVER_SSL_CONTEXT::IDBE); + break; + default: + req.initate(fmt::format(fmt::runtime(NintendoURLs::IDBEURL + "/{0:02X}/{1:016X}.idbe"), (uint32)((titleId >> 8) & 0xFF), titleId), CurlRequestHelper::SERVER_SSL_CONTEXT::IDBE); + break; + } if (!req.submitRequest(false)) { cemuLog_log(LogType::Force, fmt::format("Failed to request IDBE icon for title {0:016X}", titleId)); @@ -84,7 +100,22 @@ namespace NAPI } CurlRequestHelper req; - req.initate(fmt::format("https://idbe-wup.cdn.nintendo.net/icondata/{0:02X}/{1:016X}.idbe", (uint32)((titleId >> 8) & 0xFF), titleId), CurlRequestHelper::SERVER_SSL_CONTEXT::IDBE); + switch (ActiveSettings::GetNetworkService()) + { + case NetworkService::Nintendo: + req.initate(fmt::format(fmt::runtime(NintendoURLs::IDBEURL + "/{0:02X}/{1:016X}.idbe"), (uint32)((titleId >> 8) & 0xFF), titleId), CurlRequestHelper::SERVER_SSL_CONTEXT::IDBE); + break; + case NetworkService::Pretendo: + req.initate(fmt::format(fmt::runtime(PretendoURLs::IDBEURL + "/{0:02X}/{1:016X}.idbe"), (uint32)((titleId >> 8) & 0xFF), titleId), CurlRequestHelper::SERVER_SSL_CONTEXT::IDBE); + break; + case NetworkService::Custom: + req.initate(fmt::format(fmt::runtime(GetNetworkConfig().urls.IDBE.GetValue() + "/{0:02X}/{1:016X}.idbe"), (uint32)((titleId >> 8) & 0xFF), titleId), CurlRequestHelper::SERVER_SSL_CONTEXT::IDBE); + break; + default: + req.initate(fmt::format(fmt::runtime(NintendoURLs::IDBEURL + "/{0:02X}/{1:016X}.idbe"), (uint32)((titleId >> 8) & 0xFF), titleId), CurlRequestHelper::SERVER_SSL_CONTEXT::IDBE); + break; + } + if (!req.submitRequest(false)) { cemuLog_log(LogType::Force, fmt::format("Failed to request IDBE icon for title {0:016X}", titleId)); diff --git a/src/Cemu/napi/napi_version.cpp b/src/Cemu/napi/napi_version.cpp index f1c1b171..73dd68cf 100644 --- a/src/Cemu/napi/napi_version.cpp +++ b/src/Cemu/napi/napi_version.cpp @@ -7,6 +7,8 @@ #include "Cemu/ncrypto/ncrypto.h" #include +#include "config/ActiveSettings.h" +#include "config/NetworkSettings.h" namespace NAPI { @@ -14,7 +16,22 @@ namespace NAPI { NAPI_VersionListVersion_Result result; CurlRequestHelper req; - req.initate(fmt::format("https://tagaya.wup.shop.nintendo.net/tagaya/versionlist/{}/{}/latest_version", NCrypto::GetRegionAsString(authInfo.region), authInfo.country), CurlRequestHelper::SERVER_SSL_CONTEXT::TAGAYA); + switch (ActiveSettings::GetNetworkService()) + { + case NetworkService::Nintendo: + req.initate(fmt::format(fmt::runtime(NintendoURLs::TAGAYAURL + "/{}/{}/latest_version"), NCrypto::GetRegionAsString(authInfo.region), authInfo.country), CurlRequestHelper::SERVER_SSL_CONTEXT::TAGAYA); + break; + case NetworkService::Pretendo: + req.initate(fmt::format(fmt::runtime(PretendoURLs::TAGAYAURL + "/{}/{}/latest_version"), NCrypto::GetRegionAsString(authInfo.region), authInfo.country), CurlRequestHelper::SERVER_SSL_CONTEXT::TAGAYA); + break; + case NetworkService::Custom: + req.initate(fmt::format(fmt::runtime(GetNetworkConfig().urls.TAGAYA.GetValue() + "/{}/{}/latest_version"), NCrypto::GetRegionAsString(authInfo.region), authInfo.country), CurlRequestHelper::SERVER_SSL_CONTEXT::TAGAYA); + break; + default: + req.initate(fmt::format(fmt::runtime(NintendoURLs::TAGAYAURL + "/{}/{}/latest_version"), NCrypto::GetRegionAsString(authInfo.region), authInfo.country), CurlRequestHelper::SERVER_SSL_CONTEXT::TAGAYA); + break; + } + if (!req.submitRequest(false)) { cemuLog_log(LogType::Force, fmt::format("Failed to request version of update list")); diff --git a/src/config/ActiveSettings.cpp b/src/config/ActiveSettings.cpp index c7ff4fe6..16119725 100644 --- a/src/config/ActiveSettings.cpp +++ b/src/config/ActiveSettings.cpp @@ -20,7 +20,7 @@ void ActiveSettings::LoadOnce() g_config.SetFilename(GetPath("settings.xml").generic_wstring()); g_config.Load(); - + LaunchSettings::ChangeNetworkServiceURL(GetConfig().account.active_service); std::wstring additionalErrorInfo; s_has_required_online_files = iosuCrypt_checkRequirementsForOnlineMode(additionalErrorInfo) == IOS_CRYPTO_ONLINE_REQ_OK; } @@ -121,6 +121,10 @@ bool ActiveSettings::HasRequiredOnlineFiles() return s_has_required_online_files; } +NetworkService ActiveSettings::GetNetworkService() { + return static_cast(GetConfig().account.active_service.GetValue()); +} + bool ActiveSettings::DumpShadersEnabled() { return s_dump_shaders; diff --git a/src/config/ActiveSettings.h b/src/config/ActiveSettings.h index 69f6d34a..ae3feb94 100644 --- a/src/config/ActiveSettings.h +++ b/src/config/ActiveSettings.h @@ -1,6 +1,7 @@ #pragma once #include "config/CemuConfig.h" +#include "config/NetworkSettings.h" // global active settings for fast access (reflects settings from command line and game profile) class ActiveSettings @@ -92,7 +93,7 @@ public: [[nodiscard]] static uint32 GetPersistentId(); [[nodiscard]] static bool IsOnlineEnabled(); [[nodiscard]] static bool HasRequiredOnlineFiles(); - + [[nodiscard]] static NetworkService GetNetworkService(); // dump options [[nodiscard]] static bool DumpShadersEnabled(); [[nodiscard]] static bool DumpTexturesEnabled(); diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt index c329d58b..f02b95d4 100644 --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -6,6 +6,8 @@ add_library(CemuConfig ConfigValue.h LaunchSettings.cpp LaunchSettings.h + NetworkSettings.cpp + NetworkSettings.h PermanentConfig.cpp PermanentConfig.h PermanentStorage.cpp diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index b257ead3..84324418 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -322,7 +322,7 @@ void CemuConfig::Load(XMLConfigParser& parser) auto acc = parser.get("Account"); account.m_persistent_id = acc.get("PersistentId", account.m_persistent_id); account.online_enabled = acc.get("OnlineEnabled", account.online_enabled); - + account.active_service = acc.get("ActiveService",account.active_service); // debug auto debug = parser.get("Debug"); #if BOOST_OS_WINDOWS @@ -497,7 +497,7 @@ void CemuConfig::Save(XMLConfigParser& parser) auto acc = config.set("Account"); acc.set("PersistentId", account.m_persistent_id.GetValue()); acc.set("OnlineEnabled", account.online_enabled.GetValue()); - + acc.set("ActiveService",account.active_service.GetValue()); // debug auto debug = config.set("Debug"); #if BOOST_OS_WINDOWS diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index e7cb1ca5..0dc0843b 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -471,6 +471,7 @@ struct CemuConfig { ConfigValueBounds m_persistent_id{ Account::kMinPersistendId, Account::kMinPersistendId, 0xFFFFFFFF }; ConfigValue online_enabled{false}; + ConfigValue active_service{0}; }account{}; // input diff --git a/src/config/LaunchSettings.cpp b/src/config/LaunchSettings.cpp index 7d7c0c98..06d9a5a3 100644 --- a/src/config/LaunchSettings.cpp +++ b/src/config/LaunchSettings.cpp @@ -9,6 +9,7 @@ #include #include "config/ActiveSettings.h" +#include "config/NetworkSettings.h" #include "util/crypto/aes128.h" #include "Cafe/Filesystem/FST/FST.h" @@ -265,3 +266,26 @@ bool LaunchSettings::ExtractorTool(std::wstring_view wud_path, std::string_view } +void LaunchSettings::ChangeNetworkServiceURL(int ID){ + NetworkService Network = static_cast(ID); + switch (Network) + { + case NetworkService::Nintendo: + serviceURL_ACT = NintendoURLs::ACTURL; + serviceURL_ECS = NintendoURLs::ECSURL; + break; + case NetworkService::Pretendo: + serviceURL_ACT = PretendoURLs::ACTURL; + serviceURL_ECS = PretendoURLs::ECSURL; + break; + case NetworkService::Custom: + serviceURL_ACT = GetNetworkConfig().urls.ACT.GetValue(); + serviceURL_ECS = GetNetworkConfig().urls.ECS.GetValue(); + break; + default: + serviceURL_ACT = NintendoURLs::ACTURL; + serviceURL_ECS = NintendoURLs::ECSURL; + break; + } + +} \ No newline at end of file diff --git a/src/config/LaunchSettings.h b/src/config/LaunchSettings.h index 299dd72c..b42523ca 100644 --- a/src/config/LaunchSettings.h +++ b/src/config/LaunchSettings.h @@ -30,6 +30,7 @@ public: static std::string GetActURLPrefix() { return serviceURL_ACT; } static std::string GetServiceURL_ecs() { return serviceURL_ECS; } + static void ChangeNetworkServiceURL(int ID); private: inline static std::optional s_load_game_file{}; @@ -46,8 +47,8 @@ private: inline static std::optional s_persistent_id{}; // service URLS - inline static std::string serviceURL_ACT = "https://account.nintendo.net"; - inline static std::string serviceURL_ECS = "https://ecs.wup.shop.nintendo.net/ecs/services/ECommerceSOAP"; + inline static std::string serviceURL_ACT; + inline static std::string serviceURL_ECS; // todo - npts and other boss urls diff --git a/src/config/NetworkSettings.cpp b/src/config/NetworkSettings.cpp new file mode 100644 index 00000000..f3a3b8b6 --- /dev/null +++ b/src/config/NetworkSettings.cpp @@ -0,0 +1,43 @@ +#include "NetworkSettings.h" +#include "LaunchSettings.h" +#include "CemuConfig.h" +#include +#include "Common/FileStream.h" +XMLNetworkConfig_t n_config(L"network_services.xml"); + +void NetworkConfig::LoadOnce() { + s_full_path = boost::dll::program_location().generic_wstring(); + s_path = s_full_path.parent_path(); + n_config.SetFilename(GetPath("network_services.xml").generic_wstring()); + if(XMLExists()) { + n_config.Load(); + } +} + +void NetworkConfig::Load(XMLConfigParser& parser){ + auto config = parser.get("content"); + networkname = config.get("networkname","[Nintendo]"); + disablesslver = config.get("disablesslverification",disablesslver); + auto u = config.get("urls"); + urls.ACT = u.get("act",NintendoURLs::ACTURL); + urls.ECS = u.get("ecs",NintendoURLs::ECSURL); + urls.NUS = u.get("nus",NintendoURLs::NUSURL); + urls.IAS = u.get("ias",NintendoURLs::IASURL); + urls.CCSU = u.get("ccsu",NintendoURLs::CCSUURL); + urls.CCS = u.get("ccs",NintendoURLs::CCSURL); + urls.IDBE = u.get("idbe",NintendoURLs::IDBEURL); + urls.BOSS = u.get("boss",NintendoURLs::BOSSURL); + urls.TAGAYA = u.get("tagaya",NintendoURLs::TAGAYAURL); + if (static_cast(GetConfig().account.active_service.GetValue()) == NetworkService::Custom) { + LaunchSettings::ChangeNetworkServiceURL(2); + } +} +bool NetworkConfig::XMLExists() { + if (!fs::exists(GetPath("network_services.xml"))) { + if (static_cast(GetConfig().account.active_service.GetValue()) == NetworkService::Custom) { + LaunchSettings::ChangeNetworkServiceURL(0); + GetConfig().account.active_service = 0; + } + return false; + } else {return true;} +} \ No newline at end of file diff --git a/src/config/NetworkSettings.h b/src/config/NetworkSettings.h new file mode 100644 index 00000000..e65da8ab --- /dev/null +++ b/src/config/NetworkSettings.h @@ -0,0 +1,77 @@ +#pragma once + +#include "ConfigValue.h" +#include "XMLConfig.h" + + +enum class NetworkService { +Nintendo, +Pretendo, +Custom, +}; +struct NetworkConfig { + NetworkConfig() + { + + }; + + NetworkConfig(const NetworkConfig&) = delete; + + ConfigValue networkname; + ConfigValue disablesslver = false; + struct + { + ConfigValue ACT; + ConfigValue ECS; + ConfigValue NUS; + ConfigValue IAS; + ConfigValue CCSU; + ConfigValue CCS; + ConfigValue IDBE; + ConfigValue BOSS; + ConfigValue TAGAYA; + }urls{}; + + public: + static void LoadOnce(); + void Load(XMLConfigParser& parser); + void Save(XMLConfigParser& parser); + + static bool XMLExists(); + private: + inline static fs::path s_path; + inline static fs::path s_full_path; + [[nodiscard]] static fs::path GetPath(std::string_view p) + { + std::basic_string_view s((const char8_t*)p.data(), p.size()); + return s_path / fs::path(s); + } +}; + +struct NintendoURLs { + inline static std::string ACTURL = "https://account.nintendo.net"; + inline static std::string ECSURL = "https://ecs.wup.shop.nintendo.net/ecs/services/ECommerceSOAP"; + inline static std::string NUSURL = "https://nus.wup.shop.nintendo.net/nus/services/NetUpdateSOAP"; + inline static std::string IASURL = "https://ias.wup.shop.nintendo.net/ias/services/IdentityAuthenticationSOAP"; + inline static std::string CCSUURL = "https://ccs.wup.shop.nintendo.net/ccs/download"; + inline static std::string CCSURL = "http://ccs.cdn.wup.shop.nintendo.net/ccs/download"; + inline static std::string IDBEURL = "https://idbe-wup.cdn.nintendo.net/icondata"; + inline static std::string BOSSURL = "https://npts.app.nintendo.net/p01/tasksheet"; + inline static std::string TAGAYAURL = "https://tagaya.wup.shop.nintendo.net/tagaya/versionlist"; +}; + +struct PretendoURLs { + inline static std::string ACTURL = "https://account.pretendo.cc"; + inline static std::string ECSURL = "https://ecs.wup.shop.pretendo.cc/ecs/services/ECommerceSOAP"; + inline static std::string NUSURL = "https://nus.c.shop.pretendo.cc/nus/services/NetUpdateSOAP"; + inline static std::string IASURL = "https://ias.c.shop.pretendo.cc/ias/services/IdentityAuthenticationSOAP"; + inline static std::string CCSUURL = "https://ccs.c.shop.pretendo.cc/ccs/download"; + inline static std::string CCSURL = "http://ccs.cdn.c.shop.pretendo.cc/ccs/download"; + inline static std::string IDBEURL = "https://idbe-wup.cdn.pretendo.cc/icondata"; + inline static std::string BOSSURL = "https://npts.app.pretendo.cc/p01/tasksheet"; + inline static std::string TAGAYAURL = "https://tagaya.wup.shop.pretendo.cc/tagaya/versionlist"; +}; + +typedef XMLDataConfig XMLNetworkConfig_t; +extern XMLNetworkConfig_t n_config; +inline NetworkConfig& GetNetworkConfig() { return n_config.data();}; \ No newline at end of file diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index 6c4f5bbb..ffb58e48 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -14,6 +14,7 @@ #include #include "config/CemuConfig.h" +#include "config/NetworkSettings.h" #include "audio/IAudioAPI.h" #if BOOST_OS_WINDOWS @@ -604,6 +605,18 @@ wxPanel* GeneralSettings2::AddAccountPage(wxNotebook* notebook) content->Add(m_delete_account, 0, wxEXPAND | wxALL | wxALIGN_RIGHT, 5); m_delete_account->Bind(wxEVT_BUTTON, &GeneralSettings2::OnAccountDelete, this); + if (NetworkConfig::XMLExists()) { + wxString choices[] = { _("Nintendo"), _("Pretendo"), _("Custom") }; + m_active_service= new wxRadioBox(online_panel, wxID_ANY, _("Network Service"), wxDefaultPosition, wxDefaultSize, std::size(choices), choices, 3, wxRA_SPECIFY_COLS); + } + else { + wxString choices[] = { _("Nintendo"), _("Pretendo") }; + m_active_service= new wxRadioBox(online_panel, wxID_ANY, _("Network Service"), wxDefaultPosition, wxDefaultSize, std::size(choices), choices, 2, wxRA_SPECIFY_COLS); + } + m_active_service->SetToolTip(_("Connect to which Network Service")); + m_active_service->Bind(wxEVT_RADIOBOX, &GeneralSettings2::OnAccountServiceChanged,this); + content->Add(m_active_service, 0, wxEXPAND | wxALL, 5); + box_sizer->Add(content, 1, wxEXPAND, 5); online_panel_sizer->Add(box_sizer, 0, wxEXPAND | wxALL, 5); @@ -613,6 +626,7 @@ wxPanel* GeneralSettings2::AddAccountPage(wxNotebook* notebook) m_active_account->Enable(false); m_create_account->Enable(false); m_delete_account->Enable(false); + m_active_service->Enable(false); } } @@ -919,6 +933,7 @@ void GeneralSettings2::StoreConfig() config.account.m_persistent_id = dynamic_cast(m_active_account->GetClientObject(active_account))->GetAccount().GetPersistentId(); config.account.online_enabled = m_online_enabled->GetValue(); + config.account.active_service = m_active_service->GetSelection(); // debug config.crash_dump = (CrashDump)m_crash_dump->GetSelection(); @@ -1488,6 +1503,7 @@ void GeneralSettings2::ApplyConfig() } m_online_enabled->SetValue(config.account.online_enabled); + m_active_service->SetSelection(config.account.active_service); UpdateAccountInformation(); // debug @@ -1722,6 +1738,13 @@ void GeneralSettings2::OnActiveAccountChanged(wxCommandEvent& event) m_has_account_change = true; } +void GeneralSettings2::OnAccountServiceChanged(wxCommandEvent& event) +{ + LaunchSettings::ChangeNetworkServiceURL(m_active_service->GetSelection()); + + UpdateAccountInformation(); +} + void GeneralSettings2::OnMLCPathSelect(wxCommandEvent& event) { if (!CemuApp::SelectMLCPath(this)) diff --git a/src/gui/GeneralSettings2.h b/src/gui/GeneralSettings2.h index ed326d5a..fb3e8092 100644 --- a/src/gui/GeneralSettings2.h +++ b/src/gui/GeneralSettings2.h @@ -65,6 +65,7 @@ private: // Account wxButton* m_create_account, * m_delete_account; wxChoice* m_active_account; + wxRadioBox* m_active_service; wxCheckBox* m_online_enabled; wxCollapsiblePane* m_account_information; wxPropertyGrid* m_account_grid; @@ -93,6 +94,7 @@ private: void OnMLCPathChar(wxKeyEvent& event); void OnShowOnlineValidator(wxCommandEvent& event); void OnOnlineEnable(wxCommandEvent& event); + void OnAccountServiceChanged(wxCommandEvent& event); // updates cemu audio devices void UpdateAudioDevice(); diff --git a/src/gui/guiWrapper.cpp b/src/gui/guiWrapper.cpp index 835dc499..2a1598c0 100644 --- a/src/gui/guiWrapper.cpp +++ b/src/gui/guiWrapper.cpp @@ -5,6 +5,7 @@ #include "gui/debugger/DebuggerWindow2.h" #include "Cafe/HW/Latte/Core/Latte.h" #include "config/ActiveSettings.h" +#include "config/NetworkSettings.h" #include "config/CemuConfig.h" #include "Cafe/HW/Latte/Renderer/Renderer.h" #include "Cafe/CafeSystem.h" @@ -96,9 +97,18 @@ void gui_updateWindowTitles(bool isIdle, bool isLoading, double fps) const uint64 titleId = CafeSystem::GetForegroundTitleId(); windowText.append(fmt::format(" - FPS: {:.2f} {} {} [TitleId: {:08x}-{:08x}]", (double)fps, renderer, graphicMode, (uint32)(titleId >> 32), (uint32)(titleId & 0xFFFFFFFF))); - if (ActiveSettings::IsOnlineEnabled()) + if (ActiveSettings::IsOnlineEnabled()){ windowText.append(" [Online]"); - + if (ActiveSettings::GetNetworkService() == NetworkService::Nintendo) { + windowText.append("[Nintendo]"); + } + else if (ActiveSettings::GetNetworkService() == NetworkService::Pretendo) { + windowText.append("[Pretendo]"); + } + else if (ActiveSettings::GetNetworkService() == NetworkService::Custom) { + windowText.append("[" + GetNetworkConfig().networkname.GetValue() + "]"); + } + } windowText.append(" "); windowText.append(CafeSystem::GetForegroundTitleName()); // append region diff --git a/src/main.cpp b/src/main.cpp index f782c33e..87243bb8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,7 @@ #include "Cafe/GameProfile/GameProfile.h" #include "Cafe/GraphicPack/GraphicPack2.h" #include "config/CemuConfig.h" +#include "config/NetworkSettings.h" #include "gui/CemuApp.h" #include "Cafe/HW/Latte/Core/LatteOverlay.h" #include "config/LaunchSettings.h" @@ -216,6 +217,8 @@ void mainEmulatorCommonInit() ExceptionHandler_init(); // read config g_config.Load(); + if (NetworkConfig::XMLExists()) + n_config.Load(); // symbol storage rplSymbolStorage_init(); // static initialization @@ -345,6 +348,7 @@ int wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ L if (!LaunchSettings::HandleCommandline(lpCmdLine)) return 0; ActiveSettings::LoadOnce(); + NetworkConfig::LoadOnce(); HandlePostUpdate(); return mainEmulatorHLE(); } @@ -356,6 +360,7 @@ int main(int argc, char* argv[]) if (!LaunchSettings::HandleCommandline(argc, argv)) return 0; ActiveSettings::LoadOnce(); + NetworkConfig::LoadOnce(); HandlePostUpdate(); return mainEmulatorHLE(); } @@ -371,7 +376,7 @@ int main(int argc, char *argv[]) return 0; ActiveSettings::LoadOnce(); - + NetworkConfig::LoadOnce(); HandlePostUpdate(); return mainEmulatorHLE(); }