251 |
251 |
252 void CShowEngine::CompleteL(CHttpClient* /*aHttpClient*/, TInt aError) |
252 void CShowEngine::CompleteL(CHttpClient* /*aHttpClient*/, TInt aError) |
253 { |
253 { |
254 if (iShowDownloading != NULL) |
254 if (iShowDownloading != NULL) |
255 { |
255 { |
256 DP1("CShowEngine::Complete\tDownload of file: %S is complete", &iShowDownloading->FileName()); |
256 DP2("CShowEngine::CompleteL file=%S, aError=%d", &iShowDownloading->FileName(), aError); |
257 if(aError != KErrCouldNotConnect) |
257 if(aError != KErrCouldNotConnect) |
258 { |
258 { |
259 if(aError == KErrDisconnected && iPodcastModel.SettingsEngine().DownloadSuspended()) |
259 if(aError == KErrDisconnected && iPodcastModel.SettingsEngine().DownloadSuspended()) |
260 { |
260 { |
261 // no error if disconnect happened because of suspended downloading |
261 // no error if disconnect happened because of suspended downloading |
300 NotifyShowFinishedL(aError); |
300 NotifyShowFinishedL(aError); |
301 |
301 |
302 delete iShowDownloading; |
302 delete iShowDownloading; |
303 iShowDownloading = NULL; |
303 iShowDownloading = NULL; |
304 } |
304 } |
|
305 else if (aError == KErrDiskFull) |
|
306 { |
|
307 // stop downloading immediately if disk is full |
|
308 iShowDownloading->SetDownloadState(EQueued); |
|
309 DBUpdateShowL(*iShowDownloading); |
|
310 iDownloadErrors = KMaxDownloadErrors; |
|
311 } |
305 else // other kind of error, missing network etc, reque this show |
312 else // other kind of error, missing network etc, reque this show |
306 { |
313 { |
307 iShowDownloading->SetDownloadState(EQueued); |
314 iShowDownloading->SetDownloadState(EQueued); |
308 DBUpdateShowL(*iShowDownloading); |
315 DBUpdateShowL(*iShowDownloading); |
309 } |
316 } |
310 |
317 |
|
318 NotifyDownloadQueueUpdatedL(); |
311 iDownloadErrors++; |
319 iDownloadErrors++; |
312 if (iDownloadErrors > KMaxDownloadErrors) |
320 if (iDownloadErrors > KMaxDownloadErrors) |
313 { |
321 { |
314 DP("Too many downloading errors, suspending downloads"); |
322 DP("Too many downloading errors, suspending downloads"); |
315 iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
323 iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
1238 NotifyDownloadQueueUpdatedL(); |
1246 NotifyDownloadQueueUpdatedL(); |
1239 return; |
1247 return; |
1240 } |
1248 } |
1241 else |
1249 else |
1242 { |
1250 { |
1243 |
|
1244 // Start the download |
1251 // Start the download |
1245 |
|
1246 CShowInfo *info = DBGetNextDownloadL(); |
1252 CShowInfo *info = DBGetNextDownloadL(); |
1247 |
1253 CleanupStack::PushL(info); |
1248 while(info != NULL) |
1254 while(info != NULL) |
1249 { |
1255 { |
1250 DP1("CShowEngine::DownloadNextShow\tDownloading: %S", &(info->Title())); |
1256 DP1("CShowEngine::DownloadNextShow\tDownloading: %S", &(info->Title())); |
1251 info->SetDownloadState(EDownloading); |
1257 info->SetDownloadState(EDownloading); |
1252 info->SetLastError(KErrNone); |
1258 info->SetLastError(KErrNone); |
1260 if (error != KErrNone) |
1266 if (error != KErrNone) |
1261 { |
1267 { |
1262 info->SetDownloadState(EFailedDownload); |
1268 info->SetDownloadState(EFailedDownload); |
1263 DBRemoveDownloadL(info->Uid()); |
1269 DBRemoveDownloadL(info->Uid()); |
1264 DBUpdateShowL(*info); |
1270 DBUpdateShowL(*info); |
|
1271 CleanupStack::PopAndDestroy(info); |
1265 info = DBGetNextDownloadL(); |
1272 info = DBGetNextDownloadL(); |
1266 |
1273 |
1267 if(info == NULL) |
1274 if(info == NULL) |
1268 { |
1275 { |
1269 iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
1276 iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
1270 iShowDownloading = NULL; |
1277 iShowDownloading = NULL; |
1271 } |
1278 } |
|
1279 else |
|
1280 { |
|
1281 CleanupStack::PushL(info); |
|
1282 } |
1272 } |
1283 } |
1273 else |
1284 else |
1274 { |
1285 { |
1275 break; |
1286 break; |
1276 } |
1287 } |
1277 } |
1288 } |
|
1289 CleanupStack::Pop(info); // lives on as iShowDownloading |
1278 } |
1290 } |
1279 } |
1291 } |
1280 else |
1292 else |
1281 { |
1293 { |
1282 // Inform the observers |
1294 // Inform the observers |