os/ossrv/lowlevellibsandfws/apputils/initLocale/src/InitialiseLocale.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <e32base.h>
sl@0
    17
#include <e32std.h>
sl@0
    18
#include <e32err.h>
sl@0
    19
#include <e32debug.h>
sl@0
    20
#include <e32property.h>
sl@0
    21
#include <bacntf.h>
sl@0
    22
#include <bautils.h>
sl@0
    23
#include "LocaleRepository.h"
sl@0
    24
#include "InitialiseLocale.h"
sl@0
    25
#include <hal.h>
sl@0
    26
sl@0
    27
using namespace NCentralRepositoryConstants ;
sl@0
    28
sl@0
    29
sl@0
    30
// Text constants for debug messages
sl@0
    31
#ifdef _DEBUG
sl@0
    32
_LIT (KBadChangeNotification, "InitialiseLocale: Bad Change Notification") ;
sl@0
    33
#endif
sl@0
    34
sl@0
    35
//
sl@0
    36
// CExtendedLocaleManager::LocaleChanged
sl@0
    37
//
sl@0
    38
// Callback function to be attached to an instance of 
sl@0
    39
// CEnvironmentChangeNotifier to persist system locale data.
sl@0
    40
//
sl@0
    41
// Note that this has to be a static member function so that
sl@0
    42
// it can be encapsulated into a TCallback object for use with
sl@0
    43
// a CEnvironmentChangeNotifier - we get round this by passing
sl@0
    44
// in a "this" pointer so that while remaining a static function
sl@0
    45
// it can access all the member data anyway!
sl@0
    46
TInt CExtendedLocaleManager::LocaleChanged(TAny* aPtr)
sl@0
    47
	{
sl@0
    48
	CExtendedLocaleManager* thisLocaleManager = (CExtendedLocaleManager *) aPtr ;
sl@0
    49
	
sl@0
    50
	if(!thisLocaleManager->iChangeNotifier)	
sl@0
    51
		{
sl@0
    52
		#ifdef _DEBUG		
sl@0
    53
		RDebug::Print(KBadChangeNotification);
sl@0
    54
		#endif
sl@0
    55
		return EFalse;
sl@0
    56
		} 
sl@0
    57
sl@0
    58
sl@0
    59
 	TInt stat = thisLocaleManager->iChangeNotifier->Change();
sl@0
    60
	if(stat & EChangesLocale)
sl@0
    61
		{
sl@0
    62
		//
sl@0
    63
	   	// System Locale data has been updated, persist
sl@0
    64
	   	// changes by writing to repository.
sl@0
    65
		TRAPD(err, thisLocaleManager->PersistLocaleL()); // No way to handle errors within this callback function, so ignore them
sl@0
    66
		if(err != KErrNone)	
sl@0
    67
			{
sl@0
    68
			err=KErrNone;
sl@0
    69
			}
sl@0
    70
		}
sl@0
    71
	if(stat & EChangesSystemTime)
sl@0
    72
		{
sl@0
    73
		// changes by writing to HAL
sl@0
    74
		TInt ret = BaflUtils::PersistHAL();
sl@0
    75
		__ASSERT_DEBUG(ret == KErrNone, User::Invariant() );
sl@0
    76
		}
sl@0
    77
	
sl@0
    78
	return ETrue;
sl@0
    79
	}
sl@0
    80
sl@0
    81
sl@0
    82
//
sl@0
    83
// CExtendedLocaleManager::NewLC() 
sl@0
    84
// CExtendedLocaleManager::NewL() 
sl@0
    85
//
sl@0
    86
// Usual 2 phase construction factory NewL NewLC classes
sl@0
    87
// 	
sl@0
    88
CExtendedLocaleManager* CExtendedLocaleManager::NewLC() 
sl@0
    89
	{
sl@0
    90
	CExtendedLocaleManager* me = new(ELeave)CExtendedLocaleManager();
sl@0
    91
	CleanupStack::PushL(me) ;
sl@0
    92
	me->ConstructL() ;
sl@0
    93
	return me;
sl@0
    94
	}
sl@0
    95
	
sl@0
    96
	
sl@0
    97
