LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Preferences.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2008-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef PREFERENCES_H
23 #define PREFERENCES_H
24 
25 #include "Common.h"
26 
27 #include <LocalePreferences.h>
28 #include <string>
29 #include <lunaservice.h>
30 
31 #include "Mutex.h"
32 #include "CustomEvents.h"
33 
34 #include <QObject>
35 
36 class Preferences : public QObject
37 {
38  Q_OBJECT
39 
40 public:
41 
42  static Preferences* instance();
43 
44  /*
45  * MT safe
46  */
47  uint32_t lockTimeout() const;
48  void setLockTimeout(uint32_t timeout);
49 
50  std::string getCurrentRingtone() { return m_currentRingtoneFile;}
51  std::string getCurrentAlerttone() { return m_currentAlerttoneFile;}
52  std::string getCurrentNotificationtone() { return m_currentNotificationtoneFile;}
53 
54  bool showAlertsWhenLocked() const { return m_showAlertsWhenLocked; }
55  bool ledThrobberEnabled() const { return m_ledThrobberEnabled; }
56  bool playFeedbackSounds() const { return m_playFeedbackSounds; }
57 
58  bool sysUiNoHomeButtonMode() const { return m_sysUiNoHomeButtonMode; }
59  bool sysUiEnableNextPrevGestures() const { return m_sysUiEnableNextPrevGestures; }
60 
61  bool imeEnabled() const { return m_imeEnabled; }
62  bool pinyinEnabled() const { return m_pinyinEnabled; }
63  bool hwrEnabled() const { return m_hwrEnabled; }
64 
65  bool getPinyinPassthrough() const { return m_pinyinPassthrough; }
66  void setPinyinPassthrough(bool enabled) { m_pinyinPassthrough = enabled; }
67 
68  bool getVoiceDialEnabled() const { return m_enableVoiceDial; }
69 
70  static uint32_t roundLockTimeout(uint32_t unrounded);
71 
72  bool airplaneMode() const;
73  bool setAirplaneMode(bool on);
74  bool wifiState() const;
75  bool saveWifiState (bool on);
76  bool bluetoothState() const;
77  bool saveBluetoothState (bool on);
78 
79  bool show3GForEvdo() const { return m_show3GForEvdo; }
80  bool useDualRSSI() const { return m_dualRSSI; }
81  bool hideWANAlert() const { return m_hideWANAlert; }
82  std::string roamingIndicator() const { return m_roamingIndicator; }
83  OrientationEvent::Orientation rotationLock() const;
84  bool setRotationLockPref(OrientationEvent::Orientation lockedOrientation);
85  bool isMuteOn() const;
86  bool setMuteSoundPref(bool mute);
87  bool isAlsEnabled() const;
88 
89  bool setStringPreference(const char * keyName, const char * value);
90 
91 Q_SIGNALS:
92 
93  // Signals
94  void signalWallPaperChanged(const char* filePath);
95  void signalDockModeWallPaperChanged(const char* filePath);
96  void signalSetLockTimeout(uint32_t timeout);
97  void signalAirplaneModeChanged(bool enabled);
99  void signalDualRssiEnabled();
100  void signalVoiceDialSettingChanged(bool v);
101  void signalRotationLockChanged(OrientationEvent::Orientation rotationLock);
102  void signalMuteSoundChanged(bool muteOn);
103  void signalAlsEnabled(bool enable);
104 
105 private:
106 
107  Preferences();
108  ~Preferences();
109 
110  void registerService();
111  void init();
112 
113  static bool serverConnectCallback(LSHandle *sh, LSMessage *message, void *ctx);
114  static bool getPreferencesCallback(LSHandle *sh, LSMessage *message, void *ctx);
115 
116  std::string m_currentRingtoneFile; //path and filename of ringtone
117  std::string m_currentAlerttoneFile; //path and filename of alert tone
118  std::string m_currentNotificationtoneFile; //path and filename of alert tone
119  bool m_showAlertsWhenLocked;
120  bool m_ledThrobberEnabled;
121  bool m_playFeedbackSounds;
122 
123  bool m_sysUiNoHomeButtonMode;
124  bool m_sysUiEnableNextPrevGestures;
125 
126  bool m_imeEnabled;
127  bool m_pinyinEnabled;
128  bool m_hwrEnabled;
129  bool m_pinyinPassthrough;
130 
131  std::string m_roamingIndicator;
132  bool m_hideWANAlert;
133  bool m_dualRSSI;
134  bool m_airplaneMode;
135  bool m_wifiOn;
136  bool m_bluetoothOn;
137  bool m_show3GForEvdo;
138  bool m_enableVoiceDial;
139  uint32_t m_lockTimeout;
140  OrientationEvent::Orientation m_rotationLock;
141  bool m_muteOn;
142  bool m_enableALS;
143 
144  mutable Mutex m_mutex;
145  LSHandle* m_lsHandle;
146  LSMessageToken m_serverStatusToken;
147 };
148 
149 #endif /* PREFERENCES_H */