summaryrefslogtreecommitdiffstats
path: root/api/logic/net/FileSink.h
blob: 875fe5110fe62cfc4f1424826bd31862191418c0 (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 */
    JobStatus init(QNetworkRequest & request) override;
    JobStatus write(QByteArray & data) override;
    JobStatus abort() override;
    JobStatus finalize(QNetworkReply & reply) override;
    bool hasLocalData() 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;
};
}