Use the central URL list for forge URLs

This commit is contained in:
Petr Mrázek 2013-12-23 00:43:29 +01:00
parent 56aeaec7d6
commit f402001453
2 changed files with 23 additions and 22 deletions

View File

@ -15,6 +15,7 @@
#include "ForgeVersionList.h" #include "ForgeVersionList.h"
#include <logic/net/NetJob.h> #include <logic/net/NetJob.h>
#include <logic/net/URLConstants.h>
#include "MultiMC.h" #include "MultiMC.h"
#include <QtNetwork> #include <QtNetwork>
@ -23,9 +24,6 @@
#include "logger/QsLog.h" #include "logger/QsLog.h"
#define JSON_URL "http://files.minecraftforge.net/minecraftforge/json"
#define GRADLE_JSON_URL "http://files.minecraftforge.net/maven/net/minecraftforge/forge/json"
ForgeVersionList::ForgeVersionList(QObject *parent) : BaseVersionList(parent) ForgeVersionList::ForgeVersionList(QObject *parent) : BaseVersionList(parent)
{ {
} }
@ -170,8 +168,10 @@ void ForgeListLoadTask::executeTask()
forgeListEntry->stale = true; forgeListEntry->stale = true;
gradleForgeListEntry->stale = true; gradleForgeListEntry->stale = true;
job->addNetAction(listDownload = CacheDownload::make(QUrl(JSON_URL), forgeListEntry)); job->addNetAction(listDownload = CacheDownload::make(QUrl(URLConstants::FORGE_LEGACY_URL),
job->addNetAction(gradleListDownload = CacheDownload::make(QUrl(GRADLE_JSON_URL), gradleForgeListEntry)); forgeListEntry));
job->addNetAction(gradleListDownload = CacheDownload::make(
QUrl(URLConstants::FORGE_GRADLE_URL), gradleForgeListEntry));
connect(listDownload.get(), SIGNAL(failed(int)), SLOT(listFailed())); connect(listDownload.get(), SIGNAL(failed(int)), SLOT(listFailed()));
connect(gradleListDownload.get(), SIGNAL(failed(int)), SLOT(gradleListFailed())); connect(gradleListDownload.get(), SIGNAL(failed(int)), SLOT(gradleListFailed()));
@ -355,33 +355,32 @@ bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out)
} }
if (file.at(1).toString() == "installer") if (file.at(1).toString() == "installer")
{ {
fVersion->installer_url = fVersion->installer_url = QString("%1/%2-%3/%4-%2-%3-installer.%5").arg(
QString("%1/%2-%3/%4-%2-%3-installer.%5") webpath, fVersion->mcver, fVersion->jobbuildver, artifact,
.arg(webpath, fVersion->mcver, fVersion->jobbuildver, artifact, file.at(0).toString()); file.at(0).toString());
installer_filename = QString("%1-%2-%3-installer.%4") installer_filename = QString("%1-%2-%3-installer.%4").arg(
.arg(artifact, fVersion->mcver, fVersion->jobbuildver, file.at(0).toString()); artifact, fVersion->mcver, fVersion->jobbuildver, file.at(0).toString());
} }
else if (file.at(1).toString() == "universal") else if (file.at(1).toString() == "universal")
{ {
fVersion->universal_url = fVersion->universal_url = QString("%1/%2-%3/%4-%2-%3-universal.%5").arg(
QString("%1/%2-%3/%4-%2-%3-universal.%5") webpath, fVersion->mcver, fVersion->jobbuildver, artifact,
.arg(webpath, fVersion->mcver, fVersion->jobbuildver, artifact, file.at(0).toString()); file.at(0).toString());
filename = QString("%1-%2-%3-universal.%4") filename = QString("%1-%2-%3-universal.%4").arg(
.arg(artifact, fVersion->mcver, fVersion->jobbuildver, file.at(0).toString()); artifact, fVersion->mcver, fVersion->jobbuildver, file.at(0).toString());
} }
else if (file.at(1).toString() == "changelog") else if (file.at(1).toString() == "changelog")
{ {
fVersion->changelog_url = fVersion->changelog_url = QString("%1/%2-%3/%4-%2-%3-changelog.%5").arg(
QString("%1/%2-%3/%4-%2-%3-changelog.%5") webpath, fVersion->mcver, fVersion->jobbuildver, artifact,
.arg(webpath, fVersion->mcver, fVersion->jobbuildver, artifact, file.at(0).toString()); file.at(0).toString());
} }
} }
if (fVersion->installer_url.isEmpty() && fVersion->universal_url.isEmpty()) if (fVersion->installer_url.isEmpty() && fVersion->universal_url.isEmpty())
{ {
continue; continue;
} }
fVersion->filename = fVersion->installer_url.isEmpty() ? fVersion->filename = fVersion->installer_url.isEmpty() ? filename : installer_filename;
filename : installer_filename;
out.append(fVersion); out.append(fVersion);
} }
@ -406,8 +405,8 @@ void ForgeListLoadTask::listDownloaded()
return; return;
} }
qSort(list.begin(), list.end(), qSort(list.begin(), list.end(), [](const BaseVersionPtr & p1, const BaseVersionPtr & p2)
[](const BaseVersionPtr &p1, const BaseVersionPtr &p2) { {
// TODO better comparison (takes major/minor/build number into account) // TODO better comparison (takes major/minor/build number into account)
return p1->name() > p2->name(); return p1->name() > p2->name();
}); });

View File

@ -29,4 +29,6 @@ const QString RESOURCE_BASE("resources.download.minecraft.net/");
const QString LIBRARY_BASE("libraries.minecraft.net/"); const QString LIBRARY_BASE("libraries.minecraft.net/");
const QString SKINS_BASE("skins.minecraft.net/MinecraftSkins/"); const QString SKINS_BASE("skins.minecraft.net/MinecraftSkins/");
const QString AUTH_BASE("authserver.mojang.com/"); const QString AUTH_BASE("authserver.mojang.com/");
const QString FORGE_LEGACY_URL("http://files.minecraftforge.net/minecraftforge/json");
const QString FORGE_GRADLE_URL("http://files.minecraftforge.net/maven/net/minecraftforge/forge/json");
} }