aboutsummaryrefslogtreecommitdiff
path: root/api/logic
diff options
context:
space:
mode:
Diffstat (limited to 'api/logic')
-rw-r--r--api/logic/CMakeLists.txt50
-rw-r--r--api/logic/Env.cpp27
-rw-r--r--api/logic/Env.h11
-rw-r--r--api/logic/meta/BaseEntity.cpp (renamed from api/logic/wonko/BaseWonkoEntity.cpp)17
-rw-r--r--api/logic/meta/BaseEntity.h (renamed from api/logic/wonko/BaseWonkoEntity.h)12
-rw-r--r--api/logic/meta/Index.cpp (renamed from api/logic/wonko/WonkoIndex.cpp)57
-rw-r--r--api/logic/meta/Index.h (renamed from api/logic/wonko/WonkoIndex.h)28
-rw-r--r--api/logic/meta/Index_test.cpp50
-rw-r--r--api/logic/meta/Reference.cpp (renamed from api/logic/wonko/WonkoReference.cpp)18
-rw-r--r--api/logic/meta/Reference.h (renamed from api/logic/wonko/WonkoReference.h)15
-rw-r--r--api/logic/meta/Util.cpp (renamed from api/logic/wonko/WonkoUtil.cpp)13
-rw-r--r--api/logic/meta/Util.h (renamed from api/logic/wonko/WonkoUtil.h)4
-rw-r--r--api/logic/meta/Version.cpp (renamed from api/logic/wonko/WonkoVersion.cpp)47
-rw-r--r--api/logic/meta/Version.h (renamed from api/logic/wonko/WonkoVersion.h)26
-rw-r--r--api/logic/meta/VersionList.cpp (renamed from api/logic/wonko/WonkoVersionList.cpp)99
-rw-r--r--api/logic/meta/VersionList.h (renamed from api/logic/wonko/WonkoVersionList.h)37
-rw-r--r--api/logic/meta/format/Format.cpp84
-rw-r--r--api/logic/meta/format/Format.h57
-rw-r--r--api/logic/meta/format/FormatV1.cpp (renamed from api/logic/wonko/format/WonkoFormatV1.cpp)53
-rw-r--r--api/logic/meta/format/FormatV1.h (renamed from api/logic/wonko/format/WonkoFormatV1.h)19
-rw-r--r--api/logic/meta/tasks/LocalLoadTask.cpp123
-rw-r--r--api/logic/meta/tasks/LocalLoadTask.h (renamed from api/logic/wonko/tasks/BaseWonkoEntityLocalLoadTask.h)35
-rw-r--r--api/logic/meta/tasks/RemoteLoadTask.cpp132
-rw-r--r--api/logic/meta/tasks/RemoteLoadTask.h (renamed from api/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.h)39
-rw-r--r--api/logic/wonko/WonkoIndex_test.cpp50
-rw-r--r--api/logic/wonko/format/WonkoFormat.cpp80
-rw-r--r--api/logic/wonko/format/WonkoFormat.h54
-rw-r--r--api/logic/wonko/tasks/BaseWonkoEntityLocalLoadTask.cpp117
-rw-r--r--api/logic/wonko/tasks/BaseWonkoEntityRemoteLoadTask.cpp126
29 files changed, 770 insertions, 710 deletions
diff --git a/api/logic/CMakeLists.txt b/api/logic/CMakeLists.txt
index bcf4b65a..1827b497 100644
--- a/api/logic/CMakeLists.txt
+++ b/api/logic/CMakeLists.txt
@@ -430,32 +430,32 @@ 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/tasks/RemoteLoadTask.cpp
+ meta/tasks/RemoteLoadTask.h
+ meta/tasks/LocalLoadTask.cpp
+ meta/tasks/LocalLoadTask.h
+ meta/format/FormatV1.cpp
+ meta/format/FormatV1.h
+ meta/format/Format.cpp
+ meta/format/Format.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
+ meta/Util.cpp
+ meta/Util.h
+ meta/Reference.cpp
+ meta/Reference.h
)
-add_unit_test(WonkoIndex
- SOURCES wonko/WonkoIndex_test.cpp
+add_unit_test(Index
+ SOURCES meta/Index_test.cpp
LIBS MultiMC_logic
)
@@ -480,7 +480,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..903f1d8a 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("cache/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/wonko/BaseWonkoEntity.cpp b/api/logic/meta/BaseEntity.cpp
index e6a0e41e..fd44e29c 100644
--- a/api/logic/wonko/BaseWonkoEntity.cpp
+++ b/api/logic/meta/BaseEntity.cpp
@@ -13,27 +13,30 @@
* limitations under the License.
*/
-#include "BaseWonkoEntity.h"
+#include "BaseEntity.h"
#include "Json.h"
-#include "WonkoUtil.h"
+#include "Util.h"
-BaseWonkoEntity::~BaseWonkoEntity()
+namespace Meta
+{
+BaseEntity::~BaseEntity()
{
}
-void BaseWonkoEntity::store() const
+void BaseEntity::store() const
{
- Json::write(serialized(), Wonko::localWonkoDir().absoluteFilePath(localFilename()));
+ Json::write(serialized(), Meta::localDir().absoluteFilePath(localFilename()));
}
-void BaseWonkoEntity::notifyLocalLoadComplete()
+void BaseEntity::notifyLocalLoadComplete()
{
m_localLoaded = true;
store();
}
-void BaseWonkoEntity::notifyRemoteLoadComplete()
+void BaseEntity::notifyRemoteLoadComplete()
{
m_remoteLoaded = true;
store();
}
+}
diff --git a/api/logic/wonko/BaseWonkoEntity.h b/api/logic/meta/BaseEntity.h
index c6e8c832..b7a241c6 100644
--- a/api/logic/wonko/BaseWonkoEntity.h
+++ b/api/logic/meta/BaseEntity.h
@@ -21,17 +21,18 @@
#include "multimc_logic_export.h"
class Task;
-
-class MULTIMC_LOGIC_EXPORT BaseWonkoEntity
+namespace Meta
+{
+class MULTIMC_LOGIC_EXPORT BaseEntity
{
public:
- virtual ~BaseWonkoEntity();
+ virtual ~BaseEntity();
- using Ptr = std::shared_ptr<BaseWonkoEntity>;
+ using Ptr = std::shared_ptr<BaseEntity>;
virtual std::unique_ptr<Task> remoteUpdateTask() = 0;
virtual std::unique_ptr<Task> localUpdateTask() = 0;
- virtual void merge(const std::shared_ptr<BaseWonkoEntity> &other) = 0;
+ virtual void merge(const std::shared_ptr<BaseEntity> &other) = 0;
void store() const;
virtual QString localFilename() const = 0;
@@ -49,3 +50,4 @@ private:
bool m_localLoaded = false;
bool m_remoteLoaded = false;
};
+}
diff --git a/api/logic/wonko/WonkoIndex.cpp b/api/logic/meta/Index.cpp
index f6ad201a..8a6b1355 100644
--- a/api/logic/wonko/WonkoIndex.cpp
+++ b/api/logic/meta/Index.cpp
@@ -13,18 +13,20 @@
* 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 "tasks/LocalLoadTask.h"
+#include "tasks/RemoteLoadTask.h"
+#include "format/Format.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 +36,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 +58,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 +78,36 @@ QVariant WonkoIndex::headerData(int section, Qt::Orientation orientation, int ro
}
}
-std::unique_ptr<Task> WonkoIndex::remoteUpdateTask()
+std::unique_ptr<Task> Index::remoteUpdateTask()
{
- return std::unique_ptr<WonkoIndexRemoteLoadTask>(new WonkoIndexRemoteLoadTask(this, this));
+ return std::unique_ptr<IndexRemoteLoadTask>(new IndexRemoteLoadTask(this, this));
}
-std::unique_ptr<Task> WonkoIndex::localUpdateTask()
+std::unique_ptr<Task> Index::localUpdateTask()
{
- return std::unique_ptr<WonkoIndexLocalLoadTask>(new WonkoIndexLocalLoadTask(this, this));
+ return std::unique_ptr<IndexLocalLoadTask>(new IndexLocalLoadTask(this, this));
}
-QJsonObject WonkoIndex::serialized() const
+QJsonObject Index::serialized() const
{
- return WonkoFormat::serializeIndex(this);
+ return Format::serializeIndex(this);
}
-bool WonkoIndex::hasUid(const QString &uid) const
+bool Index::hasUid(const QString &uid) const
{
return m_uids.contains(uid);
}
-WonkoVersionListPtr WonkoIndex::getList(const QString &uid) const
+VersionListPtr Index::getList(const QString &uid) const
{
return m_uids.value(uid, nullptr);
}
-WonkoVersionListPtr WonkoIndex::getListGuaranteed(const QString &uid) const
+VersionListPtr Index::getListGuaranteed(const QString &uid) const
{
- return m_uids.value(uid, std::make_shared<WonkoVersionList>(uid));
+ return m_uids.value(uid, std::make_shared<VersionList>(uid));
}
-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 +122,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 +140,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..16e95d5a 100644
--- a/api/logic/wonko/WonkoIndex.h
+++ b/api/logic/meta/Index.h
@@ -18,19 +18,22 @@
#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>;
+
+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
{
@@ -52,17 +55,18 @@ public:
// queries
bool hasUid(const QString &uid) const;
- WonkoVersionListPtr getList(const QString &uid) const;
- WonkoVersionListPtr getListGuaranteed(const QString &uid) const;
+ VersionListPtr getList(const QString &uid) const;
+ VersionListPtr 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;
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..d26700ca
--- /dev/null
+++ b/api/logic/meta/Index_test.cpp
@@ -0,0 +1,50 @@
+#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_providesTasks()
+ {
+ QVERIFY(ENV.metadataIndex()->localUpdateTask() != nullptr);
+ QVERIFY(ENV.metadataIndex()->remoteUpdateTask() != nullptr);
+ }
+
+ 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.getList("list2") != nullptr);
+ QCOMPARE(windex.getList("list2")->uid(), QString("list2"));
+ QVERIFY(windex.getList("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/wonko/WonkoReference.cpp b/api/logic/meta/Reference.cpp
index 7193e56e..c5cef172 100644
--- a/api/logic/wonko/WonkoReference.cpp
+++ b/api/logic/meta/Reference.cpp
@@ -13,32 +13,36 @@
* limitations under the License.
*/
-#include "WonkoReference.h"
+#include "Reference.h"
-WonkoReference::WonkoReference(const QString &uid)
+namespace Meta
+{
+Reference::Reference(const QString &uid)
: m_uid(uid)
{
}
-QString WonkoReference::uid() const
+QString Reference::uid() const
{
return m_uid;
}
-QString WonkoReference::version() const
+QString Reference::version() const
{
return m_version;
}
-void WonkoReference::setVersion(const QString &version)
+void Reference::setVersion(const QString &version)
{
m_version = version;
}
-bool WonkoReference::operator==(const WonkoReference &other) const
+bool Reference::operator==(const Reference &other) const
{
return m_uid == other.m_uid && m_version == other.m_version;
}
-bool WonkoReference::operator!=(const WonkoReference &other) const
+
+bool Reference::operator!=(const Reference &other) const
{
return m_uid != other.m_uid || m_version != other.m_version;
}
+}
diff --git a/api/logic/wonko/WonkoReference.h b/api/logic/meta/Reference.h
index ba7427b3..027076cc 100644
--- a/api/logic/wonko/WonkoReference.h
+++ b/api/logic/meta/Reference.h
@@ -20,22 +20,25 @@
#include "multimc_logic_export.h"
-class MULTIMC_LOGIC_EXPORT WonkoReference
+namespace Meta
+{
+class MULTIMC_LOGIC_EXPORT Reference
{
public:
- WonkoReference() {}
- explicit WonkoReference(const QString &uid);
+ Reference() {}
+ explicit Reference(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;
+ bool operator==(const Reference &other) const;
+ bool operator!=(const Reference &other) const;
private:
QString m_uid;
QString m_version;
};
-Q_DECLARE_METATYPE(WonkoReference)
+}
+Q_DECLARE_METATYPE(Meta::Reference)
diff --git a/api/logic/wonko/WonkoUtil.cpp b/api/logic/meta/Util.cpp
index 3b8049c4..2ccbe5c4 100644
--- a/api/logic/wonko/WonkoUtil.cpp
+++ b/api/logic/meta/Util.cpp
@@ -13,35 +13,38 @@
* limitations under the License.
*/
-#include "WonkoUtil.h"
+#include "Util.h"
#include <QUrl>
#include <QDir>
#include "Env.h"
-namespace Wonko
+namespace Meta
{
QUrl rootUrl()
{
- return ENV.wonkoRootUrl();
+ return QUrl("https://meta.multimc.org");
}
+
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()
+QDir localDir()
{
- return QDir("wonko");
+ return QDir("meta");
}
}
diff --git a/api/logic/wonko/WonkoUtil.h b/api/logic/meta/Util.h
index fb58ba1f..28163fe4 100644
--- a/api/logic/wonko/WonkoUtil.h
+++ b/api/logic/meta/Util.h
@@ -21,11 +21,11 @@ class QUrl;
class QString;
class QDir;
-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();
+MULTIMC_LOGIC_EXPORT QDir localDir();
}
diff --git a/api/logic/wonko/WonkoVersion.cpp b/api/logic/meta/Version.cpp
index f5a063be..039f4fef 100644
--- a/api/logic/wonko/WonkoVersion.cpp
+++ b/api/logic/meta/Version.cpp
@@ -13,49 +13,51 @@
* limitations under the License.
*/
-#include "WonkoVersion.h"
+#include "Version.h"
#include <QDateTime>
-#include "tasks/BaseWonkoEntityLocalLoadTask.h"
-#include "tasks/BaseWonkoEntityRemoteLoadTask.h"
-#include "format/WonkoFormat.h"
+#include "tasks/LocalLoadTask.h"
+#include "tasks/RemoteLoadTask.h"
+#include "format/Format.h"
-WonkoVersion::WonkoVersion(const QString &uid, const QString &version)
+namespace Meta
+{
+Version::Version(const QString &uid, const QString &version)
: BaseVersion(), m_uid(uid), m_version(version)
{
}
-QString WonkoVersion::descriptor()
+QString Version::descriptor()
{
return m_version;
}
-QString WonkoVersion::name()
+QString Version::name()
{
return m_version;
}
-QString WonkoVersion::typeString() const
+QString Version::typeString() const
{
return m_type;
}
-QDateTime WonkoVersion::time() const
+QDateTime Version::time() const
{
return QDateTime::fromMSecsSinceEpoch(m_time * 1000, Qt::UTC);
}
-std::unique_ptr<Task> WonkoVersion::remoteUpdateTask()
+std::unique_ptr<Task> Version::remoteUpdateTask()
{
- return std::unique_ptr<WonkoVersionRemoteLoadTask>(new WonkoVersionRemoteLoadTask(this, this));
+ return std::unique_ptr<VersionRemoteLoadTask>(new VersionRemoteLoadTask(this, this));
}
-std::unique_ptr<Task> WonkoVersion::localUpdateTask()
+std::unique_ptr<Task> Version::localUpdateTask()
{
- return std::unique_ptr<WonkoVersionLocalLoadTask>(new WonkoVersionLocalLoadTask(this, this));
+ return std::unique_ptr<VersionLocalLoadTask>(new VersionLocalLoadTask(this, this));
}
-void WonkoVersion::merge(const std::shared_ptr<BaseWonkoEntity> &other)
+void Version::merge(const std::shared_ptr<BaseEntity> &other)
{
- WonkoVersionPtr version = std::dynamic_pointer_cast<WonkoVersion>(other);
+ VersionPtr version = std::dynamic_pointer_cast<Version>(other);
if (m_type != version->m_type)
{
setType(version->m_type);
@@ -72,31 +74,32 @@ void WonkoVersion::merge(const std::shared_ptr<BaseWonkoEntity> &other)
setData(version->m_data);
}
-QString WonkoVersion::localFilename() const
+QString Version::localFilename() const
{
return m_uid + '/' + m_version + ".json";
}
-QJsonObject WonkoVersion::serialized() const
+QJsonObject Version::serialized() const
{
- return WonkoFormat::serializeVersion(this);
+ return Format::serializeVersion(this);
}
-void WonkoVersion::setType(const QString &type)
+void Version::setType(const QString &type)
{
m_type = type;
emit typeChanged();
}
-void WonkoVersion::setTime(const qint64 time)
+void Version::setTime(const qint64 time)
{
m_time = time;
emit timeChanged();
}
-void WonkoVersion::setRequires(const QVector<WonkoReference> &requires)
+void Version::setRequires(const QVector<Reference> &requires)
{
m_requires = requires;
emit requiresChanged();
}
-void WonkoVersion::setData(const VersionFilePtr &data)
+void Version::setData(const VersionFilePtr &data)
{
m_data = data;
}
+}
diff --git a/api/logic/wonko/WonkoVersion.h b/api/logic/meta/Version.h
index 397ff14e..4a791880 100644
--- a/api/logic/wonko/WonkoVersion.h
+++ b/api/logic/meta/Version.h
@@ -16,7 +16,6 @@
#pragma once
#include "BaseVersion.h"
-#include "BaseWonkoEntity.h"
#include <QVector>
#include <QStringList>
@@ -24,22 +23,26 @@
#include <memory>
#include "minecraft/VersionFile.h"
-#include "WonkoReference.h"
+
+#include "BaseEntity.h"
+#include "Reference.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)
+ Q_PROPERTY(QVector<Reference> requires READ requires NOTIFY requiresChanged)
public:
- explicit WonkoVersion(const QString &uid, const QString &version);
+ explicit Version(const QString &uid, const QString &version);
QString descriptor() override;
QString name() override;
@@ -50,12 +53,12 @@ public:
QString type() const { return m_type; }
QDateTime time() const;
qint64 rawTime() const { return m_time; }
- QVector<WonkoReference> requires() const { return m_requires; }
+ QVector<Reference> requires() const { return m_requires; }
VersionFilePtr data() const { return m_data; }
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;
QString localFilename() const override;
QJsonObject serialized() const override;
@@ -63,7 +66,7 @@ public:
public: // for usage by format parsers only
void setType(const QString &type);
void setTime(const qint64 time);
- void setRequires(const QVector<WonkoReference> &requires);
+ void setRequires(const QVector<Reference> &requires);
void setData(const VersionFilePtr &data);
signals:
@@ -76,8 +79,9 @@ private:
QString m_version;
QString m_type;
qint64 m_time;
- QVector<