From afaa1dc223ec87b685778ee0aed81cb6caaa05c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 7 Aug 2013 01:38:18 +0200 Subject: Get rid of QNAM (now subclassed and less needy). Basic LWJGL download and extraction. --- backend/tasks/LoginTask.cpp | 20 +++++++++----------- backend/tasks/LoginTask.h | 3 --- 2 files changed, 9 insertions(+), 14 deletions(-) (limited to 'backend/tasks') diff --git a/backend/tasks/LoginTask.cpp b/backend/tasks/LoginTask.cpp index 30e97ca9..7a1d5262 100644 --- a/backend/tasks/LoginTask.cpp +++ b/backend/tasks/LoginTask.cpp @@ -14,27 +14,23 @@ */ #include "LoginTask.h" +#include #include -#include -#include -#include +#include +#include #include #include -LoginTask::LoginTask( const UserInfo& uInfo, QObject* parent ) : - Task(parent), uInfo(uInfo) -{ - netMgr.reset(new QNetworkAccessManager()); -} +LoginTask::LoginTask( const UserInfo& uInfo, QObject* parent ) : Task(parent), uInfo(uInfo){} void LoginTask::executeTask() { setStatus("Logging in..."); - - connect(netMgr.data(), SIGNAL(finished(QNetworkReply*)), this, SLOT(processNetReply(QNetworkReply*))); + auto & worker = NetWorker::spawn(); + connect(&worker, SIGNAL(finished(QNetworkReply*)), this, SLOT(processNetReply(QNetworkReply*))); QUrl loginURL("https://login.minecraft.net/"); QNetworkRequest netRequest(loginURL); @@ -45,11 +41,13 @@ void LoginTask::executeTask() params.addQueryItem("password", uInfo.password); params.addQueryItem("version", "13"); - netReply = netMgr->post(netRequest, params.query(QUrl::EncodeSpaces).toUtf8()); + netReply = worker.post(netRequest, params.query(QUrl::EncodeSpaces).toUtf8()); } void LoginTask::processNetReply(QNetworkReply *reply) { + if(netReply != reply) + return; // Check for errors. switch (reply->error()) { diff --git a/backend/tasks/LoginTask.h b/backend/tasks/LoginTask.h index e2f72f9e..81d1b6cc 100644 --- a/backend/tasks/LoginTask.h +++ b/backend/tasks/LoginTask.h @@ -33,7 +33,6 @@ struct LoginResponse qint64 latestVersion; }; -class QNetworkAccessManager; class QNetworkReply; class LIBMULTIMC_EXPORT LoginTask : public Task @@ -54,8 +53,6 @@ protected: QNetworkReply* netReply; UserInfo uInfo; -private: - QSharedPointer netMgr; }; #endif // LOGINTASK_H -- cgit v1.2.3