sysstatemgmt/ssmutilityplugins/ssmlocaleobserversup/src/ssmlocaleobserversup.cpp
branchRCL_3
changeset 21 ccb4f6b3db21
parent 0 4e1aa6a622a0
child 22 8cb079868133
equal deleted inserted replaced
20:1ddbe54d0645 21:ccb4f6b3db21
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 
    17 
    18 #include <bacntf.h>
    18 #include <bacntf.h>
    19 #include <bautils.h>
    19 #include <bautils.h>
    20 #include <connect/sbdefs.h>
    20 #include <connect/sbdefs.h>
    21 #include <s32file.h>
    21 #include <s32file.h>
       
    22 #include <e32reg.h>
    22 
    23 
    23 #include "ssmmapperutilitystatic.h"
    24 #include "ssmmapperutilitystatic.h"
    24 #include "ssmlocaleobserversup.h"
    25 #include "ssmlocaleobserversup.h"
    25 #include "trace.h"
    26 #include "trace.h"
    26 
    27 
    28 * Directory to store user-specific locale data files.
    29 * Directory to store user-specific locale data files.
    29 * Private directory of SSM Utility Server.
    30 * Private directory of SSM Utility Server.
    30 */
    31 */
    31 _LIT( KLocaleDataDir, "\\private\\2000d766\\localedata\\" );
    32 _LIT( KLocaleDataDir, "\\private\\2000d766\\localedata\\" );
    32 
    33 
    33 /** Name is LocaleData.Dnn or CommonData.D00 */
    34 /** Name is RegionData.Dnn */
    34 _LIT( KFileName, "LocaleData.D" );
    35 _LIT( KFileName, "RegionData.D" );
    35 _LIT( KCommonFileName, "CommonData.D" );
       
    36 
    36 
    37 /**
    37 /**
    38 * Version number from 1..255 to indicate data
    38 * Version number from 1..255 to indicate data
    39 * format of the file. To make dynamic data format fixes possible we need
    39 * format of the file. To make dynamic data format fixes possible we need
    40 * version ID.
    40 * version ID.
    41 */
    41 */
    42 const TInt KCurrentVersionNumber = 2; // For fixing TChar r/w
    42 const TInt KCurrentVersionNumber = 2; // For fixing TChar r/w
    43 
    43 
       
    44 /** The maximum number of regions to be appended to the hash set. */
       
    45 const TInt KMaxNumberOfRegions = 56;
       
    46 
    44 // ======== LOCAL FUNCTIONS ========
    47 // ======== LOCAL FUNCTIONS ========
    45 
    48 
    46 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    47 // EnvChangeNotifierCallbackL
    50 // EnvChangeNotifierCallbackL
    48 // ---------------------------------------------------------------------------
    51 // ---------------------------------------------------------------------------
    62 // ---------------------------------------------------------------------------
    65 // ---------------------------------------------------------------------------
    63 //
    66 //
    64 static HBufC* MakeFileNameL( const TDesC& aPath, const TDesC& aName, const TInt aCode )
    67 static HBufC* MakeFileNameL( const TDesC& aPath, const TDesC& aName, const TInt aCode )
    65     {
    68     {
    66     FUNC_LOG;
    69     FUNC_LOG;
    67     INFO_3( "Locale data dir: %S, file name base: %S, lang code: %d", &aPath, &aName, aCode );
    70     INFO_3( "Region data dir: %S, file name base: %S, region code: %d", &aPath, &aName, aCode );
    68 
    71 
    69     TInt length = aPath.Length();
    72     TInt length = aPath.Length();
    70 
    73 
    71     // Reserve spave for language code also
    74     // Reserve spave for language code also
    72     HBufC* buffer = HBufC::NewL( length + aName.Length() + 10 );
    75     HBufC* buffer = HBufC::NewL( length + aName.Length() + 10 );
    82         {
    85         {
    83         ptr.AppendNum( 0 ); // add leading zero to the extention
    86         ptr.AppendNum( 0 ); // add leading zero to the extention
    84         }
    87         }
    85     ptr.AppendNum( aCode );
    88     ptr.AppendNum( aCode );
    86 
    89 
    87     INFO_1( "Locale data file: %S", buffer );
    90     INFO_1( "Region data file: %S", buffer );
    88 
    91 
    89     return buffer;
    92     return buffer;
    90     }
    93     }
    91 
    94 
       
    95 inline TUint32 HashLangRegionMappingFunction(const TLanguageRegion& aMapping)
       
    96     {
       
    97     return aMapping.iLanguage;
       
    98     }
       
    99 
       
   100 inline TBool HashLangRegionMappingIdentityRelation(const TLanguageRegion& aMapping1,
       
   101     const TLanguageRegion& aMapping2)
       
   102     {
       
   103     return (aMapping1.iLanguage == aMapping2.iLanguage);
       
   104     }
    92 
   105 
    93 // ======== MEMBER FUNCTIONS ========
   106 // ======== MEMBER FUNCTIONS ========
    94 
   107 
    95 // ---------------------------------------------------------------------------
   108 // ---------------------------------------------------------------------------
    96 // CSsmLocaleObserverSup::NewL
   109 // CSsmLocaleObserverSup::NewL
   110 CSsmLocaleObserverSup::~CSsmLocaleObserverSup()
   123 CSsmLocaleObserverSup::~CSsmLocaleObserverSup()
   111     {
   124     {
   112     FUNC_LOG;
   125     FUNC_LOG;
   113 
   126 
   114     Cancel();
   127     Cancel();
       
   128     iLangRegionMappingHashSet.Close();
   115     delete iEnvChangeNotifier;
   129     delete iEnvChangeNotifier;
   116     iFs.Close();
   130     iFs.Close();
   117     iProperty.Close();
   131     iProperty.Close();
   118     }
   132     }
   119 
   133 
   131         changes, iRestoreActive );
   145         changes, iRestoreActive );
   132 
   146 
   133     if ( !iRestoreActive && ( changes & EChangesLocale ) )
   147     if ( !iRestoreActive && ( changes & EChangesLocale ) )
   134         {
   148         {
   135         TParsePtrC parse( KLocaleDataDir );
   149         TParsePtrC parse( KLocaleDataDir );
   136         SaveLocaleL( parse.FullName() );
   150         SaveRegionL( parse.FullName() );
   137         }
   151         }
   138 
   152 
   139     if( changes & EChangesSystemTime )
   153     if( changes & EChangesSystemTime )
   140         {
   154         {
   141         INFO( "Persisting HAL settings" );
   155         INFO( "Persisting HAL settings" );
   183                 INFO( "Restore finished" );
   197                 INFO( "Restore finished" );
   184 
   198 
   185                 iRestoreActive = EFalse;
   199                 iRestoreActive = EFalse;
   186 
   200 
   187                 TParsePtrC parse( KLocaleDataDir );
   201                 TParsePtrC parse( KLocaleDataDir );
   188                 TRAP( err, LoadLocaleL( parse.FullName() ) );
   202                 TRAP( err, LoadRegionL( parse.FullName() ) );
   189                 ERROR( err, "Failed to load locale" );
   203                 ERROR( err, "Failed to load locale" );
   190                 // Can not do anything about the error - just continue.
   204                 // Cannot do anything about the error - just continue.
   191                 }
   205                 }
   192             }
   206             }
   193         }
   207         }
   194     }
   208     }
   195 
   209 
   216 
   230 
   217     TInt err = iFs.Connect();
   231     TInt err = iFs.Connect();
   218     ERROR( err, "Failed to connect to file server" );
   232     ERROR( err, "Failed to connect to file server" );
   219     User::LeaveIfError( err );
   233     User::LeaveIfError( err );
   220 
   234 
       
   235     InitializeRegionMappingL();
       
   236     
   221     TRAP( err, iEnvChangeNotifier = CEnvironmentChangeNotifier::NewL(
   237     TRAP( err, iEnvChangeNotifier = CEnvironmentChangeNotifier::NewL(
   222         CActive::EPriorityStandard,
   238         CActive::EPriorityStandard,
   223         TCallBack( EnvChangeNotifierCallback, this ) ) );
   239         TCallBack( EnvChangeNotifierCallback, this ) ) );
   224     ERROR( err, "Failed to create environment change notifier" );
   240     ERROR( err, "Failed to create environment change notifier" );
   225     User::LeaveIfError( err );
   241     User::LeaveIfError( err );
   233 void CSsmLocaleObserverSup::StartL()
   249 void CSsmLocaleObserverSup::StartL()
   234     {
   250     {
   235     FUNC_LOG;
   251     FUNC_LOG;
   236 
   252 
   237     TParsePtrC parse( KLocaleDataDir );
   253     TParsePtrC parse( KLocaleDataDir );
   238     TRAPD_ERR( err, LoadLocaleL( parse.FullName() ) );
   254     TRAPD_ERR( err, LoadRegionL( parse.FullName() ) );
   239     ERROR( err, "Failed to load locale data the first time" );
   255     ERROR( err, "Failed to load region data the first time" );
   240 
   256 
   241     if ( iEnvChangeNotifier )
   257     if ( iEnvChangeNotifier )
   242         {
   258         {
   243         iEnvChangeNotifier->Start();
   259         iEnvChangeNotifier->Start();
   244         }
   260         }
   266 // CSsmLocaleObserverSup::CSsmLocaleObserverSup
   282 // CSsmLocaleObserverSup::CSsmLocaleObserverSup
   267 // ---------------------------------------------------------------------------
   283 // ---------------------------------------------------------------------------
   268 //
   284 //
   269 CSsmLocaleObserverSup::CSsmLocaleObserverSup()
   285 CSsmLocaleObserverSup::CSsmLocaleObserverSup()
   270   : CActive( EPriorityNormal ),
   286   : CActive( EPriorityNormal ),
   271     iRestoreActive( EFalse )
   287     iRestoreActive( EFalse ),
       
   288     iLangRegionMappingHashSet( &::HashLangRegionMappingFunction, &::HashLangRegionMappingIdentityRelation )
   272     {
   289     {
   273     FUNC_LOG;
   290     FUNC_LOG;
   274 
   291 
   275     CActiveScheduler::Add( this );
   292     CActiveScheduler::Add( this );
   276     }
   293     }
   289     SetActive();
   306     SetActive();
   290     }
   307     }
   291 
   308 
   292 
   309 
   293 // ---------------------------------------------------------------------------
   310 // ---------------------------------------------------------------------------
   294 // CSsmLocaleObserverSup::SaveLocaleL
   311 // CSsmLocaleObserverSup::SaveRegionL
   295 // ---------------------------------------------------------------------------
   312 // ---------------------------------------------------------------------------
   296 //
   313 //
   297 void CSsmLocaleObserverSup::SaveLocaleL( const TDesC& aPath )
   314 void CSsmLocaleObserverSup::SaveRegionL( const TDesC& aPath )
   298     {
   315     {
   299     FUNC_LOG;
   316     FUNC_LOG;
   300     INFO( "Saving locale data" );
   317     INFO( "Saving region data" );
   301 
   318     
   302     HBufC* fName = MakeFileNameL( aPath, KFileName, User::Language() );
   319     TInt region = MappedRegionL(User::Language());
       
   320     HBufC* fName = MakeFileNameL( aPath, KFileName, region);
   303     CleanupStack::PushL( fName );
   321     CleanupStack::PushL( fName );
   304 
   322 
   305     RFileWriteStream fStream;
   323     RFileWriteStream fStream;
   306     CleanupClosePushL( fStream );
   324     CleanupClosePushL( fStream );
   307     // According to documentation RFileWriteStream
   325     // According to documentation RFileWriteStream
   363     fStream.WriteInt8L( locale.NegativeCurrencyFormat() );
   381     fStream.WriteInt8L( locale.NegativeCurrencyFormat() );
   364     fStream.WriteInt8L( locale.NegativeLoseSpace() );
   382     fStream.WriteInt8L( locale.NegativeLoseSpace() );
   365     fStream.WriteInt8L( locale.NegativeCurrencySymbolOpposite() );
   383     fStream.WriteInt8L( locale.NegativeCurrencySymbolOpposite() );
   366     fStream.WriteInt16L( locale.DigitType() );
   384     fStream.WriteInt16L( locale.DigitType() );
   367 
   385 
   368     // Then save display language independent data
       
   369     SaveIndependentDataL( locale, aPath );
       
   370 
       
   371     // If CommitL leaves it means probably full disk.
   386     // If CommitL leaves it means probably full disk.
   372     // It is here assumed that data has not been changed if this leaves.
   387     // It is here assumed that data has not been changed if this leaves.
   373     fStream.CommitL();
   388     fStream.CommitL();
   374 
   389 
   375     CleanupStack::PopAndDestroy( &fStream );
   390     CleanupStack::PopAndDestroy( &fStream );
   376     CleanupStack::PopAndDestroy( fName );
   391     CleanupStack::PopAndDestroy( fName );
   377     }
   392     }
   378 
   393 
   379 
   394 
   380 // ---------------------------------------------------------------------------
   395 // ---------------------------------------------------------------------------
   381 // CSsmLocaleObserverSup::LoadLocaleL
   396 // CSsmLocaleObserverSup::LoadRegionL
   382 // ---------------------------------------------------------------------------
   397 // ---------------------------------------------------------------------------
   383 //
   398 //
   384 void CSsmLocaleObserverSup::LoadLocaleL( const TDesC& aPath )
   399 void CSsmLocaleObserverSup::LoadRegionL( const TDesC& aPath )
   385     {
   400     {
   386     FUNC_LOG;
   401     FUNC_LOG;
   387     INFO( "Loading locale data" );
   402     INFO( "Loading region data" );
   388 
   403 
   389     HBufC* fName = MakeFileNameL( aPath, KFileName, User::Language() );
   404     TInt region = MappedRegionL(User::Language());
       
   405     HBufC* fName = MakeFileNameL( aPath, KFileName, region);
   390     CleanupStack::PushL( fName );
   406     CleanupStack::PushL( fName );
   391 
   407 
   392     TLocale locale; // copy current values
   408     TLocale locale; // copy current values
   393 
   409 
   394     RFileReadStream fStream;
   410     RFileReadStream fStream;
   402         }
   418         }
   403 
   419 
   404     if ( err == KErrNone  )
   420     if ( err == KErrNone  )
   405         {
   421         {
   406         TInt version = fStream.ReadInt8L();
   422         TInt version = fStream.ReadInt8L();
   407         INFO_1( "Locale file version: %d", version );
   423         INFO_1( "Region file version: %d", version );
   408 
   424 
   409         locale.SetCountryCode( fStream.ReadInt16L() );
   425         locale.SetCountryCode( fStream.ReadInt16L() );
   410         fStream.ReadInt16L(); // obsolete
   426         fStream.ReadInt16L(); // obsolete
   411         locale.SetDateFormat( static_cast< TDateFormat >( fStream.ReadInt8L() ) );
   427         locale.SetDateFormat( static_cast< TDateFormat >( fStream.ReadInt8L() ) );
   412         locale.SetTimeFormat( static_cast< TTimeFormat >( fStream.ReadInt8L() ) );
   428         locale.SetTimeFormat( static_cast< TTimeFormat >( fStream.ReadInt8L() ) );
   448         locale.SetNegativeLoseSpace( fStream.ReadInt8L() );
   464         locale.SetNegativeLoseSpace( fStream.ReadInt8L() );
   449         locale.SetNegativeCurrencySymbolOpposite( fStream.ReadInt8L() );
   465         locale.SetNegativeCurrencySymbolOpposite( fStream.ReadInt8L() );
   450         locale.SetDigitType( static_cast< TDigitType >( fStream.ReadInt16L() ) );
   466         locale.SetDigitType( static_cast< TDigitType >( fStream.ReadInt16L() ) );
   451         }
   467         }
   452 
   468 
   453     // Then patch data with locale independent data (code 00)
       
   454     // No changes to locale if no independent data can be found (the very first boot)
       
   455     LoadIndependentDataL( locale, aPath );
       
   456 
       
   457     // Save changes to the system.
   469     // Save changes to the system.
   458     locale.Set();
   470     locale.Set();
   459 
   471 
   460     CleanupStack::PopAndDestroy( &fStream );
   472     CleanupStack::PopAndDestroy( &fStream );
   461     CleanupStack::PopAndDestroy( fName );
   473     CleanupStack::PopAndDestroy( fName );
   462     }
   474     }
   463 
   475 
   464 
   476 void CSsmLocaleObserverSup::InitializeRegionMappingL()
   465 // ---------------------------------------------------------------------------
   477     {
   466 // CSsmLocaleObserverSup::SaveIndependentDataL
   478     //Reserve the memory for the number of mappings to be appended
   467 // ---------------------------------------------------------------------------
   479     iLangRegionMappingHashSet.ReserveL( KMaxNumberOfRegions );
   468 //
   480     
   469 void CSsmLocaleObserverSup::SaveIndependentDataL(
   481     //Insert the Language - Region mapping
   470     const TLocale& aLocale,
   482     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangEnglish,             ERegGBR ) );
   471     const TDesC& aPath )
   483     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangFrench,              ERegFRA ) );
   472     {
   484     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangGerman,              ERegDEU ) );
   473     FUNC_LOG;
   485     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangSpanish,             ERegESP ) );
   474 
   486     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangItalian,             ERegITA ) );
   475     // Get old independent data, if any.
   487     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangSwedish,             ERegSWE ) );
   476     TLocale savedLoc;
   488     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangDanish,              ERegDNK ) );
   477     TRAPD( err, LoadIndependentDataL( savedLoc, aPath ) );
   489     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangNorwegian,           ERegNOR ) );
   478     ERROR( err, "Failed to load locale independent data" );
   490     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangFinnish,             ERegFIN ) );
   479 
   491     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangAmerican,            ERegUSA ) );
   480     HBufC* fName = MakeFileNameL( aPath, KCommonFileName, 0 );
   492     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangPortuguese,          ERegPRT ) );
   481     CleanupStack::PushL( fName );
   493     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangTurkish,             ERegTUR ) );
   482     RFileWriteStream fStream;
   494     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangIcelandic,           ERegISL ) );
   483     CleanupClosePushL( fStream );
   495     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangRussian,             ERegRUS ) );
   484 
   496     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangHungarian,           ERegHUN ) );
   485     err = iFs.MkDirAll( *fName ); // Ignore errors
   497     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangDutch,               ERegNLD ) );
   486     err = fStream.Create( iFs, *fName, EFileWrite );
   498     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangBelgianFlemish,      ERegBEL ) );
   487     if ( err == KErrAlreadyExists )
   499     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangCzech,               ERegCZE ) );
   488         {
   500     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangSlovak,              ERegSVK ) );
   489         // Override
   501     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangPolish,              ERegPOL ) );
   490         err = fStream.Open( iFs, *fName, EFileWrite );
   502     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangSlovenian,           ERegSVN ) );
   491         ERROR_1( err, "Failed to create stream %S", fName );
   503     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangTaiwanChinese,       ERegTWN ) );
   492         }
   504     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangHongKongChinese,     ERegHKG ) );
   493     User::LeaveIfError( err );
   505     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangPrcChinese,          ERegCHN ) );
   494 
   506     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangJapanese,            ERegJPN ) );
   495     // Write first the version number to enable support for file format changes.
   507     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangThai,                ERegTHA ) );
   496     fStream.WriteInt8L( KCurrentVersionNumber );
   508     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangArabic,              ERegARE ) );
   497     fStream.WriteInt32L( 0 ); // Universal time offset is not part of TLocale
   509     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangTagalog,             ERegPHL ) );
   498                               // any more. Write zero here to keep file structure.
   510     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangBulgarian,           ERegBGR ) );
   499     // Clock format is also common.
   511     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangCatalan,             ERegESP ) );
   500     fStream.WriteUint32L( aLocale.ClockFormat() );
   512     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangCroatian,            ERegHRV ) );
   501     fStream.WriteUint32L( 0 );  // reserved 2
   513     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangEstonian,            ERegEST ) );
   502     fStream.WriteUint32L( 0 );  // reserved 3
   514     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangFarsi,               ERegIRN ) );
   503 
   515     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangCanadianFrench,      ERegCAN ) );
   504     fStream.CommitL();
   516     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangGreek,               ERegGRC ) );
   505 
   517     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangHebrew,              ERegISR ) );
   506     CleanupStack::PopAndDestroy( &fStream );
   518     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangHindi,               ERegIND ) );
   507     CleanupStack::PopAndDestroy( fName );
   519     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangIndonesian,          ERegIDN ) );
   508     }
   520     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangLatvian,             ERegLVA ) );
   509 
   521     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangLithuanian,          ERegLTU ) );
   510 
   522     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangMalay,               ERegMYS ) );
   511 // ---------------------------------------------------------------------------
   523     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangBrazilianPortuguese, ERegBRA ) );
   512 // CSsmLocaleObserverSup::LoadIndependentDataL
   524     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangRomanian,            ERegROU ) );
   513 // ---------------------------------------------------------------------------
   525     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangSerbian,             ERegSCG ) );
   514 //
   526     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangLatinAmericanSpanish, ERegMEX ));
   515 void CSsmLocaleObserverSup::LoadIndependentDataL(
   527     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangUkrainian,           ERegUKR ) );
   516     TLocale& aLocale,
   528     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangUrdu,                ERegPAK ) );
   517     const TDesC& aPath )
   529     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangVietnamese,          ERegVNM ) );
   518     {
   530 #ifdef __E32LANG_H__
   519     FUNC_LOG;
   531     // 5.0
   520 
   532     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangBasque,              ERegESP ) );
   521     HBufC* fName = MakeFileNameL( aPath, KCommonFileName, 0 );
   533     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangGalician,            ERegESP ) );
   522     CleanupStack::PushL( fName );
   534 #endif //__E32LANG_H__
   523 
   535 #if !defined(__SERIES60_31__)
   524     RFileReadStream fStream;
   536     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangEnglish_Apac,        ERegGBR ) );
   525     CleanupClosePushL( fStream );
   537     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangEnglish_Taiwan,      ERegTWN ) );
   526     TInt err = fStream.Open( iFs, *fName, EFileRead );
   538     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangEnglish_HongKong,    ERegHKG ) );
   527     if ( err != KErrNotFound && err != KErrPathNotFound )
   539     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangEnglish_Prc,         ERegCHN ) );
   528         {
   540     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangEnglish_Japan,       ERegJPN ) );
   529         ERROR_1( err, "Failed to open stream %S", fName );
   541     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangEnglish_Thailand,    ERegTHA ) );
   530         // Data file is missing upon the first boot or when switching into a
   542     iLangRegionMappingHashSet.InsertL( TLanguageRegion( ELangMalay_Apac,          ERegMYS ) );
   531         // language for the first time
   543 #endif //!defined(__SERIES60_31__)
   532         }
   544     }
   533 
   545 
   534     if ( err == KErrNotFound || err == KErrPathNotFound )
   546 // ---------------------------------------------------------------------------
   535         {
   547 // CSsmLocaleObserverSup::MappedRegionL
   536         // File not found --> Not an error because
   548 // ---------------------------------------------------------------------------
   537         // this is a new file and older builds do not have this file.
   549 //
   538         INFO( "No locale data found" );
   550 TInt CSsmLocaleObserverSup::MappedRegionL(const TInt aLanguage)
   539         }
   551     {
   540     else
   552     FUNC_LOG;
   541         {
   553     TLanguageRegion langRegion = iLangRegionMappingHashSet.FindL(TLanguageRegion(aLanguage));
   542         User::LeaveIfError( err );
   554     return langRegion.iRegion;
   543 
   555     }    
   544         fStream.ReadInt8L();    // Version.
       
   545         fStream.ReadInt32L();   // Universal time offset was stored here.
       
   546         aLocale.SetClockFormat( ( TClockFormat ) fStream.ReadUint32L() );
       
   547         fStream.ReadUint32L(); // reserved 2
       
   548         fStream.ReadUint32L(); // reserved 3
       
   549         }
       
   550 
       
   551     CleanupStack::PopAndDestroy( &fStream );
       
   552     CleanupStack::PopAndDestroy( fName );
       
   553     }