Mercurial > trustbridge
comparison ui/mainwindow.cpp @ 1259:f1e461340ede
(issue44) Move check if the SW was updated into setLastModifiedSWDate
setLastModifiedSWDate is ideally only called once to register
a new version so this is the best place to note if an update
has been installed.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 26 Sep 2014 13:18:46 +0200 |
parents | 9a482182f80f |
children | 82792b3a16bd |
comparison
equal
deleted
inserted
replaced
1258:469c1a04b678 | 1259:f1e461340ede |
---|---|
509 getLastModForCurrentVersion(); | 509 getLastModForCurrentVersion(); |
510 return; | 510 return; |
511 } | 511 } |
512 QDateTime listInstalledLastMod = mSettings.value("List/installedDate").toDateTime(); | 512 QDateTime listInstalledLastMod = mSettings.value("List/installedDate").toDateTime(); |
513 QDateTime swInstalledLastMod = mSettings.value("Software/installedDate").toDateTime(); | 513 QDateTime swInstalledLastMod = mSettings.value("Software/installedDate").toDateTime(); |
514 | |
515 QDateTime swAvailableLastMod = mSettings.value("Software/availableDate").toDateTime(); | |
516 | |
517 if (swAvailableLastMod.isValid()) { | |
518 qDebug() << "Installed an update: " << swInstalledLastMod << | |
519 " available " << swAvailableLastMod; | |
520 syslog_info_printf ("Software has been updated to version: %s\n", | |
521 QApplication::applicationVersion().toUtf8().constData()); | |
522 if (swInstalledLastMod == swAvailableLastMod) { | |
523 QString fileName = mSettings.value("Software/available").toString(); | |
524 if (fileName.isEmpty()) { | |
525 qDebug() << "Software marked as available but no filename set."; | |
526 } else { | |
527 if (QFile::remove(fileName)) { | |
528 qDebug() << "Removed: " << fileName; | |
529 } else { | |
530 qDebug() << "Failed to remove: " << fileName; | |
531 } | |
532 } | |
533 /* Clear out available data. */ | |
534 mSettings.remove("Software/available"); | |
535 mSettings.remove("Software/availableDate"); | |
536 } | |
537 } | |
538 | |
539 QString listResource = QString::fromLatin1(LIST_RESOURCE); | 514 QString listResource = QString::fromLatin1(LIST_RESOURCE); |
540 QString swResource = QString::fromLatin1(SW_RESOURCE); | 515 QString swResource = QString::fromLatin1(SW_RESOURCE); |
541 | 516 |
542 #ifndef RELEASE_BUILD | 517 #ifndef RELEASE_BUILD |
543 /* Use this for testing to specify another file name for updates */ | 518 /* Use this for testing to specify another file name for updates */ |
606 downloader->start(); | 581 downloader->start(); |
607 } | 582 } |
608 | 583 |
609 void MainWindow::setLastModifiedSWDate(const QDateTime &date) | 584 void MainWindow::setLastModifiedSWDate(const QDateTime &date) |
610 { | 585 { |
586 QDateTime swAvailableLastMod = mSettings.value("Software/availableDate").toDateTime(); | |
587 | |
588 if (swAvailableLastMod.isValid() && date.isValid()) { | |
589 if (date >= swAvailableLastMod) { | |
590 qDebug() << "Installed an update: " << date << | |
591 " available was " << swAvailableLastMod; | |
592 syslog_info_printf ("Software has been updated to version: %s\n", | |
593 QApplication::applicationVersion().toUtf8().constData()); | |
594 QString fileName = mSettings.value("Software/available").toString(); | |
595 if (fileName.isEmpty()) { | |
596 qDebug() << "Software marked as available but no filename set."; | |
597 } else { | |
598 if (QFile::remove(fileName)) { | |
599 qDebug() << "Removed: " << fileName; | |
600 } else { | |
601 qDebug() << "Failed to remove: " << fileName; | |
602 } | |
603 } | |
604 /* Clear out available data. */ | |
605 mSettings.remove("Software/available"); | |
606 mSettings.remove("Software/availableDate"); | |
607 } | |
608 } | |
609 | |
611 mSettings.beginGroup("Software"); | 610 mSettings.beginGroup("Software"); |
612 #ifdef IS_TAG_BUILD | 611 #ifdef IS_TAG_BUILD |
613 /* We accept an invalid date to force installing any avialable update | 612 /* We accept an invalid date to force installing any avialable update |
614 * in release mode. Otherwise we default to current datetime when we | 613 * in release mode. Otherwise we default to current datetime when we |
615 * did not find out version.*/ | 614 * did not find out version.*/ |