Mercurial > trustbridge
annotate ui/downloader.cpp @ 1075:7e1fd6d96714
(issue109) Feedback improved. Shell translation updated.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Thu, 11 Sep 2014 10:18:46 +0200 (2014-09-11) |
parents | 515345358b71 |
children | 508c96e72f62 |
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 #include "downloader.h" |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 #ifndef DOWNLOAD_SERVER |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
11 #define DOWNLOAD_SERVER "https://www.intevation.de" |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
12 #endif |
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 #include <QFile> |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
15 #include <QDir> |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
16 #include <QDebug> |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
17 #include <QStandardPaths> |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
18 #include <QLocale> |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
19 #include <QSaveFile> |
956
879a634d0a40
(issue41) Add proxy support
Andre Heinecke <andre.heinecke@intevation.de>
parents:
924
diff
changeset
|
20 #include <QSettings> |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
21 |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
22 #include <polarssl/net.h> |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
23 #include <polarssl/ssl.h> |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
24 #include <polarssl/entropy.h> |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
25 #include <polarssl/ctr_drbg.h> |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
26 #include <polarssl/error.h> |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
27 #include <polarssl/certs.h> |
990
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
28 #include <polarssl/ssl_ciphersuites.h> |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
29 |
808
13cf42dbe9bd
Increase MAX SW size to 15mb
Andre Heinecke <andre.heinecke@intevation.de>
parents:
553
diff
changeset
|
30 #define MAX_SW_SIZE 15728640 |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
31 #define MAX_LIST_SIZE 1048576 |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
32 |
924
75085f7adc78
Only include sslconnection_curl if curl is used
Andre Heinecke <andre.heinecke@intevation.de>
parents:
910
diff
changeset
|
33 #ifdef USE_CURL |
908
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
809
diff
changeset
|
34 #include "sslconnection_curl.h" |
924
75085f7adc78
Only include sslconnection_curl if curl is used
Andre Heinecke <andre.heinecke@intevation.de>
parents:
910
diff
changeset
|
35 #else |
908
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
809
diff
changeset
|
36 #include "sslconnection_bare.h" |
924
75085f7adc78
Only include sslconnection_curl if curl is used
Andre Heinecke <andre.heinecke@intevation.de>
parents:
910
diff
changeset
|
37 #endif |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
38 |
990
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
39 #ifdef RELEASE_BUILD |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
40 static int accept_ciphers[] = { |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
41 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
42 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
43 TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
44 0 |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
45 }; |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
46 #else |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
47 static int accept_ciphers[] = { |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
48 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
49 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
50 TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
51 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
52 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
53 TLS_RSA_WITH_AES_256_CBC_SHA, |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
54 0 |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
55 }; |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
56 #endif |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
57 |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
58 Downloader::Downloader(QObject* parent, const QString& url, |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
59 const QByteArray& certificate, |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
60 const QDateTime& newestSW, |
45
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
35
diff
changeset
|
61 const QDateTime& newestList, |
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
35
diff
changeset
|
62 const QString& resourceSW, |
460
f8bed9008362
Added switch to download new available software.
Raimund Renkert <rrenkert@intevation.de>
parents:
459
diff
changeset
|
63 const QString& resourceList, |
f8bed9008362
Added switch to download new available software.
Raimund Renkert <rrenkert@intevation.de>
parents:
459
diff
changeset
|
64 bool downloadSW): |
12
9121eea6d93f
Fix constructor usage. Too much Java.
Andre Heinecke <aheinecke@intevation.de>
parents:
11
diff
changeset
|
65 QThread(parent), |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
66 mLastModSW(newestSW), |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
67 mLastModList(newestList), |
45
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
35
diff
changeset
|
68 mResourceSW(resourceSW), |
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
35
diff
changeset
|
69 mResourceList(resourceList), |
908
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
809
diff
changeset
|
70 mDownloadSW(downloadSW) |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
71 { |
908
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
809
diff
changeset
|
72 #ifdef USE_CURL |
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
809
diff
changeset
|
73 mSSLConnection = new SSLConnectionCurl(url, certificate); |
956
879a634d0a40
(issue41) Add proxy support
Andre Heinecke <andre.heinecke@intevation.de>
parents:
924
diff
changeset
|
74 /* Set up Proxy support. */ |
879a634d0a40
(issue41) Add proxy support
Andre Heinecke <andre.heinecke@intevation.de>
parents:
924
diff
changeset
|
75 QSettings settings; |
879a634d0a40
(issue41) Add proxy support
Andre Heinecke <andre.heinecke@intevation.de>
parents:
924
diff
changeset
|
76 QString settingsProxy = settings.value("ProxyURL").toString(); |
1062
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
990
diff
changeset
|
77 bool useProxy = settings.value("UseProxy", false).toBool(); |
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
990
diff
changeset
|
78 if (useProxy && settingsProxy.isEmpty()) { |
956
879a634d0a40
(issue41) Add proxy support
Andre Heinecke <andre.heinecke@intevation.de>
parents:
924
diff
changeset
|
79 QByteArray envProxy = qgetenv("http_proxy"); |
879a634d0a40
(issue41) Add proxy support
Andre Heinecke <andre.heinecke@intevation.de>
parents:
924
diff
changeset
|
80 if (envProxy.size()) { |
879a634d0a40
(issue41) Add proxy support
Andre Heinecke <andre.heinecke@intevation.de>
parents:
924
diff
changeset
|
81 settingsProxy = QString::fromLocal8Bit(envProxy); |
879a634d0a40
(issue41) Add proxy support
Andre Heinecke <andre.heinecke@intevation.de>
parents:
924
diff
changeset
|
82 } |
879a634d0a40
(issue41) Add proxy support
Andre Heinecke <andre.heinecke@intevation.de>
parents:
924
diff
changeset
|
83 } |
1062
515345358b71
(issue41) Add and use a UseProxy checkbox
Andre Heinecke <andre.heinecke@intevation.de>
parents:
990
diff
changeset
|
84 if (useProxy && !settingsProxy.isEmpty()) { |
956
879a634d0a40
(issue41) Add proxy support
Andre Heinecke <andre.heinecke@intevation.de>
parents:
924
diff
changeset
|
85 mSSLConnection->setProxy(QUrl(settingsProxy)); |
879a634d0a40
(issue41) Add proxy support
Andre Heinecke <andre.heinecke@intevation.de>
parents:
924
diff
changeset
|
86 } |
908
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
809
diff
changeset
|
87 #else |
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
809
diff
changeset
|
88 mSSLConnection = new SSLConnectionBare(url, certificate); |
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
809
diff
changeset
|
89 #endif |
990
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
90 setCiphersuites(accept_ciphers); |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
91 } |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
92 |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
93 Downloader::~Downloader() { |
908
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
809
diff
changeset
|
94 delete mSSLConnection; |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
95 } |
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
96 |
990
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
97 void Downloader::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:
956
diff
changeset
|
98 mSSLConnection->setCiphersuites(suites); |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
99 } |
2949f1842955
(issue90) Add possibility to force cipher suites in bare connection and test for this
Andre Heinecke <andre.heinecke@intevation.de>
parents:
956
diff
changeset
|
100 |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
101 QString Downloader::getDataDirectory() |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
102 { |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
103 QString candidate = |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
104 QStandardPaths::writableLocation(QStandardPaths::DataLocation); |
12
9121eea6d93f
Fix constructor usage. Too much Java.
Andre Heinecke <aheinecke@intevation.de>
parents:
11
diff
changeset
|
105 |
15
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
106 if (candidate.isEmpty()) { |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
107 qDebug() << "Could not find writeable locaction for me"; |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
108 return QString(); |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
109 } |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
110 |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
111 QDir cDir(candidate); |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
112 |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
113 if (!cDir.exists()) { |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
114 if (!cDir.mkpath(candidate)) { |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
115 qDebug() << "Could not create path to: " << candidate; |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
116 return QString(); |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
117 } |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
118 } |
95e1b6edf2fc
Implement more downloader functionality for Windows
Andre Heinecke <aheinecke@intevation.de>
parents:
12
diff
changeset
|
119 return cDir.absolutePath(); |
10
fe39d93f1261
Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
120 } |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
121 |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
122 |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
123 void Downloader::run() { |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
124 int ret; |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
125 QDateTime remoteModList; |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
126 QDateTime remoteModSW; |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
127 |
908
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
809
diff
changeset
|
128 if (!mSSLConnection->initialized()) { |
45
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
35
diff
changeset
|
129 emit error(tr("Failed to initialize SSL Module."), SSLConnection::ErrUnknown); |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
130 return; |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
131 } |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
132 |
908
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
809
diff
changeset
|
133 ret = mSSLConnection->connect(); |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
134 |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
135 if (ret != 0) { |
45
c6125d73faf4
Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents:
35
diff
changeset
|
136 emit error(tr("Failed to connect."), |
908
d1c951b3012d
Curl based implementation of sslconnection
Andre Heinecke <andre.heinecke@intevation.de>
parents:
809
diff
changeset
|
137 mSSLConnection->getLastError()); |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
138 return; |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
139 } |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
140 |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
141 emit progress(tr("Connected"), 1, -1); |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
142 |
910
eaed02defe6a
More SSLConnection refactoring. Fixes curl downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
908
diff
changeset
|
143 remoteModSW = mSSLConnection->getLastModifiedHeader(mResourceSW); |
485
5834b340c54c
Emit a signal for last modified date in downloader.
Raimund Renkert <rrenkert@intevation.de>
parents:
460
diff
changeset
|
144 emit lastModifiedDate(remoteModSW); |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
145 |
459
34cc448409ec
Fix error handling
Andre Heinecke <aheinecke@intevation.de>
parents:
458
diff
changeset
|
146 if (!remoteModSW.isValid()) { |
910
eaed02defe6a
More SSLConnection refactoring. Fixes curl downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
908
diff
changeset
|
147 emit error (tr("Connection failed."), SSLConnection::InvalidResponse); |
459
34cc448409ec
Fix error handling
Andre Heinecke <aheinecke@intevation.de>
parents:
458
diff
changeset
|
148 qDebug() << "Could not parse headers for Software"; |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
149 return; |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
150 } |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
151 |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
152 if (!mLastModSW.isValid() || remoteModSW > mLastModSW) { |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
153 QString dataDirectory = getDataDirectory(); |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
154 |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
155 if (dataDirectory.isEmpty()) { |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
156 qDebug() << "Failed to get data directory"; |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
157 return; |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
158 } |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
159 |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
160 QString fileName = dataDirectory.append("/SW-") |
442
d2f4e28b5a13
Fix date format for file names
Andre Heinecke <aheinecke@intevation.de>
parents:
404
diff
changeset
|
161 .append(remoteModSW.toString("yyyyMMddHHmmss")) |
809
4b702f6cf9b6
Download sofware with .sh extension on linux and make it exeutable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
808
diff
changeset
|
162 #ifdef WIN32 |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
163 .append(".exe"); |
809
4b702f6cf9b6
Download sofware with .sh extension on linux and make it exeutable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
808
diff
changeset
|
164 #else |
4b702f6cf9b6
Download sofware with .sh extension on linux and make it exeutable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
808
diff
changeset
|
165 .append(".sh"); |
4b702f6cf9b6
Download sofware with .sh extension on linux and make it exeutable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
808
diff
changeset
|
166 #endif |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
167 |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
168 qDebug() << "fileName: " << fileName; |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
169 |
460
f8bed9008362
Added switch to download new available software.
Raimund Renkert <rrenkert@intevation.de>
parents:
459
diff
changeset
|
170 if (mDownloadSW) { |
910
eaed02defe6a
More SSLConnection refactoring. Fixes curl downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
908
diff
changeset
|
171 if (!mSSLConnection->downloadFile(mResourceSW, fileName, MAX_SW_SIZE)) { |
eaed02defe6a
More SSLConnection refactoring. Fixes curl downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
908
diff
changeset
|
172 emit error(tr("Failed to download File"), SSLConnection::ConnectionLost); |
809
4b702f6cf9b6
Download sofware with .sh extension on linux and make it exeutable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
808
diff
changeset
|
173 qDebug() << "Failed to download software update."; |
460
f8bed9008362
Added switch to download new available software.
Raimund Renkert <rrenkert@intevation.de>
parents:
459
diff
changeset
|
174 return; |
f8bed9008362
Added switch to download new available software.
Raimund Renkert <rrenkert@intevation.de>
parents:
459
diff
changeset
|
175 } |
809
4b702f6cf9b6
Download sofware with .sh extension on linux and make it exeutable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
808
diff
changeset
|
176 QFile::setPermissions(fileName, QFileDevice::ReadOwner | |
4b702f6cf9b6
Download sofware with .sh extension on linux and make it exeutable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
808
diff
changeset
|
177 QFileDevice::WriteOwner | |
4b702f6cf9b6
Download sofware with .sh extension on linux and make it exeutable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
808
diff
changeset
|
178 QFileDevice::ExeOwner); |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
179 } |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
180 |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
181 emit newSoftwareAvailable(fileName, remoteModSW); |
458
6fac87cadbd8
Only check for list if now sw is available
Andre Heinecke <aheinecke@intevation.de>
parents:
443
diff
changeset
|
182 return; |
6fac87cadbd8
Only check for list if now sw is available
Andre Heinecke <aheinecke@intevation.de>
parents:
443
diff
changeset
|
183 } |
6fac87cadbd8
Only check for list if now sw is available
Andre Heinecke <aheinecke@intevation.de>
parents:
443
diff
changeset
|
184 |
910
eaed02defe6a
More SSLConnection refactoring. Fixes curl downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
908
diff
changeset
|
185 remoteModList = mSSLConnection->getLastModifiedHeader(mResourceList); |
459
34cc448409ec
Fix error handling
Andre Heinecke <aheinecke@intevation.de>
parents:
458
diff
changeset
|
186 if (!remoteModList.isValid()) { |
910
eaed02defe6a
More SSLConnection refactoring. Fixes curl downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
908
diff
changeset
|
187 emit error (tr("Connection failed."), SSLConnection::InvalidResponse); |
459
34cc448409ec
Fix error handling
Andre Heinecke <aheinecke@intevation.de>
parents:
458
diff
changeset
|
188 qDebug() << "Could not parse headers for List"; |
34cc448409ec
Fix error handling
Andre Heinecke <aheinecke@intevation.de>
parents:
458
diff
changeset
|
189 return; |
34cc448409ec
Fix error handling
Andre Heinecke <aheinecke@intevation.de>
parents:
458
diff
changeset
|
190 } |
458
6fac87cadbd8
Only check for list if now sw is available
Andre Heinecke <aheinecke@intevation.de>
parents:
443
diff
changeset
|
191 |
6fac87cadbd8
Only check for list if now sw is available
Andre Heinecke <aheinecke@intevation.de>
parents:
443
diff
changeset
|
192 if (!mLastModList.isValid() || remoteModList > mLastModList) { |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
193 QString dataDirectory = getDataDirectory(); |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
194 |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
195 if (dataDirectory.isEmpty()) { |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
196 qDebug() << "Failed to get data directory"; |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
197 return; |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
198 } |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
199 |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
200 QString fileName = dataDirectory.append("/list-") |
443
20f539866fa8
Fixed certificate list file name.
Raimund Renkert <rrenkert@intevation.de>
parents:
442
diff
changeset
|
201 .append(remoteModList.toString("yyyyMMddHHmmss")) |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
202 .append(".txt"); |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
203 |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
204 qDebug() << "fileName: " << fileName; |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
205 |
910
eaed02defe6a
More SSLConnection refactoring. Fixes curl downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
908
diff
changeset
|
206 if (!mSSLConnection->downloadFile(mResourceList, fileName, MAX_LIST_SIZE)) { |
32
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
207 return; |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
208 } |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
209 |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
210 emit newListAvailable(fileName, remoteModList); |
d8e93fa1fc93
Downloader logic
Andre Heinecke <andre.heinecke@intevation.de>
parents:
27
diff
changeset
|
211 } |
27
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
212 |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
213 emit progress(tr("Closing"), 1, -1); |
62cd56cea09b
Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
18
diff
changeset
|
214 } |