15 |
15 |
16 /** |
16 /** |
17 @file |
17 @file |
18 @publishedPartner |
18 @publishedPartner |
19 */ |
19 */ |
20 |
20 #include <centralrepository.h> |
21 #include <mtp/cmtptypefile.h> |
21 #include <mtp/cmtptypefile.h> |
22 #include <mtp/mtpdatatypeconstants.h> |
22 #include <mtp/mtpdatatypeconstants.h> |
23 |
23 |
|
24 #include "mtpframeworkconst.h" |
|
25 |
|
26 //This file is exported from s60 sdk, now just copy it |
|
27 //to make sure onb can run |
|
28 #include "UiklafInternalCRKeys.h" |
|
29 |
24 // File type constants. |
30 // File type constants. |
25 const TInt KMTPFileChunkSizeForLargeFile(0x00080000); // 512K |
31 const TInt KMTPFileChunkSizeForLargeFile(0x00080000); // 512K |
26 |
32 |
27 //For file size less than 512K, we will use this smaller chunk size to reduce the heap usage. |
33 //For file size less than 512K, we will use this smaller chunk size to reduce the heap usage. |
28 const TInt KMTPFileChunkSizeForSmallFile(0x00010000); //64K |
34 const TInt KMTPFileChunkSizeForSmallFile(0x00010000); //64K |
29 |
35 |
30 //For file size larger than it, we will split one setSize() to several smaller one, each with the following size. |
36 //For file size larger than it, we will split one setSize() to several smaller one, each with the following size. |
31 const TInt64 KMTPFileSetSizeChunk(1<<30); //1G |
37 const TInt64 KMTPFileSetSizeChunk(1<<30); //1G |
32 |
38 |
33 const TUint KUSBHeaderLen = 12; |
39 const TUint KUSBHeaderLen = 12; |
34 |
|
35 //MTP should reserve some disk space to prevent ood monitor popup |
|
36 //'Out of memory' note.When syncing music through ovi suite, |
|
37 //sometimes device screen get freeze with this note |
|
38 //If you need to adjust this value,please also update the definition |
|
39 //in file 'cmtpgetstorageinfo.cpp' |
|
40 const TInt KFreeSpaceThreshHoldValue(11*1024*1024);//11M |
|
41 |
|
42 |
40 |
43 CMTPTypeFile::CFileWriter* CMTPTypeFile::CFileWriter::NewL(RFile& aFile, RBuf8& aWriteBuf) |
41 CMTPTypeFile::CFileWriter* CMTPTypeFile::CFileWriter::NewL(RFile& aFile, RBuf8& aWriteBuf) |
44 { |
42 { |
45 CFileWriter *self = new(ELeave)CFileWriter(aFile, aWriteBuf); |
43 CFileWriter *self = new(ELeave)CFileWriter(aFile, aWriteBuf); |
46 CleanupStack::PushL(self); |
44 CleanupStack::PushL(self); |
195 TVolumeInfo volumeInfo; |
193 TVolumeInfo volumeInfo; |
196 fs.Connect(); |
194 fs.Connect(); |
197 fs.Volume(volumeInfo,driveNo); |
195 fs.Volume(volumeInfo,driveNo); |
198 fs.Close(); |
196 fs.Close(); |
199 |
197 |
200 if(volumeInfo.iFree <= KFreeSpaceThreshHoldValue + aSize) |
198 //Read the threshold value from Central Repository and check against it |
|
199 CRepository* repository(NULL); |
|
200 TInt thresholdValue(0); |
|
201 TRAPD(err,repository = CRepository::NewL(KCRUidUiklaf)); |
|
202 if (err == KErrNone) |
|
203 { |
|
204 if (driveNo == EDriveC) |
|
205 { |
|
206 TInt warningUsagePercent(0); |
|
207 err = repository->Get(KUikOODDiskFreeSpaceWarningNoteLevel,warningUsagePercent); |
|
208 if (err == KErrNone) |
|
209 { |
|
210 thresholdValue = ((volumeInfo.iSize*(100-warningUsagePercent))/100) |
|
211 + KFreeSpaceExtraReserved; |
|
212 } |
|
213 } |
|
214 else |
|
215 { |
|
216 err = repository->Get(KUikOODDiskFreeSpaceWarningNoteLevelMassMemory,thresholdValue); |
|
217 if (err == KErrNone) |
|
218 { |
|
219 thresholdValue += KFreeSpaceExtraReserved; |
|
220 } |
|
221 } |
|
222 delete repository; |
|
223 } |
|
224 |
|
225 if (err != KErrNone) |
|
226 { |
|
227 thresholdValue = KFreeSpaceThreshHoldDefaultValue + KFreeSpaceExtraReserved; |
|
228 } |
|
229 |
|
230 if(volumeInfo.iFree <= thresholdValue + aSize) |
201 { |
231 { |
202 User::Leave(KErrDiskFull); |
232 User::Leave(KErrDiskFull); |
203 } |
233 } |
204 |
234 |
205 iTargetFileSize = (TInt64)aSize; //keep a record for the target file size |
235 iTargetFileSize = (TInt64)aSize; //keep a record for the target file size |