comparison ui/downloader.h @ 10:fe39d93f1261

Start on Downloader component
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 13 Feb 2014 14:43:15 +0000
parents
children 95e1b6edf2fc
comparison
equal deleted inserted replaced
9:2ad9a96518e3 10:fe39d93f1261
1 #ifndef DOWNLOADER_H
2 #define DOWNLOADER_H
3 /**
4 * @file downloader.h
5 * @brief High level API to download necessary data.
6 *
7 */
8
9 #include <QThread>
10 #include <QString>
11 #include <QByteArray>
12
13 class Downloader: public QThread
14 {
15 Q_OBJECT
16
17 public:
18 /**
19 * @brief Construct a downloader to download data from url
20 *
21 * Takes the builtin certificate for https verification.
22 *
23 * @param[in] parent the parent object.
24 * @param[in] url the Url to download data from.
25 */
26 Downloader(QObject* parent, const QString& url);
27
28 /**
29 * @brief Construct a downloader with a specific certificate
30 *
31 * @param[in] parent the parent object.
32 * @param[in] url the Url to download data from
33 * @param[in] certificate to accept https connection from
34 */
35 Downloader(QObject* parent, const QString& url,
36 const QByteArray& certificate);
37
38 enum Status {
39 NewSoftwareAvailable, // A Software Update has been downloaded
40 NewListAvailable, // A certificate list has been downloaded
41 UpToDate, // Nothing changed
42 Error // An error happened
43 };
44
45 enum ErrorCode {
46 NoConnection,
47 InvalidCertificate,
48 ConnectionLost,
49 Timeout,
50 Unknown
51 };
52
53 /**
54 * @brief Construct a downloader with a specific certificate
55 *
56 * @param[in] url the Url to download data from
57 * @param[in] certificate to accept https connection from
58 */
59 QString getDownloadedFileName();
60
61 protected:
62 void run();
63
64 private:
65 QString mUrl;
66 QByteArray mCert;
67
68 Q_SIGNALS:
69 /**
70 * @brief Some progress has been made.
71 *
72 * @param[out] message: A message to show. Can be empty.
73 * @param[out] current: Value of current progress.
74 * @param[out] total: Total value of possible progress
75 */
76 void progress(const QString &message, int current, int total);
77
78 /**
79 * @brief An error happened
80 *
81 * @param[out] message: A message to show. Can be empty.
82 * @param[out] errorCode: ErrorCode of this error.
83 * @param[out] total: Total value of possible progress.
84 */
85 void error(const QString &message, ErrorCode error);
86 };
87 #endif

http://wald.intevation.org/projects/trustbridge/