omadrm/drmengine/ro/inc/DRMProtectedRoParser.h
changeset 0 95b198f216e5
child 18 8a03a285ab14
child 19 7c1aa284cf3b
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef DRMPROTECTEDROPARSER_H
       
    21 #define DRMPROTECTEDROPARSER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32std.h>
       
    25 #include <Xml/Parser.h>
       
    26 #include <Xml/ContentHandler.h>
       
    27 #include <Xml/XmlParserErrors.h>
       
    28 #include <Xml/Attribute.h>
       
    29 #include "DrmRightsClient.h"
       
    30 
       
    31 using namespace Xml;
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class CDRMRights;
       
    35 
       
    36 // CLASS DECLARATION
       
    37 
       
    38 /**
       
    39 *  Parser for protected rights objects
       
    40 *
       
    41 *  @lib DrmParsers.dll
       
    42 *  @since Series 60 3.0
       
    43 */
       
    44 NONSHARABLE_CLASS(CDrmProtectedRoParser): public CBase, public MContentHandler
       
    45     {
       
    46     public:
       
    47 
       
    48         class CParsedProtectedRo;
       
    49 
       
    50         enum TParserType
       
    51             {
       
    52             EXmlParser,
       
    53             EWbxmlParser
       
    54             };
       
    55             
       
    56         static const TInt KMaxElementCount = 40;
       
    57         static const TInt KMaxElementNesting = 16;
       
    58         
       
    59     public:  // Constructors and destructor
       
    60         
       
    61         /**
       
    62         * Two-phased constructor.
       
    63         */
       
    64         IMPORT_C static CDrmProtectedRoParser* NewL();
       
    65         
       
    66         /**
       
    67         * Destructor.
       
    68         */
       
    69         IMPORT_C ~CDrmProtectedRoParser();
       
    70 
       
    71     public: // New functions
       
    72         
       
    73         /**
       
    74         * ?member_description.
       
    75         * @since Series ?XX ?SeriesXX_version
       
    76         * @param ?arg1 ?description
       
    77         * @return ?description
       
    78         */
       
    79         void ParseL(
       
    80             const TDesC8& aProtectedRo,
       
    81             CParsedProtectedRo*& aResultRights);
       
    82 
       
    83         IMPORT_C void ParseAndStoreL(
       
    84             const TDesC8& aProtectedRo,
       
    85             RPointerArray<CDRMRights>& aResultRights);
       
    86             
       
    87         IMPORT_C HBufC8* GetRiUrlL(
       
    88             const TDesC8& aProtectedRo);
       
    89 
       
    90         IMPORT_C HBufC8* GetDomainIdL(
       
    91             const TDesC8& aProtectedRo);
       
    92 
       
    93         IMPORT_C HBufC8* GetRiIdL(
       
    94             const TDesC8& aProtectedRo);
       
    95 
       
    96     public: // Functions from base classes
       
    97 
       
    98         /**
       
    99         * From ?base_class ?member_description.
       
   100         * @param aDocParam Specifies the various parameters of the document.
       
   101         * @arg   aDocParam.iCharacterSetName The character encoding of the document.
       
   102         * @param aErrorCode is the error code. 
       
   103         *        If this is not KErrNone then special action may be required.
       
   104         */
       
   105         void OnStartDocumentL(
       
   106             const RDocumentParameters& aDocParam,
       
   107             TInt aErrorCode);
       
   108 
       
   109         /**
       
   110         * From ?base_class ?member_description.
       
   111         * @param aErrorCode is the error code. 
       
   112         *        If this is not KErrNone then special action may be required.
       
   113         */
       
   114         void OnEndDocumentL(
       
   115             TInt aErrorCode);
       
   116 
       
   117         /**
       
   118         * From ?base_class ?member_description.
       
   119         * @param aElement is a handle to the element's details.
       
   120         * @param aAttributes contains the attributes for the element.
       
   121         * @param aErrorCode is the error code.
       
   122         *        If this is not KErrNone then special action may be required.
       
   123         */
       
   124         void OnStartElementL(
       
   125             const RTagInfo& aElement,
       
   126             const RAttributeArray& aAttributes, 
       
   127 			TInt aErrorCode);
       
   128 
       
   129         /**
       
   130         * From ?base_class ?member_description.
       
   131         * @param aElement is a handle to the element's details.
       
   132         * @param aErrorCode is the error code.
       
   133         *        If this is not KErrNone then special action may be required.
       
   134         */
       
   135         void OnEndElementL(
       
   136             const RTagInfo& aElement,
       
   137             TInt aErrorCode);
       
   138 
       
   139         /**
       
   140         * From ?base_class ?member_description.
       
   141         * @param aBytes is the raw content data for the element. 
       
   142         *        The client is responsible for converting the data to the 
       
   143         *        required character set if necessary.
       
   144         *        In some instances the content may be binary and must not be converted.
       
   145         * @param aErrorCode is the error code.
       
   146         *        If this is not KErrNone then special action may be required.
       
   147         */
       
   148         void OnContentL(
       
   149             const TDesC8& aBytes,
       
   150             TInt aErrorCode);
       
   151 
       
   152         /**
       
   153         * From ?base_class ?member_description.
       
   154         * @param aPrefix is the Namespace prefix being declared.
       
   155         * @param aUri is the Namespace URI the prefix is mapped to.
       
   156         * @param aErrorCode is the error code.
       
   157         *        If this is not KErrNone then special action may be required.
       
   158         */
       
   159         void OnStartPrefixMappingL(
       
   160             const RString& aPrefix,
       
   161             const RString& aUri, 
       
   162 			TInt aErrorCode);
       
   163 
       
   164         /**
       
   165         * From ?base_class ?member_description.
       
   166         * @param aPrefix is the Namespace prefix that was mapped.
       
   167         * @param aErrorCode is the error code.
       
   168         *        If this is not KErrNone then special action may be required.
       
   169         */
       
   170         void OnEndPrefixMappingL(
       
   171             const RString& aPrefix,
       
   172             TInt aErrorCode);
       
   173 
       
   174         /**
       
   175         * From ?base_class ?member_description.
       
   176         * @param aBytes are the ignored bytes from the document being parsed.
       
   177         * @param aErrorCode is the error code.
       
   178         *        If this is not KErrNone then special action may be required.
       
   179         */
       
   180         void OnIgnorableWhiteSpaceL(
       
   181             const TDesC8& aBytes,
       
   182             TInt aErrorCode);
       
   183 
       
   184         /**
       
   185         * From ?base_class ?member_description.
       
   186         * @param aName is the name of the skipped entity.
       
   187         * @param aErrorCode is the error code.
       
   188         *        If this is not KErrNone then special action may be required.
       
   189         */
       
   190         void OnSkippedEntityL(
       
   191             const RString& aName,
       
   192             TInt aErrorCode);
       
   193 
       
   194         /**
       
   195         * From ?base_class ?member_description.
       
   196         * @param aTarget is the processing instruction target.
       
   197         * @param aData is the processing instruction data. If empty none was supplied.
       
   198         * @param aErrorCode is the error code.
       
   199         *        If this is not KErrNone then special action may be required.
       
   200         */
       
   201         void OnProcessingInstructionL(
       
   202             const TDesC8& aTarget,
       
   203             const TDesC8& aData, 
       
   204 			TInt aErrorCode);
       
   205 
       
   206         /**
       
   207         * From ?base_class ?member_description.
       
   208         */
       
   209         void OnOutOfData();
       
   210 
       
   211 
       
   212         /**
       
   213         * From ?base_class ?member_description.
       
   214         * @param aError is the error code
       
   215         */
       
   216         void OnError(
       
   217             TInt aErrorCode);
       
   218 
       
   219         /**
       
   220         * From ?base_class ?member_description.
       
   221         * @return				0 if no interface matching the uid is found.
       
   222                 Otherwise, the this pointer cast to that interface.
       
   223         * @param aUid the uid identifying the required interface.
       
   224         */
       
   225         TAny* GetExtendedInterface(
       
   226             const TInt32 aUid);
       
   227 
       
   228     protected:  // New functions
       
   229         
       
   230         /**
       
   231         * ?member_description.
       
   232         * @since Series ?XX ?SeriesXX_version
       
   233         * @param ?arg1 ?description
       
   234         * @return ?description
       
   235         */
       
   236         TInt MatchStackState(void);
       
   237 
       
   238         /**
       
   239         * ?member_description.
       
   240         * @since Series ?XX ?SeriesXX_version
       
   241         * @param ?arg1 ?description
       
   242         * @return ?description
       
   243         */
       
   244         HBufC8* GetAttributeValueL(
       
   245             const RAttributeArray& aAttrList,
       
   246             const TDesC8& aAttrName);
       
   247 
       
   248         /**
       
   249         * Find the next start and end position of an XML element
       
   250         * in the given data
       
   251         * @since Series 60 3.0
       
   252         * @param aElement Element to look for
       
   253         * @param aData Input data
       
   254         * @param aStart return parameter for the beginning of the element
       
   255         * @param aEnd return parameter for the end of the element
       
   256         * @return EFalse if no element could be found, ETrue otherwise
       
   257         */
       
   258         TBool GetElementStartEnd(
       
   259             const TDesC8& aElement,
       
   260             const TDesC8& aData,
       
   261             TInt& aStart,
       
   262             TInt& aEnd);
       
   263             
       
   264         /**
       
   265         * Handle a parsed domain RO which could not be added to the rights DB
       
   266         * because the device is not part of the domain.
       
   267         * @since Series 60 3.0
       
   268         * @param aDomainRoData domain RO as XML data
       
   269         * @param aDomainRo parsed domain RO
       
   270         */
       
   271         void HandleUnregisteredDomainRoL(
       
   272             const TDesC8& aContentId,
       
   273             const TDesC8& aDomainRoData,
       
   274             CParsedProtectedRo* aDomainRo);
       
   275             
       
   276         /**
       
   277         * Adds ROAP namespace URI to aProtectedRo if not already present
       
   278         * @since Series 60 3.0
       
   279         * @param aProtectedRo protected RO element
       
   280         * @return protected RO element, if namespace was not added NULL
       
   281         */    
       
   282         HBufC8* CDrmProtectedRoParser::AddRoapNamespaceL(
       
   283             TDesC8& aProtectedRo ) const;
       
   284 
       
   285     private:
       
   286 
       
   287         /**
       
   288         * C++ default constructor.
       
   289         */
       
   290         CDrmProtectedRoParser(void);
       
   291 
       
   292         void ConstructL(void);
       
   293 
       
   294     private:  // Data
       
   295         // The XML parser
       
   296         CParser* iParser;
       
   297         
       
   298         // Result of parsing the protected RO element
       
   299         CParsedProtectedRo* iRights;
       
   300         
       
   301         // Expected element names
       
   302         RString iElements[KMaxElementCount];
       
   303         
       
   304         // Parsing stack
       
   305         TInt iElementStack[KMaxElementNesting];
       
   306         
       
   307         // Depth of the parsing stack
       
   308         TInt iElementStackDepth;
       
   309         
       
   310         // Content between elements
       
   311         HBufC8* iContent;
       
   312 
       
   313     };
       
   314 
       
   315 #endif      // DRMPROTECTEDROPARSER_H   
       
   316             
       
   317 // End of File