Fix LWJGL version list loading.

SourceForge has changed its API again.
This commit is contained in:
Petr Mrázek 2014-07-20 12:59:44 +02:00
parent ce68efa174
commit 3403553d44

View File

@ -22,7 +22,7 @@
#include "logger/QsLog.h" #include "logger/QsLog.h"
#define RSS_URL "http://sourceforge.net/api/file/index/project-id/58488/mtime/desc/rss" #define RSS_URL "http://sourceforge.net/projects/java-game-lib/rss"
LWJGLVersionList::LWJGLVersionList(QObject *parent) : QAbstractListModel(parent) LWJGLVersionList::LWJGLVersionList(QObject *parent) : QAbstractListModel(parent)
{ {
@ -84,7 +84,7 @@ void LWJGLVersionList::loadList()
setLoading(true); setLoading(true);
auto worker = MMC->qnam(); auto worker = MMC->qnam();
QNetworkRequest req(QUrl(RSS_URL)); QNetworkRequest req(QUrl(RSS_URL));
req.setRawHeader("Accept", "text/xml"); req.setRawHeader("Accept", "application/rss+xml, text/xml, */*");
req.setRawHeader("User-Agent", "MultiMC/5.0 (Uncached)"); req.setRawHeader("User-Agent", "MultiMC/5.0 (Uncached)");
reply = worker->get(req); reply = worker->get(req);
connect(reply, SIGNAL(finished()), SLOT(netRequestComplete())); connect(reply, SIGNAL(finished()), SLOT(netRequestComplete()));
@ -110,7 +110,8 @@ void LWJGLVersionList::netRequestComplete()
QString xmlErrorMsg; QString xmlErrorMsg;
int errorLine; int errorLine;
if (!doc.setContent(reply->readAll(), false, &xmlErrorMsg, &errorLine)) auto rawData = reply->readAll();
if (!doc.setContent(rawData, false, &xmlErrorMsg, &errorLine))
{ {
failed("Failed to load LWJGL list. XML error: " + xmlErrorMsg + " at line " + failed("Failed to load LWJGL list. XML error: " + xmlErrorMsg + " at line " +
QString::number(errorLine)); QString::number(errorLine));
@ -146,10 +147,10 @@ void LWJGLVersionList::netRequestComplete()
QUrl url(link); QUrl url(link);
if (!url.isValid()) if (!url.isValid())
{ {
QLOG_INFO() << "LWJGL version URL isn't valid:" << link << "Skipping."; QLOG_WARN() << "LWJGL version URL isn't valid:" << link << "Skipping.";
continue; continue;
} }
QLOG_INFO() << "Discovered LWGL version" << name << "at" << link;
tempList.append(LWJGLVersion::Create(name, link)); tempList.append(LWJGLVersion::Create(name, link));
} }
} }
@ -183,7 +184,7 @@ const PtrLWJGLVersion LWJGLVersionList::getVersion(const QString &versionName)
void LWJGLVersionList::failed(QString msg) void LWJGLVersionList::failed(QString msg)
{ {
QLOG_INFO() << msg; QLOG_ERROR() << msg;
emit loadListFailed(msg); emit loadListFailed(msg);
} }