browserutilities/downloadmgr/DownloadMgrServEng/Src/HttpStorage.cpp
branchRCL_3
changeset 93 79859ed3eea9
parent 92 e1bea15f9a39
child 94 919f36ff910f
--- a/browserutilities/downloadmgr/DownloadMgrServEng/Src/HttpStorage.cpp	Thu Aug 19 10:58:56 2010 +0300
+++ b/browserutilities/downloadmgr/DownloadMgrServEng/Src/HttpStorage.cpp	Tue Aug 31 16:17:46 2010 +0300
@@ -19,7 +19,7 @@
 
 // INCLUDE FILES
 #include <bldvariant.hrh>
-#include <browser_platform_variant.hrh>
+#include <Browser_platform_variant.hrh>
 
 #include "FileExt.h"
 #include "HttpClientApp.h"
@@ -30,9 +30,9 @@
 #include "HeaderField.h"
 #include "BuffStorage.h"
 
-#include <SysUtil.h>
+#include <sysutil.h>
 #include <DocumentHandler.h>
-#include <APMSTD.H>
+#include <apmstd.h>
 
 #ifdef __SYNCML_DM_FOTA
 #include <fotaengine.h>
@@ -70,58 +70,6 @@
 // FORWARD DECLARATIONS
 //class ?FORWARD_CLASSNAME;
 
-//Music Store Warning Level Feature Flag
-#ifdef DOWNLOADMGR_WARNINGLEVEL_ENABLED_FF
-
-#include <uiklafinternalcrkeys.h>
-#include <centralrepository.h>
-
-//Beside the OOD threshold value, we need to reserve extra disk space
-//for harvest server do the harvest, set this as 1M
-const TInt KFreeSpaceExtraReserved(1024*1024);
-
-static TBool CheckFreeSpaceWarningThreshold( RFs& aFs, TInt aBytesToWrite, TInt aDrive )
-    {
-    TBool isSpace = EFalse;
-    CRepository* repository = NULL;
-    TInt64 thresholdValue( 0 );
-    TVolumeInfo volumeInfo;
-    TInt err = aFs.Volume( volumeInfo, aDrive );
-    if ( err == KErrNone ) // get warning threshold
-        {
-        TRAP( err, repository = CRepository::NewL( KCRUidUiklaf ) );
-        }
-    if ( err == KErrNone )
-        {
-        if ( volumeInfo.iDrive.iDriveAtt & KDriveAttRemovable ) // for E and F
-            {
-            TInt warningValue( 0 );
-            err = repository->Get( KUikOODDiskFreeSpaceWarningNoteLevelMassMemory, warningValue );
-            if ( err == KErrNone )
-                {
-                thresholdValue = warningValue + KFreeSpaceExtraReserved;
-                }
-            }
-        else
-            {
-            TInt warningUsagePercent( 0 );
-            err = repository->Get( KUikOODDiskFreeSpaceWarningNoteLevel, warningUsagePercent );
-            if ( err == KErrNone )
-                {
-                thresholdValue = ( ( volumeInfo.iSize * ( 100 - warningUsagePercent ) ) / 100 )
-                    + KFreeSpaceExtraReserved;
-                }
-            }
-        delete repository;
-        }
-    if ( err == KErrNone ) // Check warning threshold
-        {
-        isSpace = volumeInfo.iFree > thresholdValue + aBytesToWrite;
-        }
-    return isSpace;
-    }
-#endif
-
 // ============================ MEMBER FUNCTIONS ===============================
 
 // -----------------------------------------------------------------------------
@@ -748,26 +696,19 @@
             }
         CleanupStack::PopAndDestroy( drivesDynList );
         CLOG_WRITE_2( "Saving content to %d Drive with %d B free space", driveSpaceMax, freeSpaceMax );
-        TUint aStatus ;
-
-        if( KErrNone == DriveInfo::GetDriveStatus( iDownload->ClientApp()->Engine()->Fs(), driveSpaceMax , aStatus ))
-            {
-            iRemovableStatus = (aStatus & DriveInfo::EDriveExternallyMountable) ? aStatus : 0 ;
-            if( iRemovableStatus )
-                {
-                iRemovableStatus = (aStatus & DriveInfo::EDriveRemovable) ? KDriveAttRemovable : KDriveAttInternal ;	
-                }
-            else
-                {
-                iRemovableStatus = KDriveAttLocal  ;
-                }
-            CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus );
-            CLOG_WRITE_1( "DriveInfo Status [%d]", aStatus );        	
-            }
-        else
-            {
-            CLOG_WRITE("DriveStatus failed");
-            }
+        
+        TDriveInfo driveInfo;
+    
+    	if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, driveSpaceMax) )
+        	{
+        	iRemovableDest = (driveInfo.iDriveAtt & KDriveAttRemovable);
+        	CLOG_WRITE_1( "Removable: [%d]", iRemovableDest );
+        	CLOG_WRITE_1( "driveInfo.iDriveAtt: [%d]", driveInfo.iDriveAtt );
+        	}
+    	else
+        	{
+        	CLOG_WRITE("DriveInfo failed");
+        	}
         	
         return driveSpaceMax;
 #else
