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