# HG changeset patch # User Raimund Renkert # Date 1398344173 -7200 # Node ID b8b0f9685ffa3c9b171cb48355eefc3a07c4ac53 # Parent 77d478a34f453f050d429141856720857785e2be# Parent 5c530b2eb0ebbc5cc31940e40f3ec0a14c31075c merged. diff -r 5c530b2eb0eb -r b8b0f9685ffa ui/downloader.cpp --- a/ui/downloader.cpp Thu Apr 24 10:53:56 2014 +0000 +++ b/ui/downloader.cpp Thu Apr 24 14:56:13 2014 +0200 @@ -214,6 +214,7 @@ emit progress(tr("Connected"), 1, -1); remoteModSW = getLastModifiedHeader(mResourceSW); + emit lastModifiedDate(remoteModSW); if (!remoteModSW.isValid()) { qDebug() << "Could not parse headers for Software"; diff -r 5c530b2eb0eb -r b8b0f9685ffa ui/downloader.h --- a/ui/downloader.h Thu Apr 24 10:53:56 2014 +0000 +++ b/ui/downloader.h Thu Apr 24 14:56:13 2014 +0200 @@ -149,5 +149,12 @@ * @param[out] errorCode: ErrorCode of this error. */ void error(const QString &message, SSLConnection::ErrorCode error); + + /** + * @brief Found the last modified date for software. + * + * @param[out] date The last modified date. + */ + void lastModifiedDate(const QDateTime &date); }; #endif diff -r 5c530b2eb0eb -r b8b0f9685ffa ui/main.cpp --- a/ui/main.cpp Thu Apr 24 10:53:56 2014 +0000 +++ b/ui/main.cpp Thu Apr 24 14:56:13 2014 +0200 @@ -50,7 +50,6 @@ settings.beginGroup("settings"); int autoStart = settings.value("autostart").toInt(); settings.endGroup(); - qDebug() << "autostart: " << autoStart; if (trayMode && autoStart <= 0) { return 0; diff -r 5c530b2eb0eb -r b8b0f9685ffa ui/mainwindow.cpp --- a/ui/mainwindow.cpp Thu Apr 24 10:53:56 2014 +0000 +++ b/ui/mainwindow.cpp Thu Apr 24 14:56:13 2014 +0200 @@ -36,6 +36,11 @@ #define SERVER_URL "https://files.intevation.de:443" #define LIST_RESOURCE "/users/aheinecke/zertifikatsliste_1.txt" #define SW_RESOURCE "/users/aheinecke/zertifikatsliste_1.txt" +#ifdef Q_OS_WIN +#define SW_RESOURCE_VERSION "/users/aheinecke/trustbridge-%1.exe" +#else +#define SW_RESOURCE_VERSION "/users/aheinecke/trustbridge-%1.sh" +#endif #include "certificatelist.h" #include "downloader.h" @@ -185,6 +190,10 @@ { verifyAvailableData(); + if (!mSettings.contains("Software/installedDate")) { + lookUpDateForVersion(); + return; + } QDateTime listInstalledLastMod = mSettings.value("List/installedDate").toDateTime(); QDateTime swInstalledLastMod = mSettings.value("Software/installedDate").toDateTime(); @@ -224,6 +233,37 @@ downloader->start(); } +void MainWindow::lookUpDateForVersion() +{ + QString softwareVersion = QString::fromLatin1(SW_RESOURCE_VERSION).arg( + QApplication::applicationVersion()); + qDebug() << softwareVersion; + QString listResource = QString::fromLatin1(LIST_RESOURCE); + Downloader* downloader = new Downloader(this, + QString::fromLatin1(SERVER_URL), + QByteArray(), + QDateTime::currentDateTime(), + QDateTime::currentDateTime(), + softwareVersion, + listResource, + false); + connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater())); + connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)), + this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode))); + connect(downloader, SIGNAL(lastModifiedDate(const QDateTime&)), + this, SLOT(setLastModifiedDate(const QDateTime&))); + + downloader->start(); +} + +void MainWindow::setLastModifiedDate(const QDateTime &date) +{ + mSettings.beginGroup("Software"); + mSettings.setValue("installedDate", date); + mSettings.endGroup(); + checkUpdates(); +} + void MainWindow::newSWAvailable(const QString &fileName, const QDateTime &date) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Information); diff -r 5c530b2eb0eb -r b8b0f9685ffa ui/mainwindow.h --- a/ui/mainwindow.h Thu Apr 24 10:53:56 2014 +0000 +++ b/ui/mainwindow.h Thu Apr 24 14:56:13 2014 +0200 @@ -83,6 +83,9 @@ void saveAutoUpdate(int state); void saveAutoStart(int state); + void lookUpDateForVersion(); + void setLastModifiedDate(const QDateTime &date); + /** @brief saves the currently unselected certificates * * This creates / updates a qsettings section that