textinput/GSLangPlugin/src/GSLangPlugin.cpp
changeset 0 eb1f2e154e89
child 10 6defe5d1bd39
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  GSLangPlugin implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // Includes
       
    20 #include "GSLangPlugin.h"
       
    21 #include "GSLangContainer.h"
       
    22 #include "GSLangModel.h"
       
    23 #include <gsfwviewuids.h>
       
    24 #include <GSLangPluginRsc.rsg>
       
    25 #include <gslistbox.h>
       
    26 #include <gsprivatepluginproviderids.h>
       
    27 
       
    28 #include <AknDateFormatUtils.h>
       
    29 #include <AknFepGlobalEnums.h>  // EPinyin
       
    30 #include <aknnotewrappers.h>
       
    31 #include <aknradiobuttonsettingpage.h>
       
    32 #include <aknsettingpage.h>
       
    33 #include <akntextsettingpage.h>
       
    34 #include <aknViewAppUi.h>
       
    35 #include <AknWaitDialog.h>
       
    36 #include <eikapp.h>
       
    37 #include <featmgr.h>
       
    38 #include <hlplch.h> // HlpLauncher
       
    39 #include <PSVariables.h>
       
    40 #include <PtiEngine.h>
       
    41 #include <StringLoader.h>
       
    42 #include <syslangutil.h>        // Display UI language
       
    43 #include <ctsydomainpskeys.h>
       
    44 #include <SATDomainPSKeys.h>
       
    45 #include <e32property.h>
       
    46 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
    47 #include "PredictiveSettingDialog.h"
       
    48 #include <AknFep.rsg>
       
    49 #include <akntitle.h>
       
    50 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
    51 #include "DualLanguageDialog.h"
       
    52 #endif
       
    53 #include <aknnotedialog.h>          //CAknNoteDialog 
       
    54 #include <AvkonInternalCRKeys.h> 
       
    55 #endif
       
    56 #include <gslangplugin.mbg>
       
    57 
       
    58 #ifndef RD_STARTUP_CHANGE
       
    59     #include <sysstartup.h>         // Startup reasons
       
    60 #else
       
    61     #include <starterclient.h>      // Startup reasons
       
    62 #endif // RD_STARTUP_CHANGE
       
    63 
       
    64 // Constants
       
    65 
       
    66 // ========================= MEMBER FUNCTIONS ================================
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // CGSLangPlugin::CGSLangPlugin()
       
    70 // Constructor
       
    71 //
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 CGSLangPlugin::CGSLangPlugin():
       
    75     iCascadeOptionsOpen(EFalse),
       
    76     iDialog(NULL)
       
    77     {
       
    78     }
       
    79 
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // CGSLangPlugin::~CGSLangPlugin()
       
    83 // Destructor
       
    84 //
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 CGSLangPlugin::~CGSLangPlugin()
       
    88     {
       
    89     FeatureManager::UnInitializeLib();
       
    90     if( iContainer )
       
    91         {
       
    92         AppUi()->RemoveFromViewStack( *this, iContainer );
       
    93         delete iContainer;
       
    94         }
       
    95     if(iDialog)
       
    96         {
       
    97        delete iDialog;
       
    98         }
       
    99     
       
   100 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
   101 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__       
       
   102     if (iKeyboardLayoutStatusSubscriber)
       
   103         {
       
   104         iKeyboardLayoutStatusSubscriber->StopSubscribe();
       
   105         }
       
   106     iKeyboardLayoutStatusProperty.Close();
       
   107     delete iKeyboardLayoutStatusSubscriber;     
       
   108 #endif    
       
   109 #endif    
       
   110     }
       
   111 
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CGSLangPlugin::ConstructL(const TRect& aRect)
       
   115 // Symbian OS two-phased constructor
       
   116 // (other items were commented in a header).
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 void CGSLangPlugin::ConstructL()
       
   120     {
       
   121     FeatureManager::InitializeLibL();
       
   122     OpenLocalizedResourceFileL( KGSLangPluginResourceFileName,
       
   123                                 iResourceLoader );
       
   124     BaseConstructL( R_GS_LANG_VIEW );
       
   125     
       
   126 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   127 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__   
       
   128     //Attach the P&S property to the keyboardlayout and subscribe to the P&S framework
       
   129     // for any keyboard layout change.
       
   130     User::LeaveIfError(iKeyboardLayoutStatusProperty.Attach(KCRUidAvkon, KAknKeyBoardLayout));    
       
   131     iKeyboardLayoutStatusSubscriber = new (ELeave) CSubscriber(
       
   132                                          TCallBack(HandleKeyboardLayoutChangeNotification, this), 
       
   133                                          iKeyboardLayoutStatusProperty);    
       
   134     iKeyboardLayoutStatusSubscriber->SubscribeL();
       
   135 #endif
       
   136 #endif 
       
   137     }
       
   138 
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // CGSLangPlugin::NewL()
       
   142 // Static constructor
       
   143 //
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 CGSLangPlugin* CGSLangPlugin::NewL( TAny* /*aInitParams*/ )
       
   147     {
       
   148     CGSLangPlugin* self = new(ELeave) CGSLangPlugin();
       
   149     CleanupStack::PushL(self);
       
   150     self->ConstructL();
       
   151     CleanupStack::Pop(self);
       
   152     return self;
       
   153     }
       
   154 
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 // CGSLangPlugin::Id
       
   158 //
       
   159 //
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 TUid CGSLangPlugin::Id() const
       
   163     {
       
   164     return KGSLangPluginUID;
       
   165     }
       
   166 
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 // CGSLangPlugin::HandleClientRectChange
       
   170 //
       
   171 //
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 void CGSLangPlugin::HandleClientRectChange()
       
   175     {
       
   176     if ( iContainer )
       
   177         {
       
   178         iContainer->SetRect( ClientRect() );
       
   179         }
       
   180     }
       
   181 
       
   182 
       
   183 // -----------------------------------------------------------------------------
       
   184 // CGSLangPlugin::DoActivateL
       
   185 //
       
   186 //
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 void CGSLangPlugin::DoActivateL( const TVwsViewId& aPrevViewId,
       
   190                                  TUid aCustomMessageId,
       
   191                                  const TDesC8& aCustomMessage )
       
   192     {
       
   193     CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
       
   194     }
       
   195 
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // CGSLangPlugin::DoDeactivate
       
   199 //
       
   200 //
       
   201 // -----------------------------------------------------------------------------
       
   202 //
       
   203 void CGSLangPlugin::DoDeactivate()
       
   204     {
       
   205     CGSBaseView::DoDeactivate();
       
   206     }
       
   207 
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // CGSLangPlugin::HandleCommandL
       
   211 //
       
   212 //
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 void CGSLangPlugin::HandleCommandL( TInt aCommand )
       
   216     {
       
   217     switch ( aCommand )
       
   218         {
       
   219         case EGSMSKCmdAppChange:
       
   220             HandleListBoxSelectionL();
       
   221             break;
       
   222         case EGSCmdAppChange:
       
   223             if ( Container()->CurrentFeatureId() == EGSLangIdT9L )
       
   224                 {
       
   225 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   226                 // Launch Predictive mode setting page if >1 keyboards available on device
       
   227                 // Otherwise just change the setting value for the only keyboard
       
   228                 ShowITIMultiSettingPageL(ETrue);
       
   229 #else
       
   230                 // If EGSLangIdT9L is selected, change T9
       
   231                 // setting using setting page.
       
   232                 Container()->Model()->ChangePredictiveOnOffSettingL(
       
   233                     ETrue,
       
   234                     CGSLangModel::EGSLangOther );
       
   235 #endif
       
   236                 }
       
   237             else if( Container()->CurrentFeatureId() == EGSLangIdEPT )
       
   238                 {
       
   239                 // If EGSLangIdEPT is selected, change T9
       
   240                 // setting using setting page.
       
   241                 Container()->Model()->ChangePredictiveOnOffSettingL(
       
   242                     ETrue,
       
   243                     CGSLangModel::EGSLangOther );
       
   244                 }
       
   245             else if( Container()->CurrentFeatureId() == EGSLangIdJPT )
       
   246                 {
       
   247                 Container()->Model()->ChangePredictiveOnOffSettingL(
       
   248                     ETrue,
       
   249                     CGSLangModel::EGSLangJapanese );
       
   250                 }
       
   251             else if( Container()->CurrentFeatureId() == EGSLangIdJQC )
       
   252                 {
       
   253                 ChangeJapQwertySettingL( EGSJapQwertyFlagComma,
       
   254                                          EGSLangIdJQC, ETrue );
       
   255                 }
       
   256             else if( Container()->CurrentFeatureId() == EGSLangIdJQP )
       
   257                 {
       
   258                 ChangeJapQwertySettingL( EGSJapQwertyFlagPeriod,
       
   259                                          EGSLangIdJQP, ETrue );
       
   260                 }
       
   261             else if( Container()->CurrentFeatureId() == EGSLangIdJQWSP )
       
   262                 {
       
   263                 ChangeJapQwertySettingL( EGSJapQwertyFlagSpaceFullWidth,
       
   264                                          EGSLangIdJQWSP, ETrue );
       
   265                 }
       
   266             else if ( Container()->CurrentFeatureId() == EGSLangIdPredictiveMode )
       
   267             	{
       
   268 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
   269                if( Container()->Model()->CheckAutoWordCompletionSupportL() )
       
   270                    {
       
   271             	   ShowPredictiveModeSettingPageL( ETrue );
       
   272             	   }
       
   273 #endif 
       
   274            	 	}
       
   275 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   276             else if ( Container()->CurrentFeatureId() == EGSLangIdPredictiveOptions )
       
   277                 {
       
   278                 // Show full ITI predictive settings list
       
   279                 ShowPredictiveSettingListL();
       
   280                 }
       
   281 #endif // RD_INTELLIGENT_TEXT_INPUT
       
   282            	else
       
   283                 {
       
   284                 HandleListBoxSelectionL();
       
   285                 }
       
   286             break;
       
   287         case EAknSoftkeyBack:
       
   288             //In 5.0 "Language" settings were moved from Psln to Device view
       
   289             #ifdef RD_CONTROL_PANEL //For S60 5.0
       
   290 		        AppUi()->ActivateLocalViewL( KGSGenPluginUid );
       
   291             #else //RD_CONTROL_PANEL 
       
   292             AppUi()->ActivateLocalViewL( KGSPrslnPluginUid );
       
   293 			#endif //RD_CONTROL_PANEL
       
   294             break;
       
   295         case EAknCmdHelp:
       
   296             {
       
   297             if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   298                 {
       
   299                 HlpLauncher::LaunchHelpApplicationL(
       
   300                     iEikonEnv->WsSession(), AppUi()->AppHelpContextL() );
       
   301                 }
       
   302             break;
       
   303             }
       
   304         default:
       
   305             AppUi()->HandleCommandL( aCommand );
       
   306             break;
       
   307         }
       
   308     }
       
   309 
       
   310 // ========================= From CGSPluginInterface ==================
       
   311 
       
   312 
       
   313 // -----------------------------------------------------------------------------
       
   314 // CGSLangPlugin::GetCaptionL
       
   315 //
       
   316 //
       
   317 // -----------------------------------------------------------------------------
       
   318 //
       
   319 void CGSLangPlugin::GetCaptionL( TDes& aCaption ) const
       
   320     {
       
   321     HBufC* result = StringLoader::LoadL( R_GS_LANG_PLUGIN_CAPTION );
       
   322     aCaption.Copy( *result );
       
   323     delete result;
       
   324     }
       
   325 
       
   326 
       
   327 // -----------------------------------------------------------------------------
       
   328 // CGSLangPlugin::PluginProviderCategory
       
   329 //
       
   330 //
       
   331 // -----------------------------------------------------------------------------
       
   332 //
       
   333 TInt CGSLangPlugin::PluginProviderCategory() const
       
   334     {
       
   335     //This plugin is created by 3rd party.
       
   336     return KGSPluginProviderInternal;
       
   337     }
       
   338 
       
   339 // ========================= From CGSBaseView ==================
       
   340 
       
   341 
       
   342 // -----------------------------------------------------------------------------
       
   343 // CGSLangPlugin::NewContainerL
       
   344 //
       
   345 //
       
   346 // -----------------------------------------------------------------------------
       
   347 //
       
   348 void CGSLangPlugin::NewContainerL()
       
   349     {
       
   350     iContainer = new(ELeave) CGSLangContainer;
       
   351     }
       
   352 
       
   353 
       
   354 // -----------------------------------------------------------------------------
       
   355 // CGSLangPlugin::HandleListBoxSelectionL
       
   356 //
       
   357 //
       
   358 // -----------------------------------------------------------------------------
       
   359 //
       
   360 void CGSLangPlugin::HandleListBoxSelectionL()
       
   361     {
       
   362     const TInt currentFeatureId = Container()->CurrentFeatureId();
       
   363 
       
   364     switch ( currentFeatureId )
       
   365         {
       
   366         case EGSLangIdDTL:
       
   367             ShowLanguageSelectionSettingPageL();
       
   368             break;
       
   369         case EGSLangIdITL:
       
   370 
       
   371 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   372 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
   373             TInt keyboardLayout = 0;
       
   374             RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
       
   375             TPtiKeyboardType layout = (TPtiKeyboardType)keyboardLayout;            
       
   376             // Currently dual language feature would work correctly for ITUT and Half Qwerty products 
       
   377             // Hence the dual language settings should also be displayed only for ITUT and Halfqwerty products
       
   378             if(layout == EPtiKeyboard12Key || layout == EPtiKeyboardHalfQwerty )
       
   379                 {
       
   380 	            // Show Dual language selection setting list
       
   381 	            /* In Chinese/Japanese language variant,if there are more than one languages supporting dual language feature,
       
   382 	            display writing language setting view in which Primary and Secondary Languages can be selected from the list.
       
   383             
       
   384 	            In Chinese language variant,if there is only one language supporting dual language feature, 
       
   385 	            no need to display the Writing language view which contains Primary and Secondary Language. 
       
   386 	            Instead we can display the Writing language list directly to the user;from which the user can select the writing language*/
       
   387 		            if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) ||  FeatureManager::FeatureSupported( KFeatureIdChinese ) )
       
   388 		                {		                
       
   389 		                CPtiEngine* ptiEngine = CPtiEngine::NewL();
       
   390 		                CleanupStack::PushL( ptiEngine );
       
   391 		                CArrayFixFlat<TInt>* languages = new( ELeave )CArrayFixFlat<TInt>( 10 );
       
   392 		                CleanupStack::PushL( languages );
       
   393 		                ptiEngine->GetAvailableLanguagesL( languages );
       
   394 	                
       
   395 		                TInt count = languages->Count();  
       
   396 		                TInt noLangSupportWesternPred = count; 
       
   397 	                
       
   398 		                for (TInt index = 0; index < count; index++)
       
   399 		                    {      
       
   400 		                    const TInt langCode = languages->At(index);
       
   401 		                    if (langCode == ELangTaiwanChinese ||
       
   402 		                       langCode == ELangHongKongChinese ||
       
   403 		                       langCode == ELangPrcChinese ||
       
   404 		                       langCode == ELangJapanese ||
       
   405 		                       langCode == ELangKorean )
       
   406 		                        {
       
   407 		                        noLangSupportWesternPred--;
       
   408 		                        }            
       
   409 		                    }                               
       
   410 	             
       
   411 		                CleanupStack::PopAndDestroy(languages);
       
   412 		                CleanupStack::PopAndDestroy(ptiEngine);
       
   413 	            
       
   414 		                if( noLangSupportWesternPred > 1 )
       
   415 		                    {
       
   416 		                    ShowDualInputLanguageSettingListL();
       
   417 		                    }
       
   418 		                else
       
   419 	                    ShowInputSelectionSettingPageL();
       
   420 	                  }
       
   421 	            	else            
       
   422 	                	ShowDualInputLanguageSettingListL();
       
   423 								}
       
   424 	        	else 
       
   425             		ShowInputSelectionSettingPageL();
       
   426 #else //FF_DUAL_LANGUAGE_SUPPORT
       
   427             ShowInputSelectionSettingPageL();
       
   428 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
   429 #else //RD_INTELLIGENT_TEXT_INPUT
       
   430 			ShowInputSelectionSettingPageL();
       
   431 #endif //RD_INTELLIGENT_TEXT_INPUT
       
   432             break;
       
   433         case EGSLangAHNumberMode:
       
   434             if( iElaf )
       
   435                 {
       
   436                 ShowAHNumberModeSettingPageL();
       
   437                 }
       
   438             break;
       
   439         case EGSLangHindiNumberMode:
       
   440             ShowHindiNumberModeSettingPageL();
       
   441             break;
       
   442         case EGSLangIdT9L:
       
   443             if ( !FeatureManager::FeatureSupported( KFeatureIdJapanese ) )
       
   444                 {
       
   445 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   446                 // Launch Predictive mode setting page if >1 keyboards available on device
       
   447                 // Otherwise just change the setting value for the only keyboard
       
   448                 TInt keyboardLayout = 0;
       
   449                 RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
       
   450                 TPtiKeyboardType layout = (TPtiKeyboardType)keyboardLayout;
       
   451                 TBool isPredictionSupport = EFalse;
       
   452                 switch(layout)
       
   453                 {
       
   454                 case EPtiKeyboardHalfQwerty:
       
   455                 	isPredictionSupport = Container()->Model()->CheckT9FromPtiLForPredictionL((TPtiEngineInputMode)EPtiEngineHalfQwertyPredictive);
       
   456                   break;
       
   457                 case EPtiKeyboardQwerty4x12:
       
   458                 case EPtiKeyboardQwerty4x10:  
       
   459                 case EPtiKeyboardQwerty3x11:
       
   460                 case EPtiKeyboardCustomQwerty:
       
   461                 	isPredictionSupport = Container()->Model()->CheckT9FromPtiLForPredictionL((TPtiEngineInputMode)EPtiEngineQwertyPredictive);
       
   462                   break;
       
   463                 case EPtiKeyboardNone:
       
   464                 case EPtiKeyboard12Key:
       
   465                 	isPredictionSupport = Container()->Model()->CheckT9FromPtiLForPredictionL((TPtiEngineInputMode)EPtiEnginePredictive);
       
   466                   break;
       
   467                 default:
       
   468                 	isPredictionSupport = Container()->Model()->CheckT9FromPtiLForPredictionL((TPtiEngineInputMode)EPtiEnginePredictive);
       
   469                   break;    
       
   470                   }
       
   471                 if (isPredictionSupport)
       
   472                 	ShowITIMultiSettingPageL(EFalse);
       
   473 #else
       
   474                 //change setting without opening the setting page
       
   475                 Container()->Model()->ChangePredictiveOnOffSettingL(
       
   476                     EFalse,
       
   477                     CGSLangModel::EGSLangOther );
       
   478 #endif
       
   479                 }
       
   480             break;
       
   481         case EGSLangIdEPT:
       
   482             if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) )
       
   483                 {
       
   484                 Container()->Model()->ChangePredictiveOnOffSettingL(
       
   485                     EFalse,
       
   486                     CGSLangModel::EGSLangOther );
       
   487                 }
       
   488             break;
       
   489         case EGSLangIdResetAtokDict:
       
   490             if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) )
       
   491                 {
       
   492                 ResetATOKDictionaryL();
       
   493                 }
       
   494             break;
       
   495         case EGSLangIdJPT:
       
   496             if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) )
       
   497                 {
       
   498                 Container()->Model()->ChangePredictiveOnOffSettingL(
       
   499                     EFalse,
       
   500                     CGSLangModel::EGSLangJapanese );
       
   501                 }
       
   502             break;
       
   503         case EGSLangIdKT:
       
   504             if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) )
       
   505                 {
       
   506                 ShowKeypressTimeoutSettingPageL();
       
   507                 }
       
   508             break;
       
   509         case EGSLangIdJQC:
       
   510             if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) &&
       
   511                  FeatureManager::FeatureSupported( KFeatureIdQwertyInput ) )
       
   512                 {
       
   513                 ChangeJapQwertySettingL( EGSJapQwertyFlagComma,
       
   514                                          currentFeatureId, EFalse );
       
   515                 }
       
   516             break;
       
   517         case EGSLangIdJQP:
       
   518             if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) &&
       
   519                  FeatureManager::FeatureSupported( KFeatureIdQwertyInput ) )
       
   520                 {
       
   521                 ChangeJapQwertySettingL( EGSJapQwertyFlagPeriod,
       
   522                                          currentFeatureId, EFalse );
       
   523                 }
       
   524             break;
       
   525         case EGSLangIdJQWSP:
       
   526             if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) &&
       
   527                  FeatureManager::FeatureSupported( KFeatureIdQwertyInput ) )
       
   528                 {
       
   529                 ChangeJapQwertySettingL( EGSJapQwertyFlagSpaceFullWidth,
       
   530                                          currentFeatureId, EFalse );
       
   531                 }
       
   532             break;
       
   533         case EGSLangIdDIM:
       
   534             if ( FeatureManager::FeatureSupported( KFeatureIdChinese ) )
       
   535                 {
       
   536                 ShowDefaultInputMethodSettingPageL();
       
   537                 }
       
   538             break;
       
   539         case EGSLangIdCangJie:
       
   540             if ( FeatureManager::FeatureSupported( KFeatureIdChinese ) &&
       
   541                  Container()->Model()->DefaultInputMethodL() == ECangJie )
       
   542                 {
       
   543                 ShowChiCangJieInputModeSettingPageL();
       
   544                 }
       
   545             break;
       
   546         case EGSLangIdPredictiveMode:
       
   547 #ifndef RD_INTELLIGENT_TEXT_INPUT
       
   548            if( Container()->Model()->CheckAutoWordCompletionSupportL() )
       
   549                {
       
   550         	   ShowPredictiveModeSettingPageL( EFalse );
       
   551         	   }
       
   552 #endif
       
   553             break;
       
   554 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
   555         case EGSLangIdPredictiveOptions:
       
   556             // Show full ITI predictive settings list
       
   557             ShowPredictiveSettingListL();
       
   558             break;
       
   559 #endif
       
   560         default:
       
   561             break;
       
   562         }
       
   563     }
       
   564 
       
   565 // ========================= New ======================================
       
   566 
       
   567 
       
   568 // -----------------------------------------------------------------------------
       
   569 // CGSLangPlugin::CGSLangPlugin
       
   570 //
       
   571 //
       
   572 // -----------------------------------------------------------------------------
       
   573 //
       
   574 CGSLangContainer* CGSLangPlugin::Container()
       
   575     {
       
   576     CGSLangContainer* container = static_cast<CGSLangContainer*>( iContainer );
       
   577     return container;
       
   578     }
       
   579 
       
   580 
       
   581 // -----------------------------------------------------------------------------
       
   582 // CGSLangPlugin::ShowLanguageSelectionSettingPageL
       
   583 //
       
   584 //
       
   585 // -----------------------------------------------------------------------------
       
   586 //
       
   587 void CGSLangPlugin::ShowLanguageSelectionSettingPageL()
       
   588     {
       
   589     // If the setting page has a list create array which contains all
       
   590     // the items of the list in the setting page:
       
   591 
       
   592     // Set up UI language arrays
       
   593     CArrayFixFlat<TInt>* systemEpocLanguageCodes = 0;
       
   594     // This creates the list itself
       
   595     User::LeaveIfError( SysLangUtil::GetInstalledLanguages(
       
   596                                      systemEpocLanguageCodes ) );
       
   597     CleanupStack::PushL( systemEpocLanguageCodes );
       
   598 
       
   599     CArrayFixFlat<TInt>* dtlanguages = new(ELeave)CArrayFixFlat<TInt>(4);
       
   600     CleanupStack::PushL( dtlanguages );
       
   601     // Append "automatic" language into dtitems array
       
   602     dtlanguages->AppendL( 0 );
       
   603     // and get text for automatic from resource...
       
   604     CDesCArrayFlat* dtitems = iCoeEnv->ReadDesC16ArrayResourceL(
       
   605                             R_DISPLAY_TEXT_LANGUAGE_SETTING_PAGE_LBX );
       
   606     CleanupStack::PushL( dtitems );
       
   607 
       
   608     Container()->Model()->GetLanguagesFromPtiL(
       
   609                            systemEpocLanguageCodes,
       
   610                            dtlanguages, dtitems );
       
   611 
       
   612     TInt count = dtlanguages->Count();
       
   613     TInt currentItem = 0; // default value is Automatic
       
   614 
       
   615     //fetch the current value from model:
       
   616     TInt uiLanguage = Container()->Model()->LanguageL( CGSLangModel::EGSUiLanguage );
       
   617 
       
   618     // find the match epoc language code and set to UI array
       
   619     TInt i=0;
       
   620     for ( ; i < count; i++ )
       
   621         {
       
   622         if ( ( *dtlanguages )[i] == uiLanguage )
       
   623             {
       
   624             currentItem = i;
       
   625             break;
       
   626             }
       
   627         }
       
   628     // create setting page:
       
   629     TInt oldItem = currentItem;
       
   630     CAknSettingPage* dlg =
       
   631         new( ELeave ) CAknRadioButtonSettingPage(
       
   632                        R_DISPLAY_TEXT_LANGUAGE_SETTING_PAGE,
       
   633                        currentItem, dtitems );
       
   634 
       
   635     // Execute the setting page and check if the setting value was changed:
       
   636     if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) )
       
   637         {
       
   638         if ( oldItem != currentItem )
       
   639             {
       
   640             // Check if there is enough space in disk
       
   641             if ( Container()->Model()->CheckDiskSpaceL() )
       
   642                 {
       
   643                 // Show information note
       
   644                 HBufC* prompt = iCoeEnv->AllocReadResourceLC( R_GS_NOT_ENOUGH_MEMORY );
       
   645 
       
   646                 CAknInformationNote* note = 
       
   647                      new( ELeave ) CAknInformationNote( ETrue );
       
   648                 note->ExecuteLD( *prompt );
       
   649                 
       
   650                 CleanupStack::PopAndDestroy( prompt );
       
   651                 }
       
   652             else
       
   653                 {
       
   654                 ConfirmRebootDTLL( ( *dtlanguages )[ currentItem ],
       
   655                                ( *dtitems )[ currentItem ] );
       
   656                 }
       
   657             }
       
   658         }
       
   659     // Delete items:
       
   660     //dtitems, dtlanguages & systemEpocLanguageCodes
       
   661     CleanupStack::PopAndDestroy(3);
       
   662 
       
   663     }
       
   664 
       
   665 
       
   666 // -----------------------------------------------------------------------------
       
   667 // CGSLangPlugin::ShowInputSelectionSettingPageL
       
   668 //
       
   669 //
       
   670 // -----------------------------------------------------------------------------
       
   671 //
       
   672 void CGSLangPlugin::ShowInputSelectionSettingPageL()
       
   673     {
       
   674     // If the setting page has a list create array which contains all
       
   675     // the items of the list in the setting page:
       
   676 
       
   677     //some dummy size of 10
       
   678     CArrayFixFlat<TInt>* languages =
       
   679                new( ELeave )CArrayFixFlat<TInt>(10);
       
   680     CleanupStack::PushL( languages );
       
   681 
       
   682     //some dummy size of 10
       
   683     CDesCArrayFlat* items = new( ELeave )CDesCArrayFlat(10);
       
   684     CleanupStack::PushL( items );
       
   685 
       
   686     Container()->Model()->GetLanguagesFromPtiL( NULL,
       
   687                                                 languages, items );
       
   688     TInt i;
       
   689     TInt currentItem = 0;
       
   690 
       
   691     //fetch the current value from model:
       
   692     // current item is the decimal value of T9 language code from shared data
       
   693     TInt currentInputLanguage =
       
   694          Container()->Model()->LanguageL( CGSLangModel::EGSInputLanguage );
       
   695 
       
   696     // total sum of available T9 dictionaries
       
   697     TInt count = languages->Count();
       
   698 
       
   699     // compare sharedata languageCode with PtiLanguageCode array
       
   700     // Ptilanguage <-> listindex converter
       
   701 
       
   702     for ( i=0;i<count;i++ )
       
   703         {
       
   704         if ((*languages)[i] == currentInputLanguage)
       
   705         {
       
   706         currentItem = i;
       
   707         break;
       
   708         }
       
   709     }
       
   710     // create setting page:
       
   711     CAknSettingPage* dlg =
       
   712         new( ELeave ) CAknRadioButtonSettingPage(
       
   713                          R_INPUT_TEXT_LANGUAGE_SETTING_PAGE,
       
   714                          currentItem, items );
       
   715     TInt previous = Container()->Model()->LanguageL( CGSLangModel::EGSInputLanguage );
       
   716     // Execute the setting page and check if the setting value was changed:
       
   717     if ( dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged ) )
       
   718         {
       
   719         //if the value was changed set the value to model
       
   720         Container()->Model()->SetLanguageL( CGSLangModel::EGSInputLanguage,
       
   721                                       ( *languages )[ currentItem ] );
       
   722         //inform all other apps about language change.
       
   723         TWsEvent event;
       
   724         event.SetType( KEikInputLanguageChange  );
       
   725         iEikonEnv->WsSession().SendEventToAllWindowGroups( event );
       
   726 
       
   727         //if updated
       
   728         if ( previous !=
       
   729                 Container()->Model()->LanguageL( CGSLangModel::EGSInputLanguage ) )
       
   730             {
       
   731             //Update setting list:
       
   732             Container()->UpdateListBoxL( EGSLangIdITL );
       
   733             Container()->UpdateListBoxL( EGSLangIdT9L );
       
   734             Container()->UpdateListBoxL( EGSLangIdPredictiveMode );
       
   735             }
       
   736         TInt current = Container()->Model()->LanguageL( CGSLangModel::EGSInputLanguage );
       
   737         if ( ( (current == ELangPrcChinese || current == ELangHongKongChinese
       
   738             || current == ELangTaiwanChinese) && previous != current)
       
   739             || ( (current != ELangPrcChinese || current != ELangHongKongChinese
       
   740             || current != ELangTaiwanChinese) && previous != current) )
       
   741             {
       
   742             if (current == ELangPrcChinese )
       
   743                 {
       
   744                 Container()->Model()->SetDefaultInputMethodL( EPinyin );
       
   745                 }
       
   746             else if ( current == ELangHongKongChinese )
       
   747                 {
       
   748                 Container()->Model()->SetDefaultInputMethodL( EStroke );
       
   749                 }
       
   750             else if ( current == ELangTaiwanChinese )
       
   751                 {
       
   752                 Container()->Model()->SetDefaultInputMethodL( EZhuyin );
       
   753                 }
       
   754             Container()->UpdateListBoxL( EGSLangIdDIM );
       
   755             }
       
   756         }
       
   757     // Delete items:
       
   758     CleanupStack::PopAndDestroy(2);    // items and languages
       
   759     }
       
   760 
       
   761 
       
   762 // -----------------------------------------------------------------------------
       
   763 // CGSLangPlugin::ShowDefaultInputMethodSettingPageL
       
   764 //
       
   765 //
       
   766 // -----------------------------------------------------------------------------
       
   767 //
       
   768 void CGSLangPlugin::ShowDefaultInputMethodSettingPageL()
       
   769     {
       
   770     // If the setting page has a list create array which contains all
       
   771     // the items of the list in the setting page:
       
   772 
       
   773     // Find correct Language resource among PRC, HK and TW.
       
   774     TInt resId = 0;
       
   775     TInt lang = Container()->Model()->LanguageL( CGSLangModel::EGSInputLanguage );
       
   776     
       
   777     if ( FeatureManager::FeatureSupported( KFeatureIdQwertyInput ) 
       
   778         || (FeatureManager::FeatureSupported(KFeatureIdVirtualKeyboardInput) &&
       
   779            FeatureManager::FeatureSupported(KFeatureIdChinese)))
       
   780         {
       
   781         resId = R_DIM_QWERTY_SETTING_PAGE_LBX;
       
   782         }
       
   783     else
       
   784         {
       
   785         resId = R_DIM_SETTING_PAGE_LBX;
       
   786         }
       
   787       
       
   788     TInt keyboardLayout = 0;
       
   789     RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
       
   790     TPtiKeyboardType layout = (TPtiKeyboardType)keyboardLayout;
       
   791     
       
   792     // Get the static items here
       
   793     CGSRadioButtonSettingPageItemTextArray* items = 
       
   794         CGSRadioButtonSettingPageItemTextArray::NewL( resId, *iCoeEnv, NULL );
       
   795         
       
   796     
       
   797     CleanupStack::PushL(items);
       
   798 	
       
   799 	TBool isCangjieSupported = EFalse;
       
   800 
       
   801     
       
   802     switch( lang )
       
   803         {
       
   804         case ELangPrcChinese:
       
   805             if ( FeatureManager::FeatureSupported( KFeatureIdQwertyInput )
       
   806                || FeatureManager::FeatureSupported(KFeatureIdVirtualKeyboardInput))
       
   807                 {
       
   808                 items->SetItemVisibilityL( EGSLangSPIdQwPinyin, 
       
   809                                    CGSListBoxItemTextArray::EVisible );
       
   810                 }
       
   811             else
       
   812                 {
       
   813                 items->SetItemVisibilityL( EGSLangSPIdPinyin, 
       
   814                                    CGSListBoxItemTextArray::EVisible );
       
   815                 }
       
   816             break;
       
   817         case ELangHongKongChinese:
       
   818             if ( FeatureManager::FeatureSupported( KFeatureIdQwertyInput )
       
   819                || FeatureManager::FeatureSupported(KFeatureIdVirtualKeyboardInput))
       
   820                 {
       
   821 				if(!(layout == EPtiKeyboard12Key || layout == EPtiKeyboardHalfQwerty))
       
   822                     {
       
   823 					isCangjieSupported = ETrue;
       
   824 					}
       
   825                 if ( Container()->Model()->CheckCangjieSupportL( ELangHongKongChinese ) && isCangjieSupported )
       
   826                     {
       
   827                     
       
   828                     //Cangjie input mode is only valid for QWERTY input and Virtual keyboard Input 
       
   829                     //Putting condition for 12 key and half QWERTY keyboard layout.
       
   830                     
       
   831                         items->SetItemVisibilityL( EGSLangSPIdQwCangJie, 
       
   832                                        CGSListBoxItemTextArray::EVisible );
       
   833                         
       
   834                     
       
   835                     }
       
   836                 }
       
   837             break;
       
   838         case ELangTaiwanChinese:
       
   839             if ( FeatureManager::FeatureSupported( KFeatureIdQwertyInput ) 
       
   840                || FeatureManager::FeatureSupported(KFeatureIdVirtualKeyboardInput))
       
   841                 {
       
   842                 items->SetItemVisibilityL( EGSLangSPIdQwZhuyin, 
       
   843                                    CGSListBoxItemTextArray::EVisible );
       
   844                 }
       
   845             else
       
   846                 {
       
   847                 items->SetItemVisibilityL( EGSLangSPIdZhuyin, 
       
   848                                    CGSListBoxItemTextArray::EVisible );
       
   849                 }
       
   850             break;
       
   851         default:
       
   852             break;
       
   853         }
       
   854     
       
   855     //fetch the current value from model:
       
   856     // current item is the Hexadecimal value of Input method code from CenRep
       
   857     TInt oldInputMethodCode =
       
   858              Container()->Model()->DefaultInputMethodL();
       
   859     TInt currentItem = 0;
       
   860 
       
   861     // Construct a map for PRC,HK and TW for Input Method codes
       
   862     struct TMapArray { TInt iInputMethodCode; TInt index0, index1, index2; };
       
   863      //Note: The values 0, 1, 2, 3 have been used to align with the setting page indices
       
   864 	 
       
   865 	TMapArray qwertyMethodMap_Cangjie[] = {
       
   866         //            PRC, HK, TW
       
   867         { EPinyin     , 0, -1, -1 },
       
   868         { EZhuyin     ,-1, -1,  0 },
       
   869         { EStroke     , 1,  0,  1 },
       
   870         { ECangJie    ,-1,  1, -1 },
       
   871         { ELatin      , 2,  2,  2 }
       
   872      };
       
   873      
       
   874      TMapArray qwertyMethodMap_NoCangjie[] = {
       
   875         //            PRC, HK, TW
       
   876         { EPinyin     , 0, -1, -1 },
       
   877         { EZhuyin     ,-1, -1,  0 },
       
   878         { EStroke     , 1,  0,  1 },
       
   879         { ECangJie    ,-1, -1, -1 },
       
   880         { ELatin      , 2,  1,  2 }
       
   881         };
       
   882         
       
   883     TMapArray itutMethodMap[] = {
       
   884         //            PRC, HK, TW
       
   885         { EPinyin     , 0, -1, -1 },
       
   886         { EZhuyin     ,-1, -1,  0 },
       
   887         { EStroke     , 1,  0,  1 },
       
   888         { ELatinText  , 2,  1,  2 },
       
   889         { ELatinUpper , 3,  2,  3 },
       
   890         { ELatinLower , 4,  3,  4 }
       
   891      }; 
       
   892     
       
   893     TMapArray halfQwertyMethodMap[] = {
       
   894         //            PRC, HK, TW
       
   895         { EPinyin     , 0, -1, -1 },
       
   896         { EZhuyin     ,-1, -1,  0 },
       
   897         { EStroke     , 1,  0,  1 },
       
   898         { ECangJie    ,-1, -1, -1 },
       
   899         { ELatin      , 2,  1,  2 }
       
   900      };
       
   901     
       
   902     TInt itemsNum = KGSMapSize;
       
   903     TMapArray* methodMap = NULL;
       
   904     if ( layout == EPtiKeyboardHalfQwerty )
       
   905         {
       
   906         methodMap = halfQwertyMethodMap;
       
   907         itemsNum = sizeof( halfQwertyMethodMap ) / sizeof( TMapArray );
       
   908         }
       
   909     else if ( FeatureManager::FeatureSupported( KFeatureIdQwertyInput ) 
       
   910             || (FeatureManager::FeatureSupported(KFeatureIdVirtualKeyboardInput) &&
       
   911                     FeatureManager::FeatureSupported(KFeatureIdChinese)))
       
   912         {
       
   913 		    if (isCangjieSupported)
       
   914 		        {
       
   915 			      methodMap = qwertyMethodMap_Cangjie;
       
   916 			      itemsNum = sizeof( qwertyMethodMap_Cangjie ) / sizeof( TMapArray );
       
   917 			      }
       
   918 		    else
       
   919 		        {
       
   920 			      methodMap = qwertyMethodMap_NoCangjie;
       
   921 			      itemsNum = sizeof( qwertyMethodMap_NoCangjie ) / sizeof( TMapArray );
       
   922 			      }
       
   923         }
       
   924     else
       
   925         {
       
   926         methodMap = itutMethodMap;
       
   927         itemsNum = sizeof( itutMethodMap ) / sizeof( TMapArray );
       
   928         }
       
   929     for(TInt i = 0; i < itemsNum && i < KGSMapSize; i++)
       
   930         {
       
   931         if (oldInputMethodCode == methodMap[i].iInputMethodCode)
       
   932             {
       
   933             TInt val = 0;
       
   934             if ( lang == ELangPrcChinese )      { val = methodMap[i].index0; }
       
   935             if ( lang == ELangHongKongChinese ) { val = methodMap[i].index1; }
       
   936             if ( lang == ELangTaiwanChinese )   { val = methodMap[i].index2; }
       
   937             currentItem = val;
       
   938             break;
       
   939             }
       
   940         }
       
   941     if ( currentItem == -1 ) 
       
   942         { 
       
   943         currentItem = 0;
       
   944         }
       
   945 
       
   946     // create setting page:
       
   947     CAknSettingPage* dlg =new( ELeave ) CAknRadioButtonSettingPage(
       
   948         R_CH_DEFAULT_INPUT_METHOD_SETTING_PAGE,
       
   949         currentItem,
       
   950         items );
       
   951 
       
   952     // Execute the setting page and check if the setting value was changed:
       
   953     if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged))
       
   954         {
       
   955         TInt newInputMethodCode=EPinyin;
       
   956 
       
   957         for (TInt j = 0; j < KGSMapSize; j++)
       
   958             {
       
   959             TInt val = 0;
       
   960             if ( lang == ELangPrcChinese )      { val = methodMap[j].index0; }
       
   961             if ( lang == ELangHongKongChinese ) { val = methodMap[j].index1; }
       
   962             if ( lang == ELangTaiwanChinese )   { val = methodMap[j].index2; }
       
   963 
       
   964             if ( currentItem == val )
       
   965                 {
       
   966                 newInputMethodCode = methodMap[j].iInputMethodCode;
       
   967                 break;
       
   968                 }
       
   969             }
       
   970         //if the value was changed set the value to model
       
   971         Container()->Model()->SetDefaultInputMethodL( newInputMethodCode );
       
   972 
       
   973         //Update setting list:
       
   974         Container()->UpdateListBoxL( EGSLangIdDIM );
       
   975         // If CangJie input is selected, then make the CangJie input list
       
   976         // item visible in the UI.
       
   977         if ( newInputMethodCode == ECangJie )
       
   978             {
       
   979             Container()->UpdateListBoxL( EGSLangIdCangJie );
       
   980             }
       
   981         Container()->MakeListItemVisibleL( EGSLangIdCangJie, EGSLangIdDIM );      
       
   982         }
       
   983     // Delete items:
       
   984     CleanupStack::PopAndDestroy( items );
       
   985     }
       
   986 
       
   987 
       
   988 // -----------------------------------------------------------------------------
       
   989 // CGSLangPlugin::ShowAHNumberModeSettingPageL
       
   990 //
       
   991 // Show A&H number mode setting page
       
   992 // -----------------------------------------------------------------------------
       
   993 //
       
   994 TBool CGSLangPlugin::ShowAHNumberModeSettingPageL()
       
   995     {
       
   996     // This updates also the iAHNumberModeItems which should be checked before
       
   997     // using them.
       
   998     Container()->UpdateListBoxL( EGSLangAHNumberMode );
       
   999 
       
  1000     TInt currentItem = 
       
  1001         Container()->Model()->DefaultNumberMode( EGSNbrModeTypeArabic );
       
  1002 
       
  1003     CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
       
  1004         R_AH_NUMBER_MODE_SETTINGS_PAGE,
       
  1005         currentItem,
       
  1006         Container()->NumberModeItems( EGSNbrModeTypeArabic ) );
       
  1007 
       
  1008     TBool ret = dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
       
  1009 
       
  1010     // Code to obtain the visual appearance of the date.
       
  1011     TAknVisualDateFormat visualDateFormat;
       
  1012         {
       
  1013             TLocale locale;
       
  1014             visualDateFormat =
       
  1015             AknDateFormatUtils::MapSymbianDateFormatToVisualDateFormat(
       
  1016                                 locale.DateFormat(), NULL );
       
  1017             }
       
  1018     
       
  1019     const TInt uiLang = 
       
  1020           Container()->Model()->LanguageL( CGSLangModel::EGSUiLanguage );
       
  1021     if ( ( uiLang == ELangUrdu || User::Language() == ELangUrdu ) || 
       
  1022          ( uiLang == ELangFarsi || User::Language() == ELangFarsi) )
       
  1023         {
       
  1024         Container()->Model()->SetDefaultNumberMode( currentItem, 
       
  1025                                                 EGSNbrModeTypeEasternArabic );
       
  1026         }
       
  1027     else
       
  1028         {
       
  1029         Container()->Model()->SetDefaultNumberMode( currentItem, 
       
  1030                                                 EGSNbrModeTypeArabic );
       
  1031         }
       
  1032 
       
  1033     // Code to set ensure the visual appearance stays stable.
       
  1034     TLocale locale;
       
  1035     TDateFormat newFormat =
       
  1036         AknDateFormatUtils::MapVisualDateFormatToSymbianDateFormat(
       
  1037                             visualDateFormat, NULL );
       
  1038     if ( newFormat != locale.DateFormat())
       
  1039         {
       
  1040         locale.SetDateFormat( newFormat );
       
  1041         locale.Set();
       
  1042         }
       
  1043 
       
  1044     TWsEvent event;
       
  1045     event.SetType( KEikInputLanguageChange );
       
  1046     iEikonEnv->WsSession().SendEventToAllWindowGroups( event );
       
  1047 
       
  1048     // value should really be being updated, so update listbox
       
  1049     Container()->UpdateListBoxL( EGSLangAHNumberMode );
       
  1050 
       
  1051     return ret;
       
  1052     }
       
  1053 
       
  1054 
       
  1055 // -----------------------------------------------------------------------------
       
  1056 // CGSLangPlugin::ShowHindiNumberModeSettingPageL
       
  1057 //
       
  1058 // Show Hindi number mode setting page
       
  1059 // -----------------------------------------------------------------------------
       
  1060 //
       
  1061 TBool CGSLangPlugin::ShowHindiNumberModeSettingPageL()
       
  1062     {
       
  1063     // This updates also the iHindiNumberModeItems which should be checked before
       
  1064     // using them.
       
  1065     Container()->UpdateListBoxL( EGSLangHindiNumberMode );
       
  1066 
       
  1067     TInt currentItem = 
       
  1068         Container()->Model()->DefaultNumberMode( EGSNbrModeTypeIndic );
       
  1069 
       
  1070     CAknRadioButtonSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
       
  1071         R_HI_NUMBER_MODE_SETTINGS_PAGE,
       
  1072         currentItem,
       
  1073         Container()->NumberModeItems( EGSNbrModeTypeIndic ) );
       
  1074 
       
  1075     TBool ret = dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
       
  1076 
       
  1077     // Code to obtain the visual appearance of the date.
       
  1078     TAknVisualDateFormat visualDateFormat;
       
  1079         {
       
  1080         TLocale locale;
       
  1081         visualDateFormat =
       
  1082         AknDateFormatUtils::MapSymbianDateFormatToVisualDateFormat(
       
  1083                             locale.DateFormat(), NULL );
       
  1084         }
       
  1085         
       
  1086     Container()->Model()->SetDefaultNumberMode( currentItem, 
       
  1087                                                 EGSNbrModeTypeIndic );
       
  1088 
       
  1089     // Code to set ensure the visual appearance stays stable.
       
  1090     TLocale locale;
       
  1091     TDateFormat newFormat =
       
  1092         AknDateFormatUtils::MapVisualDateFormatToSymbianDateFormat(
       
  1093                             visualDateFormat, NULL );
       
  1094     if ( newFormat != locale.DateFormat())
       
  1095         {
       
  1096         locale.SetDateFormat( newFormat );
       
  1097         locale.Set();
       
  1098         }
       
  1099 
       
  1100     TWsEvent event;
       
  1101     event.SetType( KEikInputLanguageChange );
       
  1102     iEikonEnv->WsSession().SendEventToAllWindowGroups( event );
       
  1103 
       
  1104     // value should really be being updated, so update listbox
       
  1105     Container()->UpdateListBoxL( EGSLangHindiNumberMode );
       
  1106 
       
  1107     return ret;
       
  1108     }
       
  1109 
       
  1110 
       
  1111 // -----------------------------------------------------------------------------
       
  1112 // CGSLangPlugin::ConfirmRebootDTLL
       
  1113 //
       
  1114 //
       
  1115 // -----------------------------------------------------------------------------
       
  1116 //
       
  1117 void CGSLangPlugin::ConfirmRebootDTLL(   TInt aCurrentLanguage,
       
  1118                                         const TDesC& aLanguageName )
       
  1119     {
       
  1120     //Get information of if there are open connections
       
  1121     TInt callState = CheckCallState();
       
  1122 
       
  1123     // get information of whether there are open connections or not
       
  1124     if ( callState != EPSCTsyCallStateUninitialized &&
       
  1125          callState != EPSCTsyCallStateNone )
       
  1126         {
       
  1127         HBufC* prompt = iCoeEnv->AllocReadResourceLC( R_ACTIVE_CALLS );
       
  1128 
       
  1129         CAknInformationNote* note =
       
  1130             new( ELeave ) CAknInformationNote( ETrue );
       
  1131 
       
  1132         note->ExecuteLD( *prompt );
       
  1133 
       
  1134         CleanupStack::PopAndDestroy( prompt );
       
  1135 
       
  1136         return;
       
  1137         }
       
  1138 
       
  1139     // The activity starts here.
       
  1140     // First, show the confirmation query.
       
  1141     HBufC* buf =
       
  1142         StringLoader::LoadL(R_CONFIRM_DTL_STRING, aLanguageName, iEikonEnv );
       
  1143     CleanupStack::PushL(buf);
       
  1144 
       
  1145     CAknQueryDialog* query =
       
  1146         new( ELeave ) CAknQueryDialog( CAknQueryDialog::ENoTone );
       
  1147     query->PrepareLC( R_CONFIRM_DTL ); // pushes query to cleanupstack
       
  1148     query->SetPromptL( *buf );
       
  1149 
       
  1150     TInt ret = query->RunLD(); // deletes query
       
  1151 
       
  1152     CleanupStack::PopAndDestroy( buf );
       
  1153 
       
  1154     if ( ret )
       
  1155         {
       
  1156         // Code to obtain the visual appearance of the date.
       
  1157         TAknVisualDateFormat visualDateFormat;
       
  1158             {
       
  1159             //This locale is scoped so that it does we get a totally new
       
  1160             //instance later on
       
  1161             TLocale locale;
       
  1162             visualDateFormat =
       
  1163                 AknDateFormatUtils::MapSymbianDateFormatToVisualDateFormat(
       
  1164                                     locale.DateFormat(), NULL );
       
  1165             }
       
  1166         // if the value was changed set the value to model
       
  1167         Container()->Model()->SetLanguageL( CGSLangModel::EGSUiLanguage,
       
  1168                                             aCurrentLanguage );
       
  1169 
       
  1170         // Code to set ensure the visual appearance stays stable.
       
  1171         // Note that we force the language here because User::Language will
       
  1172         // not return the new language
       
  1173         TLocale locale;
       
  1174         TDateFormat newFormat =
       
  1175             AknDateFormatUtils::MapVisualDateFormatToSymbianDateFormat(
       
  1176                              visualDateFormat, (TLanguage*)&aCurrentLanguage );
       
  1177         if ( newFormat != locale.DateFormat() )
       
  1178             {
       
  1179             locale.SetDateFormat( newFormat );
       
  1180             locale.Set();
       
  1181             }
       
  1182         // Update setting list:
       
  1183         Container()->UpdateListBoxL( EGSLangIdDTL );
       
  1184         Container()->UpdateListBoxL( EGSLangIdITL );
       
  1185 
       
  1186         //Updating default input method based on input text language
       
  1187         //Chinese specific feature
       
  1188         if ( aCurrentLanguage == ELangPrcChinese )
       
  1189             {
       
  1190             Container()->Model()->SetDefaultInputMethodL( EPinyin );
       
  1191             }
       
  1192         else if ( aCurrentLanguage == ELangHongKongChinese )
       
  1193             {
       
  1194             Container()->Model()->SetDefaultInputMethodL( EStroke );
       
  1195             }
       
  1196         else if ( aCurrentLanguage == ELangTaiwanChinese )
       
  1197             {
       
  1198             Container()->Model()->SetDefaultInputMethodL( EZhuyin );
       
  1199             }
       
  1200 
       
  1201         TInt satLanguageSelectionTime( 0 );
       
  1202         RProperty::Get( KPSUidSatServer,
       
  1203                         KSatLanguageSelectionTimeBeforeReboot,
       
  1204                         satLanguageSelectionTime );
       
  1205                     
       
  1206         if ( 0 != satLanguageSelectionTime )
       
  1207             {
       
  1208             User::After( satLanguageSelectionTime * 1000 );
       
  1209             }
       
  1210 
       
  1211         // Reboot with Language Switch reason
       
  1212 #ifndef RD_STARTUP_CHANGE
       
  1213         SysStartup::ShutdownAndRestart( AppUi()->Application()->AppDllUid(),
       
  1214                                         ESWLangSwitch );
       
  1215 #else
       
  1216         RStarterSession startSession;
       
  1217         if ( startSession.Connect() == KErrNone )
       
  1218             {
       
  1219             startSession.Reset( RStarterSession::ELanguageSwitchReset );
       
  1220             startSession.Close();
       
  1221             }
       
  1222 #endif // RD_STARTUP_CHANGE
       
  1223         }
       
  1224     }
       
  1225 
       
  1226 
       
  1227 // -----------------------------------------------------------------------------
       
  1228 // CGSLangPlugin::CheckCallState
       
  1229 //
       
  1230 //
       
  1231 // -----------------------------------------------------------------------------
       
  1232 //
       
  1233 TInt CGSLangPlugin::CheckCallState()
       
  1234     {
       
  1235     TInt callState = KErrNone;
       
  1236 
       
  1237     //here are open connections or not
       
  1238     RProperty::Get( KPSUidCtsyCallInformation,
       
  1239                     KCTsyCallState,
       
  1240                     callState );
       
  1241     return callState;
       
  1242     }
       
  1243 
       
  1244 
       
  1245 // -----------------------------------------------------------------------------
       
  1246 // CGSLangPlugin::ResetATOKDictionaryL
       
  1247 //
       
  1248 //
       
  1249 // -----------------------------------------------------------------------------
       
  1250 //
       
  1251 void CGSLangPlugin::ResetATOKDictionaryL()
       
  1252     {
       
  1253     HBufC* buf = StringLoader::LoadL( R_CONFIRM_RESET_ATOK_STRING, iEikonEnv );
       
  1254     CleanupStack::PushL( buf );
       
  1255 
       
  1256     CAknQueryDialog* query =
       
  1257         new( ELeave ) CAknQueryDialog( CAknQueryDialog::ENoTone );
       
  1258     query->PrepareLC( R_CONFIRM_RESET_ATOK );
       
  1259     query->SetPromptL( *buf );
       
  1260 
       
  1261     TInt ret = query->RunLD(); // deletes query
       
  1262     CleanupStack::PopAndDestroy( buf );
       
  1263 
       
  1264     if ( ret )
       
  1265         {
       
  1266         CPtiEngine* ptiEngine = CPtiEngine::NewL();
       
  1267         CleanupStack::PushL( ptiEngine );
       
  1268 
       
  1269         ptiEngine->ActivateLanguageL( ELangJapanese, EPtiEngineHiraganaKanji );
       
  1270         ptiEngine->HandleCommandL( EPtiCommandResetLearningInfo );
       
  1271 
       
  1272         CleanupStack::PopAndDestroy( ptiEngine );
       
  1273         }
       
  1274     }
       
  1275 
       
  1276 
       
  1277 // -----------------------------------------------------------------------------
       
  1278 // CGSLangPlugin::ShowKeypressTimeoutSettingPageL()
       
  1279 // 
       
  1280 // Create a Keypress timeout setting page
       
  1281 // -----------------------------------------------------------------------------
       
  1282 //
       
  1283 void CGSLangPlugin::ShowKeypressTimeoutSettingPageL()
       
  1284     {
       
  1285     // Get current data
       
  1286     const TInt currentTime = Container()->Model()->KeypressTimeout();
       
  1287     TInt currentIndex;
       
  1288     if ( currentTime == 0 )
       
  1289         {
       
  1290         currentIndex = EGSKeypressTimeoutItemNone;
       
  1291         }
       
  1292     else if ( currentTime > KGSMultiTapTimerDefault )
       
  1293         {
       
  1294         currentIndex = EGSKeypressTimeoutItemLong;
       
  1295         }
       
  1296     else if ( currentTime < KGSMultiTapTimerDefault )
       
  1297         {
       
  1298         currentIndex = EGSKeypressTimeoutItemShort;
       
  1299         }
       
  1300     else
       
  1301         {
       
  1302         currentIndex = EGSKeypressTimeoutItemMedium;
       
  1303         }
       
  1304 
       
  1305     // and get text for automatic from resource...
       
  1306     CDesCArrayFlat* items = iCoeEnv->ReadDesC16ArrayResourceL( 
       
  1307                               R_KEYPRESS_TIMEOUT_SETTING_PAGE_LBX );
       
  1308     CleanupStack::PushL( items );
       
  1309 
       
  1310     // create setting page:
       
  1311     TInt oldIndex = currentIndex;
       
  1312     CAknSettingPage* dlg = new( ELeave ) CAknRadioButtonSettingPage
       
  1313                           ( R_KEYPRESS_TIMEOUT_SETTING_PAGE,
       
  1314                             currentIndex, items );
       
  1315 
       
  1316     // Execute the setting page and check if the setting value was changed:
       
  1317     if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) )
       
  1318         {
       
  1319         if ( oldIndex != currentIndex )
       
  1320             {
       
  1321             TInt newTime = KGSMultiTapTimerDefault;
       
  1322             const TInt rate = 40;       // rate is 40%.
       
  1323             switch ( currentIndex )
       
  1324                 {
       
  1325                 case EGSKeypressTimeoutItemNone:
       
  1326                     newTime = 0;
       
  1327                     break;
       
  1328                 case EGSKeypressTimeoutItemShort:
       
  1329                     newTime = 
       
  1330                     KGSMultiTapTimerDefault - KGSMultiTapTimerDefault * rate / 100;
       
  1331                     break;
       
  1332                 case EGSKeypressTimeoutItemLong:
       
  1333                     newTime = 
       
  1334                     KGSMultiTapTimerDefault + KGSMultiTapTimerDefault * rate / 100;
       
  1335                     break;
       
  1336                 case EGSKeypressTimeoutItemMedium:
       
  1337                 default:
       
  1338                     newTime = KGSMultiTapTimerDefault;
       
  1339                     break;
       
  1340                 }
       
  1341             Container()->Model()->SetKeypressTimeout( newTime );
       
  1342             // value should really be being updated, so update listbox        
       
  1343             Container()->UpdateListBoxL( EGSLangIdKT );
       
  1344             }
       
  1345         }   
       
  1346     // Delete items:
       
  1347     CleanupStack::PopAndDestroy( items );
       
  1348     }
       
  1349 
       
  1350 
       
  1351 // -----------------------------------------------------------------------------
       
  1352 // CGSLangPlugin::ChangeJapQwertySettingL
       
  1353 // Change Japanese Qwerty settings
       
  1354 // -----------------------------------------------------------------------------
       
  1355 //
       
  1356 void CGSLangPlugin::ChangeJapQwertySettingL( const TGSJapQwertyFlags aFlag,
       
  1357                                      const TInt aItemId,
       
  1358                                      const TBool aShowSettingPage )
       
  1359     {
       
  1360     TBool currentValue = Container()->Model()->JapanQwertyFlags( aFlag );
       
  1361     TBool updateValue = ETrue;
       
  1362     
       
  1363     TInt settingPageResourceId = 0;
       
  1364     TInt itemArraryResourceId = 0;    
       
  1365     switch ( aItemId )
       
  1366         {
       
  1367         case EGSLangIdJQC:
       
  1368             settingPageResourceId = R_JAP_QWERTY_COMMA_SETTING_PAGE;
       
  1369             itemArraryResourceId = R_JAP_QWERTY_COMMA_SETTING_PAGE_LBX;
       
  1370             break;
       
  1371         case EGSLangIdJQP:
       
  1372             settingPageResourceId = R_JAP_QWERTY_PERIOD_SETTING_PAGE;
       
  1373             itemArraryResourceId = R_JAP_QWERTY_PERIOD_SETTING_PAGE_LBX;
       
  1374             break;
       
  1375         case EGSLangIdJQWSP:
       
  1376             settingPageResourceId = R_JAP_QWERTY_WIDTH_SPACE_SETTING_PAGE;
       
  1377             itemArraryResourceId = R_JAP_QWERTY_WIDTH_FULL_HALF_SETTING_PAGE_LBX;
       
  1378             break;
       
  1379         default:
       
  1380             break;
       
  1381         }
       
  1382 
       
  1383     // Following code potentially changes the value of currrent value 
       
  1384     if ( aShowSettingPage )
       
  1385         {
       
  1386         updateValue = ShowJapQwertySettingPageL( settingPageResourceId,
       
  1387                                                  itemArraryResourceId,
       
  1388                                                  currentValue );
       
  1389         }
       
  1390     else
       
  1391         {
       
  1392         updateValue = !( currentValue );
       
  1393         }
       
  1394 
       
  1395     if ( currentValue != updateValue )
       
  1396         {
       
  1397         Container()->Model()->SetJapanQwertyFlags( aFlag, updateValue );
       
  1398         // value should really be being updated, so update listbox
       
  1399         Container()->UpdateListBoxL( aItemId );
       
  1400         }
       
  1401     }
       
  1402 
       
  1403 // -----------------------------------------------------------------------------
       
  1404 // CGSLangPlugin::ShowJapQwertySettingPageL
       
  1405 // Display Japanese Qwerty ON/OFF setting page.
       
  1406 // -----------------------------------------------------------------------------
       
  1407 //
       
  1408 TBool CGSLangPlugin::ShowJapQwertySettingPageL( 
       
  1409                                         const TInt aSettingPageResourceId,
       
  1410                                         const TInt aItemArraryResourceId,
       
  1411                                         const TBool aCurrentValue )
       
  1412     {
       
  1413     // Default is to act as if the user cancelled the setting page
       
  1414     TBool ret = EFalse;
       
  1415 
       
  1416     CDesCArrayFlat* items = iCoeEnv->ReadDesC16ArrayResourceL(
       
  1417                                         aItemArraryResourceId );
       
  1418     CleanupStack::PushL( items );
       
  1419     // If current value is ETrue, display index is 0.
       
  1420     TInt dispIndex = ( aCurrentValue )? 0 : 1;
       
  1421 
       
  1422     CAknRadioButtonSettingPage* dlg = new ( ELeave ) CAknRadioButtonSettingPage
       
  1423                                      ( aSettingPageResourceId, 
       
  1424                                        dispIndex, items );
       
  1425     ret = dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
       
  1426     if ( ret )
       
  1427         {
       
  1428         ret = ( dispIndex )? EFalse : ETrue;
       
  1429         }
       
  1430     else
       
  1431         {
       
  1432         ret = aCurrentValue;
       
  1433         }
       
  1434     CleanupStack::PopAndDestroy( items );
       
  1435     return ret;
       
  1436     }
       
  1437 
       
  1438 
       
  1439 // -----------------------------------------------------------------------------
       
  1440 // CGSLangPlugin::ShowChiCangJieInputModeSettingPageL
       
  1441 //
       
  1442 // Display Chinese CangJie Input mode setting page.
       
  1443 // -----------------------------------------------------------------------------
       
  1444 //
       
  1445 void CGSLangPlugin::ShowChiCangJieInputModeSettingPageL()
       
  1446     {
       
  1447     // Default is to act as if the user cancelled the setting page
       
  1448     TBool ret = EFalse;
       
  1449 
       
  1450     TInt selection = Container()->Model()->ChiCangJieInputL();
       
  1451     CDesCArrayFlat* items = iCoeEnv->ReadDesC16ArrayResourceL(
       
  1452                                         R_CHI_CANGJIE_SETTING_PAGE_LBX );
       
  1453     CleanupStack::PushL( items );
       
  1454     
       
  1455     CAknRadioButtonSettingPage* dlg = new ( ELeave ) CAknRadioButtonSettingPage
       
  1456                ( R_CHI_CANGJIE_INPUT_MODE_SETTING_PAGE, selection, items );
       
  1457     ret = dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
       
  1458     CleanupStack::PopAndDestroy( items );
       
  1459     
       
  1460     if ( ret )
       
  1461         {
       
  1462         //User has changed the value. Update the CenRep key and the UI
       
  1463         Container()->Model()->SetChiCangJieInputL( selection );
       
  1464         Container()->UpdateListBoxL( EGSLangIdCangJie );
       
  1465         }
       
  1466     }
       
  1467 
       
  1468 // -----------------------------------------------------------------------------
       
  1469 // CGSLangPlugin::ShowPredictiveModeSettingPageL
       
  1470 // Word Autocompletion Requirement
       
  1471 // Display Predictive mode setting page.
       
  1472 // -----------------------------------------------------------------------------
       
  1473 //
       
  1474 void CGSLangPlugin::ShowPredictiveModeSettingPageL( const TBool aShowSettingPage )
       
  1475     {
       
  1476     TBool updateValue = ETrue;
       
  1477     TInt selection = Container()->Model()->PredictiveModeL();
       
  1478     if ( aShowSettingPage )
       
  1479     	{
       
  1480     	// Default is to act as if the user cancelled the setting page
       
  1481      	CDesCArrayFlat* items = iCoeEnv->ReadDesC16ArrayResourceL(
       
  1482                                         R_PREDICTIVE_MODE_SETTING_PAGE_LBX );
       
  1483     	CleanupStack::PushL( items );
       
  1484     	CAknRadioButtonSettingPage* dlg = new ( ELeave ) CAknRadioButtonSettingPage
       
  1485         	       ( R_PREDICTIVE_MODE_SETTING_PAGE, selection, items );
       
  1486     	updateValue = dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
       
  1487     	CleanupStack::PopAndDestroy( items );
       
  1488     	}
       
  1489     else // just switch the value
       
  1490     	{
       
  1491     	// 0 --> Normal 
       
  1492 		// 1 --> Autocompletion
       
  1493     	if ( selection == EGSPredictiveModeNormal )
       
  1494     		{
       
  1495     		selection = EGSPredictiveModeAutocompletion;
       
  1496     		}
       
  1497     	else if ( selection == EGSPredictiveModeAutocompletion )
       
  1498     	    {
       
  1499     	    selection = EGSPredictiveModeNormal;
       
  1500     	    }
       
  1501     	}
       
  1502 
       
  1503     if ( updateValue )
       
  1504         {
       
  1505         //User has changed the value. Update the CenRep key and the UI
       
  1506         // Treat on and off separately for clarity
       
  1507         if ( selection )
       
  1508             {
       
  1509             // See if it can do predictive text entry
       
  1510             TInt langCode = Container()->Model()->LanguageL
       
  1511             							( CGSLangModel::EGSInputLanguage );
       
  1512             if( Container()->Model()->CheckDictionaryFromPtiL( langCode ) )
       
  1513                 {
       
  1514                 Container()->Model()->SetPredictiveModeL( selection );
       
  1515                 }
       
  1516             else
       
  1517                 {
       
  1518                 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( );
       
  1519                 dlg->ExecuteDlgLD(
       
  1520                     CAknNoteDialog::EShortTimeout,
       
  1521                     CAknNoteDialog::ENoTone,
       
  1522                     R_AVKON_T9_NOTE_NO_AVAILABLE );
       
  1523                 }
       
  1524             }
       
  1525         else
       
  1526             {
       
  1527             // We are always able to turn T9 off:
       
  1528             Container()->Model()->SetPredictiveModeL( selection );
       
  1529             }
       
  1530         Container()->UpdateListBoxL( EGSLangIdPredictiveMode );
       
  1531         }
       
  1532     }
       
  1533 
       
  1534 #ifdef RD_INTELLIGENT_TEXT_INPUT
       
  1535 #ifdef FF_DUAL_LANGUAGE_SUPPORT
       
  1536 // ----------------------------------------------------------------------------
       
  1537 // CGSLangPlugin::ShowDualInputLanguageSettingListL()
       
  1538 // 
       
  1539 // Display the dynamic menu
       
  1540 // ----------------------------------------------------------------------------
       
  1541 void CGSLangPlugin::ShowDualInputLanguageSettingListL()
       
  1542     {
       
  1543     CAknAppUi* appUi = static_cast<CAknAppUi*>(iCoeEnv->AppUi());
       
  1544 
       
  1545     CAknTitlePane* titlePane = static_cast<CAknTitlePane*>( appUi->StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
  1546 
       
  1547     const TDesC* appTitle = titlePane->Text();
       
  1548     HBufC* oldTitle = appTitle->AllocL();
       
  1549     CleanupStack::PushL(oldTitle);
       
  1550     HBufC* title = StringLoader::LoadLC( R_INPUT_LANGUAGE_SETTINGS_TITLE, iCoeEnv);
       
  1551     titlePane->SetTextL( *title );
       
  1552     CleanupStack::PopAndDestroy(title);
       
  1553 
       
  1554     CGSDualLanguageDialog* dlg = CGSDualLanguageDialog::NewL(R_GS_MENUBAR_CHANGE_EXIT, Container()->Model());
       
  1555     dlg->ExecuteLD(R_INPUTLANGUAGE_DIALOG);
       
  1556 
       
  1557     titlePane->SetTextL( *oldTitle );
       
  1558     CleanupStack::PopAndDestroy(oldTitle);
       
  1559     }
       
  1560 
       
  1561 #endif //FF_DUAL_LANGUAGE_SUPPORT
       
  1562 
       
  1563 void DestroySelectionItemList(TAny* aPtr)
       
  1564     {
       
  1565     CSelectionItemList* list = static_cast<CSelectionItemList*>(aPtr);
       
  1566     list->ResetAndDestroy();
       
  1567     delete list;
       
  1568     }
       
  1569 
       
  1570 // ----------------------------------------------------------------------------
       
  1571 // CGSLangPlugin::ShowITIMultiSettingPageL(TBool aShowOnOffSettingPage)
       
  1572 // 
       
  1573 // Display the dynamic menu
       
  1574 // ----------------------------------------------------------------------------
       
  1575 void CGSLangPlugin::ShowITIMultiSettingPageL(TBool aShowOnOffSettingPage)
       
  1576     {
       
  1577     if( Container()->Model()->DeviceHasMultipleKeyboardsL() )
       
  1578         {
       
  1579         CSelectionItemList* selection = new (ELeave) CSelectionItemList(2);
       
  1580         CleanupStack::PushL(TCleanupItem(DestroySelectionItemList, selection));
       
  1581         TInt physicalKeyboards = Container()->Model()->PhysicalKeyboardsL();
       
  1582         TInt predictionBitmask = Container()->Model()->PredictionBitMaskL();
       
  1583         TBool settingActive = EFalse;
       
  1584         HBufC* selectionText = 0;
       
  1585         TInt count = 0;
       
  1586         TInt itutIndex = 0;
       
  1587         TInt halfQwertyIndex = 0;
       
  1588         TInt qwertyIndex = 0;
       
  1589         for(TUint i = 0x01; i <= 0xF0; i = i << 1)
       
  1590             {
       
  1591             if(physicalKeyboards & i)
       
  1592                 {
       
  1593                 switch(i)
       
  1594                     {
       
  1595                     case 0x01: // itut
       
  1596                         settingActive = ( predictionBitmask & EKeyboardStyle12Key ? 1 : 0 ); 
       
  1597                         selectionText = iCoeEnv->AllocReadResourceLC(R_AKNFEP_PRED_SETTING_ITUT);
       
  1598                         itutIndex = count;
       
  1599                         break;
       
  1600                     case 0x10: // half
       
  1601                         settingActive = ( predictionBitmask & EKeyboardStyleHalfQwerty ? 1 : 0 ); 
       
  1602                         selectionText = iCoeEnv->AllocReadResourceLC(R_AKNFEP_PRED_SETTING_HALF_QWERTY);
       
  1603                         halfQwertyIndex = count;
       
  1604                         break;                        
       
  1605                     case 0x02: // 4x12
       
  1606                     case 0x04: // 4x10
       
  1607                     case 0x08: // 3x11                    
       
  1608                     case 0x20: // custom
       
  1609                         settingActive = ( predictionBitmask & EKeyboardStyleQwerty ? 1: 0);
       
  1610                         selectionText = iCoeEnv->AllocReadResourceLC(R_AKNFEP_PRED_SETTING_QWERTY);
       
  1611                         qwertyIndex = count;
       
  1612                         i = 0x20; // Skip rest of qwerty checks
       
  1613                         break;
       
  1614                     default:
       
  1615                         break;
       
  1616                     }
       
  1617                 count++;
       
  1618                 CSelectableItem* item = new (ELeave) CSelectableItem( *selectionText, settingActive );
       
  1619                 item->ConstructL();
       
  1620                 selection->AppendL(item);
       
  1621                 CleanupStack::PopAndDestroy(); //selectionText 
       
  1622                 }
       
  1623             }
       
  1624         
       
  1625         CAknCheckBoxSettingPage* settingPage = 
       
  1626             new( ELeave) CAknCheckBoxSettingPage( R_PREDICTIVE_TEXT_MULTI_SETTING_PAGE, selection);
       
  1627 
       
  1628         if( settingPage->ExecuteLD(CAknSettingPage::EUpdateWhenAccepted))
       
  1629             {
       
  1630             for(TUint i = 0x01; i <= 0xF0; i = i << 1)
       
  1631                 {
       
  1632                 if(physicalKeyboards & i)
       
  1633                     {
       
  1634                     switch(i)
       
  1635                         {
       
  1636                         case 0x01: // itut
       
  1637                             if( (selection->At(itutIndex))->SelectionStatus() )
       
  1638                                 {
       
  1639                                 predictionBitmask = predictionBitmask | EKeyboardStyle12Key ;
       
  1640                                 }
       
  1641                             else
       
  1642                                 {
       
  1643                                 predictionBitmask = predictionBitmask & ~EKeyboardStyle12Key ;
       
  1644                                 }                                                 
       
  1645                             break;
       
  1646                         case 0x10: // half
       
  1647                             if( (selection->At(halfQwertyIndex))->SelectionStatus() )
       
  1648                                 {
       
  1649                                 predictionBitmask = predictionBitmask | EKeyboardStyleHalfQwerty ;
       
  1650                                 }
       
  1651                             else
       
  1652                                 {
       
  1653                                 predictionBitmask = predictionBitmask & ~EKeyboardStyleHalfQwerty ;
       
  1654                                 }                                                 
       
  1655                             break;
       
  1656                         case 0x02: // 4x12
       
  1657                         case 0x04: // 4x10
       
  1658                         case 0x08: // 3x11                    
       
  1659                         case 0x20: // custom
       
  1660                             if( (selection->At(qwertyIndex))->SelectionStatus() )
       
  1661                                 {
       
  1662                                 predictionBitmask = predictionBitmask | EKeyboardStyleQwerty ;
       
  1663                                 }
       
  1664                             else
       
  1665                                 {
       
  1666                                 predictionBitmask = predictionBitmask & ~EKeyboardStyleQwerty ;
       
  1667                                 }                                                 
       
  1668                             i = 0x20; // Skip rest of qwerty checks
       
  1669                             break;
       
  1670                         default:
       
  1671                             break;
       
  1672                         }
       
  1673                     }
       
  1674                 }
       
  1675             Container()->Model()->SetPredictionBitMaskL(predictionBitmask);
       
  1676             }
       
  1677         CleanupStack::PopAndDestroy(); // selection
       
  1678         }
       
  1679     else
       
  1680         {
       
  1681         Container()->Model()->ChangePredictiveOnOffSettingL(
       
  1682                 aShowOnOffSettingPage,
       
  1683                 CGSLangModel::EGSLangOther );
       
  1684         }
       
  1685     }
       
  1686 
       
  1687 // ----------------------------------------------------------------------------
       
  1688 // CGSLangPlugin::ShowPredictiveSettingListL()
       
  1689 // 
       
  1690 // Display the dynamic menu
       
  1691 // ----------------------------------------------------------------------------
       
  1692 void CGSLangPlugin::ShowPredictiveSettingListL()
       
  1693     {
       
  1694     if (iCascadeOptionsOpen)
       
  1695         {
       
  1696         // Return if already open
       
  1697         return;
       
  1698         }
       
  1699     
       
  1700     CAknAppUi* appUi = static_cast<CAknAppUi*>(iCoeEnv->AppUi());
       
  1701 
       
  1702     CAknTitlePane* titlePane = static_cast<CAknTitlePane*>( appUi->StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
  1703 
       
  1704     const TDesC* appTitle = titlePane->Text();
       
  1705     HBufC* oldTitle = appTitle->AllocL();
       
  1706     CleanupStack::PushL(oldTitle);
       
  1707     HBufC* title = StringLoader::LoadLC( R_AKNFEP_PRED_INPUT_SETTINGS_TITLE, iCoeEnv);
       
  1708     titlePane->SetTextL( *title );
       
  1709     CleanupStack::PopAndDestroy(title);
       
  1710 
       
  1711     CGSPredictiveSettingDialog* dlg = CGSPredictiveSettingDialog::NewL(R_PREDICTIVESETTINGDIALOG_MENUBAR, R_PREDICTIVETEXTOFF_CONFIRMATION_QUERY);
       
  1712     iDialog = dlg;
       
  1713     iCascadeOptionsOpen = ETrue;
       
  1714     dlg->ExecuteLD(R_PREDICTIVESETTING_DIALOG);
       
  1715     iCascadeOptionsOpen = EFalse;
       
  1716     iDialog = NULL;
       
  1717     titlePane->SetTextL( *oldTitle );
       
  1718     CleanupStack::PopAndDestroy(oldTitle);
       
  1719     }
       
  1720 #endif
       
  1721 
       
  1722 // ----------------------------------------------------------------------------
       
  1723 // CGSLangPlugin::DynInitMenuPaneL()
       
  1724 // 
       
  1725 // Display the dynamic menu
       
  1726 // ----------------------------------------------------------------------------
       
  1727 void CGSLangPlugin::DynInitMenuPaneL( TInt aResourceId,
       
  1728                                       CEikMenuPane* aMenuPane )
       
  1729     {
       
  1730     // show or hide the 'help' menu item when supported
       
  1731     if( aResourceId == R_GS_MENU_ITEM_HELP )
       
  1732         {
       
  1733         User::LeaveIfNull( aMenuPane );
       
  1734             
       
  1735         if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
  1736             {
       
  1737             aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse );
       
  1738             }
       
  1739         else
       
  1740             {
       
  1741             aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
       
  1742             }
       
  1743         }
       
  1744 #ifdef RD_INTELLIGENT_TEXT_INPUT    
       
  1745     // show or hide the change menu option when supported
       
  1746     if(aResourceId == R_GS_MENU_ITEM_CHANGE)
       
  1747         {
       
  1748         User::LeaveIfNull( aMenuPane );
       
  1749         TInt keyboardLayout = 0;
       
  1750         RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
       
  1751         TPtiKeyboardType layout = (TPtiKeyboardType)keyboardLayout;
       
  1752         TBool isPredictionSupport = EFalse;
       
  1753         switch(layout)
       
  1754             {
       
  1755             case EPtiKeyboardHalfQwerty:
       
  1756                 isPredictionSupport = Container()->Model()->CheckT9FromPtiLForPredictionL((TPtiEngineInputMode)EPtiEngineHalfQwertyPredictive);
       
  1757                 break;
       
  1758             case EPtiKeyboardQwerty4x12:
       
  1759             case EPtiKeyboardQwerty4x10:  
       
  1760             case EPtiKeyboardQwerty3x11:
       
  1761             case EPtiKeyboardCustomQwerty:
       
  1762                 isPredictionSupport = Container()->Model()->CheckT9FromPtiLForPredictionL((TPtiEngineInputMode)EPtiEngineQwertyPredictive);
       
  1763                 break;
       
  1764             case EPtiKeyboardNone:
       
  1765             case EPtiKeyboard12Key:
       
  1766                 isPredictionSupport = Container()->Model()->CheckT9FromPtiLForPredictionL((TPtiEngineInputMode)EPtiEnginePredictive);
       
  1767                 break;
       
  1768             default:
       
  1769                 isPredictionSupport = Container()->Model()->CheckT9FromPtiLForPredictionL((TPtiEngineInputMode)EPtiEnginePredictive);
       
  1770                 break;    
       
  1771             }
       
  1772         if (isPredictionSupport == EFalse)
       
  1773             {
       
  1774             aMenuPane->SetItemDimmed(EGSCmdAppChange, ETrue );
       
  1775             }
       
  1776         }
       
  1777 #endif    
       
  1778         
       
  1779     }
       
  1780 // -----------------------------------------------------------------------------
       
  1781 // CGSLangPlugin::CreateIconL()
       
  1782 //
       
  1783 //
       
  1784 // -----------------------------------------------------------------------------
       
  1785 //
       
  1786 CGulIcon* CGSLangPlugin::CreateIconL( const TUid aIconType )
       
  1787     {
       
  1788     //EMbm<Mbm_file_name><Bitmap_name>
       
  1789     CGulIcon* icon;
       
  1790 
       
  1791     if( aIconType == KGSIconTypeLbxItem )
       
  1792         {
       
  1793         icon = AknsUtils::CreateGulIconL(
       
  1794         AknsUtils::SkinInstance(),
       
  1795         KAknsIIDQgnPropCpPersoLang,
       
  1796         KGSDefaultLangIconFileName,
       
  1797         EMbmGslangpluginQgn_prop_cp_perso_lang,
       
  1798         EMbmGslangpluginQgn_prop_cp_perso_lang_mask );
       
  1799         }
       
  1800        else
       
  1801         {
       
  1802         icon = CGSPluginInterface::CreateIconL( aIconType );
       
  1803         }
       
  1804 
       
  1805     return icon;
       
  1806     }
       
  1807 
       
  1808 #ifdef RD_INTELLIGENT_TEXT_INPUT 
       
  1809 #ifdef __ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
  1810 TInt CGSLangPlugin::HandleKeyboardLayoutChangeNotification(TAny* aObj)
       
  1811     {
       
  1812     if (aObj)
       
  1813         {
       
  1814         static_cast<CGSLangPlugin*>(aObj)->HandleKeyboardLayoutChange();
       
  1815         return KErrNone;
       
  1816         }
       
  1817     else
       
  1818         {
       
  1819         return KErrArgument;
       
  1820         }
       
  1821     }
       
  1822 
       
  1823 void CGSLangPlugin::HandleKeyboardLayoutChange()
       
  1824     {
       
  1825     if(iDialog)
       
  1826         {
       
  1827         iDialog->HandleResourceChange(KEikDynamicLayoutVariantSwitch);
       
  1828         }
       
  1829     if(iContainer)
       
  1830 		{
       
  1831         Container()->HandleResourceChange(KEikDynamicLayoutVariantSwitch);
       
  1832 		}
       
  1833     }
       
  1834 
       
  1835 CGSLangPlugin::CSubscriber::CSubscriber(TCallBack aCallBack, RProperty& aProperty)
       
  1836     :
       
  1837     CActive(EPriorityNormal), iCallBack(aCallBack), iProperty(aProperty)
       
  1838     {
       
  1839     CActiveScheduler::Add(this);
       
  1840     }
       
  1841 
       
  1842 CGSLangPlugin::CSubscriber::~CSubscriber()
       
  1843     {
       
  1844     Cancel();
       
  1845     }
       
  1846 
       
  1847 void CGSLangPlugin::CSubscriber::SubscribeL()
       
  1848     {
       
  1849     if (!IsActive())
       
  1850         {
       
  1851         iProperty.Subscribe(iStatus);
       
  1852         SetActive();
       
  1853         }
       
  1854     }
       
  1855 
       
  1856 void CGSLangPlugin::CSubscriber::StopSubscribe()
       
  1857     {
       
  1858     Cancel();
       
  1859     }
       
  1860 
       
  1861 void CGSLangPlugin::CSubscriber::RunL()
       
  1862     {
       
  1863     if (iStatus.Int() == KErrNone)
       
  1864         {
       
  1865         iCallBack.CallBack();
       
  1866         SubscribeL();
       
  1867         }
       
  1868     }
       
  1869 
       
  1870 void CGSLangPlugin::CSubscriber::DoCancel()
       
  1871     {
       
  1872     iProperty.Cancel();
       
  1873     }
       
  1874     
       
  1875 #endif //__ITI_VIRTUAL_TOUCH_FIRST_GENERATION_SUPPORT__
       
  1876 #endif
       
  1877 // End of File