homescreenpluginsrv/hspsdefinitionengine/hspsdefinitionengine/inc/hspsxmlhandler.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2005,2006 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:  Main class for XML parsing
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_hspsXMLHANDLER_H
       
    21 #define C_hspsXMLHANDLER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <contenthandler.h>
       
    26 #include <parser.h>
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class RFs;
       
    30 class ChspsDomDocument;
       
    31 class ChspsDomNode;
       
    32 
       
    33 using namespace Xml; 
       
    34 /**
       
    35 *  Main class for XML parsing
       
    36 *   @ingroup group_hspsdefinitionengine
       
    37 *  @lib hspsdefinitionengine.lib
       
    38 *  @since Series 60 3.1
       
    39 */
       
    40 class ChspsXMLHandler : public CBase, public MContentHandler
       
    41     {
       
    42     public:  // Constructors and destructor
       
    43         
       
    44         /**
       
    45         * Two-phased constructor.
       
    46         */
       
    47         static ChspsXMLHandler* NewL();
       
    48         
       
    49         /**
       
    50         * Destructor.
       
    51         */
       
    52         virtual ~ChspsXMLHandler();
       
    53 
       
    54     public: // New functions
       
    55         
       
    56         /**
       
    57         * Parses the given XML file, creates nodes and attributes and inserting
       
    58         * them to aDomDocument
       
    59         * @since Series 60 3.1
       
    60         * @param aFsSession: session to use for accessing the files
       
    61         * @param aFileName: name of XML file
       
    62         * @param aDomDocument: reference to an empty DOM
       
    63         */
       
    64         void ParseXmlDocL( RFs& aFsSession, const TDesC& aFileName,ChspsDomDocument& aDomDocument);
       
    65 
       
    66     public: // Functions from MXMLContentHandler
       
    67 
       
    68         /**
       
    69         * This method is a callback to indicate the start of the document.
       
    70         * @since Series 60 3.1
       
    71         * @param	aDocParam Specifies the various parameters of the document.
       
    72         *     	aDocParam.iCharacterSetName The character encoding of the document.
       
    73         * @param	aErrorCode is the error code. 
       
    74         * 		If this is not KErrNone then special action may be required.
       
    75         */
       
    76         void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode);
       
    77 
       
    78 
       
    79         /**
       
    80         * This method is a callback to indicate the end of the document.
       
    81         * @since Series 60 3.1
       
    82         * @param  aErrorCode is the error code. 
       
    83         * 		If this is not KErrNone then special action may be required.
       
    84         */
       
    85         void OnEndDocumentL(TInt aErrorCode);
       
    86 
       
    87 
       
    88         /**
       
    89         * This method is a callback to indicate an element has been parsed.
       
    90         * @since Series 60 3.1
       
    91         * @param  aElement is a handle to the element's details.
       
    92         * @param	aAttributes contains the attributes for the element.
       
    93         * @param	aErrorCode is the error code.
       
    94         * 		If this is not KErrNone then special action may be required.
       
    95         */
       
    96 	    void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode);
       
    97 
       
    98 	
       
    99         /**
       
   100         * This method is a callback to indicate the end of the element has been reached.
       
   101         * @since Series 60 3.1
       
   102         * @param	aElement is a handle to the element's details.
       
   103         * @param	aErrorCode is the error code.
       
   104         * 		If this is not KErrNone then special action may be required.
       
   105         */
       
   106 	    void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode);
       
   107 
       
   108 
       
   109         /**
       
   110         * This method is a callback that sends the content of the element.
       
   111         * Not all the content may be returned in one go. The data may be sent in chunks.
       
   112         * When an OnEndElementL is received this means there is no more content to be sent.
       
   113         * @since Series 60 3.1
       
   114         * @param  aBytes is the raw content data for the element. 
       
   115         * 		The client is responsible for converting the data to the 
       
   116         * 		required character set if necessary.
       
   117         * 		In some instances the content may be binary and must not be converted.
       
   118         * @param	aErrorCode is the error code.
       
   119         * 		If this is not KErrNone then special action may be required.
       
   120         */
       
   121 	    void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
       
   122 
       
   123 	
       
   124         /**
       
   125         * This method is a notification of the beginning of the scope of a prefix-URI Namespace mapping.
       
   126         * This method is always called before the corresponding OnStartElementL method.
       
   127         * @since Series 60 3.1
       
   128         * @param  aPrefix is the Namespace prefix being declared.
       
   129         * @param	aUri is the Namespace URI the prefix is mapped to.
       
   130         * @param	aErrorCode is the error code.
       
   131         * 		If this is not KErrNone then special action may be required.
       
   132         */
       
   133 	    void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
       
   134 
       
   135 
       
   136         /**
       
   137         * This method is a notification of the end of the scope of a prefix-URI mapping.
       
   138         * This method is called after the corresponding DoEndElementL method.
       
   139         * @since Series 60 3.1
       
   140         * @param  aPrefix is the Namespace prefix that was mapped.
       
   141         * @param	aErrorCode is the error code.
       
   142         * 		If this is not KErrNone then special action may be required.
       
   143         */
       
   144 	    void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
       
   145 
       
   146 
       
   147         /**
       
   148         * This method is a notification of ignorable whitespace in element content.
       
   149         * @since Series 60 3.1
       
   150         * @param  aBytes are the ignored bytes from the document being parsed.
       
   151         * @param	aErrorCode is the error code.
       
   152         * 		If this is not KErrNone then special action may be required.
       
   153         */
       
   154 	    void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
       
   155 
       
   156 
       
   157         /**
       
   158         * This method is a notification of a skipped entity. If the parser encounters an 
       
   159         * external entity it does not need to expand it - it can return the entity as aName 
       
   160         * for the client to deal with.
       
   161         * @since Series 60 3.1
       
   162         * @param  aName is the name of the skipped entity.
       
   163         * @param	aErrorCode is the error code.
       
   164         * 		If this is not KErrNone then special action may be required.
       
   165         */
       
   166 	    void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
       
   167 
       
   168 
       
   169         /**
       
   170         * This method is a receive notification of a processing instruction.
       
   171         * @since Series 60 3.1
       
   172         * @param  aTarget is the processing instruction target.
       
   173         * @param	aData is the processing instruction data. If empty none was supplied.
       
   174         * @param	aErrorCode is the error code.
       
   175         * 		If this is not KErrNone then special action may be required.
       
   176         */
       
   177 	    void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData,TInt aErrorCode);
       
   178 
       
   179 
       
   180         /**
       
   181         * This method indicates an error has occurred.
       
   182         * @since Series 60 3.1
       
   183         * @param  aError is the error code
       
   184         */
       
   185 	    void OnError(TInt aErrorCode);
       
   186 
       
   187 
       
   188         /**
       
   189         * This method obtains the interface matching the specified uid.
       
   190         * @since Series 60 3.1
       
   191         * @param	aUid the uid identifying the required interface.
       
   192         * @return 0 if no interface matching the uid is found.
       
   193         * 		Otherwise, the this pointer cast to that interface.
       
   194         */
       
   195 	    TAny* GetExtendedInterface(const TInt32 aUid);
       
   196 
       
   197     private:
       
   198 
       
   199         /**
       
   200         * C++ default constructor.
       
   201         */
       
   202         ChspsXMLHandler();
       
   203 
       
   204         /**
       
   205         * By default Symbian 2nd phase constructor is private.
       
   206         */
       
   207         void ConstructL();
       
   208 
       
   209     private:    // Data
       
   210          
       
   211         // Pointer to Symbian parser, owned
       
   212         Xml::CParser*               iXmlParser;
       
   213  
       
   214         // Pointer to DOM, not owned
       
   215         ChspsDomDocument*             iDomDocument;
       
   216 
       
   217         // Pointer to the parent node
       
   218         ChspsDomNode*                 iParentNode;
       
   219         
       
   220         // Counter and ID at the same time
       
   221         TInt                        iCurrentNodeId;
       
   222  
       
   223         // Node stack with all the unfinished nodes
       
   224         RPointerArray<ChspsDomNode>*  iNodeStack;
       
   225         
       
   226         // Variable to store value got from OnError()
       
   227         TInt                        iError;
       
   228         
       
   229     };
       
   230 
       
   231 #endif      // C_hspsXMLHANDLER_H
       
   232             
       
   233 // End of File