textinput/peninputhwrboxcn/src/peninputhwrengine.cpp
branchRCL_3
changeset 21 ecbabf52600f
parent 0 eb1f2e154e89
equal deleted inserted replaced
20:ebd48d2de13c 21: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:  Implementation of HWR engine
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <AknFepGlobalEnums.h>
       
    20 #include <aknfeppeninputenums.h>
       
    21 #include <PtiHwrRecognizer.h>
       
    22 
       
    23 #include "peninputhwrengine.h"
       
    24 #include "peninputhwrbxdatastore.h"
       
    25 
       
    26 // constant definition
       
    27 const TInt KInvalidStrokeEndMarkX = -65536;
       
    28 const TInt KInvalidStrokeEndMarkY = -65536;
       
    29 
       
    30 //const TInt KMaxPredictiveCount = 50;
       
    31 const TInt K1PagePredictiveCount = 36;
       
    32 const TUint16 KGestureSpace = 0xF800;
       
    33 const TUint16 KGestureEnter = 0xF801;
       
    34 const TUint16 KSegment = 0x0020;
       
    35 const TUint16 KGestureBackspace = 0x2408;
       
    36 const TUint16 KDisplayBackspace = 0x2190;
       
    37 const TInt KPremaryCandidateCount = 13;
       
    38 const TInt KAuxCandidateCount = 1;
       
    39 
       
    40 _LIT(KNumberSet,"0123456789");
       
    41 _LIT(KSeparator,"\0");
       
    42 _LIT(KDash,"-");
       
    43 _LIT(KSolidus,"/");
       
    44 
       
    45 // ---------------------------------------------------------
       
    46 // Symbian constructor
       
    47 // ---------------------------------------------------------
       
    48 //
       
    49 CAknFepHwrEngine* CAknFepHwrEngine::NewL(CPtiEngine* aPtiEngine, CAknFepHwrBxDataStore* aOwner)
       
    50     {
       
    51     CAknFepHwrEngine* self = new (ELeave) CAknFepHwrEngine();
       
    52     
       
    53     CleanupStack::PushL(self);
       
    54     self->ConstructL(aPtiEngine, aOwner);
       
    55     CleanupStack::Pop(self);//self
       
    56 
       
    57     return self;
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------
       
    61 // C++ constructor
       
    62 // ---------------------------------------------------------
       
    63 //
       
    64 CAknFepHwrEngine::CAknFepHwrEngine():iRecognizerInited(EFalse),
       
    65                                      iNeedSetNumberMode(EFalse),
       
    66                                      iNeedSetCase(EFalse),
       
    67                                      iNeedSetRange(EFalse)
       
    68     {
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // destructor
       
    73 // ---------------------------------------------------------
       
    74 //
       
    75 CAknFepHwrEngine::~CAknFepHwrEngine()
       
    76     {
       
    77     if(iOwnPtiEngine)
       
    78         {
       
    79         delete iPtiEngine;
       
    80         }
       
    81     delete iCustomKeymap;
       
    82     
       
    83     delete iIdle;
       
    84     
       
    85     iPermittedRanges.Reset();
       
    86     iPermittedRanges.Close();
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------
       
    90 // Second phase constructor
       
    91 // ---------------------------------------------------------
       
    92 //
       
    93 void CAknFepHwrEngine::ConstructL(CPtiEngine* aPtiEngine, CAknFepHwrBxDataStore* aOwner)
       
    94     {
       
    95     iPtiEngine = aPtiEngine;
       
    96 
       
    97     if( !iPtiEngine )
       
    98         {
       
    99         iPtiEngine = CPtiEngine::NewL(ETrue);
       
   100         iOwnPtiEngine = ETrue;
       
   101         }
       
   102 
       
   103     iIdle = CIdle::NewL(CActive::EPriorityIdle);
       
   104     iOwner = aOwner;
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------
       
   108 // Convert stroke end mark
       
   109 // ---------------------------------------------------------
       
   110 //
       
   111 void CAknFepHwrEngine::ConvertStrokeEndMark(RArray<TPoint>& aTraceData, TPoint aPnt1, TPoint aPnt2)
       
   112     {
       
   113     TInt count = aTraceData.Count();
       
   114 
       
   115     for (TInt i = 0; i < count; i++)
       
   116         {
       
   117     	if (aTraceData[i] == aPnt1)
       
   118     	    {
       
   119     		aTraceData.Remove(i);
       
   120     		aTraceData.Insert(aPnt2, i);
       
   121     	    }
       
   122         }
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------
       
   126 // Do recoginize by engine
       
   127 // ---------------------------------------------------------
       
   128 //
       
   129 void CAknFepHwrEngine::DoRecognizeL(const RArray<TPoint>& aTraceData,
       
   130                                     RPointerArray<HBufC>& aCandidates)
       
   131     {
       
   132     if (!iRecognizer)
       
   133         {
       
   134         return;
       
   135         }
       
   136         
       
   137     TPoint ctrlStrokeEndMark = iOwner->StrokeEndMarkFromControl();
       
   138     
       
   139     if (!iRecognizerInited)
       
   140         {
       
   141         DoIdleConstructL();
       
   142         }
       
   143         
       
   144     if (ctrlStrokeEndMark != iRecognizer->StrokeEndMark())
       
   145         {
       
   146         ConvertStrokeEndMark(CONST_CAST(RArray<TPoint>&, aTraceData), 
       
   147                              iOwner->StrokeEndMarkFromControl(), 
       
   148                              iRecognizer->StrokeEndMark());
       
   149         iOwner->SetStrokeEndMark(); // make control's stroke end mark info same to engine
       
   150         }
       
   151     
       
   152     aCandidates.ResetAndDestroy();
       
   153     
       
   154     TInt primaryCount;  
       
   155     TBuf<1> bufBackspace;
       
   156     bufBackspace.Append(KGestureBackspace);
       
   157     TBuf<1> bufDisplayBackspace;
       
   158     bufDisplayBackspace.Append(KDisplayBackspace);
       
   159         
       
   160     if (iOwner->IsNumberOnly())
       
   161         {     
       
   162         if ( iNumberMode == EAknEditorPlainNumberModeKeymap )
       
   163             {
       
   164             TBuf<1> bufEnter;
       
   165             bufEnter.Append( KGestureEnter );
       
   166             TBuf<1> bufSpace;
       
   167             bufSpace.Append( KGestureSpace );
       
   168             
       
   169             TBuf<13> buf;
       
   170             buf.Append( KNumberSet() );
       
   171             buf.Append( bufBackspace );
       
   172             buf.Append( bufEnter );
       
   173             buf.Append( bufSpace );
       
   174             primaryCount = iRecognizer->RecognizeWithCharSet(
       
   175                 aTraceData, aCandidates, buf );
       
   176             }
       
   177         else
       
   178             {
       
   179             primaryCount = iRecognizer->Recognize(aTraceData, aCandidates);
       
   180             }
       
   181         
       
   182         for ( TInt i = aCandidates.Count() - 1; i >= 0; i-- )
       
   183             {
       
   184             if (aCandidates[i]->Compare(bufBackspace) == 0)
       
   185             	{
       
   186                 *aCandidates[i] = bufDisplayBackspace;
       
   187             	}
       
   188             }
       
   189         
       
   190         if (iCustomKeymap)
       
   191             {
       
   192             for(TInt i=0; i<aCandidates.Count(); i++)
       
   193                 {
       
   194                 if( iCustomKeymap->Find(*aCandidates[i]) == KErrNotFound )
       
   195                     {
       
   196                     delete aCandidates[i];
       
   197     		    	aCandidates.Remove(i);
       
   198     		    	primaryCount--;
       
   199     		    	i--;
       
   200                     }
       
   201                 }
       
   202             }
       
   203                 	
       
   204         for (TInt i = 0; i < primaryCount-iTotalCandidateNum; i++)
       
   205             {
       
   206             delete aCandidates[iTotalCandidateNum];
       
   207             aCandidates.Remove(iTotalCandidateNum);
       
   208             }
       
   209         return;
       
   210         }
       
   211 
       
   212     primaryCount = iRecognizer->Recognize(aTraceData, aCandidates); 
       
   213     
       
   214     // remove uncessary primary candidate
       
   215     TInt removePos = iTotalCandidateNum - (iRangeCount - 1);        
       
   216     if (removePos >= 0)
       
   217         {
       
   218         for (TInt i = 0; i < primaryCount - removePos; i++)
       
   219             {
       
   220             delete aCandidates[removePos];
       
   221             aCandidates.Remove(removePos);
       
   222             }
       
   223         }     
       
   224 
       
   225     // filter recognized candidate, set start position for all ranges    
       
   226     TPtrC ptr(KSeparator);
       
   227     
       
   228     // remove uncessary aux candidate, including range separator 
       
   229     for (TInt i=0; i<aCandidates.Count(); i++)
       
   230         {
       
   231         if (aCandidates[i]->Compare(bufBackspace) == 0)
       
   232         	{
       
   233         	// convert backspace returned by engine, to make sure it display correctly.
       
   234             *aCandidates[i] = bufDisplayBackspace;
       
   235         	}
       
   236         
       
   237         else if ( (aCandidates[i]->CompareC(ptr) == 0) )
       
   238             {
       
   239             // remove separator from candidate list
       
   240             delete aCandidates[i];
       
   241             aCandidates.Remove(i);
       
   242             }
       
   243         }
       
   244     
       
   245     TPtrC dashPtr(KDash);
       
   246     TPtrC solidusPtr(KSolidus);
       
   247     
       
   248     // not allowing '-' to be the first char in chinese range 
       
   249     // not allowing '/' to be the first char in English and Number range 
       
   250     if ( ( iPremaryRange == ERangeNative ) && (aCandidates[0]->Compare(dashPtr) == 0) )
       
   251         {
       
   252         *aCandidates[0] = *aCandidates[1];
       
   253         *aCandidates[1] = dashPtr;
       
   254         }
       
   255     else if ( ( (iPremaryRange == ERangeEnglish)||(iPremaryRange == ERangeNumber) ) 
       
   256         && (aCandidates[0]->Compare(solidusPtr) == 0) )
       
   257         {
       
   258         *aCandidates[0] = *aCandidates[1];
       
   259         *aCandidates[1] = solidusPtr;
       
   260         }
       
   261     }
       
   262 
       
   263 // ---------------------------------------------------------
       
   264 // Judge if candidate exist in given position
       
   265 // ---------------------------------------------------------
       
   266 //
       
   267 TBool CAknFepHwrEngine::CandidateExisted()
       
   268     {
       
   269 	return iPtiEngine->MoreCandidatePages();
       
   270     }
       
   271 
       
   272 // ---------------------------------------------------------
       
   273 // Do predictive using trigger string
       
   274 // ---------------------------------------------------------
       
   275 //
       
   276 void CAknFepHwrEngine::DoPredictiveL(const TDesC& aTriggerStr, 
       
   277                                      RPointerArray<HBufC>& aPredictives,
       
   278                                      TBool aNextPage)
       
   279     {
       
   280     // predictive only valid for Chinese
       
   281     if (((iLanguage == ELangPrcChinese) || 
       
   282         (iLanguage == ELangTaiwanChinese) || 
       
   283         (iLanguage == ELangHongKongChinese)) &&
       
   284         (iPtiEngine))
       
   285         {
       
   286         // activate correct pti language according to given language
       
   287         
       
   288         if (!aNextPage)
       
   289             {
       
   290         	iPtiEngine->SetCandidatePageLength(K1PagePredictiveCount);
       
   291         	aPredictives.ResetAndDestroy();
       
   292         	
       
   293         	if(!iPtiEngine->SetPredictiveChineseChar(aTriggerStr))
       
   294         	    {
       
   295         	    return;
       
   296         	    }
       
   297             }
       
   298         else
       
   299             {
       
   300             if (!iPtiEngine->NextCandidatePage())
       
   301                 {
       
   302             	return;
       
   303                 }
       
   304             }
       
   305             
       
   306         TPtrC ptr = iPtiEngine->CandidatePage();    
       
   307         
       
   308         if ((iPtiEngine->InputMode() == EPtiEnginePinyinByPhrase) || 
       
   309             (iPtiEngine->InputMode() == EPtiEngineStrokeByPhrase) ||
       
   310             (iPtiEngine->InputMode() == EPtiEngineZhuyinByPhrase))
       
   311         	{
       
   312         	// phrase input mode
       
   313             TInt start = 0;
       
   314             TInt length = 0;
       
   315         	
       
   316             for (TInt i = 0; i <ptr.Length(); i++)
       
   317                 {
       
   318                 if (ptr[i] == KSegment)
       
   319                     {
       
   320                     TPtrC segment(ptr.Ptr() + start, length);
       
   321                     TRAP_IGNORE(aPredictives.AppendL(segment.AllocL()));
       
   322                     start += (length + 1);
       
   323                     length = 0;
       
   324                     }
       
   325                 else
       
   326                     {
       
   327                     length++;               
       
   328                     }
       
   329                 }
       
   330 
       
   331             if (length)
       
   332                 {
       
   333                 TPtrC segm(ptr.Ptr() + start, length);
       
   334                 TRAP_IGNORE(aPredictives.AppendL(segm.AllocL()));
       
   335                 }
       
   336         	}
       
   337         else
       
   338             {
       
   339             TInt predictiveCandidateNum = ptr.Length();
       
   340 
       
   341             for (TInt i=0; i<predictiveCandidateNum; i++)
       
   342                 {
       
   343                 aPredictives.Append(ptr.Mid(i,1).AllocL());
       
   344                 }
       
   345             }	
       
   346         }
       
   347     }
       
   348 
       
   349 // ---------------------------------------------------------
       
   350 // Set primary and auxiliary ranges for hwr engine
       
   351 // ---------------------------------------------------------
       
   352 //
       
   353 void CAknFepHwrEngine::SetRanges(const RArray<TInt>& aPermittedRanges)
       
   354     {
       
   355     if (!iRecognizerInited)
       
   356         {
       
   357     	iNeedSetRange = ETrue;
       
   358     	iPermittedRanges.Reset();
       
   359     	
       
   360     	for (TInt i = 0; i < aPermittedRanges.Count(); i++)
       
   361     	    {
       
   362             iPermittedRanges.Append(aPermittedRanges[i]);
       
   363     	    }
       
   364     	
       
   365     	return;    
       
   366         }
       
   367 
       
   368     if ((aPermittedRanges.Count() > 0) && (iRecognizer))
       
   369         {
       
   370         iPremaryRange = aPermittedRanges[0];
       
   371         iRangeCount = aPermittedRanges.Count();
       
   372 
       
   373         TRecognitionRange range;
       
   374 
       
   375         SetRecognitionRange(aPermittedRanges[0], range);
       
   376         iRecognizer->SetRange(range);
       
   377 
       
   378         // set auxiliary ranges for hwr engine
       
   379         for (TInt i=1; i<aPermittedRanges.Count(); i++)
       
   380             {
       
   381             SetRecognitionRange(aPermittedRanges[i], range);
       
   382 
       
   383             iRecognizer->AddAuxiliaryRange(range);
       
   384             }
       
   385         
       
   386         SetCase(iCase);
       
   387         }
       
   388     }
       
   389     
       
   390 // ---------------------------------------------------------
       
   391 // Set case
       
   392 // ---------------------------------------------------------
       
   393 //
       
   394 void CAknFepHwrEngine::SetCase(TInt aCase)
       
   395     {
       
   396     if (!iRecognizerInited)
       
   397         {
       
   398     	iNeedSetCase = ETrue;
       
   399     	iCase = aCase;
       
   400     	return;
       
   401         }
       
   402     
       
   403     // set letter to lower first when LowerCase
       
   404     // set letter to upper first when UpperCase and TextCase
       
   405     if (iRecognizer)
       
   406         {
       
   407         if (aCase == ELowerCase)
       
   408             {
       
   409             iRecognizer->SetFirstLetterOrder(ELowerFirst);
       
   410             }
       
   411         else
       
   412             {
       
   413             iRecognizer->SetFirstLetterOrder(EUpperFirst);
       
   414             }
       
   415         
       
   416         iCase = aCase;
       
   417         }
       
   418     }
       
   419 
       
   420 // ---------------------------------------------------------
       
   421 // Set number mode for hwr engine
       
   422 // ---------------------------------------------------------
       
   423 //
       
   424 void CAknFepHwrEngine::SetNumberMode(const TAknEditorNumericKeymap& aNumberMode)
       
   425     {
       
   426     iNumberMode = aNumberMode;
       
   427     
       
   428     if (!iRecognizerInited)
       
   429         {
       
   430         iNeedSetNumberMode = ETrue;
       
   431     	
       
   432     	return;
       
   433         }
       
   434 
       
   435     if (iRecognizer)
       
   436         {
       
   437         iRecognizer->SetNumberMode(aNumberMode);
       
   438         if( aNumberMode !=  EKeymapFromResource)
       
   439             {
       
   440             ResetCustomKeyMap();
       
   441             }
       
   442         }
       
   443     }
       
   444 
       
   445 // ---------------------------------------------------------
       
   446 // Get stroke end mark from hwr engine
       
   447 // ---------------------------------------------------------
       
   448 //
       
   449 TPoint CAknFepHwrEngine::StrokeEndMark() const
       
   450     {
       
   451     if (iRecognizer)
       
   452         {
       
   453         return iRecognizer->StrokeEndMark();
       
   454         }
       
   455     else
       
   456         {
       
   457         return TPoint(KInvalidStrokeEndMarkX, KInvalidStrokeEndMarkY);
       
   458         }
       
   459     }
       
   460 
       
   461 // ---------------------------------------------------------
       
   462 // Set primary candidate num for hwr engine
       
   463 // ---------------------------------------------------------
       
   464 //
       
   465 TInt CAknFepHwrEngine::SetPrimaryCandidateNum(TInt aNum)
       
   466     {
       
   467     if (iRecognizer)
       
   468         {
       
   469         return iRecognizer->SetCandidateNum(aNum);
       
   470         }
       
   471     else
       
   472         {
       
   473         return KErrGeneral;
       
   474         }
       
   475     }
       
   476 
       
   477 // ---------------------------------------------------------
       
   478 // Set aux candidate num that should be shown
       
   479 // ---------------------------------------------------------
       
   480 //
       
   481 TInt CAknFepHwrEngine::SetAuxCandidateNum(TInt aNum)
       
   482     {
       
   483     if (iRecognizer)
       
   484         {
       
   485         return iRecognizer->SetAuxCandidateNum(aNum);
       
   486         }
       
   487     else
       
   488         {
       
   489         return KErrGeneral;
       
   490         }
       
   491     }
       
   492 
       
   493 
       
   494 // ---------------------------------------------------------
       
   495 // Get aux candidate num that should be shown
       
   496 // ---------------------------------------------------------
       
   497 //
       
   498 TInt CAknFepHwrEngine::GetAuxCandidateNum()
       
   499     {
       
   500     if (iRecognizer)
       
   501         {
       
   502         return iRecognizer->GetAuxCandidateNum();
       
   503         }
       
   504     else
       
   505         {
       
   506         return KErrGeneral;
       
   507         }
       
   508     }
       
   509         
       
   510 // ---------------------------------------------------------
       
   511 // Set total candidate num that should be shown
       
   512 // ---------------------------------------------------------
       
   513 //
       
   514 TInt CAknFepHwrEngine::SetCandidateNum(TInt aNum)
       
   515     {
       
   516     if (aNum > 0)
       
   517         {
       
   518         iTotalCandidateNum = aNum;
       
   519         return KErrNone;
       
   520         }
       
   521     else
       
   522         {
       
   523         return KErrGeneral;
       
   524         }    
       
   525     }
       
   526     
       
   527 // ---------------------------------------------------------
       
   528 // Set language
       
   529 // ---------------------------------------------------------
       
   530 //
       
   531 void CAknFepHwrEngine::SetLanguageL(TInt aLanguage)
       
   532     {
       
   533     if ( (iLanguage == aLanguage) ||
       
   534          (aLanguage != ELangPrcChinese && 
       
   535           aLanguage != ELangHongKongChinese && 
       
   536           aLanguage != ELangTaiwanChinese) )
       
   537         {
       
   538         return;
       
   539         }
       
   540         
       
   541     iLanguage = aLanguage;
       
   542   switch (iLanguage)
       
   543     {
       
   544     case ELangPrcChinese:
       
   545         {
       
   546         if (iPtiEngine->ActivateLanguageL(iLanguage, EPtiEnginePinyinByPhrase) != KErrNone)
       
   547         	{
       
   548         	iPtiEngine->ActivateLanguageL(iLanguage, EPtiEnginePinyin);
       
   549         	}
       
   550         }
       
   551         break;
       
   552     case ELangHongKongChinese:
       
   553         if (iPtiEngine->ActivateLanguageL(iLanguage, EPtiEngineStrokeByPhrase) != KErrNone)
       
   554         	{
       
   555         	iPtiEngine->ActivateLanguageL(ELangHongKongChinese, EPtiEngineStroke);
       
   556         	}
       
   557         break;
       
   558     case ELangTaiwanChinese:
       
   559         if (iPtiEngine->ActivateLanguageL(iLanguage, EPtiEngineZhuyinByPhrase) != KErrNone)
       
   560         	{
       
   561         	iPtiEngine->ActivateLanguageL(ELangTaiwanChinese, EPtiEngineZhuyin);
       
   562         	}
       
   563         break;
       
   564     default:
       
   565         return;
       
   566     }
       
   567 
       
   568     iRecognizerInited = EFalse;
       
   569     
       
   570     iIdle ->Start(TCallBack(BackgroundTaskL,this));
       
   571     }
       
   572     
       
   573 // ---------------------------------------------------------------------------
       
   574 // CAknFepHwrEngine::DoIdleConstructL
       
   575 // Do background construct.
       
   576 // ---------------------------------------------------------------------------
       
   577 //
       
   578 void CAknFepHwrEngine::DoIdleConstructL()
       
   579     {
       
   580     if (iRecognizerInited)
       
   581         {
       
   582         return;
       
   583         }
       
   584 
       
   585 	iRecognizer = iPtiEngine->GetHwrRecognizerL(TLanguage(iLanguage));
       
   586 	iRecognizerInited = ETrue;
       
   587 	iOwner->SetStrokeEndMark();
       
   588 	SetPrimaryCandidateNum(KPremaryCandidateCount);
       
   589 	SetAuxCandidateNum(KAuxCandidateCount);
       
   590 	
       
   591     if (iNeedSetRange)
       
   592         {
       
   593         SetRanges(iPermittedRanges);
       
   594         iNeedSetRange = EFalse;
       
   595         iPermittedRanges.Reset();
       
   596         }
       
   597     
       
   598     if (iNeedSetCase)
       
   599         {
       
   600     	SetCase(iCase);
       
   601     	iNeedSetCase = EFalse;
       
   602         }
       
   603     
       
   604     if (iNeedSetNumberMode)
       
   605         {
       
   606     	SetNumberMode(TAknEditorNumericKeymap(iNumberMode));
       
   607     	iNeedSetNumberMode = EFalse;
       
   608         }
       
   609     }
       
   610 
       
   611 // ---------------------------------------------------------------------------
       
   612 // CAknFepHwrEngine::BackgroundConstructL
       
   613 // Do background construct.
       
   614 // ---------------------------------------------------------------------------
       
   615 //
       
   616 TInt CAknFepHwrEngine::BackgroundTaskL(TAny* aPtr)
       
   617     {
       
   618     CAknFepHwrEngine* self = static_cast<CAknFepHwrEngine*>(aPtr);
       
   619     self->DoIdleConstructL();
       
   620     return EFalse;
       
   621     }
       
   622     
       
   623 // ---------------------------------------------------------
       
   624 // Set recognition range for hwr engine
       
   625 // ---------------------------------------------------------
       
   626 //
       
   627 void CAknFepHwrEngine::SetRecognitionRange(const TInt aRange, TRecognitionRange& aRecognitionRange)
       
   628     {
       
   629     aRecognitionRange.iLanguage = TLanguage(iLanguage);
       
   630 
       
   631     switch (aRange)
       
   632         {
       
   633         case ERangeNative:
       
   634 
       
   635             if (iLanguage == ELangPrcChinese)
       
   636                 {
       
   637                 aRecognitionRange.iSubRange = EPtiRangePRCChinese;
       
   638                 }
       
   639             else
       
   640                 {
       
   641                 if (iLanguage == ELangHongKongChinese)
       
   642                     {
       
   643                     aRecognitionRange.iSubRange = EPtiRangeHKChinese;
       
   644                     }
       
   645                 else
       
   646                     {
       
   647                     aRecognitionRange.iSubRange = EPtiRangeTWChinese;
       
   648                     }
       
   649                 }
       
   650 
       
   651             break;
       
   652         case ERangeEnglish:
       
   653             aRecognitionRange.iLanguage = ELangEnglish;
       
   654             aRecognitionRange.iSubRange = EPtiRangeLatin;
       
   655 
       
   656             break;
       
   657         case ERangeNumber:
       
   658             aRecognitionRange.iSubRange = EPtiRangeNumber;
       
   659 
       
   660             break;
       
   661         case ERangeSymbol:
       
   662             // The symbol mode is associated with iLanguage instead of iPremaryRange
       
   663             aRecognitionRange.iLanguage = TLanguage(iLanguage);
       
   664             aRecognitionRange.iSubRange = EPtiRangeSymbol;
       
   665 
       
   666             break;
       
   667         default:
       
   668             break;
       
   669         }
       
   670     }
       
   671 
       
   672 // ---------------------------------------------------------
       
   673 // Set recognition range for hwr engine
       
   674 // ---------------------------------------------------------
       
   675 //
       
   676 void CAknFepHwrEngine::SetCustomKeymapL(const TDesC& aKeyMap)
       
   677     {
       
   678     delete iCustomKeymap;
       
   679     iCustomKeymap = NULL;
       
   680     iCustomKeymap = HBufC::NewL(aKeyMap.Length() + KNumberSet().Length());
       
   681     iCustomKeymap->Des().Copy(KNumberSet());
       
   682     iCustomKeymap->Des().Append(aKeyMap);
       
   683     }
       
   684 
       
   685 // ---------------------------------------------------------
       
   686 // Set recognition range for hwr engine
       
   687 // ---------------------------------------------------------
       
   688 //
       
   689 void CAknFepHwrEngine::ResetCustomKeyMap()
       
   690     {
       
   691     delete iCustomKeymap;
       
   692     iCustomKeymap = NULL;
       
   693     }
       
   694 TInt CAknFepHwrEngine::SetInputAreaSize(TSize& aSize)
       
   695     {
       
   696     if(iRecognizer)
       
   697         {
       
   698         return iRecognizer->SetInputAreaSize(aSize);        
       
   699         }
       
   700     else
       
   701         {
       
   702         return KErrNotFound;
       
   703         }        
       
   704     }
       
   705 TInt CAknFepHwrEngine::SetScreenSize(TSize& aSize)    
       
   706     {
       
   707       if(iRecognizer)
       
   708         {
       
   709         return iRecognizer->SetScreenSize(aSize);        
       
   710         }
       
   711     else
       
   712         {
       
   713         return KErrNotFound;
       
   714         }  
       
   715     }
       
   716     
       
   717 //End Of File