|
1 /* |
|
2 * Copyright (c) 2007-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: XML Parser handler* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #include <e32base.h> |
|
21 #include "MIptvEpgVodCallback.h" |
|
22 #include "CIptvEpgCategory.h" |
|
23 #include "CIptvEpgContent.h" |
|
24 #include "IptvDebug.h" |
|
25 #include <xml/xmlparsererrors.h> |
|
26 #include <utf.h> |
|
27 #include "CIptvMediaContent.h" |
|
28 #include "CIptvTerminalVideoSupport.h" |
|
29 #include "CIptv3XmlContentHandler.h" |
|
30 #include "CIptvRssPlugin.h" |
|
31 #include "CIptvDownloadItem.h" |
|
32 #include "ciptvxmlconsts.h" |
|
33 #include "ciptvxmldatetime.h" |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // -------------------------------------------------------------------------- |
|
38 // Symbian 2nd phase constructor can leave. |
|
39 // -------------------------------------------------------------------------- |
|
40 // |
|
41 void CIptvXmlContentHandler::ConstructL() |
|
42 { |
|
43 iTerminalVideoSupport = CIptvTerminalVideoSupport::NewL(); |
|
44 } |
|
45 |
|
46 // -------------------------------------------------------------------------- |
|
47 // Two-phased constructor. |
|
48 // Create instance of concrete interface implementation |
|
49 // -------------------------------------------------------------------------- |
|
50 // |
|
51 CIptvXmlContentHandler* CIptvXmlContentHandler::NewL( |
|
52 CIptvRssPlugin& aPlugin ) |
|
53 { |
|
54 CIptvXmlContentHandler* self = |
|
55 new ( ELeave ) CIptvXmlContentHandler( aPlugin ); |
|
56 CleanupStack::PushL( self ); |
|
57 |
|
58 self->ConstructL(); |
|
59 |
|
60 CleanupStack::Pop( self ); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // -------------------------------------------------------------------------- |
|
65 // Destructor |
|
66 // -------------------------------------------------------------------------- |
|
67 // |
|
68 CIptvXmlContentHandler::~CIptvXmlContentHandler() |
|
69 { |
|
70 IPTVLOGSTRING_LOW_LEVEL( |
|
71 "RSS Plugin::CIptvXmlContentHandler::~CIptvXmlContentHandler" ); |
|
72 |
|
73 delete iTerminalVideoSupport; |
|
74 |
|
75 // Delete only if iChannelCategoryKey has the original value. Otherwise |
|
76 // the iChannelCategory has been appended to iCategoryTable array. |
|
77 // Deletingin this case leads to double deletion & crash. This happened |
|
78 // when XML feed had an error in item and parsing was interrupted. |
|
79 // |
|
80 if ( 0 == iChannelCategoryKey ) |
|
81 { |
|
82 delete iChannelCategory; |
|
83 } |
|
84 iChannelCategory = NULL; |
|
85 |
|
86 delete iContent; |
|
87 delete iBuffer; |
|
88 |
|
89 iVodCallback = NULL; |
|
90 |
|
91 iMediaContents.ResetAndDestroy(); |
|
92 iMediaContentSet.Close(); |
|
93 iCurrentCategoryKeys.Close(); |
|
94 iCategoryTable.ResetAndDestroy(); |
|
95 } |
|
96 |
|
97 // -------------------------------------------------------------------------- |
|
98 // C++ default constructor |
|
99 // -------------------------------------------------------------------------- |
|
100 // |
|
101 CIptvXmlContentHandler::CIptvXmlContentHandler( CIptvRssPlugin& aPlugin ) : |
|
102 iPlugin( aPlugin ), |
|
103 iState( EIptvRssIdleState ), |
|
104 iMediaRatingScheme( EMediaRatingSimple ), |
|
105 iCategoryState( ENoChannel ) |
|
106 { |
|
107 } |
|
108 |
|
109 // -------------------------------------------------------------------------- |
|
110 // Set callback for storing XML parse results. |
|
111 // -------------------------------------------------------------------------- |
|
112 // |
|
113 void CIptvXmlContentHandler::SetVodCallback( |
|
114 MIptvEpgVodCallback* aVodCallback ) |
|
115 { |
|
116 IPTVLOGSTRING_LOW_LEVEL( |
|
117 "RSS Plugin::CIptvXmlContentHandler::SetVodCallback" ); |
|
118 iVodCallback = aVodCallback; |
|
119 } |
|
120 |
|
121 // -------------------------------------------------------------------------- |
|
122 // Callback to indicate the start of the document. |
|
123 // -------------------------------------------------------------------------- |
|
124 // |
|
125 void CIptvXmlContentHandler::OnStartDocumentL( |
|
126 const RDocumentParameters& /*aDocParam*/, |
|
127 TInt aErrorCode ) |
|
128 { |
|
129 IPTVLOGSTRING_LOW_LEVEL( |
|
130 "RSS Plugin::CIptvXmlContentHandler::OnStartDocumentL" ); |
|
131 |
|
132 if ( aErrorCode != KErrNone ) |
|
133 { |
|
134 iPlugin.SetParsingFailed(); |
|
135 } |
|
136 |
|
137 iServiceThumbnailAdded = EFalse; |
|
138 iRSSContentFound = EFalse; |
|
139 } |
|
140 |
|
141 // -------------------------------------------------------------------------- |
|
142 // Callback to indicate the end of the document. |
|
143 // -------------------------------------------------------------------------- |
|
144 // |
|
145 void CIptvXmlContentHandler::OnEndDocumentL( TInt aErrorCode ) |
|
146 { |
|
147 IPTVLOGSTRING_LOW_LEVEL( |
|
148 "RSS Plugin::CIptvXmlContentHandler::OnEndDocumentL" ); |
|
149 |
|
150 AddCategories(); |
|
151 |
|
152 if ( ( KErrNone != aErrorCode ) || !iRSSContentFound ) |
|
153 { |
|
154 iPlugin.SetParsingFailed(); |
|
155 } |
|
156 |
|
157 iPlugin.ContentUpdateCompletedL(); |
|
158 } |
|
159 |
|
160 // -------------------------------------------------------------------------- |
|
161 // Callback to indicate an element parsing start. |
|
162 // -------------------------------------------------------------------------- |
|
163 // |
|
164 void CIptvXmlContentHandler::OnStartElementL( |
|
165 const RTagInfo& aElement, |
|
166 const RAttributeArray& aAttributes, |
|
167 TInt aErrorCode ) |
|
168 { |
|
169 IPTVLOGSTRING_LOW_LEVEL( |
|
170 "RSS Plugin::CIptvXmlContentHandler::OnStartElementL" ); |
|
171 |
|
172 if ( aErrorCode != KErrNone ) |
|
173 { |
|
174 iPlugin.SetParsingFailed(); |
|
175 return; |
|
176 } |
|
177 |
|
178 delete iBuffer; |
|
179 iBuffer = NULL; |
|
180 |
|
181 TInt dataToCopy = Min( |
|
182 aElement.LocalName().DesC().Length(), |
|
183 KIptvRssItemNameMaxLength ); |
|
184 HBufC* name = HBufC::NewLC( dataToCopy ); |
|
185 TPtr localName = name->Des(); |
|
186 localName.Copy( aElement.LocalName().DesC().Mid( 0, dataToCopy ) ); |
|
187 |
|
188 // Parse name prefix. |
|
189 iMediaPrefix = EFalse; |
|
190 dataToCopy = Min( |
|
191 aElement.Prefix().DesC().Length(), |
|
192 KIptvRssItemNameMaxLength ); |
|
193 if ( 0 < dataToCopy ) |
|
194 { |
|
195 HBufC* prefix = HBufC::NewLC( dataToCopy ); |
|
196 TPtr prefixName = prefix->Des(); |
|
197 prefixName.Copy( aElement.Prefix().DesC().Mid( 0, dataToCopy ) ); |
|
198 if ( prefixName.CompareF( KIptvRssMedia ) == 0 ) |
|
199 { |
|
200 iMediaPrefix = ETrue; |
|
201 } |
|
202 CleanupStack::PopAndDestroy( prefix ); |
|
203 } |
|
204 |
|
205 switch ( iState ) |
|
206 { |
|
207 case EIptvRssIdleState: |
|
208 { |
|
209 if ( localName.CompareF( KIptvRssRss ) == 0 ) |
|
210 { |
|
211 iState = EIptvRssState; |
|
212 iRSSContentFound = ETrue; |
|
213 IPTVLOGSTRING_LOW_LEVEL( |
|
214 "RSS Plugin::State changed from EIptvRssIdleState to EIptvRssState" ); |
|
215 HandleEnclosureL( aAttributes ); |
|
216 } |
|
217 } |
|
218 break; |
|
219 |
|
220 case EIptvRssState: |
|
221 { |
|
222 if ( localName.CompareF( KIptvRssChannel ) == 0 ) |
|
223 { |
|
224 if ( SetCategoryState( EChannelFound ) ) |
|
225 { |
|
226 iState = EIptvRssChannelState; |
|
227 IPTVLOGSTRING_LOW_LEVEL( |
|
228 "RSS Plugin::State changed from EIptvRssState to EIptvRssChannelState" ); |
|
229 delete iChannelCategory; |
|
230 iChannelCategory = NULL; |
|
231 iChannelCategory = CreateCategoryL(); |
|
232 iChannelCategoryKey = 0; |
|
233 } |
|
234 } |
|
235 } |
|
236 break; |
|
237 |
|
238 case EIptvRssChannelState: |
|
239 { |
|
240 //lint -e{961} Else block not needed, default is no operation. |
|
241 if ( localName.CompareF( KIptvRssDescription ) == 0 ) |
|
242 { |
|
243 iState = EIptvRssChannelDescriptionState; |
|
244 IPTVLOGSTRING_LOW_LEVEL( |
|
245 "RSS Plugin::State changed from EIptvRssChannelState to EIptvRssChannelDescriptionState" ); |
|
246 } |
|
247 else if ( localName.CompareF( KIptvRssLink ) == 0 ) |
|
248 { |
|
249 iState = EIptvRssChannelLinkState; |
|
250 IPTVLOGSTRING_LOW_LEVEL( |
|
251 "RSS Plugin::State changed from EIptvRssChannelState to EIptvRssChannelLinkState" ); |
|
252 } |
|
253 else if ( localName.CompareF( KIptvRssTitle ) == 0 ) |
|
254 { |
|
255 iState = EIptvRssChannelTitleState; |
|
256 IPTVLOGSTRING_LOW_LEVEL( |
|
257 "RSS Plugin::State changed from EIptvRssChannelState to EIptvRssChannelTitleState" ); |
|
258 } |
|
259 else if ( localName.CompareF( KIptvRssImage ) == 0 ) |
|
260 { |
|
261 iState = EIptvRssChannelImageState; |
|
262 IPTVLOGSTRING_LOW_LEVEL( |
|
263 "RSS Plugin::State changed from EIptvRssChannelState to EIptvRssChannelImageState" ); |
|
264 HandleEnclosureL( aAttributes ); |
|
265 } |
|
266 else if ( localName.CompareF( KIptvRssItem ) == 0 ) |
|
267 { |
|
268 iCurrentCategoryKeys.Reset(); |
|
269 SetCategoryState( EItemFound ); |
|
270 iState = EIptvRssItemState; |
|
271 IPTVLOGSTRING_LOW_LEVEL( |
|
272 "RSS Plugin::State changed from EIptvRssChannelState to EIptvRssItemState" ); |
|
273 CreateContentL(); |
|
274 |
|
275 iMediaDescriptionFixed = EFalse; |
|
276 iMediaTitleFixed = EFalse; |
|
277 iMediaRatingFixed = EFalse; |
|
278 iMediaCopyrightFixed = EFalse; |
|
279 iMediaThumbnailFixed = EFalse; |
|
280 } |
|
281 } |
|
282 break; |
|
283 |
|
284 case EIptvRssChannelImageState: |
|
285 { |
|
286 if ( localName.CompareF( KIptvRssUrl ) == 0 ) |
|
287 { |
|
288 iState = EIptvRssChannelImageUrlState; |
|
289 IPTVLOGSTRING_LOW_LEVEL( |
|
290 "RSS Plugin::State changed from EIptvRssChannelImageState to EIptvRssChannelImageUrlState" ); |
|
291 } |
|
292 } |
|
293 break; |
|
294 |
|
295 case EIptvRssChannelImageUrlState: |
|
296 break; |
|
297 |
|
298 case EIptvRssChannelDescriptionState: |
|
299 break; |
|
300 |
|
301 case EIptvRssChannelLinkState: |
|
302 break; |
|
303 |
|
304 case EIptvRssChannelTitleState: |
|
305 break; |
|
306 |
|
307 case EIptvRssItemState: |
|
308 { |
|
309 //lint -e{961} Else block not needed, default is no operation. |
|
310 if ( localName.CompareF( KIptvRssDescription ) == 0 ) |
|
311 { |
|
312 iState = EIptvRssItemDescriptionState; |
|
313 IPTVLOGSTRING_LOW_LEVEL( |
|
314 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemDescriptionState" ); |
|
315 } |
|
316 else if ( localName.CompareF( KIptvRssLink ) == 0 ) |
|
317 { |
|
318 iState = EIptvRssItemLinkState; |
|
319 IPTVLOGSTRING_LOW_LEVEL( |
|
320 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemLinkState" ); |
|
321 } |
|
322 else if ( localName.CompareF( KIptvRssTitle ) == 0 ) |
|
323 { |
|
324 iState = EIptvRssItemTitleState; |
|
325 IPTVLOGSTRING_LOW_LEVEL( |
|
326 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemTitleState" ); |
|
327 } |
|
328 else if ( localName.CompareF( KIptvRssEnclosure ) == 0 ) |
|
329 { |
|
330 iState = EIptvRssItemEnclosureState; |
|
331 IPTVLOGSTRING_LOW_LEVEL( |
|
332 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemEnclosureState" ); |
|
333 HandleEnclosureL( aAttributes ); |
|
334 } |
|
335 else if ( localName.CompareF( KIptvRssGuid ) == 0 ) |
|
336 { |
|
337 iState = EIptvRssItemGuidState; |
|
338 IPTVLOGSTRING_LOW_LEVEL( |
|
339 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemGuidState" ); |
|
340 } |
|
341 else if ( localName.CompareF( KIptvRssPubDate ) == 0 ) |
|
342 { |
|
343 iState = EIptvRssItemPubDate; |
|
344 IPTVLOGSTRING_LOW_LEVEL( |
|
345 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemPubDate" ); |
|
346 } |
|
347 else if ( localName.CompareF( KIptvRssThumbnail ) == 0 ) |
|
348 { |
|
349 iState = EIptvRssItemMediaThumbnailState; |
|
350 IPTVLOGSTRING_LOW_LEVEL( |
|
351 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemMediaThumbnailState" ); |
|
352 HandleEnclosureL( aAttributes ); |
|
353 } |
|
354 else if ( localName.CompareF( KIptvRssMediaGroup ) == 0 ) |
|
355 { |
|
356 iMediaGroup = ETrue; |
|
357 iState = EIptvRssItemMediaGroupState; |
|
358 IPTVLOGSTRING_LOW_LEVEL( |
|
359 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemMediaGroupState" ); |
|
360 } |
|
361 else if ( localName.CompareF( KIptvRssMediaContent ) == 0 ) |
|
362 { |
|
363 iMediaGroup = EFalse; |
|
364 iState = EIptvRssItemMediaContentState; |
|
365 IPTVLOGSTRING_LOW_LEVEL( |
|
366 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemMediaContentState" ); |
|
367 HandleEnclosureL( aAttributes ); |
|
368 } |
|
369 else if ( localName.CompareF( KIptvRssAuthor ) == 0 ) |
|
370 { |
|
371 iState = EIptvRssItemAuthorState; |
|
372 IPTVLOGSTRING_LOW_LEVEL( |
|
373 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemAuthorState" ); |
|
374 } |
|
375 else if ( localName.CompareF( KIptvRssMediaCopyright ) == 0 ) |
|
376 { |
|
377 iState = EIptvRssItemMediaCopyrightState; |
|
378 IPTVLOGSTRING_LOW_LEVEL( |
|
379 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemMediaCopyrightState" ); |
|
380 } |
|
381 else if ( localName.CompareF( KIptvRssMediaRating ) == 0 ) |
|
382 { |
|
383 iState = EIptvRssItemRatingState; |
|
384 iMediaRatingScheme = EMediaRatingSimple; |
|
385 HandleEnclosureL( aAttributes ); |
|
386 IPTVLOGSTRING_LOW_LEVEL( |
|
387 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemRatingState" ); |
|
388 } |
|
389 else if ( localName.CompareF( KIptvRssMediaCategory ) == 0 ) |
|
390 { |
|
391 if ( iMediaPrefix ) |
|
392 { |
|
393 iState = EIptvRssItemMediaCategoryState; |
|
394 HandleEnclosureL( aAttributes ); |
|
395 IPTVLOGSTRING_LOW_LEVEL( |
|
396 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssItemMediaCategoryState" ); |
|
397 } |
|
398 } |
|
399 } |
|
400 break; |
|
401 |
|
402 case EIptvRssItemDescriptionState: |
|
403 break; |
|
404 |
|
405 case EIptvRssItemLinkState: |
|
406 break; |
|
407 |
|
408 case EIptvRssItemTitleState: |
|
409 break; |
|
410 |
|
411 case EIptvRssItemGuidState: |
|
412 break; |
|
413 |
|
414 case EIptvRssItemMediaGroupState: |
|
415 { |
|
416 //lint -e{961} Else block not needed, default is no operation. |
|
417 if ( localName.CompareF( KIptvRssDescription ) == 0 ) |
|
418 { |
|
419 iState = EIptvRssItemDescriptionState; |
|
420 IPTVLOGSTRING_LOW_LEVEL( |
|
421 "RSS Plugin::State changed from EIptvRssItemMediaGroupState to EIptvRssItemDescriptionState" ); |
|
422 } |
|
423 else if ( localName.CompareF( KIptvRssTitle ) == 0 ) |
|
424 { |
|
425 iState = EIptvRssItemTitleState; |
|
426 IPTVLOGSTRING_LOW_LEVEL( |
|
427 "RSS Plugin::State changed from EIptvRssItemMediaGroupState to EIptvRssItemTitleState" ); |
|
428 } |
|
429 else if ( localName.CompareF( KIptvRssMediaContent ) == 0 ) |
|
430 { |
|
431 iState = EIptvRssItemMediaContentState; |
|
432 IPTVLOGSTRING_LOW_LEVEL( |
|
433 "RSS Plugin::State changed from EIptvRssItemMediaGroupState to EIptvRssItemMediaContentState" ); |
|
434 HandleEnclosureL( aAttributes ); |
|
435 } |
|
436 else if ( localName.CompareF( KIptvRssThumbnail ) == 0 ) |
|
437 { |
|
438 iState = EIptvRssItemMediaThumbnailState; |
|
439 IPTVLOGSTRING_LOW_LEVEL( |
|
440 "RSS Plugin::State changed from EIptvRssItemMediaGroupState to EIptvRssItemMediaThumbnailState" ); |
|
441 HandleEnclosureL( aAttributes ); |
|
442 } |
|
443 else if ( localName.CompareF( KIptvRssMediaCopyright ) == 0 ) |
|
444 { |
|
445 iState = EIptvRssItemMediaCopyrightState; |
|
446 IPTVLOGSTRING_LOW_LEVEL( |
|
447 "RSS Plugin::State changed from EIptvRssItemMediaGroupState to EIptvRssItemMediaCopyrightState" ); |
|
448 } |
|
449 else if ( localName.CompareF( KIptvRssMediaRating ) == 0 ) |
|
450 { |
|
451 iState = EIptvRssItemRatingState; |
|
452 iMediaRatingScheme = EMediaRatingSimple; |
|
453 HandleEnclosureL( aAttributes ); |
|
454 IPTVLOGSTRING_LOW_LEVEL( |
|
455 "RSS Plugin::State changed from EIptvRssItemMediaGroupState to EIptvRssItemRatingState" ); |
|
456 } |
|
457 else if ( localName.CompareF( KIptvRssMediaCategory ) == 0 ) |
|
458 { |
|
459 if ( SetCategoryState( ECategoryFound ) ) |
|
460 { |
|
461 iState = EIptvRssItemMediaCategoryState; |
|
462 HandleEnclosureL( aAttributes ); |
|
463 IPTVLOGSTRING_LOW_LEVEL( |
|
464 "RSS Plugin::State changed from EIptvRssItemMediaGroupState to EIptvRssItemMediaCategoryState" ); |
|
465 } |
|
466 } |
|
467 } |
|
468 break; |
|
469 |
|
470 default: |
|
471 break; |
|
472 } |
|
473 |
|
474 CleanupStack::PopAndDestroy( name ); |
|
475 name = NULL; |
|
476 |
|
477 iMediaPrefix = EFalse; |
|
478 } |
|
479 |
|
480 // -------------------------------------------------------------------------- |
|
481 // Callback to indicate the element parsing completion. |
|
482 // -------------------------------------------------------------------------- |
|
483 // |
|
484 void CIptvXmlContentHandler::OnEndElementL( |
|
485 const RTagInfo& aElement, |
|
486 TInt aErrorCode ) |
|
487 { |
|
488 IPTVLOGSTRING_LOW_LEVEL( |
|
489 "RSS Plugin::CIptvXmlContentHandler::OnEndElementL" ); |
|
490 |
|
491 if ( aErrorCode != KErrNone ) |
|
492 { |
|
493 iPlugin.SetParsingFailed(); |
|
494 return; |
|
495 } |
|
496 |
|
497 TInt dataToCopy = Min( |
|
498 aElement.LocalName().DesC().Length(), |
|
499 KIptvRssItemNameMaxLength ); |
|
500 HBufC* name = HBufC::NewLC( dataToCopy ); |
|
501 TPtr localName = name->Des(); |
|
502 localName.Copy( aElement.LocalName().DesC().Mid( 0, dataToCopy ) ); |
|
503 |
|
504 // Parse name prefix. |
|
505 iMediaPrefix = EFalse; |
|
506 dataToCopy = Min( |
|
507 aElement.Prefix().DesC().Length(), |
|
508 KIptvRssItemNameMaxLength ); |
|
509 if ( 0 < dataToCopy ) |
|
510 { |
|
511 HBufC* prefix = HBufC::NewLC( dataToCopy ); |
|
512 TPtr prefixName = prefix->Des(); |
|
513 prefixName.Copy( aElement.Prefix().DesC().Mid( 0, dataToCopy ) ); |
|
514 if ( prefixName.CompareF( KIptvRssMedia ) == 0 ) |
|
515 { |
|
516 iMediaPrefix = ETrue; |
|
517 } |
|
518 CleanupStack::PopAndDestroy( prefix ); |
|
519 } |
|
520 |
|
521 switch ( iState ) |
|
522 { |
|
523 case EIptvRssIdleState: |
|
524 break; |
|
525 |
|
526 case EIptvRssState: |
|
527 { |
|
528 if ( localName.CompareF( KIptvRssRss ) == 0 ) |
|
529 { |
|
530 iState = EIptvRssIdleState; |
|
531 IPTVLOGSTRING_LOW_LEVEL( |
|
532 "RSS Plugin::State changed from EIptvRssState to EIptvRssIdleState" ); |
|
533 } |
|
534 } |
|
535 break; |
|
536 |
|
537 case EIptvRssChannelState: |
|
538 { |
|
539 if ( localName.CompareF( KIptvRssChannel ) == 0 ) |
|
540 { |
|
541 SetCategoryState( EChannelCompleted ); |
|
542 if ( 0 == iChannelCategoryKey ) |
|
543 { |
|
544 // Channel category can be deleted when not used. |
|
545 // Otherwise it has been appended to iCategoryTable and |
|
546 // can not be deleted here. |
|
547 delete iChannelCategory; |
|
548 } |
|
549 iChannelCategory = NULL; |
|
550 iChannelCategoryKey = 0; |
|
551 iState = EIptvRssState; |
|
552 IPTVLOGSTRING_LOW_LEVEL( |
|
553 "RSS Plugin::State changed from EIptvRssChannelState to EIptvRssState" ); |
|
554 } |
|
555 } |
|
556 break; |
|
557 |
|
558 case EIptvRssChannelDescriptionState: |
|
559 { |
|
560 if ( localName.CompareF( KIptvRssDescription ) == 0 ) |
|
561 { |
|
562 CompleteDescription(); |
|
563 iState = EIptvRssChannelState; |
|
564 IPTVLOGSTRING_LOW_LEVEL( |
|
565 "RSS Plugin::State changed from EIptvRssChannelDescriptionState to EIptvRssChannelState" ); |
|
566 } |
|
567 } |
|
568 break; |
|
569 |
|
570 case EIptvRssChannelLinkState: |
|
571 { |
|
572 if ( localName.CompareF( KIptvRssLink ) == 0 ) |
|
573 { |
|
574 CompleteLink(); |
|
575 iState = EIptvRssChannelState; |
|
576 IPTVLOGSTRING_LOW_LEVEL( |
|
577 "RSS Plugin::State changed from EIptvRssChannelLinkState to EIptvRssChannelState" ); |
|
578 } |
|
579 } |
|
580 break; |
|
581 |
|
582 case EIptvRssChannelTitleState: |
|
583 { |
|
584 if ( localName.CompareF( KIptvRssTitle ) == 0 ) |
|
585 { |
|
586 CompleteTitle(); |
|
587 iState = EIptvRssChannelState; |
|
588 IPTVLOGSTRING_LOW_LEVEL( |
|
589 "RSS Plugin::State changed from EIptvRssChannelTitleState to EIptvRssChannelState" ); |
|
590 } |
|
591 } |
|
592 break; |
|
593 |
|
594 case EIptvRssChannelImageUrlState: |
|
595 { |
|
596 if ( localName.CompareF( KIptvRssUrl ) == 0 ) |
|
597 { |
|
598 if ( iBuffer ) |
|
599 { |
|
600 AddServiceToDlQueueL( iBuffer->Des() ); |
|
601 } |
|
602 |
|
603 iState = EIptvRssChannelImageState; |
|
604 IPTVLOGSTRING_LOW_LEVEL( |
|
605 "RSS Plugin::State changed from EIptvRssChannelImageUrlState to EIptvRssChannelImageState" ); |
|
606 } |
|
607 } |
|
608 break; |
|
609 |
|
610 case EIptvRssChannelImageState: |
|
611 { |
|
612 if ( localName.CompareF( KIptvRssImage ) == 0 ) |
|
613 { |
|
614 iState = EIptvRssChannelState; |
|
615 IPTVLOGSTRING_LOW_LEVEL( |
|
616 "RSS Plugin::State changed from EIptvRssChannelImageState to EIptvRssChannelState " ); |
|
617 } |
|
618 } |
|
619 break; |
|
620 |
|
621 case EIptvRssItemState: |
|
622 { |
|
623 if ( localName.CompareF( KIptvRssItem ) == 0 ) |
|
624 { |
|
625 SetCategoryState( EItemCompleted ); |
|
626 PriorizeL(); |
|
627 if ( 0 == iCurrentCategoryKeys.Count() ) |
|
628 { |
|
629 SetChannelCategoryL(); // default when others not set |
|
630 } |
|
631 AddContentL(); |
|
632 |
|
633 iMediaDescriptionFixed = EFalse; |
|
634 iMediaTitleFixed = EFalse; |
|
635 iMediaRatingFixed = EFalse; |
|
636 iMediaCopyrightFixed = EFalse; |
|
637 iMediaThumbnailFixed = EFalse; |
|
638 |
|
639 iState = EIptvRssChannelState; |
|
640 IPTVLOGSTRING_LOW_LEVEL( |
|
641 "RSS Plugin::State changed from EIptvRssItemState to EIptvRssChannelState" ); |
|
642 } |
|
643 } |
|
644 break; |
|
645 |
|
646 case EIptvRssItemDescriptionState: |
|
647 { |
|
648 if ( localName.CompareF( KIptvRssDescription ) == 0 ) |
|
649 { |
|
650 CompleteDescription(); |
|
651 if ( iMediaGroup ) |
|
652 { |
|
653 iState = EIptvRssItemMediaGroupState; |
|
654 IPTVLOGSTRING_LOW_LEVEL( |
|
655 "RSS Plugin::State changed from EIptvRssItemDescriptionState to EIptvRssItemMediaGroupState" ); |
|
656 } |
|
657 else |
|
658 { |
|
659 iState = EIptvRssItemState; |
|
660 IPTVLOGSTRING_LOW_LEVEL( |
|
661 "RSS Plugin::State changed from EIptvRssItemDescriptionState to EIptvRssItemState" ); |
|
662 } |
|
663 } |
|
664 } |
|
665 break; |
|
666 |
|
667 case EIptvRssItemLinkState: |
|
668 { |
|
669 if ( localName.CompareF( KIptvRssLink ) == 0 ) |
|
670 { |
|
671 CompleteLink(); |
|
672 iState = EIptvRssItemState; |
|
673 IPTVLOGSTRING_LOW_LEVEL( |
|
674 "RSS Plugin::State changed from EIptvRssItemLinkState to EIptvRssItemState" ); |
|
675 } |
|
676 } |
|
677 break; |
|
678 |
|
679 case EIptvRssItemTitleState: |
|
680 { |
|
681 if ( localName.CompareF( KIptvRssTitle ) == 0 ) |
|
682 { |
|
683 CompleteTitle(); |
|
684 if ( iMediaGroup ) |
|
685 { |
|
686 iState = EIptvRssItemMediaGroupState; |
|
687 IPTVLOGSTRING_LOW_LEVEL( |
|
688 "RSS Plugin::State changed from EIptvRssItemTitleState to EIptvRssItemMediaGroupState" ); |
|
689 } |
|
690 else |
|
691 { |
|
692 iState = EIptvRssItemState; |
|
693 IPTVLOGSTRING_LOW_LEVEL( |
|
694 "RSS Plugin::State changed from EIptvRssItemTitleState to EIptvRssItemState" ); |
|
695 } |
|
696 } |
|
697 } |
|
698 break; |
|
699 |
|
700 case EIptvRssItemEnclosureState: |
|
701 { |
|
702 if ( localName.CompareF( KIptvRssEnclosure ) == 0 ) |
|
703 { |
|
704 iState = EIptvRssItemState; |
|
705 IPTVLOGSTRING_LOW_LEVEL( |
|
706 "RSS Plugin::State changed from EIptvRssItemEnclosureState to EIptvRssItemState" ); |
|
707 } |
|
708 } |
|
709 break; |
|
710 |
|
711 case EIptvRssItemGuidState: |
|
712 { |
|
713 if ( localName.CompareF( KIptvRssGuid ) == 0 ) |
|
714 { |
|
715 CompleteGuid(); |
|
716 iState = EIptvRssItemState; |
|
717 IPTVLOGSTRING_LOW_LEVEL( |
|
718 "RSS Plugin::State changed from EIptvRssItemGuidState to EIptvRssItemState" ); |
|
719 } |
|
720 } |
|
721 break; |
|
722 |
|
723 case EIptvRssItemPubDate: |
|
724 { |
|
725 if ( localName.CompareF( KIptvRssPubDate ) == 0 ) |
|
726 { |
|
727 CompletePubDate(); |
|
728 iState = EIptvRssItemState; |
|
729 IPTVLOGSTRING_LOW_LEVEL( |
|
730 "RSS Plugin::State changed from EIptvRssItemPubDate to EIptvRssItemState" ); |
|
731 } |
|
732 } |
|
733 break; |
|
734 |
|
735 case EIptvRssItemMediaContentState: |
|
736 { |
|
737 if ( localName.CompareF( KIptvRssMediaContent ) == 0 ) |
|
738 { |
|
739 if ( iMediaGroup ) |
|
740 { |
|
741 iState = EIptvRssItemMediaGroupState; |
|
742 IPTVLOGSTRING_LOW_LEVEL( |
|
743 "RSS Plugin::State changed from EIptvRssItemMediaContentState to EIptvRssItemMediaGroupState" ); |
|
744 } |
|
745 else |
|
746 { |
|
747 iMediaGroup = EFalse; |
|
748 iState = EIptvRssItemState; |
|
749 IPTVLOGSTRING_LOW_LEVEL( |
|
750 "RSS Plugin::State changed from EIptvRssItemMediaContentState to EIptvRssItemState" ); |
|
751 } |
|
752 } |
|
753 } |
|
754 break; |
|
755 |
|
756 case EIptvRssItemMediaGroupState: |
|
757 { |
|
758 if ( localName.CompareF( KIptvRssMediaGroup ) == 0 ) |
|
759 { |
|
760 iMediaGroup = EFalse; |
|
761 iState = EIptvRssItemState; |
|
762 IPTVLOGSTRING_LOW_LEVEL( |
|
763 "RSS Plugin::State changed from EIptvRssItemMediaGroupState to EIptvRssItemState" ); |
|
764 } |
|
765 } |
|
766 break; |
|
767 |
|
768 case EIptvRssItemMediaThumbnailState: |
|
769 { |
|
770 if ( localName.CompareF( KIptvRssThumbnail ) == 0 ) |
|
771 { |
|
772 if ( iMediaGroup ) |
|
773 { |
|
774 iState = EIptvRssItemMediaGroupState; |
|
775 IPTVLOGSTRING_LOW_LEVEL( |
|
776 "RSS Plugin::State changed from EIptvRssItemMediaThumbnailState to EIptvRssItemMediaGroupState" ); |
|
777 } |
|
778 else |
|
779 { |
|
780 iMediaGroup = EFalse; |
|
781 iState = EIptvRssItemState; |
|
782 IPTVLOGSTRING_LOW_LEVEL( |
|
783 "RSS Plugin::State changed from EIptvRssItemMediaThumbnailState to EIptvRssItemState" ); |
|
784 } |
|
785 } |
|
786 } |
|
787 break; |
|
788 |
|
789 case EIptvRssItemAuthorState: |
|
790 { |
|
791 if ( localName.CompareF( KIptvRssAuthor ) == 0 ) |
|
792 { |
|
793 CompleteAuthor(); |
|
794 iState = EIptvRssItemState; |
|
795 IPTVLOGSTRING_LOW_LEVEL( |
|
796 "RSS Plugin::State changed from EIptvRssItemAuthorState to EIptvRssItemState" ); |
|
797 } |
|
798 } |
|
799 break; |
|
800 |
|
801 case EIptvRssItemMediaCopyrightState: |
|
802 { |
|
803 if ( localName.CompareF( KIptvRssMediaCopyright ) == 0 ) |
|
804 { |
|
805 CompleteCopyright(); |
|
806 if ( iMediaGroup ) |
|
807 { |
|
808 iState = EIptvRssItemMediaGroupState; |
|
809 IPTVLOGSTRING_LOW_LEVEL( |
|
810 "RSS Plugin::State changed from EIptvRssItemMediaCopyrightState to EIptvRssItemMediaGroupState" ); |
|
811 } |
|
812 else |
|
813 { |
|
814 iState = EIptvRssItemState; |
|
815 IPTVLOGSTRING_LOW_LEVEL( |
|
816 "RSS Plugin::State changed from EIptvRssItemMediaCopyrightState to EIptvRssItemState" ); |
|
817 } |
|
818 } |
|
819 } |
|
820 break; |
|
821 |
|
822 case EIptvRssItemRatingState: |
|
823 { |
|
824 if ( localName.CompareF( KIptvRssMediaRating ) == 0 ) |
|
825 { |
|
826 CompleteRating(); |
|
827 if ( iMediaGroup ) |
|
828 { |
|
829 iState = EIptvRssItemMediaGroupState; |
|
830 IPTVLOGSTRING_LOW_LEVEL( |
|
831 "RSS Plugin::State changed from EIptvRssItemRatingState to EIptvRssItemMediaGroupState" ); |
|
832 } |
|
833 else |
|
834 { |
|
835 iState = EIptvRssItemState; |
|
836 IPTVLOGSTRING_LOW_LEVEL( |
|
837 "RSS Plugin::State changed from EIptvRssItemRatingState to EIptvRssItemState" ); |
|
838 } |
|
839 } |
|
840 } |
|
841 break; |
|
842 |
|
843 case EIptvRssItemMediaCategoryState: |
|
844 { |
|
845 if ( localName.CompareF( KIptvRssMediaCategory ) == 0 ) |
|
846 { |
|
847 CompleteCategoryL(); |
|
848 if ( iMediaGroup ) |
|
849 { |
|
850 iState = EIptvRssItemMediaGroupState; |
|
851 IPTVLOGSTRING_LOW_LEVEL( |
|
852 "RSS Plugin::State changed from EIptvRssItemMediaCategoryState to EIptvRssItemMediaGroupState" ); |
|
853 } |
|
854 else |
|
855 { |
|
856 iState = EIptvRssItemState; |
|
857 IPTVLOGSTRING_LOW_LEVEL( |
|
858 "RSS Plugin::State changed from EIptvRssItemMediaCategoryState to EIptvRssItemState" ); |
|
859 } |
|
860 } |
|
861 } |
|
862 break; |
|
863 |
|
864 case EIptvRssItemMediaCategoryEnclosureState: |
|
865 { |
|
866 if ( localName.CompareF( KIptvRssMediaCategory ) == 0 ) |
|
867 { |
|
868 // Category already got as label. |
|
869 if ( iMediaGroup ) |
|
870 { |
|
871 iState = EIptvRssItemMediaGroupState; |
|
872 IPTVLOGSTRING_LOW_LEVEL( |
|
873 "RSS Plugin::State changed from EIptvRssItemMediaCategoryEnclosureState to EIptvRssItemMediaGroupState" ); |
|
874 } |
|
875 else |
|
876 { |
|
877 iState = EIptvRssItemState; |
|
878 IPTVLOGSTRING_LOW_LEVEL( |
|
879 "RSS Plugin::State changed from EIptvRssItemMediaCategoryEnclosureState to EIptvRssItemState" ); |
|
880 } |
|
881 } |
|
882 } |
|
883 break; |
|
884 |
|
885 default: |
|
886 break; |
|
887 } |
|
888 |
|
889 CleanupStack::PopAndDestroy( name ); |
|
890 name = NULL; |
|
891 |
|
892 delete iBuffer; |
|
893 iBuffer = NULL; |
|
894 |
|
895 iMediaPrefix = EFalse; |
|
896 } |
|
897 |
|
898 // -------------------------------------------------------------------------- |
|
899 // Callback that sends the content of the element. |
|
900 // Not all the content may be returned in one go. The data may be sent in |
|
901 // chunks. When an OnEndElementL is received this means there is no more |
|
902 // content to be sent. |
|
903 // -------------------------------------------------------------------------- |
|
904 // |
|
905 void CIptvXmlContentHandler::OnContentL( |
|
906 const TDesC8& aBytes, |
|
907 TInt aErrorCode ) |
|
908 { |
|
909 IPTVLOGSTRING_LOW_LEVEL( |
|
910 "RSS Plugin::CIptvXmlContentHandler::OnContentL" ); |
|
911 |
|
912 if ( aErrorCode != KErrNone ) |
|
913 { |
|
914 iPlugin.SetParsingFailed(); |
|
915 return; |
|
916 } |
|
917 |
|
918 // Number of new bytes. |
|
919 TInt length = aBytes.Length(); |
|
920 |
|
921 HBufC* convBuf = HBufC::NewLC( length ); |
|
922 TPtr16 convPtr = convBuf->Des(); |
|
923 |
|
924 // Convert new bytes. |
|
925 CnvUtfConverter::ConvertToUnicodeFromUtf8( convPtr, aBytes ); |
|
926 |
|
927 // Total number of bytes. |
|
928 if ( iBuffer ) |
|
929 { |
|
930 length = length + iBuffer->Length(); |
|
931 } |
|
932 |
|
933 // Create new buffer. |
|
934 HBufC* newBuf = HBufC::NewLC( length ); |
|
935 TPtr16 newPtr = newBuf->Des(); |
|
936 |
|
937 // Append and delete old buffer |
|
938 if ( iBuffer ) |
|
939 { |
|
940 newPtr.Append( iBuffer->Des() ); |
|
941 delete iBuffer; |
|
942 iBuffer = NULL; |
|
943 } |
|
944 |
|
945 newPtr.Append( convPtr ); |
|
946 iBuffer = newBuf; |
|
947 |
|
948 CleanupStack::Pop( newBuf ); |
|
949 CleanupStack::PopAndDestroy( convBuf ); |
|
950 convBuf = NULL; |
|
951 } |
|
952 |
|
953 // -------------------------------------------------------------------------- |
|
954 // Notification of the beginning of the scope of a prefix-URI Namespace |
|
955 // mapping.This method is always called before the corresponding |
|
956 // OnStartElementL method. |
|
957 // -------------------------------------------------------------------------- |
|
958 // |
|
959 void CIptvXmlContentHandler::OnStartPrefixMappingL( |
|
960 const RString& /*aPrefix*/, |
|
961 const RString& /*aUri*/, |
|
962 TInt aErrorCode ) |
|
963 { |
|
964 IPTVLOGSTRING_LOW_LEVEL( |
|
965 "RSS Plugin::CIptvXmlContentHandler::OnStartPrefixMappingL" ); |
|
966 |
|
967 if ( aErrorCode != KErrNone ) |
|
968 { |
|
969 iPlugin.SetParsingFailed(); |
|
970 } |
|
971 } |
|
972 |
|
973 // -------------------------------------------------------------------------- |
|
974 // Notification of the end of the scope of a prefix-URI mapping. |
|
975 // This method is called after the corresponding DoEndElementL method. |
|
976 // -------------------------------------------------------------------------- |
|
977 // |
|
978 void CIptvXmlContentHandler::OnEndPrefixMappingL( |
|
979 const RString& /*aPrefix*/, |
|
980 TInt aErrorCode ) |
|
981 { |
|
982 IPTVLOGSTRING_LOW_LEVEL( |
|
983 "RSS Plugin::CIptvXmlContentHandler::OnEndPrefixMappingL" ); |
|
984 |
|
985 if ( aErrorCode != KErrNone ) |
|
986 { |
|
987 iPlugin.SetParsingFailed(); |
|
988 } |
|
989 } |
|
990 |
|
991 // -------------------------------------------------------------------------- |
|
992 // Notification of ignorable whitespace in element content. |
|
993 // -------------------------------------------------------------------------- |
|
994 // |
|
995 void CIptvXmlContentHandler::OnIgnorableWhiteSpaceL( |
|
996 const TDesC8& /*aBytes*/, |
|
997 TInt aErrorCode ) |
|
998 { |
|
999 IPTVLOGSTRING_LOW_LEVEL( |
|
1000 "RSS Plugin::CIptvXmlContentHandler::OnIgnorableWhiteSpaceL" ); |
|
1001 |
|
1002 if ( aErrorCode != KErrNone ) |
|
1003 { |
|
1004 iPlugin.SetParsingFailed(); |
|
1005 } |
|
1006 } |
|
1007 |
|
1008 // -------------------------------------------------------------------------- |
|
1009 // Notification of a skipped entity. If the parser encounters an |
|
1010 // external entity it does not need to expand it - it can return the |
|
1011 // entity as aName for the client to deal with. |
|
1012 // -------------------------------------------------------------------------- |
|
1013 // |
|
1014 void CIptvXmlContentHandler::OnSkippedEntityL( |
|
1015 const RString& /*aName*/, |
|
1016 TInt aErrorCode ) |
|
1017 { |
|
1018 IPTVLOGSTRING_LOW_LEVEL( |
|
1019 "RSS Plugin::CIptvXmlContentHandler::OnSkippedEntityL" ); |
|
1020 |
|
1021 if ( aErrorCode != KErrNone ) |
|
1022 { |
|
1023 iPlugin.SetParsingFailed(); |
|
1024 } |
|
1025 } |
|
1026 |
|
1027 // -------------------------------------------------------------------------- |
|
1028 // Notification of a processing instruction. |
|
1029 // -------------------------------------------------------------------------- |
|
1030 // |
|
1031 void CIptvXmlContentHandler::OnProcessingInstructionL( |
|
1032 const TDesC8& /*aTarget*/, |
|
1033 const TDesC8& /*aData*/, |
|
1034 TInt aErrorCode ) |
|
1035 { |
|
1036 IPTVLOGSTRING_LOW_LEVEL( |
|
1037 "RSS Plugin::CIptvXmlContentHandler::OnProcessingInstructionL" ); |
|
1038 |
|
1039 if ( aErrorCode != KErrNone ) |
|
1040 { |
|
1041 iPlugin.SetParsingFailed(); |
|
1042 } |
|
1043 } |
|
1044 |
|
1045 // -------------------------------------------------------------------------- |
|
1046 // Notification of XML file parsing is failure. |
|
1047 // -------------------------------------------------------------------------- |
|
1048 // |
|
1049 void CIptvXmlContentHandler::OnError( TInt aErrorCode ) |
|
1050 { |
|
1051 IPTVLOGSTRING_LOW_LEVEL( "RSS Plugin::CIptvXmlContentHandler::OnError" ); |
|
1052 |
|
1053 switch ( aErrorCode ) |
|
1054 { |
|
1055 case EXmlParserError: |
|
1056 IPTVLOGSTRING_LOW_LEVEL( |
|
1057 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlParserError" ); |
|
1058 break; |
|
1059 |
|
1060 case EXmlSyntax: |
|
1061 IPTVLOGSTRING_LOW_LEVEL( |
|
1062 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlSyntax" ); |
|
1063 break; |
|
1064 |
|
1065 case EXmlNoElements: |
|
1066 IPTVLOGSTRING_LOW_LEVEL( |
|
1067 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlNoElements" ); |
|
1068 break; |
|
1069 |
|
1070 case EXmlInvalidToken: |
|
1071 IPTVLOGSTRING_LOW_LEVEL( |
|
1072 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlInvalidToken" ); |
|
1073 break; |
|
1074 |
|
1075 case EXmlUnclosedToken: |
|
1076 IPTVLOGSTRING_LOW_LEVEL( |
|
1077 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlUnclosedToken" ); |
|
1078 break; |
|
1079 |
|
1080 case EXmlPartialChar: |
|
1081 IPTVLOGSTRING_LOW_LEVEL( |
|
1082 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlPartialChar" ); |
|
1083 break; |
|
1084 |
|
1085 case EXmlTagMismatch: |
|
1086 IPTVLOGSTRING_LOW_LEVEL( |
|
1087 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlTagMismatch" ); |
|
1088 break; |
|
1089 |
|
1090 case EXmlDuplicateAttribute: |
|
1091 IPTVLOGSTRING_LOW_LEVEL( |
|
1092 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlDuplicateAttribute" ); |
|
1093 break; |
|
1094 |
|
1095 case EXmlJunkAfterDocElement: |
|
1096 IPTVLOGSTRING_LOW_LEVEL( |
|
1097 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlJunkAfterDocElement" ); |
|
1098 break; |
|
1099 |
|
1100 case EXmlPeRef: |
|
1101 IPTVLOGSTRING_LOW_LEVEL( |
|
1102 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlPeRef" ); |
|
1103 break; |
|
1104 |
|
1105 case EXmlUndefinedEntity: |
|
1106 IPTVLOGSTRING_LOW_LEVEL( |
|
1107 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlUndefinedEntity" ); |
|
1108 break; |
|
1109 |
|
1110 case EXmlRecursiveEntity: |
|
1111 IPTVLOGSTRING_LOW_LEVEL( |
|
1112 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlRecursiveEntity" ); |
|
1113 break; |
|
1114 |
|
1115 case EXmlAsyncEntity: |
|
1116 IPTVLOGSTRING_LOW_LEVEL( |
|
1117 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlAsyncEntity" ); |
|
1118 break; |
|
1119 |
|
1120 case EXmlBadCharRef: |
|
1121 IPTVLOGSTRING_LOW_LEVEL( |
|
1122 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlBadCharRef" ); |
|
1123 break; |
|
1124 |
|
1125 case EXmlBinaryEntityRef: |
|
1126 IPTVLOGSTRING_LOW_LEVEL( |
|
1127 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlBinaryEntityRef" ); |
|
1128 break; |
|
1129 |
|
1130 case EXmlAttributeExternalEntityRef: |
|
1131 IPTVLOGSTRING_LOW_LEVEL( |
|
1132 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlAttributeExternalEntityRef" ); |
|
1133 break; |
|
1134 |
|
1135 case EXmlMisplacedPi: |
|
1136 IPTVLOGSTRING_LOW_LEVEL( |
|
1137 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlMisplacedPi" ); |
|
1138 break; |
|
1139 |
|
1140 case EXmlUnknownEncoding: |
|
1141 IPTVLOGSTRING_LOW_LEVEL( |
|
1142 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlUnknownEncoding" ); |
|
1143 break; |
|
1144 |
|
1145 case EXmlIncorrectEncoding: |
|
1146 IPTVLOGSTRING_LOW_LEVEL( |
|
1147 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlIncorrectEncoding" ); |
|
1148 break; |
|
1149 |
|
1150 case EXmlUnclosedCdata: |
|
1151 IPTVLOGSTRING_LOW_LEVEL( |
|
1152 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlUnclosedCdata" ); |
|
1153 break; |
|
1154 |
|
1155 case EXmlExternalEntityHandling: |
|
1156 IPTVLOGSTRING_LOW_LEVEL( |
|
1157 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlExternalEntityHandling" ); |
|
1158 break; |
|
1159 |
|
1160 case EXmlNotStandalone: |
|
1161 IPTVLOGSTRING_LOW_LEVEL( |
|
1162 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlNotStandalone" ); |
|
1163 break; |
|
1164 |
|
1165 case EXmlUnexpectedState: |
|
1166 IPTVLOGSTRING_LOW_LEVEL( |
|
1167 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlUnexpectedState" ); |
|
1168 break; |
|
1169 |
|
1170 case EXmlEntityDeclInPe: |
|
1171 IPTVLOGSTRING_LOW_LEVEL( |
|
1172 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlEntityDeclInPe" ); |
|
1173 break; |
|
1174 |
|
1175 case EXmlDtdRequired: |
|
1176 IPTVLOGSTRING_LOW_LEVEL( |
|
1177 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlDtdRequired" ); |
|
1178 break; |
|
1179 |
|
1180 case EXmlFeatureLockedWhileParsing: |
|
1181 IPTVLOGSTRING_LOW_LEVEL( |
|
1182 "RSS Plugin::CIptvXmlContentHandler::OnError --- EXmlFeatureLockedWhileParsing" ); |
|
1183 break; |
|
1184 |
|
1185 default: |
|
1186 IPTVLOGSTRING_LOW_LEVEL( |
|
1187 "RSS Plugin::CIptvXmlContentHandler::OnError --- Unknown error" ); |
|
1188 break; |
|
1189 } |
|
1190 |
|
1191 iPlugin.SetParsingFailed(); |
|
1192 } |
|
1193 |
|
1194 // -------------------------------------------------------------------------- |
|
1195 // Obtains the interface matching the specified uid. |
|
1196 // -------------------------------------------------------------------------- |
|
1197 // |
|
1198 TAny* CIptvXmlContentHandler::GetExtendedInterface( const TInt32 /*aUid*/ ) |
|
1199 { |
|
1200 IPTVLOGSTRING_LOW_LEVEL( |
|
1201 "RSS Plugin::CIptvXmlContentHandler::GetExtendedInterface" ); |
|
1202 |
|
1203 return NULL; |
|
1204 } |
|
1205 |
|
1206 // -------------------------------------------------------------------------- |
|
1207 // Handles item copyright value. |
|
1208 // -------------------------------------------------------------------------- |
|
1209 // |
|
1210 void CIptvXmlContentHandler::CompleteCopyright() |
|
1211 { |
|
1212 IPTVLOGSTRING_LOW_LEVEL( |
|
1213 "RSS Plugin::CIptvXmlContentHandler::CompleteCopyright" ); |
|
1214 |
|
1215 if ( iBuffer ) |
|
1216 { |
|
1217 // Media Description should override other Description values. |
|
1218 if ( iMediaPrefix || iMediaGroup || !iMediaCopyrightFixed ) |
|
1219 { |
|
1220 TInt descLength = iBuffer->Length(); |
|
1221 if ( iState == EIptvRssItemMediaCopyrightState ) |
|
1222 { |
|
1223 TInt dataToCopy = |
|
1224 Min( descLength, KIptvEpgContentCopyrightLength ); |
|
1225 if ( iContent ) |
|
1226 { |
|
1227 iContent->iCopyright.Copy( iBuffer->Mid( 0, dataToCopy ) ); |
|
1228 iMediaCopyrightFixed = iMediaPrefix || iMediaGroup; |
|
1229 } |
|
1230 } |
|
1231 } |
|
1232 } |
|
1233 } |
|
1234 |
|
1235 // -------------------------------------------------------------------------- |
|
1236 // Handles parent rating value. |
|
1237 // -------------------------------------------------------------------------- |
|
1238 // |
|
1239 void CIptvXmlContentHandler::CompleteRating() |
|
1240 { |
|
1241 IPTVLOGSTRING_LOW_LEVEL( |
|
1242 "RSS Plugin::CIptvXmlContentHandler::CompleteRating" ); |
|
1243 |
|
1244 // Media Rating should override other Rating values. |
|
1245 if ( iBuffer && ( iMediaPrefix || iMediaGroup || !iMediaRatingFixed ) ) |
|
1246 { |
|
1247 if ( iState == EIptvRssItemRatingState ) |
|
1248 { |
|
1249 if ( EMediaRatingSimple == iMediaRatingScheme ) |
|
1250 { |
|
1251 if ( 0 == iBuffer->CompareF( KIptvRssMediaAdult ) ) |
|
1252 { |
|
1253 iContent->iRatingAge = KRatingAgeAdult; |
|
1254 } |
|
1255 else |
|
1256 { |
|
1257 iContent->iRatingAge = KRatingAgeUnlimited; |
|
1258 } |
|
1259 } |
|
1260 else if ( EMediaRatingNum == iMediaRatingScheme ) |
|
1261 { |
|
1262 TBuf<KIptvMediaRatingAgeLength> ageValue; |
|
1263 TInt16 ratingAge( KRatingAgeUnlimited ); |
|
1264 TInt dataToCopy( Min( |
|
1265 KIptvMediaRatingAgeLength, iBuffer->Length() ) ); |
|
1266 ageValue.Copy( iBuffer->Mid( 0, dataToCopy ) ); |
|
1267 |
|
1268 if ( ageValue.Compare( KIptvEmptyDes ) != 0 ) |
|
1269 { |
|
1270 TLex age( ageValue ); |
|
1271 age.Val( ratingAge ); |
|
1272 } |
|
1273 |
|
1274 if ( KRatingAgeAdult < ratingAge ) |
|
1275 { |
|
1276 iContent->iRatingAge = KRatingAgeAdult; |
|
1277 } |
|
1278 else if ( 0 > ratingAge ) |
|
1279 { |
|
1280 iContent->iRatingAge = KRatingAgeUnlimited; |
|
1281 } |
|
1282 else |
|
1283 { |
|
1284 iContent->iRatingAge = ratingAge; |
|
1285 } |
|
1286 } |
|
1287 else |
|
1288 { |
|
1289 iContent->iRatingAge = KRatingAgeUnlimited; |
|
1290 } |
|
1291 |
|
1292 iMediaRatingFixed = iMediaPrefix || iMediaGroup; |
|
1293 } |
|
1294 } |
|
1295 } |
|
1296 |
|
1297 // -------------------------------------------------------------------------- |
|
1298 // Handles item category value. |
|
1299 // -------------------------------------------------------------------------- |
|
1300 // |
|
1301 void CIptvXmlContentHandler::CompleteCategoryL() |
|
1302 { |
|
1303 IPTVLOGSTRING_LOW_LEVEL( |
|
1304 "RSS Plugin::CIptvXmlContentHandler::CompleteCategoryL" ); |
|
1305 |
|
1306 if ( iBuffer ) |
|
1307 { |
|
1308 if ( EIptvRssItemMediaCategoryState == iState ) |
|
1309 { |
|
1310 SetItemCategoryL( iBuffer ); |
|
1311 } |
|
1312 } |
|
1313 } |
|
1314 |
|
1315 // -------------------------------------------------------------------------- |
|
1316 // Handles item category value. |
|
1317 // -------------------------------------------------------------------------- |
|
1318 // |
|
1319 void CIptvXmlContentHandler::CompleteCategoryL( const HBufC* aName ) |
|
1320 { |
|
1321 IPTVLOGSTRING_LOW_LEVEL( |
|
1322 "RSS Plugin::CIptvXmlContentHandler::CompleteCategoryL" ); |
|
1323 |
|
1324 if ( aName ) |
|
1325 { |
|
1326 if ( EIptvRssItemMediaCategoryEnclosureState == iState ) |
|
1327 { |
|
1328 SetItemCategoryL( aName ); |
|
1329 } |
|
1330 } |
|
1331 } |
|
1332 |
|
1333 // -------------------------------------------------------------------------- |
|
1334 // Handles item author value. |
|
1335 // -------------------------------------------------------------------------- |
|
1336 // |
|
1337 void CIptvXmlContentHandler::CompleteAuthor() |
|
1338 { |
|
1339 IPTVLOGSTRING_LOW_LEVEL( |
|
1340 "RSS Plugin::CIptvXmlContentHandler::CompleteAuthor" ); |
|
1341 |
|
1342 if ( iBuffer ) |
|
1343 { |
|
1344 TInt descLength = iBuffer->Length(); |
|
1345 if ( iState == EIptvRssItemAuthorState ) |
|
1346 { |
|
1347 TInt dataToCopy = Min( descLength, KIptvEpgContentAuthorLength ); |
|
1348 if ( iContent ) |
|
1349 { |
|
1350 iContent->iAuthor.Copy( iBuffer->Mid( 0, dataToCopy ) ); |
|
1351 } |
|
1352 } |
|
1353 } |
|
1354 } |
|
1355 |
|
1356 // -------------------------------------------------------------------------- |
|
1357 // Handles item and category description value. |
|
1358 // -------------------------------------------------------------------------- |
|
1359 // |
|
1360 void CIptvXmlContentHandler::CompleteDescription() |
|
1361 { |
|
1362 IPTVLOGSTRING_LOW_LEVEL( |
|
1363 "RSS Plugin::CIptvXmlContentHandler::CompleteDescription" ); |
|
1364 |
|
1365 if ( iBuffer ) |
|
1366 { |
|
1367 TInt descLength = iBuffer->Length(); |
|
1368 //lint -e{961} Else block not needed, default is no operation. |
|
1369 if ( iState == EIptvRssChannelDescriptionState ) |
|
1370 { |
|
1371 TInt dataToCopy = |
|
1372 Min( descLength, KIptvEpgCategoryDescriptionMaxLength ); |
|
1373 if ( iChannelCategory ) |
|
1374 { |
|
1375 iChannelCategory->iDescription.Copy( |
|
1376 iBuffer->Mid( 0, dataToCopy ) ); |
|
1377 } |
|
1378 } |
|
1379 else if ( iState == EIptvRssItemDescriptionState ) |
|
1380 { |
|
1381 // Media Description should override other Description values. |
|
1382 if ( iMediaPrefix || iMediaGroup || !iMediaDescriptionFixed ) |
|
1383 { |
|
1384 TInt dataToCopy = |
|
1385 Min( descLength, KIptvEpgContentDescriptionMaxLength ); |
|
1386 if ( iContent ) |
|
1387 { |
|
1388 iContent->iDescription.Copy( |
|
1389 iBuffer->Mid( 0, dataToCopy ) ); |
|
1390 iMediaDescriptionFixed = iMediaPrefix || iMediaGroup; |
|
1391 } |
|
1392 } |
|
1393 } |
|
1394 } |
|
1395 } |
|
1396 |
|
1397 // -------------------------------------------------------------------------- |
|
1398 // Handles item and category title value. |
|
1399 // -------------------------------------------------------------------------- |
|
1400 // |
|
1401 void CIptvXmlContentHandler::CompleteTitle() |
|
1402 { |
|
1403 IPTVLOGSTRING_LOW_LEVEL( |
|
1404 "RSS Plugin::CIptvXmlContentHandler::CompleteTitle" ); |
|
1405 |
|
1406 if ( iBuffer ) |
|
1407 { |
|
1408 TInt descLength = iBuffer->Length(); |
|
1409 //lint -e{961} Else block not needed, default is no operation. |
|
1410 if ( iState == EIptvRssChannelTitleState ) |
|
1411 { |
|
1412 TInt dataToCopy = |
|
1413 Min( descLength , KIptvEpgCategoryNameMaxLength ); |
|
1414 if ( iChannelCategory ) |
|
1415 { |
|
1416 iChannelCategory->iName.Copy( |
|
1417 iBuffer->Mid( 0, dataToCopy ) ); |
|
1418 } |
|
1419 } |
|
1420 else if ( iState == EIptvRssItemTitleState ) |
|
1421 { |
|
1422 // Media Title should override other Title values. |
|
1423 if ( iMediaPrefix || iMediaGroup || !iMediaTitleFixed ) |
|
1424 { |
|
1425 TInt dataToCopy = |
|
1426 Min( descLength, KIptvEpgContentNameMaxLength ); |
|
1427 if ( iContent ) |
|
1428 { |
|
1429 iContent->iName.Copy( iBuffer->Mid( 0, dataToCopy ) ); |
|
1430 iMediaTitleFixed = iMediaPrefix || iMediaGroup; |
|
1431 } |
|
1432 } |
|
1433 } |
|
1434 } |
|
1435 } |
|
1436 |
|
1437 // -------------------------------------------------------------------------- |
|
1438 // Handles item url link value. |
|
1439 // -------------------------------------------------------------------------- |
|
1440 // |
|
1441 void CIptvXmlContentHandler::CompleteLink() |
|
1442 { |
|
1443 IPTVLOGSTRING_LOW_LEVEL( |
|
1444 "RSS Plugin::CIptvXmlContentHandler::CompleteLink" ); |
|
1445 |
|
1446 if ( iBuffer ) |
|
1447 { |
|
1448 TInt descLength = iBuffer->Length(); |
|
1449 if ( iState == EIptvRssItemLinkState ) |
|
1450 { |
|
1451 if ( iContent ) |
|
1452 { |
|
1453 TInt dataToCopy = Min( |
|
1454 descLength, |
|
1455 KIptvEpgContentBrowserUrlMaxLength ); |
|
1456 |
|
1457 if ( dataToCopy <= KIptvUrlMaxLength ) |
|
1458 { |
|
1459 iContent->iBrowserUrl.Copy( iBuffer->Mid( 0, dataToCopy ) ); |
|
1460 } |
|
1461 } |
|
1462 } |
|
1463 } |
|
1464 } |
|
1465 |
|
1466 |
|
1467 // -------------------------------------------------------------------------- |
|
1468 // Handles item publish time value. |
|
1469 // -------------------------------------------------------------------------- |
|
1470 // |
|
1471 void CIptvXmlContentHandler::CompletePubDate() |
|
1472 { |
|
1473 IPTVLOGSTRING_LOW_LEVEL( |
|
1474 "RSS Plugin::CIptvXmlContentHandler::CompletePubDate" ); |
|
1475 |
|
1476 if ( iState == EIptvRssItemPubDate ) |
|
1477 { |
|
1478 TTime time; |
|
1479 TRAPD( error, CIptvXmlDateTime::ParseGmtL( iBuffer, time ) ); |
|
1480 if ( error == KErrNone ) |
|
1481 { |
|
1482 if ( iContent ) |
|
1483 { |
|
1484 iContent->iPubDate = time; |
|
1485 } |
|
1486 } |
|
1487 } |
|
1488 } |
|
1489 |
|
1490 // -------------------------------------------------------------------------- |
|
1491 // Handles item guid value. |
|
1492 // -------------------------------------------------------------------------- |
|
1493 // |
|
1494 void CIptvXmlContentHandler::CompleteGuid() |
|
1495 { |
|
1496 IPTVLOGSTRING_LOW_LEVEL( |
|
1497 "RSS Plugin::CIptvXmlContentHandler::CompleteGuid" ); |
|
1498 |
|
1499 if ( iBuffer ) |
|
1500 { |
|
1501 TInt descLength = iBuffer->Length(); |
|
1502 if ( iState == EIptvRssItemGuidState ) |
|
1503 { |
|
1504 if ( iContent ) |
|
1505 { |
|
1506 TInt dataToCopy = Min( descLength, KIptvIdMaxLength ); |
|
1507 iContent->iId.Copy( iBuffer->Right( dataToCopy ) ); |
|
1508 } |
|
1509 } |
|
1510 } |
|
1511 } |
|
1512 |
|
1513 // -------------------------------------------------------------------------- |
|
1514 // Handles element attributes. |
|
1515 // -------------------------------------------------------------------------- |
|
1516 // |
|
1517 void CIptvXmlContentHandler::HandleEnclosureL( |
|
1518 const RAttributeArray& aAttributeList ) |
|
1519 { |
|
1520 IPTVLOGSTRING_LOW_LEVEL( |
|
1521 "RSS Plugin::CIptvXmlContentHandler::HandleEnclosureL" ); |
|
1522 |
|
1523 CIptvMediaContent* content( CIptvMediaContent::NewL() ); |
|
1524 CleanupStack::PushL( content ); |
|
1525 |
|
1526 TInt count = aAttributeList.Count(); |
|
1527 for ( TInt i = 0; i < count; i++ ) |
|
1528 { |
|
1529 // Name |
|
1530 const RTagInfo& tag = aAttributeList[i].Attribute(); |
|
1531 const TDesC8& n = tag.LocalName().DesC(); |
|
1532 TInt dataToCopy = Min( n.Length(), KIptvRssItemNameMaxLength ); |
|
1533 HBufC* name = HBufC::NewLC( dataToCopy ); |
|
1534 TPtr namePtr = name->Des(); |
|
1535 namePtr.Copy( n.Mid( 0, dataToCopy ) ); |
|
1536 |
|
1537 // Value |
|
1538 const TDesC8& v = aAttributeList[i].Value().DesC(); |
|
1539 dataToCopy = |
|
1540 Min( v.Length(), KIptvRssEnclosureParameterMaxValueLength ); |
|
1541 HBufC* value = HBufC::NewLC( dataToCopy ); |
|
1542 TPtr valuePtr = value->Des(); |
|
1543 valuePtr.Copy( v.Mid( 0, dataToCopy ) ); |
|
1544 |
|
1545 TInt valueLength = valuePtr.Length(); |
|
1546 |
|
1547 // RSS 2.0 |
|
1548 //lint -e{961} Else block not needed, default is no operation. |
|
1549 if ( iState == EIptvRssItemEnclosureState ) |
|
1550 { |
|
1551 if ( iContent ) |
|
1552 { |
|
1553 // Url |
|
1554 //lint -e{961} Else block not needed, default is no operation. |
|
1555 if ( namePtr.CompareF( KIptvRssUrl ) == 0 && |
|
1556 valueLength <= KIptvUrlMaxLength ) |
|
1557 { |
|
1558 content->SetMediaContentUrlL( valuePtr ); |
|
1559 content->iExpression = CIptvMediaContent::EFull; |
|
1560 |
|
1561 // Set download type according protocol, |
|
1562 // mime-type can change this later |
|
1563 if ( valuePtr.Left( KIptvProtocolNameLength ).CompareF( |
|
1564 KIptvRssHttp ) == 0 ) |
|
1565 { |
|
1566 content->iDownloadType = EIptvDownloadTypeImmediate; |
|
1567 } |
|
1568 else if ( valuePtr.Left( KIptvProtocolNameLength ).CompareF( |
|
1569 KIptvRssRtsp ) == 0 ) |
|
1570 { |
|
1571 content->iDownloadType = EIptvDownloadTypeStream; |
|
1572 } |
|
1573 } |
|
1574 // Type |
|
1575 else if ( namePtr.CompareF( KIptvRssType ) == 0 ) |
|
1576 { |
|
1577 dataToCopy = Min( valueLength, KIptvCAMimeTypeLength ); |
|
1578 content->iMimeType.Copy( valuePtr.Mid( 0, dataToCopy ) ); |
|
1579 } |
|
1580 // Length |
|
1581 else if ( namePtr.CompareF( KIptvRssLength ) == 0 ) |
|
1582 { |
|
1583 if ( valuePtr.Compare( KIptvEmptyDes ) != 0 ) |
|
1584 { |
|
1585 TLex l( valuePtr ); |
|
1586 l.Val( content->iFileSize, EDecimal ); |
|
1587 } |
|
1588 } |
|
1589 } |
|
1590 } |
|
1591 else if ( iState == EIptvRssChannelImageState ) |
|
1592 { |
|
1593 if ( namePtr.CompareF( KIptvRssHref ) == 0 ) |
|
1594 { |
|
1595 AddServiceToDlQueueL( valuePtr ); |
|
1596 } |
|
1597 } |
|
1598 else if ( iState == EIptvRssState ) |
|
1599 { |
|
1600 if ( namePtr.CompareF( KIptvRssMedia ) == 0 ) |
|
1601 { |
|
1602 if ( valuePtr.CompareF( KIptvYahooRss ) == 0 ) |
|
1603 { |
|
1604 iYahoo = ETrue; |
|
1605 } |
|
1606 } |
|
1607 } |
|
1608 // Yahoo media RSS |
|
1609 else if ( iState == EIptvRssItemMediaThumbnailState ) |
|
1610 { |
|
1611 // Media Description should override other Description values. |
|
1612 if ( iMediaPrefix || iMediaGroup || !iMediaThumbnailFixed ) |
|
1613 { |
|
1614 if ( namePtr.CompareF( KIptvRssUrl ) == 0 && |
|
1615 valueLength <= KIptvUrlMaxLength ) |
|
1616 { |
|
1617 dataToCopy = |
|
1618 Min( valueLength, KIptvEpgContentIconFilePathMaxLength ); |
|
1619 iContent->iIconFilePath.Copy( valuePtr.Mid( 0, dataToCopy ) ); |
|
1620 iContent->iIsIconFilePathUrl = ETrue; |
|
1621 iMediaThumbnailFixed = iMediaPrefix || iMediaGroup; |
|
1622 } |
|
1623 } |
|
1624 } |
|
1625 else if ( iState == EIptvRssItemMediaContentState ) |
|
1626 { |
|
1627 if ( iContent ) |
|
1628 { |
|
1629 // url |
|
1630 //lint -e{961} Else block not needed, default is no operation. |
|
1631 if ( namePtr.CompareF( KIptvRssUrl ) == 0 && |
|
1632 valueLength <= KIptvUrlMaxLength ) |
|
1633 { |
|
1634 content->SetMediaContentUrlL( valuePtr ); |
|
1635 |
|
1636 // Set download type according protocol, |
|
1637 // mime-type can change this later |
|
1638 if ( valuePtr.Left( KIptvProtocolNameLength ).CompareF( |
|
1639 KIptvRssHttp ) == 0 ) |
|
1640 { |
|
1641 content->iDownloadType = EIptvDownloadTypeImmediate; |
|
1642 } |
|
1643 else if ( valuePtr.Left( KIptvProtocolNameLength ).CompareF( |
|
1644 KIptvRssRtsp ) == 0 ) |
|
1645 { |
|
1646 content->iDownloadType = EIptvDownloadTypeStream; |
|
1647 } |
|
1648 } |
|
1649 // filesize |
|
1650 else if ( namePtr.CompareF( KIptvRssMediaFileSize ) == 0 ) |
|
1651 { |
|
1652 if ( valuePtr.Compare( KIptvEmptyDes ) != 0 ) |
|
1653 { |
|
1654 TLex l( valuePtr ); |
|
1655 l.Val( content->iFileSize, EDecimal ); |
|
1656 } |
|
1657 } |
|
1658 // mime-type |
|
1659 else if ( namePtr.CompareF( KIptvRssType ) == 0 ) |
|
1660 { |
|
1661 dataToCopy = Min( valueLength, KIptvCAMimeTypeLength ); |
|
1662 content->iMimeType.Copy( valuePtr.Mid( 0, dataToCopy ) ); |
|
1663 } |
|
1664 // medium |
|
1665 else if ( namePtr.CompareF( KIptvRssMediaMedium ) == 0 ) |
|
1666 { |
|
1667 dataToCopy = Min( valueLength, KIptvMediumMaxLength ); |
|
1668 content->iMedium.Copy( valuePtr.Mid( 0, dataToCopy ) ); |
|
1669 } |
|
1670 // isDefault |
|
1671 else if ( namePtr.CompareF( KIptvRssMediaIsDefault ) == 0 ) |
|
1672 { |
|
1673 if ( valuePtr.CompareF( KIptvTrue ) == 0 ) |
|
1674 { |
|
1675 content->iIsDefault = ETrue; |
|
1676 } |
|
1677 else |
|
1678 { |
|
1679 content->iIsDefault = EFalse; |
|
1680 } |
|
1681 } |
|
1682 // expression |
|
1683 else if ( namePtr.CompareF( KIptvRssMediaExpression ) == 0 ) |
|
1684 { |
|
1685 if ( valuePtr.CompareF( KIptvRssMediaSample ) == 0 ) |
|
1686 { |
|
1687 content->iExpression = CIptvMediaContent::ESample; |
|
1688 } |
|
1689 else if ( valuePtr.CompareF( KIptvRssMediaFull ) == 0 ) |
|
1690 { |
|
1691 content->iExpression = CIptvMediaContent::EFull; |
|
1692 } |
|
1693 else if ( valuePtr.CompareF( KIptvRssMediaNonStop ) == 0 ) |
|
1694 { |
|
1695 content->iExpression = CIptvMediaContent::ENonStop; |
|
1696 } |
|
1697 else |
|
1698 { |
|
1699 content->iExpression = CIptvMediaContent::EFull; |
|
1700 } |
|
1701 } |
|
1702 // bitrate |
|
1703 else if ( namePtr.CompareF( KIptvRssMediaBitrate ) == 0 ) |
|
1704 { |
|
1705 TInt bitrate = 0; |
|
1706 if ( valuePtr.Compare( KIptvEmptyDes ) != 0 ) |
|
1707 { |
|
1708 TLex l( valuePtr ); |
|
1709 l.Val( bitrate ); |
|
1710 } |
|
1711 |
|
1712 if ( 0 < bitrate ) |
|
1713 { |
|
1714 content->iBitrate = bitrate; |
|
1715 } |
|
1716 } |
|
1717 // framerate |
|
1718 else if ( namePtr.CompareF( KIptvRssMediaFramerate ) == 0 ) |
|
1719 { |
|
1720 TInt framerate = 0; |
|
1721 if ( valuePtr.Compare( KIptvEmptyDes ) != 0 ) |
|
1722 { |
|
1723 TLex l( valuePtr ); |
|
1724 l.Val( framerate ); |
|
1725 } |
|
1726 |
|
1727 if ( 0 < framerate ) |
|
1728 { |
|
1729 content->iFramerate = framerate; |
|
1730 } |
|
1731 } |
|
1732 // samplingrate |
|
1733 else if ( namePtr.CompareF( KIptvRssMediaSamplingrate ) == 0 ) |
|
1734 { |
|
1735 TInt samplingrate = 0; |
|
1736 if ( valuePtr.Compare( KIptvEmptyDes ) != 0 ) |
|
1737 { |
|
1738 TLex l( valuePtr ); |
|
1739 l.Val( samplingrate ); |
|
1740 } |
|
1741 |
|
1742 if ( 0 < samplingrate ) |
|
1743 { |
|
1744 content->iSamplingrate = samplingrate; |
|
1745 } |
|
1746 } |
|
1747 // duration |
|
1748 else if ( namePtr.CompareF( KIptvRssMediaDuration ) == 0 ) |
|
1749 { |
|
1750 TInt duration = 0; |
|
1751 if ( valuePtr.Compare( KIptvEmptyDes ) != 0 ) |
|
1752 { |
|
1753 TLex l( valuePtr ); |
|
1754 l.Val( duration ); |
|
1755 } |
|
1756 |
|
1757 if ( 0 < duration ) |
|
1758 { |
|
1759 content->iDuration = duration; |
|
1760 } |
|
1761 } |
|
1762 // height |
|
1763 else if ( namePtr.CompareF( KIptvRssMediaHeight ) == 0 ) |
|
1764 { |
|
1765 TInt height = 0; |
|
1766 if ( valuePtr.Compare( KIptvEmptyDes ) != 0 ) |
|
1767 { |
|
1768 TLex l( valuePtr ); |
|
1769 l.Val( height ); |
|
1770 } |
|
1771 |
|
1772 if ( 0 < height ) |
|
1773 { |
|
1774 content->iHeight = height; |
|
1775 } |
|
1776 } |
|
1777 // width |
|
1778 else if ( namePtr.CompareF( KIptvRssMediaWidth ) == 0 ) |
|
1779 { |
|
1780 TInt width = 0; |
|
1781 if ( valuePtr.Compare( KIptvEmptyDes ) != 0 ) |
|
1782 { |
|
1783 TLex l( valuePtr ); |
|
1784 l.Val( width ); |
|
1785 } |
|
1786 |
|
1787 if ( 0 < width ) |
|
1788 { |
|
1789 content->iWidth = width; |
|
1790 } |
|
1791 } |
|
1792 // language |
|
1793 else if ( namePtr.CompareF( KIptvRssMediaLanguage ) == 0 ) |
|
1794 { |
|
1795 dataToCopy = Min( valueLength, KIptvCALanguageLength ); |
|
1796 content->iLanguage.Copy( valuePtr.Mid( 0, dataToCopy ) ); |
|
1797 } |
|
1798 } |
|
1799 } |
|
1800 else if ( EIptvRssItemRatingState == iState ) |
|
1801 { |
|
1802 if ( 0 == namePtr.CompareF( KIptvRssMediaRatingScheme ) ) |
|
1803 { |
|
1804 if ( 0 == valuePtr.CompareF( KIptvRssMediaRatingSchemeSimple ) ) |
|
1805 { |
|
1806 iMediaRatingScheme = EMediaRatingSimple; |
|
1807 } |
|
1808 else if ( 0 == valuePtr.CompareF( KIptvRssMediaRatingSchemeNum ) ) |
|
1809 { |
|
1810 iMediaRatingScheme = EMediaRatingNum; |
|
1811 } |
|
1812 else |
|
1813 { |
|
1814 iMediaRatingScheme = EMediaRatingSimple; |
|
1815 } |
|
1816 } |
|
1817 } |
|
1818 else if ( EIptvRssItemMediaCategoryState == iState ) |
|
1819 { |
|
1820 if ( 0 == namePtr.CompareF( KIptvRssMediaLabel ) ) |
|
1821 { |
|
1822 iState = EIptvRssItemMediaCategoryEnclosureState; |
|
1823 IPTVLOGSTRING_LOW_LEVEL( |
|
1824 "RSS Plugin::State changed from EIptvRssItemMediaCategoryState to EIptvRssItemMediaCategoryEnclosureState" ); |
|
1825 CompleteCategoryL( value ); |
|
1826 } |
|
1827 } |
|
1828 |
|
1829 // Value and Name. |
|
1830 CleanupStack::PopAndDestroy( KIptvPopValueAndName, name ); |
|
1831 value = NULL; |
|
1832 name = NULL; |
|
1833 } |
|
1834 |
|
1835 if ( content ) |
|
1836 { |
|
1837 // Check that URL is not empty |
|
1838 if ( content->GetMediaContentUrl().Length() > 0 ) |
|
1839 { |
|
1840 SetDownloadTypeFromMimeType( *content ); |
|
1841 content->PrintL(); |
|
1842 iMediaContents.AppendL( content ); |
|
1843 CleanupStack::Pop( content ); |
|
1844 } |
|
1845 else |
|
1846 { |
|
1847 CleanupStack::PopAndDestroy( content ); |
|
1848 content = NULL; |
|
1849 } |
|
1850 } |
|
1851 } |
|
1852 |
|
1853 // -------------------------------------------------------------------------- |
|
1854 // Create a new category descriptor. |
|
1855 // -------------------------------------------------------------------------- |
|
1856 // |
|
1857 CIptvEpgCategory* CIptvXmlContentHandler::CreateCategoryL() const |
|
1858 { |
|
1859 IPTVLOGSTRING_LOW_LEVEL( |
|
1860 "RSS Plugin::CIptvXmlContentHandler::CreateCategoryL" ); |
|
1861 |
|
1862 CIptvEpgCategory* category( NULL ); |
|
1863 |
|
1864 category = CIptvEpgCategory::NewL(); |
|
1865 |
|
1866 // Key is auto-increment |
|
1867 |
|
1868 // Parent key |
|
1869 category->iParentKey = KIptvVodContentCategoryRootId; |
|
1870 |
|
1871 // Id |
|
1872 category->iId = KIptvEmptyDes; |
|
1873 |
|
1874 // Name |
|
1875 category->iName = KIptvEmptyDes; |
|
1876 |
|
1877 // Icon file Id |
|
1878 category->iIconFileId = 0; // Obsolete field |
|
1879 |
|
1880 // Is icon file path URL |
|
1881 category->iIsIconFilePathUrl = ETrue; // Obsolete field |
|
1882 |
|
1883 // Icon file path |
|
1884 category->iIconFilePath = KIptvEmptyDes; // Obsolete field |
|
1885 |
|
1886 // Description |
|
1887 category->iDescription = KIptvEmptyDes; |
|
1888 |
|
1889 // Item count |
|
1890 category->iContentCount = 0; |
|
1891 |
|
1892 return category; |
|
1893 } |
|
1894 |
|
1895 // -------------------------------------------------------------------------- |
|
1896 // Set a category for current item. |
|
1897 // When category has been used for some other item it already exists and |
|
1898 // is restored, Otherwise a new one is created and a key value given. |
|
1899 // -------------------------------------------------------------------------- |
|
1900 // |
|
1901 void CIptvXmlContentHandler::SetItemCategoryL( const HBufC* aName ) |
|
1902 { |
|
1903 IPTVLOGSTRING_LOW_LEVEL( |
|
1904 "RSS Plugin::CIptvXmlContentHandler::SetItemCategoryL" ); |
|
1905 |
|
1906 // When no name defined, retain default category. |
|
1907 if ( aName ) |
|
1908 { |
|
1909 if ( 0 < aName->Length() ) |
|
1910 { |
|
1911 TUint32 categoryKey( 0 ); |
|
1912 TInt categoryCount = iCategoryTable.Count(); |
|
1913 |
|
1914 // Name of the Category candidate. |
|
1915 HBufC* name = HBufC::NewLC( KIptvEpgCategoryNameMaxLength ); |
|
1916 TPtr16 namePtr = name->Des(); |
|
1917 TInt dataToCopy = |
|
1918 Min( aName->Length(), KIptvEpgCategoryNameMaxLength ); |
|
1919 namePtr.Copy( aName->Mid( 0, dataToCopy ) ); |
|
1920 |
|
1921 // Search category whether already exist. |
|
1922 for ( TInt i = 0; ( i < categoryCount ) && ( 0 == categoryKey ); i++ ) |
|
1923 { |
|
1924 if ( 0 == iCategoryTable[i]->iName.CompareF( namePtr ) ) |
|
1925 { |
|
1926 categoryKey = i + 1; |
|
1927 } |
|
1928 } |
|
1929 |
|
1930 if ( 0 != categoryKey ) |
|
1931 { |
|
1932 // Whether category alreaady exists, add its key for content. |
|
1933 // Avoid double linking. |
|
1934 if ( 0 != iCurrentCategoryKeys.Find( categoryKey ) ) |
|
1935 { |
|
1936 iCurrentCategoryKeys.AppendL( categoryKey ); |
|
1937 } |
|
1938 } |
|
1939 else if ( iCategoryCount < KIptvEpgMaxCategoryCount ) |
|
1940 { |
|
1941 // Whether category not yet exists, add a new one. |
|
1942 CIptvEpgCategory* newCategory = CreateCategoryL(); |
|
1943 CleanupStack::PushL( newCategory ); |
|
1944 |
|
1945 // Use defaults from channel category. |
|
1946 if ( newCategory ) |
|
1947 { |
|
1948 newCategory->iName.Copy( namePtr ); |
|
1949 if ( iChannelCategory ) |
|
1950 { |
|
1951 newCategory->iDescription.Copy( |
|
1952 iChannelCategory->iDescription ); |
|
1953 } |
|
1954 |
|
1955 iCategoryTable.AppendL( newCategory ); |
|
1956 iCurrentCategoryKeys.AppendL( iCategoryTable.Count() ); |
|
1957 } |
|
1958 |
|
1959 CleanupStack::Pop( newCategory ); |
|
1960 } |
|
1961 else |
|
1962 { |
|
1963 // New category can not be set, retain selection before. |
|
1964 IPTVLOGSTRING_LOW_LEVEL( |
|
1965 "RSS Plugin::CIptvXmlContentHandler::SetItemCategoryL -- Category limit reached! Category not added!" ); |
|
1966 } |
|
1967 |
|
1968 CleanupStack::PopAndDestroy( name ); |
|
1969 name = NULL; |
|
1970 } |
|
1971 } |
|
1972 } |
|
1973 |
|
1974 // -------------------------------------------------------------------------- |
|
1975 // Set channel as default category for current Item. |
|
1976 // When channel category has already been used, restore it, |
|
1977 // Otherwise save it and give a key value. |
|
1978 // -------------------------------------------------------------------------- |
|
1979 // |
|
1980 void CIptvXmlContentHandler::SetChannelCategoryL() |
|
1981 { |
|
1982 IPTVLOGSTRING_LOW_LEVEL( |
|
1983 "RSS Plugin::CIptvXmlContentHandler::SetChannelCategoryL" ); |
|
1984 |
|
1985 if ( iChannelCategory ) |
|
1986 { |
|
1987 // Check whether channel category has not yet already been used. |
|
1988 if ( ( 0 == iChannelCategoryKey ) && |
|
1989 ( iCategoryCount < KIptvEpgMaxCategoryCount ) ) |
|
1990 { |
|
1991 iCategoryTable.AppendL( iChannelCategory ); |
|
1992 iChannelCategoryKey = iCategoryTable.Count(); |
|
1993 } |
|
1994 |
|
1995 // Add key for current item content. |
|
1996 if ( 0 != iChannelCategoryKey ) |
|
1997 { |
|
1998 iCurrentCategoryKeys.AppendL( iChannelCategoryKey ); |
|
1999 } |
|
2000 else |
|
2001 { |
|
2002 // Channel category can not be set, retain selection before. |
|
2003 IPTVLOGSTRING_LOW_LEVEL( |
|
2004 "RSS Plugin::CIptvXmlContentHandler::SetChannelCategoryL -- Category limit reached! Category not added!" ); |
|
2005 } |
|
2006 } |
|
2007 } |
|
2008 |
|
2009 // -------------------------------------------------------------------------- |
|
2010 // Stores all categories used by current itam to database. |
|
2011 // -------------------------------------------------------------------------- |
|
2012 // |
|
2013 void CIptvXmlContentHandler::AddCategories() |
|
2014 { |
|
2015 IPTVLOGSTRING_LOW_LEVEL( |
|
2016 "RSS Plugin::CIptvXmlContentHandler::AddCategories" ); |
|
2017 |
|
2018 TInt categoryCount( iCategoryTable.Count() ); |
|
2019 |
|
2020 for ( TInt i = 0; i < categoryCount; i++ ) |
|
2021 { |
|
2022 TUint32 newKey( 0 ); |
|
2023 |
|
2024 #ifdef _DEBUG |
|
2025 TBuf<KIptvEpgCategoryNameMaxLength + 1> name; |
|
2026 name.Zero(); |
|
2027 name.Copy( iCategoryTable[i]->iName ); |
|
2028 |
|
2029 IPTVLOGSTRING3_LOW_LEVEL( |
|
2030 "RSS Plugin::AddCategories Category '%S' added with %d items", |
|
2031 &name, |
|
2032 iCategoryTable[i]->iContentCount ); |
|
2033 #endif |
|
2034 |
|
2035 TRAPD( |
|
2036 error, |
|
2037 iVodCallback->AddCategoryL( *( iCategoryTable[i] ), newKey ) ); |
|
2038 //lint -e{961} Else block not needed, only error handling here. |
|
2039 if ( KErrNone != error ) |
|
2040 { |
|
2041 IPTVLOGSTRING2_LOW_LEVEL( "RSS Plugin::AddCategories Error = %d", |
|
2042 error ); |
|
2043 } |
|
2044 else if ( newKey != ( i + 1 ) ) |
|
2045 { |
|
2046 IPTVLOGSTRING3_LOW_LEVEL( |
|
2047 "RSS Plugin::AddCategories Unexpected key %d, %d expected", |
|
2048 newKey, i + 1 ); |
|
2049 } |
|
2050 } |
|
2051 |
|
2052 // Categories saved to database, descriptors no more needed. |
|
2053 iCategoryTable.ResetAndDestroy(); |
|
2054 if ( iChannelCategory && ( 0 == iChannelCategoryKey ) ) |
|
2055 { |
|
2056 // Current channel category is not included to iCategoryTable and |
|
2057 // so has not been deleted above. |
|
2058 delete iChannelCategory; |
|
2059 } |
|
2060 iChannelCategory = NULL; |
|
2061 iChannelCategoryKey = 0; |
|
2062 iCurrentCategoryKeys.Reset(); |
|
2063 } |
|
2064 |
|
2065 // -------------------------------------------------------------------------- |
|
2066 // Add current content to dabase and link it to categories. |
|
2067 // -------------------------------------------------------------------------- |
|
2068 // |
|
2069 void CIptvXmlContentHandler::AddContentL() |
|
2070 { |
|
2071 #ifdef _DEBUG |
|
2072 |
|
2073 TBuf<KIptvEpgContentNameMaxLength + 1> name; |
|
2074 name.Zero(); |
|
2075 if ( iContent ) |
|
2076 { |
|
2077 name.Copy( iContent->iName ); |
|
2078 } |
|
2079 |
|
2080 IPTVLOGSTRING2_LOW_LEVEL( |
|
2081 "RSS Plugin::CIptvXmlContentHandler::AddContentL: '%S'", |
|
2082 &name ); |
|
2083 #endif |
|
2084 |
|
2085 TBool addThis( iContent && ( iMediaContentSet.Count() > 0 ) && |
|
2086 iContent->iBrowserUrl.Length() < KIptvUrlMaxLength ); |
|
2087 TInt itemCategories( iCurrentCategoryKeys.Count() ); |
|
2088 |
|
2089 // Check category limits. |
|
2090 if ( addThis ) |
|
2091 { |
|
2092 addThis = EFalse; |
|
2093 if ( iContentCount < KIptvEpgMaxContentCount ) |
|
2094 { |
|
2095 // Check whether this item fits to any selected category |
|
2096 for ( TInt key = 0; |
|
2097 ( key < itemCategories ) && ( EFalse == addThis ); |
|
2098 key++ ) |
|
2099 { |
|
2100 TUint32 categoryKey = iCurrentCategoryKeys[key]; |
|
2101 |
|
2102 if ( 0 < categoryKey ) |
|
2103 { |
|
2104 if ( iCategoryTable[categoryKey - 1]->iContentCount < |
|
2105 KIptvEpgMaxContentCountInCategory ) |
|
2106 { |
|
2107 addThis = ETrue; |
|
2108 } |
|
2109 } |
|
2110 } |
|
2111 |
|
2112 if ( !addThis ) |
|
2113 { |
|
2114 IPTVLOGSTRING_LOW_LEVEL( |
|
2115 "RSS Plugin::AddContentL Content not added! Category limits reached!" ); |
|
2116 } |
|
2117 } |
|
2118 else |
|
2119 { |
|
2120 IPTVLOGSTRING_LOW_LEVEL( |
|
2121 "RSS Plugin::AddContentL Content not added! Limit reached!" ); |
|
2122 IPTVLOGSTRING3_LOW_LEVEL( |
|
2123 "RSS Plugin::AddContentL Total content count: %d/%d", |
|
2124 iContentCount, |
|
2125 KIptvEpgMaxContentCount ); |
|
2126 } |
|
2127 } |
|
2128 else |
|
2129 { |
|
2130 IPTVLOGSTRING_LOW_LEVEL( |
|
2131 "RSS Plugin::AddContentL Content not added! Required info missing!" ); |
|
2132 } |
|
2133 |
|
2134 TUint32 newContentKey( 0 ); |
|
2135 |
|
2136 if ( addThis ) |
|
2137 { |
|
2138 // Save content's thumbnail path |
|
2139 TBuf<KIptvCAContentUrlLength> thumbnailUrl; |
|
2140 thumbnailUrl.Copy( iContent->iIconFilePath ); |
|
2141 |
|
2142 // Set thumbnail path to zero, we dont want 2k URL's to database |
|
2143 iContent->iIconFilePath.Zero(); |
|
2144 |
|
2145 // Add order to content data. |
|
2146 // This is the item detection order and is not continuous |
|
2147 // inside one category. Anyway order is increasing inside each |
|
2148 // category and can so be used to sort items of category. |
|
2149 iContent->iOrder = iContentCount; |
|
2150 |
|
2151 // Get size, duration and language from media content's |
|
2152 // full version to "parent" content class |
|
2153 // This becomes redundant information |
|
2154 TInt count = iMediaContentSet.Count(); |
|
2155 for ( TInt i = 0; i < count; i++ ) |
|
2156 { |
|
2157 if ( iMediaContentSet[i]->iExpression == |
|
2158 CIptvMediaContent::EFull ) |
|
2159 { |
|
2160 iContent->iSize = iMediaContentSet[i]->iFileSize; |
|
2161 iContent->iDuration = iMediaContentSet[i]->iDuration; |
|
2162 iContent->iLanguage.Copy( |
|
2163 iMediaContentSet[i]->iLanguage ); |
|
2164 i = count; |
|
2165 } |
|
2166 } |
|
2167 |
|
2168 TInt error = iVodCallback->AddContentL( |
|
2169 *iContent, iMediaContentSet, newContentKey ); |
|
2170 if ( error == KErrNone ) |
|
2171 { |
|
2172 iContentCount++; |
|
2173 AddContentToDlQueueL( newContentKey, thumbnailUrl ); |
|
2174 |
|
2175 IPTVLOGSTRING3_LOW_LEVEL( |
|
2176 "RSS Plugin::AddContentL Content added, total content count: %d/%d", |
|
2177 iContentCount, |
|
2178 KIptvEpgMaxContentCount ); |
|
2179 } |
|
2180 else |
|
2181 { |
|
2182 addThis = EFalse; |
|
2183 IPTVLOGSTRING2_LOW_LEVEL( |
|
2184 "RSS Plugin::AddContentL error = %d", error ); |
|
2185 } |
|
2186 } |
|
2187 |
|
2188 if ( addThis ) |
|
2189 { |
|
2190 // Add relation to selected categories. |
|
2191 for ( TInt key = 0; key < itemCategories; key++ ) |
|
2192 { |
|
2193 TUint32 categoryKey = iCurrentCategoryKeys[key]; |
|
2194 |
|
2195 if ( 0 < categoryKey ) |
|
2196 { |
|
2197 if ( iCategoryTable[categoryKey - 1]->iContentCount < |
|
2198 KIptvEpgMaxContentCountInCategory ) |
|
2199 { |
|
2200 iVodCallback->AddRelationL( categoryKey, newContentKey ); |
|
2201 iCategoryTable[categoryKey - 1]->iContentCount++; |
|
2202 |
|
2203 IPTVLOGSTRING3_LOW_LEVEL( |
|
2204 "RSS Plugin::AddContentL Content count in category: %d/%d", |
|
2205 iCategoryTable[categoryKey - 1]->iContentCount, |
|
2206 KIptvEpgMaxContentCountInCategory ); |
|
2207 } |
|
2208 } |
|
2209 } |
|
2210 } |
|
2211 else |
|
2212 { |
|
2213 // After non added item, cleanup for empty categories. |
|
2214 // Because empty categories are checked after each rejected item, |
|
2215 // they can be assumed to be the last ones. |
|
2216 TInt categoryCount( iCategoryTable.Count() ); |
|
2217 |
|
2218 while ( 0 < categoryCount ) |
|
2219 { |
|
2220 categoryCount--; |
|
2221 if ( 0 == iCategoryTable[categoryCount]->iContentCount ) |
|
2222 { |
|
2223 if ( iCategoryTable[categoryCount] != iChannelCategory ) |
|
2224 { |
|
2225 #ifdef _DEBUG |
|
2226 name.Zero(); |
|
2227 name.Copy( iCategoryTable[categoryCount]->iName ); |
|
2228 |
|
2229 IPTVLOGSTRING2_LOW_LEVEL( |
|
2230 "RSS Plugin::AddContentL Empty category '%S' removed ", |
|
2231 &name ); |
|
2232 #endif |
|
2233 delete iCategoryTable[categoryCount]; |
|
2234 iCategoryTable[categoryCount] = NULL; |
|
2235 } |
|
2236 else |
|
2237 { |
|
2238 IPTVLOGSTRING_LOW_LEVEL( |
|
2239 "RSS Plugin::AddContentL Channel category unlinked" ); |
|
2240 iChannelCategoryKey = 0; |
|
2241 iCategoryTable[categoryCount] = NULL; |
|
2242 } |
|
2243 |
|
2244 iCategoryTable.Remove( categoryCount ); |
|
2245 } |
|
2246 else |
|
2247 { |
|
2248 categoryCount = 0; |
|
2249 } |
|
2250 } |
|
2251 } |
|
2252 |
|
2253 iMediaContents.ResetAndDestroy(); |
|
2254 iMediaContentSet.Reset(); |
|
2255 iCurrentCategoryKeys.Reset(); |
|
2256 |
|
2257 delete iContent; |
|
2258 iContent = NULL; |
|
2259 } |
|
2260 |
|
2261 // -------------------------------------------------------------------------- |
|
2262 // Create a new itme content descriptor. |
|
2263 // -------------------------------------------------------------------------- |
|
2264 // |
|
2265 void CIptvXmlContentHandler::CreateContentL() |
|
2266 { |
|
2267 IPTVLOGSTRING_LOW_LEVEL( |
|
2268 "RSS Plugin::CIptvXmlContentHandler::CreateContentL" ); |
|
2269 |
|
2270 delete iContent; |
|
2271 iContent = NULL; |
|
2272 iContent = CIptvEpgContent::NewL(); |
|
2273 |
|
2274 // Key is auto-increment |
|
2275 |
|
2276 // Id |
|
2277 iContent->iId = KIptvEmptyDes; |
|
2278 |
|
2279 // Name |
|
2280 iContent->iName = KIptvEmptyDes; |
|
2281 |
|
2282 // Content protection |
|
2283 iContent->iContentProtection = 0; |
|
2284 |
|
2285 // Icon file Id |
|
2286 iContent->iIconFileId = 0; |
|
2287 |
|
2288 // Is icon filepath URL |
|
2289 iContent->iIsIconFilePathUrl = ETrue; |
|
2290 |
|
2291 // Icon file path |
|
2292 iContent->iIconFilePath = KIptvEmptyDes; |
|
2293 |
|
2294 // Content file Id |
|
2295 iContent->iContentFileId = 0; |
|
2296 |
|
2297 // Content description |
|
2298 iContent->iDescription = KIptvEmptyDes; |
|
2299 |
|
2300 // Author |
|
2301 iContent->iAuthor = KIptvEmptyDes; |
|
2302 |
|
2303 // Copyright |
|
2304 iContent->iCopyright = KIptvEmptyDes; |
|
2305 |
|
2306 // Size |
|
2307 iContent->iSize = 0; |
|
2308 |
|
2309 // Duration |
|
2310 iContent->iDuration = 0; |
|
2311 |
|
2312 // Language |
|
2313 iContent->iLanguage = KIptvEmptyDes; |
|
2314 |
|
2315 // rating age by default unlimited. |
|
2316 iContent->iRatingAge = KRatingAgeUnlimited; |
|
2317 } |
|
2318 |
|
2319 // -------------------------------------------------------------------------- |
|
2320 // Adjust download type according to Mime type. |
|
2321 // -------------------------------------------------------------------------- |
|
2322 // |
|
2323 void CIptvXmlContentHandler::SetDownloadTypeFromMimeType( |
|
2324 CIptvMediaContent& aContent ) const |
|
2325 { |
|
2326 IPTVLOGSTRING_LOW_LEVEL( |
|
2327 "RSS Plugin::CIptvXmlContentHandler::SetDownloadTypeFromMimeType" ); |
|
2328 |
|
2329 // For some MIME types we force the download type. |
|
2330 // |
|
2331 if ( aContent.iMimeType.CompareF( KIptvMimeApplicationSdp ) == 0 ) |
|
2332 { |
|
2333 aContent.iDownloadType = EIptvDownloadTypeStream; |
|
2334 } |
|
2335 } |
|
2336 |
|
2337 // -------------------------------------------------------------------------- |
|
2338 // Item containing thumbnails is added to download queue. |
|
2339 // -------------------------------------------------------------------------- |
|
2340 // |
|
2341 void CIptvXmlContentHandler::AddContentToDlQueueL( |
|
2342 TUint32 contentKey, |
|
2343 const TDesC& aThumbnailUrl ) |
|
2344 { |
|
2345 IPTVLOGSTRING_LOW_LEVEL( |
|
2346 "RSS Plugin::CIptvXmlContentHandler::AddContentToDlQueueL" ); |
|
2347 |
|
2348 // If thumbnail path -> add to download queue |
|
2349 if ( ( aThumbnailUrl.Length() > 0 ) && |
|
2350 ( aThumbnailUrl.Length() <= KIptvUrlMaxLength ) && |
|
2351 ( aThumbnailUrl.Left( KIptvProtocolNameLength ).CompareF( |
|
2352 KIptvRssHttp ) == 0 ) ) |
|
2353 { |
|
2354 CIptvDownloadItem* item = CIptvDownloadItem::NewL(); |
|
2355 CleanupStack::PushL( item ); |
|
2356 item->iThumbnailUrl.Copy( aThumbnailUrl ); |
|
2357 item->iServiceThumbnail = EFalse; |
|
2358 item->iId = contentKey; |
|
2359 iPlugin.AddToDlQueueL( item ); |
|
2360 CleanupStack::Pop( item ); |
|
2361 } |
|
2362 } |
|
2363 |
|
2364 // -------------------------------------------------------------------------- |
|
2365 // Service image thumbnails url is added to download queue. |
|
2366 // -------------------------------------------------------------------------- |
|
2367 // |
|
2368 void CIptvXmlContentHandler::AddServiceToDlQueueL( |
|
2369 const TDesC& aThumbnailUrl ) |
|
2370 { |
|
2371 IPTVLOGSTRING_LOW_LEVEL( |
|
2372 "RSS Plugin::CIptvXmlContentHandler::AddServiceToDlQueueL" ); |
|
2373 |
|
2374 // Only first valid occurence is stored as service image. |
|
2375 if ( !iServiceThumbnailAdded ) |
|
2376 { |
|
2377 TInt urlLength = aThumbnailUrl.Length(); |
|
2378 |
|
2379 // Url can not be truncated, if too long wait a new one. |
|
2380 // If thumbnail path -> add to download queue |
|
2381 if ( ( 0 < urlLength ) && |
|
2382 ( KIptvEpgCategoryIconFilePathMaxLength >= urlLength ) && |
|
2383 ( aThumbnailUrl.Left( KIptvProtocolNameLength ).CompareF( |
|
2384 KIptvRssHttp ) == 0 ) ) |
|
2385 { |
|
2386 CIptvDownloadItem* item = CIptvDownloadItem::NewL(); |
|
2387 CleanupStack::PushL( item ); |
|
2388 item->iThumbnailUrl.Copy( aThumbnailUrl ); |
|
2389 item->iServiceThumbnail = ETrue; |
|
2390 item->iId = iChannelCategoryKey; |
|
2391 iPlugin.AddToDlQueueL( item ); |
|
2392 CleanupStack::Pop( item ); |
|
2393 |
|
2394 iServiceThumbnailAdded = ETrue; |
|
2395 IPTVLOGSTRING_LOW_LEVEL( |
|
2396 "RSS Plugin::CIptvXmlContentHandler::AddServiceToDlQueueL Service thumbnail added" ); |
|
2397 } |
|
2398 } |
|
2399 } |
|
2400 |
|
2401 // -------------------------------------------------------------------------- |
|
2402 // CIptvXmlContentHandler::PriorizeL |
|
2403 // -------------------------------------------------------------------------- |
|
2404 // |
|
2405 void CIptvXmlContentHandler::PriorizeL() |
|
2406 { |
|
2407 IPTVLOGSTRING_LOW_LEVEL( |
|
2408 "RSS Plugin::CIptvXmlContentHandler::PriorizeL" ); |
|
2409 |
|
2410 TInt count = iMediaContents.Count(); |
|
2411 if ( count > 0 ) |
|
2412 { |
|
2413 RPointerArray<CIptvMediaContent> previewStreams; |
|
2414 RPointerArray<CIptvMediaContent> previewDownloads; |
|
2415 RPointerArray<CIptvMediaContent> streams; |
|
2416 RPointerArray<CIptvMediaContent> downloads; |
|
2417 |
|
2418 for ( TInt i = 0; i < count; i++ ) |
|
2419 { |
|
2420 // Preview stream |
|
2421 //lint -e{961} Else block not needed, default is no operation. |
|
2422 if ( ( iMediaContents[i]->iExpression == CIptvMediaContent::ESample ) && |
|
2423 ( iMediaContents[i]->iDownloadType == EIptvDownloadTypeStream ) ) |
|
2424 { |
|
2425 previewStreams.AppendL( iMediaContents[i] ); |
|
2426 } |
|
2427 // Preview download |
|
2428 else if ( ( iMediaContents[i]->iExpression == CIptvMediaContent::ESample ) && |
|
2429 ( iMediaContents[i]->iDownloadType == EIptvDownloadTypeImmediate ) ) |
|
2430 { |
|
2431 previewDownloads.AppendL( iMediaContents[i] ); |
|
2432 } |
|
2433 // Stream ( full or nonstop ) |
|
2434 else if ( ( iMediaContents[i]->iExpression != CIptvMediaContent::ESample ) && |
|
2435 ( iMediaContents[i]->iDownloadType == EIptvDownloadTypeStream ) ) |
|
2436 { |
|
2437 streams.AppendL( iMediaContents[i] ); |
|
2438 } |
|
2439 // Download |
|
2440 else if ( ( iMediaContents[i]->iExpression == CIptvMediaContent::EFull ) && |
|
2441 ( iMediaContents[i]->iDownloadType == EIptvDownloadTypeImmediate ) ) |
|
2442 { |
|
2443 downloads.AppendL( iMediaContents[i] ); |
|
2444 } |
|
2445 } |
|
2446 |
|
2447 if ( iTerminalVideoSupport ) |
|
2448 { |
|
2449 TInt index = 0; |
|
2450 if ( previewStreams.Count() > 0 ) |
|
2451 { |
|
2452 index = iTerminalVideoSupport->SelectMimeTypeL( previewStreams ); |
|
2453 if ( index != KErrNotFound ) |
|
2454 { |
|
2455 IPTVLOGSTRING_LOW_LEVEL( |
|
2456 "RSS Plugin::CIptvXmlContentHandler::PriorizeL Best preview stream is:" ); |
|
2457 previewStreams[index]->PrintL(); |
|
2458 |
|
2459 // Add best items of preview streams, preview downloads, |
|
2460 // streams and downloads to array |
|
2461 iMediaContentSet.AppendL( previewStreams[index] ); |
|
2462 } |
|
2463 } |
|
2464 if ( previewDownloads.Count() > 0 ) |
|
2465 { |
|
2466 index = iTerminalVideoSupport->SelectMimeTypeL( previewDownloads ); |
|
2467 if ( index != KErrNotFound ) |
|
2468 { |
|
2469 IPTVLOGSTRING_LOW_LEVEL( |
|
2470 "RSS Plugin::CIptvXmlContentHandler::PriorizeL Best preview download is:" ); |
|
2471 previewDownloads[index]->PrintL(); |
|
2472 |
|
2473 iMediaContentSet.AppendL( previewDownloads[index] ); |
|
2474 } |
|
2475 } |
|
2476 if ( streams.Count() > 0 ) |
|
2477 { |
|
2478 index = iTerminalVideoSupport->SelectMimeTypeL( streams ); |
|
2479 if ( index != KErrNotFound ) |
|
2480 { |
|
2481 IPTVLOGSTRING_LOW_LEVEL( |
|
2482 "RSS Plugin::CIptvXmlContentHandler::PriorizeL Best stream is:" ); |
|
2483 streams[index]->PrintL(); |
|
2484 |
|
2485 iMediaContentSet.AppendL( streams[index] ); |
|
2486 } |
|
2487 } |
|
2488 if ( downloads.Count() > 0 ) |
|
2489 { |
|
2490 index = iTerminalVideoSupport->SelectMimeTypeL( downloads ); |
|
2491 if ( index != KErrNotFound ) |
|
2492 { |
|
2493 IPTVLOGSTRING_LOW_LEVEL( |
|
2494 "RSS Plugin::CIptvXmlContentHandler::PriorizeL Best download is:" ); |
|
2495 downloads[index]->PrintL(); |
|
2496 |
|
2497 iMediaContentSet.AppendL( downloads[ index ] ); |
|
2498 } |
|
2499 } |
|
2500 } |
|
2501 |
|
2502 previewStreams.Close(); |
|
2503 previewDownloads.Close(); |
|
2504 streams.Close(); |
|
2505 downloads.Close(); |
|
2506 } |
|
2507 } |
|
2508 |
|
2509 // -------------------------------------------------------------------------- |
|
2510 // Advances category state according to given event and decides whether |
|
2511 // current object should be processed. |
|
2512 // -------------------------------------------------------------------------- |
|
2513 // |
|
2514 TBool CIptvXmlContentHandler::SetCategoryState( TCategoryStateEvent aEvent ) |
|
2515 { |
|
2516 IPTVLOGSTRING3_LOW_LEVEL( |
|
2517 "RSS Plugin::CIptvXmlContentHandler::SetCategoryState State:%d, Event:%d", |
|
2518 iCategoryState, aEvent ); |
|
2519 |
|
2520 TBool processThis( ETrue ); // By default we process this object |
|
2521 |
|
2522 /** |
|
2523 * Search category attribute inside an item. |
|
2524 */ |
|
2525 //lint -e{961} Else block not needed, default is no change. |
|
2526 if ( ECategoryFound == aEvent ) |
|
2527 { |
|
2528 iCategoryFound = ETrue; |
|
2529 } |
|
2530 else if ( EItemFound == aEvent ) |
|
2531 { |
|
2532 iCategoryFound = EFalse; |
|
2533 } |
|
2534 |
|
2535 /** |
|
2536 * State transitions according to event. |
|
2537 */ |
|
2538 switch ( iCategoryState ) |
|
2539 { |
|
2540 /** |
|
2541 * Not even the first channel found yet. |
|
2542 */ |
|
2543 case ENoChannel: |
|
2544 { |
|
2545 if ( EChannelFound == aEvent ) |
|
2546 { |
|
2547 iCategoryState = EChannelNoItem; |
|
2548 } |
|
2549 } |
|
2550 break; |
|
2551 |
|
2552 /** |
|
2553 * No items found from first channel yet. |
|
2554 */ |
|
2555 case EChannelNoItem: |
|
2556 { |
|
2557 //lint -e{961} Else block not needed, default is no state change. |
|
2558 if ( EItemCompleted == aEvent ) |
|
2559 { |
|
2560 if ( iCategoryFound ) |
|
2561 { |
|
2562 iCategoryState = EItemsWithCategory; |
|
2563 iCategoryFound = EFalse; |
|
2564 } |
|
2565 else |
|
2566 { |
|
2567 iCategoryState = EItemsNoCategory; |
|
2568 } |
|
2569 } |
|
2570 else if ( EChannelCompleted == aEvent ) |
|
2571 { |
|
2572 processThis = EFalse; // Ignore empty channel. |
|
2573 iCategoryState = ENoChannel; |
|
2574 } |
|
2575 } |
|
2576 break; |
|
2577 |
|
2578 /** |
|
2579 * Only items with category definition found yet fron first channel. |
|
2580 */ |
|
2581 case EItemsWithCategory: |
|
2582 { |
|
2583 //lint -e{961} Else block not needed, default is no state change. |
|
2584 if ( EItemCompleted == aEvent ) |
|
2585 { |
|
2586 if ( iCategoryFound ) |
|
2587 { |
|
2588 iCategoryFound = EFalse; |
|
2589 } |
|
2590 else |
|
2591 { |
|
2592 iCategoryState = EItemsBoth; |
|
2593 } |
|
2594 } |
|
2595 else if ( EChannelCompleted == aEvent ) |
|
2596 { |
|
2597 iCategoryState = ESkipFurtherChannels; |
|
2598 processThis = EFalse; // Ignore channel name as category. |
|
2599 } |
|
2600 } |
|
2601 break; |
|
2602 |
|
2603 /** |
|
2604 * Only items without category definition found yet fron first channel. |
|
2605 */ |
|
2606 case EItemsNoCategory: |
|
2607 { |
|
2608 //lint -e{961} Else block not needed, default is no state change. |
|
2609 if ( EItemCompleted == aEvent ) |
|
2610 { |
|
2611 if ( iCategoryFound ) |
|
2612 { |
|
2613 iCategoryState = EItemsBoth; |
|
2614 iCategoryFound = EFalse; |
|
2615 } |
|
2616 } |
|
2617 else if ( EChannelCompleted == aEvent ) |
|
2618 { |
|
2619 iCategoryState = ESkipFurtherCategories; |
|
2620 } |
|
2621 } |
|
2622 break; |
|
2623 |
|
2624 /** |
|
2625 * First channel contains items both with and without categories. |
|
2626 */ |
|
2627 case EItemsBoth: |
|
2628 { |
|
2629 if ( EChannelCompleted == aEvent ) |
|
2630 { |
|
2631 iCategoryState = ESkipFurtherChannels; |
|
2632 } |
|
2633 } |
|
2634 break; |
|
2635 |
|
2636 /** |
|
2637 * We have processed a channel with category definitions, so we are |
|
2638 * satisfied and ignore further channels. |
|
2639 */ |
|
2640 case ESkipFurtherChannels: |
|
2641 { |
|
2642 if ( EChannelFound == aEvent ) |
|
2643 { |
|
2644 IPTVLOGSTRING_LOW_LEVEL( |
|
2645 "RSS Plugin::CIptvXmlContentHandler::SetCategoryState ESkipFurtherChannels" ); |
|
2646 processThis = EFalse; |
|
2647 } |
|
2648 } |
|
2649 break; |
|
2650 |
|
2651 /** |
|
2652 * We have processed a channel without any category definitions, |
|
2653 * so we use channels as categories and ignore further category |
|
2654 * definitions. |
|
2655 */ |
|
2656 case ESkipFurtherCategories: |
|
2657 { |
|
2658 if ( ECategoryFound == aEvent ) |
|
2659 { |
|
2660 IPTVLOGSTRING_LOW_LEVEL( |
|
2661 "RSS Plugin::CIptvXmlContentHandler::SetCategoryState SkipFurtherCategories" ); |
|
2662 processThis = EFalse; |
|
2663 } |
|
2664 } |
|
2665 break; |
|
2666 |
|
2667 default: |
|
2668 { |
|
2669 IPTVLOGSTRING_LOW_LEVEL( |
|
2670 "RSS Plugin::CIptvXmlContentHandler::SetCategoryState Unknown state" ); |
|
2671 } |
|
2672 } |
|
2673 |
|
2674 IPTVLOGSTRING3_LOW_LEVEL( |
|
2675 "RSS Plugin::CIptvXmlContentHandler::SetCategoryState New State:%d, Process:%d", |
|
2676 iCategoryState, processThis ); |
|
2677 |
|
2678 return processThis; |
|
2679 } |