-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnetworking.h
More file actions
36 lines (30 loc) · 1.29 KB
/
networking.h
File metadata and controls
36 lines (30 loc) · 1.29 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
#ifndef NETWORKING_H
#define NETWORKING_H
#include "utilsexport.h"
#include <QUrl>
#include <QImage>
class NetworkingPrivate;
// slots for *Async methods should be like this:
// void onGetString(const QUrl &url, const QString &result);
// void onNetworkError(const QUrl &url, const QString &errorString);
// the "slot" string must be the name of slot only
// you can use NW_SLOT(function) macro
// use NULL (or NW_SLOT_NONE) to ignore result
#define NW_SLOT(func) #func
#define NW_SLOT_NONE NULL
class UTILS_EXPORT Networking
{
public:
static QImage httpGetImage(const QUrl &src);
static void httpGetImageAsync(const QUrl &src, QObject *receiver, const char *slot, const char *errorSlot);
static bool insertPixmap(const QUrl &src, QObject *target, const QString &property = "pixmap");
static QString httpGetString(const QUrl &src);
static void httpGetStringAsync(const QUrl &src, QObject *receiver, const char *slot, const char *errorSlot);
static void httpPostAsync(const QUrl &src, const QByteArray &data, QObject *receiver, const char *slot, const char *errorSlot);
static QString cookiePath();
static void setCookiePath(const QString &path);
private:
static NetworkingPrivate *networkingPrivate;
static NetworkingPrivate * p();
};
#endif // NETWORKING_H