diff options
author | Marius Vlad <marius.vlad@collabora.com> | 2020-01-21 23:55:01 +0200 |
---|---|---|
committer | Marius Vlad <marius.vlad@collabora.com> | 2020-01-22 12:24:03 +0200 |
commit | a70783aad1f382bd2aaf8d611d070cef7266de50 (patch) | |
tree | 44a4fea6c36bef6d950fe75d6ad59664417f6b2f | |
parent | a38fd717e98dfc20bd7da11dec37294afda678b5 (diff) |
homescreen/: Plug-in the launcher in the applicationlauncher
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I12d17bfb130362fbe0381884d294f03fafc8833e
-rw-r--r-- | homescreen/src/applicationlauncher.cpp | 16 | ||||
-rw-r--r-- | homescreen/src/applicationlauncher.h | 6 | ||||
-rw-r--r-- | homescreen/src/main.cpp | 52 |
3 files changed, 19 insertions, 55 deletions
diff --git a/homescreen/src/applicationlauncher.cpp b/homescreen/src/applicationlauncher.cpp index 5a1e2d6..bb9f646 100644 --- a/homescreen/src/applicationlauncher.cpp +++ b/homescreen/src/applicationlauncher.cpp @@ -18,13 +18,9 @@ #include "applicationlauncher.h" -#include "afm_user_daemon_proxy.h" - #include "hmi-debug.h" -extern org::AGL::afm::user *afm_user_daemon_proxy; - -ApplicationLauncher::ApplicationLauncher(QObject *parent) +ApplicationLauncher::ApplicationLauncher(const QString &conn_str, QObject *parent) : QObject(parent) , m_launching(false) , m_timeout(new QTimer(this)) @@ -43,6 +39,12 @@ ApplicationLauncher::ApplicationLauncher(QObject *parent) connect(this, &ApplicationLauncher::currentChanged, [&]() { setLaunching(false); }); + + m_launching = false; + m_launcher = new Launcher(conn_str, parent); + + if (m_launcher->setup_pws_connection() != 0) + HMI_DEBUG("HomeScreen","ApplicationLauncher failed to set-up connection to afm-system-daemon"); } int ApplicationLauncher::launch(const QString &application) @@ -50,7 +52,9 @@ int ApplicationLauncher::launch(const QString &application) int result = -1; HMI_DEBUG("HomeScreen","ApplicationLauncher launch %s.", application.toStdString().c_str()); - result = afm_user_daemon_proxy->start(application).value().toInt(); + if (m_launcher->connection_is_set()) + result = m_launcher->start(application); + HMI_DEBUG("HomeScreen","ApplicationLauncher pid: %d.", result); if (result > 1) { diff --git a/homescreen/src/applicationlauncher.h b/homescreen/src/applicationlauncher.h index dfa5846..e6ac183 100644 --- a/homescreen/src/applicationlauncher.h +++ b/homescreen/src/applicationlauncher.h @@ -19,8 +19,11 @@ #ifndef APPLICATIONLAUNCHER_H #define APPLICATIONLAUNCHER_H +#include <QTimer> #include <QtCore/QObject> +#include "launcher.h" + class QTimer; class ApplicationLauncher : public QObject @@ -29,7 +32,7 @@ class ApplicationLauncher : public QObject Q_PROPERTY(bool launching READ isLaunching NOTIFY launchingChanged) Q_PROPERTY(QString current READ current WRITE setCurrent NOTIFY currentChanged) public: - explicit ApplicationLauncher(QObject *parent = NULL); + explicit ApplicationLauncher(const QString &afm_conn_str, QObject *parent = NULL); bool isLaunching() const; QString current() const; @@ -50,6 +53,7 @@ private: bool m_launching; QString m_current; QTimer *m_timeout; + Launcher *m_launcher; }; #endif // APPLICATIONLAUNCHER_H diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp index 901799c..fb207f2 100644 --- a/homescreen/src/main.cpp +++ b/homescreen/src/main.cpp @@ -24,6 +24,8 @@ #include <QtQml/qqml.h> #include <QQuickWindow> #include <QScreen> +#include <QUrlQuery> +#include <QTimer> #include <qpa/qplatformnativeinterface.h> #include <cstdlib> @@ -35,27 +37,13 @@ #include <bluetooth.h> #include "applicationlauncher.h" #include "statusbarmodel.h" -#include "afm_user_daemon_proxy.h" #include "mastervolume.h" #include "shell.h" #include "hmi-debug.h" #include "wayland-agl-shell-client-protocol.h" -// XXX: We want this DBus connection to be shared across the different -// QML objects, is there another way to do this, a nice way, perhaps? -org::AGL::afm::user *afm_user_daemon_proxy; - -namespace { - -struct Cleanup { - static inline void cleanup(org::AGL::afm::user *p) { - delete p; - afm_user_daemon_proxy = Q_NULLPTR; - } -}; - -} +#define CONNECT_STR "unix:/run/platform/apis/ws/afm-main" static void global_add(void *data, struct wl_registry *reg, uint32_t name, const char *interface, uint32_t) @@ -109,13 +97,6 @@ int main(int argc, char *argv[]) } std::shared_ptr<struct agl_shell> shell{agl_shell, agl_shell_destroy}; - // use launch process - QScopedPointer<org::AGL::afm::user, Cleanup> afm_user_daemon_proxy(new org::AGL::afm::user("org.AGL.afm.user", - "/org/AGL/afm/user", - QDBusConnection::sessionBus(), - 0)); - ::afm_user_daemon_proxy = afm_user_daemon_proxy.data(); - QCoreApplication::setOrganizationDomain("LinuxFoundation"); QCoreApplication::setOrganizationName("AutomotiveGradeLinux"); QCoreApplication::setApplicationName("HomeScreen"); @@ -145,7 +126,7 @@ int main(int argc, char *argv[]) qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel"); qmlRegisterType<MasterVolume>("MasterVolume", 1, 0, "MasterVolume"); - ApplicationLauncher *launcher = new ApplicationLauncher(); + ApplicationLauncher *launcher = new ApplicationLauncher(CONNECT_STR, &a); QUrl bindingAddress; bindingAddress.setScheme(QStringLiteral("ws")); @@ -157,31 +138,6 @@ int main(int argc, char *argv[]) query.addQueryItem(QStringLiteral("token"), token); bindingAddress.setQuery(query); -#if 0 - // mail.qml loading - QQmlApplicationEngine engine; - engine.rootContext()->setContextProperty("bindingAddress", bindingAddress); - engine.rootContext()->setContextProperty("launcher", launcher); - engine.rootContext()->setContextProperty("weather", new Weather(bindingAddress)); - engine.rootContext()->setContextProperty("bluetooth", new Bluetooth(bindingAddress, engine.rootContext())); - //engine.rootContext()->setContextProperty("screenInfo", &screenInfo); - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); - engine.load(QUrl(QStringLiteral("qrc:/background.qml"))); - - auto root_objects = engine.rootObjects(); - printf("num root objects: %d\n", root_objects.length()); - QObject *root = engine.rootObjects().first(); - QQuickWindow *window = qobject_cast<QQuickWindow *>(root); - - for (auto o : root_objects) { - qDebug() << o->dynamicPropertyNames(); - } - - QList<QObject *> sobjs = engine.rootObjects(); - StatusBarModel *statusBar = sobjs.first()->findChild<StatusBarModel *>("statusBar"); - statusBar->init(bindingAddress, engine.rootContext()); -#endif - QQmlEngine engine; QQmlContext *context = engine.rootContext(); context->setContextProperty("bindingAddress", bindingAddress); |