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