From 54028f6c8e856ac44e6833328b22d7b90fd4fbd7 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Thu, 22 Dec 2016 17:27:58 +0900 Subject: Wifi & Bluetooth: use binding address defined in main.cpp Change-Id: I37927e3287cc63531e58aedec0fee67eb4331e47 Signed-off-by: Tasuku Suzuki --- app/bluetooth/Bluetooth.qml | 7 +------ app/main.cpp | 29 +++++++++++++++-------------- app/wifi/Wifi.qml | 7 +------ 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/app/bluetooth/Bluetooth.qml b/app/bluetooth/Bluetooth.qml index 3a4d50f..ed489e5 100644 --- a/app/bluetooth/Bluetooth.qml +++ b/app/bluetooth/Bluetooth.qml @@ -25,12 +25,7 @@ SettingPage { title: 'Bluetooth' checkable: true - property string protocol: 'http://' - property string ipAddress: '127.0.0.1' - property string portNumber: Qt.application.arguments[1] - property string tokenString: Qt.application.arguments[2] - property string btAPI: '/api/Bluetooth-manager/' - property string btAPIpath: protocol + ipAddress + ':' + portNumber + btAPI + property string btAPIpath: bindingAddress + '/Bluetooth-manager/' property var jsonObjectBT property string currentState: 'idle' property string btState: 'off' //add property to indicate the bt status diff --git a/app/main.cpp b/app/main.cpp index fd8201e..a55ebad 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) QCommandLineParser parser; parser.addPositionalArgument("port", app.translate("main", "port for binding")); - parser.addPositionalArgument("secret", app.translate("main", "secret for binding")); +// parser.addPositionalArgument("secret", app.translate("main", "secret for binding")); parser.addHelpOption(); parser.addVersionOption(); parser.process(app); @@ -75,20 +75,21 @@ int main(int argc, char *argv[]) QQmlApplicationEngine engine; - 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); + int port = 0; + if (!positionalArguments.isEmpty()) { + port = positionalArguments.takeFirst().toInt(); } +// QString secret = positionalArguments.takeFirst(); + QUrl bindingAddress; + bindingAddress.setScheme(QStringLiteral("http")); + 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); QFile version("/proc/version"); if (version.open(QFile::ReadOnly)) { diff --git a/app/wifi/Wifi.qml b/app/wifi/Wifi.qml index f5fdae1..f9a85e1 100644 --- a/app/wifi/Wifi.qml +++ b/app/wifi/Wifi.qml @@ -25,12 +25,7 @@ SettingPage { title: 'Wifi' checkable: true - property string protocol: 'http://' - property string ipAddress: '127.0.0.1' - property string portNumber: Qt.application.arguments[1] - property string tokenString: Qt.application.arguments[2] - property string wifiAPI: '/api/wifi-manager/' - property string wifiAPIpath: protocol + ipAddress + ':' + portNumber + wifiAPI + property string wifiAPIpath: bindingAddress + '/wifi-manager/' Text { id: log -- cgit 1.2.3-korg