|
1 /* |
|
2 * Copyright (c) 2006 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: Simple Engine request |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include <e32std.h> |
|
24 |
|
25 // own simple |
|
26 #include "simplesipconnection.h" |
|
27 #include "simplecommon.h" |
|
28 #include "simpleenginerequest.h" |
|
29 #include "msimpleenginerequest.h" |
|
30 #include "msimpleowncallback.h" |
|
31 |
|
32 #ifdef _DEBUG |
|
33 #include "simpledebugutils.h" |
|
34 #endif |
|
35 |
|
36 |
|
37 // ================= MEMBER FUNCTIONS ======================= |
|
38 // |
|
39 |
|
40 // ---------------------------------------------------------- |
|
41 // CSimpleEngineRequest::CSimpleEngineRequest |
|
42 // ---------------------------------------------------------- |
|
43 // |
|
44 CSimpleEngineRequest::CSimpleEngineRequest( |
|
45 MSimpleOwnCallback& aEngine, |
|
46 MSimpleEngineRequest::TSimpleRequest aType, |
|
47 TInt aOpId ) |
|
48 : CActive( CActive::EPriorityHigh ), iType( aType ), |
|
49 iOpId( aOpId ), iEngine( aEngine ), iRefresh( ETrue ), |
|
50 iAux(0), iDestroyedPtr( NULL ) |
|
51 { |
|
52 CActiveScheduler::Add(this); |
|
53 } |
|
54 |
|
55 // ---------------------------------------------------------- |
|
56 // CSimpleEngineRequest::~CSimpleEngineRequest |
|
57 // ---------------------------------------------------------- |
|
58 // |
|
59 CSimpleEngineRequest::~CSimpleEngineRequest() |
|
60 { |
|
61 #ifdef _DEBUG |
|
62 TSimpleLogger::Log(_L("EngineRequest: destructor ereq=%d" ), (TInt)this); |
|
63 #endif |
|
64 |
|
65 if ( iDestroyedPtr ) |
|
66 { |
|
67 // We are called inside callback |
|
68 *iDestroyedPtr = ETrue; |
|
69 iDestroyedPtr = NULL; |
|
70 } |
|
71 |
|
72 Cancel(); |
|
73 delete iResponseData; |
|
74 delete iRemoteURI; |
|
75 delete iRequestContentType; |
|
76 delete iResponseContentType; |
|
77 delete iResponseBoundary; |
|
78 delete iResponseStart; |
|
79 delete iETag; |
|
80 delete iRecipientId; |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CSimpleEngineRequest::Destroy |
|
85 // ----------------------------------------------------------------------------- |
|
86 void CSimpleEngineRequest::Destroy() |
|
87 { |
|
88 #ifdef _DEBUG |
|
89 TSimpleLogger::Log(_L("EngineRequest: Destroy ereq=%d" ), (TInt)this); |
|
90 #endif |
|
91 iLink.Deque(); |
|
92 delete this; |
|
93 } |
|
94 |
|
95 // ---------------------------------------------------------- |
|
96 // CSimpleEngineRequest::NewL |
|
97 // ---------------------------------------------------------- |
|
98 // |
|
99 CSimpleEngineRequest* CSimpleEngineRequest::NewL( |
|
100 MSimpleOwnCallback& aEngine, |
|
101 TSimpleRequest aType, |
|
102 TInt aOpId ) |
|
103 { |
|
104 CSimpleEngineRequest* self = new (ELeave) CSimpleEngineRequest( aEngine, aType, aOpId ); |
|
105 #ifdef _DEBUG |
|
106 TSimpleLogger::Log(_L("EngineRequest: NewL ereq=%d" ), (TInt)self); |
|
107 #endif |
|
108 return self; |
|
109 } |
|
110 |
|
111 // ---------------------------------------------------------- |
|
112 // CSimpleEngineRequest::SetRequestData |
|
113 // ---------------------------------------------------------- |
|
114 // |
|
115 void CSimpleEngineRequest::SetRequestData( TPtrC8 aData ) |
|
116 { |
|
117 iRequestData.Set(aData); |
|
118 } |
|
119 |
|
120 // ---------------------------------------------------------- |
|
121 // CSimpleEngineRequest::SetRefreshTime |
|
122 // ---------------------------------------------------------- |
|
123 // |
|
124 void CSimpleEngineRequest::SetRefreshTime( TUint aTime ) |
|
125 { |
|
126 #ifdef _DEBUG |
|
127 TSimpleLogger::Log(_L("EngineRequest: SetRefreshTime %d" ), aTime); |
|
128 #endif |
|
129 iRefreshTime = aTime; |
|
130 } |
|
131 |
|
132 // ---------------------------------------------------------- |
|
133 // CSimpleEngineRequest::SetRemoteURIL |
|
134 // ---------------------------------------------------------- |
|
135 // |
|
136 void CSimpleEngineRequest::SetRemoteURIL( const TDesC8& aURI ) |
|
137 { |
|
138 delete iRemoteURI; |
|
139 iRemoteURI = NULL; |
|
140 iRemoteURI = aURI.AllocL(); |
|
141 } |
|
142 |
|
143 // ---------------------------------------------------------- |
|
144 // CSimpleEngineRequest::RequestType |
|
145 // ---------------------------------------------------------- |
|
146 // |
|
147 MSimpleEngineRequest::TSimpleRequest CSimpleEngineRequest::RequestType() |
|
148 { |
|
149 return iType; |
|
150 } |
|
151 |
|
152 // ---------------------------------------------------------- |
|
153 // CSimpleEngineRequest::ModifyType |
|
154 // ---------------------------------------------------------- |
|
155 // |
|
156 void CSimpleEngineRequest::ModifyType( MSimpleEngineRequest::TSimpleRequest aType ) |
|
157 { |
|
158 iType = aType; |
|
159 } |
|
160 |
|
161 // ---------------------------------------------------------- |
|
162 // CSimpleEngineRequest::Complete |
|
163 // ---------------------------------------------------------- |
|
164 // |
|
165 void CSimpleEngineRequest::Complete( TInt aStatus ) |
|
166 { |
|
167 #ifdef _DEBUG |
|
168 TSimpleLogger::Log(_L("EngineRequest: COMPLETE ereq=%d aStatus=%d" ), |
|
169 (TInt)this, aStatus ); |
|
170 #endif |
|
171 // Yield to scheduler in order to "break" a call stack before |
|
172 // continuing response handling. |
|
173 |
|
174 // RunL will handle the response further |
|
175 iStatus = KRequestPending; |
|
176 SetActive(); |
|
177 TRequestStatus* s = &iStatus; |
|
178 User::RequestComplete( s, aStatus ); |
|
179 } |
|
180 |
|
181 // ---------------------------------------------------------- |
|
182 // CSimpleEngineRequest::RequestContentType |
|
183 // ---------------------------------------------------------- |
|
184 // |
|
185 TPtrC8 CSimpleEngineRequest::RequestContentType() |
|
186 { |
|
187 return iRequestContentType ? iRequestContentType->Des() : TPtrC8(); |
|
188 } |
|
189 |
|
190 // ---------------------------------------------------------- |
|
191 // CSimpleEngineRequest::SetRequestContentTypeL |
|
192 // ---------------------------------------------------------- |
|
193 // |
|
194 void CSimpleEngineRequest::SetRequestContentTypeL( const TDesC8& aData ) |
|
195 { |
|
196 delete iRequestContentType; |
|
197 iRequestContentType = NULL; |
|
198 iRequestContentType = aData.AllocL(); |
|
199 } |
|
200 |
|
201 // ---------------------------------------------------------- |
|
202 // CSimpleEngineRequest::RequestData |
|
203 // ---------------------------------------------------------- |
|
204 // |
|
205 TPtrC8 CSimpleEngineRequest::RequestData() |
|
206 { |
|
207 return iRequestData; |
|
208 } |
|
209 |
|
210 // ---------------------------------------------------------- |
|
211 // CSimpleEngineRequest::SetResponseContentType( |
|
212 // ---------------------------------------------------------- |
|
213 // |
|
214 void CSimpleEngineRequest::SetResponseContentType( HBufC8* aData ) |
|
215 { |
|
216 delete iResponseContentType; |
|
217 iResponseContentType = NULL; |
|
218 iResponseContentType = aData; |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------------- |
|
222 // CSimpleEngineRequest::SetResponseContentType( |
|
223 // ---------------------------------------------------------- |
|
224 // |
|
225 void CSimpleEngineRequest::SetResponseBoundaryL( const TDesC8& aData ) |
|
226 { |
|
227 delete iResponseBoundary; |
|
228 iResponseBoundary = NULL; |
|
229 iResponseBoundary = aData.AllocL(); |
|
230 } |
|
231 |
|
232 // ---------------------------------------------------------- |
|
233 // CSimpleEngineRequest::SetResponseContentType( |
|
234 // ---------------------------------------------------------- |
|
235 // |
|
236 void CSimpleEngineRequest::SetResponseStartL( const TDesC8& aData ) |
|
237 { |
|
238 delete iResponseStart; |
|
239 iResponseStart = NULL; |
|
240 iResponseStart = aData.AllocL(); |
|
241 } |
|
242 |
|
243 // ---------------------------------------------------------- |
|
244 // CSimpleEngineRequest::SetResponseDataL |
|
245 // ---------------------------------------------------------- |
|
246 // |
|
247 void CSimpleEngineRequest::SetResponseDataL( const TDesC8& aData ) |
|
248 { |
|
249 delete iResponseData; |
|
250 iResponseData = NULL; |
|
251 iResponseData = aData.AllocL(); |
|
252 } |
|
253 |
|
254 // ---------------------------------------------------------- |
|
255 // CSimpleEngineRequest::SetRecipientL |
|
256 // ---------------------------------------------------------- |
|
257 // |
|
258 void CSimpleEngineRequest::SetRecipientL( const TDesC8& aRecipientId ) |
|
259 { |
|
260 delete iRecipientId; |
|
261 iRecipientId = NULL; |
|
262 iRecipientId = aRecipientId.AllocL(); |
|
263 } |
|
264 |
|
265 // ---------------------------------------------------------- |
|
266 // CSimpleEngineRequest::SetResponseMethod |
|
267 // ---------------------------------------------------------- |
|
268 // |
|
269 void CSimpleEngineRequest::SetResponseMethod( TSimpleSIPResponse aMethod ) |
|
270 { |
|
271 iResponseMethod = aMethod; |
|
272 } |
|
273 |
|
274 // ---------------------------------------------------------- |
|
275 // CSimpleEngineRequest::ResponseMethod |
|
276 // ---------------------------------------------------------- |
|
277 // |
|
278 MSimpleEngineRequest::TSimpleSIPResponse CSimpleEngineRequest::ResponseMethod( ) |
|
279 { |
|
280 return iResponseMethod; |
|
281 } |
|
282 |
|
283 // ---------------------------------------------------------- |
|
284 // CSimpleEngineRequest::ResponseContentType |
|
285 // ---------------------------------------------------------- |
|
286 // |
|
287 TPtrC8 CSimpleEngineRequest::ResponseContentType() |
|
288 { |
|
289 return iResponseContentType ? iResponseContentType->Des() : TPtrC8(); |
|
290 } |
|
291 |
|
292 // ---------------------------------------------------------- |
|
293 // CSimpleEngineRequest::ResponseBoundary |
|
294 // ---------------------------------------------------------- |
|
295 // |
|
296 TPtrC8 CSimpleEngineRequest::ResponseBoundary() |
|
297 { |
|
298 return iResponseBoundary? iResponseBoundary->Des() : TPtrC8(); |
|
299 } |
|
300 |
|
301 // ---------------------------------------------------------- |
|
302 // CSimpleEngineRequest::ResponseStart |
|
303 // ---------------------------------------------------------- |
|
304 // |
|
305 TPtrC8 CSimpleEngineRequest::ResponseStart() |
|
306 { |
|
307 return iResponseStart ? iResponseStart->Des() : TPtrC8(); |
|
308 } |
|
309 |
|
310 // ---------------------------------------------------------- |
|
311 // CSimpleEngineRequest::ResponseData |
|
312 // ---------------------------------------------------------- |
|
313 // |
|
314 TPtrC8 CSimpleEngineRequest::ResponseData() |
|
315 { |
|
316 return iResponseData ? iResponseData->Des() : TPtrC8(); |
|
317 } |
|
318 |
|
319 // ---------------------------------------------------------- |
|
320 // CSimpleEngineRequest::Recipient |
|
321 // ---------------------------------------------------------- |
|
322 // |
|
323 TPtrC8 CSimpleEngineRequest::Recipient() |
|
324 { |
|
325 return iRecipientId ? iRecipientId->Des() : TPtrC8(); |
|
326 } |
|
327 |
|
328 // ---------------------------------------------------------- |
|
329 // CSimpleEngineRequest::RefreshTime |
|
330 // ---------------------------------------------------------- |
|
331 // |
|
332 TUint CSimpleEngineRequest::RefreshTime() |
|
333 { |
|
334 return iRefreshTime; |
|
335 } |
|
336 |
|
337 // ---------------------------------------------------------- |
|
338 // CSimpleEngineRequest::RemoteURI |
|
339 // ---------------------------------------------------------- |
|
340 // |
|
341 TPtrC8 CSimpleEngineRequest::RemoteURI() |
|
342 { |
|
343 return iRemoteURI ? iRemoteURI->Des() : TPtrC8(); |
|
344 } |
|
345 |
|
346 // ---------------------------------------------------------- |
|
347 // CSimpleEngineRequest::IsRefresh |
|
348 // ---------------------------------------------------------- |
|
349 // |
|
350 TBool CSimpleEngineRequest::IsRefresh() |
|
351 { |
|
352 return iRefresh; |
|
353 } |
|
354 |
|
355 // ---------------------------------------------------------- |
|
356 // CSimpleEngineRequest::SetRefresh |
|
357 // ---------------------------------------------------------- |
|
358 // |
|
359 void CSimpleEngineRequest::SetRefresh( TBool aRefresh ) |
|
360 { |
|
361 iRefresh = aRefresh; |
|
362 } |
|
363 |
|
364 // ---------------------------------------------------------- |
|
365 // CSimpleEngineRequest::OpId |
|
366 // ---------------------------------------------------------- |
|
367 // |
|
368 TInt CSimpleEngineRequest::OpId( ) |
|
369 { |
|
370 return iOpId; |
|
371 } |
|
372 |
|
373 // ---------------------------------------------------------- |
|
374 // CSimpleEngineRequest::Aux |
|
375 // ---------------------------------------------------------- |
|
376 // |
|
377 TInt CSimpleEngineRequest::Aux( ) |
|
378 { |
|
379 return iAux; |
|
380 } |
|
381 |
|
382 // ---------------------------------------------------------- |
|
383 // CSimpleEngineRequest::SetAux |
|
384 // ---------------------------------------------------------- |
|
385 // |
|
386 void CSimpleEngineRequest::SetAux( TInt aData ) |
|
387 { |
|
388 iAux = aData; |
|
389 } |
|
390 |
|
391 // ---------------------------------------------------------- |
|
392 // CSimpleEngineRequest::SetResponseReason |
|
393 // ---------------------------------------------------------- |
|
394 void CSimpleEngineRequest::SetResponseReason( TSimpleResponseReason aReason ) |
|
395 { |
|
396 iReason = aReason; |
|
397 } |
|
398 |
|
399 // ---------------------------------------------------------- |
|
400 // CSimpleEngineRequest::ResponseReason |
|
401 // ---------------------------------------------------------- |
|
402 MSimpleEngineRequest::TSimpleResponseReason CSimpleEngineRequest::ResponseReason() |
|
403 { |
|
404 return iReason; |
|
405 } |
|
406 |
|
407 // ----------------------------------------------------------------------------- |
|
408 // CSimpleEngineRequest::SetETagL |
|
409 // ----------------------------------------------------------------------------- |
|
410 void CSimpleEngineRequest::SetETagL( const TDesC8& aTag ) |
|
411 { |
|
412 delete iETag; |
|
413 iETag = NULL; |
|
414 iETag = aTag.AllocL(); |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // CSimpleEngineRequest::ETag |
|
419 // ----------------------------------------------------------------------------- |
|
420 TPtrC8 CSimpleEngineRequest::ETag() |
|
421 { |
|
422 return iETag ? iETag->Des() : TPtrC8(); |
|
423 } |
|
424 |
|
425 // ----------------------------------------------------------------------------- |
|
426 // CSimpleEngineRequest::RunL |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 void CSimpleEngineRequest::RunL() |
|
430 { |
|
431 TInt stat = iStatus.Int(); |
|
432 #ifdef _DEBUG |
|
433 TSimpleLogger::Log(_L("EngineRequest: RunL type=%d status=%d ereq=%d"),iType,stat, (TInt)this ); |
|
434 #endif |
|
435 |
|
436 // Set the member to point to stack variable |
|
437 TBool destroyed( EFalse ); |
|
438 iDestroyedPtr = &destroyed; |
|
439 |
|
440 // Call client callback method(s) |
|
441 iEngine.Complete( iOpId, stat, *this ); |
|
442 |
|
443 // Check whether this entity is destroyed in Complete method. |
|
444 if ( destroyed ) |
|
445 { |
|
446 return; |
|
447 } |
|
448 |
|
449 // Reset response data |
|
450 delete iResponseData; |
|
451 iResponseData = NULL; |
|
452 delete iResponseContentType; |
|
453 iResponseContentType = NULL; |
|
454 delete iResponseBoundary; |
|
455 iResponseBoundary = NULL; |
|
456 delete iResponseStart; |
|
457 iResponseStart = NULL; |
|
458 delete iRecipientId; |
|
459 iRecipientId = NULL; |
|
460 iResponseMethod = EUnknownResponse; |
|
461 iReason = ENoReason; |
|
462 |
|
463 iDestroyedPtr = NULL; |
|
464 } |
|
465 |
|
466 // ---------------------------------------------------------- |
|
467 // CSimpleEngineRequest::DoCancel |
|
468 // ---------------------------------------------------------- |
|
469 // |
|
470 void CSimpleEngineRequest::DoCancel() |
|
471 { |
|
472 #ifdef _DEBUG |
|
473 TSimpleLogger::Log(_L("EngineRequest: DoCancel ereq=%d" ), (TInt)this ); |
|
474 #endif |
|
475 } |
|
476 |