|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CNcdConfigurationManager declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_NCDCONFIGURATIONMANAGER_H |
|
20 #define C_NCDCONFIGURATIONMANAGER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <badesca.h> |
|
24 |
|
25 #include "ncdconfigurationmanager.h" |
|
26 #include "ncdstoragedataitem.h" |
|
27 #include "ncdproviderdefines.h" |
|
28 #include "ncdserverdetails.h" |
|
29 |
|
30 class MNcdStorageManager; |
|
31 class CNcdKeyValueMap; |
|
32 class CNcdServerAddress; |
|
33 class CNcdServerDetails; |
|
34 class CNcdGeneralManager; |
|
35 |
|
36 /** |
|
37 * Implements configuration management for NCD provider |
|
38 */ |
|
39 class CNcdConfigurationManager : public CBase, |
|
40 public MNcdConfigurationManager |
|
41 { |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Creates a new configuration manager |
|
46 * |
|
47 * @param aAppUid Application UID for the CentralRepository |
|
48 * @param aProviderUid Provider UID used for common provider data |
|
49 * @return A new configuration manager |
|
50 */ |
|
51 static CNcdConfigurationManager* NewL( CNcdGeneralManager& aGeneralManager ); |
|
52 |
|
53 ~CNcdConfigurationManager(); |
|
54 |
|
55 public: // MNcdConfigurationManager |
|
56 |
|
57 /** |
|
58 * @see MNcdConfigurationManager::AddObserverL() |
|
59 */ |
|
60 virtual void AddObserverL( |
|
61 MNcdConfigurationObserver& aObserver, |
|
62 const MCatalogsContext& aContext ); |
|
63 |
|
64 /** |
|
65 * @see MNcdConfigurationManager::RemoveObserver() |
|
66 */ |
|
67 virtual void RemoveObserver( |
|
68 MNcdConfigurationObserver& aObserver); |
|
69 |
|
70 /** |
|
71 * @see MNcdConfigurationManager::MasterServerAddress() |
|
72 */ |
|
73 const TDesC& MasterServerAddressL( const MCatalogsContext& aContext ) const; |
|
74 |
|
75 |
|
76 /** |
|
77 * @see MNcdConfigurationManager::IsMasterServerAddressValidL() |
|
78 */ |
|
79 TBool IsMasterServerAddressValidL( const MCatalogsContext& aContext ) const; |
|
80 |
|
81 /** |
|
82 * @see MNcdConfigurationManager::SetMasterServerAddressL() |
|
83 */ |
|
84 void SetMasterServerAddressL( |
|
85 const MCatalogsContext& aContext, |
|
86 const TDesC& aAddress, |
|
87 const TInt64& aValidity ); |
|
88 |
|
89 /** |
|
90 * @param aAddress Server address. Ownership is transferred after a |
|
91 * successful operation |
|
92 */ |
|
93 void SetMasterServerAddressL( |
|
94 const MCatalogsContext& aContext, |
|
95 CNcdServerAddress* aAddress ); |
|
96 |
|
97 /** |
|
98 * @see MNcdConfigurationManager::ResetMasterServerAddressL() |
|
99 */ |
|
100 void ResetMasterServerAddressL( const MCatalogsContext& aContext ); |
|
101 |
|
102 |
|
103 /** |
|
104 * @see MNcdConfigurationManager::ClientIdL() |
|
105 */ |
|
106 const TDesC& ClientIdL( const MCatalogsContext& aContext ); |
|
107 |
|
108 |
|
109 /** |
|
110 * @see MNcdConfigurationManager::SetSsidL() |
|
111 */ |
|
112 void SetSsidL( const MCatalogsContext& aContext, |
|
113 HBufC8* aSsid ); |
|
114 |
|
115 /** |
|
116 * @see MNcdConfigurationManager::Ssid() |
|
117 */ |
|
118 const TDesC8& SsidL( const MCatalogsContext& aContext ); |
|
119 |
|
120 |
|
121 /** |
|
122 * @see MNcdConfigurationManager::ServerDetailsL() |
|
123 */ |
|
124 MNcdServerDetails& ServerDetailsL( |
|
125 const MCatalogsContext& aContext, |
|
126 const TDesC& aServerUri, |
|
127 const TDesC& aNamespace ); |
|
128 |
|
129 /** |
|
130 * @see MNcdConfigurationManager::ServerDetails() |
|
131 */ |
|
132 const MNcdServerDetails* ServerDetails( |
|
133 const MCatalogsContext& aContext, |
|
134 const TDesC& aServerUri, |
|
135 const TDesC& aNamespace ) const; |
|
136 |
|
137 /** |
|
138 * @see MNcdConfigurationManager::SaveConfigurationToDbL() |
|
139 */ |
|
140 void SaveConfigurationToDbL( |
|
141 const MCatalogsContext& aContext ); |
|
142 |
|
143 /** |
|
144 * @see MNcdConfigurationManager::ClearServerCapabilitiesL() |
|
145 */ |
|
146 virtual void ClearServerCapabilitiesL( |
|
147 const MCatalogsContext& aContext ); |
|
148 |
|
149 |
|
150 public: // From MNcdUserConfiguration |
|
151 |
|
152 /** |
|
153 * @see MNcdUserConfiguration::AddConfigurationL() |
|
154 */ |
|
155 void AddConfigurationL( const MCatalogsContext& aContext, |
|
156 CNcdKeyValuePair* aConfig ); |
|
157 |
|
158 /** |
|
159 * @see MNcdUserConfiguration::RemoveConfigurationL() |
|
160 */ |
|
161 TInt RemoveConfigurationL( const MCatalogsContext& aContext, |
|
162 const TDesC& aKey ); |
|
163 |
|
164 /** |
|
165 * @see MNcdUserConfiguration::ConfigurationsL() |
|
166 */ |
|
167 CNcdKeyValueMap* ConfigurationsLC( |
|
168 const MCatalogsContext& aContext ); |
|
169 |
|
170 |
|
171 /** |
|
172 * @see MNcdUserConfiguration::ConfigurationsL() |
|
173 */ |
|
174 CNcdKeyValueMap& ConfigurationsL( |
|
175 const MCatalogsContext& aContext, |
|
176 TNcdConfigurationCategory aCategory ); |
|
177 |
|
178 |
|
179 |
|
180 private: |
|
181 |
|
182 // Constructor |
|
183 CNcdConfigurationManager( CNcdGeneralManager& aGeneralManager ); |
|
184 |
|
185 // 2nd phase constructor |
|
186 void ConstructL(); |
|
187 |
|
188 private: |
|
189 |
|
190 // Generates a new client ID |
|
191 HBufC* GenerateClientIdLC() const; |
|
192 |
|
193 |
|
194 class CContextConfiguration; |
|
195 |
|
196 // Compares contexts |
|
197 static TBool MatchContexts( const CContextConfiguration& aFirst, |
|
198 const CContextConfiguration& aSecond ); |
|
199 |
|
200 TInt FindConfigurationL( const MCatalogsContext& aContext ) const; |
|
201 |
|
202 // Determines key's configuration category |
|
203 TNcdConfigurationCategory DetermineCategory( const TDesC& aKey ) const; |
|
204 |
|
205 |
|
206 CNcdKeyValueMap& ConfigurationByCategory( TInt aIndex, |
|
207 const TDesC& aKey ); |
|
208 |
|
209 CNcdKeyValueMap& ConfigurationByCategory( TInt aIndex, |
|
210 TNcdConfigurationCategory aCategory ); |
|
211 |
|
212 |
|
213 // Create a new context configuration for the context unless it exists |
|
214 // Returns index for the configuration in iConfigurations |
|
215 TInt CreateContextConfigurationL( |
|
216 const MCatalogsContext& aContext ); |
|
217 |
|
218 |
|
219 void SaveDataL( const TDesC& aId, |
|
220 NcdProviderDefines::TNcdDatabaseDataType aType, |
|
221 MNcdStorageDataItem& aDataItem ); |
|
222 |
|
223 void LoadDataL( const TDesC& aId, |
|
224 NcdProviderDefines::TNcdDatabaseDataType aType, |
|
225 MNcdStorageDataItem& aDataItem ); |
|
226 |
|
227 private: |
|
228 |
|
229 |
|
230 // Cached Context-specific data |
|
231 class CContextConfiguration : public CBase, public MNcdStorageDataItem |
|
232 { |
|
233 public: |
|
234 |
|
235 static CContextConfiguration* NewLC( |
|
236 const MCatalogsContext& aContext, |
|
237 const TDesC& aId ); |
|
238 |
|
239 // Only to be used with RPointerArray::Find |
|
240 static CContextConfiguration* FindNewL( |
|
241 const MCatalogsContext& aContext ); |
|
242 |
|
243 |
|
244 // Destructor |
|
245 ~CContextConfiguration(); |
|
246 |
|
247 // Returns details for the server. If the details have not been |
|
248 // set, creates new empty details |
|
249 MNcdServerDetails& ServerDetailsL( const TDesC& aServerUri, |
|
250 const TDesC& aNamespace ); |
|
251 |
|
252 // Returns details for the server. |
|
253 // Return NULL if details are not found |
|
254 CNcdServerDetails* ServerDetails( const TDesC& aServerUri, |
|
255 const TDesC& aNamespace ); |
|
256 |
|
257 |
|
258 // Clears the server details. |
|
259 void ClearServerDetails(); |
|
260 |
|
261 // Notifies the observers. |
|
262 void NotifyObserversL() const; |
|
263 |
|
264 /** |
|
265 * Adds an observer. |
|
266 * |
|
267 * @param aObserver The observer. |
|
268 */ |
|
269 void AddObserverL( MNcdConfigurationObserver& aObserver ); |
|
270 |
|
271 /** |
|
272 * Removes an observer. |
|
273 * |
|
274 * @param aObserver The observer. |
|
275 */ |
|
276 void RemoveObserver( MNcdConfigurationObserver& aObserver ); |
|
277 |
|
278 |
|
279 public: // MNcdStorageDataItem |
|
280 |
|
281 void ExternalizeL( RWriteStream& aStream ); |
|
282 void InternalizeL( RReadStream& aStream ); |
|
283 |
|
284 protected: |
|
285 |
|
286 // Constructor |
|
287 CContextConfiguration( const MCatalogsContext& aContext ); |
|
288 |
|
289 void ConstructL( const TDesC& aId ); |
|
290 |
|
291 public: |
|
292 |
|
293 // Context's family id |
|
294 TUid iFamilyId; |
|
295 |
|
296 // Client's ID |
|
297 HBufC* iId; |
|
298 |
|
299 // General configuration keys: master server address, etc. |
|
300 CNcdKeyValueMap* iConfigurationGeneral; |
|
301 |
|
302 // Client info configuration |
|
303 CNcdKeyValueMap* iConfigurationClientInfo; |
|
304 |
|
305 // Client's SSID |
|
306 HBufC8* iSsid; |
|
307 |
|
308 // Master server override received from the protocol |
|
309 CNcdServerAddress* iMasterServer; |
|
310 |
|
311 // Flag used to override MSA set by the client through |
|
312 // AddConfiguration |
|
313 TBool iUseHardcodedMasterServer; |
|
314 |
|
315 private: |
|
316 RPointerArray<CNcdServerDetails> iServerDetails; |
|
317 |
|
318 // Configuration observers. |
|
319 RPointerArray<MNcdConfigurationObserver> iObservers; |
|
320 }; |
|
321 |
|
322 |
|
323 private: // data |
|
324 |
|
325 CNcdGeneralManager& iGeneralManager; |
|
326 MNcdStorageManager& iStorageManager; |
|
327 |
|
328 // Cached configurations |
|
329 RPointerArray<CContextConfiguration> iConfigurations; |
|
330 }; |
|
331 |
|
332 |
|
333 #endif // M_NCDCONFIGURATIONMANAGER_H |