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