diff -r 1ddbe54d0645 -r ccb4f6b3db21 sysstatemgmt/syslangutil/ssmlangselcmd/src/ssmlanguageloader.cpp --- a/sysstatemgmt/syslangutil/ssmlangselcmd/src/ssmlanguageloader.cpp Thu Aug 19 11:09:10 2010 +0300 +++ b/sysstatemgmt/syslangutil/ssmlangselcmd/src/ssmlanguageloader.cpp Tue Aug 31 16:29:05 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -20,39 +20,11 @@ #include #include "ssmlanguageloader.h" +#include "ssmcommonlocale.h" #include "trace.h" -_LIT( KLocaleDllNameBase, "ELOCL" ); -_LIT( KLocaleDllExtensionFormat, ".%u" ); -_LIT( KLocaleDllExtensionPadding, "0" ); -_LIT( KDefaultLocaleDllNameExtension, ".LOC" ); -const TInt KMaxLocaleDllNameLength = 16; -const TInt KMaxLocaleDllExtensionLength = 6; -const TInt KMinLocaleDllExtensionLength = 3; -const TInt KLocaleDllExtensionPaddingPosition = 1; - // ======== MEMBER FUNCTIONS ======== -// --------------------------------------------------------------------------- -// SsmLanguageLoader::LoadLanguage -// -// --------------------------------------------------------------------------- -// -TInt SsmLanguageLoader::LoadLanguage( const TInt aLanguage ) - { - FUNC_LOG; - INFO_1( "Loading language %d", aLanguage ); - - TInt errorCode = StoreLanguageToHal( aLanguage ); - ERROR( errorCode, "Failed to store language code to HAL" ); - - errorCode = LoadLocaleDll( aLanguage ); - ERROR( errorCode, "Failed to load locale DLL" ); - - return errorCode; - } - - // ----------------------------------------------------------------------------- // SsmLanguageLoader::StoreLanguageToHal // @@ -67,70 +39,96 @@ } -// ----------------------------------------------------------------------------- -// SsmLanguageLoader::LoadLocaleDll +// --------------------------------------------------------------------------- +// SsmLanguageLoader::LoadLocale // -// ----------------------------------------------------------------------------- +// --------------------------------------------------------------------------- // -TInt SsmLanguageLoader::LoadLocaleDll( const TInt aLanguage ) +TInt SsmLanguageLoader::LoadLocale( const TInt aLanguage, const TInt aRegion, const TInt aCollation) { FUNC_LOG; - // Dot plus five digit locale - TBuf extension; - extension.Format( KLocaleDllExtensionFormat, aLanguage ); - - // Padd ".1" to ".01" for compatibility. - if ( extension.Length() < KMinLocaleDllExtensionLength ) + TInt errorCode = StoreLanguageToHal( aLanguage ); + ERROR( errorCode, "Failed to store language code to HAL" ); + + //Format the language dll to be loaded + //Dot plus four to six digit locale + TBuf extension; + extension.Format( KDllExtensionFormat, aLanguage ); + + //Padd with zero to make the file extension length to be minimum of four + for( ; extension.Length() < KMinDllExtensionLength ;) { - extension.Insert( KLocaleDllExtensionPaddingPosition, - KLocaleDllExtensionPadding ); - } - - TBuf localeDllName; - localeDllName = KLocaleDllNameBase; - localeDllName.Append( extension ); - - INFO_1( "Loading DLL named '%S'", &localeDllName ); - - TInt errorCode = ChangeLocale( localeDllName ); - - if ( errorCode == KErrNotFound ) // Try default locale - { - INFO( "SsmLanguageLoader: Loading default locale" ); - - localeDllName = KLocaleDllNameBase; - localeDllName.Append( KDefaultLocaleDllNameExtension ); - - errorCode = ChangeLocale( localeDllName ); + extension.Insert( KDllExtensionPaddingPosition, KDllExtensionPadding ); } + TBuf languageDllName( KLanguageDllNameBase ); + languageDllName.Append( extension ); + INFO_1( "Loading language DLL named '%S'", &languageDllName ); + + //Format the region dll to be loaded + //Dot plus four to six digit locale + extension.Zero(); + extension.Format( KDllExtensionFormat, aRegion ); + + //Padd with zero to make the file extension length to be minimum of four + for( ; extension.Length() < KMinDllExtensionLength ;) + { + extension.Insert( KDllExtensionPaddingPosition, KDllExtensionPadding ); + } + + TBuf regionDllName( KRegionDllNameBase ); + regionDllName.Append( extension ); + INFO_1( "Loading Region DLL named '%S'", ®ionDllName ); + + + //Format the collation file to be loaded + //Dot plus four to six digit locale + extension.Zero(); + extension.Format( KDllExtensionFormat, aCollation ); + + //Padd with zero to make the file extension length to be minimum of four + for( ; extension.Length() < KMinDllExtensionLength ;) + { + extension.Insert( KDllExtensionPaddingPosition, KDllExtensionPadding ); + } + + TBuf collationDllName( KCollationDllNameBase ); + collationDllName.Append( extension ); + INFO_1( "Loading Collation DLL named '%S'", &collationDllName ); + + //Load the given Language, Region and Collation dlls + errorCode = ChangeLocale( languageDllName, regionDllName, collationDllName ); if ( errorCode == KErrNone ) { TLocale().Set(); } - return errorCode; } - -// ----------------------------------------------------------------------------- +// --------------------------------------------------------------------------- // SsmLanguageLoader::ChangeLocale // -// ----------------------------------------------------------------------------- +// --------------------------------------------------------------------------- // -TInt SsmLanguageLoader::ChangeLocale( const TDesC& aLocaleDllName ) +TInt SsmLanguageLoader::ChangeLocale( const TDesC& aLanguageDllName, const TDesC& aRegionDllName, const TDesC& aCollationDllName ) { FUNC_LOG; + TExtendedLocale extLocale; - TExtendedLocale extLocale; - TInt errorCode = extLocale.LoadLocale( aLocaleDllName ); - ERROR( errorCode, "Failed to load locale" ); - + INFO_3( "Loading Language dll '%S', Region dll '%S' and Collation dll '%S'", + &aLanguageDllName, &aRegionDllName, &aCollationDllName ); + TInt errorCode = extLocale.LoadLocale( aLanguageDllName, aRegionDllName, aCollationDllName); if ( errorCode == KErrNone ) { + //Save the loaded locale settings errorCode = extLocale.SaveSystemSettings(); - ERROR( errorCode, "Failed to set locale" ); + ERROR( errorCode, "Failed to save locale settings" ); + } + else + { + INFO_3( "Failed to load Language dll '%S', Region dll '%S' and Collation dll '%S'", + &aLanguageDllName, &aRegionDllName, &aCollationDllName ); } return errorCode;