Offline mode support, part 1

Refactor MojangAccount so it exposes a less generic interface and supports login. Hide the ugly details.
Yggdrasil tasks are now only used from MojangAccount.
This commit is contained in:
Petr Mrázek
2013-12-05 02:39:52 +01:00
parent 613699b362
commit f028aa76bc
18 changed files with 265 additions and 322 deletions

View File

@ -69,10 +69,6 @@
#include "logic/lists/IconList.h"
#include "logic/lists/JavaVersionList.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"
#include "logic/MinecraftProcess.h"
@ -210,9 +206,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
for(AccountProfile profile : account->profiles())
{
auto meta = MMC->metacache()->resolveEntry("skins", profile.name() + ".png");
auto meta = MMC->metacache()->resolveEntry("skins", profile.name + ".png");
auto action = CacheDownload::make(
QUrl("http://skins.minecraft.net/MinecraftSkins/" + profile.name() + ".png"),
QUrl("http://skins.minecraft.net/MinecraftSkins/" + profile.name + ".png"),
meta);
job->addNetAction(action);
meta->stale = true;
@ -310,9 +306,9 @@ void MainWindow::repopulateAccountsMenu()
section->setEnabled(false);
accountMenu->addAction(section);
for (AccountProfile profile : account->profiles())
for (auto profile : account->profiles())
{
QAction *action = new QAction(profile.name(), this);
QAction *action = new QAction(profile.name, this);
action->setData(account->username());
action->setCheckable(true);
if(active_username == account->username())
@ -320,7 +316,7 @@ void MainWindow::repopulateAccountsMenu()
action->setChecked(true);
}
action->setIcon(SkinUtils::getFaceFromCache(profile.name()));
action->setIcon(SkinUtils::getFaceFromCache(profile.name));
accountMenu->addAction(action);
connect(action, SIGNAL(triggered(bool)), SLOT(changeActiveAccount()));
}
@ -378,7 +374,7 @@ void MainWindow::activeAccountChanged()
const AccountProfile *profile = account->currentProfile();
if (profile != nullptr)
{
accountMenuButton->setIcon(SkinUtils::getFaceFromCache(profile->name()));
accountMenuButton->setIcon(SkinUtils::getFaceFromCache(profile->name));
return;
}
}
@ -790,6 +786,7 @@ void MainWindow::doLaunch()
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);
RefreshTask refreshtask(account, &progDialog);
progDialog.exec(&refreshtask);
@ -829,10 +826,12 @@ void MainWindow::doLaunchInst(BaseInstance* instance, MojangAccountPtr account)
QMessageBox::Warning, QMessageBox::Ok)->exec();
}
}
*/
}
bool MainWindow::doRefreshToken(MojangAccountPtr account, const QString& errorMsg)
{
/*
EditAccountDialog passDialog(errorMsg, this, EditAccountDialog::PasswordField);
if (passDialog.exec() == QDialog::Accepted)
{
@ -848,7 +847,8 @@ bool MainWindow::doRefreshToken(MojangAccountPtr account, const QString& errorMs
return doRefreshToken(account, authTask.failReason());
}
}
else return false;
else return false;*/
return false;
}
void MainWindow::prepareLaunch(BaseInstance* instance, MojangAccountPtr account)

View File

@ -20,7 +20,6 @@
#include <logger/QsLog.h>
#include <logic/auth/flows/AuthenticateTask.h>
#include <logic/net/NetJob.h>
#include <gui/dialogs/EditAccountDialog.h>
@ -117,8 +116,8 @@ void AccountListDialog::addAccount(const QString& errMsg)
QString username(loginDialog.username());
QString password(loginDialog.password());
MojangAccountPtr account = MojangAccountPtr(new MojangAccount(username));
MojangAccountPtr account = MojangAccount::createFromUsername(username);
/*
ProgressDialog progDialog(this);
AuthenticateTask authTask(account, password, &progDialog);
if (progDialog.exec(&authTask))
@ -132,9 +131,9 @@ void AccountListDialog::addAccount(const QString& errMsg)
for(AccountProfile profile : account->profiles())
{
auto meta = MMC->metacache()->resolveEntry("skins", profile.name() + ".png");
auto meta = MMC->metacache()->resolveEntry("skins", profile.name + ".png");
auto action = CacheDownload::make(
QUrl("http://skins.minecraft.net/MinecraftSkins/" + profile.name() + ".png"),
QUrl("http://skins.minecraft.net/MinecraftSkins/" + profile.name + ".png"),
meta);
job->addNetAction(action);
meta->stale = true;
@ -142,5 +141,6 @@ void AccountListDialog::addAccount(const QString& errMsg)
job->start();
}
*/
}
}

View File

@ -20,8 +20,6 @@
#include <logger/QsLog.h>
#include <logic/auth/flows/AuthenticateTask.h>
#include <gui/dialogs/ProgressDialog.h>
#include <MultiMC.h>