1 /* |
|
2 * Copyright (c) 2007 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: XML Parser for opaque data field of Plug-ins. This field |
|
15 * contains information about depdendencies and ordering. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef DIAGPLUGINLOADERDEPENDENCYPARSER_H |
|
21 #define DIAGPLUGINLOADERDEPENDENCYPARSER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <xml/contenthandler.h> |
|
26 |
|
27 // FORWARD DECLARATION |
|
28 class CDesC16ArrayFlat; |
|
29 |
|
30 namespace Xml |
|
31 { |
|
32 class CParser; |
|
33 class RAttribute; |
|
34 } |
|
35 |
|
36 namespace DiagPluginPool |
|
37 { |
|
38 /** |
|
39 * Plugin Loader Depdenency Parser |
|
40 * Parse dependency information and other data out of plug-ins via the |
|
41 * opaque_data field. |
|
42 * |
|
43 * @since S60 v5.0 |
|
44 */ |
|
45 NONSHARABLE_CLASS( CDependencyParser ) : public CBase, |
|
46 public Xml::MContentHandler |
|
47 { |
|
48 public: |
|
49 |
|
50 /** |
|
51 * Two-phased constructor. |
|
52 * |
|
53 * @return New instance of CDependencyParser |
|
54 */ |
|
55 static CDependencyParser* NewL(); |
|
56 |
|
57 /** |
|
58 * Two-phased constructor. |
|
59 * |
|
60 * @return New instance of CDependencyParser and pop onto cleanup stack |
|
61 */ |
|
62 static CDependencyParser* NewLC(); |
|
63 |
|
64 /** |
|
65 * Destructor. |
|
66 */ |
|
67 virtual ~CDependencyParser(); |
|
68 |
|
69 /** |
|
70 * Parse out Plug-in Information from XML. |
|
71 * |
|
72 * @param aOpaqueData Contains text with opaque data for Dependencies/Order Number |
|
73 * @param aDefaultData Contains text with default data for Parent UID |
|
74 * Leave Codes: KErrNone Valid data was parsed |
|
75 * KErrNotFound No valid fields found |
|
76 * KErrArgument Text is NULL or empty |
|
77 * KErrCorrupt XML was determined to be corrupt |
|
78 * |
|
79 */ |
|
80 void ParseL( const TDesC8& aOpaqueData, const TDesC8& aDefaultData ); |
|
81 |
|
82 /** |
|
83 * Return parsed order number |
|
84 * |
|
85 * @return orrder number |
|
86 */ |
|
87 TInt GetOrderNumber() const; |
|
88 |
|
89 /** |
|
90 * Return parsed parent UID |
|
91 * |
|
92 * @return parent UID |
|
93 */ |
|
94 const TUid& GetParentUid() const; |
|
95 |
|
96 /** |
|
97 * Return parsed service provided. Ownership is transferred to the caller |
|
98 * |
|
99 * @return service provided |
|
100 */ |
|
101 HBufC* GetServiceProvided(); |
|
102 |
|
103 /** |
|
104 * Return parsed services required. Caller assumes ownership. |
|
105 * |
|
106 * @return services required |
|
107 */ |
|
108 CDesC16ArrayFlat* GetServicesRequired(); |
|
109 |
|
110 private: // from Base Class Xml::MContentHandler |
|
111 /** |
|
112 * Callback from XML Parser that indicates a Plugin element is starting |
|
113 * |
|
114 * @param aElement handle to element's details |
|
115 * @param aAttributes contains attributes for element |
|
116 * @param aErrorCode indicates error, if any |
|
117 */ |
|
118 virtual void OnStartElementL( const Xml::RTagInfo& aElement, |
|
119 const Xml::RAttributeArray& aAttributes, |
|
120 TInt aErrorCode ); |
|
121 |
|
122 /** |
|
123 * Callback from XML Parser that indicates the end of a plug-in element |
|
124 * |
|
125 * @param aElement handle to element's details |
|
126 * @param aErrorCode indicates error, if any |
|
127 */ |
|
128 virtual void OnEndElementL( const Xml::RTagInfo& aElement, TInt aErrorCode ); |
|
129 |
|
130 /** |
|
131 * Callback from XML Parser that indicates content in an XML element |
|
132 * |
|
133 * @param aBytes simple stream of data indicating the content |
|
134 * @param aErrorCode indicates error, if any |
|
135 */ |
|
136 virtual void OnContentL( const TDesC8& aBytes, TInt aErrorCode ); |
|
137 |
|
138 /** |
|
139 * Callback from XML Parser that indicates a parsing error |
|
140 * |
|
141 * @param aErrorCode indicates error, if any |
|
142 * Note: The XmlFramework has been allocated error codes in the range: -17550 to -17599 |
|
143 */ |
|
144 virtual void OnError( TInt aErrorCode ); |
|
145 |
|
146 // Unused virtual member functions |
|
147 |
|
148 /** |
|
149 * @see Xml::MContentHandler::OnStartDocumentL |
|
150 */ |
|
151 virtual void OnStartDocumentL( const Xml::RDocumentParameters& aDocParam, TInt aErrorCode ); |
|
152 |
|
153 /** |
|
154 * @see Xml::MContentHandler::OnEndDocumentL |
|
155 */ |
|
156 virtual void OnEndDocumentL( TInt aErrorCode ); |
|
157 |
|
158 /** |
|
159 * @see Xml::MContentHandler::OnEndDocumentL |
|
160 */ |
|
161 virtual void OnStartPrefixMappingL( const RString& aPrefix, |
|
162 const RString& aUri, |
|
163 TInt aErrorCode ); |
|
164 /** |
|
165 * @see Xml::MContentHandler::OnEndDocumentL |
|
166 */ |
|
167 virtual void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode ); |
|
168 |
|
169 /** |
|
170 * @see Xml::MContentHandler::OnEndDocumentL |
|
171 */ |
|
172 virtual void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode ); |
|
173 |
|
174 /** |
|
175 * @see Xml::MContentHandler::OnEndDocumentL |
|
176 */ |
|
177 virtual void OnSkippedEntityL( const RString& aName, TInt aErrorCode ); |
|
178 |
|
179 /** |
|
180 * @see Xml::MContentHandler::OnEndDocumentL |
|
181 */ |
|
182 virtual void OnProcessingInstructionL( const TDesC8& aTarget, |
|
183 const TDesC8& aData, |
|
184 TInt aErrorCode ); |
|
185 /** |
|
186 * @see Xml::MContentHandler::OnEndDocumentL |
|
187 */ |
|
188 virtual void OnExtensionL( const RString& aData, TInt aToken, TInt aErrorCode ); |
|
189 |
|
190 /** |
|
191 * @see Xml::MContentHandler::OnEndDocumentL |
|
192 */ |
|
193 virtual TAny* GetExtendedInterface( const TInt32 aUid ); |
|
194 |
|
195 private: // private utility functions |
|
196 |
|
197 /** |
|
198 * Simple utility function to allocate and pop onto the stack a 16 bit buffer descriptor |
|
199 * from an 8 bit descriptor. |
|
200 * |
|
201 * @param aDes 8 bit descriptor to be converted to 16 bits |
|
202 * @return Newly allocated 16-bit buffer containing converted contents of aDes |
|
203 */ |
|
204 HBufC* Convert8BitTo16BitBufferLC( const TDesC8& aDes ) const; |
|
205 |
|
206 /** |
|
207 * Parse a numeric attribute from XML text with specific notation for diagnostics framework |
|
208 * plug-ins. |
|
209 * |
|
210 * @param aAttribute XML attribute |
|
211 * @param aNumericAttribute Parsed out integer |
|
212 * @return Indicates whether or not attribute was parsed correctly |
|
213 */ |
|
214 TBool ParseNumericAttribute( const Xml::RAttribute& aAttribute, TInt& aNumericAttribute ); |
|
215 |
|
216 /** |
|
217 * Parse a string attribute from XML text with specific notation for diagnostics framework |
|
218 * plug-ins. |
|
219 * |
|
220 * @param aAttribute XML attribute |
|
221 * @param aStringAttribute Parsed out string |
|
222 * @return Indicates whether or not attribute was parsed correctly |
|
223 */ |
|
224 TBool ParseStringAttributeL( const Xml::RAttribute& aAttribute, HBufC*& aStringAttribute ); |
|
225 |
|
226 /** |
|
227 * Parse a hex UID from given descriptor |
|
228 * |
|
229 * @param aSource String containing UID |
|
230 * @param aTarget Parsed out UID |
|
231 * @return Error Code |
|
232 */ |
|
233 TInt ParseToUid( const TDesC8& aSource, TUid& aTarget ); |
|
234 |
|
235 /** |
|
236 * Parse a hex UID from given descriptor |
|
237 * |
|
238 * @param aAttributes List of attributes to parse |
|
239 * @param aFoundTag Reference to some class variable that indicates if a given tag has been found. |
|
240 * @return ETrue==XML OK/EFalse==XML not validated |
|
241 */ |
|
242 TBool ValidateXmlTag( const Xml::RAttributeArray& aAttributes, TBool& aFoundTag ); |
|
243 |
|
244 /** |
|
245 * Reset all data |
|
246 * |
|
247 */ |
|
248 void ResetL(); |
|
249 |
|
250 private: // private constructors |
|
251 |
|
252 /** |
|
253 * Construct a CDependencyParser object |
|
254 * |
|
255 */ |
|
256 CDependencyParser(); |
|
257 |
|
258 /** |
|
259 * 2nd phase constructor |
|
260 * |
|
261 */ |
|
262 void ConstructL(); |
|
263 |
|
264 private: // data |
|
265 |
|
266 /** |
|
267 * Pointer to XML Parser from SDK |
|
268 * owns |
|
269 */ |
|
270 Xml::CParser* iParser; |
|
271 |
|
272 /** |
|
273 * Error code indicates error in parsing |
|
274 */ |
|
275 TInt iParseStatus; |
|
276 |
|
277 /** |
|
278 * Parsed order number |
|
279 */ |
|
280 TInt iOrderNumber; |
|
281 |
|
282 /** |
|
283 * Parsed provided service |
|
284 * owns |
|
285 */ |
|
286 HBufC* iServiceProvided; |
|
287 |
|
288 /** |
|
289 * Parsed required service |
|
290 * owns |
|
291 */ |
|
292 CDesC16ArrayFlat* iServicesRequired; |
|
293 |
|
294 /** |
|
295 * Parsed parent uid |
|
296 */ |
|
297 TUid iParentUid; |
|
298 |
|
299 /** |
|
300 * Indicates that parsing is happening within services required blocks |
|
301 */ |
|
302 TBool iParsingServicesRequired; |
|
303 |
|
304 /** |
|
305 * Indicates that there was some problem with the parsing |
|
306 */ |
|
307 TBool iBadXML; |
|
308 |
|
309 /** |
|
310 * Indicates that root node has been found and we are inside it |
|
311 */ |
|
312 TBool iInsideRootNode; |
|
313 |
|
314 /** |
|
315 * Indicates that order number has been found |
|
316 */ |
|
317 TBool iFoundOrderNumber; |
|
318 |
|
319 /** |
|
320 * Indicates that services provided has been found |
|
321 */ |
|
322 TBool iFoundServiceProvided; |
|
323 |
|
324 /** |
|
325 * Indicates that services required has been found |
|
326 */ |
|
327 TBool iFoundServicesRequired; |
|
328 |
|
329 /** |
|
330 * Indicates that parser has been run at least once |
|
331 */ |
|
332 TBool iHasBeenRun; |
|
333 |
|
334 }; |
|
335 |
|
336 } // namespace DiagPluginPool |
|
337 |
|
338 #endif // DIAGPLUGINLOADERDEPENDENCYPARSER_H |
|
339 |
|
340 // End of File |
|
341 |
|