summaryrefslogtreecommitdiffstats
path: root/api/logic/net/FileSink.h
blob: 7adc9c473f68e500b71073408ae9215d80a6489c (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
#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;
};
}