changeset 488:b8b0f9685ffa

merged.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 24 Apr 2014 14:56:13 +0200
parents 77d478a34f45 (diff) 5c530b2eb0eb (current diff)
children a9da8e4eeff7 c495dd026d61
files
diffstat 5 files changed, 51 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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";
--- 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
--- 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;
--- 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);
--- 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

http://wald.intevation.org/projects/trustbridge/