#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))
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)
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) {
#include <QtQml/qqml.h>
#include <QQuickWindow>
#include <QScreen>
+#include <QUrlQuery>
+#include <QTimer>
#include <qpa/qplatformnativeinterface.h>
#include <cstdlib>
#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)
}
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");
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"));
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);