From 60989e52b3f3bc0a95d3e61bd8e59fa4d9b7ab83 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sun, 26 Nov 2023 01:10:36 -0500 Subject: The 2 year constipation. (mpris plugin) Probably buggy as hell. --- mpris-plugin/qmpriswrapper.hpp | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 mpris-plugin/qmpriswrapper.hpp (limited to 'mpris-plugin/qmpriswrapper.hpp') diff --git a/mpris-plugin/qmpriswrapper.hpp b/mpris-plugin/qmpriswrapper.hpp new file mode 100644 index 0000000..54186d2 --- /dev/null +++ b/mpris-plugin/qmpriswrapper.hpp @@ -0,0 +1,53 @@ +#ifndef QMPRISWRAPPER_HPP +#define QMPRISWRAPPER_HPP + +#include + +class QMPrisMediaPlayer2; +class QMPrisPlayer; +class QMPrisTrackList; +class qmpPluginAPI; + +class QMPrisWrapper : public QObject +{ + Q_OBJECT +public: + ~QMPrisWrapper(); + + template + static QMPrisWrapper *create(QString serviceSuffix, qmpPluginAPI *api, QObject *parent = nullptr) + { + static_assert(std::is_base_of(), "TP must be a subclass of QMPrisPlayer"); + static_assert(std::is_base_of(), "TM must be a subclass of QMPrisMediaPlayer2"); + static_assert(std::is_base_of(), "TT must be a subclass of QMPrisTrackList"); + + auto w = new QMPrisWrapper(serviceSuffix, api, parent); + auto p = new TP(api, w); + auto t = new TT(api, w); + auto mp = new TM(api, w); + w->player = p; + w->tracklist = t; + w->mediaplayer = mp; + w->post_creation(); + + return w; + } + + static void notifyPropertyChange(QString intf, QString prop, QVariant val); + +private: + explicit QMPrisWrapper(QString serviceSuffix, qmpPluginAPI *_api, QObject *parent = nullptr); + void post_creation(); + QMPrisPlayer *player = nullptr; + QMPrisMediaPlayer2 *mediaplayer = nullptr; + QMPrisTrackList *tracklist = nullptr; + QString svcsuffix; + qmpPluginAPI *api; + + const QString PLAYER_INTERFACE = "org.mpris.MediaPlayer2.Player"; + + friend class QMPrisPlayer; + friend class QMPrisMediaPlayer2; +}; + +#endif // QMPRISWRAPPER_HPP -- cgit v1.2.3