From 8a1a583afef0a719a3b793ce32bb93cc2d6180bb Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sun, 29 May 2022 21:29:07 +0200 Subject: [PATCH] refactor: rename references to CurseForge to Flame Signed-off-by: Sefa Eyeoglu --- CMakeLists.txt | 2 +- buildconfig/BuildConfig.cpp.in | 2 +- buildconfig/BuildConfig.h | 2 +- launcher/Application.cpp | 21 ++++++++++++++++----- launcher/Application.h | 2 +- launcher/net/Download.cpp | 2 +- launcher/net/Upload.cpp | 2 +- launcher/ui/pages/global/APIPage.cpp | 8 ++++---- launcher/ui/pages/global/APIPage.ui | 6 +++--- 9 files changed, 29 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 958e6ef6..1382f571 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,7 +131,7 @@ set(Launcher_MSA_CLIENT_ID "549033b2-1532-4d4e-ae77-1bbaa46f9d74" CACHE STRING " # By using this key in your builds you accept the terms and conditions laid down in # https://support.curseforge.com/en/support/solutions/articles/9000207405-curse-forge-3rd-party-api-terms-and-conditions # NOTE: CurseForge requires you to change this if you make any kind of derivative work. -set(Launcher_CURSEFORGE_API_KEY "$2a$10$1Oqr2MX3O4n/ilhFGc597u8tfI3L2Hyr9/rtWDAMRjghSQV2QUuxq" CACHE STRING "CurseForge API Key") +set(Launcher_CURSEFORGE_API_KEY "$2a$10$1Oqr2MX3O4n/ilhFGc597u8tfI3L2Hyr9/rtWDAMRjghSQV2QUuxq" CACHE STRING "API key for the CurseForge platform") #### Check the current Git commit and branch diff --git a/buildconfig/BuildConfig.cpp.in b/buildconfig/BuildConfig.cpp.in index 70f8f7f0..c0501aa3 100644 --- a/buildconfig/BuildConfig.cpp.in +++ b/buildconfig/BuildConfig.cpp.in @@ -90,7 +90,7 @@ Config::Config() HELP_URL = "@Launcher_HELP_URL@"; IMGUR_CLIENT_ID = "@Launcher_IMGUR_CLIENT_ID@"; MSA_CLIENT_ID = "@Launcher_MSA_CLIENT_ID@"; - CURSEFORGE_API_KEY = "@Launcher_CURSEFORGE_API_KEY@"; + FLAME_API_KEY = "@Launcher_CURSEFORGE_API_KEY@"; META_URL = "@Launcher_META_URL@"; BUG_TRACKER_URL = "@Launcher_BUG_TRACKER_URL@"; diff --git a/buildconfig/BuildConfig.h b/buildconfig/BuildConfig.h index 8594e46d..2ebc8658 100644 --- a/buildconfig/BuildConfig.h +++ b/buildconfig/BuildConfig.h @@ -118,7 +118,7 @@ class Config { /** * Client API key for CurseForge */ - QString CURSEFORGE_API_KEY; + QString FLAME_API_KEY; /** * Metadata repository URL prefix diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 0ef641ba..ee27adea 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -712,9 +712,20 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) m_settings->registerSetting("CloseAfterLaunch", false); m_settings->registerSetting("QuitAfterGameStop", false); - // Custom MSA credentials + // Custom Microsoft Authentication Client ID m_settings->registerSetting("MSAClientIDOverride", ""); - m_settings->registerSetting("CFKeyOverride", ""); + + // Custom Flame API Key + { + m_settings->registerSetting("CFKeyOverride", ""); + m_settings->registerSetting("FlameKeyOverride", ""); + + QString flameKey = m_settings->get("CFKeyOverride").toString(); + + if (!flameKey.isEmpty()) + m_settings->set("FlameKeyOverride", flameKey); + m_settings->reset("CFKeyOverride"); + } m_settings->registerSetting("UserAgentOverride", ""); // Init page provider @@ -1586,14 +1597,14 @@ QString Application::getMSAClientID() return BuildConfig.MSA_CLIENT_ID; } -QString Application::getCurseKey() +QString Application::getFlameAPIKey() { - QString keyOverride = m_settings->get("CFKeyOverride").toString(); + QString keyOverride = m_settings->get("FlameKeyOverride").toString(); if (!keyOverride.isEmpty()) { return keyOverride; } - return BuildConfig.CURSEFORGE_API_KEY; + return BuildConfig.FLAME_API_KEY; } QString Application::getUserAgent() diff --git a/launcher/Application.h b/launcher/Application.h index 18461ad8..5eb2f832 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -164,7 +164,7 @@ public: QString getJarPath(QString jarFile); QString getMSAClientID(); - QString getCurseKey(); + QString getFlameAPIKey(); QString getUserAgent(); QString getUserAgentUncached(); diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp index d93eb088..0557f2e3 100644 --- a/launcher/net/Download.cpp +++ b/launcher/net/Download.cpp @@ -118,7 +118,7 @@ void Download::executeTask() request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8()); if (request.url().host().contains("api.curseforge.com")) { - request.setRawHeader("x-api-key", APPLICATION->getCurseKey().toUtf8()); + request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8()); }; QNetworkReply* rep = m_network->get(request); diff --git a/launcher/net/Upload.cpp b/launcher/net/Upload.cpp index c9942a8d..2173bd08 100644 --- a/launcher/net/Upload.cpp +++ b/launcher/net/Upload.cpp @@ -175,7 +175,7 @@ namespace Net { request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8()); if (request.url().host().contains("api.curseforge.com")) { - request.setRawHeader("x-api-key", APPLICATION->getCurseKey().toUtf8()); + request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8()); } //TODO other types of post requests ? request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); diff --git a/launcher/ui/pages/global/APIPage.cpp b/launcher/ui/pages/global/APIPage.cpp index b889e6f7..93a265e3 100644 --- a/launcher/ui/pages/global/APIPage.cpp +++ b/launcher/ui/pages/global/APIPage.cpp @@ -137,8 +137,8 @@ void APIPage::loadSettings() ui->msaClientID->setText(msaClientID); QString metaURL = s->get("MetaURLOverride").toString(); ui->metaURL->setText(metaURL); - QString curseKey = s->get("CFKeyOverride").toString(); - ui->curseKey->setText(curseKey); + QString flameKey = s->get("FlameKeyOverride").toString(); + ui->flameKey->setText(flameKey); QString customUserAgent = s->get("UserAgentOverride").toString(); ui->userAgentLineEdit->setText(customUserAgent); } @@ -167,8 +167,8 @@ void APIPage::applySettings() } s->set("MetaURLOverride", metaURL); - QString curseKey = ui->curseKey->text(); - s->set("CFKeyOverride", curseKey); + QString flameKey = ui->flameKey->text(); + s->set("FlameKeyOverride", flameKey); s->set("UserAgentOverride", ui->userAgentLineEdit->text()); } diff --git a/launcher/ui/pages/global/APIPage.ui b/launcher/ui/pages/global/APIPage.ui index 5327771c..1ae788c7 100644 --- a/launcher/ui/pages/global/APIPage.ui +++ b/launcher/ui/pages/global/APIPage.ui @@ -196,7 +196,7 @@ - + true @@ -214,7 +214,7 @@ - Enter a custom API Key for CurseForge here. + Enter a custom API Key for CurseForge here. Qt::RichText @@ -228,7 +228,7 @@ - + true