fep/aknfep/src/aknfepuiinputstateindicphoneticqwerty.cpp
changeset 40 2cb9bae34d17
parent 31 f1bdd6b078d1
child 49 37f5d84451bd
equal deleted inserted replaced
31:f1bdd6b078d1 40:2cb9bae34d17
     1 /*
       
     2 * Copyright (c) 2004 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 *       Provides the TAknFepInputStateIndicPhoneticQwerty methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 #include "aknfepuiinputstateindicphoneticqwerty.h"
       
    31 #include "AknFepUIManagerStateInterface.h"      //MAknFepUIManagerStateInterface
       
    32 #include "AknFepManagerUIInterface.h"           //MAknFepManagerUIInterface
       
    33 #include "AknFepCaseManager.h"
       
    34 #include "AknFepUiIndicInputManager.h"
       
    35 #include "AknFepPanic.h"
       
    36 
       
    37 #include <e32err.h>
       
    38 #include <PtiEngine.h>
       
    39 #include <PtiDefs.h>
       
    40 #include <PtiKeyMappings.h>
       
    41 #include <CentralRepository.h> 
       
    42 #include <Languages.hrh>
       
    43 
       
    44 TAknFepInputStateIndicPhoneticQwerty::
       
    45 TAknFepInputStateIndicPhoneticQwerty(MAknFepUIManagerStateInterface* aOwner)
       
    46     :TAknFepInputStateQwerty(aOwner)
       
    47     {
       
    48     iState = EInitial;
       
    49     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    50     ptiengine->ClearCurrentWord();
       
    51     TRAP_IGNORE(ptiengine->ActivateLanguageL(KLangHindiPhonetic,
       
    52                                              EPtiEngineInputModeIndicPhoneticQwerty));//KLangHindiPhonetic
       
    53     ptiengine->SetCase(EPtiCaseLower);
       
    54     }
       
    55 
       
    56 TBool TAknFepInputStateIndicPhoneticQwerty::HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
    57     {
       
    58     TBool ret = ETrue;
       
    59     CPtiEngine* ptiengine = iOwner->PtiEngine();
       
    60     __ASSERT_DEBUG(ptiengine != NULL,AknFepPanic(EAknFepPanicNoValidPtiEngine));
       
    61     
       
    62     MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
    63     __ASSERT_DEBUG(fepMan != NULL,AknFepPanic(EAknFepPanicNoValidFepManager));
       
    64          
       
    65 	if(!IsQwertyKey(aKey)|| 
       
    66 		fepMan->IsOnlyNumericPermitted()||
       
    67 		fepMan->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed))
       
    68 		{
       
    69 		fepMan->CommitInlineEditL();
       
    70 		ptiengine->HandleCommandL(EPtiCommandBreakSyllable, NULL );	
       
    71 		ret = TAknFepInputStateQwerty::HandleKeyL(aKey, aLength);
       
    72 		}
       
    73 	else if (aKey == EPtiKeyQwertySpace ||aKey == EStdKeyEnter)
       
    74 		{    
       
    75 		TInt languageCode = 0;
       
    76     	MPtiLanguage* curlang = ptiengine->CurrentLanguage();
       
    77 	    if (curlang)
       
    78 	        {
       
    79 	        languageCode = curlang->LanguageCode();
       
    80 	        }
       
    81 
       
    82 		// Space clears Explicite halant for North Indian Languages.
       
    83 		if(IsToRemoveHalantForLanguage(languageCode))
       
    84 			{
       
    85 			RemoveHalantL(TLanguage(languageCode));
       
    86 			fepMan->CommitInlineEditL();
       
    87 			}
       
    88 		ptiengine->HandleCommandL(EPtiCommandBreakSyllable, NULL );	
       
    89 		ret = EFalse;
       
    90 		}
       
    91 	else
       
    92 		{
       
    93 		TBool isCharacter = ETrue;
       
    94 	    if (!iData)
       
    95 	        {
       
    96 	        isCharacter = IsCharacterKey(aKey);
       
    97 	        }
       
    98 	        
       
    99 		HandleCaseChange(aKey,isCharacter);
       
   100 	    iData = aKey;
       
   101 
       
   102 	    TBool keyEventHandledByFep = ETrue;
       
   103 	    
       
   104 		TPhoneticArg arg;
       
   105 	    TBuf<CAknFepManager::EMaximumFepWordLength> destinationbuf;
       
   106 	    destinationbuf.Zero();               
       
   107 	    
       
   108 		TInt errorcode = 0;   
       
   109 	    
       
   110 	    if(!((aKey == EPtiKeyStar) || 
       
   111 	    	(aKey == EPtiKeyQwerty8 && fepMan->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode)) || 
       
   112 	    	(aKey == EPtiKeyQwertySpace)))
       
   113 	    	{
       
   114 	        TPtrC string = ptiengine->AppendKeyPress((TPtiKey)aKey);
       
   115 	        arg.iChar = string[0];
       
   116 	        arg.iDest = & destinationbuf;
       
   117 	        errorcode = ptiengine->HandleCommandL(EPtiCommandGetPhoneticText,REINTERPRET_CAST( TAny*, &arg));
       
   118 	        }
       
   119 	    else
       
   120 	        {
       
   121 	    	errorcode = ptiengine->HandleCommandL(EPtiCommandBreakSyllable, NULL );	
       
   122 	    	}
       
   123 	    	
       
   124 	    switch(errorcode)
       
   125 	    	{
       
   126 	    	case KErrNone:
       
   127 	    		{
       
   128 	    		switch(arg.iState)
       
   129 	    			{
       
   130 	    			case EIndicSyllableStateInsideSyllable:
       
   131 	    				{            				
       
   132 	        			if (destinationbuf.Length())
       
   133 				            {
       
   134 				            fepMan->NewCharacterSequenceL(destinationbuf,
       
   135 				                                          EIndicInputResponsePhoneticQwertyText);
       
   136 				            }
       
   137 	    				}
       
   138 	    			break;
       
   139 	    			case EIndicSyllableStateSyllableBroken:
       
   140 	    				{
       
   141 	  					fepMan->CommitInlineEditL();
       
   142 	    				if (destinationbuf.Length())
       
   143 				            {
       
   144 				            fepMan->NewCharacterSequenceL(destinationbuf,
       
   145 				                                          EIndicInputResponsePhoneticQwertyText);
       
   146 				            }	
       
   147 	    				}
       
   148 	    			break;
       
   149 	    			default:
       
   150 	    			break;
       
   151 	    			}
       
   152 	    		}
       
   153 	    	break;
       
   154 	    	case KErrOverflow:
       
   155 	    		{
       
   156 				fepMan->NewCharacterSequenceL(destinationbuf,EIndicInputResponsePhoneticQwertyText);    		
       
   157 	    		fepMan->CommitInlineEditL();
       
   158 	        	ptiengine->HandleCommandL(EPtiCommandClearPhoneticBuffer,NULL);
       
   159 	    		}
       
   160 	    	break;
       
   161 	    	default:
       
   162 	    	break;
       
   163 	    	}
       
   164 	    ptiengine->ClearCurrentWord();
       
   165 	    CAknFepCaseManager* caseMan = iOwner->CaseMan(); 
       
   166 	    iOwner->CaseMan()->UpdateCase(ENullNaviEvent);
       
   167 		}	
       
   168 
       
   169     return ret;
       
   170     }
       
   171     
       
   172 TBool TAknFepInputStateIndicPhoneticQwerty::IsQwertyKey(const TInt aKey)
       
   173     {
       
   174     TBool response = EFalse;
       
   175     if ( (aKey >= EPtiKeyQwertyA && aKey <= EPtiKeyQwertyZ)||
       
   176         (aKey == EPtiKeyQwertyFullstop) ||
       
   177         (aKey == EPtiKeyStar || 
       
   178         (aKey == EPtiKeyQwerty8 && 
       
   179         iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode))) ||
       
   180         aKey == EPtiKeyQwertySpace || 
       
   181         aKey == EStdKeyEnter)
       
   182         {
       
   183         response = ETrue;
       
   184         }
       
   185     return response;
       
   186     }
       
   187     
       
   188 void TAknFepInputStateIndicPhoneticQwerty::RemoveHalantL(TLanguage aLanguage)
       
   189 	{
       
   190 	MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   191     if(TAknFepUiIndicInputManager::IsCharVirama(fepMan->PreviousChar(), aLanguage))
       
   192     	{
       
   193     	fepMan->RemovePreviousCharacterL();	
       
   194     	}
       
   195 	}
       
   196 	
       
   197 TBool TAknFepInputStateIndicPhoneticQwerty::IsToRemoveHalantForLanguage(TInt aLanguage)
       
   198 	{
       
   199 	TBool ret = EFalse;
       
   200 	switch(aLanguage)
       
   201 		{
       
   202 		case KLangHindiPhonetic:
       
   203 			ret = ETrue;
       
   204 		break;
       
   205 		}
       
   206 	return ret;	
       
   207 	}
       
   208 	
       
   209 	
       
   210 // End of file