2016-05-28 23:24:17 +05:30
|
|
|
#pragma once
|
2022-04-22 06:42:14 +05:30
|
|
|
|
2016-05-28 23:24:17 +05:30
|
|
|
#include <QSaveFile>
|
|
|
|
|
2022-04-22 06:42:14 +05:30
|
|
|
#include "Sink.h"
|
|
|
|
|
2016-05-28 23:24:17 +05:30
|
|
|
namespace Net {
|
2022-04-22 06:42:14 +05:30
|
|
|
class FileSink : public Sink {
|
|
|
|
public:
|
|
|
|
FileSink(QString filename) : m_filename(filename){};
|
|
|
|
virtual ~FileSink() = default;
|
|
|
|
|
|
|
|
public:
|
|
|
|
auto init(QNetworkRequest& request) -> Task::State override;
|
|
|
|
auto write(QByteArray& data) -> Task::State override;
|
|
|
|
auto abort() -> Task::State override;
|
|
|
|
auto finalize(QNetworkReply& reply) -> Task::State override;
|
2016-05-28 23:24:17 +05:30
|
|
|
|
2022-04-22 06:42:14 +05:30
|
|
|
auto hasLocalData() -> bool override;
|
2016-05-28 23:24:17 +05:30
|
|
|
|
2022-04-22 06:42:14 +05:30
|
|
|
protected:
|
|
|
|
virtual auto initCache(QNetworkRequest&) -> Task::State;
|
|
|
|
virtual auto finalizeCache(QNetworkReply& reply) -> Task::State;
|
2016-05-28 23:24:17 +05:30
|
|
|
|
2022-04-22 06:42:14 +05:30
|
|
|
protected:
|
2018-07-15 18:21:05 +05:30
|
|
|
QString m_filename;
|
|
|
|
bool wroteAnyData = false;
|
|
|
|
std::unique_ptr<QSaveFile> m_output_file;
|
2016-05-28 23:24:17 +05:30
|
|
|
};
|
2022-04-22 06:42:14 +05:30
|
|
|
} // namespace Net
|