|
1 /* |
|
2 * Copyright (c) 2002-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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "HeaderField.h" |
|
22 #include "HttpDownloadManagerServerEngine.h" |
|
23 #include "HttpClientApp.h" |
|
24 #include "FileExt.h" |
|
25 #include "HttpDownload.h" |
|
26 #include "HttpStorage.h" |
|
27 #include "HttpDownloadMgrLogger.h" |
|
28 #include "bautils.h" |
|
29 |
|
30 #include <CommDbConnPref.h> |
|
31 #include <Uri16.h> |
|
32 #include <F32FILE.H> |
|
33 #include <EscapeUtils.h> |
|
34 #include <HttpFilterCommonStringsExt.h> |
|
35 #include <tinternetdate.h> |
|
36 #include <SysUtil.h> |
|
37 #include <MGXFileManagerFactory.h> |
|
38 #include <CMGXFileManager.h> |
|
39 #include <DcfEntry.h> |
|
40 #include <DcfRep.h> |
|
41 |
|
42 #include <pathinfo.h> |
|
43 |
|
44 // EXTERNAL DATA STRUCTURES |
|
45 //extern ?external_data; |
|
46 |
|
47 // EXTERNAL FUNCTION PROTOTYPES |
|
48 //extern ?external_function( ?arg_type,?arg_type ); |
|
49 |
|
50 // CONSTANTS |
|
51 const TInt32 KDMgrInfoFileId = 0x2002; // id to check if it's really an info file |
|
52 const TInt32 KDmgrVersionNumber = 0x0301; // version number of the info file |
|
53 const TInt KUrlFixChar = '_'; |
|
54 const TInt KMaxHeaderOfMultipart = 32000; |
|
55 const TInt KRespSizeForRecognition = 1024; //for THttpProgressState EHttpContTypeRecognitionAvail |
|
56 const TInt KMinDataSizeToSend = (32*1024); //for Browser Control to call NewDownloadL |
|
57 |
|
58 _LIT8( KHttpScheme, "http" ); |
|
59 _LIT8( KHttpsScheme, "https" ); |
|
60 _LIT8( KDefDestFilename, "content.bin" ); |
|
61 _LIT8( KSchemeAddon, "://" ); |
|
62 _LIT8( KBoundary, "boundary=" ); |
|
63 _LIT8( KDoubleEOL, "\r\n\r\n" ); |
|
64 _LIT8( KContentType, "Content-Type: " ); |
|
65 |
|
66 #ifdef __SYNCML_DM_FOTA |
|
67 _LIT8( KFotaMimeType, "application/vnd.nokia.swupd.dp2"); |
|
68 #endif |
|
69 _LIT8( KDefaultAcceptHeader, "multipart/mixed, application/java-archive, application/java, application/x-java-archive, text/vnd.sun.j2me.app-descriptor, application/vnd.oma.drm.message, application/vnd.oma.drm.content, application/vnd.wap.mms-message, text/x-co/desc, application/vnd.oma.dd+xml, text/javascript, text/javascript, application/x-javascript, text/ecmascript, */*" ); |
|
70 _LIT8( KDRMOldContentType, "x-drm-old-content-type"); // old content type header to be added |
|
71 |
|
72 _LIT( KIndexString, "(%d)" ); |
|
73 const TInt KMaxIndexStringLength = 16; // max size of index string "(4294967296)" |
|
74 |
|
75 _LIT8( KCookieUsage, "CookiesEnabled" ); |
|
76 |
|
77 const TInt KStringAttribMaxLengths[][2] = { |
|
78 {EDlAttrReqUrl, KMaxUrlLength}, |
|
79 {EDlAttrRedirUlr, KMaxUrlLength}, |
|
80 {EDlAttrCurrentUrl, KMaxUrlLength}, |
|
81 {EDlAttrName, KMaxPath}, |
|
82 {EDlAttrRealm,KMaxRealmLength}, |
|
83 {EDlAttrUsername, KMaxDefAttrLength}, |
|
84 {EDlAttrPassword, KMaxDefAttrLength}, |
|
85 {EDlAttrProxyRealm, KMaxRealmLength}, |
|
86 {EDlAttrProxyUsername, KMaxDefAttrLength}, |
|
87 {EDlAttrProxyPassword, KMaxDefAttrLength}, |
|
88 {EDlAttrDestFilename, KMaxPath}, |
|
89 {EDlAttrContentType, KMaxContentTypeLength}, |
|
90 {EDlAttrMediaType, KMaxContentTypeLength}, |
|
91 {0,0} |
|
92 }; |
|
93 |
|
94 const TInt KDownloadInfoIncrSize = 2*4096; // used for DownloadInfo |
|
95 |
|
96 _LIT( KDownloadPath, "download"); |
|
97 |
|
98 // MACROS |
|
99 //#define ?macro ?macro_def |
|
100 |
|
101 #define _OMADLOTA2_MULTI_DOWNLOAD (iCodDlData && iCodDlData->Count()>1) |
|
102 |
|
103 // LOCAL CONSTANTS AND MACROS |
|
104 const TInt KDMHttpErrorBase = -25000; |
|
105 #define GLOBAL_HTTP_ERROR( err ) ( KDMHttpErrorBase - err ) |
|
106 const TInt KErrMultipeObjectDownloadFailed = -20046; |
|
107 |
|
108 // MODULE DATA STRUCTURES |
|
109 //enum ?declaration |
|
110 //typedef ?declaration |
|
111 |
|
112 // LOCAL FUNCTION PROTOTYPES |
|
113 //?type ?function_name( ?arg_type, ?arg_type ); |
|
114 |
|
115 // FORWARD DECLARATIONS |
|
116 //class ?FORWARD_CLASSNAME; |
|
117 |
|
118 // ============================ MEMBER FUNCTIONS =============================== |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CHttpDownload::CHttpDownload |
|
122 // C++ default constructor can NOT contain any code, that |
|
123 // might leave. |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 CHttpDownload::CHttpDownload( CHttpClientApp *aClientApp, |
|
127 TInt32 aId, |
|
128 CHttpClientAppInstance* aClAppInstance ) |
|
129 : CActive( EPriorityStandard ) |
|
130 , iId( aId ) |
|
131 , iClientApp( aClientApp ) |
|
132 , iClAppInstance( aClAppInstance ) |
|
133 , iPort( KDefaultPort ) |
|
134 , iDisconnectOnPause( ETrue ) |
|
135 , iDisconnectOnReset( ETrue ) |
|
136 , iCodDownload( 0 ) |
|
137 , iFotaPckgId( KDefaultFotaPckgId ) |
|
138 , iDate( 0, EJanuary, 1, 0, 0, 0, 0 ) |
|
139 , iExpires( 0, EJanuary, 1, 0, 0, 0, 0 ) |
|
140 , iDlState( EHttpDlMultipleMOStarted ) |
|
141 , iAction( ELaunch ) |
|
142 , iRestartAction( ERestartIfExpired ) |
|
143 , iPausable( ETrue ) |
|
144 , iPausableDRM( ETrue ) |
|
145 , iDrmContentLengthValid( ETrue ) |
|
146 , iMultiPart( EFalse ) |
|
147 , iDlNameChanged(EFalse) |
|
148 { |
|
149 __ASSERT_DEBUG( iClientApp, DMPanic( KErrArgument ) ); |
|
150 CLOG_CREATE; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CHttpDownload::ConstructL |
|
155 // Symbian 2nd phase constructor can leave. |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CHttpDownload::ConstructL( const TDesC8& aUrl ) |
|
159 { |
|
160 CLOG_NAME_2( _L("cl%x_d%x"), iClientApp->AppUid(), iId ); |
|
161 LOGGER_ENTERFN( "ConstructL" ); |
|
162 CLOG_WRITE8_1( "URL: %S", &aUrl ); |
|
163 |
|
164 CActiveScheduler::Add( this ); |
|
165 |
|
166 iResponseHeaders = new (ELeave) CArrayPtrFlat<CHeaderField>(2); |
|
167 iRequestHeaders = new (ELeave) CArrayPtrFlat<CHeaderField>(2); |
|
168 iEntityHeaders = new (ELeave) CArrayPtrFlat<CHeaderField>(2); |
|
169 iGeneralHeaders = new (ELeave) CArrayPtrFlat<CHeaderField>(2); |
|
170 iStorage = CHttpStorage::NewL( this ); |
|
171 iActiveDownload = 1 ; |
|
172 iMoLength = 0; |
|
173 iMoDownloadCompleted = EFalse; |
|
174 CLOG_ATTACH( iStorage, this ); |
|
175 |
|
176 iUrl = aUrl.AllocL(); |
|
177 if( iUrl->Length() ) |
|
178 // this is a new download |
|
179 { |
|
180 ParseRequestedUrlL(); // iCurrentUrl is initialized there |
|
181 ParseDownloadNameL(); |
|
182 StoreDownloadInfoL(); |
|
183 SetDownloadStatus( EHttpProgNone, EHttpDlMultipleMOStarted ); |
|
184 } |
|
185 else |
|
186 { |
|
187 LoadDownloadInfoL(); |
|
188 |
|
189 if( iDlState == EHttpDlInprogress ) |
|
190 // previous crash left this download here |
|
191 // reseting download can solve the problem |
|
192 { |
|
193 ++iDontFireEvent; |
|
194 |
|
195 TRAPD(err, PauseL() ); |
|
196 |
|
197 --iDontFireEvent; |
|
198 |
|
199 User::LeaveIfError( err ); |
|
200 } |
|
201 } |
|
202 |
|
203 if( !iStorage->CheckContentFileIntegrityL() ) |
|
204 { |
|
205 if (iStorage->ProgressiveDownload() && |
|
206 iStorage->Length() == iStorage->DownloadedSize() ) |
|
207 // If it was a progressive download |
|
208 // and downloaded size = content length, |
|
209 // it means that download was not properly closed |
|
210 // in the previous session |
|
211 { |
|
212 ReInitializeDownload(); |
|
213 } |
|
214 else |
|
215 { |
|
216 OnError( KErrUnknown, EContentFileIntegrity ); |
|
217 } |
|
218 } |
|
219 |
|
220 iMoveInProgress = EFalse; |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CHttpDownload::NewL |
|
225 // Two-phased constructor. |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 CHttpDownload* CHttpDownload::NewL( const TDesC8& aUrl, |
|
229 CHttpClientApp *aClientApp, |
|
230 TInt32 aId, |
|
231 CHttpClientAppInstance* aClAppInstance ) |
|
232 { |
|
233 __ASSERT_DEBUG( aId, DMPanic( KErrArgument ) ); |
|
234 CHttpDownload* self = new( ELeave ) CHttpDownload( aClientApp, |
|
235 aId, |
|
236 aClAppInstance ); |
|
237 |
|
238 CleanupStack::PushL( self ); |
|
239 self->ConstructL( aUrl ); |
|
240 CleanupStack::Pop(); |
|
241 |
|
242 return self; |
|
243 } |
|
244 |
|
245 |
|
246 // Destructor |
|
247 CHttpDownload::~CHttpDownload() |
|
248 { |
|
249 ++iDontFireEvent; |
|
250 |
|
251 Cancel(); |
|
252 |
|
253 delete iUrl; |
|
254 delete iRedirUrl; |
|
255 delete iCurrentUrl; |
|
256 delete iHttpRealm; |
|
257 delete iHttpNonce; |
|
258 delete iHttpUsername; |
|
259 delete iHttpPassword; |
|
260 delete iHttpProxyRealm; |
|
261 delete iHttpProxyUsername; |
|
262 delete iHttpProxyPassword; |
|
263 delete iContentType; |
|
264 delete iDDType; |
|
265 delete iMediaType; |
|
266 delete iDlName; |
|
267 delete iDispositionType; |
|
268 delete iFileMan; |
|
269 |
|
270 |
|
271 delete iHashedMsgBody; |
|
272 delete iDownloadInfo; |
|
273 delete iAttachmentFileName; |
|
274 |
|
275 if( iTransValid ) |
|
276 { |
|
277 iTrans.Close(); |
|
278 } |
|
279 |
|
280 if( iResponseHeaders ) |
|
281 { |
|
282 iResponseHeaders->ResetAndDestroy(); |
|
283 delete iResponseHeaders; |
|
284 } |
|
285 |
|
286 if( iRequestHeaders ) |
|
287 { |
|
288 iRequestHeaders->ResetAndDestroy(); |
|
289 delete iRequestHeaders; |
|
290 } |
|
291 |
|
292 if( iEntityHeaders ) |
|
293 { |
|
294 iEntityHeaders->ResetAndDestroy(); |
|
295 delete iEntityHeaders; |
|
296 } |
|
297 |
|
298 if( iGeneralHeaders ) |
|
299 { |
|
300 iGeneralHeaders->ResetAndDestroy(); |
|
301 delete iGeneralHeaders; |
|
302 } |
|
303 |
|
304 delete iStorage; |
|
305 iStorage = NULL; |
|
306 delete iHeaderOfMultipart; |
|
307 |
|
308 iMoveInProgress = EFalse; |
|
309 |
|
310 CLOG_CLOSE; |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CHttpDownload::Attach |
|
315 // ?implementation_description |
|
316 // (other items were commented in a header). |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 EXPORT_C void CHttpDownload::Attach( CHttpClientAppInstance* aClientAppInstance ) |
|
320 { |
|
321 LOGGER_ENTERFN( "CHttpDownload::Attach" ); |
|
322 |
|
323 __ASSERT_DEBUG( !iPDClAppInstance, DMPanic( KErrInUse) ); |
|
324 iPDClAppInstance = aClientAppInstance; |
|
325 } |
|
326 |
|
327 // ----------------------------------------------------------------------------- |
|
328 // CHttpDownload::StartL |
|
329 // ?implementation_description |
|
330 // (other items were commented in a header). |
|
331 // ----------------------------------------------------------------------------- |
|
332 // |
|
333 EXPORT_C void CHttpDownload::StartL() |
|
334 { |
|
335 LOGGER_ENTERFN( "StartL" ); |
|
336 |
|
337 __ASSERT_DEBUG( !iNoMedia, DMPanic( KErrAbort ) ); |
|
338 if( iNoMedia ) |
|
339 // nomedia download cannot be started |
|
340 { |
|
341 SetDownloadStatus( EHttpProgNone, EHttpDlFailed, EInternal ); |
|
342 |
|
343 return; |
|
344 } |
|
345 |
|
346 if( iContinueDownload ) |
|
347 // Don't do anything until user accepts the given content |
|
348 // to be downloaded. |
|
349 { |
|
350 CLOG_WRITE( "Continue download" ); |
|
351 |
|
352 |
|
353 if( !iConnHandler ) |
|
354 // assign download to the connhandler |
|
355 // connection is surely up because it was created from client side |
|
356 // iClAppInstance also must be valid because it's a continue download |
|
357 { |
|
358 iConnHandler = iClAppInstance->ConnHandler(); |
|
359 } |
|
360 |
|
361 if( iDlState == EHttpDlMultipleMOStarted ) |
|
362 // do it only if EHttpDlCreated, anyway ignore Start request |
|
363 { |
|
364 iStorage->CreateDestinationFileL(); |
|
365 |
|
366 SetDownloadStatus( EHttpProgResponseHeaderReceived ); |
|
367 } |
|
368 else if( iDlState == EHttpDlInprogress ) |
|
369 { |
|
370 TriggerEvent( EHttpDlAlreadyRunning ); |
|
371 } |
|
372 |
|
373 // This is the place where client already set every continue |
|
374 // download attribute |
|
375 StoreDownloadInfoL(); |
|
376 |
|
377 return; |
|
378 } |
|
379 if( iCodDownload ) |
|
380 { |
|
381 if(iDlState == EHttpDlPaused) |
|
382 { |
|
383 if( !iConnHandler ) |
|
384 { |
|
385 iConnHandler = iClAppInstance->ConnHandler(); |
|
386 } |
|
387 SetDownloadStatus( EHttpStarted ); |
|
388 //TriggerEvent( EHttpDlInprogress, EHttpProgCodDownloadShouldResume ); |
|
389 } |
|
390 else |
|
391 { |
|
392 TriggerEvent( EHttpDlInprogress, EHttpProgCodDownloadStarted ); |
|
393 } |
|
394 return; |
|
395 } |
|
396 switch( iDlState ) |
|
397 { |
|
398 case EHttpDlMultipleMOStarted: |
|
399 // normal start from the beginning |
|
400 break; |
|
401 |
|
402 case EHttpDlInprogress: |
|
403 |
|
404 if( iUpdatedDDUriSet ) |
|
405 { |
|
406 ReInitializeDownload(); |
|
407 |
|
408 iStorage->UpdateDestinationFilenameL( KNullDesC, EFalse ); |
|
409 |
|
410 ParseRequestedUrlL(); // iCurrentUrl is initialized there |
|
411 ParseDownloadNameL(); |
|
412 StoreDownloadInfoL(); |
|
413 SetDownloadStatus( EHttpStarted ); |
|
414 |
|
415 if( !iConnHandler ) |
|
416 // assign download to the connhandler |
|
417 // connection is surely up because it was created from client side |
|
418 // iClAppInstance also must be valid because it's a continue download |
|
419 { |
|
420 iConnHandler = iClAppInstance->ConnHandler(); |
|
421 } |
|
422 |
|
423 } |
|
424 else |
|
425 { |
|
426 TriggerEvent( EHttpDlAlreadyRunning ); |
|
427 } |
|
428 return; |
|
429 |
|
430 case EHttpDlPaused: |
|
431 { |
|
432 if( IsExpired() || !iPausable ) |
|
433 // cannot be resume: |
|
434 // expired |
|
435 // non-pauseable |
|
436 { |
|
437 ForcedRestartL(); |
|
438 } |
|
439 } |
|
440 break; |
|
441 |
|
442 case EHttpDlMultipleMOCompleted: |
|
443 { |
|
444 if( iRestartAction == ERestartNoIfCompleted ) |
|
445 // nothing to do because content is downloaded |
|
446 // and update check is not interested |
|
447 { |
|
448 TriggerEvent( EHttpDlMultipleMOCompleted ); |
|
449 return; |
|
450 } |
|
451 else if( iRestartAction == ERestartForced ) |
|
452 // doesn't matter what we have. |
|
453 // Download must be restarted from the very beginning |
|
454 { |
|
455 ForcedRestartL(); |
|
456 } |
|
457 else if( iRestartAction == ERestartIfExpired ) |
|
458 // First check that content is expired |
|
459 // If so, check for update on the server |
|
460 { |
|
461 if( !IsExpired() ) |
|
462 // content is still valid -> no need to download again |
|
463 // Client has to use ERestartForced or Reset() to |
|
464 // be able to download it again |
|
465 { |
|
466 TriggerEvent( EHttpDlMultipleMOCompleted ); |
|
467 return; |
|
468 } |
|
469 } |
|
470 } |
|
471 break; |
|
472 |
|
473 case EHttpDlFailed: |
|
474 { |
|
475 if( NoMedia() ) |
|
476 // we can't restart because original media is not present. |
|
477 // need a reset. |
|
478 { |
|
479 TriggerEvent( EHttpDlMediaRemoved ); |
|
480 } |
|
481 else if( iRestartAction == ERestartNoIfCompleted ) |
|
482 { |
|
483 if( iLastError == EContentExpired ) |
|
484 // Can't download content because it's expired. |
|
485 // Use ERestartIfExpired, ERestartForced or Reset() |
|
486 { |
|
487 OnError( KErrUnknown, EContentExpired ); |
|
488 return; |
|
489 } |
|
490 } |
|
491 } |
|
492 break; |
|
493 |
|
494 default: |
|
495 break; |
|
496 } |
|
497 |
|
498 if( iRedirect ) |
|
499 // Requested url has to be restored, because of a previous redirection |
|
500 { |
|
501 ReallocateStringL( iCurrentUrl, *iRedirUrl, KMaxUrlLength ); |
|
502 iRedirect = EFalse; |
|
503 } |
|
504 |
|
505 __ASSERT_DEBUG( iClAppInstance || iPDClAppInstance, DMPanic( KErrCorrupt ) ); |
|
506 if (iPDClAppInstance && !iClAppInstance ) |
|
507 //this is the case when browser is the main client and we exit browser |
|
508 //in this case the PD client has to be made the main client. |
|
509 { |
|
510 iClAppInstance = iPDClAppInstance; |
|
511 iPDClAppInstance = NULL; |
|
512 } |
|
513 if( iClAppInstance ) |
|
514 { |
|
515 if( !iConnHandler ) |
|
516 { |
|
517 iConnHandler = iClAppInstance->ConnHandler(); |
|
518 } |
|
519 |
|
520 iUseCookies = iClAppInstance->Cookies(); |
|
521 } |
|
522 |
|
523 iDlStartedByClient = ETrue; |
|
524 |
|
525 SetDownloadStatus( EHttpStarted ); |
|
526 |
|
527 } |
|
528 |
|
529 // ----------------------------------------------------------------------------- |
|
530 // CHttpDownload::PauseL |
|
531 // ?implementation_description |
|
532 // (other items were commented in a header). |
|
533 // ----------------------------------------------------------------------------- |
|
534 // |
|
535 EXPORT_C void CHttpDownload::PauseL( TBool aStore ) |
|
536 { |
|
537 LOGGER_ENTERFN( "PauseL" ); |
|
538 |
|
539 if( iDlState == EHttpDlPaused ) |
|
540 // already paused |
|
541 { |
|
542 TriggerEvent( EHttpDlPaused ); |
|
543 return; |
|
544 } |
|
545 |
|
546 //If the download is failed or completed, pause doesnt has any effect. |
|
547 if( iDlState == EHttpDlMultipleMOCompleted || iDlState == EHttpDlMultipleMOFailed ) |
|
548 { |
|
549 return; |
|
550 } |
|
551 |
|
552 InternalPauseL( iDisconnectOnPause ); |
|
553 |
|
554 //Pause the download only if it is pausable |
|
555 if( iDlState == EHttpDlInprogress ) |
|
556 { |
|
557 if( Pausable() ) |
|
558 // Do not change state when it's |
|
559 // created, pause, completed or failed. |
|
560 { |
|
561 SetDownloadStatus( EHttpProgNone, EHttpDlPaused ); |
|
562 |
|
563 if( iCodDownload ) |
|
564 { |
|
565 TriggerEvent( EHttpDlPaused, EHttpProgCodDownloadPause ); |
|
566 } |
|
567 } |
|
568 else |
|
569 { |
|
570 //Else report error |
|
571 OnError( iGlobalErrorId, (THttpDownloadMgrError) iLastError ); |
|
572 } |
|
573 } |
|
574 |
|
575 if( aStore && Pausable() ) |
|
576 { |
|
577 StoreDownloadInfoL(); |
|
578 } |
|
579 } |
|
580 |
|
581 // ----------------------------------------------------------------------------- |
|
582 // CHttpDownload::Reset |
|
583 // ?implementation_description |
|
584 // (other items were commented in a header). |
|
585 // ----------------------------------------------------------------------------- |
|
586 // |
|
587 EXPORT_C void CHttpDownload::Reset() |
|
588 { |
|
589 LOGGER_ENTERFN( "Reset" ); |
|
590 |
|
591 DoReset(); |
|
592 } |
|
593 |
|
594 // ----------------------------------------------------------------------------- |
|
595 // CHttpDownload::Delete |
|
596 // ?implementation_description |
|
597 // (other items were commented in a header). |
|
598 // ----------------------------------------------------------------------------- |
|
599 // |
|
600 EXPORT_C void CHttpDownload::Delete( CHttpClientAppInstance* aClAppInstance ) |
|
601 { |
|
602 CLOG_WRITE( "Delete()" ); |
|
603 if( !ClientApp()->Engine()->IsEngineClosing() ) |
|
604 { |
|
605 if( aClAppInstance ) |
|
606 { |
|
607 if( iPDClAppInstance == aClAppInstance ) |
|
608 { |
|
609 iPDClAppInstance = NULL; |
|
610 if( !iStorage->ProgressiveMode() ) |
|
611 { |
|
612 return;//This Attribute tells if Delete is called from MP when Exiting from Browser |
|
613 } |
|
614 if( iClAppInstance ) |
|
615 { |
|
616 SetDownloadStatus( EHttpProgNone, EHttpDlDeleting ); |
|
617 //Deref Attach Download instance |
|
618 aClAppInstance->ClientApp()->UnregisterDownload( this ); |
|
619 return; |
|
620 } |
|
621 } |
|
622 else if( iClAppInstance == aClAppInstance ) |
|
623 { |
|
624 iClAppInstance = NULL; |
|
625 if( iPDClAppInstance ) |
|
626 { |
|
627 SetDownloadStatus( EHttpProgNone, EHttpDlDeleting ); |
|
628 //Deref Master Client Instance |
|
629 aClAppInstance->ClientApp()->UnregisterDownload( this ); |
|
630 return; |
|
631 } |
|
632 } |
|
633 } |
|
634 } |
|
635 |
|
636 // Do not inform user about that we are in deleteing state |
|
637 // This won't be reenabled at the end of this function so |
|
638 // don't call delete only from outside of this class. |
|
639 ++iDontFireEvent; |
|
640 |
|
641 TPath folder; |
|
642 TFileName file; |
|
643 |
|
644 // delete info file |
|
645 iClientApp->Engine()->DownloadInfoFolder( iClientApp, folder ); |
|
646 file.Format( _L("%S%d"), &folder, iId ); |
|
647 TInt err = iClientApp->Engine()->Fs().Delete( file ); |
|
648 CLOG_WRITE_2( "Delete info file: %S, err : %d", &file, err ); |
|
649 |
|
650 // delete cod info file |
|
651 iClientApp->Engine()->CODDownloadInfoFolder( iClientApp, folder ); |
|
652 file.Format( _L("%S%d"), &folder, iId ); |
|
653 //delete main info file |
|
654 err = iClientApp->Engine()->Fs().Delete( file ); |
|
655 CLOG_WRITE_2( "Delete info file: %S, err : %d", &file, err ); |
|
656 |
|
657 //delete subinfo file |
|
658 CFileMan* fileMan = CFileMan::NewL(iClientApp->Engine()->Fs() ); |
|
659 file.Format( _L("%S%d_*"), &folder, iId ); |
|
660 fileMan->Delete( file ); |
|
661 delete fileMan; |
|
662 |
|
663 |
|
664 // to make sure the CHttpStorage releases the content file |
|
665 // and deletes it. |
|
666 CHttpStorage::TFileCloseOperation closeOp = CHttpStorage::EDeleteFile; |
|
667 |
|
668 if( iStorage->DestFNameSet() && iDlState == EHttpDlMultipleMOCompleted ) |
|
669 // Do NOT delete the file: if the destination filename was |
|
670 // set by the client and download completed. |
|
671 { |
|
672 CLOG_WRITE("Keep file"); |
|
673 closeOp = CHttpStorage::EKeepFile; |
|
674 } |
|
675 |
|
676 if( iStorage->RFileSetByClient()) |
|
677 { |
|
678 TBool pausable; |
|
679 GetBoolAttributeL( EDlAttrPausable, pausable ); |
|
680 if( iDlState == EHttpDlMultipleMOCompleted || ( iDlState == EHttpDlInprogress && pausable ) ) |
|
681 { |
|
682 CLOG_WRITE("Keep file"); |
|
683 closeOp = CHttpStorage::EKeepFile; |
|
684 } |
|
685 } |
|
686 if( iCodDlData ) |
|
687 { |
|
688 // For User Delete when all the Downloads are moved to gallery |
|
689 if( EHttpDlMultipleMOCompleted == iDlState && closeOp == CHttpStorage::EDeleteFile ) |
|
690 { |
|
691 for(TInt i = 1; i <= iCodDlData->Count(); i++) |
|
692 { |
|
693 TPtrC fullName = ((*iCodDlData)[i])->DestFilename(); |
|
694 ClientApp()->Engine()->Fs().Delete( fullName ); |
|
695 } |
|
696 } |
|
697 // For User Cancel to Cancel Multiple download, Current and Queued DLs will be delete, completed ones will be kept |
|
698 else if( EHttpDlInprogress == iDlState || EHttpDlPaused == iDlState || EHttpDlDeleting == iDlState) |
|
699 { |
|
700 for(TInt i = 1; i <= iCodDlData->Count(); i++) |
|
701 { |
|
702 if( EInProgress == ((*iCodDlData)[i])->State() || EFailed == ((*iCodDlData)[i])->State() ) // OnGoing and Queued will be deleted |
|
703 { |
|
704 TPtrC fullName = ((*iCodDlData)[i])->DestFilename(); |
|
705 if(fullName.Length()) |
|
706 { |
|
707 ClientApp()->Engine()->Fs().Delete( fullName ); |
|
708 } |
|
709 } |
|
710 //else if( ESucceeded == ((*iCodDlData)[i])->State() ) |
|
711 // Completed ones will be kept and moved to Gallery |
|
712 else if( ESucceeded == ((*iCodDlData)[i])->State() ) |
|
713 { |
|
714 MoveInDelete(i); |
|
715 } |
|
716 } |
|
717 } |
|
718 } |
|
719 else |
|
720 { |
|
721 iStorage->CloseDestinationFile( closeOp ); |
|
722 } |
|
723 // when delete there's no store -> no leave |
|
724 aClAppInstance->ClientApp()->UnregisterDownload( this ); |
|
725 } |
|
726 |
|
727 |
|
728 // ----------------------------------------------------------------------------- |
|
729 // CHttpDownload::DeleteInfoFile |
|
730 // ?implementation_description |
|
731 // (other items were commented in a header). |
|
732 // ----------------------------------------------------------------------------- |
|
733 // |
|
734 EXPORT_C void CHttpDownload::DeleteInfoFile( CHttpClientAppInstance* aClAppInstance ) |
|
735 { |
|
736 CLOG_WRITE( "DeleteInfoFile()" ); |
|
737 |
|
738 // This should be called only after the completion of download |
|
739 if( ! (EHttpDlMultipleMOCompleted == iDlState && |
|
740 ( |
|
741 EHttpProgContentFileMoved == iProgState || |
|
742 EHttpProgContentFileMovedAndDestFNChanged == iProgState |
|
743 ) |
|
744 )) |
|
745 { |
|
746 return; |
|
747 } |
|
748 |
|
749 // Do not inform user about that we are in deleteing state |
|
750 // This won't be reenabled at the end of this function so |
|
751 // don't call delete only from outside of this class. |
|
752 ++iDontFireEvent; |
|
753 |
|
754 TPath folder; |
|
755 TFileName file; |
|
756 |
|
757 // delete info file |
|
758 iClientApp->Engine()->DownloadInfoFolder( iClientApp, folder ); |
|
759 file.Format( _L("%S%d"), &folder, iId ); |
|
760 CLOG_WRITE_1( "Delete info file: %S", &file ); |
|
761 iClientApp->Engine()->Fs().Delete( file ); |
|
762 |
|
763 // delete cod info file |
|
764 iClientApp->Engine()->CODDownloadInfoFolder( iClientApp, folder ); |
|
765 file.Format( _L("%S%d"), &folder, iId ); |
|
766 CLOG_WRITE_1( "Delete info file: %S", &file ); |
|
767 iClientApp->Engine()->Fs().Delete( file ); |
|
768 |
|
769 //delete subinfo file |
|
770 CFileMan* fileMan = CFileMan::NewL(iClientApp->Engine()->Fs() ); |
|
771 file.Format( _L("%S%d_*"), &folder, iId ); |
|
772 fileMan->Delete( file ); |
|
773 delete fileMan; |
|
774 |
|
775 |
|
776 // to make sure the CHttpStorage releases the content file |
|
777 // and deletes it. |
|
778 CHttpStorage::TFileCloseOperation closeOp = CHttpStorage::EDeleteFile; |
|
779 |
|
780 if( iStorage->DestFNameSet() && iDlState == EHttpDlMultipleMOCompleted ) |
|
781 // Do NOT delete the file: if the destination filename was |
|
782 // set by the client and download completed. |
|
783 { |
|
784 CLOG_WRITE("Keep file"); |
|
785 closeOp = CHttpStorage::EKeepFile; |
|
786 } |
|
787 |
|
788 iStorage->CloseDestinationFile( closeOp ); |
|
789 |
|
790 // when delete there's no store -> no leave |
|
791 aClAppInstance->ClientApp()->UnregisterDownload( this ); |
|
792 } |
|
793 |
|
794 |
|
795 // ----------------------------------------------------------------------------- |
|
796 // CHttpDownload::MoveL |
|
797 // ?implementation_description |
|
798 // (other items were commented in a header). |
|
799 // ----------------------------------------------------------------------------- |
|
800 // |
|
801 EXPORT_C void CHttpDownload::MoveL() |
|
802 { |
|
803 LOGGER_ENTERFN( "MoveL" ); |
|
804 |
|
805 |
|
806 if(iMoveInProgress) |
|
807 { |
|
808 CLOG_WRITE(" return MoveL "); |
|
809 return; |
|
810 } |
|
811 |
|
812 iMoveInProgress = ETrue; |
|
813 |
|
814 if( !iCodDownload && iDlState != EHttpDlMultipleMOCompleted ) |
|
815 { |
|
816 User::Leave( KErrNotReady ); |
|
817 } |
|
818 //Incase of COD downloads, Move should happen only after COD Load End |
|
819 if( iCodDownload && iProgState != EHttpProgCodLoadEnd ) |
|
820 { |
|
821 User::Leave( KErrNotReady ); |
|
822 } |
|
823 |
|
824 if( iProgState == EHttpProgMovingContentFile ) |
|
825 { |
|
826 User::Leave( KErrInUse ); |
|
827 } |
|
828 |
|
829 //File is already moved. Ignore the move |
|
830 if( iProgState == EHttpProgContentFileMovedAndDestFNChanged || |
|
831 |
|
832 iProgState == EHttpProgContentFileMoved ) |
|
833 { |
|
834 return; |
|
835 } |
|
836 |
|
837 __ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
|
838 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
|
839 |
|
840 if(_OMADLOTA2_MULTI_DOWNLOAD) |
|
841 { |
|
842 iMOMoved = 1; |
|
843 SetDownloadStatus( EHttpProgMovingContentFile, iDlState ); |
|
844 MoveDownloadedMediaObjectL(iMOMoved); |
|
845 return; |
|
846 } |
|
847 |
|
848 |
|
849 RFs &rFs = iClientApp->Engine()->Fs(); |
|
850 if(!iFileMan) |
|
851 { |
|
852 iFileMan = CFileMan::NewL(rFs); |
|
853 } |
|
854 |
|
855 CLOG_WRITE_1( "Src: %S", iStorage->LocalFilename() ); |
|
856 CLOG_WRITE_1( "Dest: %S", iStorage->DestFilename() ); |
|
857 UpdateDestFileNameL(); |
|
858 |
|
859 HBufC* fileName = HBufC::NewLC( KMaxPath ); |
|
860 TPtr fileNamePtr = fileName->Des(); |
|
861 fileNamePtr = *iStorage->DestFilename(); |
|
862 HBufC* uniqueName = NULL; |
|
863 TInt index( 0 ); |
|
864 TBool bFound( EFalse ); |
|
865 do |
|
866 { |
|
867 CreateIndexedNameL(uniqueName , fileNamePtr , index); |
|
868 if( !BaflUtils::FileExists( rFs , *uniqueName ) ) |
|
869 //Check if file name exist in Destination path |
|
870 //Generate Unique name if exist |
|
871 { |
|
872 bFound =ETrue; |
|
873 break; |
|
874 } |
|
875 iDlNameChanged = ETrue; |
|
876 |
|
877 }while( !bFound ); |
|
878 CleanupStack::PopAndDestroy( fileName ); |
|
879 |
|
880 if( iDlNameChanged ) |
|
881 { |
|
882 HBufC16* destFileName ; |
|
883 destFileName = iStorage->DestFilename(); |
|
884 TPtr destFileNamePtr = destFileName->Des(); |
|
885 destFileNamePtr.Replace(0, destFileNamePtr.Length() , *uniqueName); |
|
886 TInt lastSlashPos = destFileNamePtr.LocateReverse( '\\' ); |
|
887 TPtr dlName = destFileNamePtr.MidTPtr(lastSlashPos +1 ); |
|
888 TInt dotPos = iDlName->LocateReverse( '.' ); |
|
889 if( dotPos == KErrNotFound ) |
|
890 { |
|
891 //Remove Extension from dlName as it was not present in old iDlName |
|
892 dotPos = dlName.LocateReverse( '.' ); |
|
893 if(dotPos != KErrNotFound ) |
|
894 { |
|
895 dlName.Copy( dlName.Left(dotPos)); |
|
896 } |
|
897 } |
|
898 //download name has changed |
|
899 ReallocateStringL( iDlName, dlName, KDownloadNameMaxSize ); |
|
900 } |
|
901 |
|
902 TInt err =iFileMan->Move( *iStorage->LocalFilename(), |
|
903 *iStorage->DestFilename(), |
|
904 CFileMan::EOverWrite, |
|
905 iStatus ); |
|
906 if(err != KErrNone) |
|
907 { |
|
908 iMoveInProgress = EFalse; |
|
909 CLOG_WRITE("setting iMoveInProgress false when move fails"); |
|
910 } |
|
911 |
|
912 User::LeaveIfError( err ); |
|
913 // waiting for move to complete |
|
914 SetActive(); |
|
915 SetDownloadStatus( EHttpProgMovingContentFile, iDlState ); |
|
916 } |
|
917 |
|
918 // ----------------------------------------------------------------------------- |
|
919 // CHttpDownload::GetIntAttributeL |
|
920 // ?implementation_description |
|
921 // (other items were commented in a header). |
|
922 // ----------------------------------------------------------------------------- |
|
923 // |
|
924 EXPORT_C void CHttpDownload::GetIntAttributeL( THttpDownloadAttrib aAttribute, |
|
925 TInt32& aValue ) |
|
926 { |
|
927 LOGGER_ENTERFN( "GetIntAttributeL" ); |
|
928 CLOG_WRITE_1( "Attr(%d)", aAttribute ); |
|
929 |
|
930 iNoRealError = ETrue; |
|
931 |
|
932 switch( aAttribute ) |
|
933 { |
|
934 case EDlAttrState: |
|
935 { |
|
936 if(iDlState == EHttpDlMultipleMOCompleted ) |
|
937 { |
|
938 aValue = EHttpDlCompleted; |
|
939 } |
|
940 else if(iDlState == EHttpDlMultipleMOFailed ) |
|
941 { |
|
942 aValue = EHttpDlFailed; |
|
943 } |
|
944 else |
|
945 { |
|
946 aValue = iDlState; |
|
947 } |
|
948 } |
|
949 break; |
|
950 |
|
951 case EDlAttrProgressState: |
|
952 { |
|
953 aValue = iProgState; |
|
954 } |
|
955 break; |
|
956 |
|
957 case EDlAttrUserData: |
|
958 { |
|
959 aValue = iUserData; |
|
960 } |
|
961 break; |
|
962 |
|
963 case EDlAttrId: |
|
964 { |
|
965 aValue = iId; |
|
966 } |
|
967 break; |
|
968 |
|
969 case EDlAttrMultipleMOLength: |
|
970 { |
|
971 if ( iCodDownload ) |
|
972 { |
|
973 aValue = iMoLength; |
|
974 } |
|
975 else |
|
976 { |
|
977 aValue = iStorage->Length(); |
|
978 } |
|
979 } |
|
980 break; |
|
981 |
|
982 case EDlAttrMultipleMODownloadedSize: |
|
983 { |
|
984 if( iCodDownload ) |
|
985 { |
|
986 aValue = iStorage->MoDownloadedSize(); |
|
987 } |
|
988 else |
|
989 { |
|
990 aValue = iStorage->DownloadedSize(); |
|
991 } |
|
992 } |
|
993 break; |
|
994 |
|
995 case EDlAttrLength: |
|
996 { |
|
997 aValue = iStorage->Length(); |
|
998 } |
|
999 break; |
|
1000 |
|
1001 case EDlAttrDownloadedSize: |
|
1002 { |
|
1003 aValue = iStorage->DownloadedSize(); |
|
1004 } |
|
1005 break; |
|
1006 |
|
1007 case EDlAttrStatusCode: |
|
1008 { |
|
1009 aValue = iStatusCode; |
|
1010 } |
|
1011 break; |
|
1012 |
|
1013 case EDlAttrAction: |
|
1014 { |
|
1015 aValue = iAction; |
|
1016 } |
|
1017 break; |
|
1018 |
|
1019 case EDlAttrPort: |
|
1020 { |
|
1021 aValue = iPort; |
|
1022 } |
|
1023 break; |
|
1024 |
|
1025 case EDlAttrRestartAction: |
|
1026 { |
|
1027 aValue = iRestartAction; |
|
1028 } |
|
1029 break; |
|
1030 |
|
1031 case EDlAttrErrorId: |
|
1032 { |
|
1033 aValue = iLastError; |
|
1034 } |
|
1035 break; |
|
1036 |
|
1037 case EDlAttrGlobalErrorId: |
|
1038 { |
|
1039 aValue = iGlobalErrorId; |
|
1040 } |
|
1041 break; |
|
1042 |
|
1043 case EDlAttrTargetApp: |
|
1044 { |
|
1045 aValue = iTargetApp; |
|
1046 } |
|
1047 break; |
|
1048 |
|
1049 case EDlAttrAuthScheme: |
|
1050 { |
|
1051 aValue = iAuthScheme; |
|
1052 } |
|
1053 break; |
|
1054 |
|
1055 case EDlAttrRequestHeaderAddonLength: |
|
1056 { |
|
1057 aValue = 0; |
|
1058 |
|
1059 for( TInt i = 0; i < iRequestHeaders->Count(); ++i ) |
|
1060 { |
|
1061 aValue += (*iRequestHeaders)[i]->FieldName()->Length() + |
|
1062 (*iRequestHeaders)[i]->FieldRawData()->Length() + |
|
1063 2; // +2 = KColon + KHttpFieldSeparator |
|
1064 } |
|
1065 } |
|
1066 break; |
|
1067 |
|
1068 case EDlAttrMethod: |
|
1069 { |
|
1070 aValue = iMethod; |
|
1071 } |
|
1072 break; |
|
1073 |
|
1074 case EDlAttrFotaPckgId: |
|
1075 { |
|
1076 aValue = iFotaPckgId; |
|
1077 } |
|
1078 break; |
|
1079 |
|
1080 case EDlAttrNumMediaObjects: |
|
1081 { |
|
1082 aValue = 1; |
|
1083 if(iCodDlData) |
|
1084 { |
|
1085 aValue = iCodDlData->Count(); |
|
1086 } |
|
1087 } |
|
1088 break; |
|
1089 case EDlAttrActiveDownload: |
|
1090 { |
|
1091 aValue = iActiveDownload; |
|
1092 } |
|
1093 break; |
|
1094 case EDlAttrActivePlayedDownload: |
|
1095 { |
|
1096 aValue = iActivePlayedDownload; |
|
1097 } |
|
1098 break; |
|
1099 |
|
1100 default: |
|
1101 { |
|
1102 CLOG_WRITE_1( "Unknown int attrib: %d", aAttribute ); |
|
1103 #ifdef __WINS__ |
|
1104 DMPanic( KErrArgument ); |
|
1105 #else |
|
1106 User::Leave( KErrArgument ); |
|
1107 #endif |
|
1108 } |
|
1109 break; |
|
1110 } |
|
1111 |
|
1112 iNoRealError = EFalse; |
|
1113 } |
|
1114 |
|
1115 // ----------------------------------------------------------------------------- |
|
1116 // CHttpDownload::GetIntAttributeL |
|
1117 // ?implementation_description |
|
1118 // (other items were commented in a header). |
|
1119 // ----------------------------------------------------------------------------- |
|
1120 // |
|
1121 EXPORT_C void CHttpDownload::GetIntAttributeL( THttpDownloadAttrib aAttribute, |
|
1122 TInt32& aMoIndex, |
|
1123 TInt32& aValue ) |
|
1124 { |
|
1125 LOGGER_ENTERFN( "GetIntAttributeL" ); |
|
1126 CLOG_WRITE_1( "Attr(%d)", aAttribute ); |
|
1127 |
|
1128 if (!iCodDlData) |
|
1129 { |
|
1130 aValue = 0; |
|
1131 return; |
|
1132 } |
|
1133 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
|
1134 { |
|
1135 User::Leave( KErrArgument ); |
|
1136 } |
|
1137 |
|
1138 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
|
1139 iNoRealError = ETrue; |
|
1140 |
|
1141 switch( aAttribute ) |
|
1142 { |
|
1143 case EDlAttrMultipleMOLength: |
|
1144 { |
|
1145 aValue = iMoLength; |
|
1146 } |
|
1147 break; |
|
1148 |
|
1149 case EDlAttrMultipleMODownloadedSize: |
|
1150 { |
|
1151 // Calculate downloaded size of current media object from |
|
1152 // album downloaded size. |
|
1153 TInt dlSize = iStorage->DownloadedSize(); |
|
1154 for (TInt index = 0; index < iCodDlData->Count(); ++index) |
|
1155 { |
|
1156 CMediaDataBase* moData = (*iCodDlData)[index+1]; |
|
1157 if ((moData->State() == ESucceeded) || (moData->State() == EInProgress)) |
|
1158 dlSize -= moData->DownloadedSize(); |
|
1159 } |
|
1160 |
|
1161 aValue = dlSize; |
|
1162 } |
|
1163 break; |
|
1164 |
|
1165 case EDlAttrLength: |
|
1166 { |
|
1167 aValue = iStorage->Length(); |
|
1168 } |
|
1169 break; |
|
1170 |
|
1171 case EDlAttrDownloadedSize: |
|
1172 { |
|
1173 aValue = iStorage->DownloadedSize(); |
|
1174 } |
|
1175 break; |
|
1176 |
|
1177 case EDlAttrErrorId: |
|
1178 { |
|
1179 aValue = mediaData->LastErrorId(); |
|
1180 } |
|
1181 break; |
|
1182 |
|
1183 case EDlAttrGlobalErrorId: |
|
1184 { |
|
1185 aValue = mediaData->GlobalErrorId(); |
|
1186 } |
|
1187 break; |
|
1188 |
|
1189 case EDlAttrMethod: |
|
1190 { |
|
1191 aValue = mediaData->Method(); |
|
1192 } |
|
1193 break; |
|
1194 |
|
1195 default: |
|
1196 { |
|
1197 CLOG_WRITE_1( "Unknown int attrib: %d", aAttribute ); |
|
1198 #ifdef __WINS__ |
|
1199 DMPanic( KErrArgument ); |
|
1200 #else |
|
1201 User::Leave( KErrArgument ); |
|
1202 #endif |
|
1203 } |
|
1204 break; |
|
1205 } |
|
1206 |
|
1207 iNoRealError = EFalse; |
|
1208 } |
|
1209 |
|
1210 // ----------------------------------------------------------------------------- |
|
1211 // CHttpDownload::GetBoolAttributeL |
|
1212 // ?implementation_description |
|
1213 // (other items were commented in a header). |
|
1214 // ----------------------------------------------------------------------------- |
|
1215 // |
|
1216 EXPORT_C void CHttpDownload::GetBoolAttributeL( THttpDownloadAttrib aAttribute, |
|
1217 TBool& aValue ) |
|
1218 { |
|
1219 LOGGER_ENTERFN( "GetBoolAttributeL" ); |
|
1220 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
|
1221 |
|
1222 iNoRealError = ETrue; |
|
1223 |
|
1224 switch( aAttribute ) |
|
1225 { |
|
1226 case EDlAttrNoContentTypeCheck: |
|
1227 { |
|
1228 aValue = iNoContentTypeCheck; |
|
1229 } |
|
1230 break; |
|
1231 |
|
1232 case EDlAttrDisconnectOnReset: |
|
1233 { |
|
1234 aValue = iDisconnectOnReset; |
|
1235 } |
|
1236 break; |
|
1237 |
|
1238 case EDlAttrDisconnectOnPause: |
|
1239 { |
|
1240 aValue = iDisconnectOnPause; |
|
1241 } |
|
1242 break; |
|
1243 |
|
1244 case EDlAttrNoMedia: |
|
1245 { |
|
1246 aValue = iNoMedia; |
|
1247 } |
|
1248 break; |
|
1249 |
|
1250 case EDlAttrRedirected: |
|
1251 { |
|
1252 aValue = iRedirect; |
|
1253 } |
|
1254 break; |
|
1255 |
|
1256 case EDlAttrPausable: |
|
1257 { |
|
1258 aValue = iPausable; |
|
1259 } |
|
1260 break; |
|
1261 |
|
1262 case EDlAttrHidden: |
|
1263 { |
|
1264 aValue = iHidden; |
|
1265 } |
|
1266 break; |
|
1267 |
|
1268 case EDlAttrSilent: |
|
1269 { |
|
1270 aValue = iSilentMode; |
|
1271 } |
|
1272 break; |
|
1273 |
|
1274 case EDlAttrContinue: |
|
1275 { |
|
1276 aValue = iContinueDownload; |
|
1277 } |
|
1278 break; |
|
1279 |
|
1280 case EDlAttrCodDownload: |
|
1281 { |
|
1282 aValue = iCodDownload; |
|
1283 } |
|
1284 break; |
|
1285 |
|
1286 case EDlAttrProgressive: |
|
1287 { |
|
1288 aValue = iStorage->ProgressiveMode(); |
|
1289 } |
|
1290 break; |
|
1291 |
|
1292 case EDlAttrDestRemovable: |
|
1293 { |
|
1294 aValue = iStorage->RemovableDest(); |
|
1295 } |
|
1296 break; |
|
1297 |
|
1298 case EDlAttrCodPdAvailable: |
|
1299 { |
|
1300 aValue = iCodPdAvailable; |
|
1301 } |
|
1302 break; |
|
1303 default: |
|
1304 { |
|
1305 CLOG_WRITE_1( "Unknown bool attrib: %d", aAttribute ); |
|
1306 |
|
1307 #ifdef __WINS__ |
|
1308 DMPanic( KErrArgument ); |
|
1309 #else |
|
1310 User::Leave( KErrArgument ); |
|
1311 #endif |
|
1312 } |
|
1313 break; |
|
1314 } |
|
1315 |
|
1316 iNoRealError = EFalse; |
|
1317 } |
|
1318 |
|
1319 // ----------------------------------------------------------------------------- |
|
1320 // CHttpDownload::GetBoolAttributeL |
|
1321 // ?implementation_description |
|
1322 // (other items were commented in a header). |
|
1323 // ----------------------------------------------------------------------------- |
|
1324 // |
|
1325 EXPORT_C void CHttpDownload::GetBoolAttributeL( THttpDownloadAttrib aAttribute, |
|
1326 TInt32& aMoIndex, |
|
1327 TBool& aValue ) |
|
1328 { |
|
1329 LOGGER_ENTERFN( "GetBoolAttributeL" ); |
|
1330 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
|
1331 |
|
1332 if (!iCodDlData) |
|
1333 { |
|
1334 aValue = 0; |
|
1335 return; |
|
1336 } |
|
1337 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
|
1338 { |
|
1339 User::Leave( KErrArgument ); |
|
1340 } |
|
1341 |
|
1342 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
|
1343 iNoRealError = ETrue; |
|
1344 |
|
1345 switch( aAttribute ) |
|
1346 { |
|
1347 case EDlAttrRedirected: |
|
1348 { |
|
1349 aValue = mediaData->Redirected(); |
|
1350 } |
|
1351 break; |
|
1352 |
|
1353 case EDlAttrPausable: |
|
1354 { |
|
1355 aValue = mediaData->Pausable(); |
|
1356 } |
|
1357 break; |
|
1358 |
|
1359 case EDlAttrProgressive: |
|
1360 { |
|
1361 aValue = mediaData->ProgressiveDownload(); |
|
1362 } |
|
1363 break; |
|
1364 |
|
1365 case EDlAttrDestRemovable: |
|
1366 { |
|
1367 aValue = mediaData->DesRemovable(); |
|
1368 } |
|
1369 break; |
|
1370 |
|
1371 default: |
|
1372 { |
|
1373 CLOG_WRITE_1( "Unknown bool attrib: %d", aAttribute ); |
|
1374 |
|
1375 #ifdef __WINS__ |
|
1376 DMPanic( KErrArgument ); |
|
1377 #else |
|
1378 User::Leave( KErrArgument ); |
|
1379 #endif |
|
1380 } |
|
1381 break; |
|
1382 } |
|
1383 |
|
1384 iNoRealError = EFalse; |
|
1385 } |
|
1386 |
|
1387 // ----------------------------------------------------------------------------- |
|
1388 // CHttpDownload::GetStringAttributeL |
|
1389 // ?implementation_description |
|
1390 // (other items were commented in a header). |
|
1391 // ----------------------------------------------------------------------------- |
|
1392 // |
|
1393 EXPORT_C HBufC* CHttpDownload::GetStringAttributeL( THttpDownloadAttrib aAttribute, |
|
1394 TBool& aDelete ) |
|
1395 { |
|
1396 LOGGER_ENTERFN( "GetStringAttributeL" ); |
|
1397 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
|
1398 |
|
1399 iNoRealError = ETrue; |
|
1400 HBufC* attr = NULL; |
|
1401 HBufC8* attr8 = NULL; |
|
1402 |
|
1403 aDelete = EFalse; |
|
1404 |
|
1405 switch( aAttribute ) |
|
1406 { |
|
1407 case EDlAttrReqUrl: |
|
1408 { |
|
1409 attr8 = iUrl; |
|
1410 } |
|
1411 break; |
|
1412 |
|
1413 case EDlAttrRedirUlr: |
|
1414 { |
|
1415 attr8 = iRedirUrl; |
|
1416 } |
|
1417 break; |
|
1418 |
|
1419 case EDlAttrCurrentUrl: |
|
1420 { |
|
1421 attr8 = iCurrentUrl; |
|
1422 } |
|
1423 break; |
|
1424 |
|
1425 case EDlAttrContentType: |
|
1426 { |
|
1427 attr8 = iContentType; |
|
1428 } |
|
1429 break; |
|
1430 |
|
1431 case EDlAttrDDType: |
|
1432 { |
|
1433 attr8 = iDDType; |
|
1434 } |
|
1435 break; |
|
1436 |
|
1437 case EDlAttrRealm: |
|
1438 { |
|
1439 attr8 = iHttpRealm; |
|
1440 } |
|
1441 break; |
|
1442 |
|
1443 case EDlAttrUsername: |
|
1444 { |
|
1445 attr8 = iHttpUsername; |
|
1446 } |
|
1447 break; |
|
1448 |
|
1449 case EDlAttrProxyUsername: |
|
1450 { |
|
1451 attr8 = iHttpProxyUsername; |
|
1452 } |
|
1453 break; |
|
1454 |
|
1455 case EDlAttrRequestHeaderAddon: |
|
1456 { |
|
1457 TChar colon( KColon ); |
|
1458 TInt32 length( 0 ); |
|
1459 |
|
1460 GetIntAttributeL( EDlAttrRequestHeaderAddonLength, length ); |
|
1461 if( length ) |
|
1462 { |
|
1463 attr8 = HBufC8::NewLC( length ); |
|
1464 |
|
1465 aDelete = ETrue; |
|
1466 |
|
1467 for( TInt i = 0; i < iRequestHeaders->Count(); ++i ) |
|
1468 { |
|
1469 TPtrC8 fieldName( *(*iRequestHeaders)[i]->FieldName() ); |
|
1470 TPtrC8 fieldData( *(*iRequestHeaders)[i]->FieldRawData() ); |
|
1471 |
|
1472 attr8->Des().Append( fieldName ); |
|
1473 attr8->Des().Append( colon ); |
|
1474 attr8->Des().Append( fieldData ); |
|
1475 attr8->Des().Append( KHttpFieldSeparator() ); |
|
1476 } |
|
1477 |
|
1478 CleanupStack::Pop(); |
|
1479 } |
|
1480 } |
|
1481 break; |
|
1482 |
|
1483 case EDlAttrDestFilename: |
|
1484 { |
|
1485 attr = iStorage->DestFilename(); |
|
1486 } |
|
1487 break; |
|
1488 |
|
1489 case EDlAttrLocalFileName: |
|
1490 { |
|
1491 attr = iStorage->LocalFilename(); |
|
1492 } |
|
1493 break; |
|
1494 |
|
1495 case EDlAttrDdFileName: |
|
1496 { |
|
1497 attr = iStorage->DdFileName(); |
|
1498 } |
|
1499 break; |
|
1500 |
|
1501 case EDlAttrName: |
|
1502 { |
|
1503 attr = iDlName; |
|
1504 } |
|
1505 break; |
|
1506 |
|
1507 // Response headers |
|
1508 // case EDlAttrCharSet: |
|
1509 case EDlAttrResponseCharSet: |
|
1510 case EDlAttrResponseAge: |
|
1511 case EDlAttrResponseETag: |
|
1512 case EDlAttrResponseLocation: |
|
1513 case EDlAttrResponseRetryAfter: |
|
1514 case EDlAttrResponseServer: |
|
1515 case EDlAttrResponseVary: |
|
1516 { |
|
1517 for( TInt i = 0; KResponseHeaderConvTable[i][0]; ++i ) |
|
1518 { |
|
1519 if( KResponseHeaderConvTable[i][0] == aAttribute ) |
|
1520 { |
|
1521 attr8 = HeaderFieldL( iResponseHeaders, KResponseHeaderConvTable[i][1] ); |
|
1522 break; |
|
1523 } |
|
1524 } |
|
1525 } |
|
1526 break; |
|
1527 |
|
1528 // Request headers |
|
1529 case EDlAttrRequestAccept: |
|
1530 case EDlAttrRequestAcceptCharSet: |
|
1531 case EDlAttrRequestAcceptLanguage: |
|
1532 case EDlAttrRequestExpect: |
|
1533 case EDlAttrRequestFrom: |
|
1534 case EDlAttrRequestHost: |
|
1535 case EDlAttrRequestMaxForwards: |
|
1536 case EDlAttrRequestPragma: |
|
1537 case EDlAttrRequestReferer: |
|
1538 case EDlAttrRequestUserAgent: |
|
1539 case EDlAttrRequestVary: |
|
1540 { |
|
1541 for( TInt i = 0; KRequestHeaderConvTable[i][0]; ++i ) |
|
1542 { |
|
1543 if( KRequestHeaderConvTable[i][0] == aAttribute ) |
|
1544 { |
|
1545 attr8 = HeaderFieldL( iRequestHeaders, KRequestHeaderConvTable[i][1] ); |
|
1546 break; |
|
1547 } |
|
1548 } |
|
1549 } |
|
1550 break; |
|
1551 |
|
1552 // Entity header fields |
|
1553 case EDlAttrEntityAllow: |
|
1554 case EDlAttrEntityContentEncoding: |
|
1555 case EDlAttrEntityContentLanguage: |
|
1556 case EDlAttrEntityContentLocation: |
|
1557 case EDlAttrEntityExpires: |
|
1558 case EDlAttrEntityLastModified: |
|
1559 { |
|
1560 for( TInt i = 0; KEntityHeaderConvTable[i][0]; ++i ) |
|
1561 { |
|
1562 if( KEntityHeaderConvTable[i][0] == aAttribute ) |
|
1563 { |
|
1564 attr8 = HeaderFieldL( iEntityHeaders, KEntityHeaderConvTable[i][1] ); |
|
1565 break; |
|
1566 } |
|
1567 } |
|
1568 for( TInt i = 0; KResponseHeaderConvTable[i][0]; ++i ) |
|
1569 { |
|
1570 if( KResponseHeaderConvTable[i][0] == aAttribute ) |
|
1571 { |
|
1572 attr8 = HeaderFieldL( iResponseHeaders, KResponseHeaderConvTable[i][1] ); |
|
1573 break; |
|
1574 } |
|
1575 } |
|
1576 } |
|
1577 break; |
|
1578 |
|
1579 // General header fields |
|
1580 case EDlAttrGeneralCacheControl: |
|
1581 case EDlAttrGeneralDate: |
|
1582 case EDlAttrGeneralPragma: |
|
1583 case EDlAttrGeneralVia: |
|
1584 case EDlAttrGeneralWarning: |
|
1585 { |
|
1586 for( TInt i = 0; KGeneralHeaderConvTable[i][0]; ++i ) |
|
1587 { |
|
1588 if( KGeneralHeaderConvTable[i][0] == aAttribute ) |
|
1589 { |
|
1590 attr8 = HeaderFieldL( iGeneralHeaders, KGeneralHeaderConvTable[i][1] ); |
|
1591 break; |
|
1592 } |
|
1593 } |
|
1594 for( TInt i = 0; KResponseHeaderConvTable[i][0]; ++i ) |
|
1595 { |
|
1596 if( KResponseHeaderConvTable[i][0] == aAttribute ) |
|
1597 { |
|
1598 attr8 = HeaderFieldL( iResponseHeaders, KResponseHeaderConvTable[i][1] ); |
|
1599 break; |
|
1600 } |
|
1601 } |
|
1602 } |
|
1603 break; |
|
1604 |
|
1605 case EDlAttrAlbumName: |
|
1606 { |
|
1607 if (iCodDlData && (iCodDlData->Name().Compare(KNullDesC))) |
|
1608 { |
|
1609 attr = iCodDlData->Name().AllocL(); |
|
1610 aDelete = ETrue; |
|
1611 } |
|
1612 else |
|
1613 { |
|
1614 attr = iDlName; |
|
1615 } |
|
1616 } |
|
1617 break; |
|
1618 |
|
1619 default: |
|
1620 { |
|
1621 { |
|
1622 CLOG_WRITE_1( "Unknown string8 attrib: %d", aAttribute ); |
|
1623 #ifdef __WINS__ |
|
1624 DMPanic( KErrArgument ); |
|
1625 #else |
|
1626 User::Leave( KErrArgument ); |
|
1627 #endif |
|
1628 } |
|
1629 } |
|
1630 break; |
|
1631 } |
|
1632 |
|
1633 if( !attr && !attr8 ) |
|
1634 { |
|
1635 CLOG_WRITE_1( "NULL attrib: %d", aAttribute ); |
|
1636 User::Leave( KErrNotFound ); |
|
1637 } |
|
1638 |
|
1639 if( attr8 ) |
|
1640 // it is an 8-bit attribute |
|
1641 // need to be converted to 16-bits |
|
1642 { |
|
1643 if( aDelete ) |
|
1644 { |
|
1645 CleanupStack::PushL( attr8 ); |
|
1646 } |
|
1647 |
|
1648 ReallocateStringL( attr, *attr8 ); |
|
1649 if( aDelete ) |
|
1650 { |
|
1651 CleanupStack::PopAndDestroy( attr8 ); |
|
1652 } |
|
1653 |
|
1654 // it is always true because of the conversion. |
|
1655 aDelete = ETrue; |
|
1656 } |
|
1657 |
|
1658 iNoRealError = EFalse; |
|
1659 |
|
1660 return attr; |
|
1661 } |
|
1662 |
|
1663 // ----------------------------------------------------------------------------- |
|
1664 // CHttpDownload::GetStringAttributeL |
|
1665 // ?implementation_description |
|
1666 // (other items were commented in a header). |
|
1667 // ----------------------------------------------------------------------------- |
|
1668 // |
|
1669 EXPORT_C HBufC* CHttpDownload::GetStringAttributeL( THttpDownloadAttrib aAttribute, |
|
1670 TInt32& aMoIndex, |
|
1671 TBool& aDelete ) |
|
1672 { |
|
1673 LOGGER_ENTERFN( "GetStringAttributeL" ); |
|
1674 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
|
1675 |
|
1676 if (!iCodDlData) |
|
1677 { |
|
1678 return (KNullDesC().AllocL()); |
|
1679 } |
|
1680 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
|
1681 { |
|
1682 User::Leave( KErrArgument ); |
|
1683 } |
|
1684 |
|
1685 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
|
1686 iNoRealError = ETrue; |
|
1687 HBufC* attr = NULL; |
|
1688 HBufC8* attr8 = NULL; |
|
1689 |
|
1690 aDelete = EFalse; |
|
1691 |
|
1692 switch( aAttribute ) |
|
1693 { |
|
1694 case EDlAttrReqUrl: |
|
1695 { |
|
1696 attr8 = mediaData->Url().AllocL(); |
|
1697 aDelete = ETrue; |
|
1698 } |
|
1699 break; |
|
1700 |
|
1701 case EDlAttrRedirUlr: |
|
1702 { |
|
1703 attr8 = mediaData->RedirUrl().AllocL(); |
|
1704 aDelete = ETrue; |
|
1705 } |
|
1706 break; |
|
1707 |
|
1708 case EDlAttrContentType: |
|
1709 { |
|
1710 attr8 = mediaData->Type().AllocL(); |
|
1711 aDelete = ETrue; |
|
1712 } |
|
1713 break; |
|
1714 |
|
1715 case EDlAttrDestFilename: |
|
1716 { |
|
1717 attr = mediaData->DestFilename().AllocL(); |
|
1718 aDelete = ETrue; |
|
1719 } |
|
1720 break; |
|
1721 |
|
1722 case EDlAttrName: |
|
1723 { |
|
1724 if (aMoIndex == iActiveDownload) |
|
1725 { |
|
1726 attr = iDlName; |
|
1727 } |
|
1728 else |
|
1729 { |
|
1730 attr = mediaData->Name().AllocL(); |
|
1731 aDelete = ETrue; |
|
1732 } |
|
1733 } |
|
1734 break; |
|
1735 |
|
1736 default: |
|
1737 { |
|
1738 { |
|
1739 CLOG_WRITE_1( "Unknown string8 attrib: %d", aAttribute ); |
|
1740 #ifdef __WINS__ |
|
1741 DMPanic( KErrArgument ); |
|
1742 #else |
|
1743 User::Leave( KErrArgument ); |
|
1744 #endif |
|
1745 } |
|
1746 } |
|
1747 break; |
|
1748 } |
|
1749 |
|
1750 if( !attr && !attr8 ) |
|
1751 { |
|
1752 CLOG_WRITE_1( "NULL attrib: %d", aAttribute ); |
|
1753 User::Leave( KErrNotFound ); |
|
1754 } |
|
1755 |
|
1756 if( attr8 ) |
|
1757 // it is an 8-bit attribute |
|
1758 // need to be converted to 16-bits |
|
1759 { |
|
1760 if( aDelete ) |
|
1761 { |
|
1762 CleanupStack::PushL( attr8 ); |
|
1763 } |
|
1764 |
|
1765 ReallocateStringL( attr, *attr8 ); |
|
1766 if( aDelete ) |
|
1767 { |
|
1768 CleanupStack::PopAndDestroy( attr8 ); |
|
1769 } |
|
1770 |
|
1771 // it is always true because of the conversion. |
|
1772 aDelete = ETrue; |
|
1773 } |
|
1774 |
|
1775 iNoRealError = EFalse; |
|
1776 |
|
1777 return attr; |
|
1778 } |
|
1779 |
|
1780 // ----------------------------------------------------------------------------- |
|
1781 // CHttpDownload::GetString8AttributeL |
|
1782 // ?implementation_description |
|
1783 // (other items were commented in a header). |
|
1784 // ----------------------------------------------------------------------------- |
|
1785 // |
|
1786 EXPORT_C HBufC8* CHttpDownload::GetString8AttributeL( THttpDownloadAttrib aAttribute, |
|
1787 TBool& aDelete ) |
|
1788 { |
|
1789 LOGGER_ENTERFN( "GetString8AttributeL" ); |
|
1790 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
|
1791 |
|
1792 iNoRealError = ETrue; |
|
1793 HBufC8* attr = NULL; |
|
1794 HBufC* attr16 = NULL; |
|
1795 |
|
1796 aDelete = EFalse; |
|
1797 |
|
1798 switch( aAttribute ) |
|
1799 { |
|
1800 case EDlAttrReqUrl: |
|
1801 { |
|
1802 attr = iUrl; |
|
1803 } |
|
1804 break; |
|
1805 |
|
1806 case EDlAttrRedirUlr: |
|
1807 { |
|
1808 attr = iRedirUrl; |
|
1809 } |
|
1810 break; |
|
1811 |
|
1812 case EDlAttrCurrentUrl: |
|
1813 { |
|
1814 attr = iCurrentUrl; |
|
1815 } |
|
1816 break; |
|
1817 |
|
1818 case EDlAttrRealm: |
|
1819 { |
|
1820 attr = iHttpRealm; |
|
1821 } |
|
1822 break; |
|
1823 |
|
1824 case EDlAttrUsername: |
|
1825 { |
|
1826 attr = iHttpUsername; |
|
1827 } |
|
1828 break; |
|
1829 |
|
1830 case EDlAttrProxyUsername: |
|
1831 { |
|
1832 attr = iHttpProxyUsername; |
|
1833 } |
|
1834 break; |
|
1835 |
|
1836 case EDlAttrContentType: |
|
1837 { |
|
1838 attr = iContentType; |
|
1839 } |
|
1840 break; |
|
1841 |
|
1842 case EDlAttrDDType: |
|
1843 { |
|
1844 attr = iDDType; |
|
1845 } |
|
1846 break; |
|
1847 |
|
1848 case EDlAttrRequestHeaderAddon: |
|
1849 { |
|
1850 TChar colon( KColon ); |
|
1851 TInt32 length( 0 ); |
|
1852 |
|
1853 GetIntAttributeL( EDlAttrRequestHeaderAddonLength, length ); |
|
1854 if( length ) |
|
1855 { |
|
1856 attr = HBufC8::NewLC( length ); |
|
1857 |
|
1858 for( TInt i = 0; i < iRequestHeaders->Count(); ++i ) |
|
1859 { |
|
1860 TPtrC8 fieldName( *(*iRequestHeaders)[i]->FieldName() ); |
|
1861 TPtrC8 fieldData( *(*iRequestHeaders)[i]->FieldRawData() ); |
|
1862 |
|
1863 attr->Des().Append( fieldName ); |
|
1864 attr->Des().Append( colon ); |
|
1865 attr->Des().Append( fieldData ); |
|
1866 attr->Des().Append( KHttpFieldSeparator() ); |
|
1867 } |
|
1868 |
|
1869 CleanupStack::Pop(); |
|
1870 aDelete = ETrue; |
|
1871 } |
|
1872 } |
|
1873 break; |
|
1874 |
|
1875 case EDlAttrResponseCharSet: |
|
1876 // Response headers |
|
1877 case EDlAttrResponseAge: |
|
1878 case EDlAttrResponseETag: |
|
1879 case EDlAttrResponseLocation: |
|
1880 case EDlAttrResponseRetryAfter: |
|
1881 case EDlAttrResponseServer: |
|
1882 case EDlAttrResponseVary: |
|
1883 { |
|
1884 for( TInt i = 0; KResponseHeaderConvTable[i][0]; ++i ) |
|
1885 { |
|
1886 if( KResponseHeaderConvTable[i][0] == aAttribute ) |
|
1887 { |
|
1888 attr = HeaderFieldL( iResponseHeaders, KResponseHeaderConvTable[i][1] ); |
|
1889 } |
|
1890 } |
|
1891 } |
|
1892 break; |
|
1893 |
|
1894 // Request headers |
|
1895 case EDlAttrRequestAccept: |
|
1896 case EDlAttrRequestAcceptCharSet: |
|
1897 case EDlAttrRequestAcceptLanguage: |
|
1898 case EDlAttrRequestExpect: |
|
1899 case EDlAttrRequestFrom: |
|
1900 case EDlAttrRequestHost: |
|
1901 case EDlAttrRequestMaxForwards: |
|
1902 case EDlAttrRequestPragma: |
|
1903 case EDlAttrRequestReferer: |
|
1904 case EDlAttrRequestUserAgent: |
|
1905 case EDlAttrRequestVary: |
|
1906 { |
|
1907 for( TInt i = 0; KRequestHeaderConvTable[i][0]; ++i ) |
|
1908 { |
|
1909 if( KRequestHeaderConvTable[i][0] == aAttribute ) |
|
1910 { |
|
1911 attr = HeaderFieldL( iRequestHeaders, KRequestHeaderConvTable[i][1] ); |
|
1912 break; |
|
1913 } |
|
1914 } |
|
1915 } |
|
1916 break; |
|
1917 |
|
1918 // Entity header fields |
|
1919 case EDlAttrEntityAllow: |
|
1920 case EDlAttrEntityContentEncoding: |
|
1921 case EDlAttrEntityContentLanguage: |
|
1922 case EDlAttrEntityContentLocation: |
|
1923 case EDlAttrEntityExpires: |
|
1924 case EDlAttrEntityLastModified: |
|
1925 { |
|
1926 for( TInt i = 0; KEntityHeaderConvTable[i][0]; ++i ) |
|
1927 { |
|
1928 if( KEntityHeaderConvTable[i][0] == aAttribute ) |
|
1929 { |
|
1930 attr = HeaderFieldL( iEntityHeaders, KEntityHeaderConvTable[i][1] ); |
|
1931 break; |
|
1932 } |
|
1933 } |
|
1934 for( TInt i = 0; KResponseHeaderConvTable[i][0]; ++i ) |
|
1935 { |
|
1936 if( KResponseHeaderConvTable[i][0] == aAttribute ) |
|
1937 { |
|
1938 attr = HeaderFieldL( iResponseHeaders, KResponseHeaderConvTable[i][1] ); |
|
1939 } |
|
1940 } |
|
1941 } |
|
1942 break; |
|
1943 |
|
1944 // General header fields |
|
1945 case EDlAttrGeneralCacheControl: |
|
1946 case EDlAttrGeneralDate: |
|
1947 case EDlAttrGeneralPragma: |
|
1948 case EDlAttrGeneralVia: |
|
1949 case EDlAttrGeneralWarning: |
|
1950 { |
|
1951 for( TInt i = 0; KGeneralHeaderConvTable[i][0]; ++i ) |
|
1952 { |
|
1953 if( KGeneralHeaderConvTable[i][0] == aAttribute ) |
|
1954 { |
|
1955 attr = HeaderFieldL( iGeneralHeaders, KGeneralHeaderConvTable[i][1] ); |
|
1956 break; |
|
1957 } |
|
1958 } |
|
1959 for( TInt i = 0; KResponseHeaderConvTable[i][0]; ++i ) |
|
1960 { |
|
1961 if( KResponseHeaderConvTable[i][0] == aAttribute ) |
|
1962 { |
|
1963 attr = HeaderFieldL( iResponseHeaders, KResponseHeaderConvTable[i][1] ); |
|
1964 } |
|
1965 } |
|
1966 } |
|
1967 break; |
|
1968 |
|
1969 case EDlAttrHashedMsgBody: |
|
1970 { |
|
1971 attr = iHashedMsgBody; |
|
1972 } |
|
1973 break; |
|
1974 |
|
1975 case EDlAttrMediaType: |
|
1976 { |
|
1977 attr = iMediaType; |
|
1978 } |
|
1979 break; |
|
1980 |
|
1981 case EDlAttrMediaTypeBoundary: |
|
1982 { |
|
1983 attr = GetParamFromMediaTypeL( KBoundary() ).AllocL(); |
|
1984 aDelete = ETrue; |
|
1985 } |
|
1986 break; |
|
1987 |
|
1988 default: |
|
1989 { |
|
1990 { |
|
1991 CLOG_WRITE_1( "Unknown string8 attrib: %d", aAttribute ); |
|
1992 #ifdef __WINS__ |
|
1993 DMPanic( KErrArgument ); |
|
1994 #else |
|
1995 User::Leave( KErrArgument ); |
|
1996 #endif |
|
1997 } |
|
1998 } |
|
1999 break; |
|
2000 } |
|
2001 |
|
2002 if( !attr && !attr16 ) |
|
2003 { |
|
2004 CLOG_WRITE_1( "NULL attrib: %d", aAttribute ); |
|
2005 User::Leave( KErrNotFound ); |
|
2006 } |
|
2007 |
|
2008 if( attr16 ) |
|
2009 // it is an 8-bit attribute |
|
2010 // need to be converted to 16-bits |
|
2011 { |
|
2012 if( aDelete ) |
|
2013 { |
|
2014 CleanupStack::PushL( attr16 ); |
|
2015 } |
|
2016 ReallocateStringL( attr, *attr16 ); |
|
2017 if( aDelete ) |
|
2018 { |
|
2019 CleanupStack::PopAndDestroy( attr16 ); |
|
2020 } |
|
2021 |
|
2022 // it is always true because of the conversion. |
|
2023 aDelete = ETrue; |
|
2024 } |
|
2025 |
|
2026 iNoRealError = EFalse; |
|
2027 |
|
2028 return attr; |
|
2029 } |
|
2030 |
|
2031 // ----------------------------------------------------------------------------- |
|
2032 // CHttpDownload::GetString8AttributeL |
|
2033 // ?implementation_description |
|
2034 // (other items were commented in a header). |
|
2035 // ----------------------------------------------------------------------------- |
|
2036 // |
|
2037 EXPORT_C HBufC8* CHttpDownload::GetString8AttributeL( THttpDownloadAttrib aAttribute, |
|
2038 TInt32& aMoIndex, |
|
2039 TBool& aDelete ) |
|
2040 { |
|
2041 LOGGER_ENTERFN( "GetString8AttributeL" ); |
|
2042 CLOG_WRITE_1( "Attr(%d): %d", aAttribute ); |
|
2043 |
|
2044 if (!iCodDlData) |
|
2045 { |
|
2046 return (KNullDesC8().AllocL()); |
|
2047 } |
|
2048 if ((aMoIndex <= KNonMoIndex) || (aMoIndex > iCodDlData->Count())) |
|
2049 { |
|
2050 User::Leave( KErrArgument ); |
|
2051 } |
|
2052 |
|
2053 CMediaDataBase* mediaData = (*iCodDlData)[aMoIndex]; |
|
2054 iNoRealError = ETrue; |
|
2055 HBufC8* attr = NULL; |
|
2056 HBufC* attr16 = NULL; |
|
2057 |
|
2058 aDelete = EFalse; |
|
2059 |
|
2060 switch( aAttribute ) |
|
2061 { |
|
2062 case EDlAttrReqUrl: |
|
2063 { |
|
2064 attr = mediaData->Url().AllocL(); |
|
2065 aDelete = ETrue; |
|
2066 } |
|
2067 break; |
|
2068 |
|
2069 case EDlAttrRedirUlr: |
|
2070 { |
|
2071 attr = mediaData->RedirUrl().AllocL(); |
|
2072 aDelete = ETrue; |
|
2073 } |
|
2074 break; |
|
2075 |
|
2076 case EDlAttrContentType: |
|
2077 { |
|
2078 attr = mediaData->Type().AllocL(); |
|
2079 aDelete = ETrue; |
|
2080 } |
|
2081 break; |
|
2082 |
|
2083 default: |
|
2084 { |
|
2085 { |
|
2086 CLOG_WRITE_1( "Unknown string8 attrib: %d", aAttribute ); |
|
2087 #ifdef __WINS__ |
|
2088 DMPanic( KErrArgument ); |
|
2089 #else |
|
2090 User::Leave( KErrArgument ); |
|
2091 #endif |
|
2092 } |
|
2093 } |
|
2094 break; |
|
2095 } |
|
2096 |
|
2097 if( !attr && !attr16 ) |
|
2098 { |
|
2099 CLOG_WRITE_1( "NULL attrib: %d", aAttribute ); |
|
2100 User::Leave( KErrNotFound ); |
|
2101 } |
|
2102 |
|
2103 if( attr16 ) |
|
2104 // it is an 8-bit attribute |
|
2105 // need to be converted to 16-bits |
|
2106 { |
|
2107 if( aDelete ) |
|
2108 { |
|
2109 CleanupStack::PushL( attr16 ); |
|
2110 } |
|
2111 ReallocateStringL( attr, *attr16 ); |
|
2112 if( aDelete ) |
|
2113 { |
|
2114 CleanupStack::PopAndDestroy( attr16 ); |
|
2115 } |
|
2116 |
|
2117 // it is always true because of the conversion. |
|
2118 aDelete = ETrue; |
|
2119 } |
|
2120 |
|
2121 iNoRealError = EFalse; |
|
2122 |
|
2123 return attr; |
|
2124 } |
|
2125 |
|
2126 // ----------------------------------------------------------------------------- |
|
2127 // CHttpDownload::GetFileHandleAttributeL |
|
2128 // ?implementation_description |
|
2129 // (other items were commented in a header). |
|
2130 // ----------------------------------------------------------------------------- |
|
2131 // |
|
2132 EXPORT_C RFile* CHttpDownload::GetFileHandleAttributeL() |
|
2133 { |
|
2134 LOGGER_ENTERFN( "GetFileHandleAttributeL" ); |
|
2135 |
|
2136 if( !iStorage->File() ) |
|
2137 // destination file is not opened |
|
2138 { |
|
2139 User::Leave( KErrArgument ); |
|
2140 } |
|
2141 |
|
2142 return iStorage->File(); |
|
2143 } |
|
2144 |
|
2145 // ----------------------------------------------------------------------------- |
|
2146 // CHttpDownload::SetIntAttributeL |
|
2147 // ?implementation_description |
|
2148 // (other items were commented in a header). |
|
2149 // ----------------------------------------------------------------------------- |
|
2150 // |
|
2151 EXPORT_C void CHttpDownload::SetIntAttributeL( THttpDownloadAttrib aAttribute, |
|
2152 const TInt32 aValue ) |
|
2153 { |
|
2154 LOGGER_ENTERFN( "SetIntAttributeL" ); |
|
2155 CLOG_WRITE_2( "Attr(%d): %d", aAttribute, aValue ); |
|
2156 TBool store( ETrue ); |
|
2157 |
|
2158 iNoRealError = ETrue; |
|
2159 |
|
2160 switch( aAttribute ) |
|
2161 { |
|
2162 case EDlAttrUserData: |
|
2163 { |
|
2164 iUserData = aValue; |
|
2165 } |
|
2166 break; |
|
2167 |
|
2168 case EDlAttrAction: |
|
2169 { |
|
2170 TBool PdSupported(EFalse); |
|
2171 |
|
2172 iAction = (THttpDownloadMgrAction)aValue; |
|
2173 |
|
2174 if(iClAppInstance) |
|
2175 { |
|
2176 TRAP_IGNORE(iClAppInstance->GetBoolAttributeL(EDlMgrProgressiveDownload, PdSupported)); |
|
2177 } |
|
2178 |
|
2179 if(!PdSupported) |
|
2180 { |
|
2181 iAction = (THttpDownloadMgrAction)(iAction & ~(EPdLaunch)); |
|
2182 } |
|
2183 } |
|
2184 break; |
|
2185 |
|
2186 case EDlAttrPort: |
|
2187 iPort = aValue; |
|
2188 break; |
|
2189 |
|
2190 case EDlAttrRestartAction: |
|
2191 iRestartAction = (THttpRestartActions)aValue; |
|
2192 break; |
|
2193 |
|
2194 case EDlAttrAuthScheme: |
|
2195 { |
|
2196 if( iContinueDownload && iDlState == EHttpDlMultipleMOStarted ) |
|
2197 { |
|
2198 iAuthScheme = aValue; |
|
2199 } |
|
2200 } |
|
2201 break; |
|
2202 |
|
2203 case EDlAttrLength: |
|
2204 { |
|
2205 if( (iContinueDownload && iDlState == EHttpDlMultipleMOStarted) || |
|
2206 ( iCodDownload && iDlState == EHttpDlInprogress ) ) |
|
2207 { |
|
2208 iStorage->SetLength( aValue ); |
|
2209 } |
|
2210 else |
|
2211 { |
|
2212 store = EFalse; |
|
2213 } |
|
2214 } |
|
2215 break; |
|
2216 |
|
2217 case EDlAttrMultipleMOLength: |
|
2218 { |
|
2219 iMoLength = aValue; |
|
2220 } |
|
2221 break; |
|
2222 |
|
2223 case EDlAttrDownloadedSize: |
|
2224 { |
|
2225 if( (iCodDownload || iContinueDownload) && iDlState == EHttpDlInprogress ) |
|
2226 { |
|
2227 iStorage->SetDownloadedSize( aValue ); |
|
2228 // Calculate downloaded size of current media object from |
|
2229 // album downloaded size. |
|
2230 TInt dlSize = iStorage->DownloadedSize(); |
|
2231 if( iCodDlData ) |
|
2232 { |
|
2233 for (TInt index = 0; index < iCodDlData->Count() ; ++index) |
|
2234 { |
|
2235 if( iActiveDownload - 1 == index ) |
|
2236 { |
|
2237 //the size of active download has already been taken into account |
|
2238 continue; |
|
2239 } |
|
2240 CMediaDataBase* moData = (*iCodDlData)[index+1]; |
|
2241 if ((moData->State() == ESucceeded) || (moData->State() == EInProgress)) |
|
2242 dlSize += moData->DownloadedSize(); |
|
2243 } |
|
2244 iStorage->SetMoDownloadedSize(dlSize); |
|
2245 } |
|
2246 if( iStorage->Length() != KDefaultContentLength && |
|
2247 iStorage->DownloadedSize() > iStorage->Length() ) |
|
2248 // we don't know actually how many bytes will come down. |
|
2249 { |
|
2250 CLOG_WRITE( "Length modified" ); |
|
2251 iStorage->SetLength( KDefaultContentLength ); |
|
2252 StoreDownloadInfoL(); |
|
2253 } |
|
2254 TriggerEvent( EHttpDlInprogress, EHttpProgResponseBodyReceived ); |
|
2255 } |
|
2256 |
|
2257 store = EFalse; |
|
2258 } |
|
2259 break; |
|
2260 |
|
2261 case EDlAttrSucceeded: |
|
2262 { |
|
2263 if(!aValue) |
|
2264 DownloadSucceededL(); |
|
2265 else |
|
2266 iMoDownloadCompleted = ETrue;//Download of MO has been Completed so change State ,But PD is on |
|
2267 //So MOVE will be issued by PD Client |
|
2268 |
|
2269 store = EFalse; |
|
2270 } |
|
2271 break; |
|
2272 |
|
2273 case EDlAttrFailed: |
|
2274 { |
|
2275 // This is an exeption! |
|
2276 iNoRealError = EFalse; |
|
2277 OnError( aValue, ETransactionFailed ); |
|
2278 store = EFalse; |
|
2279 } |
|
2280 break; |
|
2281 |
|
2282 case EDlAttrDefaultEvent: |
|
2283 { |
|
2284 } |
|
2285 break; |
|
2286 |
|
2287 case EDlAttrMethod: |
|
2288 { |
|
2289 if( iContinueDownload && iDlState == EHttpDlMultipleMOStarted && |
|
2290 ( aValue == EMethodGET || |
|
2291 aValue == EMethodPOST || |
|
2292 aValue == EMethodHEAD ) ) |
|
2293 { |
|
2294 iMethod = (THttpMethod)aValue; |
|
2295 } |
|
2296 else |
|
2297 { |
|
2298 User::Leave( KErrArgument ); |
|
2299 } |
|
2300 } |
|
2301 break; |
|
2302 |
|
2303 case EDlAttrFotaPckgId: |
|
2304 { |
|
2305 iFotaPckgId = aValue; |
|
2306 store = EFalse; |
|
2307 } |
|
2308 break; |
|
2309 case EDlAttrActiveDownload: |
|
2310 { |
|
2311 iActiveDownload = aValue; |
|
2312 |
|
2313 // Active MO changed. Notify clients. |
|
2314 TriggerEvent( EHttpDlCreated, EHttpProgNone ); |
|
2315 } |
|
2316 break; |
|
2317 |
|
2318 case EDlAttrActivePlayedDownload: |
|
2319 { |
|
2320 iActivePlayedDownload = aValue; |
|
2321 } |
|
2322 |
|
2323 break; |
|
2324 default: |
|
2325 { |
|
2326 #ifdef __WINS__ |
|
2327 DMPanic( KErrArgument ); |
|
2328 #else |
|
2329 User::Leave( KErrArgument ); |
|
2330 #endif |
|
2331 } |
|
2332 break; |
|
2333 } |
|
2334 |
|
2335 UpdatePausable(); |
|
2336 |
|
2337 iNoRealError = EFalse; |
|
2338 |
|
2339 if( store ) |
|
2340 { |
|
2341 StoreDownloadInfoL(); |
|
2342 } |
|
2343 } |
|
2344 |
|
2345 // ----------------------------------------------------------------------------- |
|
2346 // CHttpDownload::SetBoolAttributeL |
|
2347 // ?implementation_description |
|
2348 // (other items were commented in a header). |
|
2349 // ----------------------------------------------------------------------------- |
|
2350 // |
|
2351 EXPORT_C void CHttpDownload::SetBoolAttributeL( THttpDownloadAttrib aAttribute, |
|
2352 const TBool aValue ) |
|
2353 { |
|
2354 LOGGER_ENTERFN( "SetBoolAttributeL" ); |
|
2355 CLOG_WRITE_2( "Attr(%d): %d", aAttribute, aValue ); |
|
2356 TBool store( ETrue ); |
|
2357 |
|
2358 iNoRealError = ETrue; |
|
2359 |
|
2360 switch( aAttribute ) |
|
2361 { |
|
2362 case EDlAttrNoContentTypeCheck: |
|
2363 { |
|
2364 iNoContentTypeCheck = aValue; |
|
2365 } |
|
2366 break; |
|
2367 |
|
2368 case EDlAttrDisconnectOnReset: |
|
2369 { |
|
2370 iDisconnectOnReset = aValue; |
|
2371 } |
|
2372 break; |
|
2373 |
|
2374 case EDlAttrDisconnectOnPause: |
|
2375 { |
|
2376 iDisconnectOnPause = aValue; |
|
2377 } |
|
2378 break; |
|
2379 |
|
2380 case EDlAttrContinue: |
|
2381 { |
|
2382 if( iDlState == EHttpDlMultipleMOStarted ) |
|
2383 { |
|
2384 iContinueDownload = aValue; |
|
2385 } |
|
2386 else |
|
2387 { |
|
2388 User::Leave( KErrInUse ); |
|
2389 } |
|
2390 |
|
2391 store = EFalse; |
|
2392 } |
|
2393 break; |
|
2394 |
|
2395 case EDlAttrHidden: |
|
2396 { |
|
2397 iHidden = aValue; |
|
2398 } |
|
2399 break; |
|
2400 |
|
2401 case EDlAttrSilent: |
|
2402 { |
|
2403 iSilentMode = aValue; |
|
2404 } |
|
2405 break; |
|
2406 |
|
2407 case EDlAttrCodDownload: |
|
2408 { |
|
2409 SetCodFlag( aValue ); |
|
2410 } |
|
2411 break; |
|
2412 |
|
2413 case EDlAttrProgressive: |
|
2414 { |
|
2415 TBool PdSupported(EFalse); |
|
2416 |
|
2417 if(iClAppInstance) |
|
2418 { |
|
2419 TRAP_IGNORE(iClAppInstance->GetBoolAttributeL(EDlMgrProgressiveDownload, PdSupported)); |
|
2420 } |
|
2421 |
|
2422 if(PdSupported) |
|
2423 { |
|
2424 iStorage->SetProgressiveMode( aValue ); |
|
2425 |
|
2426 if(!aValue) |
|
2427 { |
|
2428 iActivePlayedDownload = 0; |
|
2429 } |
|
2430 |
|
2431 if (iCodDlData) |
|
2432 { |
|
2433 // Update for Active media object. |
|
2434 TInt active = iActiveDownload; |
|
2435 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
|
2436 mediaData->SetProgressiveDownload( aValue ); |
|
2437 } |
|
2438 |
|
2439 if( iProgState != EHttpProgMovingContentFile ) |
|
2440 { |
|
2441 TriggerEvent( iDlState, aValue ? EHttpDlProgProgressive : EHttpDlProgNonProgressive); |
|
2442 } |
|
2443 } |
|
2444 else |
|
2445 { |
|
2446 TriggerEvent( iDlState, EHttpDlProgNonProgressive); |
|
2447 } |
|
2448 } |
|
2449 break; |
|
2450 |
|
2451 case EDlAttrCodDescriptorAccepted: |
|
2452 { |
|
2453 TriggerEvent( EHttpDlInprogress, EHttpProgCodDescriptorAccepted ); |
|
2454 } |
|
2455 break; |
|
2456 |
|
2457 case EDlAttrCodLoadEnd: |
|
2458 { |
|
2459 SetDownloadStatus(EHttpProgCodLoadEnd,EHttpDlInprogress); |
|
2460 } |
|
2461 break; |
|
2462 |
|
2463 case EDlAttrCodPdAvailable: |
|
2464 { |
|
2465 iCodPdAvailable = aValue; |
|
2466 TriggerEvent( EHttpDlInprogress, EHttpProgCodPdAvailable ); |
|
2467 } |
|
2468 break; |
|
2469 |
|
2470 case EDlAttrDestRemovable: |
|
2471 { |
|
2472 if( iCodDownload ) |
|
2473 { |
|
2474 iStorage->SetRemovableDest( aValue ); |
|
2475 |
|
2476 if (iCodDlData) |
|
2477 { |
|
2478 // Update for Active media object. |
|
2479 TInt active = iActiveDownload; |
|
2480 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
|
2481 mediaData->SetDesRemovable( aValue ); |
|
2482 } |
|
2483 } |
|
2484 } |
|
2485 break; |
|
2486 |
|
2487 case EDlAttrDownloadUpdatedDDUri: |
|
2488 { |
|
2489 iUpdatedDDUriSet = aValue; |
|
2490 } |
|
2491 break; |
|
2492 |
|
2493 |
|
2494 case EDlAttrCodPausable: |
|
2495 { |
|
2496 iPausable = aValue; |
|
2497 |
|
2498 // Update for Active media object. |
|
2499 TInt active = iActiveDownload; |
|
2500 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
|
2501 mediaData->SetPausable( aValue ); |
|
2502 |
|
2503 // inform client about change |
|
2504 TriggerEvent( iPausable ? EHttpDlPausable : EHttpDlNonPausable ); |
|
2505 } |
|
2506 break; |
|
2507 |
|
2508 |
|
2509 default: |
|
2510 #ifdef __WINS__ |
|
2511 DMPanic( KErrArgument ); |
|
2512 #else |
|
2513 User::Leave( KErrArgument ); |
|
2514 #endif |
|
2515 break; |
|
2516 } |
|
2517 |
|
2518 UpdatePausable(); |
|
2519 |
|
2520 iNoRealError = EFalse; |
|
2521 |
|
2522 if( store ) |
|
2523 { |
|
2524 StoreDownloadInfoL(); |
|
2525 } |
|
2526 } |
|
2527 |
|
2528 |
|
2529 |
|
2530 // ----------------------------------------------------------------------------- |
|
2531 // CHttpDownload::SetStringAttributeL |
|
2532 // ?implementation_description |
|
2533 // (other items were commented in a header). |
|
2534 // ----------------------------------------------------------------------------- |
|
2535 // |
|
2536 EXPORT_C void CHttpDownload::SetStringAttributeL( THttpDownloadAttrib aAttribute, const TInt32 aMOIndex, |
|
2537 const TDesC16& aValue ) |
|
2538 { |
|
2539 LOGGER_ENTERFN( "SetStringAttributeL" ); |
|
2540 CLOG_WRITE_2( "Attr(%d - %d)", aAttribute, aValue.Length () ); |
|
2541 |
|
2542 iNoRealError = ETrue; |
|
2543 |
|
2544 CheckAttribMaxLengthL( aAttribute, aValue ); |
|
2545 |
|
2546 switch( aAttribute ) |
|
2547 { |
|
2548 case EDlAttrDestFilename: |
|
2549 { |
|
2550 TBool updateFName = EFalse; |
|
2551 |
|
2552 if( iDlState == EHttpDlMultipleMOStarted || |
|
2553 iDlState == EHttpDlMultipleMOCompleted || |
|
2554 iCodDownload ) |
|
2555 // cannot set this attribute while |
|
2556 // download is in progress |
|
2557 { |
|
2558 if( !aValue.Length() ) |
|
2559 { |
|
2560 updateFName = ETrue; |
|
2561 } |
|
2562 else if( iClientApp->Engine()->Fs().IsValidName( aValue ) ) |
|
2563 { |
|
2564 TUint attrib; |
|
2565 TInt attErr = iClientApp->Engine()->Fs().Att( aValue, attrib ); |
|
2566 |
|
2567 if( (attErr == KErrNone && !(attrib & KEntryAttDir)) || |
|
2568 attErr == KErrNotFound ) |
|
2569 // File exists and not directory or not exists |
|
2570 { |
|
2571 updateFName = ETrue; |
|
2572 } |
|
2573 else |
|
2574 { |
|
2575 User::Leave( KErrArgument ); |
|
2576 } |
|
2577 } |
|
2578 else |
|
2579 // Invalid filename passed |
|
2580 { |
|
2581 User::Leave( KErrArgument ); |
|
2582 } |
|
2583 } |
|
2584 else |
|
2585 { |
|
2586 User::Leave( KErrInUse ); |
|
2587 } |
|
2588 |
|
2589 if (updateFName) |
|
2590 { |
|
2591 iStorage->UpdateDestinationFilenameL( aValue, ETrue ); |
|
2592 if (iCodDlData) |
|
2593 { |
|
2594 CMediaDataBase* mediaData = (*iCodDlData)[aMOIndex]; |
|
2595 mediaData->SetDestFilenameL( aValue ); |
|
2596 } |
|
2597 } |
|
2598 } |
|
2599 break; |
|
2600 } |
|
2601 } |
|
2602 |
|
2603 |
|
2604 // ----------------------------------------------------------------------------- |
|
2605 // CHttpDownload::SetStringAttributeL |
|
2606 // ?implementation_description |
|
2607 // (other items were commented in a header). |
|
2608 // ----------------------------------------------------------------------------- |
|
2609 // |
|
2610 EXPORT_C void CHttpDownload::SetStringAttributeL( THttpDownloadAttrib aAttribute, |
|
2611 const TDesC16& aValue ) |
|
2612 { |
|
2613 LOGGER_ENTERFN( "SetStringAttributeL" ); |
|
2614 CLOG_WRITE_2( "Attr(%d - %d)", aAttribute, aValue.Length () ); |
|
2615 TBool store( ETrue ); |
|
2616 |
|
2617 iNoRealError = ETrue; |
|
2618 |
|
2619 CheckAttribMaxLengthL( aAttribute, aValue ); |
|
2620 |
|
2621 switch( aAttribute ) |
|
2622 { |
|
2623 case EDlAttrReqUrl: |
|
2624 // this is only for internal testing usage!!! |
|
2625 { |
|
2626 if( iDlState == EHttpDlMultipleMOStarted ) |
|
2627 { |
|
2628 ReallocateStringL( iUrl, aValue, KMaxUrlLength ); |
|
2629 ParseRequestedUrlL(); // iCurrentUrl is initialized there |
|
2630 ParseDownloadNameL(); |
|
2631 } |
|
2632 } |
|
2633 break; |
|
2634 |
|
2635 case EDlAttrContentType: |
|
2636 { |
|
2637 if( iDlState == EHttpDlInprogress ) |
|
2638 { |
|
2639 CLOG_WRITE( "EDlAttrContentType updated" ); |
|
2640 ReallocateStringL( iContentType, aValue, KMaxContentTypeLength ); |
|
2641 TriggerEvent( EHttpDlInprogress, EHttpProgContentTypeChanged ); |
|
2642 |
|
2643 // Update for Active media object. |
|
2644 HBufC8* type8 = HBufC8::NewLC( aValue.Length() ); |
|
2645 type8->Des().Copy( aValue ); |
|
2646 |
|
2647 if (iCodDlData) |
|
2648 { |
|
2649 TInt active = iActiveDownload; |
|
2650 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
|
2651 mediaData->SetTypeL( type8->Des() ); |
|
2652 CleanupStack::PopAndDestroy( type8 ); |
|
2653 } |
|
2654 } |
|
2655 } |
|
2656 break; |
|
2657 |
|
2658 case EDlAttrRealm: |
|
2659 { |
|
2660 if( iContinueDownload && iDlState == EHttpDlMultipleMOStarted ) |
|
2661 { |
|
2662 ReallocateStringL( iHttpRealm, aValue, KMaxRealmLength ); |
|
2663 } |
|
2664 |
|
2665 store = EFalse; |
|
2666 } |
|
2667 break; |
|
2668 |
|
2669 case EDlAttrUsername: |
|
2670 { |
|
2671 ReallocateStringL( iHttpUsername, aValue, KMaxDefAttrLength ); |
|
2672 store = EFalse; |
|
2673 } |
|
2674 break; |
|
2675 |
|
2676 case EDlAttrPassword: |
|
2677 { |
|
2678 ReallocateStringL( iHttpPassword, aValue, KMaxDefAttrLength ); |
|
2679 store = EFalse; |
|
2680 } |
|
2681 break; |
|
2682 |
|
2683 case EDlAttrProxyRealm: |
|
2684 { |
|
2685 if( iContinueDownload && iDlState == EHttpDlMultipleMOStarted ) |
|
2686 { |
|
2687 ReallocateStringL( iHttpProxyRealm, aValue, KMaxRealmLength ); |
|
2688 } |
|
2689 store = EFalse; |
|
2690 } |
|
2691 break; |
|
2692 |
|
2693 case EDlAttrProxyUsername: |
|
2694 { |
|
2695 ReallocateStringL( iHttpProxyUsername, aValue, KMaxDefAttrLength ); |
|
2696 store = EFalse; |
|
2697 } |
|
2698 break; |
|
2699 |
|
2700 case EDlAttrProxyPassword: |
|
2701 { |
|
2702 ReallocateStringL( iHttpProxyPassword, aValue, KMaxDefAttrLength ); |
|
2703 store = EFalse; |
|
2704 } |
|
2705 break; |
|
2706 |
|
2707 case EDlAttrDestFilename: |
|
2708 { |
|
2709 TBool updateFName = EFalse; |
|
2710 |
|
2711 if( iDlState == EHttpDlMultipleMOStarted || |
|
2712 iDlState == EHttpDlMultipleMOCompleted || |
|
2713 iCodDownload ) |
|
2714 // cannot set this attribute while |
|
2715 // download is in progress |
|
2716 { |
|
2717 if( !aValue.Length() ) |
|
2718 { |
|
2719 updateFName = ETrue; |
|
2720 } |
|
2721 else if( iClientApp->Engine()->Fs().IsValidName( aValue ) ) |
|
2722 { |
|
2723 TUint attrib; |
|
2724 TInt attErr = iClientApp->Engine()->Fs().Att( aValue, attrib ); |
|
2725 |
|
2726 if( (attErr == KErrNone && !(attrib & KEntryAttDir)) || |
|
2727 attErr == KErrNotFound ) |
|
2728 // File exists and not directory or not exists |
|
2729 { |
|
2730 updateFName = ETrue; |
|
2731 } |
|
2732 else |
|
2733 { |
|
2734 User::Leave( KErrArgument ); |
|
2735 } |
|
2736 } |
|
2737 else |
|
2738 // Invalid filename passed |
|
2739 { |
|
2740 User::Leave( KErrArgument ); |
|
2741 } |
|
2742 } |
|
2743 else |
|
2744 { |
|
2745 User::Leave( KErrInUse ); |
|
2746 } |
|
2747 |
|
2748 if (updateFName) |
|
2749 { |
|
2750 iStorage->UpdateDestinationFilenameL( aValue, ETrue ); |
|
2751 |
|
2752 if (iCodDlData) |
|
2753 { |
|
2754 TInt moIndex(0); |
|
2755 if( iActiveDownload != iActivePlayedDownload && iStorage->ProgressiveDownload() ) |
|
2756 { |
|
2757 //MP has set the Destination File Name |
|
2758 moIndex = iActivePlayedDownload; |
|
2759 } |
|
2760 else |
|
2761 { |
|
2762 // Update for Active media object. |
|
2763 moIndex = iActiveDownload; |
|
2764 } |
|
2765 CMediaDataBase* mediaData = (*iCodDlData)[moIndex]; |
|
2766 mediaData->SetDestFilenameL( aValue ); |
|
2767 } |
|
2768 } |
|
2769 } |
|
2770 break; |
|
2771 |
|
2772 case EDlAttrLocalFileName: |
|
2773 { |
|
2774 iStorage->SetLocalFilenameL(aValue); |
|
2775 } |
|
2776 break; |
|
2777 |
|
2778 case EDlAttrRequestHeaderAddon: |
|
2779 { |
|
2780 if( aValue.Length() ) |
|
2781 { |
|
2782 HBufC8* value = HBufC8::NewLC( aValue.Length() ); |
|
2783 |
|
2784 value->Des().Copy( aValue ); |
|
2785 ParseRequestHeaderAddOnL( *value ); |
|
2786 |
|
2787 CleanupStack::PopAndDestroy( value ); |
|
2788 } |
|
2789 } |
|
2790 break; |
|
2791 |
|
2792 case EDlAttrResponseHeader: |
|
2793 { |
|
2794 if( iContinueDownload && iDlState == EHttpDlMultipleMOStarted ) |
|
2795 { |
|
2796 HBufC8* temp = HBufC8::NewLC( aValue.Length() ); |
|
2797 temp->Des().Copy( aValue ); |
|
2798 |
|
2799 ContinueDownloadStoreResponseHeaderL( *temp ); |
|
2800 |
|
2801 CleanupStack::PopAndDestroy( temp ); |
|
2802 } |
|
2803 } |
|
2804 break; |
|
2805 |
|
2806 case EDlAttrName: |
|
2807 { |
|
2808 if( iCodDownload ) |
|
2809 { |
|
2810 SetDownloadNameL( aValue ); |
|
2811 |
|
2812 if (iCodDlData) |
|
2813 { |
|
2814 // Update for Active media object. |
|
2815 TInt active = iActiveDownload; |
|
2816 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
|
2817 mediaData->SetNameL( aValue ); |
|
2818 } |
|
2819 } |
|
2820 } |
|
2821 break; |
|
2822 |
|
2823 // Request headers |
|
2824 case EDlAttrRequestAccept: |
|
2825 case EDlAttrRequestAcceptCharSet: |
|
2826 case EDlAttrRequestAcceptLanguage: |
|
2827 case EDlAttrRequestExpect: |
|
2828 case EDlAttrRequestFrom: |
|
2829 case EDlAttrRequestHost: |
|
2830 case EDlAttrRequestMaxForwards: |
|
2831 case EDlAttrRequestPragma: |
|
2832 case EDlAttrRequestReferer: |
|
2833 case EDlAttrRequestUserAgent: |
|
2834 case EDlAttrRequestVary: |
|
2835 { |
|
2836 HBufC8* value = HBufC8::NewLC( aValue.Length() ); |
|
2837 |
|
2838 AddHeaderL( aAttribute, *value, KRequestHeaderConvTable, iRequestHeaders ); |
|
2839 |
|
2840 CleanupStack::PopAndDestroy( value ); |
|
2841 } |
|
2842 break; |
|
2843 |
|
2844 // General header fields |
|
2845 case EDlAttrGeneralCacheControl: |
|
2846 case EDlAttrGeneralPragma: |
|
2847 { |
|
2848 HBufC8* value = HBufC8::NewLC( aValue.Length() ); |
|
2849 |
|
2850 AddHeaderL( aAttribute, *value, KGeneralHeaderConvTable, iGeneralHeaders ); |
|
2851 |
|
2852 CleanupStack::PopAndDestroy( value ); |
|
2853 } |
|
2854 break; |
|
2855 |
|
2856 default: |
|
2857 #ifdef __WINS__ |
|
2858 DMPanic( KErrArgument ); |
|
2859 #else |
|
2860 User::Leave( KErrArgument ); |
|
2861 #endif |
|
2862 break; |
|
2863 } |
|
2864 |
|
2865 UpdatePausable(); |
|
2866 |
|
2867 iNoRealError = EFalse; |
|
2868 |
|
2869 if( store ) |
|
2870 { |
|
2871 StoreDownloadInfoL(); |
|
2872 } |
|
2873 } |
|
2874 |
|
2875 // ----------------------------------------------------------------------------- |
|
2876 // CHttpDownload::SetStringAttributeL |
|
2877 // ?implementation_description |
|
2878 // (other items were commented in a header). |
|
2879 // ----------------------------------------------------------------------------- |
|
2880 // |
|
2881 EXPORT_C void CHttpDownload::SetStringAttributeL( THttpDownloadAttrib aAttribute, |
|
2882 const TDesC8& aValue ) |
|
2883 { |
|
2884 LOGGER_ENTERFN( "SetStringAttributeL(8)" ); |
|
2885 CLOG_WRITE_2( "Attr(%d - %d)", aAttribute, aValue.Length () ); |
|
2886 TBool store( ETrue ); |
|
2887 |
|
2888 iNoRealError = ETrue; |
|
2889 |
|
2890 CheckAttribMaxLengthL( aAttribute, aValue ); |
|
2891 |
|
2892 switch( aAttribute ) |
|
2893 { |
|
2894 case EDlAttrReqUrl: |
|
2895 // this is only for internal testing usage!!! |
|
2896 { |
|
2897 if( iDlState == EHttpDlMultipleMOStarted ) |
|
2898 { |
|
2899 ReallocateStringL( iUrl, aValue, KMaxUrlLength ); |
|
2900 ParseRequestedUrlL(); // iCurrentUrl is initialized there |
|
2901 ParseDownloadNameL(); |
|
2902 } |
|
2903 } |
|
2904 break; |
|
2905 |
|
2906 case EDlAttrContentType: |
|
2907 { |
|
2908 if( iDlState == EHttpDlInprogress ) |
|
2909 { |
|
2910 ReallocateStringL( iContentType, aValue, KMaxContentTypeLength ); |
|
2911 TriggerEvent( EHttpDlInprogress, EHttpProgContentTypeChanged ); |
|
2912 } |
|
2913 else if (iDlState == EHttpDlMultipleMOCompleted )//Allow to change content type even if state is completed |
|
2914 { |
|
2915 ReallocateStringL( iContentType, aValue, KMaxContentTypeLength ); |
|
2916 //No need to trigger any event |
|
2917 } |
|
2918 } |
|
2919 break; |
|
2920 |
|
2921 case EDlAttrRealm: |
|
2922 { |
|
2923 if( iContinueDownload && iDlState == EHttpDlMultipleMOStarted ) |
|
2924 { |
|
2925 ReallocateStringL( iHttpRealm, aValue, KMaxRealmLength ); |
|
2926 } |
|
2927 store = EFalse; |
|
2928 } |
|
2929 break; |
|
2930 |
|
2931 case EDlAttrUsername: |
|
2932 { |
|
2933 ReallocateStringL( iHttpUsername, aValue, KMaxDefAttrLength ); |
|
2934 store = EFalse; |
|
2935 } |
|
2936 break; |
|
2937 |
|
2938 case EDlAttrPassword: |
|
2939 { |
|
2940 ReallocateStringL( iHttpPassword, aValue, KMaxDefAttrLength ); |
|
2941 store = EFalse; |
|
2942 } |
|
2943 break; |
|
2944 |
|
2945 case EDlAttrProxyRealm: |
|
2946 { |
|
2947 if( iContinueDownload && iDlState == EHttpDlMultipleMOStarted ) |
|
2948 { |
|
2949 ReallocateStringL( iHttpProxyRealm, aValue, KMaxRealmLength ); |
|
2950 } |
|
2951 store = EFalse; |
|
2952 } |
|
2953 break; |
|
2954 |
|
2955 case EDlAttrProxyUsername: |
|
2956 { |
|
2957 ReallocateStringL( iHttpProxyUsername, aValue, KMaxDefAttrLength ); |
|
2958 store = EFalse; |
|
2959 } |
|
2960 break; |
|
2961 |
|
2962 case EDlAttrProxyPassword: |
|
2963 { |
|
2964 ReallocateStringL( iHttpProxyPassword, aValue, KMaxDefAttrLength ); |
|
2965 store = EFalse; |
|
2966 } |
|
2967 break; |
|
2968 |
|
2969 case EDlAttrRequestHeaderAddon: |
|
2970 { |
|
2971 if( aValue.Length() ) |
|
2972 { |
|
2973 ParseRequestHeaderAddOnL( aValue ); |
|
2974 } |
|
2975 } |
|
2976 break; |
|
2977 |
|
2978 case EDlAttrResponseHeader: |
|
2979 { |
|
2980 if( iContinueDownload && iDlState == EHttpDlMultipleMOStarted ) |
|
2981 { |
|
2982 ContinueDownloadStoreResponseHeaderL( aValue ); |
|
2983 } |
|
2984 } |
|
2985 break; |
|
2986 |
|
2987 // Request headers |
|
2988 case EDlAttrRequestAccept: |
|
2989 case EDlAttrRequestAcceptCharSet: |
|
2990 case EDlAttrRequestAcceptLanguage: |
|
2991 case EDlAttrRequestExpect: |
|
2992 case EDlAttrRequestFrom: |
|
2993 case EDlAttrRequestHost: |
|
2994 case EDlAttrRequestMaxForwards: |
|
2995 case EDlAttrRequestPragma: |
|
2996 case EDlAttrRequestReferer: |
|
2997 case EDlAttrRequestUserAgent: |
|
2998 case EDlAttrRequestVary: |
|
2999 { |
|
3000 AddHeaderL( aAttribute, aValue, KRequestHeaderConvTable, iRequestHeaders ); |
|
3001 } |
|
3002 break; |
|
3003 |
|
3004 // General header fields |
|
3005 case EDlAttrGeneralCacheControl: |
|
3006 case EDlAttrGeneralPragma: |
|
3007 { |
|
3008 AddHeaderL( aAttribute, aValue, KGeneralHeaderConvTable, iGeneralHeaders ); |
|
3009 } |
|
3010 break; |
|
3011 |
|
3012 case EDlAttrHashedMsgBody: |
|
3013 { |
|
3014 ReallocateStringL( iHashedMsgBody, aValue, KHashLength ); |
|
3015 } |
|
3016 break; |
|
3017 |
|
3018 case EDlAttrRedirectedPermanently: |
|
3019 { |
|
3020 RedirectedPermanentlyL( aValue ); |
|
3021 |
|
3022 if (iCodDlData) |
|
3023 { |
|
3024 // Update for Active media object. |
|
3025 TInt active = iActiveDownload; |
|
3026 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
|
3027 if (!mediaData->Redirected()) |
|
3028 mediaData->SetRedirUrlL( aValue ); |
|
3029 } |
|
3030 } |
|
3031 break; |
|
3032 |
|
3033 case EDlAttrRedirectedTemporary: |
|
3034 { |
|
3035 RedirectedTemporaryL( aValue ); |
|
3036 |
|
3037 if (iCodDlData) |
|
3038 { |
|
3039 // Update for Active media object. |
|
3040 TInt active = iActiveDownload; |
|
3041 CMediaDataBase* mediaData = (*iCodDlData)[active]; |
|
3042 mediaData->SetRedirected( ETrue ); |
|
3043 } |
|
3044 } |
|
3045 break; |
|
3046 |
|
3047 case EDlAttrContinueBody: |
|
3048 { |
|
3049 iNoRealError = EFalse; |
|
3050 ResponseBodyReceivedL( aValue ); |
|
3051 store = EFalse; |
|
3052 } |
|
3053 break; |
|
3054 |
|
3055 case EDlAttrUpdatedDDUri: |
|
3056 { |
|
3057 ReallocateStringL( iUrl, aValue, KMaxUrlLength ); |
|
3058 } |
|
3059 break; |
|
3060 |
|
3061 default: |
|
3062 #ifdef __WINS__ |
|
3063 DMPanic( KErrArgument ); |
|
3064 #else |
|
3065 User::Leave( KErrArgument ); |
|
3066 #endif |
|
3067 break; |
|
3068 } |
|
3069 |
|
3070 UpdatePausable(); |
|
3071 |
|
3072 iNoRealError = EFalse; |
|
3073 |
|
3074 if( store ) |
|
3075 { |
|
3076 StoreDownloadInfoL(); |
|
3077 } |
|
3078 } |
|
3079 |
|
3080 // ----------------------------------------------------------------------------- |
|
3081 // CHttpDownload::SetStringAttributeL |
|
3082 // ?implementation_description |
|
3083 // (other items were commented in a header). |
|
3084 // ----------------------------------------------------------------------------- |
|
3085 // |
|
3086 EXPORT_C void CHttpDownload::SetFileHandleAttributeL( RFile* aFile ) |
|
3087 { |
|
3088 LOGGER_ENTERFN( "SetFileHandleAttributeL" ); |
|
3089 |
|
3090 iStorage->AdoptFileHandleL( aFile ); |
|
3091 } |
|
3092 |
|
3093 // ----------------------------------------------------------------------------- |
|
3094 // CHttpDownload::SetDownloadDataAttributeL |
|
3095 // ?implementation_description |
|
3096 // (other items were commented in a header). |
|
3097 // ----------------------------------------------------------------------------- |
|
3098 // |
|
3099 EXPORT_C void CHttpDownload::SetDownloadDataAttributeL( HBufC8* dlData ) |
|
3100 { |
|
3101 LOGGER_ENTERFN( "SetDownloadDataAttributeL" ); |
|
3102 |
|
3103 if (iCodDlData) |
|
3104 { |
|
3105 delete iCodDlData; |
|
3106 iCodDlData = NULL; |
|
3107 } |
|
3108 |
|
3109 iCodDlData = CDownloadDataServ::NewL(*dlData); |
|
3110 TInt downloadedSize = 0 ; |
|
3111 TBool activeDownloadChanged = EFalse; |
|
3112 |
|
3113 iMoLength = 0 ; |
|
3114 for ( TInt i = 1; i <= iCodDlData->Count() ; ++i ) |
|
3115 { |
|
3116 downloadedSize = downloadedSize + (*iCodDlData)[i]->DownloadedSize(); |
|
3117 iMoLength += (*iCodDlData)[i]->Size(); |
|
3118 |
|
3119 // Below code is executed only when download is paused. |
|
3120 // Set the ActiveDownload, DownloadedSize and Length. |
|
3121 if (((*iCodDlData)[i]->State() == EInProgress) && !activeDownloadChanged) |
|
3122 { |
|
3123 iActiveDownload = i; |
|
3124 iStorage->SetDownloadedSize( (*iCodDlData)[i]->DownloadedSize() ); |
|
3125 iStorage->SetLength( (*iCodDlData)[i]->Size() ); |
|
3126 activeDownloadChanged = ETrue; |
|
3127 } |
|
3128 } |
|
3129 iStorage->SetMoDownloadedSize( downloadedSize ); |
|
3130 } |
|
3131 // ----------------------------------------------------------------------------- |
|
3132 // CHttpDownload::SetTrackDataAttributeL |
|
3133 // ?implementation_description |
|
3134 // (other items were commented in a header). |
|
3135 // ----------------------------------------------------------------------------- |
|
3136 // |
|
3137 EXPORT_C void CHttpDownload::SetTrackDataAttributeL( TInt aIndex, HBufC8* dlData ) |
|
3138 { |
|
3139 LOGGER_ENTERFN( "SetTrackDataAttributeL" ); |
|
3140 |
|
3141 if (iCodDlData) |
|
3142 { |
|
3143 CMediaDataServ* updatedMediaData = CMediaDataServ::NewL(*dlData); |
|
3144 CMediaDataBase* mediaData = (*iCodDlData)[aIndex]; |
|
3145 mediaData->SetNameL(updatedMediaData->Name()); |
|
3146 mediaData->SetUrlL(updatedMediaData->Url()); |
|
3147 mediaData->SetSize(updatedMediaData->Size()); |
|
3148 mediaData->SetIconL( updatedMediaData->Icon() ); |
|
3149 mediaData->SetSourceUriL( updatedMediaData->SourceUri() ); |
|
3150 mediaData->SetProgressiveDownload( updatedMediaData->ProgressiveDownload() ); |
|
3151 mediaData->SetState( updatedMediaData->State() ); |
|
3152 mediaData->SetResult( updatedMediaData->Result() ); |
|
3153 mediaData->SetDownloadedSize( updatedMediaData->DownloadedSize() ); |
|
3154 mediaData->SetDestFilenameL( updatedMediaData->DestFilename() ); |
|
3155 mediaData->SetTempFilenameL( updatedMediaData->DestFilename() ); |
|
3156 |
|
3157 mediaData->ResetTypes(); |
|
3158 for (TInt type = 0; type < updatedMediaData->TypesCount(); ++type) |
|
3159 mediaData->AddTypeL( updatedMediaData->Types().MdcaPoint(type) ); |
|
3160 |
|
3161 TInt result = updatedMediaData->Result(); |
|
3162 |
|
3163 //New track download Begins.Hence make track size as 0 |
|
3164 //iStorage->SetDownloadedSize ( 0 ); |
|
3165 // Active MO completed OR failed. Notify clients. |
|
3166 if (mediaData->Result() == 0) |
|
3167 { |
|
3168 iGlobalErrorId = 0; |
|
3169 iLastError = 0; |
|
3170 TriggerEvent( EHttpDlCompleted, EHttpProgNone ); |
|
3171 } |
|
3172 else |
|
3173 { |
|
3174 // Set the error codes for single track albums |
|
3175 if(iCodDlData->Count() == 1) |
|
3176 { |
|
3177 if ( result <= -1000 ) |
|
3178 { |
|
3179 iGlobalErrorId = KErrGeneral; |
|
3180 iLastError = (THttpDownloadMgrError)result; |
|
3181 } |
|
3182 else |
|
3183 { |
|
3184 iGlobalErrorId = result; |
|
3185 iLastError = EGeneral; |
|
3186 } |
|
3187 } |
|
3188 TriggerEvent( EHttpDlFailed, EHttpProgNone ); |
|
3189 } |
|
3190 } |
|
3191 } |
|
3192 // ----------------------------------------------------------------------------- |
|
3193 // CHttpDownload::ClientAppInstance |
|
3194 // ?implementation_description |
|
3195 // (other items were commented in a header). |
|
3196 // ----------------------------------------------------------------------------- |
|
3197 // |
|
3198 EXPORT_C CHttpClientAppInstance* CHttpDownload::ClientAppInstance() const |
|
3199 { |
|
3200 return iClAppInstance; |
|
3201 } |
|
3202 |
|
3203 // ----------------------------------------------------------------------------- |
|
3204 // CHttpDownload::OnError |
|
3205 // ?implementation_description |
|
3206 // (other items were commented in a header). |
|
3207 // ----------------------------------------------------------------------------- |
|
3208 // |
|
3209 EXPORT_C void CHttpDownload::OnError( TInt aError, |
|
3210 THttpDownloadMgrError aDlError ) |
|
3211 { |
|
3212 LOGGER_ENTERFN( "OnError" ); |
|
3213 CLOG_WRITE_2( "OnError1: %d - %d", aError, aDlError ); |
|
3214 |
|
3215 if( iNoRealError ) |
|
3216 // Leave occured in Get/Set function. This leave must NOT stop |
|
3217 // download process. |
|
3218 { |
|
3219 CLOG_WRITE( "No real error" ); |
|
3220 iNoRealError = EFalse; |
|
3221 |
|
3222 return; |
|
3223 } |
|
3224 |
|
3225 if( iCodDlData && iCodDlData->Count() > 1 ) |
|
3226 { |
|
3227 if( aDlError == KErrMultipeObjectDownloadFailed ) |
|
3228 { |
|
3229 //Permanently failed error in CodHandler |
|
3230 //Delete the download |
|
3231 SetDownloadStatus( EHttpProgNone, |
|
3232 EHttpDlMultipleMOFailed, |
|
3233 aDlError, |
|
3234 aError ); |
|
3235 return; |
|
3236 } |
|
3237 else |
|
3238 { |
|
3239 SetDownloadStatus( EHttpProgNone, |
|
3240 EHttpDlPaused, |
|
3241 aDlError, |
|
3242 aError ); |
|
3243 return; |
|
3244 |
|
3245 } |
|
3246 } |
|
3247 |
|
3248 if( iDlState < EHttpDlCreated ) |
|
3249 // error occured during download object construction -> nothing to do here |
|
3250 { |
|
3251 return; |
|
3252 } |
|
3253 |
|
3254 |
|
3255 //For COD Downloads, the error code may be set from COD handler |
|
3256 //In that case if the download is paused just set the global and download error |
|
3257 |
|
3258 if( iCodDownload && iDlState == EHttpDlPaused ) |
|
3259 { |
|
3260 iLastError = aDlError; |
|
3261 iGlobalErrorId = aError; |
|
3262 TRAP_IGNORE( StoreDownloadInfoL() ); |
|
3263 return; |
|
3264 } |
|
3265 |
|
3266 |
|
3267 CancelTransaction(); |
|
3268 Cancel(); |
|
3269 Disconnect(); |
|
3270 // forget downloaded but not persisted content in case of OOM |
|
3271 CHttpStorage::TFileCloseOperation closeOp = CHttpStorage::EKeepFile; |
|
3272 if ( !Pausable() && ( iCodDlData && iCodDlData->Count() == 1 ) ) |
|
3273 { |
|
3274 closeOp = CHttpStorage::EReplaceFile; |
|
3275 } |
|
3276 |
|
3277 iStorage->CloseDestinationFile( closeOp ); |
|
3278 CLOG_WRITE_1( "OnError1 : iDlState : %d ", iDlState ); |
|
3279 |
|
3280 if( iDlState != EHttpDlMultipleMOFailed ) |
|
3281 { |
|
3282 |
|
3283 // HTTP error code range (-7200 to -7399) |
|
3284 if((aError <= KHttpErrorBase && aError >= KHttpErrorBase - 199)|| |
|
3285 aError == KErrConnectionTerminated || |
|
3286 aError == KErrCannotFindProtocol ) |
|
3287 { |
|
3288 if(!iPausable) |
|
3289 { |
|
3290 TriggerEvent( EHttpDlNonPausableNetworkLoss ); |
|
3291 } |
|
3292 } |
|
3293 |
|
3294 if( aError == KErrHttpPartialResponseReceived ) |
|
3295 { |
|
3296 //Partial response has been received and connection has been disconnected. This error will be |
|
3297 //propagated to the client only, if the HTTP:ENotifyOnDisconnect property is set with a value |
|
3298 //HTTP::EEnableDisconnectNotification |
|
3299 |
|
3300 //This error code was cancelling the pausable download. This error shud be ignored to keep the |
|
3301 //paused download. |
|
3302 //TSW Err ID : SXUU-77SRWL |
|
3303 |
|
3304 SetDownloadStatus( EHttpProgNone, |
|
3305 EHttpDlPaused, |
|
3306 aDlError, |
|
3307 aError ); |
|
3308 |
|
3309 } |
|
3310 else if( aDlError == EConnectionFailed && iPausable) |
|
3311 { |
|
3312 //Whenever connection error occurs and download can be paused. |
|
3313 //Keep the download in paused state. |
|
3314 SetDownloadStatus( EHttpProgNone, |
|
3315 EHttpDlPaused, |
|
3316 aDlError, |
|
3317 aError ); |
|
3318 } |
|
3319 else if ( aDlError == EMMCRemoved ) |
|
3320 { |
|
3321 // MMC removed. Pause the download. |
|
3322 SetDownloadStatus( EHttpProgNone, |
|
3323 EHttpDlPaused, |
|
3324 aDlError, |
|
3325 aError ); |
|
3326 } |
|
3327 else |
|
3328 { |
|
3329 |
|
3330 SetDownloadStatus( EHttpProgNone, |
|
3331 EHttpDlMultipleMOFailed, |
|
3332 aDlError, |
|
3333 aError ); |
|
3334 if(!iCodDlData) |
|
3335 { |
|
3336 TriggerEvent( EHttpDlFailed, EHttpProgNone ); |
|
3337 } |
|
3338 } |
|
3339 } |
|
3340 else if( ( EHttpDlMultipleMOFailed == iDlState ) && iCodDownload ) |
|
3341 { |
|
3342 TriggerEvent( EHttpDlMultipleMOFailed ); |
|
3343 } |
|
3344 |
|
3345 TRAP_IGNORE( StoreDownloadInfoL() ); |
|
3346 } |
|
3347 |
|
3348 |
|
3349 // ----------------------------------------------------------------------------- |
|
3350 // CHttpDownload::DetachClientInstance |
|
3351 // ?implementation_description |
|
3352 // (other items were commented in a header). |
|
3353 // ----------------------------------------------------------------------------- |
|
3354 // |
|
3355 EXPORT_C TBool CHttpDownload::DetachClientInstance( CHttpClientAppInstance* aInstance ) |
|
3356 { |
|
3357 if( iClAppInstance == aInstance ) |
|
3358 { |
|
3359 iClAppInstance = NULL; |
|
3360 } |
|
3361 else if( iPDClAppInstance == aInstance ) |
|
3362 { |
|
3363 iPDClAppInstance = NULL; |
|
3364 } |
|
3365 |
|
3366 return (iPDClAppInstance || iClAppInstance); |
|
3367 } |
|
3368 |
|
3369 |
|
3370 // ----------------------------------------------------------------------------- |
|
3371 // CHttpDownload::ClientApp |
|
3372 // ?implementation_description |
|
3373 // (other items were commented in a header). |
|
3374 // ----------------------------------------------------------------------------- |
|
3375 // |
|
3376 CHttpClientApp* CHttpDownload::ClientApp() const |
|
3377 { |
|
3378 return iClientApp; |
|
3379 } |
|
3380 |
|
3381 // ----------------------------------------------------------------------------- |
|
3382 // CHttpDownload::PDClientAppInstance |
|
3383 // ?implementation_description |
|
3384 // (other items were commented in a header). |
|
3385 // ----------------------------------------------------------------------------- |
|
3386 // |
|
3387 CHttpClientAppInstance* CHttpDownload::PDClientAppInstance() const |
|
3388 { |
|
3389 return iPDClAppInstance; |
|
3390 } |
|
3391 |
|
3392 // ----------------------------------------------------------------------------- |
|
3393 // CHttpDownload::Id |
|
3394 // ?implementation_description |
|
3395 // (other items were commented in a header). |
|
3396 // ----------------------------------------------------------------------------- |
|
3397 // |
|
3398 TInt CHttpDownload::Id() const |
|
3399 { |
|
3400 return iId; |
|
3401 } |
|
3402 |
|
3403 // ----------------------------------------------------------------------------- |
|
3404 // CHttpDownload::State |
|
3405 // ?implementation_description |
|
3406 // (other items were commented in a header). |
|
3407 // ----------------------------------------------------------------------------- |
|
3408 // |
|
3409 THttpDownloadState CHttpDownload::State() const |
|
3410 { |
|
3411 return iDlState; |
|
3412 } |
|
3413 |
|
3414 // ----------------------------------------------------------------------------- |
|
3415 // CHttpDownload::ProgState |
|
3416 // ?implementation_description |
|
3417 // (other items were commented in a header). |
|
3418 // ----------------------------------------------------------------------------- |
|
3419 // |
|
3420 THttpProgressState CHttpDownload::ProgState() const |
|
3421 { |
|
3422 return iProgState; |
|
3423 } |
|
3424 |
|
3425 // ----------------------------------------------------------------------------- |
|
3426 // CHttpDownload::ConnHandler |
|
3427 // ?implementation_description |
|
3428 // (other items were commented in a header). |
|
3429 // ----------------------------------------------------------------------------- |
|
3430 // |
|
3431 CHttpConnHandler* CHttpDownload::ConnHandler() const |
|
3432 { |
|
3433 return iConnHandler; |
|
3434 } |
|
3435 |
|
3436 // ----------------------------------------------------------------------------- |
|
3437 // CHttpDownload::NoMedia |
|
3438 // ?implementation_description |
|
3439 // (other items were commented in a header). |
|
3440 // ----------------------------------------------------------------------------- |
|
3441 // |
|
3442 TBool CHttpDownload::NoMedia() const |
|
3443 { |
|
3444 return iNoMedia; |
|
3445 } |
|
3446 |
|
3447 // ----------------------------------------------------------------------------- |
|
3448 // CHttpDownload::MediaRemoved |
|
3449 // ?implementation_description |
|
3450 // (other items were commented in a header). |
|
3451 // ----------------------------------------------------------------------------- |
|
3452 // |
|
3453 void CHttpDownload::MediaRemoved( TUint aUid, TBool aDontCheckMediaUid ) |
|
3454 { |
|
3455 LOGGER_ENTERFN( "MediaRemoved" ); |
|
3456 CLOG_WRITE_3( "Uid: %d, dontCheck: %d, iNoMedia: %d", |
|
3457 aUid, |
|
3458 aDontCheckMediaUid, |
|
3459 iNoMedia ); |
|
3460 |
|
3461 if( iNoMedia ) |
|
3462 // it is already known for us. |
|
3463 { |
|
3464 CLOG_WRITE("already know it"); |
|
3465 return; |
|
3466 } |
|
3467 |
|
3468 if( !aDontCheckMediaUid && iStorage->GetDestinationDriveId() != aUid ) |
|
3469 // destination drive is not media card |
|
3470 { |
|
3471 CLOG_WRITE("who cares"); |
|
3472 return; |
|
3473 } |
|
3474 |
|
3475 iNoMedia = ETrue; |
|
3476 |
|
3477 TRAP_IGNORE( InternalPauseL() ); |
|
3478 |
|
3479 TriggerEvent( EHttpDlMediaRemoved ); |
|
3480 |
|
3481 if( iDlState == EHttpDlInprogress ) |
|
3482 // it's happened during the download process |
|
3483 // in case of e.g completed download it's not error |
|
3484 { |
|
3485 OnError( KErrGeneral, EMMCRemoved ); |
|
3486 } |
|
3487 |
|
3488 TRAP_IGNORE( StoreDownloadInfoL() ); |
|
3489 } |
|
3490 |
|
3491 // ----------------------------------------------------------------------------- |
|
3492 // CHttpDownload::MediaInserted |
|
3493 // ?implementation_description |
|
3494 // (other items were commented in a header). |
|
3495 // ----------------------------------------------------------------------------- |
|
3496 // |
|
3497 void CHttpDownload::MediaInserted( TUint aUid ) |
|
3498 { |
|
3499 LOGGER_ENTERFN( "MediaInserted" ); |
|
3500 |
|
3501 if( iStorage->GetDestinationDriveId() != aUid ) |
|
3502 // this is not our media card |
|
3503 { |
|
3504 return; |
|
3505 } |
|
3506 |
|
3507 iNoMedia = EFalse; |
|
3508 TriggerEvent( EHttpDlMediaInserted ); |
|
3509 } |
|
3510 |
|
3511 // ----------------------------------------------------------------------------- |
|
3512 // CHttpDownload::GetDestinationDriveID |
|
3513 // ?implementation_description |
|
3514 // (other items were commented in a header). |
|
3515 // ----------------------------------------------------------------------------- |
|
3516 // |
|
3517 TInt CHttpDownload::GetDestinationDriveID() const |
|
3518 { |
|
3519 return (TInt)iStorage->GetDestinationDriveId(); |
|
3520 } |
|
3521 |
|
3522 // ----------------------------------------------------------------------------- |
|
3523 // CHttpDownload::SetClientInstance |
|
3524 // ?implementation_description |
|
3525 // (other items were commented in a header). |
|
3526 // ----------------------------------------------------------------------------- |
|
3527 // |
|
3528 void CHttpDownload::SetClientInstance( CHttpClientAppInstance* aInstance, |
|
3529 TBool aNoMoveEvent ) |
|
3530 { |
|
3531 iClAppInstance = aInstance; |
|
3532 |
|
3533 if( iClAppInstance ) |
|
3534 { |
|
3535 __ASSERT_DEBUG( iClAppInstance->Observer(), DMPanic( KErrCorrupt ) ); |
|
3536 if( iClAppInstance->Observer() && !aNoMoveEvent ) |
|
3537 // for this short moment download state becomes EHttpDlMoved |
|
3538 // to inform client app about that it grabbed this download |
|
3539 { |
|
3540 TriggerEvent( EHttpDlMoved, iProgState ); |
|
3541 } |
|
3542 } |
|
3543 |
|
3544 else |
|
3545 // No reason to keep it PD. |
|
3546 { |
|
3547 if (iStorage) |
|
3548 { |
|
3549 iStorage->SetProgressiveMode( EFalse ); |
|
3550 } |
|
3551 } |
|
3552 } |
|
3553 |
|
3554 |
|
3555 // ----------------------------------------------------------------------------- |
|
3556 // CHttpDownload::SetConnHandler |
|
3557 // ?implementation_description |
|
3558 // (other items were commented in a header). |
|
3559 // ----------------------------------------------------------------------------- |
|
3560 // |
|
3561 void CHttpDownload::SetConnHandler( CHttpConnHandler* aConnHandler ) |
|
3562 { |
|
3563 iConnHandler = aConnHandler; |
|
3564 } |
|
3565 |
|
3566 // ----------------------------------------------------------------------------- |
|
3567 // CHttpDownload::Pausable |
|
3568 // ?implementation_description |
|
3569 // (other items were commented in a header). |
|
3570 // ----------------------------------------------------------------------------- |
|
3571 // |
|
3572 TBool CHttpDownload::Pausable() const |
|
3573 { |
|
3574 return iPausable; |
|
3575 } |
|
3576 |
|
3577 // ----------------------------------------------------------------------------- |
|
3578 // CHttpDownload::SetDownloadNameL |
|
3579 // ----------------------------------------------------------------------------- |
|
3580 // |
|
3581 void CHttpDownload::SetDownloadNameL( const TDesC& aNewName ) |
|
3582 { |
|
3583 CLOG_WRITE_1( "New download name: [%S]", &aNewName ); |
|
3584 |
|
3585 ReallocateStringL( iDlName, aNewName, KDownloadNameMaxSize ); |
|
3586 |
|
3587 FixDownloadNameL(); |
|
3588 |
|
3589 TriggerEvent( EHttpDlInprogress, EHttpProgDlNameChanged ); |
|
3590 } |
|
3591 |
|
3592 // ----------------------------------------------------------------------------- |
|
3593 // CHttpDownload::MHFRunL |
|
3594 // ?implementation_description |
|
3595 // (other items were commented in a header). |
|
3596 // ----------------------------------------------------------------------------- |
|
3597 // |
|
3598 void CHttpDownload::MHFRunL( RHTTPTransaction /*aTransaction*/, |
|
3599 const THTTPEvent& aEvent ) |
|
3600 { |
|
3601 switch ( aEvent.iStatus ) |
|
3602 { |
|
3603 case THTTPEvent::EGotResponseHeaders: |
|
3604 { |
|
3605 CLOG_WRITE( "Response header received" ); |
|
3606 ResponseHeaderReceivedL(); |
|
3607 } |
|
3608 break; |
|
3609 |
|
3610 case THTTPEvent::EGotResponseBodyData: |
|
3611 { |
|
3612 MHTTPDataSupplier* respBody = iTrans.Response().Body(); |
|
3613 TPtrC8 buf; |
|
3614 |
|
3615 respBody->GetNextDataPart( buf ); |
|
3616 |
|
3617 ResponseBodyReceivedL( buf ); |
|
3618 |
|
3619 respBody->ReleaseData(); |
|
3620 } |
|
3621 break; |
|
3622 |
|
3623 case THTTPEvent::EResponseComplete: |
|
3624 { |
|
3625 CLOG_WRITE( "Response complete" ); |
|
3626 } |
|
3627 break; |
|
3628 |
|
3629 case THTTPEvent::ESucceeded: |
|
3630 { |
|
3631 CLOG_WRITE( "Transaction succeeded" ); |
|
3632 |
|
3633 DownloadSucceededL(); |
|
3634 } |
|
3635 break; |
|
3636 |
|
3637 case THTTPEvent::EFailed: |
|
3638 case THTTPEvent::EMoreDataReceivedThanExpected: |
|
3639 case THTTPEvent::EUnrecoverableError: |
|
3640 case THTTPEvent::ETooMuchRequestData: |
|
3641 { |
|
3642 CLOG_WRITE_1( "Failed event: %d", aEvent.iStatus ); |
|
3643 if( iTransValid ) |
|
3644 { |
|
3645 iTrans.Close(); |
|
3646 iTransValid = EFalse; |
|
3647 } |
|
3648 iDlStartedByClient = EFalse; |
|
3649 } |
|
3650 break; |
|
3651 |
|
3652 case THTTPEvent::ERedirectedPermanently: |
|
3653 { |
|
3654 RedirectedPermanentlyL( iTrans.Request().URI().UriDes() ); |
|
3655 } |
|
3656 break; |
|
3657 |
|
3658 case THTTPEvent::ERedirectedTemporarily: |
|
3659 { |
|
3660 RedirectedTemporaryL( iTrans.Request().URI().UriDes() ); |
|
3661 } |
|
3662 break; |
|
3663 |
|
3664 default: |
|
3665 { |
|
3666 CLOG_WRITE_1( "Event: %d", aEvent.iStatus ); |
|
3667 if( aEvent.iStatus < 0 ) |
|
3668 // error occured -> leave will be handled in OnError() |
|
3669 { |
|
3670 User::Leave( aEvent.iStatus ); |
|
3671 } |
|
3672 } |
|
3673 break; |
|
3674 } |
|
3675 } |
|
3676 |
|
3677 // ----------------------------------------------------------------------------- |
|
3678 // CHttpDownload::MHFRunError |
|
3679 // ?implementation_description |
|
3680 // (other items were commented in a header). |
|
3681 // ----------------------------------------------------------------------------- |
|
3682 // |
|
3683 TInt CHttpDownload::MHFRunError( TInt aError, |
|
3684 RHTTPTransaction /*aTransaction*/, |
|
3685 const THTTPEvent& /*aEvent*/ ) |
|
3686 { |
|
3687 CLOG_WRITE_1( "MHFRunError: %d", aError ); |
|
3688 |
|
3689 OnError( aError, ETransactionFailed ); |
|
3690 |
|
3691 return KErrNone; |
|
3692 } |
|
3693 |
|
3694 // ----------------------------------------------------------------------------- |
|
3695 // CHttpDownload::DoCancel |
|
3696 // ?implementation_description |
|
3697 // (other items were commented in a header). |
|
3698 // ----------------------------------------------------------------------------- |
|
3699 // |
|
3700 void CHttpDownload::DoCancel() |
|
3701 { |
|
3702 LOGGER_ENTERFN( "DoCancel" ); |
|
3703 |
|
3704 if( iProgState == EHttpProgMovingContentFile ) |
|
3705 { |
|
3706 delete iFileMan; |
|
3707 iFileMan = NULL; |
|
3708 |
|
3709 if( iStatus == KRequestPending ) |
|
3710 // No cancel function in CFileMan |
|
3711 { |
|
3712 SelfComplete( KErrCancel ); |
|
3713 } |
|
3714 } |
|
3715 } |
|
3716 |
|
3717 // ----------------------------------------------------------------------------- |
|
3718 // CHttpDownload::RunL |
|
3719 // ?implementation_description |
|
3720 // (other items were commented in a header). |
|
3721 // ----------------------------------------------------------------------------- |
|
3722 // |
|
3723 void CHttpDownload::RunL() |
|
3724 { |
|
3725 LOGGER_ENTERFN( "RunL" ); |
|
3726 |
|
3727 switch( iProgState ) |
|
3728 // Keep progress states consistent with SetDownloadStatus() |
|
3729 { |
|
3730 case EHttpStarted: |
|
3731 { |
|
3732 iUpdatedDDUriSet = EFalse; |
|
3733 Connect(); |
|
3734 } |
|
3735 break; |
|
3736 |
|
3737 case EHttpProgConnected: |
|
3738 { |
|
3739 if( iStatus == KErrNone ) |
|
3740 { |
|
3741 if( iCodDownload ) |
|
3742 { |
|
3743 TriggerEvent( EHttpDlInprogress, EHttpProgCodDownloadShouldResume ); |
|
3744 } |
|
3745 else |
|
3746 { |
|
3747 RequestContentL(); |
|
3748 } |
|
3749 } |
|
3750 |
|
3751 } |
|
3752 break; |
|
3753 |
|
3754 case EHttpProgMovingContentFile: |
|
3755 // Move completed |
|
3756 // State remains in completed |
|
3757 // and move result stored in error attribs |
|
3758 { |
|
3759 CLOG_WRITE_1( "Move result: %d", iStatus.Int() ); |
|
3760 // In case of PDL for OMA2 the MP/VP moves the file after the playback is done. |
|
3761 // So, the download status should be changed after that |
|
3762 //but we again send the progress state as EHttpProgContentFileMoved because we need to display |
|
3763 //where file is saved(saved to gallery) |
|
3764 //Change Dl State to Download Completed if not already |
|
3765 |
|
3766 if(_OMADLOTA2_MULTI_DOWNLOAD) |
|
3767 { |
|
3768 TPtrC fileNamePtr = ((*iCodDlData)[iMOMoved])->DestFilename(); |
|
3769 NotifyMediaGalleryL(fileNamePtr); |
|
3770 |
|
3771 // Initiate async move for the next media object |
|
3772 iMOMoved++; |
|
3773 if(iMOMoved <= iCodDlData->Count()) |
|
3774 { |
|
3775 MoveDownloadedMediaObjectL(iMOMoved); |
|
3776 break; |
|
3777 } |
|
3778 } |
|
3779 |
|
3780 SetDownloadStatus( iDlNameChanged ? EHttpProgContentFileMovedAndDestFNChanged : EHttpProgContentFileMoved, |
|
3781 iDlState = EHttpDlMultipleMOCompleted, |
|
3782 iStatus == KErrNone ? ENoError : EMoveFailed, |
|
3783 iStatus.Int() ); |
|
3784 |
|
3785 if(iStatus == KErrNone) |
|
3786 { |
|
3787 iMoveInProgress = EFalse; |
|
3788 CLOG_WRITE("setting iMoveInProgress false when move is completed"); |
|
3789 } |
|
3790 |
|
3791 |
|
3792 delete iFileMan; iFileMan = NULL; |
|
3793 |
|
3794 if( !_OMADLOTA2_MULTI_DOWNLOAD) |
|
3795 { |
|
3796 TPtr fileNamePtr(iStorage->DestFilename()->Des()); |
|
3797 NotifyMediaGalleryL(fileNamePtr); |
|
3798 } |
|
3799 } |
|
3800 break; |
|
3801 |
|
3802 default: |
|
3803 { |
|
3804 DMPanic( KErrUnknown ); |
|
3805 } |
|
3806 } |
|
3807 } |
|
3808 |
|
3809 // ----------------------------------------------------------------------------- |
|
3810 // CHttpDownload::RunError |
|
3811 // ?implementation_description |
|
3812 // (other items were commented in a header). |
|
3813 // ----------------------------------------------------------------------------- |
|
3814 // |
|
3815 TInt CHttpDownload::RunError(TInt aError) |
|
3816 { |
|
3817 // Untrapped leave occured in RunL() -> status must be update and |
|
3818 // client app has to be informed. |
|
3819 OnError( aError ); |
|
3820 |
|
3821 return KErrNone; |
|
3822 } |
|
3823 |
|
3824 // ----------------------------------------------------------------------------- |
|
3825 // CHttpDownload::Connected |
|
3826 // ?implementation_description |
|
3827 // (other items were commented in a header). |
|
3828 // ----------------------------------------------------------------------------- |
|
3829 // |
|
3830 void CHttpDownload::Connected() |
|
3831 { |
|
3832 LOGGER_ENTERFN( "Connected" ); |
|
3833 |
|
3834 if( iProgState == EHttpProgCreatingConnection ) |
|
3835 // In any other progress state we're not interested in this event |
|
3836 { |
|
3837 SetDownloadStatus( EHttpProgConnected, EHttpDlInprogress ); |
|
3838 } |
|
3839 } |
|
3840 |
|
3841 // ----------------------------------------------------------------------------- |
|
3842 // CHttpDownload::Suspended |
|
3843 // ?implementation_description |
|
3844 // (other items were commented in a header). |
|
3845 // ----------------------------------------------------------------------------- |
|
3846 // |
|
3847 void CHttpDownload::Suspended() |
|
3848 { |
|
3849 LOGGER_ENTERFN( "Suspended" ); |
|
3850 |
|
3851 if( iDlState != EHttpDlInprogress ) |
|
3852 // we are not interested in this event, |
|
3853 // only if the download is in progress. |
|
3854 { |
|
3855 return; |
|
3856 } |
|
3857 |
|
3858 SetDownloadStatus( EHttpProgConnectionSuspended ); |
|
3859 } |
|
3860 |
|
3861 // ----------------------------------------------------------------------------- |
|
3862 // CHttpDownload::Disconnected |
|
3863 // ?implementation_description |
|
3864 // (other items were commented in a header). |
|
3865 // ----------------------------------------------------------------------------- |
|
3866 // |
|
3867 void CHttpDownload::Disconnected() |
|
3868 { |
|
3869 LOGGER_ENTERFN( "Disconnected" ); |
|
3870 |
|
3871 if( iDlState != EHttpDlInprogress ) |
|
3872 // we are not interested in this event, |
|
3873 // only if the download is in progress. |
|
3874 { |
|
3875 return; |
|
3876 } |
|
3877 |
|
3878 //Set the errors |
|
3879 TRAP_IGNORE( PauseL( ETrue ) ); |
|
3880 |
|
3881 iLastError = EConnectionFailed; |
|
3882 iGlobalErrorId = KErrCommsLineFail; |
|
3883 } |
|
3884 |
|
3885 |
|
3886 // ----------------------------------------------------------------------------- |
|
3887 // CHttpDownload::ConnectionFailed |
|
3888 // ?implementation_description |
|
3889 // (other items were commented in a header). |
|
3890 // ----------------------------------------------------------------------------- |
|
3891 // |
|
3892 void CHttpDownload::ConnectionFailed( TInt aError ) |
|
3893 { |
|
3894 OnError( aError, EConnectionFailed ); |
|
3895 } |
|
3896 |
|
3897 // ----------------------------------------------------------------------------- |
|
3898 // CHttpDownload::DoReset |
|
3899 // ?implementation_description |
|
3900 // (other items were commented in a header). |
|
3901 // ----------------------------------------------------------------------------- |
|
3902 // |
|
3903 void CHttpDownload::DoReset( TBool aOnDelete ) |
|
3904 { |
|
3905 LOGGER_ENTERFN( "DoReset" ); |
|
3906 |
|
3907 // Do not inform user about what we do while reseting |
|
3908 ++iDontFireEvent; |
|
3909 |
|
3910 Cancel(); |
|
3911 |
|
3912 CancelTransaction(); |
|
3913 |
|
3914 if( iDisconnectOnReset ) |
|
3915 { |
|
3916 Disconnect(); |
|
3917 } |
|
3918 |
|
3919 delete iFileMan; iFileMan = NULL; |
|
3920 |
|
3921 ReInitializeDownload(); |
|
3922 |
|
3923 // these values are not initialized in ReInitializeDownload() |
|
3924 delete iContentType; iContentType = NULL; |
|
3925 delete iDDType; iDDType = NULL; |
|
3926 delete iHttpRealm; iHttpRealm = NULL; |
|
3927 delete iHttpNonce; iHttpNonce = NULL; |
|
3928 TRAP_IGNORE( ReallocateStringL( iRedirUrl, *iUrl, KMaxUrlLength ) ); |
|
3929 TRAP_IGNORE( ReallocateStringL( iCurrentUrl, *iUrl, KMaxUrlLength ) ); |
|
3930 iRedirect = EFalse; |
|
3931 iDlStartedByClient = EFalse; |
|
3932 iPausableDRM = ETrue; |
|
3933 iDrmContentLengthValid = ETrue; |
|
3934 |
|
3935 // content type is unknown -> download might be pausable again |
|
3936 UpdatePausable(); |
|
3937 |
|
3938 if( !aOnDelete ) |
|
3939 { |
|
3940 TRAP_IGNORE( StoreDownloadInfoL() ); |
|
3941 } |
|
3942 |
|
3943 --iDontFireEvent; |
|
3944 |
|
3945 SetDownloadStatus( EHttpProgNone, EHttpDlMultipleMOStarted ); |
|
3946 } |
|
3947 |
|
3948 // ----------------------------------------------------------------------------- |
|
3949 // CHttpDownload::StoreDownloadInfoL |
|
3950 // ?implementation_description |
|
3951 // (other items were commented in a header). |
|
3952 // ----------------------------------------------------------------------------- |
|
3953 // |
|
3954 void CHttpDownload::StoreDownloadInfoL() |
|
3955 { |
|
3956 LOGGER_ENTERFN( "StoreDownloadInfoL" ); |
|
3957 TInt bufSz = KDownloadInfoIncrSize + |
|
3958 (iDownloadInfo ? iDownloadInfo->Length(): 0); |
|
3959 HBufC8* newInfo = HBufC8::NewLC( bufSz ); |
|
3960 TPtr8 newInfoPtr = newInfo->Des(); |
|
3961 |
|
3962 APPEND_BUF_INT( newInfoPtr, KDMgrInfoFileId ); |
|
3963 APPEND_BUF_INT( newInfoPtr, KDmgrVersionNumber ); |
|
3964 APPEND_BUF_INT( newInfoPtr, iDlState ); |
|
3965 APPEND_BUF_INT( newInfoPtr, iProgState ); |
|
3966 APPEND_BUF_INT( newInfoPtr, iLastError ); |
|
3967 APPEND_BUF_INT( newInfoPtr, iGlobalErrorId ); |
|
3968 APPEND_BUF_INT( newInfoPtr, iAction ); |
|
3969 APPEND_BUF_INT( newInfoPtr, iRestartAction ); |
|
3970 APPEND_BUF_INT( newInfoPtr, iNoContentTypeCheck ); |
|
3971 |
|
3972 CLOG_WRITE("2"); |
|
3973 AppendBufL( newInfoPtr, iUrl ); |
|
3974 AppendBufL( newInfoPtr, iRedirUrl ); |
|
3975 APPEND_BUF_INT( newInfoPtr, iPort ); |
|
3976 AppendBufL( newInfoPtr, iCurrentUrl ); |
|
3977 APPEND_BUF_INT( newInfoPtr, iRedirect ); |
|
3978 APPEND_BUF_INT( newInfoPtr, iTargetApp ); |
|
3979 iStorage->AppendStorageInfoL( newInfoPtr ); |
|
3980 AppendBufL( newInfoPtr, iDlName ); |
|
3981 AppendBufL( newInfoPtr, iHashedMsgBody ); |
|
3982 APPEND_BUF_INT( newInfoPtr, iCodDownload ); |
|
3983 APPEND_BUF_INT( newInfoPtr, iNoMedia ); |
|
3984 |
|
3985 CLOG_WRITE("3"); |
|
3986 APPEND_BUF_INT( newInfoPtr, iPreferencies ); |
|
3987 APPEND_BUF_INT( newInfoPtr, iDisconnectOnPause ); |
|
3988 APPEND_BUF_INT( newInfoPtr, iDisconnectOnReset ); |
|
3989 |
|
3990 CLOG_WRITE("4"); |
|
3991 AppendBufL( newInfoPtr, iContentType ); |
|
3992 AppendBufL( newInfoPtr, iDDType ); |
|
3993 APPEND_BUF_INT( newInfoPtr, iDate ); |
|
3994 APPEND_BUF_INT( newInfoPtr, iExpires ); |
|
3995 APPEND_BUF_INT( newInfoPtr, iMaxAge ); |
|
3996 |
|
3997 CLOG_WRITE("5"); |
|
3998 |
|
3999 AppendHeadersL( newInfoPtr, iResponseHeaders ); |
|
4000 AppendHeadersL( newInfoPtr, iRequestHeaders ); |
|
4001 AppendHeadersL( newInfoPtr, iEntityHeaders ); |
|
4002 AppendHeadersL( newInfoPtr, iGeneralHeaders ); |
|
4003 |
|
4004 CLOG_WRITE("6"); |
|
4005 |
|
4006 APPEND_BUF_INT( newInfoPtr, iFotaPckgId ); |
|
4007 |
|
4008 CLOG_WRITE("7"); |
|
4009 |
|
4010 // check if download info is unchanged from previous update |
|
4011 if( iDownloadInfo && ( iDownloadInfo->Compare(*newInfo) == 0 )) |
|
4012 { |
|
4013 // no change |
|
4014 CLOG_WRITE("DownloadInfo unchanged - no need to update"); |
|
4015 CleanupStack::PopAndDestroy( newInfo ); |
|
4016 } |
|
4017 else |
|
4018 { |
|
4019 CLOG_WRITE("DownloadInfo changed - replace info file"); |
|
4020 delete iDownloadInfo; |
|
4021 iDownloadInfo = newInfo; |
|
4022 CleanupStack::Pop( newInfo ); |
|
4023 |
|
4024 HBufC* folderBuf = HBufC::NewLC( KMaxPath ); |
|
4025 TPtr folder = folderBuf->Des(); |
|
4026 HBufC* fileNameBuf = HBufC::NewLC( KMaxPath ); |
|
4027 TPtr fileName = fileNameBuf->Des(); |
|
4028 iClientApp->Engine()->DownloadInfoFolder( iClientApp, folder ); |
|
4029 fileName.Format( _L("%S%d"), &folder, iId ); |
|
4030 CLOG_WRITE_1( "info: %S", &fileName ); |
|
4031 |
|
4032 RFile outFile; |
|
4033 CleanupClosePushL<RFile>( outFile ); |
|
4034 User::LeaveIfError( outFile.Replace( iClientApp->Engine()->Fs(), |
|
4035 fileName, |
|
4036 EFileShareExclusive | |
|
4037 EFileStream | |
|
4038 EFileWrite ) ); |
|
4039 |
|
4040 outFile.Write( newInfoPtr ); |
|
4041 User::LeaveIfError( outFile.Flush() ); |
|
4042 CleanupStack::PopAndDestroy( 2, fileNameBuf ); |
|
4043 CleanupStack::PopAndDestroy(); // outFile |
|
4044 } |
|
4045 CLOG_WRITE("CHttpDownload::StoreDownloadInfoL() - exit"); |
|
4046 } |
|
4047 |
|
4048 // ----------------------------------------------------------------------------- |
|
4049 // CHttpDownload::LoadDownloadInfoL |
|
4050 // ?implementation_description |
|
4051 // (other items were commented in a header). |
|
4052 // ----------------------------------------------------------------------------- |
|
4053 // |
|
4054 void CHttpDownload::LoadDownloadInfoL() |
|
4055 { |
|
4056 LOGGER_ENTERFN( "LoadDownloadInfoL" ); |
|
4057 |
|
4058 HBufC* folderBuf = HBufC::NewLC( KMaxPath ); |
|
4059 TPtr folder = folderBuf->Des(); |
|
4060 HBufC* fileNameBuf = HBufC::NewLC( KMaxPath ); |
|
4061 TPtr fileName = fileNameBuf->Des(); |
|
4062 |
|
4063 iClientApp->Engine()->DownloadInfoFolder( iClientApp, folder ); |
|
4064 |
|
4065 fileName.Format( _L("%S%d"), &folder, iId ); |
|
4066 CLOG_WRITE_1( "info: %S", &fileName ); |
|
4067 |
|
4068 RFile inFile; |
|
4069 User::LeaveIfError( inFile.Open( iClientApp->Engine()->Fs(), |
|
4070 fileName, |
|
4071 EFileShareReadersOnly | |
|
4072 EFileRead ) ); |
|
4073 |
|
4074 CLOG_WRITE("1"); |
|
4075 CleanupClosePushL<RFile>( inFile ); |
|
4076 |
|
4077 TInt32 id; |
|
4078 READ_INT_L( inFile, id ); |
|
4079 |
|
4080 if( id == KDMgrInfoFileId ) |
|
4081 { |
|
4082 TInt version; |
|
4083 READ_INT_L( inFile, version ); |
|
4084 |
|
4085 if( version != KDmgrVersionNumber ) |
|
4086 { |
|
4087 User::Leave( KErrNotSupported ); |
|
4088 } |
|
4089 |
|
4090 READ_INT_L( inFile, iDlState ); |
|
4091 } |
|
4092 else |
|
4093 { |
|
4094 iDlState = (THttpDownloadState)id; |
|
4095 } |
|
4096 |
|
4097 READ_INT_L( inFile, iProgState ); |
|
4098 READ_INT_L( inFile, iLastError ); |
|
4099 READ_INT_L( inFile, iGlobalErrorId ); |
|
4100 READ_INT_L( inFile, iAction ); |
|
4101 READ_INT_L( inFile, iRestartAction ); |
|
4102 READ_INT_L( inFile, iNoContentTypeCheck ); |
|
4103 |
|
4104 CLOG_WRITE("2"); |
|
4105 ReadHBufCL( inFile, iUrl ); |
|
4106 ReadHBufCL( inFile, iRedirUrl ); |
|
4107 READ_INT_L( inFile, iPort ); |
|
4108 ReadHBufCL( inFile, iCurrentUrl ); |
|
4109 READ_INT_L( inFile, iRedirect ); |
|
4110 READ_INT_L( inFile, iTargetApp ); |
|
4111 iStorage->LoadStorageInfoL( inFile ); |
|
4112 ReadHBufCL( inFile, iDlName ); |
|
4113 ReadHBufCL( inFile, iHashedMsgBody ); |
|
4114 READ_INT_L( inFile, iCodDownload ); |
|
4115 READ_INT_L( inFile, iNoMedia ); |
|
4116 |
|
4117 |
|
4118 CLOG_WRITE("3"); |
|
4119 READ_INT_L( inFile, iPreferencies ); |
|
4120 READ_INT_L( inFile, iDisconnectOnPause ); |
|
4121 READ_INT_L( inFile, iDisconnectOnReset ); |
|
4122 |
|
4123 CLOG_WRITE("4"); |
|
4124 ReadHBufCL( inFile, iContentType ); |
|
4125 ReadHBufCL( inFile, iDDType ); |
|
4126 READ_CUST_L( inFile, iDate ); |
|
4127 READ_CUST_L( inFile, iExpires ); |
|
4128 READ_CUST_L( inFile, iMaxAge ); |
|
4129 |
|
4130 CLOG_WRITE("5"); |
|
4131 |
|
4132 LoadHeadersL( inFile, iResponseHeaders ); |
|
4133 LoadHeadersL( inFile, iRequestHeaders ); |
|
4134 LoadHeadersL( inFile, iEntityHeaders ); |
|
4135 LoadHeadersL( inFile, iGeneralHeaders ); |
|
4136 |
|
4137 CLOG_WRITE("6"); |
|
4138 |
|
4139 READ_INT_L( inFile, iFotaPckgId ); |
|
4140 |
|
4141 CleanupStack::PopAndDestroy(); // inFile |
|
4142 CleanupStack::PopAndDestroy( 2, folderBuf ); // also fileNameBuf |
|
4143 |
|
4144 CLOG_WRITE("9"); |
|
4145 |
|
4146 UpdatePausable(); |
|
4147 } |
|
4148 |
|
4149 // ----------------------------------------------------------------------------- |
|
4150 // CHttpDownload::IsExpired |
|
4151 // ?implementation_description |
|
4152 // (other items were commented in a header). |
|
4153 // ----------------------------------------------------------------------------- |
|
4154 // |
|
4155 TBool CHttpDownload::IsExpired() |
|
4156 { |
|
4157 TBool expired = EFalse; |
|
4158 TTime now; |
|
4159 |
|
4160 // Set UTC |
|
4161 now.UniversalTime(); |
|
4162 |
|
4163 if( iMaxAge.Int() ) |
|
4164 { |
|
4165 TTime date( iDate ); |
|
4166 |
|
4167 if( date + iMaxAge < now ) |
|
4168 { |
|
4169 expired = ETrue; |
|
4170 } |
|
4171 } |
|
4172 else if( iExpires.Year() ) |
|
4173 { |
|
4174 TTime expires( iExpires ); |
|
4175 |
|
4176 if( expires < now ) |
|
4177 { |
|
4178 expired = ETrue; |
|
4179 } |
|
4180 } |
|
4181 |
|
4182 return expired; |
|
4183 } |
|
4184 |
|
4185 // ----------------------------------------------------------------------------- |
|
4186 // CHttpDownload::IsContentFileStorageType |
|
4187 // ?implementation_description |
|
4188 // (other items were commented in a header). |
|
4189 // ----------------------------------------------------------------------------- |
|
4190 // |
|
4191 |
|
4192 TBool CHttpDownload::IsContentFileStorageType() |
|
4193 { |
|
4194 |
|
4195 |
|
4196 if( iCodDownload |
|
4197 && iContentType->Compare( KRoapMimeType ) |
|
4198 && iContentType->Compare( KRoapPduMimeType ) |
|
4199 && iContentType->Compare( KFotaPackageDataType) ) |
|
4200 { |
|
4201 return ETrue; |
|
4202 } |
|
4203 |
|
4204 return EFalse; |
|
4205 |
|
4206 } |
|
4207 |
|
4208 // ----------------------------------------------------------------------------- |
|
4209 // CHttpDownload::OnCompletedL |
|
4210 // ?implementation_description |
|
4211 // (other items were commented in a header). |
|
4212 // ----------------------------------------------------------------------------- |
|
4213 // |
|
4214 void CHttpDownload::OnCompletedL() |
|
4215 { |
|
4216 LOGGER_ENTERFN( "OnCompletedL" ); |
|
4217 |
|
4218 if( 1 == iCodDownload ) |
|
4219 { |
|
4220 iCodDownload++; |
|
4221 TriggerEvent( EHttpDlInprogress, EHttpProgCodDescriptorDownloaded ); |
|
4222 TriggerEvent( EHttpDlInprogress, EHttpProgCodDownloadStarted ); |
|
4223 } |
|
4224 else |
|
4225 { |
|
4226 if( !iContTypeRecognitionAvailSent ) |
|
4227 { |
|
4228 CLOG_WRITE( "CHttpDownload::OnCompletedL(): triggering event EHttpResponseForContentType" ); |
|
4229 TriggerEvent( EHttpDlInprogress, EHttpContTypeRecognitionAvail ); |
|
4230 iContTypeRecognitionAvailSent = ETrue; |
|
4231 } |
|
4232 //for correct display of string in download list for COD download we set progress state to moved |
|
4233 if(IsContentFileStorageType()) |
|
4234 { |
|
4235 // Retrieve the file name from the whole paths |
|
4236 HBufC* fileName = iStorage->DestFilename(); |
|
4237 TInt lastSlashPos = fileName->LocateReverse( '\\' ); |
|
4238 if( lastSlashPos == KErrNotFound ) |
|
4239 lastSlashPos = 0; |
|
4240 |
|
4241 HBufC* name = HBufC::NewLC(KMaxFileName); |
|
4242 TPtr namePtr( name->Des() ); |
|
4243 namePtr.Copy( fileName->Right(fileName->Length()-lastSlashPos-1) ); |
|
4244 |
|
4245 TInt findDot = iDlName->LocateReverse( '.' ); |
|
4246 if( findDot == KErrNotFound ) |
|
4247 { |
|
4248 //if Name displayed does not have Extension then |
|
4249 // Remove extention from retrieved name |
|
4250 TInt dotInd = namePtr.LocateReverse( '.' ); |
|
4251 if( dotInd == KErrNotFound ) |
|
4252 dotInd = namePtr.Length(); |
|
4253 namePtr.Copy( namePtr.Left( dotInd ) ); |
|
4254 |
|
4255 } |
|
4256 |
|
4257 //we never get file moved and Download complete for Cod download becuase move is inherent |
|
4258 //to Install() state i.e Download is in progress so display in download list is incorrect. |
|
4259 //related to bug HCHA-753D6G |
|
4260 |
|
4261 if(namePtr.Compare(*iDlName)) |
|
4262 { |
|
4263 ReallocateStringL( iDlName, namePtr, KDownloadNameMaxSize ); |
|
4264 SetDownloadStatus( EHttpProgContentFileMovedAndDestFNChanged, EHttpDlMultipleMOCompleted ); |
|
4265 } |
|
4266 else |
|
4267 { |
|
4268 SetDownloadStatus( EHttpProgContentFileMoved, EHttpDlMultipleMOCompleted ); |
|
4269 } |
|
4270 CleanupStack::PopAndDestroy( name ); |
|
4271 |
|
4272 } |
|
4273 else |
|
4274 { |
|
4275 TriggerEvent( EHttpDlCompleted, EHttpProgNone ); |
|
4276 SetDownloadStatus( EHttpProgNone, EHttpDlMultipleMOCompleted ); |
|
4277 } |
|
4278 } |
|
4279 |
|
4280 ++iDontFireEvent; |
|
4281 |
|
4282 Cancel(); |
|
4283 Disconnect(); |
|
4284 |
|
4285 iStorage->OnComplete(); |
|
4286 |
|
4287 // this is a special case because transaction don't need to be |
|
4288 // canceled, only deleted |
|
4289 iContinueDownload = EFalse; |
|
4290 if( iTransValid ) |
|
4291 { |
|
4292 iTrans.Close(); |
|
4293 iTransValid = EFalse; |
|
4294 } |
|
4295 |
|
4296 --iDontFireEvent; |
|
4297 |
|
4298 TRAP_IGNORE( StoreDownloadInfoL() ); |
|
4299 } |
|
4300 |
|
4301 // ----------------------------------------------------------------------------- |
|
4302 // CHttpDownload::GetParamFromMediaTypeL |
|
4303 // ?implementation_description |
|
4304 // (other items were commented in a header). |
|
4305 // ----------------------------------------------------------------------------- |
|
4306 // |
|
4307 TPtrC8 CHttpDownload::GetParamFromMediaTypeL( const TDesC8& aAttribute ) |
|
4308 { |
|
4309 if( !iMediaType ) |
|
4310 { |
|
4311 User::Leave( KErrNotFound ); |
|
4312 } |
|
4313 TInt length = iMediaType->Length(); |
|
4314 TInt start = iMediaType->Des().FindF( aAttribute ); |
|
4315 start = ( ( start + aAttribute.Length() ) >= length ) ? KErrNotFound : start; |
|
4316 User::LeaveIfError( start ); |
|
4317 start += aAttribute.Length(); |
|
4318 TInt end = iMediaType->Des().Mid( start, length-start ).Locate( KSemiColon ); |
|
4319 TInt boundaryLength = ( KErrNotFound == end ) ? length - start : end; |
|
4320 TPtrC8 ptr = iMediaType->Des().Mid( start, boundaryLength ); |
|
4321 return ptr; |
|
4322 } |
|
4323 |
|
4324 // ----------------------------------------------------------------------------- |
|
4325 // CHttpDownload::ReInitializeDownload |
|
4326 // ?implementation_description |
|
4327 // (other items were commented in a header). |
|
4328 // ----------------------------------------------------------------------------- |
|
4329 // |
|
4330 void CHttpDownload::ReInitializeDownload() |
|
4331 { |
|
4332 LOGGER_ENTERFN( "ReInitializeDownload" ); |
|
4333 |
|
4334 iResponseHeaders->ResetAndDestroy(); |
|
4335 iEntityHeaders->ResetAndDestroy(); |
|
4336 |
|
4337 iStorage->ResetAndDestroy(); |
|
4338 |
|
4339 iLastError = ENoError; |
|
4340 iMaxAge = 0; |
|
4341 iExpires.Set( 0, EJanuary, 1, 0, 0, 0, 0 ); |
|
4342 iDate.Set( 0, EJanuary, 1, 0, 0, 0, 0 ); |
|
4343 |
|
4344 iNoMedia = EFalse; |
|
4345 } |
|
4346 |
|
4347 // ----------------------------------------------------------------------------- |
|
4348 // CHttpDownload::CancelTransaction |
|
4349 // ?implementation_description |
|
4350 // (other items were commented in a header). |
|
4351 // ----------------------------------------------------------------------------- |
|
4352 // |
|
4353 void CHttpDownload::CancelTransaction() |
|
4354 { |
|
4355 LOGGER_ENTERFN( "CancelTransaction" ); |
|
4356 if( iTransValid ) |
|
4357 { |
|
4358 iTrans.Close(); |
|
4359 iTransValid = EFalse; |
|
4360 } |
|
4361 |
|
4362 if( iContinueDownload ) |
|
4363 { |
|
4364 TriggerEvent( EHttpDlCancelTransaction ); |
|
4365 } |
|
4366 |
|
4367 iContinueDownload = EFalse; |
|
4368 |
|
4369 iDlStartedByClient = EFalse; |
|
4370 } |
|
4371 |
|
4372 // ----------------------------------------------------------------------------- |
|
4373 // CHttpDownload::InternalPauseL |
|
4374 // ?implementation_description |
|
4375 // (other items were commented in a header). |
|
4376 // ----------------------------------------------------------------------------- |
|
4377 // |
|
4378 void CHttpDownload::InternalPauseL( TBool aDisconnect ) |
|
4379 { |
|
4380 LOGGER_ENTERFN( "InternalPauseL" ); |
|
4381 |
|
4382 CHttpStorage::TFileCloseOperation closeOp = CHttpStorage::EKeepFile; |
|
4383 if ( !Pausable() && ( iCodDlData && iCodDlData->Count() == 1 ) ) |
|
4384 { |
|
4385 closeOp = CHttpStorage::EReplaceFile; |
|
4386 } |
|
4387 iStorage->CloseDestinationFile( closeOp ); |
|
4388 CancelTransaction(); |
|
4389 |
|
4390 if( aDisconnect ) |
|
4391 { |
|
4392 // Indicate all clients about network loss if the downlolad is not pausable |
|
4393 if(!iPausable) |
|
4394 { |
|
4395 TriggerEvent(EHttpDlNonPausableNetworkLoss); |
|
4396 } |
|
4397 Disconnect(); |
|
4398 } |
|
4399 } |
|
4400 |
|
4401 // ----------------------------------------------------------------------------- |
|
4402 // CHttpDownload::SetDownloadStatus |
|
4403 // ?implementation_description |
|
4404 // (other items were commented in a header). |
|
4405 // ----------------------------------------------------------------------------- |
|
4406 // |
|
4407 void CHttpDownload::SetDownloadStatus( THttpProgressState aProgState, |
|
4408 THttpDownloadState aStatus, |
|
4409 THttpDownloadMgrError aErrorId, |
|
4410 TInt aGlobalErrorId ) |
|
4411 { |
|
4412 #ifdef __DOWNLOADMGR_LOG__ // to filter out EHttpProgResponseBodyReceived |
|
4413 if( aProgState != EHttpProgResponseBodyReceived ) |
|
4414 { |
|
4415 CLOG_WRITE_2( "SetDownloadStatus: %d - %d", aStatus, aProgState ); |
|
4416 } |
|
4417 #endif |
|
4418 |
|
4419 TBool eventTriggered( EFalse ); |
|
4420 |
|
4421 switch( aStatus ) |
|
4422 { |
|
4423 case EHttpDlMultipleMOStarted: |
|
4424 case EHttpDlDeleting: |
|
4425 { |
|
4426 iDlState = aStatus; |
|
4427 iProgState = aProgState; |
|
4428 } |
|
4429 break; |
|
4430 |
|
4431 case EHttpDlFailed: |
|
4432 case EHttpDlMultipleMOCompleted: |
|
4433 case EHttpDlMultipleMOFailed: |
|
4434 { |
|
4435 iDlState = aStatus; |
|
4436 iProgState = aProgState; |
|
4437 iLastError = aErrorId; |
|
4438 iGlobalErrorId = aGlobalErrorId; |
|
4439 } |
|
4440 break; |
|
4441 |
|
4442 case EHttpDlInprogress: |
|
4443 { |
|
4444 iDlState = aStatus; |
|
4445 iProgState = aProgState; |
|
4446 |
|
4447 if( aProgState == EHttpStarted || |
|
4448 aProgState == EHttpProgConnected ) |
|
4449 // in the other progress state there's no need |
|
4450 // to go into RunL() |
|
4451 // Keep it consistente with Runl() |
|
4452 { |
|
4453 SelfComplete(); |
|
4454 } |
|
4455 } |
|
4456 break; |
|
4457 |
|
4458 case EHttpDlPaused: |
|
4459 { |
|
4460 iDlState = aStatus; |
|
4461 iProgState = aProgState; |
|
4462 iLastError = aErrorId; |
|
4463 iGlobalErrorId = aGlobalErrorId; |
|
4464 Cancel(); |
|
4465 } |
|
4466 break; |
|
4467 |
|
4468 case EHttpDlMoved: |
|
4469 case EHttpDlMediaRemoved: |
|
4470 case EHttpDlMediaInserted: |
|
4471 { |
|
4472 TriggerEvent( EHttpDlMoved, EHttpProgNone ); |
|
4473 eventTriggered = ETrue; |
|
4474 } |
|
4475 break; |
|
4476 |
|
4477 default: |
|
4478 { |
|
4479 DMPanic( KErrArgument ); |
|
4480 } |
|
4481 } |
|
4482 |
|
4483 TRAP_IGNORE( StoreDownloadInfoL() ); //saving the state |
|
4484 |
|
4485 if( !eventTriggered ) |
|
4486 { |
|
4487 TriggerEvent( iDlState, iProgState ); |
|
4488 } |
|
4489 } |
|
4490 |
|
4491 // ----------------------------------------------------------------------------- |
|
4492 // CHttpDownload::ResponseHeaderReceivedL |
|
4493 // ?implementation_description |
|
4494 // (other items were commented in a header). |
|
4495 // ----------------------------------------------------------------------------- |
|
4496 // |
|
4497 void CHttpDownload::ResponseHeaderReceivedL() |
|
4498 { |
|
4499 LOGGER_ENTERFN( "ResponseHeaderReceivedL" ); |
|
4500 |
|
4501 RHTTPResponse resp = iTrans.Response(); |
|
4502 iStatusCode = resp.StatusCode(); |
|
4503 |
|
4504 CLOG_WRITE_1( "iStatusCode: %d", iStatusCode ); |
|
4505 |
|
4506 if( iProgState == EHttpContentTypeRequested ) |
|
4507 { |
|
4508 // HEAD method |
|
4509 switch( iStatusCode ) |
|
4510 { |
|
4511 case 200: // OK |
|
4512 case 201: // Created |
|
4513 case 202: // Accepted |
|
4514 case 203: // Non-Authoritative Information |
|
4515 case 204: // No Content |
|
4516 case 205: // Reset Content |
|
4517 { |
|
4518 if( iStorage->ProgressiveDownload() && iStorage->DownloadedSize() ) |
|
4519 // progressive download cannot be resumed this way. |
|
4520 // it's always an error case. |
|
4521 { |
|
4522 OnError( KErrUnknown, EHttpRestartFailed ); |
|
4523 } |
|
4524 else |
|
4525 { |
|
4526 // store response header only after first request |
|
4527 StoreResponseHeaderL(); |
|
4528 ContentTypeReceivedL(); |
|
4529 StoreDownloadInfoL(); |
|
4530 } |
|
4531 } |
|
4532 break; |
|
4533 |
|
4534 case 401: // Unauthorized |
|
4535 { |
|
4536 HttpResponse401L(); |
|
4537 } |
|
4538 break; |
|
4539 |
|
4540 case 407: // Proxy Authentication Required |
|
4541 { |
|
4542 HttpResponse407L(); |
|
4543 } |
|
4544 break; |
|
4545 |
|
4546 case 404: // Not Found |
|
4547 { |
|
4548 OnError( KErrUnknown, EObjectNotFound ); |
|
4549 } |
|
4550 break; |
|
4551 |
|
4552 default: |
|
4553 { |
|
4554 SetDownloadStatus( EHttpProgNone, |
|
4555 EHttpDlFailed, |
|
4556 EHttpUnhandled, |
|
4557 GLOBAL_HTTP_ERROR( iStatusCode ) ); |
|
4558 } |
|
4559 } |
|
4560 } |
|
4561 else |
|
4562 // GET method |
|
4563 { |
|
4564 TBool respOk = EFalse; |
|
4565 |
|
4566 switch( iStatusCode ) |
|
4567 { |
|
4568 case 200: // OK |
|
4569 case 201: // Created |
|
4570 case 202: // Accepted |
|
4571 case 203: // Non-Authoritative Information |
|
4572 case 204: // No Content |
|
4573 case 205: // Reset Content |
|
4574 // full content download |
|
4575 // If ERestartNoIfCompleted comes with 200 and |
|
4576 // iDownloadedSize != 0 it means http server |
|
4577 // doesn't support conditional range download |
|
4578 { |
|
4579 ReInitializeDownload(); |
|
4580 // store response header only after first request |
|
4581 StoreResponseHeaderL(); |
|
4582 iStorage->CreateDestinationFileL(); |
|
4583 StoreDownloadInfoL(); |
|
4584 respOk = ETrue; |
|
4585 } |
|
4586 break; |
|
4587 |
|
4588 case 206: // Partial Content |
|
4589 // partial content download |
|
4590 { |
|
4591 StoreResponseHeaderL(); |
|
4592 iStorage->CreateDestinationFileL(); |
|
4593 |
|
4594 respOk = ETrue; |
|
4595 } |
|
4596 break; |
|
4597 |
|
4598 case 304: // Not Modified |
|
4599 // content is not modified since download paused |
|
4600 { |
|
4601 iStorage->CreateDestinationFileL(); |
|
4602 OnCompletedL(); |
|
4603 } |
|
4604 break; |
|
4605 |
|
4606 case 412: // Precondition Failed |
|
4607 case 416: // content range is wrong. Most probably expired, or modified. |
|
4608 { |
|
4609 if( iRestartAction == ERestartIfExpired || |
|
4610 iRestartAction == ERestartForced ) |
|
4611 { |
|
4612 // Forget a previous redirect |
|
4613 ReallocateStringL( iRedirUrl, *iUrl, KMaxUrlLength ); |
|
4614 ReallocateStringL( iCurrentUrl, *iRedirUrl, KMaxUrlLength ); |
|
4615 iRedirect = EFalse; |
|
4616 |
|
4617 CancelTransaction(); |
|
4618 |
|
4619 ReInitializeDownload(); |
|
4620 |
|
4621 SetDownloadStatus( EHttpStarted ); |
|
4622 } |
|
4623 else |
|
4624 // ERestartNoIfCompleted => content modified since last partial download |
|
4625 { |
|
4626 OnError( KErrUnknown, EPartialContentModified ); |
|
4627 } |
|
4628 } |
|
4629 break; |
|
4630 |
|
4631 case 401: // Unauthorized |
|
4632 // HTTP authentication failed |
|
4633 { |
|
4634 HttpResponse401L(); |
|
4635 } |
|
4636 break; |
|
4637 |
|
4638 case 407: // Proxy Authentication Required |
|
4639 // Proxy authentication failed |
|
4640 { |
|
4641 HttpResponse407L(); |
|
4642 } |
|
4643 break; |
|
4644 |
|
4645 case 404: // Not Found |
|
4646 // Object not found |
|
4647 { |
|
4648 OnError( KErrUnknown, EObjectNotFound ); |
|
4649 } |
|
4650 |
|
4651 default: |
|
4652 { |
|
4653 OnError( GLOBAL_HTTP_ERROR( iStatusCode ), EHttpUnhandled ); |
|
4654 } |
|
4655 } |
|
4656 |
|
4657 if( respOk ) |
|
4658 { |
|
4659 SetDownloadStatus( EHttpProgResponseHeaderReceived ); |
|
4660 } |
|
4661 else |
|
4662 { |
|
4663 CancelTransaction(); |
|
4664 } |
|
4665 } |
|
4666 } |
|
4667 |
|
4668 // ----------------------------------------------------------------------------- |
|
4669 // CHttpDownload::ResponseBodyReceivedL |
|
4670 // ?implementation_description |
|
4671 // (other items were commented in a header). |
|
4672 // ----------------------------------------------------------------------------- |
|
4673 // |
|
4674 void CHttpDownload::ResponseBodyReceivedL( const TDesC8& aBuf ) |
|
4675 { |
|
4676 if( iMultiPart && !iCodDownload ) |
|
4677 { |
|
4678 TBool isSupportedMultiPart( EFalse ); |
|
4679 // If it leaves isSupportedMultiPart remains false -> does not supported! |
|
4680 TRAP_IGNORE( isSupportedMultiPart = IsMultipartSupportedL( aBuf ) ); |
|
4681 if( isSupportedMultiPart ) |
|
4682 { |
|
4683 SetCodFlag( ETrue ); |
|
4684 TriggerEvent( EHttpDlInprogress, EHttpProgSupportedMultiPart ); |
|
4685 } |
|
4686 } |
|
4687 |
|
4688 TBool ret(ETrue); |
|
4689 |
|
4690 if( iStorage->BufferingEnabled() ) |
|
4691 { |
|
4692 // Buffering is enabled, just pass on the data |
|
4693 ret = iStorage->WriteOutNextBodyDataL(aBuf); |
|
4694 } |
|
4695 else |
|
4696 { |
|
4697 // Buffering not yet enabled, see how much data we still have to write without buffering |
|
4698 TInt bytesToWrite = aBuf.Length(); |
|
4699 TInt downloadedSize = iStorage->DownloadedSize(); |
|
4700 |
|
4701 if(bytesToWrite + downloadedSize < KMinDataSizeToSend) |
|
4702 { |
|
4703 // Just dump non-buffered write |
|
4704 ret = iStorage->WriteOutNextBodyDataL( aBuf ); |
|
4705 } |
|
4706 else |
|
4707 { |
|
4708 // Necessary to switch to buffered writing |
|
4709 |
|
4710 TInt leftPartSize = KMinDataSizeToSend - downloadedSize; |
|
4711 TInt rightPartSize = bytesToWrite - leftPartSize; |
|
4712 |
|
4713 TBool ret1 = ETrue; |
|
4714 TBool ret2 = ETrue; |
|
4715 |
|
4716 if(leftPartSize > 0) |
|
4717 { |
|
4718 // Write left side of the block to get alignment matched |
|
4719 ret1 = iStorage->WriteOutNextBodyDataL( aBuf.Left(leftPartSize) ); |
|
4720 } |
|
4721 |
|
4722 // Enable buffering |
|
4723 iStorage->EnableBufferingL(); |
|
4724 |
|
4725 // And push the rest of this data block |
|
4726 if(rightPartSize > 0) |
|
4727 { |
|
4728 ret2 = iStorage->WriteOutNextBodyDataL( aBuf.Right(rightPartSize) ); |
|
4729 } |
|
4730 |
|
4731 if(!ret1 || !ret2) |
|
4732 { |
|
4733 ret = EFalse; |
|
4734 } |
|
4735 } |
|
4736 } |
|
4737 |
|
4738 if( !ret ) |
|
4739 { |
|
4740 StoreDownloadInfoL(); |
|
4741 } |
|
4742 |
|
4743 if( !iContTypeRecognitionAvailSent && (iStorage->DownloadedSize() >= KRespSizeForRecognition) ) |
|
4744 { |
|
4745 TriggerEvent( EHttpDlInprogress, EHttpContTypeRecognitionAvail ); |
|
4746 iContTypeRecognitionAvailSent = ETrue; |
|
4747 } |
|
4748 |
|
4749 TriggerEvent( EHttpDlInprogress, EHttpProgResponseBodyReceived ); |
|
4750 } |
|
4751 |
|
4752 // ----------------------------------------------------------------------------- |
|
4753 // CHttpDownload::IsMultipartSupportedL |
|
4754 // ?implementation_description |
|
4755 // (other items were commented in a header). |
|
4756 // ----------------------------------------------------------------------------- |
|
4757 // |
|
4758 TBool CHttpDownload::IsMultipartSupportedL( const TDesC8& aBuf ) |
|
4759 { |
|
4760 TBool ret( EFalse ); |
|
4761 |
|
4762 if( !iHeaderOfMultipart ) |
|
4763 { |
|
4764 iHeaderOfMultipart = HBufC8::NewL( KMaxHeaderOfMultipart ); |
|
4765 } |
|
4766 TInt full_length = iHeaderOfMultipart->Length() + aBuf.Length(); |
|
4767 if( KMaxHeaderOfMultipart >= full_length ) |
|
4768 { |
|
4769 iHeaderOfMultipart->Des().Append( aBuf ); |
|
4770 } |
|
4771 else |
|
4772 { |
|
4773 ret = EFalse; |
|
4774 return ret; |
|
4775 } |
|
4776 |
|
4777 TInt pos = iHeaderOfMultipart->Des().Find( KContentType() ); |
|
4778 |
|
4779 User::LeaveIfError( pos ); |
|
4780 |
|
4781 pos = pos + KContentType().Length(); |
|
4782 |
|
4783 TPtrC8 p = iHeaderOfMultipart->Des().Mid( pos ); |
|
4784 TInt temp = p.Find( KDoubleEOL() ); |
|
4785 |
|
4786 TInt posEol = pos + temp; |
|
4787 |
|
4788 TPtrC8 ptr = iHeaderOfMultipart->Des().Mid( pos, ( posEol - pos ) ); |
|
4789 if( 0 == ptr.Find( KDdMimeType() ) || |
|
4790 0 == ptr.Find( KDd2MimeType() ) || |
|
4791 0 == ptr.Find( KCodMimeType() )) |
|
4792 { |
|
4793 ret = ETrue; |
|
4794 delete iHeaderOfMultipart; |
|
4795 iHeaderOfMultipart = NULL; |
|
4796 return ret; |
|
4797 } |
|
4798 |
|
4799 return ret; |
|
4800 } |
|
4801 |
|
4802 // ----------------------------------------------------------------------------- |
|
4803 // CHttpDownload::Connect |
|
4804 // ?implementation_description |
|
4805 // (other items were commented in a header). |
|
4806 // ----------------------------------------------------------------------------- |
|
4807 // |
|
4808 void CHttpDownload::Connect() |
|
4809 { |
|
4810 LOGGER_ENTERFN( "ConnectL" ); |
|
4811 |
|
4812 SetDownloadStatus( EHttpProgCreatingConnection ); |
|
4813 |
|
4814 if( iConnHandler->IsConnected() ) |
|
4815 // we already have connection. Just use it. |
|
4816 { |
|
4817 Connected(); |
|
4818 } |
|
4819 else |
|
4820 // No connection |
|
4821 { |
|
4822 if( iClAppInstance && iClAppInstance->AutoConnect() ) |
|
4823 // Connection w/o question |
|
4824 { |
|
4825 TRAPD( err, iConnHandler->ConnectL() ); |
|
4826 |
|
4827 if( err ) |
|
4828 { |
|
4829 OnError( err, EConnectionFailed ); |
|
4830 } |
|
4831 } |
|
4832 else |
|
4833 // ask before connect |
|
4834 { |
|
4835 TriggerEvent( EHttpDlInprogress, EHttpProgConnectionNeeded ); |
|
4836 } |
|
4837 } |
|
4838 } |
|
4839 |
|
4840 // ----------------------------------------------------------------------------- |
|
4841 // CHttpDownload::Disconnect |
|
4842 // ?implementation_description |
|
4843 // (other items were commented in a header). |
|
4844 // ----------------------------------------------------------------------------- |
|
4845 // |
|
4846 void CHttpDownload::Disconnect() |
|
4847 { |
|
4848 LOGGER_ENTERFN( "Disconnect" ); |
|
4849 |
|
4850 if( iConnHandler ) |
|
4851 { |
|
4852 TriggerEvent( iDlState, EHttpProgDisconnected ); |
|
4853 // iConnHandler is set NULL from Disconnect() |
|
4854 iConnHandler->Disconnect( EFalse, this ); |
|
4855 |
|
4856 iConnHandler = NULL; |
|
4857 } |
|
4858 } |
|
4859 |
|
4860 // ----------------------------------------------------------------------------- |
|
4861 // CHttpDownload::SetRequestHeaderL |
|
4862 // ?implementation_description |
|
4863 // (other items were commented in a header). |
|
4864 // ----------------------------------------------------------------------------- |
|
4865 // |
|
4866 void CHttpDownload::SetRequestHeaderL( RStringPool& aStringPool, |
|
4867 RHTTPHeaders& aHeaders, |
|
4868 TBool aHeadMethod ) |
|
4869 { |
|
4870 LOGGER_ENTERFN( "SetRequestHeaderL" ); |
|
4871 |
|
4872 // Set default Accept header |
|
4873 aHeaders.SetRawFieldL( aStringPool.StringF(HTTP::EAccept, RHTTPSession::GetTable()), |
|
4874 KDefaultAcceptHeader(), |
|
4875 KHttpFieldSeparator ); |
|
4876 |
|
4877 SetRequestHeaderAddOnL( aStringPool, aHeaders ); |
|
4878 SetCredentialsInfoL( aStringPool ); |
|
4879 |
|
4880 // Find ETag in response header |
|
4881 RStringF etag = aStringPool.StringF(HTTP::EETag, |
|
4882 RHTTPSession::GetTable()); |
|
4883 TInt fieldInd = FindHeaderField( iResponseHeaders, etag.DesC() ); |
|
4884 if( fieldInd != KErrNotFound ) |
|
4885 // ETag is known. ETag identifies the content. Set If-Match to see |
|
4886 // that if it's changed, or a redirection goes to another url. |
|
4887 // Server will respond with 412 on error. |
|
4888 { |
|
4889 RStringF ifMatch = aStringPool.StringF(HTTP::EIfMatch, |
|
4890 RHTTPSession::GetTable()); |
|
4891 aHeaders.RemoveField( ifMatch ); |
|
4892 aHeaders.SetRawFieldL( ifMatch, |
|
4893 *(*iResponseHeaders)[fieldInd]->FieldRawData(), |
|
4894 KHttpFieldSeparator ); |
|
4895 CLOG_WRITE8_1( "ETag: %S", (*iResponseHeaders)[fieldInd]->FieldRawData() ); |
|
4896 } |
|
4897 |
|
4898 if( aHeadMethod ) |
|
4899 // HEAD method doesn't require any other field to be set |
|
4900 { |
|
4901 return; |
|
4902 } |
|
4903 |
|
4904 CLOG_WRITE_1( "Down: %d", iStorage->DownloadedSize() ); |
|
4905 CLOG_WRITE_1( "Length: %d", iStorage->Length() ); |
|
4906 |
|
4907 if( iRestartAction == ERestartNoIfCompleted ) |
|
4908 { |
|
4909 CLOG_WRITE( "ERestartNoIfCompleted" ); |
|
4910 |
|
4911 SetRangeFieldL( aStringPool, aHeaders ); |
|
4912 |
|
4913 RStringF field; |
|
4914 |
|
4915 if( iStorage->DownloadedSize() != iStorage->Length() ) |
|
4916 // download from previous point only if the content is unmodified |
|
4917 { |
|
4918 field = aStringPool.StringF(HTTP::EIfUnmodifiedSince, |
|
4919 RHTTPSession::GetTable()); |
|
4920 |
|
4921 SetExpireToFieldL( field, aStringPool, aHeaders ); |
|
4922 } |
|
4923 } |
|
4924 else if( iRestartAction == ERestartIfExpired ) |
|
4925 // Expire and max-age is already checked in StartL |
|
4926 // nothing to do if response is 304 |
|
4927 { |
|
4928 CLOG_WRITE( "ERestartIfExpired" ); |
|
4929 |
|
4930 RStringF field; |
|
4931 |
|
4932 if( iStorage->DownloadedSize() != iStorage->Length() ) |
|
4933 // we don't have the entire content |
|
4934 // start from where we stopped before |
|
4935 { |
|
4936 SetRangeFieldL( aStringPool, aHeaders ); |
|
4937 // download entire content if expired |
|
4938 field = aStringPool.StringF(HTTP::EIfRange, RHTTPSession::GetTable()); |
|
4939 } |
|
4940 else |
|
4941 // we have the entire content. Check that content is modified |
|
4942 // since it's downloaded, or wait for response 304. |
|
4943 { |
|
4944 field = aStringPool.StringF(HTTP::EIfModifiedSince, RHTTPSession::GetTable()); |
|
4945 } |
|
4946 |
|
4947 SetExpireToFieldL( field, aStringPool, aHeaders ); |
|
4948 } |
|
4949 } |
|
4950 |
|
4951 // ----------------------------------------------------------------------------- |
|
4952 // CHttpDownload::DisablePipeliningL |
|
4953 // ?implementation_description |
|
4954 // (other items were commented in a header). |
|
4955 // ----------------------------------------------------------------------------- |
|
4956 // |
|
4957 void CHttpDownload::DisablePipeliningL( RStringPool& aStringPool ) |
|
4958 { |
|
4959 LOGGER_ENTERFN( "DisablePipeliningL" ); |
|
4960 |
|
4961 RStringF pipeline = aStringPool.StringF(HTTP::EHttpPipelining, RHTTPSession::GetTable()); |
|
4962 RStringF disable = aStringPool.StringF(HTTP::EDisablePipelining, RHTTPSession::GetTable()); |
|
4963 |
|
4964 iTrans.PropertySet().SetPropertyL(pipeline, disable); |
|
4965 } |
|
4966 |
|
4967 // ----------------------------------------------------------------------------- |
|
4968 // CHttpFilterAuthentication::SetPropertyL |
|
4969 // Set property of the transaction |
|
4970 // ----------------------------------------------------------------------------- |
|
4971 // |
|
4972 void CHttpDownload::SetPropertyL( RStringPool& aStringPool, |
|
4973 RStringF aPropertyName, |
|
4974 const TDesC8& aToken ) |
|
4975 { |
|
4976 RString tokenStr = aStringPool.OpenStringL( aToken ); |
|
4977 THTTPHdrVal tokenVal = tokenStr; |
|
4978 CleanupClosePushL( tokenStr ); |
|
4979 iTrans.PropertySet().RemoveProperty( aPropertyName ); |
|
4980 iTrans.PropertySet().SetPropertyL( aPropertyName, tokenVal ); |
|
4981 |
|
4982 CLOG_WRITE8_2( "SetPropertyL: %S - %S", &aPropertyName.DesC(), &aToken ); |
|
4983 |
|
4984 CleanupStack::PopAndDestroy(); // tokenStr |
|
4985 } |
|
4986 |
|
4987 // ----------------------------------------------------------------------------- |
|
4988 // CHttpFilterAuthentication::SetPropertyL |
|
4989 // Set property of the transaction |
|
4990 // ----------------------------------------------------------------------------- |
|
4991 // |
|
4992 void CHttpDownload::SetPropertyL( RStringF aPropertyName, |
|
4993 const TInt aValue ) |
|
4994 { |
|
4995 THTTPHdrVal tokenVal = aValue; |
|
4996 |
|
4997 iTrans.PropertySet().RemoveProperty( aPropertyName ); |
|
4998 iTrans.PropertySet().SetPropertyL( aPropertyName, tokenVal ); |
|
4999 |
|
5000 CLOG_WRITE8_2( "SetPropertyL: %S - %d", &aPropertyName.DesC(), aValue ); |
|
5001 } |
|
5002 |
|
5003 // ----------------------------------------------------------------------------- |
|
5004 // CHttpFilterAuthentication::SetRequestHeaderAddOnL |
|
5005 // Set property of the transaction |
|
5006 // ----------------------------------------------------------------------------- |
|
5007 // |
|
5008 void CHttpDownload::SetRequestHeaderAddOnL( RStringPool& aStringPool, |
|
5009 RHTTPHeaders& aHeaders ) |
|
5010 { |
|
5011 if( !iRequestHeaders->Count() ) |
|
5012 { |
|
5013 return; |
|
5014 } |
|
5015 |
|
5016 TPtrC8 fieldName; |
|
5017 TPtrC8 fieldValue; |
|
5018 RStringF fieldNameStr; |
|
5019 THTTPHdrVal value; |
|
5020 |
|
5021 for( TInt i = 0; i < iRequestHeaders->Count(); ++i ) |
|
5022 { |
|
5023 CLOG_WRITE8_3( "Req(%d): %S: %S", i, (*iRequestHeaders)[i]->FieldName(), (*iRequestHeaders)[i]->FieldRawData() ); |
|
5024 |
|
5025 fieldNameStr = aStringPool.OpenFStringL( *(*iRequestHeaders)[i]->FieldName() ); |
|
5026 CleanupClosePushL( fieldNameStr ); |
|
5027 |
|
5028 // aHeaders.RemoveField( fieldNameStr ); |
|
5029 if (fieldNameStr == aStringPool.StringF(HTTP::EIfModifiedSince, RHTTPSession::GetTable()) || |
|
5030 fieldNameStr == aStringPool.StringF(HTTP::EIfUnmodifiedSince, RHTTPSession::GetTable())) |
|
5031 { |
|
5032 TInternetDate date; |
|
5033 date.SetDateL(*(*iRequestHeaders)[i]->FieldRawData()); |
|
5034 TDateTime modifyTime(date.DateTime()); |
|
5035 aHeaders.SetFieldL(fieldNameStr, modifyTime); |
|
5036 CleanupStack::PopAndDestroy(); // fieldNameStr |
|
5037 } |
|
5038 else |
|
5039 { |
|
5040 RStringF valueStr = aStringPool.OpenFStringL( *(*iRequestHeaders)[i]->FieldRawData() ); |
|
5041 value.SetStrF( valueStr ); |
|
5042 CleanupClosePushL( valueStr ); |
|
5043 |
|
5044 aHeaders.SetFieldL( fieldNameStr, valueStr ); |
|
5045 |
|
5046 CleanupStack::PopAndDestroy( 2 ); // valueStr, fieldNameStr |
|
5047 } |
|
5048 } |
|
5049 } |
|
5050 |
|
5051 // ----------------------------------------------------------------------------- |
|
5052 // CHttpDownload::SetCredentialsInfoL |
|
5053 // ?implementation_description |
|
5054 // (other items were commented in a header). |
|
5055 // ----------------------------------------------------------------------------- |
|
5056 // |
|
5057 void CHttpDownload::SetCredentialsInfoL( RStringPool& aStringPool ) |
|
5058 { |
|
5059 LOGGER_ENTERFN( "SetCredentialsInfoL" ); |
|
5060 |
|
5061 if( iHttpUsername ) |
|
5062 { |
|
5063 RStringF username = aStringPool.StringF( HTTP::EUsername, |
|
5064 RHTTPSession::GetTable() ); |
|
5065 |
|
5066 SetPropertyL( aStringPool, username, *iHttpUsername ); |
|
5067 } |
|
5068 |
|
5069 if( iHttpPassword ) |
|
5070 { |
|
5071 RStringF password = aStringPool.StringF( HTTP::EPassword, |
|
5072 RHTTPSession::GetTable() ); |
|
5073 |
|
5074 SetPropertyL( aStringPool, password, *iHttpPassword ); |
|
5075 } |
|
5076 |
|
5077 if( iHttpRealm ) |
|
5078 { |
|
5079 RStringF realm = aStringPool.StringF( HTTP::ERealm, |
|
5080 RHTTPSession::GetTable() ); |
|
5081 SetPropertyL( aStringPool, realm, *iHttpRealm ); |
|
5082 } |
|
5083 |
|
5084 if( iHttpProxyRealm ) |
|
5085 { |
|
5086 RStringF proxyRealmStr = aStringPool.StringF( |
|
5087 HttpFilterCommonStringsExt::EProxyRealm, |
|
5088 HttpFilterCommonStringsExt::GetTable() ); |
|
5089 SetPropertyL( aStringPool, proxyRealmStr, *iHttpProxyRealm ); |
|
5090 } |
|
5091 |
|
5092 if( iHttpProxyUsername ) |
|
5093 { |
|
5094 RStringF proxyUsernameStr = aStringPool.StringF( |
|
5095 HttpFilterCommonStringsExt::EProxyUsername, |
|
5096 HttpFilterCommonStringsExt::GetTable() ); |
|
5097 SetPropertyL( aStringPool, proxyUsernameStr, *iHttpProxyUsername ); |
|
5098 } |
|
5099 |
|
5100 if( iHttpProxyPassword ) |
|
5101 { |
|
5102 RStringF proxyPasswordStr = aStringPool.StringF( |
|
5103 HttpFilterCommonStringsExt::EProxyPassword, |
|
5104 HttpFilterCommonStringsExt::GetTable() ); |
|
5105 SetPropertyL( aStringPool, proxyPasswordStr, *iHttpProxyPassword ); |
|
5106 } |
|
5107 |
|
5108 if( iHttpNonce ) |
|
5109 { |
|
5110 RStringF nonce = aStringPool.StringF( HTTP::ENonce, |
|
5111 RHTTPSession::GetTable() ); |
|
5112 |
|
5113 SetPropertyL( aStringPool, nonce, *iHttpNonce ); |
|
5114 } |
|
5115 } |
|
5116 |
|
5117 // ----------------------------------------------------------------------------- |
|
5118 // CHttpDownload::SetRangeFieldL |
|
5119 // ?implementation_description |
|
5120 // (other items were commented in a header). |
|
5121 // ----------------------------------------------------------------------------- |
|
5122 // |
|
5123 void CHttpDownload::SetRangeFieldL( RStringPool& aStringPool, |
|
5124 RHTTPHeaders& aHeaders ) |
|
5125 { |
|
5126 LOGGER_ENTERFN( "SetRangeFieldL" ); |
|
5127 |
|
5128 if( iStorage->DownloadedSize() == 0 ) |
|
5129 // no bytes have been downloaded yet |
|
5130 { |
|
5131 return; |
|
5132 } |
|
5133 |
|
5134 RStringF range = aStringPool.StringF(HTTP::ERange, RHTTPSession::GetTable()); |
|
5135 |
|
5136 aHeaders.RemoveField( range ); |
|
5137 |
|
5138 TBuf8<48> rawData; |
|
5139 |
|
5140 rawData.Format( _L8("bytes=%d-"), iStorage->DownloadedSize() ); |
|
5141 |
|
5142 CLOG_WRITE8_1( "Range: %S", &rawData ); |
|
5143 aHeaders.SetRawFieldL( range, rawData, KHttpFieldSeparator ); |
|
5144 } |
|
5145 |
|
5146 // ----------------------------------------------------------------------------- |
|
5147 // CHttpDownload::SetExpireToFieldL |
|
5148 // ?implementation_description |
|
5149 // (other items were commented in a header). |
|
5150 // ----------------------------------------------------------------------------- |
|
5151 // |
|
5152 void CHttpDownload::SetExpireToFieldL( RStringF& aField, |
|
5153 RStringPool& aStringPool, |
|
5154 RHTTPHeaders& aHeaders ) |
|
5155 { |
|
5156 LOGGER_ENTERFN( "SetExpireToFieldL" ); |
|
5157 |
|
5158 RStringF expires = aStringPool.StringF(HTTP::EExpires, RHTTPSession::GetTable()); |
|
5159 RStringF lastModified = aStringPool.StringF(HTTP::ELastModified, RHTTPSession::GetTable()); |
|
5160 |
|
5161 TInt expInd( KErrNotFound ); |
|
5162 TInt modInd( KErrNotFound ); |
|
5163 |
|
5164 for( TInt i = 0; i < iResponseHeaders->Count(); ++i ) |
|
5165 // FindHeaderField, because this is double search for fieldnames |
|
5166 { |
|
5167 if( *(*iResponseHeaders)[i]->FieldName() == expires.DesC() ) |
|
5168 { |
|
5169 expInd = i; |
|
5170 continue; |
|
5171 } |
|
5172 if( *(*iResponseHeaders)[i]->FieldName() == lastModified.DesC() ) |
|
5173 { |
|
5174 modInd = i; |
|
5175 continue; |
|
5176 } |
|
5177 } |
|
5178 |
|
5179 if( expInd != KErrNotFound ) |
|
5180 { |
|
5181 CLOG_WRITE8_1( "Expire: %S", (*iResponseHeaders)[expInd]->FieldRawData() ); |
|
5182 |
|
5183 aHeaders.RemoveField( aField ); |
|
5184 aHeaders.SetRawFieldL( aField, |
|
5185 *(*iResponseHeaders)[expInd]->FieldRawData(), |
|
5186 KHttpFieldSeparator ); |
|
5187 } |
|
5188 else if( modInd != KErrNotFound ) |
|
5189 { |
|
5190 CLOG_WRITE8_1( "LastMod: %S", (*iResponseHeaders)[modInd]->FieldRawData() ); |
|
5191 |
|
5192 aHeaders.RemoveField( aField ); |
|
5193 aHeaders.SetRawFieldL( aField, |
|
5194 *(*iResponseHeaders)[modInd]->FieldRawData(), |
|
5195 KHttpFieldSeparator ); |
|
5196 } |
|
5197 } |
|
5198 |
|
5199 // ----------------------------------------------------------------------------- |
|
5200 // CHttpDownload::ParseRequestedUrlL |
|
5201 // ?implementation_description |
|
5202 // (other items were commented in a header). |
|
5203 // ----------------------------------------------------------------------------- |
|
5204 // |
|
5205 void CHttpDownload::ParseRequestedUrlL() |
|
5206 { |
|
5207 LOGGER_ENTERFN( "ParseRequestedUrlL" ); |
|
5208 |
|
5209 __ASSERT_DEBUG( iUrl->Length(), DMPanic( KErrArgument ) ); |
|
5210 |
|
5211 TUriParser8 uri; |
|
5212 uri.Parse( *iUrl ); |
|
5213 |
|
5214 TPtrC8 scheme( uri.Extract( EUriScheme ) ); |
|
5215 |
|
5216 if( scheme != KHttpScheme && |
|
5217 scheme != KHttpsScheme ) |
|
5218 // unsupported or no scheme in url. |
|
5219 // Insert 'http://' to the beginning of it. |
|
5220 { |
|
5221 HBufC8* tempBuf = HBufC8::NewL( KHttpScheme().Length() + |
|
5222 KSchemeAddon().Length() + |
|
5223 iUrl->Length() ); |
|
5224 |
|
5225 tempBuf->Des().Append( KHttpScheme ); |
|
5226 tempBuf->Des().Append( KSchemeAddon ); |
|
5227 tempBuf->Des().Append( *iUrl ); |
|
5228 |
|
5229 delete iUrl; iUrl = NULL; |
|
5230 |
|
5231 iUrl = tempBuf; |
|
5232 |
|
5233 uri.Parse( *iUrl ); |
|
5234 } |
|
5235 |
|
5236 CUri8* url = CUri8::NewLC(); |
|
5237 |
|
5238 url->SetComponentL( uri.Extract( EUriScheme ), EUriScheme ); |
|
5239 url->SetComponentL( uri.Extract( EUriHost ), EUriHost ); |
|
5240 url->SetComponentL( uri.Extract( EUriPath ), EUriPath ); |
|
5241 url->SetComponentL( uri.Extract( EUriUserinfo ), EUriUserinfo ); |
|
5242 url->SetComponentL( uri.Extract( EUriQuery ), EUriQuery ); |
|
5243 url->SetComponentL( uri.Extract( EUriFragment ), EUriFragment ); |
|
5244 |
|
5245 if( uri.IsPresent( EUriPort ) ) |
|
5246 { |
|
5247 url->SetComponentL( uri.Extract( EUriPort ), EUriPort ); |
|
5248 } |
|
5249 else |
|
5250 { |
|
5251 if( iPort != KDefaultPort ) |
|
5252 { |
|
5253 TBuf8<10> port; |
|
5254 |
|
5255 port.Format( _L8("%d"), iPort ); |
|
5256 |
|
5257 url->SetComponentL( port, EUriPort ); |
|
5258 } |
|
5259 } |
|
5260 |
|
5261 CLOG_WRITE8_1( "Parsed URL: %S", &url->Uri().UriDes() ); |
|
5262 |
|
5263 // Initially they are the same |
|
5264 ReallocateStringL( iRedirUrl, url->Uri().UriDes(), KMaxUrlLength ); |
|
5265 ReallocateStringL( iCurrentUrl, url->Uri().UriDes() , KMaxUrlLength); |
|
5266 |
|
5267 CleanupStack::PopAndDestroy( url ); |
|
5268 } |
|
5269 |
|
5270 // ----------------------------------------------------------------------------- |
|
5271 // CHttpDownload::ParseDownloadNameL |
|
5272 // ?implementation_description |
|
5273 // (other items were commented in a header). |
|
5274 // ----------------------------------------------------------------------------- |
|
5275 // |
|
5276 void CHttpDownload::ParseDownloadNameL() |
|
5277 { |
|
5278 LOGGER_ENTERFN( "ParseDownloadNameL" ); |
|
5279 |
|
5280 // Calculate the download name from the requested URL |
|
5281 HBufC8* parsedUrl = EscapeUtils::EscapeDecodeL( *iCurrentUrl ); |
|
5282 CleanupStack::PushL( parsedUrl ); |
|
5283 |
|
5284 TUriParser8 uri; |
|
5285 uri.Parse( *parsedUrl ); |
|
5286 |
|
5287 TPtrC8 path; |
|
5288 |
|
5289 path.Set( uri.Extract( EUriPath ) ); |
|
5290 |
|
5291 HBufC* newDlName = HBufC::NewLC( KDownloadNameMaxSize ); |
|
5292 TPtr newDlNamePtr = newDlName->Des(); |
|
5293 |
|
5294 // Here we don't have to deal with that iDlName is longer than KMaxPath |
|
5295 // ConvertDownloadNameUniqueL() will make the correction |
|
5296 if( path.Length() ) |
|
5297 // there's path in the url |
|
5298 { |
|
5299 TInt slash = path.LocateReverse( '/' ); |
|
5300 |
|
5301 if( slash == KErrNotFound ) |
|
5302 { |
|
5303 slash = path.LocateReverse( '\\' ); |
|
5304 } |
|
5305 |
|
5306 if( slash != KErrNotFound && slash != path.Length() ) |
|
5307 // from the last slash this is the filename |
|
5308 { |
|
5309 TPtrC8 temp( path.Right( path.Length() - slash - 1 ) ); |
|
5310 |
|
5311 if( temp.Length() ) |
|
5312 { |
|
5313 HBufC *tempstr = EscapeUtils::ConvertToUnicodeFromUtf8L(temp.Left( KDownloadNameMaxSize )); |
|
5314 newDlNamePtr.Copy(*tempstr); |
|
5315 delete tempstr; |
|
5316 } |
|
5317 else |
|
5318 // empty path -> default filename is the host |
|
5319 // filename is KDefDestFilename |
|
5320 { |
|
5321 newDlNamePtr.Copy( KDefDestFilename ); |
|
5322 } |
|
5323 } |
|
5324 else |
|
5325 // no slash -> entire path is the filename |
|
5326 { |
|
5327 HBufC *tempstr = EscapeUtils::ConvertToUnicodeFromUtf8L(path.Left( KDownloadNameMaxSize )); |
|
5328 newDlNamePtr.Copy(*tempstr); |
|
5329 delete tempstr; |
|
5330 } |
|
5331 } |
|
5332 else |
|
5333 // no path -> default filename is the host |
|
5334 // filename is KDefDestFilename |
|
5335 { |
|
5336 newDlNamePtr.Copy( KDefDestFilename ); |
|
5337 } |
|
5338 |
|
5339 SetDownloadNameL( newDlNamePtr ); |
|
5340 CleanupStack::PopAndDestroy( newDlName ); |
|
5341 CleanupStack::PopAndDestroy( parsedUrl ); |
|
5342 |
|
5343 CLOG_WRITE_1( "Name: %S", iDlName ); |
|
5344 } |
|
5345 |
|
5346 // ----------------------------------------------------------------------------- |
|
5347 // CHttpDownload::StoreResponseHeaderL |
|
5348 // ?implementation_description |
|
5349 // (other items were commented in a header). |
|
5350 // ----------------------------------------------------------------------------- |
|
5351 // |
|
5352 void CHttpDownload::StoreResponseHeaderL() |
|
5353 { |
|
5354 LOGGER_ENTERFN( "StoreResponseHeaderL" ); |
|
5355 |
|
5356 TPtrC8 rawData; |
|
5357 RStringPool strPool = iConnHandler->Session().StringPool(); |
|
5358 RHTTPHeaders headers( iTrans.Response().GetHeaderCollection() ); |
|
5359 THTTPHdrFieldIter it = headers.Fields(); |
|
5360 |
|
5361 // forget the previous headers |
|
5362 iResponseHeaders->ResetAndDestroy(); |
|
5363 iEntityHeaders->ResetAndDestroy(); |
|
5364 |
|
5365 CLOG_WRITE( "Received response header:" ); |
|
5366 while ( !it.AtEnd() ) |
|
5367 { |
|
5368 RStringTokenF fieldName = it(); |
|
5369 RStringF fieldNameStr = strPool.StringF (fieldName ); |
|
5370 |
|
5371 headers.GetRawField( fieldNameStr, rawData ); |
|
5372 |
|
5373 CHeaderField* field = CHeaderField::NewL( &fieldNameStr.DesC(), &rawData ); |
|
5374 CleanupStack::PushL( field ); |
|
5375 |
|
5376 CLOG_WRITE8_2("%S:%S", &fieldNameStr.DesC(), &rawData); |
|
5377 iResponseHeaders->AppendL( field ); |
|
5378 |
|
5379 CleanupStack::Pop( field ); |
|
5380 |
|
5381 CHeaderField* entityField = CHeaderField::NewL( &fieldNameStr.DesC(), &rawData ); |
|
5382 CleanupStack::PushL( entityField ); |
|
5383 |
|
5384 CLOG_WRITE8_2("%S:%S", &fieldNameStr.DesC(), &rawData); |
|
5385 iEntityHeaders->AppendL( entityField ); |
|
5386 |
|
5387 CleanupStack::Pop( entityField ); |
|
5388 |
|
5389 ++it; |
|
5390 } |
|
5391 |
|
5392 ParseContentTypeL( strPool ); |
|
5393 |
|
5394 ParseContentDispositionL( strPool); |
|
5395 if (!iCodDownload) |
|
5396 { |
|
5397 if (iUseAttachmentFileName || iUseInlineFileName) |
|
5398 { |
|
5399 SetDownloadNameL( *iAttachmentFileName ); |
|
5400 } |
|
5401 } |
|
5402 |
|
5403 RStringF length = strPool.StringF(HTTP::EContentLength,RHTTPSession::GetTable()); |
|
5404 RStringF date = strPool.StringF(HTTP::EDate,RHTTPSession::GetTable()); |
|
5405 RStringF expires = strPool.StringF(HTTP::EExpires,RHTTPSession::GetTable()); |
|
5406 RStringF maxAge = strPool.StringF(HTTP::EMaxAge,RHTTPSession::GetTable()); |
|
5407 RStringF cacheControl = strPool.StringF(HTTP::ECacheControl,RHTTPSession::GetTable()); |
|
5408 THTTPHdrVal value; |
|
5409 |
|
5410 if( !headers.GetField( length, 0, value ) ) |
|
5411 { |
|
5412 if( iStorage->Length() == KDefaultContentLength ) |
|
5413 // content size is |
|
5414 { |
|
5415 iStorage->SetLength( value ); |
|
5416 } |
|
5417 else |
|
5418 //This is a partial response as Length is already set so save this new length as partial Length that needs to be Downloaded. |
|
5419 { |
|
5420 iStorage->SetPartialContentLength( value ); |
|
5421 } |
|
5422 } |
|
5423 |
|
5424 CheckRealDRMContentType(); |
|
5425 if( !iDrmContentLengthValid ) |
|
5426 // Content was original encoded -> we don't know the actual content size. |
|
5427 { |
|
5428 iStorage->SetLength( KDefaultContentLength ); |
|
5429 } |
|
5430 |
|
5431 |
|
5432 iMaxAge = 0; |
|
5433 TInt parts( 0 ); |
|
5434 // this leave is trapped because we can still go on |
|
5435 TRAPD( err, parts = headers.FieldPartsL( cacheControl ) ); |
|
5436 |
|
5437 if( !err ) |
|
5438 // try to find max-age in Cache-control field |
|
5439 { |
|
5440 for( TInt i = 0; i < parts; ++i ) |
|
5441 { |
|
5442 RStringF directive; |
|
5443 THTTPHdrVal hdrVal; |
|
5444 TInt err; |
|
5445 |
|
5446 // Get the cache-control from the headers |
|
5447 // initialise the fieldname |
|
5448 headers.GetField( cacheControl, i, hdrVal ); |
|
5449 |
|
5450 if((hdrVal.Type() == THTTPHdrVal::KStrVal) || (hdrVal.Type() == THTTPHdrVal::KStrFVal)) |
|
5451 { |
|
5452 RStringF cacheDir = hdrVal.StrF(); |
|
5453 |
|
5454 TInt endPos; |
|
5455 _LIT8(KFind, "="); |
|
5456 |
|
5457 endPos = cacheDir.DesC().Find( KFind ); |
|
5458 if( endPos != -1 ) |
|
5459 { |
|
5460 TRAP(err, directive = strPool.OpenFStringL(cacheDir.DesC().Left(endPos))); |
|
5461 if( !err ) |
|
5462 { |
|
5463 if( directive == maxAge ) |
|
5464 { |
|
5465 TInt valueInt( 0 ); |
|
5466 TLex8 value( cacheDir.DesC().Right(cacheDir.DesC().Length() - endPos - 1) ); |
|
5467 |
|
5468 value.Val( valueInt ); |
|
5469 iMaxAge = valueInt; |
|
5470 } |
|
5471 } |
|
5472 } |
|
5473 } |
|
5474 } |
|
5475 } |
|
5476 |
|
5477 if( !headers.GetField( expires, 0, value ) ) |
|
5478 { |
|
5479 iExpires = value; |
|
5480 } |
|
5481 else |
|
5482 { |
|
5483 iExpires.SetYear( 0 ); |
|
5484 } |
|
5485 |
|
5486 if( !headers.GetField( date, 0, value ) ) |
|
5487 { |
|
5488 iDate = value; |
|
5489 } |
|
5490 else |
|
5491 { |
|
5492 iDate.SetYear( 0 ); |
|
5493 } |
|
5494 |
|
5495 UpdatePausable(); |
|
5496 } |
|
5497 |
|
5498 // ----------------------------------------------------------------------------- |
|
5499 // CHttpDownload::CheckRealDRMContentType |
|
5500 // ?implementation_description |
|
5501 // (other items were commented in a header). |
|
5502 // ----------------------------------------------------------------------------- |
|
5503 // |
|
5504 void CHttpDownload::CheckRealDRMContentType() |
|
5505 { |
|
5506 LOGGER_ENTERFN( "CheckRealDRMContentType" ); |
|
5507 |
|
5508 iPausableDRM = ETrue; |
|
5509 iDrmContentLengthValid = ETrue; |
|
5510 |
|
5511 TInt index = FindHeaderField( iResponseHeaders, KDRMOldContentType ); |
|
5512 if( index != KErrNotFound ) |
|
5513 // this is an old DRM protected content |
|
5514 // This transaction cannot be paused. |
|
5515 { |
|
5516 if( !(*iResponseHeaders)[index]->FieldRawData()->Compare( KDrmMessageMimeType() ) ) |
|
5517 { |
|
5518 iPausableDRM = EFalse; |
|
5519 // iDrmContentLengthValid = EFalse; |
|
5520 } |
|
5521 } |
|
5522 |
|
5523 UpdatePausable(); |
|
5524 |
|
5525 CLOG_WRITE_2( "Pausable: [%d], Length: [%d]", iPausableDRM, iDrmContentLengthValid ); |
|
5526 } |
|
5527 |
|
5528 // ----------------------------------------------------------------------------- |
|
5529 // CHttpDownload::SaveCredentialsL |
|
5530 // ?implementation_description |
|
5531 // (other items were commented in a header). |
|
5532 // ----------------------------------------------------------------------------- |
|
5533 // |
|
5534 void CHttpDownload::SaveCredentialsL( RStringPool aStringPool ) |
|
5535 { |
|
5536 LOGGER_ENTERFN( "SaveCredentialsL" ); |
|
5537 |
|
5538 RStringF username = aStringPool.StringF( HTTP::EUsername, |
|
5539 RHTTPSession::GetTable() ); |
|
5540 RStringF password = aStringPool.StringF( HTTP::EPassword, |
|
5541 RHTTPSession::GetTable() ); |
|
5542 RStringF realm = aStringPool.StringF( HTTP::ERealm, |
|
5543 RHTTPSession::GetTable() ); |
|
5544 RStringF nonce = aStringPool.StringF( HTTP::ENonce, |
|
5545 RHTTPSession::GetTable() ); |
|
5546 |
|
5547 THTTPHdrVal hdrValue; |
|
5548 |
|
5549 // Realm |
|
5550 if( iTrans.PropertySet().Property( realm, hdrValue ) ) |
|
5551 { |
|
5552 if( hdrValue.Str().DesC().Length() ) |
|
5553 // W/o realm authentication is meaningless |
|
5554 { |
|
5555 ReallocateStringL( iHttpRealm, hdrValue.Str().DesC(), KMaxDefAttrLength ); |
|
5556 CLOG_WRITE8_1( "Realm: [%S]", iHttpRealm ); |
|
5557 |
|
5558 // Username |
|
5559 if( iTrans.PropertySet().Property( username, hdrValue ) ) |
|
5560 { |
|
5561 ReallocateStringL( iHttpUsername, hdrValue.Str().DesC(), KMaxDefAttrLength ); |
|
5562 CLOG_WRITE8_1( "uname: [%S]", iHttpUsername ); |
|
5563 } |
|
5564 |
|
5565 // Password |
|
5566 if( iTrans.PropertySet().Property( password, hdrValue ) ) |
|
5567 { |
|
5568 ReallocateStringL( iHttpPassword, hdrValue.Str().DesC(), KMaxDefAttrLength ); |
|
5569 CLOG_WRITE8_1( "pwd: [%S]", iHttpPassword ); |
|
5570 } |
|
5571 |
|
5572 if( !iTrans.PropertySet().Property( |
|
5573 aStringPool.StringF( HTTP::EBasic, |
|
5574 RHTTPSession::GetTable() ), |
|
5575 hdrValue ) ) |
|
5576 // this is a digest authentication response |
|
5577 // store nonce value |
|
5578 { |
|
5579 if( iTrans.PropertySet().Property( nonce, hdrValue ) ) |
|
5580 { |
|
5581 ReallocateStringL( iHttpNonce, hdrValue.Str().DesC() ); |
|
5582 CLOG_WRITE8_1( "nonce: [%S]", iHttpNonce ); |
|
5583 } |
|
5584 } |
|
5585 } |
|
5586 } |
|
5587 } |
|
5588 |
|
5589 // ----------------------------------------------------------------------------- |
|
5590 // CHttpDownload::RequestContentL |
|
5591 // ?implementation_description |
|
5592 // (other items were commented in a header). |
|
5593 // ----------------------------------------------------------------------------- |
|
5594 // |
|
5595 void CHttpDownload::RequestContentL() |
|
5596 { |
|
5597 LOGGER_ENTERFN( "RequestContentL" ); |
|
5598 |
|
5599 RStringPool strPool = iConnHandler->Session().StringPool(); |
|
5600 RStringF method; |
|
5601 TBool aHead = ETrue; |
|
5602 |
|
5603 if( (iContentType && iContentType->Length()) || |
|
5604 iNoContentTypeCheck || |
|
5605 iSilentMode ) |
|
5606 // we know the content type -> head is already requested or |
|
5607 // every content type is welcome |
|
5608 { |
|
5609 method = strPool.StringF( HTTP::EGET,RHTTPSession::GetTable() ); |
|
5610 aHead = EFalse; |
|
5611 } |
|
5612 else |
|
5613 // content type check needed -> first request HEAD |
|
5614 { |
|
5615 method = strPool.StringF( HTTP::EHEAD,RHTTPSession::GetTable() ); |
|
5616 } |
|
5617 |
|
5618 TUriParser8 uri; |
|
5619 uri.Parse( *iCurrentUrl ); |
|
5620 |
|
5621 CLOG_WRITE8_1( "Req URL: %S", iCurrentUrl ); |
|
5622 CLOG_WRITE8_1( "Method: %S", &method.DesC() ); |
|
5623 |
|
5624 __ASSERT_DEBUG( !iTransValid, DMPanic( KErrCorrupt ) ); |
|
5625 if( iTransValid ) |
|
5626 { |
|
5627 User::Leave( KErrCorrupt ); |
|
5628 } |
|
5629 |
|
5630 iTrans = iConnHandler->Session().OpenTransactionL( uri, *this, method ); |
|
5631 iTransValid = ETrue; |
|
5632 |
|
5633 RHTTPHeaders headers( iTrans.Request().GetHeaderCollection() ); |
|
5634 |
|
5635 SetRequestHeaderL( strPool, headers, aHead ); |
|
5636 |
|
5637 DisablePipeliningL( strPool ); |
|
5638 SetCookiesL( strPool ); |
|
5639 |
|
5640 iTrans.SubmitL(); |
|
5641 |
|
5642 if( aHead ) |
|
5643 { |
|
5644 SetDownloadStatus( EHttpContentTypeRequested ); |
|
5645 } |
|
5646 else |
|
5647 { |
|
5648 SetDownloadStatus( EHttpProgSubmitIssued ); |
|
5649 } |
|
5650 } |
|
5651 |
|
5652 // ----------------------------------------------------------------------------- |
|
5653 // CHttpDownload::ContentTypeReceivedL |
|
5654 // ?implementation_description |
|
5655 // (other items were commented in a header). |
|
5656 // ----------------------------------------------------------------------------- |
|
5657 // |
|
5658 void CHttpDownload::ContentTypeReceivedL() |
|
5659 { |
|
5660 LOGGER_ENTERFN( "ContentTypeReceivedL" ); |
|
5661 |
|
5662 InternalPauseL( EFalse ); |
|
5663 SetDownloadStatus( EHttpContentTypeReceived, EHttpDlPaused ); |
|
5664 } |
|
5665 |
|
5666 // ----------------------------------------------------------------------------- |
|
5667 // CHttpDownload::HttpResponse401L |
|
5668 // ?implementation_description |
|
5669 // (other items were commented in a header). |
|
5670 // ----------------------------------------------------------------------------- |
|
5671 // |
|
5672 void CHttpDownload::HttpResponse401L() |
|
5673 { |
|
5674 LOGGER_ENTERFN( "HttpResponse401L" ); |
|
5675 |
|
5676 THTTPHdrVal hdrValue; |
|
5677 RStringPool strPool = iConnHandler->Session().StringPool(); |
|
5678 |
|
5679 // Check authentication scheme |
|
5680 TBool basic = iTrans.PropertySet().Property( strPool.StringF( HTTP::EBasic, |
|
5681 RHTTPSession::GetTable() ), |
|
5682 hdrValue ); |
|
5683 |
|
5684 if( basic ) |
|
5685 // property is set -> Basic |
|
5686 { |
|
5687 iAuthScheme = EAuthBasic; |
|
5688 } |
|
5689 else |
|
5690 // property not set -> Digest |
|
5691 { |
|
5692 iAuthScheme = EAuthDigest; |
|
5693 } |
|
5694 |
|
5695 RStringF staleStr = strPool.StringF( HTTP::EStale, RHTTPSession::GetTable() ); |
|
5696 |
|
5697 SaveCredentialsL( strPool ); |
|
5698 if( iTrans.PropertySet().Property( staleStr, hdrValue ) || // 1. |
|
5699 (iDlStartedByClient && iHttpUsername) ) // 2. |
|
5700 // 1. - In case of stale we only have to resubmit the request |
|
5701 // with the same credentials info |
|
5702 // 2. - download was started by the client app that has specified |
|
5703 // the http username -> try to do the authentication |
|
5704 { |
|
5705 CancelTransaction(); |
|
5706 SetDownloadStatus( EHttpStarted ); |
|
5707 } |
|
5708 else |
|
5709 { |
|
5710 OnError( KErrUnknown, EHttpAuthenticationFailed ); |
|
5711 } |
|
5712 } |
|
5713 |
|
5714 // ----------------------------------------------------------------------------- |
|
5715 // CHttpDownload::HttpResponse407L |
|
5716 // ?implementation_description |
|
5717 // (other items were commented in a header). |
|
5718 // ----------------------------------------------------------------------------- |
|
5719 // |
|
5720 void CHttpDownload::HttpResponse407L() |
|
5721 { |
|
5722 LOGGER_ENTERFN( "HttpResponse407L" ); |
|
5723 |
|
5724 // Check authentication scheme |
|
5725 THTTPHdrVal hdrValue; |
|
5726 |
|
5727 RStringPool strPool = iConnHandler->Session().StringPool(); |
|
5728 TInt err = iTrans.PropertySet().Property( strPool.StringF( HTTP::EBasic, |
|
5729 RHTTPSession::GetTable() ), |
|
5730 hdrValue ); |
|
5731 |
|
5732 if( !err ) |
|
5733 // property is set -> Basic |
|
5734 { |
|
5735 iAuthScheme = EAuthBasic; |
|
5736 } |
|
5737 else |
|
5738 // property not set -> Digest |
|
5739 { |
|
5740 iAuthScheme = EAuthDigest; |
|
5741 } |
|
5742 |
|
5743 RStringF staleStr = strPool.StringF( HTTP::EStale, RHTTPSession::GetTable() ); |
|
5744 |
|
5745 SaveCredentialsL( strPool ); |
|
5746 if( iTrans.PropertySet().Property( staleStr, hdrValue ) || // 1. |
|
5747 (iDlStartedByClient && iHttpUsername) ) // 2. |
|
5748 // 1. - In case of stale we only have to resubmit the request |
|
5749 // with the same credentials info |
|
5750 // 2. - download was started by the client app that has specified |
|
5751 // the http username -> try to do the authentication |
|
5752 { |
|
5753 CancelTransaction(); |
|
5754 SetDownloadStatus( EHttpStarted ); |
|
5755 } |
|
5756 else |
|
5757 { |
|
5758 OnError( KErrUnknown, EProxyAuthenticationFailed ); |
|
5759 } |
|
5760 } |
|
5761 |
|
5762 // ----------------------------------------------------------------------------- |
|
5763 // CHttpDownload::FindHeaderField |
|
5764 // ?implementation_description |
|
5765 // (other items were commented in a header). |
|
5766 // ----------------------------------------------------------------------------- |
|
5767 // |
|
5768 TInt CHttpDownload::FindHeaderField( CArrayPtrFlat<CHeaderField>* aHeaders, |
|
5769 const TDesC8& aFieldName ) const |
|
5770 { |
|
5771 for( TInt index = 0; index < aHeaders->Count(); ++index ) |
|
5772 { |
|
5773 if( *(*aHeaders)[index]->FieldName() == aFieldName ) |
|
5774 { |
|
5775 return index; |
|
5776 } |
|
5777 } |
|
5778 |
|
5779 return KErrNotFound; |
|
5780 } |
|
5781 |
|
5782 // ----------------------------------------------------------------------------- |
|
5783 // CHttpDownload::ConvertDownloadNameUniqueL |
|
5784 // ?implementation_description |
|
5785 // (other items were commented in a header). |
|
5786 // ----------------------------------------------------------------------------- |
|
5787 // |
|
5788 void CHttpDownload::ConvertDownloadNameUniqueL() |
|
5789 { |
|
5790 LOGGER_ENTERFN( "ConvertDownloadNameUniqueL" ); |
|
5791 |
|
5792 CArrayPtrFlat<CHttpDownload>* downloads = iClientApp->Downloads(); |
|
5793 TBool bFound( EFalse ); |
|
5794 TInt index( 0 ); |
|
5795 HBufC* uniqueName = NULL; |
|
5796 |
|
5797 do |
|
5798 { |
|
5799 bFound = EFalse; |
|
5800 |
|
5801 CreateIndexedNameL( uniqueName, *iDlName, index ); |
|
5802 |
|
5803 for( TInt i = 0; i < downloads->Count(); ++i ) |
|
5804 { |
|
5805 if( (*downloads)[i] != this ) |
|
5806 { |
|
5807 CLOG_WRITE_1( "Compare: %S", (*downloads)[i]->iDlName ); |
|
5808 if( !uniqueName->Des().Compare( *(*downloads)[i]->iDlName ) ) |
|
5809 { |
|
5810 bFound = ETrue; |
|
5811 break; |
|
5812 } |
|
5813 } |
|
5814 } |
|
5815 }while( bFound ); |
|
5816 |
|
5817 delete iDlName; |
|
5818 iDlName = uniqueName; |
|
5819 CLOG_WRITE_1( "Unique name: [%S]", iDlName ); |
|
5820 } |
|
5821 |
|
5822 // ----------------------------------------------------------------------------- |
|
5823 // CHttpDownload::CreateIndexedNameL |
|
5824 // ?implementation_description |
|
5825 // (other items were commented in a header). |
|
5826 // ----------------------------------------------------------------------------- |
|
5827 // |
|
5828 void CHttpDownload::CreateIndexedNameL( HBufC* &aUniqueName, |
|
5829 TDesC& aOrgName, |
|
5830 TInt& aIndex ) |
|
5831 { |
|
5832 LOGGER_ENTERFN( "CreateIndexedNameL" ); |
|
5833 |
|
5834 TPtrC left; |
|
5835 TPtrC extension; |
|
5836 TBuf<KMaxIndexStringLength> indexStr; |
|
5837 |
|
5838 if( aIndex ) |
|
5839 { |
|
5840 indexStr.Format( KIndexString, aIndex ); |
|
5841 } |
|
5842 |
|
5843 TInt fullLength = aOrgName.Length() + indexStr.Length(); |
|
5844 if( fullLength > KMaxPath ) |
|
5845 // name is longer than KMaxPath. |
|
5846 { |
|
5847 OnError( KErrGeneral, EBadUrl ); |
|
5848 User::Leave( KErrGeneral ); |
|
5849 } |
|
5850 |
|
5851 delete aUniqueName; aUniqueName = NULL; |
|
5852 |
|
5853 TInt dotInd = aOrgName.LocateReverse( '.' ); |
|
5854 if( dotInd != KErrNotFound ) |
|
5855 // filename extension found. |
|
5856 // insert index string between name and extension |
|
5857 { |
|
5858 extension.Set( aOrgName.Right( aOrgName.Length() - dotInd ) ); |
|
5859 left.Set( aOrgName.Left( MIN( dotInd, ( KDownloadNameMaxSize - |
|
5860 indexStr.Length() - extension.Length() )))); |
|
5861 } |
|
5862 else |
|
5863 { |
|
5864 left.Set( aOrgName.Left( KDownloadNameMaxSize - indexStr.Length() )); |
|
5865 } |
|
5866 |
|
5867 aUniqueName = HBufC::NewL( fullLength ); |
|
5868 aUniqueName->Des().Format( _L("%S%S%S"), &left, |
|
5869 &indexStr, |
|
5870 &extension ); |
|
5871 |
|
5872 ++aIndex; |
|
5873 } |
|
5874 |
|
5875 // ----------------------------------------------------------------------------- |
|
5876 // CHttpDownload::ContinueDownloadStoreResponseHeaderL |
|
5877 // ?implementation_description |
|
5878 // (other items were commented in a header). |
|
5879 // ----------------------------------------------------------------------------- |
|
5880 // |
|
5881 void CHttpDownload::ContinueDownloadStoreResponseHeaderL( |
|
5882 const TDesC8& aResponseHeader ) |
|
5883 { |
|
5884 LOGGER_ENTERFN( "ContinueDownloadStoreResponseHeaderL" ); |
|
5885 |
|
5886 TInt colon( KErrNotFound ); |
|
5887 TInt separator( KErrNotFound ); |
|
5888 TPtrC8 field( aResponseHeader ); |
|
5889 TPtrC8 fieldName; |
|
5890 TPtrC8 fieldValue; |
|
5891 RStringPool strPool; |
|
5892 |
|
5893 // forget the previous headers |
|
5894 iResponseHeaders->ResetAndDestroy(); |
|
5895 iEntityHeaders->ResetAndDestroy(); |
|
5896 |
|
5897 strPool.OpenL( RHTTPSession::GetTable() ); |
|
5898 strPool.OpenL( HttpFilterCommonStringsExt::GetTable() ); |
|
5899 |
|
5900 do |
|
5901 { |
|
5902 separator = KErrNotFound; |
|
5903 |
|
5904 colon = field.Locate( KColon ); |
|
5905 |
|
5906 if( colon > 0 ) |
|
5907 // name found and is at least one byte long |
|
5908 { |
|
5909 fieldName.Set( field.Left( colon ) ); |
|
5910 field.Set( field.Right( field.Length() - colon - 1 ) ); |
|
5911 |
|
5912 separator = field.Locate( KHttpFieldSeparator()[0] ); |
|
5913 |
|
5914 if( separator != KErrNotFound ) |
|
5915 // there is more add-on |
|
5916 { |
|
5917 fieldValue.Set( field.Left( separator ) ); |
|
5918 field.Set( field.Right( field.Length() - separator - 1 ) ); |
|
5919 } |
|
5920 else |
|
5921 // this is the last add-on |
|
5922 { |
|
5923 fieldValue.Set( field ); |
|
5924 } |
|
5925 |
|
5926 CHeaderField* newField = CHeaderField::NewL( &fieldName, &fieldValue ); |
|
5927 CleanupStack::PushL( newField ); |
|
5928 |
|
5929 CLOG_WRITE8_2("%S:%S", &fieldName, &fieldValue); |
|
5930 iResponseHeaders->AppendL( newField ); |
|
5931 |
|
5932 CleanupStack::Pop( newField ); |
|
5933 |
|
5934 CHeaderField* newentField = CHeaderField::NewL( &fieldName, &fieldValue ); |
|
5935 CleanupStack::PushL( newentField ); |
|
5936 |
|
5937 CLOG_WRITE8_2("%S:%S", &fieldName, &fieldValue); |
|
5938 iEntityHeaders->AppendL( newentField ); |
|
5939 |
|
5940 CleanupStack::Pop( newentField ); |
|
5941 } |
|
5942 |
|
5943 }while( separator != KErrNotFound ); |
|
5944 |
|
5945 ParseContentTypeL( strPool ); |
|
5946 |
|
5947 ParseContentDispositionL( strPool); |
|
5948 if (!iCodDownload) |
|
5949 { |
|
5950 if (iUseAttachmentFileName || iUseInlineFileName) |
|
5951 { |
|
5952 SetDownloadNameL( *iAttachmentFileName ); |
|
5953 } |
|
5954 } |
|
5955 |
|
5956 CheckRealDRMContentType(); |
|
5957 |
|
5958 RStringF length = strPool.StringF(HTTP::EContentLength,RHTTPSession::GetTable()); |
|
5959 RStringF contentEncoding = strPool.StringF( HTTP::EContentEncoding, RHTTPSession::GetTable() ); |
|
5960 |
|
5961 TInt index = FindHeaderField( iResponseHeaders, length.DesC() ); |
|
5962 TInt contentEncodingInd = FindHeaderField( iResponseHeaders, contentEncoding.DesC() ); |
|
5963 if( ( index != KErrNotFound && contentEncodingInd == KErrNotFound ) && |
|
5964 iDrmContentLengthValid ) |
|
5965 { |
|
5966 iStorage->SetLength( (*iResponseHeaders)[index]->Int() ); |
|
5967 } |
|
5968 else |
|
5969 // in case of content-encoding the content length is size of the compressed content |
|
5970 // not the decompressed one. |
|
5971 { |
|
5972 CLOG_WRITE( "Content is encoded, or DRM" ); |
|
5973 iStorage->SetLength( KDefaultContentLength ); |
|
5974 } |
|
5975 |
|
5976 strPool.Close(); |
|
5977 } |
|
5978 |
|
5979 // ----------------------------------------------------------------------------- |
|
5980 // CHttpDownload::ParseContentTypeL |
|
5981 // ?implementation_description |
|
5982 // (other items were commented in a header). |
|
5983 // ----------------------------------------------------------------------------- |
|
5984 // |
|
5985 void CHttpDownload::ParseContentTypeL( RStringPool& aStrPool ) |
|
5986 { |
|
5987 LOGGER_ENTERFN( "ParseContentTypeL" ); |
|
5988 |
|
5989 RStringF contentType = aStrPool.StringF(HTTP::EContentType,RHTTPSession::GetTable()); |
|
5990 |
|
5991 TInt index = FindHeaderField( iResponseHeaders, contentType.DesC() ); |
|
5992 if( index != KErrNotFound ) |
|
5993 // store content-type |
|
5994 { |
|
5995 TPtrC8 rawData( *(*iResponseHeaders)[index]->FieldRawData() ); |
|
5996 TPtrC8 mediaType; |
|
5997 |
|
5998 // ';' separates content-type from media type |
|
5999 TInt semicolon = rawData.Locate( KSemiColon ); |
|
6000 |
|
6001 if( semicolon != KErrNotFound ) |
|
6002 { |
|
6003 mediaType.Set( rawData.Right( rawData.Length() - semicolon - 1 ) ); |
|
6004 Trim( mediaType ); |
|
6005 rawData.Set( rawData.Left( semicolon ) ); |
|
6006 Trim( rawData ); |
|
6007 } |
|
6008 |
|
6009 ReallocateStringL( iContentType, rawData, KMaxContentTypeLength ); |
|
6010 ReallocateStringL( iDDType, rawData, KMaxContentTypeLength ); |
|
6011 ReallocateStringL( iMediaType, mediaType, KMaxContentTypeLength ); |
|
6012 } |
|
6013 |
|
6014 #ifdef __SYNCML_DM_FOTA |
|
6015 if( !iContentType->Des().CompareF( KFotaMimeType ) ) |
|
6016 { |
|
6017 iStorage->SetStorageMethod( CHttpStorage::EStoreFota ); |
|
6018 } |
|
6019 #endif |
|
6020 |
|
6021 if( ( 0 == iContentType->Des().Compare( KCodMimeType() ) ) || |
|
6022 ( 0 == iContentType->Des().Compare( KDdMimeType() ) ) || |
|
6023 ( 0 == iContentType->Des().Compare( KDd2MimeType() ) ) ) |
|
6024 { |
|
6025 SetCodFlag( ETrue ); |
|
6026 } |
|
6027 |
|
6028 if( 0 == iContentType->Des().Compare( KMultiPartMimeType() ) ) |
|
6029 { |
|
6030 iMultiPart = ETrue; |
|
6031 } |
|
6032 |
|
6033 } |
|
6034 |
|
6035 // ----------------------------------------------------------------------------- |
|
6036 // CHttpDownload::ParseContentDispositionL |
|
6037 // ?implementation_description |
|
6038 // (other items were commented in a header). |
|
6039 // ----------------------------------------------------------------------------- |
|
6040 // |
|
6041 void CHttpDownload::ParseContentDispositionL( RStringPool& aStrPool ) |
|
6042 { |
|
6043 LOGGER_ENTERFN( "ParseContentDispositionL" ); |
|
6044 |
|
6045 RStringF contentDisposition = aStrPool.StringF(HTTP::EContentDisposition,RHTTPSession::GetTable()); |
|
6046 |
|
6047 TInt index = FindHeaderField( iResponseHeaders, contentDisposition.DesC() ); |
|
6048 if( index != KErrNotFound ) |
|
6049 // store content-disposition |
|
6050 { |
|
6051 TPtrC8 rawData( *(*iResponseHeaders)[index]->FieldRawData() ); |
|
6052 TPtrC8 fileNameParm; |
|
6053 TBool isFileNameParam = EFalse; |
|
6054 |
|
6055 // ';' separates disposition-type from disposition parm |
|
6056 TInt semicolon = rawData.Locate( KSemiColon ); |
|
6057 |
|
6058 if( semicolon != KErrNotFound ) |
|
6059 { |
|
6060 fileNameParm.Set( rawData.Right( rawData.Length() - semicolon - 1 ) ); |
|
6061 Trim( fileNameParm ); |
|
6062 // filename=<AttachmentFileName> |
|
6063 TInt offset = fileNameParm.FindC( KHttpFileNameParm ); |
|
6064 if (offset != KErrNotFound) |
|
6065 { |
|
6066 // '=' separates value of fileName from the <AttachmentFileName> |
|
6067 TInt equal = fileNameParm.Locate( KEqual ); |
|
6068 if( equal != KErrNotFound ) |
|
6069 { |
|
6070 fileNameParm.Set( fileNameParm.Right( fileNameParm.Length() - equal - 1 ) ); |
|
6071 Trim( fileNameParm ); |
|
6072 TInt semicolon1 = fileNameParm.Locate( KSemiColon ); |
|
6073 |
|
6074 // find '"' around the <AttachmentFileName> |
|
6075 TInt quote = fileNameParm.Locate( KQuote ); |
|
6076 if (quote != KErrNotFound) |
|
6077 { |
|
6078 fileNameParm.Set( fileNameParm.Right( fileNameParm.Length() - quote - 1 ) ); |
|
6079 Trim( fileNameParm ); |
|
6080 } |
|
6081 |
|
6082 TInt quote1 = fileNameParm.Locate( KQuote ); |
|
6083 if (quote1 != KErrNotFound) |
|
6084 { |
|
6085 fileNameParm.Set( fileNameParm. Left(quote1) ); |
|
6086 Trim( fileNameParm ); |
|
6087 } |
|
6088 |
|
6089 if( semicolon1 != KErrNotFound ) |
|
6090 { |
|
6091 fileNameParm.Set( fileNameParm.Left( semicolon1 ) ); |
|
6092 } |
|
6093 isFileNameParam = ETrue; |
|
6094 // we must strip off any directory names from the filename |
|
6095 // first check for and remove any trailing '\' or '/' characters |
|
6096 if( ( fileNameParm.Right( 1 ).Locate( '\\' ) != KErrNotFound ) || |
|
6097 ( fileNameParm.Right( 1 ).Locate( '/' ) != KErrNotFound )) |
|
6098 { |
|
6099 fileNameParm.Set( fileNameParm.Left( fileNameParm.Length() - 1 )); |
|
6100 } |
|
6101 // next find location of last '/' or '\' to remove any directory names |
|
6102 TInt lastSlash = fileNameParm.LocateReverse( '/' ); |
|
6103 if( lastSlash == KErrNotFound ) |
|
6104 { |
|
6105 lastSlash = fileNameParm.LocateReverse( '\\' ); |
|
6106 } |
|
6107 if( lastSlash != KErrNotFound ) |
|
6108 { |
|
6109 fileNameParm.Set( fileNameParm.Mid( lastSlash + 1 )); |
|
6110 } |
|
6111 } |
|
6112 rawData.Set( rawData.Left( semicolon ) ); // DispositionType |
|
6113 Trim( rawData ); |
|
6114 } |
|
6115 } |
|
6116 |
|
6117 ReallocateStringL( iDispositionType, rawData, KMaxDispositionTypeLength ); |
|
6118 |
|
6119 if( isFileNameParam && (0 == iDispositionType->Des().CompareC( KHttpDispositionTypeAttachment()) ) ) |
|
6120 { |
|
6121 ReallocateStringL( iAttachmentFileName, fileNameParm ); |
|
6122 iUseAttachmentFileName = ETrue; |
|
6123 } |
|
6124 if( isFileNameParam && (0 == iDispositionType->Des().CompareC( KHttpDispositionTypeInline()) ) ) |
|
6125 { |
|
6126 ReallocateStringL( iAttachmentFileName, fileNameParm ); |
|
6127 iUseInlineFileName = ETrue; |
|
6128 } |
|
6129 } |
|
6130 } |
|
6131 |
|
6132 // ----------------------------------------------------------------------------- |
|
6133 // CHttpDownload::TriggerEvent |
|
6134 // ?implementation_description |
|
6135 // (other items were commented in a header). |
|
6136 // ----------------------------------------------------------------------------- |
|
6137 // |
|
6138 void CHttpDownload::TriggerEvent( THttpDownloadState aDlState, |
|
6139 THttpProgressState aProgState ) |
|
6140 { |
|
6141 #ifdef __DOWNLOADMGR_LOG__ // to filter out EHttpProgResponseBodyReceived |
|
6142 if( aProgState != EHttpProgResponseBodyReceived ) |
|
6143 { |
|
6144 CLOG_WRITE_3( "Trigger: %d - %d - %d", aDlState, aProgState, iActiveDownload ); |
|
6145 } |
|
6146 #endif |
|
6147 |
|
6148 if( iSilentMode ) |
|
6149 { |
|
6150 if( !((aDlState == EHttpDlInprogress && aProgState == EHttpStarted) |
|
6151 || aDlState == EHttpDlMultipleMOCompleted || aDlState == EHttpDlFailed )) |
|
6152 // See EDlAttrSilent |
|
6153 { |
|
6154 return; |
|
6155 } |
|
6156 } |
|
6157 |
|
6158 if( !iDontFireEvent ) |
|
6159 { |
|
6160 if( iClAppInstance && iClAppInstance->Observer() ) |
|
6161 { |
|
6162 // informs client app about status change |
|
6163 iClAppInstance->Observer()->Event( this, aDlState, aProgState, iActiveDownload ); |
|
6164 } |
|
6165 |
|
6166 if( iPDClAppInstance && iPDClAppInstance->Observer() ) |
|
6167 { |
|
6168 if( iActiveDownload == iActivePlayedDownload || aDlState == EHttpDlDeleting ) |
|
6169 iPDClAppInstance->Observer()->Event( this, aDlState, aProgState, iActiveDownload ); |
|
6170 } |
|
6171 } |
|
6172 } |
|
6173 |
|
6174 // ----------------------------------------------------------------------------- |
|
6175 // CHttpDownload::UpdatePausable |
|
6176 // ?implementation_description |
|
6177 // (other items were commented in a header). |
|
6178 // ----------------------------------------------------------------------------- |
|
6179 // |
|
6180 void CHttpDownload::UpdatePausable() |
|
6181 { |
|
6182 LOGGER_ENTERFN( "UpdatePausable" ); |
|
6183 |
|
6184 TBool pausable( ETrue ); |
|
6185 |
|
6186 if( !iPausableDRM ) |
|
6187 { |
|
6188 pausable = EFalse; |
|
6189 } |
|
6190 |
|
6191 if( iMethod == EMethodPOST ) |
|
6192 { |
|
6193 pausable = EFalse; |
|
6194 } |
|
6195 |
|
6196 if( pausable != iPausable ) |
|
6197 { |
|
6198 if( !iCodDownload ) |
|
6199 { |
|
6200 iPausable = pausable; |
|
6201 |
|
6202 // inform client about change |
|
6203 TriggerEvent( iPausable ? EHttpDlPausable : EHttpDlNonPausable ); |
|
6204 |
|
6205 TRAP_IGNORE( StoreDownloadInfoL() ); |
|
6206 } |
|
6207 } |
|
6208 } |
|
6209 |
|
6210 // ----------------------------------------------------------------------------- |
|
6211 // CHttpDownload::ForcedRestartL |
|
6212 // ?implementation_description |
|
6213 // (other items were commented in a header). |
|
6214 // ----------------------------------------------------------------------------- |
|
6215 // |
|
6216 void CHttpDownload::ForcedRestartL() |
|
6217 { |
|
6218 // Forget a previous redirect |
|
6219 ReallocateStringL( iRedirUrl, *iUrl ); |
|
6220 ReallocateStringL( iCurrentUrl, *iRedirUrl ); |
|
6221 iRedirect = EFalse; |
|
6222 |
|
6223 ReInitializeDownload(); |
|
6224 } |
|
6225 |
|
6226 // ----------------------------------------------------------------------------- |
|
6227 // CHttpDownload::HeaderFieldL |
|
6228 // ?implementation_description |
|
6229 // (other items were commented in a header). |
|
6230 // ----------------------------------------------------------------------------- |
|
6231 // |
|
6232 HBufC8* CHttpDownload::HeaderFieldL( CArrayPtrFlat<CHeaderField>* aHeaders, |
|
6233 TInt aFieldIndex ) |
|
6234 { |
|
6235 HBufC8* retVal = NULL; |
|
6236 RStringPool strPool; |
|
6237 |
|
6238 strPool.OpenL( RHTTPSession::GetTable() ); |
|
6239 // Find field in response header |
|
6240 RStringF charset = strPool.StringF( aFieldIndex, RHTTPSession::GetTable() ); |
|
6241 |
|
6242 TInt index = FindHeaderField( aHeaders, charset.DesC() ); |
|
6243 if( KErrNotFound != index ) |
|
6244 { |
|
6245 retVal = (*aHeaders)[index]->FieldRawData(); |
|
6246 } |
|
6247 |
|
6248 strPool.Close(); |
|
6249 |
|
6250 return retVal; |
|
6251 } |
|
6252 |
|
6253 #ifdef DEAD_CODE |
|
6254 // ----------------------------------------------------------------------------- |
|
6255 // CHttpDownload::CheckIfContentUnModified |
|
6256 // ?implementation_description |
|
6257 // (other items were commented in a header). |
|
6258 // ----------------------------------------------------------------------------- |
|
6259 // |
|
6260 TBool CHttpDownload::CheckIfContentUnModified() |
|
6261 { |
|
6262 CLOG_WRITE( "CheckIfContentUnModified" ); |
|
6263 |
|
6264 RStringPool strPool = iConnHandler->Session().StringPool(); |
|
6265 RHTTPHeaders headers( iTrans.Response().GetHeaderCollection() ); |
|
6266 |
|
6267 RStringF lastMod = strPool.StringF(HTTP::ELastModified,RHTTPSession::GetTable()); |
|
6268 THTTPHdrVal value; |
|
6269 |
|
6270 if( !headers.GetField( lastMod, 0, value ) ) |
|
6271 { |
|
6272 TDateTime date( value ); |
|
6273 |
|
6274 if( iDate.Year() != date.Year() || |
|
6275 iDate.Month() != date.Month() || |
|
6276 iDate.Day() != date.Day() || |
|
6277 iDate.Hour() != date.Hour() || |
|
6278 iDate.Minute() != date.Minute() || |
|
6279 iDate.Second() != date.Second() || |
|
6280 iDate.MicroSecond() != date.MicroSecond() ) |
|
6281 { |
|
6282 CLOG_WRITE( "Date changed" ); |
|
6283 |
|
6284 return EFalse; |
|
6285 } |
|
6286 } |
|
6287 |
|
6288 return ETrue; |
|
6289 } |
|
6290 #endif |
|
6291 |
|
6292 // ----------------------------------------------------------------------------- |
|
6293 // CHttpDownload::CheckAttribMaxLengthL |
|
6294 // ?implementation_description |
|
6295 // (other items were commented in a header). |
|
6296 // ----------------------------------------------------------------------------- |
|
6297 // |
|
6298 void CHttpDownload::CheckAttribMaxLengthL( THttpDownloadAttrib aAttribute, |
|
6299 const TDesC16& aValue ) |
|
6300 { |
|
6301 for( TInt i = 0; KStringAttribMaxLengths[i][0]; ++i ) |
|
6302 { |
|
6303 if( aAttribute == KStringAttribMaxLengths[i][0] ) |
|
6304 { |
|
6305 if( aValue.Length() > KStringAttribMaxLengths[i][1] ) |
|
6306 { |
|
6307 CLOG_WRITE_2( "Overflow length: %d, max-length: %d", aValue.Length(), |
|
6308 KStringAttribMaxLengths[i][1] ); |
|
6309 User::Leave( KErrOverflow ); |
|
6310 } |
|
6311 } |
|
6312 } |
|
6313 } |
|
6314 |
|
6315 // ----------------------------------------------------------------------------- |
|
6316 // CHttpDownload::CheckAttribMaxLengthL |
|
6317 // ?implementation_description |
|
6318 // (other items were commented in a header). |
|
6319 // ----------------------------------------------------------------------------- |
|
6320 // |
|
6321 void CHttpDownload::CheckAttribMaxLengthL( THttpDownloadAttrib aAttribute, |
|
6322 const TDesC8& aValue ) |
|
6323 { |
|
6324 for( TInt i = 0; KStringAttribMaxLengths[i][0]; ++i ) |
|
6325 { |
|
6326 if( aAttribute == KStringAttribMaxLengths[i][0] ) |
|
6327 { |
|
6328 if( aValue.Length() > KStringAttribMaxLengths[i][1] ) |
|
6329 { |
|
6330 CLOG_WRITE_2( "Overflow length: %d, max-length: %d", aValue.Length(), |
|
6331 KStringAttribMaxLengths[i][1] ); |
|
6332 User::Leave( KErrOverflow ); |
|
6333 } |
|
6334 } |
|
6335 } |
|
6336 } |
|
6337 |
|
6338 // ----------------------------------------------------------------------------- |
|
6339 // CHttpDownload::SetCookiesL |
|
6340 // ?implementation_description |
|
6341 // (other items were commented in a header). |
|
6342 // ----------------------------------------------------------------------------- |
|
6343 // |
|
6344 void CHttpDownload::SetCookiesL( RStringPool& aStringPool ) |
|
6345 { |
|
6346 RStringF propName = aStringPool.OpenFStringL( KCookieUsage ); |
|
6347 |
|
6348 CleanupClosePushL( propName ); |
|
6349 |
|
6350 SetPropertyL( propName, iUseCookies ); |
|
6351 |
|
6352 CleanupStack::PopAndDestroy( &propName ); |
|
6353 } |
|
6354 |
|
6355 // ----------------------------------------------------------------------------- |
|
6356 // CHttpDownload::DownloadSucceededL |
|
6357 // ?implementation_description |
|
6358 // (other items were commented in a header). |
|
6359 // ----------------------------------------------------------------------------- |
|
6360 // |
|
6361 void CHttpDownload::DownloadSucceededL() |
|
6362 { |
|
6363 CLOG_WRITE( "Transaction succeeded" ); |
|
6364 |
|
6365 // inform storage class that it doesn't have to expect any more chunk |
|
6366 // completed event fired only when the last chunk is persisted |
|
6367 OnCompletedL(); |
|
6368 iDlStartedByClient = EFalse; |
|
6369 } |
|
6370 |
|
6371 // ----------------------------------------------------------------------------- |
|
6372 // CHttpDownload::ParseRequestHeaderAddOnL |
|
6373 // ?implementation_description |
|
6374 // (other items were commented in a header). |
|
6375 // ----------------------------------------------------------------------------- |
|
6376 // |
|
6377 void CHttpDownload::ParseRequestHeaderAddOnL( const TDesC8& aValue ) |
|
6378 { |
|
6379 if( !aValue.Length() ) |
|
6380 { |
|
6381 return; |
|
6382 } |
|
6383 |
|
6384 TPtrC8 fieldName; |
|
6385 TPtrC8 fieldData; |
|
6386 TPtrC8 value( aValue ); |
|
6387 |
|
6388 TInt ind( 0 ); |
|
6389 TBool found( EFalse ); |
|
6390 |
|
6391 RStringPool strPool = iClAppInstance->ConnHandler()->Session().StringPool(); |
|
6392 TInt fieldInd; |
|
6393 |
|
6394 do |
|
6395 { |
|
6396 fieldInd = KErrNotFound; |
|
6397 // find KColon in the argument string |
|
6398 for( ind = 0; ind < value.Length() && value[ind] != KColon; ++ind ){}; |
|
6399 |
|
6400 if( value[ind] != KColon ) |
|
6401 // no KColon -> Invalid request header |
|
6402 { |
|
6403 User::Leave( KErrArgument ); |
|
6404 } |
|
6405 |
|
6406 // store field name |
|
6407 fieldName.Set( value.Left( ind ) ); |
|
6408 // and remove it from the argument string |
|
6409 value.Set( value.Right( value.Length() - ind - 1 ) ); |
|
6410 |
|
6411 // find field separator |
|
6412 ind = value.Find( KHttpFieldSeparator ); |
|
6413 |
|
6414 if( ind == KErrNotFound ) |
|
6415 // not found -> no more field |
|
6416 { |
|
6417 fieldData.Set( value ); |
|
6418 found = EFalse; |
|
6419 } |
|
6420 else |
|
6421 // found -> store raw data |
|
6422 // and go to next field |
|
6423 { |
|
6424 fieldData.Set( value.Left( ind ) ); |
|
6425 value.Set( value.Right( value.Length() - ind - 1 ) ); |
|
6426 found = ETrue; |
|
6427 } |
|
6428 |
|
6429 // Find out if this is a native request header field, or not. |
|
6430 // If not, fieldInd is KErrNotFound |
|
6431 for( TInt i = 0; KRequestHeaderConvTable[i][0]; ++i ) |
|
6432 { |
|
6433 RStringF fieldNameStr = strPool.StringF( KRequestHeaderConvTable[i][1], |
|
6434 RHTTPSession::GetTable() ); |
|
6435 |
|
6436 if( !fieldName.CompareF( fieldNameStr.DesC() ) ) |
|
6437 // this is a native header field name |
|
6438 { |
|
6439 fieldInd = i; |
|
6440 break; |
|
6441 } |
|
6442 } |
|
6443 |
|
6444 CHeaderField* field = CHeaderField::NewL( &fieldName, &fieldData, fieldInd ); |
|
6445 CleanupStack::PushL( field ); |
|
6446 |
|
6447 iRequestHeaders->AppendL( field ); |
|
6448 CLOG_WRITE8_3("Req(%d): %S:%S", iRequestHeaders->Count(), &fieldName, &fieldData ); |
|
6449 |
|
6450 CleanupStack::Pop( field ); |
|
6451 }while( found ); |
|
6452 } |
|
6453 |
|
6454 // ----------------------------------------------------------------------------- |
|
6455 // CHttpDownload::LoadHeadersL |
|
6456 // ----------------------------------------------------------------------------- |
|
6457 // |
|
6458 void CHttpDownload::LoadHeadersL( RFile& aFile, |
|
6459 CArrayPtrFlat<CHeaderField>* aHeaders ) |
|
6460 { |
|
6461 TInt headers; |
|
6462 READ_INT_L( aFile, headers ); |
|
6463 |
|
6464 CLOG_WRITE_1("Headers: %d", headers); |
|
6465 aHeaders->ResetAndDestroy(); |
|
6466 |
|
6467 for( TInt i = 0; i < headers; ++i ) |
|
6468 { |
|
6469 CHeaderField* field = CHeaderField::NewL(); |
|
6470 CleanupStack::PushL( field ); |
|
6471 |
|
6472 field->LoadHeaderInfoL( aFile ); |
|
6473 aHeaders->AppendL( field ); |
|
6474 |
|
6475 /* if( field->FieldName() && field->FieldRawData() ) |
|
6476 { |
|
6477 CLOG_WRITE8_1( "%S", field->FieldName() ); |
|
6478 CLOG_WRITE8_1( "%S", field->FieldRawData() ); |
|
6479 } |
|
6480 else |
|
6481 { |
|
6482 CLOG_WRITE8( "Empty field" ); |
|
6483 } |
|
6484 */ |
|
6485 CleanupStack::Pop( field ); |
|
6486 } |
|
6487 } |
|
6488 |
|
6489 // ----------------------------------------------------------------------------- |
|
6490 // CHttpDownload::AppendHeadersL |
|
6491 // ----------------------------------------------------------------------------- |
|
6492 // |
|
6493 void CHttpDownload::AppendHeadersL( TPtr8& aBuf, |
|
6494 CArrayPtrFlat<CHeaderField>* aHeaders ) |
|
6495 { |
|
6496 TInt headers = aHeaders->Count(); |
|
6497 CLOG_WRITE_1("Headers: %d", headers); |
|
6498 |
|
6499 APPEND_BUF_INT( aBuf, headers ); |
|
6500 |
|
6501 HBufC8* fieldName = NULL; |
|
6502 HBufC8* fieldRawData = NULL; |
|
6503 for( TInt i = 0; i < headers; ++i ) |
|
6504 { |
|
6505 fieldName = (*aHeaders)[i]->FieldName(); |
|
6506 fieldRawData = (*aHeaders)[i]->FieldRawData(); |
|
6507 AppendBufL( aBuf, fieldName ); |
|
6508 AppendBufL( aBuf, fieldRawData ); |
|
6509 CLOG_WRITE8_2( "%S:%S", fieldName, fieldRawData ); |
|
6510 } |
|
6511 } |
|
6512 |
|
6513 // ----------------------------------------------------------------------------- |
|
6514 // CHttpDownload::AddHeaderL |
|
6515 // ----------------------------------------------------------------------------- |
|
6516 // |
|
6517 void CHttpDownload::AddHeaderL( THttpDownloadAttrib aAttribute, |
|
6518 const TDesC8& aValue, |
|
6519 const TInt aConversionTable[][2], |
|
6520 CArrayPtrFlat<CHeaderField>* aHeaders ) |
|
6521 { |
|
6522 TInt index( KErrNotFound ); |
|
6523 |
|
6524 // search for if this field is already in the |
|
6525 for( index = 0; aConversionTable[index][0]; ++index ) |
|
6526 { |
|
6527 if( aConversionTable[index][0] == aAttribute ) |
|
6528 { |
|
6529 break; |
|
6530 } |
|
6531 } |
|
6532 |
|
6533 __ASSERT_DEBUG( index != KErrNotFound, DMPanic( KErrCorrupt ) ); |
|
6534 |
|
6535 RStringPool strPool = iClAppInstance->ConnHandler()->Session().StringPool(); |
|
6536 RStringF fieldName = strPool.StringF( aConversionTable[index][1], |
|
6537 RHTTPSession::GetTable() ); |
|
6538 CleanupClosePushL( fieldName ); |
|
6539 |
|
6540 // make a copy of the raw data |
|
6541 HBufC8* value = HBufC8::NewLC( aValue.Length() ); |
|
6542 value->Des().Copy( aValue ); |
|
6543 |
|
6544 CHeaderField* newField = CHeaderField::NewL( &fieldName.DesC(), value, index ); |
|
6545 |
|
6546 CleanupStack::Pop( value ); |
|
6547 CleanupStack::PushL( newField ); |
|
6548 |
|
6549 aHeaders->AppendL( newField ); |
|
6550 |
|
6551 CleanupStack::Pop( 2 ); // newField, fieldName |
|
6552 } |
|
6553 |
|
6554 // ----------------------------------------------------------------------------- |
|
6555 // CHttpDownload::RedirectedPermanentlyL |
|
6556 // ----------------------------------------------------------------------------- |
|
6557 // |
|
6558 void CHttpDownload::RedirectedPermanentlyL( const TDesC8& aNewUrl ) |
|
6559 { |
|
6560 CLOG_WRITE8_1( "ERedirectedPermanently: %S", &aNewUrl ); |
|
6561 // from now on this new redirected url has to be used |
|
6562 if( !iRedirect ) |
|
6563 { |
|
6564 ReallocateStringL( iRedirUrl, aNewUrl, KMaxUrlLength ); |
|
6565 ReallocateStringL( iCurrentUrl, *iRedirUrl, KMaxUrlLength ); |
|
6566 } |
|
6567 else |
|
6568 // there has already been a temporary redirection |
|
6569 // this permanent is not used on next submitted request |
|
6570 { |
|
6571 ReallocateStringL( iCurrentUrl, aNewUrl, KMaxUrlLength ); |
|
6572 } |
|
6573 ParseDownloadNameL(); |
|
6574 StoreDownloadInfoL(); // to store new url |
|
6575 |
|
6576 TriggerEvent( EHttpDlInprogress, EHttpProgRedirectedPermanently ); |
|
6577 } |
|
6578 |
|
6579 // ----------------------------------------------------------------------------- |
|
6580 // CHttpDownload::RedirectedPermanentlyL |
|
6581 // ----------------------------------------------------------------------------- |
|
6582 // |
|
6583 void CHttpDownload::RedirectedTemporaryL( const TDesC8& aNewUrl ) |
|
6584 { |
|
6585 CLOG_WRITE8_1( "ERedirectedTemporarily: %S", &aNewUrl ); |
|
6586 iRedirect = ETrue; |
|
6587 ReallocateStringL( iCurrentUrl, aNewUrl, KMaxUrlLength ); |
|
6588 ParseDownloadNameL(); |
|
6589 StoreDownloadInfoL(); // to store iRedirect |
|
6590 |
|
6591 TriggerEvent( EHttpDlInprogress, EHttpProgRedirectedTemporarily ); |
|
6592 } |
|
6593 |
|
6594 // ----------------------------------------------------------------------------- |
|
6595 // CHttpDownload::FixDownloadNameL |
|
6596 // ----------------------------------------------------------------------------- |
|
6597 // |
|
6598 void CHttpDownload::FixDownloadNameL() |
|
6599 { |
|
6600 if( !iCodDownload ) |
|
6601 { |
|
6602 TPtr name( iDlName->Des() ); |
|
6603 |
|
6604 for( TInt i = 0; i < name.Length(); ++i ) |
|
6605 { |
|
6606 TChar currChar = (*iDlName)[i]; |
|
6607 |
|
6608 if( currChar.IsAlphaDigit() || |
|
6609 currChar.IsGraph() || |
|
6610 currChar == 0x20 ) // space |
|
6611 { |
|
6612 continue; |
|
6613 } |
|
6614 else |
|
6615 { |
|
6616 name[i] = KUrlFixChar; |
|
6617 } |
|
6618 } |
|
6619 |
|
6620 ConvertDownloadNameUniqueL(); |
|
6621 } |
|
6622 } |
|
6623 |
|
6624 // ----------------------------------------------------------------------------- |
|
6625 // CHttpDownload::SetCodFlag |
|
6626 // ----------------------------------------------------------------------------- |
|
6627 // |
|
6628 void CHttpDownload::SetCodFlag( TBool aValue ) |
|
6629 { |
|
6630 if( aValue && iCodDownload ) |
|
6631 { |
|
6632 // this case we will not overwrite |
|
6633 // the value of iCodDownload. iCodDownload might be > 1 |
|
6634 return; |
|
6635 } |
|
6636 iCodDownload = aValue; |
|
6637 } |
|
6638 |
|
6639 // ----------------------------------------------------------------------------- |
|
6640 // CHttpDownload::SelfComplete |
|
6641 // ?implementation_description |
|
6642 // (other items were commented in a header). |
|
6643 // ----------------------------------------------------------------------------- |
|
6644 // |
|
6645 void CHttpDownload::SelfComplete( TInt aReason ) |
|
6646 { |
|
6647 __ASSERT_DEBUG( !IsActive(), DMPanic( KErrGeneral ) ); |
|
6648 SetActive(); |
|
6649 |
|
6650 TRequestStatus* dummy = &iStatus; |
|
6651 |
|
6652 User::RequestComplete( dummy, aReason ); |
|
6653 } |
|
6654 |
|
6655 // ----------------------------------------------------------------------------- |
|
6656 // CHttpDownload::UpdateDestFileNameL |
|
6657 // ----------------------------------------------------------------------------- |
|
6658 // |
|
6659 void CHttpDownload::UpdateDestFileNameL() |
|
6660 { |
|
6661 LOGGER_ENTERFN( "UpdateDestFileNameL" ); |
|
6662 RFs fs; |
|
6663 User::LeaveIfError( fs.Connect() ); |
|
6664 CleanupClosePushL(fs); |
|
6665 TInt32 downloadedSize(0); |
|
6666 downloadedSize = iStorage->DownloadedSize(); |
|
6667 HBufC16* fileName ; |
|
6668 fileName = iStorage->DestFilename(); |
|
6669 TPtr fileNamePtr = fileName->Des(); |
|
6670 TDriveUnit currentDrive(fileNamePtr); |
|
6671 TBuf<KMaxDrives> driveList; |
|
6672 TInt err( KErrNone ); |
|
6673 TInt drive( EDriveC ); |
|
6674 TBool criticalSpace( EFalse ); |
|
6675 TBool needToUpdatePath( ETrue ); |
|
6676 |
|
6677 CLOG_WRITE_1( " entering fileName: %S", fileName ); |
|
6678 #ifdef RD_MULTIPLE_DRIVE |
|
6679 HBufC8* drivesDynList = iClientApp->Engine()->QueryDynDriveListLC(); |
|
6680 TPtrC8 drives( *drivesDynList ); |
|
6681 #else |
|
6682 TPtrC drives( iClientApp->Engine()->iDriveLettersCenRep ); |
|
6683 #endif |
|
6684 // drive letters are separated by semicolons |
|
6685 for( TInt i = 0; i < drives.Length() && (err || !criticalSpace); i = i + 2 ) |
|
6686 { |
|
6687 if( ( err = fs.CharToDrive( drives[i], drive )) != KErrNone ) |
|
6688 { |
|
6689 continue; |
|
6690 } |
|
6691 if( drive == currentDrive )//if the current path is same as the path in cenrep then no need to update.The diff is because we must have not known size before hand |
|
6692 { |
|
6693 needToUpdatePath = EFalse; |
|
6694 break; |
|
6695 } |
|
6696 else |
|
6697 { |
|
6698 TInt bytesToWrite = downloadedSize; |
|
6699 if (bytesToWrite < 0) |
|
6700 bytesToWrite = 0; |
|
6701 |
|
6702 TRAP( err, criticalSpace = !SysUtil::DiskSpaceBelowCriticalLevelL( |
|
6703 &fs, bytesToWrite, drive )); |
|
6704 } |
|
6705 } |
|
6706 if( needToUpdatePath ) |
|
6707 { |
|
6708 iDlNameChanged = ETrue; |
|
6709 #ifdef RD_MULTIPLE_DRIVE |
|
6710 // using PathInfo::RootPath to set correct destination folder |
|
6711 // depending on memory used |
|
6712 |
|
6713 // Getting RootPath for selected Drive |
|
6714 TFileName rootPath; |
|
6715 User::LeaveIfError( PathInfo::GetRootPath( rootPath, drive ) ); |
|
6716 |
|
6717 // remove path from EDlAttrDestFilename |
|
6718 if( fileNamePtr.Length() > 0 ) |
|
6719 { |
|
6720 TInt lastSlashPos = fileNamePtr.LocateReverse( '\\' ); |
|
6721 if( lastSlashPos != KErrNotFound ) |
|
6722 { |
|
6723 fileNamePtr.Delete( 0, lastSlashPos ); |
|
6724 } |
|
6725 } |
|
6726 |
|
6727 // Setting RootPath for new Destination file |
|
6728 fileNamePtr.Insert( 0, rootPath ); |
|
6729 // Setting KDownloadPath |
|
6730 fileNamePtr.Insert( rootPath.Length(), KDownloadPath ); |
|
6731 #else |
|
6732 TChar driveChar; |
|
6733 fs.DriveToChar(drive, driveChar); |
|
6734 TBuf<2> buf; |
|
6735 buf.Append(driveChar); |
|
6736 fileNamePtr.Replace(0,1,buf); |
|
6737 #endif |
|
6738 err = fs.MkDirAll( fileNamePtr );//in case the size unknown the dir needs to be formed again as Drive can change |
|
6739 if ( err != KErrNone && err != KErrAlreadyExists ) |
|
6740 { |
|
6741 User::Leave( err ); |
|
6742 } |
|
6743 } |
|
6744 CLOG_WRITE_1( " exiting fileName: %S", fileName ); |
|
6745 #ifdef RD_MULTIPLE_DRIVE |
|
6746 CleanupStack::PopAndDestroy( drivesDynList ); |
|
6747 #endif |
|
6748 CleanupStack::PopAndDestroy( &fs ); |
|
6749 } |
|
6750 |
|
6751 // --------------------------------------------------------- |
|
6752 // CHttpDownload::UpdateDCFRepositoryL() |
|
6753 // Update saved file to DCFRepository |
|
6754 // --------------------------------------------------------- |
|
6755 // |
|
6756 void CHttpDownload::UpdateDCFRepositoryL( |
|
6757 const TDesC& aFileName ) |
|
6758 { |
|
6759 LOGGER_ENTERFN( "UpdateDCFRepositoryL" ); |
|
6760 CLOG_WRITE_1( " :UpdateDCFRepositoryL() for: %S", &aFileName ); |
|
6761 CDcfEntry* dcfEntry = NULL; |
|
6762 dcfEntry = CDcfEntry::NewL(); |
|
6763 CleanupStack::PushL( dcfEntry ); |
|
6764 |
|
6765 CDcfRep* dcfRep = NULL; |
|
6766 dcfRep = CDcfRep::NewL(); |
|
6767 CleanupStack::PushL( dcfRep ); |
|
6768 |
|
6769 dcfEntry->SetLocationL( aFileName, 0 ); |
|
6770 CLOG_WRITE(" : SetLocationL OK"); |
|
6771 dcfRep->UpdateL( dcfEntry ); |
|
6772 CLOG_WRITE(" :UpdateL OK"); |
|
6773 CleanupStack::PopAndDestroy(2); // dcfEntry, dcfRep |
|
6774 } |
|
6775 |
|
6776 // ----------------------------------------------------------------------------- |
|
6777 // CHttpDownload::MoveInDeleteL |
|
6778 // ?implementation_description |
|
6779 // (other items were commented in a header). |
|
6780 // ----------------------------------------------------------------------------- |
|
6781 // |
|
6782 TInt CHttpDownload::MoveInDelete(TInt mediaObjectIndex) |
|
6783 { |
|
6784 TInt err(KErrNone); |
|
6785 if(!iCodDlData) |
|
6786 return err; |
|
6787 |
|
6788 if( mediaObjectIndex <= iCodDlData->Count()) |
|
6789 { |
|
6790 TRAP_IGNORE(MoveDownloadedMediaObjectSyncL(mediaObjectIndex)); |
|
6791 TPtrC filenamePtr = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
|
6792 if(filenamePtr.Length()) |
|
6793 { |
|
6794 TRAP_IGNORE(NotifyMediaGalleryL( filenamePtr )); |
|
6795 } |
|
6796 } |
|
6797 return err; |
|
6798 } |
|
6799 |
|
6800 |
|
6801 // ----------------------------------------------------------------------------- |
|
6802 // CHttpDownload::MoveDownloadedMediaObjectL |
|
6803 // ?implementation_description |
|
6804 // (other items were commented in a header). |
|
6805 // ----------------------------------------------------------------------------- |
|
6806 // |
|
6807 void CHttpDownload::MoveDownloadedMediaObjectL(TInt mediaObjectIndex) |
|
6808 { |
|
6809 LOGGER_ENTERFN( "MoveDownloadedMediaObjectsL" ); |
|
6810 |
|
6811 if( iDlState != EHttpDlMultipleMOCompleted && !iMoDownloadCompleted ) |
|
6812 { |
|
6813 iStorage->SetProgressiveMode( EFalse ); |
|
6814 TriggerEvent( iDlState, EHttpDlProgNonProgressive); |
|
6815 return;//Move will be Done by COD as MO Completed has not happened |
|
6816 } |
|
6817 |
|
6818 //__ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
|
6819 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
|
6820 |
|
6821 #if 0 |
|
6822 |
|
6823 #else |
|
6824 |
|
6825 HBufC* filename = HBufC::NewLC(KMaxFileName); |
|
6826 TPtr filenamePtr1 = filename->Des(); |
|
6827 |
|
6828 RFs &fs = iClientApp->Engine()->Fs(); |
|
6829 if(!iFileMan) |
|
6830 { |
|
6831 iFileMan = CFileMan::NewL(fs); |
|
6832 } |
|
6833 |
|
6834 TPtrC filenamePtr2 = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
|
6835 if(!filenamePtr2.Length()) |
|
6836 { |
|
6837 CleanupStack::PopAndDestroy(filename); |
|
6838 return; |
|
6839 } |
|
6840 |
|
6841 TInt firstSlashPos = filenamePtr2.Locate( '\\' ); |
|
6842 |
|
6843 if(firstSlashPos < 0) |
|
6844 { |
|
6845 CleanupStack::PopAndDestroy(filename); |
|
6846 return; |
|
6847 } |
|
6848 TPtrC dlName = filenamePtr2.Left(firstSlashPos); |
|
6849 |
|
6850 TInt drive; |
|
6851 |
|
6852 User::LeaveIfError( fs.CharToDrive( dlName[0], drive )); |
|
6853 |
|
6854 |
|
6855 // Getting RootPath for selected Drive |
|
6856 TFileName rootPath; |
|
6857 User::LeaveIfError( PathInfo::GetRootPath( rootPath, drive ) ); |
|
6858 |
|
6859 // Setting KDownloadPath |
|
6860 rootPath.Append( KDownloadPath ); |
|
6861 |
|
6862 filenamePtr1.Copy(rootPath); |
|
6863 filenamePtr1.Append(_L("\\")); |
|
6864 |
|
6865 TInt error = fs.MkDirAll(filenamePtr1); |
|
6866 if (error!=KErrNone && error!=KErrAlreadyExists) |
|
6867 { |
|
6868 User::Leave(error); |
|
6869 } |
|
6870 if( mediaObjectIndex == iActivePlayedDownload ) |
|
6871 { |
|
6872 |
|
6873 iFname = ((*iCodDlData)[mediaObjectIndex])->TempFilename(); |
|
6874 } |
|
6875 |
|
6876 else |
|
6877 { |
|
6878 |
|
6879 iFname = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
|
6880 } |
|
6881 // Find a unique name to avoid any conflict. |
|
6882 // Here iFname has full path of current location of file |
|
6883 // and filename has destination path. |
|
6884 FindUniqueDestinationFileNameL( iFname, filename ); |
|
6885 |
|
6886 filenamePtr1 = filename->Des(); |
|
6887 |
|
6888 User::LeaveIfError( iFileMan->Move( iFname, filenamePtr1, CFileMan::EOverWrite, iStatus ) ); |
|
6889 // waiting for move to complete |
|
6890 SetActive(); |
|
6891 iFname = filenamePtr1; |
|
6892 ((*iCodDlData)[mediaObjectIndex])->SetDestFilenameL(filenamePtr1); |
|
6893 |
|
6894 CleanupStack::PopAndDestroy(filename); |
|
6895 |
|
6896 #endif |
|
6897 } |
|
6898 |
|
6899 // ----------------------------------------------------------------------------- |
|
6900 // CHttpDownload::MoveDownloadedMediaObjectSyncL |
|
6901 // ?implementation_description |
|
6902 // (other items were commented in a header). |
|
6903 // ----------------------------------------------------------------------------- |
|
6904 // |
|
6905 void CHttpDownload::MoveDownloadedMediaObjectSyncL(TInt mediaObjectIndex) |
|
6906 { |
|
6907 LOGGER_ENTERFN( "MoveDownloadedMediaObjectSyncL" ); |
|
6908 |
|
6909 if( !iCodDownload && iDlState != EHttpDlMultipleMOCompleted ) |
|
6910 { |
|
6911 User::Leave( KErrNotReady ); |
|
6912 } |
|
6913 |
|
6914 //__ASSERT_DEBUG( !IsActive(), DMPanic( KErrInUse ) ); |
|
6915 //__ASSERT_DEBUG( !iFileMan, DMPanic( KErrInUse ) ); |
|
6916 |
|
6917 |
|
6918 |
|
6919 RFs &fs = iClientApp->Engine()->Fs(); |
|
6920 if(!iFileMan) |
|
6921 { |
|
6922 iFileMan = CFileMan::NewL(fs); |
|
6923 } |
|
6924 |
|
6925 HBufC* filename = HBufC::NewLC(KMaxFileName); |
|
6926 TPtr filenamePtr = filename->Des(); |
|
6927 |
|
6928 TPtrC fileNamePtr = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
|
6929 TInt firstSlashPos = fileNamePtr.Locate( '\\' ); |
|
6930 if(firstSlashPos < 0) |
|
6931 { |
|
6932 CleanupStack::PopAndDestroy(filename); |
|
6933 return; |
|
6934 } |
|
6935 TPtrC dlName = fileNamePtr.Left(firstSlashPos); |
|
6936 TInt drive; |
|
6937 |
|
6938 User::LeaveIfError( fs.CharToDrive( dlName[0], drive )); |
|
6939 |
|
6940 |
|
6941 // Getting RootPath for selected Drive |
|
6942 TFileName rootPath; |
|
6943 User::LeaveIfError( PathInfo::GetRootPath( rootPath, drive ) ); |
|
6944 |
|
6945 // Setting KDownloadPath |
|
6946 rootPath.Append( KDownloadPath ); |
|
6947 |
|
6948 filenamePtr.Copy(rootPath); |
|
6949 filenamePtr.Append(_L("\\")); |
|
6950 |
|
6951 TInt error = fs.MkDirAll(filenamePtr); |
|
6952 if (error!=KErrNone && error!=KErrAlreadyExists) |
|
6953 { |
|
6954 User::Leave(error); |
|
6955 } |
|
6956 iFname = ((*iCodDlData)[mediaObjectIndex])->DestFilename(); |
|
6957 |
|
6958 // Find a unique name to avoid any conflict. |
|
6959 // Here iFname has full path of current location of file |
|
6960 // and filename has destination path. |
|
6961 FindUniqueDestinationFileNameL( iFname, filename ); |
|
6962 |
|
6963 filenamePtr = filename->Des(); |
|
6964 |
|
6965 TInt err = iFileMan->Move(iFname, filenamePtr, CFileMan::EOverWrite); |
|
6966 if(err != KErrNone) |
|
6967 { |
|
6968 User::LeaveIfError(err); |
|
6969 } |
|
6970 iFname = filenamePtr; |
|
6971 ((*iCodDlData)[mediaObjectIndex])->SetDestFilenameL(filenamePtr); |
|
6972 |
|
6973 CleanupStack::PopAndDestroy(filename); |
|
6974 |
|
6975 |
|
6976 } |
|
6977 |
|
6978 // ----------------------------------------------------------------------------- |
|
6979 // CHttpDownload::FindUniqueDestinationFileNameL |
|
6980 // ----------------------------------------------------------------------------- |
|
6981 // |
|
6982 void CHttpDownload::FindUniqueDestinationFileNameL( TDesC& srcFile, HBufC*& destPath ) |
|
6983 { |
|
6984 HBufC* fileExtention = HBufC::NewLC(KMaxFileName); |
|
6985 HBufC* fileName = HBufC::NewLC(KMaxFileName); |
|
6986 TPtr fileNamePtr( fileName->Des() ); |
|
6987 |
|
6988 fileNamePtr = srcFile; |
|
6989 // Retrieve the file extention. |
|
6990 TInt dotInd = srcFile.LocateReverse( '.' ); |
|
6991 if( dotInd != KErrNotFound ) |
|
6992 // Filename extension found. |
|
6993 { |
|
6994 fileExtention->Des().Copy( srcFile.Right( srcFile.Length() - dotInd ) ); |
|
6995 fileNamePtr.Copy( srcFile.Left( dotInd ) ); |
|
6996 } |
|
6997 |
|
6998 // Retrieve the file name (excluding file extention). |
|
6999 TInt lastSlashPos = fileNamePtr.LocateReverse( '\\' ); |
|
7000 if( lastSlashPos != KErrNotFound ) |
|
7001 // Filename found. |
|
7002 { |
|
7003 fileNamePtr.Copy( fileNamePtr.Right( fileNamePtr.Length() - lastSlashPos - 1 ) ); |
|
7004 } |
|
7005 |
|
7006 // Find a unique file name. |
|
7007 ConvertDownloadNameUniqueL( destPath, fileName, fileExtention ); |
|
7008 |
|
7009 // Found. Append file name and extention to destination path. |
|
7010 destPath->Des().Append( *fileName ); |
|
7011 destPath->Des().Append( *fileExtention ); |
|
7012 |
|
7013 CleanupStack::PopAndDestroy( fileName ); |
|
7014 CleanupStack::PopAndDestroy( fileExtention ); |
|
7015 } |
|
7016 |
|
7017 |
|
7018 // --------------------------------------------------------- |
|
7019 // CHttpDownload::NotifyMediaGalleryL() |
|
7020 // Notify media gallery about the new file. |
|
7021 // --------------------------------------------------------- |
|
7022 // |
|
7023 void CHttpDownload::NotifyMediaGalleryL( const TDesC& aFileName ) |
|
7024 { |
|
7025 |
|
7026 LOGGER_ENTERFN( "CHttpDownload::NotifyMediaGalleryL" ); |
|
7027 CLOG_WRITE_1(" notifying Gallery and DcfReposory about move for: %S",&aFileName); |
|
7028 // |
|
7029 // Notify Media Gallery about new media file |
|
7030 CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL( |
|
7031 iClientApp->Engine()->Fs() ); |
|
7032 CleanupStack::PushL( mgFileManager ); |
|
7033 if( aFileName.Length() > 0 ) |
|
7034 { |
|
7035 TRAP_IGNORE( mgFileManager->UpdateL( aFileName ) ); |
|
7036 } |
|
7037 else |
|
7038 { |
|
7039 TRAP_IGNORE( mgFileManager->UpdateL() ); |
|
7040 } |
|
7041 CleanupStack::PopAndDestroy( mgFileManager ); |
|
7042 // |
|
7043 // Notify DCF repository |
|
7044 TRAP_IGNORE( UpdateDCFRepositoryL( aFileName ) ); |
|
7045 } |
|
7046 // ----------------------------------------------------------------------------- |
|
7047 // CCodSaver::ConvertDownloadNameUniqueL |
|
7048 // ----------------------------------------------------------------------------- |
|
7049 // |
|
7050 void CHttpDownload::ConvertDownloadNameUniqueL( HBufC*& filePath, |
|
7051 HBufC*& fileName, |
|
7052 HBufC*& fileExtn) |
|
7053 { |
|
7054 TBool bFound( EFalse ); |
|
7055 TInt index( 0 ); |
|
7056 HBufC* uniqueName = NULL; |
|
7057 HBufC* fullNameTemp = HBufC::NewLC(KMaxFileName); |
|
7058 TPtr fullNameTempPtr( fullNameTemp->Des() ); |
|
7059 |
|
7060 RFs rFs; |
|
7061 User::LeaveIfError( rFs.Connect() ); |
|
7062 CleanupClosePushL(rFs); |
|
7063 |
|
7064 do |
|
7065 { |
|
7066 bFound = EFalse; |
|
7067 //Generate Unique name. |
|
7068 CreateIndexedNameL( uniqueName, *fileName, index ); |
|
7069 |
|
7070 //Name in \\system\\temp. |
|
7071 fullNameTempPtr.Copy( *filePath ); |
|
7072 fullNameTempPtr.Append( *uniqueName ); |
|
7073 fullNameTempPtr.Append( *fileExtn ); |
|
7074 |
|
7075 if( BaflUtils::FileExists( rFs , fullNameTempPtr ) ) |
|
7076 //Check if file name exist in Destination path. |
|
7077 { |
|
7078 bFound =ETrue; |
|
7079 } |
|
7080 |
|
7081 }while( bFound ); |
|
7082 |
|
7083 CleanupStack::PopAndDestroy(&rFs); |
|
7084 CleanupStack::PopAndDestroy(fullNameTemp); |
|
7085 |
|
7086 // This is the unique name that we were looking for. |
|
7087 CleanupStack::PopAndDestroy(fileName); |
|
7088 fileName = uniqueName; |
|
7089 CleanupStack::PushL(fileName); |
|
7090 } |
|
7091 |
|
7092 // End of File |