mtpfws/mtpfw/src/cmtpstoragemgr.cpp
branchRCL_3
changeset 24 523717cdb0ad
parent 12 8b094906a049
child 47 63cf70d3ecd8
equal deleted inserted replaced
23:f5809cfbf6d5 24:523717cdb0ad
   346     }
   346     }
   347 
   347 
   348 EXPORT_C TUint32 CMTPStorageMgr::DefaultStorageId() const
   348 EXPORT_C TUint32 CMTPStorageMgr::DefaultStorageId() const
   349     {
   349     {
   350     __FLOG(_L8("DefaultStorageId - Entry"));
   350     __FLOG(_L8("DefaultStorageId - Entry"));
   351     
       
   352     TUint32 ret = iDefaultStorageId;
       
   353     TBool check = EFalse;
       
   354 	TInt driveNo = DriveNumber(ret);
       
   355 	const TUint KMinFreeSpace(1024 * 512);  
       
   356 	if( (KErrNotFound == driveNo) || ( !IsReadWriteStorage(ret) ) )
       
   357 		{
       
   358 		check = ETrue;
       
   359 		}
       
   360 	else
       
   361 		{
       
   362 		TVolumeInfo volumeInfo;
       
   363 		if(iSingletons.Fs().Volume(volumeInfo, driveNo) != KErrNone)
       
   364 			{
       
   365 			check = ETrue;
       
   366 			}
       
   367 		else if (volumeInfo.iFree < KMinFreeSpace)
       
   368 			{
       
   369 			check = ETrue;
       
   370 			}
       
   371 		}
       
   372     	
       
   373     if(check)
       
   374     	{ 
       
   375 		const TUint KCount(iMapDriveToStorage.Count());
       
   376 		for (TInt i = 0; i < KCount; i++)
       
   377 			{
       
   378 			if (iMapDriveToStorage[i] == KErrNotFound)
       
   379 				{
       
   380 				continue;
       
   381 				}
       
   382 			TVolumeInfo volume;
       
   383 			if( !IsReadWriteStorage(iMapDriveToStorage[i]) 
       
   384 					|| (iSingletons.Fs().Volume(volume, i) != KErrNone) )
       
   385 				{
       
   386 				continue;
       
   387 				}
       
   388 			
       
   389 			if (volume.iFree > KMinFreeSpace )
       
   390 				{
       
   391 				ret = iMapDriveToStorage[i];
       
   392 				break;
       
   393 				}
       
   394 			}
       
   395     	}
       
   396     
       
   397     __FLOG(_L8("DefaultStorageId - Exit"));
   351     __FLOG(_L8("DefaultStorageId - Exit"));
   398     return ret;
   352     return iDefaultStorageId;
   399     }
   353     }
   400 
   354 
   401 EXPORT_C TInt CMTPStorageMgr::DriveNumber(TUint32 aStorageId) const
   355 EXPORT_C TInt CMTPStorageMgr::DriveNumber(TUint32 aStorageId) const
   402     {
   356     {
   403     __FLOG(_L8("DriveNumber - Entry"));
   357     __FLOG(_L8("DriveNumber - Entry"));