Mercurial > trustbridge
annotate ui/downloader.h @ 40:5cb1eb928253
Clean up debug output / functions
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 14 Mar 2014 09:47:42 +0000 |
parents | d8e93fa1fc93 |
children | c6125d73faf4 |
rev | line source |
---|---|
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
1 #ifndef DOWNLOADER_H |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
2 #define DOWNLOADER_H |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
3 /** |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
4 * @file downloader.h |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
5 * @brief High level API to download necessary data. |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
6 * |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
7 */ |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 #include <QThread> |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 #include <QString> |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
11 #include <QByteArray> |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
12 #include <QDateTime> |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
13 #include <QUrl> |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
14 |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
15 #include <polarssl/x509_crt.h> |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
16 #include <polarssl/entropy.h> |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
17 #include <polarssl/ctr_drbg.h> |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
18 #include <polarssl/ssl.h> |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
19 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
20 class Downloader: public QThread |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
21 { |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
22 Q_OBJECT |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
23 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
24 public: |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
25 /** |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
26 * @brief Construct a downloader with a specific certificate |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
27 * |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
28 * The downloader will check the last-modified date of the |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
29 * certificate list / sw on the server at the specified url |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
30 * and download those accordingly. If newestSW or newestList is |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
31 * are valid datetimes only files modified after the respective date |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
32 * are downloaded. |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
33 * |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
34 * Downloaded files are placed in QStandardPaths::DataLocation |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
35 * |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
36 * @param[in] parent the parent object. |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
37 * @param[in] url the Url to download data from |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
38 * @param[in] certificate optional certificate to validate https connection |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
39 * @param[in] newestSW datetime after which software should be downloaded |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
40 * @param[in] newestList datetime after which the list should be downloaded |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
41 */ |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
42 Downloader(QObject* parent, const QString& url, |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
43 const QByteArray& certificate = QByteArray(), |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
44 const QDateTime& newestSW = QDateTime(), |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
45 const QDateTime& newestList = QDateTime()); |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
46 |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
47 ~Downloader(); |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
48 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
49 enum ErrorCode { |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
50 NoError, |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
51 NoConnection, |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
52 SSLHandshakeFailed, |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
53 InvalidCertificate, |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
54 InvalidPinnedCertificate, |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
55 InvalidResponse, |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
56 ConnectionLost, |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
57 Timeout, |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
58 ErrUnknown |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
59 }; |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
60 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
61 /** |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
62 * @brief get the directory where the downloader saves data |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
63 * |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
64 * If the directory does not exist this function ensures that it |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
65 * is created. |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
66 * |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
67 * @returns The directory in which downloaded files are placed. |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
68 **/ |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
69 QString getDataDirectory(); |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
70 |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
71 /** |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
72 * @brief get the current error state |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
73 * |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
74 * @returns The current error state. |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
75 **/ |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
76 ErrorCode getErrorState(); |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
77 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
78 protected: |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
79 void run(); |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
80 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
81 private: |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
82 QUrl mUrl; |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
83 QByteArray mPinnedCert; |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
84 x509_crt mX509PinnedCert; |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
85 entropy_context mEntropy; |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
86 ctr_drbg_context mCtr_drbg; |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
87 ssl_context mSSL; |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
88 |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
89 QDateTime mLastModSW; |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
90 QDateTime mLastModList; |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
91 |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
92 /* Convienience to avoid having to parse all |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
93 * PolarSSL errors */ |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
94 ErrorCode mErrorState; |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
95 |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
96 bool mInitialized; |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
97 bool mConnectionEstablished; |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
98 |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
99 int mServerFD; |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
100 |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
101 |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
102 /* @brief: Initialize polarssl structures |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
103 * |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
104 * This wraps polarssl initialization functions |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
105 * that can return an error. |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
106 * Sets the error state accordingly. |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
107 * |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
108 * @returns: 0 on success a polarssl error otherwise. |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
109 */ |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
110 int init(); |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
111 |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
112 /** @brief: Establish the ssl connection |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
113 * |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
114 * Modifies the error state. Before calling this the mServerFD should |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
115 * be set to a valid socket. |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
116 * |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
117 * @returns 0 on success otherwise a polarssl error or -1 is returned |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
118 */ |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
119 int establishSSLConnection(); |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
120 |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
121 /** @brief get the last modified header of a resource. |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
122 * |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
123 * Connection should be established beforehand. |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
124 * Modifies the error state. |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
125 * |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
126 * @param[in] resource The resource to check |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
127 * |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
128 * @returns the last modified date or a null datetime in case of errors |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
129 */ |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
130 QDateTime getLastModifiedHeader(const QString &resource); |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
131 |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
132 /** @brief Download resource |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
133 * |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
134 * Download a resource with the established connection. |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
135 * Modifies the error state. |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
136 * |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
137 * @param[in] resource the resource to download |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
138 * @param[in] filename where the file should be saved. |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
139 * @param[in] maxSize maximum amount of bytes to download |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
140 * |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
141 * @returns True if the download was successful. |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
142 */ |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
143 bool downloadFile(const QString &resource, const QString &filename, |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
144 size_t maxSize); |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
145 |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
146 Q_SIGNALS: |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
147 /** |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
148 * @brief software update is available |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
149 */ |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
150 void newSoftwareAvailable(const QString &fileName, |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
151 const QDateTime &lastMod); |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
152 |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
153 /** |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
154 * @brief new certificate list available |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
155 */ |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
156 void newListAvailable(const QString &fileName, const QDateTime &lastMod); |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
157 |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
158 /** |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
159 * @brief Some progress has been made. |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
160 * |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
161 * @param[out] message: A message to show. Can be empty. |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
162 * @param[out] current: Value of current progress. |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
163 * @param[out] total: Total value of possible progress |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
164 */ |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
165 void progress(const QString &message, int current, int total); |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
166 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
167 /** |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
168 * @brief An error happened |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
169 * |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
170 * @param[out] message: A message to show. Can be empty. |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
171 * @param[out] errorCode: ErrorCode of this error. |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
172 */ |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
173 void error(const QString &message, Downloader::ErrorCode error); |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
174 }; |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
175 #endif |