mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp
branchRCL_3
changeset 4 60a94a45d437
parent 3 8b094906a049
child 11 f5809cfbf6d5
--- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp	Mon Mar 15 12:43:12 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp	Wed Mar 31 22:58:56 2010 +0300
@@ -12,7 +12,7 @@
 //
 // Description:
 //
-
+#include <centralrepository.h>
 #include <mtp/tmtptyperequest.h>
 #include <mtp/mmtpdataproviderframework.h>
 #include <mtp/mmtpobjectmgr.h>
@@ -25,6 +25,11 @@
 #include "mtpdevdppanic.h"
 #include "rmtpdevicedpsingletons.h"
 #include "cmtpdevicedpconfigmgr.h"
+#include "mtpframeworkconst.h"
+
+//This file is exported from s60 sdk, now just copy it
+//to make sure onb can run
+#include "UiklafInternalCRKeys.h"
 
 // Class constants.
 __FLOG_STMT(_LIT8(KComponent,"GetStorageInfo");)
@@ -167,6 +172,7 @@
 void CMTPGetStorageInfo::SetStorageTypeL()
 	{
 	TUint16 storageType = EMTPStorageUndefined;
+	
 	switch(iDriveInfo.iType)
 		{
 		case EMediaNotPresent:
@@ -189,7 +195,14 @@
 		case EMediaFlash:					
 		case EMediaRemote:
 		case EMediaFloppy:
-			storageType = EMTPStorageRemovableRAM;
+		    if (iDriveInfo.iDriveAtt & KDriveAttRemovable)
+		        {
+		        storageType = EMTPStorageRemovableRAM;
+		        }
+		    else
+		        {
+		        storageType = EMTPStorageFixedRAM;
+		        }
 			break;
 		default:
 			break;
@@ -239,11 +252,43 @@
 */
 void CMTPGetStorageInfo::SetFreeSpaceInBytesL()
 	{
-	TMTPTypeUint64 mtpFreeSpace(iVolumeInfo.iFree);
+	TMTPTypeUint64 mtpFreeSpace;
 	if(iIsCDrive)
-		{
-		mtpFreeSpace.Set(0);
-		}
+	    {
+	    mtpFreeSpace.Set(0);
+	    }
+	else
+	    {
+	    CRepository* repository(NULL);
+	    TInt thresholdValue(0);
+	    TRAPD(err,repository = CRepository::NewL(KCRUidUiklaf));
+	    if (err == KErrNone)
+	        {
+	        err = repository->Get(KUikOODDiskFreeSpaceWarningNoteLevelMassMemory,thresholdValue);
+	        if (err == KErrNone)
+	            {
+	            __FLOG_1(_L8("Read from central repo:%d"),thresholdValue);
+	            thresholdValue += KFreeSpaceExtraReserved;
+	            }	  
+	        delete repository;
+	        }
+	    
+	    if (err != KErrNone)
+	        {
+	        __FLOG(_L8("Fail in read ,use default"));
+	        thresholdValue = KFreeSpaceThreshHoldDefaultValue + KFreeSpaceExtraReserved;
+	        }
+	    
+	    __FLOG_2(_L8("threshold:%d free space:%ld"),thresholdValue,iVolumeInfo.iFree);
+	    //Exclude the reserved disk space when reporting free space
+	    TInt64 free = (iVolumeInfo.iFree > thresholdValue) ?
+	        (iVolumeInfo.iFree - thresholdValue) : 0;
+	    mtpFreeSpace.Set(free);
+	    __FLOG_1(_L8("set free:%ld"),free);
+	    }
+	
+	__FLOG_2(_L8("SetFreeSpaceInBytesL volume free:%ld report:%ld"),
+	        iVolumeInfo.iFree,mtpFreeSpace.Value());
 	iStorageInfo->SetL(CMTPTypeStorageInfo::EFreeSpaceInBytes, mtpFreeSpace);	
 	}