|
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 Client interface of Download Mgr Server. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "DownloadMgrLogger.h" |
|
22 #include "DownloadMgrClient.h" |
|
23 #include "DownloadMgrServer.h" |
|
24 #include "DownloadMgrHandler.h" |
|
25 #include "DownloadMgrStart.h" |
|
26 #include "DownloadMgrDef.h" |
|
27 #include "DownloadMgrTransObserver.h" |
|
28 #include "DownloadMgrCod.h" |
|
29 #include "DownloadMgrDefAttrib.h" |
|
30 #include "DownloadDataServ.h" |
|
31 |
|
32 #include <hash.h> |
|
33 #include <e32svr.h> |
|
34 #include <CodDownload.h> |
|
35 #include <AiwGenericParam.h> |
|
36 #include <eikenv.h> |
|
37 #include <HttpFilterCommonStringsExt.h> |
|
38 #include <EscapeUtils.h> |
|
39 |
|
40 // CONSTANTS |
|
41 _LIT8( KTransactionCallback, "TransactionCallback" ); |
|
42 const TInt KInitPrevCodEvent = -1; |
|
43 |
|
44 // GLOBAL FUNCTIONS |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // HashL |
|
48 // Calculates hash value |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void HashL( const TDesC8& aMessage, TDes8& aHash ) |
|
52 { |
|
53 // Calculate the 128 bit (16 byte) hash |
|
54 CMD5* md5Calculator = CMD5::NewL(); |
|
55 CleanupStack::PushL( md5Calculator ); |
|
56 |
|
57 md5Calculator->Reset(); |
|
58 TPtrC8 hash = md5Calculator->Hash( aMessage ); |
|
59 // Now print it as a 32 byte hex number |
|
60 aHash.Zero(); |
|
61 _LIT8(formatStr, "%02x"); |
|
62 for (TInt ii = 0; ii < KRawHashLength; ii++) |
|
63 { |
|
64 TBuf8<2> scratch; |
|
65 scratch.Zero(); |
|
66 scratch.Format( formatStr, hash[ii] ); |
|
67 aHash.Append( scratch ); |
|
68 } |
|
69 CleanupStack::PopAndDestroy( md5Calculator ); // MD5Calculator |
|
70 } |
|
71 |
|
72 |
|
73 /** |
|
74 * |
|
75 * Extension class. |
|
76 * |
|
77 * This class will be used to cache the closed subsession information. |
|
78 * Required subsession information will be stored in this class before closing the subsession. |
|
79 * |
|
80 */ |
|
81 NONSHARABLE_CLASS( CRHttpDlExtension ) : public CBase |
|
82 { |
|
83 public: // Constructors and destructor |
|
84 |
|
85 /** |
|
86 * Two-phased constructor. |
|
87 */ |
|
88 static CRHttpDlExtension* NewL(); |
|
89 |
|
90 /** |
|
91 * Destructor. |
|
92 */ |
|
93 virtual ~CRHttpDlExtension(); |
|
94 |
|
95 protected: // Constructors |
|
96 |
|
97 /** |
|
98 * C++ default constructor. |
|
99 */ |
|
100 CRHttpDlExtension(); |
|
101 |
|
102 /** |
|
103 * By default Symbian 2nd phase constructor is private. |
|
104 */ |
|
105 void ConstructL(); |
|
106 |
|
107 public: |
|
108 |
|
109 /** |
|
110 * Sets the value for a TBool attribute. |
|
111 * @param aAttribute Identifies the attribute to be set. |
|
112 * @param aValue The value to be set. |
|
113 * @return None. |
|
114 */ |
|
115 void SetBoolAttribute( const TUint aAttribute, TBool aValue ); |
|
116 |
|
117 |
|
118 /** |
|
119 * Sets the value for a TInt attribute. |
|
120 * @param aAttribute Identifies the attribute to be set. |
|
121 * @param aValue The value to be set. |
|
122 * @return None. |
|
123 */ |
|
124 void SetIntAttribute( const TUint aAttribute, TInt32 aValue ); |
|
125 |
|
126 /** |
|
127 * Sets the value for a TDesC8 attribute. |
|
128 * @param aAttribute Identifies the attribute to be set. |
|
129 * @param aValue The value to be set. |
|
130 * @return None. |
|
131 */ |
|
132 void SetStringAttribute( const TUint aAttribute, const TDesC8& aValue ); |
|
133 |
|
134 |
|
135 |
|
136 /** |
|
137 * Sets the value for a TDesC16 attribute. |
|
138 * @param aAttribute Identifies the attribute to be set. |
|
139 * @param aMoIndex Identifies the media object index. |
|
140 * @param aValue The value to be set. |
|
141 * @return None. |
|
142 */ |
|
143 |
|
144 void SetStringAttribute( const TUint aAttribute, |
|
145 const TInt32& aMoIndex, |
|
146 const TDesC16& aValue ); |
|
147 |
|
148 |
|
149 /** |
|
150 * Sets the value for a TDesC8 attribute. |
|
151 * @param aAttribute Identifies the attribute to be set. |
|
152 * @param aValue The value to be set. |
|
153 * @return None. |
|
154 */ |
|
155 void SetStringAttribute( const TUint aAttribute, const TDesC16& aValue ); |
|
156 |
|
157 /** |
|
158 * Gets the value for a TBool attribute. |
|
159 * @param aAttribute Identifies the attribute to be retrived. |
|
160 * @param aValue On completion, contains the requested TInt attribute. |
|
161 * @return TBool - attribute found. |
|
162 */ |
|
163 TInt GetBoolAttribute( const TUint aAttribute, TBool& aValue ); |
|
164 |
|
165 /** |
|
166 * Gets the value for a TBool attribute. |
|
167 * @param aAttribute Identifies the attribute to be retrived. |
|
168 * @param aMoIndex Identifies the media object index. |
|
169 * @param aValue On completion, contains the requested TInt attribute. |
|
170 * @return TBool - attribute found. |
|
171 */ |
|
172 TInt GetBoolAttribute( const TUint aAttribute, |
|
173 const TInt32& aMoIndex, |
|
174 TBool& aValue ); |
|
175 /** |
|
176 * Gets the value for a TInt attribute. |
|
177 * @param aAttribute Identifies the attribute to be retrived. |
|
178 * @param aValue On completion, contains the requested TInt attribute. |
|
179 * @return TBool - attribute found. |
|
180 */ |
|
181 TInt GetIntAttribute( const TUint aAttribute, TInt32& aValue ); |
|
182 |
|
183 /** |
|
184 * Gets the value for a TInt attribute. |
|
185 * @param aAttribute Identifies the attribute to be retrived. |
|
186 * @param aMoIndex Identifies the media object index. |
|
187 * @param aValue On completion, contains the requested TInt attribute. |
|
188 * @return TBool - attribute found. |
|
189 */ |
|
190 TInt GetIntAttribute( const TUint aAttribute, |
|
191 const TInt32& aMoIndex, |
|
192 TInt32& aValue ); |
|
193 |
|
194 /** |
|
195 * Gets the value for a TDes8 attribute. |
|
196 * @param aAttribute Identifies the attribute to be retrived. |
|
197 * @param aValue On completion, contains the requested TDes16 attribute. |
|
198 * @return TBool - attribute found. |
|
199 */ |
|
200 TInt GetStringAttribute( const TUint aAttribute, TDes8& aValue ); |
|
201 |
|
202 /** |
|
203 * Gets the value for a TDes8 attribute. |
|
204 * @param aAttribute Identifies the attribute to be retrived. |
|
205 * @param aMoIndex Identifies the media object index. |
|
206 * @param aValue On completion, contains the requested TDes16 attribute. |
|
207 * @return TBool - attribute found. |
|
208 */ |
|
209 TInt GetStringAttribute( const TUint aAttribute, |
|
210 const TInt32& aMoIndex, |
|
211 TDes8& aValue ); |
|
212 |
|
213 /** |
|
214 * Gets the value for a TDes16 attribute. |
|
215 * @param aAttribute Identifies the attribute to be retrived. |
|
216 * @param aValue On completion, contains the requested TDes16 attribute. |
|
217 * @return TBool - attribute found. |
|
218 */ |
|
219 TInt GetStringAttribute( const TUint aAttribute, TDes16& aValue ); |
|
220 |
|
221 /** |
|
222 * Gets the value for a TDes16 attribute. |
|
223 * @param aAttribute Identifies the attribute to be retrived. |
|
224 * @param aMoIndex Identifies the media object index. |
|
225 * @param aValue On completion, contains the requested TDes16 attribute. |
|
226 * @return TBool - attribute found. |
|
227 */ |
|
228 TInt GetStringAttribute( const TUint aAttribute, |
|
229 const TInt32& aMoIndex, |
|
230 TDes16& aValue ); |
|
231 |
|
232 /** |
|
233 * Sets the value for a TInt attribute. |
|
234 * @param aCodDlData The Cod downloaded data. |
|
235 * @return None. |
|
236 */ |
|
237 void SetCodaData( CDownloadDataServ* aCodDlData ); |
|
238 |
|
239 |
|
240 private: // Data |
|
241 |
|
242 //EDlAttrCodDownload, |
|
243 TBool iCodDownload; |
|
244 //EDlAttrCodPdAvailable, |
|
245 TBool iCodPdAvailable; |
|
246 // EDlAttrNoMedia |
|
247 TBool iNoMedia; |
|
248 // EDlAttrHidden |
|
249 TBool iHidden; |
|
250 // EDlAttrProgressive |
|
251 TBool iProgressiveDownload; |
|
252 // EDlAttrPausable |
|
253 TBool iPausable; |
|
254 // EDlAttrDestRemovable |
|
255 TBool iRemovableDest; |
|
256 |
|
257 // EDlAttrState THttpDownloadState |
|
258 TInt32 iDlState; |
|
259 // EDlAttrProgressState |
|
260 TInt32 iProgState; |
|
261 |
|
262 // EDlAttrContentType |
|
263 HBufC8* iContentType; |
|
264 // EDlAttrCurrentUrl |
|
265 HBufC8* iCurrentUrl; |
|
266 // EDlAttrReqUrl |
|
267 HBufC8* iReqUrl; |
|
268 |
|
269 TBuf8<KHashLength> iHashedMsg; |
|
270 |
|
271 // EDlAttrId |
|
272 TInt32 iId; |
|
273 // EDlAttrDownloadedSize |
|
274 TInt32 iDownloadedSize; |
|
275 //iDownloadLength |
|
276 TInt32 iDownloadLength; |
|
277 |
|
278 //EDlAttrName |
|
279 HBufC* iDlName; |
|
280 //EDlAttrDestFilename<KMaxPath> |
|
281 HBufC* iDestFileName; |
|
282 |
|
283 //Album Data |
|
284 CDownloadDataServ* iCodDlData; |
|
285 |
|
286 //Number of media objects |
|
287 TInt32 iNumMediaObjects; |
|
288 |
|
289 //Active Download |
|
290 TInt32 iActiveDownload; |
|
291 |
|
292 //EDlAttrErrorId |
|
293 TInt32 iLastError; |
|
294 //EDlAttrGlobalErrorId |
|
295 TInt32 iGlobalErrorId; |
|
296 }; |
|
297 |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // CRHttpDlExtension::CRHttpDlExtension |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 CRHttpDlExtension::CRHttpDlExtension() |
|
304 { |
|
305 CLOG_CREATE; |
|
306 } |
|
307 |
|
308 // ----------------------------------------------------------------------------- |
|
309 // CRHttpDlExtension::ConstructL |
|
310 // ----------------------------------------------------------------------------- |
|
311 // |
|
312 void CRHttpDlExtension::ConstructL() |
|
313 { |
|
314 CLOG_ENTERFN("CRHttpDlExtension::ConstructL"); |
|
315 iContentType = HBufC8::NewMaxL( KMaxContentTypeLength ); |
|
316 iDestFileName = HBufC::NewMaxL( KMaxPath ); |
|
317 iDlName = HBufC::NewMaxL( KDownloadNameMaxSize ); |
|
318 iCurrentUrl = HBufC8::NewMaxL( KMaxUrlLength ); |
|
319 iReqUrl = HBufC8::NewMaxL( KMaxUrlLength ); |
|
320 iCodDlData = NULL; |
|
321 } |
|
322 |
|
323 // ----------------------------------------------------------------------------- |
|
324 // CRHttpDlExtension::NewL |
|
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 CRHttpDlExtension* CRHttpDlExtension::NewL() |
|
328 { |
|
329 CRHttpDlExtension* self = new(ELeave)CRHttpDlExtension(); |
|
330 CleanupStack::PushL( self ); |
|
331 self->ConstructL(); |
|
332 CleanupStack::Pop(); |
|
333 return self; |
|
334 } |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // CRHttpDlExtension::~CRHttpDlExtension |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 CRHttpDlExtension::~CRHttpDlExtension() |
|
341 { |
|
342 delete iContentType; |
|
343 delete iDestFileName; |
|
344 delete iDlName; |
|
345 delete iCurrentUrl; |
|
346 delete iReqUrl; |
|
347 |
|
348 if(iCodDlData ) |
|
349 { |
|
350 delete iCodDlData; |
|
351 } |
|
352 |
|
353 |
|
354 |
|
355 CLOG_CLOSE; |
|
356 } |
|
357 |
|
358 // ----------------------------------------------------------------------------- |
|
359 // CRHttpDlExtension::SetBoolAttribute |
|
360 // ----------------------------------------------------------------------------- |
|
361 // |
|
362 void CRHttpDlExtension::SetBoolAttribute( const TUint aAttribute, TBool aValue ) |
|
363 { |
|
364 switch( aAttribute ) |
|
365 { |
|
366 case EDlAttrCodDownload: |
|
367 { |
|
368 iCodDownload = aValue; |
|
369 } |
|
370 break; |
|
371 |
|
372 case EDlAttrCodPdAvailable: |
|
373 { |
|
374 iCodPdAvailable = aValue; |
|
375 } |
|
376 break; |
|
377 case EDlAttrNoMedia: |
|
378 { |
|
379 iNoMedia = aValue; |
|
380 } |
|
381 break; |
|
382 |
|
383 case EDlAttrHidden: |
|
384 { |
|
385 iHidden = aValue; |
|
386 } |
|
387 break; |
|
388 |
|
389 case EDlAttrProgressive: |
|
390 { |
|
391 iProgressiveDownload = aValue; |
|
392 } |
|
393 break; |
|
394 |
|
395 case EDlAttrPausable: |
|
396 { |
|
397 iPausable = aValue; |
|
398 } |
|
399 break; |
|
400 |
|
401 case EDlAttrDestRemovable: |
|
402 { |
|
403 iRemovableDest = aValue; |
|
404 } |
|
405 |
|
406 default: |
|
407 { |
|
408 } |
|
409 break; |
|
410 } |
|
411 } |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // CRHttpDlExtension::SetIntAttribute |
|
415 // ----------------------------------------------------------------------------- |
|
416 // |
|
417 void CRHttpDlExtension::SetIntAttribute( const TUint aAttribute, TInt32 aValue ) |
|
418 { |
|
419 switch( aAttribute ) |
|
420 { |
|
421 case EDlAttrDownloadedSize: |
|
422 case EDlAttrMultipleMODownloadedSize: |
|
423 { |
|
424 iDownloadedSize = aValue; |
|
425 } |
|
426 break; |
|
427 |
|
428 case EDlAttrLength: |
|
429 case EDlAttrMultipleMOLength: |
|
430 { |
|
431 iDownloadLength = aValue; |
|
432 } |
|
433 break; |
|
434 |
|
435 case EDlAttrId: |
|
436 { |
|
437 iId = aValue; |
|
438 } |
|
439 |
|
440 case EDlAttrState: |
|
441 { |
|
442 iDlState = (TInt32) aValue; |
|
443 } |
|
444 break; |
|
445 |
|
446 case EDlAttrProgressState: |
|
447 { |
|
448 iProgState = aValue; |
|
449 } |
|
450 break; |
|
451 |
|
452 case EDlAttrNumMediaObjects: |
|
453 { |
|
454 iNumMediaObjects = aValue; |
|
455 } |
|
456 break; |
|
457 |
|
458 case EDlAttrErrorId: |
|
459 { |
|
460 iLastError = aValue; |
|
461 } |
|
462 break; |
|
463 |
|
464 case EDlAttrGlobalErrorId: |
|
465 { |
|
466 iGlobalErrorId = aValue; |
|
467 } |
|
468 break; |
|
469 |
|
470 case EDlAttrActiveDownload: |
|
471 { |
|
472 iActiveDownload = aValue; |
|
473 } |
|
474 break; |
|
475 |
|
476 default: |
|
477 break; |
|
478 } |
|
479 } |
|
480 |
|
481 // --------------------------------------------------------- |
|
482 // CRHttpDlExtension::SetStringAttribute |
|
483 // --------------------------------------------------------- |
|
484 // |
|
485 void CRHttpDlExtension::SetStringAttribute( const TUint aAttribute, const TDesC8& aValue ) |
|
486 { |
|
487 switch( aAttribute ) |
|
488 { |
|
489 case EDlAttrName: |
|
490 { |
|
491 iDlName->Des().Copy(aValue); |
|
492 } |
|
493 break; |
|
494 |
|
495 case EDlAttrDestFilename: |
|
496 { |
|
497 iDestFileName->Des().Copy(aValue); |
|
498 } |
|
499 break; |
|
500 |
|
501 case EDlAttrContentType: |
|
502 { |
|
503 iContentType->Des().Copy(aValue); |
|
504 } |
|
505 break; |
|
506 |
|
507 case EDlAttrCurrentUrl: |
|
508 { |
|
509 iCurrentUrl->Des().Copy(aValue); |
|
510 } |
|
511 break; |
|
512 |
|
513 case EDlAttrReqUrl: |
|
514 { |
|
515 iReqUrl->Des().Copy(aValue); |
|
516 } |
|
517 break; |
|
518 |
|
519 case EDlAttrHashedMsgBody: |
|
520 { |
|
521 iHashedMsg.Copy(aValue); |
|
522 } |
|
523 break; |
|
524 |
|
525 default: |
|
526 break; |
|
527 } |
|
528 } |
|
529 |
|
530 // --------------------------------------------------------- |
|
531 // CRHttpDlExtension::SetStringAttribute |
|
532 // --------------------------------------------------------- |
|
533 // |
|
534 void CRHttpDlExtension::SetStringAttribute( const TUint aAttribute, const TDesC16& aValue ) |
|
535 { |
|
536 switch( aAttribute ) |
|
537 { |
|
538 case EDlAttrName: |
|
539 { |
|
540 iDlName->Des().Copy(aValue); |
|
541 } |
|
542 break; |
|
543 |
|
544 case EDlAttrDestFilename: |
|
545 { |
|
546 iDestFileName->Des().Copy(aValue); |
|
547 } |
|
548 break; |
|
549 |
|
550 case EDlAttrContentType: |
|
551 { |
|
552 iContentType->Des().Copy(aValue); |
|
553 } |
|
554 break; |
|
555 |
|
556 case EDlAttrCurrentUrl: |
|
557 { |
|
558 iCurrentUrl->Des().Copy(aValue); |
|
559 } |
|
560 break; |
|
561 |
|
562 case EDlAttrReqUrl: |
|
563 { |
|
564 iReqUrl->Des().Copy(aValue); |
|
565 } |
|
566 break; |
|
567 |
|
568 case EDlAttrAlbumName: |
|
569 { |
|
570 if (iCodDlData) |
|
571 { |
|
572 iCodDlData->SetNameL(aValue); |
|
573 } |
|
574 } |
|
575 break; |
|
576 |
|
577 default: |
|
578 break; |
|
579 } |
|
580 } |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 // --------------------------------------------------------- |
|
586 // CRHttpDlExtension::GetBoolAttribute |
|
587 // --------------------------------------------------------- |
|
588 // |
|
589 |
|
590 void CRHttpDlExtension::SetStringAttribute( const TUint aAttribute, |
|
591 const TInt32& aMoIndex, |
|
592 const TDesC16& aValue ) |
|
593 { |
|
594 |
|
595 if (!iCodDlData) |
|
596 { |
|
597 return ; |
|
598 } |
|
599 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
|
600 { |
|
601 return; |
|
602 } |
|
603 |
|
604 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
|
605 |
|
606 |
|
607 switch( aAttribute ) |
|
608 { |
|
609 |
|
610 case EDlAttrDestFilename: |
|
611 { |
|
612 mediaData->SetDestFilenameL(aValue); |
|
613 } |
|
614 break; |
|
615 |
|
616 |
|
617 default: |
|
618 break; |
|
619 } |
|
620 } |
|
621 |
|
622 |
|
623 // --------------------------------------------------------- |
|
624 // CRHttpDlExtension::GetBoolAttribute |
|
625 // --------------------------------------------------------- |
|
626 // |
|
627 TInt CRHttpDlExtension::GetBoolAttribute( const TUint aAttribute, TBool& aValue ) |
|
628 { |
|
629 TInt ret( KErrNone ); |
|
630 switch( aAttribute ) |
|
631 { |
|
632 case EDlAttrCodDownload: |
|
633 { |
|
634 aValue = iCodDownload ; |
|
635 } |
|
636 break; |
|
637 |
|
638 case EDlAttrCodPdAvailable: |
|
639 { |
|
640 aValue = iCodPdAvailable ; |
|
641 } |
|
642 break; |
|
643 |
|
644 case EDlAttrNoMedia: |
|
645 { |
|
646 aValue = iNoMedia ; |
|
647 } |
|
648 break; |
|
649 |
|
650 case EDlAttrHidden: |
|
651 { |
|
652 aValue = iHidden ; |
|
653 } |
|
654 break; |
|
655 |
|
656 case EDlAttrProgressive: |
|
657 { |
|
658 aValue = iProgressiveDownload; |
|
659 } |
|
660 break; |
|
661 |
|
662 case EDlAttrPausable: |
|
663 { |
|
664 aValue = iPausable ; |
|
665 } |
|
666 break; |
|
667 |
|
668 case EDlAttrDestRemovable: |
|
669 { |
|
670 aValue = iRemovableDest ; |
|
671 } |
|
672 break; |
|
673 default: |
|
674 { |
|
675 ret = KErrNotFound; |
|
676 } |
|
677 break; |
|
678 } |
|
679 return ret; |
|
680 } |
|
681 |
|
682 |
|
683 |
|
684 // --------------------------------------------------------- |
|
685 // CRHttpDlExtension::GetBoolAttribute |
|
686 // --------------------------------------------------------- |
|
687 // |
|
688 TInt CRHttpDlExtension::GetBoolAttribute( const TUint aAttribute, |
|
689 const TInt32& aMoIndex, |
|
690 TBool& aValue ) |
|
691 { |
|
692 TInt ret( KErrNone ); |
|
693 |
|
694 if (!iCodDlData) |
|
695 { |
|
696 aValue = 0; |
|
697 return ret; |
|
698 } |
|
699 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
|
700 { |
|
701 return KErrArgument; |
|
702 } |
|
703 |
|
704 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
|
705 |
|
706 |
|
707 switch( aAttribute ) |
|
708 { |
|
709 case EDlAttrRedirected: |
|
710 { |
|
711 aValue = mediaData->Redirected(); |
|
712 } |
|
713 break; |
|
714 |
|
715 case EDlAttrPausable: |
|
716 { |
|
717 aValue = mediaData->Pausable(); |
|
718 } |
|
719 break; |
|
720 |
|
721 case EDlAttrProgressive: |
|
722 { |
|
723 aValue = mediaData->ProgressiveDownload(); |
|
724 } |
|
725 break; |
|
726 |
|
727 case EDlAttrDestRemovable: |
|
728 { |
|
729 aValue = mediaData->DesRemovable(); |
|
730 } |
|
731 break; |
|
732 |
|
733 default: |
|
734 { |
|
735 ret = KErrNotFound; |
|
736 } |
|
737 break; |
|
738 } |
|
739 return ret; |
|
740 } |
|
741 |
|
742 // --------------------------------------------------------- |
|
743 // CRHttpDlExtension::GetIntAttribute |
|
744 // --------------------------------------------------------- |
|
745 // |
|
746 TInt CRHttpDlExtension::GetIntAttribute( const TUint aAttribute, TInt32& aValue ) |
|
747 { |
|
748 TInt ret( KErrNone ); |
|
749 switch( aAttribute ) |
|
750 { |
|
751 case EDlAttrDownloadedSize: |
|
752 case EDlAttrMultipleMODownloadedSize: |
|
753 { |
|
754 aValue = iDownloadedSize; |
|
755 } |
|
756 break; |
|
757 |
|
758 case EDlAttrLength: |
|
759 case EDlAttrMultipleMOLength: |
|
760 { |
|
761 aValue = iDownloadLength; |
|
762 } |
|
763 break; |
|
764 |
|
765 case EDlAttrId : |
|
766 { |
|
767 aValue = iId; |
|
768 } |
|
769 break; |
|
770 |
|
771 case EDlAttrState: |
|
772 { |
|
773 aValue = iDlState; |
|
774 } |
|
775 break; |
|
776 |
|
777 case EDlAttrProgressState: |
|
778 { |
|
779 aValue = iProgState; |
|
780 } |
|
781 |
|
782 break; |
|
783 |
|
784 case EDlAttrNumMediaObjects: |
|
785 { |
|
786 aValue = iNumMediaObjects; |
|
787 break; |
|
788 } |
|
789 |
|
790 case EDlAttrErrorId: |
|
791 { |
|
792 aValue = iLastError; |
|
793 } |
|
794 break; |
|
795 |
|
796 case EDlAttrGlobalErrorId: |
|
797 { |
|
798 aValue = iGlobalErrorId; |
|
799 } |
|
800 break; |
|
801 |
|
802 case EDlAttrActiveDownload: |
|
803 { |
|
804 aValue = iActiveDownload; |
|
805 } |
|
806 break; |
|
807 |
|
808 default: |
|
809 { |
|
810 ret = KErrNotFound; |
|
811 } |
|
812 break; |
|
813 } |
|
814 return ret; |
|
815 } |
|
816 |
|
817 // --------------------------------------------------------- |
|
818 // CRHttpDlExtension::GetIntAttribute |
|
819 // --------------------------------------------------------- |
|
820 // |
|
821 TInt CRHttpDlExtension::GetIntAttribute( const TUint aAttribute, |
|
822 const TInt32& aMoIndex, |
|
823 TInt32& aValue ) |
|
824 { |
|
825 TInt ret( KErrNone ); |
|
826 |
|
827 if (!iCodDlData) |
|
828 { |
|
829 aValue = 0; |
|
830 return ret; |
|
831 } |
|
832 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
|
833 { |
|
834 return KErrArgument; |
|
835 } |
|
836 |
|
837 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
|
838 |
|
839 |
|
840 switch( aAttribute ) |
|
841 { |
|
842 |
|
843 case EDlAttrDownloadedSize: |
|
844 { |
|
845 aValue = iDownloadedSize; |
|
846 } |
|
847 break; |
|
848 |
|
849 case EDlAttrLength: |
|
850 { |
|
851 aValue = iDownloadLength; |
|
852 } |
|
853 break; |
|
854 |
|
855 case EDlAttrMultipleMOLength: |
|
856 { |
|
857 aValue = mediaData->Size(); |
|
858 } |
|
859 break; |
|
860 |
|
861 case EDlAttrMultipleMODownloadedSize: |
|
862 { |
|
863 // Calculate downloaded size of current media object from |
|
864 // album downloaded size. |
|
865 aValue = mediaData->DownloadedSize(); |
|
866 } |
|
867 break; |
|
868 |
|
869 case EDlAttrErrorId: |
|
870 { |
|
871 aValue = mediaData->LastErrorId(); |
|
872 } |
|
873 break; |
|
874 |
|
875 case EDlAttrGlobalErrorId: |
|
876 { |
|
877 aValue = mediaData->GlobalErrorId(); |
|
878 } |
|
879 break; |
|
880 |
|
881 case EDlAttrMethod: |
|
882 { |
|
883 aValue = mediaData->Method(); |
|
884 } |
|
885 break; |
|
886 |
|
887 default: |
|
888 { |
|
889 ret = KErrNotFound; |
|
890 |
|
891 } |
|
892 break; |
|
893 } |
|
894 |
|
895 return ret; |
|
896 |
|
897 } |
|
898 |
|
899 |
|
900 // --------------------------------------------------------- |
|
901 // CRHttpDlExtension::GetStringAttribute |
|
902 // --------------------------------------------------------- |
|
903 // |
|
904 TInt CRHttpDlExtension::GetStringAttribute( const TUint aAttribute, TDes8& aValue ) |
|
905 { |
|
906 TInt ret( KErrNone ); |
|
907 switch( aAttribute ) |
|
908 { |
|
909 case EDlAttrContentType: |
|
910 { |
|
911 aValue.Copy(iContentType->Des()); |
|
912 } |
|
913 break; |
|
914 case EDlAttrCurrentUrl: |
|
915 { |
|
916 aValue.Copy(iCurrentUrl->Des()); |
|
917 } |
|
918 break; |
|
919 |
|
920 case EDlAttrName: |
|
921 { |
|
922 aValue.Copy(iDlName->Des()); |
|
923 } |
|
924 break; |
|
925 case EDlAttrDestFilename: |
|
926 { |
|
927 aValue.Copy(iDestFileName->Des()); |
|
928 } |
|
929 break; |
|
930 |
|
931 case EDlAttrReqUrl: |
|
932 { |
|
933 aValue.Copy(iReqUrl->Des()); |
|
934 } |
|
935 break; |
|
936 |
|
937 case EDlAttrHashedMsgBody: |
|
938 { |
|
939 aValue.Copy(iHashedMsg); |
|
940 } |
|
941 break; |
|
942 |
|
943 default: |
|
944 { |
|
945 ret = KErrNotFound; |
|
946 } |
|
947 break; |
|
948 } |
|
949 return ret; |
|
950 } |
|
951 |
|
952 |
|
953 // --------------------------------------------------------- |
|
954 // CRHttpDlExtension::SetCodaData |
|
955 // --------------------------------------------------------- |
|
956 // |
|
957 void CRHttpDlExtension::SetCodaData( CDownloadDataServ* aCodDlData ) |
|
958 { |
|
959 iCodDlData = aCodDlData; |
|
960 } |
|
961 |
|
962 |
|
963 |
|
964 // --------------------------------------------------------- |
|
965 // CRHttpDlExtension::GetStringAttribute |
|
966 // --------------------------------------------------------- |
|
967 // |
|
968 TInt CRHttpDlExtension::GetStringAttribute( const TUint aAttribute, |
|
969 const TInt32& aMoIndex, TDes8& aValue ) |
|
970 { |
|
971 |
|
972 TInt ret( KErrNone ); |
|
973 |
|
974 if (!iCodDlData) |
|
975 { |
|
976 return (KErrNotFound); |
|
977 } |
|
978 |
|
979 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
|
980 { |
|
981 return KErrArgument; |
|
982 } |
|
983 |
|
984 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
|
985 switch( aAttribute ) |
|
986 { |
|
987 case EDlAttrReqUrl: |
|
988 { |
|
989 aValue.Copy(mediaData->Url()); |
|
990 } |
|
991 break; |
|
992 |
|
993 case EDlAttrRedirUlr: |
|
994 { |
|
995 aValue.Copy(mediaData->RedirUrl()); |
|
996 } |
|
997 break; |
|
998 |
|
999 case EDlAttrContentType: |
|
1000 { |
|
1001 aValue.Copy(mediaData->Type()); |
|
1002 } |
|
1003 break; |
|
1004 |
|
1005 default: |
|
1006 { |
|
1007 ret = KErrNotFound; |
|
1008 } |
|
1009 break; |
|
1010 |
|
1011 } |
|
1012 |
|
1013 |
|
1014 return ret; |
|
1015 } |
|
1016 |
|
1017 // --------------------------------------------------------- |
|
1018 // CRHttpDlExtension::GetStringAttribute |
|
1019 // --------------------------------------------------------- |
|
1020 // |
|
1021 TInt CRHttpDlExtension::GetStringAttribute( const TUint aAttribute, TDes16& aValue ) |
|
1022 { |
|
1023 TInt ret( KErrNone ); |
|
1024 switch( aAttribute ) |
|
1025 { |
|
1026 case EDlAttrContentType: |
|
1027 { |
|
1028 aValue.Copy(iContentType->Des()); |
|
1029 } |
|
1030 break; |
|
1031 |
|
1032 case EDlAttrCurrentUrl: |
|
1033 { |
|
1034 aValue.Copy(iCurrentUrl->Des()); |
|
1035 } |
|
1036 break; |
|
1037 |
|
1038 case EDlAttrName: |
|
1039 { |
|
1040 aValue.Copy(iDlName->Des()); |
|
1041 } |
|
1042 break; |
|
1043 |
|
1044 case EDlAttrDestFilename: |
|
1045 { |
|
1046 aValue.Copy(iDestFileName->Des()); |
|
1047 } |
|
1048 break; |
|
1049 |
|
1050 case EDlAttrReqUrl: |
|
1051 { |
|
1052 aValue.Copy(iReqUrl->Des()); |
|
1053 } |
|
1054 break; |
|
1055 |
|
1056 case EDlAttrAlbumName: |
|
1057 { |
|
1058 if (iCodDlData && (iCodDlData->Name().Compare(KNullDesC))) |
|
1059 { |
|
1060 aValue.Copy(iCodDlData->Name()); |
|
1061 } |
|
1062 else |
|
1063 { |
|
1064 aValue.Copy(iDlName->Des()); |
|
1065 } |
|
1066 } |
|
1067 break; |
|
1068 |
|
1069 default: |
|
1070 { |
|
1071 ret = KErrNotFound; |
|
1072 } |
|
1073 break; |
|
1074 } |
|
1075 return ret; |
|
1076 } |
|
1077 |
|
1078 |
|
1079 // --------------------------------------------------------- |
|
1080 // CRHttpDlExtension::GetStringAttribute |
|
1081 // --------------------------------------------------------- |
|
1082 // |
|
1083 TInt CRHttpDlExtension::GetStringAttribute( const TUint aAttribute, |
|
1084 const TInt32& aMoIndex, |
|
1085 TDes16& aValue ) |
|
1086 { |
|
1087 TInt ret( KErrNone ); |
|
1088 |
|
1089 if (!iCodDlData) |
|
1090 { |
|
1091 return (KErrNotFound); |
|
1092 } |
|
1093 |
|
1094 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
|
1095 { |
|
1096 return KErrArgument; |
|
1097 } |
|
1098 |
|
1099 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
|
1100 switch( aAttribute ) |
|
1101 { |
|
1102 case EDlAttrReqUrl: |
|
1103 { |
|
1104 aValue.Copy(mediaData->Url()); |
|
1105 } |
|
1106 break; |
|
1107 |
|
1108 case EDlAttrRedirUlr: |
|
1109 { |
|
1110 aValue.Copy(mediaData->RedirUrl()); |
|
1111 } |
|
1112 break; |
|
1113 |
|
1114 case EDlAttrContentType: |
|
1115 { |
|
1116 aValue.Copy(mediaData->Type()); |
|
1117 } |
|
1118 break; |
|
1119 |
|
1120 case EDlAttrDestFilename: |
|
1121 { |
|
1122 aValue.Copy(mediaData->DestFilename()); |
|
1123 } |
|
1124 break; |
|
1125 |
|
1126 case EDlAttrName: |
|
1127 { |
|
1128 if (aMoIndex == 1) |
|
1129 { |
|
1130 aValue.Copy(iDlName->Des()); |
|
1131 } |
|
1132 else |
|
1133 { |
|
1134 aValue.Copy(mediaData->Name()); |
|
1135 } |
|
1136 } |
|
1137 break; |
|
1138 |
|
1139 default: |
|
1140 { |
|
1141 ret = KErrNotFound; |
|
1142 } |
|
1143 break; |
|
1144 |
|
1145 |
|
1146 } |
|
1147 return ret; |
|
1148 } |
|
1149 |
|
1150 |
|
1151 /** |
|
1152 * Extension class. |
|
1153 */ |
|
1154 NONSHARABLE_CLASS( CRHttpDownloadExtension ) : public CBase |
|
1155 { |
|
1156 public: // Constructors and destructor |
|
1157 |
|
1158 /** |
|
1159 * Two-phased constructor. |
|
1160 */ |
|
1161 static CRHttpDownloadExtension* NewL(); |
|
1162 |
|
1163 /** |
|
1164 * Destructor. |
|
1165 */ |
|
1166 virtual ~CRHttpDownloadExtension(); |
|
1167 |
|
1168 protected: // Constructors |
|
1169 |
|
1170 /** |
|
1171 * C++ default constructor. |
|
1172 */ |
|
1173 CRHttpDownloadExtension(); |
|
1174 |
|
1175 /** |
|
1176 * By default Symbian 2nd phase constructor is private. |
|
1177 */ |
|
1178 void ConstructL(); |
|
1179 |
|
1180 public: |
|
1181 |
|
1182 /** |
|
1183 * Sets event type. |
|
1184 * @param aEventType. |
|
1185 * @return None. |
|
1186 */ |
|
1187 void SetEventType( THttpDownloadState aEventType ); |
|
1188 |
|
1189 /** |
|
1190 * Allocate buffer. |
|
1191 * @param aIsBuffered - if it's true all the buffered attribs must be handled. |
|
1192 * @return HBufC8*. |
|
1193 */ |
|
1194 HBufC8* AllocAttribBufL( TBool aIsBuffered = EFalse ); |
|
1195 |
|
1196 /** |
|
1197 * Unpack event attributes. |
|
1198 * @param aPack Package to be unpacked. |
|
1199 * @return None. |
|
1200 */ |
|
1201 void UnpackAttribL( const TDesC8& aPack ); |
|
1202 |
|
1203 /** |
|
1204 * Sets the value for a TInt attribute. |
|
1205 * @param aAttribute Identifies the attribute to be set. |
|
1206 * @param aValue The value to be set. |
|
1207 * @return None. |
|
1208 */ |
|
1209 void SetIntAttribute( const TUint aAttribute, TInt32 aValue ); |
|
1210 |
|
1211 /** |
|
1212 * Sets the value for a TDesC8 attribute. |
|
1213 * @param aAttribute Identifies the attribute to be set. |
|
1214 * @param aValue The value to be set. |
|
1215 * @return None. |
|
1216 */ |
|
1217 void SetStringAttribute( const TUint aAttribute, const TDesC8& aValue ); |
|
1218 |
|
1219 /** |
|
1220 * Sets the value for a TDesC16 attribute. |
|
1221 * @param aAttribute Identifies the attribute to be set. |
|
1222 * @param aValue The value to be set. |
|
1223 * @return None. |
|
1224 */ |
|
1225 void SetStringAttribute( const TUint aAttribute, const TDesC16& aValue ); |
|
1226 |
|
1227 /** |
|
1228 * Gets the value for a TInt attribute. |
|
1229 * @param aAttribute Identifies the attribute to be retrived. |
|
1230 * @param aValue On completion, contains the requested TInt attribute. |
|
1231 * @return TBool - attribute found. |
|
1232 */ |
|
1233 TBool GetIntAttribute( const TUint aAttribute, TInt32& aValue ); |
|
1234 |
|
1235 /** |
|
1236 * Gets the value for a TDes8 attribute. |
|
1237 * @param aAttribute Identifies the attribute to be retrived. |
|
1238 * @param aValue On completion, contains the requested TDes16 attribute. |
|
1239 * @return TBool - attribute found. |
|
1240 */ |
|
1241 TBool GetStringAttribute( const TUint aAttribute, TDes8& aValue ); |
|
1242 |
|
1243 /** |
|
1244 * Gets the value for a TDes16 attribute. |
|
1245 * @param aAttribute Identifies the attribute to be retrived. |
|
1246 * @param aValue On completion, contains the requested TDes16 attribute. |
|
1247 * @return TBool - attribute found. |
|
1248 */ |
|
1249 TBool GetStringAttribute( const TUint aAttribute, TDes16& aValue ); |
|
1250 |
|
1251 /** |
|
1252 * Unpack event attributes. |
|
1253 * @param aPack Package. |
|
1254 * @return None. |
|
1255 */ |
|
1256 void UnPackEventAttribL( const TDesC8& aPack ); |
|
1257 |
|
1258 public: // Data |
|
1259 |
|
1260 // Event type |
|
1261 THttpDownloadState iEventType; |
|
1262 // EDlAttrId |
|
1263 TInt32 iId; |
|
1264 // EDlAttrUserData |
|
1265 TInt32 iUserData; |
|
1266 // EDlAttrReqUrl |
|
1267 HBufC8* iUrl; |
|
1268 //EDlAttrName |
|
1269 HBufC16* iName; |
|
1270 // EDlAttrDownloadedSize |
|
1271 TInt32 iDownloadedSize; |
|
1272 // EDlAttrLength |
|
1273 TInt32 iTotalSize; |
|
1274 // Media Object Index |
|
1275 TInt32 iMoIndex; |
|
1276 // Indicates that download should be deleted |
|
1277 TBool iToBeDeleted; |
|
1278 // Indicates that COD is in progress. |
|
1279 RHttpDownload::TCodProgressState iCodInProgress; |
|
1280 // Delete COD download when done. |
|
1281 TBool iDeleteCodWhenDone; |
|
1282 //EDlAttrMultipleMODownloadedSize |
|
1283 TInt32 iMoDownloadedSize; |
|
1284 //EDlAttrMultipleMOLength |
|
1285 TInt32 iMoLength; |
|
1286 |
|
1287 CArrayPtrFlat< CDefaultAttrib >* iAttribs; |
|
1288 }; |
|
1289 |
|
1290 // ================= MEMBER FUNCTIONS ======================= |
|
1291 |
|
1292 |
|
1293 // ----------------------------------------------------------------------------- |
|
1294 // CRHttpDownloadExtension::CRHttpDownloadExtension |
|
1295 // ----------------------------------------------------------------------------- |
|
1296 // |
|
1297 CRHttpDownloadExtension::CRHttpDownloadExtension() |
|
1298 :iToBeDeleted( EFalse ) |
|
1299 ,iCodInProgress( RHttpDownload::ENotActive ) |
|
1300 ,iDeleteCodWhenDone( EFalse ) |
|
1301 { |
|
1302 CLOG_CREATE; |
|
1303 } |
|
1304 |
|
1305 // ----------------------------------------------------------------------------- |
|
1306 // CRHttpDownloadExtension::ConstructL |
|
1307 // ----------------------------------------------------------------------------- |
|
1308 // |
|
1309 void CRHttpDownloadExtension::ConstructL() |
|
1310 { |
|
1311 CLOG_ENTERFN("CRHttpDownloadExtension::ConstructL"); |
|
1312 iUrl = HBufC8::NewMaxL( KMaxUrlLength ); |
|
1313 iName = HBufC16::NewL( KDownloadNameMaxSize ); |
|
1314 } |
|
1315 |
|
1316 // ----------------------------------------------------------------------------- |
|
1317 // CRHttpDownloadExtension::NewL |
|
1318 // ----------------------------------------------------------------------------- |
|
1319 // |
|
1320 CRHttpDownloadExtension* CRHttpDownloadExtension::NewL() |
|
1321 { |
|
1322 CRHttpDownloadExtension* self = new(ELeave)CRHttpDownloadExtension(); |
|
1323 CleanupStack::PushL( self ); |
|
1324 self->ConstructL(); |
|
1325 CleanupStack::Pop(); |
|
1326 return self; |
|
1327 } |
|
1328 |
|
1329 // Destructor |
|
1330 CRHttpDownloadExtension::~CRHttpDownloadExtension() |
|
1331 { |
|
1332 delete iUrl; |
|
1333 delete iName; |
|
1334 if( iAttribs ) |
|
1335 { |
|
1336 iAttribs->ResetAndDestroy(); |
|
1337 delete iAttribs; |
|
1338 iAttribs = NULL; |
|
1339 } |
|
1340 CLOG_CLOSE; |
|
1341 } |
|
1342 |
|
1343 // ----------------------------------------------------------------------------- |
|
1344 // CRHttpDownloadExtension::SetEventType |
|
1345 // ----------------------------------------------------------------------------- |
|
1346 // |
|
1347 void CRHttpDownloadExtension::SetEventType( THttpDownloadState aEventType ) |
|
1348 { |
|
1349 CLOG_ENTERFN("CRHttpDownloadExtension::SetEventType"); |
|
1350 iEventType = aEventType; |
|
1351 } |
|
1352 // --------------------------------------------------------- |
|
1353 // CRHttpDownloadExtension::AllocAttribBufL |
|
1354 // --------------------------------------------------------- |
|
1355 // |
|
1356 HBufC8* CRHttpDownloadExtension::AllocAttribBufL( TBool aIsBuffered ) |
|
1357 { |
|
1358 iAttribs = |
|
1359 new (ELeave) CArrayPtrFlat< CDefaultAttrib >( 1 ); |
|
1360 |
|
1361 CDefaultAttrib* attrib = CDefaultAttrib::NewL( EDlAttrUserData, iUserData ); |
|
1362 CleanupStack::PushL( attrib ); |
|
1363 iAttribs->AppendL( attrib ); |
|
1364 CleanupStack::Pop( attrib ); |
|
1365 |
|
1366 attrib = CDefaultAttrib::NewL( EDlAttrMultipleMODownloadedSize, iMoDownloadedSize ); |
|
1367 CleanupStack::PushL( attrib ); |
|
1368 iAttribs->AppendL( attrib ); |
|
1369 CleanupStack::Pop( attrib ); |
|
1370 |
|
1371 attrib = CDefaultAttrib::NewL( EDlAttrDownloadedSize, iDownloadedSize ); |
|
1372 CleanupStack::PushL( attrib ); |
|
1373 iAttribs->AppendL( attrib ); |
|
1374 CleanupStack::Pop( attrib ); |
|
1375 |
|
1376 attrib = CDefaultAttrib::NewL( EDlAttrMultipleMOLength, iMoLength ); |
|
1377 CleanupStack::PushL( attrib ); |
|
1378 iAttribs->AppendL( attrib ); |
|
1379 CleanupStack::Pop( attrib ); |
|
1380 |
|
1381 attrib = CDefaultAttrib::NewL( EDlAttrLength, iTotalSize ); |
|
1382 CleanupStack::PushL( attrib ); |
|
1383 iAttribs->AppendL( attrib ); |
|
1384 CleanupStack::Pop( attrib ); |
|
1385 |
|
1386 if( aIsBuffered ) |
|
1387 { |
|
1388 attrib = CDefaultAttrib::NewL( EDlAttrId, iId ); |
|
1389 CleanupStack::PushL( attrib ); |
|
1390 iAttribs->AppendL( attrib ); |
|
1391 CleanupStack::Pop( attrib ); |
|
1392 |
|
1393 attrib = CDefaultAttrib::NewL( EDlAttrReqUrl, iUrl->Des() ); |
|
1394 CleanupStack::PushL( attrib ); |
|
1395 iAttribs->AppendL( attrib ); |
|
1396 CleanupStack::Pop( attrib ); |
|
1397 } |
|
1398 |
|
1399 HBufC8* buf = TDMgrUtils::PackedAttributesL( iAttribs ); |
|
1400 iAttribs->ResetAndDestroy(); |
|
1401 delete iAttribs; |
|
1402 iAttribs = NULL; |
|
1403 return buf; |
|
1404 } |
|
1405 |
|
1406 // --------------------------------------------------------- |
|
1407 // CRHttpDownloadExtension::UnPackEventAttribL |
|
1408 // --------------------------------------------------------- |
|
1409 // |
|
1410 void CRHttpDownloadExtension::UnPackEventAttribL( const TDesC8& aPack ) |
|
1411 { |
|
1412 TDMgrUtils::UnPackEventAttribL( aPack, iUserData, iMoDownloadedSize, iDownloadedSize, |
|
1413 iMoLength, iTotalSize, iMoIndex |
|
1414 ); |
|
1415 } |
|
1416 |
|
1417 // --------------------------------------------------------- |
|
1418 // CRHttpDownloadExtension::UnpackAttribL |
|
1419 // --------------------------------------------------------- |
|
1420 // |
|
1421 void CRHttpDownloadExtension::UnpackAttribL( const TDesC8& aPack ) |
|
1422 { |
|
1423 CDefaultAttrib* attrib = CDefaultAttrib::NewL(); |
|
1424 CleanupStack::PushL( attrib ); |
|
1425 |
|
1426 TDMgrUtils util; |
|
1427 util.iPtr.Set( aPack ); |
|
1428 util.iCurrent = 0; |
|
1429 |
|
1430 while( util.NextAttribL( attrib, aPack ) ) |
|
1431 { |
|
1432 switch( attrib->iType ) |
|
1433 { |
|
1434 case CDefaultAttrib::EString8: |
|
1435 { |
|
1436 SetStringAttribute( attrib->iAttribute, |
|
1437 attrib->AsTPtrC8L() ); |
|
1438 } |
|
1439 break; |
|
1440 case CDefaultAttrib::EString16: |
|
1441 { |
|
1442 /* |
|
1443 SetStringAttributeL( attrib->iAttribute, |
|
1444 attrib->AsTPtrC16L() ); |
|
1445 */ |
|
1446 } |
|
1447 break; |
|
1448 case CDefaultAttrib::EInt: |
|
1449 { |
|
1450 SetIntAttribute( attrib->iAttribute, |
|
1451 attrib->AsTInt32L() ); |
|
1452 } |
|
1453 break; |
|
1454 case CDefaultAttrib::EBool: |
|
1455 { |
|
1456 /* |
|
1457 SetBoolAttributeL( attrib->iAttribute, |
|
1458 attrib->AsTBoolL() );*/ |
|
1459 } |
|
1460 break; |
|
1461 default: |
|
1462 break; |
|
1463 } |
|
1464 } |
|
1465 |
|
1466 CleanupStack::PopAndDestroy( attrib ); // attrib; |
|
1467 } |
|
1468 |
|
1469 // --------------------------------------------------------- |
|
1470 // CRHttpDownloadExtension::SetIntAttribute |
|
1471 // --------------------------------------------------------- |
|
1472 // |
|
1473 void CRHttpDownloadExtension::SetIntAttribute( const TUint aAttribute, TInt32 aValue ) |
|
1474 { |
|
1475 switch( aAttribute ) |
|
1476 { |
|
1477 case EDlAttrUserData: |
|
1478 { |
|
1479 iUserData = aValue; |
|
1480 } |
|
1481 break; |
|
1482 case EDlAttrDownloadedSize: |
|
1483 { |
|
1484 iDownloadedSize = aValue; |
|
1485 } |
|
1486 break; |
|
1487 case EDlAttrLength: |
|
1488 { |
|
1489 iTotalSize = aValue; |
|
1490 } |
|
1491 break; |
|
1492 case EDlAttrId: |
|
1493 { |
|
1494 iId = aValue; |
|
1495 } |
|
1496 break; |
|
1497 |
|
1498 case EDlAttrMultipleMODownloadedSize: |
|
1499 { |
|
1500 iMoDownloadedSize = aValue; |
|
1501 } |
|
1502 break; |
|
1503 |
|
1504 case EDlAttrMultipleMOLength: |
|
1505 { |
|
1506 iMoLength = aValue; |
|
1507 } |
|
1508 break; |
|
1509 |
|
1510 case EDlAttrActiveDownload: |
|
1511 { |
|
1512 iMoIndex = aValue; |
|
1513 } |
|
1514 break; |
|
1515 |
|
1516 default: |
|
1517 { |
|
1518 } |
|
1519 break; |
|
1520 } |
|
1521 } |
|
1522 // --------------------------------------------------------- |
|
1523 // CRHttpDownloadExtension::SetStringAttribute |
|
1524 // --------------------------------------------------------- |
|
1525 // |
|
1526 void CRHttpDownloadExtension::SetStringAttribute( const TUint aAttribute, const TDesC8& aValue ) |
|
1527 { |
|
1528 switch( aAttribute ) |
|
1529 { |
|
1530 case EDlAttrReqUrl: |
|
1531 { |
|
1532 iUrl->Des().Copy( aValue ); |
|
1533 } |
|
1534 break; |
|
1535 default: |
|
1536 { |
|
1537 } |
|
1538 break; |
|
1539 } |
|
1540 } |
|
1541 |
|
1542 // --------------------------------------------------------- |
|
1543 // CRHttpDownloadExtension::SetStringAttribute |
|
1544 // --------------------------------------------------------- |
|
1545 // |
|
1546 void CRHttpDownloadExtension::SetStringAttribute( const TUint aAttribute, const TDesC16& aValue ) |
|
1547 { |
|
1548 switch( aAttribute ) |
|
1549 { |
|
1550 case EDlAttrName: |
|
1551 { |
|
1552 iName->Des().Copy( aValue ); |
|
1553 } |
|
1554 break; |
|
1555 default: |
|
1556 { |
|
1557 } |
|
1558 break; |
|
1559 } |
|
1560 } |
|
1561 |
|
1562 // --------------------------------------------------------- |
|
1563 // CRHttpDownloadExtension::GetIntAttribute |
|
1564 // --------------------------------------------------------- |
|
1565 // |
|
1566 TBool CRHttpDownloadExtension::GetIntAttribute( const TUint aAttribute, TInt32& aValue ) |
|
1567 { |
|
1568 TBool ret( ETrue ); |
|
1569 switch( aAttribute ) |
|
1570 { |
|
1571 case EDlAttrUserData: |
|
1572 { |
|
1573 aValue = iUserData; |
|
1574 } |
|
1575 break; |
|
1576 case EDlAttrDownloadedSize: |
|
1577 { |
|
1578 aValue = iDownloadedSize; |
|
1579 } |
|
1580 break; |
|
1581 case EDlAttrLength: |
|
1582 { |
|
1583 aValue = iTotalSize; |
|
1584 } |
|
1585 break; |
|
1586 case EDlAttrId: |
|
1587 { |
|
1588 aValue = iId; |
|
1589 } |
|
1590 break; |
|
1591 |
|
1592 case EDlAttrMultipleMODownloadedSize: |
|
1593 { |
|
1594 aValue = iMoDownloadedSize; |
|
1595 } |
|
1596 break; |
|
1597 |
|
1598 case EDlAttrMultipleMOLength: |
|
1599 { |
|
1600 aValue = iMoLength; |
|
1601 } |
|
1602 break; |
|
1603 |
|
1604 case EDlAttrActiveDownload: |
|
1605 { |
|
1606 aValue = iMoIndex; |
|
1607 } |
|
1608 break; |
|
1609 |
|
1610 default: |
|
1611 { |
|
1612 ret = EFalse; |
|
1613 } |
|
1614 break; |
|
1615 } |
|
1616 return ret; |
|
1617 } |
|
1618 |
|
1619 // --------------------------------------------------------- |
|
1620 // CRHttpDownloadExtension::GetIntAttribute |
|
1621 // --------------------------------------------------------- |
|
1622 // |
|
1623 TBool CRHttpDownloadExtension::GetStringAttribute( const TUint aAttribute, TDes8& aValue ) |
|
1624 { |
|
1625 TBool ret( ETrue ); |
|
1626 switch( aAttribute ) |
|
1627 { |
|
1628 case EDlAttrReqUrl: |
|
1629 { |
|
1630 aValue.Copy( iUrl->Des() ); |
|
1631 } |
|
1632 break; |
|
1633 default: |
|
1634 { |
|
1635 ret = EFalse; |
|
1636 } |
|
1637 break; |
|
1638 } |
|
1639 return ret; |
|
1640 } |
|
1641 |
|
1642 |
|
1643 // --------------------------------------------------------- |
|
1644 // CRHttpDownloadExtension::GetIntAttribute |
|
1645 // --------------------------------------------------------- |
|
1646 // |
|
1647 TBool CRHttpDownloadExtension::GetStringAttribute( const TUint aAttribute, TDes16& aValue ) |
|
1648 { |
|
1649 TBool ret( ETrue ); |
|
1650 switch( aAttribute ) |
|
1651 { |
|
1652 case EDlAttrReqUrl: |
|
1653 { |
|
1654 aValue.Copy( iUrl->Des() ); |
|
1655 } |
|
1656 break; |
|
1657 case EDlAttrName: |
|
1658 { |
|
1659 aValue.Copy( iName->Des() ); |
|
1660 if(!aValue.Length()) |
|
1661 return EFalse; |
|
1662 } |
|
1663 break; |
|
1664 |
|
1665 default: |
|
1666 { |
|
1667 ret = EFalse; |
|
1668 } |
|
1669 break; |
|
1670 } |
|
1671 return ret; |
|
1672 } |
|
1673 //========================================================================================== |
|
1674 |
|
1675 #ifdef DEAD_CODE |
|
1676 // --------------------------------------------------------- |
|
1677 // RHttpDownload::AllocEventAttribBufL |
|
1678 // --------------------------------------------------------- |
|
1679 // |
|
1680 HBufC8* RHttpDownload::AllocEventAttribBufL() |
|
1681 { |
|
1682 return iExtension->AllocAttribBufL(); |
|
1683 } |
|
1684 #endif |
|
1685 |
|
1686 // --------------------------------------------------------- |
|
1687 // RHttpDownload::UnpackEventAttribL |
|
1688 // --------------------------------------------------------- |
|
1689 // |
|
1690 void RHttpDownload::UnpackEventAttribL( const TDesC8& aPack ) |
|
1691 { |
|
1692 return iExtension->UnPackEventAttribL( aPack ); |
|
1693 } |
|
1694 |
|
1695 // --------------------------------------------------------- |
|
1696 // RHttpDownload::CreateL |
|
1697 // --------------------------------------------------------- |
|
1698 // |
|
1699 void RHttpDownload::CreateL( const TDesC8& aUrl, const TPtr8 aPackedAttribs ) |
|
1700 { |
|
1701 CLOG_ENTERFN( "RHttpDownload::CreateL" ) |
|
1702 |
|
1703 iExtension = CRHttpDownloadExtension::NewL(); |
|
1704 iDlExtension = CRHttpDlExtension::NewL(); |
|
1705 |
|
1706 CLOG_ATTACH( iExtension, this ); |
|
1707 |
|
1708 iDownloadHandler = new (ELeave) CDownloadMgrHandler ( iDownloadMgr, this ); |
|
1709 CLOG_ATTACH( iDownloadHandler, this ); |
|
1710 // 0st param - the URL needs to be downloaded |
|
1711 // 1st param - will contain the unique handle |
|
1712 // 2nd param - packed attributes |
|
1713 TPckg<TInt> handlePckg( iHandle ); |
|
1714 |
|
1715 User::LeaveIfError( CreateSubSession( *iDownloadMgr, |
|
1716 EHttpDownloadMgrCreateDownload, |
|
1717 TIpcArgs( &aUrl, &handlePckg, &aPackedAttribs ) ) ); |
|
1718 |
|
1719 iClosed = EFalse; |
|
1720 |
|
1721 iDownloadHandler->StartL(); |
|
1722 BufferAttributesL(); |
|
1723 |
|
1724 CLOG_NAME_2( _L("Download_%d_%d"), |
|
1725 iDownloadMgr->SessionId(), |
|
1726 iExtension->iId ); |
|
1727 } |
|
1728 |
|
1729 // --------------------------------------------------------- |
|
1730 // RHttpDownload::AttachL |
|
1731 // --------------------------------------------------------- |
|
1732 // |
|
1733 void RHttpDownload::AttachL( TInt aHandle ) |
|
1734 { |
|
1735 CLOG_ENTERFN( "RHttpDownload::AttachL" ) |
|
1736 |
|
1737 iExtension = CRHttpDownloadExtension::NewL(); |
|
1738 iDlExtension = CRHttpDlExtension::NewL(); |
|
1739 iDownloadHandler = new (ELeave) CDownloadMgrHandler ( iDownloadMgr, this ); |
|
1740 // 0st param - application UID |
|
1741 // 1st param - a handle idetifies a download subsession in server |
|
1742 TPckg<TUid> uidPckg( iDownloadMgr->iAppUid ); |
|
1743 |
|
1744 User::LeaveIfError( CreateSubSession( *iDownloadMgr, |
|
1745 EHttpDownloadAttach, |
|
1746 TIpcArgs( &uidPckg, aHandle ) ) ); |
|
1747 |
|
1748 iHandle = aHandle; |
|
1749 iClosed = EFalse; |
|
1750 iDownloadHandler->StartL(); |
|
1751 |
|
1752 BufferAttributesL(); |
|
1753 |
|
1754 CLOG_NAME_2( _L("Download_%d_%d"), |
|
1755 iDownloadMgr->SessionId(), |
|
1756 iExtension->iId ); |
|
1757 } |
|
1758 |
|
1759 // --------------------------------------------------------- |
|
1760 // RHttpDownload::AttachToDownloadL |
|
1761 // --------------------------------------------------------- |
|
1762 // |
|
1763 void RHttpDownload::AttachToDownloadL( const TInt32 aDlId ) |
|
1764 { |
|
1765 CLOG_ENTERFN( "RHttpDownload::AttachToDownloadL" ) |
|
1766 |
|
1767 iExtension = CRHttpDownloadExtension::NewL(); |
|
1768 iDlExtension = CRHttpDlExtension::NewL(); |
|
1769 iDownloadHandler = new (ELeave) CDownloadMgrHandler ( iDownloadMgr, this ); |
|
1770 // 0st param - application UID |
|
1771 // 1st param - a handle idetifies a download subsession in server |
|
1772 TPckg<TInt> handlePckg( iHandle ); |
|
1773 User::LeaveIfError( CreateSubSession( *iDownloadMgr, |
|
1774 EHttpDownloadAttachToDownload, |
|
1775 TIpcArgs( aDlId, &handlePckg ) ) ); |
|
1776 iClosed = EFalse; |
|
1777 iDownloadHandler->StartL(); |
|
1778 } |
|
1779 |
|
1780 // --------------------------------------------------------- |
|
1781 // RHttpDownload::Close |
|
1782 // --------------------------------------------------------- |
|
1783 // |
|
1784 void RHttpDownload::Close() |
|
1785 { |
|
1786 CLOG_WRITE_FORMAT( "RHttpDownload::Close - iDownloadHandler %d", iDownloadHandler ); |
|
1787 |
|
1788 if(iWait) |
|
1789 { |
|
1790 delete iWait; |
|
1791 iWait = NULL; |
|
1792 } |
|
1793 |
|
1794 if ( iDownloadHandler ) |
|
1795 { |
|
1796 CLOG_WRITE( "Cancel handler" ); |
|
1797 iDownloadHandler->Cancel(); |
|
1798 CLOG_WRITE( "handler cancelled" ); |
|
1799 delete iDownloadHandler; |
|
1800 iDownloadHandler = NULL; |
|
1801 } |
|
1802 |
|
1803 if( iExtension ) |
|
1804 { |
|
1805 delete iExtension; |
|
1806 iExtension = NULL; |
|
1807 } |
|
1808 |
|
1809 if( iDlExtension ) |
|
1810 { |
|
1811 delete iDlExtension; |
|
1812 iDlExtension = NULL; |
|
1813 } |
|
1814 |
|
1815 DeleteTransaction(); |
|
1816 iClosed = ETrue; |
|
1817 |
|
1818 if( iCodDownload ) |
|
1819 { |
|
1820 SDMgrCodUserData* ptr = (SDMgrCodUserData*)iCodDownload->UserData(); |
|
1821 if( ptr ) |
|
1822 { |
|
1823 delete ptr; |
|
1824 } |
|
1825 delete iCodDownload; |
|
1826 iCodDownload = NULL; |
|
1827 iDownloadMgr->DecrementEventPriorityFlag(); |
|
1828 } |
|
1829 |
|
1830 if( iCodObserver ) |
|
1831 { |
|
1832 delete iCodObserver; |
|
1833 iCodObserver = NULL; |
|
1834 } |
|
1835 |
|
1836 CLOG_WRITE( "Close subsession" ); |
|
1837 RSubSessionBase::CloseSubSession( EHttpDownloadClose ); |
|
1838 |
|
1839 CLOG_CLOSE; |
|
1840 } |
|
1841 |
|
1842 // --------------------------------------------------------- |
|
1843 // RHttpDownload::CloseSubSession |
|
1844 // --------------------------------------------------------- |
|
1845 // |
|
1846 void RHttpDownload::CloseSubSession() |
|
1847 { |
|
1848 CLOG_WRITE_FORMAT( "RHttpDownload::CloseSubSession - iDownloadHandler %d", iDownloadHandler ); |
|
1849 |
|
1850 if(iClosedSubSession) |
|
1851 { |
|
1852 return; |
|
1853 } |
|
1854 |
|
1855 TInt32 downloadState(0); |
|
1856 GetIntAttribute(EDlAttrState, downloadState); |
|
1857 if( EHttpDlCompleted != downloadState ) |
|
1858 { |
|
1859 return; |
|
1860 } |
|
1861 |
|
1862 if ( iDownloadHandler ) |
|
1863 { |
|
1864 CLOG_WRITE( "Cancel handler" ); |
|
1865 iDownloadHandler->Cancel(); |
|
1866 CLOG_WRITE( "handler cancelled" ); |
|
1867 delete iDownloadHandler; |
|
1868 iDownloadHandler = NULL; |
|
1869 } |
|
1870 |
|
1871 DeleteTransaction(); |
|
1872 |
|
1873 if( iCodDownload ) |
|
1874 { |
|
1875 SDMgrCodUserData* ptr = (SDMgrCodUserData*)iCodDownload->UserData(); |
|
1876 if( ptr ) |
|
1877 { |
|
1878 delete ptr; |
|
1879 } |
|
1880 delete iCodDownload; |
|
1881 iCodDownload = NULL; |
|
1882 iDownloadMgr->DecrementEventPriorityFlag(); |
|
1883 } |
|
1884 |
|
1885 if( iCodObserver ) |
|
1886 { |
|
1887 delete iCodObserver; |
|
1888 iCodObserver = NULL; |
|
1889 } |
|
1890 |
|
1891 CLOG_WRITE( "Close subsession" ); |
|
1892 RSubSessionBase::CloseSubSession( EHttpDownloadCloseCompleted ); |
|
1893 iClosedSubSession = ETrue; |
|
1894 } |
|
1895 |
|
1896 // --------------------------------------------------------- |
|
1897 // RHttpDownload::SaveDownloadInfoL |
|
1898 // --------------------------------------------------------- |
|
1899 // |
|
1900 void RHttpDownload::SaveDownloadInfoL() |
|
1901 { |
|
1902 |
|
1903 CLOG_WRITE_FORMAT( "-->RHttpDownload::SaveDownloadInfoL 0x%x", this ); |
|
1904 |
|
1905 __ASSERT_DEBUG( iDlExtension, DMPanic( KErrGeneral ) ); |
|
1906 |
|
1907 |
|
1908 TBool bCodDownLoad; |
|
1909 GetBoolAttribute(EDlAttrCodDownload, bCodDownLoad); |
|
1910 iDlExtension->SetBoolAttribute( EDlAttrCodDownload, bCodDownLoad ); |
|
1911 |
|
1912 TInt32 downloadedSize(0); |
|
1913 GetIntAttribute(EDlAttrMultipleMODownloadedSize, downloadedSize); |
|
1914 iDlExtension->SetIntAttribute( EDlAttrMultipleMODownloadedSize, downloadedSize ); |
|
1915 |
|
1916 TInt32 downloadLen; |
|
1917 GetIntAttribute(EDlAttrMultipleMOLength, downloadLen); |
|
1918 iDlExtension->SetIntAttribute( EDlAttrMultipleMOLength, downloadLen ); |
|
1919 |
|
1920 TInt32 id; |
|
1921 GetIntAttribute(EDlAttrId, id); |
|
1922 iDlExtension->SetIntAttribute( EDlAttrId, id ); |
|
1923 |
|
1924 |
|
1925 TInt32 state; |
|
1926 GetIntAttribute(EDlAttrState, state); |
|
1927 iDlExtension->SetIntAttribute( EDlAttrState, state ); |
|
1928 |
|
1929 |
|
1930 TInt32 progressState; |
|
1931 GetIntAttribute(EDlAttrProgressState, progressState); |
|
1932 iDlExtension->SetIntAttribute( EDlAttrProgressState, progressState ); |
|
1933 |
|
1934 |
|
1935 if(bCodDownLoad && iCodDownload ) |
|
1936 { |
|
1937 HBufC8* mediaInfo8 = NULL; |
|
1938 TRAPD( err, mediaInfo8 = iCodDownload->UpdatedDownloadDataL() ); |
|
1939 if ((err == KErrNone) && mediaInfo8) |
|
1940 { |
|
1941 CDownloadDataServ *CodDlData = CDownloadDataServ::NewL(*mediaInfo8); |
|
1942 iDlExtension->SetCodaData(CodDlData); |
|
1943 delete mediaInfo8; |
|
1944 TInt count = CodDlData->Count(); |
|
1945 |
|
1946 |
|
1947 iDlExtension->SetIntAttribute( EDlAttrNumMediaObjects, count ); |
|
1948 |
|
1949 for(TInt index = 1; index <= count; index++) |
|
1950 { |
|
1951 HBufC* destFileName = HBufC::NewL( KMaxPath ); |
|
1952 TPtr pFileName( destFileName->Des() ); |
|
1953 |
|
1954 err = SendReceive( EHttpDownloadGetStringAttribute, |
|
1955 TIpcArgs( EDlAttrDestFilename,index, &pFileName )); |
|
1956 |
|
1957 iDlExtension->SetStringAttribute( EDlAttrDestFilename, index, pFileName ); |
|
1958 delete destFileName; |
|
1959 |
|
1960 } |
|
1961 |
|
1962 } |
|
1963 } |
|
1964 |
|
1965 |
|
1966 |
|
1967 |
|
1968 |
|
1969 TBool bCodPdAvailable; |
|
1970 GetBoolAttribute(EDlAttrCodPdAvailable, bCodPdAvailable); |
|
1971 iDlExtension->SetBoolAttribute( EDlAttrCodPdAvailable, bCodPdAvailable ); |
|
1972 |
|
1973 TBool bNoMedia; |
|
1974 GetBoolAttribute(EDlAttrNoMedia, bNoMedia); |
|
1975 iDlExtension->SetBoolAttribute( EDlAttrNoMedia, bNoMedia ); |
|
1976 |
|
1977 TBool bHidden; |
|
1978 GetBoolAttribute(EDlAttrHidden, bHidden); |
|
1979 iDlExtension->SetBoolAttribute( EDlAttrHidden, bHidden ); |
|
1980 |
|
1981 TBool bProgressive; |
|
1982 GetBoolAttribute(EDlAttrProgressive, bProgressive); |
|
1983 iDlExtension->SetBoolAttribute( EDlAttrProgressive, bProgressive ); |
|
1984 |
|
1985 |
|
1986 TBool bPausable; |
|
1987 GetBoolAttribute(EDlAttrPausable, bPausable); |
|
1988 iDlExtension->SetBoolAttribute( EDlAttrPausable, bPausable ); |
|
1989 |
|
1990 TBool bRemovableDest; |
|
1991 GetBoolAttribute(EDlAttrDestRemovable, bRemovableDest); |
|
1992 iDlExtension->SetBoolAttribute( EDlAttrDestRemovable, bRemovableDest ); |
|
1993 |
|
1994 // |
|
1995 |
|
1996 iDlExtension->SetIntAttribute(EDlAttrActiveDownload, KNonMoIndex); |
|
1997 |
|
1998 HBufC8* contentType = HBufC8::NewL( KMaxContentTypeLength ); |
|
1999 TPtr8 pContentType( contentType->Des() ); |
|
2000 TInt err = SendReceive( EHttpDownloadGetString8Attribute, |
|
2001 TIpcArgs( EDlAttrContentType,KNonMoIndex, &pContentType )); |
|
2002 iDlExtension->SetStringAttribute( EDlAttrContentType, pContentType ); |
|
2003 delete contentType; |
|
2004 |
|
2005 HBufC* attrName = HBufC::NewL( KDownloadNameMaxSize ); |
|
2006 TPtr pName( attrName->Des() ); |
|
2007 err = SendReceive( EHttpDownloadGetStringAttribute, |
|
2008 TIpcArgs( EDlAttrName,KNonMoIndex, &pName )); |
|
2009 iDlExtension->SetStringAttribute( EDlAttrName, pName ); |
|
2010 delete attrName; |
|
2011 |
|
2012 HBufC* destFileName = HBufC::NewL( KMaxPath ); |
|
2013 TPtr pFileName( destFileName->Des() ); |
|
2014 err = SendReceive( EHttpDownloadGetStringAttribute, |
|
2015 TIpcArgs( EDlAttrDestFilename,KNonMoIndex, &pFileName )); |
|
2016 iDlExtension->SetStringAttribute( EDlAttrDestFilename, pFileName ); |
|
2017 delete destFileName; |
|
2018 // |
|
2019 |
|
2020 HBufC8* currentURL = HBufC8::NewL( KMaxUrlLength ); |
|
2021 TPtr8 pCurrentURL( currentURL->Des() ); |
|
2022 err = SendReceive( EHttpDownloadGetString8Attribute, |
|
2023 TIpcArgs( EDlAttrCurrentUrl,KNonMoIndex, &pCurrentURL )); |
|
2024 iDlExtension->SetStringAttribute( EDlAttrCurrentUrl, pCurrentURL ); |
|
2025 delete currentURL; |
|
2026 |
|
2027 HBufC8* reqURL = HBufC8::NewL( KMaxUrlLength ); |
|
2028 TPtr8 pReqURL(reqURL->Des()); |
|
2029 err = SendReceive( EHttpDownloadGetString8Attribute, |
|
2030 TIpcArgs( EDlAttrReqUrl,KNonMoIndex, &pReqURL )); |
|
2031 iDlExtension->SetStringAttribute( EDlAttrReqUrl, pReqURL ); |
|
2032 delete reqURL; |
|
2033 |
|
2034 TBuf8<KHashLength> hash_owned; |
|
2035 GetStringAttribute( EDlAttrHashedMsgBody, hash_owned ); |
|
2036 iDlExtension->SetStringAttribute( EDlAttrHashedMsgBody, hash_owned ); |
|
2037 |
|
2038 GetIntAttribute(EDlAttrDownloadedSize, downloadedSize); |
|
2039 iDlExtension->SetIntAttribute( EDlAttrDownloadedSize, downloadedSize ); |
|
2040 |
|
2041 GetIntAttribute(EDlAttrLength, downloadLen); |
|
2042 iDlExtension->SetIntAttribute( EDlAttrLength, downloadLen ); |
|
2043 |
|
2044 TInt32 errorId; |
|
2045 GetIntAttribute( EDlAttrErrorId, errorId); |
|
2046 iDlExtension->SetIntAttribute( EDlAttrErrorId, errorId ); |
|
2047 |
|
2048 TInt32 globalErrorId; |
|
2049 GetIntAttribute( EDlAttrGlobalErrorId, globalErrorId ); |
|
2050 iDlExtension->SetIntAttribute( EDlAttrGlobalErrorId, globalErrorId ); |
|
2051 |
|
2052 |
|
2053 //TInt32 activeIndex; |
|
2054 //GetIntAttribute( EDlAttrNumMediaObjects, activeIndex ); |
|
2055 //iDlExtension->SetIntAttribute(EDlAttrActiveDownload, activeIndex); |
|
2056 //iDlExtension->SetIntAttribute(EDlAttrActiveDownload, KFirstMoIndex); |
|
2057 //CLOG_WRITE_FORMAT( "<--RHttpDownload::SaveDownloadInfoL 0x%x", this ); |
|
2058 |
|
2059 HBufC* albumName = HBufC::NewL( KDownloadNameMaxSize ); |
|
2060 TPtr pAlbumName( albumName->Des() ); |
|
2061 err = SendReceive( EHttpDownloadGetStringAttribute, |
|
2062 TIpcArgs( EDlAttrAlbumName, KNonMoIndex, &pAlbumName )); |
|
2063 iDlExtension->SetStringAttribute( EDlAttrAlbumName, pAlbumName ); |
|
2064 delete albumName; |
|
2065 |
|
2066 CLOG_WRITE_FORMAT( "<--RHttpDownload::SaveDownloadInfoL 0x%x", this ); |
|
2067 } |
|
2068 |
|
2069 // --------------------------------------------------------- |
|
2070 // RHttpDownload::RHttpDownload |
|
2071 // --------------------------------------------------------- |
|
2072 // |
|
2073 RHttpDownload::RHttpDownload( RHttpDownloadMgr* aServer ) |
|
2074 { |
|
2075 CLOG_CREATE; |
|
2076 |
|
2077 // Reset data members as R-objects are not zero'd. |
|
2078 iDownloadHandler = NULL; |
|
2079 iExtension = NULL; |
|
2080 iDownloadMgr = aServer; |
|
2081 iHandle = 0; |
|
2082 iTransactionObserver = NULL; |
|
2083 iHttpTransaction = NULL; |
|
2084 iCodDownload = NULL; |
|
2085 iCodObserver = NULL; |
|
2086 iClientSideDownload = EFalse; |
|
2087 iClosedSubSession = EFalse; |
|
2088 iDlExtension = NULL; |
|
2089 iWait = NULL; |
|
2090 iASReady = EFalse; |
|
2091 } |
|
2092 |
|
2093 // --------------------------------------------------------- |
|
2094 // RHttpDownload::Start |
|
2095 // --------------------------------------------------------- |
|
2096 // |
|
2097 EXPORT_C TInt RHttpDownload::Start() |
|
2098 { |
|
2099 CLOG_ENTERFN( "RHttpDownload::Start" ) |
|
2100 |
|
2101 TRAPD( err, DoStartL() ); |
|
2102 |
|
2103 if( err ) |
|
2104 { |
|
2105 DeleteTransaction(); |
|
2106 } |
|
2107 |
|
2108 return err; |
|
2109 } |
|
2110 |
|
2111 // --------------------------------------------------------- |
|
2112 // RHttpDownload::DoStartL |
|
2113 // --------------------------------------------------------- |
|
2114 // |
|
2115 void RHttpDownload::DoStartL() |
|
2116 { |
|
2117 CLOG_ENTERFN( "RHttpDownload::DoStartL" ) |
|
2118 if( iCodDownload ) |
|
2119 { |
|
2120 TBool isCod( EFalse ); |
|
2121 GetBoolAttribute( EDlAttrCodDownload, isCod ); |
|
2122 SDMgrCodUserData* ptr =(SDMgrCodUserData*)( iCodDownload->UserData() ); |
|
2123 |
|
2124 if( isCod ) |
|
2125 { |
|
2126 // processing of start command depends the state of COD Handler |
|
2127 if( KInitPrevCodEvent == ptr->iPrevCodEvent ) |
|
2128 { |
|
2129 DoStartCodL(); |
|
2130 } |
|
2131 else if( MCodDownloadObserver::EEndLoad == ptr->iPrevCodEvent ) |
|
2132 { |
|
2133 const TCodDownloadProgress& progress = iCodDownload->Progress(); |
|
2134 if(progress.iState == TCodDownloadProgress::EPaused) |
|
2135 { |
|
2136 } |
|
2137 else |
|
2138 { |
|
2139 iCodDownload->ServiceFlowL(); |
|
2140 return; |
|
2141 } |
|
2142 } |
|
2143 else |
|
2144 { |
|
2145 const TCodDownloadProgress& progress = iCodDownload->Progress(); |
|
2146 if(progress.iState == TCodDownloadProgress::EPaused) |
|
2147 { |
|
2148 } |
|
2149 else |
|
2150 { |
|
2151 // Already beeing downloaded |
|
2152 THttpDownloadEvent event; |
|
2153 event.iDownloadState = EHttpDlAlreadyRunning; |
|
2154 event.iProgressState = EHttpProgNone; |
|
2155 iDownloadMgr->BroadcastEvent( *this, event ); |
|
2156 return; |
|
2157 } |
|
2158 } |
|
2159 } |
|
2160 } |
|
2161 // start active object to get events |
|
2162 CLOG_WRITE_FORMAT( "Start handler of 0x%x", this ); |
|
2163 iDownloadHandler->StartL(); |
|
2164 User::LeaveIfError( SendReceive( EHttpDownloadStart, TIpcArgs() ) ); |
|
2165 } |
|
2166 |
|
2167 // --------------------------------------------------------- |
|
2168 // RHttpDownload::DoStartCodL |
|
2169 // --------------------------------------------------------- |
|
2170 // |
|
2171 void RHttpDownload::DoStartCodL() |
|
2172 { |
|
2173 CLOG_ENTERFN( "RHttpDownload::DoStartCodL" ) |
|
2174 |
|
2175 if( TCodDownloadProgress::EInProgress == iCodDownload->Progress().iState ) |
|
2176 { |
|
2177 return; |
|
2178 } |
|
2179 |
|
2180 CAiwGenericParamList* params = CAiwGenericParamList::NewLC(); |
|
2181 HBufC8* buf = NULL; |
|
2182 |
|
2183 TInt32 intValue; |
|
2184 TInt err = iDownloadMgr->GetIntAttribute( EDlMgrIap, intValue ); |
|
2185 if( !err ) |
|
2186 { |
|
2187 TAiwGenericParam iap( EGenericParamAccessPoint, intValue ); |
|
2188 params->AppendL( iap ); |
|
2189 } |
|
2190 CLOG_WRITE_FORMAT( "EGenericParamAccessPoint %d", intValue ); |
|
2191 |
|
2192 buf = HBufC8::NewLC( KMaxUrlLength ); |
|
2193 TPtr8 urlBuf = buf->Des(); |
|
2194 err = GetStringAttribute( EDlAttrReqUrl, urlBuf ); |
|
2195 if( !err ) |
|
2196 { |
|
2197 TAiwGenericParam url( EGenericParamURL, urlBuf ); |
|
2198 params->AppendL( url ); |
|
2199 } |
|
2200 CleanupStack::PopAndDestroy( buf ); // buf |
|
2201 |
|
2202 buf = HBufC8::NewLC( KMaxGeneralHeaderFieldLength ); |
|
2203 TPtr8 charsetBuf = buf->Des(); |
|
2204 err = GetStringAttribute( EDlAttrResponseCharSet, charsetBuf ); |
|
2205 if( !err ) |
|
2206 { |
|
2207 TAiwGenericParam charset( EGenericParamCharSet, charsetBuf ); |
|
2208 params->AppendL( charset ); |
|
2209 } |
|
2210 CleanupStack::PopAndDestroy( buf ); // buf |
|
2211 |
|
2212 if( NULL != iDownloadMgr->NextUriObserver() ) |
|
2213 { |
|
2214 // Set CODHandler not to go to the next uri page |
|
2215 TBool suppress( ETrue ); |
|
2216 TAiwGenericParam nextUrl( EGenericParamSuppressNextUrl, suppress ); |
|
2217 params->AppendL( nextUrl ); |
|
2218 } |
|
2219 |
|
2220 TBool silent( EFalse ); |
|
2221 /*err = */GetBoolAttribute( EDlAttrSilent, silent ); |
|
2222 |
|
2223 TInt32 fota( KDefaultFotaPckgId ); |
|
2224 /*err = */GetIntAttribute( EDlAttrFotaPckgId, fota ); |
|
2225 |
|
2226 if( KDefaultFotaPckgId < fota ) |
|
2227 { |
|
2228 TAiwGenericParam fotaID( EGenericParamFotaPkgId, fota ); |
|
2229 params->AppendL( fotaID ); |
|
2230 } |
|
2231 |
|
2232 TAiwGenericParam silentMode( EGenericParamSilentDownload, silent ); |
|
2233 params->AppendL( silentMode ); |
|
2234 |
|
2235 TInt32 action( ELaunch ); |
|
2236 /*err = */GetIntAttribute( EDlAttrAction, action ); |
|
2237 if( EDoNothing == action ) |
|
2238 { |
|
2239 TAiwGenericParam actionOnExit( EGenericParamSuppressLaunch, ETrue ); |
|
2240 params->AppendL( actionOnExit ); |
|
2241 } |
|
2242 |
|
2243 TInt32 autoAccept( 0 ); |
|
2244 err = iDownloadMgr->GetIntAttribute( EDlMgrAutoAcceptCod, autoAccept ); |
|
2245 if( err == KErrNoMemory ) |
|
2246 { |
|
2247 User::Leave( KErrNoMemory ); |
|
2248 } |
|
2249 else if( err == KErrNone ) |
|
2250 { |
|
2251 TAiwGenericParam autoAcceptParam( EGenericParamSuppressDownloadConfirmation, autoAccept ); |
|
2252 params->AppendL( autoAcceptParam ); |
|
2253 } |
|
2254 |
|
2255 // Append DownloadId |
|
2256 TInt32 download; |
|
2257 err = GetIntAttribute(EDlAttrId , download); |
|
2258 if(!err) |
|
2259 { |
|
2260 TAiwGenericParam downloadId( EGenericParamDownloadId, download ); |
|
2261 params->AppendL( downloadId ); |
|
2262 } |
|
2263 |
|
2264 |
|
2265 TAiwGenericParam appUid( EGenericParamApplication, iDownloadMgr->iAppUid.iUid ); |
|
2266 params->AppendL(appUid); |
|
2267 |
|
2268 iCodDownload->StartL( params ); |
|
2269 |
|
2270 CleanupStack::PopAndDestroy( params ); // params |
|
2271 } |
|
2272 |
|
2273 // --------------------------------------------------------- |
|
2274 // RHttpDownload::StartEventNotification |
|
2275 // --------------------------------------------------------- |
|
2276 // |
|
2277 void RHttpDownload::StartEventNotification( TDes8& aDownloadState, |
|
2278 TDes8& aProgressState, |
|
2279 TDes8& aEventAttrib, |
|
2280 TRequestStatus& aStatus ) |
|
2281 { |
|
2282 if(iClosedSubSession) |
|
2283 { |
|
2284 return; |
|
2285 } |
|
2286 CLOG_ENTERFN( "RHttpDownload::StartEventNotification" ) |
|
2287 |
|
2288 CLOG_WRITE_FORMAT( "iDownloadHandler %d", iDownloadHandler ); |
|
2289 |
|
2290 SendReceive( EHttpDownloadEventSubscription, |
|
2291 TIpcArgs( &aDownloadState, &aProgressState, &aEventAttrib ), |
|
2292 aStatus ); |
|
2293 } |
|
2294 |
|
2295 // --------------------------------------------------------- |
|
2296 // RHttpDownload::CancelEventNotification |
|
2297 // --------------------------------------------------------- |
|
2298 // |
|
2299 void RHttpDownload::CancelEventNotification() |
|
2300 { |
|
2301 if(iClosedSubSession) |
|
2302 { |
|
2303 return; |
|
2304 } |
|
2305 CLOG_WRITE( "RHttpDownload::CancelEventNotificationL" ) |
|
2306 |
|
2307 SendReceive( EHttpDownloadEventCancel, TIpcArgs() ); |
|
2308 } |
|
2309 |
|
2310 // --------------------------------------------------------- |
|
2311 // RHttpDownload::PauseL |
|
2312 // --------------------------------------------------------- |
|
2313 // |
|
2314 EXPORT_C TInt RHttpDownload::Pause() |
|
2315 { |
|
2316 if(iClosedSubSession) |
|
2317 { |
|
2318 return KErrNotSupported; |
|
2319 } |
|
2320 CLOG_WRITE( "RHttpDownload::Pause" ) |
|
2321 |
|
2322 DeleteTransaction(); |
|
2323 |
|
2324 return SendReceive( EHttpDownloadPause, TIpcArgs() ); |
|
2325 } |
|
2326 |
|
2327 // --------------------------------------------------------- |
|
2328 // RHttpDownload::Reset |
|
2329 // --------------------------------------------------------- |
|
2330 // |
|
2331 EXPORT_C TInt RHttpDownload::Reset() |
|
2332 { |
|
2333 if(iClosedSubSession) |
|
2334 { |
|
2335 return KErrNotSupported; |
|
2336 } |
|
2337 CLOG_WRITE( "RHttpDownload::Reset" ) |
|
2338 |
|
2339 DeleteTransaction(); |
|
2340 |
|
2341 return SendReceive( EHttpDownloadReset, TIpcArgs() ); |
|
2342 } |
|
2343 |
|
2344 // --------------------------------------------------------- |
|
2345 // RHttpDownload::IsDeleteCodWhenDone |
|
2346 // --------------------------------------------------------- |
|
2347 // |
|
2348 TBool RHttpDownload::IsDeleteCodWhenDone() const |
|
2349 { |
|
2350 CLOG_WRITE( "RHttpDownload::IsDeleteCodWhenDone" ) |
|
2351 |
|
2352 return iExtension->iDeleteCodWhenDone; |
|
2353 } |
|
2354 |
|
2355 // --------------------------------------------------------- |
|
2356 // RHttpDownload::SetCodInProgress |
|
2357 // --------------------------------------------------------- |
|
2358 // |
|
2359 void RHttpDownload::SetCodInProgress( TCodProgressState aVal ) |
|
2360 { |
|
2361 CLOG_WRITE( "RHttpDownload::SetCodInProgress" ) |
|
2362 |
|
2363 iExtension->iCodInProgress = aVal; |
|
2364 } |
|
2365 |
|
2366 // --------------------------------------------------------- |
|
2367 // RHttpDownload::DeleteL |
|
2368 // --------------------------------------------------------- |
|
2369 // |
|
2370 |
|
2371 EXPORT_C TInt RHttpDownload::Delete() |
|
2372 { |
|
2373 CLOG_WRITE( "RHttpDownload::Delete" ) |
|
2374 TInt err( KErrNone ); |
|
2375 |
|
2376 |
|
2377 if( iCodDownload && iExtension->iCodInProgress == RHttpDownload::EInProgress ) |
|
2378 { |
|
2379 |
|
2380 //The download is still is not accepted by the user. Allow the the user to cancel the |
|
2381 // download from Accpet-Cancel dialog or if any dialog displayed before it |
|
2382 if(!iASReady) |
|
2383 { |
|
2384 return KErrInUse; |
|
2385 } |
|
2386 |
|
2387 // COD in progress; Stop instead of deleting. This leaves |
|
2388 // time for install-notify. |
|
2389 // Download will be deleted on EDone COD event. |
|
2390 CLOG_WRITE_FORMAT( "RHttpDownload delete when COD done: 0x%x", this ) |
|
2391 iCodDownload->Stop(); |
|
2392 iExtension->iDeleteCodWhenDone = ETrue; |
|
2393 |
|
2394 if(iASReady && iWait && !iWait->IsStarted()) |
|
2395 { |
|
2396 iWait->Start(); |
|
2397 } |
|
2398 } |
|
2399 |
|
2400 if( !iDownloadMgr->IsEventBroadcasting() ) |
|
2401 { |
|
2402 CLOG_WRITE_FORMAT( "RHttpDownload is deleting: 0x%x", this ); |
|
2403 iExtension->iToBeDeleted = EFalse; |
|
2404 THttpDownloadEvent event; |
|
2405 event.iDownloadState = EHttpDlDeleting; |
|
2406 event.iProgressState = EHttpProgNone; |
|
2407 TRAP( err, iDownloadMgr->HandleDMgrEventL( *this, event ) ); |
|
2408 if( KErrNone != err ) |
|
2409 { |
|
2410 return err; |
|
2411 } |
|
2412 |
|
2413 DeleteTransaction(); |
|
2414 |
|
2415 if(!iClosedSubSession) |
|
2416 { |
|
2417 err = SendReceive( EHttpDownloadDelete, TIpcArgs() ); |
|
2418 } |
|
2419 |
|
2420 // Server deleted it in server-side, so close this down in client-side: |
|
2421 iDownloadMgr->CloseDownload( this ); |
|
2422 } |
|
2423 else |
|
2424 { |
|
2425 CLOG_WRITE_FORMAT( "RHttpDownload to be deleted: 0x%x", this ) |
|
2426 iExtension->iToBeDeleted = ETrue; |
|
2427 } |
|
2428 |
|
2429 return err; |
|
2430 } |
|
2431 |
|
2432 // --------------------------------------------------------- |
|
2433 // RHttpDownload::Move |
|
2434 // --------------------------------------------------------- |
|
2435 // |
|
2436 EXPORT_C TInt RHttpDownload::Move() |
|
2437 { |
|
2438 if(iClosedSubSession) |
|
2439 { |
|
2440 return KErrNotSupported; |
|
2441 } |
|
2442 CLOG_WRITE( "RHttpDownload::Move" ) |
|
2443 |
|
2444 return SendReceive( EHttpDownloadMove, TIpcArgs() ); |
|
2445 } |
|
2446 |
|
2447 // --------------------------------------------------------- |
|
2448 // RHttpDownload::GetIntAttributeL |
|
2449 // --------------------------------------------------------- |
|
2450 // |
|
2451 EXPORT_C TInt RHttpDownload::GetIntAttribute( const TUint aAttribute, |
|
2452 TInt32& aValue ) |
|
2453 { |
|
2454 CLOG_WRITE( "RHttpDownload::GetIntAttributeL" ) |
|
2455 |
|
2456 if(iClosedSubSession) |
|
2457 { |
|
2458 if(!iDlExtension) |
|
2459 { |
|
2460 return KErrGeneral; |
|
2461 } |
|
2462 return iDlExtension->GetIntAttribute( aAttribute, aValue);; |
|
2463 } |
|
2464 |
|
2465 // IPC optimalization; some of the atributes are kept in the client side |
|
2466 // and either refreshed with the events or they are not changed. |
|
2467 TBool isProgressive (EFalse); |
|
2468 GetBoolAttribute( EDlAttrProgressive, isProgressive ); |
|
2469 if (!isProgressive) |
|
2470 { |
|
2471 if( iExtension->GetIntAttribute( aAttribute, aValue ) ) |
|
2472 { |
|
2473 return KErrNone; |
|
2474 } |
|
2475 } |
|
2476 |
|
2477 TPckg<TInt32> pckg( aValue ); |
|
2478 |
|
2479 return SendReceive( EHttpDownloadGetIntAttribute, TIpcArgs( aAttribute, KNonMoIndex, &pckg ) ); |
|
2480 } |
|
2481 |
|
2482 // --------------------------------------------------------- |
|
2483 // RHttpDownload::GetIntAttributeL |
|
2484 // --------------------------------------------------------- |
|
2485 // |
|
2486 EXPORT_C TInt RHttpDownload::GetIntAttribute( const TUint aAttribute, |
|
2487 const TInt32& aMoIndex, |
|
2488 TInt32& aValue ) |
|
2489 { |
|
2490 CLOG_WRITE( "RHttpDownload::GetIntAttributeL" ) |
|
2491 |
|
2492 TPckg<TInt32> pckg( aValue ); |
|
2493 |
|
2494 return SendReceive( EHttpDownloadGetIntAttribute, TIpcArgs( aAttribute, aMoIndex, &pckg ) ); |
|
2495 } |
|
2496 |
|
2497 // --------------------------------------------------------- |
|
2498 // RHttpDownload::GetBoolAttributeL |
|
2499 // --------------------------------------------------------- |
|
2500 // |
|
2501 EXPORT_C TInt RHttpDownload::GetBoolAttribute( const TUint aAttribute, |
|
2502 TBool& aValue ) |
|
2503 { |
|
2504 CLOG_WRITE( "RHttpDownload::GetBoolAttributeL" ) |
|
2505 |
|
2506 if(iClosedSubSession) |
|
2507 { |
|
2508 if(!iDlExtension) |
|
2509 { |
|
2510 return KErrGeneral; |
|
2511 } |
|
2512 return iDlExtension->GetBoolAttribute( aAttribute, aValue);; |
|
2513 } |
|
2514 |
|
2515 TPckg<TBool> pckg( aValue ); |
|
2516 |
|
2517 return SendReceive( EHttpDownloadGetBoolAttribute, TIpcArgs( aAttribute, KNonMoIndex, &pckg ) ); |
|
2518 } |
|
2519 |
|
2520 // --------------------------------------------------------- |
|
2521 // RHttpDownload::GetBoolAttributeL |
|
2522 // --------------------------------------------------------- |
|
2523 // |
|
2524 EXPORT_C TInt RHttpDownload::GetBoolAttribute( const TUint aAttribute, |
|
2525 const TInt32& aMoIndex, |
|
2526 TBool& aValue ) |
|
2527 { |
|
2528 CLOG_WRITE( "RHttpDownload::GetBoolAttributeL" ) |
|
2529 |
|
2530 if(iClosedSubSession) |
|
2531 { |
|
2532 if(!iDlExtension) |
|
2533 { |
|
2534 return KErrGeneral; |
|
2535 } |
|
2536 return iDlExtension->GetBoolAttribute( aAttribute, aMoIndex, aValue);; |
|
2537 } |
|
2538 |
|
2539 |
|
2540 TPckg<TBool> pckg( aValue ); |
|
2541 |
|
2542 return SendReceive( EHttpDownloadGetBoolAttribute, TIpcArgs( aAttribute, aMoIndex, &pckg ) ); |
|
2543 } |
|
2544 |
|
2545 // --------------------------------------------------------- |
|
2546 // RHttpDownload::GetStringAttribute |
|
2547 // --------------------------------------------------------- |
|
2548 // |
|
2549 EXPORT_C TInt RHttpDownload::GetStringAttribute( const TUint aAttribute, |
|
2550 TDes16& aValue ) |
|
2551 { |
|
2552 CLOG_WRITE( "RHttpDownload::GetStringAttributeL" ) |
|
2553 |
|
2554 if(iClosedSubSession) |
|
2555 { |
|
2556 if(!iDlExtension) |
|
2557 { |
|
2558 return KErrGeneral; |
|
2559 } |
|
2560 return iDlExtension->GetStringAttribute( aAttribute, aValue); |
|
2561 } |
|
2562 |
|
2563 // IPC optimalization; some of the atributes are kept in the client side |
|
2564 // and either refreshed with the events or they are not changed. |
|
2565 if( iExtension->GetStringAttribute( aAttribute, aValue) ) |
|
2566 { |
|
2567 return KErrNone; |
|
2568 } |
|
2569 |
|
2570 return SendReceive( EHttpDownloadGetStringAttribute, |
|
2571 TIpcArgs( aAttribute, KNonMoIndex, &aValue ) ); |
|
2572 } |
|
2573 |
|
2574 // --------------------------------------------------------- |
|
2575 // RHttpDownload::GetStringAttribute |
|
2576 // --------------------------------------------------------- |
|
2577 // |
|
2578 EXPORT_C TInt RHttpDownload::GetStringAttribute( const TUint aAttribute, |
|
2579 const TInt32& aMoIndex, |
|
2580 TDes16& aValue ) |
|
2581 { |
|
2582 CLOG_WRITE( "RHttpDownload::GetStringAttributeL" ) |
|
2583 |
|
2584 if(iClosedSubSession) |
|
2585 { |
|
2586 if(!iDlExtension) |
|
2587 { |
|
2588 return KErrGeneral; |
|
2589 } |
|
2590 return iDlExtension->GetStringAttribute( aAttribute, aMoIndex, aValue); |
|
2591 } |
|
2592 |
|
2593 return SendReceive( EHttpDownloadGetStringAttribute, |
|
2594 TIpcArgs( aAttribute, aMoIndex, &aValue ) ); |
|
2595 } |
|
2596 |
|
2597 // --------------------------------------------------------- |
|
2598 // RHttpDownload::GetStringAttribute |
|
2599 // --------------------------------------------------------- |
|
2600 // |
|
2601 EXPORT_C TInt RHttpDownload::GetStringAttribute( const TUint aAttribute, TDes8& aValue ) |
|
2602 { |
|
2603 |
|
2604 CLOG_WRITE( "RHttpDownload::GetStringAttributeL" ) |
|
2605 |
|
2606 if(iClosedSubSession) |
|
2607 { |
|
2608 if(!iDlExtension) |
|
2609 { |
|
2610 return KErrGeneral; |
|
2611 } |
|
2612 return iDlExtension->GetStringAttribute( aAttribute, aValue); |
|
2613 } |
|
2614 |
|
2615 // IPC optimalization; some of the atributes are kept in the client side |
|
2616 // and either refreshed with the events or they are not changed. |
|
2617 if( iExtension->GetStringAttribute( aAttribute, aValue) ) |
|
2618 { |
|
2619 return KErrNone; |
|
2620 } |
|
2621 |
|
2622 return SendReceive( EHttpDownloadGetString8Attribute, |
|
2623 TIpcArgs( aAttribute, KNonMoIndex, &aValue ) ); |
|
2624 } |
|
2625 |
|
2626 // --------------------------------------------------------- |
|
2627 // RHttpDownload::GetStringAttribute |
|
2628 // --------------------------------------------------------- |
|
2629 // |
|
2630 EXPORT_C TInt RHttpDownload::GetStringAttribute( const TUint aAttribute, |
|
2631 const TInt32& aMoIndex, |
|
2632 TDes8& aValue ) |
|
2633 { |
|
2634 CLOG_WRITE( "RHttpDownload::GetStringAttributeL" ) |
|
2635 |
|
2636 if(iClosedSubSession) |
|
2637 { |
|
2638 if(!iDlExtension) |
|
2639 { |
|
2640 return KErrGeneral; |
|
2641 } |
|
2642 return iDlExtension->GetStringAttribute( aAttribute, aMoIndex, aValue); |
|
2643 } |
|
2644 |
|
2645 |
|
2646 return SendReceive( EHttpDownloadGetString8Attribute, |
|
2647 TIpcArgs( aAttribute, aMoIndex, &aValue ) ); |
|
2648 } |
|
2649 |
|
2650 // --------------------------------------------------------- |
|
2651 // RHttpDownload::GetFileHandleAttribute |
|
2652 // --------------------------------------------------------- |
|
2653 // |
|
2654 EXPORT_C TInt RHttpDownload::GetFileHandleAttribute( RFile& aFile ) |
|
2655 { |
|
2656 CLOG_WRITE("RHttpDownload::GetFileHandleAttribute") |
|
2657 |
|
2658 if(iClosedSubSession) |
|
2659 { |
|
2660 return KErrNotSupported; |
|
2661 } |
|
2662 |
|
2663 TInt ssh; // sub-session (RFile) handle |
|
2664 TInt fsh; // session (RFs) handle |
|
2665 TPckgBuf<TInt> fh; |
|
2666 fsh = SendReceive(EHttpDownloadGetRFile, TIpcArgs(&fh)); |
|
2667 if (fsh < 0) // error ? |
|
2668 { |
|
2669 return fsh; |
|
2670 } |
|
2671 |
|
2672 ssh = fh(); |
|
2673 |
|
2674 // Adopt the file using the returned handles |
|
2675 return aFile.AdoptFromServer(fsh, ssh); |
|
2676 } |
|
2677 |
|
2678 |
|
2679 // --------------------------------------------------------- |
|
2680 // RHttpDownload::SetIntAttributeL |
|
2681 // --------------------------------------------------------- |
|
2682 // |
|
2683 EXPORT_C TInt RHttpDownload::SetIntAttribute( const TUint aAttribute, |
|
2684 TInt32 aValue ) |
|
2685 { |
|
2686 CLOG_WRITE( "RHttpDownload::SetIntAttributeL" ) |
|
2687 |
|
2688 if(iClosedSubSession) |
|
2689 { |
|
2690 return KErrNotSupported; |
|
2691 } |
|
2692 |
|
2693 TInt err = SendReceive( EHttpDownloadSetIntAttribute, |
|
2694 TIpcArgs( aAttribute, aValue ) ); |
|
2695 if( KErrNone == err ) |
|
2696 { |
|
2697 iExtension->SetIntAttribute( aAttribute, aValue ); |
|
2698 } |
|
2699 |
|
2700 return err; |
|
2701 } |
|
2702 |
|
2703 // --------------------------------------------------------- |
|
2704 // RHttpDownload::SetBoolAttribute |
|
2705 // --------------------------------------------------------- |
|
2706 // |
|
2707 EXPORT_C TInt RHttpDownload::SetBoolAttribute( const TUint aAttribute, TBool aValue ) |
|
2708 { |
|
2709 CLOG_WRITE( "RHttpDownload::SetBoolAttributeL" ) |
|
2710 |
|
2711 if(iClosedSubSession) |
|
2712 { |
|
2713 |
|
2714 if(!iDlExtension) |
|
2715 { |
|
2716 return KErrGeneral; |
|
2717 } |
|
2718 iDlExtension->SetBoolAttribute( aAttribute, aValue); |
|
2719 return; |
|
2720 } |
|
2721 |
|
2722 if (aAttribute == EDlAttrProgressive) |
|
2723 { |
|
2724 if (iCodDownload) |
|
2725 { |
|
2726 // set attached attribute to handle progressive downloads in the COD Handler (for OMA2) |
|
2727 iCodDownload->SetCodDlAttached(aValue); |
|
2728 } |
|
2729 } |
|
2730 |
|
2731 return SendReceive( EHttpDownloadSetBoolAttribute, |
|
2732 TIpcArgs( aAttribute, aValue ) ); |
|
2733 } |
|
2734 |
|
2735 // --------------------------------------------------------- |
|
2736 // RHttpDownload::SetStringAttributeL |
|
2737 // --------------------------------------------------------- |
|
2738 // |
|
2739 EXPORT_C TInt RHttpDownload::SetStringAttribute( const TUint aAttribute, |
|
2740 const TDesC16& aValue ) |
|
2741 { |
|
2742 CLOG_WRITE( "RHttpDownload::SetStringAttributeL" ) |
|
2743 |
|
2744 if(iClosedSubSession) |
|
2745 { |
|
2746 return KErrNotSupported; |
|
2747 } |
|
2748 |
|
2749 TInt err = SendReceive( EHttpDownloadSetStringAttribute, |
|
2750 TIpcArgs( aAttribute, KNonMoIndex, &aValue ) ); |
|
2751 if( KErrNone == err ) |
|
2752 { |
|
2753 iExtension->SetStringAttribute( aAttribute, aValue ); |
|
2754 } |
|
2755 return err; |
|
2756 } |
|
2757 |
|
2758 // --------------------------------------------------------- |
|
2759 // RHttpDownload::SetStringAttributeL |
|
2760 // --------------------------------------------------------- |
|
2761 // |
|
2762 EXPORT_C TInt RHttpDownload::SetStringAttribute( const TUint aAttribute, |
|
2763 const TInt32& aMoIndex, |
|
2764 const TDesC16& aValue ) |
|
2765 { |
|
2766 CLOG_WRITE( "RHttpDownload::SetStringAttributeL" ) |
|
2767 |
|
2768 if(iClosedSubSession) |
|
2769 { |
|
2770 return KErrNotSupported; |
|
2771 } |
|
2772 return SendReceive( EHttpDownloadSetStringAttribute, |
|
2773 TIpcArgs( aAttribute, aMoIndex, &aValue ) ); |
|
2774 } |
|
2775 |
|
2776 // --------------------------------------------------------- |
|
2777 // RHttpDownload::SetStringAttributeL |
|
2778 // --------------------------------------------------------- |
|
2779 // |
|
2780 EXPORT_C TInt RHttpDownload::SetStringAttribute( const TUint aAttribute, const TDesC8& aValue ) |
|
2781 { |
|
2782 CLOG_WRITE( "RHttpDownload::SetStringAttributeL" ) |
|
2783 |
|
2784 if(iClosedSubSession) |
|
2785 { |
|
2786 return KErrNotSupported; |
|
2787 } |
|
2788 |
|
2789 TInt err = SendReceive( EHttpDownloadSetString8Attribute, |
|
2790 TIpcArgs( aAttribute, &aValue ) ); |
|
2791 |
|
2792 if( KErrNone == err ) |
|
2793 { |
|
2794 iExtension->SetStringAttribute( aAttribute, aValue ); |
|
2795 } |
|
2796 |
|
2797 return err; |
|
2798 } |
|
2799 |
|
2800 // --------------------------------------------------------- |
|
2801 // RHttpDownload::SetStringAttributeL |
|
2802 // --------------------------------------------------------- |
|
2803 // |
|
2804 EXPORT_C TInt RHttpDownload::SetFileHandleAttribute( RFile& aFile ) |
|
2805 { |
|
2806 if(iClosedSubSession) |
|
2807 { |
|
2808 return KErrNotSupported; |
|
2809 } |
|
2810 if( !aFile.SubSessionHandle() ) |
|
2811 // file is not opened |
|
2812 { |
|
2813 return KErrBadHandle; |
|
2814 } |
|
2815 // store the RFs handle in message slot 0 and the RFile handle in slot 1 |
|
2816 TIpcArgs ipcArgs; |
|
2817 aFile.TransferToServer(ipcArgs, 0, 1); |
|
2818 |
|
2819 // send to server |
|
2820 return SendReceive(EHttpDownloadSetRFile, ipcArgs); |
|
2821 } |
|
2822 |
|
2823 // --------------------------------------------------------- |
|
2824 // RHttpDownload::SetDownloadDataAttributeL |
|
2825 // --------------------------------------------------------- |
|
2826 // |
|
2827 EXPORT_C TInt RHttpDownload::SetDownloadDataAttribute( const TDesC8& aValue ) |
|
2828 { |
|
2829 CLOG_WRITE( "RHttpDownload::SetDownloadDataAttribute" ) |
|
2830 |
|
2831 return SendReceive( EHttpDownloadDataAttribute, TIpcArgs( &aValue ) ); |
|
2832 } |
|
2833 |
|
2834 // --------------------------------------------------------- |
|
2835 // RHttpDownload::SetTrackDataAttributeL |
|
2836 // --------------------------------------------------------- |
|
2837 // |
|
2838 EXPORT_C TInt RHttpDownload::SetTrackDataAttribute( const TInt aIndex, const TDesC8& aValue ) |
|
2839 { |
|
2840 CLOG_WRITE( "RHttpDownload::SetTrackDataAttribute" ) |
|
2841 |
|
2842 return SendReceive( EHttpDownloadTrackAttribute, TIpcArgs( aIndex, &aValue ) ); |
|
2843 } |
|
2844 |
|
2845 // --------------------------------------------------------- |
|
2846 // RHttpDownload::IsDownload |
|
2847 // --------------------------------------------------------- |
|
2848 // |
|
2849 TBool RHttpDownload::IsDownload( TInt aHandle ) |
|
2850 { |
|
2851 CLOG_WRITE( "RHttpDownload::IsDownload" ) |
|
2852 |
|
2853 return (iHandle == aHandle) ? ETrue : EFalse; |
|
2854 } |
|
2855 // --------------------------------------------------------- |
|
2856 // RHttpDownload::IsDownload |
|
2857 // --------------------------------------------------------- |
|
2858 // |
|
2859 TBool RHttpDownload::IsDownloadL( const TUriParser8& aParsedReqUrl, const TDesC8& aHashedMsgBody ) |
|
2860 { |
|
2861 CLOG_WRITE( "RHttpDownload::IsDownload" ); |
|
2862 |
|
2863 TBuf8<KMaxUrlLength> url_Own; |
|
2864 TBuf8<KHashLength> hash_owned; |
|
2865 |
|
2866 TInt errURL(KErrNone); |
|
2867 TInt errHashedMsg(KErrNone); |
|
2868 |
|
2869 if( iClosedSubSession) |
|
2870 { |
|
2871 errURL = iDlExtension->GetStringAttribute( EDlAttrReqUrl, url_Own ); |
|
2872 if(!errURL) |
|
2873 { |
|
2874 errHashedMsg = iDlExtension->GetStringAttribute( EDlAttrHashedMsgBody, hash_owned ); |
|
2875 } |
|
2876 } |
|
2877 else |
|
2878 { |
|
2879 errURL = GetStringAttribute( EDlAttrReqUrl, url_Own ); |
|
2880 if(!errURL) |
|
2881 { |
|
2882 errHashedMsg = GetStringAttribute( EDlAttrHashedMsgBody, hash_owned ); |
|
2883 } |
|
2884 } |
|
2885 |
|
2886 TBool retVal( EFalse ); |
|
2887 |
|
2888 if( !errURL ) |
|
2889 { |
|
2890 HBufC8* escaped_own = EscapeUtils::EscapeDecodeL( url_Own ); |
|
2891 CleanupStack::PushL( escaped_own ); |
|
2892 |
|
2893 TUriParser8 parsed_Own; |
|
2894 |
|
2895 parsed_Own.Parse( *escaped_own ); |
|
2896 |
|
2897 if( !aParsedReqUrl.Extract( EUriHost ).CompareF( parsed_Own.Extract( EUriHost ) ) && |
|
2898 aParsedReqUrl.Extract( EUriPath ) == parsed_Own.Extract( EUriPath ) && |
|
2899 aParsedReqUrl.Extract( EUriQuery ) == parsed_Own.Extract( EUriQuery ) && |
|
2900 aParsedReqUrl.Extract( EUriFragment ) == parsed_Own.Extract( EUriFragment ) ) |
|
2901 { |
|
2902 |
|
2903 |
|
2904 if( !errHashedMsg ) |
|
2905 // |
|
2906 { |
|
2907 if( 0 == aHashedMsgBody.Compare( hash_owned ) ) |
|
2908 { |
|
2909 retVal = ETrue; |
|
2910 } |
|
2911 } |
|
2912 else |
|
2913 // hashed message body cannot be compared due to some unknown reason. |
|
2914 // Lets assume that the contents are the same. |
|
2915 { |
|
2916 retVal = ETrue; |
|
2917 } |
|
2918 } |
|
2919 |
|
2920 CleanupStack::PopAndDestroy( escaped_own ); |
|
2921 } |
|
2922 |
|
2923 return retVal; |
|
2924 } |
|
2925 |
|
2926 // --------------------------------------------------------- |
|
2927 // RHttpDownload::BufferAttributesL |
|
2928 // --------------------------------------------------------- |
|
2929 // |
|
2930 void RHttpDownload::BufferAttributesL() |
|
2931 { |
|
2932 CLOG_ENTERFN("RHttpDownload::BufferAttributesL"); |
|
2933 |
|
2934 if(iClosedSubSession) |
|
2935 { |
|
2936 return; |
|
2937 } |
|
2938 |
|
2939 |
|
2940 HBufC8* buf = iExtension->AllocAttribBufL( ETrue ); |
|
2941 CleanupStack::PushL( buf ); |
|
2942 TPtr8 ptr = buf->Des(); |
|
2943 |
|
2944 User::LeaveIfError( SendReceive( EHttpDownloadBufferAttributes, |
|
2945 TIpcArgs( &ptr ) ) ); |
|
2946 iExtension->UnpackAttribL( ptr ); |
|
2947 CleanupStack::PopAndDestroy( buf ); // buf |
|
2948 } |
|
2949 |
|
2950 // ----------------------------------------------------------------------------- |
|
2951 // RHttpDownload::SetEventType |
|
2952 // ----------------------------------------------------------------------------- |
|
2953 // |
|
2954 void RHttpDownload::SetEventType( THttpDownloadState aEventType ) |
|
2955 { |
|
2956 CLOG_ENTERFN("RHttpDownload::SetEventType"); |
|
2957 |
|
2958 if(iClosedSubSession) |
|
2959 { |
|
2960 return ; |
|
2961 } |
|
2962 |
|
2963 if( iExtension ) |
|
2964 { |
|
2965 iExtension->SetEventType( aEventType ); |
|
2966 } |
|
2967 } |
|
2968 |
|
2969 // ----------------------------------------------------------------------------- |
|
2970 // RHttpDownload::SetHttpTransactionL |
|
2971 // ----------------------------------------------------------------------------- |
|
2972 // |
|
2973 void RHttpDownload::SetHttpTransactionL( TInt aHttpTransaction ) |
|
2974 { |
|
2975 iDownloadMgr->IncrementEventPriorityFlag(); |
|
2976 CLOG_ENTERFN("RHttpDownload::SetHttpTransactionL"); |
|
2977 |
|
2978 THTTPHdrVal hdrVal; |
|
2979 |
|
2980 iClientSideDownload = ETrue; |
|
2981 |
|
2982 iHttpTransaction = REINTERPRET_CAST( RHTTPTransaction* , aHttpTransaction ); |
|
2983 iTransactionObserver = CTransactionObserver::NewL( this ); |
|
2984 |
|
2985 RHTTPTransactionPropertySet propSet = iHttpTransaction->PropertySet(); |
|
2986 |
|
2987 RStringPool strPool = iHttpTransaction->Session().StringPool(); |
|
2988 // set transaction property with the event handler callback functions' pointer |
|
2989 RStringF transactionCallbackStr = strPool.OpenFStringL( KTransactionCallback ); |
|
2990 CleanupClosePushL( transactionCallbackStr ); |
|
2991 THTTPHdrVal tokenVal = (TInt)(MHTTPTransactionCallback*)iTransactionObserver; |
|
2992 iHttpTransaction->PropertySet().RemoveProperty( transactionCallbackStr ); |
|
2993 iHttpTransaction->PropertySet().SetPropertyL( transactionCallbackStr, tokenVal ); |
|
2994 |
|
2995 CleanupStack::PopAndDestroy(); // transactionCallbackStr |
|
2996 |
|
2997 // |
|
2998 RHTTPHeaders headers( iHttpTransaction->Response().GetHeaderCollection() ); |
|
2999 THTTPHdrFieldIter it = headers.Fields(); |
|
3000 TInt length( 0 ); |
|
3001 HBufC8* header = NULL; |
|
3002 |
|
3003 for( TInt i = 0; i < 2; ++i ) |
|
3004 { |
|
3005 while ( !it.AtEnd() ) |
|
3006 { |
|
3007 RStringTokenF fieldName = it(); |
|
3008 RStringF fieldNameStr = strPool.StringF (fieldName ); |
|
3009 |
|
3010 TPtrC8 rawData; |
|
3011 |
|
3012 headers.GetRawField( fieldNameStr, rawData ); |
|
3013 |
|
3014 if( !header ) |
|
3015 { |
|
3016 length += fieldNameStr.DesC().Length() + |
|
3017 1 + // KColon |
|
3018 rawData.Length() + |
|
3019 KHttpFieldSeparator().Length(); |
|
3020 } |
|
3021 else |
|
3022 { |
|
3023 header->Des().Append( fieldNameStr.DesC() ); |
|
3024 header->Des().Append( KColon ); |
|
3025 header->Des().Append( rawData ); |
|
3026 header->Des().Append( KHttpFieldSeparator ); |
|
3027 } |
|
3028 |
|
3029 ++it; |
|
3030 } |
|
3031 |
|
3032 if( !header ) |
|
3033 { |
|
3034 header = HBufC8::NewL( length ); |
|
3035 it.First(); |
|
3036 } |
|
3037 } |
|
3038 |
|
3039 if( header ) |
|
3040 { |
|
3041 SetStringAttribute( EDlAttrResponseHeader, *header ); |
|
3042 } |
|
3043 |
|
3044 delete header; header = NULL; |
|
3045 |
|
3046 //realm |
|
3047 if (propSet.Property(strPool.StringF( |
|
3048 HTTP::ERealm, RHTTPSession::GetTable()), hdrVal)) |
|
3049 { |
|
3050 SetStringAttribute( EDlAttrRealm, hdrVal.Str().DesC() ); |
|
3051 } |
|
3052 |
|
3053 // username |
|
3054 if (propSet.Property(strPool.StringF( |
|
3055 HTTP::EUsername, RHTTPSession::GetTable()), hdrVal)) |
|
3056 { |
|
3057 SetStringAttribute( EDlAttrUsername, hdrVal.Str().DesC() ); |
|
3058 } |
|
3059 |
|
3060 // password |
|
3061 if (propSet.Property(strPool.StringF( |
|
3062 HTTP::EPassword, RHTTPSession::GetTable()), hdrVal)) |
|
3063 { |
|
3064 SetStringAttribute( EDlAttrPassword, hdrVal.Str().DesC() ); |
|
3065 } |
|
3066 |
|
3067 // proxy realm |
|
3068 if (propSet.Property(strPool.StringF( |
|
3069 HttpFilterCommonStringsExt::EProxyRealm, |
|
3070 HttpFilterCommonStringsExt::GetTable()), hdrVal)) |
|
3071 { |
|
3072 SetStringAttribute( EDlAttrProxyRealm, hdrVal.Str().DesC() ); |
|
3073 } |
|
3074 |
|
3075 // proxy username |
|
3076 if (propSet.Property(strPool.StringF( |
|
3077 HttpFilterCommonStringsExt::EProxyUsername, |
|
3078 HttpFilterCommonStringsExt::GetTable()), hdrVal)) |
|
3079 { |
|
3080 SetStringAttribute( EDlAttrProxyUsername, hdrVal.Str().DesC() ); |
|
3081 } |
|
3082 |
|
3083 // proxy password |
|
3084 if (propSet.Property(strPool.StringF( |
|
3085 HttpFilterCommonStringsExt::EProxyPassword, RHTTPSession::GetTable()), hdrVal)) |
|
3086 { |
|
3087 SetStringAttribute( EDlAttrProxyPassword, hdrVal.Str().DesC() ); |
|
3088 } |
|
3089 |
|
3090 RStringF method = iHttpTransaction->Request().Method(); |
|
3091 if( method == strPool.StringF( HTTP::EGET, RHTTPSession::GetTable()) ) |
|
3092 { |
|
3093 SetIntAttribute( EDlAttrMethod, EMethodGET ); |
|
3094 } |
|
3095 else if( method == strPool.StringF( HTTP::EHEAD, RHTTPSession::GetTable()) ) |
|
3096 { |
|
3097 SetIntAttribute( EDlAttrMethod, EMethodHEAD ); |
|
3098 } |
|
3099 else if( method == strPool.StringF( HTTP::EPOST, RHTTPSession::GetTable()) ) |
|
3100 { |
|
3101 SetIntAttribute( EDlAttrMethod, EMethodPOST ); |
|
3102 } |
|
3103 |
|
3104 // Hashed message body |
|
3105 TBool hasBody = iHttpTransaction->Request().HasBody(); |
|
3106 if( hasBody ) |
|
3107 { |
|
3108 TPtrC8 dataPart; |
|
3109 MHTTPDataSupplier* reqBody = iHttpTransaction->Request().Body(); |
|
3110 reqBody->Reset(); |
|
3111 reqBody->GetNextDataPart( dataPart ); |
|
3112 TBuf8<KHashLength> hash; |
|
3113 HashL( dataPart, hash ); |
|
3114 SetStringAttribute( EDlAttrHashedMsgBody, hash ); |
|
3115 } |
|
3116 |
|
3117 if( iHttpTransaction->PropertySet().Property( |
|
3118 strPool.StringF(HttpFilterCommonStringsExt::EContentInflated, |
|
3119 HttpFilterCommonStringsExt::GetTable()), |
|
3120 hdrVal )) |
|
3121 // Content was original encoded -> we don't know the actual content size. |
|
3122 { |
|
3123 SetIntAttribute( EDlAttrMultipleMOLength, KDefaultContentLength ); |
|
3124 } |
|
3125 } |
|
3126 |
|
3127 // ----------------------------------------------------------------------------- |
|
3128 // RHttpDownload::DeleteTransaction |
|
3129 // ----------------------------------------------------------------------------- |
|
3130 // |
|
3131 void RHttpDownload::DeleteTransaction() |
|
3132 { |
|
3133 CLOG_ENTERFN("RHttpDownload::DeleteTransaction"); |
|
3134 |
|
3135 iClientSideDownload = EFalse; |
|
3136 |
|
3137 if( iHttpTransaction ) |
|
3138 { |
|
3139 iHttpTransaction->Close(); |
|
3140 delete iHttpTransaction; |
|
3141 iHttpTransaction = NULL; |
|
3142 } |
|
3143 |
|
3144 if( iTransactionObserver ) |
|
3145 { |
|
3146 delete iTransactionObserver; |
|
3147 iTransactionObserver = NULL; |
|
3148 } |
|
3149 |
|
3150 iDownloadMgr->DecrementEventPriorityFlag(); |
|
3151 } |
|
3152 |
|
3153 // ----------------------------------------------------------------------------- |
|
3154 // RHttpDownload::InitCodDownloadL |
|
3155 // ----------------------------------------------------------------------------- |
|
3156 // |
|
3157 void RHttpDownload::InitCodDownloadL( const TDesC8& aBuf, |
|
3158 const TDesC8& aMimeType, |
|
3159 CEikonEnv* aEikEnv ) |
|
3160 { |
|
3161 CLOG_ENTERFN("RHttpDownload::InitCodDownloadL"); |
|
3162 |
|
3163 if(iCodDownload) |
|
3164 { |
|
3165 delete iCodDownload; |
|
3166 iCodDownload = NULL; |
|
3167 } |
|
3168 |
|
3169 if(iCodObserver) |
|
3170 { |
|
3171 delete iCodObserver; |
|
3172 iCodObserver = NULL; |
|
3173 } |
|
3174 |
|
3175 SetBoolAttribute( EDlAttrCodDownload, ETrue ); |
|
3176 |
|
3177 if(!iCodObserver) |
|
3178 { |
|
3179 iCodObserver = CCodObserver::NewL( iDownloadMgr ); |
|
3180 } |
|
3181 |
|
3182 TBool silent( EFalse ); |
|
3183 iDownloadMgr->GetBoolAttribute( EDlMgrSilentMode, silent ); |
|
3184 if( silent ) |
|
3185 { |
|
3186 aEikEnv = NULL; |
|
3187 } |
|
3188 |
|
3189 if( 0 == aMimeType.Compare( KMultiPartMimeType() ) ) |
|
3190 { |
|
3191 TInt cleanupcount( 0 ); |
|
3192 HBufC8* boundbuff = HBufC8::NewLC( KMaxContentTypeLength ); cleanupcount++; |
|
3193 TPtr8 boundary = boundbuff->Des(); |
|
3194 // Leave if media type doesn't exist; there is no boundary |
|
3195 User::LeaveIfError( GetStringAttribute( EDlAttrMediaTypeBoundary, boundary ) ); |
|
3196 HBufC* buf16 = HBufC::NewLC( KMaxUrlLength ); cleanupcount++; |
|
3197 TPtr buf16ptr = buf16->Des(); |
|
3198 User::LeaveIfError( GetStringAttribute( EDlAttrReqUrl, buf16ptr ) ); |
|
3199 |
|
3200 if(!iCodDownload) |
|
3201 { |
|
3202 iCodDownload = CCodDownload::NewL( aBuf, |
|
3203 aMimeType, |
|
3204 *iCodObserver, |
|
3205 aEikEnv, |
|
3206 &boundary, |
|
3207 &buf16ptr ); |
|
3208 } |
|
3209 CleanupStack::PopAndDestroy( cleanupcount ); |
|
3210 } |
|
3211 else |
|
3212 { |
|
3213 |
|
3214 if(!iCodDownload) |
|
3215 iCodDownload = CCodDownload::NewL( aBuf, aMimeType, *iCodObserver, aEikEnv ); |
|
3216 } |
|
3217 |
|
3218 if( !iWait ) |
|
3219 { |
|
3220 iWait = new (ELeave) CActiveSchedulerWait; |
|
3221 } |
|
3222 |
|
3223 SDMgrCodUserData* userData = new (ELeave) SDMgrCodUserData; |
|
3224 userData->iHandle = iHandle; |
|
3225 userData->iPrevCodEvent = (MCodDownloadObserver::TEvent)KInitPrevCodEvent; |
|
3226 iCodDownload->SetUserData( (TAny*)userData ); |
|
3227 iDownloadMgr->IncrementEventPriorityFlag(); |
|
3228 } |
|
3229 |
|
3230 |
|
3231 void RHttpDownload::InitPausedCodDownloadL( const TUid aAppUid ) |
|
3232 { |
|
3233 |
|
3234 TBuf8<KMaxContentTypeLength> contentType; |
|
3235 |
|
3236 GetStringAttribute( EDlAttrDDType , contentType ); |
|
3237 |
|
3238 CEikonEnv* eikenv = CEikonEnv::Static(); |
|
3239 |
|
3240 |
|
3241 TInt32 download; |
|
3242 GetIntAttribute(EDlAttrId , download); |
|
3243 |
|
3244 |
|
3245 if(iCodDownload) |
|
3246 { |
|
3247 delete iCodDownload; |
|
3248 iCodDownload = NULL; |
|
3249 } |
|
3250 |
|
3251 if(iCodObserver) |
|
3252 { |
|
3253 delete iCodObserver; |
|
3254 iCodObserver = NULL; |
|
3255 } |
|
3256 |
|
3257 SetBoolAttribute( EDlAttrCodDownload, ETrue ); |
|
3258 |
|
3259 if(!iCodObserver) |
|
3260 { |
|
3261 iCodObserver = CCodObserver::NewL( iDownloadMgr ); |
|
3262 } |
|
3263 |
|
3264 TBool silent( EFalse ); |
|
3265 iDownloadMgr->GetBoolAttribute( EDlMgrSilentMode, silent ); |
|
3266 if( silent ) |
|
3267 { |
|
3268 eikenv = NULL; |
|
3269 } |
|
3270 |
|
3271 if( 0 == contentType.Compare( KMultiPartMimeType() ) ) |
|
3272 { |
|
3273 /* |
|
3274 TInt cleanupcount( 0 ); |
|
3275 HBufC8* boundbuff = HBufC8::NewLC( KMaxContentTypeLength ); cleanupcount++; |
|
3276 TPtr8 boundary = boundbuff->Des(); |
|
3277 // Leave if media type doesn't exist; there is no boundary |
|
3278 User::LeaveIfError( GetStringAttribute( EDlAttrMediaTypeBoundary, boundary ) ); |
|
3279 HBufC* buf16 = HBufC::NewLC( KMaxUrlLength ); cleanupcount++; |
|
3280 TPtr buf16ptr = buf16->Des(); |
|
3281 User::LeaveIfError( GetStringAttribute( EDlAttrReqUrl, buf16ptr ) ); |
|
3282 |
|
3283 if(!iCodDownload) |
|
3284 { |
|
3285 iCodDownload = CCodDownload::NewL( aBuf, |
|
3286 aMimeType, |
|
3287 *iCodObserver, |
|
3288 aEikEnv, |
|
3289 &boundary, |
|
3290 &buf16ptr ); |
|
3291 } |
|
3292 CleanupStack::PopAndDestroy( cleanupcount ); */ |
|
3293 } |
|
3294 else |
|
3295 { |
|
3296 |
|
3297 if(!iCodDownload) |
|
3298 iCodDownload = CCodDownload::NewL( download, aAppUid, contentType, *iCodObserver, eikenv ); |
|
3299 } |
|
3300 |
|
3301 SDMgrCodUserData* userData = new (ELeave) SDMgrCodUserData; |
|
3302 userData->iHandle = iHandle; |
|
3303 userData->iPrevCodEvent = (MCodDownloadObserver::EDone); |
|
3304 iCodDownload->SetUserData( (TAny*)userData ); |
|
3305 iDownloadMgr->IncrementEventPriorityFlag(); |
|
3306 |
|
3307 |
|
3308 } |
|
3309 // --------------------------------------------------------- |
|
3310 // RHttpDownload::CheckContentTypeAndCreateCodDownloadL |
|
3311 // --------------------------------------------------------- |
|
3312 // |
|
3313 TBool RHttpDownload::CheckContentTypeAndCreateCodDownloadL() |
|
3314 { |
|
3315 CLOG_ENTERFN("RHttpDownload::CheckContentTypeAndCreateCodDownloadL"); |
|
3316 |
|
3317 TBool ret( ETrue ); // False if it is not a cod descriptor |
|
3318 // set in the if statement |
|
3319 |
|
3320 TBuf8<KMaxContentTypeLength> ddContentType; |
|
3321 |
|
3322 GetStringAttribute( EDlAttrDDType, ddContentType ); |
|
3323 |
|
3324 if( ( 0 == ddContentType.Compare( KCodMimeType() ) ) || |
|
3325 ( 0 == ddContentType.Compare( KDdMimeType() ) ) || |
|
3326 ( 0 == ddContentType.Compare( KDd2MimeType() ) ) || |
|
3327 ( 0 == ddContentType.Compare( KMultiPartMimeType() ) ) ) |
|
3328 { |
|
3329 |
|
3330 // This way we save IPC |
|
3331 TBuf<KMaxPath> fileName; |
|
3332 RFile file; |
|
3333 RFs fs; |
|
3334 TInt size( 0 ); |
|
3335 |
|
3336 CleanupClosePushL< RFs >( fs ); |
|
3337 CleanupClosePushL< RFile >( file ); |
|
3338 |
|
3339 // Get DD Filename for creating the download |
|
3340 User::LeaveIfError |
|
3341 ( GetStringAttribute( EDlAttrDdFileName, fileName ) ); |
|
3342 |
|
3343 User::LeaveIfError( fs.Connect() ); |
|
3344 |
|
3345 TInt err = file.Open( fs, fileName, |
|
3346 EFileShareReadersOnly | EFileStream | EFileRead ); |
|
3347 if ( err == KErrInUse ) |
|
3348 { |
|
3349 err = file.Open( fs, fileName, |
|
3350 EFileShareAny | EFileStream | EFileRead ); |
|
3351 } |
|
3352 User::LeaveIfError( err ); |
|
3353 User::LeaveIfError( file.Size( size ) ); |
|
3354 HBufC8* buf = HBufC8::NewLC( size ); |
|
3355 TPtr8 ptr = buf->Des(); |
|
3356 User::LeaveIfError( file.Read( ptr ) ); |
|
3357 CEikonEnv* eikenv = CEikonEnv::Static(); |
|
3358 |
|
3359 InitCodDownloadL( ptr, |
|
3360 ddContentType, |
|
3361 eikenv ); |
|
3362 |
|
3363 CleanupStack::PopAndDestroy( 3 ); // buf, file, fs |
|
3364 } |
|
3365 else |
|
3366 { |
|
3367 ret = EFalse; |
|
3368 } |
|
3369 |
|
3370 return ret; |
|
3371 } |
|
3372 |
|
3373 |
|
3374 // --------------------------------------------------------- |
|
3375 // RHttpDownload::SetOnError |
|
3376 // --------------------------------------------------------- |
|
3377 // |
|
3378 TInt RHttpDownload::SetOnError( TInt aError, |
|
3379 THttpDownloadMgrError aDlError ) |
|
3380 { |
|
3381 CLOG_WRITE( "RHttpDownload::SetOnError" ) |
|
3382 |
|
3383 if(iClosedSubSession) |
|
3384 { |
|
3385 return KErrNotSupported; |
|
3386 } |
|
3387 |
|
3388 return SendReceive( EHttpDownloadSetOnError, |
|
3389 TIpcArgs( aError, aDlError ) ); |
|
3390 } |
|
3391 |
|
3392 // ----------------------------------------------------------------------------- |
|
3393 // RHttpDownload::IsClientSideDownload |
|
3394 // ----------------------------------------------------------------------------- |
|
3395 // |
|
3396 TBool RHttpDownload::IsClientSideDownload() const |
|
3397 { |
|
3398 return iClientSideDownload; |
|
3399 } |
|
3400 |
|
3401 // --------------------------------------------------------- |
|
3402 // RHttpDownload::IsToBeDeleted |
|
3403 // --------------------------------------------------------- |
|
3404 // |
|
3405 TBool RHttpDownload::IsToBeDeleted() |
|
3406 { |
|
3407 CLOG_WRITE( "RHttpDownload::IsToBeDeleted" ) |
|
3408 return iExtension->iToBeDeleted; |
|
3409 } |
|
3410 |
|
3411 // --------------------------------------------------------- |
|
3412 // RHttpDownload::EventPriorityFlag |
|
3413 // --------------------------------------------------------- |
|
3414 // |
|
3415 TInt RHttpDownload::EventPriorityFlag() const |
|
3416 { |
|
3417 return iDownloadMgr->EventPriorityFlag(); |
|
3418 } |
|
3419 |
|
3420 // --------------------------------------------------------- |
|
3421 // RHttpDownload::ActiveMoIndex |
|
3422 // --------------------------------------------------------- |
|
3423 // |
|
3424 TInt32 RHttpDownload::ActiveMoIndex() const |
|
3425 { |
|
3426 return iExtension->iMoIndex; |
|
3427 } |
|
3428 |
|
3429 // --------------------------------------------------------- |
|
3430 // RHttpDownload::GetProductDownloadedSize |
|
3431 // --------------------------------------------------------- |
|
3432 // |
|
3433 TInt RHttpDownload::GetProductDownloadedSize( ) |
|
3434 { |
|
3435 TPckg<TInt32> pckg( iExtension->iMoDownloadedSize ); |
|
3436 return SendReceive( EHttpDownloadGetIntAttribute, TIpcArgs( EDlAttrMultipleMODownloadedSize, KNonMoIndex, &pckg ) ); |
|
3437 } |
|
3438 |
|
3439 // --------------------------------------------------------- |
|
3440 // RHttpDownload::StopWaitingAS() |
|
3441 // --------------------------------------------------------- |
|
3442 // |
|
3443 void RHttpDownload::StopWaitingAS() |
|
3444 { |
|
3445 if(iWait && iWait->IsStarted()) |
|
3446 { |
|
3447 iWait->AsyncStop(); |
|
3448 } |
|
3449 } |