|
1 /* |
|
2 * Copyright (c) 2000 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: Implementation of terminalsecurity components |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <AknQueryDialog.h> |
|
19 #include "SCPQueryDialog.h" |
|
20 #include <eikseced.h> |
|
21 #include <aknsoundsystem.h> |
|
22 #include <StringLoader.h> |
|
23 #include <aknappui.h> |
|
24 #include <avkon.rsg> |
|
25 #include <SecUi.rsg> |
|
26 // Include the SecUi definitions |
|
27 #include <SecUi.hrh> |
|
28 #include "SCPDebug.h" |
|
29 #include <SCPNotifier.rsg> |
|
30 // For Central Repository |
|
31 #include <centralrepository.h> |
|
32 #include <AknIncallBubbleNotify.h> |
|
33 #include <e32property.h> |
|
34 #include <ctsydomainpskeys.h> |
|
35 #include "SCPCodePrivateCRKeys.h" |
|
36 /*#ifdef _DEBUG |
|
37 #define __SCP_DEBUG |
|
38 #endif // _DEBUG |
|
39 |
|
40 // Define this so the precompiler in CW 3.1 won't complain about token pasting, |
|
41 // the warnings are not valid |
|
42 #pragma warn_illtokenpasting off |
|
43 |
|
44 #ifdef __SCP_DEBUG |
|
45 #define Dprint(a) RDebug::Print##a |
|
46 #else |
|
47 #define Dprint(a) |
|
48 #endif // _DEBUG*/ |
|
49 |
|
50 const TInt KSCPSpecialDeleteEvent( 63529 ); |
|
51 |
|
52 // ================= MEMBER FUNCTIONS ======================= |
|
53 // |
|
54 // ---------------------------------------------------------- |
|
55 // CSCPQueryDialog::CSCPQueryDialog() |
|
56 // C++ constructor |
|
57 // ---------------------------------------------------------- |
|
58 // |
|
59 CSCPQueryDialog::CSCPQueryDialog( TDes& aDataText, |
|
60 RSCPClient::TSCPButtonConfig aButtonsShown, |
|
61 TInt aMinLength, |
|
62 TInt aMaxLength, |
|
63 TBool aECSSupport |
|
64 ) |
|
65 : CAknTextQueryDialog(aDataText, ENoTone), |
|
66 iMinLength(aMinLength), |
|
67 iMaxLength(aMaxLength), |
|
68 iValidTextLen( 0 ), |
|
69 iButtons( aButtonsShown ), |
|
70 iECSSupport( aECSSupport ), |
|
71 iEcsDetector( NULL ), |
|
72 iEMCallActivated( EFalse ), |
|
73 iShowingEMNumber( EFalse ), |
|
74 iPreviousCharacterWasInvalid( EFalse ), |
|
75 iPrioritySet( EFalse ), |
|
76 iPriorityDropped( EFalse ), |
|
77 iKeyUsed ( NULL ) |
|
78 { |
|
79 } |
|
80 |
|
81 // |
|
82 // ---------------------------------------------------------- |
|
83 // CSCPQueryDialog::~CSCPQueryDialog() |
|
84 // Destructor |
|
85 // ---------------------------------------------------------- |
|
86 // |
|
87 CSCPQueryDialog::~CSCPQueryDialog() |
|
88 { |
|
89 Dprint( (_L("CSCPQueryDialog::~CSCPQueryDialog()")) ); |
|
90 |
|
91 if ( AknLayoutUtils::PenEnabled() ) |
|
92 { |
|
93 TRAP_IGNORE ( SetIncallBubbleAllowedInUsualL( ETrue ) ); |
|
94 } |
|
95 |
|
96 |
|
97 if (iFront) |
|
98 { |
|
99 // Uncapture keys, if they were captured |
|
100 if ( iMode == KSCPModeRestricted ) |
|
101 { |
|
102 RWindowGroup& groupWin=iCoeEnv->RootWin(); |
|
103 groupWin.CancelCaptureKeyUpAndDowns(iAppKey); |
|
104 groupWin.CancelCaptureKeyUpAndDowns(iVoiceKey2); |
|
105 groupWin.CancelCaptureKey(iVoiceKey1); |
|
106 } |
|
107 |
|
108 if ( iPrioritySet ) |
|
109 { |
|
110 // Return normal high-priority in case there are other notifiers active |
|
111 // and were are not going to lose foregroung right after following call |
|
112 iEikonEnv->RootWin().SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront); |
|
113 } |
|
114 |
|
115 iEikonEnv->BringForwards(EFalse); |
|
116 iEikonEnv->EikAppUi()->RemoveFromStack(this); |
|
117 |
|
118 |
|
119 static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->ReleaseContext(); |
|
120 static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PopContext(); |
|
121 |
|
122 |
|
123 if ( iECSSupport ) |
|
124 { |
|
125 delete iEcsDetector; |
|
126 } |
|
127 |
|
128 iFront = EFalse; |
|
129 } |
|
130 |
|
131 if (iDeviceLockStatusObserver) |
|
132 delete iDeviceLockStatusObserver; |
|
133 if (iCallStatusObserver) |
|
134 delete iCallStatusObserver; |
|
135 } |
|
136 // |
|
137 // ---------------------------------------------------------- |
|
138 // CSCPQueryDialog::PreLayoutDynInitL() |
|
139 // Called by framework before dialog is shown |
|
140 // ---------------------------------------------------------- |
|
141 // |
|
142 void CSCPQueryDialog::PreLayoutDynInitL() |
|
143 { |
|
144 Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL()") )); |
|
145 |
|
146 /* CEikSecretEditor* queryControl = |
|
147 static_cast<CEikSecretEditor*>( |
|
148 QueryControl()->ControlByLayoutOrNull( QueryControl()->QueryType() ) |
|
149 ); |
|
150 queryControl->EnableSCT(EFalse); */ |
|
151 |
|
152 CAknTextQueryDialog::PreLayoutDynInitL(); |
|
153 |
|
154 //disable in call bubble. |
|
155 if ( AknLayoutUtils::PenEnabled() ) |
|
156 { |
|
157 SetIncallBubbleAllowedInUsualL( EFalse ); |
|
158 } |
|
159 |
|
160 |
|
161 // Create the ECS detector object if required |
|
162 if ( iECSSupport ) |
|
163 { |
|
164 Dprint( (_L(" Creating ECS detector") )); |
|
165 iEcsDetector = CAknEcsDetector::NewL(); |
|
166 iEcsDetector->SetObserver( this ); |
|
167 } |
|
168 |
|
169 Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Set input mode") )); |
|
170 |
|
171 /* The default input mode of the lock code query must be set on the basis of the |
|
172 very first character of the current lock code. If the first character of the current |
|
173 lock code is numeric, the default input mode will also be numeric. Otherwise, the |
|
174 default input mode will be alphabetic */ |
|
175 |
|
176 CRepository* repository; |
|
177 repository = CRepository::NewL( KCRUidSCPParameters ); |
|
178 CleanupStack::PushL( repository ); |
|
179 |
|
180 User::LeaveIfError(repository->Get( KSCPLockCodeDefaultInputMode , def_mode) ); |
|
181 |
|
182 CleanupStack::PopAndDestroy( repository ); |
|
183 repository = NULL; |
|
184 |
|
185 if (def_mode == 0) |
|
186 SetDefaultInputMode( EAknEditorNumericInputMode ); |
|
187 else |
|
188 SetDefaultInputMode( EAknEditorSecretAlphaInputMode ); |
|
189 |
|
190 // Set the mode, we use this to determine the functionality for special keys |
|
191 if ( ( iButtons == RSCPClient::SCP_OK ) || ( iButtons == RSCPClient::SCP_OK_CANCEL ) ) |
|
192 { |
|
193 // Normal mode |
|
194 iMode = KSCPModeNormal; |
|
195 } |
|
196 else |
|
197 { |
|
198 // Restricted mode, used for example for Etel-originated queries |
|
199 iMode = KSCPModeRestricted; |
|
200 } |
|
201 |
|
202 Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Set button config") )); |
|
203 // Set the softkey-configuration |
|
204 switch ( iButtons ) |
|
205 { |
|
206 case ( RSCPClient::SCP_OK ): |
|
207 // Flow through |
|
208 case ( RSCPClient::SCP_OK_ETEL ): |
|
209 { |
|
210 // Hide the Cancel-softkey |
|
211 ButtonGroupContainer().MakeCommandVisible( EAknSoftkeyCancel, EFalse ); |
|
212 break; |
|
213 } |
|
214 |
|
215 default: |
|
216 // Show both softkeys |
|
217 break; |
|
218 } |
|
219 |
|
220 QueryControl()->SetTextEntryLength( iMaxLength ); |
|
221 |
|
222 // Add this higher than the environment filter, otherwise |
|
223 // we cannot capture keys from the EikSrvUi KeyFilter. |
|
224 // Used because this query might be called from notifier |
|
225 |
|
226 if ( iMode == KSCPModeNormal ) |
|
227 { |
|
228 iEikonEnv->EikAppUi()->AddToStackL(this, |
|
229 ECoeStackPriorityEnvironmentFilter+100, |
|
230 ECoeStackFlagRefusesAllKeys); |
|
231 } |
|
232 else |
|
233 { |
|
234 iEikonEnv->EikAppUi()->AddToStackL(this, |
|
235 ECoeStackPriorityEnvironmentFilter+100, |
|
236 ECoeStackFlagRefusesFocus); |
|
237 } |
|
238 |
|
239 Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Capture keys") )); |
|
240 // Capture app, voice and end keys if necessary |
|
241 if ( iMode == KSCPModeRestricted ) |
|
242 { |
|
243 RWindowGroup& groupWin=iCoeEnv->RootWin(); |
|
244 // Capture app key |
|
245 iAppKey = groupWin.CaptureKeyUpAndDowns(EStdKeyApplication0, 0, 0); |
|
246 // capture voice key |
|
247 iVoiceKey1 = groupWin.CaptureKey(EKeySide,0,0); |
|
248 iVoiceKey2 = groupWin.CaptureKeyUpAndDowns(EStdKeyDevice6, 0, 0); |
|
249 } |
|
250 |
|
251 RWsSession& wsSession = iEikonEnv->WsSession(); |
|
252 TInt myWgId = iEikonEnv->RootWin().Identifier(); |
|
253 |
|
254 TInt wgPrio = wsSession.GetWindowGroupOrdinalPriority(myWgId); |
|
255 Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): wgPrio %d"),wgPrio )); |
|
256 TInt var; |
|
257 RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState,var); |
|
258 Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): EPSCTsyCallStateNone %d"),var )); |
|
259 // we are already on forgeround, need to update priority differently |
|
260 if (var != EPSCTsyCallStateNone) |
|
261 { |
|
262 |
|
263 iEikonEnv->RootWin().SetOrdinalPosition(1,ECoeWinPriorityNormal); |
|
264 } |
|
265 else if ((wgPrio == ECoeWinPriorityAlwaysAtFront)&&(iECSSupport)) |
|
266 { |
|
267 Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): ECoeWinPriorityAlwaysAtFront+1") )); |
|
268 iEikonEnv->RootWin().SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront+1); |
|
269 iPrioritySet = ETrue; |
|
270 } |
|
271 |
|
272 // this must be done always to keep the reference count in synch |
|
273 // this does not have any effect if autoforwarding has not been set true (normal application.) |
|
274 iEikonEnv->BringForwards(ETrue, ECoeWinPriorityAlwaysAtFront+1); |
|
275 |
|
276 /// -- Change Window Priority for dialog and CBA |
|
277 if (iECSSupport) |
|
278 { |
|
279 Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Changing Window Priority") )); |
|
280 DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront); |
|
281 ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront); |
|
282 } |
|
283 else |
|
284 { |
|
285 DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityNormal); // |
|
286 ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityNormal); |
|
287 } |
|
288 |
|
289 Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Key sounds") )); |
|
290 // Key sounds |
|
291 |
|
292 static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()-> |
|
293 PushContextL(R_AVKON_DEFAULT_SKEY_LIST); |
|
294 |
|
295 static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->BringToForeground(); |
|
296 static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->LockContext(); |
|
297 |
|
298 iFront = ETrue; |
|
299 |
|
300 Dprint( (_L("CSCPQueryDialog::CSCPLockObserver") )); |
|
301 iDeviceLockStatusObserver = CSCPLockObserver::NewL(this); |
|
302 iCallStatusObserver = CSCPLockObserver::NewL(this,ESecUiCallStateObserver); |
|
303 |
|
304 } |
|
305 // |
|
306 // --------------------------------------------------------- |
|
307 // CSCPQueryDialog::OfferKeyEventL |
|
308 // called by framework when any key is pressed |
|
309 // --------------------------------------------------------- |
|
310 // |
|
311 TKeyResponse CSCPQueryDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
312 { |
|
313 Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(%d, %d, %d)"), aKeyEvent.iScanCode, |
|
314 aKeyEvent.iCode, aType )); |
|
315 |
|
316 //Handling for Key up events for special characters |
|
317 if (aType == EEventKeyUp && iPriorityDropped && iKeyUsed |
|
318 == aKeyEvent.iScanCode) |
|
319 { |
|
320 DrawableWindow()->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront); |
|
321 ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition( |
|
322 0, ECoeWinPriorityAlwaysAtFront); |
|
323 iPriorityDropped = EFalse; |
|
324 iKeyUsed = NULL; |
|
325 Dprint((_L("CSCPQueryDialog::OfferKeyEventL(): Priority dropped"))); |
|
326 return EKeyWasConsumed; |
|
327 } |
|
328 else |
|
329 { |
|
330 if (iPriorityDropped && iKeyUsed != aKeyEvent.iScanCode |
|
331 && (aKeyEvent.iScanCode == EStdKeyDevice0 |
|
332 || aKeyEvent.iScanCode == EStdKeyDevice1 |
|
333 || aKeyEvent.iScanCode == EStdKeyDevice2 |
|
334 || aKeyEvent.iScanCode == EStdKeyDevice3)) |
|
335 { |
|
336 iPriorityDropped = EFalse; |
|
337 iKeyUsed = NULL; |
|
338 } |
|
339 |
|
340 } |
|
341 |
|
342 //Consume the characters which are typed before Key up events of special characters |
|
343 if (iPriorityDropped && iKeyUsed != NULL) |
|
344 { |
|
345 return EKeyWasConsumed; |
|
346 } |
|
347 |
|
348 |
|
349 // Check if the priority should be dropped, so that special dialogs can be shown |
|
350 if ( ( aType == EEventKeyDown ) && |
|
351 ( ( aKeyEvent.iScanCode == EStdKeyLeftShift ) || // Pen-key |
|
352 ( aKeyEvent.iScanCode == EStdKeyRightShift ) || // Pen-key |
|
353 ( aKeyEvent.iScanCode == EStdKeyLeftFunc ) || //Chr-key |
|
354 ( aKeyEvent.iScanCode == EStdKeyNkpAsterisk ) || // * - key |
|
355 ( aKeyEvent.iScanCode == '*' ) // * - key |
|
356 ) |
|
357 ) |
|
358 { |
|
359 iKeyUsed = aKeyEvent.iScanCode; |
|
360 DrawableWindow()->SetOrdinalPosition(0,0); |
|
361 ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,0); |
|
362 iPriorityDropped = ETrue; |
|
363 |
|
364 Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(): Priority dropped") )); |
|
365 } |
|
366 else |
|
367 { |
|
368 // Return priority, either no dialogs shown, or already exited. |
|
369 if ( iPriorityDropped ) |
|
370 { |
|
371 DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront); |
|
372 ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront); |
|
373 iPriorityDropped = EFalse; |
|
374 Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(): Priority re-raised") )); |
|
375 } |
|
376 } |
|
377 |
|
378 if ( aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) |
|
379 { |
|
380 // Try to exit with OK as well |
|
381 TryExitL(EAknSoftkeyOk); |
|
382 return EKeyWasConsumed; |
|
383 } |
|
384 |
|
385 // app key |
|
386 if (aKeyEvent.iScanCode == EStdKeyApplication0) |
|
387 { |
|
388 if ( iButtons == RSCPClient::SCP_OK_CANCEL ) |
|
389 { |
|
390 TryExitL(EAknSoftkeyCancel); |
|
391 return EKeyWasNotConsumed; |
|
392 } |
|
393 return EKeyWasConsumed; |
|
394 } |
|
395 |
|
396 // end key |
|
397 if ( (aKeyEvent.iCode == EKeyPhoneEnd) || (aKeyEvent.iCode == EKeyEscape) ) |
|
398 { |
|
399 if ( ( iButtons == RSCPClient::SCP_OK_CANCEL ) || |
|
400 ( iButtons == RSCPClient::SCP_OK_CANCEL_ETEL ) ) |
|
401 { |
|
402 TryExitL(EAknSoftkeyCancel); |
|
403 } |
|
404 return EKeyWasConsumed; |
|
405 } |
|
406 |
|
407 if (aKeyEvent.iCode == EKeyPhoneSend) |
|
408 { |
|
409 //if (AknLayoutUtils::PenEnabled()) |
|
410 { |
|
411 if (iECSSupport) |
|
412 { |
|
413 if (iEcsDetector->State()== CAknEcsDetector::ECompleteMatch) |
|
414 { |
|
415 iEcsDetector->AddChar( (TText)(EKeyPhoneSend) ); |
|
416 |
|
417 } |
|
418 else |
|
419 { |
|
420 Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(): ShowWarningNoteL") )); |
|
421 ShowWarningNoteL(); |
|
422 return EKeyWasConsumed; |
|
423 } |
|
424 } |
|
425 else //consume the key to prevent dialler from opening |
|
426 { |
|
427 Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(): EKeyPhoneSend :EKeyWasConsumed") )); |
|
428 return EKeyWasConsumed; |
|
429 } |
|
430 } |
|
431 } |
|
432 |
|
433 if ( ( aType == EEventKey ) && ( aKeyEvent.iCode == KSCPSpecialDeleteEvent ) ) |
|
434 { |
|
435 // This special event is sent to remove the previous character while "cycling" with |
|
436 // the numeric keys. Discard, if the previous character was already removed. |
|
437 if ( iPreviousCharacterWasInvalid ) |
|
438 { |
|
439 return EKeyWasConsumed; |
|
440 } |
|
441 } |
|
442 |
|
443 if ( ( aType == EEventKey ) && ( iECSSupport ) ) |
|
444 { |
|
445 // Reset the field text |
|
446 QueryControl()->SetTextL( iTextBuffer ); |
|
447 } |
|
448 |
|
449 TKeyResponse ret = QueryControl()->OfferKeyEventL( aKeyEvent, aType ); |
|
450 |
|
451 // Check that only alphanumeric letters are entered |
|
452 if ( ( QueryControl() != NULL ) && ( QueryControl()->GetTextLength() > iValidTextLen ) ) |
|
453 { |
|
454 // A new character was added to the editor |
|
455 iTmpBuffer.Zero(); |
|
456 QueryControl()->GetText( iTmpBuffer ); |
|
457 |
|
458 TChar newChar = iTmpBuffer[ iTmpBuffer.Length() - 1 ]; |
|
459 TChar::TCategory newCat = newChar.GetCategory(); |
|
460 if ( newChar.IsSpace() || newChar < 1 || newChar > 126 ) |
|
461 /* if ( !newChar.IsAlphaDigit() && newCat != TChar::ENdCategory ) */ |
|
462 { |
|
463 // Remove the last character, not allowed |
|
464 iTmpBuffer.SetLength( iTmpBuffer.Length() - 1 ); |
|
465 QueryControl()->SetTextL( iTmpBuffer ); |
|
466 |
|
467 iPreviousCharacterWasInvalid = ETrue; |
|
468 |
|
469 // Hide the OK key if the first character was invalid |
|
470 if ( iValidTextLen == 0 ) |
|
471 { |
|
472 if (AknLayoutUtils::PenEnabled()) |
|
473 { |
|
474 ButtonGroupContainer().DimCommand(EAknSoftkeyOk, ETrue); |
|
475 } |
|
476 else |
|
477 { |
|
478 ButtonGroupContainer().MakeCommandVisible(EAknSoftkeyOk, EFalse); |
|
479 } |
|
480 |
|
481 } |
|
482 } |
|
483 else |
|
484 { |
|
485 iValidTextLen++; |
|
486 iPreviousCharacterWasInvalid = EFalse; |
|
487 } |
|
488 } |
|
489 else if ( ( QueryControl() != NULL ) && ( QueryControl()->GetTextLength() < iValidTextLen ) ) |
|
490 { |
|
491 // Character removed, make sure we're back on track, |
|
492 // though likely only backspace was pressed |
|
493 iValidTextLen = QueryControl()->GetTextLength(); |
|
494 } |
|
495 |
|
496 //Additional modifier set by query dialog, while simulating event |
|
497 // As raw key events are used to simulate, modifiers and scan codes cannot be set at a time |
|
498 // In the 1st event, modifiers are set and in subsequent event, scan codes will be set. |
|
499 if(aKeyEvent.iModifiers & EModifierNumLock && |
|
500 aKeyEvent.iModifiers & EModifierKeypad && aKeyEvent.iModifiers & EModifierSpecial |
|
501 ) |
|
502 { |
|
503 |
|
504 return EKeyWasConsumed; |
|
505 } |
|
506 if ( iECSSupport ) |
|
507 { |
|
508 // Save the text |
|
509 if ( aType == EEventKey ) |
|
510 { |
|
511 QueryControl()->GetText( iTextBuffer ); |
|
512 } |
|
513 if ( aType == EEventKey ) |
|
514 { |
|
515 iEcsDetector->SetBuffer(iTextBuffer.Left(KAknEcsMaxMatchingLength)); |
|
516 } |
|
517 if ( aType == EEventKey ) |
|
518 { |
|
519 if ( iEMCallActivated ) |
|
520 { |
|
521 TryExitL( ESecUiEmergencyCall ); |
|
522 return EKeyWasConsumed; |
|
523 } |
|
524 } |
|
525 // Retrieve the editor control ptr, we know it is a secret editor.. |
|
526 CEikSecretEditor* queryControl = static_cast<CEikSecretEditor*>( |
|
527 QueryControl()->ControlByLayoutOrNull( QueryControl()->QueryType() ) ); |
|
528 |
|
529 // Further check to ensure that the matched number is the entire buffer |
|
530 // Get the matched text and see if is the same length as the current query length |
|
531 if ( iShowingEMNumber && (QueryControl()->GetTextLength()== iEcsDetector->CurrentMatch().Length())) |
|
532 { |
|
533 // The previous keyDown-event resulted in a complete Em-number match. |
|
534 |
|
535 // An emergency number is entered, show the text in the field |
|
536 QueryControl()->SetTextL( iEcsDetector->CurrentMatch() ); |
|
537 if ( queryControl != NULL ) |
|
538 { |
|
539 queryControl->RevealSecretText( ETrue ); |
|
540 HBufC* cbaLabel = NULL; |
|
541 Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(): R_AVKON_SOFTKEY_CALL_TEXT") )); |
|
542 TRAPD ( err, cbaLabel = |
|
543 StringLoader::LoadL( R_AVKON_SOFTKEY_CALL_TEXT) ); |
|
544 if ( err == KErrNone ) |
|
545 { |
|
546 TRAP ( err, ButtonGroupContainer().AddCommandToStackL( 0, EAknSoftkeyEmergencyCall, |
|
547 *cbaLabel) ); |
|
548 delete cbaLabel; |
|
549 } |
|
550 } |
|
551 } |
|
552 else |
|
553 { |
|
554 // The input doesn't match a Em-number |
|
555 if ( queryControl != NULL ) |
|
556 { |
|
557 queryControl->RevealSecretText( EFalse ); |
|
558 HBufC* cbaLabel = NULL; |
|
559 Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(): R_SCPDIALOG_OK_TEXT") )); |
|
560 TRAPD ( err , cbaLabel= StringLoader::LoadL(R_SCPDIALOG_OK_TEXT) ); |
|
561 if ( err == KErrNone ) |
|
562 { |
|
563 TRAP ( err , ButtonGroupContainer().AddCommandToStackL(0,EAknSoftkeyOk,*cbaLabel) ); |
|
564 ButtonGroupContainer().DrawDeferred(); |
|
565 delete cbaLabel; |
|
566 } |
|
567 } |
|
568 } |
|
569 } |
|
570 |
|
571 Dprint( (_L("CSCPQueryDialog::OfferKeyEventL() exiting") )); |
|
572 |
|
573 if ( ret == EKeyWasConsumed ) // The editor control used up this keyevent |
|
574 { |
|
575 return ret; |
|
576 } |
|
577 else |
|
578 { |
|
579 return CAknTextQueryDialog::OfferKeyEventL(aKeyEvent,aType); |
|
580 } |
|
581 } |
|
582 // |
|
583 // --------------------------------------------------------- |
|
584 // CSCPQueryDialog::NeedToDismissQueryL() |
|
585 // Handles '#' key called by CAknTextQueryDialog::OfferKeyEventL() |
|
586 // --------------------------------------------------------- |
|
587 // |
|
588 TBool CSCPQueryDialog::NeedToDismissQueryL(const TKeyEvent& /*aKeyEvent*/) |
|
589 { |
|
590 return EFalse; |
|
591 } |
|
592 // |
|
593 // --------------------------------------------------------- |
|
594 // CSCPQueryDialog::OkToExitL() |
|
595 // called by framework when the Softkey is pressed |
|
596 // --------------------------------------------------------- |
|
597 // |
|
598 TBool CSCPQueryDialog::OkToExitL(TInt aButtonId) |
|
599 { |
|
600 |
|
601 Dprint( (_L("CSCPQueryDialog::OkToExitL ( aButtonId :%d, "), aButtonId )); |
|
602 TInt ret = EFalse; |
|
603 |
|
604 if ( aButtonId == EAknSoftkeyOk ) |
|
605 { |
|
606 Dprint( (_L("CSCPQueryDialog::OkToExitL - EAknSoftkeyOk") )); |
|
607 TInt textLength = QueryControl()->GetTextLength(); |
|
608 if ( textLength < iMinLength ) |
|
609 { |
|
610 // The code was too short -> play error tone & clear editor |
|
611 if ( textLength != 0 ) |
|
612 { |
|
613 CAknKeySoundSystem* soundSystem; |
|
614 if ( iEikonEnv->AppUi() ) |
|
615 { |
|
616 soundSystem = static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds(); |
|
617 soundSystem->PlaySound( EAvkonSIDErrorTone ); |
|
618 } |
|
619 QueryControl()->SetTextL( KNullDesC ); |
|
620 iTextBuffer.Zero(); |
|
621 iValidTextLen = 0; |
|
622 |
|
623 // Hide the OK key |
|
624 //ButtonGroupContainer().MakeCommandVisible( EAknSoftkeyOk, EFalse ); |
|
625 // ButtonGroupContainer().DimCommand(EAknSoftkeyOk, ETrue); |
|
626 |
|
627 if (AknLayoutUtils::PenEnabled()) |
|
628 { |
|
629 ButtonGroupContainer().DimCommand(EAknSoftkeyOk, ETrue); |
|
630 } |
|
631 else |
|
632 { |
|
633 ButtonGroupContainer().MakeCommandVisible(EAknSoftkeyOk, EFalse); |
|
634 } |
|
635 } |
|
636 ret = EFalse; |
|
637 } |
|
638 else |
|
639 { |
|
640 ret = CAknTextQueryDialog::OkToExitL(aButtonId); |
|
641 } |
|
642 } |
|
643 |
|
644 // Cancel is allowed, if the key is active |
|
645 if ( aButtonId == EAknSoftkeyCancel ) |
|
646 { |
|
647 Dprint( (_L("CSCPQueryDialog::OkToExitL EAknSoftkeyCancel ")) ); |
|
648 ret = CAknTextQueryDialog::OkToExitL(aButtonId); |
|
649 } |
|
650 |
|
651 // Emergency call, exit |
|
652 if ( aButtonId == ESecUiEmergencyCall ) |
|
653 { |
|
654 Dprint( (_L("CSCPQueryDialog::OkToExitL(): ESecUiEmergencyCall") )); |
|
655 ret = ETrue; |
|
656 } |
|
657 if (aButtonId == EAknSoftkeyEmergencyCall) |
|
658 { |
|
659 //add EKeyPhonesend to ecs detector. |
|
660 ret = ETrue; |
|
661 Dprint( (_L("CSCPQueryDialog::OkToExitL(): adding EKeyPhoneSend to detector") )); |
|
662 iEcsDetector->AddChar( (TText)(EKeyPhoneSend ) ); |
|
663 CAknTextQueryDialog::OkToExitL(aButtonId); |
|
664 } |
|
665 |
|
666 Dprint( (_L("CSCPQueryDialog::OkToExitL() done") )); |
|
667 return ret; |
|
668 } |
|
669 |
|
670 |
|
671 // --------------------------------------------------------- |
|
672 // CSCPQueryDialog::HandleEcsEvent() |
|
673 // |
|
674 // --------------------------------------------------------- |
|
675 // |
|
676 void CSCPQueryDialog::HandleEcsEvent(CAknEcsDetector* aDetector, |
|
677 CAknEcsDetector::TState aUpdatedState) |
|
678 { |
|
679 (void)aDetector; // Not used |
|
680 |
|
681 TInt err; |
|
682 if ( ( aUpdatedState == CAknEcsDetector::ECompleteMatchThenSendKey ) || |
|
683 ( aUpdatedState == CAknEcsDetector::ECallAttempted ) ) |
|
684 { |
|
685 // Call attempted, cancel the query |
|
686 iEMCallActivated = ETrue; // OfferKeyEventL will close the dialog |
|
687 } |
|
688 else if ( aUpdatedState == CAknEcsDetector::ECompleteMatch ) |
|
689 { |
|
690 iShowingEMNumber = ETrue; |
|
691 } |
|
692 else if ( iShowingEMNumber ) |
|
693 { |
|
694 // Cancel Em-number display |
|
695 iShowingEMNumber = EFalse; |
|
696 |
|
697 if ( aUpdatedState == CAknEcsDetector::EEmpty ) |
|
698 { |
|
699 // Key timeout: OfferKeyEventL won't be called, so reset the display here |
|
700 TRAP( err, QueryControl()->SetTextL( iTextBuffer ) ); |
|
701 (void)err; |
|
702 |
|
703 // Retrieve the editor control ptr, we know it is a secret editor.. |
|
704 CEikSecretEditor* queryControl = |
|
705 static_cast<CEikSecretEditor*>( |
|
706 QueryControl()->ControlByLayoutOrNull( QueryControl()->QueryType() ) |
|
707 ); |
|
708 if ( queryControl != NULL ) |
|
709 { |
|
710 queryControl->RevealSecretText( EFalse ); |
|
711 } |
|
712 // } |
|
713 HBufC* cbaLabel = NULL; |
|
714 Dprint( (_L("CSCPQueryDialog::HandleEcsEvent(): R_SCPDIALOG_OK_TEXT") )); |
|
715 TRAP ( err, cbaLabel= StringLoader::LoadL(R_SCPDIALOG_OK_TEXT) ); |
|
716 if ( err == KErrNone ) |
|
717 { |
|
718 TRAP ( err , ButtonGroupContainer().AddCommandToStackL(0, EAknSoftkeyOk, *cbaLabel) ); |
|
719 ButtonGroupContainer().DrawDeferred(); |
|
720 delete cbaLabel; |
|
721 } |
|
722 } |
|
723 } |
|
724 } |
|
725 |
|
726 void CSCPQueryDialog::ShowWarningNoteL() |
|
727 { |
|
728 |
|
729 CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog(); |
|
730 noteDlg->PrepareLC(R_SCPDIALOG_EMERGENCYCALLS_ONLY); |
|
731 noteDlg->SetTimeout(CAknNoteDialog::ELongTimeout); |
|
732 noteDlg->SetTone(CAknNoteDialog::EErrorTone); |
|
733 |
|
734 noteDlg->DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront+1); // |
|
735 noteDlg->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront+1); |
|
736 |
|
737 noteDlg->RunLD(); |
|
738 |
|
739 } |
|
740 |
|
741 // ----------------------------------------------------------------------------- |
|
742 // CSCPQueryDialog::SetIncallBubbleAllowedInUsualL() |
|
743 // ----------------------------------------------------------------------------- |
|
744 // |
|
745 void CSCPQueryDialog::SetIncallBubbleAllowedInUsualL(TBool aAllowed) |
|
746 { |
|
747 CAknIncallBubble *incallBubble = CAknIncallBubble::NewL(); |
|
748 CleanupStack::PushL(incallBubble); |
|
749 incallBubble->SetIncallBubbleAllowedInUsualL( aAllowed ); |
|
750 CleanupStack::PopAndDestroy(); |
|
751 } |
|
752 |
|
753 // Call from the SCPObserver |
|
754 |
|
755 void CSCPQueryDialog::TryCancelQueryL(TInt aReason) |
|
756 { |
|
757 Dprint( (_L("CSCPQueryDialog::TryCancelQueryL()")) ); |
|
758 |
|
759 if (EPSCTsyCallStateDisconnecting == aReason) |
|
760 { |
|
761 Dprint( (_L("CSCPQueryDialog::TryCancelQueryL() -SetOrdinalPosition ->0")) ); |
|
762 iEikonEnv->RootWin().SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront+1); |
|
763 iPrioritySet = ETrue; |
|
764 } |
|
765 else |
|
766 { |
|
767 Dprint( (_L("CSCPQueryDialog::TryExitL(EAknSoftkeyCancel)")) ); |
|
768 TryExitL(EAknSoftkeyCancel); |
|
769 } |
|
770 } |
|
771 |
|
772 |
|
773 // End of file |
|
774 |