codhandler/codeng/inc/DdParser.h
changeset 0 dd21522fd290
child 48 79859ed3eea9
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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: 
       
    15 *      Declaration of class TDdParser.   
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef DD_PARSER_H
       
    22 #define DD_PARSER_H
       
    23 
       
    24 // INCLUDES
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <nw_dom_document.h>
       
    28 
       
    29 // FORWARD DECLARATION
       
    30 
       
    31 class CMediaObjectData;
       
    32 class CCodData;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37 * DD Parser.
       
    38 */
       
    39 NONSHARABLE_CLASS( TDdParser )
       
    40     {
       
    41 
       
    42     public:     // constructor
       
    43 
       
    44         /**
       
    45         * Constructor.
       
    46         */
       
    47         inline TDdParser();
       
    48 
       
    49     public:     // new methods
       
    50 
       
    51         /**
       
    52         * Parse the buffer into aData. Existing data in aData is lost.
       
    53         * Leaves on failure; leave code can be KErrCodInvalidDescriptor as well
       
    54         * as general errors. The resulting data is not checked semantically
       
    55         * (i.e. mandatory attributes may be missing).
       
    56         * @param aBuf DD content buffer to be parsed.
       
    57         * @param aData DD will be parsed into this.
       
    58         * @param aIsDd2 equals to ETrue for the OMA 2 dd
       
    59         * @param aIsLicenseTag equals to ETrue if a license tag is presented (for OMA 2 dd)
       
    60         */
       
    61         void ParseL( const TDesC& aBuf, CCodData& aData, const TBool aIsDd2, TBool& aIsLicenseTag );
       
    62 
       
    63     private:    // types
       
    64 
       
    65         enum TDdAttr               ///< DD Attributes.
       
    66             {
       
    67             EDdName,               ///< DD-Name.
       
    68             EDdVendor,             ///< DD-Vendor.
       
    69             EDdDescription,        ///< DD-Description.
       
    70             EDdUrl,                ///< DD-URL.
       
    71             EDdSize,               ///< DD-Size.
       
    72             EDdType,               ///< DD-Type.
       
    73             EDdInstallNotify,      ///< DD-Install-Notify.
       
    74             EDdNextUrl,            ///< DD-Netx-URL.
       
    75             EDdInfoUrl,            ///< DD-Info-URL.
       
    76             EDdIcon,               ///< DD-Icon.
       
    77             EDdVersion,            ///< DD-Version.
       
    78             EDdProduct,            ///< DD-Product (OMA 2)
       
    79             EDdMediaObject,        ///< DD-MediaObject (OMA 2)
       
    80             EDdMeta,               ///< DD-Meta (OMA 2)
       
    81             EDdProgressiveDl,      ///< DD-progressiveDowloadFlag (OMA 2)
       
    82             EDdSuppressUserConfirmation,	///< DD-suppressUserConfirmation (OMA 2)
       
    83             EDdLicense,				///< DD-license (OMA 2)
       
    84             EDdOrder,				///< DD-order (OMA 2)
       
    85             EDdText,				///< DD-text (OMA 2)
       
    86             EDdUpdatedDDURI,
       
    87             EDdUnknownAttr         ///< Future DD attributes.
       
    88             };
       
    89 
       
    90     private:    // parsing
       
    91 
       
    92         /**
       
    93         * Parse document node (top level construct: 'media').
       
    94         * @param aDocNode Document node.
       
    95         */
       
    96         void DocNodeL( NW_DOM_DocumentNode_t* aDocNode );
       
    97 
       
    98         /**
       
    99          * Parse document node for OMA v2
       
   100          * @param aDocNode Document node.
       
   101          */
       
   102         void ParseDd2DocNodeL( NW_DOM_DocumentNode_t* aDocNode );
       
   103 
       
   104         /**
       
   105          * Process child element node (below 'media').
       
   106          * @param aElmtNode Element node.
       
   107          */
       
   108         void ElementNodeL( NW_DOM_ElementNode_t* aElmtNode, CMediaObjectData *& aMediaObject );
       
   109 
       
   110         /**
       
   111          * Parse Media elements for OMA v2
       
   112          * @param aElmtNode Document node.
       
   113          */
       
   114         void ParseMediaElementsL( NW_DOM_ElementNode_t* aElmtNode );
       
   115 
       
   116         /**
       
   117          * Parse Product elements for OMA v2
       
   118          * @param aElmtNode Document node.
       
   119          */
       
   120         void ParseProductElementsL( NW_DOM_ElementNode_t* aElmtNode );
       
   121 
       
   122         /**
       
   123          * Parse Media Object elements for OMA v2
       
   124          * @param aElmtNode Document node.
       
   125          */
       
   126         void ParseMediaObjectElementsL( NW_DOM_ElementNode_t* aElmtNode);
       
   127 
       
   128         /**
       
   129          * Parse Meta elements for OMA v2
       
   130          * @param aElmtNode Document node.
       
   131          */
       
   132         void ParseMetaElementsL( NW_DOM_ElementNode_t* aElmtNode );
       
   133 
       
   134         /**
       
   135          * Parse Meta elements for OMA v2
       
   136          * @param aElmtNode Document node.
       
   137          */
       
   138         void ParseMetaElementsL( NW_DOM_ElementNode_t* aElmtNode, CMediaObjectData *& aMediaObject );
       
   139 
       
   140         /**
       
   141          * Parse Object Uri elements for OMA v2
       
   142          * @param aElmtNode Document node.
       
   143          */
       
   144         void ParseObjectUriElementsL( NW_DOM_ElementNode_t* aElmtNode, CMediaObjectData *& aMediaObject );
       
   145 
       
   146         /**
       
   147          * Process child element node (below 'media') for OMA v2
       
   148          * @param aElmtNode Element node.
       
   149          */		
       
   150         void MediaElementNodeL( NW_DOM_ElementNode_t* aElmtNode);
       
   151 
       
   152         /**
       
   153          * Process child element node (below 'media Object') for OMA v2
       
   154          * @param aElmtNode Element node.
       
   155          */		
       
   156         void MediaObjElementNodeL( NW_DOM_ElementNode_t* aElmtNode, CMediaObjectData *& aMediaObject );
       
   157 
       
   158         /**
       
   159          * Process child element node (below 'meta') for OMA v2
       
   160          * @param aElmtNode Element node.
       
   161          */		
       
   162         void MetaElementNodeL( NW_DOM_ElementNode_t* aElmtNode);
       
   163 
       
   164         /**
       
   165          * Process child element node (below 'meta') for OMA v2
       
   166          * @param aElmtNode Element node.
       
   167          */		
       
   168         void MetaElementNodeL( NW_DOM_ElementNode_t* aElmtNode, CMediaObjectData *& aMediaObject );
       
   169 
       
   170         /**
       
   171          * Process child element node (below 'product') for OMA v2
       
   172          * @param aElmtNode Element node.
       
   173          */		
       
   174         void ProductElementNodeL( NW_DOM_ElementNode_t* aElmtNode);
       
   175 
       
   176         /**
       
   177          * Process child element node (below 'Object Uri') for OMA v2
       
   178          * @param aElmtNode Element node.
       
   179          */		
       
   180         void ObjUriElementNodeL( NW_DOM_ElementNode_t* aElmtNode, CMediaObjectData *& aMediaObject );
       
   181 		
       
   182         /**
       
   183         * Get 'Media' attribute value from attribute name for OMA v2
       
   184         * @param aAttrName Attribute name.
       
   185         * @return Attribute value.
       
   186         */
       
   187         TDdAttr MediaAttribute( const TDesC& aAttrName ) const;
       
   188 
       
   189         /**
       
   190         * Get 'Media Object' attribute value from attribute name for OMA v2
       
   191         * @param aAttrName Attribute name.
       
   192         * @return Attribute value.
       
   193         */
       
   194         TDdAttr MediaObjAttribute( const TDesC& aAttrName ) const;
       
   195 
       
   196         /**
       
   197         * Get 'Meta' attribute value from attribute name for OMA v2
       
   198         * @param aAttrName Attribute name.
       
   199         * @return Attribute value.
       
   200         */
       
   201         TDdAttr MetaAttribute( const TDesC& aAttrName ) const;
       
   202 
       
   203         /**
       
   204         * Get 'Product' attribute value from attribute name for OMA v2
       
   205         * @param aAttrName Attribute name.
       
   206         * @return Attribute value.
       
   207         */
       
   208         TDdAttr ProductAttribute( const TDesC& aAttrName ) const;
       
   209 
       
   210         /**
       
   211         * Get 'Object Uri' attribute value from attribute name for OMA v2
       
   212         * @param aAttrName Attribute name.
       
   213         * @return Attribute value.
       
   214         */
       
   215         TDdAttr ObjUriAttribute( const TDesC& aAttrName ) const;
       
   216 
       
   217         /**
       
   218         * Get 'DDVersion' attribute value from attribute name for OMA v2
       
   219         * @param aAttrName Attribute name.
       
   220         * @return Attribute value.
       
   221         */
       
   222         TDdAttr DdVersionAttribute( const TDesC& aAttrName ) const;
       
   223 
       
   224         /**
       
   225         * Set data for "media" attribute for OMA v2
       
   226         * @param aAttr Attribute.
       
   227         * @param aValue Value.
       
   228         */		
       
   229         void SetMediaAttrL( TDdAttr aAttr, const TDesC& aValue );
       
   230 
       
   231         /**
       
   232         * Set data for "meta" attribute for OMA v2
       
   233         * @param aAttr Attribute.
       
   234         * @param aValue Value.
       
   235         */
       
   236         void SetMetaAttrL( TDdAttr aAttr, const TDesC& aValue );
       
   237 
       
   238         /**
       
   239         * Set data for "meta" attribute for OMA v2
       
   240         * @param aAttr Attribute.
       
   241         * @param aValue Value.
       
   242         */
       
   243         void SetMetaAttrL( TDdAttr aAttr, const TDesC& aValue, CMediaObjectData *& aMediaObject );
       
   244 
       
   245         /**
       
   246         * Set data for "mediaObject" attribute.
       
   247         * @param aAttr Attribute.
       
   248         * @param aValue Value.
       
   249         */
       
   250         void SetMediaObjAttrL( TDdAttr aAttr, const TDesC& aValue, CMediaObjectData *& aMediaObject );
       
   251 				
       
   252         /**
       
   253         * Allocate and return PCDATA of element node.
       
   254         * @param aElmtNode Element node.
       
   255         * @return PCDATA or NULL. A cleanup item (or NULL) is pushed on the
       
   256         * cleanup stack.
       
   257         */
       
   258         NW_Ucs2* PcDataLC( NW_DOM_ElementNode_t* aElmtNode );
       
   259 
       
   260         /**
       
   261         * Get attribute value from attribute name.
       
   262         * @param aAttrName Attribute name.
       
   263         * @return Attribute value.
       
   264         */
       
   265         TDdAttr Attribute( const TDesC& aAttrName ) const;
       
   266 
       
   267         /**
       
   268         * Set data attribute.
       
   269         * @param aAttr Attribute.
       
   270         * @param aValue Value.
       
   271         */
       
   272         void SetAttrL( TDdAttr aAttr, const TDesC& aValue, CMediaObjectData *& aMediaObject );
       
   273 
       
   274         /**
       
   275          * Parse node attribute (for OMA v2) E.g. <media xmlns="urn:oma:xml:dl:dd:2.0" DDVersion="2.0"
       
   276 		 * where attr1 = xmlns; attr2 = DDVersion
       
   277          * @param aAttrHandle attribute handler
       
   278          */
       
   279         void ParseNodeAttributesL( NW_DOM_AttributeHandle_t* aAttrHandle );
       
   280         
       
   281         /**
       
   282         *Parse Name from URl in case Name Tag is not present In DD
       
   283         *in that case take it from URL
       
   284         */
       
   285         void ParseNameFromUrlL( CMediaObjectData *& aMediaObject );
       
   286 
       
   287         /**
       
   288         * Set error code if not already set.
       
   289         * @param aError Error.
       
   290         */
       
   291         inline void Error( TInt aError );
       
   292 
       
   293     private:    // data
       
   294 
       
   295         CCodData* iData;        ///< DD Data. Not owned.
       
   296         NW_Uint32 iEncoding;    ///< Document encoding.
       
   297         TInt iError;            ///< Error code.
       
   298         TBool iIsLicenseTag;    ///< ETrue if license tag exists in the DD2
       
   299     };
       
   300 
       
   301 #include "DdParser.inl"
       
   302 
       
   303 #endif /* def DD_PARSER_H */