From e7f373496ed51d30d87eb1b75410d4f02f0412ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 18 Jul 2020 16:18:02 +0200 Subject: [PATCH] GH-3234 Add support for custom meta URLs at build time This is not particularly interesting for non-developers. Also includes some internal restructuring of URL constants in general. --- CMakeLists.txt | 4 ++ api/logic/CMakeLists.txt | 4 +- api/logic/meta/BaseEntity.cpp | 4 +- api/logic/minecraft/AssetsUtils.cpp | 4 +- api/logic/minecraft/Library.cpp | 3 +- api/logic/minecraft/Library.h | 1 - api/logic/minecraft/MinecraftUpdate.cpp | 1 - api/logic/minecraft/OneSixVersionFormat.cpp | 5 ++- api/logic/minecraft/auth/YggdrasilTask.cpp | 4 +- .../minecraft/update/FMLLibrariesTask.cpp | 3 +- .../modplatform/legacy_ftb/PackFetchTask.cpp | 8 ++-- .../legacy_ftb/PackInstallTask.cpp | 8 ++-- api/logic/net/URLConstants.cpp | 16 -------- api/logic/net/URLConstants.h | 37 ------------------- api/logic/screenshots/ImgurAlbumCreation.cpp | 4 +- api/logic/screenshots/ImgurUpload.cpp | 4 +- api/logic/status/StatusChecker.cpp | 6 +-- api/logic/translations/TranslationsModel.cpp | 4 +- application/CMakeLists.txt | 5 --- application/MainWindow.cpp | 4 +- application/MultiMC.cpp | 1 - application/pages/global/AccountListPage.cpp | 5 ++- .../modplatform/legacy_ftb/ListModel.cpp | 4 +- .../pages/modplatform/twitch/TwitchModel.cpp | 2 - .../BuildConfig.cpp.in | 3 +- {application => buildconfig}/BuildConfig.h | 19 +++++++++- buildconfig/CMakeLists.txt | 11 ++++++ 27 files changed, 75 insertions(+), 99 deletions(-) delete mode 100644 api/logic/net/URLConstants.cpp delete mode 100644 api/logic/net/URLConstants.h rename {application => buildconfig}/BuildConfig.cpp.in (96%) rename {application => buildconfig}/BuildConfig.h (67%) create mode 100644 buildconfig/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index fdc61c06..b178462e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,9 @@ set(MultiMC_CHANLIST_URL "" CACHE STRING "URL for the channel list.") # Notification URL set(MultiMC_NOTIFICATION_URL "" CACHE STRING "URL for checking for notifications.") +# The metadata server +set(MultiMC_META_URL "https://meta.multimc.org/v1/" CACHE STRING "URL to fetch MultiMC's meta files from.") + # paste.ee API key set(MultiMC_PASTE_EE_API_KEY "utLvciUouSURFzfjPxLBf5W4ISsUX4pwBDF7N1AfZ" CACHE STRING "API key you can get from paste.ee when you register an account") @@ -264,6 +267,7 @@ add_subdirectory(libraries/classparser) # google analytics library ############################### Built Artifacts ############################### +add_subdirectory(buildconfig) add_subdirectory(api/logic) add_subdirectory(api/gui) diff --git a/api/logic/CMakeLists.txt b/api/logic/CMakeLists.txt index cf9f9a17..50eff4ba 100644 --- a/api/logic/CMakeLists.txt +++ b/api/logic/CMakeLists.txt @@ -119,8 +119,6 @@ set(NET_SOURCES net/PasteUpload.cpp net/PasteUpload.h net/Sink.h - net/URLConstants.cpp - net/URLConstants.h net/Validator.h ) @@ -491,7 +489,7 @@ set_target_properties(MultiMC_logic PROPERTIES CXX_VISIBILITY_PRESET hidden VISI generate_export_header(MultiMC_logic) # Link -target_link_libraries(MultiMC_logic systeminfo MultiMC_quazip MultiMC_classparser ${NBT_NAME} ${ZLIB_LIBRARIES}) +target_link_libraries(MultiMC_logic systeminfo MultiMC_quazip MultiMC_classparser ${NBT_NAME} ${ZLIB_LIBRARIES} BuildConfig) target_link_libraries(MultiMC_logic Qt5::Core Qt5::Xml Qt5::Network Qt5::Concurrent) # Mark and export headers diff --git a/api/logic/meta/BaseEntity.cpp b/api/logic/meta/BaseEntity.cpp index 697beb56..31d79aa3 100644 --- a/api/logic/meta/BaseEntity.cpp +++ b/api/logic/meta/BaseEntity.cpp @@ -24,6 +24,8 @@ #include "Env.h" #include "Json.h" +#include "BuildConfig.h" + class ParsingValidator : public Net::Validator { public: /* con/des */ @@ -76,7 +78,7 @@ Meta::BaseEntity::~BaseEntity() QUrl Meta::BaseEntity::url() const { - return QUrl("https://meta.multimc.org/v1/").resolved(localFilename()); + return QUrl(BuildConfig.META_URL).resolved(localFilename()); } bool Meta::BaseEntity::loadLocalFile() diff --git a/api/logic/minecraft/AssetsUtils.cpp b/api/logic/minecraft/AssetsUtils.cpp index f94f68b1..68089080 100644 --- a/api/logic/minecraft/AssetsUtils.cpp +++ b/api/logic/minecraft/AssetsUtils.cpp @@ -27,7 +27,7 @@ #include "FileSystem.h" #include "net/Download.h" #include "net/ChecksumValidator.h" -#include "net/URLConstants.h" +#include "BuildConfig.h" namespace { QSet collectPathsFromDir(QString dirPath) @@ -308,7 +308,7 @@ QString AssetObject::getLocalPath() QUrl AssetObject::getUrl() { - return URLConstants::RESOURCE_BASE + getRelPath(); + return BuildConfig.RESOURCE_BASE + getRelPath(); } QString AssetObject::getRelPath() diff --git a/api/logic/minecraft/Library.cpp b/api/logic/minecraft/Library.cpp index 9ff8dcdc..b3c7657c 100644 --- a/api/logic/minecraft/Library.cpp +++ b/api/logic/minecraft/Library.cpp @@ -5,6 +5,7 @@ #include #include #include +#include void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& native, QStringList& native32, @@ -171,7 +172,7 @@ QList< std::shared_ptr< NetAction > > Library::getDownloads( if (m_repositoryURL.isEmpty()) { - return URLConstants::LIBRARY_BASE + raw_storage; + return BuildConfig.LIBRARY_BASE + raw_storage; } if(m_repositoryURL.endsWith('/')) diff --git a/api/logic/minecraft/Library.h b/api/logic/minecraft/Library.h index 014f6745..acdd6c9c 100644 --- a/api/logic/minecraft/Library.h +++ b/api/logic/minecraft/Library.h @@ -12,7 +12,6 @@ #include "Rule.h" #include "minecraft/OpSys.h" #include "GradleSpecifier.h" -#include "net/URLConstants.h" #include "MojangDownloadInfo.h" #include "multimc_logic_export.h" diff --git a/api/logic/minecraft/MinecraftUpdate.cpp b/api/logic/minecraft/MinecraftUpdate.cpp index ca3e7617..68dd437d 100644 --- a/api/logic/minecraft/MinecraftUpdate.cpp +++ b/api/logic/minecraft/MinecraftUpdate.cpp @@ -25,7 +25,6 @@ #include "BaseInstance.h" #include "minecraft/PackProfile.h" #include "minecraft/Library.h" -#include "net/URLConstants.h" #include #include "update/FoldersTask.h" diff --git a/api/logic/minecraft/OneSixVersionFormat.cpp b/api/logic/minecraft/OneSixVersionFormat.cpp index a0b6fd0e..7ac9e2db 100644 --- a/api/logic/minecraft/OneSixVersionFormat.cpp +++ b/api/logic/minecraft/OneSixVersionFormat.cpp @@ -198,7 +198,10 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc // FIXME: this will eventually break... else { - lib->setAbsoluteUrl(URLConstants::getLegacyJarUrl(out->minecraftVersion)); + out->addProblem( + ProblemSeverity::Error, + QObject::tr("URL for the main jar could not be determined - Mojang removed the server that we used as fallback.") + ); } out->mainJar = lib; } diff --git a/api/logic/minecraft/auth/YggdrasilTask.cpp b/api/logic/minecraft/auth/YggdrasilTask.cpp index 71f5d950..570fe1ea 100644 --- a/api/logic/minecraft/auth/YggdrasilTask.cpp +++ b/api/logic/minecraft/auth/YggdrasilTask.cpp @@ -25,7 +25,7 @@ #include -#include +#include #include @@ -42,7 +42,7 @@ void YggdrasilTask::executeTask() // Get the content of the request we're going to send to the server. QJsonDocument doc(getRequestContent()); - QUrl reqUrl(URLConstants::AUTH_BASE + getEndpoint()); + QUrl reqUrl(BuildConfig.AUTH_BASE + getEndpoint()); QNetworkRequest netRequest(reqUrl); netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); diff --git a/api/logic/minecraft/update/FMLLibrariesTask.cpp b/api/logic/minecraft/update/FMLLibrariesTask.cpp index 850130a1..85993e81 100644 --- a/api/logic/minecraft/update/FMLLibrariesTask.cpp +++ b/api/logic/minecraft/update/FMLLibrariesTask.cpp @@ -4,6 +4,7 @@ #include "FMLLibrariesTask.h" #include "minecraft/MinecraftInstance.h" #include "minecraft/PackProfile.h" +#include "BuildConfig.h" FMLLibrariesTask::FMLLibrariesTask(MinecraftInstance * inst) { @@ -63,7 +64,7 @@ void FMLLibrariesTask::executeTask() for (auto &lib : fmlLibsToProcess) { auto entry = metacache->resolveEntry("fmllibs", lib.filename); - QString urlString = (lib.ours ? URLConstants::FMLLIBS_OUR_BASE_URL : URLConstants::FMLLIBS_FORGE_BASE_URL) + lib.filename; + QString urlString = (lib.ours ? BuildConfig.FMLLIBS_OUR_BASE_URL : BuildConfig.FMLLIBS_FORGE_BASE_URL) + lib.filename; dljob->addNetAction(Net::Download::makeCached(QUrl(urlString), entry)); } diff --git a/api/logic/modplatform/legacy_ftb/PackFetchTask.cpp b/api/logic/modplatform/legacy_ftb/PackFetchTask.cpp index 43c1e6f8..c2ef6436 100644 --- a/api/logic/modplatform/legacy_ftb/PackFetchTask.cpp +++ b/api/logic/modplatform/legacy_ftb/PackFetchTask.cpp @@ -2,7 +2,7 @@ #include "PrivatePackManager.h" #include -#include "net/URLConstants.h" +#include namespace LegacyFTB { @@ -13,11 +13,11 @@ void PackFetchTask::fetch() NetJob *netJob = new NetJob("LegacyFTB::ModpackFetch"); - QUrl publicPacksUrl = QUrl(URLConstants::LEGACY_FTB_CDN_BASE_URL + "static/modpacks.xml"); + QUrl publicPacksUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/modpacks.xml"); qDebug() << "Downloading public version info from" << publicPacksUrl.toString(); netJob->addNetAction(Net::Download::makeByteArray(publicPacksUrl, &publicModpacksXmlFileData)); - QUrl thirdPartyUrl = QUrl(URLConstants::LEGACY_FTB_CDN_BASE_URL + "static/thirdparty.xml"); + QUrl thirdPartyUrl = QUrl(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/thirdparty.xml"); qDebug() << "Downloading thirdparty version info from" << thirdPartyUrl.toString(); netJob->addNetAction(Net::Download::makeByteArray(thirdPartyUrl, &thirdPartyModpacksXmlFileData)); @@ -30,7 +30,7 @@ void PackFetchTask::fetch() void PackFetchTask::fetchPrivate(const QStringList & toFetch) { - QString privatePackBaseUrl = URLConstants::LEGACY_FTB_CDN_BASE_URL + "static/%1.xml"; + QString privatePackBaseUrl = BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/%1.xml"; for (auto &packCode: toFetch) { diff --git a/api/logic/modplatform/legacy_ftb/PackInstallTask.cpp b/api/logic/modplatform/legacy_ftb/PackInstallTask.cpp index a3f35154..9bf6c76a 100644 --- a/api/logic/modplatform/legacy_ftb/PackInstallTask.cpp +++ b/api/logic/modplatform/legacy_ftb/PackInstallTask.cpp @@ -9,7 +9,7 @@ #include "minecraft/MinecraftInstance.h" #include "minecraft/PackProfile.h" #include "minecraft/GradleSpecifier.h" -#include "net/URLConstants.h" +#include "BuildConfig.h" #include @@ -38,11 +38,11 @@ void PackInstallTask::downloadPack() QString url; if(m_pack.type == PackType::Private) { - url = QString(URLConstants::LEGACY_FTB_CDN_BASE_URL + "privatepacks/%1").arg(packoffset); + url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "privatepacks/%1").arg(packoffset); } else { - url = QString(URLConstants::LEGACY_FTB_CDN_BASE_URL + "modpacks/%1").arg(packoffset); + url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "modpacks/%1").arg(packoffset); } job->addNetAction(Net::Download::makeCached(url, entry)); archivePath = entry->getFullPath(); @@ -210,4 +210,4 @@ bool PackInstallTask::abort() return false; } -} \ No newline at end of file +} diff --git a/api/logic/net/URLConstants.cpp b/api/logic/net/URLConstants.cpp deleted file mode 100644 index 9a4d920b..00000000 --- a/api/logic/net/URLConstants.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "URLConstants.h" - -namespace URLConstants { - -QString getLegacyJarUrl(QString version) -{ - return AWS_DOWNLOAD_VERSIONS + getJarPath(version); -} - -QString getJarPath(QString version) -{ - return version + "/" + version + ".jar"; -} - - -} diff --git a/api/logic/net/URLConstants.h b/api/logic/net/URLConstants.h deleted file mode 100644 index ebc495bb..00000000 --- a/api/logic/net/URLConstants.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2013-2019 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -namespace URLConstants -{ -const QString AWS_DOWNLOAD_VERSIONS("https://s3.amazonaws.com/Minecraft.Download/versions/"); -const QString RESOURCE_BASE("https://resources.download.minecraft.net/"); -const QString LIBRARY_BASE("https://libraries.minecraft.net/"); -const QString SKINS_BASE("https://crafatar.com/skins/"); -const QString AUTH_BASE("https://authserver.mojang.com/"); -const QString MOJANG_STATUS_URL("https://status.mojang.com/check"); -const QString IMGUR_BASE_URL("https://api.imgur.com/3/"); -const QString FMLLIBS_OUR_BASE_URL("https://files.multimc.org/fmllibs/"); -const QString FMLLIBS_FORGE_BASE_URL("https://files.minecraftforge.net/fmllibs/"); -const QString TRANSLATIONS_BASE_URL("https://files.multimc.org/translations/"); - -const QString LEGACY_FTB_CDN_BASE_URL("https://dist.creeper.host/FTB2/"); - -QString getJarPath(QString version); -QString getLegacyJarUrl(QString version); -} diff --git a/api/logic/screenshots/ImgurAlbumCreation.cpp b/api/logic/screenshots/ImgurAlbumCreation.cpp index 3d32f597..ff9ec6fd 100644 --- a/api/logic/screenshots/ImgurAlbumCreation.cpp +++ b/api/logic/screenshots/ImgurAlbumCreation.cpp @@ -6,13 +6,13 @@ #include #include -#include "net/URLConstants.h" +#include "BuildConfig.h" #include "Env.h" #include ImgurAlbumCreation::ImgurAlbumCreation(QList screenshots) : NetAction(), m_screenshots(screenshots) { - m_url = URLConstants::IMGUR_BASE_URL + "album.json"; + m_url = BuildConfig.IMGUR_BASE_URL + "album.json"; m_status = Job_NotStarted; } diff --git a/api/logic/screenshots/ImgurUpload.cpp b/api/logic/screenshots/ImgurUpload.cpp index 74165869..1585b061 100644 --- a/api/logic/screenshots/ImgurUpload.cpp +++ b/api/logic/screenshots/ImgurUpload.cpp @@ -8,13 +8,13 @@ #include #include -#include "net/URLConstants.h" +#include "BuildConfig.h" #include "Env.h" #include ImgurUpload::ImgurUpload(ScreenshotPtr shot) : NetAction(), m_shot(shot) { - m_url = URLConstants::IMGUR_BASE_URL + "upload.json"; + m_url = BuildConfig.IMGUR_BASE_URL + "upload.json"; m_status = Job_NotStarted; } diff --git a/api/logic/status/StatusChecker.cpp b/api/logic/status/StatusChecker.cpp index f18ed364..2a4091c6 100644 --- a/api/logic/status/StatusChecker.cpp +++ b/api/logic/status/StatusChecker.cpp @@ -15,12 +15,12 @@ #include "StatusChecker.h" -#include - #include #include +#include + StatusChecker::StatusChecker() { @@ -43,7 +43,7 @@ void StatusChecker::reloadStatus() // qDebug() << "Reloading status."; NetJob* job = new NetJob("Status JSON"); - job->addNetAction(Net::Download::makeByteArray(URLConstants::MOJANG_STATUS_URL, &dataSink)); + job->addNetAction(Net::Download::makeByteArray(BuildConfig.MOJANG_STATUS_URL, &dataSink)); QObject::connect(job, &NetJob::succeeded, this, &StatusChecker::statusDownloadFinished); QObject::connect(job, &NetJob::failed, this, &StatusChecker::statusDownloadFailed); m_statusNetJob.reset(job); diff --git a/api/logic/translations/TranslationsModel.cpp b/api/logic/translations/TranslationsModel.cpp index 43b3e75f..adb3fa98 100644 --- a/api/logic/translations/TranslationsModel.cpp +++ b/api/logic/translations/TranslationsModel.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include "Json.h" #include "POTranslator.h" @@ -606,7 +606,7 @@ void TranslationsModel::downloadTranslation(QString key) MetaEntryPtr entry = ENV.metacache()->resolveEntry("translations", "mmc_" + key + ".qm"); entry->setStale(true); - auto dl = Net::Download::makeCached(QUrl(URLConstants::TRANSLATIONS_BASE_URL + lang->file_name), entry); + auto dl = Net::Download::makeCached(QUrl(BuildConfig.TRANSLATIONS_BASE_URL + lang->file_name), entry); auto rawHash = QByteArray::fromHex(lang->file_sha1.toLatin1()); dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawHash)); dl->m_total_progress = lang->file_size; diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index 53c21866..1d5b8e04 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -1,8 +1,5 @@ project(application) -######## Configure the file with build properties ######## -configure_file("${PROJECT_SOURCE_DIR}/BuildConfig.cpp.in" "${PROJECT_BINARY_DIR}/BuildConfig.cpp") - ################################ FILES ################################ ######## Sources and headers ######## @@ -11,8 +8,6 @@ SET(MULTIMC_SOURCES main.cpp MultiMC.h MultiMC.cpp - BuildConfig.h - ${PROJECT_BINARY_DIR}/BuildConfig.cpp UpdateController.cpp UpdateController.h diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index 48b9ed47..00c37084 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -56,7 +56,7 @@ #include #include #include -#include +#include #include #include #include @@ -772,7 +772,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow for (auto profile : account->profiles()) { auto meta = Env::getInstance().metacache()->resolveEntry("skins", profile.id + ".png"); - auto action = Net::Download::makeCached(QUrl(URLConstants::SKINS_BASE + profile.id + ".png"), meta); + auto action = Net::Download::makeCached(QUrl(BuildConfig.SKINS_BASE + profile.id + ".png"), meta); skin_dls.append(action); meta->setStale(true); } diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index a8d26498..eeab500e 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -45,7 +45,6 @@ #include #include "icons/IconList.h" #include "net/HttpMetaCache.h" -#include "net/URLConstants.h" #include "Env.h" #include "java/JavaUtils.h" diff --git a/application/pages/global/AccountListPage.cpp b/application/pages/global/AccountListPage.cpp index 0453ae00..3c900fab 100644 --- a/application/pages/global/AccountListPage.cpp +++ b/application/pages/global/AccountListPage.cpp @@ -22,7 +22,6 @@ #include #include "net/NetJob.h" -#include "net/URLConstants.h" #include "Env.h" #include "dialogs/ProgressDialog.h" @@ -34,6 +33,8 @@ #include "MultiMC.h" +#include "BuildConfig.h" + AccountListPage::AccountListPage(QWidget *parent) : QMainWindow(parent), ui(new Ui::AccountListPage) { @@ -170,7 +171,7 @@ void AccountListPage::addAccount(const QString &errMsg) for (AccountProfile profile : account->profiles()) { auto meta = Env::getInstance().metacache()->resolveEntry("skins", profile.id + ".png"); - auto action = Net::Download::makeCached(QUrl(URLConstants::SKINS_BASE + profile.id + ".png"), meta); + auto action = Net::Download::makeCached(QUrl(BuildConfig.SKINS_BASE + profile.id + ".png"), meta); job->addNetAction(action); meta->setStale(true); } diff --git a/application/pages/modplatform/legacy_ftb/ListModel.cpp b/application/pages/modplatform/legacy_ftb/ListModel.cpp index 105db25a..32596fb3 100644 --- a/application/pages/modplatform/legacy_ftb/ListModel.cpp +++ b/application/pages/modplatform/legacy_ftb/ListModel.cpp @@ -10,7 +10,7 @@ #include #include -#include "net/URLConstants.h" +#include namespace LegacyFTB { @@ -218,7 +218,7 @@ void ListModel::requestLogo(QString file) MetaEntryPtr entry = ENV.metacache()->resolveEntry("FTBPacks", QString("logos/%1").arg(file.section(".", 0, 0))); NetJob *job = new NetJob(QString("FTB Icon Download for %1").arg(file)); - job->addNetAction(Net::Download::makeCached(QUrl(QString(URLConstants::LEGACY_FTB_CDN_BASE_URL + "static/%1").arg(file)), entry)); + job->addNetAction(Net::Download::makeCached(QUrl(QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "static/%1").arg(file)), entry)); auto fullPath = entry->getFullPath(); QObject::connect(job, &NetJob::finished, this, [this, file, fullPath] diff --git a/application/pages/modplatform/twitch/TwitchModel.cpp b/application/pages/modplatform/twitch/TwitchModel.cpp index d9358941..9e3c3ad2 100644 --- a/application/pages/modplatform/twitch/TwitchModel.cpp +++ b/application/pages/modplatform/twitch/TwitchModel.cpp @@ -10,8 +10,6 @@ #include #include -#include "net/URLConstants.h" - namespace Twitch { ListModel::ListModel(QObject *parent) : QAbstractListModel(parent) diff --git a/application/BuildConfig.cpp.in b/buildconfig/BuildConfig.cpp.in similarity index 96% rename from application/BuildConfig.cpp.in rename to buildconfig/BuildConfig.cpp.in index a1d236b2..86ea83ee 100644 --- a/application/BuildConfig.cpp.in +++ b/buildconfig/BuildConfig.cpp.in @@ -1,7 +1,7 @@ #include "BuildConfig.h" #include -Config BuildConfig; +const Config BuildConfig; Config::Config() { @@ -33,6 +33,7 @@ Config::Config() VERSION_STR = "@MultiMC_VERSION_STRING@"; NEWS_RSS_URL = "@MultiMC_NEWS_RSS_URL@"; PASTE_EE_KEY = "@MultiMC_PASTE_EE_API_KEY@"; + META_URL = "@MultiMC_META_URL@"; } QString Config::printableVersionString() const diff --git a/application/BuildConfig.h b/buildconfig/BuildConfig.h similarity index 67% rename from application/BuildConfig.h rename to buildconfig/BuildConfig.h index 77c42dd4..a80af3d2 100644 --- a/application/BuildConfig.h +++ b/buildconfig/BuildConfig.h @@ -60,6 +60,23 @@ public: */ QString PASTE_EE_KEY; + /** + * MultiMC Metadata repository URL prefix + */ + QString META_URL; + + QString RESOURCE_BASE = "https://resources.download.minecraft.net/"; + QString LIBRARY_BASE = "https://libraries.minecraft.net/"; + QString SKINS_BASE = "https://crafatar.com/skins/"; + QString AUTH_BASE = "https://authserver.mojang.com/"; + QString MOJANG_STATUS_URL = "https://status.mojang.com/check"; + QString IMGUR_BASE_URL = "https://api.imgur.com/3/"; + QString FMLLIBS_OUR_BASE_URL = "https://files.multimc.org/fmllibs/"; + QString FMLLIBS_FORGE_BASE_URL = "https://files.minecraftforge.net/fmllibs/"; + QString TRANSLATIONS_BASE_URL = "https://files.multimc.org/translations/"; + + QString LEGACY_FTB_CDN_BASE_URL = "https://dist.creeper.host/FTB2/"; + /** * \brief Converts the Version to a string. * \return The version number in string format (major.minor.revision.build). @@ -67,4 +84,4 @@ public: QString printableVersionString() const; }; -extern Config BuildConfig; +extern const Config BuildConfig; diff --git a/buildconfig/CMakeLists.txt b/buildconfig/CMakeLists.txt new file mode 100644 index 00000000..de4fd350 --- /dev/null +++ b/buildconfig/CMakeLists.txt @@ -0,0 +1,11 @@ +######## Configure the file with build properties ######## + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/BuildConfig.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/BuildConfig.cpp") + +add_library(BuildConfig STATIC + BuildConfig.h + ${CMAKE_CURRENT_BINARY_DIR}/BuildConfig.cpp +) + +target_link_libraries(BuildConfig Qt5::Core) +target_include_directories(BuildConfig PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")