|
1 /* |
|
2 * Copyright (c) 2003 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: Imps engine wbxml message decoder |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CImpsDecodeWbXml_H |
|
21 #define CImpsDecodeWbXml_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <cstack.h> |
|
26 #include "ImpsDataAccessorApi.h" |
|
27 #include "ImpsMessageInterpreterApi.h" |
|
28 #include "ImpsWbXmlData.h" |
|
29 #include "nw_encoder_domencoder.h" |
|
30 #include "nw_wbxml_reader.h" |
|
31 #include "ImpsXmlUtils.h" |
|
32 |
|
33 // CONSTANTS |
|
34 const TInt KMaxDictionaries = 2; |
|
35 |
|
36 // DATA TYPES |
|
37 |
|
38 // decoding state |
|
39 enum TImpsDecodeState |
|
40 { |
|
41 EImpsDecodeStateIdle, |
|
42 EImpsDecodeStateTagStart, |
|
43 EImpsDecodeStateTagEnd, |
|
44 EImpsDecodeStateAttributeStart, |
|
45 EImpsDecodeStateAttributeValue, |
|
46 EImpsDecodeStateContent, |
|
47 EImpsDecodeStateExtension, |
|
48 EImpsDecodeStateExtensionValue, |
|
49 EImpsDecodeStateLiteral, |
|
50 EImpsDecodeIllegal |
|
51 }; |
|
52 |
|
53 // FORWARD DECLARATIONS |
|
54 class CImpsKey; |
|
55 class MImpsCSPSession; |
|
56 |
|
57 // CLASS DECLARATION |
|
58 |
|
59 class CImpsDecodeWbXml :public CBase, public MImpsDecoder |
|
60 { |
|
61 public: // Constructors and destructor |
|
62 |
|
63 /** |
|
64 * Two-phased constructor. |
|
65 */ |
|
66 static CImpsDecodeWbXml* NewL( MImpsCSPSession* aCallback ); |
|
67 |
|
68 public: // New functions |
|
69 |
|
70 /** |
|
71 * IMPS wbxml message decoder |
|
72 * @param aImpsData reference to MImpsDataAccessor class. |
|
73 * @param aEncodeBuffer buffer to hold the decoded message, |
|
74 */ |
|
75 void DecodeMessageL( |
|
76 MImpsDataAccessor& aImpsData, |
|
77 HBufC8** aEncodeBuffer ); |
|
78 |
|
79 /** |
|
80 * Method decodes (wb)xml message to internal data structures |
|
81 * in asynchronous manner. The completion of the operation is signaled in |
|
82 * MImpsCSPSession::TransportResponseParsedL() method. |
|
83 * @param aEncodeBuffer buffer to hold the encoded message |
|
84 * Please note that the buffer ownership is taken!!! |
|
85 */ |
|
86 TInt DecodeMsgAsyncL( |
|
87 HBufC8** aBuffer); |
|
88 |
|
89 /** |
|
90 * Method to cancel the asynchronous decoding |
|
91 */ |
|
92 void CancelDecoding(); |
|
93 |
|
94 private: |
|
95 |
|
96 /** |
|
97 * Destructor |
|
98 */ |
|
99 virtual void Destroy(); |
|
100 |
|
101 /** |
|
102 * Destructor. |
|
103 */ |
|
104 virtual ~CImpsDecodeWbXml(); |
|
105 |
|
106 /** |
|
107 * C++ default constructor. |
|
108 */ |
|
109 CImpsDecodeWbXml(); |
|
110 |
|
111 /** |
|
112 * method updates current parser state |
|
113 * @param aState new state |
|
114 */ |
|
115 void SetState(TImpsDecodeState aState); |
|
116 |
|
117 /** |
|
118 * method stores WBXML inline string |
|
119 * @param aParser parser pointer |
|
120 * @param aLength string length |
|
121 * @return (parser) error code |
|
122 */ |
|
123 NW_Status_t StoreInlineStringL(NW_WBXML_Parser_t* aParser,TInt aLength); |
|
124 |
|
125 /** |
|
126 * method stores WBXML table string |
|
127 * @param aIndex string table index |
|
128 * @return (parser) error code |
|
129 */ |
|
130 NW_Status_t StoreTableStringL(TUint32 aIndex); |
|
131 |
|
132 /** |
|
133 * method stores WBXML opaque data |
|
134 * @param aParser parser pointer |
|
135 * @param aLength data length |
|
136 * @return (parser) error code |
|
137 */ |
|
138 NW_Status_t StoreOpaqueData(NW_WBXML_Parser_t* aParser,TUint32 aLength); |
|
139 |
|
140 /** |
|
141 * method verifies WBXML document header |
|
142 * @param aDocument WBXML document pointer |
|
143 * @return (parser) error code |
|
144 */ |
|
145 NW_Status_t StoreDocument(NW_WBXML_Document_t* aDocument); |
|
146 |
|
147 /** |
|
148 * method for wbxml token handling |
|
149 * @param aToken WBXML token value |
|
150 * @return (parser) error code |
|
151 */ |
|
152 NW_Status_t StoreTokenL(TUint32 aToken); |
|
153 |
|
154 /** |
|
155 * method for wbxml entity handling |
|
156 * @param aValue value to be decoded |
|
157 * @return (parser) error code |
|
158 */ |
|
159 NW_Status_t DecodeEntityL(TUint32 aValue); |
|
160 |
|
161 /** |
|
162 * method stores parsed out data to data accessor and |
|
163 * removes token from data access key |
|
164 * @return (parser) error code |
|
165 */ |
|
166 NW_Status_t TagEndHandleL( ); |
|
167 |
|
168 /** |
|
169 * parser exception handler |
|
170 * @param aException exception value |
|
171 */ |
|
172 void ExceptionHandle(NW_WBXML_Exception_t aException); |
|
173 |
|
174 /** |
|
175 * method stores parsed string |
|
176 * @param aString string to be stored |
|
177 */ |
|
178 void StoreStringL(NW_String_t aString); |
|
179 |
|
180 /** |
|
181 * method creates the correct index in case of multiple elements |
|
182 * @param aImpsKey key of the element |
|
183 */ |
|
184 void CheckIfMultipleElementsL(TInt aImpsKey); |
|
185 |
|
186 |
|
187 /** |
|
188 * method checks if the given token is a presence transaction token |
|
189 * @param aToken |
|
190 */ |
|
191 TBool IsPureTransaction(TInt aToken); |
|
192 |
|
193 |
|
194 /** |
|
195 * method makes a simple 16bit to 8bit conversion for DTD elements |
|
196 * Use only if the unicode contains only ASCII characters! |
|
197 * To avoid dynamic memory allocation the maximum length of the DTD |
|
198 * element is set to be 100 characters! (Should be enough in WV DTDs) |
|
199 * @param aToken |
|
200 */ |
|
201 void ConvertToDes8( TUint16* aElement, TDes8& aConverted ); |
|
202 |
|
203 |
|
204 /** |
|
205 * By default constructor is private. |
|
206 */ |
|
207 void ConstructL(); |
|
208 |
|
209 // By default, prohibit copy constructor |
|
210 CImpsDecodeWbXml( const CImpsDecodeWbXml& ); |
|
211 |
|
212 // Prohibit assigment operator |
|
213 CImpsDecodeWbXml& operator= ( const CImpsDecodeWbXml& ); |
|
214 |
|
215 private: // Data |
|
216 TInt iError; |
|
217 TInt iCurrentDictionary; |
|
218 TInt iDictionaryCount; |
|
219 NW_WBXML_Dictionary_t* iDictionaries[KMaxDictionaries]; |
|
220 TInt iDecodingState; |
|
221 // HBufC8* iDecodeBuffer; |
|
222 NW_WBXML_Document_t* iDocument; |
|
223 TInt iPreviousElement; |
|
224 TInt iExtension; |
|
225 TInt iAttribute; |
|
226 MImpsDataAccessor* iImpsData; |
|
227 MImpsKey* iAccessKey; |
|
228 CImpsWbXmlData* iWbXmlData; |
|
229 TInt iCurrentCodePage; |
|
230 TInt iElementToken; |
|
231 HBufC8* iStoreValue8; |
|
232 HBufC8* iElementValue; |
|
233 HBufC* iStoreValue; |
|
234 TInt iExtensionValue; |
|
235 TBuf8<4> iVersion; |
|
236 NW_WBXML_Opaque_t iOpaque; |
|
237 TInt iContentSize; |
|
238 TImpsKeyType iKeyType; |
|
239 TInt iNameSpace; |
|
240 TInt iPreviousNameSpace; |
|
241 CImpsXmlUtils* iXmlUtils; |
|
242 TInt iPEC; |
|
243 TBool iDecodeToXml; |
|
244 TInt iTransactions; |
|
245 TBool iTypeStatus; |
|
246 CStack<NW_String_UCS2Buff_t, EFalse>* iStack; |
|
247 TInt iPureMessageType; |
|
248 |
|
249 public: // Friend classes |
|
250 |
|
251 friend NW_Status_t TagStart(NW_WBXML_Parser_t* aParser, void* aContext); |
|
252 friend NW_Status_t FQTokenL(NW_WBXML_Parser_t* aParser,TUint32 aFqtoken, void* aContext); |
|
253 friend NW_Status_t InlineStringL(NW_WBXML_Parser_t* aParser,TUint32 aLength, void* aContext); |
|
254 friend NW_Status_t TableStringL(NW_WBXML_Parser_t* aParser,TUint32 aIndex, void* aContext); |
|
255 friend NW_Status_t Extension(NW_WBXML_Parser_t* aParser,void* aContext); |
|
256 friend NW_Status_t Opaque(NW_WBXML_Parser_t* aParser,TUint32 aLength, void* aContext); |
|
257 friend NW_Status_t BinaryL(NW_WBXML_Parser_t* aParser,TUint32 aLength, void* aContext); |
|
258 friend NW_Status_t AttributeStart(NW_WBXML_Parser_t* aParser, void* aContext); |
|
259 friend NW_Status_t StartDocument(NW_WBXML_Parser_t* aParser,NW_WBXML_Document_t* aDocument, void* aContext); |
|
260 friend NW_Status_t AttributeValue(NW_WBXML_Parser_t* aParser, void* aContext); |
|
261 friend NW_Status_t TagEndL(NW_WBXML_Parser_t* aParser, void* aContext); |
|
262 friend NW_Status_t Content(NW_WBXML_Parser_t* aParser, void* aContext); |
|
263 friend NW_Status_t EntityL(NW_WBXML_Parser_t* aParser,TUint32 aLength, void* aContext); |
|
264 friend NW_Status_t Exception(NW_WBXML_Parser_t* aParser,NW_WBXML_Exception_t aException, void* aContext); |
|
265 friend NW_Status_t Binary(NW_WBXML_Parser_t* aParser,TUint32 aLength, void* aContext); |
|
266 |
|
267 }; |
|
268 |
|
269 #endif // ?INCLUDE_H |
|
270 |
|
271 // End of File |