summaryrefslogtreecommitdiffstats
path: root/app/main.cpp
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-05-16 16:14:30 -0400
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-06-02 22:28:18 -0700
commitb0f682b1579e520896ccd5492d6666d962a0c226 (patch)
tree159147561c294cd52de6d6c3b6e81c3186fedef6 /app/main.cpp
parent535f2d051f965e9ee4a9c1eed13a8d0e997463e8 (diff)
binding: add initial media binding
Add initial media binding that populates playlist on media insertion Bug-AGL: SPEC-610 Change-Id: I24227f7c718606191ae3de72bd692e747353c919 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'app/main.cpp')
-rw-r--r--app/main.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/main.cpp b/app/main.cpp
index 8ad7b7f..528f840 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -14,9 +14,11 @@
* limitations under the License.
*/
+#include <QtCore/QCommandLineParser>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QStandardPaths>
+#include <QtCore/QUrlQuery>
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
#include <QtQml/QQmlContext>
@@ -85,6 +87,29 @@ int main(int argc, char *argv[])
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;
+ 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);
+ }
+
context->setContextProperty("mediaFiles", mediaFiles);
#if defined(HAVE_DBUS)