browserutilities/downloadmgr/DownloadMgrServEng/Src/HttpStorage.cpp
changeset 38 6297cdf66332
parent 36 0ed94ceaa377
child 42 d39add9822e2
equal deleted inserted replaced
37:cb62a4f66ebe 38:6297cdf66332
   694                 CLOG_WRITE8_1( "Bad drive letter [%c]", drives[i] );
   694                 CLOG_WRITE8_1( "Bad drive letter [%c]", drives[i] );
   695                 }            
   695                 }            
   696             }
   696             }
   697         CleanupStack::PopAndDestroy( drivesDynList );
   697         CleanupStack::PopAndDestroy( drivesDynList );
   698         CLOG_WRITE_2( "Saving content to %d Drive with %d B free space", driveSpaceMax, freeSpaceMax );
   698         CLOG_WRITE_2( "Saving content to %d Drive with %d B free space", driveSpaceMax, freeSpaceMax );
   699         
   699         TUint aStatus ;
   700         TDriveInfo driveInfo;
   700 
   701     
   701         if( KErrNone == DriveInfo::GetDriveStatus( iDownload->ClientApp()->Engine()->Fs(), driveSpaceMax , aStatus ))
   702     	if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, driveSpaceMax) )
   702             {
   703         	{
   703             iRemovableStatus = (aStatus & DriveInfo::EDriveExternallyMountable) ? aStatus : 0 ;
   704         	iRemovableDest = (driveInfo.iDriveAtt & KDriveAttRemovable);
   704             if( iRemovableStatus )
   705         	CLOG_WRITE_1( "Removable: [%d]", iRemovableDest );
   705                 {
   706         	CLOG_WRITE_1( "driveInfo.iDriveAtt: [%d]", driveInfo.iDriveAtt );
   706                 iRemovableStatus = (aStatus & DriveInfo::EDriveRemovable) ? KDriveAttRemovable : KDriveAttInternal ;	
   707         	}
   707                 }
   708     	else
   708             else
   709         	{
   709                 {
   710         	CLOG_WRITE("DriveInfo failed");
   710                 iRemovableStatus = KDriveAttLocal  ;
   711         	}
   711                 }
       
   712             CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus );
       
   713             CLOG_WRITE_1( "DriveInfo Status [%d]", aStatus );        	
       
   714             }
       
   715         else
       
   716             {
       
   717             CLOG_WRITE("DriveStatus failed");
       
   718             }
   712         	
   719         	
   713         return driveSpaceMax;
   720         return driveSpaceMax;
   714 #else
   721 #else
   715         // If no MMC is inserted, this will leave (and not set mmcOk).
   722         // If no MMC is inserted, this will leave (and not set mmcOk).
   716         bytesToWrite = iLength;
   723         bytesToWrite = iLength;
   720         TBool mmcOk = EFalse;
   727         TBool mmcOk = EFalse;
   721         TRAP_IGNORE( mmcOk = !SysUtil::MMCSpaceBelowCriticalLevelL
   728         TRAP_IGNORE( mmcOk = !SysUtil::MMCSpaceBelowCriticalLevelL
   722         			       ( &fs, bytesToWrite ); )
   729         			       ( &fs, bytesToWrite ); )
   723         if(!mmcOk)
   730         if(!mmcOk)
   724         	{
   731         	{
       
   732             iRemovableStatus = TDownloadUiData::EDriveInternal ;
   725         	CLOG_WRITE( "no MMC present" );
   733         	CLOG_WRITE( "no MMC present" );
   726         	return EDriveC;
   734         	return EDriveC;
   727         	}
   735         	}
   728         CLOG_WRITE( "MMC is present " );        
   736         CLOG_WRITE( "MMC is present " );        
   729         TVolumeInfo volInfoC;
   737         TVolumeInfo volInfoC;
   730         TVolumeInfo volInfoE;
   738         TVolumeInfo volInfoE;
   731         fs.Volume(volInfoC,EDriveC);
   739         fs.Volume(volInfoC,EDriveC);
   732         fs.Volume(volInfoE,EDriveE);
   740         fs.Volume(volInfoE,EDriveE);
   733         TInt64 freeC = volInfoC.iFree;//free memory available in that drive
   741         TInt64 freeC = volInfoC.iFree;//free memory available in that drive
   734         TInt64 freeE = volInfoE.iFree;
   742         TInt64 freeE = volInfoE.iFree;
   735         return  freeC>=freeE?EDriveC:EDriveE;//put the file in which ever drive has more memory
   743         freeC>=freeE?EDriveC:EDriveE;//put the file in which ever drive has more memory
       
   744         iRemovableStatus = (EDriveC == freeC) ? TDownloadUiData::EDriveInternal : ( TDownloadUiData::EDriveExternallyMountable | TDownloadUiData::EDriveRemovable ) ;
       
   745         return freeC;
   736 #endif
   746 #endif
   737         }
   747         }
   738 
   748 
   739     // Destination is FFS in default
   749     // Destination is FFS in default
   740 #ifdef RD_MULTIPLE_DRIVE
   750 #ifdef RD_MULTIPLE_DRIVE
   821 #ifdef RD_MULTIPLE_DRIVE
   831 #ifdef RD_MULTIPLE_DRIVE
   822         CleanupStack::PopAndDestroy( drivesDynList );
   832         CleanupStack::PopAndDestroy( drivesDynList );
   823 #endif
   833 #endif
   824         }	
   834         }	
   825 
   835 
       
   836 #ifdef RD_MULTIPLE_DRIVE
       
   837     TUint aStatus ;
       
   838 
       
   839     if( KErrNone == DriveInfo::GetDriveStatus( iDownload->ClientApp()->Engine()->Fs(), drive , aStatus ))
       
   840         {
       
   841         iRemovableStatus = (aStatus & DriveInfo::EDriveExternallyMountable) ? aStatus : 0 ;
       
   842         if( iRemovableStatus )
       
   843             {
       
   844             iRemovableStatus = (aStatus & DriveInfo::EDriveRemovable) ? KDriveAttRemovable : KDriveAttInternal ;				
       
   845             }
       
   846         else
       
   847             {
       
   848             iRemovableStatus = KDriveAttLocal ;
       
   849             }
       
   850         CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus );
       
   851         CLOG_WRITE_1( "DriveInfo Status [%d]", aStatus );        	
       
   852         }
       
   853 	else
       
   854 		{
       
   855 		CLOG_WRITE("DriveStatus failed");
       
   856 		}
       
   857     
       
   858 #else
   826     TDriveInfo driveInfo;
   859     TDriveInfo driveInfo;
   827     
   860     
   828     if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, drive) )
   861     if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, drive) )
   829         {
   862         {
   830         iRemovableDest = (driveInfo.iDriveAtt & KDriveAttRemovable);
   863         if (driveInfo.iDriveAtt & KDriveAttRemovable)
   831         CLOG_WRITE_1( "Removable: [%d]", iRemovableDest );
   864             iRemovableStatus = ( TDownloadUiData::EDriveExternallyMountable | TDownloadUiData::EDriveRemovable ) ;
       
   865         else
       
   866             iRemovableStatus = TDownloadUiData::EDriveInternal ;
       
   867         CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus );
   832         }
   868         }
   833     else
   869     else
   834         {
   870         {        
   835         CLOG_WRITE("DriveInfo failed");
   871         CLOG_WRITE("DriveInfo failed");
   836         }
   872         }
   837 
   873 #endif
       
   874     
   838     if( err || !isSpace )
   875     if( err || !isSpace )
   839         {
   876         {
   840         CLOG_WRITE8( "OOD1" );
   877         CLOG_WRITE8( "OOD1" );
   841         iDownload->OnError( KErrDiskFull, EDiskFull );
   878         iDownload->OnError( KErrDiskFull, EDiskFull );
   842         User::Leave( KErrDiskFull );
   879         User::Leave( KErrDiskFull );
  1005         
  1042         
  1006     iDriveId = GetDestinationDriveId();
  1043     iDriveId = GetDestinationDriveId();
  1007     TInt drive;
  1044     TInt drive;
  1008     if( !iDownload->ClientApp()->Engine()->Fs().CharToDrive((*iDestFilename)[0], drive) )
  1045     if( !iDownload->ClientApp()->Engine()->Fs().CharToDrive((*iDestFilename)[0], drive) )
  1009         {
  1046         {
       
  1047 #ifdef RD_MULTIPLE_DRIVE
       
  1048         TUint aStatus ;
       
  1049 
       
  1050         if( KErrNone == DriveInfo::GetDriveStatus( iDownload->ClientApp()->Engine()->Fs(), drive , aStatus ))
       
  1051             {
       
  1052             iRemovableStatus = (aStatus & DriveInfo::EDriveExternallyMountable) ? aStatus : 0 ;
       
  1053             if( iRemovableStatus )
       
  1054                 {
       
  1055                 iRemovableStatus = (aStatus & DriveInfo::EDriveRemovable) ? KDriveAttRemovable : KDriveAttInternal ;				
       
  1056                 }
       
  1057             else
       
  1058                 {
       
  1059                 iRemovableStatus = KDriveAttLocal ;
       
  1060                 }
       
  1061             CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus );
       
  1062             CLOG_WRITE_1( "DriveInfo Status [%d]", aStatus );        	
       
  1063             }
       
  1064         else
       
  1065             {
       
  1066             CLOG_WRITE("DriveStatus failed");
       
  1067             }
       
  1068                 
       
  1069 #else        
  1010         TDriveInfo driveInfo;
  1070         TDriveInfo driveInfo;
       
  1071         
  1011         if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, drive) )
  1072         if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, drive) )
  1012             {
  1073             {
  1013             iRemovableDest = (driveInfo.iDriveAtt & KDriveAttRemovable);
  1074             if (driveInfo.iDriveAtt & KDriveAttRemovable)
  1014             CLOG_WRITE_1( "Removable: [%d]", iRemovableDest );
  1075             	iRemovableStatus = ( TDownloadUiData::EDriveExternallyMountable | TDownloadUiData::EDriveRemovable ) ;
       
  1076             else
       
  1077                 iRemovableStatus = TDownloadUiData::EDriveInternal ;
       
  1078             CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus );
  1015             }
  1079             }
  1016         else
  1080         else
  1017             {
  1081             {        
  1018             CLOG_WRITE("DriveInfo failed");
  1082             CLOG_WRITE("DriveInfo failed");
  1019             }
  1083             }        
       
  1084 #endif
  1020         }
  1085         }
  1021     else
  1086     else
  1022         {
  1087         {
  1023         CLOG_WRITE("CharToDrive failed");
  1088         CLOG_WRITE("CharToDrive failed");
  1024         }
  1089         }
  1041     APPEND_BUF_INT( aBuf, iStorageMethod );
  1106     APPEND_BUF_INT( aBuf, iStorageMethod );
  1042     APPEND_BUF_INT( aBuf, iProgressiveDownload);
  1107     APPEND_BUF_INT( aBuf, iProgressiveDownload);
  1043     APPEND_BUF_INT( aBuf, iDownloadedSize);
  1108     APPEND_BUF_INT( aBuf, iDownloadedSize);
  1044     AppendBufL( aBuf, iDdFilename );    
  1109     AppendBufL( aBuf, iDdFilename );    
  1045     APPEND_BUF_INT( aBuf, iDownload->iMoLength );
  1110     APPEND_BUF_INT( aBuf, iDownload->iMoLength );
  1046     APPEND_BUF_INT( aBuf, iRemovableDest );
  1111     APPEND_BUF_INT( aBuf, iRemovableStatus );
  1047 
  1112 
  1048     }
  1113     }
  1049 
  1114 
  1050 // -----------------------------------------------------------------------------
  1115 // -----------------------------------------------------------------------------
  1051 // CHttpStorage::SaveStorageInfoL
  1116 // CHttpStorage::SaveStorageInfoL
  1063     READ_INT_L( aInFile, iStorageMethod );
  1128     READ_INT_L( aInFile, iStorageMethod );
  1064     READ_INT_L( aInFile, iProgressiveDownload);
  1129     READ_INT_L( aInFile, iProgressiveDownload);
  1065     READ_INT_L( aInFile, iDownloadedSize );
  1130     READ_INT_L( aInFile, iDownloadedSize );
  1066     ReadHBufCL( aInFile, iDdFilename );
  1131     ReadHBufCL( aInFile, iDdFilename );
  1067     READ_INT_L( aInFile, iDownload->iMoLength  );
  1132     READ_INT_L( aInFile, iDownload->iMoLength  );
  1068     READ_INT_L( aInFile, iRemovableDest  );
  1133     READ_INT_L( aInFile, iRemovableStatus  );
  1069 
  1134 
  1070     }
  1135     }
  1071 
  1136 
  1072 // -----------------------------------------------------------------------------
  1137 // -----------------------------------------------------------------------------
  1073 // CHttpStorage::UpdateExtensionL
  1138 // CHttpStorage::UpdateExtensionL