X-Git-Url: https://git.sven.stormbind.net/?a=blobdiff_plain;f=src%2Fdownload-agent.h;fp=src%2Fdownload-agent.h;h=bb29b2bb9516aae4cb719c72161c93026688f902;hb=d483bd8e6523c23c6f1d8908a2e0611c2bc9ff4f;hp=0000000000000000000000000000000000000000;hpb=7dfa3fe589d1722d49681f42cdb0bf1e6efb5223;p=sven%2Fvym.git diff --git a/src/download-agent.h b/src/download-agent.h new file mode 100644 index 0000000..bb29b2b --- /dev/null +++ b/src/download-agent.h @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE +class QSslError; +QT_END_NAMESPACE + +QT_USE_NAMESPACE + +class VymModel; + +class DownloadAgent : public QObject { + Q_OBJECT + QNetworkAccessManager agent; + QList currentDownloads; + + public: + DownloadAgent(const QUrl &u); + ~DownloadAgent(); + QString getDestination(); + void setFinishedAction(VymModel *m, const QString &script); + QString getFinishedScript(); + uint getFinishedScriptModelID(); + void setUserAgent(const QString &s); + bool isSuccess(); + QString getResultMessage(); + void doDownload(const QUrl &url); + bool saveToDisk(const QString &filename, const QByteArray &data); + + public slots: + void execute(); + void requestFinished(QNetworkReply *reply); + void sslErrors(const QList &errors); + + signals: + void downloadFinished(); + + private: + QString tmpFilePath; + QByteArray userAgent; + QUrl url; + + bool success; + QString resultMessage; + + QString finishedScript; + uint finishedScriptModelID; +};