comparison ui/mainwindow.cpp @ 1241:4692f8860a24

Merged.
author Emanuel Schuetze <emanuel@intevation.de>
date Wed, 24 Sep 2014 17:50:23 +0200
parents 33a17569812a
children 8748223990eb
comparison
equal deleted inserted replaced
1240:17aa7cf0bedd 1241:4692f8860a24
31 #include <QToolButton> 31 #include <QToolButton>
32 #include <QStandardPaths> 32 #include <QStandardPaths>
33 #include <QDesktopServices> 33 #include <QDesktopServices>
34 34
35 #include "certificatelist.h" 35 #include "certificatelist.h"
36 #include "certificateitemwidget.h"
36 #include "downloader.h" 37 #include "downloader.h"
37 #include "helpdialog.h" 38 #include "helpdialog.h"
38 #include "aboutdialog.h" 39 #include "aboutdialog.h"
39 #include "separatoritemdelegate.h" 40 #include "separatoritemdelegate.h"
40 #include "installwrapper.h" 41 #include "installwrapper.h"
264 handleLTE(lteInvalidSoftware, true); /* Reset error state */ 265 handleLTE(lteInvalidSoftware, true); /* Reset error state */
265 fclose(verifyResult.fptr); 266 fclose(verifyResult.fptr);
266 } 267 }
267 268
268 void MainWindow::handleNewList(const QString& fileName, const QDateTime& modDate) { 269 void MainWindow::handleNewList(const QString& fileName, const QDateTime& modDate) {
269 qDebug() << "new list available"; 270
271 if (mSettings.value("List/available").toString() == fileName &&
272 getState() == NewListAvailable) {
273 qDebug() << "List already handled";
274 return;
275 } else {
276 qDebug() << "Handling list";
277 }
270 mSettings.setValue("List/available", fileName); 278 mSettings.setValue("List/available", fileName);
271 mSettings.setValue("List/availableDate", modDate); 279 mSettings.setValue("List/availableDate", modDate);
272 280
273 verifyListData(); 281 verifyListData();
274 if (!mListToInstall.isValid()) { 282 if (!mListToInstall.isValid()) {
510 downloadSW); 518 downloadSW);
511 519
512 connect(downloader, SIGNAL(newListAvailable(const QString&, const QDateTime&)), 520 connect(downloader, SIGNAL(newListAvailable(const QString&, const QDateTime&)),
513 this, SLOT(handleNewList(const QString&, const QDateTime&))); 521 this, SLOT(handleNewList(const QString&, const QDateTime&)));
514 if (!downloadSW) { 522 if (!downloadSW) {
515 setState(BeforeDownload);
516 connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)), 523 connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)),
517 this, SLOT(handleNewSW(const QString&, const QDateTime&))); 524 this, SLOT(handleNewSW(const QString&, const QDateTime&)));
518 } else { 525 } else {
519 setState(DownloadingSW); 526 setState(DownloadingSW);
520 connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)), 527 connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)),
579 } 586 }
580 587
581 void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error) 588 void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error)
582 { 589 {
583 syslog_error_printf ("Failed to check for updates: %s", message.toUtf8().constData()); 590 syslog_error_printf ("Failed to check for updates: %s", message.toUtf8().constData());
591 qDebug() << "Downloader error: " << error;
584 if (error == SSLConnection::InvalidCertificate) { 592 if (error == SSLConnection::InvalidCertificate) {
585 handleLTE(lteInvalidCertificate); 593 handleLTE(lteInvalidCertificate);
586 } else { 594 } else {
587 handleLTE(lteNoConnection); 595 handleLTE(lteNoConnection);
588 } 596 }
1126 /* Show a different tip in case of manual changes, updates aviailable, updates and manual 1134 /* Show a different tip in case of manual changes, updates aviailable, updates and manual
1127 * changes available */ 1135 * changes available */
1128 if (changeCount() && !mUpdatesManual->certificates().size()) { 1136 if (changeCount() && !mUpdatesManual->certificates().size()) {
1129 mUpdatesTip->setText( 1137 mUpdatesTip->setText(
1130 tr("You should apply the following, recommended changes to your certificate stores:")); 1138 tr("You should apply the following, recommended changes to your certificate stores:"));
1131 } else if (changeCount()) {
1132 mUpdatesTip->setText(
1133 tr("You can apply the following, changes to your certificate stores:"));
1134 } else { 1139 } else {
1135 mUpdatesTip->setText( 1140 mUpdatesTip->setText("");
1136 tr("There are currently no changes for your certificate stores."));
1137 } 1141 }
1138 1142
1139 if (!changeCount()) { 1143 if (!changeCount()) {
1140 /* No changes */ 1144 /* No changes */
1141 mQuitButton->setText(" " + tr("Quit")); 1145 mQuitButton->setText(" " + tr("Quit"));
1231 1235
1232 void MainWindow::loadCertificateList() 1236 void MainWindow::loadCertificateList()
1233 { 1237 {
1234 /* TODO (issue134): if nothing is available (neither old nor new) add some progress 1238 /* TODO (issue134): if nothing is available (neither old nor new) add some progress
1235 * indication */ 1239 * indication */
1240 setUpdatesEnabled(false);
1236 mInstallList->clear(); 1241 mInstallList->clear();
1237 mRemoveList->clear(); 1242 mRemoveList->clear();
1238 mUpdatesNew->clear(); 1243 mUpdatesNew->clear();
1239 mUpdatesRemove->clear(); 1244 mUpdatesRemove->clear();
1240 QList<Certificate> newInstallCerts; 1245 QList<Certificate> newInstallCerts;
1246 // No new list available, add old certificates. 1251 // No new list available, add old certificates.
1247 foreach (const Certificate &cert, mInstalledList.getCertificates()) { 1252 foreach (const Certificate &cert, mInstalledList.getCertificates()) {
1248 bool state = !mPreviouslyUnselected.contains(cert.base64Line()); 1253 bool state = !mPreviouslyUnselected.contains(cert.base64Line());
1249 if (cert.isInstallCert()) { 1254 if (cert.isInstallCert()) {
1250 oldInstallCerts.append(cert); 1255 oldInstallCerts.append(cert);
1251 QToolButton* actionBtn = new QToolButton(); 1256 CheckLessToolBtn* actionBtn = new CheckLessToolBtn();
1252 QIcon btnIcon; 1257 QIcon btnIcon;
1253 if (!state) { 1258 if (!state) {
1254 btnIcon.addFile(":/img/cert-to-be-installed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1259 btnIcon.addFile(":/img/cert-to-be-installed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1255 btnIcon.addFile(":/img/cert-not-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1260 btnIcon.addFile(":/img/cert-not-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1256 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be installed.")); 1261 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be installed."));
1264 actionBtn->setIcon(btnIcon); 1269 actionBtn->setIcon(btnIcon);
1265 mInstallList->addCertificate(cert, state, actionBtn); 1270 mInstallList->addCertificate(cert, state, actionBtn);
1266 } 1271 }
1267 else { 1272 else {
1268 oldRemoveCerts.append(cert); 1273 oldRemoveCerts.append(cert);
1269 QToolButton* actionBtn = new QToolButton(); 1274 CheckLessToolBtn* actionBtn = new CheckLessToolBtn();
1270 QIcon btnIcon; 1275 QIcon btnIcon;
1271 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed.")); 1276 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed."));
1272 actionBtn->setProperty("ToolTip_On", tr("Certificate has not been removed.")); 1277 actionBtn->setProperty("ToolTip_On", tr("Certificate has not been removed."));
1273 btnIcon.addFile(":/img/cert-to-be-removed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1278 btnIcon.addFile(":/img/cert-to-be-removed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1274 btnIcon.addFile(":/img/cert-is-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1279 btnIcon.addFile(":/img/cert-is-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1289 if (cert.isInstallCert()) { 1294 if (cert.isInstallCert()) {
1290 // Certificate with status "install". 1295 // Certificate with status "install".
1291 if (mInstalledList.getCertificates().contains(cert)) { 1296 if (mInstalledList.getCertificates().contains(cert)) {
1292 // Was in the old list. 1297 // Was in the old list.
1293 oldInstallCerts.append(cert); 1298 oldInstallCerts.append(cert);
1294 QToolButton* actionBtn = new QToolButton(); 1299 CheckLessToolBtn* actionBtn = new CheckLessToolBtn();
1295 QIcon btnIcon; 1300 QIcon btnIcon;
1296 actionBtn->setProperty("ToolTip_Off", tr("Certificate is installed.")); 1301 actionBtn->setProperty("ToolTip_Off", tr("Certificate is installed."));
1297 actionBtn->setProperty("ToolTip_On", tr("Certifcate is not installed.")); 1302 actionBtn->setProperty("ToolTip_On", tr("Certifcate is not installed."));
1298 btnIcon.addFile(":/img/cert-is-installed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1303 btnIcon.addFile(":/img/cert-is-installed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1299 btnIcon.addFile(":/img/cert-not-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1304 btnIcon.addFile(":/img/cert-not-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1301 mInstallList->addCertificate(cert, state, actionBtn); 1306 mInstallList->addCertificate(cert, state, actionBtn);
1302 } 1307 }
1303 else { 1308 else {
1304 // Is a brand new certificate 1309 // Is a brand new certificate
1305 newInstallCerts.append(cert); 1310 newInstallCerts.append(cert);
1306 QToolButton* actionBtn = new QToolButton(); 1311 CheckLessToolBtn* actionBtn = new CheckLessToolBtn();
1307 QIcon btnIcon; 1312 QIcon btnIcon;
1308 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be installed.")); 1313 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be installed."));
1309 actionBtn->setProperty("ToolTip_On", tr("Certificate will not be installed.")); 1314 actionBtn->setProperty("ToolTip_On", tr("Certificate will not be installed."));
1310 btnIcon.addFile(":/img/cert-to-be-installed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1315 btnIcon.addFile(":/img/cert-to-be-installed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1311 btnIcon.addFile(":/img/cert-not-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1316 btnIcon.addFile(":/img/cert-not-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1317 // Certificate with status "remove". 1322 // Certificate with status "remove".
1318 if (mInstalledList.getCertificates().contains(cert)) { 1323 if (mInstalledList.getCertificates().contains(cert)) {
1319 // Was in the old list. 1324 // Was in the old list.
1320 oldRemoveCerts.append(cert); 1325 oldRemoveCerts.append(cert);
1321 // Is removed, so set editable to false. 1326 // Is removed, so set editable to false.
1322 QToolButton* actionBtn = new QToolButton(); 1327 CheckLessToolBtn* actionBtn = new CheckLessToolBtn();
1323 QIcon btnIcon; 1328 QIcon btnIcon;
1324 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed.")); 1329 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed."));
1325 actionBtn->setProperty("ToolTip_On", tr("Certificate has not been removed.")); 1330 actionBtn->setProperty("ToolTip_On", tr("Certificate has not been removed."));
1326 btnIcon.addFile(":/img/cert-to-be-removed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1331 btnIcon.addFile(":/img/cert-to-be-removed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1327 btnIcon.addFile(":/img/cert-is-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1332 btnIcon.addFile(":/img/cert-is-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1335 } 1340 }
1336 else { 1341 else {
1337 // Was in the old list with status "install" and now has the 1342 // Was in the old list with status "install" and now has the
1338 // status "remove". 1343 // status "remove".
1339 newRemoveCerts.append(cert); 1344 newRemoveCerts.append(cert);
1340 QToolButton* actionBtn = new QToolButton(); 1345 CheckLessToolBtn* actionBtn = new CheckLessToolBtn();
1341 QIcon btnIcon; 1346 QIcon btnIcon;
1342 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed.")); 1347 actionBtn->setProperty("ToolTip_Off", tr("Certificate will be removed."));
1343 actionBtn->setProperty("ToolTip_On", tr("Certificate will not be removed.")); 1348 actionBtn->setProperty("ToolTip_On", tr("Certificate will not be removed."));
1344 btnIcon.addFile(":/img/cert-to-be-removed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off); 1349 btnIcon.addFile(":/img/cert-to-be-removed-good-48.png", QSize(48, 48), QIcon::Normal, QIcon::Off);
1345 btnIcon.addFile(":/img/cert-is-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On); 1350 btnIcon.addFile(":/img/cert-is-installed-bad-48.png", QSize(48, 48), QIcon::Normal, QIcon::On);
1349 } 1354 }
1350 } 1355 }
1351 } 1356 }
1352 1357
1353 listChanged(0); 1358 listChanged(0);
1359 setUpdatesEnabled(true);
1354 } 1360 }
1355 1361
1356 void MainWindow::installerError(const QString& errMsg) { 1362 void MainWindow::installerError(const QString& errMsg) {
1357 QMessageBox::warning(this, tr("Error executing update"), errMsg); 1363 QMessageBox::warning(this, tr("Error executing update"), errMsg);
1358 } 1364 }
1721 } 1727 }
1722 1728
1723 void MainWindow::handleLTE(LongTimeErrors lte, bool reset) 1729 void MainWindow::handleLTE(LongTimeErrors lte, bool reset)
1724 { 1730 {
1725 QString settingPrefix; 1731 QString settingPrefix;
1732 // qDebug() << "Handle LTE for " << lte << " Reset? : " << reset;
1726 switch (lte) { 1733 switch (lte) {
1727 case lteInvalidSoftware: 1734 case lteInvalidSoftware:
1728 settingPrefix = "LTE/invalidSW"; 1735 settingPrefix = "LTE/invalidSW";
1729 break; 1736 break;
1730 case lteInvalidList: 1737 case lteInvalidList:
1742 1749
1743 if (reset) { 1750 if (reset) {
1744 /* delete all values and be done */ 1751 /* delete all values and be done */
1745 mSettings.remove(settingPrefix + "_lastSaved"); 1752 mSettings.remove(settingPrefix + "_lastSaved");
1746 mSettings.remove(settingPrefix + "_count"); 1753 mSettings.remove(settingPrefix + "_count");
1747 mSettings.remove(settingPrefix + "_lastMsgShown"); 1754 mSettings.remove(settingPrefix + "_lastShown");
1748 return; 1755 return;
1749 } 1756 }
1750 1757
1751 QDateTime lastSaved = mSettings.value(settingPrefix + "_lastSaved").toDateTime(); 1758 QDateTime lastSaved = mSettings.value(settingPrefix + "_lastSaved").toDateTime();
1752 bool cnt_valid; 1759 bool cnt_valid;

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