realtimenetprots/sipfw/ProfileAgent/IMS_Agent/Inc/CSIPNotifyXmlBodyParser.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2004-2009 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:
       
    15 * Name          : CSIPNotifyXmlBodyParser.h
       
    16 * Part of       : ProfileAgent
       
    17 * Version       : SIP/4.0
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 #ifndef __CSIPNOTIFYXMLBODYPARSER_H__
       
    29 #define __CSIPNOTIFYXMLBODYPARSER_H__
       
    30 
       
    31 // INCLUDES
       
    32 #include <e32base.h>
       
    33 #include <xml/parser.h>
       
    34 #include <xml/contenthandler.h>
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class CSIPRegInfoElement;
       
    38 class CSIPRegistrationElement;
       
    39 class CSIPContactElement;
       
    40 
       
    41 // ENUMERATIONS
       
    42 /// Internal states for CSIPNotifyXmlBodyParser
       
    43 enum TNotifyParserState
       
    44 	{
       
    45 	EParsingUnknown,
       
    46 	EInit,
       
    47 	EParsingXmlDocument,
       
    48 	EParsingRegInfo,
       
    49 	EParsingRegistration,
       
    50 	EParsingContact,
       
    51 	EParsingUri
       
    52 	};
       
    53 
       
    54 // CLASS DEFINITIONS
       
    55 /**
       
    56  * CSIPNotifyXmlBodyParser implements an XML parser for CSIPClientData.
       
    57  * The XML DTD style is shown below.
       
    58  *
       
    59  * @code
       
    60  * <?xml version="1.0" encoding="UTF-8"?>
       
    61  *  <reginfo xmlns="urn:ietf:params:xml:ns:reginfo" version="1" state="full">
       
    62  *   <registration aor="sip:user1_public1@home1.net" id="a7" state="active">
       
    63  *    <contact id="76" state="active" event="registered">
       
    64  *     <uri>sip:[5555::aaa:bbb:ccc:ddd]</uri>
       
    65  *    </contact>
       
    66  *   </registration>
       
    67  *   <registration aor="sip:user1_public2@home1.net" id="a8" state="active">
       
    68  *    <contact id="77" state="active" event="created">
       
    69  *     <uri>sip:[5555::aaa:bbb:ccc:ddd]</uri>
       
    70  *    </contact>
       
    71  *   </registration>
       
    72  *   <registration aor="tel:+358504821437" id="a9" state="active">
       
    73  *    <contact id="78" state="active" event="created">
       
    74  *     <uri>sip:[5555::aaa:bbb:ccc:ddd]</uri>
       
    75  *    </contact>
       
    76  *   </registration>
       
    77  * </reginfo>
       
    78  * @endcode
       
    79  *
       
    80  */
       
    81 class CSIPNotifyXmlBodyParser
       
    82 	: public CBase,
       
    83 	  public Xml::MContentHandler
       
    84 	{
       
    85 	public: // Constructors and destructor
       
    86 
       
    87 		/**
       
    88 		 * Static constructor.
       
    89 		 *
       
    90 		 * @return An initialized instance of this class.
       
    91 		 */
       
    92 		static CSIPNotifyXmlBodyParser* NewL();
       
    93 
       
    94 		/// Destructor.
       
    95 		~CSIPNotifyXmlBodyParser();
       
    96 
       
    97 	public: // New methods
       
    98 
       
    99 		/**
       
   100 		 * Gets a reference to the string pool used.
       
   101 		 *
       
   102 		 * @return a reference to string pool.
       
   103 		 */
       
   104         RStringPool& StringPool();
       
   105 
       
   106 		/**
       
   107 		 * Parse an XML document extracting information into
       
   108 		 * a CSIPClientData object.
       
   109 		 *
       
   110 		 * @param aClientData parsed data will be added to this object
       
   111 		 *        The ownership is not transferred.
       
   112 		 * @param aXmlDocument
       
   113 		 */
       
   114 		void ParseL( CSIPRegInfoElement* aNotifyData,
       
   115 			         const TDesC8& aXmlDocument );
       
   116 
       
   117 	public: // From Xml::MContentHandler
       
   118 
       
   119 		void OnStartDocumentL( const Xml::RDocumentParameters& aDocParam,
       
   120 							   TInt aErrorCode );
       
   121 		void OnEndDocumentL( TInt /*aErrorCode*/ ) {};
       
   122 		void OnStartElementL( const Xml::RTagInfo& aElement,
       
   123 							  const Xml::RAttributeArray& aAttributes,
       
   124 							  TInt aErrorCode );
       
   125 		void OnEndElementL( const Xml::RTagInfo& aElement, TInt aErrorCode );
       
   126 		void OnContentL( const TDesC8& aBytes, TInt aErrorCode );
       
   127 		void OnStartPrefixMappingL( const RString& /*aPrefix*/,
       
   128 									const RString& /*aUri*/,
       
   129 									TInt /*aErrorCode*/ ) {};
       
   130 		void OnEndPrefixMappingL( const RString& /*aPrefix*/,
       
   131 								  TInt /*aErrorCode*/ ) {};
       
   132 		void OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/,
       
   133 									 TInt /*aErrorCode*/ ) {};
       
   134 		void OnSkippedEntityL( const RString& /*aName*/,
       
   135 							   TInt /*aErrorCode*/ ) {};
       
   136 		void OnProcessingInstructionL( const TDesC8& /*aTarget*/,
       
   137 									   const TDesC8& /*aData*/,
       
   138 									   TInt /*aErrorCode*/ ) {};
       
   139 		void OnError( TInt aErrorCode );
       
   140 		TAny* GetExtendedInterface( const TInt32 /*aUid*/ ) { return NULL; };
       
   141 
       
   142 	private: // New methods
       
   143 
       
   144 		void ChangeState( const RString& aElementName, TBool aEnter );
       
   145 		void HandleRegInfoL( const Xml::RTagInfo& aElement,
       
   146 							 const Xml::RAttributeArray& aAttributes );
       
   147 		void HandleRegistrationL( const Xml::RAttributeArray& aAttributes );
       
   148 		void HandleContactL( const Xml::RAttributeArray& aAttributes );
       
   149 		void HandleUriL( const TDesC8& aBytes );
       
   150 		TInt FindAttributeIndex( const TDesC8& aName,
       
   151 		                         const Xml::RAttributeArray& aAttributes) const;
       
   152 
       
   153 	private:  // Constructors
       
   154 
       
   155 		/// Default constructor
       
   156 		CSIPNotifyXmlBodyParser();
       
   157 
       
   158 		/// 2nd phase constructor.
       
   159 		void ConstructL();
       
   160 		
       
   161 		TUint ConvertToTUintL( const TDesC8& aValue );
       
   162 
       
   163 	private: // private data
       
   164 
       
   165 		/// XML Parser object. Owned.
       
   166 		Xml::CParser* iParser;
       
   167 
       
   168 		/// Temporary pointer to Client data object. Not owned.
       
   169 		CSIPRegInfoElement* iNotifyData;
       
   170 		CSIPRegistrationElement* iRegElement;
       
   171 		CSIPContactElement* iContact;
       
   172 		/// Parsing state, for XML validation.
       
   173 		TNotifyParserState iState;
       
   174         TNotifyParserState iPreviousState;
       
   175         TInt iDepthOfUnknownElements;
       
   176 	};
       
   177 
       
   178 #endif // __CSIPNOTIFYXMLBODYPARSER_H__
       
   179