filemanager/App/src/CFileManagerMainView.cpp
changeset 0 6a9f87576119
child 13 5181328fad28
equal deleted inserted replaced
-1:000000000000 0:6a9f87576119
       
     1 /*
       
     2 * Copyright (c) 2006-2008 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:  Main view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <aknlists.h>
       
    22 #include <CFileManagerEngine.h>
       
    23 #include <CFileManagerItemProperties.h>
       
    24 #include <FileManager.rsg>
       
    25 #include <csxhelp/fmgr.hlp.hrh>
       
    26 #include <FileManagerDlgUtils.h>
       
    27 #include <FileManagerDebug.h>
       
    28 #include <CFileManagerFeatureManager.h>
       
    29 #include <coreapplicationuisdomainpskeys.h>
       
    30 #include <StringLoader.h>
       
    31 #include <cmemstatepopup.h>
       
    32 #include "CFileManagerMainView.h"
       
    33 #include "CFileManagerFileListContainer.h"
       
    34 #include "CFileManagerAppUi.h"
       
    35 #include "CFileManagerDocument.h"
       
    36 #include "FileManager.hrh"
       
    37 
       
    38 
       
    39 // ======== MEMBER FUNCTIONS ========
       
    40 
       
    41 // ----------------------------------------------------------------------------
       
    42 // CFileManagerMainView::CFileManagerMainView
       
    43 // ----------------------------------------------------------------------------
       
    44 //
       
    45 CFileManagerMainView::CFileManagerMainView()
       
    46     {
       
    47     }
       
    48 
       
    49 // ----------------------------------------------------------------------------
       
    50 // CFileManagerMainView::NewLC
       
    51 // ----------------------------------------------------------------------------
       
    52 //
       
    53 CFileManagerMainView* CFileManagerMainView::NewLC()
       
    54     {
       
    55     CFileManagerMainView* self = new( ELeave ) CFileManagerMainView();
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL();
       
    58     return self;
       
    59     }
       
    60 
       
    61 // ----------------------------------------------------------------------------
       
    62 // CFileManagerMainView::ConstructL
       
    63 // ----------------------------------------------------------------------------
       
    64 //
       
    65 void CFileManagerMainView::ConstructL()
       
    66     {
       
    67     CFileManagerViewBase::ConstructL(
       
    68         FeatureManager().IsEmbedded() ?
       
    69             R_FILEMANAGER_MAIN_VIEW_EMBEDDED :
       
    70             R_FILEMANAGER_MAIN_VIEW );
       
    71     }
       
    72 
       
    73 // ----------------------------------------------------------------------------
       
    74 // CFileManagerMainView::~CFileManagerMainView
       
    75 // ----------------------------------------------------------------------------
       
    76 // 
       
    77 CFileManagerMainView::~CFileManagerMainView()
       
    78     {
       
    79     }
       
    80 
       
    81 // ----------------------------------------------------------------------------
       
    82 // CFileManagerMainView::DoActivateL
       
    83 // ----------------------------------------------------------------------------
       
    84 // 
       
    85 void CFileManagerMainView::DoActivateL(
       
    86         const TVwsViewId& aPrevViewId,
       
    87         TUid aCustomMessageId,
       
    88         const TDesC8& aCustomMessage )
       
    89     {
       
    90     FUNC_LOG
       
    91 
       
    92     CFileManagerViewBase::DoActivateL(
       
    93         aPrevViewId, aCustomMessageId, aCustomMessage );
       
    94 
       
    95     // Ensure that no directory is defined
       
    96     if ( iEngine.CurrentDirectory().Length() )
       
    97         {
       
    98         TInt count( iEngine.NavigationLevel() );
       
    99         ++count;
       
   100         for ( TInt i( 0 ); i < count; i++ )
       
   101             {
       
   102             TRAP_IGNORE( iEngine.BackstepL() );
       
   103             }
       
   104         }
       
   105 
       
   106     CFileManagerAppUi* appUi = 
       
   107         static_cast< CFileManagerAppUi* >( AppUi() );
       
   108     appUi->RestoreDefaultTitleL();
       
   109     iEngine.SetState( CFileManagerEngine::ENavigation );
       
   110     iEngine.SetObserver( this );
       
   111     appUi->ExitEmbeddedAppIfNeededL();
       
   112     if ( !appUi->WaitingForInputParams() )
       
   113         {
       
   114         iEngine.RefreshDirectory();
       
   115         }
       
   116     }
       
   117 
       
   118 // ----------------------------------------------------------------------------
       
   119 // CFileManagerMainView::DoDeactivate
       
   120 // ----------------------------------------------------------------------------
       
   121 // 
       
   122 void CFileManagerMainView::DoDeactivate()
       
   123     {
       
   124     FUNC_LOG
       
   125 
       
   126     CFileManagerViewBase::DoDeactivate();
       
   127     }
       
   128 
       
   129 // ----------------------------------------------------------------------------
       
   130 // CFileManagerMainView::DirectoryChangedL
       
   131 // ----------------------------------------------------------------------------
       
   132 // 
       
   133 void CFileManagerMainView::DirectoryChangedL()
       
   134     {
       
   135     FUNC_LOG
       
   136 
       
   137     CFileManagerAppUi* appUi = 
       
   138         static_cast< CFileManagerAppUi* >( AppUi() );
       
   139 
       
   140     if ( iContainer && !appUi->WaitingForInputParams() )
       
   141         {
       
   142         iContainer->RefreshListL( iIndex );
       
   143         }
       
   144     }
       
   145 
       
   146 // ----------------------------------------------------------------------------
       
   147 // CFileManagerMainView::Id
       
   148 // ----------------------------------------------------------------------------
       
   149 // 
       
   150 TUid CFileManagerMainView::Id() const
       
   151     {
       
   152     return CFileManagerAppUi::KFileManagerMainViewId;
       
   153     }
       
   154 
       
   155 // ----------------------------------------------------------------------------
       
   156 // CFileManagerMainView::CreateContainerL
       
   157 // ----------------------------------------------------------------------------
       
   158 // 
       
   159 CFileManagerContainerBase* CFileManagerMainView::CreateContainerL()
       
   160     {
       
   161     return CFileManagerFileListContainer::NewL(
       
   162         ClientRect(),
       
   163         iIndex,
       
   164         CFileManagerFileListContainer::EListMain,
       
   165         R_QTN_SELEC_EMPTY_LIST,
       
   166         KFMGR_HLP_MAIN_VIEW );
       
   167     }
       
   168 
       
   169 // ----------------------------------------------------------------------------
       
   170 // CFileManagerMainView::DynInitMenuPaneL
       
   171 // ----------------------------------------------------------------------------
       
   172 // 
       
   173 void CFileManagerMainView::DynInitMenuPaneL(
       
   174         TInt aResourceId, 
       
   175         CEikMenuPane* aMenuPane)
       
   176     {
       
   177     switch( aResourceId )
       
   178         {
       
   179         // These menus are used only by main view
       
   180         case R_FILEMANAGER_MAIN_VIEW_MENU:
       
   181             {
       
   182             MainMenuFilteringL( *aMenuPane );
       
   183             break;
       
   184             }
       
   185         case R_FILEMANAGER_REMOTE_DRIVES_MENU:
       
   186             {
       
   187             RemoteDrivesMenuFilteringL( *aMenuPane );
       
   188             break;
       
   189             }
       
   190         case R_FILEMANAGER_MEMORY_STORAGE_MENU:
       
   191             {
       
   192             MemoryStorageMenuFilteringL( *aMenuPane );
       
   193             break;
       
   194             }
       
   195         default:
       
   196             {
       
   197             CFileManagerViewBase::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   198             break;
       
   199             }
       
   200         }
       
   201     }
       
   202 
       
   203 // ----------------------------------------------------------------------------
       
   204 // CFileManagerMainView::MainMenuFilteringL
       
   205 // ----------------------------------------------------------------------------
       
   206 //
       
   207 void CFileManagerMainView::MainMenuFilteringL( CEikMenuPane& aMenuPane )
       
   208     {
       
   209     RemoteDriveCommonFilteringL( aMenuPane );
       
   210 
       
   211     if ( !iContainer->ListBoxNumberOfItems() )
       
   212         {
       
   213         aMenuPane.SetItemDimmed( EFileManagerEject, ETrue );
       
   214         aMenuPane.SetItemDimmed( EFileManagerFindFile, ETrue );
       
   215 #ifndef RD_FILE_MANAGER_BACKUP
       
   216         aMenuPane.SetItemDimmed( EFileManagerBackup, ETrue );
       
   217         aMenuPane.SetItemDimmed( EFileManagerRestore, ETrue );
       
   218 #endif // RD_FILE_MANAGER_BACKUP
       
   219         aMenuPane.SetItemDimmed( EFileManagerMemoryStorage, ETrue );
       
   220         return;
       
   221         }
       
   222 
       
   223     if ( !FeatureManager().IsRemoteStorageFwSupported() )
       
   224         {
       
   225         aMenuPane.SetItemDimmed( EFileManagerRemoveDrives, ETrue );
       
   226         }
       
   227 
       
   228     CFileManagerItemProperties* prop = iEngine.GetItemInfoLC(
       
   229         iContainer->ListBoxCurrentItemIndex() );
       
   230     TUint32 drvState( 0 );
       
   231     if ( prop->IsDrive() )
       
   232         {
       
   233         iEngine.DriveState( drvState, prop->FullPath() );
       
   234         }
       
   235 
       
   236     TFileManagerDriveInfo drvInfo;
       
   237     if ( DriveInfoAtCurrentPosL( drvInfo ) < 0 )
       
   238         {
       
   239         // No drive selected
       
   240         aMenuPane.SetItemDimmed( EFileManagerMemoryStorage, ETrue );
       
   241         aMenuPane.SetItemDimmed( EFileManagerEject, ETrue );
       
   242         }
       
   243     else
       
   244         {
       
   245         if ( !( drvInfo.iState & TFileManagerDriveInfo::EDriveEjectable ) ||
       
   246              !( drvInfo.iState & TFileManagerDriveInfo::EDrivePresent ) )
       
   247             {
       
   248             aMenuPane.SetItemDimmed( EFileManagerEject, ETrue );
       
   249             }
       
   250         if ( ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable ) && 
       
   251             !( drvInfo.iState & TFileManagerDriveInfo::EDrivePresent ) )
       
   252             {
       
   253             aMenuPane.SetItemDimmed( EFileManagerMemoryStorage, ETrue );
       
   254             }
       
   255         if ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote )
       
   256             {
       
   257             aMenuPane.SetItemDimmed( EFileManagerMemoryStorage, ETrue );
       
   258             }
       
   259         }
       
   260 
       
   261 #ifndef RD_FILE_MANAGER_BACKUP
       
   262     TFileManagerDriveInfo mmcinfo( iEngine.GetMMCInfoL() );
       
   263     if ( mmcinfo.iState & ( TFileManagerDriveInfo::EDriveLocked |
       
   264                             TFileManagerDriveInfo::EDriveCorrupted ) )
       
   265         {
       
   266         aMenuPane.SetItemDimmed( EFileManagerBackup, ETrue );
       
   267         aMenuPane.SetItemDimmed( EFileManagerRestore, ETrue );
       
   268         }
       
   269     else if ( !( mmcinfo.iState & TFileManagerDriveInfo::EDrivePresent ) )
       
   270         {
       
   271         aMenuPane.SetItemDimmed( EFileManagerBackup, ETrue );
       
   272         aMenuPane.SetItemDimmed( EFileManagerRestore, ETrue );
       
   273         }
       
   274     else if ( !( mmcinfo.iState & TFileManagerDriveInfo::EDriveBackupped ) )
       
   275         {
       
   276         aMenuPane.SetItemDimmed( EFileManagerRestore, ETrue );
       
   277         }
       
   278     if ( FeatureManager().IsEmbedded() )
       
   279         {
       
   280         // Disable backup in embedded mode, because it messes up 
       
   281         // backup and restore operations since embedded apps are closed.
       
   282         aMenuPane.SetItemDimmed( EFileManagerBackup, ETrue );
       
   283         aMenuPane.SetItemDimmed( EFileManagerRestore, ETrue );
       
   284         }
       
   285 #endif // RD_FILE_MANAGER_BACKUP
       
   286 
       
   287     CleanupStack::PopAndDestroy( prop );
       
   288     }
       
   289 
       
   290 // ----------------------------------------------------------------------------
       
   291 // CFileManagerMainView::RemoteDrivesMenuFilteringL
       
   292 // ----------------------------------------------------------------------------
       
   293 //
       
   294 void CFileManagerMainView::RemoteDrivesMenuFilteringL(
       
   295         CEikMenuPane& aMenuPane )
       
   296     {
       
   297     TInt index( iContainer->ListBoxCurrentItemIndex() );
       
   298     CFileManagerItemProperties* prop = iEngine.GetItemInfoLC( index );
       
   299     TUint32 drvState( 0 );
       
   300     if ( iEngine.DriveState( drvState, prop->FullPath() ) == KErrNone )
       
   301         {
       
   302         if ( !( drvState & TFileManagerDriveInfo::EDriveRemote ) ||
       
   303              ( drvState & TFileManagerDriveInfo::EDriveConnected ) )
       
   304             {
       
   305             aMenuPane.SetItemDimmed(
       
   306                 EFileManagerRemoveDrivesSettings, ETrue );
       
   307             aMenuPane.SetItemDimmed(
       
   308                 EFileManagerRemoveDrivesDelete, ETrue );
       
   309             }
       
   310         }
       
   311     else
       
   312         {
       
   313         aMenuPane.SetItemDimmed( EFileManagerRemoveDrivesSettings, ETrue );
       
   314         aMenuPane.SetItemDimmed( EFileManagerRemoveDrivesDelete, ETrue );
       
   315         }
       
   316     CleanupStack::PopAndDestroy( prop );
       
   317 	TBool dimAll( EFalse );
       
   318 	if ( !FeatureManager().IsRemoteStorageFwSupported() )
       
   319 		{
       
   320 		dimAll = ETrue;
       
   321 		}
       
   322 	else
       
   323 		{
       
   324 		if ( drvState & TFileManagerDriveInfo::EDriveRemote )
       
   325 		    {
       
   326 			if ( drvState & TFileManagerDriveInfo::EDriveConnected )
       
   327 			    {
       
   328 				aMenuPane.SetItemDimmed( EFileManagerConnectRemoveDrive, ETrue );
       
   329 				}
       
   330 			else
       
   331 				{
       
   332 				aMenuPane.SetItemDimmed( EFileManagerDisconnectRemoveDrive,ETrue );
       
   333 				}
       
   334 			}
       
   335 		else
       
   336 			{
       
   337 			dimAll = ETrue;
       
   338 			}
       
   339 		}
       
   340 		
       
   341 	if ( dimAll )
       
   342         {
       
   343 	    aMenuPane.SetItemDimmed( EFileManagerConnectRemoveDrive, ETrue );
       
   344 	    aMenuPane.SetItemDimmed( EFileManagerDisconnectRemoveDrive, ETrue );
       
   345         }
       
   346     }
       
   347 
       
   348 // ----------------------------------------------------------------------------
       
   349 // CFileManagerMainView::HandleCommandL
       
   350 // ----------------------------------------------------------------------------
       
   351 // 
       
   352 void CFileManagerMainView::HandleCommandL( TInt aCommand )
       
   353     {
       
   354     switch( aCommand )
       
   355         {
       
   356         case EFileManagerOpen:
       
   357             {
       
   358             CmdOpenMemoryStoreL();
       
   359             break;
       
   360             }
       
   361         case EFileManagerEject:
       
   362             {
       
   363             CmdEjectL();
       
   364             break;
       
   365             }
       
   366 #ifndef RD_FILE_MANAGER_BACKUP
       
   367         case EFileManagerBackup:
       
   368             {
       
   369             CmdBackupL();
       
   370             break;
       
   371             }
       
   372         case EFileManagerRestore:
       
   373             {
       
   374             CmdRestoreL();
       
   375             break;
       
   376             }
       
   377 #endif // RD_FILE_MANAGER_BACKUP
       
   378         case EFileManagerRemoveDrivesMapDrive:
       
   379             {
       
   380             CmdMapRemoteDriveL();
       
   381             break;
       
   382             }
       
   383         case EFileManagerRemoveDrivesSettings:
       
   384             {
       
   385             CmdRemoteDriveSettingsL();
       
   386             break;
       
   387             }
       
   388         case EFileManagerDelete: // Fall through
       
   389         case EFileManagerRemoveDrivesDelete:
       
   390             {
       
   391             CmdRemoteDriveDeleteL();
       
   392             break;
       
   393             }
       
   394         case EFileManagerSend: // Suppress
       
   395             {
       
   396             break;
       
   397             }
       
   398         case EFileManagerMemoryStorageDetails:
       
   399             {
       
   400             CmdMemoryStorageDetailsL();
       
   401             break;
       
   402             }
       
   403         case EFileManagerMemoryStorageName:
       
   404         case EFileManagerMemoryStorageRename: // Fall through
       
   405             {
       
   406             CmdRenameDriveL();
       
   407             break;
       
   408             }
       
   409         case EFileManagerMemoryStorageFormat:
       
   410             {
       
   411             CmdFormatDriveL();
       
   412             break;
       
   413             }
       
   414         case EFileManagerMemoryStorageSetPassword:
       
   415             {
       
   416             CmdSetDrivePasswordL();
       
   417             break;
       
   418             }
       
   419         case EFileManagerMemoryStorageChangePassword:
       
   420             {
       
   421             CmdChangeDrivePasswordL();
       
   422             break;
       
   423             }
       
   424         case EFileManagerMemoryStorageRemovePassword:
       
   425             {
       
   426             CmdRemoveDrivePasswordL();
       
   427             break;
       
   428             }
       
   429         case EFileManagerMemoryStorageUnlock:
       
   430             {
       
   431             CmdUnlockDriveL();
       
   432             break;
       
   433             }
       
   434         default:
       
   435             {
       
   436             CFileManagerViewBase::HandleCommandL( aCommand );
       
   437             break;
       
   438             }
       
   439         }
       
   440     }
       
   441 
       
   442 // ----------------------------------------------------------------------------
       
   443 // CFileManagerMainView::CmdOpenMemoryStoreL
       
   444 // ----------------------------------------------------------------------------
       
   445 // 
       
   446 void CFileManagerMainView::CmdOpenMemoryStoreL()
       
   447     {
       
   448     StoreIndex();
       
   449     TInt index( iContainer->ListBoxCurrentItemIndex() );
       
   450     if ( index >= 0 )
       
   451         {
       
   452         CFileManagerAppUi* appUi = 
       
   453             static_cast< CFileManagerAppUi* >( AppUi() );
       
   454         CFileManagerItemProperties* prop = iEngine.GetItemInfoLC( index );
       
   455 
       
   456         TRAPD( err, iEngine.OpenL( index ) );
       
   457         if ( err == KErrNone && prop->FullPath().Length() )
       
   458             {
       
   459             appUi->ActivateMemoryStoreViewL();
       
   460             }
       
   461         CleanupStack::PopAndDestroy( prop );
       
   462         }
       
   463     }
       
   464 
       
   465 // ----------------------------------------------------------------------------
       
   466 // CFileManagerMainView::CmdEjectL
       
   467 // ----------------------------------------------------------------------------
       
   468 //
       
   469 void CFileManagerMainView::CmdEjectL()
       
   470     {
       
   471     StoreIndex();
       
   472 
       
   473 #ifdef RD_MULTIPLE_DRIVE
       
   474     TInt index( iContainer->ListBoxCurrentItemIndex() );
       
   475     CFileManagerItemProperties* prop = iEngine.GetItemInfoLC( index );
       
   476     TInt drive( prop->DriveId() );
       
   477     const TInt KDriveShift = 16;
       
   478 
       
   479     // Let SysAp handle eject
       
   480     RProperty::Set(
       
   481         KPSUidCoreApplicationUIs,
       
   482         KCoreAppUIsMmcRemovedWithoutEject,
       
   483         ECoreAppUIsEjectCommandUsedToDrive | ( drive << KDriveShift )
       
   484         );
       
   485 
       
   486     CleanupStack::PopAndDestroy( prop );
       
   487 #else // RD_MULTIPLE_DRIVE
       
   488     if ( FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( R_QTN_CONF_EJECT ) )
       
   489         {
       
   490         StartProcessL( EEjectProcess );
       
   491         }
       
   492 #endif // RD_MULTIPLE_DRIVE
       
   493     }
       
   494 
       
   495 #ifndef RD_FILE_MANAGER_BACKUP
       
   496 // ----------------------------------------------------------------------------
       
   497 // CFileManagerMainView::CmdBackupL
       
   498 //
       
   499 // ----------------------------------------------------------------------------
       
   500 //
       
   501 void CFileManagerMainView::CmdBackupL()
       
   502     {
       
   503     StoreIndex();
       
   504     TInt textId( R_QTN_CONFIRM_BACKUP_TEXT );
       
   505     TFileManagerDriveInfo mmcinfo( iEngine.GetMMCInfoL() );
       
   506 
       
   507     if( mmcinfo.iState & TFileManagerDriveInfo::EDriveBackupped )
       
   508         {
       
   509         textId = R_QTN_CONFIRM_BACKUP_TEXT2;
       
   510         }
       
   511     if( FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( textId ) )
       
   512         {
       
   513         if ( !DriveReadOnlyMmcL( mmcinfo.iDrive ) )
       
   514             {
       
   515             if ( !IsDriveAvailable( mmcinfo.iDrive ) || 
       
   516                 !CheckPhoneState() )
       
   517                 {
       
   518                 FileManagerDlgUtils::ShowErrorNoteL( R_QTN_CRITICAL_ERROR );
       
   519                 }
       
   520             else
       
   521                 {
       
   522                 StartProcessL( EBackupProcess );
       
   523                 }
       
   524             }
       
   525         }
       
   526     }
       
   527 
       
   528 // ----------------------------------------------------------------------------
       
   529 // CFileManagerMainView::CmdRestoreL
       
   530 // ----------------------------------------------------------------------------
       
   531 //
       
   532 void CFileManagerMainView::CmdRestoreL()
       
   533     {
       
   534     StoreIndex();
       
   535     if( FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( R_QTN_CONFIRM_RESTORE_TEXT ) )
       
   536         {
       
   537         TFileManagerDriveInfo mmcinfo( iEngine.GetMMCInfoL() );
       
   538         
       
   539         if ( !IsDriveAvailable( mmcinfo.iDrive ) || 
       
   540             !CheckPhoneState() )
       
   541             {
       
   542             FileManagerDlgUtils::ShowErrorNoteL( R_QTN_CRITICAL_ERROR );
       
   543             }
       
   544         else
       
   545             {
       
   546             StartProcessL( ERestoreProcess );
       
   547             }
       
   548         }
       
   549     }
       
   550 #endif // RD_FILE_MANAGER_BACKUP
       
   551 
       
   552 // ----------------------------------------------------------------------------
       
   553 // CFileManagerMainView::CmdMapRemoteDriveL
       
   554 // ----------------------------------------------------------------------------
       
   555 //
       
   556 void CFileManagerMainView::CmdMapRemoteDriveL()
       
   557     {
       
   558     StoreIndex();
       
   559     const TInt KMaxRemoteDrives = 9;
       
   560     RFs& fs( CCoeEnv::Static()->FsSession() );
       
   561     TDriveList driveList;
       
   562     User::LeaveIfError( fs.DriveList( driveList, KDriveAttRemote ) );
       
   563     TInt numRemote( 0 );
       
   564     TInt count( driveList.Length() );
       
   565     for( TInt i( 0 ); i < count; ++i )
       
   566         {
       
   567         if ( driveList[ i ] & KDriveAttRemote )
       
   568             {
       
   569             ++numRemote;
       
   570             }
       
   571         }
       
   572     if ( numRemote < KMaxRemoteDrives )
       
   573         {
       
   574         OpenRemoteDriveSettingsL();
       
   575         }
       
   576     else
       
   577         {
       
   578         FileManagerDlgUtils::ShowConfirmQueryWithOkL(
       
   579             FileManagerDlgUtils::EErrorIcons,
       
   580             R_QTN_RD_ERROR_MAX_DRIVES );
       
   581         }
       
   582     }
       
   583 
       
   584 // ----------------------------------------------------------------------------
       
   585 // CFileManagerMainView::CmdRemoteDriveSettingsL
       
   586 // ------------------------------------------------------------------------------
       
   587 //
       
   588 void CFileManagerMainView::CmdRemoteDriveSettingsL()
       
   589     {
       
   590     StoreIndex();
       
   591     TInt index( iContainer->ListBoxCurrentItemIndex() );
       
   592     CFileManagerItemProperties* prop = iEngine.GetItemInfoLC( index );
       
   593     OpenRemoteDriveSettingsL( prop->DriveName() );
       
   594     CleanupStack::PopAndDestroy( prop );
       
   595     }
       
   596 
       
   597 // ------------------------------------------------------------------------------
       
   598 // CFileManagerMainView::CmdRemoteDriveDeleteL
       
   599 //
       
   600 // ------------------------------------------------------------------------------
       
   601 //
       
   602 void CFileManagerMainView::CmdRemoteDriveDeleteL()
       
   603     {
       
   604     StoreIndex();
       
   605     TInt index( iContainer->ListBoxCurrentItemIndex() );
       
   606     CFileManagerItemProperties* prop = iEngine.GetItemInfoLC( index );
       
   607     if ( IsDisconnectedRemoteDrive( *prop ) )
       
   608         {
       
   609         if ( FileManagerDlgUtils::ShowConfirmQueryWithYesNoL(
       
   610                 R_QTN_RD_QUERY_DELETE_DRIVE, prop->Name() ) )
       
   611             {
       
   612             TInt drv = TDriveUnit( prop->FullPath() );
       
   613             User::LeaveIfError( iEngine.DeleteRemoteDrive( drv ) );
       
   614             }
       
   615         }
       
   616     CleanupStack::PopAndDestroy( prop );
       
   617     }
       
   618 
       
   619 // ------------------------------------------------------------------------------
       
   620 // CFileManagerMainView::NotifyL
       
   621 //
       
   622 // ------------------------------------------------------------------------------
       
   623 //
       
   624 TInt CFileManagerMainView::NotifyL(
       
   625         TFileManagerNotify aType, TInt aData, const TDesC& aName )
       
   626     {
       
   627     TInt ret( KErrNone );
       
   628     switch ( aType )
       
   629         {
       
   630 #ifdef RD_FILE_MANAGER_BACKUP
       
   631         case ENotifyActionSelected:
       
   632             {
       
   633             if ( aData == EFileManagerBackupAction )
       
   634                 {
       
   635                 StoreIndex();
       
   636                 CFileManagerAppUi* appUi = 
       
   637                     static_cast< CFileManagerAppUi* >( AppUi() );
       
   638                 appUi->ActivateBackupViewL();
       
   639                 }
       
   640             break;
       
   641             }
       
   642 #endif // RD_FILE_MANAGER_BACKUP
       
   643         default:
       
   644             {
       
   645             ret = CFileManagerViewBase::NotifyL( aType, aData, aName );
       
   646             break;
       
   647             }
       
   648         }
       
   649     return ret;
       
   650     }
       
   651 
       
   652 // -----------------------------------------------------------------------------
       
   653 // CFileManagerMainView::MemoryStorageMenuFilteringL
       
   654 // -----------------------------------------------------------------------------
       
   655 // 
       
   656 void CFileManagerMainView::MemoryStorageMenuFilteringL( CEikMenuPane& aMenuPane )
       
   657     {
       
   658     TFileManagerDriveInfo drvInfo;
       
   659     if( DriveInfoAtCurrentPosL( drvInfo ) < 0 )
       
   660         {
       
   661         // No drive selected
       
   662         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageUnlock, ETrue );
       
   663         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageDetails, ETrue );
       
   664         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageFormat, ETrue );
       
   665         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageName, ETrue );
       
   666         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRename, ETrue );
       
   667         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageSetPassword, ETrue );
       
   668         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageChangePassword, ETrue );
       
   669         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRemovePassword, ETrue );
       
   670         return;
       
   671         }
       
   672 
       
   673     if ( drvInfo.iState & TFileManagerDriveInfo::EDriveCorrupted )
       
   674         {
       
   675         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageDetails, ETrue );
       
   676         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageName, ETrue );
       
   677         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRename, ETrue );
       
   678         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageSetPassword, ETrue );
       
   679         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageChangePassword, ETrue );
       
   680         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRemovePassword, ETrue );
       
   681         }
       
   682     else if ( !( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable ) || 
       
   683               ( drvInfo.iState & ( TFileManagerDriveInfo::EDriveLocked |
       
   684                                    TFileManagerDriveInfo::EDriveMassStorage ) ) )
       
   685         {
       
   686         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageName, ETrue );
       
   687         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRename, ETrue );
       
   688         }
       
   689     else if ( drvInfo.iName.Length() > 0 )
       
   690         {
       
   691         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageName, ETrue );
       
   692         }
       
   693     else
       
   694         {
       
   695         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRename, ETrue );
       
   696         }
       
   697     if (!( drvInfo.iState & TFileManagerDriveInfo::EDrivePresent) )
       
   698     	{
       
   699 			aMenuPane.SetItemDimmed(EFileManagerMemoryStorageSetPassword, ETrue );
       
   700 			aMenuPane.SetItemDimmed(EFileManagerMemoryStorageName, ETrue );
       
   701 			aMenuPane.SetItemDimmed(EFileManagerMemoryStorageRename, ETrue );
       
   702 			aMenuPane.SetItemDimmed(EFileManagerMemoryStorageDetails, ETrue );
       
   703 			
       
   704     	}
       
   705 
       
   706     if ( FeatureManager().IsEmbedded() ||
       
   707          !( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable ) ||
       
   708          !( drvInfo.iState & TFileManagerDriveInfo::EDriveFormattable ) )
       
   709         {
       
   710         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageFormat, ETrue );
       
   711         }
       
   712         
       
   713     if ( drvInfo.iState & TFileManagerDriveInfo::EDriveLocked )
       
   714         {
       
   715         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageDetails, ETrue );
       
   716         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageSetPassword, ETrue );
       
   717         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageChangePassword, ETrue );
       
   718         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRemovePassword, ETrue );
       
   719         }
       
   720     else
       
   721         {
       
   722         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageUnlock, ETrue );
       
   723         }
       
   724 
       
   725     if ( !( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable ) ||
       
   726          ( drvInfo.iState & ( TFileManagerDriveInfo::EDriveMassStorage |
       
   727                               TFileManagerDriveInfo::EDriveUsbMemory ) ) )
       
   728         {
       
   729         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageSetPassword, ETrue );
       
   730         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageChangePassword, ETrue );
       
   731         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRemovePassword, ETrue );
       
   732         }
       
   733     else if ( drvInfo.iState & TFileManagerDriveInfo::EDrivePasswordProtected ) 
       
   734         {
       
   735         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageSetPassword, ETrue );
       
   736         }
       
   737     else
       
   738         {
       
   739         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageChangePassword, ETrue );
       
   740         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRemovePassword, ETrue );
       
   741         }
       
   742     }
       
   743 
       
   744 // ------------------------------------------------------------------------------
       
   745 // CFileManagerMainView::CmdMemoryStorageDetailsL
       
   746 // ------------------------------------------------------------------------------
       
   747 //
       
   748 void CFileManagerMainView::CmdMemoryStorageDetailsL()
       
   749     {
       
   750     StoreIndex();
       
   751     TFileManagerDriveInfo drvInfo;
       
   752     TInt drive( DriveInfoAtCurrentPosL( drvInfo ) );
       
   753     if ( drive < 0 )
       
   754         {
       
   755         return; // No drive selected
       
   756         }
       
   757     HBufC* title = StringLoader::LoadLC( R_QTN_FMGR_MSTATE_HEADING );
       
   758     CMemStatePopup::RunLD(
       
   759         static_cast< TDriveNumber >( drive ), *title );
       
   760     CleanupStack::PopAndDestroy( title );
       
   761 //    TFileManagerDriveInfo drvInfo;
       
   762 //    iEngine.GetDriveInfoL( iEngine.CurrentDrive(), drvInfo );
       
   763 //    FileManagerDlgUtils::ShowMemoryStoreInfoPopupL( drvInfo );
       
   764     }
       
   765 
       
   766 // ------------------------------------------------------------------------------
       
   767 // CFileManagerMainView::CmdRenameDriveL
       
   768 // ------------------------------------------------------------------------------
       
   769 //
       
   770 void CFileManagerMainView::CmdRenameDriveL()
       
   771     {
       
   772     StoreIndex();
       
   773     TFileManagerDriveInfo drvInfo;
       
   774     if ( DriveInfoAtCurrentPosL( drvInfo ) < 0 )
       
   775         {
       
   776         return; // No drive selected
       
   777         }
       
   778     if ( drvInfo.iState & TFileManagerDriveInfo::EDriveWriteProtected )
       
   779         {
       
   780         FileManagerDlgUtils::ShowErrorNoteL( R_QTN_MEMORYCARD_READONLY );
       
   781         return;
       
   782         }
       
   783     RenameDriveL( EFalse );
       
   784     iEngine.SetObserver( this );
       
   785     iEngine.RefreshDirectory();
       
   786     }
       
   787 
       
   788 // ------------------------------------------------------------------------------
       
   789 // CFileManagerMainView::CmdSetDrivePasswordL
       
   790 // ------------------------------------------------------------------------------
       
   791 //
       
   792 void CFileManagerMainView::CmdSetDrivePasswordL()
       
   793     {
       
   794     StoreIndex();
       
   795     TInt drive( DriveAtCurrentPosL() );
       
   796     if ( drive < 0 )
       
   797         {
       
   798         return; // No drive selected
       
   799         }
       
   800 
       
   801     TBuf< KFmgrMaxMediaPassword > pwd;
       
   802     if( FileManagerDlgUtils::ShowPasswordQueryL( pwd ) )
       
   803         {
       
   804         TBuf< KFmgrMaxMediaPassword > nullPwd;
       
   805         EmptyPwd( nullPwd );
       
   806         if( UpdatePassword( drive, nullPwd, pwd ) == KErrNone )
       
   807             {
       
   808             FileManagerDlgUtils::ShowConfirmNoteL( R_QTN_PASSWORD_SET_TEXT );
       
   809             }
       
   810         else
       
   811             {
       
   812             FileManagerDlgUtils::ShowErrorNoteL( R_QTN_CRITICAL_ERROR );
       
   813             }
       
   814         }
       
   815     }
       
   816 
       
   817 // ------------------------------------------------------------------------------
       
   818 // CFileManagerMainView::CmdChangeDrivePasswordL
       
   819 // ------------------------------------------------------------------------------
       
   820 //
       
   821 void CFileManagerMainView::CmdChangeDrivePasswordL()
       
   822     {
       
   823     StoreIndex();
       
   824     TInt drive( DriveAtCurrentPosL() );
       
   825     if ( drive < 0 )
       
   826         {
       
   827         return; // No drive selected
       
   828         }
       
   829 
       
   830     TBuf< KFmgrMaxMediaPassword > pwd;
       
   831     TBuf< KFmgrMaxMediaPassword > oldPwd;
       
   832     TBool isDone( EFalse );
       
   833     TBool isCanceled( EFalse );
       
   834     TInt err( KErrNone );
       
   835 
       
   836     // Ask for the old password until the correct one is given
       
   837     while( !isDone )
       
   838         {
       
   839         EmptyPwd( oldPwd );
       
   840         if( FileManagerDlgUtils::ShowSimplePasswordQueryL(
       
   841                 R_QTN_PASSWORD_OLD_TEXT, oldPwd ) )
       
   842 			{
       
   843 			TInt index(iContainer->ListBoxCurrentItemIndex());
       
   844 						CFileManagerItemProperties* prop = iEngine.GetItemInfoLC(index);
       
   845 						TUint32 drvState(0);
       
   846 						TInt error= iEngine.DriveState(drvState, prop->FullPath());
       
   847 						if ((error!=KErrNone)||(!(drvState & TFileManagerDriveInfo::EDrivePresent)))
       
   848 							{
       
   849 							isDone = ETrue;
       
   850 							isCanceled = ETrue;
       
   851 							FileManagerDlgUtils::ShowErrorNoteL(R_QTN_MEMC_NOT_AVAILABLE );
       
   852 							}
       
   853 						else
       
   854             {
       
   855             err = UpdatePassword( drive, oldPwd, oldPwd );
       
   856             if( err == KErrNone )
       
   857                 {
       
   858                 isDone = ETrue;
       
   859                 }
       
   860             else
       
   861                 {
       
   862                 FileManagerDlgUtils::ShowErrorNoteL(
       
   863                     R_QTN_PASSWORDS_WRONG_TEXT );
       
   864                 }
       
   865             }
       
   866 						CleanupStack::PopAndDestroy( prop );
       
   867 						}
       
   868         else
       
   869             {
       
   870             isDone = ETrue;
       
   871             isCanceled = ETrue;
       
   872             }
       
   873         }
       
   874 
       
   875     // Then query for the new password
       
   876     if( !isCanceled )
       
   877         {
       
   878         if( FileManagerDlgUtils::ShowPasswordQueryL( pwd ) )
       
   879             {
       
   880             err = UpdatePassword( drive, oldPwd, pwd );
       
   881             if( err == KErrNone )
       
   882                 {
       
   883                 FileManagerDlgUtils::ShowConfirmNoteL(
       
   884                     R_QTN_PASSWORD_CHANGED_TEXT );
       
   885                 }
       
   886             else
       
   887                 {
       
   888                 FileManagerDlgUtils::ShowErrorNoteL(
       
   889                     R_QTN_CRITICAL_ERROR );
       
   890                 }
       
   891             }
       
   892         }
       
   893     }
       
   894 
       
   895 // ------------------------------------------------------------------------------
       
   896 // CFileManagerMainView::CmdRemoveDrivePasswordL
       
   897 // ------------------------------------------------------------------------------
       
   898 //
       
   899 void CFileManagerMainView::CmdRemoveDrivePasswordL()
       
   900     {
       
   901     StoreIndex();
       
   902     TInt drive( DriveAtCurrentPosL() );
       
   903     if ( drive < 0 )
       
   904         {
       
   905         return; // No drive selected
       
   906         }
       
   907 
       
   908     if( !UnlockRemovePasswordL( drive, ETrue ) )
       
   909         {
       
   910         FileManagerDlgUtils::ShowConfirmNoteL( R_QTN_PASSWORD_REMOVED_TEXT );
       
   911         }
       
   912     }
       
   913 
       
   914 // ------------------------------------------------------------------------------
       
   915 // CFileManagerMainView::DriveAtCurrentPosL
       
   916 // ------------------------------------------------------------------------------
       
   917 //
       
   918 TInt CFileManagerMainView::DriveAtCurrentPosL()
       
   919     {
       
   920     TFileManagerDriveInfo dummy;
       
   921     return DriveInfoAtCurrentPosL( dummy );
       
   922     }
       
   923 
       
   924 //  End of File