[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasma-workspace/Plasma/5.6] /: use QDBusConnectionInterface::serviceOwnerChanged to watch mpris2
From: Weng Xuetian <wengxt () gmail ! com>
Date: 2016-03-09 19:12:10
Message-ID: E1adjWk-0005Ve-PJ () scm ! kde ! org
[Download RAW message or body]
Git commit 70326bdbed9b3e2f74990e170cb400f1e6769c8d by Weng Xuetian.
Committed on 09/03/2016 at 19:02.
Pushed by xuetianweng into branch 'Plasma/5.6'.
use QDBusConnectionInterface::serviceOwnerChanged to watch mpris2
Current usage of QDBusServiceWatcher is not a intended feature and will
be removed in Qt 5.6 (see https://bugreports.qt.io/browse/QTBUG-51683 ).
Use the old fashioned QDBusConnectionInterface::serviceOwnerChanged to
implement the same thing.
REVIEW: 127285
M +9 -8 applets/systemtray/plugin/protocols/plasmoid/plasmoidprotocol.cpp
M +3 -2 applets/systemtray/plugin/protocols/plasmoid/plasmoidprotocol.h
M +1 -5 dataengines/mpris2/mpris2engine.cpp
http://commits.kde.org/plasma-workspace/70326bdbed9b3e2f74990e170cb400f1e6769c8d
diff --git a/applets/systemtray/plugin/protocols/plasmoid/plasmoidprotocol.cpp \
b/applets/systemtray/plugin/protocols/plasmoid/plasmoidprotocol.cpp index \
94c3efc..1631687 100644
--- a/applets/systemtray/plugin/protocols/plasmoid/plasmoidprotocol.cpp
+++ b/applets/systemtray/plugin/protocols/plasmoid/plasmoidprotocol.cpp
@@ -38,7 +38,6 @@
#include <QDBusConnection>
#include <QDBusConnectionInterface>
-#include <QDBusServiceWatcher>
#include <QDBusPendingCallWatcher>
#include <QRegExp>
@@ -306,15 +305,17 @@ void \
PlasmoidProtocol::serviceNameFetchFinished(QDBusPendingCallWatcher* watcher // not \
just compare them
// This makes mpris work, since it wants to match \
org.mpris.MediaPlayer2.dragonplayer // against org.mpris.MediaPlayer2
- QDBusServiceWatcher *serviceWatcher = new QDBusServiceWatcher(QString(),
- connection,
- \
QDBusServiceWatcher::WatchForOwnerChange,
- this);
- connect(serviceWatcher, &QDBusServiceWatcher::serviceRegistered, this, \
&PlasmoidProtocol::serviceRegistered);
- connect(serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, this, \
&PlasmoidProtocol::serviceUnregistered); + connect(connection.interface(), \
&QDBusConnectionInterface::serviceOwnerChanged, this, \
&PlasmoidProtocol::serviceOwnerChanged); }
-
+void PlasmoidProtocol::serviceOwnerChanged(const QString &serviceName, const QString \
&oldOwner, const QString &newOwner) +{
+ if (oldOwner.isEmpty()) {
+ serviceRegistered(serviceName);
+ } else if (newOwner.isEmpty()) {
+ serviceUnregistered(serviceName);
+ }
+}
void PlasmoidProtocol::serviceRegistered(const QString &service)
{
diff --git a/applets/systemtray/plugin/protocols/plasmoid/plasmoidprotocol.h \
b/applets/systemtray/plugin/protocols/plasmoid/plasmoidprotocol.h index \
9e59501..60801ca 100644
--- a/applets/systemtray/plugin/protocols/plasmoid/plasmoidprotocol.h
+++ b/applets/systemtray/plugin/protocols/plasmoid/plasmoidprotocol.h
@@ -62,10 +62,11 @@ protected Q_SLOTS:
private Q_SLOTS:
void serviceNameFetchFinished(QDBusPendingCallWatcher* watcher, const \
QDBusConnection &connection);
- void serviceRegistered(const QString &service);
- void serviceUnregistered(const QString &service);
+ void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, \
const QString &newOwner);
private:
+ void serviceRegistered(const QString &service);
+ void serviceUnregistered(const QString &service);
void initDBusActivatables();
void newDBusActivatableTask(const QString &pluginName, const QString \
&dbusService); QHash<QString, PlasmoidTask*> m_tasks;
diff --git a/dataengines/mpris2/mpris2engine.cpp \
b/dataengines/mpris2/mpris2engine.cpp index 064ca60..0ed6234 100644
--- a/dataengines/mpris2/mpris2engine.cpp
+++ b/dataengines/mpris2/mpris2engine.cpp
@@ -20,7 +20,6 @@
#include <QDBusConnection>
#include <QDBusConnectionInterface>
-#include <QDBusServiceWatcher>
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>
#include <QStringList>
@@ -39,10 +38,7 @@ Mpris2Engine::Mpris2Engine(QObject* parent,
{
Q_UNUSED(args)
- QDBusServiceWatcher *serviceWatcher = new QDBusServiceWatcher(
- QString(), QDBusConnection::sessionBus(),
- QDBusServiceWatcher::WatchForOwnerChange, this);
- connect(serviceWatcher, &QDBusServiceWatcher::serviceOwnerChanged,
+ connect(QDBusConnection::sessionBus().interface(), \
&QDBusConnectionInterface::serviceOwnerChanged, this, \
&Mpris2Engine::serviceOwnerChanged);
QDBusPendingCall async = \
QDBusConnection::sessionBus().interface()->asyncCall(QStringLiteral("ListNames"));
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic