[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:29:38 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=337dd19

The following commit has been merged in the master branch:
commit 337dd191e459011faae2f1b8a27a5760ad996e70
Author: David Kahles <david.kahles96 at gmail.com>
Date:   Fri Apr 8 01:12:10 2016 +0200

    Fix mpris player discovery
    
    The previous used QDbusServiceWatcher doesn't work as it does only watch out
    for specific services, but the players use different, unpredictable names, so
    we need to check all service registrations for mpris players.
    
    BUG: 361367
    REVIEW: 127611
---
 plugins/mpriscontrol/mpriscontrolplugin.cpp | 26 +++++++++++++++-----------
 plugins/mpriscontrol/mpriscontrolplugin.h   |  4 +---
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/plugins/mpriscontrol/mpriscontrolplugin.cpp b/plugins/mpriscontrol/mpriscontrolplugin.cpp
index cc2fcde..21b8abe 100644
--- a/plugins/mpriscontrol/mpriscontrolplugin.cpp
+++ b/plugins/mpriscontrol/mpriscontrolplugin.cpp
@@ -44,27 +44,31 @@ MprisControlPlugin::MprisControlPlugin(QObject* parent, const QVariantList& args
 {
     m_watcher = new QDBusServiceWatcher(QString(), QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this);
 
-    connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &MprisControlPlugin::addService);
-    connect(m_watcher, &QDBusServiceWatcher::serviceUnregistered, this, &MprisControlPlugin::removeService);
+    // TODO: QDBusConnectionInterface::serviceOwnerChanged is deprecated, maybe query org.freedesktop.DBus directly?
+    connect(QDBusConnection::sessionBus().interface(), &QDBusConnectionInterface::serviceOwnerChanged, this, &MprisControlPlugin::serviceOwnerChanged);
 
     //Add existing interfaces
     QStringList services = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
     Q_FOREACH (const QString& service, services) {
-        addService(service);
+        // The string doesn't matter, it just needs to be empty/non-empty
+        serviceOwnerChanged(service, QLatin1String(""), QLatin1String("1"));
     }
 }
 
-void MprisControlPlugin::addService(const QString& service)
+// Copied from the mpris2 dataengine in the plasma-workspace repository
+void MprisControlPlugin::serviceOwnerChanged(const QString& serviceName, const QString& oldOwner, const QString& newOwner)
 {
-    if (service.startsWith(QLatin1String("org.mpris.MediaPlayer2"))) {
-        addPlayer(service);
+    if (!serviceName.startsWith(QLatin1String("org.mpris.MediaPlayer2.")))
+        return;
+
+    if (!oldOwner.isEmpty()) {
+        qCDebug(KDECONNECT_PLUGIN_MPRIS) << "MPRIS service" << serviceName << "just went offline";
+        removePlayer(serviceName);
     }
-}
 
-void MprisControlPlugin::removeService(const QString& service)
-{
-    if (service.startsWith(QLatin1String("org.mpris.MediaPlayer2"))) {
-        removePlayer(service);
+    if (!newOwner.isEmpty()) {
+        qCDebug(KDECONNECT_PLUGIN_MPRIS) << "MPRIS service" << serviceName << "just came online";
+        addPlayer(serviceName);
     }
 }
 
diff --git a/plugins/mpriscontrol/mpriscontrolplugin.h b/plugins/mpriscontrol/mpriscontrolplugin.h
index e7839eb..f61438a 100644
--- a/plugins/mpriscontrol/mpriscontrolplugin.h
+++ b/plugins/mpriscontrol/mpriscontrolplugin.h
@@ -49,9 +49,7 @@ private Q_SLOTS:
     void seeked(qlonglong);
 
 private:
-    void addService(const QString& service);
-    void removeService(const QString& service);
-
+    void serviceOwnerChanged(const QString& serviceName, const QString& oldOwner, const QString& newOwner);
     void addPlayer(const QString& ifaceName);
     void removePlayer(const QString& ifaceName);
     void sendPlayerList();

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list