summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-04-07 00:27:24 +0200
committerPetr Mrázek <peterix@gmail.com>2017-04-07 00:27:24 +0200
commit795889d934e8f4ebe89be1a49a3417fd98e89be1 (patch)
treec5b0d30d425003c4b88e84a2908e63eb5ed797b9
parent160b5033a79e6b5ee9f3e2a001b96c677f41ddcb (diff)
parent8e58d61150b0bdbe9eb91065d36342f3004fe97b (diff)
downloadMultiMC-795889d934e8f4ebe89be1a49a3417fd98e89be1.tar
MultiMC-795889d934e8f4ebe89be1a49a3417fd98e89be1.tar.gz
MultiMC-795889d934e8f4ebe89be1a49a3417fd98e89be1.tar.lz
MultiMC-795889d934e8f4ebe89be1a49a3417fd98e89be1.tar.xz
MultiMC-795889d934e8f4ebe89be1a49a3417fd98e89be1.zip
Merge branch 'feature/meta' into develop
-rw-r--r--CMakeLists.txt1
-rw-r--r--api/logic/BaseInstance.cpp1
-rw-r--r--api/logic/BaseVersionList.cpp9
-rw-r--r--api/logic/BaseVersionList.h20
-rw-r--r--api/logic/CMakeLists.txt61
-rw-r--r--api/logic/Env.cpp27
-rw-r--r--api/logic/Env.h11
-rw-r--r--api/logic/InstanceCreationTask.cpp4
-rw-r--r--api/logic/ProblemProvider.h61
-rw-r--r--api/logic/Version.cpp57
-rw-r--r--api/logic/Version.h4
-rw-r--r--api/logic/Version_test.cpp38
-rw-r--r--api/logic/java/JavaInstallList.cpp2
-rw-r--r--api/logic/java/JavaInstallList.h18
-rw-r--r--api/logic/java/JavaVersion.h8
-rw-r--r--api/logic/meta/BaseEntity.cpp153
-rw-r--r--api/logic/meta/BaseEntity.h74
-rw-r--r--api/logic/meta/Index.cpp (renamed from api/logic/wonko/WonkoIndex.cpp)67
-rw-r--r--api/logic/meta/Index.h (renamed from api/logic/wonko/WonkoIndex.h)35
-rw-r--r--api/logic/meta/Index_test.cpp44
-rw-r--r--api/logic/meta/JsonFormat.cpp150
-rw-r--r--api/logic/meta/JsonFormat.h (renamed from api/logic/wonko/WonkoUtil.h)29
-rw-r--r--api/logic/meta/Version.cpp125
-rw-r--r--api/logic/meta/Version.h (renamed from api/logic/wonko/WonkoVersion.h)82
-rw-r--r--api/logic/meta/VersionList.cpp235
-rw-r--r--api/logic/meta/VersionList.h (renamed from api/logic/wonko/WonkoVersionList.h)68
-rw-r--r--api/logic/minecraft/Library.cpp23
-rw-r--r--api/logic/minecraft/Library_test.cpp2
-rw-r--r--api/logic/minecraft/MinecraftInstance.cpp7
-rw-r--r--api/logic/minecraft/MinecraftProfile.cpp39
-rw-r--r--api/logic/minecraft/MinecraftProfile.h12
-rw-r--r--api/logic/minecraft/MinecraftVersion.cpp230
-rw-r--r--api/logic/minecraft/MinecraftVersion.h132
-rw-r--r--api/logic/minecraft/MinecraftVersionList.cpp677
-rw-r--r--api/logic/minecraft/MinecraftVersionList.h73
-rw-r--r--api/logic/minecraft/MojangVersionFormat.cpp21
-rw-r--r--api/logic/minecraft/ProfilePatch.cpp175
-rw-r--r--api/logic/minecraft/ProfilePatch.h136
-rw-r--r--api/logic/minecraft/ProfileStrategy.h1
-rw-r--r--api/logic/minecraft/ProfileUtils.cpp6
-rw-r--r--api/logic/minecraft/VersionBuildError.h17
-rw-r--r--api/logic/minecraft/VersionFile.cpp42
-rw-r--r--api/logic/minecraft/VersionFile.h121
-rw-r--r--api/logic/minecraft/VersionFilterData.cpp11
-rw-r--r--api/logic/minecraft/VersionFilterData.h4
-rw-r--r--api/logic/minecraft/forge/ForgeInstaller.cpp458
-rw-r--r--api/logic/minecraft/forge/ForgeInstaller.h52
-rw-r--r--api/logic/minecraft/forge/ForgeVersion.cpp55
-rw-r--r--api/logic/minecraft/forge/ForgeVersion.h42
-rw-r--r--api/logic/minecraft/forge/ForgeVersionList.cpp333
-rw-r--r--api/logic/minecraft/forge/ForgeVersionList.h90
-rw-r--r--api/logic/minecraft/forge/LegacyForge.cpp56
-rw-r--r--api/logic/minecraft/forge/LegacyForge.h25
-rw-r--r--api/logic/minecraft/ftb/FTBInstanceProvider.cpp14
-rw-r--r--api/logic/minecraft/ftb/FTBPlugin.cpp2
-rw-r--r--api/logic/minecraft/ftb/FTBProfileStrategy.cpp13
-rw-r--r--api/logic/minecraft/ftb/FTBVersion.h32
-rw-r--r--api/logic/minecraft/legacy/LegacyUpdate.cpp1
-rw-r--r--api/logic/minecraft/legacy/LwjglVersionList.cpp5
-rw-r--r--api/logic/minecraft/legacy/LwjglVersionList.h4
-rw-r--r--api/logic/minecraft/liteloader/LiteLoaderInstaller.cpp106
-rw-r--r--api/logic/minecraft/liteloader/LiteLoaderInstaller.h39
-rw-r--r--api/logic/minecraft/liteloader/LiteLoaderVersionList.cpp332
-rw-r--r--api/logic/minecraft/liteloader/LiteLoaderVersionList.h123
-rw-r--r--api/logic/minecraft/onesix/OneSixInstance.cpp66
-rw-r--r--api/logic/minecraft/onesix/OneSixInstance.h4
-rw-r--r--api/logic/minecraft/onesix/OneSixProfileStrategy.cpp226
-rw-r--r--api/logic/minecraft/onesix/OneSixUpdate.cpp49
-rw-r--r--api/logic/minecraft/onesix/OneSixVersionFormat.cpp32
-rw-r--r--api/logic/minecraft/onesix/update/LibrariesTask.cpp18
-rw-r--r--api/logic/wonko/BaseWonkoEntity.cpp39
-rw-r--r--api/logic/wonko/BaseWonkoEntity.h51
-rw-r--r--api/logic/wonko/WonkoIndex_test.cpp50
-rw-r--r--api/logic/wonko/WonkoReference.cpp44
-rw-r--r--api/logic/wonko/WonkoReference.h41
-rw-r--r--api/logic/wonko/WonkoUtil.cpp47
-rw-r--r--api/logic/wonko/WonkoVersion.cpp102
-rw-r--r--api/logic/wonko/WonkoVersionList.cpp283
-rw-r--r--api/logic/wonko/format/WonkoFormat.cpp80
-rw-r--r--api/logic/wonko/format/WonkoFormat.h54
-rw-r--r--api/logic/wonko/format/WonkoFormatV1.cpp158
-rw-r--r--api/logic/wonko/format/WonkoFormatV1.h30
-rw-r--r--api/logic/wonko/tasks/BaseWonkoEntityLocalLoadTask.cpp117
-rw-r--r--api/logic/wonko/tasks/BaseWonkoEntityLocalLoadTask.h81
-rw-r--r--api/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp126
-rw-r--r--api/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.h90
-rw-r--r--application/BuildConfig.cpp.in1
-rw-r--r--application/BuildConfig.h5
-rw-r--r--application/CMakeLists.txt12
-rw-r--r--application/MainWindow.cpp28
-rw-r--r--application/MainWindow.h1
-rw-r--r--application/MultiMC.cpp36
-rw-r--r--application/MultiMC.h9
-rw-r--r--application/VersionProxyModel.cpp20
-rw-r--r--application/WonkoGui.cpp74
-rw-r--r--application/WonkoGui.h29
-rw-r--r--application/dialogs/NewInstanceDialog.cpp41
-rw-r--r--application/dialogs/NewInstanceDialog.h4
-rw-r--r--application/main.cpp1
-rw-r--r--application/pages/VersionPage.cpp130
-rw-r--r--application/pages/global/PackagesPage.cpp (renamed from application/pages/global/WonkoPage.cpp)117
-rw-r--r--application/pages/global/PackagesPage.h (renamed from application/pages/global/WonkoPage.h)14
-rw-r--r--application/pages/global/PackagesPage.ui (renamed from application/pages/global/WonkoPage.ui)12
-rw-r--r--application/resources/versions/LWJGL/2.9.0.json45
-rw-r--r--application/resources/versions/LWJGL/2.9.1-nightly-20130708-debug3.json45
-rw-r--r--application/resources/versions/LWJGL/2.9.1.json45
-rw-r--r--application/resources/versions/LWJGL/2.9.2-nightly-20140822.json45
-rw-r--r--application/resources/versions/minecraft.json587
-rw-r--r--application/resources/versions/versions.qrc12
-rw-r--r--application/widgets/VersionSelectWidget.cpp46
-rw-r--r--application/widgets/VersionSelectWidget.h5
-rw-r--r--wonkoclient/CMakeLists.txt10
-rw-r--r--wonkoclient/WonkoClient.cpp84
-rw-r--r--wonkoclient/WonkoClient.h36
-rw-r--r--wonkoclient/main.cpp29
115 files changed, 1850 insertions, 6356 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d3dcac78..86f8e20a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,4 +109,3 @@ add_subdirectory(api/logic)
add_subdirectory(api/gui)
add_subdirectory(application)
-add_subdirectory(wonkoclient)
diff --git a/api/logic/BaseInstance.cpp b/api/logic/BaseInstance.cpp
index 6d719c32..ee9e919d 100644
--- a/api/logic/BaseInstance.cpp
+++ b/api/logic/BaseInstance.cpp
@@ -23,7 +23,6 @@
#include "settings/Setting.h"
#include "settings/OverrideSetting.h"
-#include "minecraft/MinecraftVersionList.h"
#include "FileSystem.h"
#include "Commandline.h"
diff --git a/api/logic/BaseVersionList.cpp b/api/logic/BaseVersionList.cpp
index 5ad4df3c..8b424c11 100644
--- a/api/logic/BaseVersionList.cpp
+++ b/api/logic/BaseVersionList.cpp
@@ -30,7 +30,7 @@ BaseVersionPtr BaseVersionList::findVersion(const QString &descriptor)
return BaseVersionPtr();
}
-BaseVersionPtr BaseVersionList::getLatestStable() const
+BaseVersionPtr BaseVersionList::getRecommended() const
{
if (count() <= 0)
return BaseVersionPtr();
@@ -38,11 +38,6 @@ BaseVersionPtr BaseVersionList::getLatestStable() const
return at(0);
}
-BaseVersionPtr BaseVersionList::getRecommended() const
-{
- return getLatestStable();
-}
-
QVariant BaseVersionList::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
@@ -93,7 +88,7 @@ QHash<int, QByteArray> BaseVersionList::roleNames() const
QHash<int, QByteArray> roles = QAbstractListModel::roleNames();
roles.insert(VersionRole, "version");
roles.insert(VersionIdRole, "versionId");
- roles.insert(ParentGameVersionRole, "parentGameVersion");
+ roles.insert(ParentVersionRole, "parentGameVersion");
roles.insert(RecommendedRole, "recommended");
roles.insert(LatestRole, "latest");
roles.insert(TypeRole, "type");
diff --git a/api/logic/BaseVersionList.h b/api/logic/BaseVersionList.h
index eadc6933..655bbd43 100644
--- a/api/logic/BaseVersionList.h
+++ b/api/logic/BaseVersionList.h
@@ -22,6 +22,7 @@
#include "BaseVersion.h"
#include "tasks/Task.h"
#include "multimc_logic_export.h"
+#include "QObjectPtr.h"
/*!
* \brief Class that each instance type's version list derives from.
@@ -44,7 +45,7 @@ public:
VersionPointerRole = Qt::UserRole,
VersionRole,
VersionIdRole,
- ParentGameVersionRole,
+ ParentVersionRole,
RecommendedRole,
LatestRole,
TypeRole,
@@ -63,7 +64,7 @@ public:
* The task returned by this function should reset the model when it's done.
* \return A pointer to a task that reloads the version list.
*/
- virtual Task *getLoadTask() = 0;
+ virtual shared_qobject_ptr<Task> getLoadTask() = 0;
//! Checks whether or not the list is loaded. If this returns false, the list should be
//loaded.
@@ -76,28 +77,23 @@ public:
virtual int count() const = 0;
//////// List Model Functions ////////
- virtual QVariant data(const QModelIndex &index, int role) const;
- virtual int rowCount(const QModelIndex &parent) const;
- virtual int columnCount(const QModelIndex &parent) const;
- virtual QHash<int, QByteArray> roleNames() const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ int rowCount(const QModelIndex &parent) const override;
+ int columnCount(const QModelIndex &parent) const override;
+ virtual QHash<int, QByteArray> roleNames() const;
//! which roles are provided by this version list?
virtual RoleList providesRoles() const;
/*!
* \brief Finds a version by its descriptor.
- * \param The descriptor of the version to find.
+ * \param descriptor The descriptor of the version to find.
* \return A const pointer to the version with the given descriptor. NULL if
* one doesn't exist.
*/
virtual BaseVersionPtr findVersion(const QString &descriptor);
/*!
- * \brief Gets the latest stable version from this list
- */
- virtual BaseVersionPtr getLatestStable() const;
-
- /*!
* \brief Gets the recommended version from this list
* If the list doesn't support recommended versions, this works exactly as getLatestStable
*/
diff --git a/api/logic/CMakeLists.txt b/api/logic/CMakeLists.txt
index bcf4b65a..da673c13 100644
--- a/api/logic/CMakeLists.txt
+++ b/api/logic/CMakeLists.txt
@@ -252,10 +252,6 @@ set(MINECRAFT_SOURCES
minecraft/JarMod.h
minecraft/MinecraftInstance.cpp
minecraft/MinecraftInstance.h
- minecraft/MinecraftVersion.cpp
- minecraft/MinecraftVersion.h
- minecraft/MinecraftVersionList.cpp
- minecraft/MinecraftVersionList.h
minecraft/Rule.cpp
minecraft/Rule.h
minecraft/OpSys.cpp
@@ -271,6 +267,7 @@ set(MINECRAFT_SOURCES
minecraft/VersionBuildError.h
minecraft/VersionFile.cpp
minecraft/VersionFile.h
+ minecraft/ProfilePatch.cpp
minecraft/ProfilePatch.h
minecraft/VersionFilterData.h
minecraft/VersionFilterData.cpp
@@ -300,22 +297,10 @@ set(MINECRAFT_SOURCES
minecraft/AssetsUtils.cpp
# Forge and all things forge related
- minecraft/forge/ForgeVersion.h
- minecraft/forge/ForgeVersion.cpp
- minecraft/forge/ForgeVersionList.h
- minecraft/forge/ForgeVersionList.cpp
minecraft/forge/ForgeXzDownload.h
minecraft/forge/ForgeXzDownload.cpp
- minecraft/forge/LegacyForge.h
- minecraft/forge/LegacyForge.cpp
- minecraft/forge/ForgeInstaller.h
- minecraft/forge/ForgeInstaller.cpp
-
- # Liteloader and related things
- minecraft/liteloader/LiteLoaderInstaller.h
- minecraft/liteloader/LiteLoaderInstaller.cpp
- minecraft/liteloader/LiteLoaderVersionList.h
- minecraft/liteloader/LiteLoaderVersionList.cpp
+
+ # Skin upload utilities
minecraft/SkinUpload.cpp
minecraft/SkinUpload.h
)
@@ -430,32 +415,22 @@ set(TOOLS_SOURCES
tools/MCEditTool.h
)
-set(WONKO_SOURCES
- # Wonko
- wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp
- wonko/tasks/BaseWonkoEntityRemoteLoadTask.h
- wonko/tasks/BaseWonkoEntityLocalLoadTask.cpp
- wonko/tasks/BaseWonkoEntityLocalLoadTask.h
- wonko/format/WonkoFormatV1.cpp
- wonko/format/WonkoFormatV1.h
- wonko/format/WonkoFormat.cpp
- wonko/format/WonkoFormat.h
- wonko/BaseWonkoEntity.cpp
- wonko/BaseWonkoEntity.h
- wonko/WonkoVersionList.cpp
- wonko/WonkoVersionList.h
- wonko/WonkoVersion.cpp
- wonko/WonkoVersion.h
- wonko/WonkoIndex.cpp
- wonko/WonkoIndex.h
- wonko/WonkoUtil.cpp
- wonko/WonkoUtil.h
- wonko/WonkoReference.cpp
- wonko/WonkoReference.h
+set(META_SOURCES
+ # Metadata sources
+ meta/JsonFormat.cpp
+ meta/JsonFormat.h
+ meta/BaseEntity.cpp
+ meta/BaseEntity.h
+ meta/VersionList.cpp
+ meta/VersionList.h
+ meta/Version.cpp
+ meta/Version.h
+ meta/Index.cpp
+ meta/Index.h
)
-add_unit_test(WonkoIndex
- SOURCES wonko/WonkoIndex_test.cpp
+add_unit_test(Index
+ SOURCES meta/Index_test.cpp
LIBS MultiMC_logic
)
@@ -480,7 +455,7 @@ set(LOGIC_SOURCES
${JAVA_SOURCES}
${TRANSLATIONS_SOURCES}
${TOOLS_SOURCES}
- ${WONKO_SOURCES}
+ ${META_SOURCES}
${ICONS_SOURCES}
)
diff --git a/api/logic/Env.cpp b/api/logic/Env.cpp
index a6341ebd..d7be4a28 100644
--- a/api/logic/Env.cpp
+++ b/api/logic/Env.cpp
@@ -7,7 +7,7 @@
#include <QNetworkAccessManager>
#include <QDebug>
#include "tasks/Task.h"
-#include "wonko/WonkoIndex.h"
+#include "meta/Index.h"
#include <QDebug>
@@ -18,8 +18,7 @@ public:
shared_qobject_ptr<HttpMetaCache> m_metacache;
std::shared_ptr<IIconList> m_iconlist;
QMap<QString, std::shared_ptr<BaseVersionList>> m_versionLists;
- shared_qobject_ptr<WonkoIndex> m_wonkoIndex;
- QString m_wonkoRootUrl;
+ shared_qobject_ptr<Meta::Index> m_metadataIndex;
};
static Env * instance;
@@ -99,13 +98,13 @@ void Env::registerVersionList(QString name, std::shared_ptr< BaseVersionList > v
d->m_versionLists[name] = vlist;
}
-shared_qobject_ptr<WonkoIndex> Env::wonkoIndex()
+shared_qobject_ptr<Meta::Index> Env::metadataIndex()
{
- if (!d->m_wonkoIndex)
+ if (!d->m_metadataIndex)
{
- d->m_wonkoIndex.reset(new WonkoIndex());
+ d->m_metadataIndex.reset(new Meta::Index());
}
- return d->m_wonkoIndex;
+ return d->m_metadataIndex;
}
@@ -125,7 +124,7 @@ void Env::initHttpMetaCache()
m_metacache->addBase("root", QDir::currentPath());
m_metacache->addBase("translations", QDir("translations").absolutePath());
m_metacache->addBase("icons", QDir("cache/icons").absolutePath());
- m_metacache->addBase("wonko", QDir("cache/wonko").absolutePath());
+ m_metacache->addBase("meta", QDir("meta").absolutePath());
m_metacache->Load();
}
@@ -191,14 +190,4 @@ void Env::updateProxySettings(QString proxyTypeStr, QString addr, int port, QStr
qDebug() << proxyDesc;
}
-QString Env::wonkoRootUrl() const
-{
- return d->m_wonkoRootUrl;
-}
-
-void Env::setWonkoRootUrl(const QString& url)
-{
- d->m_wonkoRootUrl = url;
-}
-
-#include "Env.moc" \ No newline at end of file
+#include "Env.moc"
diff --git a/api/logic/Env.h b/api/logic/Env.h
index c72447ce..75ebe4a0 100644
--- a/api/logic/Env.h
+++ b/api/logic/Env.h
@@ -13,7 +13,11 @@ class QNetworkAccessManager;
class HttpMetaCache;
class BaseVersionList;
class BaseVersion;
-class WonkoIndex;
+
+namespace Meta
+{
+class Index;
+}
#if defined(ENV)
#undef ENV
@@ -53,10 +57,7 @@ public:
void registerIconList(std::shared_ptr<IIconList> iconlist);
- shared_qobject_ptr<WonkoIndex> wonkoIndex();
-
- QString wonkoRootUrl() const;
- void setWonkoRootUrl(const QString &url);
+ shared_qobject_ptr<Meta::Index> metadataIndex();
protected:
Private * d;
diff --git a/api/logic/InstanceCreationTask.cpp b/api/logic/InstanceCreationTask.cpp
index 00156701..e7b0de7c 100644
--- a/api/logic/InstanceCreationTask.cpp
+++ b/api/logic/InstanceCreationTask.cpp
@@ -4,7 +4,6 @@
#include "FileSystem.h"
//FIXME: remove this
-#include "minecraft/MinecraftVersion.h"
#include "minecraft/onesix/OneSixInstance.h"
InstanceCreationTask::InstanceCreationTask(SettingsObjectPtr settings, BaseInstanceProvider* target, BaseVersionPtr version,
@@ -21,12 +20,14 @@ InstanceCreationTask::InstanceCreationTask(SettingsObjectPtr settings, BaseInsta
void InstanceCreationTask::executeTask()
{
setStatus(tr("Creating instance from version %1").arg(m_version->name()));
+ /*
auto minecraftVersion = std::dynamic_pointer_cast<MinecraftVersion>(m_version);
if(!minecraftVersion)
{
emitFailed(tr("The supplied version is not a Minecraft version."));
return ;
}
+ */
QString stagingPath = m_target->getStagedInstancePath();
QDir rootDir(stagingPath);
@@ -34,7 +35,6 @@ void InstanceCreationTask::executeTask()
auto instanceSettings = std::make_shared<INISettingsObject>(FS::PathCombine(stagingPath, "instance.cfg"));
instanceSettings->registerSetting("InstanceType", "Legacy");
- auto mcVer = std::dynamic_pointer_cast<MinecraftVersion>(m_version);
instanceSettings->set("InstanceType", "OneSix");
InstancePtr inst(new OneSixInstance(m_globalSettings, instanceSettings, stagingPath));
inst->setIntendedVersionId(m_version->descriptor());
diff --git a/api/logic/ProblemProvider.h b/api/logic/ProblemProvider.h
new file mode 100644
index 00000000..b30e1776
--- /dev/null
+++ b/api/logic/ProblemProvider.h
@@ -0,0 +1,61 @@
+#pragma once
+
+enum class ProblemSeverity
+{
+ None,
+ Warning,
+ Error
+};
+
+class PatchProblem
+{
+public:
+ PatchProblem(ProblemSeverity severity, const QString & description)
+ {
+ m_severity = severity;
+ m_description = description;
+ }
+ const QString & getDescription() const
+ {
+ return m_description;
+ }
+ const ProblemSeverity getSeverity() const
+ {
+ return m_severity;
+ }
+private:
+ ProblemSeverity m_severity;
+ QString m_description;
+};
+
+class ProblemProvider
+{
+public:
+ virtual const QList<PatchProblem> getProblems() = 0;
+ virtual ProblemSeverity getProblemSeverity() = 0;
+};
+
+class ProblemContainer : public ProblemProvider
+{
+public:
+ const QList<PatchProblem> getProblems() override
+ {
+ return m_problems;
+ }
+ ProblemSeverity getProblemSeverity() override
+ {
+ return m_problemSeverity;
+ }
+ virtual void addProblem(ProblemSeverity severity, const QString &description)
+ {
+ if(severity > m_problemSeverity)
+ {
+ m_problemSeverity = severity;
+ }
+ m_problems.append(PatchProblem(severity, description));
+ }
+
+private:
+ QList<PatchProblem> m_problems;
+ ProblemSeverity m_problemSeverity = ProblemSeverity::None;
+};
diff --git a/api/logic/Version.cpp b/api/logic/Version.cpp
index 3c4727ad..2c83374f 100644
--- a/api/logic/Version.cpp
+++ b/api/logic/Version.cpp
@@ -75,6 +75,7 @@ void Version::parse()
{
m_sections.clear();
+ // FIXME: this is bad. versions can contain a lot more separators...
QStringList parts = m_string.split('.');
for (const auto part : parts)
@@ -82,59 +83,3 @@ void Version::parse()
m_sections.append(Section(part));
}
}
-
-bool versionIsInInterval(const QString &version, const QString &interval)
-{
- return versionIsInInterval(Version(version), interval);
-}
-bool versionIsInInterval(const Version &version, const QString &interval)
-{
- if (interval.isEmpty() || version.toString() == interval)
- {
- return true;
- }
-
- // Interval notation is used
- QRegularExpression exp(
- "(?<start>[\\[\\]\\(\\)])(?<bottom>.*?)(,(?<top>.*?))?(?<end>[\\[\\]\\(\\)]),?");
- QRegularExpressionMatch match = exp.match(interval);
- if (match.hasMatch())
- {
- const QChar start = match.captured("start").at(0);
- const QChar end = match.captured("end").at(0);
- const QString bottom = match.captured("bottom");
- const QString top = match.captured("top");
-
- // check if in range (bottom)
- if (!bottom.isEmpty())
- {
- const auto bottomVersion = Version(bottom);
- if ((start == '[') && !(version >= bottomVersion))
- {
- return false;
- }
- else if ((start == '(') && !(version > bottomVersion))
- {
- return false;
- }
- }
-
- // check if in range (top)
- if (!top.isEmpty())
- {
- const auto topVersion = Version(top);
- if ((end == ']') && !(version <= topVersion))
- {
- return false;
- }
- else if ((end == ')') && !(version < topVersion))
- {
- return false;
- }
- }
-
- return true;
- }
-
- return false;
-}
diff --git a/api/logic/Version.h b/api/logic/Version.h
index b5946ced..08dfb6e9 100644
--- a/api/logic/Version.h
+++ b/api/logic/Version.h
@@ -104,7 +104,3 @@ private:
void parse();
};
-
-MULTIMC_LOGIC_EXPORT bool versionIsInInterval(const QString &version, const QString &interval);
-MULTIMC_LOGIC_EXPORT bool versionIsInInterval(const Version &version, const QString &interval);
-
diff --git a/api/logic/Version_test.cpp b/api/logic/Version_test.cpp
index aa6cb4dd..1e7920ad 100644
--- a/api/logic/Version_test.cpp
+++ b/api/logic/Version_test.cpp
@@ -60,44 +60,6 @@ private slots:
}
- void test_versionIsInInterval_data()
- {
- QTest::addColumn<QString>("version");
- QTest::addColumn<QString>("interval");
- QTest::addColumn<bool>("result");
-
- QTest::newRow("empty, true") << "1.2.3" << "" << true;
- QTest::newRow("one version, true") << "1.2.3" << "1.2.3" << true;
- QTest::newRow("one version, false") << "1.2.3" << "1.2.2" << false;
-
- QTest::newRow("one version inclusive <-> infinity, true") << "1.2.3" << "[1.2.3,)" << true;
- QTest::newRow("one version exclusive <-> infinity, true") << "1.2.3" << "(1.2.2,)" << true;
- QTest::newRow("one version inclusive <-> infitity, false") << "1.2.3" << "[1.2.4,)" << false;
- QTest::newRow("one version exclusive <-> infinity, false") << "1.2.3" << "(1.2.3,)" << false;
-
- QTest::newRow("infinity <-> one version inclusive, true") << "1.2.3" << "(,1.2.3]" << true;
- QTest::newRow("infinity <-> one version exclusive, true") << "1.2.3" << "(,1.2.4)" << true;
- QTest::newRow("infinity <-> one version inclusive, false") << "1.2.3" << "(,1.2.2]" << false;
- QTest::newRow("infinity <-> one version exclusive, false") << "1.2.3" << "(,1.2.3)" << false;
-
- QTest::newRow("inclusive <-> inclusive, true") << "1.2.3" << "[1.2.2,1.2.3]" << true;
- QTest::newRow("inclusive <-> exclusive, true") << "1.2.3" << "[1.2.3,1.2.4)" << true;
- QTest::newRow("exclusive <-> inclusive, true") << "1.2.3" << "(1.2.2,1.2.3]" << true;
- QTest::newRow("exclusive <-> exclusive, true") << "1.2.3" << "(1.2.2,1.2.4)" << true;
- QTest::newRow("inclusive <-> inclusive, false") << "1.2.3" << "[1.0.0,1.2.2]" << false;
- QTest::newRow("inclusive <-> exclusive, false") << "1.2.3" << "[1.0.0,1.2.3)" << false;
- QTest::newRow("exclusive <-> inclusive, false") << "1.2.3" << "(1.2.3,2.0.0]" << false;
- QTest::newRow("exclusive <-> exclusive, false") << "1.2.3" << "(1.0.0,1.2.3)" << false;
- }
- void test_versionIsInInterval()
- {
- QFETCH(QString, version);
- QFETCH(QString, interval);
- QFETCH(bool, result);
-
- QCOMPARE(versionIsInInterval(version, interval), result);
- }
-
void test_versionCompare_data()
{
setupVersions();
diff --git a/api/logic/java/JavaInstallList.cpp b/api/logic/java/JavaInstallList.cpp
index c98ef279..dbf66f5f 100644
--- a/api/logic/java/JavaInstallList.cpp
+++ b/api/logic/java/JavaInstallList.cpp
@@ -29,7 +29,7 @@ JavaInstallList::JavaInstallList(QObject *parent) : BaseVersionList(parent)
{
}
-Task *JavaInstallList::getLoadTask()
+shared_qobject_ptr<Task> JavaInstallList::getLoadTask()
{
return new JavaListLoadTask(this);
}
diff --git a/api/logic/java/JavaInstallList.h b/api/logic/java/JavaInstallList.h
index 2055d154..afc5ef43 100644
--- a/api/logic/java/JavaInstallList.h
+++ b/api/logic/java/JavaInstallList.h
@@ -34,17 +34,17 @@ class MULTIMC_LOGIC_EXPORT JavaInstallList : public BaseVersionList
public:
explicit JavaInstallList(QObject *parent = 0);
- virtual Task *getLoadTask() override;
- virtual bool isLoaded() override;
- virtual const BaseVersionPtr at(int i) const override;
- virtual int count() const override;
- virtual void sortVersions() override;
+ shared_qobject_ptr<Task> getLoadTask() override;
+ bool isLoaded() override;
+ const BaseVersionPtr at(int i) const override;
+ int count() const override;
+ void sortVersions() override;
- virtual QVariant data(const QModelIndex &index, int role) const override;
- virtual RoleList providesRoles() const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ RoleList providesRoles() const override;
public slots:
- virtual void updateListData(QList<BaseVersionPtr> versions) override;
+ void updateListData(QList<BaseVersionPtr> versions) override;
protected:
QList<BaseVersionPtr> m_vlist;
@@ -60,7 +60,7 @@ public:
explicit JavaListLoadTask(JavaInstallList *vlist);
~JavaListLoadTask();
- virtual void executeTask();
+ void executeTask() override;
public slots:
void javaCheckerFinished(QList<JavaCheckResult> results);
diff --git a/api/logic/java/JavaVersion.h b/api/logic/java/JavaVersion.h
index deba5654..de13998c 100644
--- a/api/logic/java/JavaVersion.h
+++ b/api/logic/java/JavaVersion.h
@@ -3,6 +3,14 @@
#include "multimc_logic_export.h"
#include <QString>
+// NOTE: apparently the GNU C library pollutes the global namespace with these... undef them.
+#ifdef major
+ #undef major
+#endif
+#ifdef minor
+ #undef minor
+#endif
+
class MULTIMC_LOGIC_EXPORT JavaVersion
{
friend class JavaVersionTest;
diff --git a/api/logic/meta/BaseEntity.cpp b/api/logic/meta/BaseEntity.cpp
new file mode 100644
index 00000000..633afab2
--- /dev/null
+++ b/api/logic/meta/BaseEntity.cpp
@@ -0,0 +1,153 @@
+/* Copyright 2015-2017 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.
+ */
+
+#include "BaseEntity.h"
+
+#include "Json.h"
+
+#include "net/Download.h"
+#include "net/HttpMetaCache.h"
+#include "net/NetJob.h"
+
+#include "Env.h"
+#include "Json.h"
+
+class ParsingValidator : public Net::Validator
+{
+public: /* con/des */
+ ParsingValidator(Meta::BaseEntity *entity) : m_entity(entity)
+ {
+ };
+ virtual ~ParsingValidator()
+ {
+ };
+
+public: /* methods */
+ bool init(QNetworkRequest &) override
+ {
+ return true;
+ }
+ bool write(QByteArray & data) override
+ {
+ this->data.append(data);
+ return true;
+ }
+ bool abort() override
+ {
+ return true;
+ }
+ bool validate(QNetworkReply &) override
+ {
+ auto fname = m_entity->localFilename();
+ try
+ {
+ m_entity->parse(Json::requireObject(Json::requireDocument(data, fname), fname));
+ return true;
+ }
+ catch (Exception &e)
+ {
+ qWarning() << "Unable to parse response:" << e.cause();
+ return false;
+ }
+ }
+
+private: /* data */
+ QByteArray data;
+ Meta::BaseEntity *m_entity;
+};
+
+Meta::BaseEntity::~BaseEntity()
+{
+}
+
+QUrl Meta::BaseEntity::url() const
+{
+ return QUrl("https://meta.multimc.org").resolved(localFilename());
+}
+
+bool Meta::BaseEntity::loadLocalFile()
+{
+ const QString fname = QDir("meta").absoluteFilePath(localFilename());
+ if (!QFile::exists(fname))
+ {
+ return false;
+ }
+ // TODO: check if the file has the expected checksum
+ try
+ {
+ parse(Json::requireObject(Json::requireDocument(fname, fname), fname));
+ return true;
+ }
+ catch (Exception &e)
+ {
+ qDebug() << QString("Unable to parse file %1: %2").arg(fname, e.cause());
+ // just make sure it's gone and we never consider it again.
+ QFile::remove(fname);
+ return false;
+ }
+}
+
+void Meta::BaseEntity::load()
+{
+ // load local file if nothing is loaded yet
+ if(!isLoaded())
+ {
+ if(loadLocalFile())
+ {
+ m_loadStatus = LoadStatus::Local;
+ }
+ }
+ // if we need remote update, run the update task
+ if(!shouldStartRemoteUpdate())
+ {
+ return;
+ }
+ NetJob *job = new NetJob(QObject::tr("Download of meta file %1").arg(localFilename()));
+ auto url = this->url();
+ auto entry = ENV.metacache()->resolveEntry("meta", localFilename());
+ entry->setStale(true);
+ auto dl = Net::Download::makeCached(url, entry);
+ /*
+ * The validator parses the file and loads it into the object.
+ * If that fails, the file is not written to storage.
+ */
+ dl->addValidator(new ParsingValidator(this));
+ job->addNetAction(dl);
+ m_updateStatus = UpdateStatus::InProgress;
+ m_updateTask.reset(job);
+ QObject::connect(job, &NetJob::succeeded, [&]()
+ {
+ m_loadStatus = LoadStatus::Remote;
+ m_updateStatus = UpdateStatus::Succeeded;
+ m_updateTask.reset();
+ });
+ QObject::connect(job, &NetJob::failed, [&]()
+ {
+ m_updateStatus = UpdateStatus::Failed;
+ m_updateTask.reset();
+ });
+ m_updateTask->start();
+}
+
+shared_qobject_ptr<Task> Meta::BaseEntity::getCurrentTask()
+{
+ if(m_updateStatus == UpdateStatus::InProgress)
+ {
+ return m_updateTask;
+ }
+ return nullptr;
+}
+
+#include "BaseEntity.moc"
diff --git a/api/logic/meta/BaseEntity.h b/api/logic/meta/BaseEntity.h
new file mode 100644
index 00000000..85051d97
--- /dev/null
+++ b/api/logic/meta/BaseEntity.h
@@ -0,0 +1,74 @@
+/* Copyright 2015-2017 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 <QJsonObject>
+#include <QObject>
+#include "QObjectPtr.h"
+
+#include "multimc_logic_export.h"
+
+class Task;
+namespace Meta
+{
+class MULTIMC_LOGIC_EXPORT BaseEntity
+{
+public: /* types */
+ using Ptr = std::shared_ptr<BaseEntity>;
+ enum class LoadStatus
+ {
+ NotLoaded,
+ Local,
+ Remote
+ };
+ enum class UpdateStatus
+ {
+ NotDone,
+ InProgress,
+ Failed,
+ Succeeded
+ };
+
+public:
+ virtual ~BaseEntity();
+
+ virtual void merge(const std::shared_ptr<BaseEntity> &other) = 0;
+ virtual void parse(const QJsonObject &obj) = 0;
+
+ virtual QString localFilename() const = 0;
+ virtual QUrl url() const;
+
+ bool isLoaded() const
+ {
+ return m_loadStatus > LoadStatus::NotLoaded;
+ }
+ bool shouldStartRemoteUpdate() const
+ {
+ return m_updateStatus == UpdateStatus::NotDone;
+ }
+
+ void load();
+ shared_qobject_ptr<Task> getCurrentTask();
+
+protected: /* methods */
+ bool loadLocalFile();
+
+private:
+ LoadStatus m_loadStatus = LoadStatus::NotLoaded;
+ UpdateStatus m_updateStatus = UpdateStatus::NotDone;
+ shared_qobject_ptr<Task> m_updateTask;
+};
+}
diff --git a/api/logic/wonko/WonkoIndex.cpp b/api/logic/meta/Index.cpp
index f6ad201a..0749651a 100644
--- a/api/logic/wonko/WonkoIndex.cpp
+++ b/api/logic/meta/Index.cpp
@@ -13,18 +13,18 @@
* limitations under the License.
*/
-#include "WonkoIndex.h"
+#include "Index.h"
-#include "WonkoVersionList.h"
-#include "tasks/BaseWonkoEntityLocalLoadTask.h"
-#include "tasks/BaseWonkoEntityRemoteLoadTask.h"
-#include "format/WonkoFormat.h"
+#include "VersionList.h"
+#include "JsonFormat.h"
-WonkoIndex::WonkoIndex(QObject *parent)
+namespace Meta
+{
+Index::Index(QObject *parent)
: QAbstractListModel(parent)
{
}
-WonkoIndex::WonkoIndex(const QVector<WonkoVersionListPtr> &lists, QObject *parent)
+Index::Index(const QVector<VersionListPtr> &lists, QObject *parent)
: QAbstractListModel(parent), m_lists(lists)
{
for (int i = 0; i < m_lists.size(); ++i)
@@ -34,14 +34,14 @@ WonkoIndex::WonkoIndex(const QVector<WonkoVersionListPtr> &lists, QObject *paren
}
}
-QVariant WonkoIndex::data(const QModelIndex &index, int role) const
+QVariant Index::data(const QModelIndex &index, int role) const
{
if (index.parent().isValid() || index.row() < 0 || index.row() >= m_lists.size())
{
return QVariant();
}
- WonkoVersionListPtr list = m_lists.at(index.row());
+ VersionListPtr list = m_lists.at(index.row());
switch (role)
{
case Qt::DisplayRole:
@@ -56,15 +56,15 @@ QVariant WonkoIndex::data(const QModelIndex &index, int role) const
}
return QVariant();
}
-int WonkoIndex::rowCount(const QModelIndex &parent) const
+int Index::rowCount(const QModelIndex &parent) const
{
return m_lists.size();
}
-int WonkoIndex::columnCount(const QModelIndex &parent) const
+int Index::columnCount(const QModelIndex &parent) const
{
return 1;
}
-QVariant WonkoIndex::headerData(int section, Qt::Orientation orientation, int role) const
+QVariant Index::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole && section == 0)
{
@@ -76,36 +76,36 @@ QVariant WonkoIndex::headerData(int section, Qt::Orientation orientation, int ro
}
}
-std::unique_ptr<Task> WonkoIndex::remoteUpdateTask()
-{
- return std::unique_ptr<WonkoIndexRemoteLoadTask>(new WonkoIndexRemoteLoadTask(this, this));
-}
-std::unique_ptr<Task> WonkoIndex::localUpdateTask()
+bool Index::hasUid(const QString &uid) const
{
- return std::unique_ptr<WonkoIndexLocalLoadTask>(new WonkoIndexLocalLoadTask(this, this));
+ return m_uids.contains(uid);
}
-QJsonObject WonkoIndex::serialized() const
+VersionListPtr Index::get(const QString &uid)
{
- return WonkoFormat::serializeIndex(this);
+ VersionListPtr out = m_uids.value(uid, nullptr);
+ if(!out)
+ {
+ out = std::make_shared<VersionList>(uid);
+ m_uids[uid] = out;
+ }
+ return out;
}
-bool WonkoIndex::hasUid(const QString &uid) const
+VersionPtr Index::get(const QString &uid, const QString &version)
{
- return m_uids.contains(uid);
-}
-WonkoVersionListPtr WonkoIndex::getList(const QString &uid) const
-{
- return m_uids.value(uid, nullptr);
+ auto list = get(uid);
+ return list->getVersion(version);
}
-WonkoVersionListPtr WonkoIndex::getListGuaranteed(const QString &uid) const
+
+void Index::parse(const QJsonObject& obj)
{
- return m_uids.value(uid, std::make_shared<WonkoVersionList>(uid));
+ parseIndex(obj, this);
}
-void WonkoIndex::merge(const Ptr &other)
+void Index::merge(const Ptr &other)
{
- const QVector<WonkoVersionListPtr> lists = std::dynamic_pointer_cast<WonkoIndex>(other)->m_lists;
+ const QVector<VersionListPtr> lists = std::dynamic_pointer_cast<Index>(other)->m_lists;
// initial load, no need to merge
if (m_lists.isEmpty())
{
@@ -120,7 +120,7 @@ void WonkoIndex::merge(const Ptr &other)
}
else
{
- for (const WonkoVersionListPtr &list : lists)
+ for (const VersionListPtr &list : lists)
{
if (m_uids.contains(list->uid()))
{
@@ -138,10 +138,11 @@ void WonkoIndex::merge(const Ptr &other)
}
}
-void WonkoIndex::connectVersionList(const int row, const WonkoVersionListPtr &list)
+void Index::connectVersionList(const int row, const VersionListPtr &list)
{
- connect(list.get(), &WonkoVersionList::nameChanged, this, [this, row]()
+ connect(list.get(), &VersionList::nameChanged, this, [this, row]()
{
emit dataChanged(index(row), index(row), QVector<int>() << Qt::DisplayRole);
});
}
+}
diff --git a/api/logic/wonko/WonkoIndex.h b/api/logic/meta/Index.h
index fe07c3ef..9811e152 100644
--- a/api/logic/wonko/WonkoIndex.h
+++ b/api/logic/meta/Index.h
@@ -18,19 +18,23 @@
#include <QAbstractListModel>
#include <memory>
-#include "BaseWonkoEntity.h"
+#include "BaseEntity.h"
#include "multimc_logic_export.h"
class Task;
-using WonkoVersionListPtr = std::shared_ptr<class WonkoVersionList>;
-class MULTIMC_LOGIC_EXPORT WonkoIndex : public QAbstractListModel, public BaseWonkoEntity
+namespace Meta
+{
+using VersionListPtr = std::shared_ptr<class VersionList>;
+using VersionPtr = std::shared_ptr<class Version>;
+
+class MULTIMC_LOGIC_EXPORT Index : public QAbstractListModel, public BaseEntity
{
Q_OBJECT
public:
- explicit WonkoIndex(QObject *parent = nullptr);
- explicit WonkoIndex(const QVector<WonkoVersionListPtr> &lists, QObject *parent = nullptr);
+ explicit Index(QObject *parent = nullptr);
+ explicit Index(const QVector<VersionListPtr> &lists, QObject *parent = nullptr);
enum
{
@@ -44,25 +48,24 @@ public:
int columnCount(const QModelIndex &parent) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
- std::unique_ptr<Task> remoteUpdateTask() override;
- std::unique_ptr<Task> localUpdateTask() override;
-
QString localFilename() const override { return "index.json"; }
- QJsonObject serialized() const override;
// queries
+ VersionListPtr get(const QString &uid);
+ VersionPtr get(const QString &uid, const QString &version);
bool hasUid(const QString &uid) const;
- WonkoVersionListPtr getList(const QString &uid) const;
- WonkoVersionListPtr getListGuaranteed(const QString &uid) const;
- QVector<WonkoVersionListPtr> lists() const { return m_lists; }
+ QVector<VersionListPtr> lists() const { return m_lists; }
public: // for usage by parsers only
- void merge(const BaseWonkoEntity::Ptr &other);
+ void merge(const BaseEntity::Ptr &other) override;
+ void parse(const QJsonObject &obj) override;
private:
- QVector<WonkoVersionListPtr> m_lists;
- QHash<QString, WonkoVersionListPtr> m_uids;
+ QVector<VersionListPtr> m_lists;
+ QHash<QString, VersionListPtr> m_uids;
- void connectVersionList(const int row, const WonkoVersionListPtr &list);
+ void connectVersionList(const int row, const VersionListPtr &list);
};
+}
+
diff --git a/api/logic/meta/Index_test.cpp b/api/logic/meta/Index_test.cpp
new file mode 100644
index 00000000..1c5face2
--- /dev/null
+++ b/api/logic/meta/Index_test.cpp
@@ -0,0 +1,44 @@
+#include <QTest>
+#include "TestUtil.h"
+
+#include "meta/Index.h"
+#include "meta/VersionList.h"
+#include "Env.h"
+
+class IndexTest : public QObject
+{
+ Q_OBJECT
+private
+slots:
+ void test_isProvidedByEnv()
+ {
+ QVERIFY(ENV.metadataIndex());
+ QCOMPARE(ENV.metadataIndex(), ENV.metadataIndex());
+ }
+
+ void test_hasUid_and_getList()
+ {
+ Meta::Index windex({std::make_shared<Meta::VersionList>("list1"), std::make_shared<Meta::VersionList>("list2"), std::make_shared<Meta::VersionList>("list3")});
+ QVERIFY(windex.hasUid("list1"));
+ QVERIFY(!windex.hasUid("asdf"));
+ QVERIFY(windex.get("list2") != nullptr);
+ QCOMPARE(windex.get("list2")->uid(), QString("list2"));
+ QVERIFY(windex.get("adsf") != nullptr);
+ }
+
+ void test_merge()
+ {
+ Meta::Index windex({std::make_shared<Meta::VersionList>("list1"), std::make_shared<Meta::VersionList>("list2"), std::make_shared<Meta::VersionList>("list3")});
+ QCOMPARE(windex.lists().size(), 3);
+ windex.merge(std::shared_ptr<Meta::Index>(new Meta::Index({std::make_shared<Meta::VersionList>("list1"), std::make_shared<Meta::VersionList>("list2"), std::make_shared<Meta::VersionList>("list3")})));
+ QCOMPARE(windex.lists().size(), 3);
+ windex.merge(std::shared_ptr<Meta::Index>(new Meta::Index({std::make_shared<Meta::VersionList>("list4"), std::make_shared<Meta::VersionList>("list2"), std::make_shared<Meta::VersionList>("list5")})));
+ QCOMPARE(windex.lists().size(), 5);
+ windex.merge(std::shared_ptr<Meta::Index>(new Meta::Index({std::make_shared<Meta::VersionList>("list6")})));
+ QCOMPARE(windex.lists().size(), 6);
+ }
+};
+
+QTEST_GUILESS_MAIN(IndexTest)
+
+#include "Index_test.moc"
diff --git a/api/logic/meta/JsonFormat.cpp b/api/logic/meta/JsonFormat.cpp
new file mode 100644
index 00000000..fda1cf97
--- /dev/null
+++ b/api/logic/meta/JsonFormat.cpp
@@ -0,0 +1,150 @@
+/* Copyright 2015-2017 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.
+ */
+
+#include "JsonFormat.h"
+
+// FIXME: remove this from here... somehow
+#include "minecraft/onesix/OneSixVersionFormat.h"
+#include "Json.h"
+
+#include "Index.h"
+#include "Version.h"
+#include "VersionList.h"
+
+using namespace Json;
+
+namespace Meta
+{
+
+static const int currentFormatVersion = 0;
+
+// Index
+static BaseEntity::Ptr parseIndexInternal(const QJsonObject &obj)
+{
+ const QVector<QJsonObject> objects = requireIsArrayOf<QJsonObject>(obj, "packages");
+ QVector<VersionListPtr> lists;
+ lists.reserve(objects.size());
+ std::transform(objects.begin(), objects.end(), std::back_inserter(lists), [](const QJsonObject &obj)
+ {
+ VersionListPtr list = std::make_shared<VersionList>(requireString(obj, "uid"));
+ list->setName(ensureString(obj, "name", QString()));
+ return list;
+ });
+ return std::make_shared<Index>(lists);
+}
+
+// Version
+static VersionPtr parseCommonVersion(const QString &uid, const QJsonObject &obj)
+{
+ VersionPtr version = std::make_shared<Version>(uid, requireString(obj, "version"));
+ version->setTime(QDateTime::fromString(requireString(obj, "releaseTime"), Qt::ISODate).toMSecsSinceEpoch() / 1000);
+ version->setType(ensureString(obj, "type", QString()));
+ version->setParentUid(ensureString(obj, "parentUid", QString()));
+ version->setRecommended(ensureBoolean(obj, QString("recommended"), false));
+ if(obj.contains("requires"))
+ {
+ QHash<QString, QString> requires;
+ auto reqobj = requireObject(obj, "requires");
+ auto iter = reqobj.begin();
+ while(iter != reqobj.end())
+ {
+ requires[iter.key()] = requireString(iter.value());
+ iter++;
+ }
+ version->setRequires(requires);
+ }
+ return version;
+}
+
+static BaseEntity::Ptr parseVersionInternal(const QJsonObject &obj)
+{
+ VersionPtr version = parseCommonVersion(requireString(obj, "uid"), obj);
+
+ version->setData(OneSixVersionFormat::versionFileFromJson(QJsonDocument(obj),
+ QString("%1/%2.json").arg(version->uid(), version->version()),
+ obj.contains("order")));
+ return version;
+}
+
+// Version list / package
+static BaseEntity::Ptr parseVersionListInternal(const QJsonObject &obj)
+{
+ const QString uid = requireString(obj, "uid");
+
+ const QVector<QJsonObject> versionsRaw = requireIsArrayOf<QJsonObject>(obj, "versions");
+ QVector<VersionPtr> versions;
+ versions.reserve(versionsRaw.size());
+ std::transform(versionsRaw.begin(), versionsRaw.end(), std::back_inserter(versions), [uid](const QJsonObject &vObj)
+ {
+ auto version = parseCommonVersion(uid, vObj);
+ version->setProvidesRecommendations();
+ return version;
+ });
+
+ VersionListPtr list = std::make_shared<VersionList>(uid);
+ list->setName(ensureString(obj, "name", QString()));
+ list->setParentUid(ensureString(obj, "parentUid", QString()));
+ list->setVersions(versions);
+ return list;
+}
+
+
+static int formatVersion(const QJsonObject &obj)
+{
+ if (!obj.contains("formatVersion")) {
+ throw ParseException(QObject::tr("Missing required field: 'formatVersion'"));
+ }
+ if (!obj.value("formatVersion").isDouble()) {
+ throw ParseException(QObject::tr("Required field has invalid type: 'formatVersion'"));
+ }
+ return obj.value("formatVersion").toInt();
+}
+
+void parseIndex(const QJsonObject &obj, Index *ptr)
+{
+ const int version = formatVersion(obj);
+ switch (version) {
+ case 0:
+ ptr->merge(parseIndexInternal(obj));
+ break;
+ default:
+ throw ParseException(QObject::tr("Unknown formatVersion: %1").arg(version));
+ }
+}
+
+void parseVersionList(const QJsonObject &obj, VersionList *ptr)
+{
+ const int version = formatVersion(obj);
+ switch (version) {
+ case 0:
+ ptr->merge(parseVersionListInternal(obj));
+ break;
+ default:
+ throw ParseException(QObject::tr("Unknown formatVersion: %1").arg(version));
+ }
+}
+
+void parseVersion(const QJsonObject &obj, Version *ptr)
+{
+ const int version = formatVersion(obj);
+ switch (version) {
+ case 0:
+ ptr->merge(parseVersionInternal(obj));
+ break;
+ default:
+ throw ParseException(QObject::tr("Unknown formatVersion: %1").arg(version));
+ }
+}
+}
diff --git a/api/logic/wonko/WonkoUtil.h b/api/logic/meta/JsonFormat.h
index fb58ba1f..aaed07fc 100644
--- a/api/logic/wonko/WonkoUtil.h
+++ b/api/logic/meta/JsonFormat.h
@@ -15,17 +15,26 @@
#pragma once
-#include "multimc_logic_export.h"
+#include <QJsonObject>
+#include <memory>
-class QUrl;
-class QString;
-class QDir;
+#include "Exception.h"
+#include "meta/BaseEntity.h"
-namespace Wonko
+namespace Meta
{
-MULTIMC_LOGIC_EXPORT QUrl rootUrl();
-MULTIMC_LOGIC_EXPORT QUrl indexUrl();
-MULTIMC_LOGIC_EXPORT QUrl versionListUrl(const QString &uid);
-MULTIMC_LOGIC_EXPORT QUrl versionUrl(const QString &uid, const QString &version);
-MULTIMC_LOGIC_EXPORT QDir localWonkoDir();
+class Index;
+class Version;
+class VersionList;
+
+class ParseException : public Exception
+{
+public:
+ using Exception::Exception;
+};
+
+void parseIndex(const QJsonObject &obj, Index *ptr);
+void parseVersion(const QJsonObject &obj, Version *ptr);
+void parseVersionList(const QJsonObject &obj, VersionList *ptr);
+
}
diff --git a/api/logic/meta/Version.cpp b/api/logic/meta/Version.cpp
new file mode 100644
index 00000000..338e180b
--- /dev/null
+++ b/api/logic/meta/Version.cpp
@@ -0,0 +1,125 @@
+/* Copyright 2015-2017 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.
+ */
+
+#include "Version.h"
+
+#include <QDateTime>
+
+#include "JsonFormat.h"
+#include "minecraft/MinecraftProfile.h"
+
+Meta::Version::Version(const QString &uid, const QString &version)
+ : BaseVersion(), m_uid(uid), m_version(version)
+{
+}
+
+QString Meta::Version::descriptor()
+{
+ return m_version;
+}
+QString Meta::Version::name()
+{
+ if(m_data)
+ return m_data->name;
+ return m_uid;
+}
+QString Meta::Version::typeString() const
+{
+ return m_type;
+}
+
+QDateTime Meta::Version::time() const
+{
+ return QDateTime::fromMSecsSinceEpoch(m_time * 1000, Qt::UTC);
+}
+
+void Meta::Version::parse(const QJsonObject& obj)
+{
+ parseVersion(obj, this);
+}
+
+void Meta::Version::merge(const std::shared_ptr<BaseEntity> &other)
+{
+ VersionPtr version = std::dynamic_pointer_cast<Version>(other);
+ if(version->m_providesRecommendations)
+ {
+ if(m_recommended != version->m_recommended)
+ {
+ setRecommended(version->m_recommended);
+ }
+ }
+ if (m_type != version->m_type)
+ {
+ setType(version->m_type);
+ }
+ if (m_time != version->m_time)
+ {
+ setTime(version->m_time);
+ }
+ if (m_requires != version->m_requires)
+ {
+ setRequires(version->m_requires);
+ }
+ if (m_parentUid != version->m_parentUid)
+ {
+ setParentUid(version->m_parentUid);
+ }
+
+ setData(version->m_data);
+}
+
+QString Meta::Version::localFilename() const
+{
+ return m_uid + '/' + m_version + ".json";
+}
+
+void Meta::Version::setParentUid(const QString& parentUid)
+{
+ m_parentUid = parentUid;
+ emit requiresChanged();
+}
+
+void Meta::Version::setType(const QString &type)
+{
+ m_type = type;
+ emit typeChanged();
+}
+
+void Meta::Version::setTime(const qint64 time)
+{
+ m_time = time;
+ emit timeChanged();
+}
+
+void Meta::Version::setRequires(const QHash<QString, QString> &requires)
+{
+ m_requires = requires;
+ emit requiresChanged();
+}
+
+void Meta::Version::setData(const VersionFilePtr &data)
+{
+ m_data = data;
+}
+
+void Meta::Version::setProvidesRecommendations()
+{
+ m_providesRecommendations = true;
+}
+
+void Meta::Version::setRecommended(bool recommended)
+{
+ m_recommended = recommended;
+}
diff --git a/api/logic/wonko/WonkoVersion.h b/api/logic/meta/Version.h
index 397ff14e..f132b861 100644
--- a/api/logic/wonko/WonkoVersion.h
+++ b/api/logic/meta/Version.h
@@ -16,54 +16,79 @@
#pragma once
#include "BaseVersion.h"
-#include "BaseWonkoEntity.h"
-#include <QVector>
-#include <QStringList>
#include <QJsonObject>
+#include <QStringList>
+#include <QVector>
#include <memory>
#include "minecraft/VersionFile.h"
-#include "WonkoReference.h"
+
+#include "BaseEntity.h"
#include "multimc_logic_export.h"
-using WonkoVersionPtr = std::shared_ptr<class WonkoVersion>;
+namespace Meta
+{
+using VersionPtr = std::shared_ptr<class Version>;
-class MULTIMC_LOGIC_EXPORT WonkoVersion : public QObject, public BaseVersion, public BaseWonkoEntity
+class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public BaseEntity
{
Q_OBJECT
- Q_PROPERTY(QString uid READ uid CONSTANT)
- Q_PROPERTY(QString version READ version CONSTANT)
- Q_PROPERTY(QString type READ type NOTIFY typeChanged)
- Q_PROPERTY(QDateTime time READ time NOTIFY timeChanged)
- Q_PROPERTY(QVector<WonkoReference> requires READ requires NOTIFY requiresChanged)
-public:
- explicit WonkoVersion(const QString &uid, const QString &version);
+
+public: /* con/des */
+ explicit Version(const QString &uid, const QString &version);
QString descriptor() override;
QString name() override;
QString typeString() const override;
- QString uid() const { return m_uid; }
- QString version() const { return m_version; }
- QString type() const { return m_type; }
+ QString uid() const
+ {
+ return m_uid;
+ }
+ QString parentUid() const
+ {
+ return m_parentUid;
+ }
+ QString version() const
+ {
+ return m_version;
+ }
+ QString type() const
+ {
+ return m_type;
+ }
QDateTime time() const;
- qint64 rawTime() const { return m_time; }
- QVector<WonkoReference> requires() const { return m_requires; }
- VersionFilePtr data() const { return m_data; }
+ qint64 rawTime() const
+ {
+ return m_time;
+ }
+ const QHash<QString, QString> &requires() const
+ {
+ return m_requires;
+ }
+ VersionFilePtr data() const
+ {
+ return m_data;
+ }
+ bool isRecommended() const
+ {
+ return m_recommended;
+ }
- std::unique_ptr<Task> remoteUpdateTask() override;
- std::unique_ptr<Task> localUpdateTask() override;
- void merge(const std::shared_ptr<BaseWonkoEntity> &other) override;
+ void merge(const std::shared_ptr<BaseEntity> &other) override;
+ void parse(const QJsonObject &obj) override;
QString localFilename() const override;
- QJsonObject serialized() const override;
public: // for usage by format parsers only
+ void setParentUid(const QString &parentUid);
void setType(const QString &type);
void setTime(const qint64 time);
- void setRequires(const QVector<WonkoReference> &requires);
+ void setRequires(const QHash<QString, QString> &requires);
+ void setRecommended(bool recommended);
+ void setProvidesRecommendations();
void setData(const VersionFilePtr &data);
signals:
@@ -72,12 +97,17 @@ signals:
void requiresChanged();
private:
+ bool m_providesRecommendations = false;
+ bool m_recommended = false;
+ QString m_name;
QString m_uid;
+ QString m_parentUid;
QString m_version;
QString m_type;
qint64 m_time;
- QVector<WonkoReference> m_requires;
+ QHash<QString, QString> m_requires;
VersionFilePtr m_data;
};
+}
-Q_DECLARE_METATYPE(WonkoVersionPtr)
+Q_DECLARE_METATYPE(Meta::VersionPtr)
diff --git a/api/logic/meta/VersionList.cpp b/api/logic/meta/VersionList.cpp
new file mode 100644
index 00000000..0f1404ba
--- /dev/null
+++ b/api/logic/meta/VersionList.cpp
@@ -0,0 +1,235 @@
+/* Copyright 2015-2017 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.
+ */
+
+#include "VersionList.h"
+
+#include <QDateTime>
+
+#include "Version.h"
+#include "JsonFormat.h"
+
+namespace Meta
+{
+VersionList::VersionList(const QString &uid, QObject *parent)
+ : BaseVersionList(parent), m_uid(uid)
+{
+ setObjectName("Version list: " + uid);
+}
+
+shared_qobject_ptr<Task> VersionList::getLoadTask()
+{
+ load();
+ return getCurrentTask();
+}
+
+bool VersionList::isLoaded()
+{
+ return BaseEntity::isLoaded();
+}
+
+const BaseVersionPtr VersionList::at(int i) const
+{
+ return m_versions.at(i);
+}
+int VersionList::count() const
+{
+ return m_versions.size();
+}
+
+void VersionList::sortVersions()
+{
+ beginResetModel();
+ std::sort(m_versions.begin(), m_versions.end(), [](const VersionPtr &a, const VersionPtr &b)
+ {
+ return *a.get() < *b.get();
+ });
+ endResetModel();
+}
+
+QVariant VersionList::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid() || index.row() < 0 || index.row() >= m_versions.size() || index.parent().isValid())
+ {
+ return QVariant();
+ }
+
+ VersionPtr version = m_versions.at(index.row());
+
+ switch (role)
+ {
+ case VersionPointerRole: return QVariant::fromValue(std::dynamic_pointer_cast<BaseVersion>(version));
+ case VersionRole:
+ case VersionIdRole:
+ return version->version();
+ case ParentVersionRole:
+ {
+ auto parentUid = this->parentUid();
+ if(parentUid.isEmpty())
+ {
+ return QVariant();
+ }
+ auto & reqs = version->requires();
+ auto iter = reqs.find(parentUid);
+ if (iter != reqs.end())
+ {
+ return iter.value();
+ }
+ }
+ case TypeRole: return version->type();
+
+ case UidRole: return version->uid();
+ case TimeRole: return version->time();
+ case RequiresRole: return QVariant::fromValue(version->requires());
+ case SortRole: return version->rawTime();
+ case VersionPtrRole: return QVariant::fromValue(version);
+ case RecommendedRole: return version->isRecommended();
+ // FIXME: this should be determined in whatever view/proxy is used...
+ // case LatestRole: return version == getLatestStable();
+ default: return QVariant();
+ }
+}
+
+BaseVersionList::RoleList VersionList::providesRoles() const
+{
+ return {VersionPointerRole, VersionRole, VersionIdRole, ParentVersionRole,
+ TypeRole, UidRole, TimeRole, RequiresRole, SortRole,
+ RecommendedRole, LatestRole, VersionPtrRole};
+}
+
+QHash<int, QByteArray> VersionList::roleNames() const
+{
+ QHash<int, QByteArray> roles = BaseVersionList::roleNames();
+ roles.insert(UidRole, "uid");
+ roles.insert(TimeRole, "time");
+ roles.insert(SortRole, "sort");
+ roles.insert(RequiresRole, "requires");
+ return roles;
+}
+
+QString VersionList::localFilename() const
+{
+ return m_uid + "/index.json";
+}
+
+QString VersionList::humanReadable() const
+{
+ return m_name.isEmpty() ? m_uid : m_name;
+}
+
+VersionPtr VersionList::getVersion(const QString &version)
+{
+ VersionPtr out = m_lookup.value(version, nullptr);
+ if(!out)
+ {
+ out = std::make_shared<Version>(m_uid, version);
+ m_lookup[version] = out;
+ }
+ return out;
+}
+
+void VersionList::setName(const QString &name)
+{
+ m_name = name;
+ emit nameChanged(name);
+}
+
+void VersionList::setVersions(const QVector<VersionPtr> &versions)
+{
+ beginResetModel();
+ m_versions = versions;
+ std::sort(m_versions.begin(), m_versions.end(), [](const VersionPtr &a, const VersionPtr &b)
+ {
+ return a->rawTime() > b->rawTime();
+ });
+ for (int i = 0; i < m_versions.size(); ++i)
+ {
+ m_lookup.insert(m_versions.at(i)->version(), m_versions.at(i));
+ setupAddedVersion(i, m_versions.at(i));
+ }
+
+ auto recommendedIt = std::find_if(m_versions.constBegin(), m_versions.constEnd(), [](const VersionPtr &ptr) { return ptr->type() == "release"; });
+ m_recommended = recommendedIt == m_versions.constEnd() ? nullptr : *recommendedIt;
+ endResetModel();
+}
+
+void VersionList::parse(const QJsonObject& obj)
+{
+ parseVersionList(obj, this);
+}
+
+void VersionList::merge(const BaseEntity::Ptr &other)
+{
+ const VersionListPtr list = std::dynamic_pointer_cast<VersionList>(other);
+ if (m_name != list->m_name)
+ {
+ setName(list->m_name);
+ }
+
+ if(m_parentUid != list->m_parentUid)
+ {
+ setParentUid(list->m_parentUid);
+ }
+
+ if (m_versions.isEmpty())
+ {
+ setVersions(list->m_versions);
+ }
+ else
+ {
+ for (const VersionPtr &version : list->m_versions)
+ {
+ if (m_lookup.contains(version->version()))
+ {
+ m_lookup.value(version->version())->merge(version);
+ }
+ else
+ {
+ beginInsertRows(QModelIndex(), m_versions.size(), m_versions.size());
+ setupAddedVersion(m_versions.size(), version);
+ m_versions.append(version);
+ m_lookup.insert(version->uid(), version);
+ endInsertRows();
+
+ if (!m_recommended || (version->type() == "release" && version->rawTime() > m_recommended->rawTime()))
+ {
+ m_recommended = version;
+ emit dataChanged(index(0), index(m_versions.size() - 1), QVector<int>() << RecommendedRole);
+ }
+ }
+ }
+ }
+}
+
+void VersionList::setupAddedVersion(const int row, const VersionPtr &version)
+{
+ connect(version.get(), &Version::requiresChanged, this, [this, row]() { emit dataChanged(index(row), index(row), QVector<int>() << RequiresRole); });
+ connect(version.get(), &Version::timeChanged, this, [this, row]() { emit dataChanged(index(row), index(row), QVector<int>() << TimeRole << SortRole); });
+ connect(version.get(), &Version::typeChanged, this, [this, row]() { emit dataChanged(index(row), index(row), QVector<int>() << TypeRole); });
+}
+
+BaseVersionPtr VersionList::getRecommended() const
+{
+ return m_recommended;
+}
+
+}
+
+void Meta::VersionList::setParentUid(const QString& parentUid)
+{
+ m_parentUid = parentUid;
+}
+
+
+#include "VersionList.moc"
diff --git a/api/logic/wonko/WonkoVersionList.h b/api/logic/meta/VersionList.h
index 43cf73fc..e8016314 100644
--- a/api/logic/wonko/WonkoVersionList.h
+++ b/api/logic/meta/VersionList.h
@@ -15,78 +15,92 @@
#pragma once
+#include "BaseEntity.h"
#include "BaseVersionList.h"
-#include "BaseWonkoEntity.h"
+#include <QJsonObject>
#include <memory>
-using WonkoVersionPtr = std::shared_ptr<class WonkoVersion>;
-using WonkoVersionListPtr = std::shared_ptr<class WonkoVersionList>;
+namespace Meta
+{
+using VersionPtr = std::shared_ptr<class Version>;
+using VersionListPtr = std::shared_ptr<class VersionList>;
-class MULTIMC_LOGIC_EXPORT WonkoVersionList : public BaseVersionList, public BaseWonkoEntity
+class MULTIMC_LOGIC_EXPORT VersionList : public BaseVersionList, public BaseEntity
{
Q_OBJECT
Q_PROPERTY(QString uid READ uid CONSTANT)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
public:
- explicit WonkoVersionList(const QString &uid, QObject *parent = nullptr);
+ explicit VersionList(const QString &uid, QObject *parent = nullptr);
enum Roles
{
UidRole = Qt::UserRole + 100,
TimeRole,
RequiresRole,
- WonkoVersionPtrRole
+ VersionPtrRole
};
- Task *getLoadTask() override;
+ shared_qobject_ptr<Task> getLoadTask() override;
bool isLoaded() override;
const BaseVersionPtr at(int i) const override;
int count() const override;
void sortVersions() override;
- BaseVersionPtr getLatestStable() const override;
BaseVersionPtr getRecommended() const override;
QVariant data(const QModelIndex &index, int role) const override;
RoleList providesRoles() const override;
QHash<int, QByteArray> roleNames() const override;
- std::unique_ptr<Task> remoteUpdateTask() override;
- std::unique_ptr<Task> localUpdateTask() override;
-
QString localFilename() const override;
- QJsonObject serialized() const override;
- QString uid() const { return m_uid; }
- QString name() const { return m_name; }
+ QString parentUid() const
+ {
+ return m_parentUid;
+ }
+ QString uid() const
+ {
+ return m_uid;
+ }
+ QString name() const
+ {
+ return m_name;
+ }
QString humanReadable() const;
- bool hasVersion(const QString &version) const;
- WonkoVersionPtr getVersion(const QString &version) const;
+ VersionPtr getVersion(const QString &version);
- QVector<WonkoVersionPtr> versions() const { return m_versions; }
+ QVector<VersionPtr> versions() const
+ {
+ return m_versions;
+ }
public: // for usage only by parsers
void setName(const QString &name);
- void setVersions(const QVector<WonkoVersionPtr> &versions);
- void merge(const BaseWonkoEntity::Ptr &other);
+ void setParentUid(const QString &parentUid);
+ void setVersions(const QVector<VersionPtr> &versions);
+ void merge(const BaseEntity::Ptr &other) override;
+ void parse(const QJsonObject &obj) override;
signals:
void nameChanged(const QString &name);
protected slots:
- void updateListData(QList<BaseVersionPtr> versions) override {}
+ void updateListData(QList<BaseVersionPtr>) override
+ {
+ }
private:
- QVector<WonkoVersionPtr> m_versions;
- QHash<QString, WonkoVersionPtr> m_lookup;
+ QVector<VersionPtr> m_versions;
+ QHash<QString, VersionPtr> m_lookup;
QString m_uid;
+ QString m_parentUid;
QString m_name;
- WonkoVersionPtr m_recommended;
- WonkoVersionPtr m_latest;
+ VersionPtr m_recommended;
- void setupAddedVersion(const int row, const WonkoVersionPtr &version);
+ void setupAddedVersion(const int row, const VersionPtr &version);
};
-
-Q_DECLARE_METATYPE(WonkoVersionListPtr)
+}
+Q_DECLARE_METATYPE(Meta::VersionListPtr)
diff --git a/api/logic/minecraft/Library.cpp b/api/logic/minecraft/Library.cpp
index 5a75fe79..7521a049 100644
--- a/api/logic/minecraft/Library.cpp
+++ b/api/logic/minecraft/Library.cpp
@@ -30,14 +30,15 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na
};
if(m_mojangDownloads)
{
- if(m_mojangDownloads->artifact)
+ if(!isNative())
{
- auto artifact = m_mojangDownloads->artifact;
- jar += actualPath(artifact->path);
+ if(m_mojangDownloads->artifact)
+ {
+ auto artifact = m_mojangDownloads->artifact;
+ jar += actualPath(artifact->path);
+ }
}
- if(!isNative())
- return;
- if(m_nativeClassifiers.contains(system))
+ else if(m_nativeClassifiers.contains(system))
{
auto nativeClassifier = m_nativeClassifiers[system];
if(nativeClassifier.contains("${arch}"))
@@ -55,7 +56,15 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na
}
else
{
- native += actualPath(m_mojangDownloads->getDownloadInfo(nativeClassifier)->path);
+ auto dlinfo = m_mojangDownloads->getDownloadInfo(nativeClassifier);
+ if(!dlinfo)
+ {
+ qWarning() << "Cannot get native for" << nativeClassifier << "while processing" << m_name;
+ }
+ else
+ {
+ native += actualPath(dlinfo->path);
+ }
}
}
}
diff --git a/api/logic/minecraft/Library_test.cpp b/api/logic/minecraft/Library_test.cpp
index fe61d305..3f4828c9 100644
--- a/api/logic/minecraft/Library_test.cpp
+++ b/api/logic/minecraft/Library_test.cpp
@@ -234,7 +234,7 @@ slots:
auto test = readMojangJson("data/lib-native.json");
QStringList jar, native, native32, native64;
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
- QCOMPARE(jar, getStorage("org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209.jar"));
+ QCOMPARE(jar, QStringList());
QCOMPARE(native, getStorage("org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar"));
QCOMPARE(native32, {});
QCOMPARE(native64, {});
diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp
index 7b1aef1e..cb080bfe 100644
--- a/api/logic/minecraft/MinecraftInstance.cpp
+++ b/api/logic/minecraft/MinecraftInstance.cpp
@@ -5,7 +5,6 @@
#include <settings/Setting.h>
#include "settings/SettingsObject.h"
#include "Env.h"
-#include "minecraft/MinecraftVersionList.h"
#include <MMCStrings.h>
#include <pathmatcher/RegexpMatcher.h>
#include <pathmatcher/MultiMatcher.h>
@@ -21,9 +20,13 @@
#include "minecraft/launch/ModMinecraftJar.h"
#include "minecraft/launch/ClaimAccount.h"
#include "java/launch/CheckJava.h"
+#include <meta/Index.h>
+#include <meta/VersionList.h>
#include <icons/IIconList.h>
+#include <QCoreApplication>
+
#define IBUS "@im=ibus"
// all of this because keeping things compatible with deprecated old settings
@@ -104,7 +107,7 @@ QString MinecraftInstance::binRoot() const
std::shared_ptr< BaseVersionList > MinecraftInstance::versionList() const
{
- return ENV.getVersionList("net.minecraft");
+ return ENV.metadataIndex()->get("net.minecraft");
}
QStringList MinecraftInstance::javaArguments() const
diff --git a/api/logic/minecraft/MinecraftProfile.cpp b/api/logic/minecraft/MinecraftProfile.cpp
index 46235a18..c04669c1 100644
--- a/api/logic/minecraft/MinecraftProfile.cpp
+++ b/api/logic/minecraft/MinecraftProfile.cpp
@@ -80,7 +80,7 @@ void MinecraftProfile::clear()
m_traits.clear();
m_jarMods.clear();
mojangDownloads.clear();
- m_problemSeverity = ProblemSeverity::PROBLEM_NONE;
+ m_problemSeverity = ProblemSeverity::None;
}
void MinecraftProfile::clearPatches()
@@ -273,9 +273,9 @@ QVariant MinecraftProfile::data(const QModelIndex &index, int role) const
auto severity = patch->getProblemSeverity();
switch (severity)
{
- case PROBLEM_WARNING:
+ case ProblemSeverity::Warning:
return "warning";
- case PROBLEM_ERROR:
+ case ProblemSeverity::Error:
return "error";
default:
return QVariant();
@@ -491,20 +491,29 @@ void MinecraftProfile::applyLibrary(LibraryPtr library)
{
return;
}
+
+ QList<LibraryPtr> * list = &m_libraries;
+ if(library->isNative())
+ {
+ list = &m_nativeLibraries;
+ }
+
+ auto libraryCopy = Library::limitedCopy(library);
+
// find the library by name.
- const int index = findLibraryByName(m_libraries, library->rawName());
+ const int index = findLibraryByName(*list, library->rawName());
// library not found? just add it.
if (index < 0)
{
- m_libraries.append(Library::limitedCopy(library));
+ list->append(libraryCopy);
return;
}
- auto existingLibrary = m_libraries.at(index);
+
+ auto existingLibrary = list->at(index);
// if we are higher it means we should update
if (Version(library->version()) > Version(existingLibrary->version()))
{
- auto libraryCopy = Library::limitedCopy(library);
- m_libraries.replace(index, libraryCopy);
+ list->replace(index, libraryCopy);
}
}
@@ -581,6 +590,11 @@ const QList<LibraryPtr> & MinecraftProfile::getLibraries() const
return m_libraries;
}
+const QList<LibraryPtr> & MinecraftProfile::getNativeLibraries() const
+{
+ return m_nativeLibraries;
+}
+
void MinecraftProfile::getLibraryFiles(const QString& architecture, QStringList& jars, QStringList& nativeJars, const QString& overridePath) const
{
QStringList native32, native64;
@@ -590,6 +604,10 @@ void MinecraftProfile::getLibraryFiles(const QString& architecture, QStringList&
{
lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath);
}
+ for (auto lib : getNativeLibraries())
+ {
+ lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath);
+ }
if(architecture == "32")
{
nativeJars.append(native32);
@@ -621,6 +639,11 @@ void MinecraftProfile::installJarMods(QStringList selectedFiles)
m_strategy->installJarMods(selectedFiles);
}
+void MinecraftProfile::installVersion(BaseVersionPtr version)
+{
+ // TODO: implement
+}
+
/*
* TODO: get rid of this. Get rid of all order numbers.
*/
diff --git a/api/logic/minecraft/MinecraftProfile.h b/api/logic/minecraft/MinecraftProfile.h
index 392c8f5f..5b1ea539 100644
--- a/api/logic/minecraft/MinecraftProfile.h
+++ b/api/logic/minecraft/MinecraftProfile.h
@@ -22,8 +22,9 @@
#include <memory>
#include "Library.h"
-#include "VersionFile.h"
+#include "ProfilePatch.h"
#include "JarMod.h"
+#include "BaseVersion.h"
#include "MojangDownloadInfo.h"
#include "multimc_logic_export.h"
@@ -58,6 +59,9 @@ public:
/// install more jar mods
void installJarMods(QStringList selectedFiles);
+ /// install more jar mods
+ void installVersion(BaseVersionPtr version);
+
/// DEPRECATED, remove ASAP
int getFreeOrderNumber();
@@ -111,6 +115,7 @@ public: /* getters for profile variables */
const QStringList & getTweakers() const;
const QList<JarmodPtr> & getJarMods() const;
const QList<LibraryPtr> & getLibraries() const;
+ const QList<LibraryPtr> & getNativeLibraries() const;
void getLibraryFiles(const QString & architecture, QStringList & jars, QStringList & nativeJars, const QString & overridePath) const;
QString getMainJarUrl() const;
bool hasTrait(const QString & trait) const;
@@ -165,13 +170,16 @@ private: /* data */
/// the list of libraries
QList<LibraryPtr> m_libraries;
+ /// the list of libraries
+ QList<LibraryPtr> m_nativeLibraries;
+
/// traits, collected from all the version files (version files can only add)
QSet<QString> m_traits;
/// A list of jar mods. version files can add those.
QList<JarmodPtr> m_jarMods;
- ProblemSeverity m_problemSeverity = PROBLEM_NONE;
+ ProblemSeverity m_problemSeverity = ProblemSeverity::None;
/*
FIXME: add support for those rules here? Looks like a pile of quick hacks to me though.
diff --git a/api/logic/minecraft/MinecraftVersion.cpp b/api/logic/minecraft/MinecraftVersion.cpp
deleted file mode 100644
index 248c7eed..00000000
--- a/api/logic/minecraft/MinecraftVersion.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-#include "MinecraftVersion.h"
-#include "MinecraftProfile.h"
-#include "VersionBuildError.h"
-#include "ProfileUtils.h"
-#include "settings/SettingsObject.h"
-
-bool MinecraftVersion::usesLegacyLauncher()
-{
- return m_traits.contains("legacyLaunch") || m_traits.contains("aplhaLaunch");
-}
-
-QString MinecraftVersion::descriptor()
-{
- return m_descriptor;
-}
-
-QString MinecraftVersion::name()
-{
- return m_name;
-}
-
-QString MinecraftVersion::typeString() const
-{
- if(m_type == "snapshot")
- {
- return QObject::tr("Snapshot");
- }
- else if (m_type == "release")
- {
- return QObject::tr("Regular release");
- }
- else if (m_type == "old_alpha")
- {
- return QObject::tr("Alpha");
- }
- else if (m_type == "old_beta")
- {
- return QObject::tr("Beta");
- }
- else
- {
- return QString();
- }
-}
-
-VersionSource MinecraftVersion::getVersionSource()
-{
- return m_versionSource;
-}
-
-bool MinecraftVersion::hasJarMods()
-{
- return false;
-}
-
-bool MinecraftVersion::isMinecraftVersion()
-{
- return true;
-}
-
-void MinecraftVersion::applyFileTo(MinecraftProfile *profile)
-{
- if(m_versionSource == VersionSource::Local && getVersionFile())
- {
- getVersionFile()->applyTo(profile);
- }
- else
- {
- throw VersionIncomplete(QObject::tr("Can't apply incomplete/builtin Minecraft version %1").arg(m_name));
- }
-}
-
-QString MinecraftVersion::getUrl() const
-{
- // legacy fallback
- if(m_versionFileURL.isEmpty())
- {
- return QString("http://") + URLConstants::AWS_DOWNLOAD_VERSIONS + m_descriptor + "/" + m_descriptor + ".json";
- }
- // current
- return m_versionFileURL;
-}
-
-VersionFilePtr MinecraftVersion::getVersionFile()
-{
- QFileInfo versionFile(QString("versions/%1/%1.dat").arg(m_descriptor));
- m_problems.clear();
- m_problemSeverity = PROBLEM_NONE;
- if(!versionFile.exists())
- {
- if(m_loadedVersionFile)
- {
- m_loadedVersionFile.reset();
- }
- addProblem(PROBLEM_WARNING, QObject::tr("The patch file doesn't exist locally. It's possible it just needs to be downloaded."));
- }
- else
- {
- try
- {
- if(versionFile.lastModified() != m_loadedVersionFileTimestamp)
- {
- auto loadedVersionFile = ProfileUtils::parseBinaryJsonFile(versionFile);
- loadedVersionFile->name = "Minecraft";
- loadedVersionFile->setCustomizable(true);
- m_loadedVersionFileTimestamp = versionFile.lastModified();
- m_loadedVersionFile = loadedVersionFile;
- }
- }
- catch(Exception e)
- {
- m_loadedVersionFile.reset();
- addProblem(PROBLEM_ERROR, QObject::tr("The patch file couldn't be read:\n%1").arg(e.cause()));
- }
- }
- return m_loadedVersionFile;
-}
-
-bool MinecraftVersion::isCustomizable()
-{
- switch(m_versionSource)
- {
- case VersionSource::Local:
- case VersionSource::Remote:
- // locally cached file, or a remote file that we can acquire can be customized
- return true;
- case VersionSource::Builtin:
- // builtins do not follow the normal OneSix format. They are not customizable.
- default:
- // Everything else is undefined and therefore not customizable.
- return false;
- }
- return false;
-}
-
-const QList<PatchProblem> &MinecraftVersion::getProblems()
-{
- if(m_versionSource != VersionSource::Builtin && getVersionFile())
- {
- return getVersionFile()->getProblems();
- }
- return ProfilePatch::getProblems();
-}
-
-ProblemSeverity MinecraftVersion::getProblemSeverity()
-{
- if(m_versionSource != VersionSource::Builtin && getVersionFile())
- {
- return getVersionFile()->getProblemSeverity();
- }
- return ProfilePatch::getProblemSeverity();
-}
-
-void MinecraftVersion::applyTo(MinecraftProfile *profile)
-{
- // do we have this one cached?
- if (m_versionSource == VersionSource::Local)
- {
- applyFileTo(profile);
- return;
- }
- // if not builtin, do not proceed any further.
- if (m_versionSource != VersionSource::Builtin)
- {
- throw VersionIncomplete(QObject::tr(
- "Minecraft version %1 could not be applied: version files are missing.").arg(m_descriptor));
- }
- profile->applyMinecraftVersion(m_descriptor);
- profile->applyMainClass(m_mainClass);
- profile->applyAppletClass(m_appletClass);
- profile->applyMinecraftArguments(" ${auth_player_name} ${auth_session}"); // all builtin versions are legacy
- profile->applyMinecraftVersionType(m_type);
- profile->applyTraits(m_traits);
- profile->applyProblemSeverity(m_problemSeverity);
-}
-
-int MinecraftVersion::getOrder()
-{
- return order;
-}
-
-void MinecraftVersion::setOrder(int order)
-{
- this->order = order;
-}
-
-QList<JarmodPtr> MinecraftVersion::getJarMods()
-{
- return QList<JarmodPtr>();
-}
-
-QString MinecraftVersion::getName()
-{
- return "Minecraft";
-}
-QString MinecraftVersion::getVersion()
-{
- return m_descriptor;
-}
-QString MinecraftVersion::getID()
-{
- return "net.minecraft";
-}
-QString MinecraftVersion::getFilename()
-{
- return QString();
-}
-QDateTime MinecraftVersion::getReleaseDateTime()
-{
- return m_releaseTime;
-}
-
-
-bool MinecraftVersion::needsUpdate()
-{
- return m_versionSource == VersionSource::Remote || hasUpdate();
-}
-
-bool MinecraftVersion::hasUpdate()
-{
- return m_versionSource == VersionSource::Remote || (m_versionSource == VersionSource::Local && upstreamUpdate);
-}
-
-bool MinecraftVersion::isCustom()
-{
- // if we add any other source types, this will evaluate to false for them.
- return m_versionSource != VersionSource::Builtin
- && m_versionSource != VersionSource::Local
- && m_versionSource != VersionSource::Remote;
-}
diff --git a/api/logic/minecraft/MinecraftVersion.h b/api/logic/minecraft/MinecraftVersion.h
deleted file mode 100644
index 7ac9bcbb..00000000
--- a/api/logic/minecraft/MinecraftVersion.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* Copyright 2013-2017 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 <QStringList>
-#include <QSet>
-#include <QDateTime>
-
-#include "BaseVersion.h"
-#include "ProfilePatch.h"
-#include "VersionFile.h"
-
-#include "multimc_logic_export.h"
-
-class MinecraftProfile;
-class MinecraftVersion;
-typedef std::shared_ptr<MinecraftVersion> MinecraftVersionPtr;
-
-class MULTIMC_LOGIC_EXPORT MinecraftVersion : public BaseVersion, public ProfilePatch
-{
-friend class MinecraftVersionList;
-
-public: /* methods */
- bool usesLegacyLauncher();
- virtual QString descriptor() override;
- virtual QString name() override;
- virtual QString typeString() const override;
- virtual bool hasJarMods() override;
- virtual bool isMinecraftVersion() override;
- virtual void applyTo(MinecraftProfile *profile) override;
- virtual int getOrder() override;
- virtual void setOrder(int order) override;
- virtual QList<JarmodPtr> getJarMods() override;
- virtual QString getID() override;
- virtual QString getVersion() override;
- virtual QString getName() override;
- virtual QString getFilename() override;
- QDateTime getReleaseDateTime() override;
- VersionSource getVersionSource() override;
-
- bool needsUpdate();
- bool hasUpdate();
- virtual bool isCustom() override;
- virtual bool isMoveable() override
- {
- return false;
- }
- virtual bool isCustomizable() override;
- virtual bool isRemovable() override
- {
- return false;
- }
- virtual bool isRevertible() override
- {
- return false;
- }
- virtual bool isEditable() override
- {
- return false;
- }
- virtual bool isVersionChangeable() override
- {
- return true;
- }
-
- virtual VersionFilePtr getVersionFile() override;
-
- // virtual QJsonDocument toJson(bool saveOrder) override;
-
- QString getUrl() const;
-
- virtual const QList<PatchProblem> &getProblems() override;
- virtual ProblemSeverity getProblemSeverity() override;
-
-private: /* methods */
- void applyFileTo(MinecraftProfile *profile);
-
-protected: /* data */
- VersionSource m_versionSource = VersionSource::Builtin;
-
- /// The URL that this version will be downloaded from.
- QString m_versionFileURL;
-
- /// the human readable version name
- QString m_name;
-
- /// the version ID.
- QString m_descriptor;
-
- /// version traits. added by MultiMC
- QSet<QString> m_traits;
-
- /// The main class this version uses (if any, can be empty).
- QString m_mainClass;
-
- /// The applet class this version uses (if any, can be empty).
- QString m_appletClass;
-
- /// The type of this release
- QString m_type;
-
- /// the time this version was actually released by Mojang
- QDateTime m_releaseTime;
-
- /// the time this version was last updated by Mojang
- QDateTime m_updateTime;
-
- /// MD5 hash of the minecraft jar
- QString m_jarChecksum;
-
- /// order of this file... default = -2
- int order = -2;
-
- /// an update available from Mojang
- MinecraftVersionPtr upstreamUpdate;
-
- QDateTime m_loadedVersionFileTimestamp;
- mutable VersionFilePtr m_loadedVersionFile;
-};
diff --git a/api/logic/minecraft/MinecraftVersionList.cpp b/api/logic/minecraft/MinecraftVersionList.cpp
deleted file mode 100644
index 2c9a8035..00000000
--- a/api/logic/minecraft/MinecraftVersionList.cpp
+++ /dev/null
@@ -1,677 +0,0 @@
-/* Copyright 2013-2017 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.
- */
-
-#include <QtXml>
-#include "Json.h"
-#include <QtAlgorithms>
-#include <QtNetwork>
-
-#include "Env.h"
-#include "Exception.h"
-
-#include "MinecraftVersionList.h"
-#include "net/URLConstants.h"
-
-#include "ParseUtils.h"
-#include "ProfileUtils.h"
-#include "VersionFilterData.h"
-#include "onesix/OneSixVersionFormat.h"
-#include "MojangVersionFormat.h"
-#include <FileSystem.h>
-
-static const char * localVersionCache = "versions/versions.dat";
-
-class MCVListLoadTask : public Task
-{
- Q_OBJECT
-
-public:
- explicit MCVListLoadTask(MinecraftVersionList *vlist);
- virtual ~MCVListLoadTask() override{};
-
- virtual void executeTask() override;
-
-protected
-slots:
- void list_downloaded();
-
-protected:
- QNetworkReply *vlistReply;
- MinecraftVersionList *m_list;
- MinecraftVersion *m_currentStable;
-};
-
-class MCVListVersionUpdateTask : public Task
-{
- Q_OBJECT
-
-public:
- explicit MCVListVersionUpdateTask(MinecraftVersionList *vlist, std::shared_ptr<MinecraftVersion> updatedVersion);
- virtual ~MCVListVersionUpdateTask() override{};
- virtual void executeTask() override;
- bool canAbort() const override;
-
-public slots:
- bool abort() override;
-
-protected
-slots:
- void json_downloaded();
-
-protected:
- NetJobPtr specificVersionDownloadJob;
- QByteArray versionIndexData;
- std::shared_ptr<MinecraftVersion> updatedVersion;
- MinecraftVersionList *m_list;
- bool m_aborted = false;
-};
-
-class ListLoadError : public Exception
-{
-public:
- ListLoadError(QString cause) : Exception(cause) {};
- virtual ~ListLoadError() noexcept
- {
- }
-};
-
-MinecraftVersionList::MinecraftVersionList(QObject *parent) : BaseVersionList(parent)
-{
- loadBuiltinList();
- loadCachedList();
-}
-
-Task *MinecraftVersionList::getLoadTask()
-{
- return new MCVListLoadTask(this);
-}
-
-bool MinecraftVersionList::isLoaded()
-{
- return m_loaded;
-}
-
-const BaseVersionPtr MinecraftVersionList::at(int i) const
-{
- return m_vlist.at(i);
-}
-
-int MinecraftVersionList::count() const
-{
- return m_vlist.count();
-}
-
-static bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second)
-{
- auto left = std::dynamic_pointer_cast<MinecraftVersion>(first);
- auto right = std::dynamic_pointer_cast<MinecraftVersion>(second);
- return left->getReleaseDateTime() > right->getReleaseDateTime();
-}
-
-void MinecraftVersionList::sortInternal()
-{
- qSort(m_vlist.begin(), m_vlist.end(), cmpVersions);
-}
-
-void MinecraftVersionList::loadCachedList()
-{
- QFile localIndex(localVersionCache);
- if (!localIndex.exists())
- {
- return;
- }
- if (!localIndex.open(QIODevice::ReadOnly))
- {
- // FIXME: this is actually a very bad thing! How do we deal with this?
- qCritical() << "The minecraft version cache can't be read.";
- return;
- }
- auto data = localIndex.readAll();
- try
- {
- localIndex.close();
- QJsonDocument jsonDoc = QJsonDocument::fromBinaryData(data);
- if (jsonDoc.isNull())
- {
- throw ListLoadError(tr("Error reading the version list."));
- }
- loadMojangList(jsonDoc, VersionSource::Local);
- }
- catch (Exception &e)
- {
- // the cache has gone bad for some reason... flush it.
- qCritical() << "The minecraft version cache is corrupted. Flushing cache.";
- localIndex.remove();
- return;
- }
- m_hasLocalIndex = true;
-}
-
-void MinecraftVersionList::loadBuiltinList()
-{
- qDebug() << "Loading builtin version list.";
- // grab the version list data from internal resources.
- const QJsonDocument doc =
- Json::requireDocument(QString(":/versions/minecraft.json"), "builtin version list");
- const QJsonObject root = doc.object();
-
- // parse all the versions
- for (const auto version : Json::requireArray(root.value("versions")))
- {
- QJsonObject versionObj = version.toObject();
- QString versionID = versionObj.value("id").toString("");
- QString versionTypeStr = versionObj.value("type").toString("");
- if (versionID.isEmpty() || versionTypeStr.isEmpty())
- {
- qCritical() << "Parsed version is missing ID or type";
- continue;
- }
-
- if (g_VersionFilterData.legacyBlacklist.contains(versionID))
- {
- qWarning() << "Blacklisted legacy version ignored: " << versionID;
- continue;
- }
-
- // Now, we construct the version object and add it to the list.
- std::shared_ptr<MinecraftVersion> mcVersion(new MinecraftVersion());
- mcVersion->m_name = mcVersion->m_descriptor = versionID;
-
- // Parse the timestamp.
- mcVersion->m_releaseTime = timeFromS3Time(versionObj.value("releaseTime").toString(""));
- mcVersion->m_versionFileURL = QString();
- mcVersion->m_versionSource = VersionSource::Builtin;
- mcVersion->m_type = versionTypeStr;
- mcVersion->m_appletClass = versionObj.value("appletClass").toString("");
- mcVersion->m_mainClass = versionObj.value("mainClass").toString("");
- mcVersion->m_jarChecksum = versionObj.value("checksum").toString("");
- if (versionObj.contains("+traits"))
- {
- for (auto traitVal : Json::requireArray(versionObj.value("+traits")))
- {
- mcVersion->m_traits.insert(Json::requireString(traitVal));
- }
- }
- m_lookup[versionID] = mcVersion;
- m_vlist.append(mcVersion);
- }
-}
-
-void MinecraftVersionList::loadMojangList(QJsonDocument jsonDoc, VersionSource source)
-{
- qDebug() << "Loading" << ((source == VersionSource::Remote) ? "remote" : "local") << "version list.";
-
- if (!jsonDoc.isObject())
- {
- throw ListLoadError(tr("Error parsing version list JSON: jsonDoc is not an object"));
- }
-
- QJsonObject root = jsonDoc.object();
-
- try
- {
- QJsonObject latest = Json::requireObject(root.value("latest"));
- m_latestReleaseID = Json::requireString(latest.value("release"));
- m_latestSnapshotID = Json::requireString(latest.value("snapshot"));
- }
- catch (Exception &err)
- {
- qCritical()
- << tr("Error parsing version list JSON: couldn't determine latest versions");
- }
-
- // Now, get the array of versions.
- if (!root.value("versions").isArray())
- {
- throw ListLoadError(tr("Error parsing version list JSON: version list object is "
- "missing 'versions' array"));
- }
- QJsonArray versions = root.value("versions").toArray();
-
- QList<BaseVersionPtr> tempList;
- for (auto version : versions)
- {
- // Load the version info.
- if (!version.isObject())
- {
- qCritical() << "Error while parsing version list : invalid JSON structure";
- continue;
- }
-
- QJsonObject versionObj = version.toObject();
- QString versionID = versionObj.value("id").toString("");
- if (versionID.isEmpty())
- {
- qCritical() << "Error while parsing version : version ID is missing";
- continue;
- }
-
- if (g_VersionFilterData.legacyBlacklist.contains(versionID))
- {
- qWarning() << "Blacklisted legacy version ignored: " << versionID;
- continue;
- }
-
- // Now, we construct the version object and add it to the list.
- std::shared_ptr<MinecraftVersion> mcVersion(new MinecraftVersion());
- mcVersion->m_name = mcVersion->m_descriptor = versionID;
-
- mcVersion->m_releaseTime = timeFromS3Time(versionObj.value("releaseTime").toString(""));
- mcVersion->m_updateTime = timeFromS3Time(versionObj.value("time").toString(""));
-
- if (mcVersion->m_releaseTime < g_VersionFilterData.legacyCutoffDate)
- {
- continue;
- }
-
- // depends on where we load the version from -- network request or local file?
- mcVersion->m_versionSource = source;
- mcVersion->m_versionFileURL = versionObj.value("url").toString("");
- QString versionTypeStr = versionObj.value("type").toString("");
- if (versionTypeStr.isEmpty())
- {
- qCritical() << "Ignoring" << versionID
- << "because it doesn't have the version type set.";
- continue;
- }
- // OneSix or Legacy. use filter to determine type
- if (versionTypeStr == "release")
- {
- }
- else if (versionTypeStr == "snapshot") // It's a snapshot... yay
- {
- }
- else if (versionTypeStr == "old_alpha")
- {
- }
- else if (versionTypeStr == "old_beta")
- {
- }
- else
- {
- qCritical() << "Ignoring" << versionID
- << "because it has an invalid version type.";
- continue;
- }
- mcVersion->m_type = versionTypeStr;
- qDebug() << "Loaded version" << versionID << "from"
- << ((source == VersionSource::Remote) ? "remote" : "local") << "version list.";
- tempList.append(mcVersion);
- }
- updateListData(tempList);
- if(source == VersionSource::Remote)
- {
- m_loaded = true;
- }
-}
-
-void MinecraftVersionList::sortVersions()
-{
- beginResetModel();
- sortInternal();
- endResetModel();
-}
-
-QVariant MinecraftVersionList::data(const QModelIndex& index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- if (index.row() > count())
- return QVariant();
-
- auto version = std::dynamic_pointer_cast<MinecraftVersion>(m_vlist[index.row()]);
- switch (role)
- {
- case VersionPointerRole:
- return qVariantFromValue(m_vlist[index.row()]);
-
- case VersionRole:
- return version->name();
-
- case VersionIdRole:
- return version->descriptor();
-
- case RecommendedRole:
- return version->descriptor() == m_latestReleaseID;
-
- case LatestRole:
- {
- if(version->descriptor() != m_latestSnapshotID)
- return false;
- MinecraftVersionPtr latestRelease = std::dynamic_pointer_cast<MinecraftVersion>(getLatestStable());
- /*
- if(latestRelease && latestRelease->m_releaseTime > version->m_releaseTime)
- {
- return false;
- }
- */
- return true;
- }
-
- case TypeRole:
- return version->typeString();
-
- default:
- return QVariant();
- }
-}
-
-BaseVersionList::RoleList MinecraftVersionList::providesRoles() const
-{
- return {VersionPointerRole, VersionRole, VersionIdRole, RecommendedRole, LatestRole, TypeRole};
-}
-
-BaseVersionPtr MinecraftVersionList::getLatestStable() const
-{
- if(m_lookup.contains(m_latestReleaseID))
- return m_lookup[m_latestReleaseID];
- return BaseVersionPtr();
-}
-
-BaseVersionPtr MinecraftVersionList::getRecommended() const
-{
- return getLatestStable();
-}
-
-void MinecraftVersionList::updateListData(QList<BaseVersionPtr> versions)
-{
- beginResetModel();
- for (auto version : versions)
- {
- auto descr = version->descriptor();
-
- if (!m_lookup.contains(descr))
- {
- m_lookup[version->descriptor()] = version;
- m_vlist.append(version);
- continue;
- }
- auto orig = std::dynamic_pointer_cast<MinecraftVersion>(m_lookup[descr]);
- auto added = std::dynamic_pointer_cast<MinecraftVersion>(version);
- // updateListData is called after Mojang list loads. those can be local or remote
- // remote comes always after local
- // any other options are ignored
- if (orig->m_versionSource != VersionSource::Local || added->m_versionSource != VersionSource::Remote)
- {
- continue;
- }
- // alright, it's an update. put it inside the original, for further processing.
- orig->upstreamUpdate = added;
- }
- sortInternal();
- endResetModel();
-}
-
-MCVListLoadTask::MCVListLoadTask(MinecraftVersionList *vlist)
-{
- m_list = vlist;
- m_currentStable = NULL;
- vlistReply = nullptr;
-}
-
-void MCVListLoadTask::executeTask()
-{
- setStatus(tr("Loading instance version list..."));
- vlistReply = ENV.qnam().get(QNetworkRequest(QUrl("https://launchermeta.mojang.com/mc/game/version_manifest.json")));
- connect(vlistReply, SIGNAL(finished()), this, SLOT(list_downloaded()));
-}
-
-void MCVListLoadTask::list_downloaded()
-{
- if (vlistReply->error() != QNetworkReply::NoError)
- {
- vlistReply->deleteLater();
- emitFailed("Failed to load Minecraft main version list" + vlistReply->errorString());
- return;
- }
-
- auto data = vlistReply->readAll();
- vlistReply->deleteLater();
- try
- {
- QJsonParseError jsonError;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
- if (jsonError.error != QJsonParseError::NoError)
- {
- throw ListLoadError(
- tr("Error parsing version list JSON: %1").arg(jsonError.errorString()));
- }
- m_list->loadMojangList(jsonDoc, VersionSource::Remote);
- }
- catch (Exception &e)
- {
- emitFailed(e.cause());
- return;
- }
-
- emitSucceeded();
- return;
-}
-
-MCVListVersionUpdateTask::MCVListVersionUpdateTask(MinecraftVersionList *vlist, std::shared_ptr<MinecraftVersion> updatedVersion)
- : Task()
-{
- m_list = vlist;
- this->updatedVersion = updatedVersion;
-}
-
-void MCVListVersionUpdateTask::executeTask()
-{
- if(m_aborted)
- {
- emitFailed(tr("Task aborted."));
- return;
- }
- auto job = new NetJob("Version index");
- job->addNetAction(Net::Download::makeByteArray(QUrl(updatedVersion->getUrl()), &versionIndexData));
- specificVersionDownloadJob.reset(job);
- connect(specificVersionDownloadJob.get(), SIGNAL(succeeded()), SLOT(json_downloaded()));
- connect(specificVersionDownloadJob.get(), SIGNAL(failed(QString)), SIGNAL(failed(QString)));
- connect(specificVersionDownloadJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
- specificVersionDownloadJob->start();
-}
-
-bool MCVListVersionUpdateTask::canAbort() const
-{
- return true;
-}
-
-bool MCVListVersionUpdateTask::abort()
-{
- m_aborted = true;
- if(specificVersionDownloadJob)
- {
- return specificVersionDownloadJob->abort();
- }
- return true;
-}
-
-void MCVListVersionUpdateTask::json_downloaded()
-{
- specificVersionDownloadJob.reset();
-
- QJsonParseError jsonError;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(versionIndexData, &jsonError);
- versionIndexData.clear();
-
- if (jsonError.error != QJsonParseError::NoError)
- {
- emitFailed(tr("The download version file is not valid."));
- return;
- }
- VersionFilePtr file;
- try
- {
- file = MojangVersionFormat::versionFileFromJson(jsonDoc, "net.minecraft.json");
- }
- catch (Exception &e)
- {
- emitFailed(tr("Couldn't process version file: %1").arg(e.cause()));
- return;
- }
-
- // Strip LWJGL from the version file. We use our own.
- ProfileUtils::removeLwjglFromPatch(file);
-
- // TODO: recognize and add LWJGL versions here.
-
- file->fileId = "net.minecraft";
-
- // now dump the file to disk
- auto doc = OneSixVersionFormat::versionFileToJson(file, false);
- auto newdata = doc.toBinaryData();
- auto id = updatedVersion->descriptor();
- QString targetPath = "versions/" + id + "/" + id + ".dat";
- FS::ensureFilePathExists(targetPath);
- QSaveFile vfile1(targetPath);
- if (!vfile1.open(QIODevice::Truncate | QIODevice::WriteOnly))
- {
- emitFailed(tr("Can't open %1 for writing.").arg(targetPath));
- return;
- }
- qint64 actual = 0;
- if ((actual = vfile1.write(newdata)) != newdata.size())
- {
- emitFailed(tr("Failed to write into %1. Written %2 out of %3.")
- .arg(targetPath)
- .arg(actual)
- .arg(newdata.size()));
- return;
- }
- if (!vfile1.commit())
- {
- emitFailed(tr("Can't commit changes to %1").arg(targetPath));
- return;
- }
-
- m_list->finalizeUpdate(id);
- emitSucceeded();
-}
-
-std::shared_ptr<Task> MinecraftVersionList::createUpdateTask(QString version)
-{
- auto iter = m_lookup.find(version);
- if(iter == m_lookup.end())
- return nullptr;
-
- auto mcversion = std::dynamic_pointer_cast<MinecraftVersion>(*iter);
- if(!mcversion)
- {
- return nullptr;
- }
-
- return std::shared_ptr<Task>(new MCVListVersionUpdateTask(this, mcversion));
-}
-
-void MinecraftVersionList::saveCachedList()
-{
- // FIXME: throw.
- if (!FS::ensureFilePathExists(localVersionCache))
- return;
- QSaveFile tfile(localVersionCache);
- if (!tfile.open(QIODevice::WriteOnly | QIODevice::Truncate))
- return;
- QJsonObject toplevel;
- QJsonArray entriesArr;
- for (auto version : m_vlist)
- {
- auto mcversion = std::dynamic_pointer_cast<MinecraftVersion>(version);
- // do not save the remote versions.
- if (mcversion->m_versionSource != VersionSource::Local)
- continue;
- QJsonObject entryObj;
-
- entryObj.insert("id", mcversion->descriptor());
- entryObj.insert("version", mcversion->descriptor());
- entryObj.insert("time", timeToS3Time(mcversion->m_updateTime));
- entryObj.insert("releaseTime", timeToS3Time(mcversion->m_releaseTime));
- entryObj.insert("url", mcversion->m_versionFileURL);
- entryObj.insert("type", mcversion->m_type);
- entriesArr.append(entryObj);
- }
- toplevel.insert("versions", entriesArr);
-
- {
- bool someLatest = false;
- QJsonObject latestObj;
- if(!m_latestReleaseID.isNull())
- {
- latestObj.insert("release", m_latestReleaseID);
- someLatest = true;
- }
- if(!m_latestSnapshotID.isNull())
- {
- latestObj.insert("snapshot", m_latestSnapshotID);
- someLatest = true;
- }
- if(someLatest)
- {
- toplevel.insert("latest", latestObj);
- }
- }
-
- QJsonDocument doc(toplevel);
- QByteArray jsonData = doc.toBinaryData();
- qint64 result = tfile.write(jsonData);
- if (result == -1)
- return;
- if (result != jsonData.size())
- return;
- tfile.commit();
-}
-
-void MinecraftVersionList::finalizeUpdate(QString version)
-{
- int idx = -1;
- for (int i = 0; i < m_vlist.size(); i++)
- {
- if (version == m_vlist[i]->descriptor())
- {
- idx = i;
- break;
- }
- }
- if (idx == -1)
- {
- return;
- }
-
- auto updatedVersion = std::dynamic_pointer_cast<MinecraftVersion>(m_vlist[idx]);
-
- // reject any updates to builtin versions.
- if (updatedVersion->m_versionSource == VersionSource::Builtin)
- return;
-
- // if we have an update for the version, replace it, make the update local
- if (updatedVersion->upstreamUpdate)
- {
- auto updatedWith = updatedVersion->upstreamUpdate;
- updatedWith->m_versionSource = VersionSource::Local;
- m_vlist[idx] = updatedWith;
- m_lookup[version] = updatedWith;
- }
- else
- {
- // otherwise, just set the version as local;
- updatedVersion->m_versionSource = VersionSource::Local;
- }
-
- dataChanged(index(idx), index(idx));
-
- saveCachedList();
-}
-
-#include "MinecraftVersionList.moc"
diff --git a/api/logic/minecraft/MinecraftVersionList.h b/api/logic/minecraft/MinecraftVersionList.h
deleted file mode 100644
index 42333678..00000000
--- a/api/logic/minecraft/MinecraftVersionList.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Copyright 2013-2017 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 <QObject>
-#include <QList>
-#include <QSet>
-
-#include "BaseVersionList.h"
-#include "tasks/Task.h"
-#include "minecraft/MinecraftVersion.h"
-#include <net/NetJob.h>
-
-#include "multimc_logic_export.h"
-
-class MCVListLoadTask;
-class MCVListVersionUpdateTask;
-
-class MULTIMC_LOGIC_EXPORT MinecraftVersionList : public BaseVersionList
-{
- Q_OBJECT
-private:
- void sortInternal();
- void loadBuiltinList();
- void loadMojangList(QJsonDocument jsonDoc, VersionSource source);
- void loadCachedList();
- void saveCachedList();
- void finalizeUpdate(QString version);
-public:
- friend class MCVListLoadTask;
- friend class MCVListVersionUpdateTask;
-
- explicit MinecraftVersionList(QObject *parent = 0);
-
- std::shared_ptr<Task> createUpdateTask(QString version);
-
- virtual Task *getLoadTask() override;
- virtual bool isLoaded() override;
- virtual const BaseVersionPtr at(int i) const override;
- virtual int count() const override;
- virtual void sortVersions() override;
- virtual QVariant data(const QModelIndex & index, int role) const override;
- virtual RoleList providesRoles() const override;
-
- virtual BaseVersionPtr getLatestStable() const override;
- virtual BaseVersionPtr getRecommended() const override;
-
-protected:
- QList<BaseVersionPtr> m_vlist;
- QMap<QString, BaseVersionPtr> m_lookup;
-
- bool m_loaded = false;
- bool m_hasLocalIndex = false;
- QString m_latestReleaseID = "INVALID";
- QString m_latestSnapshotID = "INVALID";
-
-protected
-slots:
- virtual void updateListData(QList<BaseVersionPtr> versions) override;
-};
diff --git a/api/logic/minecraft/MojangVersionFormat.cpp b/api/logic/minecraft/MojangVersionFormat.cpp
index 34129c9e..ea8dcd4d 100644
--- a/api/logic/minecraft/MojangVersionFormat.cpp
+++ b/api/logic/minecraft/MojangVersionFormat.cpp
@@ -1,6 +1,5 @@
#include "MojangVersionFormat.h"
#include "onesix/OneSixVersionFormat.h"
-#include "MinecraftVersion.h"
#include "VersionBuildError.h"
#include "MojangDownloadInfo.h"
@@ -152,7 +151,7 @@ void MojangVersionFormat::readVersionProperties(const QJsonObject &in, VersionFi
}
else if (!toCompare.isEmpty())
{
- out->addProblem(PROBLEM_ERROR, QObject::tr("processArguments is set to unknown value '%1'").arg(processArguments));
+ out->addProblem(ProblemSeverity::Error, QObject::tr("processArguments is set to unknown value '%1'").arg(processArguments));
}
}
Bits::readString(in, "type", out->type);
@@ -167,8 +166,8 @@ void MojangVersionFormat::readVersionProperties(const QJsonObject &in, VersionFi
out->mojangAssetIndex = std::make_shared<MojangAssetIndexInfo>(out->assets);
}
- out->m_releaseTime = timeFromS3Time(in.value("releaseTime").toString(""));
- out->m_updateTime = timeFromS3Time(in.value("time").toString(""));
+ out->releaseTime = timeFromS3Time(in.value("releaseTime").toString(""));
+ out->updateTime = timeFromS3Time(in.value("time").toString(""));
if (in.contains("minimumLauncherVersion"))
{
@@ -176,7 +175,7 @@ void MojangVersionFormat::readVersionProperties(const QJsonObject &in, VersionFi
if (out->minimumLauncherVersion > CURRENT_MINIMUM_LAUNCHER_VERSION)
{
out->addProblem(
- PROBLEM_WARNING,
+ ProblemSeverity::Warning,
QObject::tr("The 'minimumLauncherVersion' value of this version (%1) is higher than supported by MultiMC (%2). It might not work properly!")
.arg(out->minimumLauncherVersion)
.arg(CURRENT_MINIMUM_LAUNCHER_VERSION));
@@ -211,9 +210,9 @@ VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc
readVersionProperties(root, out.get());
out->name = "Minecraft";
- out->fileId = "net.minecraft";
+ out->uid = "net.minecraft";
out->version = out->minecraftVersion;
- out->filename = filename;
+ // out->filename = filename;
if (root.contains("libraries"))
@@ -235,13 +234,13 @@ void MojangVersionFormat::writeVersionProperties(const VersionFile* in, QJsonObj
writeString(out, "mainClass", in->mainClass);
writeString(out, "minecraftArguments", in->minecraftArguments);
writeString(out, "type", in->type);
- if(!in->m_releaseTime.isNull())
+ if(!in->releaseTime.isNull())
{
- writeString(out, "releaseTime", timeToS3Time(in->m_releaseTime));
+ writeString(out, "releaseTime", timeToS3Time(in->releaseTime));
}
- if(!in->m_updateTime.isNull())
+ if(!in->updateTime.isNull())
{
- writeString(out, "time", timeToS3Time(in->m_updateTime));
+ writeString(out, "time", timeToS3Time(in->updateTime));
}
if(in->minimumLauncherVersion != -1)
{
diff --git a/api/logic/minecraft/ProfilePatch.cpp b/api/logic/minecraft/ProfilePatch.cpp
new file mode 100644
index 00000000..6a90f64b
--- /dev/null
+++ b/api/logic/minecraft/ProfilePatch.cpp
@@ -0,0 +1,175 @@
+#include <meta/VersionList.h>
+#include <meta/Index.h>
+#include <Env.h>
+#include "ProfilePatch.h"
+
+#include "meta/Version.h"
+#include "VersionFile.h"
+
+ProfilePatch::ProfilePatch(std::shared_ptr<Meta::Version> version)
+ :m_metaVersion(version)
+{
+}
+
+ProfilePatch::ProfilePatch(std::shared_ptr<VersionFile> file, const QString& filename)
+ :m_file(file), m_filename(filename)
+{
+}
+
+void ProfilePatch::applyTo(MinecraftProfile* profile)
+{
+ auto vfile = getVersionFile();
+ if(vfile)
+ {
+ vfile->applyTo(profile);
+ }
+}
+
+std::shared_ptr<class VersionFile> ProfilePatch::getVersionFile()
+{
+ if(m_metaVersion)
+ {
+ if(!m_metaVersion->isLoaded())
+ {
+ m_metaVersion->load();
+ }
+ return m_metaVersion->data();
+ }
+ return m_file;
+}
+
+std::shared_ptr<class Meta::VersionList> ProfilePatch::getVersionList()
+{
+ if(m_metaVersion)
+ {
+ return ENV.metadataIndex()->get(m_metaVersion->uid());
+ }
+ return nullptr;
+}
+
+int ProfilePatch::getOrder()
+{
+ if(m_orderOverride)
+ return m_order;
+
+ auto vfile = getVersionFile();
+ if(vfile)
+ {
+ return vfile->order;
+ }
+ return 0;
+}
+void ProfilePatch::setOrder(int order)
+{
+ m_orderOverride = true;
+ m_order = order;
+}
+QString ProfilePatch::getID()
+{
+ if(m_metaVersion)
+ return m_metaVersion->uid();
+ return getVersionFile()->uid;
+}
+QString ProfilePatch::getName()
+{
+ if(m_metaVersion)
+ return m_metaVersion->name();
+ return getVersionFile()->name;
+}
+QString ProfilePatch::getVersion()
+{
+ if(m_metaVersion)
+ return m_metaVersion->version();
+ return getVersionFile()->version;
+}
+QString ProfilePatch::getFilename()
+{
+ return m_filename;
+}
+QDateTime ProfilePatch::getReleaseDateTime()
+{
+ if(m_metaVersion)
+ {
+ return m_metaVersion->time();
+ }
+ return getVersionFile()->releaseTime;
+}
+
+bool ProfilePatch::isCustom()
+{
+ return !m_isVanilla;
+};
+
+bool ProfilePatch::isCustomizable()
+{
+ if(m_metaVersion)
+ {
+ if(getVersionFile())
+ {
+ return true;
+ }
+ }
+ return false;
+}
+bool ProfilePatch::isRemovable()
+{
+ return m_isRemovable;
+}
+bool ProfilePatch::isRevertible()
+{
+ return m_isRevertible;
+}
+bool ProfilePatch::isMoveable()
+{
+ return m_isMovable;
+}
+bool ProfilePatch::isVersionChangeable()
+{
+ auto list = getVersionList();
+ if(list)
+ {
+ if(!list->isLoaded())
+ {
+ list->load();
+ }
+ return list->count() != 0;
+ }
+ return false;
+}
+
+void ProfilePatch::setVanilla (bool state)
+{
+ m_isVanilla = state;
+}
+void ProfilePatch::setRemovable (bool state)
+{
+ m_isRemovable = state;
+}
+void ProfilePatch::setRevertible (bool state)
+{
+ m_isRevertible = state;
+}
+void ProfilePatch::setMovable (bool state)
+{
+ m_isMovable = state;
+}
+
+ProblemSeverity ProfilePatch::getProblemSeverity()
+{
+ auto file = getVersionFile();
+ if(file)
+ {
+ return file->getProblemSeverity();
+ }
+ return ProblemSeverity::Error;
+}
+
+const QList<PatchProblem> ProfilePatch::getProblems()
+{
+ auto file = getVersionFile();
+ if(file)
+ {
+ return file->getProblems();
+ }
+ return {PatchProblem(ProblemSeverity::Error, QObject::tr("Patch is not loaded yet."))};
+}
diff --git a/api/logic/minecraft/ProfilePatch.h b/api/logic/minecraft/ProfilePatch.h
index 26230092..fb6b2f05 100644
--- a/api/logic/minecraft/ProfilePatch.h
+++ b/api/logic/minecraft/ProfilePatch.h
@@ -5,101 +5,67 @@
#include <QJsonDocument>
#include <QDateTime>
#include "JarMod.h"
+#include "ProblemProvider.h"
class MinecraftProfile;
-
-enum ProblemSeverity
-{
- PROBLEM_NONE,
- PROBLEM_WARNING,
- PROBLEM_ERROR
-};
-
-/// where is a version from?
-enum class VersionSource
+namespace Meta
{
- Builtin, //!< version loaded from the internal resources.
- Local, //!< version loaded from a file in the cache.
- Remote, //!< incomplete version on a remote server.
-};
+ class Version;
+ class VersionList;
+}
+class VersionFile;
-class PatchProblem
+class ProfilePatch : public ProblemProvider
{
public:
- PatchProblem(ProblemSeverity severity, const QString & description)
- {
- m_severity = severity;
- m_description = description;
- }
- const QString & getDescription() const
- {
- return m_description;
- }
- const ProblemSeverity getSeverity() const
- {
- return m_severity;
- }
-private:
- ProblemSeverity m_severity;
- QString m_description;
-};
+ ProfilePatch(std::shared_ptr<Meta::Version> version);
+ ProfilePatch(std::shared_ptr<VersionFile> file, const QString &filename = QString());
-class ProfilePatch : public std::enable_shared_from_this<ProfilePatch>
-{
-public:
virtual ~ProfilePatch(){};
- virtual void applyTo(MinecraftProfile *profile) = 0;
-
- virtual bool isMinecraftVersion() = 0;
- virtual bool hasJarMods() = 0;
- virtual QList<JarmodPtr> getJarMods() = 0;
-
- virtual bool isMoveable() = 0;
- virtual bool isCustomizable() = 0;
- virtual bool isRevertible() = 0;
- virtual bool isRemovable() = 0;
- virtual bool isCustom() = 0;
- virtual bool isEditable() = 0;
- virtual bool isVersionChangeable() = 0;
-
- virtual void setOrder(int order) = 0;
- virtual int getOrder() = 0;
-
- virtual QString getID() = 0;
- virtual QString getName() = 0;
- virtual QString getVersion() = 0;
- virtual QDateTime getReleaseDateTime() = 0;
-
- virtual QString getFilename() = 0;
-
- virtual VersionSource getVersionSource() = 0;
-
- virtual std::shared_ptr<class VersionFile> getVersionFile() = 0;
-
- virtual const QList<PatchProblem>& getProblems()
- {
- return m_problems;
- }
- virtual void addProblem(ProblemSeverity severity, const QString &description)
- {
- if(severity > m_problemSeverity)
- {
- m_problemSeverity = severity;
- }
- m_problems.append(PatchProblem(severity, description));
- }
- virtual ProblemSeverity getProblemSeverity()
- {
- return m_problemSeverity;
- }
- virtual bool hasFailed()
- {
- return getProblemSeverity() == PROBLEM_ERROR;
- }
+ virtual void applyTo(MinecraftProfile *profile);
+
+ virtual bool isMoveable();
+ virtual bool isCustomizable();
+ virtual bool isRevertible();
+ virtual bool isRemovable();
+ virtual bool isCustom();
+ virtual bool isVersionChangeable();
+
+ virtual void setOrder(int order);
+ virtual int getOrder();
+
+ virtual QString getID();
+ virtual QString getName();
+ virtual QString getVersion();
+ virtual QDateTime getReleaseDateTime();
+
+ virtual QString getFilename();
+
+ virtual std::shared_ptr<class VersionFile> getVersionFile();
+ virtual std::shared_ptr<class Meta::VersionList> getVersionList();
+
+ void setVanilla (bool state);
+ void setRemovable (bool state);
+ void setRevertible (bool state);
+ void setMovable (bool state);
+
+
+ const QList<PatchProblem> getProblems() override;
+ ProblemSeverity getProblemSeverity() override;
protected:
- QList<PatchProblem> m_problems;
- ProblemSeverity m_problemSeverity = PROBLEM_NONE;
+ // Properties for UI and version manipulation from UI in general
+ bool m_isMovable = false;
+ bool m_isRevertible = false;
+ bool m_isRemovable = false;
+ bool m_isVanilla = false;
+
+ bool m_orderOverride = false;
+ int m_order = 0;
+
+ std::shared_ptr<Meta::Version> m_metaVersion;
+ std::shared_ptr<VersionFile> m_file;
+ QString m_filename;
};
typedef std::shared_ptr<ProfilePatch> ProfilePatchPtr;
diff --git a/api/logic/minecraft/ProfileStrategy.h b/api/logic/minecraft/ProfileStrategy.h
index b4dfc4b3..26bdf661 100644
--- a/api/logic/minecraft/ProfileStrategy.h
+++ b/api/logic/minecraft/ProfileStrategy.h
@@ -1,6 +1,7 @@
#pragma once
#include "ProfileUtils.h"
+#include "ProfilePatch.h"
class MinecraftProfile;
diff --git a/api/logic/minecraft/ProfileUtils.cpp b/api/logic/minecraft/ProfileUtils.cpp
index ef9b3b28..8c5bc052 100644
--- a/api/logic/minecraft/ProfileUtils.cpp
+++ b/api/logic/minecraft/ProfileUtils.cpp
@@ -102,9 +102,9 @@ bool readOverrideOrders(QString path, PatchOrder &order)
static VersionFilePtr createErrorVersionFile(QString fileId, QString filepath, QString error)
{
auto outError = std::make_shared<VersionFile>();
- outError->fileId = outError->name = fileId;
- outError->filename = filepath;
- outError->addProblem(PROBLEM_ERROR, error);
+ outError->uid = outError->name = fileId;
+ // outError->filename = filepath;
+ outError->addProblem(ProblemSeverity::Error, error);
return outError;
}
diff --git a/api/logic/minecraft/VersionBuildError.h b/api/logic/minecraft/VersionBuildError.h
index fda453e5..f362c405 100644
--- a/api/logic/minecraft/VersionBuildError.h
+++ b/api/logic/minecraft/VersionBuildError.h
@@ -27,23 +27,6 @@ public:
};
/**
- * some patch was intended for a different version of minecraft
- */
-class MinecraftVersionMismatch : public VersionBuildError
-{
-public:
- MinecraftVersionMismatch(QString fileId, QString mcVersion, QString parentMcVersion)
- : VersionBuildError(QObject::tr("The patch %1 is for a different version of Minecraft "
- "(%2) than that of the instance (%3).")
- .arg(fileId)
- .arg(mcVersion)
- .arg(parentMcVersion)) {};
- virtual ~MinecraftVersionMismatch() noexcept
- {
- }
-};
-
-/**
* files required for the version are not (yet?) present
*/
class VersionIncomplete : public VersionBuildError
diff --git a/api/logic/minecraft/VersionFile.cpp b/api/logic/minecraft/VersionFile.cpp
index 573c4cb4..b261ff2a 100644
--- a/api/logic/minecraft/VersionFile.cpp
+++ b/api/logic/minecraft/VersionFile.cpp
@@ -12,37 +12,28 @@
#include "VersionBuildError.h"
#include <Version.h>
-bool VersionFile::isMinecraftVersion()
+static bool isMinecraftVersion(const QString &uid)
{
- return fileId == "net.minecraft";
-}
-
-bool VersionFile::hasJarMods()
-{
- return !jarMods.isEmpty();
+ return uid == "net.minecraft";
}
void VersionFile::applyTo(MinecraftProfile *profile)
{
- auto theirVersion = profile->getMinecraftVersion();
- if (!theirVersion.isNull() && !dependsOnMinecraftVersion.isNull())
+ // Only real Minecraft can set those. Don't let anything override them.
+ if (isMinecraftVersion(uid))
{
- if (QRegExp(dependsOnMinecraftVersion, Qt::CaseInsensitive, QRegExp::Wildcard).indexIn(theirVersion) == -1)
- {
- throw MinecraftVersionMismatch(fileId, dependsOnMinecraftVersion, theirVersion);
- }
+ profile->applyMinecraftVersion(minecraftVersion);
+ profile->applyMinecraftVersionType(type);
+ // HACK: ignore assets from other version files than Minecraft
+ // workaround for stupid assets issue caused by amazon:
+ // https://www.theregister.co.uk/2017/02/28/aws_is_awol_as_s3_goes_haywire/
+ profile->applyMinecraftAssets(mojangAssetIndex);
}
- profile->applyMinecraftVersion(minecraftVersion);
+
profile->applyMainClass(mainClass);
profile->applyAppletClass(appletClass);
profile->applyMinecraftArguments(minecraftArguments);
- if (isMinecraftVersion())
- {
- profile->applyMinecraftVersionType(type);
- }
- profile->applyMinecraftAssets(mojangAssetIndex);
profile->applyTweakers(addTweakers);
-
profile->applyJarMods(jarMods);
profile->applyTraits(traits);
@@ -58,3 +49,14 @@ void VersionFile::applyTo(MinecraftProfile *profile)
iter++;
}
}
+
+/*
+ auto theirVersion = profile->getMinecraftVersion();
+ if (!theirVersion.isNull() && !dependsOnMinecraftVersion.isNull())
+ {
+ if (QRegExp(dependsOnMinecraftVersion, Qt::CaseInsensitive, QRegExp::Wildcard).indexIn(theirVersion) == -1)
+ {
+ throw MinecraftVersionMismatch(uid, dependsOnMinecraftVersion, theirVersion);
+ }
+ }
+*/ \ No newline at end of file
diff --git a/api/logic/minecraft/VersionFile.h b/api/logic/minecraft/VersionFile.h
index 249d0965..312d0a3b 100644
--- a/api/logic/minecraft/VersionFile.h
+++ b/api/logic/minecraft/VersionFile.h
@@ -8,7 +8,7 @@
#include <memory>
#include "minecraft/OpSys.h"
#include "minecraft/Rule.h"
-#include "ProfilePatch.h"
+#include "ProblemProvider.h"
#include "Library.h"
#include "JarMod.h"
@@ -18,126 +18,25 @@ struct MojangDownloadInfo;
struct MojangAssetIndexInfo;
typedef std::shared_ptr<VersionFile> VersionFilePtr;
-class VersionFile : public ProfilePatch
+class VersionFile : public ProblemContainer
{
friend class MojangVersionFormat;
friend class OneSixVersionFormat;
public: /* methods */
- virtual void applyTo(MinecraftProfile *profile) override;
- virtual bool isMinecraftVersion() override;
- virtual bool hasJarMods() override;
- virtual int getOrder() override
- {
- return order;
- }
- virtual void setOrder(int order) override
- {
- this->order = order;
- }
- virtual QList<JarmodPtr> getJarMods() override
- {
- return jarMods;
- }
- virtual QString getID() override
- {
- return fileId;
- }
- virtual QString getName() override
- {
- return name;
- }
- virtual QString getVersion() override
- {
- return version;
- }
- virtual QString getFilename() override
- {
- return filename;
- }
- virtual QDateTime getReleaseDateTime() override
- {
- return m_releaseTime;
- }
- VersionSource getVersionSource() override
- {
- return VersionSource::Local;
- }
-
- std::shared_ptr<class VersionFile> getVersionFile() override
- {
- return std::dynamic_pointer_cast<VersionFile>(shared_from_this());
- }
-
- virtual bool isCustom() override
- {
- return !m_isVanilla;
- };
- virtual bool isCustomizable() override
- {
- return m_isCustomizable;
- }
- virtual bool isRemovable() override
- {
- return m_isRemovable;
- }
- virtual bool isRevertible() override
- {
- return m_isRevertible;
- }
- virtual bool isMoveable() override
- {
- return m_isMovable;
- }
- virtual bool isEditable() override
- {
- return isCustom();
- }
- virtual bool isVersionChangeable() override
- {
- return false;
- }
-
- void setVanilla (bool state)
- {
- m_isVanilla = state;
- }
- void setRemovable (bool state)
- {
- m_isRemovable = state;
- }
- void setRevertible (bool state)
- {
- m_isRevertible = state;
- }
- void setCustomizable (bool state)
- {
- m_isCustomizable = state;
- }
- void setMovable (bool state)
- {
- m_isMovable = state;
- }
-
+ void applyTo(MinecraftProfile *profile);
public: /* data */
/// MultiMC: order hint for this version file if no explicit order is set
int order = 0;
- // Flags for UI and version file manipulation in general
- bool m_isVanilla = false;
- bool m_isRemovable = false;
- bool m_isRevertible = false;
- bool m_isCustomizable = false;
- bool m_isMovable = false;
-
/// MultiMC: filename of the file this was loaded from
- QString filename;
+ // QString filename;
/// MultiMC: human readable name of this package
QString name;
/// MultiMC: package ID of this package
- QString fileId;
+ QString uid;
/// MultiMC: version of this package
QString version;
@@ -148,13 +47,13 @@ public: /* data */
/// Mojang: used to version the Mojang version format
int minimumLauncherVersion = -1;
- /// Mojang: version of Minecraft this is
+ /// Mojang: DEPRECATED version of Minecraft this is
QString minecraftVersion;
/// Mojang: class to launch Minecraft with
QString mainClass;
- /// MultiMC: DEPRECATED class to launch legacy Minecraft with (ambed in a custom window)
+ /// MultiMC: class to launch legacy Minecraft with (embed in a custom window)
QString appletClass;
/// Mojang: Minecraft launch arguments (may contain placeholders for variable substitution)
@@ -164,10 +63,10 @@ public: /* data */
QString type;
/// Mojang: the time this version was actually released by Mojang
- QDateTime m_releaseTime;
+ QDateTime releaseTime;
/// Mojang: the time this version was last updated by Mojang
- QDateTime m_updateTime;
+ QDateTime updateTime;
/// Mojang: DEPRECATED asset group to be used with Minecraft
QString assets;
@@ -191,5 +90,3 @@ public:
// Mojang: extended asset index download information
std::shared_ptr<MojangAssetIndexInfo> mojangAssetIndex;
};
-
-
diff --git a/api/logic/minecraft/VersionFilterData.cpp b/api/logic/minecraft/VersionFilterData.cpp
index 0c4a6e3d..5f4ceee6 100644
--- a/api/logic/minecraft/VersionFilterData.cpp
+++ b/api/logic/minecraft/VersionFilterData.cpp
@@ -58,18 +58,11 @@ VersionFilterData::VersionFilterData()
// don't use installers for those.
forgeInstallerBlacklist = QSet<QString>({"1.5.2"});
- // these won't show up in version lists because they are extremely bad and dangerous
- legacyBlacklist = QSet<QString>({"rd-160052"});
- /*
- * nothing older than this will be accepted from Mojang servers
- * (these versions need to be tested by us first)
- */
+
+ // FIXME: remove, used for deciding when core mods should display
legacyCutoffDate = timeFromS3Time("2013-06-25T15:08:56+02:00");
lwjglWhitelist =
QSet<QString>{"net.java.jinput:jinput", "net.java.jinput:jinput-platform",
"net.java.jutils:jutils", "org.lwjgl.lwjgl:lwjgl",
"org.lwjgl.lwjgl:lwjgl_util", "org.lwjgl.lwjgl:lwjgl-platform"};
-
- // Version list magic
- recommendedMinecraftVersion = "1.7.10";
}
diff --git a/api/logic/minecraft/VersionFilterData.h b/api/logic/minecraft/VersionFilterData.h
index f7d4ebe7..2408e704 100644
--- a/api/logic/minecraft/VersionFilterData.h
+++ b/api/logic/minecraft/VersionFilterData.h
@@ -20,13 +20,9 @@ struct VersionFilterData
QMap<QString, QList<FMLlib>> fmlLibsMapping;
// set of minecraft versions for which using forge installers is blacklisted
QSet<QString> forgeInstallerBlacklist;
- // set of 'legacy' versions that will not show up in the version lists.
- QSet<QString> legacyBlacklist;
// no new versions below this date will be accepted from Mojang servers
QDateTime legacyCutoffDate;
// Libraries that belong to LWJGL
QSet<QString> lwjglWhitelist;
- // Currently recommended minecraft version
- QString recommendedMinecraftVersion;
};
extern VersionFilterData MULTIMC_LOGIC_EXPORT g_VersionFilterData;
diff --git a/api/logic/minecraft/forge/ForgeInstaller.cpp b/api/logic/minecraft/forge/ForgeInstaller.cpp
deleted file mode 100644
index a9c12fcd..00000000
--- a/api/logic/minecraft/forge/ForgeInstaller.cpp
+++ /dev/null
@@ -1,458 +0,0 @@
-/* Copyright 2013-2017 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.
- */
-
-#include "ForgeInstaller.h"
-#include "ForgeVersionList.h"
-
-#include "minecraft/MinecraftProfile.h"
-#include "minecraft/GradleSpecifier.h"
-#include "net/HttpMetaCache.h"
-#include "tasks/Task.h"
-#include "minecraft/onesix/OneSixInstance.h"
-#include <minecraft/onesix/OneSixVersionFormat.h>
-#include "minecraft/VersionFilterData.h"
-#include "minecraft/MinecraftVersion.h"
-#include "Env.h"
-#include "Exception.h"
-#include <FileSystem.h>
-
-#include <quazip.h>
-#include <quazipfile.h>
-#include <QStringList>
-#include <QRegularExpression>
-#include <QRegularExpressionMatch>
-
-#include <QJsonDocument>
-#include <QJsonArray>
-#include <QSaveFile>
-#include <QCryptographicHash>
-
-ForgeInstaller::ForgeInstaller() : BaseInstaller()
-{
-}
-
-void ForgeInstaller::prepare(const QString &filename, const QString &universalUrl)
-{
- VersionFilePtr newVersion;
- m_universal_url = universalUrl;
-
- QuaZip zip(filename);
- if (!zip.open(QuaZip::mdUnzip))
- return;
-
- QuaZipFile file(&zip);
-
- // read the install profile
- if (!zip.setCurrentFile("install_profile.json"))
- return;
-
- QJsonParseError jsonError;
- if (!file.open(QIODevice::ReadOnly))
- return;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(file.readAll(), &jsonError);
- file.close();
- if (jsonError.error != QJsonParseError::NoError)
- return;
-
- if (!jsonDoc.isObject())
- return;
-
- QJsonObject root = jsonDoc.object();
-
- auto installVal = root.value("install");
- auto versionInfoVal = root.value("versionInfo");
- if (!installVal.isObject() || !versionInfoVal.isObject())
- return;
-
- try
- {
- newVersion = OneSixVersionFormat::versionFileFromJson(QJsonDocument(versionInfoVal.toObject()), QString(), false);
- }
- catch(Exception &err)
- {
- qWarning() << "Forge: Fatal error while parsing version file:" << err.what();
- return;
- }
-
- for(auto problem: newVersion->getProblems())
- {
- qWarning() << "Forge: Problem found: " << problem.getDescription();
- }
- if(newVersion->getProblemSeverity() == ProblemSeverity::PROBLEM_ERROR)
- {
- qWarning() << "Forge: Errors found while parsing version file";
- return;
- }
-
- QJsonObject installObj = installVal.toObject();
- QString libraryName = installObj.value("path").toString();
- internalPath = installObj.value("filePath").toString();
- m_forgeVersionString = installObj.value("version").toString().remove("Forge", Qt::CaseInsensitive).trimmed();
-
- // where do we put the library? decode the mojang path
- GradleSpecifier lib(libraryName);
-
- auto cacheentry = ENV.metacache()->resolveEntry("libraries", lib.toPath());
- finalPath = "libraries/" + lib.toPath();
- if (!FS::ensureFilePathExists(finalPath))
- return;
-
- if (!zip.setCurrentFile(internalPath))
- return;
- if (!file.open(QIODevice::ReadOnly))
- return;
- {
- QByteArray data = file.readAll();
- // extract file
- QSaveFile extraction(finalPath);
- if (!extraction.open(QIODevice::WriteOnly))
- return;
- if (extraction.write(data) != data.size())
- return;
- if (!extraction.commit())
- return;
- QCryptographicHash md5sum(QCryptographicHash::Md5);
- md5sum.addData(data);
-
- cacheentry->setStale(false);
- cacheentry->setMD5Sum(md5sum.result().toHex().constData());
- ENV.metacache()->updateEntry(cacheentry);
- }
- file.close();
-
- m_forge_json = newVersion;
-}
-
-bool ForgeInstaller::add(OneSixInstance *to)
-{
- if (!BaseInstaller::add(to))
- {
- return false;
- }
-
- if (!m_forge_json)
- {
- return false;
- }
-
- // A blacklist
- QSet<QString> blacklist{"authlib", "realms"};
- QList<QString> xzlist{"org.scala-lang", "com.typesafe"};
-
- // get the minecraft version from the instance
- VersionFilePtr minecraft;
- auto minecraftPatch = to->getMinecraftProfile()->versionPatch("net.minecraft");
- if(minecraftPatch)
- {
- minecraft = std::dynamic_pointer_cast<VersionFile>(minecraftPatch);
- if(!minecraft)
- {
- auto mcWrap = std::dynamic_pointer_cast<MinecraftVersion>(minecraftPatch);
- if(mcWrap)
- {
- minecraft = mcWrap->getVersionFile();
- }
- }
- }
-
- // for each library in the version we are adding (except for the blacklisted)
- QMutableListIterator<LibraryPtr> iter(m_forge_json->libraries);
- while (iter.hasNext())
- {
- auto library = iter.next();
- QString libName = library->artifactId();
- QString libVersion = library->version();
- QString rawName = library->rawName();
-
- // ignore lwjgl libraries.
- if (g_VersionFilterData.lwjglWhitelist.contains(library->artifactPrefix()))
- {
- iter.remove();
- continue;
- }
- // ignore other blacklisted (realms, authlib)
- if (blacklist.contains(libName))
- {
- iter.remove();
- continue;
- }
- // if minecraft version was found, ignore everything that is already in the minecraft version
- if(minecraft)
- {
- bool found = false;
- for (auto & lib: minecraft->libraries)
- {
- if(library->artifactPrefix() == lib->artifactPrefix() && library->version() == lib->version())
- {
- found = true;
- break;
- }
- }
- if (found)
- continue;
- }
-
- // if this is the actual forge lib, set an absolute url for the download
- if (m_forge_version->type == ForgeVersion::Gradle)
- {
- if (libName == "forge")
- {
- library->setClassifier("universal");
- }
- else if (libName == "minecraftforge")
- {
- QString forgeCoord("net.minecraftforge:forge:%1:universal");
- // using insane form of the MC version...
- QString longVersion = m_forge_version->mcver + "-" + m_forge_version->jobbuildver;
- GradleSpecifier spec(forgeCoord.arg(longVersion));
- library->setRawName(spec);
- }
- }
- else
- {
- if (libName.contains("minecraftforge"))
- {
- library->setAbsoluteUrl(m_universal_url);
- }
- }
-
- // mark bad libraries based on the xzlist above
- for (auto entry : xzlist)
- {
- qDebug() << "Testing " << rawName << " : " << entry;
- if (rawName.startsWith(entry))
- {
- library->setHint("forge-pack-xz");
- break;
- }
- }
- }
- QString &args = m_forge_json->minecraftArguments;
- QStringList tweakers;
- {
- QRegularExpression expression("--tweakClass ([a-zA-Z0-9\\.]*)");
- QRegularExpressionMatch match = expression.match(args);
- while (match.hasMatch())
- {
- tweakers.append(match.captured(1));
- args.remove(match.capturedStart(), match.capturedLength());
- match = expression.match(args);
- }
- if(tweakers.size())
- {
- args.operator=(args.trimmed());
- m_forge_json->addTweakers = tweakers;
- }
- }
- if(minecraft && args == minecraft->minecraftArguments)
- {
- args.clear();
- }
-
- m_forge_json->name = "Forge";
- m_forge_json->fileId = id();
- m_forge_json->version = m_forgeVersionString;
- m_forge_json->dependsOnMinecraftVersion = to->intendedVersionId();
- m_forge_json->order = 5;
-
- // reset some things we do not want to be passed along.
- m_forge_json->m_releaseTime = QDateTime();
- m_forge_json->m_updateTime = QDateTime();
- m_forge_json->minimumLauncherVersion = -1;
- m_forge_json->type.clear();
- m_forge_json->minecraftArguments.clear();
- m_forge_json->minecraftVersion.clear();
-
- QSaveFile file(filename(to->instanceRoot()));
- if (!file.open(QFile::WriteOnly))
- {
- qCritical() << "Error opening" << file.fileName()
- << "for reading:" << file.errorString();
- return false;
- }
- file.write(OneSixVersionFormat::versionFileToJson(m_forge_json, true).toJson());
- file.commit();
-
- return true;
-}
-
-bool ForgeInstaller::addLegacy(OneSixInstance *to)
-{
- if (!BaseInstaller::add(to))
- {
- return false;
- }
- auto entry = ENV.metacache()->resolveEntry("minecraftforge", m_forge_version->filename());
- finalPath = FS::PathCombine(to->jarModsDir(), m_forge_version->filename());
- if (!FS::ensureFilePathExists(finalPath))
- {
- return false;
- }
- if (!QFile::copy(entry->getFullPath(), finalPath))
- {
- return false;
- }
- QJsonObject obj;
- obj.insert("order", 5);
- {
- QJsonArray jarmodsPlus;
- {
- QJsonObject libObj;
- libObj.insert("name", m_forge_version->universal_filename);
- jarmodsPlus.append(libObj);
- }
- obj.insert("+jarMods", jarmodsPlus);
- }
-
- obj.insert("name", QString("Forge"));
- obj.insert("fileId", id());
- obj.insert("version", m_forge_version->jobbuildver);
- obj.insert("mcVersion", to->intendedVersionId());
- if (g_VersionFilterData.fmlLibsMapping.contains(m_forge_version->mcver))
- {
- QJsonArray traitsPlus;
- traitsPlus.append(QString("legacyFML"));
- obj.insert("+traits", traitsPlus);
- }
- auto fullversion = to->getMinecraftProfile();
- fullversion->remove("net.minecraftforge");
-
- QFile file(filename(to->instanceRoot()));
- if (!file.open(QFile::WriteOnly))
- {
- qCritical() << "Error opening" << file.fileName()
- << "for reading:" << file.errorString();
- return false;
- }
- file.write(QJsonDocument(obj).toJson());
- file.close();
- return true;
-}
-
-class ForgeInstallTask : public Task
-{
- Q_OBJECT
-public:
- ForgeInstallTask(ForgeInstaller *installer, OneSixInstance *instance,
- BaseVersionPtr version, QObject *parent = 0)
- : Task(parent), m_installer(installer), m_instance(instance), m_version(version)
- {
- }
-
-protected:
- void executeTask() override
- {
- setStatus(tr("Installing Forge..."));
- ForgeVersionPtr forgeVersion = std::dynamic_pointer_cast<ForgeVersion>(m_version);
- if (!forgeVersion)
- {
- emitFailed(tr("Unknown error occured"));
- return;
- }
- prepare(forgeVersion);
- }
- void prepare(ForgeVersionPtr forgeVersion)
- {
- auto entry = ENV.metacache()->resolveEntry("minecraftforge", forgeVersion->filename());
- auto installFunction = [this, entry, forgeVersion]()
- {
- if (!install(entry, forgeVersion))
- {
- qCritical() << "Failure installing Forge";
- emitFailed(tr("Failure to install Forge"));
- }
- else
- {
- reload();
- }
- };
-
- /*
- * HACK IF the local non-stale file is too small, mark is as stale
- *
- * This fixes some problems with bad files acquired because of unhandled HTTP redirects
- * in old versions of MultiMC.
- */
- if (!entry->isStale())
- {
- QFileInfo localFile(entry->getFullPath());
- if (localFile.size() <= 0x4000)
- {
- entry->setStale(true);
- }
- }
-
- if (entry->isStale())
- {
- NetJob *fjob = new NetJob("Forge download");
- fjob->addNetAction(Net::Download::makeCached(forgeVersion->url(), entry));
- connect(fjob, &NetJob::progress, this, &Task::setProgress);
- connect(fjob, &NetJob::status, this, &Task::setStatus);
- connect(fjob, &NetJob::failed, [this](QString reason)
- { emitFailed(tr("Failure to download Forge:\n%1").arg(reason)); });
- connect(fjob, &NetJob::succeeded, installFunction);
- fjob->start();
- }
- else
- {
- installFunction();
- }
- }
- bool install(const std::shared_ptr<MetaEntry> &entry, const ForgeVersionPtr &forgeVersion)
- {
- if (forgeVersion->usesInstaller())
- {
- QString forgePath = entry->getFullPath();
- m_installer->prepare(forgePath, forgeVersion->universal_url);
- return m_installer->add(m_instance);
- }
- else
- return m_installer->addLegacy(m_instance);
- }
- void reload()
- {
- try
- {
- m_instance->reloadProfile();
- emitSucceeded();
- }
- catch (Exception &e)
- {
- emitFailed(e.cause());
- }
- catch (...)
- {
- emitFailed(tr("Failed to load the version description file for reasons unknown."));
- }
- }
-
-private:
- ForgeInstaller *m_installer;
- OneSixInstance *m_instance;
- BaseVersionPtr m_version;
-};
-
-Task *ForgeInstaller::createInstallTask(OneSixInstance *instance,
- BaseVersionPtr version, QObject *parent)
-{
- if (!version)
- {
- return nullptr;
- }
- m_forge_version = std::dynamic_pointer_cast<ForgeVersion>(version);
- return new ForgeInstallTask(this, instance, version, parent);
-}
-
-#include "ForgeInstaller.moc"
diff --git a/api/logic/minecraft/forge/ForgeInstaller.h b/api/logic/minecraft/forge/ForgeInstaller.h
deleted file mode 100644
index 26286be7..00000000
--- a/api/logic/minecraft/forge/ForgeInstaller.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright 2013-2017 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 "BaseInstaller.h"
-
-#include <QString>
-#include <memory>
-
-#include "multimc_logic_export.h"
-
-class VersionFile;
-class ForgeInstallTask;
-struct ForgeVersion;
-
-class MULTIMC_LOGIC_EXPORT ForgeInstaller : public BaseInstaller
-{
- friend class ForgeInstallTask;
-public:
- ForgeInstaller();
- virtual ~ForgeInstaller(){}
- virtual Task *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) override;
- virtual QString id() const override { return "net.minecraftforge"; }
-
-protected:
- void prepare(const QString &filename, const QString &universalUrl);
- bool add(OneSixInstance *to) override;
- bool addLegacy(OneSixInstance *to);
-
-private:
- // the parsed version json, read from the installer
- std::shared_ptr<VersionFile> m_forge_json;
- // the actual forge version
- std::shared_ptr<ForgeVersion> m_forge_version;
- QString internalPath;
- QString finalPath;
- QString m_forgeVersionString;
- QString m_universal_url;
-};
diff --git a/api/logic/minecraft/forge/ForgeVersion.cpp b/api/logic/minecraft/forge/ForgeVersion.cpp
deleted file mode 100644
index b859a28c..00000000
--- a/api/logic/minecraft/forge/ForgeVersion.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "ForgeVersion.h"
-#include "minecraft/VersionFilterData.h"
-#include <QObject>
-
-QString ForgeVersion::name()
-{
- return "Forge " + jobbuildver;
-}
-
-QString ForgeVersion::descriptor()
-{
- return universal_filename;
-}
-
-QString ForgeVersion::typeString() const
-{
- if (is_recommended)
- return QObject::tr("Recommended");
- return QString();
-}
-
-bool ForgeVersion::operator<(BaseVersion &a)
-{
- ForgeVersion *pa = dynamic_cast<ForgeVersion *>(&a);
- if (!pa)
- return true;
- return m_buildnr < pa->m_buildnr;
-}
-
-bool ForgeVersion::operator>(BaseVersion &a)
-{
- ForgeVersion *pa = dynamic_cast<ForgeVersion *>(&a);
- if (!pa)
- return false;
- return m_buildnr > pa->m_buildnr;
-}
-
-bool ForgeVersion::usesInstaller()
-{
- if(installer_url.isEmpty())
- return false;
- if(g_VersionFilterData.forgeInstallerBlacklist.contains(mcver))
- return false;
- return true;
-}
-
-QString ForgeVersion::filename()
-{
- return usesInstaller() ? installer_filename : universal_filename;
-}
-
-QString ForgeVersion::url()
-{
- return usesInstaller() ? installer_url : universal_url;
-}
diff --git a/api/logic/minecraft/forge/ForgeVersion.h b/api/logic/minecraft/forge/ForgeVersion.h
deleted file mode 100644
index e77d32f1..00000000
--- a/api/logic/minecraft/forge/ForgeVersion.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#pragma once
-#include <QString>
-#include <memory>
-#include "BaseVersion.h"
-
-struct ForgeVersion;
-typedef std::shared_ptr<ForgeVersion> ForgeVersionPtr;
-
-struct ForgeVersion : public BaseVersion
-{
- virtual QString descriptor() override;
- virtual QString name() override;
- virtual QString typeString() const override;
- virtual bool operator<(BaseVersion &a) override;
- virtual bool operator>(BaseVersion &a) override;
-
- QString filename();
- QString url();
-
- enum
- {
- Invalid,
- Legacy,
- Gradle
- } type = Invalid;
-
- bool usesInstaller();
-
- int m_buildnr = 0;
- QString branch;
- QString universal_url;
- QString changelog_url;
- QString installer_url;
- QString jobbuildver;
- QString mcver;
- QString mcver_sane;
- QString universal_filename;
- QString installer_filename;
- bool is_recommended = false;
-};
-
-Q_DECLARE_METATYPE(ForgeVersionPtr)
diff --git a/api/logic/minecraft/forge/ForgeVersionList.cpp b/api/logic/minecraft/forge/ForgeVersionList.cpp
deleted file mode 100644
index 2fb3d012..00000000
--- a/api/logic/minecraft/forge/ForgeVersionList.cpp
+++ /dev/null
@@ -1,333 +0,0 @@
-/* Copyright 2013-2017 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.
- */
-
-#include "ForgeVersionList.h"
-#include "ForgeVersion.h"
-
-#include "net/NetJob.h"
-#include "net/URLConstants.h"
-#include "Env.h"
-
-#include <QtNetwork>
-#include <QtXml>
-#include <QRegExp>
-
-#include <QDebug>
-
-ForgeVersionList::ForgeVersionList(QObject *parent) : BaseVersionList(parent)
-{
-}
-
-Task *ForgeVersionList::getLoadTask()
-{
- return new ForgeListLoadTask(this);
-}
-
-bool ForgeVersionList::isLoaded()
-{
- return m_loaded;
-}
-
-const BaseVersionPtr ForgeVersionList::at(int i) const
-{
- return m_vlist.at(i);
-}
-
-int ForgeVersionList::count() const
-{
- return m_vlist.count();
-}
-
-int ForgeVersionList::columnCount(const QModelIndex &parent) const
-{
- return 1;
-}
-
-QVariant ForgeVersionList::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- if (index.row() > count())
- return QVariant();
-
- auto version = std::dynamic_pointer_cast<ForgeVersion>(m_vlist[index.row()]);
- switch (role)
- {
- case VersionPointerRole:
- return qVariantFromValue(m_vlist[index.row()]);
-
- case VersionRole:
- return version->name();
-
- case VersionIdRole:
- return version->descriptor();
-
- case ParentGameVersionRole:
- return version->mcver_sane;
-
- case RecommendedRole:
- return version->is_recommended;
-
- case BranchRole:
- return version->branch;
-
- default:
- return QVariant();
- }
-}
-
-BaseVersionList::RoleList ForgeVersionList::providesRoles() const
-{
- return {VersionPointerRole, VersionRole, VersionIdRole, ParentGameVersionRole, RecommendedRole, BranchRole};
-}
-
-BaseVersionPtr ForgeVersionList::getLatestStable() const
-{
- return BaseVersionPtr();
-}
-
-void ForgeVersionList::updateListData(QList<BaseVersionPtr> versions)
-{
- beginResetModel();
- m_vlist = versions;
- m_loaded = true;
- endResetModel();
- // NOW SORT!!
- // sort();
-}
-
-void ForgeVersionList::sortVersions()
-{
- // NO-OP for now
-}
-
-ForgeListLoadTask::ForgeListLoadTask(ForgeVersionList *vlist) : Task()
-{
- m_list = vlist;
-}
-
-void ForgeListLoadTask::executeTask()
-{
- setStatus(tr("Fetching Forge version lists..."));
- auto job = new NetJob("Version index");
- // we do not care if the version is stale or not.
- auto forgeListEntry = ENV.metacache()->resolveEntry("minecraftforge", "list.json");
- auto gradleForgeListEntry = ENV.metacache()->resolveEntry("minecraftforge", "json");
-
- // verify by poking the server.
- forgeListEntry->setStale(true);
- gradleForgeListEntry->setStale(true);
-
- job->addNetAction(listDownload = Net::Download::makeCached(QUrl(URLConstants::FORGE_LEGACY_URL),forgeListEntry));
- job->addNetAction(gradleListDownload = Net::Download::makeCached(QUrl(URLConstants::FORGE_GRADLE_URL), gradleForgeListEntry));
-
- connect(listDownload.get(), SIGNAL(failed(int)), SLOT(listFailed()));
- connect(gradleListDownload.get(), SIGNAL(failed(int)), SLOT(gradleListFailed()));
-
- listJob.reset(job);
- connect(listJob.get(), SIGNAL(succeeded()), SLOT(listDownloaded()));
- connect(listJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
- listJob->start();
-}
-
-bool ForgeListLoadTask::abort()
-{
- return listJob->abort();
-}
-
-bool ForgeListLoadTask::parseForgeGradleList(QList<BaseVersionPtr> &out)
-{
- QMap<int, std::shared_ptr<ForgeVersion>> lookup;
- QByteArray data;
- {
- auto filename = gradleListDownload->getTargetFilepath();
- QFile listFile(filename);
- if (!listFile.open(QIODevice::ReadOnly))
- {
- return false;
- }
- data = listFile.readAll();
- gradleListDownload.reset();
- }
-
- QJsonParseError jsonError;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
-
- if (jsonError.error != QJsonParseError::NoError)
- {
- emitFailed("Error parsing gradle version list JSON:" + jsonError.errorString());
- return false;
- }
-
- if (!jsonDoc.isObject())
- {
- emitFailed("Error parsing gradle version list JSON: JSON root is not an object");
- return false;
- }
-
- QJsonObject root = jsonDoc.object();
-
- // we probably could hard code these, but it might still be worth doing it this way
- const QString webpath = root.value("webpath").toString();
- const QString artifact = root.value("artifact").toString();
-
- QJsonObject numbers = root.value("number").toObject();
- for (auto it = numbers.begin(); it != numbers.end(); ++it)
- {
- QJsonObject number = it.value().toObject();
- std::shared_ptr<ForgeVersion> fVersion(new ForgeVersion());
- fVersion->m_buildnr = number.value("build").toDouble();
- if(fVersion->m_buildnr >= 953 && fVersion->m_buildnr <= 965)
- {
- qDebug() << fVersion->m_buildnr;
- }
- fVersion->jobbuildver = number.value("version").toString();
- fVersion->branch = number.value("branch").toString("");
- fVersion->mcver = number.value("mcversion").toString();
- fVersion->universal_filename = "";
- fVersion->installer_filename = "";
- // HACK: here, we fix the minecraft version used by forge.
- // HACK: this will inevitably break (later)
- // FIXME: replace with a dictionary
- fVersion->mcver_sane = fVersion->mcver;
- fVersion->mcver_sane.replace("_pre", "-pre");
-
- QString universal_filename, installer_filename;
- QJsonArray files = number.value("files").toArray();
- for (auto fIt = files.begin(); fIt != files.end(); ++fIt)
- {
- // TODO with gradle we also get checksums, use them
- QJsonArray file = (*fIt).toArray();
- if (file.size() < 3)
- {
- continue;
- }
-
- QString extension = file.at(0).toString();
- QString part = file.at(1).toString();
- QString checksum = file.at(2).toString();
-
- // insane form of mcver is used here
- QString longVersion = fVersion->mcver + "-" + fVersion->jobbuildver;
- if (!fVersion->branch.isEmpty())
- {
- longVersion = longVersion + "-" + fVersion->branch;
- }
- QString filename = artifact + "-" + longVersion + "-" + part + "." + extension;
-
- QString url = QString("%1/%2/%3")
- .arg(webpath)
- .arg(longVersion)
- .arg(filename);
-
- if (part == "installer")
- {
- fVersion->installer_url = url;
- installer_filename = filename;
- }
- else if (part == "universal" || part == "client")
- {
- fVersion->universal_url = url;
- universal_filename = filename;
- }
- else if (part == "changelog")
- {
- fVersion->changelog_url = url;
- }
- }
- if (fVersion->installer_url.isEmpty() && fVersion->universal_url.isEmpty())
- {
- continue;
- }
- fVersion->universal_filename = universal_filename;
- fVersion->installer_filename = installer_filename;
- fVersion->type = ForgeVersion::Gradle;
- out.append(fVersion);
- lookup[fVersion->m_buildnr] = fVersion;
- }
- QJsonObject promos = root.value("promos").toObject();
- for (auto it = promos.begin(); it != promos.end(); ++it)
- {
- QString key = it.key();
- int build = it.value().toInt();
- QRegularExpression regexp("^(?<mcversion>[0-9]+(.[0-9]+)*)-(?<label>[a-z]+)$");
- auto match = regexp.match(key);
- if(!match.hasMatch())
- {
- qDebug() << key << "doesn't match." << "build" << build;
- continue;
- }
-
- QString label = match.captured("label");
- if(label != "recommended")
- {
- continue;
- }
- QString mcversion = match.captured("mcversion");
- qDebug() << "Forge build" << build << "is the" << label << "for Minecraft" << mcversion << QString("<%1>").arg(key);
- lookup[build]->is_recommended = true;
- }
- return true;
-}
-
-void ForgeListLoadTask::listDownloaded()
-{
- QList<BaseVersionPtr> list;
- bool ret = true;
-
- if (!parseForgeGradleList(list))
- {
- ret = false;
- }
-
- if (!ret)
- {
- return;
- }
- std::sort(list.begin(), list.end(), [](const BaseVersionPtr & l, const BaseVersionPtr & r)
- { return (*l > *r); });
-
- m_list->updateListData(list);
-
- emitSucceeded();
- return;
-}
-
-void ForgeListLoadTask::listFailed()
-{
- auto &reply = listDownload->m_reply;
- if (reply)
- {
- qCritical() << "Getting forge version list failed: " << reply->errorString();
- }
- else
- {
- qCritical() << "Getting forge version list failed for reasons unknown.";
- }
-}
-
-void ForgeListLoadTask::gradleListFailed()
-{
- auto &reply = gradleListDownload->m_reply;
- if (reply)
- {
- qCritical() << "Getting forge version list failed: " << reply->errorString();
- }
- else
- {
- qCritical() << "Getting forge version list failed for reasons unknown.";
- }
-}
diff --git a/api/logic/minecraft/forge/ForgeVersionList.h b/api/logic/minecraft/forge/ForgeVersionList.h
deleted file mode 100644
index ee4b79d2..00000000
--- a/api/logic/minecraft/forge/ForgeVersionList.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright 2013-2017 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 "ForgeVersion.h"
-
-#include <QObject>
-#include <QAbstractListModel>
-#include <QUrl>
-#include <QNetworkReply>
-
-#include "BaseVersionList.h"
-#include "tasks/Task.h"
-#include "net/NetJob.h"
-
-#include "multimc_logic_export.h"
-
-class MULTIMC_LOGIC_EXPORT ForgeVersionList : public BaseVersionList
-{
- Q_OBJECT
-public:
- friend class ForgeListLoadTask;
-
- explicit ForgeVersionList(QObject *parent = 0);
-
- virtual Task *getLoadTask() override;
- virtual bool isLoaded() override;
- virtual const BaseVersionPtr at(int i) const override;
- virtual int count() const override;
- virtual void sortVersions() override;
-
- virtual BaseVersionPtr getLatestStable() const override;
-
- ForgeVersionPtr findVersionByVersionNr(QString version);
-
- virtual QVariant data(const QModelIndex &index, int role) const override;
- virtual RoleList providesRoles() const override;
-
- virtual int columnCount(const QModelIndex &parent) const override;
-
-protected:
- QList<BaseVersionPtr> m_vlist;
-
- bool m_loaded = false;
-
-protected
-slots:
- virtual void updateListData(QList<BaseVersionPtr> versions) override;
-};
-
-class ForgeListLoadTask : public Task
-{
- Q_OBJECT
-
-public:
- explicit ForgeListLoadTask(ForgeVersionList *vlist);
-
- virtual void executeTask();
- virtual bool abort();
-
-protected
-slots:
- void listDownloaded();
- void listFailed();
- void gradleListFailed();
-
-protected:
- NetJobPtr listJob;
- ForgeVersionList *m_list;
-
- Net::Download::Ptr listDownload;
- Net::Download::Ptr gradleListDownload;
-
-private:
- bool parseForgeList(QList<BaseVersionPtr> &out);
- bool parseForgeGradleList(QList<BaseVersionPtr> &out);
-};
diff --git a/api/logic/minecraft/forge/LegacyForge.cpp b/api/logic/minecraft/forge/LegacyForge.cpp
deleted file mode 100644
index 2e4508e9..00000000
--- a/api/logic/minecraft/forge/LegacyForge.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright 2013-2017 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.
- */
-
-#include "LegacyForge.h"
-
-MinecraftForge::MinecraftForge(const QString &file) : Mod(file)
-{
-}
-
-bool MinecraftForge::FixVersionIfNeeded(QString newVersion)
-{/*
- wxString reportedVersion = GetModVersion();
- if(reportedVersion == "..." || reportedVersion.empty())
- {
- std::auto_ptr<wxFFileInputStream> in(new wxFFileInputStream("forge.zip"));
- wxTempFileOutputStream out("forge.zip");
- wxTextOutputStream textout(out);
- wxZipInputStream inzip(*in);
- wxZipOutputStream outzip(out);
- std::auto_ptr<wxZipEntry> entry;
- // preserve metadata
- outzip.CopyArchiveMetaData(inzip);
- // copy all entries
- while (entry.reset(inzip.GetNextEntry()), entry.get() != NULL)
- if (!outzip.CopyEntry(entry.release(), inzip))
- return false;
- // release last entry
- in.reset();
- outzip.PutNextEntry("forgeversion.properties");
-
- wxStringTokenizer tokenizer(newVersion,".");
- wxString verFile;
- verFile << wxString("forge.major.number=") << tokenizer.GetNextToken() << "\n";
- verFile << wxString("forge.minor.number=") << tokenizer.GetNextToken() << "\n";
- verFile << wxString("forge.revision.number=") << tokenizer.GetNextToken() << "\n";
- verFile << wxString("forge.build.number=") << tokenizer.GetNextToken() << "\n";
- auto buf = verFile.ToUTF8();
- outzip.Write(buf.data(), buf.length());
- // check if we succeeded
- return inzip.Eof() && outzip.Close() && out.Commit();
- }
- */
- return true;
-}
diff --git a/api/logic/minecraft/forge/LegacyForge.h b/api/logic/minecraft/forge/LegacyForge.h
deleted file mode 100644
index 4a51e74a..00000000
--- a/api/logic/minecraft/forge/LegacyForge.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2013-2017 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 "minecraft/Mod.h"
-
-class MinecraftForge : public Mod
-{
-public:
- MinecraftForge(const QString &file);
- bool FixVersionIfNeeded(QString newVersion);
-};
diff --git a/api/logic/minecraft/ftb/FTBInstanceProvider.cpp b/api/logic/minecraft/ftb/FTBInstanceProvider.cpp
index 1321ea1b..fe23a84e 100644
--- a/api/logic/minecraft/ftb/FTBInstanceProvider.cpp
+++ b/api/logic/minecraft/ftb/FTBInstanceProvider.cpp
@@ -9,7 +9,6 @@
#include <FileSystem.h>
#include "Env.h"
-#include "minecraft/MinecraftVersion.h"
#include "LegacyFTBInstance.h"
#include "OneSixFTBInstance.h"
@@ -246,17 +245,8 @@ InstancePtr FTBInstanceProvider::createInstance(const FTBRecord & record) const
m_settings->registerSetting("InstanceType", "Legacy");
// all legacy versions are built in. therefore we can do this even if we don't have ALL the versions Mojang has on their servers.
- auto mcVersion = std::dynamic_pointer_cast<MinecraftVersion>(ENV.getVersion("net.minecraft", record.mcVersion));
- if (mcVersion && mcVersion->usesLegacyLauncher())
- {
- m_settings->set("InstanceType", "LegacyFTB");
- inst.reset(new LegacyFTBInstance(m_globalSettings, m_settings, record.instanceDir));
- }
- else
- {
- m_settings->set("InstanceType", "OneSixFTB");
- inst.reset(new OneSixFTBInstance(m_globalSettings, m_settings, record.instanceDir));
- }
+ m_settings->set("InstanceType", "OneSixFTB");
+ inst.reset(new OneSixFTBInstance(m_globalSettings, m_settings, record.instanceDir));
// initialize
{
diff --git a/api/logic/minecraft/ftb/FTBPlugin.cpp b/api/logic/minecraft/ftb/FTBPlugin.cpp
index d14eea63..541879a1 100644
--- a/api/logic/minecraft/ftb/FTBPlugin.cpp
+++ b/api/logic/minecraft/ftb/FTBPlugin.cpp
@@ -1,11 +1,9 @@
#include "FTBPlugin.h"
#include <Env.h>
-#include "FTBVersion.h"
#include "LegacyFTBInstance.h"
#include "OneSixFTBInstance.h"
#include <BaseInstance.h>
#include <InstanceList.h>
-#include <minecraft/MinecraftVersionList.h>
#include <settings/INISettingsObject.h>
#include <FileSystem.h>
diff --git a/api/logic/minecraft/ftb/FTBProfileStrategy.cpp b/api/logic/minecraft/ftb/FTBProfileStrategy.cpp
index e4e6a6ae..c3d9cc6a 100644
--- a/api/logic/minecraft/ftb/FTBProfileStrategy.cpp
+++ b/api/logic/minecraft/ftb/FTBProfileStrategy.cpp
@@ -2,7 +2,6 @@
#include "OneSixFTBInstance.h"
#include "minecraft/VersionBuildError.h"
-#include "minecraft/MinecraftVersionList.h"
#include <FileSystem.h>
#include <QDir>
@@ -28,9 +27,8 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
if(QFile::exists(mcJson))
{
auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false);
- file->fileId = "net.minecraft";
+ file->uid = "net.minecraft";
file->name = QObject::tr("Minecraft (tracked)");
- file->setVanilla(true);
if(file->version.isEmpty())
{
file->version = mcVersion;
@@ -40,7 +38,8 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
addLib->setHint("local");
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
}
- minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(file);
+ minecraftPatch = std::make_shared<ProfilePatch>(file);
+ minecraftPatch->setVanilla(true);
}
else
{
@@ -65,8 +64,7 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
addLib->setHint("local");
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
}
- file->fileId = "org.multimc.ftb.pack";
- file->setVanilla(true);
+ file->uid = "org.multimc.ftb.pack";
file->name = QObject::tr("%1 (FTB pack)").arg(m_instance->name());
if(file->version.isEmpty())
{
@@ -82,7 +80,8 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
}
}
}
- packPatch = std::dynamic_pointer_cast<ProfilePatch>(file);
+ packPatch = std::make_shared<ProfilePatch>(file);
+ packPatch->setVanilla(true);
}
else
{
diff --git a/api/logic/minecraft/ftb/FTBVersion.h b/api/logic/minecraft/ftb/FTBVersion.h
deleted file mode 100644
index 805319b4..00000000
--- a/api/logic/minecraft/ftb/FTBVersion.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#pragma once
-#include <minecraft/MinecraftVersion.h>
-
-class FTBVersion : public BaseVersion
-{
-public:
- FTBVersion(MinecraftVersionPtr parent) : m_version(parent){};
-
-public:
- virtual QString descriptor() override
- {
- return m_version->descriptor();
- }
-
- virtual QString name() override
- {
- return m_version->name();
- }
-
- virtual QString typeString() const override
- {
- return m_version->typeString();
- }
-
- MinecraftVersionPtr getMinecraftVersion()
- {
- return m_version;
- }
-
-private:
- MinecraftVersionPtr m_version;
-};
diff --git a/api/logic/minecraft/legacy/LegacyUpdate.cpp b/api/logic/minecraft/legacy/LegacyUpdate.cpp
index fbef47f5..337a3e4e 100644
--- a/api/logic/minecraft/legacy/LegacyUpdate.cpp
+++ b/api/logic/minecraft/legacy/LegacyUpdate.cpp
@@ -27,7 +27,6 @@
#include "LegacyModList.h"
#include "LwjglVersionList.h"
-#include "minecraft/MinecraftVersionList.h"
#include "LegacyInstance.h"
#include <FileSystem.h>
diff --git a/api/logic/minecraft/legacy/LwjglVersionList.cpp b/api/logic/minecraft/legacy/LwjglVersionList.cpp
index 7f4e7b38..3d7ad2d4 100644
--- a/api/logic/minecraft/legacy/LwjglVersionList.cpp
+++ b/api/logic/minecraft/legacy/LwjglVersionList.cpp
@@ -99,6 +99,7 @@ inline QDomElement getDomElementByTagName(QDomElement parent, QString tagname)
void LWJGLVersionList::rssFailed(const QString& reason)
{
+ m_rssDLJob.reset();
m_loading = false;
qWarning() << "Failed to load LWJGL list. Network error: " + reason;
}
@@ -116,8 +117,9 @@ void LWJGLVersionList::rssSucceeded()
if (!doc.setContent(m_rssData, false, &xmlErrorMsg, &errorLine))
{
qWarning() << "Failed to load LWJGL list. XML error: " + xmlErrorMsg + " at line " + QString::number(errorLine);
- m_loading = false;
+ m_rssDLJob.reset();
m_rssData.clear();
+ m_loading = false;
return;
}
m_rssData.clear();
@@ -162,5 +164,6 @@ void LWJGLVersionList::rssSucceeded()
endResetModel();
qDebug() << "Loaded LWJGL list.";
+ m_rssDLJob.reset();
m_loading = false;
}
diff --git a/api/logic/minecraft/legacy/LwjglVersionList.h b/api/logic/minecraft/legacy/LwjglVersionList.h
index 652a3fda..f5312e2c 100644
--- a/api/logic/minecraft/legacy/LwjglVersionList.h
+++ b/api/logic/minecraft/legacy/LwjglVersionList.h
@@ -78,9 +78,9 @@ public:
return m_vlist[i];
}
- virtual Task* getLoadTask() override
+ virtual shared_qobject_ptr<Task> getLoadTask() override
{
- return nullptr;
+ return m_rssDLJob;
}
virtual void sortVersions() override {};
diff --git a/api/logic/minecraft/liteloader/LiteLoaderInstaller.cpp b/api/logic/minecraft/liteloader/LiteLoaderInstaller.cpp
deleted file mode 100644
index 2a88cfd6..00000000
--- a/api/logic/minecraft/liteloader/LiteLoaderInstaller.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/* Copyright 2013-2017 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.
- */
-
-#include "LiteLoaderInstaller.h"
-
-#include <QJsonArray>
-#include <QJsonDocument>
-
-#include <QDebug>
-
-#include "minecraft/MinecraftProfile.h"
-#include "minecraft/Library.h"
-#include "minecraft/onesix/OneSixInstance.h"
-#include <minecraft/onesix/OneSixVersionFormat.h>
-#include "minecraft/liteloader/LiteLoaderVersionList.h"
-#include "Exception.h"
-
-LiteLoaderInstaller::LiteLoaderInstaller() : BaseInstaller()
-{
-}
-
-void LiteLoaderInstaller::prepare(LiteLoaderVersionPtr version)
-{
- m_version = version;
-}
-bool LiteLoaderInstaller::add(OneSixInstance *to)
-{
- if (!BaseInstaller::add(to))
- {
- return false;
- }
- QFile file(filename(to->instanceRoot()));
- if (!file.open(QFile::WriteOnly))
- {
- qCritical() << "Error opening" << file.fileName()
- << "for reading:" << file.errorString();
- return false;
- }
- file.write(OneSixVersionFormat::versionFileToJson(m_version->getVersionFile(), true).toJson());
- file.close();
-
- return true;
-}
-
-class LiteLoaderInstallTask : public Task
-{
- Q_OBJECT
-public:
- LiteLoaderInstallTask(LiteLoaderInstaller *installer, OneSixInstance *instance, BaseVersionPtr version, QObject *parent)
- : Task(parent), m_installer(installer), m_instance(instance), m_version(version)
- {
- }
-
-protected:
- void executeTask() override
- {
- LiteLoaderVersionPtr liteloaderVersion = std::dynamic_pointer_cast<LiteLoaderVersion>(m_version);
- if (!liteloaderVersion)
- {
- return;
- }
- m_installer->prepare(liteloaderVersion);
- if (!m_installer->add(m_instance))
- {
- emitFailed(tr("For reasons unknown, the LiteLoader installation failed. Check your MultiMC log files for details."));
- return;
- }
- try
- {
- m_instance->reloadProfile();
- emitSucceeded();
- }
- catch (Exception &e)
- {
- emitFailed(e.cause());
- }
- catch (...)
- {
- emitFailed(tr("Failed to load the version description file for reasons unknown."));
- }
- }
-
-private:
- LiteLoaderInstaller *m_installer;
- OneSixInstance *m_instance;
- BaseVersionPtr m_version;
-};
-
-Task *LiteLoaderInstaller::createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent)
-{
- return new LiteLoaderInstallTask(this, instance, version, parent);
-}
-
-#include "LiteLoaderInstaller.moc"
diff --git a/api/logic/minecraft/liteloader/LiteLoaderInstaller.h b/api/logic/minecraft/liteloader/LiteLoaderInstaller.h
deleted file mode 100644
index 65e6c192..00000000
--- a/api/logic/minecraft/liteloader/LiteLoaderInstaller.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright 2013-2017 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>
-#include <QMap>
-
-#include "BaseInstaller.h"
-#include "LiteLoaderVersionList.h"
-
-#include "multimc_logic_export.h"
-
-class MULTIMC_LOGIC_EXPORT LiteLoaderInstaller : public BaseInstaller
-{
-public:
- LiteLoaderInstaller();
-
- void prepare(LiteLoaderVersionPtr version);
- bool add(OneSixInstance *to) override;
- virtual QString id() const override { return "com.mumfrey.liteloader"; }
-
- Task *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) override;
-
-private:
- LiteLoaderVersionPtr m_version;
-};
diff --git a/api/logic/minecraft/liteloader/LiteLoaderVersionList.cpp b/api/logic/minecraft/liteloader/LiteLoaderVersionList.cpp
deleted file mode 100644
index 023d2f14..00000000
--- a/api/logic/minecraft/liteloader/LiteLoaderVersionList.cpp
+++ /dev/null
@@ -1,332 +0,0 @@
-/* Copyright 2013-2017 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.
- */
-
-#include "LiteLoaderVersionList.h"
-#include <minecraft/onesix/OneSixVersionFormat.h>
-#include "Env.h"
-#include "net/URLConstants.h"
-#include "Exception.h"
-
-#include <QtXml>
-
-#include <QJsonDocument>
-#include <QJsonObject>
-#include <QJsonArray>
-#include <QJsonValue>
-#include <QJsonParseError>
-
-#include <QtAlgorithms>
-
-#include <QtNetwork>
-
-LiteLoaderVersionList::LiteLoaderVersionList(QObject *parent) : BaseVersionList(parent)
-{
-}
-
-Task *LiteLoaderVersionList::getLoadTask()
-{
- return new LLListLoadTask(this);
-}
-
-bool LiteLoaderVersionList::isLoaded()
-{
- return m_loaded;
-}
-
-const BaseVersionPtr LiteLoaderVersionList::at(int i) const
-{
- return m_vlist.at(i);
-}
-
-int LiteLoaderVersionList::count() const
-{
- return m_vlist.count();
-}
-
-static bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second)
-{
- auto left = std::dynamic_pointer_cast<LiteLoaderVersion>(first);
- auto right = std::dynamic_pointer_cast<LiteLoaderVersion>(second);
- return left->timestamp > right->timestamp;
-}
-
-VersionFilePtr LiteLoaderVersion::getVersionFile()
-{
- auto f = std::make_shared<VersionFile>();
- f->mainClass = "net.minecraft.launchwrapper.Launch";
- f->addTweakers += tweakClass;
- f->order = 10;
- f->libraries = libraries;
- f->name = "LiteLoader";
- f->fileId = "com.mumfrey.liteloader";
- f->version = version;
- f->minecraftVersion = mcVersion;
- return f;
-}
-
-void LiteLoaderVersionList::sortVersions()
-{
- beginResetModel();
- std::sort(m_vlist.begin(), m_vlist.end(), cmpVersions);
- endResetModel();
-}
-
-QVariant LiteLoaderVersionList::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- if (index.row() > count())
- return QVariant();
-
- auto version = std::dynamic_pointer_cast<LiteLoaderVersion>(m_vlist[index.row()]);
- switch (role)
- {
- case VersionPointerRole:
- return qVariantFromValue(m_vlist[index.row()]);
-
- case VersionRole:
- return version->name();
-
- case VersionIdRole:
- return version->descriptor();
-
- case ParentGameVersionRole:
- return version->mcVersion;
-
- case LatestRole:
- return version->isLatest;
-
- case RecommendedRole:
- return version->isRecommended;
-
- case TypeRole:
- return version->isSnapshot ? tr("Snapshot") : tr("Release");
-
- default:
- return QVariant();
- }
-}
-
-BaseVersionList::RoleList LiteLoaderVersionList::providesRoles() const
-{
- return {VersionPointerRole, VersionRole, VersionIdRole, ParentGameVersionRole, RecommendedRole, LatestRole, TypeRole};
-}
-
-BaseVersionPtr LiteLoaderVersionList::getLatestStable() const
-{
- for (int i = 0; i < m_vlist.length(); i++)
- {
- auto ver = std::dynamic_pointer_cast<LiteLoaderVersion>(m_vlist.at(i));
- if (ver->isRecommended)
- {
- return m_vlist.at(i);
- }
- }
- return BaseVersionPtr();
-}
-
-void LiteLoaderVersionList::updateListData(QList<BaseVersionPtr> versions)
-{
- beginResetModel();
- m_vlist = versions;
- m_loaded = true;
- std::sort(m_vlist.begin(), m_vlist.end(), cmpVersions);
- endResetModel();
-}
-
-LLListLoadTask::LLListLoadTask(LiteLoaderVersionList *vlist)
-{
- m_list = vlist;
-}
-
-LLListLoadTask::~LLListLoadTask()
-{
-}
-
-void LLListLoadTask::executeTask()
-{
- setStatus(tr("Loading LiteLoader version list..."));
- auto job = new NetJob("Version index");
- // we do not care if the version is stale or not.
- auto liteloaderEntry = ENV.metacache()->resolveEntry("liteloader", "versions.json");
-
- // verify by poking the server.
- liteloaderEntry->setStale(true);
-
- job->addNetAction(listDownload = Net::Download::makeCached(QUrl(URLConstants::LITELOADER_URL), liteloaderEntry));
-
- connect(listDownload.get(), SIGNAL(failed(int)), SLOT(listFailed()));
-
- listJob.reset(job);
- connect(listJob.get(), SIGNAL(succeeded()), SLOT(listDownloaded()));
- connect(listJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64)));
- listJob->start();
-}
-
-void LLListLoadTask::listFailed()
-{
- emitFailed("Failed to load LiteLoader version list.");
- return;
-}
-
-void LLListLoadTask::listDownloaded()
-{
- QByteArray data;
- {
- auto filename = listDownload->getTargetFilepath();
- QFile listFile(filename);
- if (!listFile.open(QIODevice::ReadOnly))
- {
- emitFailed("Failed to open the LiteLoader version list.");
- return;
- }
- data = listFile.readAll();
- listFile.close();
- listDownload.reset();
- }
-
- QJsonParseError jsonError;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
-
- if (jsonError.error != QJsonParseError::NoError)
- {
- emitFailed("Error parsing version list JSON:" + jsonError.errorString());
- return;
- }
-
- if (!jsonDoc.isObject())
- {
- emitFailed("Error parsing version list JSON: jsonDoc is not an object");
- return;
- }
-
- const QJsonObject root = jsonDoc.object();
-
- // Now, get the array of versions.
- if (!root.value("versions").isObject())
- {
- emitFailed("Error parsing version list JSON: missing 'versions' object");
- return;
- }
-
- auto meta = root.value("meta").toObject();
- QString description = meta.value("description").toString(tr("This is a lightweight loader for mods that don't change game mechanics."));
- QString defaultUrl = meta.value("url").toString("http://dl.liteloader.com");
- QString authors = meta.value("authors").toString("Mumfrey");
- auto versions = root.value("versions").toObject();
-
- QList<BaseVersionPtr> tempList;
- for (auto vIt = versions.begin(); vIt != versions.end(); ++vIt)
- {
- const QString mcVersion = vIt.key();
- const QJsonObject versionObject = vIt.value().toObject();
-
- auto processArtefacts = [&](QJsonObject artefacts, bool notSnapshots, std::shared_ptr<LiteLoaderVersion> &latest)
- {
- QString latestVersion;
- QList<BaseVersionPtr> perMcVersionList;
- for (auto aIt = artefacts.begin(); aIt != artefacts.end(); ++aIt)
- {
- const QString identifier = aIt.key();
- const QJsonObject artefact = aIt.value().toObject();
- if (identifier == "latest")
- {
- latestVersion = artefact.value("version").toString();
- continue;
- }
- LiteLoaderVersionPtr version(new LiteLoaderVersion());
- version->version = artefact.value("version").toString();
- version->mcVersion = mcVersion;
- version->md5 = artefact.value("md5").toString();
- version->timestamp = artefact.value("timestamp").toString().toLong();
- version->tweakClass = artefact.value("tweakClass").toString();
- version->authors = authors;
- version->description = description;
- version->defaultUrl = defaultUrl;
- version->isSnapshot = !notSnapshots;
- const QJsonArray libs = artefact.value("libraries").toArray();
- for (auto lIt = libs.begin(); lIt != libs.end(); ++lIt)
- {
- auto libobject = (*lIt).toObject();
- try
- {
- auto lib = OneSixVersionFormat::libraryFromJson(libobject, "versions.json");
- // hack to make liteloader 1.7.10_00 work
- if(lib->rawName() == GradleSpecifier("org.ow2.asm:asm-all:5.0.3"))
- {
- lib->setRepositoryURL("http://repo.maven.apache.org/maven2/");
- }
- version->libraries.append(lib);
- }
- catch (Exception &e)
- {
- qCritical() << "Couldn't read JSON object:";
- continue; // FIXME: ignores bad libraries and continues loading
- }
- }
- auto liteloaderLib = std::make_shared<Library>("com.mumfrey:liteloader:" + version->version);
- liteloaderLib->setRepositoryURL("http://dl.liteloader.com/versions/");
- if(!notSnapshots)
- {
- liteloaderLib->setHint("always-stale");
- }
- version->libraries.append(liteloaderLib);
- perMcVersionList.append(version);
- }
- if(notSnapshots)
- {
- for (auto version : perMcVersionList)
- {
- auto v = std::dynamic_pointer_cast<LiteLoaderVersion>(version);
- if(v->version == latestVersion)
- {
- latest = v;
- }
- }
- }
- tempList.append(perMcVersionList);
- };
-
- std::shared_ptr<LiteLoaderVersion> latestSnapshot;
- std::shared_ptr<LiteLoaderVersion> latestRelease;
- // are there actually released versions for this mc version?
- if(versionObject.contains("artefacts"))
- {
- const QJsonObject artefacts = versionObject.value("artefacts").toObject().value("com.mumfrey:liteloader").toObject();
- processArtefacts(artefacts, true, latestRelease);
- }
- if(versionObject.contains("snapshots"))
- {
- QJsonObject artefacts = versionObject.value("snapshots").toObject().value("com.mumfrey:liteloader").toObject();
- processArtefacts(artefacts, false, latestSnapshot);
- }
- if(latestSnapshot)
- {
- latestSnapshot->isLatest = true;
- }
- else if(latestRelease)
- {
- latestRelease->isLatest = true;
- }
- if(latestRelease)
- {
- latestRelease->isRecommended = true;
- }
- }
- m_list->updateListData(tempList);
-
- emitSucceeded();
-}
diff --git a/api/logic/minecraft/liteloader/LiteLoaderVersionList.h b/api/logic/minecraft/liteloader/LiteLoaderVersionList.h
deleted file mode 100644
index 6074978c..00000000
--- a/api/logic/minecraft/liteloader/LiteLoaderVersionList.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* Copyright 2013-2017 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 <QObject>
-
-#include <QString>
-#include <QStringList>
-#include "BaseVersion.h"
-#include "BaseVersionList.h"
-#include "tasks/Task.h"
-#include "net/NetJob.h"
-#include <minecraft/Library.h>
-#include <minecraft/VersionFile.h>
-
-#include "multimc_logic_export.h"
-
-class LLListLoadTask;
-class QNetworkReply;
-
-class LiteLoaderVersion : public BaseVersion
-{
-public:
- QString descriptor() override
- {
- if (isLatest)
- {
- return QObject::tr("Latest");
- }
- return QString();
- }
- QString typeString() const override
- {
- return mcVersion;
- }
- QString name() override
- {
- return version;
- }
- VersionFilePtr getVersionFile();
-
- // important info
- QString version;
- QString mcVersion;
- QString md5;
- long timestamp = 0;
- bool isLatest = false;
- bool isRecommended = false;
- bool isSnapshot = false;
-
- QString tweakClass;
- QList<LibraryPtr> libraries;
-
- // meta
- QString defaultUrl;
- QString description;
- QString authors;
-};
-typedef std::shared_ptr<LiteLoaderVersion> LiteLoaderVersionPtr;
-
-class MULTIMC_LOGIC_EXPORT LiteLoaderVersionList : public BaseVersionList
-{
- Q_OBJECT
-public:
- friend class LLListLoadTask;
-
- explicit LiteLoaderVersionList(QObject *parent = 0);
-
- Task *getLoadTask() override;
- bool isLoaded() override;
- const BaseVersionPtr at(int i) const override;
- int count() const override;
- void sortVersions() override;
- QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const override;
- RoleList providesRoles() const override;
-
- virtual BaseVersionPtr getLatestStable() const override;
-
-protected:
- QList<BaseVersionPtr> m_vlist;
-
- bool m_loaded = false;
-
-protected
-slots:
- void updateListData(QList<BaseVersionPtr> versions) override;
-};
-
-class LLListLoadTask : public Task
-{
- Q_OBJECT
-
-public:
- explicit LLListLoadTask(LiteLoaderVersionList *vlist);
- ~LLListLoadTask();
-
- virtual void executeTask();
-
-protected
-slots:
- void listDownloaded();
- void listFailed();
-
-protected:
- NetJobPtr listJob;
- Net::Download::Ptr listDownload;
- LiteLoaderVersionList *m_list;
-};
-
-Q_DECLARE_METATYPE(LiteLoaderVersionPtr)
diff --git a/api/logic/minecraft/onesix/OneSixInstance.cpp b/api/logic/minecraft/onesix/OneSixInstance.cpp
index b471ff3e..fd54f544 100644
--- a/api/logic/minecraft/onesix/OneSixInstance.cpp
+++ b/api/logic/minecraft/onesix/OneSixInstance.cpp
@@ -34,7 +34,15 @@
OneSixInstance::OneSixInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir)
: MinecraftInstance(globalSettings, settings, rootDir)
{
+ // set explicitly during instance creation
m_settings->registerSetting({"IntendedVersion", "MinecraftVersion"}, "");
+
+ // defaults to the version we've been using for years (2.9.1)
+ m_settings->registerSetting("LWJGLVersion", "2.9.1");
+
+ // optionals
+ m_settings->registerSetting("ForgeVersion", "");
+ m_settings->registerSetting("LiteloaderVersion", "");
}
void OneSixInstance::init()
@@ -275,6 +283,8 @@ QStringList OneSixInstance::verboseDescription(AuthSessionPtr session)
printLibFile(file);
}
printLibFile(mainJarPath());
+ out << "";
+ out << "Native libraries:";
for(auto file: nativeJars)
{
printLibFile(file);
@@ -480,7 +490,32 @@ std::shared_ptr<WorldList> OneSixInstance::worldList() const
bool OneSixInstance::setIntendedVersionId(QString version)
{
- settings()->set("IntendedVersion", version);
+ return setComponentVersion("net.minecraft", version);
+}
+
+QString OneSixInstance::intendedVersionId() const
+{
+ return getComponentVersion("net.minecraft");
+}
+
+bool OneSixInstance::setComponentVersion(const QString& uid, const QString& version)
+{
+ if(uid == "net.minecraft")
+ {
+ settings()->set("IntendedVersion", version);
+ }
+ else if (uid == "org.lwjgl")
+ {
+ settings()->set("LWJGLVersion", version);
+ }
+ else if (uid == "net.minecraftforge")
+ {
+ settings()->set("ForgeVersion", version);
+ }
+ else if (uid == "com.mumfrey.liteloader")
+ {
+ settings()->set("LiteloaderVersion", version);
+ }
if(getMinecraftProfile())
{
clearProfile();
@@ -489,6 +524,27 @@ bool OneSixInstance::setIntendedVersionId(QString version)
return true;
}
+QString OneSixInstance::getComponentVersion(const QString& uid) const
+{
+ if(uid == "net.minecraft")
+ {
+ return settings()->get("IntendedVersion").toString();
+ }
+ else if(uid == "org.lwjgl")
+ {
+ return settings()->get("LWJGLVersion").toString();
+ }
+ else if(uid == "net.minecraftforge")
+ {
+ return settings()->get("ForgeVersion").toString();
+ }
+ else if(uid == "com.mumfrey.liteloader")
+ {
+ return settings()->get("LiteloaderVersion").toString();
+ }
+ return QString();
+}
+
QList< Mod > OneSixInstance::getJarMods() const
{
QList<Mod> mods;
@@ -500,12 +556,6 @@ QList< Mod > OneSixInstance::getJarMods() const
return mods;
}
-
-QString OneSixInstance::intendedVersionId() const
-{
- return settings()->get("IntendedVersion").toString();
-}
-
void OneSixInstance::setShouldUpdate(bool)
{
}
@@ -523,7 +573,7 @@ QString OneSixInstance::currentVersionId() const
void OneSixInstance::reloadProfile()
{
m_profile->reload();
- setVersionBroken(m_profile->getProblemSeverity() == ProblemSeverity::PROBLEM_ERROR);
+ setVersionBroken(m_profile->getProblemSeverity() == ProblemSeverity::Error);
emit versionReloaded();
}
diff --git a/api/logic/minecraft/onesix/OneSixInstance.h b/api/logic/minecraft/onesix/OneSixInstance.h
index 72c05ad7..ec8c2597 100644
--- a/api/logic/minecraft/onesix/OneSixInstance.h
+++ b/api/logic/minecraft/onesix/OneSixInstance.h
@@ -59,9 +59,11 @@ public:
virtual QString intendedVersionId() const override;
virtual bool setIntendedVersionId(QString version) override;
-
virtual QString currentVersionId() const override;
+ QString getComponentVersion(const QString &uid) const;
+ bool setComponentVersion(const QString &uid, const QString &version);
+
virtual bool shouldUpdate() const override;
virtual void setShouldUpdate(bool val) override;
diff --git a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp
index 07c9f075..d3e137c7 100644
--- a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp
+++ b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp
@@ -3,7 +3,6 @@
#include "OneSixVersionFormat.h"
#include "minecraft/VersionBuildError.h"
-#include "minecraft/MinecraftVersionList.h"
#include "Env.h"
#include <FileSystem.h>
@@ -11,6 +10,12 @@
#include <QUuid>
#include <QJsonDocument>
#include <QJsonArray>
+#include <QSaveFile>
+#include <QResource>
+#include <meta/Index.h>
+#include <meta/Version.h>
+
+#include <tuple>
OneSixProfileStrategy::OneSixProfileStrategy(OneSixInstance* instance)
{
@@ -53,7 +58,7 @@ void OneSixProfileStrategy::upgradeDeprecatedFiles()
}
auto file = ProfileUtils::parseJsonFile(QFileInfo(sourceFile), false);
ProfileUtils::removeLwjglFromPatch(file);
- file->fileId = "net.minecraft";
+ file->uid = "net.minecraft";
file->version = file->minecraftVersion;
file->name = "Minecraft";
auto data = OneSixVersionFormat::versionFileToJson(file, false).toJson();
@@ -80,156 +85,128 @@ void OneSixProfileStrategy::upgradeDeprecatedFiles()
void OneSixProfileStrategy::loadDefaultBuiltinPatches()
{
+ auto addBuiltinPatch = [&](const QString &uid, const QString intendedVersion, int order)
{
- auto mcJson = FS::PathCombine(m_instance->instanceRoot(), "patches" , "net.minecraft.json");
+ auto jsonFilePath = FS::PathCombine(m_instance->instanceRoot(), "patches" , uid + ".json");
// load up the base minecraft patch
- ProfilePatchPtr minecraftPatch;
- if(QFile::exists(mcJson))
+ ProfilePatchPtr profilePatch;
+ if(QFile::exists(jsonFilePath))
{
- auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false);
+ auto file = ProfileUtils::parseJsonFile(QFileInfo(jsonFilePath), false);
if(file->version.isEmpty())
{
- file->version = m_instance->intendedVersionId();
+ file->version = intendedVersion;
}
- file->setVanilla(false);
- file->setRevertible(true);
- minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(file);
+ profilePatch = std::make_shared<ProfilePatch>(file, jsonFilePath);
+ profilePatch->setVanilla(false);
+ profilePatch->setRevertible(true);
}
else
{
- auto mcversion = ENV.getVersion("net.minecraft", m_instance->intendedVersionId());
- minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(mcversion);
+ auto metaVersion = ENV.metadataIndex()->get(uid, intendedVersion);
+ profilePatch = std::make_shared<ProfilePatch>(metaVersion);
+ profilePatch->setVanilla(true);
}
- if (!minecraftPatch)
+ if (!profilePatch)
{
- throw VersionIncomplete("net.minecraft");
+ throw VersionIncomplete(uid);
}
- minecraftPatch->setOrder(-2);
- profile->appendPatch(minecraftPatch);
- }
+ profilePatch->setOrder(order);
+ profile->appendPatch(profilePatch);
+ };
+ addBuiltinPatch("net.minecraft", m_instance->getComponentVersion("net.minecraft"), -2);
+ addBuiltinPatch("org.lwjgl", m_instance->getComponentVersion("org.lwjgl"), -1);
+}
+void OneSixProfileStrategy::loadUserPatches()
+{
+ // first, collect all patches (that are not builtins of OneSix) and load them
+ QMap<QString, ProfilePatchPtr> loadedPatches;
+ QDir patchesDir(FS::PathCombine(m_instance->instanceRoot(),"patches"));
+ for (auto info : patchesDir.entryInfoList(QStringList() << "*.json", QDir::Files))
{
- auto lwjglJson = FS::PathCombine(m_instance->instanceRoot(), "patches" , "org.lwjgl.json");
- ProfilePatchPtr lwjglPatch;
- if(QFile::exists(lwjglJson))
- {
- auto file = ProfileUtils::parseJsonFile(QFileInfo(lwjglJson), false);
- file->setVanilla(false);
- file->setRevertible(true);
- lwjglPatch = std::dynamic_pointer_cast<ProfilePatch>(file);
- }
- else
+ // parse the file
+ qDebug() << "Reading" << info.fileName();
+ auto file = ProfileUtils::parseJsonFile(info, true);
+ // ignore builtins
+ if (file->uid == "net.minecraft")
+ continue;
+ if (file->uid == "org.lwjgl")
+ continue;
+ auto patch = std::make_shared<ProfilePatch>(file, info.filePath());
+ patch->setRemovable(true);
+ patch->setMovable(true);
+ if(ENV.metadataIndex()->hasUid(file->uid))
{
- // NOTE: this is obviously fake, is fixed in unstable.
- QResource LWJGL(":/versions/LWJGL/2.9.1.json");
- auto lwjgl = ProfileUtils::parseJsonFile(LWJGL.absoluteFilePath(), false);
- lwjgl->setVanilla(true);
- lwjgl->setCustomizable(true);
- lwjglPatch = std::dynamic_pointer_cast<ProfilePatch>(lwjgl);
+ // FIXME: requesting a uid/list creates it in the index... this allows reverting to possibly invalid versions...
+ patch->setRevertible(true);
}
- if (!lwjglPatch)
+ loadedPatches[file->uid] = patch;
+ }
+ // these are 'special'... if not already loaded from instance files, grab them from the metadata repo.
+ auto loadSpecial = [&](const QString & uid, int order)
+ {
+ auto patchVersion = m_instance->getComponentVersion(uid);
+ if(!patchVersion.isEmpty() && !loadedPatches.contains(uid))
{
- throw VersionIncomplete("org.lwjgl");
+ auto patch = std::make_shared<ProfilePatch>(ENV.metadataIndex()->get(uid, patchVersion));
+ patch->setOrder(order);
+ patch->setVanilla(true);
+ patch->setRemovable(true);
+ patch->setMovable(true);
+ loadedPatches[uid] = patch;
}
- lwjglPatch->setOrder(-1);
- profile->appendPatch(lwjglPatch);
- }
-}
+ };
+ loadSpecial("net.minecraftforge", 5);
+ loadSpecial("com.mumfrey.liteloader", 10);
-void OneSixProfileStrategy::loadUserPatches()
-{
- // load all patches, put into map for ordering, apply in the right order
+ // now add all the patches by user sort order
ProfileUtils::PatchOrder userOrder;
ProfileUtils::readOverrideOrders(FS::PathCombine(m_instance->instanceRoot(), "order.json"), userOrder);
- QDir patches(FS::PathCombine(m_instance->instanceRoot(),"patches"));
- QSet<QString> seen_extra;
-
- // first, load things by sort order.
- for (auto id : userOrder)
+ bool orderIsDirty = false;
+ for (auto uid : userOrder)
{
// ignore builtins
- if (id == "net.minecraft")
+ if (uid == "net.minecraft")
continue;
- if (id == "org.lwjgl")
+ if (uid == "org.lwjgl")
continue;
- // parse the file
- QString filename = patches.absoluteFilePath(id + ".json");
- QFileInfo finfo(filename);
- if(!finfo.exists())
+ // ordering has a patch that is gone?
+ if(!loadedPatches.contains(uid))
{
- qDebug() << "Patch file " << filename << " was deleted by external means...";
+ orderIsDirty = true;
continue;
}
- qDebug() << "Reading" << filename << "by user order";
- VersionFilePtr file = ProfileUtils::parseJsonFile(finfo, false);
- // sanity check. prevent tampering with files.
- if (file->fileId != id)
- {
- file->addProblem(PROBLEM_WARNING, QObject::tr("load id %1 does not match internal id %2").arg(id, file->fileId));
- seen_extra.insert(file->fileId);
- }
- file->setRemovable(true);
- file->setMovable(true);
- // HACK: ignore assets from other version files than Minecraft
- // workaround for stupid assets issue caused by amazon:
- // https://www.theregister.co.uk/2017/02/28/aws_is_awol_as_s3_goes_haywire/
- file->assets = QString();
- file->mojangAssetIndex.reset();
- // HACK
- profile->appendPatch(file);
+ profile->appendPatch(loadedPatches.take(uid));
}
- // now load the rest by internal preference.
- QMultiMap<int, VersionFilePtr> files;
- for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files))
+
+ // is there anything left to sort?
+ if(loadedPatches.isEmpty())
{
- // parse the file
- qDebug() << "Reading" << info.fileName();
- auto file = ProfileUtils::parseJsonFile(info, true);
- // ignore builtins
- if (file->fileId == "net.minecraft")
- continue;
- if (file->fileId == "org.lwjgl")
- continue;
- // do not load versions with broken IDs twice
- if(seen_extra.contains(file->fileId))
- continue;
- // do not load what we already loaded in the first pass
- if (userOrder.contains(file->fileId))
- continue;
- file->setRemovable(true);
- file->setMovable(true);
- // HACK: ignore assets from other version files than Minecraft
- // workaround for stupid assets issue caused by amazon:
- // https://www.theregister.co.uk/2017/02/28/aws_is_awol_as_s3_goes_haywire/
- file->assets = QString();
- file->mojangAssetIndex.reset();
- // HACK
- files.insert(file->order, file);
+ // TODO: save the order here?
+ return;
+ }
+
+ // inserting into multimap by order number as key sorts the patches and detects duplicates
+ QMultiMap<int, ProfilePatchPtr> files;
+ auto iter = loadedPatches.begin();
+ while(iter != loadedPatches.end())
+ {
+ files.insert((*iter)->getOrder(), *iter);
+ iter++;
}
- QSet<int> seen;
+
+ // then just extract the patches and put them in the list
for (auto order : files.keys())
{
- if(seen.contains(order))
- continue;
- seen.insert(order);
const auto &values = files.values(order);
- if(values.size() == 1)
- {
- profile->appendPatch(values[0]);
- continue;
- }
- for(auto &file: values)
+ for(auto &value: values)
{
- QStringList list;
- for(auto &file2: values)
- {
- if(file != file2)
- list.append(file2->name);
- }
- file->addProblem(PROBLEM_WARNING, QObject::tr("%1 has the same order as the following components:\n%2").arg(file->name, list.join(", ")));
- profile->appendPatch(file);
+ // TODO: put back the insertion of problem messages here, so the user knows about the id duplication
+ profile->appendPatch(value);
}
}
+ // TODO: save the order here?
}
@@ -266,7 +243,10 @@ bool OneSixProfileStrategy::removePatch(ProfilePatchPtr patch)
return false;
}
}
-
+ if(!m_instance->getComponentVersion(patch->getID()).isEmpty())
+ {
+ m_instance->setComponentVersion(patch->getID(), QString());
+ }
auto preRemoveJarMod = [&](JarmodPtr jarMod) -> bool
{
@@ -285,7 +265,8 @@ bool OneSixProfileStrategy::removePatch(ProfilePatchPtr patch)
return true;
};
- for(auto &jarmod: patch->getJarMods())
+ auto &jarMods = patch->getVersionFile()->jarMods;
+ for(auto &jarmod: jarMods)
{
ok &= preRemoveJarMod(jarmod);
}
@@ -405,12 +386,9 @@ bool OneSixProfileStrategy::installJarMods(QStringList filepaths)
jarMod->originalName = sourceInfo.completeBaseName();
f->jarMods.append(jarMod);
f->name = target_name;
- f->fileId = target_id;
+ f->uid = target_id;
f->order = profile->getFreeOrderNumber();
QString patchFileName = FS::PathCombine(patchDir, target_id + ".json");
- f->filename = patchFileName;
- f->setMovable(true);
- f->setRemovable(true);
QFile file(patchFileName);
if (!file.open(QFile::WriteOnly))
@@ -421,7 +399,11 @@ bool OneSixProfileStrategy::installJarMods(QStringList filepaths)
}
file.write(OneSixVersionFormat::versionFileToJson(f, true).toJson());
file.close();
- profile->appendPatch(f);
+
+ auto patch = std::make_shared<ProfilePatch>(f, patchFileName);
+ patch->setMovable(true);
+ patch->setRemovable(true);
+ profile->appendPatch(patch);
}
profile->saveCurrentOrder();
profile->reapplyPatches();
diff --git a/api/logic/minecraft/onesix/OneSixUpdate.cpp b/api/logic/minecraft/onesix/OneSixUpdate.cpp
index 4bc80bfe..bf234189 100644
--- a/api/logic/minecraft/onesix/OneSixUpdate.cpp
+++ b/api/logic/minecraft/onesix/OneSixUpdate.cpp
@@ -24,7 +24,6 @@
#include <QDataStream>
#include "BaseInstance.h"
-#include "minecraft/MinecraftVersionList.h"
#include "minecraft/MinecraftProfile.h"
#include "minecraft/Library.h"
#include "net/URLConstants.h"
@@ -35,6 +34,9 @@
#include "update/FMLLibrariesTask.h"
#include "update/AssetUpdateTask.h"
+#include <meta/Index.h>
+#include <meta/Version.h>
+
OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
{
// create folders
@@ -44,29 +46,23 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent)
// add a version update task, if necessary
{
- auto list = std::dynamic_pointer_cast<MinecraftVersionList>(ENV.getVersionList("net.minecraft"));
- auto version = std::dynamic_pointer_cast<MinecraftVersion>(list->findVersion(m_inst->intendedVersionId()));
- if (version == nullptr)
- {
- // don't do anything if it was invalid
- m_preFailure = tr("The specified Minecraft version is invalid. Choose a different one.");
- }
- else if (m_inst->providesVersionFile() || !version->needsUpdate())
+ /*
+ * FIXME: there are some corner cases here that remain unhandled:
+ * what if local load succeeds but remote fails? The version is still usable...
+ */
+ // FIXME: derive this from the actual list of version patches...
+ auto loadVersion = [&](const QString & uid, const QString & version)
{
- qDebug() << "Instance either provides a version file or doesn't need an update.";
- }
- else
- {
- auto versionUpdateTask = list->createUpdateTask(m_inst->intendedVersionId());
- if (!versionUpdateTask)
- {
- qDebug() << "Didn't spawn an update task.";
- }
- else
+ auto obj = ENV.metadataIndex()->get(uid, version);
+ obj->load();
+ auto task = obj->getCurrentTask();
+ if(task)
{
- m_tasks.append(versionUpdateTask);
+ m_tasks.append(task.unwrap());
}
- }
+ };
+ loadVersion("org.lwjgl", m_inst->getComponentVersion("org.lwjgl"));
+ loadVersion("net.minecraft", m_inst->getComponentVersion("net.minecraft"));
}
// libraries download
@@ -117,11 +113,20 @@ void OneSixUpdate::next()
return;
}
auto task = m_tasks[m_currentTask];
+ // if the task is already finished by the time we look at it, skip it
+ if(task->isFinished())
+ {
+ next();
+ }
connect(task.get(), &Task::succeeded, this, &OneSixUpdate::subtaskSucceeded);
connect(task.get(), &Task::failed, this, &OneSixUpdate::subtaskFailed);
connect(task.get(), &Task::progress, this, &OneSixUpdate::progress);
connect(task.get(), &Task::status, this, &OneSixUpdate::setStatus);
- task->start();
+ // if the task is already running, do not start it again
+ if(!task->isRunning())
+ {
+ task->start();
+ }
}
void OneSixUpdate::subtaskSucceeded()
diff --git a/api/logic/minecraft/onesix/OneSixVersionFormat.cpp b/api/logic/minecraft/onesix/OneSixVersionFormat.cpp
index 541fb109..266bd4bd 100644
--- a/api/logic/minecraft/onesix/OneSixVersionFormat.cpp
+++ b/api/logic/minecraft/onesix/OneSixVersionFormat.cpp
@@ -1,7 +1,6 @@
#include "OneSixVersionFormat.h"
#include <Json.h>
#include "minecraft/ParseUtils.h"
-#include <minecraft/MinecraftVersion.h>
#include <minecraft/VersionBuildError.h>
#include <minecraft/MojangVersionFormat.h>
@@ -62,10 +61,19 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
}
out->name = root.value("name").toString();
- out->fileId = root.value("fileId").toString();
+
+ if(root.contains("uid"))
+ {
+ out->uid = root.value("uid").toString();
+ }
+ else
+ {
+ out->uid = root.value("fileId").toString();
+ }
+
out->version = root.value("version").toString();
out->dependsOnMinecraftVersion = root.value("mcVersion").toString();
- out->filename = filename;
+ // out->filename = filename;
MojangVersionFormat::readVersionProperties(root, out.get());
@@ -120,7 +128,8 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
bool hasLibs = root.contains("libraries");
if (hasPlusLibs && hasLibs)
{
- out->addProblem(PROBLEM_WARNING, QObject::tr("Version file has both '+libraries' and 'libraries'. This is no longer supported."));
+ out->addProblem(ProblemSeverity::Warning,
+ QObject::tr("Version file has both '+libraries' and 'libraries'. This is no longer supported."));
readLibs("libraries");
readLibs("+libraries");
}
@@ -136,23 +145,23 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
/* removed features that shouldn't be used */
if (root.contains("tweakers"))
{
- out->addProblem(PROBLEM_ERROR, QObject::tr("Version file contains unsupported element 'tweakers'"));
+ out->addProblem(ProblemSeverity::Error, QObject::tr("Version file contains unsupported element 'tweakers'"));
}
if (root.contains("-libraries"))
{
- out->addProblem(PROBLEM_ERROR, QObject::tr("Version file contains unsupported element '-libraries'"));
+ out->addProblem(ProblemSeverity::Error, QObject::tr("Version file contains unsupported element '-libraries'"));
}
if (root.contains("-tweakers"))
{
- out->addProblem(PROBLEM_ERROR, QObject::tr("Version file contains unsupported element '-tweakers'"));
+ out->addProblem(ProblemSeverity::Error, QObject::tr("Version file contains unsupported element '-tweakers'"));
}
if (root.contains("-minecraftArguments"))
{
- out->addProblem(PROBLEM_ERROR, QObject::tr("Version file contains unsupported element '-minecraftArguments'"));
+ out->addProblem(ProblemSeverity::Error, QObject::tr("Version file contains unsupported element '-minecraftArguments'"));
}
if (root.contains("+minecraftArguments"))
{
- out->addProblem(PROBLEM_ERROR, QObject::tr("Version file contains unsupported element '+minecraftArguments'"));
+ out->addProblem(ProblemSeverity::Error, QObject::tr("Version file contains unsupported element '+minecraftArguments'"));
}
return out;
}
@@ -165,7 +174,10 @@ QJsonDocument OneSixVersionFormat::versionFileToJson(const VersionFilePtr &patch
root.insert("order", patch->order);
}
writeString(root, "name", patch->name);
- writeString(root, "fileId", patch->fileId);
+
+ writeString(root, "uid", patch->uid);
+ writeString(root, "fileId", patch->uid);
+
writeString(root, "version", patch->version);
writeString(root, "mcVersion", patch->dependsOnMinecraftVersion);
diff --git a/api/logic/minecraft/onesix/update/LibrariesTask.cpp b/api/logic/minecraft/onesix/update/LibrariesTask.cpp
index f60c2b5e..3e6bb12a 100644
--- a/api/logic/minecraft/onesix/update/LibrariesTask.cpp
+++ b/api/logic/minecraft/onesix/update/LibrariesTask.cpp
@@ -35,19 +35,23 @@ void LibrariesTask::executeTask()
downloadJob.reset(job);
}
- auto libs = profile->getLibraries();
-
auto metacache = ENV.metacache();
QList<LibraryPtr> brokenLocalLibs;
QStringList failedFiles;
- for (auto lib : libs)
+ auto createJobs = [&](const QList<LibraryPtr> & libs)
{
- auto dls = lib->getDownloads(currentSystem, metacache.get(), failedFiles, inst->getLocalLibraryPath());
- for(auto dl : dls)
+ for (auto lib : libs)
{
- downloadJob->addNetAction(dl);
+ auto dls = lib->getDownloads(currentSystem, metacache.get(), failedFiles, inst->getLocalLibraryPath());
+ for(auto dl : dls)
+ {
+ downloadJob->addNetAction(dl);
+ }
}
- }
+ };
+ createJobs(profile->getLibraries());
+ createJobs(profile->getNativeLibraries());
+
// FIXME: this is never filled!!!!
if (!brokenLocalLibs.empty())
{
diff --git a/api/logic/wonko/BaseWonkoEntity.cpp b/api/logic/wonko/BaseWonkoEntity.cpp
deleted file mode 100644
index e6a0e41e..00000000
--- a/api/logic/wonko/BaseWonkoEntity.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright 2015-2017 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.
- */
-
-#include "BaseWonkoEntity.h"
-
-#include "Json.h"
-#include "WonkoUtil.h"
-
-BaseWonkoEntity::~BaseWonkoEntity()
-{
-}
-
-void BaseWonkoEntity::store() const
-{
- Json::write(serialized(), Wonko::localWonkoDir().absoluteFilePath(localFilename()));
-}
-
-void BaseWonkoEntity::notifyLocalLoadComplete()
-{
- m_localLoaded = true;
- store();
-}
-void BaseWonkoEntity::notifyRemoteLoadComplete()
-{
- m_remoteLoaded = true;
- store();
-}
diff --git a/api/logic/wonko/BaseWonkoEntity.h b/api/logic/wonko/BaseWonkoEntity.h
deleted file mode 100644
index c6e8c832..00000000
--- a/api/logic/wonko/BaseWonkoEntity.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright 2015-2017 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 <QObject>
-#include <memory>
-
-#include "multimc_logic_export.h"
-
-class Task;
-
-class MULTIMC_LOGIC_EXPORT BaseWonkoEntity
-{
-public:
- virtual ~BaseWonkoEntity();
-
- using Ptr = std::shared_ptr<BaseWonkoEntity>;
-
- virtual std::unique_ptr<Task> remoteUpdateTask() = 0;
- virtual std::unique_ptr<Task> localUpdateTask() = 0;
- virtual void merge(const std::shared_ptr<BaseWonkoEntity> &other) = 0;
-
- void store() const;
- virtual QString localFilename() const = 0;
- virtual QJsonObject serialized() const = 0;
-
- bool isComplete() const { return m_localLoaded || m_remoteLoaded; }
-
- bool isLocalLoaded() const { return m_localLoaded; }
- bool isRemoteLoaded() const { return m_remoteLoaded; }
-
- void notifyLocalLoadComplete();
- void notifyRemoteLoadComplete();
-
-private:
- bool m_localLoaded = false;
- bool m_remoteLoaded = false;
-};
diff --git a/api/logic/wonko/WonkoIndex_test.cpp b/api/logic/wonko/WonkoIndex_test.cpp
deleted file mode 100644
index d7b92f21..00000000
--- a/api/logic/wonko/WonkoIndex_test.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#include <QTest>
-#include "TestUtil.h"
-
-#include "wonko/WonkoIndex.h"
-#include "wonko/WonkoVersionList.h"
-#include "Env.h"
-
-class WonkoIndexTest : public QObject
-{
- Q_OBJECT
-private
-slots:
- void test_isProvidedByEnv()
- {
- QVERIFY(ENV.wonkoIndex());
- QCOMPARE(ENV.wonkoIndex(), ENV.wonkoIndex());
- }
-
- void test_providesTasks()
- {
- QVERIFY(ENV.wonkoIndex()->localUpdateTask() != nullptr);
- QVERIFY(ENV.wonkoIndex()->remoteUpdateTask() != nullptr);
- }
-
- void test_hasUid_and_getList()
- {
- WonkoIndex windex({std::make_shared<WonkoVersionList>("list1"), std::make_shared<WonkoVersionList>("list2"), std::make_shared<WonkoVersionList>("list3")});
- QVERIFY(windex.hasUid("list1"));
- QVERIFY(!windex.hasUid("asdf"));
- QVERIFY(windex.getList("list2") != nullptr);
- QCOMPARE(windex.getList("list2")->uid(), QString("list2"));
- QVERIFY(windex.getList("adsf") == nullptr);
- }
-
- void test_merge()
- {
- WonkoIndex windex({std::make_shared<WonkoVersionList>("list1"), std::make_shared<WonkoVersionList>("list2"), std::make_shared<WonkoVersionList>("list3")});
- QCOMPARE(windex.lists().size(), 3);
- windex.merge(std::shared_ptr<WonkoIndex>(new WonkoIndex({std::make_shared<WonkoVersionList>("list1"), std::make_shared<WonkoVersionList>("list2"), std::make_shared<WonkoVersionList>("list3")})));
- QCOMPARE(windex.lists().size(), 3);
- windex.merge(std::shared_ptr<WonkoIndex>(new WonkoIndex({std::make_shared<WonkoVersionList>("list4"), std::make_shared<WonkoVersionList>("list2"), std::make_shared<WonkoVersionList>("list5")})));
- QCOMPARE(windex.lists().size(), 5);
- windex.merge(std::shared_ptr<WonkoIndex>(new WonkoIndex({std::make_shared<WonkoVersionList>("list6")})));
- QCOMPARE(windex.lists().size(), 6);
- }
-};
-
-QTEST_GUILESS_MAIN(WonkoIndexTest)
-
-#include "WonkoIndex_test.moc"
diff --git a/api/logic/wonko/WonkoReference.cpp b/api/logic/wonko/WonkoReference.cpp
deleted file mode 100644
index 7193e56e..00000000
--- a/api/logic/wonko/WonkoReference.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright 2015-2017 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.
- */
-
-#include "WonkoReference.h"
-
-WonkoReference::WonkoReference(const QString &uid)
- : m_uid(uid)
-{
-}
-
-QString WonkoReference::uid() const
-{
- return m_uid;
-}
-
-QString WonkoReference::version() const
-{
- return m_version;
-}
-void WonkoReference::setVersion(const QString &version)
-{
- m_version = version;
-}
-
-bool WonkoReference::operator==(const WonkoReference &other) const
-{
- return m_uid == other.m_uid && m_version == other.m_version;
-}
-bool WonkoReference::operator!=(const WonkoReference &other) const
-{
- return m_uid != other.m_uid || m_version != other.m_version;
-}
diff --git a/api/logic/wonko/WonkoReference.h b/api/logic/wonko/WonkoReference.h
deleted file mode 100644
index ba7427b3..00000000
--- a/api/logic/wonko/WonkoReference.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright 2015-2017 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>
-#include <QMetaType>
-
-#include "multimc_logic_export.h"
-
-class MULTIMC_LOGIC_EXPORT WonkoReference
-{
-public:
- WonkoReference() {}
- explicit WonkoReference(const QString &uid);
-
- QString uid() const;
-
- QString version() const;
- void setVersion(const QString &version);
-
- bool operator==(const WonkoReference &other) const;
- bool operator!=(const WonkoReference &other) const;
-
-private:
- QString m_uid;
- QString m_version;
-};
-Q_DECLARE_METATYPE(WonkoReference)
diff --git a/api/logic/wonko/WonkoUtil.cpp b/api/logic/wonko/WonkoUtil.cpp
deleted file mode 100644
index 3b8049c4..00000000
--- a/api/logic/wonko/WonkoUtil.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright 2015-2017 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.
- */
-
-#include "WonkoUtil.h"
-
-#include <QUrl>
-#include <QDir>
-
-#include "Env.h"
-
-namespace Wonko
-{
-QUrl rootUrl()
-{
- return ENV.wonkoRootUrl();
-}
-QUrl indexUrl()
-{
- return rootUrl().resolved(QStringLiteral("index.json"));
-}
-QUrl versionListUrl(const QString &uid)
-{
- return rootUrl().resolved(uid + ".json");
-}
-QUrl versionUrl(const QString &uid, const QString &version)
-{
- return rootUrl().resolved(uid + "/" + version + ".json");
-}
-
-QDir localWonkoDir()
-{
- return QDir("wonko");
-}
-
-}
diff --git a/api/logic/wonko/WonkoVersion.cpp b/api/logic/wonko/WonkoVersion.cpp
deleted file mode 100644
index f5a063be..00000000
--- a/api/logic/wonko/WonkoVersion.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Copyright 2015-2017 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.
- */
-
-#include "WonkoVersion.h"
-
-#include <QDateTime>
-
-#include "tasks/BaseWonkoEntityLocalLoadTask.h"
-#include "tasks/BaseWonkoEntityRemoteLoadTask.h"
-#include "format/WonkoFormat.h"
-
-WonkoVersion::WonkoVersion(const QString &uid, const QString &version)
- : BaseVersion(), m_uid(uid), m_version(version)
-{
-}
-
-QString WonkoVersion::descriptor()
-{
- return m_version;
-}
-QString WonkoVersion::name()
-{
- return m_version;
-}
-QString WonkoVersion::typeString() const
-{
- return m_type;
-}
-
-QDateTime WonkoVersion::time() const
-{
- return QDateTime::fromMSecsSinceEpoch(m_time * 1000, Qt::UTC);
-}
-
-std::unique_ptr<Task> WonkoVersion::remoteUpdateTask()
-{
- return std::unique_ptr<WonkoVersionRemoteLoadTask>(new WonkoVersionRemoteLoadTask(this, this));
-}
-std::unique_ptr<Task> WonkoVersion::localUpdateTask()
-{
- return std::unique_ptr<WonkoVersionLocalLoadTask>(new WonkoVersionLocalLoadTask(this, this));
-}
-
-void WonkoVersion::merge(const std::shared_ptr<BaseWonkoEntity> &other)
-{
- WonkoVersionPtr version = std::dynamic_pointer_cast<WonkoVersion>(other);
- if (m_type != version->m_type)
- {
- setType(version->m_type);
- }
- if (m_time != version->m_time)
- {
- setTime(version->m_time);
- }
- if (m_requires != version->m_requires)
- {
- setRequires(version->m_requires);
- }
-
- setData(version->m_data);
-}
-
-QString WonkoVersion::localFilename() const
-{
- return m_uid + '/' + m_version + ".json";
-}
-QJsonObject WonkoVersion::serialized() const
-{
- return WonkoFormat::serializeVersion(this);
-}
-
-void WonkoVersion::setType(const QString &type)
-{
- m_type = type;
- emit typeChanged();
-}
-void WonkoVersion::setTime(const qint64 time)
-{
- m_time = time;
- emit timeChanged();
-}
-void WonkoVersion::setRequires(const QVector<WonkoReference> &requires)
-{
- m_requires = requires;
- emit requiresChanged();
-}
-void WonkoVersion::setData(const VersionFilePtr &data)
-{
- m_data = data;
-}
diff --git a/api/logic/wonko/WonkoVersionList.cpp b/api/logic/wonko/WonkoVersionList.cpp
deleted file mode 100644
index 191e00f9..00000000
--- a/api/logic/wonko/WonkoVersionList.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-/* Copyright 2015-2017 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.
- */
-
-#include "WonkoVersionList.h"
-
-#include <QDateTime>
-
-#include "WonkoVersion.h"
-#include "tasks/BaseWonkoEntityRemoteLoadTask.h"
-#include "tasks/BaseWonkoEntityLocalLoadTask.h"
-#include "format/WonkoFormat.h"
-#include "WonkoReference.h"
-
-class WVLLoadTask : public Task
-{
- Q_OBJECT
-public:
- explicit WVLLoadTask(WonkoVersionList *list, QObject *parent = nullptr)
- : Task(parent), m_list(list)
- {
- }
-
- bool canAbort() const override
- {
- return !m_currentTask || m_currentTask->canAbort();
- }
- bool abort() override
- {
- return m_currentTask->abort();
- }
-
-private:
- void executeTask() override
- {
- if (!m_list->isLocalLoaded())
- {
- m_currentTask = m_list->localUpdateTask();
- connect(m_currentTask.get(), &Task::succeeded, this, &WVLLoadTask::next);
- }
- else
- {
- m_currentTask = m_list->remoteUpdateTask();
- connect(m_currentTask.get(), &Task::succeeded, this, &WVLLoadTask::emitSucceeded);
- }
- connect(m_currentTask.get(), &Task::status, this, &WVLLoadTask::setStatus);
- connect(m_currentTask.get(), &Task::progress, this, &WVLLoadTask::setProgress);
- connect(m_currentTask.get(), &Task::failed, this, &WVLLoadTask::emitFailed);
- m_currentTask->start();
- }
-
- void next()
- {
- m_currentTask = m_list->remoteUpdateTask();
- connect(m_currentTask.get(), &Task::status, this, &WVLLoadTask::setStatus);
- connect(m_currentTask.get(), &Task::progress, this, &WVLLoadTask::setProgress);
- connect(m_currentTask.get(), &Task::succeeded, this, &WVLLoadTask::emitSucceeded);
- m_currentTask->start();
- }
-
- WonkoVersionList *m_list;
- std::unique_ptr<Task> m_currentTask;
-};
-
-WonkoVersionList::WonkoVersionList(const QString &uid, QObject *parent)
- : BaseVersionList(parent), m_uid(uid)
-{
- setObjectName("Wonko version list: " + uid);
-}
-
-Task *WonkoVersionList::getLoadTask()
-{
- return new WVLLoadTask(this);
-}
-
-bool WonkoVersionList::isLoaded()
-{
- return isLocalLoaded() && isRemoteLoaded();
-}
-
-const BaseVersionPtr WonkoVersionList::at(int i) const
-{
- return m_versions.at(i);
-}
-int WonkoVersionList::count() const
-{
- return m_versions.size();
-}
-
-void WonkoVersionList::sortVersions()
-{
- beginResetModel();
- std::sort(m_versions.begin(), m_versions.end(), [](const WonkoVersionPtr &a, const WonkoVersionPtr &b)
- {
- return *a.get() < *b.get();
- });
- endResetModel();
-}
-
-QVariant WonkoVersionList::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid() || index.row() < 0 || index.row() >= m_versions.size() || index.parent().isValid())
- {
- return QVariant();
- }
-
- WonkoVersionPtr version = m_versions.at(index.row());
-
- switch (role)
- {
- case VersionPointerRole: return QVariant::fromValue(std::dynamic_pointer_cast<BaseVersion>(version));
- case VersionRole:
- case VersionIdRole:
- return version->version();
- case ParentGameVersionRole:
- {
- const auto end = version->requires().end();
- const auto it = std::find_if(version->requires().begin(), end,
- [](const WonkoReference &ref) { return ref.uid() == "net.minecraft"; });
- if (it != end)
- {
- return (*it).version();
- }
- return QVariant();
- }
- case TypeRole: return version->type();
-
- case UidRole: return version->uid();
- case TimeRole: return version->time();
- case RequiresRole: return QVariant::fromValue(version->requires());
- case SortRole: return version->rawTime();
- case WonkoVersionPtrRole: return QVariant::fromValue(version);
- case RecommendedRole: return version == getRecommended();
- case LatestRole: return version == getLatestStable();
- default: return QVariant();
- }
-}
-
-BaseVersionList::RoleList WonkoVersionList::providesRoles() const
-{
- return {VersionPointerRole, VersionRole, VersionIdRole, ParentGameVersionRole,
- TypeRole, UidRole, TimeRole, RequiresRole, SortRole,
- RecommendedRole, LatestRole, WonkoVersionPtrRole};
-}
-
-QHash<int, QByteArray> WonkoVersionList::roleNames() const
-{
- QHash<int, QByteArray> roles = BaseVersionList::roleNames();
- roles.insert(UidRole, "uid");
- roles.insert(TimeRole, "time");
- roles.insert(SortRole, "sort");
- roles.insert(RequiresRole, "requires");
- return roles;
-}
-
-std::unique_ptr<Task> WonkoVersionList::remoteUpdateTask()
-{
- return std::unique_ptr<WonkoVersionListRemoteLoadTask>(new WonkoVersionListRemoteLoadTask(this, this));
-}
-std::unique_ptr<Task> WonkoVersionList::localUpdateTask()
-{
- return std::unique_ptr<WonkoVersionListLocalLoadTask>(new WonkoVersionListLocalLoadTask(this, this));
-}
-
-QString WonkoVersionList::localFilename() const
-{
- return m_uid + ".json";
-}
-QJsonObject WonkoVersionList::serialized() const
-{
- return WonkoFormat::serializeVersionList(this);
-}
-
-QString WonkoVersionList::humanReadable() const
-{
- return m_name.isEmpty() ? m_uid : m_name;
-}
-
-bool WonkoVersionList::hasVersion(const QString &version) const
-{
- return m_lookup.contains(version);
-}
-WonkoVersionPtr WonkoVersionList::getVersion(const QString &version) const
-{
- return m_lookup.value(version);
-}
-
-void WonkoVersionList::setName(const QString &name)
-{
- m_name = name;
- emit nameChanged(name);
-}
-void WonkoVersionList::setVersions(const QVector<WonkoVersionPtr> &versions)
-{
- beginResetModel();
- m_versions = versions;
- std::sort(m_versions.begin(), m_versions.end(), [](const WonkoVersionPtr &a, const WonkoVersionPtr &b)
- {
- return a->rawTime() > b->rawTime();
- });
- for (int i = 0; i < m_versions.size(); ++i)
- {
- m_lookup.insert(m_versions.at(i)->version(), m_versions.at(i));
- setupAddedVersion(i, m_versions.at(i));
- }
-
- m_latest = m_versions.isEmpty() ? nullptr : m_versions.first();
- auto recommendedIt = std::find_if(m_versions.constBegin(), m_versions.constEnd(), [](const WonkoVersionPtr &ptr) { return ptr->type() == "release"; });
- m_recommended = recommendedIt == m_versions.constEnd() ? nullptr : *recommendedIt;
- endResetModel();
-}
-
-void WonkoVersionList::merge(const BaseWonkoEntity::Ptr &other)
-{
- const WonkoVersionListPtr list = std::dynamic_pointer_cast<WonkoVersionList>(other);
- if (m_name != list->m_name)
- {
- setName(list->m_name);
- }
-
- if (m_versions.isEmpty())
- {
- setVersions(list->m_versions);
- }
- else
- {
- for (const WonkoVersionPtr &version : list->m_versions)
- {
- if (m_lookup.contains(version->version()))
- {
- m_lookup.value(version->version())->merge(version);
- }
- else
- {
- beginInsertRows(QModelIndex(), m_versions.size(), m_versions.size());
- setupAddedVersion(m_versions.size(), version);
- m_versions.append(version);
- m_lookup.insert(version->uid(), version);
- endInsertRows();
-
- if (!m_latest || version->rawTime() > m_latest->rawTime())
- {
- m_latest = version;
- emit dataChanged(index(0), index(m_versions.size() - 1), QVector<int>() << LatestRole);
- }
- if (!m_recommended || (version->type() == "release" && version->rawTime() > m_recommended->rawTime()))
- {
- m_recommended = version;
- emit dataChanged(index(0), index(m_versions.size() - 1), QVector<int>() << RecommendedRole);
- }
- }
- }
- }
-}
-
-void WonkoVersionList::setupAddedVersion(const int row, const WonkoVersionPtr &version)
-{
- connect(version.get(), &WonkoVersion::requiresChanged, this, [this, row]() { emit dataChanged(index(row), index(row), QVector<int>() << RequiresRole); });
- connect(version.get(), &WonkoVersion::timeChanged, this, [this, row]() { emit dataChanged(index(row), index(row), QVector<int>() << TimeRole << SortRole); });
- connect(version.get(), &WonkoVersion::typeChanged, this, [this, row]() { emit dataChanged(index(row), index(row), QVector<int>() << TypeRole); });
-}
-
-BaseVersionPtr WonkoVersionList::getLatestStable() const
-{
- return m_latest;
-}
-BaseVersionPtr WonkoVersionList::getRecommended() const
-{
- return m_recommended;
-}
-
-#include "WonkoVersionList.moc"
diff --git a/api/logic/wonko/format/WonkoFormat.cpp b/api/logic/wonko/format/WonkoFormat.cpp
deleted file mode 100644
index a5d593ca..00000000
--- a/api/logic/wonko/format/WonkoFormat.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Copyright 2015-2017 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.
- */
-
-#include "WonkoFormat.h"
-
-#include "WonkoFormatV1.h"
-
-#include "wonko/WonkoIndex.h"
-#include "wonko/WonkoVersion.h"
-#include "wonko/WonkoVersionList.h"
-
-static int formatVersion(const QJsonObject &obj)
-{
- if (!obj.contains("formatVersion")) {
- throw WonkoParseException(QObject::tr("Missing required field: 'formatVersion'"));
- }
- if (!obj.value("formatVersion").isDouble()) {
- throw WonkoParseException(QObject::tr("Required field has invalid type: 'formatVersion'"));
- }
- return obj.value("formatVersion").toInt();
-}
-
-void WonkoFormat::parseIndex(const QJsonObject &obj, WonkoIndex *ptr)
-{
- const int version = formatVersion(obj);
- switch (version) {
- case 1:
- ptr->merge(WonkoFormatV1().parseIndexInternal(obj));
- break;
- default:
- throw WonkoParseException(QObject::tr("Unknown formatVersion: %1").arg(version));
- }
-}
-void WonkoFormat::parseVersion(const QJsonObject &obj, WonkoVersion *ptr)
-{
- const int version = formatVersion(obj);
- switch (version) {
- case 1:
- ptr->merge(WonkoFormatV1().parseVersionInternal(obj));
- break;
- default:
- throw WonkoParseException(QObject::tr("Unknown formatVersion: %1").arg(version));
- }
-}
-void WonkoFormat::parseVersionList(const QJsonObject &obj, WonkoVersionList *ptr)
-{
- const int version = formatVersion(obj);
- switch (version) {
- case 10:
- ptr->merge(WonkoFormatV1().parseVersionListInternal(obj));
- break;
- default:
- throw WonkoParseException(QObject::tr("Unknown formatVersion: %1").arg(version));
- }
-}
-
-QJsonObject WonkoFormat::serializeIndex(const WonkoIndex *ptr)
-{
- return WonkoFormatV1().serializeIndexInternal(ptr);
-}
-QJsonObject WonkoFormat::serializeVersion(const WonkoVersion *ptr)
-{
- return WonkoFormatV1().serializeVersionInternal(ptr);
-}
-QJsonObject WonkoFormat::serializeVersionList(const WonkoVersionList *ptr)
-{
- return WonkoFormatV1().serializeVersionListInternal(ptr);
-}
diff --git a/api/logic/wonko/format/WonkoFormat.h b/api/logic/wonko/format/WonkoFormat.h
deleted file mode 100644
index 63ea9473..00000000
--- a/api/logic/wonko/format/WonkoFormat.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright 2015-2017 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 <QJsonObject>
-#include <memory>
-
-#include "Exception.h"
-#include "wonko/BaseWonkoEntity.h"
-
-class WonkoIndex;
-class WonkoVersion;
-class WonkoVersionList;
-
-class WonkoParseException : public Exception
-{
-public:
- using Exception::Exception;
-};
-
-class WonkoFormat
-{
-public:
- virtual ~WonkoFormat() {}
-
- static void parseIndex(const QJsonObject &obj, WonkoIndex *ptr);
- static void parseVersion(const QJsonObject &obj, WonkoVersion *ptr);
- static void parseVersionList(const QJsonObject &obj, WonkoVersionList *ptr);
-
- static QJsonObject serializeIndex(const WonkoIndex *ptr);
- static QJsonObject serializeVersion(const WonkoVersion *ptr);
- static QJsonObject serializeVersionList(const WonkoVersionList *ptr);
-
-protected:
- virtual BaseWonkoEntity::Ptr parseIndexInternal(const QJsonObject &obj) const = 0;
- virtual BaseWonkoEntity::Ptr parseVersionInternal(const QJsonObject &obj) const = 0;
- virtual BaseWonkoEntity::Ptr parseVersionListInternal(const QJsonObject &obj) const = 0;
- virtual QJsonObject serializeIndexInternal(const WonkoIndex *ptr) const = 0;
- virtual QJsonObject serializeVersionInternal(const WonkoVersion *ptr) const = 0;
- virtual QJsonObject serializeVersionListInternal(const WonkoVersionList *ptr) const = 0;
-};
diff --git a/api/logic/wonko/format/WonkoFormatV1.cpp b/api/logic/wonko/format/WonkoFormatV1.cpp
deleted file mode 100644
index 4cecb42f..00000000
--- a/api/logic/wonko/format/WonkoFormatV1.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/* Copyright 2015-2017 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.
- */
-
-#include "WonkoFormatV1.h"
-#include <minecraft/onesix/OneSixVersionFormat.h>
-
-#include "Json.h"
-
-#include "wonko/WonkoIndex.h"
-#include "wonko/WonkoVersion.h"
-#include "wonko/WonkoVersionList.h"
-#include "Env.h"
-
-using namespace Json;
-
-static WonkoVersionPtr parseCommonVersion(const QString &uid, const QJsonObject &obj)
-{
- const QVector<QJsonObject> requiresRaw = obj.contains("requires") ? requireIsArrayOf<QJsonObject>(obj, "requires") : QVector<QJsonObject>();
- QVector<WonkoReference> requires;
- requires.reserve(requiresRaw.size());
- std::transform(requiresRaw.begin(), requiresRaw.end(), std::back_inserter(requires), [](const QJsonObject &rObj)
- {
- WonkoReference ref(requireString(rObj, "uid"));
- ref.setVersion(ensureString(rObj, "version", QString()));
- return ref;
- });
-
- WonkoVersionPtr version = std::make_shared<WonkoVersion>(uid, requireString(obj, "version"));
- if (obj.value("time").isString())
- {
- version->setTime(QDateTime::fromString(requireString(obj, "time"), Qt::ISODate).toMSecsSinceEpoch() / 1000);
- }
- else
- {
- version->setTime(requireInteger(obj, "time"));
- }
- version->setType(ensureString(obj, "type", QString()));
- version->setRequires(requires);
- return version;
-}
-static void serializeCommonVersion(const WonkoVersion *version, QJsonObject &obj)
-{
- QJsonArray requires;
- for (const WonkoReference &ref : version->requires())
- {
- if (ref.version().isEmpty())
- {
- QJsonObject out;
- out["uid"] = ref.uid();
- requires.append(out);
- }
- else
- {
- QJsonObject out;
- out["uid"] = ref.uid();
- out["version"] = ref.version();
- requires.append(out);
- }
- }
-
- obj.insert("version", version->version());
- obj.insert("type", version->type());
- obj.insert("time", version->time().toString(Qt::ISODate));
- obj.insert("requires", requires);
-}
-
-BaseWonkoEntity::Ptr WonkoFormatV1::parseIndexInternal(const QJsonObject &obj) const
-{
- const QVector<QJsonObject> objects = requireIsArrayOf<QJsonObject>(obj, "index");
- QVector<WonkoVersionListPtr> lists;
- lists.reserve(objects.size());
- std::transform(objects.begin(), objects.end(), std::back_inserter(lists), [](const QJsonObject &obj)
- {
- WonkoVersionListPtr list = std::make_shared<WonkoVersionList>(requireString(obj, "uid"));
- list->setName(ensureString(obj, "name", QString()));
- return list;
- });
- return std::make_shared<WonkoIndex>(lists);
-}
-BaseWonkoEntity::Ptr WonkoFormatV1::parseVersionInternal(const QJsonObject &obj) const
-{
- WonkoVersionPtr version = parseCommonVersion(requireString(obj, "uid"), obj);
-
- version->setData(OneSixVersionFormat::versionFileFromJson(QJsonDocument(obj),
- QString("%1/%2.json").arg(version->uid(), version->version()),
- obj.contains("order")));
- return version;
-}
-BaseWonkoEntity::Ptr WonkoFormatV1::parseVersionListInternal(const QJsonObject &obj) const
-{
- const QString uid = requireString(obj, "uid");
-
- const QVector<QJsonObject> versionsRaw = requireIsArrayOf<QJsonObject>(obj, "versions");
- QVector<WonkoVersionPtr> versions;
- versions.reserve(versionsRaw.size());
- std::transform(versionsRaw.begin(), versionsRaw.end(), std::back_inserter(versions), [this, uid](const QJsonObject &vObj)
- { return parseCommonVersion(uid, vObj); });
-
- WonkoVersionListPtr list = std::make_shared<WonkoVersionList>(uid);
- list->setName(ensureString(obj, "name", QString()));
- list->setVersions(versions);
- return list;
-}
-
-QJsonObject WonkoFormatV1::serializeIndexInternal(const WonkoIndex *ptr) const
-{
- QJsonArray index;
- for (const WonkoVersionListPtr &list : ptr->lists())
- {
- QJsonObject out;
- out["uid"] = list->uid();
- out["version"] = list->name();
- index.append(out);
- }
- QJsonObject out;
- out["formatVersion"] = 1;
- out["index"] = index;
- return out;
-}
-QJsonObject WonkoFormatV1::serializeVersionInternal(const WonkoVersion *ptr) const
-{
- QJsonObject obj = OneSixVersionFormat::versionFileToJson(ptr->data(), true).object();
- serializeCommonVersion(ptr, obj);
- obj.insert("formatVersion", 1);
- obj.insert("uid", ptr->uid());
- // TODO: the name should be looked up in the UI based on the uid
- obj.insert("name", ENV.wonkoIndex()->getListGuaranteed(ptr->uid())->name());
-
- return obj;
-}
-QJsonObject WonkoFormatV1::serializeVersionListInternal(const WonkoVersionList *ptr) const
-{
- QJsonArray versions;
- for (const WonkoVersionPtr &version : ptr->versions())
- {
- QJsonObject obj;
- serializeCommonVersion(version.get(), obj);
- versions.append(obj);
- }
- QJsonObject out;
- out["formatVersion"] = 10;
- out["uid"] = ptr->uid();
- out["name"] = ptr->name().isNull() ? QJsonValue() : ptr->name();
- out["versions"] = versions;
- return out;
-}
diff --git a/api/logic/wonko/format/WonkoFormatV1.h b/api/logic/wonko/format/WonkoFormatV1.h
deleted file mode 100644
index 2ae3acd1..00000000
--- a/api/logic/wonko/format/WonkoFormatV1.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright 2015-2017 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 "WonkoFormat.h"
-
-class WonkoFormatV1 : public WonkoFormat
-{
-public:
- BaseWonkoEntity::Ptr parseIndexInternal(const QJsonObject &obj) const override;
- BaseWonkoEntity::Ptr parseVersionInternal(const QJsonObject &obj) const override;
- BaseWonkoEntity::Ptr parseVersionListInternal(const QJsonObject &obj) const override;
-
- QJsonObject serializeIndexInternal(const WonkoIndex *ptr) const override;
- QJsonObject serializeVersionInternal(const WonkoVersion *ptr) const override;
- QJsonObject serializeVersionListInternal(const WonkoVersionList *ptr) const override;
-};
diff --git a/api/logic/wonko/tasks/BaseWonkoEntityLocalLoadTask.cpp b/api/logic/wonko/tasks/BaseWonkoEntityLocalLoadTask.cpp
deleted file mode 100644
index caffa744..00000000
--- a/api/logic/wonko/tasks/BaseWonkoEntityLocalLoadTask.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Copyright 2015-2017 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.
- */
-
-#include "BaseWonkoEntityLocalLoadTask.h"
-
-#include <QFile>
-
-#include "wonko/format/WonkoFormat.h"
-#include "wonko/WonkoUtil.h"
-#include "wonko/WonkoIndex.h"
-#include "wonko/WonkoVersion.h"
-#include "wonko/WonkoVersionList.h"
-#include "Env.h"
-#include "Json.h"
-
-BaseWonkoEntityLocalLoadTask::BaseWonkoEntityLocalLoadTask(BaseWonkoEntity *entity, QObject *parent)
- : Task(parent), m_entity(entity)
-{
-}
-
-void BaseWonkoEntityLocalLoadTask::executeTask()
-{
- const QString fname = Wonko::localWonkoDir().absoluteFilePath(filename());
- if (!QFile::exists(fname))
- {
- emitFailed(tr("File doesn't exist"));
- return;
- }
-
- setStatus(tr("Reading %1...").arg(name()));
- setProgress(0, 0);
-
- try
- {
- parse(Json::requireObject(Json::requireDocument(fname, name()), name()));
- m_entity->notifyLocalLoadComplete();
- emitSucceeded();
- }
- catch (Exception &e)
- {
- emitFailed(tr("Unable to parse file %1: %2").arg(fname, e.cause()));
- }
-}
-
-// WONKO INDEX //
-WonkoIndexLocalLoadTask::WonkoIndexLocalLoadTask(WonkoIndex *index, QObject *parent)
- : BaseWonkoEntityLocalLoadTask(index, parent)
-{
-}
-QString WonkoIndexLocalLoadTask::filename() const
-{
- return "index.json";
-}
-QString WonkoIndexLocalLoadTask::name() const
-{
- return tr("Wonko Index");
-}
-void WonkoIndexLocalLoadTask::parse(const QJsonObject &obj) const
-{
- WonkoFormat::parseIndex(obj, dynamic_cast<WonkoIndex *>(entity()));
-}
-
-// WONKO VERSION LIST //
-WonkoVersionListLocalLoadTask::WonkoVersionListLocalLoadTask(WonkoVersionList *list, QObject *parent)
- : BaseWonkoEntityLocalLoadTask(list, parent)
-{
-}
-QString WonkoVersionListLocalLoadTask::filename() const
-{
- return list()->uid() + ".json";
-}
-QString WonkoVersionListLocalLoadTask::name() const
-{
- return tr("Wonko Version List for %1").arg(list()->humanReadable());
-}
-void WonkoVersionListLocalLoadTask::parse(const QJsonObject &obj) const
-{
- WonkoFormat::parseVersionList(obj, list());
-}
-WonkoVersionList *WonkoVersionListLocalLoadTask::list() const
-{
- return dynamic_cast<WonkoVersionList *>(entity());
-}
-
-// WONKO VERSION //
-WonkoVersionLocalLoadTask::WonkoVersionLocalLoadTask(WonkoVersion *version, QObject *parent)
- : BaseWonkoEntityLocalLoadTask(version, parent)
-{
-}
-QString WonkoVersionLocalLoadTask::filename() const
-{
- return version()->uid() + "/" + version()->version() + ".json";
-}
-QString WonkoVersionLocalLoadTask::name() const
-{
- return tr("Wonko Version for %1").arg(version()->name());
-}
-void WonkoVersionLocalLoadTask::parse(const QJsonObject &obj) const
-{
- WonkoFormat::parseVersion(obj, version());
-}
-WonkoVersion *WonkoVersionLocalLoadTask::version() const
-{
- return dynamic_cast<WonkoVersion *>(entity());
-}
diff --git a/api/logic/wonko/tasks/BaseWonkoEntityLocalLoadTask.h b/api/logic/wonko/tasks/BaseWonkoEntityLocalLoadTask.h
deleted file mode 100644
index a4f530c7..00000000
--- a/api/logic/wonko/tasks/BaseWonkoEntityLocalLoadTask.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* Copyright 2015-2017 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 "tasks/Task.h"
-#include <memory>
-
-class BaseWonkoEntity;
-class WonkoIndex;
-class WonkoVersionList;
-class WonkoVersion;
-
-class BaseWonkoEntityLocalLoadTask : public Task
-{
- Q_OBJECT
-public:
- explicit BaseWonkoEntityLocalLoadTask(BaseWonkoEntity *entity, QObject *parent = nullptr);
-
-protected:
- virtual QString filename() const = 0;
- virtual QString name() const = 0;
- virtual void parse(const QJsonObject &obj) const = 0;
-
- BaseWonkoEntity *entity() const { return m_entity; }
-
-private:
- void executeTask() override;
-
- BaseWonkoEntity *m_entity;
-};
-
-class WonkoIndexLocalLoadTask : public BaseWonkoEntityLocalLoadTask
-{
- Q_OBJECT
-public:
- explicit WonkoIndexLocalLoadTask(WonkoIndex *index, QObject *parent = nullptr);
-
-private:
- QString filename() const override;
- QString name() const override;
- void parse(const QJsonObject &obj) const override;
-};
-class WonkoVersionListLocalLoadTask : public BaseWonkoEntityLocalLoadTask
-{
- Q_OBJECT
-public:
- explicit WonkoVersionListLocalLoadTask(WonkoVersionList *list, QObject *parent = nullptr);
-
-private:
- QString filename() const override;
- QString name() const override;
- void parse(const QJsonObject &obj) const override;
-
- WonkoVersionList *list() const;
-};
-class WonkoVersionLocalLoadTask : public BaseWonkoEntityLocalLoadTask
-{
- Q_OBJECT
-public:
- explicit WonkoVersionLocalLoadTask(WonkoVersion *version, QObject *parent = nullptr);
-
-private:
- QString filename() const override;
- QString name() const override;
- void parse(const QJsonObject &obj) const override;
-
- WonkoVersion *version() const;
-};
diff --git a/api/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp b/api/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp
deleted file mode 100644
index 999d245b..00000000
--- a/api/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Copyright 2015-2017 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.
- */
-
-#include "BaseWonkoEntityRemoteLoadTask.h"
-
-#include "net/Download.h"
-#include "net/HttpMetaCache.h"
-#include "net/NetJob.h"
-#include "wonko/format/WonkoFormat.h"
-#include "wonko/WonkoUtil.h"
-#include "wonko/WonkoIndex.h"
-#include "wonko/WonkoVersion.h"
-#include "wonko/WonkoVersionList.h"
-#include "Env.h"
-#include "Json.h"
-
-BaseWonkoEntityRemoteLoadTask::BaseWonkoEntityRemoteLoadTask(BaseWonkoEntity *entity, QObject *parent)
- : Task(parent), m_entity(entity)
-{
-}
-
-void BaseWonkoEntityRemoteLoadTask::executeTask()
-{
- NetJob *job = new NetJob(name());
-
- auto entry = ENV.metacache()->resolveEntry("wonko", url().toString());
- entry->setStale(true);
- m_dl = Net::Download::makeCached(url(), entry);
- job->addNetAction(m_dl);
- connect(job, &NetJob::failed, this, &BaseWonkoEntityRemoteLoadTask::emitFailed);
- connect(job, &NetJob::succeeded, this, &BaseWonkoEntityRemoteLoadTask::networkFinished);
- connect(job, &NetJob::status, this, &BaseWonkoEntityRemoteLoadTask::setStatus);
- connect(job, &NetJob::progress, this, &BaseWonkoEntityRemoteLoadTask::setProgress);
- job->start();
-}
-
-void BaseWonkoEntityRemoteLoadTask::networkFinished()
-{
- setStatus(tr("Parsing..."));
- setProgress(0, 0);
-
- try
- {
- parse(Json::requireObject(Json::requireDocument(m_dl->getTargetFilepath(), name()), name()));
- m_entity->notifyRemoteLoadComplete();
- emitSucceeded();
- }
- catch (Exception &e)
- {
- emitFailed(tr("Unable to parse response: %1").arg(e.cause()));
- }
-}
-
-// WONKO INDEX //
-WonkoIndexRemoteLoadTask::WonkoIndexRemoteLoadTask(WonkoIndex *index, QObject *parent)
- : BaseWonkoEntityRemoteLoadTask(index, parent)
-{
-}
-QUrl WonkoIndexRemoteLoadTask::url() const
-{
- return Wonko::indexUrl();
-}
-QString WonkoIndexRemoteLoadTask::name() const
-{
- return tr("Wonko Index");
-}
-void WonkoIndexRemoteLoadTask::parse(const QJsonObject &obj) const
-{
- WonkoFormat::parseIndex(obj, dynamic_cast<WonkoIndex *>(entity()));
-}
-
-// WONKO VERSION LIST //
-WonkoVersionListRemoteLoadTask::WonkoVersionListRemoteLoadTask(WonkoVersionList *list, QObject *parent)
- : BaseWonkoEntityRemoteLoadTask(list, parent)
-{
-}
-QUrl WonkoVersionListRemoteLoadTask::url() const
-{
- return Wonko::versionListUrl(list()->uid());
-}
-QString WonkoVersionListRemoteLoadTask::name() const
-{
- return tr("Wonko Version List for %1").arg(list()->humanReadable());
-}
-void WonkoVersionListRemoteLoadTask::parse(const QJsonObject &obj) const
-{
- WonkoFormat::parseVersionList(obj, list());
-}
-WonkoVersionList *WonkoVersionListRemoteLoadTask::list() const
-{
- return dynamic_cast<WonkoVersionList *>(entity());
-}
-
-// WONKO VERSION //
-WonkoVersionRemoteLoadTask::WonkoVersionRemoteLoadTask(WonkoVersion *version, QObject *parent)
- : BaseWonkoEntityRemoteLoadTask(version, parent)
-{
-}
-QUrl WonkoVersionRemoteLoadTask::url() const
-{
- return Wonko::versionUrl(version()->uid(), version()->version());
-}
-QString WonkoVersionRemoteLoadTask::name() const
-{
- return tr("Wonko Version for %1").arg(version()->name());
-}
-void WonkoVersionRemoteLoadTask::parse(const QJsonObject &obj) const
-{
- WonkoFormat::parseVersion(obj, version());
-}
-WonkoVersion *WonkoVersionRemoteLoadTask::version() const
-{
- return dynamic_cast<WonkoVersion *>(entity());
-}
diff --git a/api/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.h b/api/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.h
deleted file mode 100644
index 0eab089a..00000000
--- a/api/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright 2015-2017 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 "tasks/Task.h"
-#include <memory>
-
-namespace Net
-{
- class Download;
-}
-
-class BaseWonkoEntity;
-class WonkoIndex;
-class WonkoVersionList;
-class WonkoVersion;
-
-class BaseWonkoEntityRemoteLoadTask : public Task
-{
- Q_OBJECT
-public:
- explicit BaseWonkoEntityRemoteLoadTask(BaseWonkoEntity *entity, QObject *parent = nullptr);
-
-protected:
- virtual QUrl url() const = 0;
- virtual QString name() const = 0;
- virtual void parse(const QJsonObject &obj) const = 0;
-
- BaseWonkoEntity *entity() const { return m_entity; }
-
-private slots:
- void networkFinished();
-
-private:
- void executeTask() override;
-
- BaseWonkoEntity *m_entity;
- std::shared_ptr<Net::Download> m_dl;
-};
-
-class WonkoIndexRemoteLoadTask : public BaseWonkoEntityRemoteLoadTask
-{
- Q_OBJECT
-public:
- explicit WonkoIndexRemoteLoadTask(WonkoIndex *index, QObject *parent = nullptr);
-
-private:
- QUrl url() const override;
- QString name() const override;
- void parse(const QJsonObject &obj) const override;
-};
-class WonkoVersionListRemoteLoadTask : public BaseWonkoEntityRemoteLoadTask
-{
- Q_OBJECT
-public:
- explicit WonkoVersionListRemoteLoadTask(WonkoVersionList *list, QObject *parent = nullptr);
-
-private:
- QUrl url() const override;
- QString name() const override;
- void parse(const QJsonObject &obj) const override;
-
- WonkoVersionList *list() const;
-};
-class WonkoVersionRemoteLoadTask : public BaseWonkoEntityRemoteLoadTask
-{
- Q_OBJECT
-public:
- explicit WonkoVersionRemoteLoadTask(WonkoVersion *version, QObject *parent = nullptr);
-
-private:
- QUrl url() const override;
- QString name() const override;
- void parse(const QJsonObject &obj) const override;
-
- WonkoVersion *version() const;
-};
diff --git a/application/BuildConfig.cpp.in b/application/BuildConfig.cpp.in
index 70bc93d3..99551867 100644
--- a/application/BuildConfig.cpp.in
+++ b/application/BuildConfig.cpp.in
@@ -33,7 +33,6 @@ Config::Config()
VERSION_STR = "@MultiMC_VERSION_STRING@";
NEWS_RSS_URL = "@MultiMC_NEWS_RSS_URL@";
PASTE_EE_KEY = "@MultiMC_PASTE_EE_API_KEY@";
- WONKO_ROOT_URL = "@MultiMC_WONKO_ROOT_URL@";
}
QString Config::printableVersionString() const
diff --git a/application/BuildConfig.h b/application/BuildConfig.h
index 75109b1c..1c9466ba 100644
--- a/application/BuildConfig.h
+++ b/application/BuildConfig.h
@@ -61,11 +61,6 @@ public:
QString PASTE_EE_KEY;
/**
- * Root URL for wonko things. Other wonko URLs will be resolved relative to this.
- */
- QString WONKO_ROOT_URL;
-
- /**
* \brief Converts the Version to a string.
* \return The version number in string format (major.minor.revision.build).
*/
diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt
index 90fa1aca..f03225da 100644
--- a/application/CMakeLists.txt
+++ b/application/CMakeLists.txt
@@ -30,9 +30,6 @@ set(MultiMC_ANALYTICS_ID "" CACHE STRING "ID you can get from Google analytics")
include(GetGitRevisionDescription)
get_git_head_revision(MultiMC_GIT_REFSPEC MultiMC_GIT_COMMIT)
-# Root URL for wonko files
-set(MultiMC_WONKO_ROOT_URL "" CACHE STRING "Root URL for wonko stuff")
-
message(STATUS "Git commit: ${MultiMC_GIT_COMMIT}")
message(STATUS "Git refspec: ${MultiMC_GIT_REFSPEC}")
@@ -99,8 +96,6 @@ SET(MULTIMC_SOURCES
VersionProxyModel.cpp
ColorCache.h
ColorCache.cpp
- WonkoGui.h
- WonkoGui.cpp
# GUI - windows
MainWindow.h
@@ -189,8 +184,8 @@ SET(MULTIMC_SOURCES
pages/global/ProxyPage.h
pages/global/PasteEEPage.cpp
pages/global/PasteEEPage.h
- pages/global/WonkoPage.cpp
- pages/global/WonkoPage.h
+ pages/global/PackagesPage.cpp
+ pages/global/PackagesPage.h
# GUI - dialogs
dialogs/AboutDialog.cpp
@@ -289,7 +284,7 @@ SET(MULTIMC_UIS
pages/global/MultiMCPage.ui
pages/global/ProxyPage.ui
pages/global/PasteEEPage.ui
- pages/global/WonkoPage.ui
+ pages/global/PackagesPage.ui
# Dialogs
dialogs/CopyInstanceDialog.ui
@@ -318,7 +313,6 @@ set(MULTIMC_QRCS
resources/pe_blue/pe_blue.qrc
resources/OSX/OSX.qrc
resources/iOS/iOS.qrc
- resources/versions/versions.qrc
resources/certs/certs.qrc
)
diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp
index 3bdf540d..e0870d06 100644
--- a/application/MainWindow.cpp
+++ b/application/MainWindow.cpp
@@ -54,7 +54,6 @@
#include <java/JavaUtils.h>
#include <java/JavaInstallList.h>
#include <launch/LaunchTask.h>
-#include <minecraft/MinecraftVersionList.h>
#include <minecraft/legacy/LwjglVersionList.h>
#include <minecraft/auth/MojangAccountList.h>
#include <SkinUtils.h>
@@ -555,19 +554,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
job->start();
}
- // run the things that load and download other things... FIXME: this is NOT the place
- // FIXME: invisible actions in the background = NOPE.
+ // load the news
{
- if (!MMC->minecraftlist()->isLoaded())
- {
- m_versionLoadTask = MMC->minecraftlist()->getLoadTask();
- startTask(m_versionLoadTask);
- }
- if (!MMC->lwjgllist()->isLoaded())
- {
- MMC->lwjgllist()->loadList();
- }
-
m_newsChecker->reloadNews();
updateNewsLabel();
}
@@ -1014,18 +1002,6 @@ void MainWindow::setCatBackground(bool enabled)
}
}
-// FIXME: eliminate, should not be needed
-void MainWindow::waitForMinecraftVersions()
-{
- if (!MMC->minecraftlist()->isLoaded() && m_versionLoadTask && m_versionLoadTask->isRunning())
- {
- QEventLoop waitLoop;
- waitLoop.connect(m_versionLoadTask, &Task::failed, &waitLoop, &QEventLoop::quit);
- waitLoop.connect(m_versionLoadTask, &Task::succeeded, &waitLoop, &QEventLoop::quit);
- waitLoop.exec();
- }
-}
-
void MainWindow::runModalTask(Task *task)
{
connect(task, &Task::failed, [this](QString reason)
@@ -1117,8 +1093,6 @@ void MainWindow::on_actionAddInstance_triggered()
groupName = map["group"].toString();
} while(0);
- waitForMinecraftVersions();
-
if(groupName.isEmpty())
{
groupName = MMC->settings()->get("LastUsedGroupForNewInstance").toString();
diff --git a/application/MainWindow.h b/application/MainWindow.h
index 6b30c86e..a7ab9172 100644
--- a/application/MainWindow.h
+++ b/application/MainWindow.h
@@ -167,7 +167,6 @@ private:
void updateInstanceToolIcon(QString new_icon);
void setSelectedInstanceById(const QString &id);
- void waitForMinecraftVersions();
void runModalTask(Task *task);
void instanceFromVersion(QString instName, QString instGroup, QString instIcon, BaseVersionPtr version);
void instanceFromZipPack(QString instName, QString instGroup, QString instIcon, QUrl url);
diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp
index 081de41c..942b1d93 100644
--- a/application/MultiMC.cpp
+++ b/application/MultiMC.cpp
@@ -10,6 +10,7 @@
#include "pages/global/ExternalToolsPage.h"
#include "pages/global/AccountListPage.h"
#include "pages/global/PasteEEPage.h"
+#include "pages/global/PackagesPage.h"
#include "themes/ITheme.h"
#include "themes/SystemTheme.h"
@@ -41,9 +42,6 @@
#include "icons/IconList.h"
//FIXME: get rid of this
#include "minecraft/legacy/LwjglVersionList.h"
-#include "minecraft/MinecraftVersionList.h"
-#include "minecraft/liteloader/LiteLoaderVersionList.h"
-#include "minecraft/forge/ForgeVersionList.h"
#include "net/HttpMetaCache.h"
#include "net/URLConstants.h"
@@ -337,7 +335,6 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
initIcons();
initThemes();
// make sure we have at least some minecraft versions before we init instances
- minecraftlist();
initInstances();
initAccounts();
initNetwork();
@@ -842,6 +839,7 @@ void MultiMC::initGlobalSettings()
m_globalSettingsProvider->addPage<MinecraftPage>();
m_globalSettingsProvider->addPage<JavaPage>();
m_globalSettingsProvider->addPage<ProxyPage>();
+ m_globalSettingsProvider->addPage<PackagesPage>();
m_globalSettingsProvider->addPage<ExternalToolsPage>();
m_globalSettingsProvider->addPage<AccountListPage>();
m_globalSettingsProvider->addPage<PasteEEPage>();
@@ -868,36 +866,6 @@ std::shared_ptr<LWJGLVersionList> MultiMC::lwjgllist()
return m_lwjgllist;
}
-std::shared_ptr<ForgeVersionList> MultiMC::forgelist()
-{
- if (!m_forgelist)
- {
- m_forgelist.reset(new ForgeVersionList());
- ENV.registerVersionList("net.minecraftforge", m_forgelist);
- }
- return m_forgelist;
-}
-
-std::shared_ptr<LiteLoaderVersionList> MultiMC::liteloaderlist()
-{
- if (!m_liteloaderlist)
- {
- m_liteloaderlist.reset(new LiteLoaderVersionList());
- ENV.registerVersionList("com.mumfrey.liteloader", m_liteloaderlist);
- }
- return m_liteloaderlist;
-}
-
-std::shared_ptr<MinecraftVersionList> MultiMC::minecraftlist()
-{
- if (!m_minecraftlist)
- {
- m_minecraftlist.reset(new MinecraftVersionList());
- ENV.registerVersionList("net.minecraft", m_minecraftlist);
- }
- return m_minecraftlist;
-}
-
std::shared_ptr<JavaInstallList> MultiMC::javalist()
{
if (!m_javalist)
diff --git a/application/MultiMC.h b/application/MultiMC.h
index d8062bb5..a9cbdec7 100644
--- a/application/MultiMC.h
+++ b/application/MultiMC.h
@@ -18,7 +18,6 @@ class SetupWizard;
class FolderInstanceProvider;
class GenericPageProvider;
class QFile;
-class MinecraftVersionList;
class LWJGLVersionList;
class HttpMetaCache;
class SettingsObject;
@@ -26,8 +25,6 @@ class InstanceList;
class MojangAccountList;
class IconList;
class QNetworkAccessManager;
-class ForgeVersionList;
-class LiteLoaderVersionList;
class JavaInstallList;
class UpdateChecker;
class BaseProfilerFactory;
@@ -96,10 +93,7 @@ public:
}
std::shared_ptr<TranslationsModel> translations();
- std::shared_ptr<MinecraftVersionList> minecraftlist();
std::shared_ptr<LWJGLVersionList> lwjgllist();
- std::shared_ptr<ForgeVersionList> forgelist();
- std::shared_ptr<LiteLoaderVersionList> liteloaderlist();
std::shared_ptr<JavaInstallList> javalist();
std::shared_ptr<InstanceList> instances() const
@@ -202,9 +196,6 @@ private:
std::shared_ptr<UpdateChecker> m_updateChecker;
std::shared_ptr<MojangAccountList> m_accounts;
std::shared_ptr<LWJGLVersionList> m_lwjgllist;
- std::shared_ptr<ForgeVersionList> m_forgelist;
- std::shared_ptr<LiteLoaderVersionList> m_liteloaderlist;
- std::shared_ptr<MinecraftVersionList> m_minecraftlist;
std::shared_ptr<JavaInstallList> m_javalist;
std::shared_ptr<TranslationsModel> m_translations;
std::shared_ptr<GenericPageProvider> m_globalSettingsProvider;
diff --git a/application/VersionProxyModel.cpp b/application/VersionProxyModel.cpp
index 22df7e09..96bdc9ab 100644
--- a/application/VersionProxyModel.cpp
+++ b/application/VersionProxyModel.cpp
@@ -26,19 +26,9 @@ public:
switch(role)
{
- case BaseVersionList::ParentGameVersionRole:
+ case BaseVersionList::ParentVersionRole:
case BaseVersionList::VersionIdRole:
- {
- auto versionString = data.toString();
- if(it.value().exact)
- {
- return versionString == it.value().string;
- }
- else
- {
- return versionIsInInterval(versionString, it.value().string);
- }
- }
+ // TODO: work with metadata here. Previous implementation based on the Version class is not sufficient
default:
{
auto match = data.toString();
@@ -146,7 +136,7 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
case Name:
return sourceModel()->data(parentIndex, BaseVersionList::VersionRole);
case ParentVersion:
- return sourceModel()->data(parentIndex, BaseVersionList::ParentGameVersionRole);
+ return sourceModel()->data(parentIndex, BaseVersionList::ParentVersionRole);
case Branch:
return sourceModel()->data(parentIndex, BaseVersionList::BranchRole);
case Type:
@@ -313,9 +303,9 @@ void VersionProxyModel::setSourceModel(QAbstractItemModel *replacingRaw)
auto replacing = dynamic_cast<BaseVersionList *>(replacingRaw);
beginResetModel();
+ m_columns.clear();
if(!replacing)
{
- m_columns.clear();
roles.clear();
filterModel->setSourceModel(replacing);
return;
@@ -327,7 +317,7 @@ void VersionProxyModel::setSourceModel(QAbstractItemModel *replacingRaw)
m_columns.push_back(Name);
}
/*
- if(roles.contains(BaseVersionList::ParentGameVersionRole))
+ if(roles.contains(BaseVersionList::ParentVersionRole))
{
m_columns.push_back(ParentVersion);
}
diff --git a/application/WonkoGui.cpp b/application/WonkoGui.cpp
deleted file mode 100644
index 4d376fdc..00000000
--- a/application/WonkoGui.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-#include "WonkoGui.h"
-
-#include "dialogs/ProgressDialog.h"
-#include "wonko/WonkoIndex.h"
-#include "wonko/WonkoVersionList.h"
-#include "wonko/WonkoVersion.h"
-#include "Env.h"
-
-WonkoIndexPtr Wonko::ensureIndexLoaded(QWidget *parent)
-{
- if (!ENV.wonkoIndex()->isLocalLoaded())
- {
- ProgressDialog(parent).execWithTask(ENV.wonkoIndex()->localUpdateTask());
- if (!ENV.wonkoIndex()->isRemoteLoaded() && ENV.wonkoIndex()->lists().size() == 0)
- {
- ProgressDialog(parent).execWithTask(ENV.wonkoIndex()->remoteUpdateTask());
- }
- }
- return ENV.wonkoIndex();
-}
-
-WonkoVersionListPtr Wonko::ensureVersionListExists(const QString &uid, QWidget *parent)
-{
- ensureIndexLoaded(parent);
- if (!ENV.wonkoIndex()->isRemoteLoaded() && !ENV.wonkoIndex()->hasUid(uid))
- {
- ProgressDialog(parent).execWithTask(ENV.wonkoIndex()->remoteUpdateTask());
- }
- return ENV.wonkoIndex()->getList(uid);
-}
-WonkoVersionListPtr Wonko::ensureVersionListLoaded(const QString &uid, QWidget *parent)
-{
- WonkoVersionListPtr list = ensureVersionListExists(uid, parent);
- if (!list)
- {
- return nullptr;
- }
- if (!list->isLocalLoaded())
- {
- ProgressDialog(parent).execWithTask(list->localUpdateTask());
- if (!list->isLocalLoaded())
- {
- ProgressDialog(parent).execWithTask(list->remoteUpdateTask());
- }
- }
- return list->isComplete() ? list : nullptr;
-}
-
-WonkoVersionPtr Wonko::ensureVersionExists(const QString &uid, const QString &version, QWidget *parent)
-{
- WonkoVersionListPtr list = ensureVersionListLoaded(uid, parent);
- if (!list)
- {
- return nullptr;
- }
- return list->getVersion(version);
-}
-WonkoVersionPtr Wonko::ensureVersionLoaded(const QString &uid, const QString &version, QWidget *parent, const UpdateType update)
-{
- WonkoVersionPtr vptr = ensureVersionExists(uid, version, parent);
- if (!vptr)
- {
- return nullptr;
- }
- if (!vptr->isLocalLoaded() || update == AlwaysUpdate)
- {
- ProgressDialog(parent).execWithTask(vptr->localUpdateTask());
- if (!vptr->isLocalLoaded() || update == AlwaysUpdate)
- {
- ProgressDialog(parent).execWithTask(vptr->remoteUpdateTask());
- }
- }
- return vptr->isComplete() ? vptr : nullptr;
-}
diff --git a/application/WonkoGui.h b/application/WonkoGui.h
deleted file mode 100644
index ad0bee89..00000000
--- a/application/WonkoGui.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#pragma once
-
-#include <memory>
-#include "QObjectPtr.h"
-
-class QWidget;
-class QString;
-
-using WonkoIndexPtr = shared_qobject_ptr<class WonkoIndex>;
-using WonkoVersionListPtr = std::shared_ptr<class WonkoVersionList>;
-using WonkoVersionPtr = std::shared_ptr<class WonkoVersion>;
-
-namespace Wonko
-{
-enum UpdateType
-{
- AlwaysUpdate,
- UpdateIfNeeded
-};
-
-/// Ensures that the index has been loaded, either from the local cache or remotely
-WonkoIndexPtr ensureIndexLoaded(QWidget *parent);
-/// Ensures that the given uid exists. Returns a nullptr if it doesn't.
-WonkoVersionListPtr ensureVersionListExists(const QString &uid, QWidget *parent);
-/// Ensures that the given uid exists and is loaded, either from the local cache or remotely. Returns nullptr if it doesn't exist or couldn't be loaded.
-WonkoVersionListPtr ensureVersionListLoaded(const QString &uid, QWidget *parent);
-WonkoVersionPtr ensureVersionExists(const QString &uid, const QString &version, QWidget *parent);
-WonkoVersionPtr ensureVersionLoaded(const QString &uid, const QString &version, QWidget *parent, const UpdateType update = UpdateIfNeeded);
-}
diff --git a/application/dialogs/NewInstanceDialog.cpp b/application/dialogs/NewInstanceDialog.cpp
index d53e1959..8180aa27 100644
--- a/application/dialogs/NewInstanceDialog.cpp
+++ b/application/dialogs/NewInstanceDialog.cpp
@@ -19,7 +19,6 @@
#include <BaseVersion.h>
#include <icons/IconList.h>
-#include <minecraft/MinecraftVersionList.h>
#include <tasks/Task.h>
#include <InstanceList.h>
@@ -32,6 +31,9 @@
#include <QFileDialog>
#include <QValidator>
+#include <meta/Index.h>
+#include <meta/VersionList.h>
+
class UrlValidator : public QValidator
{
public:
@@ -62,7 +64,25 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, QWidget *pare
resize(minimumSizeHint());
layout()->setSizeConstraint(QLayout::SetFixedSize);
- setSelectedVersion(MMC->minecraftlist()->getRecommended());
+ auto vlist = ENV.metadataIndex()->get("net.minecraft");
+ if(vlist->isLoaded())
+ {
+ setSelectedVersion(vlist->getRecommended());
+ }
+ else
+ {
+ vlist->load();
+ auto task = vlist->getLoadTask();
+ if(vlist->isLoaded())
+ {
+ setSelectedVersion(vlist->getRecommended());
+ }
+ if(task)
+ {
+ connect(task.get(), &Task::succeeded, this, &NewInstanceDialog::versionListUpdated);
+ }
+ }
+
InstIconKey = "default";
ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey));
@@ -95,6 +115,15 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, QWidget *pare
updateDialogState();
}
+void NewInstanceDialog::versionListUpdated()
+{
+ if(!m_versionSetByUser)
+ {
+ auto vlist = ENV.metadataIndex()->get("net.minecraft");
+ setSelectedVersion(vlist->getRecommended());
+ }
+}
+
NewInstanceDialog::~NewInstanceDialog()
{
delete ui;
@@ -134,7 +163,7 @@ void NewInstanceDialog::setSelectedVersion(BaseVersionPtr version)
if (m_selectedVersion)
{
- ui->versionTextBox->setText(version->name());
+ ui->versionTextBox->setText(version->descriptor());
}
else
{
@@ -192,14 +221,16 @@ BaseVersionPtr NewInstanceDialog::selectedVersion() const
void NewInstanceDialog::on_btnChangeVersion_clicked()
{
- VersionSelectDialog vselect(MMC->minecraftlist().get(), tr("Change Minecraft version"),
- this);
+ VersionSelectDialog vselect(ENV.metadataIndex()->get("net.minecraft").get(), tr("Change Minecraft version"), this);
vselect.exec();
if (vselect.result() == QDialog::Accepted)
{
BaseVersionPtr version = vselect.selectedVersion();
if (version)
+ {
+ m_versionSetByUser = true;
setSelectedVersion(version);
+ }
}
}
diff --git a/application/dialogs/NewInstanceDialog.h b/application/dialogs/NewInstanceDialog.h
index 1f7fadfb..1741dab8 100644
--- a/application/dialogs/NewInstanceDialog.h
+++ b/application/dialogs/NewInstanceDialog.h
@@ -36,8 +36,6 @@ public:
void setSelectedVersion(BaseVersionPtr version);
- void loadVersionList();
-
QString instName() const;
QString instGroup() const;
QString iconKey() const;
@@ -50,10 +48,12 @@ slots:
void on_iconButton_clicked();
void on_modpackBtn_clicked();
void on_instNameTextBox_textChanged(const QString &arg1);
+ void versionListUpdated();
private:
Ui::NewInstanceDialog *ui;
+ bool m_versionSetByUser = false;
BaseVersionPtr m_selectedVersion;
QString InstIconKey;
QString originalPlaceholderText;
diff --git a/application/main.cpp b/application/main.cpp
index fde9e10d..0f258926 100644
--- a/application/main.cpp
+++ b/application/main.cpp
@@ -38,7 +38,6 @@ int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(multimc);
Q_INIT_RESOURCE(backgrounds);
- Q_INIT_RESOURCE(versions);
Q_INIT_RESOURCE(pe_dark);
Q_INIT_RESOURCE(pe_light);
diff --git a/application/pages/VersionPage.cpp b/application/pages/VersionPage.cpp
index 8decc649..8e8c3d5f 100644
--- a/application/pages/VersionPage.cpp
+++ b/application/pages/VersionPage.cpp
@@ -36,19 +36,16 @@
#include <QUrl>
#include "minecraft/MinecraftProfile.h"
-#include "minecraft/forge/ForgeVersionList.h"
-#include "minecraft/forge/ForgeInstaller.h"
-#include "minecraft/liteloader/LiteLoaderVersionList.h"
-#include "minecraft/liteloader/LiteLoaderInstaller.h"
#include "minecraft/auth/MojangAccountList.h"
#include "minecraft/Mod.h"
-#include "minecraft/MinecraftVersion.h"
-#include "minecraft/MinecraftVersionList.h"
#include "icons/IconList.h"
#include "Exception.h"
#include "MultiMC.h"
+#include <meta/Index.h>
+#include <meta/VersionList.h>
+
class IconProxy : public QIdentityProxyModel
{
Q_OBJECT
@@ -155,14 +152,14 @@ void VersionPage::packageCurrent(const QModelIndex &current, const QModelIndex &
auto severity = patch->getProblemSeverity();
switch(severity)
{
- case PROBLEM_WARNING:
+ case ProblemSeverity::Warning:
ui->frame->setModText(tr("%1 possibly has issues.").arg(patch->getName()));
break;
- case PROBLEM_ERROR:
+ case ProblemSeverity::Error:
ui->frame->setModText(tr("%1 has issues!").arg(patch->getName()));
break;
default:
- case PROBLEM_NONE:
+ case ProblemSeverity::None:
ui->frame->clear();
return;
}
@@ -171,11 +168,11 @@ void VersionPage::packageCurrent(const QModelIndex &current, const QModelIndex &
QString problemOut;
for (auto &problem: problems)
{
- if(problem.getSeverity() == PROBLEM_ERROR)
+ if(problem.getSeverity() == ProblemSeverity::Error)
{
problemOut += tr("Error: ");
}
- else if(problem.getSeverity() == PROBLEM_WARNING)
+ else if(problem.getSeverity() == ProblemSeverity::Warning)
{
problemOut += tr("Warning: ");
}
@@ -326,8 +323,20 @@ void VersionPage::on_moveDownBtn_clicked()
void VersionPage::on_changeVersionBtn_clicked()
{
- VersionSelectDialog vselect(m_inst->versionList().get(), tr("Change Minecraft version"),
- this);
+ auto versionRow = currentRow();
+ if(versionRow == -1)
+ {
+ return;
+ }
+ auto patch = m_profile->versionPatch(versionRow);
+ auto name = patch->getName();
+ auto list = patch->getVersionList();
+ if(!list)
+ {
+ return;
+ }
+ auto uid = list->uid();
+ VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this);
if (!vselect.exec() || !vselect.selectedVersion())
return;
@@ -341,21 +350,25 @@ void VersionPage::on_changeVersionBtn_clicked()
return;
}
- if (!m_profile->isVanilla())
+ qDebug() << "Change" << uid << "to" << vselect.selectedVersion()->descriptor();
+ if(uid == "net.minecraft")
{
- auto result = CustomMessageBox::selectable(
- this, tr("Are you sure?"),
- tr("This will remove any library/version customization you did previously. "
- "This includes things like Forge install and similar."),
- QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Abort,
- QMessageBox::Abort)->exec();
-
- if (result != QMessageBox::Ok)
- return;
- m_profile->revertToVanilla();
- reloadMinecraftProfile();
+ if (!m_profile->isVanilla())
+ {
+ auto result = CustomMessageBox::selectable(
+ this, tr("Are you sure?"),
+ tr("This will remove any library/version customization you did previously. "
+ "This includes things like Forge install and similar."),
+ QMessageBox::Warning, QMessageBox::Ok | QMessageBox::Abort,
+ QMessageBox::Abort)->exec();
+
+ if (result != QMessageBox::Ok)
+ return;
+ m_profile->revertToVanilla();
+ reloadMinecraftProfile();
+ }
}
- m_inst->setIntendedVersionId(vselect.selectedVersion()->descriptor());
+ m_inst->setComponentVersion(uid, vselect.selectedVersion()->descriptor());
doUpdate();
m_container->refreshContainer();
}
@@ -377,16 +390,21 @@ int VersionPage::doUpdate()
void VersionPage::on_forgeBtn_clicked()
{
- VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
- vselect.setExactFilter(BaseVersionList::ParentGameVersionRole, m_inst->currentVersionId());
- vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") +
- m_inst->currentVersionId());
+ auto vlist = ENV.metadataIndex()->get("net.minecraftforge");
+ if(!vlist)
+ {
+ return;
+ }
+ VersionSelectDialog vselect(vlist.get(), tr("Select Forge version"), this);
+ vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_inst->currentVersionId());
+ vselect.setEmptyString(tr("No Forge versions are currently available for Minecraft ") + m_inst->currentVersionId());
vselect.setEmptyErrorString(tr("Couldn't load or download the Forge version lists!"));
if (vselect.exec() && vselect.selectedVersion())
{
- ProgressDialog dialog(this);
- dialog.execWithTask(
- ForgeInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this));
+ auto vsn = vselect.selectedVersion();
+ m_inst->setComponentVersion("net.minecraftforge", vsn->descriptor());
+ m_profile->reload();
+ // m_profile->installVersion();
preselect(m_profile->rowCount(QModelIndex())-1);
m_container->refreshContainer();
}
@@ -394,17 +412,21 @@ void VersionPage::on_forgeBtn_clicked()
void VersionPage::on_liteloaderBtn_clicked()
{
- VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"),
- this);
- vselect.setExactFilter(BaseVersionList::ParentGameVersionRole, m_inst->currentVersionId());
- vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") +
- m_inst->currentVersionId());
+ auto vlist = ENV.metadataIndex()->get("com.mumfrey.liteloader");
+ if(!vlist)
+ {
+ return;
+ }
+ VersionSelectDialog vselect(vlist.get(), tr("Select LiteLoader version"), this);
+ vselect.setExactFilter(BaseVersionList::ParentVersionRole, m_inst->currentVersionId());
+ vselect.setEmptyString(tr("No LiteLoader versions are currently available for Minecraft ") + m_inst->currentVersionId());
vselect.setEmptyErrorString(tr("Couldn't load or download the LiteLoader version lists!"));
if (vselect.exec() && vselect.selectedVersion())
{
- ProgressDialog dialog(this);
- dialog.execWithTask(
- LiteLoaderInstaller().createInstallTask(m_inst, vselect.selectedVersion(), this));
+ auto vsn = vselect.selectedVersion();
+ m_inst->setComponentVersion("com.mumfrey.liteloader", vsn->descriptor());
+ m_profile->reload();
+ // m_profile->installVersion(vselect.selectedVersion());
preselect(m_profile->rowCount(QModelIndex())-1);
m_container->refreshContainer();
}
@@ -456,8 +478,9 @@ void VersionPage::updateButtons(int row)
ui->moveDownBtn->setEnabled(patch->isMoveable());
ui->moveUpBtn->setEnabled(patch->isMoveable());
ui->changeVersionBtn->setEnabled(patch->isVersionChangeable());
- ui->editBtn->setEnabled(patch->isEditable());
- ui->customizeBtn->setEnabled(patch->isCustomizable());
+ ui->editBtn->setEnabled(patch->isCustom());
+ // FIXME: temporarily disabled, bring it back when the new format is stable and ready to replace the 'OneSix' one...
+ ui->customizeBtn->setEnabled(false); // patch->isCustomizable()
ui->revertBtn->setEnabled(patch->isRevertible());
}
}
@@ -489,20 +512,18 @@ int VersionPage::currentRow()
void VersionPage::on_customizeBtn_clicked()
{
+ // FIXME: temporarily disabled, bring it back when the new format is stable and ready to replace the 'OneSix' one...
+ return;
auto version = currentRow();
if(version == -1)
{
return;
}
- //HACK HACK remove, this is dumb
auto patch = m_profile->versionPatch(version);
- auto mc = std::dynamic_pointer_cast<MinecraftVersion>(patch);
- if(mc && mc->needsUpdate())
+ if(!patch->getVersionFile())
{
- if(!doUpdate())
- {
- return;
- }
+ // TODO: wait for the update task to finish here...
+ return;
}
if(!m_profile->customize(version))
{
@@ -535,15 +556,6 @@ void VersionPage::on_revertBtn_clicked()
{
return;
}
- auto mcraw = MMC->minecraftlist()->findVersion(m_inst->intendedVersionId());
- auto mc = std::dynamic_pointer_cast<MinecraftVersion>(mcraw);
- if(mc && mc->needsUpdate())
- {
- if(!doUpdate())
- {
- return;
- }
- }
if(!m_profile->revertToBase(version))
{
// TODO: some error box here
diff --git a/application/pages/global/WonkoPage.cpp b/application/pages/global/PackagesPage.cpp
index 1a72b18d..e15ddbab 100644
--- a/application/pages/global/WonkoPage.cpp
+++ b/application/pages/global/PackagesPage.cpp
@@ -13,8 +13,8 @@
* limitations under the License.
*/
-#include "WonkoPage.h"
-#include "ui_WonkoPage.h"
+#include "PackagesPage.h"
+#include "ui_PackagesPage.h"
#include <QDateTime>
#include <QSortFilterProxyModel>
@@ -23,33 +23,33 @@
#include "dialogs/ProgressDialog.h"
#include "VersionProxyModel.h"
-#include "wonko/WonkoIndex.h"
-#include "wonko/WonkoVersionList.h"
-#include "wonko/WonkoVersion.h"
+#include "meta/Index.h"
+#include "meta/VersionList.h"
+#include "meta/Version.h"
#include "Env.h"
#include "MultiMC.h"
-static QString formatRequires(const WonkoVersionPtr &version)
+using namespace Meta;
+
+static QString formatRequires(const VersionPtr &version)
{
QStringList lines;
- for (const WonkoReference &ref : version->requires())
+ auto & reqs = version->requires();
+ auto iter = reqs.begin();
+ while (iter != reqs.end())
{
- const QString readable = ENV.wonkoIndex()->hasUid(ref.uid()) ? ENV.wonkoIndex()->getList(ref.uid())->humanReadable() : ref.uid();
- if (ref.version().isEmpty())
- {
- lines.append(readable);
- }
- else
- {
- lines.append(QString("%1 (%2)").arg(readable, ref.version()));
- }
+ auto &uid = iter.key();
+ auto &version = iter.value();
+ const QString readable = ENV.metadataIndex()->hasUid(uid) ? ENV.metadataIndex()->get(uid)->humanReadable() : uid;
+ lines.append(QString("%1 (%2)").arg(readable, version));
+ iter++;
}
return lines.join('\n');
}
-WonkoPage::WonkoPage(QWidget *parent) :
+PackagesPage::PackagesPage(QWidget *parent) :
QWidget(parent),
- ui(new Ui::WonkoPage)
+ ui(new Ui::PackagesPage)
{
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
@@ -61,11 +61,11 @@ WonkoPage::WonkoPage(QWidget *parent) :
m_fileProxy->setFilterRole(Qt::DisplayRole);
m_fileProxy->setFilterKeyColumn(0);
m_fileProxy->sort(0);
- m_fileProxy->setSourceModel(ENV.wonkoIndex().get());
+ m_fileProxy->setSourceModel(ENV.metadataIndex().get());
ui->indexView->setModel(m_fileProxy);
m_filterProxy = new QSortFilterProxyModel(this);
- m_filterProxy->setSortRole(WonkoVersionList::SortRole);
+ m_filterProxy->setSortRole(VersionList::SortRole);
m_filterProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_filterProxy->setFilterRole(Qt::DisplayRole);
m_filterProxy->setFilterKeyColumn(0);
@@ -75,48 +75,48 @@ WonkoPage::WonkoPage(QWidget *parent) :
m_versionProxy = new VersionProxyModel(this);
m_filterProxy->setSourceModel(m_versionProxy);
- connect(ui->indexView->selectionModel(), &QItemSelectionModel::currentChanged, this, &WonkoPage::updateCurrentVersionList);
- connect(ui->versionsView->selectionModel(), &QItemSelectionModel::currentChanged, this, &WonkoPage::updateVersion);
- connect(m_filterProxy, &QSortFilterProxyModel::dataChanged, this, &WonkoPage::versionListDataChanged);
+ connect(ui->indexView->selectionModel(), &QItemSelectionModel::currentChanged, this, &PackagesPage::updateCurrentVersionList);
+ connect(ui->versionsView->selectionModel(), &QItemSelectionModel::currentChanged, this, &PackagesPage::updateVersion);
+ connect(m_filterProxy, &QSortFilterProxyModel::dataChanged, this, &PackagesPage::versionListDataChanged);
updateCurrentVersionList(QModelIndex());
updateVersion();
}
-WonkoPage::~WonkoPage()
+PackagesPage::~PackagesPage()
{
delete ui;
}
-QIcon WonkoPage::icon() const
+QIcon PackagesPage::icon() const
{
- return MMC->getThemedIcon("looney");
+ return MMC->getThemedIcon("packages");
}
-void WonkoPage::on_refreshIndexBtn_clicked()
+void PackagesPage::on_refreshIndexBtn_clicked()
{
- ProgressDialog(this).execWithTask(ENV.wonkoIndex()->remoteUpdateTask());
+ ENV.metadataIndex()->load();
}
-void WonkoPage::on_refreshFileBtn_clicked()
+void PackagesPage::on_refreshFileBtn_clicked()
{
- WonkoVersionListPtr list = ui->indexView->currentIndex().data(WonkoIndex::ListPtrRole).value<WonkoVersionListPtr>();
+ VersionListPtr list = ui->indexView->currentIndex().data(Index::ListPtrRole).value<VersionListPtr>();
if (!list)
{
return;
}
- ProgressDialog(this).execWithTask(list->remoteUpdateTask());
+ list->load();
}
-void WonkoPage::on_refreshVersionBtn_clicked()
+void PackagesPage::on_refreshVersionBtn_clicked()
{
- WonkoVersionPtr version = ui->versionsView->currentIndex().data(WonkoVersionList::WonkoVersionPtrRole).value<WonkoVersionPtr>();
+ VersionPtr version = ui->versionsView->currentIndex().data(VersionList::VersionPtrRole).value<VersionPtr>();
if (!version)
{
return;
}
- ProgressDialog(this).execWithTask(version->remoteUpdateTask());
+ version->load();
}
-void WonkoPage::on_fileSearchEdit_textChanged(const QString &search)
+void PackagesPage::on_fileSearchEdit_textChanged(const QString &search)
{
if (search.isEmpty())
{
@@ -129,7 +129,7 @@ void WonkoPage::on_fileSearchEdit_textChanged(const QString &search)
m_fileProxy->setFilterRegExp(".*" + parts.join(".*") + ".*");
}
}
-void WonkoPage::on_versionSearchEdit_textChanged(const QString &search)
+void PackagesPage::on_versionSearchEdit_textChanged(const QString &search)
{
if (search.isEmpty())
{
@@ -143,11 +143,11 @@ void WonkoPage::on_versionSearchEdit_textChanged(const QString &search)
}
}
-void WonkoPage::updateCurrentVersionList(const QModelIndex &index)
+void PackagesPage::updateCurrentVersionList(const QModelIndex &index)
{
if (index.isValid())
{
- WonkoVersionListPtr list = index.data(WonkoIndex::ListPtrRole).value<WonkoVersionListPtr>();
+ VersionListPtr list = index.data(Index::ListPtrRole).value<VersionListPtr>();
ui->versionsBox->setEnabled(true);
ui->refreshFileBtn->setEnabled(true);
ui->fileUidLabel->setEnabled(true);
@@ -156,19 +156,7 @@ void WonkoPage::updateCurrentVersionList(const QModelIndex &index)
ui->fileName->setText(list->name());
m_versionProxy->setSourceModel(list.get());
ui->refreshFileBtn->setText(tr("Refresh %1").arg(list->humanReadable()));
-
- if (!list->isLocalLoaded())
- {
- std::unique_ptr<Task> task = list->localUpdateTask();
- connect(task.get(), &Task::finished, this, [this, list]()
- {
- if (list->count() == 0 && !list->isRemoteLoaded())
- {
- ProgressDialog(this).execWithTask(list->remoteUpdateTask());
- }
- });
- ProgressDialog(this).execWithTask(task);
- }
+ list->load();
}
else
{
@@ -179,11 +167,11 @@ void WonkoPage::updateCurrentVersionList(const QModelIndex &index)
ui->fileNameLabel->setEnabled(false);
ui->fileName->clear();
m_versionProxy->setSourceModel(nullptr);
- ui->refreshFileBtn->setText(tr("Refresh ___"));
+ ui->refreshFileBtn->setText(tr("Refresh"));
}
}
-void WonkoPage::versionListDataChanged(const QModelIndex &tl, const QModelIndex &br)
+void PackagesPage::versionListDataChanged(const QModelIndex &tl, const QModelIndex &br)
{
if (QItemSelection(tl, br).contains(ui->versionsView->currentIndex()))
{
@@ -191,10 +179,10 @@ void WonkoPage::versionListDataChanged(const QModelIndex &tl, const QModelIndex
}
}
-void WonkoPage::updateVersion()
+void PackagesPage::updateVersion()
{
- WonkoVersionPtr version = std::dynamic_pointer_cast<WonkoVersion>(
- ui->versionsView->currentIndex().data(WonkoVersionList::VersionPointerRole).value<BaseVersionPtr>());
+ VersionPtr version = std::dynamic_pointer_cast<Version>(
+ ui->versionsView->currentIndex().data(VersionList::VersionPointerRole).value<BaseVersionPtr>());
if (version)
{
ui->refreshVersionBtn->setEnabled(true);
@@ -219,22 +207,11 @@ void WonkoPage::updateVersion()
ui->versionType->clear();
ui->versionRequiresLabel->setEnabled(false);
ui->versionRequires->clear();
- ui->refreshVersionBtn->setText(tr("Refresh ___"));
+ ui->refreshVersionBtn->setText(tr("Refresh"));
}
}
-void WonkoPage::opened()
+void PackagesPage::opened()
{
- if (!ENV.wonkoIndex()->isLocalLoaded())
- {
- std::unique_ptr<Task> task = ENV.wonkoIndex()->localUpdateTask();
- connect(task.get(), &Task::finished, this, [this]()
- {
- if (!ENV.wonkoIndex()->isRemoteLoaded())
- {
- ProgressDialog(this).execWithTask(ENV.wonkoIndex()->remoteUpdateTask());
- }
- });
- ProgressDialog(this).execWithTask(task);
- }
+ ENV.metadataIndex()->load();
}
diff --git a/application/pages/global/WonkoPage.h b/application/pages/global/PackagesPage.h
index 1d576c15..80c2886d 100644
--- a/application/pages/global/WonkoPage.h
+++ b/application/pages/global/PackagesPage.h
@@ -20,21 +20,21 @@
#include "pages/BasePage.h"
namespace Ui {
-class WonkoPage;
+class PackagesPage;
}
class QSortFilterProxyModel;
class VersionProxyModel;
-class WonkoPage : public QWidget, public BasePage
+class PackagesPage : public QWidget, public BasePage
{
Q_OBJECT
public:
- explicit WonkoPage(QWidget *parent = 0);
- ~WonkoPage();
+ explicit PackagesPage(QWidget *parent = 0);
+ ~PackagesPage();
- QString id() const override { return "wonko-global"; }
- QString displayName() const override { return tr("Wonko"); }
+ QString id() const override { return "packages-global"; }
+ QString displayName() const override { return tr("Packages"); }
QIcon icon() const override;
void opened() override;
@@ -48,7 +48,7 @@ private slots:
void versionListDataChanged(const QModelIndex &tl, const QModelIndex &br);
private:
- Ui::WonkoPage *ui;
+ Ui::PackagesPage *ui;
QSortFilterProxyModel *m_fileProxy;
QSortFilterProxyModel *m_filterProxy;
VersionProxyModel *m_versionProxy;
diff --git a/application/pages/global/WonkoPage.ui b/application/pages/global/PackagesPage.ui
index 2d14ceca..158bf1b4 100644
--- a/application/pages/global/WonkoPage.ui
+++ b/application/pages/global/PackagesPage.ui
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>WonkoPage</class>
- <widget class="QWidget" name="WonkoPage">
+ <class>PackagesPage</class>
+ <widget class="QWidget" name="PackagesPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>640</width>
- <height>480</height>
+ <width>636</width>
+ <height>621</height>
</rect>
</property>
<property name="windowTitle">
@@ -67,7 +67,7 @@
<item>
<widget class="QPushButton" name="refreshVersionBtn">
<property name="text">
- <string>Refresh ___</string>
+ <string>Refresh</string>
</property>
</widget>
</item>
@@ -180,7 +180,7 @@
<item>
<widget class="QPushButton" name="refreshFileBtn">
<property name="text">
- <string>Refresh ___</string>
+ <string>Refresh</string>
</property>
</widget>
</item>
diff --git a/application/resources/versions/LWJGL/2.9.0.json b/application/resources/versions/LWJGL/2.9.0.json
deleted file mode 100644
index 5dbd624e..00000000
--- a/application/resources/versions/LWJGL/2.9.0.json
+++ /dev/null
@@ -1,45 +0,0 @@
- {
- "fileId": "org.lwjgl",
- "name": "LWJGL",
- "version": "2.9.0",
- "+libraries": [
- {
- "name": "net.java.jinput:jinput:2.0.5"
- },
- {
- "name": "net.java.jinput:jinput-platform:2.0.5",
- "natives": {
- "linux": "natives-linux",
- "windows": "natives-windows",
- "osx": "natives-osx"
- },
- "extract": {
- "exclude": [
- "META-INF/"
- ]
- }
- },
- {
- "name": "net.java.jutils:jutils:1.0.0"
- },
- {
- "name": "org.lwjgl.lwjgl:lwjgl:2.9.0"
- },
- {
- "name": "org.lwjgl.lwjgl:lwjgl_util:2.9.0"
- },
- {
- "name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.0",
- "natives": {
- "linux": "natives-linux",
- "windows": "natives-windows",
- "osx": "natives-osx"
- },
- "extract": {
- "exclude": [
- "META-INF/"
- ]
- }
- }
- ]
-}
diff --git a/application/resources/versions/LWJGL/2.9.1-nightly-20130708-debug3.json b/application/resources/versions/LWJGL/2.9.1-nightly-20130708-debug3.json
deleted file mode 100644
index 7265b3b0..00000000
--- a/application/resources/versions/LWJGL/2.9.1-nightly-20130708-debug3.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "fileId": "org.lwjgl",
- "name": "LWJGL",
- "version": "2.9.1-nightly-20130708-debug3",
- "+libraries": [
- {
- "name": "net.java.jinput:jinput:2.0.5"
- },
- {
- "name": "net.java.jinput:jinput-platform:2.0.5",
- "natives": {
- "linux": "natives-linux",
- "windows": "natives-windows",
- "osx": "natives-osx"
- },
- "extract": {
- "exclude": [
- "META-INF/"
- ]
- }
- },
- {
- "name": "net.java.jutils:jutils:1.0.0"
- },
- {
- "name": "org.lwjgl.lwjgl:lwjgl:2.9.1-nightly-20130708-debug3"
- },
- {
- "name": "org.lwjgl.lwjgl:lwjgl_util:2.9.1-nightly-20130708-debug3"
- },
- {
- "name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.1-nightly-20130708-debug3",
- "natives": {
- "linux": "natives-linux",
- "windows": "natives-windows",
- "osx": "natives-osx"
- },
- "extract": {
- "exclude": [
- "META-INF/"
- ]
- }
- }
- ]
-}
diff --git a/application/resources/versions/LWJGL/2.9.1.json b/application/resources/versions/LWJGL/2.9.1.json
deleted file mode 100644
index e7f5e947..00000000
--- a/application/resources/versions/LWJGL/2.9.1.json
+++ /dev/null
@@ -1,45 +0,0 @@
- {
- "fileId": "org.lwjgl",
- "name": "LWJGL",
- "version": "2.9.1",
- "+libraries": [
- {
- "name": "net.java.jinput:jinput:2.0.5"
- },
- {
- "name": "net.java.jinput:jinput-platform:2.0.5",
- "natives": {
- "linux": "natives-linux",
- "windows": "natives-windows",
- "osx": "natives-osx"
- },
- "extract": {
- "exclude": [
- "META-INF/"
- ]
- }
- },
- {
- "name": "net.java.jutils:jutils:1.0.0"
- },
- {
- "name": "org.lwjgl.lwjgl:lwjgl:2.9.1"
- },
- {
- "name": "org.lwjgl.lwjgl:lwjgl_util:2.9.1"
- },
- {
- "name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.1",
- "natives": {
- "linux": "natives-linux",
- "windows": "natives-windows",
- "osx": "natives-osx"
- },
- "extract": {
- "exclude": [
- "META-INF/"
- ]
- }
- }
- ]
-}
diff --git a/application/resources/versions/LWJGL/2.9.2-nightly-20140822.json b/application/resources/versions/LWJGL/2.9.2-nightly-20140822.json
deleted file mode 100644
index 25b22eb9..00000000
--- a/application/resources/versions/LWJGL/2.9.2-nightly-20140822.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "fileId": "org.lwjgl",
- "name": "LWJGL",
- "version": "2.9.2-nightly-20140822",
- "+libraries": [
- {
- "name": "net.java.jinput:jinput:2.0.5"
- },
- {
- "name": "net.java.jinput:jinput-platform:2.0.5",
- "natives": {
- "linux": "natives-linux",
- "windows": "natives-windows",
- "osx": "natives-osx"
- },
- "extract": {
- "exclude": [
- "META-INF/"
- ]
- }
- },
- {
- "name": "net.java.jutils:jutils:1.0.0"
- },
- {
- "name": "org.lwjgl.lwjgl:lwjgl:2.9.2-nightly-20140822"
- },
- {
- "name": "org.lwjgl.lwjgl:lwjgl_util:2.9.2-nightly-20140822"
- },
- {
- "name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.2-nightly-20140822",
- "natives": {
- "linux": "natives-linux",
- "windows": "natives-windows",
- "osx": "natives-osx"
- },
- "extract": {
- "exclude": [
- "META-INF/"
- ]
- }
- }
- ]
-}
diff --git a/application/resources/versions/minecraft.json b/application/resources/versions/minecraft.json
deleted file mode 100644
index 9c08a83f..00000000
--- a/application/resources/versions/minecraft.json
+++ /dev/null
@@ -1,587 +0,0 @@
-{
-"versions": [
- {
- "id": "1.5.2",
- "checksum": "6897c3287fb971c9f362eb3ab20f5ddd",
- "releaseTime": "2013-04-25T17:45:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.5.1",
- "checksum": "5c1219d869b87d233de3033688ec7567",
- "releaseTime": "2013-03-20T12:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.5",
- "checksum": "fd11cbc5b01aae1d62cff0145171f3d9",
- "releaseTime": "2013-03-07T00:00:00+02:00",
- "type": "snapshot",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.4.7",
- "checksum": "8e80fb01b321c6b3c7efca397a3eea35",
- "releaseTime": "2012-12-28T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.4.6",
- "checksum": "48677dc4c2b98c29918722b5ab27b4fd",
- "releaseTime": "2012-12-20T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.4.5",
- "checksum": "b15e2b2b6b4629f0d99a95b6b44412a0",
- "releaseTime": "2012-11-20T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.4.4",
- "checksum": "7aa46c8058cba2f38e9d2ddddcc77c72",
- "releaseTime": "2012-11-14T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.4.3",
- "checksum": "9cc3295931edb6339f22989fe1b612a6",
- "releaseTime": "2012-11-01T00:00:00+02:00",
- "type": "snapshot",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.4.2",
- "checksum": "771175c01778ea67395bc6919a5a9dc5",
- "releaseTime": "2012-10-25T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.4.1",
- "checksum": "542621a5298659dc65f383f35170fc4c",
- "releaseTime": "2012-10-23T00:00:00+02:00",
- "type": "snapshot",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.4",
- "checksum": "32a654388b54d3e4bb29c1a46e7d6a12",
- "releaseTime": "2012-10-19T00:00:00+02:00",
- "type": "snapshot",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.3.2",
- "checksum": "969699f13e5bbe7f12e40ac4f32b7d9a",
- "releaseTime": "2012-08-16T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.3.1",
- "checksum": "266ccbc9798afd2eadf3d6c01b4c562a",
- "releaseTime": "2012-08-01T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.3",
- "checksum": "a6effac1eaccf5d429aae340cf95ed5d",
- "releaseTime": "2012-07-26T00:00:00+02:00",
- "type": "snapshot",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.2.5",
- "checksum": "8e8778078a175a33603a585257f28563",
- "releaseTime": "2012-03-30T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.2.4",
- "checksum": "25423eab6d8707f96cc6ad8a21a7250a",
- "releaseTime": "2012-03-22T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.2.3",
- "checksum": "12f6c4b1bdcc63f029e3c088a364b8e4",
- "releaseTime": "2012-03-02T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.2.2",
- "checksum": "6189e96efaea11e5164b4a4755574324",
- "releaseTime": "2012-03-01T00:00:01+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.2.1",
- "checksum": "97067a603eba2b6eb75d3194f81f6bcd",
- "releaseTime": "2012-03-01T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.1",
- "checksum": "e92302d2acdba7c97e0d8df1e10d2006",
- "releaseTime": "2012-01-12T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "1.0",
- "checksum": "3820d222b95d0b8c520d9596a756a6e6",
- "releaseTime": "2011-11-18T00:00:00+02:00",
- "type": "release",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.8.1",
- "checksum": "f8c5a2ccd3bc996792bbe436d8cc08bc",
- "releaseTime": "2011-09-19T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.8",
- "checksum": "a59a9fd4c726a573b0a2bdd10d857f59",
- "releaseTime": "2011-09-15T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.7.3",
- "checksum": "eae3353fdaa7e10a59b4cb5b45bfa10d",
- "releaseTime": "2011-07-08T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.7.2",
- "checksum": "dd9215ab1141170d4871f42bff4ab302",
- "releaseTime": "2011-07-01T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.7",
- "checksum": "682419e9ed1a236c3067822d53cda1e4",
- "releaseTime": "2011-06-30T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.6.6",
- "checksum": "ce80072464433cd5b05d505aa8ff29d1",
- "releaseTime": "2011-05-31T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.6.5",
- "checksum": "2aba888864b32038c8d22ee5df71b7c8",
- "releaseTime": "2011-05-28T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.6.4",
- "checksum": "5c4df6f120336f113180698613853dba",
- "releaseTime": "2011-05-26T00:00:04+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.6.3",
- "checksum": "efc2becca965e4f8feb5b4210c6a4fd1",
- "releaseTime": "2011-05-26T00:00:03+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.6.2",
- "checksum": "01330b1c930102a683a4dd8d792e632e",
- "releaseTime": "2011-05-26T00:00:02+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.6.1",
- "checksum": "a7e82c441a57ef4068c533f4d777336a",
- "releaseTime": "2011-05-26T00:00:01+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.6",
- "checksum": "d531e221227a65392259d3141893280d",
- "releaseTime": "2011-05-26T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.5_01",
- "checksum": "d02fa9998e30693d8d989d5f88cf0040",
- "releaseTime": "2011-04-20T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.5",
- "checksum": "24289130902822d73f8722b52bc07cdb",
- "releaseTime": "2011-04-19T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.4_01",
- "checksum": "9379e54b581ba4ef3acc3e326e87db91",
- "releaseTime": "2011-04-05T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.4",
- "checksum": "71e64b61175b371ed148b385f2d14ebf",
- "releaseTime": "2011-03-31T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.3_01",
- "checksum": "4203826f35e1036f089919032c3d19d1",
- "releaseTime": "2011-02-23T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.3b",
- "checksum": "de2164df461d028229ed2e101181bbd4",
- "releaseTime": "2011-02-22T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.2_02",
- "checksum": "1736c5ba4f63a981220c2a18a4120180",
- "releaseTime": "2011-01-21T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.2_01",
- "checksum": "486d83ec00554b45ffa21af2faa0116a",
- "releaseTime": "2011-01-14T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.2",
- "checksum": "6426223efe23c3931a4ef89685be3349",
- "releaseTime": "2011-01-13T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.1_02",
- "checksum": "7d547e495a770c62054ef136add43034",
- "releaseTime": "2010-12-22T00:00:01+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.1_01",
- "checksum": "1f9331f2bfca81b6ce2acdfc1f105837",
- "releaseTime": "2010-12-22T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.0.2",
- "checksum": "d200c465b8c167cc8df6537531fc9a48",
- "releaseTime": "2010-12-21T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.0_01",
- "checksum": "03bd20b870dbbd121de5dca98af4e1ce",
- "releaseTime": "2010-12-20T00:00:01+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "b1.0",
- "checksum": "5f8733dbbf09b4e7c874661a3c29c239",
- "releaseTime": "2010-12-20T00:00:00+02:00",
- "type": "old_beta",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "a1.2.6",
- "checksum": "ddd5e39467f28d1ea1a03b4d9e790867",
- "releaseTime": "2010-12-03T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "a1.2.5",
- "checksum": "7d3a43037190970ff2e11153b5718b74",
- "releaseTime": "2010-12-01T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "a1.2.4_01",
- "checksum": "0a1cc8c668faa6dc93fc418e8b4b097a",
- "releaseTime": "2010-11-30T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "a1.2.3_04",
- "checksum": "b2c25a753c82a1cd228ce71469829dc1",
- "releaseTime": "2010-11-26T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "a1.2.3_02",
- "checksum": "3ad4808ef2ac3b65d10305315260da03",
- "releaseTime": "2010-11-25T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "a1.2.3_01",
- "checksum": "70cbab762b17c5b11fefea9b12564119",
- "releaseTime": "2010-11-24T00:00:01+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "a1.2.3",
- "checksum": "25f053114e34b915e675f82d58f08711",
- "releaseTime": "2010-11-24T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "a1.2.2b",
- "checksum": "6250fb17f8898c4d970d6bd03c229177",
- "releaseTime": "2010-11-10T00:00:01+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "a1.2.2a",
- "checksum": "0f9fe018b344fd9dd849005f9bdca803",
- "releaseTime": "2010-11-10T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "texturepacks"]
- },
- {
- "id": "a1.2.1_01",
- "checksum": "0a496e44a7b4e2f493b5893d8e5845bd",
- "releaseTime": "2010-11-05T00:00:01+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.2.1",
- "checksum": "0a496e44a7b4e2f493b5893d8e5845bd",
- "releaseTime": "2010-11-05T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.2.0_02",
- "checksum": "f5bcb4d0c0e78bc220f164b89ae9bd60",
- "releaseTime": "2010-11-04T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.2.0_01",
- "checksum": "b2e9333e967cb89488884c2e5c715d4f",
- "releaseTime": "2010-10-31T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.2.0",
- "checksum": "44c384dae02390f700458b95d82c3e2a",
- "releaseTime": "2010-10-30T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.1.2_01",
- "checksum": "94346e1b8f6ad0e4a284314f0e29207b",
- "releaseTime": "2010-09-23T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.1.2",
- "checksum": "72ba1f834327805cb44164a42b331522",
- "releaseTime": "2010-09-20T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.1.0",
- "checksum": "891fd93e04f5daaf35d73c58e45c01b1",
- "releaseTime": "2010-09-13T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.0.17_04",
- "checksum": "16ed7dc58244772847991e504afcf02f",
- "releaseTime": "2010-08-23T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.0.17_02",
- "checksum": "d89760b0871ef61a55c9f336c0439d58",
- "releaseTime": "2010-08-20T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.0.16",
- "checksum": "6bbde02c13aed5766275f4398ede6aae",
- "releaseTime": "2010-08-12T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.0.15",
- "checksum": "ade257d2080d56fa983763f9c701fa14",
- "releaseTime": "2010-08-04T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.0.14",
- "checksum": "227d0c6fa896a231de6269a074c9a458",
- "releaseTime": "2010-07-30T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.0.11",
- "checksum": "6f1b1dd157fa0df39760f5be3eab01b0",
- "releaseTime": "2010-07-23T00:00:00+02:00",
- "type": "old_alpha",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.0.5_01",
- "checksum": "ae5f606caa18222e7568819c910ee423",
- "releaseTime": "2010-07-13T00:00:00+02:00",
- "type": "old_alpha",
- "mainClass": "y",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "a1.0.4",
- "checksum": "13ce7935c3670e7494e26b2704bfa3e9",
- "releaseTime": "2010-07-09T00:00:00+02:00",
- "type": "old_alpha",
- "mainClass": "ax",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "inf-20100618",
- "checksum": "f5f5aa34760facc10486e906a7c60196",
- "releaseTime": "2010-06-16T00:00:00+02:00",
- "type": "old_alpha",
- "mainClass": "net.minecraft.client.d",
- "appletClass": "net.minecraft.client.MinecraftApplet",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "c0.30_01c",
- "checksum": "fcfd7f83a6b27503cf48202381a5adf2",
- "releaseTime": "2009-12-22T00:00:00+02:00",
- "type": "old_alpha",
- "mainClass": "com.mojang.minecraft.l",
- "appletClass": "com.mojang.minecraft.MinecraftApplet",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "c0.0.13a_03",
- "checksum": "a9527cb5aef198e0f53e235ebe13dc75",
- "releaseTime": "2009-05-22T00:00:00+02:00",
- "type": "old_alpha",
- "mainClass": "com.mojang.minecraft.c",
- "appletClass": "com.mojang.minecraft.MinecraftApplet",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "c0.0.13a",
- "checksum": "3617fbf5fbfd2b837ebf5ceb63584908",
- "releaseTime": "2009-05-31T00:00:00+02:00",
- "type": "old_alpha",
- "mainClass": "com.mojang.minecraft.Minecraft",
- "appletClass": "com.mojang.minecraft.MinecraftApplet",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "c0.0.11a",
- "checksum": "a6e03c2eaf74709facc0d2477648e999",
- "releaseTime": "2009-05-17T00:00:00+02:00",
- "type": "old_alpha",
- "mainClass": "com.mojang.minecraft.Minecraft",
- "appletClass": "com.mojang.minecraft.MinecraftApplet",
- "+traits": ["legacyLaunch", "no-texturepacks"]
- },
- {
- "id": "rd-161348",
- "checksum": "80882b8936a5c8d91500838a6660b504",
- "releaseTime": "2009-05-16T13:48:00+02:00",
- "type": "old_alpha",
- "mainClass": "com.mojang.minecraft.RubyDung",
- "+traits": ["no-texturepacks"]
- },
- {
- "id": "rd-160052",
- "checksum": "24c5cc99a2a612697ed2f7d5d04242fe",
- "releaseTime": "2009-05-16T00:52:00+02:00",
- "type": "old_alpha",
- "mainClass": "com.mojang.rubydung.RubyDung",
- "+traits": ["no-texturepacks"]
- },
- {
- "id": "rd-132328",
- "checksum": "70e33a81c541b13a477e68c1207124eb",
- "releaseTime": "2009-05-13T23:28:00+02:00",
- "type": "old_alpha",
- "mainClass": "com.mojang.rubydung.RubyDung",
- "+traits": ["no-texturepacks"]
- },
- {
- "id": "rd-132211",
- "checksum": "99fdaea10c494b9c3c3254636b98b799",
- "releaseTime": "2009-05-13T22:11:00+02:00",
- "type": "old_alpha",
- "mainClass": "com.mojang.rubydung.RubyDung",
- "+traits": ["no-texturepacks"]
- }
-]
-}
diff --git a/application/resources/versions/versions.qrc b/application/resources/versions/versions.qrc
deleted file mode 100644
index e9621e97..00000000
--- a/application/resources/versions/versions.qrc
+++ /dev/null
@@ -1,12 +0,0 @@
-<!DOCTYPE RCC>
-<RCC version="1.0">
- <qresource prefix="/versions">
- <!-- builtin legacy versions -->
- <file>minecraft.json</file>
- <!-- LWJGL -->
- <file>LWJGL/2.9.0.json</file>
- <file>LWJGL/2.9.1-nightly-20130708-debug3.json</file>
- <file>LWJGL/2.9.1.json</file>
- <file>LWJGL/2.9.2-nightly-20140822.json</file>
- </qresource>
-</RCC>
diff --git a/application/widgets/VersionSelectWidget.cpp b/application/widgets/VersionSelectWidget.cpp
index 18284a91..1696d9d1 100644
--- a/application/widgets/VersionSelectWidget.cpp
+++ b/application/widgets/VersionSelectWidget.cpp
@@ -80,52 +80,42 @@ void VersionSelectWidget::initialize()
void VersionSelectWidget::closeEvent(QCloseEvent * event)
{
- if(loadTask)
- {
- loadTask->abort();
- loadTask->deleteLater();
- loadTask = nullptr;
- }
QWidget::closeEvent(event);
}
void VersionSelectWidget::loadList()
{
- if(loadTask)
+ auto newTask = m_vlist->getLoadTask();
+ if (!newTask)
{
return;
}
- loadTask = m_vlist->getLoadTask();
- if (!loadTask)
+ loadTask = newTask.get();
+ connect(loadTask, &Task::succeeded, this, &VersionSelectWidget::onTaskSucceeded);
+ connect(loadTask, &Task::failed, this, &VersionSelectWidget::onTaskFailed);
+ connect(loadTask, &Task::progress, this, &VersionSelectWidget::changeProgress);
+ if(!loadTask->isRunning())
{
- return;
+ loadTask->start();
}
- connect(loadTask, &Task::finished, this, &VersionSelectWidget::onTaskFinished);
- connect(loadTask, &Task::progress, this, &VersionSelectWidget::changeProgress);
- loadTask->start();
sneakyProgressBar->setHidden(false);
}
-void VersionSelectWidget::onTaskFinished()
+void VersionSelectWidget::onTaskSucceeded()
{
- if (!loadTask->successful())
- {
- CustomMessageBox::selectable(this, tr("Error"),
- tr("List update failed:\n%1").arg(loadTask->failReason()),
- QMessageBox::Warning)->show();
- if (m_proxyModel->rowCount() == 0)
- {
- listView->setEmptyMode(VersionListView::ErrorString);
- }
- }
- else if (m_proxyModel->rowCount() == 0)
+ if (m_proxyModel->rowCount() == 0)
{
listView->setEmptyMode(VersionListView::String);
}
sneakyProgressBar->setHidden(true);
- loadTask->deleteLater();
- loadTask = nullptr;
preselect();
+ loadTask = nullptr;
+}
+
+void VersionSelectWidget::onTaskFailed(const QString& reason)
+{
+ CustomMessageBox::selectable(this, tr("Error"), tr("List update failed:\n%1").arg(reason), QMessageBox::Warning)->show();
+ onTaskSucceeded();
}
void VersionSelectWidget::changeProgress(qint64 current, qint64 total)
@@ -178,4 +168,4 @@ void VersionSelectWidget::setExactFilter(BaseVersionList::ModelRoles role, QStri
void VersionSelectWidget::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter)
{
m_proxyModel->setFilter(role, filter, false);
-} \ No newline at end of file
+}
diff --git a/application/widgets/VersionSelectWidget.h b/application/widgets/VersionSelectWidget.h
index 0fc9f2e6..66e512ac 100644
--- a/application/widgets/VersionSelectWidget.h
+++ b/application/widgets/VersionSelectWidget.h
@@ -55,7 +55,8 @@ protected:
virtual void closeEvent ( QCloseEvent* );
private slots:
- void onTaskFinished();
+ void onTaskSucceeded();
+ void onTaskFailed(const QString &reason);
void changeProgress(qint64 current, qint64 total);
void currentRowChanged(const QModelIndex &current, const QModelIndex &);
@@ -66,7 +67,7 @@ private:
BaseVersionList *m_vlist = nullptr;
VersionProxyModel *m_proxyModel = nullptr;
int resizeOnColumn = 0;
- Task * loadTask = nullptr;
+ Task * loadTask;
bool preselectedAlready = false;
private:
diff --git a/wonkoclient/CMakeLists.txt b/wonkoclient/CMakeLists.txt
deleted file mode 100644
index 381857e0..00000000
--- a/wonkoclient/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-project(wonkoclient)
-
-SET( SRC_FILES
-main.cpp
-WonkoClient.cpp
-WonkoClient.h
-)
-
-add_executable(MMCClient ${SRC_FILES})
-target_link_libraries(MMCClient MultiMC_logic)
diff --git a/wonkoclient/WonkoClient.cpp b/wonkoclient/WonkoClient.cpp
deleted file mode 100644
index a45939b3..00000000
--- a/wonkoclient/WonkoClient.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-// Created by robotbrain on 3/27/16.
-//
-
-#include <minecraft/MinecraftVersionList.h>
-#include <Env.h>
-#include <minecraft/liteloader/LiteLoaderVersionList.h>
-#include <minecraft/forge/ForgeVersionList.h>
-#include <minecraft/legacy/LwjglVersionList.h>
-#include <java/JavaInstallList.h>
-#include <settings/INISettingsObject.h>
-#include "WonkoClient.h"
-
-WonkoClient &WonkoClient::getInstance() {
- static WonkoClient instance;
- return instance;
-}
-
-void WonkoClient::registerLists() {
- ENV.initHttpMetaCache();
- auto mcList = std::make_shared<MinecraftVersionList>();
- ENV.registerVersionList("net.minecraft", mcList);
- runTask(mcList->getLoadTask());
- auto llList = std::make_shared<LiteLoaderVersionList>();
- ENV.registerVersionList("com.mumfrey.liteloader", llList);
- runTask(llList->getLoadTask());
- auto forgeList = std::make_shared<ForgeVersionList>();
- ENV.registerVersionList("net.minecraftforge", forgeList);
- runTask(forgeList->getLoadTask());
- auto lwjglList = std::make_shared<LWJGLVersionList>();
- ENV.registerVersionList("org.lwjgl.legacy", lwjglList);
- runTask(lwjglList->getLoadTask());
- auto javaList = std::make_shared<JavaInstallList>();
- ENV.registerVersionList("com.java", javaList);
-}
-
-WonkoClient::WonkoClient() {
- m_settings.reset(new INISettingsObject("multimc.cfg", this));
- m_instanceList.reset(new InstanceList(m_settings, ".", this));
-}
-
-void WonkoClient::runTask(Task *pTask) {
- if (pTask == nullptr)
- return;
- QEventLoop loop;
- QObject::connect(pTask, &Task::finished, &loop, &QEventLoop::quit);
- pTask->start();
- loop.exec();
- delete pTask;
-}
-
-void WonkoClient::initGlobalSettings()
-{
- m_settings->registerSetting("ShowConsole", true);
- m_settings->registerSetting("AutoCloseConsole", true);
- m_settings->registerSetting("LogPrePostOutput", true);
- // Window Size
- m_settings->registerSetting({"LaunchMaximized", "MCWindowMaximize"}, false);
- m_settings->registerSetting({"MinecraftWinWidth", "MCWindowWidth"}, 854);
- m_settings->registerSetting({"MinecraftWinHeight", "MCWindowHeight"}, 480);
-
- // Memory
- m_settings->registerSetting({"MinMemAlloc", "MinMemoryAlloc"}, 512);
- m_settings->registerSetting({"MaxMemAlloc", "MaxMemoryAlloc"}, 1024);
- m_settings->registerSetting("PermGen", 128);
-
- // Java Settings
- m_settings->registerSetting("JavaPath", "");
- m_settings->registerSetting("JavaTimestamp", 0);
- m_settings->registerSetting("JavaArchitecture", "");
- m_settings->registerSetting("JavaVersion", "");
- m_settings->registerSetting("LastHostname", "");
- m_settings->registerSetting("JvmArgs", "");
-
- // Wrapper command for launch
- m_settings->registerSetting("WrapperCommand", "");
-
- // Custom Commands
- m_settings->registerSetting({"PreLaunchCommand", "PreLaunchCmd"}, "");
- m_settings->registerSetting({"PostExitCommand", "PostExitCmd"}, "");
-
- // Minecraft launch method
- m_settings->registerSetting("MCLaunchMethod", "LauncherPart");
-}
diff --git a/wonkoclient/WonkoClient.h b/wonkoclient/WonkoClient.h
deleted file mode 100644
index e6b35805..00000000
--- a/wonkoclient/WonkoClient.h
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// Created by robotbrain on 3/27/16.
-//
-
-#pragma once
-
-#include <memory>
-#include <InstanceList.h>
-
-#if defined(MMCC)
-#undef MMCC
-#endif
-#define MMCC (WonkoClient::getInstance())
-
-class WonkoClient : public QObject {
-Q_OBJECT
-
-private:
- WonkoClient();
-
-public:
- static WonkoClient &getInstance();
-
- void registerLists();
- void initGlobalSettings();
-
- std::shared_ptr<InstanceList> instances() const {
- return m_instanceList;
- }
-
-private:
- std::shared_ptr<InstanceList> m_instanceList;
- std::shared_ptr<SettingsObject> m_settings;
-
- void runTask(Task *pTask);
-};
diff --git a/wonkoclient/main.cpp b/wonkoclient/main.cpp
deleted file mode 100644
index eaf92c5d..00000000
--- a/wonkoclient/main.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-// Created by robotbrain on 3/26/16.
-//
-
-#include "WonkoClient.h"
-#include <QCoreApplication>
-#include <QDebug>
-#include <QtWidgets/QInputDialog>
-#include <QtGui/QDesktopServices>
-#include <QDir>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication a(argc, argv);
- if (a.arguments().contains("-d"))
- {
- int i = a.arguments().lastIndexOf("-d") + 1;
- if (i < a.arguments().length())
- {
- QDir dir = QDir::current();
- dir.cd(a.arguments()[i]);
- QDir::setCurrent(dir.absolutePath());
- qDebug() << "Using " << dir.absolutePath();
- }
- }
- MMCC.initGlobalSettings();
- MMCC.registerLists();
- return a.exec();
-}