summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2020-04-09 13:15:52 +0300
committerKatja Marttila <katja.marttila@qt.io>2020-04-15 15:18:51 +0300
commit6a93f37440a3dcc72bb5e496dac90a8f95d63eab (patch)
tree0cd5cf11721f9162bafdee036428d4a8c6455aab /src
parent9d255d235aafe5ba017eeaf09eec7d6dd2a54730 (diff)
Add possibility to auto accept or reject IFW queries from CLI
Added new command line switches accept-messages and reject-messages to automatically accept or reject installer message queries. Also removed Retry option in CLI when archive or hash download failed. With GUI it is possible to try Retry in case either is missing but without GUI Retry will cause infinite loop. Added unit tests for accept-messages and reject-messages using CLI. Task-number: QTIFW-1736 Change-Id: Ie87d2d8157be772b790415c96e5b94fc882d4be7 Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/commandlineparser.cpp6
-rw-r--r--src/libs/installer/constants.h4
-rw-r--r--src/libs/installer/downloadarchivesjob.cpp9
-rw-r--r--src/libs/installer/messageboxhandler.cpp8
-rw-r--r--src/libs/kdtools/filedownloader.cpp2
-rw-r--r--src/sdk/sdkapp.h5
6 files changed, 29 insertions, 5 deletions
diff --git a/src/libs/installer/commandlineparser.cpp b/src/libs/installer/commandlineparser.cpp
index 8c0fb1ee7..dc4569fbd 100644
--- a/src/libs/installer/commandlineparser.cpp
+++ b/src/libs/installer/commandlineparser.cpp
@@ -146,6 +146,12 @@ CommandLineParser::CommandLineParser()
QLatin1String("Create a local repository inside the installation directory. This option "
"has no effect on online installers.")));
+ // Message query options
+ m_parser.addOption(QCommandLineOption(QStringList() << CommandLineOptions::scAcceptMessageQuery,
+ QLatin1String("Accepts all message queries without user input.")));
+ m_parser.addOption(QCommandLineOption(QStringList() << CommandLineOptions::scRejectMessageQuery,
+ QLatin1String("Rejects all message queries without user input.")));
+
// Developer options
m_parser.addOption(QCommandLineOption(QStringList()
<< CommandLineOptions::scScriptShort << CommandLineOptions::scScriptLong,
diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h
index 3759e6157..1d9be8525 100644
--- a/src/libs/installer/constants.h
+++ b/src/libs/installer/constants.h
@@ -151,6 +151,10 @@ static const QLatin1String scStartPackageManagerLong("start-package-manager");
static const QLatin1String scStartUninstallerShort("sr");
static const QLatin1String scStartUninstallerLong("start-uninstaller");
+// Message acceptance options
+static const QLatin1String scAcceptMessageQuery("accept-messages");
+static const QLatin1String scRejectMessageQuery("reject-messages");
+
// Misc installation options
static const QLatin1String scRootShort("t");
static const QLatin1String scRootLong("root");
diff --git a/src/libs/installer/downloadarchivesjob.cpp b/src/libs/installer/downloadarchivesjob.cpp
index 102783133..4d9d6b325 100644
--- a/src/libs/installer/downloadarchivesjob.cpp
+++ b/src/libs/installer/downloadarchivesjob.cpp
@@ -215,7 +215,10 @@ void DownloadArchivesJob::registerFile()
"downloading failed. This is a temporary error, please retry."),
QMessageBox::Retry | QMessageBox::Cancel, QMessageBox::Cancel);
- if (res == QMessageBox::Cancel) {
+ // If run from command line instance, do not continue if hash verification failed.
+ // Same download is tried again and again causing infinite loop if hash not
+ // fixed to repositories.
+ if (res == QMessageBox::Cancel || m_core->isCommandLineInstance()) {
finishWithError(tr("Cannot verify Hash"));
return;
}
@@ -249,7 +252,9 @@ void DownloadArchivesJob::downloadFailed(const QString &error)
QLatin1String("archiveDownloadError"), tr("Download Error"), tr("Cannot download archive %1: %2")
.arg(m_archivesToDownload.first().second, error), QMessageBox::Retry | QMessageBox::Cancel);
- if (b == QMessageBox::Retry)
+ // Do not call fetchNextArchiveHash when using command line instance,
+ // installer tries to download the same archive causing infinite loop
+ if (b == QMessageBox::Retry && !m_core->isCommandLineInstance())
QMetaObject::invokeMethod(this, "fetchNextArchiveHash", Qt::QueuedConnection);
else
downloadCanceled();
diff --git a/src/libs/installer/messageboxhandler.cpp b/src/libs/installer/messageboxhandler.cpp
index cb37254eb..4562f0f3c 100644
--- a/src/libs/installer/messageboxhandler.cpp
+++ b/src/libs/installer/messageboxhandler.cpp
@@ -406,8 +406,12 @@ QMessageBox::StandardButton MessageBoxHandler::showMessageBox(MessageType messag
qCDebug(QInstaller::lcInstallerInstallLog).nospace() << "Created " << messageTypeHash.value(messageType).toUtf8().constData()
<< " message box " << identifier << ": " << title << ", " << text;
- if (qobject_cast<QApplication*> (qApp) == nullptr)
- return defaultButton;
+ if (qobject_cast<QApplication*> (qApp) == nullptr) {
+ if (m_defaultAction != AskUser)
+ return autoReply(buttons);
+ else
+ return defaultButton;
+ }
if (m_automaticAnswers.contains(identifier))
return m_automaticAnswers.value(identifier);
diff --git a/src/libs/kdtools/filedownloader.cpp b/src/libs/kdtools/filedownloader.cpp
index b816b5fd5..276d5bbef 100644
--- a/src/libs/kdtools/filedownloader.cpp
+++ b/src/libs/kdtools/filedownloader.cpp
@@ -814,7 +814,7 @@ void KDUpdater::LocalFileDownloader::doDownload()
if (!d->source->open(QFile::ReadOnly)) {
onError();
setDownloadAborted(tr("Cannot open file \"%1\" for reading: %2").arg(QFileInfo(localFile)
- .fileName(), d->source->errorString()));
+ .fileName(), d->source ? d->source->errorString() : tr("File not found")));
return;
}
diff --git a/src/sdk/sdkapp.h b/src/sdk/sdkapp.h
index ab0b9eb2f..3c0dd0da8 100644
--- a/src/sdk/sdkapp.h
+++ b/src/sdk/sdkapp.h
@@ -274,6 +274,11 @@ public:
.isSet(CommandLineOptions::scCreateLocalRepositoryLong)
|| m_core->settings().createLocalRepository());
+ if (m_parser.isSet(CommandLineOptions::scAcceptMessageQuery))
+ m_core->autoAcceptMessageBoxes();
+ if (m_parser.isSet(CommandLineOptions::scRejectMessageQuery))
+ m_core->autoRejectMessageBoxes();
+
return true;
}