summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/app.pro2
-rw-r--r--app/main.cpp26
2 files changed, 28 insertions, 0 deletions
diff --git a/app/app.pro b/app/app.pro
index 2117c8c..cc400a9 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -3,6 +3,8 @@ QT = quickcontrols2
SOURCES = main.cpp
+SUBDIRS = telephony-binding
+
RESOURCES += \
phone.qrc \
images/images.qrc \
diff --git a/app/main.cpp b/app/main.cpp
index 952d222..0fe4bf1 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -15,8 +15,11 @@
*/
#include <QtCore/QDebug>
+#include <QtCore/QCommandLineParser>
+#include <QtCore/QUrlQuery>
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
+#include <QtQml/QQmlContext>
#include <QtQuickControls2/QQuickStyle>
#ifdef HAVE_LIBHOMESCREEN
@@ -39,6 +42,29 @@ int main(int argc, char *argv[])
QQuickStyle::setStyle("AGL");
QQmlApplicationEngine engine;
+
+ QCommandLineParser parser;
+ parser.addPositionalArgument("port", app.translate("main", "port for binding"));
+ parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.process(app);
+ QStringList positionalArguments = parser.positionalArguments();
+ if (positionalArguments.length() == 2) {
+ int port = positionalArguments.takeFirst().toInt();
+ QString secret = positionalArguments.takeFirst();
+ QUrl bindingAddress;
+ 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);
+ QQmlContext *context = engine.rootContext();
+ context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
+ }
+
engine.load(QUrl(QStringLiteral("qrc:/Phone.qml")));
return app.exec();