|
1 /* |
|
2 * Copyright (c) 2007-2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_HNMULMODELPROVIDER_H |
|
21 #define C_HNMULMODELPROVIDER_H |
|
22 |
|
23 |
|
24 #include <xmlengdom.h> |
|
25 #include <bautils.h> |
|
26 #include <e32hashtab.h> |
|
27 |
|
28 class CHnXmlModelCache; |
|
29 |
|
30 /** |
|
31 * Xml Model Provider |
|
32 * |
|
33 * Parses suites definitions in xml and makes changes in model. |
|
34 * |
|
35 * @lib hnmetadatamodel |
|
36 * @since S60 5.0 |
|
37 * @ingroup group_hnmetadatamodel |
|
38 */ |
|
39 NONSHARABLE_CLASS(CHnXmlModelProvider) : public CActive |
|
40 { |
|
41 public: |
|
42 /** |
|
43 * Standard factory method. |
|
44 * |
|
45 * @since S60 v5.0 |
|
46 * @return Fully constructed object. |
|
47 */ |
|
48 IMPORT_C static CHnXmlModelProvider* NewL(); |
|
49 |
|
50 /** |
|
51 * Standard factory method. |
|
52 * |
|
53 * @since S60 v5.0 |
|
54 * @return Fully constructed object. |
|
55 */ |
|
56 IMPORT_C static CHnXmlModelProvider* NewLC(); |
|
57 |
|
58 /** |
|
59 * Standard virtual destructor. |
|
60 */ |
|
61 IMPORT_C virtual ~CHnXmlModelProvider(); |
|
62 |
|
63 /** |
|
64 * @see CAsctive::DoCancel |
|
65 */ |
|
66 void DoCancel(); |
|
67 |
|
68 /** |
|
69 * Services the suite synchronization steps according to class iterator. |
|
70 * |
|
71 * @see CAsctive::RunL |
|
72 */ |
|
73 void RunL(); |
|
74 |
|
75 private: |
|
76 |
|
77 /** |
|
78 * ReadFileLC reads file. |
|
79 * |
|
80 * @since S60 v5.0 |
|
81 * @param aPath Path to a file. |
|
82 * @return Content of the file. |
|
83 */ |
|
84 HBufC8* ReadFileLC(const TDesC& aPath); |
|
85 |
|
86 /** |
|
87 * Parses a document. |
|
88 * |
|
89 * @since S60 v5.0 |
|
90 * @param aDoc A document to be parsed. |
|
91 * @return Xml document. |
|
92 */ |
|
93 RXmlEngDocument ParseDocL( const TDesC8& aDoc ); |
|
94 |
|
95 |
|
96 /** |
|
97 * Builds root of xml model from suite definition. |
|
98 * |
|
99 * @since S60 v5.0 |
|
100 * @param aSuiteName Suite name. |
|
101 * @param aXmlDoc XLM model of the suite. |
|
102 * @return Error code. |
|
103 */ |
|
104 TInt CollectSuiteL( const TDesC& aSuiteName, RXmlEngDocument& aXmlDoc ); |
|
105 |
|
106 /** |
|
107 * appends items to suite in model, |
|
108 * |
|
109 * @since S60 v5.0 |
|
110 * @param aSuiteName Name of suite to append items to. |
|
111 * @param aXmlDoc XLM model of the suite. |
|
112 */ |
|
113 void CollectItemsL(const TDesC& aSuiteName, RXmlEngDocument& aXmlDoc ); |
|
114 |
|
115 /** |
|
116 * Copies suites and items definitions to working dir. |
|
117 * |
|
118 * @since S60 v5.0 |
|
119 * @return Error code. |
|
120 */ |
|
121 TBool SynchronizeSuitesL(); |
|
122 |
|
123 /** |
|
124 * Creates model from suite definition. |
|
125 * |
|
126 * @since S60 v5.0 |
|
127 * @param aStr Name of suite. |
|
128 * @param aXmlDoc XML model of the suite. |
|
129 */ |
|
130 void CreateModelL( const TDesC& aStr, RXmlEngDocument& aXmlDoc ); |
|
131 |
|
132 /** |
|
133 * Changes event names to ids. |
|
134 * |
|
135 * @since S60 v5.0 |
|
136 * @param aElement Xml element. |
|
137 */ |
|
138 void ChangeEventNamesToIdsL( TXmlEngElement& aElement ); |
|
139 |
|
140 /** |
|
141 * Changes event names to items in all the children. |
|
142 * |
|
143 * @see ChangeEventNamesToIdsL |
|
144 * @since S60 v5.0 |
|
145 * @param aElement Xml element. |
|
146 */ |
|
147 void ChangeEventsToIdsInChildrenL( |
|
148 TXmlEngElement & aElement ); |
|
149 |
|
150 #ifdef _DEBUG |
|
151 /** |
|
152 * Logs event mapping. |
|
153 * |
|
154 * @since S60 v5.0 |
|
155 * @param aEventMap Event map. |
|
156 */ |
|
157 void LogEventMapping( const RHashMap<HBufC*, TInt>& aEventMap ); |
|
158 #endif |
|
159 |
|
160 public: |
|
161 |
|
162 /** |
|
163 * Parses a document. |
|
164 * |
|
165 * @param aPath Path to a file. |
|
166 * @return RXmlEngDocument. |
|
167 */ |
|
168 RXmlEngDocument ParseFileL( const TDesC& aPath ); |
|
169 |
|
170 /** |
|
171 * Resets cached models. |
|
172 */ |
|
173 void ResetCache(); |
|
174 |
|
175 /** |
|
176 * Reparses a document. |
|
177 */ |
|
178 IMPORT_C void ReloadModelL(); |
|
179 |
|
180 /** |
|
181 * Parses a document - searching proper suite. |
|
182 * |
|
183 * @param aStr Name of the model. |
|
184 * @param aXmlDoc A reference to document of RXmlEngDocument class; |
|
185 * @return Error code. KErrNone if model found. |
|
186 */ |
|
187 IMPORT_C TInt GetModelL( const TDesC& aStr, RXmlEngDocument& aXmlDoc ); |
|
188 |
|
189 /** |
|
190 * Parses a document. |
|
191 * |
|
192 * @param aEventName Event name. |
|
193 * @return Event id. |
|
194 */ |
|
195 TInt GetNewEventId( HBufC* aEventName ); |
|
196 |
|
197 /** |
|
198 * Check if suite exists. |
|
199 * |
|
200 * @since S60 5.0 |
|
201 * @param aSuite Suite name. |
|
202 * @return ETrue if suite exists, otherwise EFalse. |
|
203 */ |
|
204 TBool SuiteExistsL( const TDesC& aSuite ); |
|
205 |
|
206 private: |
|
207 |
|
208 /** |
|
209 * Invoked after asynchronous synchronization is finished. |
|
210 */ |
|
211 void SynchronizationFinishedL(); |
|
212 |
|
213 /** |
|
214 * Sets up normal path to suites. |
|
215 * |
|
216 * @param aPath Path to be searched for suites. |
|
217 */ |
|
218 void SearchPathForSuitesL( const TDesC& aPath ); |
|
219 |
|
220 /** |
|
221 * Sets up normal path to suites. |
|
222 */ |
|
223 void SetupSuitePathL(); |
|
224 |
|
225 /** |
|
226 * Sets up fail sage path to suites. |
|
227 */ |
|
228 void SetupFailSafeSuitePathL(); |
|
229 |
|
230 /** |
|
231 * Standard C++ constructor. |
|
232 */ |
|
233 CHnXmlModelProvider(); |
|
234 |
|
235 /** |
|
236 * Standard symbian 2nd phase constructor. |
|
237 */ |
|
238 void ConstructL(); |
|
239 |
|
240 /** |
|
241 * Finds drive letter where suite definition is. |
|
242 * |
|
243 * @since S60 v5.0 |
|
244 * @return Error code |
|
245 */ |
|
246 void CheckDrivesL(); |
|
247 |
|
248 |
|
249 #ifdef _DEBUG |
|
250 private: |
|
251 void LogSuiteModel( const TDesC& aName, |
|
252 RXmlEngDocument& aDoc ); |
|
253 #endif // _DEBUG |
|
254 |
|
255 private: // data |
|
256 |
|
257 /** |
|
258 * Xml DOM implementation. |
|
259 */ |
|
260 RXmlEngDOMImplementation iDomImpl; |
|
261 |
|
262 /** |
|
263 * Xml DOM parser. |
|
264 */ |
|
265 RXmlEngDOMParser iDomParser; |
|
266 |
|
267 /** |
|
268 * File server session |
|
269 */ |
|
270 RFs iFs; |
|
271 |
|
272 /** |
|
273 * File manager |
|
274 */ |
|
275 CFileMan* iFileMan; |
|
276 |
|
277 /** |
|
278 * List containing names of suites (suite name is same as dir name) |
|
279 * that should be installed from all drives |
|
280 */ |
|
281 RHashSet< HBufC* > iInstSuites; |
|
282 |
|
283 /** |
|
284 * Event map. |
|
285 */ |
|
286 RHashMap< HBufC*, TInt > iEventMap; |
|
287 |
|
288 /** |
|
289 * Main path. |
|
290 */ |
|
291 RBuf iPath; |
|
292 |
|
293 /** |
|
294 * Cached suites. |
|
295 */ |
|
296 CHnXmlModelCache* iCache; |
|
297 |
|
298 /** |
|
299 * Own. Iterator used in synchronisation. |
|
300 * Indicates next suite name to be synchronised. |
|
301 */ |
|
302 THashSetIter<HBufC*>* iSuiteSetIterator; |
|
303 |
|
304 /** |
|
305 * ETrue if suite files on the c: drive were updated during the |
|
306 * last synchronization. New suite files also count as updated. |
|
307 * EFalse if the last synchronization did not alter any files |
|
308 * on the c: drive. |
|
309 */ |
|
310 TBool iSuiteFilesUpdated; |
|
311 |
|
312 }; |
|
313 #endif // C_HNMULMODELPROVIDER_H |