diff options
27 files changed, 471 insertions, 299 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e8292ce6..a33e4736 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -276,11 +276,14 @@ logic/auth/MojangAccount.h logic/auth/MojangAccount.cpp logic/auth/YggdrasilTask.h logic/auth/YggdrasilTask.cpp -logic/auth/AuthenticateTask.h -logic/auth/AuthenticateTask.cpp -logic/auth/ValidateTask.h -logic/auth/ValidateTask.cpp - +logic/auth/flows/AuthenticateTask.h +logic/auth/flows/AuthenticateTask.cpp +logic/auth/flows/RefreshTask.cpp +logic/auth/flows/RefreshTask.cpp +logic/auth/flows/ValidateTask.h +logic/auth/flows/ValidateTask.cpp +logic/auth/flows/InvalidateTask.h +logic/auth/flows/InvalidateTask.cpp # legacy instances logic/LegacyInstance.h @@ -592,5 +595,3 @@ endif (UPDATE_TRANSLATIONS) add_custom_target (translations DEPENDS ${QM_FILES}) install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/translations) - - diff --git a/gui/ConsoleWindow.cpp b/gui/ConsoleWindow.cpp index d8a1b69d..d0210df6 100644 --- a/gui/ConsoleWindow.cpp +++ b/gui/ConsoleWindow.cpp @@ -58,13 +58,23 @@ void ConsoleWindow::writeColor(QString text, const char *color) ui->text->appendHtml(QString("<font color=\"%1\">%2</font>").arg(color).arg(text)); else ui->text->appendPlainText(text); - // scroll down - QScrollBar *bar = ui->text->verticalScrollBar(); - bar->setValue(bar->maximum()); } void ConsoleWindow::write(QString data, MessageLevel::Enum mode) { + QScrollBar *bar = ui->text->verticalScrollBar(); + int max_bar = bar->maximum(); + int val_bar = bar->value(); + if(m_scroll_active) + { + if(m_last_scroll_value > val_bar) + m_scroll_active = false; + } + else + { + m_scroll_active = val_bar == max_bar; + } + if (data.endsWith('\n')) data = data.left(data.length() - 1); QStringList paragraphs = data.split('\n'); @@ -93,6 +103,11 @@ void ConsoleWindow::write(QString data, MessageLevel::Enum mode) else while (iter.hasNext()) writeColor(iter.next()); + if(m_scroll_active) + { + bar->setValue(bar->maximum()); + } + m_last_scroll_value = bar->value(); } void ConsoleWindow::clear() diff --git a/gui/ConsoleWindow.h b/gui/ConsoleWindow.h index e0a47bc6..2d948484 100644 --- a/gui/ConsoleWindow.h +++ b/gui/ConsoleWindow.h @@ -38,6 +38,16 @@ public: */ void setMayClose(bool mayclose); +private: + /** + * @brief write a colored paragraph + * @param data the string + * @param color the css color name + * this will only insert a single paragraph. + * \n are ignored. a real \n is always appended. + */ + void writeColor(QString data, const char *color = nullptr); + signals: void isClosing(); @@ -52,15 +62,6 @@ slots: void write(QString data, MessageLevel::Enum level = MessageLevel::MultiMC); /** - * @brief write a colored paragraph - * @param data the string - * @param color the css color name - * this will only insert a single paragraph. - * \n are ignored. a real \n is always appended. - */ - void writeColor(QString data, const char *color = nullptr); - - /** * @brief clear the text widget */ void clear(); @@ -82,4 +83,6 @@ private: Ui::ConsoleWindow *ui = nullptr; MinecraftProcess *proc = nullptr; bool m_mayclose = true; + int m_last_scroll_value = 0; + bool m_scroll_active = true; }; diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index a3394a82..854091c6 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -69,8 +69,9 @@ #include "logic/lists/IconList.h" #include "logic/lists/JavaVersionList.h" -#include "logic/auth/AuthenticateTask.h" -#include "logic/auth/ValidateTask.h" +#include "logic/auth/flows/AuthenticateTask.h" +#include "logic/auth/flows/RefreshTask.h" +#include "logic/auth/flows/ValidateTask.h" #include "logic/BaseInstance.h" #include "logic/InstanceFactory.h" @@ -276,7 +277,6 @@ MainWindow::~MainWindow() delete assets_downloader; } - void MainWindow::repopulateAccountsMenu() { accountMenu->clear(); @@ -791,16 +791,16 @@ void MainWindow::doLaunchInst(BaseInstance* instance, MojangAccountPtr account) { // We'll need to validate the access token to make sure the account is still logged in. ProgressDialog progDialog(this); - ValidateTask validateTask(account, &progDialog); - progDialog.exec(&validateTask); - - if (validateTask.successful()) + RefreshTask refreshtask(account, &progDialog); + progDialog.exec(&refreshtask); + + if (refreshtask.successful()) { prepareLaunch(m_selectedInstance, account); } else { - YggdrasilTask::Error* error = validateTask.getError(); + YggdrasilTask::Error *error = refreshtask.getError(); if (error != nullptr) { @@ -812,17 +812,20 @@ void MainWindow::doLaunchInst(BaseInstance* instance, MojangAccountPtr account) } else { - CustomMessageBox::selectable(this, tr("Access Token Validation Error"), + CustomMessageBox::selectable( + this, tr("Access Token Validation Error"), tr("There was an error when trying to validate your access token.\n" - "Details: %s").arg(error->getDisplayMessage()), + "Details: %s").arg(error->getDisplayMessage()), QMessageBox::Warning, QMessageBox::Ok)->exec(); } } else { - CustomMessageBox::selectable(this, tr("Access Token Validation Error"), + CustomMessageBox::selectable( + this, tr("Access Token Validation Error"), tr("There was an unknown error when trying to validate your access token." - "The authentication server might be down, or you might not be connected to the Internet."), + "The authentication server might be down, or you might not be connected to " + "the Internet."), QMessageBox::Warning, QMessageBox::Ok)->exec(); } } @@ -879,10 +882,7 @@ void MainWindow::launchInstance(BaseInstance *instance, MojangAccountPtr account console = new ConsoleWindow(proc); connect(console, SIGNAL(isClosing()), this, SLOT(instanceEnded())); - // I think this will work... - QString username = account->username(); - QString session_id = account->accessToken(); - proc->setLogin(username, session_id); + proc->setLogin(account); proc->launch(); } diff --git a/gui/dialogs/AccountListDialog.cpp b/gui/dialogs/AccountListDialog.cpp index dfac4989..f5268b61 100644 --- a/gui/dialogs/AccountListDialog.cpp +++ b/gui/dialogs/AccountListDialog.cpp @@ -20,7 +20,7 @@ #include <logger/QsLog.h> -#include <logic/auth/AuthenticateTask.h> +#include <logic/auth/flows/AuthenticateTask.h> #include <logic/net/NetJob.h> #include <gui/dialogs/EditAccountDialog.h> @@ -29,9 +29,8 @@ #include <MultiMC.h> -AccountListDialog::AccountListDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::AccountListDialog) +AccountListDialog::AccountListDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::AccountListDialog) { ui->setupUi(this); @@ -44,8 +43,8 @@ AccountListDialog::AccountListDialog(QWidget *parent) : connect(selectionModel, &QItemSelectionModel::selectionChanged, [this] (const QItemSelection& sel, const QItemSelection& dsel) { updateButtonStates(); }); - connect(m_accounts.get(), SIGNAL(listChanged), SLOT(listChanged)); - connect(m_accounts.get(), SIGNAL(activeAccountChanged), SLOT(listChanged)); + connect(m_accounts.get(), SIGNAL(listChanged()), SLOT(listChanged())); + connect(m_accounts.get(), SIGNAL(activeAccountChanged()), SLOT(listChanged())); updateButtonStates(); } @@ -60,7 +59,6 @@ void AccountListDialog::listChanged() updateButtonStates(); } - void AccountListDialog::on_addAccountBtn_clicked() { addAccount(tr("Please enter your Mojang or Minecraft account username and password to add your account.")); @@ -84,7 +82,7 @@ void AccountListDialog::on_setDefaultBtn_clicked() QModelIndex selected = selection.first(); MojangAccountPtr account = selected.data(MojangAccountList::PointerRole).value<MojangAccountPtr>(); m_accounts->setActiveAccount(account->username()); - } + } } void AccountListDialog::on_noDefaultBtn_clicked() @@ -104,7 +102,7 @@ void AccountListDialog::updateButtonStates() ui->rmAccountBtn->setEnabled(selection.size() > 0); ui->setDefaultBtn->setEnabled(selection.size() > 0); - + ui->noDefaultBtn->setDown(m_accounts->activeAccount().get() == nullptr); } @@ -146,4 +144,3 @@ void AccountListDialog::addAccount(const QString& errMsg) } } } - diff --git a/gui/dialogs/AccountListDialog.h b/gui/dialogs/AccountListDialog.h index 634d944a..84ff8e0e 100644 --- a/gui/dialogs/AccountListDialog.h +++ b/gui/dialogs/AccountListDialog.h @@ -21,7 +21,8 @@ #include "logic/lists/MojangAccountList.h" -namespace Ui { +namespace Ui +{ class AccountListDialog; } @@ -29,7 +30,7 @@ class AuthenticateTask; class AccountListDialog : public QDialog { -Q_OBJECT + Q_OBJECT public: explicit AccountListDialog(QWidget *parent = 0); ~AccountListDialog(); @@ -62,4 +63,3 @@ slots: private: Ui::AccountListDialog *ui; }; - diff --git a/gui/dialogs/AccountSelectDialog.cpp b/gui/dialogs/AccountSelectDialog.cpp index db1bd192..b8fa9e42 100644 --- a/gui/dialogs/AccountSelectDialog.cpp +++ b/gui/dialogs/AccountSelectDialog.cpp @@ -20,15 +20,14 @@ #include <logger/QsLog.h> -#include <logic/auth/AuthenticateTask.h> +#include <logic/auth/flows/AuthenticateTask.h> #include <gui/dialogs/ProgressDialog.h> #include <MultiMC.h> -AccountSelectDialog::AccountSelectDialog(const QString& message, int flags, QWidget *parent) : - QDialog(parent), - ui(new Ui::AccountSelectDialog) +AccountSelectDialog::AccountSelectDialog(const QString &message, int flags, QWidget *parent) + : QDialog(parent), ui(new Ui::AccountSelectDialog) { ui->setupUi(this); @@ -85,4 +84,3 @@ void AccountSelectDialog::on_buttonBox_rejected() { close(); } - diff --git a/gui/dialogs/AccountSelectDialog.h b/gui/dialogs/AccountSelectDialog.h index 41af4f7c..a539e7e9 100644 --- a/gui/dialogs/AccountSelectDialog.h +++ b/gui/dialogs/AccountSelectDialog.h @@ -21,17 +21,18 @@ #include "logic/lists/MojangAccountList.h" -namespace Ui { +namespace Ui +{ class AccountSelectDialog; } class AccountSelectDialog : public QDialog { -Q_OBJECT + Q_OBJECT public: enum Flags { - NoFlags=0, + NoFlags = 0, /*! * Shows a check box on the dialog that allows the user to specify that the account @@ -75,7 +76,7 @@ public: public slots: void on_buttonBox_accepted(); - + void on_buttonBox_rejected(); protected: @@ -87,4 +88,3 @@ protected: private: Ui::AccountSelectDialog *ui; }; - diff --git a/gui/dialogs/EditAccountDialog.cpp b/gui/dialogs/EditAccountDialog.cpp index d28336f7..dd3f0523 100644 --- a/gui/dialogs/EditAccountDialog.cpp +++ b/gui/dialogs/EditAccountDialog.cpp @@ -16,11 +16,10 @@ #include "EditAccountDialog.h" #include "ui_EditAccountDialog.h" -EditAccountDialog::EditAccountDialog(const QString& text, QWidget *parent, int flags) : - QDialog(parent), - ui(new Ui::EditAccountDialog) +EditAccountDialog::EditAccountDialog(const QString &text, QWidget *parent, int flags) + : QDialog(parent), ui(new Ui::EditAccountDialog) { - ui->setupUi(this); + ui->setupUi(this); ui->label->setText(text); ui->label->setVisible(!text.isEmpty()); @@ -31,7 +30,7 @@ EditAccountDialog::EditAccountDialog(const QString& text, QWidget *parent, int f EditAccountDialog::~EditAccountDialog() { - delete ui; + delete ui; } QString EditAccountDialog::username() const @@ -43,4 +42,3 @@ QString EditAccountDialog::password() const { return ui->passTextBox->text(); } - diff --git a/gui/dialogs/EditAccountDialog.h b/gui/dialogs/EditAccountDialog.h index 847c3be5..be3a88d8 100644 --- a/gui/dialogs/EditAccountDialog.h +++ b/gui/dialogs/EditAccountDialog.h @@ -17,16 +17,18 @@ #include <QDialog> -namespace Ui { +namespace Ui +{ class EditAccountDialog; } class EditAccountDialog : public QDialog { -Q_OBJECT + Q_OBJECT public: - explicit EditAccountDialog(const QString& text="", QWidget *parent = 0, int flags=UsernameField | PasswordField); + explicit EditAccountDialog(const QString &text = "", QWidget *parent = 0, + int flags = UsernameField | PasswordField); ~EditAccountDialog(); /*! @@ -41,7 +43,7 @@ public: enum Flags { - NoFlags=0, + NoFlags = 0, //! Specifies that the dialog should have a username field. UsernameField, @@ -53,4 +55,3 @@ public: private: Ui::EditAccountDialog *ui; }; - diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp index e4a26054..aedd4027 100644 --- a/logic/MinecraftProcess.cpp +++ b/logic/MinecraftProcess.cpp @@ -71,6 +71,26 @@ void MinecraftProcess::setWorkdir(QString path) m_prepostlaunchprocess.setWorkingDirectory(mcDir.absolutePath()); } +QString MinecraftProcess::censorPrivateInfo(QString in) +{ + if(!m_account) + return in; + else + { + QString sessionId = m_account->sessionId(); + QString accessToken = m_account->accessToken(); + QString clientToken = m_account->clientToken(); + QString profileId = m_account->currentProfile()->id(); + QString profileName = m_account->currentProfile()->name(); + in.replace(sessionId, "<SESSION ID>"); + in.replace(accessToken, "<ACCESS TOKEN>"); + in.replace(clientToken, "<CLIENT TOKEN>"); + in.replace(clientToken, "<PROFILE ID>"); + in.replace(clientToken, "<PROFILE NAME>"); + return in; + } +} + // console window void MinecraftProcess::on_stdErr() { @@ -83,8 +103,7 @@ void MinecraftProcess::on_stdErr() for (int i = 0; i < lines.size() - 1; i++) { QString &line = lines[i]; - emit log(line /*.replace(username, "<Username>").replace(sessionID, "<Session ID>")*/, - getLevel(line, MessageLevel::Error)); + emit log(censorPrivateInfo(line), getLevel(line, MessageLevel::Error)); } if (!complete) m_err_leftover = lines.last(); @@ -101,8 +120,7 @@ void MinecraftProcess::on_stdOut() for (int i = 0; i < lines.size() - 1; i++) { QString &line = lines[i]; - emit log(line.replace(username, "<Username>").replace(sessionID, "<Session ID>"), - getLevel(line, MessageLevel::Message)); + emit log(censorPrivateInfo(line), getLevel(line, MessageLevel::Message)); } if (!complete) m_out_leftover = lines.last(); @@ -173,8 +191,8 @@ void MinecraftProcess::launch() emit log(QString("Minecraft folder is: '%1'").arg(workingDirectory())); QString JavaPath = m_instance->settings().get("JavaPath").toString(); emit log(QString("Java path: '%1'").arg(JavaPath)); - emit log(QString("Arguments: '%1'").arg( - m_args.join("' '").replace(username, "<Username>").replace(sessionID, "<Session ID>"))); + QString allArgs = m_args.join("' '"); + emit log(QString("Arguments: '%1'").arg(censorPrivateInfo(allArgs))); start(JavaPath, m_args); if (!waitForStarted()) { diff --git a/logic/MinecraftProcess.h b/logic/MinecraftProcess.h index e38d2f83..bd0151cc 100644 --- a/logic/MinecraftProcess.h +++ b/logic/MinecraftProcess.h @@ -69,10 +69,9 @@ public: void killMinecraft(); - inline void setLogin(QString user, QString sid) + inline void setLogin(MojangAccountPtr account) { - username = user; - sessionID = sid; + m_account = account; } signals: @@ -104,11 +103,13 @@ signals: void log(QString text, MessageLevel::Enum level = MessageLevel::MultiMC); protected: - BaseInstance *m_instance; + BaseInstance *m_instance = nullptr; QStringList m_args; QString m_err_leftover; QString m_out_leftover; QProcess m_prepostlaunchprocess; + bool killed = false; + MojangAccountPtr m_account; protected slots: @@ -117,8 +118,7 @@ slots: void on_stdOut(); private: - bool killed; + QString censorPrivateInfo(QString in); MessageLevel::Enum getLevel(const QString &message, MessageLevel::Enum defaultLevel); - QString sessionID; - QString username; + }; diff --git a/logic/auth/MojangAccount.cpp b/logic/auth/MojangAccount.cpp index 4f3839bc..4a61cf19 100644 --- a/logic/auth/MojangAccount.cpp +++ b/logic/auth/MojangAccount.cpp @@ -23,8 +23,7 @@ #include <logger/QsLog.h> -MojangAccount::MojangAccount(const QString& username, QObject* parent) : - QObject(parent) +MojangAccount::MojangAccount(const QString &username, QObject *parent) : QObject(parent) { // Generate a client token. m_clientToken = QUuid::createUuid().toString(); @@ -34,9 +33,9 @@ MojangAccount::MojangAccount(const QString& username, QObject* parent) : m_currentProfile = -1; } -MojangAccount::MojangAccount(const QString& username, const QString& clientToken, - const QString& accessToken, QObject* parent) : - QObject(parent) +MojangAccount::MojangAccount(const QString &username, const QString &clientToken, + const QString &accessToken, QObject *parent) + : QObject(parent) { m_username = username; m_clientToken = clientToken; @@ -45,7 +44,7 @@ MojangAccount::MojangAccount(const QString& username, const QString& clientToken m_currentProfile = -1; } -MojangAccount::MojangAccount(const MojangAccount& other, QObject* parent) +MojangAccount::MojangAccount(const MojangAccount &other, QObject *parent) { m_username = other.username(); m_clientToken = other.clientToken(); @@ -55,7 +54,6 @@ MojangAccount::MojangAccount(const MojangAccount& other, QObject* parent) m_currentProfile = other.m_currentProfile; } - QString MojangAccount::username() const { return m_username; @@ -66,18 +64,17 @@ QString MojangAccount::clientToken() const return m_clientToken; } -void MojangAccount::setClientToken(const QString& clientToken) +void MojangAccount::setClientToken(const QString &clientToken) { m_clientToken = clientToken; } - QString MojangAccount::accessToken() const { return m_accessToken; } -void MojangAccount::setAccessToken(const QString& accessToken) +void MojangAccount::setAccessToken(const QString &accessToken) { m_accessToken = accessToken; } @@ -92,7 +89,7 @@ const QList<AccountProfile> MojangAccount::profiles() const return m_profiles; } -const AccountProfile* MojangAccount::currentProfile() const +const AccountProfile *MojangAccount::currentProfile() const { if (m_currentProfile < 0) { @@ -105,9 +102,9 @@ const AccountProfile* MojangAccount::currentProfile() const return &m_profiles.at(m_currentProfile); } -bool MojangAccount::setProfile(const QString& profileId) +bool MojangAccount::setProfile(const QString &profileId) { - const QList<AccountProfile>& profiles = this->profiles(); + const QList<AccountProfile> &profiles = this->profiles(); for (int i = 0; i < profiles.length(); i++) { if (profiles.at(i).id() == profileId) @@ -119,14 +116,14 @@ bool MojangAccount::setProfile(const QString& profileId) return false; } -void MojangAccount::loadProfiles(const ProfileList& profiles) +void MojangAccount::loadProfiles(const ProfileList &profiles) { m_profiles.clear(); for (auto profile : profiles) m_profiles.append(profile); } -MojangAccountPtr MojangAccount::loadFromJson(const QJsonObject& object) +MojangAccountPtr MojangAccount::loadFromJson(const QJsonObject &object) { // The JSON object must at least have a username for it to be valid. if (!object.value("username").isString()) @@ -134,7 +131,7 @@ MojangAccountPtr MojangAccount::loadFromJson(const QJsonObject& object) QLOG_ERROR() << "Can't load Mojang account info from JSON object. Username field is missing or of the wrong type."; return nullptr; } - + QString username = object.value("username").toString(""); QString clientToken = object.value("clientToken").toString(""); QString accessToken = object.value("accessToken").toString(""); @@ -201,7 +198,7 @@ AccountProfile::AccountProfile(const QString& id, const QString& name) m_name = name; } -AccountProfile::AccountProfile(const AccountProfile& other) +AccountProfile::AccountProfile(const AccountProfile &other) { m_id = other.m_id; m_name = other.m_name; @@ -217,4 +214,7 @@ QString AccountProfile::name() const return m_name; } - +void MojangAccount::propagateChange() +{ + emit changed(); +} diff --git a/logic/auth/MojangAccount.h b/logic/auth/MojangAccount.h index 062b8aa2..25a85790 100644 --- a/logic/auth/MojangAccount.h +++ b/logic/auth/MojangAccount.h @@ -19,6 +19,7 @@ #include <QString> #include <QList> #include <QJsonObject> +#include <QPair> #include <memory> @@ -27,7 +28,6 @@ class MojangAccount; typedef std::shared_ptr<MojangAccount> MojangAccountPtr; Q_DECLARE_METATYPE(MojangAccountPtr) - /** * Class that represents a profile within someone's Mojang account. * @@ -38,56 +38,69 @@ Q_DECLARE_METATYPE(MojangAccountPtr) class AccountProfile { public: - AccountProfile(const QString& id, const QString& name); - AccountProfile(const AccountProfile& other); + AccountProfile(const QString &id, const QString &name); + AccountProfile(const AccountProfile &other); QString id() const; QString name() const; + protected: QString m_id; QString m_name; }; - typedef QList<AccountProfile> ProfileList; +struct User +{ + QString id; + // pair of key:value + // we don't know if the keys:value mapping is 1:1, so a list is used. + QList<QPair<QString, QString>> properties; +}; /** * Object that stores information about a certain Mojang account. * - * Said information may include things such as that account's username, client token, and access + * Said information may include things such as that account's username, client token, and access * token if the user chose to stay logged in. */ class MojangAccount : public QObject { -Q_OBJECT + Q_OBJECT public: /** * Constructs a new MojangAccount with the given username. * The client token will be generated automatically and the access token will be blank. */ - explicit MojangAccount(const QString& username, QObject* parent = 0); + explicit MojangAccount(const QString &username, QObject *parent = 0); /** * Constructs a new MojangAccount with the given username, client token, and access token. */ - explicit MojangAccount(const QString& username, const QString& clientToken, const QString& accessToken, QObject* parent = 0); + explicit MojangAccount(const QString &username, const QString &clientToken, + const QString &accessToken, QObject *parent = 0); /** * Constructs a new MojangAccount matching the given account. */ - MojangAccount(const MojangAccount& other, QObject* parent); + MojangAccount(const MojangAccount &other, QObject *parent); /** * Loads a MojangAccount from the given JSON object. */ - static MojangAccountPtr loadFromJson(const QJsonObject& json); + static MojangAccountPtr loadFromJson(const QJsonObject &json); /** * Saves a MojangAccount to a JSON object and returns it. */ QJsonObject saveToJson(); + /** + * Update the account on disk and lists (it changed, for whatever reason) + * This is called by various Yggdrasil tasks. + */ + void propagateChange(); /** * This MojangAccount's username. May be an email address if the account is migrated. @@ -103,7 +116,7 @@ public: /** * Sets the MojangAccount's client token to the given value. */ - void setClientToken(const QString& token); + void setClientToken(const QString &token); /** * This MojangAccount's access token. @@ -114,7 +127,7 @@ public: /** * Changes this MojangAccount's access token to the given value. */ - void setAccessToken(const QString& token); + void setAccessToken(const QString &token); /** * Get full session ID @@ -130,25 +143,31 @@ public: * Returns a pointer to the currently selected profile. * If no profile is selected, returns the first profile in the profile list or nullptr if there are none. */ - const AccountProfile* currentProfile() const; + const AccountProfile *currentProfile() const; /** * Sets the currently selected profile to the profile with the given ID string. * If profileId is not in the list of available profiles, the function will simply return false. */ - bool setProfile(const QString& profileId); + bool setProfile(const QString &profileId); /** * Clears the current account profile list and replaces it with the given profile list. */ - void loadProfiles(const ProfileList& profiles); + void loadProfiles(const ProfileList &profiles); +signals: + /** + * This isgnal is emitted whrn the account changes + */ + void changed(); protected: QString m_username; QString m_clientToken; - QString m_accessToken; // Blank if not logged in. - int m_currentProfile; // Index of the selected profile within the list of available profiles. -1 if nothing is selected. + QString m_accessToken; // Blank if not logged in. + int m_currentProfile; // Index of the selected profile within the list of available + // profiles. -1 if nothing is selected. ProfileList m_profiles; // List of available profiles. + User m_user; // the user structure, whatever it is. }; - 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(p |
