summaryrefslogtreecommitdiffstats
path: root/logic/auth/MojangAccount.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-12-08 17:34:45 +0100
committerPetr Mrázek <peterix@gmail.com>2013-12-08 17:34:45 +0100
commit0cb8ff40b26401a707781c2c4171d3ec6c114077 (patch)
tree0e075c830b67f8b15d5359d06d1026987dc5c124 /logic/auth/MojangAccount.cpp
parentf028aa76bc5d28b7fc4d1ea4e194895690e9944e (diff)
downloadMultiMC-0cb8ff40b26401a707781c2c4171d3ec6c114077.tar
MultiMC-0cb8ff40b26401a707781c2c4171d3ec6c114077.tar.gz
MultiMC-0cb8ff40b26401a707781c2c4171d3ec6c114077.tar.lz
MultiMC-0cb8ff40b26401a707781c2c4171d3ec6c114077.tar.xz
MultiMC-0cb8ff40b26401a707781c2c4171d3ec6c114077.zip
Finish preliminary offline support
* ProgressProvider now has an abort() call * Abort button support added to the progress dialog * YggdrasilTask and MojangAccount adapted to support abort YggdrasilTask will time out after 10 seconds of no network activity, or when the user pushes the Play Offline button. In offline mode, all instance update tasks are skipped! This will need further work.
Diffstat (limited to 'logic/auth/MojangAccount.cpp')
-rw-r--r--logic/auth/MojangAccount.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/logic/auth/MojangAccount.cpp b/logic/auth/MojangAccount.cpp
index 9ab71077..b1acfb25 100644
--- a/logic/auth/MojangAccount.cpp
+++ b/logic/auth/MojangAccount.cpp
@@ -134,22 +134,21 @@ AccountStatus MojangAccount::accountStatus() const
return Online;
}
-bool MojangAccount::login(QString password)
+std::shared_ptr<Task> MojangAccount::login(QString password)
{
if(m_currentTask)
- return false;
+ return m_currentTask;
if(password.isEmpty())
{
- m_currentTask.reset(new RefreshTask(this, this));
+ m_currentTask.reset(new RefreshTask(this));
}
else
{
- m_currentTask.reset(new AuthenticateTask(this, password, this));
+ m_currentTask.reset(new AuthenticateTask(this, password));
}
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
- m_currentTask->start();
- return true;
+ return m_currentTask;
}
void MojangAccount::authSucceeded()
@@ -161,8 +160,13 @@ void MojangAccount::authSucceeded()
void MojangAccount::authFailed(QString reason)
{
- m_online = false;
- m_accessToken = QString();
+ // This is emitted when the yggdrasil tasks time out or are cancelled.
+ // -> we treat the error as no-op
+ if(reason != "Yggdrasil task cancelled.")
+ {
+ m_online = false;
+ m_accessToken = QString();
+ emit changed();
+ }
m_currentTask.reset();
- emit changed();
}