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 |