aboutsummaryrefslogtreecommitdiff
path: root/launcher/net/Download.h
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2023-08-10 20:38:32 +0200
committerSefa Eyeoglu <contact@scrumplex.net>2023-08-10 20:38:32 +0200
commitef6f9487f48ee6f114d47108977380fb4c278597 (patch)
tree57945b096640c87a976223daace6ecc27613d4c1 /launcher/net/Download.h
parent81bc9e488f653eba3e29d63b51c95f73f03ad182 (diff)
parent2090f958c8d1940238fe08f98eee2145edb12906 (diff)
downloadPrismLauncher-ef6f9487f48ee6f114d47108977380fb4c278597.tar.gz
PrismLauncher-ef6f9487f48ee6f114d47108977380fb4c278597.tar.bz2
PrismLauncher-ef6f9487f48ee6f114d47108977380fb4c278597.zip
Merge remote-tracking branch 'upstream/staging' into chore/add-compiler-warnings
Diffstat (limited to 'launcher/net/Download.h')
-rw-r--r--launcher/net/Download.h47
1 files changed, 8 insertions, 39 deletions
diff --git a/launcher/net/Download.h b/launcher/net/Download.h
index 0f11c52f..5f6a5caf 100644
--- a/launcher/net/Download.h
+++ b/launcher/net/Download.h
@@ -38,57 +38,26 @@
#pragma once
-#include <chrono>
-
#include "HttpMetaCache.h"
-#include "NetAction.h"
-#include "Sink.h"
-#include "Validator.h"
#include "QObjectPtr.h"
+#include "net/NetRequest.h"
namespace Net {
-class Download : public NetAction {
+class Download : public NetRequest {
Q_OBJECT
-
public:
using Ptr = shared_qobject_ptr<class Download>;
- enum class Option { NoOptions = 0, AcceptLocalFiles = 1, MakeEternal = 2 };
- Q_DECLARE_FLAGS(Options, Option)
-
- public:
- ~Download() override = default;
+ explicit Download() : NetRequest() { logCat = taskDownloadLogC; }
+#if defined(LAUNCHER_APPLICATION)
static auto makeCached(QUrl url, MetaEntryPtr entry, Options options = Option::NoOptions) -> Download::Ptr;
+#endif
+
static auto makeByteArray(QUrl url, std::shared_ptr<QByteArray> output, Options options = Option::NoOptions) -> Download::Ptr;
static auto makeFile(QUrl url, QString path, Options options = Option::NoOptions) -> Download::Ptr;
- public:
- void addValidator(Validator* v);
- auto abort() -> bool override;
- auto canAbort() const -> bool override { return true; }
-
- private:
- auto handleRedirect() -> bool;
-
- protected slots:
- void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) override;
- void downloadError(QNetworkReply::NetworkError error) override;
- void sslErrors(const QList<QSslError>& errors) override;
- void downloadFinished() override;
- void downloadReadyRead() override;
-
- public slots:
- void executeTask() override;
-
- private:
- std::unique_ptr<Sink> m_sink;
- Options m_options;
-
- std::chrono::steady_clock m_clock;
- std::chrono::time_point<std::chrono::steady_clock> m_last_progress_time;
- qint64 m_last_progress_bytes;
+ protected:
+ virtual QNetworkReply* getReply(QNetworkRequest&) override;
};
} // namespace Net
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(Net::Download::Options)