|         |      1 /* | 
|         |      2 * Copyright (c) 2005 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: Extracts needed attributes from received EMN message. | 
|         |     15 *		 | 
|         |     16 * | 
|         |     17 */ | 
|         |     18  | 
|         |     19  | 
|         |     20  | 
|         |     21 #ifndef EMNXMLCONTENTHANDLER_H | 
|         |     22 #define EMNXMLCONTENTHANDLER_H | 
|         |     23  | 
|         |     24 #include <xml/contenthandler.h> | 
|         |     25 #include <xml/wbxmlextensionhandler.h> | 
|         |     26 #include <AlwaysOnlineManagerCommon.h> | 
|         |     27  | 
|         |     28 #include "EMNHandler.h" // For common EMN error codes | 
|         |     29  | 
|         |     30 using namespace Xml; | 
|         |     31  | 
|         |     32 /* | 
|         |     33 * This class extracts needed attributes from received EMN message, which can | 
|         |     34 * be either in XML or in WBXML form. | 
|         |     35 * | 
|         |     36 *  @since S60 v3.1 | 
|         |     37 */ | 
|         |     38 class CEMNXMLContentHandler :  | 
|         |     39     public CBase,  | 
|         |     40     public MWbxmlExtensionHandler,  | 
|         |     41     public Xml::MContentHandler | 
|         |     42 	{ | 
|         |     43  | 
|         |     44     public: | 
|         |     45         /** | 
|         |     46         * Creates object from CEMNXMLContentHandler | 
|         |     47         * @since S60 v3.1 | 
|         |     48         * @return, Constructed object | 
|         |     49         */ | 
|         |     50         static CEMNXMLContentHandler* NewL(  | 
|         |     51             TEMNElement& aElement, TBool aIsAscii ); | 
|         |     52              | 
|         |     53         /** | 
|         |     54         * Creates object from CEMNXMLContentHandler and leaves it to  | 
|         |     55         * cleanup stack | 
|         |     56         * @since S60 v3.1 | 
|         |     57         * @return, Constructed object | 
|         |     58         */ | 
|         |     59         static CEMNXMLContentHandler* NewLC(  | 
|         |     60             TEMNElement& aElement, TBool aIsAscii ); | 
|         |     61          | 
|         |     62         /** | 
|         |     63         * Destructor | 
|         |     64         * @since S60 v3.1 | 
|         |     65         */ | 
|         |     66         virtual ~CEMNXMLContentHandler(); | 
|         |     67          | 
|         |     68         /** | 
|         |     69         * Symbian 2-phase constructor | 
|         |     70         * @since S60 v3.1 | 
|         |     71         */ | 
|         |     72         void ConstructL(); | 
|         |     73      | 
|         |     74     public: // Following public functions are all from MContentHandler | 
|         |     75     	 | 
|         |     76     	void OnStartDocumentL( | 
|         |     77     	    const RDocumentParameters& aDocParam, TInt aErrorCode ); | 
|         |     78     	     | 
|         |     79     	void OnEndDocumentL( TInt aErrorCode ); | 
|         |     80     	 | 
|         |     81     	void OnStartElementL( | 
|         |     82     	    const RTagInfo& aElement,  | 
|         |     83     	    const RAttributeArray& aAttributes, | 
|         |     84     	    TInt aErrorCode ); | 
|         |     85     	     | 
|         |     86     	void OnEndElementL( const RTagInfo& aElement, TInt aErrorCode ); | 
|         |     87     	 | 
|         |     88     	void OnContentL( const TDesC8& aBytes, TInt aErrorCode ); | 
|         |     89     	 | 
|         |     90     	void OnStartPrefixMappingL(  | 
|         |     91     	    const RString& aPrefix,  | 
|         |     92     	    const RString& aUri,  | 
|         |     93     	    TInt aErrorCode ); | 
|         |     94     	     | 
|         |     95     	void OnEndPrefixMappingL( | 
|         |     96     	    const RString& aPrefix,  | 
|         |     97     	    TInt aErrorCode ); | 
|         |     98     	     | 
|         |     99     	void OnIgnorableWhiteSpaceL( | 
|         |    100     	    const TDesC8& aBytes,  | 
|         |    101     	    TInt aErrorCode ); | 
|         |    102     	     | 
|         |    103     	void OnSkippedEntityL( | 
|         |    104     	    const RString& aName,  | 
|         |    105     	    TInt aErrorCode ); | 
|         |    106     	     | 
|         |    107     	void OnProcessingInstructionL( | 
|         |    108     	    const TDesC8& aTarget,  | 
|         |    109     	    const TDesC8& aData,  | 
|         |    110     	    TInt aErrorCode ); | 
|         |    111     	     | 
|         |    112     	void OnError( TInt aErrorCode ); | 
|         |    113     	 | 
|         |    114     	TAny* GetExtendedInterface( const TInt32 aUid ); | 
|         |    115  | 
|         |    116     public: // From MWbxmlExtensionHandler | 
|         |    117 	     | 
|         |    118 	    void OnExtensionL(  | 
|         |    119 	        const RString& aData,  | 
|         |    120 	        TInt aToken,  | 
|         |    121 	        TInt aErrorCode ); | 
|         |    122 	     | 
|         |    123     private: | 
|         |    124         /** | 
|         |    125         * Default constructor for class CEMNXMLContentHandler | 
|         |    126         * @since S60 v3.1 | 
|         |    127         * @return, Constructed object | 
|         |    128         */ | 
|         |    129     	CEMNXMLContentHandler( TEMNElement& aElement, TBool aIsAscii ); | 
|         |    130     	 | 
|         |    131     	/** | 
|         |    132     	* Extracts given attribute from XML message. | 
|         |    133     	* @param aAttributeName8 name of the attribute (8-bit) | 
|         |    134     	* @param aAttributeValue8 value of the attribute (8-bit) | 
|         |    135     	* @since S60 v3.1 | 
|         |    136     	*/ | 
|         |    137     	void HandleXMLAttributesL(  | 
|         |    138     	    const TDesC8& aAttributeName8, const TDesC8& aAttributeValue8 ); | 
|         |    139  | 
|         |    140     	/** | 
|         |    141     	* Extracts given attribute from WBXML message. | 
|         |    142     	* @param aAttributeName8 name of the attribute (8-bit) | 
|         |    143     	* @param aAttributeValue8 value of the attribute (8-bit) | 
|         |    144     	* @since S60 v3.1 | 
|         |    145     	*/ | 
|         |    146     	void HandleWBXMLAttributesL(  | 
|         |    147     	    const TDesC8& aAttributeName8, const TDesC8& aAttributeValue8 ); | 
|         |    148  | 
|         |    149     private: | 
|         |    150         // Contains mailbox and timestamp | 
|         |    151         TEMNElement&    iElement; | 
|         |    152         // Is message XML or WBXML | 
|         |    153         TBool           iIsAscii; | 
|         |    154         // Mandatory attribute: mailbox | 
|         |    155         TBool           iFoundMailboxAttribute; | 
|         |    156     }; | 
|         |    157      | 
|         |    158 #endif  // EMNXMLCONTENTHANDLER_H |