mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetstorageinfo.cpp
branchRCL_3
changeset 11 f5809cfbf6d5
parent 4 60a94a45d437
child 17 dbd1c5e08735
equal deleted inserted replaced
6:ef55b168cedb 11:f5809cfbf6d5
   195 		case EMediaFlash:					
   195 		case EMediaFlash:					
   196 		case EMediaRemote:
   196 		case EMediaRemote:
   197 		case EMediaFloppy:
   197 		case EMediaFloppy:
   198 		    if (iDriveInfo.iDriveAtt & KDriveAttRemovable)
   198 		    if (iDriveInfo.iDriveAtt & KDriveAttRemovable)
   199 		        {
   199 		        {
   200 		        storageType = EMTPStorageRemovableRAM;
   200 		        //E: is set as logically removable after eMMC image updated
       
   201 		        //So here we need to deal with this case to set it as FixedRam
       
   202 		        if(iDriveInfo.iDriveAtt & KDriveAttInternal)
       
   203 		            {
       
   204 		            __FLOG(_L8("removable but internal drive, set as Fixed RAM"));
       
   205 		            storageType = EMTPStorageFixedRAM;
       
   206 		            }
       
   207 		        else
       
   208 		            {
       
   209 		            __FLOG(_L8("non internal,set as removable RAM"));
       
   210 		            storageType = EMTPStorageRemovableRAM;
       
   211 		            }
   201 		        }
   212 		        }
   202 		    else
   213 		    else
   203 		        {
   214 		        {
       
   215 		        __FLOG(_L8("Non removable, set as Fixed RAM"));
   204 		        storageType = EMTPStorageFixedRAM;
   216 		        storageType = EMTPStorageFixedRAM;
   205 		        }
   217 		        }
   206 			break;
   218 			break;
   207 		default:
   219 		default:
   208 			break;
   220 			break;
   307 void CMTPGetStorageInfo::SetStorageDescriptionL()
   319 void CMTPGetStorageInfo::SetStorageDescriptionL()
   308 	{
   320 	{
   309 	__FLOG(_L8("SetStorageDescriptionL - Entry"));
   321 	__FLOG(_L8("SetStorageDescriptionL - Entry"));
   310     TUint32 storage(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
   322     TUint32 storage(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
   311     TInt driveNumber = iFramework.StorageMgr().DriveNumber(storage);
   323     TInt driveNumber = iFramework.StorageMgr().DriveNumber(storage);
   312 	RBuf volumeName;
   324 	__FLOG_1(_L8("driveNumber:%d"),driveNumber);
   313 	volumeName.CreateL(KMaxFileName);
   325 	
   314 	volumeName.CleanupClosePushL();
   326 	CMTPTypeString* mtpDescription = CMTPTypeString::NewLC();
   315 	RMTPDeviceDpSingletons devSingletons;
   327 	            
   316 	devSingletons.OpenL(iFramework);
   328 	//Firstly, read name from VolumeInfo
   317 	CleanupClosePushL(devSingletons);
   329 	if (0 < iVolumeInfo.iName.Length())
   318 	TRAPD(resError, devSingletons.ConfigMgr().GetFriendlyVolumeNameL(driveNumber, volumeName));
   330 	    {
   319 	if ((KErrNone == resError) && (0 < volumeName.Length()))
   331 	        __FLOG_1(_L8("Using standard volume name:%S"),&iVolumeInfo.iName);
   320 		{
   332 	        mtpDescription->SetL(iVolumeInfo.iName);	        
   321 		__FLOG(_L8("Using volume name from resource file"));
   333 	    }
   322 		CMTPTypeString* mtpDescription = CMTPTypeString::NewLC(volumeName);
   334 	else //If name not set, set name according to type
   323 		iStorageInfo->SetL(CMTPTypeStorageInfo::EStorageDescription, *mtpDescription);
   335 	    {
   324 		CleanupStack::PopAndDestroy(mtpDescription);
   336 	    TMTPTypeUint16 storageType(EMTPStorageUndefined);
   325 		}
   337 	    iStorageInfo->GetL(CMTPTypeStorageInfo::EStorageType,storageType);
   326 	else if (0 < iVolumeInfo.iName.Length())
   338 	    __FLOG_1(_L8("Set name according to storage type: %d"),storageType.Value());
   327 		{
   339 	    
   328 		__FLOG(_L8("Using standard volume name"));
   340 	    switch (storageType.Value())
   329 		CMTPTypeString* mtpDescription = CMTPTypeString::NewLC(iVolumeInfo.iName);
   341 	        {
   330 		iStorageInfo->SetL(CMTPTypeStorageInfo::EStorageDescription, *mtpDescription);
   342 	        case EMTPStorageFixedROM:
   331 	    CleanupStack::PopAndDestroy(mtpDescription);
   343 	            if (driveNumber == EDriveC)//Phone Memory
   332 		}
   344 	                {
   333 		
   345 	                __FLOG(_L8("drive c"));
   334 	CleanupStack::PopAndDestroy(&devSingletons);
   346 	                mtpDescription->SetL(KPhoneMemory);
   335 	CleanupStack::PopAndDestroy(&volumeName);
   347 	                }
       
   348 	            break;
       
   349 	        case EMTPStorageRemovableROM:
       
   350 	            break;
       
   351 	        case EMTPStorageFixedRAM: // Mass Memory
       
   352 	            mtpDescription->SetL(KMassMemory);
       
   353 	            break;
       
   354 	        case EMTPStorageRemovableRAM: // Memory Card
       
   355 	            mtpDescription->SetL(KMemoryCard);
       
   356 	            break;
       
   357 	        case EMTPStorageUndefined:
       
   358 	        default:
       
   359 	            break;
       
   360 	        }
       
   361 	    
       
   362 	    //Finally, it the name still not set, use default value:
       
   363 	    //eg, 'A drive'
       
   364 	    if(mtpDescription->NumChars() == 0)
       
   365 	        {
       
   366 	        TChar driveChar;
       
   367 	        TInt err = iFramework.Fs().DriveToChar(driveNumber,driveChar);
       
   368 	        __FLOG_2(_L8("Use default name,driveNumber:%d err:%d"),driveNumber,err);
       
   369 	        if (err == KErrNone)
       
   370 	            {
       
   371 	            TBuf<sizeof(KDefaultName) + 1> driveName;
       
   372 	            driveName.Append(driveChar);
       
   373 	            driveName.Append(KDefaultName);
       
   374 	            mtpDescription->SetL(driveName);
       
   375 	            }
       
   376 	        else
       
   377 	            {
       
   378 	            mtpDescription->SetL(KNoName);
       
   379 	            }
       
   380 	        }
       
   381 	    }
       
   382 	
       
   383 	iStorageInfo->SetL(CMTPTypeStorageInfo::EStorageDescription,*mtpDescription);
       
   384 	CleanupStack::PopAndDestroy(mtpDescription);	
       
   385 	
   336 	__FLOG(_L8("SetStorageDescriptionL - Exit"));
   386 	__FLOG(_L8("SetStorageDescriptionL - Exit"));
   337 	}
   387 	}
   338 	
   388 	
   339 /**
   389 /**
   340 Set the volume identifier of the drive in the storage info data set
   390 Set the volume identifier of the drive in the storage info data set