#pragma once #include #include #include #include #include #include #include "trace.h" class HttpDownload : public QObject { Q_OBJECT public: HttpDownload(QObject* parent, QString url, QString download_path = QDir::tempPath()); HttpDownload(QObject* parent, QNetworkAccessManager* net_manager, QString url, QString download_path = QDir::tempPath()); ~HttpDownload(); void Download(); public slots: void OnFinished(QNetworkReply* reply); void OnSslErrors(QList &ssl_errors); void OnDownloadProgress(qint64 bytes_received, qint64 bytes_total); void OnError(QNetworkReply::NetworkError error_code); void OnRedirected(const QUrl &url); private: QUrl m_url; QString m_download_path; QNetworkAccessManager* m_net_manager; QNetworkReply* m_net_reply; QNetworkRequest m_net_request; };