comparison 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
comparison
equal deleted inserted replaced
590:c93730ef2a3a 591:26a18e3c3db4
115 } 115 }
116 } 116 }
117 117
118 void MainWindow::showMessage() 118 void MainWindow::showMessage()
119 { 119 {
120 if (!isVisible() && !mCurMessage.isEmpty()) { 120 if (mCurMessage.isEmpty()) {
121 return;
122 }
123 if (mCurState == NewSoftwareAvailable || !isVisible()) {
121 mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage, 124 mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage,
122 QSystemTrayIcon::Information, 5000); 125 QSystemTrayIcon::Information, 10000);
123 mMessageTimer->start(); // Restart the timer so that we don't spam 126 mMessageTimer->start(); // Restart the timer so that we don't spam
124 } 127 }
125 } 128 }
126 129
127 void MainWindow::verifyListData() 130 void MainWindow::verifyListData()
163 166
164 void MainWindow::verifySWData() 167 void MainWindow::verifySWData()
165 { 168 {
166 QString swFileName = mSettings.value("Software/available").toString(); 169 QString swFileName = mSettings.value("Software/available").toString();
167 170
168 if (!swFileName.isEmpty()) { 171 if (swFileName.isEmpty()) {
169 QFileInfo fi(swFileName); 172 mSettings.remove("Software/availableDate");
170 if (!fi.exists()) { 173 return;
171 mSettings.remove("Software/available"); 174 }
172 mSettings.remove("Software/availableDate"); 175
173 } 176 QFileInfo fi(swFileName);
174 if (!fi.isExecutable()) { 177 if (!fi.exists()) {
175 qWarning() << "Downloaded file: " << swFileName << " is not executable.";
176 setState(TransferError);
177 return;
178 }
179 bin_verify_result verifyResult = verify_binary(swFileName.toUtf8().constData(),
180 swFileName.toUtf8().size());
181 qDebug() << "Binary verify result: " << verifyResult;
182 if (verifyResult != VerifyValid) {
183 qDebug() << "Failed to verify downloaded data. Retrying.";
184 QFile::remove(swFileName);
185 mSettings.remove("Software/available");
186 mSettings.remove("Software/availableDate");
187 }
188 } else {
189 mSettings.remove("Software/available"); 178 mSettings.remove("Software/available");
190 mSettings.remove("Software/availableDate"); 179 mSettings.remove("Software/availableDate");
180 qDebug() << "Software does not yet exist.";
181 return;
182 }
183 if (!fi.isExecutable()) {
184 qWarning() << "Downloaded file: " << swFileName << " is not executable.";
185 QFile::remove(swFileName);
186 mSettings.remove("Software/available");
187 mSettings.remove("Software/availableDate");
188 return;
189 }
190 bin_verify_result verifyResult = verify_binary(swFileName.toUtf8().constData(),
191 swFileName.toUtf8().size());
192 qDebug() << "Binary verify result: " << verifyResult;
193 if (verifyResult != VerifyValid) {
194 qDebug() << "Failed to verify downloaded data.";
195 QFile::remove(swFileName);
196 mSettings.remove("Software/available");
197 mSettings.remove("Software/availableDate");
198 return;
191 } 199 }
192 } 200 }
193 201
194 void MainWindow::handleNewList(const QString& fileName, const QDateTime& modDate) { 202 void MainWindow::handleNewList(const QString& fileName, const QDateTime& modDate) {
195 mSettings.setValue("List/available", fileName); 203 mSettings.setValue("List/available", fileName);

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