Small clean of subtitles applet code.
[mafwsubrenderer] / qmafw-gst-subtitles-renderer / inc / MafwGstRendererVolume.h
1 #ifndef MAFWGSTRENDERERVOLUME_H
2 #define MAFWGSTRENDERERVOLUME_H
3
4 #include <QObject>
5
6 class DBusConnection;
7 class DBusMessage;
8 class DBusPendingCall;
9 class DBusMessageIter;
10 class DBusPendingCall;
11
12 /**
13  * Provides volume setting, getting and listening functionality using
14  * PulseAudioMainVolume DBus API.
15  */
16 class MafwGstRendererVolume : public QObject
17 {
18     Q_OBJECT
19 public:
20     /**
21      * Constructor
22      */
23     MafwGstRendererVolume();
24     ~MafwGstRendererVolume();
25
26     /**
27      * Get the volume level. Initial volume level is always got via volumeChanged signal.
28      * Before that signal returns always 0.
29      * @return The current volume level. Value is between 0 to 99.
30      */
31     uint getVolume();
32
33     /**
34      * Set the volume level to pulse audio.
35      * @note Volume setting happens asynchronously
36      *       and may wait until dbus connection to pulse audio is ready.
37      * @param The volume level to be set. Valid value range is between 0 to 99.
38      * @return true on success.
39      */
40     bool setVolume (uint value);
41
42 Q_SIGNALS:
43     /**
44      * Signal telling that volume level has been changed.
45      */
46     void volumeChanged(uint newLevel);
47
48 private Q_SLOTS:
49     /** Makes p2p dbus connection to pulse audio. */
50     void connectToPulseAudio();
51
52 private:
53     /**
54      * Starts to listen signal from  PulseAudioMainVolume DBus API
55      */
56     void listenVolumeSignals();
57
58     /**
59      * Get the step configuration asynchronously from PulseAudioMainVolume
60      */
61     void getRestoreEntryForMediaRole();
62
63     /**
64      * Catch signals from PulseAudioMainVolume telling that volume step configuration has been changed
65      */
66     static void handleIncomingMessages( DBusConnection* conn,
67                                         DBusMessage* message,
68                                         MafwGstRendererVolume* self);
69
70     /**
71      * Catch reply callback for step configuration request from PulseAudioMainVolume.
72      */
73     static void getEntryReply(DBusPendingCall *pending, MafwGstRendererVolume *self);
74
75     static void volumeReply(DBusPendingCall *pending, MafwGstRendererVolume *self);
76
77     bool readVolumeFromStruct(DBusMessageIter *iterator);
78
79 private:
80     /** The current volume step, values are between 0, used maximum volume level */
81     uint m_currentVolume;
82
83     /** The volume step which is pending to be set. */
84     uint m_pendingVolumeValue;
85
86     /** The dbus connection object */
87     DBusConnection* m_dbusConnection;
88
89     QString m_objectPath;
90
91     /** The pending call. */
92     DBusPendingCall* m_pendingCall;
93
94
95 };
96
97 #endif // MAFWGSTRENDERERVOLUME_H