summaryrefslogtreecommitdiffstats
path: root/api/logic/net/FileSink.h
diff options
context:
space:
mode:
Diffstat (limited to 'api/logic/net/FileSink.h')
-rw-r--r--api/logic/net/FileSink.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/api/logic/net/FileSink.h b/api/logic/net/FileSink.h
new file mode 100644
index 00000000..7adc9c47
--- /dev/null
+++ b/api/logic/net/FileSink.h
@@ -0,0 +1,27 @@
+#pragma once
+#include "Sink.h"
+#include <QSaveFile>
+
+namespace Net {
+class FileSink : public Sink
+{
+public: /* con/des */
+ FileSink(QString filename);
+ virtual ~FileSink();
+
+public: /* methods */
+ JobStatus init(QNetworkRequest & request) override;
+ JobStatus write(QByteArray & data) override;
+ JobStatus abort() override;
+ JobStatus finalize(QNetworkReply & reply) override;
+
+protected: /* methods */
+ virtual JobStatus initCache(QNetworkRequest &);
+ virtual JobStatus finalizeCache(QNetworkReply &reply);
+
+protected: /* data */
+ QString m_filename;
+ bool wroteAnyData = false;
+ std::unique_ptr<QSaveFile> m_output_file;
+};
+}