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
|
|
|
*/
|
|
|
|
|
2023-07-21 19:22:59 +01:00
|
|
|
#pragma once
|
2013-07-29 17:43:13 +01:00
|
|
|
|
2015-05-05 00:40:04 +01:00
|
|
|
#include <QDBusServiceWatcher>
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <QHash>
|
2018-03-16 12:44:16 +00:00
|
|
|
#include <QSharedPointer>
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <QString>
|
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:
|
2022-09-10 22:23:52 +01:00
|
|
|
MprisPlayer(const QString &serviceName, const QString &dbusObjectPath, const QDBusConnection &busConnection);
|
2018-03-16 12:44:16 +00:00
|
|
|
MprisPlayer() = delete;
|
|
|
|
|
|
|
|
public:
|
2022-09-10 22:23:52 +01:00
|
|
|
const QString &serviceName() const
|
|
|
|
{
|
|
|
|
return m_serviceName;
|
|
|
|
}
|
|
|
|
OrgFreedesktopDBusPropertiesInterface *propertiesInterface() const
|
|
|
|
{
|
|
|
|
return m_propertiesInterface.data();
|
|
|
|
}
|
|
|
|
OrgMprisMediaPlayer2PlayerInterface *mediaPlayer2PlayerInterface() const
|
|
|
|
{
|
|
|
|
return m_mediaPlayer2PlayerInterface.data();
|
|
|
|
}
|
2018-03-16 12:44:16 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2022-09-10 22:23:52 +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:
|
2022-09-10 22:23:52 +01:00
|
|
|
explicit MprisControlPlugin(QObject *parent, const QVariantList &args);
|
2013-08-13 05:35:58 +01:00
|
|
|
|
2023-07-31 08:25:45 +01:00
|
|
|
void receivePacket(const NetworkPacket &np) override;
|
2013-07-29 17:43:13 +01:00
|
|
|
|
2013-08-10 04:21:55 +01:00
|
|
|
private Q_SLOTS:
|
2022-09-10 22:23:52 +01: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:
|
2022-09-10 22:23:52 +01:00
|
|
|
void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner);
|
|
|
|
void addPlayer(const QString &serviceName);
|
|
|
|
void removePlayer(const QString &serviceName);
|
2013-08-13 05:35:58 +01:00
|
|
|
void sendPlayerList();
|
2022-09-10 22:23:52 +01:00
|
|
|
void mprisPlayerMetadataToNetworkPacket(NetworkPacket &np, const QVariantMap &nowPlayingMap) const;
|
|
|
|
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;
|
2022-09-10 22:23:52 +01:00
|
|
|
QDBusServiceWatcher *m_watcher;
|
2013-07-29 17:43:13 +01:00
|
|
|
};
|