@@ -781,7 +722,6 @@
         			       ( &fs, bytesToWrite ); )
         if(!mmcOk)
         	{
-            iRemovableStatus = KDriveAttInternal ;
         	CLOG_WRITE( "no MMC present" );
         	return EDriveC;
         	}
@@ -792,9 +732,7 @@
         fs.Volume(volInfoE,EDriveE);
         TInt64 freeC = volInfoC.iFree;//free memory available in that drive
         TInt64 freeE = volInfoE.iFree;
-        freeC = freeE?EDriveC:EDriveE;//put the file in which ever drive has more memory
-        iRemovableStatus = (EDriveC == freeC) ? KDriveAttInternal :  KDriveAttRemovable ;
-        return freeC;
+        return  freeC>=freeE?EDriveC:EDriveE;//put the file in which ever drive has more memory
 #endif
         }
 
@@ -844,7 +782,6 @@
         if (bytesToWrite < 0)
             bytesToWrite = 0;
         
-        // Let client handle warning level check, client may want to write until critical level
 	    TRAP( err, isSpace = !SysUtil::DiskSpaceBelowCriticalLevelL(
                                                 &iDownload->ClientApp()->Engine()->Fs(),
 			                                    bytesToWrite,
@@ -858,98 +795,46 @@
 #else
         TPtrC drives( iDownload->ClientApp()->Engine()->iDriveLettersCenRep );
 #endif
-//Music Store Warning Level Feature Flag
-#ifdef DOWNLOADMGR_WARNINGLEVEL_ENABLED_FF        
-        // Check warning or critical level and change drive if warning or critical level would get crossed
-        // On first round, check warning level only
-        // On second round (all drives are about to cross warning level), check critical level
-        // When crossing warning level, user will see warning note regarding low disk space
-        for( TInt j = 0; j < 2 && (err || !isSpace); ++j )
+        
+        // drive letters are separated by semicolons
+        for( TInt i = 0; i < drives.Length() && (err || !isSpace); i = i + 2 )
             {
-#endif
-            // drive letters are separated by semicolons
-            for( TInt i = 0; i < drives.Length() && (err || !isSpace); i = i + 2 )
+            if( (err = fs.CharToDrive( drives[i], drive )) == KErrNone )
                 {
-                if( (err = fs.CharToDrive( drives[i], drive )) == KErrNone )
-                    {
-                    currentDownloadsLen = DMSrvEngine->AllDownloadsSizeInDriveL(iDownload, drive);
-                    // Check if there's enough memory in the phone
-                    bytesToWrite = iLength + currentDownloadsLen;
-                    if (bytesToWrite < 0)
-                        bytesToWrite = 0;
-//Music Store Warning Level Feature Flag
-#ifdef DOWNLOADMGR_WARNINGLEVEL_ENABLED_FF
+                currentDownloadsLen = DMSrvEngine->AllDownloadsSizeInDriveL(iDownload, drive);
 
-                    if ( !j ) // check warning level on first round
-                        {
-                        isSpace = CheckFreeSpaceWarningThreshold( fs, bytesToWrite, drive );
-                        }
-                    else // check critical level when all drives are about to cross warning level
-                        {
-                	    TRAP( err, isSpace = !SysUtil::DiskSpaceBelowCriticalLevelL(
-                            &fs, bytesToWrite, drive ));
-                        }
-                    CLOG_WRITE8_4( "Free space check type %d drive %d isSpace %d, bytesToWrite %d",
-                        j,drive,isSpace,bytesToWrite);
-#else if
-                       	    TRAP( err, isSpace = !SysUtil::DiskSpaceBelowCriticalLevelL(
-                            &fs, bytesToWrite, drive ));
-
-#endif
-                    }
-                else
-                    {
-                    CLOG_WRITE8_1( "Bad drive letter [%c]", drives[i] );
-                    }
+                // Check if there's enough memory in the phone
+                bytesToWrite = iLength + currentDownloadsLen;
+                if (bytesToWrite < 0)
+                    bytesToWrite = 0;
+                
+        	    TRAP( err, isSpace = !SysUtil::DiskSpaceBelowCriticalLevelL(
+                                                        &fs,
+        			                                    bytesToWrite,
+                                                        drive ));
                 }
-//Music Store Warning Level Feature Flag
-#ifdef DOWNLOADMGR_WARNINGLEVEL_ENABLED_FF
+            else
+                {
+                CLOG_WRITE8_1( "Bad drive letter [%c]", drives[i] );
+                }            
             }
-#endif
 #ifdef RD_MULTIPLE_DRIVE
         CleanupStack::PopAndDestroy( drivesDynList );
 #endif
         }	
 
-#ifdef RD_MULTIPLE_DRIVE
-    TUint aStatus ;
-
-    if( KErrNone == DriveInfo::GetDriveStatus( iDownload->ClientApp()->Engine()->Fs(), drive , aStatus ))
-        {
-        iRemovableStatus = (aStatus & DriveInfo::EDriveExternallyMountable) ? aStatus : 0 ;
-        if( iRemovableStatus )
-            {
-            iRemovableStatus = (aStatus & DriveInfo::EDriveRemovable) ? KDriveAttRemovable : KDriveAttInternal ;				
-            }
-        else
-            {
-            iRemovableStatus = KDriveAttLocal ;
-            }
-        CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus );
-        CLOG_WRITE_1( "DriveInfo Status [%d]", aStatus );        	
-        }
-	else
-		{
-		CLOG_WRITE("DriveStatus failed");
-		}
-    
-#else
     TDriveInfo driveInfo;
     
     if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, drive) )
         {
-        if (driveInfo.iDriveAtt & KDriveAttRemovable)
-            iRemovableStatus =  KDriveAttRemovable ;
-        else
-            iRemovableStatus = KDriveAttInternal ;
-        CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus );
+        iRemovableDest = (driveInfo.iDriveAtt & KDriveAttRemovable);
+        CLOG_WRITE_1( "Removable: [%d]", iRemovableDest );
         }
     else
