tzservices/tzloc/src/TzLocalizer.cpp
changeset 81 676b6116ca93
parent 0 2e3d3ce01487
equal deleted inserted replaced
78:175a0d824084 81:676b6116ca93
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    22 #include "TzLocalizationDbAccessor.h"
    22 #include "TzLocalizationDbAccessor.h"
    23 #include "TzLocalizationResourceReader.h"
    23 #include "TzLocalizationResourceReader.h"
    24 #include "tzlocalizationuserdatareader.h"
    24 #include "tzlocalizationuserdatareader.h"
    25 #include <tzlocalizedtimezonerecord.h>
    25 #include <tzlocalizedtimezonerecord.h>
    26 #include <tzlocalizedcityrecord.h>
    26 #include <tzlocalizedcityrecord.h>
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "TzLocalizerTraces.h"
       
    30 #endif
       
    31 
    27 /**
    32 /**
    28 Allocates and constructs a new CTzLocalizer object.
    33 Allocates and constructs a new CTzLocalizer object.
    29 @return The newly created CTzLocalizer object.
    34 @return The newly created CTzLocalizer object.
    30 */
    35 */
    31 EXPORT_C CTzLocalizer* CTzLocalizer::NewL()
    36 EXPORT_C CTzLocalizer* CTzLocalizer::NewL()
    61 	iDataSource = ETzDataSourceSystem;
    66 	iDataSource = ETzDataSourceSystem;
    62 	}
    67 	}
    63 
    68 
    64 void CTzLocalizer::ConstructL()
    69 void CTzLocalizer::ConstructL()
    65 	{
    70 	{
       
    71     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_CONSTRUCTL_ENTRY, "CTzLocalizer::ConstructL Entry" );
       
    72     
    66 	User::LeaveIfError(iTzSession.Connect());
    73 	User::LeaveIfError(iTzSession.Connect());
    67 
    74 
    68 	iStaticDataReader = CTzLocalizationResourceReader::NewL();
    75 	iStaticDataReader = CTzLocalizationResourceReader::NewL();
    69    	iUserDataReader	= CTzLocalizationUserDataReader::NewL(iTzSession);
    76    	iUserDataReader	= CTzLocalizationUserDataReader::NewL(iTzSession);
    70 
    77 
    81 		// that the language of the strings in the cached zone DB is correct on
    88 		// that the language of the strings in the cached zone DB is correct on
    82 		// construction.
    89 		// construction.
    83 		UpdateFrequentlyUsedZonesL();
    90 		UpdateFrequentlyUsedZonesL();
    84 		}
    91 		}
    85 	SetDataSource(ETzDataSourceSystem);
    92 	SetDataSource(ETzDataSourceSystem);
       
    93 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_CONSTRUCTL_EXIT, "CTzLocalizer::ConstructL Exit" );
       
    94 	
    86 	}
    95 	}
    87 
    96 
    88 // Check if the DB needs upgrading
    97 // Check if the DB needs upgrading
    89 TBool CTzLocalizer::DbNeedsUpdatingL() const
    98 TBool CTzLocalizer::DbNeedsUpdatingL() const
    90     {
    99     {
   176 @return ETrue if the cached Zone DB table had to be prepared using the defaults,
   185 @return ETrue if the cached Zone DB table had to be prepared using the defaults,
   177 		EFalse if not.
   186 		EFalse if not.
   178 */
   187 */
   179 TBool CTzLocalizer::PrepareFrequentlyUsedZonesL()
   188 TBool CTzLocalizer::PrepareFrequentlyUsedZonesL()
   180 	{
   189 	{
       
   190     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_PREPAREFREQUENTLYUSEDZONESL_ENTRY, "CTzLocalizer::PrepareFrequentlyUsedZonesL Entry" );
       
   191     
   181 	CTzLocalizedTimeZoneArray* frequentlyUsedZones = CTzLocalizedTimeZoneArray::NewLC();
   192 	CTzLocalizedTimeZoneArray* frequentlyUsedZones = CTzLocalizedTimeZoneArray::NewLC();
   182 	CTzLocalizedCityArray* cachedCities = CTzLocalizedCityArray::NewLC();
   193 	CTzLocalizedCityArray* cachedCities = CTzLocalizedCityArray::NewLC();
   183 	TBool frequentlyUsedZonesNeedUpdating = EFalse;
   194 	TBool frequentlyUsedZonesNeedUpdating = EFalse;
   184 
   195 
   185 	// Loop to fill up the frequentlyUsedZones and cachedCities arrays to send to
   196 	// Loop to fill up the frequentlyUsedZones and cachedCities arrays to send to
   235 		WriteAllFrequentlyUsedZonesL(*frequentlyUsedZones, *cachedCities);
   246 		WriteAllFrequentlyUsedZonesL(*frequentlyUsedZones, *cachedCities);
   236 		}
   247 		}
   237 
   248 
   238 	CleanupStack::PopAndDestroy(cachedCities);
   249 	CleanupStack::PopAndDestroy(cachedCities);
   239 	CleanupStack::PopAndDestroy(frequentlyUsedZones);
   250 	CleanupStack::PopAndDestroy(frequentlyUsedZones);
       
   251 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_PREPAREFREQUENTLYUSEDZONESL_EXIT, "CTzLocalizer::PrepareFrequentlyUsedZonesL Exit;frequentlyUsedZonesNeedUpdating=%u", frequentlyUsedZonesNeedUpdating );
       
   252 	
   240 
   253 
   241 	return frequentlyUsedZonesNeedUpdating;
   254 	return frequentlyUsedZonesNeedUpdating;
   242 	}
   255 	}
   243 
   256 
   244 /**
   257 /**
   245 Updates the cached zone information in the persisted data writer with the
   258 Updates the cached zone information in the persisted data writer with the
   246 strings that are currently in static data.
   259 strings that are currently in static data.
   247 */
   260 */
   248 void CTzLocalizer::UpdateFrequentlyUsedZonesL()
   261 void CTzLocalizer::UpdateFrequentlyUsedZonesL()
   249 	{
   262 	{
       
   263     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_UPDATEFREQUENTLYUSEDZONESL_ENTRY, "CTzLocalizer::UpdateFrequentlyUsedZonesL Entry" );
       
   264     
   250 	CTzLocalizedTimeZoneArray* frequentlyUsedZones = CTzLocalizedTimeZoneArray::NewLC();
   265 	CTzLocalizedTimeZoneArray* frequentlyUsedZones = CTzLocalizedTimeZoneArray::NewLC();
   251 	CTzLocalizedCityArray* cachedCities = CTzLocalizedCityArray::NewLC();
   266 	CTzLocalizedCityArray* cachedCities = CTzLocalizedCityArray::NewLC();
   252 
   267 
   253 	for(TInt i = CTzLocalizedTimeZone::ECurrentZone; i < CTzLocalizedTimeZone::ECachedTimeZones; ++i)
   268 	for(TInt i = CTzLocalizedTimeZone::ECurrentZone; i < CTzLocalizedTimeZone::ECachedTimeZones; ++i)
   254 		{
   269 		{
   318 		}
   333 		}
   319 
   334 
   320 	WriteAllFrequentlyUsedZonesL(*frequentlyUsedZones,*cachedCities);
   335 	WriteAllFrequentlyUsedZonesL(*frequentlyUsedZones,*cachedCities);
   321 	CleanupStack::PopAndDestroy(cachedCities);
   336 	CleanupStack::PopAndDestroy(cachedCities);
   322 	CleanupStack::PopAndDestroy(frequentlyUsedZones);
   337 	CleanupStack::PopAndDestroy(frequentlyUsedZones);
       
   338 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_UPDATEFREQUENTLYUSEDZONESL_EXIT, "CTzLocalizer::UpdateFrequentlyUsedZonesL Exit" );
       
   339 	
   323 	}
   340 	}
   324 
   341 
   325 /**
   342 /**
   326 Get the localized default time zone for the given frequently used time zone.
   343 Get the localized default time zone for the given frequently used time zone.
   327 The default time zone for each of the possible frequently used time zones may be
   344 The default time zone for each of the possible frequently used time zones may be
   333 
   350 
   334 @return The localized default time zone for the given frequently used time zone.
   351 @return The localized default time zone for the given frequently used time zone.
   335 */
   352 */
   336 CTzLocalizedTimeZone* CTzLocalizer::GetFrequentlyUsedDefaultZoneL(CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFreqUsedZone)
   353 CTzLocalizedTimeZone* CTzLocalizer::GetFrequentlyUsedDefaultZoneL(CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFreqUsedZone)
   337 	{
   354 	{
       
   355     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETFREQUENTLYUSEDDEFAULTZONEL_ENTRY, "CTzLocalizer::GetFrequentlyUsedDefaultZoneL Entry;aFreqUsedZone=%u", aFreqUsedZone );
       
   356     
   338 	// Assume that we will not find the key in the repository or that we do find
   357 	// Assume that we will not find the key in the repository or that we do find
   339 	// the key but it has no value.  If either of these scenarios is true then
   358 	// the key but it has no value.  If either of these scenarios is true then
   340 	// we will use the time zone identifier recorded in the resource file for
   359 	// we will use the time zone identifier recorded in the resource file for
   341 	// the default time zone.
   360 	// the default time zone.
   342 	TBool readFreqUsedZoneFromRscFile = ETrue;
   361 	TBool readFreqUsedZoneFromRscFile = ETrue;
   367 
   386 
   368 	if(readFreqUsedZoneFromRscFile)
   387 	if(readFreqUsedZoneFromRscFile)
   369 		{
   388 		{
   370 		defaultTimeZone = iStaticDataReader->ReadFrequentlyUsedZoneL(aFreqUsedZone);
   389 		defaultTimeZone = iStaticDataReader->ReadFrequentlyUsedZoneL(aFreqUsedZone);
   371 		}
   390 		}
       
   391 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETFREQUENTLYUSEDDEFAULTZONEL_EXIT, "CTzLocalizer::GetFrequentlyUsedDefaultZoneL Exit" );
   372 
   392 
   373 	return defaultTimeZone;
   393 	return defaultTimeZone;
   374 	}
   394 	}
   375 
   395 
   376 /**
   396 /**
   463 @param aSortOrder Specifies the sort order of the returned array.
   483 @param aSortOrder Specifies the sort order of the returned array.
   464 @return Array of all available localizable time zones.
   484 @return Array of all available localizable time zones.
   465 */
   485 */
   466 EXPORT_C CTzLocalizedTimeZoneArray* CTzLocalizer::GetAllTimeZonesL(const TTzSortOrder aSortOrder)
   486 EXPORT_C CTzLocalizedTimeZoneArray* CTzLocalizer::GetAllTimeZonesL(const TTzSortOrder aSortOrder)
   467 	{
   487 	{
       
   488     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETALLTIMEZONESL_ENTRY, "CTzLocalizer::GetAllTimeZonesL Entry;aSortOrder=%u", aSortOrder );
       
   489     
   468 	CTzLocalizedTimeZoneArray* allTimeZones = CTzLocalizedTimeZoneArray::NewLC();
   490 	CTzLocalizedTimeZoneArray* allTimeZones = CTzLocalizedTimeZoneArray::NewLC();
   469 	if(iDataSource&ETzDataSourceSystem)
   491 	if(iDataSource&ETzDataSourceSystem)
   470 		{
   492 		{
   471 		iStaticDataReader->ReadAllTimeZonesL(*allTimeZones);
   493 		iStaticDataReader->ReadAllTimeZonesL(*allTimeZones);
   472 		}
   494 		}
   486 		TLinearOrder<CTzLocalizedTimeZone> sortOrder(TimeZoneSortOrderL(aSortOrder));
   508 		TLinearOrder<CTzLocalizedTimeZone> sortOrder(TimeZoneSortOrderL(aSortOrder));
   487 		allTimeZones->Sort(sortOrder);
   509 		allTimeZones->Sort(sortOrder);
   488 		}
   510 		}
   489 
   511 
   490 	CleanupStack::Pop(allTimeZones);
   512 	CleanupStack::Pop(allTimeZones);
       
   513 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETALLTIMEZONESL_EXIT, "CTzLocalizer::GetAllTimeZonesL Exit" );
       
   514 	
   491 
   515 
   492 	return allTimeZones;
   516 	return allTimeZones;
   493 	}
   517 	}
   494 
   518 
   495 /**
   519 /**
   543 ETzAlphaNameAscending, or ETzAlphaNameDescending.
   567 ETzAlphaNameAscending, or ETzAlphaNameDescending.
   544 @return Pointer to the array of cities.
   568 @return Pointer to the array of cities.
   545 */
   569 */
   546 EXPORT_C CTzLocalizedCityArray* CTzLocalizer::GetCitiesL(const TTzSortOrder aSortOrder)
   570 EXPORT_C CTzLocalizedCityArray* CTzLocalizer::GetCitiesL(const TTzSortOrder aSortOrder)
   547 	{
   571 	{
       
   572     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETCITIESL_ENTRY, "CTzLocalizer::GetCitiesL Entry;aSortOrder=%u", aSortOrder );
       
   573     
   548 	//Create an empty city array and retrieve all cities
   574 	//Create an empty city array and retrieve all cities
   549 	CTzLocalizedCityArray* cities = CTzLocalizedCityArray::NewLC();
   575 	CTzLocalizedCityArray* cities = CTzLocalizedCityArray::NewLC();
   550 	if(iDataSource&ETzDataSourceSystem)
   576 	if(iDataSource&ETzDataSourceSystem)
   551 		{
   577 		{
   552 		iStaticDataReader->ReadCitiesL(*cities);
   578 		iStaticDataReader->ReadCitiesL(*cities);
   572 		TLinearOrder<CTzLocalizedCity> sortOrder(CitySortOrderL(aSortOrder));
   598 		TLinearOrder<CTzLocalizedCity> sortOrder(CitySortOrderL(aSortOrder));
   573 		cities->Sort(sortOrder);
   599 		cities->Sort(sortOrder);
   574 		}
   600 		}
   575 
   601 
   576 	CleanupStack::Pop(cities);
   602 	CleanupStack::Pop(cities);
       
   603 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETCITIESL_EXIT, "CTzLocalizer::GetCitiesL Exit" );
       
   604 	
   577 	return cities;
   605 	return cities;
   578 	}
   606 	}
   579 
   607 
   580 /**
   608 /**
   581 Gets all the cities defined in the static and persisted data that belong
   609 Gets all the cities defined in the static and persisted data that belong
   589 @leave KErrArgument An invalid sort order is specified.
   617 @leave KErrArgument An invalid sort order is specified.
   590 @return A pointer to the array of cities.
   618 @return A pointer to the array of cities.
   591 */
   619 */
   592 EXPORT_C CTzLocalizedCityArray* CTzLocalizer::GetCitiesL(TInt aTimeZoneId, const TTzSortOrder aSortOrder)
   620 EXPORT_C CTzLocalizedCityArray* CTzLocalizer::GetCitiesL(TInt aTimeZoneId, const TTzSortOrder aSortOrder)
   593 	{
   621 	{
       
   622     OstTraceDefExt2( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZLOCALIZER_GETCITIESL_ENTRY_OVERLOADED, "CTzLocalizer::GetCitiesL Entry;aTimeZoneId=%d;aSortOrder=%u", aTimeZoneId, aSortOrder );
       
   623     
   594 	CTzLocalizedCityArray* cities = CTzLocalizedCityArray::NewLC();
   624 	CTzLocalizedCityArray* cities = CTzLocalizedCityArray::NewLC();
   595 	ReadCitiesL(*cities, aTimeZoneId, ETrue);
   625 	ReadCitiesL(*cities, aTimeZoneId, ETrue);
   596 
   626 
   597 	RPointerArray<CTzLocalizedCityRecord> cityRecords;
   627 	RPointerArray<CTzLocalizedCityRecord> cityRecords;
   598 	CleanupStack::PushL(TCleanupItem(CleanupCityPointerArray, &cityRecords));
   628 	CleanupStack::PushL(TCleanupItem(CleanupCityPointerArray, &cityRecords));
   611 		{
   641 		{
   612 		User::Leave(KErrArgument);
   642 		User::Leave(KErrArgument);
   613 		}
   643 		}
   614 
   644 
   615 	CleanupStack::Pop(cities);
   645 	CleanupStack::Pop(cities);
       
   646 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETCITIESL_EXIT2, "CTzLocalizer::GetCitiesL Exit" );
       
   647 	
   616 
   648 
   617 	return cities;
   649 	return cities;
   618 	}
   650 	}
   619 
   651 
   620 /**
   652 /**
   660 @leave KErrArgument An invalid sort order is asked for.
   692 @leave KErrArgument An invalid sort order is asked for.
   661 */
   693 */
   662 void CTzLocalizer::GetCitiesL(CTzLocalizedCityArray& aCities, const TTzLocalizedId& aLocalizedId,
   694 void CTzLocalizer::GetCitiesL(CTzLocalizedCityArray& aCities, const TTzLocalizedId& aLocalizedId,
   663 		TBool aUseDataSource, const TTzSortOrder aSortOrder)
   695 		TBool aUseDataSource, const TTzSortOrder aSortOrder)
   664 	{
   696 	{
       
   697     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETCITIESL_ENTRY_OVERLOADED2, "CTzLocalizer::GetCitiesL Entry;aUseDataSource=%u;aSortOrder=%u", aUseDataSource, aSortOrder );
       
   698     
   665 	ReadCitiesL(aCities, aLocalizedId.TimeZoneId(), aUseDataSource);
   699 	ReadCitiesL(aCities, aLocalizedId.TimeZoneId(), aUseDataSource);
   666 
   700 
   667 	RPointerArray<CTzLocalizedCityRecord> cityRecords;
   701 	RPointerArray<CTzLocalizedCityRecord> cityRecords;
   668 	CleanupStack::PushL(TCleanupItem(CleanupCityPointerArray, &cityRecords));
   702 	CleanupStack::PushL(TCleanupItem(CleanupCityPointerArray, &cityRecords));
   669 	iTzSession.LocalizationReadCitiesL(cityRecords, aLocalizedId.TimeZoneId());
   703 	iTzSession.LocalizationReadCitiesL(cityRecords, aLocalizedId.TimeZoneId());
   679 		}
   713 		}
   680 	else if(aSortOrder != ETzUnsorted)
   714 	else if(aSortOrder != ETzUnsorted)
   681 		{
   715 		{
   682 		User::Leave(KErrArgument);
   716 		User::Leave(KErrArgument);
   683 		}
   717 		}
       
   718 	OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZLOCALIZER_GETCITIESL_EXIT3, "CTzLocalizer::GetCitiesL Exit" );
       
   719 	
   684 	}
   720 	}
   685 
   721 
   686 /**
   722 /**
   687 Creates a user defined city, specifying the time zone and
   723 Creates a user defined city, specifying the time zone and
   688 optionally the group to which it belongs.
   724 optionally the group to which it belongs.
   695 @leave KErrNotFound aTimeZoneId or aGroupId is not found.
   731 @leave KErrNotFound aTimeZoneId or aGroupId is not found.
   696 @leave KErrArgument aGroupId is invalid
   732 @leave KErrArgument aGroupId is invalid
   697 */
   733 */
   698 EXPORT_C CTzLocalizedCity* CTzLocalizer::AddCityL(TInt aTimeZoneId,const TDesC& aCityName, TInt aGroupId)
   734 EXPORT_C CTzLocalizedCity* CTzLocalizer::AddCityL(TInt aTimeZoneId,const TDesC& aCityName, TInt aGroupId)
   699 	{
   735 	{
       
   736     OstTraceDefExt3( OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_ADDCITYL_ENTRY, "CTzLocalizer::AddCityL Entry;aTimeZoneId=%d;aCityName=%S;aGroupId=%d", aTimeZoneId, aCityName, aGroupId );
       
   737     
   700 	//Check that aGroupId is a valid TUint8 and leave if not.
   738 	//Check that aGroupId is a valid TUint8 and leave if not.
   701 	//Group number > 255 is not supported
   739 	//Group number > 255 is not supported
   702 	__ASSERT_ALWAYS(aGroupId >= 0 && aGroupId <256 , User::Leave(KErrArgument));
   740 	__ASSERT_ALWAYS(aGroupId >= 0 && aGroupId <256 , User::Leave(KErrArgument));
   703 
   741 
   704 	// Check that the group exists - this code will leave with
   742 	// Check that the group exists - this code will leave with
   734 	//WriteCityL checks to see if a city with the same Time Zone ID
   772 	//WriteCityL checks to see if a city with the same Time Zone ID
   735 	//is already in the persisted cities, while adding the city.
   773 	//is already in the persisted cities, while adding the city.
   736 	iTzSession.LocalizationWriteCityL(newCity->Name(), (TInt)newCity->TimeZoneId(), newCity->GroupId(),
   774 	iTzSession.LocalizationWriteCityL(newCity->Name(), (TInt)newCity->TimeZoneId(), newCity->GroupId(),
   737 			newCity->TzLocalizedId().ResourceId());
   775 			newCity->TzLocalizedId().ResourceId());
   738 	CleanupStack::Pop(newCity);
   776 	CleanupStack::Pop(newCity);
       
   777 	OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZLOCALIZER_ADDCITYL_EXIT, "CTzLocalizer::AddCityL Exit" );
       
   778 	
   739 	return newCity;
   779 	return newCity;
   740 	}
   780 	}
   741 
   781 
   742 /**
   782 /**
   743 Removes a city from the user defined city collection.
   783 Removes a city from the user defined city collection.
   752 		iTzSession.LocalizationDeleteCityL(aCity->Name(), aCity->TimeZoneId());
   792 		iTzSession.LocalizationDeleteCityL(aCity->Name(), aCity->TimeZoneId());
   753 		CleanupStack::PopAndDestroy(aCity);
   793 		CleanupStack::PopAndDestroy(aCity);
   754 		}
   794 		}
   755 	else
   795 	else
   756 		{
   796 		{
       
   797 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_ERROR, CTZLOCALIZER_REMOVECITYL, "CTzLocalizer::RemoveCityL:Error:Invalid city" );
       
   798 	    
   757 		User::Leave(KErrArgument);
   799 		User::Leave(KErrArgument);
   758 		}
   800 		}
   759 	}
   801 	}
   760 
   802 
   761 /**
   803 /**
   828 @return Pointer to the array of cities.
   870 @return Pointer to the array of cities.
   829 @leave KErrArgument aGroupId is invalid
   871 @leave KErrArgument aGroupId is invalid
   830 */
   872 */
   831 EXPORT_C CTzLocalizedCityArray* CTzLocalizer::GetCitiesInGroupL(TInt aGroupId,const TTzSortOrder aSortOrder)
   873 EXPORT_C CTzLocalizedCityArray* CTzLocalizer::GetCitiesInGroupL(TInt aGroupId,const TTzSortOrder aSortOrder)
   832 	{
   874 	{
       
   875     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETCITIESINGROUPL_ENTRY, "CTzLocalizer::GetCitiesInGroupL Entry;aGroupId=%d;aSortOrder=%u", aGroupId, aSortOrder );
       
   876     
   833 	//Check that aGroupId is a valid TUint8 and leave if not.
   877 	//Check that aGroupId is a valid TUint8 and leave if not.
   834 	//Group number > 255 is not supported
   878 	//Group number > 255 is not supported
   835 	__ASSERT_ALWAYS(aGroupId >= 0 && aGroupId <256 , User::Leave(KErrArgument));
   879 	__ASSERT_ALWAYS(aGroupId >= 0 && aGroupId <256 , User::Leave(KErrArgument));
   836 
   880 
   837 	CTzLocalizedCityArray* cities = CTzLocalizedCityArray::NewLC();
   881 	CTzLocalizedCityArray* cities = CTzLocalizedCityArray::NewLC();
   860 		{
   904 		{
   861 		TLinearOrder<CTzLocalizedCity> sortOrder(CitySortOrderL(aSortOrder));
   905 		TLinearOrder<CTzLocalizedCity> sortOrder(CitySortOrderL(aSortOrder));
   862 		cities->Sort(sortOrder);
   906 		cities->Sort(sortOrder);
   863 		}
   907 		}
   864 	CleanupStack::Pop(cities);
   908 	CleanupStack::Pop(cities);
       
   909 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETCITIESINGROUPL_EXIT, "CTzLocalizer::GetCitiesInGroupL Exit" );
       
   910 	
   865 	return cities;
   911 	return cities;
   866 	}
   912 	}
   867 
   913 
   868 /**
   914 /**
   869 Returns all cities defined in the static and persisted data that are members
   915 Returns all cities defined in the static and persisted data that are members
   905 @param aFrequentlyUsedZone Identifies the cached zone to return.
   951 @param aFrequentlyUsedZone Identifies the cached zone to return.
   906 @return The cached zone.
   952 @return The cached zone.
   907 */
   953 */
   908 EXPORT_C CTzLocalizedTimeZone* CTzLocalizer::GetFrequentlyUsedZoneL(const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone)
   954 EXPORT_C CTzLocalizedTimeZone* CTzLocalizer::GetFrequentlyUsedZoneL(const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone)
   909 	{
   955 	{
       
   956     OstTraceDef1( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZLOCALIZER_GETFREQUENTLYUSEDZONEL_ENTRY, "CTzLocalizer::GetFrequentlyUsedZoneL Entry;aFrequentlyUsedZone=%u", aFrequentlyUsedZone );
       
   957     
   910 	CTzLocalizedTimeZone* timeZone;
   958 	CTzLocalizedTimeZone* timeZone;
   911 
   959 
   912 	if (aFrequentlyUsedZone == CTzLocalizedTimeZone::ECurrentZone)
   960 	if (aFrequentlyUsedZone == CTzLocalizedTimeZone::ECurrentZone)
   913 		{
   961 		{
   914 		//Get cached current zone
   962 		//Get cached current zone
   949 		CTzLocalizedTimeZoneRecord* timeZoneRecord = iTzSession.LocalizationReadFrequentlyUsedZoneL(aFrequentlyUsedZone);
   997 		CTzLocalizedTimeZoneRecord* timeZoneRecord = iTzSession.LocalizationReadFrequentlyUsedZoneL(aFrequentlyUsedZone);
   950 		CleanupStack::PushL(timeZoneRecord);
   998 		CleanupStack::PushL(timeZoneRecord);
   951 		timeZone = CreateTimeZoneL(*timeZoneRecord);
   999 		timeZone = CreateTimeZoneL(*timeZoneRecord);
   952 		CleanupStack::PopAndDestroy(timeZoneRecord);
  1000 		CleanupStack::PopAndDestroy(timeZoneRecord);
   953 		}
  1001 		}
       
  1002 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETFREQUENTLYUSEDZONEL_EXIT, "CTzLocalizer::GetFrequentlyUsedZoneL Exit" );
   954 
  1003 
   955 	return timeZone;
  1004 	return timeZone;
   956 	}
  1005 	}
   957 
  1006 
   958 /**
  1007 /**
   960 server (app-services/Tz).
  1009 server (app-services/Tz).
   961 @return The integer time zone ID according to the time zone server.
  1010 @return The integer time zone ID according to the time zone server.
   962 */
  1011 */
   963 TInt CTzLocalizer::GetTimeZoneIdFromTzServerL()
  1012 TInt CTzLocalizer::GetTimeZoneIdFromTzServerL()
   964 	{
  1013 	{
       
  1014     OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZLOCALIZER_GETTIMEZONEIDFROMTZSERVERL_ENTRY, "CTzLocalizer::GetTimeZoneIdFromTzServerL Entry" );
       
  1015     
   965 	// Get current time zone using the current CTzId from the time zone server
  1016 	// Get current time zone using the current CTzId from the time zone server
   966 	CTzId* currentCTzId = iTzSession.GetTimeZoneIdL();
  1017 	CTzId* currentCTzId = iTzSession.GetTimeZoneIdL();
   967 	CleanupStack::PushL(currentCTzId);
  1018 	CleanupStack::PushL(currentCTzId);
   968 
  1019 
   969 	TUint timeZoneIdInt = currentCTzId->TimeZoneNumericID();
  1020 	TUint timeZoneIdInt = currentCTzId->TimeZoneNumericID();
   980 		CTzLocalizedTimeZone* homeZone = iStaticDataReader->ReadFrequentlyUsedZoneL(CTzLocalizedTimeZone::EHomeZone);
  1031 		CTzLocalizedTimeZone* homeZone = iStaticDataReader->ReadFrequentlyUsedZoneL(CTzLocalizedTimeZone::EHomeZone);
   981 		CleanupStack::PushL(homeZone);
  1032 		CleanupStack::PushL(homeZone);
   982 		timeZoneIdInt = homeZone->TimeZoneId();
  1033 		timeZoneIdInt = homeZone->TimeZoneId();
   983 		CleanupStack::PopAndDestroy(homeZone);
  1034 		CleanupStack::PopAndDestroy(homeZone);
   984 		}
  1035 		}
       
  1036 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETTIMEZONEIDFROMTZSERVERL_EXIT, "CTzLocalizer::GetTimeZoneIdFromTzServerL Exit;timeZoneIdInt=%u", timeZoneIdInt );
   985 
  1037 
   986 	return timeZoneIdInt;
  1038 	return timeZoneIdInt;
   987 	}
  1039 	}
   988 
  1040 
   989 /**
  1041 /**
   994 @param aFrequentlyUsedZone Indicates one of the five cached zones.
  1046 @param aFrequentlyUsedZone Indicates one of the five cached zones.
   995 @return The city used to set the cached zone.
  1047 @return The city used to set the cached zone.
   996 */
  1048 */
   997 EXPORT_C CTzLocalizedCity* CTzLocalizer::GetFrequentlyUsedZoneCityL(const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone)
  1049 EXPORT_C CTzLocalizedCity* CTzLocalizer::GetFrequentlyUsedZoneCityL(const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone)
   998 	{
  1050 	{
       
  1051     OstTraceDef1(   OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETFREQUENTLYUSEDZONECITYL_ENTRY, "CTzLocalizer::GetFrequentlyUsedZoneCityL Entry;aFrequentlyUsedZone=%u", aFrequentlyUsedZone );
       
  1052     
   999 	CTzLocalizedCityRecord* cityRecord = iTzSession.LocalizationReadCachedTimeZoneCityL(aFrequentlyUsedZone);
  1053 	CTzLocalizedCityRecord* cityRecord = iTzSession.LocalizationReadCachedTimeZoneCityL(aFrequentlyUsedZone);
  1000 	CleanupStack::PushL(cityRecord);
  1054 	CleanupStack::PushL(cityRecord);
  1001 	CTzLocalizedCity* city = CreateCityL(*cityRecord);
  1055 	CTzLocalizedCity* city = CreateCityL(*cityRecord);
  1002 	CleanupStack::PopAndDestroy(cityRecord);
  1056 	CleanupStack::PopAndDestroy(cityRecord);
  1003 
  1057 
  1044 				CleanupStack::Pop(city);
  1098 				CleanupStack::Pop(city);
  1045 				}
  1099 				}
  1046 			}
  1100 			}
  1047 
  1101 
  1048 		}
  1102 		}
       
  1103 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETFREQUENTLYUSEDZONECITYL_EXIT, "CTzLocalizer::GetFrequentlyUsedZoneCityL Exit" );
       
  1104 	
  1049 
  1105 
  1050 	return city;
  1106 	return city;
  1051 	}
  1107 	}
  1052 
  1108 
  1053 /**
  1109 /**
  1173 @internalTechnology
  1229 @internalTechnology
  1174 */
  1230 */
  1175 template <class T>
  1231 template <class T>
  1176 void CTzLocalizer::PrepareForUTCSortL(T& aArray)
  1232 void CTzLocalizer::PrepareForUTCSortL(T& aArray)
  1177 	{
  1233 	{
       
  1234     
  1178 	//Prepare an array of timezone IDs to give to the time zone server
  1235 	//Prepare an array of timezone IDs to give to the time zone server
  1179 	RArray<TInt> timeZoneIds;
  1236 	RArray<TInt> timeZoneIds;
  1180 	CleanupClosePushL(timeZoneIds);
  1237 	CleanupClosePushL(timeZoneIds);
  1181 	TInt i;
  1238 	TInt i;
  1182 	TInt count = aArray.Count();
  1239 	TInt count = aArray.Count();
  1223 NULL is returned.
  1280 NULL is returned.
  1224 @leave KErrNotFound The specified time zone ID does not exist.
  1281 @leave KErrNotFound The specified time zone ID does not exist.
  1225 */
  1282 */
  1226 EXPORT_C CTzLocalizedCity* CTzLocalizer::FindCityByNameL(const TDesC& aCityName, const TInt aTimeZoneId)
  1283 EXPORT_C CTzLocalizedCity* CTzLocalizer::FindCityByNameL(const TDesC& aCityName, const TInt aTimeZoneId)
  1227 	{
  1284 	{
       
  1285     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_FINDCITYBYNAMEL_ENTRY, "CTzLocalizer::FindCityByNameL Entry;aCityName=%S;aTimeZoneId=%d", aCityName, aTimeZoneId );
       
  1286     
  1228 	CTzLocalizedCity* foundCity;
  1287 	CTzLocalizedCity* foundCity;
  1229 	//Create a dummy city for the search
  1288 	//Create a dummy city for the search
  1230 	CTzLocalizedCity* aCity = CTzLocalizedCity::NewLC(aCityName,TTzLocalizedId((TUint16)aTimeZoneId,0),0);
  1289 	CTzLocalizedCity* aCity = CTzLocalizedCity::NewLC(aCityName,TTzLocalizedId((TUint16)aTimeZoneId,0),0);
  1231 
  1290 
  1232 	CTzLocalizedCityArray* citiesToSearch = NULL;
  1291 	CTzLocalizedCityArray* citiesToSearch = NULL;
  1260 
  1319 
  1261 	CleanupStack::PopAndDestroy(aCity);
  1320 	CleanupStack::PopAndDestroy(aCity);
  1262 
  1321 
  1263 	delete citiesToSearch;
  1322 	delete citiesToSearch;
  1264 	citiesToSearch = NULL;
  1323 	citiesToSearch = NULL;
       
  1324 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_FINDCITYBYNAMEL_EXIT, "CTzLocalizer::FindCityByNameL Exit" );
  1265 
  1325 
  1266 	return foundCity;
  1326 	return foundCity;
  1267 	}
  1327 	}
  1268 /**
  1328 /**
  1269 Searches for a time zone with the specified name.
  1329 Searches for a time zone with the specified name.
  1273 The calling function takes ownership of the returned pointer.
  1333 The calling function takes ownership of the returned pointer.
  1274 If the search string is not found, NULL is returned.
  1334 If the search string is not found, NULL is returned.
  1275 */
  1335 */
  1276 EXPORT_C CTzLocalizedTimeZone* CTzLocalizer::FindTimeZoneByNameL(const TDesC& aTimeZoneName)
  1336 EXPORT_C CTzLocalizedTimeZone* CTzLocalizer::FindTimeZoneByNameL(const TDesC& aTimeZoneName)
  1277 	{
  1337 	{
       
  1338     OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_FINDTIMEZONEBYNAMEL_ENTRY, "CTzLocalizer::FindTimeZoneByNameL Entry;aTimeZoneName=%S", aTimeZoneName );
       
  1339     
  1278 	CTzLocalizedTimeZone* foundTimeZone;
  1340 	CTzLocalizedTimeZone* foundTimeZone;
  1279 	//Create a dummy time zone for the search
  1341 	//Create a dummy time zone for the search
  1280 	TTzLocalizedId id(0, 0);
  1342 	TTzLocalizedId id(0, 0);
  1281 	CTzLocalizedTimeZone* timeZone = CTzLocalizedTimeZone::NewLC(id,aTimeZoneName,aTimeZoneName,aTimeZoneName,aTimeZoneName);
  1343 	CTzLocalizedTimeZone* timeZone = CTzLocalizedTimeZone::NewLC(id,aTimeZoneName,aTimeZoneName,aTimeZoneName,aTimeZoneName);
  1282 	//Get all the time zones
  1344 	//Get all the time zones
  1298 
  1360 
  1299 	CleanupStack::PopAndDestroy(timeZone);
  1361 	CleanupStack::PopAndDestroy(timeZone);
  1300 
  1362 
  1301 	delete allTimeZones;
  1363 	delete allTimeZones;
  1302 	allTimeZones = NULL;
  1364 	allTimeZones = NULL;
       
  1365 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_FINDTIMEZONEBYNAMEL_EXIT, "CTzLocalizer::FindTimeZoneByNameL Exit" );
  1303 
  1366 
  1304 	return foundTimeZone;
  1367 	return foundTimeZone;
  1305 	}
  1368 	}
  1306 
  1369 
  1307 /**
  1370 /**
  1311 The calling function takes ownership of the returned pointer.
  1374 The calling function takes ownership of the returned pointer.
  1312 If the search string is not found, NULL is returned.
  1375 If the search string is not found, NULL is returned.
  1313 */
  1376 */
  1314 EXPORT_C CTzLocalizedCityGroup* CTzLocalizer::FindCityGroupByNameL(const TDesC& aCityGroupName)
  1377 EXPORT_C CTzLocalizedCityGroup* CTzLocalizer::FindCityGroupByNameL(const TDesC& aCityGroupName)
  1315 	{
  1378 	{
       
  1379     OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_FINDCITYGROUPBYNAMEL_ENTRY, "CTzLocalizer::FindCityGroupByNameL Entry;aCityGroupName=%S", aCityGroupName );
       
  1380     
  1316 	CTzLocalizedCityGroup* foundCityGroup;
  1381 	CTzLocalizedCityGroup* foundCityGroup;
  1317 	//Create a dummy city group for the search
  1382 	//Create a dummy city group for the search
  1318 	CTzLocalizedCityGroup* aCityGroup = CTzLocalizedCityGroup::NewLC(aCityGroupName,0);
  1383 	CTzLocalizedCityGroup* aCityGroup = CTzLocalizedCityGroup::NewLC(aCityGroupName,0);
  1319 	//Get all the city groups
  1384 	//Get all the city groups
  1320 	CTzLocalizedCityGroupArray* allCityGroups = GetAllCityGroupsL();
  1385 	CTzLocalizedCityGroupArray* allCityGroups = GetAllCityGroupsL();
  1335 
  1400 
  1336 	CleanupStack::PopAndDestroy(aCityGroup);
  1401 	CleanupStack::PopAndDestroy(aCityGroup);
  1337 
  1402 
  1338 	delete allCityGroups;
  1403 	delete allCityGroups;
  1339 	allCityGroups = NULL;
  1404 	allCityGroups = NULL;
       
  1405 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_FINDCITYGROUPBYNAMEL_EXIT, "CTzLocalizer::FindCityGroupByNameL Exit" );
  1340 
  1406 
  1341 	return foundCityGroup;
  1407 	return foundCityGroup;
  1342 	}
  1408 	}
  1343 
  1409 
  1344 /**
  1410 /**
  1377 as all elements in the returned array will have the same UTC offset.
  1443 as all elements in the returned array will have the same UTC offset.
  1378 @return Pointer to the array of cities.
  1444 @return Pointer to the array of cities.
  1379 */
  1445 */
  1380 EXPORT_C CTzLocalizedCityArray* CTzLocalizer::GetCitiesWithUTCOffsetL(TInt aUTCOffsetInMinutes, const TTzSortOrder aSortOrder)
  1446 EXPORT_C CTzLocalizedCityArray* CTzLocalizer::GetCitiesWithUTCOffsetL(TInt aUTCOffsetInMinutes, const TTzSortOrder aSortOrder)
  1381 	{
  1447 	{
       
  1448     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETCITIESWITHUTCOFFSETL_ENTRY, "CTzLocalizer::GetCitiesWithUTCOffsetL Entry;aUTCOffsetInMinutes=%d;aSortOrder=%u", aUTCOffsetInMinutes, aSortOrder );
       
  1449     
  1382 	//Fetch all the cities sorted by UTC offset
  1450 	//Fetch all the cities sorted by UTC offset
  1383 	CTzLocalizedCityArray* allCities = GetCitiesL(ETzUTCAscending);
  1451 	CTzLocalizedCityArray* allCities = GetCitiesL(ETzUTCAscending);
  1384 	TInt count = allCities->Count();
  1452 	TInt count = allCities->Count();
  1385 
  1453 
  1386 	CTzLocalizedCity* city;
  1454 	CTzLocalizedCity* city;
  1398 	if ((aSortOrder == ETzAlphaNameAscending) | (aSortOrder == ETzAlphaNameDescending))
  1466 	if ((aSortOrder == ETzAlphaNameAscending) | (aSortOrder == ETzAlphaNameDescending))
  1399 		{
  1467 		{
  1400 		TLinearOrder<CTzLocalizedCity> sortOrder(CitySortOrderL(aSortOrder));
  1468 		TLinearOrder<CTzLocalizedCity> sortOrder(CitySortOrderL(aSortOrder));
  1401 		allCities->Sort(sortOrder);
  1469 		allCities->Sort(sortOrder);
  1402 		}
  1470 		}
       
  1471 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETCITIESWITHUTCOFFSETL_EXIT, "CTzLocalizer::GetCitiesWithUTCOffsetL Exit" );
  1403 
  1472 
  1404 	return allCities;
  1473 	return allCities;
  1405 	}
  1474 	}
  1406 /**
  1475 /**
  1407 Returns all the time zones defined in the static data that have
  1476 Returns all the time zones defined in the static data that have
  1413 as all elements in the returned array will have the same UTC offset.
  1482 as all elements in the returned array will have the same UTC offset.
  1414 @return Pointer to the array of time zones.
  1483 @return Pointer to the array of time zones.
  1415 */
  1484 */
  1416 EXPORT_C CTzLocalizedTimeZoneArray* CTzLocalizer::GetTimeZonesWithUTCOffsetL(TInt aUTCOffsetInMinutes, const TTzSortOrder aSortOrder)
  1485 EXPORT_C CTzLocalizedTimeZoneArray* CTzLocalizer::GetTimeZonesWithUTCOffsetL(TInt aUTCOffsetInMinutes, const TTzSortOrder aSortOrder)
  1417 	{
  1486 	{
       
  1487     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETTIMEZONESWITHUTCOFFSETL_ENTRY, "CTzLocalizer::GetTimeZonesWithUTCOffsetL Entry;aUTCOffsetInMinutes=%d;aSortOrder=%u", aUTCOffsetInMinutes, aSortOrder );
       
  1488     
  1418 	//Fetch all the time zones sorted by UTC offset
  1489 	//Fetch all the time zones sorted by UTC offset
  1419 	CTzLocalizedTimeZoneArray* allTimeZones = GetAllTimeZonesL(ETzUTCAscending);
  1490 	CTzLocalizedTimeZoneArray* allTimeZones = GetAllTimeZonesL(ETzUTCAscending);
  1420 	TInt count = allTimeZones->Count();
  1491 	TInt count = allTimeZones->Count();
  1421 
  1492 
  1422 	CTzLocalizedTimeZone* timeZone;
  1493 	CTzLocalizedTimeZone* timeZone;
  1434 	if ((aSortOrder != ETzAlphaNameAscending) && (aSortOrder > ETzUTCDescending))
  1505 	if ((aSortOrder != ETzAlphaNameAscending) && (aSortOrder > ETzUTCDescending))
  1435 		{
  1506 		{
  1436 		TLinearOrder<CTzLocalizedTimeZone> sortOrder(TimeZoneSortOrderL(aSortOrder));
  1507 		TLinearOrder<CTzLocalizedTimeZone> sortOrder(TimeZoneSortOrderL(aSortOrder));
  1437 		allTimeZones->Sort(sortOrder);
  1508 		allTimeZones->Sort(sortOrder);
  1438 		}
  1509 		}
       
  1510 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_GETTIMEZONESWITHUTCOFFSETL_EXIT, "CTzLocalizer::GetTimeZonesWithUTCOffsetL Exit" );
       
  1511 	
  1439 	return allTimeZones;
  1512 	return allTimeZones;
  1440 	}
  1513 	}
  1441 /**
  1514 /**
  1442 Gets the correct TLinearOrder to sort by.
  1515 Gets the correct TLinearOrder to sort by.
  1443 @param aSortOrder
  1516 @param aSortOrder
  1577 @param aDataSource A data source flag
  1650 @param aDataSource A data source flag
  1578 @return Return ETrue if the city has been found, otherwise EFalse.
  1651 @return Return ETrue if the city has been found, otherwise EFalse.
  1579  */
  1652  */
  1580 TBool CTzLocalizer::FindCityAndSetCityIndexL(CTzLocalizedCity& aLocalizedCity, TTzLocalizerDataSource aDataSource)
  1653 TBool CTzLocalizer::FindCityAndSetCityIndexL(CTzLocalizedCity& aLocalizedCity, TTzLocalizerDataSource aDataSource)
  1581 	{
  1654 	{
       
  1655     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_FINDCITYANDSETCITYINDEXL_ENTRY, "CTzLocalizer::FindCityAndSetCityIndexL Entry;aDataSource=%u", aDataSource );
       
  1656     
  1582 	TBool hasFound = EFalse;
  1657 	TBool hasFound = EFalse;
  1583     CTzLocalizedCityArray* citiesInDb = CTzLocalizedCityArray::NewLC();
  1658     CTzLocalizedCityArray* citiesInDb = CTzLocalizedCityArray::NewLC();
  1584     if(aDataSource == ETzDataSourceSystem)
  1659     if(aDataSource == ETzDataSourceSystem)
  1585     	{
  1660     	{
  1586     	iStaticDataReader->ReadCitiesL(*citiesInDb);
  1661     	iStaticDataReader->ReadCitiesL(*citiesInDb);
  1599             hasFound = ETrue;
  1674             hasFound = ETrue;
  1600             break;
  1675             break;
  1601             }
  1676             }
  1602         }
  1677         }
  1603     CleanupStack::PopAndDestroy(citiesInDb);
  1678     CleanupStack::PopAndDestroy(citiesInDb);
       
  1679     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_FINDCITYANDSETCITYINDEXL_EXIT, "CTzLocalizer::FindCityAndSetCityIndexL Exit;hasFound=%u", hasFound );
       
  1680     
  1604     return hasFound;
  1681     return hasFound;
  1605 	}
  1682 	}
  1606 
  1683 
  1607 TBool CTzLocalizer::IsOperateOnUserDbL(TInt aTimeZoneId, TBool aUseDataSource) const
  1684 TBool CTzLocalizer::IsOperateOnUserDbL(TInt aTimeZoneId, TBool aUseDataSource) const
  1608 	{
  1685 	{
  1648 @param aCities Array of cities to be written.
  1725 @param aCities Array of cities to be written.
  1649 @internalTechnology
  1726 @internalTechnology
  1650 */
  1727 */
  1651 void CTzLocalizer::WriteAllFrequentlyUsedZonesL(const CTzLocalizedTimeZoneArray& aTimeZones, const CTzLocalizedCityArray& aCities)
  1728 void CTzLocalizer::WriteAllFrequentlyUsedZonesL(const CTzLocalizedTimeZoneArray& aTimeZones, const CTzLocalizedCityArray& aCities)
  1652 	{
  1729 	{
       
  1730     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_WRITEALLFREQUENTLYUSEDZONESL_ENTRY, "CTzLocalizer::WriteAllFrequentlyUsedZonesL Entry" );
       
  1731     
  1653 	// Ensure that the numbers of items in the arrays are the expected amount
  1732 	// Ensure that the numbers of items in the arrays are the expected amount
  1654 	__ASSERT_ALWAYS(aTimeZones.Count() == CTzLocalizedTimeZone::ECachedTimeZones &&
  1733 	__ASSERT_ALWAYS(aTimeZones.Count() == CTzLocalizedTimeZone::ECachedTimeZones &&
  1655 					aCities.Count() == CTzLocalizedTimeZone::ECachedTimeZones, User::Leave(KErrArgument));
  1734 					aCities.Count() == CTzLocalizedTimeZone::ECachedTimeZones, User::Leave(KErrArgument));
  1656 
  1735 
  1657 	RPointerArray<CTzLocalizedTimeZoneRecord> timeZones;
  1736 	RPointerArray<CTzLocalizedTimeZoneRecord> timeZones;
  1680 
  1759 
  1681 	iTzSession.LocalizationWriteAllFrequentlyUsedZonesL(timeZones, cities);
  1760 	iTzSession.LocalizationWriteAllFrequentlyUsedZonesL(timeZones, cities);
  1682 
  1761 
  1683 	CleanupStack::PopAndDestroy();	// cities
  1762 	CleanupStack::PopAndDestroy();	// cities
  1684 	CleanupStack::PopAndDestroy();	// timeZones
  1763 	CleanupStack::PopAndDestroy();	// timeZones
       
  1764 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZER_WRITEALLFREQUENTLYUSEDZONESL_EXIT, "CTzLocalizer::WriteAllFrequentlyUsedZonesL Exit" );
       
  1765 	
  1685 	}
  1766 	}
  1686 
  1767 
  1687 void CTzLocalizer::SetFrequentlyUsedZoneL(const CTzLocalizedTimeZone& aTimeZone, const CTzLocalizedCity& aCity,
  1768 void CTzLocalizer::SetFrequentlyUsedZoneL(const CTzLocalizedTimeZone& aTimeZone, const CTzLocalizedCity& aCity,
  1688 		const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone)
  1769 		const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone)
  1689 	{
  1770 	{