-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathRemoteNetwork.h
More file actions
44 lines (32 loc) · 1.04 KB
/
RemoteNetwork.h
File metadata and controls
44 lines (32 loc) · 1.04 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef REMOTENETWORK_H
#define REMOTENETWORK_H
#include <QObject>
#include <QtNetwork/QSslConfiguration>
class QNetworkAccessManager;
class QNetworkReply;
class RemoteNetwork : public QObject
{
Q_OBJECT
public:
static RemoteNetwork& get()
{
static RemoteNetwork instance;
return instance;
}
void reloadSettings();
enum RequestType
{
RequestTypeCustom,
};
void fetch(const QUrl& url, RequestType type, std::function<void(QByteArray)> when_finished = {}, bool synchronous = false, bool ignore_errors = false);
private:
RemoteNetwork();
~RemoteNetwork() override;
void gotReply(QNetworkReply* reply);
void gotError(QNetworkReply* reply, const QList<QSslError>& errors);
// This function is called for all network replies we get whether they are handled globally or individually.
// It mainly does some error checking and returns true if the actual handler should be called.
bool handleReply(QNetworkReply* reply);
QNetworkAccessManager* m_manager;
};
#endif