2015-06-18 03:01:01 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
|
2015-06-18 03:01:01 +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
|
2015-06-18 03:01:01 +01:00
|
|
|
*/
|
|
|
|
|
2023-07-21 19:22:59 +01:00
|
|
|
#pragma once
|
2015-06-18 03:01:01 +01:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
#include <core/kdeconnectplugin.h>
|
|
|
|
|
2018-04-27 23:22:45 +01:00
|
|
|
#include "mprisremoteplayer.h"
|
|
|
|
|
2018-03-04 19:48:51 +00:00
|
|
|
#define PACKET_TYPE_MPRIS_REQUEST QStringLiteral("kdeconnect.mpris.request")
|
|
|
|
#define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris")
|
2015-06-18 03:01:01 +01:00
|
|
|
|
2023-07-22 10:37:35 +01:00
|
|
|
class MprisRemotePlugin : public KdeConnectPlugin
|
2015-06-18 03:01:01 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.mprisremote")
|
|
|
|
Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY propertiesChanged)
|
|
|
|
Q_PROPERTY(int length READ length NOTIFY propertiesChanged)
|
|
|
|
Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY propertiesChanged)
|
|
|
|
Q_PROPERTY(int position READ position WRITE setPosition NOTIFY propertiesChanged)
|
|
|
|
Q_PROPERTY(QStringList playerList READ playerList NOTIFY propertiesChanged)
|
|
|
|
Q_PROPERTY(QString player READ player WRITE setPlayer)
|
2018-04-27 23:22:45 +01:00
|
|
|
Q_PROPERTY(QString title READ title NOTIFY propertiesChanged)
|
|
|
|
Q_PROPERTY(QString artist READ artist NOTIFY propertiesChanged)
|
|
|
|
Q_PROPERTY(QString album READ album NOTIFY propertiesChanged)
|
2019-07-17 22:19:53 +01:00
|
|
|
Q_PROPERTY(bool canSeek READ canSeek NOTIFY propertiesChanged)
|
2015-06-18 03:01:01 +01:00
|
|
|
|
|
|
|
public:
|
2023-07-28 09:36:48 +01:00
|
|
|
using KdeConnectPlugin::KdeConnectPlugin;
|
2015-06-18 03:01:01 +01:00
|
|
|
|
|
|
|
long position() const;
|
2018-04-27 23:22:45 +01:00
|
|
|
int volume() const;
|
|
|
|
int length() const;
|
|
|
|
bool isPlaying() const;
|
|
|
|
QStringList playerList() const;
|
|
|
|
QString player() const;
|
|
|
|
QString title() const;
|
|
|
|
QString artist() const;
|
|
|
|
QString album() const;
|
2019-07-17 22:19:53 +01:00
|
|
|
bool canSeek() const;
|
2015-06-18 03:01:01 +01:00
|
|
|
|
|
|
|
void setVolume(int volume);
|
|
|
|
void setPosition(int position);
|
2022-09-10 22:23:52 +01:00
|
|
|
void setPlayer(const QString &player);
|
2015-06-18 03:01:01 +01:00
|
|
|
|
2023-07-31 08:25:45 +01:00
|
|
|
void receivePacket(const NetworkPacket &np) override;
|
2016-12-30 15:38:12 +00:00
|
|
|
QString dbusPath() const override;
|
2015-06-18 03:01:01 +01:00
|
|
|
|
2016-12-30 15:38:12 +00:00
|
|
|
Q_SCRIPTABLE void seek(int offset) const;
|
|
|
|
Q_SCRIPTABLE void requestPlayerList();
|
2022-09-10 22:23:52 +01:00
|
|
|
Q_SCRIPTABLE void sendAction(const QString &action);
|
2015-06-18 03:01:01 +01:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
2018-06-10 00:07:29 +01:00
|
|
|
Q_SCRIPTABLE void propertiesChanged();
|
2015-06-18 03:01:01 +01:00
|
|
|
|
|
|
|
private:
|
2022-09-10 22:23:52 +01:00
|
|
|
void requestPlayerStatus(const QString &player);
|
2015-06-18 03:01:01 +01:00
|
|
|
|
2018-04-27 23:22:45 +01:00
|
|
|
QString m_currentPlayer;
|
2022-09-10 22:23:52 +01:00
|
|
|
QMap<QString, MprisRemotePlayer *> m_players;
|
2015-06-18 03:01:01 +01:00
|
|
|
};
|