fep/aknfep/peninputplugins/peninputimeplugingeneric/src/pluginfepmanagerbase.cpp
branchRCL_3
changeset 44 ecbabf52600f
child 56 8152b1f1763a
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:            Layout UI interface base class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 // System includes
       
    30 #include <w32std.h>
       
    31 #include <s32mem.h> 
       
    32 #include <aknedsts.h>               // CAknEdwinState
       
    33 #include <centralrepository.h>
       
    34 #include <AknUtils.h> 
       
    35 
       
    36 #include <peninputclient.h>
       
    37 #include <aknfeppeninputenums.h>
       
    38 #include <AknFepInternalCRKeys.h>
       
    39 #include <peninputcommonlayoutglobalenum.h>
       
    40 
       
    41 // User includes
       
    42 #include "pluginfepmanagerbase.h"
       
    43 #include "peninputimeplugingeneric.h"
       
    44 
       
    45 // ======== MEMBER FUNCTIONS ========
       
    46 
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CPluginFepManagerBase::CPluginFepManagerBase
       
    50 // Destructor
       
    51 // (other items were commented in a header).
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 CPluginFepManagerBase::~CPluginFepManagerBase()
       
    55     {
       
    56     delete iRepository;
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CPluginFepManagerBase::OnInit
       
    61 // Initalize UI.
       
    62 // (other items were commented in a header).
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void CPluginFepManagerBase::OnInit()
       
    66     {
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CPluginFepManagerBase::RetrieveEditorMaxLength
       
    71 // Explicitly get ICF max length from layout UI .
       
    72 // (other items were commented in a header).
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void CPluginFepManagerBase::RetrieveEditorMaxLength()
       
    76     {
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CPluginFepManagerBase::UpdateCaseMode
       
    81 // Update local copy of case mode.
       
    82 // (other items were commented in a header).
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 void CPluginFepManagerBase::UpdateCaseMode( TInt aCaseMode )
       
    86     {
       
    87     iLastCase = aCaseMode; 
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CPluginFepManagerBase::SetNumberModeKeyMappingL
       
    92 // Set layout UI current number mode.
       
    93 // (other items were commented in a header).
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CPluginFepManagerBase::SetNumberModeKeyMappingL( 
       
    97     TAknEditorNumericKeymap aAknEditorNumericKeymap )
       
    98     {
       
    99     SendCommandToServer( ECmdPenInputEditorNumericKeyMap, 
       
   100                          aAknEditorNumericKeymap );    
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CPluginFepManagerBase::HandleKeyL
       
   105 // Handle key event.
       
   106 // (other items were commented in a header).
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 TBool CPluginFepManagerBase::HandleKeyL( TInt aKey, TKeyPressLength aLength, TEventCode /*aEventCode*/ )
       
   110     {
       
   111     return iHkbUi->HandleKeyL( aKey, aLength );
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CPluginFepManagerBase::HandleCommandL
       
   116 // Handle command come from FEP.
       
   117 // (other items were commented in a header).
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CPluginFepManagerBase::HandleCommandL( TInt aCommandId )
       
   121     {
       
   122     SendCommandToServer( aCommandId );
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CPluginFepManagerBase::HandleCommandL
       
   127 // Handle command come from FEP.
       
   128 // (other items were commented in a header).
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 void CPluginFepManagerBase::HandleCommandL(TInt aCommandId,TInt aParam)
       
   132     {
       
   133     switch ( aCommandId )
       
   134         {
       
   135         case ECmdPenInputRange:
       
   136             {
       
   137             iHkbMode = aParam;
       
   138             if ( iHkbMode == ENativeNumber && !SupportNativeNumberRange() )
       
   139                 {
       
   140                 iHkbMode = ENumber;
       
   141                 }
       
   142             }
       
   143             break;
       
   144         case ECmdPenInputPermittedRange:
       
   145             {
       
   146             iLastCase = ECaseInvalide;
       
   147             SetLayoutPermitedRanges( aParam );
       
   148             }
       
   149             break;
       
   150         case ECmdPenInputEditorState:
       
   151             {
       
   152             CAknEdwinState* state = 
       
   153                 reinterpret_cast<CAknEdwinState*>( aParam );
       
   154             SetLayoutRange( state );
       
   155             }
       
   156             break;
       
   157         case ECmdPenInputSetWindowPos:
       
   158             {
       
   159             TRect* rect = reinterpret_cast<TRect*>( aParam );
       
   160             ASSERT( rect );
       
   161             SetLayoutPosition( *rect );
       
   162             }
       
   163             break;
       
   164         case ECmdPenInputCaseMode:
       
   165             //if( aParam != iLastCase )
       
   166                 {
       
   167                 SendCommandToServer( ECmdPenInputCase, aParam );
       
   168                 iLastCase = aParam;
       
   169                 }
       
   170             break;
       
   171         case ECmdPenInputEditorCustomNumericKeyMap:
       
   172             {
       
   173             TDesC* res = (TDesC*)aParam;
       
   174             TPtrC8 param;
       
   175             param.Set((TUint8*)res->Ptr(), res->Size());
       
   176             SendCommandToServer( aCommandId, param ); 
       
   177             SetNumberModeKeyMappingL((TAknEditorNumericKeymap)EKeymapFromResource);
       
   178             }
       
   179             break;
       
   180         case ECmdPenInputSuggestRange:
       
   181             iSuggestedRange = aParam;
       
   182             if( iSuggestedRange == ERangeAccent )
       
   183                 {
       
   184                 iSuggestedRange = ERangeEnglish;
       
   185                 }
       
   186             break;
       
   187         case ECmdPenInputSendEditorTextAndCurPos:
       
   188             {    
       
   189             TFepInputContextFieldData* pIcfData = 
       
   190                 reinterpret_cast<TFepInputContextFieldData*>( aParam );
       
   191                        
       
   192             TInt dataSize = sizeof( TFepInputContextFieldData );
       
   193             TInt textSize = pIcfData->iText.Size();
       
   194             
       
   195 			HBufC8* buf = HBufC8::NewLC(dataSize + textSize + 2*sizeof(TInt));
       
   196 			TPtr8 bufPtr = buf->Des();
       
   197 			
       
   198 			RDesWriteStream writeStream;
       
   199 			writeStream.Open(bufPtr);
       
   200 			CleanupClosePushL(writeStream);
       
   201 			
       
   202 			writeStream.WriteInt32L(dataSize);
       
   203 			writeStream.WriteInt32L(textSize);
       
   204 			
       
   205 			const TUint8* pData = reinterpret_cast<const TUint8*>( pIcfData );
       
   206 			writeStream.WriteL( pData, dataSize );
       
   207         		
       
   208     		const TUint8* pText = reinterpret_cast<const TUint8*>( pIcfData->iText.Ptr() );
       
   209 		    writeStream.WriteL( pText, textSize );
       
   210 		    
       
   211             writeStream.CommitL();
       
   212         
       
   213             SendCommandToServer( aCommandId, bufPtr );
       
   214     
       
   215 			CleanupStack::PopAndDestroy(&writeStream);
       
   216 			CleanupStack::PopAndDestroy(buf);
       
   217             }
       
   218             break;
       
   219 	     case ECmdPenInputSetPromptText:
       
   220             {
       
   221             TFepPromptText* pPromptData = 
       
   222                 reinterpret_cast<TFepPromptText*>( aParam );
       
   223                 
       
   224             TInt dataSize = sizeof( TFepPromptText );
       
   225             TInt textSize = 0;
       
   226             
       
   227             if (pPromptData->iText.Length())
       
   228                 {
       
   229                 textSize = pPromptData->iText.Size();
       
   230                 }
       
   231             
       
   232 			HBufC8* buf = HBufC8::NewLC(dataSize + textSize + 2*sizeof(TInt));
       
   233 			TPtr8 bufPtr = buf->Des();
       
   234 			
       
   235 			RDesWriteStream writeStream;
       
   236 			writeStream.Open(bufPtr);
       
   237 			CleanupClosePushL(writeStream);
       
   238 			
       
   239 			writeStream.WriteInt32L(dataSize);
       
   240 			writeStream.WriteInt32L(textSize);
       
   241 			
       
   242 			const TUint8* pData = reinterpret_cast<const TUint8*>( pPromptData );
       
   243 			writeStream.WriteL( pData, dataSize );
       
   244         	
       
   245         	if (textSize != 0)
       
   246         	    {
       
   247                 const TUint16* pText = pPromptData->iText.Ptr();
       
   248     		    writeStream.WriteL( pText, textSize/2 );
       
   249         	    }
       
   250 		    
       
   251             writeStream.CommitL();
       
   252         
       
   253             SendCommandToServer( aCommandId, bufPtr );
       
   254     
       
   255 			CleanupStack::PopAndDestroy(&writeStream);
       
   256 			CleanupStack::PopAndDestroy(buf);
       
   257             }
       
   258             break;
       
   259 		case ECmdPeninputSpellICFDisplayContent:
       
   260 			{
       
   261 			// for set icf text before enter spell mode
       
   262 			}
       
   263 			break;
       
   264         case ECmdPenInputPopupTooltip:
       
   265             {
       
   266             TPtrC* tooltipTextPtr = reinterpret_cast<TPtrC*>( aParam );
       
   267             HBufC8* buf8 = HBufC8::NewLC
       
   268                          ( sizeof( TInt ) + tooltipTextPtr->Size() );
       
   269             TPtr8 buf8Ptr = buf8->Des();
       
   270             RDesWriteStream writeStream;
       
   271             CleanupClosePushL(writeStream);
       
   272             writeStream.Open( buf8Ptr );
       
   273             writeStream.WriteInt32L( tooltipTextPtr->Size() );
       
   274             writeStream.WriteL( tooltipTextPtr->Ptr(), tooltipTextPtr->Length() );
       
   275             writeStream.CommitL();
       
   276             CleanupStack::PopAndDestroy( &writeStream );                        
       
   277             SendCommandToServer( aCommandId, buf8Ptr );            
       
   278             CleanupStack::PopAndDestroy( buf8 );
       
   279             break;
       
   280             }
       
   281         case ECmdPenInputPopupCandidateList:
       
   282             {
       
   283             TFepITICandidateList* candidatelist 
       
   284                                = reinterpret_cast<TFepITICandidateList*>( aParam );            
       
   285             CDesCArray* itemArray = candidatelist->iItemArray;
       
   286             if ( itemArray && itemArray->Count() > 0 )
       
   287                 {           
       
   288                 TInt sumSize = 0;     
       
   289                 for ( TInt i = 0; i < itemArray->Count(); i++ )
       
   290                     {
       
   291                     sumSize += (*itemArray)[i].Size();
       
   292                     }
       
   293                 HBufC8* buf8 = HBufC8::NewLC( sizeof(TInt) // For active index
       
   294                                              + sizeof(TInt) // For the count of item array
       
   295                                              + sizeof(TInt) // for langcode
       
   296                                              + sizeof(TInt)*( itemArray->Count() ) // For the size of each item
       
   297                                              + sumSize// For all of char data 
       
   298                                              );
       
   299                 TPtr8 buf8Ptr = buf8->Des();
       
   300                 RDesWriteStream writeStream;
       
   301                 CleanupClosePushL(writeStream);                
       
   302                 writeStream.Open( buf8Ptr );                
       
   303                 writeStream.WriteInt32L( candidatelist->iActiveIndex );
       
   304                 writeStream.WriteInt32L( itemArray->Count() ); 
       
   305                 writeStream.WriteInt32L(candidatelist->iLangCode);
       
   306                 
       
   307                 for ( TInt i = 0; i < itemArray->Count(); i++  )
       
   308                     {
       
   309                     writeStream.WriteInt32L( (*itemArray)[i].Size() );
       
   310                     writeStream.WriteL( (*itemArray)[i].Ptr(), (*itemArray)[i].Length() );
       
   311                     }
       
   312                 writeStream.CommitL();                 
       
   313                 CleanupStack::PopAndDestroy( &writeStream );
       
   314                 SendCommandToServer( aCommandId, buf8Ptr );
       
   315                 CleanupStack::PopAndDestroy( buf8 );
       
   316                 }            
       
   317             break;
       
   318             }
       
   319 		case ECmdPenInputFingerMatchIndicator:
       
   320             {
       
   321             TFepIndicatorInfo* pIndicatorData = 
       
   322                 reinterpret_cast<TFepIndicatorInfo*>( aParam );
       
   323             
       
   324 			HBufC8* buf = HBufC8::NewLC(4 * sizeof(TInt));
       
   325 			TPtr8 bufPtr = buf->Des();
       
   326 			
       
   327 			RDesWriteStream writeStream;
       
   328 			writeStream.Open(bufPtr);
       
   329 			CleanupClosePushL(writeStream);
       
   330 			
       
   331             writeStream.WriteInt32L(pIndicatorData->iIndicatorImgID);
       
   332             writeStream.WriteInt32L(pIndicatorData->iIndicatorMaskID);
       
   333             writeStream.WriteInt32L(pIndicatorData->iIndicatorTextImgID);
       
   334             writeStream.WriteInt32L(pIndicatorData->iIndicatorTextMaskID);
       
   335 		    
       
   336             writeStream.CommitL();
       
   337         
       
   338             SendCommandToServer( aCommandId, bufPtr );
       
   339     
       
   340 			CleanupStack::PopAndDestroy(&writeStream);
       
   341 			CleanupStack::PopAndDestroy(buf);			
       
   342             }
       
   343             break;
       
   344         default:
       
   345             SendCommandToServer( aCommandId, aParam );
       
   346             break;
       
   347         }
       
   348     }
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 // CPluginFepManagerBase::CloseUI
       
   352 // Close plugin layout UI.
       
   353 // (other items were commented in a header).
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 void CPluginFepManagerBase::CloseUI()
       
   357     {
       
   358     if (iPenInputServer->IsVisible())
       
   359 	    {
       
   360     	iPenInputServer->ActivateLayout( EFalse );  
       
   361 		}
       
   362     }
       
   363 
       
   364 // -----------------------------------------------------------------------------
       
   365 // CPluginFepManagerBase::ActivateUI
       
   366 // Activate plugin layout UI.
       
   367 // (other items were commented in a header).
       
   368 // -----------------------------------------------------------------------------
       
   369 //
       
   370 void CPluginFepManagerBase::ActivateUI()
       
   371     {
       
   372     if(iPenInputServer)
       
   373         {
       
   374         iPenInputServer->ActivateLayout( ETrue ); 
       
   375         }    
       
   376     }
       
   377 
       
   378 // -----------------------------------------------------------------------------
       
   379 // CPluginFepManagerBase::EditorMaxLength
       
   380 // Get max text length of layout UI ICF control.
       
   381 // (other items were commented in a header).
       
   382 // -----------------------------------------------------------------------------
       
   383 //
       
   384 TInt CPluginFepManagerBase::EditorMaxLength()
       
   385     {
       
   386     return iMaxEditorLength;
       
   387     }
       
   388 
       
   389 // -----------------------------------------------------------------------------
       
   390 // CPluginFepManagerBase::SizeChanged
       
   391 // Handle screen size changed.
       
   392 // (other items were commented in a header).
       
   393 // -----------------------------------------------------------------------------
       
   394 //
       
   395 void CPluginFepManagerBase::ResourceChanged(TInt aType)
       
   396     {
       
   397     iPenInputServer->ResourceChanged(aType);
       
   398     }
       
   399 
       
   400 // -----------------------------------------------------------------------------
       
   401 // CPluginFepManagerBase::SetNextFepUI
       
   402 // Set underlining UI.
       
   403 // (other items were commented in a header).
       
   404 // -----------------------------------------------------------------------------
       
   405 //
       
   406 void CPluginFepManagerBase::SetNextFepUI( MAknFepManagerInterface* aNextUi )
       
   407     {
       
   408     iHkbUi = aNextUi;    
       
   409     }
       
   410 
       
   411 // -----------------------------------------------------------------------------
       
   412 // CPluginFepManagerBase::SupportLanguage
       
   413 // Get support language in sepecfied mode.
       
   414 // (other items were commented in a header).
       
   415 // -----------------------------------------------------------------------------
       
   416 //
       
   417 TInt CPluginFepManagerBase::SupportLanguage( TInt /*aMode*/ ) const
       
   418     {
       
   419     return iLanguage;
       
   420     }
       
   421 
       
   422 // -----------------------------------------------------------------------------
       
   423 // CPluginFepManagerBase::SetInputLanguageL
       
   424 // Set current language.
       
   425 // (other items were commented in a header).
       
   426 // -----------------------------------------------------------------------------
       
   427 //
       
   428 void CPluginFepManagerBase::SetInputLanguageL( TLanguage aLanguage )
       
   429     {
       
   430     iLanguage = aLanguage;
       
   431     //maybe language check is needed.
       
   432     TInt lang = (TInt)aLanguage;
       
   433     ASSERT( lang >=0 );
       
   434     SendCommandToServer( ECmdPenInputLanguage, lang );       
       
   435     }
       
   436 
       
   437 TInt CPluginFepManagerBase::InputLanguage()
       
   438     {
       
   439     return iLanguage;
       
   440     }
       
   441 
       
   442 // -----------------------------------------------------------------------------
       
   443 // CPluginFepManagerBase::SetFepAwareEditorText
       
   444 // Set editor text and cursor information to layout UI ICF control.
       
   445 // (other items were commented in a header).
       
   446 // -----------------------------------------------------------------------------
       
   447 //
       
   448 void CPluginFepManagerBase::SetFepAwareEditorText( 
       
   449     const TFepInputContextFieldData& aIcfData )
       
   450     {
       
   451     }
       
   452     
       
   453 // -----------------------------------------------------------------------------
       
   454 // CPluginFepManagerBase::SetMode
       
   455 // Set layout UI mode.
       
   456 // (other items were commented in a header).
       
   457 // -----------------------------------------------------------------------------
       
   458 //
       
   459 #ifdef RD_INTELLIGENT_TEXT_INPUT          
       
   460 void CPluginFepManagerBase::SetMode( TInt aMode, TBool aPredictive, 
       
   461                                      TBool aQwertyInputMode, TInt aKeyboardType)
       
   462 #else
       
   463 void CPluginFepManagerBase::SetMode( TInt aMode, TBool aPredictive, 
       
   464                                      TBool aQwertyInputMode )
       
   465 #endif    
       
   466     {
       
   467     iHkbUi->SetMode( aMode, aPredictive, aQwertyInputMode );
       
   468     }
       
   469 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   470     TBool CPluginFepManagerBase::IsValidFnKeyPress() const
       
   471     {
       
   472     return EFalse;
       
   473     }
       
   474     TBool CPluginFepManagerBase::IsValidLongChrKeyPress() const
       
   475     {
       
   476     return EFalse;
       
   477     }
       
   478 #endif
       
   479 
       
   480 // -----------------------------------------------------------------------------
       
   481 // CPluginFepManagerBase::SetMode
       
   482 // Set layout UI current case.
       
   483 // (other items were commented in a header).
       
   484 // -----------------------------------------------------------------------------
       
   485 //
       
   486 void CPluginFepManagerBase::SetCase( TCase aCase )
       
   487     {
       
   488     iHkbUi->SetCase( aCase );
       
   489     }
       
   490 
       
   491 // -----------------------------------------------------------------------------
       
   492 // CPluginFepManagerBase::ExpireMultitapTimer
       
   493 // Compatibile with HKB UI.
       
   494 // (other items were commented in a header).
       
   495 // -----------------------------------------------------------------------------
       
   496 //
       
   497 void CPluginFepManagerBase::ExpireMultitapTimer()
       
   498     {
       
   499     }
       
   500 
       
   501 // -----------------------------------------------------------------------------
       
   502 // CPluginFepManagerBase::IsValidNumericLongKeyPress
       
   503 // Compatibile with HKB UI.
       
   504 // (other items were commented in a header).
       
   505 // -----------------------------------------------------------------------------
       
   506 //
       
   507 TBool CPluginFepManagerBase::IsValidNumericLongKeyPress( TInt /*aKey*/ ) const
       
   508     {
       
   509     return EFalse;
       
   510     }
       
   511 
       
   512 // -----------------------------------------------------------------------------
       
   513 // CPluginFepManagerBase::AddTextToUserDictionaryL
       
   514 // Compatibile with HKB UI.
       
   515 // (other items were commented in a header).
       
   516 // -----------------------------------------------------------------------------
       
   517 //
       
   518 void CPluginFepManagerBase::AddTextToUserDictionaryL( const TDesC& /*aText*/ )
       
   519     {
       
   520     }
       
   521        
       
   522 // -----------------------------------------------------------------------------
       
   523 // CPluginFepManagerBase::GetFormatOfFepInlineText
       
   524 // Compatibile with HKB UI.
       
   525 // (other items were commented in a header).
       
   526 // -----------------------------------------------------------------------------
       
   527 //
       
   528 void CPluginFepManagerBase::GetFormatOfFepInlineText( 
       
   529                                 TCharFormat& /*aFormat*/, 
       
   530                                 TInt& /*aNumberOfCharactersWithSameFormat*/, 
       
   531                                 TInt /*aPositionOfCharacter*/ ) const
       
   532     {
       
   533     }
       
   534 
       
   535 // -----------------------------------------------------------------------------
       
   536 // CPluginFepManagerBase::IsValidShiftKeyPress
       
   537 // Compatibile with HKB UI.
       
   538 // (other items were commented in a header).
       
   539 // -----------------------------------------------------------------------------
       
   540 //
       
   541 TBool CPluginFepManagerBase::IsValidShiftKeyPress() const
       
   542     {
       
   543     return EFalse;
       
   544     }
       
   545 
       
   546 // -----------------------------------------------------------------------------
       
   547 // CPluginFepManagerBase::SetEditorContext
       
   548 // Compatibile with HKB UI.
       
   549 // (other items were commented in a header).
       
   550 // -----------------------------------------------------------------------------
       
   551 //
       
   552 void CPluginFepManagerBase::SetEditorContext( TInt /*aContext*/ )
       
   553     {
       
   554     }
       
   555 
       
   556 // -----------------------------------------------------------------------------
       
   557 // CPluginFepManagerBase::SetEditorContext
       
   558 // Compatibile with HKB UI.
       
   559 // (other items were commented in a header).
       
   560 // -----------------------------------------------------------------------------
       
   561 //
       
   562 void CPluginFepManagerBase::SetStarKeyFlag( TBool /*aSet*/ )
       
   563     {
       
   564     }
       
   565 
       
   566 // -----------------------------------------------------------------------------
       
   567 // CPluginFepManagerBase::CPluginFepManagerBase
       
   568 // C++ default constructor.
       
   569 // (other items were commented in a header).
       
   570 // -----------------------------------------------------------------------------
       
   571 //
       
   572 CPluginFepManagerBase::CPluginFepManagerBase( CPenInputImePluginGeneric& aOwner,
       
   573                                              RPeninputServer* aPenInputServer )
       
   574     :iOwner( aOwner ), iPenInputServer( aPenInputServer )
       
   575     {
       
   576     iSuggestedRange = ERangeInvalid;
       
   577     }
       
   578 
       
   579 // -----------------------------------------------------------------------------
       
   580 // CPluginFepManagerBase::BaseConstructL
       
   581 // Symbian 2nd phase constructor.
       
   582 // (other items were commented in a header).
       
   583 // -----------------------------------------------------------------------------
       
   584 //
       
   585 void CPluginFepManagerBase::BaseConstructL()
       
   586     {
       
   587     iRepository = CRepository::NewL( KCRUidAknFep );
       
   588     }
       
   589     
       
   590 // -----------------------------------------------------------------------------
       
   591 // CPluginFepManagerBase::SetLayoutPermitedRanges
       
   592 // Set layout permited ranges.
       
   593 // (other items were commented in a header).
       
   594 // -----------------------------------------------------------------------------
       
   595 //
       
   596 void CPluginFepManagerBase::SetLayoutPermitedRanges( TInt aPermittedMode )
       
   597     {
       
   598     iPermittedMode = aPermittedMode;
       
   599     
       
   600     // Not derived from edwin
       
   601     if ( aPermittedMode == EAknEditorNumericInputMode ) 
       
   602         {
       
   603 		if ( SupportNativeNumberRange() )
       
   604 		    {
       
   605 		    iPermittedRange = ERangeNativeNumber;
       
   606 		    }
       
   607 		iPermittedRange |= ERangeNumber;
       
   608         }
       
   609     else if(aPermittedMode == (EAknEditorNumericInputMode | EAknEditorFullWidthNumericInputMode))
       
   610         {
       
   611         if ( SupportNativeNumberRange() )
       
   612             {
       
   613             iPermittedRange = ERangeNativeNumber;
       
   614             }
       
   615         iPermittedRange |= ERangeNumber;    
       
   616         }
       
   617     else if ( aPermittedMode & EAknEditorTextInputMode )
       
   618         {
       
   619         // Derived from edwin and EAknEditorTextInputMode
       
   620         iPermittedRange = ERangeNative | 
       
   621                           ERangeNumber | 
       
   622                           ERangeEnglish | 
       
   623                           ERangeSymbol |
       
   624 						  ERangeNativeNumber;
       
   625         }
       
   626     else if ( aPermittedMode & EAknEditorSecretAlphaInputMode ) 
       
   627         {
       
   628         // Derived from EAknEditorSecretAlphaInputMode 
       
   629         iPermittedRange = ERangeNumber |
       
   630                           ERangeEnglish | 
       
   631                           ERangeSymbol;        
       
   632         }
       
   633     else
       
   634         {
       
   635         iPermittedRange = ERangeNative | 
       
   636                           ERangeNumber | 
       
   637                           ERangeEnglish | 
       
   638                           ERangeSymbol |
       
   639 						  ERangeNativeNumber;
       
   640         }
       
   641     }
       
   642     
       
   643 // -----------------------------------------------------------------------------
       
   644 // CPluginFepManagerBase::SetLayoutRange
       
   645 // Set layout primary range.
       
   646 // (other items were commented in a header).
       
   647 // -----------------------------------------------------------------------------
       
   648 //
       
   649 void CPluginFepManagerBase::SetLayoutRange( 
       
   650     const CAknEdwinState* aEditorState )
       
   651     {
       
   652     //calculate permitted ranges
       
   653     if(aEditorState)
       
   654         {
       
   655         if( aEditorState->Flags() & EAknEditorFlagLatinInputModesOnly )
       
   656             {
       
   657             iPermittedRange &= ~ERangeNative;
       
   658 			iPermittedRange &= ~ERangeNativeNumber;
       
   659             }      
       
   660         if ( iPermittedMode != EAknEditorNumericInputMode 
       
   661             && !SupportLatinRange() 
       
   662             && !( aEditorState->Flags() & EAknEditorFlagLatinInputModesOnly ) )
       
   663             {
       
   664 		    iPermittedRange &= ~ERangeEnglish;
       
   665             }
       
   666         }
       
   667     else
       
   668         {
       
   669         if ( iPermittedMode == EAknEditorNumericInputMode )
       
   670             {
       
   671             if( iHkbMode == ENumber )
       
   672                 {
       
   673                 iPermittedRange = ERangeNumber;
       
   674                 }
       
   675             else if ( iHkbMode == ENativeNumber )
       
   676                 {
       
   677                 iPermittedRange = ERangeNativeNumber;
       
   678                 } 
       
   679             }
       
   680         else if( iPermittedMode == 
       
   681                  (EAknEditorNumericInputMode | EAknEditorFullWidthNumericInputMode))
       
   682             {
       
   683             iPermittedRange = ERangeNumber | ERangeNativeNumber;            
       
   684             }
       
   685         }
       
   686 
       
   687     SendCommandToServer( ECmdPenInputPermittedRange, iPermittedRange );
       
   688     
       
   689     TInt priRange;
       
   690     
       
   691     switch( iHkbMode )
       
   692         {
       
   693         case ECangJie:
       
   694         case EStrokeFind:
       
   695         case EStroke:
       
   696         case EPinyin:
       
   697         case EZhuyin:
       
   698         case EZhuyinFind:
       
   699         case EHindi:
       
   700             {
       
   701             priRange = ERangeNative;
       
   702             }
       
   703             break;                 
       
   704         case ENumber:
       
   705             {
       
   706             priRange = ERangeNumber;
       
   707             }
       
   708             break;  
       
   709         case ENativeNumber:
       
   710             {
       
   711             priRange = ERangeNativeNumber;
       
   712             }
       
   713             break;  
       
   714         case EPRCFind:
       
   715         case ELatin:
       
   716         case ELatinText:
       
   717         case ELatinUpper:
       
   718         case ELatinLower:
       
   719             if ( iLanguage == ELangHindi)
       
   720                 {
       
   721                 priRange = ERangeEnglish;
       
   722                 }
       
   723             else
       
   724                 {
       
   725                 priRange = iPermittedRange & ERangeNative ? ERangeNative : ERangeEnglish;
       
   726                 }
       
   727             break;
       
   728         default:
       
   729             {
       
   730             priRange = iPermittedRange & ERangeNative ? ERangeNative : ERangeEnglish;
       
   731             }
       
   732             break;               
       
   733         }
       
   734      
       
   735     if( iSuggestedRange != ERangeInvalid && (iSuggestedRange & iPermittedRange) )
       
   736         {
       
   737         priRange = iSuggestedRange;
       
   738         iSuggestedRange = ERangeInvalid;
       
   739         }
       
   740     SendCommandToServer( ECmdPenInputRange, priRange );  
       
   741     }
       
   742     
       
   743 // -----------------------------------------------------------------------------
       
   744 // CPluginFepManagerBase::SendCommandToServer
       
   745 // Send command to pen input server utility function.
       
   746 // (other items were commented in a header).
       
   747 // -----------------------------------------------------------------------------
       
   748 //
       
   749 void CPluginFepManagerBase::SendCommandToServer( TInt aCommandId )
       
   750     {
       
   751     iPenInputServer->HandleCommand( aCommandId );
       
   752     }
       
   753 
       
   754 // -----------------------------------------------------------------------------
       
   755 // CPluginFepManagerBase::SendCommandToServer
       
   756 // Send command to pen input server utility function.
       
   757 // (other items were commented in a header).
       
   758 // -----------------------------------------------------------------------------
       
   759 //
       
   760 void CPluginFepManagerBase::SendCommandToServer( TInt aCommandId, TInt aParam )
       
   761     {
       
   762     TBuf8<sizeof(TInt)> buf;
       
   763     buf.Append( (TUint8*)&aParam, sizeof(TInt) );    
       
   764     SendCommandToServer( aCommandId, buf );
       
   765     }
       
   766 
       
   767 // -----------------------------------------------------------------------------
       
   768 // CPluginFepManagerBase::SendCommandToServer
       
   769 // Send command to pen input server utility function.
       
   770 // (other items were commented in a header).
       
   771 // -----------------------------------------------------------------------------
       
   772 //
       
   773 void CPluginFepManagerBase::SendCommandToServer( TInt aCommandId, 
       
   774                                                  const TDesC8& aParam )
       
   775     {
       
   776     iPenInputServer->HandleCommand( aCommandId, aParam );        
       
   777     }
       
   778 
       
   779 // -----------------------------------------------------------------------------
       
   780 // CPluginFepManagerBase::LayoutLastUsedRange
       
   781 // Get layout UI last used range.
       
   782 // (other items were commented in a header).
       
   783 // -----------------------------------------------------------------------------
       
   784 //
       
   785 TInt CPluginFepManagerBase::LayoutLastUsedRange()
       
   786     {
       
   787     TInt value = 0;
       
   788     if ( iRepository )
       
   789         {
       
   790         iRepository->Get( KAknFepLastUsedRange, value );
       
   791         }
       
   792         
       
   793     return value;
       
   794     }
       
   795 
       
   796 // -----------------------------------------------------------------------------
       
   797 // CPluginFepManagerBase::SetLayoutPosition
       
   798 // Set layout UI position.
       
   799 // (other items were commented in a header).
       
   800 // -----------------------------------------------------------------------------
       
   801 //
       
   802 void CPluginFepManagerBase::SetLayoutPosition( const TRect& pParam )
       
   803     {
       
   804     TBuf8<sizeof( TRect )> buf;
       
   805     buf.Append( (TUint8*)&pParam, sizeof( pParam ) );
       
   806     
       
   807     SendCommandToServer( ECmdPenInputSetWindowPos, buf );
       
   808     }
       
   809 
       
   810 // -----------------------------------------------------------------------------
       
   811 // CPluginFepManagerBase::GetLocalLanguage
       
   812 // (other items were commented in a header).
       
   813 // -----------------------------------------------------------------------------
       
   814 //
       
   815 TLanguage CPluginFepManagerBase::GetLocalLanguage( 
       
   816     const CAknEdwinState* aEditorState ) const
       
   817     {
       
   818     TLanguage language = ELangTest;
       
   819     // Check for a local language override
       
   820     if ( aEditorState )
       
   821         {
       
   822         TInt aknEditorFlags = aEditorState->Flags()	;
       
   823         if ( aknEditorFlags & EAknEditorFlagLatinInputModesOnly )
       
   824             {
       
   825             language = ELangEnglish;
       
   826             }
       
   827         else
       
   828             {
       
   829             language = aEditorState->LocalLanguage();
       
   830             }
       
   831         }
       
   832 
       
   833     return language;
       
   834     }
       
   835 
       
   836 TBool CPluginFepManagerBase::SupportLatinRange()
       
   837     {
       
   838 	if ( iLanguage == ELangRussian || iLanguage == ELangBulgarian ||
       
   839          iLanguage == ELangUkrainian || iLanguage == ELangHebrew )
       
   840 		 {
       
   841 		 return EFalse;
       
   842 		 }
       
   843 		 
       
   844 	if ( iLanguage == ELangGreek )
       
   845 		 {
       
   846 		 return EFalse;
       
   847 		 }
       
   848 		 
       
   849 	if ( iLanguage == ELangArabic || iLanguage == ELangFarsi ||
       
   850          iLanguage == ELangUrdu || iLanguage == ELangThai )
       
   851 		 {
       
   852 		 return EFalse;
       
   853 		 }
       
   854 
       
   855 	if ( iLanguage == ELangHindi || iLanguage == ELangMarathi )
       
   856 		 {
       
   857 		 return ETrue;
       
   858 		 }	
       
   859 		
       
   860     return ETrue;	 		 		 
       
   861 	}
       
   862 	
       
   863 
       
   864 TBool CPluginFepManagerBase::SupportNativeNumberRange()
       
   865     {
       
   866 	if ( iLanguage == ELangArabic || iLanguage == ELangFarsi ||
       
   867          iLanguage == ELangUrdu || iLanguage == ELangHindi ||
       
   868          iLanguage == ELangThai )
       
   869 		 {
       
   870 		 return ETrue;
       
   871 		 }
       
   872 		
       
   873     return EFalse;	 		 		 
       
   874 	}	
       
   875  // End Of File