omadrm/drmengine/roap/inc/RoapParser.h
changeset 0 95b198f216e5
child 18 8a03a285ab14
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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:  ROAP parser base calss
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef ROAPPARSER_H
       
    21 #define ROAPPARSER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <Xml/Parser.h>
       
    25 #include <Xml/ContentHandler.h>
       
    26 #include <Xml/XmlParserErrors.h>
       
    27 #include "RoapMessage.h"
       
    28 
       
    29 using namespace Xml;
       
    30 
       
    31 namespace Roap
       
    32 {
       
    33 
       
    34 // CONSTANTS
       
    35 
       
    36 // MACROS
       
    37 
       
    38 // DATA TYPES
       
    39 enum TRoapElementEnum
       
    40     {
       
    41     ECipherData,
       
    42     ECipherValue,
       
    43     ECertificate,
       
    44     ECertificateChain,
       
    45     EContentID,
       
    46     EDcfHash,
       
    47     EDeviceDetails,
       
    48     EDeviceID,
       
    49     EDigestValue,
       
    50     EDomainAlias,
       
    51     EDomainID,
       
    52     EDomainInfo,
       
    53     EDomainKey,
       
    54     EDomainName,
       
    55     EEncKey,
       
    56     EEncryptionMethod,
       
    57     EExtension,
       
    58     EExtensions,
       
    59     EHash,
       
    60     EId,
       
    61     EIdentifier,
       
    62     EJoinDomain,
       
    63     EJoinDomainResponse,
       
    64     EKeyIdentifier,
       
    65     ELeaveDomain,
       
    66     ELeaveDomainResponse,
       
    67     EMac,
       
    68     EManufacturer,
       
    69     EModel,
       
    70     ENonce,
       
    71     ENotAfter,
       
    72     EOcspResponse,
       
    73     EProtectedRO,
       
    74     ERegistrationRequest,
       
    75     ERegistrationResponse,
       
    76     ERiAlias,
       
    77     ERights,
       
    78     ERiHello,
       
    79     ERiID,
       
    80     ERiNonce,
       
    81     ERiURL,
       
    82     ERo,
       
    83     ERoAcquisition,
       
    84     ERoapTrigger,
       
    85     ERoapURL,
       
    86     ERoID,
       
    87     ERoInfo,
       
    88     ERoResponse,
       
    89     ESelectedAlgorithm,
       
    90     ESelectedVersion,
       
    91     EServerInfo,
       
    92     ESignature,
       
    93     ESignatureValue,
       
    94     ESupportedAlgorithm,
       
    95     ETime,
       
    96     ETimeStamp,
       
    97     ETrustedAuthorities,
       
    98     EVersion,
       
    99     EX509SPKIHash,
       
   100 #ifdef RD_DRM_METERING
       
   101     EExtendedTriggerElement,
       
   102     EMeteringReportRequest,
       
   103     EMeteringReportResponse,
       
   104     EPrUrl,
       
   105 #endif
       
   106     ELast
       
   107     };
       
   108 
       
   109 enum TParserStackState
       
   110     {
       
   111     ERiHelloState,
       
   112     ESelectedVersionState,
       
   113     ERiIdState,
       
   114     ERiNonceState,
       
   115     EDeviceDetailsState,
       
   116     ECertificateState,
       
   117     EOcspResponseState,
       
   118     ERiUrlState,
       
   119     ESignatureState,
       
   120     ERegistrationResponseState,
       
   121     EPeerKeyIdentifierRIHelloState,
       
   122     ETransactionIdState,
       
   123     ETransactionIdContentIdState,
       
   124     EWhiteListState,
       
   125     EExtensionState,
       
   126     ERoResponseState,
       
   127     EDeviceIdState,
       
   128     ENonceState,
       
   129     ERiIdRoResponseState,
       
   130     ESignatureRoResponseState,
       
   131     EEncKeyState,
       
   132     ERiIdJoinDomainResponseState,
       
   133     EMacJoinDomainResponseState,
       
   134     EJoinDomainResponseState,
       
   135     ELeaveDomainResponseState,
       
   136     EDomainIdState,
       
   137     ENotAfterState,
       
   138     EDomainKeyState,
       
   139     EDomainKeyEncryptionMethodState,
       
   140     ERoapTriggerState,
       
   141     ERoapUrlState,
       
   142     ERegistrationRequestState,
       
   143     ERoAcquisitionState,
       
   144     EJoinDomainState,
       
   145     ELeaveDomainState,
       
   146     ERoIdState,
       
   147     EContentIdState,
       
   148     ESignatureValueState,
       
   149     EDigestValueState,
       
   150     EServerInfoState,
       
   151     ESupportedAlgorithmState,
       
   152     ESelectedAlgorithmState,
       
   153     ETrustedAuthoritiesState,
       
   154     EDomainKeyEncKeyState,
       
   155     EDomainAliasState,
       
   156     ERiAliasState,
       
   157 #ifdef RD_DRM_METERING
       
   158     EExtendedTriggerElementState,
       
   159     EMeteringReportRequestState,
       
   160     EMeteringReportResponseState,
       
   161     EDeviceNonceState,
       
   162     EMeteringReportNonceState,
       
   163     EPostResponseUrlState,
       
   164 #endif
       
   165     EUnknownState = -1,
       
   166     };
       
   167 
       
   168 // FORWARD DECLARATIONS
       
   169 
       
   170 class CDeviceHello;
       
   171 class CJoinDomainReq;
       
   172 class CJoinDomainResp;
       
   173 class CLeaveDomainReq;
       
   174 class CLeaveDomainResp;
       
   175 class CRIHello;
       
   176 class CRegistrationReq;
       
   177 class CRegistrationResp;
       
   178 class CRightsReq;
       
   179 class CRightsResp;
       
   180 class CRoapTrigger;
       
   181 class MRespParser;
       
   182 class CMeteringResp;
       
   183 
       
   184 // CLASS DECLARATION
       
   185 
       
   186 /**
       
   187 *  ROAP parser base class
       
   188 *
       
   189 *  @lib roaphandler.dll
       
   190 *  @since S60 v3.0
       
   191 */
       
   192 class CRoapParser : public CBase, public MContentHandler
       
   193     {
       
   194     public: // Constants
       
   195 
       
   196         static const TInt KMaxElementCount = ELast;
       
   197         static const TInt KMaxElementNesting = 32;
       
   198 
       
   199     public:  // Constructors and destructor
       
   200 
       
   201         /**
       
   202         * Two-phased constructor.
       
   203         */
       
   204         static CRoapParser* NewL();
       
   205 
       
   206         /**
       
   207         * Destructor.
       
   208         */
       
   209         virtual ~CRoapParser();
       
   210 
       
   211     public: // New functions
       
   212 
       
   213         /**
       
   214         * ?member_description.
       
   215         * @since Series ?XX ?SeriesXX_version
       
   216         * @param ?arg1 ?description
       
   217         * @return ?description
       
   218         */
       
   219         //?type ?member_function( ?type ?arg1 );
       
   220 
       
   221         CMeteringResp* ParseMeteringRespL(
       
   222             const TDesC8& aMessage );
       
   223         /**
       
   224         * ?member_description.
       
   225         * @since Series ?XX ?SeriesXX_version
       
   226         * @param ?arg1 ?description
       
   227         * @return ?description
       
   228         */
       
   229         CJoinDomainResp* ParseJoinDomainRespL(
       
   230             const TDesC8& aMessage,
       
   231             RPointerArray<HBufC8>& aDomainKeyElements);
       
   232 
       
   233         /**
       
   234         * ?member_description.
       
   235         * @since Series ?XX ?SeriesXX_version
       
   236         * @param ?arg1 ?description
       
   237         * @return ?description
       
   238         */
       
   239         CLeaveDomainResp* ParseLeaveDomainRespL(
       
   240             const TDesC8& aMessage);
       
   241 
       
   242         /**
       
   243         * ?member_description.
       
   244         * @since Series ?XX ?SeriesXX_version
       
   245         * @param ?arg1 ?description
       
   246         * @return ?description
       
   247         */
       
   248         CRegistrationResp* ParseRegistrationRespL(
       
   249             const TDesC8& aMessage);
       
   250 
       
   251         /**
       
   252         * ?member_description.
       
   253         * @since Series ?XX ?SeriesXX_version
       
   254         * @param ?arg1 ?description
       
   255         * @return ?description
       
   256         */
       
   257         CRightsResp* ParseRightsRespL(
       
   258             const TDesC8& aMessage);
       
   259 
       
   260         /**
       
   261         * ?member_description.
       
   262         * @since Series ?XX ?SeriesXX_version
       
   263         * @param ?arg1 ?description
       
   264         * @return ?description
       
   265         */
       
   266         CRIHello* ParseRIHelloL(
       
   267             const TDesC8& aMessage);
       
   268 
       
   269         /**
       
   270         * ?member_description.
       
   271         * @since Series ?XX ?SeriesXX_version
       
   272         * @param ?arg1 ?description
       
   273         * @return ?description
       
   274         */
       
   275         CRoapTrigger* ParseRoapTriggerL(
       
   276             const TDesC8& aMessage);
       
   277 
       
   278     public: // Functions from base classes
       
   279 
       
   280         /**
       
   281         * From ?base_class ?member_description.
       
   282         * @param aDocParam Specifies the various parameters of the document.
       
   283         * @arg   aDocParam.iCharacterSetName The character encoding of the document.
       
   284         * @param aErrorCode is the error code.
       
   285         *        If this is not KErrNone then special action may be required.
       
   286         */
       
   287         void OnStartDocumentL(
       
   288             const RDocumentParameters& aDocParam,
       
   289             TInt aErrorCode);
       
   290 
       
   291         /**
       
   292         * From ?base_class ?member_description.
       
   293         * @param aErrorCode is the error code.
       
   294         *        If this is not KErrNone then special action may be required.
       
   295         */
       
   296         void OnEndDocumentL(
       
   297             TInt aErrorCode);
       
   298 
       
   299         /**
       
   300         * From ?base_class ?member_description.
       
   301         * @param aElement is a handle to the element's details.
       
   302         * @param aAttributes contains the attributes for the element.
       
   303         * @param aErrorCode is the error code.
       
   304         *        If this is not KErrNone then special action may be required.
       
   305         */
       
   306         void OnStartElementL(
       
   307             const RTagInfo& aElement,
       
   308             const RAttributeArray& aAttributes,
       
   309             TInt aErrorCode);
       
   310 
       
   311         /**
       
   312         * From ?base_class ?member_description.
       
   313         * @param aElement is a handle to the element's details.
       
   314         * @param aErrorCode is the error code.
       
   315         *        If this is not KErrNone then special action may be required.
       
   316         */
       
   317         void OnEndElementL(
       
   318             const RTagInfo& aElement,
       
   319             TInt aErrorCode);
       
   320 
       
   321         /**
       
   322         * From ?base_class ?member_description.
       
   323         * @param aBytes is the raw content data for the element.
       
   324         *        The client is responsible for converting the data to the
       
   325         *        required character set if necessary.
       
   326         *        In some instances the content may be binary and must not be converted.
       
   327         * @param aErrorCode is the error code.
       
   328         *        If this is not KErrNone then special action may be required.
       
   329         */
       
   330         void OnContentL(
       
   331             const TDesC8& aBytes,
       
   332             TInt aErrorCode);
       
   333 
       
   334         /**
       
   335         * From ?base_class ?member_description.
       
   336         * @param aPrefix is the Namespace prefix being declared.
       
   337         * @param aUri is the Namespace URI the prefix is mapped to.
       
   338         * @param aErrorCode is the error code.
       
   339         *        If this is not KErrNone then special action may be required.
       
   340         */
       
   341         void OnStartPrefixMappingL(
       
   342             const RString& aPrefix,
       
   343             const RString& aUri,
       
   344             TInt aErrorCode);
       
   345 
       
   346         /**
       
   347         * From ?base_class ?member_description.
       
   348         * @param aPrefix is the Namespace prefix that was mapped.
       
   349         * @param aErrorCode is the error code.
       
   350         *        If this is not KErrNone then special action may be required.
       
   351         */
       
   352         void OnEndPrefixMappingL(
       
   353             const RString& aPrefix,
       
   354             TInt aErrorCode);
       
   355 
       
   356         /**
       
   357         * From ?base_class ?member_description.
       
   358         * @param aBytes are the ignored bytes from the document being parsed.
       
   359         * @param aErrorCode is the error code.
       
   360         *        If this is not KErrNone then special action may be required.
       
   361         */
       
   362         void OnIgnorableWhiteSpaceL(
       
   363             const TDesC8& aBytes,
       
   364             TInt aErrorCode);
       
   365 
       
   366         /**
       
   367         * From ?base_class ?member_description.
       
   368         * @param aName is the name of the skipped entity.
       
   369         * @param aErrorCode is the error code.
       
   370         *        If this is not KErrNone then special action may be required.
       
   371         */
       
   372         void OnSkippedEntityL(
       
   373             const RString& aName,
       
   374             TInt aErrorCode);
       
   375 
       
   376         /**
       
   377         * From ?base_class ?member_description.
       
   378         * @param aTarget is the processing instruction target.
       
   379         * @param aData is the processing instruction data. If empty none was supplied.
       
   380         * @param aErrorCode is the error code.
       
   381         *        If this is not KErrNone then special action may be required.
       
   382         */
       
   383         void OnProcessingInstructionL(
       
   384             const TDesC8& aTarget,
       
   385             const TDesC8& aData,
       
   386             TInt aErrorCode);
       
   387 
       
   388         /**
       
   389         * From ?base_class ?member_description.
       
   390         */
       
   391         void OnOutOfData();
       
   392 
       
   393 
       
   394         /**
       
   395         * From ?base_class ?member_description.
       
   396         * @param aError is the error code
       
   397         */
       
   398         void OnError(
       
   399             TInt aErrorCode);
       
   400 
       
   401 
       
   402         /**
       
   403         * From ?base_class ?member_description.
       
   404         * @return
       
   405                 0 if no interface matching the uid is found.
       
   406                 Otherwise, the this pointer cast to that interface.
       
   407         * @param aUid the uid identifying the required interface.
       
   408         */
       
   409         TAny* GetExtendedInterface(
       
   410             const TInt32 aUid);
       
   411 
       
   412         /**
       
   413         * ?member_description.
       
   414         * @since Series ?XX ?SeriesXX_version
       
   415         * @param ?arg1 ?description
       
   416         * @return ?description
       
   417         */
       
   418         HBufC8* GetAttributeValueL(
       
   419             const RAttributeArray& aAttrList,
       
   420             const TDesC8& aAttrName);
       
   421 
       
   422         /**
       
   423         * ?member_description.
       
   424         * @since Series ?XX ?SeriesXX_version
       
   425         * @param ?arg1 ?description
       
   426         * @return ?description
       
   427         */
       
   428         TRoapStatus ConvertRoapStatus(
       
   429             const TDesC8& aStatus);
       
   430 
       
   431         /**
       
   432         * ?member_description.
       
   433         * @since Series ?XX ?SeriesXX_version
       
   434         * @param ?arg1 ?description
       
   435         * @return ?description
       
   436         */
       
   437         TPtrC8 ExtractElement(
       
   438             const TDesC8& aMessage,
       
   439             const TDesC8& aElement,
       
   440             TInt& aOffset ) const;
       
   441 
       
   442         /**
       
   443         * ?member_description.
       
   444         * @since Series ?XX ?SeriesXX_version
       
   445         * @param ?arg1 ?description
       
   446         * @return ?description
       
   447         */
       
   448         TInt ExtractDomainKeyElements(
       
   449             const TDesC8& aMessage,
       
   450             RPointerArray<HBufC8>& aDomainKeyElements) const;
       
   451 
       
   452 
       
   453     protected:  // New functions
       
   454 
       
   455         /**
       
   456         * ?member_description.
       
   457         * @since Series ?XX ?SeriesXX_version
       
   458         * @param ?arg1 ?description
       
   459         * @return ?description
       
   460         */
       
   461         //?type ?member_function( ?type ?arg1 );
       
   462 
       
   463         /**
       
   464         * ?member_description.
       
   465         * @since Series ?XX ?SeriesXX_version
       
   466         * @param ?arg1 ?description
       
   467         * @return ?description
       
   468         */
       
   469         TParserStackState MatchStackState(void);
       
   470 
       
   471         /**
       
   472         * ?member_description.
       
   473         * @since Series ?XX ?SeriesXX_version
       
   474         * @param ?arg1 ?description
       
   475         * @return ?description
       
   476         */
       
   477         void ParseL(
       
   478             const TDesC8& aMessage);
       
   479 
       
   480     protected:  // Functions from base classes
       
   481 
       
   482         /**
       
   483         * From ?base_class ?member_description
       
   484         */
       
   485         //?type ?member_function();
       
   486 
       
   487         /**
       
   488         * C++ default constructor.
       
   489         */
       
   490         CRoapParser();
       
   491 
       
   492         /**
       
   493         * Symbian 2nd phase constructor.
       
   494         */
       
   495         void ConstructL();
       
   496 
       
   497     private:
       
   498 
       
   499         // Prohibit copy constructor if not deriving from CBase.
       
   500         // CRoapParser( const CRoapParser& );
       
   501         // Prohibit assigment operator if not deriving from CBase.
       
   502         // CRoapParser& operator=( const CRoapParser& );
       
   503 
       
   504     public:     // Data
       
   505         // ?one_line_short_description_of_data
       
   506         //?data_declaration;
       
   507         CParser* iParser;
       
   508         RString iRoapElements[KMaxElementCount];
       
   509         TInt iElementStack[KMaxElementNesting];
       
   510         TInt iElementStackDepth;
       
   511         HBufC8* iContent;
       
   512         MRespParser* iResponseParser;
       
   513 
       
   514     protected:  // Data
       
   515         // ?one_line_short_description_of_data
       
   516 
       
   517     private:    // Data
       
   518         // ?one_line_short_description_of_data
       
   519         //?data_declaration;
       
   520 
       
   521         // Reserved pointer for future extension
       
   522         //TAny* iReserved;
       
   523 
       
   524     public:     // Friend classes
       
   525         //?friend_class_declaration;
       
   526     protected:  // Friend classes
       
   527         //?friend_class_declaration;
       
   528     private:    // Friend classes
       
   529         //?friend_class_declaration;
       
   530 
       
   531     };
       
   532 }
       
   533 
       
   534 #endif      // ROAPPARSER_H
       
   535 
       
   536 // End of File