/
profilecontrol.h
231 lines (189 loc) · 8.56 KB
/
profilecontrol.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
* Copyright (C) 2013 Jolla Ltd. <pekka.vuorela@jollamobile.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#ifndef PROFILECONTROL_H
#define PROFILECONTROL_H
#include <QObject>
#include <QString>
#include <QStringList>
#include <systemsettingsglobal.h>
class SYSTEMSETTINGS_EXPORT ProfileControl: public QObject
{
Q_OBJECT
Q_ENUMS(VibraMode)
Q_PROPERTY(QString profile READ profile WRITE setProfile NOTIFY profileChanged)
Q_PROPERTY(int ringerVolume READ ringerVolume WRITE setRingerVolume NOTIFY ringerVolumeChanged())
Q_PROPERTY(int vibraMode READ vibraMode WRITE setVibraMode NOTIFY vibraModeChanged())
Q_PROPERTY(int systemSoundLevel READ systemSoundLevel WRITE setSystemSoundLevel NOTIFY systemSoundLevelChanged)
Q_PROPERTY(int touchscreenToneLevel READ touchscreenToneLevel WRITE setTouchscreenToneLevel NOTIFY touchscreenToneLevelChanged)
Q_PROPERTY(int touchscreenVibrationLevel READ touchscreenVibrationLevel WRITE setTouchscreenVibrationLevel NOTIFY touchscreenVibrationLevelChanged)
Q_PROPERTY(QString ringerToneFile READ ringerToneFile WRITE setRingerToneFile NOTIFY ringerToneFileChanged)
Q_PROPERTY(QString messageToneFile READ messageToneFile WRITE setMessageToneFile NOTIFY messageToneFileChanged)
Q_PROPERTY(QString chatToneFile READ chatToneFile WRITE setChatToneFile NOTIFY chatToneFileChanged)
Q_PROPERTY(QString mailToneFile READ mailToneFile WRITE setMailToneFile NOTIFY mailToneFileChanged)
Q_PROPERTY(QString internetCallToneFile READ internetCallToneFile WRITE setInternetCallToneFile NOTIFY internetCallToneFileChanged)
Q_PROPERTY(QString calendarToneFile READ calendarToneFile WRITE setCalendarToneFile NOTIFY calendarToneFileChanged)
Q_PROPERTY(QString clockAlarmToneFile READ clockAlarmToneFile WRITE setClockAlarmToneFile NOTIFY clockAlarmToneFileChanged)
Q_PROPERTY(bool ringerToneEnabled READ ringerToneEnabled WRITE setRingerToneEnabled NOTIFY ringerToneEnabledChanged)
Q_PROPERTY(bool messageToneEnabled READ messageToneEnabled WRITE setMessageToneEnabled NOTIFY messageToneEnabledChanged)
Q_PROPERTY(bool chatToneEnabled READ chatToneEnabled WRITE setChatToneEnabled NOTIFY chatToneEnabledChanged)
Q_PROPERTY(bool mailToneEnabled READ mailToneEnabled WRITE setMailToneEnabled NOTIFY mailToneEnabledChanged)
Q_PROPERTY(bool internetCallToneEnabled READ internetCallToneEnabled WRITE setInternetCallToneEnabled NOTIFY internetCallToneEnabledChanged)
Q_PROPERTY(bool calendarToneEnabled READ calendarToneEnabled WRITE setCalendarToneEnabled NOTIFY calendarToneEnabledChanged)
Q_PROPERTY(bool clockAlarmToneEnabled READ clockAlarmToneEnabled WRITE setClockAlarmToneEnabled NOTIFY clockAlarmToneEnabledChanged)
public:
enum VibraMode {
VibraAlways,
VibraSilent,
VibraNormal,
VibraNever
};
/*!
* Register the callback functions with libprofile and
* activate profile change tracking.
*
* \param parent the parent object
*/
ProfileControl(QObject *parent = 0);
/*!
* Unregisters the callback functions from libprofile and
* deactivates profile change tracking.
*/
virtual ~ProfileControl();
/*!
* Returns the name of the current profile.
*
* \return the current profile
*/
QString profile();
/*!
* Sets the current profile.
*
* \param profile the name of the profile to set.
*/
void setProfile(const QString &profile);
int ringerVolume() const;
void setRingerVolume(int volume);
int vibraMode() const;
void setVibraMode(int mode);
int systemSoundLevel();
void setSystemSoundLevel(int level);
int touchscreenToneLevel();
void setTouchscreenToneLevel(int level);
int touchscreenVibrationLevel();
void setTouchscreenVibrationLevel(int level);
QString ringerToneFile();
void setRingerToneFile(const QString &filename);
int ringerToneVolume();
void setRingerToneVolume(int volume);
QString messageToneFile();
void setMessageToneFile(const QString &filename);
QString chatToneFile();
void setChatToneFile(const QString &filename);
QString mailToneFile();
void setMailToneFile(const QString &filename);
QString internetCallToneFile();
void setInternetCallToneFile(const QString &filename);
QString calendarToneFile();
void setCalendarToneFile(const QString &filename);
QString clockAlarmToneFile();
void setClockAlarmToneFile(const QString &filename);
bool ringerToneEnabled();
void setRingerToneEnabled(bool enabled);
bool messageToneEnabled();
void setMessageToneEnabled(bool enabled);
bool chatToneEnabled();
void setChatToneEnabled(bool enabled);
bool mailToneEnabled();
void setMailToneEnabled(bool enabled);
bool internetCallToneEnabled();
void setInternetCallToneEnabled(bool enabled);
bool calendarToneEnabled();
void setCalendarToneEnabled(bool enabled);
bool clockAlarmToneEnabled();
void setClockAlarmToneEnabled(bool enabled);
signals:
/*!
* Signal that the profile has changed.
*
* \param profile The profile that has been selected as the current profile
*/
void profileChanged(const QString &profile);
void ringerVolumeChanged();
void vibraModeChanged();
void systemSoundLevelChanged();
void touchscreenToneLevelChanged();
void touchscreenVibrationLevelChanged();
void ringerToneFileChanged();
void messageToneFileChanged();
void messageToneVolumeChanged();
void internetCallToneFileChanged();
void chatToneFileChanged();
void mailToneFileChanged();
void calendarToneFileChanged();
void clockAlarmToneFileChanged();
void ringerToneEnabledChanged();
void messageToneEnabledChanged();
void chatToneEnabledChanged();
void mailToneEnabledChanged();
void internetCallToneEnabledChanged();
void calendarToneEnabledChanged();
void clockAlarmToneEnabledChanged();
private:
static int s_instanceCounter;
QString m_profile;
int m_ringerVolume;
bool m_vibraInGeneral;
bool m_vibraInSilent;
int m_systemSoundLevel;
int m_touchscreenToneLevel;
int m_touchscreenVibrationLevel;
QString m_ringerToneFile;
QString m_messageToneFile;
QString m_internetCallToneFile;
QString m_chatToneFile;
QString m_mailToneFile;
QString m_calendarToneFile;
QString m_clockAlarmToneFile;
int m_ringerToneEnabled;
int m_messageToneEnabled;
int m_chatToneEnabled;
int m_mailToneEnabled;
int m_internetCallToneEnabled;
int m_calendarToneEnabled;
int m_clockAlarmToneEnabled;
//! libprofile callback for profile changes
static void currentProfileChangedCallback(const char *profile, ProfileControl *profileControl);
//! libprofile callback for property changes
static void updateStateCallBackTrampoline(const char *profile, const char *key, const char *val, const char *type,
ProfileControl *profileControl);
void updateStateCallBack(const char *profile, const char *key, const char *val, const char *type);
};
#endif