67 // LOCAL FUNCTION PROTOTYPES |
67 // LOCAL FUNCTION PROTOTYPES |
68 //?type ?function_name( ?arg_type, ?arg_type ); |
68 //?type ?function_name( ?arg_type, ?arg_type ); |
69 |
69 |
70 // FORWARD DECLARATIONS |
70 // FORWARD DECLARATIONS |
71 //class ?FORWARD_CLASSNAME; |
71 //class ?FORWARD_CLASSNAME; |
|
72 |
|
73 //Music Store Warning Level Feature Flag |
|
74 #ifdef DOWNLOADMGR_WARNINGLEVEL_ENABLED_FF |
|
75 |
|
76 #include <uiklafinternalcrkeys.h> |
|
77 #include <centralrepository.h> |
|
78 |
|
79 //Beside the OOD threshold value, we need to reserve extra disk space |
|
80 //for harvest server do the harvest, set this as 1M |
|
81 const TInt KFreeSpaceExtraReserved(1024*1024); |
|
82 |
|
83 static TBool CheckFreeSpaceWarningThreshold( RFs& aFs, TInt aBytesToWrite, TInt aDrive ) |
|
84 { |
|
85 TBool isSpace = EFalse; |
|
86 CRepository* repository = NULL; |
|
87 TInt64 thresholdValue( 0 ); |
|
88 TVolumeInfo volumeInfo; |
|
89 TInt err = aFs.Volume( volumeInfo, aDrive ); |
|
90 if ( err == KErrNone ) // get warning threshold |
|
91 { |
|
92 TRAP( err, repository = CRepository::NewL( KCRUidUiklaf ) ); |
|
93 } |
|
94 if ( err == KErrNone ) |
|
95 { |
|
96 if ( volumeInfo.iDrive.iDriveAtt & KDriveAttRemovable ) // for E and F |
|
97 { |
|
98 TInt warningValue( 0 ); |
|
99 err = repository->Get( KUikOODDiskFreeSpaceWarningNoteLevelMassMemory, warningValue ); |
|
100 if ( err == KErrNone ) |
|
101 { |
|
102 thresholdValue = warningValue + KFreeSpaceExtraReserved; |
|
103 } |
|
104 } |
|
105 else |
|
106 { |
|
107 TInt warningUsagePercent( 0 ); |
|
108 err = repository->Get( KUikOODDiskFreeSpaceWarningNoteLevel, warningUsagePercent ); |
|
109 if ( err == KErrNone ) |
|
110 { |
|
111 thresholdValue = ( ( volumeInfo.iSize * ( 100 - warningUsagePercent ) ) / 100 ) |
|
112 + KFreeSpaceExtraReserved; |
|
113 } |
|
114 } |
|
115 delete repository; |
|
116 } |
|
117 if ( err == KErrNone ) // Check warning threshold |
|
118 { |
|
119 isSpace = volumeInfo.iFree > thresholdValue + aBytesToWrite; |
|
120 } |
|
121 return isSpace; |
|
122 } |
|
123 #endif |
72 |
124 |
73 // ============================ MEMBER FUNCTIONS =============================== |
125 // ============================ MEMBER FUNCTIONS =============================== |
74 |
126 |
75 // ----------------------------------------------------------------------------- |
127 // ----------------------------------------------------------------------------- |
76 // CHttpStorage::CHttpStorage |
128 // CHttpStorage::CHttpStorage |
790 // Check if there's enough memory in the phone |
842 // Check if there's enough memory in the phone |
791 bytesToWrite = iPartialLength + currentDownloadsLen; |
843 bytesToWrite = iPartialLength + currentDownloadsLen; |
792 if (bytesToWrite < 0) |
844 if (bytesToWrite < 0) |
793 bytesToWrite = 0; |
845 bytesToWrite = 0; |
794 |
846 |
|
847 // Let client handle warning level check, client may want to write until critical level |
795 TRAP( err, isSpace = !SysUtil::DiskSpaceBelowCriticalLevelL( |
848 TRAP( err, isSpace = !SysUtil::DiskSpaceBelowCriticalLevelL( |
796 &iDownload->ClientApp()->Engine()->Fs(), |
849 &iDownload->ClientApp()->Engine()->Fs(), |
797 bytesToWrite, |
850 bytesToWrite, |
798 drive )); |
851 drive )); |
799 } |
852 } |
803 HBufC8* drivesDynList = iDownload->ClientApp()->Engine()->QueryDynDriveListLC(); |
856 HBufC8* drivesDynList = iDownload->ClientApp()->Engine()->QueryDynDriveListLC(); |
804 TPtrC8 drives( *drivesDynList ); |
857 TPtrC8 drives( *drivesDynList ); |
805 #else |
858 #else |
806 TPtrC drives( iDownload->ClientApp()->Engine()->iDriveLettersCenRep ); |
859 TPtrC drives( iDownload->ClientApp()->Engine()->iDriveLettersCenRep ); |
807 #endif |
860 #endif |
808 |
861 //Music Store Warning Level Feature Flag |
809 // drive letters are separated by semicolons |
862 #ifdef DOWNLOADMGR_WARNINGLEVEL_ENABLED_FF |
810 for( TInt i = 0; i < drives.Length() && (err || !isSpace); i = i + 2 ) |
863 // Check warning or critical level and change drive if warning or critical level would get crossed |
811 { |
864 // On first round, check warning level only |
812 if( (err = fs.CharToDrive( drives[i], drive )) == KErrNone ) |
865 // On second round (all drives are about to cross warning level), check critical level |
813 { |
866 // When crossing warning level, user will see warning note regarding low disk space |
814 currentDownloadsLen = DMSrvEngine->AllDownloadsSizeInDriveL(iDownload, drive); |
867 for( TInt j = 0; j < 2 && (err || !isSpace); ++j ) |
815 |
868 { |
816 // Check if there's enough memory in the phone |
869 #endif |
817 bytesToWrite = iLength + currentDownloadsLen; |
870 // drive letters are separated by semicolons |
818 if (bytesToWrite < 0) |
871 for( TInt i = 0; i < drives.Length() && (err || !isSpace); i = i + 2 ) |
819 bytesToWrite = 0; |
872 { |
820 |
873 if( (err = fs.CharToDrive( drives[i], drive )) == KErrNone ) |
821 TRAP( err, isSpace = !SysUtil::DiskSpaceBelowCriticalLevelL( |
874 { |
822 &fs, |
875 currentDownloadsLen = DMSrvEngine->AllDownloadsSizeInDriveL(iDownload, drive); |
823 bytesToWrite, |
876 // Check if there's enough memory in the phone |
824 drive )); |
877 bytesToWrite = iLength + currentDownloadsLen; |
825 } |
878 if (bytesToWrite < 0) |
826 else |
879 bytesToWrite = 0; |
827 { |
880 //Music Store Warning Level Feature Flag |
828 CLOG_WRITE8_1( "Bad drive letter [%c]", drives[i] ); |
881 #ifdef DOWNLOADMGR_WARNINGLEVEL_ENABLED_FF |
829 } |
882 |
830 } |
883 if ( !j ) // check warning level on first round |
|
884 { |
|
885 isSpace = CheckFreeSpaceWarningThreshold( fs, bytesToWrite, drive ); |
|
886 } |
|
887 else // check critical level when all drives are about to cross warning level |
|
888 { |
|
889 TRAP( err, isSpace = !SysUtil::DiskSpaceBelowCriticalLevelL( |
|
890 &fs, bytesToWrite, drive )); |
|
891 } |
|
892 CLOG_WRITE8_4( "Free space check type %d drive %d isSpace %d, bytesToWrite %d", |
|
893 j,drive,isSpace,bytesToWrite); |
|
894 #else if |
|
895 TRAP( err, isSpace = !SysUtil::DiskSpaceBelowCriticalLevelL( |
|
896 &fs, bytesToWrite, drive )); |
|
897 |
|
898 #endif |
|
899 } |
|
900 else |
|
901 { |
|
902 CLOG_WRITE8_1( "Bad drive letter [%c]", drives[i] ); |
|
903 } |
|
904 } |
|
905 //Music Store Warning Level Feature Flag |
|
906 #ifdef DOWNLOADMGR_WARNINGLEVEL_ENABLED_FF |
|
907 } |
|
908 #endif |
831 #ifdef RD_MULTIPLE_DRIVE |
909 #ifdef RD_MULTIPLE_DRIVE |
832 CleanupStack::PopAndDestroy( drivesDynList ); |
910 CleanupStack::PopAndDestroy( drivesDynList ); |
833 #endif |
911 #endif |
834 } |
912 } |
835 |
913 |