commonuis/CommonDialogs/src/CAknMemorySelectionModel.cpp
changeset 0 2f259fa3e83a
child 14 3320e4e6e8bb
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include "CAknMemorySelectionModel.h"
       
    21 #include "CAknCommonDialogsBase.h"
       
    22 #include "AknCFDUtility.h"
       
    23 
       
    24 #include <coemain.h>
       
    25 #include <StringLoader.h>
       
    26 #include <commondialogs.rsg>
       
    27 #include <rsfwmountman.h>
       
    28 #include <pathinfo.h> //PathInfo
       
    29 #include <driveinfo.h> //DriveInfo
       
    30 
       
    31 // CONSTANTS
       
    32 const TInt KListBoxEntryMaxLength( KMaxFileName + 32 );
       
    33 
       
    34 _LIT( KImageHeader, "%d" );
       
    35 _LIT( KTabChar, "\t" );
       
    36 
       
    37 
       
    38 // ============================ MEMBER FUNCTIONS ===============================
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CAknMemorySelectionModel::CAknMemorySelectionModel
       
    42 //
       
    43 //
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CAknMemorySelectionModel::CAknMemorySelectionModel(
       
    47 	CCoeEnv* aCoeEnv,
       
    48 	MDesCArray* aDriveArray,
       
    49 	TBool aShowUnavailable,
       
    50 	TListBoxLayout aLayout )
       
    51 	:	iCoeEnv( aCoeEnv ),
       
    52 		iDriveArray( aDriveArray ),
       
    53 		iShowUnavailable( aShowUnavailable ),
       
    54 		iLayout( aLayout )
       
    55 	{
       
    56 	}
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CAknMemorySelectionModel::ConstructL
       
    60 //
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CAknMemorySelectionModel::ConstructL()
       
    64 	{
       
    65 	ReadResourcesL();
       
    66 	UpdateItemsL();
       
    67 	}
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CAknMemorySelectionModel::NewL
       
    71 //
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 CAknMemorySelectionModel* CAknMemorySelectionModel::NewL(
       
    75 	CCoeEnv* aCoeEnv,
       
    76 	MDesCArray* aDriveArray,
       
    77 	TBool aShowUnavailable,
       
    78 	TListBoxLayout aLayout )
       
    79 	{
       
    80 	CAknMemorySelectionModel* self = new( ELeave ) CAknMemorySelectionModel(
       
    81 		aCoeEnv, aDriveArray, aShowUnavailable, aLayout );
       
    82 	CleanupStack::PushL( self );
       
    83 	self->ConstructL();
       
    84 	CleanupStack::Pop( self );
       
    85 	return self;
       
    86 	}
       
    87 
       
    88 // Destructor
       
    89 CAknMemorySelectionModel::~CAknMemorySelectionModel()
       
    90 	{
       
    91 	iListBoxArray.ResetAndDestroy();
       
    92 	iListBoxArray.Close();
       
    93 	iLocStringArray.ResetAndDestroy();
       
    94 	iLocStringArray.Close();
       
    95 	}
       
    96 
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CAknMemorySelectionModel::GetItem
       
   100 //
       
   101 //
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 void CAknMemorySelectionModel::GetItem( TInt aIndex, TDes& aItem )
       
   105 	{
       
   106     TInt err = 0;
       
   107 	TRAP( err, UpdateItemsL() );
       
   108 	aItem = iListBoxArray[ aIndex ]->Des();
       
   109 	if( iLayout == ELayoutPopupMenu || iLayout == ELayoutDoublePopup )
       
   110 		{
       
   111 		// On layout with graphic, delete image index.
       
   112 		_LIT( KTab, "\t" );
       
   113 		TInt tabIndex( aItem.Find( KTab ) );
       
   114 		if( tabIndex >= 0 )
       
   115 			{
       
   116 			aItem.Delete( 0, tabIndex + 1 );
       
   117 			}
       
   118 		if( iLayout == ELayoutDoublePopup )
       
   119 			{
       
   120 			tabIndex = aItem.Find( KTab );
       
   121 			if( tabIndex >= 0 )
       
   122 				{
       
   123 				aItem = aItem.Left( tabIndex );
       
   124 				}
       
   125 			}
       
   126 		}
       
   127 	}
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CAknMemorySelectionModel::UpdateItemsL
       
   131 //
       
   132 //
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void CAknMemorySelectionModel::UpdateItemsL()
       
   136 	{
       
   137 	TInt drive;
       
   138 	TCFDDriveInfo driveInfo;
       
   139 
       
   140 	// If array has items - reset it before updating
       
   141 	iListBoxArray.ResetAndDestroy();
       
   142 	_LOG( "[CAknMemorySelectionModel] iDriveArray: " );
       
   143 
       
   144 	// Go through all drives
       
   145     for (TInt index( 0); index < iDriveArray->MdcaCount(); index++)
       
   146         {
       
   147         TPtrC text = iDriveArray->MdcaPoint( index );
       
   148         _LOG1( "%S", &text );
       
   149 
       
   150         drive = AknCFDUtility::DriveNumber( iDriveArray->MdcaPoint( index ) );
       
   151         User::LeaveIfError( drive ); // Leaves if < 0
       
   152         AknCFDUtility::DriveInfoL( TDriveNumber( drive ), driveInfo );
       
   153 
       
   154         _LOG7( "\n[CAknMemorySelectionModel] TCFDDriveInfo \n DriveNum:%d \n Path:%S \n Media:%d \n Status:%d \n Label:%S \n Space:%d \n ConnectionState:%d",
       
   155                 driveInfo.iDriveNumber,
       
   156                 &text,
       
   157                 driveInfo.iMediaType,
       
   158                 driveInfo.iDriveStatus,
       
   159                 &(driveInfo.iVolumeLabel),
       
   160                 driveInfo.iDiskSpace,
       
   161                 driveInfo.iConnectionState );
       
   162 
       
   163         AddItemToLbxL(driveInfo);
       
   164         } // for
       
   165 	}
       
   166 
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 // CAknMemorySelectionModel::MdcaCount
       
   170 //
       
   171 //
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 TInt CAknMemorySelectionModel::MdcaCount() const
       
   175 	{
       
   176 	return iListBoxArray.Count();
       
   177 	}
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CAknMemorySelectionModel::MdcaPoint
       
   181 //
       
   182 //
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 TPtrC CAknMemorySelectionModel::MdcaPoint( TInt aIndex ) const
       
   186 	{
       
   187 	return *iListBoxArray[ aIndex ];
       
   188 	}
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // CAknMemorySelectionModel::ReadResourcesL
       
   192 //
       
   193 //
       
   194 // -----------------------------------------------------------------------------
       
   195 //
       
   196 void CAknMemorySelectionModel::ReadResourcesL()
       
   197 	{
       
   198 	HBufC* buffer;
       
   199 	TInt resource;
       
   200 	for( TInt locStrIndex( 0 ); locStrIndex < ETextCount; locStrIndex++ )
       
   201 		{
       
   202 		resource = 0;
       
   203         // Resource depends on the layout type (TListBoxLayout):
       
   204 		switch( iLayout )
       
   205 			{
       
   206 		    case ELayoutPopupMenu:
       
   207 		        {
       
   208 		        resource = ResourceIDForLayoutPopupMenuItem( locStrIndex );
       
   209 		        break;
       
   210 		        }
       
   211 			case ELayoutSettingPage:
       
   212 			    {
       
   213 			    resource = ResourceIDForLayoutSettingPageItem( locStrIndex );
       
   214 			    break;
       
   215 			    }
       
   216 			case ELayoutDoublePopup:
       
   217 			    {
       
   218 			    resource = ResourceIDForLayoutDoublePopupItem( locStrIndex );
       
   219 			    break;
       
   220 			    }
       
   221 		    default:
       
   222 				{
       
   223 				User::Panic( KCFDPanicText, ECFDPanicOutOfBounds );
       
   224 				}
       
   225 			}//iLayout
       
   226 
       
   227         if( resource )
       
   228 		    {
       
   229 		    buffer = NULL;
       
   230     	    buffer = iCoeEnv->AllocReadResourceLC( resource );
       
   231     	    User::LeaveIfError( iLocStringArray.Append( buffer ) );
       
   232 	        CleanupStack::Pop();// Buffer???
       
   233 		    }
       
   234 
       
   235 		}//For loop
       
   236 
       
   237 #ifdef _DEBUG
       
   238         _LOG( "[CAknMemorySelectionModel] iLocStringArray: " );
       
   239         for( TInt lsa = 0; lsa < iLocStringArray.Count(); lsa++ )
       
   240     	    {
       
   241     	    _LOG1( "%S",iLocStringArray[ lsa ] );
       
   242     	    }
       
   243 #endif // _DEBUG
       
   244 	}
       
   245 
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 // CAknMemorySelectionModel::ResourceIDForLayoutPopupMenuItem
       
   249 //
       
   250 //
       
   251 // -----------------------------------------------------------------------------
       
   252 //
       
   253 TInt CAknMemorySelectionModel::ResourceIDForLayoutPopupMenuItem(
       
   254     TInt aLocStrIndex )
       
   255     {
       
   256     TInt resource = 0;
       
   257     switch( aLocStrIndex )
       
   258         {
       
   259     	case ETextPhoneMemory:
       
   260 			{
       
   261 			resource = R_CFD_QTN_MEMC_PHONE;
       
   262 			break;
       
   263 			}
       
   264 		case ETextMMC:
       
   265 			{
       
   266 			resource = R_CFD_QTN_MEMC_MMC;
       
   267 			break;
       
   268 			}
       
   269 		case ETextMMCLocked:
       
   270 			{
       
   271 			resource = R_CFD_QTN_MEMC_MMC_LOCKED;
       
   272 			break;
       
   273 			}
       
   274 		case ETextMMCUnavailable:
       
   275 			{
       
   276 			resource = R_CFD_QTN_MEMC_MMC_UNAVAILABLE;
       
   277 			break;
       
   278 			}
       
   279 		case ETextRemoteDrive:
       
   280 			{
       
   281 			resource = R_CFD_QTN_MEMC_REMOTE_DRIVE;
       
   282 			break;
       
   283 			}
       
   284         }
       
   285     return resource;
       
   286     }
       
   287 
       
   288 
       
   289 // -----------------------------------------------------------------------------
       
   290 // CAknMemorySelectionModel::ResourceIDForLayoutSettingPageItem
       
   291 //
       
   292 //
       
   293 // -----------------------------------------------------------------------------
       
   294 //
       
   295 TInt CAknMemorySelectionModel::ResourceIDForLayoutSettingPageItem(
       
   296     TInt aLocStrIndex )
       
   297     {
       
   298     TInt resource = 0;
       
   299     switch( aLocStrIndex )
       
   300         {
       
   301 		case ETextPhoneMemory:
       
   302 			{
       
   303 			resource = R_CFD_QTN_DATABASE_PHONE;
       
   304 			break;
       
   305 			}
       
   306 		case ETextMMC:
       
   307 			{
       
   308 			resource = R_CFD_QTN_MEMC_MCE_DEFAULT;
       
   309 			break;
       
   310 			}
       
   311 		case ETextMMCLocked:
       
   312 			{
       
   313 			resource = R_CFD_QTN_DATABASE_LOCKED;
       
   314 			break;
       
   315 			}
       
   316 		case ETextMMCUnavailable:
       
   317 			{
       
   318 			resource = R_CFD_QTN_DATABASE_UNAVAILABLE;
       
   319 			break;
       
   320 			}
       
   321 	    case ETextRemoteDrive:
       
   322 			{
       
   323 			resource = R_CFD_QTN_MEMC_REMOTE_DRIVE;
       
   324 			break;
       
   325 			}
       
   326         }
       
   327     return resource;
       
   328     }
       
   329 
       
   330 
       
   331 // -----------------------------------------------------------------------------
       
   332 // CAknMemorySelectionModel::ResourceIDForLayoutDoublePopupItem
       
   333 //
       
   334 //
       
   335 // -----------------------------------------------------------------------------
       
   336 //
       
   337 TInt CAknMemorySelectionModel::ResourceIDForLayoutDoublePopupItem(
       
   338     TInt aLocStrIndex )
       
   339     {
       
   340     TInt resource = 0;
       
   341      switch( aLocStrIndex )
       
   342         {
       
   343 		case ETextPhoneMemory:
       
   344 			{
       
   345 			resource = R_CFD_QTN_MEMC_PHONE_DOUBLE_LIST;
       
   346 			break;
       
   347 			}
       
   348 		case ETextMMC:
       
   349 			{
       
   350 			resource = R_CFD_QTN_MEMC_MMC_DOUBLE_LIST;
       
   351 			break;
       
   352 			}
       
   353 		case ETextMMCLocked:
       
   354 			{
       
   355 			resource = R_CFD_QTN_MEMC_MMC_LOCKED_DOUBLE;
       
   356 			break;
       
   357 			}
       
   358 		case ETextMMCUnavailable:
       
   359 			{
       
   360 			resource = R_CFD_QTN_MEMC_MMC_UNAVAILABLE_DOUBLE;
       
   361 			break;
       
   362 			}
       
   363 		case ETextRemoteDrive:
       
   364 			{
       
   365 			resource = R_CFD_QTN_MEMC_REMOTE_DRIVE_DOUBLE_LIST;
       
   366 			break;
       
   367 			}
       
   368         }
       
   369     return resource;
       
   370 
       
   371     }
       
   372 
       
   373 
       
   374 // -----------------------------------------------------------------------------
       
   375 // CAknMemorySelectionModel::AddItemToLbxL
       
   376 //
       
   377 //
       
   378 // -----------------------------------------------------------------------------
       
   379 //
       
   380 void CAknMemorySelectionModel::AddItemToLbxL( const TCFDDriveInfo& aDriveInfo )
       
   381     {
       
   382 	// Drives C and E are special cases and these point to phone memory and MMC
       
   383 	// memory regardless the media type. Listbox items are differend depending
       
   384 	// on the media type.
       
   385     TDriveNumber phoneDrive, mmcDrive;
       
   386     phoneDrive = ( TDriveNumber )AknCFDUtility::DriveNumber(
       
   387                         PathInfo::PhoneMemoryRootPath() );
       
   388     User::LeaveIfError(
       
   389         DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage,
       
   390                                     ( TInt& )mmcDrive ) );
       
   391 	if( aDriveInfo.iDriveNumber == phoneDrive /*Phone memory*/ )
       
   392 	    {
       
   393 	    AddPhoneItemToLbxL( aDriveInfo );
       
   394 	    }
       
   395     else if( aDriveInfo.iDriveNumber == mmcDrive  /*MMC memory*/ )
       
   396 	    {
       
   397 	    AddMMCItemToLbxL( aDriveInfo );
       
   398 	    }
       
   399 	else
       
   400 	    {
       
   401         switch( aDriveInfo.iMediaType )
       
   402 			{
       
   403 			// Different media type cases can be added here in the future
       
   404 			case EMediaRemote:
       
   405 				{
       
   406 				AddRemoteItemToLbxL( aDriveInfo );
       
   407                 break;
       
   408 				}
       
   409 			default:
       
   410 				{
       
   411 				// No actual use case for this yet (only remote drives should
       
   412 				// exist).
       
   413 				AddDefaultItemToLbxL( aDriveInfo );
       
   414                 break;
       
   415 				}
       
   416 			}
       
   417 	    }
       
   418     }
       
   419 
       
   420 
       
   421 // -----------------------------------------------------------------------------
       
   422 // CAknMemorySelectionModel::AddPhoneItemToLbxL
       
   423 //
       
   424 //
       
   425 // -----------------------------------------------------------------------------
       
   426 //
       
   427 void CAknMemorySelectionModel::AddPhoneItemToLbxL( const TCFDDriveInfo& aDriveInfo )
       
   428     {
       
   429     HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   430 	TPtr itemString( lbxItemBuf->Des() );
       
   431 
       
   432 	// Item text is affected by layout
       
   433 	switch( iLayout )
       
   434 	    {
       
   435 	        case ELayoutPopupMenu:
       
   436 	            {
       
   437                 // A-column icon:
       
   438             	itemString.Format( KImageHeader, EIconPhoneMemory );
       
   439             	itemString.Append( KTabChar );
       
   440 
       
   441         		// 1st row text:
       
   442             	if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   443             	    {
       
   444             	    // Append drive name if it has one
       
   445             	    itemString.Append( aDriveInfo.iVolumeLabel );
       
   446             	    }
       
   447             	else
       
   448             	    {
       
   449             	    // Use default drive description
       
   450             	    itemString.Append( *iLocStringArray[ ETextPhoneMemory ] );
       
   451             	    }
       
   452    	            break;
       
   453 	            }
       
   454 	        case ELayoutSettingPage:
       
   455 	            {
       
   456 	            // 1st row text:
       
   457             	if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   458             	    {
       
   459             	    // Append drive name if it has one
       
   460             	    itemString.Append( aDriveInfo.iVolumeLabel );
       
   461             	    }
       
   462             	else
       
   463             	    {
       
   464             	    // Use default drive description
       
   465             	    itemString.Append( *iLocStringArray[ ETextPhoneMemory ] );
       
   466             	    }
       
   467 	            break;
       
   468 	            }
       
   469 	        case ELayoutDoublePopup:
       
   470 	            {
       
   471 	            // A-column icon:
       
   472             	itemString.Format( KImageHeader, EIconPhoneMemory );
       
   473             	itemString.Append( KTabChar );
       
   474 
       
   475             	// 1st row text:
       
   476             	if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   477             	    {
       
   478             	    // Append drive name if it has one
       
   479             	    itemString.Append( aDriveInfo.iVolumeLabel );
       
   480             	    itemString.Append( KTabChar );
       
   481             	    }
       
   482             	else
       
   483             	    {
       
   484             	    // Use default drive description
       
   485             	    itemString.Append( *iLocStringArray[ ETextPhoneMemory ] );
       
   486             	    itemString.Append( KTabChar );
       
   487             	    }
       
   488 
       
   489             	// 2nd row text:
       
   490             	HBufC* buffer;
       
   491             	TInt64 freeSpace = aDriveInfo.iDiskSpace;
       
   492                 if ( freeSpace >= 0 )
       
   493                     {
       
   494                     buffer = HBufC::NewLC( KListBoxEntryMaxLength );  
       
   495                     TPtr unitStr( buffer->Des() );
       
   496                     AknCFDUtility::SetSecondRowTextL( freeSpace, unitStr );	
       
   497                     }
       
   498                 else
       
   499         	        {
       
   500         			// Disk space is unavailable
       
   501         			buffer = StringLoader::LoadLC(
       
   502         			            R_CFD_QTN_MEMC_SPACE_NOT_AVAILABLE,
       
   503         			            iCoeEnv);
       
   504         			}
       
   505             	itemString.Append( *buffer );//Free mem text
       
   506             	CleanupStack::PopAndDestroy( buffer );
       
   507 	            break;
       
   508 	            }
       
   509 	        }
       
   510 
       
   511 	// Finally!: append the formatted string to listbox
       
   512     User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
       
   513 	CleanupStack::Pop( lbxItemBuf );
       
   514     _LOG1( "[CAknMemorySelectionModel] Item string added to lbx array: %S", &itemString );
       
   515     _LOG1( "itemString length=%d", itemString.Length() );
       
   516     }
       
   517 
       
   518 
       
   519 // -----------------------------------------------------------------------------
       
   520 // CAknMemorySelectionModel::AddMMCItemToLbxL
       
   521 //
       
   522 //
       
   523 // -----------------------------------------------------------------------------
       
   524 //
       
   525 void CAknMemorySelectionModel::AddMMCItemToLbxL( const TCFDDriveInfo& aDriveInfo )
       
   526     {
       
   527     HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   528 	TPtr itemString( lbxItemBuf->Des() );
       
   529 
       
   530     // Item text is affected by layout
       
   531     switch( iLayout )
       
   532         {
       
   533         case ELayoutPopupMenu:
       
   534             {
       
   535             // A-column icon:
       
   536         	itemString.Format( KImageHeader, EIconMMC );
       
   537         	itemString.Append( KTabChar );
       
   538 
       
   539         	// 1st row text:
       
   540         	if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   541         	    {
       
   542         	    // Append drive name if it has one
       
   543         	    itemString.Append( aDriveInfo.iVolumeLabel );
       
   544         	    }
       
   545         	else
       
   546         	    {
       
   547         	        if( aDriveInfo.iDriveStatus == EDriveNotReady )
       
   548                     {
       
   549                     itemString.Append( *iLocStringArray[ ETextMMCUnavailable ] );
       
   550                     }
       
   551                     else if( aDriveInfo.iDriveStatus == EDriveLocked )
       
   552                     {
       
   553         	        itemString.Append( *iLocStringArray[ ETextMMCLocked ] );
       
   554                     }
       
   555                     else
       
   556                     {
       
   557         	        // Use default drive description
       
   558         	        itemString.Append( *iLocStringArray[ ETextMMC ] );
       
   559                     }
       
   560         	    }
       
   561             break;
       
   562             }
       
   563         case ELayoutSettingPage:
       
   564             {
       
   565             // 1st row text:
       
   566         	if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   567         	    {
       
   568         	    // Append drive name if it has one
       
   569         	    itemString.Append( aDriveInfo.iVolumeLabel );
       
   570         	    }
       
   571         	else
       
   572         	    {
       
   573         	        if( aDriveInfo.iDriveStatus == EDriveNotReady )
       
   574                     {
       
   575                     itemString.Append( *iLocStringArray[ ETextMMCUnavailable ] );
       
   576                     }
       
   577                     else if( aDriveInfo.iDriveStatus == EDriveLocked )
       
   578                     {
       
   579         	        itemString.Append( *iLocStringArray[ ETextMMCLocked ] );
       
   580                     }
       
   581                     else
       
   582                     {
       
   583         	        // Use default drive description
       
   584         	        itemString.Append( *iLocStringArray[ ETextMMC ] );
       
   585                     }
       
   586         	    }
       
   587             break;
       
   588             }
       
   589         case ELayoutDoublePopup:
       
   590             {
       
   591             // A-column icon:
       
   592         	itemString.Format( KImageHeader, EIconMMC );
       
   593         	itemString.Append( KTabChar );
       
   594 
       
   595         	// 1st row text:
       
   596         	if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   597         	    {
       
   598         	    // Append drive name if it has one
       
   599         	    itemString.Append( aDriveInfo.iVolumeLabel );
       
   600         	    itemString.Append( KTabChar );
       
   601         	    }
       
   602         	else
       
   603         	    {
       
   604         	    // Use default drive description
       
   605         	    itemString.Append( *iLocStringArray[ ETextMMC ] );
       
   606         	    itemString.Append( KTabChar );
       
   607         	    }
       
   608 
       
   609         	// 2nd row text:
       
   610             switch( aDriveInfo.iDriveStatus )
       
   611                 {
       
   612                 case EDriveOK:
       
   613                     {
       
   614                     HBufC* buffer;
       
   615                     TInt64 freeSpace = aDriveInfo.iDiskSpace;
       
   616                     if ( freeSpace >= 0 )
       
   617                         {
       
   618                         buffer = HBufC::NewLC( KListBoxEntryMaxLength );  
       
   619                         TPtr unitStr( buffer->Des() );
       
   620                         AknCFDUtility::SetSecondRowTextL( freeSpace, unitStr );	 
       
   621                         }
       
   622                     else
       
   623         			    {
       
   624         			    // Disk space is unavailable
       
   625         			    buffer = StringLoader::LoadLC(
       
   626         			                R_CFD_QTN_MEMC_SPACE_NOT_AVAILABLE,
       
   627         			                iCoeEnv);
       
   628         			    }
       
   629         			itemString.Append( *buffer );//Free mem text
       
   630         			CleanupStack::PopAndDestroy( buffer );
       
   631                     break;
       
   632                     }
       
   633                 case EDriveNotReady:
       
   634                     {
       
   635                     itemString.Append( *iLocStringArray[ ETextMMCUnavailable ] );
       
   636                     break;
       
   637                     }
       
   638                 case EDriveLocked:
       
   639                     {
       
   640                     itemString.Append( *iLocStringArray[ ETextMMCLocked ] );
       
   641                     break;
       
   642                     }
       
   643                 default:
       
   644                     {
       
   645                     // This is not defined in specification.
       
   646                     itemString.Append( *iLocStringArray[ ETextMMCUnavailable ] );
       
   647                     break;
       
   648                     }
       
   649                 }
       
   650             break;
       
   651             }
       
   652         }
       
   653 
       
   654 	// Finally!: append the formatted string to listbox
       
   655     User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
       
   656 	CleanupStack::Pop( lbxItemBuf );
       
   657     _LOG1( "[CAknMemorySelectionModel] Item string added to lbx array: %S", &itemString );
       
   658     _LOG1( "itemString length=%d", itemString.Length() );
       
   659     }
       
   660 
       
   661 
       
   662 // -----------------------------------------------------------------------------
       
   663 // CAknMemorySelectionModel::AddRemoteItemToLbxL
       
   664 //
       
   665 //
       
   666 // -----------------------------------------------------------------------------
       
   667 //
       
   668 void CAknMemorySelectionModel::AddRemoteItemToLbxL( const TCFDDriveInfo& aDriveInfo )
       
   669     {
       
   670     HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   671 	TPtr itemString( lbxItemBuf->Des() );
       
   672 
       
   673     // Item text is affected by layout
       
   674     switch( iLayout )
       
   675         {
       
   676         case ELayoutPopupMenu:
       
   677             {
       
   678             // A-column icon:
       
   679         	itemString.Format( KImageHeader, EIconRemoteDrive );
       
   680         	itemString.Append( KTabChar );
       
   681 
       
   682         	// 1st row text:
       
   683         	if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   684         	    {
       
   685         	    // Append drive name if it has one
       
   686         	    itemString.Append( aDriveInfo.iVolumeLabel );
       
   687         	    }
       
   688         	else
       
   689         	    {
       
   690         	    // Use default drive description
       
   691         	    itemString.Append( *iLocStringArray[ ETextRemoteDrive ] );
       
   692         	    }
       
   693             break;
       
   694             }
       
   695         case ELayoutSettingPage:
       
   696             {
       
   697           	// 1st row text:
       
   698         	if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   699         	    {
       
   700         	    // Append drive name if it has one
       
   701         	    itemString.Append( aDriveInfo.iVolumeLabel );
       
   702         	    }
       
   703         	else
       
   704         	    {
       
   705         	    // Use default drive description
       
   706         	    itemString.Append( *iLocStringArray[ ETextRemoteDrive ] );
       
   707         	    }
       
   708             break;
       
   709             }
       
   710         case ELayoutDoublePopup:
       
   711             {
       
   712             // A-column icon:
       
   713         	itemString.Format( KImageHeader, EIconRemoteDrive );
       
   714         	itemString.Append( KTabChar );
       
   715 
       
   716         	// 1st row text:
       
   717         	if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   718         	    {
       
   719         	    // Append drive name if it has one
       
   720         	    itemString.Append( aDriveInfo.iVolumeLabel );
       
   721         	    itemString.Append( KTabChar );
       
   722         	    }
       
   723         	else
       
   724         	    {
       
   725         	    // Use default drive description
       
   726         	    itemString.Append( *iLocStringArray[ ETextRemoteDrive ] );
       
   727         	    itemString.Append( KTabChar );
       
   728         	    }
       
   729 
       
   730             if( aDriveInfo.iDriveStatus == EDriveOK )
       
   731                 {
       
   732                 // 2nd row text:
       
   733                 // Currently Remote drive does not support query for available
       
   734                 // disk space, so just return " "
       
   735                 _LIT( KEmptySpace, " ");
       
   736                 itemString.Append( KEmptySpace ); 
       
   737 
       
   738                 if( aDriveInfo.iConnectionState == KMountStronglyConnected )
       
   739                     {
       
   740                     // D-column icon: Show active icon if drive has no error
       
   741                     itemString.Append( KTabChar );
       
   742                     itemString.AppendFormat( KImageHeader, EIconRemoteDriveActive );
       
   743                     }
       
   744                 else // KMountNotConnected
       
   745                     {
       
   746                     // D-column icon: Show active icon if drive has no error
       
   747                     itemString.Append( KTabChar );
       
   748                     }
       
   749                 }
       
   750             else
       
   751                 {
       
   752                 // 2nd row text:
       
   753                 itemString.Append( *iLocStringArray[ ETextMMCUnavailable ] );
       
   754                 // D-column is empty if error.
       
   755                 }
       
   756             break;
       
   757             }
       
   758         }
       
   759 
       
   760 	// Finally!: append the formatted string to listbox
       
   761     User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
       
   762 	CleanupStack::Pop( lbxItemBuf );
       
   763     _LOG1( "[CAknMemorySelectionModel] Item string added to lbx array: %S", &itemString );
       
   764     _LOG1( "itemString length=%d", itemString.Length() );
       
   765     }
       
   766 
       
   767 
       
   768 // -----------------------------------------------------------------------------
       
   769 // CAknMemorySelectionModel::AddDefaultItemToLbxL
       
   770 //
       
   771 // If drive has volume label, use it. Otherwise use drive letter for drive name.
       
   772 // -----------------------------------------------------------------------------
       
   773 //
       
   774 void CAknMemorySelectionModel::AddDefaultItemToLbxL( const TCFDDriveInfo& aDriveInfo )
       
   775     {
       
   776     HBufC* lbxItemBuf = HBufC::NewLC( KListBoxEntryMaxLength );
       
   777     TPtr itemString( lbxItemBuf->Des() );
       
   778     TChar driveLetter;
       
   779     _LIT( KFormat, ":" );
       
   780 
       
   781 	// Item text is affected by layout
       
   782 	switch( iLayout )
       
   783         {
       
   784         case ELayoutSettingPage:
       
   785             {
       
   786             if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   787                 {
       
   788                 itemString.Append( aDriveInfo.iVolumeLabel/*aDriveLetter*/ );
       
   789                 }
       
   790             else
       
   791                 {
       
   792                 User::LeaveIfError( RFs::DriveToChar( aDriveInfo.iDriveNumber, driveLetter ) );
       
   793                 itemString.Append( driveLetter );
       
   794                 itemString.Append( KFormat );
       
   795                 }
       
   796             break;
       
   797             }
       
   798         case ELayoutPopupMenu:
       
   799         case ELayoutDoublePopup:
       
   800             {
       
   801         	itemString.Format( KImageHeader, EIconPhoneMemory );
       
   802         	itemString.Append( KTabChar );
       
   803 
       
   804             if( aDriveInfo.iVolumeLabel.Length() > 0 )
       
   805                 {
       
   806                 itemString.Append( aDriveInfo.iVolumeLabel );
       
   807                 }
       
   808             else
       
   809                 {
       
   810                 User::LeaveIfError( RFs::DriveToChar( aDriveInfo.iDriveNumber, driveLetter ) );
       
   811                 itemString.Append( driveLetter );
       
   812                 itemString.Append( KFormat );
       
   813                 }
       
   814             break;
       
   815             }
       
   816         }
       
   817 
       
   818 	// Finally!: append the formatted string to listbox
       
   819     User::LeaveIfError( iListBoxArray.Append( lbxItemBuf ) );
       
   820 	CleanupStack::Pop( lbxItemBuf );
       
   821     _LOG1( "[CAknMemorySelectionModel] Item string added to lbx array: %S", &itemString );
       
   822     _LOG1( "itemString length=%d", itemString.Length() );
       
   823     }
       
   824 
       
   825 
       
   826 // -----------------------------------------------------------------------------
       
   827 // CAknMemorySelectionModel::GetDrive
       
   828 //
       
   829 //
       
   830 // -----------------------------------------------------------------------------
       
   831 //
       
   832 void CAknMemorySelectionModel::GetDrive( TInt aLbxItemIndex, TDes& aDrivePath )
       
   833     {
       
   834     if( aLbxItemIndex < iDriveArray->MdcaCount() )
       
   835         {
       
   836         aDrivePath = iDriveArray->MdcaPoint( aLbxItemIndex );
       
   837         }
       
   838     }
       
   839 
       
   840 // End of File