Fix for bug 3042 RCL_3
authorSebastian Brannstrom <sebastianb@symbian.org>
Wed, 28 Jul 2010 14:18:09 +0100
branchRCL_3
changeset 138 31659d49b2e7
parent 137 44d205147a83
Fix for bug 3042
engine/src/ShowEngine.cpp
--- a/engine/src/ShowEngine.cpp	Sat Oct 16 18:04:09 2010 +0100
+++ b/engine/src/ShowEngine.cpp	Wed Jul 28 14:18:09 2010 +0100
@@ -170,7 +170,7 @@
 void CShowEngine::Progress(CHttpClient* /*aHttpClient */, TInt aBytes,
 		TInt aTotalBytes)
 	{	
-	iShowDownloading->SetShowSize(aTotalBytes);
+	//iShowDownloading->SetShowSize(aTotalBytes);
 	TRAP_IGNORE(NotifyShowDownloadUpdatedL(aBytes, aTotalBytes));
 	}
 
@@ -253,7 +253,8 @@
 	{
 	if (iShowDownloading != NULL)
 		{
-		DP2("CShowEngine::CompleteL file=%S, aError=%d", &iShowDownloading->FileName(), aError);		
+		DP2("CShowEngine::CompleteL file=%S, aError=%d", &iShowDownloading->FileName(), aError);
+		
 		if(aError != KErrCouldNotConnect)
 			{
 			if(aError == KErrDisconnected && iPodcastModel.SettingsEngine().DownloadSuspended())
@@ -279,6 +280,14 @@
 					{
 					iShowDownloading->SetShowType(EVideoPodcast);
 					}
+				 
+				// setting file size	
+				TEntry entry;
+				TInt err = iPodcastModel.FsSession().Entry(iShowDownloading->FileName(), entry);
+				if (err == KErrNone)
+					{
+					iShowDownloading->SetShowSize(entry.iSize);
+					}
 
 				iShowDownloading->SetDownloadState(EDownloaded);
 				DBUpdateShowL(*iShowDownloading);
@@ -291,8 +300,16 @@
 				}
 			else
 				{
+				 if (aError == HTTPStatus::ERequestedRangeNotSatisfiable)
+					{
+					DP("ERequestedRangeNotSatisfiable, resetting download");
+					// file size got messed up, so delete downloaded file an re-queue
+					BaflUtils::DeleteFile(iPodcastModel.FsSession(),iShowDownloading->FileName());
+					iShowDownloading->SetDownloadState(EQueued);
+					DBUpdateShowL(*iShowDownloading);
+					}
 				// 400 and 500 series errors are serious errors on which probably another download will fail
-				if(aError >= HTTPStatus::EBadRequest && aError <= HTTPStatus::EBadRequest+200)
+				 else if (aError>= HTTPStatus::EBadRequest && aError <= HTTPStatus::EBadRequest+200)
 					{
 					iShowDownloading->SetDownloadState(EFailedDownload);
 					DBUpdateShowL(*iShowDownloading);