diff options
author | Jan Dalheimer <jan@dalheimer.de> | 2015-05-28 19:38:29 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-06-06 21:23:05 +0200 |
commit | 3a8b238052163952831fb5924b2483a375e86ebd (patch) | |
tree | ab120b4fac3a5345a20e7a09e1e7477e67d9ed6f /logic/tasks/StandardTask.h | |
parent | 161dc66c2c8d5f973ee69dab36c3969a7efd7495 (diff) | |
download | MultiMC-3a8b238052163952831fb5924b2483a375e86ebd.tar MultiMC-3a8b238052163952831fb5924b2483a375e86ebd.tar.gz MultiMC-3a8b238052163952831fb5924b2483a375e86ebd.tar.lz MultiMC-3a8b238052163952831fb5924b2483a375e86ebd.tar.xz MultiMC-3a8b238052163952831fb5924b2483a375e86ebd.zip |
NOISSUE Various changes from multiauth that are unrelated to it
Diffstat (limited to 'logic/tasks/StandardTask.h')
-rw-r--r-- | logic/tasks/StandardTask.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/logic/tasks/StandardTask.h b/logic/tasks/StandardTask.h new file mode 100644 index 00000000..6f283dcd --- /dev/null +++ b/logic/tasks/StandardTask.h @@ -0,0 +1,43 @@ +// Licensed under the Apache-2.0 license. See README.md for details. + +#pragma once + +#include "Task.h" + +#include <QPointer> +#include <memory> + +#include "QObjectPtr.h" + +class QEventLoop; +class QDir; +class NetAction; +class NetJob; +class INetworkValidator; + +class StandardTask : public Task +{ + Q_OBJECT +public: + explicit StandardTask(QObject *parent = nullptr); + +protected: + // TODO: switch to a future-based system + void runTask(QObjectPtr<Task> other); + void runTaskNonBlocking(QObjectPtr<Task> other); + QByteArray networkGet(const QUrl &url); + QByteArray networkGetCached(const QString &name, const QString &base, const QString &path, const QUrl &url, const bool alwaysRefetch = false, + INetworkValidator *validator = nullptr); + QByteArray networkGetCached(const QString &name, const QString &base, const QString &path, const QUrl &url, const QMap<QString, QString> &headers, + INetworkValidator *validator = nullptr); + void networkGetCachedNonBlocking(const QString &name, const QString &base, const QString &path, const QUrl &url, const bool alwaysRefetch = false, + INetworkValidator *validator = nullptr); + void waitOnPending(); + +private: + QEventLoop *m_loop; + QList<QPointer<Task>> m_pendingTasks; // only used to check if the object was deleted + QList<QObjectPtr<Task>> m_pendingTaskPtrs; + + QObjectPtr<NetJob> wrapDownload(const QString &name, std::shared_ptr<NetAction> action); +}; |