comparison ui/mainwindow.cpp @ 1134:f1384bf9d4a4

Mergerd
author Sascha Wilde <wilde@intevation.de>
date Wed, 17 Sep 2014 15:01:19 +0200
parents 1a5f9e260099
children a4282bc67a8b
comparison
equal deleted inserted replaced
1133:54a6fa9e44cf 1134:f1384bf9d4a4
64 #define TB_ARCH_STRING "-i386" 64 #define TB_ARCH_STRING "-i386"
65 #else 65 #else
66 #define TB_ARCH_STRING "-amd64" 66 #define TB_ARCH_STRING "-amd64"
67 #endif 67 #endif
68 68
69 #ifdef USE_REAL_RESOURCES 69 #ifdef IS_TAG_BUILD
70 # define LIST_RESOURCE "/zertifikatsliste.txt" 70 # define LIST_RESOURCE "/zertifikatsliste.txt"
71 # ifdef Q_OS_WIN 71 # ifdef Q_OS_WIN
72 # define SW_RESOURCE_VERSION "/TrustBridge-%1.exe" 72 # define SW_RESOURCE_VERSION "/TrustBridge-%1.exe"
73 # define SW_RESOURCE "/TrustBridge.exe" 73 # define SW_RESOURCE "/TrustBridge.exe"
74 # else 74 # else
75 # define SW_RESOURCE_VERSION "/TrustBridge-%1" TB_ARCH_STRING ".sh" 75 # define SW_RESOURCE_VERSION "/TrustBridge-%1" TB_ARCH_STRING ".sh"
76 # define SW_RESOURCE "/TrustBridge" TB_ARCH_STRING ".sh" 76 # define SW_RESOURCE "/TrustBridge" TB_ARCH_STRING ".sh"
77 # endif 77 # endif
78 #else // RELEASE_BUILD 78 #else // Not tag build means develpment build
79 # define LIST_RESOURCE "/zertifikatsliste.txt" 79 # define LIST_RESOURCE "/zertifikatsliste.txt"
80 # ifdef Q_OS_WIN 80 # ifdef Q_OS_WIN
81 # define SW_RESOURCE_VERSION "/development/TrustBridge-development.exe" 81 # define SW_RESOURCE_VERSION "/development/TrustBridge-%1.exe"
82 # define SW_RESOURCE "/development/TrustBridge.exe" 82 # define SW_RESOURCE "/development/TrustBridge.exe"
83 # else 83 # else
84 # define SW_RESOURCE_VERSION "/development/TrustBridge-development" TB_ARCH_STRING ".sh" 84 # define SW_RESOURCE_VERSION "/development/TrustBridge-%1" TB_ARCH_STRING ".sh"
85 # define SW_RESOURCE "/development/TrustBridge" TB_ARCH_STRING ".sh" 85 # define SW_RESOURCE "/development/TrustBridge" TB_ARCH_STRING ".sh"
86 # endif 86 # endif
87 #endif 87 #endif
88 88
89 /* Help installation path the path relative to the installation directory where 89 /* Help installation path the path relative to the installation directory where
117 mMessageTimer->setInterval(NAG_INTERVAL_MINUTES * 60 * 1000); 117 mMessageTimer->setInterval(NAG_INTERVAL_MINUTES * 60 * 1000);
118 mMessageTimer->start(); 118 mMessageTimer->start();
119 checkUpdates(); 119 checkUpdates();
120 loadUnselectedCertificates(); 120 loadUnselectedCertificates();
121 loadCertificateList(); 121 loadCertificateList();
122 if (!trayMode) { 122
123 if (mSettings.value("ShowOnNextStart").toBool()) {
124 mSettings.remove("ShowOnNextStart");
125 show();
126 } else if (!trayMode) {
123 show(); 127 show();
124 } 128 }
125 } 129 }
126 130
127 void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason) 131 void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
140 } 144 }
141 145
142 void MainWindow::messageClicked() 146 void MainWindow::messageClicked()
143 { 147 {
144 if (mCurState == NewSoftwareAvailable) { 148 if (mCurState == NewSoftwareAvailable) {
145 hide();
146 verifySWData(); 149 verifySWData();
147 QString swFileName = mSettings.value("Software/available").toString(); 150 QString swFileName = mSettings.value("Software/available").toString();
148 if (swFileName.isEmpty()) { 151 if (swFileName.isEmpty()) {
149 checkUpdates(true); 152 checkUpdates(true);
150 mCurState = DownloadingSW; 153 mCurState = DownloadingSW;
217 void MainWindow::verifySWData() 220 void MainWindow::verifySWData()
218 { 221 {
219 QString swFileName = mSettings.value("Software/available").toString(); 222 QString swFileName = mSettings.value("Software/available").toString();
220 223
221 if (swFileName.isEmpty()) { 224 if (swFileName.isEmpty()) {
225 qDebug() << "Date set but no fileName";
222 mSettings.remove("Software/availableDate"); 226 mSettings.remove("Software/availableDate");
223 return; 227 return;
224 } 228 }
225 229
226 QFileInfo fi(swFileName); 230 QFileInfo fi(swFileName);
296 QTemporaryDir tDir; 300 QTemporaryDir tDir;
297 if (!tDir.isValid()) { 301 if (!tDir.isValid()) {
298 qDebug () << "Failed to create temporary directory."; 302 qDebug () << "Failed to create temporary directory.";
299 return QString(); 303 return QString();
300 } 304 }
301 QString targetPath = tDir.path() + QObject::tr("TrustBridge-Updater", 305 QString targetPath = tDir.path() + "/" + QObject::tr("TrustBridge-Updater",
302 "Used as filename for the updater. Only use ASCII please."); 306 "Used as filename for the updater. Only use ASCII please.");
303 307
304 tDir.setAutoRemove(false); 308 tDir.setAutoRemove(false);
305 #ifdef WIN32 309 #ifdef WIN32
306 targetPath += ".exe"; 310 targetPath += ".exe";
375 /* On linux installDir is <prefix>/bin */ 379 /* On linux installDir is <prefix>/bin */
376 QStringList parameters; 380 QStringList parameters;
377 installDir.cdUp(); 381 installDir.cdUp();
378 parameters << "--prefix" << installDir.path(); 382 parameters << "--prefix" << installDir.path();
379 parameters << "--update"; 383 parameters << "--update";
380 if (isVisible()) {
381 parameters << "--show-after-update";
382 }
383 bool sudo_started = false; 384 bool sudo_started = false;
384 bool use_sudo = is_admin() && is_system_install(); 385 bool use_sudo = is_admin() && is_system_install();
385 if (use_sudo) { 386 if (use_sudo) {
386 QStringList sudoPrograms; 387 QStringList sudoPrograms;
387 sudoPrograms << "pkexec" << "kdesudo" << "sudo"; 388 sudoPrograms << "pkexec" << "kdesudo" << "sudo";
404 fclose(vres.fptr); 405 fclose(vres.fptr);
405 return; 406 return;
406 } 407 }
407 408
408 #endif 409 #endif
410 if (isVisible()) {
411 mSettings.setValue("ShowOnNextStart", true);
412 mSettings.sync();
413 }
409 414
410 syslog_info_printf ("Installing update: %s\n", fileName.toUtf8().constData()); 415 syslog_info_printf ("Installing update: %s\n", fileName.toUtf8().constData());
411 /* Installer process should now be running. We exit */ 416 /* Installer process should now be running. We exit */
412 fclose(vres.fptr); 417 fclose(vres.fptr);
413 closeApp(); 418 closeApp();
500 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater())); 505 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater()));
501 connect(downloader, SIGNAL(finished()), this, SLOT(updateCheckSuccess())); 506 connect(downloader, SIGNAL(finished()), this, SLOT(updateCheckSuccess()));
502 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)), 507 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)),
503 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode))); 508 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode)));
504 downloader->start(); 509 downloader->start();
510
511 if (downloadSW && getState() == DownloadingSW && isVisible()) {
512 QProgressDialog *progDlg = new QProgressDialog(this);
513 progDlg->setCancelButton(0);
514 progDlg->setRange(0,0);
515 progDlg->setMinimumDuration(0);
516 progDlg->setLabelText(tr("Downloading update..."));
517 progDlg->show();
518 connect(downloader, SIGNAL(finished()), progDlg, SLOT(deleteLater()));
519 connect(downloader, SIGNAL(finished()), progDlg, SLOT(cancel()));
520 }
505 } 521 }
506 522
507 void MainWindow::getLastModForCurrentVersion() 523 void MainWindow::getLastModForCurrentVersion()
508 { 524 {
509 QString softwareVersion = QString::fromLatin1(SW_RESOURCE_VERSION).arg( 525 QString softwareVersion = QString::fromLatin1(SW_RESOURCE_VERSION).arg(
521 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater())); 537 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater()));
522 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)), 538 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)),
523 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode))); 539 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode)));
524 connect(downloader, SIGNAL(lastModifiedDate(const QDateTime&)), 540 connect(downloader, SIGNAL(lastModifiedDate(const QDateTime&)),
525 this, SLOT(setLastModifiedSWDate(const QDateTime&))); 541 this, SLOT(setLastModifiedSWDate(const QDateTime&)));
526
527 downloader->start(); 542 downloader->start();
528 } 543 }
529 544
530 void MainWindow::setLastModifiedSWDate(const QDateTime &date) 545 void MainWindow::setLastModifiedSWDate(const QDateTime &date)
531 { 546 {
546 showMessage(); 561 showMessage();
547 } else { 562 } else {
548 showErrorMessage(tr("Failed to check for updates:") + "\n" + message); 563 showErrorMessage(tr("Failed to check for updates:") + "\n" + message);
549 } 564 }
550 setState(TransferError); 565 setState(TransferError);
566
567 #ifndef IS_TAG_BUILD
568 /* For development versions we default to datetime::now if
569 * we can not find our version. */
570 if (!mSettings.contains("Software/installedDate") ||
571 mSettings.value("Software/installedVersion").toString() != QApplication::applicationVersion()) {
572 setLastModifiedSWDate(QDateTime::currentDateTime());
573 }
574 #endif
551 } 575 }
552 576
553 void MainWindow::createActions() 577 void MainWindow::createActions()
554 { 578 {
555 mCheckUpdates = new QAction(tr("Check for Updates"), this); 579 mCheckUpdates = new QAction(tr("Check for Updates"), this);

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