[PATCH 2 of 3] Cleanups and coding style

Wald Commits scm-commit at wald.intevation.org
Wed May 28 10:36:09 CEST 2014


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1401263781 0
# Node ID 26a18e3c3db4820968e8b6b2591f94643e4e87b7
# Parent  c93730ef2a3aed716e5f97ec131971801a77dd88
Cleanups and coding style.

diff -r c93730ef2a3a -r 26a18e3c3db4 common/binverify.c
--- 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,
diff -r c93730ef2a3a -r 26a18e3c3db4 ui/mainwindow.cpp
--- 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;
     }
 }
 


More information about the Trustbridge-commits mailing list