diff options
author | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2018-11-30 16:09:41 +0900 |
---|---|---|
committer | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2018-11-30 16:09:41 +0900 |
commit | 1b09dfb921e37018a0dec3512e24af1d71df0ddc (patch) | |
tree | c8d5d7c59bcc31c3e8f3370fd1dad412580b84c3 /app/main.cpp | |
parent | 7d642f7dae7362a96939e412e358b6d1faad87b9 (diff) |
get gps position from navigation
Diffstat (limited to 'app/main.cpp')
-rw-r--r-- | app/main.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/app/main.cpp b/app/main.cpp index 779af3f..cb9675a 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -6,8 +6,10 @@ #include <QtGui/QGuiApplication> #include <QtQml/QQmlContext> #include <QtQuick/QQuickWindow> +#include <QtDBus/QDBusConnection> #include "qcheapruler.hpp" +#include "dbus_client.h" #ifdef HAVE_LIBHOMESCREEN #include <libhomescreen.hpp> @@ -18,6 +20,12 @@ int main(int argc, char *argv[]) { + if (!QDBusConnection::sessionBus().isConnected()) { + qWarning("Cannot connect to the D-Bus session bus.\n" + "Please check your system settings and try again.\n"); + return 1; + } + QString myname = QString("tbtnavi"); QGuiApplication app(argc, argv); @@ -35,23 +43,11 @@ int main(int argc, char *argv[]) QStringList positionalArguments = parser.positionalArguments(); QQmlApplicationEngine engine; - QQmlContext *context = engine.rootContext(); - QUrl bindingAddress; int port = 0; QString secret; if (positionalArguments.length() == 2) { port = positionalArguments.takeFirst().toInt(); secret = positionalArguments.takeFirst(); - bindingAddress.setScheme(QStringLiteral("ws")); - bindingAddress.setHost(QStringLiteral("localhost")); - bindingAddress.setPort(port); - bindingAddress.setPath(QStringLiteral("/api")); - QUrlQuery query; - query.addQueryItem(QStringLiteral("token"), secret); - bindingAddress.setQuery(query); - context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress); - } else { - context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress); } #ifdef HAVE_QLIBWINDOWMANAGER @@ -98,13 +94,20 @@ int main(int argc, char *argv[]) QObject *root = engine.rootObjects().first(); QQuickWindow *window = qobject_cast<QQuickWindow *>(root); + + //make the DBus connection info + QString pathBase = "org.agl."; + QString objBase = "/org/agl/"; + QString serverName = "naviapi"; + QObject *mapWindow = root->findChild<QObject*>("mapwindow"); + dbus_client dbus(pathBase, objBase, serverName, mapWindow); + #ifdef HAVE_QLIBWINDOWMANAGER // QObject::connect(window, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface())); // Create an event callback against an event type. Here a lambda is called when SyncDraw event occurs qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [root, qwm, myname](json_object *object) { fprintf(stderr, "Surface got syncDraw!\n"); qwm->endDraw(myname); - QMetaObject::invokeMethod(root, "startDemo", Q_ARG(QVariant, true)); }); // Create an event callback against an event type. Here a lambda is called when SyncDraw event occurs qwm->set_event_handler(QLibWindowmanager::Event_Active, [root](json_object *object) { |