teleport/client/tp-player/downloader.h

41 lines
948 B
C
Raw Normal View History

2019-10-31 17:45:17 +00:00
#ifndef DOWNLOADER_H
#define DOWNLOADER_H
#include <QFile>
#include <QNetworkAccessManager>
class Downloader : public QObject {
Q_OBJECT
public:
2019-11-01 18:12:48 +00:00
// 从url下载数据写入到filename文件中或放入data中。
2019-10-31 17:45:17 +00:00
Downloader();
~Downloader();
2019-11-01 18:12:48 +00:00
bool request(const QString& url, const QString& sid, const QString& filename);
bool request(const QString& url, const QString& sid, QByteArray* data);
2019-10-31 17:45:17 +00:00
void abort();
2019-11-01 18:12:48 +00:00
private:
bool _request(const QString& url, const QString& sid, const QString& filename, QByteArray* data);
2019-10-31 17:45:17 +00:00
private slots:
void _on_data_ready(); // 有数据可读了,读取并写入文件
void _on_finished(); // 下载结束了
private:
QFile m_file;
2019-11-01 18:12:48 +00:00
QByteArray* m_data;
2019-10-31 17:45:17 +00:00
2019-11-01 18:12:48 +00:00
bool m_result;
2019-10-31 17:45:17 +00:00
QNetworkReply* m_reply;
};
typedef struct DownloadParam {
QString url;
QString sid;
QString fname;
}DownloadParam;
#endif