summaryrefslogtreecommitdiffstats
path: root/api/logic
diff options
context:
space:
mode:
Diffstat (limited to 'api/logic')
-rw-r--r--api/logic/CMakeLists.txt4
-rw-r--r--api/logic/meta/BaseEntity.cpp4
-rw-r--r--api/logic/minecraft/AssetsUtils.cpp4
-rw-r--r--api/logic/minecraft/Library.cpp3
-rw-r--r--api/logic/minecraft/Library.h1
-rw-r--r--api/logic/minecraft/MinecraftUpdate.cpp1
-rw-r--r--api/logic/minecraft/OneSixVersionFormat.cpp5
-rw-r--r--api/logic/minecraft/auth/YggdrasilTask.cpp4
-rw-r--r--api/logic/minecraft/update/FMLLibrariesTask.cpp3
-rw-r--r--api/logic/modplatform/legacy_ftb/PackFetchTask.cpp8
-rw-r--r--api/logic/modplatform/legacy_ftb/PackInstallTask.cpp8
-rw-r--r--api/logic/net/URLConstants.cpp16
-rw-r--r--api/logic/net/URLConstants.h37
-rw-r--r--api/logic/screenshots/ImgurAlbumCreation.cpp4
-rw-r--r--api/logic/screenshots/ImgurUpload.cpp4
-rw-r--r--api/logic/status/StatusChecker.cpp6
-rw-r--r--api/logic/translations/TranslationsModel.cpp4
17 files changed, 33 insertions, 83 deletions
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<QString> 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 <net/ChecksumValidator.h>
#include <Env.h>
#include <FileSystem.h>
+#include <BuildConfig.h>
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 <FileSystem.h>
#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 <Env.h>
-#include <net/URLConstants.h>
+#include <BuildConfig.h>
#include <QDebug>
@@ -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 <QDomDocument>
-#include "net/URLConstants.h"
+#include <BuildConfig.h>
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 <QtConcurrent>
@@ -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 <QString>
-
-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 <QUrl>
#include <QStringList>
-#include "net/URLConstants.h"
+#include "BuildConfig.h"
#include "Env.h"
#include <QDebug>
ImgurAlbumCreation::ImgurAlbumCreation(QList<ScreenshotPtr> 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 <QFile>
#include <QUrl>
-#include "net/URLConstants.h"
+#include "BuildConfig.h"
#include "Env.h"
#include <QDebug>
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 <net/URLConstants.h>
-
#include <QByteArray>
#include <QDebug>
+#include <BuildConfig.h>
+
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 <net/NetJob.h>
#include <net/ChecksumValidator.h>
#include <Env.h>
-#include <net/URLConstants.h>
+#include <BuildConfig.h>
#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;