textinput/ptienginev2/src/PtiEngineImpl.cpp
branchRCL_3
changeset 20 ebd48d2de13c
parent 16 857bebeecec0
child 21 ecbabf52600f
--- a/textinput/ptienginev2/src/PtiEngineImpl.cpp	Thu Aug 19 10:15:25 2010 +0300
+++ b/textinput/ptienginev2/src/PtiEngineImpl.cpp	Tue Aug 31 15:31:50 2010 +0300
@@ -38,7 +38,6 @@
 #include <AknUtils.h>
 #include <e32property.h>
 #include <AknFepInternalCRKeys.h>
-#include <AknFepInternalPSKeys.h>
 #include <AvkonInternalCRKeys.h>
 
 const TInt KDefaultLanguageGran = 5;
@@ -134,46 +133,6 @@
 
 // Local method declarations.
 LOCAL_C TInt RemapVietnameseAccentedCharacter(TUint16 aChr);
-LOCAL_C TBool IsRegionalLang(TInt aVariantCode, TInt& aMainCode)
-    {   
-    TBool ret = ETrue;
-    switch(aVariantCode)
-        {
-        case ELangBrazilianPortuguese:
-            aMainCode = ELangPortuguese;
-            break;
-        case ELangCanadianFrench:
-            aMainCode = ELangFrench;
-            break;
-        case ELangLatinAmericanSpanish:
-            aMainCode = ELangSpanish;
-            break;
-        case ELangEnglish_Taiwan:
-        case ELangEnglish_HongKong:
-        case ELangEnglish_Prc:
-            aMainCode = ELangEnglish;
-            break;
-        default:
-            aMainCode = aVariantCode; 
-            ret = EFalse;
-        }
-    return ret;
-    }
-LOCAL_C TBool AlreadyExistLang(CArrayPtrFlat<CPtiCoreLanguage>* aLangArray, TInt aLangCode)
-    {
-    if (aLangArray)
-        {
-        for (TInt i=0; i < aLangArray->Count(); i++)
-            {
-            if (aLangArray->At(i)->LanguageCode() == aLangCode)
-                {
-                return ETrue;
-                }
-            }
-        }
-    return EFalse;
-    }
-const TUid KXt9ImplementationUid = {0x102830B9};
 	
 //
 // CPtiEngineImpl implementation
@@ -326,21 +285,13 @@
 #endif
 		for (TInt i = 0; i < count; i++)
 			{
-		    TInt code = 0;		    
 			if ((iLanguages->At(i)->LanguageCode() != ELangNumeric)
 #ifdef RD_HINDI_PHONETIC_INPUT
 				&& (iLanguages->At(i)->LanguageCode() != KLangHindiPhonetic)
 #endif
                 )
 				{
-			    if(IsRegionalLang(iLanguages->At(i)->LanguageCode(),code))
-                    {
-                    if(AlreadyExistLang(iLanguages,code))
-                        {
-                        continue;
-                        }
-                    }
-				aResult->AppendL(code);
+				aResult->AppendL(iLanguages->At(i)->LanguageCode());
 #ifdef RD_HINDI_PHONETIC_INPUT
 				if (iLanguages->At(i)->LanguageCode() == ELangHindi && isIndicPhoneticInputPresent)
 					aResult->AppendL(KLangHindiPhonetic);
@@ -712,36 +663,14 @@
 			return KErrNoSuitableCore;	
 			}
 		}
-	
-	if (iInputMode != aMode)
-		{
-		OnInputModeChanged(iInputMode, aMode);
-		iInputMode = aMode;		
-		}
+
+    iInputMode = aMode;	
 
 	TFileName temp;
 	temp.Copy(iTextBuffer);
 	return SetCurrentWord( temp );
 	}
 
