summaryrefslogtreecommitdiffstats
path: root/sample/app
diff options
context:
space:
mode:
Diffstat (limited to 'sample/app')
-rw-r--r--sample/app/app.pro2
-rw-r--r--sample/app/eventhandler.cpp25
-rw-r--r--sample/app/eventhandler.h10
-rw-r--r--sample/app/main.qml15
4 files changed, 45 insertions, 7 deletions
diff --git a/sample/app/app.pro b/sample/app/app.pro
index 5710f3b..f6f5b82 100644
--- a/sample/app/app.pro
+++ b/sample/app/app.pro
@@ -21,6 +21,8 @@ CONFIG += c++11 link_pkgconfig wayland-scanner pkgdatadir
PKGCONFIG += wayland-client
DESTDIR = $${OUT_PWD}/../package/root/bin
+include(../../pws/pws.pri)
+
SOURCES = main.cpp \
eventhandler.cpp
diff --git a/sample/app/eventhandler.cpp b/sample/app/eventhandler.cpp
index 388291f..58f99fc 100644
--- a/sample/app/eventhandler.cpp
+++ b/sample/app/eventhandler.cpp
@@ -137,6 +137,11 @@ void EventHandler::init(int port, const char *token)
if (shell_desktop)
agl_shell_desktop_add_listener(shell_desktop, &agl_shell_desk_listener, this);
+
+ m_launcher = new Launcher(DEFAULT_AFM_UNIX_SOCK, nullptr);
+ if (m_launcher->setup_pws_connection() != 0)
+ HMI_DEBUG("onscreen", "EventHandler::init failed to set-up connection to afm-system-daemon");
+
#if 0
myThis = this;
mp_wm = new QLibWindowmanager();
@@ -217,3 +222,23 @@ void EventHandler::hideWindow(QString id)
mp_hs->hideWindow(id.toStdString().c_str());
#endif
}
+
+int
+EventHandler::start(const QString &app_id)
+{
+ int pid = -1;
+
+ if (m_launcher && m_launcher->connection_is_set())
+ pid = m_launcher->start(app_id);
+
+ return pid;
+}
+
+bool
+EventHandler::is_running(const QString &app_id)
+{
+ if (m_launcher && m_launcher->connection_is_set())
+ return m_launcher->is_running(app_id);
+
+ return false;
+}
diff --git a/sample/app/eventhandler.h b/sample/app/eventhandler.h
index c57c806..77e01e6 100644
--- a/sample/app/eventhandler.h
+++ b/sample/app/eventhandler.h
@@ -29,6 +29,11 @@
#include <wayland-client.h>
#include "wayland-agl-shell-desktop-client-protocol.h"
+#ifndef DEFAULT_AFM_UNIX_SOCK
+#define DEFAULT_AFM_UNIX_SOCK "unix:/run/platform/apis/ws/afm-main"
+#endif
+
+#include "launcher.h"
#include "hmi-debug.h"
#define ROLE_NAME "onstestapp"
@@ -52,6 +57,8 @@ public:
Q_INVOKABLE void showWindow(QString id, QString json);
Q_INVOKABLE void hideWindow(QString id);
+ Q_INVOKABLE int start(const QString &app_id);
+ Q_INVOKABLE bool is_running(const QString &app_id);
signals:
void signalOnReplyShowWindow(QVariant val);
@@ -62,7 +69,8 @@ private:
QLibWindowmanager* mp_wm;
#endif
struct agl_shell_desktop *shell_desktop = nullptr;
- QQuickWindow *mp_qw;
+ Launcher *m_launcher = nullptr;
+ QQuickWindow *mp_qw;
};
#endif // EVENTHANDLER_H
diff --git a/sample/app/main.qml b/sample/app/main.qml
index 4d23921..f0a65e9 100644
--- a/sample/app/main.qml
+++ b/sample/app/main.qml
@@ -19,6 +19,7 @@ ApplicationWindow {
property string onsButton3: qsTr("")
property string postmsg: qsTr("")
property string btndata: qsTr("")
+ property int pid: -1
Label {
id: title
@@ -340,12 +341,14 @@ ApplicationWindow {
postmsg += "}"
// if the application is not already started, start it
- // if the application is not started, the first time we start
- // it will by shown by default
- eventHandler.start(onsId, postmsg)
-
- // we just need to display
- eventHandler.showWindow(onsId, postmsg)
+ if (pid == -1) {
+ // if the application is not started, then the first time
+ // we start we also display it using the default policy engine
+ pid = eventHandler.start(onsId, postmsg)
+ } else {
+ // we just need to display it
+ eventHandler.showWindow(onsId, postmsg)
+ }
}
function qmlOnReplyShowWindow(text) {