-        {        
+        {
         CLOG_WRITE("DriveInfo failed");
         }
-#endif
-    
+
     if( err || !isSpace )
         {
         CLOG_WRITE8( "OOD1" );
@@ -1122,44 +1007,16 @@
     TInt drive;
     if( !iDownload->ClientApp()->Engine()->Fs().CharToDrive((*iDestFilename)[0], drive) )
         {
-#ifdef RD_MULTIPLE_DRIVE
-        TUint aStatus ;
-
-        if( KErrNone == DriveInfo::GetDriveStatus( iDownload->ClientApp()->Engine()->Fs(), drive , aStatus ))
+        TDriveInfo driveInfo;
+        if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, drive) )
             {
-            iRemovableStatus = (aStatus & DriveInfo::EDriveExternallyMountable) ? aStatus : 0 ;
-            if( iRemovableStatus )
-                {
-                iRemovableStatus = (aStatus & DriveInfo::EDriveRemovable) ? KDriveAttRemovable : KDriveAttInternal ;				
-                }
-            else
-                {
-                iRemovableStatus = KDriveAttLocal ;
-                }
-            CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus );
-            CLOG_WRITE_1( "DriveInfo Status [%d]", aStatus );        	
+            iRemovableDest = (driveInfo.iDriveAtt & KDriveAttRemovable);
+            CLOG_WRITE_1( "Removable: [%d]", iRemovableDest );
             }
         else
             {
-            CLOG_WRITE("DriveStatus failed");
+            CLOG_WRITE("DriveInfo failed");
             }
-                
-#else        
-        TDriveInfo driveInfo;
-        
-        if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, drive) )
-            {
-            if (driveInfo.iDriveAtt & KDriveAttRemovable)
-            	iRemovableStatus = KDriveAttRemovable ;
-            else
-                iRemovableStatus = KDriveAttInternal ;
-            CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus );
-            }
-        else
-            {        
-            CLOG_WRITE("DriveInfo failed");
-            }        
-#endif
         }
     else
         {
@@ -1186,7 +1043,7 @@
     APPEND_BUF_INT( aBuf, iDownloadedSize);
     AppendBufL( aBuf, iDdFilename );    
     APPEND_BUF_INT( aBuf, iDownload->iMoLength );
-    APPEND_BUF_INT( aBuf, iRemovableStatus );
+    APPEND_BUF_INT( aBuf, iRemovableDest );
 
     }
 
@@ -1208,7 +1065,7 @@
     READ_INT_L( aInFile, iDownloadedSize );
     ReadHBufCL( aInFile, iDdFilename );
     READ_INT_L( aInFile, iDownload->iMoLength  );
-    READ_INT_L( aInFile, iRemovableStatus  );
+    READ_INT_L( aInFile, iRemovableDest  );
 
     }