|
1 /* |
|
2 * Copyright (c) 2007-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: Declarition of CAcpXmlHandler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef _ACPXMLHANDLER |
|
20 #define _ACPXMLHANDLER |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> |
|
24 #include <xml/parser.h> |
|
25 #include <xml/parserfeature.h> |
|
26 #include <xml/contenthandler.h> |
|
27 |
|
28 using namespace Xml; |
|
29 |
|
30 class CAcpProvider; |
|
31 class MAcpXmlHandlerObserver; |
|
32 |
|
33 /** |
|
34 * CAcpXmlHandler class |
|
35 * Declarition of CAcpXmlHandler. |
|
36 * |
|
37 * @lib accountcreationplugin.lib |
|
38 * @since S60 v3.2 |
|
39 */ |
|
40 NONSHARABLE_CLASS( CAcpXmlHandler ) : public CActive, MContentHandler |
|
41 { |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Two-phased constructor. |
|
46 * |
|
47 * @param aObserver for notifying xml events |
|
48 */ |
|
49 static CAcpXmlHandler* NewL( MAcpXmlHandlerObserver& aObserver ); |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 * |
|
54 * @param aObserver for notifying xml events |
|
55 */ |
|
56 static CAcpXmlHandler* NewLC( MAcpXmlHandlerObserver& aObserver ); |
|
57 |
|
58 /** |
|
59 * Destructor. |
|
60 */ |
|
61 virtual ~CAcpXmlHandler(); |
|
62 |
|
63 /** |
|
64 * Starts parsing xml with given filename. |
|
65 * Function leaves on failure. |
|
66 * |
|
67 * @since S60 v3.2 |
|
68 * @param aFilename for file to be parsed |
|
69 */ |
|
70 void StartParsingL( const TFileName& aFilename ); |
|
71 |
|
72 /** |
|
73 * Returns provider information referenced by index. |
|
74 * |
|
75 * @since S60 v3.2 |
|
76 * @param aIndex for provider list index |
|
77 * @return reference to provider information |
|
78 */ |
|
79 const CAcpProvider& ProviderFromIndexL( TInt aIndex ) const; |
|
80 |
|
81 private: |
|
82 |
|
83 CAcpXmlHandler( MAcpXmlHandlerObserver& aObserver ); |
|
84 void ConstructL(); |
|
85 |
|
86 /** |
|
87 * Handles finished provider and notifies observer. |
|
88 * |
|
89 * @since S60 v3.2 |
|
90 */ |
|
91 void HandleFinishedProviderL(); |
|
92 |
|
93 // from base class CActive |
|
94 |
|
95 /** |
|
96 * From CActive. |
|
97 * Cancels an outstanding request. |
|
98 * |
|
99 * @since S60 v3.2 |
|
100 */ |
|
101 void DoCancel(); |
|
102 |
|
103 /** |
|
104 * From CActive. |
|
105 * Handles request completion event. |
|
106 * |
|
107 * @since S60 v3.2 |
|
108 */ |
|
109 void RunL(); |
|
110 |
|
111 // from base class MContentHandler |
|
112 |
|
113 /** |
|
114 * From MContentHandler. |
|
115 * Callback to indicate the start of the document. |
|
116 * |
|
117 * @since S60 v3.2 |
|
118 * @param aDocParam Specifies the various parameters of the document. |
|
119 * @param aErrorCode Error code. |
|
120 */ |
|
121 void OnStartDocumentL( const RDocumentParameters &aDocParam, |
|
122 TInt aErrorCode ); |
|
123 |
|
124 /** |
|
125 * From MContentHandler. |
|
126 * Callback to indicate the end of the document. |
|
127 * |
|
128 * @since S60 v3.2 |
|
129 * param aErrorCode Error code. |
|
130 */ |
|
131 void OnEndDocumentL( TInt aErrorCode ); |
|
132 |
|
133 /** |
|
134 * From MContentHandler. |
|
135 * Callback to indicate an element has been parsed. |
|
136 * |
|
137 * @since S60 v3.2 |
|
138 * @param aElement Handle to the element's details. |
|
139 * @param aAttributes Attributes for the element. |
|
140 * @param aErrorCode Error code. |
|
141 */ |
|
142 void OnStartElementL( const RTagInfo &aElement, |
|
143 const RAttributeArray &aAttributes, |
|
144 TInt aErrorCode ); |
|
145 |
|
146 /** |
|
147 * From MContentHandler. |
|
148 * Callback to indicate the end of the element has been reached. |
|
149 * |
|
150 * @since S60 v3.2 |
|
151 * @param Handle to the element's details. |
|
152 * @param aErrorCode Error code. |
|
153 */ |
|
154 void OnEndElementL( const RTagInfo &aElement, TInt aErrorCode ); |
|
155 |
|
156 /** |
|
157 * From MContentHandler. |
|
158 * Callback that sends the content of the element. |
|
159 * Not all the content may be returned in one go. The data may be sent |
|
160 * in chunks. When an OnEndElementL is received this means there is no |
|
161 * more content to be sent. |
|
162 * |
|
163 * @since S60 v3.2 |
|
164 * @param aBytes Raw content data for the element. |
|
165 * @param aErrorCode Error code. |
|
166 */ |
|
167 void OnContentL( const TDesC8 &aBytes, TInt aErrorCode ); |
|
168 |
|
169 /** |
|
170 * From MContentHandler. |
|
171 * Notification of the beginning of the |
|
172 * scope of a prefix-URI Namespace mapping. |
|
173 * Not used but here because of inheritance. |
|
174 * |
|
175 * @since S60 v3.2 |
|
176 * @param aPrefix Namespace prefix being declared. |
|
177 * @param aUri Namespace URI the prefix is mapped to. |
|
178 * @param aErrorCode Error code. |
|
179 */ |
|
180 void OnStartPrefixMappingL( const RString& /*aPrefix*/, |
|
181 const RString& /*aUri*/, TInt /*aErrorCode*/ ); |
|
182 |
|
183 /** |
|
184 * From MContentHandler. |
|
185 * Notification of the end of the scope of a prefix-URI mapping. |
|
186 * Not used but here because of inheritance. |
|
187 * |
|
188 * @since S60 v3.2 |
|
189 * @param aPrefix Namespace prefix that was mapped. |
|
190 * @param aErrorCode Error code. |
|
191 */ |
|
192 void OnEndPrefixMappingL( const RString& /*aPrefix*/, |
|
193 TInt /*aErrorCode*/ ); |
|
194 |
|
195 /** |
|
196 * From MContentHandler. |
|
197 * Notification of ignorable whitespace in element content. |
|
198 * Not used but here because of inheritance. |
|
199 * |
|
200 * @since S60 v3.2 |
|
201 * @param aBytes Ignored bytes from the document being parsed. |
|
202 * @param aErrorCode Error code. |
|
203 */ |
|
204 void OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/, |
|
205 TInt /*aErrorCode*/ ); |
|
206 |
|
207 /** |
|
208 * From MContentHandler. |
|
209 * Notification of a skipped entity. |
|
210 * Not used but here because of inheritance. |
|
211 * |
|
212 * @since S60 v3.2 |
|
213 * @param aName Name of the skipped entity. |
|
214 * @param aErrorCode Error code. |
|
215 */ |
|
216 void OnSkippedEntityL( |
|
217 const RString& /*aName*/, |
|
218 TInt /*aErrorCode*/ ); |
|
219 |
|
220 /** |
|
221 * From MContentHandler. |
|
222 * Receive notification of a processing instruction. |
|
223 * Not used but here because of inheritance. |
|
224 * |
|
225 * @since S60 v3.2 |
|
226 * @param aTarget Processing instruction target. |
|
227 * @param aData Processing instruction data. If empty none was supplied. |
|
228 * @param aErrorCode Error code. |
|
229 */ |
|
230 void OnProcessingInstructionL( |
|
231 const TDesC8& /*aTarget*/, |
|
232 const TDesC8& /*aData*/, |
|
233 TInt /*aErrorCode*/ ); |
|
234 |
|
235 /** |
|
236 * From MContentHandler. |
|
237 * Indicates an error has occurred. |
|
238 * |
|
239 * @since S60 v3.2 |
|
240 * @param aErrorCode Error code. |
|
241 */ |
|
242 void OnError( TInt aErrorCode ); |
|
243 |
|
244 /** |
|
245 * From MContentHandler. |
|
246 * Obtains the interface matching the specified UID. |
|
247 * Not used but here because of inheritance (always returns NULL). |
|
248 * |
|
249 * @since S60 v3.2 |
|
250 * @param aUid UID identifying the required interface. |
|
251 */ |
|
252 TAny* GetExtendedInterface( const TInt32 /*aUid*/ ); |
|
253 |
|
254 private: // data |
|
255 |
|
256 /** |
|
257 * Reference to observer. |
|
258 * Not own. |
|
259 */ |
|
260 MAcpXmlHandlerObserver& iObserver; |
|
261 |
|
262 /** |
|
263 * Handle to parser object. |
|
264 * Own. |
|
265 */ |
|
266 CParser* iParser; |
|
267 |
|
268 /** |
|
269 * Handle to File Server. |
|
270 */ |
|
271 RFs iFileServer; |
|
272 |
|
273 /** |
|
274 * Handle to Xml file to be parsed. |
|
275 */ |
|
276 RFile iFile; |
|
277 |
|
278 /** |
|
279 * Handle to buffer which contains parsed data. |
|
280 * Own. |
|
281 */ |
|
282 HBufC8* iBuffer; |
|
283 |
|
284 /** |
|
285 * Handle to ongoing temporary provider. |
|
286 * Own. |
|
287 */ |
|
288 CAcpProvider* iProvider; |
|
289 |
|
290 /** |
|
291 * Ongoing element. Parsing is reached to this point. |
|
292 * Own. |
|
293 */ |
|
294 HBufC8* iOngoingAttr; |
|
295 |
|
296 /** |
|
297 * Flag indicates that next content data has to be saved. |
|
298 */ |
|
299 TBool iGetContentNow; |
|
300 |
|
301 /** |
|
302 * XML file to be parsed and then deleted |
|
303 */ |
|
304 TFileName iFilename; |
|
305 |
|
306 // For unit tests. |
|
307 #ifdef _DEBUG |
|
308 friend class T_CAcpXmlHandler; |
|
309 #endif |
|
310 }; |
|
311 |
|
312 #endif // ACPXMLHANDLER_H |
|
313 |
|
314 // End of file. |