[PATCH 2 of 4] Lookup the last modified date for software installer after first installation

Wald Commits scm-commit at wald.intevation.org
Thu Apr 24 14:56:27 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1398344122 -7200
# Node ID fa56a9403939a0c1f88105df57e450db35c6065c
# Parent  5834b340c54ce5f88b2790a4c9da5fba244a76b0
Lookup the last modified date for software installer after first installation.

diff -r 5834b340c54c -r fa56a9403939 ui/mainwindow.cpp
--- a/ui/mainwindow.cpp	Thu Apr 24 14:54:24 2014 +0200
+++ b/ui/mainwindow.cpp	Thu Apr 24 14:55:22 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 5834b340c54c -r fa56a9403939 ui/mainwindow.h
--- a/ui/mainwindow.h	Thu Apr 24 14:54:24 2014 +0200
+++ b/ui/mainwindow.h	Thu Apr 24 14:55:22 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


More information about the Trustbridge-commits mailing list