diff options
author | Marius Vlad <marius.vlad@collabora.com> | 2020-05-29 17:57:33 +0300 |
---|---|---|
committer | Marius Vlad <marius.vlad@collabora.com> | 2020-06-24 18:13:15 +0300 |
commit | 18abf43ba645b46b0d6c5245e8282e2d6db40332 (patch) | |
tree | ac0bef263ce9e754d0b2607177effe868eec75cf | |
parent | e0abfb8c769536cec9db9e78fff6dd93754dcd7a (diff) |
app/main: Bring back secret and port to be able to access thejellyfish_9.99.4jellyfish_9.99.3jellyfish_9.99.2jellyfish_9.99.1jellyfish/9.99.4jellyfish/9.99.3jellyfish/9.99.2jellyfish/9.99.19.99.49.99.39.99.29.99.1
bindingAdress
Bug-AGL: SPEC-3447
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I5afeecdbfc9d0272d9231d7d4c19334c1ce6d9cc
-rw-r--r-- | app/main.cpp | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/app/main.cpp b/app/main.cpp index 41b5892..76efbbf 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -17,10 +17,13 @@ */ #include <QGuiApplication> +#include <QtCore/QCommandLineParser> +#include <QtCore/QUrlQuery> #include <QtGui/QGuiApplication> #include <QtQml/QQmlContext> #include <QtQml/QQmlApplicationEngine> #include <QtQml/qqml.h> +#include <QDebug> #include "mixer.hpp" #include "audiorole.hpp" @@ -30,9 +33,38 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); app.setDesktopFileName("mixer"); - QQmlApplicationEngine engine; - qmlRegisterType<Mixer>("Mixer", 1, 0, "Mixer"); - engine.load(QUrl(QStringLiteral("qrc:/Mixer.qml"))); + QQmlApplicationEngine engine; + QQmlContext *context = engine.rootContext(); + + 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; + QUrlQuery query; + + bindingAddress.setScheme(QStringLiteral("ws")); + bindingAddress.setHost(QStringLiteral("localhost")); + bindingAddress.setPort(port); + bindingAddress.setPath(QStringLiteral("/api")); + + + query.addQueryItem(QStringLiteral("token"), secret); + bindingAddress.setQuery(query); + context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress); + + qmlRegisterType<Mixer>("Mixer", 1, 0, "Mixer"); + } + + engine.load(QUrl(QStringLiteral("qrc:/Mixer.qml"))); return app.exec(); } |