|
1 /* |
|
2 * Copyright (c) 2004-2008 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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CIPTVPPCONTENTHANDLER_H |
|
22 #define CIPTVPPCONTENTHANDLER_H |
|
23 |
|
24 #include <e32std.h> |
|
25 #include <xml/contenthandler.h> |
|
26 #include "IptvEngineUids.h" |
|
27 |
|
28 const TInt KMaxLanguageCodeStringLength = 5; |
|
29 const TInt KIptvProtocolLength = 15; |
|
30 |
|
31 class CIptvProvisioningProcessor; |
|
32 class CIptvService; |
|
33 class CIptvServices; |
|
34 |
|
35 using namespace Xml; |
|
36 |
|
37 class CIptvPPContentHandler : public CBase, |
|
38 public MContentHandler |
|
39 { |
|
40 |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Two-phased constructor. |
|
45 * @param |
|
46 */ |
|
47 static CIptvPPContentHandler* NewL( |
|
48 CIptvProvisioningProcessor& aProcessor, |
|
49 const RFs& aFs ); |
|
50 |
|
51 /** |
|
52 * Destructor. |
|
53 */ |
|
54 ~CIptvPPContentHandler(); |
|
55 |
|
56 /** |
|
57 * Reset content handler. |
|
58 */ |
|
59 void Reset(); |
|
60 |
|
61 /** |
|
62 * Set mode. |
|
63 */ |
|
64 void SetMode( TBool aLocal ); |
|
65 |
|
66 /** |
|
67 * Set services array. |
|
68 */ |
|
69 void SetServicesArray( CIptvServices* aServices ); |
|
70 |
|
71 /** |
|
72 * Get error code. |
|
73 */ |
|
74 TInt GetError() const { return iError; }; |
|
75 |
|
76 // From MContentHandler |
|
77 |
|
78 /** |
|
79 * This method is a callback to indicate the start of the document. |
|
80 * @param aDocParam Specifies the various parameters of the document. |
|
81 * @param aDocParam.iCharacterSetName The character encoding of the document. |
|
82 * @param aErrorCode is the error code. |
|
83 * If this is not KErrNone then special action may be required. |
|
84 */ |
|
85 void OnStartDocumentL( const RDocumentParameters& aDocParam, TInt aErrorCode ); |
|
86 |
|
87 /** |
|
88 * This method is a callback to indicate the end of the document. |
|
89 * @param aErrorCode is the error code. |
|
90 * If this is not KErrNone then special action may be required. |
|
91 */ |
|
92 void OnEndDocumentL( TInt aErrorCode ); |
|
93 |
|
94 /** |
|
95 * This method is a callback to indicate an element has been parsed. |
|
96 * @param aElement is a handle to the element's details. |
|
97 * @param aAttributes contains the attributes for the element. |
|
98 * @param aErrorCode is the error code. |
|
99 * If this is not KErrNone then special action may be required. |
|
100 */ |
|
101 void OnStartElementL( const RTagInfo& aElement, |
|
102 const RAttributeArray& aAttributes, |
|
103 TInt aErrorCode ); |
|
104 |
|
105 /** |
|
106 * This method is a callback to indicate the end of the element has been reached. |
|
107 * @param aElement is a handle to the element's details. |
|
108 * @param aErrorCode is the error code. |
|
109 * If this is not KErrNone then special action may be required. |
|
110 */ |
|
111 void OnEndElementL( const RTagInfo& aElement, TInt aErrorCode ); |
|
112 |
|
113 /** |
|
114 * This method is a callback that sends the content of the element. |
|
115 * Not all the content may be returned in one go. The data may be sent in chunks. |
|
116 * When an OnEndElementL is received this means there is no more content to be sent. |
|
117 * @param aBytes is the raw content data for the element. |
|
118 * The client is responsible for converting the data to the |
|
119 * required character set if necessary. |
|
120 * In some instances the content may be binary and must not be converted. |
|
121 * @param aErrorCode is the error code. |
|
122 * If this is not KErrNone then special action may be required. |
|
123 */ |
|
124 void OnContentL( const TDesC8& aBytes, TInt aErrorCode ); |
|
125 |
|
126 /** |
|
127 * This method is a notification of the beginning of the scope of a prefix-URI Namespace mapping. |
|
128 * This method is always called before the corresponding OnStartElementL method. |
|
129 * @param aPrefix is the Namespace prefix being declared. |
|
130 * @param aUri is the Namespace URI the prefix is mapped to. |
|
131 * @param aErrorCode is the error code. |
|
132 * If this is not KErrNone then special action may be required. |
|
133 */ |
|
134 void OnStartPrefixMappingL( const RString& aPrefix, |
|
135 const RString& aUri, |
|
136 TInt aErrorCode ); |
|
137 |
|
138 /** |
|
139 * This method is a notification of the end of the scope of a prefix-URI mapping. |
|
140 * This method is called after the corresponding DoEndElementL method. |
|
141 * @param aPrefix is the Namespace prefix that was mapped. |
|
142 * @param aErrorCode is the error code. |
|
143 * If this is not KErrNone then special action may be required. |
|
144 */ |
|
145 void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode ); |
|
146 |
|
147 /** |
|
148 * This method is a notification of ignorable whitespace in element content. |
|
149 * @param aBytes are the ignored bytes from the document being parsed. |
|
150 * @param aErrorCode is the error code. |
|
151 * If this is not KErrNone then special action may be required. |
|
152 */ |
|
153 void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode ); |
|
154 |
|
155 /** |
|
156 * This method is a notification of a skipped entity. If the parser encounters an |
|
157 * external entity it does not need to expand it - it can return the entity as aName |
|
158 * for the client to deal with. |
|
159 * @param aName is the name of the skipped entity. |
|
160 * @param aErrorCode is the error code. |
|
161 * If this is not KErrNone then special action may be required. |
|
162 */ |
|
163 void OnSkippedEntityL( const RString& aName, TInt aErrorCode ); |
|
164 |
|
165 /** |
|
166 * This method is a receive notification of a processing instruction. |
|
167 * @param aTarget is the processing instruction target. |
|
168 * @param aData is the processing instruction data. If empty none was supplied. |
|
169 * @param aErrorCode is the error code. |
|
170 * If this is not KErrNone then special action may be required. |
|
171 */ |
|
172 void OnProcessingInstructionL( const TDesC8& aTarget, |
|
173 const TDesC8& aData, |
|
174 TInt aErrorCode ); |
|
175 |
|
176 /** |
|
177 * This method indicates an error has occurred. |
|
178 * @param aError is the error code |
|
179 */ |
|
180 void OnError( TInt aErrorCode ); |
|
181 |
|
182 /** |
|
183 * This method obtains the interface matching the specified uid. |
|
184 * @return 0 if no interface matching the uid is found. |
|
185 * Otherwise, the this pointer cast to that interface. |
|
186 * @param aUid the uid identifying the required interface. |
|
187 */ |
|
188 TAny* GetExtendedInterface( const TInt32 aUid ); |
|
189 |
|
190 private: // New functions |
|
191 |
|
192 /** |
|
193 * C++ default constructor. |
|
194 */ |
|
195 CIptvPPContentHandler( |
|
196 CIptvProvisioningProcessor& aProcessor, |
|
197 const RFs& aFs ); |
|
198 |
|
199 /** |
|
200 * Add service. |
|
201 */ |
|
202 void AddServiceL(); |
|
203 |
|
204 /** |
|
205 * Checks if input string includes only number characters. |
|
206 * |
|
207 * @param aString Input string. |
|
208 * @return ETrue if string includes only number characters. |
|
209 */ |
|
210 TBool HasOnlyNumbers( const TDesC& aString ) const; |
|
211 |
|
212 /** |
|
213 * Get service type. |
|
214 */ |
|
215 void GetServiceTypeL( const RAttributeArray& aAttributes ); |
|
216 |
|
217 /** |
|
218 * Get language code |
|
219 */ |
|
220 void GetLanguageCode( const RAttributeArray& aAttributes ); |
|
221 |
|
222 /** |
|
223 * Set service type. |
|
224 */ |
|
225 void SetServiceTypeL( const TDesC& aServiceType ); |
|
226 |
|
227 /** |
|
228 * Complete title. |
|
229 */ |
|
230 void CompleteTitleL(); |
|
231 |
|
232 /** |
|
233 * Complete description. |
|
234 */ |
|
235 void CompleteDescriptionL(); |
|
236 |
|
237 /** |
|
238 * Complete service group Id. |
|
239 */ |
|
240 void CompleteGroupIdL(); |
|
241 |
|
242 /** |
|
243 * Complete use category. |
|
244 */ |
|
245 void CompleteUseCategoryL(); |
|
246 |
|
247 /** |
|
248 * Complete Uri. |
|
249 */ |
|
250 void CompleteUriL(); |
|
251 |
|
252 /** |
|
253 * Complete Iap. |
|
254 */ |
|
255 void CompleteIapL(); |
|
256 |
|
257 /** |
|
258 * Complete Username. |
|
259 */ |
|
260 void CompleteUsernameL(); |
|
261 |
|
262 /** |
|
263 * Complete password. |
|
264 */ |
|
265 void CompletePasswordL(); |
|
266 |
|
267 /** |
|
268 * Complete account mgmt uri. |
|
269 */ |
|
270 void CompleteAccountMgmtUri(); |
|
271 |
|
272 /** |
|
273 * Complete icon Uri. |
|
274 */ |
|
275 void CompleteIconUrlL(); |
|
276 |
|
277 /** |
|
278 * Complete icon path. |
|
279 */ |
|
280 void CompleteIconPathL(); |
|
281 |
|
282 /** |
|
283 * Complete upload provider. |
|
284 */ |
|
285 void CompleteUploadProvider(); |
|
286 |
|
287 /** |
|
288 * Complete application UID. |
|
289 */ |
|
290 void CompleteAppUIDL(); |
|
291 |
|
292 /** |
|
293 * Complete search uri |
|
294 */ |
|
295 void CompleteSearchUriL(); |
|
296 |
|
297 /** |
|
298 * Complete record uri. |
|
299 */ |
|
300 void CompleteRecordUriL(); |
|
301 |
|
302 /** |
|
303 * Set protocol. |
|
304 */ |
|
305 void SetProtocolL( const TDesC& aProtocol ); |
|
306 |
|
307 /** |
|
308 * Is valid service. |
|
309 * @param aError Cause for invalid service. |
|
310 */ |
|
311 TBool IsValidServiceL( TInt& aError ); |
|
312 |
|
313 /** |
|
314 * Set given icon path. Whether it is drive independent filepath, |
|
315 * searches correct drive and fix it |
|
316 * |
|
317 * @param aIconPath Icon path. |
|
318 */ |
|
319 void SetIconPathL( const TDesC& aIconPath ); |
|
320 |
|
321 private: |
|
322 |
|
323 /** |
|
324 * Service Title state. |
|
325 */ |
|
326 enum TServiceTitleState |
|
327 { |
|
328 EIptvServiceTitleNone, |
|
329 EIptvServiceTitleNormal, |
|
330 EIptvServiceTitleStore |
|
331 }; |
|
332 |
|
333 /** |
|
334 * State. |
|
335 */ |
|
336 TInt iState; |
|
337 |
|
338 /** |
|
339 * Service count. |
|
340 */ |
|
341 TInt iServiceCount; |
|
342 |
|
343 /** |
|
344 * Reference to CIptvProvisioningProcessor. |
|
345 */ |
|
346 CIptvProvisioningProcessor& iProcessor; |
|
347 |
|
348 /** |
|
349 * Pointer to service object. |
|
350 * Own. |
|
351 */ |
|
352 CIptvService* iService; |
|
353 |
|
354 /** |
|
355 * Local provisioning. |
|
356 */ |
|
357 TBool iLocal; |
|
358 |
|
359 /** |
|
360 * Buffer. |
|
361 * Own. |
|
362 */ |
|
363 HBufC* iBuffer; |
|
364 |
|
365 /** |
|
366 * Servies array. |
|
367 * Not own, |
|
368 */ |
|
369 CIptvServices* iServices; |
|
370 |
|
371 /** |
|
372 * Error code. |
|
373 */ |
|
374 TInt iError; |
|
375 |
|
376 /** |
|
377 * Language code currently in use for the device |
|
378 */ |
|
379 TLanguage iCurrentDeviceLanguage; |
|
380 |
|
381 /** |
|
382 * Current language code from the xml file |
|
383 */ |
|
384 TBuf<KMaxLanguageCodeStringLength> iCurrentLanguageCode; |
|
385 |
|
386 /** |
|
387 * Symbian enumeration for iCurrentLanguageCode |
|
388 */ |
|
389 TLanguage iCurrentlyParsedDetailLanguage; |
|
390 |
|
391 /** |
|
392 * Flag to identify if a single language data for title is set |
|
393 */ |
|
394 TBool iTitleLanguageDataSet; |
|
395 |
|
396 /** |
|
397 * Flag to identify if a single language data for description is set |
|
398 */ |
|
399 TBool iDescriptionLanguageDataSet; |
|
400 |
|
401 /** |
|
402 * Flag to identify if a single language data for icon URI is set |
|
403 */ |
|
404 TBool iIconUriLanguageDataSet; |
|
405 |
|
406 /** |
|
407 * Service group feed indication. |
|
408 */ |
|
409 TBool iServiceGroupFeed; |
|
410 |
|
411 /** |
|
412 * Grouped service indication. |
|
413 */ |
|
414 TUint iServiceGroupId; |
|
415 |
|
416 /** |
|
417 * Protocol. |
|
418 */ |
|
419 TBuf<KIptvProtocolLength> iProtocol; |
|
420 |
|
421 /** |
|
422 * Service Title state. |
|
423 */ |
|
424 TServiceTitleState iServiceTitleState; |
|
425 |
|
426 /** |
|
427 * Icon url waiting to be saved or ignored according to title. |
|
428 * Own. |
|
429 */ |
|
430 HBufC* iPendingIcon; |
|
431 |
|
432 /** |
|
433 * File server session |
|
434 */ |
|
435 RFs iFs; |
|
436 |
|
437 }; |
|
438 |
|
439 #endif // CIPTVPPCONTENTHANDLER_H |