commonuis/CommonDialogs/src/CAknMemorySelectionDialog.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Dialog used to selection target memory
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <aknlists.h>   // Listboxes
       
    21 #include <eikbtgpc.h>   // CEikButtonGroupContainer
       
    22 #include <barsread.h>   // TResourceReader
       
    23 #include <aknmemorycardui.mbg>
       
    24 #include <avkon.mbg>
       
    25 #include <AknIconArray.h>
       
    26 #include <aknconsts.h> // KAvkonBitmapFile
       
    27 #include <AknsConstants.h> // KAknsIIDQgnPropPhoneMemcLarge etc.
       
    28 #include <AknsUtils.h>
       
    29 #include <commondialogs.rsg> // Common dialogs resource IDs
       
    30 #include <pathinfo.h> //PathInfo
       
    31 #include <driveinfo.h> //DriveInfo
       
    32 
       
    33 #include "CAknMemorySelectionDialog.h"
       
    34 #include "AknCommonDialogsDynMem.h"
       
    35 #include "CAknCommonDialogsPopupList.h"
       
    36 #include "CAknMemorySelectionEventHandler.h"
       
    37 #include "CAknMemorySelectionModel.h"
       
    38 #include "MAknCommonDialogsEventObserver.h"
       
    39 #include "AknCFDUtility.h"
       
    40 
       
    41 
       
    42 // ======== MEMBER FUNCTIONS ========
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // CAknMemorySelectionDialog::CAknMemorySelectionDialog
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CAknMemorySelectionDialog::CAknMemorySelectionDialog(
       
    49     TCommonDialogType aDialogType )
       
    50     :   iDialogType( aDialogType ),
       
    51         iRootPathArray( EMemoryCount ),
       
    52         iDefaultFolderArray( EMemoryCount )
       
    53     {
       
    54     }
       
    55 
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CAknMemorySelectionDialog::ConstructFromResourceL
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 void CAknMemorySelectionDialog::ConstructFromResourceL(
       
    62     TInt aResourceId,
       
    63     TBool aShowUnavailableDrives )
       
    64     {
       
    65     // EMemoryTypePhone|EMemoryTypeMMC are the drives used in legacy code.
       
    66     ConstructFromResourceL( aResourceId, aShowUnavailableDrives,
       
    67         AknCommonDialogsDynMem::EMemoryTypePhone
       
    68         | AknCommonDialogsDynMem::EMemoryTypeMMC );
       
    69     }
       
    70 
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // CAknMemorySelectionDialog::ConstructFromResourceL
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 void CAknMemorySelectionDialog::ConstructFromResourceL(
       
    77     TInt aResourceId,
       
    78     TBool aShowUnavailableDrives,
       
    79     TInt aIncludedMedias )
       
    80     {
       
    81     BaseConstructL();
       
    82 
       
    83     iIncludedMedias = aIncludedMedias;
       
    84     if( iIncludedMedias & AknCommonDialogsDynMem::EMemoryTypeMMC )
       
    85         {
       
    86         iIncludedMedias = iIncludedMedias |
       
    87             AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage
       
    88             | AknCommonDialogsDynMem::EMemoryTypeMMCExternal;
       
    89         iIncludedMedias &= ( ~AknCommonDialogsDynMem::EMemoryTypeMMC );
       
    90         }
       
    91 
       
    92     if( aResourceId )
       
    93         {
       
    94         // If a resource id is given, read settings from it.
       
    95         ReadFromResourceL( aResourceId, ETrue );
       
    96         }
       
    97 
       
    98     // After user resource is read, "patch" the missing values with defaults
       
    99     // by reading all missing settings from default resource.
       
   100     SetResourceId( aResourceId, iDialogType );
       
   101     ReadFromResourceL( aResourceId, EFalse );
       
   102 
       
   103     if( !iRootPathArray.Count() )
       
   104         {
       
   105         GetSystemPathsL();
       
   106         }
       
   107 
       
   108     MAknMemorySelectionModel::TListBoxLayout layout(
       
   109         MAknMemorySelectionModel::ELayoutPopupMenu );
       
   110     if( iDialogType == ECFDDialogTypeDefaultSetting )
       
   111         {
       
   112         layout = MAknMemorySelectionModel::ELayoutSettingPage;
       
   113         }
       
   114     else if( AknCFDUtility::DirectoriesOnly( iDialogType ) )
       
   115         {
       
   116         layout = MAknMemorySelectionModel::ELayoutDoublePopup;
       
   117         }
       
   118 
       
   119     // Add dynamic drives to iRootPathArray if they're required:
       
   120     if( aIncludedMedias & AknCommonDialogsDynMem::EMemoryTypeRemote )
       
   121         {
       
   122         // Enable dynamic drives, this means iRootPathArray items are dynamic.
       
   123         iDynamicDrivesEnabled = ETrue;
       
   124         AknCFDUtility::ReadDynamicDrivesL( iRootPathArray, aIncludedMedias );
       
   125         }
       
   126 
       
   127     // Create model of listbox listing the drives in iRootPathArray:
       
   128     iModel = CAknMemorySelectionModel::NewL(
       
   129         iCoeEnv, &iRootPathArray, aShowUnavailableDrives, layout );
       
   130     iEventHandler = CAknMemorySelectionEventHandler::NewL(
       
   131             iCoeEnv, iModel, iObserver );
       
   132 
       
   133 #ifdef _DEBUG
       
   134     _LOG( "[CAknMemorySelectionDialog] iRootPathArray: " );
       
   135     for( TInt irp = 0; irp < iRootPathArray.MdcaCount(); irp++ )
       
   136         {
       
   137         TPtrC text = iRootPathArray.MdcaPoint( irp );
       
   138         _LOG1( "%S", &text );
       
   139         }
       
   140     _LOG( "[CAknMemorySelectionDialog] iDefaultFolderArray: " );
       
   141     for( TInt rpa = 0; rpa < iDefaultFolderArray.MdcaCount(); rpa++ )
       
   142         {
       
   143         TPtrC text = iDefaultFolderArray.MdcaPoint( rpa );
       
   144         _LOG1( "%S", &text );
       
   145         }
       
   146 #endif //_DEBUG
       
   147     }
       
   148 
       
   149 
       
   150 // ---------------------------------------------------------------------------
       
   151 // CAknMemorySelectionDialog::NewL
       
   152 // ---------------------------------------------------------------------------
       
   153 //
       
   154 EXPORT_C CAknMemorySelectionDialog* CAknMemorySelectionDialog::NewL(
       
   155     TCommonDialogType aDialogType,
       
   156     TBool aShowUnavailableDrives )
       
   157     {
       
   158     return NewL( aDialogType, 0, aShowUnavailableDrives );
       
   159     }
       
   160 
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // CAknMemorySelectionDialog::NewL
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 EXPORT_C CAknMemorySelectionDialog* CAknMemorySelectionDialog::NewL(
       
   167     TCommonDialogType aDialogType,
       
   168     TInt aResourceId,
       
   169     TBool aShowUnavailableDrives )
       
   170     {
       
   171     if( aDialogType == ECFDDialogTypeDefaultSetting )
       
   172         {
       
   173     	User::Leave( KErrNotSupported );
       
   174         }
       
   175     CAknMemorySelectionDialog* self =
       
   176         new( ELeave ) CAknMemorySelectionDialog( aDialogType );
       
   177     CleanupStack::PushL( self );
       
   178     self->ConstructFromResourceL( aResourceId, aShowUnavailableDrives );
       
   179     CleanupStack::Pop(); // self
       
   180     return self;
       
   181     }
       
   182 
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // CAknMemorySelectionDialog::NewL
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 EXPORT_C CAknMemorySelectionDialog* CAknMemorySelectionDialog::NewL(
       
   189     TCommonDialogType aDialogType,
       
   190     TInt aResourceId,
       
   191     TBool aShowUnavailableDrives,
       
   192     TInt aIncludedMedias )
       
   193     {
       
   194     if( aDialogType == ECFDDialogTypeDefaultSetting )
       
   195         {
       
   196     	User::Leave( KErrNotSupported );
       
   197         }
       
   198     CAknMemorySelectionDialog* self =
       
   199         new( ELeave ) CAknMemorySelectionDialog( aDialogType );
       
   200     CleanupStack::PushL( self );
       
   201     self->ConstructFromResourceL( aResourceId,
       
   202                                   aShowUnavailableDrives,
       
   203                                   aIncludedMedias );
       
   204     CleanupStack::Pop(); // self
       
   205     return self;
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // Destructor
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 EXPORT_C CAknMemorySelectionDialog::~CAknMemorySelectionDialog()
       
   213     {
       
   214     delete iEventHandler;
       
   215     delete iModel;
       
   216     delete iTitle;
       
   217     delete iLeftSoftkey;
       
   218     delete iRightSoftkey;
       
   219     }
       
   220 
       
   221 
       
   222 // ---------------------------------------------------------------------------
       
   223 // CAknMemorySelectionDialog::SetObserver
       
   224 // ---------------------------------------------------------------------------
       
   225 //
       
   226 EXPORT_C void CAknMemorySelectionDialog::SetObserver(
       
   227     MAknMemorySelectionObserver* aObserver )
       
   228     {
       
   229     // The observer could not be called, so the following code is useless
       
   230     iObserver = aObserver;
       
   231     }
       
   232 
       
   233 
       
   234 // ---------------------------------------------------------------------------
       
   235 // CAknMemorySelectionDialog::SetTitleL
       
   236 // ---------------------------------------------------------------------------
       
   237 //
       
   238 EXPORT_C void CAknMemorySelectionDialog::SetTitleL( const TDesC& aText )
       
   239     {
       
   240     AknCFDUtility::AllocateIfValidL( iTitle, aText );
       
   241     }
       
   242 
       
   243 
       
   244 // ---------------------------------------------------------------------------
       
   245 // CAknMemorySelectionDialog::SetLeftSoftkeyL
       
   246 // ---------------------------------------------------------------------------
       
   247 //
       
   248 EXPORT_C void CAknMemorySelectionDialog::SetLeftSoftkeyL( const TDesC& aText )
       
   249     {
       
   250     AknCFDUtility::AllocateIfValidL( iLeftSoftkey, aText );
       
   251     }
       
   252 
       
   253 
       
   254 // ---------------------------------------------------------------------------
       
   255 // CAknMemorySelectionDialog::SetRightSoftkeyL
       
   256 // ---------------------------------------------------------------------------
       
   257 //
       
   258 EXPORT_C void CAknMemorySelectionDialog::SetRightSoftkeyL( const TDesC& aText )
       
   259     {
       
   260     AknCFDUtility::AllocateIfValidL( iRightSoftkey, aText );
       
   261     }
       
   262 
       
   263 
       
   264 // ---------------------------------------------------------------------------
       
   265 // CAknMemorySelectionDialog::GetItem
       
   266 // ---------------------------------------------------------------------------
       
   267 //
       
   268 EXPORT_C void CAknMemorySelectionDialog::GetItem( TInt aIndex, TDes& aItem )
       
   269     {
       
   270     iModel->GetItem( aIndex, aItem );
       
   271     }
       
   272 
       
   273 // ---------------------------------------------------------------------------
       
   274 // CAknMemorySelectionDialog::GetMemories
       
   275 // ---------------------------------------------------------------------------
       
   276 //
       
   277 EXPORT_C void CAknMemorySelectionDialog::GetMemories(
       
   278     TMemory aSelectedMemory,
       
   279     TDes* aRootPath,
       
   280     TDes* aDefaultFolder )
       
   281     {
       
   282     if( iDynamicDrivesEnabled )
       
   283         {
       
   284         // When dynamic drives are enabled, parameter aSelectedMemory is not
       
   285         // of type TMemory but TInt indexing the selected listbox item.
       
   286         // GetDrivePaths handles this logic.
       
   287         GetDrivePaths( aSelectedMemory, aRootPath, aDefaultFolder );
       
   288         }
       
   289     else
       
   290         {
       
   291         // aSelectedMemory is fixed enum pointing either Phone or MMC memory.
       
   292         // This is needed for CommonDialogs legacy implementation.
       
   293         if( aRootPath )
       
   294             {
       
   295             __ASSERT_DEBUG( ( aSelectedMemory >= 0 )
       
   296                 && ( aSelectedMemory < iRootPathArray.Count() ),
       
   297                 User::Panic( KCFDPanicText, ECFDPanicOutOfBounds ) );
       
   298             *aRootPath = iRootPathArray[ aSelectedMemory ];
       
   299             }
       
   300         if( aDefaultFolder )
       
   301             {
       
   302             __ASSERT_DEBUG( ( aSelectedMemory >= 0 ) &&
       
   303                             ( aSelectedMemory < iDefaultFolderArray.Count() ),
       
   304                 User::Panic( KCFDPanicText, ECFDPanicOutOfBounds ) );
       
   305             *aDefaultFolder = iDefaultFolderArray[ aSelectedMemory ];
       
   306             }
       
   307         }
       
   308     }
       
   309 
       
   310 
       
   311 // ---------------------------------------------------------------------------
       
   312 // CAknMemorySelectionDialog::ExecuteL
       
   313 // ---------------------------------------------------------------------------
       
   314 //
       
   315 EXPORT_C CAknCommonDialogsBase::TReturnKey CAknMemorySelectionDialog::ExecuteL(
       
   316     TMemory& aSelectedMemory )
       
   317     {
       
   318     return ExecuteL( aSelectedMemory, NULL, NULL );
       
   319     }
       
   320 
       
   321 
       
   322 // ---------------------------------------------------------------------------
       
   323 // CAknMemorySelectionDialog::ExecuteL
       
   324 // ---------------------------------------------------------------------------
       
   325 //
       
   326 EXPORT_C CAknCommonDialogsBase::TReturnKey CAknMemorySelectionDialog::ExecuteL(
       
   327     TMemory& aSelectedMemory,
       
   328     TDes* aRootPath,
       
   329     TDes* aDefaultFolder )
       
   330     {
       
   331     __ASSERT_DEBUG( iTitle && iLeftSoftkey && iRightSoftkey,
       
   332         User::Panic( KCFDPanicText, ECFDPanicTitleOrSoftkeyNotSet ) );
       
   333 
       
   334     TBool doubleStyle( AknCFDUtility::DirectoriesOnly( iDialogType ) );
       
   335     CEikFormattedCellListBox* listBox = NULL;
       
   336     if( doubleStyle )
       
   337         {
       
   338         listBox = new( ELeave ) CAknDoubleLargeGraphicPopupMenuStyleListBox();
       
   339         }
       
   340     else
       
   341         {
       
   342         listBox = new( ELeave ) CAknSingleGraphicPopupMenuStyleListBox();
       
   343         }
       
   344     CleanupStack::PushL( listBox );
       
   345 
       
   346     AknPopupLayouts::TAknPopupLayouts layout( doubleStyle ?
       
   347         AknPopupLayouts::EMenuDoubleLargeGraphicWindow :
       
   348         AknPopupLayouts::EMenuGraphicWindow );
       
   349     TBool isEndKeyPress = EFalse;
       
   350     CAknCommonDialogsPopupList* popupList =
       
   351         CAknCommonDialogsPopupList::NewL(
       
   352             *iEventHandler, listBox, layout, isEndKeyPress );
       
   353     CleanupStack::PushL( popupList );
       
   354 
       
   355     listBox->ConstructL( popupList, 0 );
       
   356     listBox->CreateScrollBarFrameL( ETrue ); // Create scroll indicator
       
   357     listBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   358         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   359 
       
   360     listBox->Model()->SetItemTextArray( iModel );
       
   361     // Set model ownership type
       
   362     listBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   363 
       
   364     // Icons:
       
   365     // Granularity, 5 icons
       
   366     CAknIconArray* iconArray = new( ELeave ) CAknIconArray( 5 );
       
   367     CleanupStack::PushL( iconArray );
       
   368     LoadIconsL( iconArray, doubleStyle );
       
   369     listBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( iconArray );
       
   370     CleanupStack::Pop(); // iconArray
       
   371 
       
   372     popupList->SetTitleL( *iTitle ); // Set title
       
   373     CEikButtonGroupContainer* cba = popupList->ButtonGroupContainer();
       
   374     MEikButtonGroup* buttonGroup = cba->ButtonGroup();
       
   375     cba->SetCommandL( buttonGroup->CommandId( 0 ), *iLeftSoftkey );
       
   376     cba->SetCommandL( buttonGroup->CommandId( 2 ), *iRightSoftkey );
       
   377 
       
   378     listBox->View()->SetCurrentItemIndex( aSelectedMemory );
       
   379 
       
   380     CleanupStack::Pop(); // popupList (deleted in ExecuteLD)
       
   381     // Execute the popup dialog
       
   382     TBool returnValue( popupList->ExecuteLD() );
       
   383 
       
   384     if( returnValue )
       
   385         {
       
   386         aSelectedMemory = TMemory( listBox->CurrentItemIndex() );
       
   387         GetMemories( aSelectedMemory, aRootPath, aDefaultFolder );
       
   388         }
       
   389     CleanupStack::PopAndDestroy(); // listBox
       
   390     return TReturnKey( returnValue );
       
   391     }
       
   392 
       
   393 
       
   394 // ---------------------------------------------------------------------------
       
   395 // CAknMemorySelectionDialog::RunDlgLD
       
   396 // A wrapper for RunL.
       
   397 // ---------------------------------------------------------------------------
       
   398 //
       
   399 EXPORT_C TBool CAknMemorySelectionDialog::RunDlgLD(
       
   400     TMemory& aSelectedMemory,
       
   401     MAknMemorySelectionObserver* aObserver )
       
   402     {
       
   403     return RunL( 0, aSelectedMemory,
       
   404         NULL, NULL, KNullDesC, aObserver );
       
   405     }
       
   406 
       
   407 
       
   408 // ---------------------------------------------------------------------------
       
   409 // CAknMemorySelectionDialog::RunDlgLD
       
   410 // A wrapper for RunL.
       
   411 // ---------------------------------------------------------------------------
       
   412 //
       
   413 EXPORT_C TBool CAknMemorySelectionDialog::RunDlgLD(
       
   414     TMemory& aSelectedMemory,
       
   415     const TDesC& aTitle,
       
   416     MAknMemorySelectionObserver* aObserver )
       
   417     {
       
   418     return RunL( 0, aSelectedMemory,
       
   419         NULL, NULL, aTitle, aObserver );
       
   420     }
       
   421 
       
   422 
       
   423 // ---------------------------------------------------------------------------
       
   424 // CAknMemorySelectionDialog::RunDlgLD
       
   425 // A wrapper for RunL.
       
   426 // ---------------------------------------------------------------------------
       
   427 //
       
   428 EXPORT_C TBool CAknMemorySelectionDialog::RunDlgLD(
       
   429     TMemory& aSelectedMemory,
       
   430     TInt aResourceId,
       
   431     TDes* aRootPath, TDes* aDefaultFolder,
       
   432     MAknMemorySelectionObserver* aObserver )
       
   433     {
       
   434     return RunL( aResourceId, aSelectedMemory,
       
   435         aRootPath, aDefaultFolder, KNullDesC, aObserver );
       
   436     }
       
   437 
       
   438 
       
   439 // ---------------------------------------------------------------------------
       
   440 // CAknMemorySelectionDialog::GetDrivePaths
       
   441 // ---------------------------------------------------------------------------
       
   442 //
       
   443 TInt CAknMemorySelectionDialog::GetDrivePaths(
       
   444     TInt aLbxIndex,
       
   445     TDes* aRootPath,
       
   446     TDes* aDefaultFolder )
       
   447     {
       
   448     if ( aLbxIndex >= 0 )
       
   449         {
       
   450         if( aRootPath && ( iRootPathArray.Count() > aLbxIndex ))
       
   451             {
       
   452             // aRootPath is required.
       
   453             *aRootPath = iRootPathArray[ aLbxIndex ];
       
   454             }
       
   455         if( aDefaultFolder && ( iDefaultFolderArray.Count() > aLbxIndex ))
       
   456             {
       
   457             // aDefaultFolder is required.
       
   458             *aDefaultFolder = iDefaultFolderArray[ aLbxIndex ];
       
   459             }
       
   460         return KErrNone;
       
   461         }
       
   462     else
       
   463         return KErrNotFound;
       
   464     }
       
   465 
       
   466 
       
   467 // ---------------------------------------------------------------------------
       
   468 // CAknMemorySelectionDialog::LoadIconsL
       
   469 // ---------------------------------------------------------------------------
       
   470 //
       
   471 void CAknMemorySelectionDialog::LoadIconsL( CAknIconArray* aIconArray,
       
   472                                             TBool aDoubleStyle )
       
   473     {
       
   474     CEikonEnv* eikEnv = CEikonEnv::Static();
       
   475     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   476     if( aDoubleStyle )
       
   477         {
       
   478         AknCFDUtility::AppendSkinnedImageToArrayL( *eikEnv, *aIconArray,
       
   479             skin, KAknsIIDQgnPropPhoneMemcLarge, KAvkonBitmapFile,
       
   480             EMbmAvkonQgn_prop_phone_memc_large,
       
   481             EMbmAvkonQgn_prop_phone_memc_large_mask );
       
   482         AknCFDUtility::AppendSkinnedImageToArrayL( *eikEnv, *aIconArray,
       
   483             skin, KAknsIIDQgnPropMmcMemcLarge, KAvkonBitmapFile,
       
   484             EMbmAvkonQgn_prop_mmc_memc_large,
       
   485             EMbmAvkonQgn_prop_mmc_memc_large_mask );
       
   486         /**
       
   487         * !!! NOTE !!!
       
   488         * Inserting NULL pointers so the aIconArray count is always same
       
   489         * regardless the if(doubleStyle) clause. In doubleStyle the icons
       
   490         * are actually replaced by localized strings.
       
   491         */
       
   492         aIconArray->AppendL( NULL );// Uses mmc_locked string instead.
       
   493         aIconArray->AppendL( NULL );// Uses mmc_non string insterad.
       
   494 
       
   495         AknCFDUtility::AppendSkinnedImageToArrayL( *eikEnv, *aIconArray,
       
   496             skin, KAknsIIDQgnPropRemoteDriveMemcLarge, KAvkonBitmapFile,
       
   497             EMbmAvkonQgn_prop_remote_drive_memc_large,
       
   498             EMbmAvkonQgn_prop_remote_drive_memc_large_mask );
       
   499 
       
   500         AknCFDUtility::AppendSkinnedImageToArrayL( *eikEnv, *aIconArray,
       
   501             skin, KAknsIIDQgnIndiConnectionOnAdd, KAvkonBitmapFile,
       
   502             EMbmAvkonQgn_indi_connection_on_add,
       
   503             EMbmAvkonQgn_indi_connection_on_add_mask );
       
   504         }
       
   505     else
       
   506         {
       
   507         AknCFDUtility::AppendSkinnedImageToArrayL( *eikEnv, *aIconArray,
       
   508             skin, KAknsIIDQgnPropPhoneMemc, KMemoryCardUiBitmapFile,
       
   509             EMbmAknmemorycarduiQgn_prop_phone_memc,
       
   510             EMbmAknmemorycarduiQgn_prop_phone_memc_mask );
       
   511         AknCFDUtility::AppendSkinnedImageToArrayL( *eikEnv, *aIconArray,
       
   512             skin, KAknsIIDQgnPropMmcMemc, KMemoryCardUiBitmapFile,
       
   513             EMbmAknmemorycarduiQgn_prop_mmc_memc,
       
   514             EMbmAknmemorycarduiQgn_prop_mmc_memc_mask );
       
   515         AknCFDUtility::AppendSkinnedImageToArrayL( *eikEnv, *aIconArray,
       
   516             skin, KAknsIIDQgnPropMmcLocked, KMemoryCardUiBitmapFile,
       
   517             EMbmAknmemorycarduiQgn_prop_mmc_locked,
       
   518             EMbmAknmemorycarduiQgn_prop_mmc_locked_mask );
       
   519         AknCFDUtility::AppendSkinnedImageToArrayL( *eikEnv, *aIconArray,
       
   520             skin, KAknsIIDQgnPropMmcNon, KMemoryCardUiBitmapFile,
       
   521             EMbmAknmemorycarduiQgn_prop_mmc_non,
       
   522             EMbmAknmemorycarduiQgn_prop_mmc_non_mask );
       
   523         AknCFDUtility::AppendSkinnedImageToArrayL( *eikEnv, *aIconArray,
       
   524             skin, KAknsIIDQgnPropRemoteDriveMemc, KMemoryCardUiBitmapFile,
       
   525             EMbmAvkonQgn_prop_remote_drive_memc,
       
   526             EMbmAvkonQgn_prop_remote_drive_memc_mask );
       
   527 
       
   528         AknCFDUtility::AppendSkinnedImageToArrayL( *eikEnv, *aIconArray,
       
   529             skin, KAknsIIDQgnIndiConnectionOnAdd, KMemoryCardUiBitmapFile,
       
   530             EMbmAvkonQgn_indi_connection_on_add,
       
   531             EMbmAvkonQgn_indi_connection_on_add_mask );
       
   532         }
       
   533     _LOG1( "[CAknMemorySelectionDialog] aIconArray count=%d",
       
   534            aIconArray->Count() );
       
   535     }
       
   536 
       
   537 
       
   538 // ---------------------------------------------------------------------------
       
   539 // CAknMemorySelectionDialog::NumberOfItems
       
   540 // ---------------------------------------------------------------------------
       
   541 //
       
   542 TInt CAknMemorySelectionDialog::NumberOfItems() const
       
   543     {
       
   544     return iModel->MdcaCount();
       
   545     }
       
   546 
       
   547 
       
   548 // ---------------------------------------------------------------------------
       
   549 // CAknMemorySelectionDialog::RunL
       
   550 // ---------------------------------------------------------------------------
       
   551 //
       
   552 TBool CAknMemorySelectionDialog::RunL(
       
   553     TInt aResourceId,
       
   554     TMemory& aSelectedMemory,
       
   555     TDes* aRootPath,
       
   556     TDes* aDefaultFolder,
       
   557     const TDesC& aTitle,
       
   558     MAknMemorySelectionObserver* aObserver
       
   559     )
       
   560     {
       
   561     CAknMemorySelectionDialog* self = CAknMemorySelectionDialog::NewL(
       
   562         ECFDDialogTypeNormal, aResourceId, ETrue );
       
   563     CleanupStack::PushL( self );
       
   564 
       
   565     self->iObserver = aObserver;
       
   566     self->SetTitleL( aTitle );
       
   567 
       
   568     TBool returnValue(
       
   569         self->ExecuteL( aSelectedMemory, aRootPath, aDefaultFolder ) );
       
   570 
       
   571     CleanupStack::PopAndDestroy();
       
   572     return returnValue;
       
   573     }
       
   574 
       
   575 
       
   576 // ---------------------------------------------------------------------------
       
   577 // CAknMemorySelectionDialog::SetResourceId
       
   578 // ---------------------------------------------------------------------------
       
   579 //
       
   580 void CAknMemorySelectionDialog::SetResourceId(
       
   581     TInt& aResourceId, TCommonDialogType aDialogType ) const
       
   582     {
       
   583     switch( aDialogType )
       
   584         {
       
   585         case ECFDDialogTypeMove:
       
   586             {
       
   587             aResourceId = R_CFD_DEFAULT_MOVE_MEMORY_SELECTION;
       
   588             break;
       
   589             }
       
   590         case ECFDDialogTypeSave:
       
   591             {
       
   592             aResourceId = R_CFD_DEFAULT_SAVE_MEMORY_SELECTION;
       
   593             break;
       
   594             }
       
   595         case ECFDDialogTypeSelect:
       
   596             {
       
   597             aResourceId = R_CFD_DEFAULT_SELECT_MEMORY_SELECTION;
       
   598             break;
       
   599             }
       
   600         case ECFDDialogTypeCopy:
       
   601             {
       
   602             aResourceId = R_CFD_DEFAULT_COPY_MEMORY_SELECTION;
       
   603             break;
       
   604             }
       
   605         case ECFDDialogTypeDefaultSetting:
       
   606             {
       
   607             aResourceId = R_CFD_DEFAULT_DEFAULT_MEMORY_SELECTION;
       
   608             break;
       
   609             }
       
   610         default:
       
   611             {
       
   612             aResourceId = R_CFD_DEFAULT_MEMORY_SELECTION;
       
   613             break;
       
   614             }
       
   615         }
       
   616     }
       
   617 
       
   618 
       
   619 // ---------------------------------------------------------------------------
       
   620 // CAknMemorySelectionDialog::ReadFromResourceL
       
   621 // ---------------------------------------------------------------------------
       
   622 //
       
   623 void CAknMemorySelectionDialog::ReadFromResourceL(
       
   624     TInt aResourceId, TBool aResourceDefined )
       
   625     {
       
   626     TResourceReader reader;
       
   627     iCoeEnv->CreateResourceReaderLC( reader, aResourceId );
       
   628     // Read title.
       
   629     AknCFDUtility::AllocateIfNullL( iTitle, reader.ReadTPtrC() );
       
   630     // Read left softkey text.
       
   631     AknCFDUtility::AllocateIfNullL( iLeftSoftkey, reader.ReadTPtrC() );
       
   632     // Read right softkey text.
       
   633     AknCFDUtility::AllocateIfNullL( iRightSoftkey, reader.ReadTPtrC() );
       
   634 
       
   635     TBool readLocations = ETrue; // This is for debugging
       
   636     if( readLocations && aResourceDefined )
       
   637         {
       
   638         // Read number of LOCATION structures.
       
   639         TInt locations( reader.ReadInt16() );
       
   640         // There must be either 0 or 2 or more locations because
       
   641         // user doesn't have to define locations.
       
   642         // If they are not defined, defaults C:\ and E:\ are used.
       
   643         // If locations are defined, there must be at least two of them.
       
   644         __ASSERT_DEBUG( locations == 0 || locations >= 2,
       
   645             User::Panic( KCFDPanicText, ECFDPanicNoLocationStructures ) );
       
   646 
       
   647         TPtrC temp;
       
   648         TPath rootPath;
       
   649         for( TInt index( 0 ); index < locations; index++ )
       
   650             {
       
   651             temp.Set( reader.ReadTPtrC() );
       
   652             // Check that root path is defined
       
   653             // Descriptor must be at least 3 chars long (X:\).
       
   654             __ASSERT_DEBUG( temp.Length() >= 3,
       
   655                 User::Panic( KCFDPanicText,
       
   656                              ECFDPanicRootPathNotDefined ) );
       
   657 
       
   658              // Must not return an error
       
   659             __ASSERT_DEBUG( AknCFDUtility::DriveNumber( temp ) >= 0,
       
   660                 User::Panic( KCFDPanicText,
       
   661                              ECFDPanicRootPathNotDefined ) );
       
   662 
       
   663             rootPath.Zero();
       
   664             TDriveNumber drive =
       
   665                 ( TDriveNumber )AknCFDUtility::DriveNumber( temp );
       
   666             if( drive == EDriveC )
       
   667                 {
       
   668                 rootPath = PathInfo::PhoneMemoryRootPath();
       
   669                 }
       
   670             else
       
   671                 {
       
   672                 // There is an issue with the function PathInfo::MemoryCardRootPath(),
       
   673                 // so use this method to get MemoryCardRootPath.
       
   674                 TChar driveLetter;
       
   675                 _LIT( KPathTail, ":\\" );
       
   676                 User::LeaveIfError(
       
   677                     DriveInfo::GetDefaultDrive(
       
   678                             DriveInfo::EDefaultRemovableMassStorage,
       
   679                             driveLetter ) );
       
   680                 rootPath.Append( driveLetter );
       
   681                 rootPath.Append( KPathTail );
       
   682                 }
       
   683             TBool rightRootPath = EFalse;
       
   684             if ( temp.FindC( rootPath ) == 0 )
       
   685                 {
       
   686                 // Use user's root path, part of user defines
       
   687                 // (lowercase) may be replaced by rootPath
       
   688                 rootPath.Append( temp.Right( temp.Length() - 
       
   689                     rootPath.Length() ) );
       
   690                 rightRootPath = ETrue;
       
   691                 }
       
   692             iRootPathArray.AppendL( rootPath );
       
   693 
       
   694 			temp.Set( reader.ReadTPtrC() );
       
   695             if ( rightRootPath )
       
   696                 {
       
   697                 iDefaultFolderArray.AppendL( temp );
       
   698                 }
       
   699             else
       
   700                 {
       
   701                 iDefaultFolderArray.AppendL( KNullDesC );
       
   702                 }
       
   703             }
       
   704         } // if readLocations
       
   705     CleanupStack::PopAndDestroy(); // reader
       
   706     }
       
   707 
       
   708 // ---------------------------------------------------------------------------
       
   709 // CAknMemorySelectionDialog::GetSystemPaths
       
   710 // ---------------------------------------------------------------------------
       
   711 //
       
   712 void CAknMemorySelectionDialog::GetSystemPathsL()
       
   713     {
       
   714     iRootPathArray.AppendL( PathInfo::PhoneMemoryRootPath() );
       
   715     // There is an issue with the function PathInfo::MemoryCardRootPath(),
       
   716     // so use this method to get MemoryCardRootPath.
       
   717     TPath rootPath;
       
   718     TChar driveLetter;
       
   719     rootPath.Zero();
       
   720     _LIT( KPathTail, ":\\" );
       
   721     User::LeaveIfError(
       
   722         DriveInfo::GetDefaultDrive(
       
   723                 DriveInfo::EDefaultRemovableMassStorage,
       
   724                 driveLetter ) );
       
   725     rootPath.Append( driveLetter );
       
   726     rootPath.Append( KPathTail );
       
   727     iRootPathArray.AppendL( rootPath );
       
   728     iDefaultFolderArray.AppendL( KNullDesC );
       
   729     iDefaultFolderArray.AppendL( KNullDesC );
       
   730     }