commonuis/CommonDialogs/src/caknmemoryselectionmodelmultidrive.cpp
branchRCL_3
changeset 20 d48ab3b357f1
parent 19 aecbbf00d063
equal deleted inserted replaced
19:aecbbf00d063 20:d48ab3b357f1
    20 
    20 
    21 
    21 
    22 #include <coemain.h>
    22 #include <coemain.h>
    23 #include <StringLoader.h>
    23 #include <StringLoader.h>
    24 #include <commondialogs.rsg>
    24 #include <commondialogs.rsg>
       
    25 #include <rsfwmountman.h>
    25 #include <pathinfo.h> //PathInfo
    26 #include <pathinfo.h> //PathInfo
    26 #include <barsread.h>   // TResourceReader
    27 #include <barsread.h>   // TResourceReader
    27 #include <driveinfo.h> //DriveInfo
    28 #include <driveinfo.h> //DriveInfo
    28 #include "caknmemoryselectionmodelmultidrive.h"
    29 #include "caknmemoryselectionmodelmultidrive.h"
    29 #include "CAknCommonDialogsBase.h"
    30 #include "CAknCommonDialogsBase.h"
   300             {
   301             {
   301             // qtn.memc.remote.drive
   302             // qtn.memc.remote.drive
   302             resource = R_CFD_QTN_MEMC_REMOTE_DRIVE;
   303             resource = R_CFD_QTN_MEMC_REMOTE_DRIVE;
   303             break;
   304             break;
   304             }
   305             }
       
   306         case ETextUSBDefaultName:
       
   307             {
       
   308             // qtn.memc.usb.available.single.list
       
   309             resource = R_CFD_QTN_MEMC_USB_AVAILABLE_SINGLE_LIST;
       
   310             break;
       
   311             }
       
   312         case ETextUSBUnavailable:
       
   313             {
       
   314             // qtn.memc.usb.unavailable.single.list
       
   315             resource = R_CFD_QTN_MEMC_USB_UNAVAILABLE_SINGLE_LIST;
       
   316             break;
       
   317             }
   305         }
   318         }
   306     return resource;
   319     return resource;
   307     }
   320     }
   308 
   321 
   309 
   322 
   350             {
   363             {
   351             // TODO: To get real value from UI spec
   364             // TODO: To get real value from UI spec
   352             resource = R_CFD_QTN_MEMC_REMOTE_DRIVE;
   365             resource = R_CFD_QTN_MEMC_REMOTE_DRIVE;
   353             break;
   366             break;
   354             }
   367             }
       
   368         case ETextUSBDefaultName:
       
   369         case ETextUSBUnavailable:
       
   370             {
       
   371             // qtn.memc.usb.available.single.list
       
   372             resource = R_CFD_QTN_MEMC_USB_AVAILABLE_SINGLE_LIST;
       
   373             break;
       
   374             }
   355         }
   375         }
   356     return resource;
   376     return resource;
   357     }
   377     }
   358 
   378 
   359 
   379 
   377             {
   397             {
   378             // qtn.mem.mass.storage.double.list
   398             // qtn.mem.mass.storage.double.list
   379             resource = R_CFD_QTN_MEM_MASS_STORAGE_DOUBLE_LIST;
   399             resource = R_CFD_QTN_MEM_MASS_STORAGE_DOUBLE_LIST;
   380             break;
   400             break;
   381             }
   401             }
       
   402         case ETextMMCNamed:
       
   403             {
       
   404             // If MMC's name is given.
       
   405             // qtn.mem.named.memory.card.double
       
   406             resource = R_CFD_QTN_MEM_NAMED_MEMORY_CARD_DOUBLE;
       
   407             break;
       
   408             }
       
   409         case ETextMMCDefaultName:
       
   410             {
       
   411             // If MMC's name is empty.
       
   412             // qtn.mem.memory.card.default.double
       
   413             resource = R_CFD_QTN_MEM_MEMORY_CARD_DEFAULT_DOUBLE;
       
   414             break;
       
   415             }
       
   416         case ETextMMCLocked:
       
   417             {
       
   418             // qtn.memc.mmc.locked.double
       
   419             resource = R_CFD_QTN_MEMC_MMC_LOCKED_DOUBLE;
       
   420             break;
       
   421             }
       
   422         case ETextRemoteDrive:
       
   423             {
       
   424             // TODO: To be checked because of missing data in UI spec.
       
   425             resource = R_CFD_QTN_MEMC_REMOTE_DRIVE_DOUBLE_LIST;
       
   426             break;
       
   427             }
       
   428         case ETextUSBDefaultName:
       
   429             {
       
   430             // qtn.memc.usb.available.double
       
   431             resource = R_CFD_QTN_MEMC_USB_AVAILABLE_DOUBLE;
       
   432             break;
       
   433             }
       
   434         case ETextMMCUnavailable:
       
   435         case ETextUSBUnavailable:
   382         case ETextInternalMassStorageUnavailable:
   436         case ETextInternalMassStorageUnavailable:
   383             {
   437             {
   384             // Unavailable:qtn.memc.mmc.unavailable.double
   438             // Unavailable:qtn.memc.mmc.unavailable.double
   385             // Only for second row
   439             // Only for second row
   386             resource = R_CFD_QTN_MEMC_MMC_UNAVAILABLE_DOUBLE;
   440             resource = R_CFD_QTN_MEMC_MMC_UNAVAILABLE_DOUBLE;
   387             break;
   441             break;
   388             }
   442             }
   389         case ETextMMCNamed:
       
   390             {
       
   391             // If MMC's name is given.
       
   392             // qtn.mem.named.memory.card.double
       
   393             resource = R_CFD_QTN_MEM_NAMED_MEMORY_CARD_DOUBLE;
       
   394             break;
       
   395             }
       
   396         case ETextMMCDefaultName:
       
   397             {
       
   398             // If MMC's name is empty.
       
   399             // qtn.mem.memory.card.default.double
       
   400             resource = R_CFD_QTN_MEM_MEMORY_CARD_DEFAULT_DOUBLE;
       
   401             break;
       
   402             }
       
   403         case ETextMMCLocked:
       
   404             {
       
   405             // qtn.memc.mmc.locked.double
       
   406             resource = R_CFD_QTN_MEMC_MMC_LOCKED_DOUBLE;
       
   407             break;
       
   408             }
       
   409         case ETextMMCUnavailable:
       
   410             {
       
   411             // qtn.memc.mmc.unavailable.double
       
   412             resource = R_CFD_QTN_MEMC_MMC_UNAVAILABLE_DOUBLE;
       
   413             break;
       
   414             }
       
   415         case ETextRemoteDrive:
       
   416             {
       
   417             // TODO: To be checked because of missing data in UI spec.
       
   418             resource = R_CFD_QTN_MEMC_REMOTE_DRIVE_DOUBLE_LIST;
       
   419             break;
       
   420             }
       
   421         }
   443         }
   422     return resource;
   444     return resource;
   423 
   445 
   424     }
   446     }
   425 
   447 
   447             }
   469             }
   448         }
   470         }
   449     else if( aDriveInfo.iStatus & DriveInfo::EDriveRemovable  )
   471     else if( aDriveInfo.iStatus & DriveInfo::EDriveRemovable  )
   450         {
   472         {
   451         // External mass storage drive, like external MMC
   473         // External mass storage drive, like external MMC
   452         AddMMCItemToLbxL( aDriveInfo );
   474         if( aDriveInfo.iStatus & DriveInfo::EDriveUsbMemory )
   453 
   475         	{
   454         iHasMMCUnavailable = ( aDriveInfo.iDriveStatus == EDriveNotReady );
   476         	AddUSBItemToLbxL( aDriveInfo );
       
   477         	}
       
   478         else
       
   479         	{
       
   480         	AddMMCItemToLbxL( aDriveInfo );
       
   481         	iHasMMCUnavailable = ( aDriveInfo.iDriveStatus == EDriveNotReady );
       
   482         	}
   455         }
   483         }
   456     else if ( ( aDriveInfo.iStatus & DriveInfo::EDriveRemote )
   484     else if ( ( aDriveInfo.iStatus & DriveInfo::EDriveRemote )
   457         && ( aDriveInfo.iMediaType == EMediaRemote ) )
   485         && ( aDriveInfo.iMediaType == EMediaRemote ) )
   458         // 2 conditions used here just for sure
   486         // 2 conditions used here just for sure
   459         {
   487         {
   905     CleanupStack::Pop( lbxItemBuf );
   933     CleanupStack::Pop( lbxItemBuf );
   906     _LOG1( "[CAknMemorySelectionModelMultiDrive] Item string added to lbx array: %S", &itemString );
   934     _LOG1( "[CAknMemorySelectionModelMultiDrive] Item string added to lbx array: %S", &itemString );
   907     _LOG1( "itemString length=%d", itemString.Length() );
   935     _LOG1( "itemString length=%d", itemString.Length() );
   908     }
   936     }
   909 
   937 
       
   938 // ---------------------------------------------------------------------------
       
   939 // CAknMemorySelectionModelMultiDrive::AddUSBItemToLbxL
       
   940 // ---------------------------------------------------------------------------
       
   941 //
       
   942 void CAknMemorySelectionModelMultiDrive::AddUSBItemToLbxL(
       
   943     const TCFDDriveInfo& aDriveInfo )
       
   944     {
       
   945     HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   946     TPtr itemString( lbxItemBuf->Des() );
       
   947     HBufC* textItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   948     TPtr textString( textItemBuf->Des() );
       
   949     HBufC* textItemBuf2 = HBufC::NewLC( KListBoxEntryMaxLength );
       
   950     TPtr textString2( textItemBuf2->Des() );
       
   951     TDriveUnit driveUnit( aDriveInfo.iDriveNumber );
       
   952 
       
   953     // Item text is affected by layout
       
   954     switch( iLayout )
       
   955         {
       
   956         case ELayoutPopupMenu:
       
   957             {
       
   958             itemString.Format( KImageHeader, EIconExternalUSBDrive );
       
   959             itemString.Append( KTabChar );
       
   960 
       
   961             // 1st row text:
       
   962             if( aDriveInfo.iDriveStatus == EDriveOK )
       
   963                 {
       
   964                 if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   965                     {
       
   966                     StringLoader::Format(
       
   967                         textString2,
       
   968                         *iLocStringArray[ ETextMMCNamed ],
       
   969                         KIndexFirst,
       
   970                         driveUnit.Name()
       
   971                         );
       
   972                     StringLoader::Format(
       
   973                         textString,
       
   974                         textString2,
       
   975                         KIndexSecond,
       
   976                         aDriveInfo.iVolumeLabel
       
   977                         );
       
   978                     }
       
   979                 else
       
   980                     {
       
   981                     StringLoader::Format(
       
   982                         textString,
       
   983                         *iLocStringArray[ ETextUSBDefaultName ],
       
   984                         KNoIndex,
       
   985                         driveUnit.Name()
       
   986                         );
       
   987                     }
       
   988                 }
       
   989             else
       
   990                 {
       
   991                 StringLoader::Format(
       
   992                     textString,
       
   993                     *iLocStringArray[ ETextUSBUnavailable ],
       
   994                     KNoIndex,
       
   995                     driveUnit.Name()
       
   996                     );
       
   997                 }
       
   998             itemString.Append( textString );
       
   999 
       
  1000             break;
       
  1001             }
       
  1002         case ELayoutSettingPage:
       
  1003             {
       
  1004             // 1st row text:
       
  1005             if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
  1006                 {
       
  1007                 // Append drive name if it has one
       
  1008                 StringLoader::Format(
       
  1009                     textString,
       
  1010                     *iLocStringArray[ ETextMMCNamed ],
       
  1011                     KIndexFirst,
       
  1012                     driveUnit.Name()
       
  1013                     );
       
  1014                 StringLoader::Format(
       
  1015                     itemString,
       
  1016                     textString,
       
  1017                     KIndexSecond,
       
  1018                     aDriveInfo.iVolumeLabel
       
  1019                     );
       
  1020                 }
       
  1021             else
       
  1022                 {
       
  1023                 StringLoader::Format(
       
  1024                     itemString,
       
  1025                     *iLocStringArray[ ETextUSBDefaultName ],
       
  1026                     KNoIndex,
       
  1027                     driveUnit.Name()
       
  1028                     );
       
  1029                 }
       
  1030             break;
       
  1031             }
       
  1032         case ELayoutDoublePopup:
       
  1033             {
       
  1034             itemString.Format( KImageHeader, EIconExternalUSBDrive );
       
  1035             itemString.Append( KTabChar );
       
  1036 
       
  1037             // 1st row text:
       
  1038             if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
  1039                 {
       
  1040                 StringLoader::Format(
       
  1041                     textString2,
       
  1042                     *iLocStringArray[ ETextMMCNamed ],
       
  1043                     KIndexFirst,
       
  1044                     driveUnit.Name()
       
  1045                     );
       
  1046                 StringLoader::Format(
       
  1047                     textString,
       
  1048                     textString2,
       
  1049                     KIndexSecond,
       
  1050                     aDriveInfo.iVolumeLabel
       
  1051                     );
       
  1052                 }
       
  1053             else
       
  1054                 {
       
  1055                 // Use default drive description
       
  1056                 StringLoader::Format(
       
  1057                     textString,
       
  1058                     *iLocStringArray[ ETextUSBDefaultName ],
       
  1059                     KNoIndex,
       
  1060                     driveUnit.Name()
       
  1061                     );
       
  1062                 }
       
  1063             itemString.Append( textString );
       
  1064             itemString.Append( KTabChar );
       
  1065 
       
  1066             // 2nd row text:
       
  1067             if ( aDriveInfo.iDriveStatus == EDriveOK )
       
  1068                 {
       
  1069                 HBufC* buffer;
       
  1070                 TInt64 freeSpace = aDriveInfo.iDiskSpace;
       
  1071                 if ( freeSpace >= 0 )
       
  1072                     {
       
  1073                     buffer = HBufC::NewLC( KListBoxEntryMaxLength );  
       
  1074                     TPtr unitStr( buffer->Des() );
       
  1075                     AknCFDUtility::SetSecondRowTextL( freeSpace, unitStr );
       
  1076                     }
       
  1077                 else
       
  1078                     {
       
  1079                     // Disk space is unavailable
       
  1080                     buffer = StringLoader::LoadLC(
       
  1081                                 R_CFD_QTN_MEMC_SPACE_NOT_AVAILABLE,
       
  1082                                 iCoeEnv);
       
  1083                     }
       
  1084                 itemString.Append( *buffer );//Free mem text
       
  1085                 CleanupStack::PopAndDestroy( buffer );
       
  1086                 }
       
  1087             else
       
  1088                 {
       
  1089                 itemString.Append(
       
  1090                     *iLocStringArray[ ETextUSBUnavailable ] );
       
  1091                 }
       
  1092             break;
       
  1093             }
       
  1094         }
       
  1095 
       
  1096     // Finally!: append the formatted string to listbox
       
  1097     User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
       
  1098     CleanupStack::PopAndDestroy( 2 ); // textItemBuf2, textItemBuf
       
  1099     CleanupStack::Pop( lbxItemBuf );
       
  1100     _LOG1( "[CAknMemorySelectionModelMultiDrive] Item string added to lbx array: %S", &itemString );
       
  1101     _LOG1( "itemString length=%d", itemString.Length() );
       
  1102     }
   910 
  1103 
   911 // ---------------------------------------------------------------------------
  1104 // ---------------------------------------------------------------------------
   912 // CAknMemorySelectionModelMultiDrive::AddRemoteItemToLbxL
  1105 // CAknMemorySelectionModelMultiDrive::AddRemoteItemToLbxL
   913 // ---------------------------------------------------------------------------
  1106 // ---------------------------------------------------------------------------
   914 //
  1107 //
   980                 // Currently Remote drive does not support query for available
  1173                 // Currently Remote drive does not support query for available
   981                 // disk space, so just return " "
  1174                 // disk space, so just return " "
   982                 _LIT( KEmptySpace, " ");
  1175                 _LIT( KEmptySpace, " ");
   983                 itemString.Append( KEmptySpace ); 
  1176                 itemString.Append( KEmptySpace ); 
   984 
  1177 
   985                 //if( aDriveInfo.iConnectionState == KMountStronglyConnected )
  1178                 if( aDriveInfo.iConnectionState == KMountStronglyConnected )
   986                 //    {
  1179                     {
   987                 // D-column icon: Show active icon if drive has no error
       
   988                 //    itemString.Append( KTabChar );
       
   989                 //    itemString.AppendFormat(
       
   990                 //      KImageHeader, EIconRemoteDriveActive );
       
   991                 //    }
       
   992                 //else // KMountNotConnected
       
   993                 //    {
       
   994                     // D-column icon: Show active icon if drive has no error
  1180                     // D-column icon: Show active icon if drive has no error
   995                 itemString.Append( KTabChar );
  1181                     itemString.Append( KTabChar );
   996                 //    }
  1182                     itemString.AppendFormat(
       
  1183                         KImageHeader, EIconRemoteDriveActive );
       
  1184                     }
       
  1185                 else // KMountNotConnected
       
  1186                     {
       
  1187                     // D-column icon: Show active icon if drive has no error
       
  1188                     itemString.Append( KTabChar );
       
  1189                     }
   997                 }
  1190                 }
   998             else
  1191             else
   999                 {
  1192                 {
  1000                 // 2nd row text:
  1193                 // 2nd row text:
  1001                 itemString.Append( *iLocStringArray[ ETextMMCUnavailable ] );
  1194                 itemString.Append( *iLocStringArray[ ETextMMCUnavailable ] );
  1146             if ( driveExist )
  1339             if ( driveExist )
  1147                 {
  1340                 {
  1148                 driveNumber = TDriveNumber( i );
  1341                 driveNumber = TDriveNumber( i );
  1149                 rootPath.Zero();
  1342                 rootPath.Zero();
  1150                 memoryType = AknCFDUtility::DriveMemoryTypeL( driveNumber );
  1343                 memoryType = AknCFDUtility::DriveMemoryTypeL( driveNumber );
       
  1344                 if ( memoryType == AknCommonDialogsDynMem::EMemoryTypeMMCExternal &&
       
  1345                         ( iIncludedMedias & AknCommonDialogsDynMem::EMemoryTypeMMCExternalInDevice ) )
       
  1346                     {
       
  1347                     // Hide usb memory
       
  1348                     TCFDDriveInfo info;
       
  1349                     AknCFDUtility::DriveInfoL( driveNumber, info );
       
  1350                     if ( info.iStatus & DriveInfo::EDriveUsbMemory )
       
  1351                         {
       
  1352                         continue;
       
  1353                         }
       
  1354                     else
       
  1355                         {
       
  1356                         memoryType = AknCommonDialogsDynMem::EMemoryTypeMMCExternalInDevice;
       
  1357                         }
       
  1358                     }
  1151                 if( memoryType & iIncludedMedias )
  1359                 if( memoryType & iIncludedMedias )
  1152                     {
  1360                     {
  1153                     User::LeaveIfError(
  1361                     User::LeaveIfError(
  1154                     PathInfo::GetRootPath( rootPath, driveNumber ) );
  1362                     PathInfo::GetRootPath( rootPath, driveNumber ) );
  1155                     }
  1363                     }
  1193             TInt drive = driveList[i];
  1401             TInt drive = driveList[i];
  1194             driveNumber = TDriveNumber( i );
  1402             driveNumber = TDriveNumber( i );
  1195             if (drive)
  1403             if (drive)
  1196                 {
  1404                 {
  1197                 memoryType = AknCFDUtility::DriveMemoryTypeL( driveNumber );
  1405                 memoryType = AknCFDUtility::DriveMemoryTypeL( driveNumber );
       
  1406                 if ( memoryType == AknCommonDialogsDynMem::EMemoryTypeMMCExternal &&
       
  1407                         ( iIncludedMedias & AknCommonDialogsDynMem::EMemoryTypeMMCExternalInDevice ) )
       
  1408                     {
       
  1409                     // Hide usb memory
       
  1410                     TCFDDriveInfo info;
       
  1411                     AknCFDUtility::DriveInfoL( driveNumber, info );
       
  1412                     if ( info.iStatus & DriveInfo::EDriveUsbMemory )
       
  1413                         {
       
  1414                         continue;
       
  1415                         }
       
  1416                     else
       
  1417                         {
       
  1418                         memoryType = AknCommonDialogsDynMem::EMemoryTypeMMCExternalInDevice;
       
  1419                         }
       
  1420                     }
  1198                 if( memoryType & iIncludedMedias )
  1421                 if( memoryType & iIncludedMedias )
  1199                     {
  1422                     {
  1200                     User::LeaveIfError(
  1423                     User::LeaveIfError(
  1201                         PathInfo::GetRootPath( rootPath, driveNumber ) );
  1424                         PathInfo::GetRootPath( rootPath, driveNumber ) );
  1202                     driveArray->AppendL( rootPath );
  1425                     driveArray->AppendL( rootPath );