diff options
author | Robert Griebl <robert.griebl@pelagicore.com> | 2018-03-06 13:20:57 +0100 |
---|---|---|
committer | Dominik Holland <dominik.holland@pelagicore.com> | 2018-03-06 12:46:43 +0000 |
commit | 997d8065f0e3453a4e3084f85f413651cfb01a0c (patch) | |
tree | f4e56ad1f71dfcb069c1be2c99693e38ac3de69b | |
parent | c13638ab065f860aad4ddceced9e8cecd75f6857 (diff) |
Make the acknowledge part of appman-controller's install-package optional
Acknowledging package installations by default could interfere with System-UI
logic, so we shouldn't do it by default. There is now a new switch
-a/--acknowledge however which will activate the old behavior and forces
installation even on minimal System-UIs that do not implement the package
acknowledge callback.
Change-Id: If7e4faa328a98a231eccf36515bc0e568004d41d
Task-number: QTAUTO-835
Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rw-r--r-- | doc/controller.qdoc | 7 | ||||
-rw-r--r-- | src/tools/controller/controller.cpp | 29 |
2 files changed, 22 insertions, 14 deletions
diff --git a/doc/controller.qdoc b/doc/controller.qdoc index c840b2cd..13c7733a 100644 --- a/doc/controller.qdoc +++ b/doc/controller.qdoc @@ -83,7 +83,12 @@ The following commands are available: \li \span {style="white-space: nowrap"} {\c install-package} \li \c{<package>} \li Installs the package given on the command-line. If the package file is specified as \c{-}, - the tool will try to read the package from \c stdin. + the tool will try to read the package from \c stdin. The following options are supported: + + \c{-l, --location}: Install to a specific installation location (see \c show-installation-location). + + \c{-a, --acknowledge}: Automatically acknowledge the installation, instead of relying on the System-UI's logic. + \row \li \span {style="white-space: nowrap"} {\c remove-package} \li \c{<application-id>} diff --git a/src/tools/controller/controller.cpp b/src/tools/controller/controller.cpp index 6a270acd..b7d3c9ab 100644 --- a/src/tools/controller/controller.cpp +++ b/src/tools/controller/controller.cpp @@ -183,7 +183,7 @@ static void stopApplication(const QString &appId) Q_DECL_NOEXCEPT_EXPR(false); static void stopAllApplications() Q_DECL_NOEXCEPT_EXPR(false); static void listApplications() Q_DECL_NOEXCEPT_EXPR(false); static void showApplication(const QString &appId, bool asJson = false) Q_DECL_NOEXCEPT_EXPR(false); -static void installPackage(const QString &package, const QString &location) Q_DECL_NOEXCEPT_EXPR(false); +static void installPackage(const QString &package, const QString &location, bool acknowledge) Q_DECL_NOEXCEPT_EXPR(false); static void removePackage(const QString &package, bool keepDocuments, bool force) Q_DECL_NOEXCEPT_EXPR(false); static void listInstallationLocations() Q_DECL_NOEXCEPT_EXPR(false); static void showInstallationLocation(const QString &location, bool asJson = false) Q_DECL_NOEXCEPT_EXPR(false); @@ -357,13 +357,14 @@ int main(int argc, char *argv[]) case InstallPackage: clp.addOption({ { qSL("l"), qSL("location") }, qSL("Set a custom installation location."), qSL("installation-location"), qSL("internal-0") }); + clp.addOption({ { qSL("a"), qSL("acknowledge") }, qSL("Automatically acknowledge the installation (unattended mode).") }); clp.addPositionalArgument(qSL("package"), qSL("The file name of the package; can be - for stdin.")); clp.process(a); if (clp.positionalArguments().size() != 2) clp.showHelp(1); - installPackage(clp.positionalArguments().at(1), clp.value(qSL("l"))); + installPackage(clp.positionalArguments().at(1), clp.value(qSL("l")), clp.isSet(qSL("a"))); break; case RemovePackage: @@ -570,7 +571,7 @@ void showApplication(const QString &appId, bool asJson) Q_DECL_NOEXCEPT_EXPR(fal }); } -void installPackage(const QString &package, const QString &location) Q_DECL_NOEXCEPT_EXPR(false) +void installPackage(const QString &package, const QString &location, bool acknowledge) Q_DECL_NOEXCEPT_EXPR(false) { QString packageFile = package; @@ -622,16 +623,18 @@ void installPackage(const QString &package, const QString &location) Q_DECL_NOEX // as soon as we have the manifest available: get the app id and acknowledge the installation - QObject::connect(dbus.installer(), &IoQtApplicationInstallerInterface::taskRequestingInstallationAcknowledge, - [](const QString &taskId, const QVariantMap &metadata) { - if (taskId != installationId) - return; - applicationId = metadata.value(qSL("id")).toString(); - if (applicationId.isEmpty()) - throw Exception(Error::IO, "could not find a valid application id in the package - got: %1").arg(applicationId); - fprintf(stdout, "Acknowledging package installation...\n"); - dbus.installer()->acknowledgePackageInstallation(taskId); - }); + if (acknowledge) { + QObject::connect(dbus.installer(), &IoQtApplicationInstallerInterface::taskRequestingInstallationAcknowledge, + [](const QString &taskId, const QVariantMap &metadata) { + if (taskId != installationId) + return; + applicationId = metadata.value(qSL("id")).toString(); + if (applicationId.isEmpty()) + throw Exception(Error::IO, "could not find a valid application id in the package - got: %1").arg(applicationId); + fprintf(stdout, "Acknowledging package installation...\n"); + dbus.installer()->acknowledgePackageInstallation(taskId); + }); + } // on failure: quit |