comparison ui/mainwindow.cpp @ 1371:23df332b2a4c

(issue179) Read install signature timestamp from config This also changes the way the sigDt is propgated to the MainWindow. It no longer uses the settings but hands it over as a parameter directly.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 24 Nov 2014 15:48:49 +0100
parents 3d7ddf698480
children 00fcb9c4d16b
comparison
equal deleted inserted replaced
1370:289cb3554c55 1371:23df332b2a4c
122 return 60; 122 return 60;
123 } 123 }
124 return -1; 124 return -1;
125 } 125 }
126 126
127 MainWindow::MainWindow(bool trayMode): 127 MainWindow::MainWindow(bool trayMode, const QDateTime& sigDt):
128 mTrayMode(trayMode), 128 mTrayMode(trayMode),
129 mManualDetailsShown(false), 129 mManualDetailsShown(false),
130 mFailedConnections(0) 130 mFailedConnections(0),
131 mSigDt(sigDt)
131 { 132 {
132 createActions(); 133 createActions();
133 createTrayIcon(); 134 createTrayIcon();
134 setupGUI(); 135 setupGUI();
135 resize(900, 600); 136 resize(900, 600);
279 return; 280 return;
280 } 281 }
281 bin_verify_result verifyResult = verify_binary(swFileName.toUtf8().constData(), 282 bin_verify_result verifyResult = verify_binary(swFileName.toUtf8().constData(),
282 swFileName.toUtf8().size()); 283 swFileName.toUtf8().size());
283 QDateTime sigDt = QDateTime::fromTime_t (verifyResult.sig_time); 284 QDateTime sigDt = QDateTime::fromTime_t (verifyResult.sig_time);
284 QDateTime currentSigDt = mSettings.value("Software/currentSigDt").toDateTime(); 285
285 286 if (verifyResult.result != VerifyValid || (mSigDt.isValid() && sigDt <= mSigDt)) {
286 if (verifyResult.result != VerifyValid || (currentSigDt.isValid() && sigDt <= currentSigDt)) {
287 handleLTE(lteInvalidSoftware); 287 handleLTE(lteInvalidSoftware);
288 if (verifyResult.result != VerifyValid) { 288 if (verifyResult.result != VerifyValid) {
289 qDebug() << "Failed to verify downloaded data."; 289 qDebug() << "Failed to verify downloaded data.";
290 } else { 290 } else {
291 qDebug() << "Software update was signed at: " << sigDt; 291 qDebug() << "Software update was signed at: " << sigDt;
292 qDebug() << "But the installed software was signed on: " << currentSigDt; 292 qDebug() << "But the installed software was signed on: " << mSigDt;
293 if (verifyResult.fptr) { 293 if (verifyResult.fptr) {
294 fclose(verifyResult.fptr); 294 fclose(verifyResult.fptr);
295 } 295 }
296 } 296 }
297 QFile::remove(swFileName); 297 QFile::remove(swFileName);
423 423
424 bin_verify_result vres = verify_binary(filePath.toUtf8().constData(), 424 bin_verify_result vres = verify_binary(filePath.toUtf8().constData(),
425 filePath.toUtf8().size()); 425 filePath.toUtf8().size());
426 426
427 QDateTime sigDt = QDateTime::fromTime_t (vres.sig_time); 427 QDateTime sigDt = QDateTime::fromTime_t (vres.sig_time);
428 QDateTime currentSigDt = mSettings.value("Software/currentSigDt").toDateTime(); 428
429 429 if (vres.result != VerifyValid || (mSigDt.isValid() && sigDt <= mSigDt)) {
430 if (vres.result != VerifyValid || (currentSigDt.isValid() && sigDt <= currentSigDt)) {
431 handleLTE(lteInvalidSoftware); 430 handleLTE(lteInvalidSoftware);
432 if (vres.result != VerifyValid) { 431 if (vres.result != VerifyValid) {
433 qDebug() << "Failed to verify installer."; 432 qDebug() << "Failed to verify installer.";
434 } else { 433 } else {
435 qDebug() << "Software update was signed at: " << sigDt; 434 qDebug() << "Software update was signed at: " << sigDt;
436 qDebug() << "But the installed software was signed on: " << currentSigDt; 435 qDebug() << "But the installed software was signed on: " << mSigDt;
437 if (vres.fptr) { 436 if (vres.fptr) {
438 fclose(vres.fptr); 437 fclose(vres.fptr);
439 } 438 }
440 } 439 }
441 QFile::remove(filePath); 440 QFile::remove(filePath);

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