mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QTimer>
|
|
|
|
#include <memory>
|
|
|
|
class QNetworkReply;
|
|
|
|
namespace chatterino {
|
|
|
|
class NetworkData;
|
|
|
|
} // namespace chatterino
|
|
|
|
namespace chatterino::network::detail {
|
|
|
|
class NetworkTask : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
NetworkTask(std::shared_ptr<NetworkData> &&data);
|
|
~NetworkTask() override;
|
|
|
|
NetworkTask(const NetworkTask &) = delete;
|
|
NetworkTask(NetworkTask &&) = delete;
|
|
NetworkTask &operator=(const NetworkTask &) = delete;
|
|
NetworkTask &operator=(NetworkTask &&) = delete;
|
|
|
|
// NOLINTNEXTLINE(readability-redundant-access-specifiers)
|
|
public slots:
|
|
void run();
|
|
|
|
private:
|
|
QNetworkReply *createReply();
|
|
|
|
void logReply();
|
|
void writeToCache(const QByteArray &bytes) const;
|
|
|
|
std::shared_ptr<NetworkData> data_;
|
|
QNetworkReply *reply_{}; // parent: default (accessManager)
|
|
QTimer *timer_{}; // parent: this
|
|
|
|
// NOLINTNEXTLINE(readability-redundant-access-specifiers)
|
|
private slots:
|
|
void timeout();
|
|
void finished();
|
|
};
|
|
|
|
} // namespace chatterino::network::detail
|