297 { |
297 { |
298 iShowDownloading->SetShowType(EVideoPodcast); |
298 iShowDownloading->SetShowType(EVideoPodcast); |
299 } |
299 } |
300 |
300 |
301 iShowDownloading->SetDownloadState(EDownloaded); |
301 iShowDownloading->SetDownloadState(EDownloaded); |
302 DBUpdateShow(*iShowDownloading); |
302 DBUpdateShowL(*iShowDownloading); |
303 DBRemoveDownload(iShowDownloading->Uid()); |
303 DBRemoveDownload(iShowDownloading->Uid()); |
304 AddShowToMpxCollection(*iShowDownloading); |
304 AddShowToMpxCollection(*iShowDownloading); |
305 NotifyShowFinishedL(aError); |
305 NotifyShowFinishedL(aError); |
306 iDownloadErrors = 0; |
306 iDownloadErrors = 0; |
307 delete iShowDownloading; |
307 delete iShowDownloading; |
311 { |
311 { |
312 // 400 and 500 series errors are serious errors on which probably another download will fail |
312 // 400 and 500 series errors are serious errors on which probably another download will fail |
313 if(aError >= HTTPStatus::EBadRequest && aError <= HTTPStatus::EBadRequest+200) |
313 if(aError >= HTTPStatus::EBadRequest && aError <= HTTPStatus::EBadRequest+200) |
314 { |
314 { |
315 iShowDownloading->SetDownloadState(EFailedDownload); |
315 iShowDownloading->SetDownloadState(EFailedDownload); |
316 DBUpdateShow(*iShowDownloading); |
316 DBUpdateShowL(*iShowDownloading); |
317 DBRemoveDownload(iShowDownloading->Uid()); |
317 DBRemoveDownload(iShowDownloading->Uid()); |
318 NotifyShowFinishedL(aError); |
318 NotifyShowFinishedL(aError); |
319 |
319 |
320 delete iShowDownloading; |
320 delete iShowDownloading; |
321 iShowDownloading = NULL; |
321 iShowDownloading = NULL; |
322 } |
322 } |
323 else // other kind of error, missing network etc, reque this show |
323 else // other kind of error, missing network etc, reque this show |
324 { |
324 { |
325 iShowDownloading->SetDownloadState(EQueued); |
325 iShowDownloading->SetDownloadState(EQueued); |
326 DBUpdateShow(*iShowDownloading); |
326 DBUpdateShowL(*iShowDownloading); |
327 } |
327 } |
328 |
328 |
329 iDownloadErrors++; |
329 iDownloadErrors++; |
330 if (iDownloadErrors > KMaxDownloadErrors) |
330 if (iDownloadErrors > KMaxDownloadErrors) |
331 { |
331 { |
732 |
732 |
733 TInt lasterror = sqlite3_column_int(st, 14); |
733 TInt lasterror = sqlite3_column_int(st, 14); |
734 showInfo->SetLastError(lasterror); |
734 showInfo->SetLastError(lasterror); |
735 } |
735 } |
736 |
736 |
737 TBool CShowEngine::DBAddShow(const CShowInfo& aItem) |
737 TBool CShowEngine::DBAddShowL(const CShowInfo& aItem) |
738 { |
738 { |
739 DP2("CShowEngine::DBAddShow, title=%S, URL=%S", &aItem.Title(), &aItem.Url()); |
739 DP2("CShowEngine::DBAddShow, title=%S, URL=%S", &aItem.Title(), &aItem.Url()); |
740 |
740 |
741 HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); |
741 HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); |
742 TPtr titlePtr(titleBuf->Des()); |
742 TPtr titlePtr(titleBuf->Des()); |
802 } |
802 } |
803 |
803 |
804 sqlite3_finalize(st); |
804 sqlite3_finalize(st); |
805 } |
805 } |
806 |
806 |
807 TBool CShowEngine::DBUpdateShow(CShowInfo& aItem) |
807 TBool CShowEngine::DBUpdateShowL(CShowInfo& aItem) |
808 { |
808 { |
809 DP1("CShowEngine::DBUpdateShow, title='%S'", &aItem.Title()); |
809 DP1("CShowEngine::DBUpdateShow, title='%S'", &aItem.Title()); |
810 |
810 |
811 HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); |
811 HBufC* titleBuf = HBufC::NewLC(KMaxLineLength); |
812 TPtr titlePtr(titleBuf->Des()); |
812 TPtr titlePtr(titleBuf->Des()); |
1056 // DP2("Sorting %S greater than %S", &a.iTitle, &b.iTitle); |
1056 // DP2("Sorting %S greater than %S", &a.iTitle, &b.iTitle); |
1057 return 1; |
1057 return 1; |
1058 } |
1058 } |
1059 } |
1059 } |
1060 |
1060 |
1061 EXPORT_C void CShowEngine::DeletePlayedShows(RShowInfoArray &aShowInfoArray) |
1061 EXPORT_C void CShowEngine::DeletePlayedShowsL(RShowInfoArray &aShowInfoArray) |
1062 { |
1062 { |
1063 for (TInt i = 0; i < aShowInfoArray.Count(); i++) |
1063 for (TInt i = 0; i < aShowInfoArray.Count(); i++) |
1064 { |
1064 { |
1065 if (aShowInfoArray[i]->PlayState() == EPlayed |
1065 if (aShowInfoArray[i]->PlayState() == EPlayed |
1066 && aShowInfoArray[i]->FileName().Length() > 0) |
1066 && aShowInfoArray[i]->FileName().Length() > 0) |
1070 { |
1070 { |
1071 iPodcastModel.SoundEngine().Stop(); |
1071 iPodcastModel.SoundEngine().Stop(); |
1072 } |
1072 } |
1073 BaflUtils::DeleteFile(iPodcastModel.FsSession(), aShowInfoArray[i]->FileName()); |
1073 BaflUtils::DeleteFile(iPodcastModel.FsSession(), aShowInfoArray[i]->FileName()); |
1074 aShowInfoArray[i]->SetDownloadState(ENotDownloaded); |
1074 aShowInfoArray[i]->SetDownloadState(ENotDownloaded); |
1075 DBUpdateShow(*aShowInfoArray[i]); |
1075 DBUpdateShowL(*aShowInfoArray[i]); |
1076 } |
1076 } |
1077 } |
1077 } |
1078 } |
1078 } |
1079 |
1079 |
1080 EXPORT_C void CShowEngine::DeleteAllShowsByFeedL(TUint aFeedUid, TBool aDeleteFiles) |
1080 EXPORT_C void CShowEngine::DeleteAllShowsByFeedL(TUint aFeedUid, TBool aDeleteFiles) |
1114 { |
1114 { |
1115 BaflUtils::DeleteFile(iPodcastModel.FsSession(), info->FileName()); |
1115 BaflUtils::DeleteFile(iPodcastModel.FsSession(), info->FileName()); |
1116 } |
1116 } |
1117 |
1117 |
1118 info->SetDownloadState(ENotDownloaded); |
1118 info->SetDownloadState(ENotDownloaded); |
1119 DBUpdateShow(*info); |
1119 DBUpdateShowL(*info); |
1120 delete info; |
1120 delete info; |
1121 } |
1121 } |
1122 } |
1122 } |
1123 |
1123 |
1124 EXPORT_C void CShowEngine::GetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid) |
1124 EXPORT_C void CShowEngine::GetShowsByFeedL(RShowInfoArray& aShowArray, TUint aFeedUid) |
1157 } |
1157 } |
1158 |
1158 |
1159 EXPORT_C void CShowEngine::AddDownloadL(CShowInfo& aInfo) |
1159 EXPORT_C void CShowEngine::AddDownloadL(CShowInfo& aInfo) |
1160 { |
1160 { |
1161 aInfo.SetDownloadState(EQueued); |
1161 aInfo.SetDownloadState(EQueued); |
1162 DBUpdateShow(aInfo); |
1162 DBUpdateShowL(aInfo); |
1163 DBAddDownload(aInfo.Uid()); |
1163 DBAddDownload(aInfo.Uid()); |
1164 DownloadNextShowL(); |
1164 DownloadNextShowL(); |
1165 } |
1165 } |
1166 |
1166 |
1167 void CShowEngine::DownloadNextShowL() |
1167 void CShowEngine::DownloadNextShowL() |
1197 { |
1197 { |
1198 TBool getOk = EFalse; |
1198 TBool getOk = EFalse; |
1199 DP1("CShowEngine::DownloadNextShow\tDownloading: %S", &(info->Title())); |
1199 DP1("CShowEngine::DownloadNextShow\tDownloading: %S", &(info->Title())); |
1200 info->SetDownloadState(EDownloading); |
1200 info->SetDownloadState(EDownloading); |
1201 info->SetLastError(KErrNone); |
1201 info->SetLastError(KErrNone); |
1202 DBUpdateShow(*info); |
1202 DBUpdateShowL(*info); |
1203 iShowDownloading = info; |
1203 iShowDownloading = info; |
1204 TRAPD(error,getOk = GetShowL(info)); |
1204 TRAPD(error,getOk = GetShowL(info)); |
1205 if (error != KErrNone || !getOk) |
1205 if (error != KErrNone || !getOk) |
1206 { |
1206 { |
1207 info->SetDownloadState(EFailedDownload); |
1207 info->SetDownloadState(EFailedDownload); |
1208 DBRemoveDownload(info->Uid()); |
1208 DBRemoveDownload(info->Uid()); |
1209 DBUpdateShow(*info); |
1209 DBUpdateShowL(*info); |
1210 info = DBGetNextDownloadL(); |
1210 info = DBGetNextDownloadL(); |
1211 |
1211 |
1212 if(info == NULL) |
1212 if(info == NULL) |
1213 { |
1213 { |
1214 iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
1214 iPodcastModel.SettingsEngine().SetDownloadSuspended(ETrue); |
1262 { |
1262 { |
1263 iObservers[i]->ShowListUpdatedL(); |
1263 iObservers[i]->ShowListUpdatedL(); |
1264 } |
1264 } |
1265 } |
1265 } |
1266 |
1266 |
1267 void CShowEngine::ReadMetaData(CShowInfo& aShowInfo) |
1267 void CShowEngine::ReadMetaDataL(CShowInfo& aShowInfo) |
1268 { |
1268 { |
1269 //DP1("Read %S", &(aShowInfo->Title())); |
1269 //DP1("Read %S", &(aShowInfo->Title())); |
1270 DBUpdateShow(aShowInfo); |
1270 DBUpdateShowL(aShowInfo); |
1271 } |
1271 } |
1272 |
1272 |
1273 void CShowEngine::ReadMetaDataCompleteL() |
1273 void CShowEngine::ReadMetaDataCompleteL() |
1274 { |
1274 { |
1275 NotifyShowListUpdatedL(); |
1275 NotifyShowListUpdatedL(); |
1276 MetaDataReader().SetIgnoreTrackNo(EFalse); |
1276 MetaDataReader().SetIgnoreTrackNo(EFalse); |
1277 } |
1277 } |
1278 |
1278 |
1279 EXPORT_C void CShowEngine::UpdateShow(CShowInfo& aInfo) |
1279 EXPORT_C void CShowEngine::UpdateShowL(CShowInfo& aInfo) |
1280 { |
1280 { |
1281 DBUpdateShow(aInfo); |
1281 DBUpdateShowL(aInfo); |
1282 } |
1282 } |
1283 |
1283 |
1284 EXPORT_C CMetaDataReader& CShowEngine::MetaDataReader() |
1284 EXPORT_C CMetaDataReader& CShowEngine::MetaDataReader() |
1285 { |
1285 { |
1286 return *iMetaDataReader; |
1286 return *iMetaDataReader; |