Mercurial > trustbridge
comparison ui/mainwindow.cpp @ 486:fa56a9403939
Lookup the last modified date for software installer after first installation.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 24 Apr 2014 14:55:22 +0200 |
parents | 9be337ea1e3c |
children | 077b4342d69b ca583ffe728a |
comparison
equal
deleted
inserted
replaced
485:5834b340c54c | 486:fa56a9403939 |
---|---|
34 #endif | 34 #endif |
35 | 35 |
36 #define SERVER_URL "https://files.intevation.de:443" | 36 #define SERVER_URL "https://files.intevation.de:443" |
37 #define LIST_RESOURCE "/users/aheinecke/zertifikatsliste_1.txt" | 37 #define LIST_RESOURCE "/users/aheinecke/zertifikatsliste_1.txt" |
38 #define SW_RESOURCE "/users/aheinecke/zertifikatsliste_1.txt" | 38 #define SW_RESOURCE "/users/aheinecke/zertifikatsliste_1.txt" |
39 #ifdef Q_OS_WIN | |
40 #define SW_RESOURCE_VERSION "/users/aheinecke/trustbridge-%1.exe" | |
41 #else | |
42 #define SW_RESOURCE_VERSION "/users/aheinecke/trustbridge-%1.sh" | |
43 #endif | |
39 | 44 |
40 #include "certificatelist.h" | 45 #include "certificatelist.h" |
41 #include "downloader.h" | 46 #include "downloader.h" |
42 #include "helpdialog.h" | 47 #include "helpdialog.h" |
43 #include "aboutdialog.h" | 48 #include "aboutdialog.h" |
183 | 188 |
184 void MainWindow::checkUpdates(bool downloadSW) | 189 void MainWindow::checkUpdates(bool downloadSW) |
185 { | 190 { |
186 verifyAvailableData(); | 191 verifyAvailableData(); |
187 | 192 |
193 if (!mSettings.contains("Software/installedDate")) { | |
194 lookUpDateForVersion(); | |
195 return; | |
196 } | |
188 QDateTime listInstalledLastMod = mSettings.value("List/installedDate").toDateTime(); | 197 QDateTime listInstalledLastMod = mSettings.value("List/installedDate").toDateTime(); |
189 QDateTime swInstalledLastMod = mSettings.value("Software/installedDate").toDateTime(); | 198 QDateTime swInstalledLastMod = mSettings.value("Software/installedDate").toDateTime(); |
190 | 199 |
191 QString listResource = QString::fromLatin1(LIST_RESOURCE); | 200 QString listResource = QString::fromLatin1(LIST_RESOURCE); |
192 QString swResource = QString::fromLatin1(SW_RESOURCE); | 201 QString swResource = QString::fromLatin1(SW_RESOURCE); |
220 } | 229 } |
221 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater())); | 230 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater())); |
222 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)), | 231 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)), |
223 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode))); | 232 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode))); |
224 downloader->start(); | 233 downloader->start(); |
234 } | |
235 | |
236 void MainWindow::lookUpDateForVersion() | |
237 { | |
238 QString softwareVersion = QString::fromLatin1(SW_RESOURCE_VERSION).arg( | |
239 QApplication::applicationVersion()); | |
240 qDebug() << softwareVersion; | |
241 QString listResource = QString::fromLatin1(LIST_RESOURCE); | |
242 Downloader* downloader = new Downloader(this, | |
243 QString::fromLatin1(SERVER_URL), | |
244 QByteArray(), | |
245 QDateTime::currentDateTime(), | |
246 QDateTime::currentDateTime(), | |
247 softwareVersion, | |
248 listResource, | |
249 false); | |
250 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater())); | |
251 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)), | |
252 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode))); | |
253 connect(downloader, SIGNAL(lastModifiedDate(const QDateTime&)), | |
254 this, SLOT(setLastModifiedDate(const QDateTime&))); | |
255 | |
256 downloader->start(); | |
257 } | |
258 | |
259 void MainWindow::setLastModifiedDate(const QDateTime &date) | |
260 { | |
261 mSettings.beginGroup("Software"); | |
262 mSettings.setValue("installedDate", date); | |
263 mSettings.endGroup(); | |
264 checkUpdates(); | |
225 } | 265 } |
226 | 266 |
227 void MainWindow::newSWAvailable(const QString &fileName, const QDateTime &date) { | 267 void MainWindow::newSWAvailable(const QString &fileName, const QDateTime &date) { |
228 QMessageBox msgBox; | 268 QMessageBox msgBox; |
229 msgBox.setIcon(QMessageBox::Information); | 269 msgBox.setIcon(QMessageBox::Information); |