ifndef HTTPREQUEST_H define HTTPREQUEST_H include media include define

 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef HTTPREQUEST_H
#define HTTPREQUEST_H
#include "media.h"
#include "defines.h"
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QSharedPointer>
#include <QMap>
class HTTPRequest : public QObject
{
Q_OBJECT
public:
HTTPRequest();
void put(QString url, QVector<QPair<QString, QString> > fields);
bool putFile(QSharedPointer<Media> media, QVector<QPair<QString, QString> > fields);
void get(QString url, QVector<QPair<QString, QString> > params);
void post(QString url, QVector<QPair<QString, QString> > fields);
void postFile(QSharedPointer<Media> media, QVector<QPair<QString, QString> > fields);
void pause();
void resume();
int progress();
void connectProgress(const char* to, const char* func);
void connectStatus(const char* to, const char* func);
private:
QNetworkAccessManager qnam;
QNetworkReply* reply;
bool inProgress;
bool failed;
void connectReply(const char*, QNetworkReply *reply = 0);
qint64 doneSize;
QString url, getlenurl;
QSharedPointer<Media> media;
QVector<QPair<QString, QString> > fields;
QByteArray formStartPostData(QSharedPointer<Media>, QVector<QPair<QString, QString> >);
void putFileProgressReceiver(qint64 done, qint64 total);
void getReceiver();
void postReceiver();
void postFileReceiver();
private slots:
void putFile2(QString uploadUrl = "", QString lenUrl = "");
void putFile3();
void putFile4();
void fail(QString msg);
void fail(QNetworkReply::NetworkError code);
signals:
void progress(int);
void status(state);
void result(QString);
void error(QString);
};
#endif // HTTPREQUEST_H