summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-11-28 22:05:58 -0600
committerAndrew <forkk@forkk.net>2013-11-28 22:05:58 -0600
commit0395474a0c3b40d4ef688e5d726a6519b3b2a620 (patch)
treee1e9cb5c96f23ce3e430a3e8316fd81cd3278f2b
parentf3a9dde52e99385eba01c9356ed8ef9548833e34 (diff)
downloadMultiMC-0395474a0c3b40d4ef688e5d726a6519b3b2a620.tar
MultiMC-0395474a0c3b40d4ef688e5d726a6519b3b2a620.tar.gz
MultiMC-0395474a0c3b40d4ef688e5d726a6519b3b2a620.tar.lz
MultiMC-0395474a0c3b40d4ef688e5d726a6519b3b2a620.tar.xz
MultiMC-0395474a0c3b40d4ef688e5d726a6519b3b2a620.zip
Nuke dead code
-rw-r--r--CMakeLists.txt5
-rw-r--r--gui/dialogs/LoginDialog.cpp216
-rw-r--r--gui/dialogs/LoginDialog.h61
-rw-r--r--gui/dialogs/LoginDialog.ui186
-rw-r--r--logic/InstanceLauncher.cpp5
-rw-r--r--logic/net/LoginTask.cpp293
-rw-r--r--logic/net/LoginTask.h76
7 files changed, 3 insertions, 839 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a8038fff..dfce1fad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -193,8 +193,6 @@ gui/dialogs/CopyInstanceDialog.h
gui/dialogs/CopyInstanceDialog.cpp
gui/dialogs/dialogs/
gui/dialogs/NewInstanceDialog.cpp
-gui/dialogs/LoginDialog.h
-gui/dialogs/LoginDialog.cpp
gui/dialogs/ProgressDialog.h
gui/dialogs/ProgressDialog.cpp
gui/dialogs/AboutDialog.h
@@ -270,8 +268,6 @@ logic/net/NetJob.h
logic/net/NetJob.cpp
logic/net/HttpMetaCache.h
logic/net/HttpMetaCache.cpp
-logic/net/LoginTask.h
-logic/net/LoginTask.cpp
logic/net/S3ListBucket.h
logic/net/S3ListBucket.cpp
@@ -369,7 +365,6 @@ gui/ConsoleWindow.ui
gui/dialogs/SettingsDialog.ui
gui/dialogs/CopyInstanceDialog.ui
gui/dialogs/NewInstanceDialog.ui
-gui/dialogs/LoginDialog.ui
gui/dialogs/AboutDialog.ui
gui/dialogs/VersionSelectDialog.ui
gui/dialogs/LwjglSelectDialog.ui
diff --git a/gui/dialogs/LoginDialog.cpp b/gui/dialogs/LoginDialog.cpp
deleted file mode 100644
index 28bbb1ee..00000000
--- a/gui/dialogs/LoginDialog.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "LoginDialog.h"
-#include "ui_LoginDialog.h"
-#include "keyring.h"
-#include "gui/Platform.h"
-#include "MultiMC.h"
-#include "logic/SkinUtils.h"
-
-#include <QFile>
-#include <QJsonObject>
-#include <QJsonArray>
-#include <QJsonParseError>
-#include "logic/net/HttpMetaCache.h"
-#include "logger/QsLog.h"
-
-LoginDialog::LoginDialog(QWidget *parent, const QString &loginErrMsg)
- : QDialog(parent), ui(new Ui::LoginDialog)
-{
- MultiMCPlatform::fixWM_CLASS(this);
- ui->setupUi(this);
-
- //: Use offline mode one time
- offlineButton = new QPushButton(tr("Offline Once"));
-
- ui->loginButtonBox->addButton(offlineButton, QDialogButtonBox::ActionRole);
-
- blockToggles = false;
- isOnline_ = true;
- onlineForced = false;
-
- //: The username during login (placeholder)
- ui->usernameTextBox->lineEdit()->setPlaceholderText(tr("Name"));
-
- connect(ui->usernameTextBox, SIGNAL(currentTextChanged(QString)), this,
- SLOT(userTextChanged(QString)));
- connect(ui->forgetButton, SIGNAL(clicked(bool)), this, SLOT(forgetCurrentUser()));
- connect(offlineButton, SIGNAL(clicked(bool)), this, SLOT(launchOffline()));
-
- if (loginErrMsg.isEmpty())
- ui->loginErrorLabel->setVisible(false);
- else
- {
- ui->loginErrorLabel->setVisible(true);
- ui->loginErrorLabel->setText(
- QString("<span style=\" color:#ff0000;\">%1</span>").arg(loginErrMsg));
- }
-
- ui->lblFace->setVisible(false);
-
- resize(minimumSizeHint());
- layout()->setSizeConstraint(QLayout::SetFixedSize);
- Keyring *k = Keyring::instance();
- QStringList accounts = k->getStoredAccounts("minecraft");
- ui->usernameTextBox->addItems(accounts);
-
- // TODO: restore last selected account here, if applicable
-
- int index = ui->usernameTextBox->currentIndex();
- if (index != -1)
- {
- ui->passwordTextBox->setFocus(Qt::OtherFocusReason);
- }
-
- connect(ui->rememberUsernameCheckbox, SIGNAL(toggled(bool)), SLOT(usernameToggled(bool)));
- connect(ui->rememberPasswordCheckbox, SIGNAL(toggled(bool)), SLOT(passwordToggled(bool)));
-}
-
-LoginDialog::~LoginDialog()
-{
- delete offlineButton;
- delete ui;
-}
-
-QString LoginDialog::getUsername() const
-{
- return ui->usernameTextBox->currentText();
-}
-
-QString LoginDialog::getPassword() const
-{
- return ui->passwordTextBox->text();
-}
-
-void LoginDialog::forgetCurrentUser()
-{
- Keyring *k = Keyring::instance();
- QString acct = ui->usernameTextBox->currentText();
- k->removeStoredAccount("minecraft", acct);
- ui->passwordTextBox->clear();
- int index = ui->usernameTextBox->findText(acct);
- if (index != -1)
- ui->usernameTextBox->removeItem(index);
- if (!ui->usernameTextBox->count())
- {
- blockToggles = true;
- ui->rememberUsernameCheckbox->setChecked(false);
- ui->rememberPasswordCheckbox->setChecked(false);
- blockToggles = false;
- }
-}
-
-void LoginDialog::passwordToggled(bool state)
-{
- // if toggled off
- if (blockToggles)
- return;
- blockToggles = true;
- if (!state)
- {
- QLOG_DEBUG() << "password disabled";
- }
- else
- {
- if (!ui->rememberUsernameCheckbox->isChecked())
- {
- ui->rememberUsernameCheckbox->setChecked(true);
- }
- QLOG_DEBUG() << "password enabled";
- }
- blockToggles = false;
-}
-
-void LoginDialog::usernameToggled(bool state)
-{
- // if toggled off
- if (blockToggles)
- return;
- blockToggles = true;
- if (!state)
- {
- if (ui->rememberPasswordCheckbox->isChecked())
- {
- ui->rememberPasswordCheckbox->setChecked(false);
- }
- QLOG_DEBUG() << "username disabled";
- }
- else
- {
- QLOG_DEBUG() << "username enabled";
- }
- blockToggles = false;
-}
-
-void LoginDialog::userTextChanged(const QString &user)
-{
- blockToggles = true;
- Keyring *k = Keyring::instance();
- QStringList sl = k->getStoredAccounts("minecraft");
- bool gotFace = false;
-
- if (sl.contains(user))
- {
- ui->rememberUsernameCheckbox->setChecked(true);
- QString passwd = k->getPassword("minecraft", user);
- ui->rememberPasswordCheckbox->setChecked(!passwd.isEmpty());
- ui->passwordTextBox->setText(passwd);
-
- QPixmap face = SkinUtils::getFaceFromCache(user);
- gotFace = !face.isNull();
-
- if(gotFace) ui->lblFace->setPixmap(face);
- }
-
- ui->lblFace->setVisible(gotFace);
- blockToggles = false;
-}
-
-void LoginDialog::accept()
-{
- bool saveName = ui->rememberUsernameCheckbox->isChecked();
- bool savePass = ui->rememberPasswordCheckbox->isChecked();
- Keyring *k = Keyring::instance();
- if (saveName)
- {
- if (savePass)
- {
- k->storePassword("minecraft", getUsername(), getPassword());
- }
- else
- {
- k->storePassword("minecraft", getUsername(), QString());
- }
- }
- else
- {
- QString acct = ui->usernameTextBox->currentText();
- k->removeStoredAccount("minecraft", acct);
- }
- QDialog::accept();
-}
-
-void LoginDialog::launchOffline()
-{
- isOnline_ = false;
- QDialog::accept();
-}
-
-void LoginDialog::forceOnline()
-{
- onlineForced = true;
- offlineButton->setEnabled(false);
-}
diff --git a/gui/dialogs/LoginDialog.h b/gui/dialogs/LoginDialog.h
deleted file mode 100644
index 73a92aab..00000000
--- a/gui/dialogs/LoginDialog.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <QDialog>
-#include <QPushButton>
-
-namespace Ui
-{
-class LoginDialog;
-}
-
-class LoginDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit LoginDialog(QWidget *parent = 0, const QString &loginErrMsg = "");
- ~LoginDialog();
-
- QString getUsername() const;
- QString getPassword() const;
-
- inline bool isOnline()
- {
- return isOnline_;
- }
-
- void forceOnline();
-
-public
-slots:
- virtual void accept();
- virtual void userTextChanged(const QString &user);
- virtual void forgetCurrentUser();
-private
-slots:
- void usernameToggled(bool);
- void passwordToggled(bool);
- void launchOffline();
-
-private:
- Ui::LoginDialog *ui;
- bool blockToggles;
- QPushButton *offlineButton;
- bool isOnline_;
- bool onlineForced;
-};
diff --git a/gui/dialogs/LoginDialog.ui b/gui/dialogs/LoginDialog.ui
deleted file mode 100644
index 45f319ed..00000000
--- a/gui/dialogs/LoginDialog.ui
+++ /dev/null
@@ -1,186 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>LoginDialog</class>
- <widget class="QDialog" name="LoginDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>496</width>
- <height>168</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Login</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="loginErrorLabel">
- <property name="text">
- <string>&lt;span style=&quot; color:#ff0000;&quot;&gt;Error&lt;/span&gt;</string>
- </property>
- <property name="textInteractionFlags">
- <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="4" rowspan="2">
- <widget class="QLabel" name="lblFace">
- <property name="minimumSize">
- <size>
- <width>48</width>
- <height>48</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>48</width>
- <height>48</height>
- </size>
- </property>
- <property name="sizeIncrement">
- <size>
- <width>1</width>
- <height>1</height>
- </size>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="pixmap">
- <pixmap resource="../../graphics.qrc">:/icons/instances/steve</pixmap>
- </property>
- <property name="scaledContents">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="usernameTextBox">
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="usernameLabel">
- <property name="text">
- <string>Username:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="passwordLabel">
- <property name="text">
- <string>Password:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="passwordTextBox">
- <property name="echoMode">
- <enum>QLineEdit::Password</enum>
- </property>
- <property name="placeholderText">
- <string>Password</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="checkboxLayout">
- <item>
- <widget class="QCheckBox" name="rememberUsernameCheckbox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>&amp;Remember Username?</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="rememberPasswordCheckbox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>R&amp;emember Password?</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="forgetButton">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Forget</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="loginButtonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="../../graphics.qrc"/>
- <include location="../multimc.qrc"/>
- </resources>
- <connections>
- <connection>
- <sender>loginButtonBox</sender>
- <signal>accepted()</signal>
- <receiver>LoginDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>248</x>
- <y>254</y>
- </hint>
- <hint type="destinationlabel">
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>loginButtonBox</sender>
- <signal>rejected()</signal>
- <receiver>LoginDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>316</x>
- <y>260</y>
- </hint>
- <hint type="destinationlabel">
- <x>286</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/logic/InstanceLauncher.cpp b/logic/InstanceLauncher.cpp
index 0ef0f045..c0079d80 100644
--- a/logic/InstanceLauncher.cpp
+++ b/logic/InstanceLauncher.cpp
@@ -19,10 +19,8 @@
#include "MultiMC.h"
#include "gui/ConsoleWindow.h"
-#include "gui/dialogs/LoginDialog.h"
#include "gui/dialogs/ProgressDialog.h"
-#include "logic/net/LoginTask.h"
#include "logic/MinecraftProcess.h"
#include "logic/lists/InstanceList.h"
@@ -59,6 +57,8 @@ void InstanceLauncher::onLoginComplete()
void InstanceLauncher::doLogin(const QString &errorMsg)
{
+ // FIXME: Use new account system here...
+ /*
LoginDialog *loginDlg = new LoginDialog(nullptr, errorMsg);
loginDlg->exec();
if (loginDlg->result() == QDialog::Accepted)
@@ -72,6 +72,7 @@ void InstanceLauncher::doLogin(const QString &errorMsg)
Qt::QueuedConnection);
tDialog->exec(loginTask);
}
+ */
// onLoginComplete(LoginResponse("Offline","Offline", 1));
}
diff --git a/logic/net/LoginTask.cpp b/logic/net/LoginTask.cpp
deleted file mode 100644
index 5607447e..00000000
--- a/logic/net/LoginTask.cpp
+++ /dev/null
@@ -1,293 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "LoginTask.h"
-#include "MultiMC.h"
-#include <settingsobject.h>
-
-#include <QStringList>
-
-#include <QNetworkReply>
-#include <QNetworkRequest>
-
-#include <QUrl>
-#include <QUrlQuery>
-#include <QJsonParseError>
-#include <QJsonObject>
-
-LoginTask::LoginTask(const PasswordLogin &loginInfo, QObject *parent)
- : Task(parent), loginInfo(loginInfo)
-{
-}
-
-void LoginTask::executeTask()
-{
- yggdrasilLogin();
-}
-
-void LoginTask::legacyLogin()
-{
- setStatus(tr("Logging in..."));
- auto worker = MMC->qnam();
- connect(worker.get(), SIGNAL(finished(QNetworkReply *)), this,
- SLOT(processLegacyReply(QNetworkReply *)));
-
- QUrl loginURL("https://login.minecraft.net/");
- QNetworkRequest netRequest(loginURL);
- netRequest.setHeader(QNetworkRequest::ContentTypeHeader,
- "application/x-www-form-urlencoded");
-
- QUrlQuery params;
- params.addQueryItem("user", loginInfo.username);
- params.addQueryItem("password", loginInfo.password);
- params.addQueryItem("version", "13");
-
- netReply = worker->post(netRequest, params.query(QUrl::EncodeSpaces).toUtf8());
-}
-
-void LoginTask::parseLegacyReply(QByteArray data)
-{
- QString responseStr = QString::fromUtf8(data);
-
- QStringList strings = responseStr.split(":");
- if (strings.count() >= 4)
- {
- // strings[1] is the download ticket. It isn't used anymore.
- QString username = strings[2];
- QString sessionID = strings[3];
- /*
- struct LoginResponse
- {
- QString username;
- QString session_id;
- QString player_name;
- QString player_id;
- QString client_id;
- };
- */
- result = {username, sessionID, username, QString()};
- emitSucceeded();
- }
- else
- {
- if (responseStr.toLower() == "bad login")
- emitFailed(tr("Invalid username or password."));
- else if (responseStr.toLower() == "old version")
- emitFailed(tr("Launcher outdated, please update."));
- else
- emitFailed(tr("Login failed: %1").arg(responseStr));
- }
-}
-
-void LoginTask::processLegacyReply(QNetworkReply *reply)
-{
- processReply(reply, &LoginTask::parseLegacyReply, &LoginTask::parseLegacyError);
-}
-
-void LoginTask::processYggdrasilReply(QNetworkReply *reply)
-{
- processReply(reply, &LoginTask::parseYggdrasilReply, &LoginTask::parseYggdrasilError);
-}
-
-void LoginTask::processReply(QNetworkReply *reply,
- std::function<void(LoginTask *, QByteArray)> parser,
- std::function<QString(LoginTask *, QNetworkReply *)> errorHandler)
-{
- if (netReply != reply)
- return;
- // Check for errors.
- switch (reply->error())
- {
- case QNetworkReply::NoError:
- {
- // Check the response code.
- int responseCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
-
- switch (responseCode)
- {
- case 200:
- parser(this, reply->readAll());
- break;
-
- default:
- emitFailed(tr("Login failed: Unknown HTTP code %1 encountered.").arg(responseCode));
- break;
- }
-
- break;
- }
-
- case QNetworkReply::OperationCanceledError:
- emitFailed(tr("Login canceled."));
- break;
-
- default:
- emitFailed(errorHandler(this, reply));
- break;
- }
-}
-
-QString LoginTask::parseLegacyError(QNetworkReply *reply)
-{
- int responseCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
-
- switch (responseCode)
- {
- case 403:
- return tr("Invalid username or password.");
-
- case 503:
- return tr("The login servers are currently unavailable. Check "
- "http://help.mojang.com/ for more info.");
-
- default:
- QLOG_DEBUG() << "Login failed with QNetworkReply code:" << reply->error();
- return tr("Login failed: %1").arg(reply->errorString());
- }
-}
-
-QString LoginTask::parseYggdrasilError(QNetworkReply *reply)
-{
- QByteArray data = reply->readAll();
- QJsonParseError jsonError;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
-
- // If there are JSON errors fall back to using the legacy error handling using HTTP status
- // codes
- if (jsonError.error != QJsonParseError::NoError)
- {
- return parseLegacyError(reply);
- }
-
- if (!jsonDoc.isObject())
- {
- return parseLegacyError(reply);
- }
-
- QJsonObject root = jsonDoc.object();
-
- // QString error = root.value("error").toString();
- QString errorMessage = root.value("errorMessage").toString();
-
- if (errorMessage.isEmpty())
- {
- return parseLegacyError(reply);
- }
-
- return tr("Login failed: ") + errorMessage;
-}
-
-void LoginTask::yggdrasilLogin()
-{
- setStatus(tr("Logging in..."));
- auto worker = MMC->qnam();
- connect(worker.get(), SIGNAL(finished(QNetworkReply *)), this,
- SLOT(processYggdrasilReply(QNetworkReply *)));
-
- /*
- {
- // agent def. version might be incremented at some point
- "agent":{"name":"Minecraft","version":1},
- "username": "mojang account name",
- "password": "mojang account password",
- // client token is optional. but we supply one anyway
- "clientToken": "client identifier"
- }
- */
-
- QUrl loginURL("https://authserver.mojang.com/authenticate");
- QNetworkRequest netRequest(loginURL);
- netRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
-
- auto settings = MMC->settings();
- QString clientToken = settings->get("YggdrasilClientToken").toString();
- // escape the {}
- clientToken.remove('{');
- clientToken.remove('}');
- // create the request
- QJsonObject root;
- QJsonObject agent;
- agent.insert("name", QString("Minecraft"));
- agent.insert("version", QJsonValue(1));
- root.insert("agent", agent);
- root.insert("username", loginInfo.username);
- root.insert("password", loginInfo.password);
- root.insert("clientToken", clientToken);
- QJsonDocument requestDoc(root);
- netReply = worker->post(netRequest, requestDoc.toJson());
-}
-
-/*
-{
- "accessToken": "random access token", // hexadecimal
- "clientToken": "client identifier", // identical to the one received
- "availableProfiles": [ // only present if the agent field was received
- {
- "id": "profile identifier", // hexadecimal
- "name": "player name"
- }
- ],
- "selectedProfile": { // only present if the agent field was received
- "id": "profile identifier",
- "name": "player name"
- }
-}
-*/
-void LoginTask::parseYggdrasilReply(QByteArray data)
-{
- QJsonParseError jsonError;
- QLOG_DEBUG() << data;
- QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError);
- if (jsonError.error != QJsonParseError::NoError)
- {
- emitFailed(tr("Login failed: %1").arg(jsonError.errorString()));
- return;
- }
-
- if (!jsonDoc.isObject())
- {
- emitFailed(tr("Login failed: BAD FORMAT #1"));
- return;
- }
-
- QJsonObject root = jsonDoc.object();
-
- QString accessToken = root.value("accessToken").toString();
- QString clientToken = root.value("clientToken").toString();
- QString playerID;
- QString playerName;
- auto selectedProfile = root.value("selectedProfile");
- if (selectedProfile.isObject())
- {
- auto selectedProfileO = selectedProfile.toObject();
- playerID = selectedProfileO.value("id").toString();
- playerName = selectedProfileO.value("name").toString();
- }
-
- QString sessionID = "token:" + accessToken + ":" + playerID;
- /*
- struct LoginResponse
- {
- QString username;
- QString session_id;
- QString player_name;
- QString player_id;
- QString client_id;
- };
- */
-
- result = {loginInfo.username, sessionID, playerName, playerID, accessToken};
- emitSucceeded();
-}
diff --git a/logic/net/LoginTask.h b/logic/net/LoginTask.h
deleted file mode 100644
index fe4e6d2f..00000000
--- a/logic/net/LoginTask.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include "logic/tasks/Task.h"
-#include <QMap>
-
-struct PasswordLogin
-{
- QString username;
- QString password;
-};
-
-struct User
-{
- QString id;
- QMap<QString, QString> properties;
-};
-
-struct LoginResponse
-{
- QString username;
- QString session_id; // session id is a combination of player id and the access token
- QString player_name;
- QString player_id;
- QString access_token;
- User user; // FIXME: no idea what this really is yet. anything relevant?
-};
-
-class QNetworkReply;
-
-class LoginTask : public Task
-{
- Q_OBJECT
-public:
- explicit LoginTask(const PasswordLogin &loginInfo, QObject *parent = 0);
- LoginResponse getResult()
- {
- return result;
- }
-
-protected
-slots:
- void legacyLogin();
- void processLegacyReply(QNetworkReply *reply);
- void parseLegacyReply(QByteArray data);
- QString parseLegacyError(QNetworkReply *reply);
-
- void yggdrasilLogin();
- void processYggdrasilReply(QNetworkReply *reply);
- void parseYggdrasilReply(QByteArray data);
- QString parseYggdrasilError(QNetworkReply *reply);
-
- void processReply(QNetworkReply *reply, std::function<void(LoginTask *, QByteArray)>,
- std::function<QString(LoginTask *, QNetworkReply *)>);
-
-protected:
- void executeTask();
-
- LoginResponse result;
- QNetworkReply *netReply;
- PasswordLogin loginInfo;
-};