diff options
Diffstat (limited to 'src/libs/installer/consumeoutputoperation.cpp')
-rw-r--r-- | src/libs/installer/consumeoutputoperation.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/libs/installer/consumeoutputoperation.cpp b/src/libs/installer/consumeoutputoperation.cpp index 497af969a..d7aa6b49f 100644 --- a/src/libs/installer/consumeoutputoperation.cpp +++ b/src/libs/installer/consumeoutputoperation.cpp @@ -42,7 +42,8 @@ using namespace QInstaller; -ConsumeOutputOperation::ConsumeOutputOperation() +ConsumeOutputOperation::ConsumeOutputOperation(PackageManagerCore *core) + : UpdateOperation(core) { setName(QLatin1String("ConsumeOutput")); } @@ -58,15 +59,12 @@ bool ConsumeOutputOperation::performOperation() // 2. executable path // 3. argument for the executable // 4. more arguments possible ... - if (arguments().count() < 3) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.").arg(name()).arg( - arguments().count()).arg(tr("at least 2"), QLatin1String("(<to be saved installer key name>, " - "<executable>, [argument1], [argument2], ...)"))); + + if (!checkArgumentCount(2, INT_MAX, tr("<to be saved installer key name> " + "<executable> [argument1] [argument2] [...]"))) return false; - } - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); + PackageManagerCore *const core = packageManager(); if (!core) { setError(UserDefinedError); setErrorString(tr("Needed installer object in %1 operation is empty.").arg(name())); @@ -76,8 +74,8 @@ bool ConsumeOutputOperation::performOperation() const QString installerKeyName = arguments().at(0); if (installerKeyName.isEmpty()) { setError(UserDefinedError); - setErrorString(tr("Can not save the output of %1 to an empty installer key value.").arg( - arguments().at(1))); + setErrorString(tr("Cannot save the output of \"%1\" to an empty installer key value.").arg( + QDir::toNativeSeparators(arguments().at(1)))); return false; } @@ -90,7 +88,7 @@ bool ConsumeOutputOperation::performOperation() if (!executable.exists() || !executable.isExecutable()) { setError(UserDefinedError); - setErrorString(tr("File '%1' does not exist or is not an executable binary.").arg( + setErrorString(tr("File \"%1\" does not exist or is not an executable binary.").arg( QDir::toNativeSeparators(executable.absoluteFilePath()))); return false; } @@ -111,7 +109,7 @@ bool ConsumeOutputOperation::performOperation() << "standard output: " << process.readAllStandardOutput() << "error output: " << process.readAllStandardError(); setError(UserDefinedError); - setErrorString(tr("Running '%1' resulted in a crash.").arg( + setErrorString(tr("Running \"%1\" resulted in a crash.").arg( QDir::toNativeSeparators(executable.absoluteFilePath()))); return false; } @@ -129,8 +127,7 @@ bool ConsumeOutputOperation::performOperation() } if (executableOutput.isEmpty()) { - qWarning() << QString::fromLatin1("Cannot get any query output from executable: '%1'").arg( - executable.absoluteFilePath()); + qWarning() << "Cannot get any query output from executable" << executable.absoluteFilePath(); } core->setValue(installerKeyName, QString::fromLocal8Bit(executableOutput)); return true; @@ -145,9 +142,3 @@ bool ConsumeOutputOperation::testOperation() { return true; } - -Operation *ConsumeOutputOperation::clone() const -{ - return new ConsumeOutputOperation(); -} - |