Add pws to be able to start apps
[apps/onscreenapp.git] / sample / app / eventhandler.cpp
index 388291f..58f99fc 100644 (file)
@@ -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;
+}