summaryrefslogtreecommitdiffstats
path: root/logic/tasks
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-11-28 20:45:52 -0600
committerAndrew <forkk@forkk.net>2013-11-28 20:45:52 -0600
commitbfc9e1e5d598f354dd39e5c2eb51d5e51585359b (patch)
tree20d2dd60b8b053ac4a93eb916b5484090d375b67 /logic/tasks
parent1f150dcb7821fea19b40b9e1024fff5b594f03e9 (diff)
downloadMultiMC-bfc9e1e5d598f354dd39e5c2eb51d5e51585359b.tar
MultiMC-bfc9e1e5d598f354dd39e5c2eb51d5e51585359b.tar.gz
MultiMC-bfc9e1e5d598f354dd39e5c2eb51d5e51585359b.tar.lz
MultiMC-bfc9e1e5d598f354dd39e5c2eb51d5e51585359b.tar.xz
MultiMC-bfc9e1e5d598f354dd39e5c2eb51d5e51585359b.zip
Verify access tokens before launching Minecraft
Kind of an important thing to do... Heh...
Diffstat (limited to 'logic/tasks')
-rw-r--r--logic/tasks/Task.cpp15
-rw-r--r--logic/tasks/Task.h14
2 files changed, 29 insertions, 0 deletions
diff --git a/logic/tasks/Task.cpp b/logic/tasks/Task.cpp
index 47214723..cb7a5443 100644
--- a/logic/tasks/Task.cpp
+++ b/logic/tasks/Task.cpp
@@ -53,6 +53,8 @@ void Task::start()
void Task::emitFailed(QString reason)
{
m_running = false;
+ m_succeeded = false;
+ m_failReason = reason;
QLOG_ERROR() << "Task failed: " << reason;
emit failed(reason);
}
@@ -60,6 +62,8 @@ void Task::emitFailed(QString reason)
void Task::emitSucceeded()
{
m_running = false;
+ m_succeeded = true;
+ QLOG_INFO() << "Task succeeded";
emit succeeded();
}
@@ -67,3 +71,14 @@ bool Task::isRunning() const
{
return m_running;
}
+
+bool Task::successful() const
+{
+ return m_succeeded;
+}
+
+QString Task::failReason() const
+{
+ return m_failReason;
+}
+
diff --git a/logic/tasks/Task.h b/logic/tasks/Task.h
index 980b2af8..d08ef560 100644
--- a/logic/tasks/Task.h
+++ b/logic/tasks/Task.h
@@ -29,6 +29,18 @@ public:
virtual void getProgress(qint64 &current, qint64 &total);
virtual bool isRunning() const;
+ /*!
+ * True if this task was successful.
+ * If the task failed or is still running, returns false.
+ */
+ virtual bool successful() const;
+
+ /*!
+ * Returns the string that was passed to emitFailed as the error message when the task failed.
+ * If the task hasn't failed, returns an empty string.
+ */
+ virtual QString failReason() const;
+
public
slots:
virtual void start();
@@ -48,4 +60,6 @@ protected:
QString m_status;
int m_progress = 0;
bool m_running = false;
+ bool m_succeeded = false;
+ QString m_failReason = "";
};