1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/mw/tzlocalizer.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,175 @@
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 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __TzLocalizer_H__
1.20 +#define __TzLocalizer_H__
1.21 +
1.22 +#include <e32base.h> //CBase
1.23 +
1.24 +#include <tzlocalizationdatatypes.h> //CTzLocalizedCity, CTzLocalizedCityGroup etc
1.25 +
1.26 +// Forward Declarations
1.27 +class MTzLocalizationReader;
1.28 +class MTzLocalizationWriter;
1.29 +
1.30 +/**
1.31 +Retrieves localized time zone information based on a time zone ID.
1.32 +
1.33 +Time zone information is available in the following forms:
1.34 +- Standard Name, for instance Greenwich Mean Time,
1.35 +- Short Standard Name, for instance GMT,
1.36 +- Daylight Savings Name, for instance British Summer Time,
1.37 +- Short Daylight Savings Name, for instance BST.
1.38 +
1.39 +This information is encapsulated in a CTzLocalizedTimeZone object.
1.40 +
1.41 +A collection of localizable cities for a specific time zone can also be returned.
1.42 +New cities can be added to a time zone. Cities may also be added to groups, but
1.43 +a city may only be a member of one group.
1.44 +
1.45 +@publishedAll
1.46 +@released
1.47 +*/
1.48 +class CTzLocalizer : public CBase
1.49 + {
1.50 + public:
1.51 + /** Panic reasons for the time zone localization component. */
1.52 + enum TTzLocalizerPanics
1.53 + {
1.54 + /** The time zone server was not found. */
1.55 + ETzLocalizerPanicTimeZoneServerNotFound,
1.56 + /** A resource file was not found. */
1.57 + ETzLocalizerPanicResourceFileNotFound
1.58 + };
1.59 +
1.60 + /** Used to specify the sort order of localized time zone information. */
1.61 + enum TTzSortOrder
1.62 + {
1.63 + /** Unsorted. This is the fastest way to get localized data. */
1.64 + ETzUnsorted,
1.65 + /** Sort by UTC offset starting with the lowest. */
1.66 + ETzUTCAscending,
1.67 + /** Sort by UTC offset starting with the highest. */
1.68 + ETzUTCDescending,
1.69 + /** Sort by name (city name/group name/standard time zone name), from A-Z. */
1.70 + ETzAlphaNameAscending,
1.71 + /** Sort by name (city name/group name/standard time zone name), from Z-A. */
1.72 + ETzAlphaNameDescending,
1.73 + /** Sort by standard name from A-Z. */
1.74 + ETzAlphaStandardNameAscending,
1.75 + /** Sort by daylight savings name from A-Z. */
1.76 + ETzAlphaDaylightNameAscending,
1.77 + /** Sort by short standard name from A-Z. */
1.78 + ETzAlphaShortStandardNameAscending,
1.79 + /** Sort by short daylight savings name from A-Z. */
1.80 + ETzAlphaShortDaylightNameAscending,
1.81 + /** Sort by standard name from Z-A. */
1.82 + ETzAlphaStandardNameDescending,
1.83 + /** Sort by daylight savings name from Z-A. */
1.84 + ETzAlphaDaylightNameDescending,
1.85 + /** Sort by short standard name from Z-A. */
1.86 + ETzAlphaShortStandardNameDescending,
1.87 + /** Sort by short daylight savings name from Z-A. */
1.88 + ETzAlphaShortDaylightNameDescending
1.89 + };
1.90 +
1.91 + public:
1.92 + //Construction / Destruction
1.93 + IMPORT_C static CTzLocalizer* NewL();
1.94 + IMPORT_C static CTzLocalizer* NewLC();
1.95 + IMPORT_C ~CTzLocalizer();
1.96 +
1.97 + //Time zones
1.98 + IMPORT_C CTzLocalizedTimeZone* GetLocalizedTimeZoneL(TInt aTimeZoneId) const;
1.99 + IMPORT_C CTzLocalizedTimeZone* GetLocalizedTimeZoneL(const CTzLocalizedCity& aCity) const;
1.100 + IMPORT_C CTzLocalizedTimeZoneArray* GetAllTimeZonesL(const TTzSortOrder aSortOrder = ETzUnsorted);
1.101 +
1.102 + IMPORT_C void SetTimeZoneL(TInt aTimeZoneId);
1.103 +
1.104 + //City Management
1.105 + IMPORT_C CTzLocalizedCity* GetDefaultCityL(TInt aTimeZoneId) const;
1.106 + IMPORT_C CTzLocalizedCity* GetDefaultCityL(const CTzLocalizedCity& aCity) const;
1.107 + IMPORT_C CTzLocalizedCity* GetDefaultCityL(const CTzLocalizedTimeZone& aTimeZone) const;
1.108 +
1.109 + IMPORT_C CTzLocalizedCityArray* GetCitiesL(const TTzSortOrder aSortOrder = ETzUnsorted);
1.110 + IMPORT_C CTzLocalizedCityArray* GetCitiesL(TInt aTimeZoneId,const TTzSortOrder aSortOrder = ETzUnsorted);
1.111 + IMPORT_C CTzLocalizedCityArray* GetCitiesL(const CTzLocalizedTimeZone& aTimeZone,const TTzSortOrder aSortOrder = ETzUnsorted);
1.112 + IMPORT_C CTzLocalizedCityArray* GetCitiesL(const CTzLocalizedCity& aCity,const TTzSortOrder aSortOrder = ETzUnsorted);
1.113 +
1.114 + IMPORT_C CTzLocalizedCity* AddCityL(TInt aTimeZoneId,const TDesC& aCityName, TInt aGroupId = 0);
1.115 + IMPORT_C void RemoveCityL(CTzLocalizedCity* aCity);
1.116 +
1.117 + //City Groups
1.118 + IMPORT_C CTzLocalizedCityGroupArray* GetAllCityGroupsL(const TTzSortOrder aSortOrder = ETzUnsorted) const;
1.119 + IMPORT_C CTzLocalizedCityGroup* GetCityGroupL(TInt aGroupId) const;
1.120 + IMPORT_C CTzLocalizedCityGroup* GetCityGroupL(const CTzLocalizedCity& aCity) const ;
1.121 +
1.122 + IMPORT_C CTzLocalizedCityArray* GetCitiesInGroupL(TInt aGroupId,const TTzSortOrder aSortOrder = ETzUnsorted);
1.123 + IMPORT_C CTzLocalizedCityArray* GetCitiesInGroupL(const CTzLocalizedCity& aCity,const TTzSortOrder aSortOrder = ETzUnsorted);
1.124 + IMPORT_C CTzLocalizedCityArray* GetCitiesInGroupL(const CTzLocalizedCityGroup& aCityGroup,const TTzSortOrder aSortOrder = ETzUnsorted);
1.125 +
1.126 + //Frequently Used Zones
1.127 + IMPORT_C CTzLocalizedTimeZone* GetFrequentlyUsedZoneL(const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone);
1.128 + IMPORT_C CTzLocalizedCity* GetFrequentlyUsedZoneCityL(const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone);
1.129 + IMPORT_C void SetFrequentlyUsedZoneL(TInt aTimeZoneId,const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone);
1.130 + IMPORT_C void SetFrequentlyUsedZoneL(const CTzLocalizedTimeZone& aTimeZone,const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone);
1.131 + IMPORT_C void SetFrequentlyUsedZoneL(const CTzLocalizedCity& aCity,const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone);
1.132 +
1.133 + //Find functions
1.134 + IMPORT_C CTzLocalizedCity* FindCityByNameL(const TDesC& aCityName, const TInt aTimeZoneId = 0);
1.135 + IMPORT_C CTzLocalizedTimeZone* FindTimeZoneByNameL(const TDesC& aTimeZoneName);
1.136 + IMPORT_C CTzLocalizedCityGroup* FindCityGroupByNameL(const TDesC& aCityGroupName);
1.137 +
1.138 + IMPORT_C TBool CheckLanguage();
1.139 +
1.140 + //Cities and Time Zones with a specified UTC offset
1.141 + IMPORT_C CTzLocalizedCityArray* GetCitiesWithUTCOffsetL(TInt aUTCOffsetInMinutes, const TTzSortOrder aSortOrder = ETzUnsorted);
1.142 + IMPORT_C CTzLocalizedTimeZoneArray* GetTimeZonesWithUTCOffsetL(TInt aUTCOffsetInMinutes, const TTzSortOrder aSortOrder = ETzUnsorted);
1.143 +
1.144 + private:
1.145 + void ConstructL();
1.146 + CTzLocalizer();
1.147 +
1.148 + TBool PrepareFrequentlyUsedZonesL();
1.149 + void UpdateFrequentlyUsedZonesL();
1.150 + CTzLocalizedTimeZone* GetFrequentlyUsedDefaultZoneL(CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFreqUsedZone);
1.151 + TUint32 GetFrequentlyUsedDefaultZoneCenRepKeyL(CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFreqUsedZone);
1.152 +
1.153 + void GetCitiesL(CTzLocalizedCityArray& aCities, const TTzLocalizedId& aLocalizedId, const TTzSortOrder aSortOrder = ETzUnsorted);
1.154 +
1.155 + TLinearOrder<CTzLocalizedCity> CitySortOrderL(const TTzSortOrder aSortOrder);
1.156 + TLinearOrder<CTzLocalizedTimeZone> TimeZoneSortOrderL(const TTzSortOrder aSortOrder);
1.157 + template <class T> void PrepareForUTCSortL(T& aArray);
1.158 +
1.159 + TInt GetTimeZoneIdFromTzServerL();
1.160 + void DoSetTimeZoneL(TInt aTimeZoneId);
1.161 + void ChangeHomeTimeZoneL(TInt aNewId);
1.162 +
1.163 + void ValidateDbL();
1.164 + void RecreateDbL();
1.165 + TBool DbNeedsUpdatingL() const;
1.166 + TBool DbIsInvalidL() const;
1.167 + void UpgradeDbVersionL();
1.168 + void FetchCityToUpgradeL(CTzLocalizedTimeZoneArray& aTimeZoneArray, CTzLocalizedCityArray& aCityArray, CTzLocalizedTimeZone::TTzFrequentlyUsedZone aCachedZone);
1.169 +
1.170 + private:
1.171 + //Member data
1.172 + MTzLocalizationReader* iStaticDataReader;
1.173 + MTzLocalizationReader* iPersistedDataReader;
1.174 + MTzLocalizationWriter* iPersistedDataWriter;
1.175 + TLanguage iLanguage;
1.176 + };
1.177 +
1.178 +#endif//__TzLocalizer_H__