|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <hbdevicedialogsymbian.h> |
|
19 #include <hbsymbianvariant.h> |
|
20 #include <coreapplicationuisdomainpskeys.h> |
|
21 #include "hbdevicepowermenusymbian.h" |
|
22 |
|
23 |
|
24 //These Keys will be used in CHbSymbianVariantMap |
|
25 //Donot Change these strings |
|
26 _LIT(KVolumeLevel, "VolumeLevel"); |
|
27 _LIT(KSilenceLatchOn, "SilenceLatchOn"); //Used to latch silencebutton |
|
28 _LIT(KCypherOff, "CypherOff"); //used to poweroffButtonEnabled/Disabled |
|
29 _LIT(KVibrationEnable, "VibrationEnable"); |
|
30 _LIT(KOfflineEnable, "OfflineEnable"); |
|
31 _LIT(KShutDown, "ShutDown"); |
|
32 |
|
33 //used to load plugin |
|
34 _LIT(KPluginIdentifier, "com.nokia.hb.devicepowermenu/1.0"); |
|
35 |
|
36 |
|
37 NONSHARABLE_CLASS(CHbDevicePowerMenuPrivate) : public CBase, public MHbDeviceDialogObserver |
|
38 { |
|
39 public: |
|
40 static CHbDevicePowerMenuPrivate* NewL(CHbDevicePowerMenuSymbian* aDialog); |
|
41 virtual ~CHbDevicePowerMenuPrivate(); |
|
42 |
|
43 void ShowL(); |
|
44 void AddVariantL(const TDesC& aKey, const TAny* aData, CHbSymbianVariant::TType aDataType); |
|
45 |
|
46 //Set Methods |
|
47 void SetVolume(TInt aVolume); |
|
48 void SetSilenceMode(TBool aEnable); |
|
49 void SetOfflineMode(TBool aChecked); |
|
50 void SetVibrationEnabled(TBool aEnable); |
|
51 void SetPowerOffEnabled(TBool aEnable); |
|
52 |
|
53 public: |
|
54 // MHbDeviceDialogObserver |
|
55 void DataReceived(CHbSymbianVariantMap& aData); |
|
56 void DeviceDialogClosed(TInt aCompletionCode); |
|
57 |
|
58 private: |
|
59 CHbDevicePowerMenuPrivate(); |
|
60 void ConstructL(CHbDevicePowerMenuSymbian* aDialog); |
|
61 |
|
62 private: |
|
63 //symbian FW client intreface to load Qt.plugin |
|
64 CHbDeviceDialogSymbian* iDeviceDialog; |
|
65 //Parameter for loading qt.plugin |
|
66 CHbSymbianVariantMap* iVariantMap; |
|
67 //Symbian client interface for Powermenu |
|
68 CHbDevicePowerMenuSymbian* iPowerMenuManager; |
|
69 |
|
70 //Variants used in VariantMap |
|
71 TInt iVolumeLevel; //Volume level ranges 1 to 10 |
|
72 TBool iSilenceLatchOn; //Silence Enabled or Disbaled |
|
73 TBool iVibrationEnable; //Master Vibarate enabled/Disabled |
|
74 TBool iOfflineEnable; //Oflline Mode enabled or Disabled |
|
75 TBool iCypherOff; //Encryption/Decryption ON/OFF |
|
76 }; |
|
77 |
|
78 /** |
|
79 * Create an object of CHbDevicePowerMenuPrivate |
|
80 */ |
|
81 CHbDevicePowerMenuPrivate* CHbDevicePowerMenuPrivate::NewL(CHbDevicePowerMenuSymbian* aDialog) |
|
82 { |
|
83 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::NewL: START") ) ); |
|
84 CHbDevicePowerMenuPrivate* self = new (ELeave) CHbDevicePowerMenuPrivate(); |
|
85 CleanupStack::PushL(self); |
|
86 self->ConstructL(aDialog); |
|
87 CleanupStack::Pop(self); |
|
88 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::NewL: END") ) ); |
|
89 return self; |
|
90 } |
|
91 |
|
92 /** |
|
93 * Constructor |
|
94 */ |
|
95 CHbDevicePowerMenuPrivate::CHbDevicePowerMenuPrivate() |
|
96 { |
|
97 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::Constructor") ) ); |
|
98 //Do nothing |
|
99 } |
|
100 |
|
101 /** |
|
102 * Destructor |
|
103 */ |
|
104 CHbDevicePowerMenuPrivate::~CHbDevicePowerMenuPrivate() |
|
105 { |
|
106 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::Destructor: START") ) ); |
|
107 delete iDeviceDialog; |
|
108 delete iVariantMap; |
|
109 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::Destructor: END") ) ); |
|
110 } |
|
111 |
|
112 /** |
|
113 * Constrcuts all its member variables |
|
114 */ |
|
115 void CHbDevicePowerMenuPrivate::ConstructL(CHbDevicePowerMenuSymbian* aDialog) |
|
116 { |
|
117 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::ConstructL: START") ) ); |
|
118 iPowerMenuManager = aDialog; |
|
119 iDeviceDialog = CHbDeviceDialogSymbian::NewL(); |
|
120 iVariantMap = CHbSymbianVariantMap::NewL(); |
|
121 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::ConstructL: END") ) ); |
|
122 } |
|
123 |
|
124 /** |
|
125 * Builds all parameters required for showing the PowerMenu Dialog. |
|
126 * Loads the required powermenu plugin and calls show on DeviceDialog. |
|
127 * This Displays the Customized PowerMenu Widget. |
|
128 */ |
|
129 void CHbDevicePowerMenuPrivate::ShowL() |
|
130 { |
|
131 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::ShowL: START") ) ); |
|
132 AddVariantL(KVolumeLevel, &iVolumeLevel, CHbSymbianVariant::EInt); |
|
133 AddVariantL(KSilenceLatchOn, &iSilenceLatchOn, CHbSymbianVariant::EBool); |
|
134 AddVariantL(KVibrationEnable, &iVibrationEnable, CHbSymbianVariant::EBool); |
|
135 AddVariantL(KOfflineEnable, &iOfflineEnable, CHbSymbianVariant::EBool); |
|
136 AddVariantL(KCypherOff, &iCypherOff, CHbSymbianVariant::EBool); |
|
137 //No shutdown varinat will be added to showL |
|
138 User::LeaveIfError(iDeviceDialog->Show(KPluginIdentifier, *iVariantMap, this)); |
|
139 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::ShowL: END") ) ); |
|
140 } |
|
141 |
|
142 /** |
|
143 * Sets Volume to aVolume |
|
144 */ |
|
145 void CHbDevicePowerMenuPrivate::SetVolume(TInt aVolume) |
|
146 { |
|
147 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetVolume: START") ) ); |
|
148 iVolumeLevel = aVolume; |
|
149 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetVolume: END") ) ); |
|
150 } |
|
151 |
|
152 /** |
|
153 * Sets SilenceMode to Enable/Disable |
|
154 */ |
|
155 void CHbDevicePowerMenuPrivate::SetSilenceMode(TBool aEnable) |
|
156 { |
|
157 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetSilenceMode: START") ) ); |
|
158 iSilenceLatchOn = aEnable; |
|
159 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetSilenceMode: END") ) ); |
|
160 } |
|
161 |
|
162 /** |
|
163 * Sets OfflineMode to Checked/UnChecked |
|
164 */ |
|
165 void CHbDevicePowerMenuPrivate::SetOfflineMode(TBool aChecked) |
|
166 { |
|
167 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetOfflineMode: START") ) ); |
|
168 iOfflineEnable = aChecked; |
|
169 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetOfflineMode: END") ) ); |
|
170 } |
|
171 |
|
172 /** |
|
173 * Sets VibrationEnabled to Checked/UnChecked |
|
174 */ |
|
175 void CHbDevicePowerMenuPrivate::SetVibrationEnabled(TBool aChecked) |
|
176 { |
|
177 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetVibrationEnabled: START") ) ); |
|
178 iVibrationEnable = aChecked; |
|
179 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetVibrationEnabled: END") ) ); |
|
180 } |
|
181 |
|
182 /** |
|
183 * Sets PowerOffEnabled to Enable/Disable |
|
184 */ |
|
185 void CHbDevicePowerMenuPrivate::SetPowerOffEnabled(TBool aEnable) |
|
186 { |
|
187 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetPowerOffEnabled: START") ) ); |
|
188 iCypherOff = aEnable; |
|
189 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::SetPowerOffEnabled: END") ) ); |
|
190 } |
|
191 |
|
192 /** |
|
193 * Data received from HBDeviceDialog will hit by emit deviceDialogData in plugin |
|
194 * The values received from UI will set to ControlPanel. |
|
195 */ |
|
196 void CHbDevicePowerMenuPrivate::DataReceived(CHbSymbianVariantMap& aData) |
|
197 { |
|
198 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: START") ) ); |
|
199 // Updates received from the plugin. |
|
200 //1. Volume |
|
201 const CHbSymbianVariant* volumeVariant = aData.Get(KVolumeLevel); |
|
202 if(volumeVariant) |
|
203 { |
|
204 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: volumeVariant::Start") ) ); |
|
205 TInt* volumeValue = volumeVariant->Value<TInt>(); |
|
206 if(volumeValue) |
|
207 { |
|
208 iVolumeLevel = *volumeValue; |
|
209 iPowerMenuManager->iProfileEngine->SetMasterVolumeL( iVolumeLevel ); |
|
210 } |
|
211 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived:volumeVariant::End") ) ); |
|
212 } |
|
213 |
|
214 //2. Silence |
|
215 const CHbSymbianVariant* SilenceVariant = aData.Get(KSilenceLatchOn); |
|
216 if(SilenceVariant) |
|
217 { |
|
218 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: SilenceVariant::Start") ) ); |
|
219 TBool* LatchValue = SilenceVariant->Value<TBool>(); |
|
220 if(LatchValue) |
|
221 { |
|
222 iSilenceLatchOn = *LatchValue; |
|
223 iPowerMenuManager->iProfileEngine->SetSilenceModeL( iSilenceLatchOn );//member in CHbDevicePowerMenuSymbian |
|
224 } |
|
225 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: SilenceVariant::End") ) ); |
|
226 } |
|
227 |
|
228 //3. Vibration |
|
229 const CHbSymbianVariant* VibrationVariant = aData.Get(KVibrationEnable); |
|
230 if(VibrationVariant) |
|
231 { |
|
232 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: VibrationVariant::Start") ) ); |
|
233 TBool* VibrationValue = VibrationVariant->Value<TBool>(); |
|
234 if(VibrationValue) |
|
235 { |
|
236 iVibrationEnable = *VibrationValue; |
|
237 iPowerMenuManager->iProfileEngine->SetMasterVibraL( iVibrationEnable );//member in CHbDevicePowerMenuSymbian |
|
238 } |
|
239 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: VibrationVariant::End") ) ); |
|
240 } |
|
241 |
|
242 //4.Offline |
|
243 const CHbSymbianVariant* OfflineVariant = aData.Get(KOfflineEnable); |
|
244 if(OfflineVariant) |
|
245 { |
|
246 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: OfflineVariant::Start") ) ); |
|
247 TBool* OfflineValue = OfflineVariant->Value<TBool>(); |
|
248 if(OfflineValue) |
|
249 { |
|
250 iOfflineEnable = *OfflineValue; |
|
251 User::LeaveIfError( iPowerMenuManager->iCenrepOffline->Set( KSettingsAirplaneMode, iOfflineEnable ) ); |
|
252 } |
|
253 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: OfflineVariant::End") ) ); |
|
254 } |
|
255 |
|
256 //5.shutdown |
|
257 const CHbSymbianVariant* ShutDownVariant = aData.Get(KShutDown); |
|
258 if(ShutDownVariant) |
|
259 { |
|
260 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: ShutDownVariant::Start") ) ); |
|
261 TBool* ShutDownValue = ShutDownVariant->Value<TBool>(); |
|
262 if(ShutDownValue) |
|
263 { |
|
264 TBool shutDown = *ShutDownValue; |
|
265 if (shutDown) |
|
266 { |
|
267 iPowerMenuManager->iSysApServer.HandleLongPowerKeyPressedL(); |
|
268 } |
|
269 |
|
270 } |
|
271 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: ShutDownVariant::End") ) ); |
|
272 } |
|
273 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DataReceived: END") ) ); |
|
274 return; |
|
275 } |
|
276 |
|
277 /** |
|
278 * DeviceDialogClosed will be executed by the event emit deviceDialogClosed in plugin. |
|
279 * This will be executed when 1. Tap out side the Dialog to Close |
|
280 * 2. When Power Off Button is clicked. |
|
281 */ |
|
282 void CHbDevicePowerMenuPrivate::DeviceDialogClosed(TInt /*aCompletionCode*/) |
|
283 { |
|
284 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::DeviceDialogClosed") ) ); |
|
285 // Inform sysap to release the memory of power menu custom dialog. |
|
286 RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsPowerMenuCustomDialogStatus, ECoreAppUIsPowerMenuCustomDialogOn ); |
|
287 } |
|
288 |
|
289 /** |
|
290 * Contrcuts VariantMap |
|
291 */ |
|
292 void CHbDevicePowerMenuPrivate::AddVariantL(const TDesC& aKey, const TAny* aData, CHbSymbianVariant::TType aDataType) |
|
293 { |
|
294 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::AddVariantL: START") ) ); |
|
295 CHbSymbianVariant *variant = CHbSymbianVariant::NewL(aData, aDataType); |
|
296 CleanupStack::PushL(variant); |
|
297 //iVariantMap takes the ownerhip of variant |
|
298 User::LeaveIfError(iVariantMap->Add(aKey, variant)); |
|
299 CleanupStack::Pop(variant); |
|
300 TRACES( RDebug::Print( _L("CHbDevicePowerMenuPrivate::AddVariantL: End") ) ); |
|
301 } |
|
302 |
|
303 /* |
|
304 * Creates an object of CHbDevicePowerMenuSymbian |
|
305 */ |
|
306 CHbDevicePowerMenuSymbian* CHbDevicePowerMenuSymbian::NewL(CSysApAppUi& aSysApServer) |
|
307 { |
|
308 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::NewL: START") ) ); |
|
309 CHbDevicePowerMenuSymbian* self = new (ELeave) CHbDevicePowerMenuSymbian(aSysApServer); |
|
310 CleanupStack::PushL(self); |
|
311 self->ConstructL(); |
|
312 CleanupStack::Pop(self); |
|
313 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::NewL: END") ) ); |
|
314 return self; |
|
315 } |
|
316 |
|
317 /* |
|
318 * Destructs the class. |
|
319 */ |
|
320 CHbDevicePowerMenuSymbian::~CHbDevicePowerMenuSymbian() |
|
321 { |
|
322 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::Destructor: START") ) ); |
|
323 delete iCenrepProfile; |
|
324 delete iCenrepOffline; |
|
325 iProfileEngine->Release(); |
|
326 delete iPowerMenuPrivate; |
|
327 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::Destructor: End") ) ); |
|
328 } |
|
329 |
|
330 /* |
|
331 * Executes the dialog asynchronously. |
|
332 */ |
|
333 void CHbDevicePowerMenuSymbian::ShowL() |
|
334 { |
|
335 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::ShowL: START") ) ); |
|
336 iPowerMenuPrivate->ShowL(); |
|
337 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::ShowL: End") ) ); |
|
338 } |
|
339 |
|
340 /** |
|
341 * Sets Volume to aVolume |
|
342 */ |
|
343 void CHbDevicePowerMenuSymbian::SetVolume(TInt aVolume) |
|
344 { |
|
345 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetVolume: START") ) ); |
|
346 iPowerMenuPrivate->SetVolume(aVolume); |
|
347 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetVolume: End") ) ); |
|
348 } |
|
349 |
|
350 /** |
|
351 * Sets SilenceMode to Enable/Disable |
|
352 */ |
|
353 void CHbDevicePowerMenuSymbian::SetSilenceMode(TBool aEnable) |
|
354 { |
|
355 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetSilenceMode: START") ) ); |
|
356 iPowerMenuPrivate->SetSilenceMode(aEnable); |
|
357 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetSilenceMode: END") ) ); |
|
358 } |
|
359 |
|
360 /** |
|
361 * Sets OfflineMode to Checked/UnChecked |
|
362 */ |
|
363 void CHbDevicePowerMenuSymbian::SetOfflineMode(TBool aChecked) |
|
364 { |
|
365 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetOfflineMode: START") ) ); |
|
366 iPowerMenuPrivate->SetOfflineMode(aChecked); |
|
367 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetOfflineMode: End") ) ); |
|
368 } |
|
369 |
|
370 /** |
|
371 * Sets VibrationEnabled to Checked/UnChecked |
|
372 */ |
|
373 void CHbDevicePowerMenuSymbian::SetVibrationEnabled(TBool aEnable) |
|
374 { |
|
375 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetVibrationEnabled: START") ) ); |
|
376 iPowerMenuPrivate->SetVibrationEnabled(aEnable); |
|
377 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetVibrationEnabled: End") ) ); |
|
378 } |
|
379 |
|
380 /** |
|
381 * Sets PowerOffEnabled to Enable/Disable |
|
382 */ |
|
383 void CHbDevicePowerMenuSymbian::SetPowerOffEnabled(TBool aEnable) |
|
384 { |
|
385 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetPowerOffEnabled: START") ) ); |
|
386 iPowerMenuPrivate->SetPowerOffEnabled(aEnable); |
|
387 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::SetPowerOffEnabled: END") ) ); |
|
388 } |
|
389 |
|
390 /* |
|
391 * Constructor. |
|
392 */ |
|
393 CHbDevicePowerMenuSymbian::CHbDevicePowerMenuSymbian(CSysApAppUi& aSysApServer) |
|
394 :iSysApServer(aSysApServer) |
|
395 { |
|
396 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::Constructor") ) ); |
|
397 //Do Nothing |
|
398 } |
|
399 |
|
400 /* |
|
401 * 2nd Constructor. |
|
402 * Constructs and initializes all its meber variables |
|
403 */ |
|
404 void CHbDevicePowerMenuSymbian::ConstructL() |
|
405 { |
|
406 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::ConstructL: START") ) ); |
|
407 iProfileEngine = ::CreateProfileEngineExtended2L(); |
|
408 iCenrepOffline = CRepository::NewL( KCRUidCommunicationSettings ); |
|
409 iCenrepProfile = CRepository::NewL( KCRUidProfileEngine ); |
|
410 iPowerMenuPrivate = CHbDevicePowerMenuPrivate::NewL(this); |
|
411 |
|
412 //To Sync with Contro panel |
|
413 TBool airplaneMode(0); |
|
414 User::LeaveIfError( iCenrepOffline->Get( KSettingsAirplaneMode, airplaneMode ) ); |
|
415 SetOfflineMode(airplaneMode); |
|
416 |
|
417 TInt masterVolume(0); |
|
418 User::LeaveIfError( iCenrepProfile->Get( KProEngMasterVolume, masterVolume ) ); |
|
419 SetVolume(masterVolume); |
|
420 |
|
421 TBool masterVibrate(0); |
|
422 User::LeaveIfError( iCenrepProfile->Get( KProEngMasterVibra, masterVibrate ) ); |
|
423 SetVibrationEnabled(masterVibrate); |
|
424 |
|
425 TBool silenceMode(EFalse); |
|
426 User::LeaveIfError( iCenrepProfile->Get( KProEngSilenceMode, silenceMode ) ); |
|
427 SetSilenceMode(silenceMode); |
|
428 |
|
429 //Cypheroff is True when No encryption/Decryption is happening |
|
430 TBool cypherOff(!(iSysApServer.IsEncryptionOperationOngoingL())); |
|
431 SetPowerOffEnabled(cypherOff); |
|
432 TRACES( RDebug::Print( _L("CHbDevicePowerMenuSymbian::ConstructL: END") ) ); |
|
433 } |
|
434 |