summaryrefslogtreecommitdiffstats
path: root/logic/auth/YggdrasilTask.cpp
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-12-01 14:28:47 -0600
committerAndrew <forkk@forkk.net>2013-12-01 14:28:47 -0600
commit613699b3626aea750093ab7eaaeccaa28c0e87c6 (patch)
tree7fd542b8f4be10359ba2aaeac9834f1b5c86a750 /logic/auth/YggdrasilTask.cpp
parent2427ad687137bbcfc7303a931d7e0b74d5325e48 (diff)
parent75c4d97b90e39f2bda6e682def0fdda044cbcf6f (diff)
downloadMultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.tar
MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.tar.gz
MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.tar.lz
MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.tar.xz
MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.zip
Merge branch 'develop' of github.com:MultiMC/MultiMC5 into develop
Diffstat (limited to 'logic/auth/YggdrasilTask.cpp')
-rw-r--r--logic/auth/YggdrasilTask.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/logic/auth/YggdrasilTask.cpp b/logic/auth/YggdrasilTask.cpp
index 31c8fbab..797e84cd 100644
--- a/logic/auth/YggdrasilTask.cpp
+++ b/logic/auth/YggdrasilTask.cpp
@@ -25,13 +25,12 @@
#include <MultiMC.h>
#include <logic/auth/MojangAccount.h>
-YggdrasilTask::YggdrasilTask(MojangAccountPtr account, QObject* parent) : Task(parent)
+YggdrasilTask::YggdrasilTask(MojangAccountPtr account, QObject *parent) : Task(parent)
{
m_error = nullptr;
m_account = account;
}
-
YggdrasilTask::~YggdrasilTask()
{
if (m_error)
@@ -46,17 +45,18 @@ void YggdrasilTask::executeTask()
QJsonDocument doc(getRequestContent());
auto worker = MMC->qnam();
- connect(worker.get(), SIGNAL(finished(QNetworkReply*)), this,
- SLOT(processReply(QNetworkReply*)));
+ connect(worker.get(), SIGNAL(finished(QNetworkReply *)), this,
+ SLOT(processReply(QNetworkReply *)));
QUrl reqUrl("https://authserver.mojang.com/" + getEndpoint());
QNetworkRequest netRequest(reqUrl);
netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
-
- m_netReply = worker->post(netRequest, doc.toJson());
+
+ QByteArray requestData = doc.toJson();
+ m_netReply = worker->post(netRequest, requestData);
}
-void YggdrasilTask::processReply(QNetworkReply* reply)
+void YggdrasilTask::processReply(QNetworkReply *reply)
{
setStatus(getStateMessage(STATE_PROCESSING_RESPONSE));
@@ -76,7 +76,6 @@ void YggdrasilTask::processReply(QNetworkReply* reply)
QJsonParseError jsonError;
QByteArray replyData = reply->readAll();
QJsonDocument doc = QJsonDocument::fromJson(replyData, &jsonError);
-
// Check the response code.
int responseCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
@@ -85,15 +84,16 @@ void YggdrasilTask::processReply(QNetworkReply* reply)
// If the response code was 200, then there shouldn't be an error. Make sure anyways.
// Also, sometimes an empty reply indicates success. If there was no data received,
// pass an empty json object to the processResponse function.
- if (jsonError.error == QJsonParseError::NoError || replyData.size() == 0)
+ if (jsonError.error == QJsonParseError::NoError || replyData.size() == 0)
{
if (!processResponse(replyData.size() > 0 ? doc.object() : QJsonObject()))
{
- YggdrasilTask::Error* err = getError();
+ YggdrasilTask::Error *err = getError();
if (err)
emitFailed(err->getErrorMessage());
else
- emitFailed(tr("An unknown error occurred when processing the response from the authentication server."));
+ emitFailed(tr("An unknown error occurred when processing the response "
+ "from the authentication server."));
}
else
{
@@ -166,4 +166,3 @@ MojangAccountPtr YggdrasilTask::getMojangAccount() const
{
return this->m_account;
}
-