|
1 // PLEASE NOTE: THIS FILE HAS NOT YET BEEN MIGRATED TO NEW NOTIFIER SYSTEM !!! |
|
2 |
|
3 /* |
|
4 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
5 * All rights reserved. |
|
6 * This component and the accompanying materials are made available |
|
7 * under the terms of "Eclipse Public License v1.0" |
|
8 * which accompanies this distribution, and is available |
|
9 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
10 * |
|
11 * Initial Contributors: |
|
12 * Nokia Corporation - initial contribution. |
|
13 * |
|
14 * Contributors: |
|
15 * |
|
16 * Description: Avkon KeyLock Notifier |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #include "AknKeyLockNotifier.h" |
|
22 #include "AknNotifyPlugin.h" |
|
23 #include "AknNotifyPlugin.hrh" |
|
24 |
|
25 #include <aknnotpi.rsg> |
|
26 #include <eikenv.h> |
|
27 #include <eikappui.h> |
|
28 #include <aknkeys.h> |
|
29 #include <coedef.h> |
|
30 |
|
31 #include <uikon/eiksrvui.h> |
|
32 #include <eikon.hrh> |
|
33 #include <apgwgnam.h> |
|
34 #include <aknsoundsystem.h> |
|
35 #include <avkon.rsg> |
|
36 #include <akndlgshut.h> |
|
37 #include <eikkeysound.h> |
|
38 #include <bautils.h> |
|
39 #include <FeatMgr.h> |
|
40 |
|
41 #include <aknlayout.lag> |
|
42 #include <aknutils.h> |
|
43 #include <eikcba.h> |
|
44 #include <aknsconstants.h> |
|
45 #include <aknnotecontrol.h> |
|
46 #include <AknLayoutScalable_Avkon.cdl.h> |
|
47 |
|
48 #ifdef __COVER_DISPLAY |
|
49 #include "AknPublishToCoverUI.h" |
|
50 #endif // __COVER_DISPLAY |
|
51 |
|
52 #include <AknNotifySignature.h> |
|
53 |
|
54 #include <AiwServiceHandler.h> |
|
55 #include <AiwCommon.hrh> |
|
56 |
|
57 #include <akntashook.h> |
|
58 #define KSysApUid TUid::Uid(0x100058F3) |
|
59 |
|
60 const TInt KAknObserverListGranularity = 4; |
|
61 const TInt KAknOfferKeyLockTimeout = 6000000; // 6sec |
|
62 |
|
63 const TInt KNoteCmdFocusLost = 3100; |
|
64 |
|
65 const TUint KAknAsterisk = '*'; |
|
66 const TUint KAknHash = '#'; |
|
67 const TInt KKeyLockControlAnyKey = 3300; // phone query |
|
68 |
|
69 _LIT(KRESOURCEFILE,"z:\\private\\10003a4a\\aknnotpi.rsc"); |
|
70 |
|
71 // CAknLockedNote |
|
72 |
|
73 CAknLockedNote::CAknLockedNote(TInt& aLocked, MEikCommandObserver* aCommandObserver) |
|
74 :CAknSleepingNote(aCommandObserver), iLocked(aLocked) |
|
75 { |
|
76 AKNTASHOOK_ADD( this, "CAknLockedNote" ); |
|
77 } |
|
78 |
|
79 TBool CAknLockedNote::OkToExitL(TInt aCommand) |
|
80 { |
|
81 iLocked = EFalse; |
|
82 |
|
83 if (iCommandObserver) |
|
84 { |
|
85 iCommandObserver->ProcessCommandL(aCommand); |
|
86 } |
|
87 |
|
88 return ETrue; |
|
89 } |
|
90 |
|
91 CAknLockedNote::~CAknLockedNote() |
|
92 { |
|
93 AKNTASHOOK_REMOVE(); |
|
94 iLocked = EFalse; |
|
95 } |
|
96 |
|
97 void CAknLockedNote::CancelNote() |
|
98 { |
|
99 if ( iTimer ) |
|
100 iTimer->Cancel(); |
|
101 CAknNoteControl* ctrl = 0; |
|
102 ctrl = NoteControl(); |
|
103 if ( ctrl ) |
|
104 { // if there is no animation, just returns KErrGeneral |
|
105 ctrl->CancelAnimation(); |
|
106 } |
|
107 ExitSleepingDialog(); |
|
108 iLocked = EFalse; |
|
109 } |
|
110 |
|
111 void CAknLockedNote::FocusChanged(TDrawNow /*aDrawNow*/) |
|
112 { |
|
113 if (!IsFocused() && iCommandObserver) |
|
114 { |
|
115 TRAP_IGNORE(iCommandObserver->ProcessCommandL(KNoteCmdFocusLost)) |
|
116 } |
|
117 } |
|
118 |
|
119 |
|
120 void CAknLockedNote::CEikDialog_Reserved_1() |
|
121 { |
|
122 } |
|
123 |
|
124 void CAknLockedNote::CEikDialog_Reserved_2() |
|
125 { |
|
126 } |
|
127 |
|
128 void CAknLockedNote::CAknNoteDialog_Reserved() |
|
129 { |
|
130 } |
|
131 |
|
132 void CAknLockedNote::CAknSleepingNote_Reserved() |
|
133 { |
|
134 } |
|
135 |
|
136 |
|
137 CAknSleepingNote::CAknSleepingNote(MEikCommandObserver* aCommandObserver) |
|
138 :iCommandObserver(aCommandObserver) |
|
139 { |
|
140 AKNTASHOOK_ADD( this, "CAknSleepingNote" ); |
|
141 } |
|
142 |
|
143 |
|
144 void CAknSleepingNote::ConstructSleepingNoteL(TInt aResourceId) |
|
145 { |
|
146 iResourceId = aResourceId; |
|
147 CAknNoteDialog::ConstructSleepingDialogL(aResourceId); |
|
148 // Construct now rather than in PreLayoutDynInit |
|
149 delete iTimer; |
|
150 iTimer = 0; |
|
151 |
|
152 iTimer = CPeriodic::NewL(0); |
|
153 } |
|
154 |
|
155 TInt CAknSleepingNote::ShowNote(const TTimeout aTimeout,const TTone aTone) |
|
156 { |
|
157 ReportUserActivity(); |
|
158 iTimeoutInMicroseconds = aTimeout; |
|
159 iTone = aTone; |
|
160 return RouseSleepingDialog(); |
|
161 } |
|
162 |
|
163 TBool CAknSleepingNote::OkToExitL(TInt aCommand) |
|
164 { |
|
165 if (iCommandObserver) |
|
166 { |
|
167 iCommandObserver->ProcessCommandL(aCommand); |
|
168 } |
|
169 return ETrue; |
|
170 } |
|
171 |
|
172 void CAknSleepingNote::HandleResourceChange(TInt aType) |
|
173 { |
|
174 if( aType == KAknsMessageSkinChange ) |
|
175 { |
|
176 TInt animationRes(0); |
|
177 switch (iResourceId) |
|
178 { |
|
179 case R_KEYLOCK_NOTE_KEYLOCKED: |
|
180 animationRes = R_QGN_NOTE_INFO_ANIM; |
|
181 break; |
|
182 case R_KEYLOCK_NOTE_UNLOCK_CONFIRM: |
|
183 animationRes = R_QGN_NOTE_QUERY_ANIM; |
|
184 break; |
|
185 case R_KEYLOCK_NOTE_UNLOCK_ASTERISK: |
|
186 animationRes = R_QGN_NOTE_INFO_ANIM; |
|
187 break; |
|
188 case R_KEYLOCK_NOTE_LOCK_ON: |
|
189 animationRes = R_QGN_NOTE_KEYGUARD_LOCKED_ANIM; |
|
190 break; |
|
191 case R_KEYLOCK_NOTE_LOCK_OFF: |
|
192 animationRes = R_QGN_NOTE_KEYGUARD_OPEN_ANIM; |
|
193 break; |
|
194 case R_KEYLOCK_OFFER_LOCK_NOTE: |
|
195 animationRes = R_QGN_NOTE_QUERY_ANIM; |
|
196 break; |
|
197 default: |
|
198 break; |
|
199 } // end of switch |
|
200 |
|
201 if (animationRes) |
|
202 { |
|
203 CAknNoteControl* ctrl = 0; |
|
204 ctrl = NoteControl(); |
|
205 if ( ctrl ) |
|
206 { |
|
207 TRAP_IGNORE( ctrl->SetAnimationL( animationRes )); |
|
208 } |
|
209 } |
|
210 |
|
211 } |
|
212 |
|
213 CAknNoteDialog::HandleResourceChange(aType); |
|
214 } |
|
215 |
|
216 |
|
217 void CAknSleepingNote::CEikDialog_Reserved_1() |
|
218 { |
|
219 } |
|
220 |
|
221 void CAknSleepingNote::CEikDialog_Reserved_2() |
|
222 { |
|
223 } |
|
224 |
|
225 void CAknSleepingNote::CAknNoteDialog_Reserved() |
|
226 { |
|
227 } |
|
228 |
|
229 void CAknSleepingNote::CAknSleepingNote_Reserved() |
|
230 { |
|
231 } |
|
232 |
|
233 |
|
234 /** |
|
235 * Private class to implement the emergency number display during keylock |
|
236 * |
|
237 */ |
|
238 class CAknEcsNote: public CAknSleepingNote |
|
239 { |
|
240 public: |
|
241 /** |
|
242 * Constructor |
|
243 */ |
|
244 CAknEcsNote( MEikCommandObserver* aCommandObserver ); |
|
245 /** |
|
246 * API to set the emergency number to be displayed |
|
247 * |
|
248 * aMatchedNumber text to display (e.g. "112" ) |
|
249 */ |
|
250 void SetEmergencyNumber( const TDesC& aMatchedNumber ); |
|
251 /** |
|
252 * Dismisses the sleeping note. |
|
253 */ |
|
254 void SleepNote(); |
|
255 |
|
256 TBool iNoteOnScreen; |
|
257 }; |
|
258 |
|
259 CAknEcsNote::CAknEcsNote( MEikCommandObserver* aCommandObserver ) : CAknSleepingNote( aCommandObserver ) |
|
260 {} |
|
261 |
|
262 void CAknEcsNote::SetEmergencyNumber( const TDesC& aMatchedNumber ) |
|
263 { |
|
264 TRect screen(iAvkonAppUi->ApplicationRect()); |
|
265 TAknLayoutRect mainPane; |
|
266 mainPane.LayoutRect(screen, AKN_LAYOUT_WINDOW_main_pane(screen, 0, 1, 1)); |
|
267 TAknLayoutRect popupNoteWindow; |
|
268 AknLayoutUtils::TAknCbaLocation cbaLocation( AknLayoutUtils::CbaLocation() ); |
|
269 TInt variety( 0 ); |
|
270 if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight ) |
|
271 { |
|
272 variety = 5; |
|
273 } |
|
274 else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft ) |
|
275 { |
|
276 variety = 8; |
|
277 } |
|
278 else |
|
279 { |
|
280 variety = 2; |
|
281 } |
|
282 |
|
283 popupNoteWindow.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::popup_note_window( variety )); |
|
284 TAknLayoutText textRect; |
|
285 textRect.LayoutText(popupNoteWindow.Rect(), AKN_LAYOUT_TEXT_Note_pop_up_window_texts_Line_1(4)); |
|
286 |
|
287 // Size of a temporary buffer that contains new lines, spaces and |
|
288 // emergency number for a note. |
|
289 TBuf16<KAknEcsMaxMatchingLength+80> number; |
|
290 number.Append('\n'); |
|
291 number.Append('\n'); |
|
292 |
|
293 TInt spaceCharWidthInPixels = textRect.Font()->CharWidthInPixels(' '); |
|
294 if (spaceCharWidthInPixels < 1) |
|
295 { |
|
296 // Avoid divide by zero situation even the space char would have zero length. |
|
297 spaceCharWidthInPixels = 1; |
|
298 } |
|
299 |
|
300 TInt length = (textRect.TextRect().Width() - textRect.Font()->TextWidthInPixels(aMatchedNumber)) |
|
301 / spaceCharWidthInPixels; |
|
302 |
|
303 const TInt matchedNumberLength = aMatchedNumber.Length(); |
|
304 const TInt numberLength = number.Length(); |
|
305 const TInt numberMaxLength = number.MaxLength(); |
|
306 |
|
307 if ( numberLength + length + matchedNumberLength > numberMaxLength) |
|
308 { |
|
309 // To make sure that buffer overflow does not happen. |
|
310 length = numberMaxLength - numberLength - matchedNumberLength; |
|
311 } |
|
312 for (int i = 0; i < length ; i++) |
|
313 { |
|
314 number.Append(' '); |
|
315 } |
|
316 |
|
317 number.Append(aMatchedNumber); |
|
318 TRAP_IGNORE(SetTextL(number)); |
|
319 |
|
320 } |
|
321 |
|
322 void CAknEcsNote::SleepNote() |
|
323 { |
|
324 if (iNoteOnScreen) |
|
325 ExitSleepingDialog(); // Causes flicker to other notes if called when note is not on screen |
|
326 iNoteOnScreen = EFalse; |
|
327 } |
|
328 |
|
329 //CaknLockedPhoneQuery |
|
330 CAknLockedPhoneQuery* CAknLockedPhoneQuery::NewL( TDes& aDataText ) |
|
331 { |
|
332 CAknLockedPhoneQuery* self = |
|
333 new(ELeave) CAknLockedPhoneQuery( aDataText ); |
|
334 CleanupStack::PushL( self ); |
|
335 self->ConstructL(); |
|
336 CleanupStack::Pop( self ); |
|
337 AKNTASHOOK_ADDL( self, "CAknLockedPhoneQuery" ); |
|
338 return self; |
|
339 } |
|
340 |
|
341 CAknLockedPhoneQuery::~CAknLockedPhoneQuery() |
|
342 { |
|
343 AKNTASHOOK_REMOVE(); |
|
344 if ( iInactivityTimer ) |
|
345 { |
|
346 iInactivityTimer->Cancel(); |
|
347 delete iInactivityTimer; |
|
348 } |
|
349 } |
|
350 |
|
351 CAknLockedPhoneQuery::CAknLockedPhoneQuery(TDes& aDataText) |
|
352 : CAknTextQueryDialog(aDataText) |
|
353 { |
|
354 } |
|
355 |
|
356 void CAknLockedPhoneQuery::ConstructL() |
|
357 { |
|
358 iInactivityTimer = CPeriodic::NewL(CActive::EPriorityUserInput); |
|
359 TCallBack callback(InactivityExitL, this); |
|
360 iInactivityTimer->Start(KEcsInterKeyTimeout, |
|
361 KEcsInterKeyTimeout, callback); |
|
362 } |
|
363 |
|
364 TKeyResponse CAknLockedPhoneQuery::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
365 TEventCode aType) |
|
366 { |
|
367 ResetInactivityTimer(); |
|
368 if(aKeyEvent.iCode == EKeyPhoneSend || aKeyEvent.iCode == EKeyOK) |
|
369 { |
|
370 TryExitL(EAknSoftkeyCall); |
|
371 return EKeyWasConsumed; |
|
372 } |
|
373 if(aKeyEvent.iCode == EKeyPhoneEnd) |
|
374 { |
|
375 TryExitL(EAknSoftkeyCancel); |
|
376 return EKeyWasConsumed; |
|
377 } |
|
378 return CAknTextQueryDialog::OfferKeyEventL(aKeyEvent, aType); |
|
379 } |
|
380 |
|
381 void CAknLockedPhoneQuery::ResetInactivityTimer() |
|
382 { |
|
383 iInactivityTimer->Cancel(); |
|
384 TCallBack callback(InactivityExitL, this); |
|
385 iInactivityTimer->Start(KEcsInterKeyTimeout, |
|
386 KEcsInterKeyTimeout, callback); |
|
387 } |
|
388 |
|
389 TInt CAknLockedPhoneQuery::InactivityExitL(TAny *aThis) |
|
390 { |
|
391 static_cast<CAknLockedPhoneQuery*>(aThis)->DoInactivityExitL(); |
|
392 return 0; |
|
393 } |
|
394 |
|
395 void CAknLockedPhoneQuery::DoInactivityExitL() |
|
396 { |
|
397 TryExitL(EEikBidCancel); |
|
398 } |
|
399 |
|
400 //CAknKeyLockControl |
|
401 |
|
402 CAknKeyLockControl::CAknKeyLockControl() |
|
403 { |
|
404 AKNTASHOOK_ADD( this, "CAknKeyLockControl" ); |
|
405 } |
|
406 |
|
407 CAknKeyLockControl::CAknKeyLockControl(CAknKeyLockNotifierSubject* aNotif):iNotif(aNotif) |
|
408 { |
|
409 AKNTASHOOK_ADD( this, "CAknKeyLockControl" ); |
|
410 } |
|
411 |
|
412 CAknKeyLockControl::~CAknKeyLockControl() |
|
413 { |
|
414 AKNTASHOOK_REMOVE(); |
|
415 FeatureManager::UnInitializeLib(); |
|
416 iEikonEnv->EikAppUi()->RemoveFromStack(this); |
|
417 delete iConfirmationNote; |
|
418 //Show note "Now press *". |
|
419 //Note is shown when user has pressed "Unlock" when keypad is in locked state |
|
420 delete iConfirmationNoteAsterisk; |
|
421 delete iLockedNote; |
|
422 delete iKeypadUnlockedNote; |
|
423 delete iKeypadLockedNote; |
|
424 delete iEcsDetector; |
|
425 delete iKeyLockCba; |
|
426 delete iOfferLockNote; |
|
427 delete iEcsNote; // Ecs change |
|
428 } |
|
429 |
|
430 void CAknKeyLockControl::ConstructL() |
|
431 { |
|
432 FeatureManager::InitializeLibL(); |
|
433 iFeatureKeypadNoSlider = |
|
434 FeatureManager::FeatureSupported( KFeatureIdKeypadNoSlider ); |
|
435 |
|
436 CreateWindowL(); |
|
437 Window().SetSize(TSize(0,0)); |
|
438 |
|
439 ActivateL(); |
|
440 |
|
441 iEikonEnv->EikAppUi()->AddToStackL(this,ECoeStackPriorityEnvironmentFilter+10,ECoeStackFlagRefusesFocus); |
|
442 |
|
443 iKeyLockCba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, CEikButtonGroupContainer::EHorizontal, this, R_KEYLOCK_SOFTKEYS_UNLOCK_EMPTY); |
|
444 iKeyLockCba->ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(ECoeWinPriorityNeverAtFront); |
|
445 // const TSize screenSize=TSize(AKN_LAYOUT_WINDOW_screen.iW,AKN_LAYOUT_WINDOW_screen.iH); // Ok so far. 'screen' layout used. |
|
446 const TSize screenSize( iAvkonAppUi->ApplicationRect().Size() ); |
|
447 iKeyLockCba->MakeVisible(EFalse); |
|
448 iKeyLockCba->SetBoundingRect(TRect(screenSize)); |
|
449 |
|
450 iEcsNote = new (ELeave) CAknEcsNote( this ); |
|
451 iEcsNote->ConstructSleepingNoteL(R_AVKON_EMERGENCY_CALL_NOTE); |
|
452 iEcsNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,2); |
|
453 |
|
454 iOfferLockNote = new(ELeave)CAknLockedNote(iOfferLockEnabled, this); |
|
455 iOfferLockNote->ConstructSleepingNoteL(R_KEYLOCK_OFFER_LOCK_NOTE); |
|
456 iOfferLockNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,2); |
|
457 |
|
458 iKeypadLockedNote = new(ELeave)CAknSleepingNote(); |
|
459 iKeypadLockedNote->ConstructSleepingNoteL(R_KEYLOCK_NOTE_LOCK_ON); |
|
460 iKeypadLockedNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,2); |
|
461 |
|
462 iKeypadUnlockedNote = new(ELeave)CAknSleepingNote(); |
|
463 iKeypadUnlockedNote->ConstructSleepingNoteL(R_KEYLOCK_NOTE_LOCK_OFF); |
|
464 iKeypadUnlockedNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,2); |
|
465 |
|
466 iLockedNote = new (ELeave)CAknLockedNote(iLockedNoteDisplayed); |
|
467 iLockedNote->ConstructSleepingNoteL(R_KEYLOCK_NOTE_KEYLOCKED); |
|
468 iLockedNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,2); |
|
469 |
|
470 iConfirmationNote = new (ELeave) CAknLockedNote(iUnlockConfirmation); |
|
471 iConfirmationNote->ConstructSleepingNoteL(R_KEYLOCK_NOTE_UNLOCK_CONFIRM); |
|
472 iConfirmationNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,2); |
|
473 |
|
474 if ( iFeatureKeypadNoSlider ) |
|
475 { |
|
476 //Show note "Now press *". |
|
477 //Note is shown when user has pressed "Unlock" when keypad is in locked state |
|
478 iConfirmationNoteAsterisk = new (ELeave) CAknLockedNote(iUnlockConfirmation); |
|
479 iConfirmationNoteAsterisk->ConstructSleepingNoteL(R_KEYLOCK_NOTE_UNLOCK_ASTERISK); |
|
480 iConfirmationNoteAsterisk->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,2); |
|
481 } |
|
482 // Emergency call support |
|
483 iEcsDetector = CAknEcsDetector::NewL(); |
|
484 iEcsDetector->SetObserver( this ); |
|
485 |
|
486 iPhoneQueryOnScreen = EFalse; |
|
487 iPhoneNumber.Zero(); |
|
488 } |
|
489 |
|
490 |
|
491 void CAknKeyLockControl::EnableKeylock(TBool aShowNote) |
|
492 { |
|
493 if (iOfferLockEnabled) |
|
494 { |
|
495 iOfferLockNote->CancelNote(); |
|
496 } |
|
497 iKeyLockEnabled = ETrue; |
|
498 |
|
499 if (!iAutolockEnabled) |
|
500 SendMessageToSysAp(EEikKeyLockEnabled); |
|
501 iKeyLockCba->MakeVisible(ETrue); |
|
502 |
|
503 TBool areWeInIdleState = CEikStatusPaneBase::Current()->PaneCapabilities(TUid::Uid(EEikStatusPaneUidClock)).IsInCurrentLayout(); |
|
504 if (areWeInIdleState) |
|
505 { // idle state |
|
506 ((CEikCba*)iKeyLockCba->ButtonGroup())->SetSkinBackgroundId(KAknsIIDQsnBgAreaControlIdle); |
|
507 } |
|
508 else |
|
509 { |
|
510 ((CEikCba*)iKeyLockCba->ButtonGroup())->SetSkinBackgroundId(KAknsIIDQsnBgAreaControl); |
|
511 } |
|
512 |
|
513 iEikonEnv->BringForwards(ETrue); |
|
514 |
|
515 if ( aShowNote ) |
|
516 DisplayLockedNote(); |
|
517 ShowKeylockCba(); |
|
518 CaptureSystemKeys(); |
|
519 iEcsDetector->ConnectToEventSource(); |
|
520 |
|
521 if ( iNotif ) |
|
522 { |
|
523 iNotif->NotifyStatusChange(EKeyLockEnabled); |
|
524 } |
|
525 |
|
526 if ( !iSoundsMuted ) |
|
527 { |
|
528 CAknAppUiBase* appUi = iAvkonAppUiBase; |
|
529 TRAPD(err, appUi->KeySounds()->PushContextL(R_AVKON_SILENT_SKEY_LIST)); |
|
530 if ( !err ) |
|
531 { |
|
532 appUi->KeySounds()->BringToForeground(); |
|
533 appUi->KeySounds()->LockContext(); |
|
534 iSoundsMuted = ETrue; |
|
535 } |
|
536 } |
|
537 } |
|
538 |
|
539 void CAknKeyLockControl::DisableKeylock() |
|
540 { |
|
541 if ( iSoundsMuted ) |
|
542 { |
|
543 CAknAppUiBase* appUi = iAvkonAppUiBase; |
|
544 appUi->KeySounds()->ReleaseContext(); |
|
545 appUi->KeySounds()->PopContext(); |
|
546 } |
|
547 |
|
548 iEcsDetector->CloseEventSource(); |
|
549 UnCaptureSystemKeys(); |
|
550 iEikonEnv->BringForwards(EFalse); |
|
551 iKeyLockCba->ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(ECoeWinPriorityNeverAtFront); |
|
552 iKeyLockCba->MakeVisible(EFalse); |
|
553 iKeyLockEnabled = EFalse; |
|
554 if (!iAutolockEnabled) |
|
555 SendMessageToSysAp(EEikKeyLockDisabled); |
|
556 if ( iNotif ) |
|
557 { |
|
558 iNotif->NotifyStatusChange(EKeyLockDisabled); |
|
559 } |
|
560 iAutolockEnabled = EFalse; |
|
561 } |
|
562 |
|
563 void CAknKeyLockControl::SendMessageToSysAp(TInt aMessage) |
|
564 { |
|
565 RWsSession& ws = iEikonEnv->WsSession(); |
|
566 TInt wgId=0; |
|
567 CApaWindowGroupName::FindByAppUid(KSysApUid, ws, wgId); |
|
568 if (wgId) |
|
569 { |
|
570 TWsEvent event; |
|
571 event.SetType(aMessage); |
|
572 event.SetTimeNow(); |
|
573 ws.SendEventToWindowGroup(wgId, event); |
|
574 } |
|
575 } |
|
576 |
|
577 void CAknKeyLockControl::OfferKeylock() |
|
578 { |
|
579 iOfferLockNote->ShowNote((CAknNoteDialog::TTimeout)KAknOfferKeyLockTimeout, CAknNoteDialog::ENoTone); |
|
580 iOfferLockEnabled = ETrue; |
|
581 } |
|
582 |
|
583 |
|
584 void CAknKeyLockControl::DisplayLockedNote() |
|
585 { |
|
586 if ( !iAutolockEnabled ) |
|
587 { |
|
588 iKeypadLockedNote->ShowNote(CAknNoteDialog::EShortTimeout,CAknNoteDialog::ENoTone); |
|
589 #ifdef __COVER_DISPLAY |
|
590 #ifdef __SERIES60_30__ // different code for 3.0 and 2.8 |
|
591 SAknKeyguardNotePS params; |
|
592 params.iIsLocked = ETrue; |
|
593 params.iTimeout = CAknNoteDialog::EShortTimeout; |
|
594 params.iTone = CAknNoteDialog::ENoTone; |
|
595 TRAP_IGNORE( AknPublishToCoverUI::PublishKeyguardNoteL( params ) ); |
|
596 #else // 2.8 |
|
597 SAknKeyguardNotePSParams params; |
|
598 params.iIsLocked = ETrue; |
|
599 params.iTimeout = CAknNoteDialog::EShortTimeout; |
|
600 TRAP_IGNORE( AknPublishToCoverUI::PublishKeyguardNoteL( params ) ); |
|
601 #endif // __SERIES60_30__ |
|
602 #endif // __COVER_DISPLAY |
|
603 } |
|
604 } |
|
605 |
|
606 void CAknKeyLockControl::DisplayKeyActiveNote() |
|
607 { |
|
608 if ( !iAutolockEnabled ) |
|
609 { |
|
610 iKeypadUnlockedNote->ShowNote(CAknNoteDialog::EShortTimeout,CAknNoteDialog::ENoTone); |
|
611 #ifdef __COVER_DISPLAY |
|
612 #ifdef __SERIES60_30__ // different code for 3.0 and 2.8 |
|
613 SAknKeyguardNotePS params; |
|
614 params.iIsLocked = EFalse; |
|
615 params.iTimeout = CAknNoteDialog::EShortTimeout; |
|
616 params.iTone = CAknNoteDialog::ENoTone; |
|
617 TRAP_IGNORE( AknPublishToCoverUI::PublishKeyguardNoteL( params ) ); |
|
618 #else // 2.8 |
|
619 SAknKeyguardNotePSParams params; |
|
620 params.iIsLocked = EFalse; |
|
621 params.iTimeout = CAknNoteDialog::EShortTimeout; |
|
622 TRAP_IGNORE( AknPublishToCoverUI::PublishKeyguardNoteL( params ) ); |
|
623 #endif // __COVER_DISPLAY |
|
624 #endif // __COVER_DISPLAY |
|
625 } |
|
626 } |
|
627 |
|
628 void CAknKeyLockControl::DoUnlock() |
|
629 { |
|
630 DisableKeylock(); |
|
631 DisplayKeyActiveNote(); |
|
632 } |
|
633 |
|
634 void CAknKeyLockControl::ProcessCommandL(TInt aCommandId) |
|
635 { |
|
636 if ( aCommandId == KKeyLockControlAnyKey ) |
|
637 { |
|
638 if ( !iPhoneQueryOnScreen ) |
|
639 { |
|
640 iPhoneQueryOnScreen = ETrue; |
|
641 |
|
642 // show phone query |
|
643 ShowLockPhoneQueryL(); |
|
644 } |
|
645 } |
|
646 else if (aCommandId == EAknSoftkeyUnlock) |
|
647 { |
|
648 iPhoneQueryOnScreen = EFalse; |
|
649 if ( iAutolockEnabled ) |
|
650 { |
|
651 TApaTaskList aList(iCoeEnv->WsSession()); |
|
652 TApaTask aTask = aList.FindApp(TUid::Uid(0x100059B5)); |
|
653 if ( aTask.Exists() ) |
|
654 { |
|
655 DisableKeylock(); |
|
656 iNotif->NotifyStatusChange(EHideSoftNotifications); |
|
657 TKeyEvent keyEvent; |
|
658 keyEvent.iCode = EKeyBell; |
|
659 aTask.SendKey(keyEvent); |
|
660 SendMessageToSysAp(EEikKeyLockPowerKeyPressed); |
|
661 } |
|
662 // else we do nothing, Autolock application was not ready yet. |
|
663 } |
|
664 else |
|
665 { |
|
666 if ( iFeatureKeypadNoSlider ) |
|
667 { |
|
668 //Show note "Now press *". |
|
669 //Note is shown when user has pressed "Unlock" when keypad is in locked state |
|
670 iConfirmationNoteAsterisk->ShowNote( |
|
671 CAknNoteDialog::EShortTimeout,CAknNoteDialog::EConfirmationTone); |
|
672 } |
|
673 else |
|
674 { |
|
675 iConfirmationNote->ShowNote( |
|
676 CAknNoteDialog::EShortTimeout,CAknNoteDialog::EConfirmationTone); |
|
677 } |
|
678 iUnlockConfirmation = ETrue; |
|
679 } |
|
680 } |
|
681 else if (aCommandId == EAknSoftkeyLock) |
|
682 { |
|
683 // Lock keys |
|
684 DoExitOfferKeylock(); |
|
685 EnableKeylock(); |
|
686 } |
|
687 else if (aCommandId == EAknSoftkeyExit) |
|
688 { |
|
689 // Cancel offer keylock CBA |
|
690 DoExitOfferKeylock(); |
|
691 } |
|
692 else if (aCommandId == EAknSoftkeyEmpty) |
|
693 { |
|
694 if (iKeyLockEnabled) |
|
695 { |
|
696 ShowLockedNote(); |
|
697 } |
|
698 } |
|
699 else if (aCommandId == KNoteCmdFocusLost) |
|
700 { |
|
701 // Locked note has become unfocusd - get rid of it |
|
702 if (iOfferLockEnabled) |
|
703 { |
|
704 DoExitOfferKeylock(); |
|
705 } |
|
706 } |
|
707 } |
|
708 |
|
709 TInt CAknKeyLockControl::CountComponentControls() const |
|
710 { |
|
711 if (iKeyLockEnabled) |
|
712 return 1; |
|
713 else |
|
714 return 0; |
|
715 } |
|
716 |
|
717 CCoeControl* CAknKeyLockControl::ComponentControl(TInt /*aIndex*/) const |
|
718 { |
|
719 if (iKeyLockEnabled) |
|
720 return iKeyLockCba; |
|
721 else |
|
722 return NULL; |
|
723 } |
|
724 |
|
725 |
|
726 TKeyResponse CAknKeyLockControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
727 { |
|
728 if (!iOfferLockEnabled && !iKeyLockEnabled) |
|
729 return EKeyWasNotConsumed; |
|
730 |
|
731 |
|
732 if ( (aType == EEventKey && aKeyEvent.iRepeats == 0) || |
|
733 (aType == EEventKeyDown && aKeyEvent.iScanCode == EStdKeyDevice2) // Power key |
|
734 ) |
|
735 { |
|
736 // If power key pressed, tell SysAp about if |
|
737 if(aKeyEvent.iScanCode == EStdKeyDevice2) |
|
738 { |
|
739 SendMessageToSysAp(EEikKeyLockPowerKeyPressed); |
|
740 } |
|
741 |
|
742 if (iOfferLockEnabled) |
|
743 { |
|
744 switch (aKeyEvent.iCode) |
|
745 { |
|
746 case EKeyOK: |
|
747 { |
|
748 DoExitOfferKeylock(); |
|
749 EnableKeylock(); |
|
750 } |
|
751 case EKeyLeftArrow: |
|
752 case EKeyRightArrow: |
|
753 case EKeyUpArrow: |
|
754 case EKeyDownArrow: |
|
755 case EKeyApplication: |
|
756 return EKeyWasConsumed; |
|
757 break; |
|
758 default: |
|
759 // Normal response - send it to the cba via the control stack |
|
760 return EKeyWasNotConsumed; |
|
761 } |
|
762 } |
|
763 else if (iKeyLockEnabled) |
|
764 { |
|
765 if (iLockedNoteDisplayed) |
|
766 { |
|
767 // See if 'Unlock' has been pressed |
|
768 if (aKeyEvent.iCode == EKeyCBA1) |
|
769 { |
|
770 if ( iFeatureKeypadNoSlider ) |
|
771 { |
|
772 iConfirmationNoteAsterisk->ShowNote( |
|
773 CAknNoteDialog::EShortTimeout, |
|
774 CAknNoteDialog::EConfirmationTone); |
|
775 } |
|
776 else |
|
777 { |
|
778 iConfirmationNote->ShowNote( |
|
779 CAknNoteDialog::EShortTimeout, |
|
780 CAknNoteDialog::EConfirmationTone); |
|
781 } |
|
782 |
|
783 iUnlockConfirmation = ETrue; |
|
784 iLockedNote->CancelNote(); |
|
785 } |
|
786 // Locked note is on-screen - discard key |
|
787 return EKeyWasConsumed; |
|
788 } |
|
789 else if (iUnlockConfirmation) |
|
790 { |
|
791 // Confirmation note is on-screen - check for OK |
|
792 |
|
793 if ( ( aKeyEvent.iCode == KAknAsterisk && iFeatureKeypadNoSlider ) |
|
794 || ( aKeyEvent.iCode == EKeyCBA2 && !iFeatureKeypadNoSlider ) ) |
|
795 { |
|
796 DoUnlock(); |
|
797 if ( iFeatureKeypadNoSlider ) |
|
798 { |
|
799 //Show note "Now press *". |
|
800 //Note is shown when user has pressed "Unlock" when keypad is in locked state |
|
801 iConfirmationNoteAsterisk->CancelNote(); |
|
802 } |
|
803 else |
|
804 { |
|
805 iConfirmationNote->CancelNote(); |
|
806 } |
|
807 } |
|
808 else |
|
809 { |
|
810 if ( aKeyEvent.iCode != EKeyCBA1 ) |
|
811 ShowLockedNote(); |
|
812 } |
|
813 } |
|
814 else |
|
815 { |
|
816 // Normal response - send it to the cba |
|
817 TKeyResponse cbaResponse = iKeyLockCba->ButtonGroup()-> |
|
818 AsControl()->OfferKeyEventL(aKeyEvent, aType); |
|
819 |
|
820 if (cbaResponse == EKeyWasNotConsumed) |
|
821 { |
|
822 if ( !iFeatureKeypadNoSlider ) |
|
823 { |
|
824 // Selection key causes same action as 'Unlock' |
|
825 if (aKeyEvent.iCode == EKeyOK) |
|
826 { |
|
827 iConfirmationNote->ShowNote( |
|
828 CAknNoteDialog::EShortTimeout, |
|
829 CAknNoteDialog::EConfirmationTone); |
|
830 |
|
831 iUnlockConfirmation = ETrue; |
|
832 } |
|
833 else |
|
834 { |
|
835 ShowLockedNote(); |
|
836 } |
|
837 } |
|
838 else |
|
839 { |
|
840 if ( !(iEcsNote->iNoteOnScreen && aKeyEvent.iCode == EKeyYes) ) |
|
841 { |
|
842 if ( !iAutolockEnabled ) |
|
843 { |
|
844 ShowLockedNote(); |
|
845 } |
|
846 else |
|
847 { |
|
848 if(aKeyEvent.iScanCode == EStdKeyDevice2) |
|
849 { |
|
850 SendMessageToSysAp(EEikKeyLockPowerKeyPressed); |
|
851 return EKeyWasConsumed; |
|
852 } |
|
853 switch ( aKeyEvent.iCode ) |
|
854 { |
|
855 case EKeyLeftArrow: |
|
856 case EKeyRightArrow: |
|
857 case EKeyUpArrow: |
|
858 case EKeyDownArrow: |
|
859 case EKeyApplication: |
|
860 case EKeyCamera: |
|
861 case EKeyVolumeUp: |
|
862 case EKeyVolumeDown: |
|
863 case EKeySide: |
|
864 return EKeyWasConsumed; |
|
865 case EKeyOK: |
|
866 case EKeyPhoneSend: |
|
867 case EKeyPhoneEnd: |
|
868 case EKeyBackspace: |
|
869 if ( !iPhoneQueryOnScreen ) |
|
870 { |
|
871 return EKeyWasConsumed; |
|
872 } |
|
873 default: |
|
874 break; |
|
875 } |
|
876 if ( iPhoneQueryOnScreen ) |
|
877 { |
|
878 return EKeyWasNotConsumed; |
|
879 } |
|
880 |
|
881 iPhoneNumber.Zero(); |
|
882 if (aKeyEvent.iScanCode == EStdKeyHash) |
|
883 { |
|
884 iPhoneNumber.Append( KAknHash ); |
|
885 } |
|
886 else |
|
887 { |
|
888 iPhoneNumber.Append( aKeyEvent.iScanCode ); |
|
889 } |
|
890 ProcessCommandL( KKeyLockControlAnyKey ); |
|
891 } |
|
892 } |
|
893 } |
|
894 } |
|
895 } |
|
896 } |
|
897 } |
|
898 return EKeyWasConsumed; |
|
899 } |
|
900 |
|
901 |
|
902 void CAknKeyLockControl::ShowLockedNote() |
|
903 { |
|
904 if ( !iLockedNoteDisplayed ) |
|
905 { |
|
906 DoShowLockedNote(); |
|
907 } |
|
908 } |
|
909 |
|
910 |
|
911 void CAknKeyLockControl::DoShowLockedNote() |
|
912 { |
|
913 if ( !iAutolockEnabled ) |
|
914 { |
|
915 iLockedNote->ShowNote(CAknNoteDialog::EShortTimeout,CAknNoteDialog::ENoTone); |
|
916 iLockedNoteDisplayed = ETrue; |
|
917 } |
|
918 } |
|
919 |
|
920 void CAknKeyLockControl::ShowKeylockCba() |
|
921 { |
|
922 RDrawableWindow* cbaWindow = iKeyLockCba->ButtonGroup()->AsControl()->DrawableWindow(); |
|
923 cbaWindow->SetFaded(EFalse, RWindowTreeNode::EFadeWindowOnly); |
|
924 cbaWindow->SetOrdinalPosition(0,1); |
|
925 cbaWindow->SetNonFading(ETrue); |
|
926 } |
|
927 |
|
928 void CAknKeyLockControl::CaptureSystemKeys() |
|
929 { |
|
930 if (!iKeysCaptured) |
|
931 { |
|
932 RWindowGroup& groupWin=iCoeEnv->RootWin(); |
|
933 iAppKey = groupWin.CaptureKeyUpAndDowns(EStdKeyApplication0, 0, 0); // Capture app key |
|
934 iPowerKey = groupWin.CaptureKeyUpAndDowns(EStdKeyDevice2, 0, 0); // Capture power key |
|
935 iVoiceKey = groupWin.CaptureKeyUpAndDowns(EStdKeyDevice6, 0, 0); // Capture power key |
|
936 iAppKey2 = groupWin.CaptureKey(EKeyApplication0, 0, 0); // Capture app key |
|
937 iPowerKey2 = groupWin.CaptureKey(EKeyDevice2, 0, 0); // Capture power key |
|
938 iVoiceKey2 = groupWin.CaptureKey(EKeyDevice6, 0, 0); // Capture power key |
|
939 iLeftSoftKey = groupWin.CaptureKey(EKeyDevice0,0,0); |
|
940 iEditKey = groupWin.CaptureKey(EKeyRightShift,0,0); |
|
941 iCameraKey = groupWin.CaptureKeyUpAndDowns(EKeyCamera,0,0); |
|
942 iVolumeUpKey = groupWin.CaptureKeyUpAndDowns(EStdKeyIncVolume,0,0); |
|
943 iVolumeDownKey = groupWin.CaptureKeyUpAndDowns(EStdKeyDecVolume,0,0); |
|
944 iCameraKey2 = groupWin.CaptureKey(EKeyDevice7,0,0); |
|
945 iVolumeUpKey2 = groupWin.CaptureKey(EKeyVolumeUp,0,0); |
|
946 iVolumeDownKey2 = groupWin.CaptureKey(EKeyVolumeDown,0,0); |
|
947 iKeysCaptured = ETrue; |
|
948 } |
|
949 } |
|
950 |
|
951 void CAknKeyLockControl::UnCaptureSystemKeys() |
|
952 { |
|
953 if (iKeysCaptured) |
|
954 { |
|
955 RWindowGroup& groupWin=iCoeEnv->RootWin(); |
|
956 groupWin.CancelCaptureKeyUpAndDowns(iAppKey); |
|
957 groupWin.CancelCaptureKeyUpAndDowns(iPowerKey); |
|
958 groupWin.CancelCaptureKeyUpAndDowns(iVoiceKey); |
|
959 groupWin.CancelCaptureKey(iAppKey2); |
|
960 groupWin.CancelCaptureKey(iPowerKey2); |
|
961 groupWin.CancelCaptureKey(iVoiceKey2); |
|
962 groupWin.CancelCaptureKey(iLeftSoftKey); |
|
963 groupWin.CancelCaptureKey(iEditKey); |
|
964 groupWin.CancelCaptureKey(iCameraKey); |
|
965 groupWin.CancelCaptureKey(iVolumeUpKey); |
|
966 groupWin.CancelCaptureKey(iVolumeDownKey); |
|
967 groupWin.CancelCaptureKey(iCameraKey2); |
|
968 groupWin.CancelCaptureKey(iVolumeUpKey2); |
|
969 groupWin.CancelCaptureKey(iVolumeDownKey2); |
|
970 iKeysCaptured = EFalse; |
|
971 } |
|
972 } |
|
973 |
|
974 void CAknKeyLockControl::HandleEcsEvent( CAknEcsDetector* aEcsDetector, CAknEcsDetector::TState aState ) |
|
975 { |
|
976 switch ( aState ) |
|
977 { |
|
978 case CAknEcsDetector::ECompleteMatchThenSendKey: |
|
979 // Do nothing since note will be removed on ECallAttempted event |
|
980 break; |
|
981 case CAknEcsDetector::ECompleteMatch: |
|
982 if ( !iPhoneQueryOnScreen ) |
|
983 { |
|
984 iEcsNote->SetEmergencyNumber( aEcsDetector->CurrentMatch() ); |
|
985 iEcsNote->ShowNote( CAknNoteDialog::ENoTimeout,CAknNoteDialog::ENoTone ); |
|
986 |
|
987 // Tell sysAp to switch lights on |
|
988 SendMessageToSysAp(EEikKeyLockPowerKeyPressed); |
|
989 iEcsNote->iNoteOnScreen =ETrue; |
|
990 } |
|
991 break; |
|
992 case CAknEcsDetector::EPartialMatch: |
|
993 iEcsNote->SleepNote(); |
|
994 break; |
|
995 case CAknEcsDetector::ECallAttempted: |
|
996 iEcsNote->SleepNote(); |
|
997 break; |
|
998 case CAknEcsDetector::EEmpty: |
|
999 iEcsNote->SleepNote(); |
|
1000 break; |
|
1001 case CAknEcsDetector::ENoMatch: |
|
1002 iEcsNote->SleepNote(); |
|
1003 break; |
|
1004 default: |
|
1005 break; |
|
1006 } |
|
1007 |
|
1008 } |
|
1009 |
|
1010 void CAknKeyLockControl::DoExitOfferKeylock() |
|
1011 { |
|
1012 iOfferLockNote->CancelNote(); |
|
1013 } |
|
1014 |
|
1015 void CAknKeyLockControl::OfferTimerExpired() |
|
1016 { |
|
1017 DoExitOfferKeylock(); |
|
1018 } |
|
1019 |
|
1020 void CAknKeyLockControl::AutolockEnabled(TBool aAutoLockOn) |
|
1021 { |
|
1022 iAutolockEnabled = aAutoLockOn; |
|
1023 } |
|
1024 |
|
1025 void CAknKeyLockControl::CallNumberL( TDesC& aNumber ) |
|
1026 { |
|
1027 CAiwServiceHandler* serviceHandler; |
|
1028 serviceHandler = CAiwServiceHandler::NewL(); |
|
1029 serviceHandler->AttachL(R_AKNNOTIFYPLUGIN_INTEREST); |
|
1030 |
|
1031 TAiwDialDataV1 dialData = TAiwDialDataV1(); |
|
1032 dialData.SetTelephoneNumber(aNumber); |
|
1033 dialData.SetCallType(EAiwVoice); |
|
1034 TAiwDialDataV1Pckg dialDataPckg = TAiwDialDataV1Pckg(dialData); |
|
1035 CAiwGenericParamList& paramList = serviceHandler->InParamListL(); |
|
1036 TPtrC8 ptr; |
|
1037 ptr.Set(dialDataPckg); |
|
1038 TAiwVariant variant(ptr); |
|
1039 TAiwGenericParam param(EGenericParamCallDialDataV1, variant); |
|
1040 paramList.AppendL(param); |
|
1041 |
|
1042 serviceHandler->ExecuteServiceCmdL(KAiwCmdCall, |
|
1043 paramList, |
|
1044 serviceHandler->OutParamListL(), |
|
1045 0, |
|
1046 NULL); |
|
1047 } |
|
1048 |
|
1049 void CAknKeyLockControl::ShowLockPhoneQueryL() |
|
1050 { |
|
1051 iKeyLockCba->MakeVisible(EFalse); |
|
1052 |
|
1053 HBufC* phoneNumber = HBufC::NewLC(KPhoneNumberMaxLength); |
|
1054 phoneNumber->Des() = iPhoneNumber; |
|
1055 TPtr phonePtr(phoneNumber->Des()); |
|
1056 |
|
1057 CAknLockedPhoneQuery* phoneQuery = CAknLockedPhoneQuery::NewL(phonePtr); |
|
1058 TInt queryAction = phoneQuery->ExecuteLD(R_AVKON_LOCK_PHONE_QUERY); |
|
1059 switch(queryAction) |
|
1060 { |
|
1061 case EAknSoftkeyCall: |
|
1062 CallNumberL(phonePtr); |
|
1063 break; |
|
1064 default: |
|
1065 break; |
|
1066 } |
|
1067 |
|
1068 iPhoneQueryOnScreen = EFalse; |
|
1069 CleanupStack::PopAndDestroy(phoneNumber); |
|
1070 |
|
1071 iKeyLockCba->MakeVisible(ETrue); |
|
1072 } |
|
1073 |
|
1074 // CAknKeyLockNotifierSubject |
|
1075 |
|
1076 CAknKeyLockNotifierSubject* CAknKeyLockNotifierSubject::NewL() |
|
1077 { |
|
1078 CAknKeyLockNotifierSubject* self = new(ELeave)CAknKeyLockNotifierSubject(); |
|
1079 CleanupStack::PushL(self); |
|
1080 self->ConstructL(); |
|
1081 CleanupStack::Pop( self ); |
|
1082 return self; |
|
1083 } |
|
1084 |
|
1085 |
|
1086 void CAknKeyLockNotifierSubject::ConstructL() |
|
1087 { |
|
1088 CCoeEnv* environment = CCoeEnv::Static(); |
|
1089 |
|
1090 TFileName resourceFile; |
|
1091 resourceFile.Append(KRESOURCEFILE); |
|
1092 BaflUtils::NearestLanguageFile(environment->FsSession(),resourceFile); |
|
1093 |
|
1094 iResourceFileOffset = environment->AddResourceFileL(resourceFile); |
|
1095 |
|
1096 iObserverList = new(ELeave)CArrayPtrFlat<MAknKeyLockObserver>(KAknObserverListGranularity); |
|
1097 iKeyLockControl = new(ELeave)CAknKeyLockControl(this); |
|
1098 iKeyLockControl->ConstructL(); |
|
1099 // Make sure AppUi has a pointer to this |
|
1100 STATIC_CAST(CEikServAppUi*,CEikonEnv::Static()->AppUi())->iKeyLockController = this; |
|
1101 } |
|
1102 |
|
1103 CAknKeyLockNotifierSubject::CAknKeyLockNotifierSubject() |
|
1104 :iAllowNotifications(ETrue) |
|
1105 { |
|
1106 } |
|
1107 |
|
1108 |
|
1109 CAknKeyLockNotifierSubject::~CAknKeyLockNotifierSubject() |
|
1110 { |
|
1111 if ( iResourceFileOffset ) |
|
1112 CCoeEnv::Static()->DeleteResourceFile(iResourceFileOffset); |
|
1113 delete iKeyLockControl; |
|
1114 delete iObserverList; |
|
1115 } |
|
1116 |
|
1117 void CAknKeyLockNotifierSubject::Release() |
|
1118 { |
|
1119 delete this; |
|
1120 } |
|
1121 |
|
1122 CAknKeyLockNotifierSubject::TNotifierInfo CAknKeyLockNotifierSubject::RegisterL() |
|
1123 { |
|
1124 iInfo.iUid=KAknKeyLockNotifierUid; |
|
1125 iInfo.iChannel=EAknNotifierChannelKeyLock; |
|
1126 iInfo.iPriority=ENotifierPriorityHigh; |
|
1127 return iInfo; |
|
1128 } |
|
1129 |
|
1130 CAknKeyLockNotifierSubject::TNotifierInfo CAknKeyLockNotifierSubject::Info() const |
|
1131 { |
|
1132 return iInfo; |
|
1133 } |
|
1134 |
|
1135 TPtrC8 CAknKeyLockNotifierSubject::StartL(const TDesC8& aBuffer) |
|
1136 { |
|
1137 SAknNotifierPackage<SAknKeyLockNotifierParams>* params |
|
1138 = ( SAknNotifierPackage<SAknKeyLockNotifierParams>*)aBuffer.Ptr(); |
|
1139 |
|
1140 if ( aBuffer.Length() < 0 || (TUint)aBuffer.Length() < sizeof(SAknNotifierPackage<SAknKeyLockNotifierParams>) |
|
1141 || params->iSignature != KAKNNOTIFIERSIGNATURE ) |
|
1142 { |
|
1143 User::Leave( KErrArgument ); |
|
1144 } |
|
1145 |
|
1146 switch (params->iParamData.iReason) |
|
1147 { |
|
1148 case ELockEnabled: |
|
1149 case ELockDisabled: |
|
1150 case EAllowNotifications: |
|
1151 case EStopNotifications: |
|
1152 case EOfferKeylock: |
|
1153 case ECancelAllNotifications: |
|
1154 case EEnableAutoLockEmulation: |
|
1155 case EDisableWithoutNote: |
|
1156 case EEnableWithoutNote: |
|
1157 break; |
|
1158 case EInquire: |
|
1159 { |
|
1160 iRetPckg().iEnabled = IsKeyLockEnabled(); |
|
1161 } |
|
1162 default: |
|
1163 break; |
|
1164 } |
|
1165 return iRetPckg; |
|
1166 } |
|
1167 |
|
1168 void CAknKeyLockNotifierSubject::StartL(const TDesC8& aBuffer, TInt /*aReplySlot*/, const RMessagePtr2& aMessage) |
|
1169 { |
|
1170 SAknNotifierPackage<SAknKeyLockNotifierParams>* params |
|
1171 = ( SAknNotifierPackage<SAknKeyLockNotifierParams>*)aBuffer.Ptr(); |
|
1172 |
|
1173 if ( aBuffer.Length() < 0 || (TUint)aBuffer.Length() < sizeof(SAknNotifierPackage<SAknKeyLockNotifierParams>) |
|
1174 || params->iSignature != KAKNNOTIFIERSIGNATURE ) |
|
1175 { |
|
1176 User::Leave( KErrArgument ); |
|
1177 } |
|
1178 |
|
1179 switch (params->iParamData.iReason) |
|
1180 { |
|
1181 case ELockEnabled: |
|
1182 DoEnableKeyLock(); |
|
1183 break; |
|
1184 case ELockDisabled: |
|
1185 DoDisableKeyLock(); |
|
1186 break; |
|
1187 case EAllowNotifications: |
|
1188 DoAllowNotifications(); |
|
1189 break; |
|
1190 case EStopNotifications: |
|
1191 DoStopNotifications(); |
|
1192 break; |
|
1193 case EOfferKeylock: |
|
1194 DoOfferKeyLock(); |
|
1195 break; |
|
1196 case ECancelAllNotifications: |
|
1197 DoCancelAllNotificatons(); |
|
1198 break; |
|
1199 case EEnableAutoLockEmulation: |
|
1200 NotifyStatusChange(EShowSoftNotifications); |
|
1201 LockKeys(ETrue); |
|
1202 break; |
|
1203 case EDisableWithoutNote: |
|
1204 UnlockKeys(); |
|
1205 break; |
|
1206 case EEnableWithoutNote: |
|
1207 if (!IsKeyLockEnabled()) |
|
1208 { |
|
1209 iKeyLockControl->EnableKeylock(EFalse); |
|
1210 } |
|
1211 break; |
|
1212 case ECommandFSWToHideApplication: |
|
1213 { |
|
1214 TInt uid(0); |
|
1215 TBool disable(EFalse); |
|
1216 RDesReadStream readStream(aBuffer); |
|
1217 readStream.ReadInt32L(); // signature |
|
1218 readStream.ReadInt32L(); // op |
|
1219 uid = readStream.ReadInt32L(); // uid |
|
1220 disable = readStream.ReadInt32L(); // enable / disable |
|
1221 STATIC_CAST(CEikServAppUi*,CEikonEnv::Static()->AppUi())->HideApplicationFromFswL(uid,disable); |
|
1222 } |
|
1223 break; |
|
1224 default: |
|
1225 break; |
|
1226 }; |
|
1227 |
|
1228 aMessage.Complete(KErrNone); |
|
1229 } |
|
1230 |
|
1231 void CAknKeyLockNotifierSubject::Cancel() |
|
1232 { |
|
1233 } |
|
1234 |
|
1235 TPtrC8 CAknKeyLockNotifierSubject::UpdateL(const TDesC8& aBuffer) |
|
1236 { |
|
1237 return TPtrC8(aBuffer); |
|
1238 } |
|
1239 |
|
1240 |
|
1241 |
|
1242 TBool CAknKeyLockNotifierSubject::IsKeyLockEnabled() |
|
1243 { |
|
1244 return iKeyLockControl->iKeyLockEnabled; |
|
1245 } |
|
1246 |
|
1247 TBool CAknKeyLockNotifierSubject::AllowNotifications() |
|
1248 { |
|
1249 return iAllowNotifications; |
|
1250 } |
|
1251 |
|
1252 |
|
1253 |
|
1254 void CAknKeyLockNotifierSubject::UnlockKeys() |
|
1255 { |
|
1256 if (IsKeyLockEnabled()) |
|
1257 { |
|
1258 iKeyLockControl->DisableKeylock(); |
|
1259 } |
|
1260 } |
|
1261 |
|
1262 void CAknKeyLockNotifierSubject::LockKeys(TBool aAutoLockOn) |
|
1263 { |
|
1264 |
|
1265 // Well have to disable keylock if we are changing autolock status |
|
1266 if ( iKeyLockControl->iKeyLockEnabled && |
|
1267 aAutoLockOn != iKeyLockControl->iAutolockEnabled ) |
|
1268 { |
|
1269 iKeyLockControl->DisableKeylock(); |
|
1270 } |
|
1271 |
|
1272 if (!IsKeyLockEnabled()) |
|
1273 { |
|
1274 iKeyLockControl->AutolockEnabled(aAutoLockOn); |
|
1275 |
|
1276 iKeyLockControl->EnableKeylock(); |
|
1277 } |
|
1278 } |
|
1279 |
|
1280 |
|
1281 void CAknKeyLockNotifierSubject::AddObserverL(MAknKeyLockObserver* aObserver) |
|
1282 { |
|
1283 #if defined(_DEBUG) |
|
1284 TInt count = iObserverList->Count(); |
|
1285 for (TInt ii=0; ii<count; ii++) |
|
1286 { |
|
1287 if ( ((*iObserverList)[ii]) == aObserver) |
|
1288 { |
|
1289 Panic(EAknPanicKeyLockObserverAlreadyExists); |
|
1290 } |
|
1291 } |
|
1292 #endif |
|
1293 iObserverList->AppendL(aObserver); |
|
1294 |
|
1295 // Make sure that the observer isn't obscuring the keylock CBA |
|
1296 ShowKeylockCba(); |
|
1297 } |
|
1298 |
|
1299 |
|
1300 void CAknKeyLockNotifierSubject::RemoveObserver(MAknKeyLockObserver* aObserver) |
|
1301 { |
|
1302 TInt count = iObserverList->Count(); |
|
1303 for (TInt ii=0; ii<count; ii++) |
|
1304 { |
|
1305 if ( ((*iObserverList)[ii]) == aObserver) |
|
1306 { |
|
1307 iObserverList->Delete(ii); |
|
1308 return; |
|
1309 } |
|
1310 } |
|
1311 #if defined(_DEBUG) |
|
1312 Panic(EAknPanicKeyLockObserverNotFound); |
|
1313 #endif |
|
1314 } |
|
1315 |
|
1316 |
|
1317 void CAknKeyLockNotifierSubject::ShowKeylockCba() |
|
1318 { |
|
1319 if (iKeyLockControl->iKeyLockEnabled) |
|
1320 { |
|
1321 iKeyLockControl->ShowKeylockCba(); |
|
1322 } |
|
1323 } |
|
1324 |
|
1325 void CAknKeyLockNotifierSubject::NotifyStatusChange(TKeyLockStatus aStatus) |
|
1326 { |
|
1327 TInt count = iObserverList->Count(); |
|
1328 for (TInt ii=count-1; ii>=0; ii--) |
|
1329 { |
|
1330 ((*iObserverList)[ii])->KeyLockStatusChange(aStatus); |
|
1331 } |
|
1332 } |
|
1333 |
|
1334 void CAknKeyLockNotifierSubject::DoAllowNotifications() |
|
1335 { |
|
1336 TBool lastvalue = iAllowNotifications; |
|
1337 iAllowNotifications = ETrue; |
|
1338 NotifyStatusChange(EKeyLockAllowNotifications); |
|
1339 if (!lastvalue) |
|
1340 { |
|
1341 CEikonEnv* env = CEikonEnv::Static(); |
|
1342 // To prevent this being called more than once |
|
1343 env->SetAutoForwarding(ETrue); |
|
1344 while (iActiveWindowCount) |
|
1345 { |
|
1346 env->BringForwards(ETrue); |
|
1347 iActiveWindowCount--; |
|
1348 } |
|
1349 env->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront); |
|
1350 env->BringForwards(ETrue); |
|
1351 env->BringForwards(EFalse); |
|
1352 |
|
1353 // Enable FSW |
|
1354 STATIC_CAST(CEikServAppUi*,env->AppUi())->SuppressAppSwitching(EFalse); |
|
1355 } |
|
1356 } |
|
1357 |
|
1358 void CAknKeyLockNotifierSubject::DoStopNotifications() |
|
1359 { |
|
1360 TBool lastvalue = iAllowNotifications; |
|
1361 iAllowNotifications = EFalse; |
|
1362 NotifyStatusChange(EKeyLockStopNotifications); |
|
1363 if (lastvalue) |
|
1364 { |
|
1365 // To prevent this being called more than once |
|
1366 // Count number of times BringForwards is needed to make EikSrvUi go to background |
|
1367 iActiveWindowCount = 0; |
|
1368 CEikonEnv* env = CEikonEnv::Static(); |
|
1369 TInt windowId = env->RootWin().Identifier(); |
|
1370 while (env->WsSession().GetWindowGroupOrdinalPriority(windowId) > 0) |
|
1371 { |
|
1372 iActiveWindowCount++; |
|
1373 env->BringForwards(EFalse); |
|
1374 } |
|
1375 env->SetAutoForwarding(EFalse); |
|
1376 STATIC_CAST(CEikServAppUi*,env->AppUi())->SuppressAppSwitching(ETrue); |
|
1377 } |
|
1378 } |
|
1379 |
|
1380 void CAknKeyLockNotifierSubject::DoCancelAllNotificatons() |
|
1381 { |
|
1382 // Used when end key is pressed, to allow phone app to cancel all |
|
1383 // notifications. Global notes / soft notifications that would |
|
1384 // not normally be shown (out of priority) are not cancelled |
|
1385 |
|
1386 if ( IsKeyLockEnabled() ) |
|
1387 { |
|
1388 return; |
|
1389 } |
|
1390 |
|
1391 NotifyStatusChange(EKeyLockCancelNotification); |
|
1392 |
|
1393 // Send cancel key event to all other notifications, and hope they cancel |
|
1394 |
|
1395 TRAPD(err, AknDialogShutter::ShutDialogsL(*CEikonEnv::Static())); |
|
1396 // Ignore error message - there's nothing more we can do |
|
1397 } |
|
1398 |
|
1399 |
|
1400 |
|
1401 void CAknKeyLockNotifierSubject::DoEnableKeyLock() |
|
1402 { |
|
1403 if (!IsKeyLockEnabled()) |
|
1404 { |
|
1405 iKeyLockControl->EnableKeylock(); |
|
1406 } |
|
1407 } |
|
1408 |
|
1409 void CAknKeyLockNotifierSubject::DoDisableKeyLock() |
|
1410 { |
|
1411 if (IsKeyLockEnabled()) |
|
1412 { |
|
1413 iKeyLockControl->DisableKeylock(); |
|
1414 // Attempt to display KeyActive note |
|
1415 iKeyLockControl->DisplayKeyActiveNote(); |
|
1416 } |
|
1417 else if (iKeyLockControl->iOfferLockEnabled) |
|
1418 { |
|
1419 // Remove the offer key lock CBA |
|
1420 iKeyLockControl->OfferTimerExpired(); |
|
1421 } |
|
1422 } |
|
1423 |
|
1424 |
|
1425 void CAknKeyLockNotifierSubject::DoOfferKeyLock() |
|
1426 { |
|
1427 if (!IsKeyLockEnabled()) |
|
1428 { |
|
1429 NotifyStatusChange(EKeyLockOffered); |
|
1430 iKeyLockControl->OfferKeylock(); |
|
1431 } |
|
1432 } |