-void CPtiEngineImpl::OnInputModeChanged(TPtiEngineInputMode /*aOldMode*/, TPtiEngineInputMode aNewMode)
-	{
-	if (aNewMode == EPtiEngineQwertyPredictive)
-		{
-		HBufC16* oldTextBuf = iTextBuffer.Alloc(); 
-		ClearCurrentWord();
-		if (oldTextBuf)
-			{
-			// why assigned here? eh, I don't want to do that either.
-			// SetCurrentWord will use core(), which will use iInputMode, and 
-			// obviously, the core should return the new core, that is why.
-			iInputMode = aNewMode;
-		
-			SetCurrentWord(oldTextBuf->Des());
-			delete oldTextBuf;
-			}
-		}
-	}
 
 // ---------------------------------------------------------------------------
 // CPtiEngineImpl::CountToneMarks
@@ -1107,8 +1036,9 @@
 		case EPtiEngineStrokePhraseHalfQwerty:
 		case EPtiEngineStrokePhraseQwerty:
 			{
-			TPtiKeyboardType keyboardType = ActiveKeyboardType();
-			TBool IsStokeKey = EFalse;            
+			TPtiKeyboardType keyboardType = EPtiKeyboardNone;
+			TBool IsStokeKey = EFalse;
+            TRAP_IGNORE(keyboardType = ActiveKeyboardTypeL());
              if(EPtiKeyboardQwerty4x10 == keyboardType ||
                      EPtiKeyboardQwerty3x11 == keyboardType )
                  {
@@ -2122,7 +2052,7 @@
 	// Predictive QWERTY (XT9) changes ---->
 	// PtiXt9Core handles the capitalization it self, and it should not be overriden 
 	// byt the PtiEngine.
-	if ( IsCurrentCoreSupportCaseInfo() )
+	if ( iInputMode==EPtiEngineQwertyPredictive )
 	    {
 	    return;
 	    }
@@ -2727,7 +2657,6 @@
 //
 void CPtiEngineImpl::GetModeNameIndexL(TPtiChineseVariant aVariant, RArray<TInt>& aResult)
 	{
-	CleanupClosePushL( aResult );
 	TResourceReader reader;	
 	TFileName fileName;
 
@@ -2774,7 +2703,6 @@
 		}
 
 	CleanupStack::PopAndDestroy(3);   // fsSession, rsFile, rBuffer
-    CleanupStack::Pop();
 	}
 
 
@@ -2957,26 +2885,16 @@
 //	
 void CPtiEngineImpl::GetAvailableLanguagesL(RArray<TInt>& aResult)
 	{
-	CleanupClosePushL( aResult ); 
 	aResult.Reset();
 	
 	const TInt count = iLanguages->Count();
 	for (TInt i = 0; i < count; i++)
 		{
-	    TInt code = 0;
 		if (iLanguages->At(i)->LanguageCode() != ELangNumeric)
 			{
-		    if(IsRegionalLang(iLanguages->At(i)->LanguageCode(),code))
-		        {
-		        if(AlreadyExistLang(iLanguages,code))
-		            {
-		            continue;
-			        }
-		        }	
-			aResult.AppendL(code);
-		    }	
-		}
-    CleanupStack::Pop();
+			aResult.AppendL(iLanguages->At(i)->LanguageCode());
+			}
+		}	
 	}
 
 
@@ -3335,14 +3253,13 @@
                                                TBool aUseExtendedSet,
                                                TPtiKeyboardType aKeyboardType)
 	{
-	CleanupClosePushL( aResult );
 	aResult.Reset();		
 	TPtiNumericKeyBinding bind;		
 	
 	TPtiKeyboardType keyboardType = aKeyboardType;
 	if (keyboardType == EPtiKeyboardNone)
 	    {
-	    keyboardType = ActiveKeyboardType();
+	    keyboardType = ActiveKeyboardTypeL();
 	    
 	    if (keyboardType == EPtiKeyboard12Key ||
 	        keyboardType == EPtiKeyboardNone)
@@ -3354,7 +3271,6 @@
 	if (keyboardType == EPtiKeyboard12Key ||
 	    keyboardType == EPtiKeyboardNone)
 	    {
-		CleanupStack::Pop();
 	    // No qwerty data available, can't go on.
 	    return;
 	    }
@@ -3373,7 +3289,6 @@
 			bind = NumericModeKeysForNonLatinNumberLanguages[i];
 			User::LeaveIfError(aResult.Append(bind));		
 			}	
-		CleanupStack::Pop();
 		
 		return;			
 		}
