Changeset View
Changeset View
Standalone View
Standalone View
plugins/mprisremote/mprisremoteplugin.h
Show All 19 Lines | |||||
20 | 20 | | |||
21 | #ifndef MPRISREMOTEPLUGIN_H | 21 | #ifndef MPRISREMOTEPLUGIN_H | ||
22 | #define MPRISREMOTEPLUGIN_H | 22 | #define MPRISREMOTEPLUGIN_H | ||
23 | 23 | | |||
24 | #include <QObject> | 24 | #include <QObject> | ||
25 | 25 | | |||
26 | #include <core/kdeconnectplugin.h> | 26 | #include <core/kdeconnectplugin.h> | ||
27 | 27 | | |||
28 | #include "mprisremoteplayer.h" | ||||
29 | | ||||
28 | #define PACKET_TYPE_MPRIS_REQUEST QStringLiteral("kdeconnect.mpris.request") | 30 | #define PACKET_TYPE_MPRIS_REQUEST QStringLiteral("kdeconnect.mpris.request") | ||
29 | #define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris") | 31 | #define PACKET_TYPE_MPRIS QStringLiteral("kdeconnect.mpris") | ||
30 | 32 | | |||
31 | class Q_DECL_EXPORT MprisRemotePlugin | 33 | class Q_DECL_EXPORT MprisRemotePlugin | ||
32 | : public KdeConnectPlugin | 34 | : public KdeConnectPlugin | ||
33 | { | 35 | { | ||
34 | Q_OBJECT | 36 | Q_OBJECT | ||
35 | Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.mprisremote") | 37 | Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.mprisremote") | ||
36 | Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY propertiesChanged) | 38 | Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY propertiesChanged) | ||
37 | Q_PROPERTY(int length READ length NOTIFY propertiesChanged) | 39 | Q_PROPERTY(int length READ length NOTIFY propertiesChanged) | ||
38 | Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY propertiesChanged) | 40 | Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY propertiesChanged) | ||
39 | Q_PROPERTY(int position READ position WRITE setPosition NOTIFY propertiesChanged) | 41 | Q_PROPERTY(int position READ position WRITE setPosition NOTIFY propertiesChanged) | ||
40 | Q_PROPERTY(QStringList playerList READ playerList NOTIFY propertiesChanged) | 42 | Q_PROPERTY(QStringList playerList READ playerList NOTIFY propertiesChanged) | ||
41 | Q_PROPERTY(QString player READ player WRITE setPlayer) | 43 | Q_PROPERTY(QString player READ player WRITE setPlayer) | ||
42 | Q_PROPERTY(QString nowPlaying READ nowPlaying NOTIFY propertiesChanged) | 44 | Q_PROPERTY(QString nowPlaying READ nowPlaying NOTIFY propertiesChanged) | ||
45 | Q_PROPERTY(QString title READ title NOTIFY propertiesChanged) | ||||
46 | Q_PROPERTY(QString artist READ artist NOTIFY propertiesChanged) | ||||
47 | Q_PROPERTY(QString album READ album NOTIFY propertiesChanged) | ||||
43 | 48 | | |||
44 | public: | 49 | public: | ||
45 | explicit MprisRemotePlugin(QObject* parent, const QVariantList &args); | 50 | explicit MprisRemotePlugin(QObject* parent, const QVariantList &args); | ||
46 | ~MprisRemotePlugin() override; | 51 | ~MprisRemotePlugin() override; | ||
47 | 52 | | |||
48 | long position() const; | 53 | long position() const; | ||
49 | int volume() const { return m_volume; } | 54 | int volume() const; | ||
50 | int length() const { return m_length; } | 55 | int length() const; | ||
51 | bool isPlaying() const { return m_playing; } | 56 | bool isPlaying() const; | ||
52 | QStringList playerList() const { return m_playerList; } | 57 | QStringList playerList() const; | ||
53 | QString player() const { return m_player; } | 58 | QString player() const; | ||
54 | QString nowPlaying() const { return m_nowPlaying; } | 59 | QString nowPlaying() const; | ||
60 | QString title() const; | ||||
61 | QString artist() const; | ||||
62 | QString album() const; | ||||
55 | 63 | | |||
56 | void setVolume(int volume); | 64 | void setVolume(int volume); | ||
57 | void setPosition(int position); | 65 | void setPosition(int position); | ||
58 | void setPlayer(const QString& player); | 66 | void setPlayer(const QString& player); | ||
59 | 67 | | |||
60 | bool receivePacket(const NetworkPacket& np) override; | 68 | bool receivePacket(const NetworkPacket& np) override; | ||
61 | void connected() override {} | 69 | void connected() override {} | ||
62 | QString dbusPath() const override; | 70 | QString dbusPath() const override; | ||
63 | 71 | | |||
64 | Q_SCRIPTABLE void seek(int offset) const; | 72 | Q_SCRIPTABLE void seek(int offset) const; | ||
65 | Q_SCRIPTABLE void requestPlayerList(); | 73 | Q_SCRIPTABLE void requestPlayerList(); | ||
66 | Q_SCRIPTABLE void sendAction(const QString& action); | 74 | Q_SCRIPTABLE void sendAction(const QString& action); | ||
67 | 75 | | |||
68 | Q_SIGNALS: | 76 | Q_SIGNALS: | ||
69 | Q_SCRIPTABLE void propertiesChanged(); | 77 | Q_SCRIPTABLE void propertiesChanged(); | ||
70 | 78 | | |||
71 | private: | 79 | private: | ||
72 | void requestPlayerStatus(); | 80 | void requestPlayerStatus(); | ||
73 | 81 | | |||
74 | QString m_player; | 82 | QString m_currentPlayer; | ||
75 | bool m_playing; | 83 | QMap<QString, MprisRemotePlayer*> m_players; | ||
76 | QString m_nowPlaying; | | |||
77 | int m_volume; | | |||
78 | long m_length; | | |||
79 | long m_lastPosition; | | |||
80 | qint64 m_lastPositionTime; | | |||
81 | QStringList m_playerList; | | |||
82 | }; | 84 | }; | ||
83 | 85 | | |||
84 | #endif | 86 | #endif |