internetradio2.0/irxmlparser/inc/irxmlcontenthandler.h
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 #ifndef IRXMLCONTENTHANDLER_H
       
    20 #define IRXMLCONTENTHANDLER_H
       
    21 
       
    22 #include <contenthandler.h>
       
    23 
       
    24 class CIRAdvertisement;
       
    25 class CIRBrowseCatagoryItems;
       
    26 class CIRBrowseChannelItems;
       
    27 class CIRCacheMgmt;
       
    28 class CIRHttpResponseData;
       
    29 class CIRIsdsPreset;
       
    30 class CIROTAUpdate;
       
    31 class MIRCacheObserver;
       
    32 class MIRParserObserver;
       
    33 
       
    34 namespace Xml
       
    35     {
       
    36     class CParser;
       
    37     }
       
    38 
       
    39 //constant declaration   
       
    40 _LIT8(KFile,"text/xml");    
       
    41 const TInt KSessionLogResponse = 5;
       
    42 
       
    43 using namespace Xml;
       
    44 
       
    45 /**
       
    46 * Parse data from xml file
       
    47 *
       
    48 * @code 
       
    49 *
       
    50 * classA* ParserObserver;//class classA : public MIRParserObserver
       
    51 * classB* CacheObserver;//class classB : public MIRCacheObserver
       
    52 * CIRHttpResponseData* ResponseHeader;
       
    53 * CIRHttpResponseData* parser = CIRXMLContentHandler::
       
    54 * NewL (*ParserObserver,*CacheObserver); 
       
    55 * parser->ParseXmlL(FilePath,CachePath,ResponseHeader);
       
    56 *
       
    57 * @endcode
       
    58 *
       
    59 */
       
    60 
       
    61 class CIRXMLContentHandler : public CBase,
       
    62                         public MContentHandler
       
    63     {
       
    64 public:             
       
    65     /**
       
    66     * Gets the Filepath of the XML file
       
    67     * @param aFilePath Contains the filepath of the file
       
    68     * @return ErrorCode if the file cannot be opened
       
    69     */
       
    70   IMPORT_C void ParseXmlL( const TDesC& aFilePath, const TDesC& aCachePath,
       
    71              const CIRHttpResponseData& aResponseHeaders );
       
    72 
       
    73     /**
       
    74     * Default Constructor
       
    75     * @param aObserver Contains the reference to the MClass Observer
       
    76     */    
       
    77     IMPORT_C static CIRXMLContentHandler* NewL 
       
    78     ( MIRParserObserver &aObserver, MIRCacheObserver &aCacheObserver );       
       
    79     /**
       
    80     * Destructing the object
       
    81     */  
       
    82     ~CIRXMLContentHandler();
       
    83     /**
       
    84     * This method is a callback to indicate the start of the document
       
    85     * @param aDocParam Specifies the various parameters of the document
       
    86     * @param aErrorCode KErrNone if successfull. 
       
    87     * @return None
       
    88     */         
       
    89     virtual void OnStartDocumentL( const RDocumentParameters &aDocParam,
       
    90        TInt aErrorCode );
       
    91     /**
       
    92     * This method is a callback to indicate the end of the document
       
    93     * @param aErrorCode KErrNone if successfull. 
       
    94     * @return None
       
    95     */                  
       
    96     virtual void OnEndDocumentL( TInt aErrorCode );
       
    97     /**
       
    98     * This method is a callback to indicate an element has been parsed. 
       
    99     * @param aElement is a handle to the element's details. 
       
   100     * @param aAttributes contains the attributes for the element
       
   101     * @param aErrorCode KErrNone if successfull. 
       
   102     */    
       
   103     virtual void OnStartElementL( const RTagInfo &aElement, 
       
   104       const RAttributeArray &aAttributes, TInt aErrorCode );
       
   105     /**
       
   106     * This method is a callback to indicate the end of 
       
   107     * the element has been reached. 
       
   108     * @param aElement is a handle to the element's details. 
       
   109     * @param aErrorCode KErrNone if successfull. 
       
   110     */   
       
   111     virtual void OnEndElementL( const RTagInfo &aElement, TInt aErrorCode );
       
   112     /**
       
   113     * This method is a callback that sends the content of the element.
       
   114     * The data may be sent in chunks
       
   115     * @param aBytes is the raw content data for the element. 
       
   116     * @param aErrorCode KErrNone if successfull. 
       
   117     */  
       
   118     virtual void OnContentL( const TDesC8 &aBytes, TInt aErrorCode );
       
   119     /**
       
   120     * This method is a notification of the beginning of the scope 
       
   121     *of a prefix-URI Namespace mapping.
       
   122     * @param aPrefix is the Namespace prefix being declared 
       
   123     * @param aUri is the Namespace URI the prefix is mapped to
       
   124     * @param aErrorCode KErrNone if successfull. 
       
   125     */  
       
   126     virtual void OnStartPrefixMappingL( const RString &aPrefix, 
       
   127       const RString &aUri, TInt aErrorCode );
       
   128     /**
       
   129     * This method is a notification of the end of the scope 
       
   130     * of a prefix-URI mapping
       
   131     * @param aPrefix is the Namespace prefix that was mapped. 
       
   132     * @param aErrorCode KErrNone if successfull. 
       
   133     */  
       
   134     virtual void OnEndPrefixMappingL( const RString &aPrefix, TInt aErrorCode );
       
   135     /**
       
   136     * This method is a notification of ignorable whitespace in element content. 
       
   137     * @param aBytes are the ignored bytes from the document being parsed.. 
       
   138     * @param aErrorCode KErrNone if successfull. 
       
   139     */  
       
   140     virtual void OnIgnorableWhiteSpaceL( const TDesC8 &aBytes, TInt aErrorCode );
       
   141     /**
       
   142     * This method is a notification of a skipped entity
       
   143     * @param aName is the name of the skipped entity. 
       
   144     * @param aErrorCode KErrNone if successfull. 
       
   145     */ 
       
   146     virtual void OnSkippedEntityL( const RString &aName, TInt aErrorCode );
       
   147     /**
       
   148     * This method is a receive notification of a processing instruction.
       
   149     * @param aTarget is the processing instruction target. 
       
   150     * @param aData is the processing instruction data. 
       
   151     * If empty none was supplied.. 
       
   152     * @param aErrorCode KErrNone if successfull. 
       
   153     */ 
       
   154     virtual void OnProcessingInstructionL( const TDesC8 &aTarget, 
       
   155       const TDesC8 &aData, TInt aErrorCode );
       
   156     /**
       
   157     * This method indicates an error has occurred.
       
   158     * @param aErrorCode contains the errorcode. 
       
   159     */ 
       
   160     virtual void OnError( TInt aErrorCode );
       
   161     /**
       
   162     * This method obtains the interface matching the specified uid. 
       
   163     * @param aUid the uid identifying the required interface 
       
   164     * @return 0 if no interface matching the uid is found. 
       
   165     * Otherwise, the this pointer cast to that interface
       
   166     */ 
       
   167     virtual TAny *GetExtendedInterface( const TInt32 aUid ); 
       
   168     /**
       
   169     * This method maps the errorcode
       
   170     * @param aError conatins the errorcode
       
   171     * @return the type of the error
       
   172     */ 
       
   173     TInt ParseError( TInt aError );
       
   174     /**
       
   175     * This method stringpool handle
       
   176     * @param aError conatins the errorcode
       
   177     * @return the type of the error
       
   178     */ 
       
   179     RStringPool& StringPool ();
       
   180     
       
   181     void ResetValues();
       
   182 
       
   183 protected:
       
   184     
       
   185     /**
       
   186     * Default Constructor
       
   187     * @param aObserver Contains the reference to the MClass Observer
       
   188     */  
       
   189     CIRXMLContentHandler( MIRParserObserver &aObserver,
       
   190         MIRCacheObserver &aCacheObserver );
       
   191 
       
   192     /**
       
   193     * Two-Phase Constructor
       
   194     */
       
   195     void ConstructL();
       
   196     
       
   197    private :
       
   198     
       
   199     // Buffer for the URL
       
   200     HBufC* iBufGetOperation;
       
   201     
       
   202     // Buffer for Size
       
   203     HBufC* iSize;  
       
   204   
       
   205     // Count of the bitrates
       
   206     TBool iIRID;
       
   207 
       
   208     TInt iBitrateCounter;   
       
   209     
       
   210     // Indicating for Channels/Preset
       
   211     TInt iFlag;
       
   212     
       
   213     // Indicating for Channels
       
   214     TInt iChannelFlag;
       
   215     
       
   216     // Bool Value to indicate the class
       
   217     TBool iPresets;
       
   218     TBool iCategories;
       
   219     TBool iCat;
       
   220     TBool iChannels;
       
   221     TBool iChan;
       
   222     TBool iAdvertisement;
       
   223     TBool iOTAUpdate;
       
   224     TBool iTimeStamp; //checks the header has a time stamp
       
   225     TInt  iEOD;
       
   226     // Pointer to the PresetData
       
   227     CIRIsdsPreset *iPreset;
       
   228     
       
   229     // Pointer to the CategoryData
       
   230     CIRBrowseCatagoryItems *iCategory;
       
   231     
       
   232     // Pointer to the ChannelData
       
   233     CIRBrowseChannelItems *iChannel;
       
   234     
       
   235     // Pointer to the Advertisement
       
   236     
       
   237     CIRAdvertisement *iAdv;
       
   238     
       
   239     //! An Handle to Stringpool
       
   240       
       
   241     RStringPool    iStringPool;
       
   242     
       
   243     //! Reference to the CallBack Class
       
   244     
       
   245     MIRParserObserver& iParseObserver;
       
   246     
       
   247     CParser* iParser;
       
   248 
       
   249     //Caching 
       
   250     CIRCacheMgmt *iCache;
       
   251     
       
   252     MIRCacheObserver &iCacheObserver;
       
   253     
       
   254     TBuf<256> iFileToCache;
       
   255 
       
   256     // For Advertisement
       
   257     TBool iAdvts;
       
   258     TBool iAdvertisementTagFlag;
       
   259     HBufC*   iUrlContentForAds;  //to store the content of the tag
       
   260 
       
   261 
       
   262 
       
   263 public:
       
   264 
       
   265     // Count of the bitrates
       
   266     
       
   267     TBuf<30>      iRID;
       
   268 
       
   269     // Array of Pointers to PresetClass
       
   270     
       
   271     CArrayPtrFlat<CIRIsdsPreset>* iPtrPreset;
       
   272     
       
   273     // Array of Pointers to CategoryClass
       
   274     
       
   275     CArrayPtrFlat<CIRBrowseCatagoryItems>* iPtrCategory;
       
   276     
       
   277     // Array of Pointers to BrowseCategoryClass
       
   278     
       
   279     CArrayPtrFlat<CIRBrowseChannelItems>* iPtrChannel;
       
   280     // Pointer to the OTAUpdate
       
   281     
       
   282     CIROTAUpdate *iOTA;
       
   283     
       
   284     
       
   285       
       
   286 };
       
   287 
       
   288 #endif //IRXMLCONTENTHANDLER_H