|
1 // Copyright (c) 1997-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 __TIMEZONE_SERVER_H__ |
|
17 #define __TIMEZONE_SERVER_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <e32std.h> |
|
21 #include <s32file.h> |
|
22 #include <tz.h> |
|
23 #include "tzconfigagent.h" |
|
24 #include "tzlocalizationdb.h" |
|
25 #include "tzswiobserver.h" |
|
26 |
|
27 const TUint KTimeZoneServerMajorVersion = 0; |
|
28 const TUint KTimeZoneServerMinorVersion = 1; |
|
29 const TUint KTimeZoneServerBuildVersion = 1; |
|
30 |
|
31 // Structures |
|
32 struct TRendezvous |
|
33 { |
|
34 TThreadId iId; |
|
35 TRequestStatus* iStatus; |
|
36 }; |
|
37 |
|
38 class CTzServer; |
|
39 class CTzUserDataDb; |
|
40 class CTzUserDataCache; |
|
41 |
|
42 #define KCapabilityNone 0 |
|
43 #define KCapabilityWriteDeviceData 1000 |
|
44 #define KCapabilityReadUserData 2000 |
|
45 #define KCapabilityWriteUserData 3000 |
|
46 |
|
47 _LIT(KTimeZoneServerName,"!TzServer"); |
|
48 |
|
49 /* CTzServer |
|
50 @internalComponent |
|
51 */ |
|
52 class CTzServer : public CPolicyServer, public MTZCfgAgentObserver |
|
53 { |
|
54 public: |
|
55 enum TFunctionCode |
|
56 { |
|
57 EGetLocalTimeZoneId = KCapabilityNone, |
|
58 EConvertLocalZoneTime, |
|
59 EConvertForeignZoneTime, |
|
60 EGetLocalEncodedTimeZoneRulesSize, |
|
61 EGetLocalOlsenEncodedTimeZoneRulesSize, |
|
62 EGetForeignEncodedTimeZoneRulesSize, |
|
63 EGetLocalEncodedTimeZoneRules, |
|
64 EGetLocalOlsenEncodedTimeZoneRules, |
|
65 EGetForeignEncodedTimeZoneRules, |
|
66 EGetTimeZoneFormat, |
|
67 ERegisterTimeChangeNotifier, |
|
68 ECancelRequestforNotice, |
|
69 ESrvOpcodeResourceCount, |
|
70 ESrvOpcodeSetHeapFailure, |
|
71 EGetOffsetsForTimeZoneIds, |
|
72 EIsDaylightSavingOn, |
|
73 EAutoUpdate, |
|
74 EGetUserTimeZoneNamesSize, |
|
75 EGetUserTimeZoneNames, |
|
76 EGetUserTimeZoneIds, |
|
77 EGetUserTimeZoneIdsSize, |
|
78 ESwiObsBegin, |
|
79 ESwiObsFileChanged, |
|
80 ESwiObsEnd, |
|
81 ESrvOpcodeResetHeap, |
|
82 ESetTimeZone = KCapabilityWriteDeviceData, |
|
83 EEnableAutoUpdate, // Also has WriteDeviceData capability. |
|
84 ENotifyHomeTimeZoneChanged, |
|
85 ESetHomeTime, |
|
86 ESetUnknownZoneTime, |
|
87 ECreateUserTimeZone, |
|
88 EUpdateUserTimeZone, |
|
89 EDeleteUserTimeZone, |
|
90 ELocalizationReadCitiesSize = KCapabilityReadUserData, |
|
91 ELocalizationReadCitiesTzIdSize, |
|
92 ELocalizationReadCitiesInGroupSize, |
|
93 ELocalizationReadCities, |
|
94 ELocalizationReadFrequentlyUsedZoneSize, |
|
95 ELocalizationReadFrequentlyUsedZone, |
|
96 ELocalizationReadCachedTimeZoneCitySize, |
|
97 ELocalizationReadCachedTimeZoneCity, |
|
98 ELocalizationOpenDb = KCapabilityWriteUserData, |
|
99 ELocalizationCloseDb, |
|
100 ELocalizationWriteCity, |
|
101 ELocalizationDeleteCity, |
|
102 ELocalizationWriteFrequentlyUsedZone, |
|
103 ELocalizationWriteAllFrequentlyUsedZones, |
|
104 ENotSupported |
|
105 }; |
|
106 |
|
107 public: |
|
108 static CTzServer* NewL(); |
|
109 ~CTzServer(); |
|
110 |
|
111 private: |
|
112 CTzServer(TInt aPriority); |
|
113 void ConstructL(); |
|
114 |
|
115 public: |
|
116 inline CTzConfigAgent& TimeZoneManager() const; |
|
117 inline CTzUserDataDb& UserTimeZoneDb() const; |
|
118 inline CTzLocalizationDb& LocalizationDb() const; |
|
119 inline CTzSwiObserver& SwiObserver() const; |
|
120 |
|
121 void SessionClosed() const; |
|
122 void SessionAdded() const; // required to be const to avoid compiler error |
|
123 void Error(TInt aError); |
|
124 |
|
125 private: |
|
126 // from MTZCfgAgentObserver |
|
127 void NotifyTZStatusChange(RTz::TTzChanges aChange, const TAny* aRequester); |
|
128 |
|
129 virtual CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
|
130 |
|
131 private: |
|
132 mutable TInt iSessionCount; |
|
133 CTzConfigAgent* iTimeZoneMgr; |
|
134 CTzUserDataDb* iTzUserDataDb; |
|
135 CTzLocalizationDb* iTzLocalizationDb; |
|
136 CTzSwiObserver* iTzSwiObserver; |
|
137 }; |
|
138 |
|
139 // |
|
140 // Active scheduler |
|
141 // |
|
142 class CTZSrvScheduler : public CActiveScheduler |
|
143 { |
|
144 public: |
|
145 ~CTZSrvScheduler(); |
|
146 static CTZSrvScheduler* NewL(); |
|
147 |
|
148 private: |
|
149 // from CActiveScheduler |
|
150 virtual void Error(TInt aError) const; |
|
151 |
|
152 private: |
|
153 CTzServer* iServer; |
|
154 }; |
|
155 |
|
156 inline CTzConfigAgent& CTzServer::TimeZoneManager() const |
|
157 { |
|
158 return *iTimeZoneMgr; |
|
159 } |
|
160 |
|
161 inline CTzUserDataDb& CTzServer::UserTimeZoneDb() const |
|
162 { |
|
163 return *iTzUserDataDb; |
|
164 } |
|
165 |
|
166 inline CTzLocalizationDb& CTzServer::LocalizationDb() const |
|
167 { |
|
168 return *iTzLocalizationDb; |
|
169 } |
|
170 |
|
171 inline CTzSwiObserver& CTzServer::SwiObserver() const |
|
172 { |
|
173 return *iTzSwiObserver; |
|
174 } |
|
175 |
|
176 #endif |