|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <f32file.h> |
|
20 #include <parser.h> |
|
21 #include <utf.h> |
|
22 |
|
23 #include "iradvertisement.h" |
|
24 #include "irbrowsecatagoryitems.h" |
|
25 #include "irbrowsechannelitems.h" |
|
26 #include "ircachemgmt.h" |
|
27 #include "irdebug.h" |
|
28 #include "irisdspreset.h" |
|
29 #include "irparserobserver.h" |
|
30 #include "irotaupdate.h" |
|
31 #include "irxmlcontenthandler.h" |
|
32 #include "irxmlelements.h" |
|
33 |
|
34 const TInt KLargeArraySize = 256; |
|
35 const TUint8 KAttributeBufferSize = 100; |
|
36 const TUint8 KBitRateCounterValue0 = 0; |
|
37 const TUint8 KBitRateCounterValue1 = 1; |
|
38 const TUint8 KBitRateCounterValue2 = 2; |
|
39 const TUint8 KCategoriesItemSelect = 0; |
|
40 const TUint8 KChannelItemSelect = 1; |
|
41 const TUint8 KPresetItemSelect = 2; |
|
42 const TUint8 KOTAUpdateItemSelect = 3; |
|
43 const TUint8 KIRIDSelect = 4; |
|
44 const TUint8 KTen = 10; |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // Gets the Filepath of the XML file |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 EXPORT_C void CIRXMLContentHandler::ParseXmlL(const TDesC& aFilePath, |
|
51 const TDesC& aCachePath, |
|
52 const CIRHttpResponseData& aResponseHeaders) |
|
53 { |
|
54 IRLOG_DEBUG( "CIRXMLContentHandler::ParseXmlL" ); |
|
55 iFileToCache.Zero(); |
|
56 iFileToCache.Copy(aCachePath); |
|
57 |
|
58 RFs fs; |
|
59 CleanupClosePushL(fs); |
|
60 User::LeaveIfError(fs.Connect()); |
|
61 Xml::ParseL(*iParser,fs,aFilePath); |
|
62 CleanupStack::PopAndDestroy(&fs); |
|
63 |
|
64 |
|
65 //! Error in the Document |
|
66 if(iEOD != KErrNone ) |
|
67 { |
|
68 ResetValues(); |
|
69 iParseObserver.ParseError( iEOD ); |
|
70 } |
|
71 else |
|
72 { |
|
73 if(iCategories) |
|
74 { |
|
75 TRAP_IGNORE(iCache->CacheCategoryItemsL(*iPtrCategory, |
|
76 iFileToCache ,aResponseHeaders)) |
|
77 ResetValues(); |
|
78 iParseObserver.ParsedStructureL(KCategoriesItemSelect); |
|
79 } |
|
80 |
|
81 if(iChan) |
|
82 { |
|
83 if(iFileToCache.Length()!=0) |
|
84 { |
|
85 TRAP_IGNORE(iCache->CacheChannelItemsL(*iPtrChannel, |
|
86 iFileToCache ,aResponseHeaders)) |
|
87 } |
|
88 ResetValues(); |
|
89 iParseObserver.ParsedStructureL(KChannelItemSelect); |
|
90 } |
|
91 |
|
92 if(iPresets) |
|
93 { |
|
94 if( 0 < iPtrPreset->Count() ) |
|
95 { |
|
96 TRAP_IGNORE(iCache->CachePresetItemL(*iPtrPreset, |
|
97 iFileToCache,aResponseHeaders)) |
|
98 ResetValues(); |
|
99 iParseObserver.ParsedStructureL(KPresetItemSelect); |
|
100 } |
|
101 } |
|
102 if(iOTAUpdate) |
|
103 { |
|
104 TRAP_IGNORE(iCache->CacheOtaInfoL(*iOTA, |
|
105 iFileToCache,aResponseHeaders)) |
|
106 ResetValues(); |
|
107 iParseObserver.ParsedStructureL(KOTAUpdateItemSelect); |
|
108 } |
|
109 if(iIRID) |
|
110 { |
|
111 ResetValues(); |
|
112 iParseObserver.ParsedStructureL(KIRIDSelect); |
|
113 } |
|
114 if( iTimeStamp ) |
|
115 { |
|
116 //session log response is obtained |
|
117 ResetValues(); |
|
118 iParseObserver.ParsedStructureL(KSessionLogResponse); |
|
119 } |
|
120 } |
|
121 IRLOG_DEBUG( "CIRXMLContentHandler::ParseXmlL - Exiting." ); |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CIRXMLContentHandler ::NewL |
|
126 // Constructor |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 EXPORT_C CIRXMLContentHandler* CIRXMLContentHandler ::NewL(MIRParserObserver |
|
130 &aObserver,MIRCacheObserver &aCacheObserver) |
|
131 { |
|
132 IRLOG_DEBUG( "CIRXMLContentHandler::NewL" ); |
|
133 CIRXMLContentHandler* self = new (ELeave) CIRXMLContentHandler(aObserver, |
|
134 aCacheObserver); |
|
135 CleanupStack::PushL(self); |
|
136 self->ConstructL(); |
|
137 CleanupStack::Pop(self); |
|
138 IRLOG_DEBUG( "CIRXMLContentHandler::NewL - Exiting." ); |
|
139 return(self); |
|
140 } |
|
141 // --------------------------------------------------------------------------- |
|
142 // CIRXMLContentHandler ::CIRXMLContentHandler |
|
143 // Default Constructor |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 CIRXMLContentHandler ::CIRXMLContentHandler(MIRParserObserver &aObserver, |
|
147 MIRCacheObserver &aCacheObserver):iParseObserver(aObserver), |
|
148 iCacheObserver(aCacheObserver) |
|
149 { |
|
150 IRLOG_DEBUG( "CIRXMLContentHandler::CIRXMLContentHandler" ); |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CIRXMLContentHandler ::ConstructL |
|
155 // Two-Phase Constructor |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 void CIRXMLContentHandler ::ConstructL() |
|
159 { |
|
160 IRLOG_DEBUG( "CIRXMLContentHandler::ConstructL" ); |
|
161 ResetValues(); |
|
162 TIRXMLElementFormat::OpenStringPoolL(iStringPool); |
|
163 |
|
164 iPtrCategory = new (ELeave) CArrayPtrFlat<CIRBrowseCatagoryItems>( |
|
165 KLargeArraySize); |
|
166 iPtrChannel = new (ELeave) CArrayPtrFlat<CIRBrowseChannelItems>( |
|
167 KLargeArraySize); |
|
168 iPtrPreset = new (ELeave) CArrayPtrFlat<CIRIsdsPreset>(KLargeArraySize); |
|
169 |
|
170 iParser = CParser::NewL(KFile,*this); |
|
171 iCache = CIRCacheMgmt::OpenL(iCacheObserver); |
|
172 |
|
173 iBufGetOperation = HBufC::NewL(0); |
|
174 iSize = HBufC::NewL(0); |
|
175 IRLOG_DEBUG( "CIRXMLContentHandler::ConstructL - Exiting." ); |
|
176 } |
|
177 // --------------------------------------------------------------------------- |
|
178 // CIRXMLContentHandler::~CIRXMLContentHandler() |
|
179 // Destructing the object |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 CIRXMLContentHandler::~CIRXMLContentHandler() |
|
183 { |
|
184 IRLOG_DEBUG( "CIRXMLContentHandler::~CIRXMLContentHandler." ); |
|
185 TRAP_IGNORE(TIRXMLElementFormat::CloseStringPoolL(iStringPool)) |
|
186 delete iParser; |
|
187 if(iUrlContentForAds) |
|
188 { |
|
189 delete iUrlContentForAds; |
|
190 iUrlContentForAds = NULL; |
|
191 } |
|
192 if(iPtrPreset) |
|
193 { |
|
194 iPtrPreset->ResetAndDestroy(); |
|
195 } |
|
196 delete iPtrPreset; |
|
197 if(iPtrCategory) |
|
198 { |
|
199 iPtrCategory->ResetAndDestroy(); |
|
200 } |
|
201 delete iPtrCategory; |
|
202 if(iPtrChannel) |
|
203 { |
|
204 iPtrChannel->ResetAndDestroy(); |
|
205 } |
|
206 delete iPtrChannel; |
|
207 |
|
208 delete iOTA; |
|
209 delete iAdv; |
|
210 |
|
211 if (iCache) |
|
212 { |
|
213 iCache->Close(); |
|
214 } |
|
215 |
|
216 delete iPreset; |
|
217 delete iCategory; |
|
218 delete iChannel; |
|
219 delete iBufGetOperation; |
|
220 delete iSize; |
|
221 |
|
222 IRLOG_DEBUG( "CIRXMLContentHandler::~CIRXMLContentHandler - Exiting." ); |
|
223 } |
|
224 // --------------------------------------------------------------------------- |
|
225 // CIRXMLContentHandler::ResetValues |
|
226 // Reseting the Values |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 |
|
230 void CIRXMLContentHandler::ResetValues() |
|
231 { |
|
232 IRLOG_DEBUG( "CIRXMLContentHandler::ResetValues" ); |
|
233 iFlag = 1; |
|
234 iPresets = EFalse; |
|
235 iCategories=EFalse; |
|
236 iCat=EFalse; |
|
237 iChannels=EFalse; |
|
238 iChan=EFalse; |
|
239 iAdvertisement=EFalse; |
|
240 iOTAUpdate=EFalse; |
|
241 iIRID = EFalse; |
|
242 iTimeStamp = EFalse; |
|
243 iChannel = NULL; |
|
244 iCategory = NULL; |
|
245 iAdvts = EFalse; |
|
246 iAdvertisementTagFlag = EFalse; |
|
247 IRLOG_DEBUG( "CIRXMLContentHandler::ResetValues - Exiting." ); |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------------------------- |
|
251 // CIRXMLContentHandler:: OnStartDocumentL |
|
252 // This method is a callback to indicate the start of the document |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 void CIRXMLContentHandler:: OnStartDocumentL(const Xml::RDocumentParameters& |
|
256 /*aDocParam*/ , TInt /*aErrorCode*/ ) |
|
257 { |
|
258 IRLOG_DEBUG( "CIRXMLContentHandler::OnStartDocumentL" ); |
|
259 iEOD = KErrNone; |
|
260 } |
|
261 |
|
262 // --------------------------------------------------------------------------- |
|
263 // CIRXMLContentHandler::OnEndDocumentL |
|
264 // This method is a callback to indicate the end of the document |
|
265 // --------------------------------------------------------------------------- |
|
266 // |
|
267 void CIRXMLContentHandler::OnEndDocumentL(TInt /*aErrorCode*/) |
|
268 { |
|
269 //No Implementation |
|
270 IRLOG_DEBUG( "CIRXMLContentHandler::OnEndDocumentL" ); |
|
271 return; |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // CIRXMLContentHandler::OnStartElementL |
|
276 // This method is a callback to indicate an element has been parsed. |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 void CIRXMLContentHandler::OnStartElementL(const Xml::RTagInfo &aElement, |
|
280 const Xml::RAttributeArray &aAttributes, TInt /*aErrorCode*/) |
|
281 { |
|
282 IRLOG_DEBUG( "CIRXMLContentHandler::OnStartElementL" ); |
|
283 //Compare the element name to identify the type - //TO DO String Pool |
|
284 TInt genre = (aElement.LocalName().DesC()).Compare(KGenre); |
|
285 TInt lang = (aElement.LocalName().DesC()).Compare(KLanguage); |
|
286 TInt country = (aElement.LocalName().DesC()).Compare(KCountry); |
|
287 TInt channel = (aElement.LocalName().DesC()).Compare(KChannel); |
|
288 TInt preset = (aElement.LocalName().DesC()).Compare(KPreset); |
|
289 TInt advertisements = (aElement.LocalName().DesC()).Compare(KAdvertisements); |
|
290 TInt ad = (aElement.LocalName().DesC()).Compare(KAd); |
|
291 |
|
292 TInt genres = (aElement.LocalName().DesC()).Compare(KCatGenre); |
|
293 TInt countries = (aElement.LocalName().DesC()).Compare(KCatCountry); |
|
294 TInt languages = (aElement.LocalName().DesC()).Compare(KCatLang); |
|
295 TInt channels = (aElement.LocalName().DesC()).Compare(KChannels); |
|
296 TInt presets = (aElement.LocalName().DesC()).Compare(KPresets); |
|
297 |
|
298 TInt IRID = (aElement.LocalName().DesC()).Compare(KIRID); |
|
299 TInt timestamp = (aElement.LocalName().DesC()).Compare(KTimeStamp); |
|
300 TInt irappversion = (aElement.LocalName().DesC()).Compare(KIRVersion); |
|
301 TInt adv = (aElement.LocalName().DesC()).Compare(KAdv); |
|
302 TInt banner = (aElement.LocalName().DesC()).Compare(KBanner); |
|
303 |
|
304 |
|
305 if(iUrlContentForAds) |
|
306 { |
|
307 delete(iUrlContentForAds); |
|
308 iUrlContentForAds = NULL; |
|
309 } |
|
310 |
|
311 TInt bufSize(KTen); |
|
312 iUrlContentForAds = HBufC::NewL( bufSize );//this is because, the OnContentL method gives chunck by chunck |
|
313 |
|
314 if(ad == 0) |
|
315 { |
|
316 //We want to take the first Ad only so if an Ad has already been created |
|
317 //iChannel and iCategory will not be NULL hence the new Ad should not be added |
|
318 if( !iChannel && !iCategory ) |
|
319 { |
|
320 iChannel = CIRBrowseChannelItems::NewL(); |
|
321 iCategory = CIRBrowseCatagoryItems::NewL(); |
|
322 |
|
323 } |
|
324 } |
|
325 if(advertisements == 0 ) |
|
326 { |
|
327 iAdvertisementTagFlag = ETrue; |
|
328 } |
|
329 if(iAdvertisementTagFlag && banner == 0) |
|
330 { |
|
331 iAdvts = ETrue; |
|
332 } |
|
333 // Creates the instance of the class Browse by Genre/Language/Country |
|
334 if(iFlag) |
|
335 { |
|
336 if(genre == 0 || lang == 0 || country == 0) |
|
337 { |
|
338 //If there are ads then destroy the list and put the ads |
|
339 //as ads will the first in the xml |
|
340 if((iAdvts) && (iCategory)) |
|
341 { |
|
342 iPtrCategory->ResetAndDestroy(); |
|
343 iPtrCategory->AppendL(iCategory); |
|
344 iCategory = NULL; |
|
345 delete iChannel; |
|
346 iChannel = NULL; |
|
347 iAdvts = EFalse; |
|
348 } |
|
349 iCategory = CIRBrowseCatagoryItems::NewL(); |
|
350 iCat = ETrue; |
|
351 } |
|
352 } |
|
353 if(iFlag) |
|
354 { |
|
355 // In case of browse by genres, country and lanaguages |
|
356 if(genres == 0 || countries == 0 || languages == 0) |
|
357 { |
|
358 if(iAdvts == EFalse) |
|
359 { |
|
360 iPtrCategory->ResetAndDestroy(); |
|
361 } |
|
362 if(genres == 0) |
|
363 { |
|
364 iFileToCache.Zero(); |
|
365 iFileToCache.Copy(KCatGenre); |
|
366 } |
|
367 if(countries == 0) |
|
368 { |
|
369 iFileToCache.Zero(); |
|
370 iFileToCache.Copy(KCatCountry); |
|
371 } |
|
372 if(languages == 0) |
|
373 { |
|
374 iFileToCache.Zero(); |
|
375 iFileToCache.Copy(KCatLang); |
|
376 } |
|
377 |
|
378 iCategories = ETrue; |
|
379 } |
|
380 } |
|
381 // Creates the instance of the class Channel |
|
382 if(channel == 0) |
|
383 { |
|
384 //If there are ads then destroy the list and put the ads |
|
385 //as ads will the first in the xml |
|
386 if((iAdvts) && (iChannel)) |
|
387 { iPtrChannel->AppendL(iChannel); |
|
388 iChannel = NULL; |
|
389 delete iCategory; |
|
390 iCategory = NULL; |
|
391 iAdvts = EFalse; |
|
392 } |
|
393 iChannel = CIRBrowseChannelItems::NewL(); |
|
394 iChannels = ETrue; |
|
395 iBitrateCounter = 0; |
|
396 } |
|
397 if(channels == 0 ) |
|
398 { |
|
399 iPtrChannel->ResetAndDestroy(); |
|
400 iChan = ETrue; |
|
401 iChannelFlag = 0; |
|
402 } |
|
403 // Creates the instance of the class for Preset Data |
|
404 if(preset == 0) |
|
405 { |
|
406 iPreset = CIRIsdsPreset::NewL(); |
|
407 iPresets = ETrue; |
|
408 } |
|
409 if(presets == 0) |
|
410 { |
|
411 iPtrPreset->ResetAndDestroy(); |
|
412 iFlag = 0; |
|
413 } |
|
414 if(IRID == 0) |
|
415 { |
|
416 iIRID = ETrue; |
|
417 } |
|
418 if(timestamp == 0) |
|
419 { |
|
420 //time stamp is obtained when session log is obtained in isds |
|
421 iTimeStamp = ETrue; |
|
422 } |
|
423 if(irappversion == 0) |
|
424 { |
|
425 iOTA = CIROTAUpdate::NewL(); |
|
426 iOTAUpdate = ETrue; |
|
427 } |
|
428 if(adv == 0) |
|
429 { |
|
430 iAdv = CIRAdvertisement::NewL(); |
|
431 iAdvertisement = ETrue; |
|
432 } |
|
433 TBuf<KAttributeBufferSize> BufParam1; |
|
434 TBuf<KAttributeBufferSize> BufParam2; |
|
435 |
|
436 // Parses the attributes and the value of the element |
|
437 TInt nAttributes = aAttributes.Count(); |
|
438 for (TInt indexofattribute = 0; indexofattribute < nAttributes; |
|
439 ++indexofattribute ) |
|
440 { |
|
441 const RAttribute& attribute = aAttributes[indexofattribute]; |
|
442 const RTagInfo& nameInfo = attribute.Attribute(); |
|
443 |
|
444 //!Gets the elementId from the Pool for the specified attributename |
|
445 TIRXMLElement ATTelementId = TIRXMLElementFormat::GetElementIdL( |
|
446 (nameInfo.LocalName().DesC()),iStringPool); |
|
447 |
|
448 HBufC* converted = CnvUtfConverter::ConvertToUnicodeFromUtf8L( attribute.Value().DesC() ); |
|
449 CleanupStack::PushL(converted); |
|
450 |
|
451 switch(ATTelementId) |
|
452 { |
|
453 case EGetOperation: |
|
454 { |
|
455 delete iBufGetOperation; |
|
456 iBufGetOperation = NULL; |
|
457 iBufGetOperation = converted->Des().AllocL(); |
|
458 } |
|
459 break; |
|
460 |
|
461 case EName: |
|
462 { |
|
463 //if name is parsed |
|
464 if(iCat) |
|
465 { |
|
466 //if category |
|
467 iCategory->SetGetOperation(*iBufGetOperation); |
|
468 BufParam1.Copy(*converted); |
|
469 } |
|
470 if(iChannels) |
|
471 { |
|
472 //if channel |
|
473 iChannel->SetGetOperationL(*iBufGetOperation); |
|
474 iChannel->SetSize(*iSize); |
|
475 BufParam1.Copy(*converted); |
|
476 } |
|
477 if(iPresets) |
|
478 { |
|
479 if((aElement.LocalName().DesC()) == KPreset) |
|
480 { |
|
481 //for preset |
|
482 iPreset->SetName(*converted); |
|
483 } |
|
484 BufParam1.Copy(*converted); |
|
485 } |
|
486 } |
|
487 break; |
|
488 |
|
489 case EID: |
|
490 { |
|
491 //getting id |
|
492 if(iCat) |
|
493 { |
|
494 //for category |
|
495 iCategory->SetTextL(BufParam1,*converted); |
|
496 } |
|
497 |
|
498 if(iChannels) |
|
499 { |
|
500 //for channel |
|
501 BufParam2.Copy(*converted); |
|
502 } |
|
503 if(iPresets) |
|
504 { |
|
505 //for preset |
|
506 iPreset->SetGenreInfo(*converted,BufParam1); |
|
507 } |
|
508 if(iIRID) |
|
509 { |
|
510 //ir id |
|
511 iRID.Copy(*converted); |
|
512 } |
|
513 } |
|
514 break; |
|
515 |
|
516 case ESize: |
|
517 { |
|
518 delete iSize; |
|
519 iSize = NULL; |
|
520 iSize = converted->Des().AllocL(); |
|
521 if(iCat) |
|
522 { |
|
523 iCategory->SetSize(*iSize); |
|
524 } |
|
525 } |
|
526 break; |
|
527 |
|
528 case EShortDesC: |
|
529 { |
|
530 //getting short description |
|
531 if(iChannels) |
|
532 { |
|
533 iChannel->SetTextL(BufParam1,BufParam2,*converted); |
|
534 } |
|
535 if(iPresets) |
|
536 { |
|
537 iPreset->SetShortDesc(*converted); |
|
538 } |
|
539 } |
|
540 break; |
|
541 |
|
542 case EBitrateValue: |
|
543 { |
|
544 //parsing bit rate |
|
545 if(iChannels) |
|
546 { |
|
547 if(iBitrateCounter == KBitRateCounterValue0) |
|
548 { |
|
549 iChannel->SetBitrate(*converted); |
|
550 BufParam1.Copy(*converted); |
|
551 } |
|
552 |
|
553 if(iBitrateCounter == KBitRateCounterValue1) |
|
554 { |
|
555 iChannel->SetBitrate(BufParam1,*converted); |
|
556 BufParam2.Copy(*converted); |
|
557 } |
|
558 |
|
559 if(iBitrateCounter == KBitRateCounterValue2) |
|
560 { |
|
561 iChannel->SetBitrate(BufParam1,BufParam2,*converted); |
|
562 } |
|
563 |
|
564 iBitrateCounter++; |
|
565 } |
|
566 } |
|
567 break; |
|
568 |
|
569 case ESdsID: |
|
570 { |
|
571 if(iPresets) |
|
572 { |
|
573 iPreset->SetId(*converted); |
|
574 } |
|
575 } |
|
576 break; |
|
577 |
|
578 case ELangCode: |
|
579 { |
|
580 //language code |
|
581 if(iPresets) |
|
582 { |
|
583 iPreset->SetLangCode(*converted); |
|
584 } |
|
585 } |
|
586 break; |
|
587 |
|
588 case ELang: |
|
589 { |
|
590 //language |
|
591 if(iPresets) |
|
592 { |
|
593 iPreset->SetLang(*converted); |
|
594 } |
|
595 } |
|
596 break; |
|
597 |
|
598 case ECountryCode: |
|
599 { |
|
600 //country code |
|
601 if(iPresets) |
|
602 { |
|
603 iPreset->SetCountryCode(*converted); |
|
604 } |
|
605 } |
|
606 break; |
|
607 |
|
608 case ECountry: |
|
609 { |
|
610 //country |
|
611 if(iPresets) |
|
612 { |
|
613 iPreset->SetCountryName(*converted); |
|
614 } |
|
615 } |
|
616 break; |
|
617 |
|
618 case ELastUpdated: |
|
619 { |
|
620 //last modified time |
|
621 if(iPresets) |
|
622 { |
|
623 iPreset->SetLastModifiedTime(*converted); |
|
624 } |
|
625 } |
|
626 break; |
|
627 |
|
628 case EDesc: |
|
629 { |
|
630 //description |
|
631 if(iPresets) |
|
632 { |
|
633 iPreset->SetDescription(*converted); |
|
634 } |
|
635 } |
|
636 break; |
|
637 |
|
638 case EImgURL: |
|
639 { |
|
640 //image url |
|
641 if(iChannels) |
|
642 { |
|
643 iChannel->SetImageUrl(*converted); |
|
644 } |
|
645 if(iPresets) |
|
646 { |
|
647 iPreset->SetImgUrl(*converted); |
|
648 } |
|
649 } |
|
650 break; |
|
651 |
|
652 case EAdvImgURL: |
|
653 { |
|
654 //advertisement url |
|
655 if(iPresets) |
|
656 { |
|
657 iPreset->SetAdvertisementUrl(*converted); |
|
658 } |
|
659 } |
|
660 break; |
|
661 |
|
662 case EAdvInUse: |
|
663 { |
|
664 //advertisement in use |
|
665 if(iPresets) |
|
666 { |
|
667 iPreset->SetAdvertisementInUse(*converted); |
|
668 } |
|
669 } |
|
670 break; |
|
671 |
|
672 case EGenreID: |
|
673 { |
|
674 //genre id |
|
675 if(iPresets) |
|
676 { |
|
677 iPreset->SetGenreInfo(BufParam1,*converted); |
|
678 } |
|
679 } |
|
680 break; |
|
681 |
|
682 case EURL: |
|
683 { |
|
684 //url |
|
685 if(iPresets) |
|
686 { |
|
687 BufParam2.Copy(*converted); |
|
688 } |
|
689 if(iAdvertisement) |
|
690 { |
|
691 iAdv->SetURL(*converted); |
|
692 } |
|
693 } |
|
694 break; |
|
695 |
|
696 case EMusicStoreEnabled: |
|
697 { |
|
698 if(iPresets) |
|
699 { |
|
700 iPreset->SetMusicStoreStatus(*converted); |
|
701 } |
|
702 } |
|
703 break; |
|
704 |
|
705 case EBitrate: |
|
706 { |
|
707 //set url |
|
708 if(iPresets) |
|
709 { |
|
710 iPreset->SetUrlL(BufParam1,BufParam2,*converted); |
|
711 } |
|
712 } |
|
713 break; |
|
714 |
|
715 case EIRID: |
|
716 { |
|
717 //irid |
|
718 } |
|
719 break; |
|
720 |
|
721 case EVersion: |
|
722 { |
|
723 //for ota update |
|
724 if(iOTAUpdate) |
|
725 { |
|
726 iOTA->SetVersion(*converted); |
|
727 } |
|
728 } |
|
729 break; |
|
730 |
|
731 case EUpdateInterval: |
|
732 { |
|
733 //update interval |
|
734 if(iOTAUpdate) |
|
735 { |
|
736 iOTA->SetUpdateInterval(*converted); |
|
737 } |
|
738 } |
|
739 break; |
|
740 |
|
741 case EUpdateMethod: |
|
742 { |
|
743 //update method |
|
744 if(iOTAUpdate) |
|
745 { |
|
746 iOTA->SetUpdateMethod(*converted); |
|
747 } |
|
748 } |
|
749 break; |
|
750 |
|
751 case EInUse: |
|
752 { |
|
753 //advertisement in use |
|
754 if(iAdvertisement) |
|
755 { |
|
756 iAdv->SetAdvInUse(*converted); |
|
757 } |
|
758 } |
|
759 break; |
|
760 |
|
761 case EUsageVisibleTimes: |
|
762 { |
|
763 if(iAdvertisement) |
|
764 { |
|
765 iAdv->SetUsage(*converted); |
|
766 } |
|
767 } |
|
768 break; |
|
769 |
|
770 case EVisibleTime: |
|
771 { |
|
772 //advertisement visible time |
|
773 if(iAdvertisement) |
|
774 { |
|
775 iAdv->SetVisibleTime(*converted); |
|
776 } |
|
777 } |
|
778 break; |
|
779 |
|
780 case EElementIDUnknown: |
|
781 { |
|
782 //unknown |
|
783 } |
|
784 break; |
|
785 |
|
786 default: |
|
787 { |
|
788 break; |
|
789 } |
|
790 }//End of Switch |
|
791 CleanupStack::PopAndDestroy(converted); |
|
792 } //End of for |
|
793 IRLOG_DEBUG( "CIRXMLContentHandler::OnStartElementL - Exiting." ); |
|
794 } |
|
795 |
|
796 // --------------------------------------------------------------------------- |
|
797 // CIRXMLContentHandler::OnEndElementL |
|
798 // This method is a callback to indicate the end of the element has been reached. |
|
799 // --------------------------------------------------------------------------- |
|
800 // |
|
801 void CIRXMLContentHandler::OnEndElementL(const RTagInfo &aElement, TInt /*aErrorCode*/) |
|
802 { |
|
803 IRLOG_DEBUG( "CIRXMLContentHandler::OnEndElementL" ); |
|
804 if((aElement.LocalName().DesC()) == KPreset) |
|
805 { |
|
806 if ( iPreset->GetUrlCount() > 0 ) |
|
807 { |
|
808 // The ownership is transferred to the array. |
|
809 iPtrPreset->AppendL(iPreset); |
|
810 } |
|
811 else |
|
812 { |
|
813 // If there is not a single URL, we don't let it in. |
|
814 iEOD = KErrCorrupt; |
|
815 delete iPreset; |
|
816 } |
|
817 // Ownership transferred. Remove the pointer. |
|
818 iPreset = NULL; |
|
819 } |
|
820 if((aElement.LocalName().DesC()) == KBanner) |
|
821 { |
|
822 //get the content for the tag "banner" |
|
823 //assign it to "iBanner" of CIRBrowseChannelItems |
|
824 if(iUrlContentForAds) |
|
825 { |
|
826 iChannel->SetBannerUrl(*iUrlContentForAds); |
|
827 iCategory->SetBannerUrl(*iUrlContentForAds); |
|
828 } |
|
829 } |
|
830 if((aElement.LocalName().DesC()) == KClickthroughUrl) |
|
831 { |
|
832 //get the content for the tag "clickthrough-url" |
|
833 //assign it to "iClickThroughUrl" of CIRBrowseChannelItems |
|
834 if(iUrlContentForAds) |
|
835 { |
|
836 iChannel->SetClickThroughUrl(*iUrlContentForAds); |
|
837 iCategory->SetClickThroughUrl(*iUrlContentForAds); |
|
838 } |
|
839 } |
|
840 |
|
841 if(iUrlContentForAds) |
|
842 { |
|
843 delete iUrlContentForAds; |
|
844 iUrlContentForAds = NULL; |
|
845 |
|
846 } |
|
847 if(iFlag) |
|
848 { |
|
849 if((aElement.LocalName().DesC()) == KGenre || |
|
850 (aElement.LocalName().DesC()) == KLanguage || |
|
851 (aElement.LocalName().DesC()) == KCountry) |
|
852 { |
|
853 iPtrCategory->AppendL(iCategory); |
|
854 iCategory = NULL; |
|
855 iCat = EFalse; |
|
856 } |
|
857 } |
|
858 |
|
859 if((aElement.LocalName().DesC()) == KChannel) |
|
860 { |
|
861 iPtrChannel->AppendL(iChannel); |
|
862 iChannel = NULL; |
|
863 iChannels = EFalse; |
|
864 } |
|
865 //appends the created channel(ad) to the array |
|
866 /* |
|
867 if((aElement.LocalName().DesC()) == KAd) |
|
868 { |
|
869 iPtrChannel->AppendL(iChannel); |
|
870 iChannel = NULL; |
|
871 |
|
872 } */ |
|
873 |
|
874 if((aElement.LocalName().DesC()) == KServers) |
|
875 { |
|
876 if (iPreset) |
|
877 { |
|
878 iPreset->SetUrlCount(); |
|
879 } |
|
880 } |
|
881 IRLOG_DEBUG( "CIRXMLContentHandler::OnEndElementL - Exiting." ); |
|
882 } |
|
883 |
|
884 // --------------------------------------------------------------------------- |
|
885 // CIRXMLContentHandler ::OnContentL |
|
886 // This method is a callback that sends the content of the element.The data |
|
887 // may be sent in chunks |
|
888 // --------------------------------------------------------------------------- |
|
889 // |
|
890 void CIRXMLContentHandler ::OnContentL(const TDesC8 &aBytes, TInt |
|
891 aErrorCode) |
|
892 { |
|
893 IRLOG_DEBUG( "CIRXMLContentHandler::OnContentL" ); |
|
894 |
|
895 if ( KErrNone == aErrorCode ) |
|
896 { |
|
897 |
|
898 |
|
899 HBufC* buffertmp = HBufC::NewLC( aBytes.Length() + 1 ); |
|
900 TPtr buffertmpPtr( buffertmp->Des() ); |
|
901 buffertmpPtr.Copy( aBytes ); |
|
902 |
|
903 |
|
904 TInt tempSize; |
|
905 if(iUrlContentForAds) |
|
906 { |
|
907 tempSize = iUrlContentForAds->Length() + aBytes.Length(); |
|
908 iUrlContentForAds = iUrlContentForAds->ReAllocL( tempSize ); |
|
909 TPtr bufferPtr( iUrlContentForAds->Des() ); |
|
910 bufferPtr.Append(buffertmpPtr); |
|
911 } |
|
912 |
|
913 CleanupStack::PopAndDestroy(buffertmp); // buffertmp |
|
914 } |
|
915 |
|
916 if ( iOTAUpdate ) |
|
917 { |
|
918 HBufC* converted = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aBytes ); |
|
919 CleanupStack::PushL( converted ); |
|
920 converted->Des().TrimAll(); |
|
921 if ( converted->Des().Length() ) |
|
922 { |
|
923 iOTA->SetOTAUrl( *converted ); |
|
924 } |
|
925 CleanupStack::PopAndDestroy( converted ); |
|
926 } |
|
927 |
|
928 IRLOG_DEBUG( "CIRXMLContentHandler::OnContentL - Exiting." ); |
|
929 } |
|
930 |
|
931 |
|
932 // --------------------------------------------------------------------------- |
|
933 // CIRXMLContentHandler::OnStartPrefixMappingL |
|
934 // This method is a notification of the beginning of the scope of a |
|
935 // prefix-URI Namespace mapping. |
|
936 // --------------------------------------------------------------------------- |
|
937 // |
|
938 void CIRXMLContentHandler::OnStartPrefixMappingL(const RString& /*aPrefix*/, |
|
939 const RString& /*aUri*/, TInt /*aErrorCode*/) |
|
940 { |
|
941 //No Implementaion |
|
942 IRLOG_DEBUG( "CIRXMLContentHandler::OnStartPrefixMappingL" ); |
|
943 } |
|
944 |
|
945 // --------------------------------------------------------------------------- |
|
946 // CIRXMLContentHandler :: OnEndPrefixMappingL |
|
947 // This method is a notification of the end of the scope of a prefix-URI mapping |
|
948 // --------------------------------------------------------------------------- |
|
949 // |
|
950 void CIRXMLContentHandler :: OnEndPrefixMappingL(const RString& /*aPrefix*/, |
|
951 TInt /*aErrorCode*/) |
|
952 { |
|
953 //No Implementaion |
|
954 IRLOG_DEBUG( "CIRXMLContentHandler::OnEndPrefixMappingL" ); |
|
955 } |
|
956 |
|
957 // --------------------------------------------------------------------------- |
|
958 // CIRXMLContentHandler :: OnIgnorableWhiteSpaceL |
|
959 // This method is a notification of ignorable whitespace in element content. |
|
960 // --------------------------------------------------------------------------- |
|
961 // |
|
962 void CIRXMLContentHandler :: OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, |
|
963 TInt /*aErrorCode*/) |
|
964 { |
|
965 //No Implementaion |
|
966 IRLOG_DEBUG( "CIRXMLContentHandler::OnIgnorableWhiteSpaceL" ); |
|
967 } |
|
968 |
|
969 // --------------------------------------------------------------------------- |
|
970 // CIRXMLContentHandler :: OnSkippedEntityL |
|
971 // This method is a notification of a skipped entity |
|
972 // --------------------------------------------------------------------------- |
|
973 // |
|
974 void CIRXMLContentHandler :: OnSkippedEntityL(const RString& /*aName*/, |
|
975 TInt /*aErrorCode*/) |
|
976 { |
|
977 //No Implementaion |
|
978 IRLOG_DEBUG( "CIRXMLContentHandler::OnSkippedEntityL" ); |
|
979 } |
|
980 |
|
981 // --------------------------------------------------------------------------- |
|
982 // CIRXMLContentHandler :: OnProcessingInstructionL |
|
983 // This method is a receive notification of a processing instruction. |
|
984 // --------------------------------------------------------------------------- |
|
985 // |
|
986 void CIRXMLContentHandler :: OnProcessingInstructionL(const TDesC8& |
|
987 /*aTarget*/, const TDesC8& /*aData*/, TInt /*aErrorCode*/) |
|
988 { |
|
989 //No Implementaion |
|
990 IRLOG_DEBUG( "CIRXMLContentHandler::OnProcessingInstructionL" ); |
|
991 } |
|
992 |
|
993 // --------------------------------------------------------------------------- |
|
994 // CIRXMLContentHandler :: OnError |
|
995 // This method indicates an error has occurred. |
|
996 // --------------------------------------------------------------------------- |
|
997 // |
|
998 void CIRXMLContentHandler :: OnError(TInt aErrorCode ) |
|
999 { |
|
1000 iEOD = aErrorCode; |
|
1001 IRLOG_ERROR2( "CIRXMLContentHandler::OnError (%d)", aErrorCode ); |
|
1002 } |
|
1003 |
|
1004 |
|
1005 // --------------------------------------------------------------------------- |
|
1006 // CIRXMLContentHandler :: GetExtendedInterface |
|
1007 // This method obtains the interface matching the specified uid. |
|
1008 // --------------------------------------------------------------------------- |
|
1009 // |
|
1010 TAny* CIRXMLContentHandler :: GetExtendedInterface(const TInt32 /*aUid*/) |
|
1011 { |
|
1012 //No Implementation |
|
1013 IRLOG_DEBUG( "CIRXMLContentHandler::GetExtendedInterface" ); |
|
1014 return NULL; |
|
1015 } |
|
1016 |
|
1017 |
|
1018 |
|
1019 GLDEF_C TInt E32Dll() |
|
1020 // DLL entry point |
|
1021 { |
|
1022 return(KErrNone); |
|
1023 } |
|
1024 |
|
1025 |