CExtendedLocaleManager* CExtendedLocaleManager::NewL() 
sl@0
    98
	{
sl@0
    99
	CExtendedLocaleManager* me = CExtendedLocaleManager::NewLC() ;
sl@0
   100
	CleanupStack::Pop(me) ;
sl@0
   101
	return me;
sl@0
   102
	}
sl@0
   103
	
sl@0
   104
		
sl@0
   105
sl@0
   106
sl@0
   107
//
sl@0
   108
// CExtendedLocaleManager::CExtendedLocaleManager	
sl@0
   109
// 
sl@0
   110
// Constructor - doesn't really do anything!
sl@0
   111
//
sl@0
   112
CExtendedLocaleManager::CExtendedLocaleManager() 
sl@0
   113
	{
sl@0
   114
	}
sl@0
   115
sl@0
   116
sl@0
   117
sl@0
   118
//
sl@0
   119
// CExtendedLocaleManager::ConstructL()
sl@0
   120
//
sl@0
   121
// Second phase constructor, initialises locale data from persisted (or default)
sl@0
   122
// values in repository, creates an instance of CEnvironmentChangeNotifier, and
sl@0
   123
// attaches the callback function, passing in our "this" pointer to get round the
sl@0
   124
// requirement for the callback function to be a static. 
sl@0
   125
//
sl@0
   126
void CExtendedLocaleManager::ConstructL()
sl@0
   127
	{
sl@0
   128
	
sl@0
   129
	TUid LocalePropertyUid;
sl@0
   130
	LocalePropertyUid.iUid = KUidLocalePersistProperties ;
sl@0
   131
	
sl@0
   132
	TInt error = RProperty::Define((TUint)EInitialisationState, RProperty::EInt,TSecurityPolicy::EAlwaysPass,TSecurityPolicy(ECapabilityWriteDeviceData));
sl@0
   133
	if(error != KErrAlreadyExists)
sl@0
   134
	{
sl@0
   135
	User::LeaveIfError(error);
sl@0
   136
	
sl@0
   137
	//If the property definition fails bail out. Note that if the 
sl@0
   138
	// property has already been defined (because the locale initialisation code
sl@0
   139
	// has already been called) this call will return KErrAlreadyExists so locale
sl@0
   140
	// initialisation will only take place once. 
sl@0
   141
	//
sl@0
   142
	// Set property to indicate initialisation in progress
sl@0
   143
	User::LeaveIfError(RProperty::Set(LocalePropertyUid, EInitialisationState, ELocaleInitialisationInProgress)) ;
sl@0
   144
sl@0
   145
	TUid LocaleRepositoryUid;
sl@0
   146
	LocaleRepositoryUid.iUid = KLocalePersistRepositoryUid;
sl@0
   147
sl@0
   148
	
sl@0
   149
	// Initialise system locale data from repository contents.
sl@0
   150
	CRepository* repository = CRepository::NewLC(LocaleRepositoryUid); 
sl@0
   151
	TRAPD(err, InitialiseLocaleL(*repository));  //this function should no longer attempt to set the failure flag 
sl@0
   152
	if (err != KErrNone)
sl@0
   153
		{
sl@0
   154
		// Failed to read DLL name, load corresponding Locale aspect or read value from DLL,
sl@0
   155
		// Set property to indicate initialisation failure and bail out!
sl@0
   156
		User::LeaveIfError(RProperty::Set(LocalePropertyUid, EInitialisationState, ELocaleInitialisationFailed)) ;
sl@0
   157
		}
sl@0
   158
	CleanupStack::PopAndDestroy(repository); 
sl@0
   159
	
sl@0
   160
	}
sl@0
   161
	
sl@0
   162
	//After Initialisation, monitor the system locale for changes. If initialiselocale.exe is restarted, 
sl@0
   163
	//then initialisation will not be executed, going to monitor directly.
sl@0
   164
sl@0
   165
	//
sl@0
   166
	// Create and install an CActiveScheduler to look after the active object
sl@0
   167
	// in the change notifier
sl@0
   168
	iActiveScheduler = new (ELeave) CActiveScheduler;
sl@0
   169
	CActiveScheduler::Install(iActiveScheduler);
sl@0
   170
		
sl@0
   171
sl@0
   172
	// Create the change notifier and install the callback function
sl@0
   173
	const TCallBack myCallBackFunction(&CExtendedLocaleManager::LocaleChanged, this);
sl@0
   174
	iChangeNotifier = CEnvironmentChangeNotifier::NewL(CActive::EPriorityStandard, myCallBackFunction);
sl@0
   175
	iChangeNotifier->Start();
sl@0
   176
sl@0
   177
	// Set property to indicate initialisation complete
sl@0
   178
	User::LeaveIfError(RProperty::Set(LocalePropertyUid, EInitialisationState, ELocaleInitialisationComplete));
sl@0
   179
	
sl@0
   180
	//now call RProcess::Rendezvous to indicate initialiseLocale is completed with no error
sl@0
   181
	RProcess().Rendezvous(KErrNone);
sl@0
   182
sl@0
   183
	// All ready to go! Start the active sheduler. 
sl@0
   184
	CActiveScheduler::Start();	
sl@0
   185
sl@0
   186
	}
