-
Notifications
You must be signed in to change notification settings - Fork 0
/
http.h
62 lines (46 loc) · 1.38 KB
/
http.h
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
60
61
62
#ifndef HTTP_H
#define HTTP_H
#include <QObject>
#include <QtNetwork>
class Http : public QObject
{
Q_OBJECT
public:
explicit Http(QObject *parent = 0);
~Http();
void downloadFile( QString strUrl, QString strSavePath );
void cancelDownload();
qint64 getFileSize(QString url ,int tryTimes); //请求的文件服务器不存在,返回-1
signals:
void sigCurrentDownloadFile( int nPercentage );
void sigDownloadFinished( QString strFile, bool bSuccess );
public slots:
void downloadError(QNetworkReply::NetworkError code);
void downloadFinished();
void downloadReadyRead();
void updateDataReadProgress( qint64 bytesReceived, qint64 bytesTotal );
void onDownloadTimer();
private:
void tryDownloadAgain();
void timerEvent(QTimerEvent* event);
private:
static QNetworkAccessManager* s_pNetMgr;
QNetworkReply* m_pNetReply;
QFile* m_pFile;
bool m_bSuccess;
QString m_strFileName;
QString m_strFileNameTmp;
QString m_strUrl;
qint64 m_nFileSize;
int m_nTryTotal;
int m_nTryCur;
qint64 m_nCurDownload;
qint64 m_nLastDownload;
QTimer m_timer;
int m_nTimerId;
int m_nTimerInterval;
int m_nNoData;
bool m_bAbort;
int n_reConn;
};
#endif // HTTP_H