2018-07-07 13:08:57 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common/NetworkCommon.hpp"
|
2019-08-20 20:08:49 +02:00
|
|
|
#include "common/NetworkTimer.hpp"
|
2018-07-07 13:08:57 +02:00
|
|
|
|
|
|
|
#include <QNetworkRequest>
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
class QNetworkReply;
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
class NetworkResult;
|
|
|
|
|
|
|
|
struct NetworkData {
|
2018-07-16 17:23:41 +02:00
|
|
|
NetworkData();
|
|
|
|
~NetworkData();
|
|
|
|
|
2018-07-07 13:08:57 +02:00
|
|
|
QNetworkRequest request_;
|
|
|
|
const QObject *caller_ = nullptr;
|
|
|
|
bool useQuickLoadCache_{};
|
2018-08-10 18:56:17 +02:00
|
|
|
bool executeConcurrently{};
|
2018-07-07 13:08:57 +02:00
|
|
|
|
|
|
|
NetworkReplyCreatedCallback onReplyCreated_;
|
|
|
|
NetworkErrorCallback onError_;
|
|
|
|
NetworkSuccessCallback onSuccess_;
|
|
|
|
|
|
|
|
NetworkRequestType requestType_ = NetworkRequestType::Get;
|
|
|
|
|
|
|
|
QByteArray payload_;
|
|
|
|
|
2019-08-20 20:08:49 +02:00
|
|
|
// Timer that tracks the timeout
|
|
|
|
// By default, there's no explicit timeout for the request
|
|
|
|
// to enable the timer, the "setTimeout" function needs to be called before
|
|
|
|
// execute is called
|
|
|
|
bool hasTimeout_{};
|
|
|
|
QTimer timer_;
|
|
|
|
|
2018-07-07 13:08:57 +02:00
|
|
|
QString getHash();
|
|
|
|
|
|
|
|
void writeToCache(const QByteArray &bytes);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString hash_;
|
|
|
|
};
|
|
|
|
|
2019-08-20 20:08:49 +02:00
|
|
|
void load(const std::shared_ptr<NetworkData> &data);
|
|
|
|
|
2018-07-07 13:08:57 +02:00
|
|
|
} // namespace chatterino
|