Fix for 3843, Podcatcher will now stop downloading when 1 MB disk space remains symbian1
authorSebastian Brannstrom <sebastianb@symbian.org>
Sat, 16 Oct 2010 19:49:47 +0100
branchsymbian1
changeset 245 3f57982a6f10
parent 244 d6c20128dad5
child 246 140a404c6b53
Fix for 3843, Podcatcher will now stop downloading when 1 MB disk space remains
application/group/Podcast.mmp
engine/inc/HttpEventHandler.h
engine/src/HttpEventHandler.cpp
--- a/application/group/Podcast.mmp	Sat Oct 16 18:39:26 2010 +0100
+++ b/application/group/Podcast.mmp	Sat Oct 16 19:49:47 2010 +0100
@@ -106,5 +106,6 @@
 LIBRARY ws32.lib 
 LIBRARY hlplch.lib
 LIBRARY bitgdi.lib 
-LIBRARY  commonui.lib  // CDocumentHandler
+LIBRARY commonui.lib  // CDocumentHandler
 LIBRARY centralrepository.lib
+LIBRARY sysutil.lib 
--- a/engine/inc/HttpEventHandler.h	Sat Oct 16 18:39:26 2010 +0100
+++ b/engine/inc/HttpEventHandler.h	Sat Oct 16 19:49:47 2010 +0100
@@ -71,6 +71,7 @@
 	TBool iSilent;
 	TBool iContinue;
 	TInt iLastStatusCode;
+	TInt iDriveNo;
 };
 
 #endif
--- a/engine/src/HttpEventHandler.cpp	Sat Oct 16 18:39:26 2010 +0100
+++ b/engine/src/HttpEventHandler.cpp	Sat Oct 16 19:49:47 2010 +0100
@@ -19,10 +19,13 @@
 // HttpEventHandler.cpp
 #include <e32debug.h>
 #include <httperr.h>
+#include <sysutil.h>
 #include "HttpEventHandler.h"
 #include "bautils.h"
 #include "Httpclient.h"
 
+const TInt64 KMinDiskSpace = 1024 * 1024; // at least 1 MB must remain
+
 void CHttpEventHandler::ConstructL()
 	{
 	//iVerbose = ETrue;	
@@ -148,6 +151,18 @@
 			// Some (more) body data has been received (in the HTTP response)
 			//DumpRespBody(aTransaction);
 			//DP1("Saving: %d", iSavingResponseBody);
+			
+			// check if we have enough disk space
+			if (iDriveNo != -1 && SysUtil::DiskSpaceBelowCriticalLevelL( &iFileServ, KMinDiskSpace, iDriveNo ))
+				{
+					TInt error = KErrDiskFull;
+					iFileOpen = EFalse;
+					iRespBodyFile.Close();
+					iCallbacks.FileError(error);
+					iHttpClient->ClientRequestCompleteL(error);
+					return;
+				}
+			
 			// Append to the output file if we're saving responses
 			if (iFileOpen)
 				{
@@ -239,6 +254,26 @@
 	DP1("CHttpEventHandler::SetSaveFileName, aContinue=%d", aContinue);
 	iFileName.Copy(fName);
 	iContinue = aContinue;
+	
+	switch(fName[0])
+		{
+		case 'C':
+			iDriveNo = EDriveC;
+			break;
+		case 'E':
+			iDriveNo = EDriveE;
+			break;
+		case 'F':
+			iDriveNo = EDriveF;
+			break;
+		case 'G':
+			iDriveNo = EDriveG;
+			break;
+		default:
+			iDriveNo = -1;
+			break;
+		}
+	DP1("iDriveNo set to %d", iDriveNo);
 	}
 
 void CHttpEventHandler::DumpRespHeadersL(RHTTPTransaction& aTrans)