summaryrefslogtreecommitdiff
path: root/qmafwwatchlet/qmafwwatchletvolumecontrol.h
blob: 75b313aedea0bb8fb715463b7d284919ca76e24b (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef QMAFWWATCHLETVOLUMECONTROL_H
#define QMAFWWATCHLETVOLUMECONTROL_H

#include <QtCore/QObject>
#include <dbus/dbus.h>

class MainVolumeControlProxy;

namespace sowatch
{

class QMafwWatchletVolumeControl : public QObject
{
	Q_OBJECT
	Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged)
	Q_PROPERTY(int min READ min NOTIFY minChanged)
	Q_PROPERTY(int max READ max NOTIFY maxChanged)

public:
	explicit QMafwWatchletVolumeControl(QObject *parent = 0);
	~QMafwWatchletVolumeControl();

	int volume() const;
	int min() const;
	int max() const;

	void setVolume(int vol);
	
signals:
	void volumeChanged();
	void minChanged();
	void maxChanged();
	
public slots:
	void up();
	void down();

private:
	void _openConnection();
	void _listenForSignal();
	void _fetchValues();
	static void handleFetchReply(DBusPendingCall *pending, void *user_data);
	static DBusHandlerResult handleDBusSignal(DBusConnection *connection, DBusMessage *message, void *user_data);

private:
	DBusConnection *_conn;
	int _curStep;
	int _maxStep;
};

}

#endif // QMAFWWATCHLETVOLUMECONTROL_H