summaryrefslogtreecommitdiffstats
path: root/app/main.cpp
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-03-30 15:05:03 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-04-14 10:56:21 -0700
commit4eee2655560fbb2f7724095bb7fa488f3f39ba55 (patch)
treef8903724e9890fd8163880d04a1f5545577ce3ed /app/main.cpp
parent86affe07b3ec456c8c43651a7d009508dd64491a (diff)
dbus: add signal support for removable media
Detect media insertation and removal from lightmediascanner and update the playlist accordingly. This makes some assumptions that only one media device will available at a time. Bug-AGL: SPEC-484 Change-Id: I8300abce3ac09c9cd0327c9d90892e3c5171d8d2 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'app/main.cpp')
-rw-r--r--app/main.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/app/main.cpp b/app/main.cpp
index 74ebad3..e8d4082 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -31,6 +31,10 @@
#include "lightmediascanner.h"
#endif
+#ifdef HAVE_DBUS
+#include "dbus.h"
+#endif
+
#include "playlistwithmetadata.h"
#ifndef HAVE_LIGHTMEDIASCANNER
@@ -68,18 +72,12 @@ int main(int argc, char *argv[])
qmlRegisterType<PlaylistWithMetadata>("MediaPlayer", 1, 0, "PlaylistWithMetadata");
QVariantList mediaFiles;
- QString music;
#ifdef HAVE_LIGHTMEDIASCANNER
- LightMediaScanner scanner(QDir::homePath() + "/.config/lightmediascannerd/db.sqlite3");
- while (scanner.next(music)) {
- QFileInfo fileInfo(music);
- // Possible for stale entries due to removable media
- if (!fileInfo.exists())
- continue;
- mediaFiles.append(QUrl::fromLocalFile(music));
- }
+ mediaFiles = LightMediaScanner::processLightMediaScanner();
#else
+ QString music;
+
for (const auto &music : QStandardPaths::standardLocations(QStandardPaths::MusicLocation)) {
mediaFiles.append(readMusicFile(music));
}
@@ -88,8 +86,14 @@ int main(int argc, char *argv[])
QQmlApplicationEngine engine;
QQmlContext *context = engine.rootContext();
context->setContextProperty("mediaFiles", mediaFiles);
+
+#if defined(HAVE_DBUS) && defined(HAVE_LIGHTMEDIASCANNER)
+ DbusService dbus_service;
+ context->setContextProperty("dbus", &dbus_service);
+ if (!dbus_service.enableLMS())
+ qWarning() << "Cannot run enableLMS";
+#endif
engine.load(QUrl(QStringLiteral("qrc:/MediaPlayer.qml")));
return app.exec();
}
-