textinput/GSLangPlugin/src/PredictiveSettingDialog.cpp
branchRCL_3
changeset 44 ecbabf52600f
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 /*
       
    18  * ============================================================================
       
    19  *  Name     : CGSPredictiveSettingList from AknFepPredictiveSettingList 
       
    20  * ============================================================================
       
    21  */
       
    22 #include <centralrepository.h>
       
    23 #include <AknQueryDialog.h>
       
    24 #include <AknFepInternalCRKeys.h>
       
    25 #include <PtiDefs.h>
       
    26 #include <e32property.h>
       
    27 #include <AvkonInternalCRKeys.h>
       
    28 #include <AknFepGlobalEnums.h>
       
    29 #include "PredictiveSettingDialog.h"
       
    30 #include <aknnotewrappers.h>
       
    31 #include <aknfep.rsg>
       
    32 #include <hlplch.h> // HlpLauncher
       
    33 #include <csxhelp/cp.hlp.hrh> 
       
    34 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    35 #include <uikon/eikctrlstatus.h>
       
    36 #endif
       
    37 
       
    38 CGSPredictiveSettingDialog *CGSPredictiveSettingDialog::NewL(TInt aMenuResId, TInt aConfirmationQueryResId)
       
    39 	{
       
    40 	CGSPredictiveSettingDialog* self = CGSPredictiveSettingDialog::NewLC(aMenuResId, aConfirmationQueryResId);		
       
    41 	CleanupStack::Pop(self);
       
    42 	return self;
       
    43 	}
       
    44 
       
    45 CGSPredictiveSettingDialog *CGSPredictiveSettingDialog::NewLC(TInt aMenuResId, TInt aConfirmationQueryResId)
       
    46 	{
       
    47 	CGSPredictiveSettingDialog* self = new (ELeave) CGSPredictiveSettingDialog(aConfirmationQueryResId);
       
    48 	CleanupStack::PushL(self);
       
    49 	self->ConstructL(aMenuResId);
       
    50     return self;
       
    51 	}
       
    52 
       
    53 void CGSPredictiveSettingDialog::ConstructL( TInt aMenuTitleResourceId )
       
    54 	{
       
    55 	CAknDialog::ConstructL(aMenuTitleResourceId);
       
    56 
       
    57 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__	
       
    58 	iItemCloseEventCheck = CIdle::NewL(CActive::EPriorityStandard);
       
    59 #endif	
       
    60 
       
    61 	}
       
    62 
       
    63 CGSPredictiveSettingDialog ::CGSPredictiveSettingDialog(TInt aConfirmationQueryResId):
       
    64 	iConfirmationQueryResId(aConfirmationQueryResId),
       
    65 	iPredictiveSettingOffQueryNotShown(ETrue)
       
    66 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__	
       
    67 	,iSettingItemInEditingState(EFalse)
       
    68 #endif //__ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__		
       
    69 	{
       
    70 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__	
       
    71 	RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, iOriginalKeyboardLayout);
       
    72 #endif //__ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
    73 	}
       
    74 	
       
    75 CGSPredictiveSettingDialog::~CGSPredictiveSettingDialog()
       
    76 	{
       
    77 	delete iSettingsData;
       
    78 
       
    79 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__	
       
    80 	delete iItemCloseEventCheck;
       
    81 	iItemCloseEventCheck = NULL;
       
    82 #endif
       
    83 		
       
    84 	}
       
    85 
       
    86 
       
    87 SEikControlInfo CGSPredictiveSettingDialog::CreateCustomControlL(TInt /*aControlType*/)
       
    88 {
       
    89 	
       
    90 	// construct the data object the settings list will use
       
    91 	iSettingsData = CGSPredictiveSettingData::NewL();
       
    92 	ReadSettingsDataL();
       
    93 		
       
    94 	iSettingsList = CGSPredictiveSettingList::NewL(*iSettingsData, *this);
       
    95 	
       
    96 	SEikControlInfo controlInfo;
       
    97 	controlInfo.iFlags = EEikControlHasEars;
       
    98 	controlInfo.iTrailerTextId = 0;
       
    99 	controlInfo.iControl = iSettingsList;
       
   100 	STATIC_CAST(CGSPredictiveSettingList*, controlInfo.iControl)->SetContainerWindowL(*this);
       
   101 	
       
   102 	return controlInfo;
       
   103 }
       
   104 
       
   105 
       
   106 CGSPredictiveSettingDialog::TFormControlTypes CGSPredictiveSettingDialog::ConvertCustomControlTypeToBaseControlType(TInt /*aControlType*/) const
       
   107 {
       
   108 	return EPopfieldDerived;
       
   109 }
       
   110 
       
   111 
       
   112 TBool CGSPredictiveSettingDialog::OkToExitL(TInt aButtonId)
       
   113 {
       
   114 	TBool retValue = EFalse;
       
   115 	switch(aButtonId)
       
   116 	{
       
   117 	case EAknSoftkeyBack:
       
   118 		iSettingsList->StoreSettingsL();
       
   119 		SaveSettingsDataL();
       
   120 		retValue = ETrue;
       
   121 		break;
       
   122 	
       
   123 	case EAknSoftkeyOptions:
       
   124 		DisplayMenuL();
       
   125 		break;
       
   126 	
       
   127 	case EAknSoftkeyChange:
       
   128 		EditItemL(EFalse);
       
   129 		break;
       
   130 	}
       
   131 	return retValue;
       
   132 }
       
   133 
       
   134 void CGSPredictiveSettingDialog::ProcessCommandL(TInt aCommandId)
       
   135 	{
       
   136 	// This is MT Error fixing.
       
   137 	// This function is called by dialog framework, whenever menu item is 
       
   138 	// selected. we should have to hide existing display menu first to maitain the
       
   139 	// control stack .
       
   140 	// If user try to stop displaying menu after creating any control
       
   141 	// In that situation whenever application goes to background framework remove the
       
   142 	// control from the stack when try to remove the menubar from control stack.
       
   143 	CAknDialog::ProcessCommandL(aCommandId);
       
   144 	
       
   145 	switch(aCommandId)
       
   146 		{
       
   147 		case EAknFepCmdPredSettingChange:
       
   148 			EditItemL(ETrue);
       
   149 			break;
       
   150 		case EAknCmdHelp:
       
   151 			{
       
   152 				
       
   153 		    const TInt KArrayGranularity = 3;
       
   154 		    CArrayFix<TCoeHelpContext>* contexts =
       
   155 		                new (ELeave) CArrayFixFlat<TCoeHelpContext>( KArrayGranularity );
       
   156 		    CleanupStack::PushL ( contexts );
       
   157 		    TUid appuid = { 0x100058EC };
       
   158 		    contexts->AppendL( TCoeHelpContext( appuid, KPREDINPUT_HLP_INPUT ) );
       
   159 		    CleanupStack::Pop( contexts );
       
   160 		    HlpLauncher::LaunchHelpApplicationL( CEikonEnv::Static()->WsSession(), contexts );
       
   161 			}
       
   162 			break;
       
   163 		case EAknCmdExit:
       
   164 			// Save the setting and exit application.
       
   165 			iSettingsList->StoreSettingsL();
       
   166 			SaveSettingsDataL();
       
   167 			// Pass the EAknCmdExit command to Avkon 
       
   168 			// Framework 
       
   169 			iAvkonAppUi->ProcessCommandL(aCommandId);
       
   170 			break;
       
   171 		}
       
   172 	
       
   173 	}
       
   174 
       
   175 // Reads Input Settings data from CenRep.
       
   176 void CGSPredictiveSettingDialog::ReadSettingsDataL()
       
   177     {
       
   178     TInt autoWordCompl = 0;
       
   179 	TInt typingCorrection = 0;
       
   180 	TInt numberCandidates = 0;
       
   181 	TInt primaryCandidate = 0;
       
   182 	TInt physicalKeyboards = 0;
       
   183     // Read CenRep 
       
   184     TInt ret = KErrNone;
       
   185     CRepository* aknFepRepository = NULL;
       
   186     TRAP(ret, aknFepRepository = CRepository::NewL(KCRUidAknFep));
       
   187     if (ret == KErrNone)
       
   188         {
       
   189          if(aknFepRepository)
       
   190         	{
       
   191         	aknFepRepository->Get(KAknFepPredTxtFlagExtension, iPredictiveTextFlag);
       
   192         	aknFepRepository->Get(KAknFepAutoCompleteFlag, autoWordCompl);
       
   193         	aknFepRepository->Get(KAknFepTypingCorrectionLevel, typingCorrection);
       
   194         	aknFepRepository->Get(KAknFepNumberCandidateFlag, numberCandidates);
       
   195         	aknFepRepository->Get(KAknFepPrimaryCandidateFlag, primaryCandidate);
       
   196         	aknFepRepository->Get(KAknFepPhysicalKeyboards, physicalKeyboards);
       
   197         	delete aknFepRepository;
       
   198         	}
       
   199         }
       
   200 
       
   201     // Parse keyboard dependent settings for current keyboard from bitmask
       
   202 	TInt keyboardLayout = 0;
       
   203 	RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
       
   204 	TPtiKeyboardType layout = (TPtiKeyboardType)keyboardLayout;
       
   205 	TInt autoTmp = autoWordCompl;
       
   206 	
       
   207 	switch(layout)
       
   208 	    {
       
   209 	    case EPtiKeyboardNone:
       
   210 	        break;
       
   211 	  	case EPtiKeyboard12Key:
       
   212 	        autoTmp &= EKeyboardStyle12Key;
       
   213 	        iPredictiveTextFlag &= EKeyboardStyle12Key;	        
       
   214 	        break;
       
   215 	    case EPtiKeyboardHalfQwerty:
       
   216 	        autoTmp &= EKeyboardStyleHalfQwerty;
       
   217 	        iPredictiveTextFlag &= EKeyboardStyleHalfQwerty;
       
   218 	        break;
       
   219 	  	case EPtiKeyboardQwerty4x12:
       
   220 	  	case EPtiKeyboardQwerty4x10:
       
   221 	  	case EPtiKeyboardQwerty3x11:
       
   222 	  	case EPtiKeyboardCustomQwerty:
       
   223 	        autoTmp &= EKeyboardStyleQwerty;
       
   224 	        iPredictiveTextFlag &= EKeyboardStyleQwerty;
       
   225 	        break;
       
   226 	  	default:
       
   227 	  	    break;
       
   228 	    }
       
   229 	    	    
       
   230 	// The Value of iPredictiveTextFlag should be as mentioned below according to keyboard 
       
   231 	// layout and ITI settings	
       
   232 	// IF ITI is off for QWERTY/ITU-T iPredictiveTextFlag = 0
       
   233 	// IF ITI is on for ITU-T         iPredictiveTextFlag = 1
       
   234 	// IF ITI is on for QWERTY        iPredictiveTextFlag = 2
       
   235 	
       
   236 	//load setting data
       
   237 	iSettingsData->LoadL(( autoTmp ? 1 : 0), typingCorrection, numberCandidates,
       
   238 	           primaryCandidate, physicalKeyboards, autoWordCompl);
       
   239    
       
   240     }
       
   241     
       
   242 
       
   243 void CGSPredictiveSettingDialog::SaveSettingsDataL() const
       
   244     {
       
   245     // Read setting data and fill CenRep.
       
   246     TInt ret = KErrNone;
       
   247     CRepository* AknFepRepository = NULL;
       
   248     TRAP(ret, AknFepRepository = CRepository::NewL(KCRUidAknFep));
       
   249     if (ret == KErrNone)
       
   250     	{
       
   251     	if(AknFepRepository)
       
   252       	{
       
   253        	TInt autoFlag = 0;
       
   254        	AknFepRepository->Get(KAknFepAutoCompleteFlag, autoFlag);
       
   255        	TInt predFlag = 0;
       
   256        	AknFepRepository->Get(KAknFepPredTxtFlagExtension, predFlag);
       
   257 
       
   258        	// Parse keyboard dependent settings for current keyboard from bitmask
       
   259        	TInt keyboardLayout = 0;
       
   260        	RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
       
   261        	TPtiKeyboardType layout = (TPtiKeyboardType)keyboardLayout;
       
   262        	switch(layout)
       
   263        	    {
       
   264        	    case EPtiKeyboardNone:
       
   265        	        break;
       
   266        	    case EPtiKeyboard12Key:
       
   267        	        if (iSettingsData->AutoWordCompl())
       
   268        	            {
       
   269        	            autoFlag |= EKeyboardStyle12Key;
       
   270        	            }
       
   271        	        else
       
   272        	            {
       
   273        	            autoFlag &= ~EKeyboardStyle12Key;
       
   274        	            }
       
   275        	        break;
       
   276 	   	    case EPtiKeyboardHalfQwerty:
       
   277 	   	        if (iSettingsData->AutoWordCompl())
       
   278 	   	            {
       
   279 	   	            autoFlag |= EKeyboardStyleHalfQwerty;
       
   280 	   	            }
       
   281 	   	        else
       
   282 	   	            {
       
   283 	   	            autoFlag &= ~EKeyboardStyleHalfQwerty;
       
   284 	   	            }
       
   285 	   	        break;
       
   286 	   	        
       
   287        	    case EPtiKeyboardQwerty4x12:
       
   288        	    case EPtiKeyboardQwerty4x10:
       
   289        	    case EPtiKeyboardQwerty3x11:
       
   290        	    case EPtiKeyboardCustomQwerty:
       
   291        	        if (iSettingsData->AutoWordCompl())
       
   292        	            {
       
   293        	            autoFlag |= EKeyboardStyleQwerty;
       
   294        	            }
       
   295        	        else
       
   296        	            {
       
   297        	            autoFlag &= ~EKeyboardStyleQwerty;
       
   298        	            }
       
   299        	        break;
       
   300        	    default:
       
   301        	        break;
       
   302        	    }
       
   303 
       
   304         if(iSettingsList->DeviceHasMultipleKeyboards())
       
   305             {
       
   306             AknFepRepository->Set(KAknFepAutoCompleteFlag, iSettingsData->AWCBitmask());
       
   307             }
       
   308         else
       
   309             {
       
   310             AknFepRepository->Set(KAknFepAutoCompleteFlag, autoFlag);            
       
   311             }
       
   312         AknFepRepository->Set(KAknFepTypingCorrectionLevel, iSettingsData->TypingCorrection());
       
   313         AknFepRepository->Set(KAknFepNumberCandidateFlag, iSettingsData->NumberCandidates());
       
   314         AknFepRepository->Set(KAknFepPrimaryCandidateFlag, iSettingsData->PrimaryCandidate());
       
   315         delete AknFepRepository;
       
   316         }
       
   317       }
       
   318     }
       
   319 
       
   320 void CGSPredictiveSettingDialog::SaveCurrentSettingsDataL() const
       
   321     {
       
   322     // Read setting data and fill CenRep.
       
   323     TInt ret = KErrNone;
       
   324     CRepository* AknFepRepository = NULL;
       
   325     TRAP(ret, AknFepRepository = CRepository::NewL(KCRUidAknFep));
       
   326     if (ret == KErrNone)
       
   327     	{
       
   328     	if(AknFepRepository)
       
   329       	{
       
   330       	if(EAutoWordCompletion == iSettingsList->ListBox()->CurrentItemIndex())
       
   331       		{
       
   332        		TInt autoFlag = 0;
       
   333        		AknFepRepository->Get(KAknFepAutoCompleteFlag, autoFlag);
       
   334        		TInt predFlag = 0;
       
   335        		AknFepRepository->Get(KAknFepPredTxtFlagExtension, predFlag);
       
   336 
       
   337        		// Parse keyboard dependent settings for current keyboard from bitmask
       
   338        		TInt keyboardLayout = 0;
       
   339        		RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
       
   340        		TPtiKeyboardType layout = (TPtiKeyboardType)keyboardLayout;
       
   341        		switch(layout)
       
   342        	    	{
       
   343        	    	case EPtiKeyboardNone:
       
   344 	       	        break;
       
   345 	       	    case EPtiKeyboard12Key:
       
   346     	   	        if (iSettingsData->AutoWordCompl())
       
   347        		            {
       
   348        	    	        autoFlag |= EKeyboardStyle12Key;
       
   349        	        	    }
       
   350        	        	else
       
   351 	       	            {
       
   352     	   	            autoFlag &= ~EKeyboardStyle12Key;
       
   353        		            }
       
   354        	        	break;
       
   355 	   	 	   case EPtiKeyboardHalfQwerty:
       
   356 	   	   	     if (iSettingsData->AutoWordCompl())
       
   357 	   	        	    {
       
   358 	   	         	   autoFlag |= EKeyboardStyleHalfQwerty;
       
   359 	   	  	          }
       
   360 	 	  	        else
       
   361 	   	     	       {
       
   362 	   	     	       autoFlag &= ~EKeyboardStyleHalfQwerty;
       
   363 	   	        	    }
       
   364 	   	     	   break;
       
   365        	    	case EPtiKeyboardQwerty4x12:
       
   366        	    	case EPtiKeyboardQwerty4x10:
       
   367 	       	    case EPtiKeyboardQwerty3x11:
       
   368        		    case EPtiKeyboardCustomQwerty:
       
   369        	    	    if (iSettingsData->AutoWordCompl())
       
   370        	        	    {
       
   371        	            	autoFlag |= EKeyboardStyleQwerty;
       
   372     	   	            }
       
   373 	       	        else
       
   374        		            {
       
   375        	    	        autoFlag &= ~EKeyboardStyleQwerty;
       
   376        	        	    }
       
   377        	        	break;
       
   378 	       	    default:
       
   379     	   	        break;
       
   380        		    }
       
   381 
       
   382 	        //AknFepRepository->Set(KAknFepPredTxtFlagExtension, predFlag);
       
   383     	    //AknFepRepository->Set(KAknFepPredTxtFlag, iPredictiveTextFlag != 0); // For backwards compatibility
       
   384         	if(iSettingsList->DeviceHasMultipleKeyboards())
       
   385             	{
       
   386 	            AknFepRepository->Set(KAknFepAutoCompleteFlag, iSettingsData->AWCBitmask());
       
   387     	        }
       
   388         	else
       
   389             	{
       
   390 	            AknFepRepository->Set(KAknFepAutoCompleteFlag, autoFlag);            
       
   391     	        }
       
   392         	}
       
   393         	else if(ETypingCorrectionLevel == iSettingsList->ListBox()->CurrentItemIndex())
       
   394         		{
       
   395         		AknFepRepository->Set(KAknFepTypingCorrectionLevel, iSettingsData->TypingCorrection());
       
   396         		}
       
   397         	else if(ENumberCandidate  == iSettingsList->ListBox()->CurrentItemIndex())
       
   398         		{
       
   399         		AknFepRepository->Set(KAknFepNumberCandidateFlag, iSettingsData->NumberCandidates());	
       
   400         		}
       
   401         	else if(EPrimaryCandidate == iSettingsList->ListBox()->CurrentItemIndex())
       
   402         		{
       
   403         		AknFepRepository->Set(KAknFepPrimaryCandidateFlag, iSettingsData->PrimaryCandidate());	
       
   404         		}
       
   405         	delete AknFepRepository;
       
   406         	}
       
   407       	}
       
   408     }
       
   409 
       
   410 void CGSPredictiveSettingDialog::EditItemL(TBool aCalledFromMenu)
       
   411 {
       
   412     TInt prevSettings = CurrentSettings();
       
   413 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__	
       
   414 	// Set the flag as we are currently editing the settings item
       
   415 	iSettingItemInEditingState = ETrue;
       
   416 #endif //__ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
   417     
       
   418 	iSettingsList->EditCurrentItemL(aCalledFromMenu);
       
   419 	LaunchPredictiveSettingOffQueryIfNecessaryL(prevSettings);
       
   420 	SaveCurrentSettingsDataL();
       
   421 
       
   422 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__	
       
   423 	//Reset the flag as the current item edit is over
       
   424 	iSettingItemInEditingState = EFalse;
       
   425 #endif //__ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
   426 		
       
   427 }
       
   428 
       
   429 void CGSPredictiveSettingDialog::LaunchPredictiveSettingOffQueryIfNecessaryL(TInt aPrevSettings)
       
   430 	{
       
   431 	if(iPredictiveSettingOffQueryNotShown)
       
   432 		{
       
   433 		CRepository* AknFepRepository = NULL;
       
   434 		AknFepRepository = CRepository::NewL(KCRUidAknFep);
       
   435 		if(AknFepRepository)
       
   436 			{
       
   437 		    CleanupStack::PushL(AknFepRepository);
       
   438 		    AknFepRepository->Get(KAknFepPredTxtFlagExtension,iPredictiveTextFlag);
       
   439 		    }
       
   440 		    
       
   441 		TInt keyboardLayout = 0;
       
   442 		RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
       
   443 		TPtiKeyboardType layout = (TPtiKeyboardType)keyboardLayout;
       
   444 		TBool QueryNeeded = EFalse;
       
   445 
       
   446 		if(iSettingsList->DeviceHasMultipleKeyboards())
       
   447 		    {
       
   448 			TInt activateITIForKbd = 0;
       
   449 			if(EAutoWordCompletion == iSettingsList->ListBox()->CurrentItemIndex() && 
       
   450 			   iSettingsData->AWCBitmask() != aPrevSettings & 0xF)
       
   451 			    {
       
   452 			    // if AWC is ON and Prev.Settings of AWC is not ON and ITI is OFF
       
   453 			    if((iSettingsData->AWCBitmask() & EKeyboardStyle12Key) && 
       
   454 			       ((aPrevSettings & 0xF) & EKeyboardStyle12Key)!=1 &&
       
   455 			        (iPredictiveTextFlag & EKeyboardStyle12Key) == 0)
       
   456 			         {
       
   457 			         QueryNeeded = ETrue;
       
   458 			         activateITIForKbd |= EKeyboardStyle12Key ;
       
   459 			         if(layout == EPtiKeyboard12Key)
       
   460 			             iPredictiveSettingOffQueryNotShown = EFalse;
       
   461 			         }
       
   462 			    // if AWC is ON and Prev.Settings of AWC is not ON and ITI is OFF        
       
   463 			    if((iSettingsData->AWCBitmask() & EKeyboardStyleQwerty) && 
       
   464 			       ((aPrevSettings & 0xF) & EKeyboardStyleQwerty)!=2 &&
       
   465 			        (iPredictiveTextFlag & EKeyboardStyleQwerty) == 0)
       
   466 			         {
       
   467 			         QueryNeeded = ETrue;
       
   468 			         activateITIForKbd |= EKeyboardStyleQwerty ;
       
   469 			         if(layout == EKeyboardStyleQwerty)
       
   470 			             iPredictiveSettingOffQueryNotShown = EFalse;
       
   471 			         }
       
   472 			     if((iSettingsData->AWCBitmask() & EKeyboardStyleHalfQwerty) && 
       
   473 			       ((aPrevSettings & 0xF) & EKeyboardStyleHalfQwerty)!=4 &&
       
   474 			        (iPredictiveTextFlag & EKeyboardStyleHalfQwerty) == 0)
       
   475 			         {
       
   476 			         QueryNeeded = ETrue;
       
   477 			         activateITIForKbd |= EKeyboardStyleHalfQwerty ;
       
   478 			         if(layout == EKeyboardStyleHalfQwerty)
       
   479 			             iPredictiveSettingOffQueryNotShown = EFalse;
       
   480 			         }     
       
   481 			    }
       
   482 			// if Prev.Setting of TypingCorrection != Curr.Settng of TypingCorrection and
       
   483 			// Current TypingCorrection != OFF and ITI is OFF   
       
   484 			else if(iSettingsData->iTypingCorrection != ((aPrevSettings >> 4)&0xF) &&
       
   485 			        ETypingCorrectionLevel == iSettingsList->ListBox()->CurrentItemIndex() && 
       
   486 			        0 != iSettingsData->TypingCorrection() &&
       
   487 			        (iPredictiveTextFlag & EKeyboardStyleQwerty) == 0)
       
   488 			    {
       
   489 			    QueryNeeded = ETrue;
       
   490 			    iPredictiveSettingOffQueryNotShown = EFalse;
       
   491 			    activateITIForKbd |= EKeyboardStyleQwerty ;
       
   492 			    }
       
   493 			// if Prev.Setting of NumberCandidate != Curr.Settng of NumberCandidate and
       
   494 			// Current NumberCandidate is ON and ITI is OFF     
       
   495 			else if(iSettingsData->iNumberCandidates != ((aPrevSettings >> 8)&0xF) &&
       
   496 			        ENumberCandidate == iSettingsList->ListBox()->CurrentItemIndex() && 
       
   497 			        1 == iSettingsData->NumberCandidates() &&
       
   498 			        (iPredictiveTextFlag & EKeyboardStyleQwerty) == 0)
       
   499 			    {
       
   500 			    QueryNeeded = ETrue;
       
   501 			    iPredictiveSettingOffQueryNotShown = EFalse;
       
   502 			    activateITIForKbd |= EKeyboardStyleQwerty ;
       
   503 			    }
       
   504 			if(QueryNeeded)
       
   505 			    {
       
   506 			    CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   507 			    if(dlg->ExecuteLD(iConfirmationQueryResId))
       
   508 			        {
       
   509 			        if(activateITIForKbd & EKeyboardStyle12Key)
       
   510 			            {
       
   511 			            iPredictiveTextFlag |= EKeyboardStyle12Key;
       
   512 			            }
       
   513 			                        
       
   514 			        if(activateITIForKbd & EKeyboardStyleQwerty)
       
   515 			            {
       
   516 			            iPredictiveTextFlag |= EKeyboardStyleQwerty;
       
   517 			            }
       
   518 			        if(activateITIForKbd & EKeyboardStyleHalfQwerty)
       
   519 			            {
       
   520 			            iPredictiveTextFlag |= EKeyboardStyleHalfQwerty;
       
   521 			            }
       
   522 
       
   523 			        }
       
   524 			    }
       
   525 			}
       
   526 		else
       
   527 			{
       
   528 			TInt predFlag = 0;
       
   529 			AknFepRepository->Get(KAknFepPredTxtFlagExtension, predFlag);
       
   530 			TInt autoFlag = 0;
       
   531        		AknFepRepository->Get(KAknFepAutoCompleteFlag, autoFlag);
       
   532 
       
   533 	       	switch(layout)
       
   534     	   	    {
       
   535        		    case EPtiKeyboardNone:
       
   536        	    	    break;
       
   537        	    	case EPtiKeyboard12Key:
       
   538        	    		autoFlag = ((autoFlag & EPtiKeyboard12Key)!=0);
       
   539 	       	    	// if ITI is ON for QWERTY then iPredictiveTextFlag = 2; In that case we have to find out the ITI state for ITU-T
       
   540     	   	        if (!( iPredictiveTextFlag & EKeyboardStyle12Key ))
       
   541        		            {
       
   542        	    	        predFlag |= EKeyboardStyle12Key;
       
   543        	        	    }
       
   544        	    		
       
   545        	    		break;
       
   546        	    	case EPtiKeyboardHalfQwerty:
       
   547        	    		autoFlag = ((autoFlag & EKeyboardStyleHalfQwerty)!=0);
       
   548     	   	        if (!( iPredictiveTextFlag & EKeyboardStyleHalfQwerty))
       
   549        		            {
       
   550        	    	        predFlag |= EKeyboardStyleHalfQwerty;
       
   551        	        	    }
       
   552        	    		
       
   553        	    		break;
       
   554 				case EPtiKeyboardQwerty4x12:
       
   555        	    	case EPtiKeyboardQwerty4x10:
       
   556        	    	case EPtiKeyboardQwerty3x11:
       
   557        	    	case EPtiKeyboardCustomQwerty:
       
   558        	    		autoFlag = ((autoFlag & EKeyboardStyleQwerty)!=0);
       
   559 	       	    	// if ITI is ON for ITU-T then iPredictiveTextFlag = 1; In that case we have to find out the ITI state for QWERTY
       
   560     	   	        if (!(iPredictiveTextFlag & EKeyboardStyleQwerty ))
       
   561        		            {
       
   562        	    	        predFlag |= EKeyboardStyleQwerty;
       
   563        	            	}
       
   564        	    		break;
       
   565        	    	default:
       
   566        	    		break;
       
   567     	   	    }
       
   568 
       
   569 			
       
   570 			if (predFlag != iPredictiveTextFlag)
       
   571 			    {
       
   572 			    switch(iSettingsList->ListBox()->CurrentItemIndex())
       
   573 			    	{
       
   574 			    	case EAutoWordCompletion:
       
   575 			    		if(iSettingsData->iAutoWordCompl != autoFlag &&
       
   576 			    			1 == iSettingsData->AutoWordCompl())
       
   577 			    			{
       
   578 			    			QueryNeeded = ETrue;	
       
   579 			    			}
       
   580 			    		break;
       
   581 			    	case ETypingCorrectionLevel:
       
   582 			    		if(iSettingsData->iTypingCorrection != ((aPrevSettings >> 4)&0xF) && 
       
   583 			    			0 != iSettingsData->TypingCorrection())
       
   584 			    			{
       
   585 			    			QueryNeeded = ETrue;
       
   586 			    			}
       
   587 			    		break;
       
   588 			    	case ENumberCandidate:
       
   589 			    		if(iSettingsData->iNumberCandidates != ((aPrevSettings >> 8)&0xF) && 
       
   590 			    			0 != iSettingsData->NumberCandidates())
       
   591 			    			{
       
   592 			    			QueryNeeded = ETrue;
       
   593 			    			}
       
   594 			    		break;
       
   595 			    	}
       
   596 			
       
   597 			    if(QueryNeeded)
       
   598 			        {
       
   599 			        CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   600 			        if(dlg->ExecuteLD(iConfirmationQueryResId))
       
   601 			            iPredictiveTextFlag = predFlag;
       
   602 
       
   603 			        iPredictiveSettingOffQueryNotShown = EFalse;	
       
   604 			        }
       
   605 			    }	
       
   606 			}
       
   607 		if(AknFepRepository)
       
   608 			{
       
   609 			if(QueryNeeded)
       
   610 				{
       
   611 				AknFepRepository->Set(KAknFepPredTxtFlagExtension,iPredictiveTextFlag);
       
   612         		AknFepRepository->Set(KAknFepPredTxtFlag, iPredictiveTextFlag != 0); // For backwards compatibility							
       
   613 				}
       
   614 			CleanupStack::Pop(AknFepRepository);
       
   615 			delete AknFepRepository;
       
   616 			}			
       
   617 		}
       
   618 	}
       
   619 TInt CGSPredictiveSettingDialog::CurrentSettings()
       
   620     {
       
   621     TInt settings = 0;
       
   622     //settings are the values of first 16 bits
       
   623     //  settings & 0xF = iAWCBitmask
       
   624     //  (settings >> 4) & 0xF = iNumberCandidates
       
   625     //  (settings >> 8) & 0xF = iTypingCorrection
       
   626     //  (settings >> 12) & 0xF = iPrimaryCandidate
       
   627     settings = (iSettingsData->iPrimaryCandidate << 12) |
       
   628                 (iSettingsData->iNumberCandidates << 8) |
       
   629                 (iSettingsData->iTypingCorrection << 4) |
       
   630                 (iSettingsData->AWCBitmask());
       
   631     return settings;                
       
   632     }
       
   633 
       
   634 // This part of code for error fixing multiple layout. Whenever you switch from one keyboard 
       
   635 // Layout to another keyboard layout HandleResourceChange is getting called and loads the 
       
   636 // Setting information specific to keyboard layout
       
   637 void CGSPredictiveSettingDialog::HandleResourceChange(TInt aType)
       
   638     {
       
   639     
       
   640     CAknDialog::HandleResourceChange(aType);
       
   641  
       
   642     // Check for keyboard layout change
       
   643     // If layout is changed, load the setting information based on 
       
   644     // Layout.
       
   645     if(aType==KEikDynamicLayoutVariantSwitch)
       
   646         {   
       
   647         TInt keyboardLayout = EPtiKeyboardNone;
       
   648         RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
       
   649 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
   650         if(iOriginalKeyboardLayout != keyboardLayout)
       
   651             {
       
   652             if(iSettingItemInEditingState)
       
   653             	{
       
   654             	// If we are currently editing the settings item then generate a cancel event
       
   655             	// and start the scheduler so as to close the settings page 
       
   656             	// when the blocking call completes. 
       
   657             	RWsSession& wsSession = CEikonEnv::Static()->WsSession();
       
   658             	TKeyEvent escapeEvent = {EKeyEscape, EStdKeyEscape, 0, 0};
       
   659             	TRAP_IGNORE(CEikonEnv::Static()->SimulateKeyEventL(escapeEvent, EEventKey));
       
   660             	wsSession.Flush();
       
   661             	iItemCloseEventCheck->Start( TCallBack(EventCheckCallback, this) );
       
   662             	}
       
   663             else
       
   664 	            {
       
   665     	        // In case the current settings item is not in editing state then directly 
       
   666     	        // close the settings page.
       
   667             	TRAP_IGNORE(TryExitL(EAknSoftkeyBack));	
       
   668     	        }
       
   669             return;
       
   670             }
       
   671 #endif //__ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__     
       
   672         // Read the Predictive setting
       
   673         TInt ret = KErrNone;
       
   674         CRepository* AknFepRepository = NULL;
       
   675         TRAP(ret, AknFepRepository = CRepository::NewL(KCRUidAknFep));
       
   676         if(ret == KErrNone)
       
   677         {
       
   678           AknFepRepository->Get(KAknFepPredTxtFlagExtension,iPredictiveTextFlag);
       
   679    
       
   680         // Adjust predictive flag after layout switch
       
   681         TInt keyboardLayout = EPtiKeyboardNone;
       
   682         RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
       
   683         switch(keyboardLayout)
       
   684             {
       
   685             case EPtiKeyboard12Key:
       
   686                 // Dictionary is ON for ITU-T
       
   687                 iPredictiveTextFlag &= EKeyboardStyle12Key;
       
   688                 break;
       
   689             case EPtiKeyboardHalfQwerty:    
       
   690                 iPredictiveTextFlag &= EKeyboardStyleHalfQwerty;
       
   691                 break;
       
   692             case EPtiKeyboardQwerty4x12:
       
   693             case EPtiKeyboardQwerty4x10:
       
   694             case EPtiKeyboardQwerty3x11:            
       
   695             case EPtiKeyboardCustomQwerty:
       
   696                 // Dictionary is ON for QWERTY
       
   697                 iPredictiveTextFlag &= EKeyboardStyleQwerty;
       
   698             case EPtiKeyboardNone:
       
   699             default:
       
   700                 break;
       
   701             }
       
   702         delete AknFepRepository;
       
   703         }
       
   704         }        
       
   705     }
       
   706 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
   707 TInt CGSPredictiveSettingDialog::EventCheckCallback(TAny* aObj)
       
   708 	{
       
   709     TRAP_IGNORE(static_cast<CGSPredictiveSettingDialog*>(aObj)->AttemptToExitL());
       
   710     return KErrNone;	
       
   711 	}
       
   712 	
       
   713 void CGSPredictiveSettingDialog::AttemptToExitL()
       
   714 	{
       
   715 	if(iItemCloseEventCheck->IsActive())
       
   716 		{
       
   717 		iItemCloseEventCheck->Cancel();	
       
   718 		}
       
   719 	// iSettingItemInEditingState sets before the blocking call of editing item state and 
       
   720 	// gets reset after the blocking call.
       
   721     if (!iSettingItemInEditingState)
       
   722     	{
       
   723     	// In case we are here, then we need to close the settings item because of layout change
       
   724     	TRAP_IGNORE(TryExitL(EAknSoftkeyBack));	
       
   725     	}
       
   726     else
       
   727     	{
       
   728     	// Because of priority we hit the scheduler first and then the blocking call gets
       
   729     	// executed. To handle such a scenario, restart the scheduler.
       
   730     	iItemCloseEventCheck->Start( TCallBack(EventCheckCallback, this) );	
       
   731     	}
       
   732 	}
       
   733 #endif //__ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
   734 
       
   735 void CGSPredictiveSettingDialog::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   736     {
       
   737     if ( aPointerEvent.iType == TPointerEvent::EDrag )
       
   738         {
       
   739         iSettingsList->HandlePointerEventL(aPointerEvent);
       
   740         }
       
   741     else
       
   742         {
       
   743         CAknDialog::HandlePointerEventL(aPointerEvent);
       
   744         }
       
   745     }
       
   746 
       
   747 /**
       
   748  *From MEikCommandObserver
       
   749  */
       
   750 void CGSPredictiveSettingDialog::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) 
       
   751     {
       
   752     if ( iAvkonAppUi->IsSingleClickCompatible() )
       
   753         {
       
   754         if ( R_PREDICTIVESETTINGDIALOG_MENU == aResourceId )
       
   755             {
       
   756             aMenuPane->SetItemDimmed(EAknFepCmdPredSettingChange, ETrue);
       
   757             }
       
   758         } 
       
   759     }