File indexing completed on 2024-03-24 04:59:49
0001 /** 0002 * SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 0011 #include <core/kdeconnectplugin.h> 0012 0013 #include "mprisremoteplayer.h" 0014 0015 #define PACKET_TYPE_MPRIS_REQUEST QStringLiteral("kdeconnect.mpris.request") 0016 #define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris") 0017 0018 class MprisRemotePlugin : public KdeConnectPlugin 0019 { 0020 Q_OBJECT 0021 Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.mprisremote") 0022 Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY propertiesChanged) 0023 Q_PROPERTY(int length READ length NOTIFY propertiesChanged) 0024 Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY propertiesChanged) 0025 Q_PROPERTY(int position READ position WRITE setPosition NOTIFY propertiesChanged) 0026 Q_PROPERTY(QStringList playerList READ playerList NOTIFY propertiesChanged) 0027 Q_PROPERTY(QString player READ player WRITE setPlayer) 0028 Q_PROPERTY(QString title READ title NOTIFY propertiesChanged) 0029 Q_PROPERTY(QString artist READ artist NOTIFY propertiesChanged) 0030 Q_PROPERTY(QString album READ album NOTIFY propertiesChanged) 0031 Q_PROPERTY(bool canSeek READ canSeek NOTIFY propertiesChanged) 0032 0033 public: 0034 using KdeConnectPlugin::KdeConnectPlugin; 0035 0036 long position() const; 0037 int volume() const; 0038 int length() const; 0039 bool isPlaying() const; 0040 QStringList playerList() const; 0041 QString player() const; 0042 QString title() const; 0043 QString artist() const; 0044 QString album() const; 0045 bool canSeek() const; 0046 0047 void setVolume(int volume); 0048 void setPosition(int position); 0049 void setPlayer(const QString &player); 0050 0051 void receivePacket(const NetworkPacket &np) override; 0052 QString dbusPath() const override; 0053 0054 Q_SCRIPTABLE void seek(int offset) const; 0055 Q_SCRIPTABLE void requestPlayerList(); 0056 Q_SCRIPTABLE void sendAction(const QString &action); 0057 0058 Q_SIGNALS: 0059 Q_SCRIPTABLE void propertiesChanged(); 0060 0061 private: 0062 void requestPlayerStatus(const QString &player); 0063 0064 QString m_currentPlayer; 0065 QMap<QString, MprisRemotePlayer *> m_players; 0066 };