|
1 /* |
|
2 * Copyright (c) 2006-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: Parses XML content and stores data to storage |
|
15 |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CBSIMPORTXMLPARSER_H |
|
21 |
|
22 #define CBSIMPORTXMLPARSER_H |
|
23 |
|
24 |
|
25 |
|
26 // INCLUDE FILES |
|
27 |
|
28 #include <e32base.h> |
|
29 |
|
30 #include <f32file.h> |
|
31 |
|
32 #include <gmxmldocument.h> |
|
33 |
|
34 #include <rbsobjowningptrarray.h> |
|
35 |
|
36 #include <mbselement.h> |
|
37 |
|
38 |
|
39 |
|
40 class CMDXMLNode; |
|
41 |
|
42 class CBSImportStorageManager; |
|
43 |
|
44 |
|
45 |
|
46 // CLASS DEFINITION |
|
47 |
|
48 class CBSImportXMLParser : public CBase |
|
49 |
|
50 { |
|
51 |
|
52 private: // Definitions |
|
53 |
|
54 |
|
55 |
|
56 struct TImportBitmap |
|
57 |
|
58 { |
|
59 |
|
60 TInt iBitmapId; |
|
61 |
|
62 TInt iBitmapMaskId; |
|
63 |
|
64 TInt iSkinId; |
|
65 |
|
66 TInt iSkinMaskId; |
|
67 |
|
68 }; |
|
69 |
|
70 |
|
71 |
|
72 enum TXMLBaseTagTypes |
|
73 |
|
74 { |
|
75 |
|
76 EBrandUnknown, |
|
77 |
|
78 EBrandAppID, |
|
79 |
|
80 EBrandID, |
|
81 |
|
82 EBrandLanguage, |
|
83 |
|
84 EBrandVersion, |
|
85 |
|
86 EBrandElement |
|
87 |
|
88 }; |
|
89 |
|
90 |
|
91 |
|
92 public: |
|
93 |
|
94 |
|
95 |
|
96 static CBSImportXMLParser* NewL( CBSImportStorageManager* aStorage ); |
|
97 |
|
98 |
|
99 |
|
100 static CBSImportXMLParser* NewLC( CBSImportStorageManager* aStorage ); |
|
101 |
|
102 |
|
103 |
|
104 ~CBSImportXMLParser(); |
|
105 |
|
106 |
|
107 |
|
108 /** |
|
109 |
|
110 * Parse XML document and store data to storage |
|
111 |
|
112 * |
|
113 |
|
114 * @since S60 3.2 |
|
115 |
|
116 * @param aDocument XML document to parse |
|
117 |
|
118 * @return none |
|
119 |
|
120 */ |
|
121 |
|
122 void ParseDocumentL( CMDXMLDocument& aDocument ); |
|
123 |
|
124 |
|
125 |
|
126 private: |
|
127 |
|
128 |
|
129 |
|
130 CBSImportXMLParser( CBSImportStorageManager* aStorage ); |
|
131 |
|
132 |
|
133 |
|
134 void ConstructL(); |
|
135 |
|
136 |
|
137 |
|
138 /** |
|
139 |
|
140 * Parses full the base element <branding> and it's child elements. |
|
141 |
|
142 * |
|
143 |
|
144 * @since S60 v3.2 |
|
145 |
|
146 * @param aElement to parse |
|
147 |
|
148 */ |
|
149 |
|
150 void ParseDocumentBaseL( CMDXMLNode* aElement ); |
|
151 |
|
152 |
|
153 |
|
154 /** |
|
155 |
|
156 * Analyzes a child node of <branding> and stores the value to storage. |
|
157 |
|
158 * Ignores undetected XML nodes. |
|
159 |
|
160 * |
|
161 |
|
162 * @since S60 v3.2 |
|
163 |
|
164 * @param aElement to parse |
|
165 |
|
166 */ |
|
167 |
|
168 void AnalyzeNodeL( CMDXMLNode* aNode ); |
|
169 |
|
170 |
|
171 |
|
172 /** |
|
173 |
|
174 * Converts a given node to TXMLBaseTagTypes. This can handle all |
|
175 |
|
176 * child nodes of <branding> |
|
177 |
|
178 * |
|
179 |
|
180 * @since S60 v3.2 |
|
181 |
|
182 * @param aNode node to check |
|
183 |
|
184 * @return corresponding TXMLBaseTagTypes value (or EBrandUnknown). |
|
185 |
|
186 */ |
|
187 |
|
188 TXMLBaseTagTypes SolveTagTypeL( CMDXMLNode* aNode ); |
|
189 |
|
190 |
|
191 |
|
192 /** |
|
193 |
|
194 * Parses full <element> node. Returns a newly constructed MBSElement |
|
195 |
|
196 * from the content of teh node. |
|
197 |
|
198 * Ownership is transferred! |
|
199 |
|
200 * |
|
201 |
|
202 * @since S60 v3.2 |
|
203 |
|
204 * @param aNode <element> node |
|
205 |
|
206 * @return Concrete element constructed from node. |
|
207 |
|
208 */ |
|
209 |
|
210 MBSElement* ParseBrandElementL( CMDXMLNode* aNode ); |
|
211 |
|
212 |
|
213 |
|
214 /** |
|
215 |
|
216 * Converts elements type attribute value to TBSElementType |
|
217 |
|
218 * (see MBSElement). |
|
219 |
|
220 * |
|
221 |
|
222 * @since S60 v3.2 |
|
223 |
|
224 * @param aType value of type attribute |
|
225 |
|
226 * @return corresponding TBrandingElementType value or KErrNotFound. |
|
227 |
|
228 */ |
|
229 |
|
230 TInt SolveElementType( const TDesC& aType ); |
|
231 |
|
232 |
|
233 |
|
234 /** |
|
235 |
|
236 * Search a child node with name inside another node. Returns the first match |
|
237 |
|
238 * |
|
239 |
|
240 * @since S60 v3.2 |
|
241 |
|
242 * @param aNode parent node to search |
|
243 |
|
244 * @param aTagName Child nodes name |
|
245 |
|
246 * @return found node or NULL if not found; |
|
247 |
|
248 */ |
|
249 |
|
250 CMDXMLNode* SearchChild( CMDXMLNode* aNode, const TDesC& aChildName ); |
|
251 |
|
252 |
|
253 |
|
254 /** |
|
255 |
|
256 * Parse value from <element_value> tag. Leaves if parse fails. |
|
257 |
|
258 * Ownership is transferred to caller (NodeTextLC) |
|
259 |
|
260 * |
|
261 |
|
262 * @since S60 3.2 |
|
263 |
|
264 * @param aNode XML node to parse. should be <element_value>. |
|
265 |
|
266 * @return value from <element_value> |
|
267 |
|
268 */ |
|
269 |
|
270 HBufC* NodeTextLC( CMDXMLNode* elNode ); |
|
271 |
|
272 TInt NodeIntL ( CMDXMLNode* elNode ); |
|
273 |
|
274 |
|
275 |
|
276 /** |
|
277 |
|
278 * Parse <element> tag for given value type. Leaves if parsing fails. |
|
279 |
|
280 * |
|
281 |
|
282 * @since S60 3.2 |
|
283 |
|
284 * @param aNode XML node to parse |
|
285 |
|
286 * @param aValue Parsed value |
|
287 |
|
288 * @return none |
|
289 |
|
290 */ |
|
291 |
|
292 void DoParseIntegerL( CMDXMLNode* aNode, TInt& aValue ); |
|
293 |
|
294 void DoParseTextL ( CMDXMLNode* aNode, HBufC*& aText ); |
|
295 |
|
296 void DoParseFileL ( CMDXMLNode* aNode, HBufC*& aText ); |
|
297 |
|
298 void DoParseListL ( CMDXMLNode* aNode, RBSObjOwningPtrArray<MBSElement>& aElementArray ); |
|
299 |
|
300 void DoParseBitmapL ( CMDXMLNode* aNode, CBSBitmap*& aBitmap ); |
|
301 |
|
302 |
|
303 |
|
304 private: // Data |
|
305 |
|
306 |
|
307 |
|
308 // Not owned. Storage where to put parsed elements |
|
309 |
|
310 CBSImportStorageManager* iStorage; |
|
311 |
|
312 }; |
|
313 |
|
314 |
|
315 |
|
316 #endif //CBSIMPORTXMLPARSER_H |
|
317 |