summaryrefslogtreecommitdiffstats
path: root/api/logic/modplatform
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2019-11-03 23:48:12 +0100
committerPetr Mrázek <peterix@gmail.com>2019-11-03 23:48:12 +0100
commit47ed2f48d4a118876263f37b9fe2ab8911c2a8fe (patch)
tree3caa2000d3fe9f57a82757dec2ae138e7474c499 /api/logic/modplatform
parent0c9340a3d2e32223a9097f95b92b11045aaec845 (diff)
downloadMultiMC-47ed2f48d4a118876263f37b9fe2ab8911c2a8fe.tar
MultiMC-47ed2f48d4a118876263f37b9fe2ab8911c2a8fe.tar.gz
MultiMC-47ed2f48d4a118876263f37b9fe2ab8911c2a8fe.tar.lz
MultiMC-47ed2f48d4a118876263f37b9fe2ab8911c2a8fe.tar.xz
MultiMC-47ed2f48d4a118876263f37b9fe2ab8911c2a8fe.zip
NOISSUE put legacy FTB support in a namespace, fix its base URL
Diffstat (limited to 'api/logic/modplatform')
-rw-r--r--api/logic/modplatform/legacy_ftb/PackFetchTask.cpp (renamed from api/logic/modplatform/ftb/FtbPackFetchTask.cpp)46
-rw-r--r--api/logic/modplatform/legacy_ftb/PackFetchTask.h (renamed from api/logic/modplatform/ftb/FtbPackFetchTask.h)20
-rw-r--r--api/logic/modplatform/legacy_ftb/PackHelpers.h (renamed from api/logic/modplatform/ftb/PackHelpers.h)16
-rw-r--r--api/logic/modplatform/legacy_ftb/PackInstallTask.cpp (renamed from api/logic/modplatform/ftb/FtbPackInstallTask.cpp)50
-rw-r--r--api/logic/modplatform/legacy_ftb/PackInstallTask.h (renamed from api/logic/modplatform/ftb/FtbPackInstallTask.h)14
-rw-r--r--api/logic/modplatform/legacy_ftb/PrivatePackManager.cpp (renamed from api/logic/modplatform/ftb/FtbPrivatePackManager.cpp)10
-rw-r--r--api/logic/modplatform/legacy_ftb/PrivatePackManager.h (renamed from api/logic/modplatform/ftb/FtbPrivatePackManager.h)8
7 files changed, 97 insertions, 67 deletions
diff --git a/api/logic/modplatform/ftb/FtbPackFetchTask.cpp b/api/logic/modplatform/legacy_ftb/PackFetchTask.cpp
index fe3f3fac..43c1e6f8 100644
--- a/api/logic/modplatform/ftb/FtbPackFetchTask.cpp
+++ b/api/logic/modplatform/legacy_ftb/PackFetchTask.cpp
@@ -1,34 +1,36 @@
-#include "FtbPackFetchTask.h"
-#include <QDomDocument>
-#include "FtbPrivatePackManager.h"
+#include "PackFetchTask.h"
+#include "PrivatePackManager.h"
+#include <QDomDocument>
#include "net/URLConstants.h"
-void FtbPackFetchTask::fetch()
+namespace LegacyFTB {
+
+void PackFetchTask::fetch()
{
publicPacks.clear();
thirdPartyPacks.clear();
- NetJob *netJob = new NetJob("FtbModpackFetch");
+ NetJob *netJob = new NetJob("LegacyFTB::ModpackFetch");
- QUrl publicPacksUrl = QUrl(URLConstants::FTB_CDN_BASE_URL + "static/modpacks.xml");
+ QUrl publicPacksUrl = QUrl(URLConstants::LEGACY_FTB_CDN_BASE_URL + "static/modpacks.xml");
qDebug() << "Downloading public version info from" << publicPacksUrl.toString();
netJob->addNetAction(Net::Download::makeByteArray(publicPacksUrl, &publicModpacksXmlFileData));
- QUrl thirdPartyUrl = QUrl(URLConstants::FTB_CDN_BASE_URL + "static/thirdparty.xml");
+ QUrl thirdPartyUrl = QUrl(URLConstants::LEGACY_FTB_CDN_BASE_URL + "static/thirdparty.xml");
qDebug() << "Downloading thirdparty version info from" << thirdPartyUrl.toString();
netJob->addNetAction(Net::Download::makeByteArray(thirdPartyUrl, &thirdPartyModpacksXmlFileData));
- QObject::connect(netJob, &NetJob::succeeded, this, &FtbPackFetchTask::fileDownloadFinished);
- QObject::connect(netJob, &NetJob::failed, this, &FtbPackFetchTask::fileDownloadFailed);
+ QObject::connect(netJob, &NetJob::succeeded, this, &PackFetchTask::fileDownloadFinished);
+ QObject::connect(netJob, &NetJob::failed, this, &PackFetchTask::fileDownloadFailed);
jobPtr.reset(netJob);
netJob->start();
}
-void FtbPackFetchTask::fetchPrivate(const QStringList & toFetch)
+void PackFetchTask::fetchPrivate(const QStringList & toFetch)
{
- QString privatePackBaseUrl = URLConstants::FTB_CDN_BASE_URL + "static/%1.xml";
+ QString privatePackBaseUrl = URLConstants::LEGACY_FTB_CDN_BASE_URL + "static/%1.xml";
for (auto &packCode: toFetch)
{
@@ -38,9 +40,9 @@ void FtbPackFetchTask::fetchPrivate(const QStringList & toFetch)
QObject::connect(job, &NetJob::succeeded, this, [this, job, data, packCode]
{
- FtbModpackList packs;
- parseAndAddPacks(*data, FtbPackType::Private, packs);
- foreach(FtbModpack currentPack, packs)
+ ModpackList packs;
+ parseAndAddPacks(*data, PackType::Private, packs);
+ foreach(Modpack currentPack, packs)
{
currentPack.packCode = packCode;
emit privateFileDownloadFinished(currentPack);
@@ -65,18 +67,18 @@ void FtbPackFetchTask::fetchPrivate(const QStringList & toFetch)
}
}
-void FtbPackFetchTask::fileDownloadFinished()
+void PackFetchTask::fileDownloadFinished()
{
jobPtr.reset();
QStringList failedLists;
- if(!parseAndAddPacks(publicModpacksXmlFileData, FtbPackType::Public, publicPacks))
+ if(!parseAndAddPacks(publicModpacksXmlFileData, PackType::Public, publicPacks))
{
failedLists.append(tr("Public Packs"));
}
- if(!parseAndAddPacks(thirdPartyModpacksXmlFileData, FtbPackType::ThirdParty, thirdPartyPacks))
+ if(!parseAndAddPacks(thirdPartyModpacksXmlFileData, PackType::ThirdParty, thirdPartyPacks))
{
failedLists.append(tr("Third Party Packs"));
}
@@ -91,7 +93,7 @@ void FtbPackFetchTask::fileDownloadFinished()
}
}
-bool FtbPackFetchTask::parseAndAddPacks(QByteArray &data, FtbPackType packType, FtbModpackList &list)
+bool PackFetchTask::parseAndAddPacks(QByteArray &data, PackType packType, ModpackList &list)
{
QDomDocument doc;
@@ -112,7 +114,7 @@ bool FtbPackFetchTask::parseAndAddPacks(QByteArray &data, FtbPackType packType,
{
QDomElement element = nodes.at(i).toElement();
- FtbModpack modpack;
+ Modpack modpack;
modpack.name = element.attribute("name");
modpack.currentVersion = element.attribute("version");
modpack.mcVersion = element.attribute("mcVersion");
@@ -161,8 +163,10 @@ bool FtbPackFetchTask::parseAndAddPacks(QByteArray &data, FtbPackType packType,
return true;
}
-void FtbPackFetchTask::fileDownloadFailed(QString reason)
+void PackFetchTask::fileDownloadFailed(QString reason)
{
- qWarning() << "Fetching FtbPacks failed:" << reason;
+ qWarning() << "Fetching FTBPacks failed:" << reason;
emit failed(reason);
}
+
+}
diff --git a/api/logic/modplatform/ftb/FtbPackFetchTask.h b/api/logic/modplatform/legacy_ftb/PackFetchTask.h
index f955fe83..4a8469b1 100644
--- a/api/logic/modplatform/ftb/FtbPackFetchTask.h
+++ b/api/logic/modplatform/legacy_ftb/PackFetchTask.h
@@ -6,13 +6,15 @@
#include <QObject>
#include "PackHelpers.h"
-class MULTIMC_LOGIC_EXPORT FtbPackFetchTask : public QObject {
+namespace LegacyFTB {
+
+class MULTIMC_LOGIC_EXPORT PackFetchTask : public QObject {
Q_OBJECT
public:
- FtbPackFetchTask() = default;
- virtual ~FtbPackFetchTask() = default;
+ PackFetchTask() = default;
+ virtual ~PackFetchTask() = default;
void fetch();
void fetchPrivate(const QStringList &toFetch);
@@ -23,18 +25,20 @@ private:
QByteArray publicModpacksXmlFileData;
QByteArray thirdPartyModpacksXmlFileData;
- bool parseAndAddPacks(QByteArray &data, FtbPackType packType, FtbModpackList &list);
- FtbModpackList publicPacks;
- FtbModpackList thirdPartyPacks;
+ bool parseAndAddPacks(QByteArray &data, PackType packType, ModpackList &list);
+ ModpackList publicPacks;
+ ModpackList thirdPartyPacks;
protected slots:
void fileDownloadFinished();
void fileDownloadFailed(QString reason);
signals:
- void finished(FtbModpackList publicPacks, FtbModpackList thirdPartyPacks);
+ void finished(ModpackList publicPacks, ModpackList thirdPartyPacks);
void failed(QString reason);
- void privateFileDownloadFinished(FtbModpack modpack);
+ void privateFileDownloadFinished(Modpack modpack);
void privateFileDownloadFailed(QString reason, QString packCode);
};
+
+}
diff --git a/api/logic/modplatform/ftb/PackHelpers.h b/api/logic/modplatform/legacy_ftb/PackHelpers.h
index 4306caee..566210d0 100644
--- a/api/logic/modplatform/ftb/PackHelpers.h
+++ b/api/logic/modplatform/legacy_ftb/PackHelpers.h
@@ -5,15 +5,17 @@
#include <QStringList>
#include <QMetaType>
+namespace LegacyFTB {
+
//Header for structs etc...
-enum class FtbPackType
+enum class PackType
{
Public,
ThirdParty,
Private
};
-struct FtbModpack
+struct Modpack
{
QString name;
QString description;
@@ -31,11 +33,13 @@ struct FtbModpack
bool bugged = false;
bool broken = false;
- FtbPackType type;
+ PackType type;
QString packCode;
};
-//We need it for the proxy model
-Q_DECLARE_METATYPE(FtbModpack)
+typedef QList<Modpack> ModpackList;
-typedef QList<FtbModpack> FtbModpackList;
+}
+
+//We need it for the proxy model
+Q_DECLARE_METATYPE(LegacyFTB::Modpack)
diff --git a/api/logic/modplatform/ftb/FtbPackInstallTask.cpp b/api/logic/modplatform/legacy_ftb/PackInstallTask.cpp
index 4962bcac..ea7e2c0c 100644
--- a/api/logic/modplatform/ftb/FtbPackInstallTask.cpp
+++ b/api/logic/modplatform/legacy_ftb/PackInstallTask.cpp
@@ -1,28 +1,32 @@
-#include "FtbPackInstallTask.h"
+#include "PackInstallTask.h"
+
#include "Env.h"
#include "MMCZip.h"
-#include "QtConcurrent"
+
#include "BaseInstance.h"
#include "FileSystem.h"
#include "settings/INISettingsObject.h"
#include "minecraft/MinecraftInstance.h"
#include "minecraft/ComponentList.h"
#include "minecraft/GradleSpecifier.h"
-
#include "net/URLConstants.h"
-FtbPackInstallTask::FtbPackInstallTask(FtbModpack pack, QString version)
+#include <QtConcurrent>
+
+namespace LegacyFTB {
+
+PackInstallTask::PackInstallTask(Modpack pack, QString version)
{
m_pack = pack;
m_version = version;
}
-void FtbPackInstallTask::executeTask()
+void PackInstallTask::executeTask()
{
downloadPack();
}
-void FtbPackInstallTask::downloadPack()
+void PackInstallTask::downloadPack()
{
setStatus(tr("Downloading zip for %1").arg(m_pack.name));
@@ -32,46 +36,46 @@ void FtbPackInstallTask::downloadPack()
entry->setStale(true);
QString url;
- if(m_pack.type == FtbPackType::Private)
+ if(m_pack.type == PackType::Private)
{
- url = QString(URLConstants::FTB_CDN_BASE_URL + "privatepacks/%1").arg(packoffset);
+ url = QString(URLConstants::LEGACY_FTB_CDN_BASE_URL + "privatepacks/%1").arg(packoffset);
}
else
{
- url = QString(URLConstants::FTB_CDN_BASE_URL + "modpacks/%1").arg(packoffset);
+ url = QString(URLConstants::LEGACY_FTB_CDN_BASE_URL + "modpacks/%1").arg(packoffset);
}
job->addNetAction(Net::Download::makeCached(url, entry));
archivePath = entry->getFullPath();
netJobContainer.reset(job);
- connect(job, &NetJob::succeeded, this, &FtbPackInstallTask::onDownloadSucceeded);
- connect(job, &NetJob::failed, this, &FtbPackInstallTask::onDownloadFailed);
- connect(job, &NetJob::progress, this, &FtbPackInstallTask::onDownloadProgress);
+ connect(job, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
+ connect(job, &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
+ connect(job, &NetJob::progress, this, &PackInstallTask::onDownloadProgress);
job->start();
progress(1, 4);
}
-void FtbPackInstallTask::onDownloadSucceeded()
+void PackInstallTask::onDownloadSucceeded()
{
abortable = false;
unzip();
}
-void FtbPackInstallTask::onDownloadFailed(QString reason)
+void PackInstallTask::onDownloadFailed(QString reason)
{
abortable = false;
emitFailed(reason);
}
-void FtbPackInstallTask::onDownloadProgress(qint64 current, qint64 total)
+void PackInstallTask::onDownloadProgress(qint64 current, qint64 total)
{
abortable = true;
progress(current, total * 4);
setStatus(tr("Downloading zip for %1 (%2%)").arg(m_pack.name).arg(current / 10));
}
-void FtbPackInstallTask::unzip()
+void PackInstallTask::unzip()
{
progress(2, 4);
setStatus(tr("Extracting modpack"));
@@ -85,22 +89,22 @@ void FtbPackInstallTask::unzip()
}
m_extractFuture = QtConcurrent::run(QThreadPool::globalInstance(), MMCZip::extractDir, archivePath, extractDir.absolutePath() + "/unzip");
- connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::finished, this, &FtbPackInstallTask::onUnzipFinished);
- connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::canceled, this, &FtbPackInstallTask::onUnzipCanceled);
+ connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::finished, this, &PackInstallTask::onUnzipFinished);
+ connect(&m_extractFutureWatcher, &QFutureWatcher<QStringList>::canceled, this, &PackInstallTask::onUnzipCanceled);
m_extractFutureWatcher.setFuture(m_extractFuture);
}
-void FtbPackInstallTask::onUnzipFinished()
+void PackInstallTask::onUnzipFinished()
{
install();
}
-void FtbPackInstallTask::onUnzipCanceled()
+void PackInstallTask::onUnzipCanceled()
{
emitAborted();
}
-void FtbPackInstallTask::install()
+void PackInstallTask::install()
{
progress(3, 4);
setStatus(tr("Installing modpack"));
@@ -197,7 +201,7 @@ void FtbPackInstallTask::install()
emitSucceeded();
}
-bool FtbPackInstallTask::abort()
+bool PackInstallTask::abort()
{
if(abortable)
{
@@ -205,3 +209,5 @@ bool FtbPackInstallTask::abort()
}
return false;
}
+
+} \ No newline at end of file
diff --git a/api/logic/modplatform/ftb/FtbPackInstallTask.h b/api/logic/modplatform/legacy_ftb/PackInstallTask.h
index 3319025e..1eec1880 100644
--- a/api/logic/modplatform/ftb/FtbPackInstallTask.h
+++ b/api/logic/modplatform/legacy_ftb/PackInstallTask.h
@@ -6,15 +6,17 @@
#include "meta/Index.h"
#include "meta/Version.h"
#include "meta/VersionList.h"
-#include "modplatform/ftb/PackHelpers.h"
+#include "PackHelpers.h"
-class MULTIMC_LOGIC_EXPORT FtbPackInstallTask : public InstanceTask
+namespace LegacyFTB {
+
+class MULTIMC_LOGIC_EXPORT PackInstallTask : public InstanceTask
{
Q_OBJECT
public:
- explicit FtbPackInstallTask(FtbModpack pack, QString version);
- virtual ~FtbPackInstallTask(){}
+ explicit PackInstallTask(Modpack pack, QString version);
+ virtual ~PackInstallTask(){}
bool abort() override;
@@ -43,6 +45,8 @@ private: /* data */
NetJobPtr netJobContainer;
QString archivePath;
- FtbModpack m_pack;
+ Modpack m_pack;
QString m_version;
};
+
+}
diff --git a/api/logic/modplatform/ftb/FtbPrivatePackManager.cpp b/api/logic/modplatform/legacy_ftb/PrivatePackManager.cpp
index c3477cec..501e6003 100644
--- a/api/logic/modplatform/ftb/FtbPrivatePackManager.cpp
+++ b/api/logic/modplatform/legacy_ftb/PrivatePackManager.cpp
@@ -1,10 +1,12 @@
-#include "FtbPrivatePackManager.h"
+#include "PrivatePackManager.h"
#include <QDebug>
#include "FileSystem.h"
-void FtbPrivatePackManager::load()
+namespace LegacyFTB {
+
+void PrivatePackManager::load()
{
try
{
@@ -18,7 +20,7 @@ void FtbPrivatePackManager::load()
}
}
-void FtbPrivatePackManager::save() const
+void PrivatePackManager::save() const
{
if(!dirty)
{
@@ -35,3 +37,5 @@ void FtbPrivatePackManager::save() const
qWarning() << "Failed to write third party FTB pack codes to" << m_filename;
}
}
+
+}
diff --git a/api/logic/modplatform/ftb/FtbPrivatePackManager.h b/api/logic/modplatform/legacy_ftb/PrivatePackManager.h
index 388224d6..0232bac7 100644
--- a/api/logic/modplatform/ftb/FtbPrivatePackManager.h
+++ b/api/logic/modplatform/legacy_ftb/PrivatePackManager.h
@@ -5,10 +5,12 @@
#include <QFile>
#include "multimc_logic_export.h"
-class MULTIMC_LOGIC_EXPORT FtbPrivatePackManager
+namespace LegacyFTB {
+
+class MULTIMC_LOGIC_EXPORT PrivatePackManager
{
public:
- ~FtbPrivatePackManager()
+ ~PrivatePackManager()
{
save();
}
@@ -38,3 +40,5 @@ private:
QString m_filename = "private_packs.txt";
mutable bool dirty = false;
};
+
+}