|
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 __TZLOCALIZATION_DB_ACCESSOR_H__ |
|
17 #define __TZLOCALIZATION_DB_ACCESSOR_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <d32dbms.h> |
|
21 #include "TzLocalizationDataTypes.h" |
|
22 #include <tz.h> |
|
23 |
|
24 _LIT(KTzMutexName, "TZ_GlobalMutex"); |
|
25 |
|
26 /** |
|
27 Provides access to the time zone localization database |
|
28 through a RDbs session. |
|
29 The database is stored in the DBMS private directory |
|
30 @internalTechnology |
|
31 */ |
|
32 class CTzLocalizationDbAccessor : public CBase |
|
33 { |
|
34 public: |
|
35 //Enumerations used for column ordering in the database. |
|
36 //The database columns MUST be created in the same order they appear in this enumeration |
|
37 enum TTzCityColumn |
|
38 { |
|
39 // Enum will used as a DB column index, so it must start at 1 |
|
40 ETzCityId =1, |
|
41 ETzCityCity, |
|
42 ETzCityGroup, |
|
43 ETzCityResourceId, |
|
44 }; |
|
45 |
|
46 enum TTzZoneColumn |
|
47 { |
|
48 // Enum will used as a DB column index, so it must start at 1 |
|
49 ETzZoneId =1, |
|
50 ETzZoneStdName, |
|
51 ETzZoneDSTName, |
|
52 ETzZoneShortStdName, |
|
53 ETzZoneShortDSTName, |
|
54 ETzZoneCity, |
|
55 ETzZoneGroupId, |
|
56 ETzZoneResourceId, |
|
57 ETzZoneCityIndex, |
|
58 }; |
|
59 |
|
60 // enum that specifies the maximum length of the strings corresponding |
|
61 // to time zone IDs and group IDs |
|
62 enum TTzStringLength |
|
63 { |
|
64 // Group ID is an unsigned 8-bit integer |
|
65 EMaxGroupIdStringLength = 3, |
|
66 // Time Zone ID is an unsigned 16-bit integer |
|
67 EMaxTimeZoneIdStringLength = 5 |
|
68 }; |
|
69 |
|
70 public: |
|
71 //Construction / Destruction |
|
72 static CTzLocalizationDbAccessor* NewL(); |
|
73 static CTzLocalizationDbAccessor* NewLC(); |
|
74 ~CTzLocalizationDbAccessor(); |
|
75 |
|
76 void PrepareCityViewL(const TDesC& aSqlQuery); |
|
77 void PrepareZoneViewL(); |
|
78 |
|
79 TBool DbNeedsUpdatingL(); |
|
80 void RecreateDbL(RTz& aTzSession); |
|
81 |
|
82 protected: |
|
83 CTzLocalizationDbAccessor(); |
|
84 //Second phase construction |
|
85 void ConstructL(); |
|
86 static void ReleaseMutex(TAny *target) ; |
|
87 |
|
88 private: |
|
89 TInt CreateFrequentlyUsedZoneTableL(); |
|
90 TInt CreateUserCityTableL(); |
|
91 void CloseDb(); |
|
92 void OpenDbL(); |
|
93 |
|
94 protected: |
|
95 //Member data |
|
96 RDbs iDbsSession; //DBMS server session |
|
97 RDbNamedDatabase iLocalizedTimeZoneDb; //Database |
|
98 RDbView iCityView; //Rowset |
|
99 RDbView iZoneView; //Rowset |
|
100 RMutex iZoneMutex ; // protecting iZoneView changes |
|
101 }; |
|
102 |
|
103 #endif //__TZLOCALIZATION_DB_ACCESSOR_H__ |