|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "HttpClientAppInstance.h" |
|
22 #include "HttpConnHandler.h" |
|
23 #include "HttpDownloadManagerServerEngine.h" |
|
24 #include "FileExt.h" |
|
25 #include "HttpClientApp.h" |
|
26 #include "HttpDownloadMgrLogger.h" |
|
27 |
|
28 // EXTERNAL DATA STRUCTURES |
|
29 //extern ?external_data; |
|
30 |
|
31 // EXTERNAL FUNCTION PROTOTYPES |
|
32 //extern ?external_function( ?arg_type,?arg_type ); |
|
33 |
|
34 // CONSTANTS |
|
35 _LIT( KDownloadFilenameFormat, "%S%S"); |
|
36 |
|
37 // MACROS |
|
38 //#define ?macro ?macro_def |
|
39 |
|
40 // LOCAL CONSTANTS AND MACROS |
|
41 //const ?type ?constant_var = ?constant; |
|
42 //#define ?macro_name ?macro_def |
|
43 |
|
44 // MODULE DATA STRUCTURES |
|
45 //enum ?declaration |
|
46 //typedef ?declaration |
|
47 |
|
48 // LOCAL FUNCTION PROTOTYPES |
|
49 //?type ?function_name( ?arg_type, ?arg_type ); |
|
50 |
|
51 // FORWARD DECLARATIONS |
|
52 //class ?FORWARD_CLASSNAME; |
|
53 |
|
54 // ============================= LOCAL FUNCTIONS =============================== |
|
55 |
|
56 // ============================ MEMBER FUNCTIONS =============================== |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CHttpClientApp::CHttpClientApp |
|
60 // C++ default constructor can NOT contain any code, that |
|
61 // might leave. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CHttpClientApp::CHttpClientApp( TUint32 aAppUid, |
|
65 CHttpDownloadManagerServerEngine* aEngine ) |
|
66 : iAppUid( aAppUid ) |
|
67 , iEngine( aEngine ) |
|
68 { |
|
69 CLOG_CREATE; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CHttpClientApp::ConstructL |
|
74 // Symbian 2nd phase constructor can leave. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CHttpClientApp::ConstructL() |
|
78 { |
|
79 CLOG_NAME_1( _L("CHttpClientApp_%x"), iAppUid ); |
|
80 |
|
81 iInstances = new (ELeave) CArrayPtrFlat<CHttpClientAppInstance>(2); |
|
82 iDownloads = new (ELeave) CArrayPtrFlat<CHttpDownload>(2); |
|
83 iConnections = new (ELeave) CArrayPtrFlat<CHttpConnHandler>(2); |
|
84 |
|
85 TBuf<KMaxPath> folder; |
|
86 iEngine->ClientAppFolder( this, folder ); |
|
87 |
|
88 // Create client app's folder |
|
89 TInt error = iEngine->Fs().MkDirAll( folder ); |
|
90 if( error != KErrNone && error != KErrAlreadyExists ) |
|
91 // leave if makedir failed in some way |
|
92 // don't leave if already exists |
|
93 { |
|
94 CLOG_WRITE8_1( "MkDirAll: %d", error ); |
|
95 User::Leave( error ); |
|
96 } |
|
97 |
|
98 // create folder for info files |
|
99 iEngine->DownloadInfoFolder( this, folder ); |
|
100 |
|
101 error = iEngine->Fs().MkDirAll( folder ); |
|
102 if( error != KErrNone && error != KErrAlreadyExists ) |
|
103 // leave if makedir failed in some way |
|
104 // don't leave if already exists |
|
105 { |
|
106 CLOG_WRITE8_1( "info dir: %d", error ); |
|
107 User::Leave( error ); |
|
108 } |
|
109 |
|
110 // create folder for COD info files |
|
111 iEngine->CODDownloadInfoFolder( this, folder ); |
|
112 |
|
113 error = iEngine->Fs().MkDirAll( folder ); |
|
114 if( error != KErrNone && error != KErrAlreadyExists ) |
|
115 // leave if makedir failed in some way |
|
116 // don't leave if already exists |
|
117 { |
|
118 CLOG_WRITE8_1( "info dir: %d", error ); |
|
119 User::Leave( error ); |
|
120 } |
|
121 |
|
122 // create folder for content files |
|
123 iEngine->DownloadContentFolder( this, folder ); |
|
124 error = iEngine->Fs().MkDirAll( folder ); |
|
125 if( error != KErrNone && error != KErrAlreadyExists ) |
|
126 // leave if makedir failed in some way |
|
127 // don't leave if already exists |
|
128 { |
|
129 CLOG_WRITE8_1( "content dir: %d", error ); |
|
130 User::Leave( error ); |
|
131 } |
|
132 |
|
133 iEngine->ClientAppFolder( this, folder ); |
|
134 LoadClientInfoL( folder ); |
|
135 |
|
136 iEngine->CodFolder( this, folder ); |
|
137 |
|
138 CFileMan* fileman = CFileMan::NewL( iEngine->Fs() ); |
|
139 fileman->RmDir( folder ); |
|
140 delete fileman; |
|
141 |
|
142 iEngine->Fs().MkDir( folder ); |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CHttpClientApp::NewL |
|
147 // Two-phased constructor. |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 CHttpClientApp* CHttpClientApp::NewL( TUint32 aAppUid, |
|
151 CHttpDownloadManagerServerEngine* aEngine ) |
|
152 { |
|
153 CHttpClientApp* self = new( ELeave ) CHttpClientApp( aAppUid, aEngine ); |
|
154 |
|
155 CleanupStack::PushL( self ); |
|
156 self->ConstructL(); |
|
157 CleanupStack::Pop(); |
|
158 |
|
159 return self; |
|
160 } |
|
161 |
|
162 |
|
163 // Destructor |
|
164 CHttpClientApp::~CHttpClientApp() |
|
165 { |
|
166 CloseClientApp( EFalse ); |
|
167 |
|
168 CLOG_CLOSE; |
|
169 } |
|
170 |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CHttpClientApp::CreateNewInstanceL |
|
174 // ?implementation_description |
|
175 // (other items were commented in a header). |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 CHttpClientAppInstance* |
|
179 CHttpClientApp::CreateNewInstanceL( MDownloadStateObserver* aObserver, |
|
180 TBool aMaster ) |
|
181 { |
|
182 LOGGER_ENTERFN( "CreateNewInstanceL" ); |
|
183 |
|
184 TInt instanceId( 1 ); |
|
185 TInt index; |
|
186 |
|
187 if( aMaster ) |
|
188 { |
|
189 // Check that there can be only 1 master instance |
|
190 for( index = 0; index < iInstances->Count(); ++index ) |
|
191 { |
|
192 if( (*iInstances)[index]->Master() ) |
|
193 { |
|
194 User::Leave( KErrAlreadyExists ); |
|
195 } |
|
196 } |
|
197 } |
|
198 |
|
199 // generate new instance id |
|
200 for( index = 0; index < iInstances->Count(); ++index ) |
|
201 { |
|
202 if( instanceId <= (*iInstances)[index]->InstanceId() ) |
|
203 { |
|
204 instanceId = (*iInstances)[index]->InstanceId() + 1; |
|
205 } |
|
206 } |
|
207 |
|
208 CLOG_WRITE8_1( "New instance id: [%d]", instanceId ); |
|
209 |
|
210 // Create new connhandler used by the instance |
|
211 // Every instance has its own connhandler |
|
212 CHttpConnHandler* conn = CHttpConnHandler::NewL( this ); |
|
213 |
|
214 // connhandlers are owned by CHttpClientApp. |
|
215 CleanupStack::PushL( conn ); |
|
216 iConnections->AppendL( conn ); |
|
217 CleanupStack::Pop( conn ); |
|
218 |
|
219 // Create new client instance |
|
220 CHttpClientAppInstance* instance = |
|
221 CHttpClientAppInstance::NewL( this, conn, aMaster, instanceId, aObserver ); |
|
222 |
|
223 CleanupStack::PushL( instance ); |
|
224 iInstances->AppendL( instance ); |
|
225 CleanupStack::Pop( instance ); |
|
226 |
|
227 // Associate connhandler with client instance |
|
228 conn->SetClientAppInst( instance ); |
|
229 |
|
230 for( index = 0; index < iDownloads->Count(); ++index ) |
|
231 { |
|
232 if( !(*iDownloads)[index]->ClientAppInstance() ) |
|
233 // this download is not occupied by any client instance |
|
234 { |
|
235 CLOG_WRITE8_1( "Controlling download: [%d]", (*iDownloads)[index]->Id() ); |
|
236 // From it's owned by this new instance |
|
237 (*iDownloads)[index]->SetClientInstance( instance, ETrue ); |
|
238 if( (*iDownloads)[index]->ConnHandler() && aMaster )//In case of embedded browser(aMaster =0) the connection should be set by parent application |
|
239 { |
|
240 // conn handler in this download is not associated with |
|
241 // any client instance. do it now. |
|
242 (*iDownloads)[index]->ConnHandler()->SetClientAppInst( instance ); |
|
243 } |
|
244 } |
|
245 } |
|
246 |
|
247 return instance; |
|
248 } |
|
249 |
|
250 // ----------------------------------------------------------------------------- |
|
251 // CHttpClientApp::CloseInstance |
|
252 // ?implementation_description |
|
253 // (other items were commented in a header). |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 void CHttpClientApp::CloseInstance( CHttpClientAppInstance* aInstance ) |
|
257 { |
|
258 LOGGER_ENTERFN( "CloseInstance" ); |
|
259 |
|
260 CLOG_WRITE_1( "Instance: %d", aInstance->InstanceId() ); |
|
261 CLOG_WRITE_1( "ExitAction: %d", aInstance->ExitAction() ); |
|
262 |
|
263 TInt index; |
|
264 |
|
265 // find this instance |
|
266 for( index = 0; index < iInstances->Count(); ++index ) |
|
267 { |
|
268 if( aInstance == (*iInstances)[index] ) |
|
269 { |
|
270 break; |
|
271 } |
|
272 } |
|
273 |
|
274 __ASSERT_DEBUG( index != iInstances->Count(), DMPanic( KErrCorrupt ) ); |
|
275 if( index == iInstances->Count() ) |
|
276 { |
|
277 return; |
|
278 } |
|
279 |
|
280 // delete instance from the array |
|
281 iInstances->Delete( index ); |
|
282 |
|
283 CHttpClientAppInstance* masterInstance = NULL; |
|
284 |
|
285 // find which client instance will inherit |
|
286 // the downloads of the closed instance |
|
287 for( index = 0; index < iInstances->Count(); ++index ) |
|
288 { |
|
289 if( (*iInstances)[index]->Master() ) |
|
290 { |
|
291 masterInstance = (*iInstances)[index]; |
|
292 break; |
|
293 } |
|
294 } |
|
295 |
|
296 // Detach instance from conn handler(s) associated with it. |
|
297 for( index = 0; index < iConnections->Count(); ++index ) |
|
298 { |
|
299 if( (*iConnections)[index]->ClientAppInst() == aInstance ) |
|
300 { |
|
301 (*iConnections)[index]->SetClientAppInst( masterInstance ); |
|
302 |
|
303 if(!masterInstance && iInstances->Count() == 0) |
|
304 { |
|
305 DestroyConnHandler((*iConnections)[index]); |
|
306 } |
|
307 |
|
308 |
|
309 } |
|
310 } |
|
311 |
|
312 // detach download(s) from this instance |
|
313 for( index = 0; index < iDownloads->Count(); ++index ) |
|
314 { |
|
315 if( aInstance == (*iDownloads)[index]->ClientAppInstance() || |
|
316 aInstance == (*iDownloads)[index]->PDClientAppInstance() ) |
|
317 { |
|
318 //Unregister the download in case of PDClientAppInstance. This was registered during attach |
|
319 if( (*iDownloads)[index]->DetachClientInstance( aInstance ) ) |
|
320 { |
|
321 continue; |
|
322 } |
|
323 if( !(*iDownloads)[index]->Pausable() ) |
|
324 // non-pausable download always deleted |
|
325 { |
|
326 CLOG_WRITE_1( "Download is not pausable: [%d]", (*iDownloads)[index]->Id() ); |
|
327 (*iDownloads)[index]->Delete( aInstance ); |
|
328 // index(th) element was delete |
|
329 --index; |
|
330 } |
|
331 else |
|
332 { |
|
333 switch( aInstance->ExitAction() ) |
|
334 { |
|
335 case EExitPause: |
|
336 { |
|
337 TRAP_IGNORE( (*iDownloads)[index]->PauseL() ); |
|
338 } |
|
339 // flow through |
|
340 |
|
341 case EExitNothing: |
|
342 { |
|
343 (*iDownloads)[index]->SetClientInstance( masterInstance ); |
|
344 } |
|
345 break; |
|
346 |
|
347 |
|
348 case EExitDelete: |
|
349 { |
|
350 CLOG_WRITE_1( "Deleting: [%d]", (*iDownloads)[index]->Id() ); |
|
351 (*iDownloads)[index]->Delete( aInstance ); |
|
352 // index(th) element was delete |
|
353 --index; |
|
354 } |
|
355 break; |
|
356 |
|
357 default: |
|
358 break; |
|
359 } |
|
360 } |
|
361 } |
|
362 |
|
363 } |
|
364 |
|
365 // delete the instance |
|
366 delete aInstance; |
|
367 } |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // CHttpClientApp::CloseClientApp |
|
371 // ?implementation_description |
|
372 // (other items were commented in a header). |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 void CHttpClientApp::CloseClientApp( TBool /*bStore*/ ) |
|
376 { |
|
377 LOGGER_ENTERFN( "CloseClientApp" ); |
|
378 |
|
379 if( iConnections ) |
|
380 { |
|
381 iConnections->ResetAndDestroy(); |
|
382 delete iConnections; |
|
383 iConnections = NULL; |
|
384 } |
|
385 |
|
386 if( iDownloads ) |
|
387 { |
|
388 for (TInt i=0; i<iDownloads->Count(); i++) |
|
389 { |
|
390 iDownloads->At(i)->Deref(); |
|
391 } |
|
392 delete iDownloads; |
|
393 iDownloads = NULL; |
|
394 } |
|
395 |
|
396 if( iInstances ) |
|
397 { |
|
398 iInstances->ResetAndDestroy(); |
|
399 delete iInstances; |
|
400 iInstances = NULL; |
|
401 } |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // CHttpClientApp::Instances |
|
406 // ?implementation_description |
|
407 // (other items were commented in a header). |
|
408 // ----------------------------------------------------------------------------- |
|
409 // |
|
410 CArrayPtrFlat<CHttpClientAppInstance>* CHttpClientApp::Instances() const |
|
411 { |
|
412 return iInstances; |
|
413 } |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // CHttpClientApp::CreateNewDownloadL |
|
417 // ?implementation_description |
|
418 // (other items were commented in a header). |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 CHttpDownload* |
|
422 CHttpClientApp::CreateNewDownloadL( CHttpClientAppInstance* aClAppInstance, |
|
423 const TDesC8& aUrl ) |
|
424 { |
|
425 if( !aUrl.Length() ) |
|
426 // w/o url a download is meaningless |
|
427 { |
|
428 User::Leave( KErrArgument ); |
|
429 } |
|
430 |
|
431 TInt downloadId = iEngine->NextDownloadId(); |
|
432 |
|
433 CHttpDownload* newDl = CHttpDownload::NewL( aUrl, |
|
434 this, |
|
435 downloadId, |
|
436 aClAppInstance ); |
|
437 |
|
438 CleanupStack::PushL( newDl ); |
|
439 RegisterDownloadL( newDl ); |
|
440 CleanupStack::Pop( newDl ); |
|
441 |
|
442 return newDl; |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CHttpClientApp::AppUid |
|
447 // ?implementation_description |
|
448 // (other items were commented in a header). |
|
449 // ----------------------------------------------------------------------------- |
|
450 // |
|
451 TUint32 CHttpClientApp::AppUid() const |
|
452 { |
|
453 return iAppUid; |
|
454 } |
|
455 |
|
456 // ----------------------------------------------------------------------------- |
|
457 // CHttpClientApp::Downloads |
|
458 // ?implementation_description |
|
459 // (other items were commented in a header). |
|
460 // ----------------------------------------------------------------------------- |
|
461 // |
|
462 CArrayPtrFlat<CHttpDownload>* CHttpClientApp::Downloads() const |
|
463 { |
|
464 return iDownloads; |
|
465 } |
|
466 |
|
467 // ----------------------------------------------------------------------------- |
|
468 // CHttpClientApp::Engine |
|
469 // ?implementation_description |
|
470 // (other items were commented in a header). |
|
471 // ----------------------------------------------------------------------------- |
|
472 // |
|
473 CHttpDownloadManagerServerEngine* CHttpClientApp::Engine() const |
|
474 { |
|
475 return iEngine; |
|
476 } |
|
477 |
|
478 // ----------------------------------------------------------------------------- |
|
479 // CHttpClientApp::RegisterDownloadL |
|
480 // ?implementation_description |
|
481 // (other items were commented in a header). |
|
482 // ----------------------------------------------------------------------------- |
|
483 // |
|
484 void CHttpClientApp::RegisterDownloadL( CHttpDownload* aDownload ) |
|
485 { |
|
486 iDownloads->AppendL( aDownload ); |
|
487 aDownload->Ref(); |
|
488 } |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // CHttpClientApp::UnregisterDownload |
|
492 // ?implementation_description |
|
493 // (other items were commented in a header). |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 EXPORT_C void CHttpClientApp::UnregisterDownload( CHttpDownload* aDownload ) |
|
497 { |
|
498 CLOG_WRITE_1("Unregister download: %d", aDownload->Id() ); |
|
499 |
|
500 TInt index; |
|
501 for( index = 0; index < iDownloads->Count(); ++index ) |
|
502 { |
|
503 if( (*iDownloads)[index] == aDownload ) |
|
504 { |
|
505 iDownloads->Delete( index ); |
|
506 aDownload->Deref(); |
|
507 break; |
|
508 } |
|
509 } |
|
510 } |
|
511 |
|
512 // ----------------------------------------------------------------------------- |
|
513 // CHttpClientApp::DownloadsInMaster |
|
514 // |
|
515 // Counts how many (no media) downloads the Master instance has. |
|
516 // |
|
517 // ----------------------------------------------------------------------------- |
|
518 // |
|
519 TInt32 CHttpClientApp::DownloadsInMaster( TBool aNoMediasOnly ) |
|
520 { |
|
521 TInt32 counter( 0 ); |
|
522 |
|
523 for( TInt i = 0; i < iDownloads->Count(); ++i ) |
|
524 { |
|
525 if( (*iDownloads)[i]->ClientAppInstance()&& |
|
526 (*iDownloads)[i]->ClientAppInstance()->Master() ) |
|
527 { |
|
528 if( aNoMediasOnly && (*iDownloads)[i]->NoMedia() ) |
|
529 // count only the aNoMediasOnly |
|
530 { |
|
531 ++counter; |
|
532 } |
|
533 else if( !aNoMediasOnly ) |
|
534 // count every download |
|
535 { |
|
536 ++counter; |
|
537 } |
|
538 } |
|
539 } |
|
540 |
|
541 return counter; |
|
542 } |
|
543 |
|
544 // ----------------------------------------------------------------------------- |
|
545 // CHttpClientApp::DestroyConnHandler |
|
546 // |
|
547 // Deletes given connhandler from the array and destroys the object itself. |
|
548 // ----------------------------------------------------------------------------- |
|
549 // |
|
550 void CHttpClientApp::DestroyConnHandler( CHttpConnHandler* aConnHandler ) |
|
551 { |
|
552 CLOG_WRITE( "DestroyConnHandler" ); |
|
553 |
|
554 __ASSERT_DEBUG( aConnHandler, DMPanic( KErrCorrupt )); |
|
555 |
|
556 for( TInt index = 0; index < iConnections->Count(); ++index ) |
|
557 { |
|
558 if( (*iConnections)[index] == aConnHandler ) |
|
559 { |
|
560 __ASSERT_DEBUG( !aConnHandler->ClientAppInst(), DMPanic( KErrCorrupt )); |
|
561 iConnections->Delete( index ); |
|
562 delete aConnHandler; |
|
563 |
|
564 break; |
|
565 } |
|
566 } |
|
567 } |
|
568 |
|
569 // ----------------------------------------------------------------------------- |
|
570 // CHttpClientApp::LoadClientInfoL |
|
571 // |
|
572 // Download info and all the downloads are loaded here |
|
573 // ----------------------------------------------------------------------------- |
|
574 // |
|
575 void CHttpClientApp::LoadClientInfoL( const TDesC& /*aFolder*/ ) |
|
576 { |
|
577 LoadDownloadsL(); |
|
578 } |
|
579 |
|
580 // ----------------------------------------------------------------------------- |
|
581 // CHttpClientApp::StoreClientInfoL |
|
582 // |
|
583 // For further improvement if any download info has to be persisted |
|
584 // ----------------------------------------------------------------------------- |
|
585 // |
|
586 void CHttpClientApp::StoreClientInfoL() |
|
587 { |
|
588 } |
|
589 |
|
590 // ----------------------------------------------------------------------------- |
|
591 // CHttpClientApp::LoadDownloadsL |
|
592 // ?implementation_description |
|
593 // (other items were commented in a header). |
|
594 // ----------------------------------------------------------------------------- |
|
595 // |
|
596 void CHttpClientApp::LoadDownloadsL() |
|
597 { |
|
598 TPath folder; |
|
599 |
|
600 Engine()->DownloadInfoFolder( this, folder ); |
|
601 |
|
602 CDir* dirs = NULL; |
|
603 |
|
604 TUint mask = KEntryAttMatchMask | KEntryAttMatchExclude; |
|
605 |
|
606 User::LeaveIfError( Engine()->Fs().GetDir( folder, |
|
607 mask, |
|
608 EAscending | EDirsLast, |
|
609 dirs ) ); |
|
610 if( dirs && dirs->Count() ) |
|
611 // there are downloads for this client |
|
612 { |
|
613 TInt err; |
|
614 |
|
615 CleanupStack::PushL( dirs ); |
|
616 for( TInt i = 0; i < dirs->Count(); ++i ) |
|
617 { |
|
618 if( (*dirs)[i].IsDir() ) |
|
619 // directories are sorted to the end of the array |
|
620 // if this entry is dir we finished |
|
621 { |
|
622 break; |
|
623 } |
|
624 |
|
625 TInt32 id = DownloadIdL( (*dirs)[i].iName ); |
|
626 |
|
627 if ( IsDownloadAlreadyLoaded( id ) ) |
|
628 continue; |
|
629 |
|
630 // Download is not assigned to any instance |
|
631 // Id comes from the filename |
|
632 CHttpDownload* newDl = NULL; |
|
633 TRAP( err, newDl = CHttpDownload::NewL( KNullDesC8(), this, id ) ); |
|
634 if( err != KErrEof && |
|
635 err != KErrCorrupt && |
|
636 err != KErrNotFound && |
|
637 err != KErrNotSupported ) |
|
638 // no problem load info file and the download is valid |
|
639 // and it was pausable, or non-pausable but completed |
|
640 { |
|
641 RegisterDownloadL( newDl ); |
|
642 } |
|
643 else |
|
644 { |
|
645 TBuf<KMaxPath> fileName; |
|
646 |
|
647 fileName.Format( KDownloadFilenameFormat, |
|
648 &folder, |
|
649 &(*dirs)[i].iName ); |
|
650 |
|
651 if( newDl ) |
|
652 { |
|
653 newDl->Delete(NULL); |
|
654 delete newDl; |
|
655 } |
|
656 |
|
657 if( !err ) |
|
658 // delete unusable info file |
|
659 { |
|
660 iEngine->Fs().Delete( fileName ); |
|
661 } |
|
662 } |
|
663 } |
|
664 |
|
665 CleanupStack::Pop( dirs ); |
|
666 } |
|
667 |
|
668 delete dirs; |
|
669 } |
|
670 |
|
671 // ----------------------------------------------------------------------------- |
|
672 // CHttpClientApp::OutputFilenameL |
|
673 // |
|
674 // Gets the download id from the give folder name |
|
675 // ----------------------------------------------------------------------------- |
|
676 // |
|
677 TInt32 CHttpClientApp::DownloadIdL( const TDesC& aFilename ) const |
|
678 { |
|
679 TLex temp( aFilename ); |
|
680 TUint32 id; |
|
681 User::LeaveIfError( temp.Val( id, EDecimal ) ); |
|
682 |
|
683 return id; |
|
684 } |
|
685 |
|
686 // ----------------------------------------------------------------------------- |
|
687 // CHttpClientApp::IsDownloadAlreadyLoaded |
|
688 // |
|
689 // Check whether the download is already loaded or not for the client |
|
690 // ----------------------------------------------------------------------------- |
|
691 // |
|
692 TBool CHttpClientApp::IsDownloadAlreadyLoaded( TInt32 aId ) const |
|
693 { |
|
694 |
|
695 for( TInt index = 0; index < iDownloads->Count(); ++index ) |
|
696 { |
|
697 if( (*iDownloads)[index]->Id() == aId) |
|
698 { |
|
699 return ETrue; |
|
700 } |
|
701 } |
|
702 return EFalse; |
|
703 } |
|
704 |
|
705 |
|
706 |
|
707 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
708 |
|
709 // End of File |