summaryrefslogtreecommitdiffstats
path: root/api/logic/net/FileSink.h
blob: a7528b5dcf5e83060fe640e71c751fc766e98324 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once
#include "Sink.h"
#include <QSaveFile>

namespace Net {
class FileSink : public Sink
{
public: /* con/des */
	FileSink(QString filename);
	virtual ~FileSink();

public: /* methods */
	Task::Status init(QNetworkRequest & request) override;
	Task::Status write(QByteArray & data) override;
	Task::Status abort() override;
	Task::Status finalize(QNetworkReply & reply) override;
	bool hasLocalData() override;

protected: /* methods */
	virtual Task::Status initCache(QNetworkRequest &);
	virtual Task::Status finalizeCache(QNetworkReply &reply);

protected: /* data */
	QString m_filename;
	bool wroteAnyData = false;
	std::unique_ptr<QSaveFile> m_output_file;
};
}