diff ui/mainwindow.cpp @ 591:26a18e3c3db4

Cleanups and coding style.
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 28 May 2014 07:56:21 +0000
parents 02a89710a7cd
children 778f74d0706f
line wrap: on
line diff
--- 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/