engine/src/ShowEngine.cpp
branchsymbian1
changeset 212 713bd6cc0b7a
parent 167 4bfc2fcec5f6
child 246 140a404c6b53
equal deleted inserted replaced
211:aa8e7de6f033 212:713bd6cc0b7a
   160 	}
   160 	}
   161 
   161 
   162 void CShowEngine::Progress(CHttpClient* /*aHttpClient */, TInt aBytes,
   162 void CShowEngine::Progress(CHttpClient* /*aHttpClient */, TInt aBytes,
   163 		TInt aTotalBytes)
   163 		TInt aTotalBytes)
   164 	{	
   164 	{	
   165 	iShowDownloading->SetShowSize(aTotalBytes);
   165 	//iShowDownloading->SetShowSize(aTotalBytes);
   166 	TRAP_IGNORE(NotifyShowDownloadUpdatedL(aBytes, aTotalBytes));
   166 	TRAP_IGNORE(NotifyShowDownloadUpdatedL(aBytes, aTotalBytes));
   167 	}
   167 	}
   168 
   168 
   169 void CShowEngine::Disconnected(CHttpClient* /*aClient */)
   169 void CShowEngine::Disconnected(CHttpClient* /*aClient */)
   170 	{
   170 	{
   237 
   237 
   238 void CShowEngine::CompleteL(CHttpClient* /*aHttpClient*/, TInt aError)
   238 void CShowEngine::CompleteL(CHttpClient* /*aHttpClient*/, TInt aError)
   239 	{
   239 	{
   240 	if (iShowDownloading != NULL)
   240 	if (iShowDownloading != NULL)
   241 		{
   241 		{
   242 		DP2("CShowEngine::CompleteL file=%S, aError=%d", &iShowDownloading->FileName(), aError);		
   242 		DP2("CShowEngine::CompleteL file=%S, aError=%d", &iShowDownloading->FileName(), aError);
       
   243 		
   243 		if(aError != KErrCouldNotConnect)
   244 		if(aError != KErrCouldNotConnect)
   244 			{
   245 			{
   245 			if(aError == KErrDisconnected && iPodcastModel.SettingsEngine().DownloadSuspended())
   246 			if(aError == KErrDisconnected && iPodcastModel.SettingsEngine().DownloadSuspended())
   246 				{
   247 				{
   247 				// no error if disconnect happened because of suspended downloading
   248 				// no error if disconnect happened because of suspended downloading
   263 					}
   264 					}
   264 				else if (mimeType.Left(5) == KMimeVideo)
   265 				else if (mimeType.Left(5) == KMimeVideo)
   265 					{
   266 					{
   266 					iShowDownloading->SetShowType(EVideoPodcast);
   267 					iShowDownloading->SetShowType(EVideoPodcast);
   267 					}
   268 					}
       
   269 				 
       
   270 				// setting file size	
       
   271 				TEntry entry;
       
   272 				TInt err = iPodcastModel.FsSession().Entry(iShowDownloading->FileName(), entry);
       
   273 				if (err == KErrNone)
       
   274 					{
       
   275 					iShowDownloading->SetShowSize(entry.iSize);
       
   276 					}
   268 
   277 
   269 				iShowDownloading->SetDownloadState(EDownloaded);
   278 				iShowDownloading->SetDownloadState(EDownloaded);
   270 				DBUpdateShowL(*iShowDownloading);
   279 				DBUpdateShowL(*iShowDownloading);
   271 				DBRemoveDownloadL(iShowDownloading->Uid());
   280 				DBRemoveDownloadL(iShowDownloading->Uid());
   272 				AddShowToMpxCollection(*iShowDownloading);				
   281 				AddShowToMpxCollection(*iShowDownloading);				
   275 				delete iShowDownloading;
   284 				delete iShowDownloading;
   276 				iShowDownloading = NULL;
   285 				iShowDownloading = NULL;
   277 				}
   286 				}
   278 			else
   287 			else
   279 				{
   288 				{
       
   289 				 if (aError == HTTPStatus::ERequestedRangeNotSatisfiable)
       
   290 					{
       
   291 					DP("ERequestedRangeNotSatisfiable, resetting download");
       
   292 					// file size got messed up, so delete downloaded file an re-queue
       
   293 					BaflUtils::DeleteFile(iPodcastModel.FsSession(),iShowDownloading->FileName());
       
   294 					iShowDownloading->SetDownloadState(EQueued);
       
   295 					DBUpdateShowL(*iShowDownloading);
       
   296 					}
   280 				// 400 and 500 series errors are serious errors on which probably another download will fail
   297 				// 400 and 500 series errors are serious errors on which probably another download will fail
   281 				if(aError >= HTTPStatus::EBadRequest && aError <= HTTPStatus::EBadRequest+200)
   298 				 else if (aError>= HTTPStatus::EBadRequest && aError <= HTTPStatus::EBadRequest+200)
   282 					{
   299 					{
   283 					iShowDownloading->SetDownloadState(EFailedDownload);
   300 					iShowDownloading->SetDownloadState(EFailedDownload);
   284 					DBUpdateShowL(*iShowDownloading);
   301 					DBUpdateShowL(*iShowDownloading);
   285 					DBRemoveDownloadL(iShowDownloading->Uid());
   302 					DBRemoveDownloadL(iShowDownloading->Uid());
   286 					NotifyShowFinishedL(aError);
   303 					NotifyShowFinishedL(aError);