fep/aknfep/src/AknFepManager.cpp
branchRCL_3
changeset 44 ecbabf52600f
child 46 bd83ceabce89
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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 CAknFepManager methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    30 #include <uikon/eikdefmacros.h>
       
    31 #endif
       
    32 #include "AknFepManager.h"
       
    33 #include "AknFepManagerInterface.h" // MAknFepManagerInterface
       
    34 #include "aknfepindicator.h"
       
    35 #include "AknFepPanic.h"
       
    36 #include "AknFepKeyCatcher.h"
       
    37 #include "AknFepGlobalEnums.h"
       
    38 #include "AknFepCaseManager.h"
       
    39 #include "AknFepHashKeyManager.h"
       
    40 #include "AknFepSharedDataInterface.h"
       
    41 #include "AknFepInlineTextDecorator.h"
       
    42 #include "AknFepUiManagerBase.h"
       
    43 #include "AknFepUiManagerChinese.h"
       
    44 #include "AknFepUiManagerWestern.h"
       
    45 
       
    46 #include "AknFepPluginManager.h"
       
    47 #include "AknFepUiIndicInputManager.h"
       
    48 #include "AknFepUiIndicEnums.h"
       
    49 #include <AknFepUIStylusPopupMenu.h>
       
    50 #include "aknfepuispellinputpane.h"
       
    51 
       
    52 #include <bautils.h>
       
    53 #include <coeaui.h>                 //CCoeAppUi
       
    54 #include <aknedsts.h>               //CAknEdwinState
       
    55 #include <uikon.hrh>                //keys
       
    56 #include <aknenv.h>                 //CAknEnv
       
    57 #include <PtiEngine.h>              //CPtiEngine
       
    58 #include <AknJapaneseReading.h>     //CAknJapaneseReading
       
    59 #include <featmgr.h>                //FeatureManager
       
    60 #include <e32base.h>                //CPeriodic
       
    61 #include <PtiDefs.h>                //keys
       
    62 #include <fepipext.h>               //MCoeFepSpecificExtensions
       
    63 
       
    64 #include <aknsoundsystem.h>
       
    65 #include <avkon.rsg>
       
    66 #include <avkon.hrh>
       
    67 
       
    68 #include <tagma.h>
       
    69 #include <frmtview.h>
       
    70 #include <aknedformaccessor.h>
       
    71 
       
    72 #include <aknfep.rsg>
       
    73 #include <avkon.mbg>
       
    74 
       
    75 #include "aknconsts.h"
       
    76 #include <aknfeppeninputenums.h>
       
    77 #include <eikproc.h>                // User Dictionary
       
    78 #include <eikapp.h>                 // User Dictionary
       
    79 
       
    80 #include <StringLoader.h>
       
    81 
       
    82 #include <centralrepository.h>
       
    83 #include <AknFepInternalCRKeys.h>
       
    84 #include <settingsinternalcrkeys.h>
       
    85 #include <AknUtils.h>
       
    86 #include <AknCustomCursorSupport.h>
       
    87 #include <PtiKeyMappings.h>
       
    88 #include <aknfeppeninputimeplugin.h>
       
    89 #include <peninputcmd.h>
       
    90 
       
    91 #include <AknSettingCache.h>
       
    92 #include <peninputgsinterface.h>
       
    93 #include <aknextendedinputcapabilities.h>
       
    94 #include <AvkonInternalCRKeys.h>
       
    95 #include <hlplch.h>
       
    96 #include <aknfepdocumentnavigation.h>
       
    97 
       
    98 #include <eikcolib.h>
       
    99 #include <akntoolbar.h>
       
   100 
       
   101 #include <eikfrlbd.h>
       
   102 #include <eikccpu.h>
       
   103 #include <aknappui.h>
       
   104 #include <apgwgnam.h>
       
   105 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   106 #include "AknFepUiWordPopupContent.h"
       
   107 #include "AknFepFnKeyManager.h"
       
   108 #include <csxhelp/cp.hlp.hrh> 
       
   109 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   110 
       
   111 #ifdef RD_TACTILE_FEEDBACK
       
   112 #include <touchfeedback.h>
       
   113 #endif //RD_TACTILE_FEEDBACK
       
   114 #include "AknFepThaiSCTSelector.h"
       
   115 
       
   116 //the follow 10 filse include for phrase creation
       
   117 #include <bamdesca.h>
       
   118 #include <eikspane.h> //CEikStatusPane 
       
   119 #include <akntitle.h> //CAknTitlePane 
       
   120 #include <akntoolbar.h> //CAknToolBar 
       
   121 #include <aknappui.h>
       
   122 #include "AknFep.hrh"
       
   123 #include "aknfepuserdbdlg.h"
       
   124 #include "aknfepzhuyinkeyhandler.h"
       
   125 #include "AknFepZhuyinAnalyser.h"
       
   126 #include "AknFepZhuyinAnalyserDb.h"
       
   127 
       
   128 #include <aknnavi.h> 
       
   129 #include <aknnavide.h> 
       
   130 
       
   131 #include <eikedwin.h>
       
   132 #include <aknCharMap.h>
       
   133 
       
   134 #include <AknFepInternalPSKeys.h>
       
   135 #include <e32property.h>
       
   136 #include <AknDef.h>
       
   137 
       
   138 const TInt KSelectItemSize(10);
       
   139 _LIT(KAknFepResourceFileName, "z:\\resource\\fep\\aknfep.rsc");
       
   140 
       
   141 #define text_to_field_mode_hash_key ';'
       
   142 #define iAvkonAppUi ((CAknAppUi*)CEikonEnv::Static()->EikAppUi())
       
   143 #define __SHIFT_KEY_LOOP
       
   144 
       
   145 // EAknEditorNativeKeysNumberModeKeymap is used for example in MFNE editors.
       
   146 #define EAknEditorNativeKeysNumberModeKeymap EAknEditorReservedInternalUseKeymap
       
   147 
       
   148 // UID of user dictionary application
       
   149 const TUid KUidUserDictApp = {0x101F8645};
       
   150 
       
   151 const TText KAknFEPLineFeedSymbol = 0x21B2;
       
   152 const TText KAknFEPMirroredLineFeedSymbol = 0x21B3;
       
   153 const TText KAknFEPZeroKey = 0x30;
       
   154 
       
   155 // inline text decoration potentially adds 2 directional markers for every "real" character. Buffer needs to be 3 x predictive engine bufsize
       
   156 const TInt KMaxInlineEditSize( 3 * CAknFepManager::EMaximumFepWordLength );
       
   157 
       
   158 // Maximum number of chunks to navigate throught attempting to get to the visual end of a selection.
       
   159 // Since chunks are arranged only within a line, this should be more than the number of chunks likely in
       
   160 // a single line of text
       
   161 const TInt KMaxChunkWalkIterations(20);
       
   162 
       
   163 // This command is is used for setting empty CBA.
       
   164 const TInt KNullCommandId = 0;
       
   165 
       
   166 _LIT_SECURE_ID(KPhoneSecureId, 0x100058b3);
       
   167 
       
   168 #ifdef RD_HINDI_PHONETIC_INPUT
       
   169 
       
   170 const TUint KQuestionMark = 0x003F;
       
   171 
       
   172 #endif
       
   173 
       
   174 // Ccpu key events. 
       
   175 /*As part of build warnings commenting this perticular code it might require when touch is enabled.
       
   176 const TKeyEvent KEditorCopyEvent = {3, 67, 161, 0};  // Ctrl + C
       
   177 const TKeyEvent KEditorCutEvent  = {24, 88, 161, 0}; // Ctrl + X
       
   178 */
       
   179 
       
   180 const TInt KTouchInputPreviewOn = 1;
       
   181 const TInt KTouchInputPreviewOff = 0;
       
   182 
       
   183 #ifdef  RD_SCALABLE_UI_V2
       
   184 const TKeyEvent KAknCcpuCopyEvent = {EKeyF18, EEikCmdEditCopy, EModifierCtrl, 1};  // Copy event for AknCcpuSupport
       
   185 const TKeyEvent KAknCcpuCutEvent  = {EKeyF18, EEikCmdEditCut, EModifierCtrl, 1};   // Cut event for AknCcpuSupport
       
   186 
       
   187 const TInt KMaxMenuSize = 28;
       
   188 const TInt KEditorMenuPermitedSend[KMaxMenuSize] = 
       
   189     {         
       
   190     EJapanFepCmdModeHiragana,
       
   191     EJapanFepCmdModeKatakana,
       
   192     EJapanFepCmdEditModeAlpha,
       
   193     EJapanFepCmdEditModeNumber,
       
   194     EJapanFepCmdModeFullWidth,
       
   195     EJapanFepCmdModeHalfWidth,
       
   196     EChinFepCmdModePinyin,
       
   197     EChinFepCmdModeZhuyin,
       
   198     EChinFepCmdModeStroke,
       
   199     EChinFepCmdModePinyinPhrase,
       
   200     EChinFepCmdModeZhuyinPhrase,
       
   201     EChinFepCmdModeStrokePhrase,    
       
   202     EAknCmdT9PredictiveT9Off,
       
   203     EAknCmdMultitapPredictiveT9On,
       
   204     EJapanFepCmdMultitapPredictiveT9On,
       
   205     EChinFepCmdModeZhuyinFind,
       
   206     EChinFepCmdModeStrokeFind,
       
   207     EAknCmdEditModeAlpha,
       
   208     EAknCmdEditModeLatinText,
       
   209     EChinFepCmdModeLatinUpper,
       
   210     EChinFepCmdModeLatinLower,
       
   211     EAknCmdEditModeNumber,
       
   212     EChinFepCmdModeNumber,
       
   213     EAknCmdEditModeArabicIndicNumber,
       
   214     EAknCmdEditModeEasternArabicIndicNumber,
       
   215     EAknCmdEditModeIndicNumber,
       
   216     EAknCmdEditModeKorean,
       
   217     EAknCmdEditModeEnglish
       
   218     };   
       
   219      
       
   220 #endif // RD_SCALABLE_UI_V2 
       
   221 
       
   222 
       
   223 // Number modes used by Arabic or Hindi.
       
   224 enum TNonLatinNumberModes
       
   225     { 
       
   226     ENbrModeLatin,
       
   227     ENbrModeArabic = 1,
       
   228     ENbrModeIndic = 1
       
   229     };
       
   230 
       
   231 // Number mode type
       
   232 enum TNonLatinNumberModeType
       
   233     {
       
   234     ENbrModeTypeArabic,
       
   235     ENbrModeTypeIndic,
       
   236     ENbrModeTypeEasternArabic //for Urdu & Farsi languages
       
   237     };
       
   238     
       
   239 // The passwd timeout is same as defined on CEikSecretEditor.
       
   240 const TInt KSyncPasswdTimeout = 1000000;
       
   241 
       
   242 #ifdef RD_SCALABLE_UI_V2
       
   243 TUid AppUidFromWndGroupId(TInt aWndGrpId);
       
   244 extern TUid GetCurAppUid();
       
   245 extern TBool IsGlobalNotesApp(TUid& aUid);
       
   246 TInt GetForegroundTaskAppWgId();
       
   247 #endif
       
   248 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   249 const TInt KWordToFocusInCandidateList = 1;
       
   250 #endif
       
   251 
       
   252 LOCAL_C TInt RemapVietnameseAccentedCharacter(TUint16 aChr);
       
   253 
       
   254 //
       
   255 // Class TTextDirectionalInfo
       
   256 //
       
   257 /**
       
   258 * The implementation inializes with well-defined "null" state
       
   259 */
       
   260 CAknFepManager::TTextDirectionalInfo::TTextDirectionalInfo() : 
       
   261 iDirectionalStatus(EUnknown), iBlockEnvironment(EUndefined)
       
   262     {}
       
   263 
       
   264 void CAknFepManager::TTextDirectionalInfo::SetDirectionFromChunk( 
       
   265                const CTmTextLayout::TTmChunkDescription& aChunk )
       
   266     {
       
   267     if ( aChunk.iStart >= 0 ) // Condition for valid block. Does nothing otherwise
       
   268         iDirectionalStatus = aChunk.iRightToLeft ? ERightToLeft : ELeftToRight;
       
   269     }
       
   270 
       
   271 
       
   272 void TFepLanguageTranslation::ReadFromResource(TResourceReader& aReader)
       
   273     {
       
   274     iName.Set(aReader.ReadTPtrC());
       
   275     iLanguageId = aReader.ReadInt16();
       
   276     iCommandId = aReader.ReadInt16();
       
   277     }
       
   278 
       
   279 
       
   280 CAknFepManager::CAknFepManager(CCoeEnv& aConeEnvironment)
       
   281     :CCoeFep(aConeEnvironment),
       
   282     iAsyncResouceChanged(EActivePriorityDefault),
       
   283     iPreviousEditingState(EStateNone),
       
   284     iInputCapabilities(TCoeInputCapabilities::ENone),
       
   285     iModeBefore(ELatin),
       
   286     #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   287     iKeyPressedDuringShift(EFalse),
       
   288 #endif
       
   289     iCharWidth(EHalfWidthChar),
       
   290     iAsyncOwnSimulateKey(EActivePriorityDefault),
       
   291     iLongThai0Key(EFalse),
       
   292     iEditCharsPtr(0,0),
       
   293     iComposChrFlag(0),
       
   294     iIsUserdbdlgActive(0),
       
   295     iLongClearAfterCloseUI(EFalse),
       
   296     // phrase creation
       
   297     iPhraseCreation(0),
       
   298     iPinyinPhraseCreation(0),
       
   299     iEntryPhrase(0)
       
   300     
       
   301 
       
   302     {
       
   303     }
       
   304 
       
   305 void CAknFepManager::ConstructL(const CCoeFepParameters& aFepParameters)
       
   306     {
       
   307     BaseConstructL(aFepParameters);
       
   308     iUiInterface = CAknFepUIInterface::NewL();
       
   309     iIndicator = iUiInterface->NewIndicatorL();
       
   310     iPreviousIndicator = CAknEnv::Static()->SwapEditingStateIndicator(iIndicator);
       
   311 
       
   312     // Set up resources
       
   313     TFileName resourceName(KAknFepResourceFileName);
       
   314     CCoeEnv* coeEnv = CCoeEnv::Static();
       
   315     BaflUtils::NearestLanguageFile(coeEnv->FsSession(), resourceName);
       
   316     iResId = coeEnv->AddResourceFileL(resourceName);
       
   317 
       
   318     // Save Japanese Feature support to a member variable
       
   319     iFeatureSupportedJapanese = FeatureManager::FeatureSupported(KFeatureIdJapanese);
       
   320 
       
   321     iUiLanguage = User::Language();
       
   322     
       
   323     // Shared Data
       
   324     iSharedDataInterface = CAknFepSharedDataInterface::NewL(this);
       
   325 
       
   326     TInt previUiLanguage = iSharedDataInterface->PluginUILanguage();
       
   327 
       
   328     if (iUiLanguage != previUiLanguage)
       
   329         {
       
   330         
       
   331         // if UI language has changed we need to set text input language according to UI language
       
   332         iSharedDataInterface->SetPluginUILanguage(iUiLanguage);
       
   333         iSharedDataInterface->SetInputTextLanguage(0);  // signals that it needs to be updated
       
   334         }
       
   335 
       
   336     if (!iSharedDataInterface->InputMode()) //not initialised yet - first time device is switched on
       
   337         {
       
   338         switch (iUiLanguage)
       
   339             {
       
   340             case ELangPrcChinese:
       
   341                 iSharedDataInterface->SetInputMode(EPinyin);
       
   342                 break;
       
   343             case ELangTaiwanChinese:
       
   344                 iSharedDataInterface->SetInputMode(EZhuyin);
       
   345                 break;
       
   346             case ELangHongKongChinese:
       
   347                 iSharedDataInterface->SetInputMode(EStroke);
       
   348                 iSharedDataInterface->SetCangJieMode(ECangJieNormal);
       
   349                 break;
       
   350             case ELangJapanese:
       
   351                 iSharedDataInterface->SetInputMode(EHiraganaKanji);
       
   352                 break;
       
   353             case ELangKorean:
       
   354                 iSharedDataInterface->SetInputMode(EHangul);
       
   355                 break;
       
   356             case ELangHindi:
       
   357                 iSharedDataInterface->SetInputMode(EHindi);
       
   358                 break;
       
   359             default:
       
   360                 iSharedDataInterface->SetInputMode(ELatin);
       
   361                 break;
       
   362             }
       
   363         }
       
   364 
       
   365     iUiInterface->SetFepMenuObserver(this);
       
   366    
       
   367     TInt inputLanguage = iSharedDataInterface->InputTextLanguage();
       
   368 
       
   369     // A process instantiating Fep may miss ECapabilityWriteDeviceData capability, 
       
   370     // which is needed for updating locale repository.
       
   371     // A workaround is to delay change up to a process that has the capability
       
   372     TSecurityInfo info;
       
   373     info.Set(RProcess());
       
   374 
       
   375     TBool hasCapability = info.iCaps.HasCapability(ECapabilityWriteDeviceData);
       
   376     
       
   377     if (!inputLanguage && hasCapability)
       
   378         {
       
   379         // set correct input language
       
   380         inputLanguage = SubstituteSublanguageId(iUiLanguage);
       
   381         
       
   382         // If Ptiengine is not initialize, initialize it
       
   383         if (!iPtiEngine)
       
   384             {
       
   385             iPtiEngine = CPtiEngine::NewL(ETrue);    
       
   386             }         
       
   387         // If still not found, default to english.
       
   388         if (!iPtiEngine->GetLanguage(inputLanguage))
       
   389             {
       
   390             inputLanguage = ELangEnglish;   
       
   391             }
       
   392         
       
   393         // Set the current input language
       
   394         iSharedDataInterface->SetInputTextLanguage(inputLanguage);
       
   395         
       
   396         // update numeric input
       
   397         if ( iUiLanguage == ELangArabic ) 
       
   398             {
       
   399             SetDefaultNumberMode( ENbrModeArabic, 
       
   400                                   ENbrModeTypeArabic );
       
   401             }            
       
   402         else if ( ( iUiLanguage == ELangUrdu  ) || 
       
   403                   ( iUiLanguage == ELangFarsi  ) )
       
   404             {
       
   405             SetDefaultNumberMode( ENbrModeArabic, 
       
   406                                   ENbrModeTypeEasternArabic );
       
   407             }
       
   408 		else if ( TAknFepUiIndicInputManager::IsScriptDevanagari( iUiLanguage ) )
       
   409             {
       
   410             SetDefaultNumberMode( ENbrModeLatin, 
       
   411                                   ENbrModeTypeIndic );
       
   412             }
       
   413         else
       
   414             {           
       
   415             SetDefaultNumberMode( ENbrModeLatin, ENbrModeTypeArabic );
       
   416             }
       
   417         }
       
   418         
       
   419     iSctEditChars = HBufC::NewL( 10 );
       
   420     
       
   421 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   422     // Predictive QWERTY (XT9) changes ---->
       
   423     	if(CCoeEnv::Static()->AppUi())
       
   424 				iExactWordPopupContent = iUiInterface->CreateWordPopupContentL();
       
   425     // Predictive QWERTY (XT9) changes <----
       
   426 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   427     // If the following line is uncommented, the FEP is fully constructed
       
   428     // for all applications at application startup.
       
   429     // ConstructFullyL();
       
   430     iShiftKeypressMonitor = CPeriodic::NewL(CActive::EPriorityStandard);
       
   431 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   432     iFnKeyManager = CAknFepFnKeyManager::NewL( *this,iSharedDataInterface );
       
   433 #endif
       
   434     TRAPD(result,iKeyCatcher = CAknFepKeyCatcher::NewL(*this));
       
   435     if(result == KErrNone)
       
   436         {
       
   437         iKeyCatcher->ActivateL();
       
   438         }
       
   439     // the follow 3 objects for phrase creation
       
   440     iZhuyinKeyHandler = CZhuyinKeyHandler::NewL();
       
   441     iZhuyinAnalyserDb = CZhuyinAnalyserDbFeed::NewL(EPinyinAnalyserTypeZhuyin);
       
   442     iZhuyinAnalyser = CAknFepZhuyinAnalyser::NewL(iZhuyinAnalyserDb);
       
   443     iAknFepThaiSCTSelector = CAknFepThaiSCTSelector::NewL();
       
   444     iHybridAplphaChangedToAlphanumeric = EFalse;
       
   445     iLastFocusedEditor = NULL;
       
   446     iFepAwareDialogParentEditor = NULL;
       
   447 	
       
   448     // Fep manager should have both read and write privilege.
       
   449     // Known case: Auto-completion cannot be changed in setting dialog.
       
   450     RProperty::Define( KPSUidAknFep, KAknFepSettingDialogState, RProperty::EInt );
       
   451     }
       
   452 
       
   453 void CAknFepManager::ConstructFullyL()
       
   454     {
       
   455     if (!iPtiEngine)
       
   456         {
       
   457         iPtiEngine = CPtiEngine::NewL(ETrue);    
       
   458         } 
       
   459     
       
   460     if ( !(iPtiEngine->GetLanguage(iSharedDataInterface->InputTextLanguage())) )
       
   461         {
       
   462         // If input language cenrep value is set to language unknown to PtiEngine,
       
   463         // try to reset based on UI-language. 
       
   464         TInt inputLang = SubstituteSublanguageId(iUiLanguage);
       
   465         
       
   466         // If still not found, default to english.
       
   467         if (!iPtiEngine->GetLanguage(inputLang))
       
   468             {
       
   469             inputLang = ELangEnglish;   
       
   470             }
       
   471         iSharedDataInterface->SetInputTextLanguage(inputLang);      
       
   472         }      
       
   473 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   474 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
   475     if (iPtiEngine->GetLanguage(iSharedDataInterface->InputTextLanguageSecondary()) == NULL)
       
   476         {
       
   477         // If secondary input language is unknown to PtiEngine, set it to none
       
   478         iSharedDataInterface->SetInputTextLanguageSecondary(0);
       
   479         }
       
   480 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
   481 #endif
       
   482         
       
   483     if(NULL == iKeyCatcher)
       
   484         {
       
   485         iKeyCatcher = CAknFepKeyCatcher::NewL(*this);    
       
   486         iKeyCatcher->ActivateL();
       
   487         }
       
   488     
       
   489     iConcatenationTimer=CPeriodic::NewL(CActive::EPriorityStandard);
       
   490     iPostEventCheck=CIdle::NewL(CActive::EPriorityStandard);
       
   491     iChrKeypressMonitor = CPeriodic::NewL(CActive::EPriorityStandard);
       
   492 
       
   493     CCoeEnv* coeEnv = CCoeEnv::Static();
       
   494     TInt inputLanguage = iSharedDataInterface->InputTextLanguage();
       
   495 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   496 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
   497     TInt inputLanguageSecondary = iSharedDataInterface->InputTextLanguageSecondary();
       
   498 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
   499 #endif
       
   500     SetWesternPredictive(iSharedDataInterface->PredictiveTextOn());
       
   501 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
   502     iIsAutoCompleteOn = iSharedDataInterface->PredictiveTextAutoCompleteOn(); // AutoCompletion disabled by Default 
       
   503 #endif	//RD_INTELLIGENT_TEXT_INPUT
       
   504 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   505     iIsAutoCompleteOn = iSharedDataInterface->PredictiveTextAutoCompleteOn(); // AutoCompletion disabled by Default 
       
   506     iTypingCorrectionLevel = iSharedDataInterface->PredictiveTextTypingCorrectionLevel();
       
   507     iIsNumberCandidateShown = iSharedDataInterface->PredictiveTextNumberCandidateShown();
       
   508     TInt primaryCandidateValue = iSharedDataInterface->PredictiveTextPrimaryCandidate();
       
   509     if( primaryCandidateValue == 0)
       
   510 		iPrimaryCandidate = ETrue;
       
   511 	else if(primaryCandidateValue == 1)
       
   512 		iPrimaryCandidate = EFalse; 
       
   513 #endif // RD_INTELLIGENT_TEXT_INPUT
       
   514     iJapanesePredictive = iSharedDataInterface->PredictiveTextJapaneseOn();
       
   515     iQwertyInputMode = iSharedDataInterface->QwertyInputMode();
       
   516     iMultiTapTimer = iSharedDataInterface->MultiTapTimer();
       
   517     iJapaneseQwertyFlags = iSharedDataInterface->JapaneseQwertyFlags();
       
   518 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   519     if(!iFnKeyManager)
       
   520         {
       
   521         iFnKeyManager = CAknFepFnKeyManager::NewL( *this,iSharedDataInterface );
       
   522         }    
       
   523 #endif
       
   524     iCaseMan = CAknFepCaseManager::NewL(*this);
       
   525     iLangMan = CAknFepLanguageManager::NewL( this, iCaseMan, iSharedDataInterface );
       
   526     iPtiEngine->ActivateLanguageL(inputLanguage);
       
   527 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   528 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
   529     iPtiEngine->SetSecondaryInputL(inputLanguageSecondary);
       
   530 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
   531 #endif
       
   532     iLangMan->SetInputLanguageL(inputLanguage);
       
   533     SetInputLanguageCapabilities(inputLanguage);
       
   534     iCurrentFepUI = iLangMan->GetFepUI(ELatin, iCharWidth, IsPredictive(ELatin));
       
   535 
       
   536     iLastKeyPressedWasHashKey = EFalse;
       
   537     iDeviceSupportsRtlLanguage = DeviceSupportsRTLLanguageL();
       
   538 
       
   539     TResourceReader reader;
       
   540     // get character from resource to represent an 'enter' character
       
   541     coeEnv->CreateResourceReaderLC(reader, R_AVKON_SCT_SPACE_SYMBOL);
       
   542     iSpaceCharacterCode = reader.ReadUint16();
       
   543     coeEnv->CreateResourceReaderLC(reader, R_AVKON_SCT_FULLWIDTHSPACE_SYMBOL);
       
   544     iFullWidthSpaceCharacterCode = reader.ReadUint16();
       
   545     CleanupStack::PopAndDestroy(2); //reader
       
   546 
       
   547     //initialise states
       
   548     iMode = EAknEditorNullInputMode; //Force a sync of mode...
       
   549     SyncStates(EAknFepStateNull);
       
   550     ResetFlags();
       
   551     ResetExtendedFlags();
       
   552 
       
   553     ReadHashKeyLoopL();
       
   554     iHashKeyMan = CAknFepHashKeyManager::NewL(*this, iCaseMan);
       
   555     SetHashKeyStyle();
       
   556     iInlineTextDecorator = new (ELeave) CAknFepInlineTextDecorator;
       
   557     if (IsFeatureSupportedJapanese())
       
   558         {
       
   559         CAknJapaneseReading::CreateL(iPtiEngine);
       
   560         }
       
   561     // setting call back
       
   562     TCallBack callback(DoSimulateKey, this);
       
   563     iAsyncOwnSimulateKey.Set(callback);
       
   564     
       
   565     TCallBack resourcechangedcallback(HandleResourceChangedCallback,this);
       
   566     iAsyncResouceChanged.Set(resourcechangedcallback);
       
   567 #ifdef RD_SCALABLE_UI_V2
       
   568     iFepPluginManager = CAknFepPluginManager::NewL
       
   569         ( *this, *iSharedDataInterface, *iLangMan, *iCaseMan);
       
   570     iNotifyPlugin = ETrue;
       
   571 #endif //RD_SCALABLE_UI_V2
       
   572 
       
   573     iFepFullyConstructed = ETrue;
       
   574 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   575     iIsFnKeyMapped = IsFnKeyMappedL();
       
   576     iKeyboardType = (TPtiKeyboardType)iSharedDataInterface->KeyboardLayout();
       
   577 #endif
       
   578     
       
   579     iFnKeypressMonitor = CPeriodic::NewL(CActive::EPriorityStandard);
       
   580     }
       
   581 
       
   582 CAknFepManager::~CAknFepManager()
       
   583     {
       
   584 #ifdef RD_PF_SEC_APPARC
       
   585     delete iNullService;
       
   586 #else
       
   587     //Embedding - removing created document
       
   588     if ( iEmbedded )
       
   589         {
       
   590         CEikonEnv::Static()->Process()->DestroyDocument(iEmbedded); // User dictionary
       
   591         iEmbedded = NULL;
       
   592         }
       
   593 #endif
       
   594     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
   595         {
       
   596         SetFlag(CAknFepManager::EFlagSupressAutoUpdate);
       
   597         TRAPD(err, CommitInlineEditL())
       
   598         if (err)
       
   599             {
       
   600             CleanUpFep();
       
   601             }
       
   602         }
       
   603         
       
   604     if ( EditorState() )
       
   605         {
       
   606         EditorState()->SetObserver(NULL);    
       
   607         }        
       
   608     if (iLastFocusedEditor)
       
   609         {
       
   610         iLastFocusedEditor->SetObserver(NULL);
       
   611         iLastFocusedEditor = NULL;
       
   612         } 
       
   613     if (iFepAwareDialogParentEditor)
       
   614         {
       
   615         iFepAwareDialogParentEditor->SetObserver(NULL);
       
   616         iFepAwareDialogParentEditor = NULL;
       
   617         } 
       
   618     
       
   619     delete iSharedDataInterface;
       
   620     MAknEditingStateIndicator* indicator = CAknEnv::Static()->EditingStateIndicator();
       
   621     if (indicator == iIndicator)
       
   622         {
       
   623         CAknEnv::Static()->SwapEditingStateIndicator(NULL);
       
   624         }
       
   625 
       
   626         
       
   627     delete iIndicator;
       
   628     iIndicator = NULL;
       
   629     CCoeEnv::Static()->DeleteResourceFile(iResId);
       
   630 
       
   631     // Everything that is constructed in ConstructFullyL() method
       
   632     // needs to be deleted in CommonDestroyFep() method.
       
   633     CommonDestroyFep();
       
   634 
       
   635 	if (iUiInterface)
       
   636 	    iUiInterface->SetFepMenuObserver(NULL);
       
   637 
       
   638     delete iPtiEngine;
       
   639     delete iSctEditChars;
       
   640 
       
   641 #ifdef RD_SCALABLE_UI_V2
       
   642     if ( FepAwareTextEditor() )
       
   643         {
       
   644     		UnregisterObserver();
       
   645         }
       
   646     delete iFepPluginManager;
       
   647     delete iStylusCcpuMenu;        
       
   648 
       
   649     delete iSpellInitText;        
       
   650 #endif // RD_SCALABLE_UI_V2
       
   651     delete iUiInterface;
       
   652 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   653     // Predictive QWERTY (XT9) changes ---->
       
   654     delete iExactWordPopupContent;
       
   655     iExactWordPopupContent = 0;
       
   656     delete iCandidatePopup;
       
   657     iCandidatePopup = 0;
       
   658     delete iResourceString;
       
   659     iResourceString = 0;
       
   660     // Predictive QWERTY (XT9) changes <----
       
   661 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   662     // the follow objects for phrase creation
       
   663       delete iZhuyinKeyHandler;
       
   664       delete iZhuyinAnalyser;
       
   665     delete iAknFepThaiSCTSelector;
       
   666     }
       
   667 
       
   668 void CAknFepManager::CommonDestroyFep()
       
   669     {
       
   670     iFepFullyConstructed = EFalse;
       
   671 
       
   672     // This method is called both from destructor and CleanUpFep methods.
       
   673     iAsyncOwnSimulateKey.Cancel();
       
   674     iAsyncResouceChanged.Cancel();
       
   675     delete iShiftKeypressMonitor;
       
   676     iShiftKeypressMonitor = NULL;
       
   677     delete iConcatenationTimer;
       
   678     iConcatenationTimer = NULL;
       
   679     delete iChrKeypressMonitor;
       
   680     iChrKeypressMonitor = NULL;
       
   681     delete iLangMan;
       
   682     iLangMan = NULL;
       
   683     iCurrentFepUI = NULL;
       
   684     delete iKeyCatcher;
       
   685     iKeyCatcher = NULL;
       
   686 
       
   687     delete iPostEventCheck;
       
   688     iPostEventCheck = NULL;
       
   689     delete iHashKeyMan;
       
   690     iHashKeyMan = NULL;
       
   691     delete iCaseMan;
       
   692     iCaseMan = NULL;
       
   693     delete iInlineTextDecorator;
       
   694     iInlineTextDecorator = NULL;
       
   695     iHashKeyLoop.Close();
       
   696 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   697     if(iFnKeyManager)
       
   698         {
       
   699         delete iFnKeyManager;
       
   700         iFnKeyManager = NULL;
       
   701         }
       
   702     if( iNumericResourceTimer )        
       
   703         {
       
   704         delete iNumericResourceTimer;
       
   705         iNumericResourceTimer = NULL;    
       
   706         }
       
   707 #endif
       
   708     delete iFnKeypressMonitor;
       
   709     iFnKeypressMonitor = NULL;
       
   710     }
       
   711 
       
   712 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   713 void CAknFepManager::SetKeyboardLayout(TPtiKeyboardType aType)
       
   714     {
       
   715     	
       
   716     if(iQwertyInputMode && iFnKeyManager 
       
   717     		&& (iFnKeyManager->FnKeyState()== CAknFepFnKeyManager::EFnKeyLock
       
   718 		||iFnKeyManager->FnKeyState()== CAknFepFnKeyManager::EFnKeyNext)) 
       
   719 		{
       
   720         	iMode = ENumber;
       
   721 		}
       
   722 	
       
   723 	if(iFnKeyManager)        
       
   724 		{
       
   725 		iFnKeyManager->ClearFnKeyState();
       
   726 		}
       
   727     	
       
   728     if(iPtiEngine)
       
   729         {
       
   730         iPtiEngine->SetKeyboardType(aType);
       
   731         }    
       
   732     iKeyboardType = aType;        
       
   733     }
       
   734 
       
   735 TPtiKeyboardType CAknFepManager::KeyboardLayout() const
       
   736     {
       
   737     return iKeyboardType;
       
   738     }
       
   739 #endif
       
   740 TBool CAknFepManager::TryCloseUiL()
       
   741     {
       
   742 #ifdef RD_HINDI_PHONETIC_INPUT        
       
   743     if ((iSharedDataInterface->InputTextLanguage() == KLangHindiPhonetic) && 
       
   744          IsFlagSet(CAknFepManager::EFlagNoMatches))
       
   745         {
       
   746         ClearFlag(CAknFepManager::EFlagNoMatches);
       
   747     	if (PreviousChar() == KQuestionMark)
       
   748     		RemovePreviousCharacterL();
       
   749     	}
       
   750 #endif    
       
   751     if (iFepManState == EAknFepStateUIActive)
       
   752         {
       
   753         // In Japanese input,
       
   754         // commit inline editing at only the western predictive mode.
       
   755         if (!IsFeatureSupportedJapanese() || WesternPredictive())
       
   756             {
       
   757             if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
   758                 {
       
   759                 TryRemoveNoMatchesIndicatorL();
       
   760                 UpdateCbaL(NULL);
       
   761                 }
       
   762                 
       
   763              	
       
   764 
       
   765 //#ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
   766 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   767             if ( iFepPluginManager && 
       
   768              	(iFepPluginManager->PluginInputMode() == EPluginInputModeNone))
       
   769             	{
       
   770             	RemoveSuggestedAdvanceCompletionL();
       
   771             	}            
       
   772 #endif // RD_INTELLIGENT_TEXT_INPUT              
       
   773 //#endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
   774                 
       
   775 #ifdef RD_SCALABLE_UI_V2 
       
   776             
       
   777             if ( iFepPluginManager != NULL && 
       
   778                  iFepPluginManager->BeforeSpell() )
       
   779                 {
       
   780                 iFepPluginManager->SetBeforeSpell(EFalse);
       
   781                 }
       
   782             else
       
   783 #endif  
       
   784           
       
   785                 {
       
   786                 CommitInlineEditL();    
       
   787                 }
       
   788             }
       
   789         if (IsCcpuFlagSet(ECcpuStataCommitPredictiveWord))            
       
   790             {
       
   791             // Word commiting must be done after CommitInlineEditL call (because
       
   792             // of Japanese ReadingTextL funtionality), hence the delayed commit here.
       
   793             iPtiEngine->CommitCurrentWord();
       
   794             ClearCcpuFlag(ECcpuStataCommitPredictiveWord);
       
   795             }            
       
   796         InternalFepUI()->CloseUI();
       
   797         SyncStates(EAknFepStateInitial);
       
   798         if (iMode == EPinyin || iMode == EZhuyin || iMode == EStroke || iMode == ECangJie)
       
   799             {
       
   800             SetCursorType(EActive);
       
   801             if ( EditorState() )
       
   802             	{
       
   803             	EditorState()->SetFlags( EditorState()->Flags() & ~EAknEditorFlagChinesePopup );
       
   804             	}            
       
   805             }
       
   806 
       
   807         // EFalse in case of latin input in Japanese variant
       
   808         if (IsFeatureSupportedJapanese() 
       
   809          && iMode == ELatin && !WesternPredictive())
       
   810             {
       
   811             return EFalse;
       
   812             }
       
   813 
       
   814         return ETrue;
       
   815         }
       
   816     else
       
   817         {
       
   818     	if (IsKoreanInputLanguage())
       
   819         	{
       
   820         	if (IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
   821         		{
       
   822         	   	CommitInlineEditL();
       
   823         		PtiEngine()->ClearCurrentWord();
       
   824         		}
       
   825         	}
       
   826     	
       
   827         //in initial state characters should either:
       
   828         //1. not be consumed by the FEP.
       
   829         //2. be committed immediately by the Input State.
       
   830         //3. be multitap chars, in which case they may need to be committed
       
   831         // here. It is best to let the engine deal with this.
       
   832         if ( IsFlagSet( EFlagInsideInlineEditingTransaction ) )
       
   833             {
       
   834             InternalFepUI()->ExpireMultitapTimer();
       
   835             }
       
   836         return EFalse;
       
   837         }
       
   838     }
       
   839 
       
   840 void CAknFepManager::SendUIActivatedNotification()
       
   841     {
       
   842     SyncStates(EAknFepStateUIActive);
       
   843     }
       
   844 
       
   845 void CAknFepManager::SendUIDeActivatedNotification()
       
   846     {
       
   847     SyncStates(EAknFepStateInitial);
       
   848     }
       
   849 
       
   850 void CAknFepManager::PlaySound(TAvkonSystemSID aSound) const
       
   851     {
       
   852     if (SoundSystem())
       
   853         {
       
   854         SoundSystem()->PlaySound(aSound);
       
   855         }
       
   856     }
       
   857     
       
   858 void CAknFepManager::SetLongClearAfterCloseUI(TBool aLongClear)
       
   859     {
       
   860     iLongClearAfterCloseUI = aLongClear;
       
   861     }
       
   862 
       
   863 TKeyResponse CAknFepManager::HandleKeyEventL(TUint aCode, TKeyPressLength aLength,TEventCode aEventCode)
       
   864     {
       
   865     TKeyResponse response = EKeyWasNotConsumed;
       
   866 
       
   867     TInt documentLength = -1;
       
   868     if (iInputCapabilities.FepAwareTextEditor())
       
   869         {
       
   870         documentLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
   871         }
       
   872 
       
   873     if (iFepFullyConstructed && iConcatenationTimer->IsActive())
       
   874         {
       
   875         if (!( aCode == EKeyRightArrow ||
       
   876              aCode == EKeyLeftArrow ||
       
   877              aCode == EKeyUpArrow ||
       
   878              aCode == EKeyDownArrow ))
       
   879             {
       
   880             iConcatenationTimer->Cancel();
       
   881             }
       
   882         }
       
   883 
       
   884 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
   885     
       
   886     if(iKeyBackSpaceHit && aCode != EKeyBackspace)
       
   887     	iKeyBackSpaceHit = 0;
       
   888     
       
   889     if (aCode != EPtiKeyStar && iNumericResourceTimer)
       
   890         {
       
   891         // return with EKeyWasConsumed if any of the arrow keys are pressed with 
       
   892         // iNumericResourceTimer is active
       
   893         if(NumericResourceMultiTapTimerTimeoutL()&&
       
   894            (aCode == EKeyRightArrow || aCode == EKeyLeftArrow || aCode == EKeyUpArrow || aCode ==EKeyDownArrow))
       
   895             return EKeyWasConsumed;
       
   896         }
       
   897 #endif
       
   898 
       
   899 
       
   900 
       
   901     // This method is implemented independent of all modes, so it can be called by anyone, anywhere
       
   902     if ( BidiCursorRequired() )
       
   903         {
       
   904         response = AttemptCursorFlipAtAmbiguousPointL( aCode );
       
   905         if ( response == EKeyWasConsumed )
       
   906             {
       
   907             return response;
       
   908             }
       
   909         }
       
   910 
       
   911     if ( aCode != EPtiKeyHash 
       
   912 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   913 #ifdef __HALF_QWERTY_KEYPAD
       
   914 #ifdef __SHIFT_KEY_LOOP		
       
   915     		&& ( aCode != EPtiKeyQwertyLeftShift 
       
   916     		|| EPtiKeyboardHalfQwerty != KeyboardLayout() )
       
   917 #endif //__SHIFT_KEY_LOOP
       
   918 #endif //__HALF_QWERTY_KEYPAD
       
   919 #endif //RD_INTELLIGENT_TEXT_INPUT   		
       
   920     		)
       
   921     
       
   922         {
       
   923         
       
   924         SetLastPressedHashKeyStatus(EFalse);
       
   925         
       
   926         if(iHashKeyMan)
       
   927             {
       
   928             iHashKeyMan->CancelHashKeyTimer();
       
   929             if (aCode != EKeyOK)
       
   930                 {
       
   931                 iHashKeyMan->ClearSelectionModeHashKeyLoop();
       
   932                 }
       
   933             }
       
   934         }
       
   935     // Always commit the text before handling arrow keys
       
   936     if (iMode == EHangul && IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
   937     	{
       
   938     	if ( aCode == EKeyRightArrow ||
       
   939              aCode == EKeyLeftArrow ||
       
   940              aCode == EKeyUpArrow ||
       
   941              aCode == EKeyDownArrow )
       
   942     		{
       
   943     		CommitInlineEditL();
       
   944        		iPtiEngine->ClearCurrentWord();
       
   945     		}
       
   946         }
       
   947     TBool isPassNext = IsFlagSet(EFlagPassNextKey);
       
   948    
       
   949     switch (aCode)
       
   950         {
       
   951         case EKeyEscape:
       
   952 
       
   953 #ifdef RD_SCALABLE_UI_V2     
       
   954         if( iFepFullyConstructed && iFepPluginManager)
       
   955             {
       
   956             iFepPluginManager->ResetMenuState(EFalse);            
       
   957             }
       
   958 #endif         
       
   959             if (TryCloseUiL())
       
   960                 {
       
   961                 response = EKeyWasConsumed;
       
   962                 // phrase creation
       
   963                 PhraseCreation(EFalse);
       
   964                 // phrase creation
       
   965                 PinyinPhraseCreation(EFalse);
       
   966                 }
       
   967             break;
       
   968 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   969 #ifdef __HALF_QWERTY_KEYPAD
       
   970 #ifdef __SHIFT_KEY_LOOP
       
   971         case EPtiKeyQwertyLeftShift:
       
   972         if( EPtiKeyboardHalfQwerty == KeyboardLayout() )
       
   973         	{
       
   974 			response = HandleHashKeyL(aLength);
       
   975             (aLength == ELongKeyPress)? SetLastPressedHashKeyStatus(EFalse):SetLastPressedHashKeyStatus(ETrue);
       
   976 			}
       
   977             break;			
       
   978 #endif //__SHIFT_KEY_LOOP       	
       
   979 #endif //__HALF_QWERTY_KEYPAD	
       
   980 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   981         case EPtiKeyHash:
       
   982             if(InputMode() == EHangul)
       
   983             	{
       
   984 				if (aLength == EShortKeyPress)
       
   985 					{
       
   986 					FepUI()->HandleKeyL(aCode, aLength);
       
   987 					response = EKeyWasConsumed;
       
   988 					}
       
   989 				else
       
   990 					{
       
   991                	 	//PhraseCreation(EFalse);
       
   992             		response = HandleHashKeyL(aLength);
       
   993             		(aLength == ELongKeyPress)? SetLastPressedHashKeyStatus(EFalse):
       
   994                                         		SetLastPressedHashKeyStatus(ETrue);
       
   995 					}
       
   996 				}
       
   997      	     else if (InputMode()!= EZhuyin)
       
   998                 {
       
   999                 if (IsPinyinPhraseCreation() )
       
  1000                     {
       
  1001                     ClearCcpuFlag( ECcpuStateHashDown );
       
  1002                     response = EKeyWasConsumed;
       
  1003                     }
       
  1004                 else
       
  1005                     {
       
  1006                     response = HandleHashKeyL(aLength);
       
  1007                     (aLength == ELongKeyPress)
       
  1008                         ? SetLastPressedHashKeyStatus(EFalse)
       
  1009                             : SetLastPressedHashKeyStatus(ETrue);
       
  1010                     }
       
  1011                 }
       
  1012             else
       
  1013                 {
       
  1014                 PhraseCreation(EFalse);
       
  1015                 response = HandleHashKeyL(aLength);
       
  1016                 (aLength == ELongKeyPress)
       
  1017                     ? SetLastPressedHashKeyStatus(EFalse)
       
  1018                         : SetLastPressedHashKeyStatus(ETrue);
       
  1019                 }
       
  1020             break;
       
  1021         case EKeyCBA1:
       
  1022             if(Japanese())
       
  1023                 {
       
  1024                 if (FepUI()->HandleKeyL(aCode, aLength))
       
  1025                     {
       
  1026                     response = EKeyWasConsumed;
       
  1027                     }
       
  1028                 break;
       
  1029                 }
       
  1030             // phrase creation the key CBA2 need to solve.
       
  1031             if ( IsEntryPhrase() )
       
  1032                 {
       
  1033                 if ( FepUI()->HandleKeyL( aCode, aLength ) )
       
  1034                     {
       
  1035                     response = EKeyWasConsumed;
       
  1036                     break;
       
  1037                     }
       
  1038                 }
       
  1039 
       
  1040             if (!WesternPredictive())
       
  1041                 {
       
  1042                 if (TryCloseUiL())
       
  1043                     {
       
  1044                     response = EKeyWasConsumed;
       
  1045                     }
       
  1046                 }            
       
  1047             break;
       
  1048         case EKeyCBA2:
       
  1049             if(Japanese())
       
  1050                 {
       
  1051                 if (FepUI()->HandleKeyL(aCode, aLength))
       
  1052                     {
       
  1053                     response = EKeyWasConsumed;
       
  1054                     }
       
  1055                 break;
       
  1056                 }
       
  1057             if (!WesternPredictive())
       
  1058                 {
       
  1059                 if (TryCloseUiL())
       
  1060                     {
       
  1061                     // phrase creation the key CBA2 need to solve.
       
  1062                     PhraseCreation( EFalse );
       
  1063                     response = EKeyWasConsumed;
       
  1064                     }
       
  1065                 }
       
  1066      		 else
       
  1067                 {
       
  1068                 if ( IsFlagSet( EFlagInsideInlineEditingTransaction ) )
       
  1069                     {
       
  1070                     InternalFepUI()->ExpireMultitapTimer();
       
  1071                     }
       
  1072                 }
       
  1073             // phrase creation the key CBA2 need to solve.
       
  1074             EntryPhrase( EFalse );
       
  1075             break;
       
  1076         case EPtiKeyStar:
       
  1077             if (IsFlagSet(EFlagPassNextKey))
       
  1078                 {
       
  1079                 ClearFlag(EFlagPassNextKey);
       
  1080                 }
       
  1081             else if ( !IsFepAwareTextEditor() )
       
  1082                 {
       
  1083                 // The editor is MFNE or other non FEP aware text editor.
       
  1084                 // Pass the key to the editor to handle.
       
  1085                 response = EKeyWasNotConsumed;
       
  1086                 }
       
  1087             else if (IsFlagSet(EFlagShiftKeyDepressed))
       
  1088                 {
       
  1089                 response = EKeyWasConsumed;
       
  1090                 }
       
  1091             else 
       
  1092                 {
       
  1093 #ifdef RD_SCALABLE_UI_V2                
       
  1094                 iStarKeyPressed = ETrue;
       
  1095 #endif // RD_SCALABLE_UI_V2                    
       
  1096                 if (FepUI()->HandleKeyL(aCode, aLength, aEventCode))
       
  1097                     {
       
  1098                     response = EKeyWasConsumed;
       
  1099                     }
       
  1100 #ifdef RD_SCALABLE_UI_V2                
       
  1101                 iStarKeyPressed = EFalse;
       
  1102 #endif // RD_SCALABLE_UI_V2                     
       
  1103                 }
       
  1104             break;
       
  1105         case EKeyRightArrow:
       
  1106             if (TryHandleArrowRightEventL(documentLength))
       
  1107                 {
       
  1108                 response = EKeyWasConsumed;
       
  1109                 break;
       
  1110                 }
       
  1111             // fall through
       
  1112         case EKeyLeftArrow:
       
  1113             if (aCode == EKeyLeftArrow && TryHandleArrowLeftEventL(documentLength))
       
  1114                 {
       
  1115                 response = EKeyWasConsumed;
       
  1116                 break;
       
  1117                 }
       
  1118                 
       
  1119             if (IsCcpuFlagSet(ECcpuStateCopy | ECcpuStateCut))    
       
  1120                 {
       
  1121                 response = EKeyWasNotConsumed;
       
  1122                 break;
       
  1123                 }            
       
  1124             else if (IsCcpuFlagSet(ECcpuStateStartCopy | ECcpuStateStartCut))    
       
  1125                 {
       
  1126                 TryHandleCommonArrowAndBackspaceFunctionalityL(aCode, response);                
       
  1127                 break;
       
  1128                 }               
       
  1129 
       
  1130             if (iLanguageCapabilities.iInputLanguageCode == ELangJapanese && iMode != ELatin)
       
  1131                 {
       
  1132                 if(FepUI()->HandleKeyL(aCode, aLength))
       
  1133                     {
       
  1134                     response = EKeyWasConsumed;
       
  1135                     }
       
  1136                 }
       
  1137             else
       
  1138                 {
       
  1139                 if (WesternPredictive())
       
  1140                     {
       
  1141                     response = HandleWesternPredictiveArrowKeyL(aCode, aLength);
       
  1142                     }
       
  1143                 else
       
  1144                     {
       
  1145                     if (iFepManState == EAknFepStateUIActive)
       
  1146                         {
       
  1147                         FepUI()->HandleKeyL(aCode, aLength);
       
  1148                         response = EKeyWasConsumed;
       
  1149                         }
       
  1150                     else
       
  1151                         {
       
  1152                         /*
       
  1153 						TCursorSelection currentEditorSelection(0,0);
       
  1154 						if(iInputCapabilities.FepAwareTextEditor())
       
  1155 							{
       
  1156 							iInputCapabilities.FepAwareTextEditor()->
       
  1157 								GetCursorSelectionForFep(currentEditorSelection);
       
  1158 							}
       
  1159                         
       
  1160 						if(!IsMfneEditor() &&
       
  1161 								(PluginInputMode() == EPluginInputModeItut ||
       
  1162 								 PluginInputMode() == EPluginInputModeFSQ)  &&
       
  1163 								 currentEditorSelection.Length() != 0)
       
  1164 							{
       
  1165 							response = EKeyWasConsumed;
       
  1166 							break;
       
  1167 							}
       
  1168 						*/
       
  1169 
       
  1170                         response = HandleNaviEventOutsideInlineEditL(aCode, aLength);
       
  1171                         if (response == EKeyWasConsumed)
       
  1172                             {
       
  1173                             iCaseMan->UpdateCase(ENullNaviEvent);
       
  1174                             }
       
  1175                         else if (aCode == EKeyLeftArrow && !IsFlagSet(EFlagShiftKeyDepressed))
       
  1176                             {
       
  1177                             iCaseMan->UpdateCase(ELeftNaviEvent);
       
  1178                             }
       
  1179                         else if (!IsFlagSet(EFlagShiftKeyDepressed))
       
  1180                             {
       
  1181                             iCaseMan->UpdateCase(ERightNaviEvent);
       
  1182                             }
       
  1183                         }
       
  1184                     }
       
  1185                 }
       
  1186             break;
       
  1187         case EKeyDownArrow:
       
  1188        	    if( iWesternPredictive && IsFlagSet(EFlagInsideInlineEditingTransaction) && 
       
  1189        	    	( EPtiKeyboard12Key == KeyboardLayout() ) && ( IsFlagSet(EFlagShiftKeyDepressed) ||
       
  1190        	    	  HashKeySelectionInUse()&& IsCcpuFlagSet(ECcpuStateHashDown) ) )
       
  1191             	{
       
  1192  				iPtiEngine->CommitCurrentWord();
       
  1193             	CommitInlineEditL();
       
  1194             	response = EKeyWasConsumed;
       
  1195             	break;
       
  1196             	}
       
  1197 
       
  1198           if (TryHandleArrowDownEventL(documentLength) || IsFlagSet(EFlagNoMatches))
       
  1199                 {
       
  1200                 response = EKeyWasConsumed;
       
  1201                 break;
       
  1202                 }
       
  1203                 
       
  1204         case EKeyUpArrow:
       
  1205             if (iLanguageCapabilities.iInputLanguageCode == ELangJapanese && iMode != ELatin)
       
  1206                 {
       
  1207                 if ( (iAknEditorFlags & EAknEditorFlagNoLRNavigation) &&
       
  1208                     IsFlagSet(EFlagShiftKeyDepressed) )
       
  1209                     {
       
  1210                     // Up or down key is pressed during shift key press.
       
  1211                     ClearFlag(EFlagNoActionDuringShiftKeyPress);
       
  1212                     return EKeyWasNotConsumed;
       
  1213                     }
       
  1214 
       
  1215                 if(FepUI()->HandleKeyL(aCode, aLength))
       
  1216                     {
       
  1217                     response = EKeyWasConsumed;
       
  1218                     }
       
  1219                 else
       
  1220                     {
       
  1221                     TryHandleCommonArrowAndBackspaceFunctionalityL(aCode, response);
       
  1222                     }
       
  1223                 }
       
  1224             else
       
  1225                 {
       
  1226                 if (iLanguageCapabilities.iInputLanguageCode == ELangThai &&
       
  1227                     iFepManState == EAknFepStateUIActive &&
       
  1228                     WesternPredictive() )
       
  1229                     {
       
  1230                     if (FepUI()->HandleKeyL(aCode, aLength))
       
  1231                         {
       
  1232                         ClearFlag(EFlagChangeInputMode);
       
  1233                         response = EKeyWasConsumed;
       
  1234                         }
       
  1235                     break;
       
  1236                     }
       
  1237                 else if ( (iAknEditorFlags & EAknEditorFlagNoLRNavigation) &&
       
  1238                     IsFlagSet(EFlagShiftKeyDepressed) )
       
  1239                     {
       
  1240                     // Up or down key is pressed during shift key press.
       
  1241                     ClearFlag(EFlagNoActionDuringShiftKeyPress);
       
  1242                     return EKeyWasNotConsumed;
       
  1243                     }
       
  1244                 if (WesternPredictive())
       
  1245                     {
       
  1246                     // For customizabal of Down/Up scroll keypress action.
       
  1247                     // If it need to custom it, the function of HandleKeyL returns EFalse.
       
  1248 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1249                     // Predictive QWERTY (XT9) changes ---->
       
  1250                     if ( IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) )
       
  1251                         {
       
  1252                         TInt wordIndexToSelect = 0;
       
  1253                         
       
  1254                         if(iQwertyInputMode && EPtiKeyboardHalfQwerty != KeyboardLayout())
       
  1255                         	{
       
  1256                         	if(!iPrimaryCandidate)
       
  1257                             iPtiEngine->HandleCommandL( EPtiCommandUserActionGetIndexOfSecondaryCandidate, 
       
  1258         							&wordIndexToSelect );
       
  1259                             
       
  1260                         	if( iQwertyInputMode 
       
  1261                         	    && IsExactWordPopUpShown()
       
  1262                         	    && aCode == EKeyUpArrow )
       
  1263 	                        	{
       
  1264 		                        iExactWordPopupContent->HidePopUp();
       
  1265                             
       
  1266                                 // When press up, if FSQ is opened, 
       
  1267                                 // also need to check and close tooltip on it.
       
  1268 		                        SendEventsToPluginManL( EPluginHideTooltip );
       
  1269 		                                                                                    
       
  1270 	                        	iPtiEngine->HandleCommandL( 
       
  1271                                            EPtiCommandUserActionSetCurrentIndexOfCandidates, 
       
  1272 	                        								 &wordIndexToSelect );
       
  1273 	                        	iPtiEngine->HandleCommandL( EPtiCommandLockCurrentCandidate );
       
  1274 	                        	/* Update the Candidate List in case of Exact Typing as best predicted word is 
       
  1275 	                             selected from the tooltip to the editor */
       
  1276 	                        	if(!iPrimaryCandidate)
       
  1277 	                        	    iPtiEngine->HandleCommandL(EPtiCommandSetFlagToUpdateCandidates);
       
  1278 	                        	    
       
  1279 	                        	TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  1280 	                        	UpdateInlineEditL( selectedWord, selectedWord.Length() ); 
       
  1281 	                        	response = EKeyWasConsumed;
       
  1282 		                     
       
  1283 	                        	}
       
  1284 	                        else
       
  1285 	                        	{
       
  1286 		                        LaunchCandidatePopupListL( wordIndexToSelect );
       
  1287 		                        response = EKeyWasConsumed;
       
  1288 	                        	}
       
  1289                         	}
       
  1290                         else
       
  1291                         	{
       
  1292                         	if (!IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))
       
  1293                         	    {
       
  1294                         	    TInt lastCandidateIndex = iPtiEngine->NumberOfCandidates() -1;
       
  1295                            	    if( EPtiKeyboard12Key == KeyboardLayout() && ( IsFlagSet(EFlagShiftKeyDepressed) ||
       
  1296                            	    		  HashKeySelectionInUse()&& IsCcpuFlagSet(ECcpuStateHashDown) ) )
       
  1297     	                        	{
       
  1298     	                            if (response != EKeyWasConsumed)
       
  1299     	                                {
       
  1300     	                                response = HandleWesternPredictiveArrowKeyL(aCode, aLength);
       
  1301     	                                }
       
  1302     	                        	}
       
  1303                            	    else if(aCode == EKeyUpArrow && lastCandidateIndex >= 0)
       
  1304                         	        {
       
  1305                         	        // Get last word on list
       
  1306                         	        LaunchCandidatePopupListL( lastCandidateIndex );
       
  1307                         	        response = EKeyWasConsumed;
       
  1308                         	        }
       
  1309                         	    else
       
  1310                         	        {
       
  1311                         	        // Get next word on list (wrap around if at end)
       
  1312                         	        iPtiEngine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, 
       
  1313             							&wordIndexToSelect );
       
  1314                         	        wordIndexToSelect < lastCandidateIndex ? wordIndexToSelect++ : wordIndexToSelect = 0;
       
  1315                         	        LaunchCandidatePopupListL( wordIndexToSelect );
       
  1316                         	        response = EKeyWasConsumed;
       
  1317                         	        }                        	                        	    
       
  1318                         	    }
       
  1319                         	else
       
  1320                         	    response = EKeyWasConsumed;
       
  1321                         	}
       
  1322                         }
       
  1323                     else
       
  1324                         {                       
       
  1325 	                    // Predictive QWERTY (XT9) changes <----
       
  1326 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  1327                     if(iFepManState == EAknFepStateUIActive &&
       
  1328                         FepUI()->HandleKeyL(aCode, aLength))
       
  1329                         {
       
  1330                         response = EKeyWasConsumed;
       
  1331 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1332 
       
  1333                         // When press up, if FSQ is opened, 
       
  1334                         // also need to check and close tooltip on it.
       
  1335                         SendEventsToPluginManL( EPluginHideTooltip );
       
  1336 
       
  1337 	                    // Predictive QWERTY (XT9) changes ---->
       
  1338 	                    // Exact word popup is hidden when the exact word is selected
       
  1339 	                    iExactWordPopupContent->HidePopUp();
       
  1340 	                    // Predictive QWERTY (XT9) changes <----
       
  1341 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  1342                         }
       
  1343                     // normal operation of  Down/Up scroll keypress action.
       
  1344                     if (response != EKeyWasConsumed)
       
  1345                         {
       
  1346                         response = HandleWesternPredictiveArrowKeyL(aCode, aLength);
       
  1347                         }
       
  1348 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1349                         } // Predictive QWERTY (XT9) changes
       
  1350 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  1351                     }
       
  1352                 else
       
  1353                     {
       
  1354                     if (iFepManState == EAknFepStateUIActive)
       
  1355                         {
       
  1356                         FepUI()->HandleKeyL(aCode, aLength);
       
  1357                         response = EKeyWasConsumed;
       
  1358                         }
       
  1359                     else
       
  1360                         {
       
  1361                         TryHandleCommonArrowAndBackspaceFunctionalityL(aCode, response);
       
  1362                         }
       
  1363                     }
       
  1364                 }
       
  1365             break;
       
  1366         case EKeyBackspace:
       
  1367             if (iLanguageCapabilities.iInputLanguageCode == ELangJapanese &&
       
  1368                 !(iMode == ELatin || iMode == ENumber))
       
  1369                 {
       
  1370                 if (FepUI()->HandleKeyL(aCode, aLength))
       
  1371                     {
       
  1372                     response = EKeyWasConsumed;
       
  1373                     }
       
  1374                 }
       
  1375             else if (iLanguageCapabilities.iInputLanguageCode == ELangVietnamese)
       
  1376                 {
       
  1377                 TCursorSelection cursorSelection;
       
  1378                 if ( !IsFepAwareTextEditor() )                                           
       
  1379                     {
       
  1380                     response = EKeyWasNotConsumed;
       
  1381                     }
       
  1382                 else
       
  1383                     {
       
  1384                     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSelection); 
       
  1385                     if (cursorSelection.Length() != 0)      
       
  1386                         {
       
  1387                         response = EKeyWasNotConsumed;
       
  1388                         }
       
  1389 #ifdef RD_SCALABLE_UI_V2
       
  1390                     else if ( !documentLength 
       
  1391                         && ( iFepPluginManager->PluginInputMode() == EPluginInputModeItut
       
  1392                         || iFepPluginManager->PluginInputMode() == EPluginInputModeVkb ) )
       
  1393                         {
       
  1394                         response = EKeyWasConsumed;
       
  1395                         }
       
  1396 #endif   
       
  1397 										else 
       
  1398                         {
       
  1399                         if (FepUI()->HandleKeyL(aCode, aLength))
       
  1400                             {
       
  1401                             response = EKeyWasConsumed;
       
  1402                             }
       
  1403                         else
       
  1404                             {
       
  1405                             if( WesternPredictive() )
       
  1406                                 {
       
  1407                                 // We need to start the autoconcatination timer
       
  1408                                 SimulateKeyEventL(EKeyF24);
       
  1409                                 }
       
  1410                             }
       
  1411                         }
       
  1412                     }
       
  1413                 
       
  1414                 }
       
  1415             else if (IsKoreanInputLanguage() && iMode == EHangul)
       
  1416                 {
       
  1417                 if (FepUI()->HandleKeyL(aCode, aLength))
       
  1418                     {
       
  1419                     response = EKeyWasConsumed;
       
  1420                     }
       
  1421                 }
       
  1422             else
       
  1423                 {
       
  1424                 if (iFepManState == EAknFepStateInitial)
       
  1425                     {
       
  1426 #ifdef RD_SCALABLE_UI_V2
       
  1427                      if ( iFepPluginManager->PluginInputMode() == EPluginInputModeItut )
       
  1428                         {
       
  1429                         if ( iFepPluginManager->CurrentFepInputUI() && 
       
  1430                             FepUI()->HandleKeyL(aCode, aLength))
       
  1431                             {
       
  1432                             response = EKeyWasConsumed;
       
  1433                             break;
       
  1434                             }
       
  1435                         }
       
  1436                      if ( !documentLength 
       
  1437                         && ( iFepPluginManager->PluginInputMode() == EPluginInputModeItut
       
  1438                         || iFepPluginManager->PluginInputMode() == EPluginInputModeVkb ) )
       
  1439                         {
       
  1440                         response = EKeyWasConsumed;
       
  1441                         break;
       
  1442 
       
  1443                         }
       
  1444 #endif                        
       
  1445                     if (IsFlagSet(EFlagLineFeedCharacter))
       
  1446                         {
       
  1447                         // restore cursor visibility
       
  1448                         if (IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))
       
  1449                             {
       
  1450                             iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL(ETrue);        
       
  1451                             }
       
  1452                         
       
  1453                         iInputCapabilities.FepAwareTextEditor()->CancelFepInlineEdit();
       
  1454                         ClearFlag(EFlagInsideMultitapInlineEditingTransaction | 
       
  1455                                   EFlagInsideInlineEditingTransaction | 
       
  1456                                   EFlagLineFeedCharacter);
       
  1457                         response =  EKeyWasConsumed;
       
  1458                         }
       
  1459                     else
       
  1460                         {
       
  1461                         response = HandleNaviEventOutsideInlineEditL(aCode, aLength);
       
  1462                         if (WesternPredictive() && response == EKeyWasNotConsumed)
       
  1463                             {
       
  1464                             // if we're passing a backspace to the editor simulate any old keypress
       
  1465                             // to catch and check the state of play after the deletion
       
  1466                             SimulateKeyEventL(EKeyF24);
       
  1467                             }
       
  1468                         if (response == EKeyWasNotConsumed)
       
  1469                             {
       
  1470                             if(iMode == EZhuyinFind)
       
  1471                                 {
       
  1472                                 SetFlag(EFlagSupressAutoUpdate);
       
  1473                                 }
       
  1474                             if (iLongClearAfterCloseUI &&
       
  1475                                 aLength == ELongKeyPress)
       
  1476                                 {
       
  1477                                 response = EKeyWasConsumed;
       
  1478                                 }
       
  1479 
       
  1480                             iCaseMan->UpdateCase(EBackspaceEvent);
       
  1481                             }
       
  1482 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1483                         if(IsAutoCompleteOn())
       
  1484                             {
       
  1485                             TInt tailLength = 0;
       
  1486                             iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, 
       
  1487                                                         &tailLength );
       
  1488                             if(tailLength > 0)
       
  1489                                 {
       
  1490                                 RemoveSuggestedAdvanceCompletionL();
       
  1491                                 }
       
  1492                             }
       
  1493 #endif
       
  1494                         }
       
  1495                     
       
  1496                     // Clear the star key flag.
       
  1497                     if( FepUI() )
       
  1498                         {
       
  1499                         FepUI()->SetStarKeyFlag( EFalse );
       
  1500                         }
       
  1501                     }
       
  1502 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1503                 else if (IsAutoCompleteOn())
       
  1504                     {
       
  1505                       if(FepUI()->HandleKeyL(aCode, aLength))
       
  1506                         {
       
  1507                         if( EPtiKeyboardHalfQwerty == KeyboardLayout()
       
  1508                         		&& iWesternPredictive
       
  1509                         		&& iCaseMan->CurrentCase() != EAknEditorUpperCase )
       
  1510                             {
       
  1511                         	ClearFlag(CAknFepManager::EFlagChangeInputMode);
       
  1512                             }
       
  1513                         TInt tailLength = 0;
       
  1514                         iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength );
       
  1515                         if(tailLength > 0)
       
  1516                             {
       
  1517                             RemoveSuggestedAdvanceCompletionL();
       
  1518                             }
       
  1519                         response = EKeyWasConsumed;
       
  1520                         }
       
  1521                     }
       
  1522                 else if(FepUI()->HandleKeyL(aCode, aLength))
       
  1523                     {
       
  1524                     response = EKeyWasConsumed;
       
  1525                     }
       
  1526                 SendEventsToPluginManL( EPluginHideTooltip );
       
  1527                 iExactWordPopupContent->HidePopUp();
       
  1528 #else
       
  1529                 else if (FepUI()->HandleKeyL(aCode, aLength))
       
  1530                     {
       
  1531                     response = EKeyWasConsumed;
       
  1532                     }                
       
  1533 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  1534                 }
       
  1535             break;
       
  1536         case EKeyDelete:
       
  1537 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1538 			if(IsAutoCompleteOn())
       
  1539 				{
       
  1540 				TInt tailLength = 0;
       
  1541 				iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, 
       
  1542 												&tailLength );
       
  1543 				if(tailLength > 0)
       
  1544 					{
       
  1545 					RemoveSuggestedAdvanceCompletionL();
       
  1546 				    }
       
  1547 				}
       
  1548 
       
  1549             // When press delete key, if FSQ is opened, 
       
  1550             // also need to check and close tooltip on it.
       
  1551 			SendEventsToPluginManL( EPluginHideTooltip );
       
  1552 
       
  1553 		    iExactWordPopupContent->HidePopUp();
       
  1554         	if ( IsFlagSet( EFlagInsideInlineEditingTransaction ) )
       
  1555             	{
       
  1556             	TryRemoveNoMatchesIndicatorL();
       
  1557             	UpdateCbaL(NULL);
       
  1558             	CommitInlineEditL();
       
  1559     	        } 
       
  1560 #endif //RD_INTELLIGENT_TEXT_INPUT        
       
  1561         	break;            
       
  1562         case EKeyF19:  // Fep simulated event to asynchronously update the case.
       
  1563             iCaseMan->UpdateCase(ENullNaviEvent);
       
  1564             response=EKeyWasConsumed;
       
  1565             ClearExtendedFlag(EExtendedFlagOkKeyPressOnCandidatePopup );
       
  1566             break;
       
  1567         case EKeyF22:
       
  1568             if (WesternPredictive())
       
  1569                 {
       
  1570                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  1571                 if (CursorInsideWord())
       
  1572                     {
       
  1573                     MoveCursorToEndOfWordL();
       
  1574                     }
       
  1575                 if (iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep())
       
  1576                     {
       
  1577                     iCaseMan->UpdateCase(ENullNaviEvent);
       
  1578                     }
       
  1579                 }
       
  1580             else if (iMode == ELatin)
       
  1581                 {
       
  1582                 iCaseMan->UpdateCase(ENullNaviEvent);
       
  1583                 }
       
  1584             ClearCcpuFlag(ECcpuStateIgnoreStarUp);    
       
  1585             response=EKeyWasConsumed;
       
  1586             break;
       
  1587         case EKeyF23:
       
  1588             if (WesternPredictive())
       
  1589                 {
       
  1590                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  1591                 if (CursorInsideWord())
       
  1592                     {
       
  1593                     MoveCursorToStartOfWordL();
       
  1594                     }
       
  1595                 if (iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep())
       
  1596                     {
       
  1597                     iCaseMan->UpdateCase(ENullNaviEvent);
       
  1598                     }
       
  1599                 }
       
  1600             else if (iMode == ELatin)
       
  1601                 {
       
  1602                 iCaseMan->UpdateCase(ENullNaviEvent);
       
  1603                 }
       
  1604             ClearCcpuFlag(ECcpuStateIgnoreStarUp);    
       
  1605             response=EKeyWasConsumed;
       
  1606             break;
       
  1607         case EKeyF24:
       
  1608             if (WesternPredictive() && CursorInsideWord())
       
  1609                 {
       
  1610                 // word concatenation - start the timer; add concatenated word
       
  1611                 // to UDB on timer expiry
       
  1612                 iConcatenationTimer->Start(EWordConcatenationTimeout, EWordConcatenationTimeout,
       
  1613                     TCallBack(WordConcatenationTimerTimeoutCallback, this));
       
  1614                 }
       
  1615             response=EKeyWasConsumed;
       
  1616             break;
       
  1617         case EPtiKey0: //fall through
       
  1618         case EPtiKey1:
       
  1619         case EPtiKey2:
       
  1620         case EPtiKey3:
       
  1621         case EPtiKey4:
       
  1622         case EPtiKey5:
       
  1623         case EPtiKey6:
       
  1624         case EPtiKey7:
       
  1625         case EPtiKey8:
       
  1626         case EPtiKey9:
       
  1627             #ifdef RD_SCALABLE_UI_V2     
       
  1628                 if ( aLength == ELongKeyPress && !isPassNext && (aCode == EPtiKey0) )
       
  1629                     {
       
  1630                     if( !IsQwerty() && 
       
  1631                         !IsFlagSet(CAknFepManager::EFlagPassNextKey)&&
       
  1632                         iFepPluginManager->PluginInputMode() != EPluginInputModeItut )
       
  1633                         {
       
  1634                         iFepPluginManager->ClosePluginInputModeL( ETrue );
       
  1635                         }
       
  1636                     }
       
  1637             #endif
       
  1638              if (IsFlagSet(EFlagLineFeedCharacter) && aCode != EPtiKey0)
       
  1639                 {
       
  1640                 // There is line feed character waiting. Pospone this event and handle
       
  1641                 // line feed first.
       
  1642                 CancelInlineEdit();
       
  1643                  if (!(iAknEditorFlags & EAknEditorFlagFindPane) || iQwertyInputMode)
       
  1644                  {
       
  1645                   SimulateKeyEventL(EKeyEnter);
       
  1646                   SimulateKeyEventL(EKeyF19); // Asyncronous case update    
       
  1647                  }
       
  1648                 SimulateKeyEventL((TPtiKey)aCode);                  
       
  1649                 ClearFlag(EFlagLineFeedCharacter);
       
  1650                 return EKeyWasConsumed;                 
       
  1651                 }                
       
  1652             if (iLanguageCapabilities.iInputLanguageCode == ELangJapanese && iMode != ELatin)
       
  1653                 {
       
  1654                 if (EditorHasFreeSpace() || iFepManState == EAknFepStateUIActive)
       
  1655                     {
       
  1656                     if (FepUI()->HandleKeyL(aCode, aLength))
       
  1657                         {
       
  1658                         ClearFlag(EFlagChangeInputMode);
       
  1659                         response = EKeyWasConsumed;
       
  1660                         }
       
  1661                     // response is EKeyWasNotConsumed
       
  1662                     }
       
  1663                 }
       
  1664             else
       
  1665                 {
       
  1666                 //pass extra key received when doing secret text edit
       
  1667                 if (IsFlagSet(EFlagPassNextKey))
       
  1668                     {
       
  1669                     ClearFlag(EFlagPassNextKey);
       
  1670                     }
       
  1671                 else if (IsFlagSet(EFlagShiftKeyDepressed) || IsCcpuFlagSet(ECcpuStateHashDown))
       
  1672                     {
       
  1673                     response = EKeyWasConsumed;
       
  1674                     }
       
  1675                     
       
  1676                 // The key event is passed to the editor to handle in case of
       
  1677                 // MFNE and other non FEP aware editors (response = EKeyWasNotConsumed).
       
  1678                 else if ( IsFepAwareTextEditor() )
       
  1679                     {
       
  1680                     if ( ( iMode != ENumber && iMode != ENativeNumber ) ||
       
  1681                         ( ( iMode == ENumber || iMode == ENativeNumber )  && aLength == ELongKeyPress))
       
  1682                         {
       
  1683                         // Be default the key event is handled by FEP for FEP aware editors.
       
  1684                         response = EKeyWasConsumed;
       
  1685                         }
       
  1686 
       
  1687                     // New character can be entered to the editor if there is
       
  1688                     // space left in the editor. Editor can be modified also
       
  1689                     // is the last character is multitapped or last character
       
  1690                     // in inline state is replaced with a digit.
       
  1691                     /*Hindi*/
       
  1692                     //This condition is added for Hindi language in case of multitapping of EKey1 to get 
       
  1693                     //a numeral value "1" because of a clasical case of Halant and ZWS getting added 
       
  1694                     //before numeral 1 which may affect incase of limited space in editor   
       
  1695                         
       
  1696                     if (( EditorHasFreeSpace()
       
  1697                         || (!WesternPredictive() && !EditorHasFreeSpace() && 
       
  1698                            (TAknFepUiIndicInputManager::IsIndicLangauge(
       
  1699                             TLanguage(iLanguageCapabilities.iInputLanguageCode)))) 
       
  1700                         || IsFlagSet(EFlagInsideMultitapInlineEditingTransaction)
       
  1701                         || (IsFlagSet(EFlagInsideInlineEditingTransaction) && aLength == ELongKeyPress)))
       
  1702                         {
       
  1703                         ClearFlag(EFlagEditorFull);
       
  1704 
       
  1705                         if (aLength == ELongKeyPress && 
       
  1706                            (iMode != ELatin && iMode != ENumber && iMode != ENativeNumber && iMode != EStrokeFind && iMode != EHangul) &&
       
  1707                             FepUI()->IsValidNumericLongKeyPress(aCode))
       
  1708                             {
       
  1709                             if (iFepManState == EAknFepStateInitial) // Multitapping
       
  1710                                 {
       
  1711 #ifdef RD_SCALABLE_UI_V2
       
  1712                                  if (iFepFullyConstructed && 
       
  1713                                      iFepPluginManager->CurrentFepInputUI() )
       
  1714                                      {
       
  1715                                      if (iFepPluginManager->CurrentFepInputUI()->HandleKeyL(aCode, 
       
  1716                                                                                          aLength))
       
  1717                                          {
       
  1718                                          response = EKeyWasConsumed;
       
  1719                                          break;
       
  1720                                          }
       
  1721                                      }
       
  1722 #endif        
       
  1723                                 // Current multitabbed character is replaced with a number.
       
  1724                                 TChar ch(aCode);
       
  1725                                 TBuf<1> buf;
       
  1726                                 buf.Append(ch);
       
  1727                                 NewCharacterL(buf);
       
  1728                                 CommitInlineEditL();
       
  1729                                 iPtiEngine->ClearCurrentWord();
       
  1730                                 }
       
  1731                             else
       
  1732                                 {
       
  1733                                 // Long number key press is given to the editor.
       
  1734                                 TryCloseUiL();
       
  1735                                 response = EKeyWasNotConsumed;
       
  1736                                 }
       
  1737                             }
       
  1738                         else if (FepUI()->HandleKeyL(aCode, aLength))
       
  1739                             {
       
  1740         	            	if ( (iMode == EPinyin || iMode == EZhuyin || iMode == EStroke || iMode == ECangJie)
       
  1741         	            			&& iFepManState == EAknFepStateUIActive )
       
  1742         	            		{
       
  1743         	            		if ( EditorState() )
       
  1744         	            			{
       
  1745         	            			EditorState()->SetFlags( EditorState()->Flags() | EAknEditorFlagChinesePopup );
       
  1746         	            			}       	            		
       
  1747         	            		}
       
  1748                             ClearFlag(EFlagChangeInputMode);
       
  1749                             // for japanese variant
       
  1750                             if (IsFeatureSupportedJapanese()
       
  1751                              && iMode == ENumber)
       
  1752                                 {
       
  1753                                 response = EKeyWasConsumed;
       
  1754                                 }
       
  1755                             }
       
  1756                         else
       
  1757                             {
       
  1758                             //By default, pass long keypress to an editor for inserting number.
       
  1759                             response = EKeyWasNotConsumed;
       
  1760                             //No need to handle long key press in dialer
       
  1761                             if ( RProcess().SecureId().iId != KPhoneSecureId )
       
  1762                                 {
       
  1763 
       
  1764                                 if ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic )
       
  1765                                     {
       
  1766                                     SimulateKeyEventL( aCode + KLatinToArabicIndicDigitsDelta );
       
  1767                                     response = EKeyWasConsumed;
       
  1768                                     }
       
  1769                                 else if( iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic )    
       
  1770                                     {
       
  1771                                     SimulateKeyEventL( aCode + KLatinToEasternArabicIndicDigitsDelta );
       
  1772                                     response = EKeyWasConsumed;
       
  1773                                     }
       
  1774                                 /*Hindi*/    
       
  1775                                 else if ( iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari 
       
  1776                                             || iPreviousEditingState == EDevanagariIndicNumeric )                           
       
  1777                                     {
       
  1778                                     
       
  1779                                     SimulateKeyEventL( aCode + KLatinToDevanagariDigitsDelta );
       
  1780                                     
       
  1781                                     response = EKeyWasConsumed;
       
  1782                                     }
       
  1783                                 }
       
  1784                             }
       
  1785                         }
       
  1786                     }                   
       
  1787                 }
       
  1788             break;
       
  1789         case EKeyOK:
       
  1790             {
       
  1791             if (iUiInterface->SoftkeysExist() && EditSubmenuInUse()) 
       
  1792                 {                           
       
  1793                 if (iUiInterface->SoftkeyCommandId(ELeftSoftkeyIndex) == EAknFepSoftkeyStartCopy)
       
  1794                     {                                     
       
  1795                     ProcessCommandL(EAknFepSoftkeyStartCopy);
       
  1796                     response = EKeyWasConsumed;             
       
  1797                     break;
       
  1798                     }
       
  1799                 else if (iUiInterface->SoftkeyCommandId(ELeftSoftkeyIndex) == EAknFepSoftkeyStartCut)
       
  1800                     {
       
  1801                     ProcessCommandL(EAknFepSoftkeyStartCut);
       
  1802                     response = EKeyWasConsumed;             
       
  1803                     break;              
       
  1804                     }
       
  1805                 else if (iUiInterface->SoftkeyCommandId(ELeftSoftkeyIndex) == EEikCmdEditCopy)
       
  1806                     {                                     
       
  1807                     ProcessCommandL(EEikCmdEditCopy);
       
  1808                     response = EKeyWasConsumed;             
       
  1809                     break;
       
  1810                     }
       
  1811                 else if (iUiInterface->SoftkeyCommandId(ELeftSoftkeyIndex) == EEikCmdEditCut)
       
  1812                     {
       
  1813                     ProcessCommandL(EEikCmdEditCut);
       
  1814                     response = EKeyWasConsumed;             
       
  1815                     break;              
       
  1816                     }                                                                               
       
  1817                 }
       
  1818             
       
  1819             if ( (iAknEditorFlags & EAknEditorFlagNoLRNavigation) &&
       
  1820                 IsFlagSet(EFlagShiftKeyDepressed) )
       
  1821                 {
       
  1822                 // Selection key is pressed during shift key press.
       
  1823                 ClearFlag(EFlagNoActionDuringShiftKeyPress);
       
  1824                 return EKeyWasNotConsumed;
       
  1825                 }
       
  1826             if (iLanguageCapabilities.iInputLanguageCode == ELangJapanese && iMode != ELatin)
       
  1827                 {
       
  1828                 if (FepUI()->HandleKeyL(aCode, aLength))
       
  1829                     {
       
  1830                     response = EKeyWasConsumed;
       
  1831                     }
       
  1832                 }
       
  1833             else
       
  1834                 {
       
  1835                 if (IsFlagSet(EFlagShiftKeyDepressed) && 
       
  1836                   !(iAknEditorFlags & EAknEditorFlagSupressShiftMenu))
       
  1837                     {
       
  1838                     response = EKeyWasConsumed;
       
  1839                     }
       
  1840                 else if (iFepManState == EAknFepStateUIActive)
       
  1841                     {
       
  1842                     if (FepUI()->HandleKeyL(aCode, aLength))
       
  1843                         {
       
  1844                         response = EKeyWasConsumed;
       
  1845                         }
       
  1846                     }
       
  1847                 else if (iMode == ELatin && !WesternPredictive() && 
       
  1848                          IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))                    
       
  1849                     {
       
  1850                     CommitInlineEditL();
       
  1851                     }
       
  1852 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1853 			    // Predictive QWERTY (XT9) changes ---->
       
  1854 			    // Accept current candidate (including possible auto-completed part) and insert space after the word
       
  1855 			    // if selection key pressed while inline editing (on Qwerty only!)
       
  1856 			    // this is not the expected behavior for half qwerty
       
  1857 			    
       
  1858 				TBool isQwertyMode = iQwertyInputMode && 
       
  1859 								!( EPtiKeyboardHalfQwerty == KeyboardLayout() );
       
  1860 			    if ( response == EKeyWasNotConsumed && iWesternPredictive && isQwertyMode && 
       
  1861 			         IsFlagSet(EFlagInsideInlineEditingTransaction) 
       
  1862 			         // For addition of ITI features on FSQ. 
       
  1863 			         // If FSQ is opened with ITI features activated, don't commit as HW's action
       
  1864 			         && !( iFepPluginManager && iFepPluginManager->EnableITIOnFSQ() ) )
       
  1865 			        {
       
  1866 			        
       
  1867 					// If the primary candidate setting is exact typing, The tooltip/bubble always shows the best prediction.
       
  1868 				    // Word on the typing line is accepted into editor on selection key event..  
       
  1869 					                  
       
  1870 			        iPtiEngine->CommitCurrentWord();
       
  1871 			        CommitInlineEditL();
       
  1872                     TryCloseUiL();
       
  1873                     if(!static_cast<TChar>(NextChar()).IsSpace())
       
  1874 	                    {
       
  1875 	                    SimulateKeyEventL(EKeySpace);
       
  1876 	                    }
       
  1877                     else 
       
  1878 	                	{
       
  1879 						TCursorSelection sel;
       
  1880             			iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(sel);
       
  1881             			sel.iCursorPos++;
       
  1882             			sel.iAnchorPos++;
       
  1883             			iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);	                		
       
  1884 	                	}    
       
  1885                     SimulateKeyEventL(EKeyF19); // asynchronous case update
       
  1886                 
       
  1887 			        response = EKeyWasConsumed;
       
  1888 			        }
       
  1889 			    // Predictive QWERTY (XT9) changes <----
       
  1890 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  1891                 }
       
  1892             }
       
  1893             break;
       
  1894 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1895         	case EKeyPhoneEnd:
       
  1896 	        	{
       
  1897 	        	// Suggested word should get committed in exact typing
       
  1898 				if ( iWesternPredictive &&
       
  1899 			    	 IsFlagSet(EFlagInsideInlineEditingTransaction) )
       
  1900 			        {
       
  1901 						
       
  1902 					// If the primary candidate setting is exact typing, The tooltip/bubble always shows the best prediction.
       
  1903 					// Word on the typing line is accepted into editor on end key event..
       
  1904 						
       
  1905 			        iPtiEngine->CommitCurrentWord();
       
  1906 					CommitInlineEditL();
       
  1907 	            	TryCloseUiL();
       
  1908 	            	ClearFlag(CAknFepManager::EFlagNoMatches);
       
  1909 	            	SimulateKeyEventL(EKeyF19); // asynchronous case update
       
  1910 			        }
       
  1911 	        	}
       
  1912 			break;
       
  1913 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  1914         default:
       
  1915             break;
       
  1916         }
       
  1917     SchedulePostEventCheckL(aCode);
       
  1918 
       
  1919 #ifdef RD_SCALABLE_UI_V2     
       
  1920     if ( !isPassNext )
       
  1921         {
       
  1922         SendEventsToPluginManL( EPluginKeyEvent, aCode );
       
  1923         }
       
  1924 #endif
       
  1925         
       
  1926     return response;
       
  1927     }
       
  1928     
       
  1929 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1930 void CAknFepManager::HandleShiftHalfQwertyChineseL(TEventCode aEventCode)
       
  1931     {
       
  1932     if (aEventCode == EEventKeyDown)
       
  1933         {
       
  1934         ClearCcpuFlag(ECcpuStateCbaShown);		
       
  1935         SetFlag(EFlagShiftKeyDepressed | EFlagNoActionDuringShiftKeyPress);
       
  1936         ClearFlag(EFlagNoActionDuringChrKeyPress);
       
  1937         SetFlag(EFlagQwertyShiftMode);
       
  1938         // Long press of shift key timer is activated.
       
  1939         iShiftKeypressMonitor->Start(EShiftKeyRepeatDelay,
       
  1940             EShiftKeyRepeatDelay, TCallBack(ResetShiftKeyMonitorCallback,
       
  1941                 this) );
       
  1942         }
       
  1943     else if (aEventCode == EEventKeyUp)
       
  1944         {
       
  1945         ClearFlag(EFlagShiftKeyDepressed
       
  1946             |EFlagNoActionDuringShiftKeyPress);
       
  1947         ClearFlag(EFlagQwertyShiftMode);
       
  1948         iShiftKeypressMonitor->Cancel();
       
  1949 
       
  1950         if ( (iKeyPressedDuringShift)|| IsFlagSet(EFlagLongShiftKeyPress) )
       
  1951             {
       
  1952             iKeyPressedDuringShift = EFalse;
       
  1953             ClearFlag( EFlagLongShiftKeyPress );
       
  1954             if ( iFnKeyManager->FnKeyState() )
       
  1955                 {
       
  1956                 iFnKeyManager->SetFnKeyState( CAknFepFnKeyManager::EFnKeyNone );
       
  1957                 }
       
  1958             UpdateIndicators();
       
  1959             }
       
  1960         else
       
  1961             {
       
  1962             CAknEdwinState* editorState = EditorState();
       
  1963             TInt permittedCases = editorState->PermittedCases();
       
  1964             permittedCases = permittedCases == 0 ?
       
  1965             EAknEditorLowerCase | EAknEditorUpperCase : permittedCases;
       
  1966 
       
  1967             if (iMode == ELatin && (permittedCases & EAknEditorTextCase))
       
  1968                 {
       
  1969                 // Latin case update is changed back to automatic if latin 
       
  1970                 // text case is allowed and the case is changed manually from #-key.
       
  1971                 ClearFlag(CAknFepManager::EFlagSupressAutoUpdate);
       
  1972                 }
       
  1973             TInt currentCase = iCaseMan->CurrentCase();
       
  1974 
       
  1975             // Is current latin case last available case.
       
  1976             TBool lastCase = ( ( !(permittedCases & EAknEditorTextCase)
       
  1977                     && ((currentCase == EAknEditorLowerCase)
       
  1978                         || (currentCase == EAknEditorUpperCase
       
  1979                             && !(permittedCases
       
  1980                                 & EAknEditorLowerCase)) )
       
  1981                     || (editorState->Flags() & EAknEditorFlagFixedCase) )
       
  1982                 || (editorState->Flags()
       
  1983                     & EAknEditorFlagForceTransparentFepModes) );
       
  1984 
       
  1985             if (iMode == ELatin
       
  1986                 && !IsFlagSet(CAknFepManager::EFlagChangeInputMode)
       
  1987                 && !lastCase)
       
  1988                 {
       
  1989                 if (iWesternPredictive)
       
  1990                     {
       
  1991                     // Input mode is still Latin. Only case is updated.
       
  1992                     if (permittedCases & EAknEditorTextCase)
       
  1993                         {
       
  1994                         iCaseMan->ManualCaseUpdate();
       
  1995                         }
       
  1996                     else
       
  1997                         {
       
  1998                         iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
  1999                         }
       
  2000                     }
       
  2001                 else
       
  2002                     {
       
  2003                     if(iCaseMan->CurrentCase() == EAknEditorUpperCase)
       
  2004                         {
       
  2005                         iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
  2006                         }
       
  2007                     else
       
  2008                         {
       
  2009                         iCaseMan->SetCurrentCase(EAknEditorUpperCase);
       
  2010                         }
       
  2011                     }
       
  2012 
       
  2013                 // Next time input mode is changed if any text is not entered before.
       
  2014                 SetFlag(CAknFepManager::EFlagChangeInputMode);
       
  2015                 }
       
  2016             else
       
  2017                 {
       
  2018                 // Input mode is incremented.
       
  2019                 SetChangeModeByShiftAndSpace( EFalse );
       
  2020                 TryIncrementChineseModeForQwertyL(iMode);
       
  2021 
       
  2022                 ClearFlag(CAknFepManager::EFlagChangeInputMode);
       
  2023 
       
  2024                 if ( iMode == ELatin && iWesternPredictive ) // New mode after Increment.
       
  2025 
       
  2026                     {
       
  2027                     if (editorState->Flags() & EAknEditorFlagFixedCase)
       
  2028                         {
       
  2029                         // Only one fixed case is available. Use it.
       
  2030                         iCaseMan->ConfigureCaseStateFromEditorState();
       
  2031                         SetFlag(CAknFepManager::EFlagChangeInputMode);
       
  2032                         }
       
  2033                     else if (editorState->Flags()
       
  2034                         & EAknEditorFlagForceTransparentFepModes)
       
  2035                         {
       
  2036                         // Only lower case is used with find pane.
       
  2037                         iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
  2038                         SetFlag(CAknFepManager::EFlagSupressAutoUpdate);
       
  2039                         SetFlag(CAknFepManager::EFlagChangeInputMode);
       
  2040                         }
       
  2041                     else if (permittedCases & EAknEditorTextCase)
       
  2042                         {
       
  2043                         iCaseMan->SetCurrentCase(EAknEditorTextCase);
       
  2044                         iCaseMan->UpdateCase(ENullNaviEvent);
       
  2045                         }
       
  2046                     else
       
  2047                         {
       
  2048                         if (permittedCases & EAknEditorUpperCase)
       
  2049                             {
       
  2050                             iCaseMan->SetCurrentCase(EAknEditorUpperCase);
       
  2051                             if ( !(permittedCases
       
  2052                                     & EAknEditorLowerCase))
       
  2053                                 {
       
  2054                                 // We need to move to next input mode since only upper case 
       
  2055                                 // is permitted in Latin input mode.
       
  2056                                 SetFlag(CAknFepManager::EFlagChangeInputMode);
       
  2057                                 }
       
  2058                             }
       
  2059                         else
       
  2060                             {
       
  2061                             iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
  2062                             SetFlag(CAknFepManager::EFlagChangeInputMode);
       
  2063                             }
       
  2064                         }
       
  2065                     }
       
  2066                 }
       
  2067             }
       
  2068         }
       
  2069     }
       
  2070 
       
  2071 void CAknFepManager::HandleShiftQwertyChineseL(TEventCode aEventCode)
       
  2072     {
       
  2073     if ( IsFlagSet( EFlagQwertyChrKeyDepressed ) && 
       
  2074     	 !IsFeatureSupportedJapanese() && 
       
  2075     	 iCurrentFepUI->IsValidShiftKeyPress())
       
  2076     	{
       
  2077         ClearFlag(EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
  2078         LaunchLanguagesPopupListL();
       
  2079         return;
       
  2080     	}
       
  2081     
       
  2082     TInt language = iSharedDataInterface->InputTextLanguage();
       
  2083 
       
  2084     if (aEventCode == EEventKeyUp)
       
  2085         {
       
  2086         ClearCcpuFlag(ECcpuStateCbaShown);
       
  2087         if (FepUI())
       
  2088             {
       
  2089             FepUI()->HandleKeyL(EKeyLeftShift, EShortKeyPress);
       
  2090             }
       
  2091         TBool validShift = iCurrentFepUI->IsValidShiftKeyPress();
       
  2092                 
       
  2093         if (IsFlagSet(EFlagLongShiftKeyPress) ||iKeyPressedDuringShift)
       
  2094             {
       
  2095             if (iKeyPressedDuringShift || IsFlagSet(EFlagQwertyShiftMode))
       
  2096                 {
       
  2097                 iShiftKeypressMonitor->Cancel();
       
  2098                 iKeyPressedDuringShift = EFalse;
       
  2099                 ClearFlag(EFlagQwertyShiftMode);
       
  2100                 }
       
  2101             }
       
  2102         else
       
  2103             if (IsFlagSet(EFlagQwertyShiftMode))
       
  2104                 {
       
  2105                 if ( iMode != ELatin && validShift )
       
  2106                     {
       
  2107                     iModeBefore = iMode;
       
  2108                     TryChangeModeL(ELatin);
       
  2109                     ClearFlag( EFlagQwertyShiftMode );
       
  2110                     }
       
  2111                 }
       
  2112             else
       
  2113                 {
       
  2114                 if (iMode == ELatin)
       
  2115                     {
       
  2116                     TBool isWsPr= EFalse;
       
  2117                     if (WesternPredictive())
       
  2118                         {
       
  2119                         SetWesternPredictive(EFalse);
       
  2120                         isWsPr = ETrue;
       
  2121                         }
       
  2122                     TInt Modetemp = iModeBefore;
       
  2123                     TInt sharedDataMode = iSharedDataInterface->InputMode();
       
  2124                     if (Modetemp == EStroke && 
       
  2125                     	iQwertyInputMode && 
       
  2126                     	sharedDataMode == ECangJie)
       
  2127                     	{
       
  2128                     	Modetemp = ECangJie;
       
  2129                     	}
       
  2130 
       
  2131                     TryChangeModeL(Modetemp);
       
  2132                     if (isWsPr)
       
  2133                         {
       
  2134                         SetWesternPredictive(ETrue);
       
  2135                         }
       
  2136                     }
       
  2137                 }
       
  2138 
       
  2139         ClearFlag(EFlagShiftKeyDepressed);
       
  2140 
       
  2141         if (IsFlagSet(EFlagLongShiftKeyPress)
       
  2142                 && iMode == ELatin
       
  2143                 && IsFlagSet(EFlagQwertyShiftMode))//latin shift ->abc
       
  2144             {
       
  2145             ClearFlag(EFlagQwertyShiftMode);
       
  2146             }
       
  2147 
       
  2148         if (IsFlagSet(EFlagLongShiftKeyPress)) //long keypress up
       
  2149             {
       
  2150             ClearFlag(EFlagLongShiftKeyPress
       
  2151                     |EFlagNoActionDuringShiftKeyPress);
       
  2152             }
       
  2153         else // short keypress up
       
  2154             {
       
  2155             iShiftKeypressMonitor->Cancel();
       
  2156             }
       
  2157 
       
  2158         ClearFlag(EFlagNoActionDuringChrKeyPress);
       
  2159         ClearFlag(EFlagNoActionDuringShiftKeyPress);
       
  2160         if ( validShift )
       
  2161             {
       
  2162             UpdateIndicators();
       
  2163             }
       
  2164         else
       
  2165             {
       
  2166             ClearFlag(EFlagQwertyShiftMode);
       
  2167             }
       
  2168         }
       
  2169     else
       
  2170         if (aEventCode == EEventKeyDown)
       
  2171             {
       
  2172 
       
  2173             SetFlag(EFlagShiftKeyDepressed | EFlagNoActionDuringShiftKeyPress);
       
  2174             ClearFlag(EFlagNoActionDuringChrKeyPress);
       
  2175 
       
  2176             if (IsFlagSet(EFlagQwertyShiftMode))
       
  2177                 {
       
  2178                 ClearFlag(EFlagQwertyShiftMode);
       
  2179                 }
       
  2180             else
       
  2181                 {
       
  2182                 SetFlag(EFlagQwertyShiftMode);
       
  2183                 if ( iCurrentFepUI->IsValidShiftKeyPress() 
       
  2184                 		|| iMode == ELatin )
       
  2185                     {
       
  2186                     UpdateIndicators();
       
  2187                     }
       
  2188    	            // If the iShiftKeypressMonitor is actived now, cancel it first.
       
  2189 	              iShiftKeypressMonitor->Cancel();
       
  2190                 // Long press of shift key timer is activated.
       
  2191                 iShiftKeypressMonitor->Start(EShiftKeyRepeatDelay,
       
  2192                         EShiftKeyRepeatDelay, TCallBack(
       
  2193                                 ResetShiftKeyMonitorCallback, this));
       
  2194                 }
       
  2195             }
       
  2196     }
       
  2197 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  2198 TKeyResponse CAknFepManager::HandleShiftKeyEventL(TEventCode aEventCode)
       
  2199     {
       
  2200     TKeyResponse response = EKeyWasNotConsumed;
       
  2201 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2202 	// GQF clarification 
       
  2203 	// In case irrespective Fn/shift key Text case should not be changed.
       
  2204 	// Like Shift +Fn + Shift should not toggle the text case of the editor.
       
  2205 	// Only Consecutive press of shift key should change the text case
       
  2206 	if( iQwertyInputMode && (EEventKeyDown== aEventCode) && EPtiKeyboardHalfQwerty != KeyboardLayout())
       
  2207 		{
       
  2208 		if( (iFnKeyManager->FnKeyState() == CAknFepFnKeyManager::EFnKeyNext) && 
       
  2209 			IsFlagSet(EFlagQwertyShiftMode))
       
  2210 			{
       
  2211 			iFnKeyManager->ClearFnKeyState();
       
  2212 			iPtiEngine->SetCase((TPtiTextCase)EPtiCaseLower);
       
  2213 			ClearFlag(EFlagQwertyShiftMode);
       
  2214 			}
       
  2215 		}
       
  2216     TInt language = iSharedDataInterface->InputTextLanguage();
       
  2217 #endif    
       
  2218     
       
  2219     if (iQwertyInputMode)
       
  2220         {
       
  2221         if ( !iInputCapabilities.FepAwareTextEditor() )
       
  2222             {
       
  2223             response = EKeyWasNotConsumed;
       
  2224             }
       
  2225 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2226         else if (language == ELangTaiwanChinese||
       
  2227                     language == ELangHongKongChinese ||
       
  2228                     language == ELangPrcChinese)
       
  2229                 {
       
  2230                 if ( ( EPtiKeyboardHalfQwerty == KeyboardLayout() && FepUI() ) &&
       
  2231                         iPtiEngine &&
       
  2232                         ( EPtiCaseFnUpper == iPtiEngine->Case() || EPtiCaseFnLower == iPtiEngine->Case() ) &&
       
  2233                         ( aEventCode == EEventKeyDown || aEventCode == EEventKeyUp ) )
       
  2234                     {
       
  2235                     // Ignore the KeyUp event
       
  2236                     if( aEventCode == EEventKeyDown )
       
  2237                         {
       
  2238                         FepUI()->HandleKeyL( EPtiKeyQwertyLeftShift, 
       
  2239                                                      EShortKeyPress );
       
  2240                         }
       
  2241                     if( aEventCode == EEventKeyUp )
       
  2242                         {
       
  2243 			            ClearCcpuFlag(ECcpuStateCbaShown);
       
  2244                         }						
       
  2245                     }
       
  2246                 else
       
  2247                     {
       
  2248                     if ((iAknEditorFlags & EAknEditorFlagFindPane)&& (CAknFepFnKeyManager::EFnKeyNone ==FnKeyState()))
       
  2249                         {
       
  2250                         if (aEventCode == EEventKeyUp)
       
  2251                             {
       
  2252 				            ClearCcpuFlag(ECcpuStateCbaShown);							
       
  2253                             if ( iKeyPressedDuringShift )
       
  2254                                 {
       
  2255                                 iKeyPressedDuringShift = EFalse;
       
  2256                                 }
       
  2257                             else
       
  2258                                 {
       
  2259                                 TryIncrementModeChineseQwertyL( iMode );
       
  2260                                 }
       
  2261                             ClearFlag( EFlagShiftKeyDepressed | EFlagNoActionDuringShiftKeyPress );
       
  2262                             }
       
  2263                         else if(aEventCode == EEventKeyDown)
       
  2264                             {
       
  2265                             SetFlag(EFlagShiftKeyDepressed | EFlagNoActionDuringShiftKeyPress);
       
  2266                             ClearFlag(EFlagNoActionDuringChrKeyPress);
       
  2267                             }
       
  2268                         return EKeyWasConsumed;
       
  2269                         }
       
  2270                     if (EPtiKeyboardHalfQwerty == KeyboardLayout())
       
  2271                         {
       
  2272                         HandleShiftHalfQwertyChineseL(aEventCode);
       
  2273                         }
       
  2274                     else
       
  2275                         {
       
  2276                         HandleShiftQwertyChineseL(aEventCode);
       
  2277                         }
       
  2278                     }
       
  2279                 }
       
  2280 #endif // ITI flag
       
  2281         else if (aEventCode == EEventKeyDown)
       
  2282             {
       
  2283 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2284 #ifdef __HALF_QWERTY_KEYPAD
       
  2285             if( ( EPtiKeyboardHalfQwerty == KeyboardLayout() && FepUI() ) &&
       
  2286                 iPtiEngine && EditorHasFreeSpace())
       
  2287                 {
       
  2288 		if (IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction))
       
  2289                             {
       
  2290                             iPtiEngine->CancelTimerActivity();
       
  2291                             }
       
  2292                 if( EPtiCaseFnUpper == iPtiEngine->Case() || EPtiCaseFnLower == iPtiEngine->Case() )
       
  2293                     {
       
  2294                     FepUI()->HandleKeyL( EPtiKeyQwertyLeftShift, 
       
  2295                                                  EShortKeyPress );
       
  2296 					iFnCharInsertedForShift = ETrue;                                                    
       
  2297                     }                 
       
  2298                 }
       
  2299 #endif // Half Qwerty flag
       
  2300 #endif // ITI flag
       
  2301 
       
  2302             // Shift key is pressed down.
       
  2303             SetFlag(EFlagShiftKeyDepressed | EFlagNoActionDuringShiftKeyPress);
       
  2304             ClearFlag(EFlagNoActionDuringChrKeyPress);
       
  2305             if ( IsFlagSet(EFlagQwertyShiftMode) && IsFlagSet(EFlagNoActionDuringShiftKeyPress) )
       
  2306                 {
       
  2307                 ClearFlag(EFlagQwertyShiftMode | EFlagNoActionDuringShiftKeyPress);
       
  2308                 // If long shift key press flag is set, then do not do manual case update.
       
  2309                 if (!IsFlagSet(EFlagLongShiftKeyPress))
       
  2310                     {
       
  2311                     iCaseMan->ManualCaseUpdate();
       
  2312                     }
       
  2313                 }
       
  2314             else
       
  2315                 {
       
  2316                 if (!(iCurrentFepUI->IsValidShiftKeyPress()))
       
  2317                     {
       
  2318                     return EKeyWasConsumed;
       
  2319                     }
       
  2320 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2321 #ifdef __HALF_QWERTY_KEYPAD                    
       
  2322                 if(!iFnCharInsertedForShift)
       
  2323 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  2324 #endif //__HALF_QWERTY_KEYPAD                
       
  2325                 	{
       
  2326                 	SetFlag(EFlagQwertyShiftMode);
       
  2327                 	}
       
  2328 					
       
  2329                 if(iShiftKeypressMonitor->IsActive())
       
  2330                 	iShiftKeypressMonitor->Cancel();               	
       
  2331                 // Long press of shift key timer is activated.
       
  2332                 iShiftKeypressMonitor->Start(EShiftKeyRepeatDelay, EShiftKeyRepeatDelay, 
       
  2333                     TCallBack(ResetShiftKeyMonitorCallback, this));
       
  2334 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2335                 // Shift kkey hack for GQF implementation. Need to check 
       
  2336                 // if it has any side effect.  
       
  2337                 if((iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyLock)
       
  2338                     && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyForced)
       
  2339                     && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyDown)
       
  2340                     && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNext))
       
  2341 #endif
       
  2342                 UpdateIndicators();
       
  2343                 }
       
  2344             }
       
  2345         else if (aEventCode == EEventKeyUp)
       
  2346             {
       
  2347 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2348 #ifdef __HALF_QWERTY_KEYPAD            
       
  2349             if( ( EPtiKeyboardHalfQwerty == KeyboardLayout() && FepUI() ) &&
       
  2350                 iPtiEngine )
       
  2351                 {
       
  2352                 ClearCcpuFlag(ECcpuStateHashDown
       
  2353                       | ECcpuStateHashKeyDeleteDone
       
  2354                       | ECcpuStateChangeToPredictionMode);
       
  2355                 if (IsCcpuFlagSet(ECcpuStateEdwinInSelectionMode))
       
  2356                     {
       
  2357                     SetCcpuFlag(ECcpuStateSelectionEventPosted);
       
  2358                     ClearCcpuFlag(ECcpuStateEdwinInSelectionMode);
       
  2359                     SetFlag(EFlagLongShiftKeyPress);
       
  2360 
       
  2361                     TKeyEvent ccpuStart = {0, EStdKeyLeftShift, 0, 0};
       
  2362                     CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, aEventCode);
       
  2363                     }
       
  2364                   if( CAknFepFnKeyManager::EFnKeyNone != FnKeyState())
       
  2365                       {
       
  2366                       ClearFlag(EFlagQwertyShiftMode);
       
  2367                       }
       
  2368                 //  iFnCharInsertedForShift = EFalse;    
       
  2369                   }
       
  2370                 
       
  2371 #endif // Half Qwerty flag
       
  2372 #endif // ITI flag
       
  2373 
       
  2374             ClearFlag(EFlagShiftKeyDepressed);
       
  2375             ClearCcpuFlag(ECcpuStateCbaShown);
       
  2376             if ( !IsFlagSet(EFlagNoActionDuringShiftKeyPress) ||
       
  2377                 (IsFlagSet(EFlagNoActionDuringShiftKeyPress) && IsFlagSet(EFlagLongShiftKeyPress)) )
       
  2378                 {
       
  2379                 ClearFlag(EFlagQwertyShiftMode);
       
  2380                 }
       
  2381 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  2382 #ifdef __HALF_QWERTY_KEYPAD				          
       
  2383             if( IsFlagSet(EFlagQwertyChrKeyDepressed) && IsFlagSet(EFlagNoActionDuringShiftKeyPress))
       
  2384                 {
       
  2385 #ifdef FF_DUAL_LANGUAGE_SUPPORT                    
       
  2386                  // Currently dual language feature would work correctly for ITUT and Half Qwerty products 
       
  2387 				 // Hence the dual language settings should also be displayed only for ITUT and Halfqwerty products
       
  2388                 if(iKeyboardType == EPtiKeyboardHalfQwerty )
       
  2389                     LaunchDualLanguageSettingDialogL();
       
  2390                 else                     
       
  2391 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
  2392                     LaunchLanguagesPopupListL();
       
  2393                 ClearFlag(EFlagQwertyChrKeyDepressed|EFlagNoActionDuringChrKeyPress|EFlagNoActionDuringShiftKeyPress);                
       
  2394                 }
       
  2395                
       
  2396 #ifdef __SHIFT_KEY_LOOP                                
       
  2397             if( KeyboardLayout() == EPtiKeyboardHalfQwerty &&
       
  2398             // looping does not happen for long key press
       
  2399                 !IsFlagSet(EFlagLongShiftKeyPress) &&     
       
  2400             // looping does not happen in functionized state                
       
  2401                 iFnKeyManager->FnKeyState() == CAknFepFnKeyManager::EFnKeyNone &&
       
  2402             // looping happens only when no action 
       
  2403             // has happened when the shift key has been pressed     
       
  2404                  IsFlagSet(EFlagNoActionDuringShiftKeyPress) && !iFnCharInsertedForShift )
       
  2405                 {
       
  2406                 HandleKeyEventL( EStdKeyLeftShift, EShortKeyPress );
       
  2407                 ClearFlag(EFlagQwertyShiftMode);
       
  2408                 }
       
  2409         	iFnCharInsertedForShift = EFalse;        
       
  2410 #endif //__SHIFT_KEY_LOOP       
       
  2411 #endif //__HALF_QWERTY_KEYPAD      
       
  2412 #endif //RD_INTELLIGENT_TEXT_INPUT   
       
  2413             if (IsFlagSet(EFlagLongShiftKeyPress))  //long keypress up
       
  2414                 {
       
  2415                 ClearFlag(EFlagLongShiftKeyPress);
       
  2416                 }
       
  2417             else                                    // short keypress up
       
  2418                 {
       
  2419                 iShiftKeypressMonitor->Cancel();
       
  2420 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  2421 #ifdef __HALF_QWERTY_KEYPAD               
       
  2422 #ifdef __SHIFT_KEY_LOOP
       
  2423 				// Cancel multitap timer
       
  2424                 
       
  2425                 if( iPtiEngine != NULL )
       
  2426                     {
       
  2427 				    iPtiEngine->CancelTimerActivity();
       
  2428                     }
       
  2429 #endif //__SHIFT_KEY_LOOP       
       
  2430 #endif //__HALF_QWERTY_KEYPAD      
       
  2431 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  2432                 }
       
  2433             ClearFlag( EFlagNoActionDuringShiftKeyPress );
       
  2434 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2435             // Shift kkey hack for GQF implementation. Need to check 
       
  2436                 // if it has any side effect.  
       
  2437             if((iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyLock)
       
  2438                 && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyForced)
       
  2439                 && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyDown)
       
  2440                 &&(iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNext))
       
  2441 #endif
       
  2442             UpdateIndicators();
       
  2443             }
       
  2444         }
       
  2445     else
       
  2446         {
       
  2447         if ( !iInputCapabilities.FepAwareTextEditor() && (!iCandidatePopup))
       
  2448             {
       
  2449             response = EKeyWasNotConsumed;
       
  2450             }        
       
  2451         else if (aEventCode == EEventKeyDown)
       
  2452             {
       
  2453             if (Japanese() && iInputCapabilities.FepAwareTextEditor())
       
  2454                 {
       
  2455                 if (!(iCurrentFepUI->IsValidShiftKeyPress()))
       
  2456                     {
       
  2457                     return EKeyWasConsumed;
       
  2458                     }
       
  2459                 TryCloseUiL();
       
  2460                 }
       
  2461             
       
  2462             // Shift key is pressed down but no any other key is pressed.
       
  2463             ClearCcpuFlag(ECcpuSupressEditMenuFromShiftUp);
       
  2464             SetFlag(EFlagShiftKeyDepressed | EFlagNoActionDuringShiftKeyPress);
       
  2465             if ( !(iAknEditorFlags & EAknEditorFlagNoLRNavigation))
       
  2466                 {
       
  2467                 // Cancel the timer first if active.
       
  2468                 // EEventKeyUp is not sent always for shift key during debugging on emulator.
       
  2469                 iShiftKeypressMonitor->Cancel();
       
  2470                 // Long press of shift key timer is activated.
       
  2471                 iShiftKeypressMonitor->Start(EShiftKeyRepeatDelay, EShiftKeyRepeatDelay,
       
  2472                     TCallBack(ResetShiftKeyMonitorCallback, this));
       
  2473                 }
       
  2474             if ( IsFlagSet(EFlagInsideInlineEditingTransaction) &&
       
  2475                 WesternPredictive() && iFepManState == EAknFepStateUIActive )
       
  2476                 {
       
  2477                 TryRemoveNoMatchesIndicatorL();
       
  2478                 UpdateCbaL(NULL);
       
  2479                 }
       
  2480             }
       
  2481         else if (aEventCode == EEventKeyUp)
       
  2482             {
       
  2483             ClearFlag(EFlagShiftKeyDepressed);
       
  2484             ClearCcpuFlag(ECcpuStateCbaShown);
       
  2485             if (IsFlagSet(EFlagLongShiftKeyPress))  //long keypress up
       
  2486                 {
       
  2487                 ClearFlag(EFlagLongShiftKeyPress | EFlagNoActionDuringShiftKeyPress);
       
  2488                 // Shift long key press timer started, in between release of
       
  2489                 // Shift key should cancel active long shift key timer. 
       
  2490                 iShiftKeypressMonitor->Cancel();
       
  2491                 if (!iInputCapabilities.FepAwareTextEditor())
       
  2492                     {
       
  2493                     TKeyEvent ccpuStart = {0, EStdKeyLeftShift, 0, 0};
       
  2494                     CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKeyUp);                    
       
  2495                     }
       
  2496                 }
       
  2497             else                                    // short keypress up
       
  2498                 {
       
  2499                 iShiftKeypressMonitor->Cancel();
       
  2500                 if (!(iAknEditorFlags & EAknEditorFlagSupressShiftMenu) &&
       
  2501                     IsFlagSet(EFlagNoActionDuringShiftKeyPress) && //iCurrentFepUI->IsValidShiftKeyPress() &&
       
  2502                     !IsCcpuFlagSet(ECcpuSupressEditMenuFromShiftUp))
       
  2503                     {
       
  2504                     // Shift key is released before any other key is pressed.
       
  2505                     // Edit menu is launched if it is allowed.
       
  2506                     ClearFlag(EFlagNoActionDuringShiftKeyPress);
       
  2507                     //Check if pointer event drag is not there before launch of edit menu.
       
  2508                     if( !IsExtendedFlagSet(EExtendedFlagPointerEventTypeEDrag))
       
  2509                       	{
       
  2510                     	LaunchSelectModeMenuL();
       
  2511                     	}
       
  2512                    
       
  2513                     if (iInputCapabilities.FepAwareTextEditor())
       
  2514                         {
       
  2515                         response = EKeyWasConsumed;    
       
  2516                         }
       
  2517                     }
       
  2518                 }
       
  2519             }
       
  2520         }
       
  2521 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2522     if (aEventCode == EEventKeyUp && 
       
  2523         EPtiKeyboardQwerty4x10 == KeyboardLayout() && FepUI())
       
  2524 	    {
       
  2525 	    FepUI()->HandleKeyL(EKeyLeftShift, EShortKeyPress);
       
  2526 	    }
       
  2527 #endif	    
       
  2528     return response;
       
  2529     }
       
  2530 
       
  2531 TKeyResponse CAknFepManager::HandleThai0KeyEvent(TEventCode aEventCode, TKeyPressLength aLength, 
       
  2532                                                  TBool& aThai0KeyHandling)
       
  2533     {
       
  2534     TKeyResponse response = EKeyWasNotConsumed;
       
  2535     aThai0KeyHandling = EFalse;
       
  2536     if(iQwertyInputMode)
       
  2537         {
       
  2538         return response;    
       
  2539         }
       
  2540    
       
  2541     if ( iLanguageCapabilities.iInputLanguageCode == ELangThai && 
       
  2542          iMode != ENumber && iMode != ENativeNumber )
       
  2543         {
       
  2544         if (!IsPredictive())
       
  2545             {
       
  2546             if (aEventCode != EEventKeyUp)
       
  2547                 {
       
  2548                 response = EKeyWasConsumed;
       
  2549                 if ( aLength == ELongKeyPress)
       
  2550                     {
       
  2551                     if (!iLongThai0Key)
       
  2552                         {
       
  2553                         iLongThai0Key = ETrue;
       
  2554                         response = EKeyWasNotConsumed; // 0 to editor
       
  2555                         aThai0KeyHandling = ETrue;
       
  2556                         }
       
  2557                     }
       
  2558                 }
       
  2559 
       
  2560             else if (aEventCode == EEventKeyUp)
       
  2561                 {
       
  2562                 if (iLongThai0Key)
       
  2563                     {
       
  2564                     iLongThai0Key = EFalse;
       
  2565                     response = EKeyWasConsumed;
       
  2566                     }
       
  2567                 else
       
  2568                     {
       
  2569                     response = EKeyWasNotConsumed; // Show Thai 0 key SCT
       
  2570                     aThai0KeyHandling = ETrue;
       
  2571                     }
       
  2572                 }
       
  2573             }
       
  2574         }
       
  2575     return response;
       
  2576     }
       
  2577 
       
  2578 TBool CAknFepManager::HandleQwertyChrKeyEventL(TEventCode aEventCode)
       
  2579     {
       
  2580     TBool response = EFalse;
       
  2581     if ( !iQwertyInputMode || !iInputCapabilities.FepAwareTextEditor() )
       
  2582         {
       
  2583         return response;
       
  2584         }
       
  2585 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2586     if(IsFlagSet(EFlagShiftKeyDepressed))
       
  2587         {
       
  2588         iKeyPressedDuringShift = ETrue;
       
  2589         }
       
  2590 #ifdef __HALF_QWERTY_KEYPAD
       
  2591     
       
  2592         if( (aEventCode == EEventKeyUp) )
       
  2593             {
       
  2594             ClearFlag(EFlagQwertyChrKeyDepressed);
       
  2595             }
       
  2596         // Handle shift for Half Qwerty seperately
       
  2597         if( ( EPtiKeyboardHalfQwerty == KeyboardLayout() && FepUI() ) &&
       
  2598             iPtiEngine /*&&             
       
  2599             ( aEventCode == EEventKeyDown || aEventCode == EEventKeyUp ) */ && !IsFlagSet(EFlagShiftKeyDepressed))
       
  2600             {		
       
  2601 
       
  2602 			if( HandleChrKeyForHalfQwertyL(aEventCode) )
       
  2603 				{
       
  2604 				return ETrue;
       
  2605 				}							
       
  2606             }
       
  2607 #endif // Half Qwerty flag 
       
  2608         // This part of code for error fixing.
       
  2609         // whenever fep is Fnupper state, press of "CHR" key
       
  2610         // always launch SCT table.
       
  2611         if( (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNone)&&
       
  2612             (IsFlagSet(EFlagQwertyShiftMode) || IsFlagSet(EFlagLongShiftKeyPress)))
       
  2613             {
       
  2614             ClearFlag(EFlagNoActionDuringShiftKeyPress | EFlagLongShiftKeyPress | EFlagShiftKeyDepressed | EFlagQwertyShiftMode);
       
  2615             iShiftKeypressMonitor->Cancel();  
       
  2616             SetFlag(EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
  2617             return response;
       
  2618             }
       
  2619            
       
  2620 
       
  2621 #endif // ITI flag
       
  2622     if (aEventCode == EEventKeyDown)
       
  2623         {
       
  2624         SetFlag(EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
  2625         response = EFalse;
       
  2626 
       
  2627         if (IsFeatureSupportedJapanese() || 
       
  2628             ( IsChineseInputLanguage() 
       
  2629 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
  2630             && KeyboardLayout() == EPtiKeyboardHalfQwerty
       
  2631 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  2632             ) )
       
  2633             {
       
  2634             // start timer for Chr key long pressing
       
  2635             iChrKeypressMonitor->Start(EChrKeyRepeatDelay, EChrKeyRepeatDelay, 
       
  2636                 TCallBack(HandleChrKeyMonitorCallback, this));
       
  2637             }
       
  2638         }
       
  2639     else if (aEventCode == EEventKeyUp)
       
  2640         {
       
  2641         if (iChrKeypressMonitor->IsActive())
       
  2642             {
       
  2643             iChrKeypressMonitor->Cancel();
       
  2644             }
       
  2645 
       
  2646         if (IsFlagSet(EFlagShiftKeyDepressed) && IsFlagSet(EFlagNoActionDuringChrKeyPress)
       
  2647 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2648 		 	||
       
  2649             IsFlagSet(EFlagQwertyShiftMode)
       
  2650 #endif            	
       
  2651 			)
       
  2652             {
       
  2653             ClearFlag(EFlagNoActionDuringShiftKeyPress | EFlagLongShiftKeyPress | 
       
  2654                       EFlagShiftKeyDepressed | EFlagQwertyShiftMode |EFlagQwertyChrKeyDepressed);
       
  2655             iShiftKeypressMonitor->Cancel();
       
  2656 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2657             iKeyPressedDuringShift = EFalse;
       
  2658 #endif                 
       
  2659             UpdateIndicators();
       
  2660             // In Japanese variant, the selecting input language is unnecessary.
       
  2661 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2662             if (EPtiKeyboardQwerty4x10 == KeyboardLayout() || EPtiKeyboardHalfQwerty == KeyboardLayout())
       
  2663                 {
       
  2664             	if (!IsFeatureSupportedJapanese() && iCurrentFepUI->IsValidShiftKeyPress())
       
  2665 	                {
       
  2666 #ifdef FF_DUAL_LANGUAGE_SUPPORT	                
       
  2667 					// Currently dual language feature would work correctly for ITUT and Half Qwerty products 
       
  2668 	                // Hence the dual language settings should also be displayed only for ITUT and Halfqwerty products
       
  2669 	                if(iKeyboardType == EPtiKeyboard12Key || iKeyboardType == EPtiKeyboardHalfQwerty )
       
  2670                         LaunchDualLanguageSettingDialogL();
       
  2671                     else                      
       
  2672 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
  2673                     LaunchLanguagesPopupListL();
       
  2674 	                }
       
  2675                 }
       
  2676             else
       
  2677             	{
       
  2678 #endif            	
       
  2679             if (!IsFeatureSupportedJapanese() && iCurrentFepUI->IsValidShiftKeyPress())
       
  2680                 {
       
  2681                 LaunchLanguagesPopupListL();
       
  2682 	                }
       
  2683 #ifdef RD_INTELLIGENT_TEXT_INPUT	                
       
  2684                 }
       
  2685 #endif                
       
  2686             }
       
  2687         else if (IsFlagSet(EFlagNoActionDuringChrKeyPress))
       
  2688             {
       
  2689             // pass key to Chinese UI manager in Chinese qwerty input for sct table
       
  2690             if(IsChineseInputLanguage() && iMode != ELatin)
       
  2691                 {
       
  2692                 FepUI()->HandleKeyL(EStdKeyLeftFunc, EShortKeyPress);
       
  2693                 ClearFlag( EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress );
       
  2694                 }
       
  2695             else if (Japanese())
       
  2696                 {
       
  2697                 if (iMode != EHiragana)
       
  2698                     {
       
  2699                     // Commit characters
       
  2700 #ifdef RD_INTELLIGENT_TEXT_INPUT                    
       
  2701                 	// Set the iSupressCursorMoveToEndChrKeyPressed when cursor is in 
       
  2702 					// between two words and SCT is launched
       
  2703                     iSupressCursorMoveToEndChrKeyPressed = ETrue;
       
  2704 #endif //RD_INTELLIGENT_TEXT_INPUT                    
       
  2705                     HandleChangeInFocus();
       
  2706                     LaunchSpecialCharacterTableL();
       
  2707                     }
       
  2708                 }
       
  2709             else if ( IsAbleToLaunchSCT() )
       
  2710                 {                
       
  2711 #ifdef RD_INTELLIGENT_TEXT_INPUT                
       
  2712                	// Set the iSupressCursorMoveToEndChrKeyPressed when cursor is in 
       
  2713 				// between two words and SCT is launched
       
  2714                 iSupressCursorMoveToEndChrKeyPressed = ETrue;
       
  2715 #endif //RD_INTELLIGENT_TEXT_INPUT                
       
  2716                 HandleChangeInFocus();
       
  2717                 LaunchSpecialCharacterTableL();
       
  2718                 }
       
  2719             else if(IsFlagSet(EFlagQwertyChrKeyDepressed))
       
  2720             	{
       
  2721 					 ClearFlag(EFlagQwertyChrKeyDepressed);
       
  2722             	}
       
  2723             }
       
  2724         else
       
  2725             {
       
  2726             FepUI()->ExpireMultitapTimer();
       
  2727             ClearFlag(EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
  2728             
       
  2729             response = ETrue;
       
  2730             } 
       
  2731         }
       
  2732     return response;
       
  2733     }
       
  2734     
       
  2735 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2736 #ifdef __HALF_QWERTY_KEYPAD    
       
  2737 TKeyResponse CAknFepManager::HandleChrKeyForHalfQwertyL( TEventCode aEventCode)
       
  2738 	{
       
  2739 	if ((IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction)) && !(EPtiCaseFnUpper == iPtiEngine->Case() || EPtiCaseFnLower == iPtiEngine->Case()))
       
  2740         {
       
  2741         iPtiEngine->CancelTimerActivity();
       
  2742         }
       
  2743 	// in functionized mode the chr key is mapped to specific chars
       
  2744 	// and should therefore be handled by the states
       
  2745 	if ( EPtiCaseFnUpper == iPtiEngine->Case() || EPtiCaseFnLower == iPtiEngine->Case() || IsReverseFnkeyInput())
       
  2746 		{		
       
  2747 		if( aEventCode == EEventKeyDown && ( EditorHasFreeSpace() ||
       
  2748     		  IsFlagSet( EFlagInsideMultitapInlineEditingTransaction )))
       
  2749 			{
       
  2750 			FepUI()->HandleKeyL( EStdKeyLeftFunc, 
       
  2751 										 EShortKeyPress );			
       
  2752 			}
       
  2753 		return EKeyWasConsumed;
       
  2754 		}
       
  2755 	// in non-functionized predictive mode,
       
  2756 	// a long key press of the chr key should produce the SCT
       
  2757 	// a short key press should produce the candidate list
       
  2758 	if ( ( iWesternPredictive || IsChineseInputLanguage() ) /*&& 
       
  2759 	   ( iMode != EPinyin && iMode != EStroke && iMode != EZhuyin )*/ )
       
  2760 		{						
       
  2761 		
       
  2762 		if(!iChrKeypressMonitor->IsActive())
       
  2763 			{
       
  2764 			// this monitors long key presses of chr key
       
  2765 			// the framework does not give us the iRepeats info 
       
  2766 			// for chr key for some reason
       
  2767 			iChrKeypressMonitor->Start(EHalfQwertyChrKeyRepeatDelay, EHalfQwertyChrKeyRepeatDelay, 
       
  2768                 TCallBack(HandleChrKeyMonitorCallback, this));			
       
  2769 			}
       
  2770 
       
  2771 		if( aEventCode != EEventKeyUp )
       
  2772 			{
       
  2773 			SetFlag( EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
  2774 			return EKeyWasConsumed;
       
  2775 			}
       
  2776 
       
  2777 		if ( aEventCode == EEventKeyUp && IsFlagSet(EFlagNoActionDuringChrKeyPress) )
       
  2778 			{
       
  2779 			if(!iChrLongKeyPress )
       
  2780 				{							
       
  2781 				// if we have come here it's a short press
       
  2782 				// the flag EFlagNoActionDuringChrKeyPress is cleared in the timer callback
       
  2783 				if(!IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) || IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction))
       
  2784 					{
       
  2785 					// when not in inline editing mode,
       
  2786 					// chr key should produce the SCT
       
  2787 					if ( !IsChineseInputLanguage() )
       
  2788 						{
       
  2789 						LaunchSpecialCharacterTableL();	
       
  2790 						}
       
  2791 					else
       
  2792 						{
       
  2793 						FepUI()->HandleKeyL( EStdKeyLeftFunc, 
       
  2794 								 EShortKeyPress );
       
  2795 						}
       
  2796 					}				
       
  2797 				ClearFlag( EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);			
       
  2798 
       
  2799 				iChrKeypressMonitor->Cancel();			
       
  2800 
       
  2801 				TInt wordToFocus = KWordToFocusInCandidateList;
       
  2802 				TInt numberOfCandidates = iPtiEngine->NumberOfCandidates();
       
  2803 				if (numberOfCandidates > 1)
       
  2804 				{
       
  2805 				wordToFocus = KWordToFocusInCandidateList;
       
  2806 				}
       
  2807 				LaunchCandidatePopupListL(wordToFocus);
       
  2808 
       
  2809 				return EKeyWasConsumed;
       
  2810 				}
       
  2811 			else 
       
  2812 				{
       
  2813 
       
  2814 		    	
       
  2815 		    	// Cancel the timer    	
       
  2816 		    	iChrKeypressMonitor->Cancel();
       
  2817 		    	
       
  2818 		    	// commit the characters
       
  2819 	        	HandleChangeInFocus();
       
  2820 
       
  2821 		    	// Clear the chr key depressed flag
       
  2822 		    	ClearFlag( EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
  2823 		        // launch the special character table
       
  2824 		        iChrLongKeyPress = EFalse;
       
  2825 		        
       
  2826 		        if ( IsAbleToLaunchSCT() )
       
  2827 		            {
       
  2828 		            LaunchSpecialCharacterTableL();
       
  2829 		            }
       
  2830 
       
  2831 		        return EKeyWasConsumed;
       
  2832 				}	
       
  2833 			}
       
  2834 		else
       
  2835 			{
       
  2836 			return EKeyWasNotConsumed;
       
  2837 			}
       
  2838 		}
       
  2839 	return EKeyWasNotConsumed;
       
  2840 	}			
       
  2841 #endif //__HALF_QWERTY_KEYPAD 
       
  2842 #endif //RD_INTELLIGENT_TEXT_INPUT				
       
  2843 
       
  2844 TKeyResponse CAknFepManager::HandleQwertyControlKeyEventL(const TKeyEvent& aKeyEvent, 
       
  2845                                                           TEventCode aEventCode)
       
  2846     {
       
  2847     TKeyResponse response = EKeyWasConsumed;
       
  2848 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2849      if (EPtiKeyboardQwerty4x10 == KeyboardLayout())
       
  2850      {
       
  2851      	if( iCurrentFepUI && !iCurrentFepUI->IsValidShiftKeyPress() && aEventCode == EEventKeyUp )
       
  2852      	{
       
  2853      	    FepUI()->HandleKeyL(EKeyLeftCtrl, EShortKeyPress);    
       
  2854      		return EKeyWasConsumed;
       
  2855      	}
       
  2856      }
       
  2857 #endif     
       
  2858 
       
  2859     // need to ignore [Ctrl] + the following simbol keys
       
  2860     // because FEP doesn't consume [Ctrl] combination keys.
       
  2861     if (Japanese() && aEventCode == EEventKey)
       
  2862         {
       
  2863         TBool comsume = EFalse;
       
  2864         switch (aKeyEvent.iScanCode)
       
  2865             {
       
  2866             case EStdKeyNkpPlus:
       
  2867             case EPtiKeyQwertyPlus:
       
  2868             case EPtiKeyQwertyMinus:
       
  2869             case EPtiKeyQwertyComma:
       
  2870             case EPtiKeyQwertySemicolon:
       
  2871             case EPtiKeyQwertyFullstop:
       
  2872             case EPtiKeyQwertyHash:
       
  2873             case EPtiKeyQwertySlash:
       
  2874             case EPtiKeyQwertyApostrophe:
       
  2875             case EPtiKeyQwertySpace:
       
  2876                 comsume = ETrue;
       
  2877                 break;
       
  2878             default:
       
  2879                 break;
       
  2880             }
       
  2881         if (comsume)
       
  2882             {
       
  2883             return EKeyWasConsumed;
       
  2884             }
       
  2885         }
       
  2886 
       
  2887 #ifdef RD_SCALABLE_UI_V2
       
  2888     if (aKeyEvent.iModifiers & EModifierCtrl
       
  2889     && (aKeyEvent.iScanCode == EPtiKeyQwertyC || aKeyEvent.iScanCode == EPtiKeyQwertyV || 
       
  2890         aKeyEvent.iScanCode == EPtiKeyQwertyX))
       
  2891         {
       
  2892         SendEventsToPluginManL( EPluginSyncFepAwareText );
       
  2893         // Let copy / cut / paste events to flow through.
       
  2894         response = EKeyWasNotConsumed;
       
  2895         }          
       
  2896 #endif         
       
  2897 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2898     // Predictive QWERTY (XT9) changes ---->
       
  2899     // Ctrl combinations which affect the editor state, must commit the current inline edit.
       
  2900     // Otherwise the currently active inline word might be lost.
       
  2901     if ( iWesternPredictive && iQwertyInputMode && IsFlagSet(EFlagInsideInlineEditingTransaction) )
       
  2902         {
       
  2903         switch (aKeyEvent.iScanCode)
       
  2904             {
       
  2905             case EStdKeyUpArrow:
       
  2906             case EStdKeyDownArrow:
       
  2907             case EStdKeyLeftArrow:
       
  2908             case EStdKeyRightArrow:
       
  2909             case EPtiKeyQwertyC:
       
  2910             case EPtiKeyQwertyV:
       
  2911             case EPtiKeyQwertyX:
       
  2912             case EPtiKeyQwertyA:
       
  2913                 iPtiEngine->CommitCurrentWord();
       
  2914                 TryCloseUiL();        
       
  2915                 break;
       
  2916             default:
       
  2917                 break;
       
  2918             }
       
  2919         }
       
  2920     // Predictive QWERTY (XT9) changes <----
       
  2921 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  2922 
       
  2923     if (aEventCode != EEventKeyUp)
       
  2924         {
       
  2925         return EKeyWasNotConsumed;
       
  2926         }
       
  2927     
       
  2928     if(iQwertyInputMode)
       
  2929         {
       
  2930 
       
  2931 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2932         // Query ptiEngine to know if the scancode maps to EPtiKeyQwertyC, 
       
  2933         // EPtiKeyQwertyV or EPtiKeyQwertyX.
       
  2934         // we should not always rely on scancode as products may change it, while
       
  2935         // still having the 'C', 'V' and 'X' mappings
       
  2936         
       
  2937         TBuf<32> mapData;              
       
  2938         iPtiEngine->MappingDataForKey((TPtiKey)aKeyEvent.iScanCode, mapData, EPtiCaseUpper); 
       
  2939         
       
  2940         if( mapData.Length() > 0 )    
       
  2941         	{
       
  2942         	if( mapData[0] == EPtiKeyQwertyC || mapData[0] == EPtiKeyQwertyV ||
       
  2943         	mapData[0] == EPtiKeyQwertyX )
       
  2944         		{
       
  2945         		// Let copy / cut / paste events to flow through.
       
  2946             	response = EKeyWasNotConsumed;
       
  2947         		}
       
  2948         	}
       
  2949 #else     
       
  2950         if (aKeyEvent.iScanCode == EPtiKeyQwertyC || aKeyEvent.iScanCode == EPtiKeyQwertyV ||
       
  2951             aKeyEvent.iScanCode == EPtiKeyQwertyX)
       
  2952             {
       
  2953             // Let copy / cut / paste events to flow through.
       
  2954             response = EKeyWasNotConsumed;
       
  2955             }
       
  2956 #endif
       
  2957             
       
  2958             
       
  2959         if (aKeyEvent.iScanCode == EStdKeyRightShift || aKeyEvent.iScanCode == EStdKeyLeftShift
       
  2960 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  2961 			||
       
  2962             IsFlagSet(EFlagQwertyShiftMode)
       
  2963 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  2964 			)
       
  2965             {
       
  2966             if(!iInputCapabilities.FepAwareTextEditor())
       
  2967                 {
       
  2968                 response = EKeyWasNotConsumed;
       
  2969                 }
       
  2970             else
       
  2971                 {
       
  2972                 SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  2973                 if ( iMode != ENumber && iMode!= ENativeNumber )
       
  2974                     {
       
  2975                     iModeBefore = iMode;
       
  2976                     }
       
  2977 #ifdef RD_HINDI_PHONETIC_INPUT  
       
  2978                            
       
  2979                 if(iSharedDataInterface->InputTextLanguage() == KLangHindiPhonetic)    
       
  2980                     {
       
  2981                     TryChangePhoneticModeL();   
       
  2982                     }
       
  2983                 else
       
  2984                     {
       
  2985 #endif                  
       
  2986                     if((!(IsOnlyNumericPermitted() || 
       
  2987                          (iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))) &&
       
  2988                        TAknFepUiIndicInputManager::IsIndicLangauge(
       
  2989                          (TLanguage)iSharedDataInterface->InputTextLanguage()))
       
  2990                         {
       
  2991                         if(iLanguageCapabilities.iInputLanguageCode == ELangEnglish)
       
  2992                             {
       
  2993                             ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
  2994                             }
       
  2995                         else
       
  2996                             {
       
  2997                             ChangeInputLanguageL(ELangEnglish); 
       
  2998                             }   
       
  2999                         }
       
  3000                     else
       
  3001                         {
       
  3002                         TryIncrementModeChineseQwertyL(iMode);  
       
  3003                         }  
       
  3004 #ifdef RD_HINDI_PHONETIC_INPUT        
       
  3005                     }   
       
  3006 #endif
       
  3007                 }
       
  3008             ClearFlag(EFlagShiftKeyDepressed);
       
  3009             if ( !IsFlagSet(EFlagNoActionDuringShiftKeyPress) ||
       
  3010                 (IsFlagSet(EFlagNoActionDuringShiftKeyPress) && IsFlagSet(EFlagLongShiftKeyPress)) )
       
  3011                 {
       
  3012                 ClearFlag(EFlagQwertyShiftMode);
       
  3013                 }
       
  3014             if (IsFlagSet(EFlagLongShiftKeyPress))  //long keypress up
       
  3015                 {
       
  3016                 ClearFlag(EFlagLongShiftKeyPress);
       
  3017                 }
       
  3018             else                                    // short keypress up
       
  3019                 {
       
  3020                 iShiftKeypressMonitor->Cancel();
       
  3021                 }
       
  3022             ClearFlag( EFlagNoActionDuringShiftKeyPress );
       
  3023             UpdateIndicators();
       
  3024             }
       
  3025         else if(aKeyEvent.iScanCode == EStdKeySpace) // switch between last used Chinese input mode and English
       
  3026             {
       
  3027 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3028             // Predictive QWERTY (XT9) changes ---->
       
  3029             // Toggle the predictive mode with ctrl+space
       
  3030             if ( (iPermittedInputModes & EAknEditorTextInputMode) &&
       
  3031                  !(iAknEditorFlags & EAknEditorFlagNoT9) &&
       
  3032                  iMode == ELatin &&
       
  3033                  iLanguageCapabilities.iSupportsWesternQwertyPredictive )
       
  3034                 {
       
  3035                 if (iWesternPredictive)
       
  3036                     {
       
  3037                     //ProcessCommandL(EAknCmdT9PredictiveT9Off);
       
  3038                     SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  3039                     //HandleChangeInFocus();                    
       
  3040                     if (iMode != ELatin)
       
  3041                         {
       
  3042                         TryChangeModeL(ELatin);
       
  3043                         }
       
  3044                     else
       
  3045                         {
       
  3046 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3047                         RemoveSuggestedAdvanceCompletionL();
       
  3048 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  3049                         CommitInlineEditL();
       
  3050                         }
       
  3051                     SetCcpuFlag(ECcpuStataCommitPredictiveWord);
       
  3052                     SetWesternPredictive(EFalse);
       
  3053                     HandleChangeInFocus();
       
  3054                     }
       
  3055                 else
       
  3056                     {
       
  3057                     //ProcessCommandL(EAknCmdMultitapPredictiveT9On);
       
  3058                     SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  3059                     //HandleChangeInFocus();
       
  3060                     SetWesternPredictive(ETrue);
       
  3061                     TryCloseUiL();
       
  3062                     TryChangeModeL(ELatin);
       
  3063      				}              
       
  3064                 // Reset the function key state,if predictive mode is cahnged.
       
  3065 				if (iFnKeyManager)
       
  3066 					{
       
  3067 					iFnKeyManager->ClearFnKeyState();
       
  3068 					}
       
  3069                 }
       
  3070             else // Predictive QWERTY (XT9) changes <----
       
  3071                 {
       
  3072 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  3073             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  3074             if(iMode != iModeBefore && iMode != ENumber && iMode != ENativeNumber )
       
  3075                 {
       
  3076                 TInt mode = iMode;
       
  3077                 if(iMode != ELatin && iModeBefore != ELatin) // more than one Chinese input modes
       
  3078                     {
       
  3079                     TryChangeModeL(ELatin);
       
  3080                     }
       
  3081                 else
       
  3082                     {
       
  3083                     TryChangeToModeBeforeL();
       
  3084                     }
       
  3085                 iModeBefore = mode; // deposit previous input mode
       
  3086                 }
       
  3087 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3088             }
       
  3089 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  3090             } 
       
  3091 #ifdef RD_INTELLIGENT_TEXT_INPUT //// Predictive QWERTY (XT9) changes: open the edit menu with Fn+space ---->
       
  3092         else if (aKeyEvent.iScanCode == EStdKeyLeftFunc)
       
  3093             {
       
  3094             LaunchSelectModeMenuL();
       
  3095             } // Predictive QWERTY (XT9) changes <----
       
  3096 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  3097         }       
       
  3098 
       
  3099     if (IsCcpuFlagSet(ECcpuStatePosted))           
       
  3100         {
       
  3101 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3102         // Query ptiEngine to know if the scancode maps to EPtiKeyQwertyC, 
       
  3103         // EPtiKeyQwertyV or EPtiKeyQwertyX.
       
  3104         // we should not always rely on scancode as products may change it, while
       
  3105         // still having the 'C', 'V' and 'X' mappings
       
  3106         
       
  3107         TBuf<32> mapData;              
       
  3108         iPtiEngine->MappingDataForKey((TPtiKey)aKeyEvent.iScanCode, mapData, EPtiCaseUpper); 
       
  3109         
       
  3110         if( mapData.Length() > 0 )    
       
  3111         	{
       
  3112         	if( mapData[0] == EPtiKeyQwertyC || mapData[0] == EPtiKeyQwertyX )
       
  3113         		{
       
  3114 	            // Let copy / cut events to flow through.
       
  3115 	            response = EKeyWasNotConsumed;
       
  3116 	            }
       
  3117         	}
       
  3118 #else
       
  3119         if (aKeyEvent.iScanCode == EPtiKeyQwertyC || aKeyEvent.iScanCode == EPtiKeyQwertyX)          
       
  3120             {
       
  3121             // Let copy / cut events to flow through.
       
  3122             response = EKeyWasNotConsumed;
       
  3123             }        
       
  3124 #endif   
       
  3125         ResetCcpuFlags();               
       
  3126         }
       
  3127 
       
  3128 /*    if (EPtiKeyboardQwerty4x10 == KeyboardLayout())
       
  3129     	{
       
  3130     	FepUI()->HandleKeyL(EKeyLeftCtrl, EShortKeyPress);    
       
  3131    	}*/
       
  3132 
       
  3133     //The default value of response is EKeyWasConsumed. So in some case, fep don¡¯t 
       
  3134     //do anything, but it return Consumed.
       
  3135     //This make app miss the event EEventKeyUp. 
       
  3136     //As per the logic of the function, the combine about ctrl key including:
       
  3137     //       Ctrl key + C; Ctrl key + V; Ctrl + X
       
  3138     //       Ctrl key + Shift key
       
  3139     //       Ctrl key + space
       
  3140     //       Ctrl key + Function key
       
  3141     //In above cases, it return EKeyWasConsumed, it is correct.
       
  3142     //The function for Ctrl Key as pressing the only one key ctrl at one time is to 
       
  3143     //do something if the flag EFlagQwertyShiftMode is set
       
  3144     //In this case, it return EKeyWasConsumed, it is correct.
       
  3145     //In other case, it should return EKeyWasNotConsumed
       
  3146     if( ( aKeyEvent.iScanCode == EStdKeyRightCtrl || aKeyEvent.iScanCode==EStdKeyLeftCtrl )
       
  3147         && !IsFlagSet(EFlagQwertyShiftMode) )
       
  3148         {
       
  3149         response = EKeyWasNotConsumed;
       
  3150         }
       
  3151 
       
  3152     return response;
       
  3153     }
       
  3154 
       
  3155 TBool CAknFepManager::HandleQwertyKeyEventL(const TKeyEvent& aKeyEvent, TKeyResponse& aResponse)
       
  3156     {
       
  3157     TBool keyHandled = EFalse;
       
  3158     aResponse = EKeyWasNotConsumed;
       
  3159 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  3160     if(iKeyBackSpaceHit && (EKeyBackspace != aKeyEvent.iCode || EStdKeyBackspace != aKeyEvent.iScanCode))
       
  3161         	iKeyBackSpaceHit = 0;
       
  3162         
       
  3163     if(IsMfneEditor())
       
  3164         {
       
  3165         // multi-field editors need the key event to be sent to them directly
       
  3166         // therefore not consuming it here
       
  3167         return EFalse;
       
  3168         }
       
  3169 
       
  3170     if(IsFlagSet(EFlagShiftKeyDepressed))
       
  3171         {
       
  3172         iKeyPressedDuringShift = ETrue; 
       
  3173         }  
       
  3174   // This part of code for error fixing
       
  3175     // After short pressing of Fn/shift, if user press enter key, delete key
       
  3176     // it will reset the shift key and Fn key state.
       
  3177     if( EKeyEnter == aKeyEvent.iCode || EStdKeyEnter == aKeyEvent.iScanCode|| 
       
  3178         EKeyBackspace == aKeyEvent.iCode || EStdKeyBackspace == aKeyEvent.iScanCode)
       
  3179         {
       
  3180 		// if the shift key is still depressed, 
       
  3181 		// don't clear the qwerty shift mode
       
  3182         if(!IsFlagSet(EFlagShiftKeyDepressed))
       
  3183         	ClearFlag(EFlagQwertyShiftMode);     
       
  3184         if( iFnKeyManager->FnKeyState() == CAknFepFnKeyManager::EFnKeyNext )
       
  3185             {
       
  3186             iFnKeyManager->ClearFnKeyState();
       
  3187             }
       
  3188         }
       
  3189 #endif    
       
  3190     
       
  3191     if ( iQwertyInputMode && 
       
  3192          ( EditorHasFreeSpace() || 
       
  3193 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__         
       
  3194 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  3195            KeyEventWillReplaceCharacter( aKeyEvent ) ||
       
  3196 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  3197 #endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__         
       
  3198            ( Japanese() && iFepManState == EAknFepStateUIActive ) ) )
       
  3199         {
       
  3200         if (IsFlagSet(EFlagPassNextKey))
       
  3201             {
       
  3202 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__            
       
  3203 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3204             // Don't clear the pass next flag yet on the simulated "rollback key"
       
  3205             // used with secret editors, the actual key code to be entered to the
       
  3206             // editor will follow next.
       
  3207             if ( aKeyEvent.iCode != EKeyF20 )
       
  3208 #endif // RD_INTELLIGENT_TEXT_INPUT          
       
  3209 #endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__          
       
  3210             ClearFlag(EFlagPassNextKey);
       
  3211             return ETrue;   
       
  3212             }        
       
  3213                  
       
  3214         TInt keyScanCode = aKeyEvent.iScanCode;
       
  3215 #if defined(__WINS__)
       
  3216         if ( keyScanCode == EStdKeyNkpPlus )
       
  3217             {
       
  3218             // Workaround solution for the qwerty '+' key in emulator environment.
       
  3219             // I did not find a way how to to configure epoc_352x416_Qwerty.ini to send '+' keyevent.
       
  3220             keyScanCode = 0x2b;  // '+' key.
       
  3221             }
       
  3222 #endif                 
       
  3223         TBool phoneIdle = (EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor);        
       
  3224 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3225         TInt keyLayout =iSharedDataInterface->KeyboardLayout();
       
  3226         if (IsOnlyNumericPermitted() && phoneIdle &&                
       
  3227 #ifdef __REVERSE_FN_KEY_SUPPORTED
       
  3228             !iIsReverseFnkeyInput &&
       
  3229 #endif
       
  3230             (keyLayout != EPtiKeyboardHalfQwerty ))                
       
  3231 #else
       
  3232         if (IsOnlyNumericPermitted() && phoneIdle)                
       
  3233 #endif
       
  3234             {
       
  3235             return ETrue;          
       
  3236             }
       
  3237         //if this SpecialNumeric editor, do not consume event.    
       
  3238         if (IsOnlyNumericPermitted() && IsSpecialNumericEditor())
       
  3239         	{
       
  3240         	return EFalse;
       
  3241         	}    
       
  3242       
       
  3243         
       
  3244 #ifdef FF_HOME_SCREEN_EASY_DIALING
       
  3245 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3246         
       
  3247         // This piece of code part of error fixing
       
  3248         // The Fep will insert the char, if Phone application launch the
       
  3249         // Phone number acquire editor in idle mode
       
  3250         // Specially Fep does not maintain Fn key state for non Fepware editor.
       
  3251         // So, Intermediate state of FnKey like FnNext will not work
       
  3252         // Hold on Fn key modify the modifier of of key event.
       
  3253         const TBool fnDown = (aKeyEvent.iModifiers & EModifierRightFunc);        
       
  3254         if( phoneIdle && fnDown && iFnKeyManager )
       
  3255             {
       
  3256             iFnKeyManager->SetFnKeyState(CAknFepFnKeyManager::EFnKeyDown);
       
  3257             SetCase((TCase)EFnKeyLowerCase);
       
  3258             }
       
  3259 #endif  // RD_INTELLIGENT_TEXT_INPUT
       
  3260 #endif  // FF_HOME_SCREEN_EASY_DIALING
       
  3261         
       
  3262        
       
  3263         const TBool shifted = (aKeyEvent.iModifiers & (EModifierLeftShift | 
       
  3264                                EModifierRightShift | EModifierShift));
       
  3265         
       
  3266         // This is needed for forcing shif state if this is the first key press in
       
  3267         // phone idle.    
       
  3268         if (shifted && phoneIdle)                    
       
  3269             {
       
  3270             SetFlag(EFlagQwertyShiftMode);
       
  3271             }                           
       
  3272 
       
  3273             
       
  3274         if (aKeyEvent.iRepeats == 1)
       
  3275             {
       
  3276             iKeyRepeat = ELongKeyPress;
       
  3277             }
       
  3278         else
       
  3279             {
       
  3280             iKeyRepeat = EShortKeyPress;
       
  3281             }
       
  3282                                   
       
  3283         if ( IsFlagSet(EFlagShiftKeyDepressed) &&
       
  3284             IsChineseInputLanguage() &&
       
  3285             keyScanCode == EPtiKeyQwertySpace) 
       
  3286             {
       
  3287             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  3288             ClearFlag(EFlagQwertyShiftMode);
       
  3289             ClearFlag(EFlagLongShiftKeyPress);
       
  3290             SetChangeModeByShiftAndSpace( ETrue );
       
  3291             TryIncrementChineseModeForQwertyL(iMode);
       
  3292             keyHandled = ETrue;
       
  3293             }
       
  3294 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3295 		else
       
  3296             {
       
  3297 	            if(iKeyRepeat == ELongKeyPress && iPtiEngine->CurrentWord().Length() == EMaximumFepWordLength)
       
  3298 	            {
       
  3299 	            	keyHandled = ETrue;
       
  3300 	            }
       
  3301 	            else
       
  3302 	            {
       
  3303 	            	keyHandled = FepUI()->HandleKeyL(keyScanCode, iKeyRepeat);     
       
  3304 					if( EPtiKeyboardHalfQwerty == KeyboardLayout() 
       
  3305 	            			&& iWesternPredictive
       
  3306 	            			&& iCaseMan->CurrentCase() != EAknEditorUpperCase )
       
  3307 	            		{
       
  3308 	            		ClearFlag(CAknFepManager::EFlagChangeInputMode);
       
  3309 	            		}
       
  3310 	            	if ( keyHandled && iFepManState == EAknFepStateUIActive 
       
  3311 	            			&& (iMode == EPinyin || iMode == EZhuyin || iMode == EStroke || iMode == ECangJie) )
       
  3312 	            		{
       
  3313 	            		if ( EditorState() )
       
  3314 	            			{
       
  3315 		            		EditorState()->SetFlags( EditorState()->Flags() | EAknEditorFlagChinesePopup );
       
  3316 	            			}
       
  3317 	            		}
       
  3318 	            }
       
  3319             }
       
  3320 #else
       
  3321         if (IsChineseInputLanguage() && keyScanCode == EStdKeyBackspace)
       
  3322             {
       
  3323             keyHandled = FepUI()->HandleKeyL(keyScanCode, iKeyRepeat);
       
  3324             }
       
  3325             else
       
  3326             {
       
  3327             keyHandled = FepUI()->HandleKeyL(keyScanCode, EShortKeyPress);      
       
  3328             }
       
  3329 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  3330         
       
  3331         if (keyHandled)
       
  3332             {
       
  3333             aResponse = EKeyWasConsumed;
       
  3334 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3335             // Predictive QWERTY changes ---->
       
  3336             if ( iLangMan->IsSplitView() || ( iFepPluginManager && !iFepPluginManager->EnableITIOnFSQ()))
       
  3337                 {
       
  3338                 ShowExactWordPopupIfNecessaryL();
       
  3339                 }
       
  3340             // Predictive QWERTY changes <----
       
  3341             }
       
  3342 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  3343 
       
  3344             // The indicators should be updated only if the key was handled. Otherwise
       
  3345             // the shift-copy-pasting will mess up the indicators.
       
  3346 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3347     TInt language = iSharedDataInterface->InputTextLanguage();
       
  3348     TBool IsChineseInput = language == ELangTaiwanChinese||
       
  3349                            language == ELangHongKongChinese ||
       
  3350                            language == ELangPrcChinese;
       
  3351 #endif      
       
  3352        if ( !shifted  )
       
  3353             {           
       
  3354 #ifdef RD_INTELLIGENT_TEXT_INPUT     
       
  3355             if(IsChineseInput && (iKeyboardType!= EPtiKeyboardHalfQwerty)) 
       
  3356                 {
       
  3357                 ClearFlag(EFlagQwertyShiftMode);
       
  3358                 UpdateIndicators();      
       
  3359                 }
       
  3360             else if( keyHandled )
       
  3361                 {
       
  3362 #endif                 
       
  3363                 ClearFlag(EFlagQwertyShiftMode);
       
  3364                 UpdateIndicators();
       
  3365                 
       
  3366 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  3367                 }
       
  3368 #endif
       
  3369             } 
       
  3370               
       
  3371 #ifdef RD_SCALABLE_UI_V2
       
  3372     if ( ( (keyScanCode >= EPtiKeyQwertyA && keyScanCode <= EPtiKeyQwertyZ) ||
       
  3373          (keyScanCode >= EPtiKeyQwerty0 && keyScanCode <= EPtiKeyQwerty9) ||
       
  3374          (keyScanCode == EStdKeyEnter) ||
       
  3375          (keyScanCode == EPtiKeyQwertyPlus) ||
       
  3376          (keyScanCode == EPtiKeyQwertyMinus) ||
       
  3377          (keyScanCode == EPtiKeyQwertyComma) ||
       
  3378          (keyScanCode == EPtiKeyQwertySemicolon) ||
       
  3379          (keyScanCode == EPtiKeyQwertyFullstop)  ||
       
  3380          (keyScanCode == EPtiKeyQwertyHash)  ||
       
  3381          (keyScanCode == EPtiKeyQwertySlash) ||
       
  3382          (keyScanCode == EPtiKeyQwertyApostrophe) )
       
  3383          && !( iFepPluginManager && iFepPluginManager->EnableITIOnFSQ() ) )          
       
  3384         {
       
  3385         //SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  3386         //iFepPluginManager->ClosePluginInputModeL(ETrue);
       
  3387         }
       
  3388     else if( keyHandled )
       
  3389         {
       
  3390         //for QWERTY, number only, the number is send to editor
       
  3391         //bypass FEP
       
  3392         SendEventsToPluginManL( EPluginSyncFepAwareText ); 
       
  3393         //iFepPluginManager->SyncFepAwareText();
       
  3394         }
       
  3395 #endif
       
  3396         }
       
  3397         
       
  3398 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
  3399 
       
  3400         TInt lang = iSharedDataInterface->InputTextLanguage();
       
  3401 
       
  3402         if(lang == ELangTaiwanChinese||
       
  3403            lang == ELangHongKongChinese ||
       
  3404            lang == ELangPrcChinese)    
       
  3405             {        
       
  3406             if( CurrentInputLangCode() == ELangEnglish 
       
  3407                 && IsFlagSet(EFlagQwertyShiftMode)
       
  3408                 && !IsFlagSet(EFlagLongShiftKeyPress))
       
  3409                 {
       
  3410                 ClearFlag(EFlagQwertyShiftMode); 
       
  3411                 UpdateIndicators();  
       
  3412                 }
       
  3413             }
       
  3414 #endif // RD_INTELLIGENT_TEXT_INPUT  
       
  3415     iKeyRepeat = EShortKeyPress;        
       
  3416     return keyHandled;
       
  3417     }
       
  3418 
       
  3419 
       
  3420 
       
  3421 void CAknFepManager::CancelTransaction()
       
  3422     {
       
  3423     if (iInputCapabilities.FepAwareTextEditor() && IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  3424         {
       
  3425         CancelInlineEdit();
       
  3426         }
       
  3427     }
       
  3428 
       
  3429 void CAknFepManager::IsOnHasChangedState()
       
  3430     {
       
  3431     }
       
  3432 
       
  3433 void CAknFepManager::OfferKeyEventL(TEventResponse& /*aEventResponse*/, 
       
  3434                                     const TKeyEvent& /*aKeyEvent*/, 
       
  3435                                     TEventCode /*aEventCode*/)
       
  3436     {
       
  3437     }
       
  3438 
       
  3439 void CAknFepManager::OfferPointerEventL(TEventResponse& /*aEventResponse*/, 
       
  3440                                         const TPointerEvent& /*aPointerEvent*/, 
       
  3441                                         const CCoeControl* /*aWindowOwningControl*/)
       
  3442     {
       
  3443     }
       
  3444 
       
  3445 void CAknFepManager::OfferPointerBufferReadyEventL(TEventResponse& /*aEventResponse*/, 
       
  3446                                                    const CCoeControl* /*aWindowOwningControl*/)
       
  3447     {
       
  3448     }
       
  3449 
       
  3450 TInt CAknFepManager::NumberOfAttributes() const
       
  3451     {
       
  3452     return 0;
       
  3453     }
       
  3454 
       
  3455 TUid CAknFepManager::AttributeAtIndex(TInt /*aIndex*/) const
       
  3456     {
       
  3457     return KNullUid;
       
  3458     }
       
  3459 
       
  3460 void CAknFepManager::WriteAttributeDataToStreamL(TUid /*aAttributeUid*/, RWriteStream& /*aStream*/) const
       
  3461     {
       
  3462     }
       
  3463 
       
  3464 void CAknFepManager::ReadAttributeDataFromStreamL(TUid /*aAttributeUid*/, RReadStream& /*aStream*/)
       
  3465     {
       
  3466     }
       
  3467 
       
  3468 void CAknFepManager::HandleGainingForeground()
       
  3469     {
       
  3470     if (iFepFullyConstructed)
       
  3471         {
       
  3472         ClearFlag(EFlagRemoveMatchesMenuItem);
       
  3473         ClearCcpuFlag(ECcpuStateHashDown | ECcpuStateSelectionEventPosted | 
       
  3474                       ECcpuStateEdwinInSelectionMode);
       
  3475         TRAPD(err, iPtiEngine->HandleCommandL(EPtiCommandReloadLearningInfo));
       
  3476         if (err != KErrNone)
       
  3477             {
       
  3478             CleanUpFep();
       
  3479             }
       
  3480         }
       
  3481 
       
  3482 #ifdef RD_SCALABLE_UI_V2        
       
  3483     CCoeControl* focusCtrl = static_cast<const CCoeAppUi*>(CCoeEnv::Static()->AppUi())->TopFocusedControl(); 
       
  3484     iGainForeground = ETrue;
       
  3485     /*if( iLoseForeAndGainFocus )
       
  3486         {
       
  3487         SendEventsToPluginManL( EPluginFocusChanged, iGainForeground );
       
  3488         }*/
       
  3489     if(focusCtrl && focusCtrl->IsFocused())
       
  3490         {
       
  3491         if(GetForegroundTaskAppWgId() == CCoeEnv::Static()->RootWin().Identifier())
       
  3492             //SendEventsToPluginManL( EPluginFocusChanged, iGainForeground );
       
  3493             TRAP_IGNORE(SendEventsToPluginManL( EPluginForegroundChanged, ETrue));            
       
  3494         }
       
  3495     else
       
  3496         {
       
  3497         if (iFepPluginManager) 
       
  3498             {
       
  3499             iFepPluginManager->HandleiDimGainForeground(ETrue);   
       
  3500             }            
       
  3501         }
       
  3502 #endif // RD_SCALABLE_UI_V2        
       
  3503     }
       
  3504 
       
  3505 void CAknFepManager::HandleLosingForeground()
       
  3506     {
       
  3507     if (iFepFullyConstructed)
       
  3508         {
       
  3509         // Forget the shift state on FEP switch (i.e. when application goes to background)
       
  3510         ClearFlag(EFlagQwertyShiftMode | EFlagShiftKeyDepressed | 
       
  3511                   EFlagLongShiftKeyPress | EFlagNoActionDuringShiftKeyPress);
       
  3512         }	
       
  3513     if (Japanese())
       
  3514         {
       
  3515         TRAP_IGNORE(TryCloseUiL());
       
  3516         }
       
  3517     if (IsChineseInputLanguage())
       
  3518         {
       
  3519         TRAP_IGNORE(TryCloseUiL());
       
  3520         }
       
  3521         
       
  3522 #ifdef RD_SCALABLE_UI_V2     
       
  3523     iGainForeground = EFalse;
       
  3524     //SendEventsToPluginManL( EPluginFocusChanged, iGainForeground );
       
  3525     TRAP_IGNORE(SendEventsToPluginManL( EPluginForegroundChanged, EFalse));            
       
  3526 #endif // RD_SCALABLE_UI_V2    
       
  3527     }
       
  3528 
       
  3529 void CAknFepManager::HandleChangeInFocus()
       
  3530     {
       
  3531     TRAPD(err, HandleChangeInFocusL());
       
  3532     if (err != KErrNone)
       
  3533         {
       
  3534         CleanUpFep();
       
  3535         }
       
  3536     }
       
  3537 
       
  3538 void CAknFepManager::HandleChangeInFocusForSettingFep()
       
  3539 	{
       
  3540 	HandleChangeInFocus();
       
  3541 	}
       
  3542 
       
  3543 void CAknFepManager::HandleDestructionOfFocusedItem()
       
  3544     {
       
  3545     if (iInputCapabilities.FepAwareTextEditor())
       
  3546         {
       
  3547         iFocusedItemDestroy = ETrue;
       
  3548         if ( iFepManState == EAknFepStateUIActive )
       
  3549             {            
       
  3550             TRAP_IGNORE(SendEventsToPluginManL( EPluginFocusItemDestroy ));  
       
  3551             if (Japanese() && iAknEditorFlags & EAknEditorFlagFindPane)
       
  3552                 {
       
  3553                 // In case of Find pane while inputting japanese characters,
       
  3554                 // No update or commit characters.
       
  3555                 iPtiEngine->ClearCurrentWord();
       
  3556                 }
       
  3557 
       
  3558         #ifdef RD_SCALABLE_UI_V2
       
  3559             // For addition of ITI features on FSQ, 
       
  3560             // need to restore some values stored before opening FSQ
       
  3561             // When go into this section, 
       
  3562             // touch ui won't be closed by ClosePluginInputUiL,
       
  3563             // but need to restore fep state here            
       
  3564             if ( iFepPluginManager )
       
  3565             	{
       
  3566                 TRAP_IGNORE(iFepPluginManager->ResetItiStateL());
       
  3567             	}
       
  3568         #endif
       
  3569             // Close UI
       
  3570             if ( FepUI())
       
  3571                 {
       
  3572                 FepUI()->CloseUI();
       
  3573                 }
       
  3574             }
       
  3575         else
       
  3576             {            
       
  3577             TRAP_IGNORE(SendEventsToPluginManL( EPluginFocusItemDestroy, ETrue ));  
       
  3578             }
       
  3579         iFocusedItemDestroy = EFalse;
       
  3580         }
       
  3581 
       
  3582     if ( !(IsFlagSet(EFlagForegroundUIComponentVisible) ||
       
  3583         IsFlagSet(EFlagMenuPaneVisible)) )
       
  3584         {
       
  3585         iLanguageCapabilities.iNumericEditorDigitType = EDigitTypeUnknown;
       
  3586         //UpdateLocalDigitMode();
       
  3587         }
       
  3588     if(IsFlagSet(EFlagForegroundUIComponentVisible))
       
  3589         {
       
  3590         ClearFlag(EFlagForegroundUIComponentVisible);
       
  3591         }
       
  3592 
       
  3593     ClearFlag( EFlagInsideInlineEditingTransaction |
       
  3594         EFlagInsideMultitapInlineEditingTransaction |
       
  3595         EFlagLineFeedCharacter | EFlagNoMatches );
       
  3596 
       
  3597     iInputCapabilities = NULL;
       
  3598     }
       
  3599 
       
  3600 void CAknFepManager::HandleAknEdwinStateEventL(CAknEdwinState* aAknEdwinState, 
       
  3601                                                EAknEdwinStateEvent aEventType)
       
  3602     {
       
  3603     if(aEventType == EAknEdwinDestroy)
       
  3604     	{
       
  3605 		// Reset the last focus editor when destroy it.
       
  3606         if ( aAknEdwinState == iLastFocusedEditor )
       
  3607             {
       
  3608             iLastFocusedEditor->SetObserver( NULL );
       
  3609             iLastFocusedEditor = NULL;
       
  3610             }
       
  3611         
       
  3612         // Whenever the editor is destroyed, we destroy all the UI components we launched
       
  3613         if(iFepAwareDialogParentEditor == NULL || 
       
  3614         		iFepAwareDialogParentEditor == aAknEdwinState)
       
  3615         	{
       
  3616             // EExtendedFlagEdwinEditorDestroyed flag is used to leave once the dialog is closed.
       
  3617             SetExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  3618             // Delete any candidate popup is launched
       
  3619             if(iCandidatePopup)
       
  3620                 {
       
  3621                 delete iCandidatePopup;
       
  3622                 iCandidatePopup = NULL;
       
  3623                 }        
       
  3624             // Delete anu UI components launched by Fep.
       
  3625             iUiInterface->DeleteDialogs();
       
  3626         	}
       
  3627         
       
  3628         if ( iFepPluginManager )
       
  3629         	{
       
  3630 			// Check whether the destroyed editor is the editor that stored in fep
       
  3631 			// according to the editor state
       
  3632 			if ( aAknEdwinState == iFepPluginManager->EdwinState())
       
  3633 				{
       
  3634 				// Set the editor pointer to NULL to avoid wild pointer exist
       
  3635 				iFepPluginManager->ClearDestroyedEditorPointer();
       
  3636 				}
       
  3637         	}
       
  3638     	}
       
  3639     if ( IsFepAwareTextEditor() )
       
  3640         {
       
  3641         CAknEdwinState* editorState = EditorState();
       
  3642         if ( editorState != aAknEdwinState || !iFepFullyConstructed )
       
  3643             {
       
  3644             // FEP state update is not needed because editor state of non-focused
       
  3645             // editor was changed.
       
  3646             return;
       
  3647             }
       
  3648 
       
  3649         switch (aEventType)
       
  3650             {
       
  3651             case EAknEdwinStateInputModeUpdate:
       
  3652                 {
       
  3653                 TUint currentInputMode = editorState->CurrentInputMode();
       
  3654                 if ( EditorModeFromFepMode(iMode) != currentInputMode )
       
  3655                     {
       
  3656                     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  3657                         {
       
  3658                         TryRemoveNoMatchesIndicatorL();
       
  3659                         }
       
  3660                     UpdateCbaL(NULL);
       
  3661                     TryCloseUiL();
       
  3662                     ConfigureFEPFromEditorStateL();
       
  3663                     }
       
  3664                 }
       
  3665                 break;
       
  3666             case EAknEdwinStateCaseModeUpdate:
       
  3667                 {
       
  3668                 TInt currentCaseMode = editorState->CurrentCase();
       
  3669                 if ( currentCaseMode != iCaseMan->CurrentCase() )
       
  3670                     {
       
  3671                     iCaseMan->SetCurrentCase(currentCaseMode);
       
  3672                     }
       
  3673                 }
       
  3674                 break;
       
  3675             case EAknEdwinStateLocalLanguageUpdate:
       
  3676                 {
       
  3677                 TLanguage localLanguage = ELangTest;
       
  3678                 if (GetLocalLanguage( localLanguage ) )
       
  3679                     {
       
  3680                     iLanguageCapabilities.iLocalInputLanguageInUse = ETrue;
       
  3681                     if ( localLanguage != iLanguageCapabilities.iInputLanguageCode )
       
  3682                         {
       
  3683                         ChangeInputLanguageL(localLanguage);
       
  3684                         }
       
  3685                     }
       
  3686                 }
       
  3687                 break;
       
  3688             case EAknEdwinStateFlagsUpdate:
       
  3689                 {
       
  3690                 TInt oldEditorFlags = iAknEditorFlags;
       
  3691                 if(iAknEditorFlags != editorState->Flags())
       
  3692                     {
       
  3693                     iAknEditorFlags = editorState->Flags();
       
  3694                     UpdateLocalDigitMode();
       
  3695                     }
       
  3696                 if ( iAknEditorFlags != oldEditorFlags )
       
  3697                     {
       
  3698                     if ( (iAknEditorFlags & EAknEditorFlagNoT9) != 
       
  3699                          (oldEditorFlags & EAknEditorFlagNoT9))
       
  3700                         {
       
  3701                         if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  3702                             {
       
  3703                             TryRemoveNoMatchesIndicatorL();
       
  3704                             }
       
  3705                         UpdateCbaL(NULL);
       
  3706                         TryCloseUiL();
       
  3707                         ConfigureFEPFromEditorStateL();
       
  3708                         }
       
  3709 
       
  3710                     if ( (iAknEditorFlags & EAknEditorFlagNoEditIndicators) != 
       
  3711                          (oldEditorFlags & EAknEditorFlagNoEditIndicators))
       
  3712                         {
       
  3713                         // We only need to update indicators when EAknEditorFlagNoEditIndicators was modified.
       
  3714                         // Current Fep state is not lost.
       
  3715                         UpdateIndicators();
       
  3716                         }
       
  3717 
       
  3718                     if ( (iAknEditorFlags & EAknEditorFlagFixedCase) != 
       
  3719                          (oldEditorFlags & EAknEditorFlagFixedCase))
       
  3720                         {
       
  3721                         // We only need to update EFlagSupressAutoUpdate flag when the
       
  3722                         // EAknEditorFlagFixedCase was modified.
       
  3723                         // Current Fep state is not lost.
       
  3724                         if (iAknEditorFlags & EAknEditorFlagFixedCase)
       
  3725                             {
       
  3726                             SetFlag(EFlagSupressAutoUpdate);
       
  3727                             }
       
  3728                         else
       
  3729                             {
       
  3730                             ClearFlag(EFlagSupressAutoUpdate);
       
  3731                             }
       
  3732                         }
       
  3733                     }
       
  3734                 }
       
  3735                 break;
       
  3736             case EAknEdwinStateEventStateUpdate:
       
  3737                 {
       
  3738                 // Feps state is reseted and new state is fetched completelly from editor state.
       
  3739                 if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  3740                     {
       
  3741                     TryRemoveNoMatchesIndicatorL();
       
  3742                     }
       
  3743                 UpdateCbaL(NULL);
       
  3744                 TryCloseUiL();
       
  3745                 ConfigureFEPFromEditorStateL();
       
  3746                 }
       
  3747                 break;           
       
  3748             case EAknSyncEdwinState:
       
  3749 #ifdef RD_SCALABLE_UI_V2
       
  3750                  if ( !IsCcpuFlagSet(ECcpuStateIgnoreNextEdwinSyncEvent) && iFepPluginManager &&
       
  3751                      iFepPluginManager->PluginInputMode() == EPluginInputModeNone )
       
  3752 #else
       
  3753                  if ( !IsCcpuFlagSet(ECcpuStateIgnoreNextEdwinSyncEvent) )
       
  3754 #endif                     
       
  3755                      {
       
  3756                      HandleChangeInFocusL();                        
       
  3757                      }
       
  3758                  else
       
  3759                     {
       
  3760                     ClearCcpuFlag(ECcpuStateIgnoreNextEdwinSyncEvent);
       
  3761                     }
       
  3762                  break;  
       
  3763                  
       
  3764 #ifdef RD_SCALABLE_UI_V2
       
  3765             case EAknActivatePenInputRequest:
       
  3766                 SendEventsToPluginManL( EPluginEditorActivate );
       
  3767                 break;
       
  3768             case EAknClosePenInputRequest:
       
  3769                 if ( iFepPluginManager )
       
  3770                     {
       
  3771                     iFepPluginManager->ClosePluginInputModeL( EFalse );
       
  3772                     }
       
  3773                 break;
       
  3774             case EAknEdwinStatePromptUpdate:
       
  3775                 SendEventsToPluginManL( EPluginPromptChanged ); 
       
  3776                 break;
       
  3777 #endif // RD_SCALABLE_UI_V2                
       
  3778             case EAknCursorPositionChanged:
       
  3779 #ifdef RD_SCALABLE_UI_V2  
       
  3780                 SendEventsToPluginManL( EPluginSyncFepAwareText );   
       
  3781                 HandleCopyCutStateL();    
       
  3782 #endif
       
  3783                 // whenever focus cahnged happen, internally
       
  3784                 // editor treat cursorposition change.
       
  3785                 // In between, if editor context not in inline edit state.
       
  3786                 // Try to update the case editor gets the focus, and editor
       
  3787                 // context come in inline state.                
       
  3788 				iCaseMan->UpdateCase( ENullNaviEvent );
       
  3789                 break;
       
  3790 
       
  3791             default:
       
  3792                 break;
       
  3793             }
       
  3794         }
       
  3795 #ifdef RD_SCALABLE_UI_V2
       
  3796     else
       
  3797         {
       
  3798         // Close touch input when inMenu is opened. When inMenu is opened, 
       
  3799         // editor loses focus, and inMenu gets focus. After touch input has 
       
  3800         // been force closed, menu state should be restored and last focused
       
  3801         // window ,which launches touch input, should be removed.
       
  3802         if( aEventType == EAknClosePenInputRequest  
       
  3803                 && iFepPluginManager  
       
  3804                 && iFepPluginManager->IsInMenuOpen() )
       
  3805             {
       
  3806             CCoeEnv* env = CCoeEnv::Static();
       
  3807             TKeyEvent keyEvent = {EKeyCBA2, EStdKeyNull, 0, 0};
       
  3808             env->SimulateKeyEventL(keyEvent,EEventKey);            
       
  3809             iFepPluginManager->ResetMenuState();            
       
  3810             iFepPluginManager->RemoveLastFocusedWinFromOpenList();
       
  3811             iFepPluginManager->ClosePluginInputModeL( EFalse );
       
  3812             }
       
  3813         }
       
  3814 #endif // RD_SCALABLE_UI_V2  
       
  3815     }
       
  3816 
       
  3817 
       
  3818 CAknExtendedInputCapabilities::TEditorType CAknFepManager::EditorType() const
       
  3819     {
       
  3820     MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
  3821 
       
  3822     if ( mop )
       
  3823         {
       
  3824         CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
  3825         mop->MopGetObject( extendedInputCapabilities );
       
  3826 
       
  3827         if ( extendedInputCapabilities && iInputCapabilities.FepAwareTextEditor() ) 
       
  3828             {
       
  3829             TInt type = extendedInputCapabilities->EditorType();                                     
       
  3830             return static_cast<CAknExtendedInputCapabilities::TEditorType>( type );
       
  3831             }
       
  3832         }
       
  3833         
       
  3834     return CAknExtendedInputCapabilities::EUndefined;
       
  3835     }
       
  3836 
       
  3837 TUint CAknFepManager::MIDPConstraint() const
       
  3838 	{
       
  3839 	TUint ConstraintValue=0xFFFFFFFF;
       
  3840 	MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
  3841 	
       
  3842 	if ( mop )
       
  3843 		{
       
  3844 		CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
  3845         mop->MopGetObject( extendedInputCapabilities );
       
  3846 		if ( extendedInputCapabilities && iInputCapabilities.FepAwareTextEditor() ) 
       
  3847 			{
       
  3848 			ConstraintValue = extendedInputCapabilities->MIDPConstrainst();
       
  3849 			}
       
  3850 		}
       
  3851 		return ConstraintValue;
       
  3852 	}
       
  3853     
       
  3854 TBool CAknFepManager::IsSpecialNumericEditor()
       
  3855 	{
       
  3856 	TBool JavaNumericEditor = EFalse;
       
  3857 	TUint ConstraintValue = MIDPConstraint();
       
  3858 	if((ConstraintValue & ESplConstraintMask) == ESplNumeric )
       
  3859 		JavaNumericEditor = ETrue;
       
  3860 	
       
  3861 	return JavaNumericEditor;
       
  3862 	
       
  3863 	}
       
  3864 #ifdef RD_SCALABLE_UI_V2
       
  3865 void CAknFepManager::HandleInputCapabilitiesEventL( TInt aEvent, TAny* /*aParams*/ )
       
  3866     {
       
  3867     switch (aEvent)
       
  3868         {
       
  3869         case CAknExtendedInputCapabilities::MAknEventObserver::EActivatePenInputRequest:
       
  3870             SendEventsToPluginManL( EPluginEditorActivate );
       
  3871             break;
       
  3872         case CAknExtendedInputCapabilities::MAknEventObserver::EClosePenInputRequest:
       
  3873             if ( iFepPluginManager )
       
  3874                 {
       
  3875                 iFepPluginManager->ClosePluginInputModeL( EFalse );
       
  3876                 }
       
  3877             break;
       
  3878         case CAknExtendedInputCapabilities::MAknEventObserver::EPointerEventReceived:
       
  3879 
       
  3880 /* 
       
  3881 #ifdef RD_TACTILE_FEEDBACK
       
  3882             CAknExtendedInputCapabilities::
       
  3883                 MAknEventObserver::TPointerEventReceivedParams* params = 
       
  3884                     static_cast<CAknExtendedInputCapabilities::
       
  3885                 MAknEventObserver::TPointerEventReceivedParams*>(aParams);
       
  3886             if (params->iPointerEvent.iType == TPointerEvent::EButton1Down)            
       
  3887                 {
       
  3888                 
       
  3889                 MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  3890                 if (feedback && iFepPluginManager && !iFepPluginManager->VKBIsOpened())
       
  3891                     {
       
  3892                     feedback->InstantFeedback( ETouchFeedbackBasic );
       
  3893                     }
       
  3894                 }
       
  3895 #endif // RD_TACTILE_FEEDBACK
       
  3896 */
       
  3897             if( IsFlagSet( EFlagInsideInlineEditingTransaction ) )
       
  3898                 {
       
  3899                 if (IsFeatureSupportedJapanese())
       
  3900 			        {
       
  3901 			        TryCloseUiL();
       
  3902 			        }
       
  3903 			    else
       
  3904 			        {
       
  3905 #ifdef RD_INTELLIGENT_TEXT_INPUT			        
       
  3906 			        iPtiEngine->CommitCurrentWord();
       
  3907 					CommitInlineEditL();
       
  3908 			        TryCloseUiL();
       
  3909 
       
  3910 #else
       
  3911 					CommitInlineEditL();
       
  3912 #endif			        
       
  3913 			        }
       
  3914                 }
       
  3915             break;      
       
  3916         case CAknExtendedInputCapabilities::MAknEventObserver::EControlContentUpdatedInternally:
       
  3917             SendEventsToPluginManL( EPluginSyncFepAwareText, EPluginSyncAll );
       
  3918             break;
       
  3919         case CAknExtendedInputCapabilities::MAknEventObserver::EOpenStylusMenuCcpu:
       
  3920             // User has highlighted text and editor requests stylus ccpu popup menu
       
  3921             // to be displayed.        
       
  3922             LaunchStylusCcpuMenuL(iClickPoint);
       
  3923             break;
       
  3924         }    
       
  3925     }
       
  3926     
       
  3927 void CAknFepManager::SubmitInlineTextL( const TDesC& aData )
       
  3928     {
       
  3929     if(TextIsValidInEditor(aData))
       
  3930     	{
       
  3931     	StartInlineEditL(aData);
       
  3932     	CommitInlineEditL();
       
  3933     	}
       
  3934     }
       
  3935     
       
  3936 // for japanese  
       
  3937 void CAknFepManager::NotifyJapaneseSetting()
       
  3938     {
       
  3939 	TInt param = 0;
       
  3940     // Deleting direction ON(right side) / OFF(left side)
       
  3941     if (iSharedDataInterface->ClearDirection() == EClearDirectionRight)
       
  3942         {
       
  3943         param |= EPenInputJapaneseSettingDeletingDirection;
       
  3944         }
       
  3945     // Japanese predictive ON(predictive on) / OFF(predictive off)
       
  3946     if (iJapanesePredictive)
       
  3947         {
       
  3948         param |= EPenInputJapaneseSettingPredictive;
       
  3949         }
       
  3950     // Japanese HWR conversion ON / OFF
       
  3951     if (iSharedDataInterface->JapaneseHwrConversion() == EJapaneseConversionOn)
       
  3952         {
       
  3953         param |= EPenInputJapaneseSettingConversion;
       
  3954         }
       
  3955     // Japanese HWR conversion ON / OFF
       
  3956     if (iCharWidth == EFullWidthChar)
       
  3957         {
       
  3958         param |= EPenInputJapaneseSettingCharacterWidth;
       
  3959         }
       
  3960     // Japanese qwerty setting flag
       
  3961     TInt qwertflag = iSharedDataInterface->JapaneseQwertyFlags();
       
  3962     // Qwerty Comma
       
  3963     if (qwertflag & EJapQwertySettingComma)
       
  3964         {
       
  3965         param |= EPenInputJapaneseSettingQwertyComma;
       
  3966         }
       
  3967     // Qwerty Period
       
  3968     if (qwertflag & EJapQwertySettingPeriod)
       
  3969         {
       
  3970         param |= EPenInputJapaneseSettingQwertyPeriod;
       
  3971         }
       
  3972     // Qwerty Width Of Space
       
  3973     if (qwertflag & EJapQwertySettingSpaceFullWidth)
       
  3974         {
       
  3975         param |= EPenInputJapaneseSettingQwertyWidthOfSpace;
       
  3976         }
       
  3977     // Lunch SCT
       
  3978     if (IsAbleToLaunchSCT())
       
  3979         {
       
  3980         param |= EPenInputJapaneseSettingLunchSCT;
       
  3981         }
       
  3982 #ifdef RD_SCALABLE_UI_V2
       
  3983     // Set Japanese setting
       
  3984     if(iFepPluginManager->CurrentPluginInputFepUI())    
       
  3985         {
       
  3986         TRAP_IGNORE(iFepPluginManager->CurrentPluginInputFepUI()->HandleCommandL(
       
  3987                                              ECmdPenInputJapaneseSetting, param));
       
  3988         }
       
  3989 #endif //RD_SCALABLE_UI_V2    
       
  3990     }
       
  3991 
       
  3992 TBool CAknFepManager::FullyFepAwareTextEditor() const
       
  3993     {
       
  3994     if ( iInputCapabilities.FepAwareTextEditor() )
       
  3995         {
       
  3996         if ( EditorType() != CAknExtendedInputCapabilities::EMFNEBased )
       
  3997             {
       
  3998             return ETrue;
       
  3999             }
       
  4000         }
       
  4001         
       
  4002     return EFalse;
       
  4003     }
       
  4004 
       
  4005 TBool CAknFepManager::SemiFepAwareTextEditor( TBool aAtLeast ) const
       
  4006     {
       
  4007     if ( aAtLeast )
       
  4008         {
       
  4009         switch ( EditorType() )
       
  4010             {
       
  4011             case CAknExtendedInputCapabilities::EEdwinBased:
       
  4012             case CAknExtendedInputCapabilities::EMFNEBased:
       
  4013                 return ETrue;
       
  4014                 
       
  4015             default:
       
  4016                 return EFalse;
       
  4017             }
       
  4018         }
       
  4019     else
       
  4020         {
       
  4021         return EditorType() == CAknExtendedInputCapabilities::EMFNEBased;
       
  4022         }
       
  4023     }
       
  4024     
       
  4025 void CAknFepManager::ProcessEditorMenuCommand(TInt aCommand)
       
  4026     {
       
  4027     TRAP_IGNORE(ProcessCommandL(aCommand));    
       
  4028     }
       
  4029     
       
  4030 TInt CAknFepManager::GetPermittedEditorMenu(TBool aOnlyCount)
       
  4031     {
       
  4032     TInt count = 0;
       
  4033     TRAP_IGNORE(count = GetPermittedEditorMenuL(aOnlyCount));
       
  4034     return count;
       
  4035     }
       
  4036 
       
  4037 TInt CAknFepManager::GetPermittedEditorMenuL(TBool aOnlyCount)
       
  4038     {
       
  4039     
       
  4040     CAknEdwinState* editorState = NULL;
       
  4041     if (iInputCapabilities.FepAwareTextEditor())
       
  4042         {
       
  4043         editorState = EditorState();
       
  4044         }
       
  4045     
       
  4046     CAknFepUiInterfaceMenuBar* menuBar = NULL;
       
  4047 
       
  4048 	RPointerArray<CEikMenuPaneItem> editorMenuItemList;	
       
  4049     
       
  4050     CEikMenuPane* editorMenuPane = new (ELeave) CEikMenuPane((MEikMenuObserver*)(this));
       
  4051     CleanupDeletePushL( editorMenuPane );
       
  4052     
       
  4053     editorMenuPane->SetItemArrayOwnedExternally(EFalse);
       
  4054     TResourceReader reader;
       
  4055     CCoeEnv::Static()->CreateResourceReaderLC(reader, R_AVKON_TOUCH_INDICATOR_EDIT_MODE_MENU);//
       
  4056         
       
  4057     const TInt menuCount=reader.ReadInt16();
       
  4058     for ( TInt ii=0; ii<menuCount; ++ii )
       
  4059         {
       
  4060         CEikMenuPaneItem* item = new(ELeave) CEikMenuPaneItem();
       
  4061         CleanupStack::PushL( item );
       
  4062         item->iData.iCommandId = reader.ReadInt32();
       
  4063         item->iData.iCascadeId = reader.ReadInt32();
       
  4064         item->iData.iFlags = reader.ReadInt32();
       
  4065         TPtrC txtptr = reader.ReadTPtrC();
       
  4066         item->SetScaleableTextL( txtptr );
       
  4067         TPtrC extratxtptr = reader.ReadTPtrC();
       
  4068         item->iData.iExtraText = extratxtptr;
       
  4069         TPtrC bitmapFile = reader.ReadTPtrC();
       
  4070         TInt bitmapId = reader.ReadInt16();
       
  4071         TInt bitmapMaskId = reader.ReadInt16();
       
  4072         CleanupStack::Pop(); // pop first, since additem pushes again
       
  4073         editorMenuPane->AddMenuItemL( item->iData );
       
  4074         editorMenuItemList.Append(item);
       
  4075         reader.ReadInt32(); // extension link
       
  4076         }
       
  4077         
       
  4078     CleanupStack::PopAndDestroy(); //reader 
       
  4079 
       
  4080             
       
  4081     if (editorState)
       
  4082         {
       
  4083         menuBar = iUiInterface->EditorStateMenuBar(editorState);
       
  4084         }
       
  4085     
       
  4086     TInt count = 0;            
       
  4087     
       
  4088     if ( menuBar )
       
  4089         {
       
  4090         CAknFepUiInterfaceMenuPane* menuPane = menuBar->MenuPane();
       
  4091 
       
  4092         CEikMenuPane* oldMenuPane = menuPane->GetMenuPane();
       
  4093    
       
  4094         menuPane->SetMenuPane(editorMenuPane);             
       
  4095              
       
  4096         DynInitTouchMenuPaneL(menuPane);
       
  4097         
       
  4098         menuPane->SetMenuPane(oldMenuPane);
       
  4099                 
       
  4100 
       
  4101         for (TInt ii = 0; ii < KMaxMenuSize; ii++)
       
  4102             {
       
  4103             CEikMenuPaneItem::SData& itemdata = 
       
  4104                         editorMenuPane->ItemData(KEditorMenuPermitedSend[ii]);
       
  4105             if ( !(itemdata.iFlags & EEikMenuItemDimmed ) )
       
  4106                 {
       
  4107                 count = count + 1;
       
  4108                 iEditorCommandList[count] = itemdata.iCommandId; 
       
  4109                 }
       
  4110             }
       
  4111         iEditorCommandList[0] = count;
       
  4112         if (!aOnlyCount && iFepPluginManager->CurrentPluginInputFepUI())
       
  4113             {
       
  4114             iFepPluginManager->CurrentPluginInputFepUI()->HandleCommandL(
       
  4115                         ECmdPenInputSendEditMenuData, reinterpret_cast<TInt>(iEditorCommandList));
       
  4116             }
       
  4117         }
       
  4118     
       
  4119     editorMenuItemList.ResetAndDestroy();
       
  4120 	CleanupStack::PopAndDestroy(editorMenuPane);
       
  4121 	
       
  4122     return count;
       
  4123     }
       
  4124 #endif // RD_SCALABLE_UI_V2
       
  4125 
       
  4126 void CAknFepManager::ExitPluginSpellModeByOk()
       
  4127     {
       
  4128     TRAP_IGNORE(ExitPluginSpellModeByOkL());
       
  4129     }
       
  4130 
       
  4131 void CAknFepManager::ExitPluginSpellModeByOkL()
       
  4132     {
       
  4133 #ifdef RD_SCALABLE_UI_V2        		    
       
  4134     if (iFepPluginManager->IsSpellVisible())
       
  4135         {
       
  4136         CommitInlineEditL();
       
  4137         HBufC* spell = iFepPluginManager->SpellTextInput();
       
  4138         
       
  4139         iFepPluginManager->SetITUTSpellingStateL(EFalse); 
       
  4140         iFepPluginManager->HideSpellEditor();        
       
  4141         
       
  4142         if (spell)
       
  4143             {
       
  4144             CleanupStack::PushL(spell);
       
  4145             TPtr text = spell->Des();
       
  4146             FepUI()->AddTextToUserDictionaryL(text);
       
  4147             InsertTextFromDialogL(text, iFepPluginManager->CursorSelection());
       
  4148             CleanupStack::PopAndDestroy(spell);
       
  4149             }
       
  4150         
       
  4151         UpdateCbaL(NULL); 
       
  4152         if (iFepPluginManager->CaseUpdatesSupressed())
       
  4153             {
       
  4154             SetFlag(EFlagSupressAutoUpdate);
       
  4155             }
       
  4156         else
       
  4157             {
       
  4158             ClearFlag(EFlagSupressAutoUpdate);
       
  4159             }
       
  4160         ClearFlag(EFlagSupressAutoUpdateAtEditorStart);
       
  4161         }
       
  4162 #endif       		    
       
  4163     }
       
  4164 
       
  4165 void CAknFepManager::ExitPluginSpellModeByCancel()
       
  4166     {
       
  4167 /*    
       
  4168 #ifdef RD_SCALABLE_UI_V2
       
  4169     if (iFepPluginManager->IsSpellVisible())
       
  4170         {
       
  4171         iFepPluginManager->SetITUTSpellingStateL(EFalse); 
       
  4172         iFepPluginManager->DestroySpellEditor();
       
  4173         UpdateCbaL(NULL);
       
  4174         HandleChangeInFocus();
       
  4175         if (iFepPluginManager->CursorSelection().Length())
       
  4176             {
       
  4177             EditorState()->SetInlineEditSpan(iFepPluginManager->CursorSelection());
       
  4178             ConfigureFEPFromEditorStateL();
       
  4179             }
       
  4180         TransferFepStateToEditorL();
       
  4181 
       
  4182         if (iFepPluginManager->CaseUpdatesSupressed())
       
  4183             {
       
  4184             SetFlag(EFlagSupressAutoUpdate);
       
  4185             }
       
  4186         else
       
  4187             {
       
  4188             ClearFlag(EFlagSupressAutoUpdate);
       
  4189             }
       
  4190         ClearFlag(EFlagSupressAutoUpdateAtEditorStart);
       
  4191         iFepPluginManager->SetBeforeSpell(ETrue);
       
  4192         }
       
  4193 #endif
       
  4194 */
       
  4195 #ifdef RD_SCALABLE_UI_V2
       
  4196     if (iFepPluginManager->IsSpellVisible())
       
  4197         {
       
  4198         TRAP_IGNORE(iFepPluginManager->SetITUTSpellingStateL(EFalse)); 
       
  4199         iFepPluginManager->HideSpellEditor();        
       
  4200 
       
  4201         TRAP_IGNORE(UpdateCbaL(NULL)); 
       
  4202         if (iFepPluginManager->CaseUpdatesSupressed())
       
  4203             {
       
  4204             SetFlag(EFlagSupressAutoUpdate);
       
  4205             }
       
  4206         else
       
  4207             {
       
  4208             ClearFlag(EFlagSupressAutoUpdate);
       
  4209             }
       
  4210         ClearFlag(EFlagSupressAutoUpdateAtEditorStart);
       
  4211         }
       
  4212 #endif       		
       
  4213     }
       
  4214 
       
  4215 void CAknFepManager::ProcessCommandL(TInt aCommandId)
       
  4216     {
       
  4217     //ProcessCommandL() is called before HandleChangeInFocus() for the editor to insert the
       
  4218     //number into, so have to force a call
       
  4219     
       
  4220     //Process pen input menu if avaliable
       
  4221 #ifdef RD_SCALABLE_UI_V2
       
  4222 
       
  4223      if (iFepPluginManager && 
       
  4224         (iFepPluginManager->PluginInputMode() == EPluginInputModeItut)) 
       
  4225        	{
       
  4226        	switch(aCommandId)
       
  4227        		{
       
  4228        		case EAknSoftkeyOptions:
       
  4229        		    {
       
  4230        		    LaunchSelectModeMenuL();
       
  4231        		    }
       
  4232        		    return;
       
  4233        		case EAknSoftkeyOk:
       
  4234        		    {
       
  4235                 iFepPluginManager->ClosePluginInputModeL(ETrue);
       
  4236        		    }
       
  4237        		    return;
       
  4238        		default:
       
  4239        			{
       
  4240        			break;
       
  4241        			}
       
  4242        		}
       
  4243        	}
       
  4244 
       
  4245     SendEventsToPluginManL( EPluginMenuCmd, aCommandId );
       
  4246 
       
  4247 #endif //RD_SCALABLE_UI_V2
       
  4248     MAknFepManagerInterface* currentFepUI=NULL;
       
  4249     switch (aCommandId)
       
  4250         {
       
  4251         // Edit mode menu commands
       
  4252         //The soft CBA event from touch screen. 
       
  4253         case EAknSoftkeyCancel:
       
  4254       //  case (TUint16)EAknSoftkeyCancel:
       
  4255         case EAknSoftkeySelect:
       
  4256      //   case (TUint16)EAknSoftkeySelect:
       
  4257         currentFepUI = FepUI();
       
  4258         if (currentFepUI)
       
  4259             currentFepUI->HandleCommandL( aCommandId );
       
  4260             break;
       
  4261         // --- commands for Japanese ---
       
  4262         case EJapanFepCmdModeHiragana:
       
  4263             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4264             HandleChangeInFocus();
       
  4265             TryChangeModeL(EHiraganaKanji);
       
  4266             break;
       
  4267         case EJapanFepCmdModeKatakana:
       
  4268             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4269             HandleChangeInFocus();
       
  4270             TryChangeModeL(EKatakana);
       
  4271             break;
       
  4272         case EAknCmdEditInsertPictograph:
       
  4273             SetStopProcessFocus(ETrue);            
       
  4274             HandleChangeInFocus();
       
  4275             LaunchPictographCharacterTableL();
       
  4276             SetStopProcessFocus(EFalse);            
       
  4277             break;
       
  4278         case EJapanFepCmdModeFullWidth:
       
  4279         case EPenInputJpCmdFullWidth:
       
  4280         case EJapanFepCmdModeHalfWidth:
       
  4281         case EPenInputJpCmdHalfWidth:
       
  4282             {
       
  4283             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4284             HandleChangeInFocus();
       
  4285             if (aCommandId == EJapanFepCmdModeFullWidth
       
  4286              || aCommandId == EPenInputJpCmdFullWidth)
       
  4287                 {
       
  4288                 iCharWidth = EFullWidthChar;
       
  4289                 }
       
  4290             else
       
  4291                 {
       
  4292                 iCharWidth = EHalfWidthChar;
       
  4293                 }
       
  4294             UpdateIndicators();
       
  4295             TryChangeModeL(iMode);
       
  4296 #ifdef RD_SCALABLE_UI_V2
       
  4297             if (aCommandId == EPenInputJpCmdFullWidth
       
  4298              || aCommandId == EPenInputJpCmdHalfWidth)
       
  4299                 {
       
  4300                 // Re-open pen input window
       
  4301                 SendEventsToPluginManL( EPluginActivate );  
       
  4302                 }
       
  4303 #endif //RD_SCALABLE_UI_V2
       
  4304             }
       
  4305             break;
       
  4306         case EJapanFepCmdModeUserDic:
       
  4307         case EPenInputJpCmdSaveWord:
       
  4308             {
       
  4309             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4310             // User dictionary
       
  4311 #ifdef RD_PF_SEC_APPARC
       
  4312             // Launch settings app
       
  4313             if ( iNullService )
       
  4314                 {
       
  4315                 delete iNullService;
       
  4316                 iNullService = NULL;
       
  4317                 }
       
  4318             iNullService = CAknNullService::NewL( KUidUserDictApp, this );
       
  4319 #else
       
  4320             CEikProcess* process = CEikonEnv::Static()->Process();
       
  4321             if (iEmbedded)
       
  4322                 {
       
  4323                 process->DestroyDocument(iEmbedded);
       
  4324                 }
       
  4325 #if (defined(SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1) || defined(__SERIES60_27__) || defined(__SERIES60_28__)) 
       
  4326             iEmbedded = process->AddNewDocumentL(_L("User Dictionary"), KUidUserDictApp);
       
  4327 #else
       
  4328             iEmbedded = process->AddNewDocumentL(KUidUserDictApp);
       
  4329 #endif
       
  4330             iEmbedded->NewDocumentL();
       
  4331             iEmbedded->EditL(NULL);
       
  4332 #endif //RD_PF_SEC_APPARC
       
  4333             }
       
  4334             break;
       
  4335         case EPenInputJpCmdKutenCode:
       
  4336         case EJapanFepCmdModeKutenCodeInput:
       
  4337             {
       
  4338             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4339             LaunchKutenCodeQueryL();
       
  4340 #ifdef RD_SCALABLE_UI_V2
       
  4341             if (aCommandId == EPenInputJpCmdKutenCode)
       
  4342                 {
       
  4343                 // Re-open pen input window
       
  4344                 SendEventsToPluginManL( EPluginActivate );
       
  4345                 }
       
  4346 #endif //RD_SCALABLE_UI_V2
       
  4347             }
       
  4348             break;
       
  4349         case EAknCmdEditClearDirectionLeft:
       
  4350         case EAknCmdEditClearDirectionRight:
       
  4351             {
       
  4352             TInt value = EClearDirectionLeft;
       
  4353             if (aCommandId == EAknCmdEditClearDirectionRight)
       
  4354                 {
       
  4355                 value = EClearDirectionRight;
       
  4356                 }
       
  4357             iSharedDataInterface->SetClearDirection(value);
       
  4358             }
       
  4359             break;
       
  4360         case EAknFepSoftkeyCloseWindow:
       
  4361             if(IsChineseInputLanguage())
       
  4362                 {
       
  4363                 TryCloseUiL();
       
  4364                 }                        
       
  4365             if (iCcpuMode != ECcpuStateNone)
       
  4366                 {
       
  4367                 ResetCcpuFlags();
       
  4368 
       
  4369                 // reset select mode indicators
       
  4370                 iIndicator->SetCopyMode(EFalse);
       
  4371                 // update view                
       
  4372                 iPreviousEditingState = EStateNone;
       
  4373                 UpdateIndicators();
       
  4374 
       
  4375                 iUiInterface->DeleteSoftkeys();                              
       
  4376                 break;
       
  4377                 }
       
  4378         case EAknFepSoftkeyCommit:
       
  4379         case EAknFepSoftkeySelectCandidate:
       
  4380         case EAknFepSoftkeyConvert:
       
  4381         case EAknFepSoftkeyOtherModes:
       
  4382         case EAknFepSoftkeyRetroActiveHalf:
       
  4383         case EAknFepSoftkeyRetroActiveFull:
       
  4384             {
       
  4385             FepUI()->HandleCommandL(aCommandId);
       
  4386             }
       
  4387             break;
       
  4388         case EAknFepSoftkeyPredictiveOn:
       
  4389             {
       
  4390             iJapanesePredictive = ETrue;
       
  4391             iSharedDataInterface->SetJapanesePredictiveTextOn();
       
  4392             iHashKeyMan->SetMode(iMode, ETrue);
       
  4393             UpdateIndicators();
       
  4394             FepUI()->HandleCommandL(aCommandId);
       
  4395             }
       
  4396             break;
       
  4397         case EJapanFepCmdModePredictiveOn:
       
  4398             {
       
  4399             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4400             HandleChangeInFocus();
       
  4401             if (!iJapanesePredictive)
       
  4402                 {
       
  4403                 LaunchConfirmationNoteL(R_AVKON_JAPANESE_PREDICTIVE_ACTIVATED_NOTE);
       
  4404                 }
       
  4405             iJapanesePredictive = ETrue;
       
  4406             TryChangeModeL(EHiraganaKanji);
       
  4407             iSharedDataInterface->SetJapanesePredictiveTextOn();
       
  4408             }
       
  4409             break;
       
  4410         case EJapanFepCmdModePredictiveOff:
       
  4411             {
       
  4412             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4413             HandleChangeInFocus();
       
  4414             if (iJapanesePredictive)
       
  4415                 {
       
  4416                 LaunchConfirmationNoteL(R_AVKON_JAPANESE_PREDICTIVE_DEACTIVATED_NOTE);
       
  4417                 }
       
  4418             iJapanesePredictive = EFalse;
       
  4419             TryChangeModeL(EHiraganaKanji);
       
  4420             iSharedDataInterface->ResetJapanesePredictiveTextOn();
       
  4421             }
       
  4422             break;
       
  4423 #ifdef RD_SCALABLE_UI_V2
       
  4424         case EPenInputJpCmdPredictiveOn:
       
  4425             {
       
  4426             iJapanesePredictive = ETrue;
       
  4427             iSharedDataInterface->SetJapanesePredictiveTextOn();
       
  4428             if (iFepPluginManager->PluginInputMode() == EPluginInputModeHwr)
       
  4429                 {
       
  4430                 iSharedDataInterface->SetJapaneseHwrConversion(EJapaneseConversionOn);
       
  4431                 }
       
  4432             }
       
  4433             break;
       
  4434         case EPenInputJpCmdPredictiveOff:
       
  4435             {
       
  4436             iJapanesePredictive = EFalse;
       
  4437             iSharedDataInterface->ResetJapanesePredictiveTextOn();
       
  4438             }
       
  4439             break;
       
  4440         case EPenInputJpCmdConversionOn:
       
  4441             {
       
  4442             iSharedDataInterface->SetJapaneseHwrConversion(EJapaneseConversionOn);
       
  4443             }
       
  4444             break;
       
  4445         case EPenInputJpCmdConversionOff:
       
  4446             {
       
  4447             iSharedDataInterface->SetJapaneseHwrConversion(EJapaneseConversionOff);
       
  4448             }
       
  4449             break;
       
  4450 #endif //RD_SCALABLE_UI_V2
       
  4451 
       
  4452         // --- commands for Chinese ---
       
  4453         case EChinFepCmdModePinyin:
       
  4454         case EChinFepCmdModePinyinPhrase:
       
  4455             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4456             HandleChangeInFocus();
       
  4457             TryChangeModeL(EPinyin);
       
  4458             break;
       
  4459         case EChinFepCmdModeZhuyin:
       
  4460         case EChinFepCmdModeZhuyinPhrase:
       
  4461             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4462             HandleChangeInFocus();
       
  4463             TryChangeModeL(EZhuyin);
       
  4464             break;
       
  4465         case EChinFepCmdModeStroke:
       
  4466         case EChinFepCmdModeStrokePhrase:  
       
  4467             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4468             HandleChangeInFocus();
       
  4469             TryChangeModeL(EStroke);
       
  4470             break;
       
  4471         case EChinFepCmdModeCangJie:
       
  4472             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4473             HandleChangeInFocus();
       
  4474             TryChangeModeL(ECangJie);
       
  4475             break;
       
  4476         case EChinFepCmdModeCangJieOption:
       
  4477             // Launch CangJie option dialog
       
  4478             {
       
  4479             SetStopProcessFocus(ETrue);
       
  4480             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4481             TInt newMode = LaunchCangJieOptionDlgL();
       
  4482             SetStopProcessFocus(EFalse);
       
  4483             UpdateCangJieState( newMode );
       
  4484             }
       
  4485             break;
       
  4486         case EChinFepCmdModeLatinUpper:
       
  4487             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4488             HandleChangeInFocus();
       
  4489             TryChangeModeL(ELatinUpper);
       
  4490             // delete it for support auto update to text-case
       
  4491             //SetFlag(EFlagSupressAutoUpdate);
       
  4492             iCaseMan->SetCurrentCase(EAknEditorUpperCase);
       
  4493             break;
       
  4494         case EAknCmdEditModeKorean:
       
  4495             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4496             HandleChangeInFocus();
       
  4497             TryChangeModeL(EHangul);
       
  4498             // delete it for support auto update to text-case
       
  4499             //SetFlag(EFlagSupressAutoUpdate);
       
  4500             iCaseMan->SetCurrentCase(EAknEditorUpperCase);
       
  4501             break;
       
  4502         case EChinFepCmdModeLatinLower:
       
  4503             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4504             HandleChangeInFocus();
       
  4505             TryChangeModeL(ELatinLower);
       
  4506             // delete it for support auto update to text-case
       
  4507             //SetFlag(EFlagSupressAutoUpdate);
       
  4508             iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
  4509             break;
       
  4510         case EAknCmdEditModeNumber:
       
  4511             //if current input is arabic finger hwr, then change the default 
       
  4512             //number mode.
       
  4513             if(iSharedDataInterface->InputTextLanguage() == ELangArabic 
       
  4514                && iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr)
       
  4515                 {
       
  4516                 iSharedDataInterface->SetDefaultArabicNumberMode(0);
       
  4517                 HandleChangeInFocus();
       
  4518                 SendEventsToPluginManL(EPluginArabicNumModeChanged, 0);                
       
  4519                 break;
       
  4520                 }
       
  4521         case EJapanFepCmdEditModeNumber:
       
  4522         case EChinFepCmdModeNumber:
       
  4523             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4524             HandleChangeInFocus();
       
  4525             if ( iLanguageCapabilities.iArabicIndicDigitsAllowed 
       
  4526                 || iLanguageCapabilities.iEasternArabicIndicDigitsAllowed 
       
  4527                 || iLanguageCapabilities.iIndicDigitsAllowed )
       
  4528                 {
       
  4529                 iLanguageCapabilities.iLocalDigitType = EDigitTypeWestern;
       
  4530                 }
       
  4531             TryChangeModeL(ENumber);
       
  4532             break;
       
  4533         case EAknCmdEditModeArabicIndicNumber:
       
  4534             //if current input is arabic finger hwr, then change the default 
       
  4535             //number mode.
       
  4536             if(iSharedDataInterface->InputTextLanguage() == ELangArabic 
       
  4537                && iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr)
       
  4538                 {
       
  4539                 iSharedDataInterface->SetDefaultArabicNumberMode(1);
       
  4540                 SendEventsToPluginManL(EPluginArabicNumModeChanged, 1);
       
  4541                 HandleChangeInFocus();
       
  4542                 }
       
  4543             else
       
  4544                 {
       
  4545                 SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4546                 HandleChangeInFocus();
       
  4547                 iLanguageCapabilities.iLocalDigitType = EDigitTypeArabicIndic;
       
  4548                 TryChangeModeL(ENativeNumber);
       
  4549                 }
       
  4550             break;
       
  4551             /*For Eastern Arabic Numeric*/
       
  4552         case EAknCmdEditModeEasternArabicIndicNumber:
       
  4553             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4554             HandleChangeInFocus();
       
  4555             iLanguageCapabilities.iLocalDigitType = EDigitTypeEasternArabicIndic;
       
  4556             TryChangeModeL(ENativeNumber);
       
  4557             break;
       
  4558             /*for Hindi*/
       
  4559         case EAknCmdEditModeIndicNumber:
       
  4560             HandleChangeInFocus();
       
  4561             iLanguageCapabilities.iLocalDigitType = EDigitTypeDevanagari;
       
  4562             TryChangeModeL(ENativeNumber);
       
  4563             break;
       
  4564         case EChinFepCmdInstructions:
       
  4565             SetStopProcessFocus(ETrue);            
       
  4566             HandleChangeInFocus();
       
  4567             LaunchHelpTextQueryL();
       
  4568             SetStopProcessFocus(EFalse);            
       
  4569             break;
       
  4570         case EChinFepCmdModeZhuyinFind:
       
  4571             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4572             HandleChangeInFocus();
       
  4573             TryChangeModeL(EZhuyinFind);
       
  4574             break;
       
  4575         case EChinFepCmdModeStrokeFind:
       
  4576             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4577             HandleChangeInFocus();
       
  4578             TryChangeModeL(EStrokeFind);
       
  4579             break;
       
  4580 
       
  4581         // commands for western or common
       
  4582         case EJapanFepCmdMultitapPredictiveT9On:
       
  4583         case EAknCmdMultitapPredictiveT9On:
       
  4584 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4585         case EAknFepCmdPredActivate:
       
  4586 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  4587             SetStopProcessFocus(ETrue, EFalse);
       
  4588             HandleChangeInFocus();
       
  4589 #ifdef RD_SCALABLE_UI_V2     
       
  4590         if( iFepFullyConstructed && iFepPluginManager)
       
  4591             {
       
  4592             iFepPluginManager->SetMenuState();            
       
  4593             }
       
  4594 #endif
       
  4595             if ( !iWesternPredictive )
       
  4596                 {
       
  4597                 LaunchConfirmationNoteL(R_AVKON_T9_ACTIVATED_NOTE);
       
  4598                 }
       
  4599             SetWesternPredictive(ETrue);
       
  4600             SetStopProcessFocus(EFalse);
       
  4601             TryChangeModeL(ELatin);
       
  4602             break;
       
  4603         case EAknCmdT9PredictiveT9Off:
       
  4604 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4605         case EAknFepCmdPredDeactivate:
       
  4606 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  4607         SetStopProcessFocus(ETrue, EFalse);
       
  4608             HandleChangeInFocus();
       
  4609 #ifdef RD_SCALABLE_UI_V2     
       
  4610         if( iFepFullyConstructed && iFepPluginManager) 
       
  4611             {
       
  4612             iFepPluginManager->SetMenuState();            
       
  4613             }
       
  4614 #endif   
       
  4615             if (iMode != ELatin)
       
  4616                 {
       
  4617                 TryChangeModeL(ELatin);
       
  4618                 }
       
  4619             else
       
  4620                 {
       
  4621 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4622                 RemoveSuggestedAdvanceCompletionL();
       
  4623 #endif // RD_INTELLIGENT_TEXT_INPUT                	
       
  4624                 CommitInlineEditL();
       
  4625                 }
       
  4626 			if ( iWesternPredictive )
       
  4627                 {
       
  4628                 LaunchConfirmationNoteL(R_AVKON_T9_DEACTIVATED_NOTE);
       
  4629                 }
       
  4630             SetWesternPredictive(EFalse);
       
  4631             SetStopProcessFocus(EFalse);            
       
  4632             break;
       
  4633         case EAknCmdEditModeEnglish:
       
  4634         case EAknCmdEditModeAlpha:
       
  4635         case EJapanFepCmdEditModeAlpha:
       
  4636             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4637             HandleChangeInFocus();            
       
  4638             TryChangeModeL(ELatin);
       
  4639             iCaseMan->UpdateCase( ENullNaviEvent );
       
  4640             ClearFlag(EFlagSupressAutoUpdate);
       
  4641             break;
       
  4642         case EAknCmdEditModeLatinText:
       
  4643             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4644             HandleChangeInFocus();
       
  4645             TryChangeModeL(ELatinText);
       
  4646             ClearFlag(EFlagSupressAutoUpdate);
       
  4647             iCaseMan->SetCurrentCase(EAknEditorTextCase);
       
  4648             break;
       
  4649         case EAknCmdEditInsertSymbol:
       
  4650         case EAknCmdEditInsertSymbolJp:
       
  4651         case EAknFepSoftkeySymbol:
       
  4652         case EAknCmdEditInsertSmiley:
       
  4653             SetCcpuFlag(ECcpuStateSupressCursorMoveToEnd);
       
  4654 #ifdef RD_SCALABLE_UI_V2            
       
  4655      if (iFepPluginManager && 
       
  4656         (iFepPluginManager->PluginInputMode() == EPluginInputModeItut ||
       
  4657          iFepPluginManager->PluginInputMode() == EPluginInputModeFSQ ||
       
  4658          iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr || 
       
  4659          iFepPluginManager->PluginInputMode() == EPluginInputModePortraitFSQ ) )
       
  4660         {
       
  4661         iFepPluginManager->SetMenuState();     
       
  4662         }
       
  4663 
       
  4664 #endif //RD_SCALABLE_UI_V2             
       
  4665             SetStopProcessFocus(ETrue, EFalse);
       
  4666             HandleChangeInFocus();
       
  4667             if (aCommandId == EAknFepSoftkeySymbol)
       
  4668                 {               
       
  4669                 SetCcpuFlag(ECcpuStateCbaSymbol);
       
  4670                 }
       
  4671             // Show Thai specific SCT with Thai vowels and tonemarks
       
  4672             if ( (iLanguageCapabilities.iInputLanguageCode == ELangThai ) &&
       
  4673                  (iMode!=ENumber && iMode != ENativeNumber ) )
       
  4674                 {
       
  4675 				TInt resourceId = 0;
       
  4676 				if (iAknFepThaiSCTSelector)
       
  4677 					{
       
  4678 					resourceId = iAknFepThaiSCTSelector->ThaiSCRResourceId(PreviousChar(),EPtiKeyStar);
       
  4679 					}
       
  4680 				LaunchSpecialCharacterTableL(resourceId, 
       
  4681 											 aCommandId==EAknCmdEditInsertSymbol, 
       
  4682 											 aCommandId==EAknCmdEditInsertSmiley);                  
       
  4683                 }
       
  4684             else
       
  4685             {
       
  4686                 LaunchSpecialCharacterTableL(0, 
       
  4687                                              aCommandId==EAknCmdEditInsertSymbol, 
       
  4688                                              aCommandId==EAknCmdEditInsertSmiley);
       
  4689             }
       
  4690             SetStopProcessFocus(EFalse);
       
  4691             ClearCcpuFlag(ECcpuStateCbaSymbol);
       
  4692             break;
       
  4693         case EAknFepSoftkeyPrevious:
       
  4694             FepUI()->HandleCommandL(aCommandId);
       
  4695             break;
       
  4696         case EAknFepSoftkeySpell:
       
  4697             LaunchEditWordQueryL();
       
  4698             break;
       
  4699         case EAknCmdT9PredictiveInsertWord:
       
  4700             SetStopProcessFocus(ETrue, EFalse);
       
  4701             HandleChangeInFocus();
       
  4702             LaunchInsertWordQueryL(KNullDesC, TCursorSelection(0,0));
       
  4703             SetStopProcessFocus(EFalse);
       
  4704 #ifdef RD_SCALABLE_UI_V2     
       
  4705         if( iFepFullyConstructed && iFepPluginManager)
       
  4706             {
       
  4707             iFepPluginManager->ResetMenuState();            
       
  4708             }
       
  4709 #endif             
       
  4710             break;
       
  4711         case EAknCmdT9PredictiveEditWord:
       
  4712             SetStopProcessFocus( ETrue, EFalse );
       
  4713             HandleChangeInFocus();
       
  4714 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4715                 RemoveSuggestedAdvanceCompletionL();
       
  4716 #endif // RD_INTELLIGENT_TEXT_INPUT   
       
  4717             LaunchEditWordQueryL();
       
  4718             SetStopProcessFocus(EFalse);
       
  4719 #ifdef RD_SCALABLE_UI_V2     
       
  4720             if( iFepFullyConstructed && iFepPluginManager )
       
  4721                 {
       
  4722                 iFepPluginManager->ResetMenuState();            
       
  4723                 }
       
  4724 #endif 
       
  4725             break;
       
  4726         case EAknCmdT9PredictiveMatches:
       
  4727             SetStopProcessFocus(ETrue,EFalse);
       
  4728             LaunchMatchesPopupListL();
       
  4729             SetStopProcessFocus(EFalse);
       
  4730             break;
       
  4731 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  4732         case EAknCmdPredictiveAutoWord:
       
  4733              if ( !iIsAutoCompleteOn )
       
  4734                 {
       
  4735                 SetStopProcessFocus(ETrue);
       
  4736                 LaunchConfirmationNoteL(R_AVKON_PREDICTIVE_AUTOCOMPLETION_ACTIVATED_NOTE);
       
  4737                 SetStopProcessFocus(EFalse);
       
  4738                 }
       
  4739              iIsAutoCompleteOn = ETrue;      
       
  4740          	 iSharedDataInterface->SetPredictiveTextAutoCompleteOn();  			                 	 
       
  4741 #ifdef  RD_SCALABLE_UI_V2       	 
       
  4742             if(iFepPluginManager->PluginInputMode() == EPluginInputModeItut)
       
  4743                 {
       
  4744                 SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  4745                 HandleChangeInFocus();
       
  4746                 }
       
  4747 #endif
       
  4748 	 		 UpdateIndicators();
       
  4749         	 break;
       
  4750         case EAknCmdPredictiveNormal:
       
  4751              if ( iIsAutoCompleteOn )
       
  4752                 {
       
  4753                 SetStopProcessFocus(ETrue);
       
  4754                 LaunchConfirmationNoteL(R_AVKON_PREDICTIVE_AUTOCOMPLETION_DEACTIVATED_NOTE);
       
  4755                 SetStopProcessFocus(EFalse);
       
  4756                 }
       
  4757          	 iIsAutoCompleteOn = EFalse;
       
  4758          	 iSharedDataInterface->ResetPredictiveTextAutoCompleteOn();        	 
       
  4759         	 UpdateIndicators();
       
  4760         	 break;
       
  4761 #endif
       
  4762         case EAknCmdInputLanguage:
       
  4763 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4764         case EAknFepCmdPredInputLanguage:
       
  4765 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  4766             SetStopProcessFocus(ETrue, EFalse);
       
  4767             HandleChangeInFocus();
       
  4768 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4769 #ifdef FF_DUAL_LANGUAGE_SUPPORT 
       
  4770             	// Currently dual language feature would work correctly for ITUT and Half Qwerty products 
       
  4771                 // Hence the dual language settings should also be displayed only for ITUT and Halfqwerty products
       
  4772                 if(iKeyboardType == EPtiKeyboard12Key || iKeyboardType == EPtiKeyboardHalfQwerty )
       
  4773                     LaunchDualLanguageSettingDialogL();
       
  4774                 else 
       
  4775 					{ 
       
  4776 					LaunchLanguagesPopupListL(aCommandId == EAknCmdInputLanguage);		            
       
  4777 		            iStopProcessFocus = EFalse; 
       
  4778 					}             
       
  4779 #else // FF_DUAL_LANGUAGE_SUPPORT
       
  4780             LaunchLanguagesPopupListL(aCommandId == EAknCmdInputLanguage);
       
  4781             //HandleChangeInFocus();
       
  4782             iStopProcessFocus = EFalse;
       
  4783 #endif // FF_DUAL_LANGUAGE_SUPPORT
       
  4784 #else            
       
  4785             LaunchLanguagesPopupListL(aCommandId == EAknCmdInputLanguage);
       
  4786             HandleChangeInFocus();
       
  4787             iStopProcessFocus = EFalse;
       
  4788 #endif
       
  4789             break;
       
  4790         case EAknEditMenuCmdCutText:
       
  4791              StartCcpuModeL(EFalse);
       
  4792              if (WesternPredictive())
       
  4793                 {                
       
  4794                 // Remove underlining from predicted word when focus is re-gained.
       
  4795                 SetCcpuFlag(ECcpuStateUncommitWhenFocused);                 
       
  4796                 }                                     
       
  4797              SetCcpuFlag(ECcpuStateIgnoreNextFocusChange);                            
       
  4798              SetCcpuFlag(ECcpuStateEdwinInSelectionMode);                       
       
  4799              break;            
       
  4800         case EAknEditMenuCmdCopyText:                               
       
  4801              StartCcpuModeL(ETrue);
       
  4802              if (WesternPredictive())
       
  4803                 {                
       
  4804                 // Remove underlining from predicted word when focus is re-gained.
       
  4805                 SetCcpuFlag(ECcpuStateUncommitWhenFocused);                 
       
  4806                 }                        
       
  4807              SetCcpuFlag(ECcpuStateIgnoreNextFocusChange);               
       
  4808              SetCcpuFlag(ECcpuStateEdwinInSelectionMode);                
       
  4809              break;
       
  4810         case EAknFepSoftkeyStartCopy:
       
  4811         case EAknFepSoftkeyStartCut:        
       
  4812              {
       
  4813              ResetCcpuFlags();
       
  4814              if (aCommandId == EAknFepSoftkeyStartCopy)
       
  4815                 {
       
  4816                 SetCcpuFlag(ECcpuStateCopy);                
       
  4817                 }
       
  4818              else
       
  4819                 {
       
  4820                 SetCcpuFlag(ECcpuStateCut);
       
  4821                 }
       
  4822                 
       
  4823              __ASSERT_DEBUG(iUiInterface->SoftkeysExist(),
       
  4824                             AknFepPanic(EAknFepPanicNoHandleToFepAwareTextEditor));
       
  4825                  
       
  4826             TBool update = UpdateCBALabelL(ELeftSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY);
       
  4827             update |= UpdateCBALabelL(ERightSoftkeyIndex, EAknFepSoftkeyCloseWindow, 
       
  4828                                       R_AKNFEP_SOFTKEY_CCPU_CANCEL);
       
  4829             update |= UpdateCBALabelL( EMiddleSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY ); 
       
  4830             if (update)
       
  4831                 {
       
  4832                 iUiInterface->DrawSoftkeysNow();
       
  4833                 }                           
       
  4834              }
       
  4835              break;   
       
  4836         case EEikCmdEditCopy:
       
  4837         case EEikCmdEditCut:
       
  4838             {
       
  4839 #ifdef RD_SCALABLE_UI_V2            
       
  4840      if (iFepPluginManager && 
       
  4841         (iFepPluginManager->PluginInputMode() == EPluginInputModeItut ||
       
  4842          iFepPluginManager->PluginInputMode() == EPluginInputModeFSQ ||
       
  4843          iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr || 
       
  4844          iFepPluginManager->PluginInputMode() == EPluginInputModePortraitFSQ ) )
       
  4845         {
       
  4846         iFepPluginManager->SetMenuState(EFalse);     
       
  4847         }
       
  4848 
       
  4849 #endif //RD_SCALABLE_UI_V2             
       
  4850             SetStopProcessFocus(ETrue, EFalse);
       
  4851             HandleCopyCutEventL(aCommandId);
       
  4852             SetStopProcessFocus(EFalse);            
       
  4853             }
       
  4854             break;
       
  4855         case EEikCmdEditPaste:
       
  4856            	{
       
  4857            	// We have a hindi character in clipboard which can form ligature with the existing text
       
  4858            	// if pasted. While the input language is English, the cursor aligmment check would not happen.
       
  4859            	// When selecting Options->Paste, the Fep context at this point is for the menu.
       
  4860            	// iInputCapabilities for editor context is retrived from CCoeEnv and is restored back
       
  4861            	// after doing the operation, else FepAwareTextEditor will be true in menu context.
       
  4862            	if ( (!BidiCursorRequired()) && (!WesternPredictive()) )
       
  4863            		{
       
  4864 	        	TCoeInputCapabilities origInputCapabilities = iInputCapabilities;
       
  4865 	        
       
  4866 	        	CCoeEnv* coeEnv = CCoeEnv::Static();
       
  4867 	        	iInputCapabilities = static_cast<const CCoeAppUi*>(coeEnv->AppUi())->InputCapabilities();
       
  4868         	
       
  4869         		if( !(iInputCapabilities.SupportsSecretText()) )		        
       
  4870 		        	{
       
  4871 		    	    DoCursorDirectionCheckL();
       
  4872 			        }	
       
  4873     	       	iInputCapabilities = origInputCapabilities;
       
  4874 	           	}
       
  4875            	}     
       
  4876         	break;
       
  4877             
       
  4878         case EAknCmdEditMenuSctSelected:
       
  4879             {
       
  4880             SetCcpuFlag(ECcpuStateSupressCursorMoveToEnd);
       
  4881             HandleChangeInFocus();  // to re-establish contact with editor
       
  4882 
       
  4883             TBuf<ESingleCharacter> charAsDesc(ESingleCharacter);
       
  4884             for ( TInt ii = 0; ii < iSctEditChars->Length(); ii++)
       
  4885                 {
       
  4886                 charAsDesc[0]=(TText) (*iSctEditChars)[ii];
       
  4887                 if (charAsDesc[0] == TText(0x000A) // 0x000A is line feed
       
  4888                  || charAsDesc[0] == CEditableText::EParagraphDelimiter) 
       
  4889                     {
       
  4890                     // This is line feed character. Post it to editor and let it decide
       
  4891                     // if it is valid.
       
  4892                     if (!(iAknEditorFlags & EAknEditorFlagFindPane) && iSctEditChars->Length() == 1)                              
       
  4893                         {
       
  4894                         SimulateKeyEventL(EKeyEnter);
       
  4895                         SimulateKeyEventL(EKeyF19); // Asyncronous case update                                                                                  
       
  4896                         }
       
  4897                     }                                                        
       
  4898                 else
       
  4899                     {
       
  4900                     if (CharIsValidInEditor(charAsDesc[0]))
       
  4901                     {
       
  4902                     TCursorSelection cursorSelection(0,0);
       
  4903                     if ((iAknEditorFlags & EAknEditorFlagMTAutoOverwrite) && 
       
  4904                                     iMode == ELatin && !WesternPredictive())
       
  4905                         {
       
  4906                         TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
  4907                         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  4908                         if (iUncommittedText.iCursorPos < edSize && iUncommittedText.Length() == 0)
       
  4909                             {
       
  4910                             cursorSelection = TCursorSelection(iUncommittedText.iCursorPos + 1, 
       
  4911                                                                iUncommittedText.iAnchorPos);
       
  4912                             }
       
  4913                         }
       
  4914                         
       
  4915                     if (EditorHasFreeSpace())
       
  4916                         {
       
  4917                         InsertTextFromDialogL(charAsDesc, cursorSelection);
       
  4918                         }
       
  4919                                            
       
  4920                     }
       
  4921                   } 
       
  4922                  
       
  4923                 }
       
  4924             } 
       
  4925             break;
       
  4926         case EAknCmdTaskSwapper:
       
  4927             SendEventsToPluginManL( EPluginFaseSwap, ETrue );
       
  4928             break;
       
  4929             
       
  4930         case EAknCmdEditMenuClose:
       
  4931             {
       
  4932             // Handle destruction of menu
       
  4933             StopDisplayingMenuBar();     
       
  4934             }            
       
  4935         break;
       
  4936 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  4937         // Predictive QWERTY (XT9) changes ---->
       
  4938          case EAknFepCmdPredMatches:
       
  4939          {
       
  4940          	HandleChangeInFocus();  // to re-establish contact with editor
       
  4941 	        // Focus current active word in list ---->
       
  4942 	        TInt wordToFocus;
       
  4943 	        iPtiEngine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, &wordToFocus );
       
  4944 	        iSListLaunchedFromMenu = ETrue;
       
  4945 	        TKeyEvent candLaunch = {EKeyDownArrow, EStdKeyDownArrow, 0, 0};
       
  4946 			CEikonEnv::Static()->WsSession().SimulateKeyEvent(candLaunch);
       
  4947 	        //LaunchCandidatePopupListL( wordToFocus );
       
  4948 	       }
       
  4949 	        break;
       
  4950         case EAknFepCmdPredSettings:
       
  4951         	LaunchPredictiveSettingDialogL();
       
  4952         	break;
       
  4953         /*
       
  4954 	    This code is the part of fixing TSW Error 
       
  4955 	    "Matches" and "insert word" options are not available under Edit Menu.
       
  4956 	    This is For Insert Word Functionality*/	
       
  4957         case EAknEditMenuCmdInsertWord:
       
  4958         	HandleChangeInFocus();
       
  4959             LaunchInsertWordQueryL(KNullDesC, TCursorSelection(0,0));
       
  4960         	break;
       
  4961 #ifdef __USER_DICTIONARY_EDITING__ 
       
  4962         case EAknFepCmdPredEditUserDictionary:
       
  4963             if ( IsAutoCompleteOn() )
       
  4964                 {
       
  4965                 HandleChangeInFocus();
       
  4966                 RemoveSuggestedAdvanceCompletionL();
       
  4967                 }
       
  4968             UiInterface()->LaunchUserDictEditDialogL();
       
  4969             break;
       
  4970 #endif //__USER_DICTIONARY_EDITING__ 
       
  4971         
       
  4972         case EAknFepCmdPredHelp:
       
  4973 	        // Help ID:PREDINPUT_HLP_INPUT
       
  4974 			{					
       
  4975             const TInt KArrayGranularity = 3;
       
  4976             CArrayFix<TCoeHelpContext>* contexts =
       
  4977                     new (ELeave) CArrayFixFlat<TCoeHelpContext>( KArrayGranularity );
       
  4978 	    	CleanupStack::PushL ( contexts );
       
  4979 	    	TUid appuid = { 0x100058EC };
       
  4980 	    	contexts->AppendL( TCoeHelpContext( appuid, KPREDINPUT_HLP_INPUT ) );
       
  4981 	    	CleanupStack::Pop( contexts );
       
  4982 	    	HlpLauncher::LaunchHelpApplicationL( CEikonEnv::Static()->WsSession(), contexts );			
       
  4983 			}
       
  4984 	        break;
       
  4985        // Predictive QWERTY (XT9) changes <----
       
  4986 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  4987         // add for phrase creation user db view.
       
  4988         case EAknCmdUserDBDlg:
       
  4989             {
       
  4990             HandleChangeInFocus();
       
  4991             LaunchUserDBDlgL();
       
  4992            }            
       
  4993         break;
       
  4994         case EPenInputCmdPreviewOn:
       
  4995             {
       
  4996             iSharedDataInterface->SetFepShowVkbPreviewStatus(KTouchInputPreviewOn);
       
  4997             SendEventsToPluginManL(EPluginPreview, KTouchInputPreviewOn);  
       
  4998             }
       
  4999         break;
       
  5000         case EPenInputCmdPreviewOff:
       
  5001             {
       
  5002             iSharedDataInterface->SetFepShowVkbPreviewStatus(KTouchInputPreviewOff);
       
  5003             SendEventsToPluginManL(EPluginPreview, KTouchInputPreviewOff);    
       
  5004             }
       
  5005         break;
       
  5006         case EPenInputCmdRecognitionWithDictionary:
       
  5007             {
       
  5008             SetStopProcessFocus(ETrue);
       
  5009             HandleChangeInFocus();
       
  5010             LaunchRecognitionWithDictionaryPopupListL();
       
  5011             HandleChangeInFocus();
       
  5012             iStopProcessFocus = EFalse;
       
  5013             }
       
  5014             break;
       
  5015         case EPenInputCmdHwrInputToPortrait:
       
  5016             {
       
  5017             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  5018             HandleChangeInFocus();                        
       
  5019             SendEventsToPluginManL( EPluginSwitchToPortrait);
       
  5020             }
       
  5021             break;
       
  5022         case EPenInputCmdHwrInputToLandscape:
       
  5023             {
       
  5024             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  5025             HandleChangeInFocus();                        
       
  5026             SendEventsToPluginManL( EPluginSwitchToLandscape);
       
  5027             }
       
  5028             break;
       
  5029         /*case EPenInputCmdSwitchToVkeyBasedInput:
       
  5030             {
       
  5031             SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
  5032             HandleChangeInFocus();            
       
  5033             SendEventsToPluginManL( EPluginSwitchMode);
       
  5034             }
       
  5035             break;*/
       
  5036         case EPenInputCmdWritingSpeed:
       
  5037             {
       
  5038             SetStopProcessFocus(ETrue,EFalse);
       
  5039             LaunchWritingSpeedPopupListL();
       
  5040 			SetStopProcessFocus(EFalse);
       
  5041             }
       
  5042             break;
       
  5043         case EPenInputCmdGuidingLine:
       
  5044             {
       
  5045             SetStopProcessFocus(ETrue,EFalse);
       
  5046             LaunchGuidingLinePopupListL();
       
  5047 			SetStopProcessFocus(EFalse);
       
  5048             }
       
  5049             break;
       
  5050         default:
       
  5051             break;
       
  5052         }
       
  5053         
       
  5054         
       
  5055     StopDisplayingMenuBar();
       
  5056     }
       
  5057 
       
  5058 void CAknFepManager::SetEmphasis(CBase* /*aMenuControl*/,TBool aEmphasis)
       
  5059     {
       
  5060     if (aEmphasis)
       
  5061         { // opening main menu pane
       
  5062         SetFlag(EFlagMenuPaneVisible);
       
  5063         if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  5064             {
       
  5065             SetFlag(EFlagInlineEditInBackground);
       
  5066             }
       
  5067         }
       
  5068     else
       
  5069         {
       
  5070 		// The pointer to be cleared when the callback is received on leaving the focus from the menu pane.
       
  5071 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
  5072         iOptionsMenuBar = NULL;
       
  5073 #endif
       
  5074         ClearFlag(EFlagMenuPaneVisible | EFlagRemoveMatchesMenuItem | EFlagInlineEditInBackground);
       
  5075         }
       
  5076     }
       
  5077 
       
  5078 void CAknFepManager::DynInitMenuBarL(TInt aResourceId, CAknFepUiInterfaceMenuBar* aMenuBar)
       
  5079     {
       
  5080     if (iFepFullyConstructed && IsFlagSet(EFlagLaunchEditMenu))
       
  5081         {
       
  5082         aMenuBar->ReplaceAllMenuPanes(R_AVKON_EDIT_MODE_MENU);
       
  5083         }
       
  5084         
       
  5085 #ifdef RD_SCALABLE_UI_V2        
       
  5086     if (iFepFullyConstructed &&
       
  5087         aResourceId == R_AVKON_PENINPUT_OPTION_MENU_BAR)
       
  5088         {
       
  5089         aMenuBar->ReplaceAllMenuPanes(R_AVKON_TOUCH_TOUCHINPUT_MENU);
       
  5090         }
       
  5091 #endif //RD_SCALABLE_UI_V2        
       
  5092         
       
  5093     }
       
  5094 
       
  5095 #ifdef RD_SCALABLE_UI_V2
       
  5096 void CAknFepManager::DynInitTouchMenuPaneL(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  5097     {
       
  5098     if ( !iFepFullyConstructed )
       
  5099         {
       
  5100         return;
       
  5101         }
       
  5102 
       
  5103 
       
  5104     if (iFepManState != EAknFepStateNull &&
       
  5105         iInputCapabilities.FepAwareTextEditor() &&
       
  5106         !(iAknEditorFlags & EAknEditorFlagFindPane))
       
  5107         {
       
  5108         // 'Input language' menu item on option menu isn't supported in Japanese variant.
       
  5109         if (!IsFeatureSupportedJapanese())
       
  5110             {
       
  5111             // Insert 'Input language' item to incoming menu if editor is active on screen and
       
  5112             // menu contains 'Help' or 'Exit' item.
       
  5113             if (!IsOnlyNumericPermitted())
       
  5114                 {
       
  5115                 TInt helpIndex;
       
  5116                 if (aMenuPane->MenuItemExists(EAknCmdHelp, helpIndex) ||
       
  5117                     aMenuPane->MenuItemExists(EAknCmdExit, helpIndex))
       
  5118                     {
       
  5119                     AddInputLanguageItemL(aMenuPane, helpIndex);
       
  5120                     }
       
  5121                 }
       
  5122             }
       
  5123         }
       
  5124 
       
  5125     TInt index;
       
  5126     if(aMenuPane->MenuItemExists(EAknCmdEditItemPlaceHolder, index))
       
  5127 	    {
       
  5128 		aMenuPane->DeleteMenuItem(EAknCmdEditItemPlaceHolder);	   
       
  5129 	    }
       
  5130 
       
  5131     ClearFlag(EFlagLaunchEditMenu);
       
  5132             
       
  5133     DimInputmodeTouchMenuItems(aMenuPane);
       
  5134     }
       
  5135 #endif //RD_SCALABLE_UI_V2
       
  5136 void CAknFepManager::DynInitMenuPaneL(TInt aResourceId, CAknFepUiInterfaceMenuPane* aMenuPane)
       
  5137     {
       
  5138     if ( !iFepFullyConstructed )
       
  5139         {
       
  5140         return;
       
  5141         }
       
  5142 
       
  5143 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
  5144     CAknEdwinState* editorState = NULL;
       
  5145     if (iInputCapabilities.FepAwareTextEditor())
       
  5146         {
       
  5147         editorState = EditorState();
       
  5148         }
       
  5149 
       
  5150     if (editorState)
       
  5151         {
       
  5152         iOptionsMenuBar = iUiInterface->EditorStateMenuBar(editorState);
       
  5153         }
       
  5154 #endif    
       
  5155     
       
  5156     SetCcpuFlag(ECcpuStateIgnoreNextEdwinSyncEvent);
       
  5157 
       
  5158     if (iFepManState != EAknFepStateNull &&
       
  5159         iInputCapabilities.FepAwareTextEditor() &&
       
  5160         !(iAknEditorFlags & EAknEditorFlagFindPane))
       
  5161         {
       
  5162         // 'Input language' menu item on option menu isn't supported in Japanese variant.
       
  5163         if (!IsFeatureSupportedJapanese())
       
  5164             {
       
  5165             // Insert 'Input language' item to incoming menu if editor is active on screen and
       
  5166             // menu contains 'Help' or 'Exit' item.
       
  5167             //Also, no need for writing language/ITI options in telephony's dialer
       
  5168             if ( (RProcess().SecureId().iId != KPhoneSecureId) && !IsOnlyNumericPermitted() )
       
  5169                 {
       
  5170 #ifdef RD_INTELLIGENT_TEXT_INPUT                
       
  5171                 //This method gets called multiple times - first before the help and exit
       
  5172                 //commands are populated and finally after these items are added.
       
  5173                 //So if we have already added the input options menu and/or writing language menu,
       
  5174                 //remove it. It will get added again to the correct place with the below code.
       
  5175                 //No need to handle following menu types here.
       
  5176                 if ( !( R_AVKON_EDIT_MODE_MENU == aResourceId || 
       
  5177                         R_AKNFEP_PRED_INPUT_OPTIONS_SUBMENU == aResourceId ||
       
  5178                         R_AVKON_PREDICTIVE_TEXT_MENU_T9 == aResourceId ||
       
  5179                         R_AVKON_INPUT_MODE_SUB_MENU == aResourceId ||
       
  5180                         R_AKNFEP_EDIT_SUBMENU == aResourceId ||
       
  5181                         R_AVKON_TOUCH_TOUCHINPUT_MENU == aResourceId ) 
       
  5182                 // Add this condition for adding "input options" into the option menu of FSQ.
       
  5183                         || ( R_AVKON_TOUCH_TOUCHINPUT_MENU == aResourceId
       
  5184                              && iFepPluginManager
       
  5185                              && iFepPluginManager->IsSupportITIOnFSQ() )
       
  5186                         )                        
       
  5187                     {
       
  5188                     FindAndRemoveInputOptionsMenuItemL( aMenuPane );
       
  5189                     FindAndRemoveEditSubMenuItemL (aMenuPane);
       
  5190                     AddInputOptionsMenuItemL( aMenuPane );
       
  5191                     }                                	        	
       
  5192 #else
       
  5193                 TInt helpIndex;
       
  5194 		if ( aMenuPane->MenuItemExists(EAknCmdHelp, helpIndex) ||
       
  5195                      aMenuPane->MenuItemExists(EAknCmdExit, helpIndex) )
       
  5196                     {
       
  5197                     AddInputLanguageItemL(aMenuPane, helpIndex);
       
  5198                     }
       
  5199                        	
       
  5200 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  5201                 }
       
  5202             }
       
  5203 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5204         if ( IsChineseInputLanguage() && 
       
  5205                 ( iKeyboardType == EPtiKeyboardQwerty4x10 ||
       
  5206                 iKeyboardType == EPtiKeyboardQwerty3x11 ) )
       
  5207             {
       
  5208             // the follow added for phrase creation
       
  5209             TInt iptlanguage;
       
  5210             if ( !iIsUserdbdlgActive )
       
  5211                 {
       
  5212                 aMenuPane->MenuItemExists( EAknCmdInputLanguage, iptlanguage );
       
  5213                 AddUserDBDlgItemL( aMenuPane, iptlanguage );
       
  5214                 }
       
  5215             }
       
  5216 #endif
       
  5217 
       
  5218         if (!(aResourceId == R_AVKON_EDIT_MODE_MENU ||
       
  5219             aResourceId == R_AVKON_TOUCH_TOUCHINPUT_MENU ||
       
  5220             aResourceId == R_AVKON_TOUCH_INDICATOR_EDIT_MODE_MENU))
       
  5221             {
       
  5222             AddEditSubmenuL(aMenuPane);
       
  5223             }
       
  5224         }
       
  5225 		
       
  5226 		//HWR Hindi, Training application is not available,
       
  5227         //Disable Menu option
       
  5228         if(aResourceId == R_AVKON_TOUCH_TOUCHINPUT_MENU && 
       
  5229         	iLanguageCapabilities.iInputLanguageCode == ELangHindi)
       
  5230         	{
       
  5231         	aMenuPane->SetItemDimmed(EPenInputCmdHwrTraining, ETrue);
       
  5232         	}
       
  5233     TInt index;
       
  5234     if(aMenuPane->MenuItemExists(EAknCmdEditItemPlaceHolder, index))
       
  5235 	    {
       
  5236 		aMenuPane->DeleteMenuItem(EAknCmdEditItemPlaceHolder);	   
       
  5237 	    }
       
  5238 #ifdef RD_SCALABLE_UI_V2
       
  5239     TInt oldPermitModes = -1;
       
  5240     if (R_AVKON_TOUCH_TOUCHINPUT_MENU == aResourceId )
       
  5241         {
       
  5242         oldPermitModes = iPermittedInputModes;
       
  5243         
       
  5244         if( iFepPluginManager != NULL )
       
  5245             {
       
  5246             iPermittedInputModes = iFepPluginManager->PreviousPermitMode();
       
  5247             }
       
  5248         }
       
  5249     if( iFepPluginManager != NULL )
       
  5250         {
       
  5251         iFepPluginManager->InitMenuPaneL( iRememberEditorState, aMenuPane, aResourceId );
       
  5252         }
       
  5253     if (oldPermitModes != -1)
       
  5254         {
       
  5255         iPermittedInputModes = oldPermitModes;    
       
  5256         }
       
  5257 #endif //  RD_SCALABLE_UI_V2      
       
  5258     switch (aResourceId)
       
  5259         {
       
  5260         case R_AVKON_TOUCHINPUT_PREVIEW:
       
  5261             {
       
  5262             InitPreviewMenuPane(aMenuPane);     
       
  5263             } 
       
  5264         break;
       
  5265         case R_AVKON_EDIT_MODE_MENU:
       
  5266         case R_AVKON_TOUCH_INDICATOR_EDIT_MODE_MENU:
       
  5267             {
       
  5268             ClearFlag(EFlagLaunchEditMenu);
       
  5269             
       
  5270    		  //call comes here when edit key or '*' is pressed and displays avkon edit menu            
       
  5271 		  //moving only the essential condition checks in EditSubmenuInUse() here
       
  5272 		  //no need of checking iSharedDataInterface->EditSubmenuInUse() because for devices with edit key
       
  5273 		  //this would return 0 and would not populate CUT and COPY option
       
  5274 
       
  5275         	TBool tempFlag = ETrue;
       
  5276 	        if ( ( ( RProcess().SecureId().iId == KPhoneSecureId ) && (iQwertyInputMode) ) ||
       
  5277 	             ( ExtendedInputCapabilities() & 
       
  5278                  CAknExtendedInputCapabilities::EForceEditSubmenuStatusFlagOff)
       
  5279 	        	  
       
  5280 	           )
       
  5281 	        	{
       
  5282 	        	tempFlag = EFalse;         		
       
  5283 	        	}
       
  5284 
       
  5285             if (tempFlag)
       
  5286                 {
       
  5287                 TInt posit(0);
       
  5288                     
       
  5289                 if (!(iAknEditorFlags & EAknEditorFlagFindPane) &&
       
  5290                 	iInputCapabilities.FepAwareTextEditor() &&
       
  5291                     aMenuPane->MenuItemExists(EEikCmdEditCut, posit) &&
       
  5292                     !IsOnlyNumericPermitted() 
       
  5293                     )
       
  5294                     { 
       
  5295                     if (iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep() > 0 )
       
  5296                     	{
       
  5297 						if (iRememberEditorState && iRememberEditorState->CcpuState() &&
       
  5298 							!iRememberEditorState->CcpuState()->CcpuCanCopy()&& 
       
  5299 							PluginInputMode() != EPluginInputModeItut )                      
       
  5300 							{                                                       
       
  5301 							TBuf<KMaxFileName> titleStr;
       
  5302 							StringLoader::Load(titleStr, R_AKNFEP_OPTIONS_EDIT_MENU_CUT_TEXT);                          
       
  5303 																
       
  5304 							CAknFepUiInterfaceMenuPane::SItemData itemData;
       
  5305 						
       
  5306 							itemData.iCommandId = EAknEditMenuCmdCutText;
       
  5307 							itemData.iCascadeId = 0;                        
       
  5308 							if (titleStr.Length())
       
  5309 								{
       
  5310 								itemData.iText.Copy(titleStr.Mid(1, titleStr.Length() - 1));                                                
       
  5311 								}
       
  5312 							itemData.iFlags = 0;                        
       
  5313 							aMenuPane->InsertMenuItemL(itemData, posit);            
       
  5314 											
       
  5315 							titleStr.Zero();                                            
       
  5316 							itemData.iText.Zero();
       
  5317 							StringLoader::Load(titleStr, R_AKNFEP_OPTIONS_EDIT_MENU_COPY_TEXT);
       
  5318 							
       
  5319 							itemData.iCommandId = EAknEditMenuCmdCopyText;                      
       
  5320 							if (titleStr.Length())
       
  5321 								{
       
  5322 								itemData.iText.Copy(titleStr.Mid(1, titleStr.Length() - 1));                                                
       
  5323 								}
       
  5324 							aMenuPane->InsertMenuItemL(itemData, posit);                                                    
       
  5325 							}
       
  5326 						else //Hack for browser in case there are some text already selected
       
  5327 							{
       
  5328 							 if (iRememberEditorState && iRememberEditorState->CcpuState() )
       
  5329 								 {
       
  5330 								  if(iRememberEditorState->CcpuState()->CcpuCanPaste())
       
  5331 									  aMenuPane->SetItemDimmed(EEikCmdEditPaste,EFalse);
       
  5332 								  if(iRememberEditorState->CcpuState()->CcpuCanCopy())
       
  5333 									  aMenuPane->SetItemDimmed(EEikCmdEditCopy,EFalse);
       
  5334 								  if(iRememberEditorState->CcpuState()->CcpuCanCut())
       
  5335 									  aMenuPane->SetItemDimmed(EEikCmdEditCut,EFalse);
       
  5336 								 }
       
  5337 							 }
       
  5338                     	}
       
  5339                     //if the document size is 0 and there are items in clipboard then dislay Paste item
       
  5340                     if ( iRememberEditorState && iRememberEditorState->CcpuState() &&
       
  5341                          iRememberEditorState->CcpuState()->CcpuCanPaste())
       
  5342                         aMenuPane->SetItemDimmed(EEikCmdEditPaste,EFalse);
       
  5343                     
       
  5344                     } 
       
  5345                 
       
  5346                 }                       
       
  5347             
       
  5348             DimInputmodeMenuItems(aMenuPane);
       
  5349 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5350             //Is this an edit menu launched for a western language?
       
  5351             if ( R_AVKON_EDIT_MODE_MENU == aResourceId && !IsChineseInputLanguage() 
       
  5352                     && ELangJapanese != iLanguageCapabilities.iInputLanguageCode )
       
  5353                 {
       
  5354                 //If this is edit menu (launched from '*' or edit key) and predictive input is allowed,
       
  5355                     //we need to remove "Input language" and add "Input options" menu item. 
       
  5356                 if (!IsOnlyNumericPermitted() && IsLanguageSupportPrediction() && !(iAknEditorFlags & EAknEditorFlagNoT9))
       
  5357                     {
       
  5358                     TInt menuitemPos(0);
       
  5359                     if(aMenuPane->MenuItemExists(EAknCmdEditInsertSmiley,menuitemPos)) // insert after smiley if exist
       
  5360                         {
       
  5361                         AddPredictiveModeEditMenuL(aMenuPane,menuitemPos+1);
       
  5362                         }
       
  5363                     else if(aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol,menuitemPos)) // insert after smybol if exist
       
  5364                         {
       
  5365                         AddPredictiveModeEditMenuL(aMenuPane,menuitemPos+1);
       
  5366                         }
       
  5367                     }
       
  5368                 }
       
  5369 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  5370 
       
  5371             }
       
  5372             break;
       
  5373                         
       
  5374         case R_AVKON_PREDICTIVE_TEXT_MENU_T9:
       
  5375             {
       
  5376             if( (iPtiEngine->NumberOfCandidates() <= 1) && !IsFlagSet(EFlagRemoveMatchesMenuItem ) )
       
  5377 			   {
       
  5378 			   SetFlag( EFlagRemoveMatchesMenuItem );
       
  5379 			   }
       
  5380 
       
  5381             if (iMode != ELatin)
       
  5382                 {
       
  5383                 aMenuPane->SetItemDimmed(EAknCmdT9PredictiveInsertWord, ETrue);
       
  5384                 }
       
  5385             if (!IsFlagSet(EFlagInlineEditInBackground))
       
  5386                 {
       
  5387                 aMenuPane->SetItemDimmed(EAknCmdT9PredictiveMatches, ETrue);
       
  5388                 aMenuPane->SetItemDimmed(EAknCmdT9PredictiveEditWord, ETrue);
       
  5389                 }
       
  5390             else if (IsFlagSet(EFlagRemoveMatchesMenuItem))
       
  5391                 {
       
  5392                 aMenuPane->SetItemDimmed(EAknCmdT9PredictiveMatches, ETrue);
       
  5393                 }
       
  5394             break;
       
  5395             }
       
  5396         case R_AVKON_INPUT_MODE_SUB_MENU:
       
  5397             {
       
  5398             if (IsChineseInputLanguage())
       
  5399                 {
       
  5400                 DoChineseSubMenu(aMenuPane);
       
  5401                 }
       
  5402             break;
       
  5403         case R_AKNFEP_EDIT_SUBMENU:
       
  5404             DisableEditSubmenuItems(aMenuPane);
       
  5405             break;
       
  5406             }
       
  5407 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5408             // Predictive QWERTY (XT9) changes ---->
       
  5409         case R_AKNFEP_PRED_INPUT_OPTIONS_SUBMENU:
       
  5410         	{
       
  5411             	// This part of code fixing TSW Errors
       
  5412             	// "Edit word" option is not available under edit menu in ITU-T mode.
       
  5413             	// "Insert word" Should not be available QWERTY mode.
       
  5414           	if (IsKoreanInputLanguage() || 
       
  5415           			CurrentInputLangCode() == ELangPrcChinese || 
       
  5416           			CurrentInputLangCode() == ELangTaiwanChinese || 
       
  5417           			CurrentInputLangCode() == ELangHongKongChinese  )
       
  5418           		{
       
  5419           		// No text prediction for korean.
       
  5420           		aMenuPane->SetItemDimmed(EAknFepCmdPredActivate, ETrue );
       
  5421           		aMenuPane->SetItemDimmed(EAknFepCmdPredDeactivate,ETrue );
       
  5422                 aMenuPane->SetItemDimmed( EAknFepCmdPredSettings, ETrue );
       
  5423           		}
       
  5424           	else 
       
  5425                 {
       
  5426                 aMenuPane->SetItemDimmed( EAknFepCmdPredSettings, EFalse );
       
  5427                 if(iSharedDataInterface->PredictiveTextOn())
       
  5428                     {
       
  5429                     aMenuPane->SetItemDimmed( EAknFepCmdPredActivate, ETrue );					
       
  5430                     }
       
  5431                 else
       
  5432                     {
       
  5433                     aMenuPane->SetItemDimmed(EAknFepCmdPredDeactivate,ETrue ); 
       
  5434                     }	
       
  5435                 }
       
  5436         	} 
       
  5437           break;
       
  5438             
       
  5439 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  5440         default:
       
  5441             break;
       
  5442         }
       
  5443 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5444 	/*
       
  5445     This code is the part of fixing TSW Error Edit Menu : 
       
  5446     "Matches" and "insert word" options are not available under Edit Menu.
       
  5447     This is To make visible/invisible the Insert Word in Optios menu & Edit Menu*/
       
  5448     iIsLastResourceEditMenu = aResourceId;
       
  5449 #endif  
       
  5450     }
       
  5451 
       
  5452 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5453 void CAknFepManager::FindAndRemoveInputOptionsMenuItemL( CAknFepUiInterfaceMenuPane* aMenuPane )
       
  5454     {
       
  5455     //Logic : 
       
  5456     //Loop through each item in menu pane and check if the data
       
  5457     //CEikMenuPaneItem::SData::iCascadeId == R_AKNFEP_PRED_INPUT_OPTIONS_SUBMENU
       
  5458     //or if CEikMenuPaneItem::SData::iCommandId == EAknCmdInputLanguage
       
  5459     //If so, delete that item.
       
  5460     TInt numOfMenuItems = aMenuPane->NumberOfItemsInPane();
       
  5461     CEikMenuPane* menuPane = aMenuPane->GetMenuPane();
       
  5462     for (TInt index(0); index < numOfMenuItems ; ++index )
       
  5463         {
       
  5464         CEikMenuPaneItem::SData itemData = menuPane->ItemDataByIndexL( index );
       
  5465         if ( itemData.iCascadeId == R_AKNFEP_PRED_INPUT_OPTIONS_SUBMENU ||
       
  5466              itemData.iCommandId == EAknCmdInputLanguage ||
       
  5467              itemData.iCascadeId == R_AVKON_INPUT_MODE_SUB_MENU ||
       
  5468            ( IsChineseInputLanguage() && iSharedDataInterface->QwertyInputMode() && 
       
  5469              itemData.iCommandId == EChinFepCmdModeCangJieOption ) )
       
  5470             { 
       
  5471             menuPane->DeleteBetweenMenuItems( index, index );
       
  5472             //Assumption - there can only be one such item in the menu pane
       
  5473             //Hence we can return without going through the remaining items
       
  5474             numOfMenuItems = aMenuPane->NumberOfItemsInPane();
       
  5475             index--;
       
  5476             }
       
  5477         }
       
  5478     }
       
  5479 
       
  5480 void CAknFepManager::FindAndRemoveEditSubMenuItemL( CAknFepUiInterfaceMenuPane* aMenuPane )
       
  5481     {
       
  5482     //Logic : 
       
  5483     //Loop through each item in menu pane and check if the data
       
  5484     //CEikMenuPaneItem::SData::iCascadeId == R_AKNFEP_EDIT_SUBMENU
       
  5485     //If so, delete that item.
       
  5486     TInt numOfMenuItems = aMenuPane->NumberOfItemsInPane();
       
  5487     CEikMenuPane* menuPane = aMenuPane->GetMenuPane();
       
  5488     for (TInt index(0); index < numOfMenuItems ; ++index )
       
  5489         {
       
  5490         CEikMenuPaneItem::SData itemData = menuPane->ItemDataByIndexL( index );
       
  5491         if ( itemData.iCascadeId == R_AKNFEP_EDIT_SUBMENU )
       
  5492             {
       
  5493             menuPane->DeleteBetweenMenuItems( index, index );
       
  5494             //Assumption - there can only be one such item in the menu pane
       
  5495             //Hence we can return without going through the remaining items
       
  5496             return;
       
  5497             }
       
  5498         }
       
  5499     }
       
  5500 
       
  5501 void CAknFepManager::AddInputOptionsMenuItemL( CAknFepUiInterfaceMenuPane* aMenuPane )
       
  5502     {
       
  5503     //Logic:
       
  5504     //Appropriate location is :
       
  5505     //  if Avkon Help command exists, then immediately above it
       
  5506     //  else if Avkon Exit command exists, then immediately above it
       
  5507     //  else if there are 3 or more items in the Options menu, then 3rd from last
       
  5508     //  else it is the last item. 
       
  5509     TInt posToInsertItem( 0 );
       
  5510     //MenuItemExists() will return the index of the item in 2nd parameter
       
  5511     //But if item is not found, it is returning the total number of items.
       
  5512     if ( ( aMenuPane->MenuItemExists(EAknCmdHelp, posToInsertItem) ) ||
       
  5513          ( aMenuPane->MenuItemExists(EAknCmdExit, posToInsertItem) ) )
       
  5514         {
       
  5515         //do nothing - we already have posToInsertItem with required value 
       
  5516         }
       
  5517     else 
       
  5518         {
       
  5519         TInt numOfMenuItems = aMenuPane->NumberOfItemsInPane();
       
  5520         if ( numOfMenuItems > 2 )
       
  5521             {
       
  5522             //We should add the new item as third from last, after ignoring
       
  5523             //any dimmed items in the menu pane
       
  5524             TInt numOfUnDimmedItems(0);
       
  5525             //loop from bottom for better performance 
       
  5526             for (TInt index(numOfMenuItems-1); index >= 0 ; --index )
       
  5527                 {
       
  5528                 CEikMenuPaneItem::SData itemData = aMenuPane->GetMenuPane()->ItemDataByIndexL( index );
       
  5529                 if ( !(itemData.iFlags & EEikMenuItemDimmed) )
       
  5530                     {
       
  5531                     ++numOfUnDimmedItems;
       
  5532                     }
       
  5533                 if ( numOfUnDimmedItems == 2 )
       
  5534                     {
       
  5535                     //We have our position - save it and break from this loop
       
  5536                     if ( index > 1 )
       
  5537                         {
       
  5538                         posToInsertItem = index;
       
  5539                         }
       
  5540                     else 
       
  5541                         {
       
  5542                         //There are two or less items on this menu that will be displayed
       
  5543                         //Hence, push ITI options to the end of the list:
       
  5544                         posToInsertItem = numOfMenuItems;
       
  5545                         }
       
  5546                     break;
       
  5547                     }
       
  5548                 }
       
  5549             }
       
  5550         else 
       
  5551             {
       
  5552             posToInsertItem = numOfMenuItems;
       
  5553             }
       
  5554         }
       
  5555     TInt inputOptionsPos = 0;
       
  5556     TInt pastePos = 0;
       
  5557     
       
  5558     if ( aMenuPane->MenuItemExists( EEikCmdEditPaste, pastePos ) )
       
  5559         {
       
  5560         CEikMenuPaneItem::SData& itemData = aMenuPane->GetMenuPane()->ItemDataByIndexL( pastePos );
       
  5561         if ( !( itemData.iFlags & EEikMenuItemDimmed ) )
       
  5562         	{
       
  5563             inputOptionsPos = pastePos + 1; 
       
  5564         	}
       
  5565         }
       
  5566    
       
  5567     //Now we have the position at which we need to insert the menu item. 
       
  5568     if (
       
  5569 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
  5570     iQwertyInputMode &&
       
  5571 #endif   		
       
  5572     IsLanguageSupportPrediction() && !(iAknEditorFlags & EAknEditorFlagNoT9))
       
  5573         {
       
  5574         AddPredictiveModeOptionsL( aMenuPane, inputOptionsPos );
       
  5575         }
       
  5576     else
       
  5577         {
       
  5578         AddInputLanguageItemL(aMenuPane, posToInsertItem);
       
  5579         }
       
  5580     }
       
  5581 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  5582 
       
  5583 
       
  5584 void CAknFepManager::AddEditSubmenuL(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  5585     {
       
  5586     // Adds edit-submenu to options menu when required contidions are met.
       
  5587     // Edit-submenu is added if:
       
  5588     //  1. There is active editor on screen
       
  5589     //  2. Editor contains text or there is text in clipboard.
       
  5590     //  3. Editor is not in Find Pane.
       
  5591     //
       
  5592     // Since menu will have focus, we also need to remeber certain values
       
  5593     // to be able to access undelying editor attributes.
       
  5594     
       
  5595     CAknEdwinState* editorState = EditorState();
       
  5596     iEditorCcpuStatus = 0;        
       
  5597     if (editorState && editorState->CcpuState())
       
  5598         {
       
  5599         iEditorCcpuStatus = EditorCcpuStatus(editorState);    
       
  5600         }
       
  5601     else
       
  5602         {
       
  5603         // The editor doesn't have ccpu-capability, doen't display the menu.
       
  5604         return; 
       
  5605         }            
       
  5606     TInt index;
       
  5607     if (aMenuPane->MenuItemExists(EAknCmdEditTextMenu, index))
       
  5608         {
       
  5609         return;    
       
  5610         }
       
  5611         
       
  5612     iRememberLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();      
       
  5613     
       
  5614     if (iRememberLength > 0 || (iEditorCcpuStatus & ECcpuStatusFlagCanPaste))
       
  5615         {
       
  5616 		if (aMenuPane->MenuItemExists(EAknCmdEditItemPlaceHolder, index) ||
       
  5617 				aMenuPane->MenuItemExists(EAknCmdInputLanguage, index) ||
       
  5618 		    aMenuPane->MenuItemExists(EAknCmdHelp, index) || 
       
  5619             aMenuPane->MenuItemExists(EAknCmdExit, index))  
       
  5620             {
       
  5621             TBuf<KMaxFileName> titleStr;
       
  5622             StringLoader::Load(titleStr, R_AKNFEP_OPTIONS_EDIT_SUBMENU_TITLE);          
       
  5623         
       
  5624             CAknFepUiInterfaceMenuPane::SItemData mData;
       
  5625                             
       
  5626             mData.iCommandId = EAknCmdEditTextMenu;
       
  5627             mData.iCascadeId = R_AKNFEP_EDIT_SUBMENU;  
       
  5628             mData.iFlags = 0;
       
  5629             mData.iText.Copy(titleStr.Mid(1, titleStr.Length() - 1).Left(
       
  5630                CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  5631                             
       
  5632             aMenuPane->InsertMenuItemL(mData, index);  
       
  5633 
       
  5634  			if(aMenuPane->MenuItemExists(EAknCmdEditItemPlaceHolder, index))
       
  5635     			{
       
  5636     			    aMenuPane->DeleteMenuItem(EAknCmdEditItemPlaceHolder);
       
  5637     			   
       
  5638     			}
       
  5639             // Remember editor state, because there is no access to it while
       
  5640             // menu is on screen.
       
  5641             iRememberEditorState = editorState;              
       
  5642             }                                           
       
  5643         }               
       
  5644     }
       
  5645 
       
  5646     
       
  5647 void CAknFepManager::DisableEditSubmenuItems(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  5648     {
       
  5649     aMenuPane->SetItemDimmed(EAknEditMenuCmdCopyText, ETrue); 
       
  5650     aMenuPane->SetItemDimmed(EEikCmdEditCopy, ETrue);
       
  5651     aMenuPane->SetItemDimmed(EAknEditMenuCmdCutText, ETrue);  
       
  5652     aMenuPane->SetItemDimmed(EEikCmdEditCut, ETrue);
       
  5653     aMenuPane->SetItemDimmed(EEikCmdEditPaste, ETrue);                                          
       
  5654     
       
  5655     if (iRememberLength > 0)
       
  5656         {           
       
  5657         if (iEditorCcpuStatus & ECcpuStatusFlagCanCopy)
       
  5658             {
       
  5659             aMenuPane->SetItemDimmed(EEikCmdEditCopy, EFalse);              
       
  5660             }
       
  5661         else
       
  5662             {
       
  5663             aMenuPane->SetItemDimmed(EAknEditMenuCmdCopyText, EFalse);                                      
       
  5664             }   
       
  5665                         
       
  5666         if (iEditorCcpuStatus & ECcpuStatusFlagCanCut)
       
  5667             {
       
  5668             aMenuPane->SetItemDimmed(EEikCmdEditCut, EFalse);               
       
  5669             }
       
  5670         else
       
  5671             {
       
  5672             aMenuPane->SetItemDimmed(EAknEditMenuCmdCutText, EFalse);                                   
       
  5673             }               
       
  5674         }
       
  5675                         
       
  5676     if (iEditorCcpuStatus & ECcpuStatusFlagCanPaste)            
       
  5677         {
       
  5678         aMenuPane->SetItemDimmed(EEikCmdEditPaste, EFalse);             
       
  5679         }   
       
  5680     }
       
  5681     
       
  5682 
       
  5683 void CAknFepManager::StartCcpuModeL(TBool aCopyMode)
       
  5684     {
       
  5685     ResetCcpuFlags();
       
  5686     if (!iUiInterface->SoftkeysExist())
       
  5687         {
       
  5688         iUiInterface->CreateSoftkeys(R_AVKON_SOFTKEYS_EMPTY, this);
       
  5689         }
       
  5690         
       
  5691     TBool update = EFalse;
       
  5692     if (aCopyMode)
       
  5693         {
       
  5694         SetCcpuFlag(ECcpuStateStartCopy);
       
  5695         update = UpdateCBALabelL(ELeftSoftkeyIndex, EAknFepSoftkeyStartCopy, 
       
  5696                                  R_AKNFEP_SOFTKEY_CCPU_START);      
       
  5697         update |= UpdateCBALabelL( EMiddleSoftkeyIndex, EAknFepSoftkeyStartCopy, 
       
  5698                                    R_AVKON_SOFTKEY_SELECT_TEXT ); 
       
  5699         }
       
  5700     else
       
  5701         {
       
  5702         SetCcpuFlag(ECcpuStateStartCut);
       
  5703         update = UpdateCBALabelL(ELeftSoftkeyIndex, EAknFepSoftkeyStartCut, 
       
  5704                                  R_AKNFEP_SOFTKEY_CCPU_START);               
       
  5705         update |= UpdateCBALabelL( EMiddleSoftkeyIndex, EAknFepSoftkeyStartCut, 
       
  5706                                    R_AVKON_SOFTKEY_SELECT_TEXT ); 
       
  5707         }
       
  5708         
       
  5709     update |= UpdateCBALabelL(ERightSoftkeyIndex, EAknFepSoftkeyCloseWindow,
       
  5710                               R_AKNFEP_SOFTKEY_CCPU_CANCEL);
       
  5711         
       
  5712     if (update)
       
  5713         {
       
  5714         iUiInterface->DrawSoftkeysNow();
       
  5715         }           
       
  5716 
       
  5717     iIndicator->SetCopyMode(ETrue);
       
  5718     UpdateIndicators(); // updates status of indicators
       
  5719     }
       
  5720 
       
  5721 
       
  5722 TBool CAknFepManager::OkToActivateSelectionMode() const
       
  5723     {
       
  5724     if (iFepManState != EAknFepStateNull && 
       
  5725         iInputCapabilities.FepAwareTextEditor() &&
       
  5726         !(iAknEditorFlags & EAknEditorFlagFindPane))
       
  5727         {               
       
  5728         return ETrue;       
       
  5729         }
       
  5730     
       
  5731     return EFalse;  
       
  5732     }
       
  5733 
       
  5734 
       
  5735 TBool CAknFepManager::HandleCcpuModeKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aEventCode,
       
  5736                                              TKeyResponse& aRetCode, TBool aLongPressFlag)
       
  5737     {
       
  5738     TKeyPressLength length = aKeyEvent.iRepeats ? ELongKeyPress : EShortKeyPress;
       
  5739     TBool indicLang = TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(
       
  5740                                      iLanguageCapabilities.iInputLanguageCode))
       
  5741 #ifdef RD_HINDI_PHONETIC_INPUT
       
  5742     || TAknFepUiIndicInputManager :: IsIndicPhoneticLanguage(TLanguage(
       
  5743                                      iLanguageCapabilities.iInputLanguageCode))
       
  5744 #endif
       
  5745     ;
       
  5746     if(aKeyEvent.iCode == EKeyEscape)
       
  5747         return EFalse;
       
  5748     if (aEventCode == EEventKey && aKeyEvent.iCode == '*')
       
  5749         {
       
  5750         iStarScan = aKeyEvent.iScanCode;
       
  5751         }
       
  5752 
       
  5753     if ((aKeyEvent.iScanCode == EStdKeyDevice0)
       
  5754      || (aKeyEvent.iScanCode == EStdKeyDevice1))
       
  5755         {
       
  5756         if (HashKeySelectionInUse()
       
  5757          && IsCcpuFlagSet(ECcpuStateHashDown))
       
  5758             {
       
  5759             if (IsCcpuFlagSet(ECcpuStateChangeToPredictionMode))
       
  5760                 {
       
  5761                 ClearCcpuFlag(ECcpuStateChangeToPredictionMode);
       
  5762                 if (iModeBefore == ELatin
       
  5763                  || iModeBefore == EHiraganaKanji)
       
  5764                     {
       
  5765                     TBool preFlag = IsPredictive();
       
  5766                     TryChangePredictiveInputModeL(!preFlag);
       
  5767                     }
       
  5768                 else
       
  5769                     {
       
  5770                     TryChangeToModeBeforeL();
       
  5771                     }
       
  5772                 }
       
  5773             }
       
  5774         // Always let sofkeys fall through.
       
  5775         return EFalse;      
       
  5776         }
       
  5777                 
       
  5778     if (IsCcpuFlagSet(ECcpuStateSelectionEventPosted))
       
  5779         {
       
  5780         ClearCcpuFlag(ECcpuStateSelectionEventPosted);
       
  5781         return EFalse;  
       
  5782         }       
       
  5783                         
       
  5784     if (HashKeySelectionInUse())
       
  5785         {       
       
  5786         if (aKeyEvent.iScanCode == EStdKeyHash && aEventCode == EEventKeyDown
       
  5787             && iInputCapabilities.FepAwareTextEditor())
       
  5788             {
       
  5789             SetCcpuFlag(ECcpuStateHashDown);
       
  5790             iHashKeyMan->ResetPreviousSelectionStyleMode();
       
  5791             return EFalse;
       
  5792             }
       
  5793             
       
  5794         if (!IsOnlyNumericPermitted())
       
  5795             {
       
  5796             if (IsFeatureSupportedJapanese())
       
  5797                 {
       
  5798                 if (FepUI()->IsValidShiftKeyPress()
       
  5799                  && aKeyEvent.iScanCode == iStarScan
       
  5800                  && !iQwertyInputMode
       
  5801                  && !(iMode == EKatakana && iFepManState == EAknFepStateUIActive))
       
  5802                     {
       
  5803                     if ( aEventCode == EEventKeyUp && !aLongPressFlag
       
  5804                      && !(iMode == ELatin && WesternPredictive()
       
  5805                           && iFepManState == EAknFepStateUIActive))
       
  5806                         {
       
  5807                         if (!IsCcpuFlagSet(ECcpuStateIgnoreStarUp))
       
  5808                             {
       
  5809                             LaunchSpecialCharacterTableL();
       
  5810                             }
       
  5811                         return EFalse;
       
  5812                         }
       
  5813                     else if ( aEventCode == EEventKey
       
  5814                            && !aLongPressFlag
       
  5815                            && length == ELongKeyPress )
       
  5816                         {
       
  5817                         LaunchSelectModeMenuL();
       
  5818                         aRetCode = EKeyWasConsumed;
       
  5819                         return ETrue;
       
  5820                         }
       
  5821                     }
       
  5822                 }
       
  5823             else
       
  5824                 {
       
  5825                 if ((aKeyEvent.iScanCode == iStarScan && aEventCode == EEventKeyUp &&
       
  5826                     !aLongPressFlag && !iQwertyInputMode) &&
       
  5827                 (!indicLang || WesternPredictive() || (iMode == ENumber || iMode == ENativeNumber) ))
       
  5828                 {
       
  5829                 // Disables *-key on korean multitapping mode
       
  5830                 if(IsKoreanInputLanguage() && iMode == EHangul)
       
  5831                 	{
       
  5832                 	SetCcpuFlag(ECcpuStateIgnoreStarUp);	
       
  5833                 	}
       
  5834 				
       
  5835                 if (!IsCcpuFlagSet(ECcpuStateIgnoreStarUp))
       
  5836                     {
       
  5837 #ifdef RD_SCALABLE_UI_V2                    
       
  5838                     if (iFepPluginManager->CurrentFepInputUI())
       
  5839                         {
       
  5840                         if (iFepPluginManager->CurrentFepInputUI()->HandleKeyL(EStdKeyNull, EShortKeyPress))
       
  5841                             {
       
  5842                             return EFalse;
       
  5843                             }
       
  5844                         }
       
  5845 #endif                        
       
  5846                     LaunchSelectModeMenuL();
       
  5847                     aRetCode = EKeyWasConsumed;
       
  5848                     return ETrue;
       
  5849                     }
       
  5850                 return EFalse;
       
  5851                 }
       
  5852             else if((aKeyEvent.iScanCode == iStarScan && aEventCode == EEventKey
       
  5853                 && !aLongPressFlag && !iQwertyInputMode)
       
  5854                 && (indicLang)
       
  5855                 && (! WesternPredictive())
       
  5856                 && (length == ELongKeyPress)
       
  5857                 && (iMode != ENumber && iMode != ENativeNumber ))            
       
  5858                 {
       
  5859                     LaunchSelectModeMenuL();
       
  5860                     return EFalse;
       
  5861                     }
       
  5862                 }
       
  5863             }
       
  5864         }
       
  5865         
       
  5866     if (IsCcpuFlagSet(ECcpuStateHashDown))
       
  5867         {
       
  5868         if (aEventCode == EEventKey)
       
  5869             {                   
       
  5870             if (aKeyEvent.iScanCode == EStdKeyDownArrow
       
  5871                 || aKeyEvent.iScanCode == EStdKeyRightArrow
       
  5872                 || aKeyEvent.iScanCode == EStdKeyLeftArrow
       
  5873                 || aKeyEvent.iScanCode == EStdKeyUpArrow)
       
  5874                 {
       
  5875 				if (IsFlagSet(EFlagInsideInlineEditingTransaction) && iMode == EHangul) 
       
  5876 					{
       
  5877 					CommitInlineEditL();
       
  5878        				iPtiEngine->ClearCurrentWord();
       
  5879 					}
       
  5880 										
       
  5881                 if ((IsCcpuFlagSet(ECcpuStateStartCopy)) ||
       
  5882                     (IsCcpuFlagSet(ECcpuStateStartCut)))
       
  5883                     {
       
  5884                     aRetCode = EKeyWasConsumed;             
       
  5885                     return ETrue;   
       
  5886                     }
       
  5887                 
       
  5888                 if (!IsCcpuFlagSet(ECcpuStateEdwinInSelectionMode))
       
  5889                     {
       
  5890                     // User wants to select and not to change mode, so cancel the mode change
       
  5891                     // caused by initial hash key press.                                    
       
  5892                     if(!(iAknEditorFlags & EAknEditorFlagFindPane))
       
  5893                         {                               
       
  5894                         iHashKeyMan->SetPreviousSelectionStyleModeL();                                                   
       
  5895                         SetCcpuFlag(ECcpuStateEdwinInSelectionMode);
       
  5896                         TKeyEvent ccpuStart = {EKeyF21, EStdKeyF21, 0, 0};
       
  5897                         // to enable copy/paste support on cba. We simulate via CCoeEnv
       
  5898                         // to avoid fep SimulateKeyEventL adding shift modifiers
       
  5899                         CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKey); 
       
  5900                         }
       
  5901                     }
       
  5902 
       
  5903                 // If prediction is changed while pressing hash-key,
       
  5904                 // it go back previous prediction state.
       
  5905                 if (IsCcpuFlagSet(ECcpuStateChangeToPredictionMode))
       
  5906                     {
       
  5907                     ClearCcpuFlag(ECcpuStateChangeToPredictionMode);
       
  5908                     if (iModeBefore == ELatin
       
  5909                      || iModeBefore == EHiraganaKanji)
       
  5910                         {
       
  5911                         TBool preFlag = IsPredictive();
       
  5912                         TryChangePredictiveInputModeL(!preFlag);
       
  5913                         }
       
  5914                     else
       
  5915                         {
       
  5916                         TryChangeToModeBeforeL();
       
  5917                         }
       
  5918                     }
       
  5919                     
       
  5920                 if (WesternPredictive() && IsFlagSet(EFlagInsideInlineEditingTransaction))                    
       
  5921                     {      
       
  5922                     // This will commit inline edit if it is active for predictive mode.                              
       
  5923                     return EFalse;
       
  5924                     }
       
  5925 
       
  5926                 aRetCode = EKeyWasNotConsumed;
       
  5927                 return ETrue;
       
  5928                 }
       
  5929             else if (aKeyEvent.iScanCode == EStdKeyBackspace)   
       
  5930                 {                               
       
  5931                 if (!(aKeyEvent.iModifiers & EStdKeyLeftShift))
       
  5932                     {                                   
       
  5933                     // Simulate edit key + clear key functionality via hash key in no-edit-key device.              
       
  5934                     TKeyEvent ccpuStart = {127, EStdKeyBackspace, EStdKeyLeftShift, 0};
       
  5935                     CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, aEventCode);                    
       
  5936                     
       
  5937                     aRetCode = EKeyWasConsumed;             
       
  5938                     return ETrue;                                       
       
  5939                     }
       
  5940                 else if (!IsCcpuFlagSet(ECcpuStateHashKeyDeleteDone))
       
  5941                     {
       
  5942                     // Hash key + clear key was pressed, but hash key was released before
       
  5943                     // changing to selection mode. Need to return to previous mode, because
       
  5944                     // user didn't want to change input mode.                       
       
  5945                     iHashKeyMan->SetPreviousSelectionStyleModeL();
       
  5946                     SetCcpuFlag(ECcpuStateHashKeyDeleteDone);
       
  5947                     }
       
  5948 
       
  5949                 // If prediction is changed while pressing hash-key,
       
  5950                 // it go back previous prediction state.
       
  5951                 if (IsCcpuFlagSet(ECcpuStateChangeToPredictionMode))
       
  5952                     {
       
  5953                     ClearCcpuFlag(ECcpuStateChangeToPredictionMode);
       
  5954                     if (iModeBefore == ELatin
       
  5955                      || iModeBefore == EHiraganaKanji)
       
  5956                         {
       
  5957                         TBool preFlag = IsPredictive();
       
  5958                         TryChangePredictiveInputModeL(!preFlag);
       
  5959                         }
       
  5960                     else
       
  5961                         {
       
  5962                         TryChangeToModeBeforeL();
       
  5963                         }
       
  5964                     }
       
  5965 
       
  5966                 }
       
  5967             }
       
  5968         else if (aKeyEvent.iScanCode == EStdKeyHash && aEventCode == EEventKeyUp)
       
  5969             {
       
  5970             ClearCcpuFlag(ECcpuStateHashDown
       
  5971                           | ECcpuStateHashKeyDeleteDone
       
  5972                           | ECcpuStateChangeToPredictionMode);
       
  5973             if (IsCcpuFlagSet(ECcpuStateEdwinInSelectionMode))
       
  5974                 {
       
  5975                 SetCcpuFlag(ECcpuStateSelectionEventPosted);
       
  5976                 ClearCcpuFlag(ECcpuStateEdwinInSelectionMode);
       
  5977                 SetFlag(EFlagLongShiftKeyPress);
       
  5978 
       
  5979                 TKeyEvent ccpuStart = {0, EStdKeyLeftShift, 0, 0};
       
  5980                 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, aEventCode);
       
  5981                 }
       
  5982 
       
  5983             return EFalse;
       
  5984             }
       
  5985         } 
       
  5986     
       
  5987     if (IsCcpuFlagSet(ECcpuStateStartCopy | ECcpuStateStartCut))    
       
  5988         {
       
  5989         if (aKeyEvent.iScanCode == EStdKeyDevice3 && aEventCode == EEventKey)
       
  5990             {
       
  5991             aRetCode = EKeyWasConsumed;                         
       
  5992             if (IsCcpuFlagSet(ECcpuStateStartCopy))
       
  5993                 {
       
  5994                 ProcessCommandL(EAknFepSoftkeyStartCopy);
       
  5995                 }
       
  5996             else
       
  5997                 {
       
  5998                 ProcessCommandL(EAknFepSoftkeyStartCut);                
       
  5999                 }                   
       
  6000             return ETrue;               
       
  6001             }       
       
  6002         else if (aKeyEvent.iScanCode < EStdKeyLeftArrow ||
       
  6003                  aKeyEvent.iScanCode > EStdKeyDownArrow) 
       
  6004             {       
       
  6005             aRetCode = EKeyWasConsumed;             
       
  6006             return ETrue;   
       
  6007             }
       
  6008         }       
       
  6009     else if (IsCcpuFlagSet(ECcpuStateCopy | ECcpuStateCut))
       
  6010         {       
       
  6011         if ((aKeyEvent.iScanCode >= EStdKeyLeftArrow) && (aKeyEvent.iScanCode <= EStdKeyDownArrow)) 
       
  6012             {   
       
  6013             if (!(aKeyEvent.iModifiers & EModifierShift))
       
  6014                 {
       
  6015                 TKeyEvent ccpuStart = aKeyEvent;
       
  6016                 ccpuStart.iModifiers |= EModifierShift;
       
  6017                 ccpuStart.iModifiers |= EModifierRightShift;
       
  6018                 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, aEventCode);        
       
  6019                 
       
  6020                 aRetCode = EKeyWasConsumed;
       
  6021                 return ETrue;                                                                                                       
       
  6022                 }  
       
  6023             else
       
  6024                 {
       
  6025                 aRetCode = EKeyWasNotConsumed;              
       
  6026                 return ETrue;
       
  6027                 }               
       
  6028             }
       
  6029         
       
  6030         TCursorSelection cursorSelection;
       
  6031         if( iInputCapabilities.FepAwareTextEditor() )
       
  6032         	{
       
  6033 			iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSelection); 
       
  6034 			if( (aEventCode ==  EEventKeyUp) && (cursorSelection.Length() == 0) 
       
  6035 				&& ((aKeyEvent.iScanCode ==  EStdKeyBackspace) || (aKeyEvent.iCode ==  EKeyBackspace)
       
  6036 				|| (aKeyEvent.iScanCode ==  EStdKeyDelete) || (aKeyEvent.iCode ==  EKeyDelete))) 
       
  6037 				{
       
  6038 				ClearCcpuFlag(ECcpuStateButton);
       
  6039 				}
       
  6040 			}
       
  6041         if (aKeyEvent.iScanCode != EStdKeyBackspace && aKeyEvent.iCode != EKeyOK)   
       
  6042             {                           
       
  6043             aRetCode = EKeyWasConsumed;
       
  6044             return ETrue;                                                       
       
  6045             }
       
  6046         else
       
  6047             {
       
  6048             if (iInputCapabilities.FepAwareTextEditor())            
       
  6049                 {
       
  6050                 TCursorSelection cursorSelection;                               
       
  6051                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSelection); 
       
  6052                 if (cursorSelection.Length() == 0)      
       
  6053                     {
       
  6054                     aRetCode = EKeyWasConsumed;
       
  6055                     return ETrue;                                                                           
       
  6056                     }
       
  6057                 else if (aKeyEvent.iScanCode == EStdKeyBackspace)
       
  6058                     {
       
  6059                     // Selection will be removed, handle cba button state accordingly                    
       
  6060                     if (iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep() ==
       
  6061                         cursorSelection.Length())
       
  6062                         {
       
  6063                         // Whole text was selected and will be removed. Cancel the ccpu mode.
       
  6064                         ProcessCommandL(EAknFepSoftkeyCloseWindow);
       
  6065                         }
       
  6066                     else    
       
  6067                         {
       
  6068                         // Part of the text will be removed. Set Cba-buttons to initial ccpu-mode status.                        
       
  6069                         __ASSERT_DEBUG(iUiInterface->SoftkeysExist(),
       
  6070                                     AknFepPanic(EAknFepPanicNoHandleToFepAwareTextEditor));
       
  6071                  
       
  6072                         TBool update = UpdateCBALabelL(ELeftSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY);
       
  6073                         update |= UpdateCBALabelL(ERightSoftkeyIndex, EAknFepSoftkeyCloseWindow, R_AKNFEP_SOFTKEY_CCPU_CANCEL);
       
  6074                         update |= UpdateCBALabelL( EMiddleSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY ); 
       
  6075                         if (update)
       
  6076                             {
       
  6077                             iUiInterface->DrawSoftkeysNow();
       
  6078                             }                                                                     
       
  6079                         }
       
  6080                     }                    
       
  6081                 }
       
  6082             }                                   
       
  6083         }
       
  6084         
       
  6085     return EFalse;  
       
  6086     }
       
  6087     
       
  6088     
       
  6089 
       
  6090 void CAknFepManager::AddInputLanguageItemL(CAknFepUiInterfaceMenuPane* aMenuPane, TInt aIndex)
       
  6091     {
       
  6092     CAknFepUiInterfaceMenuPane::SItemData mData;
       
  6093     
       
  6094     TBuf<KMaxFileName> langStr;
       
  6095     TInt Inputlangindex;
       
  6096     if(!aMenuPane->MenuItemExists(EAknCmdInputLanguage, Inputlangindex))
       
  6097 	    {    
       
  6098     StringLoader::Load(langStr, R_AKNFEP_OPTIONS_INPUT_LANGUAGE);
       
  6099     
       
  6100     mData.iCommandId = EAknCmdInputLanguage;
       
  6101     mData.iCascadeId = 0;  
       
  6102     mData.iFlags = 0;
       
  6103     mData.iText.Copy(langStr.Mid(1, langStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  6104     
       
  6105     aMenuPane->InsertMenuItemL(mData, aIndex); 
       
  6106 	    }
       
  6107     
       
  6108     // Chinese input mode switching from the option menu
       
  6109     if (IsChineseInputLanguage() && iSharedDataInterface->QwertyInputMode())
       
  6110         {
       
  6111         // Add Chinese language items
       
  6112         langStr.Zero();
       
  6113         
       
  6114         StringLoader::Load(langStr, R_AKNFEP_OPTIONS_INPUT_MODE_CHI);
       
  6115         
       
  6116         mData.iCommandId = EAknCmdInputMethod;
       
  6117         mData.iCascadeId = R_AVKON_INPUT_MODE_SUB_MENU;
       
  6118         mData.iFlags = 0;
       
  6119         mData.iText.Copy(langStr.Mid(1, langStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  6120         
       
  6121         aMenuPane->InsertMenuItemL(mData, ++aIndex);
       
  6122         
       
  6123         // Check if the current engine has CangJie feature or not, if not
       
  6124         // then CangJie mode becomes invisible, similar impl in IsInputModeAvailable
       
  6125         // and DoChineseSubMenu        
       
  6126         TBool isCangJieSupported = EFalse;
       
  6127         MPtiCoreInfo* ptiCoreInfo = iPtiEngine->CoreInfo(EPtiEngineNormalCangjieQwerty);
       
  6128         if ( ptiCoreInfo )
       
  6129             {
       
  6130             isCangJieSupported = ptiCoreInfo->CapsBits() & ESupportCangjieInput;
       
  6131             }
       
  6132         
       
  6133         // Add Hong Kong CangJie option, option available only in HK variant and qwerty mode
       
  6134         if ( iLanguageCapabilities.iInputLanguageCode == 
       
  6135              ELangHongKongChinese && isCangJieSupported )
       
  6136             {
       
  6137             langStr.Zero();
       
  6138             
       
  6139             StringLoader::Load(langStr, R_AKNFEP_OPTIONS_CANGJIE_MODE);
       
  6140             
       
  6141             mData.iCommandId = EChinFepCmdModeCangJieOption;
       
  6142             mData.iCascadeId = 0;
       
  6143             mData.iFlags = 0;
       
  6144             mData.iText.Copy(langStr.Mid(1, langStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  6145             
       
  6146             aMenuPane->InsertMenuItemL(mData, ++aIndex);          
       
  6147             }
       
  6148         }
       
  6149     }
       
  6150 
       
  6151 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  6152 // Predictive QWERTY (XT9) changes ---->
       
  6153 void CAknFepManager::AddPredictiveModeOptionsL(CAknFepUiInterfaceMenuPane* aMenuPane, 
       
  6154                                                TInt aIndex ) const
       
  6155     {
       
  6156     CAknFepUiInterfaceMenuPane::SItemData mData;
       
  6157     
       
  6158     HBufC* inputMenuStr = StringLoader::LoadLC(R_AKNFEP_PRED_OPTIONS_INPUT_OPTIONS);
       
  6159     
       
  6160     mData.iCommandId = 0;
       
  6161     mData.iCascadeId = R_AKNFEP_PRED_INPUT_OPTIONS_SUBMENU;  
       
  6162     mData.iFlags = 0;
       
  6163     mData.iText.Copy(inputMenuStr->Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  6164     
       
  6165     CleanupStack::PopAndDestroy(inputMenuStr);
       
  6166     
       
  6167     aMenuPane->InsertMenuItemL(mData, aIndex);
       
  6168        
       
  6169     // Chinese input mode switching from the option menu
       
  6170     if (IsChineseInputLanguage() && iSharedDataInterface->QwertyInputMode())
       
  6171         {
       
  6172         // Add Chinese language items
       
  6173         TBuf<KMaxFileName> langStr;
       
  6174         
       
  6175         langStr.Zero();
       
  6176         
       
  6177         StringLoader::Load(langStr, R_AKNFEP_OPTIONS_INPUT_MODE_CHI);
       
  6178         
       
  6179         mData.iCommandId = EAknCmdInputMethod;
       
  6180         mData.iCascadeId = R_AVKON_INPUT_MODE_SUB_MENU;
       
  6181         mData.iFlags = 0;
       
  6182         mData.iText.Copy(langStr.Mid(1, langStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  6183         
       
  6184         aMenuPane->InsertMenuItemL(mData, ++aIndex);
       
  6185         
       
  6186         // Check if the current engine has CangJie feature or not, if not
       
  6187         // then CangJie mode becomes invisible, similar impl in IsInputModeAvailable
       
  6188         // and DoChineseSubMenu        
       
  6189         TBool isCangJieSupported = EFalse;
       
  6190         MPtiCoreInfo* ptiCoreInfo = iPtiEngine->CoreInfo(EPtiEngineNormalCangjieQwerty);
       
  6191         if ( ptiCoreInfo != NULL)
       
  6192             {
       
  6193             isCangJieSupported = ptiCoreInfo->CapsBits() & ESupportCangjieInput;
       
  6194             }
       
  6195 #ifdef __HALF_QWERTY_KEYPAD
       
  6196         isCangJieSupported = isCangJieSupported && (iKeyboardType != EPtiKeyboardHalfQwerty);
       
  6197 #endif //__HALF_QWERTY_KEYPAD
       
  6198         
       
  6199         // Add Hong Kong CangJie option, option available only in HK variant and qwerty mode
       
  6200         if ( iLanguageCapabilities.iInputLanguageCode == ELangHongKongChinese && isCangJieSupported )
       
  6201             {
       
  6202             langStr.Zero();
       
  6203             
       
  6204             StringLoader::Load(langStr, R_AKNFEP_OPTIONS_CANGJIE_MODE);
       
  6205             
       
  6206             mData.iCommandId = EChinFepCmdModeCangJieOption;
       
  6207             mData.iCascadeId = 0;
       
  6208             mData.iFlags = 0;
       
  6209             mData.iText.Copy(langStr.Mid(1, langStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
  6210             
       
  6211             aMenuPane->InsertMenuItemL(mData, ++aIndex);          
       
  6212             }
       
  6213         }
       
  6214     }
       
  6215 
       
  6216 void CAknFepManager::AddPredictiveModeEditMenuL(CAknFepUiInterfaceMenuPane* aMenuPane, 
       
  6217                                                 TInt aIndex ) const
       
  6218 	{
       
  6219 	// Remove Predictive Edit menu option if XT9 options are there --->
       
  6220 	aMenuPane->SetItemDimmed(EAknCmdPredictiveTextCascade, ETrue);
       
  6221     aMenuPane->SetItemDimmed(EAknCmdMultitapPredictiveT9On, ETrue);
       
  6222 	// Remove Predictive Edit menu option if XT9 options are there <---
       
  6223 	//if current writing language supports prediction then display input options settings --> 
       
  6224     //if current writing language does not supports prediction then display only input language 
       
  6225     //option to modify the writing language, when user wants to modify when edit query is launched. <--
       
  6226      TBool isLanguagugeSupportsPrediction = EFalse;
       
  6227      switch(iKeyboardType)
       
  6228      {
       
  6229 		 case EPtiKeyboardHalfQwerty:
       
  6230 #ifdef __HALF_QWERTY_KEYPAD		 
       
  6231 		 		isLanguagugeSupportsPrediction = (iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive); 
       
  6232 #endif   //__HALF_QWERTY_KEYPAD
       
  6233 		    break;
       
  6234      case EPtiKeyboardQwerty4x12:
       
  6235      case EPtiKeyboardQwerty4x10:  
       
  6236      case EPtiKeyboardQwerty3x11:
       
  6237      case EPtiKeyboardCustomQwerty:
       
  6238 		 		isLanguagugeSupportsPrediction = (iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternQwertyPredictive);
       
  6239 		    break;
       
  6240      case EPtiKeyboardNone:
       
  6241      case EPtiKeyboard12Key:
       
  6242 		 		isLanguagugeSupportsPrediction = (!iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternPredictive);
       
  6243 		    break;
       
  6244 		 default:
       
  6245 		 		isLanguagugeSupportsPrediction = (!iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternPredictive);
       
  6246 		    break;    
       
  6247 		 }
       
  6248      if (isLanguagugeSupportsPrediction && !(iAknEditorFlags & EAknEditorFlagNoT9))
       
  6249          {
       
  6250          aMenuPane->SetItemDimmed(EAknCmdInputLanguage, ETrue);           
       
  6251          AddPredictiveModeOptionsL(aMenuPane, aIndex);
       
  6252          }
       
  6253 	}
       
  6254 // Predictive QWERTY (XT9) changes <----
       
  6255 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6256 void CAknFepManager::DoChineseSubMenu(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  6257     {
       
  6258     // ZhuyinFind & StrokeFind ONLY available for FindEditors
       
  6259     if (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes)
       
  6260         {
       
  6261         if (iMode == EZhuyinFind)
       
  6262             {
       
  6263             aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyinFind, ETrue);
       
  6264             }
       
  6265         
       
  6266         if (iMode == EStrokeFind)
       
  6267             {
       
  6268             aMenuPane->SetItemDimmed(EChinFepCmdModeStrokeFind, ETrue);
       
  6269             }        
       
  6270         }
       
  6271     else
       
  6272         {
       
  6273         aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyinFind, ETrue);
       
  6274         aMenuPane->SetItemDimmed(EChinFepCmdModeStrokeFind, ETrue);
       
  6275         }
       
  6276     
       
  6277     // Customize menu item for Chinese mainland
       
  6278     if (iLanguageCapabilities.iInputLanguageCode == ELangPrcChinese)
       
  6279         {
       
  6280         aMenuPane->SetItemDimmed(EChinFepCmdModeCangJie, ETrue);
       
  6281         aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyin, ETrue);
       
  6282         aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyinFind, ETrue);
       
  6283         
       
  6284         if (iMode == EPinyin)
       
  6285             {
       
  6286             aMenuPane->SetItemDimmed(EChinFepCmdModePinyin, ETrue);
       
  6287             }
       
  6288         else if (iMode == EStroke)
       
  6289             {
       
  6290             aMenuPane->SetItemDimmed(EChinFepCmdModeStroke, ETrue);
       
  6291             }
       
  6292         else if (iMode == ELatin)
       
  6293             {
       
  6294             aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6295             }
       
  6296         else
       
  6297             return;
       
  6298         }
       
  6299     // Customize menu item for HongKong
       
  6300     else if (iLanguageCapabilities.iInputLanguageCode == ELangHongKongChinese)
       
  6301         {
       
  6302         aMenuPane->SetItemDimmed(EChinFepCmdModePinyin, ETrue);
       
  6303         aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyin, ETrue);
       
  6304         aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyinFind, ETrue);     
       
  6305         
       
  6306         TBool isCangJieSupported = EFalse;
       
  6307 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  6308         if ( EPtiKeyboardQwerty3x11 == KeyboardLayout() )
       
  6309         	{
       
  6310         	isCangJieSupported = ETrue;
       
  6311         	}
       
  6312 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6313 #ifdef RD_INTELLIGENT_TEXT_INPUT      
       
  6314 #ifdef __HALF_QWERTY_KEYPAD
       
  6315         isCangJieSupported = isCangJieSupported && (iKeyboardType != EPtiKeyboardHalfQwerty);
       
  6316 #endif //__HALF_QWERTY_KEYPAD
       
  6317 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6318         
       
  6319         // CangJie is only for qwerty mode
       
  6320         if ( !iSharedDataInterface->QwertyInputMode() || !isCangJieSupported )
       
  6321             aMenuPane->SetItemDimmed(EChinFepCmdModeCangJie, ETrue);
       
  6322         
       
  6323         if (iMode == EStroke)
       
  6324             {
       
  6325             aMenuPane->SetItemDimmed(EChinFepCmdModeStroke, ETrue);              
       
  6326             }
       
  6327         else if (iMode == ECangJie)
       
  6328             {
       
  6329             aMenuPane->SetItemDimmed(EChinFepCmdModeCangJie, ETrue);
       
  6330             }
       
  6331         else if (iMode == ELatin)
       
  6332             {
       
  6333             aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6334             }
       
  6335         else
       
  6336             return;                
       
  6337         }
       
  6338     // Customize menu item for TaiWan
       
  6339     else if (iLanguageCapabilities.iInputLanguageCode == ELangTaiwanChinese)
       
  6340         {
       
  6341         aMenuPane->SetItemDimmed(EChinFepCmdModePinyin, ETrue);
       
  6342         aMenuPane->SetItemDimmed(EChinFepCmdModeCangJie, ETrue);
       
  6343         
       
  6344         if (iMode == EStroke)
       
  6345             {
       
  6346             aMenuPane->SetItemDimmed(EChinFepCmdModeStroke, ETrue);
       
  6347             }
       
  6348         else if (iMode == EZhuyin)
       
  6349             {
       
  6350             aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyin, ETrue);
       
  6351             }
       
  6352         else if (iMode == ELatin)
       
  6353             {
       
  6354             aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6355             }
       
  6356         else
       
  6357             return;                 
       
  6358         }
       
  6359     else
       
  6360         return;    
       
  6361     }
       
  6362 #ifdef RD_SCALABLE_UI_V2
       
  6363        
       
  6364 void CAknFepManager::DoWesternTouchMenu(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  6365     {
       
  6366     const TInt inputLanguage = iLanguageCapabilities.iInputLanguageCode;
       
  6367     // if mode is already hangul or language is not korean dim korean mode menu item
       
  6368     TInt index;
       
  6369         
       
  6370     if( iMode == EHangul || inputLanguage != ELangKorean || !(IsModePermitted(EHangul)))
       
  6371         {
       
  6372         if ( aMenuPane->MenuItemExists( EAknCmdEditModeKorean, index) )
       
  6373             {
       
  6374             aMenuPane->SetItemDimmed(EAknCmdEditModeKorean, ETrue);
       
  6375             }
       
  6376         }
       
  6377     else
       
  6378         {
       
  6379         if ( aMenuPane->MenuItemExists( EAknCmdEditModeKorean, index ) )
       
  6380             {
       
  6381             aMenuPane->SetItemDimmed(EAknCmdEditModeKorean, EFalse);
       
  6382             }
       
  6383         }
       
  6384     // remove Chinese specific items from menu
       
  6385     aMenuPane->SetItemDimmed(EAknCmdEditModeAlpha, ETrue);    
       
  6386     
       
  6387     if (aMenuPane->MenuItemExists(EJapanFepCmdModeUserDic, index))
       
  6388         {
       
  6389         aMenuPane->SetItemDimmed(EJapanFepCmdModeUserDic, ETrue);
       
  6390         }
       
  6391 
       
  6392     // T9 stuff
       
  6393     if (WesternPredictive())
       
  6394         {
       
  6395         aMenuPane->SetItemDimmed(EAknCmdPredictiveTextCascade, EFalse);
       
  6396         if(iPtiEngine->CurrentLanguage()->HasInputMode(EPtiEngineWordCompletion))
       
  6397         	{
       
  6398         	// Disable Autoword Completion feature for Touch Input
       
  6399         	#ifndef RD_SCALABLE_UI_V2  
       
  6400         	aMenuPane->SetItemDimmed(EAknCmdPredictiveModeCascade, EFalse);	
       
  6401         	#endif // RD_SCALABLE_UI_V2
       
  6402         	}
       
  6403         	
       
  6404         if (aMenuPane->MenuItemExists(EAknCmdT9PredictiveT9Off, index)) 
       
  6405             {
       
  6406             aMenuPane->SetItemDimmed(EAknCmdT9PredictiveT9Off, EFalse);
       
  6407             }          	
       
  6408         }
       
  6409     else
       
  6410         {
       
  6411         if ( (iPermittedInputModes & EAknEditorTextInputMode) &&
       
  6412             !(iAknEditorFlags & EAknEditorFlagNoT9) &&
       
  6413             iMode == ELatin &&
       
  6414             !IsKoreanInputLanguage() &&
       
  6415             iLanguageCapabilities.iSupportsWesternPredictive)
       
  6416             {
       
  6417             aMenuPane->SetItemDimmed(EAknCmdMultitapPredictiveT9On, EFalse);
       
  6418             }
       
  6419         }
       
  6420 
       
  6421     if (  ( iMode == ENumber || iMode == ENativeNumber ) &&
       
  6422         (iPermittedInputModes & (EAknEditorTextInputMode | EAknEditorSecretAlphaInputMode)) )
       
  6423         {
       
  6424         aMenuPane->SetItemDimmed(EAknCmdEditModeAlpha, EFalse); 
       
  6425         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6426         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6427         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6428         }
       
  6429 
       
  6430     if ( IsModePermitted(ENumber) )
       
  6431         {
       
  6432         if (( iMode != ENumber ||
       
  6433             iMode == ENumber && iLanguageCapabilities.iArabicIndicDigitsAllowed &&
       
  6434             !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
  6435             (iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic)) 
       
  6436             || ( iMode != ENumber ||
       
  6437             iMode == ENumber && iLanguageCapabilities.iEasternArabicIndicDigitsAllowed &&
       
  6438             !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
  6439             (iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic))
       
  6440             ||( iMode != ENumber ||
       
  6441             iMode == ENumber && iLanguageCapabilities.iIndicDigitsAllowed &&
       
  6442             !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
  6443             (iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari)) &&
       
  6444             (!(iPermittedInputModes==EAknEditorNumericInputMode))) // hide the menu if number editor
       
  6445             
       
  6446             {
       
  6447             aMenuPane->SetItemDimmed(EAknCmdEditModeNumber, EFalse);
       
  6448             }
       
  6449         }
       
  6450     
       
  6451     if ( IsModePermitted( ENativeNumber ) )
       
  6452         {
       
  6453        if ( iLanguageCapabilities.iArabicIndicDigitsAllowed &&
       
  6454             !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
  6455             iMode != ENativeNumber )
       
  6456             {
       
  6457             aMenuPane->SetItemDimmed(EAknCmdEditModeArabicIndicNumber, EFalse);
       
  6458             }
       
  6459         else if ( iLanguageCapabilities.iEasternArabicIndicDigitsAllowed &&
       
  6460             !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
  6461             iMode != ENativeNumber )
       
  6462             {
       
  6463             aMenuPane->SetItemDimmed(EAknCmdEditModeEasternArabicIndicNumber, EFalse);
       
  6464             }   
       
  6465         else if( iLanguageCapabilities.iIndicDigitsAllowed && 
       
  6466             !( iAknEditorFlags & EAknEditorFlagLatinInputModesOnly ) &&       
       
  6467 
       
  6468             iMode != ENativeNumber )
       
  6469             {
       
  6470             aMenuPane->SetItemDimmed(EAknCmdEditModeIndicNumber, EFalse);   
       
  6471             }
       
  6472         }
       
  6473 
       
  6474     if (IsAbleToLaunchSCT())
       
  6475         {
       
  6476         if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index)) 
       
  6477             {
       
  6478             aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbol, EFalse);
       
  6479             }
       
  6480         }
       
  6481 
       
  6482     if ( iMode != ENumber && iMode != ENativeNumber && 
       
  6483          iPtiEngine->NumberOfLanguages() > 1 &&
       
  6484         !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))
       
  6485         {
       
  6486         aMenuPane->SetItemDimmed(EAknCmdInputLanguage, EFalse);
       
  6487         }
       
  6488         
       
  6489     if (iPermittedInputModes == EAknEditorNumericInputMode)
       
  6490         {
       
  6491         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6492         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6493         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6494         }
       
  6495     else if ( (iMode == ELatin || iMode == ENumber || iMode == ENativeNumber ) &&
       
  6496         (iPermittedInputModes & EAknEditorSecretAlphaInputMode) &&
       
  6497         !(iPermittedInputModes & EAknEditorTextInputMode))
       
  6498         {
       
  6499         // Text case mode is not available in secret editors.
       
  6500         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6501         }
       
  6502         
       
  6503     if (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes)
       
  6504         {
       
  6505         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6506         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6507         }   
       
  6508         
       
  6509     if (iCaseMan->CurrentCase() == EAknEditorUpperCase)
       
  6510         {
       
  6511         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);   
       
  6512         }
       
  6513     else if (iCaseMan->CurrentCase() == EAknEditorLowerCase)
       
  6514         {
       
  6515         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);   
       
  6516         }
       
  6517         
       
  6518     aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);    
       
  6519     
       
  6520     if (!(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) 
       
  6521     && iFepPluginManager->IsNonLatinLanguage(TLanguage(iSharedDataInterface->InputTextLanguage())))
       
  6522         {
       
  6523         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6524         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6525         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6526         }             
       
  6527     if( iMode == EHangul )
       
  6528         {
       
  6529         //aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, EFalse);
       
  6530         //aMenuPane->SetItemDimmed(EAknCmdEditModeAlpha, EFalse);
       
  6531         
       
  6532         aMenuPane->SetItemDimmed(EAknCmdEditModeEnglish, EFalse);
       
  6533         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6534         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6535         
       
  6536         }
       
  6537     else
       
  6538         {
       
  6539         aMenuPane->SetItemDimmed(EAknCmdEditModeEnglish, ETrue);
       
  6540         }
       
  6541     }    
       
  6542 
       
  6543 void CAknFepManager::DoChineseTouchMenu(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  6544     {
       
  6545     TInt index;
       
  6546     if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index)
       
  6547         && aMenuPane->MenuItemExists(EJapanFepCmdModeUserDic, index)) 
       
  6548         {
       
  6549         aMenuPane->SetItemDimmed(EJapanFepCmdModeUserDic, ETrue);    
       
  6550         }
       
  6551 
       
  6552     if (WesternPredictive())
       
  6553         {
       
  6554         aMenuPane->SetItemDimmed(EAknCmdPredictiveTextCascade, EFalse);
       
  6555         if(iPtiEngine->CurrentLanguage()->HasInputMode(EPtiEngineWordCompletion))
       
  6556         	{
       
  6557         	// Disable Autoword Completion feature for Touch Input
       
  6558         	#ifndef RD_SCALABLE_UI_V2  
       
  6559         	aMenuPane->SetItemDimmed(EAknCmdPredictiveModeCascade, EFalse);	
       
  6560         	#endif // RD_SCALABLE_UI_V2
       
  6561         	}
       
  6562         	
       
  6563         if (aMenuPane->MenuItemExists(EAknCmdT9PredictiveT9Off, index)) 
       
  6564             {
       
  6565             aMenuPane->SetItemDimmed(EAknCmdT9PredictiveT9Off, EFalse);
       
  6566             }             	
       
  6567         }
       
  6568     else
       
  6569         {
       
  6570         if ( (iPermittedInputModes & EAknEditorTextInputMode) &&
       
  6571             !(iAknEditorFlags & EAknEditorFlagNoT9) &&
       
  6572             iMode == ELatin)
       
  6573             {
       
  6574             aMenuPane->SetItemDimmed(EAknCmdMultitapPredictiveT9On, EFalse);
       
  6575             }
       
  6576         }
       
  6577     if (IsAbleToLaunchSCT() &&
       
  6578         aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index))
       
  6579         {
       
  6580         aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbol, EFalse);
       
  6581         }
       
  6582     if( (iFepPluginManager && (iFepPluginManager->PluginInputMode() != EPluginInputModeItut ) ) 
       
  6583             && aMenuPane->MenuItemExists(EChinFepCmdInstructions, index) )  
       
  6584         {
       
  6585         aMenuPane->SetItemDimmed(EChinFepCmdInstructions, ETrue);
       
  6586         }
       
  6587     else if ( !(iPermittedInputModes == EAknEditorNumericInputMode ||
       
  6588         iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) )
       
  6589         {
       
  6590         if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index)) 
       
  6591             {
       
  6592             aMenuPane->SetItemDimmed(EChinFepCmdInstructions, EFalse);
       
  6593             }
       
  6594         }
       
  6595 
       
  6596     if ( iMode != ENumber && iPtiEngine->NumberOfLanguages() > 1  &&
       
  6597         !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))
       
  6598         {
       
  6599         aMenuPane->SetItemDimmed(EAknCmdInputLanguage, EFalse);
       
  6600         }
       
  6601 
       
  6602     if (iPermittedInputModes == EAknEditorNumericInputMode)
       
  6603         {
       
  6604         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6605         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6606         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6607         }
       
  6608     else if ( (iMode == ELatin || iMode == ENumber) &&
       
  6609         (iPermittedInputModes & EAknEditorSecretAlphaInputMode) &&
       
  6610         !(iPermittedInputModes & EAknEditorTextInputMode))
       
  6611         {
       
  6612         // Text case mode is not available in secret editors.
       
  6613         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6614         }
       
  6615     if (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes)
       
  6616         {
       
  6617         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6618         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6619         }
       
  6620 
       
  6621     if ( IsModePermitted(ENumber) && iMode != ENumber )
       
  6622         {
       
  6623         //aMenuPane->SetItemDimmed(EChinFepCmdModeNumber, EFalse);  // original statement
       
  6624         aMenuPane->SetItemDimmed(EAknCmdEditModeNumber, EFalse);
       
  6625         // end modifying
       
  6626         }
       
  6627     }
       
  6628 TBool CAknFepManager::IsChineseInputMode( TInt aMode )
       
  6629     {
       
  6630     return aMode == EPRCFind || aMode == ECangJie || aMode == EZhuyinFind
       
  6631            || aMode == EStrokeFind || aMode == EPinyin || aMode == EZhuyin
       
  6632            || aMode == EStroke;    
       
  6633     }
       
  6634 
       
  6635 #endif //RD_SCALABLE_UI_V2
       
  6636 void CAknFepManager::DoWesternMenu(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  6637     {
       
  6638     // remove Chinese specific items from menu
       
  6639     aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6640     aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6641     aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6642     const TInt inputLanguage = iLanguageCapabilities.iInputLanguageCode;
       
  6643     
       
  6644     
       
  6645     TInt pos=-1;
       
  6646     
       
  6647     if( aMenuPane->MenuItemExists( EAknCmdEditModeKorean, pos ) )
       
  6648         {
       
  6649         // if mode is already hangul or language is not korean dim korean mode menu item
       
  6650         if( iMode == EHangul || inputLanguage != ELangKorean || !(IsModePermitted(EHangul)))
       
  6651             {
       
  6652             
       
  6653             aMenuPane->SetItemDimmed(EAknCmdEditModeKorean, ETrue);
       
  6654             }
       
  6655         else
       
  6656             {
       
  6657             aMenuPane->SetItemDimmed(EAknCmdEditModeKorean, EFalse);
       
  6658             }
       
  6659         }
       
  6660     
       
  6661     TInt index;
       
  6662     
       
  6663     if (aMenuPane->MenuItemExists(EJapanFepCmdModeUserDic, index))
       
  6664         {
       
  6665         aMenuPane->SetItemDimmed(EJapanFepCmdModeUserDic, ETrue);
       
  6666         }
       
  6667 
       
  6668     // T9 stuff
       
  6669     if (WesternPredictive())
       
  6670         {
       
  6671         aMenuPane->SetItemDimmed(EAknCmdPredictiveTextCascade, EFalse);
       
  6672 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  6673         if(iPtiEngine->CurrentLanguage()->HasInputMode(EPtiEngineWordCompletion))
       
  6674         	{
       
  6675         	// Disable Autoword Completion feature for Touch Input
       
  6676         	#ifndef RD_SCALABLE_UI_V2  
       
  6677         	aMenuPane->SetItemDimmed(EAknCmdPredictiveModeCascade, EFalse);	
       
  6678         	#endif // RD_SCALABLE_UI_V2
       
  6679         	}
       
  6680 #endif  //RD_INTELLIGENT_TEXT_INPUT 
       
  6681         }
       
  6682     else
       
  6683         {
       
  6684         if ( (iPermittedInputModes & EAknEditorTextInputMode) &&
       
  6685             !(iAknEditorFlags & EAknEditorFlagNoT9) &&
       
  6686             iMode == ELatin &&
       
  6687 			!IsKoreanInputLanguage() &&
       
  6688 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  6689             // Predictive QWERTY (XT9) changes ---->
       
  6690             ((
       
  6691 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6692             iLanguageCapabilities.iSupportsWesternPredictive && !IsKoreanInputLanguage()
       
  6693 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  6694 			&& !iQwertyInputMode) ||
       
  6695 			(iLanguageCapabilities.iSupportsWesternQwertyPredictive && iQwertyInputMode)
       
  6696 			)
       
  6697             // Predictive QWERTY (XT9) changes <----
       
  6698 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6699            )
       
  6700             {
       
  6701             aMenuPane->SetItemDimmed(EAknCmdMultitapPredictiveT9On, EFalse);
       
  6702             }
       
  6703         }
       
  6704 
       
  6705     if ( ( iMode == ENumber || iMode == ENativeNumber || iMode == EHangul ) && 
       
  6706         (iPermittedInputModes & (EAknEditorTextInputMode | EAknEditorSecretAlphaInputMode)) )
       
  6707         {
       
  6708         aMenuPane->SetItemDimmed(EAknCmdEditModeAlpha, EFalse);
       
  6709         }
       
  6710 
       
  6711     if ( IsModePermitted(ENumber) )
       
  6712         {
       
  6713         if ( iMode != ENumber ) // hide the menu if number editor
       
  6714             {
       
  6715             aMenuPane->SetItemDimmed(EAknCmdEditModeNumber, EFalse);
       
  6716             }
       
  6717 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  6718         // Predictive QWERTY (XT9) changes ---->
       
  6719         // There's no need for numeric mode when full qwerty keyboard is in use (like in MAXI)
       
  6720         if (iQwertyInputMode)
       
  6721             {
       
  6722             aMenuPane->SetItemDimmed(EAknCmdEditModeNumber, ETrue);
       
  6723             }
       
  6724         // Predictive QWERTY (XT9) changes <----
       
  6725 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6726         }
       
  6727         
       
  6728     if ( IsModePermitted(ENativeNumber) && iMode != ENativeNumber)
       
  6729         {
       
  6730         if ( iLanguageCapabilities.iArabicIndicDigitsAllowed ) // hide the menu if number editor)
       
  6731             {
       
  6732             aMenuPane->SetItemDimmed(EAknCmdEditModeArabicIndicNumber, EFalse);
       
  6733             }
       
  6734         else if ( iLanguageCapabilities.iEasternArabicIndicDigitsAllowed ) // hide the menu if number editor)
       
  6735             {
       
  6736             aMenuPane->SetItemDimmed(EAknCmdEditModeEasternArabicIndicNumber, EFalse);
       
  6737             }    
       
  6738         else if( iLanguageCapabilities.iIndicDigitsAllowed ) // hide the menu if number editor)
       
  6739             {
       
  6740             aMenuPane->SetItemDimmed(EAknCmdEditModeIndicNumber, EFalse);   
       
  6741             }
       
  6742         }
       
  6743 
       
  6744     if (IsAbleToLaunchSCT())
       
  6745         {
       
  6746         if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index)) 
       
  6747             {
       
  6748             aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbol, EFalse);
       
  6749             }
       
  6750         }
       
  6751     TInt writtingLanguage = 0;
       
  6752     if ( iMode != ENumber && iMode != ENativeNumber && iPtiEngine->NumberOfLanguages() > 1 &&
       
  6753         !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly)
       
  6754         && aMenuPane->MenuItemExists( EAknCmdInputLanguage, writtingLanguage ) )
       
  6755         {
       
  6756         aMenuPane->SetItemDimmed(EAknCmdInputLanguage, EFalse);
       
  6757         }
       
  6758     }
       
  6759 
       
  6760 void CAknFepManager::DoChineseMenu(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  6761     {
       
  6762     TInt index;
       
  6763     if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index)
       
  6764        && aMenuPane->MenuItemExists(EJapanFepCmdModeUserDic, index)) 
       
  6765         {
       
  6766         aMenuPane->SetItemDimmed(EJapanFepCmdModeUserDic, ETrue);    
       
  6767         }
       
  6768 
       
  6769     if (WesternPredictive())
       
  6770         {
       
  6771         aMenuPane->SetItemDimmed(EAknCmdPredictiveTextCascade, EFalse);
       
  6772 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  6773         if(iPtiEngine->CurrentLanguage()->HasInputMode(EPtiEngineWordCompletion))
       
  6774         	{
       
  6775         	// Disable Autoword Completion feature for Touch Input
       
  6776         	#ifndef RD_SCALABLE_UI_V2  
       
  6777         	aMenuPane->SetItemDimmed(EAknCmdPredictiveModeCascade, EFalse);	
       
  6778         	#endif // RD_SCALABLE_UI_V2
       
  6779         	}
       
  6780 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  6781         }
       
  6782     else
       
  6783         {
       
  6784         if ( (iPermittedInputModes & EAknEditorTextInputMode) &&
       
  6785             !(iAknEditorFlags & EAknEditorFlagNoT9) &&
       
  6786             iMode == ELatin)
       
  6787             {
       
  6788             aMenuPane->SetItemDimmed(EAknCmdMultitapPredictiveT9On, EFalse);
       
  6789             }
       
  6790         }
       
  6791     if (IsAbleToLaunchSCT() &&
       
  6792         aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index))
       
  6793         {
       
  6794         aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbol, EFalse);
       
  6795         }
       
  6796     if( iQwertyInputMode && aMenuPane->MenuItemExists(EChinFepCmdInstructions, index) )
       
  6797         {
       
  6798         aMenuPane->SetItemDimmed(EChinFepCmdInstructions, ETrue);
       
  6799         }
       
  6800     else if ( !(iPermittedInputModes == EAknEditorNumericInputMode ||
       
  6801         iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) )
       
  6802         {
       
  6803         if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index)
       
  6804             && aMenuPane->MenuItemExists(EChinFepCmdInstructions, index)) 
       
  6805             {
       
  6806             aMenuPane->SetItemDimmed(EChinFepCmdInstructions, EFalse);
       
  6807             }
       
  6808         }
       
  6809 
       
  6810     if ( (!IsOnlyNumericPermitted()) && iPtiEngine->NumberOfLanguages() > 1  &&
       
  6811         !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))
       
  6812         {
       
  6813         aMenuPane->SetItemDimmed(EAknCmdInputLanguage, EFalse);
       
  6814         // the follow added for phrase creation
       
  6815         TInt iptlanguage;
       
  6816         if ( !iIsUserdbdlgActive 
       
  6817 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  6818         && EPtiKeyboardHalfQwerty != KeyboardLayout() 
       
  6819 #endif
       
  6820         && IsChineseInputLanguage() )
       
  6821             {
       
  6822             aMenuPane->MenuItemExists( EAknCmdInputLanguage, iptlanguage );
       
  6823             MPtiLanguage* ptilang = iPtiEngine->CurrentLanguage();
       
  6824             TInt inputLanguage = (ptilang)? ptilang->LanguageCode() : 0;          
       
  6825             if (iQwertyInputMode && (inputLanguage == ELangPrcChinese ||
       
  6826             	inputLanguage == ELangHongKongChinese ||
       
  6827             	inputLanguage == ELangTaiwanChinese))
       
  6828             	{
       
  6829             	TRAP_IGNORE(AddUserDBDlgItemL( aMenuPane, iptlanguage ));
       
  6830             	}
       
  6831             }
       
  6832         }
       
  6833 
       
  6834     if (iPermittedInputModes == EAknEditorNumericInputMode)
       
  6835         {
       
  6836         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6837         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6838         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6839         }
       
  6840     else if ( (iMode == ELatin || iMode == ENumber) &&
       
  6841         (iPermittedInputModes & EAknEditorSecretAlphaInputMode) &&
       
  6842         !(iPermittedInputModes & EAknEditorTextInputMode))
       
  6843         {
       
  6844         // Text case mode is not available in secret editors.
       
  6845         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6846         }
       
  6847     if (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes)
       
  6848         {
       
  6849         aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6850         aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6851         }
       
  6852 
       
  6853     if ( IsModePermitted(ENumber) && iMode != ENumber )
       
  6854         {
       
  6855         //aMenuPane->SetItemDimmed(EChinFepCmdModeNumber, EFalse);  // original statement
       
  6856         aMenuPane->SetItemDimmed(EAknCmdEditModeNumber, EFalse);
       
  6857         // end modifying
       
  6858         }
       
  6859     }
       
  6860 
       
  6861 void CAknFepManager::DoJapaneseMenu(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  6862     {
       
  6863     // remove Chinese specific items from menu
       
  6864     TInt index;
       
  6865     if (aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index))
       
  6866         {
       
  6867         aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbol, ETrue);
       
  6868         }
       
  6869         
       
  6870     aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue);
       
  6871     aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);
       
  6872     aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);
       
  6873 
       
  6874     if (IsAbleToLaunchSCT()
       
  6875      && !iSharedDataInterface->QwertyInputMode())
       
  6876         {
       
  6877         aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbolJp, EFalse);
       
  6878         }
       
  6879 
       
  6880     if (IsAbleToLaunchPCT()
       
  6881      && !iSharedDataInterface->QwertyInputMode())
       
  6882         {
       
  6883         aMenuPane->SetItemDimmed(EAknCmdEditInsertPictograph, EFalse);
       
  6884         }
       
  6885 
       
  6886     if (!(iPermittedInputModes & EAknEditorHiraganaKanjiInputMode) &&
       
  6887         aMenuPane->MenuItemExists(EJapanFepCmdModeUserDic, index)
       
  6888         )
       
  6889         {
       
  6890         aMenuPane->SetItemDimmed(EJapanFepCmdModeUserDic, ETrue);
       
  6891         }
       
  6892 
       
  6893     if (iPermittedInputModes == (EAknEditorSecretAlphaInputMode | EAknEditorNumericInputMode))
       
  6894         {
       
  6895         if (iMode == ELatin)
       
  6896             {
       
  6897             aMenuPane->SetItemDimmed(EJapanFepCmdEditModeNumber, EFalse);
       
  6898             }
       
  6899         else if (iMode == ENumber)
       
  6900             {
       
  6901             aMenuPane->SetItemDimmed(EJapanFepCmdEditModeAlpha, EFalse);
       
  6902             }
       
  6903         }
       
  6904     else
       
  6905         {
       
  6906         // If the fep is running on the Janapnse User Dictionary Application,
       
  6907         // "User Dictionary" in editting options menu is hidden.
       
  6908         if (CEikonEnv::Static()->EikAppUi()->Application())
       
  6909             {
       
  6910             if (CEikonEnv::Static()->EikAppUi()->Application()->AppDllUid() == KUidUserDictApp)
       
  6911                 {
       
  6912                 aMenuPane->SetItemDimmed(EJapanFepCmdModeUserDic, ETrue);
       
  6913                 }
       
  6914             }
       
  6915 
       
  6916         if (iPermittedInputModes & EAknEditorHiraganaKanjiInputMode)
       
  6917             {
       
  6918             aMenuPane->SetItemDimmed(EJapanFepCmdModeKutenCodeInput, EFalse);
       
  6919             }
       
  6920 
       
  6921         TInt value = iSharedDataInterface->ClearDirection();
       
  6922         if (value == EClearDirectionRight)
       
  6923             {
       
  6924             aMenuPane->SetItemDimmed(EAknCmdEditClearDirectionLeft, EFalse);
       
  6925             }
       
  6926         else
       
  6927             {
       
  6928             aMenuPane->SetItemDimmed(EAknCmdEditClearDirectionRight, EFalse);
       
  6929             }
       
  6930 
       
  6931         if (!iSharedDataInterface->QwertyInputMode())
       
  6932             {
       
  6933             if (IsPredictive(ELatin))
       
  6934                 {
       
  6935                 aMenuPane->SetItemDimmed(EJapanFepCmdPredictiveTextCascade, EFalse);
       
  6936                 }
       
  6937             else if ((iPermittedInputModes & EAknEditorHalfWidthTextInputMode)
       
  6938                   && !(iAknEditorFlags & EAknEditorFlagNoT9))
       
  6939                 {
       
  6940                 aMenuPane->SetItemDimmed(EJapanFepCmdMultitapPredictiveT9On, EFalse);
       
  6941                 }
       
  6942             }
       
  6943 
       
  6944         if (IsPredictive(EHiraganaKanji))
       
  6945             {
       
  6946             aMenuPane->SetItemDimmed(EJapanFepCmdModePredictiveOff, EFalse);
       
  6947             }
       
  6948         else if((iPermittedInputModes & EAknEditorHiraganaKanjiInputMode)
       
  6949              && !(iAknEditorFlags & EAknEditorFlagNoT9))
       
  6950             {
       
  6951             aMenuPane->SetItemDimmed(EJapanFepCmdModePredictiveOn, EFalse);
       
  6952             }
       
  6953 
       
  6954         if (iMode != EHiraganaKanji && iPermittedInputModes & EAknEditorHiraganaKanjiInputMode)
       
  6955             {
       
  6956             aMenuPane->SetItemDimmed(EJapanFepCmdModeHiragana, EFalse);
       
  6957             }
       
  6958 
       
  6959         if (iCharWidth == EHalfWidthChar)
       
  6960             {
       
  6961             if (iPermittedInputModes & EAknEditorKatakanaInputMode && iMode != EKatakana)
       
  6962                 {
       
  6963                 aMenuPane->SetItemDimmed(EJapanFepCmdModeKatakana, EFalse);
       
  6964                 }
       
  6965 
       
  6966             if (iMode != ELatin && (iPermittedInputModes & EAknEditorHalfWidthTextInputMode
       
  6967                 || iPermittedInputModes & EAknEditorSecretAlphaInputMode))
       
  6968                 {
       
  6969                 aMenuPane->SetItemDimmed(EJapanFepCmdEditModeAlpha, EFalse);
       
  6970                 }
       
  6971 
       
  6972             if (iMode != ENumber
       
  6973              && iPermittedInputModes & EAknEditorNumericInputMode
       
  6974              && !iSharedDataInterface->QwertyInputMode())
       
  6975                 {
       
  6976                 aMenuPane->SetItemDimmed(EJapanFepCmdEditModeNumber, EFalse);
       
  6977                 }
       
  6978 
       
  6979             if (iMode == EKatakana && iPermittedInputModes & EAknEditorFullWidthKatakanaInputMode)
       
  6980                 {
       
  6981                 aMenuPane->SetItemDimmed(EJapanFepCmdModeFullWidth, EFalse);
       
  6982                 }
       
  6983 
       
  6984             if (iMode == ELatin && !iWesternPredictive 
       
  6985              && iPermittedInputModes & EAknEditorFullWidthTextInputMode)
       
  6986                 {
       
  6987                 aMenuPane->SetItemDimmed(EJapanFepCmdModeFullWidth, EFalse);
       
  6988                 }
       
  6989 
       
  6990             if (iMode == ENumber
       
  6991              && iPermittedInputModes & EAknEditorFullWidthNumericInputMode)
       
  6992                 {
       
  6993                 aMenuPane->SetItemDimmed(EJapanFepCmdModeFullWidth, EFalse);
       
  6994                 }
       
  6995             }
       
  6996         else // Full width Character
       
  6997             {
       
  6998             if (iMode != EKatakana && iPermittedInputModes & EAknEditorFullWidthKatakanaInputMode)
       
  6999                 {
       
  7000                 aMenuPane->SetItemDimmed(EJapanFepCmdModeKatakana, EFalse);
       
  7001                 }
       
  7002 
       
  7003             if (iMode != ELatin && iPermittedInputModes & EAknEditorFullWidthTextInputMode)
       
  7004                 {
       
  7005                 aMenuPane->SetItemDimmed(EJapanFepCmdEditModeAlpha, EFalse);
       
  7006                 }
       
  7007 
       
  7008             if (iMode != ENumber
       
  7009              && iPermittedInputModes & EAknEditorFullWidthNumericInputMode
       
  7010              && !iSharedDataInterface->QwertyInputMode())
       
  7011                 {
       
  7012                 aMenuPane->SetItemDimmed(EJapanFepCmdEditModeNumber, EFalse);
       
  7013                 }
       
  7014 
       
  7015             if (iMode == EKatakana && iPermittedInputModes & EAknEditorKatakanaInputMode)
       
  7016                 {
       
  7017                 aMenuPane->SetItemDimmed(EJapanFepCmdModeHalfWidth, EFalse);
       
  7018                 }
       
  7019 
       
  7020             if (iMode == ELatin && iPermittedInputModes & EAknEditorFullWidthTextInputMode)
       
  7021                 {
       
  7022                 aMenuPane->SetItemDimmed(EJapanFepCmdModeHalfWidth, EFalse);
       
  7023                 }
       
  7024 
       
  7025             if (iMode == ENumber
       
  7026              && iPermittedInputModes & EAknEditorFullWidthNumericInputMode)
       
  7027                 {
       
  7028                 aMenuPane->SetItemDimmed(EJapanFepCmdModeHalfWidth, EFalse);
       
  7029                 }
       
  7030             }
       
  7031         }
       
  7032     }
       
  7033 
       
  7034 void CAknFepManager::HandlePointerEventInInlineTextL(TPointerEvent::TType /*aType*/, TUint /*aModifiers*/, TInt /*aPositionInInlineText*/)
       
  7035     {
       
  7036     }
       
  7037 
       
  7038 void CAknFepManager::GetFormatOfFepInlineText(TCharFormat& aFormat, 
       
  7039                                               TInt& aNumberOfCharactersWithSameFormat, 
       
  7040                                               TInt aPositionOfCharacter) const
       
  7041     {
       
  7042     if ( FepUI() )
       
  7043         {
       
  7044         FepUI()->GetFormatOfFepInlineText(aFormat, aNumberOfCharactersWithSameFormat, 
       
  7045                                           aPositionOfCharacter);
       
  7046         }
       
  7047     }
       
  7048 
       
  7049 void CAknFepManager::NumberModeChangeGSNotification()
       
  7050 	{
       
  7051 	iLanguageCapabilities.iNumericEditorDigitType = EDigitTypeUnknown;
       
  7052 	UpdateNumericEditorDigitType();	
       
  7053 	UpdateLocalDigitMode();
       
  7054 	}
       
  7055 
       
  7056 void CAknFepManager::HandleChangeInFocusL()
       
  7057     {
       
  7058     // Closing SCT has done focus change, so here just reset the flag.
       
  7059     // dim state changed, need fetch it again.
       
  7060     SendEventsToPluginManL(EPluginEnableFetchDimState);
       
  7061 
       
  7062     //The CCPU flag ECcpuStateShiftkeyWasPressedBeforeLosingFocus suggests that the candidate list was closed
       
  7063     //with a long key press of shift key. If so then, FEP needs to set the EFlagShiftKeyDepressed for the CCPU mode to work 
       
  7064     //correctly. The state of the shift state is copied to local variable isToSetShiftKeyStateDown because as a function of change
       
  7065     //of focus the FEP clears all the CCPU flags which would reset ECcpuStateShiftkeyWasPressedBeforeLosingFocus also.
       
  7066     TBool isToSetShiftKeyStateDown = IsCcpuFlagSet(ECcpuStateShiftkeyWasPressedBeforeLosingFocus);
       
  7067     if (!Japanese() || iFepManState != EAknFepStateUIActive)
       
  7068         {
       
  7069         if (IsCcpuFlagSet(ECcpuStateIgnoreNextFocusChange))
       
  7070             {
       
  7071             // The focus event was caused by menu selection, don't clear all ccpu flags.
       
  7072             ClearCcpuFlag(ECcpuStateIgnoreNextFocusChange);
       
  7073             }
       
  7074         else
       
  7075             {
       
  7076             if((HashKeySelectionInUse() && IsCcpuFlagSet(ECcpuStateHashDown) 
       
  7077              && IsCcpuFlagSet(ECcpuStateEdwinInSelectionMode)))
       
  7078                 {
       
  7079                 ClearCcpuFlag(ECcpuStateHashDown);              
       
  7080                 SetCcpuFlag(ECcpuStateSelectionEventPosted);
       
  7081                 ClearCcpuFlag(ECcpuStateEdwinInSelectionMode);
       
  7082                 SetFlag(EFlagLongShiftKeyPress);                
       
  7083                 TKeyEvent ccpuStart = {0, EStdKeyLeftShift, 0, 0};
       
  7084                 CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKeyUp);                                       
       
  7085                 }   
       
  7086             else
       
  7087                 {
       
  7088                 TBool isToSupressCursorMove = IsCcpuFlagSet(ECcpuStateSupressCursorMoveToEnd);
       
  7089                 TBool isCommitPredictiveWord = IsCcpuFlagSet(ECcpuStataCommitPredictiveWord);
       
  7090                 CancelCcpuMode();               
       
  7091                 if(isToSupressCursorMove)
       
  7092                     SetCcpuFlag(ECcpuStateSupressCursorMoveToEnd);
       
  7093                 if(isCommitPredictiveWord)
       
  7094                     SetCcpuFlag(ECcpuStataCommitPredictiveWord);                
       
  7095                 }    
       
  7096             
       
  7097             }
       
  7098         SetCcpuFlag(ECcpuSupressEditMenuFromShiftUp);        
       
  7099         iPreviousEditingState = EStateNone;
       
  7100         iEditIndicatorAtLastUpdate = NULL;
       
  7101         ClearFlag( EFlagBidiCursorIsInitialized );
       
  7102 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  7103 // removing the no match indicator is not necessary for ITI 
       
  7104         if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  7105             {
       
  7106             TryRemoveNoMatchesIndicatorL();
       
  7107             }
       
  7108 #endif             
       
  7109         UpdateCbaL(NULL);
       
  7110                     
       
  7111         if (iFepFullyConstructed)
       
  7112             {
       
  7113             SetCcpuFlag(ECcpuStateLosingFocus); // CommitInlineEditL needs to now we're losing focus (for cursor handling):           
       
  7114             CancelAllTimerActivity();
       
  7115             FepUI()->ExpireMultitapTimer();
       
  7116             ClearCcpuFlag(ECcpuStateLosingFocus); // Cleared right away to make sure nothing else is affected.              
       
  7117             }
       
  7118         // Forget shift key and chr key press if application or UI component is
       
  7119         // changed during shiftkey press.
       
  7120         ClearFlag(EFlagQwertyChrKeyDepressed);
       
  7121         //If candidate list was closed by long keypress of shift key, set the flag EFlagShiftKeyDepressed for CCPU mode
       
  7122         //to work correctly once it re-focuses on the editor.
       
  7123         if(isToSetShiftKeyStateDown)
       
  7124             {
       
  7125             SetFlag(EFlagShiftKeyDepressed);
       
  7126             ClearCcpuFlag(ECcpuStateShiftkeyWasPressedBeforeLosingFocus);
       
  7127             }
       
  7128         else
       
  7129             {
       
  7130             ClearFlag(EFlagShiftKeyDepressed);
       
  7131             }
       
  7132         if ( iFepFullyConstructed && IsFepAwareTextEditor() )
       
  7133             {
       
  7134             //save state of old item
       
  7135             TransferFepStateToEditorL();
       
  7136 
       
  7137             if ( WesternPredictive() )
       
  7138                 {                                            
       
  7139 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  7140                 // To rip off suggested word completion when there is a change in focus
       
  7141                 if(IsAutoCompleteOn())
       
  7142                 	{
       
  7143                 	RemoveSuggestedCompletionL();
       
  7144 
       
  7145                 	}
       
  7146 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  7147                 SetCcpuFlag(ECcpuStateLosingFocus);    // CommitInlineEditL needs to now we're losing focus (for cursor handling):                
       
  7148                 CommitInlineEditL(); 
       
  7149                 ClearCcpuFlag(ECcpuStateLosingFocus);  // Cleared right away to make sure nothing else is affected.                              
       
  7150                 }
       
  7151             else
       
  7152                 {
       
  7153                 TryCloseUiL();
       
  7154                 }
       
  7155                                  
       
  7156             iRememberLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
  7157             if (iLastFocusedEditor && !IsExtendedFlagSet(EExtendedFlagFepAwareDialogLaunched))
       
  7158                 {
       
  7159                 iLastFocusedEditor->SetObserver(NULL);
       
  7160                 iLastFocusedEditor = NULL;
       
  7161                 }            
       
  7162 			// When editor launches a non-fep aware dialog, then we
       
  7163 			// should not set the observer to Null. Because if the dialog is 
       
  7164 			// destroyed we will not know and the dialog will remain orphaned.                                     
       
  7165 			// Also we need to know the fep editor pointer.
       
  7166             iLastFocusedEditor = EditorState();        
       
  7167             iEditorCcpuStatus = EditorCcpuStatus(iLastFocusedEditor); 
       
  7168             //iLastFocusedEditor->SetObserver(NULL);    
       
  7169 #ifdef RD_SCALABLE_UI_V2            
       
  7170             UnregisterObserver();
       
  7171 #endif // RD_SCALABLE_UI_V2 
       
  7172             }
       
  7173 
       
  7174         if (iPermittedInputModes & EAknEditorSecretAlphaInputMode &&
       
  7175             !(iPermittedInputModes & EAknEditorTextInputMode))
       
  7176             {
       
  7177             // For password editors.                
       
  7178             ClearFlag(EFlagSupressAutoUpdate);
       
  7179             } 
       
  7180 
       
  7181         // Losing focus is over, from this point on we are gaining focus.
       
  7182         ClearCcpuFlag(ECcpuStateLosingFocus);   
       
  7183 
       
  7184 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  7185         if(iFnKeyManager)
       
  7186                 iFnKeyManager->ClearFnKeyState();
       
  7187                 
       
  7188         if(iResourceString)
       
  7189           {
       
  7190           delete iResourceString;
       
  7191           iResourceString = NULL;
       
  7192           }
       
  7193 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  7194         
       
  7195         // get input capabilities from newly focused item
       
  7196         CCoeEnv* coeEnv = CCoeEnv::Static();
       
  7197         iInputCapabilities = static_cast<const CCoeAppUi*>(coeEnv->AppUi())->InputCapabilities();
       
  7198         SetQwertyModeToInputcapbility();
       
  7199         if ( IsFepAwareTextEditor() )
       
  7200             {
       
  7201             // Now at the launch of non-fep aware dialogs we do not set the editor observer to NULL,
       
  7202             // and retain the editor pointer in iLastFocusedEditor. 
       
  7203             // So in case the editor is back in focus, we set iLastFocusedEditor to NULL
       
  7204             // and set the editor observer again.
       
  7205             
       
  7206 			// At launch of fep aware dialog on a fep aware editor say spell query launched on messaging editor,
       
  7207             // we have the flag EExtendedFlagFepAwareDialogLaunched set. 
       
  7208 			// So in this scenario we retain the observer for both the editor as we need to close the spell query
       
  7209             // on close of messaging editor. 
       
  7210             // Specific scenario is explained, the same is applicable for all general scenarios, for any
       
  7211             // fep aware dialog launched on any other fep aware editor.
       
  7212             if (iLastFocusedEditor && !IsExtendedFlagSet(EExtendedFlagFepAwareDialogLaunched))
       
  7213                 {
       
  7214                 iLastFocusedEditor->SetObserver(NULL);
       
  7215                 iLastFocusedEditor = NULL;
       
  7216                 }
       
  7217             if( EditorState() )
       
  7218                 {
       
  7219             	EditorState()->SetObserver(this);
       
  7220                 }
       
  7221             ConfigureFEPFromEditorStateL();
       
  7222 #ifdef RD_INTELLIGENT_TEXT_INPUT	
       
  7223 			if( PtiEngine() )
       
  7224 				{
       
  7225 	            if(!IsAutoCompleteOn())
       
  7226 	                {
       
  7227 					TInt tailLength = 0;
       
  7228 		            TRAP_IGNORE( PtiEngine()->HandleCommandL( 
       
  7229 									EPtiCommandGetAutoCompletionTailLength,
       
  7230 									&tailLength ));	
       
  7231 					if(tailLength)
       
  7232 						{					
       
  7233 						RemoveSuggestedAdvanceCompletionL();
       
  7234 						}
       
  7235 	                }	
       
  7236 				}
       
  7237 #endif
       
  7238             if (!iWesternPredictive && iMode == ELatin)
       
  7239                 {
       
  7240                 // It is possible to cause situation (by ill-acting client
       
  7241                 // app) where focus handling goes out of sync and there actually
       
  7242                 // is uncomitted inline edit operation going on in to-be-focused
       
  7243                 // editor. Multitapping mode doesn't like that, so we make sure here
       
  7244                 // that it won't happen.
       
  7245                 CancelInlineEdit();                         
       
  7246                 }             
       
  7247             AdjustCursorTypeForCurrentPosition();
       
  7248             
       
  7249             if (IsCcpuFlagSet(ECcpuStateUncommitWhenFocused))
       
  7250                 {
       
  7251                 // One of the ccpu editing options mode was started from
       
  7252                 // options menu. If there is active predictive word it
       
  7253                 // needs to be deactivated.
       
  7254                 ClearCcpuFlag(ECcpuStateUncommitWhenFocused);               
       
  7255                 DeactivatePredicitveWordAndMoveCursorL();                        
       
  7256                 }
       
  7257 #ifdef RD_SCALABLE_UI_V2                   
       
  7258             RegisterObserver();
       
  7259 #endif // RD_SCALABLE_UI_V2            		
       
  7260             }
       
  7261         else // no FepAwareTextEditor
       
  7262             {
       
  7263 #ifdef RD_SCALABLE_UI_V2
       
  7264             // register to receive TInputCapabilitiesEvent events
       
  7265             if ( SemiFepAwareTextEditor() )
       
  7266                 {
       
  7267                 RegisterObserver();
       
  7268                 TLanguage localLanguage = ELangTest;
       
  7269                 if (GetLocalLanguage( localLanguage ) )
       
  7270                     {
       
  7271                     iLanguageCapabilities.iLocalInputLanguageInUse = ETrue;
       
  7272                     if ( localLanguage != iLanguageCapabilities.iInputLanguageCode )
       
  7273                         {
       
  7274                         ChangeInputLanguageL(localLanguage);
       
  7275                         }
       
  7276                     }
       
  7277                 else if (iLanguageCapabilities.iLocalInputLanguageInUse)
       
  7278                     {
       
  7279                     iLanguageCapabilities.iLocalInputLanguageInUse = EFalse;
       
  7280                     ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
  7281                     }
       
  7282 
       
  7283                 if (IsFlagSet(EFlagNewSharedDataInputLanguage) )
       
  7284                     {
       
  7285                     //Global mode or input language has been changed in general settings
       
  7286                     if ( !iLanguageCapabilities.iLocalInputLanguageInUse)
       
  7287                         {
       
  7288                         ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
  7289                         }
       
  7290                     ClearFlag(EFlagNewSharedDataInputLanguage);
       
  7291                     }
       
  7292                 }
       
  7293 #endif // RD_SCALABLE_UI_V2
       
  7294             // Check for non Edwin derived editors (eg mfne, tel no editor etc)
       
  7295             if (iInputCapabilities.SupportsWesternNumericIntegerPositive() || 
       
  7296                 iInputCapabilities.SupportsWesternNumericIntegerNegative() || 
       
  7297                 iInputCapabilities.SupportsWesternNumericReal() )
       
  7298                 {
       
  7299                 SyncStates(EAknFepStateInitial);
       
  7300                 iPermittedInputModes = EAknEditorNumericInputMode;
       
  7301                 iAknEditorNumericKeymap = EAknEditorNativeKeysNumberModeKeymap;
       
  7302                 iAknEditorFlags = 0;
       
  7303                 iCharWidth = EHalfWidthChar;
       
  7304                 UpdateNumericEditorDigitType();
       
  7305                 
       
  7306                 if ( IsMfneEditor() ) 
       
  7307                     {
       
  7308                     UpdateLocalDigitMode();
       
  7309                     }
       
  7310                 
       
  7311                 if( IsInputModeAvailable(ENativeNumber) &&
       
  7312                     ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ||
       
  7313                       iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic ||
       
  7314                       iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ) )
       
  7315                     {
       
  7316                     TryChangeModeL( ENativeNumber );
       
  7317                     }
       
  7318                 else
       
  7319                     {
       
  7320                     TryChangeModeL( ENumber );
       
  7321                     }
       
  7322                 }
       
  7323             else //we don't have a valid editor
       
  7324                 {
       
  7325                 SyncStates(EAknFepStateNull);
       
  7326                 
       
  7327                 // Reset the qwerty shift case mode when we do not have a valis editor.
       
  7328                 ClearFlag(IsFlagSet( EFlagQwertyShiftMode ));
       
  7329                 if (!IsFlagSet(EFlagForegroundUIComponentVisible | EFlagMenuPaneVisible) &&
       
  7330                     iIndicator)
       
  7331                     {
       
  7332                     iIndicator->SetState(EStateNone);
       
  7333                     iHybridAplphaChangedToAlphanumeric = EFalse; 
       
  7334                     }
       
  7335                 ClearFlag(EFlagForegroundUIComponentVisible);
       
  7336                 iPermittedInputModes = EAknEditorNullInputMode;
       
  7337                 
       
  7338 #ifdef RD_SCALABLE_UI_V2                
       
  7339                 RegisterObserver();               
       
  7340 #endif // RD_SCALABLE_UI_V2                      
       
  7341                 }            
       
  7342             }
       
  7343         }
       
  7344     else if (Japanese() && iFepManState == EAknFepStateUIActive)
       
  7345         {
       
  7346         if (iInputCapabilities.FepAwareTextEditor())
       
  7347             {
       
  7348             TryCloseUiL();
       
  7349             }
       
  7350         }
       
  7351     
       
  7352 #ifdef RD_SCALABLE_UI_V2
       
  7353         {
       
  7354         /*
       
  7355         if( iGainForeground )
       
  7356             {
       
  7357             iLoseForeAndGainFocus = EFalse;
       
  7358             }
       
  7359         else
       
  7360             {
       
  7361             iLoseForeAndGainFocus = ETrue;
       
  7362             }
       
  7363         SendEventsToPluginManL( EPluginFocusChanged, iGainForeground );
       
  7364         */
       
  7365         CCoeControl* focusCtrl = static_cast<const CCoeAppUi*>(CCoeEnv::Static()->AppUi())->TopFocusedControl();         
       
  7366        CAknAppUi* aui = static_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
       
  7367        TBool bForeGround = aui->IsForeground();
       
  7368        if(iGainForeground && ! bForeGround)
       
  7369         {
       
  7370         iGainForeground = EFalse;
       
  7371         }
       
  7372         
       
  7373         if(iGainForeground && iNotifyPlugin)
       
  7374             {            
       
  7375             SendEventsToPluginManL( EPluginFocusChanged, 
       
  7376                                     iGainForeground && focusCtrl!=0 && focusCtrl->IsFocused());        
       
  7377             }
       
  7378         iNotifyPlugin = ETrue;
       
  7379         }
       
  7380 #endif // RD_SCALABLE_UI_V2
       
  7381         if( PtiEngine() && FepAwareTextEditor() )
       
  7382             {
       
  7383             if( FepAwareTextEditor()->DocumentLengthForFep() == 0 &&
       
  7384                 IsFlagSet(EFlagInsideInlineEditingTransaction)&&
       
  7385                 iFepManState == EAknFepStateUIActive )
       
  7386               {
       
  7387               PtiEngine()->ClearCurrentWord();                
       
  7388               TryCloseUiL();                
       
  7389               }
       
  7390             }
       
  7391 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  7392     // Predictive QWERTY (XT9) changes ---->
       
  7393     ShowExactWordPopupIfNecessaryL();
       
  7394     // Predictive QWERTY (XT9) changes <----
       
  7395 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  7396     }
       
  7397 
       
  7398 void CAknFepManager::CleanUpFep()
       
  7399     {
       
  7400     if (iFepFullyConstructed)
       
  7401         {
       
  7402         CancelAllTimerActivity();
       
  7403         iInputCapabilities.FepAwareTextEditor()->CancelFepInlineEdit();
       
  7404         }
       
  7405     else
       
  7406         {
       
  7407         CommonDestroyFep();
       
  7408         }
       
  7409     }
       
  7410 
       
  7411 #ifdef RD_SCALABLE_UI_V2
       
  7412 void CAknFepManager::UnregisterObserver()
       
  7413     {
       
  7414 
       
  7415 		MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
  7416     
       
  7417     	if ( mop )
       
  7418     		{
       
  7419     		CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
  7420     		mop->MopGetObject( extendedInputCapabilities );
       
  7421 
       
  7422     		if ( extendedInputCapabilities ) 
       
  7423     			{
       
  7424     			extendedInputCapabilities->UnregisterObserver( this );
       
  7425     			}
       
  7426     		}
       
  7427     }
       
  7428 
       
  7429 void CAknFepManager::RegisterObserver()
       
  7430     {
       
  7431 
       
  7432 	MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
  7433 
       
  7434 	if ( mop )
       
  7435 		{
       
  7436 		CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
  7437 		mop->MopGetObject( extendedInputCapabilities );
       
  7438 
       
  7439 		if ( extendedInputCapabilities ) 
       
  7440 			{
       
  7441 			extendedInputCapabilities->RegisterObserver( this );
       
  7442 			}
       
  7443 		}
       
  7444     }    
       
  7445  
       
  7446 #endif // RD_SCALABLE_UI_V2    
       
  7447     
       
  7448 void CAknFepManager::SimulateKeyEventL(TUint aKeyCode, TBool aActiveObj)
       
  7449     {
       
  7450     if (aActiveObj)
       
  7451         {
       
  7452         iSimulateKey = aKeyCode;
       
  7453         iAsyncOwnSimulateKey.CallBack();
       
  7454         }
       
  7455     else
       
  7456         {
       
  7457         CArrayFix<TUint>* simCharArray = new(ELeave) CArrayFixFlat<TUint>(1);
       
  7458         CleanupStack::PushL(simCharArray);
       
  7459         simCharArray->AppendL(aKeyCode);
       
  7460         SimulateKeyEventsL(simCharArray->Array());
       
  7461         CleanupStack::PopAndDestroy(); // simCharArray
       
  7462         }
       
  7463     }
       
  7464 
       
  7465 TInt CAknFepManager::ResetShiftKeyMonitorCallback(TAny* aObj)
       
  7466     {
       
  7467     TRAPD(err, static_cast<CAknFepManager*>(aObj)->ResetShiftKeyMonitorL());
       
  7468     if (err)
       
  7469         {
       
  7470         static_cast<CAknFepManager*>(aObj)->CleanUpFep();
       
  7471         return KErrDied;
       
  7472         }
       
  7473     return KErrNone;
       
  7474     }
       
  7475 
       
  7476 void CAknFepManager::ResetShiftKeyMonitorL()
       
  7477     {
       
  7478     TBool phoneIdle = (EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor); 
       
  7479     if(phoneIdle)
       
  7480     	{
       
  7481     	iShiftKeypressMonitor->Cancel();
       
  7482     	return;
       
  7483     	}
       
  7484     
       
  7485     SetFlag(EFlagLongShiftKeyPress);
       
  7486 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__    
       
  7487 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  7488     // Copy-paste with shift+SKs is always available on ITU-T. On QWERTY,
       
  7489     // it's available if activated in the Central Repository.
       
  7490     if ( (!iQwertyInputMode || iSharedDataInterface->ShiftCopyPastingOnQwerty()) && 
       
  7491          !(iAknEditorFlags & EAknEditorFlagFindPane) )
       
  7492 #endif // RD_INTELLIGENT_TEXT_INPUT        
       
  7493 #else    
       
  7494     if (!iQwertyInputMode && !(iAknEditorFlags & EAknEditorFlagFindPane))
       
  7495 #endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
  7496         {
       
  7497         if (HashKeySelectionInUse() && IsCcpuFlagSet(ECcpuStateHashDown)) 
       
  7498             {
       
  7499             SetCcpuFlag(ECcpuStateEdwinInSelectionMode);
       
  7500             iHashKeyMan->SetPreviousSelectionStyleModeL();
       
  7501             }
       
  7502     	if(iCandidatePopup)
       
  7503     		{	// if candidate list is launched and then a long key press of shift key is done, destroy the candidate list first
       
  7504 				iCandidatePopup->AttemptExitL(EFalse);
       
  7505 				HandleChangeInFocusL();
       
  7506     		}
       
  7507         if(!IsCcpuFlagSet(ECcpuStateCbaShown))
       
  7508 			{       
       
  7509 	        TKeyEvent ccpuStart = {EKeyF21, EStdKeyF21, 0, 0};
       
  7510     	    // to enable copy/paste support on cba. We simulate via CCoeEnv
       
  7511         	// to avoid fep SimulateKeyEventL adding shift modifiers
       
  7512 	        CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKey);
       
  7513 			SetCcpuFlag(ECcpuStateCbaShown);
       
  7514 			}
       
  7515         }
       
  7516 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  7517 #ifdef __HALF_QWERTY_KEYPAD   
       
  7518 	// we should not enter the copy-paste mode in find pane editors
       
  7519     if( EPtiKeyboardHalfQwerty == KeyboardLayout() && !(iAknEditorFlags & EAknEditorFlagFindPane))
       
  7520         {
       
  7521         CAknFepFnKeyManager::TFnKeyState fnState = FnKeyState();
       
  7522         
       
  7523         if( CAknFepFnKeyManager::EFnKeyNone != fnState 
       
  7524         		|| iFnCharInsertedForShift )
       
  7525             {
       
  7526             TText prevCh = PreviousChar();
       
  7527             if (prevCh == '#' || prevCh == '/')
       
  7528                 {
       
  7529                 RemovePreviousCharacterL();             
       
  7530                 }
       
  7531             // reset the fn state if it is FnNext
       
  7532             if( fnState == CAknFepFnKeyManager::EFnKeyNext )
       
  7533                 {
       
  7534                 SetFnKeyState( CAknFepFnKeyManager::EFnKeyNone );
       
  7535                 }
       
  7536             }
       
  7537         SetCcpuFlag( CAknFepManager::ECcpuStateEdwinInSelectionMode );
       
  7538         if(!IsCcpuFlagSet(ECcpuStateCbaShown))
       
  7539             {		
       
  7540 	        TKeyEvent ccpuStart = {EKeyF21, EStdKeyF21, 0, 0};
       
  7541          
       
  7542     	    // to enable copy/paste support on cba. We simulate via CCoeEnv
       
  7543         	// to avoid fep SimulateKeyEventL adding shift modifiers
       
  7544         	CCoeEnv::Static()->SimulateKeyEventL(ccpuStart, EEventKey);    
       
  7545             SetCcpuFlag(ECcpuStateCbaShown); 			                                      
       
  7546 			}
       
  7547         }  
       
  7548 #endif //__HALF_QWERTY_KEYPAD
       
  7549 		          
       
  7550 #endif//RD_INTELLIGENT_TEXT_INPUT        
       
  7551     iShiftKeypressMonitor->Cancel();
       
  7552     }
       
  7553 
       
  7554 void CAknFepManager::CancelAllTimerActivity()
       
  7555     {
       
  7556     if (iShiftKeypressMonitor->IsActive())
       
  7557         {
       
  7558         iShiftKeypressMonitor->Cancel();
       
  7559         }
       
  7560     if (iConcatenationTimer->IsActive())
       
  7561         {
       
  7562         iConcatenationTimer->Cancel();
       
  7563         }
       
  7564     if (iChrKeypressMonitor->IsActive())
       
  7565         {
       
  7566         iChrKeypressMonitor->Cancel();
       
  7567         }
       
  7568     if (iPostEventCheck->IsActive())
       
  7569         {
       
  7570         iPostEventCheck->Cancel();
       
  7571         }
       
  7572     if ( iHashKeyMan )
       
  7573         {
       
  7574         iHashKeyMan->CancelHashKeyTimer();
       
  7575         }
       
  7576 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
  7577     if( iNumericResourceTimer )
       
  7578         {
       
  7579         TRAP_IGNORE( NumericResourceMultiTapTimerTimeoutL());
       
  7580         }
       
  7581 #endif
       
  7582     DeactivateFnkeyPressMonitor();
       
  7583     }
       
  7584 
       
  7585 TBool CAknFepManager::IsModePermitted(TInt aMode, TWidthChar aWidth) const
       
  7586     {
       
  7587     if (aWidth == ENoneWidthChar)
       
  7588         {
       
  7589         aWidth = iCharWidth;
       
  7590         }
       
  7591 
       
  7592     TBool isModePermitted = ETrue;
       
  7593     const TInt inputLanguage = iLanguageCapabilities.iInputLanguageCode;    
       
  7594     
       
  7595     if ( aMode == ENativeNumber && !IsInputModeAvailable( aMode ) )
       
  7596         {
       
  7597         if ( inputLanguage == ELangThai && iFepPluginManager && 
       
  7598                iFepPluginManager->PluginInputMode() != EPluginInputModeItut &&
       
  7599                !iQwertyInputMode)
       
  7600                {
       
  7601                return ETrue;
       
  7602                }        
       
  7603         return EFalse;
       
  7604         }
       
  7605     
       
  7606     TUint editorMode = EditorMode(aMode, aWidth);
       
  7607 
       
  7608     //Support Boxcn default Chinese inputmode when defaul inputmode is Cangjie Hongkong
       
  7609     //only if Chinese input is permitted in the editor
       
  7610     if (!( (iVariantPermittedModes | ELatinText | ELatinUpper | ELatinLower | EHiragana) & aMode) )
       
  7611         {
       
  7612         //the mode is never valid in this variant
       
  7613         isModePermitted = EFalse;
       
  7614         }
       
  7615     else if( aMode == ECangJie && !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))
       
  7616 		{
       
  7617 		if (iQwertyInputMode || iFepPluginManager->PluginInputMode() == EPluginInputModeVkb
       
  7618 				|| iFepPluginManager->PluginInputMode() == EPluginInputModeFSQ)
       
  7619 			{
       
  7620 			isModePermitted = ETrue;
       
  7621 			}
       
  7622 		else
       
  7623 			{
       
  7624 			isModePermitted = EFalse;
       
  7625 			}
       
  7626 		}
       
  7627     else if (!(iPermittedInputModes & editorMode))
       
  7628         {
       
  7629         isModePermitted = EFalse;
       
  7630         }
       
  7631     else if (((aMode == EPinyin) || (aMode == EZhuyin) || (aMode == EStroke) || (aMode == ECangJie)
       
  7632         ||   (aMode == EHiraganaKanji) || (aMode == EKatakana) || ( aMode == EHangul )
       
  7633         || (((aMode == ELatin) || (aMode == ENumber) || iMode == ENativeNumber ) && (iCharWidth == EFullWidthChar)))
       
  7634         && (iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))
       
  7635         {
       
  7636         //the editor does not allow Chinese modes
       
  7637         isModePermitted = EFalse;
       
  7638         }
       
  7639     else if (((aMode == EStrokeFind) || (aMode == EZhuyinFind))
       
  7640         && (!(iAknEditorFlags & EAknEditorFlagForceTransparentFepModes)))
       
  7641         {
       
  7642         //StrokeFind and ZhuyinFind modes are only valid in a chinese find pane
       
  7643         isModePermitted = EFalse;
       
  7644         }
       
  7645     else
       
  7646         {
       
  7647         TUint editorsWhichAllowThisMode;
       
  7648         if (aMode == ENumber || aMode == ENativeNumber )
       
  7649             {
       
  7650             //The FEP's ENumber mode has a direct mapping to EAknEditorNumericInputMode
       
  7651             // or EAknEditorFullWidthNumericInputMode
       
  7652             editorsWhichAllowThisMode = EAknEditorNumericInputMode;
       
  7653             if (aWidth == EFullWidthChar)
       
  7654                 {
       
  7655                 editorsWhichAllowThisMode = EAknEditorFullWidthNumericInputMode;
       
  7656                 }
       
  7657             }
       
  7658         else if (aMode == EHiragana)
       
  7659             {
       
  7660             editorsWhichAllowThisMode = EAknEditorHiraganaInputMode;
       
  7661             }
       
  7662         else if (aMode == EKatakana || (aMode == ELatin && aWidth == EFullWidthChar))
       
  7663             {
       
  7664             editorsWhichAllowThisMode = EditorMode(aMode, aWidth);
       
  7665             }
       
  7666         else if (aMode == EHiraganaKanji)
       
  7667             {
       
  7668             // HiraganaKanji mode allows all input mode.
       
  7669             editorsWhichAllowThisMode = EAknEditorAllInputModes;
       
  7670             }
       
  7671         else if (aMode == EHangul)
       
  7672             {
       
  7673             editorsWhichAllowThisMode =(EAknEditorTextInputMode | EAknEditorSecretAlphaInputMode | EAknEditorHalfWidthTextInputMode);     
       
  7674             }          
       
  7675         else
       
  7676             {
       
  7677             //if the editor allows Text Input or Secret Alpha Mode,
       
  7678             //we infer that Chinese Modes are valid
       
  7679             editorsWhichAllowThisMode =(EAknEditorTextInputMode | 
       
  7680                                         EAknEditorSecretAlphaInputMode | 
       
  7681                                         EAknEditorHalfWidthTextInputMode);
       
  7682             }
       
  7683         isModePermitted = iPermittedInputModes & editorsWhichAllowThisMode;
       
  7684         }
       
  7685 
       
  7686     return isModePermitted;
       
  7687     }
       
  7688 
       
  7689 TInt CAknFepManager::SyncStates(TAknFepManagerState aState)
       
  7690     {
       
  7691     TInt ret = KErrNone;
       
  7692     
       
  7693     if (!iFepFullyConstructed)
       
  7694         {
       
  7695         if (aState == EAknFepStateNull)
       
  7696             {
       
  7697             return KErrNone;
       
  7698             }
       
  7699                        
       
  7700         TRAP(ret, ConstructFullyL());
       
  7701         }
       
  7702     if (iFepFullyConstructed)
       
  7703         {
       
  7704         iFepManState = aState;
       
  7705         iKeyCatcher->SetState(aState);
       
  7706         }
       
  7707    
       
  7708     return ret;    
       
  7709     }
       
  7710 
       
  7711 TUint CAknFepManager::EditorMode(TInt aMode, TWidthChar aWidth) const
       
  7712     {
       
  7713     TInt editorMode = 0;
       
  7714     switch(aMode)
       
  7715         {
       
  7716         case EPinyin:
       
  7717         case EZhuyin:
       
  7718         case EStroke:
       
  7719         case ECangJie:
       
  7720         case EPRCFind:
       
  7721         case EZhuyinFind:
       
  7722         case EStrokeFind:
       
  7723         case EHangul:
       
  7724             {
       
  7725             editorMode = EAknEditorTextInputMode;
       
  7726             }
       
  7727             break;
       
  7728         case EHindi:
       
  7729         case ELatin:
       
  7730         case ELatinText:
       
  7731         case ELatinUpper:
       
  7732         case ELatinLower:
       
  7733             {
       
  7734             if (iPermittedInputModes & EAknEditorTextInputMode)
       
  7735                 {
       
  7736                  editorMode = EAknEditorTextInputMode;
       
  7737                 }
       
  7738             else if (iPermittedInputModes & EAknEditorHalfWidthTextInputMode)
       
  7739                 {
       
  7740                 if (IsFeatureSupportedJapanese())
       
  7741                     {
       
  7742                     editorMode = EAknEditorHalfWidthTextInputMode;
       
  7743                     }
       
  7744                 else
       
  7745                     {
       
  7746                     editorMode = EAknEditorTextInputMode;
       
  7747                     }
       
  7748                 }
       
  7749             else
       
  7750                 {
       
  7751                 editorMode = EAknEditorSecretAlphaInputMode;
       
  7752                 }
       
  7753             if (aWidth == EFullWidthChar)
       
  7754                 {
       
  7755                 editorMode = EAknEditorFullWidthTextInputMode;
       
  7756                 }
       
  7757             }
       
  7758             break;
       
  7759         case EHiragana:
       
  7760             {
       
  7761             editorMode = EAknEditorHiraganaInputMode;
       
  7762             }
       
  7763             break;
       
  7764         case EHiraganaKanji:
       
  7765             {
       
  7766             editorMode = EAknEditorHiraganaKanjiInputMode;
       
  7767             }
       
  7768             break;
       
  7769         case EKatakana:
       
  7770             {
       
  7771             editorMode = EAknEditorKatakanaInputMode;
       
  7772             if (aWidth == EFullWidthChar)
       
  7773                 {
       
  7774                 editorMode = EAknEditorFullWidthKatakanaInputMode;
       
  7775                 }
       
  7776             }
       
  7777             break;
       
  7778         case ENumber:
       
  7779         case ENativeNumber:
       
  7780             {
       
  7781             editorMode = EAknEditorNumericInputMode;
       
  7782             if (aWidth == EFullWidthChar)
       
  7783                 {
       
  7784                 editorMode = EAknEditorFullWidthNumericInputMode;
       
  7785                 }
       
  7786             }
       
  7787             break;
       
  7788         default:
       
  7789             break;
       
  7790         }
       
  7791 
       
  7792     return editorMode;
       
  7793     }
       
  7794 
       
  7795 void CAknFepManager::LaunchPenSupportMenuL()
       
  7796     {
       
  7797     if (HashKeySelectionInUse() && IsCcpuFlagSet(ECcpuStateHashDown))
       
  7798         {
       
  7799         return;
       
  7800         }
       
  7801 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  7802 	if(iCandidatePopup)        
       
  7803 		{
       
  7804 		iCandidatePopup->AttemptExitL(EFalse);
       
  7805 		HandleChangeInFocusL();
       
  7806 		}
       
  7807 #endif		
       
  7808     
       
  7809     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  7810         {
       
  7811         TryRemoveNoMatchesIndicatorL();
       
  7812 		/*
       
  7813 	    This code is the part of fixing TSW Error Edit Menu : 
       
  7814 	    "Matches" and "insert word" options are not available under Edit Menu.
       
  7815 	    When we launch Edit Menu.the word which in Inline Editing in the BackGorund 
       
  7816 	    Should not Commit*/        
       
  7817 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  7818         CommitInlineEditL();
       
  7819 #endif
       
  7820 		/*
       
  7821 	    This code is the part of fixing TSW ErrorEdit Menu : 
       
  7822 	    "Matches" and "insert word" options are not available under Edit Menu.
       
  7823 	    This Flag is useful for deciding whether "Matches" Menu Item can Visible 
       
  7824 	    or not*/
       
  7825 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
  7826         SetFlag(EFlagInlineEditInBackground);
       
  7827 #endif
       
  7828 		/*
       
  7829 	    This code is the part of fixing TSW Error  Edit Menu : 
       
  7830 	    "Matches" and "insert word" options are not available under Edit Menu.*/
       
  7831 #ifndef RD_INTELLIGENT_TEXT_INPUT        
       
  7832         ClearFlag(EFlagInsideInlineEditingTransaction);
       
  7833 #endif        
       
  7834         }
       
  7835     
       
  7836     CAknEdwinState* editorState = NULL;
       
  7837     if (iInputCapabilities.FepAwareTextEditor())
       
  7838         {
       
  7839         editorState = EditorState();
       
  7840         }
       
  7841     
       
  7842     iEditMenuBar = NULL;
       
  7843     if (editorState)
       
  7844         {
       
  7845         iEditMenuBar = iUiInterface->EditorStateMenuBar(editorState);
       
  7846         }
       
  7847     
       
  7848     if (iEditMenuBar && 
       
  7849         !iEditMenuBar->IsDisplayed())
       
  7850         {
       
  7851         
       
  7852         iPenSupportMenu = ETrue;
       
  7853        // SetFlag(EFlagLaunchEditMenu);
       
  7854         CAknFepUiInterfaceMenuPane* menuPane = iEditMenuBar->MenuPane();
       
  7855         
       
  7856         CEikMenuPane* oldMenuPane = menuPane->GetMenuPane();        
       
  7857         if (!oldMenuPane)
       
  7858             {
       
  7859             menuPane = NULL;    
       
  7860             }
       
  7861         
       
  7862         iRememberEditorState = EditorState();
       
  7863   
       
  7864         iEditMenuBar->SetMenuType(CAknFepUiInterfaceMenuBar::EMenuEdit);        
       
  7865         // It is unnecessary to add ROW SCT in Editting option menu.
       
  7866         iEditMenuBar->TryDisplayMenuBarL();
       
  7867         if (menuPane && menuPane->NumberOfItemsInPane() == 0)
       
  7868             {
       
  7869             // Edit menu do not contain any items.
       
  7870             iEditMenuBar->StopDisplayingMenuBar();
       
  7871             }
       
  7872         else
       
  7873             {
       
  7874             //adjust menu position to the front of dialog to
       
  7875             //avoid input capability is wrongly got
       
  7876             CCoeEnv* coeEnv = CCoeEnv::Static();
       
  7877             CCoeAppUi* appUi = (CCoeAppUi*)(coeEnv->AppUi());
       
  7878             if( appUi->IsDisplayingDialog() )
       
  7879                 {
       
  7880                 iEditMenuBar->RemoveFromStack();
       
  7881                 iEditMenuBar->AddToStackL(ECoeStackPriorityDialog + 1, ECoeStackFlagStandard);                              
       
  7882                 }
       
  7883             }
       
  7884             
       
  7885         iEditMenuBar->SetMenuType(CAknFepUiInterfaceMenuBar::EMenuOptions);
       
  7886         }
       
  7887         iPenSupportMenu = EFalse;
       
  7888     }
       
  7889 
       
  7890 void CAknFepManager::LaunchSelectModeMenuL()
       
  7891     {
       
  7892     if (HashKeySelectionInUse() && IsCcpuFlagSet(ECcpuStateHashDown))
       
  7893         {
       
  7894         return;
       
  7895         }
       
  7896 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  7897 	if(iCandidatePopup)        
       
  7898 		{
       
  7899 		iCandidatePopup->AttemptExitL(EFalse);
       
  7900 		HandleChangeInFocusL();
       
  7901 		}
       
  7902 #endif		
       
  7903     
       
  7904     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  7905         {
       
  7906         TryRemoveNoMatchesIndicatorL();
       
  7907 		/*
       
  7908 	    This code is the part of fixing TSW Error :  Edit Menu : 
       
  7909 	    "Matches" and "insert word" options are not available under Edit Menu.
       
  7910 	    When we launch Edit Menu.the word which in Inline Editing in the BackGorund 
       
  7911 	    Should not Commit*/        
       
  7912 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  7913         CommitInlineEditL();
       
  7914 #endif
       
  7915 		/*
       
  7916 	    This code is the part of fixing TSW Error :  Edit Menu : 
       
  7917 	    "Matches" and "insert word" options are not available under Edit Menu.
       
  7918 	    This Flag is useful for deciding whether "Matches" Menu Item can Visible 
       
  7919 	    or not*/
       
  7920 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
  7921         SetFlag(EFlagInlineEditInBackground);
       
  7922 #endif
       
  7923 		/*
       
  7924 	    This code is the part of fixing TSW Error :  Edit Menu : 
       
  7925 	    "Matches" and "insert word" options are not available under Edit Menu.*/
       
  7926 #ifndef RD_INTELLIGENT_TEXT_INPUT        
       
  7927         ClearFlag(EFlagInsideInlineEditingTransaction);
       
  7928 #endif        
       
  7929         }
       
  7930     
       
  7931     CAknEdwinState* editorState = NULL;
       
  7932     if (iInputCapabilities.FepAwareTextEditor())
       
  7933         {
       
  7934         editorState = EditorState();
       
  7935         }
       
  7936     
       
  7937     iEditMenuBar = NULL;
       
  7938     if (editorState)
       
  7939         {
       
  7940         iEditMenuBar = iUiInterface->EditorStateMenuBar(editorState);
       
  7941         }
       
  7942     
       
  7943     if (iEditMenuBar && 
       
  7944         !iEditMenuBar->IsDisplayed())
       
  7945         {
       
  7946        // SetFlag(EFlagLaunchEditMenu);
       
  7947         CAknFepUiInterfaceMenuPane* menuPane = iEditMenuBar->MenuPane();
       
  7948         CEikMenuPane* oldMenuPane = menuPane->GetMenuPane();        
       
  7949         if (!oldMenuPane)
       
  7950             {
       
  7951             menuPane = NULL;    
       
  7952             }        
       
  7953          if(menuPane)
       
  7954         	SetFlag(EFlagLaunchEditMenu);
       
  7955         
       
  7956         iRememberEditorState = EditorState();
       
  7957         
       
  7958         // It is unnecessary to add ROW SCT in Editting option menu.
       
  7959         if (!IsFeatureSupportedJapanese())
       
  7960             {
       
  7961             iEditCharsPtr.Copy(KNullDesC);
       
  7962             iEditCharsPtr.Set( iSctEditChars->Des() );
       
  7963             
       
  7964             // get the SCT resource id from editor default settings
       
  7965             TInt currentEditorSCTResId = GetCurrentEditorSCTResId();
       
  7966             TInt charResourceId = ENoCharacters;
       
  7967             if ( currentEditorSCTResId == EDefaultNumericCharMapResId)
       
  7968                 {
       
  7969                 charResourceId = NumericModeSCTResourceId();
       
  7970                 if ( charResourceId != ENoCharacters && IsAbleToLaunchSCT()&& 
       
  7971                         EditorType() != CAknExtendedInputCapabilities::EEikSecretEditorBased)
       
  7972                     {
       
  7973                     
       
  7974                     if( menuPane != NULL )
       
  7975                         {
       
  7976                         menuPane->ConstructMenuSctRowL( iEditCharsPtr, charResourceId );
       
  7977                         }
       
  7978                     }
       
  7979                 else
       
  7980                     {
       
  7981                     currentEditorSCTResId = charResourceId;
       
  7982                     }   
       
  7983                 }
       
  7984             else
       
  7985                 {
       
  7986                 TInt sctChars = EAknSCTChiChineseInputModes;
       
  7987                 if (iCharWidth == EFullWidthChar)
       
  7988                     {
       
  7989                     sctChars = EAknSCTFullCase;
       
  7990                     }
       
  7991                 else
       
  7992                     {
       
  7993                     if (iMode == ELatin)
       
  7994                         {
       
  7995                         if ( FeatureManager::FeatureSupported(KFeatureIdChinese) )
       
  7996                             {
       
  7997                             sctChars = EAknSCTChiLatinInputModes;
       
  7998                             }
       
  7999                         else
       
  8000                             {
       
  8001                             if (iQwertyInputMode)
       
  8002                                 {
       
  8003                                 sctChars = EAknSCTQwerty;
       
  8004                                 }
       
  8005                             else
       
  8006                                 {
       
  8007                                 sctChars = EAknSCTUpperCase;
       
  8008                                 if (iCaseMan->CurrentCase() == EAknEditorLowerCase)
       
  8009                                     {
       
  8010                                     sctChars = EAknSCTLowerCase;
       
  8011                                     }
       
  8012                                 }
       
  8013                             }
       
  8014                         }
       
  8015                     else if (iMode == ENumber || iMode == ENativeNumber)
       
  8016                         {
       
  8017                         sctChars = EAknSCTNumeric;
       
  8018                         if ( ((iAknEditorFlags & EAknEditorFlagUseSCTNumericCharmap) ||
       
  8019                             (iAknEditorNumericKeymap == EAknEditorAlphanumericNumberModeKeymap)) &&
       
  8020                             !IsOnlyHalfWidthCharacterPermitted() )
       
  8021                             {
       
  8022                             sctChars = EAknSCTLowerCase;
       
  8023                             }
       
  8024                         }
       
  8025                     //delete for phrase creation
       
  8026 //                    else if (iMode == EStroke && iFepManState == EAknFepStateUIActive)
       
  8027 //                    	{
       
  8028 //                    	return;
       
  8029 //                    	}
       
  8030                     else if (iMode == EHiraganaKanji)
       
  8031                         {
       
  8032                         sctChars = EAknSCTFullCase;
       
  8033                         }
       
  8034                     else if(iMode == EKatakana)
       
  8035                         {
       
  8036                         sctChars = EAknSCTHalfCase;
       
  8037                         }
       
  8038                     }
       
  8039                     
       
  8040                 if (!(ExtendedInputCapabilities() & CAknExtendedInputCapabilities::EDisableSCT))                    
       
  8041                     {
       
  8042                     if( menuPane && (EditorType() != CAknExtendedInputCapabilities::EEikSecretEditorBased))
       
  8043                         {
       
  8044                         if(IsAbleToLaunchSmiley())
       
  8045                             {
       
  8046                             sctChars |= EAknCharMapEmotionUse;
       
  8047                             }
       
  8048                         
       
  8049                         menuPane->ConstructMenuSctRowFromDialogL( sctChars, iEditCharsPtr, 
       
  8050                                                                   currentEditorSCTResId );                    
       
  8051                         }
       
  8052                     }
       
  8053                 }
       
  8054             }
       
  8055             iEditMenuBar->SetMenuType(CAknFepUiInterfaceMenuBar::EMenuEdit);
       
  8056             iFepPluginManager->SetMenuState( ETrue ); 
       
  8057             iEditMenuBar->TryDisplayMenuBarL();
       
  8058             if (menuPane && menuPane->NumberOfItemsInPane() == 0)
       
  8059                 {
       
  8060                 // Edit menu do not contain any items.
       
  8061                 iEditMenuBar->StopDisplayingMenuBar();
       
  8062                 iFepPluginManager->ResetMenuState( ETrue );
       
  8063                 }
       
  8064             else
       
  8065                 {
       
  8066                 //adjust menu position to the front of dialog to
       
  8067                 //avoid input capability is wrongly got
       
  8068                 CCoeEnv* coeEnv = CCoeEnv::Static();
       
  8069                 CCoeAppUi* appUi = (CCoeAppUi*)(coeEnv->AppUi());
       
  8070                 if( appUi->IsDisplayingDialog() )
       
  8071                     {
       
  8072                     iEditMenuBar->RemoveFromStack();
       
  8073                     // Set the MenuBar not focused, the later add to stack operation could unfocus other control correctly
       
  8074                     iEditMenuBar->SetFocus(EFalse);
       
  8075                     iEditMenuBar->AddToStackL(ECoeStackPriorityDialog + 1, ECoeStackFlagStandard);                              
       
  8076                     }
       
  8077                 }
       
  8078                 
       
  8079             iEditMenuBar->SetMenuType(CAknFepUiInterfaceMenuBar::EMenuOptions);
       
  8080         }
       
  8081     }
       
  8082 
       
  8083 void CAknFepManager::LaunchMatchesPopupListL()
       
  8084     {
       
  8085     TInt noOfMatches = iPtiEngine->NumberOfCandidates();
       
  8086     if (noOfMatches > 1)    // 1 => only current match available, 0 => not in inline edit
       
  8087         {
       
  8088         // Create a list to pass to the dialog
       
  8089         CDesCArrayFlat* matchesList=new(ELeave)CDesCArrayFlat(1);
       
  8090         CleanupStack::PushL(matchesList);
       
  8091         iPtiEngine->GetCandidateListL(*matchesList);
       
  8092         TBuf<EMaximumFepWordLength> matchListDesc;
       
  8093         TInt matchListItemCount = matchesList->MdcaCount();
       
  8094         TInt currentIndex = ResolveCurrentCandidateListIndex(matchesList);      
       
  8095         for ( TInt ii=0; ii < matchListItemCount ; ii++)
       
  8096             {   
       
  8097             matchListDesc = matchesList->MdcaPoint(ii);
       
  8098             TChar tempChar = matchListDesc[0];
       
  8099             if(tempChar.IsDigit())
       
  8100                 {
       
  8101                 AknTextUtils::ConvertDigitsTo(matchListDesc,iLanguageCapabilities.iLocalDigitType);
       
  8102                 matchesList->Delete(ii);
       
  8103                 matchesList->InsertL(ii,matchListDesc);
       
  8104                 }
       
  8105             }
       
  8106 
       
  8107         // add 'Spell' to the bottom of the list
       
  8108         TResourceReader reader;
       
  8109         CCoeEnv* coeEnv = CCoeEnv::Static();
       
  8110         coeEnv->CreateResourceReaderLC(reader, R_AVKON_T9_MATCHES_QUERY_SPELL_ITEM);
       
  8111         matchesList->AppendL(reader.ReadTPtrC());
       
  8112         CleanupStack::PopAndDestroy(); // reader
       
  8113 
       
  8114         TInt index = 0;
       
  8115         SetFlag(EFlagForegroundUIComponentVisible);
       
  8116 
       
  8117         TUid fepUid = CCoeEnv::Static()->FepUid();
       
  8118         ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  8119 		SendEventsToPluginManL(EPluginEnablePriorityChangeOnOriChange,EFalse);
       
  8120         // Fire up the dialog
       
  8121 		iMatchesListLaunched = ETrue;
       
  8122         TInt returnValue = iUiInterface->LaunchListPopupL(R_AVKON_T9_MATCHES_QUERY, index, 
       
  8123                                                           currentIndex, matchesList, NULL);
       
  8124         iMatchesListLaunched = EFalse;
       
  8125         PrepareFepAfterDialogExitL(fepUid);
       
  8126 		SendEventsToPluginManL(EPluginEnablePriorityChangeOnOriChange,ETrue);
       
  8127         if(returnValue == EAknSoftkeyOk)
       
  8128             {// Selected item 'index' from the matches array
       
  8129             HandleChangeInFocusL();
       
  8130             TBuf<EMaximumFepWordLength> newText;
       
  8131             // Get current match from editor and show it as a default text in 'insert word' query.
       
  8132             iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(newText, 
       
  8133                              iUncommittedText.iAnchorPos, iUncommittedText.Length());
       
  8134             
       
  8135             if (index==noOfMatches) // => 'spell' item at the bottom of the list
       
  8136                 {
       
  8137                 LaunchInsertWordQueryL(newText, iUncommittedText);
       
  8138                 #ifdef RD_SCALABLE_UI_V2
       
  8139                 if( iFepFullyConstructed && iFepPluginManager )
       
  8140                     {
       
  8141                     iFepPluginManager->ResetMenuState();
       
  8142                     }
       
  8143                 #endif
       
  8144                 }
       
  8145             else
       
  8146                 { // insert word at index into text
       
  8147                 TBuf<EMaximumFepWordLength> modifiedMatch;                
       
  8148                 modifiedMatch.Copy(matchesList->MdcaPoint(index));
       
  8149                 TChar first(newText[0]);
       
  8150                 if (first.IsUpper())
       
  8151                     {
       
  8152                     TChar converted(modifiedMatch[0]);
       
  8153                     converted.UpperCase();
       
  8154                     modifiedMatch[0] = converted;
       
  8155                     }
       
  8156                 InsertTextFromDialogL(modifiedMatch, iUncommittedText);
       
  8157                 }
       
  8158             }
       
  8159         CleanupStack::PopAndDestroy(); // matchesList
       
  8160         }
       
  8161     }
       
  8162 
       
  8163 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  8164 // Predictive QWERTY (XT9) changes ---->
       
  8165 void CAknFepManager::LaunchCandidatePopupListL( TInt aFocusedIndex )
       
  8166     {
       
  8167     iKeyBackSpaceHit = 1;
       
  8168     //CPtiEngine* ptiEngine = iPtiEngine;
       
  8169     
       
  8170     // Addition for ITI features on FSQ.
       
  8171     // Before open candidate list, if FSQ is opened, 
       
  8172     // also need to check and close tooltip on it.
       
  8173     SendEventsToPluginManL( EPluginHideTooltip );
       
  8174     
       
  8175     // Before open candidate list, if touch ui is opened, 
       
  8176     // also need to close touch ui firstly.
       
  8177     if ( iFepPluginManager->PluginInputMode() != EPluginInputModeNone )
       
  8178         {
       
  8179         iFepPluginManager->ClosePluginInputUiL( ETrue );
       
  8180         }              
       
  8181 
       
  8182     iExactWordPopupContent->HidePopUp();
       
  8183         
       
  8184     TBool isShiftKeyDepressedAfterCandidateListLaunched = EFalse;
       
  8185     // Retrieve active index for QWERTY keypad when Best Prediction is Set
       
  8186     TInt activeIndex = KErrNotFound;
       
  8187                 
       
  8188     if(iPrimaryCandidate && IsQwerty() && ( KeyboardLayout() != EPtiKeyboardHalfQwerty))
       
  8189         {           
       
  8190         iPtiEngine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, &activeIndex );        
       
  8191         }
       
  8192             
       
  8193     TInt noOfMatches = iPtiEngine->NumberOfCandidates();
       
  8194     if (noOfMatches > 0)
       
  8195         {
       
  8196         //! The compact candidate popup that opens with when arrow down pressed while inline editing
       
  8197         //MAknFepCandidatePopup *candidatePopup;
       
  8198         
       
  8199         //Predictive QWERTY (XT9) changes for new Architecture ---->
       
  8200         iCandidatePopup = UiInterface()->NewCandidatePopupL(*this);
       
  8201         //Predictive QWERTY (XT9) changes for new Architecture <----
       
  8202             
       
  8203         // Determine the place where to spawn the candidate popup.
       
  8204         TPoint  inlineEditorTl;
       
  8205         TPoint  inlineEditorBr;
       
  8206         TInt    height;
       
  8207         TInt    ascent;
       
  8208         TInt    documentOffset = iPtiEngine->CurrentWord().Length();
       
  8209         
       
  8210         //  Popup Position was not right for RTL ---->
       
  8211         if(iLanguageCapabilities.iRightToLeftLanguage)
       
  8212         	documentOffset = 0;
       
  8213         //  Popup Position was not right for RTL <----
       
  8214         GetScreenCoordinatesL(inlineEditorTl, height, ascent, documentOffset);
       
  8215         
       
  8216         inlineEditorTl.iY -= height;
       
  8217         GetScreenCoordinatesL(inlineEditorBr, height, ascent);
       
  8218         
       
  8219         // Focus next word in list ---->
       
  8220         // To fix the bug Candidate list opens with the highlight on 3rd candidate when Exact typing is use.
       
  8221         // Show the popup.
       
  8222         TInt selectedIdx = aFocusedIndex;
       
  8223         TKeyEvent lastKeyEvent;
       
  8224         
       
  8225         if(selectedIdx == KErrNotFound)
       
  8226             {
       
  8227             if (noOfMatches > 1)
       
  8228                 {
       
  8229                 selectedIdx = KWordToFocusInCandidateList;
       
  8230                 }
       
  8231             // Focus next word in list <----
       
  8232             if(iSListLaunchedFromMenu)
       
  8233                 {
       
  8234                 iPtiEngine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, &selectedIdx );
       
  8235                 iSListLaunchedFromMenu = EFalse;
       
  8236                 }
       
  8237             }
       
  8238         TUid fepUid = CCoeEnv::Static()->FepUid();
       
  8239         ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  8240         TInt popupCmd = iCandidatePopup->ExecutePopupL( TRect(inlineEditorTl, inlineEditorBr),
       
  8241                                                         selectedIdx, lastKeyEvent, iLanguageCapabilities.iRightToLeftLanguage,
       
  8242                                                         (TInt)KeyboardLayout() );
       
  8243         PrepareFepAfterDialogExitL(fepUid);      
       
  8244         
       
  8245         if((lastKeyEvent.iScanCode == EStdKeyDevice3 ) || 
       
  8246         		((lastKeyEvent.iScanCode == KAknFEPZeroKey)&& ((KeyboardLayout()== EPtiKeyboard12Key)||(KeyboardLayout()==EPtiKeyboardHalfQwerty))) 
       
  8247         		|| lastKeyEvent.iCode == EKeySpace )
       
  8248         	{
       
  8249         	SetExtendedFlag(EExtendedFlagOkKeyPressOnCandidatePopup);
       
  8250         	}
       
  8251        
       
  8252      
       
  8253         TBool needToExecute(EFalse);        
       
  8254         //The candidate list was closed by long key press of shift key
       
  8255         isShiftKeyDepressedAfterCandidateListLaunched = IsFlagSet(EFlagShiftKeyDepressed) && (KeyboardLayout()== EPtiKeyboard12Key);
       
  8256         if (popupCmd != EAknSoftkeyCancel)
       
  8257             {
       
  8258             HandleChangeInFocusL();
       
  8259                               
       
  8260             if (popupCmd == EAknFepSoftkeySpell)
       
  8261                 {                               
       
  8262                 // For QWERTY Input Mode
       
  8263                 if (iQwertyInputMode && EPtiKeyboardHalfQwerty != iKeyboardType) 
       
  8264                     {   
       
  8265                     TInt activeIdx = KErrNotFound;
       
  8266                     TInt secondaryIdx = KErrNotFound;
       
  8267                                     
       
  8268                     iPtiEngine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates, 
       
  8269                                                 &activeIdx );
       
  8270                     iPtiEngine->HandleCommandL( EPtiCommandUserActionGetIndexOfSecondaryCandidate, 
       
  8271                                                 &secondaryIdx );
       
  8272                     
       
  8273                     if(activeIdx != secondaryIdx)
       
  8274                         {                        
       
  8275                         iPtiEngine->HandleCommandL( 
       
  8276                                  EPtiCommandUserActionSetCurrentIndexOfCandidates, &secondaryIdx );                         
       
  8277                         }
       
  8278                     else
       
  8279                         {
       
  8280                         secondaryIdx = 0;
       
  8281                         iPtiEngine->HandleCommandL( 
       
  8282                                  EPtiCommandUserActionSetCurrentIndexOfCandidates, &secondaryIdx );  
       
  8283                         }
       
  8284                     TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  8285                     if(!IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8286                         {
       
  8287                         StartInlineEditingWithSelectedWord(selectedWord);
       
  8288                         }
       
  8289                     UpdateInlineEditL( selectedWord, selectedWord.Length() );
       
  8290                         
       
  8291                     } 
       
  8292                 // For ITUT Keypad, remove autocompletion part before launching Query Dialog
       
  8293                 else
       
  8294                     {
       
  8295                     RemoveSuggestedAdvanceCompletionL();
       
  8296                     }
       
  8297                 
       
  8298                 // delete the candidate popup before launching the edit word dialog
       
  8299                 // as the candidate list has already been closed.
       
  8300                 if(iCandidatePopup)
       
  8301                     {
       
  8302                     delete iCandidatePopup;
       
  8303                     iCandidatePopup = NULL;
       
  8304                     }
       
  8305                 
       
  8306                 LaunchEditWordQueryL(); 
       
  8307                 }           
       
  8308             
       
  8309             // Close with space or selection key: Commit and add space or move cursor ahead one
       
  8310             // character if next character already is space
       
  8311             else if ( ( lastKeyEvent.iScanCode == EStdKeyDevice3 || lastKeyEvent.iScanCode == KAknFEPZeroKey )
       
  8312             		 && ( KeyboardLayout() == EPtiKeyboard12Key || KeyboardLayout() == EPtiKeyboardHalfQwerty ) )
       
  8313                 {
       
  8314                 iPtiEngine->HandleCommandL( EPtiCommandUserActionSetCurrentIndexOfCandidates, 
       
  8315                                             &selectedIdx ); 
       
  8316                 TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  8317                 if(!IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8318                     {
       
  8319                      StartInlineEditingWithSelectedWord(selectedWord);
       
  8320                     }
       
  8321                 UpdateInlineEditL( selectedWord, selectedWord.Length() );
       
  8322                 iPtiEngine->CommitCurrentWord();
       
  8323                 CommitInlineEditL();
       
  8324 				#ifdef RD_INTELLIGENT_TEXT_INPUT    
       
  8325 				    iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  8326 				#endif    
       
  8327 
       
  8328                 AddOneSpaceOrMoveCursorL();
       
  8329                 }
       
  8330             // Close with right arrow commits the word, does not add space
       
  8331             else if ( lastKeyEvent.iScanCode == EStdKeyRightArrow )
       
  8332             	{
       
  8333                 // Change of UI Spec
       
  8334                 /*
       
  8335                  * The following codde change is a part of bug fix for improper 
       
  8336                  * behavior of right arrow key when the candidate list is open. The
       
  8337                  * right arrow key according to the UI specs should not the selected 
       
  8338                  * candicdate and cursor should be end of the word.
       
  8339                  */
       
  8340                 iPtiEngine->HandleCommandL( EPtiCommandUserActionSetCurrentIndexOfCandidates, 
       
  8341                                             &selectedIdx );               
       
  8342                 TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  8343                 if(!IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8344                     {
       
  8345                      StartInlineEditingWithSelectedWord(selectedWord);
       
  8346                     }
       
  8347                 UpdateInlineEditL( selectedWord, selectedWord.Length() );  //selection.iAnchorPosition
       
  8348                 iPtiEngine->CommitCurrentWord();
       
  8349                 CommitInlineEditL();
       
  8350                 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
  8351 				    iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  8352 				#endif  
       
  8353 
       
  8354                 SimulateKeyEventL(EKeyF19);
       
  8355                 }
       
  8356             else if(popupCmd == EAknSoftkeyOk)
       
  8357                 {
       
  8358                 iPtiEngine->HandleCommandL( EPtiCommandUserActionSetCurrentIndexOfCandidates, 
       
  8359                                             &selectedIdx ); 
       
  8360                 TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  8361                 if(!IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8362                     {
       
  8363                      StartInlineEditingWithSelectedWord(selectedWord);
       
  8364                     }
       
  8365                 UpdateInlineEditL( selectedWord, selectedWord.Length() );
       
  8366                 iPtiEngine->CommitCurrentWord();
       
  8367                 CommitInlineEditL();
       
  8368                 AddOneSpaceOrMoveCursorL();
       
  8369                 }
       
  8370             else
       
  8371                 {
       
  8372                 iPtiEngine->HandleCommandL( EPtiCommandUserActionSetCurrentIndexOfCandidates, 
       
  8373                                             &selectedIdx ); 
       
  8374                 TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  8375                 if(!IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8376                     {
       
  8377                      StartInlineEditingWithSelectedWord(selectedWord);
       
  8378                     }
       
  8379                 UpdateInlineEditL( selectedWord, selectedWord.Length() );
       
  8380                 needToExecute = ETrue;
       
  8381                 }
       
  8382             }
       
  8383         else if (popupCmd == EAknSoftkeyCancel && iPrimaryCandidate && IsQwerty() 
       
  8384 				             && ( KeyboardLayout() != EPtiKeyboardHalfQwerty ) )
       
  8385             {
       
  8386             iPtiEngine->HandleCommandL( EPtiCommandUserActionSetIndexOfActiveCandidate, &activeIndex );             
       
  8387             iKeyBackSpaceHit = 0;
       
  8388             }            
       
  8389 		else if(lastKeyEvent.iCode == EKeyPhoneEnd )
       
  8390 			{
       
  8391 			HandleChangeInFocusL();
       
  8392 			CCoeEnv::Static()->SimulateKeyEventL( lastKeyEvent, EEventKey );
       
  8393 			}		
       
  8394 	    else if (popupCmd == EAknSoftkeyCancel && IsQwerty() && ( KeyboardLayout() != EPtiKeyboardHalfQwerty ) ) 
       
  8395            iKeyBackSpaceHit = 0;
       
  8396 		
       
  8397         // If the dialog is not closed by pressing softkeys, escape, or right arrow
       
  8398         // then the pressed key is handled also by Fep. This way the user can keep typing when the popup is open.
       
  8399       
       
  8400         //=============== Error fixing and simplify the condition ==========================================
       
  8401         // The following piece of code should be excuted, if focus word
       
  8402         // in the candidate list is accept, otherwise word sholud remain as it is.
       
  8403         // If user does not accept the word,popupCmd always be EAknSoftkeyCancel.
       
  8404         // Insetead of earlier lengthy condition, makes it simple.
       
  8405            
       
  8406         if( needToExecute )
       
  8407            {
       
  8408             const TBool shifted = (lastKeyEvent.iModifiers & (EModifierLeftShift | 
       
  8409                                    EModifierRightShift | EModifierShift));
       
  8410             const TBool chrDown = (lastKeyEvent.iModifiers & (EModifierLeftFunc));                       
       
  8411             
       
  8412             const TBool fnDown = (lastKeyEvent.iModifiers & (EModifierRightFunc));                       
       
  8413             if(fnDown  ) 
       
  8414                 iFnKeyManager->SetFnKeyState(CAknFepFnKeyManager::EFnKeyDown)  ;     
       
  8415 
       
  8416          	if (shifted)
       
  8417           		{
       
  8418           		SetFlag(EFlagQwertyShiftMode|EFlagNoActionDuringShiftKeyPress);
       
  8419           		}
       
  8420             else
       
  8421                 {
       
  8422                 ClearFlag(EFlagQwertyShiftMode|EFlagNoActionDuringShiftKeyPress);
       
  8423                 }
       
  8424             
       
  8425             if (chrDown)
       
  8426                 {
       
  8427                 SetFlag(EFlagQwertyChrKeyDepressed|EFlagNoActionDuringChrKeyPress);
       
  8428                 }
       
  8429             else
       
  8430                 {
       
  8431                 ClearFlag(EFlagQwertyChrKeyDepressed|EFlagNoActionDuringChrKeyPress);
       
  8432                 }
       
  8433             if ( lastKeyEvent.iScanCode == EStdKeyDevice3 )
       
  8434                 {
       
  8435                 CCoeEnv::Static()->SimulateKeyEventL( lastKeyEvent, EEventKey );
       
  8436                 }
       
  8437             if (! ( lastKeyEvent.iScanCode == EStdKeyDevice3 || 
       
  8438                     lastKeyEvent.iScanCode == EStdKeyRightArrow ) )
       
  8439                 {
       
  8440                 /*
       
  8441                  * The following code change is a part of bug fix for improper 
       
  8442                  * behavior of any keypress when the candidate list is open. The
       
  8443                  * keypress according to the UI specs should lock the selected 
       
  8444                  * candidate to editor and the inserted letter is appended to it. 
       
  8445                  */                
       
  8446                 iPtiEngine->HandleCommandL( EPtiCommandLockCurrentCandidate);
       
  8447                 TPtrC selectedWord = iPtiEngine->CurrentWord();
       
  8448                 if(!IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8449                     {
       
  8450                      StartInlineEditingWithSelectedWord(selectedWord);
       
  8451                     }
       
  8452                 UpdateInlineEditL( selectedWord, selectedWord.Length() );  //selection.iAnchorPosition
       
  8453                 // For QWERTY input mode, scanCode is used
       
  8454 			#ifdef __HALF_QWERTY_KEYPAD
       
  8455                 if( KeyboardLayout() == EPtiKeyboardHalfQwerty)
       
  8456                     {
       
  8457                     iHalfQwertyLastKeyEvent = lastKeyEvent;
       
  8458                     iAsyncOwnSimulateKey.CallBack();                    
       
  8459                     }
       
  8460                 else 
       
  8461 			#endif //__HALF_QWERTY_KEYPAD
       
  8462                 if (iQwertyInputMode)
       
  8463                     {
       
  8464                     CCoeEnv::Static()->SimulateKeyEventL( lastKeyEvent, EEventKey );
       
  8465                     }
       
  8466                 // For ITUT input Mode, keyCode is used
       
  8467                 else
       
  8468                     {
       
  8469                     SimulateKeyEventL( lastKeyEvent.iCode);
       
  8470                     }
       
  8471                 }
       
  8472             }
       
  8473             
       
  8474         ShowExactWordPopupIfNecessaryL();
       
  8475         if(iCandidatePopup)
       
  8476             {
       
  8477             delete iCandidatePopup;
       
  8478             iCandidatePopup = NULL;
       
  8479             }
       
  8480         }
       
  8481     //The flag ECcpuStateShiftkeyWasPressedBeforeLosingFocus suggests that the candidate list was closed with a 
       
  8482     //long key press of edit key (shift key). There are multiple calls to HandleChangedInFocusL() one manually and the other  through
       
  8483     //CONE focus change notifier. We want the flag to be set for CONE's focus handler.
       
  8484     if(isShiftKeyDepressedAfterCandidateListLaunched)
       
  8485         {
       
  8486         SetCcpuFlag(ECcpuStateShiftkeyWasPressedBeforeLosingFocus);
       
  8487         }
       
  8488     }
       
  8489 void CAknFepManager::StartInlineEditingWithSelectedWord(TDesC& aTextToUncommit)
       
  8490     {
       
  8491     if(iConcatenationTimer->IsActive())
       
  8492     	iConcatenationTimer->Cancel();
       
  8493 	
       
  8494     TInt docLenFep=iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
  8495                 if (iUncommittedText.iCursorPos>docLenFep)
       
  8496                     iUncommittedText.iCursorPos=docLenFep;
       
  8497                 if (iUncommittedText.iAnchorPos>docLenFep)
       
  8498                     iUncommittedText.iAnchorPos=docLenFep;
       
  8499                         // Activates western predictive UI to an inline editing state.
       
  8500                 FepUI()->ActivateUI();
       
  8501                 SyncStates(EAknFepStateUIActive);
       
  8502                   // Predictive QWERTY (XT9) changes <----
       
  8503                 TRAP_IGNORE(StartInlineEditL(iUncommittedText, aTextToUncommit,
       
  8504                         aTextToUncommit.Length(), EFalse));
       
  8505 
       
  8506     }
       
  8507 void CAknFepManager::GetCandidatesWithIndexL(CDesCArray* aArray,
       
  8508         TInt& aActiveIdx, TInt& aSecondaryIdx)
       
  8509     {
       
  8510 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  8511 	return;
       
  8512 #endif
       
  8513     aActiveIdx = -1;
       
  8514     aSecondaryIdx = -1;
       
  8515     iPtiEngine->HandleCommandL(
       
  8516             EPtiCommandUserActionGetCurrentIndexOfCandidates, &aActiveIdx);
       
  8517 
       
  8518     if (iKeyBackSpaceHit)
       
  8519         aSecondaryIdx = aActiveIdx;
       
  8520     else
       
  8521         iPtiEngine->HandleCommandL(
       
  8522                 EPtiCommandUserActionGetIndexOfSecondaryCandidate,
       
  8523                 &aSecondaryIdx);
       
  8524 
       
  8525     if (aArray == NULL || aActiveIdx == aSecondaryIdx)
       
  8526         return;
       
  8527 
       
  8528     iPtiEngine->GetCandidateListL(*aArray);
       
  8529     iPtiEngine->HandleCommandL(
       
  8530             EPtiCommandUserActionGetCurrentIndexOfCandidates, &aActiveIdx);
       
  8531     iPtiEngine->HandleCommandL(
       
  8532             EPtiCommandUserActionGetIndexOfSecondaryCandidate, &aSecondaryIdx);
       
  8533     }
       
  8534 
       
  8535 void CAknFepManager::ShowExactWordPopupIfNecessaryL()
       
  8536     {
       
  8537     // Ok, I have to do it here, same logics are in
       
  8538     // TryPopExactWordInICFL and ShowExactWordPopupIfNecessaryL.
       
  8539     // the code follows the old code's logic: this is a
       
  8540     // equivalent of the OLD ShowExactWordPopupIfNecessaryL; but
       
  8541     // now I can call TryPopExactWordInICFL and 
       
  8542     // TryPopExactWordInOtherPlaceL directly after extracting them from
       
  8543     // the OLD ShowExactWordPopupIfNecessaryL.
       
  8544     iExactWordPopupContent->HidePopUp();
       
  8545 //    SendEventsToPluginManL(EPluginHideTooltip);
       
  8546     if (!iWesternPredictive || !IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8547         return;
       
  8548 
       
  8549     if (EPtiKeyboardHalfQwerty == KeyboardLayout())
       
  8550         {
       
  8551         if (IsFlagSet(CAknFepManager::EFlagNoMatches))
       
  8552             UpdateCbaL(R_AKNFEP_SOFTKEYS_SPELL_EMPTY);
       
  8553         return;
       
  8554         }
       
  8555 
       
  8556     //TryPopExactWordInICFL();
       
  8557     if (iFepPluginManager && !iFepPluginManager->IsTooltipOpenOnFSQ())
       
  8558         TryPopExactWordInOtherPlaceL();
       
  8559     }
       
  8560 
       
  8561 void CAknFepManager::TryPopExactWordInICFL()
       
  8562     {
       
  8563 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  8564 	return;
       
  8565 #endif
       
  8566 	
       
  8567     // Before open tooltip,  
       
  8568     // also need to check and close tooltip on it.
       
  8569 //    SendEventsToPluginManL(EPluginHideTooltip);
       
  8570     if (!iWesternPredictive || !IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8571         {
       
  8572         SendEventsToPluginManL(EPluginHideTooltip);
       
  8573         return;
       
  8574         }
       
  8575 
       
  8576     TInt activeIdx, secondaryIdx;
       
  8577     GetCandidatesWithIndexL(NULL, activeIdx, secondaryIdx);
       
  8578     if (activeIdx == secondaryIdx)
       
  8579         {
       
  8580         SendEventsToPluginManL(EPluginHideTooltip);
       
  8581         return;
       
  8582         }
       
  8583 
       
  8584     CDesCArray* candidates = new (ELeave) CDesCArrayFlat(16);
       
  8585     CleanupStack::PushL(candidates);
       
  8586     GetCandidatesWithIndexL(candidates, activeIdx, secondaryIdx);
       
  8587     CleanupStack::PopAndDestroy(candidates);
       
  8588     if (activeIdx == secondaryIdx)
       
  8589         {
       
  8590         SendEventsToPluginManL(EPluginHideTooltip);
       
  8591         return;
       
  8592         }
       
  8593 
       
  8594     if (iFepPluginManager)
       
  8595         SendEventsToPluginManL(EPluginShowTooltip, secondaryIdx);
       
  8596     }
       
  8597 
       
  8598 void CAknFepManager::TryPopExactWordInOtherPlaceL()
       
  8599     {
       
  8600 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  8601 	return;
       
  8602 #endif
       
  8603 	
       
  8604     iExactWordPopupContent->HidePopUp();
       
  8605     if (!iWesternPredictive || !IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8606         return;
       
  8607     // In the proactive mode this popup is used to show the exact input if it differs from the
       
  8608     // default candidate shown inline.
       
  8609     // In the reactive mode it is used to show the best guess candidate if it differs from the
       
  8610     // exact word shown inline.
       
  8611 
       
  8612     TBool popupBelowInline = EFalse; // ETrue -> popup is above inline editor
       
  8613     TInt activeIdx, secondaryIdx;
       
  8614     GetCandidatesWithIndexL(NULL, activeIdx, secondaryIdx);
       
  8615     if (activeIdx == secondaryIdx)
       
  8616         return;
       
  8617 
       
  8618     CDesCArray* candidates = new (ELeave) CDesCArrayFlat(16);
       
  8619     CleanupStack::PushL(candidates);
       
  8620     GetCandidatesWithIndexL(candidates, activeIdx, secondaryIdx);
       
  8621 
       
  8622     // In case the active index and the secondary index is same, 
       
  8623     // then we do not need to display the popup
       
  8624     if (activeIdx == secondaryIdx)
       
  8625         {
       
  8626         CleanupStack::PopAndDestroy(candidates);
       
  8627         return;
       
  8628         }
       
  8629 
       
  8630     TPtrC secondaryWord = (*candidates)[secondaryIdx];
       
  8631     iExactWordPopupContent->SetTextL(secondaryWord);
       
  8632     iExactWordPopupContent->SetArrowDirection(
       
  8633             MAknFepUiWordPopupContent::EUpwards);
       
  8634     CleanupStack::PopAndDestroy(candidates);
       
  8635 
       
  8636     TPoint popupTopRight;
       
  8637     TInt height;
       
  8638     TInt ascent;
       
  8639     TInt documentOffset = iPtiEngine->CurrentWord().Length();
       
  8640 
       
  8641     GetScreenCoordinatesL(popupTopRight, height, ascent, documentOffset);
       
  8642     iExactWordPopupContent->UpdateContentSize();
       
  8643 
       
  8644     TBool rightToLeftLang = IsRightToLeftParagraph(DocPos());
       
  8645     if (!rightToLeftLang)
       
  8646         {
       
  8647         popupTopRight.iX += iExactWordPopupContent->Size().iWidth;
       
  8648         }
       
  8649 
       
  8650     if (popupBelowInline)
       
  8651         {
       
  8652         popupTopRight.iY += ascent / 2;
       
  8653         }
       
  8654     else
       
  8655         {
       
  8656         popupTopRight.iY -= height + iExactWordPopupContent->Size().iHeight;
       
  8657         }
       
  8658 
       
  8659     iExactWordPopupContent->SetPosition(popupTopRight);
       
  8660     iExactWordPopupContent->ShowPopUp();
       
  8661     }
       
  8662 
       
  8663 void CAknFepManager::LaunchPredictiveSettingDialogL()
       
  8664 	{
       
  8665 #ifdef RD_SCALABLE_UI_V2	
       
  8666     // Addtion of ITI features on FSQ.
       
  8667     if ( iFepPluginManager 
       
  8668          && iFepPluginManager->IsSupportITIOnFSQ() )
       
  8669         {
       
  8670         // Hide touch input ui firstly,
       
  8671         // otherwise, touch ui can hide status pane.        
       
  8672         // Let CAknFepPluginManager know this setting dialog will be opened.
       
  8673         iFepPluginManager->ITISettingDialogOpen( ETrue );
       
  8674         iFepPluginManager->ClosePluginInputUiL( ETrue );
       
  8675         SendEventsToPluginManL( ELostForeground );
       
  8676         }
       
  8677 #endif // RD_SCALABLE_UI_V2
       
  8678 
       
  8679 	// Hide fixed toolbar just before launching predictive settings dialog
       
  8680 	CEikAppUiFactory * appUiFactory = NULL;
       
  8681 	appUiFactory = static_cast<CEikAppUiFactory*>(CEikonEnv::Static()->AppUiFactory());
       
  8682 	
       
  8683 	CAknToolbar * fixedToolbar = NULL;
       
  8684 	if(appUiFactory)
       
  8685 	    fixedToolbar = appUiFactory->CurrentFixedToolbar();
       
  8686 	
       
  8687 	// If fixedtoolbar is not there in the current editor, we don't need to hide it before launching settings dialog 
       
  8688 	// and unhide it after settings dialog is done.
       
  8689 	if( fixedToolbar && !( fixedToolbar->IsShown() && fixedToolbar->CountComponentControls()>0 ) )
       
  8690 	    fixedToolbar = NULL;
       
  8691 	
       
  8692 	if(fixedToolbar)
       
  8693 		{
       
  8694 	  fixedToolbar->SetDimmed(ETrue);
       
  8695 	  fixedToolbar->DrawDeferred();
       
  8696 	  }
       
  8697     TUid fepUid = CCoeEnv::Static()->FepUid();
       
  8698     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  8699 		
       
  8700     if ( iFepPluginManager && iFepPluginManager->IsSupportITIOnFSQ() )
       
  8701         {
       
  8702 	    RProperty::Set( KPSUidAknFep, KAknFepSettingDialogState, 2 );
       
  8703 	    }
       
  8704     else
       
  8705         {
       
  8706 	    RProperty::Set( KPSUidAknFep, KAknFepSettingDialogState, 1 );
       
  8707 		}
       
  8708     
       
  8709 	UiInterface()->LaunchPredictiveSettingDialogL(R_PREDICTIVESETTING_DIALOG,
       
  8710 												  R_PREDICTIVESETTINGDIALOG_MENUBAR,
       
  8711 												  R_PREDICTIVETEXTOFF_CONFIRMATION_QUERY,
       
  8712 												  R_AKNFEP_PRED_INPUT_SETTINGS_TITLE);
       
  8713     PrepareFepAfterDialogExitL(fepUid);	
       
  8714 	RProperty::Set(KPSUidAknFep,KAknFepSettingDialogState,0);
       
  8715 #ifdef RD_SCALABLE_UI_V2	
       
  8716     // // Addtion of ITI features on FSQ.    
       
  8717     if ( iFepPluginManager 
       
  8718          && iFepPluginManager->IsSupportITIOnFSQ() )
       
  8719         {        
       
  8720         // Let CAknFepPluginManager know this setting dialog will be opened.
       
  8721         iFepPluginManager->ITISettingDialogOpen( EFalse );        
       
  8722         }
       
  8723 #endif // RD_SCALABLE_UI_V2
       
  8724 
       
  8725 	// Enables fixed toolbar after predictive settings dialog is closed
       
  8726 	if(fixedToolbar)
       
  8727 		{
       
  8728 	  fixedToolbar->SetDimmed(EFalse);
       
  8729 	  fixedToolbar->DrawDeferred();
       
  8730 	  }
       
  8731 	}
       
  8732 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
  8733 void CAknFepManager::LaunchWritingLanguageSettingDialogL()
       
  8734     {
       
  8735     TUid fepUid = CCoeEnv::Static()->FepUid();
       
  8736     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  8737     UiInterface()->LaunchWritingLanguageSettingDialogL(R_INPUTLANGUAGE_DIALOG, R_PREDICTIVESETTINGDIALOG_MENUBAR, R_INPUT_LANGUAGE_SETTINGS_TITLE);
       
  8738     PrepareFepAfterDialogExitL(fepUid);	
       
  8739 	}
       
  8740 
       
  8741 void  CAknFepManager:: LaunchDualLanguageSettingDialogL()
       
  8742     {
       
  8743     /* In Chinese language variant,if there are more than one languages supporting dual language feature,
       
  8744     display writing language setting view in which Primary and Secondary Languages can be selected from the list.
       
  8745     
       
  8746     In Chinese language variant,if there is only one language supporting dual language feature, 
       
  8747     no need to display the Writing language view which contains Primary and Secondary Language. 
       
  8748     Instead we can display the Writing language list directly to the user;from which the user can select the writing language*/
       
  8749 
       
  8750     if( FeatureManager::FeatureSupported( KFeatureIdChinese ) || FeatureManager::FeatureSupported( KFeatureIdJapanese ))
       
  8751         {                        
       
  8752         CArrayFixFlat<TInt>* languages = new( ELeave )CArrayFixFlat<TInt>( ELanguageArrayGranularity );
       
  8753         CleanupStack::PushL( languages );
       
  8754         iPtiEngine->GetAvailableLanguagesL( languages );
       
  8755         
       
  8756         TInt count = languages->Count();   
       
  8757         TInt noLangSupportWesternPred = count;
       
  8758         for (TInt index = 0; index < count; index++)
       
  8759             {      
       
  8760             TInt langCode = languages->At(index);            
       
  8761             
       
  8762             if (langCode == ELangTaiwanChinese ||
       
  8763                langCode == ELangHongKongChinese ||
       
  8764                langCode == ELangPrcChinese ||
       
  8765                langCode == ELangJapanese ||
       
  8766                langCode == ELangKorean )
       
  8767                 {
       
  8768                 noLangSupportWesternPred--;
       
  8769                 }            
       
  8770             }                         
       
  8771         CleanupStack::PopAndDestroy(languages);    
       
  8772         
       
  8773         if( noLangSupportWesternPred > 1 )
       
  8774             {             
       
  8775             SetFlag(CAknFepManager::EFlagNewSharedDataInputMode);
       
  8776             LaunchWritingLanguageSettingDialogL();            
       
  8777             if(IsFlagSet(CAknFepManager::EFlagNewSharedDataInputLanguage))
       
  8778                 {
       
  8779                 ClearFlag(CAknFepManager::EFlagNewSharedDataInputLanguage);
       
  8780                 HandleChangeInFocusL();
       
  8781                 ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
  8782                 }
       
  8783             }
       
  8784         else
       
  8785             LaunchLanguagesPopupListL();                                                
       
  8786         }   
       
  8787     else
       
  8788         {
       
  8789         LaunchWritingLanguageSettingDialogL();        
       
  8790         if(IsFlagSet(CAknFepManager::EFlagNewSharedDataInputLanguage))
       
  8791             {
       
  8792             ClearFlag(CAknFepManager::EFlagNewSharedDataInputLanguage);
       
  8793             HandleChangeInFocusL();
       
  8794             ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
  8795             }
       
  8796         } 
       
  8797         
       
  8798     }
       
  8799 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
  8800 // Predictive QWERTY (XT9) changes <----
       
  8801 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  8802 void CAknFepManager::LaunchInsertWordQueryL(const TDesC& aInitialText, 
       
  8803                                             TCursorSelection aTextSpanToReplace)
       
  8804     {
       
  8805     TInt recourceId = R_AVKON_INSERT_WORD_QUERY;
       
  8806     LaunchFepQueryDialogL(recourceId, aInitialText, aTextSpanToReplace);
       
  8807     }
       
  8808 
       
  8809 void CAknFepManager::LaunchEditWordQueryL()
       
  8810     {
       
  8811 
       
  8812     TBuf<EMaximumFepWordLength> newText;
       
  8813 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  8814 	if(IsAutoCompleteOn())
       
  8815   		{
       
  8816         RemoveSuggestedCompletionL();
       
  8817         }
       
  8818 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  8819     iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(newText, 
       
  8820                                                                     iUncommittedText.iAnchorPos, 
       
  8821                                                                     iUncommittedText.Length());
       
  8822 
       
  8823     TInt recourceId = R_AVKON_INSERT_WORD_QUERY;
       
  8824     LaunchFepQueryDialogL(recourceId, newText, iUncommittedText);
       
  8825     }
       
  8826 
       
  8827 void CAknFepManager::LaunchFepQueryDialogL(TInt aResourceId, const TDesC& aInitialText, 
       
  8828                                            TCursorSelection aTextSpanToReplace)
       
  8829     {
       
  8830     HBufC* textBuf = HBufC::NewLC(EQueryBufferLength);  // buffer for inserted text
       
  8831     TPtr text = textBuf->Des();
       
  8832 
       
  8833     if (aInitialText.Length() <= EQueryBufferLength)
       
  8834         text.Copy(aInitialText);
       
  8835     else // truncate the incoming text to EQueryBufferLength before copying
       
  8836         {
       
  8837         TPtrC truncatedText = aInitialText.Left(EQueryBufferLength);
       
  8838         text.Copy(truncatedText);
       
  8839         }
       
  8840 
       
  8841     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8842         {
       
  8843         TryRemoveNoMatchesIndicatorL();
       
  8844         CommitInlineEditL();
       
  8845         }
       
  8846     UpdateCbaL(NULL);
       
  8847 
       
  8848     TInt underlyingCase = iCaseMan->CurrentCase();
       
  8849     TBool isCaseUpdatesSupressed = IsFlagSet(EFlagSupressAutoUpdateAtEditorStart);
       
  8850 
       
  8851 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
  8852     if (aInitialText.Length())
       
  8853         {
       
  8854         iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
  8855         if (aInitialText.Length() == 1)
       
  8856             {
       
  8857             if (STATIC_CAST(TChar, aInitialText[0]).IsUpper())
       
  8858                 iCaseMan->SetCurrentCase(EAknEditorTextCase);
       
  8859             }
       
  8860         else // length of initial text > 1
       
  8861             {
       
  8862             if (STATIC_CAST(TChar, aInitialText[0]).IsUpper())
       
  8863                 {
       
  8864                 if (STATIC_CAST(TChar, aInitialText[1]).IsLower())
       
  8865                     iCaseMan->SetCurrentCase(EAknEditorTextCase);
       
  8866                 else // 2nd character is upper case
       
  8867                     iCaseMan->SetCurrentCase(EAknEditorUpperCase);
       
  8868                 }
       
  8869             }
       
  8870         }
       
  8871 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  8872 
       
  8873     if (iCaseMan->CurrentCase() == EAknEditorLowerCase 
       
  8874      || iCaseMan->CurrentCase() == EAknEditorUpperCase)
       
  8875         {
       
  8876         SetFlag(EFlagSupressAutoUpdateAtEditorStart);
       
  8877         }
       
  8878 
       
  8879     TransferFepStateToEditorL();
       
  8880 
       
  8881     SetFlag(EFlagForegroundUIComponentVisible);
       
  8882     
       
  8883     TInt textQueryEditorFlag = 0;
       
  8884     if ((aResourceId == R_AVKON_INSERT_WORD_QUERY ||
       
  8885          aResourceId == R_AVKON_EDIT_WORD_QUERY ) &&
       
  8886          FeatureManager::FeatureSupported( KFeatureIdChinese ))
       
  8887     	{
       
  8888 	    textQueryEditorFlag = EAknEditorFlagLatinInputModesOnly;
       
  8889     	}
       
  8890 #ifdef RD_SCALABLE_UI_V2     
       
  8891     if (iFepFullyConstructed && 
       
  8892         iFepPluginManager->PluginInputMode() == EPluginInputModeItut )
       
  8893    // if ( iFepFullyConstructed && 
       
  8894     //    (( iFepPluginManager->PluginInputMode() == EPluginInputModeItut ) && IsChineseInputLanguage())) 
       
  8895         {
       
  8896         iFepPluginManager->SpellText(textBuf);
       
  8897         iFepPluginManager->DisplaySpellEditor(textQueryEditorFlag, aInitialText, 
       
  8898                                               TCursorSelection(aInitialText.Length(), 0));
       
  8899 
       
  8900         delete iSpellInitText;
       
  8901         iSpellInitText = NULL;
       
  8902 	    iSpellInitText = aInitialText.AllocL();
       
  8903 	    iSpellInitCurSel = aTextSpanToReplace;
       
  8904 
       
  8905         iFepPluginManager->SetCaseUpdatesSupressed(isCaseUpdatesSupressed);
       
  8906 		//add to avoid text update late when open spell.
       
  8907         //iFepPluginManager->SetITUTSpellingStateL(ETrue);    
       
  8908         iFepPluginManager->SetCursorSelection(aTextSpanToReplace);
       
  8909         CleanupStack::PopAndDestroy();
       
  8910         
       
  8911         return;
       
  8912         }
       
  8913 #endif    
       
  8914     
       
  8915     if(iFepPluginManager)
       
  8916         {
       
  8917         iFepPluginManager->SetInEditWordQueryFlag(ETrue);
       
  8918         }
       
  8919 
       
  8920     PrepareFepForFepAwareDialogLaunch();
       
  8921     TUid fepUid = CCoeEnv::Static()->FepUid();
       
  8922     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  8923     TInt id = iUiInterface->TextQueryDialogL(text, *EditorState(), 
       
  8924                                              textQueryEditorFlag, aResourceId);
       
  8925     PrepareFepAfterFepAwareDialogExitL(fepUid);        
       
  8926     PrepareFepAfterDialogExitL(fepUid);
       
  8927 
       
  8928     if(iFepPluginManager)
       
  8929         {
       
  8930         iFepPluginManager->SetInEditWordQueryFlag(EFalse);
       
  8931         }                                             
       
  8932     if (id == EAknSoftkeyOk)
       
  8933         {
       
  8934         // Insert the character into the edwin.
       
  8935         InsertTextFromDialogL(text, aTextSpanToReplace);
       
  8936         // Add the word to the user dictionary (except for single character)  after it has been added to the editor.
       
  8937         // FepUI of the main editor is used. Different FepUI is used in multitap
       
  8938         // query and predictive mode 'main' editor at least in Japanese variant.
       
  8939 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  8940         if(text.Length() > 1)
       
  8941             FepUI()->AddTextToUserDictionaryL(text);
       
  8942 #else
       
  8943         FepUI()->AddTextToUserDictionaryL(text); 
       
  8944 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  8945 
       
  8946         }
       
  8947     else // restore original case and inline text
       
  8948         {
       
  8949         HandleChangeInFocus();
       
  8950         if (aTextSpanToReplace.Length())
       
  8951             {
       
  8952             EditorState()->SetInlineEditSpan(aTextSpanToReplace);
       
  8953             ConfigureFEPFromEditorStateL();
       
  8954             }
       
  8955         iCaseMan->SetCurrentCase(underlyingCase);
       
  8956         TransferFepStateToEditorL();
       
  8957         }
       
  8958 
       
  8959     if (isCaseUpdatesSupressed)
       
  8960         {
       
  8961         SetFlag(EFlagSupressAutoUpdate);
       
  8962         }
       
  8963     else
       
  8964         {
       
  8965         ClearFlag(EFlagSupressAutoUpdate);
       
  8966         }
       
  8967     ClearFlag(EFlagSupressAutoUpdateAtEditorStart);
       
  8968     CleanupStack::PopAndDestroy(); // text
       
  8969     }
       
  8970 
       
  8971 void CAknFepManager::InsertTextFromDialogL(const TDesC& aTextFromDialog, 
       
  8972                                            TCursorSelection aExtentOfTextToReplace)
       
  8973     {
       
  8974     SetCcpuFlag(ECcpuStateSupressCursorMoveToEnd);
       
  8975     // ensure we're back on the correct editor
       
  8976  
       
  8977 #ifdef RD_SCALABLE_UI_V2   
       
  8978     iNotifyPlugin = EFalse; // not really focus change
       
  8979     HandleChangeInFocus();
       
  8980     iNotifyPlugin = ETrue;
       
  8981 #else
       
  8982     HandleChangeInFocus();
       
  8983 #endif    
       
  8984     // need to commit if the editor was previously performing an inline edit
       
  8985     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
  8986         CommitInlineEditL();
       
  8987 
       
  8988     TInt addedTextLength=0;
       
  8989 
       
  8990     TCursorSelection currentSelection;
       
  8991 // In case input capabilities goes null leaving with an error code and allowing application to handle..
       
  8992     if (NULL == iInputCapabilities.FepAwareTextEditor())
       
  8993         User::Leave(KErrCorrupt);
       
  8994     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(currentSelection);
       
  8995     // Prepare for the edit
       
  8996     TInt docLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
  8997     TInt maxLength = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
  8998 
       
  8999     if (aExtentOfTextToReplace.Length())
       
  9000         {
       
  9001         if (currentSelection.Length())
       
  9002             // Want to 'cancel' the selection so move cursor & anchor to the end of
       
  9003             // the selection and then to the end of the current word
       
  9004             {
       
  9005             TInt endOfSelection=currentSelection.HigherPos();
       
  9006             iUncommittedText.SetSelection(endOfSelection, endOfSelection);
       
  9007             if (CursorInsideWord())
       
  9008                 MoveCursorToEndOfWordL();
       
  9009             }
       
  9010         iUncommittedText = aExtentOfTextToReplace;
       
  9011         iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
  9012         addedTextLength = aTextFromDialog.Length();
       
  9013         if (maxLength != 0)
       
  9014             {
       
  9015             addedTextLength = Min(addedTextLength,
       
  9016                 (maxLength - docLength + iUncommittedText.Length()));
       
  9017             }
       
  9018         }
       
  9019     else
       
  9020         {
       
  9021         addedTextLength = aTextFromDialog.Length();
       
  9022 
       
  9023         //maxLength of 0 means the editor has no limit
       
  9024         if (maxLength != 0)
       
  9025             {
       
  9026             addedTextLength = Min(addedTextLength,
       
  9027                                   (maxLength - docLength + currentSelection.Length()));
       
  9028             }
       
  9029         if (currentSelection.Length())
       
  9030             {
       
  9031             iUncommittedText.SetSelection(currentSelection.HigherPos(), 
       
  9032                                           currentSelection.LowerPos());
       
  9033             iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
  9034             }
       
  9035         else // do this in order for editor to get the correct number of chars to format from GetFormatOfFepInlineText()
       
  9036             iUncommittedText.iCursorPos+=addedTextLength;
       
  9037         }
       
  9038     // if necessary trim text to fit into available space in the editor & perform the edit
       
  9039     TPtrC textToEditor = aTextFromDialog.Left(addedTextLength);
       
  9040 
       
  9041     StartInlineEditL(textToEditor);
       
  9042     CommitInlineEditL();
       
  9043 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
  9044     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  9045 #endif    
       
  9046 
       
  9047     EditorState()->SetInlineEditSpan(iUncommittedText);
       
  9048     }
       
  9049 
       
  9050 void CAknFepManager::LaunchKutenCodeQueryL()
       
  9051     {
       
  9052     TInt code;
       
  9053     TUid fepUid = CCoeEnv::Static()->FepUid();
       
  9054     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
  9055     UiInterface()->JapaneseKutenQueryDialogL(R_AKNFEPUICTRLJAPANESEKUTEN_QUERY, code, 0);
       
  9056 
       
  9057     PrepareFepAfterDialogExitL(fepUid);
       
  9058 
       
  9059     HandleChangeInFocus();  // to re-establish contact with editor under KutenCode Query
       
  9060 
       
  9061     if (code > 0 && EditorHasFreeSpace())
       
  9062         {
       
  9063         TBuf<ESingleCharacter> text;
       
  9064         text.Append((TText)code);
       
  9065         SetFlag(EFlagInsideInlineEditingTransaction);
       
  9066         iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(text, ESingleCharacter, 
       
  9067                                                                      ETrue, NULL, *this, *this);
       
  9068         CommitInlineEditL();
       
  9069         }
       
  9070     }
       
  9071 
       
  9072 TInt CAknFepManager::NumericModeSCTResourceId() const
       
  9073     {
       
  9074     TInt charMapResId = EDefaultNumericCharMapResId;
       
  9075     TBool phoneIdle = (EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor);            
       
  9076     
       
  9077     if( phoneIdle )
       
  9078         {
       
  9079         charMapResId=R_AKNFEP_SCT_NUMERIC_MODE_CHARS_STANDARD;
       
  9080         return charMapResId;
       
  9081         }
       
  9082 
       
  9083     switch (iAknEditorNumericKeymap)
       
  9084         {
       
  9085         case EAknEditorStandardNumberModeKeymap:
       
  9086             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_STANDARD;
       
  9087             break;
       
  9088         case EAknEditorCalculatorNumberModeKeymap:
       
  9089             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_CALCULATOR;
       
  9090             break;
       
  9091         case EAknEditorConverterNumberModeKeymap:
       
  9092             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_CONVERTER;
       
  9093             break;
       
  9094         case EAknEditorFixedDiallingNumberModeKeymap:
       
  9095             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_FIXED_DIALLING;
       
  9096             break;
       
  9097         case EAknEditorSATNumberModeKeymap:
       
  9098             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_SAT;
       
  9099             break;
       
  9100         case EAknEditorToFieldNumberModeKeymap:
       
  9101             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_TO_FIELD;
       
  9102             break;
       
  9103         case EAknEditorPlainNumberModeKeymap:
       
  9104             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_PLAIN;
       
  9105             break;
       
  9106         case EAknEditorNativeKeysNumberModeKeymap:
       
  9107             //currently this is not in use
       
  9108             break;
       
  9109         case EAknEditorSATHiddenNumberModeKeymap:
       
  9110             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_SAT_HIDDEN;
       
  9111             break;
       
  9112         default:
       
  9113             //We reach here because there is no valid SCT resource ID set
       
  9114             //by the current editor. So best we can do now is set the 
       
  9115             //default mode for numeric editors.
       
  9116             charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_STANDARD;
       
  9117             break;
       
  9118         }
       
  9119     if(IsHybridAplhaEditor() && !IsHybridAlphaModeChangedtoAplhanumeric())
       
  9120         {
       
  9121         charMapResId = R_AKNFEP_SCT_NUMERIC_MODE_CHARS_STANDARD;
       
  9122         }
       
  9123     return charMapResId;
       
  9124     }
       
  9125 
       
  9126 
       
  9127 TBool CAknFepManager::HashKeyModeChangeBlockedInSearchField() const
       
  9128     {
       
  9129     if ((iAknEditorFlags & EAknEditorFlagFindPane) && 
       
  9130          iSharedDataInterface->HashKeySelectionInUse() &&                
       
  9131          !IsChineseInputLanguage() &&
       
  9132          !IsKoreanInputLanguage() &&
       
  9133          iLanguageCapabilities.iInputLanguageCode != ELangVietnamese &&
       
  9134          !FeatureManager::FeatureSupported(KFeatureIdJapanese))
       
  9135          {
       
  9136          if (iMode == ELatin || iMode == ENumber || iMode == ENativeNumber )
       
  9137             {
       
  9138             return ETrue;               
       
  9139             }                               
       
  9140          }
       
  9141              
       
  9142     return EFalse;         
       
  9143     }
       
  9144 
       
  9145     
       
  9146 TKeyResponse CAknFepManager::HandleHashKeyL(TKeyPressLength aLength)
       
  9147     {
       
  9148     TKeyResponse response = EKeyWasNotConsumed;
       
  9149     if (IsFlagSet(EFlagPassNextKey))
       
  9150         {
       
  9151         ClearFlag(EFlagPassNextKey);
       
  9152         }
       
  9153     else if (IsFlagSet(EFlagShiftKeyDepressed))
       
  9154         {
       
  9155         response = EKeyWasConsumed;
       
  9156         }
       
  9157     else if (HashKeyModeChangeBlockedInSearchField())      
       
  9158         {
       
  9159         // Do not allow case changes for latin languages in search field
       
  9160         // if hash key selection is active.
       
  9161         response = EKeyWasConsumed;
       
  9162         }
       
  9163     else
       
  9164         {
       
  9165         if ( IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) )
       
  9166             {
       
  9167 #ifdef RD_HINDI_PHONETIC_INPUT	                    
       
  9168 		if(iSharedDataInterface->InputTextLanguage() != KLangHindiPhonetic)    
       
  9169 #endif            
       
  9170             FepUI()->ExpireMultitapTimer();
       
  9171             // For Japanese, send backspace key event in case hash key
       
  9172             // is pressed while secret text input.
       
  9173            if (IsFeatureSupportedJapanese())
       
  9174                 {
       
  9175                 if (iInputCapabilities.SupportsSecretText())
       
  9176                     {
       
  9177                     SimulateKeyEventL(EKeyF20);          //backspace
       
  9178                     }
       
  9179                 }
       
  9180 #ifdef RD_HINDI_PHONETIC_INPUT	                    
       
  9181 		if(iSharedDataInterface->InputTextLanguage() != KLangHindiPhonetic)    
       
  9182 #endif            
       
  9183                 ClearFlag(EFlagInsideMultitapInlineEditingTransaction);
       
  9184             iCaseMan->UpdateCase(ENullNaviEvent);
       
  9185             }
       
  9186         if (aLength == EShortKeyPress)
       
  9187             {
       
  9188             if ( iMode != ENumber && iMode != ENativeNumber )
       
  9189                 {
       
  9190                 iModeBefore = iMode;
       
  9191                 if (iModeBefore == ELatin)
       
  9192                     {
       
  9193                     iCaseBefore = iCaseMan->CurrentCase();
       
  9194                     }
       
  9195                 }
       
  9196             }
       
  9197 
       
  9198        // always keep previous input mode for Japanese input
       
  9199        if (IsFeatureSupportedJapanese())
       
  9200             {
       
  9201             iModeBefore = iMode;
       
  9202             if (iModeBefore == ELatin)
       
  9203                 {
       
  9204                 iCaseBefore = iCaseMan->CurrentCase();
       
  9205                 }
       
  9206             }
       
  9207        if (iMode == EHangul && aLength == ELongKeyPress)
       
  9208        		{       
       
  9209        		if (IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
  9210                 {
       
  9211                 TPtrC text = iPtiEngine->CurrentWord();
       
  9212                 if (text.Length() > 0)
       
  9213             		{
       
  9214             		CancelInlineEdit();
       
  9215             		StartInlineEditL();
       
  9216             		UpdateInlineEditL(iPtiEngine->PreviousCandidate(), iPtiEngine->PreviousCandidate().Length());
       
  9217             		CommitInlineEditL();
       
  9218             		}
       
  9219             	else
       
  9220             		{
       
  9221             		CancelInlineEdit();          		
       
  9222             		}
       
  9223             	iPtiEngine->ClearCurrentWord();
       
  9224                 }
       
  9225        		}
       
  9226 		
       
  9227         response = iHashKeyMan->HandleKeyEventL(aLength);
       
  9228         if (response == EKeyWasNotConsumed)
       
  9229             {
       
  9230             switch (iAknEditorNumericKeymap)
       
  9231                 {
       
  9232             case EAknEditorStandardNumberModeKeymap: //fall through
       
  9233             case EAknEditorFixedDiallingNumberModeKeymap:
       
  9234             case EAknEditorSATNumberModeKeymap:
       
  9235             case EAknEditorSATHiddenNumberModeKeymap:
       
  9236             case EAknEditorAlphanumericNumberModeKeymap:
       
  9237                 if (!EditorHasFreeSpace())
       
  9238                     {
       
  9239                     response=EKeyWasConsumed;
       
  9240                     }
       
  9241                 break;
       
  9242             case EAknEditorCalculatorNumberModeKeymap: //fall through
       
  9243             case EAknEditorConverterNumberModeKeymap:
       
  9244                 SimulateKeyEventL(CurrentDecimalSeparator());
       
  9245                 if (EditorHasFreeSpace())
       
  9246                     {
       
  9247                     SetFlag(EFlagCharacterAdded);
       
  9248                     }
       
  9249                 response=EKeyWasConsumed;
       
  9250                 break;
       
  9251             case EAknEditorToFieldNumberModeKeymap:
       
  9252                 SimulateKeyEventL(text_to_field_mode_hash_key);
       
  9253                 if (EditorHasFreeSpace())
       
  9254                     {
       
  9255                     SetFlag(EFlagCharacterAdded);
       
  9256                     }
       
  9257                 response=EKeyWasConsumed;
       
  9258                 break;
       
  9259             case EAknEditorPlainNumberModeKeymap:
       
  9260                 response=EKeyWasConsumed;
       
  9261                 break;
       
  9262             case EAknEditorNativeKeysNumberModeKeymap:
       
  9263                 break;
       
  9264             default:
       
  9265                 break;
       
  9266                 }
       
  9267             }
       
  9268         }
       
  9269     return response;
       
  9270     }
       
  9271 
       
  9272 TInt CAknFepManager::EditorNumericKeymap() const
       
  9273     {
       
  9274     return iAknEditorNumericKeymap;
       
  9275     }
       
  9276 
       
  9277 
       
  9278 TBool CAknFepManager::HashKeySelectionInUse() const
       
  9279     {       
       
  9280 	if (ExtendedInputCapabilities() 
       
  9281     & CAknExtendedInputCapabilities::EForceHashKeySelectionStatusFlagOff)
       
  9282 	    {
       
  9283 	    return EFalse;
       
  9284 	    }
       
  9285         
       
  9286     return iSharedDataInterface->HashKeySelectionInUse();           
       
  9287     }     
       
  9288   
       
  9289 
       
  9290 TBool CAknFepManager::EditSubmenuInUse() const
       
  9291 	{
       
  9292 	if (RProcess().SecureId().iId == KPhoneSecureId)
       
  9293 		{
       
  9294 		if (iQwertyInputMode)
       
  9295 			{
       
  9296 			return EFalse;				
       
  9297 			}
       
  9298 		} 
       
  9299 			
       
  9300 	if (ExtendedInputCapabilities() & CAknExtendedInputCapabilities::EForceEditSubmenuStatusFlagOff)
       
  9301 	    {
       
  9302 	    return EFalse;
       
  9303 	    }			
       
  9304 			
       
  9305 	return iSharedDataInterface->EditSubmenuInUse();			
       
  9306 	} 
       
  9307 
       
  9308 
       
  9309 void CAknFepManager::DimEditMenuModeItems(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  9310     {
       
  9311     // current item
       
  9312     DimMenuItem(aMenuPane, iMode);
       
  9313 
       
  9314     // dim menu items for Chinese input modes that aren't valid in the current editor
       
  9315     // or the device subvariant
       
  9316     for (TInt mode = KFirstMode; mode <= KLastMode; mode = mode << 1)
       
  9317         {
       
  9318         if (!IsModePermitted(mode))
       
  9319             {
       
  9320             DimMenuItem(aMenuPane, mode);
       
  9321             }
       
  9322         }
       
  9323     
       
  9324     // Switch menu whether input language is supported related chinese phrase    
       
  9325     MPtiLanguage* ptilang = iPtiEngine->GetLanguage(
       
  9326                 iLanguageCapabilities.iInputLanguageCode ); 
       
  9327     if ( ptilang )
       
  9328         {
       
  9329         if( iMode != EPinyin && IsModePermitted( EPinyin ) )
       
  9330             {
       
  9331             if( ptilang->HasInputMode( EPtiEnginePinyinByPhrase ) ) 
       
  9332                 {
       
  9333                 aMenuPane->SetItemDimmed( EChinFepCmdModePinyin, ETrue );
       
  9334                 aMenuPane->SetItemDimmed( EChinFepCmdModePinyinPhrase, EFalse );
       
  9335                 }
       
  9336             }
       
  9337         
       
  9338         if( iMode != EZhuyin && IsModePermitted( EZhuyin ) )
       
  9339             {
       
  9340             if( ptilang->HasInputMode( EPtiEngineZhuyinByPhrase ) ) 
       
  9341                 {
       
  9342                 aMenuPane->SetItemDimmed( EChinFepCmdModeZhuyin, ETrue );
       
  9343                 aMenuPane->SetItemDimmed( EChinFepCmdModeZhuyinPhrase, EFalse );
       
  9344                 }
       
  9345             }
       
  9346             
       
  9347         if( iMode != EStroke && IsModePermitted( EStroke ) )
       
  9348             {
       
  9349             if( ptilang->HasInputMode( EPtiEngineStrokeByPhrase ) ) 
       
  9350                 {
       
  9351                 aMenuPane->SetItemDimmed( EChinFepCmdModeStroke, ETrue );
       
  9352                 aMenuPane->SetItemDimmed( EChinFepCmdModeStrokePhrase, EFalse );
       
  9353                 }
       
  9354             }
       
  9355         }
       
  9356     
       
  9357     if (IsAbleToLaunchSmiley())
       
  9358         {
       
  9359         TInt index;
       
  9360         if (aMenuPane->MenuItemExists(EAknCmdEditInsertSmiley, index))
       
  9361             {
       
  9362             aMenuPane->SetItemDimmed(EAknCmdEditInsertSmiley, EFalse);
       
  9363             }
       
  9364         }        
       
  9365     }
       
  9366 
       
  9367 void CAknFepManager::DimMenuItem(CAknFepUiInterfaceMenuPane* aMenuPane, TInt aMode)
       
  9368     {
       
  9369     TInt dimmedMenuItem = 0;
       
  9370     switch (aMode)
       
  9371         {
       
  9372         case EPinyin:
       
  9373             dimmedMenuItem = EChinFepCmdModePinyin;
       
  9374             break;
       
  9375         case EZhuyin:
       
  9376             dimmedMenuItem = EChinFepCmdModeZhuyin;
       
  9377             break;
       
  9378         case EStroke:
       
  9379             dimmedMenuItem = EChinFepCmdModeStroke;
       
  9380             break;
       
  9381         case ECangJie:
       
  9382             dimmedMenuItem = EChinFepCmdModeCangJie;
       
  9383             break;
       
  9384         case EZhuyinFind:
       
  9385             dimmedMenuItem = EChinFepCmdModeZhuyinFind;
       
  9386             break;
       
  9387         case EStrokeFind:
       
  9388             dimmedMenuItem = EChinFepCmdModeStrokeFind;
       
  9389             break;
       
  9390         case ELatin:
       
  9391             if ( iLanguageCapabilities.iInputLanguageCode != ELangJapanese)
       
  9392                 {
       
  9393                 // According Katja's info, dim the current case item in the 
       
  9394                 // indicator menu.
       
  9395                 if ( iCaseMan->CurrentCase() == EAknEditorUpperCase )
       
  9396                     {
       
  9397                     dimmedMenuItem = EChinFepCmdModeLatinUpper;
       
  9398                     }
       
  9399                 else if(iCaseMan->CurrentCase() == EAknEditorLowerCase)
       
  9400                     {
       
  9401                     dimmedMenuItem = EChinFepCmdModeLatinLower;
       
  9402                     }
       
  9403                 else if(iCaseMan->CurrentCase() == EAknEditorTextCase)
       
  9404                     {
       
  9405                     dimmedMenuItem = EAknCmdEditModeLatinText;
       
  9406                     }
       
  9407                 }
       
  9408             break;
       
  9409         case ENativeNumber:
       
  9410             {
       
  9411             aMenuPane->SetItemDimmed(EAknCmdEditModeArabicIndicNumber, ETrue);
       
  9412             aMenuPane->SetItemDimmed(EAknCmdEditModeEasternArabicIndicNumber, ETrue);
       
  9413             aMenuPane->SetItemDimmed(EAknCmdEditModeIndicNumber, ETrue);
       
  9414             }
       
  9415             break;
       
  9416         default:
       
  9417             break;
       
  9418         }
       
  9419     TInt index;
       
  9420     if (dimmedMenuItem && aMenuPane->MenuItemExists(dimmedMenuItem, index))
       
  9421         {
       
  9422         aMenuPane->SetItemDimmed(dimmedMenuItem, ETrue);
       
  9423         }
       
  9424     }
       
  9425 
       
  9426 void CAknFepManager::LaunchConfirmationNoteL(TInt aResourceId)
       
  9427     {
       
  9428     SetFlag(EFlagForegroundUIComponentVisible);
       
  9429 	iUiInterface->LaunchConfirmationNoteL(aResourceId);
       
  9430     }
       
  9431 
       
  9432 void CAknFepManager::NewCharacterL(const TDesC& aChar)
       
  9433     {
       
  9434     if ( aChar.Length() == 0 )
       
  9435     	{
       
  9436     	return;
       
  9437     	}
       
  9438     TChar ch = aChar[0];
       
  9439 
       
  9440     TBool validNewCandidate = CharIsValidInEditor(ch);
       
  9441     // Check if the character is valid for the editor.
       
  9442     if ( !validNewCandidate )
       
  9443         {
       
  9444         TChar firstNewCandidate = ch;
       
  9445         TBool goneThroughAllCandidates(EFalse);
       
  9446         TPtrC8 sequence = iPtiEngine->CurrentInputSequence();
       
  9447 
       
  9448         if ( sequence.Length() )
       
  9449             {
       
  9450             TPtiKey key = (TPtiKey)sequence[0];
       
  9451                         
       
  9452             TBuf<20> mapData;              
       
  9453             iPtiEngine->MappingDataForKey(key, mapData, iPtiEngine->Case()); 
       
  9454             // If the character was not coming from ptiengine mappings, fail instantly.              
       
  9455             if (mapData.Locate(firstNewCandidate) != KErrNotFound)
       
  9456                 {                
       
  9457                 // If there is an ivalid character in chr-loop, try to jump to next valid one.
       
  9458                 for (TInt jj = 0; jj < mapData.Length(); jj++)
       
  9459                     {
       
  9460                     TPtrC text = iPtiEngine->AppendKeyPress(key);
       
  9461 				    if ( text.Length() == 0 )
       
  9462 				    	{
       
  9463 				    	continue;
       
  9464 				    	}
       
  9465                     ch = text[0];
       
  9466                     goneThroughAllCandidates = (ch == firstNewCandidate);                    
       
  9467                     validNewCandidate = CharIsValidInEditor(ch);
       
  9468                     if (validNewCandidate || goneThroughAllCandidates)
       
  9469                         {
       
  9470                         break;
       
  9471                         }                                        
       
  9472                     }
       
  9473                 }            
       
  9474             }
       
  9475         }
       
  9476     if (!validNewCandidate)
       
  9477         {
       
  9478         // No valid characters at all.
       
  9479         CancelInlineEdit();
       
  9480         return;
       
  9481         }
       
  9482 
       
  9483     if ( (ch == KAknFEPLineFeedSymbol ||
       
  9484           ch == KAknFEPMirroredLineFeedSymbol) &&
       
  9485         (EditorHasFreeSpace() || IsFlagSet(EFlagLastCharacterInEditor)))
       
  9486         {
       
  9487         SetFlag(EFlagLineFeedCharacter);
       
  9488         }
       
  9489     else
       
  9490         {
       
  9491         ClearFlag(EFlagLineFeedCharacter);
       
  9492         }
       
  9493         
       
  9494     if ( (ch == EKeySpace) &&
       
  9495         (EditorHasFreeSpace() || IsFlagSet(EFlagLastCharacterInEditor)))
       
  9496         {
       
  9497         SetFlag(EFlagSpaceCharacter);
       
  9498         }
       
  9499     else
       
  9500         {
       
  9501         ClearFlag(EFlagSpaceCharacter);
       
  9502         }
       
  9503 
       
  9504 
       
  9505     if (iInputCapabilities.SupportsSecretText())
       
  9506         {
       
  9507         if (IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))
       
  9508             {
       
  9509             SimulateKeyEventL(EKeyF20); // to delete previous char in secret text editor
       
  9510             }
       
  9511         //we receive an extra key press if we simulate a key that is also a device key
       
  9512         if (ch.IsDigit() || TUint(ch) == EStarKeyUnicodeValue || TUint(ch) == EHashKeyUnicodeValue)
       
  9513             {
       
  9514             SetFlag(EFlagPassNextKey);
       
  9515             }
       
  9516         if ( ch.IsDigit() && iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic )
       
  9517             {
       
  9518             ClearFlag(EFlagPassNextKey);
       
  9519             SimulateKeyEventL(ch + (TChar)KLatinToArabicIndicDigitsDelta ); 
       
  9520             }
       
  9521         else if ( ch.IsDigit() 
       
  9522                && iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic )
       
  9523             {
       
  9524             ClearFlag(EFlagPassNextKey);
       
  9525             if(iLanguageCapabilities.iInputLanguageCode == ELangUrdu 
       
  9526             || iLanguageCapabilities.iInputLanguageCode == ELangFarsi)
       
  9527                 {
       
  9528                 SimulateKeyEventL(ch + (TChar)KLatinToEasternArabicIndicDigitsDelta );  
       
  9529                 }
       
  9530             }    
       
  9531         else if ( ch.IsDigit() && iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari )
       
  9532             {
       
  9533             ClearFlag(EFlagPassNextKey);
       
  9534             SimulateKeyEventL(ch + (TChar)KLatinToDevanagariDigitsDelta);
       
  9535             }
       
  9536         else
       
  9537             {
       
  9538             SimulateKeyEventL(ch);
       
  9539             }
       
  9540         SetFlag(EFlagInsideMultitapInlineEditingTransaction | EFlagInsideInlineEditingTransaction);
       
  9541         }
       
  9542     else if (EditorHasFreeSpace() || IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))
       
  9543         {
       
  9544         TBuf<1> buf;
       
  9545         if ( ch.IsDigit() && iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic )
       
  9546             {
       
  9547             buf.Append( ch + (TChar)KLatinToArabicIndicDigitsDelta );   
       
  9548             }
       
  9549         else if ( ch.IsDigit() 
       
  9550                && iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic )
       
  9551             {
       
  9552             if(iLanguageCapabilities.iInputLanguageCode == ELangUrdu 
       
  9553             || iLanguageCapabilities.iInputLanguageCode == ELangFarsi)
       
  9554                 {
       
  9555                 buf.Append( ch + (TChar)KLatinToEasternArabicIndicDigitsDelta );                    
       
  9556                 }
       
  9557             }    
       
  9558         else if ( ch.IsDigit() && iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari )
       
  9559             {
       
  9560             buf.Append( ch + (TChar)KLatinToDevanagariDigitsDelta );    
       
  9561             }
       
  9562         else
       
  9563             {
       
  9564             buf.Append( ch );
       
  9565             }
       
  9566 
       
  9567         if (iFepManState == EAknFepStateInitial) //multitapping
       
  9568             {
       
  9569             if (!IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))
       
  9570                 {
       
  9571                 TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
  9572                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  9573                 if (iAknEditorFlags & EAknEditorFlagMTAutoOverwrite && iMode == ELatin 
       
  9574                     && !WesternPredictive()
       
  9575                     && iUncommittedText.iCursorPos < edSize 
       
  9576                     && iUncommittedText.Length() == 0)
       
  9577                     {
       
  9578                     // If the cursor is at the beginning or in the middle of the text,
       
  9579                     // existing characters are replaced with new ones in latin multitap input.
       
  9580                     iUncommittedText.iCursorPos++;
       
  9581                     StartInlineEditL(iUncommittedText, buf, ESingleCharacter, EFalse);
       
  9582                     SetFlag(EFlagInsideMultitapInlineEditingTransaction);
       
  9583                     UpdateInlineEditL(buf, ESingleCharacter);
       
  9584                     }
       
  9585                 else
       
  9586                     {
       
  9587                     StartInlineEditL(buf);
       
  9588                     SetFlag(EFlagInsideMultitapInlineEditingTransaction);
       
  9589                     }
       
  9590                 }
       
  9591             else
       
  9592                 {
       
  9593                 UpdateInlineEditL(buf, ESingleCharacter);
       
  9594                 }
       
  9595 
       
  9596             if(!EditorHasFreeSpace())
       
  9597                 {
       
  9598                 SetFlag(EFlagLastCharacterInEditor);
       
  9599                 }
       
  9600             }
       
  9601         else
       
  9602             {
       
  9603             iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(buf, ESingleCharacter, 
       
  9604                                                                         ETrue, NULL, *this, *this);
       
  9605             }
       
  9606         SetFlag(EFlagInsideInlineEditingTransaction);
       
  9607         }
       
  9608     }
       
  9609 
       
  9610 void CAknFepManager::NewTextL(const TDesC& aText)
       
  9611     {
       
  9612     ClearFlag(EFlagLineFeedCharacter);
       
  9613     TBool unlimit = EFalse;
       
  9614     TInt freeSpace = EditorFreeSpace(unlimit);
       
  9615 
       
  9616     if (IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) ||
       
  9617         unlimit || freeSpace > 0 ) //
       
  9618         {
       
  9619         if( unlimit || freeSpace > aText.Length() )
       
  9620             {
       
  9621             iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(aText, aText.Length(), ETrue, 
       
  9622                                                                                  NULL, *this, *this);
       
  9623             }
       
  9624         else  
       
  9625             {
       
  9626             iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(aText.Left(freeSpace), freeSpace, ETrue, 
       
  9627                                                                                  NULL, *this, *this);
       
  9628             }
       
  9629         
       
  9630         SetFlag(EFlagInsideInlineEditingTransaction);
       
  9631         }
       
  9632     }
       
  9633 
       
  9634 
       
  9635 void CAknFepManager::NewCharacterSequenceL(const TDesC& aText, TIndicInputResponse aResponse)
       
  9636     {
       
  9637     TChar zws((ZERO_WIDTH_SPACE));
       
  9638     TChar virama((TAknFepUiIndicInputManager::Virama(TLanguage(
       
  9639                     iLanguageCapabilities.iInputLanguageCode))));
       
  9640     TBool ret = ETrue;
       
  9641 	TBuf<CAknFepManager::EMaximumFepWordLength> buf;
       
  9642     buf.Zero();
       
  9643     TBool isTextLayoutPresent = (AknFepDocumentNavigation() || TextLayout()) ? ETrue : EFalse;
       
  9644     switch( aResponse )
       
  9645         {
       
  9646         case EIndicInputResponseNone:
       
  9647             {
       
  9648             NewCharacterL(aText);
       
  9649             }
       
  9650             break;
       
  9651         case EIndicInputResponseNumber:
       
  9652             {
       
  9653             NewCharacterL(aText);
       
  9654             CommitInlineEditL();
       
  9655             }
       
  9656             break;
       
  9657         case EIndicInputResponseZWSandCharacter:
       
  9658             {
       
  9659             if (! iInputCapabilities.SupportsSecretText() && isTextLayoutPresent)
       
  9660                 {
       
  9661                 buf.Append(zws);
       
  9662                 NewCharacterL(buf);
       
  9663                 CommitInlineEditL();
       
  9664                 }
       
  9665             NewCharacterL(aText);           
       
  9666             }
       
  9667             break;
       
  9668         case EIndicInputResponseInsertZWS:
       
  9669             {
       
  9670             buf.Append(virama);
       
  9671             if(isTextLayoutPresent)
       
  9672                 buf.Append(zws);
       
  9673             ret = EFalse;           
       
  9674             }
       
  9675             break;
       
  9676         case EIndicInputResponseInsertZWSandLigature:
       
  9677             {
       
  9678             buf.Append(virama);
       
  9679             if(isTextLayoutPresent)
       
  9680                 buf.Append(zws);
       
  9681             if ( iInputCapabilities.SupportsSecretText() )
       
  9682                 {
       
  9683                 buf.Append(aText);  
       
  9684                 }
       
  9685             ret = EFalse;           
       
  9686             }
       
  9687             break;
       
  9688 
       
  9689         case EIndicInputResponseInsertRepha:
       
  9690             {
       
  9691             MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
  9692                 iInputCapabilities.FepAwareTextEditor();
       
  9693 
       
  9694             if( fepAwareTextEditor )
       
  9695                 {
       
  9696                 TInt nextCharPos = 0;
       
  9697                 TCursorSelection curSel;
       
  9698             
       
  9699                 fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
  9700                 
       
  9701                 // Insert Repha before the desired syllable.
       
  9702                 TBool leftFlag = GetNextVisualLeftCharacter( nextCharPos );
       
  9703                 if( leftFlag )
       
  9704                     {
       
  9705                     curSel.iCursorPos = nextCharPos;
       
  9706                     curSel.iAnchorPos = nextCharPos;
       
  9707                     
       
  9708                     fepAwareTextEditor->SetCursorSelectionForFepL( curSel );
       
  9709                                                 
       
  9710                     TAknFepUiIndicInputManager::GetRepha( buf, 
       
  9711                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) );
       
  9712 
       
  9713                     ret = EFalse;
       
  9714                     }
       
  9715                 }
       
  9716             break;
       
  9717             }
       
  9718 
       
  9719         case EIndicInputResponseInsertRakar:
       
  9720             {
       
  9721             TAknFepUiIndicInputManager::GetRakar( buf, 
       
  9722                 TLanguage( iLanguageCapabilities.iInputLanguageCode ) );
       
  9723             ret = EFalse;
       
  9724             }
       
  9725             break;
       
  9726 #ifdef RD_HINDI_PHONETIC_INPUT      
       
  9727     	case EIndicInputResponsePhoneticMultitapText:
       
  9728     		{
       
  9729     		buf.Append(aText);
       
  9730 			ret = EFalse;	
       
  9731     		}
       
  9732     		break;
       
  9733         case EIndicInputResponsePhoneticQwertyText:
       
  9734             {
       
  9735             buf.Append(aText);
       
  9736             ret = EFalse;   
       
  9737             }
       
  9738             break;
       
  9739 #endif          
       
  9740 
       
  9741         case EIndicInputResponseInsertDirectLigature:
       
  9742             {
       
  9743             // In key-0, the new line character preceeds the Ksha.
       
  9744             // First clear the new line flag.
       
  9745             ClearFlag( EFlagLineFeedCharacter );
       
  9746             
       
  9747             buf.Append( aText );
       
  9748             ret = EFalse;
       
  9749             }
       
  9750             break;
       
  9751 
       
  9752         case EIndicInputResponseInsertViramaZWSandDirectLigature:
       
  9753             {
       
  9754             // This case handles the insertion of Virama when star key
       
  9755             // is pressed.
       
  9756 
       
  9757             // In key-0, the new line character preceeds the Ksha.
       
  9758             // First clear the new line flag.
       
  9759             ClearFlag( EFlagLineFeedCharacter );
       
  9760 
       
  9761             buf.Append(virama);
       
  9762             if(isTextLayoutPresent)
       
  9763                 buf.Append(zws);
       
  9764             if ( iInputCapabilities.SupportsSecretText() )
       
  9765                 {
       
  9766                 buf.Append(aText);  
       
  9767                 }
       
  9768             ret = EFalse;
       
  9769             }
       
  9770             break;
       
  9771 
       
  9772         case EIndicInputResponseZWSandDirectLigature:
       
  9773             {
       
  9774             if (! iInputCapabilities.SupportsSecretText() && isTextLayoutPresent)
       
  9775                 {
       
  9776                 buf.Append(zws);
       
  9777                 NewCharacterL(buf);
       
  9778                 CommitInlineEditL();
       
  9779                 }
       
  9780             buf.Zero();
       
  9781             buf.Append( aText );
       
  9782             ret = EFalse;
       
  9783             }
       
  9784             break;
       
  9785 
       
  9786 #ifdef RD_MARATHI
       
  9787 		case EIndicInputResponseInsertEyeLashRa:
       
  9788 			{
       
  9789 			TAknFepUiIndicInputManager::GetEyeLashRa( buf, 
       
  9790 				(TLanguage)iLanguageCapabilities.iInputLanguageCode );
       
  9791 			ret = EFalse;
       
  9792     		}
       
  9793 			break;
       
  9794 
       
  9795 		case EIndicInputResponseInsertChandraA:
       
  9796 			{
       
  9797 			TAknFepUiIndicInputManager::GetChandraA( buf );
       
  9798 			ret = EFalse;
       
  9799 			}
       
  9800 			break;
       
  9801 #endif // RD_MARATHI
       
  9802 
       
  9803         default:
       
  9804             break;
       
  9805         }
       
  9806         
       
  9807     if(ret)
       
  9808         return;
       
  9809     
       
  9810     if ( iInputCapabilities.SupportsSecretText() )
       
  9811         {
       
  9812         if ( IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) )
       
  9813             {
       
  9814             SimulateKeyEventL(EKeyF20); // to delete previous char in secret text editor
       
  9815             }
       
  9816         for( TInt counter=0; counter<buf.Length(); counter++ )
       
  9817             {
       
  9818             if( (buf[counter] != ZERO_WIDTH_SPACE) )
       
  9819                 SimulateKeyEventL(buf[counter]);    
       
  9820             }
       
  9821         SetFlag(EFlagInsideMultitapInlineEditingTransaction | EFlagInsideInlineEditingTransaction);
       
  9822         }
       
  9823     else if ( EditorHasFreeSpace() || IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) )
       
  9824         {
       
  9825         if ( iFepManState == EAknFepStateInitial ) //multitapping
       
  9826             {
       
  9827             if ( !IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) )
       
  9828                 {
       
  9829                 TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
  9830                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
  9831                 if (iAknEditorFlags & EAknEditorFlagMTAutoOverwrite && iMode == ELatin 
       
  9832                     && !WesternPredictive()
       
  9833                     && iUncommittedText.iCursorPos < edSize 
       
  9834                     && iUncommittedText.Length() == 0)
       
  9835                     {
       
  9836                     // If the cursor is at the beginning or in the middle of the text,
       
  9837                     // existing characters are replaced with new ones in latin multitap input.
       
  9838                     iUncommittedText.iCursorPos++;
       
  9839                     StartInlineEditL(iUncommittedText, buf, ESingleCharacter, EFalse);
       
  9840                     }
       
  9841                 else
       
  9842                     {
       
  9843                     StartInlineEditL();
       
  9844                     }
       
  9845                 SetFlag(EFlagInsideMultitapInlineEditingTransaction);
       
  9846                 }
       
  9847             UpdateInlineEditL(buf, buf.Length());
       
  9848 
       
  9849             if( !EditorHasFreeSpace() )
       
  9850                 {
       
  9851                 SetFlag(EFlagLastCharacterInEditor);
       
  9852                 }
       
  9853             }
       
  9854         SetFlag(EFlagInsideInlineEditingTransaction);
       
  9855 
       
  9856         // Check if text needs to be committed   		
       
  9857         if( ( TAknFepUiIndicInputManager::IsToCommitCharSeq( aResponse ) ) )
       
  9858             {
       
  9859             CommitInlineEditL();    
       
  9860             }
       
  9861         if( aResponse == EIndicInputResponseInsertZWSandLigature )
       
  9862             {
       
  9863             NewCharacterL(aText);   
       
  9864             }    
       
  9865         else if( aResponse == EIndicInputResponseInsertViramaZWSandDirectLigature )
       
  9866             {
       
  9867             // Doing this here because we first commit the virama 
       
  9868             // and ZWS and keep the ligature in the inline buffer.
       
  9869             NewLigatureL( aText );
       
  9870             }
       
  9871         }
       
  9872     }
       
  9873 
       
  9874 void CAknFepManager::CommitInlineEditL()
       
  9875     {   
       
  9876     if ( !IsFlagSet( CAknFepManager::EFlagInsideInlineEditingTransaction ) )
       
  9877         {
       
  9878         return;
       
  9879         }
       
  9880 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  9881     // Before commit inline, check and close 
       
  9882     // tooltip on FSQ first.
       
  9883     SendEventsToPluginManL( EPluginHideTooltip );
       
  9884 
       
  9885     // Predictive QWERTY (XT9) changes ---->
       
  9886     // Exact word popup is hidden when the inline editor is closed
       
  9887     iExactWordPopupContent->HidePopUp();
       
  9888     // Predictive QWERTY (XT9) changes <----
       
  9889 #endif //RD_INTELLIGENT_TEXT_INPUT
       
  9890     if (iInputCapabilities.FepAwareTextEditor())
       
  9891 			{
       
  9892 	    if  (IsFlagSet(EFlagLineFeedCharacter))
       
  9893 	        {
       
  9894 	        if (iInputCapabilities.SupportsSecretText())
       
  9895 	            {
       
  9896 	            SimulateKeyEventL(EKeyF20); // backspace to delete previous char in secret text editor
       
  9897 	            SimulateKeyEventL(EKeyEnter);
       
  9898 	            SimulateKeyEventL(EKeyF19); // Asyncronous case update
       
  9899 	            }
       
  9900 	        else
       
  9901 	            {
       
  9902 	            __ASSERT_DEBUG(iInputCapabilities.FepAwareTextEditor(),
       
  9903 	                           AknFepPanic(EAknFepPanicNoHandleToFepAwareTextEditor));
       
  9904 	            iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL(ETrue);
       
  9905 	            iInputCapabilities.FepAwareTextEditor()->CancelFepInlineEdit();
       
  9906 	            
       
  9907 	            // Multitapping enter event is not posted for find pane.
       
  9908 	            // It would never accept it anyway but the event causes problems in gallery's find.
       
  9909 	            // Allow real enter from qwerty keyboard though.
       
  9910 	            if (!(iAknEditorFlags & EAknEditorFlagFindPane) || iQwertyInputMode)
       
  9911 	                {                
       
  9912 	                SimulateKeyEventL(EKeyEnter);
       
  9913 	                SimulateKeyEventL(EKeyF19); // Asyncronous case update
       
  9914 	                }            
       
  9915 	            }
       
  9916 	        }
       
  9917 	    else if (IsFlagSet(EFlagSpaceCharacter | EFlagFullWidthSpaceCharacter))
       
  9918 	        {
       
  9919 	        TBuf<ESingleCharacter> charAsDesc(ESingleCharacter);
       
  9920 	
       
  9921 	        if (IsFlagSet(EFlagSpaceCharacter))
       
  9922 	            {
       
  9923 	            charAsDesc[0] = TText(0x0020);      // 0x0020 is space
       
  9924 	            }
       
  9925 	        else
       
  9926 	            {
       
  9927 	            charAsDesc[0] = TText(0x3000);      // 0x3000 is full-width space
       
  9928 	            }
       
  9929 	
       
  9930 	        if (iInputCapabilities.SupportsSecretText())
       
  9931 	            {
       
  9932 	            SimulateKeyEventL(EKeyF20); // backspace to delete previous char in secret text editor
       
  9933 	            SimulateKeyEventL(charAsDesc[0]);
       
  9934 	            SimulateKeyEventL(EKeyF19); // Asyncronous case update
       
  9935 	            }
       
  9936 	        else
       
  9937 	            {
       
  9938 	            iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(charAsDesc, 1);
       
  9939 	            iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL(ETrue);
       
  9940 	            CCoeEnv* coeEnv = CCoeEnv::Static();
       
  9941 	            iInputCapabilities.FepAwareTextEditor()->CommitFepInlineEditL(*coeEnv);
       
  9942 	            iCaseMan->UpdateCase(ENullNaviEvent);
       
  9943 	            if (!EditorHasFreeSpace())
       
  9944 	                {
       
  9945 	                SetFlag(EFlagEditorFull);
       
  9946 	                }
       
  9947 	            else
       
  9948 	            	{
       
  9949 	            	ClearFlag(EFlagEditorFull);
       
  9950 	            	}
       
  9951 	            }
       
  9952 	        }
       
  9953 	    else if (IsFlagSet(EFlagInsideInlineEditingTransaction) 
       
  9954 	         && !iInputCapabilities.SupportsSecretText())
       
  9955 	        {
       
  9956 	        // Chinese languages seem not to support this
       
  9957 	        if ( !IsChineseInputLanguage() &&
       
  9958 	            (iUncommittedText.Length() == 0 || 
       
  9959 	                    (
       
  9960 	#ifdef RD_INTELLIGENT_TEXT_INPUT
       
  9961 	                    !IsAutoCompleteOn() &&
       
  9962 	#endif //RD_INTELLIGENT_TEXT_INPUT                    
       
  9963 	                    !EditorSupportsNeutralProtection()
       
  9964 	                    ) 
       
  9965 	            )
       
  9966 	           )
       
  9967 	                    
       
  9968 	            { // empty insertions need no resolution.
       
  9969 	            /*Hindi*/
       
  9970 	            if( (TAknFepUiIndicInputManager :: IsIndicLangauge(
       
  9971 	                      TLanguage(iLanguageCapabilities.iInputLanguageCode))) 
       
  9972 	#ifdef RD_HINDI_PHONETIC_INPUT
       
  9973 	                || ( TAknFepUiIndicInputManager :: IsIndicPhoneticLanguage(
       
  9974 	                      TLanguage(iLanguageCapabilities.iInputLanguageCode)) )
       
  9975 	#endif
       
  9976 	            )
       
  9977 	                {
       
  9978 	                // NOTE! Need to get cursor visibility information from some where.
       
  9979 	                CommitInlineEditWithoutResolutionL( *(iInputCapabilities.FepAwareTextEditor()), 
       
  9980 	                                                    ETrue, EFalse); 
       
  9981 	                }
       
  9982 	            else
       
  9983 	                {
       
  9984 	                // NOTE! Need to get cursor visibility information from some where.
       
  9985 	                CommitInlineEditWithoutResolutionL( *(iInputCapabilities.FepAwareTextEditor()), 
       
  9986 	                                                    ETrue);
       
  9987 	                }
       
  9988 	            }
       
  9989 	        else
       
  9990 	            {
       
  9991 	
       
  9992 	            //note secret text editors do not use the MCoeFepAwareTextEditor interface,
       
  9993 	            //we only need to clear the flags to 'commit' a character
       
  9994 	
       
  9995 	            __ASSERT_DEBUG(iInputCapabilities.FepAwareTextEditor(),
       
  9996 	                           AknFepPanic(EAknFepPanicNoHandleToFepAwareTextEditor));
       
  9997 	            CCoeEnv* coeEnv = CCoeEnv::Static();
       
  9998 	
       
  9999 	            TBool showCursor = ETrue;
       
 10000 	            if (IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) ||
       
 10001 	                IsCcpuFlagSet(ECcpuStateLosingFocus))
       
 10002 	                {
       
 10003 	                showCursor = EFalse;
       
 10004 	                }
       
 10005                 else
       
 10006                     {
       
 10007                     if(IsKoreanInputLanguage( ) && !IsQwerty() &&
       
 10008                     		IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
 10009                         {
       
 10010                         showCursor = EFalse;
       
 10011                         }
       
 10012                     }
       
 10013 
       
 10014 	            iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL(showCursor);
       
 10015 	            ClearFlag(EFlagInsideInlineEditingTransaction);
       
 10016 	            iInputCapabilities.FepAwareTextEditor()->CommitFepInlineEditL(*coeEnv);
       
 10017 	
       
 10018 	            // Arabic & Hebrew required functionality added ---->
       
 10019 	            if (IsFlagSet(EFlagInsideMultitapInlineEditingTransaction)) // Condition added for AknFep.
       
 10020 	                {
       
 10021 	                // 3 * as each original character can potentially take 2 markers
       
 10022 	                HBufC* decoratedTextBuf = HBufC::NewLC(KMaxInlineEditSize + 2); // +2 to accommodate previous and next charcaters
       
 10023 	                TPtr decoratedText = decoratedTextBuf->Des();
       
 10024 	                // Resolve in a slightly wider range than the new text. Attempt to expand 1 character in each direction
       
 10025 	                TCursorSelection resolveSpan(iUncommittedText.HigherPos(), 
       
 10026 	                                             iUncommittedText.LowerPos());
       
 10027 	                TInt decCursor = 0;
       
 10028 	
       
 10029 	                // Gets the CPlainText object from the focused editor if it exists.
       
 10030 	                CPlainText* plainText = PlainText();
       
 10031 	                TBool containsTextField = EFalse;
       
 10032 	                if (resolveSpan.iAnchorPos > 0)
       
 10033 	                    {
       
 10034 	                    if (plainText)
       
 10035 	                        {
       
 10036 	                        // Check if surrounding document position contains text field.
       
 10037 	                        containsTextField = plainText->FindFields(resolveSpan.iAnchorPos - 1);
       
 10038 	                        }
       
 10039 	                    TBuf<ESingleCharacter> chDes;
       
 10040 	                    iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep( chDes, 
       
 10041 	                                              resolveSpan.iAnchorPos - 1, ESingleCharacter);
       
 10042 	                    if ( chDes.Length() != 0 && chDes[0] != CEditableText::EPictureCharacter && !containsTextField)
       
 10043 	                        {
       
 10044 	                        // Resolve span is not extended if surrounding character is picture character or it
       
 10045 	                        // contains text field. Text field data would be lost when FEP replaces existing editor
       
 10046 	                        // content with new text buffer content that does not have text field data.
       
 10047 	                        // ResolveDecoratedText() call does not handle these special cases which can has some 
       
 10048 	                        // effects to Arabic & Hebrew text rendering.
       
 10049 	                        resolveSpan.iAnchorPos--;
       
 10050 	                        }
       
 10051 	                    }
       
 10052 	                if (resolveSpan.iCursorPos < 
       
 10053 	                    iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep())
       
 10054 	                    {
       
 10055 	                    containsTextField = EFalse;
       
 10056 	                    if (plainText)
       
 10057 	                        {
       
 10058 	                        // Check if surrounding document position contains text fields.
       
 10059 	                        containsTextField = plainText->FindFields(resolveSpan.iCursorPos);
       
 10060 	                        }
       
 10061 	                    TBuf<ESingleCharacter> chDes;
       
 10062 	                    iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep( chDes, 
       
 10063 	                                                  resolveSpan.iCursorPos, ESingleCharacter);
       
 10064 	                    if ( chDes.Length() != 0 && chDes[0] != CEditableText::EPictureCharacter && !containsTextField)
       
 10065 	                        {
       
 10066 	                        // Resolve span is not extended if surrounding character is picture character or it
       
 10067 	                        // contains text field. Text field data would be lost when FEP replaces existing editor
       
 10068 	                        // content with new text buffer content that does not have text field data.
       
 10069 	                        // ResolveDecoratedText() call does not handle these special cases which can has some 
       
 10070 	                        // effect to Arabic & Hebrew text rendering.
       
 10071 	                        resolveSpan.iCursorPos++;
       
 10072 	                        decCursor++;
       
 10073 	                        }
       
 10074 	                    }
       
 10075 	
       
 10076 	                // resolveSpan has been widened. Now go get the text for that span.
       
 10077 	                iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(decoratedText, 
       
 10078 	                                                 resolveSpan.iAnchorPos, resolveSpan.Length());
       
 10079 	
       
 10080 	                if ( decoratedText.Length() != resolveSpan.Length() )
       
 10081 	                    {
       
 10082 	                    // This assert checks is we have failed to retrieve enough text.  Should not happen
       
 10083 	                    // __ASSERT_DEBUG( decoratedText.Length() == resolveSpan.Length(),  Panic(EEikPanicT9CharPosOutOfRange) );
       
 10084 	                    // Abondon the resolution.
       
 10085 	
       
 10086 	                    iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL( ETrue );
       
 10087 	                    }
       
 10088 	                else
       
 10089 	                    {
       
 10090 	                    TInt lowerOffset = iUncommittedText.LowerPos() - resolveSpan.LowerPos();
       
 10091 	
       
 10092 	                    TBool needsResolving = iInlineTextDecorator->ResolveDecoratedText(decoratedText,
       
 10093 	                        TCursorSelection(lowerOffset, lowerOffset + iUncommittedText.Length()));
       
 10094 	
       
 10095 	                    if ( needsResolving )
       
 10096 	                        {                      
       
 10097 	                        TBool setToTrue=EFalse;
       
 10098 	                        iInputCapabilities.FepAwareTextEditor()->Extension1()->StartFepInlineEditL(
       
 10099 	                            setToTrue,
       
 10100 	                            resolveSpan,
       
 10101 	                            decoratedText,
       
 10102 	                            decoratedText.Length() - decCursor,
       
 10103 	                            EFalse,
       
 10104 	                            0, // MFormCustomDrawer*
       
 10105 	                            *this,
       
 10106 	                            *this);
       
 10107 	
       
 10108 	                        iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL( ETrue );
       
 10109 	                        if (IsFeatureSupportedJapanese())
       
 10110 	                            {
       
 10111 	                            // need to call clear buffer of PtiEngine for Japanese varint
       
 10112 	                            // before calling second CommitFepInlineEditL().
       
 10113 	                            // because the committed string is set as reading string twice
       
 10114 	                            iPtiEngine->ClearCurrentWord();
       
 10115 	                            }
       
 10116 	                        iInputCapabilities.FepAwareTextEditor()->CommitFepInlineEditL(*coeEnv);
       
 10117 	                        }
       
 10118 	                    else
       
 10119 	                        {
       
 10120                             // Line cursor is made invisible here.  There is no line cursor in S60 LAF, even though there is
       
 10121                             // an Edwin flag which govern this.  See CEikEdwin::SetCursorVisibilityL(TBool)
       
 10122                             // Cursor is not set if this CommitInlineEditL call was prompted when losing focus.
       
 10123 	                        MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 10124                             
       
 10125                             // Use FepAwareTextEditor to judge, not use TextView()
       
 10126                             if ( (docNavi || FepAwareTextEditor()) && !IsCcpuFlagSet(ECcpuStateLosingFocus) )
       
 10127                                 {
       
 10128                                 if (docNavi)
       
 10129                                     {
       
 10130                                     docNavi->SetCursorVisibilityL( TCursor::EFCursorInvisible, 
       
 10131                                                                  TCursor::EFCursorFlashing );
       
 10132                                     }
       
 10133                                 else 
       
 10134                                     {
       
 10135                                     //Use Edwin (FepAwareTextEditor) to set cursor visibility
       
 10136                                     FepAwareTextEditor()->SetInlineEditingCursorVisibilityL( ETrue );
       
 10137                                     }
       
 10138                                 }
       
 10139 	                        }
       
 10140 	                    }
       
 10141 	                // iMatchState=EWordMatchFirst;
       
 10142 	
       
 10143 	                CleanupStack::PopAndDestroy(); // decoratedTextBuf
       
 10144 	                }
       
 10145 	            if (iInputCapabilities.FepAwareTextEditor())
       
 10146 	                {
       
 10147 	                iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);   
       
 10148 	                }
       
 10149 	            
       
 10150 	            iCaseMan->UpdateCase(ENullNaviEvent);
       
 10151 	            // <---- Arabic & Hebrew required functionality added
       
 10152 	            if (!EditorHasFreeSpace())
       
 10153 	                {
       
 10154 	                SetFlag(EFlagEditorFull);
       
 10155 	                }
       
 10156 	            else
       
 10157 	            	{
       
 10158 	            	ClearFlag(EFlagEditorFull);
       
 10159 	            	}
       
 10160 	            }
       
 10161 	        }
       
 10162 	    else if (IsFlagSet(EFlagInsideInlineEditingTransaction) 
       
 10163 	          && iInputCapabilities.SupportsSecretText())
       
 10164 	        {
       
 10165 	        CCoeEnv* coeEnv = CCoeEnv::Static();
       
 10166 	        iInputCapabilities.FepAwareTextEditor()->CommitFepInlineEditL(*coeEnv);
       
 10167 	        iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 10168 	        
       
 10169 	        if (iQwertyInputMode)
       
 10170 	            {
       
 10171 	            // Case may need to updated automatically in case of qwerty secret text editor
       
 10172 	            // beause of the sticky shift feature.
       
 10173 	            if (iCaseMan->CurrentCase() == EAknEditorLowerCase)
       
 10174 	                {
       
 10175 	                SetCase(ELowerCase);            
       
 10176 	                }
       
 10177 	            else
       
 10178 	                {
       
 10179 	                SetCase(EUpperCase);                        
       
 10180 	                }               
       
 10181 	            UpdateIndicators();         
       
 10182 	            }
       
 10183 	        }
       
 10184 			}
       
 10185     
       
 10186 //    SendEventsToPluginManL( EPluginSyncFepAwareText, EPluginSyncUpdatedText );
       
 10187       
       
 10188     ClearFlag(EFlagInsideMultitapInlineEditingTransaction | EFlagInsideInlineEditingTransaction |
       
 10189         EFlagLineFeedCharacter | EFlagLastCharacterInEditor | EFlagSpaceCharacter |
       
 10190         EFlagFullWidthSpaceCharacter);
       
 10191         
       
 10192     // No-edit_key devices: Inline editing ending, allow edit-menu again.    
       
 10193     ClearCcpuFlag(ECcpuStateIgnoreStarUp | ECcpuStateNewPredictiveWord);        
       
 10194 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10195     iUncommittedText.iCursorPos=0;
       
 10196     iUncommittedText.iAnchorPos=0;
       
 10197 #endif 
       
 10198     if (!iInputCapabilities.FepAwareTextEditor())
       
 10199         {
       
 10200         // In case while updating the inline edit, 3rd party app removes the focus out of editor before the transaction
       
 10201         // completes, we return with an error.
       
 10202         User::Leave(KErrCorrupt);
       
 10203         }
       
 10204 
       
 10205     }
       
 10206 
       
 10207 void CAknFepManager::CommitInlineEditL(const TDesC& aText, TInt aUncommitedTextChange)
       
 10208     {
       
 10209     if (iMode == EHiraganaKanji)
       
 10210         {
       
 10211         // When there is not enough editing space to enter the selected candidate,
       
 10212         // the error tone is played.
       
 10213         if ((iFreeSpaceOfEditor > 0) && (iFreeSpaceOfEditor < aText.Length()))
       
 10214             {
       
 10215             PlaySound(EAvkonSIDErrorTone);
       
 10216             }
       
 10217         }
       
 10218 
       
 10219     //maxLength of 0 means the editor has no limit
       
 10220     TInt maxEdSize = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
 10221     if ( maxEdSize != 0 && iFreeSpaceOfEditor < aText.Length())
       
 10222         {
       
 10223         TPtrC charbuf = aText.Left(iFreeSpaceOfEditor);
       
 10224         TInt uncommitedTextChange = charbuf.Length();
       
 10225         UpdateInlineEditL(charbuf, uncommitedTextChange);
       
 10226         }
       
 10227     else
       
 10228         {
       
 10229         UpdateInlineEditL(aText, aUncommitedTextChange);
       
 10230         }
       
 10231 
       
 10232     ClearFlag(EFlagInsideMultitapInlineEditingTransaction);
       
 10233     CommitInlineEditL();
       
 10234     }
       
 10235 
       
 10236 void CAknFepManager::CancelInlineEdit()
       
 10237     {
       
 10238     if( !EditorState()->CurrentInlineEditSpan().Length() )
       
 10239     	{
       
 10240     	ClearFlag(EFlagInsideInlineEditingTransaction);
       
 10241     	if(IsFlagSet(CAknFepManager::EFlagNoMatches))
       
 10242     		{
       
 10243     		ClearFlag(CAknFepManager::EFlagNoMatches); 
       
 10244     		}
       
 10245     	}
       
 10246     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
 10247         {
       
 10248         TRAP_IGNORE(TryRemoveNoMatchesIndicatorL());
       
 10249 
       
 10250         if (iInputCapabilities.SupportsSecretText())
       
 10251             {
       
 10252             TRAP_IGNORE(SimulateKeyEventL(EKeyF20)); // backspace to delete previous char in secret text editor
       
 10253             }
       
 10254         else if (IsFeatureSupportedJapanese()
       
 10255               && iFepManState == EAknFepStateUIActive)
       
 10256             {
       
 10257             FepUI()->CloseUI();
       
 10258             FepUI()->ExpireMultitapTimer();
       
 10259             iPtiEngine->ClearCurrentWord();
       
 10260             SyncStates(EAknFepStateInitial);
       
 10261             }
       
 10262         }
       
 10263 
       
 10264     iUncommittedText.iCursorPos=0;
       
 10265     
       
 10266     iUncommittedText.iAnchorPos=0;
       
 10267     
       
 10268     iInputCapabilities.FepAwareTextEditor()->CancelFepInlineEdit();
       
 10269     ClearFlag(EFlagInsideMultitapInlineEditingTransaction | EFlagInsideInlineEditingTransaction 
       
 10270               | EFlagLineFeedCharacter | EFlagSpaceCharacter | EFlagFullWidthSpaceCharacter);
       
 10271     ClearCcpuFlag(ECcpuStateNewPredictiveWord);    
       
 10272     }
       
 10273 
       
 10274 void CAknFepManager::GetScreenCoordinatesL(TPoint& aLeftSideOfBaseLine, TInt& aHeight, 
       
 10275                                            TInt& aAscent, TInt aDocumentOffset)
       
 10276     {
       
 10277     TCursorSelection cursorSelection;
       
 10278     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSelection);
       
 10279     TInt documentPosition = cursorSelection.LowerPos()  - aDocumentOffset;
       
 10280     if (documentPosition < 0)
       
 10281         documentPosition = 0;
       
 10282     iInputCapabilities.FepAwareTextEditor()->GetScreenCoordinatesForFepL(aLeftSideOfBaseLine, 
       
 10283                                                           aHeight, aAscent, documentPosition);
       
 10284     }
       
 10285 
       
 10286 void CAknFepManager::GetScreenCoordinatesL(TPoint& aLeftSideOfBaseLine, 
       
 10287                                            TInt& aHeight, TInt& aAscent)
       
 10288     {
       
 10289     TCursorSelection cursorSelection;
       
 10290     MCoeFepAwareTextEditor* fepAwareTextEditor = iInputCapabilities.FepAwareTextEditor();
       
 10291 
       
 10292     fepAwareTextEditor->GetCursorSelectionForFep(cursorSelection);
       
 10293     fepAwareTextEditor->GetScreenCoordinatesForFepL(aLeftSideOfBaseLine, aHeight, aAscent, 
       
 10294                                                     cursorSelection.LowerPos());
       
 10295     }
       
 10296 
       
 10297 TBool CAknFepManager::EditorHasFreeSpace( TInt aRequiredNumberOfCharacter ) const
       
 10298     {
       
 10299     TBool unlimit = EFalse;
       
 10300     TInt freeSpace = 0;
       
 10301 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10302 	if(WesternPredictive())
       
 10303 	    {
       
 10304 	    freeSpace = EditorFreeSpaceForAutoWordCompletion(unlimit);	
       
 10305 	    }
       
 10306 	else
       
 10307 		{
       
 10308 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 10309     	freeSpace = EditorFreeSpace(unlimit);			
       
 10310 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10311 		}
       
 10312 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 10313     if( unlimit || freeSpace > aRequiredNumberOfCharacter )
       
 10314         {
       
 10315         return ETrue;
       
 10316         }
       
 10317     return EFalse;
       
 10318     }
       
 10319     
       
 10320 // -----------------------------------------------------------------------------
       
 10321 // check whether the current editor is a Java secret editor
       
 10322 // ----------------------------------------------------------------------------- 
       
 10323 TBool CAknFepManager::IsJavaSecretEditor()
       
 10324     {
       
 10325     TBool JavaSecretEditor = EFalse;
       
 10326     
       
 10327     TUint ConstraintValue = 0;
       
 10328     MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
 10329     
       
 10330     if ( mop )
       
 10331         {
       
 10332         CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
 10333         mop->MopGetObject( extendedInputCapabilities );
       
 10334         if ( extendedInputCapabilities && iInputCapabilities.FepAwareTextEditor() ) 
       
 10335             {
       
 10336             ConstraintValue = extendedInputCapabilities->MIDPConstrainst();
       
 10337             }
       
 10338         }
       
 10339     if( ConstraintValue & 0x10000 ) 
       
 10340         {
       
 10341         JavaSecretEditor = ETrue;
       
 10342         }
       
 10343     
       
 10344     return JavaSecretEditor;
       
 10345     }       
       
 10346 
       
 10347 TBool CAknFepManager::IsEditorHasFreeSpace() const
       
 10348     {
       
 10349     TBool unlimit = EFalse;
       
 10350     TInt freeSpace = 0;
       
 10351 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10352 	if(WesternPredictive())
       
 10353 	    {
       
 10354 	    freeSpace = EditorFreeSpaceForAutoWordCompletion(unlimit);	
       
 10355 	    }
       
 10356 	else
       
 10357 		{
       
 10358 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 10359     	freeSpace = EditorFreeSpace(unlimit);			
       
 10360 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10361 		}
       
 10362 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 10363     if( unlimit || freeSpace > 0 )
       
 10364         {
       
 10365         return ETrue;
       
 10366         }
       
 10367     return EFalse;
       
 10368     }
       
 10369     
       
 10370 TInt CAknFepManager::EditorFreeSpace(TBool& aUnlimit, 
       
 10371     TBool isToCountUncommittedTextLength /*= EFalse */) const
       
 10372     {
       
 10373     aUnlimit = EFalse;
       
 10374 
       
 10375     if (!iInputCapabilities.FepAwareTextEditor())
       
 10376         {
       
 10377         //no handle to MCoeFepAwareTextEditor in non Edwin derived editors
       
 10378         return 0;
       
 10379         }
       
 10380 
       
 10381     //maxLength of 0 means the editor has no limit
       
 10382     TInt maxEdSize = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
 10383     TCursorSelection currentSelection;
       
 10384     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(currentSelection);
       
 10385 
       
 10386     aUnlimit = (maxEdSize == 0 || ((iAknEditorFlags & EAknEditorFlagMTAutoOverwrite) &&
       
 10387                                    (currentSelection.iCursorPos >= 0 && 
       
 10388                                     currentSelection.iCursorPos < maxEdSize) ));
       
 10389     if(aUnlimit)
       
 10390         {
       
 10391         return 0;
       
 10392         }
       
 10393 
       
 10394     TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 10395 
       
 10396     if( isToCountUncommittedTextLength )
       
 10397         {
       
 10398         return ( maxEdSize - edSize + 
       
 10399             currentSelection.Length() + UncommittedText().Length() );
       
 10400         }
       
 10401     
       
 10402     return (maxEdSize - edSize + currentSelection.Length());
       
 10403 
       
 10404     }
       
 10405 
       
 10406 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 10407 TInt CAknFepManager::EditorFreeSpaceForAutoWordCompletion(TBool& aUnlimit, 
       
 10408     TBool /* isToCountUncommittedTextLength = EFalse*/ ) const
       
 10409     {
       
 10410     aUnlimit = EFalse;
       
 10411 
       
 10412     if (!iInputCapabilities.FepAwareTextEditor())
       
 10413         {
       
 10414         //no handle to MCoeFepAwareTextEditor in non Edwin derived editors
       
 10415         return 0;
       
 10416         }
       
 10417 
       
 10418     //maxLength of 0 means the editor has no limit
       
 10419     TInt maxEdSize = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
 10420     TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 10421     TInt keySequenceLength = iPtiEngine->CurrentInputSequence().Length();
       
 10422     TCursorSelection currentSelectionOrUncommitted;    
       
 10423 	iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(currentSelectionOrUncommitted);
       
 10424 
       
 10425     aUnlimit = (maxEdSize == 0 || ((iAknEditorFlags & EAknEditorFlagMTAutoOverwrite) &&
       
 10426                                    (currentSelectionOrUncommitted.iCursorPos >= 0 && 
       
 10427                                     currentSelectionOrUncommitted.iCursorPos < maxEdSize) ));
       
 10428     if(aUnlimit)
       
 10429         {
       
 10430         return 0;
       
 10431         }
       
 10432     else
       
 10433         {
       
 10434 
       
 10435         if ( !iQwertyInputMode )
       
 10436             {
       
 10437             return ( maxEdSize - edSize + currentSelectionOrUncommitted.Length() );
       
 10438             }
       
 10439         else
       
 10440             {
       
 10441             // In the predictive QWERTY mode, the keySequenceLength doesn't necessarily have anything
       
 10442             // to do with the amount of characters on screen. At least entering accented characters with
       
 10443             // Chr-multitapping will increase the key sequence length although number of characters 
       
 10444             // doesn't change (this is either bug or feature of ZiCore). Ask the auto-completion
       
 10445             // length directly from PtiEngine instead of trying to calculate it on our own.
       
 10446             TInt tailLength = 0;
       
 10447             TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength ));
       
 10448             if( tailLength < 0 )
       
 10449              {
       
 10450              tailLength = 0;
       
 10451              }
       
 10452             return (maxEdSize - edSize + currentSelectionOrUncommitted.Length() + tailLength);
       
 10453             }
       
 10454         }
       
 10455     }
       
 10456 #endif
       
 10457 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
 10458 #ifdef RD_INTELLIGENT_TEXT_INPUT  
       
 10459 
       
 10460 TInt CAknFepManager::DocumentLength() const
       
 10461     {
       
 10462     TInt ret = 0;
       
 10463     if ( iInputCapabilities.FepAwareTextEditor() )
       
 10464         {
       
 10465         ret = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 10466         }
       
 10467     return ret;
       
 10468     }
       
 10469     
       
 10470 TBool CAknFepManager::KeyEventWillReplaceCharacter( const TKeyEvent& aKeyEvent )
       
 10471     {
       
 10472     // The function is currently used only in QWERTY mode. It might not work correctly
       
 10473     // with ITU-T input.
       
 10474     TBool ret = EFalse;
       
 10475     if ( IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) )
       
 10476         {
       
 10477         // Multitapping
       
 10478         ret = ETrue;
       
 10479         }
       
 10480     else if ( aKeyEvent.iRepeats &&
       
 10481               LongPressNumberEntryOnQwerty() &&
       
 10482               FnKeyState() == CAknFepFnKeyManager::EFnKeyNone &&
       
 10483               KeyMapsDifferentCharacterWithFn( (TPtiKey)aKeyEvent.iScanCode ) )
       
 10484         {
       
 10485         // QWERTY key long press producing another charcter
       
 10486         ret = ETrue;
       
 10487         }
       
 10488     return ret;    
       
 10489     }
       
 10490 #endif
       
 10491 #endif
       
 10492 TChar CAknFepManager::CurrentDecimalSeparator() const
       
 10493     {
       
 10494     TLocale tLoc;
       
 10495     return tLoc.DecimalSeparator();
       
 10496     }
       
 10497 
       
 10498 void CAknFepManager::ConfigureFEPFromEditorStateL()
       
 10499     {
       
 10500     User::LeaveIfError(SyncStates(EAknFepStateInitial));
       
 10501 
       
 10502     CAknEdwinState* editorState = EditorState();
       
 10503     TInt editorMode = editorState->CurrentInputMode();
       
 10504     TInt sharedDataMode = iSharedDataInterface->InputMode();
       
 10505     TBool latinCaseSet = EFalse;
       
 10506     iPermittedInputModes = editorState->PermittedInputModes();
       
 10507     TInt defaultInputMode = editorState->DefaultInputMode();
       
 10508     if(iAknEditorFlags != editorState->Flags())
       
 10509         {
       
 10510         iAknEditorFlags = editorState->Flags();
       
 10511         UpdateLocalDigitMode();
       
 10512         }
       
 10513     iAknEditorNumericKeymap = editorState->NumericKeymap();
       
 10514 
       
 10515     TLanguage localLanguage = ELangTest;
       
 10516     if (GetLocalLanguage( localLanguage ) )
       
 10517         {
       
 10518         iLanguageCapabilities.iLocalInputLanguageInUse = ETrue;
       
 10519         if ( localLanguage != iLanguageCapabilities.iInputLanguageCode )
       
 10520             {
       
 10521             ChangeInputLanguageL(localLanguage);
       
 10522             }
       
 10523         }
       
 10524     else if (iLanguageCapabilities.iLocalInputLanguageInUse)
       
 10525         {
       
 10526         ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
 10527         iLanguageCapabilities.iLocalInputLanguageInUse = EFalse;
       
 10528         ClearFlag(EFlagNewSharedDataInputMode);
       
 10529 		}
       
 10530 
       
 10531     if (IsFlagSet(EFlagNewSharedDataInputLanguage) )
       
 10532         {
       
 10533         //Global mode or input language has been changed in general settings
       
 10534         if ( !iLanguageCapabilities.iLocalInputLanguageInUse)
       
 10535             {
       
 10536             ChangeInputLanguageL(iSharedDataInterface->InputTextLanguage());
       
 10537             }
       
 10538         ClearFlag(EFlagNewSharedDataInputLanguage);
       
 10539         }
       
 10540 
       
 10541     if (IsFeatureSupportedJapanese())
       
 10542         {
       
 10543         // set Japanese predicitve ON/OFF
       
 10544         if (iAknEditorFlags & EAknEditorFlagNoT9)
       
 10545             {
       
 10546             iJapanesePredictive = EFalse;
       
 10547             }
       
 10548         else
       
 10549             {
       
 10550             // Is it supported Japanese predictive input
       
 10551             if (HasJapanesePredictionInputMode())
       
 10552                 {
       
 10553                 iJapanesePredictive = iSharedDataInterface->PredictiveTextJapaneseOn();
       
 10554                 }
       
 10555             else
       
 10556                 {
       
 10557                 // if Predictive Japanese input isn't supported in PtiEngine, set to OFF.
       
 10558                 iJapanesePredictive = EFalse;
       
 10559                 iSharedDataInterface->ResetJapanesePredictiveTextOn();
       
 10560                 }
       
 10561             }
       
 10562 
       
 10563         // In Japanese variant, EAknEditorTextInputMode of allow input mode
       
 10564         // means all input mode.
       
 10565         if (iPermittedInputModes & EAknEditorTextInputMode)
       
 10566             {
       
 10567             iPermittedInputModes |= (EAknEditorKatakanaInputMode |
       
 10568                                     EAknEditorHalfWidthTextInputMode |
       
 10569                                     EAknEditorFullWidthTextInputMode |
       
 10570                                     EAknEditorFullWidthNumericInputMode |
       
 10571                                     EAknEditorFullWidthKatakanaInputMode |
       
 10572                                     EAknEditorHiraganaKanjiInputMode |
       
 10573                                     EAknEditorHiraganaInputMode);
       
 10574             }
       
 10575 
       
 10576         if (iAknEditorFlags & EAknEditorFlagLatinInputModesOnly)
       
 10577             {
       
 10578             if (iPermittedInputModes == EAknEditorNumericInputMode)
       
 10579                 {
       
 10580                 iPermittedInputModes = EAknEditorNumericInputMode;
       
 10581                 }
       
 10582             else if (iPermittedInputModes & EAknEditorNumericInputMode)
       
 10583                 {
       
 10584                 iPermittedInputModes = (EAknEditorHalfWidthTextInputMode 
       
 10585                                       | EAknEditorNumericInputMode);
       
 10586                 }
       
 10587             else
       
 10588                 {
       
 10589                 iPermittedInputModes = EAknEditorHalfWidthTextInputMode;
       
 10590                 }
       
 10591             }
       
 10592 
       
 10593         if (editorMode)
       
 10594             {
       
 10595             editorMode = ConfigureFepModeFromEditorMode(editorMode);
       
 10596             }
       
 10597         else // for new editors
       
 10598             {
       
 10599             iCharWidth = EHalfWidthChar;
       
 10600             sharedDataMode = EHiraganaKanji;
       
 10601             // First input mode is changed to Latin from Hiragana/Kanji
       
 10602             // if display language is English.
       
 10603             TInt dispLang = iSharedDataInterface->DisplayLanguage();
       
 10604             // ELangTest means Automatic as display language in GS
       
 10605             if (dispLang == ELangTest)
       
 10606                 {
       
 10607                 // UiLanguage isn't Japanese, Latin is set.
       
 10608                 if (iUiLanguage != ELangJapanese)
       
 10609                     {
       
 10610                     sharedDataMode = ELatin;
       
 10611                     }
       
 10612                 }
       
 10613             else if (dispLang != ELangJapanese)
       
 10614                 {
       
 10615                 // Display language isn't Japanese, Latin is set.
       
 10616                 sharedDataMode = ELatin;
       
 10617                 }
       
 10618 
       
 10619             if (!(iPermittedInputModes & EAknEditorHiraganaKanjiInputMode))
       
 10620                 {
       
 10621                 if (IsOnlyFullWidthCharacterPermitted())
       
 10622                     {
       
 10623                     iCharWidth = EFullWidthChar;
       
 10624                     }
       
 10625                 else if (IsOnlyHalfWidthCharacterPermitted())
       
 10626                     {
       
 10627                     iCharWidth = EHalfWidthChar;
       
 10628                     }
       
 10629 
       
 10630                 if (iPermittedInputModes & (EAknEditorKatakanaInputMode |
       
 10631                                         EAknEditorFullWidthKatakanaInputMode))
       
 10632                     {
       
 10633                     // In case setting Latin as above, Latin is used preferentially.
       
 10634                     if (sharedDataMode == ELatin
       
 10635                      && (iPermittedInputModes & 
       
 10636                            (EAknEditorHalfWidthTextInputMode | EAknEditorFullWidthTextInputMode)))
       
 10637                         {
       
 10638                         sharedDataMode = ELatin;
       
 10639                         }
       
 10640                     else
       
 10641                         {
       
 10642                         sharedDataMode = EKatakana;
       
 10643                         }
       
 10644                     }
       
 10645                 else if (iPermittedInputModes & (EAknEditorHalfWidthTextInputMode |
       
 10646                                              EAknEditorFullWidthTextInputMode))
       
 10647                     {
       
 10648                     sharedDataMode = ELatin;
       
 10649                     }
       
 10650                 else if (iPermittedInputModes & (EAknEditorNumericInputMode |
       
 10651                                                  EAknEditorFullWidthNumericInputMode))
       
 10652                     {
       
 10653                     sharedDataMode = ENumber;
       
 10654                     }
       
 10655                 // First input mode is changed to latin from katakana
       
 10656                 // if display language is English.
       
 10657                 if (!(dispLang == ELangTest || dispLang == ELangJapanese))
       
 10658                     {
       
 10659                     if ((iPermittedInputModes &  EAknEditorKatakanaInputMode) &&
       
 10660                         (iPermittedInputModes & EAknEditorHalfWidthTextInputMode))
       
 10661                         {
       
 10662                         sharedDataMode = ELatin;
       
 10663                         }
       
 10664 
       
 10665                     if ((iPermittedInputModes &  EAknEditorKatakanaInputMode) &&
       
 10666                         (iPermittedInputModes & EAknEditorFullWidthTextInputMode))
       
 10667                         {
       
 10668                         sharedDataMode = ELatin;
       
 10669                         }
       
 10670                     }
       
 10671                 }
       
 10672             }
       
 10673         }
       
 10674     else // for other variants (western or chinese)
       
 10675         {
       
 10676         if (!(iPermittedInputModes & (EAknEditorTextInputMode | EAknEditorNumericInputMode 
       
 10677             | EAknEditorSecretAlphaInputMode)))
       
 10678             {
       
 10679             // Any latin input mode is not permitted by the editor.
       
 10680             // For compatibility permitted japanese input modes are checked and
       
 10681             // corresponding latin input modes are allowed.
       
 10682             if ( iPermittedInputModes & ( EAknEditorKatakanaInputMode |
       
 10683                                     EAknEditorHalfWidthTextInputMode |
       
 10684                                     EAknEditorFullWidthTextInputMode |
       
 10685                                     EAknEditorFullWidthKatakanaInputMode |
       
 10686                                     EAknEditorHiraganaKanjiInputMode |
       
 10687                                     EAknEditorHiraganaInputMode
       
 10688                                     | EAknEditorHangulInputMode ) )
       
 10689                 {
       
 10690                 iPermittedInputModes |= EAknEditorTextInputMode;
       
 10691                 }
       
 10692             if ( iPermittedInputModes & EAknEditorFullWidthNumericInputMode )
       
 10693                 {
       
 10694                 iPermittedInputModes |= EAknEditorNumericInputMode;
       
 10695                 }
       
 10696 
       
 10697             if ( !(defaultInputMode & (EAknEditorTextInputMode | EAknEditorNumericInputMode)))
       
 10698                 {
       
 10699                 if ( defaultInputMode & ( EAknEditorKatakanaInputMode |
       
 10700                                     EAknEditorHalfWidthTextInputMode|
       
 10701                                     EAknEditorFullWidthTextInputMode |
       
 10702                                     EAknEditorFullWidthKatakanaInputMode |
       
 10703                                     EAknEditorHiraganaKanjiInputMode |
       
 10704                                     EAknEditorHiraganaInputMode
       
 10705                                     | EAknEditorHangulInputMode ) )
       
 10706                     {
       
 10707                     defaultInputMode = EAknEditorTextInputMode;
       
 10708                     }
       
 10709                 else if (defaultInputMode & EAknEditorFullWidthNumericInputMode)
       
 10710                     {
       
 10711                     defaultInputMode = EAknEditorNumericInputMode;
       
 10712                     }
       
 10713                 }
       
 10714             }
       
 10715         }
       
 10716 
       
 10717     // object provider items
       
 10718     iEditMenuBar = NULL;
       
 10719     editorState->SetMenu();
       
 10720     editorState->SetCba();
       
 10721 
       
 10722 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
 10723     iOptionsMenuBar = NULL;
       
 10724 #endif    
       
 10725 
       
 10726     SetWesternPredictive(iSharedDataInterface->PredictiveTextOn());
       
 10727     //check that we don't have a Chinese find mode saved to an editor that is
       
 10728     //not a Chinese find pane
       
 10729     __ASSERT_DEBUG( !((editorMode == EZhuyinFind || editorMode == EStrokeFind) &&
       
 10730         !(iAknEditorFlags & EAknEditorFlagForceTransparentFepModes))
       
 10731         , AknFepPanic(EAknFepPanicFindModeSavedToNonFindEditor));
       
 10732 
       
 10733     ReadHashKeyLoopL();
       
 10734 
       
 10735     UpdateNumericEditorDigitType();
       
 10736     if ( IsMfneEditor() ) 
       
 10737         {
       
 10738         UpdateLocalDigitMode();
       
 10739         }
       
 10740     
       
 10741     if (editorMode) //should be an editor that has been used before
       
 10742         {
       
 10743         if (IsFlagSet(EFlagNewSharedDataInputMode) && (IsModePermitted(sharedDataMode)) && !IsKoreanInputLanguage()
       
 10744                 && (!(iAknEditorFlags & EAknEditorFlagForceTransparentFepModes)))
       
 10745             {
       
 10746             
       
 10747                 {
       
 10748                 //change to global mode, except in Find Pane, where we ignore
       
 10749                 //GS setting
       
 10750                 TryChangeModeL(sharedDataMode);
       
 10751                 ClearFlag(EFlagNewSharedDataInputMode);
       
 10752                 latinCaseSet = sharedDataMode & (ELatinUpper | ELatinLower);
       
 10753                 if (sharedDataMode == ELatinText)
       
 10754                     {
       
 10755                     editorState->SetFlags( editorState->Flags() & ~EFlagSupressAutoUpdate );
       
 10756                     }
       
 10757                 }
       
 10758             }
       
 10759 
       
 10760         // Next two cases are apps/UI intitialinsg their editors in the
       
 10761         // with the modes defined in uikon.hrh, change these to an appropriate
       
 10762         // FEP mode
       
 10763         else if (editorMode == EAknEditorNumericInputMode)
       
 10764             {
       
 10765             iCharWidth = EHalfWidthChar;
       
 10766             if ( (iMode == ENumber || iMode == ENativeNumber) && 
       
 10767                  IsModePermitted(iMode))
       
 10768                 {
       
 10769                 TryChangeModeL( iMode );
       
 10770                 }
       
 10771             else if ( IsInputModeAvailable(ENativeNumber) &&
       
 10772                  ( iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic || 
       
 10773                    iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ||
       
 10774                    iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ) )
       
 10775                 {
       
 10776                 TryChangeModeL( ENativeNumber );
       
 10777                 }
       
 10778             else
       
 10779                 {
       
 10780                 TryChangeModeL( ENumber );
       
 10781                 }
       
 10782             }
       
 10783         else if (editorMode == EAknEditorSecretAlphaInputMode)
       
 10784             {
       
 10785             //this is safe default as it is currently allowed in all FEPs
       
 10786             SetWesternPredictive(EFalse);
       
 10787             TryChangeModeL(ELatin);
       
 10788             }
       
 10789         else if (editorMode == EAknEditorTextInputMode)
       
 10790             {        
       
 10791             if (IsKoreanInputLanguage())
       
 10792             	{
       
 10793                 if( iMode == EAknEditorNullInputMode )
       
 10794             		{
       
 10795             		SetWesternPredictive(EFalse);
       
 10796          			TryChangeModeL(EHangul);
       
 10797             		}
       
 10798             	else
       
 10799             		{
       
 10800             		TryChangeModeL(ELatin);
       
 10801             		}
       
 10802             	}
       
 10803             else
       
 10804             	{
       
 10805             	//this is safe default as it is currently allowed in all FEPs
       
 10806             	TryChangeModeL(ELatin); 
       
 10807             	}
       
 10808             }
       
 10809         else if ( editorMode == EAknEditorHangulInputMode )
       
 10810         	{
       
 10811             // Choose EHangul as the current fep mode 
       
 10812             // if the editor mode stored in editor state is EAknEditorHangulInputMode. 
       
 10813             TryChangeModeL(EHangul);        
       
 10814         	}        
       
 10815         else if (!iStrokeUsedInQWERTY)
       
 10816         	{
       
 10817         	if (editorMode == EStroke && sharedDataMode == ECangJie)
       
 10818         		{
       
 10819         		TryChangeModeL(sharedDataMode);
       
 10820         		}
       
 10821         	else
       
 10822         		{
       
 10823         		TryChangeModeL(editorMode);
       
 10824         		}
       
 10825         	}
       
 10826         else  //normal case, use locally stored mode
       
 10827             {
       
 10828             if (editorMode == ECangJie && sharedDataMode == ECangJie && iQwertyInputMode)
       
 10829             	{
       
 10830             	TryChangeModeL(EStroke);
       
 10831             	}
       
 10832             else
       
 10833             	{
       
 10834             	TryChangeModeL(editorMode);
       
 10835             	}
       
 10836             }
       
 10837         }
       
 10838     else if ((iAknEditorFlags & EAknEditorFlagForceTransparentFepModes) 
       
 10839               && !IsFeatureSupportedJapanese())  //new find pane
       
 10840         {
       
 10841         // the default chinese find mode is the first mode in the hash key loop, except PrcChinese
       
 10842         if( iLanguageCapabilities.iInputLanguageCode == ELangPrcChinese)
       
 10843             {
       
 10844             // Default searching language shall be ELatin
       
 10845             // Changed from EPinyin to ELatin here
       
 10846             TryChangeModeL(ELatin);
       
 10847             }
       
 10848         else
       
 10849             {
       
 10850             TryChangeModeL(iHashKeyLoop[0]); 
       
 10851             }
       
 10852         }
       
 10853     else    //new editor
       
 10854         {
       
 10855         if (defaultInputMode == EAknEditorNumericInputMode)
       
 10856             {
       
 10857             //numeric mode is not saved to/retreived from shared data
       
 10858             iCharWidth = EHalfWidthChar;
       
 10859             
       
 10860             if( IsInputModeAvailable(ENativeNumber) && 
       
 10861                 ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ||
       
 10862                   iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic ||
       
 10863                   iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ) )
       
 10864                 {
       
 10865                 TryChangeModeL( ENativeNumber );
       
 10866                 }
       
 10867             else
       
 10868                 {
       
 10869                 TryChangeModeL( ENumber );
       
 10870                 }
       
 10871             }
       
 10872         else if ((defaultInputMode == EAknEditorTextInputMode) &&
       
 10873                  ((iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) ||
       
 10874                  (iAknEditorFlags & EAknEditorFlagNoT9)))
       
 10875             {
       
 10876             //Chinese Modes or Western Predictive mode not allowed.
       
 10877             //See if we are ok going to the current shared data mode,
       
 10878             //otherwise go for a safe default
       
 10879             if (TryChangeModeL(sharedDataMode))
       
 10880                 {
       
 10881                 latinCaseSet = sharedDataMode & (ELatinUpper | ELatinLower);
       
 10882                 }
       
 10883             else
       
 10884                 {
       
 10885                 TryChangeModeL(ELatin);
       
 10886                 }
       
 10887             }
       
 10888         else if (defaultInputMode == EAknEditorHalfWidthTextInputMode)
       
 10889             {
       
 10890             iCharWidth = EHalfWidthChar;
       
 10891             TryChangeModeL(ELatin);
       
 10892             }
       
 10893         else if (defaultInputMode == EAknEditorHiraganaInputMode)
       
 10894             {
       
 10895             TryChangeModeL(EHiragana);
       
 10896             }
       
 10897         else if (  iLanguageCapabilities.iInputLanguageCode == ELangJapanese
       
 10898               && (defaultInputMode == EAknEditorKatakanaInputMode
       
 10899               || defaultInputMode == EAknEditorFullWidthKatakanaInputMode))
       
 10900             {
       
 10901             iCharWidth = (defaultInputMode == EAknEditorKatakanaInputMode)?
       
 10902                                 EHalfWidthChar : EFullWidthChar;
       
 10903             TryChangeModeL(EKatakana);
       
 10904             }
       
 10905         else if (defaultInputMode == EAknEditorFullWidthTextInputMode)
       
 10906             {
       
 10907             iCharWidth = EFullWidthChar;
       
 10908             TryChangeModeL(ELatin);
       
 10909             }
       
 10910         else if (defaultInputMode == EAknEditorFullWidthNumericInputMode)
       
 10911             {
       
 10912             iCharWidth = EFullWidthChar;
       
 10913             if( IsInputModeAvailable(ENativeNumber) && 
       
 10914                 ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ||
       
 10915                   iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic ||
       
 10916                   iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ) )
       
 10917                 {
       
 10918                 TryChangeModeL( ENativeNumber );
       
 10919                 }
       
 10920             else
       
 10921                 {
       
 10922                 TryChangeModeL( ENumber );
       
 10923                 }
       
 10924             }
       
 10925         else if (defaultInputMode == EAknEditorTextInputMode 
       
 10926             && iLanguageCapabilities.iInputLanguageCode == ELangHindi )
       
 10927             {
       
 10928             TryChangeModeL( EHindi );
       
 10929             }
       
 10930         else // Default input mode is EAknEditorTextInputMode
       
 10931             {
       
 10932             // Check possibility move this section on else if
       
 10933             if (IsKoreanInputLanguage())
       
 10934             	{
       
 10935             	TryChangeModeL(EHangul);
       
 10936             	}
       
 10937             else if (TryChangeModeL(sharedDataMode))
       
 10938                 {
       
 10939                 latinCaseSet = sharedDataMode & (ELatinUpper | ELatinLower);
       
 10940                 }
       
 10941             else
       
 10942                 {
       
 10943                 TryChangeModeL(ELatin);
       
 10944                 }
       
 10945                 
       
 10946             }
       
 10947         }
       
 10948 
       
 10949     if (!iMode)
       
 10950         {
       
 10951         // If mode change wasn't successful, try latin mode as fallback.
       
 10952         TryChangeModeL(ELatin);             
       
 10953         }
       
 10954 
       
 10955     // if also fallback fails, panic.
       
 10956     __ASSERT_DEBUG(iMode, AknFepPanic(EAknFepPanicNoPermittedEditorModesAvailable));
       
 10957 
       
 10958     if (iCaseMan && !latinCaseSet)
       
 10959         {
       
 10960         iCaseMan->ConfigureCaseStateFromEditorState();
       
 10961         if ( (editorState->Flags() & EFlagSupressAutoUpdate) ||
       
 10962             editorMode == EAknEditorSecretAlphaInputMode )
       
 10963             {
       
 10964             SetFlag(EFlagSupressAutoUpdate);
       
 10965             }
       
 10966         else
       
 10967             {
       
 10968             ClearFlag(EFlagSupressAutoUpdate);
       
 10969             }
       
 10970         }
       
 10971     if ((iAknEditorFlags & EAknEditorFlagForceTransparentFepModes) &&
       
 10972         IsChineseInputLanguage() && iCaseMan != NULL )
       
 10973         {
       
 10974         SetFlag(EFlagSupressAutoUpdate);
       
 10975         iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
 10976         }
       
 10977 
       
 10978     UpdateEditorContext();
       
 10979 
       
 10980     // Check if this editor was previously inline editing
       
 10981     if ( WesternPredictive() && editorState->CurrentInlineEditSpan().Length())
       
 10982         { // restore the fep to an inline editing state
       
 10983         iUncommittedText = editorState->CurrentInlineEditSpan();
       
 10984         TInt docLenFep=iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 10985         if (iUncommittedText.iCursorPos>docLenFep)
       
 10986             iUncommittedText.iCursorPos=docLenFep;
       
 10987         if (iUncommittedText.iAnchorPos>docLenFep)
       
 10988             iUncommittedText.iAnchorPos=docLenFep;
       
 10989 
       
 10990         TBuf<EMaximumFepWordLength> textToUncommit;
       
 10991         iInputCapabilities.FepAwareTextEditor()->
       
 10992             GetEditorContentForFep(textToUncommit, iUncommittedText.iAnchorPos, 
       
 10993                                    Min(iUncommittedText.Length(), EMaximumFepWordLength));
       
 10994 
       
 10995         // Activates western predictive UI to an inline editing state.
       
 10996         FepUI()->ActivateUI();
       
 10997         SyncStates(EAknFepStateUIActive);
       
 10998         TInt err = iPtiEngine->SetCurrentWord(textToUncommit);
       
 10999 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 11000         // Predictive QWERTY (XT9) changes (TEST) ---->
       
 11001         // The PtiXt9Core may choose to ignore the SetCurrentInputSequence() call.
       
 11002         // Make sure our text buffer is in sync with the one in PtiEngine.
       
 11003         if(KErrNone != err)
       
 11004         	textToUncommit = iPtiEngine->CurrentWord();
       
 11005         TInt maxEdSize = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
 11006         if((maxEdSize > 0) && (iUncommittedText.iAnchorPos + textToUncommit.Length() > maxEdSize))
       
 11007         {
       
 11008         	textToUncommit.SetLength(maxEdSize - iUncommittedText.iAnchorPos);
       
 11009         	iUncommittedText.iCursorPos = maxEdSize;
       
 11010         }	
       
 11011         // Predictive QWERTY (XT9) changes <----
       
 11012 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 11013         StartInlineEditL(iUncommittedText, textToUncommit, textToUncommit.Length(), EFalse);
       
 11014        
       
 11015         // Make sure editor character case in sync
       
 11016         if( iUncommittedText.iAnchorPos == 0 )
       
 11017         	iCaseMan->UpdateCase(ENullNaviEvent);
       
 11018         
       
 11019         }
       
 11020 
       
 11021     if (editorState != iPreviousEditorState)
       
 11022         {
       
 11023         // we have changed editor, time to update local digits mode
       
 11024         UpdateLocalDigitMode(); 
       
 11025         iPreviousEditorState = editorState;
       
 11026         }
       
 11027 
       
 11028     if(IsExtendedFlagSet(EExtendedFlagShiftReleasedOnPopup) && !(iAknEditorFlags & EAknEditorFlagFindPane) )
       
 11029         {
       
 11030         // If in FEP context, shift is released on a non fep aware dialog
       
 11031         // like "text copied to clipboard", then release the shift 
       
 11032         // when the editor comes in focus by simulating shift up event.
       
 11033         ClearExtendedFlag(EExtendedFlagShiftReleasedOnPopup);
       
 11034         TKeyEvent shiftUp = {0, EStdKeyLeftShift, 0, 0};
       
 11035         CCoeEnv::Static()->SimulateKeyEventL(shiftUp, EEventKeyUp);     
       
 11036         }
       
 11037     else if (IsFlagSet(EFlagLongShiftKeyPress) && !(iAknEditorFlags & EAknEditorFlagFindPane))
       
 11038         {
       
 11039         // Find pane editor does not require any shift simulation
       
 11040         
       
 11041         // After the "text copied" note and if the shift key was not released
       
 11042         // then simulate shift down event.
       
 11043         TKeyEvent shiftDown = {0, EStdKeyLeftShift, 0, 0};
       
 11044         CCoeEnv::Static()->SimulateKeyEventL(shiftDown, EEventKeyDown);      
       
 11045         if((!iCandidatePopup) && (KeyboardLayout() != EPtiKeyboard12Key ))
       
 11046         ResetShiftKeyMonitorL();
       
 11047         }
       
 11048 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 11049     TransferFepStateToEditorL(EFalse); // ensure editor has up to date state
       
 11050 #else
       
 11051     TransferFepStateToEditorL(); // ensure editor has up to date state
       
 11052 #endif   
       
 11053     
       
 11054     iHashKeyMan->ResetIndicHashKeyStateL();
       
 11055     ClearExtendedFlag(EExtendedFlagShortPressHashKey);
       
 11056     }
       
 11057 
       
 11058 TInt CAknFepManager::ConfigureFepModeFromEditorMode(TInt aEditorMode)
       
 11059     {
       
 11060     TInt fepMode(aEditorMode);
       
 11061 
       
 11062     switch (aEditorMode)
       
 11063         {
       
 11064         case EAknEditorNumericInputMode:
       
 11065             if( IsInputModeAvailable(ENativeNumber) && 
       
 11066                 ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ||
       
 11067                   iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic ||
       
 11068                   iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ) )
       
 11069                 {
       
 11070                 fepMode = ENativeNumber;
       
 11071                 }
       
 11072             else
       
 11073                 {
       
 11074                 fepMode = ENumber;
       
 11075                 }
       
 11076             iCharWidth = EHalfWidthChar;
       
 11077             break;
       
 11078         case EAknEditorSecretAlphaInputMode:
       
 11079         case EAknEditorTextInputMode:
       
 11080         case EAknEditorHalfWidthTextInputMode:
       
 11081             fepMode = ELatin;
       
 11082             iCharWidth = EHalfWidthChar;
       
 11083             break;
       
 11084         case EAknEditorKatakanaInputMode:
       
 11085             fepMode = EKatakana;
       
 11086             iCharWidth = EHalfWidthChar;
       
 11087             break;
       
 11088         case EAknEditorFullWidthTextInputMode:
       
 11089             fepMode = ELatin;
       
 11090             iCharWidth = EFullWidthChar;
       
 11091             break;
       
 11092         case EAknEditorFullWidthKatakanaInputMode:
       
 11093             fepMode = EKatakana;
       
 11094             iCharWidth = EFullWidthChar;
       
 11095             break;
       
 11096         case EAknEditorFullWidthNumericInputMode:
       
 11097             if( IsInputModeAvailable(ENativeNumber) && 
       
 11098                 ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ||
       
 11099                   iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic ||
       
 11100                   iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ) )
       
 11101                 {
       
 11102                 fepMode = ENativeNumber;
       
 11103                 }
       
 11104             else
       
 11105                 {
       
 11106                 fepMode = ENumber;
       
 11107                 }
       
 11108             iCharWidth = EFullWidthChar;
       
 11109             break;
       
 11110         case EAknEditorHiraganaKanjiInputMode:
       
 11111             fepMode = EHiraganaKanji;
       
 11112             break;
       
 11113         case EAknEditorHiraganaInputMode:
       
 11114             fepMode = EHiragana;
       
 11115             break;
       
 11116         default:
       
 11117             break;
       
 11118         }
       
 11119     return fepMode;
       
 11120     }
       
 11121 
       
 11122 void CAknFepManager::LaunchHelpTextQueryL()
       
 11123     {
       
 11124     TUid fepUid = CCoeEnv::Static()->FepUid();  
       
 11125     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
 11126     iUiInterface->LaunchHelpTextQueryL(R_AKNFEP_HELP_TEXT);
       
 11127     PrepareFepAfterDialogExitL(fepUid);
       
 11128     }
       
 11129 
       
 11130 void CAknFepManager::UpdateEditorContext() const
       
 11131     {
       
 11132     if(EditingStateIndicator())
       
 11133         {
       
 11134         iUiInterface->UpdateEditorContext(*EditingStateIndicator(), *FepUI());
       
 11135         }
       
 11136     }
       
 11137 
       
 11138 TBool CAknFepManager::TextIsValidInEditor(const TDesC& aText)
       
 11139     {
       
 11140     TBool ret = ETrue;
       
 11141     TUint length = aText.Length();
       
 11142     TCoeInputCapabilities::MCoeFepSpecificExtensions* ipCapExt = 
       
 11143                            iInputCapabilities.FepSpecificExtensions(TUid::Uid(EAknFepUid));
       
 11144     if (ipCapExt)
       
 11145         {
       
 11146         while(length--)
       
 11147             {
       
 11148             if (!ipCapExt->IsValidCharacter(aText[length]))
       
 11149                 {
       
 11150                 ret = EFalse;
       
 11151                 }
       
 11152             }
       
 11153         }
       
 11154     return ret;
       
 11155     }
       
 11156 
       
 11157 TBool CAknFepManager::CharIsValidInEditor(TChar aChar)
       
 11158     {
       
 11159     TBool ret = ETrue;
       
 11160     TCoeInputCapabilities::MCoeFepSpecificExtensions* ipCapExt = 
       
 11161                            iInputCapabilities.FepSpecificExtensions(TUid::Uid(EAknFepUid));
       
 11162     if (ipCapExt)
       
 11163         {
       
 11164         if (!ipCapExt->IsValidCharacter(aChar))
       
 11165             {
       
 11166             ret = EFalse;
       
 11167             }
       
 11168         }
       
 11169     return ret;
       
 11170     }
       
 11171 
       
 11172 void CAknFepManager::SetCursorType(TChineseFepCursorType aType)
       
 11173     {
       
 11174     TBool setToTrue = ETrue;
       
 11175     TTextCursor newCursor;
       
 11176 
       
 11177     newCursor.iType=TTextCursor::ETypeRectangle;
       
 11178     if (aType == EPassive)
       
 11179         {
       
 11180         newCursor.iType=TTextCursor::ETypeHollowRectangle;
       
 11181         }
       
 11182     if ( IsFepAwareTextEditor() )
       
 11183         {
       
 11184         iInputCapabilities.FepAwareTextEditor()->Extension1()->SetCursorType(setToTrue, newCursor);
       
 11185         }
       
 11186     }
       
 11187 
       
 11188 MAknEditingStateIndicator* CAknFepManager::EditingStateIndicator() const
       
 11189     {
       
 11190     MAknEditingStateIndicator* indicator = NULL;
       
 11191 
       
 11192     // First ask indicator from controls owning the editor.
       
 11193     // For example CAknQueryControl and CAknSearchField implement
       
 11194     // their own indicators.
       
 11195 
       
 11196     MObjectProvider* objectProvider = NULL;
       
 11197 
       
 11198     // First try through CAknEdwinState object.
       
 11199     // It exists with CEikEdwin-derived editors.
       
 11200     
       
 11201 		MCoeFepAwareTextEditor* editor = NULL;
       
 11202 		MCoeFepAwareTextEditor_Extension1* ext1 = NULL;
       
 11203 		CAknEdwinState* state = NULL;
       
 11204 
       
 11205     editor = iInputCapabilities.FepAwareTextEditor();
       
 11206     
       
 11207     if(editor)
       
 11208     	ext1 = editor->Extension1() ;
       
 11209     if(ext1)
       
 11210       state = (CAknEdwinState*)ext1->State( KNullUid ) ;
       
 11211       
       
 11212     if ( IsFepAwareTextEditor() && ( editor  ) && ( ext1) && ( state ))
       
 11213         {
       
 11214         objectProvider = state->ObjectProvider();
       
 11215         }
       
 11216 
       
 11217     // If not found, try to get object provider from input capabilities.
       
 11218     // It is set there with CEikMfne-derived editors.
       
 11219 
       
 11220     if ( !objectProvider )
       
 11221         {
       
 11222         objectProvider = iInputCapabilities.ObjectProvider();
       
 11223         }
       
 11224 
       
 11225     if ( objectProvider )
       
 11226         {
       
 11227         indicator = objectProvider->MopGetObject( indicator );
       
 11228         }
       
 11229 
       
 11230     // If no indicator was supplied, get one from CAknEnv.
       
 11231     // By default, this one is FEP's own indicator.
       
 11232 
       
 11233     if ( !indicator )
       
 11234         {
       
 11235         indicator = CAknEnv::Static()->EditingStateIndicator();
       
 11236         if (indicator != iIndicator)
       
 11237             {
       
 11238             CAknEnv::Static()->SwapEditingStateIndicator(iIndicator);
       
 11239             indicator = iIndicator;
       
 11240             }
       
 11241         }
       
 11242 
       
 11243     return indicator;
       
 11244     }
       
 11245 
       
 11246 TBool CAknFepManager::TryHandleArrowRightEventL(TInt aDokumentLength)
       
 11247     {
       
 11248     TBool ret = EFalse;
       
 11249     TBool thai = (iLanguageCapabilities.iInputLanguageCode == ELangThai);
       
 11250     if (  iInputCapabilities.FepAwareTextEditor() &&
       
 11251           (iSharedDataInterface->SpaceWithScrollRight() || thai ) &&
       
 11252           (!(iAknEditorFlags & EAknEditorFlagNoLRNavigation)) &&
       
 11253           iFepManState == EAknFepStateInitial &&
       
 11254           (!IsFlagSet(EFlagInsideInlineEditingTransaction) ) &&
       
 11255           (!IsFlagSet(EFlagShiftKeyDepressed)) &&
       
 11256           iMode != EHiragana )          //  Not supported in only Hiragana input mode
       
 11257         {
       
 11258         TInt cursorPos = DocPos().iPos;
       
 11259         TCursorSelection cursorSel;
       
 11260         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSel);
       
 11261         if (( cursorPos == aDokumentLength)
       
 11262             && !cursorSel.Length()
       
 11263             && (IsFeatureSupportedJapanese() || (PreviousChar() != 0x0020)) )
       
 11264             {
       
 11265             // set to half-width space or full-width space by current input mode.
       
 11266             //    0x0020 is unicode for half-width space
       
 11267             //    0x3000 is unicode for full-width space
       
 11268             TUint code(0);
       
 11269             switch (iMode)
       
 11270                 {
       
 11271                 case EHiraganaKanji:
       
 11272                     code = 0x3000;
       
 11273                     break;
       
 11274                 case ELatin:
       
 11275                     code = (!WesternPredictive() && iCharWidth == EFullWidthChar)?
       
 11276                             0x3000 : 0x0020;
       
 11277                     break;
       
 11278                 case EHiragana:
       
 11279                     // Not supported in only Hiragana input mode
       
 11280                     break;
       
 11281                 case EHangul:
       
 11282                 	code = 0x0020;
       
 11283                 	break;
       
 11284                 case ENumber:
       
 11285                 case ENativeNumber:
       
 11286                 case EKatakana:
       
 11287                 default:
       
 11288                     code = (iCharWidth == EFullWidthChar)? 0x3000 : 0x0020;
       
 11289                     break;
       
 11290                 }
       
 11291             if (code)
       
 11292                 {
       
 11293                 SimulateKeyEventL(code); // add a space
       
 11294                 SimulateKeyEventL(EKeyF19); // Asyncronous case update
       
 11295                 ret = ETrue;
       
 11296                 }
       
 11297             }
       
 11298         }
       
 11299     return ret;
       
 11300     }
       
 11301 
       
 11302 TBool CAknFepManager::TryHandleArrowLeftEventL(TInt aDokumentLength)
       
 11303     {
       
 11304     TBool ret = EFalse;
       
 11305     if (iInputCapabilities.FepAwareTextEditor() &&
       
 11306         iSharedDataInterface->SpaceWithScrollRight() &&
       
 11307         (!(iAknEditorFlags & EAknEditorFlagNoLRNavigation)) &&
       
 11308         iFepManState == EAknFepStateInitial &&
       
 11309         (!IsFlagSet(EFlagInsideInlineEditingTransaction) ) &&
       
 11310         (!IsFlagSet(EFlagShiftKeyDepressed)) &&
       
 11311         iMode != EHiragana )          //  Not supported in only Hiragana input mode
       
 11312         {
       
 11313         TInt cursorPos = DocPos().iPos;
       
 11314         TCursorSelection cursorSel;
       
 11315         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSel);
       
 11316         TText previousChar = PreviousChar();
       
 11317         if (( cursorPos == aDokumentLength)
       
 11318             && !cursorSel.Length()
       
 11319             && (IsFeatureSupportedJapanese()
       
 11320             && (previousChar == 0x3000 || previousChar == 0x0020) )) // full width or half-width space.
       
 11321             {
       
 11322             SimulateKeyEventL(EKeyBackspace);
       
 11323             SimulateKeyEventL(EKeyF19); // Asyncronous case update
       
 11324             ret = ETrue;
       
 11325             }
       
 11326         }
       
 11327     return ret;
       
 11328     }
       
 11329 
       
 11330 TBool CAknFepManager::TryHandleArrowDownEventL(TInt aDokumentLength)
       
 11331     {
       
 11332     TBool ret = EFalse;
       
 11333 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 11334     // Predictive QWERTY (XT9) changes ---->
       
 11335     if ( iWesternPredictive &&
       
 11336          IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) && !(iAknEditorFlags & EAknEditorFlagNoT9) 
       
 11337          && !IsFlagSet(EFlagInsideMultitapInlineEditingTransaction) && !IsFlagSet(EFlagNoMatches))
       
 11338         {
       
 11339         LaunchCandidatePopupListL();
       
 11340         ret = ETrue;
       
 11341         }
       
 11342     // Predictive QWERTY (XT9) changes <----
       
 11343     else 
       
 11344 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 11345     if  ( ( iAknEditorFlags & EAknEditorFlagAllowEntersWithScrollDown ) &&
       
 11346           iInputCapabilities.FepAwareTextEditor() &&
       
 11347           ( iSharedDataInterface->EntersWithScrollDown() ) &&
       
 11348           iFepManState == EAknFepStateInitial &&
       
 11349           !IsFlagSet(EFlagInsideInlineEditingTransaction) &&
       
 11350           !IsFlagSet(EFlagShiftKeyDepressed) )
       
 11351         {
       
 11352         TInt cursorPos = DocPos().iPos;
       
 11353         TCursorSelection cursorSel;
       
 11354         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(cursorSel);
       
 11355         if ( cursorPos == aDokumentLength &&
       
 11356             !cursorSel.Length() )
       
 11357             {
       
 11358             SimulateKeyEventL(EKeyEnter); // add line feed
       
 11359             SimulateKeyEventL(EKeyF19); // Asyncronous case update
       
 11360             ret = ETrue;
       
 11361             }
       
 11362         }
       
 11363     return ret;
       
 11364     }
       
 11365 
       
 11366 TUint CAknFepManager::EditorModeFromFepMode(TInt aFepMode)
       
 11367     {
       
 11368     TUint editorMode(aFepMode);
       
 11369     switch (aFepMode)
       
 11370         {
       
 11371         case ELatin:
       
 11372             if (iPermittedInputModes & EAknEditorTextInputMode)
       
 11373                 {
       
 11374                 editorMode = EAknEditorTextInputMode;
       
 11375                 if (IsFeatureSupportedJapanese())
       
 11376                     {
       
 11377                     if (iCharWidth == EHalfWidthChar 
       
 11378                     && (iPermittedInputModes & EAknEditorHalfWidthTextInputMode))
       
 11379                         {
       
 11380                         editorMode = EAknEditorHalfWidthTextInputMode;
       
 11381                         }
       
 11382                     else if (iCharWidth == EFullWidthChar 
       
 11383                          && (iPermittedInputModes & EAknEditorFullWidthTextInputMode))
       
 11384                         {
       
 11385                         editorMode = EAknEditorFullWidthTextInputMode;
       
 11386                         }
       
 11387                     }
       
 11388                 }
       
 11389             else if (iPermittedInputModes & EAknEditorHalfWidthTextInputMode)
       
 11390                 {
       
 11391                 editorMode = EAknEditorTextInputMode;
       
 11392                 if (IsFeatureSupportedJapanese())
       
 11393                     {
       
 11394                     editorMode = EAknEditorHalfWidthTextInputMode;
       
 11395                     if (iCharWidth == EFullWidthChar 
       
 11396                      &&(iPermittedInputModes & EAknEditorFullWidthTextInputMode))
       
 11397                         {
       
 11398                         editorMode = EAknEditorFullWidthTextInputMode;
       
 11399                         }
       
 11400                     }
       
 11401                 }
       
 11402             else if (iPermittedInputModes & EAknEditorFullWidthTextInputMode)
       
 11403                 {
       
 11404                 editorMode = EAknEditorTextInputMode;
       
 11405                 if (IsFeatureSupportedJapanese())
       
 11406                     {
       
 11407                     editorMode = EAknEditorFullWidthTextInputMode;
       
 11408                     }
       
 11409                 }
       
 11410             else
       
 11411                 {
       
 11412                 editorMode = EAknEditorSecretAlphaInputMode;
       
 11413                 }
       
 11414             break;
       
 11415         case ENumber:
       
 11416         case ENativeNumber:
       
 11417             editorMode = EAknEditorNumericInputMode;
       
 11418             if (iCharWidth == EFullWidthChar 
       
 11419             && (iPermittedInputModes & EAknEditorFullWidthNumericInputMode))
       
 11420                 {
       
 11421                 editorMode = EAknEditorFullWidthNumericInputMode;
       
 11422                 }
       
 11423             break;
       
 11424     	case EHangul: 
       
 11425        		editorMode = EAknEditorHangulInputMode;       	
       
 11426        		break;
       
 11427         default:
       
 11428             if (IsFeatureSupportedJapanese())
       
 11429                 {
       
 11430                 editorMode = EditorMode(aFepMode, iCharWidth);
       
 11431                 }
       
 11432             break;
       
 11433         }
       
 11434     return editorMode;
       
 11435     }
       
 11436 
       
 11437 CAknKeySoundSystem* CAknFepManager::SoundSystem() const
       
 11438     {
       
 11439     CCoeEnv* coeEnv = CCoeEnv::Static();
       
 11440     if (coeEnv->AppUi())
       
 11441         {
       
 11442         return iAvkonAppUiBase->KeySounds();
       
 11443         }
       
 11444     return NULL;
       
 11445     }
       
 11446 
       
 11447 void CAknFepManager::SetHashKeyStyle()
       
 11448     {
       
 11449     CAknFepHashKeyManager::THashKeyStyle style = CAknFepHashKeyManager::EHashKeyStyleWestern;
       
 11450 
       
 11451     switch (iLanguageCapabilities.iInputLanguageCode)
       
 11452         {
       
 11453         case ELangPrcChinese:
       
 11454         case ELangHongKongChinese:
       
 11455         case ELangTaiwanChinese:
       
 11456             style = CAknFepHashKeyManager::EHashKeyStyleChineseWithWestern;
       
 11457             break;
       
 11458         case ELangJapanese:
       
 11459             style = CAknFepHashKeyManager::EHashKeyStyleJapanese;
       
 11460             break;
       
 11461         case ELangKorean:
       
 11462         	style = CAknFepHashKeyManager::EHashKeyStyleKoreanWithWestern;
       
 11463         	break;
       
 11464         default:
       
 11465             break;
       
 11466         }
       
 11467 
       
 11468     iHashKeyMan->SetHashKeyStyle( style );
       
 11469     }
       
 11470 
       
 11471 void CAknFepManager::ReadHashKeyLoopL()
       
 11472     {
       
 11473     iHashKeyLoop.Reset();
       
 11474 
       
 11475     CCoeEnv* coeEnv = CCoeEnv::Static();
       
 11476     TResourceReader reader;
       
 11477     coeEnv->CreateResourceReaderLC(reader, R_HASH_KEY_LOOP_ALL_INPUT_MODES);
       
 11478 
       
 11479     iVariantPermittedModes = 0;
       
 11480     const TInt count = reader.ReadInt16();
       
 11481     for (TInt ii=0; ii<count; ii++)
       
 11482         {
       
 11483         TInt mode = reader.ReadInt32();
       
 11484         if ( IsInputModeAvailable(mode) )
       
 11485             {
       
 11486             if ( mode == EPRCFind)
       
 11487                 {
       
 11488                 mode = ELatin;
       
 11489                 }
       
 11490             iHashKeyLoop.Append(mode);
       
 11491             iVariantPermittedModes |= mode;
       
 11492             }
       
 11493         }
       
 11494     CleanupStack::PopAndDestroy(); //reader
       
 11495     }
       
 11496 
       
 11497 TBool CAknFepManager::IsValidInLineCharacter(TChar aCharacter) const
       
 11498     {
       
 11499     TBool validInlineCharacter = ETrue;
       
 11500     TChar::TCategory category = aCharacter.GetCategory();
       
 11501     TChar::TBdCategory bdCategory = aCharacter.GetBdCategory();
       
 11502     switch (iLanguageCapabilities.iInputLanguageCode)
       
 11503         {
       
 11504         case ELangArabic:
       
 11505             {
       
 11506             // Needs more specific category
       
 11507             validInlineCharacter = ( (category & TChar::ELetterOtherGroup) &&
       
 11508                 (bdCategory == TChar::ERightToLeftArabic) );
       
 11509             break;
       
 11510             }
       
 11511         case ELangHebrew:
       
 11512             {
       
 11513             // Needs more specific category
       
 11514             validInlineCharacter = ( (category & TChar::ELetterOtherGroup) &&
       
 11515                 (bdCategory == TChar::ERightToLeft) );
       
 11516             break;
       
 11517             }
       
 11518         case ELangFarsi:
       
 11519         case ELangUrdu:
       
 11520             {
       
 11521             // Needs more specific category
       
 11522             validInlineCharacter = ( (category & TChar::ELetterOtherGroup) &&
       
 11523                 (bdCategory == TChar::ERightToLeftArabic) );
       
 11524             break;
       
 11525             }
       
 11526             /*Hindi*/            
       
 11527         case ELangHindi:
       
 11528 #ifdef RD_MARATHI
       
 11529 			/* Same for Marathi */
       
 11530         case ELangMarathi:
       
 11531 #endif
       
 11532             {
       
 11533             // Needs more specific category
       
 11534             validInlineCharacter = IsValidInlineIndicCharacter(aCharacter);
       
 11535             
       
 11536             break;
       
 11537             }
       
 11538         case ELangVietnamese:
       
 11539             {
       
 11540             // For full screen qwerty, validInlineCharacter is true
       
 11541             if( !( iFepPluginManager && iFepPluginManager->EnableITIOnFSQ() ) )
       
 11542                 {
       
 11543                 validInlineCharacter = (aCharacter.IsAlpha() &&
       
 11544                                         !((category & TChar::ELetterOtherGroup))) ||
       
 11545                                         ((category == TChar::EMarkGroup) && 
       
 11546                                         (bdCategory == TChar::ENonSpacingMark));
       
 11547                 }
       
 11548             break;
       
 11549             }
       
 11550         case ELangThai:
       
 11551             {
       
 11552             validInlineCharacter = (!(aCharacter.IsSpace() || (aCharacter == 0x2029))) &&
       
 11553                                    ((aCharacter.IsAlpha() && 
       
 11554                                     !(category & TChar::ELetterOtherGroup)) ||
       
 11555                                    ((category & TChar::EMarkGroup) && 
       
 11556                                     (bdCategory == TChar::ENonSpacingMark)) ||
       
 11557                                    ((category & TChar::ELetterModifierGroup) && 
       
 11558                                     (bdCategory == TChar::ELeftToRight)) ||
       
 11559                                    ((category & TChar::ESeparatorGroup ) && 
       
 11560                                     (bdCategory == TChar::EWhitespace))||
       
 11561                                    ((category & TChar::EMcCategory) && 
       
 11562                                     (bdCategory == TChar::ELeftToRight)));
       
 11563             break;                                    
       
 11564             }
       
 11565         case ELangTaiwanChinese:
       
 11566         case ELangHongKongChinese:
       
 11567         case ELangPrcChinese:
       
 11568         case ELangEnglish:
       
 11569             {                           
       
 11570 #ifdef RD_INTELLIGENT_TEXT_INPUT   
       
 11571             // for qwerty special characters should not break the word
       
 11572             if( iQwertyInputMode && ( KeyboardLayout() !=EPtiKeyboardHalfQwerty ))
       
 11573                 {
       
 11574                 validInlineCharacter = (!( aCharacter.IsSpace() || (aCharacter == 0x2029) || 
       
 11575                                         ( aCharacter.IsAlpha() && 
       
 11576                                          (category & TChar::ELetterOtherGroup))||
       
 11577                                         ((category & TChar::EMarkGroup) && 
       
 11578                                          (bdCategory == TChar::ENonSpacingMark)) ||
       
 11579                         				((category & TChar::ELetterModifierGroup) && 
       
 11580                         		 		 (bdCategory == TChar::ELeftToRight)) ||
       
 11581                         				((category & TChar::ESeparatorGroup ) && 
       
 11582                         		 		 (bdCategory == TChar::EWhitespace))));
       
 11583                 }            
       
 11584             else                
       
 11585 #endif      // whereas for ITUT and Half Qwerty they should
       
 11586                 {
       
 11587                 validInlineCharacter = ( aCharacter.IsAlpha() && !(category & TChar::ELetterOtherGroup) );
       
 11588                 }            
       
 11589             break;
       
 11590             }
       
 11591         default:
       
 11592             {
       
 11593 #ifdef RD_INTELLIGENT_TEXT_INPUT            
       
 11594 			// for qwerty special characters should not break the word
       
 11595 			
       
 11596 			if( iQwertyInputMode && ( KeyboardLayout() !=EPtiKeyboardHalfQwerty ) )
       
 11597 				{
       
 11598 				validInlineCharacter = (!(aCharacter.IsSpace() || (aCharacter == 0x2029)));	
       
 11599 				}
       
 11600 			else	            
       
 11601 #endif		// whereas for ITUT and Half Qwerty they should
       
 11602 				{
       
 11603 				validInlineCharacter = ( aCharacter.IsAlpha() && !(category & TChar::ELetterOtherGroup) );
       
 11604 				}
       
 11605 			
       
 11606 
       
 11607             break;
       
 11608             }
       
 11609         }
       
 11610 	
       
 11611 	TUint16 key = 0;
       
 11612 	if(validInlineCharacter)
       
 11613 		{
       
 11614 		validInlineCharacter = EFalse;
       
 11615         ConvertCharToKey(aCharacter, key);
       
 11616 		if(0 != key)
       
 11617 			{
       
 11618 			validInlineCharacter = ETrue;
       
 11619 			}
       
 11620 		}
       
 11621 		
       
 11622     return validInlineCharacter;
       
 11623     }
       
 11624 TBool CAknFepManager::IsValidInlineIndicCharacter(TChar aCharacter) const
       
 11625     {
       
 11626     TBool validInlineCharacter = ETrue;
       
 11627     TChar::TCategory category = aCharacter.GetCategory();
       
 11628     TChar::TBdCategory bdCategory = aCharacter.GetBdCategory();
       
 11629     
       
 11630     if(!((category == TChar::EPoCategory) || aCharacter == 0x0950 || aCharacter == 0x093D))
       
 11631         {
       
 11632         validInlineCharacter = ((( (category & TChar::ELetterOtherGroup) 
       
 11633                                       && (bdCategory == TChar::ELeftToRight) )
       
 11634                                   ||( (category & TChar::EMcCategory) 
       
 11635                                       && (bdCategory == TChar::ELeftToRight) )
       
 11636                                   ||( (category & TChar::EMarkGroup) 
       
 11637                                       && (bdCategory == TChar::ENonSpacingMark)) )
       
 11638                                  &&( ! ( aCharacter.IsAlpha() 
       
 11639                                       && !(category & TChar::ELetterOtherGroup) )));
       
 11640         }
       
 11641     else 
       
 11642         {
       
 11643         validInlineCharacter = EFalse;
       
 11644         }
       
 11645     return  validInlineCharacter;
       
 11646     }
       
 11647 
       
 11648 TInt CAknFepManager::WordConcatenationTimerTimeoutCallback(TAny* aObj)
       
 11649     {
       
 11650     TRAPD(err, static_cast<CAknFepManager*>(aObj)->WordConcatenationTimerTimeoutL());
       
 11651     if (err)
       
 11652         {
       
 11653         static_cast<CAknFepManager*>(aObj)->CleanUpFep();
       
 11654         return KErrNoMemory;
       
 11655         }
       
 11656     return KErrNone;
       
 11657     }
       
 11658 
       
 11659 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 11660     
       
 11661 TBool CAknFepManager::IsHybridAplhaEditor() const
       
 11662     {
       
 11663     TBool phoneIdle = (EditorType() == CAknExtendedInputCapabilities::EHybridAlphaNumericEditor);
       
 11664     return phoneIdle;
       
 11665     }
       
 11666 
       
 11667 TBool CAknFepManager::IsHybridAlphaModeChangedtoAplhanumeric() const
       
 11668     {
       
 11669     return iHybridAplphaChangedToAlphanumeric;
       
 11670     }
       
 11671 
       
 11672 TBool CAknFepManager::IsPhoneNumberEditor() const
       
 11673     {
       
 11674     TBool phoneEditor = (EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor);
       
 11675     return phoneEditor;
       
 11676     }
       
 11677 CAknFepFnKeyManager::TFnKeyState CAknFepManager::FnKeyState()
       
 11678     {
       
 11679     return iFnKeyManager->FnKeyState();
       
 11680     }
       
 11681 void CAknFepManager::SetFnKeyState(CAknFepFnKeyManager::TFnKeyState aState)
       
 11682     {
       
 11683     iFnKeyManager->SetFnKeyState(aState);
       
 11684     }
       
 11685 #ifdef __REVERSE_FN_KEY_SUPPORTED
       
 11686 TBool CAknFepManager::IsReverseFnkeyInput()
       
 11687     {
       
 11688     return iIsReverseFnkeyInput;
       
 11689     }
       
 11690 void CAknFepManager::SetReverseFnkeyInputMode(TBool iIsOn)
       
 11691 	{
       
 11692 	iIsReverseFnkeyInput = iIsOn;
       
 11693 	}
       
 11694 TBool CAknFepManager::IsValidCharInNumericEditorL( TChar aChar ) const
       
 11695     {
       
 11696     if(!EditorState())
       
 11697         {
       
 11698     	return EFalse;    	
       
 11699         }
       
 11700     TBool validChar = EFalse;
       
 11701     if( aChar.IsDigit() )
       
 11702         {
       
 11703         return ETrue;
       
 11704         }
       
 11705     TBool phoneIdle = (EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor);            
       
 11706     if( (phoneIdle || (IsHybridAplhaEditor() && !IsHybridAlphaModeChangedtoAplhanumeric()))
       
 11707 	 	&& aChar == '#')    
       
 11708     	{
       
 11709     	return ETrue;
       
 11710     	}
       
 11711 	if( aChar == '.' && EAknEditorConverterNumberModeKeymap == iAknEditorNumericKeymap)
       
 11712         {
       
 11713         return ETrue;
       
 11714         }	
       
 11715     if( IsAllowedKeymappingForNumberMode(aChar) )
       
 11716     	{
       
 11717     	return ETrue;
       
 11718     	}
       
 11719     	
       
 11720     TInt resourceSCTId = EditorState()->SpecialCharacterTableResourceId();  
       
 11721     // No SCT table use default SCT
       
 11722     if( resourceSCTId == KErrNotFound || !resourceSCTId || 
       
 11723             (IsHybridAplhaEditor()&& !IsHybridAlphaModeChangedtoAplhanumeric()))
       
 11724         {
       
 11725         resourceSCTId = NumericModeSCTResourceId();
       
 11726         }   
       
 11727     
       
 11728     if( resourceSCTId )
       
 11729         {
       
 11730         TResourceReader reader;
       
 11731         CEikonEnv::Static()->CreateResourceReaderLC(reader,resourceSCTId);
       
 11732         reader.ReadInt32(); // skip sct id    
       
 11733         TPtrC chars=reader.ReadTPtrC(); // read special char        
       
 11734         validChar = ( chars.Locate(aChar)>=0 );                      
       
 11735         CleanupStack::PopAndDestroy();
       
 11736         }
       
 11737     return validChar;
       
 11738     
       
 11739     }
       
 11740 TInt CAknFepManager::GetNumericSCTResID()
       
 11741     {
       
 11742     if(!EditorState())
       
 11743       	{
       
 11744         return NumericModeSCTResourceId();
       
 11745     	  }
       
 11746     TInt resourceSCTId = EditorState()->SpecialCharacterTableResourceId();
       
 11747     if(resourceSCTId == KErrNotFound || !resourceSCTId )
       
 11748         {
       
 11749         resourceSCTId = NumericModeSCTResourceId();
       
 11750         }
       
 11751     return resourceSCTId;
       
 11752     }
       
 11753 
       
 11754 TBool CAknFepManager::IsValidCharForNumericInFnReverseL(TInt aKey, TPtiTextCase aCase) 
       
 11755     {
       
 11756     if(!EditorState())
       
 11757         {
       
 11758     	return EFalse;    	
       
 11759         }
       
 11760     TBuf<32> keyMaps;
       
 11761     iPtiEngine->MappingDataForKey( (TPtiKey)aKey, keyMaps, aCase);  
       
 11762     
       
 11763     TBool validKey(EFalse);   
       
 11764     if( keyMaps.Length()<= 0 )
       
 11765         {
       
 11766         return validKey;
       
 11767         }
       
 11768     TChar chr =keyMaps[0];
       
 11769     if( chr.IsDigit() )
       
 11770         {
       
 11771         return ETrue;
       
 11772         }
       
 11773 
       
 11774     TInt resourceSCTId = EditorState()->SpecialCharacterTableResourceId();  
       
 11775     // No SCT table use default SCT
       
 11776     if( resourceSCTId == KErrNotFound || !resourceSCTId )
       
 11777         {
       
 11778         resourceSCTId = NumericModeSCTResourceId();
       
 11779         }   
       
 11780     
       
 11781     if( resourceSCTId )
       
 11782         {
       
 11783         TResourceReader reader;
       
 11784         CEikonEnv::Static()->CreateResourceReaderLC(reader,resourceSCTId);
       
 11785         reader.ReadInt32(); // skip sct id    
       
 11786         TPtrC chars=reader.ReadTPtrC(); // read special char
       
 11787         
       
 11788         validKey = (chars.Locate(chr)>=0 );
       
 11789         if(chr.IsAlpha())
       
 11790             {
       
 11791             chr.UpperCase();
       
 11792             validKey |= (chars.Locate(chr)>=0 ) ;
       
 11793             }                 
       
 11794             
       
 11795         CleanupStack::PopAndDestroy();
       
 11796         }
       
 11797          
       
 11798     return validKey;
       
 11799     
       
 11800     }
       
 11801 #endif //__REVERSE_FN_KEY_SUPPORTED
       
 11802 void CAknFepManager::AddOneSpaceOrMoveCursorL()
       
 11803 	{
       
 11804 	if(static_cast<TChar>(NextChar()).IsSpace())
       
 11805 		{
       
 11806 		TCursorSelection sel;
       
 11807 		iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(sel);
       
 11808 		sel.iCursorPos++;
       
 11809 		sel.iAnchorPos++;
       
 11810 		iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);	                		
       
 11811 		}
       
 11812 	else if(IsEditorHasFreeSpace())
       
 11813     	{
       
 11814         SimulateKeyEventL(EKeySpace);
       
 11815     	}
       
 11816 	SimulateKeyEventL(EKeyF19);
       
 11817 	}
       
 11818 #endif
       
 11819 TBool CAknFepManager::IsOnlyNumericPermitted() const
       
 11820     {
       
 11821     if (IsFeatureSupportedJapanese())
       
 11822         {
       
 11823         return !(iPermittedInputModes & ~(EAknEditorNumericInputMode 
       
 11824                | EAknEditorFullWidthNumericInputMode) );
       
 11825         }
       
 11826     else
       
 11827         {
       
 11828         // Only non-japanese modes are considered.
       
 11829         return !( iPermittedInputModes & 
       
 11830                   (EAknEditorTextInputMode | EAknEditorSecretAlphaInputMode) );
       
 11831         }
       
 11832     }
       
 11833 
       
 11834 void CAknFepManager::TryIncrementModeL(TInt aCurrentMode)
       
 11835     {
       
 11836     //check that we are currently in the correct mode
       
 11837     __ASSERT_DEBUG(IsModePermitted(iMode),
       
 11838                    AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 11839     __ASSERT_DEBUG(iInputCapabilities.FepAwareTextEditor(),
       
 11840                    AknFepPanic(EAknFepPanicNoHandleToFepAwareTextEditor));
       
 11841 
       
 11842     const TInt lastModePos = iHashKeyLoop.Count()-1 ;
       
 11843     const TInt currentModePos = iHashKeyLoop.Find(aCurrentMode);
       
 11844     TInt newModePos = currentModePos;
       
 11845 
       
 11846     __ASSERT_DEBUG(currentModePos != KErrNotFound ,
       
 11847                    AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 11848 
       
 11849     do  {
       
 11850         if (newModePos == lastModePos)
       
 11851             {
       
 11852             //we've got to the end of the hash key loop, go back to the beginning
       
 11853             newModePos = 0;
       
 11854             }
       
 11855         else
       
 11856             {
       
 11857             newModePos++;
       
 11858             }
       
 11859 
       
 11860         if (TryChangeModeL(iHashKeyLoop[newModePos]))
       
 11861             {
       
 11862             return; //succeeded to move to next available mode
       
 11863             }
       
 11864         }
       
 11865         while (newModePos != currentModePos);
       
 11866     }
       
 11867 
       
 11868 void CAknFepManager::TryIncrementModeChineseQwertyL(TInt aCurrentMode)
       
 11869     {
       
 11870     __ASSERT_DEBUG(IsModePermitted(aCurrentMode),AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 11871 
       
 11872     const TInt lastModePos = iHashKeyLoop.Count() - 1 ;
       
 11873     const TInt currentModePos = iHashKeyLoop.Find(aCurrentMode);
       
 11874     TInt newModePos = currentModePos;
       
 11875 
       
 11876     __ASSERT_DEBUG(currentModePos != KErrNotFound ,
       
 11877                    AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 11878 
       
 11879     do  
       
 11880         {
       
 11881         if (newModePos == lastModePos)
       
 11882             {
       
 11883             //we've got to the end of the hash key loop, go back to the beginning
       
 11884             newModePos = 0;
       
 11885             }
       
 11886         else
       
 11887             {
       
 11888             newModePos++;
       
 11889             }
       
 11890         }while(iHashKeyLoop[newModePos] == ENumber && !IsOnlyNumericPermitted()); // no number mode in Chinese qwerty input, except those editors which only support number
       
 11891             
       
 11892     SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
 11893     if(TryChangeModeL(iHashKeyLoop[newModePos]))
       
 11894         {
       
 11895         return; //succeeded to move to next available mode
       
 11896         }
       
 11897     }
       
 11898 
       
 11899 void CAknFepManager::TryIncrementChineseModeForQwertyL( TInt aCurrentMode )
       
 11900     {
       
 11901     __ASSERT_DEBUG(IsModePermitted(aCurrentMode),AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 11902 
       
 11903     const TInt lastModePos = iHashKeyLoop.Count() - 1;
       
 11904     const TInt currentModePos = iHashKeyLoop.Find( aCurrentMode );
       
 11905     TInt newModePos = currentModePos;
       
 11906 
       
 11907     __ASSERT_DEBUG(currentModePos != KErrNotFound ,
       
 11908         AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 11909 
       
 11910     do
       
 11911         {
       
 11912         if ( newModePos == lastModePos )
       
 11913             {
       
 11914             //we've got to the end of the hash key loop, go back to the beginning
       
 11915             newModePos = 0;
       
 11916             }
       
 11917         else
       
 11918             {
       
 11919             newModePos++;
       
 11920             }
       
 11921         }
       
 11922     while ( (iHashKeyLoop[newModePos] == ENumber
       
 11923         && !IsOnlyNumericPermitted()) || (iHashKeyLoop[newModePos] == ELatin
       
 11924         && IsChangeModeByShiftAndSpace() ) ); // no number mode and latin in Chinese qwerty input, except those editors which only support number
       
 11925 
       
 11926     SendEventsToPluginManL( EPluginCloseMode, EFalse );
       
 11927     if ( TryChangeModeL( iHashKeyLoop[newModePos] ) )
       
 11928         {
       
 11929         return; //succeeded to move to next available mode
       
 11930         }
       
 11931     }
       
 11932 
       
 11933 void CAknFepManager::TryChangeToSharedDataModeL()
       
 11934     {
       
 11935     TInt sharedDataMode = iSharedDataInterface->InputMode();
       
 11936     TryChangeModeL(sharedDataMode);
       
 11937     }
       
 11938 
       
 11939 void CAknFepManager::TryChangeToModeBeforeL()
       
 11940     {
       
 11941     if (TryChangeModeL(iModeBefore))
       
 11942         {
       
 11943         if (iModeBefore==ELatin)
       
 11944             {
       
 11945             if ( iCaseBefore )
       
 11946                 {
       
 11947                 iCaseMan->SetCurrentCase(iCaseBefore);
       
 11948                 }
       
 11949             else
       
 11950                 {
       
 11951                 iCaseMan->UpdateCase(ENullNaviEvent);
       
 11952                 }
       
 11953             }
       
 11954         }
       
 11955     }
       
 11956 
       
 11957 #ifdef RD_HINDI_PHONETIC_INPUT    
       
 11958 
       
 11959 TBool CAknFepManager::IsIndicPhoneticInputLanguage() const
       
 11960     {
       
 11961     MPtiLanguage* ptilang = iPtiEngine->CurrentLanguage();
       
 11962     TInt currentPtiLang = (ptilang)? ptilang->LanguageCode() : 0;
       
 11963     return (TAknFepUiIndicInputManager::IsIndicPhoneticLanguage(TLanguage(currentPtiLang)));
       
 11964     }
       
 11965 
       
 11966 void CAknFepManager::TryChangePhoneticModeL()
       
 11967     {
       
 11968     MPtiLanguage* ptilang = iPtiEngine->CurrentLanguage();
       
 11969     TInt currentPtiLang = (ptilang)? ptilang->LanguageCode() : 0;
       
 11970     TInt lang = 0;
       
 11971     
       
 11972     (TAknFepUiIndicInputManager :: IsIndicPhoneticLanguage(TLanguage(currentPtiLang)))? 
       
 11973     lang = ELangEnglish : lang = iLanguageCapabilities.iInputLanguageCode;
       
 11974     
       
 11975     iPtiEngine->ActivateLanguageL(lang);
       
 11976     iLangMan->SetInputLanguageL(lang);
       
 11977     InternalFepUI()->SetMode(iMode, EFalse, iQwertyInputMode);  
       
 11978     iCaseMan->UpdateCase(ENullNaviEvent);
       
 11979     UpdateIndicators();
       
 11980     CommitInlineEditL();
       
 11981     }
       
 11982     
       
 11983 TInt CAknFepManager::SetPhoneticIndicator(TLanguage aInputLanguage)
       
 11984     {
       
 11985     TInt newState = 0;
       
 11986     TInt currentCase = iCaseMan->CurrentCase();
       
 11987 
       
 11988     switch(aInputLanguage)
       
 11989         {
       
 11990         case KLangHindiPhonetic: 
       
 11991             if(currentCase == EAknEditorUpperCase)  
       
 11992                 {
       
 11993                 newState = EIndicatorStateHindiPhoneticUpper;   
       
 11994                 }
       
 11995             else
       
 11996                 {
       
 11997                 newState = EIndicatorStateHindiPhoneticLower;   
       
 11998                 }
       
 11999         break;
       
 12000         default:
       
 12001         break;
       
 12002         }
       
 12003     return newState;        
       
 12004     }
       
 12005 #endif
       
 12006 TBool CAknFepManager::TryChangeModeL(TInt aMode)
       
 12007     {
       
 12008     CAknEdwinState* editorState = EditorState();
       
 12009     TInt sharedDataMode = iSharedDataInterface->InputMode();
       
 12010 
       
 12011     if (aMode == EStroke && iQwertyInputMode && sharedDataMode == ECangJie)
       
 12012     	{
       
 12013     	iEditorStateStrokeUsed = editorState;
       
 12014     	iStrokeUsedInQWERTY = ETrue;
       
 12015     	}
       
 12016     else if (iEditorStateStrokeUsed == editorState)
       
 12017     	{
       
 12018     	iStrokeUsedInQWERTY = EFalse;
       
 12019     	}
       
 12020     
       
 12021     if (aMode == ECangJie && !iQwertyInputMode && 
       
 12022     		(iFepPluginManager->PluginInputMode() != EPluginInputModeVkb
       
 12023 			|| iFepPluginManager->PluginInputMode() != EPluginInputModeFSQ))
       
 12024         {
       
 12025         aMode = EStroke;
       
 12026         }
       
 12027     
       
 12028     if (aMode == ELatinText ||aMode == ELatinUpper || aMode == ELatinLower)
       
 12029         {
       
 12030         if (TryChangeModeL(ELatin))
       
 12031             {
       
 12032             if ( !(iAknEditorFlags & EAknEditorFlagFixedCase) )
       
 12033                 {
       
 12034                 if (aMode == ELatinText)
       
 12035                     {
       
 12036                     ClearFlag(EFlagSupressAutoUpdate);
       
 12037                     }
       
 12038                 else if (aMode == ELatinUpper)
       
 12039                     {
       
 12040                     //Modify for allow text case after entering a dot and space
       
 12041                     ClearFlag(EFlagSupressAutoUpdate);
       
 12042                     //Modify for allow text case after entering a dot and space
       
 12043                     iCaseMan->SetCurrentCase(EAknEditorUpperCase);
       
 12044                     }
       
 12045                 else //lower
       
 12046                     {
       
 12047                     //Modify for allow text case after entering a dot and space
       
 12048                     ClearFlag(EFlagSupressAutoUpdate);
       
 12049                     //Modify for allow text case after entering a dot and space
       
 12050                     iCaseMan->SetCurrentCase(EAknEditorLowerCase);
       
 12051                     }
       
 12052                 UpdateIndicators();
       
 12053                 }
       
 12054             return ETrue;
       
 12055             }
       
 12056         return EFalse;
       
 12057         }
       
 12058 
       
 12059     if ( iQwertyInputMode && ( aMode == ENumber || aMode == ENativeNumber ) && 
       
 12060          !IsOnlyNumericPermitted() 
       
 12061          // Add this condition to exclude all touch inputmethods. 
       
 12062          // When change to number range on touch inputmethods, fn key state can't be locked.          
       
 12063          && iFepPluginManager 
       
 12064          && iFepPluginManager->PluginInputMode() == EPluginInputModeNone )
       
 12065         {
       
 12066         if (TryChangeModeL(ELatin))
       
 12067             {
       
 12068 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12069             // If editor should be launched in FnLock state, because in case of QWERTY keypad
       
 12070             // Current numeric mode converted to alphanumeric mode.
       
 12071             if( iFnKeyManager )
       
 12072                 {
       
 12073                 iFnKeyManager->SetFnKeyState(CAknFepFnKeyManager::EFnKeyLock);
       
 12074                 SetCase((TCase)EFnKeyLowerCase);
       
 12075                 }
       
 12076 #endif // RD_INTELLIGENT_TEXT_INPUT
       
 12077             return ETrue;
       
 12078             }
       
 12079         }
       
 12080 
       
 12081     if (IsModePermitted(aMode))
       
 12082         {
       
 12083         if (aMode == ELatin)
       
 12084             {
       
 12085             if (iAknEditorFlags & EAknEditorFlagNoT9)
       
 12086                 {
       
 12087                 SetWesternPredictive(EFalse);
       
 12088                 }
       
 12089 
       
 12090             if (iAknEditorFlags & EAknEditorFlagFixedCase)
       
 12091                 {
       
 12092                 iCaseMan->ConfigureCaseStateFromEditorState();
       
 12093                 }
       
 12094             }
       
 12095 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
 12096         if (!iQwertyInputMode && WesternPredictive() && iFepManState == EAknFepStateUIActive)
       
 12097 #else
       
 12098         if (WesternPredictive() && iFepManState == EAknFepStateUIActive)
       
 12099 #endif            
       
 12100             {
       
 12101             TryRemoveNoMatchesIndicatorL();
       
 12102             UpdateCbaL(NULL);
       
 12103             }
       
 12104         TryCloseUiL();
       
 12105 
       
 12106         // getting a new ui manager object corresponded in aMode.
       
 12107         MAknFepManagerInterface* fepUI = iLangMan->GetFepUI(aMode, iCharWidth, 
       
 12108                                                             IsPredictive(aMode));
       
 12109         // getting the currect language id from ptiengine.
       
 12110         MPtiLanguage* ptilang = iPtiEngine->CurrentLanguage();
       
 12111         TInt currentPtiLang = (ptilang)? ptilang->LanguageCode() : 0;
       
 12112         // getting the supported language id in current ui manager.
       
 12113         TInt currentUiLang = fepUI->SupportLanguage(aMode);
       
 12114 
       
 12115         // changing language id both ptiengine and ui manager
       
 12116         // 1. check the currect ui manager for input mode
       
 12117         // 2. check the current ptiengine and ui manager
       
 12118         if (iCurrentFepUI != fepUI
       
 12119          || currentPtiLang != currentUiLang)
       
 12120             {
       
 12121             iCurrentFepUI = fepUI;
       
 12122             TInt err = iPtiEngine->ActivateLanguageL(currentUiLang);
       
 12123             if (err != KErrNone)
       
 12124                 {
       
 12125 #ifdef _DEBUG
       
 12126                 RDebug::Print(_L("ActivateLanguageL error return code=[%d] language id=[%d]"),
       
 12127                                 err, iLanguageCapabilities.iInputLanguageCode);
       
 12128 #endif
       
 12129                 ChangeInputLanguageL(ELangEnglish);
       
 12130                 return ETrue;
       
 12131                 }
       
 12132             }
       
 12133 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12134 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
 12135         // Change secondary input
       
 12136         iPtiEngine->SetSecondaryInputL(iSharedDataInterface->InputTextLanguageSecondary());
       
 12137 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
 12138 #endif
       
 12139 
       
 12140 //#ifndef RD_INTELLIGENT_TEXT_INPUT 
       
 12141             TBuf<50> mapData;
       
 12142             //Init Data
       
 12143             for (TInt i = 0; i < 50; i++)
       
 12144                 {
       
 12145                 mapData.Append(0);
       
 12146                 }
       
 12147 
       
 12148             //Backup original input mode
       
 12149             TPtiEngineInputMode oriMode = iPtiEngine->InputMode();
       
 12150             
       
 12151             //Change current input mode, since MappingDataForKey I/F only worked
       
 12152             //when in EPtiEngineMultitapping mode
       
 12153             iPtiEngine->SetInputMode(EPtiEngineMultitapping);
       
 12154             iPtiEngine->MappingDataForKey(EPtiKey1, mapData, iPtiEngine->Case());
       
 12155             
       
 12156             //Restore
       
 12157             iPtiEngine->SetInputMode(oriMode);
       
 12158 
       
 12159             //Get first three symbols
       
 12160 			if(mapData.Length() > 0)
       
 12161 				{
       
 12162 	        	iSymbolData.iSymbol1 = mapData[0];
       
 12163 	            
       
 12164 				if (mapData.Length() > 1)
       
 12165 	            	iSymbolData.iSymbol2 = mapData[1];
       
 12166 	        	if (mapData.Length() > 2)
       
 12167 	        		iSymbolData.iSymbol3 = mapData[2];
       
 12168 				}
       
 12169             
       
 12170             //Write data to stream
       
 12171             if (iFepPluginManager && iFepPluginManager->CurrentPluginInputFepUI())
       
 12172                 {
       
 12173                 iFepPluginManager->CurrentPluginInputFepUI()->HandleCommandL(
       
 12174                             ECmdPenInputSymbolOfHardKeyOne, reinterpret_cast<TInt>(&iSymbolData));
       
 12175                 }
       
 12176 //#endif                
       
 12177         iMode = aMode;
       
 12178         
       
 12179 #ifdef RD_SCALABLE_UI_V2 
       
 12180         if ( IsChineseInputMode( aMode ) )
       
 12181             {
       
 12182             iLastChineseInputMode = aMode;
       
 12183             }        
       
 12184 #endif // RD_SCALABLE_UI_V2
       
 12185         if(iMode == ENumber || iMode == ENativeNumber )
       
 12186             {
       
 12187 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
 12188             ClearFlag(CAknFepManager::EFlagNewSharedDataInputLanguage);
       
 12189             ClearFlag(CAknFepManager::EFlagNewSharedDataInputMode);
       
 12190 #endif //  RD_INTELLIGENT_TEXT_INPUT  
       
 12191             InternalFepUI()->SetNumberModeKeyMappingL(iAknEditorNumericKeymap);
       
 12192             }
       
 12193 #ifdef RD_INTELLIGENT_TEXT_INPUT            
       
 12194         InternalFepUI()->SetMode(iMode, IsPredictive(), iQwertyInputMode, KeyboardLayout());
       
 12195 #else
       
 12196         InternalFepUI()->SetMode(iMode, IsPredictive(), iQwertyInputMode);
       
 12197 #endif        
       
 12198         iHashKeyMan->SetMode(iMode, IsPredictive());
       
 12199         // ensure editor is aware of new fep mode
       
 12200         TCursorSelection curSel;
       
 12201         if ( IsFepAwareTextEditor() )
       
 12202             {
       
 12203             EditorState()->SetCurrentInputMode(EditorModeFromFepMode(aMode));
       
 12204             iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(curSel);
       
 12205             AdjustCursorTypeForCurrentPosition();
       
 12206             }
       
 12207 
       
 12208         // when cursor is in between two words and SCT is launched and
       
 12209         // cancel key is pressed, dont move the cursor at the end of
       
 12210         // second word.     
       
 12211          if (WesternPredictive(aMode) && !curSel.Length()
       
 12212             && CursorInsideWord() && !IsCcpuFlagSet(ECcpuStateSupressCursorMoveToEnd)
       
 12213 #ifdef RD_INTELLIGENT_TEXT_INPUT            
       
 12214             && (!iSupressCursorMoveToEndChrKeyPressed)
       
 12215 #endif //RD_INTELLIGENT_TEXT_INPUT       
       
 12216             )
       
 12217             {
       
 12218             MoveCursorToEndOfWordL();
       
 12219             }
       
 12220         else
       
 12221             {
       
 12222 #ifdef RD_INTELLIGENT_TEXT_INPUT              
       
 12223             iSupressCursorMoveToEndChrKeyPressed = EFalse;
       
 12224 #endif //RD_INTELLIGENT_TEXT_INPUT             
       
 12225             ClearCcpuFlag(ECcpuStateSupressCursorMoveToEnd);
       
 12226             }
       
 12227 
       
 12228 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12229         // Ensure that autocompletion state is updated
       
 12230         if (WesternPredictive())
       
 12231         	{
       
 12232         	SetAutoCompletionState(iSharedDataInterface->PredictiveTextAutoCompleteOn());
       
 12233         	}
       
 12234 #endif
       
 12235         // Set multitap timer to PtiEngine for Japanese variant only
       
 12236         if (IsFeatureSupportedJapanese())
       
 12237             {
       
 12238             TInt timeout = (iInputCapabilities.SupportsSecretText())? 
       
 12239             					KSyncPasswdTimeout : iMultiTapTimer;
       
 12240             iPtiEngine->HandleCommandL(EPtiCommandSetMultitapTimer, &timeout);
       
 12241             iPtiEngine->HandleCommandL(EPtiCommandSetJapaneseQwertyFlags, &iJapaneseQwertyFlags);
       
 12242             TInt clear = iSharedDataInterface->ClearDirection();
       
 12243             iPtiEngine->HandleCommandL(EPtiCommandSetClearFunction, &clear);
       
 12244             // Send PtiEngine the command whether Pictograph is allowed in Candidate list
       
 12245             TInt allow = IsAbleToLaunchPCT();
       
 12246 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 12247             iPtiEngine->HandleCommandL(EPtiCommandAllowPictographCandidate, &allow);
       
 12248 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 12249             }
       
 12250 
       
 12251         UpdateIndicators(); // moved to bottom to avoid extra indicator updates
       
 12252 
       
 12253         return ETrue;
       
 12254         }
       
 12255     return EFalse;
       
 12256     }
       
 12257 
       
 12258 void CAknFepManager::ChangeInputLanguageL(TInt aInputLanguage)
       
 12259     {
       
 12260     	if(iLangMan)
       
 12261     	{
       
 12262     	iLangMan->SetInputLanguageL(aInputLanguage);
       
 12263 
       
 12264     	SetInputLanguageCapabilities(aInputLanguage);
       
 12265 
       
 12266     	ReadHashKeyLoopL();
       
 12267 		// we need to make sure that we commit the word to ptiengine, 
       
 12268 		// so that the word gets added to the UWD 
       
 12269     	SetCcpuFlag(ECcpuStataCommitPredictiveWord);
       
 12270     	// Addition for ITI on FSQ
       
 12271     	// When FSQ is opened with the ITI-supported input language, 
       
 12272     	// if switch to another language which doesn't support ITI, such as Korean,
       
 12273     	// need to restore the previous configuration on FEP
       
 12274         if ( iFepPluginManager && !iFepPluginManager->IsSupportITIOnFSQ() )
       
 12275         	{    	
       
 12276         	iFepPluginManager->ResetItiStateL();
       
 12277         	}    	
       
 12278     	if ( !TryChangeModeL(NewInputModeAfterLanguageChange()) )
       
 12279 	        {
       
 12280 	        if ( !TryChangeModeL(ELatin) )
       
 12281 	            {
       
 12282 	            // If the editor does not support text input mode, we try number mode.
       
 12283 	            if( IsInputModeAvailable(ENativeNumber) && 
       
 12284 	                ( iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic ||
       
 12285 	                  iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic ||
       
 12286 	                  iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari ) )
       
 12287 	                {
       
 12288 	                TryChangeModeL(ENativeNumber);;
       
 12289 	                }
       
 12290 	            else
       
 12291 	                {
       
 12292 	                TryChangeModeL(ENumber);
       
 12293 	                }
       
 12294 	            }
       
 12295 	        }
       
 12296   
       
 12297         if (!iLanguageCapabilities.iLocalInputLanguageInUse)
       
 12298         	{
       
 12299         	switch (iSharedDataInterface->InputTextLanguage())
       
 12300             	{
       
 12301             	case ELangPrcChinese:
       
 12302             		{
       
 12303             		iSharedDataInterface->SetInputMode(EPinyin);
       
 12304             		SetFlag(EFlagNewSharedDataInputMode);
       
 12305             		break;            		
       
 12306             		}
       
 12307             	case ELangTaiwanChinese:
       
 12308             		{
       
 12309             	    iSharedDataInterface->SetInputMode(EZhuyin);
       
 12310             	    SetFlag(EFlagNewSharedDataInputMode);
       
 12311             	    break;
       
 12312             		}
       
 12313             	case ELangHongKongChinese:
       
 12314             		{
       
 12315             	    iSharedDataInterface->SetInputMode(EStroke);
       
 12316             	    iSharedDataInterface->SetCangJieMode(ECangJieNormal);
       
 12317             	    SetFlag(EFlagNewSharedDataInputMode);
       
 12318             	    break;
       
 12319             		}
       
 12320             	default:
       
 12321             		break;
       
 12322             	}
       
 12323             }
       
 12324 
       
 12325     	SetHashKeyStyle();
       
 12326     	UpdateEditorContext();
       
 12327   		}
       
 12328     //add notify to phrase creation udbmanagement view
       
 12329     
       
 12330     if(iUserdbdlg)
       
 12331 	    {
       
 12332 	    iUserdbdlg->OnChangeLanguageL( aInputLanguage );	
       
 12333 	    if ( aInputLanguage != ELangPrcChinese &&
       
 12334 	        	 aInputLanguage != ELangTaiwanChinese &&
       
 12335 	        	 aInputLanguage != ELangHongKongChinese )
       
 12336 	    	{
       
 12337 	    	iUserdbdlg = NULL;
       
 12338 	    	}
       
 12339 	    }
       
 12340     }
       
 12341 
       
 12342 void CAknFepManager::RemovePreviousCharacterL()
       
 12343     {
       
 12344     if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
 12345         {
       
 12346         CommitInlineEditL();
       
 12347         }
       
 12348 
       
 12349     // Set cursor span on previous character
       
 12350     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 12351     if (iUncommittedText.iAnchorPos > 0)
       
 12352         {
       
 12353         iUncommittedText.iAnchorPos--;
       
 12354         }
       
 12355     
       
 12356 
       
 12357     // get text to replace
       
 12358     TBuf<ESingleCharacter> charToReplace;
       
 12359     iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(charToReplace, 
       
 12360                                                                     iUncommittedText.iAnchorPos, 
       
 12361                                                                     ESingleCharacter);
       
 12362 
       
 12363     // delete the character with an inline edit
       
 12364     StartInlineEditL(iUncommittedText, charToReplace, ESingleCharacter, EFalse);
       
 12365     UpdateInlineEditL(KNullDesC, 0);
       
 12366     CommitInlineEditL();
       
 12367     }
       
 12368 
       
 12369 void CAknFepManager::RemoveZWSCharacterL( TBool aIsViramaInputted, 
       
 12370                                             TBool aIsInMultitappingHalant, 
       
 12371                                             TBool aIsCharModifier, 
       
 12372                                             TBool aIsLigaturePresent /*= EFalse*/)
       
 12373     {
       
 12374     CTextLayout* textLayout = TextLayout();
       
 12375     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 12376     if(!textLayout && !docNavi)
       
 12377         return;
       
 12378 
       
 12379     if( aIsLigaturePresent )
       
 12380         {
       
 12381         TTmDocPosSpec pos = DocPos();
       
 12382         TTmPosInfo2 info;
       
 12383         TTmLineInfo lineInfo;
       
 12384         if (docNavi)
       
 12385         	{
       
 12386         	docNavi->FindDocPos(pos, info, lineInfo);
       
 12387         	}
       
 12388         else
       
 12389         	{
       
 12390         	textLayout->TagmaTextLayout().FindDocPos(pos, info, lineInfo);      
       
 12391         	}
       
 12392 
       
 12393         if( IsZWSCharacterPresent( ETrue ) )
       
 12394             {
       
 12395             TInt commitPoint = pos.iPos - 2;
       
 12396             if( IsFlagSet( EFlagInsideInlineEditingTransaction ) )
       
 12397                 {
       
 12398                 CommitInlineEditL();
       
 12399                 }
       
 12400 
       
 12401             TCursorSelection sel( commitPoint, commitPoint );
       
 12402             iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);
       
 12403             }
       
 12404         }
       
 12405     else
       
 12406         {
       
 12407         if ( IsFlagSet(EFlagInsideInlineEditingTransaction) && IsZWSCharacterPresent())
       
 12408             {
       
 12409             CommitInlineEditL();
       
 12410             }
       
 12411         }
       
 12412 
       
 12413     TTmDocPosSpec pos = DocPos();
       
 12414     pos.iType = TTmDocPosSpec::ETrailing;
       
 12415     TTmPosInfo2 info;
       
 12416     TTmLineInfo lineInfo;
       
 12417     if ( ! iInputCapabilities.SupportsSecretText() )
       
 12418         {
       
 12419         if (docNavi)
       
 12420         	{
       
 12421         	docNavi->FindDocPos(pos, info, lineInfo);
       
 12422         	}
       
 12423         else
       
 12424         	{
       
 12425         	textLayout->TagmaTextLayout().FindDocPos(pos, info, lineInfo);
       
 12426         	}
       
 12427         TBuf<2> previousCharacter;
       
 12428         TBuf<1> zwsPrevChar;
       
 12429         previousCharacter.FillZ();
       
 12430         zwsPrevChar.FillZ();
       
 12431         TBool found = EFalse;
       
 12432 
       
 12433         TCursorSelection curSel;
       
 12434         if ( IsFepAwareTextEditor() )
       
 12435             {
       
 12436             iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(curSel);
       
 12437             TInt lowerpos = curSel.LowerPos();
       
 12438             if( lowerpos > 0)
       
 12439                 {
       
 12440                 if(lowerpos > 1)
       
 12441                 iInputCapabilities.FepAwareTextEditor()->
       
 12442                     GetEditorContentForFep(previousCharacter, lowerpos - 2, 2);
       
 12443                 else
       
 12444                 iInputCapabilities.FepAwareTextEditor()->
       
 12445                     GetEditorContentForFep(previousCharacter, lowerpos - 1, 1);
       
 12446                     
       
 12447                 if( lowerpos > 1 )
       
 12448                     {
       
 12449                     if(previousCharacter[1] == ZERO_WIDTH_SPACE)
       
 12450                         {
       
 12451                         zwsPrevChar.Append(previousCharacter[1]);
       
 12452                         if( aIsInMultitappingHalant )
       
 12453                             {
       
 12454                             curSel.iAnchorPos = lowerpos - 2;
       
 12455                             }
       
 12456                         else
       
 12457                             {
       
 12458                             curSel.iAnchorPos = lowerpos - 1;
       
 12459                             }
       
 12460                         found = ETrue;      
       
 12461                         }
       
 12462                     else if( previousCharacter[0] == ZERO_WIDTH_SPACE )
       
 12463                         {
       
 12464                         zwsPrevChar.Append(previousCharacter[0]);
       
 12465                         curSel.iAnchorPos = lowerpos - 2;
       
 12466                         curSel.iCursorPos = lowerpos - 1;                       
       
 12467                         found = ETrue;
       
 12468                         }   
       
 12469                     }
       
 12470                 else
       
 12471                     {
       
 12472                     if(previousCharacter[0] == ZERO_WIDTH_SPACE)
       
 12473                         {
       
 12474                         zwsPrevChar.Append(previousCharacter[0]);
       
 12475                         if( aIsInMultitappingHalant )
       
 12476                             {
       
 12477                             curSel.iAnchorPos = lowerpos - 2;
       
 12478                             }
       
 12479                         else
       
 12480                             {
       
 12481                             curSel.iAnchorPos = lowerpos - 1;
       
 12482                             }
       
 12483                         found = ETrue;    
       
 12484                         }   
       
 12485                     }    
       
 12486                 
       
 12487                 }
       
 12488             }
       
 12489         if( found )
       
 12490             {
       
 12491             StartInlineEditL(curSel, zwsPrevChar, ESingleCharacter, ETrue);
       
 12492             UpdateInlineEditL(KNullDesC, 0);
       
 12493             CommitInlineEditL();    
       
 12494             if ( !aIsInMultitappingHalant && ! iInputCapabilities.SupportsSecretText() )
       
 12495                 {
       
 12496                 if ( aIsViramaInputted )
       
 12497                     {
       
 12498                     TTmDocPosSpec pos = DocPos();
       
 12499                     TTmPosInfo2 infotemp;
       
 12500                     if (docNavi)
       
 12501                     	{
       
 12502                     	docNavi->FindDocPos(pos, info, lineInfo);      
       
 12503                     	}
       
 12504                     else
       
 12505                     	{
       
 12506                     	textLayout->TagmaTextLayout().FindDocPos(pos, info, lineInfo);      
       
 12507                     	}
       
 12508                     if(NextChar() && TAknFepUiIndicInputManager::IsCharBaseConsonant(NextChar(), 
       
 12509                                            TLanguage(iLanguageCapabilities.iInputLanguageCode)))
       
 12510 	                    {
       
 12511 	                    TInt nextPos;                  
       
 12512 	                    if (docNavi)
       
 12513 	                    	{
       
 12514 	                    	nextPos = docNavi->FindNextPos(pos.iPos);
       
 12515 	                    	}
       
 12516 	                    else
       
 12517 	                    	{
       
 12518 		                    nextPos = textLayout->TagmaTextLayout().FindNextPos(pos.iPos);                 
       
 12519 	                    	}
       
 12520 	                    info.iDocPos.iPos  = nextPos;   
       
 12521 	                    }
       
 12522                     else if((TAknFepUiIndicInputManager::IsCharAnVowel(NextChar(), 
       
 12523                              TLanguage(iLanguageCapabilities.iInputLanguageCode)))
       
 12524                          &&(aIsCharModifier && TAknFepUiIndicInputManager::IsCharVirama(
       
 12525                              PreviousChar(), TLanguage(iLanguageCapabilities.iInputLanguageCode))))
       
 12526                         {
       
 12527                         bool posFound;
       
 12528 		                if (docNavi)
       
 12529 		                	{
       
 12530 		                	posFound = docNavi->GetNextVisualCursorPos(pos, infotemp, EFalse);      
       
 12531 		                	}
       
 12532 		                else
       
 12533 		                	{
       
 12534 		                	posFound = textLayout->TagmaTextLayout().GetNextVisualCursorPos(pos, 
       
 12535                                                                                       infotemp, 
       
 12536                                                                                       EFalse);      
       
 12537 		                	}
       
 12538                         
       
 12539                     	if (posFound)
       
 12540                             {
       
 12541                             info.iDocPos.iPos = infotemp.iDocPos.iPos;
       
 12542                             }
       
 12543                         }
       
 12544                     TCursorSelection sel(info.iDocPos.iPos ,info.iDocPos.iPos );
       
 12545                     iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);    
       
 12546                     }
       
 12547                 else
       
 12548                     {
       
 12549                     TCursorSelection sel(info.iDocPos.iPos - 1,info.iDocPos.iPos - 1);
       
 12550                     iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);        
       
 12551                     }   
       
 12552                 
       
 12553                 SendEventsToPluginManL( EPluginSyncFepAwareText );
       
 12554                 }
       
 12555             }
       
 12556         }
       
 12557     }
       
 12558 
       
 12559 void  CAknFepManager::TryChangePredictiveInputModeL(TBool aFlag)
       
 12560     {
       
 12561     if(Japanese() && iMode != ELatin)
       
 12562         {
       
 12563         if(aFlag)
       
 12564             {
       
 12565             if (!(iAknEditorFlags & EAknEditorFlagNoT9)
       
 12566                && HasJapanesePredictionInputMode())
       
 12567                 {
       
 12568                 iJapanesePredictive = aFlag;
       
 12569                 iSharedDataInterface->SetJapanesePredictiveTextOn();
       
 12570                 }
       
 12571             }
       
 12572         else
       
 12573             {
       
 12574             iJapanesePredictive = aFlag;
       
 12575             iSharedDataInterface->ResetJapanesePredictiveTextOn();
       
 12576             }
       
 12577         }
       
 12578     else
       
 12579         {
       
 12580         SetWesternPredictive(aFlag);
       
 12581         }
       
 12582     TryChangeModeL(iMode);
       
 12583     }
       
 12584 
       
 12585 MCoeFepAwareTextEditor* CAknFepManager::FepAwareTextEditor() const
       
 12586     {
       
 12587     return iInputCapabilities.FepAwareTextEditor();
       
 12588     }
       
 12589 
       
 12590 TBool CAknFepManager::IsFepAwareTextEditor() const
       
 12591     {
       
 12592 #ifdef RD_SCALABLE_UI_V2   
       
 12593     return FullyFepAwareTextEditor();
       
 12594 #else
       
 12595 		return ( iInputCapabilities.FepAwareTextEditor() ? ETrue : EFalse );
       
 12596 #endif    
       
 12597     }
       
 12598     
       
 12599 TCursorSelection CAknFepManager::UncommittedText() const
       
 12600     {
       
 12601     return iUncommittedText;
       
 12602     }
       
 12603 
       
 12604 void CAknFepManager::SetCase(TCase aCase)
       
 12605     {
       
 12606     // For QWERTY only keypad, extended input state like FnLock is applicable.
       
 12607     // In case of ITU-T keypad, this flag should not be part of editor flag.
       
 12608     // In case of numeric only editor Only FnReverse state is valid and editor will be on EFnReverse
       
 12609     // State if FnKey is hold on state.
       
 12610     
       
 12611     //TODO: In case of other functionized input state like (FnNext), it should be stored in editor
       
 12612     
       
 12613 #ifdef  RD_INTELLIGENT_TEXT_INPUT
       
 12614     if(EditorState())
       
 12615         {
       
 12616         if( iFnKeyManager &&  ( iFnKeyManager->FnKeyState()== CAknFepFnKeyManager::EFnKeyLock ) )
       
 12617             {
       
 12618             EditorState()->SetFlags( EditorState()->Flags() | EAknEditorFlagFnLock );
       
 12619             }
       
 12620         else
       
 12621             {
       
 12622             EditorState()->SetFlags( EditorState()->Flags() & ~EAknEditorFlagFnLock );       
       
 12623             }
       
 12624         }
       
 12625 #endif
       
 12626 
       
 12627     InternalFepUI()->SetCase(aCase);
       
 12628     }
       
 12629 
       
 12630 CAknEdwinState* CAknFepManager::EditorState() const
       
 12631     {
       
 12632     if ( IsFepAwareTextEditor() )
       
 12633         {
       
 12634         MCoeFepAwareTextEditor* fepAvareTextEditor = iInputCapabilities.FepAwareTextEditor();
       
 12635         
       
 12636         if ( fepAvareTextEditor && fepAvareTextEditor->Extension1() )
       
 12637             {
       
 12638             return static_cast<CAknEdwinState*>( fepAvareTextEditor->Extension1()->State( KNullUid ) );
       
 12639             }
       
 12640         }
       
 12641     return NULL;
       
 12642     }
       
 12643 
       
 12644  void CAknFepManager::SetPredictiveIndicatorState(TAknEditingState& aState)
       
 12645 	{
       
 12646 	
       
 12647 	TInt currentCase = iCaseMan->CurrentCase();
       
 12648 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 12649     if(iIsAutoCompleteOn && iLanguageCapabilities.iInputLanguageCode != ELangThai)
       
 12650     	{
       
 12651        	if (iLanguageCapabilities.iInputLanguageCode == ELangArabic)
       
 12652         	aState=EAutoCompleteArabic;
       
 12653        	
       
 12654        	else if (iLanguageCapabilities.iInputLanguageCode == ELangHebrew)
       
 12655            		 aState=EAutoCompleteHebrew;
       
 12656        	
       
 12657         else if (iLanguageCapabilities.iInputLanguageCode == ELangFarsi ||
       
 12658             	 iLanguageCapabilities.iInputLanguageCode == ELangUrdu)
       
 12659             	 aState=EAutoCompleteFarsiAndUrdu;
       
 12660              	/*Hindi*/
       
 12661         else if ( (iLanguageCapabilities.iInputLanguageCode == ELangHindi) || (iLanguageCapabilities.iInputLanguageCode == ELangMarathi))
       
 12662         		  aState = EAutoCompleteHindi;
       
 12663         
       
 12664         else if(iLanguageCapabilities.iInputLanguageCode == ELangVietnamese)
       
 12665             	{
       
 12666             	switch (currentCase)
       
 12667                 	{
       
 12668                 	case EAknEditorUpperCase:
       
 12669                     	aState =  EAutoCompleteUpperVietnamese;
       
 12670                     	break;
       
 12671                 	case EAknEditorLowerCase:
       
 12672                     	aState =  EAutoCompleteLowerVietnamese;
       
 12673                     	break;
       
 12674                     case EAknEditorTextCase:
       
 12675                         aState = EAutoCompleteShiftedVietnamese;
       
 12676                         break;
       
 12677                     default:
       
 12678                         break;
       
 12679                     }    
       
 12680                 }
       
 12681         else
       
 12682                 {
       
 12683                 switch (currentCase)
       
 12684                     {
       
 12685                     case EAknEditorUpperCase:
       
 12686                         aState =  EAutoCompleteUpper;
       
 12687                         break;
       
 12688                     case EAknEditorLowerCase:
       
 12689                         aState =  EAutoCompleteLower;
       
 12690                         break;
       
 12691                     case EAknEditorTextCase:
       
 12692                         aState = EAutoCompleteShifted;
       
 12693                         break;
       
 12694                     default:
       
 12695                         break;
       
 12696                     }
       
 12697                 }
       
 12698             
       
 12699     	}
       
 12700     else
       
 12701 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 12702 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12703 		if(iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNone)
       
 12704 			{
       
 12705 			aState = EFnKeyPressed;
       
 12706 			if(iFnKeyManager->FnKeyState() == CAknFepFnKeyManager::EFnKeyLock)
       
 12707 	            aState = EFnKeyLocked;    
       
 12708 			}
       
 12709         else
       
 12710 #endif
       
 12711         {
       
 12712     	if (iLanguageCapabilities.iInputLanguageCode == ELangArabic)
       
 12713       	 	 aState = ET9Arabic;
       
 12714     	
       
 12715    		else if (iLanguageCapabilities.iInputLanguageCode == ELangHebrew)
       
 12716         	     aState = ET9Hebrew;
       
 12717    		
       
 12718     	else if (iLanguageCapabilities.iInputLanguageCode == ELangFarsi ||
       
 12719         	     iLanguageCapabilities.iInputLanguageCode == ELangUrdu)
       
 12720         		 aState = ET9FarsiAndUrdu;
       
 12721         		 
       
 12722     	else if (iLanguageCapabilities.iInputLanguageCode == ELangThai)
       
 12723         		 aState = ET9Thai;
       
 12724     	
       
 12725     	/*Hindi*/
       
 12726 #ifdef RD_MARATHI
       
 12727                         /*Marathi*/
       
 12728                         else if ( iLanguageCapabilities.iInputLanguageCode == ELangMarathi )
       
 12729                         	aState = EIndicatorStatePredictiveMarathi;
       
 12730 #endif // RD_MARATHI
       
 12731     	
       
 12732     	else if(iLanguageCapabilities.iInputLanguageCode == ELangVietnamese)
       
 12733         	{
       
 12734         	switch (currentCase)
       
 12735             	{
       
 12736             	case EAknEditorUpperCase:
       
 12737                 	aState =  ET9UpperVietnamese;
       
 12738                 	break;
       
 12739             	case EAknEditorLowerCase:
       
 12740                 	aState =  ET9LowerVietnamese;
       
 12741                 	break;
       
 12742                 case EAknEditorTextCase:
       
 12743                     aState = ET9ShiftedVietnamese;
       
 12744                     break;
       
 12745                 default:
       
 12746                     break;
       
 12747                 }    
       
 12748             }
       
 12749         
       
 12750         else if(iLanguageCapabilities.iInputLanguageCode == ELangGreek)
       
 12751             {
       
 12752             switch (currentCase)
       
 12753                 {
       
 12754                 case EAknEditorUpperCase:
       
 12755                     aState =  ET9UpperGreek;
       
 12756                     break;
       
 12757                 case EAknEditorLowerCase:
       
 12758                     aState =  ET9LowerGreek;
       
 12759                     break;
       
 12760                 case EAknEditorTextCase:
       
 12761                     aState = ET9ShiftedGreek;
       
 12762                     break;
       
 12763                 default:
       
 12764                     break;
       
 12765                 }    
       
 12766             }
       
 12767         
       
 12768         //Cyrillic alphabet is used for Russian, Bulgarian and 
       
 12769         //Ukranian languages
       
 12770         else if(iLanguageCapabilities.iInputLanguageCode == ELangRussian ||
       
 12771                 iLanguageCapabilities.iInputLanguageCode == ELangBulgarian ||
       
 12772                 iLanguageCapabilities.iInputLanguageCode == ELangUkrainian )
       
 12773             {
       
 12774             switch (currentCase)
       
 12775                 {
       
 12776                 case EAknEditorUpperCase:
       
 12777                     aState =  ET9UpperCyrillic;
       
 12778                     break;
       
 12779                 case EAknEditorLowerCase:
       
 12780                     aState =  ET9LowerCyrillic;
       
 12781                     break;
       
 12782                 case EAknEditorTextCase:
       
 12783                     aState = ET9ShiftedCyrillic;
       
 12784                     break;
       
 12785                 default:
       
 12786                     break;
       
 12787                 }    
       
 12788             }
       
 12789         else
       
 12790             {
       
 12791             switch (currentCase)
       
 12792                 {
       
 12793                 case EAknEditorUpperCase:
       
 12794                     aState = ET9Upper;
       
 12795                     break;
       
 12796                 case EAknEditorLowerCase:
       
 12797                     aState = ET9Lower;
       
 12798                     break;
       
 12799                 case EAknEditorTextCase:
       
 12800                     aState = ET9Shifted;
       
 12801                     break;
       
 12802                 default:
       
 12803                     break;
       
 12804                 }
       
 12805             }
       
 12806         
       
 12807     	}
       
 12808 	}
       
 12809 void CAknFepManager::UpdateIndicators()
       
 12810     { 
       
 12811     if(ELongKeyPress == iKeyRepeat)
       
 12812         return;	
       
 12813 	// If it is fepware editor update the Indicators
       
 12814 	// otherwise not need excute remainig part of code.
       
 12815 	if( !iInputCapabilities.FepAwareTextEditor() || !iFepFullyConstructed ) 
       
 12816 		{
       
 12817         //Ensure, If no idicator is require, make indicator state None 
       
 12818         if (!IsFlagSet(EFlagForegroundUIComponentVisible | EFlagMenuPaneVisible))
       
 12819             iIndicator->SetState(EStateNone);
       
 12820 		return;
       
 12821 		}
       
 12822 
       
 12823     TAknEditingState newState = EStateNone;
       
 12824     MPtiLanguage* ptiLang = PtiEngine()->CurrentLanguage();    
       
 12825     MAknEditingStateIndicator* editingStateIndicator = EditingStateIndicator();
       
 12826 
       
 12827     TBool findPaneIndicator(
       
 12828         iAknEditorFlags & EAknEditorFlagNoEditIndicators &&
       
 12829         iAknEditorFlags & EAknEditorFlagForceTransparentFepModes &&
       
 12830         editingStateIndicator != (MAknEditingStateIndicator*)iIndicator );
       
 12831 
       
 12832 #ifdef RD_SCALABLE_UI_V2
       
 12833     TBool fingerItutIndicator = ( iFepPluginManager && 
       
 12834                                   iFepPluginManager->PluginInputMode() == EPluginInputModeItut );
       
 12835     // Portrait FSQ is added.
       
 12836     TBool fingerFSQIndicator = ( iFepPluginManager && 
       
 12837             ( iFepPluginManager->PluginInputMode() == EPluginInputModeFSQ ||
       
 12838               iFepPluginManager->PluginInputMode() == EPluginInputModePortraitFSQ ) );
       
 12839 #else
       
 12840     TBool fingerItutIndicator = EFalse;
       
 12841     TBool fingerFSQIndicator = EFalse;
       
 12842     
       
 12843 #endif
       
 12844     if ( IsHybridAplhaEditor() && !iHybridAplphaChangedToAlphanumeric )
       
 12845             {
       
 12846             newState = EHybridModeLatin;
       
 12847             }    
       
 12848     //else if (!(iAknEditorFlags & EAknEditorFlagNoEditIndicators) 
       
 12849     //    || findPaneIndicator || fingerItutIndicator)
       
 12850     else if (!(iAknEditorFlags & EAknEditorFlagNoEditIndicators) 
       
 12851         || findPaneIndicator || fingerItutIndicator || fingerFSQIndicator)
       
 12852         {
       
 12853         
       
 12854 #ifdef RD_SCALABLE_UI_V2
       
 12855         if ( ( IsFlagSet(EFlagQwertyShiftMode)  || IsFlagSet(EFlagLongShiftKeyPress)) &&
       
 12856              ((iFepPluginManager && iFepPluginManager->PluginInputMode() == EPluginInputModeVkb) ||
       
 12857         #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 12858 			      iQwertyInputMode
       
 12859       	#else	       								
       
 12860 		           ( iQwertyInputMode && (IsFlagSet(EFlagQwertyShiftMode) ||IsFlagSet(EFlagLongShiftKeyPress))
       
 12861 		           && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNext)
       
 12862 		           && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyLock)
       
 12863 		           && (iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyForced)
       
 12864 		           )
       
 12865 		#endif
       
 12866              ))
       
 12867 #else
       
 12868         if ( iQwertyInputMode && IsFlagSet(EFlagQwertyShiftMode))
       
 12869     
       
 12870 #endif        
       
 12871             {
       
 12872             newState = EQwertyShift;
       
 12873 
       
 12874 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
 12875 			// To keep the shift key indicator in         
       
 12876             // Check if fn/shift both key are pressed 
       
 12877             if((iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNone) &&
       
 12878             	(IsFlagSet(EFlagQwertyShiftMode) || IsFlagSet(EFlagLongShiftKeyPress)))
       
 12879 	            {
       
 12880 	            newState = EFnKeyPressed;	
       
 12881 	            }
       
 12882 #endif            
       
 12883             
       
 12884             }
       
 12885         else
       
 12886             {
       
 12887             switch (iMode)
       
 12888                 {
       
 12889                 case EHiraganaKanji:
       
 12890                     if (IsPredictive())
       
 12891                         {
       
 12892                         newState = EIndicatorStateJapanesePredictive;
       
 12893                         }
       
 12894                     else
       
 12895                         {
       
 12896                         newState = EIndicatorStateHiraganaKanji;
       
 12897                         }
       
 12898                     break;
       
 12899                 case EKatakana:
       
 12900                     if (iCharWidth == EHalfWidthChar)
       
 12901                         {
       
 12902                         newState = EIndicatorStateHalfKatakana;
       
 12903                         }
       
 12904                     else if (iCharWidth == EFullWidthChar)
       
 12905                         {
       
 12906                         newState = EIndicatorStateFullKatakana;
       
 12907                         }
       
 12908                     break;
       
 12909                 case EHiragana:
       
 12910                     {
       
 12911                     newState = EIndicatorStateHiragana;
       
 12912                     }
       
 12913                     break;
       
 12914                 case EPinyin:
       
 12915                     if (ptiLang->HasInputMode(EPtiEnginePinyinByPhrase))
       
 12916                         {
       
 12917                         newState = EIndicatorStatePinyinPhrase;
       
 12918                         }                        
       
 12919                     else
       
 12920                         {
       
 12921                         newState = EIndicatorStatePinyin;
       
 12922                         }                        
       
 12923 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12924                     if ( iFnKeyManager->FnKeyState()
       
 12925                         == CAknFepFnKeyManager::EFnKeyLock )
       
 12926                         newState = EFnKeyLocked;
       
 12927                     else if ( iFnKeyManager->FnKeyState()
       
 12928                         != CAknFepFnKeyManager::EFnKeyNone )
       
 12929                         newState = EFnKeyPressed;
       
 12930 #endif
       
 12931                     break;
       
 12932                 case EZhuyin:
       
 12933                     if (ptiLang->HasInputMode(EPtiEngineZhuyinByPhrase))
       
 12934                         {
       
 12935                         newState = EIndicatorStateZhuyinPhrase;
       
 12936                         }                        
       
 12937                     else
       
 12938                         {
       
 12939                         newState = EIndicatorStateZhuyin;
       
 12940                         }                        
       
 12941 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12942                     if ( iFnKeyManager->FnKeyState()
       
 12943                         == CAknFepFnKeyManager::EFnKeyLock )
       
 12944                         newState = EFnKeyLocked;
       
 12945                     else if ( iFnKeyManager->FnKeyState()
       
 12946                         != CAknFepFnKeyManager::EFnKeyNone )
       
 12947                         newState = EFnKeyPressed;
       
 12948 #endif
       
 12949                     break;
       
 12950                 case EStroke:
       
 12951                     {
       
 12952                     TBool flag = ptiLang->HasInputMode(EPtiEngineStrokeByPhrase);
       
 12953                     if (iLanguageCapabilities.iInputLanguageCode == ELangPrcChinese)
       
 12954                         {
       
 12955                         if (flag)
       
 12956                             {
       
 12957                             newState = EIndicatorStateStrokePhrase;
       
 12958                             }                            
       
 12959                         else
       
 12960                             {
       
 12961                             newState = EIndicatorStateStroke;
       
 12962                             }                            
       
 12963                         }
       
 12964                     else
       
 12965                         {
       
 12966                         if (flag)
       
 12967                             {
       
 12968                             newState = EIndicatorStateStrokeTradPhrase;
       
 12969                             }                            
       
 12970                         else
       
 12971                             {
       
 12972                             newState = EIndicatorStateStrokeTrad;
       
 12973                             }                            
       
 12974                         }
       
 12975                         }
       
 12976 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12977                     if ( iFnKeyManager->FnKeyState()
       
 12978                         == CAknFepFnKeyManager::EFnKeyLock )
       
 12979                         newState = EFnKeyLocked;
       
 12980                     else if ( iFnKeyManager->FnKeyState()
       
 12981                         != CAknFepFnKeyManager::EFnKeyNone )
       
 12982                         newState = EFnKeyPressed;
       
 12983 #endif
       
 12984                     break;
       
 12985                 case ECangJie:
       
 12986                     newState = EIndicatorStateCangJie;
       
 12987 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 12988                     if ( iFnKeyManager->FnKeyState()
       
 12989                         == CAknFepFnKeyManager::EFnKeyLock )
       
 12990                         newState = EFnKeyLocked;
       
 12991                     else if ( iFnKeyManager->FnKeyState()
       
 12992                         != CAknFepFnKeyManager::EFnKeyNone )
       
 12993                         newState = EFnKeyPressed;
       
 12994 #endif
       
 12995                     break;
       
 12996                 case EZhuyinFind:
       
 12997                     newState = EIndicatorStateZhuyinFind;
       
 12998                     break;
       
 12999                 case EStrokeFind:
       
 13000                     newState = EIndicatorStateStrokeFind;
       
 13001                     break;
       
 13002                 case ENumber:
       
 13003                     {
       
 13004                     newState = ENumeric;
       
 13005                     //iLanguageCapabilities.iLocalDigitType = EDigitTypeWestern;
       
 13006                     }
       
 13007                     break;
       
 13008                 case ENativeNumber:
       
 13009                     {
       
 13010                     UpdateNumberIndicator( newState );
       
 13011                     }
       
 13012                     break;
       
 13013                 case EHangul:
       
 13014                 	{
       
 13015                 	newState = EIndicatorStateHangul;            	              	
       
 13016                 	}
       
 13017                 	break;
       
 13018                 case ELatin:
       
 13019                     {
       
 13020                     UpdateLatinIndicator( newState );
       
 13021                     }
       
 13022                     break;
       
 13023                 case EHindi:
       
 13024                     {
       
 13025                     UpdateHindiIndicator( newState );
       
 13026                     }
       
 13027                     break;
       
 13028                 default:
       
 13029                     break;
       
 13030            }
       
 13031         }
       
 13032     }
       
 13033 
       
 13034     if ( iFepPluginManager && iFepPluginManager->PluginInputMode() == EPluginInputModeVkb )
       
 13035         {
       
 13036         newState = iFepPluginManager->VKBIndicatorState( newState );
       
 13037         }
       
 13038 
       
 13039     // Update indicators only if the state has been changed, or if the indicator has swapped
       
 13040     if ((iPreviousEditingState != newState) || (editingStateIndicator != iEditIndicatorAtLastUpdate))
       
 13041         {
       
 13042         if (editingStateIndicator)
       
 13043             {
       
 13044             // because current avkon have not find chinese phrase indicator,
       
 13045             // so change back to no-phrase
       
 13046            if (findPaneIndicator || iAknEditorFlags & EAknEditorFlagFindPane )
       
 13047                 {
       
 13048                 switch(newState)
       
 13049                     {
       
 13050                     case EIndicatorStateStrokePhrase:
       
 13051                         {
       
 13052                         newState = EIndicatorStateStroke; 
       
 13053                         }
       
 13054                     break;
       
 13055                     case EIndicatorStateStrokeTradPhrase:
       
 13056                         {
       
 13057                         newState = EIndicatorStateStrokeTrad; 
       
 13058                         }
       
 13059                     break;
       
 13060                     case EIndicatorStatePinyinPhrase:
       
 13061                         {
       
 13062                         newState = EIndicatorStatePinyin; 
       
 13063                         }
       
 13064                     break;
       
 13065                     case EIndicatorStateZhuyinPhrase:
       
 13066                         {
       
 13067                         newState = EIndicatorStateZhuyin; 
       
 13068                         }
       
 13069                     break;
       
 13070                     default:
       
 13071                         {
       
 13072                         break;
       
 13073                         }
       
 13074                     }
       
 13075                 }
       
 13076            // Add This condition for  Phonebook, ReTe, PF52.50_2008_wk32: 
       
 13077            // Navigation bar disappears after tapping find pane and then returning back to Names list view.
       
 13078            // Portrait FSQ is added.
       
 13079            if (!(editingStateIndicator == (MAknEditingStateIndicator*)iIndicator &&
       
 13080                ( iFepPluginManager && 
       
 13081                     ( iFepPluginManager->PluginInputMode() == EPluginInputModeItut 
       
 13082                     || iFepPluginManager->PluginInputMode() == EPluginInputModeFSQ 
       
 13083                     || iFepPluginManager->PluginInputMode() == EPluginInputModePortraitFSQ ) ) &&
       
 13084                IsFindPaneEditor()))
       
 13085                {
       
 13086                editingStateIndicator->SetState(newState);
       
 13087                }
       
 13088 
       
 13089             // Ensure that no indicator is shown in navi pane when other
       
 13090             // indicator is changed in use.
       
 13091             if ( editingStateIndicator != (MAknEditingStateIndicator*)iIndicator &&
       
 13092                  iPreviousEditingState == EStateNone &&
       
 13093                  (!IsFlagSet(EFlagForegroundUIComponentVisible | EFlagMenuPaneVisible)) )
       
 13094 
       
 13095                 {
       
 13096                 iIndicator->SetState( EStateNone );
       
 13097                 }
       
 13098 
       
 13099             iPreviousEditingState = newState;
       
 13100             iEditIndicatorAtLastUpdate=editingStateIndicator;
       
 13101             }
       
 13102         }
       
 13103     }
       
 13104 
       
 13105 void CAknFepManager::UpdateNumberIndicator( TAknEditingState& aNewState )
       
 13106     {
       
 13107     
       
 13108  // The fix is made only for Hindi
       
 13109     UpdateNumericEditorDigitType();
       
 13110     TBool supportsWesternNumericIntegerOrReal =
       
 13111         ( iInputCapabilities.SupportsWesternNumericIntegerPositive() ||
       
 13112         iInputCapabilities.SupportsWesternNumericIntegerNegative() ||
       
 13113         iInputCapabilities.SupportsWesternNumericReal() );
       
 13114 
       
 13115 #ifdef RD_SCALABLE_UI_V2                        
       
 13116         iFepPluginManager->SetPluginNativeRange( ETrue );
       
 13117 #endif // RD_SCALABLE_UI_V2 
       
 13118         // In usual case digit mode is Arabic-Indic digits if local digit mode is
       
 13119         // Arabic-Indic and current input language is Arabic.
       
 13120         if ( (!supportsWesternNumericIntegerOrReal &&
       
 13121             iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic /* &&
       
 13122             iLanguageCapabilities.iInputLanguageCode == ELangArabic*/
       
 13123             )
       
 13124             ||
       
 13125             // But digit mode is Arabic-Indic digit in MFNE and real number
       
 13126             // editors if UI language is Arabic and global digit setting is
       
 13127             // Arabic-Indic digits.
       
 13128             ( !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
 13129             iLanguageCapabilities.iNumericEditorDigitType == EDigitTypeArabicIndic && // AknTextUtils::DigitModeQuery(AknTextUtils::EDigitModeShownToUser) &&
       
 13130             supportsWesternNumericIntegerOrReal &&
       
 13131             iUiLanguage == ELangArabic
       
 13132             )
       
 13133             )
       
 13134             {
       
 13135             aNewState=EArabicIndicNumeric;
       
 13136                         
       
 13137             }
       
 13138         else if ( (!supportsWesternNumericIntegerOrReal &&
       
 13139             iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic /* &&
       
 13140             iLanguageCapabilities.iInputLanguageCode == ELangUrdu,Farasi*/
       
 13141             )
       
 13142             ||
       
 13143             // But digit mode is Arabic-Indic digit in MFNE and real number
       
 13144             // editors if UI language is Arabic and global digit setting is
       
 13145             // Arabic-Indic digits.
       
 13146             ( !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
 13147             iLanguageCapabilities.iNumericEditorDigitType == EDigitTypeEasternArabicIndic && // AknTextUtils::DigitModeQuery(AknTextUtils::EDigitModeShownToUser) &&
       
 13148             supportsWesternNumericIntegerOrReal &&
       
 13149             (iUiLanguage == ELangUrdu || iUiLanguage == ELangFarsi)))
       
 13150             {
       
 13151             aNewState=EArabicIndicNumeric;                            
       
 13152             }    
       
 13153         /* Devanagari Scripts */
       
 13154         else if ( (!supportsWesternNumericIntegerOrReal &&
       
 13155                 iLanguageCapabilities.iLocalDigitType == EDigitTypeDevanagari //&&
       
 13156                 //iLanguageCapabilities.iInputLanguageCode == ELangHindi
       
 13157                 )
       
 13158                 ||
       
 13159                 ( !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) &&
       
 13160                 iLanguageCapabilities.iNumericEditorDigitType == EDigitTypeDevanagari && // AknTextUtils::DigitModeQuery(AknTextUtils::EDigitModeShownToUser) &&
       
 13161                 supportsWesternNumericIntegerOrReal &&
       
 13162                 TAknFepUiIndicInputManager::IsScriptDevanagari( iUiLanguage )
       
 13163                 )
       
 13164                 )
       
 13165             {
       
 13166             aNewState= EDevanagariIndicNumeric;                            
       
 13167             }
       
 13168         else
       
 13169         {
       
 13170         if ( iLanguageCapabilities.iInputLanguageCode == ELangArabic )
       
 13171             {
       
 13172             iLanguageCapabilities.iLocalDigitType = EDigitTypeArabicIndic;
       
 13173             aNewState=EArabicIndicNumeric;
       
 13174             }
       
 13175         else if ( iLanguageCapabilities.iInputLanguageCode == ELangFarsi 
       
 13176                || iLanguageCapabilities.iInputLanguageCode == ELangUrdu )
       
 13177             {
       
 13178             iLanguageCapabilities.iLocalDigitType = EDigitTypeEasternArabicIndic;
       
 13179             aNewState=EArabicIndicNumeric;
       
 13180             }    
       
 13181         else if ( iLanguageCapabilities.iInputLanguageCode == ELangHindi )
       
 13182             {
       
 13183             //iLanguageCapabilities.iLocalDigitType = EDigitTypeDevanagari;
       
 13184             aNewState= EDevanagariIndicNumeric;
       
 13185             }
       
 13186         }
       
 13187     }
       
 13188     
       
 13189 void CAknFepManager::UpdateLatinIndicator( TAknEditingState& aNewState )
       
 13190     {  
       
 13191     if (IsPredictive())
       
 13192         {
       
 13193         //AutoComplete - Begin
       
 13194         SetPredictiveIndicatorState( aNewState );
       
 13195         //AutoComplete - End
       
 13196 
       
 13197         return;           
       
 13198         }
       
 13199 
       
 13200     TInt currentCase = iCaseMan->CurrentCase();
       
 13201 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 13202 	if(iFnKeyManager->FnKeyState() == CAknFepFnKeyManager::EFnKeyLock)
       
 13203 		aNewState = EFnKeyLocked;
       
 13204     else if(iFnKeyManager->FnKeyState() != CAknFepFnKeyManager::EFnKeyNone)
       
 13205 		aNewState = EFnKeyPressed;
       
 13206 	else    
       
 13207 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 13208 		{
       
 13209 #ifdef RD_SCALABLE_UI_V2                        
       
 13210     if( iFepPluginManager &&
       
 13211         ( !iFepPluginManager->SyncWithPluginRange() || iFepPluginManager->PluginNativeRange() ) )
       
 13212         {
       
 13213         iFepPluginManager->SetPluginNativeRange( ETrue );
       
 13214 #endif // RD_SCALABLE_UI_V2 
       
 13215         switch ( iLanguageCapabilities.iInputLanguageCode )
       
 13216             {
       
 13217             case ELangArabic:
       
 13218                 {
       
 13219                 aNewState=EMultitapArabic; 
       
 13220                 }
       
 13221                 return;
       
 13222             case ELangHebrew:
       
 13223                 {
       
 13224                 aNewState=EMultitapHebrew;                              
       
 13225                 }
       
 13226                 return;
       
 13227             case ELangFarsi:
       
 13228             case ELangUrdu:
       
 13229                 {
       
 13230                 aNewState=EMultitapFarsiAndUrdu;                                 
       
 13231                 }
       
 13232                 return;
       
 13233             case ELangThai:
       
 13234                 {
       
 13235                 aNewState = EMultitapThai;                               
       
 13236                 }
       
 13237                 return;
       
 13238                 
       
 13239 #ifdef RD_MARATHI
       
 13240             case ELangMarathi:
       
 13241                 {
       
 13242                 aNewState = EIndicatorStateMultitapMarathi;                                
       
 13243                 }
       
 13244             	return;
       
 13245 #endif // RD_MARATHI
       
 13246 
       
 13247 #ifdef RD_HINDI_PHONETIC_INPUT  
       
 13248             case KLangHindiPhonetic:
       
 13249                 {                            
       
 13250                 TInt currentPtiLang = (ptiLang)? ptiLang->LanguageCode() : 0;
       
 13251                 
       
 13252                 if(TAknFepUiIndicInputManager::IsIndicPhoneticLanguage(TLanguage(currentPtiLang)))
       
 13253                     {
       
 13254                     aNewState = TAknEditingState(SetPhoneticIndicator(TLanguage(currentPtiLang)));
       
 13255                     }
       
 13256                 else
       
 13257                     {
       
 13258                      switch ( currentCase )
       
 13259                         {
       
 13260                         case EAknEditorUpperCase:
       
 13261                             aNewState=EMultitapUpper;
       
 13262                             if (iCharWidth == EFullWidthChar)
       
 13263                                 {
       
 13264                                 aNewState=EIndicatorStateFullLatinUpper;
       
 13265                                 }
       
 13266                             break;
       
 13267                         case EAknEditorLowerCase:
       
 13268                             aNewState=EMultitapLower;
       
 13269                             if (iCharWidth == EFullWidthChar)
       
 13270                                 {
       
 13271                                 aNewState=EIndicatorStateFullLatinLower;
       
 13272                                 }
       
 13273                             break;
       
 13274                         case EAknEditorTextCase:
       
 13275                             aNewState=EMultitapShifted;
       
 13276                             if (iCharWidth == EFullWidthChar)
       
 13277                                 {
       
 13278                                 aNewState=EIndicatorStateFullLatinText;
       
 13279                                 }
       
 13280                             break;
       
 13281                         default:
       
 13282                             break;
       
 13283                         }
       
 13284                     }       
       
 13285                 
       
 13286                 }
       
 13287             return;
       
 13288 #endif
       
 13289             case ELangVietnamese:
       
 13290                 {                          
       
 13291                 switch (currentCase)
       
 13292                     {
       
 13293                     case EAknEditorUpperCase:
       
 13294                         aNewState =  EMultitapUpperVietnamese;
       
 13295                         break;
       
 13296                     case EAknEditorLowerCase:
       
 13297                         aNewState =  EMultitapLowerVietnamese;
       
 13298                         break;
       
 13299                     case EAknEditorTextCase:
       
 13300                         aNewState = EMultitapShiftedVietnamese;
       
 13301                         break;
       
 13302                     default:
       
 13303                         break;
       
 13304                     }
       
 13305 				return;	  
       
 13306                 }
       
 13307                 
       
 13308             case ELangGreek:
       
 13309                 {
       
 13310                 switch (currentCase)
       
 13311                     {
       
 13312                     case EAknEditorUpperCase:
       
 13313                         aNewState =  EMultitapUpperGreek;
       
 13314                         break;
       
 13315                     case EAknEditorLowerCase:
       
 13316                         aNewState =  EMultitapLowerGreek;
       
 13317                         break;
       
 13318                     case EAknEditorTextCase:
       
 13319                         aNewState = EMultitapShiftedGreek;
       
 13320                         break;
       
 13321                     default:
       
 13322                         break;
       
 13323                     }
       
 13324 				return;  
       
 13325                 }
       
 13326             
       
 13327             //Cyrillic alphabet is used for Russian, Bulgarian and 
       
 13328             //Ukranian languages. So fall through for all these languages -
       
 13329             case ELangRussian:
       
 13330             case ELangBulgarian:
       
 13331             case ELangUkrainian:
       
 13332                 {
       
 13333                 switch (currentCase)
       
 13334                     {
       
 13335                     case EAknEditorUpperCase:
       
 13336                         aNewState =  EMultitapUpperCyrillic;
       
 13337                         break;
       
 13338                     case EAknEditorLowerCase:
       
 13339                         aNewState =  EMultitapLowerCyrillic;
       
 13340                         break;
       
 13341                     case EAknEditorTextCase:
       
 13342                         aNewState = EMultitapShiftedCyrillic;
       
 13343                         break;
       
 13344                     default:
       
 13345                         break;
       
 13346                     } 
       
 13347 				return; 
       
 13348                 }
       
 13349             }
       
 13350 #ifdef RD_SCALABLE_UI_V2     
       
 13351         }
       
 13352         // if plugin is not native range
       
 13353     
       
 13354     if(iFepPluginManager && iLanguageCapabilities.iInputLanguageCode != ELangRussian &&
       
 13355        iLanguageCapabilities.iInputLanguageCode != ELangBulgarian &&
       
 13356        iLanguageCapabilities.iInputLanguageCode != ELangUkrainian &&
       
 13357        iLanguageCapabilities.iInputLanguageCode != ELangGreek )
       
 13358         {
       
 13359         iFepPluginManager->SetPluginNativeRange( EFalse );
       
 13360         }
       
 13361     
       
 13362 #endif // RD_SCALABLE_UI_V2                                 
       
 13363 		}
       
 13364 #ifdef RD_INTELLIGENT_TEXT_INPUT		
       
 13365 	if(FnKeyState() == CAknFepFnKeyManager::EFnKeyNone)
       
 13366 #endif //RD_INTELLIGENT_TEXT_INPUT		
       
 13367 	    {
       
 13368         switch (currentCase)
       
 13369         {
       
 13370         case EAknEditorUpperCase:
       
 13371             aNewState=EMultitapUpper;
       
 13372             if (iCharWidth == EFullWidthChar)
       
 13373                 {
       
 13374                 aNewState=EIndicatorStateFullLatinUpper;
       
 13375                 }
       
 13376             break;
       
 13377         case EAknEditorLowerCase:
       
 13378             aNewState=EMultitapLower;
       
 13379             if (iCharWidth == EFullWidthChar)
       
 13380                 {
       
 13381                 aNewState=EIndicatorStateFullLatinLower;
       
 13382                 }
       
 13383             break;
       
 13384         case EAknEditorTextCase:
       
 13385             aNewState=EMultitapShifted;
       
 13386             if (iCharWidth == EFullWidthChar)
       
 13387                 {
       
 13388                 aNewState=EIndicatorStateFullLatinText;
       
 13389                 }
       
 13390             break;
       
 13391         default:
       
 13392             break;
       
 13393         }
       
 13394         }
       
 13395     }
       
 13396 void CAknFepManager::UpdateHindiIndicator( TAknEditingState& aNewState )
       
 13397     {
       
 13398     if ( IsPredictive() )
       
 13399         {
       
 13400         if( iIsAutoCompleteOn )
       
 13401             aNewState = EAutoCompleteHindi; 
       
 13402         else
       
 13403             aNewState = EIndicatorStatePredictiveHindi;
       
 13404         }
       
 13405     else
       
 13406         {
       
 13407         aNewState = EIndicatorStateMultitapHindi;
       
 13408         }
       
 13409     }
       
 13410 
       
 13411 TInt CAknFepManager::CurrentInputLangCode()
       
 13412 	{
       
 13413 	ASSERT(iPtiEngine);
       
 13414 	
       
 13415 	MPtiLanguage* lang = iPtiEngine->CurrentLanguage();
       
 13416 	ASSERT(lang);
       
 13417 	
       
 13418 	return lang->LanguageCode();
       
 13419 	}
       
 13420 
       
 13421 TBool CAknFepManager::GetIndicatorImgID(TInt& aIndicatorImgID, TInt& aIndicatorTextID)
       
 13422     {
       
 13423     if (iPreviousEditingState == EStateNone)
       
 13424         {
       
 13425         UpdateIndicators();
       
 13426         if (iPreviousEditingState == EStateNone)
       
 13427             {
       
 13428             return EFalse;    
       
 13429             }
       
 13430         }
       
 13431  
       
 13432 	TBool predictiveMode = QueryPredictiveState(iPreviousEditingState);
       
 13433 	TBool predictiveAutoCompleteMode = EFalse;
       
 13434 	if(!predictiveMode)
       
 13435 		{
       
 13436 		predictiveAutoCompleteMode = QueryPredictiveAutoCompleteState(iPreviousEditingState);		
       
 13437 		}
       
 13438     
       
 13439     if (predictiveMode)
       
 13440         {
       
 13441         aIndicatorImgID = EAknNaviPaneEditorIndicatorT9;
       
 13442         }
       
 13443     else if (predictiveAutoCompleteMode)
       
 13444         {
       
 13445         aIndicatorImgID = EAknNaviPaneEditorIndicatorAutoComplete;   
       
 13446         }
       
 13447     else 
       
 13448         {
       
 13449         aIndicatorImgID = EAknNaviPaneEditorIndicatorQuery;
       
 13450         }
       
 13451    
       
 13452     aIndicatorTextID = EvaluateState(iPreviousEditingState);
       
 13453     
       
 13454     return ETrue;
       
 13455     }
       
 13456     
       
 13457 TInt CAknFepManager::EvaluateState(const TAknEditingState aState)
       
 13458 {
       
 13459 	TInt result = 0;
       
 13460 	switch(aState)
       
 13461 	{
       
 13462 		case EArabicIndicNumeric:
       
 13463   			 result = EAknNaviPaneEditorIndicatorArabicIndicNumberCase;
       
 13464   			 break;
       
 13465   			 
       
 13466 		case ET9Thai:
       
 13467 		case EMultitapThai:
       
 13468 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13469 		case EAutoCompleteThai:
       
 13470 #endif
       
 13471 			result = EAknNaviPaneEditorIndicatorThai;
       
 13472 			break;				
       
 13473 			
       
 13474 		case EIndicatorStatePredictiveHindi:
       
 13475 		case EIndicatorStateMultitapHindi:
       
 13476 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13477 		case EAutoCompleteHindi:
       
 13478 #endif
       
 13479 #ifdef RD_MARATHI
       
 13480 		case EIndicatorStateMultitapMarathi:
       
 13481 		case EIndicatorStatePredictiveMarathi:
       
 13482 #endif // RD_MARATHI
       
 13483 			result = EAknNaviPaneEditorIndicatorDevanagariCase;
       
 13484 			break;	
       
 13485 			
       
 13486 		case ET9Arabic:
       
 13487 		case EMultitapArabic:
       
 13488 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13489 		case EAutoCompleteArabic:
       
 13490 #endif
       
 13491 			result = EAknNaviPaneEditorIndicatorArabicCase;
       
 13492 			break;	
       
 13493 
       
 13494 		case ET9Hebrew:
       
 13495 		case EMultitapHebrew:
       
 13496 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13497 		case EAutoCompleteHebrew:
       
 13498 #endif
       
 13499 			result = EAknNaviPaneEditorIndicatorHebrewCase;
       
 13500 			break;	
       
 13501 			
       
 13502 		case ET9FarsiAndUrdu:
       
 13503 		case EMultitapFarsiAndUrdu:
       
 13504 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13505 		case EAutoCompleteFarsiAndUrdu:
       
 13506 #endif
       
 13507 			result = EAknNaviPaneEditorIndicatorFarsiAndUrduCase;
       
 13508 			break;					
       
 13509 
       
 13510 
       
 13511 		case ET9Upper:
       
 13512 		case EMultitapUpper:
       
 13513 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13514 		case EAutoCompleteUpper:
       
 13515 #endif
       
 13516 			result = EAknNaviPaneEditorIndicatorUpperCase;	
       
 13517 			break;
       
 13518 
       
 13519 		case ET9Lower:
       
 13520 		case EMultitapLower:
       
 13521 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13522 		case EAutoCompleteLower:
       
 13523 #endif
       
 13524 			result = EAknNaviPaneEditorIndicatorLowerCase;	
       
 13525 			break;
       
 13526 
       
 13527 		case ET9Shifted:
       
 13528 		case EMultitapShifted:
       
 13529 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13530 		case EAutoCompleteShifted:
       
 13531 #endif
       
 13532 			result = EAknNaviPaneEditorIndicatorTextCase;	
       
 13533 			break;
       
 13534 			
       
 13535 		case ENumeric:
       
 13536 			result = EAknNaviPaneEditorIndicatorNumberCase;	
       
 13537 			break;		
       
 13538   			 
       
 13539   			 	
       
 13540 		case EIndicatorStatePinyin:
       
 13541 			result = EAknNaviPaneEditorIndicatorPinyin;
       
 13542 			break;
       
 13543 		case EIndicatorStatePinyinPhrase:
       
 13544 			result = EAknNaviPaneEditorIndicatorPinyinPhrase;
       
 13545 			break;
       
 13546 			
       
 13547 		case EIndicatorStateZhuyin:
       
 13548 			 result = EAknNaviPaneEditorIndicatorZhuyin;
       
 13549 			break;
       
 13550 		case EIndicatorStateZhuyinPhrase:
       
 13551 			 result = EAknNaviPaneEditorIndicatorZhuyinPhrase;
       
 13552 			break;
       
 13553 
       
 13554 		case EIndicatorStateZhuyinFind:
       
 13555 			result = EAknNaviPaneEditorIndicatorZhuyinFind;
       
 13556 			break;
       
 13557 
       
 13558 		case EDevanagariIndicNumeric :
       
 13559 			result = EAknNaviPaneEditorIndicatorDevanagariIndicNumberCase;
       
 13560 			break;
       
 13561 		
       
 13562 		case EIndicatorStateHiraganaKanji:
       
 13563 		case EIndicatorStateJapanesePredictive:
       
 13564 			result = EAknNaviPaneEditorIndicatorJapaneseHiraganaKanji;
       
 13565 			break;
       
 13566 
       
 13567 		case EIndicatorStateFullKatakana:
       
 13568 			result = EAknNaviPaneEditorIndicatorJapaneseFullKatakana;
       
 13569 			break;
       
 13570 
       
 13571 		case EIndicatorStateHalfKatakana:
       
 13572 			result = EAknNaviPaneEditorIndicatorJapaneseHalfKatakana;
       
 13573 			break;
       
 13574 
       
 13575 		case EIndicatorStateFullLatinText:
       
 13576 			result = EAknNaviPaneEditorIndicatorJapaneseFullTextAlphabet;
       
 13577 			break;
       
 13578 
       
 13579 		case EIndicatorStateFullLatinUpper:
       
 13580 			result = EAknNaviPaneEditorIndicatorJapaneseFullUpperAlphabet;
       
 13581 			break; 
       
 13582 
       
 13583 		case EIndicatorStateFullLatinLower:
       
 13584 			result = EAknNaviPaneEditorIndicatorJapaneseFullLowerAlphabet;
       
 13585 			break;
       
 13586 
       
 13587 		case EIndicatorStateFullNumeric:
       
 13588 			result = EAknNaviPaneEditorIndicatorJapaneseFullNumeric;
       
 13589 			break;
       
 13590 
       
 13591 		case EIndicatorStateHiragana:
       
 13592 			result = EAknNaviPaneEditorIndicatorJapaneseHiragana;
       
 13593 			break;
       
 13594 
       
 13595 		case EIndicatorStateStroke:
       
 13596 			result = EAknNaviPaneEditorIndicatorStroke;
       
 13597 			break;
       
 13598 		case EIndicatorStateStrokePhrase:
       
 13599 			result = EAknNaviPaneEditorIndicatorStrokePhrase;
       
 13600 			break;
       
 13601 
       
 13602 		case EIndicatorStateStrokeTrad:
       
 13603 			result = EAknNaviPaneEditorIndicatorStrokeTrad;
       
 13604 			break;
       
 13605 		case EIndicatorStateStrokeTradPhrase:
       
 13606 			result = EAknNaviPaneEditorIndicatorStrokeTradPhrase;
       
 13607 			break;
       
 13608 
       
 13609 		case EQwertyShift:
       
 13610 			result = EAknNaviPaneEditorIndicatorQwertyShift;
       
 13611 			break;
       
 13612 
       
 13613 		case EIndicatorStateStrokeFind:
       
 13614 			result = EAknNaviPaneEditorIndicatorStrokeFind;
       
 13615 			break;
       
 13616 
       
 13617 		case EIndicatorStateCangJie:
       
 13618 			result = EAknNaviPaneEditorIndicatorCangJie;
       
 13619 			break;
       
 13620 		
       
 13621 		case ET9UpperVietnamese:
       
 13622 		case EMultitapUpperVietnamese:
       
 13623 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13624 		case EAutoCompleteUpperVietnamese:
       
 13625 #endif
       
 13626 			result = EAknNaviPaneEditorIndicatorVietnameseUpperCase;
       
 13627 			break;			
       
 13628 			
       
 13629 		case ET9LowerVietnamese:
       
 13630 		case EMultitapLowerVietnamese:
       
 13631 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13632 		case EAutoCompleteLowerVietnamese:
       
 13633 #endif
       
 13634 			result = EAknNaviPaneEditorIndicatorVietnameseLowerCase;
       
 13635 			break;	
       
 13636 			
       
 13637 		case ET9ShiftedVietnamese:
       
 13638 		case EMultitapShiftedVietnamese:
       
 13639 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 13640 		case EAutoCompleteShiftedVietnamese:
       
 13641 #endif
       
 13642 			result = EAknNaviPaneEditorIndicatorVietnameseTextCase;
       
 13643 			break;
       
 13644 #ifdef RD_HINDI_PHONETIC_INPUT	
       
 13645 		case EIndicatorStateHindiPhoneticUpper:
       
 13646 			result = EAknNaviPaneEditorIndicatorDevanagariPhoneticUpperCase;
       
 13647 			break;
       
 13648 		case EIndicatorStateHindiPhoneticLower:
       
 13649 			result = EAknNaviPaneEditorIndicatorDevanagariPhoneticLowerCase;
       
 13650 			break;
       
 13651 #endif
       
 13652         case ET9UpperGreek:
       
 13653         case EMultitapUpperGreek:
       
 13654             result = EAknNaviPaneEditorIndicatorGreekUpperCase;
       
 13655             break;
       
 13656             
       
 13657         case ET9LowerGreek:
       
 13658         case EMultitapLowerGreek:
       
 13659             result = EAknNaviPaneEditorIndicatorGreekLowerCase;
       
 13660             break;
       
 13661         
       
 13662         case ET9ShiftedGreek:
       
 13663         case EMultitapShiftedGreek:
       
 13664             result = EAknNaviPaneEditorIndicatorGreekTextCase;
       
 13665             break;
       
 13666             
       
 13667         case ET9UpperCyrillic:
       
 13668         case EMultitapUpperCyrillic:
       
 13669             result = EAknNaviPaneEditorIndicatorCyrillicUpperCase;
       
 13670             break;
       
 13671             
       
 13672         case ET9LowerCyrillic:
       
 13673         case EMultitapLowerCyrillic:
       
 13674             result = EAknNaviPaneEditorIndicatorCyrillicLowerCase;
       
 13675             break;
       
 13676         
       
 13677         case ET9ShiftedCyrillic:
       
 13678         case EMultitapShiftedCyrillic:
       
 13679             result = EAknNaviPaneEditorIndicatorCyrillicTextCase;
       
 13680             break;
       
 13681             
       
 13682         case EHybridModeLatin:
       
 13683             result = EAknNaviPaneEditorIndicatorHybridLatin;
       
 13684             break;
       
 13685         case EIndicatorStateHangul:
       
 13686             result = EAknNaviPaneEditorIndicatorKoreanHangul;
       
 13687             break;
       
 13688         
       
 13689 	}
       
 13690 	return result;
       
 13691 
       
 13692 }    
       
 13693 
       
 13694 TBool CAknFepManager::IsAbleToLaunchSCT() const
       
 13695     {
       
 13696     TBool ableToLaunchSCT = ETrue;
       
 13697 
       
 13698     if (ExtendedInputCapabilities() & CAknExtendedInputCapabilities::EDisableSCT && 
       
 13699         PluginInputMode() == EPluginInputModeNone )
       
 13700         {
       
 13701         // The editor doesn't allow SCT.
       
 13702         return EFalse;
       
 13703         }
       
 13704     
       
 13705     if (iMode == ENumber || iMode == ENativeNumber)
       
 13706         {
       
 13707         if (iPermittedInputModes == EAknEditorNumericInputMode || !NumericModeSCTResourceId()) 
       
 13708             {
       
 13709             // SCT is not launched if the number mode is the only input mode or
       
 13710             // if there is not keymap resource for the current numeric keymap mode.
       
 13711             ableToLaunchSCT = EFalse;
       
 13712             }
       
 13713         if (iAknEditorFlags & EAknEditorFlagUseSCTNumericCharmap ||
       
 13714             ( (iAknEditorNumericKeymap == EAknEditorAlphanumericNumberModeKeymap) &&
       
 13715               (iPermittedInputModes != EAknEditorNumericInputMode) ))
       
 13716             {
       
 13717             // SCT is launched in the number mode if requested by editor flag
       
 13718             // EAknEditorFlagUseSCTNumericCharmap or if also text input modes are
       
 13719             // allowed and the keymap is EAknEditorAlphanumericNumberModeKeymap.
       
 13720             ableToLaunchSCT = ETrue;
       
 13721             }      
       
 13722         }
       
 13723     if (!(EditorHasFreeSpace() && EditorState() 
       
 13724         && EditorState()->SpecialCharacterTableResourceId()))
       
 13725         {
       
 13726         ableToLaunchSCT = EFalse;
       
 13727         }
       
 13728     
       
 13729     return ableToLaunchSCT;
       
 13730     }
       
 13731 
       
 13732 TBool CAknFepManager::QueryPredictiveState(const TAknEditingState aState)
       
 13733  { 
       
 13734     return  (( aState == EIndicatorStatePinyin) ||
       
 13735              ( aState == EIndicatorStatePinyinPhrase) ||
       
 13736              ( aState == EIndicatorStateZhuyin) ||
       
 13737              ( aState == EIndicatorStateZhuyinPhrase) ||
       
 13738              ( aState == EIndicatorStateZhuyinFind) ||
       
 13739              ( aState == EIndicatorStateStrokeFind) ||
       
 13740              ( aState == EIndicatorStateStroke) || 
       
 13741              ( aState == EIndicatorStateStrokePhrase) ||
       
 13742 			 ( aState == EIndicatorStateCangJie) ||
       
 13743              ( aState == EIndicatorStateStrokeTrad) || 
       
 13744              ( aState == EIndicatorStateStrokeTradPhrase) ||
       
 13745              ( aState == ET9Upper) ||
       
 13746              ( aState == ET9Shifted) ||
       
 13747              ( aState == ET9Lower) ||
       
 13748              ( aState == ET9Arabic) ||
       
 13749              ( aState == ET9Hebrew) ||
       
 13750              ( aState == ET9FarsiAndUrdu) ||
       
 13751              ( aState == ET9Thai) ||
       
 13752              ( aState == EIndicatorStatePredictiveHindi) ||
       
 13753 #ifdef RD_MARATHI
       
 13754              ( aState == EIndicatorStatePredictiveMarathi) ||
       
 13755 #endif // RD_MARATHI
       
 13756              ( aState == EIndicatorStateJapanesePredictive) ||
       
 13757              ( aState == ET9UpperVietnamese) ||
       
 13758              ( aState == ET9LowerVietnamese) ||
       
 13759              ( aState == ET9ShiftedVietnamese) ||
       
 13760              ( aState == ET9UpperGreek) ||
       
 13761              ( aState == ET9LowerGreek) ||
       
 13762              ( aState == ET9ShiftedGreek) ||
       
 13763              ( aState == ET9UpperCyrillic) ||
       
 13764              ( aState == ET9LowerCyrillic) ||
       
 13765              ( aState == ET9ShiftedCyrillic) );  
       
 13766  }
       
 13767 
       
 13768  TBool CAknFepManager::QueryPredictiveAutoCompleteState(TAknEditingState aState)
       
 13769  {
       
 13770  	 	        
       
 13771     return (( aState == EAutoCompleteUpper ) ||  
       
 13772      		( aState == EAutoCompleteShifted )  ||
       
 13773      		( aState == EAutoCompleteLower ) || 
       
 13774      		( aState == EAutoCompleteHindi ) ||
       
 13775      		( aState == EAutoCompleteArabic ) ||
       
 13776      		( aState == EAutoCompleteHebrew ) ||
       
 13777      		( aState == EAutoCompleteFarsiAndUrdu ) ||
       
 13778      		( aState == EAutoCompleteThai ) ||
       
 13779      		( aState == EAutoCompleteUpperVietnamese ) ||
       
 13780      		( aState == EAutoCompleteLowerVietnamese ) ||
       
 13781      		( aState == EAutoCompleteShiftedVietnamese ));
       
 13782  }
       
 13783 
       
 13784 void CAknFepManager::LaunchSpecialCharacterTableL(TInt aResourceId, TBool aLaunchedByTouchWin, TBool aSmileyFirst)
       
 13785     {
       
 13786 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
 13787     // Set the iSupressCursorMoveToEndChrKeyPressed when cursor is in 
       
 13788 	// between two words and SCT is launched
       
 13789     iSupressCursorMoveToEndChrKeyPressed = ETrue;
       
 13790 #endif //RD_INTELLIGENT_TEXT_INPUT    
       
 13791 #ifdef RD_SCALABLE_UI_V2
       
 13792     if ( iStarKeyPressed && iFepPluginManager && 
       
 13793          iFepPluginManager->PluginInputMode() == EPluginInputModeItut )
       
 13794             {
       
 13795             aLaunchedByTouchWin = ETrue;
       
 13796             }
       
 13797     iCancelPopupInQwerty = aLaunchedByTouchWin;
       
 13798 #endif //RD_SCALABLE_UI_V2
       
 13799     DoLaunchSctAndPctL(aResourceId, aSmileyFirst ? EShowSmileyFirst : EShowSctFirst );
       
 13800 #ifdef RD_SCALABLE_UI_V2
       
 13801     iCancelPopupInQwerty = EFalse;
       
 13802 #endif //RD_SCALABLE_UI_V2    
       
 13803 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
 13804     iSupressCursorMoveToEndChrKeyPressed = ETrue;  
       
 13805 #endif //RD_INTELLIGENT_TEXT_INPUT     
       
 13806     }
       
 13807 
       
 13808 TBool CAknFepManager::IsAbleToLaunchPCT() const
       
 13809     {
       
 13810     TBool isAbleToLaunch = EFalse;
       
 13811     if (FeatureManager::FeatureSupported(KFeatureIdJapanesePicto)
       
 13812      && (iAknEditorFlags & EAknEditorFlagEnablePictographInput))
       
 13813         {
       
 13814         isAbleToLaunch = ETrue;
       
 13815         }
       
 13816     return isAbleToLaunch;
       
 13817     }
       
 13818 
       
 13819 TBool CAknFepManager::IsAbleToLaunchSmiley() const
       
 13820     {
       
 13821 	if(iLanguageCapabilities.iRightToLeftLanguage)
       
 13822 		{
       
 13823 	       return EFalse;
       
 13824 		}
       
 13825 	
       
 13826     TBool ableToLaunchSmiley(EFalse);
       
 13827     
       
 13828     CAknEdwinState* edwinState = EditorState();
       
 13829     if ( edwinState && EditorHasFreeSpace() )
       
 13830         {
       
 13831         CAknEdwinFormAccessor* formAccessor = edwinState->FormAccessor();
       
 13832         if(formAccessor)
       
 13833             {
       
 13834             CEikEdwin *edwin = static_cast<CEikEdwin*>(formAccessor->FormClientControl());
       
 13835             if(edwin)
       
 13836                 {
       
 13837                 ableToLaunchSmiley = ((edwin->UserFlags()&CEikEdwin::EAvkonEnableSmileySupport) != 0);
       
 13838                 }
       
 13839             }
       
 13840         }
       
 13841 
       
 13842     return ableToLaunchSmiley;
       
 13843     }
       
 13844 
       
 13845 TInt CAknFepManager::GetCurrentEditorSCTResId() const
       
 13846     {
       
 13847     if(!EditorState())
       
 13848         {
       
 13849     	return NumericModeSCTResourceId();    	
       
 13850         }
       
 13851     TInt currentEditorSCTResId = EditorState()->SpecialCharacterTableResourceId();
       
 13852     if ( FeatureManager::FeatureSupported(KFeatureIdChinese) )
       
 13853         {        
       
 13854         if (currentEditorSCTResId == R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG)
       
 13855             {
       
 13856             if (iMode == EZhuyin)
       
 13857             	{
       
 13858             	currentEditorSCTResId = 
       
 13859                                   R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_FOR_ZHUYIN_SYMBOL_INPUT;
       
 13860         	    }
       
 13861             else
       
 13862             	{
       
 13863             	currentEditorSCTResId = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_CHINESE;
       
 13864         	    }        
       
 13865             }
       
 13866         }
       
 13867 
       
 13868     if ( FeatureManager::FeatureSupported(KFeatureIdKorean) )
       
 13869         {
       
 13870         // Use the special sct resource file for Korean variant.
       
 13871         if (currentEditorSCTResId == R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG)
       
 13872             {
       
 13873             currentEditorSCTResId = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_KOREAN;
       
 13874             }
       
 13875         }
       
 13876     
       
 13877     if (currentEditorSCTResId == EDefaultSCTResourceId) // -1 forces the default in SCT resource definition
       
 13878         {
       
 13879         if (iAknEditorFlags & EAknEditorFlagLatinInputModesOnly)
       
 13880             {
       
 13881             currentEditorSCTResId = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_LATIN_ONLY;
       
 13882             }        
       
 13883         else	
       
 13884             {        		        	
       
 13885             // only ITU-T and when Bopomofo symbol input mode is supported, we use new sct table
       
 13886             TInt supportSCTToneMarks = EFalse;
       
 13887             MPtiCoreInfo* ptiCoreInfo = iPtiEngine->CoreInfo(EPtiEngineZhuyin);
       
 13888             
       
 13889             if(ptiCoreInfo)
       
 13890                 {
       
 13891                 supportSCTToneMarks = ptiCoreInfo->CapsBits() & ESupportSCTToneMarks;
       
 13892                 }
       
 13893             
       
 13894             ptiCoreInfo = iPtiEngine->CoreInfo(EPtiEngineZhuyinByPhrase);
       
 13895             if(ptiCoreInfo)    
       
 13896                 {
       
 13897                 supportSCTToneMarks = supportSCTToneMarks || 
       
 13898                                       (ptiCoreInfo->CapsBits() & ESupportSCTToneMarks);
       
 13899                 }
       
 13900             
       
 13901             if(!iQwertyInputMode && (iMode == EZhuyin) && supportSCTToneMarks)
       
 13902                 {
       
 13903                 currentEditorSCTResId = 
       
 13904                                   R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_FOR_ZHUYIN_SYMBOL_INPUT;
       
 13905                 }
       
 13906             else
       
 13907                 {
       
 13908                 if ( FeatureManager::FeatureSupported(KFeatureIdChinese) )
       
 13909                     {    
       
 13910                     currentEditorSCTResId = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_CHINESE;
       
 13911                     }                
       
 13912                 else if( FeatureManager::FeatureSupported(KFeatureIdKorean) )
       
 13913                     {    
       
 13914                     // Use the special sct resource file for Korean variant.
       
 13915                     currentEditorSCTResId = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_KOREAN;
       
 13916                     }               
       
 13917                 else
       
 13918                     {                    
       
 13919                     currentEditorSCTResId = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG;
       
 13920                     }
       
 13921                 }
       
 13922             }
       
 13923         }  
       
 13924     return currentEditorSCTResId;         
       
 13925     }
       
 13926 
       
 13927 void CAknFepManager::LaunchPictographCharacterTableL()
       
 13928     {
       
 13929     DoLaunchSctAndPctL(NULL, EShowPctFirst);
       
 13930     }
       
 13931 
       
 13932 
       
 13933 void CAknFepManager::UpdateInlineEditL(const TDesC& aNewInlineText, 
       
 13934                                        TInt aPositionOfInsertionPointInInlineText)
       
 13935     {
       
 13936     if ( ! IsFlagSet ( EFlagInsideInlineEditingTransaction ) )
       
 13937         {
       
 13938         return;
       
 13939         }
       
 13940     // Japanese implementation needs to be merged with functionality of other languages. Now they are separate.
       
 13941     if (iLanguageCapabilities.iInputLanguageCode == ELangJapanese)
       
 13942         {
       
 13943         iUncommittedText.iCursorPos = iUncommittedText.iAnchorPos + 
       
 13944                                       aPositionOfInsertionPointInInlineText;
       
 13945 
       
 13946         if (aNewInlineText.Length() == 1)
       
 13947             {
       
 13948             if (aNewInlineText[0] == KAknFEPLineFeedSymbol ||
       
 13949                 aNewInlineText[0] == KAknFEPMirroredLineFeedSymbol)
       
 13950                 {
       
 13951                 SetFlag(EFlagLineFeedCharacter);
       
 13952                 ClearFlag(EFlagSpaceCharacter | EFlagFullWidthSpaceCharacter);
       
 13953                 }
       
 13954             else if (aNewInlineText[0] == iSpaceCharacterCode)
       
 13955                 {
       
 13956                 SetFlag(EFlagSpaceCharacter);
       
 13957                 ClearFlag(EFlagLineFeedCharacter | EFlagFullWidthSpaceCharacter);
       
 13958                 }
       
 13959             else if (aNewInlineText[0] == iFullWidthSpaceCharacterCode)
       
 13960                 {
       
 13961                 SetFlag(EFlagFullWidthSpaceCharacter);
       
 13962                 ClearFlag(EFlagLineFeedCharacter | EFlagSpaceCharacter);
       
 13963                 }
       
 13964             else
       
 13965                 {
       
 13966                 ClearFlag(EFlagLineFeedCharacter 
       
 13967                           | EFlagSpaceCharacter 
       
 13968                           | EFlagFullWidthSpaceCharacter);
       
 13969                 }
       
 13970             if (iInputCapabilities.SupportsSecretText())
       
 13971                 {
       
 13972                 TBuf<1> buf;
       
 13973                 buf.Append(aNewInlineText[0]);
       
 13974                 NewCharacterL(buf);
       
 13975                 }
       
 13976             else
       
 13977                 {
       
 13978                 SetFlag(EFlagInsideMultitapInlineEditingTransaction);
       
 13979                 iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(aNewInlineText, 
       
 13980                                                   aPositionOfInsertionPointInInlineText);
       
 13981                 }
       
 13982             }
       
 13983         else
       
 13984             {
       
 13985             ClearFlag(EFlagLineFeedCharacter | EFlagSpaceCharacter | EFlagFullWidthSpaceCharacter);
       
 13986             iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(aNewInlineText, 
       
 13987                                                    aPositionOfInsertionPointInInlineText);
       
 13988             }
       
 13989 #ifdef _DEBUG
       
 13990         RDebug::Print(_L("UpdateInlineEditL text=[%S] len=[%d] CurPos=[%d] AncPos=[%d] change=[%d]"),
       
 13991             &aNewInlineText, iUncommittedText.Length(),
       
 13992             iUncommittedText.iCursorPos, iUncommittedText.iAnchorPos,
       
 13993             aPositionOfInsertionPointInInlineText);
       
 13994 #endif
       
 13995         }
       
 13996     else
       
 13997         {
       
 13998         	TInt curPos = iUncommittedText.iAnchorPos + aNewInlineText.Length();
       
 13999         	
       
 14000         	TInt deltaCur = curPos - iUncommittedText.iCursorPos;
       
 14001         	
       
 14002         	TInt maxEdSize = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
 14003         	
       
 14004         	TInt docLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 14005         	
       
 14006         	HBufC* newInlineText=NULL;
       
 14007 	        	
       
 14008         	TBool syncLater = ETrue;
       
 14009 			// we have to restrict to a length that is permissible in the editor
       
 14010         	// this situation comes when we select the max length condition is reached 
       
 14011         	// in the editor and we navigate to one of the words in the middle 
       
 14012         	// and select a longer word from the candidate list        	
       
 14013         	
       
 14014 
       
 14015         	if( (maxEdSize > 0) && ( deltaCur > 0 ) 
       
 14016         							&& (( docLength + deltaCur) > maxEdSize ) )
       
 14017         	{
       
 14018         		newInlineText= aNewInlineText.Left( aNewInlineText.Length() - (docLength + deltaCur - maxEdSize )).AllocLC();
       
 14019         		aPositionOfInsertionPointInInlineText=newInlineText->Length();
       
 14020         	}
       
 14021         	else if((maxEdSize > 0) && (curPos > maxEdSize))
       
 14022         	{
       
 14023         		newInlineText= aNewInlineText.Left(maxEdSize - iUncommittedText.iAnchorPos).AllocLC();
       
 14024         		aPositionOfInsertionPointInInlineText=newInlineText->Length();
       
 14025         	}        	
       
 14026         	else
       
 14027         	{
       
 14028         		newInlineText=aNewInlineText.AllocLC();
       
 14029         		syncLater = EFalse;        	
       
 14030         	} 
       
 14031 	// The Below code changes are made to sync iTextBuffer and the last word in the editor.When the 
       
 14032 	// cursor position reaches more than the max length of editor, tail length is modified according 
       
 14033 	// to truncated last word and Autocompletion bit length (Element count) value to display last 
       
 14034 	// word in the editor properly. 			       	        	        	
       
 14035     #ifdef RD_INTELLIGENT_TEXT_INPUT        	 	
       
 14036 			if(syncLater)
       
 14037         	    {       	    
       
 14038     	        TBuf<CAknFepManager::EMaximumFepWordLength> currentText = iPtiEngine->CurrentWord();
       
 14039     	        currentText.SetLength(newInlineText->Length());        	        
       
 14040     	        iPtiEngine->HandleCommandL( EPtiCommandSetCursorCrossedMaxLength );
       
 14041     	        iPtiEngine->SetCurrentWord(currentText); 
       
 14042     	        TransferFepStateToEditorL();
       
 14043     	        iPtiEngine->HandleCommandL( EPtiCommandResetCursorCrossedMaxLength );
       
 14044         	    }
       
 14045 	#endif 	
       
 14046         	// CleanupStack::PushL(TCleanupItem(ClearFepStateOnLeave,this));
       
 14047         	iUncommittedText.iCursorPos = iUncommittedText.iAnchorPos + aPositionOfInsertionPointInInlineText;
       
 14048 
       
 14049 		HBufC* decoratedInlineEdit = HBufC::NewLC(aNewInlineText.Length()*3);
       
 14050 		TPtr bufferPtr(decoratedInlineEdit->Des());
       
 14051 
       
 14052         if ( EditorSupportsNeutralProtection() )
       
 14053             {
       
 14054         		if ( newInlineText->Length() > 0 )
       
 14055                 {
       
 14056                 iInlineTextDecorator->DecorateInlineText(
       
 14057         			newInlineText->Des(),
       
 14058                     bufferPtr,
       
 14059                     aPositionOfInsertionPointInInlineText,
       
 14060                     static_cast<TChar>(PreviousChar()),
       
 14061                     IsRightToLeftParagraph(DocPos() ),
       
 14062                     ( CurrentInputDirectionality() == TBidiText::ERightToLeft ) );
       
 14063                 }
       
 14064 
       
 14065             // Because the length of the new inline edit may bear no relation to the old inline edit,
       
 14066             // the passed desired position of the cursor (which is hidden in S60 anyway) in the new
       
 14067             // inline edit is restricted to its Length(). The input value of parameter
       
 14068             // aPositionOfInsertionPointInInlineText is ignored, and its modified value
       
 14069             // from the DecorateInlineText routine is also ignored.
       
 14070             
       
 14071 			aPositionOfInsertionPointInInlineText = decoratedInlineEdit->Length();
       
 14072 
       
 14073 			iUncommittedText.iCursorPos = iUncommittedText.iAnchorPos + aPositionOfInsertionPointInInlineText;
       
 14074 			
       
 14075             iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(
       
 14076                 bufferPtr, aPositionOfInsertionPointInInlineText);
       
 14077             	
       
 14078             iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 14079             iUncommittedText.iAnchorPos-=decoratedInlineEdit->Length();
       
 14080         	}
       
 14081 
       
 14082         	else
       
 14083         	{
       
 14084         		// Even without the issue of decoration, the length of the new inline edit may bear no
       
 14085         		// relation to the old inline edit. It is always set to length (the end) of the new inline edit
       
 14086         		aPositionOfInsertionPointInInlineText = newInlineText->Length();
       
 14087 
       
 14088         		iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(
       
 14089         			newInlineText->Des(), aPositionOfInsertionPointInInlineText);
       
 14090 
       
 14091         		// This is needed here too because we should not insist that the new text is the same length
       
 14092         		// as the old, and so the iUncommitted text should be reset.
       
 14093         		iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 14094         		iUncommittedText.iAnchorPos-=newInlineText->Length();
       
 14095         	}       
       
 14096 
       
 14097         	
       
 14098         CleanupStack::PopAndDestroy(decoratedInlineEdit);  
       
 14099         SendEventsToPluginManL( EPluginSyncFepAwareText, EPluginSyncUpdatedText );
       
 14100         CleanupStack::PopAndDestroy(newInlineText);
       
 14101         //Send info to engine to set EPtiXt9FlagAutoCompletionSetOnToOff flag as false 
       
 14102         TInt value = 0;
       
 14103         TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandAutoCompletionOnToOff,&value));			
       
 14104         }  
       
 14105     }
       
 14106 
       
 14107 void CAknFepManager::StartInlineEditL()
       
 14108     {
       
 14109     if(iConcatenationTimer->IsActive())
       
 14110     	iConcatenationTimer->Cancel();
       
 14111 	
       
 14112     //currently western only, would need to sort out flags if this were to be used
       
 14113     //in multitap modes
       
 14114     switch (iMode)
       
 14115         {
       
 14116         case ELatin:
       
 14117         case EKatakana:
       
 14118         case EHiragana:
       
 14119             iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(KNullDesC, 0, EFalse, 
       
 14120                                                                          NULL, *this, *this);
       
 14121             iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 14122             break;
       
 14123         default:
       
 14124             iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(KNullDesC, 0, EFalse, 
       
 14125                                                                          NULL, *this, *this);
       
 14126             break;
       
 14127         }
       
 14128 #ifdef _DEBUG
       
 14129     RDebug::Print(_L("StartInlineEditL len=[%d] CurPos=[%d] AncPos=[%d]"),
       
 14130         iUncommittedText.Length(),
       
 14131         iUncommittedText.iCursorPos, iUncommittedText.iAnchorPos );
       
 14132 #endif
       
 14133 
       
 14134     // have to calculate the number of free space on current EDITOR after StartFepInlineEditL().
       
 14135     TInt maxEdSize = iInputCapabilities.FepAwareTextEditor()->DocumentMaximumLengthForFep();
       
 14136     TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 14137     iFreeSpaceOfEditor = maxEdSize - edSize;
       
 14138 
       
 14139     SetFlag(EFlagInsideInlineEditingTransaction);
       
 14140     }
       
 14141 
       
 14142 void CAknFepManager::StartInlineEditL(const TDesC& aText)
       
 14143     {
       
 14144     if(iConcatenationTimer->IsActive())
       
 14145     	iConcatenationTimer->Cancel();
       
 14146 	
       
 14147     TInt textLength = aText.Length();
       
 14148 
       
 14149     // CleanupStack::PushL(TCleanupItem(ClearFepStateOnLeave,this));
       
 14150     
       
 14151 	HBufC* decoratedInlineEdit = HBufC::NewLC(aText.Length()*3);
       
 14152 	TPtr bufferPtr(decoratedInlineEdit->Des());
       
 14153 
       
 14154     // decorate the inline edit
       
 14155     if( aText.Length() > 0 && EditorSupportsNeutralProtection() )
       
 14156         {
       
 14157         iInlineTextDecorator->DecorateInlineText(
       
 14158             aText,
       
 14159             bufferPtr,
       
 14160             textLength, // aPositionOfInsertionPointInInlineText,
       
 14161             static_cast<TChar>(PreviousChar()),
       
 14162             IsRightToLeftParagraph( DocPos() ),
       
 14163             ( CurrentInputDirectionality() == TBidiText::ERightToLeft ) );
       
 14164         }
       
 14165     else
       
 14166         {
       
 14167 
       
 14168         bufferPtr.Copy(aText);
       
 14169         }
       
 14170     
       
 14171     // Before starting editor inline, we cancel editor inline if by any chance editor ends up in inline edit and fep does not
       
 14172         TBool phoneIdle = (EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor); 
       
 14173         
       
 14174         if(phoneIdle)
       
 14175             {
       
 14176             iInputCapabilities.FepAwareTextEditor()->CancelFepInlineEdit();
       
 14177             }
       
 14178     
       
 14179     // operates at the current insertion point or selection
       
 14180     iInputCapabilities.FepAwareTextEditor()->StartFepInlineEditL(
       
 14181 
       
 14182         bufferPtr,
       
 14183         textLength, // aPositionOfInsertionPointInInlineText,
       
 14184         EFalse,  // Cursor visibility
       
 14185         0, // MFormCustomDrawer*
       
 14186         *this,
       
 14187         *this);
       
 14188 
       
 14189     // CleanupStack::Pop(); // cleanupitem for FEP state.
       
 14190 
       
 14191     if (!iInputCapabilities.FepAwareTextEditor())
       
 14192         {
       
 14193         // In case while starting the inline edit, 3rd party app removes the focus out of editor before the transaction
       
 14194         // completes, we return with an error.
       
 14195         User::Leave(KErrCorrupt);
       
 14196         }
       
 14197     // cursor span needs to be updated following potential modification
       
 14198     // of the inline edit content before it was started
       
 14199     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 14200 	iUncommittedText.iAnchorPos-=decoratedInlineEdit->Length();
       
 14201 	CleanupStack::PopAndDestroy(decoratedInlineEdit);
       
 14202 
       
 14203     SetFlag(EFlagInsideInlineEditingTransaction);
       
 14204     }
       
 14205 
       
 14206 void CAknFepManager::StartInlineEditL(TCursorSelection aCursorSelection, 
       
 14207                                       const TDesC& aInitialInlineText, 
       
 14208                                       TInt aPositionOfInsertionPointInInlineText, 
       
 14209                                       TBool aCursorVisibility)
       
 14210     {
       
 14211     	
       
 14212 		if(iConcatenationTimer->IsActive())
       
 14213     	iConcatenationTimer->Cancel();
       
 14214 	
       
 14215     TBool setToTrue=EFalse;
       
 14216 
       
 14217     // setToTrue parameter forces use of selection hiding inline edit editor API -
       
 14218     // this method also sets the cursor selection to the second parameter
       
 14219     // CleanupStack::PushL(TCleanupItem(ClearFepStateOnLeave,this));
       
 14220     iInputCapabilities.FepAwareTextEditor()->Extension1()->StartFepInlineEditL(
       
 14221         setToTrue,
       
 14222         aCursorSelection,
       
 14223         aInitialInlineText,
       
 14224         aPositionOfInsertionPointInInlineText,
       
 14225         aCursorVisibility,
       
 14226         0, // MFormCustomDrawer* ?
       
 14227         *this,
       
 14228         *this);
       
 14229     // CleanupStack::Pop(); // cleanupitem for FEP state.
       
 14230     SetFlag(EFlagInsideInlineEditingTransaction);
       
 14231     //This will suppress Edit submenu from poping up
       
 14232     SetCcpuFlag(ECcpuStateIgnoreStarUp);
       
 14233     }
       
 14234 
       
 14235 TBool CAknFepManager::CloseUiIfWordDeletedL()
       
 14236     {
       
 14237     if (iUncommittedText.Length()==0)
       
 14238         {
       
 14239         // word has been totally deleted
       
 14240         ClearFlag(EFlagCompoundWord);
       
 14241         TryCloseUiL();
       
 14242         return ETrue;
       
 14243         }
       
 14244     return EFalse;
       
 14245     }
       
 14246 
       
 14247 TBool CAknFepManager::TryGetTextToUncommitL(TDes& aText, TInt aCode, TBool& aComsumeKey)
       
 14248     {
       
 14249     TWesternNaviEvent naviEvent = ENullNaviEvent;
       
 14250     if (aCode == EKeyLeftArrow)
       
 14251         {
       
 14252         naviEvent = ELeftNaviEvent;
       
 14253         }
       
 14254     else if (aCode == EKeyRightArrow)
       
 14255         {
       
 14256         naviEvent = ERightNaviEvent;
       
 14257         }
       
 14258     else if (aCode == EKeyBackspace)
       
 14259         {
       
 14260         naviEvent = EBackspaceEvent;
       
 14261         }
       
 14262 
       
 14263     TInt nextCharPos = 0;  // Character ordinal in logical memory (0 - n-1)
       
 14264     TBool hindibackspace = 0 ;  
       
 14265     TBool nextPositionFound = EFalse;
       
 14266     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 14267     if ( naviEvent == ERightNaviEvent )
       
 14268         {
       
 14269         nextPositionFound = GetNextVisualRightCharacter( nextCharPos );
       
 14270         if( (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) || 
       
 14271                 (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai))
       
 14272             {
       
 14273             FindStartOfWord(nextCharPos);   
       
 14274                         
       
 14275             if(nextCharPos < iUncommittedText.LowerPos())
       
 14276                 {
       
 14277                 nextCharPos = iUncommittedText.LowerPos();
       
 14278                 }
       
 14279             }
       
 14280         }
       
 14281     else if ( naviEvent == ELeftNaviEvent )
       
 14282         {
       
 14283         nextPositionFound = GetNextVisualLeftCharacter( nextCharPos );
       
 14284         if( nextPositionFound && (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) ||
       
 14285                 (nextPositionFound && (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai)))
       
 14286             {
       
 14287             FindEndOfWord(nextCharPos);
       
 14288             if(nextCharPos > iUncommittedText.HigherPos())
       
 14289                 {
       
 14290                 nextCharPos = iUncommittedText.HigherPos();
       
 14291                 }
       
 14292             }
       
 14293             
       
 14294         }
       
 14295     else if ( naviEvent == EBackspaceEvent )
       
 14296         {
       
 14297         if (iLanguageCapabilities.iRightToLeftLanguage)
       
 14298             {
       
 14299             nextPositionFound = GetNextVisualRightCharacter( nextCharPos );
       
 14300             }
       
 14301         else
       
 14302             {
       
 14303             if( (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) ||
       
 14304                     (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai))
       
 14305                 {
       
 14306                 TCursorSelection curSel;
       
 14307                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(curSel);
       
 14308                 nextCharPos = curSel.iCursorPos;        
       
 14309                 hindibackspace = ETrue;
       
 14310                 }
       
 14311             else
       
 14312                 {
       
 14313             nextPositionFound = GetNextVisualLeftCharacter( nextCharPos );
       
 14314                 }   
       
 14315             }
       
 14316         }
       
 14317 
       
 14318     if ( !nextPositionFound && !hindibackspace )
       
 14319         {
       
 14320         aComsumeKey = EFalse;
       
 14321         return EFalse;
       
 14322         }
       
 14323 
       
 14324     TInt anchorPos = 0;
       
 14325     TInt cursorPos = 0;
       
 14326     TTmDocPosSpec pos = DocPos();
       
 14327     CTmTextLayout::TTmChunkDescription leftChunk;
       
 14328     CTmTextLayout::TTmChunkDescription rightChunk;
       
 14329     FindAdjacentChunks(pos, leftChunk, rightChunk);
       
 14330 
       
 14331     if (( naviEvent == ELeftNaviEvent && leftChunk.iRightToLeft ) ||
       
 14332         ( naviEvent == ERightNaviEvent && !rightChunk.iRightToLeft ))
       
 14333         {
       
 14334         anchorPos = nextCharPos;
       
 14335         cursorPos = nextCharPos;
       
 14336         FindEndOfWord(cursorPos);
       
 14337         }
       
 14338     else
       
 14339         {
       
 14340         if( (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) ||
       
 14341                 (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai))
       
 14342             {
       
 14343             cursorPos = nextCharPos;
       
 14344             }
       
 14345         else
       
 14346             {
       
 14347             cursorPos = nextCharPos + 1;    
       
 14348             }
       
 14349         anchorPos = nextCharPos;
       
 14350         FindStartOfWord(anchorPos);
       
 14351         }
       
 14352         
       
 14353 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
 14354 	TCursorSelection curSel;
       
 14355     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(curSel);
       
 14356     // if selection happens dont consume the event pass it to editor
       
 14357     if((naviEvent == EBackspaceEvent)
       
 14358             && (!IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
 14359             && (curSel.iAnchorPos != curSel.iCursorPos))
       
 14360         {
       
 14361         aComsumeKey = EFalse;
       
 14362         return EFalse;
       
 14363         }
       
 14364 #endif
       
 14365 
       
 14366     iUncommittedText.SetSelection(cursorPos, anchorPos);
       
 14367 
       
 14368     if (iUncommittedText.Length() <= EMaximumFepWordLength)
       
 14369         {
       
 14370         iInputCapabilities.FepAwareTextEditor()->
       
 14371             GetEditorContentForFep(aText, iUncommittedText.iAnchorPos, iUncommittedText.Length());
       
 14372         aComsumeKey = ETrue;
       
 14373         return ETrue;
       
 14374         }
       
 14375     else
       
 14376         {
       
 14377         if (naviEvent == EBackspaceEvent)
       
 14378             {
       
 14379             // delete the last character
       
 14380             cursorPos--;
       
 14381             iUncommittedText.SetSelection(cursorPos, cursorPos);
       
 14382             aComsumeKey = EFalse;
       
 14383             }
       
 14384         else
       
 14385             {
       
 14386             TInt newCursorPosition= (pos.iPos == cursorPos) ? anchorPos : cursorPos;
       
 14387             iUncommittedText.SetSelection(newCursorPosition, newCursorPosition);
       
 14388             iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
 14389             aComsumeKey = ETrue;
       
 14390             }
       
 14391         // The word is longer than EMaximumFepWordLength. Ui is deactivated.
       
 14392         TryCloseUiL();
       
 14393         return EFalse;
       
 14394         }
       
 14395     }
       
 14396 
       
 14397 
       
 14398 TBool CAknFepManager::TryGetTextToUncommitL(TDes& aText, TBool& aComsumeKey)
       
 14399     {
       
 14400     TInt nextCharRightPos = 0;  // Character ordinal in logical memory (0 - n-1)
       
 14401     TInt nextCharLeftPos = 0; 
       
 14402     TBool nextRightPosFound = EFalse;
       
 14403     TBool nextLeftPosFound = EFalse;
       
 14404     
       
 14405     nextRightPosFound = GetNextVisualRightCharacter( nextCharRightPos );
       
 14406     if( (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) || 
       
 14407             (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai))
       
 14408         {
       
 14409         FindStartOfWord(nextCharRightPos);   
       
 14410                     
       
 14411         if(nextCharRightPos < iUncommittedText.LowerPos())
       
 14412             {
       
 14413             nextCharRightPos = iUncommittedText.LowerPos();
       
 14414             }
       
 14415         }
       
 14416     
       
 14417     
       
 14418     nextLeftPosFound = GetNextVisualLeftCharacter( nextCharLeftPos );
       
 14419     if( nextLeftPosFound && (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) ||
       
 14420             (nextLeftPosFound && (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai)))
       
 14421         {
       
 14422         FindEndOfWord(nextCharLeftPos);
       
 14423         if(nextCharLeftPos > iUncommittedText.HigherPos())
       
 14424             {
       
 14425             nextCharLeftPos = iUncommittedText.HigherPos();
       
 14426             }
       
 14427         }
       
 14428             
       
 14429 
       
 14430 
       
 14431 
       
 14432     if ( !nextRightPosFound && !nextLeftPosFound )
       
 14433         {
       
 14434         aComsumeKey = EFalse;
       
 14435         return EFalse;
       
 14436         }
       
 14437 
       
 14438     TInt anchorPos = 0;
       
 14439     TInt cursorPos = 0;
       
 14440 
       
 14441     
       
 14442     
       
 14443     TTmDocPosSpec pos = DocPos();
       
 14444     CTmTextLayout::TTmChunkDescription leftChunk;
       
 14445     CTmTextLayout::TTmChunkDescription rightChunk;
       
 14446     FindAdjacentChunks(pos, leftChunk, rightChunk);
       
 14447 
       
 14448     /*
       
 14449     if( (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode))) ||
       
 14450             (TLanguage(iLanguageCapabilities.iInputLanguageCode) == ELangThai))
       
 14451         {
       
 14452         cursorPos = pos.iPos;
       
 14453         }
       
 14454     else
       
 14455         {
       
 14456         cursorPos = pos.iPos + 1;    
       
 14457         }
       
 14458     */
       
 14459     
       
 14460     anchorPos = pos.iPos;
       
 14461     cursorPos = pos.iPos;
       
 14462     FindEndOfWord(cursorPos);          
       
 14463     FindStartOfWord(anchorPos);
       
 14464     
       
 14465     
       
 14466     if(cursorPos == pos.iPos || anchorPos == pos.iPos)
       
 14467         {
       
 14468         iUncommittedText.SetSelection(pos.iPos, pos.iPos);
       
 14469         aComsumeKey = ETrue;
       
 14470         return EFalse;
       
 14471         }
       
 14472     else
       
 14473         {
       
 14474         iUncommittedText.SetSelection(cursorPos, anchorPos);
       
 14475         }  
       
 14476     
       
 14477     if (iUncommittedText.Length() <= EMaximumFepWordLength)
       
 14478         {
       
 14479         iInputCapabilities.FepAwareTextEditor()->
       
 14480             GetEditorContentForFep(aText, iUncommittedText.iAnchorPos, iUncommittedText.Length());
       
 14481         aComsumeKey = ETrue;
       
 14482         return ETrue;
       
 14483         }
       
 14484     else
       
 14485         {
       
 14486         /*
       
 14487         TInt newCursorPosition= (pos.iPos == cursorPos) ? anchorPos : cursorPos;
       
 14488         iUncommittedText.SetSelection(newCursorPosition, newCursorPosition);
       
 14489         iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
 14490         */
       
 14491         aComsumeKey = ETrue;
       
 14492         // The word is longer than EMaximumFepWordLength. Ui is deactivated.
       
 14493         TryCloseUiL();
       
 14494         return EFalse;
       
 14495         }
       
 14496     }
       
 14497 
       
 14498 void CAknFepManager::UpdateCbaL(TInt aResourceId)
       
 14499     {
       
 14500     if ( !IsFepAwareTextEditor() )
       
 14501         {
       
 14502         return;
       
 14503         }
       
 14504 
       
 14505     if (IsCcpuFlagSet(ECcpuStateStartCopy | ECcpuStateCopy | ECcpuStateStartCut | ECcpuStateCut))
       
 14506         {
       
 14507         return;
       
 14508         }
       
 14509     
       
 14510     if((iAknEditorFlags & EAknEditorFlagFindPane)&& IsChineseInputLanguage()&& aResourceId != NULL)
       
 14511         {
       
 14512         return;
       
 14513         }
       
 14514 
       
 14515 	iUiInterface->UpdateSoftkeysL(aResourceId, EditorState(), this, 
       
 14516                                 iSharedDataInterface->InputMode());
       
 14517     }
       
 14518 
       
 14519 
       
 14520 TBool CAknFepManager::TryRemoveNoMatchesIndicatorL()
       
 14521     {
       
 14522     __ASSERT_DEBUG(IsFlagSet(EFlagInsideInlineEditingTransaction), 
       
 14523                    AknFepPanic(EAknFepPanicNotInsideInlineEdit));
       
 14524 
       
 14525     if (IsFlagSet(CAknFepManager::EFlagNoMatches))
       
 14526         {
       
 14527         ClearFlag(CAknFepManager::EFlagNoMatches); 
       
 14528         TBuf<EMaximumFepWordLength> newText;
       
 14529         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(newText, 
       
 14530                                                                       iUncommittedText.iAnchorPos,
       
 14531                                                                       iUncommittedText.Length());
       
 14532         iInputCapabilities.FepAwareTextEditor()->UpdateFepInlineTextL(newText, 
       
 14533                                                                       iUncommittedText.Length());
       
 14534         SendEventsToPluginManL( EPluginSyncFepAwareText );
       
 14535         return ETrue;
       
 14536         }
       
 14537     return EFalse;
       
 14538     }
       
 14539 
       
 14540 TBool CAknFepManager::IsMoreGoodWordsComing(TInt aNewWordLength) const
       
 14541     {
       
 14542     return (aNewWordLength == iUncommittedText.Length() + 1);
       
 14543     }
       
 14544 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 14545 TBool CAknFepManager::IsMoreGoodAutoCompleteWordsComing(TInt aInputMode,TInt aPreviousWordLength, 
       
 14546                                                         TInt aNewWordLength) const
       
 14547 	{
       
 14548 	return ((aInputMode == EPtiEngineWordCompletion) && (aPreviousWordLength != aNewWordLength ));	
       
 14549 	}
       
 14550 #endif
       
 14551 
       
 14552 void CAknFepManager::TryStartCompoundWord()
       
 14553     {
       
 14554     // check if this word constitutes a 'compound' word
       
 14555     // i.e. is either adjacent char is an alphabetic characeter
       
 14556     TBuf<ESingleCharacter> ch;
       
 14557     // check the previous character
       
 14558     if(iUncommittedText.iAnchorPos>0)
       
 14559         {
       
 14560         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(ch, 
       
 14561                                                                      iUncommittedText.iAnchorPos-1,
       
 14562                                                                      ESingleCharacter);
       
 14563         if (ch.Length()>0 && STATIC_CAST(TChar, IsValidInLineCharacter(ch[0])))
       
 14564             {
       
 14565             SetFlag(EFlagCompoundWord);
       
 14566             }
       
 14567         }
       
 14568 
       
 14569     // check the next character
       
 14570     TInt edSize = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 14571     if (!IsFlagSet(EFlagCompoundWord) && iUncommittedText.iAnchorPos < edSize)
       
 14572         {
       
 14573         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(ch, 
       
 14574                                                                      iUncommittedText.iAnchorPos,
       
 14575                                                                      ESingleCharacter);
       
 14576         if (ch.Length()>0 && STATIC_CAST(TChar, IsValidInLineCharacter(ch[0])))
       
 14577             {
       
 14578             SetFlag(EFlagCompoundWord);
       
 14579             }
       
 14580         }
       
 14581     }
       
 14582 
       
 14583 void CAknFepManager::AddCompoundWordToUdbL()
       
 14584     {
       
 14585     __ASSERT_DEBUG(WesternPredictive() , AknFepPanic(EAknFepPanicNonPermittedEditorMode));
       
 14586 
       
 14587     HBufC* compoundWordBuf = 
       
 14588                    HBufC::NewLC(iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep()); // buffer for text
       
 14589     TPtr compoundWord=compoundWordBuf->Des();
       
 14590 
       
 14591     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 14592 
       
 14593     // reset cursor span on word
       
 14594     FindStartOfWord(iUncommittedText.iAnchorPos);
       
 14595     FindEndOfWord(iUncommittedText.iCursorPos);
       
 14596 
       
 14597     iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(compoundWord, 
       
 14598                                                                     iUncommittedText.iAnchorPos, 
       
 14599                                                                     iUncommittedText.Length());
       
 14600     FepUI()->AddTextToUserDictionaryL(compoundWord);
       
 14601     CleanupStack::PopAndDestroy();  // compoundWordBuf
       
 14602     }
       
 14603 
       
 14604 void CAknFepManager::SetWesternPredictive( const TBool aWesternPredictive )
       
 14605     {
       
 14606     const TInt previousValue = iWesternPredictive;
       
 14607     iWesternPredictive = aWesternPredictive && !(iAknEditorFlags & EAknEditorFlagNoT9) &&
       
 14608     // Predictive QWERTY (XT9) changes ---->
       
 14609         (   
       
 14610 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14611         (
       
 14612 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 14613 		iLanguageCapabilities.iSupportsWesternPredictive 
       
 14614 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14615         && !iQwertyInputMode)
       
 14616          || (iLanguageCapabilities.iSupportsWesternQwertyPredictive && iQwertyInputMode) 
       
 14617 #ifdef __HALF_QWERTY_KEYPAD
       
 14618          || (iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive && iQwertyInputMode) 
       
 14619 #endif //__HALF_QWERTY_KEYPAD
       
 14620 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 14621 		);
       
 14622     // Predictive QWERTY (XT9) changes <----
       
 14623     if ( (previousValue != iWesternPredictive) && !(iAknEditorFlags & EAknEditorFlagNoT9) )
       
 14624         {
       
 14625         if (iWesternPredictive)
       
 14626             {
       
 14627             iSharedDataInterface->SetPredictiveTextOn();
       
 14628             }
       
 14629         else
       
 14630             {
       
 14631             iSharedDataInterface->ResetPredictiveTextOn();
       
 14632             }
       
 14633         if ( iFepPluginManager && iFepPluginManager->IsSupportITIOnFSQ() )
       
 14634         	{
       
 14635             TRAP_IGNORE(SendEventsToPluginManL( EPluginUpdatePenInputITIStatus ));
       
 14636         	}
       
 14637         }
       
 14638     }
       
 14639 
       
 14640 void CAknFepManager::SetWesternAutoComplete( const TBool aWesternAutoComplete )
       
 14641     {
       
 14642     const TInt previousValue = iIsAutoCompleteOn;
       
 14643     iIsAutoCompleteOn = aWesternAutoComplete && !(iAknEditorFlags & EAknEditorFlagNoT9);
       
 14644     if ( (previousValue != iIsAutoCompleteOn) && !(iAknEditorFlags & EAknEditorFlagNoT9) )
       
 14645         {
       
 14646         if (iIsAutoCompleteOn)
       
 14647             {
       
 14648             iSharedDataInterface->SetPredictiveTextAutoCompleteOn();
       
 14649             }
       
 14650         else
       
 14651             {
       
 14652             iSharedDataInterface->ResetPredictiveTextAutoCompleteOn();
       
 14653             }
       
 14654         }
       
 14655     }
       
 14656 
       
 14657 void CAknFepManager::SetJapanesePredictive(const TBool aJapanesePredictive)
       
 14658     {
       
 14659     if (iJapanesePredictive != aJapanesePredictive)
       
 14660         {
       
 14661         iJapanesePredictive = aJapanesePredictive;
       
 14662         }
       
 14663     if (iJapanesePredictive & iSharedDataInterface->PredictiveTextJapaneseOn()
       
 14664      || !iJapanesePredictive & !iSharedDataInterface->PredictiveTextJapaneseOn())
       
 14665         {
       
 14666         if(iJapanesePredictive)
       
 14667             {
       
 14668             iSharedDataInterface->SetJapanesePredictiveTextOn();
       
 14669             }
       
 14670         else
       
 14671             {
       
 14672             iSharedDataInterface->ResetJapanesePredictiveTextOn();
       
 14673             }
       
 14674         }
       
 14675     }
       
 14676 
       
 14677 void CAknFepManager::SetQwertyMode(const TBool aQwertyInputMode)
       
 14678     {
       
 14679 #ifdef RD_SCALABLE_UI_V2
       
 14680     if( aQwertyInputMode && iFepPluginManager && 
       
 14681         iSharedDataInterface->PluginInputMode() != EPluginInputModeNone
       
 14682         // Add this condition for addtion of ITI features on FSQ.
       
 14683         // iSharedDataInterface->QwertyInputMode() == 1, means that 
       
 14684         // hw keyboard is slided, then need to close touch inputmethods.
       
 14685         && iSharedDataInterface->QwertyInputMode() )
       
 14686         {
       
 14687         iFepPluginManager->ResetMenuState(EFalse);        
       
 14688         ExitPluginSpellModeByCancel();
       
 14689         TRAP_IGNORE(iFepPluginManager->ClosePluginInputModeL( ETrue ));
       
 14690         if ( iCancelPopupInQwerty )
       
 14691             {
       
 14692             TRAP_IGNORE( SimulateKeyEventL( EKeyCBA2 ) );
       
 14693             }
       
 14694         }
       
 14695     SetQwertyModeToInputcapbility();
       
 14696 #endif//RD_SCALABLE_UI_V2
       
 14697     if (!COMPARE_BOOLS(aQwertyInputMode, iQwertyInputMode))
       
 14698         {
       
 14699 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 14700         if(IsAutoCompleteOn())
       
 14701         	{
       
 14702             TRAP_IGNORE(RemoveSuggestedCompletionL());
       
 14703             }
       
 14704 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 14705         iQwertyInputMode = aQwertyInputMode;
       
 14706         if (!iQwertyInputMode)
       
 14707             {
       
 14708 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14709             SetTypingCorrectionLevel(EPtiErrorCorrectionLevelHigh);
       
 14710             SetNumberCandidateState(ETrue); // ETrue
       
 14711             SetPrimaryCandidate(EFalse); // Best prediction
       
 14712 #endif            
       
 14713             ClearFlag(EFlagQwertyShiftMode | EFlagNoActionDuringChrKeyPress);
       
 14714             }
       
 14715 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14716         else
       
 14717 	        {
       
 14718 	        iSharedDataInterface->HandlePredictiveTextNumberCandidateSettingChange();
       
 14719 	        iSharedDataInterface->HandlePredictiveTextTypingCorrectionLevelChange();
       
 14720 	        iSharedDataInterface->HandlePredictiveTextPrimaryCandidateChange();	
       
 14721 	        }
       
 14722 #endif        
       
 14723 
       
 14724         if ( iFepManState != EAknFepStateNull && IsFepAwareTextEditor() )
       
 14725             {
       
 14726 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14727 
       
 14728 			   // In case of layout remove the auto completion part
       
 14729 			   // Before transfer fep state to editor state.        
       
 14730                if(IsAutoCompleteOn())
       
 14731             	{
       
 14732 #ifdef RD_SCALABLE_UI_V2            	
       
 14733                 if( iFepPluginManager 
       
 14734                         && iFepPluginManager->IsSupportITIOnFSQ()
       
 14735                         && !iQwertyInputMode )
       
 14736                     {
       
 14737                     TRAP_IGNORE( iPtiEngine->HandleCommandL( EPtiCommandLockCurrentCandidate ) );
       
 14738                     }
       
 14739                 else
       
 14740 #endif //RD_SCALABLE_UI_V2                	
       
 14741                     {
       
 14742                     TInt tailLength = 0;
       
 14743                     TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength ));
       
 14744                     if(tailLength > 0)
       
 14745                         {
       
 14746                         TRAP_IGNORE(
       
 14747                             {
       
 14748                             RemoveSuggestedAdvanceCompletionL();
       
 14749                             iPtiEngine->HandleCommandL( EPtiCommandLockCurrentCandidate );
       
 14750                             });                       
       
 14751                         }
       
 14752                     }
       
 14753             	}
       
 14754 #endif 
       
 14755             if ( !iFocusedItemDestroy )
       
 14756             	{            	
       
 14757                 TRAP_IGNORE(
       
 14758                     {
       
 14759                     TransferFepStateToEditorL();
       
 14760                     TryCloseUiL();
       
 14761                     ConfigureFEPFromEditorStateL();
       
 14762                     });                
       
 14763             	}            
       
 14764             }
       
 14765         }
       
 14766 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14767     if(iFnKeyManager)
       
 14768         iFnKeyManager->SetQwertyInputMode(aQwertyInputMode);
       
 14769 #endif
       
 14770     }
       
 14771 
       
 14772 TBool CAknFepManager::WesternPredictive(TInt aMode) const
       
 14773     {
       
 14774     TInt mode = iMode;
       
 14775     if ( aMode )
       
 14776         {
       
 14777         mode = aMode;
       
 14778         }
       
 14779     return (mode == ELatin && iWesternPredictive &&
       
 14780     // Predictive QWERTY (XT9) changes ---->
       
 14781       
       
 14782 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14783         ((
       
 14784 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 14785 		iLanguageCapabilities.iSupportsWesternPredictive 
       
 14786 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14787         && !iQwertyInputMode)
       
 14788          || (iLanguageCapabilities.iSupportsWesternQwertyPredictive && iQwertyInputMode)
       
 14789 #ifdef __HALF_QWERTY_KEYPAD
       
 14790 		|| (iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive && iQwertyInputMode)
       
 14791 #endif //__HALF_QWERTY_KEYPAD
       
 14792 		)
       
 14793 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 14794 		);
       
 14795     // Predictive QWERTY (XT9) changes <----
       
 14796     }
       
 14797 
       
 14798 TBool CAknFepManager::IsPredictive(TInt aMode) const
       
 14799     {
       
 14800     TBool isPredictive = EFalse;
       
 14801     TInt mode = iMode;
       
 14802     if ( aMode )
       
 14803         {
       
 14804         mode = aMode;
       
 14805         }
       
 14806     if (mode == EHiraganaKanji )
       
 14807         {
       
 14808         if ((iPermittedInputModes & EAknEditorHiraganaKanjiInputMode)
       
 14809          && iJapanesePredictive
       
 14810          && !(iAknEditorFlags & EAknEditorFlagNoT9)
       
 14811          && HasJapanesePredictionInputMode())
       
 14812             {
       
 14813             isPredictive = ETrue;
       
 14814             // Japanese predictive input is available on both Qwerty and not Qwerty
       
 14815             return isPredictive;
       
 14816             }
       
 14817         }
       
 14818     else if (mode == ELatin)
       
 14819         {
       
 14820         if ((iPermittedInputModes & (EAknEditorTextInputMode | EAknEditorHalfWidthTextInputMode))
       
 14821           && !(iAknEditorFlags & EAknEditorFlagNoT9)
       
 14822           && iWesternPredictive && 
       
 14823           (iLanguageCapabilities.iSupportsWesternPredictive
       
 14824 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14825            ||iLanguageCapabilities.iSupportsWesternQwertyPredictive 
       
 14826 #ifdef __HALF_QWERTY_KEYPAD           
       
 14827            ||iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive
       
 14828 #endif //__HALF_QWERTY_KEYPAD           
       
 14829 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 14830 		)) // Predictive QWERTY (XT9) changes
       
 14831             {
       
 14832             isPredictive = ETrue;
       
 14833             }
       
 14834         }
       
 14835 #ifdef RD_SCALABLE_UI_V2
       
 14836 	#ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14837 	    return isPredictive; //&& (iFepPluginManager->PluginInputMode() == EPluginInputModeNone);
       
 14838 	#else
       
 14839 	    return isPredictive && !iQwertyInputMode 
       
 14840              && ((iFepPluginManager->PluginInputMode() == EPluginInputModeItut) 
       
 14841 	    			|| (iFepPluginManager->PluginInputMode() == EPluginInputModeNone));
       
 14842 	#endif //RD_INTELLIGENT_TEXT_INPUT
       
 14843 #else
       
 14844 	#ifdef RD_INTELLIGENT_TEXT_INPUT
       
 14845 	    return isPredictive;
       
 14846 	#else
       
 14847 	    return isPredictive && !iQwertyInputMode;
       
 14848 	#endif //RD_INTELLIGENT_TEXT_INPUT
       
 14849 #endif //RD_SCALABLE_UI_V2
       
 14850     }
       
 14851 
       
 14852 TBool CAknFepManager::Japanese() const
       
 14853     {
       
 14854     TBool rtn = EFalse;
       
 14855     switch (iMode)
       
 14856         {
       
 14857         case EHiraganaKanji:
       
 14858         case EKatakana:
       
 14859         case EHiragana:
       
 14860             rtn = ETrue;
       
 14861             break;
       
 14862         case ELatin:
       
 14863             if ((!WesternPredictive()) && iCharWidth == EFullWidthChar)
       
 14864                 {
       
 14865                 rtn = ETrue;
       
 14866                 }
       
 14867             break;
       
 14868         case ENumber:
       
 14869             if (iCharWidth == EFullWidthChar)
       
 14870                 {
       
 14871                 rtn = ETrue;
       
 14872                 }
       
 14873             break;
       
 14874         default:
       
 14875             break;
       
 14876         }
       
 14877     return rtn;
       
 14878     }
       
 14879 
       
 14880 TBool CAknFepManager::IsOnlyFullWidthCharacterPermitted() const
       
 14881     {
       
 14882     CAknEdwinState* editorState = EditorState();
       
 14883     TUint permittedInputModes = editorState->PermittedInputModes();
       
 14884     TUint fullWidthPermitted = (EAknEditorFullWidthTextInputMode
       
 14885                               | EAknEditorFullWidthNumericInputMode
       
 14886                               | EAknEditorFullWidthKatakanaInputMode);
       
 14887     TUint fullWidthNotPermitted = ~fullWidthPermitted;
       
 14888     TBool isfullchar = ETrue;
       
 14889     if (permittedInputModes & fullWidthNotPermitted)
       
 14890         {
       
 14891         isfullchar = EFalse;
       
 14892         }
       
 14893 
       
 14894     if (!(permittedInputModes & fullWidthPermitted))
       
 14895         {
       
 14896         isfullchar = EFalse;
       
 14897         }
       
 14898 
       
 14899     return isfullchar;
       
 14900     }
       
 14901 
       
 14902 TBool CAknFepManager::IsOnlyHalfWidthCharacterPermitted() const
       
 14903     {
       
 14904     CAknEdwinState* editorState = EditorState();
       
 14905     TUint permittedInputModes;
       
 14906     if( editorState )
       
 14907         {
       
 14908         permittedInputModes= editorState->PermittedInputModes();
       
 14909         }
       
 14910     else
       
 14911         {
       
 14912         permittedInputModes = EAknEditorNumericInputMode;
       
 14913         }
       
 14914     TUint halfWidthNotPermitted = (EAknEditorFullWidthTextInputMode
       
 14915                                  | EAknEditorFullWidthNumericInputMode
       
 14916                                  | EAknEditorFullWidthKatakanaInputMode
       
 14917                                  | EAknEditorHiraganaKanjiInputMode
       
 14918                                  | EAknEditorHiraganaInputMode);
       
 14919 
       
 14920     TUint halfWidthPermitted  = ~halfWidthNotPermitted;
       
 14921     TBool ishalfchar = ETrue;
       
 14922     if (permittedInputModes & halfWidthNotPermitted)
       
 14923         {
       
 14924         ishalfchar = EFalse;
       
 14925         }
       
 14926 
       
 14927     if (!(permittedInputModes & halfWidthPermitted))
       
 14928         {
       
 14929         ishalfchar = EFalse;
       
 14930         }
       
 14931     if (permittedInputModes & EAknEditorTextInputMode)
       
 14932         {
       
 14933         ishalfchar = EFalse;
       
 14934         }
       
 14935     if (editorState && (editorState->Flags() & EAknEditorFlagLatinInputModesOnly))
       
 14936         {
       
 14937         ishalfchar = ETrue;
       
 14938         }
       
 14939     return ishalfchar;
       
 14940     }
       
 14941 
       
 14942 TBool CAknFepManager::IsHalfAndFullKatakanaPermitted() const
       
 14943     {
       
 14944     CAknEdwinState* editorState = EditorState();
       
 14945     TUint permittedInputModes = editorState->PermittedInputModes();
       
 14946     TUint katakanaInputMode = (EAknEditorKatakanaInputMode
       
 14947                               | EAknEditorFullWidthKatakanaInputMode);
       
 14948     TBool iskatakana = EFalse;
       
 14949     if ((permittedInputModes & katakanaInputMode) == katakanaInputMode)
       
 14950         {
       
 14951         iskatakana = ETrue;
       
 14952         }
       
 14953     return iskatakana;
       
 14954     }
       
 14955 
       
 14956 TBool CAknFepManager::IsHalfAndFullLatinPermitted() const
       
 14957     {
       
 14958     CAknEdwinState* editorState = EditorState();
       
 14959     TUint permittedInputModes = editorState->PermittedInputModes();
       
 14960     TUint latinInputMode = (EAknEditorHalfWidthTextInputMode
       
 14961                               | EAknEditorFullWidthTextInputMode);
       
 14962     TBool islatin = EFalse;
       
 14963 
       
 14964     if ((permittedInputModes & latinInputMode) == latinInputMode)
       
 14965         {
       
 14966         islatin = ETrue;
       
 14967         }
       
 14968     return islatin;
       
 14969     }
       
 14970 
       
 14971 TBool CAknFepManager::IsHalfAndFullNumberPermitted() const
       
 14972     {
       
 14973     CAknEdwinState* editorState = EditorState();
       
 14974     TUint permittedInputModes = editorState->PermittedInputModes();
       
 14975     TUint numInputMode = (EAknEditorNumericInputMode
       
 14976                               | EAknEditorFullWidthNumericInputMode);
       
 14977     TBool isnum = EFalse;
       
 14978     if ((permittedInputModes & numInputMode) == numInputMode)
       
 14979         {
       
 14980         isnum = ETrue;
       
 14981         }
       
 14982 
       
 14983     return isnum;
       
 14984     }
       
 14985 
       
 14986 TWidthChar CAknFepManager::CharacterWidth() const
       
 14987     {
       
 14988     return iCharWidth;
       
 14989     }
       
 14990 
       
 14991 CPtiEngine* CAknFepManager::PtiEngine() const
       
 14992     {
       
 14993     return iPtiEngine;
       
 14994     }
       
 14995 
       
 14996 void CAknFepManager::SetInlineEditingCursorVisibilityL(TBool aCursorVisibility)
       
 14997     {
       
 14998 #ifdef RD_SCALABLE_UI_V2
       
 14999     if ( SemiFepAwareTextEditor( ETrue ) )
       
 15000 #else
       
 15001     if (iInputCapabilities.FepAwareTextEditor())
       
 15002 #endif // RD_SCALABLE_UI_V2
       
 15003         {
       
 15004         iInputCapabilities.FepAwareTextEditor()->SetInlineEditingCursorVisibilityL(aCursorVisibility);
       
 15005         }
       
 15006     }
       
 15007 
       
 15008 TInt CAknFepManager::InputMode() const
       
 15009     {
       
 15010     return iMode;
       
 15011     }
       
 15012     
       
 15013 TInt CAknFepManager::CangJieMode() const
       
 15014     {
       
 15015     TInt shareMode = iSharedDataInterface->CangJieMode();
       
 15016     TInt cangjieMode = shareMode + EPtiEngineNormalCangjieQwerty;
       
 15017     return cangjieMode;
       
 15018     }    
       
 15019 
       
 15020 TBool CAknFepManager::InputLanguageSupportsCaseChanges() const
       
 15021     {
       
 15022     return iLanguageCapabilities.iSupportsCase;
       
 15023     }
       
 15024 
       
 15025 TBool CAknFepManager::IsAbleScrollLatinPredictive() const
       
 15026     {
       
 15027     return iSharedDataInterface->ScrollLatinPredictiveCandidates();
       
 15028     }
       
 15029 
       
 15030 TText CAknFepManager::PreviousChar( TBool /*aContextSensitive*/ )
       
 15031     {
       
 15032     TBuf<ESingleCharacter> previousCharacter(ESingleCharacter);
       
 15033     previousCharacter.FillZ();
       
 15034 
       
 15035     TCursorSelection curSel;
       
 15036     if ( IsFepAwareTextEditor() )
       
 15037         {
       
 15038         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(curSel);
       
 15039         TInt lowerpos = curSel.LowerPos();
       
 15040         if(lowerpos > 0)
       
 15041             {
       
 15042             iInputCapabilities.FepAwareTextEditor()->
       
 15043                 GetEditorContentForFep(previousCharacter, lowerpos-1, ESingleCharacter);
       
 15044             if (previousCharacter.Length())
       
 15045                 return previousCharacter[0];
       
 15046             }
       
 15047         }
       
 15048     return NULL;
       
 15049     }
       
 15050 
       
 15051 TBool CAknFepManager::IsZWSCharacterPresent( TBool aLigaturePresent /* = EFalse*/ )
       
 15052     {
       
 15053     TBuf<3> previousCharacter;
       
 15054     previousCharacter.Zero();
       
 15055     TBool found = EFalse;
       
 15056     previousCharacter.FillZ();
       
 15057 
       
 15058     TCursorSelection curSel;
       
 15059     if ( IsFepAwareTextEditor() )
       
 15060         {
       
 15061         MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 15062             iInputCapabilities.FepAwareTextEditor();
       
 15063         fepAwareTextEditor->GetCursorSelectionForFep(curSel);
       
 15064         TInt lowerpos = curSel.LowerPos();
       
 15065         if( lowerpos > 1 )
       
 15066             {
       
 15067             if( aLigaturePresent && lowerpos > 3 )
       
 15068                 {
       
 15069                 fepAwareTextEditor->
       
 15070                     GetEditorContentForFep(previousCharacter, 
       
 15071                                             lowerpos - 4, 2);
       
 15072                 }
       
 15073             else
       
 15074                 {
       
 15075                 fepAwareTextEditor->
       
 15076                     GetEditorContentForFep(previousCharacter, 
       
 15077                                             lowerpos - 2, 2);
       
 15078                 }
       
 15079             if( previousCharacter[0] == ZERO_WIDTH_SPACE
       
 15080                      || previousCharacter[1] == ZERO_WIDTH_SPACE )
       
 15081                 {
       
 15082                 found = ETrue;
       
 15083                 }   
       
 15084             }
       
 15085         }
       
 15086     return found;
       
 15087     }
       
 15088 
       
 15089 TText CAknFepManager::NextChar()    
       
 15090     {
       
 15091     TBuf<ESingleCharacter> nextCharacter(ESingleCharacter);
       
 15092     nextCharacter.FillZ();
       
 15093 
       
 15094     TCursorSelection curSel;
       
 15095     if ( IsFepAwareTextEditor() )
       
 15096         {
       
 15097         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(curSel);
       
 15098         TInt higherpos = curSel.HigherPos();
       
 15099         TInt maxLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 15100         if ( higherpos >= 0 && higherpos <= maxLength && maxLength >= 1 ) 
       
 15101             {
       
 15102             iInputCapabilities.FepAwareTextEditor()->
       
 15103                 GetEditorContentForFep(nextCharacter, higherpos, ESingleCharacter);
       
 15104             if( nextCharacter.Length() )    
       
 15105                 return nextCharacter[0];
       
 15106             }
       
 15107         }
       
 15108     return NULL;    
       
 15109     }
       
 15110     
       
 15111 void CAknFepManager::FindStartOfWord(TInt& aAnchorPos) const
       
 15112     {
       
 15113     TBuf<ESingleCharacter> characterBuffer;
       
 15114     FOREVER
       
 15115         {
       
 15116         if (aAnchorPos<=0)
       
 15117             {
       
 15118             break; // start of editor
       
 15119             }
       
 15120         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(characterBuffer, 
       
 15121                                                                         aAnchorPos-1, 
       
 15122                                                                         ESingleCharacter);
       
 15123         if (!IsValidInLineCharacter(characterBuffer[0]))
       
 15124             {
       
 15125             break;
       
 15126             }
       
 15127         aAnchorPos--;
       
 15128         }
       
 15129     }
       
 15130 
       
 15131 void CAknFepManager::FindEndOfWord(TInt& aCursorPos) const
       
 15132     {
       
 15133     TBuf<ESingleCharacter> characterBuffer;
       
 15134     FOREVER
       
 15135         {
       
 15136         if (aCursorPos>=iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep())
       
 15137             {
       
 15138             break; // end of editor
       
 15139             }
       
 15140         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(characterBuffer, 
       
 15141                                                                         aCursorPos, 
       
 15142                                                                         ESingleCharacter);
       
 15143         if (!IsValidInLineCharacter(characterBuffer[0]))
       
 15144             {
       
 15145             break;
       
 15146             }
       
 15147         aCursorPos++;
       
 15148         }
       
 15149     }
       
 15150 
       
 15151 TBool CAknFepManager::CursorInsideWord()
       
 15152     {
       
 15153     TBuf<ESingleCharacter> characterBuffer;
       
 15154     TBool insideWord=ETrue;
       
 15155 
       
 15156     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 15157     TInt cursorPos=iUncommittedText.iCursorPos;
       
 15158 
       
 15159     if (cursorPos)
       
 15160         {
       
 15161         // check character before cursor
       
 15162         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(characterBuffer, 
       
 15163                                                                         cursorPos-1, 
       
 15164                                                                         ESingleCharacter);
       
 15165         if (characterBuffer.Length())
       
 15166 			{
       
 15167             if (!IsValidInLineCharacter(characterBuffer[0]))
       
 15168                 {
       
 15169                 insideWord=EFalse;
       
 15170                 }
       
 15171 			}	
       
 15172         }
       
 15173     else // at start of editor
       
 15174         {
       
 15175         insideWord=EFalse;
       
 15176         }
       
 15177 
       
 15178     if (insideWord && cursorPos<iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep())
       
 15179         {
       
 15180         // put character after cursor into buffer
       
 15181         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(characterBuffer, cursorPos,
       
 15182                                                                         ESingleCharacter);
       
 15183         if (characterBuffer.Length())
       
 15184 			{
       
 15185             if (!IsValidInLineCharacter(characterBuffer[0]))
       
 15186                 {
       
 15187                 insideWord=EFalse;
       
 15188                 }
       
 15189 			}	
       
 15190         }
       
 15191     else // at end of editor
       
 15192         {
       
 15193         insideWord=EFalse;
       
 15194         }
       
 15195 
       
 15196     return insideWord;
       
 15197     }
       
 15198 
       
 15199 void CAknFepManager::MoveCursorToStartOfWordL()
       
 15200     {
       
 15201     TInt anchorPos=iUncommittedText.iAnchorPos;
       
 15202     FindStartOfWord(anchorPos);
       
 15203     iUncommittedText.SetSelection(anchorPos, anchorPos);
       
 15204     iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
 15205     }
       
 15206 
       
 15207 void CAknFepManager::MoveCursorToEndOfWordL()
       
 15208     {
       
 15209     TInt cursorPos=iUncommittedText.iCursorPos;
       
 15210     
       
 15211     if(!IsExtendedFlagSet(EExtendedFlagOkKeyPressOnCandidatePopup))    
       
 15212     	FindEndOfWord(cursorPos);
       
 15213     iUncommittedText.SetSelection(cursorPos, cursorPos);
       
 15214     iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
 15215     }
       
 15216 
       
 15217 TKeyResponse CAknFepManager::HandleNaviEventOutsideInlineEditL(TUint aCode, 
       
 15218                                                                TKeyPressLength aLength)
       
 15219     {
       
 15220     TKeyResponse response = EKeyWasNotConsumed;
       
 15221     if ( iFepPluginManager && iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr 
       
 15222     	 && aCode == EKeyBackspace )
       
 15223     	{
       
 15224         return response;
       
 15225     	}
       
 15226     
       
 15227     if (TryHandleCommonArrowAndBackspaceFunctionalityL(aCode, response))
       
 15228         {
       
 15229         return response;
       
 15230         }
       
 15231     
       
 15232     // You will not understand the flowing lines, 
       
 15233     // for it is just a "hole stem" than normal logic.
       
 15234     //
       
 15235     // Let me explain: 
       
 15236     // In HWR, 4x12 keyboard is used, and predictive should be disabled for it.
       
 15237     // unfortunately, the existed codes enable predictive in some special case.
       
 15238     // when you switch from FSQ to HWR, with ITI on, you will get that.
       
 15239     // then if you press arrow key, 
       
 15240     // the code blow of "HandlePredictiveNaviEventOutsideInlineEditL" will be called.
       
 15241     // which is writen for FSQ, not HWR, that finally cause navi-event being consumed.
       
 15242     // No navigation action being performed.
       
 15243     //
       
 15244     // It is not a complete fix, just for simplicity. 
       
 15245     if (iFepPluginManager && 
       
 15246         iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr)
       
 15247         {
       
 15248         return EKeyWasNotConsumed;
       
 15249         }
       
 15250 
       
 15251     if (WesternPredictive())
       
 15252         {
       
 15253         response = HandlePredictiveNaviEventOutsideInlineEditL(aCode, aLength);
       
 15254         }
       
 15255 
       
 15256     return response;
       
 15257     }
       
 15258 
       
 15259 TKeyResponse CAknFepManager::HandleWesternPredictiveArrowKeyL(TInt aCode, TKeyPressLength aLength)
       
 15260     {
       
 15261     TKeyResponse response = EKeyWasNotConsumed;
       
 15262     
       
 15263     if (IsFlagSet(EFlagLineFeedCharacter))
       
 15264         {
       
 15265         // This event will stop the multitapping timer for enter chr.
       
 15266         // just return.
       
 15267         return EKeyWasConsumed;                
       
 15268         }
       
 15269 
       
 15270 	TCursorSelection selection;
       
 15271     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(selection);
       
 15272     if(!IsMfneEditor() &&
       
 15273          ( iFepPluginManager->PluginInputMode() == EPluginInputModeItut) &&
       
 15274          selection.Length() > 0)
       
 15275         {
       
 15276         // If open virtual ITUT and highlight some chars
       
 15277         return EKeyWasConsumed;
       
 15278         }        
       
 15279     if (aCode == EKeyUpArrow || aCode == EKeyDownArrow)
       
 15280         {
       
 15281         ClearFlag(EFlagCompoundWord);
       
 15282         if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
 15283             {
       
 15284             // moving out of an inline edit
       
 15285             TryRemoveNoMatchesIndicatorL();
       
 15286             UpdateCbaL(NULL);
       
 15287             // To rip off suggested word completion when user presses UP / DOWN arrow keys
       
 15288             if(IsAutoCompleteOn())
       
 15289            		{
       
 15290 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 15291            		
       
 15292            		RemoveSuggestedCompletionL();
       
 15293            		
       
 15294 #else
       
 15295            		TInt tailLength = 0;
       
 15296            		iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, 
       
 15297 										&tailLength );
       
 15298            		if(tailLength > 0)
       
 15299            			{
       
 15300            			RemoveSuggestedAdvanceCompletionL();
       
 15301            			return EKeyWasConsumed;
       
 15302            			}
       
 15303 #endif          	
       
 15304             	}
       
 15305             if (IsFlagSet(EFlagShiftKeyDepressed) || IsCcpuFlagSet(ECcpuStateHashDown))
       
 15306                 {
       
 15307                 CommitInlineEditL();
       
 15308                 TryCloseUiL();
       
 15309                 SimulateKeyEventL(EKeyF19);  // Asyncronous case update
       
 15310                 // pass to editor for text selection.
       
 15311                 response=EKeyWasNotConsumed;
       
 15312                 }
       
 15313             }
       
 15314 		if ((iInputCapabilities.FepAwareTextEditor() && !TryHandleTextSelectedNaviEventL(aCode, response)) && !IsFlagSet(EFlagShiftKeyDepressed))
       
 15315             {
       
 15316             if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
 15317                 {
       
 15318                 ClearFlag(CAknFepManager::EFlagNoMatches);
       
 15319                 TryRemoveNoMatchesIndicatorL();
       
 15320                 CommitInlineEditL();
       
 15321                 }
       
 15322             UpdateCbaL(NULL);
       
 15323 
       
 15324             // simulate a designated key event to catch and check if we're inside a word
       
 15325             if (aCode == EKeyDownArrow)
       
 15326                 {
       
 15327                 SimulateKeyEventL(EKeyF22);
       
 15328                 }
       
 15329             else
       
 15330                 {
       
 15331                 SimulateKeyEventL(EKeyF23);
       
 15332                 }
       
 15333             // pass to editor for text selection.
       
 15334             response=EKeyWasNotConsumed;
       
 15335             }
       
 15336         else if (IsFlagSet(EFlagShiftKeyDepressed) || IsCcpuFlagSet(ECcpuStateHashDown))
       
 15337             {
       
 15338             // Need to update case indicator if text selection is made upwards.
       
 15339             SimulateKeyEventL(EKeyF19);
       
 15340             }
       
 15341         }
       
 15342     else // right or left
       
 15343         {
       
 15344         if (IsFlagSet(EFlagInsideInlineEditingTransaction))
       
 15345             {
       
 15346             // moving out of an inline edit
       
 15347 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 15348                 if(IsAutoCompleteOn())
       
 15349                 	{
       
 15350                 	if((aCode == EKeyLeftArrow && 
       
 15351                 	    		CurrentInputDirectionality() == TBidiText::ELeftToRight) || 
       
 15352                 	    (aCode == EKeyRightArrow && 
       
 15353                 	    		CurrentInputDirectionality() == TBidiText::ERightToLeft))
       
 15354                 		{
       
 15355                 		RemoveSuggestedCompletionL();	
       
 15356                 		}
       
 15357                 	}
       
 15358 #else
       
 15359             if(IsAutoCompleteOn())
       
 15360             	{
       
 15361                 TInt tailLength = 0;
       
 15362             	iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength );
       
 15363             	// In case the inline editing is ongoing and there is a word completion
       
 15364                 // currently shown, the first backwards tap will remove the suggested 
       
 15365                 // completion. 
       
 15366                 if(tailLength > 0)
       
 15367 	                {
       
 15368 	                if (((CurrentInputDirectionality()==TBidiText::ERightToLeft) && aCode == EKeyLeftArrow) 
       
 15369 	                	|| ((CurrentInputDirectionality()==TBidiText::ELeftToRight) && aCode == EKeyRightArrow ))
       
 15370 	                    {
       
 15371 					    iPtiEngine->HandleCommandL( EPtiCommandLockCurrentCandidate);
       
 15372 					    TPtrC selectedWord = iPtiEngine->CurrentWord();
       
 15373                         UpdateInlineEditL( selectedWord, selectedWord.Length() );  //selection.iAnchorPosition
       
 15374                         iPtiEngine->CommitCurrentWord();
       
 15375                         TryCloseUiL();
       
 15376                         // Asyncronous case update after the editor has handled the key
       
 15377                 		SimulateKeyEventL(EKeyF19); 
       
 15378 	                    response=EKeyWasConsumed;
       
 15379 	                    }
       
 15380 	                else if(((CurrentInputDirectionality()== TBidiText::ERightToLeft ) && aCode == EKeyRightArrow) 
       
 15381 	                	|| ((CurrentInputDirectionality()== TBidiText::ELeftToRight) && aCode == EKeyLeftArrow )) 
       
 15382 		                {
       
 15383 	                    RemoveSuggestedAdvanceCompletionL();
       
 15384 	                    response=EKeyWasConsumed;
       
 15385 		                } 
       
 15386 			           return response;   	
       
 15387 	                }
       
 15388 	                else if (!IsQwerty())
       
 15389 		                {
       
 15390 		                iPtiEngine->CommitCurrentWord();
       
 15391 		                }
       
 15392 				
       
 15393             	}
       
 15394 #endif // RD_INTELLIGENT_TEXT_INPUT
       
 15395             TryRemoveNoMatchesIndicatorL();
       
 15396             UpdateCbaL(NULL);
       
 15397             if (IsFlagSet(EFlagShiftKeyDepressed) || IsCcpuFlagSet(ECcpuStateHashDown))
       
 15398                 {
       
 15399 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 15400                  if(IsAutoCompleteOn()) // To rip off suggested completion when shift key is pressed 
       
 15401                  	{
       
 15402                  	RemoveSuggestedCompletionL();
       
 15403                 	}
       
 15404 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 15405                 CommitInlineEditL();
       
 15406                 TryCloseUiL();
       
 15407                 SimulateKeyEventL(EKeyF19);  // Asyncronous case update
       
 15408                 // pass to editor for text selection.
       
 15409                 response=EKeyWasNotConsumed;
       
 15410                 }
       
 15411             else
       
 15412                 {
       
 15413                 TWesternNaviEvent naviEvent = ELeftNaviEvent;
       
 15414                 if (aCode == EKeyRightArrow)
       
 15415                     {
       
 15416                     naviEvent = ERightNaviEvent;
       
 15417                     }
       
 15418                 // Find the visual left/right end of the current word
       
 15419                 TTmDocPosSpec pos;
       
 15420                 GetAvkonDefinedVisualLimitsOfSelection(
       
 15421                     iUncommittedText, naviEvent, pos, NULL );
       
 15422 
       
 15423                 if (IsCcpuFlagSet(ECcpuStateNewPredictiveWord))
       
 15424                     {
       
 15425                     // This is new predictive word which is being committed with arrow
       
 15426                     // key. Force ::TryCloseUiL to commit PtiEngie word to keep
       
 15427                     // frequency information in sync.
       
 15428                     SetCcpuFlag(ECcpuStataCommitPredictiveWord);
       
 15429                     }
       
 15430 
       
 15431                 TryCloseUiL();
       
 15432 
       
 15433                 // Position should be dis-ambiguated based on last navigation and direction of blocks.
       
 15434                 AdjustPosSpecForAmbiguityAfterLeftOrRightNavigation( pos, naviEvent );
       
 15435 
       
 15436                 SetCursorPositionL( pos );
       
 15437                 if (CursorInsideWord() && naviEvent == ERightNaviEvent)
       
 15438                 {
       
 15439                     MoveCursorToEndOfWordL();
       
 15440                 }
       
 15441 
       
 15442                 iCaseMan->UpdateCase(ENullNaviEvent);
       
 15443                 response=EKeyWasConsumed;
       
 15444                 }
       
 15445             }
       
 15446         else
       
 15447             {
       
 15448 #ifndef RD_INTELLIGENT_TEXT_INPUT            
       
 15449             if ( iLanguageCapabilities.iInputLanguageCode == ELangThai ) // Without this, t9 goes inside words
       
 15450                 {                               // That is not allowed in Thai
       
 15451                 response = EKeyWasNotConsumed;
       
 15452                 }
       
 15453             else
       
 15454 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 15455             response = HandleNaviEventOutsideInlineEditL(aCode, aLength);
       
 15456             if (response == EKeyWasNotConsumed)
       
 15457                 {
       
 15458                 // moving over a space
       
 15459                 if (aCode == EKeyLeftArrow && !IsFlagSet(EFlagShiftKeyDepressed))
       
 15460                     {
       
 15461                     iCaseMan->UpdateCase(ELeftNaviEvent);
       
 15462                     }
       
 15463                 else if (!IsFlagSet(EFlagShiftKeyDepressed)) // EKeyRightArrow
       
 15464                     {
       
 15465                     iCaseMan->UpdateCase(ERightNaviEvent);
       
 15466                     }
       
 15467                 }
       
 15468             else
       
 15469                 iCaseMan->UpdateCase(ENullNaviEvent);
       
 15470             }
       
 15471         }
       
 15472     return response;
       
 15473     }
       
 15474 
       
 15475 TBool CAknFepManager::TryHandleTextSelectedNaviEventL(TInt aCode, TKeyResponse& response)
       
 15476     {
       
 15477     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 15478 
       
 15479     if (!IsFlagSet(EFlagShiftKeyDepressed) && iUncommittedText.Length())
       
 15480         {
       
 15481         if (aCode == EKeyBackspace)
       
 15482             {
       
 15483             iCaseMan->UpdateCase(EBackspaceEvent);
       
 15484             response = EKeyWasNotConsumed;
       
 15485             }
       
 15486         else
       
 15487             {
       
 15488             TInt newCursorPos = iUncommittedText.HigherPos(); //default, right or down
       
 15489             if (aCode == EKeyLeftArrow || aCode == EKeyUpArrow)
       
 15490                 {
       
 15491                 newCursorPos = iUncommittedText.LowerPos();
       
 15492                 }
       
 15493             iUncommittedText.SetSelection(newCursorPos, newCursorPos);
       
 15494             iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
 15495 
       
 15496             if (WesternPredictive())
       
 15497                 {
       
 15498                 if (CursorInsideWord())
       
 15499                     {
       
 15500                     if (aCode == EKeyLeftArrow || aCode == EKeyUpArrow)
       
 15501                         {
       
 15502                         MoveCursorToStartOfWordL();
       
 15503                         }
       
 15504                     else //right or down
       
 15505                         {
       
 15506                         MoveCursorToEndOfWordL();
       
 15507                         }
       
 15508                     }
       
 15509                 iCaseMan->UpdateCase(ENullNaviEvent);
       
 15510                 }
       
 15511             response = EKeyWasConsumed;
       
 15512             }
       
 15513         return ETrue;
       
 15514         }
       
 15515     return EFalse;
       
 15516     }
       
 15517 
       
 15518 TBool CAknFepManager::TryHandleCommonArrowAndBackspaceFunctionalityL(TInt aCode, 
       
 15519                                                                      TKeyResponse& aResponse)
       
 15520     {
       
 15521     TBool keyHandled = ETrue;
       
 15522     if ( !IsFepAwareTextEditor() )
       
 15523         {
       
 15524         aResponse=EKeyWasNotConsumed;
       
 15525         return keyHandled;
       
 15526         }
       
 15527 #ifdef RD_HINDI_PHONETIC_INPUT        
       
 15528 	if(iLanguageCapabilities.iInputLanguageCode == KLangHindiPhonetic)
       
 15529 		{
       
 15530 		if (aCode == EKeyBackspace)
       
 15531         	{
       
 15532         	CommitInlineEditL();
       
 15533         	FepUI()->HandleKeyL(aCode, EShortKeyPress);
       
 15534         	}
       
 15535 		if(IsFlagSet(CAknFepManager::EFlagNoMatches)) 
       
 15536 			{
       
 15537 			if(PreviousChar() == 0x003F && aCode != EKeyBackspace)
       
 15538 				{
       
 15539 				RemovePreviousCharacterL();		
       
 15540 				}
       
 15541 			ClearFlag(CAknFepManager::EFlagNoMatches);
       
 15542 			FepUI()->ExpireMultitapTimer();
       
 15543 			}
       
 15544 		iPtiEngine->HandleCommandL(EPtiCommandBreakSyllable, NULL );
       
 15545 		}
       
 15546 #endif		
       
 15547     if (IsFlagSet(EFlagInsideMultitapInlineEditingTransaction))
       
 15548         {
       
 15549         FepUI()->ExpireMultitapTimer();
       
 15550 
       
 15551         if (aCode == EKeyBackspace)
       
 15552             {
       
 15553             aResponse = EKeyWasNotConsumed; // let editor handle the move
       
 15554             }
       
 15555         else
       
 15556             {
       
 15557             aResponse = EKeyWasConsumed;
       
 15558             }
       
 15559         }
       
 15560     else
       
 15561         {
       
 15562         //selecting text
       
 15563         if (IsFlagSet(EFlagShiftKeyDepressed) || IsCcpuFlagSet(ECcpuStateCopy | ECcpuStateCut))
       
 15564             {
       
 15565             if (iShiftKeypressMonitor->IsActive())
       
 15566                 {
       
 15567                 ResetShiftKeyMonitorL();    //don't want edit menu
       
 15568                 }
       
 15569             ClearFlag(EFlagQwertyShiftMode);
       
 15570             SimulateKeyEventL(EKeyF19);  // Asyncronous case update
       
 15571             aResponse = EKeyWasNotConsumed;
       
 15572             return keyHandled;
       
 15573             }
       
 15574 
       
 15575         TCursorSelection currentEditorSelection;
       
 15576         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(currentEditorSelection);
       
 15577 
       
 15578         TWesternNaviEvent naviEvent = ENullNaviEvent;
       
 15579 
       
 15580         // Translate key code to internal navi-event
       
 15581         switch( aCode )
       
 15582             {
       
 15583             case EKeyUpArrow:
       
 15584                 naviEvent = EUpNaviEvent;
       
 15585                 break;
       
 15586             case EKeyDownArrow:
       
 15587                 naviEvent = EDownNaviEvent;
       
 15588                 break;
       
 15589             case EKeyRightArrow:
       
 15590                 naviEvent = ERightNaviEvent;
       
 15591                 break;
       
 15592             case EKeyLeftArrow:
       
 15593                 naviEvent = ELeftNaviEvent;
       
 15594                 break;
       
 15595             default: // just leave it as NULL
       
 15596                 break;
       
 15597             }
       
 15598 
       
 15599         if (currentEditorSelection.Length())
       
 15600             {
       
 15601             // we have text selected - set cursor to start/end of current selection
       
 15602             TTmDocPosSpec newPos;
       
 15603             aResponse = NavigateFromSelectionL( currentEditorSelection, naviEvent, newPos );
       
 15604             
       
 15605             // You will not understand the following lines, 
       
 15606             // for it is just a "hole stem" than normal logic.
       
 15607             //
       
 15608             // Let me explain: 
       
 15609             // In HWR, 4x12 keyboard is used, and predictive should be disabled for it.
       
 15610             // unfortunately, the existing codes enable predictive in some special case.
       
 15611             // when you switch from FSQ to HWR, with ITI on, you will get that.
       
 15612             // then if you select some words and press arrow key, 
       
 15613             // the if bratch of the code blow will be excuted.
       
 15614             // which is writen for FSQ, not HWR, 
       
 15615             // MoveCursorToEndOfWordL or MoveCursorToStartOfWordL is called unexpected
       
 15616             //
       
 15617             // It is not a complete fix, just for simplicity.
       
 15618             TBool isFingerHwr = ( iFepPluginManager != NULL ) && 
       
 15619 								( iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr );
       
 15620 
       
 15621             if ( aCode != EKeyBackspace && !isFingerHwr && WesternPredictive() )
       
 15622                 {
       
 15623                 if (CursorInsideWord())
       
 15624                     {
       
 15625                     TBool rightToleftParagraph = IsRightToLeftParagraph(newPos);
       
 15626                     if ( (rightToleftParagraph && naviEvent == ELeftNaviEvent) ||
       
 15627                          (!rightToleftParagraph && naviEvent == ERightNaviEvent) )
       
 15628                         {
       
 15629                         MoveCursorToEndOfWordL();
       
 15630                         }
       
 15631                     else
       
 15632                         {
       
 15633                         MoveCursorToStartOfWordL();
       
 15634                         }
       
 15635                     }
       
 15636 
       
 15637                 }
       
 15638             }
       
 15639         else if (!(EditorState()->Flags() & EAknEditorFlagNoLRNavigation))
       
 15640             {
       
 15641             if ((naviEvent != ENullNaviEvent) && HandleLoopingInNaviEventL(naviEvent))
       
 15642                 {
       
 15643                 aResponse=EKeyWasConsumed;
       
 15644                 }
       
 15645             else
       
 15646                 {
       
 15647                 if (iMode == ELatin)
       
 15648                     {
       
 15649                     // normal operation of Down/Up scroll keypress action.
       
 15650                     switch( aCode )
       
 15651                         {
       
 15652                         case EKeyUpArrow:
       
 15653                         case EKeyDownArrow:
       
 15654                             SimulateKeyEventL(EKeyF22);
       
 15655                             break;
       
 15656                         case EKeyRightArrow:
       
 15657                         case EKeyLeftArrow:
       
 15658                             {
       
 15659                             /*Hindi*/
       
 15660                             if( (TAknFepUiIndicInputManager :: IsIndicLangauge(
       
 15661                                       TLanguage(iLanguageCapabilities.iInputLanguageCode))) 
       
 15662                                  && IsZWSCharacterPresent() )
       
 15663                                 {
       
 15664                                 RemoveZWSCharacterL(EKeyLeftArrow); 
       
 15665                                 }
       
 15666                             }
       
 15667                             break;
       
 15668                         default: // nothing
       
 15669                             break;
       
 15670                         }
       
 15671                     }
       
 15672                 keyHandled = EFalse;
       
 15673                 }
       
 15674             }
       
 15675         }
       
 15676 
       
 15677     return keyHandled;
       
 15678     }
       
 15679 
       
 15680 /**
       
 15681 * Routine handled navigation and also backspace events at "beginning" of document
       
 15682 *
       
 15683 */
       
 15684 TBool CAknFepManager::HandleLoopingInNaviEventL(TWesternNaviEvent aNaviEvent)
       
 15685     {
       
 15686     TBool looping = EFalse;
       
 15687     TBool eventHandled = EFalse;
       
 15688     TTmDocPosSpec newCursorPos;
       
 15689 
       
 15690     // This routine may handle Left, Right and Backspace and nothing else
       
 15691     // Note that Up and Down cannot do any sort of document looping in FEP
       
 15692     if ( aNaviEvent != ELeftNaviEvent
       
 15693         && aNaviEvent != ERightNaviEvent
       
 15694         && aNaviEvent != EBackspaceEvent )
       
 15695         return eventHandled; // not consumed
       
 15696 
       
 15697     TTmDocPosSpec pos = DocPos();
       
 15698     TBool rightToLeftParagraph = IsRightToLeftParagraph(pos);
       
 15699 
       
 15700     TWesternNaviEvent incrementingNaviEvent = 
       
 15701                                           rightToLeftParagraph ? ELeftNaviEvent : ERightNaviEvent;
       
 15702     TWesternNaviEvent decrementingNaviEvent = 
       
 15703                                           rightToLeftParagraph ? ERightNaviEvent : ELeftNaviEvent;
       
 15704 
       
 15705     if (aNaviEvent == decrementingNaviEvent)
       
 15706         {
       
 15707         // Abandon early if we are not in the first line.
       
 15708         if ( InFirstLineAndFormatted( pos ) )
       
 15709             {
       
 15710             TTmDocPosSpec startPos;
       
 15711             GetVisualDocStart( startPos );
       
 15712              if( AtVisualStart( pos, startPos ) )
       
 15713                 {
       
 15714                 TTmDocPosSpec endPos;
       
 15715                 if ( !GetVisualDocEnd( endPos ) )
       
 15716                     {
       
 15717                     // End of document is not formatted. Value returned is just pos at DocLength.
       
 15718                     // So actually move the cursor there (this is guranteed to format the last line)
       
 15719                     // and the end End position is found a 2nd time.
       
 15720                     newCursorPos = endPos;
       
 15721                     SetCursorPositionL( newCursorPos );
       
 15722                     GetVisualDocEnd( endPos );
       
 15723                     }
       
 15724                 newCursorPos = endPos;
       
 15725                 looping = ETrue;
       
 15726                 }
       
 15727             }
       
 15728         }
       
 15729     else if (aNaviEvent == incrementingNaviEvent )
       
 15730         {
       
 15731         if ( InLastLineAndFormatted( pos ) )
       
 15732             {
       
 15733             TTmDocPosSpec endPos;
       
 15734             GetVisualDocEnd( endPos );
       
 15735             if( AtVisualEnd( pos, endPos, 
       
 15736                              iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep() ) )
       
 15737                 {
       
 15738                 TTmDocPosSpec startPos;
       
 15739                 if ( !GetVisualDocStart( startPos ) )
       
 15740                     {
       
 15741                     // Document was not formatted at docPos(0).  So actually move the cursor
       
 15742                     // to that line at least, and then ask for the start pos again.
       
 15743                     newCursorPos = startPos;
       
 15744                     SetCursorPositionL( newCursorPos );
       
 15745                     GetVisualDocStart( startPos );
       
 15746                     }
       
 15747                 newCursorPos = startPos;
       
 15748                 looping = ETrue;
       
 15749                 }
       
 15750             }
       
 15751         }
       
 15752     else if ( aNaviEvent == EBackspaceEvent )
       
 15753         {
       
 15754         // Deletion is always logical, so the condition is simply to test the logical pos.
       
 15755         if ( pos.iPos ==0 )
       
 15756             {
       
 15757             eventHandled = ETrue;
       
 15758             }
       
 15759         }
       
 15760 
       
 15761     if (looping)
       
 15762         {
       
 15763         // This takes language issues into account, adjusting the cursor position:
       
 15764         AdjustPosSpecForInputLanguageAfterDocumentLoop( newCursorPos, aNaviEvent, 
       
 15765                                                         (aNaviEvent == incrementingNaviEvent) );
       
 15766         SetCursorPositionL( newCursorPos );
       
 15767         eventHandled = ETrue;
       
 15768         }
       
 15769     return eventHandled;
       
 15770     }
       
 15771 
       
 15772 void CAknFepManager::TransferFepStateToEditorL( TBool aFnLockSync )
       
 15773     {
       
 15774     // If editor in Fnlock state, need to set actual input mode
       
 15775     // because, in case of qwerty keypad alphanumeric editor there is no numeric mode
       
 15776     // numeric mode handle as FnLock
       
 15777 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 15778 
       
 15779    if( aFnLockSync && iQwertyInputMode && iFnKeyManager && iFnKeyManager->FnKeyState()==CAknFepFnKeyManager::EFnKeyLock)
       
 15780         {
       
 15781         EditorState()->SetCurrentInputMode(EditorModeFromFepMode(ENumber));
       
 15782         // Indicator should not be reset, if menu is displaying from editor.
       
 15783         if(!IsFlagSet(EFlagForegroundUIComponentVisible | EFlagMenuPaneVisible))
       
 15784             iFnKeyManager->ClearFnKeyState(); 
       
 15785         }
       
 15786     else
       
 15787         {
       
 15788 #endif
       
 15789         EditorState()->SetCurrentInputMode(EditorModeFromFepMode(iMode));
       
 15790         
       
 15791 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
 15792         }
       
 15793    if(iFnKeyManager && iFnKeyManager->FnKeyState()!=CAknFepFnKeyManager::EFnKeyLock)
       
 15794        iFnKeyManager->ClearFnKeyState();       
       
 15795 
       
 15796 #endif
       
 15797 
       
 15798     
       
 15799     if ((iMode == ELatin && iWesternPredictive &&
       
 15800         IsFlagSet(EFlagInsideInlineEditingTransaction)) 
       
 15801 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 15802         ||(IsLanguageSupportPrediction() && IsFlagSet(EFlagInsideInlineEditingTransaction))
       
 15803 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 15804 		)
       
 15805         {
       
 15806         EditorState()->SetInlineEditSpan(iUncommittedText);
       
 15807 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 15808         if (IsFlagSet(CAknFepManager::EFlagNoMatches))
       
 15809 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 15810         TryRemoveNoMatchesIndicatorL();
       
 15811         UpdateCbaL(NULL);
       
 15812         }
       
 15813     else
       
 15814         {
       
 15815         EditorState()->SetInlineEditSpan(TCursorSelection(0,0));
       
 15816         }
       
 15817     EditorState()->SetCurrentCaseWithNoInitialisation(iCaseMan->CurrentCase());
       
 15818     if ( IsFlagSet( EFlagSupressAutoUpdate ) )
       
 15819         {
       
 15820         EditorState()->SetFlags( EditorState()->Flags() | EFlagSupressAutoUpdate );
       
 15821         }
       
 15822     else
       
 15823         {
       
 15824         EditorState()->SetFlags( EditorState()->Flags() & ~EFlagSupressAutoUpdate );
       
 15825         }
       
 15826     SetQwertyModeToInputcapbility();
       
 15827     }
       
 15828 
       
 15829 MAknFepManagerInterface* CAknFepManager::FepUI() const
       
 15830     {
       
 15831 #ifdef RD_SCALABLE_UI_V2
       
 15832     if ( iFepFullyConstructed && ( iFepPluginManager->PluginInputMode() != EPluginInputModeNone ) )
       
 15833         {
       
 15834         if (iFepPluginManager->PluginInputMode() == EPluginInputModeItut)
       
 15835             {
       
 15836             return iFepPluginManager->CurrentFepInputUI() ?
       
 15837                 iFepPluginManager->CurrentFepInputUI() : iCurrentFepUI;
       
 15838             }
       
 15839         if ( iFepPluginManager->EnableITIOnFSQ() )
       
 15840             {
       
 15841             return iCurrentFepUI;
       
 15842             }
       
 15843         return iFepPluginManager->CurrentPluginInputFepUI();
       
 15844         }
       
 15845 #endif        
       
 15846     return iCurrentFepUI;
       
 15847     }
       
 15848 
       
 15849 void CAknFepManager::LaunchLanguagesPopupListL(TBool aLaunchedByTouchWin)
       
 15850     {
       
 15851 #ifdef RD_SCALABLE_UI_V2
       
 15852     if( iFepPluginManager->PluginInputMode() != EPluginInputModeNone &&
       
 15853         iFepPluginManager->PluginInputMode() != EPluginInputModeItut
       
 15854         // Add this condition for correction of dim features on FSQ
       
 15855         && iFepPluginManager->PluginInputMode() != EPluginInputModeFSQ
       
 15856         && iFepPluginManager->PluginInputMode() != EPluginInputModePortraitFSQ )
       
 15857         {
       
 15858         iFepPluginManager->LaunchPenInputLanguageSelectionL(aLaunchedByTouchWin);
       
 15859         return;
       
 15860         }
       
 15861 #endif //RD_SCALABLE_UI_V2
       
 15862        
       
 15863     CArrayFixFlat<TInt>* languages = 
       
 15864         new( ELeave )CArrayFixFlat<TInt>( ELanguageArrayGranularity );
       
 15865     CleanupStack::PushL( languages );
       
 15866     iPtiEngine->GetAvailableLanguagesL( languages );
       
 15867 
       
 15868     // Create a list of languages for the dialog
       
 15869     CDesCArrayFlat* languagesList = 
       
 15870         new( ELeave )CDesCArrayFlat( ELanguageArrayGranularity );
       
 15871     CleanupStack::PushL( languagesList );
       
 15872 
       
 15873     // Item format should be "<icon_index>\t<item_text>"
       
 15874     _LIT( KIconIndexSelected,    "0\t" );
       
 15875     _LIT( KIconIndexNotSelected, "\t" );// No icon
       
 15876     
       
 15877     MPtiLanguage* lang = NULL;
       
 15878     TInt  currentLanguage = iSharedDataInterface->InputTextLanguage();
       
 15879     TInt selectedLanguageIndex = 0;
       
 15880     
       
 15881     for (TInt ii=0; ii < languages->Count(); ii++)
       
 15882         {
       
 15883         lang = iPtiEngine->GetLanguage( ( *languages )[ii] );
       
 15884         if (!lang)
       
 15885             {
       
 15886             User::Leave( KErrCorrupt );
       
 15887             }
       
 15888         // Buffer should contain both tabulator string and localized name:
       
 15889         HBufC* langStrBuf = HBufC::NewL( lang->LocalizedName().Length() + 3 );
       
 15890         CleanupStack::PushL( langStrBuf );
       
 15891         
       
 15892         TPtr langStrPtr = langStrBuf->Des();
       
 15893 
       
 15894         // If language is current language - use selected icon in lbx:
       
 15895         if( lang->LanguageCode() == currentLanguage )
       
 15896             {
       
 15897             langStrPtr.Append( KIconIndexSelected );
       
 15898             selectedLanguageIndex = ii;
       
 15899             }
       
 15900         else
       
 15901             {
       
 15902             langStrPtr.Append( KIconIndexNotSelected );    
       
 15903             }
       
 15904         langStrPtr.Append( lang->LocalizedName() );
       
 15905         languagesList->AppendL( langStrPtr );
       
 15906         CleanupStack::PopAndDestroy( langStrBuf );
       
 15907         }
       
 15908 
       
 15909     // Add icons to the listbox:
       
 15910     CArrayPtr<CGulIcon>* icons = new( ELeave ) CArrayPtrFlat<CGulIcon>(10);
       
 15911     CleanupStack::PushL( icons );
       
 15912     LoadIconL( icons, EMbmAvkonQgn_prop_sub_current, 
       
 15913                EMbmAvkonQgn_prop_sub_current_mask );
       
 15914 
       
 15915     TInt index = 0;
       
 15916     SetFlag( EFlagForegroundUIComponentVisible );
       
 15917     CleanupStack::Pop( icons );	// iUiInterface->LaunchListPopupL takes ownership immediately
       
 15918 #ifdef RD_SCALABLE_UI_V2 
       
 15919     if( iFepFullyConstructed && iFepPluginManager && !iFepPluginManager->IsInMenuOpen() )
       
 15920             {
       
 15921             iFepPluginManager->SetMenuState();            
       
 15922             }
       
 15923 #endif              
       
 15924     // Fire up the dialog
       
 15925 #ifdef RD_SCALABLE_UI_V2
       
 15926     iCancelPopupInQwerty = aLaunchedByTouchWin;
       
 15927 #endif //RD_SCALABLE_UI_V2
       
 15928     TUid fepUid = CCoeEnv::Static()->FepUid();
       
 15929     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
 15930 	SendEventsToPluginManL(EPluginEnablePriorityChangeOnOriChange,EFalse);
       
 15931     TInt returnValue = iUiInterface->LaunchListPopupL(R_AVKON_T9_LANGUAGES_QUERY, index, 
       
 15932                                                       selectedLanguageIndex, languagesList, icons);
       
 15933 #ifdef RD_SCALABLE_UI_V2
       
 15934     iCancelPopupInQwerty = EFalse;
       
 15935 #endif //RD_SCALABLE_UI_V2    
       
 15936     PrepareFepAfterDialogExitL(fepUid);
       
 15937     CleanupStack::PopAndDestroy( languagesList );
       
 15938 
       
 15939     if(returnValue == EAknSoftkeyOk)
       
 15940         {
       
 15941         // Selected item index from the languages array
       
 15942         HandleChangeInFocusL();
       
 15943 
       
 15944         // The user has changed language and the local language is not used any more.
       
 15945         iLanguageCapabilities.iLocalInputLanguageInUse = EFalse;
       
 15946         if (EditorState())
       
 15947             {
       
 15948             EditorState()->SetLocalLanguage( ELangTest );
       
 15949             }
       
 15950 
       
 15951         TBool westernPredictiveInUse = WesternPredictive();
       
 15952 
       
 15953 // Truncate autocompletion portion on change of writing language
       
 15954 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 15955 		RemoveSuggestedAdvanceCompletionL();
       
 15956 #endif // RD_INTELLIGENT_TEXT_INPUT   
       
 15957         //Hindi Change Bug Fix
       
 15958         iSharedDataInterface->SetInputTextLanguage(languages->At(index));
       
 15959         CAknEnv::Static()->SettingCache().Update(KEikInputLanguageChange);
       
 15960         SetActiveInputLanguage( languages->At(index) );
       
 15961         ChangeInputLanguageL(languages->At(index));           
       
 15962         SetFlag( EFlagNewSharedDataInputLanguage | EFlagNewSharedDataInputMode );
       
 15963 	  	// This pice of code TSW Fute error fixing.
       
 15964         // Display the confirmation msg if the dictionary is not available for
       
 15965         // Current language.
       
 15966 #ifdef RD_INTELLIGENT_TEXT_INPUT         
       
 15967         // Display the confirmation msg only for Western languages
       
 15968         if (!IsChineseInputLanguage())
       
 15969         	{
       
 15970 	        if (!IsLanguageSupportPrediction())
       
 15971 	        	{
       
 15972 	        	LaunchConfirmationNoteL(R_AVKON_T9_NOTE_NO_AVAILABLE);
       
 15973 	        	}     
       
 15974         	}
       
 15975 #endif
       
 15976         
       
 15977           
       
 15978         }
       
 15979 	SendEventsToPluginManL(EPluginEnablePriorityChangeOnOriChange,ETrue);	
       
 15980     CleanupStack::PopAndDestroy( languages );
       
 15981     }
       
 15982 
       
 15983 void CAknFepManager::LaunchRecognitionWithDictionaryPopupListL()
       
 15984     {
       
 15985 #ifdef RD_SCALABLE_UI_V2
       
 15986     if( iFepPluginManager && (iFepPluginManager->PluginInputMode() == EPluginInputModeHwr) )
       
 15987         {
       
 15988         iFepPluginManager->LaunchPenInputRecognitionWithDictionarySelectionL();
       
 15989         return;
       
 15990         }
       
 15991 #endif //RD_SCALABLE_UI_V2
       
 15992     }
       
 15993 void CAknFepManager::LaunchWritingSpeedPopupListL()
       
 15994     {
       
 15995 #ifdef RD_SCALABLE_UI_V2
       
 15996     if( iFepPluginManager && (iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr) )
       
 15997         {
       
 15998         iFepPluginManager->LaunchPenInputWritingSpeedSelectionL();
       
 15999         return;
       
 16000         }
       
 16001 #endif //RD_SCALABLE_UI_V2
       
 16002     }
       
 16003 void CAknFepManager::LaunchGuidingLinePopupListL()
       
 16004     {
       
 16005 #ifdef RD_SCALABLE_UI_V2
       
 16006     if( iFepPluginManager && (iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr) )
       
 16007         {
       
 16008         iFepPluginManager->LaunchPenInputGuidingLineSelectionL();
       
 16009         return;
       
 16010         }
       
 16011 #endif //RD_SCALABLE_UI_V2
       
 16012     }
       
 16013 void CAknFepManager::LoadIconL( CArrayPtr<CGulIcon>* aIcons, 
       
 16014                                 TInt aBitmapId, 
       
 16015                                 TInt aMaskId )
       
 16016     {
       
 16017     CGulIcon* icon = CGulIcon::NewLC();
       
 16018     CFbsBitmap* bitmap = 0;
       
 16019     CFbsBitmap* mask = 0;
       
 16020     AknIconUtils::CreateIconL(  bitmap, mask, KAvkonBitmapFile, aBitmapId, aMaskId );
       
 16021     icon->SetBitmap( bitmap );
       
 16022     icon->SetMask( mask );
       
 16023     aIcons->AppendL( icon );
       
 16024     CleanupStack::Pop( icon );
       
 16025     }
       
 16026 
       
 16027 
       
 16028 TBool CAknFepManager::IsInputModeAvailable(TInt aMode) const
       
 16029     {
       
 16030     TBool isAvailable = ETrue;
       
 16031     const TInt inputLanguage = iLanguageCapabilities.iInputLanguageCode;
       
 16032     switch (aMode)
       
 16033         {
       
 16034         case ELatin:
       
 16035             isAvailable = !( ( inputLanguage == ELangPrcChinese ) &&
       
 16036                 (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes));
       
 16037             break;
       
 16038         case EPinyin:
       
 16039             isAvailable = ( inputLanguage == ELangPrcChinese );
       
 16040             break;
       
 16041         case EStroke:
       
 16042             isAvailable = ( inputLanguage == ELangPrcChinese || 
       
 16043                 inputLanguage == ELangHongKongChinese || 
       
 16044                 inputLanguage == ELangTaiwanChinese);
       
 16045             break;
       
 16046         case ECangJie:
       
 16047             {
       
 16048             isAvailable = ( ( inputLanguage == ELangHongKongChinese ) &&
       
 16049                           iQwertyInputMode );
       
 16050 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 16051 #ifdef __HALF_QWERTY_KEYPAD            
       
 16052             isAvailable = isAvailable && (EPtiKeyboardHalfQwerty != KeyboardLayout()); 
       
 16053 #endif //__HALF_QWERTY_KEYPAD
       
 16054 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 16055             }
       
 16056             
       
 16057             break;
       
 16058         case EZhuyin:
       
 16059             isAvailable = ( inputLanguage == ELangTaiwanChinese );
       
 16060             break;
       
 16061         case EPRCFind:
       
 16062             isAvailable = ( ( inputLanguage == ELangPrcChinese ) &&
       
 16063                 (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes));
       
 16064             break;
       
 16065         case EZhuyinFind:
       
 16066             isAvailable = ( ( inputLanguage == ELangTaiwanChinese ) &&
       
 16067                 (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes));
       
 16068             break;
       
 16069         case EStrokeFind:
       
 16070             isAvailable = ( ( inputLanguage == ELangHongKongChinese ) &&
       
 16071                 (iAknEditorFlags & EAknEditorFlagForceTransparentFepModes));
       
 16072             break;
       
 16073         case EHiraganaKanji:
       
 16074             isAvailable = (inputLanguage == ELangJapanese);
       
 16075             break;
       
 16076         case EKatakana:
       
 16077             isAvailable = (inputLanguage == ELangJapanese );
       
 16078             break;
       
 16079         case EHindi:
       
 16080             isAvailable = (inputLanguage == ELangHindi );
       
 16081             break;
       
 16082         case EHangul:
       
 16083             isAvailable = (inputLanguage == ELangKorean );
       
 16084             break;
       
 16085         case ENativeNumber:
       
 16086             isAvailable = (inputLanguage == ELangHindi 
       
 16087                 || inputLanguage == ELangArabic 
       
 16088                 || inputLanguage == ELangUrdu
       
 16089                 || inputLanguage == ELangFarsi/*
       
 16090                 || ( inputLanguage == ELangThai && iFepPluginManager && 
       
 16091                      iFepPluginManager->PluginInputMode() != EPluginInputModeItut &&
       
 16092                      iFepPluginManager->PluginInputMode() != EPluginInputModeNone)*/ );
       
 16093         default:
       
 16094             break;
       
 16095         }
       
 16096     return isAvailable;
       
 16097     }
       
 16098 
       
 16099 TInt CAknFepManager::NewInputModeAfterLanguageChange() const
       
 16100     {
       
 16101     TInt inputMode = 0;
       
 16102     switch (iLanguageCapabilities.iInputLanguageCode)
       
 16103         {
       
 16104         case ELangPrcChinese:
       
 16105             if ( iAknEditorFlags & EAknEditorFlagForceTransparentFepModes )
       
 16106                 {
       
 16107                 inputMode = ELatin; // EPRCFind from hashkey loop
       
 16108                 }
       
 16109             else
       
 16110                 {
       
 16111                 inputMode = EPinyin;
       
 16112                 }
       
 16113             break;
       
 16114         case ELangHongKongChinese:
       
 16115             if ( iAknEditorFlags & EAknEditorFlagForceTransparentFepModes )
       
 16116                 {
       
 16117                 inputMode = EStrokeFind;
       
 16118                 }
       
 16119             else
       
 16120                 {
       
 16121                 TInt sharedDataMode = iSharedDataInterface->InputMode();
       
 16122 	            if (iQwertyInputMode && 
       
 16123 	            	sharedDataMode == ECangJie)
       
 16124 	            	{
       
 16125 	            	inputMode = ECangJie;
       
 16126 	            	}
       
 16127 	            else
       
 16128 	            	{
       
 16129 	            	inputMode = EStroke;
       
 16130 	            	}
       
 16131                 }
       
 16132             break;
       
 16133         case ELangTaiwanChinese:
       
 16134             if ( iAknEditorFlags & EAknEditorFlagForceTransparentFepModes )
       
 16135                 {
       
 16136                 inputMode = EZhuyinFind;
       
 16137                 }
       
 16138             else
       
 16139                 {
       
 16140                 inputMode = EZhuyin;
       
 16141                 }
       
 16142             break;
       
 16143         case ELangJapanese:
       
 16144             inputMode = EHiraganaKanji;
       
 16145             break;
       
 16146         case ELangKorean:
       
 16147             inputMode = EHangul;
       
 16148             break;
       
 16149         default:
       
 16150             inputMode = ELatin;
       
 16151             break;
       
 16152         }
       
 16153     return inputMode;
       
 16154     }
       
 16155 
       
 16156 void CAknFepManager::SetInputLanguageCapabilities(const TInt aInputLanguage)
       
 16157     {
       
 16158     iLanguageCapabilities.iInputLanguageCode = aInputLanguage;
       
 16159 
       
 16160     if ( aInputLanguage == ELangArabic || aInputLanguage == ELangHebrew || 
       
 16161          aInputLanguage == ELangFarsi  || aInputLanguage == ELangUrdu )
       
 16162         {
       
 16163         iLanguageCapabilities.iSupportsCase = EFalse;
       
 16164         iLanguageCapabilities.iRightToLeftLanguage = ETrue;
       
 16165         SetCursorTypeForInputDirection(EFalse);
       
 16166         }
       
 16167     else
       
 16168         {
       
 16169         /*Hindi*/
       
 16170         if ( aInputLanguage == ELangThai 
       
 16171         || (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(aInputLanguage)))
       
 16172         ) 
       
 16173             {
       
 16174             iLanguageCapabilities.iSupportsCase = EFalse;
       
 16175             }
       
 16176         else
       
 16177             {
       
 16178             iLanguageCapabilities.iSupportsCase = ETrue;
       
 16179             }
       
 16180         iLanguageCapabilities.iRightToLeftLanguage = EFalse;
       
 16181         SetCursorTypeForInputDirection(ETrue);
       
 16182         }
       
 16183 
       
 16184     TLanguage uiLanguage = User::Language();
       
 16185     iLanguageCapabilities.iArabicIndicDigitsAllowed = 
       
 16186              ( aInputLanguage == ELangArabic || uiLanguage == ELangArabic);
       
 16187     iLanguageCapabilities.iEasternArabicIndicDigitsAllowed = ( 
       
 16188         ( aInputLanguage == ELangUrdu || uiLanguage == ELangUrdu ) ||
       
 16189         ( aInputLanguage == ELangFarsi|| uiLanguage == ELangFarsi ) );
       
 16190     /*Hindi*/
       
 16191     iLanguageCapabilities.iIndicDigitsAllowed =  
       
 16192              ( (TAknFepUiIndicInputManager :: IsIndicDigitsSupported(TLanguage(aInputLanguage))) );
       
 16193     UpdateLocalDigitMode();
       
 16194 
       
 16195     MAknFepManagerInterface* fepUI = iLangMan->GetFepUI(ELatin, iCharWidth, ETrue);
       
 16196     MPtiLanguage* ptiLanguage = iPtiEngine->GetLanguage(fepUI->SupportLanguage(ELatin));
       
 16197     if (ptiLanguage) // can be NULL in some uncommon situations
       
 16198         {
       
 16199         iLanguageCapabilities.iSupportsWesternPredictive = 
       
 16200                                            ptiLanguage->HasInputMode(EPtiEnginePredictive);
       
 16201         // tp teleca change Korean lang does not support predictive
       
 16202         // and we want to disable predictive even with local editors
       
 16203         if(/*IsKoreanInputLanguage()*/GetInputLanguageFromSharedDataInterface() == ELangKorean )
       
 16204             {
       
 16205             iLanguageCapabilities.iSupportsWesternPredictive = EFalse;
       
 16206             }
       
 16207         
       
 16208         
       
 16209         // tp teleca change end
       
 16210 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 16211         // Predictive QWERTY (XT9) changes ---->
       
 16212         iLanguageCapabilities.iSupportsWesternQwertyPredictive = 
       
 16213                                            ptiLanguage->HasInputMode(EPtiEngineQwertyPredictive );
       
 16214         if ( GetInputLanguageFromSharedDataInterface() == ELangKorean )
       
 16215             {
       
 16216             iLanguageCapabilities.iSupportsWesternQwertyPredictive = EFalse;            
       
 16217             }
       
 16218         
       
 16219         // Predictive QWERTY (XT9) changes <----
       
 16220 #ifdef __HALF_QWERTY_KEYPAD
       
 16221 		iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive = ptiLanguage->HasInputMode(EPtiEngineHalfQwertyPredictive );
       
 16222 #endif         
       
 16223 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 16224         }
       
 16225 
       
 16226     if (!iLanguageCapabilities.iSupportsWesternPredictive 
       
 16227 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 16228         && !iLanguageCapabilities.iSupportsWesternQwertyPredictive 
       
 16229         // Predictive QWERTY changes
       
 16230 #ifdef __HALF_QWERTY_KEYPAD
       
 16231 		&& !iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive 
       
 16232 #endif //__HALF_QWERTY_KEYPAD        
       
 16233 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 16234         ) // Predictive QWERTY changes
       
 16235         {
       
 16236         SetWesternPredictive(EFalse);
       
 16237         }
       
 16238     }
       
 16239 
       
 16240 TInt CAknFepManager::SubstituteSublanguageId(const TInt aUiLanguage) const
       
 16241     {
       
 16242     return DefaultInputLanguageFromUILanguage(aUiLanguage);
       
 16243     }
       
 16244 
       
 16245 TTmDocPosSpec CAknFepManager::DocPos()
       
 16246     {
       
 16247     TTmDocPosSpec docPos = TTmDocPosSpec();
       
 16248     TTmDocPos rawDocPos;
       
 16249     TBool gotPos = EFalse;
       
 16250     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16251     if (docNavi)
       
 16252     	{
       
 16253         docNavi->GetDocPos(rawDocPos);
       
 16254         gotPos = ETrue;
       
 16255     	}
       
 16256     else
       
 16257     	{
       
 16258         // Use Edwin (FepAwareTextEditor() ) to get the position of document
       
 16259         if ( FepAwareTextEditor() )
       
 16260             {
       
 16261             TCursorSelection cursorSel( 0, 0 );
       
 16262             // Get the postion of document
       
 16263             FepAwareTextEditor()->GetCursorSelectionForFep( cursorSel );
       
 16264 
       
 16265             // Set the leading edge of the document.
       
 16266             rawDocPos.iPos = cursorSel.iCursorPos;
       
 16267             CAknEdwinState* state( EditorState() );
       
 16268             rawDocPos.iLeadingEdge = ( state && 
       
 16269                 state->Flags() & EAknEditorFlagCursorLedingEdge );                
       
 16270             gotPos = ETrue;
       
 16271             }
       
 16272     	}
       
 16273     if (gotPos)
       
 16274     	{
       
 16275         docPos.iPos = rawDocPos.iPos;
       
 16276         TTmDocPosSpec::TType docPosType = 
       
 16277                       rawDocPos.iLeadingEdge ? TTmDocPosSpec::ELeading : TTmDocPosSpec::ETrailing;
       
 16278         docPos.iType = docPosType;
       
 16279         }
       
 16280     return docPos;
       
 16281     }
       
 16282 
       
 16283 /**
       
 16284 * This method needs EditorState() to exist
       
 16285 *
       
 16286 */
       
 16287 CTextView* CAknFepManager::TextView() const
       
 16288     {
       
 16289     if (EditorState())
       
 16290         {
       
 16291         CAknEdwinFormAccessor* formAccessor = EditorState()->FormAccessor();
       
 16292         if (formAccessor)
       
 16293             {
       
 16294             return formAccessor->GetTextView();
       
 16295             }
       
 16296         }
       
 16297     return NULL;
       
 16298     }
       
 16299 
       
 16300 CTextLayout* CAknFepManager::TextLayout() const
       
 16301     {
       
 16302     if( EditorState() )
       
 16303         {
       
 16304         CAknEdwinFormAccessor* formAccessor = EditorState()->FormAccessor();
       
 16305         if (formAccessor)
       
 16306             {
       
 16307             return formAccessor->GetTextLayout();
       
 16308             }
       
 16309         }
       
 16310     return NULL;
       
 16311     }
       
 16312     
       
 16313 CPlainText* CAknFepManager::PlainText() const
       
 16314     {
       
 16315     return iUiInterface->PlainText(EditorState());
       
 16316     }
       
 16317 
       
 16318 /**
       
 16319 * Checks if the paragraph containing aPos is Right to left.
       
 16320 * This routine will return nonsense if
       
 16321 *   - TextLayout() does not return a pointer
       
 16322 *   - the position passed is not in the formatted region
       
 16323 *
       
 16324 * Note, the return value from FindDocPos is thrown away
       
 16325 */
       
 16326 TBool CAknFepManager::IsRightToLeftParagraph(TTmDocPosSpec aPos) const
       
 16327     {
       
 16328     TTmPosInfo2 posInfo;
       
 16329     TTmLineInfo lineInfo;
       
 16330     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16331     if (docNavi)
       
 16332     	{
       
 16333     	docNavi->FindDocPos(aPos, posInfo, lineInfo);
       
 16334     	}
       
 16335 	else
       
 16336 		{
       
 16337 	    CTextLayout* textLayout = TextLayout();
       
 16338 	    if (textLayout)
       
 16339 	        {
       
 16340 	        textLayout->TagmaTextLayout().FindDocPos(aPos, posInfo, lineInfo);
       
 16341 	        }
       
 16342 		}
       
 16343 		
       
 16344     return lineInfo.iFlags & TTmLineInfo::EParRightToLeft;
       
 16345     }
       
 16346 
       
 16347 
       
 16348 void CAknFepManager::FindAdjacentChunks(const TTmDocPosSpec& aPos,
       
 16349                                         CTmTextLayout::TTmChunkDescription& aLeft, 
       
 16350                                         CTmTextLayout::TTmChunkDescription& aRight) const
       
 16351     {
       
 16352     aLeft.iStart = -1;
       
 16353     aLeft.iEnd = -1;
       
 16354     aLeft.iRightToLeft = EFalse;
       
 16355     aRight.iStart = -1;
       
 16356     aRight.iEnd = -1;
       
 16357     aRight.iRightToLeft = EFalse;
       
 16358 
       
 16359     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16360     if (docNavi)
       
 16361     	{
       
 16362     	docNavi->FindAdjacentChunks(aPos, aLeft, aRight);
       
 16363     	}
       
 16364     else
       
 16365     	{
       
 16366     CTextLayout* textLayout = TextLayout();
       
 16367     if (textLayout)
       
 16368         {
       
 16369         textLayout->TagmaTextLayout().FindAdjacentChunks(aPos, aLeft, aRight);
       
 16370         }
       
 16371     	}
       
 16372     }
       
 16373 
       
 16374 
       
 16375 TBool CAknFepManager::GetNextVisualRightCharacter( TInt& aPosition )
       
 16376     {
       
 16377     TTmDocPosSpec pos = DocPos();
       
 16378     TTmPosInfo2 info;
       
 16379     TBool nextPositionFound = EFalse;
       
 16380     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16381     if (docNavi)
       
 16382     	{
       
 16383     	nextPositionFound = docNavi->GetNextVisualCursorPos(pos, info, EFalse);
       
 16384     	}
       
 16385     else
       
 16386     	{
       
 16387 	    CTextLayout* textLayout = TextLayout();
       
 16388 	    if (textLayout)
       
 16389 	        {
       
 16390 	        nextPositionFound = textLayout->TagmaTextLayout().GetNextVisualCursorPos(pos, 
       
 16391                                                                                    info, 
       
 16392                                                                                    EFalse);
       
 16393 	        }
       
 16394         }
       
 16395     if (nextPositionFound)
       
 16396         {
       
 16397         aPosition = info.iDocPos.iPos;
       
 16398 
       
 16399         CTmTextLayout::TTmChunkDescription leftChunk;
       
 16400         CTmTextLayout::TTmChunkDescription rightChunk;
       
 16401         FindAdjacentChunks(pos, leftChunk, rightChunk);
       
 16402 
       
 16403         if ( !rightChunk.iRightToLeft )
       
 16404             {
       
 16405             aPosition -= 1;
       
 16406             }
       
 16407         }
       
 16408     return nextPositionFound;
       
 16409     }
       
 16410 
       
 16411 TBool CAknFepManager::GetNextVisualLeftCharacter( TInt& aPosition )
       
 16412     {
       
 16413     TTmDocPosSpec pos = DocPos();
       
 16414     TTmPosInfo2 info;
       
 16415     TBool nextPositionFound = EFalse;
       
 16416     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16417     if (docNavi)
       
 16418     	{
       
 16419     	nextPositionFound = docNavi->GetNextVisualCursorPos(pos, info, ETrue);
       
 16420     	}
       
 16421     else
       
 16422     	{
       
 16423 	    CTextLayout* textLayout = TextLayout();
       
 16424 	    if (textLayout)
       
 16425 	        {
       
 16426 	        nextPositionFound = TextLayout()->TagmaTextLayout().GetNextVisualCursorPos(pos, 
       
 16427                                                                                      info, 
       
 16428                                                                                      ETrue);
       
 16429 	        }
       
 16430         }
       
 16431     if (nextPositionFound)
       
 16432         {
       
 16433         aPosition = info.iDocPos.iPos;
       
 16434         CTmTextLayout::TTmChunkDescription leftChunk;
       
 16435         CTmTextLayout::TTmChunkDescription rightChunk;
       
 16436         FindAdjacentChunks(pos, leftChunk, rightChunk);
       
 16437 
       
 16438         if ( leftChunk.iRightToLeft )
       
 16439             {
       
 16440             aPosition -= 1;
       
 16441             }
       
 16442         if (iLanguageCapabilities.iInputLanguageCode == ELangVietnamese)
       
 16443             {
       
 16444             aPosition = pos.iPos -1;
       
 16445             }
       
 16446         }
       
 16447     return nextPositionFound;
       
 16448     }
       
 16449 
       
 16450 void CAknFepManager::FindVisualRightOfWord(TInt& aPosition)
       
 16451     {
       
 16452     TTmDocPosSpec pos = DocPos();
       
 16453     CTmTextLayout::TTmChunkDescription leftChunk;
       
 16454     CTmTextLayout::TTmChunkDescription rightChunk;
       
 16455     FindAdjacentChunks(pos, leftChunk, rightChunk);
       
 16456 
       
 16457     if ( rightChunk.iRightToLeft )
       
 16458         {
       
 16459         FindStartOfWord(aPosition);
       
 16460         }
       
 16461     else
       
 16462         {
       
 16463         FindEndOfWord(aPosition);
       
 16464         }
       
 16465     }
       
 16466 
       
 16467 void CAknFepManager::FindVisualLeftOfWord(TInt& aPosition)
       
 16468     {
       
 16469     TTmDocPosSpec pos = DocPos();
       
 16470     CTmTextLayout::TTmChunkDescription leftChunk;
       
 16471     CTmTextLayout::TTmChunkDescription rightChunk;
       
 16472     FindAdjacentChunks(pos, leftChunk, rightChunk);
       
 16473 
       
 16474     if ( leftChunk.iRightToLeft)
       
 16475         {
       
 16476         FindEndOfWord(aPosition);
       
 16477         }
       
 16478     else
       
 16479         {
       
 16480         FindStartOfWord(aPosition);
       
 16481         }
       
 16482     }
       
 16483 
       
 16484 
       
 16485 
       
 16486 TBool CAknFepManager::GetVisualDocStart( TTmDocPosSpec& aPos) const
       
 16487     {
       
 16488     // Set up the initial try as leading to the first logical character
       
 16489     // It is a requirement that this position is at least in the first line
       
 16490     TTmDocPosSpec pos(0, TTmDocPosSpec::ELeading);
       
 16491 
       
 16492     // Need to record if we are in aleft to right paragraph or not
       
 16493     TBool leftToRightParagraph = !IsRightToLeftParagraph(pos);
       
 16494 
       
 16495     TBool success(EFalse);
       
 16496     CTextLayout* textLayout = TextLayout();
       
 16497     TTmDocPosSpec docPos;
       
 16498     if (AknFepDocumentNavigation() || textLayout)
       
 16499         {
       
 16500 //      This was written because Tagma's LineExtreme() method did not seem to work
       
 16501         success = GetAknFepLineExtreme( pos, !leftToRightParagraph, docPos );
       
 16502         }
       
 16503 
       
 16504     if (success)
       
 16505         aPos = docPos;
       
 16506     else // Possible cleanup; action for when there is insufficient information
       
 16507         {
       
 16508         aPos.iPos = 0;
       
 16509         aPos.iType = TTmDocPosSpec::ELeading;
       
 16510         }
       
 16511 
       
 16512     return success;
       
 16513     }
       
 16514 
       
 16515 TBool CAknFepManager::GetVisualDocEnd( TTmDocPosSpec& aPos) const
       
 16516     {
       
 16517     // Set EAknEditorFlagNeedWholeTextData to Editor State
       
 16518     // EAknEditorFlagNeedWholeTextData means needing to get whole document data to editor
       
 16519     UpdateEditorStateFlags( EAknEditorFlagNeedWholeTextData );
       
 16520 
       
 16521     TInt docLength = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 16522 
       
 16523     // Set up the initial try as trailing after the last logical character
       
 16524     // It is a requirement that this position is at least in the last line
       
 16525     TTmDocPosSpec pos(docLength, TTmDocPosSpec::ETrailing);
       
 16526 
       
 16527     // Need to record if we are in a left to right paragraph or not
       
 16528     TBool leftToRightParagraph = !IsRightToLeftParagraph(pos);
       
 16529 
       
 16530     TBool success(EFalse);
       
 16531     CTextLayout* textLayout = TextLayout();
       
 16532     TTmDocPosSpec docPos;
       
 16533     if (AknFepDocumentNavigation() || textLayout)
       
 16534         {
       
 16535         // This was written because Tagma's LineExtreme() method did not seem to work
       
 16536         success = GetAknFepLineExtreme( pos, leftToRightParagraph, docPos );
       
 16537         }
       
 16538 
       
 16539     if (success)
       
 16540         aPos = docPos;
       
 16541     else // Possible cleanup; action for when there is insufficient information
       
 16542         {
       
 16543         aPos.iPos = docLength;
       
 16544         aPos.iType = TTmDocPosSpec::ETrailing;
       
 16545         }
       
 16546         
       
 16547     // Remove EAknEditorFlagNeedWholeTextData fromEditor State
       
 16548     UpdateEditorStateFlags( EAknEditorFlagNeedWholeTextData, EFalse );
       
 16549     return success;
       
 16550     }
       
 16551 
       
 16552 
       
 16553 TBool CAknFepManager::GetAknFepLineExtreme( const TTmDocPosSpec& aPos, TBool aToRight,
       
 16554         TTmDocPosSpec& aExtreme) const
       
 16555     {
       
 16556     TBool success(EFalse);
       
 16557 
       
 16558     TTmPosInfo2 posInfo;
       
 16559     TTmLineInfo lineInfo;
       
 16560     TBool found = EFalse;
       
 16561     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16562     if (docNavi)
       
 16563     	{
       
 16564     	found = docNavi->FindDocPos(aPos, posInfo, lineInfo);
       
 16565     	}
       
 16566     else
       
 16567     	{
       
 16568 	    CTextLayout* textLayout = TextLayout();
       
 16569 	    if ( textLayout )
       
 16570 	        {
       
 16571 	        found = textLayout->TagmaTextLayout().FindDocPos(aPos, posInfo, lineInfo);
       
 16572 	        }
       
 16573     	}
       
 16574 
       
 16575     if ( found )
       
 16576         {
       
 16577         // Make a selection of the line info.  Cursor first, Anchar 2nd:
       
 16578         TCursorSelection theWholeLine( lineInfo.iEnd-1, lineInfo.iStart );
       
 16579 
       
 16580         TWesternNaviEvent event;
       
 16581         if ( aToRight )
       
 16582             event = ERightNaviEvent;
       
 16583         else
       
 16584             event = ELeftNaviEvent;
       
 16585 
       
 16586         GetAvkonDefinedVisualLimitsOfSelection( theWholeLine, event, aExtreme, NULL );
       
 16587         success = ETrue;
       
 16588         }
       
 16589 
       
 16590     return success;
       
 16591     }
       
 16592 
       
 16593 
       
 16594 /**
       
 16595 * This routine analyses a selection (Does not have to be a real selection, but the datastructure
       
 16596 * is used as input) to find its visual start or end, according to the passed parameter
       
 16597 * The algo used is:
       
 16598 * - First find the top line of the selection.
       
 16599 * - Then find the bottom line of the selection.
       
 16600 * - Look at the two lines' directionality (from the paragraph they belong to) and decide what the overall
       
 16601 * directionality of the selection is.  Thus right/left can be translated to increment/decrement.
       
 16602 * (Note that Up is always decrement; down is always increment). So that allows the key actions to be
       
 16603 * correctly grouped, and allows it to be determined which keys act from the top or the bottom line
       
 16604 * (Decrement always acts from the top line; Increment always acts from the bottom line)
       
 16605 *
       
 16606 * - When the keys are handled, the action is again translated back to right/left according to the key-
       
 16607 * grouping and whether you are acting from the top line or from the bottom line.  Eg, decrement in RTL
       
 16608 * line is visually to the Right.
       
 16609 * - the appropriate "ExtremePos" API is called passing in the position on the line in which we are acting
       
 16610 *
       
 16611 */
       
 16612 void CAknFepManager::GetAvkonDefinedVisualLimitsOfSelection(
       
 16613     const TCursorSelection& aSelection,
       
 16614     TWesternNaviEvent aEvent,
       
 16615     TTmDocPosSpec& aLimitPos,
       
 16616     TWesternNaviEvent* aEffectiveRightOrLeftEvent ) const
       
 16617     {
       
 16618     // in case an irrelvant event is sent, initialize aLimitPos to something safe
       
 16619     aLimitPos.iPos = 0;
       
 16620     aLimitPos.iType = TTmDocPosSpec::ELeading;
       
 16621 
       
 16622     TTmDocPosSpec lowLogicalPos( aSelection.LowerPos(), TTmDocPosSpec::ELeading );
       
 16623     TTmDocPosSpec highLogicalPos( aSelection.HigherPos(), TTmDocPosSpec::ETrailing );
       
 16624 
       
 16625     // this records what the resulting Right/left direction (for optional return)
       
 16626     TWesternNaviEvent effectiveEvent = aEvent;
       
 16627 
       
 16628     // Get line and paragraph of the lower limit of the selection:
       
 16629     TTmPosInfo2 posInfo;
       
 16630     TTmLineInfo lineInfo;
       
 16631     TBool lowIsRightToLeft;
       
 16632     TBool highIsRightToLeft;
       
 16633     TBool layoutExists = EFalse;
       
 16634     
       
 16635     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 16636     if (docNavi)
       
 16637     	{
       
 16638     	docNavi->FindDocPos(lowLogicalPos, posInfo, lineInfo);
       
 16639         lowIsRightToLeft = lineInfo.iFlags & TTmLineInfo::EParRightToLeft;
       
 16640     	docNavi->FindDocPos(highLogicalPos, posInfo, lineInfo);
       
 16641         highIsRightToLeft = lineInfo.iFlags & TTmLineInfo::EParRightToLeft;
       
 16642         layoutExists = ETrue;
       
 16643     	}
       
 16644     else
       
 16645     	{
       
 16646 	    CTextLayout* textLayout = TextLayout();
       
 16647 	    if (textLayout)
       
 16648 	        {
       
 16649 	        textLayout->TagmaTextLayout().FindDocPos(lowLogicalPos, posInfo, lineInfo);
       
 16650 	        lowIsRightToLeft = lineInfo.iFlags & TTmLineInfo::EParRightToLeft;
       
 16651 	        textLayout->TagmaTextLayout().FindDocPos(highLogicalPos, posInfo, lineInfo);
       
 16652 	        highIsRightToLeft = lineInfo.iFlags & TTmLineInfo::EParRightToLeft;
       
 16653 	        layoutExists = ETrue;
       
 16654 	        }
       
 16655     	}
       
 16656         
       
 16657     if (layoutExists)
       
 16658     	{
       
 16659         // Decide on the net directionality. This if looks a bit laboured, but it
       
 16660         // exhibits the Averell policy.
       
 16661         TBool netDirectionIsRightToLeft(EFalse);
       
 16662         if ( lowIsRightToLeft == highIsRightToLeft )
       
 16663             netDirectionIsRightToLeft = lowIsRightToLeft;
       
 16664         else
       
 16665             netDirectionIsRightToLeft = lowIsRightToLeft;// ambiguous - Take first paragraph
       
 16666 
       
 16667         if ( netDirectionIsRightToLeft )
       
 16668             switch ( aEvent )
       
 16669             {
       
 16670             case ELeftNaviEvent:
       
 16671             case EDownNaviEvent:
       
 16672                 effectiveEvent = ELeftNaviEvent;
       
 16673                 aLimitPos = LeftVisualExtremePos( highLogicalPos, lowLogicalPos.iPos, 
       
 16674                                                   highLogicalPos.iPos );
       
 16675                 break;
       
 16676             case ERightNaviEvent:
       
 16677             case EUpNaviEvent:
       
 16678                 effectiveEvent = ERightNaviEvent;
       
 16679                 aLimitPos = RightVisualExtremePos(lowLogicalPos, lowLogicalPos.iPos, 
       
 16680                                                   highLogicalPos.iPos );
       
 16681                 break;
       
 16682             default:
       
 16683             // No action. Only the events above are handled.
       
 16684                 break;
       
 16685             }
       
 16686         else
       
 16687             switch (aEvent)
       
 16688             {
       
 16689             case ELeftNaviEvent:
       
 16690             case EUpNaviEvent:
       
 16691                 effectiveEvent = ELeftNaviEvent;
       
 16692                 aLimitPos = LeftVisualExtremePos( lowLogicalPos, lowLogicalPos.iPos, 
       
 16693                                                   highLogicalPos.iPos);
       
 16694                 break;
       
 16695             case ERightNaviEvent:
       
 16696             case EDownNaviEvent:
       
 16697                 effectiveEvent = ERightNaviEvent;
       
 16698                 aLimitPos = RightVisualExtremePos( highLogicalPos, lowLogicalPos.iPos, 
       
 16699                                                    highLogicalPos.iPos );
       
 16700                 break;
       
 16701             default:
       
 16702             // No action. Only the events above are handled.
       
 16703                 break;
       
 16704             }
       
 16705         }
       
 16706 
       
 16707     else
       
 16708         {
       
 16709         // No text layout: Left or Up naviEvent gives low end; Right or down give high end
       
 16710         switch ( aEvent )
       
 16711             {
       
 16712             case ELeftNaviEvent:
       
 16713             case EUpNaviEvent:
       
 16714                 effectiveEvent = ELeftNaviEvent;
       
 16715                 aLimitPos = lowLogicalPos;
       
 16716                 break;
       
 16717             case ERightNaviEvent:
       
 16718             case EDownNaviEvent:
       
 16719                 effectiveEvent = ERightNaviEvent;
       
 16720                 aLimitPos = highLogicalPos;
       
 16721                 break;
       
 16722             default:
       
 16723             // No action. Only the events above are handled.
       
 16724                 break;
       
 16725             }
       
 16726         }
       
 16727     // return the effective direction (Right or Left)
       
 16728     if ( aEffectiveRightOrLeftEvent )
       
 16729         *aEffectiveRightOrLeftEvent = effectiveEvent;
       
 16730 
       
 16731     }
       
 16732 
       
 16733 
       
 16734 TTmDocPosSpec CAknFepManager::LeftVisualExtremePos( const TTmDocPosSpec& aStartPos, 
       
 16735                                                     TInt aMinPos, TInt aMaxPos ) const
       
 16736     {
       
 16737     // Start at start and find adjacent left chunks repeatedly until we find no more chunks, or our max or min
       
 16738     // is within a chunk
       
 16739     TTmDocPosSpec currentPos = aStartPos;
       
 16740     CTextLayout* textLayout = TextLayout();
       
 16741     if (AknFepDocumentNavigation() || textLayout)
       
 16742         {
       
 16743         CTmTextLayout::TTmChunkDescription leftChunk;
       
 16744         CTmTextLayout::TTmChunkDescription rightChunk;
       
 16745 
       
 16746         TInt iterations(0);
       
 16747         TBool endFound(EFalse);
       
 16748 
       
 16749         while( !endFound && iterations < KMaxChunkWalkIterations )
       
 16750             {
       
 16751             iterations++;
       
 16752             FindAdjacentChunks(currentPos, leftChunk, rightChunk);
       
 16753             // Try to move to left end of left chunk
       
 16754             endFound = LeftEndOfChunkWithinRange( leftChunk, aMinPos, aMaxPos, currentPos );
       
 16755             }
       
 16756         }
       
 16757     return currentPos;
       
 16758     }
       
 16759 
       
 16760 TTmDocPosSpec CAknFepManager::RightVisualExtremePos( const TTmDocPosSpec& aStartPos, 
       
 16761                                                      TInt aMinPos, TInt aMaxPos ) const
       
 16762     {
       
 16763     // Start at start and find adjacent right chunks repeatedly until we find no more chunks, or our max or min
       
 16764     // is within a chunk
       
 16765     TTmDocPosSpec currentPos = aStartPos;
       
 16766     CTextLayout* textLayout = TextLayout();
       
 16767     if (AknFepDocumentNavigation() || textLayout)
       
 16768         {
       
 16769         CTmTextLayout::TTmChunkDescription leftChunk;
       
 16770         CTmTextLayout::TTmChunkDescription rightChunk;
       
 16771 
       
 16772         TInt iterations(0);
       
 16773         TBool endFound(EFalse);
       
 16774 
       
 16775         while( !endFound && iterations < KMaxChunkWalkIterations )
       
 16776             {
       
 16777             iterations++;
       
 16778             FindAdjacentChunks(currentPos, leftChunk, rightChunk);
       
 16779             // Try to move to left end of left chunk
       
 16780             endFound = RightEndOfChunkWithinRange( rightChunk, aMinPos, aMaxPos, currentPos );
       
 16781             }
       
 16782         }
       
 16783     return currentPos;
       
 16784     }
       
 16785 
       
 16786 TBool CAknFepManager::LeftEndOfChunkWithinRange( const CTmTextLayout::TTmChunkDescription& aChunk,
       
 16787                                          TInt aMinPos, TInt aMaxPos, TTmDocPosSpec& aNewPos) const
       
 16788     {
       
 16789     TBool constrained = EFalse;
       
 16790     TInt leftEnd;
       
 16791     if ( !ChunkIsValid( aChunk ) )
       
 16792         {
       
 16793         constrained = ETrue; // leave the aNewPos as it is
       
 16794         }
       
 16795     else if ( aChunk.iStart >= iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep() )
       
 16796         {
       
 16797         constrained = ETrue; // That chunk was a ficticious one:
       
 16798         }
       
 16799     else if ( aChunk.iEnd <= aMinPos || aChunk.iStart >= aMaxPos )
       
 16800         {
       
 16801         constrained = ETrue; // That chunk found does not actually overlap with valid range. Don't go there
       
 16802         }
       
 16803     else
       
 16804         {
       
 16805         if ( aChunk.iRightToLeft )
       
 16806             {
       
 16807             leftEnd =  aChunk.iEnd;
       
 16808             if ( leftEnd >= aMaxPos )
       
 16809                 {
       
 16810                 constrained = ETrue;
       
 16811                 aNewPos.iPos = aMaxPos;
       
 16812                 }
       
 16813             else
       
 16814                 {
       
 16815                 aNewPos.iPos = leftEnd;
       
 16816                 }
       
 16817             aNewPos.iType = TTmDocPosSpec::ETrailing;
       
 16818             }
       
 16819         else
       
 16820             {
       
 16821             leftEnd = aChunk.iStart;
       
 16822             if ( leftEnd <= aMinPos )
       
 16823                 {
       
 16824                 constrained = ETrue;
       
 16825                 aNewPos.iPos = aMinPos;
       
 16826                 }
       
 16827             else
       
 16828                 {
       
 16829                 aNewPos.iPos = leftEnd;
       
 16830                 }
       
 16831             aNewPos.iType = TTmDocPosSpec::ELeading;
       
 16832             }
       
 16833         }
       
 16834     return constrained;
       
 16835     }
       
 16836 
       
 16837 TBool CAknFepManager::RightEndOfChunkWithinRange( const CTmTextLayout::TTmChunkDescription& aChunk,
       
 16838                                          TInt aMinPos, TInt aMaxPos, TTmDocPosSpec& aNewPos) const
       
 16839     {
       
 16840     TBool constrained = EFalse;
       
 16841     TInt rightEnd;
       
 16842     if ( !ChunkIsValid( aChunk ) )
       
 16843         {
       
 16844         constrained = ETrue; // leave the aNewPos as it is
       
 16845         }
       
 16846     else if ( aChunk.iStart >= iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep() )
       
 16847         {
       
 16848         constrained = ETrue; // That chunk was a ficticious one:
       
 16849         }
       
 16850     else if ( aChunk.iEnd <= aMinPos || aChunk.iStart >= aMaxPos )
       
 16851         {
       
 16852         constrained = ETrue; // That chunk found does not actually overlap with valid range. Don't go there
       
 16853         }
       
 16854     else
       
 16855         {
       
 16856         if ( aChunk.iRightToLeft )
       
 16857             {
       
 16858             rightEnd =  aChunk.iStart;
       
 16859             if ( rightEnd <= aMinPos )
       
 16860                 {
       
 16861                 constrained = ETrue;
       
 16862                 aNewPos.iPos = aMinPos;
       
 16863                 }
       
 16864             else
       
 16865                 {
       
 16866                 aNewPos.iPos = rightEnd;
       
 16867                 }
       
 16868             aNewPos.iType = TTmDocPosSpec::ELeading;
       
 16869             }
       
 16870         else
       
 16871             {
       
 16872             rightEnd = aChunk.iEnd;
       
 16873             if ( rightEnd >= aMaxPos )
       
 16874                 {
       
 16875                 constrained = ETrue;
       
 16876                 aNewPos.iPos = aMaxPos;
       
 16877                 }
       
 16878             else
       
 16879                 {
       
 16880                 aNewPos.iPos = rightEnd;
       
 16881                 }
       
 16882             aNewPos.iType = TTmDocPosSpec::ETrailing;
       
 16883             }
       
 16884         }
       
 16885     return constrained;
       
 16886     }
       
 16887 
       
 16888 /**
       
 16889 * This method handles the attachment to the chunk being navigated toward.
       
 16890 * Should only be used for Right and Left navigation.
       
 16891 * The actual direction of that chunk does not need to be looked at. Even if
       
 16892 * is the same direction as the one being moved from, you still attach to it, as it may not
       
 16893 * be logically contiguous.
       
 16894 */
       
 16895 void CAknFepManager::AdjustPosSpecForAmbiguityAfterLeftOrRightNavigation( TTmDocPosSpec& aPos, 
       
 16896                                                               TWesternNaviEvent aEvent ) const
       
 16897     {
       
 16898 
       
 16899     CTmTextLayout::TTmChunkDescription leftChunk;
       
 16900     CTmTextLayout::TTmChunkDescription rightChunk;
       
 16901     FindAdjacentChunks(aPos, leftChunk, rightChunk);
       
 16902 
       
 16903     TBool inputDirectionIsRTL = ( CurrentInputDirectionality() == TBidiText::ERightToLeft );
       
 16904 
       
 16905     switch (aEvent)
       
 16906         {
       
 16907         case ELeftNaviEvent:
       
 16908             {
       
 16909             // Do not attach to the left chunk if its directionality is not the same as aDirection
       
 16910             if ( ChunkIsValid( leftChunk ) )
       
 16911                 if ( COMPARE_BOOLS(inputDirectionIsRTL, leftChunk.iRightToLeft) )
       
 16912                     AttachToLeftChunk( aPos, leftChunk );
       
 16913             break;
       
 16914             }
       
 16915         case ERightNaviEvent:
       
 16916             {
       
 16917             if ( ChunkIsValid( rightChunk ) )
       
 16918                 if ( COMPARE_BOOLS(inputDirectionIsRTL, rightChunk.iRightToLeft) )
       
 16919                     AttachToRightChunk( aPos, rightChunk );
       
 16920             break;
       
 16921             }
       
 16922         default:
       
 16923             break;
       
 16924         }
       
 16925 
       
 16926     }
       
 16927 
       
 16928 
       
 16929 void CAknFepManager::AttachToRightChunk( TTmDocPosSpec& aPos, 
       
 16930                                          const CTmTextLayout::TTmChunkDescription& aRightChunk )
       
 16931     {
       
 16932     if ( aRightChunk.iRightToLeft )
       
 16933         {
       
 16934         aPos.iPos = aRightChunk.iEnd;
       
 16935         aPos.iType = TTmDocPosSpec::ETrailing;
       
 16936         }
       
 16937     else
       
 16938         {
       
 16939         aPos.iPos = aRightChunk.iStart;
       
 16940         aPos.iType = TTmDocPosSpec::ELeading;
       
 16941         }
       
 16942     }
       
 16943 
       
 16944 void CAknFepManager::AttachToLeftChunk( TTmDocPosSpec& aPos, 
       
 16945                                         const CTmTextLayout::TTmChunkDescription& aLeftChunk )
       
 16946     {
       
 16947     if ( aLeftChunk.iRightToLeft )
       
 16948         {
       
 16949         aPos.iPos = aLeftChunk.iStart;
       
 16950         aPos.iType = TTmDocPosSpec::ELeading;
       
 16951         }
       
 16952     else
       
 16953         {
       
 16954         aPos.iPos = aLeftChunk.iEnd;
       
 16955         aPos.iType = TTmDocPosSpec::ETrailing;
       
 16956         }
       
 16957     }
       
 16958 
       
 16959 /**
       
 16960 * This routine ensures that the cursor position is not attached to a chunk of opposite direction.
       
 16961 * For end of document, the normal routine can be used.
       
 16962 * For the start, usually do nothing, but there is the possibility of forcing position 0/Trailing, when
       
 16963 * the edge chunk and the input directionality are opposite.
       
 16964 */
       
 16965 void CAknFepManager::AdjustPosSpecForInputLanguageAfterDocumentLoop( TTmDocPosSpec& aPos, 
       
 16966                                      TWesternNaviEvent /*aNaviEvent*/, TBool aLoopToTop ) const
       
 16967     {
       
 16968 
       
 16969     // Looping based on a Left event should adjust the cursor position as if that point had
       
 16970     // been reached by navigation to that same visual position outwards from the body
       
 16971     // Define this as the effective navigation that has just happened:
       
 16972     TWesternNaviEvent effectiveEvent(ELeftNaviEvent);
       
 16973 
       
 16974     // Rule for this effective navigation is
       
 16975     // move to top of document : if paradirection is LTR then treat it as a LEFT navi
       
 16976     // move to top of document : if paradirection is RTL then treat it as RIGHT navi
       
 16977     // move to bottom of document : if paradirection is LTR then treat is as RIGHT navi
       
 16978     // move to bottom of document : if paradirection is RTL then treat as LEFT navi
       
 16979     // However, NOTE that decrementing events leads to looping to the END! (and vice versa)
       
 16980     TBool newParaIsRTL = IsRightToLeftParagraph(aPos);
       
 16981     if ( aLoopToTop && newParaIsRTL ) // move to top; RTL
       
 16982         effectiveEvent = ERightNaviEvent;
       
 16983     else if ( !aLoopToTop && !newParaIsRTL ) // move to bottom; LTR
       
 16984         effectiveEvent = ERightNaviEvent;
       
 16985 
       
 16986     if ( aLoopToTop )
       
 16987         {
       
 16988         //  There is no ficticious block of the paragraph direction at -1 to 0.  So we have to
       
 16989         // behave as if there is one:
       
 16990         //
       
 16991         CTmTextLayout::TTmChunkDescription leftChunk;
       
 16992         CTmTextLayout::TTmChunkDescription rightChunk;
       
 16993         CTmTextLayout::TTmChunkDescription& edgeChunk = leftChunk;
       
 16994 
       
 16995         FindAdjacentChunks(aPos, leftChunk, rightChunk);
       
 16996 
       
 16997         // Get input language direction
       
 16998         TBool inputDirectionIsRTL = ( CurrentInputDirectionality() == TBidiText::ERightToLeft );
       
 16999         if ( effectiveEvent == ELeftNaviEvent )
       
 17000             edgeChunk = leftChunk;
       
 17001         else
       
 17002             edgeChunk = rightChunk;
       
 17003 
       
 17004         // Check edgechunk for its direction
       
 17005         if ( !COMPARE_BOOLS( edgeChunk.iRightToLeft, inputDirectionIsRTL ) )
       
 17006             {
       
 17007             // Input language disagrees with the chunk that we are on,
       
 17008             aPos.iPos = 0;
       
 17009             aPos.iType = TTmDocPosSpec::ETrailing;
       
 17010             }
       
 17011 
       
 17012         }
       
 17013     else // Looping to the end of document
       
 17014         {
       
 17015         // There IS a ficticious block at the doc end, so use the usual routine.
       
 17016         AdjustPosSpecForAmbiguityAfterLeftOrRightNavigation( aPos, effectiveEvent );
       
 17017         }
       
 17018 
       
 17019     }
       
 17020 
       
 17021 TBool CAknFepManager::ChunkIsValid( const CTmTextLayout::TTmChunkDescription& aChunk )
       
 17022     {
       
 17023     TBool isValid(ETrue);
       
 17024 
       
 17025     const TInt KNotValid = -1;
       
 17026     if ( aChunk.iRightToLeft == KNotValid )
       
 17027         isValid = EFalse;
       
 17028     else if (aChunk.iStart == KNotValid )
       
 17029         isValid = EFalse;
       
 17030     else if (aChunk.iEnd == KNotValid )
       
 17031         isValid = EFalse;
       
 17032 
       
 17033 #ifdef _DEBUG
       
 17034     if (isValid)
       
 17035         __ASSERT_DEBUG( aChunk.iStart <= aChunk.iEnd, 
       
 17036                         AknFepPanic( EAknFepPanicBadCursorNavigationState ) );
       
 17037 #endif
       
 17038 
       
 17039     return isValid;
       
 17040     }
       
 17041 /**
       
 17042 * Finds the current input direction. This is determined as best as it can using
       
 17043 * - T9Interface as the preferred source of information
       
 17044 * - shared data (via AknTextUtils) if that fails
       
 17045 * - localLanguage overrides the above sources of information
       
 17046 * - when fep is in numeric mode it returns LTR
       
 17047 * - if FEP is in an irelevant mode, then LTR is returned
       
 17048 *
       
 17049 * @return TDirectionality::ELeftToRight for LTR alpha mode or numeric mode
       
 17050 */
       
 17051 TBidiText::TDirectionality CAknFepManager::CurrentInputDirectionality() const
       
 17052     {
       
 17053     TBidiText::TDirectionality directionality(TBidiText::ELeftToRight);
       
 17054 
       
 17055     // See if we are in a mode where the directionality is defined:
       
 17056     TBool checkForRTLValid(EFalse);
       
 17057 
       
 17058     switch (iMode )
       
 17059         {
       
 17060         case ELatin:
       
 17061         case ENumber:
       
 17062             checkForRTLValid = ETrue;
       
 17063             break;
       
 17064         default:
       
 17065             break;
       
 17066         }
       
 17067 
       
 17068     if ( checkForRTLValid )
       
 17069         {
       
 17070             MPtiLanguage* ptilang = iPtiEngine->CurrentLanguage(); // No need to get language from PtiEngine ?
       
 17071             TInt inputLanguage = (ptilang)? ptilang->LanguageCode() : 0;
       
 17072             if ( inputLanguage )
       
 17073                 {
       
 17074                 directionality = TBidiText::ScriptDirectionality( (TLanguage)inputLanguage );
       
 17075                 checkForRTLValid = EFalse;
       
 17076                 }
       
 17077         }
       
 17078 
       
 17079     // if no T9 interface information is available, then go for other sources
       
 17080     // Note that you have to check for local language in this case (belt-and-braces)
       
 17081     if ( checkForRTLValid )
       
 17082         {
       
 17083         TLanguage localLanguage = ELangTest;
       
 17084         if ( GetLocalLanguage( localLanguage ) )
       
 17085             directionality = TBidiText::ScriptDirectionality( localLanguage );
       
 17086         else
       
 17087             directionality = AknTextUtils::CurrentScriptDirectionality();
       
 17088         }
       
 17089 
       
 17090     return directionality;
       
 17091     }
       
 17092 
       
 17093 
       
 17094 TBool CAknFepManager::GetLocalLanguage( TLanguage& aLanguage ) const
       
 17095     {
       
 17096     TBool result(EFalse);
       
 17097     // Check for a local language override
       
 17098     if ( IsFepAwareTextEditor() )
       
 17099         {
       
 17100         // For ITU-T keyboard we always use english in latin-only editors.               
       
 17101         // In case of qwerty keyboard, some languages can be used in latin
       
 17102         // only-editors, some require that english is used instead. That
       
 17103         // is decided here.
       
 17104         const TInt globalLang = iSharedDataInterface->InputTextLanguage();        
       
 17105         TBool allowTest = 
       
 17106 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 17107                            !iQwertyInputMode ||
       
 17108 #endif
       
 17109                            globalLang == ELangPrcChinese ||
       
 17110                            globalLang == ELangHongKongChinese ||
       
 17111                            globalLang == ELangTaiwanChinese ||
       
 17112                            globalLang == ELangThai ||
       
 17113                            globalLang == ELangGreek ||
       
 17114                            globalLang == ELangArabic ||
       
 17115                            globalLang == ELangFarsi ||                           
       
 17116                            globalLang == ELangUrdu ||
       
 17117                            globalLang == ELangHebrew ||
       
 17118                            globalLang == ELangRussian ||
       
 17119                            globalLang == ELangUkrainian ||
       
 17120                            globalLang == ELangHindi ||
       
 17121 #ifdef RD_MARATHI
       
 17122                            globalLang == ELangMarathi ||
       
 17123 #endif // RD_MARATHI
       
 17124 
       
 17125 #ifdef RD_HINDI_PHONETIC_INPUT  
       
 17126                            globalLang == KLangHindiPhonetic ||
       
 17127 #endif                           
       
 17128                            globalLang == ELangBulgarian || 
       
 17129                            globalLang == ELangVietnamese;
       
 17130                                           
       
 17131         if (allowTest && iAknEditorFlags & EAknEditorFlagLatinInputModesOnly &&
       
 17132             iLanguageCapabilities.iInputLanguageCode != ELangJapanese)
       
 17133             {
       
 17134             aLanguage = ELangEnglish;               
       
 17135             }
       
 17136         else
       
 17137             {
       
 17138             aLanguage = EditorState()->LocalLanguage();
       
 17139             
       
 17140             // Change local language to ELangEnglish if application, e.g. Search Widget,
       
 17141             // sets local language to ELangEnglish_Taiwan, ELangEnglish_HongKong 
       
 17142             // and ELangEnglish_Prc. 
       
 17143             if( aLanguage == ELangEnglish_Taiwan || 
       
 17144                     aLanguage == ELangEnglish_HongKong || 
       
 17145                     aLanguage == ELangEnglish_Prc )
       
 17146                 {
       
 17147                 aLanguage = ELangEnglish;
       
 17148                 }
       
 17149             }
       
 17150             
       
 17151         if ( aLanguage != ELangTest )
       
 17152             {   
       
 17153             MPtiLanguage* languageObject = NULL;
       
 17154             languageObject = iPtiEngine->GetLanguage(aLanguage);
       
 17155             if (languageObject)  // Check if the input language is supported.
       
 17156                 {                
       
 17157                 result = ETrue;
       
 17158                 }
       
 17159             else
       
 17160                 {
       
 17161                 aLanguage = ELangTest;
       
 17162                 }
       
 17163             }
       
 17164         }
       
 17165     return result;
       
 17166     }
       
 17167 
       
 17168 
       
 17169 TBool CAknFepManager::GetExposedDirectionOfText( TInt aPos, TBool aForward, 
       
 17170                                                  TBool& aIsRightToLeft ) const
       
 17171     {
       
 17172     TBool hasStrongCharacter(EFalse);
       
 17173 
       
 17174     // Access the plain text from the editor, getting a little bit at a time.
       
 17175 
       
 17176     TInt docLen = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 17177 
       
 17178     // Init with defaults for aForward = ETrue
       
 17179     TInt limit = docLen;
       
 17180     TInt increment = 1;
       
 17181     if ( !aForward )
       
 17182         {
       
 17183         limit = -1; // Loop does not execute if == limit
       
 17184         increment = -1;
       
 17185         }
       
 17186 
       
 17187     for ( TInt index = aPos; index != limit ; index += increment )
       
 17188         {
       
 17189         TChar ch = CharAt(index);
       
 17190         if ( iInlineTextDecorator->CharacterIsStrongRightToLeft( (TText)ch ) )
       
 17191             {
       
 17192             hasStrongCharacter = ETrue;
       
 17193             aIsRightToLeft = ETrue;
       
 17194             break;
       
 17195             }
       
 17196         else if ( iInlineTextDecorator->CharacterIsStrongLeftToRight( (TText)ch ) )
       
 17197             {
       
 17198             hasStrongCharacter = ETrue;
       
 17199             aIsRightToLeft = EFalse;
       
 17200             break;
       
 17201             }
       
 17202         }
       
 17203 
       
 17204     return hasStrongCharacter;
       
 17205     }
       
 17206 
       
 17207 TBool CAknFepManager::GetExposedDirectionOfTextInDescriptor( const TDesC& aText, TBool aForward, 
       
 17208                                                              TBool& aIsRightToLeft ) const
       
 17209     {
       
 17210     TBool hasStrongCharacter(EFalse);
       
 17211 
       
 17212     TInt textLen = aText.Length();
       
 17213 
       
 17214     TInt start = 0;
       
 17215     TInt limit = textLen;
       
 17216     TInt increment = 1;
       
 17217     if ( !aForward )
       
 17218         {
       
 17219         start = textLen-1;
       
 17220         limit = -1; // Loop does not execute if == limit
       
 17221         increment = -1;
       
 17222         }
       
 17223 
       
 17224     for ( TInt index = start; index != limit ; index += increment )
       
 17225         {
       
 17226         if ( iInlineTextDecorator->CharacterIsStrongRightToLeft( (TText)aText[index] ) )
       
 17227             {
       
 17228             hasStrongCharacter = ETrue;
       
 17229             aIsRightToLeft = ETrue;
       
 17230             break;
       
 17231             }
       
 17232         else if (  iInlineTextDecorator->CharacterIsStrongLeftToRight( (TText)aText[index] ) )
       
 17233             {
       
 17234             hasStrongCharacter = ETrue;
       
 17235             aIsRightToLeft = EFalse;
       
 17236             break;
       
 17237             }
       
 17238         }
       
 17239 
       
 17240     return hasStrongCharacter;
       
 17241     }
       
 17242 
       
 17243 TChar CAknFepManager::CharAt( TInt aPos ) const
       
 17244     {
       
 17245     TBuf<ESingleCharacter> chDes;
       
 17246 #ifdef RD_SCALABLE_UI_V2
       
 17247     if ( SemiFepAwareTextEditor( ETrue ) )
       
 17248 #else
       
 17249     if ( iInputCapabilities.FepAwareTextEditor() )
       
 17250 #endif // RD_SCALABLE_UI_V2    
       
 17251         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep( chDes, aPos, 
       
 17252                                                                          ESingleCharacter);
       
 17253     if( chDes.Length() > 0 )
       
 17254         return chDes[0];
       
 17255     else
       
 17256         return TChar(0);
       
 17257     }
       
 17258 
       
 17259 
       
 17260 /**
       
 17261 * Navigate off of selected text using an Up/Down/Right/Left navigation event
       
 17262 *
       
 17263 * The code takes account of the paragraph directionality that the passed selection is
       
 17264 * found in.
       
 17265 *
       
 17266 * The new cursor position is resolved for ambuguity and set using SetCursorPosition and
       
 17267 * so it has the same side-effects:
       
 17268 *   iUncommittedText is set to the zero-width "cursor" state with the new cursor position
       
 17269 *   iUncommittedText is set into the FepAwareTextEditor state
       
 17270 *   iCaseManager is updated with a ENullNaviEvent
       
 17271 *   the doc pos is set in TextView object if present
       
 17272 */
       
 17273 TKeyResponse CAknFepManager::NavigateFromSelectionL(
       
 17274             const TCursorSelection& aSelection,
       
 17275             TWesternNaviEvent aNaviEvent,
       
 17276             TTmDocPosSpec& aPos)
       
 17277     {
       
 17278     if (IsCcpuFlagSet(ECcpuStateCopy | ECcpuStateCut | ECcpuStateHashDown))
       
 17279         {
       
 17280         return EKeyWasNotConsumed;
       
 17281         }
       
 17282         
       
 17283     switch( aNaviEvent )
       
 17284         {
       
 17285         case EUpNaviEvent:
       
 17286         case EDownNaviEvent:
       
 17287         case ERightNaviEvent:
       
 17288         case ELeftNaviEvent:
       
 17289             // Carry on. Handle this event
       
 17290             break;
       
 17291         default: // just leave it as NULL
       
 17292             return EKeyWasNotConsumed;
       
 17293         }
       
 17294     // Find the visual end of the selection
       
 17295     TWesternNaviEvent effectiveEvent; // used to return either Right or Left event from next call:
       
 17296     GetAvkonDefinedVisualLimitsOfSelection( aSelection, aNaviEvent, aPos, &effectiveEvent );
       
 17297     AdjustPosSpecForAmbiguityAfterLeftOrRightNavigation( aPos, effectiveEvent );
       
 17298 
       
 17299     // Set this as the current position
       
 17300     SetCursorPositionL( aPos );
       
 17301 
       
 17302     return EKeyWasConsumed;
       
 17303     }
       
 17304 
       
 17305 
       
 17306 void CAknFepManager::SetCursorPositionL( const TTmDocPosSpec& aNewCursorPos, TBool aDragSelectOn )
       
 17307     {
       
 17308     if ( !iInputCapabilities.FepAwareTextEditor() )
       
 17309         return;
       
 17310 
       
 17311     TInt newAnchorPos = aNewCursorPos.iPos;
       
 17312 
       
 17313     if ( aDragSelectOn )
       
 17314         {
       
 17315         TCursorSelection selection;
       
 17316         iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(selection);
       
 17317         if ( selection.Length() > 0 ) // there is a selection. Keep the anchor
       
 17318             newAnchorPos = selection.iAnchorPos;
       
 17319         }
       
 17320 
       
 17321     iUncommittedText.SetSelection( aNewCursorPos.iPos, newAnchorPos );
       
 17322 
       
 17323     iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(iUncommittedText);
       
 17324     iCaseMan->UpdateCase(ENullNaviEvent);
       
 17325 
       
 17326     // This is able to set the directional attachment of the cursor in a way that the FepAwareTextEditor interface cannot
       
 17327     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 17328     if (docNavi)
       
 17329     	{
       
 17330     	docNavi->SetDocPosL(aNewCursorPos, aDragSelectOn);
       
 17331     	}
       
 17332     else
       
 17333     	{
       
 17334         CAknEdwinFormAccessor* formAccessor = EditorState()->FormAccessor();
       
 17335         if (formAccessor)
       
 17336             {
       
 17337             CEikEdwin *edwin = static_cast<CEikEdwin *>( formAccessor->FormClientControl() );
       
 17338             if (edwin)
       
 17339                 edwin->SetCursorPosL( aNewCursorPos.iPos, aDragSelectOn );
       
 17340             }
       
 17341         }
       
 17342     }
       
 17343 
       
 17344 
       
 17345 
       
 17346 TBool CAknFepManager::InFirstLineAndFormatted( const TTmDocPosSpec& aPos ) const
       
 17347     {
       
 17348     return DocPosInFirstOrLastLineAndFormatted( aPos, ETrue);
       
 17349     }
       
 17350 
       
 17351 TBool CAknFepManager::InLastLineAndFormatted( const TTmDocPosSpec& aPos ) const
       
 17352     {
       
 17353     return DocPosInFirstOrLastLineAndFormatted( aPos, EFalse );
       
 17354     }
       
 17355 
       
 17356 TBool CAknFepManager::DocPosInFirstOrLastLineAndFormatted( const TTmDocPosSpec& aPos, 
       
 17357                                                            TBool aCheckFirstLine ) const
       
 17358     {
       
 17359     TBool success(EFalse);
       
 17360     TTmLineInfo lineInfo;
       
 17361     MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 17362     if (docNavi)
       
 17363     	{
       
 17364 	    success = docNavi->DocPosToLine( aPos, lineInfo);
       
 17365     	}
       
 17366     else
       
 17367     	{
       
 17368 	    CTextLayout* textLayout = TextLayout();
       
 17369 	    if ( textLayout )
       
 17370 	        {
       
 17371 	        success = textLayout->TagmaTextLayout().DocPosToLine( aPos, lineInfo);
       
 17372 	        }
       
 17373     	}
       
 17374     	
       
 17375         if ( success )
       
 17376             {
       
 17377             if ( aCheckFirstLine )
       
 17378                 success = (lineInfo.iLineNumber == 0 );
       
 17379             else
       
 17380                 {
       
 17381                 // Current position has yielded line information.  But how to tell if it is the last line?
       
 17382                 // Use the fact that the docpos of the last character will be in the last line.
       
 17383                 // Also account for the fact that these APIs report a character at docLength itself, a
       
 17384                 // ficticious end of paragraph character.  So use a >= docLength
       
 17385                 success = (lineInfo.iEnd >= 
       
 17386                            iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep()  );
       
 17387                 }
       
 17388             }
       
 17389         
       
 17390     return success;
       
 17391     }
       
 17392 
       
 17393 TBool CAknFepManager::AtVisualStart( const TTmDocPosSpec& aCurrentPos, 
       
 17394                                      const TTmDocPosSpec& aLimitPos ) const
       
 17395     {
       
 17396     TBool positionsAreTheSame(EFalse);
       
 17397     if ( aCurrentPos.iPos == aLimitPos.iPos && aCurrentPos.iType == aLimitPos.iType )
       
 17398         positionsAreTheSame = ETrue;
       
 17399     else if ( aCurrentPos.iPos == 0 && aCurrentPos.iType == TTmDocPosSpec::ETrailing )
       
 17400         positionsAreTheSame = ETrue;
       
 17401 
       
 17402     return positionsAreTheSame;
       
 17403     }
       
 17404 
       
 17405 TBool CAknFepManager::AtVisualEnd( const TTmDocPosSpec& aCurrentPos, 
       
 17406                                    const TTmDocPosSpec& aLimitPos, TInt aDocLength ) const
       
 17407     {
       
 17408     TBool positionsAreTheSame(EFalse);
       
 17409     if ( aCurrentPos.iPos == aLimitPos.iPos && aCurrentPos.iType == aLimitPos.iType )
       
 17410         positionsAreTheSame = ETrue;
       
 17411     else if ( aCurrentPos.iPos == aDocLength && aCurrentPos.iType == TTmDocPosSpec::ELeading )
       
 17412         positionsAreTheSame = ETrue;
       
 17413     else if ( aCurrentPos.iPos > aDocLength )
       
 17414         positionsAreTheSame = ETrue;
       
 17415 
       
 17416     return positionsAreTheSame;
       
 17417     }
       
 17418 
       
 17419 
       
 17420 void CAknFepManager::SetCursorType(TBool aIsLeftToRight)
       
 17421     {
       
 17422     if ( !BidiCursorRequired() )
       
 17423         return;
       
 17424 
       
 17425     // Optimization to prevent excessive Wserv communication:
       
 17426     if ( IsFlagSet( EFlagBidiCursorIsInitialized )
       
 17427         && COMPARE_BOOLS( !aIsLeftToRight, IsFlagSet( EFlagCursorPointsRightToLeft ) ) )
       
 17428         return;
       
 17429 
       
 17430     SetFlag( EFlagBidiCursorIsInitialized );
       
 17431 
       
 17432     MCoeFepAwareTextEditor* editor = iInputCapabilities.FepAwareTextEditor();
       
 17433     if (editor && editor->Extension1())
       
 17434         {
       
 17435         TCharFormat format;
       
 17436         TInt docPos = DocPos().iPos;
       
 17437         editor->GetFormatForFep(format, docPos);
       
 17438         
       
 17439         // Use Avkon routine to make all the layout decisions. It returns a TTextCursor object
       
 17440         TTextCursor newCursor;
       
 17441         AknCustomCursorSupport::GetBidiTextCursorFromFontSpec( format.iFontSpec, 
       
 17442                                                                !aIsLeftToRight, newCursor );
       
 17443         TBool setToTrue(ETrue);
       
 17444         editor->Extension1()->SetCursorType(setToTrue, newCursor);
       
 17445        
       
 17446         // Keep flag in step for optimization
       
 17447         if ( aIsLeftToRight )
       
 17448             ClearFlag( EFlagCursorPointsRightToLeft );
       
 17449         else
       
 17450             SetFlag( EFlagCursorPointsRightToLeft );
       
 17451         }
       
 17452     }
       
 17453 
       
 17454 TBool CAknFepManager::DeviceSupportsRTLLanguageL()
       
 17455     {
       
 17456     CArrayFixFlat<TInt>* languages = new (ELeave) CArrayFixFlat<TInt>(ELanguageArrayGranularity);
       
 17457     CleanupStack::PushL(languages);
       
 17458     iPtiEngine->GetAvailableLanguagesL(languages);
       
 17459 
       
 17460     TBool bidiCursorSuppressed(EFalse);
       
 17461 #if defined(__WINS__)
       
 17462     bidiCursorSuppressed = ETrue;
       
 17463     // Test (Disabled) mode (fake) UID, key and its value
       
 17464     const TInt KTestModeValue = 1; // 1 = show Bidi cursor
       
 17465 
       
 17466     CRepository* repository = NULL;
       
 17467     TRAPD(ret, repository = CRepository::NewL(KCRUidAknFep));
       
 17468     if (ret == KErrNone)
       
 17469         {
       
 17470         TInt modeValue = 0;
       
 17471         if (repository->Get(KAknFepTestModeKey, modeValue) == KErrNone)
       
 17472             {
       
 17473             if (modeValue == KTestModeValue)
       
 17474                 {
       
 17475                 bidiCursorSuppressed = EFalse; // show bidi cursor
       
 17476                 }
       
 17477             }
       
 17478         }
       
 17479     delete repository;
       
 17480 #endif
       
 17481 
       
 17482     TBool result = EFalse;
       
 17483     if (!bidiCursorSuppressed)
       
 17484         {
       
 17485         for (TInt jj = 0; jj < languages->Count(); jj++)
       
 17486             {
       
 17487             if (languages->At(jj) == ELangArabic ||
       
 17488                 languages->At(jj) == ELangHebrew ||
       
 17489                 languages->At(jj) == ELangFarsi  ||
       
 17490                 languages->At(jj) == ELangUrdu )
       
 17491                 // + others...
       
 17492                 {
       
 17493                 result = ETrue;
       
 17494                 break;
       
 17495                 }
       
 17496             }
       
 17497         }
       
 17498 
       
 17499     CleanupStack::PopAndDestroy();  // languages
       
 17500     return result;
       
 17501     }
       
 17502 
       
 17503 void CAknFepManager::CalculateEditorDigitType(TDigitType& aDestination)
       
 17504     {
       
 17505     // When current range is latin number mode
       
 17506     if ( iMode == ENumber )
       
 17507         {
       
 17508         // Set the Local Digit Type flag to EDigitTypeWestern
       
 17509         aDestination = EDigitTypeWestern;
       
 17510         return;
       
 17511         }
       
 17512 
       
 17513     TBool ASCIIDigits = EFalse;
       
 17514     MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
 17515 
       
 17516     if ( mop )
       
 17517         {
       
 17518         CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
 17519         mop->MopGetObject( extendedInputCapabilities );
       
 17520 
       
 17521         if ( extendedInputCapabilities ) 
       
 17522             {
       
 17523             if ( extendedInputCapabilities->SupportsCapabilities(
       
 17524                 CAknExtendedInputCapabilities::ESupportsOnlyASCIIDigits ) )
       
 17525                 {
       
 17526                 // If this is true, then the inputcaps wants only ascii
       
 17527                 // digits -> you can, when the editor is seen as numeric,
       
 17528                 // be sure that only latin indicator is then wanted.
       
 17529                 ASCIIDigits = ETrue;
       
 17530                 }
       
 17531             }
       
 17532         }
       
 17533 
       
 17534     if (iAknEditorFlags & EAknEditorFlagLatinInputModesOnly) 
       
 17535         {
       
 17536         // use of only latin characters implies that numbers are also western
       
 17537         ASCIIDigits = ETrue;
       
 17538         }
       
 17539 
       
 17540     AknTextUtils::TDigitModeQueryType editorType = AknTextUtils::EDigitModeEditorDefault;
       
 17541     TBool numberOnlyEditor = iPermittedInputModes == EAknEditorNumericInputMode;
       
 17542     if ( numberOnlyEditor )
       
 17543         {
       
 17544         editorType = AknTextUtils::EDigitModeNumberEditor;
       
 17545         if (ASCIIDigits)
       
 17546             {
       
 17547             editorType = AknTextUtils::EDigitModeLatinNumberEditor;
       
 17548             }
       
 17549         }
       
 17550         
       
 17551     if (iLanguageCapabilities.iArabicIndicDigitsAllowed &&
       
 17552             (AknTextUtils::DigitModeQuery(editorType) || iMode == ENativeNumber) && 
       
 17553         !ASCIIDigits)
       
 17554         {
       
 17555         aDestination = EDigitTypeArabicIndic;
       
 17556         }
       
 17557     else if (iLanguageCapabilities.iEasternArabicIndicDigitsAllowed &&
       
 17558             (AknTextUtils::DigitModeQuery(editorType) || iMode == ENativeNumber) && 
       
 17559         !ASCIIDigits)
       
 17560         {
       
 17561         aDestination = EDigitTypeEasternArabicIndic;
       
 17562         }    
       
 17563     /*Hindi*/    
       
 17564     else if ( iLanguageCapabilities.iIndicDigitsAllowed &&
       
 17565             (AknTextUtils::DigitModeQuery(editorType) || iMode == ENativeNumber) && 
       
 17566         !ASCIIDigits)    
       
 17567         {
       
 17568         aDestination = EDigitTypeDevanagari;    
       
 17569         }
       
 17570     else
       
 17571         {
       
 17572         aDestination = EDigitTypeWestern;
       
 17573         }
       
 17574     }
       
 17575 
       
 17576 
       
 17577 void CAknFepManager::UpdateNumericEditorDigitType()
       
 17578     {
       
 17579     if (iLanguageCapabilities.iNumericEditorDigitType == EDigitTypeUnknown)
       
 17580         {
       
 17581         CalculateEditorDigitType(iLanguageCapabilities.iNumericEditorDigitType);
       
 17582         }
       
 17583     }
       
 17584 
       
 17585 void CAknFepManager::UpdateLocalDigitMode()
       
 17586     {
       
 17587     TInt oldLocalDigitType = iLanguageCapabilities.iLocalDigitType;
       
 17588     CalculateEditorDigitType(iLanguageCapabilities.iLocalDigitType);
       
 17589     
       
 17590     if (oldLocalDigitType != iLanguageCapabilities.iLocalDigitType && 
       
 17591         iCaseMan) // happens in destructor   
       
 17592         {
       
 17593         UpdateIndicators(); 
       
 17594         }
       
 17595     }
       
 17596 
       
 17597 /**
       
 17598 * This routine should be called if the flag is set that says that the last navigation was to an
       
 17599 * ambiguous point.
       
 17600 * The routine checks to see if the event passed is
       
 17601 * - Right or Left Arrow
       
 17602 * - Would be the event to "jump" across the ambiguity. That is
       
 17603 *       - if at the "left" side of a LTR | RTL point, you need a Right arrow
       
 17604 *       - if at the "right" side of a LTR | RTL point, you need a Left arrow.
       
 17605 *       - if at the "left" side of a RTL | LTR point, you need a Right arrow
       
 17606 *       - if at the "right" side of a RTL | LTR point, you need a Left arrow.
       
 17607 *
       
 17608 */
       
 17609 // TKeyResponse CAknFepManager::AttemptCursorFlipAtAmbiguousPointL( const TKeyEvent& aKeyEvent, TEventCode aEventCode )
       
 17610 TKeyResponse CAknFepManager::AttemptCursorFlipAtAmbiguousPointL( const TUint aCode )
       
 17611     {
       
 17612     TKeyResponse response = EKeyWasNotConsumed;
       
 17613 
       
 17614     if ( IsFlagSet(EFlagAtDirectionallyAmbiguousPoint)  // only perform if already at ambi-point?
       
 17615         && !IsFlagSet(EFlagInsideInlineEditingTransaction) ) // do not flip if inside inline edit
       
 17616         {
       
 17617         if ( aCode == EKeyRightArrow || aCode == EKeyLeftArrow )
       
 17618             {
       
 17619             // Never use TextView() to get editor data, 
       
 17620             // use FepAwareTextEditor() condition instead of TextView()
       
 17621             if ( iInputCapabilities.FepAwareTextEditor() && EditorState() 
       
 17622             && AknFepDocumentNavigation() )
       
 17623                 {
       
 17624                 TTmDocPosSpec docPos = DocPos();
       
 17625                 TTextDirectionalInfo status = LocalTextDirectionalStatus( docPos );
       
 17626 
       
 17627                 CTmTextLayout::TTmChunkDescription leftChunk;
       
 17628                 CTmTextLayout::TTmChunkDescription rightChunk;
       
 17629                 FindAdjacentChunks(docPos, leftChunk, rightChunk);
       
 17630 
       
 17631                 if ( status.iBlockEnvironment == 
       
 17632                      TTextDirectionalInfo::EAtRightEndOfBlockFacingOppositeDirectionalBlock
       
 17633                     && aCode == EKeyRightArrow )
       
 17634                     {
       
 17635                     response = EKeyWasConsumed;
       
 17636                     // Set cursor to new directionality ( opposite to current )
       
 17637                     SetCursorTypeForTextDirection( status.iDirectionalStatus == 
       
 17638                                                    TTextDirectionalInfo::ERightToLeft );
       
 17639                     // Must actually change the docpos!
       
 17640                     AttachToRightChunk( docPos, rightChunk );
       
 17641                     SetCursorPositionL( docPos, ETrue ); // Drag any existing selection
       
 17642                     }
       
 17643                 else if (  status.iBlockEnvironment == 
       
 17644                            TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock
       
 17645                     && aCode == EKeyLeftArrow )
       
 17646                     {
       
 17647                     response = EKeyWasConsumed;
       
 17648                     // Effectively this toggles the direction of the cursor
       
 17649                     SetCursorTypeForTextDirection( status.iDirectionalStatus == 
       
 17650                                                    TTextDirectionalInfo::ERightToLeft );
       
 17651                     // Must actually change the docpos!
       
 17652                     AttachToLeftChunk( docPos, leftChunk );
       
 17653                     SetCursorPositionL( docPos, ETrue ); // Drag any existing selection
       
 17654                     }
       
 17655                 }
       
 17656             }
       
 17657         }
       
 17658     return response;
       
 17659     }
       
 17660 
       
 17661 
       
 17662 TInt CAknFepManager::PostEventCheckCallback(TAny* aObj)
       
 17663     {
       
 17664     TRAP_IGNORE(static_cast<CAknFepManager*>(aObj)->DoCursorDirectionCheckL());
       
 17665     return KErrNone;
       
 17666     }
       
 17667 
       
 17668 TBool CAknFepManager::BidiCursorRequired() const
       
 17669     {
       
 17670     return iDeviceSupportsRtlLanguage;
       
 17671     }
       
 17672 
       
 17673 void CAknFepManager::DoCursorDirectionCheckL()
       
 17674     {
       
 17675    iPostEventCheck->Cancel();
       
 17676     if(BidiCursorRequired()) 
       
 17677         {
       
 17678         AdjustCursorTypeForCurrentPosition();
       
 17679         }
       
 17680 
       
 17681     if ( !BidiCursorRequired() 
       
 17682     || (TAknFepUiIndicInputManager :: IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode)) ))
       
 17683             {
       
 17684 		/*Hindi*/
       
 17685     	if( ( !WesternPredictive() ) && 
       
 17686 			( TAknFepUiIndicInputManager::IsIndicLangauge( 
       
 17687 					TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) ) && 
       
 17688 			( ( TAknFepUiIndicInputManager::IsCharVirama( 
       
 17689 					PreviousChar( ETrue ), TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) ) 
       
 17690 #ifdef RD_MARATHI
       
 17691 			|| ( IsEyeLashRaPresentL() && 
       
 17692 			TAknFepUiIndicInputManager::IsCharVirama(
       
 17693 					PreviousToPreviousChar( ETrue ), TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) )
       
 17694 #endif
       
 17695 			)
       
 17696     		&& !( iInputCapabilities.SupportsSecretText() )
       
 17697     		)
       
 17698 			{
       
 17699 			TTmDocPosSpec pos = DocPos();
       
 17700 			pos.iType = TTmDocPosSpec::ETrailing;
       
 17701 		    TTmPosInfo2 info;
       
 17702 			TTmLineInfo lineInfo;
       
 17703 			TBool findAvailable = EFalse;
       
 17704 		    MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 17705 		    if (docNavi)
       
 17706 		    	{
       
 17707 			    docNavi->FindDocPos(pos, info, lineInfo);
       
 17708 			    findAvailable = ETrue;
       
 17709 		    	}
       
 17710 		    else
       
 17711 		    	{
       
 17712 				CTextLayout* textLayout = TextLayout();
       
 17713 	    		if ( textLayout )
       
 17714 	    			{
       
 17715 					textLayout->TagmaTextLayout().FindDocPos(pos, info, lineInfo);	    					    
       
 17716 					findAvailable = ETrue;
       
 17717 	    			}
       
 17718 		    	}
       
 17719 		    if (findAvailable)
       
 17720 		    	{
       
 17721 				TCursorSelection sel(info.iDocPos.iPos  ,info.iDocPos.iPos );
       
 17722 				iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);
       
 17723 		    	}
       
 17724 			}		
       
 17725 		}	
       
 17726     }
       
 17727 
       
 17728 void CAknFepManager::AdjustCursorTypeForCurrentPosition()
       
 17729     {
       
 17730     
       
 17731     // Never use TextView() to get editor data, 
       
 17732     // use FepAwareTextEditor() condition instead of TextView()
       
 17733     if ( iInputCapabilities.FepAwareTextEditor() && EditorState() 
       
 17734     && AknFepDocumentNavigation())
       
 17735         AdjustCursorTypeForPosition( DocPos() );
       
 17736     }
       
 17737 
       
 17738 void CAknFepManager::SchedulePostEventCheckL( TUint aCode )
       
 17739     {
       
 17740     
       
 17741     TBool isToPostEvent   = EFalse;    
       
 17742     TBool isIndicLanguage = TAknFepUiIndicInputManager :: 
       
 17743                             IsIndicLangauge(TLanguage(iLanguageCapabilities.iInputLanguageCode));
       
 17744     
       
 17745     if ( BidiCursorRequired() )
       
 17746         {
       
 17747         switch ( aCode )
       
 17748             {
       
 17749             // Navigation cases:
       
 17750             case EKeyDownArrow:
       
 17751             case EKeyUpArrow:            
       
 17752             case EPtiKey1:
       
 17753             case EPtiKey2:
       
 17754             case EPtiKey3:
       
 17755             case EPtiKey4:
       
 17756             case EPtiKey5:
       
 17757             case EPtiKey6:
       
 17758             case EPtiKey7:
       
 17759             case EPtiKey8:
       
 17760             case EPtiKey9:
       
 17761             case EPtiKey0:
       
 17762                  {
       
 17763                     isToPostEvent = ETrue;
       
 17764                  }
       
 17765                  break;
       
 17766             case EKeyBackspace:
       
 17767             case EKeyDelete:
       
 17768                 {
       
 17769                     if(!isIndicLanguage)
       
 17770                     {
       
 17771                         isToPostEvent = ETrue;
       
 17772                     }
       
 17773                 }
       
 17774                 break;
       
 17775             case EKeyLeftArrow:
       
 17776             case EKeyRightArrow:
       
 17777                 {
       
 17778                     if(!isIndicLanguage)
       
 17779                     {
       
 17780                         isToPostEvent = ETrue;
       
 17781                     }
       
 17782                 }
       
 17783                 break;                
       
 17784             default:
       
 17785                 break;
       
 17786             }
       
 17787 
       
 17788         // If Repha has been inserted then do not post event.
       
 17789         if( isIndicLanguage )
       
 17790             {
       
 17791             if( aCode == EPtiKey1 && ( !iQwertyInputMode ) )
       
 17792                 {
       
 17793                 if( IsRephaPresent() 
       
 17794 #ifdef RD_MARATHI
       
 17795                 || IsEyeLashRaPresentL()
       
 17796 #endif
       
 17797                 )
       
 17798                     {
       
 17799                     isToPostEvent = EFalse;
       
 17800                     }
       
 17801                 }
       
 17802             }
       
 17803         }
       
 17804               
       
 17805         if(isIndicLanguage) // iQwertyInputMode check is added so as to ensure that the event is not posted for Qwerty mode. 
       
 17806         {
       
 17807             if((aCode == EKeyBackspace || aCode == EKeyDelete) && (!iQwertyInputMode))
       
 17808             {
       
 17809                 isToPostEvent = ETrue;
       
 17810             }           
       
 17811         } 
       
 17812         
       
 17813         if(isToPostEvent)
       
 17814         {
       
 17815             if ( iPostEventCheck->IsActive() )
       
 17816                 iPostEventCheck->Cancel();
       
 17817             iPostEventCheck->Start( TCallBack(PostEventCheckCallback, this) );
       
 17818         }                   
       
 17819     }
       
 17820 
       
 17821 void CAknFepManager::AdjustCursorTypeForPosition( const TTmDocPosSpec& aDocPos )
       
 17822     {
       
 17823 
       
 17824     TTextDirectionalInfo dirInfo = LocalTextDirectionalStatus( aDocPos );
       
 17825     // default clearing of this flag
       
 17826     ClearFlag( EFlagAtDirectionallyAmbiguousPoint );
       
 17827 
       
 17828     switch ( dirInfo.iBlockEnvironment )
       
 17829         {
       
 17830         case TTextDirectionalInfo::EUndefined:
       
 17831             // Set according to input direction
       
 17832             SetCursorTypeForTextDirection( CurrentInputDirectionality() == 
       
 17833                                            TBidiText::ELeftToRight );
       
 17834             break; // do nothing
       
 17835 
       
 17836         // All unambiguous cases
       
 17837         case TTextDirectionalInfo::EInsideBlock:
       
 17838         case TTextDirectionalInfo::EAtRightEndOfLine:
       
 17839         case TTextDirectionalInfo::EAtLeftEndOfLine:
       
 17840         case TTextDirectionalInfo::EAtRightEndOfBlockFacingSameDirectionBlock:
       
 17841         case TTextDirectionalInfo::EAtLeftEndOfBlockFacingSameDirectionBlock:
       
 17842             SetCursorTypeForTextDirection( dirInfo.iDirectionalStatus == 
       
 17843                                            TTextDirectionalInfo::ELeftToRight );
       
 17844             break;
       
 17845 
       
 17846         // Ambiguous. Navigation has resulted in an ambiguous visual position. Set cursor according
       
 17847         // to current direction
       
 17848         case TTextDirectionalInfo::EAtRightEndOfBlockFacingOppositeDirectionalBlock:
       
 17849         case TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock:
       
 17850             SetCursorTypeForTextDirection( dirInfo.iDirectionalStatus == 
       
 17851                                            TTextDirectionalInfo::ELeftToRight );
       
 17852             SetFlag( EFlagAtDirectionallyAmbiguousPoint );
       
 17853             break;
       
 17854         default:
       
 17855             // Do nothing
       
 17856             break;
       
 17857         }
       
 17858     }
       
 17859 
       
 17860 void CAknFepManager::SetCursorTypeForTextDirection( TBool aLeftToRight )
       
 17861     {
       
 17862     SetCursorType( aLeftToRight );
       
 17863     }
       
 17864 
       
 17865 void CAknFepManager::SetCursorTypeForInputDirection( TBool /*aLeftToRight*/ )
       
 17866     {
       
 17867     // Do nothing
       
 17868     }
       
 17869 
       
 17870 CAknFepManager::TTextDirectionalInfo CAknFepManager::
       
 17871                                LocalTextDirectionalStatus( const TTmDocPosSpec& aDocPos ) const
       
 17872     {
       
 17873     TTextDirectionalInfo directionalInfo;
       
 17874 
       
 17875     MCoeFepAwareTextEditor* fepAwareTextEditor = iInputCapabilities.FepAwareTextEditor();
       
 17876     if ( !fepAwareTextEditor )
       
 17877         return directionalInfo;
       
 17878 
       
 17879     if ( aDocPos.iPos < 0 ) // somehow, we are before the first character
       
 17880         directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ENotInDocument;
       
 17881     else if ( aDocPos.iPos > fepAwareTextEditor->DocumentLengthForFep() ) // (iPos = docLen still is within document)
       
 17882         directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ENotInDocument;
       
 17883     else if ( fepAwareTextEditor->DocumentLengthForFep() == 0 ) // zero length; no document
       
 17884         directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ENotInDocument;
       
 17885 
       
 17886     if ( directionalInfo.iDirectionalStatus == TTextDirectionalInfo::EUnknown )
       
 17887         {
       
 17888         CTmTextLayout::TTmChunkDescription leftChunk;
       
 17889         CTmTextLayout::TTmChunkDescription rightChunk;
       
 17890         FindAdjacentChunks(aDocPos, leftChunk, rightChunk);
       
 17891 
       
 17892     // Cases:
       
 17893     // position is within a chunk (chunks are continuous in logical index and same directionality.
       
 17894     //  ->Return directionality
       
 17895     // position is betweeen two chunks of opposite directionality
       
 17896     //  -> return simple ambiguity
       
 17897     // position is between two chnks of same directionality, but logical index is not contiguous
       
 17898     //  -> return complex ambiguity ; return directionality
       
 17899 
       
 17900         if ( leftChunk.iStart == -1 && rightChunk.iStart == -1 ) // 2 chunks invalid; direction stays EUnkonwn
       
 17901             {
       
 17902             directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ENoDirectionalChunks;
       
 17903             }
       
 17904         else if ( leftChunk.iStart == -1 )  // no left block
       
 17905             {
       
 17906             directionalInfo.iBlockEnvironment = TTextDirectionalInfo::EAtLeftEndOfLine;
       
 17907             directionalInfo.SetDirectionFromChunk( rightChunk );
       
 17908             }
       
 17909         else if ( rightChunk.iStart == -1 ) // no right block
       
 17910             {
       
 17911             directionalInfo.iBlockEnvironment = TTextDirectionalInfo::EAtRightEndOfLine;
       
 17912             directionalInfo.SetDirectionFromChunk( leftChunk );
       
 17913             }
       
 17914         // Both chunks are the same direction.
       
 17915         // We are either nicely inside a block or the two blocks are at +/- 2, 4, etc levels
       
 17916         else if ( COMPARE_BOOLS( leftChunk.iRightToLeft, rightChunk.iRightToLeft ) )
       
 17917             {
       
 17918             // Can set direction from either chunk; use left one
       
 17919             directionalInfo.SetDirectionFromChunk( leftChunk );
       
 17920 
       
 17921             if (leftChunk.iRightToLeft )
       
 17922                 {
       
 17923                 if ( leftChunk.iStart == rightChunk.iEnd ) // chunks are continguous
       
 17924                     directionalInfo.iBlockEnvironment = TTextDirectionalInfo::EInsideBlock;
       
 17925                 else // Chunks are separated by 2, 4 etc. levels
       
 17926                     directionalInfo.iBlockEnvironment = ( aDocPos.iPos == leftChunk.iStart ) ?
       
 17927                         TTextDirectionalInfo::EAtRightEndOfBlockFacingSameDirectionBlock :
       
 17928                         TTextDirectionalInfo::EAtLeftEndOfBlockFacingSameDirectionBlock;
       
 17929                 }
       
 17930             else
       
 17931                 {
       
 17932                 if ( leftChunk.iEnd == rightChunk.iStart ) // chunks are continguous
       
 17933                     directionalInfo.iBlockEnvironment = TTextDirectionalInfo::EInsideBlock;
       
 17934                 else // Chunks are separated by 2, 4 etc. levels
       
 17935                     directionalInfo.iBlockEnvironment = ( aDocPos.iPos == leftChunk.iEnd ) ?
       
 17936                         TTextDirectionalInfo::EAtRightEndOfBlockFacingSameDirectionBlock :
       
 17937                         TTextDirectionalInfo::EAtLeftEndOfBlockFacingSameDirectionBlock;
       
 17938                 }
       
 17939             }
       
 17940         else // Blocks are in opposite direction. Have to deal with all the values of the iType enum
       
 17941             {
       
 17942             TInt charPos;
       
 17943             switch( aDocPos.iType )
       
 17944                 {
       
 17945                 case TTmDocPosSpec::ETrailing: // position follows a block End
       
 17946                     {
       
 17947                     charPos = aDocPos.iPos - 1; //  attachment is to character[iPos-1] - now find it
       
 17948                     if ( leftChunk.iStart <= charPos && charPos < leftChunk.iEnd ) // pos is in left chunk
       
 17949                         {
       
 17950                         directionalInfo.SetDirectionFromChunk( leftChunk );
       
 17951                         directionalInfo.iBlockEnvironment = 
       
 17952                             TTextDirectionalInfo::EAtRightEndOfBlockFacingOppositeDirectionalBlock;
       
 17953                         }
       
 17954                     else if( rightChunk.iStart <= charPos && charPos < rightChunk.iEnd ) // pos is in right chunk
       
 17955                         {
       
 17956                         directionalInfo.SetDirectionFromChunk( rightChunk );
       
 17957                         directionalInfo.iBlockEnvironment = 
       
 17958                             TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock;
       
 17959                         }
       
 17960                     else // Probably impossible situation.  Supply reasonable defaults rather than panicking
       
 17961                         {
       
 17962                         directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ELeftToRight;
       
 17963                         directionalInfo.iBlockEnvironment = 
       
 17964                             TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock;
       
 17965                         }
       
 17966                     break;
       
 17967                     }
       
 17968                 case TTmDocPosSpec::ELeading: // position precedes a block start
       
 17969                     {
       
 17970                     charPos = aDocPos.iPos; //  attachment is to character[iPos] - now find it
       
 17971                     if ( leftChunk.iStart <= charPos && charPos < leftChunk.iEnd ) // pos is in left chunk
       
 17972                         {
       
 17973                         directionalInfo.SetDirectionFromChunk( leftChunk );
       
 17974                         directionalInfo.iBlockEnvironment = 
       
 17975                             TTextDirectionalInfo::EAtRightEndOfBlockFacingOppositeDirectionalBlock;
       
 17976                         }
       
 17977                     else if( rightChunk.iStart <= charPos && charPos < rightChunk.iEnd ) // pos is in right chunk
       
 17978                         {
       
 17979                         directionalInfo.SetDirectionFromChunk( rightChunk );
       
 17980                         directionalInfo.iBlockEnvironment = 
       
 17981                             TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock;
       
 17982                         }
       
 17983                     else // Probably impossible situation.  Supply reasonable defaults rather than panicking
       
 17984                         {
       
 17985                         directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ELeftToRight;
       
 17986                         directionalInfo.iBlockEnvironment = 
       
 17987                             TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock;
       
 17988                         }
       
 17989                     break;
       
 17990                     }
       
 17991                 case TTmDocPosSpec::ELeftToRight: // Is attached to a Left to right block
       
 17992                     {
       
 17993                     directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ELeftToRight;
       
 17994                     // If left chunk is RTL, then we are NOT attached to that left block
       
 17995                     // (ie. we are at left end of the right block)
       
 17996                     directionalInfo.iBlockEnvironment = leftChunk.iRightToLeft ?
       
 17997                         TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock : // must be in right chunk then (left end of it)
       
 17998                         TTextDirectionalInfo::EAtRightEndOfBlockFacingOppositeDirectionalBlock; // else in left chunk (right end of it)
       
 17999                     break;
       
 18000                     }
       
 18001                 case TTmDocPosSpec::ERightToLeft:
       
 18002                     {
       
 18003                     directionalInfo.iDirectionalStatus = TTextDirectionalInfo::ERightToLeft;
       
 18004                     // If left chunk if RTL, then we are attached to that left block (ie. at right end of it)
       
 18005                     directionalInfo.iBlockEnvironment = leftChunk.iRightToLeft ? // is it in left chunk?
       
 18006                         TTextDirectionalInfo::EAtRightEndOfBlockFacingOppositeDirectionalBlock : // right end of left chunk
       
 18007                         TTextDirectionalInfo::EAtLeftEndOfBlockFacingOppositeDirectionalBlock;
       
 18008                     break;
       
 18009                     }
       
 18010                 }
       
 18011 
       
 18012             }
       
 18013         }
       
 18014     return directionalInfo;
       
 18015     }
       
 18016 
       
 18017 
       
 18018 /**
       
 18019 * Redecoration is carried out if a neutral is exposed by the deletion to a directionality
       
 18020 * different to that which is was already marked.
       
 18021 *
       
 18022 * The routine leaves iUncommittedText again set to the (possibly new) cursor position.
       
 18023 *
       
 18024 */
       
 18025 void CAknFepManager::RedecorateAfterDeletionL( const TDesC& aTextThatWasDeleted  )
       
 18026     {
       
 18027     if (!EditorSupportsNeutralProtection())
       
 18028         return;
       
 18029 
       
 18030     if ( aTextThatWasDeleted.Length() == 0 )
       
 18031         return;
       
 18032 
       
 18033     TBool protect = ETrue;
       
 18034 
       
 18035     // Set up iUncommittedText with the current cursor position so that PreviousChar will work:
       
 18036     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 18037 
       
 18038     TTmDocPosSpec docPos = DocPos();
       
 18039     TInt docLen = iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 18040 
       
 18041     TInt previousPos = docPos.iPos;
       
 18042     // Trailing iType actually points to character at index iPos - 1
       
 18043     if( docPos.iType == TTmDocPosSpec::ETrailing )
       
 18044         previousPos = previousPos -= 1;
       
 18045     TInt nextPos = previousPos + 1;
       
 18046 
       
 18047     // Perform no neutral protection if the beginning of the text is deleted.
       
 18048     // Note that there MAY be protection occuring if the delete is from the end so there is
       
 18049     // no corresponding test on DocLength. That is handled later where the paragraph direction
       
 18050     // is used for the "forward" directionality.
       
 18051     if ( previousPos < 0 )
       
 18052         return;
       
 18053 
       
 18054     // Up to 2 protection characters, one RTL and one LTR
       
 18055     TBuf<2> textToInsert;
       
 18056 
       
 18057     TBool adjacentPrecedingIsNeutral(EFalse);
       
 18058     TBool adjacentTrailingIsNeutral(EFalse);
       
 18059 
       
 18060     // See if either preceding or next is neutral
       
 18061     adjacentPrecedingIsNeutral = iInlineTextDecorator->CharacterIsNeutral( CharAt(previousPos) );
       
 18062     if ( nextPos < docLen )
       
 18063         adjacentTrailingIsNeutral = iInlineTextDecorator->CharacterIsNeutral( CharAt(nextPos) );
       
 18064 
       
 18065     if ( !adjacentPrecedingIsNeutral && !adjacentTrailingIsNeutral )
       
 18066         protect = EFalse;
       
 18067 
       
 18068     // Inits actually correspond to LTR, but they are only used if the bools indicating
       
 18069     // strong directionality found get set
       
 18070     TBool directionPrecedingDeleteIsRTL(EFalse);
       
 18071     TBool directionTrailingDeleteIsRTL(EFalse);
       
 18072     if ( protect )
       
 18073         {
       
 18074         TBool strongPreceding = GetExposedDirectionOfText( previousPos, EFalse, 
       
 18075                                                            directionPrecedingDeleteIsRTL );
       
 18076         TBool strongTrailing = GetExposedDirectionOfText( nextPos, ETrue, 
       
 18077                                                           directionTrailingDeleteIsRTL );
       
 18078         if (!strongTrailing)
       
 18079             {
       
 18080             TBool isRTLPara = IsRightToLeftParagraph(docPos);
       
 18081             directionTrailingDeleteIsRTL = isRTLPara;
       
 18082             strongTrailing = ETrue;
       
 18083             }
       
 18084         if ( !strongPreceding || !strongTrailing) // Must have strong in both directions
       
 18085             protect = EFalse;
       
 18086         else if ( COMPARE_BOOLS( directionPrecedingDeleteIsRTL, directionTrailingDeleteIsRTL ) ) // Must differ
       
 18087             protect = EFalse;
       
 18088         }
       
 18089 
       
 18090     TBool forwardProtection(EFalse);
       
 18091 
       
 18092     if ( protect )
       
 18093         {
       
 18094         protect = EFalse;
       
 18095         TBool deletedWasRTL;
       
 18096 
       
 18097         // Check for and do reverse protection
       
 18098         if ( adjacentPrecedingIsNeutral )
       
 18099             {
       
 18100             TBool deletedTextIsStrong = GetExposedDirectionOfTextInDescriptor( aTextThatWasDeleted, 
       
 18101                                                                                ETrue, 
       
 18102                                                                                deletedWasRTL ); // search forward into deleted stuff
       
 18103             if ( deletedTextIsStrong && (directionPrecedingDeleteIsRTL == deletedWasRTL))
       
 18104                 {
       
 18105                 protect = ETrue;
       
 18106                 forwardProtection = EFalse;
       
 18107                 if ( deletedWasRTL )
       
 18108                     textToInsert.Append( CAknFepInlineTextDecorator::ERightToLeftMark );
       
 18109                 else
       
 18110                     textToInsert.Append( CAknFepInlineTextDecorator::ELeftToRightMark );
       
 18111                 }
       
 18112             }
       
 18113 
       
 18114         // Check for and do forward protection
       
 18115         // Note it is possible to have both forward and reverse redecoration.
       
 18116         if ( adjacentTrailingIsNeutral )
       
 18117             {
       
 18118             TBool deletedTextIsStrong = GetExposedDirectionOfTextInDescriptor( aTextThatWasDeleted, 
       
 18119                                                                                EFalse, 
       
 18120                                                                                deletedWasRTL ); // search backward in deleted stuff
       
 18121             if (deletedTextIsStrong && (directionTrailingDeleteIsRTL == deletedWasRTL) )
       
 18122                 {
       
 18123                 protect = ETrue;
       
 18124                 forwardProtection = ETrue;
       
 18125                 if ( deletedWasRTL )
       
 18126                     textToInsert.Append( CAknFepInlineTextDecorator::ERightToLeftMark );
       
 18127                 else
       
 18128                     textToInsert.Append( CAknFepInlineTextDecorator::ELeftToRightMark );
       
 18129                 }
       
 18130             }
       
 18131         }
       
 18132 
       
 18133 
       
 18134     if ( protect )
       
 18135         {
       
 18136         StartInlineEditL(textToInsert);
       
 18137         CommitInlineEditWithoutResolutionL(*(iInputCapabilities.FepAwareTextEditor()), ETrue);
       
 18138         // iUncommittedText is now set to correct value by the Commitxxxx method
       
 18139         // Document position is adjusted to as to keep the cursor stable.
       
 18140         // Make a docPos. If reverse protection, then the position should trail
       
 18141         TTmDocPosSpec docPos( iUncommittedText.LowerPos() , TTmDocPosSpec::ETrailing );
       
 18142         // But if there has been forward Protection, then we have to back up the cursor by 1
       
 18143         // and lead. (This is OK too, if there is simultaneous reversse and forward protection)
       
 18144         if ( forwardProtection )
       
 18145             {
       
 18146             docPos.iPos = Max(docPos.iPos - 1, 0 );
       
 18147             docPos.iType = TTmDocPosSpec::ELeading;
       
 18148             }
       
 18149         SetCursorPositionL( docPos );
       
 18150         }
       
 18151     }
       
 18152 
       
 18153 TBool CAknFepManager::EditorSupportsNeutralProtection()
       
 18154     {
       
 18155     TBool ret = ETrue;
       
 18156     if ( !IsFepAwareTextEditor() )
       
 18157         ret = EFalse;
       
 18158 
       
 18159     else if (iInputCapabilities.SupportsSecretText())
       
 18160         ret = EFalse;
       
 18161 
       
 18162     else if ( iAknEditorFlags & EAknEditorFlagLatinInputModesOnly )
       
 18163         ret = EFalse;
       
 18164 
       
 18165     else if (iPermittedInputModes == EAknEditorNumericInputMode)
       
 18166         ret = EFalse;
       
 18167 
       
 18168     else if ( !CharIsValidInEditor( CAknFepInlineTextDecorator::ERightToLeftMark ) )
       
 18169         ret = EFalse;
       
 18170 
       
 18171     return ret;
       
 18172     }
       
 18173 
       
 18174 void CAknFepManager::CommitInlineEditWithoutResolutionL(MCoeFepAwareTextEditor& aFepAwareTextEditor, 
       
 18175                                                         TBool aCursorVisibility , TBool aClearPti )
       
 18176     {
       
 18177     aFepAwareTextEditor.SetInlineEditingCursorVisibilityL(aCursorVisibility);
       
 18178     /*
       
 18179     On any call to CommitFepInlineEditL, the mode will change
       
 18180     even when a leave event occurs.
       
 18181     */
       
 18182     ClearFlag(EFlagInsideInlineEditingTransaction | EFlagInsideMultitapInlineEditingTransaction);
       
 18183     ClearCcpuFlag(ECcpuStateNewPredictiveWord);
       
 18184     
       
 18185     if(aClearPti)
       
 18186         {
       
 18187         iPtiEngine->CommitCurrentWord();
       
 18188         }
       
 18189     CCoeEnv* coeEnv = CCoeEnv::Static();
       
 18190     aFepAwareTextEditor.CommitFepInlineEditL(*coeEnv);
       
 18191     aFepAwareTextEditor.GetCursorSelectionForFep(iUncommittedText);
       
 18192     // iMatchState=EWordMatchFirst;
       
 18193     iCaseMan->UpdateCase(ENullNaviEvent);
       
 18194     }
       
 18195 
       
 18196 void CAknFepManager::WordConcatenationTimerTimeoutL()
       
 18197     {
       
 18198     iConcatenationTimer->Cancel();
       
 18199 
       
 18200     // add concatenated word to the UDB (a concatenated word is a compound word)
       
 18201     AddCompoundWordToUdbL();
       
 18202 
       
 18203 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 18204 	MoveCursorToEndOfWordL();
       
 18205 #endif
       
 18206     }
       
 18207 
       
 18208 
       
 18209 TKeyResponse CAknFepManager::HandlePredictiveNaviEventOutsideInlineEditL(TUint aCode, 
       
 18210                                                                          TKeyPressLength aLength)
       
 18211     {
       
 18212     TKeyResponse response = EKeyWasNotConsumed;
       
 18213 
       
 18214     TWesternNaviEvent naviEvent = ENullNaviEvent;
       
 18215     if (aCode == EKeyLeftArrow)
       
 18216         {
       
 18217         naviEvent = ELeftNaviEvent;
       
 18218         }
       
 18219     else if (aCode == EKeyRightArrow)
       
 18220         {
       
 18221         naviEvent = ERightNaviEvent;
       
 18222         }
       
 18223     else if (aCode == EKeyBackspace)
       
 18224         {
       
 18225         naviEvent = EBackspaceEvent;
       
 18226         }
       
 18227 
       
 18228     TInt nextCharPos = 0;  // Character ordinal in logical memory (0 - n-1)
       
 18229     TBool nextPositionFound = EFalse;
       
 18230     if ( naviEvent == ERightNaviEvent )
       
 18231         {
       
 18232         nextPositionFound = GetNextVisualRightCharacter( nextCharPos );
       
 18233         }
       
 18234     else if ( naviEvent == ELeftNaviEvent )
       
 18235         {
       
 18236         nextPositionFound = GetNextVisualLeftCharacter( nextCharPos );
       
 18237         }
       
 18238     else if ( naviEvent == EBackspaceEvent )
       
 18239         {
       
 18240         if (iLanguageCapabilities.iRightToLeftLanguage)
       
 18241             {
       
 18242             TChar character = PreviousChar();
       
 18243             TChar::TBdCategory bdCategory = character.GetBdCategory();
       
 18244             // In case last character in buffer is number or Latin characters, needs to delete 
       
 18245             // character from left.
       
 18246             if (TChar::EEuropeanNumber == bdCategory || TChar::EArabicNumber == bdCategory ||
       
 18247                 TChar::ELeftToRight == bdCategory )
       
 18248                 {
       
 18249                 nextPositionFound = GetNextVisualLeftCharacter( nextCharPos );
       
 18250                 }
       
 18251             else
       
 18252                 {
       
 18253                 nextPositionFound = GetNextVisualRightCharacter( nextCharPos );
       
 18254                 }
       
 18255             }
       
 18256         else
       
 18257             {
       
 18258             nextPositionFound = GetNextVisualLeftCharacter( nextCharPos );
       
 18259             }
       
 18260         }
       
 18261 
       
 18262     if ( !nextPositionFound )
       
 18263         {
       
 18264         response = EKeyWasNotConsumed;
       
 18265         }
       
 18266     else // not looping - lets see what to do
       
 18267         {
       
 18268         TBuf<ESingleCharacter> characterBuffer;
       
 18269         iInputCapabilities.FepAwareTextEditor()->GetEditorContentForFep(characterBuffer, 
       
 18270                                                                         nextCharPos, 
       
 18271                                                                         ESingleCharacter);
       
 18272 
       
 18273         if ( !IsValidInLineCharacter( STATIC_CAST(TChar, characterBuffer[0])) )
       
 18274             {
       
 18275             // if the character is a non-alpha character; let it go
       
 18276             response=EKeyWasNotConsumed;
       
 18277             if (IsFlagSet(EFlagCompoundWord))
       
 18278                 {
       
 18279                 if  (STATIC_CAST(TChar, characterBuffer[0]).IsSpace())
       
 18280                     // we are navigating over a space so add any current compond word to the udb
       
 18281                     AddCompoundWordToUdbL();
       
 18282                 ClearFlag(EFlagCompoundWord);
       
 18283                 }
       
 18284         //allow to popup editsubmenu        
       
 18285         ClearCcpuFlag(ECcpuStateIgnoreStarUp);
       
 18286             }
       
 18287         else
       
 18288             {
       
 18289             if (FepUI()->HandleKeyL(aCode, aLength))
       
 18290                 {
       
 18291                 response=EKeyWasConsumed;
       
 18292                 }
       
 18293             }
       
 18294         }
       
 18295     return response;
       
 18296     }
       
 18297 
       
 18298 /**
       
 18299  * Call back function:
       
 18300  */
       
 18301 TInt CAknFepManager::DoSimulateKey(TAny* aThisPtr)
       
 18302     {
       
 18303     CAknFepManager* myobj = static_cast<CAknFepManager*>(aThisPtr);
       
 18304     TRAPD(error, myobj->HandleOwnedSimulateKeyL());
       
 18305     return error;
       
 18306     }
       
 18307 
       
 18308 void CAknFepManager::HandleOwnedSimulateKeyL()
       
 18309     {
       
 18310 #ifdef RD_INTELLIGENT_TEXT_INPUT         
       
 18311 #ifdef __HALF_QWERTY_KEYPAD
       
 18312         if( KeyboardLayout() == EPtiKeyboardHalfQwerty )
       
 18313             {            
       
 18314             CCoeEnv::Static()->SimulateKeyEventL( iHalfQwertyLastKeyEvent, EEventKey );
       
 18315             }        
       
 18316         else
       
 18317 #endif //__HALF_QWERTY_KEYPAD        
       
 18318 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 18319     if (iSimulateKey > 0)
       
 18320         {
       
 18321         HandleKeyEventL(iSimulateKey, EShortKeyPress);
       
 18322         iSimulateKey = 0;
       
 18323         }
       
 18324     }
       
 18325 
       
 18326 /**
       
 18327  * This method is that the label of CBA is updated by aTextResId.
       
 18328  * @param aPosition   CBA position, either ELeftSoftkeyIndex or ERightSoftkeyIndex
       
 18329  * @param aCommandId  command id for softkey
       
 18330  * @param aTextResId  resource id to set string on label.
       
 18331  * @return TBool The return value is ETrue in case it is necessary to update CBA.
       
 18332  */
       
 18333 TBool CAknFepManager::UpdateCBALabelL(TInt aPosition, TInt aCommandId, TInt aTextResId)
       
 18334     {
       
 18335     return iUiInterface->UpdateSoftkeyLabelL(aPosition, aCommandId, aTextResId);
       
 18336     }
       
 18337 
       
 18338 void CAknFepManager::DoLaunchSctAndPctL(TInt aResourceId, TShowSctMode aShowSctMode)
       
 18339     {
       
 18340     TBool replace = EFalse;
       
 18341     TBool disableRecentItemRow = EFalse;
       
 18342     
       
 18343     if (ExtendedInputCapabilities() & CAknExtendedInputCapabilities::EDisableSCT)
       
 18344         {
       
 18345         // The editor doesn't allow SCT.
       
 18346         return;
       
 18347         }
       
 18348     if ( EditorType() == CAknExtendedInputCapabilities::EEikSecretEditorBased )
       
 18349         {
       
 18350         
       
 18351         disableRecentItemRow = ETrue;
       
 18352         }    
       
 18353     
       
 18354     if (IsCcpuFlagSet(ECcpuStateCbaSymbol) && 
       
 18355         iMode == ELatin && WesternPredictive(ELatin) && 
       
 18356         iPtiEngine->LastEnteredKey() == EPtiKey1)
       
 18357         {
       
 18358         // User is entering special character as result of pressing key '1' and
       
 18359         // cycling through candidates until left softkey turns into "Symbol". In
       
 18360         // that case we want to replace last cahracter instead of adding new one.
       
 18361         replace = ETrue;
       
 18362         }
       
 18363     
       
 18364     //Commit characters in latin multitap as some editors may call CancelFepTransaction()
       
 18365     //which will be received before the focus change notification.
       
 18366     if (IsFeatureSupportedJapanese())
       
 18367         {
       
 18368         TryCloseUiL();
       
 18369         }
       
 18370     else
       
 18371         {
       
 18372 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 18373         if(!(WesternPredictive()))
       
 18374 #endif
       
 18375         CommitInlineEditL();
       
 18376         }
       
 18377 
       
 18378     if (!EditorHasFreeSpace())
       
 18379         {
       
 18380         return;
       
 18381         }
       
 18382     
       
 18383     // get the SCT resource id from editor default settings
       
 18384     TInt currentEditorSCTResId = GetCurrentEditorSCTResId();
       
 18385     TInt charMap = aResourceId;
       
 18386     if ( FeatureManager::FeatureSupported(KFeatureIdChinese) )
       
 18387         {        
       
 18388         if (charMap == R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG)
       
 18389             {
       
 18390             charMap = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_CHINESE;
       
 18391             }
       
 18392         }
       
 18393     else if ( FeatureManager::FeatureSupported(KFeatureIdKorean) )
       
 18394         {     
       
 18395         // Use the special sct resource file for Korean variant.
       
 18396         if (charMap == R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG)
       
 18397             {
       
 18398             charMap = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_KOREAN;
       
 18399             }
       
 18400         }
       
 18401     if (!charMap)
       
 18402         {
       
 18403         // override numeric keymap if necessary. flag is for non standard charmaps
       
 18404         TInt standardNumericCharMap = EDefaultNumericCharMapResId;
       
 18405         if ((iMode == ENumber || iMode == ENativeNumber) &&
       
 18406             !(iAknEditorFlags & EAknEditorFlagUseSCTNumericCharmap) &&
       
 18407             (iCharWidth == EHalfWidthChar) &&
       
 18408             ( (iAknEditorNumericKeymap != EAknEditorAlphanumericNumberModeKeymap) ||
       
 18409               (iPermittedInputModes == EAknEditorNumericInputMode) ))
       
 18410             {
       
 18411             standardNumericCharMap = NumericModeSCTResourceId();
       
 18412             }
       
 18413         charMap = standardNumericCharMap;
       
 18414         }
       
 18415         
       
 18416     if ( charMap == ENoCharacters && !IsAbleToLaunchSCT())
       
 18417         {
       
 18418     	currentEditorSCTResId = charMap;
       
 18419         }
       
 18420     if(R_AKNFEP_SCT_NUMERIC_MODE_CHARS_PLAIN == charMap)
       
 18421         {
       
 18422         TBool isEmpty = ETrue;
       
 18423         TRAP_IGNORE(isEmpty = GetSctLengthL(charMap));
       
 18424         if(isEmpty)
       
 18425            {
       
 18426            return;
       
 18427            }
       
 18428         }
       
 18429 
       
 18430     if (currentEditorSCTResId)
       
 18431         {
       
 18432         TBuf<32> specialChars;
       
 18433 
       
 18434         TInt sctChars = EAknSCTChiChineseInputModes;
       
 18435         TInt afterSctChars = EAknSCTHalfCase;
       
 18436 
       
 18437         if (iCharWidth == EFullWidthChar)
       
 18438             {
       
 18439             sctChars = EAknSCTFullCase;
       
 18440             if (iMode == ELatin)
       
 18441                 {
       
 18442                 afterSctChars = EAknSCTUpperCase;
       
 18443                 if (iCaseMan->CurrentCase() == EAknEditorLowerCase)
       
 18444                     {
       
 18445                     afterSctChars = EAknSCTLowerCase;
       
 18446                     }
       
 18447                 }
       
 18448             else if (iMode == ENumber||iMode == ENativeNumber)
       
 18449                 {
       
 18450                 afterSctChars = EAknSCTLowerCase;
       
 18451                 }
       
 18452             }
       
 18453         else
       
 18454             {
       
 18455             if (iMode == ELatin)
       
 18456                 {
       
 18457                 if ( FeatureManager::FeatureSupported(KFeatureIdChinese) )
       
 18458                     {
       
 18459                     sctChars = EAknSCTChiLatinInputModes;
       
 18460                     }
       
 18461                 else
       
 18462                     {
       
 18463                     if (iQwertyInputMode)
       
 18464                         {
       
 18465                         sctChars = EAknSCTQwerty;
       
 18466                         afterSctChars = EAknSCTFullCase;                        
       
 18467                         }
       
 18468                     else
       
 18469                         {                                           
       
 18470                         sctChars = EAknSCTUpperCase;
       
 18471                         afterSctChars = EAknSCTFullCase;
       
 18472                         if (iCaseMan->CurrentCase() == EAknEditorLowerCase)
       
 18473                             {
       
 18474                             sctChars = EAknSCTLowerCase;
       
 18475                             }
       
 18476                         }
       
 18477                     }
       
 18478                 }
       
 18479             else if (iMode == ENumber||iMode == ENativeNumber)
       
 18480                 {
       
 18481                 sctChars = EAknSCTNumeric;
       
 18482                 if ( ((iAknEditorFlags & EAknEditorFlagUseSCTNumericCharmap) ||
       
 18483                       (iAknEditorNumericKeymap == EAknEditorAlphanumericNumberModeKeymap)) &&
       
 18484                       !IsOnlyHalfWidthCharacterPermitted() )
       
 18485                     {
       
 18486                     sctChars = EAknSCTLowerCase;
       
 18487                     afterSctChars = EAknSCTFullCase;
       
 18488                     }
       
 18489                 }
       
 18490             else if (iMode == EHiraganaKanji)
       
 18491                 {
       
 18492                 sctChars = EAknSCTFullCase;
       
 18493                 }
       
 18494             else if(iMode == EKatakana)
       
 18495                 {
       
 18496                 sctChars = EAknSCTHalfCase;
       
 18497                 afterSctChars = EAknSCTFullCase;
       
 18498                 }
       
 18499             }
       
 18500 
       
 18501         SetFlag(EFlagForegroundUIComponentVisible);
       
 18502 
       
 18503         TBool showAnotherTable = EFalse;
       
 18504         if (IsFeatureSupportedJapanese())
       
 18505             {
       
 18506             if (sctChars == EAknSCTFullCase)
       
 18507                 {
       
 18508                 if (!IsOnlyFullWidthCharacterPermitted())
       
 18509                     {
       
 18510                     showAnotherTable = ETrue;
       
 18511                     }
       
 18512                 }
       
 18513             else if (sctChars == EAknSCTHalfCase || sctChars == EAknSCTUpperCase 
       
 18514                   || sctChars == EAknSCTLowerCase)
       
 18515                 {
       
 18516                 if (!IsOnlyHalfWidthCharacterPermitted() 
       
 18517                  && !(iAknEditorFlags & EAknEditorFlagLatinInputModesOnly))
       
 18518                     {
       
 18519                     showAnotherTable = ETrue;
       
 18520                     }
       
 18521                 }
       
 18522             }
       
 18523 #ifdef RD_SCALABLE_UI_V2     
       
 18524         if( iFepFullyConstructed && !iFepPluginManager->IsGlobleNotes())
       
 18525             {
       
 18526              if (iFepPluginManager->PluginInputMode() == EPluginInputModeItut ||
       
 18527                  iFepPluginManager->PluginInputMode() == EPluginInputModeFSQ ||
       
 18528                  iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr ||
       
 18529                  iFepPluginManager->PluginInputMode() == EPluginInputModePortraitFSQ )
       
 18530 
       
 18531                 {
       
 18532                 SetStopProcessFocus(ETrue, EFalse);
       
 18533                 iFepPluginManager->SetMenuState();            
       
 18534                 }                      
       
 18535              else if (!iFepPluginManager->IsGlobleNotes())
       
 18536                 {
       
 18537                 iFepPluginManager->ClosePluginInputUiL( ETrue );
       
 18538                 }
       
 18539             }
       
 18540 #endif  
       
 18541 
       
 18542         TBool lockNumericKeys = ( iPtiEngine->IsQwertyBasedMode(iPtiEngine->InputMode())) 
       
 18543         #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
 18544                             || ( iPtiEngine->InputMode() == EPtiEngineHalfQwerty ) ||
       
 18545                             ( iPtiEngine->InputMode() == EPtiEngineHalfQwertyPredictive ) 
       
 18546         #endif                            
       
 18547                             ;
       
 18548         TUid fepUid = CCoeEnv::Static()->FepUid();
       
 18549 
       
 18550         if(IsAbleToLaunchSmiley())
       
 18551             {
       
 18552             if(aShowSctMode == EShowSmileyFirst)
       
 18553                 {
       
 18554                 sctChars |= EAknCharMapEmotionFirst;
       
 18555                 }
       
 18556             else
       
 18557                 {
       
 18558                 sctChars |= EAknCharMapEmotionUse;
       
 18559                 }
       
 18560             }
       
 18561         ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
 18562         
       
 18563         if ( iFepPluginManager && iFepPluginManager->IsSpellVisible() )
       
 18564         	{
       
 18565             iFepPluginManager->SetLaunchSCTInSpell( ETrue );            
       
 18566         	}        	
       
 18567         SendEventsToPluginManL(EPluginEnablePriorityChangeOnOriChange,EFalse);
       
 18568 		if (iUiInterface->CharMapDialogL(
       
 18569 			sctChars, 
       
 18570 			specialChars, 
       
 18571 			charMap,
       
 18572 			lockNumericKeys,
       
 18573             aShowSctMode==EShowPctFirst,
       
 18574 			!IsAbleToLaunchPCT(),
       
 18575 			showAnotherTable,
       
 18576 			afterSctChars,
       
 18577 			currentEditorSCTResId,
       
 18578 			disableRecentItemRow))
       
 18579             {
       
 18580             PrepareFepAfterDialogExitL(fepUid);
       
 18581             SetCcpuFlag(ECcpuStateSupressCursorMoveToEnd);
       
 18582 			// after closing SCT, need change dim state.
       
 18583             SendEventsToPluginManL(EPluginEnableFetchDimState);
       
 18584 #ifdef RD_SCALABLE_UI_V2 
       
 18585             iNotifyPlugin = EFalse;
       
 18586             if( iFepFullyConstructed && iFepPluginManager)
       
 18587                 {
       
 18588                  if (iFepPluginManager->PluginInputMode() == EPluginInputModeItut ||
       
 18589                      iFepPluginManager->PluginInputMode() == EPluginInputModeFSQ ||
       
 18590                      iFepPluginManager->PluginInputMode() == EPluginInputModeFingerHwr ||
       
 18591                      iFepPluginManager->PluginInputMode() == EPluginInputModePortraitFSQ )
       
 18592                     {
       
 18593                     SetStopProcessFocus(EFalse);
       
 18594                     }                      
       
 18595                  else
       
 18596                     {
       
 18597                     HandleChangeInFocus();
       
 18598                     }
       
 18599                 }
       
 18600             else
       
 18601                 {
       
 18602                 HandleChangeInFocus();
       
 18603                 }   
       
 18604             // Set the flag, not change focus for next.
       
 18605             iNotifyPlugin = ETrue;
       
 18606 #endif            
       
 18607 
       
 18608             //Removes auto-complition part if SCT is launched and any special character is selected 
       
 18609 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 18610             if( specialChars.Length() > 0 )
       
 18611                 {
       
 18612             	RemoveSuggestedAdvanceCompletionL();
       
 18613                 }
       
 18614 #endif // RD_INTELLIGENT_TEXT_INPUT
       
 18615             TBuf<ESingleCharacter> charAsDesc(ESingleCharacter);
       
 18616             for ( TInt ii = 0; ii < specialChars.Length(); ii++)
       
 18617                 {
       
 18618                 charAsDesc[0]=(TText)specialChars[ii];
       
 18619 
       
 18620                 if (iInputCapabilities.SupportsSecretText())
       
 18621                     {
       
 18622                     TChar ch = charAsDesc[0];
       
 18623                     if (ch == TText(0x000A) || ch == TText(CEditableText::EParagraphDelimiter))
       
 18624                         // 0x000A is ascii, EParagraphDelimiter is unicode - future
       
 18625                         // proofs against sct changing to unicode
       
 18626                         ch = EKeyEnter;
       
 18627                     if (CharIsValidInEditor(ch))
       
 18628                         {
       
 18629                         //we receive an extra key press if we simulate a key that is also a device key
       
 18630                         if (ch.IsDigit() || TUint(ch) == EStarKeyUnicodeValue 
       
 18631                          || TUint(ch) == EHashKeyUnicodeValue)
       
 18632                             SetFlag(EFlagPassNextKey);
       
 18633                         SimulateKeyEventL(ch);
       
 18634                         }
       
 18635                     }
       
 18636                 else
       
 18637                     {
       
 18638                     if (charAsDesc[0] == TText(0x000A)) // 0x000A is line feed
       
 18639                         {
       
 18640                         charAsDesc[0] = CEditableText::EParagraphDelimiter;
       
 18641                         }
       
 18642                         
       
 18643                     if (CharIsValidInEditor(charAsDesc[0]))
       
 18644                         {
       
 18645                         TCursorSelection cursorSelection(0,0);
       
 18646                         if ((iAknEditorFlags & EAknEditorFlagMTAutoOverwrite) && iMode == ELatin 
       
 18647                           && !WesternPredictive())
       
 18648                             {
       
 18649                             TInt edSize = 
       
 18650                                    iInputCapabilities.FepAwareTextEditor()->DocumentLengthForFep();
       
 18651                             iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 18652                             if (iUncommittedText.iCursorPos < edSize 
       
 18653                              && iUncommittedText.Length() == 0)
       
 18654                                 {
       
 18655                                 cursorSelection = TCursorSelection(iUncommittedText.iCursorPos + 1,
       
 18656                                                                    iUncommittedText.iAnchorPos);
       
 18657                                 }
       
 18658                             }
       
 18659                         if (EditorState())
       
 18660                             {
       
 18661                             if (charAsDesc[0] == CEditableText::EParagraphDelimiter)
       
 18662                                 {
       
 18663                                 // This is line feed character. Post it to editor and let it decide
       
 18664                                 // if it is valid.
       
 18665                                  if (!(iAknEditorFlags & EAknEditorFlagFindPane) 
       
 18666                                     && specialChars.Length() == 1)
       
 18667                                     { 
       
 18668 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
 18669                                     CommitInlineEditL();                                    
       
 18670 #endif
       
 18671                                    
       
 18672                                     SimulateKeyEventL(EKeyEnter);   
       
 18673                                     SimulateKeyEventL(EKeyF19); // Asyncronous case update                                                                                              
       
 18674                                     }
       
 18675                                 }                                                        
       
 18676                             else
       
 18677                                 {                                                                                                                                   
       
 18678                                 if (replace)
       
 18679                                     {
       
 18680                                     TKeyEvent delKey = {8, EStdKeyBackspace, 1, 0};        
       
 18681                                     CCoeEnv::Static()->SimulateKeyEventL(delKey, EEventKey);                                                                
       
 18682                                     }                               
       
 18683 //There may be several char to be inserted, need disable Focus change to avoid multi-focus change.
       
 18684 #ifdef RD_SCALABLE_UI_V2 
       
 18685 #endif       
       
 18686                                 InsertTextFromDialogL(charAsDesc, cursorSelection);
       
 18687                                 }
       
 18688                             // Clear dead key, vowel sequence and vietnamese tone mark states.                         
       
 18689                             iPtiEngine->HandleCommandL(EPtiCommandGetAndClearLastVietnameseChar, 
       
 18690                                                        NULL);
       
 18691                             iPtiEngine->HandleCommandL(EPtiCommandClearVowelSeq, 
       
 18692                                                        NULL);
       
 18693                             iPtiEngine->HandleCommandL(EPtiCommandGetAndClearDeadKeyRootChar, 
       
 18694                                                        NULL);                            
       
 18695                             }
       
 18696                         }
       
 18697                     }
       
 18698                 }
       
 18699             }
       
 18700         else
       
 18701             {
       
 18702             iClosePeninputUi = EFalse;
       
 18703             iStopProcessFocus = EFalse;                   
       
 18704             }		   
       
 18705         PrepareFepAfterDialogExitL(fepUid);
       
 18706 		SendEventsToPluginManL(EPluginEnablePriorityChangeOnOriChange,ETrue);
       
 18707         }
       
 18708     }
       
 18709 
       
 18710 /**
       
 18711  * Queries supportting of SecretText
       
 18712  *
       
 18713  * @since 2.6
       
 18714  * @return ETrue if SecretText was supported
       
 18715  */
       
 18716 TBool CAknFepManager::IsSupportsSecretText() const
       
 18717     {
       
 18718     TBool bSecret = iInputCapabilities.SupportsSecretText();
       
 18719     if( !bSecret )
       
 18720         {
       
 18721         //test java editor
       
 18722         MObjectProvider* mop = iInputCapabilities.ObjectProvider();            	
       
 18723         if ( mop )
       
 18724            {
       
 18725             CAknExtendedInputCapabilities* extendedInputCapabilities;
       
 18726             extendedInputCapabilities = mop->MopGetObject( extendedInputCapabilities );
       
 18727             if ( extendedInputCapabilities ) 
       
 18728                 {
       
 18729                 TUint constraints = extendedInputCapabilities->MIDPConstrainst();
       
 18730                 if( constraints & 0x10000 )
       
 18731                     {
       
 18732                     bSecret = ETrue;
       
 18733                     }
       
 18734                 }
       
 18735             }
       
 18736         }
       
 18737     
       
 18738     return bSecret;
       
 18739     }
       
 18740 
       
 18741 void CAknFepManager::SendEventsToPluginManL( TInt aEventType, TInt aEventData )
       
 18742     {
       
 18743 #ifdef RD_SCALABLE_UI_V2
       
 18744     if ( iFepFullyConstructed )
       
 18745         {
       
 18746         iFepPluginManager->HandleEventsFromFepL( aEventType, aEventData );
       
 18747         }
       
 18748 #endif //RD_SCALABLE_UI_V2
       
 18749     }
       
 18750     
       
 18751 void CAknFepManager::UpdateCangJieState(TInt aNewMode)
       
 18752     {
       
 18753     CAknFepUIManagerChinese* fepUiMgr = STATIC_CAST(CAknFepUIManagerChinese*, 
       
 18754                                              iLangMan->GetFepUI(ECangJie, ENoneWidthChar, EFalse));
       
 18755     
       
 18756     if (aNewMode >= 0)
       
 18757         {
       
 18758         if ( fepUiMgr )
       
 18759             {
       
 18760             fepUiMgr->UpdateCangJieState();
       
 18761             }
       
 18762         
       
 18763         // Store CangJie settings into the sharedata
       
 18764         iSharedDataInterface->SetCangJieMode(aNewMode);            
       
 18765         }
       
 18766     }
       
 18767 
       
 18768 TInt CAknFepManager::LaunchCangJieOptionDlgL()
       
 18769     {
       
 18770     // Get the CangJie level from the GS
       
 18771     TInt currentLevel = iSharedDataInterface->CangJieMode();
       
 18772     
       
 18773     if ((currentLevel != ECangJieNormal) 
       
 18774     && (currentLevel != ECangJieEasy) 
       
 18775     && (currentLevel != ECangJieAdvanced))
       
 18776         return KErrGeneral;
       
 18777 
       
 18778     // Launch the CangJie setting menu
       
 18779     CDesCArrayFlat* items = CCoeEnv::Static()->ReadDesC16ArrayResourceL(R_AVKON_CANGJIE_OPTIONS_LBX);
       
 18780     CleanupStack::PushL(items);
       
 18781 
       
 18782     TUid fepUid = CCoeEnv::Static()->FepUid();   
       
 18783     ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
 18784 	TInt ret = iUiInterface->LaunchCangJieOptionDlgL(
       
 18785         R_AVKON_CANGJIE_MODE_OPTIONS_SETTING_PAGE,
       
 18786         currentLevel,
       
 18787         items
       
 18788         );
       
 18789     PrepareFepAfterDialogExitL(fepUid);
       
 18790 
       
 18791     CleanupStack::PopAndDestroy(items);
       
 18792 
       
 18793     return ret ? currentLevel : KErrGeneral;
       
 18794     }
       
 18795 
       
 18796 GLDEF_C void AknFepPanic(TAknFepPanic aPanic)
       
 18797     {
       
 18798     User::Panic(_L("AKNFEP"),aPanic);
       
 18799     }
       
 18800 
       
 18801 /**
       
 18802  * Set Multitap timer value. 
       
 18803  *
       
 18804  * @since 3.0
       
 18805  * @param Value of KAknFepMultiTapTimer setting
       
 18806  */
       
 18807 void CAknFepManager::SetMultiTapTimer(const TInt aMultiTapTimer)
       
 18808     {
       
 18809     if (iMultiTapTimer != aMultiTapTimer)
       
 18810         {
       
 18811         iMultiTapTimer = aMultiTapTimer;
       
 18812         }
       
 18813     }
       
 18814 
       
 18815 /**
       
 18816  * Set Japanese Qwerty Flags value. 
       
 18817  *
       
 18818  * @since 3.0
       
 18819  * @param Value of KAknFepJapaneseSpecialCharFlag setting
       
 18820  */
       
 18821 void CAknFepManager::SetJapaneseQwertyFlags(const TInt aJapaneseQwertyFlags)
       
 18822     {
       
 18823     if (iJapaneseQwertyFlags != aJapaneseQwertyFlags)
       
 18824         {
       
 18825         iJapaneseQwertyFlags = aJapaneseQwertyFlags;
       
 18826         }
       
 18827     }
       
 18828 
       
 18829 /**
       
 18830  * Handle the Chr Key Monitor
       
 18831  * for Japanese variant only.
       
 18832  *
       
 18833  * @since 3.0
       
 18834  * @return KErrNone if succeed, KErrDied if failed
       
 18835  */
       
 18836 TInt CAknFepManager::HandleChrKeyMonitorCallback(TAny* aObj)
       
 18837     {
       
 18838     TRAPD(err, static_cast<CAknFepManager*>(aObj)->HandleChrKeyMonitorL());
       
 18839     if (err)
       
 18840         {
       
 18841         static_cast<CAknFepManager*>(aObj)->CleanUpFep();
       
 18842         return KErrDied;
       
 18843         }
       
 18844     return KErrNone;
       
 18845     }
       
 18846 
       
 18847 /**
       
 18848  * Handle the Chr Key Monitor
       
 18849  * for Japanese variant only.
       
 18850  *
       
 18851  * @since 3.0
       
 18852  */
       
 18853 void CAknFepManager::HandleChrKeyMonitorL()
       
 18854     {
       
 18855 #ifdef RD_INTELLIGENT_TEXT_INPUT        
       
 18856 #ifdef __HALF_QWERTY_KEYPAD        
       
 18857     if ( IsFlagSet(EFlagQwertyChrKeyDepressed) && 
       
 18858     		  IsFlagSet(EFlagNoActionDuringChrKeyPress) && 
       
 18859     		  (EPtiKeyboardHalfQwerty == KeyboardLayout() ) && 
       
 18860     		  ( iWesternPredictive || iMode == EPinyin || 
       
 18861     		     iMode == EStroke || iMode == EZhuyin ) )   
       
 18862     	{
       
 18863     	// Clear the chr key depressed flag
       
 18864     	TBool validchr = FepUI()->IsValidLongChrKeyPress();
       
 18865     	
       
 18866     	if(!validchr || !IsAbleToLaunchSCT() )
       
 18867     		{
       
 18868 			  FepUI()->HandleKeyL( EStdKeyLeftFunc, EShortKeyPress );    		
       
 18869 			  ClearFlag( EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
 18870     		}
       
 18871     	else
       
 18872     		{
       
 18873     		// will launch SCT later
       
 18874     		iChrLongKeyPress = ETrue;	
       
 18875     		}	
       
 18876         
       
 18877     	}
       
 18878     	else
       
 18879 #endif   
       
 18880 #endif
       
 18881 	 if (IsFlagSet(EFlagQwertyChrKeyDepressed) && IsFlagSet(EFlagNoActionDuringChrKeyPress)
       
 18882      && iCurrentFepUI->IsValidShiftKeyPress())
       
 18883         {
       
 18884         // Timer cancel
       
 18885         iChrKeypressMonitor->Cancel();
       
 18886         // Commit characters
       
 18887         HandleChangeInFocus();
       
 18888         // Clear flags
       
 18889         ClearFlag(EFlagQwertyChrKeyDepressed | EFlagNoActionDuringChrKeyPress);
       
 18890         // Open editting menu
       
 18891         LaunchSelectModeMenuL();
       
 18892         }
       
 18893     }
       
 18894 
       
 18895 
       
 18896 // -----------------------------------------------------------------------------
       
 18897 // CAknFepManager::SetCursorSelectionL
       
 18898 // Set editor cursor selection.
       
 18899 // (other items were commented in a header).
       
 18900 // -----------------------------------------------------------------------------
       
 18901 //
       
 18902 void CAknFepManager::SetCursorSelectionL(const TCursorSelection& /*aCurSel*/, TBool /*aSyncCursor*/)
       
 18903     {
       
 18904     }
       
 18905 
       
 18906  TInt CAknFepManager::HandleResourceChangedCallback(TAny* aObj)
       
 18907 	{
       
 18908 	TRAPD(err, static_cast<CAknFepManager*>(aObj)->ResourceChangedTimeroutL());
       
 18909     if (err)
       
 18910         {
       
 18911         static_cast<CAknFepManager*>(aObj)->CleanUpFep();
       
 18912         return KErrNoMemory;
       
 18913         }
       
 18914     return KErrNone;
       
 18915 	}
       
 18916 
       
 18917 void CAknFepManager::ResourceChangedTimeroutL()
       
 18918     {
       
 18919     if(iCurrentFepUI)
       
 18920 	    {
       
 18921 	    iCurrentFepUI->ResourceChanged(1);	
       
 18922 	    }   
       
 18923     }
       
 18924 
       
 18925 
       
 18926 // -----------------------------------------------------------------------------
       
 18927 // pen related inplementation
       
 18928 // -----------------------------------------------------------------------------
       
 18929 #ifdef RD_SCALABLE_UI_V2
       
 18930 
       
 18931 // -----------------------------------------------------------------------------
       
 18932 // CAknFepManager::HandleLayoutChange
       
 18933 // Update plugin UI case mode.
       
 18934 // (other items were commented in a header).
       
 18935 // -----------------------------------------------------------------------------
       
 18936 //
       
 18937 void CAknFepManager::HandleResourceChange(TInt aType)
       
 18938     {
       
 18939     if(iCurrentFepUI)
       
 18940     	{
       
 18941         iAsyncResouceChanged.CallBack();
       
 18942     	}
       
 18943 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 18944     
       
 18945     if(aType == KEikDynamicLayoutVariantSwitch)        
       
 18946         {		
       
 18947 		if ( iAvkonAppUi->IsDisplayingDialog() && iMatchesListLaunched )
       
 18948 			{
       
 18949 			 iUiInterface->DeleteDialogs();
       
 18950 			}
       
 18951         
       
 18952         //When there is a change of layout, the inline text position changes and hence the candidate 
       
 18953         //list position also needs to change accordingly.
       
 18954         //We need the editor to be brought back to focus, this is because we need the position of
       
 18955         //the inline text.
       
 18956         if( iCandidatePopup && iPtiEngine )
       
 18957         	{
       
 18958 			iCandidatePopup->UnFocus();
       
 18959 			//Need to get the editor state back after it is brought back to focus.
       
 18960 			TRAP_IGNORE( HandleChangeInFocusL()); 
       
 18961 			
       
 18962 			// Add candidate list control stack to get the layout change event
       
 18963 			// after dialog control......
       
 18964 			TRAP_IGNORE( iCandidatePopup->SetFocusAddStackReducePriorityL() );
       
 18965         	}        
       
 18966         }
       
 18967 #endif		
       
 18968     TRAP_IGNORE(SendEventsToPluginManL( EPluginResourceChanged, aType ));
       
 18969     }   
       
 18970 void CAknFepManager::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
 18971     {
       
 18972     if (IsFlagSet(CAknFepManager::EFlagNoMatches))
       
 18973         {
       
 18974         ClearFlag(CAknFepManager::EFlagNoMatches); 
       
 18975         }
       
 18976    
       
 18977     if(aPointerEvent.iType == TPointerEvent::EDrag)
       
 18978     	{
       
 18979     	SetExtendedFlag(EExtendedFlagPointerEventTypeEDrag);
       
 18980     	}
       
 18981     if (aPointerEvent.iType == TPointerEvent::EButton1Up)
       
 18982         {
       
 18983     	ClearExtendedFlag(EExtendedFlagPointerEventTypeEDrag);
       
 18984 
       
 18985         // Remember last up-click in case it is needed for displaying
       
 18986         // stylus ccpu-menu.
       
 18987         iClickPoint = aPointerEvent.iPosition;
       
 18988         }    
       
 18989     }
       
 18990  
       
 18991 // -----------------------------------------------------------------------------
       
 18992 // CAknFepManager::HandleSelModeArrowKeyEventL
       
 18993 // Set text selection when tap on the arrow keys.
       
 18994 // (other items were commented in a header).
       
 18995 // -----------------------------------------------------------------------------
       
 18996 //
       
 18997 TBool CAknFepManager::HandleSelModeArrowKeyEventL(const TKeyEvent& aKeyEvent, 
       
 18998                                                   TEventCode aEventCode,
       
 18999                                                   TKeyResponse& aRetCode)
       
 19000     {
       
 19001     aRetCode = EKeyWasNotConsumed;
       
 19002     TBool used = EFalse;
       
 19003 
       
 19004     // only arrow keys are potentially handled
       
 19005     if ( ( aKeyEvent.iScanCode == EStdKeyLeftArrow 
       
 19006             || aKeyEvent.iScanCode == EStdKeyRightArrow )
       
 19007             && iInputCapabilities.FepAwareTextEditor() )
       
 19008         {
       
 19009         TInt inputMode = PluginInputMode();
       
 19010         TBool isArabicFingerHwr = ( inputMode == EPluginInputModeFingerHwr &&
       
 19011                 GetInputLanguageFromSharedDataInterface() == ELangArabic );
       
 19012         TCursorSelection currentEditorSelection( 0, 0 );
       
 19013 
       
 19014         iInputCapabilities.FepAwareTextEditor()->
       
 19015                 GetCursorSelectionForFep( currentEditorSelection );
       
 19016         
       
 19017         if ( !IsMfneEditor() && ( inputMode == EPluginInputModeItut ||
       
 19018                 inputMode == EPluginInputModeFSQ  || 
       
 19019                 inputMode == EPluginInputModePortraitFSQ  || 
       
 19020                 isArabicFingerHwr )
       
 19021                 && currentEditorSelection.Length() != 0 )
       
 19022             {
       
 19023             used = ETrue;
       
 19024 
       
 19025             if ( !( aKeyEvent.iModifiers & EModifierShift ) )
       
 19026                 {
       
 19027                 TKeyEvent ccpuStart = aKeyEvent;
       
 19028                 ccpuStart.iModifiers |= EModifierShift;
       
 19029                 ccpuStart.iModifiers |= EModifierRightShift;
       
 19030                 CCoeEnv::Static()->SimulateKeyEventL( ccpuStart, aEventCode );        
       
 19031                 aRetCode = EKeyWasConsumed;
       
 19032                 }               
       
 19033             }
       
 19034         }
       
 19035     
       
 19036     return used;
       
 19037     }
       
 19038 
       
 19039 #else // !RD_SCALABLE_UI_V2
       
 19040 // -----------------------------------------------------------------------------
       
 19041 // CAknFepManager::HandleResourceChange
       
 19042 // Update plugin UI case mode.
       
 19043 // (other items were commented in a header).
       
 19044 // -----------------------------------------------------------------------------
       
 19045 //
       
 19046 void CAknFepManager::HandleResourceChange(TInt aType)
       
 19047     {
       
 19048     if (iFepFullyConstructed && Japanese() )
       
 19049         {
       
 19050         // Japaneseinput should handle the event of changing layout or screen.
       
 19051         FepUI()->ResourceChanged(aType);
       
 19052         }
       
 19053 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 19054     if(iCandidatePopup && iPtiEngine && (aType == KEikDynamicLayoutVariantSwitch))        
       
 19055         {
       
 19056         //When there is a change of layout, the inline text position changes and hence the candidate 
       
 19057         //list position also needs to change accordingly.
       
 19058         //We need the editor to be brought back to focus, this is because we need the position of
       
 19059         //the inline text.
       
 19060         iCandidatePopup->UnFocus();
       
 19061         //Need to get the editor state back after it is brought back to focus.
       
 19062         TRAP_IGNORE(HandleChangeInFocusL());
       
 19063         //Can not do anything if FEP is not constructed fully
       
 19064         if(iFepFullyConstructed)
       
 19065             {
       
 19066             //Now we read the position of the inline text
       
 19067             TPoint  inlineEditorTl;
       
 19068             TPoint  inlineEditorBr;
       
 19069             TInt    height;
       
 19070             TInt    ascent;
       
 19071             TInt    documentOffset = iPtiEngine->CurrentWord().Length();
       
 19072             //  Popup Position for RTL
       
 19073             if(iLanguageCapabilities.iRightToLeftLanguage)
       
 19074                 documentOffset = 0;
       
 19075             //  Popup Position for RTL
       
 19076             TRAP_IGNORE( GetScreenCoordinatesL( inlineEditorTl, height, ascent, documentOffset ));
       
 19077             inlineEditorTl.iY -= height;
       
 19078             TRAP_IGNORE( GetScreenCoordinatesL( inlineEditorBr, height, ascent ));
       
 19079             
       
 19080             //Let the candidate list know about a change of resource and update the
       
 19081             //inline text rectangle.
       
 19082             //Now show the candidate list at the re-calculated position
       
 19083             iCandidatePopup->ShowAtNewPosition(TRect(inlineEditorTl,inlineEditorBr));
       
 19084             }
       
 19085         }
       
 19086 #endif		
       
 19087     }
       
 19088 
       
 19089 #endif //RD_SCALABLE_UI_V2    
       
 19090 
       
 19091 TDigitType CAknFepManager::LocalDigit()
       
 19092     {
       
 19093     return iLanguageCapabilities.iLocalDigitType;
       
 19094     }
       
 19095     
       
 19096 /**
       
 19097 * Returns ETrue if arabic indic digit setting is on. 
       
 19098 *
       
 19099 * @since 3.0
       
 19100 */
       
 19101 TBool CAknFepManager::ArabicIndicDigitsInUse() const
       
 19102     {
       
 19103     return (iLanguageCapabilities.iLocalDigitType == EDigitTypeArabicIndic);
       
 19104     }
       
 19105        
       
 19106 TBool CAknFepManager::EasternArabicIndicDigitsInUse() const
       
 19107     {
       
 19108     return (iLanguageCapabilities.iLocalDigitType == EDigitTypeEasternArabicIndic);
       
 19109     }
       
 19110     
       
 19111 /**
       
 19112  *  Sets delayed commit on (predicitve word will be commited in 
       
 19113  *  next call to TryCloseUiL. This is needed because of Japanese ReadingTextL).
       
 19114  *
       
 19115  * @since 3.1
       
 19116  */
       
 19117 void CAknFepManager::SetDelayedCommit()
       
 19118     {
       
 19119     iCcpuMode |= ECcpuStataCommitPredictiveWord;
       
 19120     }
       
 19121 
       
 19122 // -----------------------------------------------------------------------------
       
 19123 // CAknFepManager::SetDefaultNumberMode
       
 19124 //
       
 19125 // Set default number mode for non-latin languagues
       
 19126 // 
       
 19127 // Copied from CGSLangModel::SetDefaultNumberMode
       
 19128 // -----------------------------------------------------------------------------
       
 19129 //
       
 19130 void CAknFepManager::SetDefaultNumberMode( TInt aMode, TInt aNbrModeType )
       
 19131     {
       
 19132     //As aMode comes from the UI, it can either be 0 or 1. This needs
       
 19133     //special handling for Indic mode as it has been defined as an enum
       
 19134     //constant and has a value of 2. This applies to any values defined
       
 19135     //in the enum and have a value > 1.
       
 19136     if ( aNbrModeType == ENbrModeTypeArabic ||
       
 19137          aNbrModeType == ENbrModeTypeEasternArabic )
       
 19138         {
       
 19139         iSharedDataInterface->SetDefaultNumberMode( KSettingsDefaultNumberMode, aMode );
       
 19140         }
       
 19141     else
       
 19142         {
       
 19143         iSharedDataInterface->SetDefaultNumberMode( KSettingsIndicDefaultNumberMode, aMode );
       
 19144         }
       
 19145 
       
 19146     TLocale locale;
       
 19147     if ( aMode == ENbrModeLatin )
       
 19148         {
       
 19149         locale.SetDigitType( EDigitTypeWestern );
       
 19150         }
       
 19151     else
       
 19152         {
       
 19153         //if aMode != EGSNbrModeLatin, then it should be either latin or arabic. However
       
 19154         //as EGSNbrModeArabic and EGsNbrModeIndic both have a value = 1, we can't use
       
 19155         //that constant for below comparison. Hence, need to depend on the 2nd param.
       
 19156         switch ( aNbrModeType )
       
 19157             {
       
 19158             case ENbrModeTypeArabic:
       
 19159                 locale.SetDigitType( EDigitTypeArabicIndic );
       
 19160                 break;
       
 19161             case ENbrModeTypeIndic:
       
 19162                 locale.SetDigitType( EDigitTypeDevanagari );
       
 19163                 break;
       
 19164             case ENbrModeTypeEasternArabic:
       
 19165                 locale.SetDigitType( EDigitTypeEasternArabicIndic );
       
 19166                 break;
       
 19167             default:
       
 19168                 break;
       
 19169             }
       
 19170         }
       
 19171 
       
 19172     locale.Set();
       
 19173     }
       
 19174 
       
 19175 // -----------------------------------------------------------------------------
       
 19176 // CAknFepManager::ResolveCurrentCandidateListIndex
       
 19177 //
       
 19178 // Calculates correct selection index for matches popup list.
       
 19179 // -----------------------------------------------------------------------------
       
 19180 //
       
 19181 TInt CAknFepManager::ResolveCurrentCandidateListIndex(CDesCArrayFlat* aCandList)
       
 19182     {
       
 19183     if (iPtiEngine && aCandList)
       
 19184         {           
       
 19185         TBuf<EMaximumFepWordLength> currentCand;
       
 19186     
       
 19187         currentCand.Copy(iPtiEngine->CurrentWord());    
       
 19188         for (TInt i = 0; i < aCandList->Count(); i++)
       
 19189             {
       
 19190             if (currentCand == aCandList->MdcaPoint(i))
       
 19191                 {
       
 19192                 if (i == aCandList->Count() - 1)
       
 19193                     {
       
 19194                     return 0;
       
 19195                     }
       
 19196                 return i + 1;
       
 19197                 }
       
 19198             }
       
 19199         }
       
 19200 
       
 19201     return 0;
       
 19202     }
       
 19203 
       
 19204 void CAknFepManager::AlignLogicalAndVisualCursorL( TTmDocPosSpec::TType aType, 
       
 19205                                                     TBool aToLeft )
       
 19206     {
       
 19207     if( !( iInputCapabilities.SupportsSecretText() ) )
       
 19208         {
       
 19209         if( IsFlagSet( EFlagInsideInlineEditingTransaction ) && 
       
 19210             IsFlagSet( EFlagInsideMultitapInlineEditingTransaction ) )
       
 19211             {
       
 19212             CommitInlineEditL();
       
 19213             }
       
 19214 
       
 19215         MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 19216             iInputCapabilities.FepAwareTextEditor();
       
 19217 
       
 19218 	    MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 19219         if( (docNavi || TextLayout()) && fepAwareTextEditor )
       
 19220             {
       
 19221             TTmDocPosSpec pos = DocPos();
       
 19222             pos.iType = aType;
       
 19223             TTmPosInfo2 info;
       
 19224             if (docNavi)
       
 19225             	{
       
 19226 	            docNavi->GetNextVisualCursorPos( pos, info, aToLeft );
       
 19227             	}
       
 19228             else
       
 19229             	{
       
 19230  	            TextLayout()->TagmaTextLayout().GetNextVisualCursorPos( pos, info, aToLeft );
       
 19231             	}
       
 19232             TCursorSelection curSel( info.iDocPos.iPos, info.iDocPos.iPos );
       
 19233             fepAwareTextEditor->SetCursorSelectionForFepL( curSel );
       
 19234             }
       
 19235         }
       
 19236     }
       
 19237 
       
 19238 void CAknFepManager::RemoveRephaCharacterL()
       
 19239     {
       
 19240     MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 19241         iInputCapabilities.FepAwareTextEditor();
       
 19242     
       
 19243     if( fepAwareTextEditor )
       
 19244         {
       
 19245         TInt previousCharPos = 0;
       
 19246         TBool leftFlag = GetNextVisualLeftCharacter( previousCharPos );
       
 19247         
       
 19248         if( !leftFlag )
       
 19249             {
       
 19250             return;
       
 19251             }
       
 19252         
       
 19253         TCursorSelection curSel;
       
 19254         fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
 19255             
       
 19256         TInt lowerPos = curSel.LowerPos();
       
 19257         if( lowerPos > 1 )
       
 19258             {
       
 19259             const TInt rephaLength( 2 );
       
 19260             TBuf<rephaLength> previousCharacter;
       
 19261             previousCharacter.FillZ();
       
 19262             
       
 19263             fepAwareTextEditor->
       
 19264                 GetEditorContentForFep( previousCharacter, 
       
 19265                                         previousCharPos, rephaLength );
       
 19266             
       
 19267             if (rephaLength == previousCharacter.Length())
       
 19268                 {
       
 19269                 if( previousCharacter[0] == TAknFepUiIndicInputManager::RaCharacter( 
       
 19270                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) &&
       
 19271                     previousCharacter[1] == TAknFepUiIndicInputManager::Virama( 
       
 19272                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) )
       
 19273                     {
       
 19274                     curSel.iAnchorPos = previousCharPos;
       
 19275                     curSel.iCursorPos = previousCharPos + rephaLength;
       
 19276                     
       
 19277                     // Remove the repha
       
 19278                     
       
 19279                     if( IsFlagSet( EFlagInsideInlineEditingTransaction ) && 
       
 19280                         IsFlagSet( EFlagInsideMultitapInlineEditingTransaction ) )
       
 19281                         {
       
 19282                         CommitInlineEditL();
       
 19283                         }
       
 19284                     StartInlineEditL( curSel, previousCharacter, rephaLength, ETrue );
       
 19285                     UpdateInlineEditL( KNullDesC, 0 );
       
 19286                     CommitInlineEditL();
       
 19287     
       
 19288                     // Go to the visual right position of current ligature as the 
       
 19289                     // repha has been deleted.
       
 19290                     AlignLogicalAndVisualCursorL( TTmDocPosSpec::ELeading, EFalse );
       
 19291                     }
       
 19292                 }
       
 19293             }
       
 19294         }
       
 19295     }
       
 19296 
       
 19297 TBool CAknFepManager::IsRephaPresent()
       
 19298     {
       
 19299     TBool result = EFalse;
       
 19300     
       
 19301     MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 19302         iInputCapabilities.FepAwareTextEditor();
       
 19303 
       
 19304     if( fepAwareTextEditor )
       
 19305         {
       
 19306         TCursorSelection curSel;
       
 19307         
       
 19308         fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
 19309         
       
 19310         TInt previousCharPos = 0;
       
 19311         TBool leftFlag = GetNextVisualLeftCharacter( previousCharPos );
       
 19312         
       
 19313         if( !leftFlag )
       
 19314             {
       
 19315             return result;
       
 19316             }
       
 19317 
       
 19318         TInt lowerPos = curSel.LowerPos();
       
 19319         if( lowerPos > 1 )
       
 19320             {
       
 19321             const TInt rephaLength( 2 );
       
 19322             TBuf<rephaLength> previousCharacter;
       
 19323             previousCharacter.FillZ();
       
 19324             
       
 19325             fepAwareTextEditor->
       
 19326                 GetEditorContentForFep( previousCharacter, 
       
 19327                                         previousCharPos, rephaLength );
       
 19328 
       
 19329             // Verify whether the length of the string is equal to the length 
       
 19330             // of repha before doing further checks.
       
 19331             if( previousCharacter.Length() == rephaLength )
       
 19332                 {               
       
 19333                 if( previousCharacter[0] == TAknFepUiIndicInputManager::RaCharacter( 
       
 19334                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) &&
       
 19335                     previousCharacter[1] == TAknFepUiIndicInputManager::Virama( 
       
 19336                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) )
       
 19337                     {
       
 19338                     result = ETrue;
       
 19339                     }
       
 19340                 }
       
 19341             }
       
 19342         }
       
 19343         
       
 19344     return result;
       
 19345     }
       
 19346     
       
 19347 TText CAknFepManager::PreviousToPreviousChar( TBool aContextSensitive )
       
 19348     {
       
 19349     TBuf<ESingleCharacter> prevToPrevChar( ESingleCharacter );
       
 19350     prevToPrevChar.FillZ();
       
 19351 
       
 19352     if( !aContextSensitive )
       
 19353         {
       
 19354         TTmDocPosSpec pos = DocPos();
       
 19355         
       
 19356         // Pos=0 means it is before the first character and there is no previous character
       
 19357         if (pos.iPos > 0 ) 
       
 19358             {
       
 19359             if( iInputCapabilities.FepAwareTextEditor() )
       
 19360                 {
       
 19361                 iInputCapabilities.FepAwareTextEditor()->
       
 19362                     GetEditorContentForFep( prevToPrevChar, pos.iPos - 1, ESingleCharacter );
       
 19363                 }
       
 19364             }
       
 19365         }
       
 19366     else
       
 19367         {
       
 19368         TCursorSelection curSel;
       
 19369         
       
 19370         MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 19371             iInputCapabilities.FepAwareTextEditor();
       
 19372         
       
 19373         if( fepAwareTextEditor )
       
 19374             {
       
 19375             fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
 19376             TInt lowerpos = curSel.LowerPos();
       
 19377 
       
 19378             if( lowerpos > 1 )
       
 19379                 {
       
 19380                 fepAwareTextEditor->
       
 19381                     GetEditorContentForFep( prevToPrevChar, lowerpos - 2, ESingleCharacter );
       
 19382                 }
       
 19383             }
       
 19384         }
       
 19385     if (prevToPrevChar.Length())
       
 19386         return prevToPrevChar[0];
       
 19387     else
       
 19388         return NULL;
       
 19389     }
       
 19390 
       
 19391 void CAknFepManager::RemoveRakarCharacterL()
       
 19392     {
       
 19393     MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 19394         iInputCapabilities.FepAwareTextEditor();
       
 19395     
       
 19396     if( fepAwareTextEditor )
       
 19397         {
       
 19398         TCursorSelection curSel;
       
 19399             
       
 19400         fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
 19401         
       
 19402         TInt lowerpos = curSel.LowerPos();
       
 19403 
       
 19404         if( lowerpos > 1 )
       
 19405             {
       
 19406             const TInt rakarLength( 2 );
       
 19407             TBuf<rakarLength> buffer;
       
 19408             buffer.FillZ();
       
 19409 
       
 19410             fepAwareTextEditor->
       
 19411                 GetEditorContentForFep( buffer, lowerpos - rakarLength, rakarLength );
       
 19412             
       
 19413             if (rakarLength == buffer.Length())
       
 19414                 {
       
 19415                 if( buffer[0] == TAknFepUiIndicInputManager::Virama( 
       
 19416                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) &&
       
 19417                     buffer[1] == TAknFepUiIndicInputManager::RaCharacter( 
       
 19418                         TLanguage( iLanguageCapabilities.iInputLanguageCode ) ) )
       
 19419                     {
       
 19420                     curSel.iAnchorPos = lowerpos - rakarLength;
       
 19421                     curSel.iCursorPos = lowerpos;
       
 19422                     
       
 19423                     // Remove the repha
       
 19424                     
       
 19425                     if( IsFlagSet( EFlagInsideInlineEditingTransaction ) && 
       
 19426                         IsFlagSet( EFlagInsideMultitapInlineEditingTransaction ) )
       
 19427                         {
       
 19428                         CommitInlineEditL();
       
 19429                         }
       
 19430                     StartInlineEditL( curSel, buffer, rakarLength, ETrue );
       
 19431                     UpdateInlineEditL( KNullDesC, 0 );
       
 19432                     CommitInlineEditL();
       
 19433                     }
       
 19434                 }
       
 19435             }
       
 19436         }
       
 19437     }
       
 19438 
       
 19439 /**
       
 19440  * Returns the status of predictive input.
       
 19441  *
       
 19442  *  @since 3.2
       
 19443  *  @return ETrue is available predictive input.
       
 19444  */
       
 19445 TBool CAknFepManager::IsAbleToChangePrediction() const
       
 19446     {
       
 19447     TBool ret = EFalse;
       
 19448     if (!(iAknEditorFlags & EAknEditorFlagNoT9))
       
 19449         {
       
 19450         if (iMode == EHiraganaKanji)
       
 19451             {
       
 19452             if (HasJapanesePredictionInputMode())
       
 19453                 {
       
 19454                 ret = ETrue;
       
 19455                 }
       
 19456             }
       
 19457         else
       
 19458             {
       
 19459             ret = ETrue;
       
 19460             }
       
 19461         }
       
 19462     return ret;
       
 19463     }
       
 19464 
       
 19465 TLanguage CAknFepManager :: GetInputLanguageFromSharedDataInterface()
       
 19466 {
       
 19467     return ((TLanguage)(iSharedDataInterface->InputTextLanguage()));
       
 19468 }
       
 19469     
       
 19470     
       
 19471 void CAknFepManager::DeactivatePredicitveWordAndMoveCursorL()
       
 19472     {
       
 19473     if (WesternPredictive())
       
 19474         {           
       
 19475         TWesternNaviEvent naviEvent = ERightNaviEvent;
       
 19476     
       
 19477         if (iLanguageCapabilities.iRightToLeftLanguage)
       
 19478             {
       
 19479             naviEvent = ELeftNaviEvent;     
       
 19480             }
       
 19481 #ifdef RD_INTELLIGENT_TEXT_INPUT         
       
 19482 		// This function is called at time of Cut/Copy command
       
 19483 		// TryCloseUiL will remove the auto completion part
       
 19484 		// To adjust the visual cursor position commit the text with
       
 19485 		// auto completion part.  
       
 19486 		if( IsAutoCompleteOn()) 
       
 19487 			{
       
 19488 			TInt tailLength = 0;
       
 19489 			iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength );
       
 19490 
       
 19491 			if( tailLength > 0)
       
 19492 				{
       
 19493 				// Sync the key sequence and editor text.	
       
 19494 				iPtiEngine->HandleCommandL( EPtiCommandLockCurrentCandidate );			
       
 19495 				}
       
 19496 			}
       
 19497 #endif
       
 19498     
       
 19499         // Find the visual left/right end of the current word
       
 19500         TTmDocPosSpec pos;
       
 19501         GetAvkonDefinedVisualLimitsOfSelection(
       
 19502                iUncommittedText, naviEvent, pos, NULL );
       
 19503                
       
 19504         TryCloseUiL();
       
 19505     
       
 19506         // Position should be dis-ambiguated based on last navigation and direction of blocks.
       
 19507         AdjustPosSpecForAmbiguityAfterLeftOrRightNavigation( pos, naviEvent );
       
 19508 
       
 19509         SetCursorPositionL( pos );
       
 19510 
       
 19511         iCaseMan->UpdateCase(ENullNaviEvent);       
       
 19512         }
       
 19513     }
       
 19514 
       
 19515 
       
 19516 // -----------------------------------------------------------------------------
       
 19517 // CAknFepManager::EditorCcpuStatus
       
 19518 //
       
 19519 // Returns the Ccpu status of given editor state as a flag combination.
       
 19520 // -----------------------------------------------------------------------------
       
 19521 //
       
 19522 TInt CAknFepManager::EditorCcpuStatus(CAknEdwinState* aEdwinState)
       
 19523     {
       
 19524     TInt ret = 0;
       
 19525                                             
       
 19526     if (aEdwinState && aEdwinState->CcpuState())
       
 19527         {
       
 19528         if (aEdwinState->CcpuState()->CcpuCanCopy())
       
 19529             {
       
 19530             ret |=  ECcpuStatusFlagCanCopy;
       
 19531             }
       
 19532         if (aEdwinState->CcpuState()->CcpuCanCut()) 
       
 19533             {
       
 19534             ret |=  ECcpuStatusFlagCanCut;
       
 19535             }
       
 19536         if (aEdwinState->CcpuState()->CcpuCanPaste())               
       
 19537             {
       
 19538             ret |=  ECcpuStatusFlagCanPaste;                    
       
 19539             }
       
 19540         }                 
       
 19541     return ret; 
       
 19542     }
       
 19543     
       
 19544 void CAknFepManager::NewLigatureL( const TDesC& aText )
       
 19545     {
       
 19546     if( !iInputCapabilities.SupportsSecretText() && 
       
 19547         ( EditorHasFreeSpace() || 
       
 19548             IsFlagSet( EFlagInsideMultitapInlineEditingTransaction ) ) )
       
 19549         {
       
 19550         if ( iFepManState == EAknFepStateInitial ) //multitapping
       
 19551             {
       
 19552             if ( !IsFlagSet( EFlagInsideMultitapInlineEditingTransaction ) )
       
 19553                 {
       
 19554                 ClearFlag( EFlagLineFeedCharacter );
       
 19555                 StartInlineEditL( aText );
       
 19556                 SetFlag( EFlagInsideMultitapInlineEditingTransaction );
       
 19557                 SetFlag( EFlagInsideInlineEditingTransaction );
       
 19558                 }
       
 19559             }
       
 19560         }
       
 19561     }
       
 19562 
       
 19563 
       
 19564 
       
 19565 // -----------------------------------------------------------------------------
       
 19566 // CAknFepManager::CancelCcpuMode
       
 19567 //
       
 19568 // Cancels the copy / cut mode initiated from editing options -submenu.
       
 19569 // -----------------------------------------------------------------------------
       
 19570 //
       
 19571 void CAknFepManager::CancelCcpuMode()
       
 19572     {
       
 19573     iIndicator->SetCopyMode(EFalse);
       
 19574     if (IsCcpuFlagSet(ECcpuStateStartCopy | ECcpuStateCopy | ECcpuStateStartCut | ECcpuStateCut))
       
 19575         {
       
 19576         iUiInterface->DeleteSoftkeys();    
       
 19577         }
       
 19578     
       
 19579     ResetCcpuFlags();                       
       
 19580     }
       
 19581 
       
 19582 // -----------------------------------------------------------------------------
       
 19583 // CAknFepManager::CancelShiftKeyTimer
       
 19584 //
       
 19585 // Cancels shift key timer.
       
 19586 // -----------------------------------------------------------------------------
       
 19587 //
       
 19588 void CAknFepManager::CancelShiftKeyTimer()
       
 19589     {
       
 19590     ClearFlag(EFlagShiftKeyDepressed);
       
 19591     if (iShiftKeypressMonitor)
       
 19592         {
       
 19593         iShiftKeypressMonitor->Cancel();    
       
 19594         }
       
 19595     }
       
 19596 
       
 19597 void CAknFepManager::RemoveTextFromEditorL( TInt aNumOfCharacters, 
       
 19598                                             TInt aPos /*= 0*/,
       
 19599                                             TBool aIsToAlignCursor /* = ETrue */)
       
 19600 	{
       
 19601     if( IsFlagSet( EFlagInsideInlineEditingTransaction ) && 
       
 19602         IsFlagSet( EFlagInsideMultitapInlineEditingTransaction ) )
       
 19603         {
       
 19604         // Update the inline buffer with NULL descriptor.
       
 19605         // Inline buffer can be only at position 0, i.e. 
       
 19606         // where the cursor stands.
       
 19607         if( aNumOfCharacters == UncommittedText().Length()
       
 19608              && aPos == 0 )
       
 19609             {
       
 19610             UpdateInlineEditL( KNullDesC, 0 );
       
 19611             }
       
 19612         CommitInlineEditL();
       
 19613         }
       
 19614     else
       
 19615         {
       
 19616         MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 19617             iInputCapabilities.FepAwareTextEditor();
       
 19618 
       
 19619         if( fepAwareTextEditor && aPos >= 0 )
       
 19620             {
       
 19621             // Get the previous cursor position.
       
 19622             TCursorSelection cursorSelPrevious;
       
 19623             fepAwareTextEditor->GetCursorSelectionForFep( cursorSelPrevious );
       
 19624 
       
 19625             // Place the cursor at the desired position.
       
 19626             TCursorSelection sel( cursorSelPrevious.iCursorPos - aPos, 
       
 19627                             cursorSelPrevious.iCursorPos - aPos );
       
 19628         	fepAwareTextEditor->SetCursorSelectionForFepL( sel );
       
 19629 
       
 19630             // Set cursor span on previous N characters
       
 19631             if ( sel.iAnchorPos >= aNumOfCharacters )
       
 19632                 {
       
 19633                 sel.iAnchorPos -= aNumOfCharacters;
       
 19634 
       
 19635                 // get text to clear
       
 19636                 TBuf<EMaximumFepWordLength> bufToClear;
       
 19637                 fepAwareTextEditor->GetEditorContentForFep( bufToClear, sel.iAnchorPos, 
       
 19638                                                             aNumOfCharacters );
       
 19639 
       
 19640                 // delete the character with an inline edit
       
 19641                 StartInlineEditL( sel, bufToClear, aNumOfCharacters, EFalse );
       
 19642                 UpdateInlineEditL( KNullDesC, 0 );
       
 19643                 CommitInlineEditL();
       
 19644                 
       
 19645                 if( aIsToAlignCursor )
       
 19646                     {
       
 19647                     // Move the cursor to the original position considering the 
       
 19648                     // aNumOfCharacters
       
 19649                     cursorSelPrevious.iCursorPos -= aNumOfCharacters;
       
 19650                     cursorSelPrevious.iAnchorPos = cursorSelPrevious.iCursorPos;
       
 19651                     fepAwareTextEditor->SetCursorSelectionForFepL( cursorSelPrevious );
       
 19652                     }
       
 19653                 }        
       
 19654             }        
       
 19655         }
       
 19656     }
       
 19657 
       
 19658 #ifdef RD_MARATHI
       
 19659 
       
 19660 TBool CAknFepManager::IsChandraAPresentL()
       
 19661     {
       
 19662     TBool result = EFalse;
       
 19663 
       
 19664     MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 19665 		iInputCapabilities.FepAwareTextEditor();
       
 19666 
       
 19667 	if( fepAwareTextEditor )
       
 19668 		{
       
 19669 		TCursorSelection curSel;
       
 19670 		
       
 19671 		fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
 19672 		
       
 19673 		TInt lowerpos = curSel.LowerPos();
       
 19674 
       
 19675         TInt chandraALength = 2;
       
 19676         TBuf<2> buf;
       
 19677 	    TAknFepUiIndicInputManager::GetChandraA( buf );
       
 19678 
       
 19679 		if( lowerpos > ( chandraALength - 1 ) )
       
 19680 			{
       
 19681 			TBuf<2>previousCharacter;
       
 19682 
       
 19683 			fepAwareTextEditor->GetEditorContentForFep( 
       
 19684                 previousCharacter, lowerpos-chandraALength, chandraALength );
       
 19685 			
       
 19686 			if( buf.CompareC( previousCharacter ) == 0 )
       
 19687 			    {
       
 19688 			    // Chandra-A found
       
 19689 			    result = ETrue;
       
 19690 			    }
       
 19691 			}
       
 19692 		}
       
 19693     return result;
       
 19694 	}
       
 19695 
       
 19696 TBool CAknFepManager::IsEyeLashRaPresentL()
       
 19697     {
       
 19698     TBool result = EFalse;
       
 19699 
       
 19700     MCoeFepAwareTextEditor* fepAwareTextEditor = 
       
 19701 		iInputCapabilities.FepAwareTextEditor();
       
 19702 
       
 19703 	if( fepAwareTextEditor )
       
 19704 		{
       
 19705 		TCursorSelection curSel;
       
 19706 		
       
 19707 		fepAwareTextEditor->GetCursorSelectionForFep( curSel );
       
 19708 		
       
 19709 		TInt lowerpos = curSel.LowerPos();
       
 19710 
       
 19711         
       
 19712         TBuf<3> buf;
       
 19713 	    TAknFepUiIndicInputManager::GetEyeLashRa( buf, 
       
 19714 	                                    (TLanguage)iLanguageCapabilities.iInputLanguageCode );
       
 19715         TInt eyeLashRaLength = buf.Length();
       
 19716 
       
 19717 		if( ( lowerpos - eyeLashRaLength ) >= 0 )
       
 19718 			{
       
 19719 			TBuf<3>previousCharacter;
       
 19720 
       
 19721 			fepAwareTextEditor->GetEditorContentForFep( 
       
 19722                 previousCharacter, lowerpos-eyeLashRaLength, eyeLashRaLength );
       
 19723 			
       
 19724 			if( previousCharacter.Length() >=2 && 
       
 19725 			    buf.CompareC( previousCharacter ) == 0 )
       
 19726 			    {
       
 19727 			    // EyeLashRa found
       
 19728 			    result = ETrue;
       
 19729 			    }
       
 19730 			}
       
 19731 		}
       
 19732     return result;
       
 19733 	}
       
 19734 
       
 19735 #endif // RD_MARATHI
       
 19736 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
 19737 void CAknFepManager::RemoveSuggestedCompletionL()
       
 19738 {	
       
 19739 	if(iPtiEngine->InputMode() == EPtiEngineWordCompletion && 
       
 19740 	   IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
       
 19741 		{
       
 19742 			TBuf<CAknFepManager::EMaximumFepWordLength> currentText = iPtiEngine->CurrentWord();
       
 19743 			if(currentText.Length() > iPtiEngine->CurrentInputSequence().Length())
       
 19744 				{
       
 19745 				currentText.SetLength(iPtiEngine->CurrentInputSequence().Length());
       
 19746 				iPtiEngine->SetCurrentWord(currentText);
       
 19747 	    		UpdateInlineEditL(currentText,currentText.Length()); 
       
 19748    	            TransferFepStateToEditorL();
       
 19749 				}
       
 19750 			
       
 19751 		}
       
 19752 }
       
 19753 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 19754 
       
 19755 
       
 19756 // -----------------------------------------------------------------------------
       
 19757 // CAknFepManager::ExtendedInputCapabilities
       
 19758 //
       
 19759 // Returns the extended input bapabilities bitvector.
       
 19760 // -----------------------------------------------------------------------------
       
 19761 //
       
 19762 TUint CAknFepManager::ExtendedInputCapabilities() const
       
 19763     {
       
 19764     MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
 19765 
       
 19766     if ( mop && iInputCapabilities.FepAwareTextEditor() )//IsFepAwareTextEditor()
       
 19767 		{
       
 19768 		CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
 19769 		mop->MopGetObject( extendedInputCapabilities );
       
 19770 
       
 19771 		if ( extendedInputCapabilities ) 
       
 19772 			{
       
 19773 			return extendedInputCapabilities->Capabilities();
       
 19774 			}
       
 19775 		} 
       
 19776 		
       
 19777     return 0;		          
       
 19778     }
       
 19779 
       
 19780 
       
 19781 #ifdef RD_SCALABLE_UI_V2         
       
 19782 // -----------------------------------------------------------------------------
       
 19783 // CAknFepManager::LaunchStylusCcpuMenuL
       
 19784 //
       
 19785 // Displays stylus ccpu-menu.
       
 19786 // -----------------------------------------------------------------------------
       
 19787 //    
       
 19788 void CAknFepManager::LaunchStylusCcpuMenuL(TPoint &aClickPoint)
       
 19789     {
       
 19790     const TInt KItemCopy  = 0x01;
       
 19791     const TInt KItemCut   = 0x02;
       
 19792     const TInt KItemPaste = 0x04;
       
 19793     
       
 19794     delete iStylusCcpuMenu;
       
 19795     iStylusCcpuMenu = NULL;    
       
 19796      
       
 19797     // It is assume that this method is called only if there is selected
       
 19798     // text in suitable editor, ie. there will be at least "copy"-item available.
       
 19799     TInt items = KItemCopy;    
       
 19800         
       
 19801     CAknEdwinState* editorState = EditorState();
       
 19802     if (editorState && editorState->CcpuState())
       
 19803         {              
       
 19804         if (editorState->CcpuState()->CcpuCanCut())
       
 19805             {
       
 19806             items |= KItemCut;
       
 19807             }
       
 19808         if (editorState->CcpuState()->CcpuCanPaste())
       
 19809             {
       
 19810             items |= KItemPaste;
       
 19811             }                    
       
 19812         }        
       
 19813     
       
 19814     if (items)
       
 19815         {
       
 19816         TBuf<CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength> itemStr;          
       
 19817         iStylusCcpuMenu = iUiInterface->NewStylusPopUpMenuL(this, aClickPoint);     
       
 19818         
       
 19819         if (items & KItemCopy)
       
 19820             {
       
 19821             StringLoader::Load(itemStr, R_AKNFEP_SOFTKEY_COPY);            
       
 19822             iStylusCcpuMenu->AddMenuItemL(itemStr.Mid(1, itemStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength), EEikCmdEditCopy);            
       
 19823             }
       
 19824         if (items & KItemCut)
       
 19825             {                    
       
 19826             itemStr.Zero();
       
 19827             StringLoader::Load(itemStr, R_AKNFEP_SOFTKEY_CUT);            
       
 19828             iStylusCcpuMenu->AddMenuItemL(itemStr.Mid(1, itemStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength), EEikCmdEditCut);
       
 19829             }
       
 19830         if (items & KItemPaste)
       
 19831             {
       
 19832             itemStr.Zero();
       
 19833             StringLoader::Load(itemStr, R_AKNFEP_STYLUS_CCPU_MENU_PASTE);               
       
 19834             iStylusCcpuMenu->AddMenuItemL(itemStr.Mid(1, itemStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength), EEikCmdEditPaste);                
       
 19835             }
       
 19836         
       
 19837         SetCcpuFlag(ECcpuStateCopy); // This forces ProcessCommandL to handle the events.
       
 19838         iStylusCcpuMenu->SetPosition(aClickPoint);    
       
 19839         iStylusCcpuMenu->ShowMenu();       
       
 19840         }
       
 19841     }
       
 19842 #endif    
       
 19843 
       
 19844 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 19845  TBool CAknFepManager::IsFnKeyMappedL(TPtiKeyboardType aKeyboardType)
       
 19846     {
       
 19847     MPtiLanguage *lang = NULL;
       
 19848     RArray < TPtiNumericKeyBinding > keybinding;
       
 19849     TBool ret = EFalse;
       
 19850     if(iPtiEngine)
       
 19851         {
       
 19852         lang = iPtiEngine->CurrentLanguage();
       
 19853         if(lang)
       
 19854         {
       
 19855         iPtiEngine->GetNumericModeKeysForQwertyL(lang->LanguageCode(), keybinding, aKeyboardType);
       
 19856         TInt numericKeysCount = keybinding.Count();
       
 19857         while ( numericKeysCount-- )
       
 19858             {
       
 19859             TPtiNumericKeyBinding numKeyBind = keybinding[numericKeysCount];
       
 19860             if ( numKeyBind.iCase == EPtiCaseFnLower || numKeyBind.iCase == EPtiCaseFnUpper)
       
 19861                 {
       
 19862                 ret = ETrue;
       
 19863                 break;
       
 19864                     }
       
 19865                 }
       
 19866             }
       
 19867         }
       
 19868     keybinding.Reset();
       
 19869     return ret;
       
 19870     }
       
 19871 TBool CAknFepManager::IsFnKeyMapped()
       
 19872     {
       
 19873     return iIsFnKeyMapped;
       
 19874     }
       
 19875     
       
 19876 void CAknFepManager::SetFnKeyMappingState()
       
 19877     {
       
 19878     TRAP_IGNORE(iIsFnKeyMapped = IsFnKeyMappedL());
       
 19879     }
       
 19880 
       
 19881 TBool CAknFepManager::KeyMapsDifferentCharacterWithFn( TPtiKey aKey ) const
       
 19882     {
       
 19883     // we are interested only about the first mapped character => buffer length 1 is adequate
       
 19884     TBuf<1> lowerMapping; 
       
 19885     TBuf<1> upperMapping;
       
 19886     TBuf<1> lowerFnMapping; 
       
 19887     TBuf<1> upperFnMapping;
       
 19888     iPtiEngine->MappingDataForKey( aKey, lowerMapping, EPtiCaseLower );
       
 19889     iPtiEngine->MappingDataForKey( aKey, upperMapping, EPtiCaseUpper );
       
 19890     iPtiEngine->MappingDataForKey( aKey, lowerFnMapping, EPtiCaseFnLower );
       
 19891     iPtiEngine->MappingDataForKey( aKey, upperFnMapping, EPtiCaseFnUpper );
       
 19892     
       
 19893     if ( lowerFnMapping.Length() )
       
 19894         {
       
 19895         if ( !lowerMapping.Length() ||              // < key maps character only with Fn
       
 19896              lowerMapping[0] != lowerFnMapping[0] ) // < Fn changes the character of the key
       
 19897             {
       
 19898             return ETrue;
       
 19899             }
       
 19900         }
       
 19901     else if ( upperFnMapping.Length() )
       
 19902         {
       
 19903         if ( !upperMapping.Length() ||              // < key maps character only with Fn
       
 19904              upperMapping[0] != upperFnMapping[0] ) // < Fn changes the character of the key
       
 19905             {
       
 19906             return ETrue;
       
 19907             }
       
 19908         }
       
 19909     
       
 19910     return EFalse; // The key doesn't have symbol behind Fn or the symbol is the same as without Fn
       
 19911     }
       
 19912 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 19913 MAknFepDocumentNavigation* CAknFepManager::AknFepDocumentNavigation() const
       
 19914 	{
       
 19915 	MAknFepDocumentNavigation* navi = NULL;
       
 19916 	
       
 19917     MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
 19918     if ( mop )
       
 19919         {
       
 19920         mop->MopGetObject( navi );
       
 19921         }
       
 19922     
       
 19923     return navi;
       
 19924 	}
       
 19925 
       
 19926 CAknFepUIInterface* CAknFepManager::UiInterface()
       
 19927 	{
       
 19928 	return iUiInterface;
       
 19929 	}
       
 19930 
       
 19931 void CAknFepManager::AlignLogicalAndVisualCursorL()
       
 19932     {
       
 19933     TBool isIndicLang = 
       
 19934         TAknFepUiIndicInputManager::
       
 19935             IsIndicLangauge( TLanguage( iLanguageCapabilities.iInputLanguageCode ) );
       
 19936 
       
 19937     if( isIndicLang )
       
 19938         {
       
 19939         TTmDocPosSpec pos = DocPos();
       
 19940         pos.iType = TTmDocPosSpec::ETrailing;
       
 19941         TTmPosInfo2 info;
       
 19942         TTmLineInfo lineInfo;
       
 19943 
       
 19944         TBool findAvailable = EFalse;
       
 19945 
       
 19946         MAknFepDocumentNavigation* docNavi = AknFepDocumentNavigation();
       
 19947 
       
 19948         if ( docNavi )
       
 19949             {
       
 19950             docNavi->FindDocPos( pos, info, lineInfo );
       
 19951             findAvailable = ETrue;
       
 19952             }
       
 19953         else
       
 19954             {
       
 19955             CTextLayout* textLayout = TextLayout();
       
 19956             if ( textLayout )
       
 19957                 {
       
 19958                 textLayout->TagmaTextLayout().FindDocPos( pos, info, lineInfo );	    					    
       
 19959                 findAvailable = ETrue;
       
 19960                 }
       
 19961             }
       
 19962 
       
 19963         if ( findAvailable )
       
 19964             {
       
 19965             TCursorSelection sel( info.iDocPos.iPos, info.iDocPos.iPos );
       
 19966             iInputCapabilities.FepAwareTextEditor()->SetCursorSelectionForFepL(sel);
       
 19967             }
       
 19968         }
       
 19969     }
       
 19970 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 19971 TKeyResponse CAknFepManager::HandleFnKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aEventCode )
       
 19972     {
       
 19973      TKeyResponse ret; 
       
 19974      
       
 19975 #ifdef __HALF_QWERTY_KEYPAD  
       
 19976      if ( IsFlagSet( EFlagShiftKeyDepressed ) && 
       
 19977         ( EPtiKeyboardHalfQwerty == KeyboardLayout() )&& 
       
 19978         ( aEventCode != EEventKeyUp ) )
       
 19979          {
       
 19980          return EKeyWasNotConsumed;
       
 19981          }
       
 19982 #endif
       
 19983      
       
 19984      if (!iCurrentFepUI->IsValidFnKeyPress() && EStdKeyRightFunc == aKeyEvent.iScanCode)
       
 19985      	{
       
 19986      	TBool Uiret = ETrue;
       
 19987      	if (EEventKeyDown == aEventCode )
       
 19988      		{
       
 19989       		Uiret = FepUI()->HandleKeyL(EKeyRightFunc, EShortKeyPress);     		
       
 19990      		}
       
 19991      		
       
 19992      	if (Uiret)
       
 19993      		{
       
 19994      		ret = EKeyWasConsumed;
       
 19995      		}
       
 19996         else
       
 19997         	{
       
 19998      	    ret = iFnKeyManager->HandleFnKeyEventL( aKeyEvent, aEventCode, 
       
 19999                                             	    iInputCapabilities ) ;     	        	
       
 20000         	}	 
       
 20001      	}
       
 20002      else
       
 20003      	{
       
 20004 		//Handle Fn key and consider long press case
       
 20005 		if( EStdKeyRightFunc == aKeyEvent.iScanCode )
       
 20006 			{
       
 20007 			switch(aEventCode)
       
 20008 				{
       
 20009 				case EEventKeyDown:
       
 20010 					ActivateFnkeyPressMonitor();
       
 20011 					break;
       
 20012 				case EEventKeyUp:
       
 20013 					{
       
 20014 					if(!iFnKeypressMonitor->IsActive())
       
 20015 					   {
       
 20016 					    //when long pressing event occurrs,
       
 20017                         //event has been already handled in HandleFnKeyPressMonitorCallback()
       
 20018 						return EKeyWasConsumed;
       
 20019 					   }
       
 20020 					//when short pressing event occurs, 
       
 20021                     //only deactive fn Key press monitor and normal event handle flow will work
       
 20022 					DeactivateFnkeyPressMonitor();
       
 20023 					}
       
 20024 					break;
       
 20025 				default:
       
 20026 					break;	
       
 20027 				}			  
       
 20028 			}
       
 20029      	ret = iFnKeyManager->HandleFnKeyEventL( aKeyEvent, aEventCode, 
       
 20030                                             	iInputCapabilities ) ;     	
       
 20031      	}
       
 20032      if(IsHybridAplhaEditor() && !iHybridAplphaChangedToAlphanumeric)
       
 20033          {
       
 20034          if(FnKeyState() != CAknFepFnKeyManager::EFnKeyLock)
       
 20035             iHybridAplphaChangedToAlphanumeric = ETrue;
       
 20036          }
       
 20037 
       
 20038      return ret;
       
 20039     }
       
 20040 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 20041 
       
 20042 // -----------------------------------------------------------------------------
       
 20043 // CAknFepManager::HasJapanesePredictionInputMode
       
 20044 // Has Japanese prediction input mode in PtiEngine
       
 20045 // -----------------------------------------------------------------------------
       
 20046 //
       
 20047 TBool CAknFepManager::HasJapanesePredictionInputMode() const
       
 20048     {
       
 20049     // Is it supported Japanese predictive input
       
 20050     TBool ret = EFalse;
       
 20051     MPtiLanguage* ptilang = iPtiEngine->GetLanguage(ELangJapanese);
       
 20052     if ( ptilang
       
 20053      &&  ( (!iQwertyInputMode && ptilang->HasInputMode(EPtiEngineHiraganaKanjiPredictive))
       
 20054          ||(iQwertyInputMode && ptilang->HasInputMode(EPtiEngineHiraganaKanjiPredictiveQwerty)) ) )
       
 20055         {
       
 20056         ret = ETrue;
       
 20057         }
       
 20058     return ret;
       
 20059     }
       
 20060 #ifdef RD_HINDI_PHONETIC_INPUT
       
 20061 void CAknFepManager::HandleIndicCaseL()
       
 20062 	{
       
 20063 		iHashKeyMan->HandleSetIndicStateL();
       
 20064 	}
       
 20065 #endif
       
 20066 
       
 20067 // -----------------------------------------------------------------------------
       
 20068 // CAknFepManager::IsCursorAtEndOfWord
       
 20069 // 
       
 20070 // -----------------------------------------------------------------------------
       
 20071 //    
       
 20072 TBool CAknFepManager::IsCursorAtEndOfWord()
       
 20073     {   
       
 20074     iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(iUncommittedText);
       
 20075     TInt origPos = iUncommittedText.iCursorPos; 
       
 20076    
       
 20077     FindEndOfWord(iUncommittedText.iCursorPos);
       
 20078        
       
 20079     if (origPos != iUncommittedText.iCursorPos)
       
 20080         {
       
 20081         return EFalse;
       
 20082         }
       
 20083         
       
 20084     return ETrue;        
       
 20085     }
       
 20086 
       
 20087 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 20088 TInt CAknFepManager::GetCurrentCase()
       
 20089     {
       
 20090     TCase returnCase;
       
 20091     
       
 20092     switch( iCaseMan->CurrentCase() )
       
 20093         {
       
 20094         case EAknEditorUpperCase:
       
 20095         case EAknEditorTextCase:
       
 20096             {
       
 20097             returnCase = EUpperCase;
       
 20098             }
       
 20099             break;
       
 20100 
       
 20101         case EAknEditorLowerCase:
       
 20102             {
       
 20103             returnCase = ELowerCase;
       
 20104             }
       
 20105             break;
       
 20106         
       
 20107         default:
       
 20108             returnCase = ELowerCase;
       
 20109             break;
       
 20110         }
       
 20111     return returnCase;
       
 20112     }
       
 20113 // Predictive QWERTY changes (XT9) ---->
       
 20114 
       
 20115 void CAknFepManager::GetCandidatesL( CDesCArray& aArray, TInt& aActiveIdx )
       
 20116     {
       
 20117     iPtiEngine->GetCandidateListL(aArray);
       
 20118     iPtiEngine->HandleCommandL(
       
 20119             EPtiCommandUserActionGetCurrentIndexOfCandidates, &aActiveIdx);
       
 20120     }
       
 20121 
       
 20122 void CAknFepManager::GetUpdateCandidatePositionL(TRect& aRect)
       
 20123     {
       
 20124      if(iCandidatePopup && iFepFullyConstructed && iPtiEngine)
       
 20125         {
       
 20126         //Now we read the position of the inline text
       
 20127         TPoint  inlineEditorTl;
       
 20128         TPoint  inlineEditorBr;
       
 20129         TInt    height;
       
 20130         TInt    ascent;
       
 20131         TInt    documentOffset = iPtiEngine->CurrentWord().Length();
       
 20132         //  Popup Position for RTL
       
 20133         if(iLanguageCapabilities.iRightToLeftLanguage)
       
 20134             documentOffset = 0;
       
 20135         //  Popup Position for RTL
       
 20136         GetScreenCoordinatesL(inlineEditorTl, height, ascent, documentOffset);
       
 20137         inlineEditorTl.iY -= height;
       
 20138         GetScreenCoordinatesL(inlineEditorBr, height, ascent);
       
 20139         aRect.iTl = inlineEditorTl;
       
 20140         aRect.iBr = inlineEditorBr;
       
 20141         }
       
 20142     }
       
 20143 
       
 20144 TBool CAknFepManager::IsRightToLeftLanguage()
       
 20145 	{
       
 20146 	return iLanguageCapabilities.iRightToLeftLanguage ;
       
 20147 	}
       
 20148 
       
 20149 /**
       
 20150 * Setter for the advanced predictive typing correction.
       
 20151 * @param    aLevel   The level to be set.
       
 20152 */
       
 20153 void CAknFepManager::SetTypingCorrectionLevel(TInt aLevel)
       
 20154 	{
       
 20155 	iTypingCorrectionLevel = aLevel;
       
 20156     
       
 20157 	if(iFepFullyConstructed)
       
 20158 		{
       
 20159 		TPtiErrorCorrectionLevel correctionLevel = (TPtiErrorCorrectionLevel)aLevel;
       
 20160 		TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandSetCorrectionLevel, &correctionLevel ));	
       
 20161 		}
       
 20162 	}
       
 20163 	
       
 20164 /**
       
 20165 * Resetter for the advanced predictive Number Candidate setting.
       
 20166 * @param    aValue   The value to be set.
       
 20167 */
       
 20168 void CAknFepManager::SetNumberCandidateState(TInt aValue)
       
 20169 	{
       
 20170 	if(aValue == 0)
       
 20171 		iIsNumberCandidateShown = EFalse;
       
 20172 	else if(aValue == 1)
       
 20173 		iIsNumberCandidateShown = ETrue;
       
 20174 	
       
 20175 	if(iFepFullyConstructed)
       
 20176 		{
       
 20177 		TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandSetNumberCandidateStatus, 
       
 20178 		                                        &iIsNumberCandidateShown ));
       
 20179 		}
       
 20180 	}
       
 20181 	
       
 20182 void CAknFepManager::RemoveSuggestedAdvanceCompletionL()
       
 20183     {	
       
 20184     if( IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction) &&
       
 20185         iPtiEngine->CurrentWord().Length() )
       
 20186         {
       
 20187         TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandUserActionShorten ));
       
 20188         TPtrC currentText = iPtiEngine->CurrentWord();
       
 20189         UpdateInlineEditL( currentText, currentText.Length() );
       
 20190         }
       
 20191     }
       
 20192 /**
       
 20193 * Setes the current state from GS to the local state
       
 20194 */    
       
 20195    
       
 20196 void CAknFepManager::SetAutoCompletionState(TInt aValue) 
       
 20197 	{
       
 20198 	if(aValue == 0)
       
 20199 		{
       
 20200 		iIsAutoCompleteOn = EFalse;
       
 20201 		}
       
 20202 	else if(aValue == 1)
       
 20203 		{
       
 20204 		iIsAutoCompleteOn = ETrue;
       
 20205 		}
       
 20206 	 
       
 20207 	if(iFepFullyConstructed)
       
 20208 		{
       
 20209 		if(iIsAutoCompleteOn)
       
 20210 			{
       
 20211 			TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandEnableAutoCompletion  ));
       
 20212 			}
       
 20213 		else
       
 20214 			{
       
 20215 			TInt tailLength = 0;
       
 20216 			TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandGetAutoCompletionTailLength, &tailLength ));
       
 20217 			if(tailLength > 0)
       
 20218 				{
       
 20219 				// send an update to engine to signify change in autocompletion from on to off while tail exists
       
 20220 				// This will set EPtiXt9FlagAutoCompletionSetOnToOff flag as true in engine
       
 20221 				TInt value = 1;
       
 20222 				TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandAutoCompletionOnToOff,&value));				
       
 20223 				}
       
 20224 			
       
 20225 			
       
 20226 			TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandDisableAutoCompletion ));
       
 20227 			}
       
 20228 		}
       
 20229 	}
       
 20230 	
       
 20231 /**
       
 20232 * Sets the primary candidate from GS to the local state
       
 20233 */    
       
 20234    
       
 20235 void CAknFepManager::SetPrimaryCandidate(TInt aValue) 
       
 20236 	{
       
 20237 	if(aValue == 0)
       
 20238 		iPrimaryCandidate = ETrue;
       
 20239 	else if(aValue == 1)
       
 20240 		iPrimaryCandidate = EFalse;    
       
 20241 	if(iFepFullyConstructed)
       
 20242 		{
       
 20243 		TRAP_IGNORE(iPtiEngine->HandleCommandL( EPtiCommandSetProactiveCorrection, 
       
 20244 		                                        &iPrimaryCandidate ));
       
 20245 		}
       
 20246 	}
       
 20247 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 20248     
       
 20249 CAknFepPluginManager* CAknFepManager::PluginUIManager()
       
 20250     {
       
 20251 #ifdef RD_SCALABLE_UI_V2
       
 20252 
       
 20253     return iFepPluginManager;
       
 20254 #else
       
 20255     return NULL;        
       
 20256 #endif //RD_SCALABLE_UI_V2     
       
 20257     }
       
 20258 
       
 20259 // add for phrase creation
       
 20260 MZhuyinKeyHandler* CAknFepManager::ZhuyinKeyHandler()
       
 20261     {
       
 20262     return iZhuyinKeyHandler;
       
 20263     }
       
 20264 // add for phrase creation
       
 20265 CAknFepZhuyinAnalyser* CAknFepManager::ZhuyinAnalyser()
       
 20266     {
       
 20267     return iZhuyinAnalyser;
       
 20268     }
       
 20269 
       
 20270 #ifdef RD_SCALABLE_UI_V2
       
 20271 void CAknFepManager::UpdateTouchCaseMode()
       
 20272 	{
       
 20273     if (iFepFullyConstructed && 
       
 20274         iFepPluginManager 
       
 20275         // case should be updated even if current input mode is none because iPreviousCoseMode
       
 20276         // still need to be updated.
       
 20277         /*&& 
       
 20278         iFepPluginManager->PluginInputMode() != EPluginInputModeNone*/)
       
 20279     	{
       
 20280     	iFepPluginManager->UpdateCaseMode();	
       
 20281     	}
       
 20282 	}
       
 20283 #endif// RD_SCALABLE_UI_V2
       
 20284 
       
 20285 void CAknFepManager::SetStopProcessFocus(TBool aStop, TBool aClose)
       
 20286     {
       
 20287     iClosePeninputUi = aClose;
       
 20288     iStopProcessFocus = aStop;
       
 20289     if (!aStop)
       
 20290         {
       
 20291         HandleChangeInFocus();
       
 20292         }
       
 20293     }
       
 20294     
       
 20295 TBool CAknFepManager::StopProcessFocus()
       
 20296     {
       
 20297     return iStopProcessFocus;    
       
 20298     }
       
 20299     
       
 20300 TBool CAknFepManager::CloseUiOnFocusChange()
       
 20301     {
       
 20302     return iClosePeninputUi;    
       
 20303     }
       
 20304 void CAknFepManager::HandleCopyCutStateL()    
       
 20305 {
       
 20306     if (IsCcpuFlagSet(ECcpuStateCopy | ECcpuStateCut))
       
 20307                 {
       
 20308                 TCursorSelection selection;
       
 20309                 iInputCapabilities.FepAwareTextEditor()->GetCursorSelectionForFep(selection);
       
 20310                 TBool update;
       
 20311                 if (selection.Length() > 0)
       
 20312                     {
       
 20313                     if (!IsCcpuFlagSet(ECcpuStateButton))
       
 20314                         {
       
 20315                         __ASSERT_DEBUG(iUiInterface->SoftkeysExist(),
       
 20316                                        AknFepPanic(EAknFepPanicNoHandleToFepAwareTextEditor));                         
       
 20317                         if (IsCcpuFlagSet(ECcpuStateCopy))                      
       
 20318                             {
       
 20319                             update = UpdateCBALabelL(ELeftSoftkeyIndex, EEikCmdEditCopy, R_AKNFEP_SOFTKEY_COPY);
       
 20320                             update |= UpdateCBALabelL( EMiddleSoftkeyIndex, EEikCmdEditCopy, R_AVKON_SOFTKEY_SELECT_TEXT ); 
       
 20321                             }
       
 20322                         else
       
 20323                             {
       
 20324                             update = UpdateCBALabelL(ELeftSoftkeyIndex, EEikCmdEditCut, R_AKNFEP_SOFTKEY_CUT);                          
       
 20325                             update |= UpdateCBALabelL( EMiddleSoftkeyIndex, EEikCmdEditCut, R_AVKON_SOFTKEY_SELECT_TEXT ); 
       
 20326                             }
       
 20327                         if (update)
       
 20328                             {
       
 20329                             iUiInterface->DrawSoftkeysNow();
       
 20330                             }               
       
 20331                         SetCcpuFlag(ECcpuStateButton);                                      
       
 20332                         }                   
       
 20333                     }   
       
 20334                 else if (IsCcpuFlagSet(ECcpuStateButton))                        
       
 20335                     {                   
       
 20336                     ClearCcpuFlag(ECcpuStateButton);
       
 20337                     update = EFalse;
       
 20338                     update = UpdateCBALabelL(ELeftSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY);
       
 20339                     update |= UpdateCBALabelL( EMiddleSoftkeyIndex, KNullCommandId, R_TEXT_SOFTKEY_EMPTY );
       
 20340                     if (update)
       
 20341                         {
       
 20342                         iUiInterface->DrawSoftkeysNow();
       
 20343                         }               
       
 20344                     }
       
 20345                 }    
       
 20346 }    
       
 20347 #ifdef RD_SCALABLE_UI_V2
       
 20348 TInt GetForegroundTaskAppWgId()
       
 20349     {
       
 20350     TApaTaskList tList(CCoeEnv::Static()->WsSession());
       
 20351     
       
 20352     TApaTask task = tList.FindByPos(0);
       
 20353     return task.WgId();
       
 20354     }
       
 20355 
       
 20356 void CAknFepManager::DimInputmodeTouchMenuItems(CAknFepUiInterfaceMenuPane* aMenuPane)
       
 20357     {
       
 20358     DimEditMenuModeItems(aMenuPane);
       
 20359 
       
 20360     if ( IsChineseInputLanguage() )
       
 20361         {
       
 20362         DoChineseTouchMenu(aMenuPane);
       
 20363         }
       
 20364     else if ( iLanguageCapabilities.iInputLanguageCode == ELangJapanese)
       
 20365         {
       
 20366         DoJapaneseMenu(aMenuPane);
       
 20367         }
       
 20368     else
       
 20369         {
       
 20370         DoWesternTouchMenu(aMenuPane);
       
 20371         }
       
 20372     }
       
 20373 #endif
       
 20374 
       
 20375 void CAknFepManager::DimInputmodeMenuItems(CAknFepUiInterfaceMenuPane* aMenuPane)
       
 20376     {
       
 20377     DimEditMenuModeItems(aMenuPane);
       
 20378 
       
 20379     if ( IsChineseInputLanguage() )
       
 20380         {
       
 20381         DoChineseMenu(aMenuPane);
       
 20382         }
       
 20383     else if ( iLanguageCapabilities.iInputLanguageCode == ELangJapanese)
       
 20384         {
       
 20385         DoJapaneseMenu(aMenuPane);
       
 20386         }
       
 20387     else
       
 20388         {
       
 20389         DoWesternMenu(aMenuPane);
       
 20390         }
       
 20391     }
       
 20392 
       
 20393 void CAknFepManager::HandleCopyCutEventL(TInt aCommandId)
       
 20394     {
       
 20395      if (iCcpuMode != ECcpuStateNone)
       
 20396         {                   
       
 20397         ResetCcpuFlags();                   
       
 20398         iUiInterface->DeleteSoftkeys();
       
 20399                     
       
 20400         SetCcpuFlag(ECcpuStatePosted);  
       
 20401                                          
       
 20402 #ifdef RD_SCALABLE_UI_V2                    
       
 20403         if (aCommandId == EEikCmdEditCopy)
       
 20404             {                     
       
 20405             // Send copy event to AknCcpuSupport.
       
 20406             CCoeEnv::Static()->SimulateKeyEventL(KAknCcpuCopyEvent, EEventKey);
       
 20407             }
       
 20408         else
       
 20409             {
       
 20410             // Send cut event to AknCcpuSupport.
       
 20411             CCoeEnv::Static()->SimulateKeyEventL(KAknCcpuCutEvent, EEventKey);
       
 20412             }                               
       
 20413 #else         
       
 20414 /*As part of build warnings commenting this perticular code it might require when touch is enabled.        
       
 20415         if (aCommandId == EEikCmdEditCopy)
       
 20416             {                                          
       
 20417             // Send copy-event to editor.
       
 20418             CCoeEnv::Static()->SimulateKeyEventL(KEditorCopyEvent, EEventKey);
       
 20419             }
       
 20420         else 
       
 20421             {                       
       
 20422             // send cut-event to editor.         
       
 20423             CCoeEnv::Static()->SimulateKeyEventL(KEditorCutEvent, EEventKey);
       
 20424             } 
       
 20425 			*/            
       
 20426 #endif // RD_SCALABLE_UI_V2 
       
 20427 
       
 20428         if (iInputCapabilities.FepAwareTextEditor())                                
       
 20429             {
       
 20430             // update indicators only if this is editable component.
       
 20431             iIndicator->SetCopyMode(EFalse);
       
 20432             UpdateIndicators();                                                           
       
 20433             }
       
 20434 #ifdef  RD_SCALABLE_UI_V2       	 
       
 20435         HandleChangeInFocus();
       
 20436 #endif
       
 20437         
       
 20438         }
       
 20439 
       
 20440     }
       
 20441 
       
 20442 TInt CAknFepManager::FepShowVkbPreviewStatus()
       
 20443     {
       
 20444     return iSharedDataInterface->FepShowVkbPreviewStatus();    
       
 20445     }
       
 20446 
       
 20447 void CAknFepManager::InitPreviewMenuPane(CAknFepUiInterfaceMenuPane* aMenuPane)
       
 20448     {
       
 20449     if (FepShowVkbPreviewStatus() > 0)
       
 20450         {
       
 20451         aMenuPane->GetMenuPane()->SetItemButtonState(EPenInputCmdPreviewOn, 
       
 20452                                                      EEikMenuItemSymbolOn );
       
 20453         }
       
 20454     else
       
 20455         {
       
 20456         aMenuPane->GetMenuPane()->SetItemButtonState(EPenInputCmdPreviewOff, 
       
 20457                                                      EEikMenuItemSymbolOn );
       
 20458         }
       
 20459     }
       
 20460 
       
 20461 void CAknFepManager::SynCCPSoftKey()
       
 20462     {
       
 20463     TRAP_IGNORE(HandleCopyCutStateL());   
       
 20464     }
       
 20465 
       
 20466 TInt CAknFepManager::PluginInputMode() const
       
 20467 {
       
 20468 #ifdef RD_SCALABLE_UI_V2
       
 20469     return iFepPluginManager ? iFepPluginManager->PluginInputMode() : EPluginInputModeNone;
       
 20470 #else
       
 20471     return EPluginInputModeNone;
       
 20472 #endif 
       
 20473 }
       
 20474 
       
 20475 void CAknFepManager::HandleEndKeyL()
       
 20476     {
       
 20477 #ifdef RD_SCALABLE_UI_V2 
       
 20478 
       
 20479     if (iFepPluginManager)
       
 20480         {
       
 20481         return;    
       
 20482         }
       
 20483 
       
 20484     RWsSession &ws = CCoeEnv::Static()->WsSession();
       
 20485     //TInt wgId =ws.GetFocusWindowGroup();
       
 20486     CApaWindowGroupName* wg = CApaWindowGroupName::NewLC(ws,
       
 20487         CCoeEnv::Static()->WsSession().GetFocusWindowGroup());
       
 20488 
       
 20489     TUid id = wg->AppUid();
       
 20490     CleanupStack::PopAndDestroy(wg); 
       
 20491 
       
 20492     if (0x10207218 == id.iUid ||
       
 20493         0x10281EF2 == id.iUid)
       
 20494         {
       
 20495         RPeninputServer iPenInputServer;
       
 20496 
       
 20497         TInt err = iPenInputServer.Connect();
       
 20498 		if(err == KErrNone)
       
 20499 			{
       
 20500 			iPenInputServer.SetForeground(ETrue);
       
 20501 			iPenInputServer.ActivateLayout( EFalse ); 
       
 20502 			iPenInputServer.HandleCommand(ECmdPenInputWindowClose);
       
 20503 			
       
 20504 			iPenInputServer.ClearServerEvent();
       
 20505 			iPenInputServer.LoseForeground();
       
 20506 			iPenInputServer.Close();
       
 20507 			}
       
 20508         }
       
 20509 #endif //RD_SCALABLE_UI_V2         
       
 20510     }
       
 20511 void CAknFepManager::NeedDisableKeySound(const TKeyEvent& aKeyEvent, TEventCode aEventCode)
       
 20512     {
       
 20513 #ifdef RD_SCALABLE_UI_V2    
       
 20514     TInt keyCode = aKeyEvent.iScanCode;
       
 20515     TBool interestKey = EFalse;
       
 20516     if ( keyCode == EPtiKey0 || 
       
 20517          keyCode == EPtiKey1 ||
       
 20518          keyCode == EPtiKey2 ||
       
 20519          keyCode == EPtiKey3 ||
       
 20520          keyCode == EPtiKey4 ||
       
 20521          keyCode == EPtiKey5 ||
       
 20522          keyCode == EPtiKey6 ||
       
 20523          keyCode == EPtiKey7 ||
       
 20524          keyCode == EPtiKey8 ||
       
 20525          keyCode == EPtiKey9 ||
       
 20526          keyCode == EStdKeyDownArrow ||
       
 20527          keyCode == EStdKeyRightArrow ||
       
 20528          keyCode == EStdKeyLeftArrow ||
       
 20529          keyCode == EStdKeyUpArrow ||
       
 20530          keyCode == EStdKeyBackspace
       
 20531          )
       
 20532         {
       
 20533         interestKey = ETrue;
       
 20534         }
       
 20535     if( interestKey && iFepPluginManager && 
       
 20536         iFepPluginManager->PluginInputMode() == EPluginInputModeItut)
       
 20537         {
       
 20538         if( aEventCode == EEventKeyDown )
       
 20539             {
       
 20540             static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi())->
       
 20541                  DisableNextKeySound( keyCode ); 
       
 20542             }
       
 20543         else if( aEventCode == EEventKey )
       
 20544             {
       
 20545 			#ifdef RD_TACTILE_FEEDBACK
       
 20546             MTouchFeedback::Instance()->
       
 20547                 InstantFeedback(ETouchFeedbackSensitive);
       
 20548 			#endif
       
 20549             }
       
 20550         }
       
 20551 #endif     
       
 20552     }
       
 20553 
       
 20554 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 20555 void CAknFepManager::SetComposChrFlag( TBool aFlag )
       
 20556     {
       
 20557     iComposChrFlag = aFlag;
       
 20558     }
       
 20559 TBool CAknFepManager::GetComposChrFlag( )
       
 20560     {
       
 20561     return iComposChrFlag;
       
 20562     }
       
 20563 #endif
       
 20564 
       
 20565 // add for phrase creation User db view
       
 20566 void CAknFepManager::AddUserDBDlgItemL( CAknFepUiInterfaceMenuPane* aMenuPane, TInt aIndex )
       
 20567     {
       
 20568     CAknFepUiInterfaceMenuPane::SItemData mData;
       
 20569 
       
 20570     TBuf<KMaxFileName> langStr;
       
 20571     TInt Inputlangindex;
       
 20572     if (!aMenuPane->MenuItemExists(EAknCmdUserDBDlg, Inputlangindex))
       
 20573         {
       
 20574         StringLoader::Load(langStr, R_AKNFEP_OPTIONS_USER_DB_DLG);
       
 20575 
       
 20576         mData.iCommandId = EAknCmdUserDBDlg;
       
 20577         mData.iCascadeId = 0;
       
 20578         mData.iFlags = 0;
       
 20579         mData.iText.Copy(langStr.Mid(1, langStr.Length() - 1).Left(CAknFepUiInterfaceMenuPane::SItemData::ENominalTextLength));
       
 20580 
       
 20581         aMenuPane->InsertMenuItemL(mData, aIndex);
       
 20582         }
       
 20583     }
       
 20584 // add for phrase creation
       
 20585 void CAknFepManager::LaunchUserDBDlgL( )
       
 20586     {
       
 20587     TInt itemIndex = 0;
       
 20588     
       
 20589     //Change title text
       
 20590     CEikStatusPane* statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane();
       
 20591     CAknTitlePane* title = static_cast< CAknTitlePane* >(
       
 20592         statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle) ) );
       
 20593 
       
 20594     //Save the old title tet
       
 20595     HBufC* Oldtitletext = title->Text()->AllocLC();
       
 20596     //Load the new title text
       
 20597     HBufC* titletext = StringLoader::LoadLC( R_AKNFEP_USER_DB_MANAGEMENT_TITLE );
       
 20598     //Set title to the new text
       
 20599     title->SetTextL( *titletext );
       
 20600 
       
 20601     CDesCArray* items = new( ELeave ) CDesCArrayFlat( KSelectItemSize );
       
 20602     CleanupStack::PushL( items );
       
 20603     CArrayFix<TInt>* selectedItems = new( ELeave ) CArrayFixFlat<TInt>( KSelectItemSize );
       
 20604     CleanupStack::PushL( selectedItems );
       
 20605     
       
 20606     CAknToolbar* toolbar = iAvkonAppUi->CurrentFixedToolbar();
       
 20607     
       
 20608     if( toolbar && toolbar->IsShown() && toolbar->CountComponentControls()>0 )
       
 20609         {
       
 20610         toolbar->SetDimmed( ETrue );
       
 20611         toolbar->DrawDeferred();
       
 20612         }
       
 20613     
       
 20614     TUid naviPaneUid;
       
 20615 	naviPaneUid.iUid = EEikStatusPaneUidNavi;
       
 20616 
       
 20617 	CEikStatusPaneBase::TPaneCapabilities subPane =
       
 20618 			statusPane->PaneCapabilities(naviPaneUid);
       
 20619 	// if we can access the navigation pane
       
 20620 	if (subPane.IsPresent() && subPane.IsAppOwned())
       
 20621 		{
       
 20622 		CAknNavigationControlContainer
       
 20623 				* naviPane =
       
 20624 						(CAknNavigationControlContainer *) statusPane->ControlL(naviPaneUid);
       
 20625 		iTapGroup = naviPane->CreateTabGroupL();
       
 20626 		iTapGroup->MakeVisible( EFalse );
       
 20627 		naviPane->PushL( *iTapGroup );
       
 20628 		}
       
 20629     
       
 20630     iUserdbdlg = CAknFepUserdbDlg::NewL( itemIndex,
       
 20631         selectedItems, items, R_AKNFEP_USERDB_DLG_MENUBAR, iPtiEngine, this );
       
 20632     
       
 20633     iIsUserdbdlgActive = 1;
       
 20634     
       
 20635     iUserdbdlg->RunLD();
       
 20636     
       
 20637     iIsUserdbdlgActive = 0;
       
 20638     
       
 20639 	// if we can access the navigation pane
       
 20640 	if (subPane.IsPresent() && subPane.IsAppOwned())
       
 20641 		{
       
 20642 
       
 20643 		CAknNavigationControlContainer
       
 20644 				* naviPane =
       
 20645 						(CAknNavigationControlContainer *) statusPane->ControlL(naviPaneUid);
       
 20646 		naviPane->Pop();
       
 20647 		delete iTapGroup;
       
 20648 		iTapGroup = NULL;
       
 20649 		}
       
 20650 	
       
 20651     //Set the title to old text
       
 20652     title->SetTextL( *Oldtitletext );
       
 20653     
       
 20654     if( toolbar )
       
 20655         {
       
 20656         toolbar->SetDimmed( EFalse );
       
 20657         toolbar->DrawNow();
       
 20658         }
       
 20659     
       
 20660     CleanupStack::PopAndDestroy( selectedItems );
       
 20661     CleanupStack::PopAndDestroy( items );
       
 20662     CleanupStack::PopAndDestroy( titletext );
       
 20663     CleanupStack::PopAndDestroy( Oldtitletext );
       
 20664     iUserdbdlg = NULL;
       
 20665     }
       
 20666 // add for phrase creation
       
 20667 TBool CAknFepManager::IsPinyinPhraseCreation() const
       
 20668     {
       
 20669     return iPinyinPhraseCreation;
       
 20670     }
       
 20671 
       
 20672 void CAknFepManager::PinyinPhraseCreation(  TBool aPinyinPhraseCreation )
       
 20673     {
       
 20674     if ( iPinyinPhraseCreation != aPinyinPhraseCreation )
       
 20675         {
       
 20676         iPinyinPhraseCreation = aPinyinPhraseCreation;
       
 20677         }
       
 20678     }
       
 20679 // add for phrase creation
       
 20680 TBool CAknFepManager::IsPhraseCreation() const
       
 20681     {
       
 20682     return iPhraseCreation;
       
 20683     }
       
 20684 // add for phrase creation
       
 20685 void CAknFepManager::PhraseCreation(  TBool aPhraseCreation )
       
 20686     {
       
 20687     if ( iPhraseCreation != aPhraseCreation )
       
 20688         {
       
 20689         iPhraseCreation = aPhraseCreation;
       
 20690         }
       
 20691     }
       
 20692 // add for phrase creation
       
 20693 TBool CAknFepManager::IsEntryPhrase() const
       
 20694     {
       
 20695     return iEntryPhrase;
       
 20696     }
       
 20697 // add for phrase creation
       
 20698 void CAknFepManager::EntryPhrase( TBool aEntryPhrase )
       
 20699     {
       
 20700     if ( iEntryPhrase != aEntryPhrase )
       
 20701         {
       
 20702         iEntryPhrase = aEntryPhrase;
       
 20703         }
       
 20704     }
       
 20705 // add for phrase creation
       
 20706 void CAknFepManager::EnableKeyStar( TBool aEnable )
       
 20707     {
       
 20708     if ( iKeyStar != aEnable )
       
 20709         {
       
 20710         iKeyStar = aEnable;
       
 20711         }
       
 20712     }
       
 20713 // add for phrase creation
       
 20714 TBool CAknFepManager::IsEnableKeyStar( ) const
       
 20715     {
       
 20716     return iKeyStar;
       
 20717     }
       
 20718 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
 20719 	
       
 20720 
       
 20721 #ifdef __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
 20722 /**
       
 20723 * @return   ETrue   If the number entry with long key press is supported on QWERTY keyboard.
       
 20724 */
       
 20725 TBool CAknFepManager::LongPressNumberEntryOnQwerty() const
       
 20726     {
       
 20727     TBool value = EFalse;
       
 20728     if ( iSharedDataInterface )
       
 20729         {
       
 20730         value = iSharedDataInterface->LongPressNumberEntryOnQwerty();
       
 20731         }
       
 20732     return value;
       
 20733     }
       
 20734 
       
 20735 #endif // __ITI_LONGPRESS_NUM_SHIFT_COPYPASTE__
       
 20736 
       
 20737 
       
 20738 void CAknFepManager::MultitapThroughSCTCharL(TCallBack aCallBack)
       
 20739     {
       
 20740     
       
 20741 	TInt res = GetNumericSCTResID();
       
 20742     
       
 20743     if(!res)
       
 20744     	{
       
 20745     	return;
       
 20746     	}
       
 20747 
       
 20748     if(!iNumericResourceTimer)
       
 20749         {        
       
 20750         iNumericResourceTimer = CChrMultiTapTimer::NewL(aCallBack);
       
 20751         }
       
 20752     
       
 20753     if(!iResourceString || iNumericResourceId !=res )
       
 20754         {
       
 20755         // either the resource string has not be created or the resource ID has changed
       
 20756         if(iResourceString)
       
 20757             {
       
 20758             delete iResourceString;
       
 20759             iResourceString = NULL;
       
 20760             }
       
 20761         iNumericResourceId = res;
       
 20762         TResourceReader reader;
       
 20763         CEikonEnv::Static()->CreateResourceReaderLC(reader,iNumericResourceId);
       
 20764         reader.ReadInt32(); // skip sct id 
       
 20765         iResourceString = reader.ReadHBufC16L();
       
 20766         CleanupStack::PopAndDestroy();
       
 20767         }
       
 20768     if(!iResourceString)
       
 20769         {
       
 20770         return;
       
 20771         }
       
 20772     if(iNumericResourceTimer->IsActive())
       
 20773         {
       
 20774         if( iChrCharIndex == iResourceString->Length() )
       
 20775             {
       
 20776             iChrCharIndex = 0;            
       
 20777             }
       
 20778     
       
 20779         iNumericResourceTimer->Cancel();
       
 20780         iNumericResourceTimer->After(KChrKeyMultitapTimeout);        
       
 20781         }
       
 20782     else
       
 20783         {
       
 20784         iChrCharIndex = 0;
       
 20785         iNumericResourceTimer->After(KChrKeyMultitapTimeout);
       
 20786         }    
       
 20787     TBuf<1> buf;
       
 20788     buf.Append((*iResourceString)[iChrCharIndex]); 
       
 20789     NewCharacterL(buf);
       
 20790     iChrCharIndex++;
       
 20791     	if (iResourceString->Length() == 1)
       
 20792 		{
       
 20793 		NumericResourceMultiTapTimerTimeoutL();
       
 20794 		}
       
 20795 
       
 20796     }
       
 20797 TBool CAknFepManager::NumericResourceMultiTapTimerTimeoutL()
       
 20798     {
       
 20799     if(iNumericResourceTimer->IsActive())
       
 20800     	{
       
 20801     	iNumericResourceTimer->Cancel();
       
 20802     	if(IsFlagSet(CAknFepManager::EFlagInsideMultitapInlineEditingTransaction))
       
 20803 	        {
       
 20804 	        CommitInlineEditL();
       
 20805 	        return ETrue;
       
 20806 	        } 
       
 20807     	}       
       
 20808     return EFalse;    
       
 20809     }    
       
 20810 void CAknFepManager::ChangeMfneAmPm()
       
 20811     {
       
 20812 	//trigger when touch at "AM" or "PM" in ICF
       
 20813     if (iInputCapabilities.FepAwareTextEditor() && IsMfneEditor() )
       
 20814         {
       
 20815         MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
 20816         if ( mop && iInputCapabilities.FepAwareTextEditor() )
       
 20817             {
       
 20818             CAknExtendedInputCapabilities* extendedInputCapabilities = 
       
 20819                 mop->MopGetObject( extendedInputCapabilities );
       
 20820             if ( extendedInputCapabilities->Capabilities() && CAknExtendedInputCapabilities::EInputEditorAmPm )// if support AM/PM toggle
       
 20821                  {
       
 20822                 extendedInputCapabilities->ReportEventL(
       
 20823                     CAknExtendedInputCapabilities::MAknEventObserver::EChangeAmPm, NULL);
       
 20824                  }
       
 20825             }
       
 20826         }
       
 20827     }
       
 20828 
       
 20829 //-------------------------------------------------------------------
       
 20830 
       
 20831 //
       
 20832 // CChrMultiTapTimer
       
 20833 //
       
 20834 
       
 20835 // ---------------------------------------------------------------------------
       
 20836 // CChrMultiTapTimer::NewL
       
 20837 // 
       
 20838 // ---------------------------------------------------------------------------
       
 20839 // 
       
 20840 CChrMultiTapTimer* CChrMultiTapTimer::NewL(TCallBack aCallback)
       
 20841     {
       
 20842     CChrMultiTapTimer* self = new(ELeave)CChrMultiTapTimer(aCallback);
       
 20843     CleanupStack::PushL(self);
       
 20844     self->ConstructL();
       
 20845     CleanupStack::Pop();    // self
       
 20846     return self;
       
 20847     }
       
 20848 
       
 20849 
       
 20850 // ---------------------------------------------------------------------------
       
 20851 // CChrMultiTapTimer::CChrMultiTapTimer
       
 20852 // 
       
 20853 // ---------------------------------------------------------------------------
       
 20854 // 
       
 20855 CChrMultiTapTimer::CChrMultiTapTimer(TCallBack aCallback)
       
 20856 :CTimer(EPriorityStandard), iCallback(aCallback)
       
 20857     {
       
 20858     }
       
 20859 
       
 20860 // ---------------------------------------------------------------------------
       
 20861 // CChrMultiTapTimer::ConstructL
       
 20862 // 
       
 20863 // ---------------------------------------------------------------------------
       
 20864 // 
       
 20865 void CChrMultiTapTimer::ConstructL()
       
 20866     {
       
 20867     CTimer::ConstructL();
       
 20868     CActiveScheduler::Add(this);
       
 20869     }
       
 20870 
       
 20871 // ---------------------------------------------------------------------------
       
 20872 // CChrMultiTapTimer::After
       
 20873 // 
       
 20874 // ---------------------------------------------------------------------------
       
 20875 // 
       
 20876 void CChrMultiTapTimer::After(TTimeIntervalMicroSeconds32 aInterval)
       
 20877     {
       
 20878     if (IsActive())
       
 20879         {
       
 20880         Cancel();
       
 20881         }
       
 20882     CTimer::After(aInterval);
       
 20883     }
       
 20884 
       
 20885 // ---------------------------------------------------------------------------
       
 20886 // CChrMultiTapTimer::RunL
       
 20887 // 
       
 20888 // ---------------------------------------------------------------------------
       
 20889 // 
       
 20890 void CChrMultiTapTimer::RunL()
       
 20891     {
       
 20892     iCallback.CallBack();
       
 20893     }
       
 20894 
       
 20895 TBool CAknFepManager::IsLanguageSupportPrediction()
       
 20896     {
       
 20897     TBool isLanguagugeSupportsPrediction = EFalse;
       
 20898     switch(iKeyboardType)
       
 20899         {
       
 20900         case EPtiKeyboardHalfQwerty:
       
 20901 #ifdef __HALF_QWERTY_KEYPAD
       
 20902             isLanguagugeSupportsPrediction = (iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternHalfQwertyPredictive); 
       
 20903 #endif              
       
 20904             break;
       
 20905         case EPtiKeyboardQwerty4x12:
       
 20906         case EPtiKeyboardQwerty4x10:
       
 20907         case EPtiKeyboardQwerty3x11:
       
 20908         case EPtiKeyboardCustomQwerty:
       
 20909             isLanguagugeSupportsPrediction = (iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternQwertyPredictive);
       
 20910             break;
       
 20911         case EPtiKeyboardNone:
       
 20912         case EPtiKeyboard12Key:
       
 20913             isLanguagugeSupportsPrediction = (!iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternPredictive);
       
 20914             break;
       
 20915         default:
       
 20916             isLanguagugeSupportsPrediction = (!iQwertyInputMode) & (iLanguageCapabilities.iSupportsWesternPredictive);
       
 20917             break;    
       
 20918         }    
       
 20919     return isLanguagugeSupportsPrediction;
       
 20920     }
       
 20921 #endif //RD_INTELLIGENT_TEXT_INPUT
       
 20922 
       
 20923 TBool CAknFepManager::IsAllowedKeymappingForNumberMode(TChar aChar) const
       
 20924     {
       
 20925     TBool response = EFalse;
       
 20926 
       
 20927 
       
 20928     switch ( iAknEditorNumericKeymap )
       
 20929         {
       
 20930         case EAknEditorStandardNumberModeKeymap:
       
 20931         case EAknEditorFixedDiallingNumberModeKeymap:
       
 20932         case EAknEditorSATNumberModeKeymap:
       
 20933         case EAknEditorSATHiddenNumberModeKeymap:
       
 20934             {
       
 20935             response = (aChar == '#');
       
 20936             }
       
 20937             break;
       
 20938         case EAknEditorCalculatorNumberModeKeymap:
       
 20939         case EAknEditorConverterNumberModeKeymap:
       
 20940             {
       
 20941             TLocale tLoc;
       
 20942             response = (aChar == tLoc.DecimalSeparator());
       
 20943             }
       
 20944             break;
       
 20945         case EAknEditorToFieldNumberModeKeymap:
       
 20946             {
       
 20947             response = (aChar == ';');
       
 20948             }
       
 20949             break;
       
 20950         case EAknEditorPlainNumberModeKeymap:
       
 20951         case EAknEditorReservedInternalUseKeymap:
       
 20952         default:
       
 20953             break;
       
 20954         }
       
 20955 
       
 20956     return response;
       
 20957     }
       
 20958 /**
       
 20959   * Return wether ipnut mode is change by press shift+space. 
       
 20960   * This is for half-qwerty.
       
 20961   */
       
 20962 TBool CAknFepManager::IsChangeModeByShiftAndSpace()
       
 20963     {
       
 20964     return iShiftAndSpace;
       
 20965     }
       
 20966 
       
 20967 /**
       
 20968   * Set wether ipnut mode is change by press shift+space. 
       
 20969   * This is for half-qwerty.
       
 20970   */
       
 20971 void CAknFepManager::SetChangeModeByShiftAndSpace( TBool aFlag )
       
 20972     {
       
 20973     iShiftAndSpace = aFlag;
       
 20974     }
       
 20975 
       
 20976 void CAknFepManager::HideExactWordPopUp()
       
 20977 	{
       
 20978 	iExactWordPopupContent->HidePopUp();
       
 20979 	TRAP_IGNORE( SendEventsToPluginManL( EPluginHideTooltip ));
       
 20980 	}
       
 20981 
       
 20982 TBool CAknFepManager::IsExactWordPopUpShown()
       
 20983 	{
       
 20984 #ifdef RD_SCALABLE_UI_V2 
       
 20985 	return iExactWordPopupContent->IsPopUpVisible()
       
 20986            || ( iFepPluginManager && iFepPluginManager->IsTooltipOpenOnFSQ() );
       
 20987 #else
       
 20988 	return iExactWordPopupContent->IsPopUpVisible();
       
 20989 #endif // RD_SCALABLE_UI_V2
       
 20990 	}
       
 20991 void CAknFepManager::StopDisplayingMenuBar()
       
 20992     {
       
 20993     if (iEditMenuBar)
       
 20994         {
       
 20995         iEditMenuBar->StopDisplayingMenuBar();
       
 20996         iEditMenuBar = NULL;
       
 20997         }
       
 20998 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__    
       
 20999     // temporary solution for Entering key on virtual QWERTY not working 
       
 21000     // like enter on virtual ITU-T or on external keyboard
       
 21001     if ( iOptionsMenuBar && !( iFepPluginManager && 
       
 21002         ( iFepPluginManager->CurrentPluginInputMode() == EPluginInputModeFSQ || 
       
 21003           iFepPluginManager->CurrentPluginInputMode() == EPluginInputModePortraitFSQ ) ) )
       
 21004         {
       
 21005         iOptionsMenuBar->StopDisplayingMenuBar();
       
 21006         iOptionsMenuBar = NULL;
       
 21007         }
       
 21008 #endif //__ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__   
       
 21009     }
       
 21010 
       
 21011 void CAknFepManager::SetQwertyModeToInputcapbility()
       
 21012     {
       
 21013     if ( iSharedDataInterface->QwertyInputMode() )
       
 21014         {
       
 21015         SetExtendedInputCapabilities( ExtendedInputCapabilities() |
       
 21016             CAknExtendedInputCapabilities::EInputEditorQwertyInputActive  );
       
 21017         }
       
 21018     else
       
 21019         {
       
 21020         SetExtendedInputCapabilities( ExtendedInputCapabilities() &
       
 21021             ~CAknExtendedInputCapabilities::EInputEditorQwertyInputActive  );
       
 21022         }
       
 21023     }
       
 21024 void CAknFepManager::SetExtendedInputCapabilities( TUint aCapabilities)
       
 21025     {
       
 21026     MObjectProvider* mop = iInputCapabilities.ObjectProvider();
       
 21027 
       
 21028     if ( mop && iInputCapabilities.FepAwareTextEditor() )//IsFepAwareTextEditor()
       
 21029         {
       
 21030         CAknExtendedInputCapabilities* extendedInputCapabilities =
       
 21031         mop->MopGetObject( extendedInputCapabilities );
       
 21032 
       
 21033         if ( extendedInputCapabilities )
       
 21034             {
       
 21035             extendedInputCapabilities->SetCapabilities( aCapabilities );
       
 21036             }
       
 21037         }
       
 21038 
       
 21039     return;
       
 21040     }
       
 21041 
       
 21042 void CAknFepManager::PrepareFepAfterDialogExitL(TUid aFepUid)
       
 21043     {
       
 21044     // This ensures that on 3rd party fep change we do not have access to other fep variables
       
 21045     if (aFepUid != CCoeEnv::Static()->FepUid())
       
 21046         {
       
 21047 		// In case the fep has changed, then leave
       
 21048         User::Leave(KErrNone);
       
 21049         }
       
 21050 	// Once the editor which launches a dialog is destroyed, this flag is set
       
 21051 	// In case we have any dialog launched we leave as the underneath editor is
       
 21052 	// destroyed
       
 21053     if (IsExtendedFlagSet(EExtendedFlagEdwinEditorDestroyed))
       
 21054         {
       
 21055         if(!iFepAwareDialogParentEditor)
       
 21056             {
       
 21057 			// For Eg: Messaging editor launches spell query which inturn launches
       
 21058 			// SCT. Then don't clear the flag once we dismiss SCT because we even
       
 21059 			// need to dismiss spell query dialog.
       
 21060             ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
 21061             }       
       
 21062         User::Leave(KErrNone);
       
 21063         }
       
 21064     if(!iFepAwareDialogParentEditor)
       
 21065         {
       
 21066         ClearExtendedFlag(EExtendedFlagEdwinEditorDestroyed);
       
 21067         }    
       
 21068     }
       
 21069 
       
 21070 void CAknFepManager::PrepareFepForFepAwareDialogLaunch()
       
 21071     {
       
 21072     iFepAwareDialogParentEditor = EditorState();
       
 21073     SetExtendedFlag(EExtendedFlagFepAwareDialogLaunched);
       
 21074     }
       
 21075 
       
 21076 void CAknFepManager::PrepareFepAfterFepAwareDialogExitL(TUid aFepUid)
       
 21077     {
       
 21078     // This ensures that on 3rd party fep change we do not have access to other fep variables
       
 21079     if (aFepUid != CCoeEnv::Static()->FepUid())
       
 21080         {
       
 21081         // In case the fep has changed, then leave
       
 21082         User::Leave(KErrNone);
       
 21083         }    
       
 21084     iFepAwareDialogParentEditor = NULL;
       
 21085     ClearExtendedFlag(EExtendedFlagFepAwareDialogLaunched);
       
 21086     }
       
 21087 
       
 21088 void CAknFepManager::ConvertCharToKey(TChar aChar, TUint16& aKey) const
       
 21089     {
       
 21090     aKey = 0;
       
 21091 	
       
 21092 	if (!iPtiEngine)
       
 21093 		return;
       
 21094 		
       
 21095     CPtiCoreLanguage* lang = static_cast<CPtiCoreLanguage*>( iPtiEngine->CurrentLanguage() );
       
 21096     if (!lang)
       
 21097         return;
       
 21098 
       
 21099     const TBool vietnamese = (iLanguageCapabilities.iInputLanguageCode == ELangVietnamese);
       
 21100     
       
 21101     MPtiKeyMappings* map;
       
 21102     TPtiKeyboardType keyboardLayout = KeyboardLayout();
       
 21103 	if ( keyboardLayout == EPtiKeyboardQwerty4x12 
       
 21104 		 || keyboardLayout == EPtiKeyboardQwerty4x10
       
 21105 		 || keyboardLayout == EPtiKeyboardQwerty3x11
       
 21106 		 || keyboardLayout == EPtiKeyboardCustomQwerty )
       
 21107 		{
       
 21108 		map = lang->GetQwertyKeymappings();
       
 21109 		}
       
 21110 	else if( keyboardLayout == EPtiKeyboardHalfQwerty )
       
 21111 		{
       
 21112 		map = lang->GetHalfQwertyKeymappings();
       
 21113 		}
       
 21114 	else    
       
 21115 		{
       
 21116 		map = lang->GetKeymappings();
       
 21117 		}          
       
 21118 
       
 21119     if (!map)
       
 21120         {
       
 21121         return;
       
 21122         }   
       
 21123 
       
 21124     TUint16 ch;
       
 21125     ch = (TUint16)map->KeyForCharacter(aChar); 
       
 21126     if ( !ch && vietnamese 
       
 21127          && !( iFepPluginManager && iFepPluginManager->IsSupportITIOnFSQ() ) )
       
 21128         {
       
 21129         // This may be Vietnamese tone mark or an accented character which isn't listed
       
 21130         // in keymappings. 
       
 21131         ch = RemapVietnameseAccentedCharacter(aChar);
       
 21132         }
       
 21133 
       
 21134     aKey = ch;
       
 21135     }
       
 21136 
       
 21137 TBool CAknFepManager::GetSctLengthL(TInt resourceId)const
       
 21138 	{
       
 21139 	CCoeEnv* coeEnv = CCoeEnv::Static();
       
 21140 	TResourceReader reader;
       
 21141 	CEikonEnv::Static()->CreateResourceReaderLC(reader,resourceId);
       
 21142 	TInt component_count=reader.ReadInt16();
       
 21143 	TInt length = 0;
       
 21144 	TBool isEmpty = ETrue;
       
 21145 	HBufC* sctChar = NULL;
       
 21146 	
       
 21147 	for (TInt ii=0;ii<component_count;ii++)
       
 21148 		{
       
 21149 		TInt component_id=reader.ReadInt16();
       
 21150 		switch(component_id)
       
 21151 			{
       
 21152 			case EAknSCTLowerCase:
       
 21153 				{
       
 21154 		        sctChar = reader.ReadHBufCL();
       
 21155 		        length += (sctChar != NULL)? sctChar->Length(): 0;
       
 21156 		        break;
       
 21157 				}
       
 21158 			case EAknSCTUpperCase:
       
 21159 				{
       
 21160 		        sctChar = reader.ReadHBufCL();
       
 21161 		        length += (sctChar != NULL)? sctChar->Length(): 0;
       
 21162 		        break;
       
 21163 				}
       
 21164 			case EAknSCTNumeric:
       
 21165 				{
       
 21166 		        sctChar = reader.ReadHBufCL();
       
 21167 		        length += (sctChar != NULL)? sctChar->Length(): 0;
       
 21168 		    	break;
       
 21169 				}
       
 21170 		    case EAknSCTFullCase:
       
 21171 		        {
       
 21172 		        sctChar = reader.ReadHBufCL();
       
 21173 		        length += (sctChar != NULL)? sctChar->Length(): 0;
       
 21174 		        break;
       
 21175 		        }
       
 21176 		    case EAknSCTHalfCase:
       
 21177 		       	{
       
 21178 		        sctChar = reader.ReadHBufCL();
       
 21179 		        length += (sctChar != NULL)? sctChar->Length(): 0;
       
 21180 		        break;
       
 21181 		       	}
       
 21182 		    case EAknSCTQwerty:
       
 21183 		        {
       
 21184 		        sctChar = reader.ReadHBufCL();
       
 21185 		        length += (sctChar != NULL)? sctChar->Length(): 0;
       
 21186 		        break;
       
 21187 		        }
       
 21188 		   	default:
       
 21189 		        break;
       
 21190 			}
       
 21191 	    delete sctChar;
       
 21192 	    sctChar = NULL;
       
 21193 	    if(length > 0)
       
 21194 	    	{
       
 21195             isEmpty = EFalse;
       
 21196 	    	break;
       
 21197 	    	}
       
 21198 		}
       
 21199 	CleanupStack::PopAndDestroy();  //reader 
       
 21200 	return isEmpty;
       
 21201 	}
       
 21202     
       
 21203 // ========================================
       
 21204 // Update Editor State Flag
       
 21205 // Add editor state flags or 
       
 21206 // Remove editor state flags
       
 21207 // ========================================
       
 21208 void CAknFepManager::UpdateEditorStateFlags( TInt aFlag, TBool aAdd ) const
       
 21209     {
       
 21210     CAknEdwinState* state( EditorState() );
       
 21211     if ( state )
       
 21212         {
       
 21213         TInt flags( state->Flags() );
       
 21214         if ( aAdd )
       
 21215             {
       
 21216             flags |= aFlag;  // Add flag
       
 21217             }
       
 21218         else
       
 21219             {
       
 21220             flags &= ~aFlag;  // Remove flag
       
 21221             }
       
 21222         state->SetFlags( flags );
       
 21223         }
       
 21224     }
       
 21225 
       
 21226 
       
 21227 // ---------------------------------------------------------------------------
       
 21228 // CAknFepManager::HandleFnKeyPressMonitorCallback
       
 21229 // Handle fnkey press monitor callback
       
 21230 // static function
       
 21231 // ---------------------------------------------------------------------------
       
 21232 //
       
 21233 TInt CAknFepManager::HandleFnKeyPressMonitorCallback(TAny* aObj)
       
 21234 	{
       
 21235     TRAPD(err, static_cast<CAknFepManager*>(aObj)->HandleFnKeyPressMonitor());
       
 21236     if (err)
       
 21237         {
       
 21238         static_cast<CAknFepManager*>(aObj)->CleanUpFep();
       
 21239         return KErrDied;
       
 21240         }
       
 21241     return KErrNone;
       
 21242 	}
       
 21243 
       
 21244 // ---------------------------------------------------------------------------
       
 21245 // CAknFepManager::HandleFnKeyPressMonitor
       
 21246 // Handle fnkey press monitor callback
       
 21247 // ---------------------------------------------------------------------------
       
 21248 //
       
 21249 void CAknFepManager::HandleFnKeyPressMonitor()
       
 21250 	{
       
 21251 	DeactivateFnkeyPressMonitor();
       
 21252 	
       
 21253 	//if previous state of fn key is EFnKeyNone or EFnKeyNext, EFnKeyLock will be set;
       
 21254 	//otherwise, if previous state is EFnKeyLock, EFnKeyNone will be set.
       
 21255 	switch(iFnKeyManager->FnKeyState())
       
 21256 		{
       
 21257 		case CAknFepFnKeyManager::EFnKeyPressed:
       
 21258 		case CAknFepFnKeyManager::EFnKeyPressedAgain:
       
 21259 			 iFnKeyManager->SetFnKeyState(CAknFepFnKeyManager::EFnKeyLock);
       
 21260 			break;
       
 21261 		case CAknFepFnKeyManager::EFnKeyDown:
       
 21262 			 iFnKeyManager->SetFnKeyState(CAknFepFnKeyManager::EFnKeyNone);
       
 21263 			 break;
       
 21264 		default:
       
 21265 			break;
       
 21266 		}
       
 21267 	}
       
 21268 
       
 21269 // ---------------------------------------------------------------------------
       
 21270 // CAknFepManager::ActivateFnkeyPressMonitor
       
 21271 // Activate Fnkey press Monitor
       
 21272 // ---------------------------------------------------------------------------
       
 21273 //
       
 21274 void CAknFepManager::ActivateFnkeyPressMonitor()
       
 21275 	{
       
 21276 	 if( iFnKeypressMonitor )
       
 21277 		 {
       
 21278 		  iFnKeypressMonitor->Start(KFnKeyLongPressTimeout, KFnKeyLongPressTimeout, 
       
 21279 							   TCallBack(HandleFnKeyPressMonitorCallback, this));
       
 21280 		 }
       
 21281 	}
       
 21282 
       
 21283 // ---------------------------------------------------------------------------
       
 21284 // CAknFepManager::DeactivateFnkeyPressMonitor
       
 21285 // Deactivate Fnkey press Monitor
       
 21286 // ---------------------------------------------------------------------------
       
 21287 //
       
 21288 void CAknFepManager::DeactivateFnkeyPressMonitor()
       
 21289 	{
       
 21290 	 if( iFnKeypressMonitor && iFnKeypressMonitor->IsActive())
       
 21291 		 {
       
 21292 		   iFnKeypressMonitor->Cancel();
       
 21293 		 }
       
 21294 	}
       
 21295 
       
 21296 // ---------------------------------------------------------------------------
       
 21297 // LOCAL METHODS
       
 21298 // 
       
 21299 // ---------------------------------------------------------------------------
       
 21300 //     
       
 21301 const TInt KVietKeyMarker = 0xffff;
       
 21302 const TUint16 vietnameseAccents[] =
       
 21303     {
       
 21304     KVietKeyMarker, EPtiKey2, // For key 2, a-based    
       
 21305     0x00c1,	0x00c0, 0x1ea2, 0x00c3, 0x1ea0,
       
 21306     0x00e1, 0x00e0, 0x1ea3, 0x00e3, 0x1ea1,
       
 21307     0x0102, 0x1eae, 0x1eb0, 0x1eb2, 0x1eb4, 0x1eb6,
       
 21308     0x0103, 0x1eaf, 0x1eb1, 0x1eb3, 0x1eb5, 0x1eb7,
       
 21309     0x00c2, 0x1ea4, 0x1ea6, 0x1ea8, 0x1eaa, 0x1eac,
       
 21310     0x00e2, 0x1ea5, 0x1ea7, 0x1ea9, 0x1eab, 0x1ead, 
       
 21311 
       
 21312     KVietKeyMarker, EPtiKey3, // For key 3, e-based    
       
 21313     0x00c9,	0x00c8, 0x1eba, 0x1ebc, 0x1eb8,
       
 21314     0x00e9, 0x00e8, 0x1ebb, 0x1ebd, 0x1eb9,
       
 21315     0x00ca, 0x1ebe, 0x1ec0, 0x1ec2, 0x1ec4, 0x1ec6,
       
 21316     0x00ea, 0x1ebf, 0x1ec1, 0x1ec3, 0x1ec5, 0x1ec7,
       
 21317 
       
 21318     KVietKeyMarker, EPtiKey4, // For key 4, i-based    
       
 21319     0x00cd,	0x00cc, 0x1ec8, 0x0128, 0x1eca,
       
 21320     0x00ed, 0x00ec, 0x1ec9, 0x0129, 0x1ecb,
       
 21321     
       
 21322     KVietKeyMarker, EPtiKey6, // For key 6, o-based    
       
 21323     0x00d3,	0x00d2, 0x1ece, 0x00d5, 0x1ecc,
       
 21324     0x00f3, 0x00f2, 0x1ecf, 0x00f5, 0x1ecd,
       
 21325     0x00d4, 0x1ed0, 0x1ed2, 0x1ed4, 0x1ed6, 0x1ed8,
       
 21326     0x00f4, 0x1ed1, 0x1ed3, 0x1ed5, 0x1ed7, 0x1ed9,
       
 21327     0x01a0, 0x1eda, 0x1edc, 0x1ede, 0x1ee0, 0x1ee2,
       
 21328     0x01a1, 0x1edb, 0x1edd, 0x1edf, 0x1ee1, 0x1ee3, 
       
 21329     0
       
 21330     }; 
       
 21331 
       
 21332 
       
 21333 // ---------------------------------------------------------------------------
       
 21334 // RemapVietnameseAccentedCharacter
       
 21335 // 
       
 21336 // ---------------------------------------------------------------------------
       
 21337 // 
       
 21338 LOCAL_C TInt RemapVietnameseAccentedCharacter(TUint16 aChr)
       
 21339 	{
       
 21340 	// Check tone marks first.	
       
 21341 	switch (aChr)
       
 21342 		{
       
 21343 		case 0x0301:
       
 21344 		     return EPtiKey2;
       
 21345 		case 0x0300:
       
 21346 		     return EPtiKey3;
       
 21347 		case 0x0309:
       
 21348 		     return EPtiKey4;		     
       
 21349 		case 0x0303:
       
 21350 			 return EPtiKey5;			
       
 21351 		case 0x0323:
       
 21352 			 return EPtiKey6;						 
       
 21353 		default:
       
 21354 			break; 	
       
 21355 		}	 
       
 21356 	
       
 21357 	TInt ret = 0;
       
 21358 	
       
 21359 	for (const TUint16* ptr = vietnameseAccents; *ptr != 0; ptr++)
       
 21360 		{
       
 21361 		if (*ptr == KVietKeyMarker)
       
 21362 			{
       
 21363 			ret = ptr[1];
       
 21364 			ptr++;
       
 21365 			}
       
 21366 		else
       
 21367 			{
       
 21368 			if (*ptr == aChr)
       
 21369 				{
       
 21370 				break;
       
 21371 				}
       
 21372 			}			
       
 21373 		}
       
 21374 		
       
 21375 	return ret;	 		
       
 21376 	}
       
 21377 
       
 21378 // End of file