Mercurial > trustbridge
annotate ui/downloader.h @ 1287:d3d66d43365f
Merged
author | Emanuel Schuetze <emanuel@intevation.de> |
---|---|
date | Mon, 29 Sep 2014 13:02:41 +0200 |
parents | 2a1aa9df8f11 |
children |
rev | line source |
---|---|
404 | 1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=2) | |
5 * and comes with ABSOLUTELY NO WARRANTY! | |
6 * See LICENSE.txt for details. | |
7 */ | |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 #ifndef DOWNLOADER_H |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 #define DOWNLOADER_H |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 /** |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
11 * @file downloader.h |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
12 * @brief High level API to download necessary data. |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
13 * |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
14 */ |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
15 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
16 #include <QThread> |
45
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
32
diff
changeset
|
17 #include <QDateTime> |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
18 #include <QString> |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
19 #include <QByteArray> |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
20 |
45
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
32
diff
changeset
|
21 #include "sslconnection.h" |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
22 |
1255
2a1aa9df8f11
(issue133) Improve API documentation
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
23 /** @brief High level API to download necessary data. |
2a1aa9df8f11
(issue133) Improve API documentation
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
24 * |
2a1aa9df8f11
(issue133) Improve API documentation
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
25 * The downloader class is the UI interface to the Update server. |
2a1aa9df8f11
(issue133) Improve API documentation
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
26 * It controls the SSL Connection and checks if updates are available |
2a1aa9df8f11
(issue133) Improve API documentation
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
27 * and downloads them on demand. Each Downloader object is intended |
2a1aa9df8f11
(issue133) Improve API documentation
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
28 * to be run only once and controlled mainly by the constructor of |
2a1aa9df8f11
(issue133) Improve API documentation
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
29 * the object. |
2a1aa9df8f11
(issue133) Improve API documentation
Andre Heinecke <andre.heinecke@intevation.de>
parents:
1053
diff
changeset
|
30 */ |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
31 class Downloader: public QThread |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
32 { |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
33 Q_OBJECT |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
34 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
35 public: |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
36 /** |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
37 * @brief Construct a downloader with a specific certificate |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
38 * |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
39 * 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
|
40 * 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
|
41 * 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
|
42 * 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
|
43 * are downloaded. |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
44 * |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
45 * Downloaded files are placed in QStandardPaths::DataLocation |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
46 * |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
47 * @param[in] parent the parent object. |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
48 * @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
|
49 * @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
|
50 * @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
|
51 * @param[in] newestList datetime after which the list should be downloaded |
45
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
32
diff
changeset
|
52 * @param[in] resourceSW the path where the software is to be found |
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
32
diff
changeset
|
53 * @param[in] resourceList the path where the list is to be found |
1053
78798d3af8f0
Fixed doxygen build warnings.
Emanuel Schuetze <emanuel@intevation.de>
parents:
990
diff
changeset
|
54 * @param[in] downloadSW TODO |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
55 */ |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
56 Downloader(QObject* parent, const QString& url, |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
57 const QByteArray& certificate = QByteArray(), |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
58 const QDateTime& newestSW = QDateTime(), |
45
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
32
diff
changeset
|
59 const QDateTime& newestList = QDateTime(), |
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
32
diff
changeset
|
60 const QString& resourceSW = QString(), |
460
f8bed9008362
Added switch to download new available software.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
61 const QString& resourceList = QString(), |
f8bed9008362
Added switch to download new available software.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
62 bool downloadSW = true); |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
63 |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
64 ~Downloader(); |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
65 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
66 /** |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
67 * @brief get the directory where the downloader saves data |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
68 * |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
69 * 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
|
70 * is created. |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
71 * |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
72 * @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
|
73 **/ |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
74 QString getDataDirectory(); |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
75 |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
76 /** |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
77 * @brief get the current error state |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
78 * |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
79 * @returns The current error state. |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
80 **/ |
45
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
32
diff
changeset
|
81 SSLConnection::ErrorCode getErrorState(); |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
82 |
990
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
910
diff
changeset
|
83 |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
910
diff
changeset
|
84 /** |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
910
diff
changeset
|
85 * @brief forward the setCiphersuites call to the sslconnection |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
910
diff
changeset
|
86 * |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
910
diff
changeset
|
87 * see sslconnection.h for details. |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
910
diff
changeset
|
88 */ |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
910
diff
changeset
|
89 void setCiphersuites(int suites[]); |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
910
diff
changeset
|
90 |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
91 protected: |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
92 void run(); |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
93 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
94 private: |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
95 QDateTime mLastModSW; |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
96 QDateTime mLastModList; |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
97 |
45
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
32
diff
changeset
|
98 QString mResourceSW; |
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
32
diff
changeset
|
99 QString mResourceList; |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
15
diff
changeset
|
100 |
460
f8bed9008362
Added switch to download new available software.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
101 bool mDownloadSW; |
f8bed9008362
Added switch to download new available software.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
102 |
908
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
485
diff
changeset
|
103 SSLConnection *mSSLConnection; |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
104 |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
105 Q_SIGNALS: |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
106 /** |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
107 * @brief software update is available |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
108 */ |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
109 void newSoftwareAvailable(const QString &fileName, |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
110 const QDateTime &lastMod); |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
111 |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
112 /** |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
113 * @brief new certificate list available |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
114 */ |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
115 void newListAvailable(const QString &fileName, const QDateTime &lastMod); |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
116 |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
10
diff
changeset
|
117 /** |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
118 * @brief Some progress has been made. |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
119 * |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
120 * @param[out] message: A message to show. Can be empty. |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
121 * @param[out] current: Value of current progress. |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
122 * @param[out] total: Total value of possible progress |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
123 */ |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
124 void progress(const QString &message, int current, int total); |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
125 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
126 /** |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
127 * @brief An error happened |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
128 * |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
129 * @param[out] message: A message to show. Can be empty. |
1053
78798d3af8f0
Fixed doxygen build warnings.
Emanuel Schuetze <emanuel@intevation.de>
parents:
990
diff
changeset
|
130 * @param[out] error: ErrorCode of this error. |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
131 */ |
45
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
32
diff
changeset
|
132 void error(const QString &message, SSLConnection::ErrorCode error); |
485
5834b340c54c
Emit a signal for last modified date in downloader.
Raimund Renkert <rrenkert@intevation.de>
parents:
460
diff
changeset
|
133 |
5834b340c54c
Emit a signal for last modified date in downloader.
Raimund Renkert <rrenkert@intevation.de>
parents:
460
diff
changeset
|
134 /** |
5834b340c54c
Emit a signal for last modified date in downloader.
Raimund Renkert <rrenkert@intevation.de>
parents:
460
diff
changeset
|
135 * @brief Found the last modified date for software. |
5834b340c54c
Emit a signal for last modified date in downloader.
Raimund Renkert <rrenkert@intevation.de>
parents:
460
diff
changeset
|
136 * |
5834b340c54c
Emit a signal for last modified date in downloader.
Raimund Renkert <rrenkert@intevation.de>
parents:
460
diff
changeset
|
137 * @param[out] date The last modified date. |
5834b340c54c
Emit a signal for last modified date in downloader.
Raimund Renkert <rrenkert@intevation.de>
parents:
460
diff
changeset
|
138 */ |
5834b340c54c
Emit a signal for last modified date in downloader.
Raimund Renkert <rrenkert@intevation.de>
parents:
460
diff
changeset
|
139 void lastModifiedDate(const QDateTime &date); |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
140 }; |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
141 #endif |