diff options
Diffstat (limited to 'app/main.cpp')
-rw-r--r-- | app/main.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/app/main.cpp b/app/main.cpp index 4f13346..6122733 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -9,7 +9,6 @@ #include <QtDBus/QDBusConnection> #include "qcheapruler.hpp" -#include "dbus_client.h" #include "file_operation.h" #ifdef HAVE_QLIBHOMESCREEN @@ -21,12 +20,6 @@ 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); @@ -43,12 +36,25 @@ int main(int argc, char *argv[]) parser.process(app); QStringList positionalArguments = parser.positionalArguments(); + //make the bindingAddress for websocket QQmlApplicationEngine engine; + 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); + engine.rootContext()->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress); + }else { + engine.rootContext()->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress); } #ifdef HAVE_QLIBWINDOWMANAGER @@ -76,9 +82,11 @@ int main(int argc, char *argv[]) #endif qmlRegisterType<QCheapRuler>("com.mapbox.cheap_ruler", 1, 0, "CheapRuler"); + //read the config info from /etc/naviconfig.ini File_Operation file; engine.rootContext()->setContextProperty("fileOperation", &file); + //load the qml file engine.load(QUrl(QStringLiteral("qrc:qml/Main.qml"))); QObject *root = engine.rootObjects().first(); @@ -86,12 +94,6 @@ int main(int argc, char *argv[]) #ifdef HAVE_QLIBHOMESCREEN qhs->setQuickWindow(window); #endif - //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())); |