terminalsecurity/SCP/SCPClient/src/SCPQueryDialog.cpp
branchRCL_3
changeset 25 b183ec05bd8c
parent 24 13d7c31c74e0
child 26 19bba8228ff0
equal deleted inserted replaced
24:13d7c31c74e0 25:b183ec05bd8c
     1 /*
     1 /*
     2 * Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    24 #include <avkon.rsg>
    24 #include <avkon.rsg>
    25 #include <SecUi.rsg>
    25 #include <SecUi.rsg>
    26 // Include the SecUi definitions
    26 // Include the SecUi definitions
    27 #include <secui.hrh>
    27 #include <secui.hrh>
    28 #include "SCPDebug.h"
    28 #include "SCPDebug.h"
    29 #include <SCPNotifier.rsg>
    29 #include <scpnotifier.rsg>
    30 // For Central Repository
    30 // For Central Repository
    31 #include <centralrepository.h>
    31 #include <centralrepository.h>
    32 #include <AknIncallBubbleNotify.h>
    32 #include <AknIncallBubbleNotify.h>
    33 #include <e32property.h>
    33 #include <e32property.h>
    34 #include <ctsydomainpskeys.h>
    34 #include <ctsydomainpskeys.h>
    35 #include "SCPCodePrivateCRKeys.h"
    35 #include "SCPCodePrivateCRKeys.h"
    36 #include <DevManInternalCRKeys.h>
       
    37 #include <featmgr.h>
       
    38 
       
    39 /*#ifdef _DEBUG
    36 /*#ifdef _DEBUG
    40 #define __SCP_DEBUG
    37 #define __SCP_DEBUG
    41 #endif // _DEBUG
    38 #endif // _DEBUG
    42 
    39 
    43 // Define this so the precompiler in CW 3.1 won't complain about token pasting,
    40 // Define this so the precompiler in CW 3.1 won't complain about token pasting,
    49 #else
    46 #else
    50 #define Dprint(a)
    47 #define Dprint(a)
    51 #endif // _DEBUG*/
    48 #endif // _DEBUG*/
    52 
    49 
    53 const TInt KSCPSpecialDeleteEvent( 63529 );
    50 const TInt KSCPSpecialDeleteEvent( 63529 );
    54 const TInt KLockedbyLawmo (30);
    51 
    55 // ================= MEMBER FUNCTIONS =======================
    52 // ================= MEMBER FUNCTIONS =======================
    56 //
    53 //
    57 // ----------------------------------------------------------
    54 // ----------------------------------------------------------
    58 // CSCPQueryDialog::CSCPQueryDialog()
    55 // CSCPQueryDialog::CSCPQueryDialog()
    59 // C++ constructor
    56 // C++ constructor
    61 //
    58 //
    62 CSCPQueryDialog::CSCPQueryDialog(   TDes& aDataText,
    59 CSCPQueryDialog::CSCPQueryDialog(   TDes& aDataText,
    63                                     RSCPClient::TSCPButtonConfig aButtonsShown, 
    60                                     RSCPClient::TSCPButtonConfig aButtonsShown, 
    64                                     TInt aMinLength,
    61                                     TInt aMinLength,
    65                                     TInt aMaxLength,
    62                                     TInt aMaxLength,
    66                                     TBool aECSSupport,
    63                                     TBool aECSSupport
    67                                     TKeypadContext aContextSensitive /*= EContextSensitive*/
       
    68                                     )
    64                                     )
    69             : CAknTextQueryDialog(aDataText, ENoTone),
    65             : CAknTextQueryDialog(aDataText, ENoTone),
    70 			  iMinLength(aMinLength),
    66 			  iMinLength(aMinLength),
    71 			  iMaxLength(aMaxLength),
    67 			  iMaxLength(aMaxLength),
    72 			  iValidTextLen( 0 ),
    68 			  iValidTextLen( 0 ),
    76 			  iEMCallActivated( EFalse ),
    72 			  iEMCallActivated( EFalse ),
    77 			  iShowingEMNumber( EFalse ),
    73 			  iShowingEMNumber( EFalse ),
    78 			  iPreviousCharacterWasInvalid( EFalse ),
    74 			  iPreviousCharacterWasInvalid( EFalse ),
    79 			  iPrioritySet( EFalse ),
    75 			  iPrioritySet( EFalse ),
    80 			  iPriorityDropped( EFalse ),
    76 			  iPriorityDropped( EFalse ),
    81 			  iLockedByLawMo( EFalse ),
    77 			  iKeyUsed ( NULL )
    82 			  iKeyUsed ( NULL ),
    78 	{		 
    83 			  iContextSensitive(aContextSensitive)
       
    84 	{
       
    85         def_mode = 0;
    79         def_mode = 0;
    86         iAppKey = 0;
    80         iAppKey = 0;
    87         iMode = KSCPModeNormal;
    81         iMode = KSCPModeNormal;
    88 	}
    82 	}
    89 	
    83 	
    95 //
    89 //
    96 CSCPQueryDialog::~CSCPQueryDialog()
    90 CSCPQueryDialog::~CSCPQueryDialog()
    97 	{
    91 	{
    98 	Dprint( (_L("CSCPQueryDialog::~CSCPQueryDialog()")) );
    92 	Dprint( (_L("CSCPQueryDialog::~CSCPQueryDialog()")) );
    99 	
    93 	
   100    if (iDeviceLockStatusObserver)
    94 	    if ( AknLayoutUtils::PenEnabled() )
   101         delete iDeviceLockStatusObserver;
    95         {
   102     
    96         TRAP_IGNORE ( SetIncallBubbleAllowedInUsualL( ETrue ) );
   103     if (iCallStatusObserver)
    97         }
   104         delete iCallStatusObserver;
    98 
   105 	    
    99 	
   106 	if (iFront)
   100 	if (iFront)
   107 		{
   101 		{
   108 		// Uncapture keys, if they were captured
   102 		// Uncapture keys, if they were captured
   109 		if ( iMode == KSCPModeRestricted )		
   103 		if ( iMode == KSCPModeRestricted )		
   110 			{
   104 			{
   111 			RWindowGroup& groupWin=iCoeEnv->RootWin();
   105 			RWindowGroup& groupWin=iCoeEnv->RootWin();
   112 			groupWin.CancelCaptureKeyUpAndDowns(iAppKey);
   106 			groupWin.CancelCaptureKeyUpAndDowns(iAppKey);
   113 			groupWin.CancelCaptureKeyUpAndDowns(iVoiceKey2);
   107 			groupWin.CancelCaptureKeyUpAndDowns(iVoiceKey2);
   114 			groupWin.CancelCaptureKey(iVoiceKey1);
   108 			groupWin.CancelCaptureKey(iVoiceKey1);						
   115 			}
   109 			}
   116 
   110 
   117 		if ( iPrioritySet )
   111 		if ( iPrioritySet )
   118 		    {
   112 		    {
   119     		// Return normal high-priority in case there are other notifiers active 
   113     		// Return normal high-priority in case there are other notifiers active 
   120 	    	// and were are not going to lose foregroung right after following call	
   114 	    	// and were are not going to lose foregroung right after following call	
   121 		    iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
   115 		    iEikonEnv->RootWin().SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront);
   122 		    }
   116 		    }
   123 		 						
   117 		 						
   124 		iEikonEnv->BringForwards(EFalse);	
   118 		iEikonEnv->BringForwards(EFalse);	
   125 		iEikonEnv->EikAppUi()->RemoveFromStack(this);
   119 		iEikonEnv->EikAppUi()->RemoveFromStack(this);
   126 		
   120 		
   134 		    delete iEcsDetector;
   128 		    delete iEcsDetector;
   135             }
   129             }
   136 		
   130 		
   137 		iFront = EFalse;
   131 		iFront = EFalse;
   138 		}
   132 		}
   139 }
   133 	
   140 
   134 	if (iDeviceLockStatusObserver)
   141 void CSCPQueryDialog :: PostLayoutDynInitL() {
   135 		delete iDeviceLockStatusObserver;
   142     Dprint( (_L("[CSCPQueryDialog]-> PostLayoutDynInitL() >>>") ));    
   136 		if (iCallStatusObserver)
   143     iDeviceLockStatusObserver = CSCPLockObserver::NewL(this);
   137 		delete iCallStatusObserver;
   144     iCallStatusObserver = CSCPLockObserver::NewL(this, ESecUiCallStateObserver);
   138 	}
   145     Dprint( (_L("[CSCPQueryDialog]-> PostLayoutDynInitL() <<<") ));
       
   146 }
       
   147 
       
   148 //
   139 //
   149 // ----------------------------------------------------------
   140 // ----------------------------------------------------------
   150 // CSCPQueryDialog::PreLayoutDynInitL()
   141 // CSCPQueryDialog::PreLayoutDynInitL()
   151 // Called by framework before dialog is shown 
   142 // Called by framework before dialog is shown 
   152 // ----------------------------------------------------------
   143 // ----------------------------------------------------------
   153 //
   144 //
   154 void CSCPQueryDialog :: PreLayoutDynInitL()
   145 void CSCPQueryDialog::PreLayoutDynInitL()
   155     {
   146     {
   156     Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL()") ));
   147     Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL()") ));
   157     
   148     
       
   149     /* CEikSecretEditor* queryControl = 
       
   150                     static_cast<CEikSecretEditor*>(
       
   151                         QueryControl()->ControlByLayoutOrNull( QueryControl()->QueryType() ) 
       
   152                        ); 
       
   153     queryControl->EnableSCT(EFalse); */
       
   154     
   158     CAknTextQueryDialog::PreLayoutDynInitL();
   155     CAknTextQueryDialog::PreLayoutDynInitL();
   159     
   156     
   160     CEikSecretEditor* queryControl = static_cast<CEikSecretEditor*>( 
       
   161                 QueryControl()->ControlByLayoutOrNull( QueryControl()->QueryType() ) );
       
   162 
       
   163     queryControl->SetFeature(CEikSecretEditor::ELockQuerySCT, ETrue);
       
   164 
       
   165     //disable in call bubble.
   157     //disable in call bubble.
   166     if ( AknLayoutUtils::PenEnabled() )
   158     if ( AknLayoutUtils::PenEnabled() )
   167         {
   159         {
   168         SetIncallBubbleAllowedInUsualL( EFalse );
   160         SetIncallBubbleAllowedInUsualL( EFalse );
   169         }
   161         }
       
   162 
   170     
   163     
   171     // Create the ECS detector object if required
   164     // Create the ECS detector object if required
   172     if ( iECSSupport )
   165     if ( iECSSupport )
   173         {
   166         {
   174         Dprint( (_L(" Creating ECS detector") ));
   167         Dprint( (_L(" Creating ECS detector") ));
   176         iEcsDetector->SetObserver( this );
   169         iEcsDetector->SetObserver( this );
   177         }    
   170         }    
   178     
   171     
   179     Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Set input mode") ));
   172     Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Set input mode") ));
   180         
   173         
   181     switch(iContextSensitive) {
   174     /* The default input mode of the lock code query must be set on the basis of the
   182         case EContextSensitive: {
   175     very first character of the current lock code. If the first character of the current
   183             Dprint(_L("[CSCPQueryDialog]-> iContextSensitive = EContextSensitive"));
   176     lock code is numeric, the default input mode will also be numeric. Otherwise, the 
   184             /* The default input mode of the lock code query must be set on the basis of the
   177     default input mode will be alphabetic */
   185             very first character of the current lock code. If the first character of the current
   178     
   186             lock code is numeric, the default input mode will also be numeric. Otherwise, the 
   179     CRepository* repository;
   187             default input mode will be alphabetic */
   180     repository = CRepository::NewL( KCRUidSCPParameters );
   188             
   181     CleanupStack::PushL( repository );
   189             CRepository* repository = CRepository :: NewL(KCRUidSCPParameters);
   182     
   190             CleanupStack :: PushL(repository);
   183     User::LeaveIfError(repository->Get( KSCPLockCodeDefaultInputMode , def_mode) );
   191             User :: LeaveIfError(repository->Get(KSCPLockCodeDefaultInputMode, def_mode));            
   184     
   192             CleanupStack :: PopAndDestroy(repository);
   185     CleanupStack::PopAndDestroy( repository );
   193 
   186     repository = NULL;   
   194             if (def_mode == 0) {
   187     
   195                 Dprint(_L("[CSCPQueryDialog]-> Context determined as Numeric"));
   188     if (def_mode == 0)
   196                 SetDefaultInputMode(EAknEditorNumericInputMode);
   189     	SetDefaultInputMode( EAknEditorNumericInputMode ); 
   197             }
   190     else
   198             else {
   191     	SetDefaultInputMode( EAknEditorSecretAlphaInputMode );
   199                 Dprint(_L("[CSCPQueryDialog]-> Context determined as Alphanumeric"));
       
   200                 SetDefaultInputMode(EAknEditorSecretAlphaInputMode);
       
   201             }
       
   202         }
       
   203         break;
       
   204         case ENumeric:
       
   205             Dprint(_L("[CSCPQueryDialog]-> iContextSensitive = ENumeric"));
       
   206             SetDefaultInputMode( EAknEditorNumericInputMode );
       
   207             break;
       
   208         case EAlphaNumeric:
       
   209             Dprint(_L("[CSCPQueryDialog]-> iContextSensitive = EAlphaNumeric"));
       
   210             SetDefaultInputMode( EAknEditorSecretAlphaInputMode );
       
   211             break;
       
   212     };
       
   213     
   192     
   214     // Set the mode, we use this to determine the functionality for special keys
   193     // Set the mode, we use this to determine the functionality for special keys
   215     if ( ( iButtons == RSCPClient::SCP_OK ) || ( iButtons == RSCPClient::SCP_OK_CANCEL ) )
   194     if ( ( iButtons == RSCPClient::SCP_OK ) || ( iButtons == RSCPClient::SCP_OK_CANCEL ) )
   216         {
   195         {
   217         // Normal mode
   196         // Normal mode
   276     TInt myWgId = iEikonEnv->RootWin().Identifier();
   255     TInt myWgId = iEikonEnv->RootWin().Identifier();
   277     
   256     
   278     TInt wgPrio = wsSession.GetWindowGroupOrdinalPriority(myWgId);
   257     TInt wgPrio = wsSession.GetWindowGroupOrdinalPriority(myWgId);
   279 	Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): wgPrio %d"),wgPrio ));
   258 	Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): wgPrio %d"),wgPrio ));
   280 	TInt var;
   259 	TInt var;
   281 	RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, var);
   260 	RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState,var);
   282 	Dprint((_L("CSCPQueryDialog::PreLayoutDynInitL(): EPSCTsyCallStateNone %d"), var));
   261 	Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): EPSCTsyCallStateNone %d"),var ));
   283 	
   262     // we are already on forgeround, need to update priority differently
   284     // If the call is made during device startup have the priority as normal
   263 	if (var != EPSCTsyCallStateNone)
   285     if (iECSSupport)
   264 	{
   286     {
   265 		// If the call is made during device startup have the priority as normal
   287         switch(var) {
   266 		if (iECSSupport && (iButtons == RSCPClient::SCP_OK))
   288             default:
   267 		{
   289             case EPSCTsyCallStateNone:
   268 		iEikonEnv->RootWin().SetOrdinalPosition(1,ECoeWinPriorityNormal);
   290                 Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Started Maximized...")));
   269 		}
   291                 iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront + 1);
   270 	
   292                 iPrioritySet = ETrue;
   271 	}
   293                 break;
   272     else if ((wgPrio == ECoeWinPriorityAlwaysAtFront)&&(iECSSupport))
   294             case EPSCTsyCallStateAlerting:
   273         {
   295             case EPSCTsyCallStateHold:
   274         Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): ECoeWinPriorityAlwaysAtFront+1") ));	
   296             case EPSCTsyCallStateRinging:
   275         iEikonEnv->RootWin().SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront+1);
   297             case EPSCTsyCallStateDialling:
   276         iPrioritySet = ETrue;
   298             case EPSCTsyCallStateAnswering:
   277         }
   299             case EPSCTsyCallStateConnected: {
   278         
   300                 switch(iButtons) {
       
   301                     case RSCPClient::SCP_OK:
       
   302                     case RSCPClient::SCP_OK_ETEL: {
       
   303                         Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Started Minimized...")));
       
   304                         iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityLow);
       
   305                         break;
       
   306                     }
       
   307                     default:
       
   308                         break;
       
   309                 }
       
   310             }
       
   311         }
       
   312     }
       
   313 	        
       
   314    // this must be done always to keep the reference count in synch  
   279    // this must be done always to keep the reference count in synch  
   315    // this does not have any effect if autoforwarding has not been set true (normal application.)
   280    // this does not have any effect if autoforwarding has not been set true (normal application.)
   316    iEikonEnv->BringForwards(ETrue, ECoeWinPriorityAlwaysAtFront+1);
   281    iEikonEnv->BringForwards(ETrue, ECoeWinPriorityAlwaysAtFront+1);
   317 
   282 
   318 	/// -- Change Window Priority for dialog and CBA 
   283 	/// -- Change Window Priority for dialog and CBA 
   319 	if (iECSSupport)
   284 	if (iECSSupport)
   320 		{
   285 		{
   321 		Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Changing Window Priority") ));
   286 		Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Changing Window Priority") ));			
   322 		DrawableWindow()->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
   287 		DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront);
   323 		ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
   288 		ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront); 	
   324 		}
   289 		}
   325 	else
   290 	else
   326 		{
   291 		{
   327 		DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityNormal + 1); //
   292 		DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityNormal); //
   328 		ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityNormal + 1);
   293 		ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,ECoeWinPriorityNormal); 	  	
   329 		}	
   294 		}	
   330 
   295 
   331 	Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Key sounds") ));
   296 	Dprint( (_L("CSCPQueryDialog::PreLayoutDynInitL(): Key sounds") ));
   332 	// Key sounds
   297 	// Key sounds
   333 
   298 
   336 	    	                                                             
   301 	    	                                                             
   337 	static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->BringToForeground();
   302 	static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->BringToForeground();
   338 	static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->LockContext();
   303 	static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->LockContext();
   339 
   304 
   340 	iFront = ETrue;
   305 	iFront = ETrue;
   341     TInt currentLawmoState(0); 
   306 	
   342     Dprint( (_L("CSCPQueryDialog::lawmo cenrep") ));
   307 	Dprint( (_L("CSCPQueryDialog::CSCPLockObserver") ));
   343     CRepository* crep = CRepository::NewLC( KCRUidDeviceManagementInternalKeys );
   308 	iDeviceLockStatusObserver = CSCPLockObserver::NewL(this);
   344     TInt reterr = crep->Get( KLAWMOPhoneLock, currentLawmoState ); 
   309 	iCallStatusObserver = CSCPLockObserver::NewL(this,ESecUiCallStateObserver);
   345     Dprint( (_L("CSCPQueryDialog::lawmo cenrep done") ));
   310 
   346 
   311 	}
   347     if(reterr != KErrNone) 
       
   348         {
       
   349         Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep lawmo, lErr=%d"), reterr);
       
   350         CleanupStack :: PopAndDestroy(crep);
       
   351         return;
       
   352         }
       
   353     
       
   354     if(currentLawmoState!=KLockedbyLawmo)
       
   355         {
       
   356         // Hide the OK key
       
   357         Dprint( (_L("CSCPQueryDialog::lawmo state !=30, dim key") ));
       
   358         iLockedByLawMo = ETrue;
       
   359         ButtonGroupContainer().MakeCommandVisible( EAknSoftkeyOk, ETrue );
       
   360         ButtonGroupContainer().DimCommand(EAknSoftkeyOk, ETrue);
       
   361         }	
       
   362 	CleanupStack::PopAndDestroy();
       
   363 }
       
   364 //
   312 //
   365 // ---------------------------------------------------------
   313 // ---------------------------------------------------------
   366 // CSCPQueryDialog::OfferKeyEventL
   314 // CSCPQueryDialog::OfferKeyEventL
   367 // called by framework when any key is pressed
   315 // called by framework when any key is pressed
   368 // ---------------------------------------------------------
   316 // ---------------------------------------------------------
   434 	        }
   382 	        }
   435 	    }
   383 	    }
   436 		
   384 		
   437     if ( aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter)
   385     if ( aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter)
   438         {
   386         {
   439     
   387         // Try to exit with OK as well
   440             if(QueryControl()->GetTextLength() > 0) {
   388         TryExitL(EAknSoftkeyOk);
   441                 // Try to exit with OK as well
   389         return EKeyWasConsumed;
   442                 TryExitL(EAknSoftkeyOk);                
       
   443             }
       
   444             
       
   445             return EKeyWasConsumed;
       
   446         }
   390         }
   447 
   391 
   448 	// app key
   392 	// app key
   449 	if (aKeyEvent.iScanCode == EStdKeyApplication0)
   393 	if (aKeyEvent.iScanCode == EStdKeyApplication0)
   450 		{
   394 		{
   471 	    {
   415 	    {
   472         //if (AknLayoutUtils::PenEnabled())
   416         //if (AknLayoutUtils::PenEnabled())
   473             {
   417             {
   474             if (iECSSupport)
   418             if (iECSSupport)
   475                 {
   419                 {
   476                 if ( iEcsDetector->State() == CAknEcsDetector::ECompleteMatch ||
   420                 if (iEcsDetector->State()== CAknEcsDetector::ECompleteMatch)
   477                      iEcsDetector->State() == CAknEcsDetector::EServiceNumMatch )
       
   478                     {
   421                     {
   479                     Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(): adding EKeyPhoneSend to detector")));
   422                     iEcsDetector->AddChar( (TText)(EKeyPhoneSend) );
   480                     
   423                     
   481                     switch(iButtons) {
       
   482                         case RSCPClient::SCP_OK:
       
   483                         case RSCPClient::SCP_OK_ETEL:
       
   484                             //Required only during device startup
       
   485                             iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityLow);
       
   486                             break;
       
   487                         default:
       
   488                             break;
       
   489                     }
       
   490                     
       
   491                     iEcsDetector->AddChar( (TText)(EKeyPhoneSend ) );
       
   492                     }   
   424                     }   
   493                 else
   425                 else
   494                     {
   426                     {
   495                     Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(): ShowWarningNoteL") ));
   427                     Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(): ShowWarningNoteL") ));
   496                     ShowWarningNoteL();
   428                     ShowWarningNoteL();
   566         // Character removed, make sure we're back on track,
   498         // Character removed, make sure we're back on track,
   567         // though likely only backspace was pressed
   499         // though likely only backspace was pressed
   568         iValidTextLen = QueryControl()->GetTextLength();
   500         iValidTextLen = QueryControl()->GetTextLength();
   569         }   
   501         }   
   570         
   502         
   571     //Additional modifier set by query dialog, while simulating event
   503 //Additional modifier set by query dialog, while simulating event
   572     // As raw key events are used to simulate, modifiers and scan codes cannot be set at a time
   504 // As raw key events are used to simulate, modifiers and scan codes cannot be set at a time
   573     // In the 1st event, modifiers are set and in subsequent event, scan codes will be set.
   505 // In the 1st event, modifiers are set and in subsequent event, scan codes will be set.
   574     if( aKeyEvent.iModifiers & EModifierNumLock &&
   506 if(aKeyEvent.iModifiers & EModifierNumLock &&
   575         aKeyEvent.iModifiers & EModifierKeypad && 
   507         aKeyEvent.iModifiers & EModifierKeypad && aKeyEvent.iModifiers & EModifierSpecial
   576         aKeyEvent.iModifiers & EModifierSpecial) {
   508 )
   577     
   509     {
   578         return EKeyWasConsumed;
   510    
       
   511     return EKeyWasConsumed;
   579     }
   512     }
   580     
       
   581     if ( iECSSupport )
   513     if ( iECSSupport )
   582         {
   514         {
   583         // Save the text
   515         // Save the text
   584         if ( aType == EEventKey ) 
   516         if ( aType == EEventKey ) 
   585             {
   517             {
   587             }
   519             }
   588         if ( aType == EEventKey ) 
   520         if ( aType == EEventKey ) 
   589             {
   521             {
   590             iEcsDetector->SetBuffer(iTextBuffer.Left(KAknEcsMaxMatchingLength));
   522             iEcsDetector->SetBuffer(iTextBuffer.Left(KAknEcsMaxMatchingLength));
   591             }
   523             }
   592         /*if ( aType == EEventKey )
   524         if ( aType == EEventKey )
   593             {
   525             {
   594         if ( iEMCallActivated )
   526         if ( iEMCallActivated )
   595             {
   527             {
   596             TryExitL( ESecUiEmergencyCall );
   528             TryExitL( ESecUiEmergencyCall );
   597             return EKeyWasConsumed;
   529             return EKeyWasConsumed;
   598             }
   530             }
   599         }*/
   531         }
   600         // Retrieve the editor control ptr, we know it is a secret editor..
   532         // Retrieve the editor control ptr, we know it is a secret editor..
   601         CEikSecretEditor* queryControl = static_cast<CEikSecretEditor*>( 
   533         CEikSecretEditor* queryControl = static_cast<CEikSecretEditor*>( 
   602             QueryControl()->ControlByLayoutOrNull( QueryControl()->QueryType() ) );                
   534             QueryControl()->ControlByLayoutOrNull( QueryControl()->QueryType() ) );                
   603         
   535         
   604          // Further check to ensure that the matched number is the entire buffer
   536          // Further check to ensure that the matched number is the entire buffer
   634             {
   566             {
   635             // The input doesn't match a Em-number
   567             // The input doesn't match a Em-number
   636             if ( queryControl != NULL )
   568             if ( queryControl != NULL )
   637                 {
   569                 {
   638                 queryControl->RevealSecretText( EFalse );
   570                 queryControl->RevealSecretText( EFalse );
   639 				
   571 			if(aType == EEventKey)
   640                 if(aType == EEventKey)
   572 			{
   641                 {
   573                 HBufC* cbaLabel = NULL;
   642                     HBufC* cbaLabel = NULL;
   574                 TRAPD ( err , cbaLabel= StringLoader::LoadL(R_SCPDIALOG_OK_TEXT) );
   643                     Dprint( (_L("CSCPQueryDialog::OfferKeyEventL(): R_SCPDIALOG_OK_TEXT") ));
   575                 if ( err == KErrNone )
   644                     TRAPD ( err , cbaLabel= StringLoader::LoadL(R_SCPDIALOG_OK_TEXT) );
   576                 {
   645                     if ( err == KErrNone )
   577 					if (isCallSoftkeyAdded)
   646                     {
   578 					{
   647                         if (isCallSoftkeyAdded)
   579 						isCallSoftkeyAdded = EFalse;
   648                         {
   580 						ButtonGroupContainer().RemoveCommandFromStack(0,EAknSoftkeyEmergencyCall);
   649                             isCallSoftkeyAdded = EFalse;
   581 					}
   650                             ButtonGroupContainer().RemoveCommandFromStack(0,EAknSoftkeyEmergencyCall);
   582 					else
   651                         }
   583 					{
   652                         else
   584 					ButtonGroupContainer().RemoveCommandFromStack(0,EAknSoftkeyOk);
   653                         {
   585 					}
   654                         ButtonGroupContainer().RemoveCommandFromStack(0,EAknSoftkeyOk);
   586                 TRAP ( err , ButtonGroupContainer().AddCommandToStackL(0,EAknSoftkeyOk,*cbaLabel) );
   655                         }
   587                 ButtonGroupContainer().DrawDeferred();
   656                     TRAP ( err , ButtonGroupContainer().AddCommandToStackL(0,EAknSoftkeyOk,*cbaLabel) );
   588                 delete cbaLabel;
   657 	                if(iLockedByLawMo)
   589 				}
   658 	                {
   590             	  }
   659 	                ButtonGroupContainer().MakeCommandVisible( EAknSoftkeyOk, ETrue );
       
   660 	                ButtonGroupContainer().DimCommand(EAknSoftkeyOk, ETrue);
       
   661 	                }
       
   662                     ButtonGroupContainer().DrawDeferred();
       
   663                     delete cbaLabel;
       
   664                     }
       
   665                 }
   591                 }
   666             }
   592             }
   667         }
   593         }                  
   668     }
       
   669      
   594      
   670     Dprint( (_L("CSCPQueryDialog::OfferKeyEventL() exiting") ));
   595     Dprint( (_L("CSCPQueryDialog::OfferKeyEventL() exiting") ));
   671               
   596               
   672     if ( ret == EKeyWasConsumed ) // The editor control used up this keyevent
   597     if ( ret == EKeyWasConsumed ) // The editor control used up this keyevent
   673         {
   598         {
   674         return ret;
   599         return ret;
   675         }         
   600         }         
   676     else
   601     else
   677         {
   602         {
   678         return CAknTextQueryDialog::OfferKeyEventL(aKeyEvent,aType);
   603         return CAknTextQueryDialog::OfferKeyEventL(aKeyEvent,aType);
   679         }  
       
   680     
       
   681     if(iLockedByLawMo)
       
   682 	    {
       
   683 	    Dprint( (_L("dim key hit 2") ));
       
   684 	    ButtonGroupContainer().MakeCommandVisible( EAknSoftkeyOk, ETrue );
       
   685 	    ButtonGroupContainer().DimCommand(EAknSoftkeyOk, ETrue);
       
   686         }    
   604         }    
   687 	}
   605 	}
   688 //
   606 //
   689 // ---------------------------------------------------------
   607 // ---------------------------------------------------------
   690 // CSCPQueryDialog::NeedToDismissQueryL()
   608 // CSCPQueryDialog::NeedToDismissQueryL()
   705 	{
   623 	{
   706 	
   624 	
   707 	     Dprint( (_L("CSCPQueryDialog::OkToExitL ( aButtonId :%d, "), aButtonId ));
   625 	     Dprint( (_L("CSCPQueryDialog::OkToExitL ( aButtonId :%d, "), aButtonId ));
   708 	TInt ret = EFalse;
   626 	TInt ret = EFalse;
   709 	
   627 	
   710 	switch(aButtonId) {
   628     if ( aButtonId == EAknSoftkeyOk )
   711 	    case EAknSoftkeyOk:
   629 		{	        		
   712 	    case EAknSoftkeyCancel:
   630 		Dprint( (_L("CSCPQueryDialog::OkToExitL - EAknSoftkeyOk") ));		
   713 	        ret = CAknTextQueryDialog::OkToExitL(aButtonId);
   631 		TInt textLength = QueryControl()->GetTextLength();
   714 	        break;
   632 		if ( textLength < iMinLength )
   715 	    case ESecUiEmergencyCall:
   633 			{	
   716 	    case EAknSoftkeyEmergencyCall: {
   634 			// The code was too short -> play error tone & clear editor
   717             Dprint( (_L("CSCPQueryDialog::OkToExitL(): adding EKeyPhoneSend to detector") ));
   635 			if ( textLength != 0 )
   718             
   636 				{
   719             switch(iButtons) {
   637 				CAknKeySoundSystem* soundSystem;
   720                 case RSCPClient::SCP_OK:
   638 	            if ( iEikonEnv->AppUi() )
   721                 case RSCPClient::SCP_OK_ETEL:
   639 		            {		            
   722                     //Required only during device startup
   640 		            soundSystem = static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds();
   723                     iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityLow);
   641 		            soundSystem->PlaySound( EAvkonSIDErrorTone );
   724                     break;
   642 		            } 
   725                 default:
   643 				QueryControl()->SetTextL( KNullDesC );
   726                     break;
   644 				iTextBuffer.Zero();
   727             }
   645 				iValidTextLen = 0;
   728             
   646 
   729             iEMCallActivated = ETrue;
   647                 // Hide the OK key
   730             iEcsDetector->AddChar( (TText)(EKeyPhoneSend ) );   
   648                 //ButtonGroupContainer().MakeCommandVisible( EAknSoftkeyOk, EFalse );
   731 	    }
   649                // ButtonGroupContainer().DimCommand(EAknSoftkeyOk, ETrue);
   732         break;
   650 
   733 	    default:
   651                 if (AknLayoutUtils::PenEnabled())
   734 	        break;	        
   652                     {
   735 	}
   653                     ButtonGroupContainer().DimCommand(EAknSoftkeyOk, ETrue);
   736 	
   654                     }
       
   655                 else
       
   656                     {
       
   657                     ButtonGroupContainer().MakeCommandVisible(EAknSoftkeyOk, EFalse);
       
   658                     }
       
   659                 }
       
   660             ret = EFalse;
       
   661             }	
       
   662 		else
       
   663 			{		
       
   664 			ret = CAknTextQueryDialog::OkToExitL(aButtonId);
       
   665 			}			    
       
   666 		}
       
   667 				
       
   668 	// Cancel is allowed, if the key is active
       
   669 	if ( aButtonId == EAknSoftkeyCancel )
       
   670 		{
       
   671     	Dprint( (_L("CSCPQueryDialog::OkToExitL EAknSoftkeyCancel ")) );	
       
   672 	    ret = CAknTextQueryDialog::OkToExitL(aButtonId);
       
   673 		}
       
   674 		
       
   675     // Emergency call, exit
       
   676     if ( aButtonId == ESecUiEmergencyCall )
       
   677         {
       
   678 		Dprint( (_L("CSCPQueryDialog::OkToExitL(): ESecUiEmergencyCall") ));
       
   679         ret = ETrue;
       
   680         }
       
   681     if (aButtonId == EAknSoftkeyEmergencyCall)
       
   682         {
       
   683         //add EKeyPhonesend to ecs detector. 
       
   684         ret = ETrue;
       
   685         Dprint( (_L("CSCPQueryDialog::OkToExitL(): adding EKeyPhoneSend to detector") ));
       
   686          iEcsDetector->AddChar( (TText)(EKeyPhoneSend ) );
       
   687         CAknTextQueryDialog::OkToExitL(aButtonId);
       
   688         }
       
   689    
   737 	Dprint( (_L("CSCPQueryDialog::OkToExitL() done") ));   
   690 	Dprint( (_L("CSCPQueryDialog::OkToExitL() done") ));   
   738 	return ret;
   691 	return ret;
   739 	}
   692 	}
   740 
   693 
   741 
   694 
   744 // 
   697 // 
   745 // ---------------------------------------------------------
   698 // ---------------------------------------------------------
   746 //
   699 //
   747 void CSCPQueryDialog::HandleEcsEvent(CAknEcsDetector* aDetector, 
   700 void CSCPQueryDialog::HandleEcsEvent(CAknEcsDetector* aDetector, 
   748                                      CAknEcsDetector::TState aUpdatedState)
   701                                      CAknEcsDetector::TState aUpdatedState)
   749     {
   702     {   
   750     (void)aDetector; // Not used
   703     (void)aDetector; // Not used
       
   704     
   751     TInt err;
   705     TInt err;
   752 
   706     if ( ( aUpdatedState == CAknEcsDetector::ECompleteMatchThenSendKey ) || 
   753     // Check if service calling feature is enabled
   707          ( aUpdatedState == CAknEcsDetector::ECallAttempted ) )
   754     TBool serviceCallEnabled( EFalse );
   708         {
   755     TRAP( err, FeatureManager::InitializeLibL() );
   709         // Call attempted, cancel the query
   756     if ( err == KErrNone )
   710         iEMCallActivated = ETrue; // OfferKeyEventL will close the dialog         
   757         {
   711         }        
   758         serviceCallEnabled = FeatureManager::FeatureSupported( 
   712     else if ( aUpdatedState == CAknEcsDetector::ECompleteMatch )    
   759             KFeatureIdFfServiceCallWhilePhoneLocked );
   713         {                
   760         FeatureManager::UnInitializeLib();
       
   761         }
       
   762 
       
   763     if ( aUpdatedState == CAknEcsDetector::ECompleteMatch ||
       
   764               ( serviceCallEnabled && aUpdatedState == CAknEcsDetector::EServiceNumMatch ) )
       
   765         {
       
   766         iShowingEMNumber = ETrue;
   714         iShowingEMNumber = ETrue;
   767         }
   715         }
   768     else if ( iShowingEMNumber )
   716     else if ( iShowingEMNumber )
   769         {
   717         {
   770         // Cancel Em-number display
   718         // Cancel Em-number display
   783                    );            
   731                    );            
   784             if ( queryControl != NULL )
   732             if ( queryControl != NULL )
   785                 {
   733                 {
   786                 queryControl->RevealSecretText( EFalse );
   734                 queryControl->RevealSecretText( EFalse );
   787                 }
   735                 }
   788 
   736            // }        
   789                 HBufC* cbaLabel = NULL;
   737                 HBufC* cbaLabel = NULL;
   790 				Dprint( (_L("CSCPQueryDialog::HandleEcsEvent(): R_SCPDIALOG_OK_TEXT") ));
   738 				Dprint( (_L("CSCPQueryDialog::HandleEcsEvent(): R_SCPDIALOG_OK_TEXT") ));
   791                 TRAP ( err, cbaLabel= StringLoader::LoadL(R_SCPDIALOG_OK_TEXT) );
   739                 TRAP ( err, cbaLabel= StringLoader::LoadL(R_SCPDIALOG_OK_TEXT) );
   792                 if ( err == KErrNone )
   740                 if ( err == KErrNone )
   793                 {
   741                 {
   799 						else
   747 						else
   800 						{
   748 						{
   801 							ButtonGroupContainer().RemoveCommandFromStack(0,EAknSoftkeyOk);
   749 							ButtonGroupContainer().RemoveCommandFromStack(0,EAknSoftkeyOk);
   802 						}
   750 						}
   803                 	TRAP ( err , ButtonGroupContainer().AddCommandToStackL(0, EAknSoftkeyOk, *cbaLabel) );
   751                 	TRAP ( err , ButtonGroupContainer().AddCommandToStackL(0, EAknSoftkeyOk, *cbaLabel) );
   804                     if(iLockedByLawMo)
       
   805                     {
       
   806                     ButtonGroupContainer().MakeCommandVisible( EAknSoftkeyOk, ETrue );
       
   807                     ButtonGroupContainer().DimCommand(EAknSoftkeyOk, ETrue);
       
   808                     }
       
   809                 	ButtonGroupContainer().DrawDeferred();
   752                 	ButtonGroupContainer().DrawDeferred();
   810                 	delete cbaLabel;
   753                 	delete cbaLabel;
   811                 }
   754                 }
   812             }
   755             }
   813         }
   756         }    
   814     }    
   757     }
   815  
   758  
   816 void CSCPQueryDialog::ShowWarningNoteL()
   759 void CSCPQueryDialog::ShowWarningNoteL()
   817     {
   760     {
   818     
   761     
   819     CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog();
   762     CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog();
   830     
   773     
   831 // -----------------------------------------------------------------------------
   774 // -----------------------------------------------------------------------------
   832 // CSCPQueryDialog::SetIncallBubbleAllowedInUsualL()
   775 // CSCPQueryDialog::SetIncallBubbleAllowedInUsualL()
   833 // -----------------------------------------------------------------------------
   776 // -----------------------------------------------------------------------------
   834 //
   777 //
   835 void CSCPQueryDialog :: SetIncallBubbleAllowedInUsualL(TBool aAllowed) {
   778 void CSCPQueryDialog::SetIncallBubbleAllowedInUsualL(TBool aAllowed)
       
   779     {
   836     CAknIncallBubble *incallBubble =  CAknIncallBubble::NewL();
   780     CAknIncallBubble *incallBubble =  CAknIncallBubble::NewL();
   837     CleanupStack :: PushL(incallBubble);
   781     CleanupStack::PushL(incallBubble);
   838     incallBubble->SetIncallBubbleAllowedInUsualL(aAllowed);
   782     incallBubble->SetIncallBubbleAllowedInUsualL( aAllowed );
   839     CleanupStack :: PopAndDestroy();
   783     CleanupStack::PopAndDestroy();
   840 }
       
   841 	
       
   842 void CSCPQueryDialog::TryCancelQueryL(TInt aReason) {
       
   843     Dprint( (_L("CSCPQueryDialog::TryCancelQueryL() >>>")) );
       
   844     
       
   845     switch(aReason) {
       
   846         case CSCPLockObserver :: EEnded:
       
   847             Dprint( (_L("CSCPQueryDialog::TryCancelQueryL(): Call ended, raising priority...")));
       
   848             
       
   849             switch(iButtons) {
       
   850                 case RSCPClient :: SCP_OK:
       
   851                 case RSCPClient :: SCP_OK_ETEL:
       
   852                     if(iEMCallActivated) {
       
   853                         TryExitL(EAknSoftkeyCancel);
       
   854                     }
       
   855                     else {
       
   856                         iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront + 1);
       
   857                         iPrioritySet = ETrue;
       
   858                     }
       
   859                     break;
       
   860                 default:
       
   861                     break;
       
   862             }
       
   863             break;
       
   864         case CSCPLockObserver :: EInProgress:
       
   865             Dprint( (_L("CSCPQueryDialog::TryCancelQueryL(): received call in progress event...")));
       
   866             TryExitL(EAknSoftkeyCancel);
       
   867             break;
       
   868         case ESecUiDeviceLocked:
       
   869             Dprint(_L("[CSCPQueryDialog]-> TryExitL 4"));
       
   870             TryExitL(EAknSoftkeyCancel);
       
   871             break;
       
   872         case ESecUiNone:
       
   873             Dprint(_L("[CSCPQueryDialog]-> TryExitL 5"));
       
   874             TryExitL(EAknSoftkeyOk);
       
   875             break;
       
   876         default:
       
   877             break;
       
   878     }
   784     }
   879 	
   785 	
   880     Dprint( (_L("CSCPQueryDialog::TryCancelQueryL() <<<")) );
   786 // Call from the SCPObserver
   881 }
   787 	
       
   788 void CSCPQueryDialog::TryCancelQueryL(TInt aReason)
       
   789     {
       
   790     Dprint( (_L("CSCPQueryDialog::TryCancelQueryL()")) );
       
   791     
       
   792 	if (EPSCTsyCallStateDisconnecting == aReason)
       
   793 	{
       
   794 	Dprint( (_L("CSCPQueryDialog::TryCancelQueryL() -SetOrdinalPosition ->0")) );
       
   795 	iEikonEnv->RootWin().SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront+1);
       
   796 	iPrioritySet = ETrue;
       
   797 	}
       
   798 	else
       
   799 	{
       
   800 	Dprint( (_L("CSCPQueryDialog::TryExitL(EAknSoftkeyCancel)")) );
       
   801     TryExitL(EAknSoftkeyCancel);
       
   802 	}
       
   803     }
       
   804 
       
   805     
   882 // End of file
   806 // End of file
       
   807