1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // 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
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __TzLocalizer_H__
17 #define __TzLocalizer_H__
19 #include <e32base.h> //CBase
21 #include <tzlocalizationdatatypes.h> //CTzLocalizedCity, CTzLocalizedCityGroup etc
23 // Forward Declarations
24 class MTzLocalizationReader;
25 class MTzLocalizationWriter;
28 Retrieves localized time zone information based on a time zone ID.
30 Time zone information is available in the following forms:
31 - Standard Name, for instance Greenwich Mean Time,
32 - Short Standard Name, for instance GMT,
33 - Daylight Savings Name, for instance British Summer Time,
34 - Short Daylight Savings Name, for instance BST.
36 This information is encapsulated in a CTzLocalizedTimeZone object.
38 A collection of localizable cities for a specific time zone can also be returned.
39 New cities can be added to a time zone. Cities may also be added to groups, but
40 a city may only be a member of one group.
45 class CTzLocalizer : public CBase
48 /** Panic reasons for the time zone localization component. */
49 enum TTzLocalizerPanics
51 /** The time zone server was not found. */
52 ETzLocalizerPanicTimeZoneServerNotFound,
53 /** A resource file was not found. */
54 ETzLocalizerPanicResourceFileNotFound
57 /** Used to specify the sort order of localized time zone information. */
60 /** Unsorted. This is the fastest way to get localized data. */
62 /** Sort by UTC offset starting with the lowest. */
64 /** Sort by UTC offset starting with the highest. */
66 /** Sort by name (city name/group name/standard time zone name), from A-Z. */
67 ETzAlphaNameAscending,
68 /** Sort by name (city name/group name/standard time zone name), from Z-A. */
69 ETzAlphaNameDescending,
70 /** Sort by standard name from A-Z. */
71 ETzAlphaStandardNameAscending,
72 /** Sort by daylight savings name from A-Z. */
73 ETzAlphaDaylightNameAscending,
74 /** Sort by short standard name from A-Z. */
75 ETzAlphaShortStandardNameAscending,
76 /** Sort by short daylight savings name from A-Z. */
77 ETzAlphaShortDaylightNameAscending,
78 /** Sort by standard name from Z-A. */
79 ETzAlphaStandardNameDescending,
80 /** Sort by daylight savings name from Z-A. */
81 ETzAlphaDaylightNameDescending,
82 /** Sort by short standard name from Z-A. */
83 ETzAlphaShortStandardNameDescending,
84 /** Sort by short daylight savings name from Z-A. */
85 ETzAlphaShortDaylightNameDescending
89 //Construction / Destruction
90 IMPORT_C static CTzLocalizer* NewL();
91 IMPORT_C static CTzLocalizer* NewLC();
92 IMPORT_C ~CTzLocalizer();
95 IMPORT_C CTzLocalizedTimeZone* GetLocalizedTimeZoneL(TInt aTimeZoneId) const;
96 IMPORT_C CTzLocalizedTimeZone* GetLocalizedTimeZoneL(const CTzLocalizedCity& aCity) const;
97 IMPORT_C CTzLocalizedTimeZoneArray* GetAllTimeZonesL(const TTzSortOrder aSortOrder = ETzUnsorted);
99 IMPORT_C void SetTimeZoneL(TInt aTimeZoneId);
102 IMPORT_C CTzLocalizedCity* GetDefaultCityL(TInt aTimeZoneId) const;
103 IMPORT_C CTzLocalizedCity* GetDefaultCityL(const CTzLocalizedCity& aCity) const;
104 IMPORT_C CTzLocalizedCity* GetDefaultCityL(const CTzLocalizedTimeZone& aTimeZone) const;
106 IMPORT_C CTzLocalizedCityArray* GetCitiesL(const TTzSortOrder aSortOrder = ETzUnsorted);
107 IMPORT_C CTzLocalizedCityArray* GetCitiesL(TInt aTimeZoneId,const TTzSortOrder aSortOrder = ETzUnsorted);
108 IMPORT_C CTzLocalizedCityArray* GetCitiesL(const CTzLocalizedTimeZone& aTimeZone,const TTzSortOrder aSortOrder = ETzUnsorted);
109 IMPORT_C CTzLocalizedCityArray* GetCitiesL(const CTzLocalizedCity& aCity,const TTzSortOrder aSortOrder = ETzUnsorted);
111 IMPORT_C CTzLocalizedCity* AddCityL(TInt aTimeZoneId,const TDesC& aCityName, TInt aGroupId = 0);
112 IMPORT_C void RemoveCityL(CTzLocalizedCity* aCity);
115 IMPORT_C CTzLocalizedCityGroupArray* GetAllCityGroupsL(const TTzSortOrder aSortOrder = ETzUnsorted) const;
116 IMPORT_C CTzLocalizedCityGroup* GetCityGroupL(TInt aGroupId) const;
117 IMPORT_C CTzLocalizedCityGroup* GetCityGroupL(const CTzLocalizedCity& aCity) const ;
119 IMPORT_C CTzLocalizedCityArray* GetCitiesInGroupL(TInt aGroupId,const TTzSortOrder aSortOrder = ETzUnsorted);
120 IMPORT_C CTzLocalizedCityArray* GetCitiesInGroupL(const CTzLocalizedCity& aCity,const TTzSortOrder aSortOrder = ETzUnsorted);
121 IMPORT_C CTzLocalizedCityArray* GetCitiesInGroupL(const CTzLocalizedCityGroup& aCityGroup,const TTzSortOrder aSortOrder = ETzUnsorted);
123 //Frequently Used Zones
124 IMPORT_C CTzLocalizedTimeZone* GetFrequentlyUsedZoneL(const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone);
125 IMPORT_C CTzLocalizedCity* GetFrequentlyUsedZoneCityL(const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone);
126 IMPORT_C void SetFrequentlyUsedZoneL(TInt aTimeZoneId,const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone);
127 IMPORT_C void SetFrequentlyUsedZoneL(const CTzLocalizedTimeZone& aTimeZone,const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone);
128 IMPORT_C void SetFrequentlyUsedZoneL(const CTzLocalizedCity& aCity,const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone);
131 IMPORT_C CTzLocalizedCity* FindCityByNameL(const TDesC& aCityName, const TInt aTimeZoneId = 0);
132 IMPORT_C CTzLocalizedTimeZone* FindTimeZoneByNameL(const TDesC& aTimeZoneName);
133 IMPORT_C CTzLocalizedCityGroup* FindCityGroupByNameL(const TDesC& aCityGroupName);
135 IMPORT_C TBool CheckLanguage();
137 //Cities and Time Zones with a specified UTC offset
138 IMPORT_C CTzLocalizedCityArray* GetCitiesWithUTCOffsetL(TInt aUTCOffsetInMinutes, const TTzSortOrder aSortOrder = ETzUnsorted);
139 IMPORT_C CTzLocalizedTimeZoneArray* GetTimeZonesWithUTCOffsetL(TInt aUTCOffsetInMinutes, const TTzSortOrder aSortOrder = ETzUnsorted);
145 TBool PrepareFrequentlyUsedZonesL();
146 void UpdateFrequentlyUsedZonesL();
147 CTzLocalizedTimeZone* GetFrequentlyUsedDefaultZoneL(CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFreqUsedZone);
148 TUint32 GetFrequentlyUsedDefaultZoneCenRepKeyL(CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFreqUsedZone);
150 void GetCitiesL(CTzLocalizedCityArray& aCities, const TTzLocalizedId& aLocalizedId, const TTzSortOrder aSortOrder = ETzUnsorted);
152 TLinearOrder<CTzLocalizedCity> CitySortOrderL(const TTzSortOrder aSortOrder);
153 TLinearOrder<CTzLocalizedTimeZone> TimeZoneSortOrderL(const TTzSortOrder aSortOrder);
154 template <class T> void PrepareForUTCSortL(T& aArray);
156 TInt GetTimeZoneIdFromTzServerL();
157 void DoSetTimeZoneL(TInt aTimeZoneId);
158 void ChangeHomeTimeZoneL(TInt aNewId);
162 TBool DbNeedsUpdatingL() const;
163 TBool DbIsInvalidL() const;
164 void UpgradeDbVersionL();
165 void FetchCityToUpgradeL(CTzLocalizedTimeZoneArray& aTimeZoneArray, CTzLocalizedCityArray& aCityArray, CTzLocalizedTimeZone::TTzFrequentlyUsedZone aCachedZone);
169 MTzLocalizationReader* iStaticDataReader;
170 MTzLocalizationReader* iPersistedDataReader;
171 MTzLocalizationWriter* iPersistedDataWriter;
175 #endif//__TzLocalizer_H__