changeset 591:26a18e3c3db4

Cleanups and coding style.
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 28 May 2014 07:56:21 +0000
parents c93730ef2a3a
children 778f74d0706f
files common/binverify.c ui/mainwindow.cpp
diffstat 2 files changed, 32 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/common/binverify.c	Wed May 28 07:55:35 2014 +0000
+++ b/common/binverify.c	Wed May 28 07:56:21 2014 +0000
@@ -50,7 +50,7 @@
       return VerifyUnknownError;
     }
 
-  filenameW = utf8_to_wchar(filename, strnlen(filename, MAX_PATH));
+  filenameW = utf8_to_wchar(filename, name_len);
 
   result = CryptQueryObject (CERT_QUERY_OBJECT_FILE,
                              filenameW,
--- a/ui/mainwindow.cpp	Wed May 28 07:55:35 2014 +0000
+++ b/ui/mainwindow.cpp	Wed May 28 07:56:21 2014 +0000
@@ -117,9 +117,12 @@
 
 void MainWindow::showMessage()
 {
-    if (!isVisible() && !mCurMessage.isEmpty()) {
+    if (mCurMessage.isEmpty()) {
+        return;
+    }
+    if (mCurState == NewSoftwareAvailable || !isVisible()) {
         mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage,
-                               QSystemTrayIcon::Information, 5000);
+                               QSystemTrayIcon::Information, 10000);
         mMessageTimer->start(); // Restart the timer so that we don't spam
     }
 }
@@ -165,29 +168,34 @@
 {
     QString swFileName = mSettings.value("Software/available").toString();
 
-    if (!swFileName.isEmpty()) {
-        QFileInfo fi(swFileName);
-        if (!fi.exists()) {
-            mSettings.remove("Software/available");
-            mSettings.remove("Software/availableDate");
-        }
-        if (!fi.isExecutable()) {
-            qWarning() << "Downloaded file: " << swFileName << " is not executable.";
-            setState(TransferError);
-            return;
-        }
-        bin_verify_result verifyResult = verify_binary(swFileName.toUtf8().constData(),
-                swFileName.toUtf8().size());
-        qDebug() << "Binary verify result: " << verifyResult;
-        if (verifyResult != VerifyValid) {
-            qDebug() << "Failed to verify downloaded data. Retrying.";
-            QFile::remove(swFileName);
-            mSettings.remove("Software/available");
-            mSettings.remove("Software/availableDate");
-        }
-    } else {
+    if (swFileName.isEmpty()) {
+        mSettings.remove("Software/availableDate");
+        return;
+    }
+
+    QFileInfo fi(swFileName);
+    if (!fi.exists()) {
         mSettings.remove("Software/available");
         mSettings.remove("Software/availableDate");
+        qDebug() << "Software does not yet exist.";
+        return;
+    }
+    if (!fi.isExecutable()) {
+        qWarning() << "Downloaded file: " << swFileName << " is not executable.";
+        QFile::remove(swFileName);
+        mSettings.remove("Software/available");
+        mSettings.remove("Software/availableDate");
+        return;
+    }
+    bin_verify_result verifyResult = verify_binary(swFileName.toUtf8().constData(),
+            swFileName.toUtf8().size());
+    qDebug() << "Binary verify result: " << verifyResult;
+    if (verifyResult != VerifyValid) {
+        qDebug() << "Failed to verify downloaded data.";
+        QFile::remove(swFileName);
+        mSettings.remove("Software/available");
+        mSettings.remove("Software/availableDate");
+        return;
     }
 }
 

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