mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp
changeset 20 6e82ae192c3a
parent 18 1b39655331a3
child 25 48a2e0d8a4ce
equal deleted inserted replaced
18:1b39655331a3 20:6e82ae192c3a
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 //
    14 //
    15 
    15 #include <centralrepository.h>
    16 #include <mtp/tmtptyperequest.h>
    16 #include <mtp/tmtptyperequest.h>
    17 #include <mtp/mmtpdataproviderframework.h>
    17 #include <mtp/mmtpdataproviderframework.h>
    18 #include <mtp/mmtpobjectmgr.h>
    18 #include <mtp/mmtpobjectmgr.h>
    19 #include <mtp/cmtptypestorageinfo.h>
    19 #include <mtp/cmtptypestorageinfo.h>
    20 #include <mtp/cmtptypestring.h>
    20 #include <mtp/cmtptypestring.h>
    23 #include "cmtpstoragemgr.h"
    23 #include "cmtpstoragemgr.h"
    24 #include "mtpdevicedpconst.h"
    24 #include "mtpdevicedpconst.h"
    25 #include "mtpdevdppanic.h"
    25 #include "mtpdevdppanic.h"
    26 #include "rmtpdevicedpsingletons.h"
    26 #include "rmtpdevicedpsingletons.h"
    27 #include "cmtpdevicedpconfigmgr.h"
    27 #include "cmtpdevicedpconfigmgr.h"
    28 
    28 #include "mtpframeworkconst.h"
    29 //MTP should reserve some disk space to prevent ood monitor popup
    29 
    30 //'Out of memory' note.When syncing music through ovi suite,
    30 //This file is exported from s60 sdk, now just copy it
    31 //sometimes device screen get freeze with this note
    31 //to make sure onb can run
    32 //If you need to adjust this value,please also update the definition
    32 #include "UiklafInternalCRKeys.h"
    33 //in file 'cmtptypefile.cpp'
       
    34 const TInt KFreeSpaceThreshHoldValue(11*1024*1024);//11M
       
    35 
    33 
    36 // Class constants.
    34 // Class constants.
    37 __FLOG_STMT(_LIT8(KComponent,"GetStorageInfo");)
    35 __FLOG_STMT(_LIT8(KComponent,"GetStorageInfo");)
    38 
    36 
    39 /**
    37 /**
   172 Set the storage type in the storage info data set
   170 Set the storage type in the storage info data set
   173 */
   171 */
   174 void CMTPGetStorageInfo::SetStorageTypeL()
   172 void CMTPGetStorageInfo::SetStorageTypeL()
   175 	{
   173 	{
   176 	TUint16 storageType = EMTPStorageUndefined;
   174 	TUint16 storageType = EMTPStorageUndefined;
       
   175 	
   177 	switch(iDriveInfo.iType)
   176 	switch(iDriveInfo.iType)
   178 		{
   177 		{
   179 		case EMediaNotPresent:
   178 		case EMediaNotPresent:
   180 			User::Leave(KErrDisMounted);
   179 			User::Leave(KErrDisMounted);
   181 			break;
   180 			break;
   194 			break;
   193 			break;
   195 		case EMediaHardDisk:
   194 		case EMediaHardDisk:
   196 		case EMediaFlash:					
   195 		case EMediaFlash:					
   197 		case EMediaRemote:
   196 		case EMediaRemote:
   198 		case EMediaFloppy:
   197 		case EMediaFloppy:
   199 			storageType = EMTPStorageRemovableRAM;
   198 		    if (iDriveInfo.iDriveAtt & KDriveAttRemovable)
       
   199 		        {
       
   200 		        storageType = EMTPStorageRemovableRAM;
       
   201 		        }
       
   202 		    else
       
   203 		        {
       
   204 		        storageType = EMTPStorageFixedRAM;
       
   205 		        }
   200 			break;
   206 			break;
   201 		default:
   207 		default:
   202 			break;
   208 			break;
   203 		}
   209 		}
   204 	TMTPTypeUint16 mtpStorageType(storageType);	
   210 	TMTPTypeUint16 mtpStorageType(storageType);	
   251 	    {
   257 	    {
   252 	    mtpFreeSpace.Set(0);
   258 	    mtpFreeSpace.Set(0);
   253 	    }
   259 	    }
   254 	else
   260 	else
   255 	    {
   261 	    {
       
   262 	    CRepository* repository(NULL);
       
   263 	    TInt thresholdValue(0);
       
   264 	    TRAPD(err,repository = CRepository::NewL(KCRUidUiklaf));
       
   265 	    if (err == KErrNone)
       
   266 	        {
       
   267 	        err = repository->Get(KUikOODDiskFreeSpaceWarningNoteLevelMassMemory,thresholdValue);
       
   268 	        if (err == KErrNone)
       
   269 	            {
       
   270 	            __FLOG_1(_L8("Read from central repo:%d"),thresholdValue);
       
   271 	            thresholdValue += KFreeSpaceExtraReserved;
       
   272 	            }	  
       
   273 	        delete repository;
       
   274 	        }
       
   275 	    
       
   276 	    if (err != KErrNone)
       
   277 	        {
       
   278 	        __FLOG(_L8("Fail in read ,use default"));
       
   279 	        thresholdValue = KFreeSpaceThreshHoldDefaultValue + KFreeSpaceExtraReserved;
       
   280 	        }
       
   281 	    
       
   282 	    __FLOG_2(_L8("threshold:%d free space:%ld"),thresholdValue,iVolumeInfo.iFree);
   256 	    //Exclude the reserved disk space when reporting free space
   283 	    //Exclude the reserved disk space when reporting free space
   257 	    TInt64 free = (iVolumeInfo.iFree > KFreeSpaceThreshHoldValue) ?
   284 	    TInt64 free = (iVolumeInfo.iFree > thresholdValue) ?
   258 	        (iVolumeInfo.iFree - KFreeSpaceThreshHoldValue) : 0;
   285 	        (iVolumeInfo.iFree - thresholdValue) : 0;
   259 	    mtpFreeSpace.Set(free);
   286 	    mtpFreeSpace.Set(free);
       
   287 	    __FLOG_1(_L8("set free:%ld"),free);
   260 	    }
   288 	    }
   261 	__FLOG_2(_L8("SetFreeSpaceInBytesL volume free:%d report:%d"),
   289 	
       
   290 	__FLOG_2(_L8("SetFreeSpaceInBytesL volume free:%ld report:%ld"),
   262 	        iVolumeInfo.iFree,mtpFreeSpace.Value());
   291 	        iVolumeInfo.iFree,mtpFreeSpace.Value());
   263 	iStorageInfo->SetL(CMTPTypeStorageInfo::EFreeSpaceInBytes, mtpFreeSpace);	
   292 	iStorageInfo->SetL(CMTPTypeStorageInfo::EFreeSpaceInBytes, mtpFreeSpace);	
   264 	}
   293 	}
   265 	
   294 	
   266 /**
   295 /**