internetradio2.0/irxmlparser/src/irxmlelements.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 <stringpool.h>
       
    20 
       
    21 #include "irdebug.h"
       
    22 #include "irxmlelements.h"
       
    23 
       
    24 //Ignores PC Lint Warning 618.
       
    25 
       
    26 //! Literals for the StringPool
       
    27 
       
    28 //! Literals for List of genres,languages,countries
       
    29  _STLIT8( KName, "name" );
       
    30  _STLIT8( KID, "id" );
       
    31  _STLIT8( KSize, "size" );
       
    32  
       
    33 //!Literals for the List of Channels
       
    34  _STLIT8( KShortDesC, "shortDesc" );
       
    35 
       
    36  _STLIT8( KBitrate, "bitrate" );
       
    37  _STLIT8( KValue, "value" );
       
    38 //! Literals for the channel 
       
    39 
       
    40 _STLIT8( KSdsid, "sdsid" );
       
    41 _STLIT8( KLangCode, "langCode" );
       
    42 _STLIT8( KLang, "lang" );
       
    43 _STLIT8( KCountryCode, "countryCode" );
       
    44 _STLIT8( KLastUpdated, "lastUpdated" );
       
    45 _STLIT8( KDescription, "description" );
       
    46 _STLIT8( KImgURL, "imgUrl" );
       
    47 _STLIT8( KAdvUrl, "advertiseImgUrl" );
       
    48 _STLIT8( KAdvUse, "advertiseInUse" );
       
    49 _STLIT8( KGenreId, "genreid" );
       
    50 _STLIT8( KURL, "url" );
       
    51 _STLIT8( KMusicStoreEnabled, "musicStoreEnabled" );
       
    52 //!Literals for the log Usage
       
    53 
       
    54 _STLIT8( KIRId, "irid" ); 
       
    55 //! Literals for the OTA Update
       
    56 
       
    57 _STLIT8( KVersion, "version" );
       
    58 _STLIT8( KUpdateInterval, "updateInterval" );
       
    59 _STLIT8( KUpdateMethod, "updateMethod" );
       
    60 
       
    61  //! Literals for Advertisement
       
    62 _STLIT8( KInUse, "inUse" );
       
    63 _STLIT8( KUsageVisibleTimes, "usageVisibleTimes" );
       
    64 _STLIT8( KVisibleTime, "visibleTime" );
       
    65  
       
    66 const TInt KNoOfElementInTable = 27;
       
    67  
       
    68  //! PoolTable
       
    69  const TAny* const IRXMLPoolContent[] =
       
    70     { 
       
    71   (const TAny*)         &KGetOp,    
       
    72   (const TAny*)         &KName,       
       
    73   (const TAny*)         &KID,    
       
    74   (const TAny*)         &KSize,
       
    75   (const TAny*)         &KShortDesC,
       
    76   (const TAny*)         &KValue,        
       
    77   (const TAny*)         &KSdsid,
       
    78   (const TAny*)         &KLangCode,
       
    79   (const TAny*)         &KLang,
       
    80   (const TAny*)         &KCountryCode,
       
    81   (const TAny*)         &KCountry,
       
    82   (const TAny*)         &KLastUpdated,
       
    83   (const TAny*)         &KDescription,
       
    84   (const TAny*)         &KImgURL,
       
    85   (const TAny*)         &KAdvUrl,    
       
    86   (const TAny*)         &KAdvUse,
       
    87   (const TAny*)         &KGenreId,
       
    88   (const TAny*)         &KURL,    
       
    89   (const TAny*)         &KMusicStoreEnabled,    
       
    90   (const TAny*)         &KBitrate,
       
    91   (const TAny*)         &KIRId,
       
    92   (const TAny*)         &KVersion,
       
    93   (const TAny*)         &KUpdateInterval,
       
    94   (const TAny*)         &KUpdateMethod,
       
    95   (const TAny*)          &KInUse,
       
    96   (const TAny*)         &KUsageVisibleTimes,
       
    97   (const TAny*)          &KVisibleTime
       
    98     };
       
    99     
       
   100 //! Pointer to a StringTable
       
   101 const static TStringTable IRPoolTable = 
       
   102     {
       
   103     KNoOfElementInTable,      
       
   104     &IRXMLPoolContent[0],
       
   105     EFalse
       
   106     };     
       
   107 
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // Creates an initialised string pool with no pre-loaded string tables.
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void TIRXMLElementFormat::OpenStringPoolL( RStringPool&  aStringPool )
       
   114     {
       
   115     IRLOG_DEBUG( "CIRXMLContentHandler::OpenStringPoolL" );
       
   116     aStringPool.OpenL( IRPoolTable );
       
   117     IRLOG_DEBUG( "CIRXMLContentHandler::OpenStringPoolL - Exiting." );
       
   118     }
       
   119 
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // TIRXMLElementFormat :: GetElementIdL
       
   123 // The ElementId of the element from the StringPool
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 TIRXMLElement TIRXMLElementFormat::GetElementIdL( const TDesC8& aElement, 
       
   127                                   const RStringPool& aStringPool )
       
   128     {
       
   129     IRLOG_DEBUG( "TIRXMLElementFormat::GetElementIdL" );
       
   130     TBool validElement = EFalse;
       
   131     TInt  tableEntries;
       
   132     TInt  pos(0);
       
   133     tableEntries = IRPoolTable.iCount;
       
   134     while( pos < tableEntries && validElement == EFalse )
       
   135         {
       
   136         RStringF tableEntry;
       
   137         tableEntry = aStringPool.StringF( pos, IRPoolTable );
       
   138         HBufC8* ElementName = HBufC8::NewLC( tableEntry.DesC().Length() );
       
   139         ElementName->Des().Copy( tableEntry.DesC() );
       
   140         TLex8 string( *ElementName );
       
   141         TPtrC8 token = string.NextToken();
       
   142         TInt CompareResult = aElement.Compare( token );
       
   143         if ( CompareResult == 0 )
       
   144             {
       
   145              validElement = ETrue;
       
   146             }
       
   147         if ( validElement == EFalse )
       
   148             {
       
   149              pos++;
       
   150             }
       
   151         tableEntry.Close();
       
   152         CleanupStack::PopAndDestroy( ElementName );        
       
   153         }
       
   154     if ( validElement )
       
   155         {
       
   156         IRLOG_DEBUG( "CIRXMLContentHandler::GetElementIdL - Exiting (1)." );
       
   157         return static_cast<TIRXMLElement>( pos );
       
   158         }        
       
   159     IRLOG_DEBUG( "CIRXMLContentHandler::GetElementIdL - Exiting (2)." );
       
   160     return(EElementIDUnknown);
       
   161     } 
       
   162     
       
   163 // ---------------------------------------------------------------------------
       
   164 // TIRXMLElementFormat::CloseStringPoolL
       
   165 // Closes the StringPool
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 void TIRXMLElementFormat::CloseStringPoolL( RStringPool&  aStringPool )
       
   169     {
       
   170     IRLOG_DEBUG( "TIRXMLElementFormat::CloseStringPoolL" );
       
   171     aStringPool.Close();
       
   172     IRLOG_DEBUG( "TIRXMLElementFormat::CloseStringPoolL - Exiting." );
       
   173     return;
       
   174     }    
       
   175    
       
   176