summaryrefslogtreecommitdiffstats
path: root/logic/net
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-11-22 01:04:14 +0100
committerPetr Mrázek <peterix@gmail.com>2013-11-22 01:04:14 +0100
commit7f5eb5d61ad5c94da5e3a0443ffbcd9088285496 (patch)
tree89e4b8db259233d3377d2f46e30244db12b09ad5 /logic/net
parent57a9dadb08a2a7ebfeba3d5f5234145b3db6c794 (diff)
downloadMultiMC-7f5eb5d61ad5c94da5e3a0443ffbcd9088285496.tar
MultiMC-7f5eb5d61ad5c94da5e3a0443ffbcd9088285496.tar.gz
MultiMC-7f5eb5d61ad5c94da5e3a0443ffbcd9088285496.tar.lz
MultiMC-7f5eb5d61ad5c94da5e3a0443ffbcd9088285496.tar.xz
MultiMC-7f5eb5d61ad5c94da5e3a0443ffbcd9088285496.zip
Implement user info stub for newest minecraft snapshot
Diffstat (limited to 'logic/net')
-rw-r--r--logic/net/HttpMetaCache.h1
-rw-r--r--logic/net/LoginTask.cpp15
-rw-r--r--logic/net/LoginTask.h15
3 files changed, 20 insertions, 11 deletions
diff --git a/logic/net/HttpMetaCache.h b/logic/net/HttpMetaCache.h
index e91d2684..08b39fe2 100644
--- a/logic/net/HttpMetaCache.h
+++ b/logic/net/HttpMetaCache.h
@@ -15,7 +15,6 @@
#pragma once
#include <QString>
-#include <QSharedPointer>
#include <QMap>
#include <qtimer.h>
diff --git a/logic/net/LoginTask.cpp b/logic/net/LoginTask.cpp
index 4a789bb4..5607447e 100644
--- a/logic/net/LoginTask.cpp
+++ b/logic/net/LoginTask.cpp
@@ -27,7 +27,8 @@
#include <QJsonParseError>
#include <QJsonObject>
-LoginTask::LoginTask(const UserInfo &uInfo, QObject *parent) : Task(parent), uInfo(uInfo)
+LoginTask::LoginTask(const PasswordLogin &loginInfo, QObject *parent)
+ : Task(parent), loginInfo(loginInfo)
{
}
@@ -49,8 +50,8 @@ void LoginTask::legacyLogin()
"application/x-www-form-urlencoded");
QUrlQuery params;
- params.addQueryItem("user", uInfo.username);
- params.addQueryItem("password", uInfo.password);
+ params.addQueryItem("user", loginInfo.username);
+ params.addQueryItem("password", loginInfo.password);
params.addQueryItem("version", "13");
netReply = worker->post(netRequest, params.query(QUrl::EncodeSpaces).toUtf8());
@@ -221,8 +222,8 @@ void LoginTask::yggdrasilLogin()
agent.insert("name", QString("Minecraft"));
agent.insert("version", QJsonValue(1));
root.insert("agent", agent);
- root.insert("username", uInfo.username);
- root.insert("password", uInfo.password);
+ root.insert("username", loginInfo.username);
+ root.insert("password", loginInfo.password);
root.insert("clientToken", clientToken);
QJsonDocument requestDoc(root);
netReply = worker->post(netRequest, requestDoc.toJson());
@@ -247,6 +248,7 @@ void LoginTask::yggdrasilLogin()
void LoginTask::parseYggdrasilReply(QByteArray data)
{
QJsonParseError jsonError;
+ QLOG_DEBUG() << data;
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
if (jsonError.error != QJsonParseError::NoError)
{
@@ -273,6 +275,7 @@ void LoginTask::parseYggdrasilReply(QByteArray data)
playerID = selectedProfileO.value("id").toString();
playerName = selectedProfileO.value("name").toString();
}
+
QString sessionID = "token:" + accessToken + ":" + playerID;
/*
struct LoginResponse
@@ -285,6 +288,6 @@ void LoginTask::parseYggdrasilReply(QByteArray data)
};
*/
- result = {uInfo.username, sessionID, playerName, playerID, accessToken};
+ result = {loginInfo.username, sessionID, playerName, playerID, accessToken};
emitSucceeded();
}
diff --git a/logic/net/LoginTask.h b/logic/net/LoginTask.h
index 26ac0808..fe4e6d2f 100644
--- a/logic/net/LoginTask.h
+++ b/logic/net/LoginTask.h
@@ -16,14 +16,20 @@
#pragma once
#include "logic/tasks/Task.h"
-#include <QSharedPointer>
+#include <QMap>
-struct UserInfo
+struct PasswordLogin
{
QString username;
QString password;
};
+struct User
+{
+ QString id;
+ QMap<QString, QString> properties;
+};
+
struct LoginResponse
{
QString username;
@@ -31,6 +37,7 @@ struct LoginResponse
QString player_name;
QString player_id;
QString access_token;
+ User user; // FIXME: no idea what this really is yet. anything relevant?
};
class QNetworkReply;
@@ -39,7 +46,7 @@ class LoginTask : public Task
{
Q_OBJECT
public:
- explicit LoginTask(const UserInfo &uInfo, QObject *parent = 0);
+ explicit LoginTask(const PasswordLogin &loginInfo, QObject *parent = 0);
LoginResponse getResult()
{
return result;
@@ -65,5 +72,5 @@ protected:
LoginResponse result;
QNetworkReply *netReply;
- UserInfo uInfo;
+ PasswordLogin loginInfo;
};