From 0cb8ff40b26401a707781c2c4171d3ec6c114077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 8 Dec 2013 17:34:45 +0100 Subject: 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. --- logic/auth/MojangAccount.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'logic/auth/MojangAccount.cpp') 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 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(); } -- cgit v1.2.3