summaryrefslogtreecommitdiffstats
path: root/backend/lists
diff options
context:
space:
mode:
Diffstat (limited to 'backend/lists')
-rw-r--r--backend/lists/LwjglVersionList.cpp13
-rw-r--r--backend/lists/LwjglVersionList.h21
-rw-r--r--backend/lists/MinecraftVersionList.cpp16
-rw-r--r--backend/lists/MinecraftVersionList.h2
4 files changed, 21 insertions, 31 deletions
diff --git a/backend/lists/LwjglVersionList.cpp b/backend/lists/LwjglVersionList.cpp
index 824d0906..73a27a58 100644
--- a/backend/lists/LwjglVersionList.cpp
+++ b/backend/lists/LwjglVersionList.cpp
@@ -14,6 +14,7 @@
*/
#include "LwjglVersionList.h"
+#include <net/NetWorker.h>
#include <QtNetwork>
@@ -53,7 +54,7 @@ QVariant LWJGLVersionList::data(const QModelIndex &index, int role) const
return version->name();
case Qt::ToolTipRole:
- return version->url().toString();
+ return version->url();
default:
return QVariant();
@@ -90,7 +91,8 @@ void LWJGLVersionList::loadList()
Q_ASSERT_X(!m_loading, "loadList", "list is already loading (m_loading is true)");
setLoading(true);
- reply = netMgr.get(QNetworkRequest(QUrl(RSS_URL)));
+ auto & worker = NetWorker::spawn();
+ reply = worker.get(QNetworkRequest(QUrl(RSS_URL)));
connect(reply, SIGNAL(finished()), SLOT(netRequestComplete()));
}
@@ -144,9 +146,9 @@ void LWJGLVersionList::netRequestComplete()
// Make sure it's a download link.
if (link.endsWith("/download") && link.contains(lwjglRegex))
{
- QString name = link.mid(lwjglRegex.indexIn(link));
+ QString name = link.mid(lwjglRegex.indexIn(link) + 6);
// Subtract 4 here to remove the .zip file extension.
- name = name.left(lwjglRegex.matchedLength() - 4);
+ name = name.left(lwjglRegex.matchedLength() - 10);
QUrl url(link);
if (!url.isValid())
@@ -179,7 +181,8 @@ const PtrLWJGLVersion LWJGLVersionList::getVersion(const QString &versionName)
{
for (int i = 0; i < count(); i++)
{
- if (at(i)->name() == versionName)
+ QString name = at(i)->name();
+ if ( name == versionName)
return at(i);
}
return PtrLWJGLVersion();
diff --git a/backend/lists/LwjglVersionList.h b/backend/lists/LwjglVersionList.h
index f3e7799a..2360f181 100644
--- a/backend/lists/LwjglVersionList.h
+++ b/backend/lists/LwjglVersionList.h
@@ -20,7 +20,6 @@
#include <QSharedPointer>
#include <QUrl>
-#include <QNetworkAccessManager>
#include <QNetworkReply>
#include "libmmc_config.h"
@@ -32,32 +31,22 @@ class LIBMULTIMC_EXPORT LWJGLVersion : public QObject
{
Q_OBJECT
- /*!
- * The name of the LWJGL version.
- */
- Q_PROPERTY(QString name READ name)
-
- /*!
- * The URL for this version of LWJGL.
- */
- Q_PROPERTY(QUrl url READ url)
-
- LWJGLVersion(const QString &name, const QUrl &url, QObject *parent = 0) :
+ LWJGLVersion(const QString &name, const QString &url, QObject *parent = 0) :
QObject(parent), m_name(name), m_url(url) { }
public:
- static PtrLWJGLVersion Create(const QString &name, const QUrl &url, QObject *parent = 0)
+ static PtrLWJGLVersion Create(const QString &name, const QString &url, QObject *parent = 0)
{
return PtrLWJGLVersion(new LWJGLVersion(name, url, parent));
};
QString name() const { return m_name; }
- QUrl url() const { return m_url; }
+ QString url() const { return m_url; }
protected:
QString m_name;
- QUrl m_url;
+ QString m_url;
};
class LIBMULTIMC_EXPORT LWJGLVersionList : public QAbstractListModel
@@ -112,8 +101,6 @@ private:
QList<PtrLWJGLVersion> m_vlist;
QNetworkReply *m_netReply;
-
- QNetworkAccessManager netMgr;
QNetworkReply *reply;
bool m_loading;
diff --git a/backend/lists/MinecraftVersionList.cpp b/backend/lists/MinecraftVersionList.cpp
index 7f220086..e14d7a25 100644
--- a/backend/lists/MinecraftVersionList.cpp
+++ b/backend/lists/MinecraftVersionList.cpp
@@ -14,6 +14,7 @@
*/
#include "MinecraftVersionList.h"
+#include <net/NetWorker.h>
#include <QDebug>
@@ -29,8 +30,6 @@
#include <QtNetwork>
-#include "netutils.h"
-
#define MCVLIST_URLBASE "http://s3.amazonaws.com/Minecraft.Download/versions/"
#define ASSETS_URLBASE "http://assets.minecraft.net/"
#define MCN_URLBASE "http://sonicrules.org/mcnweb.py"
@@ -160,21 +159,18 @@ MCVListLoadTask::MCVListLoadTask(MinecraftVersionList *vlist)
{
m_list = vlist;
m_currentStable = NULL;
- netMgr = nullptr;
vlistReply = nullptr;
}
MCVListLoadTask::~MCVListLoadTask()
{
- if(netMgr)
- netMgr->deleteLater();
}
void MCVListLoadTask::executeTask()
{
setStatus("Loading instance version list...");
- netMgr = new QNetworkAccessManager();
- vlistReply = netMgr->get(QNetworkRequest(QUrl(QString(MCVLIST_URLBASE) + "versions.json")));
+ auto & worker = NetWorker::spawn();
+ vlistReply = worker.get(QNetworkRequest(QUrl(QString(MCVLIST_URLBASE) + "versions.json")));
connect(vlistReply, SIGNAL(finished()), this, SLOT(list_downloaded()));
}
@@ -283,12 +279,18 @@ void MCVListLoadTask::list_downloaded()
{
versionType = MinecraftVersion::Snapshot;
}
+ else if(versionTypeStr == "old_beta" || versionTypeStr == "old_alpha")
+ {
+ versionType = MinecraftVersion::Nostalgia;
+ }
else
{
//FIXME: log this somewhere
continue;
}
+ //FIXME: detect if snapshots are old or not
+
// Get the download URL.
QString dlUrl = QString(MCVLIST_URLBASE) + versionID + "/";
diff --git a/backend/lists/MinecraftVersionList.h b/backend/lists/MinecraftVersionList.h
index 078c7c66..8707016a 100644
--- a/backend/lists/MinecraftVersionList.h
+++ b/backend/lists/MinecraftVersionList.h
@@ -24,7 +24,6 @@
#include "libmmc_config.h"
class MCVListLoadTask;
-class QNetworkAccessManager;
class QNetworkReply;
class LIBMULTIMC_EXPORT MinecraftVersionList : public InstVersionList
@@ -76,7 +75,6 @@ protected:
//! Loads versions from Mojang's official version list.
bool loadFromVList();
- QNetworkAccessManager *netMgr;
QNetworkReply *vlistReply;
MinecraftVersionList *m_list;