summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSky <git@bunnies.cc>2013-12-13 14:58:11 +0000
committerSky <git@bunnies.cc>2013-12-13 14:58:11 +0000
commit979946b7bb2cec808198f9194169ea08cce8bb00 (patch)
tree76db4173a0f896b7accfcdf8bb8a7dd143525922
parent808ca763632090abdab5a2451c95dbb0f4319126 (diff)
downloadMultiMC-979946b7bb2cec808198f9194169ea08cce8bb00.tar
MultiMC-979946b7bb2cec808198f9194169ea08cce8bb00.tar.gz
MultiMC-979946b7bb2cec808198f9194169ea08cce8bb00.tar.lz
MultiMC-979946b7bb2cec808198f9194169ea08cce8bb00.tar.xz
MultiMC-979946b7bb2cec808198f9194169ea08cce8bb00.zip
First sweep moving URLs to a constants file
-rw-r--r--CMakeLists.txt1
-rw-r--r--gui/MainWindow.cpp4
-rw-r--r--gui/dialogs/AccountListDialog.cpp3
-rw-r--r--logic/LegacyUpdate.cpp3
-rw-r--r--logic/OneSixLibrary.cpp7
-rw-r--r--logic/OneSixLibrary.h3
-rw-r--r--logic/OneSixUpdate.cpp10
-rw-r--r--logic/auth/YggdrasilTask.cpp3
-rw-r--r--logic/lists/MinecraftVersionList.cpp9
-rw-r--r--logic/net/S3ListBucket.cpp1
-rw-r--r--logic/net/URLConstants.h32
11 files changed, 56 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c92b3f07..3b1b5483 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -303,6 +303,7 @@ logic/net/S3ListBucket.h
logic/net/S3ListBucket.cpp
logic/net/PasteUpload.h
logic/net/PasteUpload.cpp
+logic/net/URLConstants.h
# Yggdrasil login stuff
logic/auth/MojangAccount.h
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index 80bde381..f6ef6bad 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -76,6 +76,8 @@
#include "logic/updater/DownloadUpdateTask.h"
+#include "logic/net/URLConstants.h"
+
#include "logic/BaseInstance.h"
#include "logic/InstanceFactory.h"
#include "logic/MinecraftProcess.h"
@@ -217,7 +219,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
{
auto meta = MMC->metacache()->resolveEntry("skins", profile.name + ".png");
auto action = CacheDownload::make(
- QUrl("http://skins.minecraft.net/MinecraftSkins/" + profile.name + ".png"),
+ QUrl("http://" + URLConstants::SKINS_BASE + profile.name + ".png"),
meta);
job->addNetAction(action);
meta->stale = true;
diff --git a/gui/dialogs/AccountListDialog.cpp b/gui/dialogs/AccountListDialog.cpp
index 8dae5f07..91b2ac55 100644
--- a/gui/dialogs/AccountListDialog.cpp
+++ b/gui/dialogs/AccountListDialog.cpp
@@ -21,6 +21,7 @@
#include <logger/QsLog.h>
#include <logic/net/NetJob.h>
+#include <logic/net/URLConstants.h>
#include <gui/dialogs/EditAccountDialog.h>
#include <gui/dialogs/ProgressDialog.h>
@@ -134,7 +135,7 @@ void AccountListDialog::addAccount(const QString& errMsg)
{
auto meta = MMC->metacache()->resolveEntry("skins", profile.name + ".png");
auto action = CacheDownload::make(
- QUrl("http://skins.minecraft.net/MinecraftSkins/" + profile.name + ".png"),
+ QUrl("http://" + URLConstants::SKINS_BASE + profile.name + ".png"),
meta);
job->addNetAction(action);
meta->stale = true;
diff --git a/logic/LegacyUpdate.cpp b/logic/LegacyUpdate.cpp
index 60dde3e8..e71b270e 100644
--- a/logic/LegacyUpdate.cpp
+++ b/logic/LegacyUpdate.cpp
@@ -25,6 +25,7 @@
#include <quazipfile.h>
#include <JlCompress.h>
#include "logger/QsLog.h"
+#include "logic/net/URLConstants.h"
LegacyUpdate::LegacyUpdate(BaseInstance *inst, bool only_prepare, QObject *parent)
: Task(parent), m_inst(inst), m_only_prepare(only_prepare)
@@ -263,7 +264,7 @@ void LegacyUpdate::jarStart()
QString version_id = inst->intendedVersionId();
QString localPath = version_id + "/" + version_id + ".jar";
- QString urlstr = "http://s3.amazonaws.com/Minecraft.Download/versions/" + localPath;
+ QString urlstr = "http://" + URLConstants::AWS_DOWNLOAD_VERSIONS + localPath;
auto dljob = new NetJob("Minecraft.jar for version " + version_id);
diff --git a/logic/OneSixLibrary.cpp b/logic/OneSixLibrary.cpp
index ad4aec44..4b6ed9dc 100644
--- a/logic/OneSixLibrary.cpp
+++ b/logic/OneSixLibrary.cpp
@@ -18,6 +18,7 @@
#include "OneSixLibrary.h"
#include "OneSixRule.h"
#include "OpSys.h"
+#include "logic/net/URLConstants.h"
void OneSixLibrary::finalize()
{
@@ -140,9 +141,9 @@ QJsonObject OneSixLibrary::toJson()
libRoot.insert("MMC-absoluteUrl", m_absolute_url);
if (m_hint.size())
libRoot.insert("MMC-hint", m_hint);
- if (m_base_url != "http://s3.amazonaws.com/Minecraft.Download/libraries/" &&
- m_base_url != "https://s3.amazonaws.com/Minecraft.Download/libraries/" &&
- m_base_url != "https://libraries.minecraft.net/")
+ if (m_base_url != "http://" + URLConstants::AWS_DOWNLOAD_LIBRARIES &&
+ m_base_url != "https://" + URLConstants::AWS_DOWNLOAD_LIBRARIES &&
+ m_base_url != "https://" + URLConstants::LIBRARY_BASE)
libRoot.insert("url", m_base_url);
if (isNative() && m_native_suffixes.size())
{
diff --git a/logic/OneSixLibrary.h b/logic/OneSixLibrary.h
index f8dc3aef..5cb867c2 100644
--- a/logic/OneSixLibrary.h
+++ b/logic/OneSixLibrary.h
@@ -21,6 +21,7 @@
#include <QJsonObject>
#include <memory>
+#include "logic/net/URLConstants.h"
#include "OpSys.h"
class Rule;
@@ -30,7 +31,7 @@ class OneSixLibrary
private:
// basic values used internally (so far)
QString m_name;
- QString m_base_url = "https://libraries.minecraft.net/";
+ QString m_base_url = "https://" + URLConstants::LIBRARY_BASE;
QList<std::shared_ptr<Rule>> m_rules;
// custom values
diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp
index 39064de8..4228fc44 100644
--- a/logic/OneSixUpdate.cpp
+++ b/logic/OneSixUpdate.cpp
@@ -29,6 +29,7 @@
#include "OneSixLibrary.h"
#include "OneSixInstance.h"
#include "net/ForgeMirrors.h"
+#include "net/URLConstants.h"
#include "assets/AssetsUtils.h"
#include "pathutils.h"
@@ -131,8 +132,7 @@ void OneSixUpdate::versionFileStart()
QLOG_INFO() << m_inst->name() << ": getting version file.";
setStatus("Getting the version files from Mojang.");
- QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/");
- urlstr += targetVersion->descriptor() + "/" + targetVersion->descriptor() + ".json";
+ QString urlstr = "http://" + URLConstants::AWS_DOWNLOAD_VERSIONS + targetVersion->descriptor() + "/" + targetVersion->descriptor() + ".json";
auto job = new NetJob("Version index");
job->addNetAction(ByteArrayDownload::make(QUrl(urlstr)));
specificVersionDownloadJob.reset(job);
@@ -202,7 +202,7 @@ void OneSixUpdate::assetIndexStart()
OneSixInstance *inst = (OneSixInstance *)m_inst;
std::shared_ptr<OneSixVersion> version = inst->getFullVersion();
QString assetName = version->assets;
- QUrl indexUrl("http://s3.amazonaws.com/Minecraft.Download/indexes/" + assetName + ".json");
+ QUrl indexUrl = "http://" + URLConstants::AWS_DOWNLOAD_INDEXES + assetName + ".json";
QString localPath = assetName + ".json";
auto job = new NetJob("Asset index for " + inst->name());
@@ -241,7 +241,7 @@ void OneSixUpdate::assetIndexFinished()
if ((!objectFile.isFile()) || (objectFile.size() != object.size))
{
auto objectDL = MD5EtagDownload::make(
- QUrl("http://resources.download.minecraft.net/" + objectName),
+ QUrl("http://" + URLConstants::RESOURCE_BASE + objectName),
objectFile.filePath());
dls.append(objectDL);
}
@@ -298,7 +298,7 @@ void OneSixUpdate::jarlibStart()
{
QString version_id = version->id;
QString localPath = version_id + "/" + version_id + ".jar";
- QString urlstr = "http://s3.amazonaws.com/Minecraft.Download/versions/" + localPath;
+ QString urlstr = "http://" + URLConstants::AWS_DOWNLOAD_VERSIONS + localPath;
auto job = new NetJob("Libraries for instance " + inst->name());
diff --git a/logic/auth/YggdrasilTask.cpp b/logic/auth/YggdrasilTask.cpp
index 45155058..088e1fc0 100644
--- a/logic/auth/YggdrasilTask.cpp
+++ b/logic/auth/YggdrasilTask.cpp
@@ -24,6 +24,7 @@
#include <MultiMC.h>
#include <logic/auth/MojangAccount.h>
+#include <logic/net/URLConstants.h>
YggdrasilTask::YggdrasilTask(MojangAccount *account, QObject *parent)
: Task(parent), m_account(account)
@@ -38,7 +39,7 @@ void YggdrasilTask::executeTask()
QJsonDocument doc(getRequestContent());
auto worker = MMC->qnam();
- QUrl reqUrl("https://authserver.mojang.com/" + getEndpoint());
+ QUrl reqUrl("https://" + URLConstants::AUTH_BASE + getEndpoint());
QNetworkRequest netRequest(reqUrl);
netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
diff --git a/logic/lists/MinecraftVersionList.cpp b/logic/lists/MinecraftVersionList.cpp
index 2a9c0d3b..523b81ac 100644
--- a/logic/lists/MinecraftVersionList.cpp
+++ b/logic/lists/MinecraftVersionList.cpp
@@ -15,6 +15,7 @@
#include "MinecraftVersionList.h"
#include "MultiMC.h"
+#include "logic/net/URLConstants.h"
#include <QtXml>
@@ -28,10 +29,6 @@
#include <QtNetwork>
-#define MCVLIST_URLBASE "http://s3.amazonaws.com/Minecraft.Download/versions/"
-#define ASSETS_URLBASE "http://assets.minecraft.net/"
-#define MCN_URLBASE "http://sonicrules.org/mcnweb.py"
-
MinecraftVersionList::MinecraftVersionList(QObject *parent) : BaseVersionList(parent)
{
}
@@ -144,7 +141,7 @@ void MCVListLoadTask::executeTask()
{
setStatus("Loading instance version list...");
auto worker = MMC->qnam();
- vlistReply = worker->get(QNetworkRequest(QUrl(QString(MCVLIST_URLBASE) + "versions.json")));
+ vlistReply = worker->get(QNetworkRequest(QUrl("http://" + URLConstants::AWS_DOWNLOAD_VERSIONS + "versions.json")));
connect(vlistReply, SIGNAL(finished()), this, SLOT(list_downloaded()));
}
@@ -270,7 +267,7 @@ void MCVListLoadTask::list_downloaded()
continue;
}
// Get the download URL.
- QString dlUrl = QString(MCVLIST_URLBASE) + versionID + "/";
+ QString dlUrl = "http://" + URLConstants::AWS_DOWNLOAD_VERSIONS + versionID + "/";
// Now, we construct the version object and add it to the list.
std::shared_ptr<MinecraftVersion> mcVersion(new MinecraftVersion());
diff --git a/logic/net/S3ListBucket.cpp b/logic/net/S3ListBucket.cpp
index 89dff951..439b7086 100644
--- a/logic/net/S3ListBucket.cpp
+++ b/logic/net/S3ListBucket.cpp
@@ -102,7 +102,6 @@ void S3ListBucket::processValidReply()
};
// nothing went wrong...
- QString prefix("http://s3.amazonaws.com/Minecraft.Resources/");
QByteArray ba = m_reply->readAll();
QString xmlErrorMsg;
diff --git a/logic/net/URLConstants.h b/logic/net/URLConstants.h
new file mode 100644
index 00000000..dcd5c2b1
--- /dev/null
+++ b/logic/net/URLConstants.h
@@ -0,0 +1,32 @@
+/* Copyright 2013 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_BASE("s3.amazonaws.com/Minecraft.Download/");
+const QString AWS_DOWNLOAD_VERSIONS(AWS_DOWNLOAD_BASE + "versions/");
+const QString AWS_DOWNLOAD_LIBRARIES(AWS_DOWNLOAD_BASE + "libraries/");
+const QString AWS_DOWNLOAD_INDEXES(AWS_DOWNLOAD_BASE + "indexes/");
+const QString ASSETS_BASE("assets.minecraft.net/");
+//const QString MCN_BASE("sonicrules.org/mcnweb.py");
+const QString RESOURCE_BASE("resources.download.minecraft.net/");
+const QString LIBRARY_BASE("libraries.minecraft.net/");
+const QString SKINS_BASE("skins.minecraft.net/MinecraftSkins/");
+const QString AUTH_BASE("authserver.mojang.com/");
+}