summaryrefslogtreecommitdiff
path: root/saltoqd/musicmanager.h
blob: 5bae89bf10be4a246d45ed9a98e4a9b0f7ace161 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef MUSICMANAGER_H
#define MUSICMANAGER_H

#include <QtDBus/QDBusServiceWatcher>
#include <QtDBus/QDBusContext>
#include "toqmanager.h"

class MusicManager : public QObject, public ToqManager::EndpointHandler, protected QDBusContext
{
	Q_OBJECT
public:
	explicit MusicManager(ToqManager *toq);

	void handleMessage(const ToqConnection::Message &msg) Q_DECL_OVERRIDE;

private:
	void handleGetPlayerStatusMessage(const ToqConnection::Message &msg);

	void switchToService(const QString &service);
	void fetchMetadataFromService();
	void sendCurrentMprisMetadata();
	void fillWithMetadata(QJsonObject &obj);
	void callMprisMethod(const QString &method);

private slots:
	void handleMprisServiceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner);
	void handleMprisPropertiesChanged(const QString &interface, const QMap<QString,QVariant> &changed, const QStringList &invalidated);

private:
	ToqManager *_toq;
	QDBusServiceWatcher *_watcher;
	QString _curService;
	QVariantMap _curMetadata;
	QString _curPlaybackStatus;
	bool _isPlayerVisible;
};


#endif // MUSICMANAGER_H