textinput/peninputgenericitut/src/peninputgenericitutdatamgr.cpp
branchRCL_3
changeset 19 ac7e4d1d9209
parent 18 b1ea1642412e
equal deleted inserted replaced
18:b1ea1642412e 19:ac7e4d1d9209
    32 #include <aknlayoutscalable_avkon.cdl.h>
    32 #include <aknlayoutscalable_avkon.cdl.h>
    33 #include <peninputlayoutmultilineicf.h>
    33 #include <peninputlayoutmultilineicf.h>
    34 #include <AknSettingCache.h>
    34 #include <AknSettingCache.h>
    35 #include <AknFepInternalCRKeys.h>
    35 #include <AknFepInternalCRKeys.h>
    36 #include <centralrepository.h>
    36 #include <centralrepository.h>
       
    37 #include <featmgr.h> 
    37 
    38 
    38 #include "peninputgenericitutdatamgr.h"
    39 #include "peninputgenericitutdatamgr.h"
    39 #include "peninputgenericitutlayoutcontext.h"
    40 #include "peninputgenericitutlayoutcontext.h"
    40 #include "peninputgenericitutconverter.h"
    41 #include "peninputgenericitutconverter.h"
    41 #include "peninputgenericitutcustomization.h"
    42 #include "peninputgenericitutcustomization.h"
    98     iMenuItemList.ResetAndDestroy();
    99     iMenuItemList.ResetAndDestroy();
    99     
   100     
   100     CCoeEnv::Static()->DeleteResourceFile(iAvkonResId);
   101     CCoeEnv::Static()->DeleteResourceFile(iAvkonResId);
   101         
   102         
   102     CCoeEnv::Static()->DeleteResourceFile(iCommonResId);
   103     CCoeEnv::Static()->DeleteResourceFile(iCommonResId);
   103 
   104     
   104     // Remove all resource files from control environment
   105     // Remove the resource file of current input language
   105     for (TInt i=0; i< iConfigResIds.Count(); i++)
   106     if ( iConfigResId )
   106         {
   107         {
   107         CCoeEnv::Static()->DeleteResourceFile(iConfigResIds[i]);
   108         CCoeEnv::Static()->DeleteResourceFile( iConfigResId );
   108         }
   109         }
   109     iConfigResIds.Close();
   110     
       
   111     // Remove the resource file of some special controls
       
   112     if ( iSpecialResId )
       
   113         {
       
   114         CCoeEnv::Static()->DeleteResourceFile( iSpecialResId );
       
   115         }
   110 
   116 
   111     ClearChnCandidates(EItutCandidates);
   117     ClearChnCandidates(EItutCandidates);
   112     ClearChnCandidates(EItutPuncCandidates);
   118     ClearChnCandidates(EItutPuncCandidates);
   113 
   119 
   114     iKeypadCellRects.Close();
   120     iKeypadCellRects.Close();
   118     delete iNumericKeymapData;
   124     delete iNumericKeymapData;
   119     }
   125     }
   120 
   126 
   121 void CGenericItutDataMgr::ConstructL()
   127 void CGenericItutDataMgr::ConstructL()
   122     {
   128     {
   123 
       
   124     // initialize layout info of controls and layout
   129     // initialize layout info of controls and layout
   125     ReadLafInfo();
   130     ReadLafInfo();
   126 
   131 
   127     TFileName resourceCommonName(KItutCommonResFile);
   132     TFileName resourceCommonName(KItutCommonResFile);
   128     CCoeEnv* coeEnv = CCoeEnv::Static();
   133     CCoeEnv* coeEnv = CCoeEnv::Static();
   151         reader.ReadInt16();
   156         reader.ReadInt16();
   152         CleanupStack::Pop(); // pop first, since additem pushes again
   157         CleanupStack::Pop(); // pop first, since additem pushes again
   153         iMenuItemList.Append( item );
   158         iMenuItemList.Append( item );
   154         reader.ReadInt32(); // extension link
   159         reader.ReadInt32(); // extension link
   155         }        
   160         }        
   156     CleanupStack::PopAndDestroy(); //reader         
   161     CleanupStack::PopAndDestroy(); //reader
       
   162 
       
   163     // There are some special controls in Chinese and Korean VITUT,
       
   164     // and these controls are hidden when changing to other input language, 
       
   165     // so related resource file should be in control environment at all times.
       
   166     // Otherwise crash happens when reading resource for them sometime. 
       
   167     // For example: If writing language is Chinese, enters spell mode,
       
   168     // then switches theme, crash happens. 
       
   169     if ( FeatureManager::FeatureSupported( KFeatureIdChinese ) ||
       
   170             FeatureManager::FeatureSupported( KFeatureIdKorean ) )
       
   171         {
       
   172         TFileName  resourceFilename( KConfigResourceFile ) ;
       
   173         if ( FeatureManager::FeatureSupported( KFeatureIdChinese ) )
       
   174             {
       
   175             // Chinese variant
       
   176             resourceFilename.Append( ResFileExtByScriptIdx( EChnExt ) );
       
   177             }
       
   178         else
       
   179             {
       
   180             // Korean variant
       
   181             resourceFilename.Append( ResFileExtByScriptIdx( EHangulExt ) );
       
   182             }
       
   183         resourceFilename.Append(KResourceFileExtName);
       
   184         
       
   185         BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFilename );
       
   186         iSpecialResId = coeEnv->AddResourceFileL( resourceFilename );        
       
   187         }
   157     }
   188     }
   158 
   189 
   159 CGenericItutDataMgr::TMenuItem* CGenericItutDataMgr::GetMenuItem(TInt aCommand)
   190 CGenericItutDataMgr::TMenuItem* CGenericItutDataMgr::GetMenuItem(TInt aCommand)
   160     {
   191     {
   161     for (TInt i=0;i<iMenuItemList.Count();i++)
   192     for (TInt i=0;i<iMenuItemList.Count();i++)
  1165             {
  1196             {
  1166             iCurrentScriptIdx = scriptIdx;
  1197             iCurrentScriptIdx = scriptIdx;
  1167 
  1198 
  1168             CCoeEnv* coeEnv = CCoeEnv::Static();
  1199             CCoeEnv* coeEnv = CCoeEnv::Static();
  1169             
  1200             
  1170             TFileName resourceConfigName(iResourceFilename);
  1201             // Remove the resource file of previous input language.
  1171             BaflUtils::NearestLanguageFile(coeEnv->FsSession(), resourceConfigName);
  1202             // The previous resource file should be removed first,
  1172             // Do not delete resource file from control environment if changing language.
  1203             // Because there are some same keypad ids in the resource file
  1173             // Otherwise crash happens if switching theme. For example:If writing language
  1204             // of latin, Cyrillic, and etc.
  1174             // is Chinese, enters spell mode, then switches theme, crash happens. 
  1205             if ( iConfigResId )
  1175             TInt configResId = coeEnv->AddResourceFileL(resourceConfigName);
  1206                 {
  1176             if ( iConfigResIds.Find(configResId) ==  KErrNotFound)
  1207                 coeEnv->DeleteResourceFile( iConfigResId );
  1177                 {
  1208                 }
  1178                 iConfigResIds.Append( configResId );
  1209 
  1179                 }
  1210             // Add the resource file of current input language
  1180             else
  1211             TFileName resourceConfigName( iResourceFilename );
  1181                 {
  1212             BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceConfigName );
  1182                 // Remove resource file to ensure the resource file is added only one time.
  1213             iConfigResId = coeEnv->AddResourceFileL( resourceConfigName );
  1183                 coeEnv->DeleteResourceFile( configResId );
       
  1184                 }
       
  1185             
  1214             
  1186             if (IsChinese())
  1215             if (IsChinese())
  1187                 {
  1216                 {
  1188                 iLayoutContext->UiManager()->CreateChineseSpecificCtrlsIfNeededL();
  1217                 iLayoutContext->UiManager()->CreateChineseSpecificCtrlsIfNeededL();
  1189                 }
  1218                 }