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)
|
||||
{
|
||||
UserInfo uInfo{username, password};
|
||||
PasswordLogin uInfo{username, password};
|
||||
|
||||
ProgressDialog *tDialog = new ProgressDialog(this);
|
||||
LoginTask *loginTask = new LoginTask(uInfo, tDialog);
|
||||
|
@ -63,7 +63,7 @@ void InstanceLauncher::doLogin(const QString &errorMsg)
|
||||
loginDlg->exec();
|
||||
if (loginDlg->result() == QDialog::Accepted)
|
||||
{
|
||||
UserInfo uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
|
||||
PasswordLogin uInfo{loginDlg->getUsername(), loginDlg->getPassword()};
|
||||
|
||||
ProgressDialog *tDialog = new ProgressDialog(nullptr);
|
||||
LoginTask *loginTask = new LoginTask(uInfo, tDialog);
|
||||
|
@ -93,6 +93,8 @@ QStringList OneSixInstance::processMinecraftArgs(LoginResponse response)
|
||||
token_mapping["game_directory"] = absRootDir;
|
||||
QString absAssetsDir = QDir("assets/").absolutePath();
|
||||
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);
|
||||
for (int i = 0; i < parts.length(); i++)
|
||||
|
@ -16,7 +16,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "logic/OneSixLibrary.h"
|
||||
|
||||
|
@ -151,7 +151,7 @@ std::shared_ptr<OneSixVersion> OneSixVersion::fromJson(QJsonObject root)
|
||||
root.value("minimumLauncherVersion").toDouble();
|
||||
|
||||
// ADD MORE HERE :D
|
||||
if (launcher_ver > 0 && launcher_ver <= 9)
|
||||
if (launcher_ver > 0 && launcher_ver <= 10)
|
||||
return fromJsonV4(root, readVersion);
|
||||
else
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <QAbstractListModel>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "logic/BaseVersion.h"
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractListModel>
|
||||
#include <QSharedPointer>
|
||||
#include <QUrl>
|
||||
|
||||
#include <QNetworkReply>
|
||||
|
@ -16,7 +16,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QAbstractListModel>
|
||||
#include "categorizedsortfilterproxymodel.h"
|
||||
#include <QIcon>
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractListModel>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "BaseVersionList.h"
|
||||
#include "logic/tasks/Task.h"
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "BaseVersionList.h"
|
||||
#include "logic/tasks/Task.h"
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#pragma once
|
||||
#include <QString>
|
||||
#include <QSharedPointer>
|
||||
#include <QMap>
|
||||
#include <qtimer.h>
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user