aboutsummaryrefslogtreecommitdiffstats
path: root/launcher
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2020-01-22 21:42:06 +0200
committerMarius Vlad <marius.vlad@collabora.com>2020-01-23 16:33:56 +0200
commit50d87b3696390d30f8801bcdff908e33ed7e61aa (patch)
treedda169c89c5d9db8d69535a7a8ed3cb29db79be6 /launcher
parent830921faab68c1d4b00b9a93a99a1584c59baf34 (diff)
launcher/: Convert launcher to agl-compositor
- adds pws/ directory just like homescreen to be able to get list of runnables apps and be able to spawn them with the help of libafbwsc - removes libhomescreen libwindowmanger call from main and qmake files Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Change-Id: I2f6aebfe05a23389796e801300cb616000bdef2b
Diffstat (limited to 'launcher')
-rw-r--r--launcher/launcher.pro6
-rw-r--r--launcher/src/applicationhandler.cpp30
-rw-r--r--launcher/src/applicationhandler.h36
-rw-r--r--launcher/src/applicationlauncher.cpp22
-rw-r--r--launcher/src/applicationlauncher.h7
-rw-r--r--launcher/src/applicationmodel.cpp8
-rw-r--r--launcher/src/applicationmodel.h2
-rw-r--r--launcher/src/main.cpp91
8 files changed, 108 insertions, 94 deletions
diff --git a/launcher/launcher.pro b/launcher/launcher.pro
index e16e9ce..bf1989e 100644
--- a/launcher/launcher.pro
+++ b/launcher/launcher.pro
@@ -18,22 +18,22 @@ TARGET = launcher
QT = qml quick dbus websockets
CONFIG += c++11 link_pkgconfig
DESTDIR = $${OUT_PWD}/../package/root/bin
-PKGCONFIG += qlibwindowmanager libhomescreen
include(../interfaces/interfaces.pri)
+include(../pws/pws.pri)
SOURCES += \
src/main.cpp \
src/applicationmodel.cpp \
src/appinfo.cpp \
src/applicationlauncher.cpp \
- src/homescreenhandler.cpp
+ src/applicationhandler.cpp
HEADERS += \
src/applicationlauncher.h \
src/applicationmodel.h \
src/appinfo.h \
- src/homescreenhandler.h
+ src/applicationhandler.h
OTHER_FILES += \
README.md
diff --git a/launcher/src/applicationhandler.cpp b/launcher/src/applicationhandler.cpp
new file mode 100644
index 0000000..38f5220
--- /dev/null
+++ b/launcher/src/applicationhandler.cpp
@@ -0,0 +1,30 @@
+#include <QFileInfo>
+#include <functional>
+
+#include "applicationhandler.h"
+
+
+ApplicationHandler::ApplicationHandler(QObject *parent, Launcher *launcher) :
+ QObject(parent)
+{
+ m_launcher = launcher;
+}
+
+ApplicationHandler::~ApplicationHandler()
+{
+}
+
+size_t
+ApplicationHandler::getRunnables(void)
+{
+ QString data;
+ size_t runnables = 0;
+
+ if (m_launcher == nullptr)
+ return runnables;
+
+ runnables = m_launcher->get_list_runnables(data);
+ emit initAppList(data);
+
+ return runnables;
+}
diff --git a/launcher/src/applicationhandler.h b/launcher/src/applicationhandler.h
new file mode 100644
index 0000000..5a5508e
--- /dev/null
+++ b/launcher/src/applicationhandler.h
@@ -0,0 +1,36 @@
+#ifndef APPLICATIONHANDLER_H
+#define APPLICATIONHANDLER_H
+
+#include <QObject>
+#include <QDebug>
+#include <string>
+
+#include "launcher.h"
+
+using namespace std;
+
+class ApplicationHandler : public QObject
+{
+ Q_OBJECT
+public:
+ explicit ApplicationHandler(QObject *parent = 0, Launcher *launcher = 0);
+ ~ApplicationHandler();
+
+ //void init(int port, const char* token, QLibWindowmanager *qwm, QString myname);
+ //Q_INVOKABLE void tapShortcut(QString application_id);
+ Q_INVOKABLE size_t getRunnables(void);
+
+ //void onRep(struct json_object* reply_contents);
+ //static void* myThis;
+ //static void onRep_static(struct json_object* reply_contents);
+
+signals:
+ void initAppList(QString data);
+ void appListUpdate(QStringList info);
+
+private:
+ QString m_myname;
+ Launcher *m_launcher;
+};
+
+#endif // APPLICATIONHANDLER_H
diff --git a/launcher/src/applicationlauncher.cpp b/launcher/src/applicationlauncher.cpp
index 19ea2e3..9dcc3fc 100644
--- a/launcher/src/applicationlauncher.cpp
+++ b/launcher/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,15 +39,23 @@ 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("Launcher","ApplicationLauncher failed to set-up connection to afm-system-daemon");
}
int ApplicationLauncher::launch(const QString &application)
{
int result = -1;
- HMI_DEBUG("launch","ApplicationLauncher launch %s.", application.toStdString().c_str());
+ HMI_DEBUG("Launcher","ApplicationLauncher launch %s.", application.toStdString().c_str());
- result = afm_user_daemon_proxy->start(application).value().toInt();
- HMI_DEBUG("launch","ApplicationLauncher pid: %d.", result);
+ if (m_launcher->connection_is_set())
+ result = m_launcher->start(application);
+
+ HMI_DEBUG("Launcher","ApplicationLauncher pid: %d.", result);
if (result > 1) {
setLaunching(true);
@@ -83,3 +87,5 @@ void ApplicationLauncher::setCurrent(const QString &current)
m_current = current;
emit currentChanged(current);
}
+
+
diff --git a/launcher/src/applicationlauncher.h b/launcher/src/applicationlauncher.h
index d205994..4cb8e79 100644
--- a/launcher/src/applicationlauncher.h
+++ b/launcher/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,10 +32,11 @@ 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;
+ Launcher *get_launcher(void) { return m_launcher; }
signals:
void newAppRequestsToBeVisible(int pid);
@@ -50,6 +54,7 @@ private:
bool m_launching;
QString m_current;
QTimer *m_timeout;
+ Launcher *m_launcher;
};
#endif // APPLICATIONLAUNCHER_H
diff --git a/launcher/src/applicationmodel.cpp b/launcher/src/applicationmodel.cpp
index 261e43e..ccb5d06 100644
--- a/launcher/src/applicationmodel.cpp
+++ b/launcher/src/applicationmodel.cpp
@@ -21,13 +21,13 @@
#include "hmi-debug.h"
+#include <QJsonDocument>
+#include <QJsonArray>
+#include <QJsonObject>
+
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply>
-#include "afm_user_daemon_proxy.h"
-
-extern org::AGL::afm::user *afm_user_daemon_proxy;
-
class ApplicationModel::Private
{
public:
diff --git a/launcher/src/applicationmodel.h b/launcher/src/applicationmodel.h
index 780e575..0b64c5d 100644
--- a/launcher/src/applicationmodel.h
+++ b/launcher/src/applicationmodel.h
@@ -18,6 +18,8 @@
#ifndef APPLICATIONMODEL_H
#define APPLICATIONMODEL_H
+#include <QDebug>
+#include <QFile>
#include <QtCore/QAbstractListModel>
class ApplicationModel : public QAbstractListModel
diff --git a/launcher/src/main.cpp b/launcher/src/main.cpp
index e550948..6d20ec8 100644
--- a/launcher/src/main.cpp
+++ b/launcher/src/main.cpp
@@ -23,47 +23,23 @@
#include <QtQml/qqml.h>
#include <QQuickWindow>
#include <QThread>
+#include <QUrlQuery>
+
+#include <QDBusMetaType>
+#include <QDBusArgument>
-#include <qlibwindowmanager.h>
#include "applicationlauncher.h"
#include "applicationmodel.h"
+#include "applicationhandler.h"
#include "appinfo.h"
-#include "afm_user_daemon_proxy.h"
-#include "homescreenhandler.h"
-#include "hmi-debug.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"
int main(int argc, char *argv[])
{
QString myname = QString("launcher");
QGuiApplication a(argc, argv);
- // 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(myname);
- QCoreApplication::setApplicationVersion("0.1.0");
-
QCommandLineParser parser;
parser.addPositionalArgument("port", a.translate("main", "port for binding"));
parser.addPositionalArgument("secret", a.translate("main", "secret for binding"));
@@ -80,44 +56,17 @@ int main(int argc, char *argv[])
token = positionalArguments.takeFirst();
}
- HMI_DEBUG("launcher","port = %d, token = %s", port, token.toStdString().c_str());
-
// import C++ class to QML
qmlRegisterType<ApplicationModel>("AppModel", 1, 0, "ApplicationModel");
// DBus
qDBusRegisterMetaType<AppInfo>();
- qDBusRegisterMetaType<QList<AppInfo> >();
-
- ApplicationLauncher *launcher = new ApplicationLauncher();
- QLibWindowmanager* layoutHandler = new QLibWindowmanager();
- if(layoutHandler->init(port,token) != 0){
- exit(EXIT_FAILURE);
- }
-
- AGLScreenInfo screenInfo(layoutHandler->get_scale_factor());
+ qDBusRegisterMetaType<QList<AppInfo>>();
- if (layoutHandler->requestSurface(myname) != 0) {
- exit(EXIT_FAILURE);
- }
-
- layoutHandler->set_event_handler(QLibWindowmanager::Event_SyncDraw, [layoutHandler, myname](json_object *object) {
- layoutHandler->endDraw(myname);
- });
-
- layoutHandler->set_event_handler(QLibWindowmanager::Event_Visible, [layoutHandler, launcher](json_object *object) {
- QString label = QString(json_object_get_string( json_object_object_get(object, "drawing_name") ));
- qDebug() << label;
- QMetaObject::invokeMethod(launcher, "setCurrent", Qt::QueuedConnection, Q_ARG(QString, label == "HomeScreen" ? "Home" : label));
- });
-
- layoutHandler->set_event_handler(QLibWindowmanager::Event_Invisible, [layoutHandler, launcher](json_object *object) {
- const char* label = json_object_get_string( json_object_object_get(object, "drawing_name") );
- HMI_DEBUG("launch", "surface %s Event_Invisible", label);
- });
-
- HomescreenHandler* homescreenHandler = new HomescreenHandler();
- homescreenHandler->init(port, token.toStdString().c_str(), layoutHandler, myname);
+ ApplicationLauncher *launcher =
+ new ApplicationLauncher(CONNECT_STR, &a);
+ ApplicationHandler *homescreenHandler =
+ new ApplicationHandler(nullptr, launcher->get_launcher());
QUrl bindingAddress;
bindingAddress.setScheme(QStringLiteral("ws"));
@@ -129,28 +78,14 @@ int main(int argc, char *argv[])
query.addQueryItem(QStringLiteral("token"), token);
bindingAddress.setQuery(query);
- const QByteArray hack_delay = qgetenv("HMI_LAUNCHER_STARTUP_DELAY");
- int delay_time = 1;
-
- if (!hack_delay.isEmpty()) {
- delay_time = (QString::fromLocal8Bit(hack_delay)).toInt();
- }
-
- QThread::sleep(delay_time);
- qDebug("Sleep %d sec to resolve race condtion between HomeScreen and Launcher", delay_time);
-
// mail.qml loading
QQmlApplicationEngine engine;
- engine.rootContext()->setContextProperty(QStringLiteral("layoutHandler"), layoutHandler);
+
engine.rootContext()->setContextProperty(QStringLiteral("homescreenHandler"), homescreenHandler);
engine.rootContext()->setContextProperty(QStringLiteral("launcher"), launcher);
- engine.rootContext()->setContextProperty(QStringLiteral("screenInfo"), &screenInfo);
engine.load(QUrl(QStringLiteral("qrc:/Launcher.qml")));
- homescreenHandler->getRunnables();
- QObject *root = engine.rootObjects().first();
- QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
- QObject::connect(window, SIGNAL(frameSwapped()), layoutHandler, SLOT(slotActivateSurface()));
+ homescreenHandler->getRunnables();
return a.exec();
}