Merge branch 'stable'

This commit is contained in:
David Edmundson 2015-09-11 11:29:31 +02:00
commit 25944356fc
2 changed files with 22 additions and 7 deletions

View file

@ -42,21 +42,33 @@ MprisControlPlugin::MprisControlPlugin(QObject* parent, const QVariantList& args
: KdeConnectPlugin(parent, args)
, prevVolume(-1)
{
m_watcher = new QDBusServiceWatcher("org.mpris.MediaPlayer2", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this);
m_watcher = new QDBusServiceWatcher(QString(), QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this);
connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &MprisControlPlugin::addPlayer);
connect(m_watcher, &QDBusServiceWatcher::serviceUnregistered, this, &MprisControlPlugin::removePlayer);
//Add existing interfaces
QStringList interfaces = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
Q_FOREACH (const QString& iface, interfaces) {
if (iface.startsWith("org.mpris.MediaPlayer2")) {
addPlayer(iface);
}
QStringList services = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
Q_FOREACH (const QString& service, services) {
addService(service);
}
}
void MprisControlPlugin::addService(const QString& service)
{
if (service.startsWith(QLatin1String("org.mpris.MediaPlayer2"))) {
addPlayer(service);
}
}
void MprisControlPlugin::removeService(const QString& service)
{
if (service.startsWith(QLatin1String("org.mpris.MediaPlayer2"))) {
removePlayer(service);
}
}
void MprisControlPlugin::addPlayer(const QString& service)
{
QDBusInterface mprisInterface(service, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2");

View file

@ -49,6 +49,9 @@ private Q_SLOTS:
void seeked(qlonglong);
private:
void addService(const QString& service);
void removeService(const QString& service);
void addPlayer(const QString& ifaceName);
void removePlayer(const QString& ifaceName);
void sendPlayerList();