[SCM] ktp-kded-integration-module packaging branch, master, updated. debian/15.12.1-2-382-gbd961c2

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:15:30 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-kded-module.git;a=commitdiff;h=5d2f4b9

The following commit has been merged in the master branch:
commit 5d2f4b9923e0fb1516050e295f7499411a8feea5
Author: Alexandr Akulich <akulichalexander at gmail.com>
Date:   Tue Nov 12 10:48:41 2013 +0100

    TelepathyMPRIS: Refactor.
    
    Get rid unnecessary include.
    Extract few string constants to static const string.
    Replace QString::contains() by startsWith() in service prefix matching.
    Rename newMediaPlayer() to watchPlayer() (inspired by unwatchAllPlayers()).
    Rename m_knownPlayers to m_watchedPlayers.
    Move few public slots to private slots or methods.
    
    REVIEW: 113803
---
 telepathy-mpris.cpp | 46 +++++++++++++++++++++++++---------------------
 telepathy-mpris.h   | 15 ++++++---------
 2 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/telepathy-mpris.cpp b/telepathy-mpris.cpp
index 93875fe..a014b51 100644
--- a/telepathy-mpris.cpp
+++ b/telepathy-mpris.cpp
@@ -29,10 +29,14 @@
 #include <KConfigGroup>
 #include <KLocalizedString>
 
-#include <TelepathyQt/AccountSet>
-
 #include <KTp/global-presence.h>
 
+static const QLatin1String dbusInterfaceProperties("org.freedesktop.DBus.Properties");
+
+static const QLatin1String mprisPath("/org/mpris/MediaPlayer2");
+static const QLatin1String mprisServicePrefix("org.mpris.MediaPlayer2");
+static const QLatin1String mprisInterfaceName("org.mpris.MediaPlayer2.Player");
+
 TelepathyMPRIS::TelepathyMPRIS(KTp::GlobalPresence* globalPresence, QObject* parent)
     : TelepathyKDEDModulePlugin(globalPresence, parent),
       m_enabledInConfig(false),
@@ -65,7 +69,7 @@ void TelepathyMPRIS::onPlayerSignalReceived(const QString &interface, const QVar
     }
 
     // this is not the correct property interface, ignore
