|
1 /* |
|
2 * Copyright (c) 2005-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 : CSIPClientDataParser.h |
|
16 * Part of : SIP Client Resolver |
|
17 * Version : 1.0 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @internalComponent |
|
26 */ |
|
27 #ifndef CSIPCLIENTDATAPARSER_H |
|
28 #define CSIPCLIENTDATAPARSER_H |
|
29 |
|
30 // INCLUDES |
|
31 #include <e32base.h> |
|
32 #include <xml/parser.h> |
|
33 #include <xml/contenthandler.h> |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class CSIPClientData; |
|
37 |
|
38 // ENUMERATIONS |
|
39 /// Internal states for CSIPClientDataParser |
|
40 enum TParserState |
|
41 { |
|
42 EInit, |
|
43 ESIPClient, |
|
44 ESIPHeaders, |
|
45 EAccept, |
|
46 EAcceptContact, |
|
47 EAllowEvents, |
|
48 ESDPLines, |
|
49 ELine, |
|
50 ERtpmap, |
|
51 EMediaAttribute |
|
52 }; |
|
53 |
|
54 // CLASS DEFINITIONS |
|
55 |
|
56 // State class for XML parsing |
|
57 // current state, tag, enter, next state |
|
58 class TStateTransition |
|
59 { |
|
60 public: // Constructors |
|
61 |
|
62 TStateTransition(const RString& aTag, |
|
63 TParserState aState, |
|
64 TParserState aNextState, |
|
65 TBool aEnter=ETrue) |
|
66 : iTag(aTag), |
|
67 iState(aState), |
|
68 iNextState(aNextState), |
|
69 iEnter(aEnter) {} |
|
70 |
|
71 public: // Data |
|
72 |
|
73 RString iTag; |
|
74 TParserState iState; |
|
75 TParserState iNextState; |
|
76 TBool iEnter; |
|
77 }; |
|
78 |
|
79 /** |
|
80 * CSIPClientDataParser implements an XML parser for CSIPClientData. |
|
81 * The XML style is shown below. |
|
82 * |
|
83 * @code |
|
84 * <SIP_CLIENT ALLOW_STARTING="YES"> |
|
85 * <SIP_HEADERS> |
|
86 * <ACCEPT value="application/sdp"/> |
|
87 * <ACCEPT value=""/> |
|
88 * </SIP_HEADERS> |
|
89 * <SDP_LINES> |
|
90 * <LINE name="m" value="video 53000 RTP/AVP 32"> |
|
91 * <RTPMAP value="rtpmap:32 MPV/90000"/> |
|
92 * <MEDIA_ATTRIBUTE value="extension"/> |
|
93 * </LINE> |
|
94 * </SDP_LINES> |
|
95 * </SIP_CLIENT> |
|
96 * @endcode |
|
97 * |
|
98 */ |
|
99 NONSHARABLE_CLASS(CSIPClientDataParser) |
|
100 : public CBase, |
|
101 public Xml::MContentHandler |
|
102 { |
|
103 public: // Constructors and destructor |
|
104 |
|
105 /** |
|
106 * Static constructor. |
|
107 * |
|
108 * @return An initialized instance of this class. |
|
109 */ |
|
110 static CSIPClientDataParser* NewL(); |
|
111 |
|
112 /// Destructor. |
|
113 ~CSIPClientDataParser(); |
|
114 |
|
115 public: // New methods |
|
116 |
|
117 /** |
|
118 * Parse an XML document extracting information into |
|
119 * a CSIPClientData object. |
|
120 * |
|
121 * @param aClientData parsed data will be added to this object |
|
122 * The ownership is not transferred. |
|
123 * @param aXmlDocument |
|
124 */ |
|
125 void ParseL( CSIPClientData* aClientData, |
|
126 const TDesC8& aXmlDocument ); |
|
127 |
|
128 public: // From Xml::MContentHandler |
|
129 |
|
130 void OnStartDocumentL( const Xml::RDocumentParameters& /*aDocParam*/, |
|
131 TInt /*aErrorCode*/ ) {}; |
|
132 void OnEndDocumentL( TInt /*aErrorCode*/ ) {}; |
|
133 void OnStartElementL( const Xml::RTagInfo& aElement, |
|
134 const Xml::RAttributeArray& aAttributes, |
|
135 TInt aErrorCode ); |
|
136 void OnEndElementL( const Xml::RTagInfo& aElement, TInt aErrorCode ); |
|
137 void OnContentL( const TDesC8& /*aBytes*/, TInt /*aErrorCode*/ ) {}; |
|
138 void OnStartPrefixMappingL( const RString& /*aPrefix*/, |
|
139 const RString& /*aUri*/, |
|
140 TInt /*aErrorCode*/ ) {}; |
|
141 void OnEndPrefixMappingL( const RString& /*aPrefix*/, |
|
142 TInt /*aErrorCode*/ ) {}; |
|
143 void OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/, |
|
144 TInt /*aErrorCode*/ ) {}; |
|
145 void OnSkippedEntityL( const RString& /*aName*/, |
|
146 TInt /*aErrorCode*/ ) {}; |
|
147 void OnProcessingInstructionL( const TDesC8& /*aTarget*/, |
|
148 const TDesC8& /*aData*/, |
|
149 TInt /*aErrorCode*/ ) {}; |
|
150 void OnError( TInt /*aErrorCode*/ ) {}; |
|
151 TAny* GetExtendedInterface( const TInt32 /*aUid*/ ) { return NULL; }; |
|
152 |
|
153 private: // New methods |
|
154 |
|
155 void ChangeStateL( const RString& aElementName, TBool aEnter ); |
|
156 void HandleSIPClientL( const Xml::RAttributeArray& aAttributes ); |
|
157 void HandleSIPHeaderL( RStringF aHeaderName, |
|
158 const Xml::RAttributeArray& aAttributes ); |
|
159 void HandleSdpLineL( const Xml::RAttributeArray& aAttributes ); |
|
160 void HandleRtpmapL( const Xml::RAttributeArray& aAttributes ); |
|
161 void HandleMediaAttributeL( const Xml::RAttributeArray& aAttributes ); |
|
162 HBufC8* CreateSdpFieldBufLC( const TDesC8& aFieldStart, |
|
163 const TDesC8& aValue ); |
|
164 |
|
165 private: // Constructors |
|
166 |
|
167 /// Default constructor |
|
168 inline CSIPClientDataParser(); |
|
169 |
|
170 /// 2nd phase constructor. |
|
171 inline void ConstructL(); |
|
172 |
|
173 private: // private data |
|
174 |
|
175 /// XML Parser object. Owned. |
|
176 Xml::CParser* iParser; |
|
177 |
|
178 /// Temporary pointer to Client data object. Not owned. |
|
179 CSIPClientData* iClientData; |
|
180 |
|
181 /// ETrue when SIP header lookup has been opened |
|
182 TBool iSIPHeaderLookupOpened; |
|
183 |
|
184 /// RString constants used in XML |
|
185 RString iTagSIPClient; |
|
186 RString iTagSIPHeaders; |
|
187 RString iTagSDPLines; |
|
188 RString iTagLine; |
|
189 RString iTagLineM; |
|
190 RString iTagRtpmap; |
|
191 RString iTagMediaAttribute; |
|
192 RString iTagAccept; |
|
193 RString iTagAllowStarting; |
|
194 RString iTagAcceptContact; |
|
195 RString iTagAllowEvents; |
|
196 RString iTagYes; |
|
197 |
|
198 /// An array of parser states |
|
199 RArray<TStateTransition> iStateTransitions; |
|
200 |
|
201 /// Parsing state, for XML validation. |
|
202 TParserState iState; |
|
203 }; |
|
204 |
|
205 #endif // CSIPCLIENTDATAPARSER_H |
|
206 |