2016-05-28 18:54:17 +01:00
|
|
|
#pragma once
|
|
|
|
#include "Sink.h"
|
|
|
|
#include <QSaveFile>
|
|
|
|
|
|
|
|
namespace Net {
|
|
|
|
class FileSink : public Sink
|
|
|
|
{
|
|
|
|
public: /* con/des */
|
|
|
|
FileSink(QString filename);
|
|
|
|
virtual ~FileSink();
|
|
|
|
|
|
|
|
public: /* methods */
|
2017-05-03 22:11:52 +01:00
|
|
|
JobStatus init(QNetworkRequest & request) override;
|
|
|
|
JobStatus write(QByteArray & data) override;
|
|
|
|
JobStatus abort() override;
|
|
|
|
JobStatus finalize(QNetworkReply & reply) override;
|
2016-10-28 01:19:19 +01:00
|
|
|
bool hasLocalData() override;
|
2016-05-28 18:54:17 +01:00
|
|
|
|
|
|
|
protected: /* methods */
|
2017-05-03 22:11:52 +01:00
|
|
|
virtual JobStatus initCache(QNetworkRequest &);
|
|
|
|
virtual JobStatus finalizeCache(QNetworkReply &reply);
|
2016-05-28 18:54:17 +01:00
|
|
|
|
|
|
|
protected: /* data */
|
|
|
|
QString m_filename;
|
|
|
|
bool wroteAnyData = false;
|
|
|
|
std::unique_ptr<QSaveFile> m_output_file;
|
|
|
|
};
|
|
|
|
}
|