Mercurial > trustbridge
view ui/downloader.h @ 11:7e2f14c7aba2
Split up downloader component and further implement it
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 14 Feb 2014 11:20:15 +0000 |
parents | fe39d93f1261 |
children | 95e1b6edf2fc |
line wrap: on
line source
#ifndef DOWNLOADER_H #define DOWNLOADER_H /** * @file downloader.h * @brief High level API to download necessary data. * */ #include <QThread> #include <QString> #include <QByteArray> class Downloader: public QThread { Q_OBJECT public: /** * @brief Construct a downloader to download data from url * * Takes the builtin certificate for https verification. * * @param[in] parent the parent object. * @param[in] url the Url to download data from. */ Downloader(QObject* parent, const QString& url); /** * @brief Construct a downloader with a specific certificate * * @param[in] parent the parent object. * @param[in] url the Url to download data from * @param[in] certificate to accept https connection from */ Downloader(QObject* parent, const QString& url, const QByteArray& certificate); enum Status { NewSoftwareAvailable, // A Software Update has been downloaded NewListAvailable, // A certificate list has been downloaded UpToDate, // Nothing changed Error // An error happened }; enum ErrorCode { NoConnection, InvalidCertificate, ConnectionLost, Timeout, Unknown }; /** * @brief Construct a downloader with a specific certificate * * @param[in] url the Url to download data from * @param[in] certificate to accept https connection from */ QString getDownloadedFileName(); protected: void run(); private: QString mUrl; QByteArray mCert; Q_SIGNALS: /** * @brief Some progress has been made. * * @param[out] message: A message to show. Can be empty. * @param[out] current: Value of current progress. * @param[out] total: Total value of possible progress */ void progress(const QString &message, int current, int total); /** * @brief An error happened * * @param[out] message: A message to show. Can be empty. * @param[out] errorCode: ErrorCode of this error. * @param[out] total: Total value of possible progress. */ void error(const QString &message, ErrorCode error); }; #endif