-    if (interface != QLatin1String("org.mpris.MediaPlayer2.Player")) {
+    if (interface != mprisInterfaceName) {
         return;
     }
 
@@ -102,14 +106,13 @@ void TelepathyMPRIS::serviceNameFetchFinished(QDBusPendingCallWatcher *callWatch
     QStringList mprisServices = reply.value();
 
     Q_FOREACH (const QString &service, mprisServices) {
-        if (!service.contains(QLatin1String("org.mpris.MediaPlayer2"))) {
+        if (!service.startsWith(mprisServicePrefix))
             continue;
-        }
-        newMediaPlayer(service);
-        m_knownPlayers.append(service);
+
+        watchPlayer(service);
     }
 
-    if (m_knownPlayers.isEmpty()) {
+    if (m_watchedPlayers.isEmpty()) {
         kDebug() << "Received empty players list while active, deactivating (player quit)";
         m_lastReceivedMetadata.clear();
         m_playbackActive = false;
@@ -142,30 +145,31 @@ void TelepathyMPRIS::onSettingsChanged()
     }
 }
 
-void TelepathyMPRIS::newMediaPlayer(const QString &service)
+void TelepathyMPRIS::watchPlayer(const QString &service)
 {
     kDebug() << "Found mpris service:" << service;
     requestPlaybackStatus(service);
 
     //check if we are already watching this service
-    if (!m_knownPlayers.contains(service)) {
+    if (!m_watchedPlayers.contains(service)) {
         QDBusConnection::sessionBus().connect(service,
-                                              QLatin1String("/org/mpris/MediaPlayer2"),
-                                              QLatin1String("org.freedesktop.DBus.Properties"),
+                                              mprisPath,
+                                              dbusInterfaceProperties,
                                               QLatin1String("PropertiesChanged"),
                                               this,
                                               SLOT(onPlayerSignalReceived(QString,QVariantMap,QStringList)) );
+        m_watchedPlayers.append(service);
     }
 }
 
 void TelepathyMPRIS::requestPlaybackStatus(const QString& service)
 {
     QDBusInterface mprisInterface(service,
-                                  QLatin1String("/org/mpris/MediaPlayer2"),
-                                  QLatin1String("org.freedesktop.DBus.Properties"));
+                                  mprisPath,
+                                  dbusInterfaceProperties);
 
     QDBusPendingCall call = mprisInterface.asyncCall(QLatin1String("GetAll"),
-                                                     QLatin1String("org.mpris.MediaPlayer2.Player"));
+                                                     mprisInterfaceName);
 
     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
     connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
@@ -176,11 +180,11 @@ void TelepathyMPRIS::serviceOwnerChanged(const QString &serviceName, const QStri
 {
     Q_UNUSED(oldOwner)
 
-    if (serviceName.contains(QLatin1String("org.mpris.MediaPlayer2"))) {
+    if (serviceName.startsWith(mprisServicePrefix)) {
         if (!newOwner.isEmpty()) {
             //if we have newOwner, we have new player registered at dbus
             kDebug() << "New player appeared on dbus, connecting...";
-            newMediaPlayer(serviceName);
+            watchPlayer(serviceName);
         } else if (newOwner.isEmpty()) {
             //if there's no owner, the player quit, look if there are any other players
             kDebug() << "Player disappeared from dbus, looking for other players...";
@@ -296,14 +300,14 @@ void TelepathyMPRIS::activatePlugin(bool enabled)
 void TelepathyMPRIS::unwatchAllPlayers()
 {
     // disconnect all old player to avoid double connection
-    Q_FOREACH (const QString &service, m_knownPlayers) {
+    Q_FOREACH (const QString &service, m_watchedPlayers) {
         QDBusConnection::sessionBus().disconnect(service,
-                                                 QLatin1String("/org/mpris/MediaPlayer2"),
-                                                 QLatin1String("org.freedesktop.DBus.Properties"),
+                                                 mprisPath,
+                                                 dbusInterfaceProperties,
                                                  QLatin1String("PropertiesChanged"),
                                                  this,
                                                  SLOT(onPlayerSignalReceived(QString,QVariantMap,QStringList)) );
     }
-    m_knownPlayers.clear();
+    m_watchedPlayers.clear();
 }
 
diff --git a/telepathy-mpris.h b/telepathy-mpris.h
index c223e94..f9469f1 100644
--- a/telepathy-mpris.h
+++ b/telepathy-mpris.h
@@ -22,8 +22,6 @@
 #define TELEPATHY_MPRIS_H
 
 #include "telepathy-kded-module-plugin.h"
-#include <TelepathyQt/Presence>
-#include <TelepathyQt/AccountManager>
 
 class TelepathyMPRIS : public TelepathyKDEDModulePlugin, protected QDBusContext
 {
@@ -36,23 +34,22 @@ public:
     QString pluginName() const;
 
 public Q_SLOTS:
-    void onPlayerSignalReceived(const QString &interface, const QVariantMap &changedProperties, const QStringList &invalidatedProperties);
     void onSettingsChanged();
-    void detectPlayers();
-    void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner);
     void onActivateNowPlaying();
     void onDeactivateNowPlaying();
 
-    void onPlaybackStatusReceived(QDBusPendingCallWatcher *watcher);
-
 Q_SIGNALS:
     void togglePlaybackActive(bool);
 
 private Q_SLOTS:
     void serviceNameFetchFinished(QDBusPendingCallWatcher *callWatcher);
-    void newMediaPlayer(const QString &player);
+    void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner);
+    void onPlaybackStatusReceived(QDBusPendingCallWatcher *watcher);
+    void onPlayerSignalReceived(const QString &interface, const QVariantMap &changedProperties, const QStringList &invalidatedProperties);
 
 private:
+    void detectPlayers();
+    void watchPlayer(const QString &player);
     void requestPlaybackStatus(const QString& service);
     void setPlaybackStatus(const QVariantMap &reply);
     void setTrackToPresence();
@@ -60,7 +57,7 @@ private:
     void unwatchAllPlayers();
 
     bool m_enabledInConfig;
-    QStringList m_knownPlayers;
+    QStringList m_watchedPlayers;
     QString m_nowPlayingText;
 
     QVariantMap m_lastReceivedMetadata;

-- 
ktp-kded-integration-module packaging



More information about the pkg-kde-commits mailing list