# HG changeset patch # User Sebastian Brannstrom # Date 1278530736 -3600 # Node ID 4bfc2fcec5f6e6c73bbfd16b45ac2658f0c9f16e # Parent 58268495eb35e71897331d5d8896cb2b37104e09 Proposed fix for bug 2931 diff -r 58268495eb35 -r 4bfc2fcec5f6 engine/inc/HttpEventHandler.h --- a/engine/inc/HttpEventHandler.h Wed Jul 07 20:24:29 2010 +0100 +++ b/engine/inc/HttpEventHandler.h Wed Jul 07 20:25:36 2010 +0100 @@ -58,7 +58,7 @@ private: TBool iVerbose; - TBool iSavingResponseBody; + TBool iFileOpen; RFs& iFileServ; RFile iRespBodyFile; TFileName iFileName; diff -r 58268495eb35 -r 4bfc2fcec5f6 engine/src/FeedEngine.cpp --- a/engine/src/FeedEngine.cpp Wed Jul 07 20:24:29 2010 +0100 +++ b/engine/src/FeedEngine.cpp Wed Jul 07 20:25:36 2010 +0100 @@ -698,10 +698,6 @@ void CFeedEngine::DownloadInfo(CHttpClient* /*aHttpClient */, int /*aTotalBytes*/) { - /*DP1("About to download %d bytes", aTotalBytes); - if(aHttpClient == iShowClient && iShowDownloading != NULL && aTotalBytes != -1) { - iShowDownloading->iShowSize = aTotalBytes; - }*/ } EXPORT_C void CFeedEngine::ImportFeedsL(const TDesC& aFile) diff -r 58268495eb35 -r 4bfc2fcec5f6 engine/src/HttpEventHandler.cpp --- a/engine/src/HttpEventHandler.cpp Wed Jul 07 20:24:29 2010 +0100 +++ b/engine/src/HttpEventHandler.cpp Wed Jul 07 20:25:36 2010 +0100 @@ -71,12 +71,8 @@ // Dump the headers if we're being verbose //DumpRespHeadersL(aTransaction); - // Determine if the body will be saved to disk - iSavingResponseBody = ETrue; - TBool cancelling = EFalse; if (resp.HasBody() && (iLastStatusCode >= 200) && (iLastStatusCode < 300) && (iLastStatusCode != 204)) { - //iBytesDownloaded = 0; TInt dataSize = resp.Body()->OverallDataSize(); if (dataSize >= 0) { DP1("Response body size is %d", dataSize); @@ -87,17 +83,10 @@ } iCallbacks.DownloadInfo(iHttpClient, dataSize); - cancelling = EFalse; } - // If we're cancelling, must do it now.. - if (cancelling) - { - DP("Transaction Cancelled"); - aTransaction.Close(); - iHttpClient->ClientRequestCompleteL(KErrCancel); - } - else if (iSavingResponseBody) // If we're saving, then open a file handle for the new file + DP1("iFileOpen=%d", iFileOpen); + if (!iFileOpen) { iFileServ.Parse(iFileName, iParsedFileName); TInt valid = iFileServ.IsValidName(iFileName); @@ -105,7 +94,6 @@ if (!valid) { DP("The specified filename is not valid!."); - iSavingResponseBody = EFalse; iHttpClient->ClientRequestCompleteL(KErrBadName); } else @@ -115,12 +103,12 @@ if (err) { DP2("There was an error=%d opening file '%S'", err, &iParsedFileName.FullName()); - iSavingResponseBody = EFalse; iHttpClient->ClientRequestCompleteL(KErrInUse); User::Leave(err); } else { + iFileOpen = ETrue; int pos = -KByteOverlap; if((err=iRespBodyFile.Seek(ESeekEnd, pos)) != KErrNone) { @@ -128,10 +116,10 @@ iHttpClient->ClientRequestCompleteL(KErrWrite); User::Leave(err); } - iBytesDownloaded = (pos > 0) ? pos : 0; - iBytesTotal += iBytesDownloaded; - DP1("Total bytes is now %u", iBytesTotal); - DP1("Seeking end: %d", pos); + iBytesDownloaded = (pos > 0) ? pos : 0; + iBytesTotal += iBytesDownloaded; + DP1("Total bytes is now %u", iBytesTotal); + DP1("Seeking end: %d", pos); } } else @@ -142,13 +130,15 @@ if (err) { DP("There was an error replacing file"); - iSavingResponseBody = EFalse; User::Leave(err); } + else + { + iFileOpen = ETrue; + } } } } - } break; case THTTPEvent::EGotResponseBodyData: { @@ -159,7 +149,7 @@ //DumpRespBody(aTransaction); //DP1("Saving: %d", iSavingResponseBody); // Append to the output file if we're saving responses - if (iSavingResponseBody) + if (iFileOpen) { TPtrC8 bodyData; iRespBody->GetNextDataPart(bodyData); @@ -168,6 +158,7 @@ // on writing error we close connection if (error != KErrNone) { + iFileOpen = EFalse; iRespBodyFile.Close(); iCallbacks.FileError(error); iHttpClient->ClientRequestCompleteL(error); @@ -185,14 +176,15 @@ case THTTPEvent::EResponseComplete: { // The transaction's response is complete - DP("Transaction Complete"); DP("Closing file"); + iFileOpen = EFalse; iRespBodyFile.Close(); } break; case THTTPEvent::ESucceeded: { DP("Transaction Successful"); + iFileOpen = EFalse; iRespBodyFile.Close(); aTransaction.Close(); iHttpClient->ClientRequestCompleteL(KErrNone); @@ -200,6 +192,7 @@ case THTTPEvent::EFailed: { DP("Transaction Failed"); + iFileOpen = EFalse; iRespBodyFile.Close(); aTransaction.Close(); @@ -224,6 +217,7 @@ // close off the transaction if it's an error if (aEvent.iStatus < 0) { + iFileOpen = EFalse; iRespBodyFile.Close(); aTransaction.Close(); iHttpClient->ClientRequestCompleteL(aEvent.iStatus); diff -r 58268495eb35 -r 4bfc2fcec5f6 engine/src/ShowEngine.cpp --- a/engine/src/ShowEngine.cpp Wed Jul 07 20:24:29 2010 +0100 +++ b/engine/src/ShowEngine.cpp Wed Jul 07 20:25:36 2010 +0100 @@ -172,12 +172,7 @@ void CShowEngine::DownloadInfo(CHttpClient* aHttpClient, TInt aTotalBytes) { - DP1("About to download %d bytes", aTotalBytes); - if (aHttpClient == iShowClient && iShowDownloading != NULL - && aTotalBytes != -1) - { - iShowDownloading->SetShowSize(aTotalBytes); - } + DP1("CShowEngine::DownloadInfo, About to download %d bytes", aTotalBytes); } void CShowEngine::GetShowL(CShowInfo *info)