omadrm/drmengine/ro/inc/DrmRightsParser.h
changeset 23 493788a4a8a4
parent 0 95b198f216e5
equal deleted inserted replaced
5:79d62d1d7957 23:493788a4a8a4
    18 
    18 
    19 #ifndef DRMRIGHTSPARSER_H
    19 #ifndef DRMRIGHTSPARSER_H
    20 #define DRMRIGHTSPARSER_H
    20 #define DRMRIGHTSPARSER_H
    21 
    21 
    22 //  INCLUDES
    22 //  INCLUDES
    23 #include <Xml/Parser.h>
    23 #include <xml/parser.h>
    24 #include <Xml/ContentHandler.h>
    24 #include <xml/contenthandler.h>
    25 #include <Xml/XmlParserErrors.h>
    25 #include <xml/xmlparsererrors.h>
    26 
    26 
    27 using namespace Xml;
    27 using namespace Xml;
    28 
    28 
    29 // FORWARD DECLARATIONS
    29 // FORWARD DECLARATIONS
    30 class CDRMRights;
    30 class CDRMRights;
    48         enum TParserType
    48         enum TParserType
    49             {
    49             {
    50             EXmlParser,
    50             EXmlParser,
    51             EWbxmlParser
    51             EWbxmlParser
    52             };
    52             };
    53             
    53 
    54         enum TSoftwareSchemaType
    54         enum TSoftwareSchemaType
    55             {
    55             {
    56             ESymbianSid,
    56             ESymbianSid,
    57             ESymbianVid
    57             ESymbianVid
    58             };
    58             };
    59 
    59 
    60         static const TInt KMaxElementCount = 40;
    60         static const TInt KMaxElementCount = 40;
    61         static const TInt KMaxElementNesting = 16;
    61         static const TInt KMaxElementNesting = 16;
    62 
    62 
    63     public:  // Constructors and destructor
    63     public:  // Constructors and destructor
    64         
    64 
    65         /**
    65         /**
    66         * Create a parser object
    66         * Create a parser object
    67         * @since Series 60 3.0
    67         * @since Series 60 3.0
    68         * @param Type of the parser (XML or WBXML)
    68         * @param Type of the parser (XML or WBXML)
    69         * @return Allocated parser
    69         * @return Allocated parser
    70         */
    70         */
    71         IMPORT_C static CDrmRightsParser* NewL(
    71         IMPORT_C static CDrmRightsParser* NewL(
    72             TParserType aType = EXmlParser);
    72             TParserType aType = EXmlParser);
    73         
    73 
    74         /**
    74         /**
    75         * Destructor.
    75         * Destructor.
    76         */
    76         */
    77         IMPORT_C ~CDrmRightsParser();
    77         IMPORT_C ~CDrmRightsParser();
    78 
    78 
    79     public: // New functions
    79     public: // New functions
    80         
    80 
    81         /**
    81         /**
    82         * Parse one rights object
    82         * Parse one rights object
    83         * @since Series 60 3.0
    83         * @since Series 60 3.0
    84         * @param aRightsObject XML or WBXML representation of the rights
    84         * @param aRightsObject XML or WBXML representation of the rights
    85         * @param aResultRigths Parsed rights
    85         * @param aResultRigths Parsed rights
   102 
   102 
   103         /**
   103         /**
   104         * From MContentHandler
   104         * From MContentHandler
   105         * @param aDocParam Specifies the various parameters of the document.
   105         * @param aDocParam Specifies the various parameters of the document.
   106         * @arg   aDocParam.iCharacterSetName The character encoding of the document.
   106         * @arg   aDocParam.iCharacterSetName The character encoding of the document.
   107         * @param aErrorCode is the error code. 
   107         * @param aErrorCode is the error code.
   108         *        If this is not KErrNone then special action may be required.
   108         *        If this is not KErrNone then special action may be required.
   109         */
   109         */
   110         void OnStartDocumentL(
   110         void OnStartDocumentL(
   111             const RDocumentParameters& aDocParam,
   111             const RDocumentParameters& aDocParam,
   112             TInt aErrorCode);
   112             TInt aErrorCode);
   113 
   113 
   114         /**
   114         /**
   115         * From MContentHandler
   115         * From MContentHandler
   116         * @param aErrorCode is the error code. 
   116         * @param aErrorCode is the error code.
   117         *        If this is not KErrNone then special action may be required.
   117         *        If this is not KErrNone then special action may be required.
   118         */
   118         */
   119         void OnEndDocumentL(
   119         void OnEndDocumentL(
   120             TInt aErrorCode);
   120             TInt aErrorCode);
   121 
   121 
   126         * @param aErrorCode is the error code.
   126         * @param aErrorCode is the error code.
   127         *        If this is not KErrNone then special action may be required.
   127         *        If this is not KErrNone then special action may be required.
   128         */
   128         */
   129         void OnStartElementL(
   129         void OnStartElementL(
   130             const RTagInfo& aElement,
   130             const RTagInfo& aElement,
   131             const RAttributeArray& aAttributes, 
   131             const RAttributeArray& aAttributes,
   132 			TInt aErrorCode);
   132             TInt aErrorCode);
   133 
   133 
   134         /**
   134         /**
   135         * From MContentHandler
   135         * From MContentHandler
   136         * @param aElement is a handle to the element's details.
   136         * @param aElement is a handle to the element's details.
   137         * @param aErrorCode is the error code.
   137         * @param aErrorCode is the error code.
   141             const RTagInfo& aElement,
   141             const RTagInfo& aElement,
   142             TInt aErrorCode);
   142             TInt aErrorCode);
   143 
   143 
   144         /**
   144         /**
   145         * From MContentHandler
   145         * From MContentHandler
   146         * @param aBytes is the raw content data for the element. 
   146         * @param aBytes is the raw content data for the element.
   147         *        The client is responsible for converting the data to the 
   147         *        The client is responsible for converting the data to the
   148         *        required character set if necessary.
   148         *        required character set if necessary.
   149         *        In some instances the content may be binary and must not be converted.
   149         *        In some instances the content may be binary and must not be converted.
   150         * @param aErrorCode is the error code.
   150         * @param aErrorCode is the error code.
   151         *        If this is not KErrNone then special action may be required.
   151         *        If this is not KErrNone then special action may be required.
   152         */
   152         */
   161         * @param aErrorCode is the error code.
   161         * @param aErrorCode is the error code.
   162         *        If this is not KErrNone then special action may be required.
   162         *        If this is not KErrNone then special action may be required.
   163         */
   163         */
   164         void OnStartPrefixMappingL(
   164         void OnStartPrefixMappingL(
   165             const RString& aPrefix,
   165             const RString& aPrefix,
   166             const RString& aUri, 
   166             const RString& aUri,
   167 			TInt aErrorCode);
   167             TInt aErrorCode);
   168 
   168 
   169         /**
   169         /**
   170         * From MContentHandler
   170         * From MContentHandler
   171         * @param aPrefix is the Namespace prefix that was mapped.
   171         * @param aPrefix is the Namespace prefix that was mapped.
   172         * @param aErrorCode is the error code.
   172         * @param aErrorCode is the error code.
   203         * @param aErrorCode is the error code.
   203         * @param aErrorCode is the error code.
   204         *        If this is not KErrNone then special action may be required.
   204         *        If this is not KErrNone then special action may be required.
   205         */
   205         */
   206         void OnProcessingInstructionL(
   206         void OnProcessingInstructionL(
   207             const TDesC8& aTarget,
   207             const TDesC8& aTarget,
   208             const TDesC8& aData, 
   208             const TDesC8& aData,
   209 			TInt aErrorCode);
   209             TInt aErrorCode);
   210 
   210 
   211         /**
   211         /**
   212         * From MContentHandler
   212         * From MContentHandler
   213         */
   213         */
   214         void OnOutOfData();
   214         void OnOutOfData();
   230         */
   230         */
   231         TAny* GetExtendedInterface(
   231         TAny* GetExtendedInterface(
   232             const TInt32 aUid);
   232             const TInt32 aUid);
   233 
   233 
   234     protected:  // New functions
   234     protected:  // New functions
   235         
   235 
   236         /**
   236         /**
   237         * Match the state of the current stack to the predefined states
   237         * Match the state of the current stack to the predefined states
   238         * @since Series 60 3.0
   238         * @since Series 60 3.0
   239         * @return KErrNotFound if no state is matched, otherwise the number
   239         * @return KErrNotFound if no state is matched, otherwise the number
   240         *         of the state
   240         *         of the state
   246         * @since Series 60 3.0
   246         * @since Series 60 3.0
   247         * @param aResult Out parameter for the resul
   247         * @param aResult Out parameter for the resul
   248         */
   248         */
   249         void TransformRightsObjectL(
   249         void TransformRightsObjectL(
   250             RPointerArray<CDRMRights>& aResult);
   250             RPointerArray<CDRMRights>& aResult);
   251             
   251 
   252         /**
   252         /**
   253         * Return the value of an attribute as a buffer
   253         * Return the value of an attribute as a buffer
   254         * @since Series 60 3.0
   254         * @since Series 60 3.0
   255         * @param aAttrList Atrribute list
   255         * @param aAttrList Atrribute list
   256         * @param aAttrName Name of the attribute
   256         * @param aAttrName Name of the attribute
   273 
   273 
   274         /**
   274         /**
   275         * Parse the time string and return the TTime
   275         * Parse the time string and return the TTime
   276         */
   276         */
   277         TTime ParseRelTimeL(TDesC8& aRelTimeString);
   277         TTime ParseRelTimeL(TDesC8& aRelTimeString);
   278         
   278 
   279         /**
   279         /**
   280         * Parse the interval string and return the interval
   280         * Parse the interval string and return the interval
   281         */        
   281         */
   282         TTimeIntervalSeconds ParseRelInterval(TDesC8& aRelTimeString);
   282         TTimeIntervalSeconds ParseRelInterval(TDesC8& aRelTimeString);
   283 
   283 
   284 
   284 
   285         /**
   285         /**
   286         * Validate time string variables
   286         * Validate time string variables
   296 
   296 
   297 
   297 
   298     protected:  // Data
   298     protected:  // Data
   299         // XML Parser
   299         // XML Parser
   300         CParser* iParser;
   300         CParser* iParser;
   301         
   301 
   302         // Parsed rigths object
   302         // Parsed rigths object
   303         CParsedRightsObject* iRights;
   303         CParsedRightsObject* iRights;
   304         
   304 
   305         // Predefined XML element names
   305         // Predefined XML element names
   306         RString iElements[KMaxElementCount];
   306         RString iElements[KMaxElementCount];
   307         
   307 
   308         // Current parsing stack
   308         // Current parsing stack
   309         TInt iElementStack[KMaxElementNesting];
   309         TInt iElementStack[KMaxElementNesting];
   310         
   310 
   311         // Depth of the current parsing stack
   311         // Depth of the current parsing stack
   312         TInt iElementStackDepth;
   312         TInt iElementStackDepth;
   313         
   313 
   314         // Content between elements
   314         // Content between elements
   315         HBufC8* iContent;
   315         HBufC8* iContent;
   316         
   316 
   317         // Determines if the input is XML or WBXML
   317         // Determines if the input is XML or WBXML
   318         TParserType iParserType;
   318         TParserType iParserType;
   319         
   319 
   320         // Determines what kind of software constraint the RO contains
   320         // Determines what kind of software constraint the RO contains
   321         TSoftwareSchemaType iSoftwareSchemeType;
   321         TSoftwareSchemaType iSoftwareSchemeType;
   322 
   322 
   323         // In increments of +- 15 minutes
   323         // In increments of +- 15 minutes
   324         TInt iTimeZone;
   324         TInt iTimeZone;
   325 
   325 
   326         // Tagname of unkown tag
   326         // Tagname of unkown tag
   327         HBufC8* iUnknownTag;
   327         HBufC8* iUnknownTag;
   328     };
   328     };
   329 
   329 
   330 #endif      // DRMRIGHTSPARSER_H   
   330 #endif      // DRMRIGHTSPARSER_H
   331             
   331 
   332 // End of File
   332 // End of File