17 |
17 |
18 |
18 |
19 |
19 |
20 // INCLUDE FILES |
20 // INCLUDE FILES |
21 #include <bldvariant.hrh> |
21 #include <bldvariant.hrh> |
22 #include <Browser_platform_variant.hrh> |
22 #include <browser_platform_variant.hrh> |
23 |
23 |
24 #include "FileExt.h" |
24 #include "FileExt.h" |
25 #include "HttpClientApp.h" |
25 #include "HttpClientApp.h" |
26 #include "HttpDownload.h" |
26 #include "HttpDownload.h" |
27 #include "HttpStorage.h" |
27 #include "HttpStorage.h" |
28 #include "HttpDownloadManagerServerEngine.h" |
28 #include "HttpDownloadManagerServerEngine.h" |
29 #include "HttpDownloadMgrLogger.h" |
29 #include "HttpDownloadMgrLogger.h" |
30 #include "HeaderField.h" |
30 #include "HeaderField.h" |
31 #include "BuffStorage.h" |
31 #include "BuffStorage.h" |
32 |
32 |
33 #include <sysutil.h> |
33 #include <SysUtil.h> |
34 #include <DocumentHandler.h> |
34 #include <DocumentHandler.h> |
35 #include <apmstd.h> |
35 #include <APMSTD.H> |
36 |
36 |
37 #ifdef __SYNCML_DM_FOTA |
37 #ifdef __SYNCML_DM_FOTA |
38 #include <fotaengine.h> |
38 #include <fotaengine.h> |
39 #endif |
39 #endif |
40 |
40 |
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 |
694 CLOG_WRITE8_1( "Bad drive letter [%c]", drives[i] ); |
746 CLOG_WRITE8_1( "Bad drive letter [%c]", drives[i] ); |
695 } |
747 } |
696 } |
748 } |
697 CleanupStack::PopAndDestroy( drivesDynList ); |
749 CleanupStack::PopAndDestroy( drivesDynList ); |
698 CLOG_WRITE_2( "Saving content to %d Drive with %d B free space", driveSpaceMax, freeSpaceMax ); |
750 CLOG_WRITE_2( "Saving content to %d Drive with %d B free space", driveSpaceMax, freeSpaceMax ); |
699 |
751 TUint aStatus ; |
700 TDriveInfo driveInfo; |
752 |
701 |
753 if( KErrNone == DriveInfo::GetDriveStatus( iDownload->ClientApp()->Engine()->Fs(), driveSpaceMax , aStatus )) |
702 if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, driveSpaceMax) ) |
754 { |
703 { |
755 iRemovableStatus = (aStatus & DriveInfo::EDriveExternallyMountable) ? aStatus : 0 ; |
704 iRemovableDest = (driveInfo.iDriveAtt & KDriveAttRemovable); |
756 if( iRemovableStatus ) |
705 CLOG_WRITE_1( "Removable: [%d]", iRemovableDest ); |
757 { |
706 CLOG_WRITE_1( "driveInfo.iDriveAtt: [%d]", driveInfo.iDriveAtt ); |
758 iRemovableStatus = (aStatus & DriveInfo::EDriveRemovable) ? KDriveAttRemovable : KDriveAttInternal ; |
707 } |
759 } |
708 else |
760 else |
709 { |
761 { |
710 CLOG_WRITE("DriveInfo failed"); |
762 iRemovableStatus = KDriveAttLocal ; |
711 } |
763 } |
|
764 CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus ); |
|
765 CLOG_WRITE_1( "DriveInfo Status [%d]", aStatus ); |
|
766 } |
|
767 else |
|
768 { |
|
769 CLOG_WRITE("DriveStatus failed"); |
|
770 } |
712 |
771 |
713 return driveSpaceMax; |
772 return driveSpaceMax; |
714 #else |
773 #else |
715 // If no MMC is inserted, this will leave (and not set mmcOk). |
774 // If no MMC is inserted, this will leave (and not set mmcOk). |
716 bytesToWrite = iLength; |
775 bytesToWrite = iLength; |
720 TBool mmcOk = EFalse; |
779 TBool mmcOk = EFalse; |
721 TRAP_IGNORE( mmcOk = !SysUtil::MMCSpaceBelowCriticalLevelL |
780 TRAP_IGNORE( mmcOk = !SysUtil::MMCSpaceBelowCriticalLevelL |
722 ( &fs, bytesToWrite ); ) |
781 ( &fs, bytesToWrite ); ) |
723 if(!mmcOk) |
782 if(!mmcOk) |
724 { |
783 { |
|
784 iRemovableStatus = KDriveAttInternal ; |
725 CLOG_WRITE( "no MMC present" ); |
785 CLOG_WRITE( "no MMC present" ); |
726 return EDriveC; |
786 return EDriveC; |
727 } |
787 } |
728 CLOG_WRITE( "MMC is present " ); |
788 CLOG_WRITE( "MMC is present " ); |
729 TVolumeInfo volInfoC; |
789 TVolumeInfo volInfoC; |
730 TVolumeInfo volInfoE; |
790 TVolumeInfo volInfoE; |
731 fs.Volume(volInfoC,EDriveC); |
791 fs.Volume(volInfoC,EDriveC); |
732 fs.Volume(volInfoE,EDriveE); |
792 fs.Volume(volInfoE,EDriveE); |
733 TInt64 freeC = volInfoC.iFree;//free memory available in that drive |
793 TInt64 freeC = volInfoC.iFree;//free memory available in that drive |
734 TInt64 freeE = volInfoE.iFree; |
794 TInt64 freeE = volInfoE.iFree; |
735 return freeC>=freeE?EDriveC:EDriveE;//put the file in which ever drive has more memory |
795 freeC = freeE?EDriveC:EDriveE;//put the file in which ever drive has more memory |
|
796 iRemovableStatus = (EDriveC == freeC) ? KDriveAttInternal : KDriveAttRemovable ; |
|
797 return freeC; |
736 #endif |
798 #endif |
737 } |
799 } |
738 |
800 |
739 // Destination is FFS in default |
801 // Destination is FFS in default |
740 #ifdef RD_MULTIPLE_DRIVE |
802 #ifdef RD_MULTIPLE_DRIVE |
793 HBufC8* drivesDynList = iDownload->ClientApp()->Engine()->QueryDynDriveListLC(); |
856 HBufC8* drivesDynList = iDownload->ClientApp()->Engine()->QueryDynDriveListLC(); |
794 TPtrC8 drives( *drivesDynList ); |
857 TPtrC8 drives( *drivesDynList ); |
795 #else |
858 #else |
796 TPtrC drives( iDownload->ClientApp()->Engine()->iDriveLettersCenRep ); |
859 TPtrC drives( iDownload->ClientApp()->Engine()->iDriveLettersCenRep ); |
797 #endif |
860 #endif |
798 |
861 //Music Store Warning Level Feature Flag |
799 // drive letters are separated by semicolons |
862 #ifdef DOWNLOADMGR_WARNINGLEVEL_ENABLED_FF |
800 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 |
801 { |
864 // On first round, check warning level only |
802 if( (err = fs.CharToDrive( drives[i], drive )) == KErrNone ) |
865 // On second round (all drives are about to cross warning level), check critical level |
803 { |
866 // When crossing warning level, user will see warning note regarding low disk space |
804 currentDownloadsLen = DMSrvEngine->AllDownloadsSizeInDriveL(iDownload, drive); |
867 for( TInt j = 0; j < 2 && (err || !isSpace); ++j ) |
805 |
868 { |
806 // Check if there's enough memory in the phone |
869 #endif |
807 bytesToWrite = iLength + currentDownloadsLen; |
870 // drive letters are separated by semicolons |
808 if (bytesToWrite < 0) |
871 for( TInt i = 0; i < drives.Length() && (err || !isSpace); i = i + 2 ) |
809 bytesToWrite = 0; |
872 { |
810 |
873 if( (err = fs.CharToDrive( drives[i], drive )) == KErrNone ) |
811 TRAP( err, isSpace = !SysUtil::DiskSpaceBelowCriticalLevelL( |
874 { |
812 &fs, |
875 currentDownloadsLen = DMSrvEngine->AllDownloadsSizeInDriveL(iDownload, drive); |
813 bytesToWrite, |
876 // Check if there's enough memory in the phone |
814 drive )); |
877 bytesToWrite = iLength + currentDownloadsLen; |
815 } |
878 if (bytesToWrite < 0) |
816 else |
879 bytesToWrite = 0; |
817 { |
880 //Music Store Warning Level Feature Flag |
818 CLOG_WRITE8_1( "Bad drive letter [%c]", drives[i] ); |
881 #ifdef DOWNLOADMGR_WARNINGLEVEL_ENABLED_FF |
819 } |
882 |
820 } |
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 |
821 #ifdef RD_MULTIPLE_DRIVE |
909 #ifdef RD_MULTIPLE_DRIVE |
822 CleanupStack::PopAndDestroy( drivesDynList ); |
910 CleanupStack::PopAndDestroy( drivesDynList ); |
823 #endif |
911 #endif |
824 } |
912 } |
825 |
913 |
|
914 #ifdef RD_MULTIPLE_DRIVE |
|
915 TUint aStatus ; |
|
916 |
|
917 if( KErrNone == DriveInfo::GetDriveStatus( iDownload->ClientApp()->Engine()->Fs(), drive , aStatus )) |
|
918 { |
|
919 iRemovableStatus = (aStatus & DriveInfo::EDriveExternallyMountable) ? aStatus : 0 ; |
|
920 if( iRemovableStatus ) |
|
921 { |
|
922 iRemovableStatus = (aStatus & DriveInfo::EDriveRemovable) ? KDriveAttRemovable : KDriveAttInternal ; |
|
923 } |
|
924 else |
|
925 { |
|
926 iRemovableStatus = KDriveAttLocal ; |
|
927 } |
|
928 CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus ); |
|
929 CLOG_WRITE_1( "DriveInfo Status [%d]", aStatus ); |
|
930 } |
|
931 else |
|
932 { |
|
933 CLOG_WRITE("DriveStatus failed"); |
|
934 } |
|
935 |
|
936 #else |
826 TDriveInfo driveInfo; |
937 TDriveInfo driveInfo; |
827 |
938 |
828 if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, drive) ) |
939 if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, drive) ) |
829 { |
940 { |
830 iRemovableDest = (driveInfo.iDriveAtt & KDriveAttRemovable); |
941 if (driveInfo.iDriveAtt & KDriveAttRemovable) |
831 CLOG_WRITE_1( "Removable: [%d]", iRemovableDest ); |
942 iRemovableStatus = KDriveAttRemovable ; |
|
943 else |
|
944 iRemovableStatus = KDriveAttInternal ; |
|
945 CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus ); |
832 } |
946 } |
833 else |
947 else |
834 { |
948 { |
835 CLOG_WRITE("DriveInfo failed"); |
949 CLOG_WRITE("DriveInfo failed"); |
836 } |
950 } |
837 |
951 #endif |
|
952 |
838 if( err || !isSpace ) |
953 if( err || !isSpace ) |
839 { |
954 { |
840 CLOG_WRITE8( "OOD1" ); |
955 CLOG_WRITE8( "OOD1" ); |
841 iDownload->OnError( KErrDiskFull, EDiskFull ); |
956 iDownload->OnError( KErrDiskFull, EDiskFull ); |
842 User::Leave( KErrDiskFull ); |
957 User::Leave( KErrDiskFull ); |
1005 |
1120 |
1006 iDriveId = GetDestinationDriveId(); |
1121 iDriveId = GetDestinationDriveId(); |
1007 TInt drive; |
1122 TInt drive; |
1008 if( !iDownload->ClientApp()->Engine()->Fs().CharToDrive((*iDestFilename)[0], drive) ) |
1123 if( !iDownload->ClientApp()->Engine()->Fs().CharToDrive((*iDestFilename)[0], drive) ) |
1009 { |
1124 { |
|
1125 #ifdef RD_MULTIPLE_DRIVE |
|
1126 TUint aStatus ; |
|
1127 |
|
1128 if( KErrNone == DriveInfo::GetDriveStatus( iDownload->ClientApp()->Engine()->Fs(), drive , aStatus )) |
|
1129 { |
|
1130 iRemovableStatus = (aStatus & DriveInfo::EDriveExternallyMountable) ? aStatus : 0 ; |
|
1131 if( iRemovableStatus ) |
|
1132 { |
|
1133 iRemovableStatus = (aStatus & DriveInfo::EDriveRemovable) ? KDriveAttRemovable : KDriveAttInternal ; |
|
1134 } |
|
1135 else |
|
1136 { |
|
1137 iRemovableStatus = KDriveAttLocal ; |
|
1138 } |
|
1139 CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus ); |
|
1140 CLOG_WRITE_1( "DriveInfo Status [%d]", aStatus ); |
|
1141 } |
|
1142 else |
|
1143 { |
|
1144 CLOG_WRITE("DriveStatus failed"); |
|
1145 } |
|
1146 |
|
1147 #else |
1010 TDriveInfo driveInfo; |
1148 TDriveInfo driveInfo; |
|
1149 |
1011 if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, drive) ) |
1150 if( !iDownload->ClientApp()->Engine()->Fs().Drive( driveInfo, drive) ) |
1012 { |
1151 { |
1013 iRemovableDest = (driveInfo.iDriveAtt & KDriveAttRemovable); |
1152 if (driveInfo.iDriveAtt & KDriveAttRemovable) |
1014 CLOG_WRITE_1( "Removable: [%d]", iRemovableDest ); |
1153 iRemovableStatus = KDriveAttRemovable ; |
|
1154 else |
|
1155 iRemovableStatus = KDriveAttInternal ; |
|
1156 CLOG_WRITE_1( "Removable: [%d]", iRemovableStatus ); |
1015 } |
1157 } |
1016 else |
1158 else |
1017 { |
1159 { |
1018 CLOG_WRITE("DriveInfo failed"); |
1160 CLOG_WRITE("DriveInfo failed"); |
1019 } |
1161 } |
|
1162 #endif |
1020 } |
1163 } |
1021 else |
1164 else |
1022 { |
1165 { |
1023 CLOG_WRITE("CharToDrive failed"); |
1166 CLOG_WRITE("CharToDrive failed"); |
1024 } |
1167 } |
1041 APPEND_BUF_INT( aBuf, iStorageMethod ); |
1184 APPEND_BUF_INT( aBuf, iStorageMethod ); |
1042 APPEND_BUF_INT( aBuf, iProgressiveDownload); |
1185 APPEND_BUF_INT( aBuf, iProgressiveDownload); |
1043 APPEND_BUF_INT( aBuf, iDownloadedSize); |
1186 APPEND_BUF_INT( aBuf, iDownloadedSize); |
1044 AppendBufL( aBuf, iDdFilename ); |
1187 AppendBufL( aBuf, iDdFilename ); |
1045 APPEND_BUF_INT( aBuf, iDownload->iMoLength ); |
1188 APPEND_BUF_INT( aBuf, iDownload->iMoLength ); |
1046 APPEND_BUF_INT( aBuf, iRemovableDest ); |
1189 APPEND_BUF_INT( aBuf, iRemovableStatus ); |
1047 |
1190 |
1048 } |
1191 } |
1049 |
1192 |
1050 // ----------------------------------------------------------------------------- |
1193 // ----------------------------------------------------------------------------- |
1051 // CHttpStorage::SaveStorageInfoL |
1194 // CHttpStorage::SaveStorageInfoL |
1063 READ_INT_L( aInFile, iStorageMethod ); |
1206 READ_INT_L( aInFile, iStorageMethod ); |
1064 READ_INT_L( aInFile, iProgressiveDownload); |
1207 READ_INT_L( aInFile, iProgressiveDownload); |
1065 READ_INT_L( aInFile, iDownloadedSize ); |
1208 READ_INT_L( aInFile, iDownloadedSize ); |
1066 ReadHBufCL( aInFile, iDdFilename ); |
1209 ReadHBufCL( aInFile, iDdFilename ); |
1067 READ_INT_L( aInFile, iDownload->iMoLength ); |
1210 READ_INT_L( aInFile, iDownload->iMoLength ); |
1068 READ_INT_L( aInFile, iRemovableDest ); |
1211 READ_INT_L( aInFile, iRemovableStatus ); |
1069 |
1212 |
1070 } |
1213 } |
1071 |
1214 |
1072 // ----------------------------------------------------------------------------- |
1215 // ----------------------------------------------------------------------------- |
1073 // CHttpStorage::UpdateExtensionL |
1216 // CHttpStorage::UpdateExtensionL |