mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp
branchRCL_3
changeset 4 60a94a45d437
parent 3 8b094906a049
child 11 f5809cfbf6d5
equal deleted inserted replaced
3:8b094906a049 4:60a94a45d437
    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 #include "mtpframeworkconst.h"
       
    29 
       
    30 //This file is exported from s60 sdk, now just copy it
       
    31 //to make sure onb can run
       
    32 #include "UiklafInternalCRKeys.h"
    28 
    33 
    29 // Class constants.
    34 // Class constants.
    30 __FLOG_STMT(_LIT8(KComponent,"GetStorageInfo");)
    35 __FLOG_STMT(_LIT8(KComponent,"GetStorageInfo");)
    31 
    36 
    32 /**
    37 /**
   165 Set the storage type in the storage info data set
   170 Set the storage type in the storage info data set
   166 */
   171 */
   167 void CMTPGetStorageInfo::SetStorageTypeL()
   172 void CMTPGetStorageInfo::SetStorageTypeL()
   168 	{
   173 	{
   169 	TUint16 storageType = EMTPStorageUndefined;
   174 	TUint16 storageType = EMTPStorageUndefined;
       
   175 	
   170 	switch(iDriveInfo.iType)
   176 	switch(iDriveInfo.iType)
   171 		{
   177 		{
   172 		case EMediaNotPresent:
   178 		case EMediaNotPresent:
   173 			User::Leave(KErrDisMounted);
   179 			User::Leave(KErrDisMounted);
   174 			break;
   180 			break;
   187 			break;
   193 			break;
   188 		case EMediaHardDisk:
   194 		case EMediaHardDisk:
   189 		case EMediaFlash:					
   195 		case EMediaFlash:					
   190 		case EMediaRemote:
   196 		case EMediaRemote:
   191 		case EMediaFloppy:
   197 		case EMediaFloppy:
   192 			storageType = EMTPStorageRemovableRAM;
   198 		    if (iDriveInfo.iDriveAtt & KDriveAttRemovable)
       
   199 		        {
       
   200 		        storageType = EMTPStorageRemovableRAM;
       
   201 		        }
       
   202 		    else
       
   203 		        {
       
   204 		        storageType = EMTPStorageFixedRAM;
       
   205 		        }
   193 			break;
   206 			break;
   194 		default:
   207 		default:
   195 			break;
   208 			break;
   196 		}
   209 		}
   197 	TMTPTypeUint16 mtpStorageType(storageType);	
   210 	TMTPTypeUint16 mtpStorageType(storageType);	
   237 /**
   250 /**
   238 Set the free space of the drive in the storage info data set
   251 Set the free space of the drive in the storage info data set
   239 */
   252 */
   240 void CMTPGetStorageInfo::SetFreeSpaceInBytesL()
   253 void CMTPGetStorageInfo::SetFreeSpaceInBytesL()
   241 	{
   254 	{
   242 	TMTPTypeUint64 mtpFreeSpace(iVolumeInfo.iFree);
   255 	TMTPTypeUint64 mtpFreeSpace;
   243 	if(iIsCDrive)
   256 	if(iIsCDrive)
   244 		{
   257 	    {
   245 		mtpFreeSpace.Set(0);
   258 	    mtpFreeSpace.Set(0);
   246 		}
   259 	    }
       
   260 	else
       
   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);
       
   283 	    //Exclude the reserved disk space when reporting free space
       
   284 	    TInt64 free = (iVolumeInfo.iFree > thresholdValue) ?
       
   285 	        (iVolumeInfo.iFree - thresholdValue) : 0;
       
   286 	    mtpFreeSpace.Set(free);
       
   287 	    __FLOG_1(_L8("set free:%ld"),free);
       
   288 	    }
       
   289 	
       
   290 	__FLOG_2(_L8("SetFreeSpaceInBytesL volume free:%ld report:%ld"),
       
   291 	        iVolumeInfo.iFree,mtpFreeSpace.Value());
   247 	iStorageInfo->SetL(CMTPTypeStorageInfo::EFreeSpaceInBytes, mtpFreeSpace);	
   292 	iStorageInfo->SetL(CMTPTypeStorageInfo::EFreeSpaceInBytes, mtpFreeSpace);	
   248 	}
   293 	}
   249 	
   294 	
   250 /**
   295 /**
   251 Set the free space of in objects in the storage info data set
   296 Set the free space of in objects in the storage info data set