fep/aknfep/src/AknFepUiInputStateHalfQwerty.cpp
changeset 0 eb1f2e154e89
child 7 6defe5d1bd39
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:           
       
    15 *       Provides the TAknFepInputStateHalfQwerty methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "AknFepUiInputStateHalfQwerty.h"
       
    31 #include "AknFepUIManagerStateInterface.h"      //MAknFepUIManagerStateInterface
       
    32 #include "AknFepManagerUIInterface.h"           //MAknFepManagerUIInterface
       
    33 #include "AknFepCaseManager.h"
       
    34 
       
    35 #include <PtiEngine.h>
       
    36 #include <PtiDefs.h>
       
    37 #include <PtiKeyMappings.h>
       
    38 #include <centralrepository.h> 
       
    39 #include <AknFepInternalCRKeys.h>       
       
    40   
       
    41 
       
    42 TAknFepInputStateHalfQwerty::TAknFepInputStateHalfQwerty(MAknFepUIManagerStateInterface* aOwner)
       
    43     :TAknFepInputStateBase(aOwner)
       
    44     {
       
    45     iState = EInitial;
       
    46     iData = 0;
       
    47     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    48     ptiengine->ClearCurrentWord();
       
    49     ptiengine->SetInputMode(EPtiEngineHalfQwerty);
       
    50     }
       
    51 
       
    52 TBool TAknFepInputStateHalfQwerty::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    53     {
       
    54     TBool ret = EFalse;
       
    55     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    56     if( ptiengine == NULL || aKey == EStdKeyNull || 
       
    57     		aKey == EStdKeyF21 || aKey == EKeyF21 || aKey == EKeyF20 || aKey == EKeyF19 ||
       
    58 		aKey == EStdKeyLeftArrow || aKey == EStdKeyRightArrow || aKey == EStdKeyDownArrow || aKey == EStdKeyUpArrow )
       
    59         return ret;
       
    60     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    61     CAknFepFnKeyManager::TFnKeyState fnKeyState  = fepMan->FnKeyState();    
       
    62     TPtiTextCase CurCase = ptiengine->Case();
       
    63 
       
    64     if (iData && (iData != aKey) )
       
    65         {
       
    66         ptiengine->CancelTimerActivity();        
       
    67         fepMan->CommitInlineEditL();      
       
    68         ptiengine->ClearCurrentWord();        
       
    69         fepMan->ClearFlag(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction);
       
    70         iData = 0;
       
    71         }
       
    72     // if it is a long key press of the punctuation key,
       
    73 		 
       
    74 	  if( aLength == ELongKeyPress && aKey == EStdKeyFullStop)
       
    75 	  	{
       
    76 	  	// Commit the current word and then do the usual stuff
       
    77 	  	ptiengine->CancelTimerActivity();	  		  	
       
    78 	  	}
       
    79 	if( !fepMan->EditorHasFreeSpace() && !iData )
       
    80 		{
       
    81 		// Do not proceed as we have reached max limit and timer has expired
       
    82 		ptiengine->CancelTimerActivity();
       
    83 		ptiengine->ClearCurrentWord();        
       
    84         fepMan->ClearFlag(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction);
       
    85         return 0;
       
    86         }
       
    87     
       
    88     if( EStdKeyEnter == aKey )
       
    89 		{
       
    90 		// Asynchronous case update.
       
    91 		fepMan->SimulateKeyEventL(EKeyF19);
       
    92 		return 0;
       
    93 		}
       
    94 		
       
    95     if (!iOwner->PtiEngine()->IsValidKey((TPtiKey)aKey))
       
    96         {     
       
    97         iData = 0;
       
    98         ChrKeyTimerExpired();
       
    99         fepMan->ClearFlag(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction);        
       
   100         ptiengine->CancelTimerActivity();		                
       
   101         return ret;
       
   102         }
       
   103   TPtrC text;
       
   104   /*
       
   105         if ( fepMan->IsOnlyNumericPermitted() )    
       
   106             {
       
   107             ptiengine->CancelTimerActivity();       
       
   108             text.Set(ptiengine->AppendKeyPress((TPtiKey)aKey)); 
       
   109             TPtrC numericChars(KAllAllowedNumericChars, KNumAllowedIdleNumericChars);   
       
   110             if (text.Length() && numericChars.Locate(text[0]) != KErrNotFound)
       
   111                 {
       
   112                 TBuf<1> chr;    
       
   113                 chr.Append(text[0]);
       
   114                 fepMan->NewCharacterL(chr);             
       
   115                 ptiengine->CancelTimerActivity();        
       
   116                 fepMan->CommitInlineEditL();      
       
   117                 ptiengine->ClearCurrentWord();                                      
       
   118                 }
       
   119             
       
   120             return ETrue;
       
   121             }
       
   122  */
       
   123 #ifdef __REVERSE_FN_KEY_SUPPORTED
       
   124 	TInt origLanguage = ptiengine->CurrentLanguage()->LanguageCode();
       
   125     TPtiEngineInputMode origInputMode = ptiengine->InputMode();
       
   126     TBool languageChanged = EFalse;
       
   127 		
       
   128     // In reverse fn key mapping filter the char applicable for
       
   129     // Numeric editor.
       
   130     if( fepMan->IsOnlyNumericPermitted() )
       
   131         {
       
   132         
       
   133         if( EStdKeyLeftFunc == aKey )
       
   134             {
       
   135             TCallBack timerExpire(TimerExpire, this);
       
   136             fepMan->MultitapThroughSCTCharL(timerExpire); 
       
   137             return ETrue;
       
   138             }
       
   139         else 
       
   140             {
       
   141             ChrKeyTimerExpired();
       
   142             }
       
   143         if( !fepMan->IsValidCharForNumericInFnReverseL( aKey, iOwner->PtiEngine()->Case() ) )
       
   144             {
       
   145             if(CheckHasValidNumerKeyMappedL(aKey,languageChanged))
       
   146                 return ETrue;
       
   147             }
       
   148         }
       
   149     
       
   150 #endif //__REVERSE_FN_KEY_SUPPORTED
       
   151 
       
   152 
       
   153 //    if( aLength == EShortKeyPress )
       
   154         {
       
   155         /*
       
   156         if (aKey == EStdKeySpace && (fnKeyState == CAknFepFnKeyManager::EFnKeyNone))
       
   157             {
       
   158             _LIT(KSpaceCharacter, " ");
       
   159             text.Set(KSpaceCharacter);        
       
   160             }        
       
   161         else*/ 
       
   162    if( aKey == EStdKeySpace && fepMan->FnKeyState() == CAknFepFnKeyManager::EFnKeyNone)
       
   163     		{
       
   164     		_LIT(KSpace," "); 
       
   165 			fepMan->StartInlineEditL();
       
   166             fepMan->UpdateInlineEditL(KSpace,0);
       
   167             fepMan->CommitInlineEditL();
       
   168         	return ETrue;        		
       
   169     		}    
       
   170         else
       
   171             {
       
   172             TBool isCharacter = ETrue;
       
   173             if (!iData)
       
   174                 {
       
   175                 isCharacter = IsCharacterKey(aKey);
       
   176                 }
       
   177             HandleCaseChange(aKey, isCharacter);        
       
   178             CurCase = ptiengine->Case();
       
   179 
       
   180             if(( (fepMan->IsHybridAplhaEditor() && !fepMan->IsHybridAlphaModeChangedtoAplhanumeric())
       
   181                     || fepMan->IsPhoneNumberEditor() )
       
   182                     && fepMan->FnKeyState() != CAknFepFnKeyManager::EFnKeyNone)
       
   183             {            
       
   184             if( EStdKeyLeftFunc == aKey )
       
   185                 {
       
   186                 TCallBack timerExpire(TimerExpire, this);
       
   187                 fepMan->MultitapThroughSCTCharL(timerExpire); 
       
   188                 return ETrue;
       
   189                 }
       
   190             else
       
   191                 { 
       
   192                 ChrKeyTimerExpired();
       
   193                 }	
       
   194 
       
   195             if(!fepMan->IsPhoneNumberEditor())
       
   196 			{
       
   197 				TChar validchr;
       
   198 				if(!CheckHasValidNumerKeyMappedL(aKey,languageChanged))
       
   199 					ptiengine->SetCase((TPtiTextCase)EPtiCaseLower);
       
   200 				else
       
   201 					return ETrue;
       
   202 			}
       
   203             }
       
   204             if(!iData)
       
   205             	{
       
   206             	// this should be called after case change 
       
   207             	// so that the shift state is taken care of
       
   208             	#ifdef __HALF_QWERTY_PREVIEW_PANE
       
   209                 	fepMan->PreparePreviewPaneL((TPtiKey)aKey);
       
   210 				#endif //__HALF_QWERTY_PREVIEW_PANE
       
   211             	}
       
   212 
       
   213             // Over ride the case changes, force to fnLower for 
       
   214             // long key press.
       
   215             if( aLength == ELongKeyPress && aKey == EStdKeyFullStop)
       
   216             	{
       
   217             	iOwner->PtiEngine()->SetCase( EPtiCaseFnLower );
       
   218             	}
       
   219             	            
       
   220             // Get keymapping from PtiEngine.                
       
   221             text.Set(ptiengine->AppendKeyPress((TPtiKey)aKey));
       
   222 
       
   223             // send the text to be highlighted here
       
   224             #ifdef __HALF_QWERTY_PREVIEW_PANE
       
   225             	fepMan->ShowPaneL();
       
   226 			#endif //__HALF_QWERTY_PREVIEW_PANE            	
       
   227             }
       
   228             
       
   229         if (text.Length() > 0)        
       
   230              {               
       
   231             TBuf<1> chr;    
       
   232             chr.Append(text[0]);
       
   233             if( fepMan->IsOnlyNumericPermitted() 
       
   234             	&& !iOwner->FepMan()->IsValidCharInNumericEditorL(text[0]) )
       
   235             	{
       
   236             	ptiengine->CancelTimerActivity(); 
       
   237             	
       
   238 #ifdef __REVERSE_FN_KEY_SUPPORTED            	
       
   239 	            if(languageChanged)
       
   240     	            {
       
   241         	        ptiengine->ActivateLanguageL(origLanguage);
       
   242             	    ptiengine->SetInputMode(origInputMode );            		
       
   243                 	}            
       
   244 #endif                		
       
   245 	            if(fepMan->IsHybridAplhaEditor() && !fepMan->IsHybridAlphaModeChangedtoAplhanumeric())
       
   246 					ptiengine->SetCase(CurCase);      		
       
   247             	return ETrue;
       
   248             	}            
       
   249             if(fepMan->IsHybridAplhaEditor() && !fepMan->IsHybridAlphaModeChangedtoAplhanumeric()
       
   250                                             && fepMan->FnKeyState() != CAknFepFnKeyManager::EFnKeyNone)
       
   251                 {
       
   252                 if(!iOwner->FepMan()->IsValidCharInNumericEditorL(text[0]) )
       
   253                     {
       
   254                     ptiengine->CancelTimerActivity(); 
       
   255                                     
       
   256 #ifdef __REVERSE_FN_KEY_SUPPORTED               
       
   257                     if(languageChanged)
       
   258                         {
       
   259                         ptiengine->ActivateLanguageL(origLanguage);
       
   260                         ptiengine->SetInputMode(origInputMode );                    
       
   261                         }            
       
   262 #endif  
       
   263                     }
       
   264             	}
       
   265             fepMan->NewCharacterL(chr);
       
   266             
       
   267             if ( aKey == EStdKeyEnter)
       
   268                 {
       
   269                 fepMan->CommitInlineEditL();      
       
   270                 ptiengine->ClearCurrentWord();                
       
   271                 iData = 0;
       
   272                 }
       
   273             else            
       
   274                 {    
       
   275                 iData = aKey;            
       
   276                 fepMan->SetFlag(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction);                   
       
   277                 }
       
   278                                   
       
   279             }
       
   280         if((text.Length() > 0) || (IsKeymapped(aKey)))
       
   281             {
       
   282             ret = ETrue;
       
   283             }
       
   284         TBuf<32> mappedCharacters;
       
   285         iOwner->PtiEngine()->MappingDataForKey((TPtiKey)aKey, mappedCharacters, iOwner->PtiEngine()->Case());
       
   286         if( mappedCharacters.Length() < 2 )
       
   287             {
       
   288             ptiengine->CancelTimerActivity(); 
       
   289             if( aLength == EShortKeyPress )
       
   290             	{            	
       
   291             	SetShortKeyPressText(text);
       
   292             	}
       
   293             }
       
   294 		if(fepMan->IsHybridAplhaEditor() && !fepMan->IsHybridAlphaModeChangedtoAplhanumeric())
       
   295 			ptiengine->SetCase(CurCase);
       
   296     }
       
   297     
       
   298 // else
       
   299 // //Long key press
       
   300 //    {
       
   301 //        if (aKey == EStdKeyEnter)
       
   302 //            {
       
   303             // PtiEngine does not have mapping for the enter key.
       
   304 //            const TText KAknFEPLineFeedSymbol = 0x21B2;
       
   305 //            TBuf<1> lineFeed;
       
   306 //            lineFeed.Zero();
       
   307 //            lineFeed.Append(KAknFEPLineFeedSymbol);
       
   308 //            text.Set(lineFeed);
       
   309 //            }
       
   310 //        else
       
   311 //            {
       
   312 //            TBool isCharacter = ETrue;
       
   313 //            if (!iData)
       
   314 //            {
       
   315 //            isCharacter = IsCharacterKey(aKey);
       
   316 //            }
       
   317 //            //HandleCaseChange(aKey, isCharacter);
       
   318 //            //Forcing Fn mode for long key press
       
   319 //            
       
   320 //            /*
       
   321 //            //Start of Option-1
       
   322 //            ptiengine->SetCase(EPtiCaseFnLower);
       
   323 //            text.Set(ptiengine->AppendKeyPress((TPtiKey)aKey));
       
   324 //            // End of Option-1
       
   325 //            */
       
   326 //
       
   327 //            //Start of Option-2
       
   328 //            //To do: Space key lower case being mapped and removing 
       
   329 //            //hard coding of space in UI State.
       
   330 //            TBuf<5> allFnMappedCharacters;
       
   331 //            ptiengine->MappingDataForKey((TPtiKey)aKey, allFnMappedCharacters, EPtiCaseFnLower);
       
   332 //            text.Set(allFnMappedCharacters);
       
   333 //            // End of Option-2
       
   334 //
       
   335 //            }
       
   336 //        #ifdef __HALF_QWERTY_PREVIEW_PANE
       
   337 //        // in any case hide the preview pane
       
   338 //        	fepMan->HidePane();
       
   339 //		#endif //__HALF_QWERTY_PREVIEW_PANE
       
   340 //            
       
   341 //        if (text.Length() > 0)        
       
   342 //            {               
       
   343 //            TBuf<1> chr;    
       
   344 //            chr.Append(text[0]);
       
   345 //            fepMan->NewCharacterL(chr);
       
   346 //            fepMan->CommitInlineEditL();      
       
   347 //            ptiengine->ClearCurrentWord();                
       
   348 //            iData = 0;
       
   349 //            /*
       
   350 //            if (aKey == EStdKeyEnter)
       
   351 //                {
       
   352 //                fepMan->CommitInlineEditL();      
       
   353 //          ptiengine->ClearCurrentWord();                
       
   354 //          iLastKey = 0;
       
   355 //                }
       
   356 //            else            
       
   357 //                {    
       
   358 //                iLastKey = aKey;            
       
   359 //                fepMan->SetFlag(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction);                   
       
   360 //                }
       
   361 //            */
       
   362 //                                  
       
   363 //            ret = ETrue;
       
   364 //            }
       
   365 //        else
       
   366 //            {
       
   367 //            // text.Length is zero. Handle long key.
       
   368 //            if( aKey == EStdKeyFullStop )
       
   369 //                {
       
   370 //                ptiengine->CancelTimerActivity();
       
   371 //                }
       
   372 //            }
       
   373 //        }
       
   374     if( aKey!=EStdKeyBackspace && fnKeyState  != CAknFepFnKeyManager::EFnKeyNone)
       
   375     	return ETrue;
       
   376         
       
   377     if(ptiengine->IsValidKey((TPtiKey)aKey))
       
   378        	ret = ETrue;
       
   379         
       
   380 #ifdef __REVERSE_FN_KEY_SUPPORTED
       
   381 	if(languageChanged)
       
   382     	{
       
   383         ptiengine->ActivateLanguageL(origLanguage);
       
   384         ptiengine->SetInputMode(origInputMode );            		
       
   385         }    
       
   386 #endif  
       
   387   
       
   388     return ret;
       
   389     }
       
   390 
       
   391 // Functions from MPtiObserver interface
       
   392 void TAknFepInputStateHalfQwerty::KeyTimerExpired()
       
   393     {
       
   394     if (iData)
       
   395         {
       
   396         MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   397         TRAP_IGNORE(fepMan->CommitInlineEditL())
       
   398 
       
   399         CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   400         ptiengine->ClearCurrentWord();
       
   401         #ifdef __HALF_QWERTY_PREVIEW_PANE
       
   402         	fepMan->HidePane();
       
   403 		#endif //__HALF_QWERTY_PREVIEW_PANE
       
   404         iData = 0;
       
   405         fepMan->ClearFlag(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction);
       
   406         CAknFepFnKeyManager::TFnKeyState fnKeyState  = fepMan->FnKeyState();    
       
   407         if( !fepMan->IsFlagSet( CAknFepManager::EFlagLongShiftKeyPress ) )
       
   408             {
       
   409             if(fnKeyState == CAknFepFnKeyManager::EFnKeyNext)
       
   410                 fepMan->SetFnKeyState(CAknFepFnKeyManager::EFnKeyNone);
       
   411             }
       
   412         }  
       
   413     }
       
   414     
       
   415 void TAknFepInputStateHalfQwerty::HandleCaseChange(TInt /*aKey*/, TBool aIsCharacter)
       
   416     {
       
   417     // Punctuation key multitapping should not change case
       
   418     if( iData )
       
   419         return;
       
   420     
       
   421     TPtiTextCase caseMode = EPtiCaseLower;
       
   422 
       
   423     if (aIsCharacter)
       
   424         {
       
   425         if( iData == 0 || !( iOwner->FepMan()->IsOnlyNumericPermitted()  ) )
       
   426             {
       
   427             // use the Edwin case only when timer expires
       
   428             // To handle cases like insert fn character empty editor
       
   429             // followed by alpa character
       
   430             switch(iOwner->CaseMan()->CurrentCase())
       
   431                {
       
   432                 case EAknEditorLowerCase:
       
   433                     caseMode = EPtiCaseLower;
       
   434                     break;            
       
   435                 case EAknEditorTextCase:
       
   436                 case EAknEditorUpperCase:
       
   437                    caseMode = EPtiCaseUpper;
       
   438                default:
       
   439                    break;
       
   440                }
       
   441             }
       
   442         else
       
   443             {
       
   444             // user is still multitapping, use the existing PtiEngine case
       
   445             caseMode = iOwner->PtiEngine()->Case();
       
   446             }
       
   447         }
       
   448         
       
   449     TPtiTextCase shiftedCase = caseMode;
       
   450     
       
   451     TPtiTextCase curCase = iOwner->PtiEngine()->Case();
       
   452     if(curCase == EPtiCaseFnUpper || curCase == EPtiCaseFnLower)
       
   453         return;
       
   454 
       
   455     if ( iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) && 
       
   456         ( !aIsCharacter|| iOwner->CaseMan()->IsAbleChangeCase() ) )
       
   457         {
       
   458         // Case mode is changed to opposite because shift key is/was pressed and
       
   459         // in case of character key case changes are allowed. In case of
       
   460         // number or special key, shift mode is used always when 
       
   461         // shift key is pressed
       
   462         
       
   463                 
       
   464         // clear this flag so that the shift key mode gets reset 
       
   465         // when shift key up event is received
       
   466         
       
   467         iOwner->FepMan()->ClearFlag(CAknFepManager::EFlagNoActionDuringShiftKeyPress);
       
   468         
       
   469 		// Do not toggle case while multitapping
       
   470         if( !iData )
       
   471         	{
       
   472         	switch ( caseMode )
       
   473 	            {
       
   474 	            case EPtiCaseUpper:
       
   475 	                shiftedCase = EPtiCaseLower;
       
   476 	                break;
       
   477 	            case EPtiCaseLower:
       
   478 	                shiftedCase = EPtiCaseUpper;
       
   479 	                break;
       
   480 	            default:
       
   481 	                break;
       
   482 	            }
       
   483         	}
       
   484         }
       
   485         
       
   486     if ( iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed) )
       
   487         {
       
   488         // Chr key is pressed down. Chr mode is used.
       
   489         if (shiftedCase == EPtiCaseLower)
       
   490             {
       
   491             shiftedCase = EPtiCaseChrLower;
       
   492             }
       
   493         else if (shiftedCase == EPtiCaseUpper)
       
   494             {
       
   495             shiftedCase = EPtiCaseChrUpper;
       
   496             }
       
   497         }
       
   498     iOwner->FepMan()->ClearFlag( CAknFepManager::EFlagNoActionDuringChrKeyPress );
       
   499     iOwner->PtiEngine()->SetCase(shiftedCase);
       
   500     
       
   501     }
       
   502 
       
   503 TBool TAknFepInputStateHalfQwerty::IsCharacterKey(const TInt aKey)
       
   504     {
       
   505     CPtiEngine* ptiengine = iOwner->PtiEngine();       
       
   506     // Max length doesn't matter because we'll need only the first character.    
       
   507     TBuf<KMaxName> lowerdata;   
       
   508     
       
   509     ptiengine->MappingDataForKey((TPtiKey)aKey, lowerdata, EPtiCaseLower);        
       
   510     if (lowerdata.Length() > 0)
       
   511         {
       
   512         TChar lower = lowerdata[0];        
       
   513         TUint upper = lower.GetUpperCase();
       
   514     
       
   515         if ( TUint(lower) != upper )
       
   516             {
       
   517             return ETrue;   
       
   518             }
       
   519         }
       
   520    
       
   521      return EFalse;
       
   522     }       
       
   523 TBool TAknFepInputStateHalfQwerty::TryGetValidCharForKey(const TInt& aKey, TChar& aChar)
       
   524     {    
       
   525     if( ! TryGetValidCharForKeyAndCase( aKey, aChar, EPtiCaseFnLower) )
       
   526         {
       
   527         if(! TryGetValidCharForKeyAndCase( aKey, aChar, EPtiCaseUpper))
       
   528             {
       
   529             if(! TryGetValidCharForKeyAndCase( aKey, aChar, EPtiCaseLower))
       
   530                 {
       
   531                 return EFalse;
       
   532                 }
       
   533             }
       
   534         }
       
   535     return ETrue;
       
   536     }
       
   537 TBool TAknFepInputStateHalfQwerty::TryGetValidCharForKeyAndCase(const TInt& aKey, TChar& aChar, TPtiTextCase aCase)
       
   538     {
       
   539     TBuf<KMaxName> mappedCharacters;
       
   540 
       
   541     iOwner->PtiEngine()->MappingDataForKey((TPtiKey)aKey, mappedCharacters, aCase);        
       
   542     TRAP_IGNORE(
       
   543     for (TInt i = 0; i < mappedCharacters.Length(); i++ )
       
   544         {
       
   545         if( iOwner->FepMan()->IsValidCharInNumericEditorL( mappedCharacters[i] ) )
       
   546             {
       
   547             aChar = mappedCharacters[i];
       
   548             return ETrue;
       
   549             } 
       
   550         }); 
       
   551     return EFalse;
       
   552     }
       
   553 TInt TAknFepInputStateHalfQwerty::TimerExpire(TAny* aPtr)
       
   554     {
       
   555     reinterpret_cast<TAknFepInputStateHalfQwerty*>(aPtr)->ChrKeyTimerExpired();
       
   556     return 1;
       
   557     }
       
   558 TInt TAknFepInputStateHalfQwerty::ChrKeyTimerExpired()
       
   559     {
       
   560     if(iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction))
       
   561         {
       
   562         // this function is only called for number only editors 
       
   563 
       
   564         TRAP_IGNORE(iOwner->FepMan()->CommitInlineEditL());
       
   565         }    
       
   566     return 1;
       
   567     }
       
   568 
       
   569 
       
   570 TBool TAknFepInputStateHalfQwerty::IsKeymapped(TInt aKey)
       
   571     {
       
   572     TBuf<20> mapData;
       
   573     TBool ret = EFalse;
       
   574     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   575     for(TInt count=0;count<EPtiCaseMax;count++)
       
   576         {
       
   577         ptiengine->MappingDataForKey(static_cast<TPtiKey>(aKey), mapData, static_cast<TPtiTextCase> (count)); 
       
   578         if(mapData.Length())
       
   579             {
       
   580             ret = ETrue;
       
   581             break;
       
   582             }
       
   583         }
       
   584     return ret;
       
   585     }
       
   586 
       
   587 TBool TAknFepInputStateHalfQwerty::CheckHasValidNumerKeyMappedL(TInt aKey, TBool &aLangChanged)
       
   588     {
       
   589     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
   590     TInt origLanguage = ptiengine->CurrentLanguage()->LanguageCode();
       
   591     TPtiEngineInputMode origInputMode = ptiengine->InputMode();
       
   592     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   593     
       
   594     //TBool languageChanged = EFalse;
       
   595     
       
   596                 TChar chr;
       
   597 
       
   598                 if( ! TryGetValidCharForKey(aKey, chr) )
       
   599                     {
       
   600                     // If the key in not valid char in the current input language in Fn reverse mode,
       
   601                     // then we will check if against English language. And if its valid then we will
       
   602                     // insert the char based out of key for English input language and revert back 
       
   603                     // the change in input language at the end.
       
   604 
       
   605                     if(ptiengine->CurrentLanguage()->LanguageCode() == ELangEnglish)
       
   606                         {
       
   607                         if(fepMan->IsOnlyNumericPermitted())
       
   608                             return ETrue;
       
   609                         else
       
   610                             return EFalse;
       
   611                         }
       
   612 
       
   613                     aLangChanged = ETrue;
       
   614                     ptiengine->ActivateLanguageL(ELangEnglish);
       
   615                     ptiengine->SetInputMode(EPtiEngineHalfQwerty); 
       
   616 
       
   617                     if( !fepMan->IsValidCharForNumericInFnReverseL(aKey, iOwner->PtiEngine()->Case()) )
       
   618                         {
       
   619                         if( ! TryGetValidCharForKey(aKey, chr) )
       
   620                             {
       
   621                             ptiengine->ActivateLanguageL(origLanguage);
       
   622                             ptiengine->SetInputMode(origInputMode );  
       
   623                             if(fepMan->IsHybridAplhaEditor() && !fepMan->IsHybridAlphaModeChangedtoAplhanumeric())    
       
   624                                 return EFalse;
       
   625                             else
       
   626                                 return ETrue;
       
   627                             }
       
   628                         else
       
   629                             {
       
   630                             if(aLangChanged)
       
   631                                 {
       
   632                                 ptiengine->ActivateLanguageL(origLanguage);
       
   633                                 ptiengine->SetInputMode(origInputMode );                    
       
   634                                 }
       
   635 
       
   636                             TBuf<1> buf;    
       
   637                             buf.Append(chr);
       
   638                             fepMan->NewCharacterL(buf);
       
   639                             fepMan->CommitInlineEditL();      
       
   640                             ptiengine->ClearCurrentWord();                
       
   641                             iData = 0;
       
   642                             ptiengine->CancelTimerActivity();
       
   643                             return ETrue;                       
       
   644                             }
       
   645                         }
       
   646                     }
       
   647                 else
       
   648                     {
       
   649                     if(aLangChanged)
       
   650                         {
       
   651                         ptiengine->ActivateLanguageL(origLanguage);
       
   652                         ptiengine->SetInputMode(origInputMode );                    
       
   653                         }
       
   654 
       
   655                     TBuf<1> buf;    
       
   656                     buf.Append(chr);
       
   657                     fepMan->NewCharacterL(buf);
       
   658                     fepMan->CommitInlineEditL();      
       
   659                     ptiengine->ClearCurrentWord();                
       
   660                     iData = 0;
       
   661                     ptiengine->CancelTimerActivity();
       
   662                     return ETrue;
       
   663                     }
       
   664                 
       
   665     
       
   666     return EFalse;
       
   667     }	
       
   668 // End of file