|
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 "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __TZLOCAL_RESOURCE_READER_H__ |
|
17 #define __TZLOCAL_RESOURCE_READER_H__ |
|
18 |
|
19 #include "TzLocalizationDataTypes.h" |
|
20 #include <barsc.h> // RResourceFile |
|
21 #include <barsread.h> // TResourceReader |
|
22 #include <f32file.h> // RFs |
|
23 |
|
24 /** |
|
25 Concrete implementation of MTzLocalizationReader |
|
26 Reads Localized time zone information and city information from resource files |
|
27 @internalTechnology |
|
28 */ |
|
29 class CTzLocalizationResourceReader : public CBase |
|
30 { |
|
31 //enums |
|
32 /** |
|
33 Enum to get to the various resources in the resource files. These can be added |
|
34 to the offset returned by RResourceFile::Offset() to get the relevant resource |
|
35 ID |
|
36 */ |
|
37 enum TTzResourceOffset |
|
38 { |
|
39 /** |
|
40 Offset of the RSS Signature, this is always the first resource, so the enum |
|
41 starts at 1. |
|
42 */ |
|
43 ETzRssSignature = 1, |
|
44 /** |
|
45 Offset of the first localized resource. In the time zones resource file, this |
|
46 is the default cached zones resource, in the groups resource files, this is the |
|
47 first group. |
|
48 */ |
|
49 ETzFirstLocalizedResource, |
|
50 /** |
|
51 Offset of the first localized time zone resource. This simply allows the |
|
52 default cached zones resource to be skipped over in the time zones resource |
|
53 file. |
|
54 */ |
|
55 ETzFirstTimeZoneResource |
|
56 }; |
|
57 |
|
58 public: |
|
59 CTzLocalizedTimeZone* ReadTimeZoneL(const TInt aTimeZoneId); |
|
60 CTzLocalizedTimeZone* ReadTimeZoneL(const TTzLocalizedId& aTzLocalizedId); |
|
61 void ReadAllTimeZonesL(CTzLocalizedTimeZoneArray& aTimeZones); |
|
62 void ReadCitiesL(CTzLocalizedCityArray& aCities); |
|
63 void ReadCitiesL(CTzLocalizedCityArray& aCities, const TInt aTimeZoneId); |
|
64 void ReadCitiesL(CTzLocalizedCityArray& aCities, const TTzLocalizedId& aTzLocalizedId); |
|
65 void ReadCitiesInGroupL(CTzLocalizedCityArray& aCities, const TUint8 aGroupId); |
|
66 void ReadAllGroupsL(CTzLocalizedCityGroupArray& aGroups); |
|
67 CTzLocalizedCityGroup* ReadGroupL(const TUint8 aGroupId); |
|
68 CTzLocalizedCity* ReadDefaultCityL(const TInt aTimeZoneId); |
|
69 CTzLocalizedCity* ReadDefaultCityL(const TTzLocalizedId& aTzLocalizedId); |
|
70 CTzLocalizedTimeZone* ReadFrequentlyUsedZoneL(const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone); |
|
71 CTzLocalizedCity* ReadCachedTimeZoneCityL(const CTzLocalizedTimeZone::TTzFrequentlyUsedZone aFrequentlyUsedZone); |
|
72 |
|
73 //New Functions |
|
74 static CTzLocalizationResourceReader* NewL(); |
|
75 static CTzLocalizationResourceReader* NewLC(); |
|
76 ~CTzLocalizationResourceReader(); |
|
77 |
|
78 private: |
|
79 void ConstructL(); |
|
80 TInt FindTimeZoneResourceIdL(const TInt aTimeZoneId); |
|
81 TInt LocalizedResourceIdL(const RResourceFile& aResourceFile, const TTzResourceOffset aOffset); |
|
82 TInt FirstTimeZoneResourceIdL(); |
|
83 TInt FirstGroupResourceIdL(); |
|
84 TInt CachedTimeZoneResourceIdL(); |
|
85 void BufferResourceL(const RResourceFile& aResourceFile, const TInt aResourceId); |
|
86 void ResetResourceBuffer(); |
|
87 CTzLocalizedTimeZone* DoReadTimeZoneL(const TInt aResourceId); |
|
88 CTzLocalizedTimeZone* CreateTimeZoneFromResourceL(const TInt aResourceId); |
|
89 void DoReadCitiesL(CTzLocalizedCityArray& aCities, const TInt aResourceId); |
|
90 void AddCityArrayFromResourceL(CTzLocalizedCityArray& aCities, const TInt aResourceId); |
|
91 CTzLocalizedCityGroup* DoReadGroupL(const TInt aResourceId); |
|
92 CTzLocalizedCityGroup* CreateGroupFromResourceL(); |
|
93 |
|
94 private: |
|
95 RFs iFs; |
|
96 RResourceFile iTimeZoneResourceFile; |
|
97 RResourceFile iGroupResourceFile; |
|
98 TBool iGroupResourceFileExists; |
|
99 TResourceReader iResourceReader; |
|
100 HBufC8* iResourceBuffer; |
|
101 }; |
|
102 |
|
103 #endif //__TZLOCAL_RESOURCE_READER_H__ |