@@ -3457,7 +3372,6 @@
                 }				
 			}			      
 		}		
-	CleanupStack::Pop();
 	}	
 	
 	
@@ -3810,7 +3724,9 @@
         }
 		    		    
     return EPtiKeyboardNone;*/
-	TInt keyboardLayout = ActiveKeyboardType();          
+	TInt keyboardLayout = 0;
+    
+    RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
 
     if (keyboardLayout <= 0 ||
         keyboardLayout > EPtiKeyboardMaxLayout - 1)
@@ -3901,7 +3817,6 @@
 void CPtiEngineImpl::KeyboardTypesSupportedByLanguageL(TInt aLanguage,
                                                        RArray<TPtiKeyboardType>& aResult)
     {
-	CleanupClosePushL( aResult );
     CPtiCoreLanguage* lang = NULL;
     
     if (iCurrentLanguage && iCurrentLanguage->LanguageCode() == aLanguage)
@@ -3963,51 +3878,30 @@
             User::LeaveIfError(aResult.Append(EPtiKeyboardHalfQwerty));
             }            
         }                
-    CleanupStack::Pop();
     }
 
 
 // ---------------------------------------------------------------------------
-// CPtiEngineImpl::ActiveKeyboardType
+// CPtiEngineImpl::ActiveKeyboardTypeL
 // 
 // ---------------------------------------------------------------------------
 //
-TPtiKeyboardType CPtiEngineImpl::ActiveKeyboardType() const
+TPtiKeyboardType CPtiEngineImpl::ActiveKeyboardTypeL()
     {    
-	TInt keyboardType = EPtiKeyboardNone;
-#ifdef RD_SCALABLE_UI_V2
-	// Get physical keyboard type
-	RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardType );
-
-	// When active keyboard is virtual keyboard, 
-	// need to get the active virtual keyboard type 
-	// and set keyboardType again.
-	
-	// When the default physical keyboard is 0, 
-	// it means that there is no physical keyboard,
-	// also need to get the active virtual keyboard type.
-	TInt isQwertyOn = 0;
-	RProperty::Get(KCRUidAvkon, KAknQwertyInputModeActive, isQwertyOn);	
-	TInt isVirtualInputActive = 0;
-	RProperty::Get( KPSUidAknFep, KAknFepTouchInputActive, 
-					isVirtualInputActive );    
-	if (( isVirtualInputActive > 0 || keyboardType == 0) && !isQwertyOn)
-		{
-		// Active keyboard is virtual keyboard          
-		RProperty::Get( KPSUidAknFep, KAknFepVirtualKeyboardType, 
-						keyboardType );      
-		}
-#else
-	// Get physical keyboard type
-	RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardType );	    
-#endif
-
-	if ( keyboardType <= 0 || keyboardType >= EPtiKeyboardMaxLayout )
-		{
-	    keyboardType = EPtiKeyboardNone;
-		}        
-	return (TPtiKeyboardType)keyboardType;
+    // Qwerty Keyboard layout
+    TInt keyboardLayout = 0;
+    
+    RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
+
+    if (keyboardLayout <= 0 ||
+        keyboardLayout > EPtiKeyboardMaxLayout - 1)
+        {
+        return EPtiKeyboardNone;
+        }
+        
+    return (TPtiKeyboardType)keyboardLayout;
     }
+
         
 // ---------------------------------------------------------------------------
 // CPtiEngineImpl::GetNumericModeKeysForQwertyL
@@ -4319,16 +4213,5 @@
     
     }
 #endif //FF_DUAL_LANGUAGE_SUPPORT
-TBool CPtiEngineImpl::IsCurrentCoreSupportCaseInfo()
-    {
-    if ( Core() )
-        {
-        if ( Core()->GetCoreInfo()->Uid() == KXt9ImplementationUid.iUid )
-            {
-            return ETrue;
-            }
-        }
-    return EFalse;
-    }
 // End of file