fep/aknfep/src/AknFepPluginManager.cpp
changeset 0 eb1f2e154e89
child 3 f5a1e66df979
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2002 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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 // System includes
       
    30 #include <aknedsts.h> 
       
    31 #include <AknUtils.h> 
       
    32 #include <aknappui.h> 
       
    33 #include <eikccpu.h> 
       
    34 #include <eikdialg.h> 
       
    35 #include <eikcapc.h> // CEikCaptionedControl
       
    36 #include <aknQueryControl.h> 
       
    37 #include <centralrepository.h> 
       
    38 #include <StringLoader.h> 
       
    39 #include <AknFepPluginManager.h>
       
    40 #include <aknfeppeninputimeplugin.h>
       
    41 #include <UikonInternalPSKeys.h> // KUikGlobalNotesAllowed
       
    42 #include <AvkonInternalCRKeys.h>    // KAknQwertyInputModeActive
       
    43 #include <hlplch.h>
       
    44 #include <peninputgsinterface.h>
       
    45 #include <AknFep.rsg>
       
    46 #include <avkon.rsg>
       
    47 #include <AknIndicatorContainer.h>  //CAknIndicatorContainer
       
    48 #include <StringLoader.h>
       
    49 #include <peninputgenericitutcustomization.h>
       
    50 #include <eikgted.h> 
       
    51 #include <txtglobl.h>
       
    52 #include <eikedwin.h> 
       
    53 #include <featmgr.h>                 //FeatureManager
       
    54 #include <aknextendedinputcapabilities.h>
       
    55 #include <avkon.hrh>
       
    56 #include <PtiEngine.h>
       
    57 #include <peninputcommonlayoutglobalenum.h>
       
    58 #include <PtiCompositionDataIF.h> // MPtiEngineCompositionDataInterface
       
    59 #include <eikapp.h>
       
    60 #include <AknFepGlobalEnums.h>
       
    61 #include <AknFepInternalCRKeys.h>
       
    62 
       
    63 // User includes
       
    64 #include "AknFepManagerInterface.h" // MAknFepManagerInterface
       
    65 #include "AknFepUiManagerBase.h"
       
    66 #include "aknfepuimanagerfingeritutchinese.h"
       
    67 
       
    68 // For Spell
       
    69 #include "aknfepuispellcontainer.h"            
       
    70 #include "aknfepuispellinputpane.h"
       
    71 
       
    72 #include <eikgted.h> 
       
    73 
       
    74 #include <apgwgnam.h>
       
    75 
       
    76 #include <PtiKeyMappings.h>
       
    77 #include <aknpriv.hrh>
       
    78 
       
    79 // Constants
       
    80 const TInt KCursorBlinkPerioid = 10000;//300000; // five tenth of a second * 2
       
    81 const TInt KMaxServerDataLength = 50;
       
    82 const TUint KVkbParagraphSeparator = 0x2029;
       
    83 const TUint KVkbTabulator = 0x0009;
       
    84 const TUid KAknfepUID= { 0x100056de }; 
       
    85 const TUid KUidtruiApp = { 0x2000B104 }; 
       
    86 const TInt KAknScreenServerUid = 0x100056cf;
       
    87 const TInt KAknCapServerUid = 0x10207218;
       
    88 const TInt KAknNotifySrvUid = 0x10281EF2;
       
    89 const TInt KAknHelpAppUid = 0x10005234;
       
    90 const TInt KInvalidValue = -1;
       
    91 
       
    92 // Paste event for AknCcpuSupport
       
    93 const TKeyEvent KAknCcpuPasteEvent = {EKeyF18, EEikCmdEditPaste, EModifierCtrl, 1}; 
       
    94 
       
    95 const TUint KSupportedDeadKeys[] = { 0x005E, 0x0060, 0x00A8, 0x007E, 0x00AF, 
       
    96 		                             0x00B4, 0x00B8, 0x02C7, 0x02DB, 0x02DD, 
       
    97 		                             0x00A8, 0x0384, 0x0385 }; 
       
    98 
       
    99 _LIT(KVkbTabChar, " ");
       
   100 
       
   101 _LIT(KHWR_HLP_MAIN_VIEW, "HWR_HLP_MAIN_VIEW");
       
   102 _LIT(KVQWERTY_HLP_MAIN_VIEW, "VQWERTY_HLP_MAIN_VIEW"); 
       
   103 _LIT(KVITU_HLP_MAIN_VIEW, "VITU_HLP_MAIN_VIEW");
       
   104 
       
   105 const TInt KDefaultCandidateArraySize = 16;
       
   106 const TInt KNumberOfCases = 6;
       
   107 
       
   108 #define iAvkonAppUi ((CAknAppUi*)CEikonEnv::Static()->EikAppUi())
       
   109 TUid AppUidFromWndGroupIdL(TInt aWndGrpId)
       
   110     {
       
   111     RWsSession &ws = CCoeEnv::Static()->WsSession();
       
   112     //TInt wgId =ws.GetFocusWindowGroup();
       
   113     CApaWindowGroupName* wg = CApaWindowGroupName::NewLC(ws,aWndGrpId);
       
   114 
       
   115     TUid id = wg->AppUid();
       
   116     CleanupStack::PopAndDestroy(wg);    	
       
   117     return id;
       
   118     
       
   119     }
       
   120 
       
   121 TUid GetFocusAppUid()
       
   122     { 
       
   123     TUid id = {0x0};
       
   124     TRAP_IGNORE(id = AppUidFromWndGroupIdL(CCoeEnv::Static()->WsSession().GetFocusWindowGroup()));
       
   125     return id;
       
   126     }
       
   127 TUid GetCurAppUid()
       
   128     {
       
   129     TUid id = {0x0};	
       
   130     TRAP_IGNORE(id = AppUidFromWndGroupIdL(CCoeEnv::Static()->RootWin().Identifier())); 
       
   131     return id;           
       
   132     }
       
   133 
       
   134 TBool IsGlobalNotesApp(TUid& aUid)		  
       
   135     {
       
   136     const TInt KAknCapServerUid = 0x10207218;
       
   137     const TInt KAknNotifySrvUid = 0x10281EF2;      
       
   138     if(aUid.iUid == KAknCapServerUid || aUid.iUid == KAknNotifySrvUid)
       
   139         return ETrue;
       
   140     return EFalse;
       
   141     }
       
   142 #ifdef RD_SCALABLE_UI_V2
       
   143 inline TBool IsAbleTouseCallBubble()
       
   144     {
       
   145     const TInt KAknCapServerUid = 0x10207218;    
       
   146     return GetCurAppUid().iUid != KAknCapServerUid;
       
   147     }
       
   148 #endif //RD_SCALABLE_UI_V2
       
   149     
       
   150 RDrawableWindow* GetFocusWindow()
       
   151     {
       
   152     CCoeControl* focusControl = CCoeEnv::Static()->AppUi()->TopFocusedControl();
       
   153     if( focusControl )
       
   154         {
       
   155         return focusControl->DrawableWindow();
       
   156         }
       
   157     return NULL;
       
   158     }
       
   159 // ======== MEMBER FUNCTIONS ========
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // CAknFepPluginManager::NewL
       
   163 // (other items were commented in a header)
       
   164 // ---------------------------------------------------------------------------
       
   165 //    
       
   166 CAknFepPluginManager* CAknFepPluginManager::NewL( CAknFepManager& aFepMan,
       
   167                                                 CAknFepSharedDataInterface& aSharedData,
       
   168                                                 CAknFepLanguageManager& aLangMan,
       
   169                                                 CAknFepCaseManager& aCaseMan )
       
   170     { 
       
   171     CAknFepPluginManager* self = new (ELeave) CAknFepPluginManager
       
   172         ( aFepMan, aSharedData, aLangMan, aCaseMan ); 
       
   173     CleanupStack::PushL( self );
       
   174     self->ConstructL();       
       
   175     CleanupStack::Pop(self);
       
   176     return self;
       
   177     }
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // CAknFepPluginManager::~CAknFepPluginManager
       
   181 // (other items were commented in a header)
       
   182 // ---------------------------------------------------------------------------
       
   183 //     
       
   184 CAknFepPluginManager::~CAknFepPluginManager()
       
   185     {  
       
   186     if ( iConnectAo )
       
   187     	{
       
   188     	iConnectAo->Cancel();
       
   189     	delete iConnectAo;
       
   190     	}
       
   191     
       
   192     delete iAdjustDataQueryTimer;
       
   193 
       
   194     iCurrentPluginInputFepUI = NULL; // why not delete????
       
   195     delete iPenInputMenu;
       
   196     
       
   197     if( iPenInputSvrConnected )
       
   198         {
       
   199         iPenInputServer.Close();
       
   200         iPenInputSvrConnected = EFalse;
       
   201         }
       
   202     delete iFingerItutChineseUI;
       
   203     
       
   204     delete iIcfDataBuf;
       
   205     iIcfDataBuf = NULL;
       
   206     
       
   207     delete iSpellText;
       
   208     iSpellText = NULL;
       
   209 
       
   210     delete iSpell;
       
   211     iSpell = NULL;
       
   212     
       
   213     delete iLastEditorContentBuf;
       
   214     
       
   215     delete iAvkonRepository;
       
   216     
       
   217     /*    
       
   218     for(TInt i = 0; i < iCandidateList.Count(); i++)
       
   219         {
       
   220         HBufC* buf = iCandidateList[i];
       
   221         delete buf;
       
   222         }
       
   223     iCandidateList.Close();
       
   224     */
       
   225     iCandidateList.ResetAndDestroy();
       
   226     iSendAllList.iCandidates.Reset();
       
   227     iOpenWindowList.Close();
       
   228     iEventData.Close();    
       
   229     iPreCaption.Close();
       
   230     
       
   231     ClosePeninputSetting();
       
   232     }
       
   233     
       
   234 // ---------------------------------------------------------------------------
       
   235 // CAknFepPluginManager::CAknFepPluginManager
       
   236 // (other items were commented in a header)
       
   237 // ---------------------------------------------------------------------------
       
   238 // 
       
   239 CAknFepPluginManager::CAknFepPluginManager( CAknFepManager& aFepMan, 
       
   240                                           CAknFepSharedDataInterface& aSharedData,
       
   241                                           CAknFepLanguageManager& aLangMan,
       
   242                                           CAknFepCaseManager& aCaseMan )
       
   243     : iFepMan( aFepMan ), iLangMan( aLangMan ), iCaseMan( aCaseMan ),
       
   244       iSharedData( aSharedData ), iPluginPrimaryRange( ERangeInvalid ), iCandidateIndex(1),
       
   245       iCharStartPostion( KInvalidValue )
       
   246     {
       
   247     iIndicatorImgID = 0;
       
   248     iIndicatorTextID = 0;
       
   249     iLastDataQueryWin = NULL;
       
   250     iDefaultOrientation = -1;
       
   251     iIsInEditWordQueryDlg = EFalse;    
       
   252     iClosePluginInputMode = EFalse;
       
   253     iDimGainForeground = ETrue;
       
   254 	// Modify for bug ELZG-7WZC35 begin
       
   255     iAlignment = 0;
       
   256     // Modify for bug ELZG-7WZC35 end
       
   257     }
       
   258 
       
   259 // ---------------------------------------------------------------------------
       
   260 // CAknFepPluginManager::ConstructL
       
   261 // (other items were commented in a header)
       
   262 // ---------------------------------------------------------------------------
       
   263 // 
       
   264 void CAknFepPluginManager::ConstructL()
       
   265     {
       
   266     iPenInputMenu = CAknFepPluginMenuManager::NewL(&iFepMan);
       
   267     
       
   268     //here ERangeInvalid means there is no change of plugin input range.
       
   269     iFepMan.UiInterface()->TouchPaneSetFepPenSupportInterface(this);
       
   270     iEventData.CreateMaxL(KMaxServerDataLength);
       
   271     
       
   272     RThread client;
       
   273     iHasSWEventCap = client.HasCapability(ECapabilitySwEvent);
       
   274     client.Close();
       
   275     iAvkonRepository = CRepository::NewL( KCRUidAvkon ); 
       
   276     
       
   277     iConnectAo = new (ELeave)CConnectAo(this);
       
   278     }
       
   279 
       
   280 // -----------------------------------------------------------------------------
       
   281 // CAknFepPluginManager::ActivatePenInputL
       
   282 // Change to default plugin input mode
       
   283 // (other items were commented in a header).
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 void CAknFepPluginManager::ActivatePenInputL()
       
   287     {
       
   288     if( !iPenInputSvrConnected || !iPenInputServer.IsVisible() || iPenInputServer.IsDimmed() )
       
   289         {
       
   290         if( iFepMan.FepAwareTextEditor() )
       
   291             {
       
   292             TryChangePluginInputModeByModeL((TPluginInputMode)(iSharedData.PluginInputMode()),
       
   293                                             EPenInputOpenManually,
       
   294                                             ERangeInvalid);
       
   295             }
       
   296         }    
       
   297     iFepMan.PtiEngine()->CancelTimerActivity();    
       
   298     }
       
   299 
       
   300 	
       
   301 // ---------------------------------------------------------------------------
       
   302 // CAknFepPluginManager::DeactivatePenInputL
       
   303 // (other items were commented in a header)
       
   304 // ---------------------------------------------------------------------------
       
   305 // 
       
   306 void CAknFepPluginManager::DeactivatePenInputL()
       
   307     {
       
   308     ClosePluginInputModeL(ETrue);
       
   309     }
       
   310 
       
   311 // -----------------------------------------------------------------------------
       
   312 // CAknFepPluginManager::HandleServerEventL
       
   313 // Handle pen input server events.
       
   314 // (other items were commented in a header).
       
   315 // -----------------------------------------------------------------------------
       
   316 //
       
   317 TBool CAknFepPluginManager::HandleServerEventL(TInt aEventId)
       
   318     {
       
   319     if(ESignalServerExit == aEventId)
       
   320         {
       
   321         iPenInputSvrConnected = EFalse; 
       
   322         return ETrue;
       
   323         }
       
   324     if(ESignalServerReady == aEventId)
       
   325         {
       
   326         //reconnect to server
       
   327         iFepMan.SendEventsToPluginManL(EPluginEditorActivate);
       
   328         return ETrue;
       
   329         }
       
   330     TBool bHandled = EFalse;
       
   331     if( !iLangMan.CurrentImePlugin())
       
   332         {
       
   333         return bHandled;
       
   334         }
       
   335     
       
   336     iEventData.Zero();
       
   337     TPtrC pBuf; 
       
   338     TInt dataLen = iPenInputServer.GetServerEventData(iEventData);
       
   339     
       
   340     if( KErrNone == dataLen )
       
   341         {
       
   342         pBuf.Set(iEventData);
       
   343         }
       
   344     else if ( dataLen > 0 )
       
   345         {
       
   346         iEventData.ReAllocL(dataLen);
       
   347         dataLen = iPenInputServer.GetServerEventData(iEventData);
       
   348         pBuf.Set(iEventData);
       
   349         }
       
   350     if( dataLen != KErrNone )
       
   351 	    {
       
   352 	    return ETrue;
       
   353 	    }
       
   354 
       
   355     if( !iLangMan.CurrentImePlugin()->HandleServerEventL(aEventId, iEventData) )
       
   356         {
       
   357         bHandled = ETrue;
       
   358         
       
   359         //only handle events which IME plug-in don't handled
       
   360         switch( aEventId )
       
   361             {
       
   362             case ESignalReplacePartText:
       
   363             case ESignalReplaceText://Get key event
       
   364             case ESignalReplaceTextJp:
       
   365                 {
       
   366                 TInt repeatCount = 0;
       
   367                 TInt len = *(TInt*)pBuf.Ptr();
       
   368                 TInt stringLength = pBuf.Length();
       
   369                 TInt midLength = sizeof(TInt)/sizeof(TText);
       
   370                 
       
   371                 if (midLength > stringLength)
       
   372                     {
       
   373                     break;   
       
   374                     }
       
   375 
       
   376                 iFepMan.SetFlag( CAknFepManager::EFlagSupressAutoUpdate );
       
   377 
       
   378                 TPtrC s = pBuf.Mid(midLength);//sizeof(TInt)/sizeof(TText)
       
   379                                 
       
   380                 //set selection
       
   381                 MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor();
       
   382                 if( iFepMan.IsFepAwareTextEditor() && edit )
       
   383                     {
       
   384                     TCursorSelection curSor;
       
   385                     edit->GetCursorSelectionForFep(curSor);
       
   386                     if ( curSor.iAnchorPos == curSor.iCursorPos )
       
   387                         {
       
   388                         if (ESignalReplaceTextJp == aEventId)
       
   389                             {
       
   390                             if (curSor.iCursorPos  >= len)
       
   391                                 {
       
   392                                 curSor.iAnchorPos = curSor.iCursorPos - len;
       
   393                                 if (curSor.iAnchorPos<0 || 
       
   394                                     curSor.iAnchorPos>edit->DocumentLengthForFep())
       
   395                                     {
       
   396                                     break;
       
   397                                     }
       
   398                                 }
       
   399                             }
       
   400                         else
       
   401                             {
       
   402                             if(ESignalReplacePartText == aEventId)
       
   403                                 {
       
   404                                 curSor.iAnchorPos = curSor.iCursorPos - len;
       
   405                                 }
       
   406                             else
       
   407                                 {
       
   408                                 if ( iCharStartPostion == KInvalidValue )    
       
   409                                     {
       
   410                                     curSor.iAnchorPos = curSor.iCursorPos -  
       
   411                                         ( iLastSubmitCount<len?iLastSubmitCount:len );
       
   412                                     }
       
   413                                 else
       
   414                                     {
       
   415                                     curSor.iAnchorPos = iCharStartPostion;  
       
   416                                     iLastSubmitCount = curSor.iCursorPos - iCharStartPostion;
       
   417                                     //Fixed bug ID SAHN-7JDDC8
       
   418                                     }
       
   419                                 }
       
   420                             
       
   421                             if (curSor.iAnchorPos<0 || 
       
   422                                 curSor.iAnchorPos>edit->DocumentLengthForFep())
       
   423                                 {
       
   424                                 break;
       
   425                                 }
       
   426                             
       
   427                             // check repeated string 
       
   428                             if (len >= iLastSubmitCount)
       
   429                                 {
       
   430                                 TBuf<CAknFepManager::EMaximumFepWordLength> textToUncommit;
       
   431                                 textToUncommit.Zero();    
       
   432                                 
       
   433                                  edit->GetEditorContentForFep(textToUncommit, curSor.iAnchorPos, 
       
   434                                                            Min(curSor.Length(), 
       
   435                                                            CAknFepManager::EMaximumFepWordLength));
       
   436                                 
       
   437                                 repeatCount = RepeatStringFromLeft(s,textToUncommit);    
       
   438                                 curSor.iAnchorPos += repeatCount;
       
   439                                 if (curSor.iAnchorPos<0 || 
       
   440                                     curSor.iAnchorPos>edit->DocumentLengthForFep())
       
   441                                     {
       
   442                                     break;
       
   443                                     }
       
   444                                 }
       
   445                                 
       
   446                             if (curSor.iCursorPos > curSor.iAnchorPos)
       
   447                                 {
       
   448                                 edit->SetCursorSelectionForFepL(curSor);    
       
   449                                 }
       
   450                             }
       
   451                         }
       
   452                     }
       
   453                 else
       
   454                     {
       
   455                     TBuf<1> backSpace;
       
   456                     backSpace.Append(TChar(EKeyBackspace));
       
   457                     for(TInt i = 0; i < len; ++i)
       
   458                         {
       
   459                         SubmitUiPluginTextL(backSpace, EKeyEvent);
       
   460                         }
       
   461                     }
       
   462                 iFepMan.ClearFlag( CAknFepManager::EFlagSupressAutoUpdate );
       
   463                 
       
   464                 if (repeatCount > 0)
       
   465                     {
       
   466                     OnPenInputServerKeyEventL(s.Right(s.Length() - repeatCount));
       
   467                     
       
   468                     iLastSubmitCount += repeatCount;   
       
   469                     }
       
   470                 else
       
   471                     {
       
   472                     OnPenInputServerKeyEventL(s);    
       
   473                     }
       
   474                 }
       
   475                 break;
       
   476             case ESignalKeyEvent:
       
   477                 {
       
   478                 TPtr ptr( const_cast<TUint16*>(pBuf.Ptr()), pBuf.Length(), pBuf.Length() );
       
   479                 if(iFepMan.InputMode() == ELatin && (iPluginInputMode == EPluginInputModeVkb || 
       
   480                    iPluginInputMode == EPluginInputModeFSQ))
       
   481                     {
       
   482                     AdjustDataCase( ptr );
       
   483                     }
       
   484                 OnPenInputServerKeyEventL(pBuf);
       
   485               	}
       
   486               	break;
       
   487             case ESignalNotifyUpdateCba://Update CBA
       
   488                 {
       
   489                 TInt* cbaData = (TInt* )(pBuf.Ptr());
       
   490                 iFepMan.UpdateCbaL(*cbaData);
       
   491                 }
       
   492                 break;                    
       
   493             case ESignalHwNotifySctPopup:
       
   494                 iFepMan.LaunchSpecialCharacterTableL( 0,ETrue );//possible?
       
   495                 break;                      
       
   496             case ESignalSetAppEditorCursor:
       
   497                 {
       
   498                 TInt8 *ptrData = (TInt8* )(pBuf.Ptr());
       
   499                 TCursorSelection curSel = *(TCursorSelection* )(ptrData);
       
   500                 TBool sync = *(TBool *)(ptrData + sizeof(TCursorSelection));
       
   501                 
       
   502                 if ( iFepMan.UncommittedText().Length() > 0 )
       
   503                     {
       
   504                     iFepMan.PtiEngine()->CancelTimerActivity(); 
       
   505                     //using TryCloseUiL() to sync Fep state
       
   506                     //iFepMan.CommitInlineEditL();
       
   507                     iFepMan.TryCloseUiL();
       
   508                     }
       
   509                 //now change the cursor position
       
   510                 SetCursorSelectionL(curSel, sync);
       
   511                 }
       
   512                 break;
       
   513             case ESignalLaunchLanguageMenu:
       
   514                 LaunchPenInputLanguageSelectionL(ETrue);
       
   515                 break;                                       
       
   516             case ESignalLaunchOptionMenu:
       
   517             case ESignalLaunchOptionsMenu:
       
   518                 {
       
   519                 if (iInMenu || (!iPenInputMenu) || iPenInputMenu->IsShowing())
       
   520                     {
       
   521                     break;    
       
   522                     }
       
   523                 iLaunchMenu = ETrue;
       
   524                 if (PluginInputMode() == EPluginInputModeItut ||
       
   525                     PluginInputMode() == EPluginInputModeFSQ ||
       
   526                     PluginInputMode() == EPluginInputModeFingerHwr)
       
   527                     {
       
   528                     SetMenuState();
       
   529                     }                
       
   530                 else
       
   531                     {
       
   532                     ClosePluginInputUiL(ETrue);
       
   533                     }           
       
   534                 LaunchPenInputMenuL(R_AVKON_PENINPUT_OPTION_MENU_BAR);
       
   535                 }
       
   536                 break;
       
   537             case ESignalLayoutClosed:
       
   538                 ClosePluginInputModeL(ETrue);
       
   539                 if(iPenInputSvrConnected ) //lost foreground
       
   540                     {
       
   541                     iPenInputServer.LoseForeground();
       
   542                     }                
       
   543                 break;                    
       
   544             case ESignalCaseMode:
       
   545                 {
       
   546                 TInt* pluginCase = (TInt* )(pBuf.Ptr());    
       
   547                 iFepMan.ClearFlag(CAknFepManager::EFlagSupressAutoUpdate);
       
   548                 
       
   549                 if (ECaseInverseText == *pluginCase)
       
   550                     {
       
   551                     iFepMan.SetFlag(CAknFepManager::EFlagQwertyShiftMode);    
       
   552                     }
       
   553                 iCaseMan.SetCurrentCase(*pluginCase);
       
   554                 
       
   555                 if (ECaseInverseText == *pluginCase)
       
   556                     {
       
   557                     iFepMan.ClearFlag(CAknFepManager::EFlagQwertyShiftMode);    
       
   558                     }
       
   559                 }
       
   560                 break;
       
   561             case ESignalRange:
       
   562                 {
       
   563                 HideTooltipOnFSQL();
       
   564 
       
   565                 TInt newPrimaryRange = *(TInt* )(pBuf.Ptr());
       
   566                 // Addition for ITI features on FSQ, 
       
   567                 // when swith to other ranges from latin/native range, 
       
   568                 // need to commit text to fep and ptiengint if necessary
       
   569                 if ( EnableITIOnFSQ() && newPrimaryRange != ERangeEnglish 
       
   570                      && newPrimaryRange != ERangeNative )
       
   571                     {
       
   572                     iFepMan.CommitInlineEditL();
       
   573                     iFepMan.PtiEngine()->CommitCurrentWord();
       
   574                     }                
       
   575                 iPluginPrimaryRange = newPrimaryRange;
       
   576                 if (ELangJapanese == iSharedData.InputTextLanguage()
       
   577                     && ERangeNative == iPluginPrimaryRange )
       
   578                     {
       
   579                     TInt subrange = *(TInt* )( (TInt8* )(pBuf.Ptr()) + sizeof(TInt) );
       
   580                     iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputJapaneseSetSubRange, 
       
   581                                                              subrange);
       
   582                     }
       
   583                 SyncIndicatorWithPluginRangeL();
       
   584                 }
       
   585                 break;
       
   586             case ESignalLayoutUIChanged:
       
   587                 {
       
   588                 TInt8 *ptrData = (TInt8* )(pBuf.Ptr());
       
   589                 TBool switchByMode = *(TInt*)(ptrData);
       
   590                 if( switchByMode )
       
   591                     {
       
   592                     TInt mode = *(TInt* )( ptrData + sizeof(switchByMode) );
       
   593 					ClosePluginInputModeL(ETrue);               
       
   594                     iFepMan.TryCloseUiL();  
       
   595 					iPreferredUiMode = EFalse;
       
   596                     TryChangePluginInputModeByModeL((TPluginInputMode)mode, 
       
   597                                                     EPenInputOpenManually,
       
   598                                                     ERangeInvalid);
       
   599                     }
       
   600                 }
       
   601                 break;
       
   602             case ESignalCommitInlineText:
       
   603                 {
       
   604                 iFepMan.CommitInlineEditL();
       
   605                 }
       
   606                 break;
       
   607             case ESignalEnterMatchSelection:
       
   608                 {
       
   609                 TBool on = *((TInt*)(pBuf.Ptr()));
       
   610 
       
   611                 if (on)
       
   612                     {
       
   613                     EnterMatchSelectionState();
       
   614                     }
       
   615                 else
       
   616                     {
       
   617                     iFepMan.PluginUIManager()->SetFingerMatchSelectionState(EFalse);
       
   618                     }    
       
   619                 }
       
   620                 break;
       
   621             case ESignalSelectMatchSelectionText:
       
   622                 {
       
   623                 TInt* ptrData = (TInt*)(pBuf.Ptr());
       
   624                 TInt itemidx = *(ptrData);
       
   625                 TBool commit = *(ptrData + 1);
       
   626                 
       
   627                 iFepMan.UpdateInlineEditL(iSendAllList.iCandidates[itemidx], 
       
   628                                           iSendAllList.iCandidates[itemidx].Length());
       
   629                 
       
   630                 if (commit)
       
   631                     {
       
   632                     iFepMan.TryCloseUiL();
       
   633                     iFepMan.FepUI()->HandleCommandL(ESignalSelectMatchSelectionText);
       
   634                     }
       
   635                 else
       
   636                     {
       
   637                     iFepMan.PluginUIManager()->SetFingerMatchSelectionState(EFalse);
       
   638                     }    
       
   639                 
       
   640                 SendIcfDataL(EPluginSyncUpdatedText);
       
   641                 }
       
   642                 break;
       
   643             case ESignalEnterSpellMode:
       
   644                 {
       
   645                 iFepMan.LaunchEditWordQueryL();
       
   646                 }
       
   647                 break;
       
   648             case ESignalExitSpellMode:
       
   649                 {
       
   650                 TInt* ptrData = (TInt*)(pBuf.Ptr());
       
   651                 TBool exitbyok = *(ptrData);
       
   652 
       
   653                 exitbyok ? iFepMan.ExitPluginSpellModeByOk() : 
       
   654                            iFepMan.ExitPluginSpellModeByCancel();
       
   655                 }
       
   656                 break;
       
   657             case ESignalLaunchSCT:
       
   658             	{
       
   659             	iFepMan.LaunchSpecialCharacterTableL(0,ETrue);	
       
   660             	}
       
   661             	break;
       
   662             case ESignalGetEditMenuData:
       
   663                 {
       
   664                 //Calcuate which menu needed to add
       
   665                 iFepMan.GetPermittedEditorMenu(EFalse);
       
   666                 }
       
   667                 break;
       
   668             case ESignalEditorMenuCommand:
       
   669                 {
       
   670                 //Execute editor menu command
       
   671                 TInt* command = (TInt* )(pBuf.Ptr());
       
   672                 iFepMan.ProcessEditorMenuCommand(*command);
       
   673                 iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputFingerInputMode,
       
   674                                                          iFepMan.InputMode());
       
   675                     
       
   676                 iIndicatorImgID = 0;
       
   677                 iIndicatorTextID = 0;  
       
   678                 UpdateITUTIndicator();                
       
   679                 }
       
   680                 break;                
       
   681             case ESignalCharacterStart:
       
   682                 {
       
   683                 TBool charStart = *(TBool*)(pBuf.Ptr());
       
   684                 if( charStart )
       
   685                     {
       
   686                     MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor(); 
       
   687                     if( !edit )
       
   688                         {
       
   689                         break;
       
   690                         }
       
   691                     TCursorSelection curSor;
       
   692                     edit->GetCursorSelectionForFep(curSor);
       
   693                     iCharStartPostion = Min( curSor.iCursorPos, curSor.iAnchorPos );          
       
   694 
       
   695                     }
       
   696                 else
       
   697                     {
       
   698                     iCharStartPostion = KInvalidValue;
       
   699                     }
       
   700                 }
       
   701                 break;
       
   702             case ESignalShowCandidate:
       
   703                 {
       
   704                 // Get candidate list
       
   705                 TInt activeIdx = 0;
       
   706                 CDesCArray* candidates = new (ELeave) CDesCArrayFlat
       
   707                                                  ( KDefaultCandidateArraySize );
       
   708         		CleanupStack::PushL( candidates );
       
   709         		iFepMan.GetCandidatesL( *candidates, activeIdx );
       
   710         		TFepITICandidateList candidateListData;
       
   711         		candidateListData.iItemArray = candidates;
       
   712         		candidateListData.iActiveIndex 
       
   713         		            = ( candidates->Count() >= 2 ) ? 1 : activeIdx;        		
       
   714         		ShowCandidateListL( candidateListData );        		
       
   715         		CleanupStack::PopAndDestroy( candidates );                
       
   716                 }
       
   717                 break;
       
   718             case ESignalSelectCandidate:
       
   719                 {
       
   720                 // Select candidate word on fsq
       
   721                 TInt index = *(TInt*)( pBuf.Ptr() );
       
   722                 CommitCandidateWordOnFSQL( index );                
       
   723                 break;
       
   724                 }
       
   725             case ESignalAcceptTooltip:
       
   726                 {
       
   727                 // Simulate Up key and then join in the key flow for HW
       
   728                 // to accept tooltip
       
   729                 TKeyEvent keyEvent = { EKeyUpArrow, EStdKeyUpArrow, 0, 0 };                  
       
   730                 CCoeEnv::Static()->SimulateKeyEventL( keyEvent, EEventKey );
       
   731                 
       
   732                 // commit tooltip text then commit inline                
       
   733                 iFepMan.CommitInlineEditL();
       
   734                 // Need to commit into engine, it will clear textbuffer in it.
       
   735                 iFepMan.PtiEngine()->CommitCurrentWord();
       
   736                 }
       
   737                 break;
       
   738             case ESignalStartInlineText:
       
   739                 {
       
   740                 if (!(iFepMan.IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)))
       
   741                     {
       
   742 					TBuf<CAknFepManager::EMaximumFepWordLength> textToUncommit;
       
   743 					TBool comsumeKey;
       
   744 					
       
   745 					if (!(iFepMan.TryGetTextToUncommitL(textToUncommit, comsumeKey)))
       
   746 						{
       
   747 						// If T9 word length > 32, the navi key is consumed without action.
       
   748 						// Maybe should navigate inside word.
       
   749 						return comsumeKey;
       
   750 						}
       
   751 					iFepMan.PtiEngine()->ClearCurrentWord();
       
   752 					iFepMan.PtiEngine()->SetCurrentWord(textToUncommit); // this set the input sequence of PtiEngine          
       
   753 					iFepMan.StartInlineEditL(iFepMan.UncommittedText(), textToUncommit, 
       
   754 											 textToUncommit.Length(), EFalse);
       
   755 
       
   756                     // update ICF content
       
   757                     SendIcfDataL();
       
   758                     }
       
   759                 }
       
   760                 break;
       
   761             case ESignalCommitITIInlineText:
       
   762                 {
       
   763                 // Commit autocompletion
       
   764                 iFepMan.CommitInlineEditL();
       
   765                 // Need to commit into engine, it will clear textbuffer in it.
       
   766                 iFepMan.PtiEngine()->CommitCurrentWord();
       
   767                 }
       
   768                 break;
       
   769             default:
       
   770                 break;
       
   771             }
       
   772         }  
       
   773     return bHandled;
       
   774     }
       
   775     
       
   776 // -----------------------------------------------------------------------------
       
   777 // CAknFepPluginManager::EnterMatchSelectionState
       
   778 // Enter match selection state
       
   779 // (other items were commented in a header).
       
   780 // -----------------------------------------------------------------------------
       
   781 //
       
   782 TBool CAknFepPluginManager::EnterMatchSelectionState()
       
   783     {
       
   784     GetAllPredictiveCandidate();
       
   785     
       
   786     if (iCandidateList.Count() > 0)
       
   787         {
       
   788         SetFingerMatchSelectionState(ETrue);
       
   789         iFepMan.PluginUIManager()->ShowAllCandidates();
       
   790         return ETrue;
       
   791         }
       
   792     
       
   793     return EFalse;    
       
   794     }
       
   795 
       
   796 // -----------------------------------------------------------------------------
       
   797 // CAknFepPluginManager::HandleEventsFromFepL
       
   798 // Handle events from FEP
       
   799 // (other items were commented in a header).
       
   800 // -----------------------------------------------------------------------------
       
   801 //
       
   802 void CAknFepPluginManager::HandleEventsFromFepL( TInt aEventType, TInt aEventData )
       
   803     {
       
   804 
       
   805     if( iPluginInputMode == EPluginInputModeNone && 
       
   806         aEventType != EPluginEditorActivate && 
       
   807         aEventType != EPluginActivate &&
       
   808         aEventType != EPluginResourceChanged )
       
   809         {      
       
   810         return;
       
   811         }
       
   812         
       
   813     switch ( aEventType )
       
   814         {
       
   815         case EPluginEditorActivate:
       
   816             {
       
   817             ActivatePenInputL();
       
   818             RWsSession &ws = CCoeEnv::Static()->WsSession();
       
   819             TInt wgId =ws.GetFocusWindowGroup();
       
   820             iEditorPriority = ws.GetWindowGroupOrdinalPriority(wgId);
       
   821             }
       
   822             break;
       
   823         case EPluginActivate:
       
   824             {//The command is obsolete, use other commands
       
   825             //current only some Japanese menu commands call this
       
   826             ActivatePenInputL();    
       
   827             }            
       
   828             break;
       
   829         case EPluginCloseMode:
       
   830             {
       
   831             if (iPluginInputMode == EPluginInputModeItut && 
       
   832                 !iSharedData.PredictiveTextAutoCompleteOn())
       
   833             	{
       
   834             	return;
       
   835             	}
       
   836             
       
   837             ClosePluginInputModeL( aEventData );
       
   838             }
       
   839             break;
       
   840         case EPluginFocusItemDestroy:
       
   841             if( iFepMan.FepAwareTextEditor() )
       
   842                 {
       
   843                 iMfne = NULL;
       
   844                 if ( !aEventData )
       
   845                     {
       
   846                     RemoveLastFocusedWinFromOpenList();
       
   847                     }
       
   848                 else
       
   849                     {
       
   850                     ClosePluginInputUiL(ETrue);
       
   851                     }
       
   852                 }
       
   853             break;
       
   854         case EPluginSyncFepAwareText:
       
   855             {
       
   856             SyncFepAwareText( TPluginSync(aEventData) );
       
   857             }
       
   858             break;
       
   859         /*case EPluginActivateInGlobalNote:
       
   860             {
       
   861             OnFocusChangedL(ETrue);
       
   862             iPenInputServer.ActivatePeninputInNotesL();           
       
   863             }
       
   864             break;*/
       
   865         case EPluginMenuCmd:
       
   866             {
       
   867             ProcessMenuCommandL( aEventData );
       
   868             }
       
   869             break;
       
   870         case EPluginForegroundChanged:
       
   871             {
       
   872             iForegroundChange = ETrue;   
       
   873             iLaunchHelp = EFalse;    
       
   874             
       
   875             if (!aEventData && IsInGlobleNoteEditor())
       
   876                 {
       
   877                 ClosePluginInputUiL(ETrue);
       
   878                 if(iPenInputSvrConnected ) //lost foreground
       
   879                     {
       
   880                     iPenInputServer.LoseForeground();
       
   881                     }
       
   882                 }
       
   883             else
       
   884                 {
       
   885                 OnFocusChangedL( aEventData ) ;   
       
   886                 }
       
   887             }
       
   888             break;
       
   889         case EPluginFocusChanged:
       
   890             {
       
   891             OnFocusChangedL( aEventData );
       
   892             }
       
   893             break;
       
   894         case EPluginResourceChanged:
       
   895             {
       
   896 			iOrientationChangedfromUI = ETrue;
       
   897             OnResourceChangedL( aEventData );
       
   898 			iOrientationChangedfromUI = EFalse;
       
   899             }
       
   900             break;
       
   901         case EPluginFaseSwap:
       
   902             {
       
   903             iFastSwapByMenu = aEventData;
       
   904             }
       
   905             break;
       
   906         case EPluginKeyEvent:
       
   907             {
       
   908             HandleKeyEventL( aEventData );
       
   909             }
       
   910             break;
       
   911         case EPluginUpdateIndicator:
       
   912             {
       
   913             UpdateITUTIndicator();
       
   914             }
       
   915             break;
       
   916         case EPluginPreview:
       
   917             {
       
   918             iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputCharacterPreview, 
       
   919                aEventData);                 
       
   920             }
       
   921             break;
       
   922         case EPluginPromptChanged:
       
   923             {
       
   924             SetPromptText( EFalse );
       
   925             }
       
   926             break;
       
   927         case ELostForeground:
       
   928             {
       
   929             if(iPenInputSvrConnected ) //lost foreground
       
   930                 {
       
   931                 iPenInputServer.LoseForeground();
       
   932                 }
       
   933             }
       
   934             break;
       
   935         case EPluginShowTooltip:
       
   936         	{
       
   937         	ShowTooltipOnFSQL( aEventData );
       
   938         	}
       
   939         	break;
       
   940         case EPluginHideTooltip:
       
   941         	{
       
   942         	HideTooltipOnFSQL();
       
   943         	}
       
   944         	break;
       
   945         default:
       
   946             break;
       
   947         }
       
   948     }
       
   949             
       
   950 // -----------------------------------------------------------------------------
       
   951 // CAknFepPluginManager::TryChangePluginInputModeByModeL
       
   952 // Change current input method to plugin input method with specified layout UI id.
       
   953 // (other items were commented in a header).
       
   954 // -----------------------------------------------------------------------------
       
   955 //
       
   956 TBool CAknFepPluginManager::TryChangePluginInputModeByModeL
       
   957     (TPluginInputMode aSuggestMode, TInt aOpenMode,TInt aSuggestRange)
       
   958     {
       
   959     if ( iSharedData.QwertyInputMode() )
       
   960         {
       
   961         return EFalse;
       
   962         }
       
   963 
       
   964     TBool rtn = EFalse;
       
   965     if ( iFepMan.ExtendedInputCapabilities() & 
       
   966         CAknExtendedInputCapabilities::EInputEditorDisableVKB ) 
       
   967         {
       
   968         return EFalse;
       
   969         }
       
   970 
       
   971     if (! ConnectServer() )
       
   972         {
       
   973         return EFalse;
       
   974         }
       
   975     
       
   976     
       
   977     if ((iPenInputServer.PreferredUiMode() != EPluginInputModeNone) && iPreferredUiMode )
       
   978         {
       
   979         aSuggestMode = iPenInputServer.PreferredUiMode();
       
   980         }
       
   981         
       
   982     if (!GetCurSuggestMode( aSuggestMode ))
       
   983         {
       
   984         return EFalse;    
       
   985         }
       
   986     
       
   987     // add by jiawenjuan to remember the old fep aware editor.
       
   988     TBool cleanContent = EFalse;   
       
   989     if(iOldFepAwareEditor != iFepMan.FepAwareTextEditor())
       
   990         {
       
   991         cleanContent = ETrue;
       
   992         iOldFepAwareEditor = iFepMan.FepAwareTextEditor();
       
   993         }
       
   994 
       
   995     if( !iAdjustDataQueryTimer )
       
   996         {
       
   997         iAdjustDataQueryTimer = CPeriodic::NewL(CActive::EPriorityStandard);
       
   998         }
       
   999             
       
  1000     // Addition for ITI features on FSQ, if iITISettingDialogOpen == ETrue,
       
  1001     // it means that predictive setting dialog is closed, then re-open FSQ again.
       
  1002     // Need to set iITISettingDialogOpen = EFalse at this moment
       
  1003     if ( iITISettingDialogOpen )
       
  1004     	{
       
  1005     	iITISettingDialogOpen = EFalse;
       
  1006     	}  
       
  1007     
       
  1008     // getting a new ui manager object corresponded in aMode.
       
  1009     TInt uiLanguage = iSharedData.DisplayLanguage();
       
  1010     if( uiLanguage == ELangTest )
       
  1011         {
       
  1012         uiLanguage = User::Language();
       
  1013         }
       
  1014     
       
  1015     if ( iDefaultOrientation == -1 )
       
  1016         {
       
  1017         iDefaultOrientation = iAvkonAppUi->Orientation();
       
  1018         }
       
  1019     iPenInputServer.BackgroudDefaultOri( iDefaultOrientation );
       
  1020     
       
  1021     TPixelsTwipsAndRotation size; 
       
  1022     CCoeEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation(size);
       
  1023     TBool landscape = size.iPixelSize.iWidth > size.iPixelSize.iHeight;     
       
  1024     TBool disableFSQ = 
       
  1025         (  aSuggestMode == EPluginInputModeFSQ &&
       
  1026            ( iDefaultOrientation == CAknAppUiBase::EAppUiOrientationPortrait ||
       
  1027 		     ( !landscape && !iAvkonAppUi->OrientationCanBeChanged() ) ) );
       
  1028           
       
  1029     if ( disableFSQ )
       
  1030         {
       
  1031         iPenInputServer.SetDisabledLayout( EPluginInputModeFSQ );
       
  1032         }
       
  1033 
       
  1034     if ( aSuggestMode == EPluginInputModeFSQ )
       
  1035         {
       
  1036         TPluginInputMode tempInputMode = iPluginInputMode;           
       
  1037         iPluginInputMode = EPluginInputModeFSQ;
       
  1038         
       
  1039         if (disableFSQ )
       
  1040             {
       
  1041             iPluginInputMode = tempInputMode;
       
  1042             aSuggestMode = EPluginInputModeItut;
       
  1043             }
       
  1044         else
       
  1045             {
       
  1046             if ( !iSharedData.AutoRotateEnabled() )
       
  1047                 {
       
  1048                 iFepMan.SetNotifyPlugin( EFalse );
       
  1049                 iAvkonAppUi->SetOrientationL( CAknAppUiBase::EAppUiOrientationLandscape );
       
  1050                 iFepMan.SetNotifyPlugin( ETrue );
       
  1051                 iOrientationChanged = ETrue;
       
  1052                 }
       
  1053         
       
  1054 		    CCoeEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation(size);
       
  1055             landscape = size.iPixelSize.iWidth > size.iPixelSize.iHeight;  
       
  1056             if( !landscape )
       
  1057                 {
       
  1058                 iPluginInputMode = tempInputMode;
       
  1059                 aSuggestMode = EPluginInputModeItut;
       
  1060                 }
       
  1061             }
       
  1062         }
       
  1063     else if ( iOrientationChanged )
       
  1064         {
       
  1065         iFepMan.SetNotifyPlugin( EFalse );
       
  1066         iAvkonAppUi->SetOrientationL( (CAknAppUiBase::TAppUiOrientation)iDefaultOrientation );
       
  1067         iFepMan.SetNotifyPlugin( ETrue );
       
  1068         iOrientationChanged = EFalse;
       
  1069         }
       
  1070     
       
  1071     TBool isSplit = IsEditorSupportSplitIme();
       
  1072     // temp code for Chinese split view
       
  1073     if ( iSharedData.PenInputLanguage() == ELangPrcChinese || 
       
  1074          iSharedData.PenInputLanguage() == ELangTaiwanChinese ||
       
  1075          iSharedData.PenInputLanguage() == ELangHongKongChinese )
       
  1076         {
       
  1077         isSplit = EFalse;
       
  1078         }    
       
  1079     iLangMan.SetSplitView(isSplit);
       
  1080  
       
  1081     TInt inputLang = iFepMan.InputLanguageCapabilities().iInputLanguageCode;
       
  1082     MAknFepManagerInterface* fepUI = iLangMan.GetPluginInputFepUiL(
       
  1083                                                     aSuggestMode, 
       
  1084                                                     inputLang,
       
  1085                                                     uiLanguage,
       
  1086                                                     &iPenInputServer); 
       
  1087     iCurrentPluginInputFepUI = fepUI;
       
  1088     
       
  1089     if ( iCurrentPluginInputFepUI )     
       
  1090         {
       
  1091         // fix EVWG-7U73HS
       
  1092         iPenInputServer.DimUiLayout(EFalse);
       
  1093         
       
  1094         AddCurrentWinToOpenListL();
       
  1095         if (iPluginInputMode == EPluginInputModeItut)
       
  1096             {
       
  1097             iIndicatorImgID = 0;
       
  1098             iIndicatorTextID = 0;           
       
  1099             }
       
  1100 
       
  1101         iPluginInputMode = (TPluginInputMode)iLangMan.CurrentImePlugin()->CurrentMode();
       
  1102 
       
  1103 
       
  1104         // Addition for ITI features on FSQ
       
  1105         // Before open touch window, need to set iPluginPrimaryRange = 0
       
  1106         // which means use the default range.
       
  1107         iPluginPrimaryRange = 0;
       
  1108         
       
  1109         InitializePluginInputL(aOpenMode, aSuggestRange, cleanContent);
       
  1110 
       
  1111         //following codes is used to tell MFNE editor the Touch Input 
       
  1112         //has been opened. Because MFNE editor has no editorstate, so 
       
  1113         //use this way to implement this.
       
  1114         if ( iFepMan.IsMfneEditor() )
       
  1115             {
       
  1116             MCoeFepAwareTextEditor* mfne( iFepMan.FepAwareTextEditor() );
       
  1117             iMfneChanged = ( iMfne != mfne );
       
  1118             iMfne = mfne;
       
  1119             InformMfneUiStatusL( ETrue );  
       
  1120             }
       
  1121         
       
  1122         //save plugin input mode to repository
       
  1123         if( iPenInputServer.PreferredUiMode() == EPluginInputModeNone )
       
  1124             {
       
  1125             //do not remember application set input mode
       
  1126             iSharedData.SetPluginInputMode(iPluginInputMode);
       
  1127             }
       
  1128             
       
  1129         if (CurrentFepInputUI())
       
  1130            	{
       
  1131            	CurrentFepInputUI()->SetMode(iFepMan.InputMode(), ETrue, EFalse);		
       
  1132            	}
       
  1133 			
       
  1134         if(!iOrientationChangedfromUI)
       
  1135 		    {
       
  1136 		    iFepMan.UpdateCbaL( NULL );
       
  1137 		    }
       
  1138         
       
  1139         // Notify application touch window state
       
  1140         NotifyAppUiImeTouchWndState( ETrue );
       
  1141 
       
  1142         rtn = ETrue;
       
  1143         }
       
  1144     else
       
  1145         {
       
  1146         iPluginInputMode = EPluginInputModeNone;
       
  1147         }   
       
  1148         
       
  1149     if( iCurrentPluginInputFepUI && iPluginInputMode != EPluginInputModeNone )
       
  1150         {
       
  1151         iFepMan.UiInterface()->TouchPaneSetInputMethodIconActivated(ETrue);
       
  1152         }
       
  1153     else
       
  1154         {
       
  1155         iFepMan.UiInterface()->TouchPaneSetInputMethodIconActivated(EFalse);
       
  1156         }
       
  1157         
       
  1158         
       
  1159     if ( aOpenMode == EPenInputOpenManually )   
       
  1160     	{
       
  1161         iCurLanguage = iSharedData.InputTextLanguage();	
       
  1162     	}
       
  1163     return rtn;
       
  1164     }
       
  1165     
       
  1166 // -----------------------------------------------------------------------------
       
  1167 // CAknFepPluginManager::ClosePluginInputModeL
       
  1168 // Close plugin input mode
       
  1169 // (other items were commented in a header).
       
  1170 // -----------------------------------------------------------------------------
       
  1171 //
       
  1172 void CAknFepPluginManager::ClosePluginInputModeL( TBool aRestore )
       
  1173     {   
       
  1174     if (iPluginInputMode == EPluginInputModeNone)
       
  1175         {
       
  1176         return;
       
  1177         }
       
  1178       
       
  1179     iOldFepAwareEditor = NULL;	
       
  1180     if ( iSharedData.QwertyInputMode() && iPenInputMenu )
       
  1181         {
       
  1182         iPenInputMenu->Hide();
       
  1183         }    
       
  1184         
       
  1185     TPluginInputMode prePluginInputMode = iPluginInputMode;
       
  1186     RemoveCurrentWinFromOpenList();
       
  1187     ClosePluginInputUiL(ETrue);
       
  1188     iClosePluginInputMode = ETrue;
       
  1189        
       
  1190     // TInt prevIputMode = iPluginInputMode;
       
  1191     
       
  1192     if( iOpenWindowList.Count() == 0 || iSharedData.QwertyInputMode() )
       
  1193         {
       
  1194         iPluginInputMode = EPluginInputModeNone;
       
  1195         }
       
  1196     
       
  1197     if( aRestore && !iSharedData.QwertyInputMode() && iFepMan.InputMode() == ELatin)
       
  1198         {
       
  1199 	    RestorePredictStateL();
       
  1200         if ( iFepMan.EditorType() == CAknExtendedInputCapabilities::EPhoneNumberEditor )
       
  1201             {
       
  1202             if( AknTextUtils::NumericEditorDigitType() == EDigitTypeEasternArabicIndic || 
       
  1203                 AknTextUtils::NumericEditorDigitType() == EDigitTypeDevanagari ||
       
  1204                 AknTextUtils::NumericEditorDigitType() == EDigitTypeArabicIndic )
       
  1205                 {
       
  1206                 iFepMan.TryChangeModeL( ENativeNumber );
       
  1207                 }
       
  1208             else
       
  1209                 {
       
  1210                 iFepMan.TryChangeModeL( ENumber );
       
  1211                 }
       
  1212             }
       
  1213         }
       
  1214     //iFepMan.UpdateCbaL( NULL ); //pls refer to bug ESZG-7G7CGF
       
  1215                 
       
  1216     iFepMan.UiInterface()->TouchPaneSetInputMethodIconActivated(EFalse);
       
  1217     
       
  1218     if ( prePluginInputMode == EPluginInputModeVkb )
       
  1219         {
       
  1220         iFepMan.UpdateIndicators();
       
  1221         }        
       
  1222     }   
       
  1223    
       
  1224 // -----------------------------------------------------------------------------
       
  1225 // CAknFepPluginManager::ClosePluginInputUiL
       
  1226 // Close plugin input UI, only close UI
       
  1227 // (other items were commented in a header).
       
  1228 // -----------------------------------------------------------------------------
       
  1229 //
       
  1230 void CAknFepPluginManager::ClosePluginInputUiL(TBool aResetState)
       
  1231     {
       
  1232     // For addition of ITI features on FSQ, 
       
  1233     // need to restore some values stored before opening FSQ    
       
  1234     
       
  1235     iConnectAo->Cancel();
       
  1236     ResetItiStateL();
       
  1237 
       
  1238     if( iPenInputSvrConnected )
       
  1239         {
       
  1240         if( iCurrentPluginInputFepUI )
       
  1241             {
       
  1242             //Change for finger support of MFNE editor, it is a requirement for Tube
       
  1243             InformMfneUiStatusL( EFalse );            
       
  1244             
       
  1245             iPenInputServer.ClearServerEvent();
       
  1246             iCurrentPluginInputFepUI->CloseUI();
       
  1247             if( aResetState )
       
  1248                 {
       
  1249                 iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputWindowClose);
       
  1250                 }
       
  1251             
       
  1252             //iFepMan.UpdateCbaL(NULL); //pls refer to bug ESZG-7G7CGF
       
  1253             
       
  1254             if (iPluginInputMode == EPluginInputModeItut)
       
  1255                 {
       
  1256                 iIndicatorImgID = 0;
       
  1257                 iIndicatorTextID = 0;           
       
  1258                 }            
       
  1259             }
       
  1260         }
       
  1261 
       
  1262     if ( iPluginInputMode == EPluginInputModeFSQ  && iOrientationChanged )
       
  1263         {
       
  1264 		// This TRAP_IGNORE is essential to fix bug ECJA-7JDCKR, never delete it
       
  1265         TRAP_IGNORE( iAvkonAppUi->SetOrientationL( (CAknAppUiBase::TAppUiOrientation)iDefaultOrientation ) );
       
  1266         iOrientationChanged = EFalse;
       
  1267         } 
       
  1268         
       
  1269     // Notify editor the touch window has been closed
       
  1270     NotifyAppUiImeTouchWndState( EFalse );
       
  1271     
       
  1272     iCharStartPostion = KInvalidValue;
       
  1273     }
       
  1274 
       
  1275 // ---------------------------------------------------------------------------
       
  1276 // CAknFepPluginManager::OnResourceChangedL
       
  1277 // (other items were commented in a header)
       
  1278 // ---------------------------------------------------------------------------
       
  1279 // 
       
  1280 void CAknFepPluginManager::OnResourceChangedL( TInt aType )
       
  1281     { 
       
  1282     if ( !iCurrentPluginInputFepUI || !iPenInputServer.IsForeground() || 
       
  1283          iPluginInputMode == EPluginInputModeNone )
       
  1284         {
       
  1285         return;
       
  1286         }
       
  1287         
       
  1288     if ( iPluginInputMode == EPluginInputModeFSQ && 
       
  1289          !iSharedData.AutoRotateEnabled())
       
  1290         {
       
  1291         return;
       
  1292         }
       
  1293         
       
  1294     TBool setResChange = EFalse;
       
  1295     
       
  1296     if (iPluginInputMode == EPluginInputModeItut || 
       
  1297          iPluginInputMode == EPluginInputModeFSQ ||
       
  1298         iPluginInputMode == EPluginInputModeFingerHwr)
       
  1299         {
       
  1300         setResChange = ETrue;
       
  1301         iPenInputServer.SetResourceChange(ETrue);    
       
  1302         }
       
  1303     
       
  1304     iResourceChange = ETrue;   
       
  1305 
       
  1306     if ( iSharedData.AutoRotateEnabled() && 
       
  1307         ( iPluginInputMode == EPluginInputModeFSQ || iPluginInputMode == EPluginInputModeItut ) )
       
  1308         {
       
  1309         if ( IsSpellVisible() )
       
  1310             {
       
  1311             iFepMan.ExitPluginSpellModeByCancel();
       
  1312             }
       
  1313         
       
  1314         if ( iPenInputMenu && iPenInputMenu->IsShowing() )
       
  1315             {
       
  1316             iPenInputMenu->Hide();
       
  1317             ResetMenuState();
       
  1318             }
       
  1319         ClosePluginInputModeL(ETrue);               
       
  1320         iFepMan.TryCloseUiL(); 
       
  1321         TPixelsTwipsAndRotation size; 
       
  1322         CCoeEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation(size);
       
  1323 
       
  1324         iPluginInputMode = ( size.iPixelSize.iWidth < size.iPixelSize.iHeight ) ? 
       
  1325             EPluginInputModeItut : EPluginInputModeFSQ;
       
  1326         }
       
  1327     TryChangePluginInputModeByModeL( iPluginInputMode,
       
  1328                                      EPenInputOpenManually,
       
  1329                                      ERangeInvalid ); 
       
  1330     /*if(size.iPixelSize.iWidth > size.iPixelSize.iHeight ) //landscape
       
  1331         {
       
  1332         if ( iPluginInputMode == EPluginInputModeVkb )
       
  1333             {        	
       
  1334             // Get store value from CenRep
       
  1335             TryChangePluginInputModeByModeL((TPluginInputMode)(iSharedData.FepLastUseVkbModeForLandscape()),
       
  1336                                             EPenInputOpenManually,
       
  1337                                             ERangeInvalid); 
       
  1338             hasChanged = ETrue;                                
       
  1339             }                 
       
  1340         } 
       
  1341     else
       
  1342         {
       
  1343         if ( iPluginInputMode == EPluginInputModeFSQ )
       
  1344             {
       
  1345             TryChangePluginInputModeByModeL(EPluginInputModeVkb,
       
  1346                                             EPenInputOpenManually,
       
  1347                                             ERangeInvalid);     
       
  1348             hasChanged = ETrue;                                       
       
  1349             }
       
  1350         
       
  1351         }*/
       
  1352     if ( /*!hasChanged &&*/ iCurrentPluginInputFepUI )
       
  1353         {
       
  1354         iCurrentPluginInputFepUI->ResourceChanged(aType);
       
  1355         }
       
  1356     
       
  1357     if (iInMenu)
       
  1358         {
       
  1359         SetMenuState(EFalse);
       
  1360         }
       
  1361         
       
  1362     if (setResChange)    
       
  1363         {
       
  1364         iPenInputServer.SetResourceChange(EFalse);         
       
  1365         }
       
  1366 
       
  1367     iResourceChange = EFalse;
       
  1368     if(IsDisplayDataQuery() && //data query
       
  1369        PluginInputMode() == EPluginInputModeVkb &&
       
  1370        !iAdjustDataQueryTimer->IsActive()) //only vkb mode 
       
  1371         {
       
  1372         iAdjustDataQueryTimer->Start(KCursorBlinkPerioid, 
       
  1373                                      KCursorBlinkPerioid, 
       
  1374                                      TCallBack(AdjustDataQueryCallBackL , this)); 
       
  1375         }
       
  1376     }     
       
  1377 
       
  1378 // ---------------------------------------------------------------------------
       
  1379 // CAknFepPluginManager::SyncFepAwareText
       
  1380 // (other items were commented in a header)
       
  1381 // ---------------------------------------------------------------------------
       
  1382 //     
       
  1383 void CAknFepPluginManager::SyncFepAwareText( TPluginSync aSyncType, TBool /*aSendNow*/ )
       
  1384     {
       
  1385     TRAP_IGNORE(SendIcfDataL(aSyncType));
       
  1386     }   
       
  1387        
       
  1388 // ---------------------------------------------------------------------------
       
  1389 // CAknFepPluginManager::ProcessMenuCommand
       
  1390 // (other items were commented in a header)
       
  1391 // ---------------------------------------------------------------------------
       
  1392 // 
       
  1393 void CAknFepPluginManager::ProcessMenuCommandL(TInt aCommandId)
       
  1394     {
       
  1395     if( iPenInputMenu && iPenInputMenu->IsShowing() )
       
  1396         {
       
  1397         iPenInputMenu->Hide();
       
  1398         if( !iLangMan.CurrentImePlugin()->HandleMenuCommandL(aCommandId) )
       
  1399             {
       
  1400             switch(aCommandId)
       
  1401                 {
       
  1402                 case EPenInputCmdHwrTraining:
       
  1403                     {
       
  1404                     LaunchHwrTrainUiL();
       
  1405                     iFepMan.SetGainForeground( EFalse );
       
  1406                     }
       
  1407                     break;
       
  1408                 case EPenInputCmdSetting:
       
  1409                     {
       
  1410                     if (iInMenu)
       
  1411                         {
       
  1412                         ResetMenuState(EFalse);    
       
  1413                         ClosePluginInputUiL(ETrue);
       
  1414                         if(iPenInputSvrConnected ) //lost foreground
       
  1415                             {
       
  1416                             iPenInputServer.LoseForeground();
       
  1417                             }                        
       
  1418                         }
       
  1419 
       
  1420                     LaunchPenInputSettingL();
       
  1421                     }
       
  1422                     break;                
       
  1423                 case EPenInputCmdVITUT:
       
  1424                     {
       
  1425 					ClosePluginInputModeL(ETrue);             
       
  1426                     iFepMan.TryCloseUiL();  
       
  1427                     TryChangePluginInputModeByModeL(EPluginInputModeItut, 
       
  1428                                                     EPenInputOpenManually,
       
  1429                                                     ERangeInvalid);
       
  1430                     }
       
  1431                     break;
       
  1432                 case EPeninputCmdFSQ:
       
  1433                     {
       
  1434 					ClosePluginInputModeL(ETrue);               
       
  1435                     iFepMan.TryCloseUiL();  
       
  1436                     TryChangePluginInputModeByModeL(EPluginInputModeFSQ, 
       
  1437                                                     EPenInputOpenManually,
       
  1438                                                     ERangeInvalid);
       
  1439                     }
       
  1440                     break;
       
  1441                 case EFepInputCmdHelp:
       
  1442                     {
       
  1443                     if (iInMenu)
       
  1444                         {
       
  1445                         ResetMenuState(EFalse);    
       
  1446                         ClosePluginInputUiL(ETrue);
       
  1447                         if(iPenInputSvrConnected ) //lost foreground
       
  1448                             {
       
  1449                             iPenInputServer.LoseForeground();
       
  1450                             }                        
       
  1451                        }
       
  1452                     if (GetCurAppUid().iUid != KAknHelpAppUid)
       
  1453                         {
       
  1454                         iLaunchHelp = ETrue;
       
  1455                         }
       
  1456                     LaunchHelpL();
       
  1457                     }
       
  1458                     break;
       
  1459                 case EPenInputCmdCut:
       
  1460                     {//ctrl + x
       
  1461                     iFepMan.HandleCopyCutEventL(EEikCmdEditCut);
       
  1462                     }   // Send cut-event to edwin.
       
  1463                     break;
       
  1464                 case EPenInputCmdCopy:
       
  1465                     {//ctrl + c
       
  1466                     iFepMan.HandleCopyCutEventL(EEikCmdEditCopy);
       
  1467                     }   // Send copy-event to edwin.
       
  1468                     break;
       
  1469                 case EEikCmdEditPaste:
       
  1470                     {//ctrl + v
       
  1471                     TKeyEvent ccpuKey = KAknCcpuPasteEvent;
       
  1472                     CCoeEnv::Static()->SimulateKeyEventL( ccpuKey, EEventKey );
       
  1473                     }   // Send copy-event to edwin.
       
  1474                     break;
       
  1475                 }
       
  1476             }
       
  1477         }
       
  1478     }
       
  1479 
       
  1480 // ---------------------------------------------------------------------------
       
  1481 // CAknFepPluginManager::HandleKeyEventL
       
  1482 // (other items were commented in a header)
       
  1483 // ---------------------------------------------------------------------------
       
  1484 // 
       
  1485 void CAknFepPluginManager::HandleKeyEventL(TInt aKeyId)
       
  1486     {
       
  1487     switch ( aKeyId )
       
  1488         {
       
  1489         case EKeyF19:
       
  1490             {
       
  1491             SyncFepAwareText( EPluginSyncUpdatedText );
       
  1492             }
       
  1493             break;
       
  1494         case EPtiKeyHash:
       
  1495             {
       
  1496             if (PluginInputMode() == EPluginInputModeItut) 
       
  1497                 {
       
  1498                 if ( iFepMan.IsChineseInputLanguage() || 
       
  1499                     !( iFepMan.InputMode() == ENumber && iFepMan.WasLastKeyPressAHashKey() ) )
       
  1500                     {
       
  1501                     if (iCurrentPluginInputFepUI)
       
  1502                         {
       
  1503                         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputFingerInputMode,
       
  1504                             iFepMan.InputMode());
       
  1505                             
       
  1506                         iIndicatorImgID = 0;
       
  1507                         iIndicatorTextID = 0;  
       
  1508                         UpdateITUTIndicator();
       
  1509 
       
  1510                         if (iFepMan.InputMode() == ELatin)
       
  1511                             {
       
  1512                             iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputCaseMode, 
       
  1513                                                                      iCaseMan.CurrentCase());	
       
  1514                             }
       
  1515 
       
  1516                         if (CurrentFepInputUI())
       
  1517                         	{
       
  1518                         	CurrentFepInputUI()->SetMode(iFepMan.InputMode(), ETrue, EFalse);	
       
  1519                         	}
       
  1520                         }
       
  1521                     }    
       
  1522                 if ( !iFepMan.IsSupportsSecretText() )
       
  1523                     {
       
  1524                     SyncFepAwareText( EPluginSyncUpdatedText );  
       
  1525                     }
       
  1526                 else
       
  1527                 	{
       
  1528                 	if (iCurrentPluginInputFepUI)
       
  1529                 		{
       
  1530                 		iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputCaseMode, 
       
  1531                                                              iCaseMan.CurrentCase());	
       
  1532                 		}
       
  1533                 	}
       
  1534                 }
       
  1535             }
       
  1536             break;
       
  1537         case EKeyCBA1:
       
  1538             {
       
  1539             }
       
  1540             break;
       
  1541         case EKeyCBA2:
       
  1542             {
       
  1543             }
       
  1544             break;
       
  1545         case EPtiKeyStar:
       
  1546             {
       
  1547 			if (PluginInputMode() != EPluginInputModeNone )
       
  1548                 {
       
  1549                 SyncFepAwareText( EPluginSyncUpdatedText );
       
  1550                 }
       
  1551             break;
       
  1552             }
       
  1553         case EPtiKey0: //fall through
       
  1554         case EPtiKey1:
       
  1555         case EPtiKey2:
       
  1556         case EPtiKey3:
       
  1557         case EPtiKey4:
       
  1558         case EPtiKey5:
       
  1559         case EPtiKey6:
       
  1560         case EPtiKey7:
       
  1561         case EPtiKey8:
       
  1562         case EPtiKey9:
       
  1563             {
       
  1564             if (PluginInputMode() != EPluginInputModeNone )
       
  1565                 {
       
  1566                 SyncFepAwareText( EPluginSyncUpdatedText );
       
  1567                 }
       
  1568             }
       
  1569             break;
       
  1570         case EKeyDownArrow:
       
  1571         case EKeyUpArrow:
       
  1572         case EKeyLeftArrow:
       
  1573         case EKeyRightArrow:
       
  1574             {
       
  1575             SyncFepAwareText();
       
  1576             }
       
  1577             break;
       
  1578         /*    
       
  1579         case EKeyLeftArrow:
       
  1580             {
       
  1581            
       
  1582             if ( !iFepMan.IsMfneEditor() &&
       
  1583                  ( PluginInputMode() == EPluginInputModeItut || 
       
  1584                    PluginInputMode() == EPluginInputModeFSQ ) &&
       
  1585                  iCurSelPre.Length() > 0)
       
  1586                 {
       
  1587                 MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor(); 
       
  1588                 if(iCurSelPre.iCursorPos > 0)
       
  1589                     {
       
  1590                     TInt pos = iCurSelPre.iCursorPos - 1;
       
  1591                     edit->SetCursorSelectionForFepL
       
  1592                         ( TCursorSelection( pos, iCurSelPre.iAnchorPos ) );
       
  1593 					iCaseMan.UpdateCase(ENullNaviEvent);
       
  1594                     }
       
  1595                 else  if(iCurSelPre.iCursorPos == 0)
       
  1596                     {
       
  1597                     edit->SetCursorSelectionForFepL
       
  1598                         ( TCursorSelection( iCurSelPre.iCursorPos, iCurSelPre.iAnchorPos ) );
       
  1599                     }
       
  1600                 }
       
  1601             SyncFepAwareText();
       
  1602             }
       
  1603             break;
       
  1604         case EKeyRightArrow:
       
  1605             {
       
  1606             MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor();
       
  1607             if ( !iFepMan.IsMfneEditor() &&
       
  1608                  ( PluginInputMode() == EPluginInputModeItut || 
       
  1609                    PluginInputMode() == EPluginInputModeFSQ ) &&
       
  1610                  iCurSelPre.Length() > 0)
       
  1611                 {          
       
  1612                 if(iCurSelPre.iCursorPos < edit->DocumentLengthForFep())
       
  1613                     {
       
  1614                     TInt pos = iCurSelPre.iCursorPos + 1;
       
  1615                     edit->SetCursorSelectionForFepL
       
  1616                         ( TCursorSelection( pos, iCurSelPre.iAnchorPos ) );
       
  1617 					iCaseMan.UpdateCase(ENullNaviEvent);
       
  1618                     }
       
  1619                 else if(iCurSelPre.iCursorPos == edit->DocumentLengthForFep())
       
  1620                     {
       
  1621                     edit->SetCursorSelectionForFepL
       
  1622                         ( TCursorSelection( iCurSelPre.iCursorPos, iCurSelPre.iAnchorPos ) );
       
  1623                     }  
       
  1624                 }
       
  1625             SyncFepAwareText();
       
  1626             }
       
  1627             break;
       
  1628             */ 
       
  1629         case EKeyBackspace:
       
  1630             {
       
  1631             }
       
  1632             break;
       
  1633         case EKeyOK:
       
  1634             {
       
  1635             ClosePluginInputUiL( ETrue );
       
  1636             }
       
  1637             break;
       
  1638         case EKeyEscape:
       
  1639             {
       
  1640 			ClosePluginInputUiL( ETrue );
       
  1641             DestroySpellEditor();
       
  1642             }
       
  1643             break;
       
  1644        }
       
  1645     }
       
  1646     
       
  1647 // ---------------------------------------------------------------------------
       
  1648 // CAknFepPluginManager::InitMenuPaneL
       
  1649 // (other items were commented in a header)
       
  1650 // ---------------------------------------------------------------------------
       
  1651 //     
       
  1652 void CAknFepPluginManager::InitMenuPaneL( CAknEdwinState* aEditorState, 
       
  1653     CAknFepUiInterfaceMenuPane* aMenuPane, TInt aResourceId )
       
  1654     {
       
  1655     //CAknEdwinState* remeberedEditorState = iFepMan.RememberedEditorState();
       
  1656 
       
  1657     if(aResourceId == R_AVKON_TOUCH_TOUCHINPUT_MENU )
       
  1658         {
       
  1659         if (aEditorState && aEditorState->CcpuState())  
       
  1660             {   
       
  1661             if (!aEditorState->CcpuState()->CcpuCanCopy())
       
  1662                 {
       
  1663                 aMenuPane->SetItemDimmed(EEikCmdEditCopy, ETrue);           
       
  1664                 }   
       
  1665                             
       
  1666             if (!aEditorState->CcpuState()->CcpuCanCut())
       
  1667                 {
       
  1668                 aMenuPane->SetItemDimmed(EEikCmdEditCut, ETrue);          
       
  1669                 }               
       
  1670                             
       
  1671             if (!aEditorState->CcpuState()->CcpuCanPaste())         
       
  1672                 {
       
  1673                 aMenuPane->SetItemDimmed(EEikCmdEditPaste, ETrue);             
       
  1674                 }
       
  1675             }
       
  1676         else
       
  1677             {
       
  1678             aMenuPane->SetItemDimmed(EEikCmdEditCopy, ETrue);           
       
  1679             aMenuPane->SetItemDimmed(EEikCmdEditCut, ETrue);          
       
  1680             aMenuPane->SetItemDimmed(EEikCmdEditPaste, ETrue);             
       
  1681             }
       
  1682 
       
  1683        // For training UI
       
  1684        if (!(iPluginInputMode == EPluginInputModeHwr ||
       
  1685              iPluginInputMode == EPluginInputModeFSc ||
       
  1686              iPluginInputMode == EPluginInputModeFingerHwr))
       
  1687             {
       
  1688             aMenuPane->SetItemDimmed(EPenInputCmdSetting, ETrue);    
       
  1689             aMenuPane->SetItemDimmed(EPenInputCmdHwrTraining, ETrue);    
       
  1690             }
       
  1691        else
       
  1692             {
       
  1693             // Mode is HWR or Full scree HWR
       
  1694             // If fep is running in HWR Training, dim "HWR Training" item.
       
  1695             TUid appId = GetCurAppUid();
       
  1696             if ( appId == KUidtruiApp )
       
  1697                 {
       
  1698                 aMenuPane->SetItemDimmed( EPenInputCmdHwrTraining, ETrue );
       
  1699                 }
       
  1700             }
       
  1701        
       
  1702        // For Predictive
       
  1703        if (iPluginInputMode != EPluginInputModeItut)
       
  1704            {
       
  1705            aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbol, ETrue);
       
  1706            aMenuPane->SetItemDimmed(EAknCmdPredictiveTextCascade, ETrue); 
       
  1707            aMenuPane->SetItemDimmed(EAknCmdMultitapPredictiveT9On, ETrue); 
       
  1708            }
       
  1709                    
       
  1710        //For Preview bubble
       
  1711        if (!(iPluginInputMode == EPluginInputModeVkb ||
       
  1712              iPluginInputMode == EPluginInputModeFSQ ||
       
  1713              iPluginInputMode == EPluginInputModeFingerHwr ))
       
  1714            {
       
  1715            if(!(iPluginInputMode == EPluginInputModeItut &&
       
  1716              (iSharedData.InputTextLanguage() == ELangPrcChinese ||
       
  1717              iSharedData.InputTextLanguage() == ELangTaiwanChinese ||
       
  1718              iSharedData.InputTextLanguage() == ELangHongKongChinese )))
       
  1719                {
       
  1720                aMenuPane->SetItemDimmed(EPenInputPreview, ETrue);
       
  1721                }
       
  1722            }
       
  1723             
       
  1724        // for inputmode
       
  1725        if (iPluginInputMode != EPluginInputModeItut)
       
  1726            {
       
  1727             // dim menu items for Chinese input modes that aren't valid in the current editor
       
  1728             // or the device subvariant
       
  1729             for (TInt mode = KFirstMode; mode <= KLastMode; mode = mode << 1)
       
  1730                 {
       
  1731                 iFepMan.DimMenuItem(aMenuPane, mode);
       
  1732                 }
       
  1733            aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);     
       
  1734            aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue); 
       
  1735            aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue); 
       
  1736            
       
  1737            }
       
  1738        else 
       
  1739            {
       
  1740            iFepMan.DimInputmodeMenuItems(aMenuPane);
       
  1741            if (iFepMan.IsChineseInputLanguage())
       
  1742                 {
       
  1743                 DimAllModeAndCase(aMenuPane);   
       
  1744                 }
       
  1745            }
       
  1746        if (iFepMan.IsAbleToLaunchSmiley()) 
       
  1747            {
       
  1748            TInt indexForSmiley;
       
  1749            if (aMenuPane->MenuItemExists(EAknCmdEditInsertSmiley, 
       
  1750                    indexForSmiley))
       
  1751                {
       
  1752                aMenuPane->SetItemDimmed(EAknCmdEditInsertSmiley, EFalse);
       
  1753                }
       
  1754            }
       
  1755            
       
  1756         if (iPluginInputMode == EPluginInputModeItut ||
       
  1757             iPluginInputMode == EPluginInputModeVkb ||
       
  1758             iPluginInputMode == EPluginInputModeFSQ )
       
  1759             {
       
  1760             TInt index = 0;     
       
  1761             if (isLanuchSCT && aMenuPane->MenuItemExists(EAknCmdEditInsertSymbol, index))
       
  1762                  {
       
  1763                  aMenuPane->SetItemDimmed(EAknCmdEditInsertSymbol, EFalse);
       
  1764                  }
       
  1765             }
       
  1766         
       
  1767         TBool disableDic = ETrue;
       
  1768         
       
  1769         if ((iPluginInputMode == EPluginInputModeHwr)
       
  1770                 && (iFepMan.IsArabicInputLanguage()))
       
  1771             {
       
  1772             disableDic = EFalse;
       
  1773             }
       
  1774 
       
  1775         TInt dicIndex = 0;
       
  1776         if (aMenuPane->MenuItemExists(
       
  1777                 EPenInputCmdRecognitionWithDictionary, dicIndex))
       
  1778             {
       
  1779             aMenuPane->SetItemDimmed(
       
  1780                     EPenInputCmdRecognitionWithDictionary, disableDic);
       
  1781             }
       
  1782         
       
  1783         // add some input mode in option menu
       
  1784         TBool isSplitView = IsEditorSupportSplitIme();
       
  1785     	if(isSplitView)
       
  1786     	    {
       
  1787     	    TInt disabledMode = iPenInputServer.DisabledLayout();
       
  1788     	    TInt curMode =  iLangMan.CurrentImePlugin()->CurrentMode();
       
  1789     	    if(!(disabledMode & EPluginInputModeFSQ) && curMode != EPluginInputModeFSQ )
       
  1790     	        {
       
  1791     	        aMenuPane->SetItemDimmed(EPeninputCmdFSQ, EFalse);
       
  1792     	        }
       
  1793     	    if(!(disabledMode & EPluginInputModeItut) && curMode != EPluginInputModeItut)
       
  1794     	        {
       
  1795     	        aMenuPane->SetItemDimmed(EPenInputCmdVITUT, EFalse);
       
  1796     	        }
       
  1797 
       
  1798     	    }
       
  1799         
       
  1800         iLangMan.CurrentImePlugin()->DynInitMenuPaneL(aMenuPane);
       
  1801         }
       
  1802         
       
  1803         
       
  1804     }    
       
  1805 
       
  1806 // ---------------------------------------------------------------------------
       
  1807 // CAknFepPluginManager::OnFocusChangedL
       
  1808 // (other items were commented in a header)
       
  1809 // ---------------------------------------------------------------------------
       
  1810 //     
       
  1811 void CAknFepPluginManager::OnFocusChangedL( TBool aGainForeground )
       
  1812     {
       
  1813     if (iLaunchHelp)
       
  1814         {
       
  1815         return;    
       
  1816         }
       
  1817     
       
  1818     if ( iFepMan.StopProcessFocus()  )
       
  1819         {
       
  1820         if (iFepMan.CloseUiOnFocusChange())
       
  1821             {
       
  1822             ClosePluginInputUiL(ETrue);   
       
  1823             }
       
  1824                     
       
  1825         return ;
       
  1826         }
       
  1827 
       
  1828     if(aGainForeground && !iPenInputServer.AutoOpen())
       
  1829         {
       
  1830         ClosePluginInputUiL(ETrue);    
       
  1831         return;	
       
  1832         }
       
  1833 
       
  1834     
       
  1835     TUid appId = GetCurAppUid();
       
  1836     TBool bClose = ETrue;
       
  1837     TBool bOpen = ETrue;
       
  1838     TUid focusAppId = GetFocusAppUid();
       
  1839     
       
  1840     if ( !aGainForeground && appId == focusAppId )
       
  1841         {
       
  1842         return;
       
  1843         }
       
  1844         
       
  1845     if( !iLaunchMenu && IsGlobalNotesApp(focusAppId)) 
       
  1846 
       
  1847         {
       
  1848         if( iPluginInputMode == EPluginInputModeItut ||
       
  1849             iPluginInputMode == EPluginInputModeFSQ ||
       
  1850             iPluginInputMode == EPluginInputModeFingerHwr)
       
  1851             {
       
  1852             bClose = EFalse;
       
  1853             }
       
  1854 
       
  1855         }
       
  1856     iLaunchMenu = EFalse;
       
  1857     
       
  1858     // In globsl notes editor, launching global notes not fep dlg or menu
       
  1859     if(focusAppId.iUid == appId.iUid &&
       
  1860        IsGlobalNotesApp(appId) &&
       
  1861        !iFepMan.IsFepAwareTextEditor())
       
  1862         {
       
  1863         if( iPluginInputMode == EPluginInputModeItut ||
       
  1864             iPluginInputMode == EPluginInputModeFSQ ||
       
  1865             iPluginInputMode == EPluginInputModeFingerHwr)
       
  1866             {
       
  1867              ClosePluginInputUiL(ETrue);
       
  1868              if(iPenInputSvrConnected ) //lost foreground
       
  1869                 {
       
  1870                 iPenInputServer.LoseForeground();
       
  1871                 }
       
  1872                 
       
  1873             return;
       
  1874             }
       
  1875         }
       
  1876     
       
  1877     //global notes editor won't open automatically
       
  1878     /*if(IsGlobalNotesApp(appId) || IsGlobalNotesApp(focusAppId))
       
  1879         {
       
  1880         if(!iPenInputServer.IsDimmed())
       
  1881             bOpen = EFalse;						
       
  1882         }*/
       
  1883 
       
  1884     if ( aGainForeground && iFepMan.FepAwareTextEditor() && IsCurrentWindInOpenList() )
       
  1885         {
       
  1886         if(!iPenInputSvrConnected) 
       
  1887             {
       
  1888             HandleEventsFromFepL(EPluginEditorActivate,0);
       
  1889             }
       
  1890                 
       
  1891         if(!bOpen )
       
  1892             {
       
  1893             return;
       
  1894             }
       
  1895 
       
  1896         if( iInMenu && iCurEditor == iFepMan.FepAwareTextEditor() )
       
  1897             {
       
  1898             ResetMenuState();
       
  1899             InformMfneUiStatusL( EFalse );
       
  1900 			// If need to open setting app automatically, 
       
  1901 			// do not open Touch window again. Fix for ESCN-7NVAWF
       
  1902 			TBool langChange = iCurLanguage != iSharedData.InputTextLanguage();
       
  1903 					
       
  1904 			TryChangePluginInputModeByModeL(
       
  1905 							(TPluginInputMode)iSharedData.PluginInputMode(),
       
  1906 				langChange?EPenInputOpenManually:EPenInputOpenAutomatically,
       
  1907 				ERangeInvalid);            
       
  1908 			return;
       
  1909             }
       
  1910             
       
  1911 //       iPenInputServer.UpdateAppInfo(KNullDesC, EAppIndicatorMsg);  
       
  1912           
       
  1913         //only automatically open when window in the list
       
  1914         
       
  1915         if ( !iFastSwapByMenu )
       
  1916             {  
       
  1917             TBool langChange = iCurLanguage != iSharedData.InputTextLanguage();
       
  1918  //               iPenInputServer.DimUiLayout(EFalse);
       
  1919             TBool enableAdaptiveSearch = EFalse;
       
  1920             if ( iFepMan.IsFindPaneEditor() && iFepMan.IsSupportedAdaptiveSearch() )
       
  1921                 {
       
  1922                 iAvkonRepository->Get( KAknAvkonAdaptiveSearchEnabled, enableAdaptiveSearch );
       
  1923                 if ( enableAdaptiveSearch )
       
  1924                     {
       
  1925                     if(!(iInMenu && ( iPluginInputMode == EPluginInputModeItut ||
       
  1926                                     iPluginInputMode == EPluginInputModeFSQ )))
       
  1927                         {
       
  1928                         ClosePluginInputModeL(ETrue);
       
  1929                         if(iPenInputSvrConnected ) //lost foreground
       
  1930                             {
       
  1931                             iPenInputServer.LoseForeground();
       
  1932                             }                
       
  1933                         }                
       
  1934                     }
       
  1935                 }   
       
  1936             if ( !enableAdaptiveSearch )
       
  1937                 {
       
  1938 			TInt openMode = EPenInputOpenAutomatically;
       
  1939 			TPluginInputMode inputMode = (TPluginInputMode)iSharedData.PluginInputMode();                        
       
  1940 				if ((inputMode == EPluginInputModeFSc || inputMode == EPluginInputModeHwr ||
       
  1941 					 inputMode == EPluginInputModeFingerHwr) &&
       
  1942 				 iFepMan.IsSupportsSecretText())
       
  1943 				{
       
  1944                     openMode = EPenInputOpenManually;
       
  1945                     }
       
  1946                 if(langChange)
       
  1947                     {
       
  1948                     openMode = EPenInputOpenManually;
       
  1949                     }
       
  1950              
       
  1951                 TryChangePluginInputModeByModeL(inputMode, openMode, ERangeInvalid);
       
  1952                 }
       
  1953             }          
       
  1954         iFastSwapByMenu = EFalse;                   
       
  1955         }
       
  1956     else 
       
  1957         {   
       
  1958         TBool enableAdaptiveSearch = EFalse;
       
  1959         
       
  1960         if ( iFepMan.IsFindPaneEditor() && iFepMan.IsSupportedAdaptiveSearch() )
       
  1961             {
       
  1962             iAvkonRepository->Get( KAknAvkonAdaptiveSearchEnabled, enableAdaptiveSearch );
       
  1963             if ( enableAdaptiveSearch )
       
  1964                 {
       
  1965                 if(iInMenu && ( iPluginInputMode == EPluginInputModeItut ||
       
  1966                                 iPluginInputMode == EPluginInputModeFSQ ||
       
  1967                                 iPluginInputMode == EPluginInputModeFingerHwr))
       
  1968                     {                
       
  1969                     //iPenInputServer.DimUiLayout(ETrue); //dim the ui
       
  1970                     return;
       
  1971                     }                
       
  1972                 
       
  1973                 ClosePluginInputModeL(ETrue);
       
  1974                 if(iPenInputSvrConnected ) //lost foreground
       
  1975                     {
       
  1976                     iPenInputServer.LoseForeground(); 
       
  1977                     }
       
  1978                 }
       
  1979             }
       
  1980         
       
  1981         if ( !enableAdaptiveSearch )
       
  1982             {
       
  1983             if(iInMenu && ( iPluginInputMode == EPluginInputModeItut ||
       
  1984                             iPluginInputMode == EPluginInputModeFSQ ||
       
  1985                             iPluginInputMode == EPluginInputModeFingerHwr))
       
  1986                 {                
       
  1987                 //iPenInputServer.DimUiLayout(ETrue); //dim the ui
       
  1988                 return;
       
  1989                 }            
       
  1990             
       
  1991             //current control is not any kind of editor
       
  1992             if(bClose)
       
  1993                 {
       
  1994                 ClosePluginInputUiL(ETrue);
       
  1995                 if(iPenInputSvrConnected ) //lost foreground
       
  1996                     {
       
  1997                     iPenInputServer.LoseForeground();
       
  1998                     }
       
  1999                 }
       
  2000             else
       
  2001                 {
       
  2002                 //send dim command
       
  2003                 //global notes app do nothing when lose focus
       
  2004                 if( iPenInputSvrConnected )
       
  2005                     {
       
  2006                     iPenInputServer.SetInternalPopUp(iInMenu);
       
  2007                     iPenInputServer.SetEditorPriority(iEditorPriority);                
       
  2008                     TUid curApp = GetCurAppUid();          
       
  2009                     iPenInputServer.SetGlobalNotes( IsGlobalNotesApp(curApp) && 
       
  2010                                                     !iInGlobleNoteEditor);
       
  2011                     iPenInputServer.DimUiLayout(ETrue);
       
  2012                     }
       
  2013                 }
       
  2014             }
       
  2015         }
       
  2016 
       
  2017     //set touch pane enable/disable
       
  2018     if( iFepMan.FepAwareTextEditor() )
       
  2019         {
       
  2020         iFepMan.UiInterface()->TouchPaneAllowInputMethodActivation(ETrue);
       
  2021         }
       
  2022     else 
       
  2023         {   
       
  2024         iFepMan.UiInterface()->TouchPaneAllowInputMethodActivation(EFalse);
       
  2025         }
       
  2026 
       
  2027     iFepMan.UiInterface()->TouchPaneRefreshL();        
       
  2028     }    
       
  2029 void CAknFepPluginManager::SendIcfDataL(  TPluginSync aSyncType )
       
  2030     {
       
  2031     if( PluginInputMode() == EPluginInputModeNone || 
       
  2032         !iCurrentPluginInputFepUI )
       
  2033         {
       
  2034         return;
       
  2035         }
       
  2036         
       
  2037     MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor();
       
  2038     if ( !edit )
       
  2039         {
       
  2040         if ( IsDimed() )
       
  2041             {
       
  2042             TFepInputContextFieldData icfData;
       
  2043             icfData.iCmd = EPeninputICFInitial;
       
  2044     	    icfData.iText.Set(*iLastEditorContentBuf);
       
  2045     	    icfData.iCurSel = iCurSelPre;
       
  2046     	    if ( iFepMan.IsFlagSet(CAknFepManager::EFlagNoMatches) )
       
  2047                 {
       
  2048                 icfData.iFlag = EFepICFDataInlineNoMatch;
       
  2049                 }
       
  2050             if ( ExistInlineText() ) // inline
       
  2051                 {
       
  2052                 icfData.iStartPos = iFepMan.UncommittedText().LowerPos();
       
  2053                 icfData.iLength = iCurSelPre.iCursorPos - icfData.iStartPos;
       
  2054                 icfData.iMidPos = 0;
       
  2055                 }
       
  2056             iCurrentPluginInputFepUI->HandleCommandL
       
  2057                 (ECmdPenInputSendEditorTextAndCurPos, reinterpret_cast<TInt>(&icfData));
       
  2058             }
       
  2059         return;
       
  2060         }
       
  2061             
       
  2062     if( iDisableSyncText )            
       
  2063         {
       
  2064         iPendingSyncReq = ETrue;
       
  2065         return;
       
  2066         }
       
  2067 
       
  2068     iPendingSyncReq = EFalse;
       
  2069             
       
  2070     TBool enableCursor;
       
  2071     TBool enableSelection;
       
  2072     TFepInputContextFieldData icfData;
       
  2073     
       
  2074     if ( iFepMan.IsFeatureSupportedJapanese()
       
  2075         && EPluginSyncCurSel == aSyncType
       
  2076         && iFepMan.FepAwareTextEditor()->DocumentLengthForFep() > iPreDocumentLengthForFep
       
  2077         && iCurSelCur.iAnchorPos > iPreDocumentLengthForFep ) // add linefeed by Down Key
       
  2078         {
       
  2079         aSyncType = EPluginSyncUpdatedText;
       
  2080         iCurSelPre.iAnchorPos = iPreDocumentLengthForFep;
       
  2081         }    
       
  2082     
       
  2083     edit->GetCursorSelectionForFep( iCurSelCur );
       
  2084     TInt editContentLen = edit->DocumentLengthForFep();	
       
  2085     	
       
  2086     if( iCurSelCur.iCursorPos > editContentLen )
       
  2087     	{
       
  2088     	iCurSelCur.iCursorPos = editContentLen;
       
  2089     	}
       
  2090     if( iCurSelCur.iAnchorPos > editContentLen )
       
  2091     	{
       
  2092     	iCurSelCur.iAnchorPos = editContentLen;
       
  2093     	}
       
  2094     	
       
  2095     // 1. set cursor visiblity
       
  2096     CAknEdwinState* editorState = iFepMan.EditorState();
       
  2097     TBool secretEditor = iFepMan.IsSupportsSecretText();
       
  2098     
       
  2099     if (editorState)
       
  2100         {
       
  2101 		enableCursor = !IsEditorCursorDisabled(); 
       
  2102         enableSelection = IsEditorCursorSelVisible();
       
  2103         }
       
  2104     else // MFNE
       
  2105         {        
       
  2106         enableCursor = (iCurSelCur.Length()==0);
       
  2107         enableSelection = (iCurSelCur.Length()>0);
       
  2108         }
       
  2109     icfData.iCursorVisibility = enableCursor;
       
  2110     icfData.iCursorSelVisible = enableSelection;    
       
  2111  
       
  2112     delete iIcfDataBuf;
       
  2113     iIcfDataBuf = NULL;
       
  2114     
       
  2115     // 2. set cursor xy-position in window
       
  2116     TPoint position(-1,-1);
       
  2117     TInt height = 0;
       
  2118     TInt ascent = 0;
       
  2119     
       
  2120     if( PluginInputMode() == EPluginInputModeFSc )
       
  2121         {
       
  2122         edit->GetScreenCoordinatesForFepL
       
  2123             ( position, height, ascent, iCurSelCur.iCursorPos );
       
  2124         icfData.iRect = TRect( TPoint( position.iX, position.iY-ascent ),
       
  2125                                TPoint( position.iX, position.iY+height-ascent ) );
       
  2126         }
       
  2127     
       
  2128     // 3. set cursor selection
       
  2129     icfData.iCurSel = iCurSelCur;
       
  2130 
       
  2131     // 4. set leading edge flag
       
  2132     icfData.iLeadingEdge = (iFepMan.DocPos().iType == TTmDocPosSpec::ELeading);
       
  2133     
       
  2134     // 5. set icf direction 
       
  2135     if ( iFepMan.IsMfneEditor() )
       
  2136         {
       
  2137         icfData.iFlag = EFepICFDataDirectionMFNE;
       
  2138         }
       
  2139     else
       
  2140         {
       
  2141         if ( TBidiText::ScriptDirectionality
       
  2142             ( TLanguage( iFepMan.InputLanguageCapabilities().iInputLanguageCode ) ) ==
       
  2143             TBidiText::ELeftToRight )
       
  2144             {
       
  2145             icfData.iFlag = EFepICFDataDirectionLTR;
       
  2146             }
       
  2147         else
       
  2148             {
       
  2149             icfData.iFlag = EFepICFDataDirectionRTL;
       
  2150             }
       
  2151         }
       
  2152     
       
  2153     // 6. set other icf data info
       
  2154     // get last editor content
       
  2155 	TPtrC lastEditorContent;
       
  2156     if ( !iLastEditorContentBuf )
       
  2157     	{
       
  2158     	lastEditorContent.Set( KNullDesC );
       
  2159     	}
       
  2160     else
       
  2161     	{
       
  2162     	lastEditorContent.Set( iLastEditorContentBuf->Des() );
       
  2163     	}
       
  2164     
       
  2165     // get current editor content	
       
  2166     HBufC* currentEditorContentBuf = HBufC::NewLC( editContentLen );
       
  2167     TPtr16 currentEditorContent = currentEditorContentBuf->Des();
       
  2168 	edit->GetEditorContentForFep( currentEditorContent, 0, editContentLen ); 
       
  2169 	
       
  2170 	TBool send = ETrue;
       
  2171 	
       
  2172 	if ( !SetSyncIcfDataL( icfData, lastEditorContent, currentEditorContent ) )
       
  2173     	{
       
  2174     	send = EFalse;
       
  2175     	}
       
  2176 
       
  2177     if ( send )
       
  2178     	{
       
  2179     	iCurrentPluginInputFepUI->HandleCommandL
       
  2180             (ECmdPenInputSendEditorTextAndCurPos, reinterpret_cast<TInt>(&icfData));
       
  2181     	}
       
  2182     	
       
  2183     if ( secretEditor ) 
       
  2184         { 
       
  2185         TBool cursorDisabled = IsEditorCursorDisabled(); 
       
  2186         iCurrentPluginInputFepUI->HandleCommandL( ECmdPenInputDimArrowKeys, cursorDisabled );        
       
  2187         } 
       
  2188 
       
  2189 
       
  2190     // reset last editor content buffer
       
  2191     delete iLastEditorContentBuf;
       
  2192     iLastEditorContentBuf = currentEditorContentBuf;
       
  2193 	CleanupStack::Pop(); // currentEditorContentBuf
       
  2194 	
       
  2195     iCurSelPre.iCursorPos = iCurSelCur.iCursorPos;
       
  2196     iCurSelPre.iAnchorPos = iCurSelCur.iAnchorPos;
       
  2197     iPreDocumentLengthForFep = editContentLen;
       
  2198     }
       
  2199 
       
  2200 TBool CAknFepPluginManager::SetSyncIcfDataL( TFepInputContextFieldData& aIcfData,
       
  2201                                             const TDesC& aLastEditorContent,
       
  2202                                             const TDesC& aCurrentEditorContent )
       
  2203 	{
       
  2204 	MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor();
       
  2205 	
       
  2206 	    // if content is the same, sync cursor selection only
       
  2207     if ( !iModeChanged && 
       
  2208         aLastEditorContent.Compare( aCurrentEditorContent ) == 0 )
       
  2209     	{
       
  2210         if ( aIcfData.iCurSel.HigherPos() > edit->DocumentLengthForFep() || 
       
  2211          aIcfData.iCurSel.LowerPos() < 0 )
       
  2212             {
       
  2213             return EFalse;
       
  2214             }
       
  2215     	return SetSyncCurSelIcfDataL( aIcfData );    	
       
  2216     	}
       
  2217     		
       
  2218 	if ( TextInlined( aLastEditorContent, aCurrentEditorContent ) ) // inline
       
  2219         {
       
  2220         aIcfData.iCmd = EPeninputICFReplace;
       
  2221         aIcfData.iStartPos = iFepMan.UncommittedText().LowerPos();
       
  2222         aIcfData.iLength = iCurSelPre.HigherPos() - aIcfData.iStartPos;
       
  2223         TInt readLen = iFepMan.UncommittedText().Length();
       
  2224         iIcfDataBuf = HBufC::NewL( readLen );
       
  2225         TPtr16 icfDes = iIcfDataBuf->Des();
       
  2226         edit->GetEditorContentForFep( icfDes, aIcfData.iStartPos, readLen ); 
       
  2227         if ( iFepMan.IsFlagSet(CAknFepManager::EFlagNoMatches) )
       
  2228             {
       
  2229             aIcfData.iFlag = EFepICFDataInlineNoMatch;
       
  2230             }
       
  2231         aIcfData.iText.Set(icfDes);
       
  2232         
       
  2233     	if ( EnableITIOnFSQ() )
       
  2234     	    {
       
  2235     	    TInt tailLength = 0;
       
  2236     	    iFepMan.PtiEngine()->HandleCommandL
       
  2237     	             ( EPtiCommandGetAutoCompletionTailLength, &tailLength );
       
  2238     	    if ( tailLength > 0 )
       
  2239     	        {
       
  2240     	        aIcfData.iMidPos = tailLength;
       
  2241     	        }
       
  2242             else
       
  2243                 {
       
  2244                 aIcfData.iMidPos = 0;
       
  2245                 }
       
  2246     	    }    	
       
  2247         else
       
  2248             {
       
  2249             aIcfData.iMidPos = 0;
       
  2250             }
       
  2251 
       
  2252         aIcfData.iCursorVisibility = EFalse;
       
  2253         aIcfData.iCursorSelVisible = EFalse;
       
  2254         }
       
  2255     else if ( TextInserted( aLastEditorContent, aCurrentEditorContent ) ) // insert
       
  2256         {
       
  2257         aIcfData.iCmd = EPeninputICFReplace;
       
  2258         aIcfData.iStartPos = iCurSelPre.LowerPos();
       
  2259         aIcfData.iLength = iCurSelPre.Length();
       
  2260         aIcfData.iMidPos = -1;
       
  2261         TInt readLen = iCurSelCur.iCursorPos - iCurSelPre.LowerPos();
       
  2262         iIcfDataBuf = HBufC::NewL( readLen );
       
  2263         TPtr16 icfDes = iIcfDataBuf->Des();
       
  2264         edit->GetEditorContentForFep( icfDes, aIcfData.iStartPos, readLen );
       
  2265         aIcfData.iText.Set(icfDes);
       
  2266         }
       
  2267     else if ( TextDeleted( aLastEditorContent, aCurrentEditorContent ) ) // delete
       
  2268         {
       
  2269         aIcfData.iCmd = EPeninputICFDelete;
       
  2270         aIcfData.iStartPos = iCurSelCur.iCursorPos;
       
  2271         aIcfData.iLength = aLastEditorContent.Length() - aCurrentEditorContent.Length();
       
  2272         aIcfData.iMidPos = -1;
       
  2273         aIcfData.iText.Set(KNullDesC);
       
  2274         }
       
  2275     else if ( !iModeChanged && iFepMan.IsFeatureSupportedJapanese()
       
  2276         && (iFepMan.FepAwareTextEditor()->DocumentLengthForFep() < iPreDocumentLengthForFep
       
  2277             || iFepMan.FepAwareTextEditor()->DocumentLengthForFep() == iPreDocumentLengthForFep 
       
  2278             && iCurSelCur.iCursorPos > 0)
       
  2279         && iCurSelCur.iCursorPos == iCurSelPre.iCursorPos
       
  2280         && iCurSelCur.iAnchorPos == iCurSelPre.iAnchorPos )
       
  2281         {
       
  2282         if ( iFepMan.FepAwareTextEditor()->DocumentLengthForFep() < iPreDocumentLengthForFep ) // Delete Right
       
  2283             {
       
  2284             aIcfData.iCmd = EPeninputICFDelete;
       
  2285             aIcfData.iStartPos = iCurSelCur.iCursorPos;
       
  2286             aIcfData.iLength = iPreDocumentLengthForFep - 
       
  2287                                iFepMan.FepAwareTextEditor()->DocumentLengthForFep();
       
  2288             aIcfData.iMidPos = -1;
       
  2289             aIcfData.iText.Set(KNullDesC);
       
  2290             }
       
  2291         else  // Replace
       
  2292             {
       
  2293             TInt repLen = (iCurSelCur.iCursorPos > 1)? 2:1;
       
  2294             iIcfDataBuf = HBufC::NewL( repLen );
       
  2295             TPtr16 icfDes = iIcfDataBuf->Des();
       
  2296             iFepMan.FepAwareTextEditor()->GetEditorContentForFep( icfDes, 
       
  2297                                                                   iCurSelCur.iCursorPos - repLen, 
       
  2298                                                                   repLen );
       
  2299             if (2 == repLen && icfDes[0] == KVkbParagraphSeparator)
       
  2300                 {
       
  2301                 repLen = 1;
       
  2302                 icfDes.Delete(0,1);
       
  2303                 }
       
  2304             aIcfData.iCmd = EPeninputICFReplace;
       
  2305             aIcfData.iStartPos = iCurSelCur.iCursorPos - repLen;
       
  2306             aIcfData.iLength = repLen;
       
  2307             aIcfData.iMidPos = -1;
       
  2308             aIcfData.iText.Set(icfDes);
       
  2309             }
       
  2310         }
       
  2311     else if ( TextMultiTapped( aLastEditorContent, aCurrentEditorContent ) )// multitap
       
  2312         {
       
  2313         aIcfData.iCmd = EPeninputICFReplace;
       
  2314         aIcfData.iStartPos = iCurSelCur.iCursorPos - 1;
       
  2315         aIcfData.iLength = 1;
       
  2316         aIcfData.iMidPos = -1;
       
  2317         iIcfDataBuf = HBufC::NewL( aIcfData.iLength );
       
  2318         TPtr16 icfDes = iIcfDataBuf->Des();
       
  2319         edit->GetEditorContentForFep( icfDes, aIcfData.iStartPos, aIcfData.iLength );
       
  2320         aIcfData.iText.Set(icfDes);
       
  2321         }
       
  2322     else
       
  2323         {
       
  2324         aIcfData.iCmd = EPeninputICFInitial;
       
  2325 	    aIcfData.iStartPos = 0;
       
  2326 	    aIcfData.iLength = edit->DocumentLengthForFep();
       
  2327 	    aIcfData.iMidPos = -1;
       
  2328 	    iIcfDataBuf = HBufC::NewL( aIcfData.iLength );
       
  2329 	    TPtr16 icfDes = iIcfDataBuf->Des();
       
  2330 	    edit->GetEditorContentForFep( icfDes, 0, aIcfData.iLength );
       
  2331 	    aIcfData.iText.Set(icfDes);
       
  2332         }
       
  2333     if ( aIcfData.iStartPos > edit->DocumentLengthForFep() || aIcfData.iStartPos < 0 )
       
  2334         {
       
  2335         return EFalse;
       
  2336         }
       
  2337     return ETrue;
       
  2338 	}
       
  2339 	
       
  2340 TBool CAknFepPluginManager::SetSyncCurSelIcfDataL( TFepInputContextFieldData& aIcfData )
       
  2341 	{
       
  2342 	MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor();
       
  2343 	if ( ExistInlineText() ) // inline
       
  2344         {
       
  2345         aIcfData.iCmd = EPeninputICFSetCurSel;
       
  2346         aIcfData.iStartPos = iFepMan.UncommittedText().LowerPos();
       
  2347         aIcfData.iLength = iCurSelPre.iCursorPos - aIcfData.iStartPos;
       
  2348         TInt readLen = iFepMan.UncommittedText().Length();
       
  2349         iIcfDataBuf = HBufC::NewL( readLen );
       
  2350         TPtr16 icfDes = iIcfDataBuf->Des();
       
  2351         edit->GetEditorContentForFep( icfDes, aIcfData.iStartPos, readLen ); 
       
  2352         if ( iFepMan.IsFlagSet(CAknFepManager::EFlagNoMatches) )
       
  2353             {
       
  2354             aIcfData.iFlag = EFepICFDataInlineNoMatch;
       
  2355             }
       
  2356         aIcfData.iText.Set(icfDes);
       
  2357         
       
  2358     	if ( EnableITIOnFSQ() )
       
  2359     	    {
       
  2360     	    TInt tailLength = 0;
       
  2361     	    iFepMan.PtiEngine()->HandleCommandL
       
  2362     	             ( EPtiCommandGetAutoCompletionTailLength, &tailLength );
       
  2363     	    if ( tailLength > 0 )
       
  2364     	        {
       
  2365     	        aIcfData.iMidPos = tailLength;
       
  2366     	        }
       
  2367     	    else
       
  2368     	        {
       
  2369     	        aIcfData.iMidPos = 0;
       
  2370     	        }
       
  2371     	    }
       
  2372         else
       
  2373             {
       
  2374             aIcfData.iMidPos = 0;
       
  2375             }
       
  2376 
       
  2377         aIcfData.iCursorVisibility = EFalse;
       
  2378         aIcfData.iCursorSelVisible = EFalse;
       
  2379         }
       
  2380     else
       
  2381         {
       
  2382         // update curosr pos
       
  2383         aIcfData.iCmd = EPeninputICFSetCurSel;
       
  2384         aIcfData.iStartPos = iCurSelCur.iCursorPos;
       
  2385         aIcfData.iMidPos = -1;
       
  2386         aIcfData.iText.Set(KNullDesC);
       
  2387         }
       
  2388         
       
  2389     iInlineStateOn = ( aIcfData.iMidPos == 0 );
       
  2390 	
       
  2391     return ETrue;
       
  2392 	}   
       
  2393 
       
  2394 TBool CAknFepPluginManager::TextInlined( const TDesC& aLastEditorContent, 
       
  2395                                          const TDesC& aCurrentEditorContent)
       
  2396 	{
       
  2397 	if ( iModeChanged )
       
  2398 		{
       
  2399 		return EFalse;
       
  2400 		}
       
  2401 		
       
  2402 	return ( ExistInlineText()  && 
       
  2403            aLastEditorContent.Left(iFepMan.UncommittedText().LowerPos()).Compare(
       
  2404                    aCurrentEditorContent.Left(iFepMan.UncommittedText().LowerPos()) ) == 0 && 
       
  2405            aLastEditorContent.Mid(iCurSelPre.HigherPos()).Compare(
       
  2406                    aCurrentEditorContent.Mid(iCurSelCur.iCursorPos) ) == 0 );
       
  2407 	}
       
  2408 
       
  2409 TBool CAknFepPluginManager::TextInserted( const TDesC& aLastEditorContent, 
       
  2410                                           const TDesC& aCurrentEditorContent)
       
  2411 	{
       
  2412 	if ( iModeChanged )
       
  2413 		{
       
  2414 		return EFalse;
       
  2415 		}
       
  2416 	
       
  2417 	return ( iCurSelCur.LowerPos() > iCurSelPre.LowerPos() && 
       
  2418            aLastEditorContent.Left(iCurSelPre.LowerPos()).Compare(
       
  2419                  aCurrentEditorContent.Left(iCurSelPre.LowerPos()) ) == 0 && 
       
  2420            aLastEditorContent.Mid(iCurSelPre.HigherPos()).Compare(
       
  2421                  aCurrentEditorContent.Mid(iCurSelCur.iCursorPos) ) == 0);	
       
  2422 	}
       
  2423 	
       
  2424 TBool CAknFepPluginManager::TextDeleted( const TDesC& aLastEditorContent, 
       
  2425                                          const TDesC& aCurrentEditorContent)
       
  2426 	{
       
  2427 	if ( iModeChanged )
       
  2428 		{
       
  2429 		return EFalse;
       
  2430 		}
       
  2431 	
       
  2432     if ( aLastEditorContent.Length() < aCurrentEditorContent.Length() )
       
  2433         {
       
  2434         return EFalse;
       
  2435         } 
       
  2436 	
       
  2437 	TPtrC curRightContent = aCurrentEditorContent.Mid(iCurSelCur.iCursorPos);
       
  2438 
       
  2439 	TInt pos = aLastEditorContent.Length()-curRightContent.Length();
       
  2440 
       
  2441 	return ( iCurSelCur.HigherPos() <= iCurSelPre.HigherPos() && 
       
  2442            aLastEditorContent.Left(iCurSelCur.iCursorPos).Compare(
       
  2443                aCurrentEditorContent.Left(iCurSelCur.iCursorPos) ) == 0 
       
  2444            && ( pos >= 0) && aLastEditorContent.Mid(pos).Compare(curRightContent ) == 0	);
       
  2445 	}	
       
  2446 	
       
  2447 TBool CAknFepPluginManager::TextMultiTapped( const TDesC& aLastEditorContent, 
       
  2448                                              const TDesC& aCurrentEditorContent)
       
  2449 	{
       
  2450 	if ( iModeChanged )
       
  2451 		{
       
  2452 		return EFalse;
       
  2453 		}
       
  2454 
       
  2455 	MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor();
       
  2456 	
       
  2457 	if ( iCurSelCur.iCursorPos > aLastEditorContent.Length() )
       
  2458 	    {
       
  2459 	    return EFalse;
       
  2460 	    }
       
  2461 	return ( iCurSelCur.iCursorPos > 0 && 
       
  2462         ( iCurSelPre.iCursorPos <= edit->DocumentMaximumLengthForFep() 
       
  2463               || edit->DocumentMaximumLengthForFep() == 0 ) && 
       
  2464         aLastEditorContent.Left(iCurSelCur.iCursorPos-1).Compare(
       
  2465               aCurrentEditorContent.Left(iCurSelCur.iCursorPos-1) ) == 0 && 
       
  2466         aLastEditorContent.Mid(iCurSelCur.iCursorPos).Compare(
       
  2467               aCurrentEditorContent.Mid(iCurSelCur.iCursorPos) ) == 0);	
       
  2468 	}	
       
  2469 	
       
  2470 // -----------------------------------------------------------------------------
       
  2471 // CAknFepPluginManager::SetCursorSelectionL
       
  2472 // Set editor cursor selection.
       
  2473 // (other items were commented in a header).
       
  2474 // -----------------------------------------------------------------------------
       
  2475 //
       
  2476 void CAknFepPluginManager::SetCursorSelectionL(const TCursorSelection& aCurSel, TBool aSyncCursor)    
       
  2477     {
       
  2478     MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor();
       
  2479     if(edit && 
       
  2480        aCurSel.HigherPos() <= edit->DocumentLengthForFep() && 
       
  2481        aCurSel.LowerPos() >= 0 )
       
  2482         {
       
  2483         if ( ( aCurSel.iCursorPos != iCurSelPre.iCursorPos ) || 
       
  2484             ( aCurSel.iAnchorPos != iCurSelPre.iAnchorPos ) || aSyncCursor)
       
  2485             {
       
  2486             edit->SetCursorSelectionForFepL(aCurSel);
       
  2487             
       
  2488             iFepMan.SynCCPSoftKey();
       
  2489             TCursorSelection curSel; 
       
  2490             edit->GetCursorSelectionForFep( curSel );
       
  2491 
       
  2492             if(curSel.iCursorPos != aCurSel.iCursorPos || 
       
  2493                curSel.iAnchorPos != aCurSel.iAnchorPos )
       
  2494                 {
       
  2495                 iCurSelPre.iCursorPos = aCurSel.iCursorPos;
       
  2496                 iCurSelPre.iAnchorPos = aCurSel.iAnchorPos;
       
  2497                 }
       
  2498 
       
  2499             if ( aSyncCursor || 
       
  2500                 curSel.iCursorPos != aCurSel.iCursorPos || 
       
  2501                 curSel.iAnchorPos != aCurSel.iAnchorPos || 
       
  2502                 curSel.iCursorPos != iCurSelPre.iCursorPos || 
       
  2503                 curSel.iAnchorPos != iCurSelPre.iAnchorPos )
       
  2504                 {
       
  2505 			    iCaseMan.UpdateCase(ENullNaviEvent);			    
       
  2506                 SendIcfDataL();
       
  2507                 }
       
  2508             else
       
  2509                 {
       
  2510                 iCurSelPre.iCursorPos = aCurSel.iCursorPos;
       
  2511                 iCurSelPre.iAnchorPos = aCurSel.iAnchorPos;
       
  2512                 }
       
  2513             }
       
  2514         }
       
  2515     }   
       
  2516  
       
  2517 HBufC*  CAknFepPluginManager::GetNumberKeymapResource(TInt aCaseMode)
       
  2518     {
       
  2519     HBufC* rtn = NULL;
       
  2520     TRAP_IGNORE( rtn = DoGetNumberKeymapResourceL( aCaseMode ));
       
  2521     return rtn;
       
  2522     }
       
  2523     
       
  2524 HBufC*  CAknFepPluginManager::DoGetNumberKeymapResourceL(TInt aCaseMode)
       
  2525     {//the code is borrowed from DoLaunchSctAndPctL
       
  2526     
       
  2527     HBufC* rtn = NULL;
       
  2528     
       
  2529     //first get resource id
       
  2530     TInt currentEditorSCTResId = iFepMan.GetCurrentEditorSCTResId();
       
  2531     
       
  2532     //load from resource
       
  2533     TResourceReader reader;
       
  2534     CCoeEnv* env = CCoeEnv::Static();
       
  2535     env->CreateResourceReaderLC(reader, currentEditorSCTResId);
       
  2536     reader.ReadInt32();//LONG flag
       
  2537     reader.ReadTPtrC();//LTEXT title="";
       
  2538     reader.ReadInt32();//LLINK pages=0;
       
  2539     reader.ReadInt32();//LLINK buttons=0;
       
  2540 
       
  2541     const TInt count = reader.ReadInt16(); //line count
       
  2542     for( TInt i = 0; i < count; ++i )
       
  2543         {
       
  2544         TInt type = reader.ReadInt16();      
       
  2545         if( type == EAknCtSpecialCharacterMap )
       
  2546             {
       
  2547             reader.ReadTPtrC(); //caption
       
  2548             reader.ReadInt16(); //id
       
  2549             reader.ReadInt32(); //flags          
       
  2550             TInt component_count=reader.ReadInt16();
       
  2551             for (TInt ii=0;ii<component_count;ii++)
       
  2552                 {
       
  2553                 TInt component_id=reader.ReadInt16();
       
  2554                 if(component_id == aCaseMode)
       
  2555                     {
       
  2556                     rtn = reader.ReadHBufCL();
       
  2557                     break;
       
  2558                     }
       
  2559                 else
       
  2560                     {
       
  2561                     reader.ReadTPtrC();
       
  2562                     }
       
  2563                 }
       
  2564   
       
  2565             break;
       
  2566             }
       
  2567         else
       
  2568             {
       
  2569             //ignore line
       
  2570             CEikCaptionedControl* line=new(ELeave) CEikCaptionedControl;
       
  2571             CleanupStack::PushL(line);
       
  2572             SEikControlInfo controlInfo=EikControlFactory::CreateByTypeL(type);
       
  2573             if( controlInfo.iControl )
       
  2574                 {
       
  2575                 line->iControl = controlInfo.iControl;
       
  2576                 line->ConstructFromResourceL(reader);
       
  2577                 CleanupStack::PopAndDestroy(line); // line
       
  2578                 }
       
  2579             else
       
  2580                 {
       
  2581                 User::Leave(KErrNotSupported);
       
  2582                 }
       
  2583             }
       
  2584         }
       
  2585 
       
  2586     CleanupStack::PopAndDestroy(); //reader
       
  2587     return rtn;
       
  2588     }
       
  2589                              
       
  2590 // -----------------------------------------------------------------------------
       
  2591 // CAknFepPluginManager::InitializePluginInputL
       
  2592 // Initialize plugin UI
       
  2593 // (other items were commented in a header).
       
  2594 // -----------------------------------------------------------------------------
       
  2595 //
       
  2596 void CAknFepPluginManager::InitializePluginInputL(TInt aOpenMode, TInt aSuggestRange,
       
  2597                                                   TBool aCleanContent)
       
  2598     {
       
  2599     if ( iFepMan.FepManState()!= EAknFepStateUIActive || iClosePluginInputMode )      
       
  2600         {
       
  2601         //Set hardware key board mode
       
  2602         iFepMan.TryCloseUiL();
       
  2603         iClosePluginInputMode = EFalse;
       
  2604         }
       
  2605     
       
  2606     UpdatePredicState();
       
  2607   
       
  2608     NotifyLayoutL( aOpenMode, aSuggestRange, aCleanContent );
       
  2609     
       
  2610 //    iPenInputServer.UpdateAppInfo(KNullDesC, EAppIndicatorMsg);  
       
  2611     
       
  2612     iPluginInputMode =  (TPluginInputMode)iLangMan.CurrentImePlugin()->CurrentMode();   
       
  2613 
       
  2614     //adjust VKB window if data query dialog is displaying
       
  2615     if(IsDisplayDataQuery())
       
  2616         {
       
  2617         RDrawableWindow* focusWin = 
       
  2618                        CCoeEnv::Static()->AppUi()->TopFocusedControl()->DrawableWindow();        
       
  2619         if(!iLastDataQueryWin
       
  2620            || iLastDataQueryWin != focusWin)
       
  2621             {
       
  2622             iDataQueryAlreadyShow = EFalse;
       
  2623             iLastDataQueryWin = focusWin;
       
  2624             }
       
  2625         }
       
  2626     if(IsDisplayDataQuery() && //data query
       
  2627        !iDataQueryAlreadyShow &&  //only adjust once
       
  2628        PluginInputMode() == EPluginInputModeVkb) //only vkb mode 
       
  2629         {
       
  2630         RepositionDataQuery(EFalse);
       
  2631         }
       
  2632 
       
  2633     if ( !NotifyInGlobalNoteEditorL() )
       
  2634     	{
       
  2635     	iCurrentPluginInputFepUI->ActivateUI(); 
       
  2636     	}
       
  2637     
       
  2638     iFepMan.UpdateIndicators();
       
  2639     iCurrentPluginInputFepUI->SetNextFepUI(
       
  2640         iLangMan.GetFepUI(iFepMan.InputMode(), ENoneWidthChar, 
       
  2641         iFepMan.IsPredictive(iFepMan.InputMode())) );    
       
  2642     //SyncFepAwareText( EPluginSyncUpdatedText ); //sync again
       
  2643     iLastSubmitCount = 0;
       
  2644     }
       
  2645 
       
  2646 // -----------------------------------------------------------------------------
       
  2647 // CAknFepPluginManager::LaunchPenInputMenuL
       
  2648 // Launch plugin menu.
       
  2649 // (other items were commented in a header).
       
  2650 // -----------------------------------------------------------------------------
       
  2651 //
       
  2652 void CAknFepPluginManager::LaunchPenInputMenuL(TInt aResourceId, TBool aRemeber)
       
  2653     {
       
  2654     TInt previousModes = iCurPermitModes;
       
  2655     TBool previousSCT  = isLanuchSCT;
       
  2656     TInt inputmode = PluginInputMode();
       
  2657     
       
  2658     if (R_AVKON_PENINPUT_OPTION_MENU_BAR == aResourceId &&
       
  2659         (inputmode == EPluginInputModeItut ||
       
  2660          inputmode == EPluginInputModeVkb ||
       
  2661          inputmode == EPluginInputModeFSQ))
       
  2662         {
       
  2663         isLanuchSCT = EFalse;
       
  2664         iCurPermitModes = iFepMan.PermittedModes(); 
       
  2665         isLanuchSCT = iFepMan.IsAbleToLaunchSCT();  
       
  2666         }
       
  2667     else
       
  2668         {
       
  2669         iCurPermitModes = 0;    
       
  2670         }
       
  2671         
       
  2672     if (aRemeber)
       
  2673         {
       
  2674         iFepMan.RemeberEditorState();   
       
  2675         }
       
  2676     else
       
  2677         {
       
  2678         iCurPermitModes = previousModes;
       
  2679         isLanuchSCT = previousSCT;
       
  2680         }
       
  2681     
       
  2682     iPenInputMenu->ShowL(aResourceId);
       
  2683     }
       
  2684  
       
  2685 // ---------------------------------------------------------------------------
       
  2686 // CAknFepPluginManager::LaunchPenInputLanguageSelectionL
       
  2687 // (other items were commented in a header)
       
  2688 // ---------------------------------------------------------------------------
       
  2689 //     
       
  2690 void CAknFepPluginManager::LaunchPenInputLanguageSelectionL( TBool aLaunchedByTouchWin )
       
  2691     {
       
  2692     //record langauge
       
  2693     TInt oldLang = iSharedData.InputTextLanguage();
       
  2694     CPenInputGSInterface*  setting = CPenInputGSInterface::NewL();
       
  2695     CleanupStack::PushL(setting);
       
  2696     iFepMan.SetCancelPopupInQwerty( aLaunchedByTouchWin );
       
  2697     setting->ShowInputLanguagePageL();
       
  2698     iFepMan.SetCancelPopupInQwerty( EFalse );
       
  2699     CleanupStack::PopAndDestroy(setting); 
       
  2700     TInt inputLanguage = iSharedData.InputTextLanguage();
       
  2701     if( oldLang != inputLanguage)
       
  2702         {
       
  2703         iSharedData.SetInputTextLanguage(inputLanguage);
       
  2704         iFepMan.ChangeInputLanguageL(inputLanguage);
       
  2705         iFepMan.SetFlag( CAknFepManager::EFlagNewSharedDataInputLanguage 
       
  2706             | CAknFepManager::EFlagNewSharedDataInputMode );
       
  2707 
       
  2708         }
       
  2709     }        
       
  2710 
       
  2711 // ---------------------------------------------------------------------------
       
  2712 // CAknFepPluginManager::LaunchPenInputRecognitionWithDictionarySelectionL
       
  2713 // (other items were commented in a header)
       
  2714 // ---------------------------------------------------------------------------
       
  2715 //     
       
  2716 void CAknFepPluginManager::LaunchPenInputRecognitionWithDictionarySelectionL()
       
  2717     {
       
  2718     //record langauge
       
  2719     CPenInputGSInterface*  setting = CPenInputGSInterface::NewL();
       
  2720     CleanupStack::PushL(setting);
       
  2721     setting->ShowRecognitionWithDictionaryL();
       
  2722     CleanupStack::PopAndDestroy(setting); 
       
  2723     TInt inputLanguage = iSharedData.InputTextLanguage();
       
  2724     }  
       
  2725 
       
  2726 // ---------------------------------------------------------------------------
       
  2727 // CAknFepPluginManager::LaunchPenInputSettingL
       
  2728 // (other items were commented in a header)
       
  2729 // ---------------------------------------------------------------------------
       
  2730 // 
       
  2731 void CAknFepPluginManager::LaunchPenInputSettingL()
       
  2732     {
       
  2733     //record langauge
       
  2734     TInt oldLang = iSharedData.InputTextLanguage();
       
  2735     if ( !iGsInterface )
       
  2736         {
       
  2737         iGsInterface = CPenInputGSInterface::NewL();
       
  2738         }    
       
  2739     iGsInterface->ShowMainViewL();
       
  2740     TInt inputLanguage = iSharedData.InputTextLanguage();
       
  2741     if( oldLang != inputLanguage)
       
  2742         {
       
  2743         iFepMan.ChangeInputLanguageL(inputLanguage);
       
  2744         }
       
  2745 
       
  2746     }     
       
  2747 
       
  2748 // -----------------------------------------------------------------------------
       
  2749 // CAknFepManager::ParseInputContextContent
       
  2750 // Parse editor text passed to plugin ICF
       
  2751 // (other items were commented in a header).
       
  2752 // -----------------------------------------------------------------------------
       
  2753 //
       
  2754 void CAknFepPluginManager::ParseInputContextContent(TDes& aBuffer, TInt aCurrent,
       
  2755                                               TInt& aFrom, TInt& aTo)
       
  2756     {
       
  2757     TInt maxLen = aBuffer.Length();
       
  2758     TInt i;
       
  2759     //find from
       
  2760     for( i = aCurrent - 1; i >=0; i--)
       
  2761         {
       
  2762         if( aBuffer[i] == KVkbTabulator)
       
  2763             {
       
  2764             // tabulator found, replace it with a space
       
  2765             aBuffer.Replace(i, 1, KVkbTabChar);
       
  2766             }
       
  2767         else if(aBuffer[i] == KVkbParagraphSeparator)
       
  2768             {
       
  2769             break;
       
  2770             }
       
  2771         }
       
  2772         
       
  2773     aFrom = i + 1;
       
  2774     
       
  2775     for(i = aCurrent; i < maxLen; i++)
       
  2776         {
       
  2777         if( aBuffer[i] == KVkbTabulator)
       
  2778             {
       
  2779             // tabulator found, replace it with a space
       
  2780             aBuffer.Replace(i, 1, KVkbTabChar);
       
  2781             }
       
  2782         else if(aBuffer[i] == KVkbParagraphSeparator)
       
  2783             {
       
  2784             break;
       
  2785             }
       
  2786         }
       
  2787         
       
  2788     aTo = i;
       
  2789     }
       
  2790 
       
  2791 // ---------------------------------------------------------------------------
       
  2792 // CAknFepPluginManager::SubmitUiPluginTextL
       
  2793 // (other items were commented in a header)
       
  2794 // ---------------------------------------------------------------------------
       
  2795 // 
       
  2796 void CAknFepPluginManager::SubmitUiPluginTextL(const TDesC& aData, 
       
  2797 											   TSimulateEventMode aForcedMode)
       
  2798     {    
       
  2799     iDisableSyncText = ETrue;
       
  2800     // a flag to decide if to simulate space or enter key event in number only editor
       
  2801     // if is asked, simulate these keys anyway.
       
  2802     TBool disableSpaceEnterFlag = EFalse ;
       
  2803     
       
  2804     if ( iFepMan.PermittedModes() == EAknEditorNumericInputMode )
       
  2805         {
       
  2806         CAknEdwinState* editorState = iFepMan.EditorState();
       
  2807         
       
  2808         if ( !editorState )
       
  2809             {
       
  2810             disableSpaceEnterFlag = !iFepMan.IsMfneEditor();
       
  2811             }
       
  2812         else
       
  2813             {
       
  2814             disableSpaceEnterFlag = 
       
  2815                      !(editorState->Flags() & EAknEditorFlagDeliverVirtualKeyEventsToApplication);
       
  2816             }
       
  2817         }
       
  2818 
       
  2819     CCoeEnv* env = CCoeEnv::Static();
       
  2820     MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor(); 
       
  2821         /*
       
  2822         TBool noSimulate = !iFepMan.IsMfneEditor() && iCurSelPre.Length() > 0 &&
       
  2823             ( PluginInputMode() == EPluginInputModeItut || PluginInputMode() == EPluginInputModeFSQ );
       
  2824         */   
       
  2825         for(int i = 0; i < aData.Length(); ++i)
       
  2826             {
       
  2827             TKeyEvent keyEvent = {aData[i], EStdKeyNull, 0, 0};
       
  2828             
       
  2829             /*
       
  2830             if ( noSimulate )
       
  2831                 {
       
  2832                 if (keyEvent.iCode == EKeyLeftArrow )
       
  2833                     {
       
  2834                     if(iCurSelPre.iCursorPos > 0)
       
  2835                         {
       
  2836                         TInt pos = iCurSelPre.iCursorPos - 1;
       
  2837                         edit->SetCursorSelectionForFepL
       
  2838                             ( TCursorSelection( pos, iCurSelPre.iAnchorPos ) );
       
  2839                         }
       
  2840                     else  if(iCurSelPre.iCursorPos == 0)
       
  2841                         {
       
  2842                         edit->SetCursorSelectionForFepL
       
  2843                             ( TCursorSelection( iCurSelPre.iCursorPos, iCurSelPre.iAnchorPos ) );
       
  2844                         }
       
  2845                     SendIcfDataL();
       
  2846                     continue;
       
  2847                     }
       
  2848                 else if (keyEvent.iCode == EKeyRightArrow )
       
  2849                     {                   
       
  2850                     if(iCurSelPre.iCursorPos < edit->DocumentLengthForFep())
       
  2851                         {
       
  2852                         TInt pos = iCurSelPre.iCursorPos + 1;
       
  2853                         edit->SetCursorSelectionForFepL
       
  2854                             ( TCursorSelection( pos, iCurSelPre.iAnchorPos ) );
       
  2855                         }
       
  2856                     else if(iCurSelPre.iCursorPos == edit->DocumentLengthForFep())
       
  2857                         {
       
  2858                         edit->SetCursorSelectionForFepL
       
  2859                             ( TCursorSelection( iCurSelPre.iCursorPos, iCurSelPre.iAnchorPos ) );
       
  2860                         }  
       
  2861                     SendIcfDataL();
       
  2862                     continue;
       
  2863                     }    
       
  2864                 }
       
  2865             */        
       
  2866             
       
  2867 		    if (keyEvent.iCode == EKeyLeftArrow && iHasSWEventCap)
       
  2868                 {
       
  2869                 TRawEvent eventDown; 
       
  2870                 eventDown.Set( TRawEvent::EKeyDown, EStdKeyLeftArrow); 
       
  2871                 eventDown.SetTip( ETrue );
       
  2872                 static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi())->DisableNextKeySound( EStdKeyLeftArrow ); 
       
  2873                 CCoeEnv::Static()->WsSession().SimulateRawEvent( eventDown ); 
       
  2874 
       
  2875                 TRawEvent eventUp; 
       
  2876                 eventUp.Set( TRawEvent::EKeyUp, 14); 
       
  2877                 eventUp.SetTip( ETrue );
       
  2878                 CCoeEnv::Static()->WsSession().SimulateRawEvent( eventUp ); 
       
  2879                 }
       
  2880                 
       
  2881 		    else if (keyEvent.iCode == EKeyRightArrow && iHasSWEventCap)
       
  2882                 {
       
  2883                 TRawEvent eventDown; 
       
  2884                 eventDown.Set( TRawEvent::EKeyDown, EStdKeyRightArrow); 
       
  2885                 eventDown.SetTip( ETrue );
       
  2886                 static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi())->DisableNextKeySound( EStdKeyRightArrow ); 
       
  2887                 CCoeEnv::Static()->WsSession().SimulateRawEvent( eventDown ); 
       
  2888 
       
  2889                 TRawEvent eventUp; 
       
  2890                 eventUp.Set( TRawEvent::EKeyUp, EStdKeyRightArrow); 
       
  2891                 eventUp.SetTip( ETrue );
       
  2892                 CCoeEnv::Static()->WsSession().SimulateRawEvent( eventUp ); 
       
  2893                 }
       
  2894             
       
  2895             
       
  2896             else if ( keyEvent.iCode >= EKeyApplication27 
       
  2897                     || (iFepMan.IsFeatureSupportedJapanese()
       
  2898                          && iFepMan.InputMode() == EHiraganaKanji
       
  2899                          && edit
       
  2900                          && (EPtiKey0 <= keyEvent.iCode && keyEvent.iCode <= EPtiKey9)
       
  2901                        )
       
  2902                     )
       
  2903                 {
       
  2904                 TBuf<1> buf;
       
  2905                 buf.Append( TChar( aData[i] ) );
       
  2906                 iFepMan.SubmitInlineTextL( buf );
       
  2907                 }
       
  2908             else
       
  2909                 {
       
  2910                 if ( ( disableSpaceEnterFlag && 
       
  2911                     ( keyEvent.iCode == EKeySpace || keyEvent.iCode == EKeyEnter ) ) || 
       
  2912                     ( edit && edit->DocumentLengthForFep() <= 0  && 
       
  2913                     ( keyEvent.iCode == EKeyDelete || keyEvent.iCode == EKeyBackspace ) ) )
       
  2914                     {
       
  2915                     iLastSubmitCount--;
       
  2916                     continue;
       
  2917                     }
       
  2918                 if ( keyEvent.iCode == EKeyTab )
       
  2919                     {
       
  2920                     iLastSubmitCount--;
       
  2921                     }
       
  2922                 else if (keyEvent.iCode == EKeySpace)
       
  2923                     {
       
  2924                     keyEvent.iScanCode = EStdKeySpace;
       
  2925                     }
       
  2926                 else if (keyEvent.iCode == EKeyDelete)
       
  2927                     {
       
  2928                     keyEvent.iScanCode = EStdKeyDelete;
       
  2929                     if (iSharedData.ClearDirection() == EClearDirectionLeft)
       
  2930                         {
       
  2931                         keyEvent.iCode = EKeyBackspace;
       
  2932                         keyEvent.iScanCode = EStdKeyBackspace;
       
  2933                         }
       
  2934                     }
       
  2935                 else if (keyEvent.iCode == EKeyBackspace)
       
  2936                     {
       
  2937                     keyEvent.iScanCode = EStdKeyBackspace;
       
  2938                     }
       
  2939                 else if (keyEvent.iCode == EKeyEnter)
       
  2940                     {
       
  2941                     keyEvent.iScanCode = EStdKeyEnter;
       
  2942                     }
       
  2943                 else if ( EnableITIOnFSQ() )
       
  2944                     {
       
  2945                     // For addtion of ITI features on FSQ
       
  2946                     // If FSQ is opened with ITI enabled,
       
  2947                     // Must get scan code from keymapping, EStdKeyNull won't be handled by ITI engine. 
       
  2948                     keyEvent.iScanCode = GetScanCodeFromHwKeymapping( aData[i] );
       
  2949                     }
       
  2950                 // For converter
       
  2951                 // If inputting through VKB or HWR, the event can be done only when aType is equal to EEventKey.
       
  2952                 // Besides, only when inputting the dot in VKB or HWR, aKeyEvent.iScanCode is equal to decimalChar.
       
  2953                 CAknEdwinState* editorState = iFepMan.EditorState();
       
  2954                 TLocale locale;
       
  2955                 if(editorState && 
       
  2956                   (editorState->NumericKeymap() == EAknEditorConverterNumberModeKeymap ||
       
  2957                     editorState->NumericKeymap() == EAknEditorCalculatorNumberModeKeymap) &&
       
  2958                     keyEvent.iCode == locale.DecimalSeparator() )
       
  2959                     {
       
  2960                     keyEvent.iScanCode = locale.DecimalSeparator();
       
  2961                     }
       
  2962 
       
  2963                 // The keycode is a non-standard keyboard character
       
  2964                 keyEvent.iModifiers |= EModifierSpecial;
       
  2965                 
       
  2966                 
       
  2967                 if (keyEvent.iScanCode == EStdKeyBackspace && 
       
  2968                 	iHasSWEventCap &&
       
  2969                 	aForcedMode != EKeyEvent )
       
  2970                     {
       
  2971                     TRawEvent eventDown; 
       
  2972                     eventDown.Set( TRawEvent::EKeyDown, EStdKeyBackspace); 
       
  2973                     eventDown.SetTip( ETrue );
       
  2974                     static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi())->DisableNextKeySound( 
       
  2975                                                                                 EStdKeyBackspace ); 
       
  2976                     CCoeEnv::Static()->WsSession().SimulateRawEvent( eventDown ); 
       
  2977                     
       
  2978                     TRawEvent eventUp; 
       
  2979                     eventUp.Set( TRawEvent::EKeyUp, EStdKeyBackspace); 
       
  2980                     eventUp.SetTip( ETrue );
       
  2981                     CCoeEnv::Static()->WsSession().SimulateRawEvent( eventUp ); 
       
  2982                     }
       
  2983                 else if ( keyEvent.iScanCode == EStdKeyEnter && iHasSWEventCap )
       
  2984                     {
       
  2985                     TRawEvent eventDown; 
       
  2986                     eventDown.Set( TRawEvent::EKeyDown, EStdKeyEnter ); 
       
  2987                     iAvkonAppUi->DisableNextKeySound( EStdKeyEnter ); 
       
  2988                     CCoeEnv::Static()->WsSession().SimulateRawEvent( eventDown ); 
       
  2989                     
       
  2990                     TRawEvent eventUp; 
       
  2991                     eventUp.Set( TRawEvent::EKeyUp, EStdKeyEnter ); 
       
  2992                     CCoeEnv::Static()->WsSession().SimulateRawEvent( eventUp );                 	
       
  2993                     }
       
  2994                 else if ( EnableITIOnFSQ() )
       
  2995                     {
       
  2996                     // For addition of ITI features on FSQ.
       
  2997                     // If FSQ is opened with ITI enabled, ensure keycatcher to handle key events
       
  2998                     // else, remain the old logic.                   
       
  2999                     if ( IsITISupportedKey( keyEvent ) )
       
  3000                         {                            
       
  3001                         // check if need to change current text case
       
  3002                         TPtiTextCase textCase = 
       
  3003                         CaseForMappedCharacter( TChar( keyEvent.iCode ) );                                                        
       
  3004 						if ( !IsDeadKeyCode( keyEvent.iCode ) && IsNeedToChangeTextCase( textCase ) )
       
  3005                             {
       
  3006                             iFepMan.PtiEngine()->SetCase( textCase );
       
  3007                             }                        
       
  3008                         env->SimulateKeyEventL(keyEvent, EEventKey);
       
  3009                         }
       
  3010                     else if ( keyEvent.iScanCode == EStdKeyBackspace 
       
  3011                               || keyEvent.iScanCode == EStdKeyEnter
       
  3012                               || keyEvent.iScanCode == EStdKeySpace )
       
  3013                         {
       
  3014                         // For these keys, clear the flag to make sure ptiengine handle this key.                            
       
  3015                         env->SimulateKeyEventL(keyEvent, EEventKey);
       
  3016                         }
       
  3017                     else
       
  3018                         {
       
  3019                         // When FSQ opened with ITI features enabled, 
       
  3020                         // but key is not supported by ITI
       
  3021                         // commit inline if necessary
       
  3022                         if ( iFepMan.UncommittedText().Length() > 0 )
       
  3023                             {                                
       
  3024                             iFepMan.CommitInlineEditL();
       
  3025                             iFepMan.PtiEngine()->CommitCurrentWord();
       
  3026                             }                            
       
  3027                         // set flag to ensure not to be handled by key catcher.
       
  3028                         iFepMan.SetFlag(CAknFepManager::EFlagPassNextKey);
       
  3029                         env->SimulateKeyEventL(keyEvent, EEventKey);
       
  3030                 		iFepMan.ClearFlag(CAknFepManager::EFlagPassNextKey);
       
  3031                         }
       
  3032                     }
       
  3033                 else
       
  3034                 	{
       
  3035                 	// keep the old logic is not affected
       
  3036                     iFepMan.SetFlag(CAknFepManager::EFlagPassNextKey);
       
  3037                 	env->SimulateKeyEventL(keyEvent, EEventKey);
       
  3038                 	iFepMan.ClearFlag(CAknFepManager::EFlagPassNextKey);
       
  3039                 	}                    
       
  3040                 }
       
  3041             }  
       
  3042     
       
  3043     //fix defect             
       
  3044     if( edit )
       
  3045         {
       
  3046         env->ForEachFepObserverCall(FepObserverHandleCompletionOfTransactionL);
       
  3047         }
       
  3048     iSyncWithPluginRange = ETrue;
       
  3049     iCaseMan.UpdateCase(ENullNaviEvent);
       
  3050     iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputCaseMode, iCaseMan.CurrentCase());
       
  3051     iSyncWithPluginRange = EFalse;
       
  3052     
       
  3053     iDisableSyncText = EFalse;
       
  3054     if( iPendingSyncReq )
       
  3055         {
       
  3056         SendIcfDataL( EPluginSyncAll );
       
  3057         }
       
  3058     }    
       
  3059 
       
  3060 // -----------------------------------------------------------------------------
       
  3061 // CAknFepPluginManager::OnPenInputServerKeyEventL
       
  3062 // Handle key event sent from pen input server
       
  3063 // (other items were commented in a header).
       
  3064 // -----------------------------------------------------------------------------
       
  3065 //
       
  3066 void CAknFepPluginManager::OnPenInputServerKeyEventL(const TDesC& aData)
       
  3067     {
       
  3068     
       
  3069     iFepMan.PtiEngine()->CancelTimerActivity();
       
  3070     
       
  3071     if( aData.Length() <= 0 )
       
  3072         {
       
  3073         return;
       
  3074         }
       
  3075  
       
  3076     if ( iFepMan.IsFepAwareTextEditor() )
       
  3077         {
       
  3078         CAknEdwinState* editorState = iFepMan.EditorState();
       
  3079         TBool sendFlag =  editorState && 
       
  3080             (editorState->Flags() & EAknEditorFlagDeliverVirtualKeyEventsToApplication);
       
  3081             
       
  3082         TInt maxEdSize = iFepMan.FepAwareTextEditor()->
       
  3083             DocumentMaximumLengthForFep();
       
  3084         if ( maxEdSize == 0  )
       
  3085             {
       
  3086             iLastSubmitCount = aData.Length();
       
  3087             SubmitUiPluginTextL(aData);
       
  3088             }
       
  3089         else
       
  3090             {
       
  3091             TCursorSelection currentSelection;
       
  3092             iFepMan.FepAwareTextEditor()->GetCursorSelectionForFep(currentSelection);
       
  3093             TInt freeSpaceOfEditor = maxEdSize - 
       
  3094                 iFepMan.FepAwareTextEditor()->DocumentLengthForFep() +
       
  3095                 currentSelection.Length(); 
       
  3096                 
       
  3097             if ( freeSpaceOfEditor >= 0 )
       
  3098                 {
       
  3099                 if ( ( aData.Length() <= freeSpaceOfEditor ) ||
       
  3100                     ( ( aData.Length()-1 == freeSpaceOfEditor ) && 
       
  3101                       (( aData[aData.Length()-1] == EKeyBackspace ) ||
       
  3102                       	 (aData[aData.Length()-1] == EKeyEnter )  ||
       
  3103                          (aData[aData.Length()-1] == EKeyLeftArrow )  ||
       
  3104                          (aData[aData.Length()-1] == EKeyRightArrow ) ) ))
       
  3105                     {
       
  3106                     iLastSubmitCount = aData.Length();
       
  3107                     }
       
  3108                 else
       
  3109                     {
       
  3110                     iLastSubmitCount = freeSpaceOfEditor;
       
  3111                     }
       
  3112                     
       
  3113                 if ( sendFlag )
       
  3114                     {
       
  3115                     SubmitUiPluginTextL(aData);
       
  3116                     }
       
  3117                 else
       
  3118                     {
       
  3119                     TPtrC charbuf = aData.Left(iLastSubmitCount);
       
  3120                     SubmitUiPluginTextL(charbuf);
       
  3121                     }
       
  3122                     
       
  3123                 if (freeSpaceOfEditor == 0 || iLastSubmitCount == freeSpaceOfEditor)
       
  3124                 	{
       
  3125                 	HasNoFreeSpace();	
       
  3126                 	}
       
  3127                     
       
  3128                 }
       
  3129             else
       
  3130                 {
       
  3131                 iLastSubmitCount = 0;
       
  3132                 if ( sendFlag )
       
  3133                     {
       
  3134                     SubmitUiPluginTextL(aData);
       
  3135                     }
       
  3136                 }
       
  3137             }
       
  3138         }
       
  3139     else
       
  3140         {
       
  3141         SubmitUiPluginTextL(aData);
       
  3142         }
       
  3143     }
       
  3144 
       
  3145 // ---------------------------------------------------------------------------
       
  3146 // CAknFepPluginManager::SyncIndicatorWithPluginRangeL
       
  3147 // (other items were commented in a header)
       
  3148 // ---------------------------------------------------------------------------
       
  3149 //     
       
  3150 void CAknFepPluginManager::SyncIndicatorWithPluginRangeL()
       
  3151     {
       
  3152     iSyncWithPluginRange = ETrue;
       
  3153     iPluginNativeRange = EFalse;
       
  3154     TInt newMode = iFepMan.InputMode();
       
  3155     if( iPluginPrimaryRange == ERangeNative )
       
  3156         {
       
  3157         if( !iFepMan.EditorState() )
       
  3158             {
       
  3159             return;
       
  3160             }
       
  3161         TInt defaultInputMode = iFepMan.EditorState()->DefaultInputMode();
       
  3162         if ( iFepMan.IsChineseInputLanguage() )
       
  3163            {
       
  3164            defaultInputMode = iFepMan.InputMode();
       
  3165            }    
       
  3166         const TInt inputLanguage = iSharedData.InputTextLanguage();
       
  3167         
       
  3168         switch(inputLanguage)
       
  3169             {
       
  3170             case ELangPrcChinese:
       
  3171                 if( defaultInputMode != EPinyin &&
       
  3172                     defaultInputMode != EStroke )
       
  3173                     {
       
  3174                     if ( iFepMan.LastChineseInputMode() )
       
  3175                         {
       
  3176                         newMode = iFepMan.LastChineseInputMode();
       
  3177                         }
       
  3178                     else
       
  3179                         {
       
  3180                     newMode = EPinyin;
       
  3181                         }                    
       
  3182                     }
       
  3183                 else
       
  3184                     {
       
  3185                     newMode = defaultInputMode;
       
  3186                     }
       
  3187                 break;
       
  3188             case ELangTaiwanChinese:
       
  3189                 if( defaultInputMode != EZhuyin &&
       
  3190                     defaultInputMode != EStroke )
       
  3191                     {
       
  3192                     if ( iFepMan.LastChineseInputMode() )
       
  3193                         {
       
  3194                         newMode = iFepMan.LastChineseInputMode();
       
  3195                         }
       
  3196                     else
       
  3197                         {
       
  3198                     newMode = EZhuyin;
       
  3199                         }                    
       
  3200                     }
       
  3201                 else
       
  3202                     {
       
  3203                     newMode = defaultInputMode;
       
  3204                     }
       
  3205                 break;
       
  3206             case ELangHongKongChinese:
       
  3207                 if( defaultInputMode != ECangJie &&
       
  3208                     defaultInputMode != EStroke )
       
  3209                     {
       
  3210                     if ( iFepMan.LastChineseInputMode() )
       
  3211                         {
       
  3212                         newMode = iFepMan.LastChineseInputMode();
       
  3213                         }
       
  3214                     else
       
  3215                         {
       
  3216                     newMode = EStroke;
       
  3217                         }
       
  3218                     }
       
  3219                 else
       
  3220                     {
       
  3221                     newMode = defaultInputMode;
       
  3222                     }
       
  3223                 break;
       
  3224             case ELangJapanese:
       
  3225                 {
       
  3226                 newMode = defaultInputMode;
       
  3227                 iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputJapaneseGetModeOfSubRange, (TInt)(&newMode));
       
  3228                 }
       
  3229                 break;
       
  3230             case ELangHindi:
       
  3231                 {
       
  3232                 newMode = EHindi;
       
  3233                 }
       
  3234                 break;
       
  3235             case ELangKorean:
       
  3236                 {
       
  3237                 newMode = EHangul;
       
  3238                 }
       
  3239                 break;
       
  3240             default:
       
  3241                 newMode = ELatin;
       
  3242                 iPluginNativeRange = ETrue;
       
  3243                 break;
       
  3244             }
       
  3245         }
       
  3246     else if( iPluginPrimaryRange == ERangeEnglish ||
       
  3247              iPluginPrimaryRange == ERangeAccent )
       
  3248         {
       
  3249         newMode = ELatin;
       
  3250         }
       
  3251     else if( iPluginPrimaryRange == ERangeNumber )
       
  3252         {
       
  3253         newMode = ENumber;
       
  3254         }
       
  3255     else if ( iPluginPrimaryRange == ERangeNativeNumber )
       
  3256         {
       
  3257         newMode = ENativeNumber;
       
  3258         iPluginNativeRange = ETrue;
       
  3259         }
       
  3260     //else do NOTHING but keep current for other ranges
       
  3261     
       
  3262     if( newMode != iFepMan.InputMode() || 
       
  3263         ( newMode == ELatin || newMode == ENumber ) )
       
  3264         {
       
  3265         iFepMan.TryChangeModeL(newMode);
       
  3266         UpdatePredicState();
       
  3267         //iCaseMan.SetCurrentCase(iCaseMan.CurrentCase());
       
  3268         iCaseMan.UpdateCase(ENullNaviEvent);
       
  3269         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputCaseMode, 
       
  3270                                                  iCaseMan.CurrentCase());
       
  3271         }
       
  3272     
       
  3273     // Addition for ITI features on FSQ    
       
  3274     if ( newMode == ELatin && IsSupportITIOnFSQ() )
       
  3275         {
       
  3276         // When change range back to Latin
       
  3277         // 1. Config fep state again.        
       
  3278         SetItiStateL();
       
  3279         // 2. Restore predict state for FSQ.
       
  3280         RestorePredictStateL();
       
  3281         }    
       
  3282     else
       
  3283     	{
       
  3284     	// 1. Restore predict state for FSQ.
       
  3285     	ResetItiStateL();
       
  3286     	// 2. Update predict state.
       
  3287     	UpdatePredicState();
       
  3288     	}
       
  3289     //Set correct fep ui	
       
  3290     if(IsSupportITIOnFSQ())
       
  3291         {
       
  3292         iCurrentPluginInputFepUI->SetNextFepUI(
       
  3293             iLangMan.GetFepUI(iFepMan.InputMode(), ENoneWidthChar,
       
  3294                 iFepMan.IsPredictive(iFepMan.InputMode())) );  		
       
  3295         }
       
  3296     iSyncWithPluginRange = EFalse;
       
  3297     }        
       
  3298 
       
  3299 // ---------------------------------------------------------------------------
       
  3300 // CAknFepPluginManager::GetCurSuggestMode
       
  3301 // (other items were commented in a header)
       
  3302 // ---------------------------------------------------------------------------
       
  3303 //     
       
  3304 TBool CAknFepPluginManager::GetCurSuggestMode( TPluginInputMode& aSuggestMode )
       
  3305     {
       
  3306     TInt fepDisableLayoouts = 0;
       
  3307     TInt disableLayouts = iPenInputServer.DisabledLayout();
       
  3308 
       
  3309     switch(aSuggestMode)
       
  3310         {
       
  3311 		case EPluginInputModeFingerHwr:
       
  3312         case EPluginInputModeFSc:
       
  3313         case EPluginInputModeHwr:
       
  3314 			{
       
  3315 		    if( iFepMan.IsSupportsSecretText() || 
       
  3316 		    	( ( aSuggestMode == EPluginInputModeFSc || 
       
  3317 		    		aSuggestMode == EPluginInputModeFingerHwr) &&
       
  3318 		    	    iSharedData.InputTextLanguage() != ELangPrcChinese &&
       
  3319                     iSharedData.InputTextLanguage() != ELangTaiwanChinese &&
       
  3320                     iSharedData.InputTextLanguage() != ELangHongKongChinese ))   
       
  3321 				{
       
  3322 				aSuggestMode = EPluginInputModeItut;
       
  3323 				if ((disableLayouts & aSuggestMode))
       
  3324 					{
       
  3325 					aSuggestMode = EPluginInputModeFSQ;
       
  3326 					}
       
  3327 				fepDisableLayoouts |= EPluginInputModeHwr | EPluginInputModeFSc |
       
  3328 				                      EPluginInputModeFingerHwr;
       
  3329 				}
       
  3330 			}
       
  3331 			break;
       
  3332         case EPluginInputModeVkb:
       
  3333             {
       
  3334             }
       
  3335             break;
       
  3336         case EPluginInputModeFSQ:
       
  3337             {
       
  3338             if ((disableLayouts & aSuggestMode))
       
  3339                 {
       
  3340                 aSuggestMode = EPluginInputModeItut;
       
  3341                 }
       
  3342             }
       
  3343             break;
       
  3344         case EPluginInputModeItut:
       
  3345             {
       
  3346             if ((disableLayouts & aSuggestMode))
       
  3347                 {
       
  3348                 aSuggestMode = EPluginInputModeFSQ;
       
  3349                 }
       
  3350             }
       
  3351             break;
       
  3352         default:
       
  3353 			{
       
  3354 			aSuggestMode = EPluginInputModeItut;
       
  3355 			if ((disableLayouts & aSuggestMode))
       
  3356 				{
       
  3357 				aSuggestMode = EPluginInputModeFSQ;
       
  3358 				}
       
  3359 			}
       
  3360             break;
       
  3361         }
       
  3362 
       
  3363      if (disableLayouts == 0)
       
  3364         {
       
  3365         return ETrue;   
       
  3366         }
       
  3367         
       
  3368      disableLayouts |= fepDisableLayoouts;
       
  3369      
       
  3370      // disable all
       
  3371      if (disableLayouts ==  EPluginInputModeAll)
       
  3372         {
       
  3373         return EFalse;     
       
  3374         }         
       
  3375      
       
  3376      if (!(disableLayouts & aSuggestMode))
       
  3377         {
       
  3378         return ETrue;   
       
  3379         }
       
  3380         
       
  3381      TInt testMode = EPluginInputModeHwr;
       
  3382      while ( testMode < EPluginInputModeAll )
       
  3383          {
       
  3384          if (!(testMode & disableLayouts))
       
  3385              {
       
  3386              break;
       
  3387              }
       
  3388          testMode<<=1;
       
  3389          }
       
  3390          
       
  3391      if ((testMode == EPluginInputModeFSc ||
       
  3392           testMode == EPluginInputModeFingerHwr ) && 
       
  3393          iSharedData.InputTextLanguage() != ELangPrcChinese &&
       
  3394          iSharedData.InputTextLanguage() != ELangTaiwanChinese &&
       
  3395          iSharedData.InputTextLanguage() != ELangHongKongChinese )
       
  3396          {
       
  3397          return EFalse;   
       
  3398          }
       
  3399     
       
  3400     aSuggestMode = TPluginInputMode(testMode);
       
  3401         
       
  3402     return ETrue;     
       
  3403     }
       
  3404 
       
  3405 // ---------------------------------------------------------------------------
       
  3406 // CAknFepPluginManager::ConnectServer
       
  3407 // (other items were commented in a header)
       
  3408 // ---------------------------------------------------------------------------
       
  3409 //     
       
  3410 TBool CAknFepPluginManager::ConnectServer()
       
  3411     {
       
  3412     if(!iPenInputSvrConnected)
       
  3413         {
       
  3414         if(!iConnectAo->IsActive())
       
  3415             {
       
  3416             iConnectAo->RequestConnect();
       
  3417             iPenInputServer.ConnectAsyc(iConnectAo->RequestStatus());
       
  3418             }
       
  3419         // vv 
       
  3420         return EFalse;
       
  3421         }
       
  3422 
       
  3423     iPenInputServer.SetForeground(iOpenPenUiFlag);
       
  3424     
       
  3425     return ETrue;
       
  3426     }
       
  3427     
       
  3428 // ---------------------------------------------------------------------------
       
  3429 // CAknFepPluginManager::NotifyLayoutL
       
  3430 // (other items were commented in a header)
       
  3431 // ---------------------------------------------------------------------------
       
  3432 // 
       
  3433 void CAknFepPluginManager::NotifyLayoutL(TInt aOpenMode, TInt aSuggestRange, 
       
  3434                                          TBool aCleanContent)
       
  3435     {
       
  3436     TBool isSecret = EFalse;
       
  3437     if ( iFepMan.IsSupportsSecretText() )
       
  3438         {
       
  3439         isSecret = ETrue;
       
  3440         } 
       
  3441  
       
  3442     CAknEdwinState* editorState = iFepMan.EditorState();// still stay here
       
  3443     
       
  3444     // for MFNE Editor
       
  3445     if( !editorState && iFepMan.InputMode() == ENumber )
       
  3446         {
       
  3447         if( AknTextUtils::NumericEditorDigitType() == EDigitTypeEasternArabicIndic || 
       
  3448             AknTextUtils::NumericEditorDigitType() == EDigitTypeDevanagari ||
       
  3449             AknTextUtils::NumericEditorDigitType() == EDigitTypeArabicIndic )
       
  3450             {
       
  3451             iFepMan.TryChangeModeL( ENativeNumber );
       
  3452             }
       
  3453         else if ( AknTextUtils::NumericEditorDigitType() == EDigitTypeWestern )
       
  3454             {
       
  3455             iFepMan.TryChangeModeL( ENumber );
       
  3456             }
       
  3457         }
       
  3458 
       
  3459     if(editorState && (editorState->Flags() & EAknEditorFlagNumberGrouping))
       
  3460         {
       
  3461         iCurrentPluginInputFepUI->HandleCommandL( ECmdPenInputIsNumberGrouping, 
       
  3462                                               ETrue );
       
  3463         }
       
  3464     else
       
  3465         {
       
  3466         iCurrentPluginInputFepUI->HandleCommandL( ECmdPenInputIsNumberGrouping, 
       
  3467                                               EFalse );
       
  3468         }    
       
  3469                                                                                   
       
  3470     if ( PluginInputMode() == EPluginInputModeItut )
       
  3471         {
       
  3472         // The preview bubble item will be shown in option menu 
       
  3473         // when current language is Chinese
       
  3474         if ( iFepMan.InputLanguageCapabilities().iInputLanguageCode == ELangPrcChinese ||
       
  3475              iFepMan.InputLanguageCapabilities().iInputLanguageCode == ELangTaiwanChinese ||
       
  3476              iFepMan.InputLanguageCapabilities().iInputLanguageCode == ELangHongKongChinese )
       
  3477             {
       
  3478             iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputCharacterPreview, 
       
  3479                    iFepMan.FepShowVkbPreviewStatus());                 
       
  3480             }
       
  3481         
       
  3482         if ( iSharedData.InputTextLanguage() == ELangThai 
       
  3483             && iFepMan.InputMode() == ENativeNumber  )
       
  3484             {
       
  3485             iFepMan.TryChangeModeL( ENumber );
       
  3486             }
       
  3487 
       
  3488         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputPermittedRange,
       
  3489                                          iFepMan.PermittedModes());
       
  3490         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputEditorState, 
       
  3491                                              reinterpret_cast<TInt>( editorState ));
       
  3492         NotifyLayoutKeymappingL();
       
  3493         
       
  3494         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputFingerInputMode,
       
  3495                                                  iFepMan.InputMode());
       
  3496         
       
  3497         TFepSymbolOfHardwareOne symbolInfo = iFepMan.SymbolInfoOfHardKey1();
       
  3498         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputSymbolOfHardKeyOne, reinterpret_cast<TInt>(&symbolInfo));
       
  3499 
       
  3500         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputCaseMode, 
       
  3501                                        iCaseMan.CurrentCase());
       
  3502         
       
  3503         TBool enableIndicatorBtn = iFepMan.GetPermittedEditorMenu(ETrue) > 0? ETrue : EFalse;                                
       
  3504         if (IsDimed() && iResourceChange)
       
  3505             {
       
  3506             enableIndicatorBtn = iEnableIndicatorBtn;   
       
  3507             }
       
  3508         else
       
  3509             {
       
  3510             iEnableIndicatorBtn = enableIndicatorBtn;    
       
  3511             }
       
  3512         
       
  3513 
       
  3514         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputEnableIndicatorButton,
       
  3515                                                  enableIndicatorBtn); 
       
  3516         
       
  3517         if (!iSpellOn)
       
  3518               {
       
  3519             iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputFingerSpelling, 0);
       
  3520               SetPromptText( aCleanContent );     
       
  3521               }
       
  3522         else
       
  3523             {
       
  3524             SetITUTSpellingStateL(ETrue);
       
  3525             iIndicatorImgID = 0;
       
  3526             iIndicatorTextID = 0;
       
  3527             }    
       
  3528         UpdateITUTIndicator();       
       
  3529         }
       
  3530     else
       
  3531         {
       
  3532         DestroySpellEditor();
       
  3533         if (PluginInputMode() == EPluginInputModeFSQ ||
       
  3534             PluginInputMode() == EPluginInputModeVkb ||
       
  3535             PluginInputMode() == EPluginInputModeFingerHwr)
       
  3536             {
       
  3537             iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputCharacterPreview, 
       
  3538                    iFepMan.FepShowVkbPreviewStatus());                 
       
  3539             }
       
  3540       
       
  3541         // for Japanese peninput setting
       
  3542         if (iFepMan.IsFeatureSupportedJapanese())
       
  3543             {
       
  3544             iFepMan.NotifyJapaneseSetting();
       
  3545             }
       
  3546  
       
  3547  		NotifyLayoutKeymappingL();
       
  3548 
       
  3549         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputPermittedRange, 
       
  3550                                                  iFepMan.PermittedModes());        
       
  3551         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputRange, iFepMan.InputMode());
       
  3552 
       
  3553         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputEditorState, 
       
  3554                                                  reinterpret_cast<TInt>( editorState ));
       
  3555 
       
  3556 
       
  3557 		if(aSuggestRange != ERangeInvalid)
       
  3558 			{
       
  3559 			iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputSuggestRange, aSuggestRange);
       
  3560 			}
       
  3561         
       
  3562         //set allow change case
       
  3563         TBool allowChangeCase = editorState && iCaseMan.IsAbleChangeCase();
       
  3564         //disable/enable case change
       
  3565         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputAllowChangeCase, allowChangeCase);
       
  3566         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputPermittedCase, 
       
  3567                                                  iCaseMan.PluginPermittedCases());
       
  3568         }
       
  3569     // moved    
       
  3570 /*    iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputEditorState, 
       
  3571                                              reinterpret_cast<TInt>( editorState ));*/
       
  3572                                              
       
  3573     if ( PluginInputMode() != EPluginInputModeItut )
       
  3574         {
       
  3575          //set current case
       
  3576         iCaseMan.SetCurrentCase(iCaseMan.CurrentCase());
       
  3577         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputCaseMode, 
       
  3578                                            iCaseMan.CurrentCase());
       
  3579         if ( PluginInputMode() == EPluginInputModeFSQ ||
       
  3580              PluginInputMode() == EPluginInputModeFingerHwr)
       
  3581             {
       
  3582             SetPromptText( aCleanContent );
       
  3583             }
       
  3584         }
       
  3585         iCurrentPluginInputFepUI->HandleCommandL( ECmdPenInputEnableSettingBtn, 
       
  3586                                                   IsEnableSettingBtn() );
       
  3587     
       
  3588     if(!IsDimed())
       
  3589         {
       
  3590         // remember previous password state
       
  3591         iIsPassWord = isSecret;
       
  3592         iCurrentPluginInputFepUI->HandleCommandL( ECmdPenInputIsSecretText, 
       
  3593                                                   isSecret );
       
  3594         }
       
  3595     else
       
  3596         {
       
  3597         // Set previous password state when screen is dimed
       
  3598         iCurrentPluginInputFepUI->HandleCommandL( ECmdPenInputIsSecretText, 
       
  3599 												  iIsPassWord );	
       
  3600         }
       
  3601 			
       
  3602     TBool enableArrowBtn = IsDimArrowKeys();
       
  3603 
       
  3604     if (IsDimed() && iResourceChange)
       
  3605         {
       
  3606         enableArrowBtn = iEnableArrowBtn;   
       
  3607         }
       
  3608     else
       
  3609         {
       
  3610         iEnableArrowBtn = enableArrowBtn;    
       
  3611         }                                               
       
  3612                                               
       
  3613                                               
       
  3614     iCurrentPluginInputFepUI->HandleCommandL( ECmdPenInputDimArrowKeys, 
       
  3615                                               enableArrowBtn);    
       
  3616                                                                                         
       
  3617     SetIcfAlignment();
       
  3618     
       
  3619     iModeChanged = ETrue;
       
  3620     SendIcfDataL( EPluginSyncAll );
       
  3621     iModeChanged = EFalse;
       
  3622     
       
  3623     // For addition of ITI features on FSQ, do configuration before opening FSQ,
       
  3624     // so that ITI features can be taken into effect.   
       
  3625     SetItiStateL();	
       
  3626 
       
  3627     if ( ExistInlineText() )
       
  3628         {
       
  3629         SendIcfDataL();
       
  3630         }
       
  3631     
       
  3632     if ( PluginInputMode() != EPluginInputModeItut )
       
  3633         {
       
  3634         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputWindowOpen, aOpenMode);
       
  3635         }
       
  3636     if(PluginInputMode() == EPluginInputModeItut 
       
  3637        || PluginInputMode() == EPluginInputModeFSQ
       
  3638 	   || PluginInputMode() == EPluginInputModeFingerHwr)
       
  3639         {
       
  3640         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputInEditWordQueryDlg, iIsInEditWordQueryDlg);
       
  3641         }    
       
  3642     }
       
  3643 
       
  3644     
       
  3645 // ---------------------------------------------------------------------------
       
  3646 // CAknFepPluginManager::IsEnableModeSwitchBtn
       
  3647 // (other items were commented in a header)
       
  3648 // ---------------------------------------------------------------------------
       
  3649 //     
       
  3650 TBool CAknFepPluginManager::IsEnableModeSwitchBtn()
       
  3651     {
       
  3652     TBool enableInSecret = EFalse;
       
  3653         
       
  3654     if( !iFepMan.IsSupportsSecretText() )
       
  3655         {
       
  3656         TPluginInputMode counterPart = iPluginInputMode == EPluginInputModeVkb ? 
       
  3657                                 EPluginInputModeHwr : EPluginInputModeVkb;
       
  3658         if( iLangMan.IsPluginInputAvaiable(counterPart, 
       
  3659                                       iCurrentPluginInputFepUI->SupportLanguage(iPluginInputMode), 
       
  3660                                       &iPenInputServer)) 
       
  3661             {
       
  3662             enableInSecret = ETrue;
       
  3663             }
       
  3664         }
       
  3665         
       
  3666     return enableInSecret;
       
  3667     }
       
  3668 
       
  3669 // ---------------------------------------------------------------------------
       
  3670 // CAknFepPluginManager::IsEnableSettingBtn
       
  3671 // (other items were commented in a header)
       
  3672 // ---------------------------------------------------------------------------
       
  3673 // 
       
  3674 TBool CAknFepPluginManager::IsEnableSettingBtn()
       
  3675     {
       
  3676     TBool ebable = ETrue;
       
  3677     TInt enalbeInStartup = 0;
       
  3678     RProperty::Get(KPSUidUikon, KUikGlobalNotesAllowed, enalbeInStartup);
       
  3679     ebable = enalbeInStartup;
       
  3680     
       
  3681     if (iInGlobleNoteEditor || 
       
  3682         (iPenInputMenu && iPenInputMenu->IsShowing()))
       
  3683         {
       
  3684         ebable = EFalse;    
       
  3685         }
       
  3686     
       
  3687     return ebable;
       
  3688     }
       
  3689  
       
  3690 // ---------------------------------------------------------------------------
       
  3691 // CAknFepPluginManager::NotifyLayoutKeymappingL
       
  3692 // (other items were commented in a header)
       
  3693 // ---------------------------------------------------------------------------
       
  3694 //    
       
  3695 void CAknFepPluginManager::NotifyLayoutKeymappingL()
       
  3696     {
       
  3697     CAknEdwinState* editorState = iFepMan.EditorState();
       
  3698     if ( editorState )
       
  3699         {
       
  3700         if( ( iFepMan.InputMode() == ENumber || iFepMan.InputMode() == ENativeNumber )&& 
       
  3701             (editorState->Flags() & EAknEditorFlagUseSCTNumericCharmap) &&
       
  3702             iFepMan.IsFepAwareTextEditor() &&
       
  3703             iFepMan.IsAbleToLaunchSCT() )
       
  3704             {
       
  3705             TInt sctChars = EAknSCTNumeric;
       
  3706 
       
  3707             if ( !iFepMan.IsOnlyHalfWidthCharacterPermitted() )
       
  3708                 {
       
  3709                 sctChars = EAknSCTLowerCase;
       
  3710                 }
       
  3711             //read resource from resource
       
  3712             HBufC* keymapRes = GetNumberKeymapResource(sctChars);
       
  3713             if( keymapRes )
       
  3714                 {
       
  3715                 CleanupStack::PushL(keymapRes);
       
  3716                 iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputEditorCustomNumericKeyMap,
       
  3717                                                     reinterpret_cast<TInt>(keymapRes) );
       
  3718                 CleanupStack::PopAndDestroy(keymapRes);
       
  3719                 return;
       
  3720                 }
       
  3721             }
       
  3722         iCurrentPluginInputFepUI->SetNumberModeKeyMappingL(editorState->NumericKeymap() );
       
  3723         }
       
  3724     else
       
  3725         {
       
  3726         TCoeInputCapabilities inputCapabilities = iFepMan.InputCapabilities();
       
  3727 
       
  3728         if( inputCapabilities.SupportsWesternNumericReal() )
       
  3729             {
       
  3730             //read resource from resource
       
  3731             HBufC* keymapRes = HBufC::NewL(2);
       
  3732             TLocale locale;
       
  3733             TChar decimalSep = locale.DecimalSeparator(); 
       
  3734             TChar minusSign ='-'; 
       
  3735 
       
  3736             keymapRes->Des().Append(decimalSep);
       
  3737             keymapRes->Des().Append(minusSign);
       
  3738 
       
  3739             if( keymapRes )
       
  3740                 {
       
  3741                 CleanupStack::PushL(keymapRes);
       
  3742                 iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputEditorCustomNumericKeyMap,
       
  3743                                                     reinterpret_cast<TInt>(keymapRes) );
       
  3744                 CleanupStack::PopAndDestroy(keymapRes);
       
  3745                 return;
       
  3746                 }
       
  3747             }
       
  3748 
       
  3749         iCurrentPluginInputFepUI->SetNumberModeKeyMappingL(EAknEditorPlainNumberModeKeymap);
       
  3750         }
       
  3751     }    
       
  3752 
       
  3753 // ---------------------------------------------------------------------------
       
  3754 // CAknFepPluginManager::IsDisplayDataQuery
       
  3755 // (other items were commented in a header)
       
  3756 // ---------------------------------------------------------------------------
       
  3757 // 
       
  3758 TBool CAknFepPluginManager::IsDisplayDataQuery()
       
  3759     {
       
  3760     return iFepMan.UiInterface()->IsDisplayDataQuery(iFepMan.IsFepAwareTextEditor());
       
  3761     }           
       
  3762 
       
  3763 // ---------------------------------------------------------------------------
       
  3764 // CAknFepPluginManager::RepositionDataQuery
       
  3765 // (other items were commented in a header)
       
  3766 // ---------------------------------------------------------------------------
       
  3767 //     
       
  3768 void CAknFepPluginManager::RepositionDataQuery(TBool aForce)
       
  3769     {
       
  3770     if( !aForce && iDataQueryAlreadyShow )
       
  3771         {
       
  3772         return;
       
  3773         }
       
  3774         
       
  3775     TRect param;
       
  3776     
       
  3777     CEikAppUi* eikAppUi = (CEikAppUi *)CCoeEnv::Static()->AppUi();
       
  3778     
       
  3779     param = TRect(eikAppUi->TopFocusedControl()->PositionRelativeToScreen(),
       
  3780                   eikAppUi->TopFocusedControl()->Size());
       
  3781     
       
  3782     TPixelsTwipsAndRotation size; 
       
  3783     CCoeEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation(size);
       
  3784     
       
  3785     if(size.iPixelSize.iWidth > size.iPixelSize.iHeight )
       
  3786         {
       
  3787         // landscape, retrieve current position
       
  3788         TRect parentRect;
       
  3789         
       
  3790         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, parentRect); 
       
  3791         CCoeControl* ctrl = eikAppUi->TopFocusedControl();
       
  3792         TRect ctrlRect = ctrl->Rect();			
       
  3793         ctrlRect.Move( 0, parentRect.iBr.iY - ctrlRect.iBr.iY );
       
  3794 
       
  3795         param = TRect( ctrlRect.iTl, ctrl->Size() );
       
  3796         //ctrl->SetExtent( ctrlRect.iTl, ctrl->Size() );
       
  3797         }
       
  3798 
       
  3799     TRAP_IGNORE(iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputSetWindowPos, (TInt)&param));
       
  3800     iDataQueryAlreadyShow = ETrue;
       
  3801     }    
       
  3802 
       
  3803 // ---------------------------------------------------------------------------
       
  3804 // CAknFepPluginManager::AdjustDataQueryCallBackL
       
  3805 // (other items were commented in a header)
       
  3806 // ---------------------------------------------------------------------------
       
  3807 // 
       
  3808 TInt CAknFepPluginManager::AdjustDataQueryCallBackL(TAny *aPtr)
       
  3809     {
       
  3810     CAknFepPluginManager* self = static_cast<CAknFepPluginManager*>(aPtr);
       
  3811     self->iAdjustDataQueryTimer->Cancel(); 
       
  3812     if(self->IsDisplayDataQuery() && //data query
       
  3813        self->iPluginInputMode == EPluginInputModeVkb) //only vkb mode 
       
  3814         {
       
  3815         self->RepositionDataQuery(ETrue);
       
  3816         }
       
  3817         
       
  3818     return ETrue;
       
  3819     }        
       
  3820 // -----------------------------------------------------------------------------
       
  3821 // CAknFepPluginManager::FepObserverHandleCompletionOfTransactionL
       
  3822 // Timer procedure for updating cursor.
       
  3823 // (other items were commented in a header).
       
  3824 // -----------------------------------------------------------------------------
       
  3825 //
       
  3826 void CAknFepPluginManager::FepObserverHandleCompletionOfTransactionL(MCoeFepObserver& aFepObserver)
       
  3827     {
       
  3828     aFepObserver.HandleCompletionOfTransactionL();
       
  3829     }
       
  3830 
       
  3831 MAknFepManagerInterface*  CAknFepPluginManager::CurrentFepInputUI()
       
  3832 	{
       
  3833 	if (PluginInputMode() ==  EPluginInputModeItut &&
       
  3834 	    (iFepMan.InputMode() == EPinyin || iFepMan.InputMode() == EZhuyin ||
       
  3835 	    iFepMan.InputMode() == EStroke || iFepMan.InputMode() == ECangJie))
       
  3836 	     
       
  3837 		{
       
  3838 		if (!iFingerItutChineseUI)
       
  3839 		    {
       
  3840 		    TRAP_IGNORE(CreateFingerItutChineseUiL());
       
  3841 		    }
       
  3842 		    
       
  3843 		return iFingerItutChineseUI;
       
  3844 		}
       
  3845 		
       
  3846 	return NULL;
       
  3847 	}
       
  3848 
       
  3849 void CAknFepPluginManager::CreateFingerItutChineseUiL()
       
  3850     {
       
  3851     iFingerItutChineseUI = CAknFepUIManagerFingerItutChinese::NewL(&iFepMan, &iCaseMan, 
       
  3852                                      (TLanguage)iSharedData.InputTextLanguage(), this);
       
  3853     }
       
  3854 
       
  3855 void CAknFepPluginManager::LaunchHwrTrainUiL()
       
  3856     {
       
  3857     _LIT(KPeninputHwrTrainingUI, "z:\\sys\\bin\\trui.exe" );
       
  3858  
       
  3859     RProcess process;
       
  3860     TInt err = process.Create(KPeninputHwrTrainingUI, KNullDesC);
       
  3861     User::LeaveIfError(err);
       
  3862 
       
  3863     process.Resume();
       
  3864     process.Close();
       
  3865     }    
       
  3866     
       
  3867 TBool CAknFepPluginManager::IsVisible()
       
  3868     {
       
  3869     if( iPenInputSvrConnected )
       
  3870         {
       
  3871         return iPenInputServer.IsVisible();
       
  3872         }
       
  3873         
       
  3874     return EFalse;
       
  3875     }
       
  3876     
       
  3877 void CAknFepPluginManager::SetFingerMatchSelectionState(TBool aMatchStateOn)
       
  3878     {
       
  3879     if(!iCurrentPluginInputFepUI)
       
  3880         {
       
  3881         return;
       
  3882         }    
       
  3883     if (aMatchStateOn)
       
  3884         {
       
  3885         TRAP_IGNORE(iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputFingerMatchSelection, 1));
       
  3886         iMatchState = ETrue;
       
  3887         }
       
  3888     else
       
  3889         {
       
  3890         TRAP_IGNORE(iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputFingerMatchSelection, 0));
       
  3891         iMatchState = EFalse;
       
  3892         }
       
  3893     }
       
  3894 
       
  3895 void CAknFepPluginManager::ConvertDigitToDigittype(TDigitType& digittype,TDes& aConvertedNumeral)
       
  3896 	{
       
  3897 	TChar chchar(aConvertedNumeral[0]);
       
  3898 	switch(digittype)
       
  3899     	{
       
  3900     	case EDigitTypeDevanagari:
       
  3901         	{
       
  3902         	chchar = (aConvertedNumeral[0] + KLatinToDevanagariDigitsDelta);
       
  3903 	    	}
       
  3904         	break;	
       
  3905         case EDigitTypeArabicIndic:
       
  3906             {
       
  3907         	chchar = (aConvertedNumeral[0] + KLatinToArabicIndicDigitsDelta);
       
  3908 	        }
       
  3909             break;
       
  3910     	case EDigitTypeEasternArabicIndic:
       
  3911         	{
       
  3912         	chchar = (aConvertedNumeral[0] + KLatinToEasternArabicIndicDigitsDelta);
       
  3913         	}
       
  3914     	}
       
  3915     aConvertedNumeral.Zero();
       
  3916     aConvertedNumeral.Append(chchar);
       
  3917 	}
       
  3918 
       
  3919 void CAknFepPluginManager::GetAllPredictiveCandidate()
       
  3920     {
       
  3921     TRAP_IGNORE(GetAllPredictiveCandidateL());    
       
  3922     }
       
  3923 
       
  3924 void CAknFepPluginManager::GetAllPredictiveCandidateL()
       
  3925     {
       
  3926     CPtiEngine* ptiengine = iFepMan.PtiEngine();
       
  3927     TBuf<1> tempbuf;
       
  3928     ResetCandidateList();
       
  3929 
       
  3930     for (TInt index = 0; index < ptiengine->NumberOfCandidates(); index++)
       
  3931         {
       
  3932         TPtrC newText = ptiengine->NextCandidate();
       
  3933 
       
  3934         if (newText.Length() > 0)
       
  3935             {
       
  3936       		if(newText.Length() == 1)
       
  3937      			{
       
  3938                 TDigitType digittype = iFepMan.LocalDigit();
       
  3939                 TChar chchar(newText[0]);
       
  3940 
       
  3941                 if(chchar.IsDigit() && digittype)
       
  3942                     {
       
  3943                     tempbuf.Zero();
       
  3944                     tempbuf.Append(newText[0]);
       
  3945                     ConvertDigitToDigittype(digittype,tempbuf);
       
  3946 
       
  3947                     HBufC* textBuf = tempbuf.Alloc();
       
  3948 
       
  3949                     CleanupStack::PushL(textBuf);
       
  3950                     iCandidateList.Append(textBuf);
       
  3951                     CleanupStack::Pop(textBuf);
       
  3952 
       
  3953                     continue;
       
  3954                    	}
       
  3955            		}
       
  3956 
       
  3957             HBufC* textBuf = newText.Alloc();
       
  3958                 
       
  3959             CleanupStack::PushL(textBuf);
       
  3960             iCandidateList.Append(textBuf);
       
  3961             CleanupStack::Pop(textBuf);
       
  3962             }
       
  3963         }
       
  3964     }
       
  3965 
       
  3966 void CAknFepPluginManager::ResetCandidateList()
       
  3967     {
       
  3968     iCandidateIndex = 0;
       
  3969     iCandidateList.ResetAndDestroy();
       
  3970     }
       
  3971 
       
  3972 void CAknFepPluginManager::ShowAllCandidates()
       
  3973     {
       
  3974     iSendAllList.iCandidates.Reset();
       
  3975 
       
  3976     GetAllPredictiveCandidate();
       
  3977 
       
  3978     if (!iCandidateList.Count())
       
  3979         return;
       
  3980 
       
  3981     for (TInt i = 0; i < iCandidateList.Count(); i++)
       
  3982         iSendAllList.iCandidates.Append(iCandidateList[i]->Des());
       
  3983 
       
  3984     TRAP_IGNORE(iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputFingerMatchList, 
       
  3985                                                          reinterpret_cast<TInt>(&iSendAllList)));
       
  3986     }
       
  3987 
       
  3988 TBool CAknFepPluginManager::DoNextCandidates()
       
  3989     {
       
  3990     if((iCandidateIndex) * 3 >= iCandidateList.Count())
       
  3991         {
       
  3992         iCandidateIndex = 0;
       
  3993         }
       
  3994         
       
  3995     iCandidateIndex++;           
       
  3996     
       
  3997     int nStartIndex = (iCandidateIndex - 1) * 3;
       
  3998 
       
  3999     
       
  4000     for (TInt index = 0; index < 3; index++, nStartIndex ++)
       
  4001         {
       
  4002         if (nStartIndex < iCandidateList.Count())
       
  4003             {
       
  4004             TPtr16 canDes = iCandidateList[nStartIndex]->Des();
       
  4005             iSendList.iCandidate[index].Set(canDes);
       
  4006             }
       
  4007         else
       
  4008             {
       
  4009             iSendList.iCandidate[index].Set(KNullDesC);
       
  4010             }
       
  4011         }
       
  4012         
       
  4013     
       
  4014     TRAP_IGNORE(iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputFingerMatchList, 
       
  4015                                                          reinterpret_cast<TInt>(&iSendList)));    
       
  4016     
       
  4017     if (iCandidateIndex * 3 >= iCandidateList.Count())
       
  4018         {
       
  4019         return ETrue;
       
  4020         }
       
  4021     
       
  4022     return EFalse;
       
  4023     }
       
  4024     
       
  4025 void CAknFepPluginManager::DoPreviousCandidates()
       
  4026     {
       
  4027     iCandidateIndex--;
       
  4028       
       
  4029     if(iCandidateIndex < 1)
       
  4030         {
       
  4031         iCandidateIndex = iCandidateList.Count() / 3 + 1;
       
  4032         }
       
  4033         
       
  4034     int nStartIndex = (iCandidateIndex -1) * 3;
       
  4035         
       
  4036     for (TInt index = 0; index < 3; index++, nStartIndex ++)
       
  4037         {
       
  4038         if (nStartIndex < iCandidateList.Count())
       
  4039             {
       
  4040             TPtr16 canDes = iCandidateList[nStartIndex]->Des();
       
  4041             iSendList.iCandidate[index].Set(canDes);
       
  4042             }
       
  4043         else
       
  4044             {
       
  4045             iSendList.iCandidate[index].Set(KNullDesC);
       
  4046             }
       
  4047         }
       
  4048         
       
  4049     
       
  4050     TRAP_IGNORE(iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputFingerMatchList, 
       
  4051                                                          reinterpret_cast<TInt>(&iSendList)));    
       
  4052     }
       
  4053     
       
  4054 TBool CAknFepPluginManager::GetIndicatorImgID(const TInt IndicatorUID,TInt &aImage, TInt &aMask)
       
  4055     {
       
  4056     TBool ret = EFalse;
       
  4057     TRAP_IGNORE(ret = GetIndicatorImgIDL(IndicatorUID, aImage, aMask));
       
  4058     return ret;
       
  4059     }
       
  4060 TBool CAknFepPluginManager::GetIndicatorImgIDL(const TInt IndicatorUID,TInt &aImage, TInt &aMask)
       
  4061     {
       
  4062     TBool ret = EFalse;
       
  4063     aImage = 0;
       
  4064     aMask =0;
       
  4065     TResourceReader reader;
       
  4066 
       
  4067     CCoeEnv::Static()->CreateResourceReaderLC(reader,
       
  4068         R_AVKON_NAVI_PANE_EDITOR_INDICATORS );
       
  4069 
       
  4070     TInt indicatorCount = reader.ReadInt16(); // Number of indicators in the INDICATOR_PANE resource.
       
  4071             
       
  4072     for ( TInt ii = 0; ii < indicatorCount; ii++ )
       
  4073         {
       
  4074         TInt foundUid = reader.ReadInt16(); // First is the indicator UID.
       
  4075 
       
  4076         if ( foundUid == IndicatorUID )
       
  4077             {
       
  4078             reader.ReadInt16(); // narrow priority, can be ignored
       
  4079             reader.ReadInt16(); // wide priority, can be ignored
       
  4080 
       
  4081             HBufC* bitmapFile = reader.ReadHBufCL(); // File containing the indicator graphics.
       
  4082             CleanupStack::PushL( bitmapFile );
       
  4083                     
       
  4084             TInt stateCount = reader.ReadInt16(); // Number of indicator states.
       
  4085             TInt state      = reader.ReadInt16(); // First state is used ( can be EAknIndicatorStateOn / EAknIndicatorStateAnimate ).
       
  4086             TInt iconCount  = reader.ReadInt16(); // Number of icons or frames.
       
  4087                     
       
  4088             if ( state == IndicatorUID )
       
  4089                 {
       
  4090     	      // Go through the animation frames.
       
  4091                 for ( TInt j = 0; j < iconCount; j++ )
       
  4092                     {
       
  4093                     // Use the last animation frame
       
  4094                     // in case of animated indicator.
       
  4095                     reader.ReadInt16();
       
  4096                     reader.ReadInt16();
       
  4097                     reader.ReadInt16();
       
  4098                     reader.ReadInt16();
       
  4099                     }
       
  4100                 }
       
  4101 
       
  4102             // These are the correct IDs to be used for
       
  4103             // the indicator.
       
  4104             aImage = reader.ReadInt16();
       
  4105             aMask  = reader.ReadInt16();
       
  4106                     
       
  4107             
       
  4108     	  // CREATE THE INDICATOR ICON WITH THE BITMAP FILE & BITMAP ID INFORMATION HERE
       
  4109 
       
  4110             
       
  4111             CleanupStack::PopAndDestroy( bitmapFile );
       
  4112             ret = ETrue;
       
  4113             break; // icon created
       
  4114             }
       
  4115         else // Not the correct indicator, pass through the INDICATOR resource.
       
  4116             {	 		
       
  4117         	  reader.ReadInt16();
       
  4118         	  reader.ReadInt16();    
       
  4119         	  HBufC* bitmapFile = reader.ReadHBufCL(); // bmp filename
       
  4120         	  delete bitmapFile;
       
  4121         	  bitmapFile = NULL;
       
  4122             TInt numberOfStates = reader.ReadInt16();  // Number of states
       
  4123         	  for ( TInt j = 0; j < numberOfStates; j++ )
       
  4124         	      {
       
  4125         	      reader.ReadInt16(); // State id
       
  4126                 TInt numberOfIcons = reader.ReadInt16();	        	
       
  4127         	      for ( TInt jj = 0; jj < numberOfIcons; jj++ )
       
  4128                     {
       
  4129         		    for ( TInt jjj = CAknIndicatorContainer::ELayoutModeUsual; 
       
  4130                       jjj <= CAknIndicatorContainer::ELayoutModeWide; jjj++ )
       
  4131         	              {
       
  4132         	              reader.ReadInt16(); // bitmap
       
  4133         	              reader.ReadInt16(); // mask
       
  4134         			  }
       
  4135         	          }        	
       
  4136         	      }
       
  4137         	  }
       
  4138         }
       
  4139     
       
  4140     CleanupStack::PopAndDestroy(); // reader
       
  4141 
       
  4142     return ret;  
       
  4143     }     
       
  4144 
       
  4145 void CAknFepPluginManager::UpdateITUTIndicator()    
       
  4146     {
       
  4147     if ( EPluginInputModeItut != PluginInputMode() )
       
  4148         {
       
  4149         return;
       
  4150         }
       
  4151         
       
  4152     TInt indicatorImgID;
       
  4153     TInt indicatorTextID;
       
  4154     
       
  4155     if (iFepMan.GetIndicatorImgID(indicatorImgID, indicatorTextID))   
       
  4156         {
       
  4157         iIndicatorImgID = indicatorImgID;
       
  4158         iIndicatorTextID = indicatorTextID;
       
  4159         }
       
  4160         TInt indImgid = 0;
       
  4161         TInt indMaskid = 0; 
       
  4162 
       
  4163         TInt textImgid = 0;
       
  4164         TInt textMaskid = 0; 
       
  4165 
       
  4166     if (iIndicatorImgID > 0)
       
  4167         {
       
  4168         GetIndicatorImgID(iIndicatorImgID ,indImgid, indMaskid);
       
  4169         }
       
  4170     
       
  4171     if (iIndicatorTextID > 0)
       
  4172         {
       
  4173         GetIndicatorImgID(iIndicatorTextID ,textImgid, textMaskid);
       
  4174         }
       
  4175         
       
  4176     if (iIndicatorImgID != 0 || iIndicatorTextID != 0)
       
  4177         {
       
  4178         TFepIndicatorInfo indicator;
       
  4179         
       
  4180         indicator.iIndicatorImgID = indImgid;
       
  4181         indicator.iIndicatorMaskID = indMaskid;
       
  4182         indicator.iIndicatorTextImgID = textImgid;
       
  4183         indicator.iIndicatorTextMaskID = textMaskid;
       
  4184         TRAP_IGNORE(iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputFingerMatchIndicator, 
       
  4185             reinterpret_cast<TInt>(&indicator)));    
       
  4186         }
       
  4187    }
       
  4188 
       
  4189 void CAknFepPluginManager::SetITUTSpellingStateL(TBool aState)
       
  4190     {
       
  4191     if (aState)
       
  4192         {
       
  4193         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputFingerSpelling, 1);
       
  4194 
       
  4195         HBufC* titleStr = StringLoader::LoadL(R_AKNFEP_PROMPT_TEXT);                          
       
  4196         CleanupStack::PushL(titleStr);
       
  4197 
       
  4198         TFepPromptText promptText;
       
  4199         promptText.iLines = 1;
       
  4200         TPtr16 canDes = titleStr->Des();
       
  4201         promptText.iText.Set(canDes);
       
  4202 
       
  4203         promptText.iCleanContent = EFalse;
       
  4204         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputSetPromptText,
       
  4205             reinterpret_cast<TInt>(&promptText));
       
  4206 
       
  4207         CleanupStack::PopAndDestroy(titleStr);
       
  4208         }
       
  4209     else
       
  4210         {
       
  4211         TPtr offPromot(NULL, 0);
       
  4212         TFepPromptText promptText;
       
  4213         
       
  4214         promptText.iLines = 1;
       
  4215         promptText.iText.Set(offPromot);
       
  4216         promptText.iCleanContent = EFalse;
       
  4217         
       
  4218         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputSetPromptText,
       
  4219             reinterpret_cast<TInt>(&promptText));
       
  4220             
       
  4221         iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputFingerSpelling, 0);
       
  4222         }
       
  4223     }
       
  4224 
       
  4225 void CAknFepPluginManager::DisplaySpellEditor(const TInt aEditorFlag, 
       
  4226                                               const TDesC& aInitText, 
       
  4227                                               TCursorSelection aCurSel)
       
  4228     {
       
  4229     TRAP_IGNORE(DisplaySpellEditorL(aEditorFlag, aInitText, aCurSel));
       
  4230     }
       
  4231 void CAknFepPluginManager::DisplaySpellEditorL(const TInt aEditorFlag, 
       
  4232                                               const TDesC& aInitText, 
       
  4233                                               TCursorSelection aCurSel)
       
  4234     {
       
  4235     TInt editorFlag = 0;
       
  4236     TInt editorCase = 0;
       
  4237     TInt editorSCTResId = 0;
       
  4238     
       
  4239     if (aEditorFlag)
       
  4240 	   { 
       
  4241 	   editorFlag = aEditorFlag;	     
       
  4242 	   }
       
  4243        
       
  4244     editorCase = iCaseMan.CurrentCase();
       
  4245         
       
  4246     if( iFepMan.EditorState()->Flags() & EAknEditorFlagLatinInputModesOnly )
       
  4247         {
       
  4248         editorFlag = editorFlag | EAknEditorFlagLatinInputModesOnly;
       
  4249         }
       
  4250         
       
  4251     if (FeatureManager::FeatureSupported(KFeatureIdJapanese))
       
  4252         {
       
  4253         editorFlag = editorFlag | EAknEditorFlagLatinInputModesOnly;
       
  4254         }
       
  4255     
       
  4256     editorSCTResId = iFepMan.EditorState()->SpecialCharacterTableResourceId();
       
  4257     
       
  4258     if (FeatureManager::FeatureSupported(KFeatureIdChinese))
       
  4259         {
       
  4260         if (!editorSCTResId || editorSCTResId == R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG)
       
  4261             {
       
  4262             editorSCTResId = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_CHINESE;
       
  4263             }
       
  4264         }
       
  4265     else if (!editorSCTResId)
       
  4266         {
       
  4267         editorSCTResId = R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG;
       
  4268         }
       
  4269  
       
  4270     delete iSpell;
       
  4271     iSpell = NULL;
       
  4272     iSpellCba = ESpellCBACancelEmpty;
       
  4273     iSpellOn = ETrue;
       
  4274     iSpell = CAknFepUiSpellContainer::NewL(editorFlag, editorCase, editorSCTResId);
       
  4275    
       
  4276     iSpell->SetInputWinObserver(this);
       
  4277    
       
  4278     iSpell->InputPane()->SetInputWinTextL(&aInitText);
       
  4279     iSpell->InputPane()->InputWin()->SetSelectionL(aCurSel.iCursorPos, aCurSel.iAnchorPos);
       
  4280     AddWinToOpenListL( iSpell->DrawableWindow() );
       
  4281     }    
       
  4282 
       
  4283 void CAknFepPluginManager:: DestroySpellEditor()
       
  4284     {
       
  4285     iSpellOn = EFalse;
       
  4286     iSpellCba = ESpellCBANone;
       
  4287     delete iSpell;
       
  4288     iSpell = NULL;
       
  4289     }
       
  4290 
       
  4291 HBufC*  CAknFepPluginManager::SpellTextInput()
       
  4292     {
       
  4293     HBufC* textInput = NULL;
       
  4294     if (iSpell)
       
  4295         {
       
  4296         TRAP_IGNORE(textInput = iSpell->InputPane()->InputWin()->GetTextInHBufL());
       
  4297         return textInput;    
       
  4298         }
       
  4299     
       
  4300     return NULL;    
       
  4301     }
       
  4302 
       
  4303 void CAknFepPluginManager::HandleEdwinEventL( CEikEdwin* /*aEdwin*/, 
       
  4304                                               TEdwinEvent aEventType )
       
  4305     {
       
  4306     if (aEventType == EEventTextUpdate)
       
  4307         {
       
  4308         TInt textLength = 0;
       
  4309         HBufC* text = SpellTextInput(); 
       
  4310         
       
  4311         if (text)
       
  4312             {
       
  4313             CleanupStack::PushL(text);
       
  4314             textLength = text->Length();
       
  4315             CleanupStack::PopAndDestroy(text); 
       
  4316             }
       
  4317         
       
  4318         if ( textLength == 0 && 
       
  4319             iSpellCba == ESpellCBAOkCancel)
       
  4320             {
       
  4321             iSpellCba = ESpellCBACancelEmpty;
       
  4322             iFepMan.UpdateCbaL(NULL);
       
  4323             }
       
  4324             
       
  4325         if (textLength > 0 && 
       
  4326             iSpellCba == ESpellCBACancelEmpty)
       
  4327             {
       
  4328             iSpellCba = ESpellCBAOkCancel;
       
  4329             iFepMan.UpdateCbaL(NULL);
       
  4330             }
       
  4331         }
       
  4332     }
       
  4333 
       
  4334 TInt CAknFepPluginManager::GetSoftKeyResID()
       
  4335     {
       
  4336     TInt resId = 0;
       
  4337     switch (iSpellCba)
       
  4338         {
       
  4339         case ESpellCBACancelEmpty:
       
  4340             {
       
  4341             resId = R_AKNFEP_SOFTKEYS_FINGER_CANCEL;
       
  4342             }
       
  4343          break;
       
  4344         case ESpellCBAOkCancel:
       
  4345             {
       
  4346             resId = R_AKNFEP_SOFTKEYS_FINGER_OK_CANCEL;
       
  4347             }
       
  4348         case ESpellCBANone:
       
  4349         default:
       
  4350             {
       
  4351             break;
       
  4352             }
       
  4353         }
       
  4354         
       
  4355     return resId;
       
  4356     }
       
  4357 
       
  4358 void CAknFepPluginManager::SetPromptText( TBool aCleanContent )
       
  4359     {
       
  4360     if (IsDimed() && !iResourceChange) 
       
  4361         { 
       
  4362         return;  
       
  4363         } 
       
  4364         
       
  4365     MCoeCaptionRetrieverForFep* capRetrieve = NULL;
       
  4366     if ( iFepMan.FepAwareTextEditor() )
       
  4367         {
       
  4368         capRetrieve = iFepMan.InputCapabilities().CaptionRetrieverForFep();
       
  4369         }
       
  4370     TFepPromptText promptText;
       
  4371     promptText.iLines = 1;
       
  4372     promptText.iCleanContent = aCleanContent;
       
  4373     
       
  4374     if (capRetrieve)
       
  4375         {
       
  4376         TBuf<100> caption;
       
  4377         caption.Zero();
       
  4378         capRetrieve->GetCaptionForFep(caption);
       
  4379         promptText.iText.Set(caption);
       
  4380         iPreCaption.Close();
       
  4381         iPreCaption.Create(caption.Length());
       
  4382         iPreCaption.Append(caption);
       
  4383         }  
       
  4384     else
       
  4385         {
       
  4386         promptText.iText.Set(KNullDesC);
       
  4387         if ( IsDimed() )
       
  4388             {
       
  4389             promptText.iText.Set(iPreCaption);
       
  4390             }
       
  4391 	    else
       
  4392 			{
       
  4393 			iPreCaption.Close();
       
  4394 			}
       
  4395         }    
       
  4396 
       
  4397     TRAP_IGNORE(iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputSetPromptText,
       
  4398                                                          reinterpret_cast<TInt>(&promptText)));        
       
  4399     }
       
  4400 
       
  4401 void CAknFepPluginManager::SetIcfAlignment()
       
  4402     {
       
  4403 	// Modify for bug ELZG-7WZC35 begin
       
  4404     // fix TINA-7HNEKA, spell editor is not really background editor.
       
  4405     //if ( iSpellOn )
       
  4406     //    {
       
  4407     //    return;
       
  4408     //    }
       
  4409 	// Modify for bug ELZG-7WZC35 end
       
  4410     
       
  4411     TUint cap = iFepMan.ExtendedInputCapabilities();
       
  4412 
       
  4413     TInt alignment = EAknEditorAlignNone;
       
  4414 
       
  4415     if (cap & CAknExtendedInputCapabilities::EInputEditorAlignCenter)
       
  4416         {
       
  4417         alignment = EAknEditorAlignCenter;
       
  4418         }
       
  4419     else if (cap & CAknExtendedInputCapabilities::EInputEditorAlignRight)
       
  4420         {
       
  4421         alignment = EAknEditorAlignRight;
       
  4422         }
       
  4423     else if (cap & CAknExtendedInputCapabilities::EInputEditorAlignBidi)
       
  4424         {
       
  4425         alignment = EAknEditorAlignBidi;
       
  4426         }
       
  4427     else if (cap & CAknExtendedInputCapabilities::EInputEditorAlignLeft)
       
  4428         {
       
  4429         alignment = EAknEditorAlignLeft;
       
  4430         }
       
  4431 	// Modify for bug ELZG-7WZC35 begin
       
  4432     else
       
  4433         {
       
  4434         alignment = iAlignment;
       
  4435         }
       
  4436     // Modify for bug ELZG-7WZC35 end
       
  4437 		
       
  4438     TRAP_IGNORE(iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputSetTextAlignment,
       
  4439                                                          alignment));
       
  4440 														 
       
  4441 	// Modify for bug ELZG-7WZC35 begin
       
  4442     iAlignment = alignment;
       
  4443     // Modify for bug ELZG-7WZC35 end
       
  4444     }
       
  4445     
       
  4446 void CAknFepPluginManager::HasNoFreeSpace()
       
  4447 	{
       
  4448     if ( iCurrentPluginInputFepUI &&
       
  4449          EPluginInputModeItut == PluginInputMode() )
       
  4450         {
       
  4451         TRAP_IGNORE(iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputNoFreeSpace));
       
  4452         }		
       
  4453 	}
       
  4454     
       
  4455 // ---------------------------------------------------------------------------
       
  4456 // CAknFepPluginManager::PluginInputMode
       
  4457 // (other items were commented in a header)
       
  4458 // ---------------------------------------------------------------------------
       
  4459 //           
       
  4460 TPluginInputMode CAknFepPluginManager::PluginInputMode()
       
  4461     {
       
  4462     if( iPluginInputMode != EPluginInputModeNone && IsCurrentWindInOpenList() )
       
  4463         {
       
  4464         return iPluginInputMode;            
       
  4465         }
       
  4466 
       
  4467     return EPluginInputModeNone;
       
  4468     }
       
  4469     
       
  4470 void CAknFepPluginManager::AddCurrentWinToOpenListL()
       
  4471     {
       
  4472     AddWinToOpenListL( GetFocusWindow() );
       
  4473     }
       
  4474 
       
  4475 void CAknFepPluginManager::AddWinToOpenListL( RDrawableWindow* aWin)
       
  4476     {
       
  4477     /*if( aWin )
       
  4478         {
       
  4479         iLastFocusedWin = (TInt )aWin;
       
  4480         if( iOpenWindowList.Find( (TInt)aWin ) == KErrNotFound )
       
  4481             {
       
  4482             iOpenWindowList.AppendL( (TInt)aWin );    
       
  4483             }
       
  4484         
       
  4485         }    
       
  4486       */  
       
  4487      if( aWin )
       
  4488         {
       
  4489         iLastFocusedWin = aWin->WsHandle();
       
  4490         if( iOpenWindowList.Find( aWin->WsHandle() ) == KErrNotFound )
       
  4491             {
       
  4492             iOpenWindowList.AppendL( aWin->WsHandle() );    
       
  4493             }
       
  4494         
       
  4495         }    
       
  4496 
       
  4497     }
       
  4498 
       
  4499 void CAknFepPluginManager::RemoveCurrentWinFromOpenList()
       
  4500     {
       
  4501     RDrawableWindow* win = GetFocusWindow();
       
  4502     if( win )
       
  4503         {
       
  4504         TInt index = iOpenWindowList.Find( win->WsHandle() );
       
  4505         if( index !=  KErrNotFound )
       
  4506             {
       
  4507             iOpenWindowList.Remove( index );           
       
  4508             }
       
  4509         }     
       
  4510     }
       
  4511 
       
  4512 void CAknFepPluginManager::RemoveLastFocusedWinFromOpenList()
       
  4513     {
       
  4514     TInt index = iOpenWindowList.Find( iLastFocusedWin );
       
  4515     if( index !=  KErrNotFound )
       
  4516         {
       
  4517         iOpenWindowList.Remove( index );           
       
  4518         }
       
  4519     iLastFocusedWin = 0;
       
  4520 
       
  4521     }
       
  4522 
       
  4523 TBool CAknFepPluginManager::IsCurrentWindInOpenList()
       
  4524     {
       
  4525     // When touch ui is activated, its associated focus window is inserted into iOpenWindowList.
       
  4526     // When focus go back to the associated window, touch ui is activated automatically if the window is iOpenWindowList. 
       
  4527     if ( IsDimed() )
       
  4528         {
       
  4529         return ETrue;
       
  4530         }
       
  4531     RDrawableWindow* win = GetFocusWindow();       
       
  4532     if( win )
       
  4533         {
       
  4534         return iOpenWindowList.Find( win->WsHandle() ) != KErrNotFound;
       
  4535         }
       
  4536     return EFalse;
       
  4537     }
       
  4538 
       
  4539 TBool CAknFepPluginManager::ExistInlineText()
       
  4540 	{
       
  4541 	return ( iFepMan.WesternPredictive() && 
       
  4542         iFepMan.IsFlagSet( CAknFepManager::EFlagInsideInlineEditingTransaction ) && 
       
  4543         !iFepMan.IsFlagSet( CAknFepManager::EFlagInsideMultitapInlineEditingTransaction )&&
       
  4544         iFepMan.UncommittedText().Length() > 0 );
       
  4545 	}
       
  4546 	
       
  4547 void CAknFepPluginManager::UpdateCaseMode()
       
  4548 	{
       
  4549 	if (iPreviousCoseMode != iCaseMan.CurrentCase())
       
  4550 		{
       
  4551 		iPreviousCoseMode =iCaseMan.CurrentCase();
       
  4552 		
       
  4553 		if (EPluginInputModeNone == PluginInputMode())
       
  4554 			{
       
  4555 			return;	
       
  4556 			}
       
  4557 	
       
  4558 		TRAP_IGNORE(iCurrentPluginInputFepUI->HandleCommandL(ECmdPenInputCaseMode, 
       
  4559 		                                                     iCaseMan.CurrentCase()));	
       
  4560 		UpdateITUTIndicator();
       
  4561 		}	
       
  4562 	}
       
  4563 
       
  4564 void CAknFepPluginManager::AdjustDataCase( TDes& aData )
       
  4565 		{
       
  4566 		if( iCaseMan.CurrentCase() == EAknEditorLowerCase  )
       
  4567     		{
       
  4568     		aData.LowerCase();
       
  4569     		}
       
  4570 		else if( iCaseMan.CurrentCase() == EAknEditorUpperCase )
       
  4571     		{
       
  4572             if( iCaseMan.IsInverseCase() )
       
  4573                 {
       
  4574                 iCaseMan.SetInverseCase( EFalse );
       
  4575                 aData.LowerCase();
       
  4576                 return;
       
  4577                 }
       
  4578             for( TInt i = 0; i<aData.Length(); i++ )
       
  4579 	   			{
       
  4580 	   			if ( aData[i] != 0x03C2 ) //fix CSTI-7THJR2, final sigma exists in capslock mode
       
  4581 	   				{
       
  4582 	   				aData.UpperCase();
       
  4583 	   				}
       
  4584     			}
       
  4585     		}
       
  4586 		}
       
  4587 		
       
  4588 TBool CAknFepPluginManager::IsDimArrowKeys()
       
  4589     {
       
  4590     TBool cursorDisabled = IsEditorCursorDisabled(); 
       
  4591     return cursorDisabled || iFepMan.IsFindPaneEditor(); 
       
  4592     }
       
  4593     
       
  4594 void CAknFepPluginManager::DimAllModeAndCase(CAknFepUiInterfaceMenuPane* aMenuPane)
       
  4595     {
       
  4596     aMenuPane->SetItemDimmed(EChinFepCmdModeStroke, ETrue);    
       
  4597     aMenuPane->SetItemDimmed(EChinFepCmdModeZhuyin, ETrue);    
       
  4598     aMenuPane->SetItemDimmed(EChinFepCmdModePinyin, ETrue);    
       
  4599     aMenuPane->SetItemDimmed(EAknCmdEditModeLatinText, ETrue);     
       
  4600     aMenuPane->SetItemDimmed(EChinFepCmdModeLatinUpper, ETrue); 
       
  4601     aMenuPane->SetItemDimmed(EChinFepCmdModeLatinLower, ETrue);         
       
  4602     }
       
  4603     
       
  4604 void CAknFepPluginManager::LaunchHelpL()
       
  4605     {
       
  4606     TCoeHelpContext context;
       
  4607  
       
  4608     switch (PluginInputMode())
       
  4609         {
       
  4610         case EPluginInputModeItut:
       
  4611             {
       
  4612             context.iContext = KVITU_HLP_MAIN_VIEW;    
       
  4613             }
       
  4614         break;
       
  4615 		case EPluginInputModeFingerHwr:
       
  4616         case EPluginInputModeHwr:
       
  4617         case EPluginInputModeFSc:
       
  4618             {
       
  4619             context.iContext = KHWR_HLP_MAIN_VIEW;    
       
  4620             }
       
  4621         break;        
       
  4622         case EPluginInputModeVkb:
       
  4623         case EPluginInputModeFSQ:
       
  4624             {
       
  4625             context.iContext = KVQWERTY_HLP_MAIN_VIEW;    
       
  4626             }
       
  4627         break;        
       
  4628         default:
       
  4629             {
       
  4630             return;   
       
  4631             }
       
  4632         }
       
  4633 
       
  4634     context.iMajor =  KAknfepUID;
       
  4635    
       
  4636     CArrayFixFlat<TCoeHelpContext>* array = new(ELeave)CArrayFixFlat<TCoeHelpContext>(1);
       
  4637     array->AppendL( context );
       
  4638     HlpLauncher::LaunchHelpApplicationL(CCoeEnv::Static()->WsSession(),array);                    
       
  4639     }
       
  4640 
       
  4641 TInt CAknFepPluginManager::RepeatStringFromLeft(const TDesC& aSubmitData, TDes& aEditorData)
       
  4642     {
       
  4643     TInt index = 0;
       
  4644     TInt ret = KErrNotFound;
       
  4645     for (; index < aEditorData.Length(); index++ )
       
  4646         {
       
  4647         //aSubmitData.CompareC( aEditorData.Left(index + 1)) < 0
       
  4648         ret = aSubmitData.Find( aEditorData.Left(index + 1)); 
       
  4649         if ( ret != index )
       
  4650             {            
       
  4651             break;
       
  4652             }
       
  4653 	}
       
  4654     return ( aEditorData.Length() < aSubmitData.Length() ) ? index : 0;
       
  4655     } 
       
  4656       
       
  4657 TBool CAknFepPluginManager::IsGlobleNotes()
       
  4658     {
       
  4659     TUid appId = GetCurAppUid();
       
  4660     TUid focusAppId = GetFocusAppUid();    
       
  4661     
       
  4662     if(IsGlobalNotesApp(appId) || IsGlobalNotesApp(focusAppId))
       
  4663         {
       
  4664         return ETrue;				
       
  4665         }   
       
  4666      
       
  4667      return EFalse;
       
  4668      }
       
  4669     
       
  4670 
       
  4671     								  
       
  4672 void CAknFepPluginManager::SetMenuState(TBool aUpdateEditor)
       
  4673     {
       
  4674     if(!iPenInputSvrConnected ) 
       
  4675         {
       
  4676         return;
       
  4677         }    	
       
  4678 
       
  4679     if (!(PluginInputMode() == EPluginInputModeItut ||
       
  4680         PluginInputMode() == EPluginInputModeFSQ ||
       
  4681         PluginInputMode() == EPluginInputModeFingerHwr))
       
  4682         {
       
  4683         return;
       
  4684         }
       
  4685 
       
  4686     //save current Fep aware editor
       
  4687     if (aUpdateEditor && !iInMenu)
       
  4688         {
       
  4689         if(iFepMan.FepAwareTextEditor())
       
  4690             iCurEditor = iFepMan.FepAwareTextEditor();    
       
  4691         else
       
  4692             iCurEditor = NULL;            
       
  4693         }
       
  4694         
       
  4695     iInMenu = ETrue;
       
  4696 
       
  4697     TUid curApp = GetCurAppUid();
       
  4698     iPenInputServer.SetGlobalNotes( IsGlobalNotesApp(curApp) && 
       
  4699                                     !iInGlobleNoteEditor);
       
  4700     iPenInputServer.SetInternalPopUp(ETrue);
       
  4701     
       
  4702     iPenInputServer.SetEditorPriority(iEditorPriority);
       
  4703     iPenInputServer.DimUiLayout(ETrue); //dim the ui    
       
  4704     }
       
  4705     
       
  4706 void CAknFepPluginManager::ResetMenuState(TBool aUnDim)    
       
  4707     {
       
  4708     if(!iPenInputSvrConnected ) 
       
  4709         {
       
  4710         return;
       
  4711         }    	
       
  4712     	
       
  4713     iInMenu = EFalse;
       
  4714     iCurEditor = NULL;
       
  4715     if (aUnDim)
       
  4716         {
       
  4717         iPenInputServer.SetInternalPopUp(EFalse);
       
  4718         iPenInputServer.DimUiLayout(EFalse);       
       
  4719         }
       
  4720     }
       
  4721     
       
  4722 TBool CAknFepPluginManager::IsDimed()
       
  4723     {
       
  4724     if(!iPenInputSvrConnected ) 
       
  4725         {
       
  4726         return EFalse;
       
  4727         }    
       
  4728     return iPenInputServer.IsDimmed();    
       
  4729     }
       
  4730 void CAknFepPluginManager::HandleiDimGainForeground(TBool aGain)
       
  4731     {
       
  4732     if (aGain)
       
  4733         {
       
  4734         iDimGainForeground = ETrue;
       
  4735         }
       
  4736     else
       
  4737         {
       
  4738         if (iDimGainForeground)
       
  4739             {
       
  4740             TUid focusAppId = GetFocusAppUid();
       
  4741 
       
  4742             if(iInMenu &&
       
  4743                !(focusAppId.iUid == KAknCapServerUid || 
       
  4744                 focusAppId.iUid == KAknNotifySrvUid  ||
       
  4745                 focusAppId.iUid == KAknScreenServerUid ) &&
       
  4746                focusAppId != GetCurAppUid() )
       
  4747                 {
       
  4748                 iDimGainForeground = EFalse;
       
  4749                 if (iPenInputSvrConnected)
       
  4750                     {
       
  4751                     iPenInputServer.SetResourceChange(EFalse);    
       
  4752                     }
       
  4753                 
       
  4754                 TRAP_IGNORE( ClosePluginInputUiL(ETrue) );
       
  4755                 if(iPenInputSvrConnected ) //lost foreground
       
  4756                     {
       
  4757                     iPenInputServer.LoseForeground();
       
  4758                     }  
       
  4759                 iPenInputServer.ClearTouchUI();
       
  4760                 }
       
  4761             }
       
  4762         }
       
  4763     }
       
  4764     
       
  4765 /*
       
  4766 #ifdef RD_TACTILE_FEEDBACK
       
  4767 TBool CAknFepPluginManager::VKBIsOpened()
       
  4768 	{
       
  4769 	return (iPenInputSvrConnected && iPenInputServer.IsVisible() && !iPenInputServer.IsDimmed());
       
  4770 	}
       
  4771 #endif // RD_TACTILE_FEEDBACK	
       
  4772 */
       
  4773     
       
  4774 #ifdef RD_SCALABLE_UI_V2
       
  4775 void CAknFepPluginManager::SetCursorVisibility(TBool aVisibility, TBool aReportPlugin)
       
  4776     {
       
  4777     iCursorVisibility = aVisibility;
       
  4778 
       
  4779     if (aReportPlugin)
       
  4780         {
       
  4781         SyncFepAwareText();
       
  4782         }
       
  4783     }
       
  4784 #endif // RD_SCALABLE_UI_V2
       
  4785 
       
  4786 void CAknFepPluginManager::InformMfneUiStatusL( TBool aOpened )
       
  4787     {
       
  4788     if ( iMfne && iMfneChanged )
       
  4789         {
       
  4790         //make the selection longer than maximum length of current 
       
  4791         //text, so it won't change the behavior of MFNE editor which 
       
  4792         //doesn't support finger touch.
       
  4793         TInt cursor( iMfne->DocumentLengthForFep() + 1 );
       
  4794         TInt anchor( 0 );
       
  4795         if ( aOpened )
       
  4796             {            
       
  4797             anchor = cursor;
       
  4798             }
       
  4799         iMfne->SetCursorSelectionForFepL( 
       
  4800             TCursorSelection( cursor, anchor ) );        
       
  4801         }
       
  4802     if ( !aOpened )
       
  4803         {
       
  4804         iMfne = NULL;
       
  4805         }
       
  4806     }
       
  4807 
       
  4808 void CAknFepPluginManager::UpdatePredicState()
       
  4809     {
       
  4810     if(!iSharedData.QwertyInputMode() && iFepMan.InputMode() == ELatin)
       
  4811         {
       
  4812         if ( iPluginInputMode != EPluginInputModeItut
       
  4813             // Add this condition for addition of ITI features on FSQ
       
  4814             && !IsSupportITIOnFSQ() )
       
  4815             {
       
  4816             if( iSharedData.PredictiveTextOn())
       
  4817                 {
       
  4818                 iFepMan.SetWesternPredictive(EFalse);
       
  4819                 TRAP_IGNORE( iFepMan.TryCloseUiL() );
       
  4820                 iT9UsedBeforePluginInput = ETrue;
       
  4821                 }
       
  4822             }
       
  4823         }  
       
  4824 
       
  4825     if(iSharedData.PredictiveTextAutoCompleteOn()
       
  4826         // Add this condition for addition of ITI features on FSQ
       
  4827        && !IsSupportITIOnFSQ() )
       
  4828         {
       
  4829         iFepMan.SetWesternAutoComplete(EFalse);
       
  4830         iAutoCompBeforePluginInput = ETrue;
       
  4831         iSharedData.ResetPredictiveTextAutoCompleteOn();
       
  4832         }
       
  4833     }
       
  4834     
       
  4835 TBool CAknFepPluginManager::NotifyInGlobalNoteEditorL()
       
  4836 	{
       
  4837 	TUid curAppId = GetCurAppUid();
       
  4838 	iInGlobleNoteEditor = IsGlobalNotesApp(curAppId) ? ETrue:EFalse;
       
  4839 	if (iCurrentPluginInputFepUI)
       
  4840 		{
       
  4841 		iCurrentPluginInputFepUI->HandleCommandL( 
       
  4842 		    ECmdPenInputEnableSettingBtn, !iInGlobleNoteEditor);
       
  4843 		}
       
  4844 		
       
  4845     //if it's in global notes, show it.
       
  4846     if(EPluginInputModeItut == PluginInputMode() ||
       
  4847        EPluginInputModeFSQ == PluginInputMode() )      
       
  4848 		{
       
  4849 		if(iInGlobleNoteEditor && iPenInputSvrConnected)
       
  4850 			{
       
  4851 			iPenInputServer.ActivatePeninputInNotesL();
       
  4852 	        return ETrue;	
       
  4853 			}
       
  4854 		}   
       
  4855     return EFalse;              
       
  4856 	}
       
  4857 	
       
  4858 // ---------------------------------------------------------------------------
       
  4859 // Get the correct indicator for VKB
       
  4860 // ---------------------------------------------------------------------------
       
  4861 //     
       
  4862 TAknEditingState CAknFepPluginManager::VKBIndicatorState
       
  4863                                                 ( TAknEditingState aOldState )
       
  4864     {      
       
  4865     if ( !IsChineseIndicator( aOldState ) ) 
       
  4866         {
       
  4867         return aOldState;
       
  4868         }
       
  4869     TAknEditingState editingState = EStateNone; 
       
  4870     switch ( iSharedData.DefaultOnScreenVKB() )
       
  4871         {
       
  4872         case EPinyin:
       
  4873             {
       
  4874             editingState = EIndicatorStatePinyinPhrase;
       
  4875             break;
       
  4876             }
       
  4877         case EStroke:
       
  4878             {
       
  4879             if ( iSharedData.PenInputLanguage() == ELangPrcChinese )
       
  4880                 {
       
  4881                 editingState = EIndicatorStateStrokePhrase;
       
  4882                 }
       
  4883             else
       
  4884                 {
       
  4885                 editingState = EIndicatorStateStrokeTradPhrase;
       
  4886                 }
       
  4887             break;
       
  4888             }
       
  4889         case EZhuyin:
       
  4890             {            
       
  4891             editingState = EIndicatorStateZhuyinPhrase;
       
  4892             break;
       
  4893             }
       
  4894         case ECangJie:
       
  4895             {            
       
  4896             editingState = EIndicatorStateCangJie;
       
  4897             break;
       
  4898             }
       
  4899         default:
       
  4900             {
       
  4901             editingState = aOldState;
       
  4902             }            
       
  4903         }        
       
  4904     return editingState;
       
  4905     }
       
  4906 
       
  4907 void CAknFepPluginManager::ClosePeninputSetting()
       
  4908     {
       
  4909     if ( iGsInterface )
       
  4910         {
       
  4911         delete iGsInterface;
       
  4912         iGsInterface = NULL;
       
  4913         }
       
  4914     }
       
  4915 
       
  4916 // ---------------------------------------------------------------------------
       
  4917 // Show tooltip on FSQ to show the best guess word shown inline.
       
  4918 // ---------------------------------------------------------------------------
       
  4919 // 
       
  4920 void CAknFepPluginManager::ShowTooltipOnFSQL( TInt aSecondaryIdx )
       
  4921     {
       
  4922     if ( aSecondaryIdx < 0  
       
  4923     		|| !iCurrentPluginInputFepUI 
       
  4924     		|| !EnableITIOnFSQ() 
       
  4925     		|| !( iFepMan.EditorState() )
       
  4926     		|| (iFepMan.EditorState()->Flags() & EAknEditorFlagEnablePartialScreen)
       
  4927     		)
       
  4928         {
       
  4929         iTooltipOpenOnFSQ = EFalse;
       
  4930         return;
       
  4931         }
       
  4932     
       
  4933 	CDesCArray* candidates = new ( ELeave ) CDesCArrayFlat( KDefaultCandidateArraySize );
       
  4934 	CleanupStack::PushL( candidates );
       
  4935 	TInt activeIdx = KErrNotFound;
       
  4936 	iFepMan.GetCandidatesL( *candidates, activeIdx );
       
  4937 	if ( aSecondaryIdx < candidates->Count() )
       
  4938 		{
       
  4939 		TPtrC aText = ( *candidates )[ aSecondaryIdx ];
       
  4940 
       
  4941 	    TFepITITooltipText tooltipText;
       
  4942 	    tooltipText.iDataSize = aText.Size();
       
  4943 	    tooltipText.iText.Set( aText );    
       
  4944 	    TPtrC tooltipTextPtr;
       
  4945 	    tooltipTextPtr.Set( aText );    
       
  4946 	    iCurrentPluginInputFepUI->HandleCommandL( ECmdPenInputPopupTooltip, 
       
  4947 	                                reinterpret_cast<TInt>( &tooltipTextPtr ) );
       
  4948 	    
       
  4949 	    iTooltipOpenOnFSQ = ETrue;		
       
  4950 		}
       
  4951 	else
       
  4952 		{
       
  4953 		iTooltipOpenOnFSQ = EFalse;
       
  4954 		}
       
  4955     
       
  4956     CleanupStack::PopAndDestroy( candidates );
       
  4957     }
       
  4958 
       
  4959 // ---------------------------------------------------------------------------
       
  4960 // Hide tooltip on FSQ if necessary.
       
  4961 // ---------------------------------------------------------------------------
       
  4962 // 
       
  4963 void CAknFepPluginManager::HideTooltipOnFSQL()
       
  4964     {
       
  4965     if ( !iCurrentPluginInputFepUI || !EnableITIOnFSQ() || !iTooltipOpenOnFSQ )
       
  4966         {
       
  4967         return;
       
  4968         }
       
  4969 
       
  4970     iCurrentPluginInputFepUI->HandleCommandL( ECmdPenInputHideTooltip );
       
  4971     iTooltipOpenOnFSQ = EFalse;
       
  4972     }
       
  4973 
       
  4974 // --------------------------------------------------------------------------- 
       
  4975 // Show candidate list
       
  4976 // --------------------------------------------------------------------------- 
       
  4977 //  
       
  4978 void CAknFepPluginManager::ShowCandidateListL
       
  4979                                       ( TFepITICandidateList aCandidateList )
       
  4980     {
       
  4981     if ( !iCurrentPluginInputFepUI )
       
  4982         {
       
  4983         return;       
       
  4984         }
       
  4985     HideTooltipOnFSQL();
       
  4986     iCurrentPluginInputFepUI->HandleCommandL( ECmdPenInputPopupCandidateList,
       
  4987                                 reinterpret_cast<TInt>( &aCandidateList ) );    
       
  4988     }
       
  4989 
       
  4990 // --------------------------------------------------------------------------- 
       
  4991 // Hide candidate list.
       
  4992 // --------------------------------------------------------------------------- 
       
  4993 //  
       
  4994 void CAknFepPluginManager::HideCandidateListL()
       
  4995     {    
       
  4996     if ( !iCurrentPluginInputFepUI )
       
  4997         {
       
  4998         return;       
       
  4999         }
       
  5000     iCurrentPluginInputFepUI->HandleCommandL( ECmdPenInputHideCandidateList );    
       
  5001     }
       
  5002 
       
  5003 
       
  5004 // --------------------------------------------------------------------------- 
       
  5005 // Commit candidate word on FSQ. 
       
  5006 // --------------------------------------------------------------------------- 
       
  5007 //  
       
  5008 void CAknFepPluginManager::CommitCandidateWordOnFSQL( TInt aIndex )
       
  5009     {
       
  5010     iFepMan.PtiEngine()->HandleCommandL( 
       
  5011 							EPtiCommandUserActionSetCurrentIndexOfCandidates, 
       
  5012                             &aIndex ); 
       
  5013     TPtrC selectedWord = iFepMan.PtiEngine()->CurrentWord();
       
  5014     iFepMan.UpdateInlineEditL( selectedWord, selectedWord.Length() );
       
  5015     iFepMan.PtiEngine()->CommitCurrentWord();
       
  5016     iFepMan.CommitInlineEditL();
       
  5017     }
       
  5018 
       
  5019 TBool CAknFepPluginManager::IsChineseIndicator( TAknEditingState aOldState )
       
  5020     {
       
  5021     return aOldState == EIndicatorStatePinyinPhrase
       
  5022            || aOldState == EIndicatorStateStrokePhrase
       
  5023            || aOldState == EIndicatorStateStrokeTradPhrase
       
  5024            || aOldState == EIndicatorStateZhuyinPhrase
       
  5025            || aOldState == EIndicatorStateCangJie
       
  5026            || aOldState == EIndicatorStateZhuyinFind
       
  5027            || aOldState == EIndicatorStateStrokeFind;
       
  5028     }
       
  5029     
       
  5030 // --------------------------------------------------------------------------- 
       
  5031  // Test if editor has EEikEdwinAvkonDisableCursor flag. 
       
  5032  // --------------------------------------------------------------------------- 
       
  5033  //  
       
  5034  TBool CAknFepPluginManager::IsEditorCursorDisabled() 
       
  5035      { 
       
  5036      CAknEdwinState* editorState = iFepMan.EditorState(); 
       
  5037      if ( !editorState ) 
       
  5038          { 
       
  5039          return EFalse; 
       
  5040          } 
       
  5041       
       
  5042      TInt flags = editorState->Flags();         
       
  5043      return ( flags & EEikEdwinAvkonDisableCursor ) == EEikEdwinAvkonDisableCursor; 
       
  5044      } 
       
  5045 
       
  5046 // --------------------------------------------------------------------------- 
       
  5047 // Check if the cusror in editor is visible. 
       
  5048 // --------------------------------------------------------------------------- 
       
  5049 //  
       
  5050 TBool CAknFepPluginManager::IsEditorCursorVisible()
       
  5051     {
       
  5052     CAknEdwinState* editorState = iFepMan.EditorState(); 
       
  5053     if ( !editorState ) 
       
  5054          { 
       
  5055          return EFalse; 
       
  5056          }
       
  5057      return ( editorState->Flags() & EAknEditorFlagTextCursorVisible )      
       
  5058             == EAknEditorFlagTextCursorVisible;
       
  5059     }
       
  5060 
       
  5061 // --------------------------------------------------------------------------- 
       
  5062 // Check if curor selection in editor is visible.
       
  5063 // --------------------------------------------------------------------------- 
       
  5064 //  
       
  5065 TBool CAknFepPluginManager::IsEditorCursorSelVisible()
       
  5066     {
       
  5067      CAknEdwinState* editorState = iFepMan.EditorState(); 
       
  5068      if ( !editorState ) 
       
  5069          { 
       
  5070          return EFalse; 
       
  5071          }
       
  5072      return ( editorState->Flags() & EAknEditorFlagSelectionVisible )      
       
  5073             == EAknEditorFlagSelectionVisible;
       
  5074     }
       
  5075         
       
  5076 // --------------------------------------------------------------------------- 
       
  5077 // Check if ITI features is enabled when FSQ is opened.
       
  5078 // --------------------------------------------------------------------------- 
       
  5079 //  
       
  5080 TBool CAknFepPluginManager::EnableITIOnFSQ()
       
  5081     {
       
  5082 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5083     if ( IsSupportITIOnFSQ()         
       
  5084          && iFepMan.IsQwerty()
       
  5085          && iFepMan.WesternPredictive() )
       
  5086         {
       
  5087         return ETrue;    
       
  5088         }
       
  5089     return EFalse;
       
  5090 #else
       
  5091     return EFalse;
       
  5092 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  5093     }
       
  5094 
       
  5095 // -----------------------------------------------------------------------------
       
  5096 // Check if ITI can be supported by FSQ..
       
  5097 // -----------------------------------------------------------------------------
       
  5098 //    
       
  5099 TBool CAknFepPluginManager::IsSupportITIOnFSQ()
       
  5100     {
       
  5101 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5102     if ( iPluginInputMode == EPluginInputModeFSQ
       
  5103          // Exclude non Latin mode 
       
  5104          && iFepMan.InputMode() == ELatin
       
  5105          // Exclude accent range
       
  5106          && ( iPluginPrimaryRange == ERangeNative 
       
  5107               || iPluginPrimaryRange == ERangeEnglish
       
  5108               // iPluginPrimaryRange == 0 is the default range, 
       
  5109               // default range couldn't be accent. 
       
  5110               || !iPluginPrimaryRange )
       
  5111          && iFepMan.InputLanguageCapabilities().iSupportsWesternQwertyPredictive
       
  5112          && !iSharedData.QwertyInputMode() )
       
  5113         {
       
  5114         return ETrue;
       
  5115         }        
       
  5116 #endif
       
  5117     return EFalse;
       
  5118     }
       
  5119 
       
  5120 // --------------------------------------------------------------------------- 
       
  5121 // Get scan code from hw keymapping.
       
  5122 // --------------------------------------------------------------------------- 
       
  5123 //  
       
  5124 TInt CAknFepPluginManager::GetScanCodeFromHwKeymapping( TUint aKeyCode )
       
  5125     {
       
  5126 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5127     CPtiCoreLanguage *lang = static_cast<CPtiCoreLanguage*>
       
  5128                                    ( iFepMan.PtiEngine()->CurrentLanguage() );
       
  5129     MPtiKeyMappings* keymapping = lang->GetQwertyKeymappings();
       
  5130     if ( keymapping )
       
  5131         {
       
  5132         // Save the old input mode
       
  5133         TPtiEngineInputMode oldInputMode = iFepMan.PtiEngine()->InputMode();
       
  5134         // Change to input mode to EPtiEngineQwertyPredictive, after that
       
  5135         // qwerty keymapping can be got
       
  5136         iFepMan.PtiEngine()->SetInputMode( EPtiEngineQwertyPredictive );
       
  5137         // Find scancode by keycode from qwerty keymapping
       
  5138         TInt retKey = keymapping->KeyForCharacter( aKeyCode );
       
  5139         // Restore the old input mode
       
  5140         iFepMan.PtiEngine()->SetInputMode( oldInputMode );
       
  5141         return retKey;
       
  5142         }
       
  5143     return EPtiKeyNone;
       
  5144 #else
       
  5145     return EPtiKeyNone;
       
  5146 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  5147     }
       
  5148 
       
  5149 // --------------------------------------------------------------------------- 
       
  5150 // Check if those keys are IIT-supported keys.
       
  5151 // --------------------------------------------------------------------------- 
       
  5152 //  
       
  5153 TBool CAknFepPluginManager::IsITISupportedKey( const TKeyEvent& aKeyEvent )
       
  5154     {
       
  5155 // ITI supported conditions
       
  5156 // 1. scan code != EPtiKeyNone
       
  5157 // 2. Basic alpha characters
       
  5158 // 3. 
       
  5159 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5160     if ( aKeyEvent.iScanCode != EPtiKeyNone 
       
  5161          && ( iPluginPrimaryRange == ERangeNative 
       
  5162               || iPluginPrimaryRange == ERangeEnglish
       
  5163               || ( iPluginPrimaryRange == 0 && iFepMan.InputMode() != ENumber 
       
  5164                    && iFepMan.InputMode() != ENativeNumber) )
       
  5165          && ( TChar( aKeyEvent.iCode ).IsAlpha() || IsDeadKeyCode( aKeyEvent.iCode ) ) 
       
  5166           )
       
  5167         {
       
  5168         return ETrue;
       
  5169         }
       
  5170     return EFalse;
       
  5171 #else
       
  5172     return EFalse;
       
  5173 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  5174     }
       
  5175     
       
  5176 TPtiTextCase CAknFepPluginManager::CaseForMappedCharacter(TChar aCharacter)
       
  5177     {
       
  5178 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5179     const TInt KDefaulCoreMaximumWordLength = 100;
       
  5180     TPtiTextCase casesTOCheckAgainst[KNumberOfCases] ={  EPtiCaseLower, EPtiCaseUpper, 
       
  5181                                                       EPtiCaseChrLower, EPtiCaseChrUpper, 
       
  5182                                                       EPtiCaseFnLower, EPtiCaseFnUpper };
       
  5183     TPtiTextCase caseCalculated = EPtiCaseLower;
       
  5184     TBuf<KDefaulCoreMaximumWordLength> mappedCharacters; 
       
  5185     TBool isMappingFound = EFalse;
       
  5186     TPtiKey key = iFepMan.PtiEngine()->CharacterToKey( aCharacter );
       
  5187 
       
  5188     //It loops through all the key mappings to find the character in the key mappings and
       
  5189     //if the character available in the key mapping, fetches the corresponding case.
       
  5190     for( TInt i=0; i< KNumberOfCases ; i++)
       
  5191         {
       
  5192         iFepMan.PtiEngine()->MappingDataForKey( key, mappedCharacters, 
       
  5193                                                 casesTOCheckAgainst[i] );
       
  5194         for( TInt j=0; j < mappedCharacters.Length(); j++ )
       
  5195             {
       
  5196             if( mappedCharacters[j] == aCharacter )
       
  5197                 {
       
  5198                 caseCalculated = casesTOCheckAgainst[i];
       
  5199                 isMappingFound = ETrue;
       
  5200                 break;
       
  5201                 }
       
  5202             }
       
  5203         if ( isMappingFound )
       
  5204         	{
       
  5205         	break;
       
  5206         	}
       
  5207         }
       
  5208     //Now if there is no key mapping found for the character, then use the default TChar
       
  5209     //APIs to find the case of the character.
       
  5210     if( !isMappingFound )
       
  5211         {
       
  5212         caseCalculated = aCharacter.IsUpper()?EPtiCaseUpper:EPtiCaseLower;
       
  5213         }
       
  5214     return caseCalculated;
       
  5215 #else
       
  5216     return aCharacter.IsUpper() ? EPtiCaseUpper : EPtiCaseLower;   
       
  5217 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  5218     }
       
  5219     
       
  5220 TBool CAknFepPluginManager::IsNeedToChangeTextCase( const TPtiTextCase& aTextCase )
       
  5221     {
       
  5222 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  5223     TPtiTextCase textCase = aTextCase;
       
  5224     if( EPtiKeyboardHalfQwerty != iFepMan.PtiEngine()->KeyboardType() )
       
  5225 		{
       
  5226 		if ( textCase  == EPtiCaseChrLower )
       
  5227 			{
       
  5228 			textCase = EPtiCaseLower;
       
  5229 			}
       
  5230 		else if (textCase == EPtiCaseChrUpper)
       
  5231 			{
       
  5232 			textCase = EPtiCaseUpper;
       
  5233 			}
       
  5234 		}
       
  5235     return ( iFepMan.PtiEngine()->Case() == textCase )
       
  5236             ? EFalse : ETrue;   
       
  5237 #else
       
  5238     return EFalse;
       
  5239 #endif // RD_INTELLIGENT_TEXT_INPUT
       
  5240     }
       
  5241 
       
  5242 // -----------------------------------------------------------------------------
       
  5243 // Do some configuration to make FSQ support ITI features.
       
  5244 // -----------------------------------------------------------------------------
       
  5245 //
       
  5246 void CAknFepPluginManager::SetItiStateL()
       
  5247     {
       
  5248     if ( iIsITIConfigured || !IsSupportITIOnFSQ() )
       
  5249     	{
       
  5250     	return;
       
  5251     	}
       
  5252     // 1. Config keyboard layout type
       
  5253     SetItiKeyboardLayoutL();               
       
  5254     
       
  5255     // 2. Change FEP to qwerty mode.   
       
  5256     iFepMan.SetQwertyMode( ETrue );
       
  5257 
       
  5258     // 3. Notify the activation of ITI on FSQ to peninput server        
       
  5259     iCurrentPluginInputFepUI->HandleCommandL( ECmdPeninputITIStatus,
       
  5260                                               iFepMan.WesternPredictive() );
       
  5261 
       
  5262     // 4. if there is un-commited text editor, 
       
  5263     //    need to setcurrentword to ptiengine again.
       
  5264     TInt unCommitedLen = iFepMan.UncommittedText().Length();
       
  5265     if ( unCommitedLen > 0 )
       
  5266         {
       
  5267         HBufC* unCommitedText = HBufC::NewL( unCommitedLen );
       
  5268         TPtr unCommitedTextPtr = unCommitedText->Des();        
       
  5269         TInt startPos = iFepMan.UncommittedText().LowerPos();
       
  5270         MCoeFepAwareTextEditor* edit = iFepMan.FepAwareTextEditor();
       
  5271         edit->GetEditorContentForFep( unCommitedTextPtr, 
       
  5272                                       startPos, unCommitedLen ); 		
       
  5273 		iFepMan.PtiEngine()->SetCurrentWord( *unCommitedText );
       
  5274 		delete unCommitedText;
       
  5275 		unCommitedText = NULL;
       
  5276         }
       
  5277     
       
  5278     // 5. Set ITI configured flag;
       
  5279     iIsITIConfigured = ETrue;
       
  5280     }
       
  5281 
       
  5282 // -----------------------------------------------------------------------------
       
  5283 // Restore some configuration after closing FSQ.
       
  5284 // -----------------------------------------------------------------------------
       
  5285 //
       
  5286 void CAknFepPluginManager::ResetItiStateL()
       
  5287     {    
       
  5288     if ( !iIsITIConfigured )
       
  5289     	{
       
  5290     	return;
       
  5291     	}
       
  5292     
       
  5293     // Close FSQ then current keyboard type return to the previously-stored one,
       
  5294     // 1. The first step is to restore keyboard type, because the value will
       
  5295     // be used in iFepMan.SetQwertyMode( EFalse );
       
  5296     ResetItiKeyboardLayoutL();
       
  5297     
       
  5298     // 2. Change FEP to non qwerty mode.
       
  5299     iFepMan.SetQwertyMode( EFalse );
       
  5300 
       
  5301     // 3. Notify the deactivation of ITI to peninputserver        
       
  5302     iCurrentPluginInputFepUI->HandleCommandL( ECmdPeninputITIStatus, EFalse );    
       
  5303  
       
  5304     // 4. Clear ITI configured flag;
       
  5305     iIsITIConfigured = EFalse; 
       
  5306     }
       
  5307 
       
  5308 // -----------------------------------------------------------------------------
       
  5309 // Config keyboard layout for ITI.
       
  5310 // -----------------------------------------------------------------------------
       
  5311 //
       
  5312 void CAknFepPluginManager::SetItiKeyboardLayoutL()
       
  5313     { 
       
  5314     if ( iLastKeyboardLayout || !IsSupportITIOnFSQ() )
       
  5315         {
       
  5316         return;
       
  5317         }    
       
  5318     // 1. Record the previous keyboard type
       
  5319     RProperty keyboardLayoutStatusProperty;
       
  5320     keyboardLayoutStatusProperty.Get( KCRUidAvkon, KAknKeyBoardLayout, 
       
  5321                                           iLastKeyboardLayout );
       
  5322 
       
  5323     // 2. Utilize right qwerty keyboard type
       
  5324     TPtiKeyboardType keyboardType = EPtiKeyboardQwerty4x12;
       
  5325     RArray<TPtiKeyboardType> supportedKeyboards;
       
  5326     CleanupClosePushL( supportedKeyboards );
       
  5327     iFepMan.PtiEngine()->KeyboardTypesSupportedByLanguageL
       
  5328                     ( iSharedData.PenInputLanguage(), supportedKeyboards );   
       
  5329     for ( TInt i = 0; i < supportedKeyboards.Count(); i ++ )
       
  5330         {        
       
  5331         if ( supportedKeyboards[i] == EPtiKeyboardQwerty4x12 
       
  5332              || supportedKeyboards[i] == EPtiKeyboardQwerty3x11
       
  5333              || supportedKeyboards[i] == EPtiKeyboardQwerty4x10
       
  5334              || supportedKeyboards[i] == EPtiKeyboardCustomQwerty )
       
  5335             {
       
  5336             keyboardType = supportedKeyboards[i];
       
  5337             break;
       
  5338             }        
       
  5339         }
       
  5340     keyboardLayoutStatusProperty.Set( KCRUidAvkon, KAknKeyBoardLayout, 
       
  5341                                       keyboardType );
       
  5342     CleanupStack::PopAndDestroy( &supportedKeyboards );    
       
  5343     }
       
  5344 // -----------------------------------------------------------------------------
       
  5345 // Restore keyboard layout after closing FSQ.
       
  5346 // -----------------------------------------------------------------------------
       
  5347 //
       
  5348 void CAknFepPluginManager::ResetItiKeyboardLayoutL()
       
  5349     {    
       
  5350     if ( !iLastKeyboardLayout || iITISettingDialogOpen )
       
  5351     	{
       
  5352     	return;
       
  5353     	}
       
  5354     
       
  5355     // Close FSQ then current keyboard type return to the previously-stored one,
       
  5356     //Restore keyboard layout type and qwerty mode of FEP        
       
  5357     // 1. Store the previous keyboard type, 
       
  5358     // except that opening predictive setting dialog cause fsq closed.        
       
  5359     RProperty keyboardLayoutStatusProperty;
       
  5360     keyboardLayoutStatusProperty.Set( KCRUidAvkon, KAknKeyBoardLayout, 
       
  5361                                           iLastKeyboardLayout );
       
  5362     iLastKeyboardLayout = 0;        
       
  5363     }
       
  5364 
       
  5365 // -----------------------------------------------------------------------------
       
  5366 // Restore predict state.
       
  5367 // -----------------------------------------------------------------------------
       
  5368 //
       
  5369 void CAknFepPluginManager::RestorePredictStateL()
       
  5370     {
       
  5371     if( iT9UsedBeforePluginInput )
       
  5372         {
       
  5373         iT9UsedBeforePluginInput = EFalse;
       
  5374         iFepMan.SetWesternPredictive(ETrue);
       
  5375         iFepMan.TryChangeModeL(ELatin);     
       
  5376         }
       
  5377     if(iAutoCompBeforePluginInput)
       
  5378         {
       
  5379         iAutoCompBeforePluginInput = EFalse;
       
  5380         iFepMan.SetWesternAutoComplete(ETrue);        
       
  5381         iFepMan.TryChangeModeL(ELatin);      
       
  5382         }
       
  5383     }
       
  5384 
       
  5385 // -----------------------------------------------------------------------------
       
  5386 // Check if the keycode belongs to dead keys.
       
  5387 // -----------------------------------------------------------------------------
       
  5388 //
       
  5389 TBool CAknFepPluginManager::IsDeadKeyCode( TUint aKeyCode )
       
  5390 	{	
       
  5391 	for ( TInt i = 0; i < sizeof(KSupportedDeadKeys) / sizeof(TUint); i++ )
       
  5392 		{
       
  5393 		if ( aKeyCode == KSupportedDeadKeys[i] )
       
  5394 			{
       
  5395 			return ETrue;
       
  5396 			}
       
  5397 		}
       
  5398 	return EFalse;
       
  5399 	}
       
  5400  
       
  5401 // -----------------------------------------------------------------------------
       
  5402 // Notify app touch input window closed or open.
       
  5403 // -----------------------------------------------------------------------------
       
  5404 //
       
  5405 void CAknFepPluginManager::NotifyAppUiImeTouchWndState( const TBool aTouchState )
       
  5406     {
       
  5407     if ( iLangMan.IsSplitView() )
       
  5408         {
       
  5409         CEikonEnv* eikEnv = CEikonEnv::Static();
       
  5410         TUint param = aTouchState ? KAknSplitInputEnabled : KAknSplitInputDisabled;
       
  5411         if ( eikEnv && eikEnv->EikAppUi() )
       
  5412             {
       
  5413             eikEnv->EikAppUi()->ReportResourceChangedToAppL( param );
       
  5414             }
       
  5415         }
       
  5416     }
       
  5417 
       
  5418 // -----------------------------------------------------------------------------
       
  5419 // Check if current editor support partial screen IMEs
       
  5420 // -----------------------------------------------------------------------------
       
  5421 //
       
  5422 TBool CAknFepPluginManager::IsEditorSupportSplitIme()
       
  5423     {
       
  5424     //Mfne editors
       
  5425     if ( iFepMan.IsMfneEditor() )
       
  5426         {
       
  5427         TUint caps = iFepMan.ExtendedInputCapabilities();
       
  5428         return CAknExtendedInputCapabilities::EInputEditorPartialScreen == 
       
  5429                    ( caps & CAknExtendedInputCapabilities::EInputEditorPartialScreen );
       
  5430         }
       
  5431     
       
  5432     //Normal editors
       
  5433     CAknEdwinState* state = iFepMan.EditorState(); 
       
  5434     if ( state )
       
  5435         {
       
  5436         return EAknEditorFlagEnablePartialScreen == 
       
  5437                    ( state->Flags() & EAknEditorFlagEnablePartialScreen );
       
  5438         }
       
  5439     
       
  5440     return EFalse;
       
  5441     }
       
  5442 
       
  5443 void CAknFepPluginManager::OnServerReady(TInt aErr)
       
  5444     {
       
  5445     if( KErrNone != aErr )
       
  5446         {
       
  5447         iFepMan.UiInterface()->TouchPaneSetInputMethodIconActivated(EFalse);
       
  5448             
       
  5449         return;               
       
  5450         }
       
  5451     TRAP_IGNORE(iPenInputServer.AddPeninputServerObserverL(this)); //always add the handler            
       
  5452     
       
  5453     iPenInputSvrConnected = ETrue;                     
       
  5454     ActivatePenInputL();
       
  5455     }
       
  5456 
       
  5457 CConnectAo::CConnectAo(CAknFepPluginManager* aClient) 
       
  5458                 : CActive(CActive::EPriorityStandard),
       
  5459                   iClient(aClient)
       
  5460     {
       
  5461     CActiveScheduler::Add(this);
       
  5462     //SetActive();
       
  5463     }
       
  5464 
       
  5465 
       
  5466 void CConnectAo::RunL()
       
  5467     {
       
  5468     iClient->OnServerReady(iStatus.Int());
       
  5469     }
       
  5470 
       
  5471 void CConnectAo::DoCancel()
       
  5472     {
       
  5473     
       
  5474     }
       
  5475 TInt CConnectAo::RunError(TInt aError)
       
  5476     {
       
  5477     return KErrNone;
       
  5478     }
       
  5479 
       
  5480 void CConnectAo::RequestConnect()
       
  5481     {
       
  5482     iStatus = KRequestPending;
       
  5483     SetActive();
       
  5484     }
       
  5485 TRequestStatus& CConnectAo::RequestStatus()
       
  5486     {
       
  5487     return iStatus;
       
  5488     }
       
  5489 
       
  5490 //End of File