upnpavcontroller/upnpxmlparser/inc/upnpxmleventparser.h
changeset 0 7f85d04be362
child 38 5360b7ddc251
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     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:      XML SAX Parser for UPnP.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef C_UPNPXMLEVENTPARSER_H_
       
    24 #define C_UPNPXMLEVENTPARSER_H_
       
    25 
       
    26 // INCLUDES
       
    27 #include <e32base.h>
       
    28 #include <xml/contenthandler.h>
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 
       
    32 using namespace Xml;
       
    33 
       
    34 /**
       
    35  * XML SAX Parser for UPnP.
       
    36  *
       
    37  * @since s60 3.1
       
    38  * @lib upnpxmlparser.lib
       
    39  */
       
    40 class CUPnPXMLEventParser :  public CBase,
       
    41                              public MContentHandler
       
    42     {
       
    43 
       
    44 public:
       
    45 
       
    46     enum TParserState
       
    47         {
       
    48         EEvent = 0,
       
    49         EInstanceID,
       
    50         EVolume,
       
    51         EMute,
       
    52         ENotSupported // Brightness etc.
       
    53         };    
       
    54 
       
    55 public:
       
    56 
       
    57     /**
       
    58      * 2-phased constructor.
       
    59      */
       
    60     IMPORT_C static CUPnPXMLEventParser* NewL();
       
    61     
       
    62     /**
       
    63      * Destructor.
       
    64      */
       
    65     virtual ~CUPnPXMLEventParser();
       
    66     
       
    67 public:
       
    68 
       
    69     /**
       
    70      * Parses xml data to the array of objects.
       
    71      * @param aResultArray, An array for objects in xml root.
       
    72      * @param aData, xml data.
       
    73      */
       
    74     IMPORT_C void ParseResultDataL( const TDesC8& aData,
       
    75         TInt& aInstanceId, TInt& aVolume, TBool& aMute );
       
    76                     
       
    77 protected: // from MContentHandler
       
    78 
       
    79     /**
       
    80      * From MContentHandler.
       
    81      * @param aDocParam, not used.
       
    82      * @param aErrorCode, not used.
       
    83      */
       
    84     void OnStartDocumentL( const RDocumentParameters& aDocParam, 
       
    85                            TInt aErrorCode );
       
    86     
       
    87     /**
       
    88      * From MContentHandler.
       
    89      * @param aErrorCode, not used.
       
    90      */
       
    91     void OnEndDocumentL( TInt aErrorCode );
       
    92     
       
    93     /**
       
    94      * From MContentHandler.
       
    95      * @param aElement, holds the element info.
       
    96      * @param aAttributes, holds the element's attributes.
       
    97      * @param aErrorCode, if not KErrNone, the method is ignored.
       
    98      */
       
    99     void OnStartElementL( const RTagInfo& aElement, 
       
   100                           const RAttributeArray& aAttributes, 
       
   101                           TInt aErrorCode );
       
   102     
       
   103     /**
       
   104      * From MContentHandler.
       
   105      * @param aElement, holds the element info.
       
   106      * @param aErrorCode, if not KErrNone, the method is ignored.
       
   107      */
       
   108     void OnEndElementL( const RTagInfo& aElement, TInt aErrorCode );
       
   109     
       
   110     /**
       
   111      * From MContentHandler.
       
   112      * @param aBytes, The value of the content.
       
   113      * @param aErrorCode, if not KErrNone, the method is ignored.
       
   114      */
       
   115     void OnContentL( const TDesC8& aBytes, TInt aErrorCode );
       
   116     
       
   117     /**
       
   118      * From MContentHandler.
       
   119      * @param aPrefix, not used.
       
   120      * @param aUri, not used.
       
   121      * @param aErrorCode, not used.
       
   122      */    
       
   123     void OnStartPrefixMappingL( const RString& aPrefix, 
       
   124                                 const RString& aUri, 
       
   125                                 TInt aErrorCode );
       
   126     
       
   127     /**
       
   128      * From MContentHandler.
       
   129      * @param aPrefix, not used.
       
   130      * @param aErrorCode, not used.
       
   131      */
       
   132     void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode );
       
   133     
       
   134     /**
       
   135      * From MContentHandler.
       
   136      * @param aBytes, not used.
       
   137      * @param aErrorCode, not used.
       
   138      */
       
   139     void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode );
       
   140     
       
   141     /**
       
   142      * From MContentHandler.
       
   143      * @param aName, not used.
       
   144      * @param aErrorCode, not used.
       
   145      */
       
   146     void OnSkippedEntityL( const RString& aName, TInt aErrorCode );
       
   147     
       
   148     /**
       
   149      * From MContentHandler.
       
   150      * @param aTarget, not used.
       
   151      * @param aData, not used.
       
   152      * @param aErrorCode, not used. 
       
   153      */
       
   154     void OnProcessingInstructionL( const TDesC8& aTarget, 
       
   155                                    const TDesC8& aData, 
       
   156                                    TInt aErrorCode );
       
   157     
       
   158     /**
       
   159      * From MContentHandler.
       
   160      * @param aErrorCode
       
   161      */                               
       
   162     void OnError( TInt aErrorCode );
       
   163     
       
   164     /**
       
   165      * From MContentHandler.
       
   166      * @param aUid, not used.
       
   167      * @return None.
       
   168      */
       
   169     TAny* GetExtendedInterface( const TInt32 aUid );
       
   170 
       
   171                                     
       
   172 private:
       
   173 
       
   174     /**
       
   175      * Constructor.
       
   176      */
       
   177     CUPnPXMLEventParser();
       
   178     
       
   179     /**
       
   180      * 2nd phase constructor.
       
   181      */
       
   182     void ConstructL();
       
   183     
       
   184 private:    
       
   185 
       
   186     void SetAttributesL( const RAttributeArray& aAttributes );
       
   187 
       
   188     void Reset();
       
   189     
       
   190 private: // data
       
   191     
       
   192     TParserState    iParserState;
       
   193         
       
   194     TInt            iInstanceID;
       
   195     
       
   196     TInt            iMute;
       
   197 
       
   198     TInt            iVolume;
       
   199     //ETrue:Master Volume is set.EFalse:Master Volume is not set.
       
   200     TBool           iMasterVolumeState;
       
   201     };
       
   202 
       
   203 #endif // C_UPNPXMLEVENTPARSER_H_
       
   204 
       
   205 // End of File