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