sl@0
   187
sl@0
   188
sl@0
   189
//
sl@0
   190
// CExtendedLocaleManager::~CExtendedLocaleManager()
sl@0
   191
// 
sl@0
   192
// Destructor to tidy up on shutdown (if needed!).
sl@0
   193
CExtendedLocaleManager::~CExtendedLocaleManager()	
sl@0
   194
	{
sl@0
   195
	delete iChangeNotifier;
sl@0
   196
	delete iActiveScheduler;
sl@0
   197
	}
sl@0
   198
sl@0
   199
sl@0
   200
sl@0
   201
sl@0
   202
sl@0
   203
//
sl@0
   204
// CExtendedLocaleManager::PersistLocaleL
sl@0
   205
//
sl@0
   206
// Persist system locale data by writing it to a repository
sl@0
   207
void CExtendedLocaleManager::PersistLocaleL()
sl@0
   208
	{
sl@0
   209
	TUid LocaleRepositoryUid;
sl@0
   210
	LocaleRepositoryUid.iUid = KLocalePersistRepositoryUid ;
sl@0
   211
sl@0
   212
	CRepository* repository = CRepository::NewLC(LocaleRepositoryUid) ;
sl@0
   213
sl@0
   214
	// Refresh extended locale with current system settings
sl@0
   215
   	iExtendedLocale.LoadSystemSettings();
sl@0
   216
   	
sl@0
   217
	// Perform repository update in a transaction so that we're
sl@0
   218
	// guaranteed to retain consistent state of repository contents.
sl@0
   219
	User::LeaveIfError(repository->StartTransaction(CRepository::EReadWriteTransaction));
sl@0
   220
	repository->CleanupFailTransactionPushL();
sl@0
   221
sl@0
   222
	TBuf<KMaxFileName> DllName ;
sl@0
   223
sl@0
   224
	//
sl@0
   225
	// Locale DLL for Language Settings
sl@0
   226
	User::LeaveIfError(iExtendedLocale.GetLocaleDllName(ELocaleLanguageSettings, DllName));
sl@0
   227
	User::LeaveIfError(repository->Set(KLocaleLanguageDll, DllName));
sl@0
   228
	
sl@0
   229
	//	
sl@0
   230
	// Locale DLL for Collation/Charset settings
sl@0
   231
	User::LeaveIfError(iExtendedLocale.GetLocaleDllName(ELocaleCollateSetting, DllName));
sl@0
   232
	User::LeaveIfError(repository->Set(KLocaleCollationDll, DllName));
sl@0
   233
		
sl@0
   234
	//
sl@0
   235
	// Locale DLL for Locale settings
sl@0
   236
	User::LeaveIfError(iExtendedLocale.GetLocaleDllName(ELocaleLocaleSettings, DllName));
sl@0
   237
	User::LeaveIfError(repository->Set(KLocaleLocaleDll, DllName));
sl@0
   238
	
sl@0
   239
	//
sl@0
   240
	#ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
sl@0
   241
	// Locale DLL for Time and date settings
sl@0
   242
	User::LeaveIfError(iExtendedLocale.GetLocaleDllName(ELocaleTimeDateSettings, DllName));
sl@0
   243
	User::LeaveIfError(repository->Set(KLocaleTimeDateDll, DllName));
sl@0
   244
	#endif
sl@0
   245
			
sl@0
   246
	//
sl@0
   247
	// Locale customisations (contents of embedded TLocale)
sl@0
   248
	TLocale* locale = iExtendedLocale.GetLocale() ;
sl@0
   249
	User::LeaveIfError(repository->Set(KLocaleCountryCode, locale->CountryCode()));
sl@0
   250
	User::LeaveIfError(repository->Set(KLocaleUtcOffset, User::UTCOffset().Int()));
sl@0
   251
	User::LeaveIfError(repository->Set(KLocaleDateFormat, locale->DateFormat()));
sl@0
   252
	User::LeaveIfError(repository->Set(KLocaleTimeFormat, locale->TimeFormat()));
sl@0
   253
	User::LeaveIfError(repository->Set(KLocaleCurrencySymbolPosition, locale->CurrencySymbolPosition()));
sl@0
   254
	User::LeaveIfError(repository->Set(KLocaleCurrencySpaceBetween, locale->CurrencySpaceBetween()));
sl@0
   255
	User::LeaveIfError(repository->Set(KLocaleCurrencyDecimalPlaces, locale->CurrencyDecimalPlaces()));
sl@0
   256
	User::LeaveIfError(repository->Set(KLocaleCurrencyNegativeInBrackets, locale->CurrencyNegativeInBrackets()));
sl@0
   257
	User::LeaveIfError(repository->Set(KLocaleCurrencyTriadsAllowed, locale->CurrencyTriadsAllowed()));
sl@0
   258
	User::LeaveIfError(repository->Set(KLocaleThousandsSeparator, (TInt)locale->ThousandsSeparator()));
sl@0
   259
	User::LeaveIfError(repository->Set(KLocaleDecimalSeparator, (TInt)locale->DecimalSeparator()));
sl@0
   260
	
sl@0
   261
	TInt index ;
sl@0
   262
	for (index = 0; index < KMaxDateSeparators; index++)
sl@0
   263
		{
sl@0
   264
		User::LeaveIfError(repository->Set(KLocaleDateSeparatorBase+index, (TInt)locale->DateSeparator(index)));
sl@0
   265
		}
sl@0
   266
		
sl@0
   267
	for (index = 0; index < KMaxTimeSeparators; index++)
sl@0
   268
		{
sl@0
   269
		User::LeaveIfError(repository->Set(KLocaleTimeSeparatorBase +index, (TInt)locale->TimeSeparator(index)));
sl@0
   270
		}
sl@0
   271
		
sl@0
   272
 	User::LeaveIfError(repository->Set(KLocaleAmPmSpaceBetween, locale->AmPmSpaceBetween()));
sl@0
   273
	User::LeaveIfError(repository->Set(KLocaleAmPmSymbolPosition, locale->AmPmSymbolPosition()));
sl@0
   274
	User::LeaveIfError(repository->Set(KLocaleWorkDays, (TInt)locale->WorkDays()));
sl@0
   275
	User::LeaveIfError(repository->Set(KLocaleStartOfWeek, locale->StartOfWeek()));
sl@0
   276
	User::LeaveIfError(repository->Set(KLocaleClockFormat, locale->ClockFormat()));
sl@0
   277
	User::LeaveIfError(repository->Set(KLocaleUnitsGeneral, locale->UnitsGeneral()));
sl@0
   278
	User::LeaveIfError(repository->Set(KLocaleUnitsDistanceShort, locale->UnitsDistanceShort()));
sl@0
   279
	User::LeaveIfError(repository->Set(KLocaleUnitsDistanceLong, locale->UnitsDistanceLong()));
sl@0
   280
	User::LeaveIfError(repository->Set(KLocaleCurrencyNegativeFormat, locale->NegativeCurrencyFormat()));
sl@0
   281
	User::LeaveIfError(repository->Set(KLocaleCurrencyNegativeLoseSpace, locale->NegativeLoseSpace()));
sl@0
   282
	User::LeaveIfError(repository->Set(KLocaleCurrencySymbolOpposite, locale->NegativeCurrencySymbolOpposite()));
sl@0
   283
	
sl@0
   284
	TCurrencySymbol currencySymbol ;
sl@0
   285
	currencySymbol.Set() ;
sl@0
   286
	User::LeaveIfError(repository->Set(KLocaleCurrencySymbol, currencySymbol));
sl@0
   287
	
sl@0
   288
	for (index = 0; index < 3; index++)
sl@0
   289
		{
sl@0
   290
		User::LeaveIfError(repository->Set(KLocaleLanguageDowngradeBase+index, locale->LanguageDowngrade(index)));
sl@0
   291
		}
sl@0
   292
		
sl@0
   293
	User::LeaveIfError(repository->Set(KLocaleDigitType, locale->DigitType()));
sl@0
   294
	User::LeaveIfError(repository->Set(KLocaleDeviceTimeState, locale->DeviceTime()));
sl@0
   295
	
sl@0
   296
	// Completed sucessfully, commit transaction and close registry
sl@0
   297
	TUint32 transactionErr ;
sl@0
   298
 	User::LeaveIfError(repository->CommitTransaction(transactionErr));
sl@0
   299
 	CleanupStack::Pop(); // pop repository->CleanupFailTransactionPushL item
sl@0
   300
	CleanupStack::PopAndDestroy (repository);	
sl@0
   301
	}
