diff options
author | Robert Griebl <robert.griebl@pelagicore.com> | 2018-03-21 13:26:47 +0100 |
---|---|---|
committer | Dominik Holland <dominik.holland@pelagicore.com> | 2018-03-22 14:58:23 +0000 |
commit | d47e6e66df5b7b457319572334c981d38b6e32a6 (patch) | |
tree | f36580461e599bf58a79a27cf926084361b1e3fd | |
parent | 790857cd87c5cb43c51c134161cbf974c898ba1b (diff) |
Move sanity checks in the qml launcher
We tested the parameters coming from the AM without being sure that we were
being called from the AM at all (--help / --directload)
Change-Id: I3928701ef3981b7681174dd030f9b16d463aa512
Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rw-r--r-- | src/launcher-lib/launchermain.cpp | 81 | ||||
-rw-r--r-- | src/launcher-lib/launchermain.h | 3 | ||||
-rw-r--r-- | src/launchers/qml/main.cpp | 1 |
3 files changed, 45 insertions, 40 deletions
diff --git a/src/launcher-lib/launchermain.cpp b/src/launcher-lib/launchermain.cpp index 790c5afe..76142550 100644 --- a/src/launcher-lib/launchermain.cpp +++ b/src/launcher-lib/launchermain.cpp @@ -53,47 +53,10 @@ QT_BEGIN_NAMESPACE_AM -LauncherMain::LauncherMain(int &argc, char **argv, const QByteArray &configYaml) Q_DECL_NOEXCEPT_EXPR(false) +LauncherMain::LauncherMain(int &argc, char **argv) Q_DECL_NOEXCEPT : LauncherMainBase(SharedMain::preConstructor(argc), argv) , SharedMain() -{ - auto docs = QtYaml::variantDocumentsFromYaml(configYaml.isEmpty() ? qgetenv("AM_CONFIG") - : configYaml); - if (docs.size() == 1) - m_configuration = docs.first().toMap(); - - m_baseDir = m_configuration.value(qSL("baseDir")).toString() + qL1C('/'); - m_runtimeConfiguration = m_configuration.value(qSL("runtimeConfiguration")).toMap(); - m_securityToken = QByteArray::fromHex(m_configuration.value(qSL("")).toString().toLatin1()); - m_systemProperties = m_configuration.value(qSL("systemProperties")).toMap(); - - QVariantMap loggingConfig = m_configuration.value(qSL("logging")).toMap(); - m_loggingRules = variantToStringList(loggingConfig.value(qSL("rules"))); - - QVariantMap dbusConfig = m_configuration.value(qSL("dbus")).toMap(); - m_dbusAddressP2P = dbusConfig.value(qSL("p2p")).toString(); - m_dbusAddressNotifications = dbusConfig.value(qSL("org.freedesktop.Notifications")).toString(); - - QVariantMap uiConfig = m_configuration.value(qSL("ui")).toMap(); - m_slowAnimations = uiConfig.value(qSL("slowAnimations")).toBool(); - m_openGLConfiguration = uiConfig.value(qSL("opengl")).toMap(); - - // un-comment this if things go south: - //qWarning() << "### LOG " << m_loggingRules; - //qWarning() << "### DBUS" << dbusConfig; - //qWarning() << "### UI " << uiConfig; - //qWarning() << "### RT " << m_runtimeConfiguration; - //qWarning() << "### SYSP" << m_systemProperties; - //qWarning() << "### GL " << m_openGLConfiguration; - - // sanity checks - if (m_baseDir == qL1S("/")) - throw Exception("Runtime launcher received an empty baseDir"); - if (loggingConfig.isEmpty()) - throw Exception("Runtime launcher received no logging configuration"); - if (dbusConfig.isEmpty()) - throw Exception("Runtime launcher received no D-Bus configuration"); -} +{ } LauncherMain::~LauncherMain() { } @@ -143,6 +106,46 @@ QVariantMap LauncherMain::openGLConfiguration() const return m_openGLConfiguration; } +void LauncherMain::loadConfiguration(const QByteArray &configYaml) Q_DECL_NOEXCEPT_EXPR(false) +{ + auto docs = QtYaml::variantDocumentsFromYaml(configYaml.isEmpty() ? qgetenv("AM_CONFIG") + : configYaml); + if (docs.size() == 1) + m_configuration = docs.first().toMap(); + + m_baseDir = m_configuration.value(qSL("baseDir")).toString() + qL1C('/'); + m_runtimeConfiguration = m_configuration.value(qSL("runtimeConfiguration")).toMap(); + m_securityToken = QByteArray::fromHex(m_configuration.value(qSL("")).toString().toLatin1()); + m_systemProperties = m_configuration.value(qSL("systemProperties")).toMap(); + + QVariantMap loggingConfig = m_configuration.value(qSL("logging")).toMap(); + m_loggingRules = variantToStringList(loggingConfig.value(qSL("rules"))); + + QVariantMap dbusConfig = m_configuration.value(qSL("dbus")).toMap(); + m_dbusAddressP2P = dbusConfig.value(qSL("p2p")).toString(); + m_dbusAddressNotifications = dbusConfig.value(qSL("org.freedesktop.Notifications")).toString(); + + QVariantMap uiConfig = m_configuration.value(qSL("ui")).toMap(); + m_slowAnimations = uiConfig.value(qSL("slowAnimations")).toBool(); + m_openGLConfiguration = uiConfig.value(qSL("opengl")).toMap(); + + // un-comment this if things go south: + //qWarning() << "### LOG " << m_loggingRules; + //qWarning() << "### DBUS" << dbusConfig; + //qWarning() << "### UI " << uiConfig; + //qWarning() << "### RT " << m_runtimeConfiguration; + //qWarning() << "### SYSP" << m_systemProperties; + //qWarning() << "### GL " << m_openGLConfiguration; + + // sanity checks + if (m_baseDir == qL1S("/")) + throw Exception("Runtime launcher received an empty baseDir"); + if (loggingConfig.isEmpty()) + throw Exception("Runtime launcher received no logging configuration"); + if (dbusConfig.isEmpty()) + throw Exception("Runtime launcher received no D-Bus configuration"); +} + void LauncherMain::setupDBusConnections() Q_DECL_NOEXCEPT_EXPR(false) { if (m_dbusAddressP2P.isEmpty()) diff --git a/src/launcher-lib/launchermain.h b/src/launcher-lib/launchermain.h index 7ca97b8c..73a076cb 100644 --- a/src/launcher-lib/launchermain.h +++ b/src/launcher-lib/launchermain.h @@ -64,10 +64,11 @@ class LauncherMain : public LauncherMainBase, public SharedMain { Q_OBJECT public: - LauncherMain(int &argc, char **argv, const QByteArray &configYaml = QByteArray()) Q_DECL_NOEXCEPT_EXPR(false); + LauncherMain(int &argc, char **argv) Q_DECL_NOEXCEPT; ~LauncherMain(); public: + void loadConfiguration(const QByteArray &configYaml = QByteArray()) Q_DECL_NOEXCEPT_EXPR(false); void setupDBusConnections() Q_DECL_NOEXCEPT_EXPR(false); QString baseDir() const; diff --git a/src/launchers/qml/main.cpp b/src/launchers/qml/main.cpp index 81026b8e..a8f8b343 100644 --- a/src/launchers/qml/main.cpp +++ b/src/launchers/qml/main.cpp @@ -194,6 +194,7 @@ int main(int argc, char *argv[]) } directLoad = fi.absoluteFilePath(); } else { + a.loadConfiguration(); a.setupDBusConnections(); StartupTimer::instance()->checkpoint("after dbus initialization"); } |