diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-12-08 17:34:45 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-12-08 17:34:45 +0100 |
commit | 0cb8ff40b26401a707781c2c4171d3ec6c114077 (patch) | |
tree | 0e075c830b67f8b15d5359d06d1026987dc5c124 /logic/auth/YggdrasilTask.h | |
parent | f028aa76bc5d28b7fc4d1ea4e194895690e9944e (diff) | |
download | MultiMC-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/YggdrasilTask.h')
-rw-r--r-- | logic/auth/YggdrasilTask.h | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/logic/auth/YggdrasilTask.h b/logic/auth/YggdrasilTask.h index 18d3dc61..1f81a2d0 100644 --- a/logic/auth/YggdrasilTask.h +++ b/logic/auth/YggdrasilTask.h @@ -19,6 +19,7 @@ #include <QString> #include <QJsonObject> +#include <QTimer> #include "logic/auth/MojangAccount.h" @@ -32,39 +33,17 @@ class YggdrasilTask : public Task Q_OBJECT public: explicit YggdrasilTask(MojangAccount * account, QObject *parent = 0); - ~YggdrasilTask(); /** * Class describing a Yggdrasil error response. */ - class Error + struct Error { - public: - Error(const QString& shortError, const QString& errorMessage, const QString& cause) : - m_shortError(shortError), m_errorMessage(errorMessage), m_cause(cause) {} - - QString getShortError() const { return m_shortError; } - QString getErrorMessage() const { return m_errorMessage; } - QString getCause() const { return m_cause; } - - /// Gets the string to display in the GUI for describing this error. - QString getDisplayMessage() - { - return getErrorMessage(); - } - - protected: - QString m_shortError; - QString m_errorMessage; + QString m_errorMessageShort; + QString m_errorMessageVerbose; QString m_cause; }; - /** - * Returns a pointer to a YggdrasilTask::Error object if an error has occurred. - * If no error has occurred, returns a null pointer. - */ - virtual Error *getError() const; - protected: /** * Enum for describing the state of the current task. @@ -115,13 +94,25 @@ protected: */ virtual QString getStateMessage(const State state) const; - MojangAccount *m_account = nullptr; - - QNetworkReply *m_netReply; - - Error *m_error = nullptr; - protected slots: - void processReply(QNetworkReply *reply); + void processReply(); + void refreshTimers(qint64, qint64); + void heartbeat(); + +public +slots: + virtual void abort() override; + +protected: + // FIXME: segfault disaster waiting to happen + MojangAccount *m_account = nullptr; + QNetworkReply *m_netReply = nullptr; + std::shared_ptr<Error> m_error; + QTimer timeout_keeper; + QTimer counter; + int count = 0; // num msec since time reset + + const int timeout_max = 10000; + const int time_step = 50; }; |