sl@0
   302
	
sl@0
   303
	
sl@0
   304
	
sl@0
   305
	
sl@0
   306
//
sl@0
   307
// Initialise System Locale data from persisted (or default) data held in a
sl@0
   308
//repository.
sl@0
   309
void CExtendedLocaleManager::InitialiseLocaleL(CRepository& aRepository)
sl@0
   310
	{
sl@0
   311
sl@0
   312
	// Get names of DLLs to be loaded	
sl@0
   313
	TBuf<KMaxFileName> DllName ;
sl@0
   314
	
sl@0
   315
	#ifndef SYMBIAN_DISTINCT_LOCALE_MODEL
sl@0
   316
	// Collation/Charset settings
sl@0
   317
	User::LeaveIfError(aRepository.Get(KLocaleCollationDll, DllName));
sl@0
   318
	User::LeaveIfError(iExtendedLocale.LoadLocaleAspect(ELocaleCollateSetting,DllName));
sl@0
   319
		
sl@0
   320
	// Language Settings
sl@0
   321
	User::LeaveIfError(aRepository.Get(KLocaleLanguageDll, DllName));
sl@0
   322
	User::LeaveIfError(iExtendedLocale.LoadLocaleAspect(ELocaleLanguageSettings,DllName));
sl@0
   323
	
sl@0
   324
	// Locale settings
sl@0
   325
	User::LeaveIfError(aRepository.Get(KLocaleLocaleDll, DllName));
sl@0
   326
	User::LeaveIfError(iExtendedLocale.LoadLocaleAspect(ELocaleLocaleSettings,DllName));
sl@0
   327
	
sl@0
   328
	// Time and Date settings
sl@0
   329
	User::LeaveIfError(aRepository.Get(KLocaleTimeDateDll, DllName));	
sl@0
   330
	User::LeaveIfError(iExtendedLocale.LoadLocaleAspect(ELocaleTimeDateSettings,DllName));
sl@0
   331
	
sl@0
   332
	#else
sl@0
   333
	
sl@0
   334
	User::LeaveIfError(aRepository.Get(KLocaleCollationDll, DllName));
sl@0
   335
	User::LeaveIfError(iExtendedLocale.LoadLocaleAspect(DllName));
sl@0
   336
sl@0
   337
	User::LeaveIfError(aRepository.Get(KLocaleLanguageDll, DllName));
sl@0
   338
	User::LeaveIfError(iExtendedLocale.LoadLocaleAspect(DllName));
sl@0
   339
sl@0
   340
	User::LeaveIfError(aRepository.Get(KLocaleLocaleDll, DllName));
sl@0
   341
	User::LeaveIfError(iExtendedLocale.LoadLocaleAspect(DllName));
sl@0
   342
	
sl@0
   343
	#endif
sl@0
   344
sl@0
   345
	iExtendedLocale.SaveSystemSettings();
sl@0
   346
	
sl@0
   347
	// Locale customisations
sl@0
   348
	TLocale* locale = iExtendedLocale.GetLocale() ;
sl@0
   349
sl@0
   350
	TInt intValue ;	
sl@0
   351
	User::LeaveIfError(aRepository.Get(KLocaleCountryCode, intValue));
sl@0
   352
	locale->SetCountryCode(intValue) ;
sl@0
   353
sl@0
   354
	User::LeaveIfError(aRepository.Get(KLocaleUtcOffset, intValue));
sl@0
   355
	User::SetUTCOffset(intValue) ;
sl@0
   356
sl@0
   357
	User::LeaveIfError(aRepository.Get(KLocaleDateFormat, intValue));
sl@0
   358
	locale->SetDateFormat((TDateFormat)intValue) ;
sl@0
   359
	
sl@0
   360
	User::LeaveIfError(aRepository.Get(KLocaleTimeFormat, intValue));
sl@0
   361
	locale->SetTimeFormat((TTimeFormat)intValue) ;
sl@0
   362
	
sl@0
   363
	User::LeaveIfError(aRepository.Get(KLocaleCurrencySymbolPosition, intValue));
sl@0
   364
	locale->SetCurrencySymbolPosition((TLocalePos)intValue) ;
sl@0
   365
	
sl@0
   366
	User::LeaveIfError(aRepository.Get(KLocaleCurrencySpaceBetween, intValue));
sl@0
   367
	locale->SetCurrencySpaceBetween((TBool)intValue) ;
sl@0
   368
	
sl@0
   369
	User::LeaveIfError(aRepository.Get(KLocaleCurrencyDecimalPlaces, intValue));
sl@0
   370
	locale->SetCurrencyDecimalPlaces((TBool)intValue) ;
sl@0
   371
		
sl@0
   372
	User::LeaveIfError(aRepository.Get(KLocaleCurrencyNegativeInBrackets, intValue));
sl@0
   373
	locale->SetCurrencyNegativeInBrackets((TBool)intValue) ;
sl@0
   374
sl@0
   375
	User::LeaveIfError(aRepository.Get(KLocaleCurrencyTriadsAllowed, intValue));
sl@0
   376
	locale->SetCurrencyTriadsAllowed((TBool)intValue) ;
sl@0
   377
sl@0
   378
	TCurrencySymbol currencySymbol ;
sl@0
   379
	User::LeaveIfError(aRepository.Get(KLocaleCurrencySymbol, currencySymbol));
sl@0
   380
	iExtendedLocale.SetCurrencySymbol(currencySymbol) ;
sl@0
   381
sl@0
   382
	User::LeaveIfError(aRepository.Get(KLocaleThousandsSeparator, intValue));
sl@0
   383
	locale->SetThousandsSeparator(intValue) ;
sl@0
   384
		
sl@0
   385
	User::LeaveIfError(aRepository.Get(KLocaleDecimalSeparator, intValue));
sl@0
   386
	locale->SetDecimalSeparator(intValue) ;
sl@0
   387
sl@0
   388
	TInt index ;
sl@0
   389
	for (index = 0; index < KMaxDateSeparators; index++)
sl@0
   390
		{
sl@0
   391
		User::LeaveIfError(aRepository.Get(KLocaleDateSeparatorBase+index, intValue));
sl@0
   392
		locale->SetDateSeparator(intValue, index) ;
sl@0
   393
		}
sl@0
   394
		
sl@0
   395
	for (index = 0; index < KMaxTimeSeparators; index++)
sl@0
   396
		{
sl@0
   397
		User::LeaveIfError(aRepository.Get(KLocaleTimeSeparatorBase+index, intValue));
sl@0
   398
		locale->SetTimeSeparator(intValue, index) ;
sl@0
   399
		}
sl@0
   400
sl@0
   401
	User::LeaveIfError(aRepository.Get(KLocaleAmPmSpaceBetween, intValue));
sl@0
   402
	locale->SetAmPmSpaceBetween(intValue) ;
sl@0
   403
		
sl@0
   404
	User::LeaveIfError(aRepository.Get(KLocaleAmPmSymbolPosition, intValue));
sl@0
   405
	locale->SetAmPmSymbolPosition((TLocalePos)intValue) ;
sl@0
   406
		
sl@0
   407
	User::LeaveIfError(aRepository.Get(KLocaleWorkDays, intValue));
sl@0
   408
	locale->SetWorkDays(intValue) ;
sl@0
   409
	
sl@0
   410
	User::LeaveIfError(aRepository.Get(KLocaleStartOfWeek, intValue));
sl@0
   411
	locale->SetStartOfWeek((TDay)intValue) ;
sl@0
   412
sl@0
   413
	User::LeaveIfError(aRepository.Get(KLocaleClockFormat, intValue));
sl@0
   414
	locale->SetClockFormat((TClockFormat)intValue) ;
sl@0
   415
sl@0
   416
	User::LeaveIfError(aRepository.Get(KLocaleUnitsGeneral, intValue));
sl@0
   417
	locale->SetUnitsGeneral((TUnitsFormat)intValue) ;
sl@0
   418
sl@0
   419
	User::LeaveIfError(aRepository.Get(KLocaleUnitsDistanceShort, intValue));
sl@0
   420
	locale->SetUnitsDistanceShort((TUnitsFormat)intValue) ;
sl@0
   421
sl@0
   422
	User::LeaveIfError(aRepository.Get(KLocaleUnitsDistanceLong, intValue));
sl@0
   423
	locale->SetUnitsDistanceLong((TUnitsFormat)intValue) ;		
sl@0
   424
sl@0
   425
	User::LeaveIfError(aRepository.Get(KLocaleCurrencyNegativeFormat, intValue));
sl@0
   426
	locale->SetNegativeCurrencyFormat((TLocale::TNegativeCurrencyFormat)intValue) ;		
sl@0
   427
sl@0
   428
	User::LeaveIfError(aRepository.Get(KLocaleCurrencyNegativeLoseSpace, intValue));
sl@0
   429
	locale->SetNegativeLoseSpace(intValue) ;	
sl@0
   430
sl@0
   431
	User::LeaveIfError(aRepository.Get(KLocaleCurrencySymbolOpposite, intValue));
sl@0
   432
	locale->SetNegativeCurrencySymbolOpposite(intValue) ;	
sl@0
   433
sl@0
   434
	for (index = 0; index < 3; index++)
sl@0
   435
		{
sl@0
   436
		User::LeaveIfError(aRepository.Get(KLocaleLanguageDowngradeBase+index, intValue));
sl@0
   437
		locale->SetLanguageDowngrade(index, (TLanguage)intValue) ;
sl@0
   438
		}
sl@0
   439
sl@0
   440
	User::LeaveIfError(aRepository.Get(KLocaleDigitType, intValue));
sl@0
   441
	locale->SetDigitType((TDigitType)intValue) ;	
sl@0
   442
		
sl@0
   443
	User::LeaveIfError(aRepository.Get(KLocaleDeviceTimeState, intValue));
sl@0
   444
	locale->SetDeviceTime((TLocale::TDeviceTimeState)intValue) ;	
sl@0
   445
	
sl@0
   446
	//
sl@0
   447
	// Sucessfully loaded a complete set of persisted/default Locale data - write to
sl@0
   448
	// system locale data.
sl@0
   449
	User::LeaveIfError(iExtendedLocale.SaveSystemSettings());
sl@0
   450
		
sl@0
   451
	}
sl@0
   452
	
sl@0
   453
	
sl@0
   454
// Entry point for the executable
sl@0
   455
TInt E32Main()
sl@0
   456
	{
sl@0
   457
	TInt result = KErrNone;
sl@0
   458
	CTrapCleanup* tc = CTrapCleanup::New();
sl@0
   459
	if(!tc)
sl@0
   460
		{
sl@0
   461
		User::Panic(KLocaleInitPanic, KErrNoMemory) ;
sl@0
   462
		}
sl@0
   463
	__UHEAP_MARK;
sl@0
   464
	
sl@0
   465
	CExtendedLocaleManager* localeManager = NULL ;
sl@0
   466
	TRAPD(err, (localeManager = CExtendedLocaleManager::NewL()));
sl@0
   467
	if(err != KErrNone)
sl@0
   468
		{
sl@0
   469
		result = err;		
sl@0
   470
		}	
sl@0
   471
	__UHEAP_MARKEND;
sl@0
   472
	
sl@0
   473
	delete localeManager;
sl@0
   474
	delete tc;
sl@0
   475
	return result;
sl@0
   476
	}
sl@0
   477