Пример #1
0
// ---------------------------------------------------------------------------
// TPresCondValidity::ConvertToLocal()
// ---------------------------------------------------------------------------
//        
void TPresCondValidity::ConvertToLocal(TTime& aDateTime)
    {
    OPENG_DP(D_OPENG_LIT( " TPresCondValidity::ConvertToLocal()" ) );
    OPENG_DP(D_OPENG_LIT( "     ConvertToLocal aDateTime:"));
    LogDateTime(aDateTime.DateTime());

    TLocale myLocale;
    myLocale.Refresh();
    
    // getting UTC difference    
    TTimeIntervalSeconds uTCseconds = myLocale.UniversalTimeOffset();
    aDateTime = aDateTime + uTCseconds;
    }
/**
This routine is used to check if conversion of digits is needed.
Conversion is needed if user language is   
- Arabic, Urdu or Farsi and if digit type is Arabic-Indic
- Urdu or Farsi and digit type is Eastern Arabic_indic
- Hindi and digit type is Devanagari. 

@return  ETrue if conversion is needed, EFalse if not
*/
TBool CResourceLoader::LanguageSpecificNumberConverter::IsConversionNeeded()
    {
    TLocale locale;
    locale.Refresh();
    const TLanguage language = User::Language();
    const TDigitType digitType = locale.DigitType();
    
    if ( ( ( language == ELangArabic || language == ELangUrdu || language == ELangFarsi ) &&
         digitType == EDigitTypeArabicIndic ) 
         || ( ( language == ELangUrdu || language == ELangFarsi ) &&
         digitType == EDigitTypeEasternArabicIndic )
         || ( language == ELangHindi && digitType == EDigitTypeDevanagari )
        )
        {
        return ETrue;
        }

    return EFalse;
    }
Пример #3
0
void testChangeLocale(TInt isrom)
{
	TLocale locale;
	
#ifdef __WINS__
//We get a power-change notification 1 second after switch-on
//So we wait for a second on WINS.
//Should we fix this bug??
	User::After(1000000);
#endif
	RChangeNotifier notifier;
	TInt res=notifier.Create();
	test(res==KErrNone);
	TRequestStatus stat;
	res=notifier.Logon(stat);
	test(res==KErrNone);
	//initial pattern of stat is already tested by t_chnot

	res=notifier.Logon(stat);
	test(res==KErrNone);
	test(stat==KRequestPending);
	if (isrom == 0) 
		{
		test.Printf(_L("Change to RAM US Locale\n")); 	
		res=UserSvr::ChangeLocale(ELOCLUS);
		}
	else
		{
		test.Printf(_L("Change to ROM US Locale\n")); 	
		res=UserSvr::ChangeLocale(ELOCLUS_ROM);
		}
	test.Printf(_L("res=%d\n"),res);
	test(res==KErrNone);
	test(stat.Int() & EChangesLocale);
	res=notifier.Logon(stat);
	test(res==KErrNone);
	test(stat==KRequestPending);
	
	locale.Refresh();
	testUS(locale);
}
/**
This routine is used to convert between European digits and 
Arabic-Indic, Eastern Arabic-Indic, Devanagari or Thai digits 
based on existing digit type setting. 

@param aDes  Parameter to change
*/
void CResourceLoader::LanguageSpecificNumberConverter::Convert( TDes &aDes )
    {   
    TLocale locale;
    locale.Refresh();
    const TDigitType digitType = locale.DigitType();
    TChar toArea = 0x030;
    switch( digitType )
        {
        case EDigitTypeWestern:
        case EDigitTypeArabicIndic:
        case EDigitTypeEasternArabicIndic:
        case EDigitTypeDevanagari:
        case EDigitTypeThai:
            toArea = digitType;
            break;
        case EDigitTypeUnknown:
        case EDigitTypeAllTypes:
            return;
        }
    
    const TInt length = aDes.Length();
    for( TInt i = 0; i < length; i++ )
        {
        TChar character = aDes[i];
        TChar fromArea = NumberToBase( character );
        TChar::TBdCategory cat = character.GetBdCategory();
        switch( cat )
            {
            case TChar::EArabicNumber:
            case TChar::EEuropeanNumber:
                character += toArea;
                character -= fromArea;
                aDes[i] = TUint16( character );
                break;
            default: 
                break;
            }
        }
    }
Пример #5
0
LOCAL_C TInt E32TestLocale(TInt isrom)
{
	TInt r;
	TAny *LocaleAddr;
	TLocale locale;
	
	/* Setup the US Locale DLL and ensure the Locale got modified (testUS) */
	testChangeLocale(isrom);
 
	/* Now get a pointer to some data in the DLL. This will be used to move a
	** page from the dll 
	*/
	SLocaleLanguage localeLanguage;
	LocaleLanguageGet(localeLanguage);
	LocaleAddr = (TAny *) localeLanguage.iDateSuffixTable;
	test(LocaleAddr != NULL);

	RPageMove pagemove;
	r=pagemove.Open();
	test_KErrNone(r);

	r=pagemove.TryMovingLocaleDll(LocaleAddr);
	
	if (isrom == 0) 
		{
		test_KErrNone(r);
		}
	else
		{
		// When the locale is in rom it is in the unpaged part of rom and 
		// Epoc::LinearToPhysical() won't be able to find the address.
		test_Equal(KErrArgument, r)
		}

	test.Printf(_L("Locale Test: Page move done\n"));

	/* Test US again. The kernel should have cached the locale informaton, so this will not
	 * really be testing the pagmove.
	 */
	locale.Refresh();
	testUS(locale);
	
	/* Reload the Default Locale */
	test.Printf(_L("Locale Test: Change to UK Default\n"));
	r=UserSvr::ChangeLocale(ELOCL_DEFAULT);	
	test(r==KErrNone);
	locale.Refresh();
	testUK(locale);	

	/* This will ACTUALLY test the page which was moved by making the kernel reload the Locale
	 * information from the DLL. 
	 */
	if (isrom == 0) 
		{
		test.Printf(_L("RAM Locale Test: Change to US Again\n"));
		r=UserSvr::ChangeLocale(ELOCLUS);	
		}
	else
		{
		test.Printf(_L("ROM Locale Test: Change to US Again\n"));
		r=UserSvr::ChangeLocale(ELOCLUS_ROM);	
		}


	test(r==KErrNone);
	locale.Refresh();
	testUS(locale);

	/* Reset the Locale to the default */
	r=UserSvr::ChangeLocale(ELOCL_DEFAULT);	
	test(r==KErrNone);
	locale.Refresh();
	testUK(locale);	
	return(KErrNone);
}