summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Lenhardt <alexander.lenhardt@nokia.com>2012-01-06 17:17:58 +0100
committerAlexander Lenhardt <alexander.lenhardt@nokia.com>2012-01-10 13:21:29 +0100
commit29ce88adff148dbebb3452bc609f92dddfb40382 (patch)
tree2a8d51fec5c58f7af362d556bf860cf78c19ec77
parent389e748234c2ea5e1dca7b2fe9db7ed741eacbf3 (diff)
internal config controls whether the maintenance tool can be run standalone
Change-Id: Ia2d95f4f25195981676531e9837a55851360de68 Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
-rw-r--r--installerbuilder/installerbase/installerbase.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/installerbuilder/installerbase/installerbase.cpp b/installerbuilder/installerbase/installerbase.cpp
index 50479f298..a3c815f86 100644
--- a/installerbuilder/installerbase/installerbase.cpp
+++ b/installerbuilder/installerbase/installerbase.cpp
@@ -53,6 +53,7 @@
#include "kdupdaterfiledownloaderfactory.h"
#include <QtCore/QTranslator>
+#include <QtGui/QMessageBox>
#include <QtNetwork/QNetworkProxyFactory>
@@ -83,6 +84,23 @@ static QSet<Repository> repositories(const QStringList &arguments, const int ind
return set;
}
+static bool allowMaintenanceTool()
+{
+ try {
+ Settings m_settings = Settings(Settings::fromFileAndPrefix(QLatin1String(":/metadata/installer-config/config.xml"),
+ QLatin1String(":/metadata/installer-config/")));
+
+ if (m_settings.value(QLatin1String("AllowExecuteMaintenanceTool"), QLatin1String("true")).toString().toLower()
+ == QLatin1String("true"))
+ {
+ return true;
+ }
+ } catch (const Error &e) {
+ qWarning("Could not parse Config: %s", qPrintable(e.message()));
+ return true;
+ }
+ return false;
+}
// -- main
@@ -232,6 +250,16 @@ int main(int argc, char *argv[])
// instantiate the installer we are actually going to use
QInstaller::PackageManagerCore core(content.magicmaker(), content.performedOperations());
+ Settings m_settings = Settings(Settings::fromFileAndPrefix(QLatin1String(":/metadata/installer-config/config.xml"),
+ QLatin1String(":/metadata/installer-config/")));
+
+ // check execution rights for the maintanance tool
+ if (!core.isInstaller() && !allowMaintenanceTool() && !args.contains(QLatin1String("--script"))) {
+ QString reason = m_settings.value(QLatin1String("DisallowExecuteReason"),
+ QString::fromLatin1("You are not allowed to run %1.").arg(qAppName())).toString();
+ QMessageBox::information(0, QLatin1String("Update notification"), reason);
+ return 0;
+ }
if (QInstaller::isVerbose()) {
verbose() << "Resource tree after loading the in-binary resource: " << std::endl;