mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsxmlparser.h
branchRCL_3
changeset 20 4a793f564d72
parent 19 0aa8cc770c8a
child 21 74aa6861c87d
equal deleted inserted replaced
19:0aa8cc770c8a 20:4a793f564d72
     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:  This class parses the dps xml script. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DPSXMLPARSER_H
       
    20 #define DPSXMLPARSER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <xml/wbxmlextensionhandler.h>
       
    24 #include <contenthandler.h>
       
    25 #include "dpsdefs.h"
       
    26 #include "dpsconst.h"
       
    27 
       
    28 using namespace Xml;
       
    29 
       
    30 class CDpsEngine;
       
    31 
       
    32 /**
       
    33 *   The interface acts as a hook between the xml framework and the detailed 
       
    34 *   implementation
       
    35 */
       
    36 class MDpsExtensionHandler
       
    37     {
       
    38     public:
       
    39         enum 
       
    40         {
       
    41         // dps engine dll uid 
       
    42         EInterfaceUid = 0x10274798
       
    43         };
       
    44     };
       
    45 
       
    46 /**
       
    47 *   The parser for dps script
       
    48 */
       
    49 NONSHARABLE_CLASS(CDpsXmlParser) : public CBase, public MContentHandler, 
       
    50                                    public MDpsExtensionHandler
       
    51     {
       
    52     public:
       
    53         /**
       
    54         *   Two phase constructor
       
    55         *   @param aEngine the dps engine pointer
       
    56         *   @return a CDpsXmlParaser instance
       
    57         */
       
    58         static CDpsXmlParser* NewL(CDpsEngine* aEngine);
       
    59     	
       
    60         /**
       
    61         *   Destructor
       
    62         */
       
    63         ~CDpsXmlParser();  
       
    64     	
       
    65         /**
       
    66         *   @return ETrue if the script is a dps notification, 
       
    67         *   otherwise EFalse
       
    68         */
       
    69         inline TBool IsEvent() const;
       
    70     	
       
    71         /**
       
    72         *   Gets the dps operation result from the parser and sets it to the 
       
    73         *   dps reply
       
    74         *   @param aResult the dps operatoin result
       
    75         */
       
    76         inline void SetOperationResult(TDpsResult& aResult) const;
       
    77     	
       
    78         /**
       
    79         *   Gets the dps operation enumeration of this script
       
    80         *   @return the dps operation enumeration
       
    81         */
       
    82         inline TDpsOperation Operation() const;
       
    83     	    
       
    84         /**
       
    85         *   Sets the dps operation arguments
       
    86         *   @param aParams the arguments to be set
       
    87         */
       
    88         inline void SetParameters(TDpsArgArray& aParams);
       
    89     	
       
    90         /**
       
    91         *   Gets the dps event of this script
       
    92         *   @return the dps event enumeration
       
    93         */
       
    94         inline TDpsEvent Event() const;
       
    95     	    
       
    96         /**
       
    97         *   Gets the dps attribute
       
    98         *   @param aAttrib the attribute got
       
    99         */
       
   100         inline void GetAttribute(TDpsAttribute& aAttrib) const;
       
   101     	
       
   102         /**
       
   103         *   @return ETrue if this dps operation has attribue, othewise EFalse
       
   104         */
       
   105         inline TBool HasAttribute() const;
       
   106     	
       
   107         /**
       
   108         *   Gets the dps arguments
       
   109         *   @param aParams the arguments to be returned
       
   110         */
       
   111         inline void GetParameters(TDpsArgArray& aParams) const;
       
   112         
       
   113         /**
       
   114         *   Resets the member variables 
       
   115         */
       
   116         void Reset();
       
   117 		
       
   118     	    
       
   119     private:
       
   120     // From MContentHandler
       
   121         /**
       
   122         *   @see MContentHandler
       
   123         */
       
   124         void OnStartDocumentL(const RDocumentParameters& aDocParam, 
       
   125                               TInt aErrorCode);
       
   126 		
       
   127         /**
       
   128         *   @see MContentHandler
       
   129         */
       
   130         void OnEndDocumentL(TInt aErrorCode);
       
   131 		
       
   132         /**
       
   133         *   @see MContentHandler
       
   134         */
       
   135         void OnStartElementL(const RTagInfo& aElement, 
       
   136                              const RAttributeArray& aAttributes, 
       
   137                              TInt aErrCode);
       
   138 		
       
   139         /**
       
   140         *   @see MContentHandler
       
   141         */
       
   142         void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
       
   143 		
       
   144         /**
       
   145         *   @see MContentHandler
       
   146         */
       
   147         void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
       
   148 		
       
   149         /**
       
   150         *   @see MContentHandler
       
   151         */
       
   152         void OnStartPrefixMappingL(const RString& aPrefix, 
       
   153                                    const RString& aUri, 
       
   154                                    TInt aErrorCode);
       
   155 		
       
   156         /**
       
   157         *   @see MContentHandler
       
   158         */
       
   159         void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
       
   160 		
       
   161         /**
       
   162         *   @see MContentHandler
       
   163         */
       
   164         void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
       
   165 		
       
   166         /**
       
   167         *   @see MContentHandler
       
   168         */
       
   169         void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
       
   170 		
       
   171         /**
       
   172         *   @see MContentHandler
       
   173         */
       
   174         void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, 
       
   175                                       TInt aErrorCode);
       
   176 		
       
   177         /**
       
   178         *   @see MContentHandler
       
   179         */
       
   180         void OnError(TInt aErrorCode);
       
   181 		
       
   182         /**
       
   183         *   @see MContentHandler
       
   184         */
       
   185         TAny* GetExtendedInterface(const TInt32 aUid); 
       
   186 		        				
       
   187     private:
       
   188         /**
       
   189         *   Default constructor
       
   190         *   @param aEngine a pointer to the dps engine
       
   191         */
       
   192         CDpsXmlParser(CDpsEngine* aEngine);
       
   193         
       
   194         /**
       
   195         *
       
   196         */
       
   197         void ParseAttributesL(const RAttributeArray& aAttributes, 
       
   198                               const TDesC8& aTag);
       
   199 
       
   200 		
       
   201     private:
       
   202         TDpsXmlAction iAction;
       
   203         TDpsAttribute iAttrib;
       
   204 		
       
   205         TDpsEvent iDpsEvent;
       
   206         TDpsOperation iDpsOperation;	
       
   207         TDpsResult iDpsResult;
       
   208         // only one
       
   209         TDpsElement iElement; 
       
   210         TDpsArgArray iDpsArgs;
       
   211         // not owned by this class
       
   212         CDpsEngine* iEngine;
       
   213     };
       
   214 #include "dpsxmlparser.inl"
       
   215 #endif