commonuis/CommonDialogs/src/caknmemoryselectionmodelmultidrive.cpp
changeset 0 2f259fa3e83a
child 4 8ca85d2f0db7
child 14 3320e4e6e8bb
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Model used in listbox of memory selection dialog which support
       
    15 *                multiple drives. It is used to replace
       
    16 *                CAknMemorySelectionModel
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #include <coemain.h>
       
    23 #include <StringLoader.h>
       
    24 #include <commondialogs.rsg>
       
    25 #include <rsfwmountman.h>
       
    26 #include <pathinfo.h> //PathInfo
       
    27 #include <barsread.h>   // TResourceReader
       
    28 #include <driveinfo.h> //DriveInfo
       
    29 #include "caknmemoryselectionmodelmultidrive.h"
       
    30 #include "CAknCommonDialogsBase.h"
       
    31 #include "AknCFDUtility.h"
       
    32 
       
    33 const TInt KListBoxEntryMaxLength( KMaxFileName + 32 );
       
    34 const TInt KNoIndex = -1;
       
    35 const TInt KIndexFirst = 0;
       
    36 const TInt KIndexSecond = 1;
       
    37 _LIT( KImageHeader, "%d" );
       
    38 _LIT( KTabChar, "\t" );
       
    39 _LIT( KSpaceChar, " " );
       
    40 
       
    41 
       
    42 // ======== MEMBER FUNCTIONS ========
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // CAknMemorySelectionModelMultiDrive::CAknMemorySelectionModelMultiDrive
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CAknMemorySelectionModelMultiDrive::CAknMemorySelectionModelMultiDrive(
       
    49     CCoeEnv* aCoeEnv,
       
    50     MDesCArray* aDriveArray,
       
    51     MDesCArray* aDefaultFolderArray,
       
    52     TInt aIncludedMedias,
       
    53     TBool aShowUnavailable,
       
    54     TListBoxLayout aLayout )
       
    55     :   iCoeEnv( aCoeEnv ),
       
    56         iDriveArray( aDriveArray ),
       
    57         iDefaultFolderArray( aDefaultFolderArray ),
       
    58         iIncludedMedias( aIncludedMedias ),
       
    59         iShowUnavailable( aShowUnavailable ),
       
    60         iLayout( aLayout )
       
    61     {
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CAknMemorySelectionModelMultiDrive::ConstructL
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void CAknMemorySelectionModelMultiDrive::ConstructL()
       
    69     {
       
    70     ReadResourcesL();
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CAknMemorySelectionModelMultiDrive::NewL
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 CAknMemorySelectionModelMultiDrive* CAknMemorySelectionModelMultiDrive::NewL(
       
    78     CCoeEnv* aCoeEnv,
       
    79     MDesCArray* aDriveArray,
       
    80     MDesCArray* aDefaultFolderArray,
       
    81     TInt aIncludedMedias,
       
    82     TBool aShowUnavailable,
       
    83     TListBoxLayout aLayout )
       
    84     {
       
    85     CAknMemorySelectionModelMultiDrive* self =
       
    86         new( ELeave ) CAknMemorySelectionModelMultiDrive(
       
    87             aCoeEnv, aDriveArray, aDefaultFolderArray,
       
    88             aIncludedMedias, aShowUnavailable, aLayout );
       
    89     CleanupStack::PushL( self );
       
    90     self->ConstructL();
       
    91     CleanupStack::Pop( self );
       
    92     return self;
       
    93     }
       
    94 
       
    95 // Destructor
       
    96 CAknMemorySelectionModelMultiDrive::~CAknMemorySelectionModelMultiDrive()
       
    97     {
       
    98     iListBoxArray.ResetAndDestroy();
       
    99     iListBoxArray.Close();
       
   100     iLocStringArray.ResetAndDestroy();
       
   101     iLocStringArray.Close();
       
   102     delete iDefDriveArray;
       
   103     iDefDriveArray = NULL;
       
   104     delete iDefDefaultFolderArray;
       
   105     iDefDefaultFolderArray = NULL;
       
   106     }
       
   107 
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CAknMemorySelectionModelMultiDrive::GetItem
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CAknMemorySelectionModelMultiDrive::GetItem( TInt aIndex, TDes& aItem )
       
   114     {
       
   115     aItem = iListBoxArray[ aIndex ]->Des();
       
   116     if( iLayout == ELayoutPopupMenu || iLayout == ELayoutDoublePopup )
       
   117         {
       
   118         // On layout with graphic, delete image index.
       
   119         _LIT( KTab, "\t" );
       
   120         TInt tabIndex( aItem.Find( KTab ) );
       
   121         if( tabIndex >= 0 )
       
   122             {
       
   123             aItem.Delete( 0, tabIndex + 1 );
       
   124             }
       
   125         if( iLayout == ELayoutDoublePopup )
       
   126             {
       
   127             tabIndex = aItem.Find( KTab );
       
   128             if( tabIndex >= 0 )
       
   129                 {
       
   130                 aItem = aItem.Left( tabIndex );
       
   131                 }
       
   132             }
       
   133         }
       
   134     }
       
   135 
       
   136 // ---------------------------------------------------------------------------
       
   137 // CAknMemorySelectionModelMultiDrive::UpdateItemsL
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 void CAknMemorySelectionModelMultiDrive::UpdateItemsL()
       
   141     {
       
   142     TInt drive;
       
   143     TCFDDriveInfo driveInfo;
       
   144 
       
   145     // If array has items - reset it before updating
       
   146     iListBoxArray.ResetAndDestroy();
       
   147     _LOG( "[CAknMemorySelectionModelMultiDrive] iDriveArray: " );
       
   148 
       
   149     // Go through all drives
       
   150     for( TInt index( 0 ); index < iDriveArray->MdcaCount(); index++ )
       
   151         { 
       
   152         TPtrC text(iDriveArray->MdcaPoint( index ));
       
   153         _LOG1( "%S", &text );
       
   154 
       
   155         drive = AknCFDUtility::DriveNumber( iDriveArray->MdcaPoint( index ) );
       
   156         User::LeaveIfError( drive ); // Leaves if < 0
       
   157         AknCFDUtility::DriveInfoL( TDriveNumber( drive ), driveInfo );
       
   158 
       
   159         _LOG7( "\n[CAknMemorySelectionModelMultiDrive] TCFDDriveInfo \n DriveNum:%d \n Path:%S \n Media:%d \n Status:%d \n Label:%S \n Space:%d \n ConnectionState:%d",
       
   160                driveInfo.iDriveNumber,
       
   161                &text,
       
   162                driveInfo.iMediaType,
       
   163                driveInfo.iDriveStatus,
       
   164                &(driveInfo.iVolumeLabel),
       
   165                driveInfo.iDiskSpace,
       
   166                driveInfo.iConnectionState );
       
   167 
       
   168         AddItemToLbxL( driveInfo );
       
   169         } // for
       
   170     }
       
   171 
       
   172 
       
   173 // ---------------------------------------------------------------------------
       
   174 // CAknMemorySelectionModelMultiDrive::MdcaCount
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 TInt CAknMemorySelectionModelMultiDrive::MdcaCount() const
       
   178     {
       
   179     return iListBoxArray.Count();
       
   180     }
       
   181 
       
   182 // ---------------------------------------------------------------------------
       
   183 // CAknMemorySelectionModelMultiDrive::MdcaPoint
       
   184 // ---------------------------------------------------------------------------
       
   185 //
       
   186 TPtrC CAknMemorySelectionModelMultiDrive::MdcaPoint( TInt aIndex ) const
       
   187     {
       
   188     return *iListBoxArray[ aIndex ];
       
   189     }
       
   190 
       
   191 // ---------------------------------------------------------------------------
       
   192 // CAknMemorySelectionModelMultiDrive::ReadResourcesL
       
   193 // ---------------------------------------------------------------------------
       
   194 //
       
   195 void CAknMemorySelectionModelMultiDrive::ReadResourcesL()
       
   196     {
       
   197     HBufC* buffer;
       
   198     TInt resource;
       
   199     for( TInt locStrIndex( 0 ); locStrIndex < ETextCount; locStrIndex++ )
       
   200         {
       
   201         resource = 0;
       
   202         // Resource depends on the layout type (TListBoxLayout):
       
   203         switch( iLayout )
       
   204             {
       
   205             case ELayoutPopupMenu:
       
   206                 {
       
   207                 resource = ResourceIDForLayoutPopupMenuItem( locStrIndex );
       
   208                 break;
       
   209                 }
       
   210             case ELayoutSettingPage:
       
   211                 {
       
   212                 resource = ResourceIDForLayoutSettingPageItem( locStrIndex );
       
   213                 break;
       
   214                 }
       
   215             case ELayoutDoublePopup:
       
   216                 {
       
   217                 resource = ResourceIDForLayoutDoublePopupItem( locStrIndex );
       
   218                 break;
       
   219                 }
       
   220             default:
       
   221                 {
       
   222                 User::Panic( KCFDPanicText, ECFDPanicOutOfBounds );
       
   223                 }
       
   224             }//iLayout
       
   225 
       
   226         if( resource )
       
   227             {
       
   228             buffer = NULL;
       
   229             buffer = iCoeEnv->AllocReadResourceLC( resource );
       
   230             User::LeaveIfError( iLocStringArray.Append( buffer ) );
       
   231             CleanupStack::Pop();
       
   232             }
       
   233 
       
   234         }//For loop
       
   235 
       
   236 #ifdef _DEBUG
       
   237         _LOG( "[CAknMemorySelectionModelMultiDrive] iLocStringArray: " );
       
   238         for( TInt lsa = 0; lsa < iLocStringArray.Count(); lsa++ )
       
   239             {
       
   240             _LOG1( "%S",iLocStringArray[ lsa ] );
       
   241             }
       
   242 #endif // _DEBUG
       
   243     }
       
   244 
       
   245 
       
   246 // ---------------------------------------------------------------------------
       
   247 // CAknMemorySelectionModelMultiDrive::ResourceIDForLayoutPopupMenuItem
       
   248 // ---------------------------------------------------------------------------
       
   249 //
       
   250 TInt CAknMemorySelectionModelMultiDrive::ResourceIDForLayoutPopupMenuItem(
       
   251     TInt aLocStrIndex )
       
   252     {
       
   253     TInt resource = 0;
       
   254     switch( aLocStrIndex )
       
   255         {
       
   256         case ETextDeviceMemory:
       
   257             {
       
   258             // qtn.mem.device.memory
       
   259             resource = R_CFD_QTN_MEM_DEVICE_MEMORY;
       
   260             break;
       
   261             }
       
   262         case ETextInternalMassStorage:
       
   263             {
       
   264             // qtn.mem.mass.storage
       
   265             resource = R_CFD_QTN_MEM_MASS_STORAGE;
       
   266             break;
       
   267             }
       
   268         case ETextInternalMassStorageUnavailable:
       
   269             {
       
   270             // qtn.mem.mass.storage.unavailable
       
   271             resource = R_CFD_QTN_MEM_MASS_STORAGE_UNAVAILABLE;
       
   272             break;
       
   273             }
       
   274         case ETextMMCDefaultName:
       
   275             {
       
   276             // If MMC's name is empty.
       
   277             // qtn.mem.memory.card.default
       
   278             resource = R_CFD_QTN_MEM_MEMORY_CARD_DEFAULT;
       
   279             break;
       
   280             }
       
   281         case ETextMMCNamed:
       
   282             {
       
   283             // If MMC's name is given.
       
   284             // qtn.mem.named.memory.card
       
   285             resource = R_CFD_QTN_MEM_NAMED_MEMORY_CARD;
       
   286             break;
       
   287             }
       
   288         case ETextMMCLocked:
       
   289             {
       
   290             // qtn.mem.memory.card.locked
       
   291             resource = R_CFD_QTN_MEM_MEMORY_CARD_LOCKED;
       
   292             break;
       
   293             }
       
   294         case ETextMMCUnavailable:
       
   295             {
       
   296             // qtn.mem.memory.card.unavailable
       
   297             resource = R_CFD_QTN_MEM_MEMORY_CARD_UNAVAILABLE;
       
   298             break;
       
   299             }
       
   300         case ETextRemoteDrive:
       
   301             {
       
   302             // qtn.memc.remote.drive
       
   303             resource = R_CFD_QTN_MEMC_REMOTE_DRIVE;
       
   304             break;
       
   305             }
       
   306         }
       
   307     return resource;
       
   308     }
       
   309 
       
   310 
       
   311 // ---------------------------------------------------------------------------
       
   312 // CAknMemorySelectionModelMultiDrive::ResourceIDForLayoutSettingPageItem
       
   313 // ---------------------------------------------------------------------------
       
   314 //
       
   315 TInt CAknMemorySelectionModelMultiDrive::ResourceIDForLayoutSettingPageItem(
       
   316     TInt aLocStrIndex )
       
   317     {
       
   318     TInt resource = 0;
       
   319     switch( aLocStrIndex )
       
   320         {
       
   321         case ETextDeviceMemory:
       
   322             {
       
   323             // qtn.mem.device.memory.setting.list
       
   324             resource = R_CFD_QTN_MEM_DEVICE_MEMEORY_SETTING_LIST;
       
   325             break;
       
   326             }
       
   327         case ETextInternalMassStorage:
       
   328         case ETextInternalMassStorageUnavailable:
       
   329             {
       
   330             // qtn.mem.mass.storage.setting.list
       
   331             resource = R_CFD_QTN_MEM_MASS_STORAGE_SETTING_LIST;
       
   332             break;
       
   333             }
       
   334         case ETextMMCDefaultName:
       
   335         case ETextMMCLocked:
       
   336         case ETextMMCUnavailable:
       
   337             {
       
   338             // If MMC's name is empty.
       
   339             // qtn.mem.memory.card.defaul.setting.list
       
   340             resource = R_CFD_QTN_MEM_MEMORY_CARD_DEFAULT_SETTING_LIST;
       
   341             break;
       
   342             }
       
   343         case ETextMMCNamed:
       
   344             {
       
   345             // If MMC's name is given.
       
   346             // qtn.mem.named.memory.card.setting.list
       
   347             resource = R_CFD_QTN_MEM_NAMED_MEMORY_CARD_SETTING_LIST;
       
   348             break;
       
   349             }
       
   350         case ETextRemoteDrive:
       
   351             {
       
   352             // TODO: To get real value from UI spec
       
   353             resource = R_CFD_QTN_MEMC_REMOTE_DRIVE;
       
   354             break;
       
   355             }
       
   356         }
       
   357     return resource;
       
   358     }
       
   359 
       
   360 
       
   361 // ---------------------------------------------------------------------------
       
   362 // CAknMemorySelectionModelMultiDrive::ResourceIDForLayoutDoublePopupItem
       
   363 // ---------------------------------------------------------------------------
       
   364 //
       
   365 TInt CAknMemorySelectionModelMultiDrive::ResourceIDForLayoutDoublePopupItem(
       
   366     TInt aLocStrIndex )
       
   367     {
       
   368     TInt resource = 0;
       
   369      switch( aLocStrIndex )
       
   370         {
       
   371         case ETextDeviceMemory:
       
   372             {
       
   373             // qtn.mem.device.memory.double.list
       
   374             resource = R_CFD_QTN_MEM_DEVICE_MEMORY_DOUBLE_LIST;
       
   375             break;
       
   376             }
       
   377         case ETextInternalMassStorage:
       
   378             {
       
   379             // qtn.mem.mass.storage.double.list
       
   380             resource = R_CFD_QTN_MEM_MASS_STORAGE_DOUBLE_LIST;
       
   381             break;
       
   382             }
       
   383         case ETextInternalMassStorageUnavailable:
       
   384             {
       
   385             // Unavailable:qtn.memc.mmc.unavailable.double
       
   386             // Only for second row
       
   387             resource = R_CFD_QTN_MEMC_MMC_UNAVAILABLE_DOUBLE;
       
   388             break;
       
   389             }
       
   390         case ETextMMCNamed:
       
   391             {
       
   392             // If MMC's name is given.
       
   393             // qtn.mem.named.memory.card.double
       
   394             resource = R_CFD_QTN_MEM_NAMED_MEMORY_CARD_DOUBLE;
       
   395             break;
       
   396             }
       
   397         case ETextMMCDefaultName:
       
   398             {
       
   399             // If MMC's name is empty.
       
   400             // qtn.mem.memory.card.default.double
       
   401             resource = R_CFD_QTN_MEM_MEMORY_CARD_DEFAULT_DOUBLE;
       
   402             break;
       
   403             }
       
   404         case ETextMMCLocked:
       
   405             {
       
   406             // qtn.memc.mmc.locked.double
       
   407             resource = R_CFD_QTN_MEMC_MMC_LOCKED_DOUBLE;
       
   408             break;
       
   409             }
       
   410         case ETextMMCUnavailable:
       
   411             {
       
   412             // qtn.memc.mmc.unavailable.double
       
   413             resource = R_CFD_QTN_MEMC_MMC_UNAVAILABLE_DOUBLE;
       
   414             break;
       
   415             }
       
   416         case ETextRemoteDrive:
       
   417             {
       
   418             // TODO: To be checked because of missing data in UI spec.
       
   419             resource = R_CFD_QTN_MEMC_REMOTE_DRIVE_DOUBLE_LIST;
       
   420             break;
       
   421             }
       
   422         }
       
   423     return resource;
       
   424 
       
   425     }
       
   426 
       
   427 
       
   428 // ---------------------------------------------------------------------------
       
   429 // CAknMemorySelectionModelMultiDrive::AddItemToLbxL
       
   430 // ---------------------------------------------------------------------------
       
   431 //
       
   432 void CAknMemorySelectionModelMultiDrive::AddItemToLbxL(
       
   433         const TCFDDriveInfo& aDriveInfo )
       
   434     {
       
   435     // Listbox items are differend depending on the media type.
       
   436     if ( aDriveInfo.iStatus & DriveInfo::EDriveInternal )
       
   437         {
       
   438         // Internal drives including device memory and internal mass storage
       
   439         if ( aDriveInfo.iStatus & DriveInfo::EDriveExternallyMountable )
       
   440             {
       
   441             // Internal mass storage drive
       
   442             AddInternalStorageItemToLbxL( aDriveInfo );
       
   443             }
       
   444         else
       
   445             {
       
   446             // Device memory drive
       
   447             AddDeviceMemoryItemToLbxL( aDriveInfo );
       
   448             }
       
   449         }
       
   450     else if( aDriveInfo.iStatus & DriveInfo::EDriveRemovable  )
       
   451         {
       
   452         // External mass storage drive, like external MMC
       
   453         AddMMCItemToLbxL( aDriveInfo );
       
   454 
       
   455         iHasMMCUnavailable = ( aDriveInfo.iDriveStatus == EDriveNotReady );
       
   456         }
       
   457     else if ( ( aDriveInfo.iStatus & DriveInfo::EDriveRemote )
       
   458         && ( aDriveInfo.iMediaType == EMediaRemote ) )
       
   459         // 2 conditions used here just for sure
       
   460         {
       
   461         // Remote drive
       
   462         AddRemoteItemToLbxL( aDriveInfo );
       
   463         }
       
   464     else
       
   465         {
       
   466         // Default
       
   467         // No actual use case for this yet.
       
   468         AddDefaultItemToLbxL( aDriveInfo );
       
   469         }
       
   470     }      
       
   471 
       
   472 // ---------------------------------------------------------------------------
       
   473 // CAknMemorySelectionModelMultiDrive::AddDeviceMemoryItemToLbxL
       
   474 // ---------------------------------------------------------------------------
       
   475 void CAknMemorySelectionModelMultiDrive::AddDeviceMemoryItemToLbxL(
       
   476     const TCFDDriveInfo& aDriveInfo )
       
   477     {
       
   478     HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   479     TPtr itemString( lbxItemBuf->Des() );
       
   480     HBufC* textItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   481     TPtr textString( textItemBuf->Des() );
       
   482     TDriveUnit driveUnit( aDriveInfo.iDriveNumber );
       
   483 
       
   484     // Item text is affected by layout
       
   485     switch( iLayout )
       
   486         {
       
   487             case ELayoutPopupMenu:
       
   488                 {
       
   489                 // A-column icon:
       
   490                 itemString.Format( KImageHeader, EIconDeviceMemory );
       
   491                 itemString.Append( KTabChar );
       
   492 
       
   493                 // 1st row text:
       
   494                 // Drive letter needs to be added
       
   495                 StringLoader::Format( textString,
       
   496                                       *iLocStringArray[ ETextDeviceMemory ],
       
   497                                       KNoIndex,
       
   498                                       driveUnit.Name() );
       
   499                 itemString.Append( textString );
       
   500                 break;
       
   501                 }
       
   502             case ELayoutSettingPage:
       
   503                 {
       
   504                 // 1st row text:
       
   505                 // Drive letter needs to be added
       
   506                 StringLoader::Format( itemString,
       
   507                                       *iLocStringArray[ ETextDeviceMemory ],
       
   508                                       KNoIndex,
       
   509                                       driveUnit.Name() );
       
   510                 break;
       
   511                 }
       
   512             case ELayoutDoublePopup:
       
   513                 {
       
   514                 // A-column icon:
       
   515                 itemString.Format( KImageHeader, EIconDeviceMemory );
       
   516                 itemString.Append( KTabChar );
       
   517 
       
   518                 // 1st row text:
       
   519                 StringLoader::Format( textString,
       
   520                                       *iLocStringArray[ ETextDeviceMemory ],
       
   521                                       KNoIndex,
       
   522                                       driveUnit.Name() );
       
   523                 itemString.Append( textString );
       
   524                 itemString.Append( KTabChar );
       
   525 
       
   526                 // 2nd row text:
       
   527                 HBufC* buffer;
       
   528                 TInt64 freeSpace = aDriveInfo.iDiskSpace;
       
   529                 if ( freeSpace >= 0 )
       
   530                     {
       
   531                     buffer = HBufC::NewLC( KListBoxEntryMaxLength );  
       
   532                     TPtr unitStr( buffer->Des() );
       
   533                     AknCFDUtility::SetSecondRowTextL( freeSpace, unitStr );
       
   534                     }
       
   535                 else
       
   536                     {
       
   537                     // Disk space is unavailable
       
   538                     buffer = StringLoader::LoadLC(
       
   539                                 R_CFD_QTN_MEMC_SPACE_NOT_AVAILABLE,
       
   540                                 iCoeEnv);
       
   541                     }
       
   542                 itemString.Append( *buffer );//Free mem text
       
   543                 CleanupStack::PopAndDestroy( buffer );
       
   544                 break;
       
   545                 }
       
   546             }
       
   547 
       
   548     // Finally!: append the formatted string to listbox
       
   549     User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
       
   550     CleanupStack::PopAndDestroy( textItemBuf );
       
   551     CleanupStack::Pop( lbxItemBuf );
       
   552     _LOG1(
       
   553         "[CAknMemorySelectionModelMultiDrive] Item string added to lbx array: %S",
       
   554            &itemString );
       
   555     _LOG1( "itemString length=%d", itemString.Length() );
       
   556     }
       
   557 
       
   558 // --------------------------------------------------------------------------
       
   559 // CAknMemorySelectionModelMultiDrive::AddInternalStorageItemToLbxL
       
   560 //
       
   561 //
       
   562 // --------------------------------------------------------------------------
       
   563 //
       
   564 void CAknMemorySelectionModelMultiDrive::AddInternalStorageItemToLbxL(
       
   565     const TCFDDriveInfo& aDriveInfo )
       
   566     {
       
   567     HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   568     TPtr itemString( lbxItemBuf->Des() );
       
   569     HBufC* textItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   570     TPtr textString( textItemBuf->Des() );
       
   571     TDriveUnit driveUnit( aDriveInfo.iDriveNumber );
       
   572 
       
   573     // Item text is affected by layout
       
   574     switch( iLayout )
       
   575         {
       
   576         case ELayoutPopupMenu:
       
   577             {
       
   578             // A-column icon:
       
   579             if( aDriveInfo.iDriveStatus == EDriveOK )
       
   580                 {
       
   581                 itemString.Format( KImageHeader, EIconInternalMassStorage );
       
   582                 }
       
   583             else
       
   584                 {
       
   585                 itemString.Format( KImageHeader,
       
   586                                    EIconInternalMassStorageUnavailable );
       
   587                 }
       
   588             itemString.Append( KTabChar );
       
   589 
       
   590             // 1st row text:
       
   591             if( aDriveInfo.iDriveStatus == EDriveOK )
       
   592                 {
       
   593                 StringLoader::Format(
       
   594                     textString,
       
   595                     *iLocStringArray[ ETextInternalMassStorage ],
       
   596                     KNoIndex,
       
   597                     driveUnit.Name()
       
   598                     );
       
   599                 }
       
   600             else
       
   601                 {
       
   602                 StringLoader::Format(
       
   603                     textString,
       
   604                     *iLocStringArray[ ETextInternalMassStorageUnavailable ],
       
   605                     KNoIndex,
       
   606                     driveUnit.Name()
       
   607                     );
       
   608                 }
       
   609             itemString.Append( textString );
       
   610             break;
       
   611             }
       
   612         case ELayoutSettingPage:
       
   613             {
       
   614             // 1st row text:
       
   615             StringLoader::Format(
       
   616                     itemString,
       
   617                     *iLocStringArray[ ETextInternalMassStorage ],
       
   618                     KNoIndex,
       
   619                     driveUnit.Name()
       
   620                     );
       
   621             break;
       
   622             }
       
   623         case ELayoutDoublePopup:
       
   624             {
       
   625             // A-column icon:
       
   626             itemString.Format( KImageHeader, EIconInternalMassStorage );
       
   627             itemString.Append( KTabChar );
       
   628 
       
   629             // 1st row text:
       
   630             StringLoader::Format(
       
   631                     textString,
       
   632                     *iLocStringArray[ ETextInternalMassStorage ],
       
   633                     KNoIndex,
       
   634                     driveUnit.Name()
       
   635                     );
       
   636             itemString.Append( textString );
       
   637             itemString.Append( KTabChar );
       
   638 
       
   639             // 2nd row text:
       
   640             if ( aDriveInfo.iDriveStatus == EDriveOK )
       
   641                 {
       
   642                 HBufC* buffer;
       
   643                 TInt64 freeSpace = aDriveInfo.iDiskSpace;
       
   644                 if ( freeSpace >= 0 )
       
   645                     {
       
   646                     buffer = HBufC::NewLC( KListBoxEntryMaxLength );  
       
   647                     TPtr unitStr( buffer->Des() );
       
   648                     AknCFDUtility::SetSecondRowTextL( freeSpace, unitStr );
       
   649                     }
       
   650                 else
       
   651                     {
       
   652                     // Disk space is unavailable
       
   653                     buffer = StringLoader::LoadLC(
       
   654                                 R_CFD_QTN_MEMC_SPACE_NOT_AVAILABLE,
       
   655                                 iCoeEnv);
       
   656                     }
       
   657                 itemString.Append( *buffer );//Free mem text
       
   658                 CleanupStack::PopAndDestroy( buffer );
       
   659                 }
       
   660             else
       
   661                 {
       
   662                 itemString.Append(
       
   663                     *iLocStringArray[
       
   664                         ETextInternalMassStorageUnavailable ] );
       
   665                 }
       
   666             break;
       
   667             }
       
   668         }
       
   669 
       
   670     // Finally!: append the formatted string to listbox
       
   671     User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
       
   672     CleanupStack::PopAndDestroy( textItemBuf );
       
   673     CleanupStack::Pop( lbxItemBuf );
       
   674     _LOG1( "[CAknMemorySelectionModelMultiDrive] Item string added to lbx array: %S", &itemString );
       
   675     _LOG1( "itemString length=%d", itemString.Length() );
       
   676     }
       
   677 
       
   678 // ---------------------------------------------------------------------------
       
   679 // CAknMemorySelectionModelMultiDrive::AddMMCItemToLbxL
       
   680 // ---------------------------------------------------------------------------
       
   681 //
       
   682 void CAknMemorySelectionModelMultiDrive::AddMMCItemToLbxL(
       
   683     const TCFDDriveInfo& aDriveInfo )
       
   684     {
       
   685     HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   686     TPtr itemString( lbxItemBuf->Des() );
       
   687     HBufC* textItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   688     TPtr textString( textItemBuf->Des() );
       
   689     HBufC* textItemBuf2 = HBufC::NewLC( KListBoxEntryMaxLength );
       
   690     TPtr textString2( textItemBuf2->Des() );
       
   691     TDriveUnit driveUnit( aDriveInfo.iDriveNumber );
       
   692 
       
   693     // Item text is affected by layout
       
   694     switch( iLayout )
       
   695         {
       
   696         case ELayoutPopupMenu:
       
   697             {
       
   698             // A-column icon:
       
   699             switch ( aDriveInfo.iDriveStatus )
       
   700                 {
       
   701                 case EDriveNotReady:
       
   702                     {
       
   703                     itemString.Format( KImageHeader, EIconMMCUnavailable );
       
   704                     break;
       
   705                     }
       
   706                 case EDriveLocked:
       
   707                     {
       
   708                     itemString.Format( KImageHeader, EIconMMCLocked );
       
   709                     break;
       
   710                     }
       
   711                  default: // Normal condition
       
   712                     {
       
   713                     itemString.Format( KImageHeader, EIconMMC );
       
   714                     break;
       
   715                     }
       
   716                 }
       
   717             itemString.Append( KTabChar );
       
   718 
       
   719             // 1st row text:
       
   720             if( ( aDriveInfo.iDriveStatus == EDriveOK ) &&
       
   721                 ( aDriveInfo.iVolumeLabel.Length() > 0 ) )
       
   722                 {
       
   723                 StringLoader::Format(
       
   724                     textString2,
       
   725                     *iLocStringArray[ ETextMMCNamed ],
       
   726                     KIndexFirst,
       
   727                     driveUnit.Name()
       
   728                     );
       
   729                 StringLoader::Format(
       
   730                     textString,
       
   731                     textString2,
       
   732                     KIndexSecond,
       
   733                     aDriveInfo.iVolumeLabel
       
   734                     );
       
   735                 }
       
   736             else if ( aDriveInfo.iDriveStatus == EDriveNotReady )
       
   737                 {
       
   738                 //textString.Format(
       
   739                 //    *iLocStringArray[ ETextMMCUnavailable ],
       
   740                 //    driveUnit.Name() );
       
   741                 StringLoader::Format(
       
   742                     textString,
       
   743                     *iLocStringArray[ ETextMMCUnavailable ],
       
   744                     KNoIndex,
       
   745                     driveUnit.Name()
       
   746                     );
       
   747                 }
       
   748             else if( aDriveInfo.iDriveStatus == EDriveLocked )
       
   749                 {
       
   750                 //textString.Format(
       
   751                 //    *iLocStringArray[ ETextMMCLocked ],
       
   752                 //    driveUnit.Name() );
       
   753                 StringLoader::Format(
       
   754                     textString,
       
   755                     *iLocStringArray[ ETextMMCLocked ],
       
   756                     KNoIndex,
       
   757                     driveUnit.Name()
       
   758                     );
       
   759                 }
       
   760             else
       
   761                 {
       
   762                 // Use default drive description
       
   763                 //textString.Format(
       
   764                 //    *iLocStringArray[ ETextMMCDefaultName ],
       
   765                 //    driveUnit.Name() );
       
   766                 StringLoader::Format(
       
   767                     textString,
       
   768                     *iLocStringArray[ ETextMMCDefaultName ],
       
   769                     KNoIndex,
       
   770                     driveUnit.Name()
       
   771                     );
       
   772                 }
       
   773             itemString.Append( textString );
       
   774 
       
   775             break;
       
   776             }
       
   777         case ELayoutSettingPage:
       
   778             {
       
   779             // 1st row text:
       
   780             if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   781                 {
       
   782                 // Append drive name if it has one
       
   783                 //itemString.Format(
       
   784                 //    *iLocStringArray[ ETextMMCNamed ],
       
   785                 //    driveUnit.Name(),
       
   786                 //    aDriveInfo.iVolumeLabel
       
   787                 //    );
       
   788                 StringLoader::Format(
       
   789                     textString,
       
   790                     *iLocStringArray[ ETextMMCNamed ],
       
   791                     KIndexFirst,
       
   792                     driveUnit.Name()
       
   793                     );
       
   794                 StringLoader::Format(
       
   795                     itemString,
       
   796                     textString,
       
   797                     KIndexSecond,
       
   798                     aDriveInfo.iVolumeLabel
       
   799                     );
       
   800                 }
       
   801             else
       
   802                 {
       
   803                 //itemString.Format(
       
   804                 //    *iLocStringArray[ ETextMMCDefaultName ],
       
   805                 //    driveUnit.Name()
       
   806                 //    );
       
   807                 StringLoader::Format(
       
   808                     itemString,
       
   809                     *iLocStringArray[ ETextMMCDefaultName ],
       
   810                     KNoIndex,
       
   811                     driveUnit.Name()
       
   812                     );
       
   813                 }
       
   814             break;
       
   815             }
       
   816         case ELayoutDoublePopup:
       
   817             {
       
   818             // A-column icon:
       
   819             if( aDriveInfo.iDriveStatus == EDriveNotReady )
       
   820                 {
       
   821                 itemString.Format( KImageHeader, EIconMMCUnavailable );
       
   822                 }
       
   823             else
       
   824                 {
       
   825                 itemString.Format( KImageHeader, EIconMMC );
       
   826                 }
       
   827             itemString.Append( KTabChar );
       
   828 
       
   829             // 1st row text:
       
   830             if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   831                 {
       
   832                 StringLoader::Format(
       
   833                     textString2,
       
   834                     *iLocStringArray[ ETextMMCNamed ],
       
   835                     KIndexFirst,
       
   836                     driveUnit.Name()
       
   837                     );
       
   838                 StringLoader::Format(
       
   839                     textString,
       
   840                     textString2,
       
   841                     KIndexSecond,
       
   842                     aDriveInfo.iVolumeLabel
       
   843                     );
       
   844                 }
       
   845             else
       
   846                 {
       
   847                 // Use default drive description
       
   848                 //textString.Format(
       
   849                 //    *iLocStringArray[ ETextMMCDefaultName ],
       
   850                 //    driveUnit.Name()
       
   851                 //   );
       
   852                 StringLoader::Format(
       
   853                     textString,
       
   854                     *iLocStringArray[ ETextMMCDefaultName ],
       
   855                     KNoIndex,
       
   856                     driveUnit.Name()
       
   857                     );
       
   858                 }
       
   859             itemString.Append( textString );
       
   860             itemString.Append( KTabChar );
       
   861 
       
   862             // 2nd row text:
       
   863             switch( aDriveInfo.iDriveStatus )
       
   864                 {
       
   865                 case EDriveNotReady:
       
   866                     {
       
   867                     itemString.Append(
       
   868                         *iLocStringArray[ ETextMMCUnavailable ] );
       
   869                     break;
       
   870                     }
       
   871                 case EDriveLocked:
       
   872                     {
       
   873                     itemString.Append( *iLocStringArray[ ETextMMCLocked ] );
       
   874                     break;
       
   875                     }
       
   876                 case EDriveOK:
       
   877                 default:
       
   878                     {
       
   879                     HBufC* buffer;
       
   880                     TInt64 freeSpace = aDriveInfo.iDiskSpace;
       
   881                     if ( freeSpace >= 0 )
       
   882                         {
       
   883                         buffer = HBufC::NewLC( KListBoxEntryMaxLength );  
       
   884                         TPtr unitStr( buffer->Des() );
       
   885                         AknCFDUtility::SetSecondRowTextL( freeSpace, unitStr );
       
   886                         }
       
   887                     else
       
   888                         {
       
   889                         // Disk space is unavailable
       
   890                         buffer = StringLoader::LoadLC(
       
   891                                     R_CFD_QTN_MEMC_SPACE_NOT_AVAILABLE,
       
   892                                     iCoeEnv);
       
   893                         }
       
   894                     itemString.Append( *buffer );//Free mem text
       
   895                     CleanupStack::PopAndDestroy( buffer );
       
   896                     break;
       
   897                     }
       
   898                 }
       
   899             break;
       
   900             }
       
   901         }
       
   902 
       
   903     // Finally!: append the formatted string to listbox
       
   904     User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
       
   905     CleanupStack::PopAndDestroy( 2 ); // textItemBuf2, textItemBuf
       
   906     CleanupStack::Pop( lbxItemBuf );
       
   907     _LOG1( "[CAknMemorySelectionModelMultiDrive] Item string added to lbx array: %S", &itemString );
       
   908     _LOG1( "itemString length=%d", itemString.Length() );
       
   909     }
       
   910 
       
   911 
       
   912 // ---------------------------------------------------------------------------
       
   913 // CAknMemorySelectionModelMultiDrive::AddRemoteItemToLbxL
       
   914 // ---------------------------------------------------------------------------
       
   915 //
       
   916 void CAknMemorySelectionModelMultiDrive::AddRemoteItemToLbxL( const TCFDDriveInfo& aDriveInfo )
       
   917     {
       
   918     HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   919     TPtr itemString( lbxItemBuf->Des() );
       
   920 
       
   921     // Item text is affected by layout
       
   922     switch( iLayout )
       
   923         {
       
   924         case ELayoutPopupMenu:
       
   925             {
       
   926             // A-column icon:
       
   927             itemString.Format( KImageHeader, EIconRemoteDrive );
       
   928             itemString.Append( KTabChar );
       
   929 
       
   930             // 1st row text:
       
   931             if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   932                 {
       
   933                 // Append drive name if it has one
       
   934                 itemString.Append( aDriveInfo.iVolumeLabel );
       
   935                 }
       
   936             else
       
   937                 {
       
   938                 // Use default drive description
       
   939                 itemString.Append( *iLocStringArray[ ETextRemoteDrive ] );
       
   940                 }
       
   941             break;
       
   942             }
       
   943         case ELayoutSettingPage:
       
   944             {
       
   945             // 1st row text:
       
   946             if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   947                 {
       
   948                 // Append drive name if it has one
       
   949                 itemString.Append( aDriveInfo.iVolumeLabel );
       
   950                 }
       
   951             else
       
   952                 {
       
   953                 // Use default drive description
       
   954                 itemString.Append( *iLocStringArray[ ETextRemoteDrive ] );
       
   955                 }
       
   956             break;
       
   957             }
       
   958         case ELayoutDoublePopup:
       
   959             {
       
   960             // A-column icon:
       
   961             itemString.Format( KImageHeader, EIconRemoteDrive );
       
   962             itemString.Append( KTabChar );
       
   963 
       
   964             // 1st row text:
       
   965             if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   966                 {
       
   967                 // Append drive name if it has one
       
   968                 itemString.Append( aDriveInfo.iVolumeLabel );
       
   969                 itemString.Append( KTabChar );
       
   970                 }
       
   971             else
       
   972                 {
       
   973                 // Use default drive description
       
   974                 itemString.Append( *iLocStringArray[ ETextRemoteDrive ] );
       
   975                 itemString.Append( KTabChar );
       
   976                 }
       
   977 
       
   978             if( aDriveInfo.iDriveStatus == EDriveOK )
       
   979                 {
       
   980                 // 2nd row text:
       
   981                 // Currently Remote drive does not support query for available
       
   982                 // disk space, so just return " "
       
   983                 _LIT( KEmptySpace, " ");
       
   984                 itemString.Append( KEmptySpace ); 
       
   985 
       
   986                 if( aDriveInfo.iConnectionState == KMountStronglyConnected )
       
   987                     {
       
   988                     // D-column icon: Show active icon if drive has no error
       
   989                     itemString.Append( KTabChar );
       
   990                     itemString.AppendFormat(
       
   991                         KImageHeader, EIconRemoteDriveActive );
       
   992                     }
       
   993                 else // KMountNotConnected
       
   994                     {
       
   995                     // D-column icon: Show active icon if drive has no error
       
   996                     itemString.Append( KTabChar );
       
   997                     }
       
   998                 }
       
   999             else
       
  1000                 {
       
  1001                 // 2nd row text:
       
  1002                 itemString.Append( *iLocStringArray[ ETextMMCUnavailable ] );
       
  1003                 // D-column is empty if error.
       
  1004                 }
       
  1005             break;
       
  1006             }
       
  1007         }
       
  1008 
       
  1009     // Finally!: append the formatted string to listbox
       
  1010     User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
       
  1011     CleanupStack::Pop( lbxItemBuf );
       
  1012     _LOG1( "[CAknMemorySelectionModelMultiDrive] Item string added to lbx array: %S", &itemString );
       
  1013     _LOG1( "itemString length=%d", itemString.Length() );
       
  1014     }
       
  1015 
       
  1016 
       
  1017 // ---------------------------------------------------------------------------
       
  1018 // CAknMemorySelectionModelMultiDrive::AddDefaultItemToLbxL
       
  1019 //
       
  1020 // If drive has volume label, use it.
       
  1021 // Otherwise use drive letter for drive name.
       
  1022 // ---------------------------------------------------------------------------
       
  1023 //
       
  1024 void CAknMemorySelectionModelMultiDrive::AddDefaultItemToLbxL(
       
  1025     const TCFDDriveInfo& aDriveInfo )
       
  1026     {
       
  1027     HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
  1028     TPtr itemString( lbxItemBuf->Des() );
       
  1029     TDriveUnit driveUnit( aDriveInfo.iDriveNumber );
       
  1030 
       
  1031     // Item text is affected by layout
       
  1032     switch( iLayout )
       
  1033         {
       
  1034         case ELayoutSettingPage:
       
  1035             {
       
  1036             if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
  1037                 {
       
  1038                 itemString.Append( driveUnit.Name() );
       
  1039                 itemString.Append( KSpaceChar );
       
  1040                 itemString.Append( aDriveInfo.iVolumeLabel );
       
  1041                 }
       
  1042             else
       
  1043                 {
       
  1044                 itemString.Append( driveUnit.Name() );
       
  1045                 }
       
  1046             break;
       
  1047             }
       
  1048         case ELayoutPopupMenu:
       
  1049         case ELayoutDoublePopup:
       
  1050             {
       
  1051             itemString.Format( KImageHeader, EIconDeviceMemory );
       
  1052             itemString.Append( KTabChar );
       
  1053 
       
  1054             if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
  1055                 {
       
  1056                 itemString.Append( driveUnit.Name() );
       
  1057                 itemString.Append( KSpaceChar );
       
  1058                 itemString.Append( aDriveInfo.iVolumeLabel );
       
  1059                 }
       
  1060             else
       
  1061                 {
       
  1062                 itemString.Append( driveUnit.Name() );
       
  1063                 }
       
  1064             break;
       
  1065             }
       
  1066         }
       
  1067 
       
  1068     // Finally!: append the formatted string to listbox
       
  1069     User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
       
  1070     CleanupStack::Pop( lbxItemBuf );
       
  1071     _LOG1( "[CAknMemorySelectionModelMultiDrive] Item string added to lbx array: %S", &itemString );
       
  1072     _LOG1( "itemString length=%d", itemString.Length() );
       
  1073     }
       
  1074 
       
  1075 
       
  1076 // ---------------------------------------------------------------------------
       
  1077 // CAknMemorySelectionModelMultiDrive::GetDrive
       
  1078 // ---------------------------------------------------------------------------
       
  1079 //
       
  1080 void CAknMemorySelectionModelMultiDrive::GetDrive( TInt aLbxItemIndex, TDes& aDrivePath )
       
  1081     {
       
  1082     if( aLbxItemIndex < iDriveArray->MdcaCount() )
       
  1083         {
       
  1084         aDrivePath = iDriveArray->MdcaPoint( aLbxItemIndex );
       
  1085         }
       
  1086     }
       
  1087 
       
  1088 // ---------------------------------------------------------------------------
       
  1089 // CAknMemorySelectionModelMultiDrive::HasUnavailbleMMC
       
  1090 // ---------------------------------------------------------------------------
       
  1091 //
       
  1092 TBool CAknMemorySelectionModelMultiDrive::HasUnavailbleMMC()
       
  1093     {
       
  1094     return iHasMMCUnavailable;
       
  1095     }
       
  1096 
       
  1097 // ---------------------------------------------------------------------------
       
  1098 // CAknMemorySelectionModelMultiDrive::ReadUserDefinedDataL
       
  1099 // ---------------------------------------------------------------------------
       
  1100 //
       
  1101 void CAknMemorySelectionModelMultiDrive::ReadUserDefinedDataL(
       
  1102     TResourceReader& aReader, TInt aLocations )
       
  1103     {
       
  1104     if ( aLocations <= 0)
       
  1105         {
       
  1106         return;
       
  1107         }
       
  1108     
       
  1109     iDefDriveArray = new ( ELeave ) CDesCArrayFlat( aLocations );
       
  1110     iDefDefaultFolderArray = new ( ELeave ) CDesCArrayFlat( aLocations );
       
  1111     for ( TInt i = 0; i < aLocations; i++ )
       
  1112         {
       
  1113         // read the location, save path and default folder in array
       
  1114         TPath temp;
       
  1115         temp.Copy( aReader.ReadTPtrC() );
       
  1116         iDefDriveArray->AppendL( temp );
       
  1117         temp.Copy( aReader.ReadTPtrC() );
       
  1118         iDefDefaultFolderArray->AppendL( temp );
       
  1119         }
       
  1120     }
       
  1121 
       
  1122 // ---------------------------------------------------------------------------
       
  1123 // CAknMemorySelectionModelMultiDrive::UpdateDataArraysL
       
  1124 // ---------------------------------------------------------------------------
       
  1125 //
       
  1126 void CAknMemorySelectionModelMultiDrive::UpdateDataArraysL()
       
  1127     {
       
  1128     TDriveList driveList;
       
  1129     TInt driveCount;
       
  1130     User::LeaveIfError( DriveInfo::GetUserVisibleDrives(
       
  1131         iCoeEnv->FsSession(), driveList, driveCount, KDriveAttAll ) );
       
  1132     TPath rootPath;
       
  1133     TDriveNumber driveNumber;
       
  1134     AknCommonDialogsDynMem::TMemoryTypes memoryType;
       
  1135     
       
  1136     CDesCArrayFlat* driveArray = STATIC_CAST( CDesCArrayFlat*, iDriveArray );
       
  1137     CDesCArrayFlat* defaultFolderArray =
       
  1138         STATIC_CAST( CDesCArrayFlat*, iDefaultFolderArray );
       
  1139     driveArray->Reset();
       
  1140     defaultFolderArray->Reset();
       
  1141     
       
  1142     if ( iDefDriveArray != NULL && iDefDefaultFolderArray != NULL )
       
  1143         {
       
  1144         for ( TInt i = 0; i < KMaxDrives; i++ )
       
  1145             {
       
  1146             TInt driveExist = driveList[i];
       
  1147             if ( driveExist )
       
  1148                 {
       
  1149                 driveNumber = TDriveNumber( i );
       
  1150                 rootPath.Zero();
       
  1151                 memoryType = AknCFDUtility::DriveMemoryTypeL( driveNumber );
       
  1152                 if( memoryType & iIncludedMedias )
       
  1153                     {
       
  1154                     User::LeaveIfError(
       
  1155                     PathInfo::GetRootPath( rootPath, driveNumber ) );
       
  1156                     }
       
  1157                 else
       
  1158                     {
       
  1159                     continue;
       
  1160                     }
       
  1161                 
       
  1162                 TBool isUserDefined = EFalse;
       
  1163                 // add right location even user's location with wrong sequence
       
  1164                 for ( TInt j = 0; j < iDefDriveArray->MdcaCount(); j++ )
       
  1165                     {
       
  1166                     // same drive info and user's root path must under c:\data\.
       
  1167                     // try to get the location
       
  1168                     if ( ( *iDefDriveArray )[j].FindC( rootPath ) == 0 )
       
  1169                         {
       
  1170                         // Use user's root path, part of user definiens
       
  1171                         // (lowercase) may be replaced by system rootPath
       
  1172                         rootPath.Append( ( *iDefDriveArray )[j].Right( 
       
  1173                             ( *iDefDriveArray )[j].Length() - rootPath.Length() ) );
       
  1174                         driveArray->AppendL( rootPath );
       
  1175                         defaultFolderArray->AppendL( ( *iDefDefaultFolderArray )[j] );
       
  1176                         isUserDefined = ETrue;
       
  1177                         break;
       
  1178                         }
       
  1179                     }
       
  1180                 if ( !isUserDefined )
       
  1181                     {
       
  1182                     // user does not define location for this drive
       
  1183                     // use the default
       
  1184                     driveArray->AppendL( rootPath );
       
  1185                     defaultFolderArray->AppendL( KNullDesC );
       
  1186                     }
       
  1187                 }
       
  1188             }
       
  1189         }
       
  1190     else
       
  1191         {
       
  1192         for ( TInt i=0; i<KMaxDrives; i++ )
       
  1193             {
       
  1194             TInt drive = driveList[i];
       
  1195             driveNumber = TDriveNumber( i );
       
  1196             if (drive)
       
  1197                 {
       
  1198                 memoryType = AknCFDUtility::DriveMemoryTypeL( driveNumber );
       
  1199                 if( memoryType & iIncludedMedias )
       
  1200                     {
       
  1201                     User::LeaveIfError(
       
  1202                         PathInfo::GetRootPath( rootPath, driveNumber ) );
       
  1203                     driveArray->AppendL( rootPath );
       
  1204                     defaultFolderArray->AppendL( KNullDesC );
       
  1205                     }
       
  1206                 }
       
  1207             }
       
  1208         }
       
  1209     }
       
  1210 
       
  1211 // End of File