Implement user info stub for newest minecraft snapshot
This commit is contained in:
parent
57a9dadb08
commit
7f5eb5d61a
@ -589,7 +589,7 @@ void MainWindow::doAutoLogin()
|
|||||||
|
|
||||||
void MainWindow::doLogin(QString username, QString password)
|
void MainWindow::doLogin(QString username, QString password)
|
||||||
{
|
{
|
||||||
UserInfo uInfo{username, password};
|
PasswordLogin uInfo{username, password};
|
||||||
|
|
||||||
ProgressDialog *tDialog = new ProgressDialog(this);
|
ProgressDialog *tDialog = new ProgressDialog(this);
|
||||||
LoginTask *loginTask = new LoginTask(uInfo, tDialog);
|
LoginTask *loginTask = new LoginTask(uInfo, tDialog);
|
||||||
|
@ -63,7 +63,7 @@ void InstanceLauncher::doLogin(const QString &errorMsg)
|
|||||||
loginDlg->exec();
|
loginDlg->exec();
|
||||||
if (loginDlg->result() == QDialog::Accepted)
|
if (loginDlg->result() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
|
PasswordLogin uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
|
||||||
|
|
||||||
ProgressDialog *tDialog = new ProgressDialog(nullptr);
|
ProgressDialog *tDialog = new ProgressDialog(nullptr);
|
||||||
LoginTask *loginTask = new LoginTask(uInfo, tDialog);
|
LoginTask *loginTask = new LoginTask(uInfo, tDialog);
|
||||||
|
@ -93,6 +93,8 @@ QStringList OneSixInstance::processMinecraftArgs(LoginResponse response)
|
|||||||
token_mapping["game_directory"] = absRootDir;
|
token_mapping["game_directory"] = absRootDir;
|
||||||
QString absAssetsDir = QDir("assets/").absolutePath();
|
QString absAssetsDir = QDir("assets/").absolutePath();
|
||||||
token_mapping["game_assets"] = absAssetsDir;
|
token_mapping["game_assets"] = absAssetsDir;
|
||||||
|
//TODO: this is something new and not even fully implemented in the vanilla launcher.
|
||||||
|
token_mapping["user_properties"] = "{ }";
|
||||||
|
|
||||||
QStringList parts = args_pattern.split(' ', QString::SkipEmptyParts);
|
QStringList parts = args_pattern.split(' ', QString::SkipEmptyParts);
|
||||||
for (int i = 0; i < parts.length(); i++)
|
for (int i = 0; i < parts.length(); i++)
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
#include "logic/OneSixLibrary.h"
|
#include "logic/OneSixLibrary.h"
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ std::shared_ptr<OneSixVersion> OneSixVersion::fromJson(QJsonObject root)
|
|||||||
root.value("minimumLauncherVersion").toDouble();
|
root.value("minimumLauncherVersion").toDouble();
|
||||||
|
|
||||||
// ADD MORE HERE :D
|
// ADD MORE HERE :D
|
||||||
if (launcher_ver > 0 && launcher_ver <= 9)
|
if (launcher_ver > 0 && launcher_ver <= 10)
|
||||||
return fromJsonV4(root, readVersion);
|
return fromJsonV4(root, readVersion);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
#include "logic/BaseVersion.h"
|
#include "logic/BaseVersion.h"
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include "categorizedsortfilterproxymodel.h"
|
#include "categorizedsortfilterproxymodel.h"
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
#include "BaseVersionList.h"
|
#include "BaseVersionList.h"
|
||||||
#include "logic/tasks/Task.h"
|
#include "logic/tasks/Task.h"
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
#include "BaseVersionList.h"
|
#include "BaseVersionList.h"
|
||||||
#include "logic/tasks/Task.h"
|
#include "logic/tasks/Task.h"
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@
|
|||||||
#include <QJsonParseError>
|
#include <QJsonParseError>
|
||||||
#include <QJsonObject>
|
#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");
|
"application/x-www-form-urlencoded");
|
||||||
|
|
||||||
QUrlQuery params;
|
QUrlQuery params;
|
||||||
params.addQueryItem("user", uInfo.username);
|
params.addQueryItem("user", loginInfo.username);
|
||||||
params.addQueryItem("password", uInfo.password);
|
params.addQueryItem("password", loginInfo.password);
|
||||||
params.addQueryItem("version", "13");
|
params.addQueryItem("version", "13");
|
||||||
|
|
||||||
netReply = worker->post(netRequest, params.query(QUrl::EncodeSpaces).toUtf8());
|
netReply = worker->post(netRequest, params.query(QUrl::EncodeSpaces).toUtf8());
|
||||||
@ -221,8 +222,8 @@ void LoginTask::yggdrasilLogin()
|
|||||||
agent.insert("name", QString("Minecraft"));
|
agent.insert("name", QString("Minecraft"));
|
||||||
agent.insert("version", QJsonValue(1));
|
agent.insert("version", QJsonValue(1));
|
||||||
root.insert("agent", agent);
|
root.insert("agent", agent);
|
||||||
root.insert("username", uInfo.username);
|
root.insert("username", loginInfo.username);
|
||||||
root.insert("password", uInfo.password);
|
root.insert("password", loginInfo.password);
|
||||||
root.insert("clientToken", clientToken);
|
root.insert("clientToken", clientToken);
|
||||||
QJsonDocument requestDoc(root);
|
QJsonDocument requestDoc(root);
|
||||||
netReply = worker->post(netRequest, requestDoc.toJson());
|
netReply = worker->post(netRequest, requestDoc.toJson());
|
||||||
@ -247,6 +248,7 @@ void LoginTask::yggdrasilLogin()
|
|||||||
void LoginTask::parseYggdrasilReply(QByteArray data)
|
void LoginTask::parseYggdrasilReply(QByteArray data)
|
||||||
{
|
{
|
||||||
QJsonParseError jsonError;
|
QJsonParseError jsonError;
|
||||||
|
QLOG_DEBUG() << data;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
|
||||||
if (jsonError.error != QJsonParseError::NoError)
|
if (jsonError.error != QJsonParseError::NoError)
|
||||||
{
|
{
|
||||||
@ -273,6 +275,7 @@ void LoginTask::parseYggdrasilReply(QByteArray data)
|
|||||||
playerID = selectedProfileO.value("id").toString();
|
playerID = selectedProfileO.value("id").toString();
|
||||||
playerName = selectedProfileO.value("name").toString();
|
playerName = selectedProfileO.value("name").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString sessionID = "token:" + accessToken + ":" + playerID;
|
QString sessionID = "token:" + accessToken + ":" + playerID;
|
||||||
/*
|
/*
|
||||||
struct LoginResponse
|
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();
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "logic/tasks/Task.h"
|
#include "logic/tasks/Task.h"
|
||||||
#include <QSharedPointer>
|
#include <QMap>
|
||||||
|
|
||||||
struct UserInfo
|
struct PasswordLogin
|
||||||
{
|
{
|
||||||
QString username;
|
QString username;
|
||||||
QString password;
|
QString password;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct User
|
||||||
|
{
|
||||||
|
QString id;
|
||||||
|
QMap<QString, QString> properties;
|
||||||
|
};
|
||||||
|
|
||||||
struct LoginResponse
|
struct LoginResponse
|
||||||
{
|
{
|
||||||
QString username;
|
QString username;
|
||||||
@ -31,6 +37,7 @@ struct LoginResponse
|
|||||||
QString player_name;
|
QString player_name;
|
||||||
QString player_id;
|
QString player_id;
|
||||||
QString access_token;
|
QString access_token;
|
||||||
|
User user; // FIXME: no idea what this really is yet. anything relevant?
|
||||||
};
|
};
|
||||||
|
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
@ -39,7 +46,7 @@ class LoginTask : public Task
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit LoginTask(const UserInfo &uInfo, QObject *parent = 0);
|
explicit LoginTask(const PasswordLogin &loginInfo, QObject *parent = 0);
|
||||||
LoginResponse getResult()
|
LoginResponse getResult()
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
@ -65,5 +72,5 @@ protected:
|
|||||||
|
|
||||||
LoginResponse result;
|
LoginResponse result;
|
||||||
QNetworkReply *netReply;
|
QNetworkReply *netReply;
|
||||||
UserInfo uInfo;
|
PasswordLogin loginInfo;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user