epoc32/include/mw/tzlocalizer.h
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
     1.1 --- a/epoc32/include/mw/tzlocalizer.h	Wed Mar 31 12:27:01 2010 +0100
     1.2 +++ b/epoc32/include/mw/tzlocalizer.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -1,9 +1,9 @@
     1.4  // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5  // All rights reserved.
     1.6  // This component and the accompanying materials are made available
     1.7 -// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     1.8 +// under the terms of "Eclipse Public License v1.0"
     1.9  // which accompanies this distribution, and is available
    1.10 -// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.12  //
    1.13  // Initial Contributors:
    1.14  // Nokia Corporation - initial contribution.
    1.15 @@ -16,28 +16,63 @@
    1.16  #ifndef __TzLocalizer_H__
    1.17  #define __TzLocalizer_H__
    1.18  
    1.19 -#include <e32base.h> //CBase
    1.20 +#include <e32base.h>
    1.21 +#include <tz.h>
    1.22 +#include <tzlocalizationdatatypes.h>
    1.23  
    1.24 -#include <tzlocalizationdatatypes.h> 	//CTzLocalizedCity, CTzLocalizedCityGroup etc
    1.25 +class CTzLocalizationResourceReader;
    1.26 +class CTzLocalizationUserDataReader;
    1.27  
    1.28 -// Forward Declarations
    1.29 -class MTzLocalizationReader;
    1.30 -class MTzLocalizationWriter;
    1.31 -
    1.32 +const TInt KTzCityNotInGroupId = 0;
    1.33  /**
    1.34 -Retrieves localized time zone information based on a time zone ID.
    1.35 +Retrieves localized time zone information based on a time zone identifier.
    1.36  
    1.37  Time zone information is available in the following forms:
    1.38 -- Standard Name, for instance Greenwich Mean Time,
    1.39 -- Short Standard Name, for instance GMT,
    1.40 -- Daylight Savings Name, for instance British Summer Time,
    1.41 -- Short Daylight Savings Name, for instance BST.
    1.42 +
    1.43 +- Standard time name, for example "Greenwich Mean Time"
    1.44 +- Short standard time name, for instance "GMT"
    1.45 +- Daylight saving time name, for instance "British Summer Time"
    1.46 +- Short daylight saving time name, for instance "BST"
    1.47  
    1.48  This information is encapsulated in a CTzLocalizedTimeZone object.
    1.49  
    1.50 -A collection of localizable cities for a specific time zone can also be returned.
    1.51 -New cities can be added to a time zone.  Cities may also be added to groups, but 
    1.52 -a city may only be a member of one group.
    1.53 +A collection of localized cities for a specific time zone is returned as a
    1.54 +CTzLocalizedCityArray object.  An individual localized city is returned as a
    1.55 +CTzLocalizedCity object.
    1.56 +
    1.57 +A collection of localized city groups for a specific time zone is returned as a
    1.58 +CTzLocalizedCityGroupArray.  An individual localized city group is returned as a
    1.59 +CTzLocalizedCityGroup object.
    1.60 +
    1.61 +New non-localized cities can be added to an existing time zone.  A new city may
    1.62 +also be added to a city group, but a city may only be a member of one city
    1.63 +group.
    1.64 +
    1.65 +User-defined time zone names can also be retrieved through this class,
    1.66 +encapsulated as follows:
    1.67 +
    1.68 +- In a CTzLocalizedTimeZone object for long/short standard time and long/short
    1.69 +daylight saving time user-defined time zone names.
    1.70 +- In a CTzLocalizedCityArray object or CTzLocalizedCity object for user-defined
    1.71 +time zone city names.
    1.72 +- In a CTzLocalizedCityGroupArray object or CTzLocalizedCityGroup object for
    1.73 +user-defined time zone region names.
    1.74 +
    1.75 +All user-defined time zones names’ use the same city group identifier of
    1.76 +KTzCityNotInGroupId to indicate that they do not belong to a specific group.
    1.77 +
    1.78 +For methods that return a single city or single city group, if the given group
    1.79 +identifier is KTzCityNotInGroupId the methods leave with KErrArgument since it
    1.80 +is not possible to determine which region name should be used to identify the
    1.81 +single city group.
    1.82 +
    1.83 +For methods that return an array of cities or city groups, if the given group
    1.84 +identifier is KTzCityNotInGroupId the methods shall return all user-defined city
    1.85 +names or region names.
    1.86 +
    1.87 +The array object forms can contain a combination of system time zone
    1.88 +localization information and user-defined time zone names.  The client can
    1.89 +control the combination of data using the SetDataSource() method.
    1.90  
    1.91  @publishedAll
    1.92  @released
    1.93 @@ -85,17 +120,40 @@
    1.94  			ETzAlphaShortDaylightNameDescending
    1.95  			};
    1.96  
    1.97 +	    /**
    1.98 +	    This enumeration indicates the data source(s) to use for CTzLocalizer
    1.99 +	    methods that return a combination of system time zone localization
   1.100 +	    information and user-defined time zone names.  The enumeration values
   1.101 +	    are bit flags which can be combined using the logical OR operator.
   1.102 +	    */
   1.103 +		enum TTzLocalizerDataSource
   1.104 +	        {
   1.105 +	        /** Use system time zone localization information. */
   1.106 +	        ETzDataSourceSystem = 0x1,
   1.107 +	        /** Use non-localized user time zone names. */
   1.108 +	        ETzDataSourceUser   = 0x2
   1.109 +	        };
   1.110 +
   1.111  	public:
   1.112  		//Construction / Destruction
   1.113  		IMPORT_C static CTzLocalizer* NewL();
   1.114  		IMPORT_C static CTzLocalizer* NewLC();
   1.115  		IMPORT_C ~CTzLocalizer();
   1.116  
   1.117 +	private:
   1.118 +		CTzLocalizer();
   1.119 +		void ConstructL();
   1.120 +        TBool DbNeedsUpdatingL() const;
   1.121 +        void UpgradeDbVersionL();
   1.122 +        void FetchCityToUpgradeL(CTzLocalizedTimeZoneArray& aTimeZoneArray, CTzLocalizedCityArray& aCityArray, CTzLocalizedTimeZone::TTzFrequentlyUsedZone aCachedZone);
   1.123 +        void RecreateDbL();
   1.124 +
   1.125 +	public:
   1.126  		//Time zones
   1.127  		IMPORT_C CTzLocalizedTimeZone* GetLocalizedTimeZoneL(TInt aTimeZoneId) const;
   1.128  		IMPORT_C CTzLocalizedTimeZone* GetLocalizedTimeZoneL(const CTzLocalizedCity& aCity) const;
   1.129  		IMPORT_C CTzLocalizedTimeZoneArray* GetAllTimeZonesL(const TTzSortOrder aSortOrder = ETzUnsorted);
   1.130 -		
   1.131 +
   1.132  		IMPORT_C void SetTimeZoneL(TInt aTimeZoneId);
   1.133  
   1.134  		//City Management
   1.135 @@ -131,45 +189,55 @@
   1.136  		IMPORT_C CTzLocalizedCity* FindCityByNameL(const TDesC& aCityName, const TInt aTimeZoneId = 0);
   1.137  		IMPORT_C CTzLocalizedTimeZone* FindTimeZoneByNameL(const TDesC& aTimeZoneName);
   1.138  		IMPORT_C CTzLocalizedCityGroup* FindCityGroupByNameL(const TDesC& aCityGroupName);
   1.139 -		
   1.140 +
   1.141  		IMPORT_C TBool CheckLanguage();
   1.142 -		
   1.143 +
   1.144  		//Cities and Time Zones with a specified UTC offset
   1.145  		IMPORT_C CTzLocalizedCityArray* GetCitiesWithUTCOffsetL(TInt aUTCOffsetInMinutes, const TTzSortOrder aSortOrder = ETzUnsorted);
   1.146  		IMPORT_C CTzLocalizedTimeZoneArray* GetTimeZonesWithUTCOffsetL(TInt aUTCOffsetInMinutes, const TTzSortOrder aSortOrder = ETzUnsorted);
   1.147 -		
   1.148 +
   1.149 +		IMPORT_C void SetDataSource(TUint aDataSource);
   1.150 +
   1.151  	private:
   1.152 -		void ConstructL();
   1.153 -		CTzLocalizer();
   1.154 -		
   1.155  		TBool PrepareFrequentlyUsedZonesL();
   1.156  		void UpdateFrequentlyUsedZonesL();
   1.157  		CTzLocalizedTimeZone* GetFrequentlyUsedDefaultZoneL(CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFreqUsedZone);
   1.158  		TUint32 GetFrequentlyUsedDefaultZoneCenRepKeyL(CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFreqUsedZone);
   1.159 -		
   1.160 -		void GetCitiesL(CTzLocalizedCityArray& aCities, const TTzLocalizedId& aLocalizedId, const TTzSortOrder aSortOrder = ETzUnsorted);
   1.161 -		
   1.162 +		void GetCitiesL(CTzLocalizedCityArray& aCities, const TTzLocalizedId& aLocalizedId,
   1.163 +			TBool aUseDataSource, const TTzSortOrder aSortOrder = ETzUnsorted);
   1.164  		TLinearOrder<CTzLocalizedCity> CitySortOrderL(const TTzSortOrder aSortOrder);
   1.165  		TLinearOrder<CTzLocalizedTimeZone> TimeZoneSortOrderL(const TTzSortOrder aSortOrder);
   1.166  		template <class T> void PrepareForUTCSortL(T& aArray);
   1.167 -		
   1.168  		TInt GetTimeZoneIdFromTzServerL();
   1.169  		void DoSetTimeZoneL(TInt aTimeZoneId);
   1.170  		void ChangeHomeTimeZoneL(TInt aNewId);
   1.171 -		
   1.172 -		void ValidateDbL();
   1.173 -        void RecreateDbL();
   1.174 -        TBool DbNeedsUpdatingL() const;
   1.175 -		TBool DbIsInvalidL() const;
   1.176 -        void UpgradeDbVersionL();
   1.177 -        void FetchCityToUpgradeL(CTzLocalizedTimeZoneArray& aTimeZoneArray, CTzLocalizedCityArray& aCityArray, CTzLocalizedTimeZone::TTzFrequentlyUsedZone aCachedZone);
   1.178 +        TBool FindCityAndSetCityIndexL(CTzLocalizedCity& aLocalizedCity, TTzLocalizerDataSource aDataSource);
   1.179 +        TBool IsOperateOnUserDbL(TInt aTimeZoneId, TBool aUseDataSource) const;
   1.180 +        void ReadCitiesL(CTzLocalizedCityArray& aCityArray, TInt aTimeZoneId, TBool aUseDataSource) const;
   1.181 +        CTzLocalizedCity* ReadDefaultCityL(TInt aTimeZoneId, TBool aUseDataSource) const;
   1.182 +        void WriteAllFrequentlyUsedZonesL(const CTzLocalizedTimeZoneArray& aTimeZones, const CTzLocalizedCityArray& aCities);
   1.183 +        void SetFrequentlyUsedZoneL(const CTzLocalizedTimeZone& aTimeZone, const CTzLocalizedCity& aCity,
   1.184 +        	const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone);
   1.185 +        CTzLocalizedTimeZone* GetLocalizedTimeZoneL(TInt aTimeZoneId, TBool aUseDataSource) const;
   1.186 +        CTzLocalizedTimeZone* GetLocalizedTimeZoneL(const CTzLocalizedCity& aCity, TBool aUseDataSource) const;
   1.187 +        static void PopulateCityArrayL(const RPointerArray<CTzLocalizedCityRecord>& aCityRecords,
   1.188 +        	CTzLocalizedCityArray& aCities);
   1.189 +        static CTzLocalizedTimeZoneRecord* CreateTimeZoneRecordL(const CTzLocalizedTimeZone& aTimeZone);
   1.190 +        static CTzLocalizedTimeZoneRecord* CreateTimeZoneRecordLC(const CTzLocalizedTimeZone& aTimeZone);
   1.191 +        static CTzLocalizedCityRecord* CreateCityRecordL(const CTzLocalizedCity& aCity);
   1.192 +        static CTzLocalizedCityRecord* CreateCityRecordLC(const CTzLocalizedCity& aCity);
   1.193 +        static CTzLocalizedTimeZone* CreateTimeZoneL(const CTzLocalizedTimeZoneRecord& aTimeZoneRecord);
   1.194 +        static CTzLocalizedCity* CreateCityL(const CTzLocalizedCityRecord& aCityRecord);
   1.195 +        static void CleanupTimeZonePointerArray(TAny* aArray);
   1.196 +        static void CleanupCityPointerArray(TAny* aArray);
   1.197  
   1.198 -	private:
   1.199 -		//Member data
   1.200 -		MTzLocalizationReader* iStaticDataReader;
   1.201 -		MTzLocalizationReader* iPersistedDataReader;
   1.202 -		MTzLocalizationWriter* iPersistedDataWriter;
   1.203 +private:
   1.204 +		CTzLocalizationResourceReader* iStaticDataReader;
   1.205 +		CTzLocalizationUserDataReader* iUserDataReader;
   1.206 +
   1.207  		TLanguage iLanguage;
   1.208 +		TUint iDataSource;
   1.209 +		RTz iTzSession;
   1.210  	};
   1.211  
   1.212  #endif//__TzLocalizer_H__