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