|
1 /* |
|
2 * Copyright (c) 2004 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 the License "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 * This file contains the declaration of the Download Mgr Server. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "DownloadMgrLogger.h" |
|
22 #include "DownloadMgrServer.h" |
|
23 #include "DownloadMgrDef.h" |
|
24 #include "DownloadMgrDefAttrib.h" |
|
25 #include <HttpClientApp.h> |
|
26 #include <HttpClientAppInstance.h> |
|
27 #include <HttpDownload.h> |
|
28 #include <e32svr.h> |
|
29 #include <basched.h> |
|
30 //#include <e32uid.h> |
|
31 |
|
32 // CONSTANTS |
|
33 |
|
34 // GLOBAL FUNCTIONS |
|
35 |
|
36 // --------------------------------------------------------- |
|
37 // CDownloadSubSession::NewL |
|
38 // --------------------------------------------------------- |
|
39 // |
|
40 CDownloadSubSession * CDownloadSubSession::NewL( CDownloadMgrSession* aSession, |
|
41 CHttpDownload* aDownload ) |
|
42 { |
|
43 CLOG_ENTERFN_NULL( "CDownloadSubSession::NewL" ) |
|
44 CDownloadSubSession* self = new (ELeave) CDownloadSubSession(); |
|
45 CleanupStack::PushL( self ); |
|
46 self->ConstructL( aSession, aDownload ); |
|
47 CleanupStack::Pop( self ); // self |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------- |
|
52 // CDownloadSubSession::CDownloadSubSession |
|
53 // --------------------------------------------------------- |
|
54 // |
|
55 CDownloadSubSession::CDownloadSubSession() |
|
56 :iEvent( EFalse ) |
|
57 { |
|
58 CLOG_CREATE; |
|
59 } |
|
60 |
|
61 |
|
62 // --------------------------------------------------------- |
|
63 // CDownloadSubSession::ConstructL |
|
64 // --------------------------------------------------------- |
|
65 // |
|
66 void CDownloadSubSession::ConstructL( CDownloadMgrSession *aSession, |
|
67 CHttpDownload* aDownload ) |
|
68 { |
|
69 CLOG_ENTERFN( "CDownloadSubSession::ConstructL" ) |
|
70 iSession = aSession; |
|
71 iDownload = aDownload; |
|
72 |
|
73 #ifdef _DEBUG |
|
74 TInt32 dlId; |
|
75 |
|
76 aDownload->GetIntAttributeL( EDlAttrId, dlId ); |
|
77 CLOG_NAME_2( _L("Download_%d_%d"), aSession->SessionId(), dlId ); |
|
78 #endif |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------- |
|
82 // CDownloadSubSession::~CDownloadSubSession |
|
83 // --------------------------------------------------------- |
|
84 // |
|
85 CDownloadSubSession::~CDownloadSubSession() |
|
86 { |
|
87 CLOG_WRITE( "CDownloadSubSession::~CDownloadSubSession()" ) |
|
88 // Trigger the event queue |
|
89 TUint dummy( 0 ); |
|
90 if( iSession ) |
|
91 { |
|
92 iSession->Event( NULL, (THttpDownloadState)dummy, (THttpProgressState)dummy, (TInt32)dummy ); |
|
93 } |
|
94 if( iAttribs ) |
|
95 { |
|
96 iAttribs->ResetAndDestroy(); |
|
97 delete iAttribs; |
|
98 iAttribs = NULL; |
|
99 } |
|
100 CLOG_CLOSE; |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------- |
|
104 // CDownloadSubSession::CloseCounter |
|
105 // --------------------------------------------------------- |
|
106 // |
|
107 void CDownloadSubSession::CloseDownload() |
|
108 { |
|
109 CLOG_WRITE( "CDownloadSubSession::CloseDownload" ) |
|
110 |
|
111 iSession->ClientAppInstance()->ClientApp()->UnregisterDownload( iDownload ); |
|
112 iDownload->DetachClientInstance(iSession->ClientAppInstance()); |
|
113 iSession->DeleteDownload( Message().Int3() ); |
|
114 } |
|
115 |
|
116 |
|
117 /// --------------------------------------------------------- |
|
118 // CDownloadSubSession::Message |
|
119 // --------------------------------------------------------- |
|
120 // |
|
121 |
|
122 const RMessage2& CDownloadSubSession::Message() const |
|
123 { |
|
124 CLOG_WRITE( "CDownloadSubSession::Message()" ); |
|
125 CLOG_WRITE_FORMAT( "iSession = %x", iSession ); |
|
126 return iSession->CurrentMessage(); |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------- |
|
130 // CDownloadSubSession::DispatchDownloadMessageL |
|
131 // --------------------------------------------------------- |
|
132 // |
|
133 void CDownloadSubSession::DispatchMessageL( const RMessage2& aMessage ) |
|
134 { |
|
135 CLOG_ENTERFN( "CDownloadSubSession::DispatchMessageL" ) |
|
136 switch( aMessage.Function() ) |
|
137 { |
|
138 case EHttpDownloadStart: |
|
139 { |
|
140 StartL(); |
|
141 return; |
|
142 } |
|
143 case EHttpDownloadEventSubscription: |
|
144 { |
|
145 InitDownloadEvent( aMessage ); |
|
146 // Send event from the queue |
|
147 TUint dummy( 0 ); |
|
148 iSession->Event( NULL, (THttpDownloadState)dummy, (THttpProgressState)dummy, (TInt32)dummy ); |
|
149 // This is an asyncron request will be completed later! |
|
150 iSession->SetComplete( EFalse ); |
|
151 return; |
|
152 } |
|
153 case EHttpDownloadEventCancel: |
|
154 { |
|
155 CancelDownloadEvent(); |
|
156 return; |
|
157 } |
|
158 case EHttpDownloadPause: |
|
159 { |
|
160 PauseL(); |
|
161 return; |
|
162 } |
|
163 case EHttpDownloadReset: |
|
164 { |
|
165 Reset(); |
|
166 return; |
|
167 } |
|
168 case EHttpDownloadDelete: |
|
169 { |
|
170 Delete(); |
|
171 return; |
|
172 } |
|
173 case EHttpDownloadMove: |
|
174 { |
|
175 MoveL(); |
|
176 return; |
|
177 } |
|
178 case EHttpDownloadClose: |
|
179 { |
|
180 CloseDownload(); |
|
181 return; |
|
182 } |
|
183 |
|
184 case EHttpDownloadCloseCompleted: |
|
185 { |
|
186 CloseCompletedDownload(); |
|
187 return; |
|
188 } |
|
189 |
|
190 case EHttpDownloadGetIntAttribute: |
|
191 { |
|
192 GetIntAttributeL(); |
|
193 return; |
|
194 } |
|
195 case EHttpDownloadGetBoolAttribute: |
|
196 { |
|
197 GetBoolAttributeL(); |
|
198 return; |
|
199 } |
|
200 case EHttpDownloadGetStringAttribute: |
|
201 { |
|
202 GetStringAttributeL(); |
|
203 return; |
|
204 } |
|
205 case EHttpDownloadGetString8Attribute: |
|
206 { |
|
207 GetString8AttributeL(); |
|
208 return; |
|
209 } |
|
210 case EHttpDownloadSetIntAttribute: |
|
211 { |
|
212 SetIntAttributeL(); |
|
213 return; |
|
214 } |
|
215 case EHttpDownloadSetBoolAttribute: |
|
216 { |
|
217 SetBoolAttributeL(); |
|
218 return; |
|
219 } |
|
220 case EHttpDownloadSetStringAttribute: |
|
221 { |
|
222 SetStringAttributeL(); |
|
223 return; |
|
224 } |
|
225 case EHttpDownloadSetString8Attribute: |
|
226 { |
|
227 SetString8AttributeL(); |
|
228 return; |
|
229 } |
|
230 case EHttpDownloadBufferAttributes: |
|
231 { |
|
232 BufferAttributesL(); |
|
233 return; |
|
234 } |
|
235 case EHttpDownloadGetRFile: |
|
236 { |
|
237 GetFileHandleAttributeL(); |
|
238 return; |
|
239 } |
|
240 case EHttpDownloadSetRFile: |
|
241 { |
|
242 SetFileHandleAttributeL(); |
|
243 return; |
|
244 } |
|
245 case EHttpDownloadDataAttribute: |
|
246 { |
|
247 SetDownloadDataAttributeL(); |
|
248 return; |
|
249 } |
|
250 case EHttpDownloadTrackAttribute: |
|
251 { |
|
252 SetTrackDataAttributeL(); |
|
253 return; |
|
254 } |
|
255 case EHttpDownloadSetOnError: |
|
256 { |
|
257 const TInt error = Message().Int0(); |
|
258 const THttpDownloadMgrError dlerror |
|
259 = (THttpDownloadMgrError)Message().Int1(); |
|
260 OnError( error, dlerror ); |
|
261 return; |
|
262 } |
|
263 |
|
264 default: |
|
265 { |
|
266 iSession->PanicClient( EBadRequest ); |
|
267 return; |
|
268 } |
|
269 } |
|
270 } |
|
271 |
|
272 |
|
273 /// --------------------------------------------------------- |
|
274 // CDownloadSubSession::Start |
|
275 // --------------------------------------------------------- |
|
276 // |
|
277 void CDownloadSubSession::StartL() |
|
278 { |
|
279 CLOG_ENTERFN( "CDownloadSubSession::StartL" ) |
|
280 iDownload->StartL(); |
|
281 } |
|
282 |
|
283 /// --------------------------------------------------------- |
|
284 // CDownloadSubSession::Attributes |
|
285 // --------------------------------------------------------- |
|
286 // |
|
287 void CDownloadSubSession::PauseL() |
|
288 { |
|
289 CLOG_ENTERFN( "CDownloadSubSession::PauseL" ) |
|
290 iDownload->PauseL( ETrue ); |
|
291 } |
|
292 |
|
293 /// --------------------------------------------------------- |
|
294 // CDownloadSubSession::Reset |
|
295 // --------------------------------------------------------- |
|
296 // |
|
297 void CDownloadSubSession::Reset() |
|
298 { |
|
299 CLOG_ENTERFN( "CDownloadSubSession::Reset" ) |
|
300 iDownload->Reset(); |
|
301 } |
|
302 |
|
303 /// --------------------------------------------------------- |
|
304 // CDownloadSubSession::Delete |
|
305 // --------------------------------------------------------- |
|
306 // |
|
307 void CDownloadSubSession::Delete() |
|
308 { |
|
309 CLOG_ENTERFN( "CDownloadSubSession::Delete()" ) |
|
310 iSession->RemoveFromQueue( iDownload ); |
|
311 iDownload->Delete( iSession->ClientAppInstance() ); |
|
312 } |
|
313 |
|
314 /// --------------------------------------------------------- |
|
315 // CDownloadSubSession::CloseCompletedDownload |
|
316 // --------------------------------------------------------- |
|
317 // |
|
318 void CDownloadSubSession::CloseCompletedDownload() |
|
319 { |
|
320 CLOG_WRITE( "CDownloadSubSession::CloseCompletedDownload" ) |
|
321 iDownload->DeleteInfoFile( iSession->ClientAppInstance() ); |
|
322 iSession->RemoveFromQueue( iDownload ); |
|
323 iSession->DeleteDownload( Message().Int3() ); |
|
324 } |
|
325 |
|
326 /// --------------------------------------------------------- |
|
327 // CDownloadSubSession::MoveL |
|
328 // --------------------------------------------------------- |
|
329 // |
|
330 void CDownloadSubSession::MoveL() |
|
331 { |
|
332 CLOG_ENTERFN( "CDownloadSubSession::MoveL" ) |
|
333 iDownload->MoveL(); |
|
334 } |
|
335 |
|
336 /// --------------------------------------------------------- |
|
337 // CDownloadSubSession::InitDownloadEvent |
|
338 // --------------------------------------------------------- |
|
339 // |
|
340 void CDownloadSubSession::InitDownloadEvent( const RMessage2& aMessage ) |
|
341 { |
|
342 CLOG_ENTERFN( "CDownloadSubSession::InitDownloadEvent" ) |
|
343 __ASSERT_DEBUG( iEvent == EFalse, iSession->PanicClient( EMultipleInitDownloadEvent ) ); |
|
344 iMessage = aMessage; |
|
345 iEvent = ETrue; |
|
346 } |
|
347 |
|
348 /// --------------------------------------------------------- |
|
349 // CDownloadSubSession::CancelDownloadEvent |
|
350 // --------------------------------------------------------- |
|
351 // |
|
352 void CDownloadSubSession::CancelDownloadEvent() |
|
353 { |
|
354 CLOG_ENTERFN( "CDownloadSubSession::CancelDownloadEvent" ) |
|
355 CLOG_WRITE_FORMAT( "CDownloadSubSession::CancelDownloadEvent iEvent = %d", iEvent ) |
|
356 if( iEvent ) |
|
357 { |
|
358 iMessage.Complete( KErrCancel ); |
|
359 iEvent = EFalse; |
|
360 } |
|
361 } |
|
362 |
|
363 // --------------------------------------------------------- |
|
364 // CDownloadSubSession::Event |
|
365 // --------------------------------------------------------- |
|
366 // |
|
367 TBool CDownloadSubSession::EventL( TInt32 aDownloadState, TInt32 aProgressState, TInt32 aMoIndex ) |
|
368 { |
|
369 TBool retVal( iEvent ); |
|
370 CLOG_ENTERFN( "CDownloadSubSession::Event" ) |
|
371 if( iEvent ) |
|
372 { |
|
373 CLOG_WRITE_FORMAT( " aDownloadState = %d", aDownloadState ) |
|
374 CLOG_WRITE_FORMAT( " aProgressState = %d", aProgressState ) |
|
375 CLOG_WRITE_FORMAT( " aMoIndex = %d", aMoIndex ) |
|
376 |
|
377 TPckgBuf<TInt32> pckgDownloadState( aDownloadState ); |
|
378 TPckgBuf<TInt32> pckgProgressState( aProgressState ); |
|
379 |
|
380 TInt ret = iMessage.Write( 0, pckgDownloadState ); |
|
381 if( ret != KErrNone ) |
|
382 { |
|
383 CLOG_WRITE_FORMAT( " iMessage.Write( 0, pckgDownloadState ) returned error code: %d", ret ) |
|
384 iSession->PanicClient( EBadDescriptor ); |
|
385 } |
|
386 else |
|
387 { |
|
388 ret = iMessage.Write( 1, pckgProgressState ); |
|
389 if( ret != KErrNone ) |
|
390 { |
|
391 CLOG_WRITE_FORMAT( " iMessage.Write( 1, pckgProgressState ) returned error code: %d", ret ) |
|
392 iSession->PanicClient( EBadDescriptor ); |
|
393 } |
|
394 else |
|
395 { |
|
396 HBufC8* eventAttr = NULL; |
|
397 |
|
398 TInt32 userdata( 0 ); |
|
399 iDownload->GetIntAttributeL( EDlAttrUserData, userdata ); |
|
400 |
|
401 TInt32 moDownloadedsize( 0 ); |
|
402 iDownload->GetIntAttributeL( EDlAttrMultipleMODownloadedSize, moDownloadedsize ); |
|
403 |
|
404 TInt32 moLength( 0 ); |
|
405 iDownload->GetIntAttributeL( EDlAttrMultipleMOLength, moLength ); |
|
406 |
|
407 TInt32 downloadedsize( 0 ); |
|
408 iDownload->GetIntAttributeL( EDlAttrDownloadedSize, downloadedsize ); |
|
409 |
|
410 TInt32 length( 0 ); |
|
411 iDownload->GetIntAttributeL( EDlAttrLength, length ); |
|
412 |
|
413 // Mask media object index with userdata. |
|
414 // For example if aMoIndex = 0x00000004 and userdata = 0x00000005, |
|
415 // then maskData = 0x00040005. |
|
416 TInt32 maskedData = (aMoIndex << 16); |
|
417 maskedData = (maskedData | (userdata & 0x0000FFFF)); |
|
418 |
|
419 TRAPD( err, eventAttr = TDMgrUtils::PackEventAttribL( maskedData, moDownloadedsize, downloadedsize, moLength, length ) ); |
|
420 if( KErrNone == err ) |
|
421 { |
|
422 TPtr8 ptr = eventAttr->Des(); |
|
423 ret = iMessage.Write( 2, ptr ); |
|
424 if( ret != KErrNone ) |
|
425 { |
|
426 CLOG_WRITE_FORMAT( " iMessage.Write( 2, ptr ) returned error code: %d", ret ) |
|
427 iSession->PanicClient( EBadDescriptor ); |
|
428 } |
|
429 } |
|
430 delete eventAttr; |
|
431 } |
|
432 } |
|
433 EventComplete( KErrNone ); |
|
434 } |
|
435 CLOG_WRITE_FORMAT( "Event sent: %d", retVal ) |
|
436 return retVal; |
|
437 } |
|
438 |
|
439 // --------------------------------------------------------- |
|
440 // CDownloadSubSession::CreateAttribPackL |
|
441 // --------------------------------------------------------- |
|
442 // |
|
443 HBufC8* CDownloadSubSession::CreateAttribPackL( TBool aBuffered ) |
|
444 { |
|
445 CLOG_ENTERFN( "CDownloadSubSession::CreateEventAttribPackLC" ) |
|
446 iAttribs = |
|
447 new (ELeave) CArrayPtrFlat< CDefaultAttrib >( 1 ); |
|
448 |
|
449 TInt32 value( 0 ); |
|
450 iDownload->GetIntAttributeL( EDlAttrUserData, value ); |
|
451 CDefaultAttrib* attrib = CDefaultAttrib::NewL( EDlAttrUserData, value ); |
|
452 CleanupStack::PushL( attrib ); |
|
453 iAttribs->AppendL( attrib ); |
|
454 CleanupStack::Pop( attrib ); |
|
455 |
|
456 iDownload->GetIntAttributeL( EDlAttrMultipleMODownloadedSize, value ); |
|
457 attrib = CDefaultAttrib::NewL( EDlAttrMultipleMODownloadedSize, value ); |
|
458 CleanupStack::PushL( attrib ); |
|
459 iAttribs->AppendL( attrib ); |
|
460 CleanupStack::Pop( attrib ); |
|
461 |
|
462 iDownload->GetIntAttributeL( EDlAttrDownloadedSize, value ); |
|
463 attrib = CDefaultAttrib::NewL( EDlAttrDownloadedSize, value ); |
|
464 CleanupStack::PushL( attrib ); |
|
465 iAttribs->AppendL( attrib ); |
|
466 CleanupStack::Pop( attrib ); |
|
467 |
|
468 iDownload->GetIntAttributeL( EDlAttrMultipleMOLength, value ); |
|
469 attrib = CDefaultAttrib::NewL( EDlAttrMultipleMOLength, value ); |
|
470 CleanupStack::PushL( attrib ); |
|
471 iAttribs->AppendL( attrib ); |
|
472 CleanupStack::Pop( attrib ); |
|
473 |
|
474 iDownload->GetIntAttributeL( EDlAttrLength, value ); |
|
475 attrib = CDefaultAttrib::NewL( EDlAttrLength, value ); |
|
476 CleanupStack::PushL( attrib ); |
|
477 iAttribs->AppendL( attrib ); |
|
478 CleanupStack::Pop( attrib ); |
|
479 |
|
480 if( aBuffered ) |
|
481 { |
|
482 TBool deleteStr; |
|
483 HBufC8* tempBuf = iDownload->GetString8AttributeL( |
|
484 EDlAttrReqUrl, |
|
485 deleteStr ); |
|
486 if( deleteStr ) |
|
487 { |
|
488 CleanupStack::PushL( tempBuf ); |
|
489 } |
|
490 TInt length = tempBuf->Length(); |
|
491 attrib = CDefaultAttrib::NewL( EDlAttrReqUrl, tempBuf->Des() ); |
|
492 CleanupStack::PushL( attrib ); |
|
493 iAttribs->AppendL( attrib ); |
|
494 CleanupStack::Pop( attrib ); |
|
495 if( deleteStr ) |
|
496 { |
|
497 CleanupStack::PopAndDestroy( tempBuf ); // tempBuf |
|
498 } |
|
499 |
|
500 iDownload->GetIntAttributeL( EDlAttrId, value ); |
|
501 attrib = CDefaultAttrib::NewL( EDlAttrId, value ); |
|
502 CleanupStack::PushL( attrib ); |
|
503 iAttribs->AppendL( attrib ); |
|
504 CleanupStack::Pop( attrib ); |
|
505 } |
|
506 |
|
507 HBufC8* buf = TDMgrUtils::PackedAttributesL( iAttribs ); |
|
508 iAttribs->ResetAndDestroy(); |
|
509 delete iAttribs; |
|
510 iAttribs = NULL; |
|
511 return buf; |
|
512 } |
|
513 |
|
514 // --------------------------------------------------------- |
|
515 // CDownloadSubSession::OnError |
|
516 // --------------------------------------------------------- |
|
517 // |
|
518 void CDownloadSubSession::OnError( TInt aError, |
|
519 THttpDownloadMgrError aDlError ) |
|
520 { |
|
521 CLOG_ENTERFN( "CDownloadSubSession::OnError" ) |
|
522 |
|
523 iDownload->OnError( aError, aDlError ); |
|
524 } |
|
525 |
|
526 // --------------------------------------------------------- |
|
527 // CDownloadSubSession::EventComplete |
|
528 // --------------------------------------------------------- |
|
529 // |
|
530 void CDownloadSubSession::EventComplete( TInt aErrorStatus ) |
|
531 { |
|
532 CLOG_ENTERFN( "CDownloadSubSession::EventComplete" ) |
|
533 if( iEvent ) |
|
534 { |
|
535 iMessage.Complete( aErrorStatus ); |
|
536 iEvent = EFalse; |
|
537 } |
|
538 } |
|
539 |
|
540 // --------------------------------------------------------- |
|
541 // CDownloadSubSession::GetIntAttributeL |
|
542 // --------------------------------------------------------- |
|
543 // |
|
544 void CDownloadSubSession::GetIntAttributeL() |
|
545 { |
|
546 CLOG_ENTERFN( "CDownloadSubSession::GetIntAttributeL" ) |
|
547 |
|
548 const TInt attr = Message().Int0(); |
|
549 TInt32 moIndex = Message().Int1(); |
|
550 TInt32 value; |
|
551 |
|
552 if (moIndex == KNonMoIndex) |
|
553 iDownload->GetIntAttributeL( (THttpDownloadAttrib)attr, value ); |
|
554 else |
|
555 iDownload->GetIntAttributeL( (THttpDownloadAttrib)attr, moIndex, value ); |
|
556 |
|
557 TPckg<TInt32> pckg( value ); |
|
558 |
|
559 Write( 2, pckg ); |
|
560 } |
|
561 |
|
562 // --------------------------------------------------------- |
|
563 // CDownloadSubSession::GetBoolAttributeL |
|
564 // --------------------------------------------------------- |
|
565 // |
|
566 void CDownloadSubSession::GetBoolAttributeL() |
|
567 { |
|
568 CLOG_ENTERFN( "CDownloadSubSession::GetBoolAttributeL" ) |
|
569 |
|
570 const TInt attr = Message().Int0(); |
|
571 TInt32 moIndex = Message().Int1(); |
|
572 TBool value; |
|
573 |
|
574 if (moIndex == KNonMoIndex) |
|
575 iDownload->GetBoolAttributeL( (THttpDownloadAttrib)attr, value ); |
|
576 else |
|
577 iDownload->GetBoolAttributeL( (THttpDownloadAttrib)attr, moIndex, value ); |
|
578 |
|
579 TPckg<TBool> pckg( value ); |
|
580 |
|
581 Write( 2, pckg ); |
|
582 } |
|
583 |
|
584 // --------------------------------------------------------- |
|
585 // CDownloadSubSession::GetStringAttributeL |
|
586 // --------------------------------------------------------- |
|
587 // |
|
588 void CDownloadSubSession::GetStringAttributeL() |
|
589 { |
|
590 CLOG_ENTERFN( "CDownloadSubSession::GetStringAttributeL" ) |
|
591 const TInt attr = Message().Int0(); |
|
592 TInt32 moIndex = Message().Int1(); |
|
593 |
|
594 TBool deleteStr; |
|
595 HBufC* tempBuf = NULL; |
|
596 if (moIndex == KNonMoIndex) |
|
597 tempBuf = iDownload->GetStringAttributeL( (THttpDownloadAttrib)attr, deleteStr ); |
|
598 else |
|
599 tempBuf = iDownload->GetStringAttributeL( (THttpDownloadAttrib)attr, moIndex, deleteStr ); |
|
600 |
|
601 TPtr value( tempBuf->Des() ); |
|
602 |
|
603 Write( 2, value ); |
|
604 |
|
605 if( deleteStr ) |
|
606 { |
|
607 delete tempBuf; |
|
608 } |
|
609 } |
|
610 |
|
611 // --------------------------------------------------------- |
|
612 // CDownloadSubSession::GetString8AttributeL |
|
613 // --------------------------------------------------------- |
|
614 // |
|
615 void CDownloadSubSession::GetString8AttributeL() |
|
616 { |
|
617 CLOG_ENTERFN( "CDownloadSubSession::GetString8AttributeL" ) |
|
618 const TInt attr = Message().Int0(); |
|
619 TInt32 moIndex = Message().Int1(); |
|
620 |
|
621 TBool deleteStr; |
|
622 HBufC8* tempBuf = NULL; |
|
623 if (moIndex == KNonMoIndex) |
|
624 tempBuf = iDownload->GetString8AttributeL( (THttpDownloadAttrib)attr, deleteStr ); |
|
625 else |
|
626 tempBuf = iDownload->GetString8AttributeL( (THttpDownloadAttrib)attr, moIndex, deleteStr ); |
|
627 |
|
628 TPtr8 value( tempBuf->Des() ); |
|
629 |
|
630 Write( 2, value ); |
|
631 |
|
632 if( deleteStr ) |
|
633 { |
|
634 delete tempBuf; |
|
635 } |
|
636 } |
|
637 |
|
638 // --------------------------------------------------------- |
|
639 // CDownloadSubSession::GetFileHandleAttributeL |
|
640 // --------------------------------------------------------- |
|
641 // |
|
642 void CDownloadSubSession::GetFileHandleAttributeL() |
|
643 { |
|
644 CLOG_ENTERFN( "CDownloadSubSession::GetFileHandleAttributeL" ) |
|
645 |
|
646 RFile* file = iDownload->GetFileHandleAttributeL(); |
|
647 |
|
648 // transfer to client: store the RFile handle into the package buffer in slot 0 |
|
649 // and complete the message with the RFs handle |
|
650 User::LeaveIfError( file->TransferToClient( Message(), 0) ); |
|
651 } |
|
652 |
|
653 // --------------------------------------------------------- |
|
654 // CDownloadSubSession::SetIntAttributeL |
|
655 // --------------------------------------------------------- |
|
656 // |
|
657 void CDownloadSubSession::SetIntAttributeL() |
|
658 { |
|
659 CLOG_ENTERFN( "CDownloadSubSession::SetIntAttributeL" ) |
|
660 const TInt attr = Message().Int0(); |
|
661 const TInt32 value = Message().Int1(); |
|
662 iDownload->SetIntAttributeL( (THttpDownloadAttrib)attr, value ); |
|
663 } |
|
664 |
|
665 // --------------------------------------------------------- |
|
666 // CDownloadSubSession::SetBoolAttributeL |
|
667 // --------------------------------------------------------- |
|
668 // |
|
669 void CDownloadSubSession::SetBoolAttributeL() |
|
670 { |
|
671 CLOG_ENTERFN( "CDownloadSubSession::SetBoolAttributeL" ) |
|
672 const TInt attr = Message().Int0(); |
|
673 const TBool value = (TBool)Message().Int1(); |
|
674 iDownload->SetBoolAttributeL( (THttpDownloadAttrib)attr, value ); |
|
675 } |
|
676 |
|
677 // --------------------------------------------------------- |
|
678 // CDownloadSubSession::SetStringAttributeL |
|
679 // --------------------------------------------------------- |
|
680 // |
|
681 void CDownloadSubSession::SetStringAttributeL() |
|
682 { |
|
683 CLOG_ENTERFN( "CDownloadSubSession::SetStringAttributeL" ) |
|
684 const TInt attr = Message().Int0(); |
|
685 const TInt moIndex = Message().Int1(); |
|
686 |
|
687 TInt desLen = Message().GetDesLength( 2 ); |
|
688 |
|
689 HBufC* writeBuf = HBufC::NewLC( desLen ); |
|
690 TPtr initptr = writeBuf->Des(); |
|
691 |
|
692 Read( 2, initptr ); |
|
693 |
|
694 if(moIndex != KNonMoIndex) |
|
695 { |
|
696 iDownload->SetStringAttributeL( (THttpDownloadAttrib)attr, moIndex, initptr ); |
|
697 } |
|
698 else |
|
699 { |
|
700 iDownload->SetStringAttributeL( (THttpDownloadAttrib)attr, initptr ); |
|
701 } |
|
702 |
|
703 CleanupStack::PopAndDestroy( writeBuf ); // writeBuf |
|
704 } |
|
705 |
|
706 // --------------------------------------------------------- |
|
707 // CDownloadSubSession::SetString8AttributeL |
|
708 // --------------------------------------------------------- |
|
709 // |
|
710 void CDownloadSubSession::SetString8AttributeL() |
|
711 { |
|
712 CLOG_ENTERFN( "CDownloadSubSession::SetString8AttributeL" ) |
|
713 const TInt attr = Message().Int0(); |
|
714 |
|
715 TInt desLen = Message().GetDesLength( 1 ); |
|
716 |
|
717 HBufC8* writeBuf = HBufC8::NewLC( desLen ); |
|
718 TPtr8 initptr = writeBuf->Des(); |
|
719 |
|
720 Read( 1, initptr ); |
|
721 |
|
722 iDownload->SetStringAttributeL( (THttpDownloadAttrib)attr, initptr ); |
|
723 CleanupStack::PopAndDestroy( writeBuf ); // writeBuf; |
|
724 } |
|
725 |
|
726 // --------------------------------------------------------- |
|
727 // CDownloadSubSession::SetFileHandleAttributeL |
|
728 // --------------------------------------------------------- |
|
729 // |
|
730 void CDownloadSubSession::SetFileHandleAttributeL() |
|
731 { |
|
732 CLOG_ENTERFN( "CDownloadSubSession::SetFileHandleAttributeL" ) |
|
733 |
|
734 RFile* file = new (ELeave) RFile; |
|
735 CleanupStack::PushL( file ); |
|
736 |
|
737 file->AdoptFromClient( Message(), 0, 1 ); |
|
738 |
|
739 // ownership is passed to the engine |
|
740 iDownload->SetFileHandleAttributeL( file ); |
|
741 |
|
742 CleanupStack::Pop( file ); |
|
743 } |
|
744 |
|
745 // --------------------------------------------------------- |
|
746 // CDownloadSubSession::SetDownloadDataAttributeL |
|
747 // --------------------------------------------------------- |
|
748 // |
|
749 void CDownloadSubSession::SetDownloadDataAttributeL() |
|
750 { |
|
751 CLOG_ENTERFN( "CDownloadSubSession::SetDownloadDataAttributeL" ) |
|
752 |
|
753 TInt desLen = Message().GetDesLength( 0 ); |
|
754 |
|
755 HBufC8* writeBuf = HBufC8::NewLC( desLen ); |
|
756 TPtr8 initPtr = writeBuf->Des(); |
|
757 |
|
758 Read( 0, initPtr); |
|
759 |
|
760 // ownership is passed to the engine |
|
761 iDownload->SetDownloadDataAttributeL(writeBuf); |
|
762 |
|
763 CleanupStack::PopAndDestroy(writeBuf); |
|
764 } |
|
765 |
|
766 // --------------------------------------------------------- |
|
767 // CDownloadSubSession::SetTrackDataAttributeL |
|
768 // --------------------------------------------------------- |
|
769 // |
|
770 void CDownloadSubSession::SetTrackDataAttributeL() |
|
771 { |
|
772 CLOG_ENTERFN( "CDownloadSubSession::SetTrackDataAttributeL" ) |
|
773 |
|
774 const TInt index = Message().Int0(); |
|
775 TInt desLen = Message().GetDesLength( 1 ); |
|
776 |
|
777 HBufC8* writeBuf = HBufC8::NewLC( desLen ); |
|
778 TPtr8 initPtr = writeBuf->Des(); |
|
779 |
|
780 Read( 1, initPtr); |
|
781 |
|
782 // ownership is passed to the engine |
|
783 iDownload->SetTrackDataAttributeL(index, writeBuf); |
|
784 |
|
785 CleanupStack::PopAndDestroy(writeBuf); |
|
786 } |
|
787 |
|
788 // --------------------------------------------------------- |
|
789 // CDownloadSubSession::SetDefAttributesL |
|
790 // --------------------------------------------------------- |
|
791 // |
|
792 void CDownloadSubSession::SetDefAttributesL() |
|
793 { |
|
794 CLOG_ENTERFN( "CDownloadSubSession::SetDefAttributesL" ) |
|
795 |
|
796 TInt desLen = Message().GetDesLength( 2 ); |
|
797 |
|
798 HBufC8* attribBuf = HBufC8::NewLC( desLen ); |
|
799 TPtr8 attribs = attribBuf->Des(); |
|
800 |
|
801 Read( 2, attribs ); |
|
802 |
|
803 CDefaultAttrib* attrib = CDefaultAttrib::NewL(); |
|
804 CleanupStack::PushL( attrib ); |
|
805 TDMgrUtils util; |
|
806 util.iPtr.Set( attribs ); |
|
807 util.iCurrent = 0; |
|
808 |
|
809 while( util.NextAttribL( attrib, attribs ) ) |
|
810 { |
|
811 switch( attrib->iType ) |
|
812 { |
|
813 case CDefaultAttrib::EString8: |
|
814 { |
|
815 iDownload->SetStringAttributeL( attrib->iAttribute, |
|
816 attrib->AsTPtrC8L() ); |
|
817 } |
|
818 break; |
|
819 case CDefaultAttrib::EString16: |
|
820 { |
|
821 iDownload->SetStringAttributeL( attrib->iAttribute, |
|
822 attrib->AsTPtrC16L() ); |
|
823 } |
|
824 break; |
|
825 case CDefaultAttrib::EInt: |
|
826 { |
|
827 iDownload->SetIntAttributeL( attrib->iAttribute, |
|
828 attrib->AsTInt32L() ); |
|
829 } |
|
830 break; |
|
831 case CDefaultAttrib::EBool: |
|
832 { |
|
833 iDownload->SetBoolAttributeL( attrib->iAttribute, |
|
834 attrib->AsTBoolL() ); |
|
835 } |
|
836 break; |
|
837 default: |
|
838 break; |
|
839 } |
|
840 } |
|
841 |
|
842 CleanupStack::PopAndDestroy( 2 ); // attribBuf, attrib; |
|
843 } |
|
844 |
|
845 // --------------------------------------------------------- |
|
846 // CDownloadSubSession::Write |
|
847 // --------------------------------------------------------- |
|
848 // |
|
849 void CDownloadSubSession::Write( TInt aParam, TDesC8& aDes ) |
|
850 { |
|
851 CLOG_ENTERFN( "CDownloadSubSession::Write" ) |
|
852 |
|
853 TInt ret = Message().Write( aParam, aDes ); |
|
854 |
|
855 CLOG_WRITE_FORMAT( "CDownloadSubSession::Write ret = %d", ret ); |
|
856 CLOG_WRITE_FORMAT( "CDownloadSubSession = %x", this ); |
|
857 if( ret != KErrNone ) |
|
858 { |
|
859 iSession->PanicClient( EBadDescriptor ); |
|
860 } |
|
861 } |
|
862 |
|
863 // --------------------------------------------------------- |
|
864 // CDownloadSubSession::Write |
|
865 // --------------------------------------------------------- |
|
866 // |
|
867 void CDownloadSubSession::Write( TInt aParam, TDesC16& aDes ) |
|
868 { |
|
869 CLOG_ENTERFN( "CDownloadSubSession::Write" ) |
|
870 |
|
871 TInt ret = Message().Write( aParam, aDes ); |
|
872 |
|
873 if( ret != KErrNone ) |
|
874 { |
|
875 iSession->PanicClient( EBadDescriptor ); |
|
876 } |
|
877 } |
|
878 |
|
879 // --------------------------------------------------------- |
|
880 // CDownloadSubSession::Read |
|
881 // --------------------------------------------------------- |
|
882 // |
|
883 void CDownloadSubSession::Read( TInt aParam, TDes8& aDes ) |
|
884 { |
|
885 CLOG_ENTERFN( "CDownloadSubSession::Read" ) |
|
886 |
|
887 TInt ret = Message().Read( aParam, aDes ); |
|
888 |
|
889 if( ret != KErrNone ) |
|
890 { |
|
891 iSession->PanicClient( EBadDescriptor ); |
|
892 } |
|
893 } |
|
894 |
|
895 // --------------------------------------------------------- |
|
896 // CDownloadSubSession::Read |
|
897 // --------------------------------------------------------- |
|
898 // |
|
899 void CDownloadSubSession::Read( TInt aParam, TDes16& aDes ) |
|
900 { |
|
901 CLOG_ENTERFN( "CDownloadSubSession::Read" ) |
|
902 |
|
903 TInt ret = Message().Read( aParam, aDes ); |
|
904 |
|
905 if( ret != KErrNone ) |
|
906 { |
|
907 iSession->PanicClient( EBadDescriptor ); |
|
908 } |
|
909 } |
|
910 |
|
911 // --------------------------------------------------------- |
|
912 // CDownloadSubSession::IsCurrentDownload |
|
913 // --------------------------------------------------------- |
|
914 // |
|
915 TBool CDownloadSubSession::IsDownload( CHttpDownload* aDownload ) |
|
916 { |
|
917 CLOG_WRITE( "CDownloadSubSession::IsDownload" ); |
|
918 __ASSERT_DEBUG( iDownload, iSession->PanicClient( EBadSubsessionHandle ) ); |
|
919 return (iDownload == aDownload) ? ETrue : EFalse; |
|
920 } |
|
921 |
|
922 // --------------------------------------------------------- |
|
923 // CDownloadSubSession::Handle |
|
924 // --------------------------------------------------------- |
|
925 // |
|
926 TUint CDownloadSubSession::Handle() |
|
927 { |
|
928 CLOG_WRITE( "CDownloadSubSession::Handle" ) |
|
929 return iHandle; |
|
930 } |
|
931 |
|
932 // --------------------------------------------------------- |
|
933 // CDownloadSubSession::SetHandle |
|
934 // --------------------------------------------------------- |
|
935 // |
|
936 void CDownloadSubSession::SetHandle( TUint aHandle ) |
|
937 { |
|
938 CLOG_ENTERFN( "CDownloadSubSession::SetHandle" ) |
|
939 iHandle = aHandle; |
|
940 } |
|
941 |
|
942 // --------------------------------------------------------- |
|
943 // CDownloadSubSession::Download |
|
944 // --------------------------------------------------------- |
|
945 // |
|
946 CHttpDownload* CDownloadSubSession::Download() |
|
947 { |
|
948 CLOG_WRITE( "CDownloadSubSession::Download" ) |
|
949 return iDownload; |
|
950 } |
|
951 |
|
952 // --------------------------------------------------------- |
|
953 // CDownloadSubSession::BufferAttributesL |
|
954 // --------------------------------------------------------- |
|
955 // |
|
956 void CDownloadSubSession::BufferAttributesL() |
|
957 { |
|
958 HBufC8* attr = CreateAttribPackL( ETrue ); |
|
959 TPtr8 ptr = attr->Des(); |
|
960 Write( 0, ptr ); |
|
961 delete attr; |
|
962 } |