internetradio2.0/irxmlparser/src/irxmlcontenthandler.cpp
changeset 14 896e9dbc5f19
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
       
     1 /*
       
     2 * Copyright (c) 2009 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:  The implementation for presentation elements.
       
    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     // if XML Parsing error occurred, maybe iChannel wasn't deleted 
       
   244     if ( iChannel )
       
   245         {
       
   246         delete iChannel;
       
   247         }
       
   248     iChannel = NULL;
       
   249     // if XML Parsing error occurred, maybe iCategory wasn't deleted     
       
   250     if ( iCategory )
       
   251         {
       
   252         delete iCategory;
       
   253         } 
       
   254     iCategory = NULL;
       
   255     iAdvts = EFalse;
       
   256     iAdvertisementTagFlag = EFalse;   
       
   257     IRLOG_DEBUG( "CIRXMLContentHandler::ResetValues - Exiting." );
       
   258   }    
       
   259  
       
   260 // ---------------------------------------------------------------------------
       
   261 // CIRXMLContentHandler:: OnStartDocumentL
       
   262 // This method is a callback to indicate the start of the document
       
   263 // ---------------------------------------------------------------------------
       
   264 //   
       
   265 void CIRXMLContentHandler:: OnStartDocumentL( const Xml::RDocumentParameters& 
       
   266   /*aDocParam*/ , TInt /*aErrorCode*/ )
       
   267     {                
       
   268     IRLOG_DEBUG( "CIRXMLContentHandler::OnStartDocumentL" );
       
   269     iEOD = KErrNone;
       
   270     }
       
   271     
       
   272 // ---------------------------------------------------------------------------
       
   273 // CIRXMLContentHandler::OnEndDocumentL
       
   274 // This method is a callback to indicate the end of the document
       
   275 // ---------------------------------------------------------------------------
       
   276 // 
       
   277 void CIRXMLContentHandler::OnEndDocumentL( TInt /*aErrorCode*/ )
       
   278     {
       
   279     //No Implementation
       
   280     IRLOG_DEBUG( "CIRXMLContentHandler::OnEndDocumentL" );
       
   281     return;
       
   282     }
       
   283  
       
   284 // ---------------------------------------------------------------------------
       
   285 // CIRXMLContentHandler::OnStartElementL
       
   286 // This method is a callback to indicate an element has been parsed. 
       
   287 // ---------------------------------------------------------------------------
       
   288 //
       
   289 void CIRXMLContentHandler::OnStartElementL( const Xml::RTagInfo &aElement, 
       
   290       const Xml::RAttributeArray &aAttributes, TInt /*aErrorCode*/ )
       
   291     {     
       
   292     IRLOG_DEBUG( "CIRXMLContentHandler::OnStartElementL" );     
       
   293     //Compare the element name to identify the type - //TO DO String Pool        
       
   294     TInt genre = ( aElement.LocalName().DesC() ).Compare( KGenre );
       
   295     TInt lang = ( aElement.LocalName().DesC() ).Compare( KLanguage );
       
   296     TInt country = ( aElement.LocalName().DesC() ).Compare( KCountry );
       
   297     TInt channel = ( aElement.LocalName().DesC() ).Compare( KChannel );
       
   298     TInt preset = ( aElement.LocalName().DesC() ).Compare( KPreset );
       
   299     TInt advertisements = ( aElement.LocalName().DesC() ).Compare( KAdvertisements );
       
   300     TInt ad = ( aElement.LocalName().DesC() ).Compare( KAd );
       
   301 
       
   302     TInt genres = ( aElement.LocalName().DesC() ).Compare( KCatGenre );
       
   303     TInt countries = ( aElement.LocalName().DesC() ).Compare( KCatCountry );
       
   304     TInt languages = ( aElement.LocalName().DesC() ).Compare( KCatLang );
       
   305     TInt channels = ( aElement.LocalName().DesC() ).Compare( KChannels );
       
   306     TInt presets = ( aElement.LocalName().DesC() ).Compare( KPresets );
       
   307 
       
   308     TInt IRID = ( aElement.LocalName().DesC() ).Compare( KIRID );
       
   309     TInt timestamp = ( aElement.LocalName().DesC() ).Compare( KTimeStamp );
       
   310     TInt irappversion = ( aElement.LocalName().DesC() ).Compare( KIRVersion );
       
   311     TInt adv = ( aElement.LocalName().DesC() ).Compare( KAdv );
       
   312     TInt banner = ( aElement.LocalName().DesC() ).Compare( KBanner );
       
   313 
       
   314    
       
   315     if ( iUrlContentForAds )
       
   316         {
       
   317         delete( iUrlContentForAds );
       
   318         iUrlContentForAds = NULL;
       
   319         }
       
   320 
       
   321     TInt bufSize( KTen );
       
   322     iUrlContentForAds = HBufC::NewL( bufSize );//this is because, the OnContentL method gives chunck by chunck
       
   323 
       
   324     if ( ad == 0 )
       
   325          {   
       
   326          //We want to take the first Ad only so if an Ad has already been created
       
   327          //iChannel and iCategory will not be NULL hence the new Ad should not be added
       
   328          if ( !iChannel && !iCategory )
       
   329              {
       
   330              iChannel = CIRBrowseChannelItems::NewL();  
       
   331              iCategory = CIRBrowseCatagoryItems::NewL();  
       
   332              
       
   333              }
       
   334          }
       
   335     if ( advertisements == 0 )
       
   336         { 
       
   337         iAdvertisementTagFlag = ETrue;   
       
   338         }
       
   339     if ( iAdvertisementTagFlag && banner == 0 )
       
   340         {
       
   341         iAdvts = ETrue;
       
   342         }
       
   343     // Creates the instance of the class Browse by Genre/Language/Country
       
   344     if ( iFlag )
       
   345         {
       
   346         if ( genre == 0 || lang == 0 || country == 0 )
       
   347         {
       
   348         //If there are ads then destroy the list and put the ads
       
   349         //as ads will the first in the xml
       
   350         if ( ( iAdvts )  && ( iCategory ) )
       
   351             { 
       
   352             iPtrCategory->ResetAndDestroy();
       
   353             iPtrCategory->AppendL( iCategory );
       
   354             iCategory = NULL;
       
   355             delete iChannel; 
       
   356             iChannel = NULL;
       
   357             iAdvts = EFalse;
       
   358             }
       
   359             iCategory = CIRBrowseCatagoryItems::NewL();
       
   360             iCat = ETrue;                
       
   361             }
       
   362         }
       
   363     if ( iFlag )
       
   364         {
       
   365         // In case of browse by genres, country and lanaguages
       
   366          if ( genres == 0 || countries == 0 || languages == 0 )
       
   367             { 
       
   368             if ( iAdvts == EFalse )
       
   369                 {
       
   370                 iPtrCategory->ResetAndDestroy();
       
   371                 }
       
   372             if ( genres == 0 )
       
   373                 {
       
   374                 iFileToCache.Zero();
       
   375                 iFileToCache.Copy( KCatGenre );
       
   376                 }
       
   377             if ( countries == 0 )                        
       
   378                 {
       
   379                 iFileToCache.Zero();
       
   380                 iFileToCache.Copy( KCatCountry );
       
   381                 }
       
   382             if ( languages == 0 )                        
       
   383                 {      
       
   384                 iFileToCache.Zero();
       
   385                 iFileToCache.Copy( KCatLang );
       
   386                 }
       
   387 
       
   388             iCategories = ETrue;                           
       
   389             }
       
   390         }
       
   391     // Creates the instance of the class Channel
       
   392     if ( channel == 0 )
       
   393         {
       
   394         //If there are ads then destroy the list and put the ads
       
   395         //as ads will the first in the xml
       
   396         if ( ( iAdvts )   && ( iChannel ) ) 
       
   397             {
       
   398             iPtrChannel->AppendL( iChannel );
       
   399             iChannel = NULL;
       
   400             delete iCategory; 
       
   401             iCategory = NULL;
       
   402             iAdvts = EFalse;
       
   403             }
       
   404         iChannel = CIRBrowseChannelItems::NewL();    
       
   405         iChannels = ETrue;
       
   406         iBitrateCounter = 0;
       
   407         }
       
   408     if ( channels == 0 )
       
   409         { 
       
   410         iPtrChannel->ResetAndDestroy();   
       
   411         iChan = ETrue;
       
   412         iChannelFlag = 0;    
       
   413         }
       
   414     // Creates the instance of the class for Preset Data
       
   415     if ( preset == 0 )
       
   416         {    
       
   417          iPreset = CIRIsdsPreset::NewL();    
       
   418          iPresets = ETrue;           
       
   419         }
       
   420     if ( presets == 0 )
       
   421         {     
       
   422         iPtrPreset->ResetAndDestroy();  
       
   423         iFlag = 0;
       
   424         }
       
   425     if ( IRID == 0 )
       
   426         {
       
   427         iIRID = ETrue;    
       
   428         }
       
   429     if ( timestamp == 0 )
       
   430         {
       
   431         //time stamp is obtained when session log is obtained in isds 
       
   432         iTimeStamp = ETrue;
       
   433         }
       
   434     if ( irappversion == 0 )
       
   435         {
       
   436         iOTA = CIROTAUpdate::NewL();
       
   437         iOTAUpdate = ETrue;
       
   438         }
       
   439     if ( adv == 0 )
       
   440         {
       
   441         iAdv = CIRAdvertisement::NewL();
       
   442         iAdvertisement = ETrue;
       
   443         }
       
   444     TBuf<KAttributeBufferSize> BufParam1;
       
   445     TBuf<KAttributeBufferSize> BufParam2; 
       
   446     
       
   447     // Parses the attributes and the value of the element
       
   448     TInt nAttributes = aAttributes.Count();
       
   449     for ( TInt indexofattribute = 0; indexofattribute < nAttributes; 
       
   450                           ++indexofattribute )
       
   451         {
       
   452         const RAttribute& attribute = aAttributes[indexofattribute];
       
   453         const RTagInfo& nameInfo = attribute.Attribute();
       
   454          
       
   455         //!Gets the elementId from the Pool for the specified attributename
       
   456         TIRXMLElement ATTelementId = TIRXMLElementFormat::GetElementIdL(
       
   457                     ( nameInfo.LocalName().DesC() ),iStringPool ); 
       
   458          
       
   459         HBufC* converted = CnvUtfConverter::
       
   460             ConvertToUnicodeFromUtf8L( attribute.Value().DesC() );
       
   461         CleanupStack::PushL( converted );
       
   462         
       
   463         switch( ATTelementId ) 
       
   464             {
       
   465             case EGetOperation: 
       
   466                 {
       
   467                 delete iBufGetOperation;
       
   468                 iBufGetOperation = NULL;
       
   469                 iBufGetOperation = converted->Des().AllocL();
       
   470                 }
       
   471                 break;
       
   472                                
       
   473             case EName:
       
   474                 {
       
   475                 //if name is parsed
       
   476                 if ( iCat )
       
   477                     {                                                                    
       
   478                     //if category
       
   479                     iCategory->SetGetOperation( *iBufGetOperation );                                          
       
   480                     BufParam1.Copy( *converted );                
       
   481                     }
       
   482                 if ( iChannels )
       
   483                     {
       
   484                      //if channel
       
   485                     iChannel->SetGetOperationL( *iBufGetOperation );
       
   486                     iChannel->SetSize( *iSize );
       
   487                     BufParam1.Copy( *converted );
       
   488                     } 
       
   489                 if ( iPresets )
       
   490                     {
       
   491                     if ( ( aElement.LocalName().DesC()) == KPreset )
       
   492                       {
       
   493                       //for preset
       
   494                       iPreset->SetNameL( *converted );
       
   495                       }                                
       
   496                     BufParam1.Copy( *converted );
       
   497                     }                        
       
   498                 }
       
   499                 break;    
       
   500                                      
       
   501             case EID:
       
   502                 {
       
   503                 //getting id
       
   504                 if ( iCat )
       
   505                     {
       
   506                     //for category
       
   507                     iCategory->SetTextL( BufParam1, *converted );    
       
   508                     }
       
   509                    
       
   510                 if ( iChannels )
       
   511                     {
       
   512                     //for channel
       
   513                     BufParam2.Copy( *converted );          
       
   514                     }     
       
   515                 if ( iPresets )
       
   516                     {
       
   517                       //for preset
       
   518                     iPreset->SetGenreInfoL( *converted, BufParam1 );
       
   519                     }  
       
   520                 if( iIRID)
       
   521                     {
       
   522                       //ir id
       
   523                     iRID.Copy( *converted );
       
   524                     }
       
   525                 }
       
   526                 break;
       
   527                              
       
   528             case ESize: 
       
   529                 {
       
   530                 delete iSize;
       
   531                 iSize = NULL;
       
   532                 iSize = converted->Des().AllocL();
       
   533                 if( iCat )
       
   534                     {
       
   535                     iCategory->SetSize( *iSize );
       
   536                     }                       
       
   537                 }
       
   538                 break;
       
   539                          
       
   540             case EShortDesC:
       
   541                 {
       
   542                 //getting short description
       
   543                 if( iChannels )              
       
   544                     {
       
   545                     iChannel->SetTextL( BufParam1,BufParam2,*converted );
       
   546                     }
       
   547                 if( iPresets )
       
   548                      {
       
   549                      iPreset->SetShortDescL( *converted );
       
   550                      }             
       
   551                 }
       
   552                 break;
       
   553                           
       
   554             case EBitrateValue:
       
   555                 {
       
   556                 //parsing bit rate
       
   557                 if( iChannels )
       
   558                     {
       
   559                         if( iBitrateCounter == KBitRateCounterValue0 )
       
   560                             {
       
   561                              iChannel->SetBitrate( *converted );
       
   562                              BufParam1.Copy( *converted );
       
   563                             }
       
   564                                             
       
   565                         if( iBitrateCounter == KBitRateCounterValue1 )
       
   566                             {
       
   567                              iChannel->SetBitrate( BufParam1,*converted );     
       
   568                              BufParam2.Copy( *converted );
       
   569                             }
       
   570                                            
       
   571                         if( iBitrateCounter == KBitRateCounterValue2 )
       
   572                             {
       
   573                             iChannel->SetBitrate( BufParam1,BufParam2,*converted );
       
   574                             }
       
   575                                            
       
   576                         iBitrateCounter++;
       
   577                     }
       
   578                 }                       
       
   579                 break;
       
   580                          
       
   581             case ESdsID:
       
   582                 {                   
       
   583                 if( iPresets )
       
   584                     {
       
   585                     iPreset->SetId( *converted );
       
   586                     }                                         
       
   587                 }
       
   588                 break;
       
   589                            
       
   590             case ELangCode:
       
   591                 {
       
   592                 //language code
       
   593                 if( iPresets )
       
   594                     {
       
   595                     iPreset->SetLangCodeL( *converted );
       
   596                     }                
       
   597                 }
       
   598                 break;
       
   599                            
       
   600             case ELang:
       
   601                 {                       
       
   602                 //language
       
   603                 if( iPresets )
       
   604                     {
       
   605                     iPreset->SetLangL( *converted );    
       
   606                     }
       
   607                 }
       
   608                 break;
       
   609                            
       
   610             case ECountryCode:
       
   611                 {
       
   612                 //country code
       
   613                 if( iPresets )
       
   614                     {
       
   615                     iPreset->SetCountryCodeL( *converted );    
       
   616                     }
       
   617                 }
       
   618                 break;
       
   619                     
       
   620             case ECountry:
       
   621                 {
       
   622                 //country
       
   623                 if( iPresets )
       
   624                     {
       
   625                     iPreset->SetCountryNameL( *converted );    
       
   626                     }
       
   627                 }
       
   628                 break;
       
   629                            
       
   630             case ELastUpdated:
       
   631                 {
       
   632                 //last modified time
       
   633                 if( iPresets )
       
   634                     {
       
   635                     iPreset->SetLastModifiedTimeL( *converted );    
       
   636                     }
       
   637                 }
       
   638                 break;
       
   639                            
       
   640             case EDesc:
       
   641                 {
       
   642                 //description
       
   643                 if( iPresets )
       
   644                     {
       
   645                     iPreset->SetDescriptionL( *converted );
       
   646                     }
       
   647                 }
       
   648                 break;
       
   649                            
       
   650             case EImgURL:
       
   651                 {
       
   652                 //image url
       
   653                 if( iChannels )                  
       
   654                     {
       
   655                     iChannel->SetImageUrlL( *converted );
       
   656                     }
       
   657                 if( iPresets )
       
   658                     {
       
   659                     iPreset->SetImgUrlL( *converted );    
       
   660                     }
       
   661                 }
       
   662                 break;
       
   663                            
       
   664             case EAdvImgURL:
       
   665                 {
       
   666                 //advertisement url
       
   667                 if( iPresets )
       
   668                     {
       
   669                     iPreset->SetAdvertisementUrlL( *converted );    
       
   670                     }
       
   671                 }
       
   672                 break;
       
   673                             
       
   674             case EAdvInUse:
       
   675                 {
       
   676                  //advertisement in use
       
   677                  if( iPresets )
       
   678                      {
       
   679                      iPreset->SetAdvertisementInUseL( *converted );    
       
   680                      }
       
   681                  }
       
   682                  break;
       
   683                            
       
   684             case EGenreID:
       
   685                 {
       
   686                 //genre id
       
   687                 if( iPresets )
       
   688                     {
       
   689                     iPreset->SetGenreInfoL( BufParam1,*converted );    
       
   690                     }
       
   691                 }
       
   692                 break;
       
   693                           
       
   694             case EURL:
       
   695                 {
       
   696                 //url
       
   697                 if( iPresets )
       
   698                    {
       
   699                     BufParam2.Copy( *converted );    
       
   700                     }
       
   701                 if( iAdvertisement )
       
   702                     {
       
   703                     iAdv->SetURL( *converted );
       
   704                     } 
       
   705                 }
       
   706                 break;
       
   707                         
       
   708             case EMusicStoreEnabled:
       
   709                 {                   
       
   710                 if( iPresets )
       
   711                     {
       
   712                     iPreset->SetMusicStoreStatusL( *converted );
       
   713                     }                                         
       
   714                 }
       
   715                 break;     
       
   716                         
       
   717             case EBitrate:
       
   718                 {
       
   719                 //set url
       
   720                 if( iPresets )
       
   721                     {
       
   722                     iPreset->SetUrlL( BufParam1,BufParam2,*converted );
       
   723                     }
       
   724                 }
       
   725                 break;
       
   726                            
       
   727             case EIRID:
       
   728                 {
       
   729                 //irid      
       
   730                 }
       
   731                 break;
       
   732                            
       
   733             case EVersion:
       
   734                 {
       
   735                 //for ota update
       
   736                 if( iOTAUpdate )
       
   737                    {
       
   738                     iOTA->SetVersion( *converted );
       
   739                     } 
       
   740                 }
       
   741                 break;
       
   742                            
       
   743             case EUpdateInterval:
       
   744                 {
       
   745                 //update interval
       
   746                 if( iOTAUpdate )
       
   747                     {
       
   748                     iOTA->SetUpdateInterval( *converted );    
       
   749                     }
       
   750                 }
       
   751                 break;
       
   752                            
       
   753             case EUpdateMethod:
       
   754                 {
       
   755                 //update method
       
   756                 if( iOTAUpdate )
       
   757                     {
       
   758                     iOTA->SetUpdateMethod( *converted );    
       
   759                     }
       
   760                 }
       
   761                 break;
       
   762                            
       
   763             case EInUse:
       
   764                  {
       
   765                  //advertisement in use
       
   766                  if( iAdvertisement )
       
   767                      {
       
   768                      iAdv->SetAdvInUse( *converted );
       
   769                      }
       
   770                  }
       
   771                  break;
       
   772                            
       
   773             case EUsageVisibleTimes:
       
   774                 {
       
   775                 if( iAdvertisement )
       
   776                     {
       
   777                     iAdv->SetUsage( *converted );
       
   778                     }
       
   779                 }
       
   780                 break;
       
   781                            
       
   782             case EVisibleTime:
       
   783                 {
       
   784                 //advertisement visible time
       
   785                 if( iAdvertisement )
       
   786                     {
       
   787                     iAdv->SetVisibleTime( *converted );
       
   788                     }
       
   789                 }
       
   790                 break;
       
   791                            
       
   792             case EElementIDUnknown:
       
   793                 {
       
   794                 //unknown
       
   795                 }
       
   796                 break;
       
   797                           
       
   798             default:
       
   799                 {
       
   800                 break;
       
   801                 } 
       
   802             }//End of Switch
       
   803         CleanupStack::PopAndDestroy( converted );
       
   804         } //End of for                    
       
   805     IRLOG_DEBUG( "CIRXMLContentHandler::OnStartElementL - Exiting." );                         
       
   806     }
       
   807  
       
   808 // ---------------------------------------------------------------------------
       
   809 // CIRXMLContentHandler::OnEndElementL
       
   810 // This method is a callback to indicate the end of the element has been reached. 
       
   811 // ---------------------------------------------------------------------------
       
   812 //
       
   813 void CIRXMLContentHandler::OnEndElementL( const RTagInfo &aElement, TInt /*aErrorCode*/ )
       
   814     {    
       
   815     IRLOG_DEBUG( "CIRXMLContentHandler::OnEndElementL" );        
       
   816     if( ( aElement.LocalName( ).DesC( ) ) == KPreset )
       
   817         {
       
   818         if ( iPreset->GetUrlCount() > 0 )
       
   819             {
       
   820             // The ownership is transferred to the array.
       
   821             iPtrPreset->AppendL( iPreset ); 
       
   822             }
       
   823         else
       
   824             {
       
   825             // If there is not a single URL, we don't let it in.
       
   826             iEOD = KErrCorrupt;
       
   827             delete iPreset;
       
   828             }
       
   829         // Ownership transferred. Remove the pointer.
       
   830         iPreset = NULL; 
       
   831         }
       
   832     if( ( aElement.LocalName( ).DesC( ) ) == KBanner )
       
   833         {
       
   834         //get the content for the tag "banner"
       
   835         //assign it to "iBanner" of CIRBrowseChannelItems
       
   836         if( iUrlContentForAds )
       
   837             {
       
   838             iChannel->SetBannerUrl( *iUrlContentForAds );         
       
   839             iCategory->SetBannerUrl( *iUrlContentForAds );          
       
   840             }
       
   841         }
       
   842     if( ( aElement.LocalName(  ).DesC(  ) ) == KClickthroughUrl )
       
   843         {
       
   844         //get the content for the tag "clickthrough-url"
       
   845         //assign it to "iClickThroughUrl" of CIRBrowseChannelItems 
       
   846         if( iUrlContentForAds )
       
   847             {
       
   848             iChannel->SetClickThroughUrl( *iUrlContentForAds );         
       
   849             iCategory->SetClickThroughUrl( *iUrlContentForAds );
       
   850             }
       
   851         }
       
   852       
       
   853     if( iUrlContentForAds )
       
   854         {
       
   855         delete iUrlContentForAds;
       
   856         iUrlContentForAds = NULL;
       
   857          
       
   858         }
       
   859     if( iFlag )
       
   860         {
       
   861         if( ( aElement.LocalName( ).DesC( ) ) == KGenre ||
       
   862           ( aElement.LocalName( ).DesC( ) ) == KLanguage || 
       
   863           ( aElement.LocalName( ).DesC( ) ) == KCountry )
       
   864             {         
       
   865             iPtrCategory->AppendL( iCategory );
       
   866             iCategory = NULL;
       
   867             iCat = EFalse;
       
   868             }
       
   869         }
       
   870     
       
   871     if( ( aElement.LocalName( ).DesC( ) ) == KChannel )
       
   872         {
       
   873         iPtrChannel->AppendL( iChannel );
       
   874         iChannel = NULL;
       
   875         iChannels = EFalse;         
       
   876         } 
       
   877     //appends the created channel(ad) to the array
       
   878     /*
       
   879     if((aElement.LocalName().DesC()) == KAd)
       
   880         {
       
   881     iPtrChannel->AppendL(iChannel);
       
   882         iChannel = NULL;
       
   883 
       
   884         } */
       
   885    
       
   886     if( ( aElement.LocalName( ).DesC( ) ) == KServers )
       
   887     {
       
   888         if ( iPreset )
       
   889         {
       
   890             iPreset->SetUrlCount( );
       
   891         }
       
   892         }               
       
   893     IRLOG_DEBUG( "CIRXMLContentHandler::OnEndElementL - Exiting." );                   
       
   894     }
       
   895  
       
   896 // ---------------------------------------------------------------------------
       
   897 // CIRXMLContentHandler ::OnContentL
       
   898 // This method is a callback that sends the content of the element.The data 
       
   899 // may be sent in chunks
       
   900 // ---------------------------------------------------------------------------
       
   901 //
       
   902 void CIRXMLContentHandler ::OnContentL( const TDesC8 &aBytes, TInt 
       
   903     aErrorCode )
       
   904     { 
       
   905     IRLOG_DEBUG(  "CIRXMLContentHandler::OnContentL" );
       
   906     
       
   907     if ( KErrNone == aErrorCode )
       
   908         {
       
   909         
       
   910         
       
   911         HBufC* buffertmp = HBufC::NewLC( aBytes.Length( ) + 1 );
       
   912         TPtr buffertmpPtr( buffertmp->Des( ) );
       
   913         buffertmpPtr.Copy( aBytes );
       
   914     
       
   915     
       
   916         TInt tempSize;
       
   917         if( iUrlContentForAds )
       
   918             {
       
   919               tempSize = iUrlContentForAds->Length( ) + aBytes.Length( );
       
   920               iUrlContentForAds = iUrlContentForAds->ReAllocL( tempSize );
       
   921               TPtr bufferPtr( iUrlContentForAds->Des( ) );
       
   922               bufferPtr.Append( buffertmpPtr );
       
   923             }
       
   924         
       
   925         CleanupStack::PopAndDestroy( buffertmp ); // buffertmp
       
   926         } 
       
   927         
       
   928         if ( iOTAUpdate )
       
   929             {
       
   930             HBufC* converted = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aBytes );
       
   931             CleanupStack::PushL( converted );
       
   932             converted->Des( ).TrimAll( );
       
   933             if ( converted->Des( ).Length( ) )
       
   934                 {                    
       
   935                 iOTA->SetOTAUrl( *converted );
       
   936                 }
       
   937             CleanupStack::PopAndDestroy( converted );
       
   938             }
       
   939     
       
   940     IRLOG_DEBUG( "CIRXMLContentHandler::OnContentL - Exiting." );        
       
   941     }
       
   942 
       
   943 
       
   944 // ---------------------------------------------------------------------------
       
   945 // CIRXMLContentHandler::OnStartPrefixMappingL
       
   946 // This method is a notification of the beginning of the scope of a 
       
   947 // prefix-URI Namespace mapping.
       
   948 // ---------------------------------------------------------------------------
       
   949 // 
       
   950 void CIRXMLContentHandler::OnStartPrefixMappingL( const RString& /*aPrefix*/, 
       
   951     const RString& /*aUri*/, TInt /*aErrorCode*/ )
       
   952     {
       
   953     //No Implementaion    
       
   954     IRLOG_DEBUG( "CIRXMLContentHandler::OnStartPrefixMappingL" );      
       
   955     }  
       
   956       
       
   957 // ---------------------------------------------------------------------------
       
   958 // CIRXMLContentHandler :: OnEndPrefixMappingL
       
   959 // This method is a notification of the end of the scope of a prefix-URI mapping
       
   960 // ---------------------------------------------------------------------------
       
   961 //  
       
   962 void CIRXMLContentHandler :: OnEndPrefixMappingL( const RString& /*aPrefix*/, 
       
   963     TInt /*aErrorCode*/)
       
   964     {
       
   965     //No Implementaion    
       
   966     IRLOG_DEBUG( "CIRXMLContentHandler::OnEndPrefixMappingL" );    
       
   967     }
       
   968      
       
   969 // ---------------------------------------------------------------------------
       
   970 // CIRXMLContentHandler :: OnIgnorableWhiteSpaceL
       
   971 // This method is a notification of ignorable whitespace in element content. 
       
   972 // ---------------------------------------------------------------------------
       
   973 //
       
   974 void CIRXMLContentHandler :: OnIgnorableWhiteSpaceL( const TDesC8&  /*aBytes*/, 
       
   975     TInt /*aErrorCode*/ )
       
   976     {
       
   977     //No Implementaion        
       
   978     IRLOG_DEBUG( "CIRXMLContentHandler::OnIgnorableWhiteSpaceL" );        
       
   979     }
       
   980      
       
   981 // ---------------------------------------------------------------------------
       
   982 // CIRXMLContentHandler :: OnSkippedEntityL
       
   983 // This method is a notification of a skipped entity
       
   984 // ---------------------------------------------------------------------------
       
   985 //
       
   986 void CIRXMLContentHandler :: OnSkippedEntityL( const RString& /*aName*/, 
       
   987     TInt /*aErrorCode*/ )
       
   988     {
       
   989     //No Implementaion    
       
   990     IRLOG_DEBUG(  "CIRXMLContentHandler::OnSkippedEntityL" );
       
   991     }
       
   992 
       
   993 // ---------------------------------------------------------------------------
       
   994 // CIRXMLContentHandler :: OnProcessingInstructionL
       
   995 // This method is a receive notification of a processing instruction.
       
   996 // ---------------------------------------------------------------------------
       
   997 //
       
   998 void CIRXMLContentHandler :: OnProcessingInstructionL( const TDesC8& 
       
   999   /*aTarget*/, const TDesC8& /*aData*/, TInt /*aErrorCode*/ )
       
  1000      {
       
  1001       //No Implementaion    
       
  1002      IRLOG_DEBUG( "CIRXMLContentHandler::OnProcessingInstructionL" );
       
  1003      }
       
  1004  
       
  1005 // ---------------------------------------------------------------------------
       
  1006 // CIRXMLContentHandler :: OnError
       
  1007 // This method indicates an error has occurred.
       
  1008 // ---------------------------------------------------------------------------
       
  1009 //
       
  1010 void CIRXMLContentHandler :: OnError( TInt aErrorCode )
       
  1011      {
       
  1012      iEOD = aErrorCode;         
       
  1013      IRLOG_ERROR2( "CIRXMLContentHandler::OnError (%d)", aErrorCode );
       
  1014      }
       
  1015   
       
  1016   
       
  1017 // ---------------------------------------------------------------------------
       
  1018 // CIRXMLContentHandler :: GetExtendedInterface
       
  1019 // This method obtains the interface matching the specified uid. 
       
  1020 // ---------------------------------------------------------------------------
       
  1021 //
       
  1022 TAny* CIRXMLContentHandler :: GetExtendedInterface( const TInt32 /*aUid*/ )
       
  1023      {
       
  1024       //No Implementation
       
  1025       IRLOG_DEBUG( "CIRXMLContentHandler::GetExtendedInterface" );
       
  1026       return NULL;
       
  1027      }
       
  1028  
       
  1029 
       
  1030 
       
  1031 GLDEF_C TInt E32Dll( ) 
       
  1032 // DLL entry point
       
  1033     {
       
  1034     return( KErrNone );
       
  1035     }
       
  1036 
       
  1037