1 /* |
|
2 * Copyright (c) 2006-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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef IRXMLCONTENTHANDLER_H |
|
20 #define IRXMLCONTENTHANDLER_H |
|
21 |
|
22 #include <contenthandler.h> |
|
23 |
|
24 class CIRAdvertisement; |
|
25 class CIRBrowseCatagoryItems; |
|
26 class CIRBrowseChannelItems; |
|
27 class CIRCacheMgmt; |
|
28 class CIRHttpResponseData; |
|
29 class CIRIsdsPreset; |
|
30 class CIROTAUpdate; |
|
31 class MIRCacheObserver; |
|
32 class MIRParserObserver; |
|
33 |
|
34 namespace Xml |
|
35 { |
|
36 class CParser; |
|
37 } |
|
38 |
|
39 //constant declaration |
|
40 _LIT8(KFile,"text/xml"); |
|
41 const TInt KSessionLogResponse = 5; |
|
42 |
|
43 using namespace Xml; |
|
44 |
|
45 /** |
|
46 * Parse data from xml file |
|
47 * |
|
48 * @code |
|
49 * |
|
50 * classA* ParserObserver;//class classA : public MIRParserObserver |
|
51 * classB* CacheObserver;//class classB : public MIRCacheObserver |
|
52 * CIRHttpResponseData* ResponseHeader; |
|
53 * CIRHttpResponseData* parser = CIRXMLContentHandler::NewL (*ParserObserver,*CacheObserver); |
|
54 * parser->ParseXmlL(FilePath,CachePath,ResponseHeader); |
|
55 * |
|
56 * @endcode |
|
57 * |
|
58 */ |
|
59 |
|
60 class CIRXMLContentHandler : public CBase, |
|
61 public MContentHandler |
|
62 { |
|
63 public: |
|
64 /** |
|
65 * Gets the Filepath of the XML file |
|
66 * @param aFilePath Contains the filepath of the file |
|
67 * @return ErrorCode if the file cannot be opened |
|
68 */ |
|
69 IMPORT_C void ParseXmlL(const TDesC& aFilePath, const TDesC& aCachePath, |
|
70 const CIRHttpResponseData& aResponseHeaders); |
|
71 |
|
72 /** |
|
73 * Default Constructor |
|
74 * @param aObserver Contains the reference to the MClass Observer |
|
75 */ |
|
76 IMPORT_C static CIRXMLContentHandler* NewL |
|
77 (MIRParserObserver &aObserver, MIRCacheObserver &aCacheObserver); |
|
78 /** |
|
79 * Destructing the object |
|
80 */ |
|
81 ~CIRXMLContentHandler(); |
|
82 /** |
|
83 * This method is a callback to indicate the start of the document |
|
84 * @param aDocParam Specifies the various parameters of the document |
|
85 * @param aErrorCode KErrNone if successfull. |
|
86 * @return None |
|
87 */ |
|
88 virtual void OnStartDocumentL(const RDocumentParameters &aDocParam, |
|
89 TInt aErrorCode); |
|
90 /** |
|
91 * This method is a callback to indicate the end of the document |
|
92 * @param aErrorCode KErrNone if successfull. |
|
93 * @return None |
|
94 */ |
|
95 virtual void OnEndDocumentL(TInt aErrorCode); |
|
96 /** |
|
97 * This method is a callback to indicate an element has been parsed. |
|
98 * @param aElement is a handle to the element's details. |
|
99 * @param aAttributes contains the attributes for the element |
|
100 * @param aErrorCode KErrNone if successfull. |
|
101 */ |
|
102 virtual void OnStartElementL(const RTagInfo &aElement, |
|
103 const RAttributeArray &aAttributes, TInt aErrorCode); |
|
104 /** |
|
105 * This method is a callback to indicate the end of the element has been reached. |
|
106 * @param aElement is a handle to the element's details. |
|
107 * @param aErrorCode KErrNone if successfull. |
|
108 */ |
|
109 virtual void OnEndElementL(const RTagInfo &aElement, TInt aErrorCode); |
|
110 /** |
|
111 * This method is a callback that sends the content of the element.The data may be sent in chunks |
|
112 * @param aBytes is the raw content data for the element. |
|
113 * @param aErrorCode KErrNone if successfull. |
|
114 */ |
|
115 virtual void OnContentL(const TDesC8 &aBytes, TInt aErrorCode); |
|
116 /** |
|
117 * This method is a notification of the beginning of the scope of a prefix-URI Namespace mapping. |
|
118 * @param aPrefix is the Namespace prefix being declared |
|
119 * @param aUri is the Namespace URI the prefix is mapped to |
|
120 * @param aErrorCode KErrNone if successfull. |
|
121 */ |
|
122 virtual void OnStartPrefixMappingL(const RString &aPrefix, |
|
123 const RString &aUri, TInt aErrorCode); |
|
124 /** |
|
125 * This method is a notification of the end of the scope of a prefix-URI mapping |
|
126 * @param aPrefix is the Namespace prefix that was mapped. |
|
127 * @param aErrorCode KErrNone if successfull. |
|
128 */ |
|
129 virtual void OnEndPrefixMappingL(const RString &aPrefix, TInt aErrorCode); |
|
130 /** |
|
131 * This method is a notification of ignorable whitespace in element content. |
|
132 * @param aBytes are the ignored bytes from the document being parsed.. |
|
133 * @param aErrorCode KErrNone if successfull. |
|
134 */ |
|
135 virtual void OnIgnorableWhiteSpaceL(const TDesC8 &aBytes, TInt aErrorCode); |
|
136 /** |
|
137 * This method is a notification of a skipped entity |
|
138 * @param aName is the name of the skipped entity. |
|
139 * @param aErrorCode KErrNone if successfull. |
|
140 */ |
|
141 virtual void OnSkippedEntityL(const RString &aName, TInt aErrorCode); |
|
142 /** |
|
143 * This method is a receive notification of a processing instruction. |
|
144 * @param aTarget is the processing instruction target. |
|
145 * @param aData is the processing instruction data. If empty none was supplied.. |
|
146 * @param aErrorCode KErrNone if successfull. |
|
147 */ |
|
148 virtual void OnProcessingInstructionL(const TDesC8 &aTarget, |
|
149 const TDesC8 &aData, TInt aErrorCode); |
|
150 /** |
|
151 * This method indicates an error has occurred. |
|
152 * @param aErrorCode contains the errorcode. |
|
153 */ |
|
154 virtual void OnError(TInt aErrorCode); |
|
155 /** |
|
156 * This method obtains the interface matching the specified uid. |
|
157 * @param aUid the uid identifying the required interface |
|
158 * @return 0 if no interface matching the uid is found. Otherwise, the this pointer cast to that interface |
|
159 */ |
|
160 virtual TAny *GetExtendedInterface(const TInt32 aUid); |
|
161 /** |
|
162 * This method maps the errorcode |
|
163 * @param aError conatins the errorcode |
|
164 * @return the type of the error |
|
165 */ |
|
166 TInt ParseError(TInt aError); |
|
167 /** |
|
168 * This method stringpool handle |
|
169 * @param aError conatins the errorcode |
|
170 * @return the type of the error |
|
171 */ |
|
172 RStringPool& StringPool (); |
|
173 |
|
174 void ResetValues(); |
|
175 |
|
176 protected: |
|
177 |
|
178 /** |
|
179 * Default Constructor |
|
180 * @param aObserver Contains the reference to the MClass Observer |
|
181 */ |
|
182 CIRXMLContentHandler(MIRParserObserver &aObserver,MIRCacheObserver &aCacheObserver); |
|
183 |
|
184 /** |
|
185 * Two-Phase Constructor |
|
186 */ |
|
187 void ConstructL(); |
|
188 |
|
189 private : |
|
190 |
|
191 // Buffer for the URL |
|
192 HBufC* iBufGetOperation; |
|
193 |
|
194 // Buffer for Size |
|
195 HBufC* iSize; |
|
196 |
|
197 // Count of the bitrates |
|
198 TBool iIRID; |
|
199 |
|
200 TInt iBitrateCounter; |
|
201 |
|
202 // Indicating for Channels/Preset |
|
203 TInt iFlag; |
|
204 |
|
205 // Indicating for Channels |
|
206 TInt iChannelFlag; |
|
207 |
|
208 // Bool Value to indicate the class |
|
209 TBool iPresets; |
|
210 TBool iCategories; |
|
211 TBool iCat; |
|
212 TBool iChannels; |
|
213 TBool iChan; |
|
214 TBool iAdvertisement; |
|
215 TBool iOTAUpdate; |
|
216 TBool iTimeStamp; //checks the header has a time stamp |
|
217 TInt iEOD; |
|
218 // Pointer to the PresetData |
|
219 CIRIsdsPreset *iPreset; |
|
220 |
|
221 // Pointer to the CategoryData |
|
222 CIRBrowseCatagoryItems *iCategory; |
|
223 |
|
224 // Pointer to the ChannelData |
|
225 CIRBrowseChannelItems *iChannel; |
|
226 |
|
227 // Pointer to the Advertisement |
|
228 |
|
229 CIRAdvertisement *iAdv; |
|
230 |
|
231 //! An Handle to Stringpool |
|
232 |
|
233 RStringPool iStringPool; |
|
234 |
|
235 //! Reference to the CallBack Class |
|
236 |
|
237 MIRParserObserver& iParseObserver; |
|
238 |
|
239 CParser* iParser; |
|
240 |
|
241 //Caching |
|
242 CIRCacheMgmt *iCache; |
|
243 |
|
244 MIRCacheObserver &iCacheObserver; |
|
245 |
|
246 TBuf<256> iFileToCache; |
|
247 |
|
248 // For Advertisement |
|
249 TBool iAdvts; |
|
250 TBool iAdvertisementTagFlag; |
|
251 HBufC* iUrlContentForAds; //to store the content of the tag |
|
252 |
|
253 |
|
254 |
|
255 public: |
|
256 |
|
257 // Count of the bitrates |
|
258 |
|
259 TBuf<30> iRID; |
|
260 |
|
261 // Array of Pointers to PresetClass |
|
262 |
|
263 CArrayPtrFlat<CIRIsdsPreset>* iPtrPreset; |
|
264 |
|
265 // Array of Pointers to CategoryClass |
|
266 |
|
267 CArrayPtrFlat<CIRBrowseCatagoryItems>* iPtrCategory; |
|
268 |
|
269 // Array of Pointers to BrowseCategoryClass |
|
270 |
|
271 CArrayPtrFlat<CIRBrowseChannelItems>* iPtrChannel; |
|
272 // Pointer to the OTAUpdate |
|
273 |
|
274 CIROTAUpdate *iOTA; |
|
275 |
|
276 |
|
277 |
|
278 }; |
|
279 |
|
280 #endif //IRXMLCONTENTHANDLER_H |
|