|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __CWSPCORXDATA_H__ |
|
17 #define __CWSPCORXDATA_H__ |
|
18 |
|
19 // System includes |
|
20 #include <e32base.h> |
|
21 #include <http/framework/crxdata.h> |
|
22 |
|
23 // Forward declarations |
|
24 class MWspCORxDataCallback; |
|
25 |
|
26 |
|
27 //##ModelId=3BBD80690108 |
|
28 class CWspCORxData : public CRxData |
|
29 { |
|
30 public: // Methods |
|
31 |
|
32 /** @fn NewL(CProtTransaction& aProtTrans, MRxDataObserver& aObserver, MWspCORxDataCallback& aMethodCallback) |
|
33 Intended Usage : Static factory constructor. |
|
34 @since 7.0 |
|
35 @leave Leaves with KErrNoMemory if there was not enough memory to |
|
36 create the object. |
|
37 @param aTransaction The protocol transaction object associated |
|
38 with the Rx data object. |
|
39 @param aObserver A reference to the Rx data observer |
|
40 object. |
|
41 @param aMethodCallback A reference to the callback object. |
|
42 @return A pointer to newly created object. |
|
43 */ |
|
44 //##ModelId=3C4C41AD03E3 |
|
45 static CWspCORxData* NewL( |
|
46 CProtTransaction& aTrasaction, |
|
47 MRxDataObserver& aObserver, |
|
48 MWspCORxDataCallback& aMethodCallback |
|
49 ); |
|
50 |
|
51 /** @fn ~CWspCORxData() |
|
52 Intended Usage : Standard destructor. |
|
53 @since 7.0 |
|
54 */ |
|
55 //##ModelId=3C4C41AD03D9 |
|
56 ~CWspCORxData(); |
|
57 |
|
58 /** @fn SetResponseDataL(const TDesC8& aResponseHeaders, MHTTPDataSupplier& aResponseBody) |
|
59 Intended Usage : Sets the header and body data for the request response. |
|
60 The header data is segmented into the individual header |
|
61 fields and set into the response object's headers. |
|
62 |
|
63 The client is informed using the EGotResponseHeaders |
|
64 event. The raw field value is not decoded. This is left |
|
65 for when the field value is required. |
|
66 |
|
67 If there is any body data then the client is informed |
|
68 using the EGotResponseBodyData event. If there is no |
|
69 body data and no more primitives are expected, the |
|
70 RxData observer is sent the EResponseComplete status. |
|
71 |
|
72 The more data flag that indicates if there is more data |
|
73 to be received for this transaction in subsequent |
|
74 S-MethodResultData primitives to follow. |
|
75 @since 7.0 |
|
76 @leave The function will leave if setting the header data or body |
|
77 data fails. |
|
78 @param aResponseHeaders A reference to a buffer with the the |
|
79 header data. |
|
80 @param aResponseBody A reference to the data supplier object |
|
81 for the body data. |
|
82 @param aMoreResponseData A flag indicating that there is more data |
|
83 to be received for this transaction in |
|
84 subsequent S-MethodResultData primitives |
|
85 to follow. . |
|
86 @pre A S-MethodResult primitive has been received. |
|
87 @post The data supplier for thebody data is stored. The header |
|
88 data has been segmented into the individual header fields |
|
89 and set in the response object. |
|
90 */ |
|
91 //##ModelId=3C4C41AD0392 |
|
92 void SetResponseDataL(const TDesC8& aResponseHeaders, MHTTPDataSupplier& aResponseBody, TBool aMoreResponseData); |
|
93 |
|
94 /** @fn UpdateResponseDataL(const TDesC8& aTrailerHeaders, TBool aMoreResponseData) |
|
95 Intended Usage : Fetches any extra body data from the stored data |
|
96 supplier. Trailer header data is only allowed if this is |
|
97 the last S-MethodResultData primitive. |
|
98 |
|
99 If this is the last primitive and there is some header |
|
100 data, this is segmented into the individual header |
|
101 fields and added to the response object's headers. The |
|
102 raw field value is not decoded. This is left for when |
|
103 the field value is required. |
|
104 |
|
105 The client is sent the EGotResponseTrailerHeaders event. |
|
106 |
|
107 If there is any extra body data and the client has |
|
108 already released the previous batch of body data, then |
|
109 the EGotResponseBodyData event is sent. |
|
110 |
|
111 The more data flag that indicates if there is more data |
|
112 to be received for this transaction in subsequent |
|
113 S-MethodResultData primitives to follow. |
|
114 @since 7.0 |
|
115 @leave The function will leave with KWspErrNotExpectingTrailers if |
|
116 there is trailer header data but more S-MethodResulData |
|
117 primitives are expected. Also, it will leave if it fails to |
|
118 update the body data. |
|
119 @param aTrailerHeaders A reference to a buffer with the encoded |
|
120 trailer headers. This must be empty |
|
121 unless this is the last S-MethodResultData |
|
122 primitive. |
|
123 @param aMoreResponseData A flag indicating that there is more data |
|
124 to be received for this transaction in |
|
125 subsequent S-MethodResultData primitives |
|
126 to follow. . |
|
127 @pre A S-MethodResultData primitive has been received. |
|
128 @post Any trailer header data is segmented into the individual |
|
129 header fields and added to the response object's headers. |
|
130 The client is notified of more body data if there is any |
|
131 and the previous batch of data has been released. |
|
132 */ |
|
133 //##ModelId=3C4C41AD036A |
|
134 void UpdateResponseDataL(const TDesC8& aTrailerHeaders, TBool aMoreResponseData); |
|
135 |
|
136 private: // Methods from CRxData |
|
137 |
|
138 /** @fn void ResetRxData() |
|
139 @see CRxData |
|
140 */ |
|
141 //##ModelId=3C4C41AD034C |
|
142 virtual void ResetRxData(); |
|
143 |
|
144 private: // Methods from MHTTPDataSupplier |
|
145 |
|
146 /** @fn GetNextDataPart(TPtrC8& aDataPart) |
|
147 @see MHTTPDataSupplier |
|
148 */ |
|
149 //##ModelId=3C4C41AD0324 |
|
150 virtual TBool GetNextDataPart(TPtrC8& aDataPart); |
|
151 |
|
152 /** @fn ReleaseData() |
|
153 @see MHTTPDataSupplier |
|
154 */ |
|
155 //##ModelId=3C4C41AD0310 |
|
156 virtual void ReleaseData(); |
|
157 |
|
158 /** @fn OverallDataSize() |
|
159 @see MHTTPDataSupplier |
|
160 */ |
|
161 //##ModelId=3C4C41AD02FC |
|
162 virtual TInt OverallDataSize(); |
|
163 |
|
164 /** @fn Reset() |
|
165 @see MHTTPDataSupplier |
|
166 */ |
|
167 //##ModelId=3C4C41AD02E8 |
|
168 virtual TInt Reset(); |
|
169 |
|
170 private: // Methods |
|
171 |
|
172 /** @fn CWspCORxData(CProtTransaction& aTransaction, MRxDataObserver& aObserver, MWspCORxDataCallback& aMethodCallback) |
|
173 Intended Usage : First phase constructor. |
|
174 @since 7.0 |
|
175 @param aTransaction The protocol transaction object associated |
|
176 with the Rx data object. |
|
177 @param aObserver A reference to the Rx data observer |
|
178 object. |
|
179 @param aMethodCallback A reference to the callback object. |
|
180 */ |
|
181 //##ModelId=3C4C41AD02AC |
|
182 CWspCORxData( |
|
183 CProtTransaction& aTransaction, |
|
184 MRxDataObserver& aObserver, |
|
185 MWspCORxDataCallback& aMethodCallback |
|
186 ); |
|
187 |
|
188 /** @fn SetHeaderDataL(const TDesC8& aResponseHeaders) |
|
189 Intended Usage : |
|
190 @since 7.0 |
|
191 @leave |
|
192 @param aResponseHeaders A reference a buffer with the header |
|
193 data. |
|
194 @pre A S-MethodResult primitive has been received. |
|
195 @post The trailer header data has been segmented into the |
|
196 individual header fields and set in the response object. |
|
197 */ |
|
198 //##ModelId=3C4C41AD0298 |
|
199 void SetHeaderDataL(const TDesC8& aResponseHeaders); |
|
200 |
|
201 /** @fn SetBodyDataL(MHTTPDataSupplier& aResponseBody) |
|
202 Intended Usage : |
|
203 @since 7.0 |
|
204 @leave |
|
205 @param aResponseBody A reference to the data supplier object for |
|
206 the body data. |
|
207 @pre A S-MethodResult primitive has been received. The |
|
208 EGotResponseHeaders event has been sent. |
|
209 @post The body data supplier is stored. |
|
210 */ |
|
211 //##ModelId=3C4C41AD027A |
|
212 void SetBodyDataL(MHTTPDataSupplier& aResponseBody); |
|
213 |
|
214 /** @fn UpdateHeaderDataL(const TDesC8& aTrailerHeaders) |
|
215 Intended Usage : |
|
216 @since 7.0 |
|
217 @leave |
|
218 @param aTrailerHeaders A reference to a buffer with the encoded |
|
219 trailer headers. This must be empty unless |
|
220 this is the last S-MethodResultData |
|
221 primitive. |
|
222 @pre A S-MethodResultData primitive has been received. |
|
223 @post Any extra header data is segmented into the individual |
|
224 header fields and added to the response object's headers. |
|
225 */ |
|
226 //##ModelId=3C4C41AD0266 |
|
227 void UpdateHeaderDataL(const TDesC8& aTrailerHeaders); |
|
228 |
|
229 /** @fn UpdateBodyDataL() |
|
230 Intended Usage : |
|
231 @since 7.0 |
|
232 @leave |
|
233 @pre A S-MethodResultData primitive has been received. |
|
234 @post Any extra body data is appended to the buffer. |
|
235 */ |
|
236 //##ModelId=3C4C41AD025C |
|
237 void UpdateBodyDataL(); |
|
238 |
|
239 /** @fn ResponseCompleteL() |
|
240 Informs the observer that the response is complete. Also, if there are |
|
241 trailer headers, the client is sent the EGotResponseTrailerHeaders event. |
|
242 @since 7.0 |
|
243 @pre All the response data has been received and sent to the client. |
|
244 @post The observer has been told that the response is complete. If |
|
245 trailer headers have been received, the client is sent the |
|
246 EGotResponseTrailerHeaders event. |
|
247 */ |
|
248 void ResponseCompleteL(); |
|
249 |
|
250 private: // Attributes |
|
251 |
|
252 /** A reference to the method callback object. |
|
253 */ |
|
254 //##ModelId=3C4C41AD0252 |
|
255 MWspCORxDataCallback& iMethodCallback; |
|
256 |
|
257 /** A pointer to the data supplier for the body data - not owned. |
|
258 */ |
|
259 //##ModelId=3C4C41AD0240 |
|
260 MHTTPDataSupplier* iBodyDataSupplier; |
|
261 |
|
262 /** A flag that indicates whether subsequent S-MethodResultData primitives |
|
263 are expected for the response. |
|
264 */ |
|
265 //##ModelId=3C4C41AD0236 |
|
266 TBool iMoreData; |
|
267 |
|
268 /** A flag to indicate whether there are more data chunks to be obtained from |
|
269 the data supplier object for the current SDU. |
|
270 */ |
|
271 TBool iLastChunk; |
|
272 |
|
273 /** A flag that indicates whether there is a current response body data part. |
|
274 */ |
|
275 //##ModelId=3C4C41AD022A |
|
276 TBool iGotBodyData; |
|
277 |
|
278 /** A descriptor pointer to a buffer containing the current reponse body |
|
279 data part. |
|
280 */ |
|
281 //##ModelId=3C4C41AD0204 |
|
282 TPtrC8 iBodyData; |
|
283 |
|
284 /** The overall size of the body data. If this is not known, e.g. the |
|
285 response is divided over several primitives, then this is set to |
|
286 KErrNotFound. |
|
287 */ |
|
288 //##ModelId=3C4C41AD01F8 |
|
289 TInt iOverallDataSize; |
|
290 |
|
291 /** A flag that indicates the there are trailer headers. |
|
292 */ |
|
293 TBool iHasTrailer; |
|
294 |
|
295 }; |
|
296 |
|
297 #endif // __CWSPCORXDATA_H__ |