2013-07-29 17:43:13 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
|
2013-07-29 17:43:13 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2013-07-29 17:43:13 +01:00
|
|
|
*/
|
|
|
|
|
2013-08-13 14:48:02 +01:00
|
|
|
#ifndef MPRISCONTROLPLUGIN_H
|
|
|
|
#define MPRISCONTROLPLUGIN_H
|
2013-07-29 17:43:13 +01:00
|
|
|
|
|
|
|
#include <QString>
|
2013-07-30 19:21:06 +01:00
|
|
|
#include <QHash>
|
2015-05-05 00:40:04 +01:00
|
|
|
#include <QDBusServiceWatcher>
|
2018-03-16 12:44:16 +00:00
|
|
|
#include <QSharedPointer>
|
2013-07-29 17:43:13 +01:00
|
|
|
|
2014-06-14 15:34:00 +01:00
|
|
|
#include <core/kdeconnectplugin.h>
|
2013-08-13 05:35:58 +01:00
|
|
|
|
2018-03-16 12:44:16 +00:00
|
|
|
class OrgFreedesktopDBusPropertiesInterface;
|
|
|
|
class OrgMprisMediaPlayer2PlayerInterface;
|
|
|
|
|
|
|
|
class MprisPlayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MprisPlayer(const QString& serviceName, const QString& dbusObjectPath, const QDBusConnection& busConnection);
|
|
|
|
MprisPlayer() = delete;
|
|
|
|
|
|
|
|
public:
|
|
|
|
const QString& serviceName() const { return m_serviceName; }
|
|
|
|
OrgFreedesktopDBusPropertiesInterface* propertiesInterface() const { return m_propertiesInterface.data(); }
|
|
|
|
OrgMprisMediaPlayer2PlayerInterface* mediaPlayer2PlayerInterface() const { return m_mediaPlayer2PlayerInterface.data(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_serviceName;
|
|
|
|
QSharedPointer<OrgFreedesktopDBusPropertiesInterface> m_propertiesInterface;
|
|
|
|
QSharedPointer<OrgMprisMediaPlayer2PlayerInterface> m_mediaPlayer2PlayerInterface;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-03-04 19:48:51 +00:00
|
|
|
#define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris")
|
2013-10-11 14:19:23 +01:00
|
|
|
|
2013-08-13 05:35:58 +01:00
|
|
|
class MprisControlPlugin
|
|
|
|
: public KdeConnectPlugin
|
2013-07-29 17:43:13 +01:00
|
|
|
{
|
2013-07-30 19:21:06 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2013-07-29 17:43:13 +01:00
|
|
|
public:
|
2017-09-03 20:39:44 +01:00
|
|
|
explicit MprisControlPlugin(QObject* parent, const QVariantList& args);
|
2013-08-13 05:35:58 +01:00
|
|
|
|
2018-03-04 19:48:51 +00:00
|
|
|
bool receivePacket(const NetworkPacket& np) override;
|
2016-06-20 08:05:02 +01:00
|
|
|
void connected() override { }
|
2013-07-29 17:43:13 +01:00
|
|
|
|
2013-08-10 04:21:55 +01:00
|
|
|
private Q_SLOTS:
|
2013-11-18 01:34:34 +00:00
|
|
|
void propertiesChanged(const QString& propertyInterface, const QVariantMap& properties);
|
2014-12-13 22:41:53 +00:00
|
|
|
void seeked(qlonglong);
|
2013-07-30 19:21:06 +01:00
|
|
|
|
|
|
|
private:
|
2016-04-08 00:12:10 +01:00
|
|
|
void serviceOwnerChanged(const QString& serviceName, const QString& oldOwner, const QString& newOwner);
|
2018-03-16 12:44:16 +00:00
|
|
|
void addPlayer(const QString& serviceName);
|
|
|
|
void removePlayer(const QString& serviceName);
|
2013-08-13 05:35:58 +01:00
|
|
|
void sendPlayerList();
|
2018-03-04 19:48:51 +00:00
|
|
|
void mprisPlayerMetadataToNetworkPacket(NetworkPacket& np, const QVariantMap& nowPlayingMap) const;
|
2018-03-04 12:47:29 +00:00
|
|
|
bool sendAlbumArt(const NetworkPacket& np);
|
2013-08-13 14:48:02 +01:00
|
|
|
|
2018-03-16 12:44:16 +00:00
|
|
|
QHash<QString, MprisPlayer> playerList;
|
2013-08-10 04:21:55 +01:00
|
|
|
int prevVolume;
|
2015-05-05 00:40:04 +01:00
|
|
|
QDBusServiceWatcher* m_watcher;
|
2013-07-30 19:21:06 +01:00
|
|
|
|
2013-07-29 17:43:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|