filemanager/App/src/CFileManagerViewBase.cpp
changeset 0 6a9f87576119
child 1 d1daf54a55b5
equal deleted inserted replaced
-1:000000000000 0:6a9f87576119
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Base class for all file manager views
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <aknlists.h>
       
    22 #include <eikmenup.h> // CEikMenuPane
       
    23 #include <eikmenub.h> // CEikMenuBar
       
    24 #include <StringLoader.h>
       
    25 #include <AknCommonDialogs.h> // Common File Dialogs
       
    26 #include <CAknMemorySelectionDialog.h>
       
    27 #include <CAknFileSelectionDialog.h>
       
    28 #include <sendui.h>
       
    29 #include <sendnorm.rsg>
       
    30 #include <SenduiMtmUids.h>
       
    31 #include <AknProgressDialog.h>
       
    32 #include <eikprogi.h>
       
    33 #include <AknWaitNoteWrapper.h>
       
    34 #include <aknnotewrappers.h>
       
    35 #include <AknWaitDialog.h>
       
    36 #include <cmemstatepopup.h>
       
    37 #include <f32file.h>
       
    38 #include <aknmessagequerydialog.h>
       
    39 #include <CMessageData.h>
       
    40 #include <DRMHelper.h>
       
    41 #include <bautils.h>
       
    42 #include <AknCommonDialogsDynMem.h>
       
    43 #include "CFileManagerViewBase.h"
       
    44 #include "CFileManagerContainerBase.h"
       
    45 #include "CFileManagerAppUi.h"
       
    46 #include "CFileManagerDocument.h"
       
    47 #include "CFileManagerFileSelectionFilter.h"
       
    48 #include "FileManager.hrh"
       
    49 #ifdef RD_FILE_MANAGER_BACKUP
       
    50  #include "CFileManagerSchBackupHandler.h"
       
    51  #include "CFileManagerBackupSettings.h"
       
    52  #include "CFileManagerTaskScheduler.h"
       
    53 #endif // RD_FILE_MANAGER_BACKUP
       
    54 #include <CFileManagerEngine.h>
       
    55 #include <CFileManagerUtils.h>
       
    56 #include <CFileManagerCommonDefinitions.h>
       
    57 #include <CFileManagerItemProperties.h>
       
    58 #include <CFileManagerActiveExecute.h>
       
    59 #include <Cfilemanageractivedelete.h>
       
    60 #include <FileManager.rsg>
       
    61 #include <FileManagerView.rsg>
       
    62 #include <FileManagerDebug.h>
       
    63 #include <FileManagerDlgUtils.h>
       
    64 #include <CFileManagerFeatureManager.h>
       
    65 #include <FileManagerPrivateCRKeys.h>
       
    66 #include <DataSyncInternalPSKeys.h>
       
    67 #include <connect/sbdefs.h>
       
    68 #include <e32property.h>
       
    69 #include <caf/caf.h>
       
    70 #include <drmagents.h>
       
    71 
       
    72 using namespace conn;
       
    73 
       
    74 // CONSTANTS
       
    75 const TUint KMessageSize = 1024;
       
    76 const TUint KMaxPercentage = 100;
       
    77 const TUint KProgressBarUpdateInterval = 1000000; // microseconds
       
    78 const TUint KDriveLetterSize = 1;
       
    79 const TUint KRefreshProgressStartDelay = 1000000; // microseconds
       
    80 const TInt KFmgrMSK = 3;
       
    81 const TInt KEstimateUpperLimit = 90; // User selectable continuation
       
    82 const TInt KEstimateLowerLimit = 10; // Backup will be interrupted
       
    83 const TUint32 KDefaultFolderMask = CFileManagerItemProperties::EFolder |
       
    84                                   CFileManagerItemProperties::EDefault;
       
    85 const TInt64 KMSecToMicroSecMultiplier = 1000000;
       
    86 const TInt64 KMinToMicroSecMultiplier = KMSecToMicroSecMultiplier * 60;
       
    87 const TInt64 KHourToMicroSecMultiplier = KMinToMicroSecMultiplier * 60;
       
    88 const TUint KProgressBarAsyncStartDelay = 1500000; // microseconds
       
    89 
       
    90 
       
    91 // ============================ LOCAL FUNCTIONS ================================
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // IsWmDrmFile
       
    95 // 
       
    96 // -----------------------------------------------------------------------------
       
    97 // 
       
    98 static TBool IsWmDrmFile( const TDesC& aFullPath )
       
    99     {
       
   100     TBool ret( EFalse );
       
   101     ContentAccess::CContent* content = NULL;
       
   102     TRAPD( err, content = ContentAccess::CContent::CContent::NewL(
       
   103         aFullPath, EContentShareReadWrite ) );
       
   104     if ( err != KErrNone )
       
   105         {
       
   106         TRAP( err, content = ContentAccess::CContent::CContent::NewL(
       
   107             aFullPath, EContentShareReadOnly ) );
       
   108         }
       
   109     if ( err == KErrNone )
       
   110         {
       
   111         TInt isProtected( 0 );
       
   112         err = content->GetAttribute( EIsProtected, isProtected );
       
   113         if ( err == KErrNone && isProtected )
       
   114             {
       
   115             TInt fileType( 0 );
       
   116             err = content->GetAttribute( DRM::EDrmFileType, fileType );
       
   117             ret = ( err == KErrNone && fileType == DRM::EDrmWMFile );
       
   118             }
       
   119         delete content;
       
   120         }
       
   121     return ret;
       
   122     }
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // Int64ToInt
       
   126 // 
       
   127 // -----------------------------------------------------------------------------
       
   128 // 
       
   129 static TInt Int64ToInt( const TInt64& aInt64 )
       
   130     {
       
   131     if ( aInt64 > KMaxTInt )
       
   132         {
       
   133         return KMaxTInt;
       
   134         }
       
   135     return I64INT( aInt64 );
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // EmptyPwd
       
   140 // 
       
   141 // -----------------------------------------------------------------------------
       
   142 // 
       
   143 //static void EmptyPwd( TDes& aPwd )
       
   144 //    {
       
   145 //    aPwd.FillZ( aPwd.MaxLength( ) );
       
   146 //    aPwd.Zero();
       
   147 //    }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // ConvertCharsToPwd
       
   151 // 
       
   152 // -----------------------------------------------------------------------------
       
   153 // 
       
   154 //static void ConvertCharsToPwd( const TDesC& aWord, TDes8& aConverted )
       
   155 //    {
       
   156 //    // Make sure the target password is empty ( can't use the function here )
       
   157 //    aConverted.FillZ( aConverted.MaxLength() );
       
   158 //    aConverted.Zero();
       
   159 //    TInt size( aWord.Size() );
       
   160 //    if ( size )
       
   161 //        {
       
   162 //        if ( size > aConverted.MaxLength() )
       
   163 //            {
       
   164 //            size = aConverted.MaxLength();
       
   165 //            }
       
   166 //        aConverted.Copy( (TUint8*)aWord.Ptr(), size );
       
   167 //        }
       
   168 //    }
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // IsSystemProcess
       
   172 // 
       
   173 // -----------------------------------------------------------------------------
       
   174 // 
       
   175 static TBool IsSystemProcess(
       
   176         MFileManagerProcessObserver::TFileManagerProcess aProcess )
       
   177     {
       
   178     switch ( aProcess )
       
   179         {
       
   180         case MFileManagerProcessObserver::EFormatProcess:
       
   181         case MFileManagerProcessObserver::EBackupProcess:
       
   182         case MFileManagerProcessObserver::ERestoreProcess:
       
   183         case MFileManagerProcessObserver::ESchBackupProcess:
       
   184             {
       
   185             return ETrue;
       
   186             }
       
   187         default:
       
   188             {
       
   189             break;
       
   190             }
       
   191         }
       
   192     return EFalse;
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // GetDeleteQueryPromptLC
       
   197 // Chooses correct string for the delete note
       
   198 // -----------------------------------------------------------------------------
       
   199 // 
       
   200 static HBufC* GetDeleteQueryPromptLC( CFileManagerItemProperties& aProp, TInt aCount )
       
   201     {
       
   202 
       
   203     HBufC* prompt = NULL;
       
   204     if ( aCount == 0 && aProp.ContainsAnyFilesOrFolders() )
       
   205         {
       
   206         prompt = StringLoader::LoadLC( R_QTN_FLDR_DEL_FULL_FLDRS_QUERY );
       
   207         }
       
   208     else if ( aCount <= 1 )
       
   209         {
       
   210         prompt = StringLoader::LoadLC( R_QTN_QUERY_COMMON_CONF_DELETE, aProp.NameAndExt() );
       
   211         }
       
   212     else // aCount > 1
       
   213         {
       
   214         prompt = StringLoader::LoadLC( R_QTN_FLDR_DEL_ITEMS_QUERY, aCount );
       
   215         }
       
   216 
       
   217     return prompt;
       
   218     }
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // MinIndex
       
   222 // 
       
   223 // -----------------------------------------------------------------------------
       
   224 // 
       
   225 static TInt MinIndex( CArrayFixFlat<TInt>& aIndexArray )
       
   226     {
       
   227     TInt count( aIndexArray.Count() );
       
   228     if ( !count )
       
   229         {
       
   230         return 0;
       
   231         }
       
   232     // Find min index
       
   233     TInt index( 0 );
       
   234     TInt i( 0 );
       
   235     TInt ret( aIndexArray.At( i ) );
       
   236     ++i;
       
   237     for( ; i < count; ++i )
       
   238         {
       
   239         index = aIndexArray.At( i );
       
   240         if ( index < ret )
       
   241             {
       
   242             ret = index;
       
   243             }
       
   244         }
       
   245     return ret;
       
   246     }
       
   247 
       
   248 // -----------------------------------------------------------------------------
       
   249 // SetCurrentYearMonthAndDay
       
   250 // 
       
   251 // -----------------------------------------------------------------------------
       
   252 // 
       
   253 static TTime SetCurrentYearMonthAndDay( const TTime& aTime )
       
   254     {    
       
   255     TTime timeNow;
       
   256     timeNow.HomeTime();
       
   257     TDateTime dateTimeNow( timeNow.DateTime() );
       
   258     TInt64 ret( timeNow.Int64() );
       
   259     // Replace hours, minutes and seconds using given ones.
       
   260     ret -= static_cast< TInt64 >( dateTimeNow.Hour() ) * KHourToMicroSecMultiplier;
       
   261     ret -= static_cast< TInt64 >( dateTimeNow.Minute() ) * KMinToMicroSecMultiplier;
       
   262     ret -= static_cast< TInt64 >( dateTimeNow.Second() ) * KMSecToMicroSecMultiplier;
       
   263     ret -= dateTimeNow.MicroSecond();
       
   264     TDateTime dateTime( aTime.DateTime() );
       
   265     ret += static_cast< TInt64 >( dateTime.Hour() ) * KHourToMicroSecMultiplier;
       
   266     ret += static_cast< TInt64 >( dateTime.Minute() ) * KMinToMicroSecMultiplier;
       
   267     ret += static_cast< TInt64 >( dateTime.Second() ) * KMSecToMicroSecMultiplier;
       
   268     return ret;
       
   269     }
       
   270 
       
   271 // ============================ MEMBER FUNCTIONS ===============================
       
   272 
       
   273 // -----------------------------------------------------------------------------
       
   274 // CFileManagerViewBase::CFileManagerViewBase
       
   275 // C++ default constructor can NOT contain any code, that
       
   276 // might leave.
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 CFileManagerViewBase::CFileManagerViewBase() :
       
   280     iEngine( static_cast< CFileManagerDocument* >( AppUi()->Document() )->Engine() )
       
   281     {
       
   282     }
       
   283 
       
   284 
       
   285 // -----------------------------------------------------------------------------
       
   286 // CFileManagerViewBase::~CFileManagerViewBase
       
   287 // Destructor
       
   288 // -----------------------------------------------------------------------------
       
   289 // 
       
   290 CFileManagerViewBase::~CFileManagerViewBase()
       
   291     {
       
   292     delete iWaitNoteWrapper;
       
   293     delete iActiveDelete;
       
   294     delete iPeriodic;
       
   295     delete iMarkedArray;
       
   296     delete iContainer;
       
   297     delete iActiveExec;
       
   298     delete iRefreshProgressDelayedStart;
       
   299     delete iEjectQueryDialog;
       
   300     }
       
   301 
       
   302 // -----------------------------------------------------------------------------
       
   303 // CFileManagerViewBase::GetSendFilesLC
       
   304 // 
       
   305 // -----------------------------------------------------------------------------
       
   306 // 
       
   307 CArrayFixFlat<TInt>* CFileManagerViewBase::GetSendFilesLC( TInt& aSize )
       
   308     {
       
   309     // Get index array and remove folders and play lists
       
   310     CArrayFixFlat< TInt >* ret = MarkedArrayLC();
       
   311     TInt i( ret->Count() );
       
   312     while ( i > 0 )
       
   313         {
       
   314         --i;
       
   315         // IconIdL() is slow if the icon is not cached yet.
       
   316         // However, it is faster than FileTypeL().
       
   317         switch ( iEngine.IconIdL( ret->At( i ) ) )
       
   318             {
       
   319             case EFileManagerFolderIcon: // FALLTHROUGH
       
   320             case EFileManagerFolderSubIcon: // FALLTHROUGH
       
   321             case EFileManagerFolderEmptyIcon: // FALLTHROUGH
       
   322             case EFileManagerPlaylistFileIcon:
       
   323                 {
       
   324                 ret->Delete( i );
       
   325                 break;
       
   326                 }
       
   327             default:
       
   328                 {
       
   329                 break;
       
   330                 }
       
   331             }
       
   332         }
       
   333     aSize = Int64ToInt( iEngine.GetFileSizesL( *ret ) );
       
   334     return ret;
       
   335     }
       
   336 
       
   337 // -----------------------------------------------------------------------------
       
   338 // CFileManagerViewBase::ConstructL
       
   339 // 
       
   340 // -----------------------------------------------------------------------------
       
   341 // 
       
   342 void CFileManagerViewBase::ConstructL( TInt aResId )
       
   343     {
       
   344     BaseConstructL( aResId );
       
   345     }
       
   346 
       
   347 // -----------------------------------------------------------------------------
       
   348 // CFileManagerViewBase::HandleCommandL
       
   349 // 
       
   350 // -----------------------------------------------------------------------------
       
   351 //
       
   352 void CFileManagerViewBase::HandleCommandL( TInt aCommand )
       
   353     {
       
   354     if ( !iContainer ) return;
       
   355 
       
   356     TBool updateCba( !iContainer->SelectionModeEnabled() );
       
   357 
       
   358     switch( aCommand )
       
   359         {
       
   360         case EFileManagerOpen:
       
   361             {
       
   362             CmdOpenL();
       
   363             break;
       
   364             }
       
   365         case EFileManagerDelete:
       
   366             {
       
   367             CmdDeleteL();
       
   368             break;
       
   369             }
       
   370         case EFileManagerMoveToFolder:
       
   371             {
       
   372             CmdMoveToFolderL();
       
   373             break;
       
   374             }
       
   375         case EFileManagerCopyToFolder:
       
   376             {
       
   377             CmdCopyToFolderL();
       
   378             break;
       
   379             }
       
   380         case EFileManagerNewFolder:
       
   381             {
       
   382             CmdNewFolderL();
       
   383             break;
       
   384             }
       
   385         case EFileManagerMarkOne:   // FALLTHROUGH
       
   386         case EFileManagerUnmarkOne: // FALLTHROUGH
       
   387         case EFileManagerToggleMark:
       
   388             {
       
   389             CmdToggleMarkL();
       
   390             break;
       
   391             }
       
   392         case EFileManagerMarkAll:
       
   393             {
       
   394             CmdMarkAllL();
       
   395             break;
       
   396             }
       
   397         case EFileManagerUnmarkAll:
       
   398             {
       
   399             CmdUnmarkAllL();
       
   400             break;
       
   401             }
       
   402         case EFileManagerRename:
       
   403             {
       
   404             CmdRenameL();
       
   405             break;
       
   406             }
       
   407         case EFileManagerFindFile:
       
   408             {
       
   409             CmdFindL();
       
   410             break;
       
   411             }
       
   412         case EFileManagerFileDetails: // FALLTHROUGH
       
   413         case EFileManagerFolderDetails: // FALLTHROUGH
       
   414         case EFileManagerViewInfo:
       
   415             {
       
   416             CmdViewInfoL();
       
   417             break;
       
   418             }
       
   419 //        case EFileManagerMemoryState:
       
   420 //            {
       
   421 //            CmdMemoryStateL();
       
   422 //            break;
       
   423 //            }
       
   424         case EFileManagerReceiveViaIR:
       
   425             {
       
   426             CmdReceiveViaIRL();
       
   427             break;
       
   428             }
       
   429         case EFileManagerCheckMark: // Suppress
       
   430             {
       
   431             break;
       
   432             }
       
   433         case EAknSoftkeyContextOptions: // FALLTHROUGH
       
   434         case EFileManagerSelectionKey:
       
   435             {
       
   436             TInt count( iContainer->ListBoxSelectionIndexesCount() );
       
   437             if ( !count )
       
   438                 {
       
   439                 HandleCommandL( EFileManagerOpen );
       
   440                 }
       
   441             else if ( count > 0 )
       
   442                 {
       
   443                 ShowContextSensitiveMenuL();
       
   444                 }
       
   445             break;
       
   446             }
       
   447         case EFileManagerSend:
       
   448             {
       
   449             if ( !iSendUiPopupOpened )
       
   450             {
       
   451                 SendUiQueryL();
       
   452             }
       
   453             break;
       
   454             }
       
   455         case EFileManagerMoreInfoOnline:
       
   456             {
       
   457             OpenInfoUrlL( iContainer->ListBoxCurrentItemIndex() );
       
   458             break;
       
   459             }
       
   460         case EFileManagerUnlockMemoryCard:
       
   461             {
       
   462             CmdUnlockDriveL();
       
   463             break;
       
   464             }
       
   465 //        case EFileManagerMemoryCardName:
       
   466 //        case EFileManagerMemoryCardRename: // Fall through
       
   467 //            {
       
   468 //            CmdRenameDriveL();
       
   469 //            break;
       
   470 //            }
       
   471         //case EFileManagerMemoryCardFormat:
       
   472         case EFileManagerMemoryStorageFormat:
       
   473         case EFileManagerFormatMassStorage: // Fall through
       
   474             {
       
   475             CmdFormatDriveL();
       
   476             break;
       
   477             }
       
   478 //        case EFileManagerMemoryCardPasswordSet:
       
   479 //            {
       
   480 //            CmdSetDrivePasswordL();
       
   481 //            break;
       
   482 //            }
       
   483 //        case EFileManagerMemoryCardPasswordChange:
       
   484 //            {
       
   485 //            CmdChangeDrivePasswordL();
       
   486 //            break;
       
   487 //            }
       
   488 //        case EFileManagerMemoryCardPasswordRemove:
       
   489 //            {
       
   490 //            CmdRemoveDrivePasswordL();
       
   491 //            break;
       
   492 //            }
       
   493 //        case EFileManagerMemoryCardDetails:
       
   494 //            {
       
   495 //            CmdMemoryCardDetailsL();
       
   496 //            break;
       
   497 //            }
       
   498         case EFileManagerConnectRemoveDrive:
       
   499             {
       
   500             SetRemoteDriveConnectionStateL( ETrue );
       
   501             break;
       
   502             }
       
   503         case EFileManagerDisconnectRemoveDrive:
       
   504             {
       
   505             SetRemoteDriveConnectionStateL( EFalse );
       
   506             break;
       
   507             }
       
   508         case EFileManagerRefreshRemoteDrive:
       
   509             {
       
   510             CmdRefreshDirectoryL();
       
   511             break;
       
   512             }
       
   513 	    case EFileManagerSortByName:
       
   514 	    case EFileManagerSortByType: // Fall through
       
   515 	    case EFileManagerSortMostRecentFirst: // Fall through
       
   516 	    case EFileManagerSortLargestFirst: // Fall through
       
   517 	    case EFileManagerSortByMatch: // Fall through
       
   518             {
       
   519             CmdSortL( aCommand );
       
   520             break;
       
   521             }
       
   522         default:
       
   523             {
       
   524             AppUi()->HandleCommandL( aCommand );
       
   525             break;
       
   526             }
       
   527         }
       
   528 
       
   529     if ( updateCba )
       
   530         {
       
   531         UpdateCbaL();
       
   532         }
       
   533     }
       
   534 
       
   535 // -----------------------------------------------------------------------------
       
   536 // CFileManagerViewBase::SendUiQueryL
       
   537 // 
       
   538 // -----------------------------------------------------------------------------
       
   539 // 
       
   540 void CFileManagerViewBase::SendUiQueryL()
       
   541     {
       
   542     //iSendUiPopupOpened = ETrue;	
       
   543     	
       
   544     CSendUi& sendUi( static_cast< CFileManagerAppUi* >( AppUi() )->SendUiL() );
       
   545     CMessageData* msgData = CMessageData::NewL();
       
   546     CleanupStack::PushL( msgData );
       
   547     TInt msgSize( KMessageSize );
       
   548     CArrayFixFlat< TInt >* files = GetSendFilesLC( msgSize );
       
   549     TInt count( files->Count() );
       
   550     if ( count )
       
   551         {
       
   552         // Set dimmed services specified for FileManager by Send UI spec
       
   553         const TInt KDimmedServices = 4;
       
   554         CArrayFixFlat< TUid >* servicesToDim =
       
   555             new ( ELeave ) CArrayFixFlat< TUid >( KDimmedServices );
       
   556         CleanupStack::PushL( servicesToDim );
       
   557 
       
   558         servicesToDim->AppendL( KSenduiMtmAudioMessageUid );
       
   559         servicesToDim->AppendL( KMmsDirectUpload );
       
   560         servicesToDim->AppendL( KMmsIndirectUpload );
       
   561         servicesToDim->AppendL( KSenduiMtmPostcardUid );
       
   562 
       
   563         TSendingCapabilities caps(
       
   564             0, msgSize, TSendingCapabilities::ESupportsAttachments );
       
   565         for( TInt i( 0 ); i < count ; i++ )
       
   566             {
       
   567             HBufC* fullPath = iEngine.IndexToFullPathLC( files->At( i ) );
       
   568             msgData->AppendAttachmentL( *fullPath );
       
   569             CleanupStack::PopAndDestroy( fullPath );
       
   570             }
       
   571         // Let SendUi handle protected files, queries and filtering
       
   572         sendUi.ShowQueryAndSendL( msgData, caps, servicesToDim );
       
   573         CleanupStack::PopAndDestroy( servicesToDim );
       
   574         }
       
   575     CleanupStack::PopAndDestroy( files );
       
   576     CleanupStack::PopAndDestroy( msgData );
       
   577     
       
   578     iSendUiPopupOpened = EFalse;
       
   579     }
       
   580 
       
   581 // -----------------------------------------------------------------------------
       
   582 // CFileManagerViewBase::MarkMenuFilteringL
       
   583 // 
       
   584 // -----------------------------------------------------------------------------
       
   585 // 
       
   586 void CFileManagerViewBase::MarkMenuFilteringL( CEikMenuPane& aMenuPane )
       
   587     {
       
   588     TInt index( iContainer->ListBoxCurrentItemIndex() );
       
   589     if ( iContainer->ListBoxIsItemSelected( index ) )
       
   590         {
       
   591         aMenuPane.SetItemDimmed( EFileManagerMarkOne, ETrue );
       
   592         }
       
   593     else
       
   594         {
       
   595         aMenuPane.SetItemDimmed( EFileManagerUnmarkOne, ETrue );
       
   596         }
       
   597 
       
   598     if ( iEngine.IsFolder( index ) )
       
   599         {
       
   600         aMenuPane.SetItemDimmed( EFileManagerMarkOne, ETrue );
       
   601         aMenuPane.SetItemDimmed( EFileManagerUnmarkOne, ETrue );
       
   602         aMenuPane.SetItemDimmed( EFileManagerMarkAll, ETrue );
       
   603         }
       
   604 
       
   605     TInt files( iEngine.FilesInFolderL() );
       
   606     TInt count( iContainer->ListBoxSelectionIndexesCount() );
       
   607     if ( count == files )
       
   608         {
       
   609         aMenuPane.SetItemDimmed( EFileManagerMarkAll, ETrue );
       
   610         }
       
   611 
       
   612     if ( !count )
       
   613         {
       
   614         aMenuPane.SetItemDimmed( EFileManagerUnmarkAll, ETrue );
       
   615         }
       
   616 
       
   617     }
       
   618 
       
   619 // -----------------------------------------------------------------------------
       
   620 // CFileManagerViewBase::CmdOpenL
       
   621 // 
       
   622 // -----------------------------------------------------------------------------
       
   623 // 
       
   624 CFileManagerViewBase::TFileManagerOpenResult CFileManagerViewBase::CmdOpenL()
       
   625     {
       
   626     if ( !iContainer || iActiveProcess != ENoProcess )
       
   627         {
       
   628         return EOpenError; // Ignore to avoid mess up
       
   629         }
       
   630     TInt index( iContainer->ListBoxCurrentItemIndex() );
       
   631     TInt err( KErrNone );
       
   632 
       
   633     if ( index < 0 )
       
   634         {
       
   635         return EOpenError;
       
   636         }
       
   637     CFileManagerAppUi* appUi = 
       
   638         static_cast< CFileManagerAppUi* >( AppUi() );
       
   639     TBool isFolder( iEngine.IsFolder( index ) );
       
   640     StoreIndex();
       
   641     TRAP( err, iEngine.OpenL( index ) );
       
   642     if ( err == KErrNone )
       
   643         {
       
   644         if ( isFolder )
       
   645             {
       
   646             if ( !appUi->ActivateFoldersViewL() )
       
   647                 {
       
   648                 // Folders view is already open
       
   649                 // Refresh if this view is folders view
       
   650                 if ( Id() == CFileManagerAppUi::KFileManagerFoldersViewId )
       
   651                     {
       
   652                     iEngine.SetObserver( this );
       
   653                     iEngine.RefreshDirectory();
       
   654                     }
       
   655                 }
       
   656             return EFolderOpened;
       
   657             }
       
   658         return EFileOpened;
       
   659         }
       
   660     if ( !HandleFileNotFoundL( err ) )
       
   661         {
       
   662         if ( !isFolder )
       
   663             {
       
   664             FileManagerDlgUtils::ShowErrorNoteL(
       
   665                 R_QTN_FMGR_ERROR_CANT_OPEN );
       
   666             }
       
   667         }
       
   668     return EOpenError;
       
   669     }
       
   670 
       
   671 // ----------------------------------------------------------------------------
       
   672 // CFileManagerViewBase::CmdDeleteL
       
   673 // 
       
   674 // ----------------------------------------------------------------------------
       
   675 // 
       
   676 void CFileManagerViewBase::CmdDeleteL()
       
   677     {
       
   678 
       
   679     if ( !iContainer->ListBoxNumberOfItems() )
       
   680         {
       
   681         // List box is empty, nothing to delete
       
   682         return;
       
   683         }
       
   684 
       
   685     const TInt selectionCount(iContainer->ListBoxSelectionIndexesCount() );
       
   686     TInt index( iContainer->ListBoxCurrentItemIndex() );
       
   687 
       
   688     if ( selectionCount == 1 )
       
   689         {
       
   690         // One item marked
       
   691         const CArrayFix< TInt >* items = iContainer->ListBoxSelectionIndexes();
       
   692         index = items->At( 0 );
       
   693         }
       
   694 
       
   695     CFileManagerItemProperties* prop = iEngine.GetItemInfoL( index );
       
   696     CleanupStack::PushL( prop );
       
   697 
       
   698     if ( DeleteStatusNotOkL( *prop, selectionCount ) ) 
       
   699         {
       
   700         // It is not possible to continue delete operation
       
   701         CleanupStack::PopAndDestroy( prop );
       
   702         return;
       
   703         }
       
   704 
       
   705     HBufC* prompt = GetDeleteQueryPromptLC( *prop, selectionCount );
       
   706 
       
   707     TBool ret( EFalse );
       
   708     DenyDirectoryRefresh( ETrue );
       
   709     TRAPD( err, ret = FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( *prompt ) );
       
   710     DenyDirectoryRefresh( EFalse );
       
   711     User::LeaveIfError( err );
       
   712     if ( ret )
       
   713         {
       
   714         DeleteItemsL( index );
       
   715         }
       
   716     else
       
   717         {
       
   718         CheckPostponedDirectoryRefresh();
       
   719         }
       
   720     CleanupStack::PopAndDestroy( prompt );
       
   721     CleanupStack::PopAndDestroy( prop );
       
   722 
       
   723     }
       
   724 
       
   725 // -----------------------------------------------------------------------------
       
   726 // CFileManagerViewBase::CmdMoveToFolderL
       
   727 // 
       
   728 // -----------------------------------------------------------------------------
       
   729 // 
       
   730 void CFileManagerViewBase::CmdMoveToFolderL()
       
   731     {
       
   732 
       
   733     if ( DriveReadOnlyMmcL( iEngine.CurrentDirectory() ) )
       
   734         {
       
   735         return;
       
   736         }
       
   737 
       
   738     // double KMaxFileName is needed if both source and target are KMaxFileName
       
   739     HBufC* fileName = HBufC::NewLC( KFmgrDoubleMaxFileName );
       
   740     TPtr ptrFileName = fileName->Des();
       
   741     CFileManagerFileSelectionFilter* filter =
       
   742         new( ELeave ) CFileManagerFileSelectionFilter( iEngine );
       
   743     CleanupStack::PushL( filter );
       
   744 
       
   745     TInt memType(
       
   746         AknCommonDialogsDynMem::EMemoryTypePhone |
       
   747         AknCommonDialogsDynMem::EMemoryTypeMMC );
       
   748 
       
   749     if ( FeatureManager().IsRemoteStorageFwSupported() )
       
   750         {
       
   751         memType |= AknCommonDialogsDynMem::EMemoryTypeRemote;
       
   752         }
       
   753 
       
   754     DenyDirectoryRefresh( ETrue );
       
   755     TBool ret( AknCommonDialogsDynMem::RunMoveDlgLD( 
       
   756         memType,
       
   757         ptrFileName,
       
   758         R_FILEMANAGER_MOVE_MEMORY_SELECTIONDIALOG,
       
   759         filter ) );
       
   760     DenyDirectoryRefresh( EFalse );
       
   761     CleanupStack::PopAndDestroy( filter );
       
   762 
       
   763     if ( ret && ptrFileName.Length() )
       
   764         {
       
   765         if ( !DriveReadOnlyMmcL( ptrFileName ) )
       
   766             {
       
   767             RunOperationL( 
       
   768                 MFileManagerProcessObserver::EMoveProcess, ptrFileName );
       
   769             }
       
   770         }
       
   771     if (!ret )
       
   772         {
       
   773         CheckPostponedDirectoryRefresh();
       
   774         }
       
   775 
       
   776     CleanupStack::PopAndDestroy( fileName );
       
   777     }
       
   778 
       
   779 // -----------------------------------------------------------------------------
       
   780 // CFileManagerViewBase::CmdCopyToFolderL
       
   781 // 
       
   782 // -----------------------------------------------------------------------------
       
   783 // 
       
   784 void CFileManagerViewBase::CmdCopyToFolderL()
       
   785     {
       
   786     // double KMaxFileName is needed if both source and target are KMaxFileName
       
   787     HBufC* fileName = HBufC::NewLC( KFmgrDoubleMaxFileName );
       
   788     TPtr ptrFileName = fileName->Des();
       
   789     CFileManagerFileSelectionFilter* filter =
       
   790         new( ELeave ) CFileManagerFileSelectionFilter( iEngine );
       
   791     CleanupStack::PushL( filter );
       
   792 
       
   793     TInt memType(
       
   794         AknCommonDialogsDynMem::EMemoryTypePhone |
       
   795         AknCommonDialogsDynMem::EMemoryTypeMMC );
       
   796 
       
   797     if ( FeatureManager().IsRemoteStorageFwSupported() )
       
   798         {
       
   799         memType |= AknCommonDialogsDynMem::EMemoryTypeRemote;
       
   800         }
       
   801 
       
   802     DenyDirectoryRefresh( ETrue );
       
   803     TBool ret( AknCommonDialogsDynMem::RunCopyDlgLD( 
       
   804         memType,
       
   805         ptrFileName,
       
   806         R_FILEMANAGER_COPY_MEMORY_SELECTIONDIALOG,
       
   807         filter ) );
       
   808     DenyDirectoryRefresh( EFalse );
       
   809     CleanupStack::PopAndDestroy( filter );
       
   810 
       
   811     if ( ret && ptrFileName.Length() )
       
   812         {
       
   813         if ( !DriveReadOnlyMmcL( ptrFileName ) )
       
   814             {
       
   815             RunOperationL(
       
   816                 MFileManagerProcessObserver::ECopyProcess, ptrFileName );
       
   817             }
       
   818         }
       
   819     if (!ret )
       
   820         {
       
   821         CheckPostponedDirectoryRefresh();
       
   822         }
       
   823     CleanupStack::PopAndDestroy( fileName );
       
   824     }
       
   825 
       
   826 // -----------------------------------------------------------------------------
       
   827 // CFileManagerViewBase::CmdNewFolderL
       
   828 // 
       
   829 // -----------------------------------------------------------------------------
       
   830 // 
       
   831 void CFileManagerViewBase::CmdNewFolderL()
       
   832     {
       
   833 
       
   834     if ( DriveReadOnlyMmcL( iEngine.CurrentDirectory() ) )
       
   835         {
       
   836         return;
       
   837         }
       
   838 
       
   839     StoreIndex();
       
   840 
       
   841     if ( !iEngine.EnoughSpaceL(
       
   842             iEngine.CurrentDirectory(),
       
   843             0, 
       
   844             MFileManagerProcessObserver::ENoProcess ) )
       
   845         {
       
   846         User::Leave( KErrDiskFull );
       
   847         }
       
   848     HBufC* folderNameBuf = HBufC::NewLC( KMaxFileName );
       
   849     TPtr folderName( folderNameBuf->Des() );
       
   850 
       
   851     if ( FileManagerDlgUtils::ShowFolderNameQueryL(
       
   852          R_QTN_FLDR_NAME_PRMPT, folderName, iEngine, ETrue ) )
       
   853         {
       
   854         TBuf<KMaxPath> fullFolderName( iEngine.CurrentDirectory() );
       
   855         fullFolderName.Append( folderName );
       
   856         CFileManagerUtils::EnsureFinalBackslash( fullFolderName );
       
   857         
       
   858         if ( iEngine.IsSystemFolder( fullFolderName ) )
       
   859             {
       
   860             FileManagerDlgUtils::ShowInfoNoteL( R_QTN_FLDR_NAME_ALREADY_USED, folderName );
       
   861             }
       
   862         else
       
   863             {
       
   864         iEngine.NewFolderL( folderName );
       
   865             }
       
   866         iEngine.SetObserver( this );
       
   867         iEngine.RefreshDirectory();
       
   868         }
       
   869     else
       
   870         {
       
   871         if ( iContainer && iContainer->IsSearchFieldVisible() )
       
   872             {
       
   873             iContainer->DrawDeferred();
       
   874             }
       
   875         }
       
   876     CleanupStack::PopAndDestroy( folderNameBuf );
       
   877     }
       
   878 
       
   879 // -----------------------------------------------------------------------------
       
   880 // CFileManagerViewBase::CmdToggleMarkL
       
   881 // 
       
   882 // -----------------------------------------------------------------------------
       
   883 // 
       
   884 void CFileManagerViewBase::CmdToggleMarkL()
       
   885     {
       
   886     const TInt index( iContainer->ListBoxCurrentItemIndex() );
       
   887     if ( iEngine.IsFolder( index ) )
       
   888         {
       
   889         iContainer->ListBoxDeselectItem( index );
       
   890         }
       
   891     else
       
   892         {
       
   893         iContainer->ListBoxToggleItemL( index );
       
   894         }
       
   895     }
       
   896 
       
   897 // -----------------------------------------------------------------------------
       
   898 // CFileManagerViewBase::CmdMarkAllL
       
   899 // 
       
   900 // -----------------------------------------------------------------------------
       
   901 // 
       
   902 void CFileManagerViewBase::CmdMarkAllL()
       
   903     {
       
   904     iContainer->ListBoxSelectAllL();
       
   905     }
       
   906 
       
   907 // -----------------------------------------------------------------------------
       
   908 // CFileManagerViewBase::CmdUnmarkAllL
       
   909 // 
       
   910 // -----------------------------------------------------------------------------
       
   911 // 
       
   912 void CFileManagerViewBase::CmdUnmarkAllL()
       
   913     {
       
   914     iContainer->ListBoxClearSelection();
       
   915     }
       
   916 
       
   917 // -----------------------------------------------------------------------------
       
   918 // CFileManagerViewBase::CmdRenameL
       
   919 // 
       
   920 // -----------------------------------------------------------------------------
       
   921 // 
       
   922 void CFileManagerViewBase::CmdRenameL()
       
   923     {
       
   924     TInt index( iContainer->ListBoxCurrentItemIndex() );
       
   925     if ( index >= 0 )
       
   926         {
       
   927         StoreIndex();
       
   928         CFileManagerItemProperties* prop = 
       
   929             iEngine.GetItemInfoL( index );
       
   930         CleanupStack::PushL( prop );
       
   931 
       
   932         if ( DriveReadOnlyMmcL( prop->FullPath() ) )
       
   933             {
       
   934             CleanupStack::PopAndDestroy( prop );
       
   935             return;
       
   936             }
       
   937 
       
   938         HBufC* itemNameBuf = HBufC::NewLC( KMaxFileName );
       
   939         TPtr itemName( itemNameBuf->Des() );
       
   940         itemName.Append( prop->NameAndExt() );
       
   941 
       
   942         TInt err( KErrNone );
       
   943         TBool ret( EFalse );
       
   944         if ( prop->TypeL() & CFileManagerItemProperties::EFolder )
       
   945             {
       
   946             DenyDirectoryRefresh( ETrue );
       
   947             TRAP( err, ret = FileManagerDlgUtils::ShowFolderNameQueryL(
       
   948                 R_QTN_FLDR_ITEM_NAME_PRMPT, itemName, iEngine  ) );
       
   949             DenyDirectoryRefresh( EFalse );
       
   950             User::LeaveIfError( err );
       
   951             if ( ret )
       
   952                 {
       
   953                 if ( itemName.Length() > 1 )
       
   954                 	{
       
   955                 	if ( itemName[0] == '.' )
       
   956                 		{
       
   957                 		TInt j = 1;
       
   958                 		for ( j; j < itemName.Length(); j++ )
       
   959                 			{
       
   960                 			if ( !( (itemName[j] <= 'Z') && (itemName[j] >= 'A') ) )
       
   961                 				{
       
   962                 				break;
       
   963                 				}
       
   964                 			}
       
   965                 		if ( j == itemName.Length() )
       
   966                 			{
       
   967                 			itemName.Delete(0, 1);
       
   968                 			}
       
   969                 		}
       
   970                 	}
       
   971                 TRAP( err, iEngine.RenameL( index, itemName ) );
       
   972                 if ( err == KErrAccessDenied || 
       
   973                     err == KErrInUse || 
       
   974                     err == KErrBadName || 
       
   975                     err == KErrAlreadyExists ||
       
   976                     err == KErrNotReady )
       
   977                     {
       
   978                     err = KErrNone; // Set error as handled
       
   979                     FileManagerDlgUtils::ShowInfoNoteL(
       
   980                         R_QTN_FLDR_CANT_RENAME_ITEM,
       
   981                         prop->NameAndExt() );
       
   982                     }
       
   983                 }
       
   984             }
       
   985         else 
       
   986             {
       
   987             DenyDirectoryRefresh( ETrue );
       
   988             TRAP( err, ret = FileManagerDlgUtils::ShowFileNameQueryL(
       
   989                 R_QTN_FLDR_ITEM_NAME_PRMPT, prop->FullPath(), itemName, iEngine ) );
       
   990             DenyDirectoryRefresh( EFalse );
       
   991             User::LeaveIfError( err );
       
   992             if ( ret )
       
   993                 {
       
   994                 TRAP( err, iEngine.RenameL( index, itemName ) );
       
   995                 if ( err == KErrAccessDenied || 
       
   996                     err == KErrInUse || 
       
   997                     err == KErrBadName || 
       
   998                     err == KErrAlreadyExists ||
       
   999                     err == KErrNotReady )
       
  1000                     {
       
  1001                     err = KErrNone; // Set error as handled
       
  1002                     FileManagerDlgUtils::ShowInfoNoteL(
       
  1003                         R_QTN_FLDR_CANT_RENAME_ITEM,
       
  1004                         prop->NameAndExt() );
       
  1005                     }
       
  1006                 }
       
  1007             }
       
  1008 
       
  1009         CleanupStack::PopAndDestroy( itemNameBuf );
       
  1010         CleanupStack::PopAndDestroy( prop );
       
  1011         User::LeaveIfError( err );
       
  1012         }
       
  1013     iEngine.SetObserver( this );
       
  1014     iEngine.RefreshDirectory();
       
  1015     }
       
  1016 
       
  1017 // -----------------------------------------------------------------------------
       
  1018 // CFileManagerViewBase::CmdFindL
       
  1019 // 
       
  1020 // -----------------------------------------------------------------------------
       
  1021 // 
       
  1022 void CFileManagerViewBase::CmdFindL()
       
  1023     {
       
  1024     HBufC* path = HBufC::NewLC( KMaxFileName );
       
  1025     TPtr ptrPath( path->Des() );
       
  1026     if( AskPathL( ptrPath, R_QTN_FMGR_FIND_PRTX ) )
       
  1027         {
       
  1028         HBufC* searchStringBuf = HBufC::NewLC( KMaxFileName );
       
  1029         TPtr searchString( searchStringBuf->Des() );
       
  1030         HBufC* prompt = StringLoader::LoadLC( R_QTN_FMGR_FIND_DATAQ_PRTX );
       
  1031         CAknTextQueryDialog *textQuery = 
       
  1032             new( ELeave ) CAknTextQueryDialog( searchString, *prompt );
       
  1033         if ( textQuery->ExecuteLD( R_FILEMANAGER_SEARCH_QUERY ) )
       
  1034             {
       
  1035             iEngine.SetSearchStringL( searchString );
       
  1036             iEngine.SetSearchFolderL( ptrPath );
       
  1037             if ( Id() == CFileManagerAppUi::KFileManagerSearchResultsViewId )
       
  1038                 {
       
  1039                 // Start new search in the existing view
       
  1040                 iIndex = 0;
       
  1041                 iEngine.SetObserver( this );
       
  1042                 iEngine.RefreshDirectory();
       
  1043                 }
       
  1044             else
       
  1045                 {
       
  1046                 // Open search view and start new search
       
  1047                 StoreIndex();
       
  1048                 // Ensure that current directory is set correctly.
       
  1049                 // If current view was opened from previous search results view,
       
  1050                 // backstep stack to current directory may be incomplete.
       
  1051                 iEngine.SetDirectoryWithBackstepsL( iEngine.CurrentDirectory() );
       
  1052                 CFileManagerAppUi* appUi = 
       
  1053                     static_cast< CFileManagerAppUi* >( AppUi() );
       
  1054                 appUi->ActivateSearchResultsViewL();
       
  1055                 }
       
  1056             }
       
  1057         CleanupStack::PopAndDestroy( prompt );
       
  1058         CleanupStack::PopAndDestroy( searchStringBuf );
       
  1059         }
       
  1060     CleanupStack::PopAndDestroy( path );
       
  1061     }
       
  1062 
       
  1063 // -----------------------------------------------------------------------------
       
  1064 // CFileManagerViewBase::CmdViewInfoL
       
  1065 // 
       
  1066 // -----------------------------------------------------------------------------
       
  1067 // 
       
  1068 void CFileManagerViewBase::CmdViewInfoL()
       
  1069     {
       
  1070     TInt index( iContainer->ListBoxCurrentItemIndex() );
       
  1071     if ( index >= 0 )
       
  1072         {
       
  1073         CFileManagerItemProperties* prop = iEngine.GetItemInfoL( index );
       
  1074         CleanupStack::PushL( prop );
       
  1075         FileManagerDlgUtils::ShowItemInfoPopupL( *prop, FeatureManager() );
       
  1076         CleanupStack::PopAndDestroy( prop );
       
  1077         }
       
  1078     }
       
  1079 
       
  1080 // -----------------------------------------------------------------------------
       
  1081 // CFileManagerViewBase::CmdMemoryStateL
       
  1082 // 
       
  1083 // -----------------------------------------------------------------------------
       
  1084 // 
       
  1085 //void CFileManagerViewBase::CmdMemoryStateL()
       
  1086 //    {
       
  1087 //    TInt drv( iEngine.CurrentDrive() );
       
  1088 //    if ( drv != KErrNotFound )
       
  1089 //        {
       
  1090 //        HBufC* title = StringLoader::LoadLC( R_QTN_FMGR_MSTATE_HEADING );
       
  1091 //        CMemStatePopup::RunLD(
       
  1092 //            static_cast< TDriveNumber >( drv ), *title );
       
  1093 //        CleanupStack::PopAndDestroy( title );
       
  1094 //        }
       
  1095 //    }
       
  1096 
       
  1097 // -----------------------------------------------------------------------------
       
  1098 // CFileManagerViewBase::CmdReceiveViaIR
       
  1099 // 
       
  1100 // -----------------------------------------------------------------------------
       
  1101 // 
       
  1102 void CFileManagerViewBase::CmdReceiveViaIRL()
       
  1103     {
       
  1104 
       
  1105     if ( DriveReadOnlyMmcL( iEngine.CurrentDirectory() ) )
       
  1106         {
       
  1107         return;
       
  1108         }
       
  1109 
       
  1110     iEngine.SetObserver( this );
       
  1111 
       
  1112     ClearProgressBarL();
       
  1113 
       
  1114     iProgressDialog = new( ELeave ) CAknProgressDialog( 
       
  1115         reinterpret_cast< CEikDialog** >( &iProgressDialog ), ETrue );
       
  1116     iProgressDialog->PrepareLC( R_FILE_RECEIVE_DIALOG );
       
  1117     iProgressInfo = iProgressDialog->GetProgressInfoL();
       
  1118     if ( iProgressInfo )
       
  1119         {
       
  1120         // final value is 100 percent
       
  1121         iProgressInfo->SetFinalValue( KMaxPercentage ); 
       
  1122         }
       
  1123     iProgressDialog->RunLD();
       
  1124     iProgressDialog->SetCallback( this );
       
  1125 
       
  1126     HBufC* label = StringLoader::LoadLC( R_QTN_IR_CONNECTING );
       
  1127     iProgressDialog->SetTextL( *label );
       
  1128     CleanupStack::PopAndDestroy( label );
       
  1129 
       
  1130     CFileManagerAppUi* appUi = static_cast< CFileManagerAppUi* >( AppUi() );
       
  1131     TRAPD( err, appUi->StartIRReceiveL( *this ) );
       
  1132 
       
  1133     if ( err == KErrNone )
       
  1134         {
       
  1135         iActiveProcess = MFileManagerProcessObserver::EIRReceiveProcess;
       
  1136         }
       
  1137     else
       
  1138         {
       
  1139         ClearProgressBarL();
       
  1140         User::Leave( err );
       
  1141         }
       
  1142     }
       
  1143 
       
  1144 
       
  1145 // -----------------------------------------------------------------------------
       
  1146 // CFileManagerViewBase::DynInitMenuPaneL
       
  1147 // 
       
  1148 // -----------------------------------------------------------------------------
       
  1149 // 
       
  1150 void CFileManagerViewBase::DynInitMenuPaneL( TInt aResourceId, 
       
  1151                                              CEikMenuPane* aMenuPane)
       
  1152     {
       
  1153     TBool isHandled( ETrue );
       
  1154 
       
  1155     switch( aResourceId )
       
  1156         {
       
  1157         // These menus are used by memory store and folders views
       
  1158         case R_FILEMANAGER_MEMORY_STORE_VIEW_MENU:
       
  1159             {
       
  1160             MemoryStoreMenuFilteringL( *aMenuPane );
       
  1161             break;
       
  1162             }
       
  1163         case R_FILEMANAGER_MARK_UNMARK_MENU:
       
  1164         case R_FILEMANAGER_CONTEXT_SENSITIVE_MARK_UNMARK_MENU:
       
  1165             {
       
  1166             MarkMenuFilteringL( *aMenuPane );
       
  1167             break;
       
  1168             }
       
  1169         case R_FILEMANAGER_ORGANISE_MENU:
       
  1170             {
       
  1171             OrganiseMenuFilteringL( *aMenuPane );
       
  1172             break;
       
  1173             }
       
  1174         case R_FILEMANAGER_DETAILS_MENU:
       
  1175             {
       
  1176             DetailsMenuFilteringL( *aMenuPane );
       
  1177             break;
       
  1178             }
       
  1179 //        case R_FILEMANAGER_MEMORY_CARD_MENU:
       
  1180 //            {
       
  1181 //            MemoryCardMenuFilteringL( *aMenuPane );
       
  1182 //            break;
       
  1183 //            }
       
  1184 //        case R_FILEMANAGER_MEMORY_CARD_PASSWORD_MENU:
       
  1185 //            {
       
  1186 //            MemoryCardPasswordMenuFilteringL( *aMenuPane );
       
  1187 //            break;
       
  1188 //            }
       
  1189         case R_FILEMANAGER_CONTEXT_SENSITIVE_MENU:
       
  1190             {
       
  1191             ContextSensitiveMenuFilteringL( *aMenuPane );
       
  1192             break;
       
  1193             }
       
  1194         case R_FILEMANAGER_SORT_MENU:
       
  1195         case R_FILEMANAGER_SEARCH_SORT_MENU: // Fall through
       
  1196             {
       
  1197             SortMenuFilteringL( *aMenuPane );
       
  1198             break;
       
  1199             }
       
  1200         default:
       
  1201             {
       
  1202             isHandled = EFalse;
       
  1203             break;
       
  1204             }
       
  1205         }
       
  1206 
       
  1207     TBool isContextMenu( aResourceId == R_FILEMANAGER_CONTEXT_SENSITIVE_MENU );
       
  1208     if ( isHandled || isContextMenu )
       
  1209         {
       
  1210         CEikMenuBar* menuBar = MenuBar();
       
  1211         if ( menuBar )
       
  1212             {
       
  1213             if ( isContextMenu )
       
  1214                 {
       
  1215                 menuBar->SetMenuType( CEikMenuBar::EMenuContext );
       
  1216                 }
       
  1217             else
       
  1218                 {
       
  1219                 menuBar->SetMenuType( CEikMenuBar::EMenuOptions );
       
  1220                 }
       
  1221             }
       
  1222         }
       
  1223     }
       
  1224 
       
  1225 // -----------------------------------------------------------------------------
       
  1226 // CFileManagerViewBase::DoActivateL
       
  1227 // 
       
  1228 // -----------------------------------------------------------------------------
       
  1229 // 
       
  1230 void CFileManagerViewBase::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
       
  1231                                         TUid /*aCustomMessageId*/,
       
  1232                                         const TDesC8& /*aCustomMessage*/ )
       
  1233     {
       
  1234     if ( !iContainer )
       
  1235         {
       
  1236         iContainer = CreateContainerL();
       
  1237         iContainer->SetMopParent( this );
       
  1238         AppUi()->AddToStackL( *this, iContainer );
       
  1239         iEngine.SetObserver( this );
       
  1240         iContainer->ActivateL();
       
  1241         }
       
  1242 
       
  1243     if ( iContainer )
       
  1244         {
       
  1245         iContainer->SetListEmptyL();
       
  1246         }
       
  1247 
       
  1248     // Set container to observe MSK commands
       
  1249     CEikButtonGroupContainer* bgc = Cba();
       
  1250     if ( bgc )
       
  1251         {
       
  1252         CEikCba* cba = static_cast< CEikCba* >( bgc->ButtonGroup() );
       
  1253         cba->SetMSKCommandObserver( iContainer );
       
  1254         }
       
  1255     }
       
  1256 
       
  1257 // -----------------------------------------------------------------------------
       
  1258 // CFileManagerViewBase::DoDeactivate
       
  1259 // 
       
  1260 // -----------------------------------------------------------------------------
       
  1261 // 
       
  1262 void CFileManagerViewBase::DoDeactivate()
       
  1263     {
       
  1264     if ( iContainer )
       
  1265         {
       
  1266         AppUi()->RemoveFromStack( iContainer );
       
  1267         delete iContainer;
       
  1268         iContainer = NULL;
       
  1269         }
       
  1270     }
       
  1271 
       
  1272 // -----------------------------------------------------------------------------
       
  1273 // CFileManagerViewBase::MarkedArrayLC
       
  1274 // 
       
  1275 // -----------------------------------------------------------------------------
       
  1276 // 
       
  1277 CArrayFixFlat<TInt>* CFileManagerViewBase::MarkedArrayLC()
       
  1278     {
       
  1279     TInt count( iContainer->ListBoxSelectionIndexesCount() );
       
  1280     CArrayFixFlat<TInt>* ret = 
       
  1281         new( ELeave ) CArrayFixFlat<TInt>( count ? count : 1 );
       
  1282     
       
  1283     CleanupStack::PushL( ret );
       
  1284 
       
  1285     if ( !count )
       
  1286         {
       
  1287         if ( iContainer->ListBoxNumberOfItems() > 0)
       
  1288             {
       
  1289             ret->AppendL( iContainer->ListBoxCurrentItemIndex() );
       
  1290             }
       
  1291         return ret;
       
  1292         }
       
  1293 
       
  1294     const CArrayFix< TInt >* items = iContainer->ListBoxSelectionIndexes();
       
  1295     for( TInt i( 0 ); i < count; ++i )
       
  1296         {
       
  1297         ret->AppendL( items->At( i ) );
       
  1298         }
       
  1299     return ret;
       
  1300     }
       
  1301 
       
  1302 // -----------------------------------------------------------------------------
       
  1303 // CFileManagerViewBase::DialogDismissedL
       
  1304 // 
       
  1305 // -----------------------------------------------------------------------------
       
  1306 // 
       
  1307 void CFileManagerViewBase::DialogDismissedL( TInt aButtonId  )
       
  1308     {
       
  1309     FUNC_LOG
       
  1310 
       
  1311     if ( aButtonId == EAknSoftkeyCancel )
       
  1312         {
       
  1313         TBool isHandled( ETrue );
       
  1314         switch( iActiveProcess )
       
  1315             {
       
  1316             case ENoProcess:
       
  1317                 {
       
  1318                 if ( IsRefreshInProgress() )
       
  1319                     {
       
  1320                     // Already freed, just set to NULL
       
  1321                     iProgressDialogRefresh = NULL;
       
  1322                     iEngine.CancelRefresh();
       
  1323                     DirectoryChangedL(); // Ensure that view gets updated
       
  1324                     }
       
  1325                 break;
       
  1326                 }
       
  1327             case EIRReceiveProcess:
       
  1328                 {
       
  1329                 // Already freed, just set to NULL
       
  1330                 iProgressDialog = NULL;
       
  1331                 iProgressInfo = NULL;
       
  1332 
       
  1333                 static_cast< CFileManagerAppUi* >( AppUi() )->StopIRReceive();
       
  1334                 break;
       
  1335                 }
       
  1336             case ECopyProcess: // FALLTHROUGH
       
  1337             case EMoveProcess:
       
  1338                 {
       
  1339                 // Already freed, just set to NULL
       
  1340                 iProgressDialog = NULL;
       
  1341                 iProgressInfo = NULL;
       
  1342 
       
  1343                 delete iPeriodic;
       
  1344                 iPeriodic = NULL;
       
  1345                 if ( iActiveExec )
       
  1346                     {
       
  1347                     iActiveExec->CancelExecution();
       
  1348                     }
       
  1349                 break;
       
  1350                 }
       
  1351             case EFileOpenProcess: // FALLTHROUGH
       
  1352             case EBackupProcess: // FALLTHROUGH
       
  1353             case ERestoreProcess:
       
  1354                 {
       
  1355                 // Already freed, just set to NULL
       
  1356                 iProgressDialog = NULL;
       
  1357                 iProgressInfo = NULL;
       
  1358 
       
  1359                 iEngine.CancelProcess( iActiveProcess );
       
  1360                 if ( iActiveProcess == EBackupProcess ||
       
  1361                      iActiveProcess == ERestoreProcess )
       
  1362                     {
       
  1363                     CFileManagerAppUi* appUi = static_cast< CFileManagerAppUi* >( AppUi() );
       
  1364                     appUi->BackupOrRestoreEnded();
       
  1365                     }
       
  1366                 break;
       
  1367                 }
       
  1368             case EFormatProcess: // FALLTHROUGH
       
  1369             case EEjectProcess:
       
  1370                 {
       
  1371                 // Already freed, just set to NULL
       
  1372                 iProgressDialog = NULL;
       
  1373                 iProgressInfo = NULL;
       
  1374                 break;
       
  1375                 }
       
  1376             default:
       
  1377                 {
       
  1378                 isHandled = EFalse;
       
  1379                 break;
       
  1380                 }
       
  1381             }
       
  1382         if ( isHandled )
       
  1383             {
       
  1384             iEikonEnv->SetSystem( EFalse );
       
  1385             iActiveProcess = ENoProcess;
       
  1386             }
       
  1387 
       
  1388 #ifdef RD_FILE_MANAGER_BACKUP
       
  1389         if ( iSchBackupPending )
       
  1390             {
       
  1391             StartSchBackupL();
       
  1392             }
       
  1393 #endif // RD_FILE_MANAGER_BACKUP
       
  1394 
       
  1395         }
       
  1396     }
       
  1397 
       
  1398 // -----------------------------------------------------------------------------
       
  1399 // CFileManagerViewBase::ProcessFinishedL
       
  1400 // 
       
  1401 // -----------------------------------------------------------------------------
       
  1402 // 
       
  1403 void CFileManagerViewBase::ProcessFinishedL( TInt aError, const TDesC& aName )
       
  1404     {
       
  1405     FUNC_LOG
       
  1406 
       
  1407     TRAPD( err, DoProcessFinishedL( aError, aName ) );
       
  1408     if( err != KErrNone )
       
  1409         {
       
  1410         // Clean up the active process before forwarding leave
       
  1411         ERROR_LOG2(
       
  1412             "CFileManagerViewBase::ProcessFinishedL-iActiveProcess=%d,err=%d",
       
  1413             iActiveProcess, err )
       
  1414         iEikonEnv->SetSystem( EFalse );
       
  1415         iActiveProcess = ENoProcess;
       
  1416         User::Leave( err );
       
  1417         }
       
  1418     }
       
  1419 
       
  1420 // -----------------------------------------------------------------------------
       
  1421 // CFileManagerViewBase::DoProcessFinishedL
       
  1422 // 
       
  1423 // -----------------------------------------------------------------------------
       
  1424 // 
       
  1425 void CFileManagerViewBase::DoProcessFinishedL( TInt aError, const TDesC& aName )
       
  1426     {
       
  1427     FUNC_LOG
       
  1428 
       
  1429     TBool isHandled( ETrue );
       
  1430     TBool doRefresh( ETrue );
       
  1431 
       
  1432     LOG_IF_ERROR2( aError, "CFileManagerViewBase::DoProcessFinishedL-iActiveProcess=%d,aError=%d",
       
  1433         iActiveProcess, aError )
       
  1434 
       
  1435     if ( iPeriodic && iProgressInfo && iTotalTransferredBytes )
       
  1436         {
       
  1437         iProgressInfo->SetAndDraw( iTotalTransferredBytes );
       
  1438         }
       
  1439     if ( IsSystemProcess( iActiveProcess ) )
       
  1440         {
       
  1441         // Remove system status to allow app close from task switcher
       
  1442         iEikonEnv->SetSystem( EFalse );
       
  1443         }
       
  1444 
       
  1445     ClearProgressBarL();
       
  1446 
       
  1447     switch( iActiveProcess )
       
  1448         {
       
  1449         case EIRReceiveProcess: // FALLTHROUGH
       
  1450             {
       
  1451             static_cast< CFileManagerAppUi* >( AppUi() )->StopIRReceive();
       
  1452             if ( aError != KErrNone && aError != KErrCancel )
       
  1453                 {
       
  1454                 if ( aError == KErrDiskFull )
       
  1455                     {
       
  1456                     ShowDiskSpaceErrorL( iEngine.CurrentDirectory() );
       
  1457                     }
       
  1458                 else
       
  1459                     {
       
  1460                     // Show general error note
       
  1461                     Error( aError );
       
  1462                     }
       
  1463                 }
       
  1464             break;
       
  1465             }
       
  1466         case ECopyProcess: // FALLTHROUGH
       
  1467         case EMoveProcess: 
       
  1468             {
       
  1469             if ( aError != KErrNone && aError != KErrCancel && !aName.Length() )
       
  1470                 {
       
  1471                 // Show general error note if item name is unavailable
       
  1472                 if ( iActiveExec && aError == KErrDiskFull )
       
  1473                     {
       
  1474                     ShowDiskSpaceErrorL( iActiveExec->ToFolder() );
       
  1475                     }
       
  1476                 else
       
  1477                     {
       
  1478                     Error( aError );
       
  1479                     }
       
  1480                 }
       
  1481             else if ( aError != KErrNone )
       
  1482                 {
       
  1483                 // If the copy process is cancelled, no error notes should be displayed
       
  1484                 if( aError != KErrCancel )
       
  1485                     {
       
  1486                     // Show more informative note first
       
  1487                     if ( iActiveExec && aError == KErrDiskFull )
       
  1488                         {
       
  1489                         ShowDiskSpaceErrorL( iActiveExec->ToFolder() );
       
  1490                         }
       
  1491                     else if ( aError == KErrNoMemory ||
       
  1492                               aError == KErrDiskFull ||
       
  1493                               aError == KErrDirFull )
       
  1494                         {
       
  1495                         Error( aError );
       
  1496                         }
       
  1497                     if ( iActiveProcess == EMoveProcess )
       
  1498                         {
       
  1499                         FileManagerDlgUtils::ShowErrorNoteL(
       
  1500                             R_QTN_FLDR_ITEM_CANNOT_BE_MOVED, aName );
       
  1501                         }
       
  1502                     else
       
  1503                         {
       
  1504                         FileManagerDlgUtils::ShowErrorNoteL(
       
  1505                             R_QTN_FLDR_ITEM_CANNOT_BE_COPIED, aName );
       
  1506                         }
       
  1507                     }
       
  1508                 delete iActiveExec;
       
  1509                 iActiveExec = NULL;
       
  1510                 }
       
  1511             else if ( iActiveProcess == EMoveProcess && iMarkedArray )
       
  1512                 {
       
  1513                 // Set focus to the item after selection
       
  1514                 TInt newIndex( MinIndex( *iMarkedArray ) );
       
  1515                 if ( iContainer )
       
  1516                     {
       
  1517                     iContainer->SetIndex( newIndex );
       
  1518                     }
       
  1519                 StoreIndex();
       
  1520                 }
       
  1521                 
       
  1522             break;
       
  1523             }
       
  1524         case EFileOpenProcess:
       
  1525             {
       
  1526             if ( aError != KErrNone && aError != KErrCancel )
       
  1527                 {
       
  1528                 if ( aError == KErrNoMemory || aError == KErrDiskFull )
       
  1529                     {
       
  1530                     Error( aError );
       
  1531                     }
       
  1532                 else if ( aError == KErrNotSupported )
       
  1533                     {
       
  1534                     FileManagerDlgUtils::ShowErrorNoteL(
       
  1535                         R_QTN_FMGR_ERROR_UNSUPPORT );
       
  1536                     }
       
  1537                 else if ( aError == KErrFmgrNotSupportedRemotely )
       
  1538                     {
       
  1539                     FileManagerDlgUtils::ShowConfirmQueryWithOkL(
       
  1540                         FileManagerDlgUtils::EInfoIcons,
       
  1541                         R_QTN_FMGR_INFONOTE_UNABLE_OPEN_REMOTELY );
       
  1542                     }
       
  1543                 else if ( !HandleFileNotFoundL( aError ) )
       
  1544                     {
       
  1545                     FileManagerDlgUtils::ShowErrorNoteL(
       
  1546                         R_QTN_FMGR_ERROR_CANT_OPEN );
       
  1547                     }
       
  1548                 }
       
  1549             else
       
  1550                 {
       
  1551                 // No refresh needed if open was successful or canceled
       
  1552                 doRefresh = EFalse;
       
  1553                 }
       
  1554             break;
       
  1555             }
       
  1556         case EFormatProcess:
       
  1557             {
       
  1558             RefreshDriveInfoL();
       
  1559             if ( aError == KErrNone )
       
  1560                 {
       
  1561 #ifdef RD_MULTIPLE_DRIVE
       
  1562                 if ( DriveInfo().iState & TFileManagerDriveInfo::EDriveMassStorage )
       
  1563                     {
       
  1564                     FileManagerDlgUtils::ShowInfoNoteL(
       
  1565                         R_QTN_FMGR_MASS_FORMAT_COMPLETED );
       
  1566                     }
       
  1567                 else
       
  1568                     {
       
  1569 #endif // RD_MULTIPLE_DRIVE
       
  1570                     FileManagerDlgUtils::ShowInfoNoteL( R_QTN_FORMAT_COMPLETED );
       
  1571 
       
  1572                     // After formatting a name to the card can be given
       
  1573                     RenameDriveL( ETrue );
       
  1574 #ifdef RD_MULTIPLE_DRIVE
       
  1575                     }
       
  1576 #endif // RD_MULTIPLE_DRIVE
       
  1577                 }
       
  1578             else if ( aError == KErrInUse || aError > 0 )
       
  1579                 {
       
  1580                 FileManagerDlgUtils::ShowErrorNoteL(
       
  1581                     R_QTN_FORMAT_FILES_IN_USE );
       
  1582                 }
       
  1583             else if ( aError != KErrCancel )
       
  1584                 {
       
  1585                 FileManagerDlgUtils::ShowErrorNoteL(
       
  1586                     R_QTN_CRITICAL_ERROR );
       
  1587                 }
       
  1588             break;
       
  1589             }
       
  1590         case EBackupProcess:
       
  1591             {
       
  1592             CFileManagerAppUi* appUi = static_cast< CFileManagerAppUi* >( AppUi() );
       
  1593             appUi->BackupOrRestoreEnded();
       
  1594             if ( aError == KErrNone )
       
  1595                 {
       
  1596                 FileManagerDlgUtils::ShowInfoNoteL(
       
  1597                     R_QTN_BACKUP_COMPLETED );
       
  1598                 }
       
  1599             else if ( aError == KErrDiskFull )
       
  1600                 {
       
  1601 #ifdef RD_FILE_MANAGER_BACKUP
       
  1602 
       
  1603                 CFileManagerBackupSettings& settings(
       
  1604                     iEngine.BackupSettingsL() );
       
  1605 
       
  1606                 FileManagerDlgUtils::ShowConfirmQueryWithOkL(
       
  1607                     FileManagerDlgUtils::EErrorIcons,
       
  1608                     R_QTN_FMGR_BACKUP_DESTINATION_FULL,
       
  1609                     iEngine.DriveName( settings.TargetDrive() ) );
       
  1610 
       
  1611 #else // RD_FILE_MANAGER_BACKUP
       
  1612 
       
  1613                 FileManagerDlgUtils::ShowErrorNoteL(
       
  1614                     R_QTN_BACKUP_NO_SPACE );
       
  1615 
       
  1616 #endif // RD_FILE_MANAGER_BACKUP
       
  1617                 }
       
  1618             else if ( aError > 0 )
       
  1619                 {
       
  1620                 // No critical error, but some files not handled
       
  1621                 if ( aError > 1 )
       
  1622                     {
       
  1623                     FileManagerDlgUtils::ShowConfirmQueryWithOkL(
       
  1624                         FileManagerDlgUtils::EInfoIcons,
       
  1625                         R_QTN_FILES_NOT_BACKUPPED,
       
  1626                         aError );
       
  1627                     }
       
  1628                 else
       
  1629                     {
       
  1630                     FileManagerDlgUtils::ShowConfirmQueryWithOkL(
       
  1631                         FileManagerDlgUtils::EInfoIcons,
       
  1632                         R_QTN_ONE_FILE_NOT_BACKUPPED );
       
  1633                     }
       
  1634                 }
       
  1635             else if ( aError != KErrCancel )
       
  1636                 {
       
  1637                 if ( aError == KErrNoMemory || aError == KErrDirFull )
       
  1638                     {
       
  1639                     // Show more informative note first
       
  1640                     Error( aError );
       
  1641                     }
       
  1642                 FileManagerDlgUtils::ShowErrorNoteL(
       
  1643                     R_QTN_CRITICAL_ERROR );
       
  1644                 }
       
  1645             break;
       
  1646             }
       
  1647         case ERestoreProcess:
       
  1648             {
       
  1649             CFileManagerAppUi* appUi = static_cast< CFileManagerAppUi* >( AppUi() );
       
  1650             appUi->BackupOrRestoreEnded();
       
  1651             if ( aError == KErrNone )
       
  1652                 {
       
  1653                 FileManagerDlgUtils::ShowInfoNoteL(
       
  1654                     R_QTN_RESTORE_COMPLETED );
       
  1655                 }
       
  1656             else if ( aError == KErrDiskFull )
       
  1657                 {
       
  1658                 FileManagerDlgUtils::ShowErrorNoteL(
       
  1659 #ifdef RD_FILE_MANAGER_BACKUP
       
  1660                     R_QTN_FMGR_RESTORE_SPACE_ERROR
       
  1661 #else // RD_FILE_MANAGER_BACKUP
       
  1662                     R_QTN_RESTORE_NO_SPACE
       
  1663 #endif // RD_FILE_MANAGER_BACKUP
       
  1664                      );
       
  1665                 }
       
  1666 #ifdef RD_FILE_MANAGER_BACKUP
       
  1667             else if ( aError == KErrCorrupt )
       
  1668                 {
       
  1669                 FileManagerDlgUtils::ShowErrorNoteL(
       
  1670                     R_QTN_FMGR_ERROR_CORRUPTED_BACKUP_FILE );
       
  1671                 }
       
  1672 #endif // RD_FILE_MANAGER_BACKUP
       
  1673             else if ( aError > 0 )
       
  1674                 {
       
  1675                 // No critical error, but some files not handled
       
  1676                 if ( aError > 1 )
       
  1677                     {
       
  1678                     FileManagerDlgUtils::ShowInfoNoteL(
       
  1679                         R_QTN_FILES_NOT_RESTORED, aError );
       
  1680                     }
       
  1681                 else
       
  1682                     {
       
  1683                     FileManagerDlgUtils::ShowInfoNoteL(
       
  1684                         R_QTN_ONE_FILE_NOT_RESTORED );
       
  1685                     }
       
  1686                 }
       
  1687             else
       
  1688                 {
       
  1689                 if ( aError == KErrNoMemory || aError == KErrDirFull )
       
  1690                     {
       
  1691                     // Show more informative note first
       
  1692                     Error( aError );
       
  1693                     }
       
  1694                 FileManagerDlgUtils::ShowErrorNoteL(
       
  1695                     R_QTN_CRITICAL_ERROR );
       
  1696                 }
       
  1697             break;
       
  1698             }
       
  1699         case EEjectProcess:
       
  1700             {
       
  1701             TRAP_IGNORE( ShowEjectQueryL() );
       
  1702             break;
       
  1703             }
       
  1704 #ifdef RD_FILE_MANAGER_BACKUP
       
  1705         case ESchBackupProcess:
       
  1706             {
       
  1707             CFileManagerAppUi* appUi =
       
  1708                 static_cast< CFileManagerAppUi* >( AppUi() );
       
  1709             appUi->SchBackupHandlerL().ProcessFinishedL( aError, aName );
       
  1710             // No refresh needed, done by view activation
       
  1711             doRefresh = EFalse;
       
  1712             break;
       
  1713             }
       
  1714 #endif // RD_FILE_MANAGER_BACKUP
       
  1715         default:
       
  1716             {
       
  1717             isHandled = EFalse;
       
  1718             break;
       
  1719             }
       
  1720         }
       
  1721 
       
  1722     if ( isHandled )
       
  1723         {
       
  1724         iEikonEnv->SetSystem( EFalse );
       
  1725         iActiveProcess = ENoProcess;
       
  1726 
       
  1727         if ( doRefresh )
       
  1728             {
       
  1729             iEngine.SetObserver( this );
       
  1730             iEngine.RefreshDirectory();
       
  1731             }
       
  1732         }
       
  1733 
       
  1734 #ifdef RD_FILE_MANAGER_BACKUP
       
  1735     if ( iSchBackupPending )
       
  1736         {
       
  1737         StartSchBackupL();
       
  1738         }
       
  1739 #endif // RD_FILE_MANAGER_BACKUP
       
  1740 
       
  1741     }
       
  1742 
       
  1743 // -----------------------------------------------------------------------------
       
  1744 // CFileManagerViewBase::ProcessAdvanceL
       
  1745 // 
       
  1746 // -----------------------------------------------------------------------------
       
  1747 // 
       
  1748 void CFileManagerViewBase::ProcessAdvanceL( TInt aValue )
       
  1749     {
       
  1750     FUNC_LOG
       
  1751 
       
  1752     switch( iActiveProcess )
       
  1753         {
       
  1754         case EIRReceiveProcess:
       
  1755             {
       
  1756             if ( iProgressDialog )
       
  1757                 {
       
  1758                 HBufC* label = StringLoader::LoadLC( 
       
  1759                     R_QTN_FMGR_NOTE_RECEIVE_IR, aValue );
       
  1760                 iProgressDialog->SetTextL( *label );
       
  1761                 CleanupStack::PopAndDestroy( label );
       
  1762                 // Incrementing progress of the process: 
       
  1763                 if ( iProgressInfo )
       
  1764                     {
       
  1765                     iProgressInfo->SetAndDraw( aValue ); 
       
  1766                     }
       
  1767                 }
       
  1768             break;
       
  1769             }
       
  1770         case EBackupProcess: // FALLTHROUGH
       
  1771         case ERestoreProcess: // FALLTHROUGH
       
  1772         case EFormatProcess:
       
  1773             {
       
  1774 #ifdef RD_FILE_MANAGER_BACKUP
       
  1775             if ( iActiveProcess == EBackupProcess && iProgressDialog )
       
  1776                 {
       
  1777                 HBufC* label = StringLoader::LoadLC(
       
  1778                     R_QTN_BACKUP_INPROGRESS );
       
  1779                 iProgressDialog->SetTextL( *label );
       
  1780                 CleanupStack::PopAndDestroy( label );
       
  1781                 
       
  1782                 iProgressDialog->ButtonGroupContainer().SetCommandSetL(R_AVKON_SOFTKEYS_CANCEL);
       
  1783                 iProgressDialog->ButtonGroupContainer().DrawDeferred();
       
  1784                 }
       
  1785             else if ( iActiveProcess == ERestoreProcess && iProgressDialog )
       
  1786                 {
       
  1787                 HBufC* label = StringLoader::LoadLC(
       
  1788                     R_QTN_RESTORE_INPROGRESS );
       
  1789                 iProgressDialog->SetTextL( *label );
       
  1790                 CleanupStack::PopAndDestroy( label );
       
  1791                 }                
       
  1792 #endif // RD_FILE_MANAGER_BACKUP
       
  1793             if ( iProgressInfo )
       
  1794                 {
       
  1795                 iProgressInfo->SetAndDraw( aValue );
       
  1796                 }
       
  1797             break;
       
  1798             }
       
  1799 #ifdef RD_FILE_MANAGER_BACKUP
       
  1800         case ESchBackupProcess:
       
  1801             {
       
  1802             CFileManagerAppUi* appUi =
       
  1803                 static_cast< CFileManagerAppUi* >( AppUi() );
       
  1804             appUi->SchBackupHandlerL().ProcessAdvanceL( aValue );
       
  1805             break;
       
  1806             }
       
  1807 #endif // RD_FILE_MANAGER_BACKUP
       
  1808         default:
       
  1809             {
       
  1810             break;
       
  1811             }
       
  1812         }
       
  1813     iTotalTransferredBytes = static_cast<TUint>(aValue);  // to avoid over 2GB files looks likes minus value 
       
  1814     }
       
  1815 
       
  1816 // -----------------------------------------------------------------------------
       
  1817 // CFileManagerViewBase::ProcessStartedL
       
  1818 // 
       
  1819 // -----------------------------------------------------------------------------
       
  1820 // 
       
  1821 void CFileManagerViewBase::ProcessStartedL(
       
  1822     MFileManagerProcessObserver::TFileManagerProcess aProcess,
       
  1823     TInt aFinalValue )
       
  1824     {
       
  1825     FUNC_LOG
       
  1826 
       
  1827     // For preventing shutter to close app during system process
       
  1828     iEikonEnv->SetSystem( IsSystemProcess( aProcess ) );
       
  1829 
       
  1830     switch( aProcess )
       
  1831         {
       
  1832         case EIRReceiveProcess:
       
  1833             {
       
  1834             if ( iProgressDialog )
       
  1835                 {
       
  1836                 HBufC* label = StringLoader::LoadLC(
       
  1837                     R_QTN_FMGR_NOTE_RECEIVE_IR, 0 );
       
  1838                 iProgressDialog->SetTextL( *label );
       
  1839                 CleanupStack::PopAndDestroy( label );
       
  1840                 }
       
  1841             break;
       
  1842             }
       
  1843         case EFileOpenProcess:
       
  1844             {
       
  1845             ClearProgressBarL();
       
  1846             LaunchProgressDialogL( 0, 0, aProcess );
       
  1847             iActiveProcess = aProcess;
       
  1848             break;
       
  1849             }
       
  1850         case ERestoreProcess:
       
  1851             {
       
  1852             CEikButtonGroupContainer* cba = Cba();
       
  1853             cba->SetCommandSetL( R_AVKON_SOFTKEYS_EMPTY );
       
  1854             cba->DrawDeferred();
       
  1855             // FALLTHROUGH
       
  1856             }
       
  1857         case EBackupProcess: // FALLTHROUGH
       
  1858         case EFormatProcess:
       
  1859             {
       
  1860             if ( iProgressDialog )
       
  1861                 {
       
  1862                 if ( !iProgressDialog->IsVisible() )
       
  1863                     {
       
  1864                     iProgressDialog->MakeVisible( ETrue );
       
  1865                     }
       
  1866                 }
       
  1867             if ( iProgressInfo )
       
  1868                 {
       
  1869                 iProgressInfo->SetFinalValue( aFinalValue );
       
  1870                 }    
       
  1871             break;
       
  1872             }
       
  1873 #ifdef RD_FILE_MANAGER_BACKUP
       
  1874         case ESchBackupProcess:
       
  1875             {
       
  1876             CFileManagerAppUi* appUi =
       
  1877                 static_cast< CFileManagerAppUi* >( AppUi() );
       
  1878             appUi->SchBackupHandlerL().ProcessStartedL( aFinalValue );
       
  1879             break;
       
  1880             }
       
  1881 #endif // RD_FILE_MANAGER_BACKUP
       
  1882         default:
       
  1883             {
       
  1884             break;
       
  1885             }
       
  1886         }
       
  1887     }
       
  1888 
       
  1889 // -----------------------------------------------------------------------------
       
  1890 // CFileManagerViewBase::RunOperationL
       
  1891 // 
       
  1892 // -----------------------------------------------------------------------------
       
  1893 // 
       
  1894 void CFileManagerViewBase::RunOperationL
       
  1895     ( MFileManagerProcessObserver::TFileManagerProcess aOperation,
       
  1896       const TDesC& aToFolder )
       
  1897     {
       
  1898 
       
  1899     StoreIndex();
       
  1900     delete iMarkedArray;
       
  1901     iMarkedArray = NULL;
       
  1902     iMarkedArray = MarkedArrayLC();
       
  1903     CleanupStack::Pop( iMarkedArray );
       
  1904 
       
  1905     // Check if marked source and destination folder are available
       
  1906     if ( !iMarkedArray->Count() || !IsDriveAvailable( aToFolder ) )
       
  1907         {
       
  1908         return;
       
  1909         }
       
  1910 
       
  1911     CFileManagerItemProperties* prop =
       
  1912         iEngine.GetItemInfoLC( iMarkedArray->At( 0 ) );
       
  1913 
       
  1914 #ifdef __KEEP_DRM_CONTENT_ON_PHONE
       
  1915     // When this flag is on all the selected items have to be gone through and checked
       
  1916     // whether they are protected and the user has to be notified when moving or
       
  1917     // copying file(s) is impossible. This only applies to processes from phone to MMC.
       
  1918     TBool process( ETrue );
       
  1919     if ( CFileManagerUtils::IsFromInternalToRemovableDrive(
       
  1920             iEikonEnv->FsSession(), iEngine.CurrentDirectory(), aToFolder ) )
       
  1921         {
       
  1922         TInt fileAmount (iMarkedArray->Count());
       
  1923 
       
  1924         // Only one folder can be selected at a time
       
  1925         if (iEngine.IsFolder(iMarkedArray->At( 0 )))
       
  1926             {
       
  1927             if ( prop->FilesContainedL() == 0 && prop->FoldersContainedL() == 0)
       
  1928                 {
       
  1929                 process = ETrue;
       
  1930                 }
       
  1931             else if (AreChosenFilesProtectedL( ETrue ))
       
  1932                 {
       
  1933                 if ( aOperation == EMoveProcess )
       
  1934                     {
       
  1935                     FileManagerDlgUtils::ShowInfoNoteL(
       
  1936                         R_QTN_DRM_INFO_MOVE_FOLDER_FORBID );
       
  1937                     }
       
  1938                 else
       
  1939                     {
       
  1940                     FileManagerDlgUtils::ShowInfoNoteL(
       
  1941                         R_QTN_DRM_INFO_COPY_FOLDER_FORBID );
       
  1942                     }
       
  1943                 process = EFalse;
       
  1944                 }
       
  1945             else if (AreChosenFilesProtectedL( EFalse ))
       
  1946                 {
       
  1947                 TInt textId( 0 );
       
  1948                 if ( aOperation == EMoveProcess )
       
  1949                     {
       
  1950                     textId = R_QTN_DRM_QUERY_MOVE_FORBIDDEN;
       
  1951                     }
       
  1952                 else
       
  1953                     {
       
  1954                     textId = R_QTN_DRM_QUERY_COPY_FORBIDDEN;
       
  1955                     }
       
  1956                 if ( FileManagerDlgUtils::ShowConfirmQueryWithYesNoL(
       
  1957                         textId ) )
       
  1958                     {
       
  1959                     // Engine will not touch protected objects anyway
       
  1960                     process = ETrue;
       
  1961                     }
       
  1962                 else
       
  1963                     {
       
  1964                     process = EFalse;
       
  1965                     }
       
  1966                 }
       
  1967             }
       
  1968         else if ( fileAmount == 1 && AreChosenFilesProtectedL( ETrue ))
       
  1969             {
       
  1970             if ( aOperation == EMoveProcess )
       
  1971                 {
       
  1972                 FileManagerDlgUtils::ShowInfoNoteL(
       
  1973                     R_QTN_DRM_INFO_MOVE_ONE_FORBID );
       
  1974                 }
       
  1975             else
       
  1976                 {
       
  1977                 FileManagerDlgUtils::ShowInfoNoteL(
       
  1978                     R_QTN_DRM_INFO_COPY_ONE_FORBID );
       
  1979                 }
       
  1980             process= EFalse;
       
  1981             }
       
  1982         else if ( fileAmount > 1 && AreChosenFilesProtectedL( EFalse ))
       
  1983             {
       
  1984             if (AreChosenFilesProtectedL( ETrue ))
       
  1985                 {
       
  1986                 if ( aOperation == EMoveProcess )
       
  1987                     {
       
  1988                     FileManagerDlgUtils::ShowInfoNoteL(
       
  1989                         R_QTN_DRM_INFO_MOVE_MANY_FORBID );
       
  1990                     }
       
  1991                 else
       
  1992                     {
       
  1993                     FileManagerDlgUtils::ShowInfoNoteL(
       
  1994                         R_QTN_DRM_INFO_COPY_MANY_FORBID );
       
  1995                     }
       
  1996                 process= EFalse;
       
  1997                 }
       
  1998             else
       
  1999                 {
       
  2000                 TInt textId( 0 );
       
  2001                 if ( aOperation == EMoveProcess )
       
  2002                     {
       
  2003                     textId = R_QTN_DRM_QUERY_MOVE_FORBIDDEN;
       
  2004                     }
       
  2005                 else
       
  2006                     {
       
  2007                     textId = R_QTN_DRM_QUERY_COPY_FORBIDDEN;
       
  2008                     }
       
  2009                 if ( FileManagerDlgUtils::ShowConfirmQueryWithYesNoL(
       
  2010                         textId ) )
       
  2011                     {
       
  2012                     // Engine will not touch protected objects anyway
       
  2013                     process = ETrue;
       
  2014                     }
       
  2015                 else
       
  2016                     {
       
  2017                     process = EFalse;
       
  2018                     }
       
  2019                 }
       
  2020             }
       
  2021         }
       
  2022     if ( process )
       
  2023         {
       
  2024 #endif // __KEEP_DRM_CONTENT_ON_PHONE
       
  2025 
       
  2026         TInt64 size( 0 );
       
  2027         // Skip remote folder size counting because it may last very long time.
       
  2028         // The content may also change during the operation what makes 
       
  2029         // the counting needless.
       
  2030         if ( !( prop->IsRemoteDrive() &&
       
  2031                 ( prop->TypeL() & CFileManagerItemProperties::EFolder ) ) )
       
  2032             {
       
  2033             size = iEngine.GetFileSizesL( *iMarkedArray ) ;
       
  2034             }
       
  2035         if ( size == KErrNotFound )
       
  2036             {
       
  2037             // User has cancelled size calculation, do nothing
       
  2038             }
       
  2039         else if ( iEngine.EnoughSpaceL( aToFolder, size, aOperation ))
       
  2040             {
       
  2041             iTotalTransferredBytes = 0;            
       
  2042             iEngine.SetObserver( this );
       
  2043             if ( aOperation == EMoveProcess && 
       
  2044                 aToFolder.Left( KDriveLetterSize ) == 
       
  2045                 prop->FullPath().Left( KDriveLetterSize ) )
       
  2046                 {
       
  2047                 // If operation is move and it happens inside drive
       
  2048                 // set size to file amount
       
  2049                 // CFileMan is not calling notify if those conditions apply
       
  2050                 if ( iMarkedArray->Count() > 0 )
       
  2051                     {   
       
  2052                     size = iMarkedArray->Count();
       
  2053                     }
       
  2054                 else
       
  2055                     {
       
  2056                     // Folder move time we cannot predict, so setting size to
       
  2057                     // 0 to show wait note, one file moves so fast that it
       
  2058                     // won't show wait note anyway
       
  2059                     size = 0;
       
  2060                     }
       
  2061                 }
       
  2062 
       
  2063             if ( prop->IsRemoteDrive() ||
       
  2064                 CFileManagerUtils::IsRemoteDrive(
       
  2065                     iEikonEnv->FsSession(), aToFolder ) )
       
  2066                 {
       
  2067                 // Use wait note for remote drives 
       
  2068                 // because real progress information is unavailable
       
  2069                 size = 0;
       
  2070                 }
       
  2071 
       
  2072             LaunchProgressDialogL( size, 0, aOperation );
       
  2073             delete iActiveExec;
       
  2074             iActiveExec = NULL;
       
  2075             iActiveExec = CFileManagerActiveExecute::NewL(
       
  2076                 iEngine, aOperation, *this, *iMarkedArray, aToFolder );
       
  2077             iActiveProcess = aOperation;
       
  2078             TRAPD( err, iActiveExec->ExecuteL( CFileManagerActiveExecute::ENoOverWrite ) );
       
  2079             if ( err != KErrNone )
       
  2080                 {
       
  2081                 // Clean up the active process before forwarding leave
       
  2082                 ERROR_LOG2(
       
  2083                     "CFileManagerViewBase::RunOperationL-aOperation=%d,err=%d",
       
  2084                     aOperation, err )
       
  2085                 iActiveProcess = ENoProcess;
       
  2086                 User::Leave( err );
       
  2087                 }
       
  2088             }
       
  2089         else
       
  2090             {
       
  2091             ShowDiskSpaceErrorL( aToFolder );
       
  2092             }
       
  2093 
       
  2094 #ifdef  __KEEP_DRM_CONTENT_ON_PHONE
       
  2095         }
       
  2096 #endif // __KEEP_DRM_CONTENT_ON_PHONE
       
  2097 
       
  2098     CleanupStack::PopAndDestroy( prop );
       
  2099 
       
  2100     }
       
  2101 
       
  2102 // -----------------------------------------------------------------------------
       
  2103 // CFileManagerViewBase::ProcessQueryOverWriteL
       
  2104 // 
       
  2105 // -----------------------------------------------------------------------------
       
  2106 // 
       
  2107 TBool CFileManagerViewBase::ProcessQueryOverWriteL
       
  2108     ( const TDesC& aOldName, TDes& aNewName, TFileManagerProcess aOperation )
       
  2109     {
       
  2110     
       
  2111     TParsePtrC name( aOldName );
       
  2112 
       
  2113     // Stop progress note before showing the query to be restarted later. 
       
  2114     // Note that progress note may still exist after stop (to fill min time on screen) 
       
  2115     // and it gets deleted later by AVKON. Asynchronous restart is needed to prevent 
       
  2116     // mess up (if note still exists). Otherwise starting and stopping progress note too 
       
  2117     // quickly multiple times leads to mess up in AVKON's note handling.
       
  2118     StopProgressDialogAndStoreValues();
       
  2119 
       
  2120     TBool overWrite( FileManagerDlgUtils::ShowConfirmQueryWithYesNoL(
       
  2121             R_QTN_FLDR_OVERWRITE_QUERY, name.NameAndExt() ) );
       
  2122     if ( !overWrite )
       
  2123         {
       
  2124         if ( !FileManagerDlgUtils::ShowFileNameQueryL(
       
  2125             R_QTN_FLDR_ITEM_NAME_PRMPT, aOldName, aNewName, iEngine ) )
       
  2126             {
       
  2127             aNewName.Zero();
       
  2128             }
       
  2129         }
       
  2130 
       
  2131     if ( iActiveProcess == aOperation &&
       
  2132          ( aOperation == MFileManagerProcessObserver::ECopyProcess ||
       
  2133            aOperation == MFileManagerProcessObserver::EMoveProcess ) )
       
  2134         {
       
  2135         // Progress note needs asynchronous start because of AVKON's note handling.
       
  2136         delete iRefreshProgressDelayedStart;
       
  2137         iRefreshProgressDelayedStart = NULL;
       
  2138         iRefreshProgressDelayedStart = CPeriodic::NewL( CActive::EPriorityUserInput );
       
  2139         iRefreshProgressDelayedStart->Start(
       
  2140             KProgressBarAsyncStartDelay, KProgressBarAsyncStartDelay,
       
  2141             TCallBack( LaunchProgressDialogAsync, this ) );
       
  2142         }
       
  2143     
       
  2144     return overWrite;
       
  2145     }
       
  2146 
       
  2147 // -----------------------------------------------------------------------------
       
  2148 // CFileManagerViewBase::ProcessQueryRenameL
       
  2149 // 
       
  2150 // -----------------------------------------------------------------------------
       
  2151 //
       
  2152 TBool CFileManagerViewBase::ProcessQueryRenameL
       
  2153     ( const TDesC& aOldName, TDes& aNewName, TFileManagerProcess aOperation )
       
  2154     {
       
  2155     TParsePtrC typeCheck( aOldName );
       
  2156     TParse oldName;
       
  2157     TBool folderRename( EFalse );
       
  2158 
       
  2159     // Check is item file or folder
       
  2160     if ( !typeCheck.NameOrExtPresent() )
       
  2161         {
       
  2162         oldName.Set( aOldName.Left( aOldName.Length() - 1 ), NULL, NULL );
       
  2163         folderRename = ETrue;
       
  2164         }
       
  2165     else
       
  2166         {
       
  2167         oldName.Set( aOldName , NULL, NULL );
       
  2168         }
       
  2169 
       
  2170     // Stop progress note before showing the query to be restarted later. 
       
  2171     // Note that progress note may still exist after stop (to fill min time on screen) 
       
  2172     // and it gets deleted later by AVKON. Asynchronous restart is needed to prevent 
       
  2173     // mess up (if note still exists). Otherwise starting and stopping progress note too 
       
  2174     // quickly multiple times leads to mess up in AVKON's note handling.
       
  2175     StopProgressDialogAndStoreValues();
       
  2176 
       
  2177     TBool rename( FileManagerDlgUtils::ShowConfirmQueryWithOkCancelL(
       
  2178             R_QTN_FLDR_RENAME_QUERY, oldName.NameAndExt() ) );
       
  2179     if ( rename )
       
  2180         {
       
  2181         TBool done( 0 );
       
  2182         if ( folderRename )
       
  2183             {
       
  2184             aNewName.Copy( aOldName );
       
  2185             done = FileManagerDlgUtils::ShowFolderNameQueryL(
       
  2186                 R_QTN_FLDR_ITEM_NAME_PRMPT, aNewName, iEngine );
       
  2187             }
       
  2188         else
       
  2189             {
       
  2190             done = FileManagerDlgUtils::ShowFileNameQueryL(
       
  2191                 R_QTN_FLDR_ITEM_NAME_PRMPT, aOldName, aNewName, iEngine );
       
  2192             }
       
  2193 
       
  2194         if ( !done )
       
  2195             {
       
  2196             // User cancelled rename
       
  2197             aNewName.Zero();
       
  2198             }
       
  2199         }
       
  2200 
       
  2201     if ( iActiveProcess == aOperation &&
       
  2202          ( aOperation == MFileManagerProcessObserver::ECopyProcess ||
       
  2203            aOperation == MFileManagerProcessObserver::EMoveProcess ) )
       
  2204         {
       
  2205         // Progress note needs asynchronous start because of AVKON's note handling.
       
  2206         delete iRefreshProgressDelayedStart;
       
  2207         iRefreshProgressDelayedStart = NULL;
       
  2208         iRefreshProgressDelayedStart = CPeriodic::NewL( CActive::EPriorityUserInput );
       
  2209         iRefreshProgressDelayedStart->Start(
       
  2210             KProgressBarAsyncStartDelay, KProgressBarAsyncStartDelay,
       
  2211             TCallBack( LaunchProgressDialogAsync, this ) );
       
  2212         }
       
  2213 
       
  2214     return rename;
       
  2215     }
       
  2216 
       
  2217 // -----------------------------------------------------------------------------
       
  2218 // CFileManagerViewBase::LaunchProgressDialogL  
       
  2219 // 
       
  2220 // -----------------------------------------------------------------------------
       
  2221 // 
       
  2222 void CFileManagerViewBase::LaunchProgressDialogL( 
       
  2223     TInt64 aFinalValue, 
       
  2224     TInt64 aInitialValue, 
       
  2225     MFileManagerProcessObserver::TFileManagerProcess aOperation,
       
  2226     TBool aImmediatelyVisible )
       
  2227     {
       
  2228     TInt dialogId( 0 );
       
  2229     TInt textId( 0 );
       
  2230     TBool isPeriodic( EFalse );
       
  2231     TInt value;
       
  2232     value=Int64ToInt(aFinalValue);
       
  2233     switch ( aOperation )
       
  2234         {
       
  2235         case ECopyProcess:
       
  2236             {
       
  2237             isPeriodic = ( value > 1 );
       
  2238             if ( isPeriodic )
       
  2239                 {
       
  2240                 dialogId = R_FILEMANAGER_PROGRESS_NOTE_COPY;
       
  2241                 }
       
  2242             else
       
  2243                 {
       
  2244                 dialogId = R_FILEMANAGER_WAIT_NOTE_COPY;
       
  2245                 }
       
  2246             break;
       
  2247             }
       
  2248         case EMoveProcess:
       
  2249             {
       
  2250             isPeriodic = ( value > 1 );
       
  2251             if ( isPeriodic )
       
  2252                 {
       
  2253                 dialogId = R_FILEMANAGER_PROGRESS_NOTE_MOVE;
       
  2254                 }
       
  2255             else
       
  2256                 {
       
  2257                 dialogId = R_FILEMANAGER_WAIT_NOTE_MOVE;
       
  2258                 }
       
  2259             break;
       
  2260             }
       
  2261         case EFormatProcess:
       
  2262             {
       
  2263             dialogId = R_FILEMANAGER_PROGRESS_NOTE;
       
  2264 			TFileManagerDriveInfo drvInfo;
       
  2265 			DriveInfoAtCurrentPosL( drvInfo );
       
  2266 #ifdef RD_MULTIPLE_DRIVE
       
  2267 			if ( drvInfo.iState & TFileManagerDriveInfo::EDriveMassStorage
       
  2268 					|| drvInfo.iState & TFileManagerDriveInfo::EDriveUsbMemory )
       
  2269                 {
       
  2270                 textId = R_QTN_FMGR_MASS_FORMAT_INPROGRESS;
       
  2271                 }
       
  2272             else
       
  2273                 {
       
  2274 #endif // RD_MULTIPLE_DRIVE
       
  2275                 textId = R_QTN_FORMAT_INPROGRESS;
       
  2276 #ifdef RD_MULTIPLE_DRIVE
       
  2277                 }
       
  2278 #endif // RD_MULTIPLE_DRIVE
       
  2279             break;
       
  2280             }
       
  2281         case EBackupProcess:
       
  2282             {
       
  2283             dialogId = R_FILEMANAGER_PROGRESS_NOTE_WITH_CANCEL;
       
  2284 #ifdef RD_FILE_MANAGER_BACKUP
       
  2285             textId = R_QTN_FMGR_PROGRESS_PREPARING_BACKUP;
       
  2286 #else // RD_FILE_MANAGER_BACKUP
       
  2287             textId = R_QTN_BACKUP_INPROGRESS;
       
  2288 #endif // RD_FILE_MANAGER_BACKUP
       
  2289             aImmediatelyVisible = ETrue;
       
  2290             break;
       
  2291             }
       
  2292         case ERestoreProcess:
       
  2293             {
       
  2294             dialogId = R_FILEMANAGER_PROGRESS_NOTE;
       
  2295 #ifdef RD_FILE_MANAGER_BACKUP
       
  2296             textId = R_QTN_FMGR_PROGRESS_PREPARING_RESTORE;
       
  2297 #else // RD_FILE_MANAGER_BACKUP
       
  2298             textId = R_QTN_RESTORE_INPROGRESS;
       
  2299 #endif // RD_FILE_MANAGER_BACKUP
       
  2300             break;
       
  2301             }
       
  2302         case EEjectProcess:
       
  2303             {
       
  2304             dialogId = R_FILEMANAGER_WAIT_NOTE;
       
  2305             textId = R_QTN_WAIT_EJECT;
       
  2306             break;
       
  2307             }
       
  2308         case EFileOpenProcess:
       
  2309             {
       
  2310             dialogId = R_FILEMANAGER_WAIT_NOTE_OPEN_WITH_CANCEL;
       
  2311             break;
       
  2312             }
       
  2313         default:
       
  2314             {
       
  2315             dialogId = R_FILEMANAGER_WAIT_NOTE_OPEN;
       
  2316             break;
       
  2317             }
       
  2318         }
       
  2319     LaunchProgressBarL(
       
  2320         dialogId, textId, aFinalValue, aInitialValue, isPeriodic, aImmediatelyVisible );
       
  2321     
       
  2322 #ifdef RD_FILE_MANAGER_BACKUP
       
  2323     if ( aOperation == EBackupProcess && iProgressDialog )
       
  2324         {
       
  2325         iProgressDialog->ButtonGroupContainer().SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY);
       
  2326         iProgressDialog->ButtonGroupContainer().DrawDeferred();
       
  2327         }
       
  2328 #endif // RD_FILE_MANAGER_BACKUP
       
  2329     }
       
  2330 
       
  2331 // ------------------------------------------------------------------------------
       
  2332 // CFileManagerViewBase::ShowWaitDialogL
       
  2333 //
       
  2334 // ------------------------------------------------------------------------------
       
  2335 //
       
  2336 void CFileManagerViewBase::ShowWaitDialogL( MAknBackgroundProcess& aProcess)
       
  2337     {
       
  2338     CAknWaitNoteWrapper* waitNoteWrapper = CAknWaitNoteWrapper::NewL();
       
  2339     CleanupDeletePushL( waitNoteWrapper );
       
  2340     waitNoteWrapper->ExecuteL( R_FILEMANAGER_WAIT_NOTE_PROCESS, aProcess );
       
  2341     CleanupStack::PopAndDestroy( waitNoteWrapper );
       
  2342     }
       
  2343 
       
  2344 // ------------------------------------------------------------------------------
       
  2345 // CFileManagerViewBase::DoUpdateProgressBar
       
  2346 //
       
  2347 // ------------------------------------------------------------------------------
       
  2348 //
       
  2349 void CFileManagerViewBase::DoUpdateProgressBar()
       
  2350     {
       
  2351     // Update progress indicator
       
  2352     if ( iProgressDialog && iProgressInfo )
       
  2353         {
       
  2354           iProgressInfo->SetAndDraw( iTotalTransferredBytes/1024 );
       
  2355         }
       
  2356     }
       
  2357 
       
  2358 // ------------------------------------------------------------------------------
       
  2359 // CFileManagerViewBase::UpdateProgressBar
       
  2360 //
       
  2361 // ------------------------------------------------------------------------------
       
  2362 //
       
  2363 TInt CFileManagerViewBase::UpdateProgressBar(TAny* aPtr )
       
  2364     {
       
  2365     static_cast< CFileManagerViewBase* >( aPtr )->DoUpdateProgressBar();
       
  2366     return KErrNone;
       
  2367     }
       
  2368 
       
  2369 // ------------------------------------------------------------------------------
       
  2370 // CFileManagerViewBase::RefreshStartedL
       
  2371 //
       
  2372 // ------------------------------------------------------------------------------
       
  2373 //
       
  2374 void CFileManagerViewBase::RefreshStartedL()
       
  2375     {
       
  2376     FUNC_LOG
       
  2377 
       
  2378     DenyDirectoryRefresh( EFalse );
       
  2379 
       
  2380     if ( static_cast< CFileManagerAppUi* >( AppUi() )->IsFmgrForeGround() )
       
  2381         {
       
  2382         if ( iContainer )
       
  2383             {
       
  2384             iContainer->SetListEmptyL();
       
  2385             }
       
  2386 
       
  2387         ClearProgressBarL();
       
  2388         if ( Id() == CFileManagerAppUi::KFileManagerSearchResultsViewId )
       
  2389             {
       
  2390             // On remote drives local find progress note is sometimes 
       
  2391             // totally blocked if the note is not started directly here.
       
  2392             iProgressDialogRefresh = new( ELeave ) CAknProgressDialog(
       
  2393                 reinterpret_cast< CEikDialog** >(
       
  2394                     &iProgressDialogRefresh ), EFalse );
       
  2395             iProgressDialogRefresh->SetCallback( this );
       
  2396             iProgressDialogRefresh->ExecuteLD( R_FILEMANAGER_FIND_WAIT_DIALOG );
       
  2397             }
       
  2398         else
       
  2399             {
       
  2400             // Start progress dialog using own timer, otherwise progress dialog
       
  2401             // burns sometimes quite a lot CPU time even if it is not
       
  2402             // visible at all.
       
  2403             iRefreshProgressDelayedStart = CPeriodic::NewL(
       
  2404                 CActive::EPriorityUserInput );
       
  2405             iRefreshProgressDelayedStart->Start(
       
  2406                 KRefreshProgressStartDelay,
       
  2407                 KRefreshProgressStartDelay,
       
  2408                 TCallBack( RefreshProgressDelayedStart, this ) );
       
  2409             }
       
  2410         }
       
  2411     }
       
  2412 
       
  2413 // ------------------------------------------------------------------------------
       
  2414 // CFileManagerViewBase::RefreshStoppedL
       
  2415 //
       
  2416 // ------------------------------------------------------------------------------
       
  2417 //
       
  2418 void CFileManagerViewBase::RefreshStoppedL()
       
  2419     {
       
  2420     FUNC_LOG
       
  2421 
       
  2422     ClearProgressBarL();
       
  2423 
       
  2424     if( iContainer )
       
  2425         {
       
  2426         TInt index( iContainer->ListBoxCurrentItemIndex() );
       
  2427         if ( index > 0 && index < iContainer->ListBoxNumberOfItems() )
       
  2428             {
       
  2429             iIndex = index;
       
  2430             }
       
  2431         DirectoryChangedL();
       
  2432         UpdateCbaL();
       
  2433         }
       
  2434     }
       
  2435 
       
  2436 // ------------------------------------------------------------------------------
       
  2437 // CFileManagerViewBase::AreChosenFilesProtectedL
       
  2438 //
       
  2439 // ------------------------------------------------------------------------------
       
  2440 //
       
  2441 TBool CFileManagerViewBase::AreChosenFilesProtectedL( TBool aMode )
       
  2442     {
       
  2443     TBool ret = aMode;
       
  2444     CArrayFixFlat<TInt>* indexArray = MarkedArrayLC();
       
  2445 
       
  2446     TInt i( 0 );
       
  2447 
       
  2448 #ifdef __KEEP_DRM_CONTENT_ON_PHONE
       
  2449     TBool protectedFile( EFalse );
       
  2450 #endif // __KEEP_DRM_CONTENT_ON_PHONE
       
  2451 
       
  2452     while( ( ret == aMode ) && i < indexArray->Count() )
       
  2453         {
       
  2454         CFileManagerItemProperties* prop = iEngine.GetItemInfoL( indexArray->At( i ));
       
  2455         CleanupStack::PushL( prop );
       
  2456 
       
  2457 #ifdef __KEEP_DRM_CONTENT_ON_PHONE
       
  2458         // Only one folder can be selected at a time
       
  2459         if (iEngine.IsFolder(indexArray->At( i )))
       
  2460             {
       
  2461 
       
  2462             CDirScan *dirScan = CDirScan::NewLC( iEikonEnv->FsSession() );
       
  2463             CDir *currentDir = NULL;
       
  2464             // Go through the files only
       
  2465             dirScan->SetScanDataL( prop->FullPath(), KEntryAttNormal, ESortNone );
       
  2466 
       
  2467             dirScan->NextL( currentDir );
       
  2468             while ( ( ret == aMode ) && currentDir )
       
  2469                 {
       
  2470                 CleanupStack::PushL( currentDir );  // currentDir won't be null
       
  2471                                                     // due to while loop conditional
       
  2472                 TInt j( 0 );
       
  2473                 while ( ( ret == aMode ) && j < currentDir->Count() )
       
  2474                     {
       
  2475                     const TEntry &currentFile( ( *currentDir )[ j ] );
       
  2476                     TPtrC currentPath (dirScan->FullPath());
       
  2477                     HBufC* currentFilePath = HBufC::NewLC( KMaxFileName );
       
  2478                     TPtr completeFilePath = currentFilePath->Des();
       
  2479                     completeFilePath.Append(currentPath);
       
  2480                     completeFilePath.Append(currentFile.iName);
       
  2481 
       
  2482 
       
  2483                     // the following could leave if file is opened in exclusive
       
  2484                     // mode by another app- will cause 'in use' error dialog
       
  2485                     //to be displayed
       
  2486                     User::LeaveIfError( iEngine.IsDistributableFile( completeFilePath,
       
  2487                                                                       protectedFile ));
       
  2488                       if( protectedFile == !aMode )
       
  2489                         {
       
  2490                         ret = !aMode;
       
  2491                         }
       
  2492                     ++j;
       
  2493                     CleanupStack::PopAndDestroy( currentFilePath );
       
  2494                     currentFilePath = NULL;
       
  2495                     }
       
  2496                 CleanupStack::PopAndDestroy( currentDir );
       
  2497                 currentDir=NULL;
       
  2498                 dirScan->NextL( currentDir );
       
  2499                 }
       
  2500             CleanupStack::PopAndDestroy( dirScan );
       
  2501             dirScan = NULL;
       
  2502             }
       
  2503         else
       
  2504             {
       
  2505 
       
  2506             // the following could leave if file is opened in exclusive
       
  2507             // mode by another app- will cause 'in use' error dialog
       
  2508             //to be displayed
       
  2509             User::LeaveIfError( iEngine.IsDistributableFile( prop->FullPath(),
       
  2510                                                               protectedFile ));
       
  2511             if( protectedFile == !aMode )
       
  2512                 {
       
  2513                 ret = !aMode;
       
  2514                 }
       
  2515             }
       
  2516 
       
  2517 #else // __KEEP_DRM_CONTENT_ON_PHONE
       
  2518         if ( ( (prop->TypeL() & CFileManagerItemProperties::EForwardLocked)
       
  2519                  == CFileManagerItemProperties::EForwardLocked ) == !aMode )
       
  2520             {
       
  2521             ret = !aMode;
       
  2522             }
       
  2523 #endif // __KEEP_DRM_CONTENT_ON_PHONE
       
  2524         CleanupStack::PopAndDestroy( prop );
       
  2525         ++i;
       
  2526         }
       
  2527     CleanupStack::PopAndDestroy( indexArray );
       
  2528     return ret;
       
  2529     }
       
  2530 
       
  2531 // ------------------------------------------------------------------------------
       
  2532 // CFileManagerViewBase::ShowContextSensitiveMenuL
       
  2533 //
       
  2534 // ------------------------------------------------------------------------------
       
  2535 //
       
  2536 void CFileManagerViewBase::ShowContextSensitiveMenuL()
       
  2537     {
       
  2538     CEikMenuBar* menu = MenuBar();
       
  2539     // set context sensitive menu
       
  2540     menu->SetMenuTitleResourceId( R_FILEMANAGER_CONTEXT_SENSITIVE_MENUBAR );
       
  2541     // show context sensitive menu
       
  2542     TRAPD( err, menu->TryDisplayMenuBarL() );
       
  2543     menu->SetMenuTitleResourceId( R_FILEMANAGER_MEMORY_STORE_MENUBAR );
       
  2544     User::LeaveIfError( err );
       
  2545     }
       
  2546 
       
  2547 // ------------------------------------------------------------------------------
       
  2548 // CFileManagerViewBase::ClearProgressBarL
       
  2549 //
       
  2550 // ------------------------------------------------------------------------------
       
  2551 //
       
  2552 void CFileManagerViewBase::ClearProgressBarL()
       
  2553     {
       
  2554     FUNC_LOG
       
  2555 
       
  2556     iProgressInfo = NULL;
       
  2557 
       
  2558     if ( iProgressDialog )
       
  2559         {
       
  2560         iProgressDialog->ProcessFinishedL();
       
  2561         iProgressDialog = NULL;
       
  2562         }
       
  2563     if ( iProgressDialogRefresh )
       
  2564         {
       
  2565         iProgressDialogRefresh->ProcessFinishedL();
       
  2566         iProgressDialogRefresh = NULL;
       
  2567         }
       
  2568     delete iPeriodic;
       
  2569     iPeriodic = NULL;
       
  2570 
       
  2571     delete iRefreshProgressDelayedStart;
       
  2572     iRefreshProgressDelayedStart = NULL;
       
  2573 
       
  2574     iTotalTransferredBytes = 0;
       
  2575     }
       
  2576 
       
  2577 // ------------------------------------------------------------------------------
       
  2578 // CFileManagerViewBase::StoreIndex
       
  2579 //
       
  2580 // ------------------------------------------------------------------------------
       
  2581 //
       
  2582 TBool CFileManagerViewBase::StoreIndex()
       
  2583     {
       
  2584     if ( iContainer )
       
  2585         {
       
  2586         TInt index( iContainer->ListBoxCurrentItemIndex() );
       
  2587         if ( index >= 0 &&
       
  2588             index < iContainer->ListBoxNumberOfItems() )
       
  2589             {
       
  2590             iIndex = index; // Store view's internal index
       
  2591 
       
  2592             // Store navigation index
       
  2593             TUid viewId( Id() );
       
  2594             if ( viewId == CFileManagerAppUi::KFileManagerMemoryStoreViewId ||
       
  2595                  viewId == CFileManagerAppUi::KFileManagerFoldersViewId )
       
  2596                 {
       
  2597                 iEngine.SetCurrentIndex( index );
       
  2598                 }
       
  2599             }
       
  2600         }
       
  2601     else
       
  2602         {
       
  2603         return EFalse;
       
  2604         }
       
  2605     return ETrue;
       
  2606     }
       
  2607 
       
  2608 // ------------------------------------------------------------------------------
       
  2609 // CFileManagerViewBase::DriveReadOnlyMmcL
       
  2610 //
       
  2611 // ------------------------------------------------------------------------------
       
  2612 //
       
  2613 TBool CFileManagerViewBase::DriveReadOnlyMmcL( const TInt aDrive ) const
       
  2614     {
       
  2615     TBool ret( EFalse );
       
  2616     TUint32 drvState( 0 );
       
  2617     TInt err( iEngine.DriveState( drvState, aDrive ) );
       
  2618     if ( err == KErrNone &&
       
  2619         ( drvState & TFileManagerDriveInfo::EDriveWriteProtected ) )
       
  2620         {
       
  2621         ret = ETrue;
       
  2622         }
       
  2623     if ( ret )
       
  2624         {
       
  2625 #ifdef RD_MULTIPLE_DRIVE
       
  2626         HBufC* text = iEngine.GetFormattedDriveNameLC(
       
  2627             aDrive,
       
  2628             R_QTN_MEMC_MULTIPLE_MEMC_READ_ONLY );
       
  2629         FileManagerDlgUtils::ShowErrorNoteL( *text );
       
  2630         CleanupStack::PopAndDestroy( text );
       
  2631 #else // RD_MULTIPLE_DRIVE
       
  2632         FileManagerDlgUtils::ShowErrorNoteL(
       
  2633             R_QTN_MEMC_MEMORYCARD_READ_ONLY );
       
  2634 #endif // RD_MULTIPLE_DRIVE
       
  2635         }
       
  2636 
       
  2637     return ret;
       
  2638     }
       
  2639 
       
  2640 
       
  2641 // ------------------------------------------------------------------------------
       
  2642 // CFileManagerViewBase::DriveReadOnlyMmcL
       
  2643 //
       
  2644 // ------------------------------------------------------------------------------
       
  2645 //
       
  2646 TBool CFileManagerViewBase::DriveReadOnlyMmcL( const TDesC& aFullPath ) const
       
  2647     {
       
  2648     TBool ret( EFalse );
       
  2649     if ( aFullPath.Length() )
       
  2650         {
       
  2651         TInt drive = TDriveUnit( aFullPath );
       
  2652         ret = DriveReadOnlyMmcL( drive );
       
  2653         }
       
  2654     return ret;
       
  2655     }
       
  2656 
       
  2657 // ------------------------------------------------------------------------------
       
  2658 // CFileManagerViewBase::CurrentProcess
       
  2659 //
       
  2660 // ------------------------------------------------------------------------------
       
  2661 //
       
  2662 MFileManagerProcessObserver::TFileManagerProcess CFileManagerViewBase::CurrentProcess()
       
  2663     {
       
  2664     return iActiveProcess;
       
  2665     }
       
  2666 
       
  2667 // ------------------------------------------------------------------------------
       
  2668 // CFileManagerViewBase::Error
       
  2669 //
       
  2670 // ------------------------------------------------------------------------------
       
  2671 //
       
  2672 void CFileManagerViewBase::Error( TInt aError )
       
  2673     {
       
  2674     if ( aError != KErrNone )
       
  2675         {
       
  2676         ERROR_LOG1( "CFileManagerViewBase::Error()-aError=%d", aError )
       
  2677         iEikonEnv->HandleError( aError );
       
  2678         }
       
  2679     }
       
  2680 
       
  2681 // ------------------------------------------------------------------------------
       
  2682 // CFileManagerViewBase::AddSendOptionL
       
  2683 //
       
  2684 // ------------------------------------------------------------------------------
       
  2685 //
       
  2686 void CFileManagerViewBase::AddSendOptionL(
       
  2687         CEikMenuPane& aMenuPane,
       
  2688         const TInt aCommandIdAfter )
       
  2689     {
       
  2690     CSendUi& sendUi( static_cast< CFileManagerAppUi* >( AppUi() )->SendUiL() );
       
  2691     TInt pos( 0 );
       
  2692     aMenuPane.ItemAndPos( aCommandIdAfter, pos );
       
  2693     CArrayFixFlat< TInt >* indexArray = MarkedArrayLC();
       
  2694     TInt msgSize( KMessageSize );
       
  2695     if ( indexArray->Count() == 1 && 
       
  2696          !iEngine.IsFolder( indexArray->At( 0 ) ) )
       
  2697         {
       
  2698         msgSize = Int64ToInt( iEngine.GetFileSizesL( *indexArray ) );
       
  2699         }
       
  2700     CleanupStack::PopAndDestroy( indexArray );
       
  2701     TSendingCapabilities caps(
       
  2702         0, msgSize, TSendingCapabilities::ESupportsAttachments );
       
  2703     sendUi.AddSendMenuItemL( aMenuPane, pos, EFileManagerSend, caps );
       
  2704     aMenuPane.SetItemSpecific(EFileManagerSend, ETrue);
       
  2705     }
       
  2706 
       
  2707 // ------------------------------------------------------------------------------
       
  2708 // CFileManagerViewBase::DeleteStatusNotOk
       
  2709 //
       
  2710 // ------------------------------------------------------------------------------
       
  2711 //
       
  2712 TBool CFileManagerViewBase::DeleteStatusNotOkL(
       
  2713         CFileManagerItemProperties& aProp, TInt aSelectionCount ) const
       
  2714     {
       
  2715     if ( DriveReadOnlyMmcL( aProp.FullPath() ) )
       
  2716         {
       
  2717         // Can't delete from read-only MMC card
       
  2718         return ETrue;
       
  2719         }
       
  2720 
       
  2721     TUint32 itemType( aProp.TypeL() );
       
  2722     if ( !aSelectionCount &&
       
  2723         ( itemType & KDefaultFolderMask ) == KDefaultFolderMask )
       
  2724         {
       
  2725         // Can't delete default folder
       
  2726         FileManagerDlgUtils::ShowErrorNoteL(
       
  2727             R_QTN_FMGR_ERROR_DEL_DEF_FLDR );
       
  2728         return ETrue;
       
  2729         }
       
  2730     if ( aSelectionCount <= 1 &&
       
  2731         ( itemType & CFileManagerItemProperties::EOpen ) )
       
  2732         {
       
  2733         // Can't delete open file
       
  2734         FileManagerDlgUtils::ShowErrorNoteL(
       
  2735             R_QTN_FMGR_ERROR_DELETE_FILE_OPEN );
       
  2736         return ETrue;
       
  2737         }
       
  2738 
       
  2739     return EFalse;
       
  2740     }
       
  2741 
       
  2742 // ------------------------------------------------------------------------------
       
  2743 // CFileManagerViewBase::DeleteItemsL
       
  2744 //
       
  2745 // ------------------------------------------------------------------------------
       
  2746 //
       
  2747 void CFileManagerViewBase::DeleteItemsL( TInt aIndex )
       
  2748     {
       
  2749     
       
  2750     CArrayFixFlat<TInt>* deleteArray = MarkedArrayLC();
       
  2751     TInt newIndex( MinIndex( *deleteArray ) );
       
  2752     delete iActiveDelete;
       
  2753     iActiveDelete = NULL;
       
  2754     iActiveDelete = iEngine.CreateActiveDeleteL( *deleteArray );
       
  2755     delete iWaitNoteWrapper;
       
  2756     iWaitNoteWrapper = NULL;
       
  2757     iWaitNoteWrapper = CAknWaitNoteWrapper::NewL();
       
  2758     iActiveProcess = EDeleteProcess;
       
  2759     TRAPD( err, iWaitNoteWrapper->ExecuteL(
       
  2760         R_FILEMANAGER_DELETE_WAIT_DIALOG, *iActiveDelete ) );
       
  2761     iActiveProcess = ENoProcess;
       
  2762     User::LeaveIfError( err );
       
  2763 
       
  2764     HBufC* fileNameBuf = HBufC::NewLC( KMaxFileName );
       
  2765     TPtr fileName( fileNameBuf->Des() );
       
  2766 
       
  2767     err = iActiveDelete->GetError( fileName );
       
  2768 
       
  2769     switch ( err )
       
  2770         {
       
  2771         case KErrInUse:
       
  2772         case KErrFmgrSeveralFilesInUse:
       
  2773             {
       
  2774             ERROR_LOG1( "CFileManagerViewBase::DeleteItemsL()-err=%d", err )
       
  2775             if ( iEngine.IsFolder( aIndex ) )
       
  2776                 {
       
  2777                 if ( err == KErrFmgrSeveralFilesInUse )
       
  2778                     {
       
  2779                     FileManagerDlgUtils::ShowErrorNoteL(
       
  2780                         R_QTN_FMGR_ERROR_DEL_FLDR_OPEN_SE );
       
  2781                     }
       
  2782                 else
       
  2783                     {
       
  2784                     FileManagerDlgUtils::ShowErrorNoteL(
       
  2785                         R_QTN_FMGR_ERROR_DEL_FLDR_OPEN_1 );
       
  2786                     }
       
  2787                 }
       
  2788             else
       
  2789                 {
       
  2790                 FileManagerDlgUtils::ShowErrorNoteL(
       
  2791                     R_QTN_FMGR_ERROR_DELETE_FILE_OPEN );
       
  2792                 }
       
  2793             break;
       
  2794             }
       
  2795         case KErrNone:
       
  2796             {
       
  2797             if ( iContainer )
       
  2798                 {
       
  2799                 //CEikListBox& listBox( iContainer->ListBox() );
       
  2800                 //AknSelectionService::HandleItemRemovalAndPositionHighlightL(  
       
  2801                 //    &listBox, listBox.CurrentItemIndex(), *deleteArray);
       
  2802 
       
  2803 #ifndef RD_DRM_RIGHTS_MANAGER_REMOVAL
       
  2804                 if ( FeatureManager().IsDrmFullSupported() )
       
  2805                     {
       
  2806                     TInt deletedItems( 0 );
       
  2807                     TInt deletedDrmItems( iActiveDelete->DeletedDrmItems( deletedItems ) );
       
  2808                     if( deletedDrmItems )
       
  2809                         {
       
  2810                         if( deletedDrmItems > 1 )
       
  2811                             {
       
  2812                             FileManagerDlgUtils::ShowInfoQueryL(
       
  2813                                 R_QTN_DRM_MOS_DELETED, deletedDrmItems );
       
  2814                             }
       
  2815                         else
       
  2816                             {
       
  2817                             FileManagerDlgUtils::ShowInfoQueryL(
       
  2818                                 R_QTN_DRM_MO_DELETED, fileName );
       
  2819                             }
       
  2820                         }
       
  2821                     }
       
  2822 #endif // RD_DRM_RIGHTS_MANAGER_REMOVAL
       
  2823 
       
  2824                 // Set focus to the item after selection
       
  2825                 iContainer->SetIndex( newIndex );
       
  2826                 }
       
  2827             break;
       
  2828             }
       
  2829         default:
       
  2830             {
       
  2831             ERROR_LOG1( "CFileManagerViewBase::DeleteItemsL()-err=%d", err )
       
  2832             FileManagerDlgUtils::ShowErrorNoteL(
       
  2833                 R_QTN_FLDR_CANT_DELETE_ITEM, fileName );
       
  2834             break;
       
  2835             }
       
  2836         }
       
  2837     CleanupStack::PopAndDestroy( fileNameBuf );
       
  2838     CleanupStack::PopAndDestroy( deleteArray );
       
  2839     StoreIndex();
       
  2840     iEngine.SetObserver( this );
       
  2841     iEngine.RefreshDirectory();
       
  2842     }
       
  2843 
       
  2844 // ------------------------------------------------------------------------------
       
  2845 // CFileManagerViewBase::HasInfoUrlL
       
  2846 //
       
  2847 // ------------------------------------------------------------------------------
       
  2848 //
       
  2849 TBool CFileManagerViewBase::HasInfoUrlL( TInt aIndex )
       
  2850     {
       
  2851     if ( iEngine.IsFolder( aIndex ) )
       
  2852         {
       
  2853         return EFalse;
       
  2854         }
       
  2855     TBool hasUrl( EFalse );
       
  2856     HBufC8* url = NULL;
       
  2857     HBufC* fullPath = iEngine.IndexToFullPathLC( aIndex );
       
  2858     CDRMHelper* drmHelper = CDRMHelper::NewLC( *iEikonEnv );
       
  2859 
       
  2860     TRAPD( err, hasUrl = drmHelper->HasInfoUrlL( *fullPath, url ) );
       
  2861     if ( hasUrl && url && err == KErrNone )
       
  2862         {
       
  2863         hasUrl = url->Length() > 0;
       
  2864         }
       
  2865     else
       
  2866         {
       
  2867         hasUrl = EFalse;
       
  2868         }
       
  2869 
       
  2870     ERROR_LOG2( "CFileManagerViewBase::HasInfoUrlL()-hasUrl=%d,err=%d", hasUrl, err )
       
  2871 
       
  2872     delete url;
       
  2873     CleanupStack::PopAndDestroy( drmHelper );
       
  2874     CleanupStack::PopAndDestroy( fullPath );
       
  2875     return hasUrl;
       
  2876     }
       
  2877 
       
  2878 // ------------------------------------------------------------------------------
       
  2879 // CFileManagerViewBase::OpenInfoUrlL
       
  2880 //
       
  2881 // ------------------------------------------------------------------------------
       
  2882 //
       
  2883 void CFileManagerViewBase::OpenInfoUrlL( TInt aIndex )
       
  2884     {
       
  2885     if ( iEngine.IsFolder( aIndex ) )
       
  2886         {
       
  2887         return;
       
  2888         }
       
  2889     HBufC* fullPath = iEngine.IndexToFullPathLC( aIndex );
       
  2890     CDRMHelper* drmHelper = CDRMHelper::NewLC( *iEikonEnv );
       
  2891 
       
  2892     // Call returns after browser has been closed
       
  2893 #ifdef FILE_MANAGER_ERROR_LOG_ENABLED
       
  2894     TRAPD( err, drmHelper->OpenInfoUrlL( *fullPath ) );
       
  2895     ERROR_LOG1( "CFileManagerViewBase::OpenInfoUrlL()-err=%d", err )
       
  2896 #else // FILE_MANAGER_ERROR_LOG_ENABLED
       
  2897     TRAP_IGNORE( drmHelper->OpenInfoUrlL( *fullPath ) );
       
  2898 #endif // FILE_MANAGER_ERROR_LOG_ENABLED
       
  2899 
       
  2900     CleanupStack::PopAndDestroy( drmHelper );
       
  2901     CleanupStack::PopAndDestroy( fullPath );
       
  2902     }
       
  2903 
       
  2904 // ------------------------------------------------------------------------------
       
  2905 // CFileManagerViewBase::CheckFileRightsAndInformIfExpiredL
       
  2906 //
       
  2907 // ------------------------------------------------------------------------------
       
  2908 //
       
  2909 TBool CFileManagerViewBase::CheckFileRightsAndInformIfExpiredL(
       
  2910         const TDesC& aFullPath )
       
  2911     {
       
  2912     if ( !FeatureManager().IsDrmFullSupported() )
       
  2913         {
       
  2914         return ETrue;
       
  2915         }
       
  2916     TBool expired( EFalse );
       
  2917     TBool wmDrm( IsWmDrmFile( aFullPath ) );
       
  2918     if ( !wmDrm ) // Ignore WM DRM files
       
  2919         {
       
  2920         TBool dummy( EFalse );
       
  2921         CDRMHelperRightsConstraints* dummy2 = NULL;
       
  2922         CDRMHelperRightsConstraints* dummy3 = NULL;
       
  2923         CDRMHelperRightsConstraints* dummy4 = NULL;
       
  2924         CDRMHelperRightsConstraints* dummy5 = NULL;
       
  2925         CDRMHelper* drmHelper = CDRMHelper::NewLC( *iEikonEnv );
       
  2926         TRAPD( err, drmHelper->GetRightsDetailsL(
       
  2927             aFullPath, 0, expired, dummy, dummy2, dummy3, dummy4, dummy5 ) );
       
  2928         delete dummy2;
       
  2929         delete dummy3;
       
  2930         delete dummy4;
       
  2931         delete dummy5;
       
  2932         if ( expired )
       
  2933             {
       
  2934             err = KErrCANoPermission;
       
  2935             }
       
  2936         if ( err == KErrCANoRights || err == KErrCANoPermission )
       
  2937             {
       
  2938             // Rights expired or missing, show note or try get silent rights
       
  2939             expired = ETrue;
       
  2940             ERROR_LOG1( "CFileManagerViewBase::CheckFileRightsAndInformIfExpiredL-err=%d",
       
  2941                 err )
       
  2942             HBufC8* previewUri = NULL;
       
  2943             if ( drmHelper->HandleErrorOrPreviewL( err, aFullPath, previewUri ) == KErrNone )
       
  2944                 {
       
  2945                 expired = EFalse;
       
  2946                 }
       
  2947             delete previewUri; // Not needed
       
  2948             }
       
  2949         CleanupStack::PopAndDestroy( drmHelper );
       
  2950         }
       
  2951     ERROR_LOG2(
       
  2952         "CFileManagerViewBase::CheckFileRightsAndInformIfExpiredL-expired=%d,wmDrm=%d",
       
  2953         expired, wmDrm )
       
  2954     return !expired;
       
  2955     }
       
  2956 
       
  2957 // ------------------------------------------------------------------------------
       
  2958 // CFileManagerViewBase::HandleFileNotFoundL
       
  2959 //
       
  2960 // ------------------------------------------------------------------------------
       
  2961 //
       
  2962 TBool CFileManagerViewBase::HandleFileNotFoundL( TInt aError )
       
  2963     {
       
  2964     if ( aError == KErrNotFound )
       
  2965         {
       
  2966         iEngine.SetObserver( this );
       
  2967         iEngine.RefreshDirectory();
       
  2968         return ETrue;
       
  2969         }
       
  2970     if ( aError == KErrPathNotFound )
       
  2971         {
       
  2972         TInt count( iEngine.FolderLevel() );
       
  2973         TBool connectedRemoteDrive( EFalse );
       
  2974         RefreshDriveInfoL();
       
  2975 
       
  2976         TFileManagerDriveInfo& drvInfo( DriveInfo() );
       
  2977         TBool remoteDrive( EFalse );
       
  2978         // Check if drive is remote drive and is it connected or not
       
  2979         if ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote )
       
  2980             {
       
  2981             remoteDrive = ETrue;
       
  2982             if ( drvInfo.iState & TFileManagerDriveInfo::EDriveConnected )
       
  2983                 {
       
  2984                 connectedRemoteDrive = ETrue;
       
  2985                 }
       
  2986             }
       
  2987         // Check if drive has been disconnected and reconnect canceled
       
  2988         if ( remoteDrive && !connectedRemoteDrive )
       
  2989             {
       
  2990             // Do only root refresh if user is already got back in main view
       
  2991             if ( Id() == CFileManagerAppUi::KFileManagerMainViewId && 
       
  2992                 iEngine.NavigationLevel() < 0 )
       
  2993                 {
       
  2994                 iEngine.SetObserver( this );
       
  2995                 iEngine.RefreshDirectory();
       
  2996                 }
       
  2997             // Open memory store view to show not connected.
       
  2998             else if ( Id() != CFileManagerAppUi::KFileManagerMemoryStoreViewId )
       
  2999                 {
       
  3000                 iIndex = 0;
       
  3001                 static_cast< CFileManagerAppUi* >( AppUi() )->ActivateMemoryStoreViewL();
       
  3002                 }
       
  3003             else
       
  3004                 {
       
  3005                 iIndex = 0;
       
  3006                 if ( iContainer )
       
  3007                     {
       
  3008                     iContainer->SetListEmptyL();
       
  3009                     }
       
  3010                 DirectoryChangedL();
       
  3011                 }
       
  3012             }
       
  3013         // Check if fetch was canceled in connected memory store view
       
  3014         else if ( connectedRemoteDrive &&
       
  3015                  Id() == CFileManagerAppUi::KFileManagerMemoryStoreViewId )
       
  3016             {
       
  3017             static_cast< CFileManagerAppUi* >( AppUi() )->ActivateMainViewL();
       
  3018             }
       
  3019         else if ( count > 0 &&
       
  3020             ( connectedRemoteDrive ||
       
  3021               !BaflUtils::PathExists(
       
  3022                 iEikonEnv->FsSession(), iEngine.CurrentDirectory() ) ) )
       
  3023             {
       
  3024             // Go back to last valid folder
       
  3025             CFileManagerAppUi* appUi =
       
  3026                 static_cast< CFileManagerAppUi* >( AppUi() );
       
  3027             TInt err( KErrNone );
       
  3028             for ( TInt i( 0 ); i < count; i++ )
       
  3029                 {
       
  3030                 TRAP( err, iEngine.BackstepL() );
       
  3031                 if ( err == KErrNone )
       
  3032                     {
       
  3033                     break;
       
  3034                     }
       
  3035                 }
       
  3036             if ( iEngine.FolderLevel() ||
       
  3037                  iEngine.State() == CFileManagerEngine::ESearch )
       
  3038                 {
       
  3039                 iEngine.SetObserver( this );
       
  3040                 iEngine.RefreshDirectory();
       
  3041                 }
       
  3042             else
       
  3043                 {
       
  3044                 appUi->CloseFoldersViewL();
       
  3045                 }
       
  3046             }
       
  3047         else
       
  3048             {
       
  3049             // Refresh root folder
       
  3050             iEngine.SetObserver( this );
       
  3051             iEngine.RefreshDirectory();
       
  3052             }
       
  3053         return ETrue;
       
  3054         }
       
  3055     return EFalse;
       
  3056     }
       
  3057 
       
  3058 // ------------------------------------------------------------------------------
       
  3059 // CFileManagerViewBase::ScreenDeviceChanged
       
  3060 //
       
  3061 // ------------------------------------------------------------------------------
       
  3062 //
       
  3063 void CFileManagerViewBase::ScreenDeviceChanged()
       
  3064     {
       
  3065     if ( iContainer )
       
  3066         {
       
  3067         iContainer->SetRect( ClientRect() );
       
  3068         iContainer->DrawDeferred();
       
  3069         }
       
  3070     }
       
  3071 
       
  3072 // ------------------------------------------------------------------------------
       
  3073 // CFileManagerViewBase::NotifyL
       
  3074 //
       
  3075 // ------------------------------------------------------------------------------
       
  3076 //
       
  3077 TInt CFileManagerViewBase::NotifyL( TFileManagerNotify aType,
       
  3078         TInt aData, const TDesC& aName )
       
  3079     {
       
  3080     TInt ret( KErrNone );
       
  3081     switch ( aType )
       
  3082         {
       
  3083         case ENotifyDisksChanged:
       
  3084             {
       
  3085             if ( iDirectoryRefreshDenied )
       
  3086                 {
       
  3087                 iDirectoryRefreshPostponed = ETrue;
       
  3088                 }
       
  3089             else if ( iActiveProcess == ENoProcess && !IsRefreshInProgress() )
       
  3090                 {
       
  3091                 StoreIndex();
       
  3092                 iEngine.SetObserver( this );
       
  3093                 iEngine.RefreshDirectory();
       
  3094                 }
       
  3095 #ifndef RD_MULTIPLE_DRIVE
       
  3096             else if ( iActiveProcess == EEjectProcess )
       
  3097                 {
       
  3098                 // Memory card was put back, complete query
       
  3099                 if ( iEngine.AnyEjectableDrivePresent() )
       
  3100                     {
       
  3101                     delete iEjectQueryDialog;
       
  3102                     iEjectQueryDialog = NULL;
       
  3103                     }
       
  3104                 }
       
  3105 #endif // RD_MULTIPLE_DRIVE
       
  3106             break;
       
  3107             }
       
  3108         case ENotifyBackupMemoryLow:
       
  3109             {
       
  3110             if( aData < KEstimateLowerLimit )
       
  3111                 {
       
  3112                 ret = KErrDiskFull;
       
  3113                 }
       
  3114             else if( aData < KEstimateUpperLimit )
       
  3115                 {
       
  3116 
       
  3117 #ifdef RD_FILE_MANAGER_BACKUP
       
  3118                 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() );
       
  3119 #endif // RD_FILE_MANAGER_BACKUP
       
  3120 
       
  3121                 if ( !FileManagerDlgUtils::ShowConfirmQueryWithYesNoL(
       
  3122 #ifdef RD_FILE_MANAGER_BACKUP
       
  3123                         R_QTN_FMGR_BACKUP_TIGHT_MEMORY,
       
  3124                         iEngine.DriveName( settings.TargetDrive() )
       
  3125 #else // RD_FILE_MANAGER_BACKUP
       
  3126                         R_QTN_CONFIRM_BACKUP_LEVEL1
       
  3127 #endif // RD_FILE_MANAGER_BACKUP
       
  3128                      ) )
       
  3129                     {
       
  3130                     ret = KErrCancel;
       
  3131                     }
       
  3132                 }
       
  3133             break;
       
  3134             }
       
  3135         case ENotifyForcedFormat:
       
  3136             {
       
  3137             StopProgressDialogAndStoreValues();
       
  3138 
       
  3139             TInt textId( R_QTN_CONFIRM_FORMAT_TEXT2 );
       
  3140 #ifdef RD_MULTIPLE_DRIVE
       
  3141             if ( DriveInfo().iState & TFileManagerDriveInfo::EDriveMassStorage )
       
  3142                 {
       
  3143                 textId = R_QTN_FMGR_FORMAT_MASS_QUERY2;
       
  3144                 }
       
  3145 #endif // RD_MULTIPLE_DRIVE
       
  3146 
       
  3147             TBool query( FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( textId ) );
       
  3148             LaunchProgressDialogL(
       
  3149                 iProgressFinalValue, iProgressCurrentValue, iActiveProcess );
       
  3150             return query;
       
  3151             }
       
  3152         case ENotifyFileOpenDenied:
       
  3153             {
       
  3154             TBool launchProgress( StopProgressDialogAndStoreValues() );
       
  3155 
       
  3156             ret = !CheckFileRightsAndInformIfExpiredL( aName );
       
  3157             if ( launchProgress )
       
  3158                 {
       
  3159                 LaunchProgressDialogL(
       
  3160                     iProgressFinalValue, iProgressCurrentValue, iActiveProcess );
       
  3161                 }
       
  3162             break;
       
  3163             }
       
  3164         default:
       
  3165             {
       
  3166             break;
       
  3167             }
       
  3168         }
       
  3169     return ret;
       
  3170     }
       
  3171 
       
  3172 // ------------------------------------------------------------------------------
       
  3173 // CFileManagerViewBase::MemoryStoreMenuFilteringL
       
  3174 //
       
  3175 // ------------------------------------------------------------------------------
       
  3176 //
       
  3177 void CFileManagerViewBase::MemoryStoreMenuFilteringL(
       
  3178         CEikMenuPane& aMenuPane )
       
  3179     {
       
  3180     TBool isSearchOn( iEngine.State() == CFileManagerEngine::ESearch );
       
  3181     TRAP_IGNORE ( RefreshDriveInfoL() );
       
  3182     TFileManagerDriveInfo& drvInfo( DriveInfo() );   
       
  3183     TInt driveNumber = drvInfo.iDrive;
       
  3184     iEngine.GetDriveInfoL(driveNumber,drvInfo);
       
  3185 
       
  3186     // Common remote drive filtering
       
  3187     RemoteDriveCommonFilteringL( aMenuPane );
       
  3188     
       
  3189     CFileManagerFeatureManager& featureManager( FeatureManager() );
       
  3190     
       
  3191 #ifdef RD_MULTIPLE_DRIVE
       
  3192     // No format item for mass storage in embedded mode dimming
       
  3193     if ( !( drvInfo.iState & TFileManagerDriveInfo::EDriveFormattable ) )
       
  3194         {
       
  3195         aMenuPane.SetItemDimmed( EFileManagerFormatMassStorage, ETrue );
       
  3196         }
       
  3197 #endif // RD_MULTIPLE_DRIVE
       
  3198 
       
  3199     // Memory store specific remote drive filtering
       
  3200     if ( !featureManager.IsRemoteStorageFwSupported() ||
       
  3201          !( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote ) ||
       
  3202          !( drvInfo.iState & TFileManagerDriveInfo::EDriveConnected ) )
       
  3203         {
       
  3204         // For disconnected or non remote drive
       
  3205         aMenuPane.SetItemDimmed( EFileManagerRefreshRemoteDrive, ETrue );
       
  3206         }
       
  3207 
       
  3208     if ( !featureManager.IsHelpSupported() )
       
  3209         {
       
  3210         // No help item dimming
       
  3211         aMenuPane.SetItemDimmed( EAknCmdHelp, ETrue );
       
  3212         }
       
  3213     if ( !featureManager.IsIrdaSupported() )
       
  3214         {
       
  3215         // No infra red item dimming
       
  3216         aMenuPane.SetItemDimmed( EFileManagerReceiveViaIR, ETrue );
       
  3217         }
       
  3218     if ( isSearchOn )
       
  3219         {
       
  3220         // Search view item dimming
       
  3221         aMenuPane.SetItemDimmed( EFileManagerRename, ETrue );
       
  3222         aMenuPane.SetItemDimmed( EFileManagerReceiveViaIR, ETrue );
       
  3223         aMenuPane.SetItemDimmed( EFileManagerOrganise, ETrue );
       
  3224 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCard, ETrue );
       
  3225 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCardPassword, ETrue );
       
  3226         //aMenuPane.SetItemDimmed( EFileManagerUnlockMemoryCard, ETrue );
       
  3227         aMenuPane.SetItemDimmed( EFileManagerRefreshRemoteDrive, ETrue );
       
  3228 #ifdef RD_MULTIPLE_DRIVE
       
  3229         aMenuPane.SetItemDimmed( EFileManagerFormatMassStorage, ETrue );
       
  3230 #endif // RD_MULTIPLE_DRIVE
       
  3231         aMenuPane.SetItemDimmed( EFileManagerSort, ETrue );
       
  3232         }
       
  3233     else
       
  3234         {
       
  3235         aMenuPane.SetItemDimmed( EFileManagerSearchSort, ETrue );
       
  3236         }
       
  3237        //dim the item unconditionally 
       
  3238         aMenuPane.SetItemDimmed( EFileManagerFormatMassStorage, ETrue );
       
  3239     if ( drvInfo.iState & TFileManagerDriveInfo::EDriveWriteProtected )
       
  3240         {
       
  3241         // Write protected item dimming
       
  3242         aMenuPane.SetItemDimmed( EFileManagerRename, ETrue );
       
  3243         aMenuPane.SetItemDimmed( EFileManagerDelete, ETrue );
       
  3244         aMenuPane.SetItemDimmed( EFileManagerReceiveViaIR, ETrue );
       
  3245 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCard, ETrue );
       
  3246 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCardPassword, ETrue );
       
  3247 #ifdef RD_MULTIPLE_DRIVE
       
  3248         aMenuPane.SetItemDimmed( EFileManagerFormatMassStorage, ETrue );
       
  3249 #endif // RD_MULTIPLE_DRIVE
       
  3250         }
       
  3251 
       
  3252 #ifdef RD_MULTIPLE_DRIVE
       
  3253     if ( drvInfo.iState & TFileManagerDriveInfo::EDriveMassStorage )
       
  3254         {
       
  3255         // Mass storage item dimming
       
  3256 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCard, ETrue );
       
  3257 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCardPassword, ETrue );
       
  3258         aMenuPane.SetItemDimmed( EFileManagerUnlockMemoryCard, ETrue );
       
  3259 
       
  3260         if ( !( drvInfo.iState & TFileManagerDriveInfo::EDrivePresent ) )
       
  3261             {
       
  3262             aMenuPane.SetItemDimmed( EFileManagerFormatMassStorage, ETrue );
       
  3263             }
       
  3264         }
       
  3265     else
       
  3266 #endif // RD_MULTIPLE_DRIVE
       
  3267     if ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable )
       
  3268         {
       
  3269         // Memory card item dimming
       
  3270         if ( !( drvInfo.iState & TFileManagerDriveInfo::EDrivePresent ) ||
       
  3271              ( drvInfo.iState & ( TFileManagerDriveInfo::EDriveCorrupted |
       
  3272                                   TFileManagerDriveInfo::EDriveLocked ) ) )
       
  3273             {
       
  3274 //            aMenuPane.SetItemDimmed( EFileManagerMemoryCardPassword, ETrue );
       
  3275             aMenuPane.SetItemDimmed( EFileManagerDetails, ETrue );
       
  3276             }
       
  3277         if ( ( drvInfo.iState & TFileManagerDriveInfo::EDriveCorrupted ) ||
       
  3278              !( drvInfo.iState & TFileManagerDriveInfo::EDriveLocked ) )
       
  3279             {
       
  3280             aMenuPane.SetItemDimmed( EFileManagerUnlockMemoryCard, ETrue );
       
  3281             }
       
  3282 //        if ( !( drvInfo.iState & TFileManagerDriveInfo::EDriveLockable ) )
       
  3283 //            {
       
  3284 //            aMenuPane.SetItemDimmed( EFileManagerMemoryCardPassword, ETrue );
       
  3285 //            }
       
  3286         if ( !featureManager.IsMmcPassWdSupported() )
       
  3287             {
       
  3288             //aMenuPane.SetItemDimmed( EFileManagerMemoryCardPassword, ETrue );
       
  3289             aMenuPane.SetItemDimmed( EFileManagerUnlockMemoryCard, ETrue );
       
  3290             }
       
  3291 #ifdef RD_MULTIPLE_DRIVE
       
  3292         aMenuPane.SetItemDimmed( EFileManagerFormatMassStorage, ETrue );
       
  3293 #endif // RD_MULTIPLE_DRIVE
       
  3294         }
       
  3295     else
       
  3296         {
       
  3297         // No mass storage or memory card item dimming
       
  3298 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCard, ETrue );
       
  3299 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCardPassword, ETrue );
       
  3300         aMenuPane.SetItemDimmed( EFileManagerUnlockMemoryCard, ETrue );
       
  3301 #ifdef RD_MULTIPLE_DRIVE
       
  3302         aMenuPane.SetItemDimmed( EFileManagerFormatMassStorage, ETrue );
       
  3303 #endif // RD_MULTIPLE_DRIVE
       
  3304         }
       
  3305 
       
  3306 //    CEikListBox& listBox = iContainer->ListBox();
       
  3307     TBool dimSend( EFalse );
       
  3308 
       
  3309     if ( iContainer->ListBoxSelectionIndexesCount() )
       
  3310         {
       
  3311         // Selections in list
       
  3312         aMenuPane.SetItemDimmed( EFileManagerOpen, ETrue );
       
  3313         aMenuPane.SetItemDimmed( EFileManagerRename, ETrue );
       
  3314         aMenuPane.SetItemDimmed( EFileManagerDetails, ETrue );
       
  3315 
       
  3316         if ( !featureManager.IsDrmFullSupported() &&
       
  3317             AreChosenFilesProtectedL( ETrue ) )
       
  3318             {
       
  3319             dimSend = ETrue;
       
  3320             }
       
  3321 
       
  3322         /* Codes below will cause trouble for large amount file selection
       
  3323         if ( !dimSend )
       
  3324             {
       
  3325             // Check if there are files to send
       
  3326             TInt dummy( 0 );
       
  3327             CArrayFixFlat< TInt >* files = GetSendFilesLC( dummy );
       
  3328             if ( !files->Count() )
       
  3329                 {
       
  3330                 dimSend = ETrue;
       
  3331                 }
       
  3332             CleanupStack::PopAndDestroy( files );
       
  3333             }
       
  3334         */
       
  3335 
       
  3336         // Hide empty details if no item or memory specific details 
       
  3337         // can be shown.
       
  3338         if ( isSearchOn ||
       
  3339             ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote ) )
       
  3340             {
       
  3341             aMenuPane.SetItemDimmed( EFileManagerDetails, ETrue );
       
  3342             }
       
  3343         if ( ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote ) &&
       
  3344              !( drvInfo.iState & TFileManagerDriveInfo::EDriveConnected ) )
       
  3345             {
       
  3346             // Handle disconnected remote drive
       
  3347             dimSend = ETrue;
       
  3348             }
       
  3349         }
       
  3350     else if ( iContainer->ListBoxNumberOfItems() )
       
  3351         {
       
  3352         // There is items in list, check selection type
       
  3353         TUint32 fileType( iEngine.FileTypeL(
       
  3354             iContainer->ListBoxCurrentItemIndex() ) );
       
  3355         if ( ( fileType & KDefaultFolderMask ) == KDefaultFolderMask )
       
  3356             {
       
  3357             dimSend = ETrue;
       
  3358             aMenuPane.SetItemDimmed( EFileManagerDelete, ETrue );
       
  3359             aMenuPane.SetItemDimmed( EFileManagerMark, ETrue );
       
  3360             aMenuPane.SetItemDimmed( EFileManagerRename, ETrue );
       
  3361             }
       
  3362         else if ( fileType & CFileManagerItemProperties::EFolder )
       
  3363             {
       
  3364             dimSend = ETrue;
       
  3365             aMenuPane.SetItemDimmed( EFileManagerMark, ETrue );
       
  3366             }
       
  3367 
       
  3368         if ( fileType & CFileManagerItemProperties::EPlaylist )
       
  3369             {
       
  3370             dimSend = ETrue;
       
  3371             }
       
  3372 
       
  3373         // When full OMA DRM is in use, it is ok to show send option
       
  3374         if( ( fileType & CFileManagerItemProperties::EForwardLocked ) &&
       
  3375             !featureManager.IsDrmFullSupported() )
       
  3376             {
       
  3377             dimSend = ETrue;
       
  3378             }
       
  3379         if ( ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote ) &&
       
  3380              !( drvInfo.iState & TFileManagerDriveInfo::EDriveConnected ) )
       
  3381             {
       
  3382             // Handle disconnected remote drive
       
  3383             dimSend = ETrue;
       
  3384             }
       
  3385         }
       
  3386     else 
       
  3387         {
       
  3388         // List is empty
       
  3389         aMenuPane.SetItemDimmed( EFileManagerOpen, ETrue );
       
  3390         aMenuPane.SetItemDimmed( EFileManagerDelete, ETrue );
       
  3391         aMenuPane.SetItemDimmed( EFileManagerMark, ETrue );
       
  3392         aMenuPane.SetItemDimmed( EFileManagerRename, ETrue );
       
  3393         aMenuPane.SetItemDimmed( EFileManagerSort, ETrue );
       
  3394         aMenuPane.SetItemDimmed( EFileManagerSearchSort, ETrue );
       
  3395         aMenuPane.SetItemDimmed( EFileManagerDetails, ETrue );
       
  3396         dimSend = ETrue;
       
  3397         
       
  3398         if ( drvInfo.iState & TFileManagerDriveInfo::EDriveWriteProtected )
       
  3399             {
       
  3400             // Handle write protected drive
       
  3401             aMenuPane.SetItemDimmed( EFileManagerOrganise, ETrue );
       
  3402             }
       
  3403         if ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote )
       
  3404             {
       
  3405             // Handle empty remote folder
       
  3406             aMenuPane.SetItemDimmed( EFileManagerDetails, ETrue );
       
  3407             }
       
  3408 
       
  3409         if ( ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote ) &&
       
  3410              !( drvInfo.iState & TFileManagerDriveInfo::EDriveConnected ) )
       
  3411             {
       
  3412             // Handle disconnected remote drive
       
  3413             aMenuPane.SetItemDimmed( EFileManagerReceiveViaIR, ETrue );
       
  3414             aMenuPane.SetItemDimmed( EFileManagerOrganise, ETrue );
       
  3415 //            aMenuPane.SetItemDimmed( EFileManagerDetails, ETrue );
       
  3416             }
       
  3417         else if ( !( drvInfo.iState & TFileManagerDriveInfo::EDrivePresent ) ||  
       
  3418                  ( drvInfo.iState & (
       
  3419                     TFileManagerDriveInfo::EDriveCorrupted |
       
  3420                     TFileManagerDriveInfo::EDriveLocked ) ) )
       
  3421             {
       
  3422             // Handle unavailable drive
       
  3423 //            aMenuPane.SetItemDimmed( EFileManagerDetails, ETrue );
       
  3424             aMenuPane.SetItemDimmed( EFileManagerReceiveViaIR, ETrue );
       
  3425             aMenuPane.SetItemDimmed( EFileManagerOrganise, ETrue );
       
  3426 //            aMenuPane.SetItemDimmed( EFileManagerMemoryCardPassword, ETrue );
       
  3427             
       
  3428             if ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable &&
       
  3429                  !( drvInfo.iState & TFileManagerDriveInfo::EDriveLocked ) )
       
  3430                 {
       
  3431                 aMenuPane.SetItemDimmed( EFileManagerUnlockMemoryCard, ETrue );
       
  3432                 }
       
  3433             }
       
  3434         else if ( isSearchOn ||
       
  3435                  !BaflUtils::PathExists(
       
  3436                     iEikonEnv->FsSession(), iEngine.CurrentDirectory() ) )
       
  3437             {
       
  3438             // Handle empty search results and invalid path
       
  3439             if ( isSearchOn || !iEngine.CurrentDirectory().Length() )
       
  3440                 {
       
  3441                 aMenuPane.SetItemDimmed( EFileManagerReceiveViaIR, ETrue );
       
  3442                 aMenuPane.SetItemDimmed( EFileManagerOrganise, ETrue );
       
  3443 //                aMenuPane.SetItemDimmed( EFileManagerMemoryCardPassword, ETrue );
       
  3444 //                aMenuPane.SetItemDimmed( EFileManagerMemoryCard, ETrue );
       
  3445                 aMenuPane.SetItemDimmed( EFileManagerUnlockMemoryCard, ETrue );
       
  3446 //                aMenuPane.SetItemDimmed( EFileManagerDetails, ETrue );
       
  3447                 }
       
  3448             else
       
  3449                 {
       
  3450                 // BaflUtils::PathExists does not work for remote drive root dirs.
       
  3451                 if( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote )
       
  3452                     {
       
  3453                     _LIT( KRootFolder, "?:\\" );
       
  3454                     if ( iEngine.CurrentDirectory().MatchF( KRootFolder ) )
       
  3455                         {
       
  3456                         User::Leave( KErrPathNotFound );
       
  3457                         }
       
  3458                     }
       
  3459                 else
       
  3460                     {
       
  3461                     User::Leave( KErrPathNotFound );
       
  3462                     }
       
  3463                 }
       
  3464             }
       
  3465         }
       
  3466 
       
  3467     if ( !dimSend )
       
  3468         {
       
  3469         AddSendOptionL( aMenuPane, EFileManagerDelete );
       
  3470         }
       
  3471     }
       
  3472 
       
  3473 // ------------------------------------------------------------------------------
       
  3474 // CFileManagerViewBase::OrganiseMenuFilteringL
       
  3475 //
       
  3476 // ------------------------------------------------------------------------------
       
  3477 //
       
  3478 void CFileManagerViewBase::OrganiseMenuFilteringL( CEikMenuPane& aMenuPane )
       
  3479     {
       
  3480 //    CEikListBox& listBox( iContainer->ListBox() );
       
  3481 
       
  3482     if ( iContainer->ListBoxNumberOfItems() )
       
  3483         {
       
  3484         if ( !iContainer->ListBoxSelectionIndexesCount() )
       
  3485             {
       
  3486             TUint32 fileType( iEngine.FileTypeL(
       
  3487                 iContainer->ListBoxCurrentItemIndex() ) );
       
  3488             if ( ( fileType & KDefaultFolderMask ) == KDefaultFolderMask )
       
  3489                 {
       
  3490                 aMenuPane.SetItemDimmed( EFileManagerMoveToFolder, ETrue );
       
  3491                 }
       
  3492             }
       
  3493         }
       
  3494     else
       
  3495         {
       
  3496         aMenuPane.SetItemDimmed( EFileManagerMoveToFolder, ETrue );
       
  3497         aMenuPane.SetItemDimmed( EFileManagerCopyToFolder, ETrue );
       
  3498         }
       
  3499 
       
  3500     // Search view item dimming
       
  3501     if( iEngine.State() == CFileManagerEngine::ESearch )
       
  3502         {
       
  3503         aMenuPane.SetItemDimmed( EFileManagerNewFolder, ETrue );
       
  3504         }
       
  3505 
       
  3506     TFileManagerDriveInfo& drvInfo( DriveInfo() );
       
  3507     if ( drvInfo.iState & TFileManagerDriveInfo::EDriveWriteProtected )
       
  3508         {
       
  3509         // Write protected item dimming
       
  3510         aMenuPane.SetItemDimmed( EFileManagerNewFolder, ETrue );
       
  3511 		}
       
  3512 
       
  3513 	TInt index(iContainer->ListBoxCurrentItemIndex());
       
  3514 	TUint32 fileType(iEngine.FileTypeL(index));
       
  3515 	if (!(fileType & CFileManagerItemProperties::EFolder))
       
  3516 		{
       
  3517 		aMenuPane.SetItemDimmed(EFileManagerMoveToFolder, ETrue);
       
  3518         }
       
  3519     }
       
  3520 
       
  3521 // ------------------------------------------------------------------------------
       
  3522 // CFileManagerViewBase::DetailsMenuFilteringL
       
  3523 //
       
  3524 // ------------------------------------------------------------------------------
       
  3525 //
       
  3526 void CFileManagerViewBase::DetailsMenuFilteringL( CEikMenuPane& aMenuPane )
       
  3527     {
       
  3528     TInt index( iContainer->ListBoxCurrentItemIndex() );
       
  3529     TUint32 fileType( iEngine.FileTypeL( index ) );
       
  3530     if ( fileType & CFileManagerItemProperties::EFolder )
       
  3531         {
       
  3532         aMenuPane.SetItemDimmed( EFileManagerFileDetails, ETrue );
       
  3533         }
       
  3534     else
       
  3535         {
       
  3536         aMenuPane.SetItemDimmed( EFileManagerFolderDetails, ETrue );
       
  3537         }
       
  3538     if ( !FeatureManager().IsDrmFullSupported() ||
       
  3539          !( fileType & CFileManagerItemProperties::EDrmProtected ) ||
       
  3540         !HasInfoUrlL( index ) )
       
  3541         {
       
  3542         aMenuPane.SetItemDimmed( EFileManagerMoreInfoOnline, ETrue );
       
  3543         }
       
  3544     }
       
  3545 
       
  3546 //// ------------------------------------------------------------------------------
       
  3547 //// CFileManagerViewBase::MemoryCardMenuFilteringL
       
  3548 ////
       
  3549 //// ------------------------------------------------------------------------------
       
  3550 ////
       
  3551 //void CFileManagerViewBase::MemoryCardMenuFilteringL( CEikMenuPane& aMenuPane )
       
  3552 //    {
       
  3553 //    TFileManagerDriveInfo& drvInfo( DriveInfo() );
       
  3554 //    
       
  3555 //    if ( drvInfo.iState & ( TFileManagerDriveInfo::EDriveCorrupted |
       
  3556 //                            TFileManagerDriveInfo::EDriveLocked |
       
  3557 //                            TFileManagerDriveInfo::EDriveMassStorage ) )
       
  3558 //        {
       
  3559 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCardName, ETrue );
       
  3560 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCardRename, ETrue );
       
  3561 //        }
       
  3562 //    else
       
  3563 //        {
       
  3564 //        if ( drvInfo.iName.Length() )
       
  3565 //            {
       
  3566 //            aMenuPane.SetItemDimmed( EFileManagerMemoryCardName, ETrue );
       
  3567 //            }
       
  3568 //        else
       
  3569 //            {
       
  3570 //            aMenuPane.SetItemDimmed( EFileManagerMemoryCardRename, ETrue );
       
  3571 //            }
       
  3572 //        }
       
  3573 //
       
  3574 //    if ( !( drvInfo.iState & TFileManagerDriveInfo::EDriveFormattable ) )
       
  3575 //        {
       
  3576 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCardFormat, ETrue );
       
  3577 //        }
       
  3578 //    }
       
  3579 //
       
  3580 //// ------------------------------------------------------------------------------
       
  3581 //// CFileManagerViewBase::MemoryCardPasswordMenuFilteringL
       
  3582 ////
       
  3583 //// ------------------------------------------------------------------------------
       
  3584 ////
       
  3585 //void CFileManagerViewBase::MemoryCardPasswordMenuFilteringL( CEikMenuPane& aMenuPane )
       
  3586 //    {
       
  3587 //    TFileManagerDriveInfo& drvInfo( DriveInfo() );
       
  3588 //    
       
  3589 //    if ( drvInfo.iState & TFileManagerDriveInfo::EDrivePasswordProtected ) 
       
  3590 //        {
       
  3591 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCardPasswordSet, ETrue );
       
  3592 //        }
       
  3593 //    else
       
  3594 //        {
       
  3595 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCardPasswordChange, ETrue );
       
  3596 //        aMenuPane.SetItemDimmed( EFileManagerMemoryCardPasswordRemove, ETrue );
       
  3597 //        }
       
  3598 //    }
       
  3599 
       
  3600 // ------------------------------------------------------------------------------
       
  3601 // CFileManagerViewBase::ContextSensitiveMenuFilteringL
       
  3602 //
       
  3603 // ------------------------------------------------------------------------------
       
  3604 //
       
  3605 void CFileManagerViewBase::ContextSensitiveMenuFilteringL( CEikMenuPane& aMenuPane )
       
  3606     {
       
  3607     TFileManagerDriveInfo& drvInfo( DriveInfo() );
       
  3608     TInt driveNumber = drvInfo.iDrive;
       
  3609     iEngine.GetDriveInfoL(driveNumber,drvInfo);
       
  3610 
       
  3611     // Check if there are files to send
       
  3612     TInt dummy( 0 );
       
  3613     CArrayFixFlat< TInt >* files = GetSendFilesLC( dummy );
       
  3614     
       
  3615     TBool dimSend( EFalse );
       
  3616     if ( ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote ) &&
       
  3617          !( drvInfo.iState & TFileManagerDriveInfo::EDriveConnected ) )
       
  3618         {
       
  3619         dimSend = ETrue;
       
  3620         }
       
  3621     
       
  3622     if ( files->Count() && !dimSend )
       
  3623         {
       
  3624         AddSendOptionL( aMenuPane, EFileManagerOrganise );
       
  3625         }
       
  3626     CleanupStack::PopAndDestroy( files );
       
  3627 
       
  3628     if ( drvInfo.iState & TFileManagerDriveInfo::EDriveWriteProtected )
       
  3629         {
       
  3630         // Write protected item dimming
       
  3631         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageFormat, ETrue );
       
  3632         }
       
  3633 
       
  3634     if ( iEngine.State() == CFileManagerEngine::ESearch ||
       
  3635          !( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable ) )
       
  3636         {
       
  3637         // No memory card item dimming
       
  3638         aMenuPane.SetItemDimmed( EFileManagerUnlockMemoryCard, ETrue );
       
  3639         aMenuPane.SetItemDimmed( EFileManagerMemoryStorageFormat, ETrue );
       
  3640         }
       
  3641     else
       
  3642         {
       
  3643         // Memory card item dimming
       
  3644         if ( !( drvInfo.iState & TFileManagerDriveInfo::EDriveLocked ) )
       
  3645             {
       
  3646             aMenuPane.SetItemDimmed( EFileManagerUnlockMemoryCard, ETrue );
       
  3647             }
       
  3648         if ( !( drvInfo.iState & TFileManagerDriveInfo::EDriveCorrupted ) ||
       
  3649              !( drvInfo.iState & TFileManagerDriveInfo::EDriveFormattable ) )
       
  3650             {
       
  3651             aMenuPane.SetItemDimmed( EFileManagerMemoryStorageFormat, ETrue );
       
  3652             }
       
  3653         }
       
  3654     }
       
  3655 
       
  3656 // -----------------------------------------------------------------------------
       
  3657 // CFileManagerViewBase::DriveInfo
       
  3658 // 
       
  3659 // -----------------------------------------------------------------------------
       
  3660 // 
       
  3661 TFileManagerDriveInfo& CFileManagerViewBase::DriveInfo() const
       
  3662     {
       
  3663     return static_cast< CFileManagerAppUi* >( AppUi() )->DriveInfo();
       
  3664     }
       
  3665 
       
  3666 // -----------------------------------------------------------------------------
       
  3667 // CFileManagerViewBase::RefreshDriveInfoL
       
  3668 // 
       
  3669 // -----------------------------------------------------------------------------
       
  3670 // 
       
  3671 void CFileManagerViewBase::RefreshDriveInfoL()
       
  3672     {
       
  3673     if ( !iEngine.CurrentDirectory().Length() )
       
  3674         {
       
  3675         return;
       
  3676         }
       
  3677     iEngine.GetDriveInfoL( DriveInfo() );
       
  3678     }
       
  3679 
       
  3680 // ------------------------------------------------------------------------------
       
  3681 // CFileManagerViewBase::StartProcessL
       
  3682 //
       
  3683 // ------------------------------------------------------------------------------
       
  3684 //
       
  3685 void CFileManagerViewBase::StartProcessL(
       
  3686         MFileManagerProcessObserver::TFileManagerProcess aProcess,
       
  3687         TInt aValue )
       
  3688     {
       
  3689     if ( iActiveProcess != ENoProcess )
       
  3690         {
       
  3691         return;
       
  3692         }
       
  3693     LaunchProgressDialogL( KMaxTInt, 0, aProcess );
       
  3694     iEngine.SetObserver( this );
       
  3695     iActiveProcess = aProcess;
       
  3696     TInt err( KErrNone );
       
  3697     switch ( aProcess )
       
  3698         {
       
  3699         case EFormatProcess:
       
  3700             {
       
  3701             TRAP( err, iEngine.StartFormatProcessL( aValue ) );
       
  3702             break;
       
  3703             }
       
  3704         case EBackupProcess:
       
  3705         case ERestoreProcess: // FALLTHROUGH
       
  3706             {
       
  3707             CFileManagerAppUi* appUi = static_cast< CFileManagerAppUi* >( AppUi() );
       
  3708             appUi->BackupOrRestoreStarted();
       
  3709             
       
  3710             TRAP( err, iEngine.StartBackupProcessL( aProcess ) );
       
  3711             break;
       
  3712             }
       
  3713         case EEjectProcess:
       
  3714             {
       
  3715             TRAP( err, iEngine.StartEjectProcessL( aValue ) );
       
  3716             break;
       
  3717             }
       
  3718         default:
       
  3719             {
       
  3720             TRAP( err, ClearProgressBarL() );
       
  3721             iActiveProcess = ENoProcess;
       
  3722             break;
       
  3723             }
       
  3724         }
       
  3725     if ( err != KErrNone )
       
  3726         {
       
  3727         // Clean up the active process before forwarding leave
       
  3728         ERROR_LOG2(
       
  3729             "CFileManagerViewBase::StartProcessL-aProcess=%d,err=%d",
       
  3730             aProcess, err )
       
  3731         iActiveProcess = ENoProcess;
       
  3732         User::Leave( err );
       
  3733         }
       
  3734     }
       
  3735 
       
  3736 // ------------------------------------------------------------------------------
       
  3737 // CFileManagerViewBase::CmdUnlockDriveL
       
  3738 //
       
  3739 // ------------------------------------------------------------------------------
       
  3740 //
       
  3741 void CFileManagerViewBase::CmdUnlockDriveL()
       
  3742     {
       
  3743     TFileManagerDriveInfo drvInfo;
       
  3744     if ( DriveInfoAtCurrentPosL( drvInfo ) < 0 )
       
  3745         {
       
  3746         return; // No drive selected
       
  3747         }
       
  3748 
       
  3749     if ( !UnlockRemovePasswordL( drvInfo.iDrive, EFalse ) ) // Unlock only
       
  3750         {
       
  3751         RefreshDriveInfoL();
       
  3752         iEngine.SetObserver( this );
       
  3753         iEngine.RefreshDirectory();
       
  3754         }
       
  3755     }
       
  3756 
       
  3757 // ------------------------------------------------------------------------------
       
  3758 // CFileManagerViewBase::CmdFormatDriveL
       
  3759 //
       
  3760 // ------------------------------------------------------------------------------
       
  3761 //
       
  3762 void CFileManagerViewBase::CmdFormatDriveL()
       
  3763     {
       
  3764     StoreIndex();
       
  3765     TFileManagerDriveInfo drvInfo;
       
  3766     if ( DriveInfoAtCurrentPosL( drvInfo ) < 0 )
       
  3767         {
       
  3768         return; // No drive selected
       
  3769         }
       
  3770 
       
  3771     if ( !( drvInfo.iState & ( TFileManagerDriveInfo::EDriveRemovable |
       
  3772                                TFileManagerDriveInfo::EDriveFormattable ) ) ||
       
  3773         ( drvInfo.iState & TFileManagerDriveInfo::EDriveWriteProtected ) )
       
  3774         {
       
  3775         FileManagerDlgUtils::ShowErrorNoteL(
       
  3776             R_QTN_MEMORYCARD_READONLY );
       
  3777         return;
       
  3778         }
       
  3779 
       
  3780     TBool query( EFalse );
       
  3781 #ifdef RD_MULTIPLE_DRIVE
       
  3782     if ( drvInfo.iState & TFileManagerDriveInfo::EDriveUsbMemory )
       
  3783         {
       
  3784         HBufC* text = iEngine.GetFormattedDriveNameLC(
       
  3785             drvInfo.iDrive, R_QTN_FMGR_USB_MEMORY_FORMAT_QUERY );
       
  3786         query = FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( *text );
       
  3787         CleanupStack::PopAndDestroy( text );
       
  3788         }
       
  3789     else if ( drvInfo.iState & TFileManagerDriveInfo::EDriveMassStorage )
       
  3790         {
       
  3791         HBufC* text = iEngine.GetFormattedDriveNameLC(
       
  3792             drvInfo.iDrive, R_QTN_FMGR_FORMAT_MASS_QUERY1 );
       
  3793         query = FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( *text );
       
  3794         CleanupStack::PopAndDestroy( text );
       
  3795         }
       
  3796     else
       
  3797         {
       
  3798 #endif // RD_MULTIPLE_DRIVE
       
  3799         query = FileManagerDlgUtils::ShowConfirmQueryWithYesNoL(
       
  3800             R_QTN_CONFIRM_FORMAT_TEXT );
       
  3801 #ifdef RD_MULTIPLE_DRIVE
       
  3802         }
       
  3803 #endif // RD_MULTIPLE_DRIVE
       
  3804 
       
  3805     if ( query )
       
  3806         {
       
  3807         StartProcessL( EFormatProcess, drvInfo.iDrive );
       
  3808         }
       
  3809     }
       
  3810 
       
  3811 //// ------------------------------------------------------------------------------
       
  3812 //// CFileManagerViewBase::CmdRenameDriveL
       
  3813 ////
       
  3814 //// ------------------------------------------------------------------------------
       
  3815 ////
       
  3816 //void CFileManagerViewBase::CmdRenameDriveL()
       
  3817 //    {
       
  3818 //    TFileManagerDriveInfo& drvInfo( DriveInfo() );
       
  3819 //    if ( drvInfo.iState & TFileManagerDriveInfo::EDriveWriteProtected )
       
  3820 //        {
       
  3821 //        FileManagerDlgUtils::ShowErrorNoteL( R_QTN_MEMORYCARD_READONLY );
       
  3822 //        return;
       
  3823 //        }
       
  3824 //    StoreIndex();
       
  3825 //    RenameDriveL( EFalse );
       
  3826 //    iEngine.SetObserver( this );
       
  3827 //    iEngine.RefreshDirectory();
       
  3828 //    }
       
  3829 //
       
  3830 //// ------------------------------------------------------------------------------
       
  3831 //// CFileManagerViewBase::CmdSetDrivePasswordL
       
  3832 ////
       
  3833 //// ------------------------------------------------------------------------------
       
  3834 ////
       
  3835 //void CFileManagerViewBase::CmdSetDrivePasswordL()
       
  3836 //    {
       
  3837 //    TBuf< KFmgrMaxMediaPassword > nullPwd;
       
  3838 //    TBuf< KFmgrMaxMediaPassword > pwd;
       
  3839 //    TInt ret( KErrNone );
       
  3840 //    if( FileManagerDlgUtils::ShowPasswordQueryL( pwd ) )
       
  3841 //        {
       
  3842 //        EmptyPwd( nullPwd );
       
  3843 //        ret = UpdatePasswordL( nullPwd, pwd );
       
  3844 //        if( ret == KErrNone )
       
  3845 //            {
       
  3846 //            FileManagerDlgUtils::ShowConfirmNoteL( R_QTN_PASSWORD_SET_TEXT );
       
  3847 //            RefreshDriveInfoL();
       
  3848 //            }
       
  3849 //        else
       
  3850 //            {
       
  3851 //            FileManagerDlgUtils::ShowErrorNoteL( R_QTN_CRITICAL_ERROR );
       
  3852 //            }
       
  3853 //        }
       
  3854 //    }
       
  3855 //
       
  3856 //// ------------------------------------------------------------------------------
       
  3857 //// CFileManagerViewBase::CmdChangeDrivePasswordL
       
  3858 ////
       
  3859 //// ------------------------------------------------------------------------------
       
  3860 ////
       
  3861 //void CFileManagerViewBase::CmdChangeDrivePasswordL()
       
  3862 //    {
       
  3863 //    TBuf< KFmgrMaxMediaPassword > pwd;
       
  3864 //    TBuf< KFmgrMaxMediaPassword > oldPwd;
       
  3865 //    TBool isDone( EFalse );
       
  3866 //    TBool isCanceled( EFalse );
       
  3867 //    TInt err( KErrNone );
       
  3868 //
       
  3869 //    // Ask for the old password until the correct one is given
       
  3870 //    while( !isDone )
       
  3871 //        {
       
  3872 //        EmptyPwd( oldPwd );
       
  3873 //        if( FileManagerDlgUtils::ShowSimplePasswordQueryL(
       
  3874 //                R_QTN_PASSWORD_OLD_TEXT, oldPwd ) )
       
  3875 //            {
       
  3876 //            err = UpdatePasswordL( oldPwd, oldPwd );
       
  3877 //            if( err == KErrNone )
       
  3878 //                {
       
  3879 //                isDone = ETrue;
       
  3880 //                }
       
  3881 //            else
       
  3882 //                {
       
  3883 //                FileManagerDlgUtils::ShowErrorNoteL(
       
  3884 //                    R_QTN_PASSWORDS_WRONG_TEXT );
       
  3885 //                }
       
  3886 //            }
       
  3887 //        else
       
  3888 //            {
       
  3889 //            isDone = ETrue;
       
  3890 //            isCanceled = ETrue;
       
  3891 //            }
       
  3892 //        }
       
  3893 //
       
  3894 //    // Then query for the new password
       
  3895 //    if( !isCanceled )
       
  3896 //        {
       
  3897 //        if( FileManagerDlgUtils::ShowPasswordQueryL( pwd ) )
       
  3898 //            {
       
  3899 //            err = UpdatePasswordL( oldPwd, pwd );
       
  3900 //            if( err == KErrNone )
       
  3901 //                {
       
  3902 //                FileManagerDlgUtils::ShowConfirmNoteL(
       
  3903 //                    R_QTN_PASSWORD_CHANGED_TEXT );
       
  3904 //                }
       
  3905 //            else
       
  3906 //                {
       
  3907 //                FileManagerDlgUtils::ShowErrorNoteL(
       
  3908 //                    R_QTN_CRITICAL_ERROR );
       
  3909 //                }
       
  3910 //            }
       
  3911 //        }
       
  3912 //    }
       
  3913 //
       
  3914 //// ------------------------------------------------------------------------------
       
  3915 //// CFileManagerViewBase::CmdRemoveDrivePasswordL
       
  3916 ////
       
  3917 //// ------------------------------------------------------------------------------
       
  3918 ////
       
  3919 //void CFileManagerViewBase::CmdRemoveDrivePasswordL()
       
  3920 //    {
       
  3921 //    if( !UnlockRemovePasswordL( ETrue ) )
       
  3922 //        {
       
  3923 //        FileManagerDlgUtils::ShowConfirmNoteL( R_QTN_PASSWORD_REMOVED_TEXT );
       
  3924 //        RefreshDriveInfoL();
       
  3925 //        }
       
  3926 //    }
       
  3927 //
       
  3928 //// ------------------------------------------------------------------------------
       
  3929 //// CFileManagerViewBase::CmdMemoryCardDetailsL
       
  3930 ////
       
  3931 //// ------------------------------------------------------------------------------
       
  3932 ////
       
  3933 //void CFileManagerViewBase::CmdMemoryCardDetailsL()
       
  3934 //    {
       
  3935 //    TFileManagerDriveInfo drvInfo;
       
  3936 //    iEngine.GetDriveInfoL( iEngine.CurrentDrive(), drvInfo );
       
  3937 //    FileManagerDlgUtils::ShowMemoryStoreInfoPopupL( drvInfo );
       
  3938 //    }
       
  3939 
       
  3940 // ------------------------------------------------------------------------------
       
  3941 // CFileManagerViewBase::UpdatePasswordL
       
  3942 //
       
  3943 // ------------------------------------------------------------------------------
       
  3944 //
       
  3945 TInt CFileManagerViewBase::UpdatePassword(
       
  3946         TInt aDrive, const TDesC& aOldPwd, const TDesC& aPwd )
       
  3947     {
       
  3948     TMediaPassword mPwdNew;
       
  3949     TMediaPassword mPwdOld;
       
  3950 
       
  3951     ConvertCharsToPwd( aOldPwd, mPwdOld );
       
  3952     ConvertCharsToPwd( aPwd, mPwdNew );
       
  3953 
       
  3954     return iEngine.SetDrivePassword( aDrive, mPwdOld, mPwdNew );
       
  3955     }
       
  3956 
       
  3957 // ------------------------------------------------------------------------------
       
  3958 // CFileManagerViewBase::UnlockRemovePasswordL
       
  3959 //
       
  3960 // ------------------------------------------------------------------------------
       
  3961 //
       
  3962 TInt CFileManagerViewBase::UnlockRemovePasswordL(
       
  3963         TInt aDrive, TBool aRemove )
       
  3964     {
       
  3965     TBuf< KFmgrMaxMediaPassword > oldPwd;
       
  3966     TInt err( KErrNone );
       
  3967     TMediaPassword pwd;
       
  3968     TInt res( R_QTN_UNLOCK_PASSWORD_TEXT );
       
  3969     TInt resWrong( R_QTN_UNLOCK_PWD_WRONG_TEXT );
       
  3970     HBufC* text = NULL;
       
  3971 
       
  3972     if( aRemove )
       
  3973         {
       
  3974         // Confirm the action
       
  3975         if( !FileManagerDlgUtils::ShowConfirmQueryWithYesNoL(
       
  3976                 R_QTN_PASSWORD_REMOVE_TEXT ) )
       
  3977             {
       
  3978             return KErrCancel; // Skip the rest if not accepted
       
  3979             }
       
  3980         res = R_QTN_PASSWORD_OLD_TEXT;
       
  3981         resWrong = R_QTN_PASSWORDS_WRONG_TEXT;
       
  3982         }
       
  3983     else
       
  3984         {
       
  3985         // Just unlock
       
  3986 #ifdef RD_MULTIPLE_DRIVE
       
  3987         text = iEngine.GetFormattedDriveNameLC(
       
  3988             aDrive,
       
  3989             R_QTN_MEMC_UNLOCK_PASSWORD_MULTIPLE_DEFAULTNAME,
       
  3990             R_QTN_MEMC_UNLOCK_PASSWORD_MULTIPLE );
       
  3991 #else // RD_MULTIPLE_DRIVE
       
  3992         text = StringLoader::LoadLC( R_QTN_UNLOCK_PASSWORD_TEXT );
       
  3993 #endif // RD_MULTIPLE_DRIVE
       
  3994         }
       
  3995 
       
  3996     // Show until correct pwd is given or canceled
       
  3997     TBool isDone( EFalse );
       
  3998     while( !isDone )
       
  3999         {
       
  4000         // Empty first
       
  4001         EmptyPwd( oldPwd );
       
  4002         TBool pwdGiven( EFalse );
       
  4003         if ( text )
       
  4004             {
       
  4005             pwdGiven = FileManagerDlgUtils::ShowSimplePasswordQueryL( *text, oldPwd );
       
  4006             }
       
  4007         else
       
  4008             {
       
  4009             pwdGiven = FileManagerDlgUtils::ShowSimplePasswordQueryL( res, oldPwd );
       
  4010             }
       
  4011         if( pwdGiven )
       
  4012             {
       
  4013             ConvertCharsToPwd( oldPwd, pwd );
       
  4014             if( aRemove )
       
  4015                 {
       
  4016                 err = iEngine.RemoveDrivePassword(  aDrive, pwd );
       
  4017                 }
       
  4018             else
       
  4019                 {
       
  4020                 err = iEngine.UnlockDrive( aDrive, pwd );
       
  4021                 }
       
  4022 
       
  4023             if ( err == KErrNone )
       
  4024                 {
       
  4025                 isDone = ETrue;
       
  4026                 }
       
  4027             else
       
  4028                 {
       
  4029                 FileManagerDlgUtils::ShowErrorNoteL( resWrong );
       
  4030                 }
       
  4031             }
       
  4032         else
       
  4033             {
       
  4034             err = KErrCancel;
       
  4035             isDone = ETrue;
       
  4036             }
       
  4037         }
       
  4038     if ( text )
       
  4039         {
       
  4040         CleanupStack::PopAndDestroy( text );
       
  4041         }
       
  4042     return err;
       
  4043     }
       
  4044 
       
  4045 // ------------------------------------------------------------------------------
       
  4046 // CFileManagerViewBase::SetRemoteDriveConnectionStateL
       
  4047 //
       
  4048 // ------------------------------------------------------------------------------
       
  4049 //
       
  4050 void CFileManagerViewBase::SetRemoteDriveConnectionStateL( TBool aState )
       
  4051     {
       
  4052     TInt drv( 0 );
       
  4053 
       
  4054     StoreIndex();
       
  4055     if ( !iEngine.CurrentDirectory().Length() )
       
  4056         {
       
  4057         TInt index( iContainer->ListBoxCurrentItemIndex() );
       
  4058         CFileManagerItemProperties* prop = iEngine.GetItemInfoL( index );
       
  4059         CleanupStack::PushL( prop );
       
  4060         drv = TDriveUnit( prop->FullPath() );
       
  4061         CleanupStack::PopAndDestroy( prop );
       
  4062         }
       
  4063     else
       
  4064         {
       
  4065         TFileManagerDriveInfo& drvInfo( DriveInfo() );
       
  4066         drv = drvInfo.iDrive;
       
  4067         }
       
  4068     iEngine.SetRemoteDriveConnection( drv, aState );
       
  4069     }
       
  4070 
       
  4071 // ------------------------------------------------------------------------------
       
  4072 // CFileManagerViewBase::OpenRemoteDriveSettingsL
       
  4073 //
       
  4074 // ------------------------------------------------------------------------------
       
  4075 //
       
  4076 void CFileManagerViewBase::OpenRemoteDriveSettingsL(
       
  4077         const TDesC& aDriveName )
       
  4078     {
       
  4079     CFileManagerAppUi* appUi = static_cast< CFileManagerAppUi* >( AppUi() );
       
  4080     appUi->ActivateRemoteDriveSettingsViewL( aDriveName );
       
  4081     }
       
  4082 
       
  4083 // ------------------------------------------------------------------------------
       
  4084 // CFileManagerViewBase::IsDisconnectedRemoteDrive
       
  4085 //
       
  4086 // ------------------------------------------------------------------------------
       
  4087 //
       
  4088 TBool CFileManagerViewBase::IsDisconnectedRemoteDrive(
       
  4089         CFileManagerItemProperties& aProp )
       
  4090     {
       
  4091     TUint32 drvState( 0 );
       
  4092     if ( iEngine.DriveState( drvState, aProp.FullPath() ) == KErrNone )
       
  4093         {
       
  4094         if ( ( drvState & TFileManagerDriveInfo::EDriveRemote ) &&
       
  4095             !( drvState & TFileManagerDriveInfo::EDriveConnected ) )
       
  4096             {
       
  4097             return ETrue;
       
  4098             }
       
  4099         }
       
  4100     return EFalse;
       
  4101     }
       
  4102 
       
  4103 // ------------------------------------------------------------------------------
       
  4104 // CFileManagerViewBase::RemoteDriveCommonFilteringL
       
  4105 //
       
  4106 // ------------------------------------------------------------------------------
       
  4107 //
       
  4108 void CFileManagerViewBase::RemoteDriveCommonFilteringL( CEikMenuPane& aMenuPane )
       
  4109     {
       
  4110     TBool dimAll( EFalse );
       
  4111     if ( !FeatureManager().IsRemoteStorageFwSupported() )
       
  4112         {
       
  4113         dimAll = ETrue;
       
  4114         }
       
  4115     else
       
  4116         {
       
  4117 //        CEikListBox& listBox = iContainer->ListBox();
       
  4118         if ( iContainer->ListBoxNumberOfItems() )
       
  4119             {    
       
  4120             TInt index( iContainer->ListBoxCurrentItemIndex() );
       
  4121             CFileManagerItemProperties* prop = iEngine.GetItemInfoL( index );
       
  4122 
       
  4123             TUint32 drvState( 0 );
       
  4124             TInt err( iEngine.DriveState( drvState, prop->FullPath() ) );
       
  4125             if ( err == KErrNone &&
       
  4126                 ( drvState & TFileManagerDriveInfo::EDriveRemote ) )
       
  4127                 {
       
  4128                 if ( drvState & TFileManagerDriveInfo::EDriveConnected )
       
  4129                     {
       
  4130                     aMenuPane.SetItemDimmed( EFileManagerConnectRemoveDrive, ETrue );
       
  4131                     }
       
  4132                 else
       
  4133                     {
       
  4134                     aMenuPane.SetItemDimmed( EFileManagerDisconnectRemoveDrive, ETrue );
       
  4135                     }
       
  4136                 }
       
  4137             else
       
  4138                 {
       
  4139                 dimAll = ETrue;
       
  4140                 }
       
  4141             delete prop;
       
  4142             }
       
  4143         else
       
  4144             {
       
  4145             // List is empty
       
  4146             TFileManagerDriveInfo& drvInfo( DriveInfo() );
       
  4147             
       
  4148             if ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote )
       
  4149                 {
       
  4150                 if ( drvInfo.iState & TFileManagerDriveInfo::EDriveConnected )
       
  4151                     {
       
  4152                     aMenuPane.SetItemDimmed( EFileManagerConnectRemoveDrive, ETrue );
       
  4153                     }
       
  4154                 else
       
  4155                     {
       
  4156                     aMenuPane.SetItemDimmed( EFileManagerDisconnectRemoveDrive, ETrue );
       
  4157                     }
       
  4158                 }
       
  4159             else
       
  4160                 {
       
  4161                 dimAll = ETrue;
       
  4162                 }
       
  4163             }
       
  4164         }
       
  4165         
       
  4166     if ( dimAll )
       
  4167         {
       
  4168         aMenuPane.SetItemDimmed( EFileManagerConnectRemoveDrive, ETrue );
       
  4169         aMenuPane.SetItemDimmed( EFileManagerDisconnectRemoveDrive, ETrue );
       
  4170         }
       
  4171     }
       
  4172 
       
  4173 // -----------------------------------------------------------------------------
       
  4174 // CFileManagerViewBase::LaunchProgressBarL  
       
  4175 // 
       
  4176 // -----------------------------------------------------------------------------
       
  4177 // 
       
  4178 void CFileManagerViewBase::LaunchProgressBarL(
       
  4179         TInt aDialogId,
       
  4180         TInt aTextId,
       
  4181         TInt64 aFinalValue,
       
  4182         TInt64 aInitialValue,
       
  4183         TBool aPeriodic,
       
  4184         TBool aImmediatelyVisible )
       
  4185     {
       
  4186     ClearProgressBarL(); // Clear previous
       
  4187 
       
  4188     if ( aFinalValue )
       
  4189         {
       
  4190         iProgressDialog = new (ELeave) CAknProgressDialog(
       
  4191             ( reinterpret_cast< CEikDialog** >( &iProgressDialog ) ), aImmediatelyVisible );
       
  4192         iProgressDialog->PrepareLC( aDialogId );
       
  4193         
       
  4194         if ( aPeriodic )
       
  4195             {
       
  4196             iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard );
       
  4197             iPeriodic->Start(
       
  4198                 KProgressBarUpdateInterval, KProgressBarUpdateInterval,
       
  4199                 TCallBack( UpdateProgressBar, this ) );
       
  4200             }
       
  4201         }
       
  4202     else
       
  4203         {
       
  4204         iProgressDialog = new (ELeave) CAknWaitDialog(
       
  4205             ( reinterpret_cast< CEikDialog** >( &iProgressDialog ) ), aImmediatelyVisible );
       
  4206         iProgressDialog->PrepareLC( aDialogId );
       
  4207         }
       
  4208 
       
  4209     if ( aTextId )
       
  4210         {
       
  4211         HBufC* text = StringLoader::LoadLC( aTextId );
       
  4212         iProgressDialog->SetTextL( *text );
       
  4213         CleanupStack::PopAndDestroy( text );
       
  4214         }
       
  4215 
       
  4216     iProgressDialog->SetCallback(this);
       
  4217     iProgressInfo = iProgressDialog->GetProgressInfoL();
       
  4218     if ( iProgressInfo )
       
  4219         {
       
  4220         iProgressInfo->SetFinalValue( static_cast<TInt>( aFinalValue/1024 ) ); 
       
  4221         iProgressInfo->SetAndDraw( static_cast<TInt>( aInitialValue/1024 ) );
       
  4222         }
       
  4223     iProgressDialog->RunLD();
       
  4224     }
       
  4225 
       
  4226 // ------------------------------------------------------------------------------
       
  4227 // CFileManagerViewBase::RefreshProgressDelayedStart
       
  4228 //
       
  4229 // ------------------------------------------------------------------------------
       
  4230 //
       
  4231 TInt CFileManagerViewBase::RefreshProgressDelayedStart( TAny* aPtr )
       
  4232     {
       
  4233     CFileManagerViewBase* view = static_cast< CFileManagerViewBase* > ( aPtr );
       
  4234     TRAP_IGNORE( view->RefreshProgressDelayedStartL() );
       
  4235     return KErrNone;
       
  4236     }
       
  4237 
       
  4238 // ------------------------------------------------------------------------------
       
  4239 // CFileManagerViewBase::RefreshProgressDelayedStartL
       
  4240 //
       
  4241 // ------------------------------------------------------------------------------
       
  4242 //
       
  4243 void CFileManagerViewBase::RefreshProgressDelayedStartL()
       
  4244     {
       
  4245     CFileManagerAppUi* app = static_cast< CFileManagerAppUi* >( AppUi() );
       
  4246 
       
  4247     delete iRefreshProgressDelayedStart;
       
  4248     iRefreshProgressDelayedStart = NULL;
       
  4249 
       
  4250     if( iProgressDialogRefresh )
       
  4251         {
       
  4252         iProgressDialogRefresh->ProcessFinishedL();
       
  4253         iProgressDialogRefresh = NULL;
       
  4254         }
       
  4255     iProgressDialogRefresh = new( ELeave ) CAknProgressDialog(
       
  4256         reinterpret_cast< CEikDialog** >( &iProgressDialogRefresh ),
       
  4257         ETrue );
       
  4258     iProgressDialogRefresh->SetCallback( this );
       
  4259 
       
  4260     if ( Id() == CFileManagerAppUi::KFileManagerSearchResultsViewId )
       
  4261         {
       
  4262         iProgressDialogRefresh->ExecuteLD( R_FILEMANAGER_FIND_WAIT_DIALOG );
       
  4263         }
       
  4264     else
       
  4265         {
       
  4266         iProgressDialogRefresh->ExecuteLD( R_FILEMANAGER_WAIT_NOTE_OPEN );
       
  4267         }
       
  4268     }
       
  4269 
       
  4270 // ------------------------------------------------------------------------------
       
  4271 // CFileManagerViewBase::IsRefreshInProgress
       
  4272 //
       
  4273 // ------------------------------------------------------------------------------
       
  4274 //
       
  4275 TBool CFileManagerViewBase::IsRefreshInProgress()
       
  4276     {
       
  4277     if ( iRefreshProgressDelayedStart || iProgressDialogRefresh )
       
  4278         {
       
  4279         return ETrue;
       
  4280         }
       
  4281     return EFalse;
       
  4282     }
       
  4283 
       
  4284 // ------------------------------------------------------------------------------
       
  4285 // CFileManagerViewBase::ProcessCommandL
       
  4286 //
       
  4287 // ------------------------------------------------------------------------------
       
  4288 //
       
  4289 void CFileManagerViewBase::ProcessCommandL( TInt aCommand )
       
  4290     {
       
  4291     // Suppress commands during refresh
       
  4292     if ( IsRefreshInProgress() )
       
  4293         {
       
  4294         switch ( aCommand )
       
  4295             {
       
  4296             case EAknSoftkeyOptions: // FALLTHROUGH
       
  4297             case EAknSoftkeyBack:  // FALLTHROUGH
       
  4298             case EAknSoftkeyContextOptions:  // FALLTHROUGH
       
  4299             case EAknSoftkeyMark:  // FALLTHROUGH
       
  4300             case EAknSoftkeyUnmark:  // FALLTHROUGH
       
  4301             case EAknSoftkeySelect:
       
  4302                 {
       
  4303                 return;
       
  4304                 }
       
  4305             default:
       
  4306                 {
       
  4307                 break;
       
  4308                 }
       
  4309             }
       
  4310         }
       
  4311 
       
  4312     // Handle commands directly
       
  4313     switch ( aCommand )
       
  4314         {
       
  4315         case EAknSoftkeyContextOptions: // FALLTHROUGH
       
  4316         case EAknSoftkeyMark:
       
  4317             {
       
  4318             HandleCommandL( aCommand );
       
  4319             break;
       
  4320             }
       
  4321         default:
       
  4322             {
       
  4323             CAknView::ProcessCommandL( aCommand );
       
  4324             break;
       
  4325             }
       
  4326         }
       
  4327     }
       
  4328 
       
  4329 // ------------------------------------------------------------------------------
       
  4330 // CFileManagerViewBase::AskPathL
       
  4331 //
       
  4332 // ------------------------------------------------------------------------------
       
  4333 //
       
  4334 TBool CFileManagerViewBase::AskPathL( TDes& aPath, TInt aTextId )
       
  4335     {
       
  4336     TBool ret( EFalse );
       
  4337     TInt memType(
       
  4338         AknCommonDialogsDynMem::EMemoryTypePhone |
       
  4339         AknCommonDialogsDynMem::EMemoryTypeMMC );
       
  4340 
       
  4341     if ( FeatureManager().IsRemoteStorageFwSupported() )
       
  4342         {
       
  4343         memType |= AknCommonDialogsDynMem::EMemoryTypeRemote;
       
  4344         }
       
  4345 
       
  4346     HBufC* title = StringLoader::LoadLC( aTextId );
       
  4347     CFileManagerFileSelectionFilter* filter =
       
  4348         new( ELeave ) CFileManagerFileSelectionFilter( iEngine );
       
  4349     CleanupStack::PushL( filter );
       
  4350 
       
  4351     ret = AknCommonDialogsDynMem::RunFolderSelectDlgLD(
       
  4352         memType,
       
  4353         aPath,
       
  4354         KNullDesC,
       
  4355         R_FILEMANAGER_FIND_MEMORY_SELECTIONDIALOG,
       
  4356         R_FILEMANAGER_FIND_FOLDER_SELECTIONDIALOG,
       
  4357         *title,
       
  4358         filter );
       
  4359 
       
  4360     CleanupStack::PopAndDestroy( filter );
       
  4361     CleanupStack::PopAndDestroy( title );
       
  4362     return ret;
       
  4363     }
       
  4364 
       
  4365 #ifdef RD_FILE_MANAGER_BACKUP
       
  4366 // ------------------------------------------------------------------------------
       
  4367 // CFileManagerViewBase::StartSchBackupL
       
  4368 //
       
  4369 // ------------------------------------------------------------------------------
       
  4370 //
       
  4371 void CFileManagerViewBase::StartSchBackupL()
       
  4372     {
       
  4373     FUNC_LOG
       
  4374 
       
  4375     CFileManagerAppUi* appUi = static_cast< CFileManagerAppUi* >( AppUi() );
       
  4376     CFileManagerSchBackupHandler& handler( appUi->SchBackupHandlerL() );
       
  4377 
       
  4378     if ( FeatureManager().IsFeatureSupported(
       
  4379             EFileManagerFeatureScheduledBackupDisabled ) )
       
  4380         {
       
  4381         // Scheduled backup is disabled, disable scheduler and cancel backup
       
  4382         INFO_LOG( "CFileManagerViewBase::StartSchBackupL-Backup disabled" )
       
  4383 
       
  4384         handler.CancelBackupStarter();
       
  4385         CFileManagerTaskScheduler& scheduler( appUi->TaskSchedulerL() );
       
  4386         scheduler.EnableBackupScheduleL( EFalse );
       
  4387         appUi->SchBackupFinishedL( KErrCancel );
       
  4388         return;
       
  4389         }
       
  4390 
       
  4391     // Start scheduled backup if no process in progress
       
  4392     // Otherwise wait process to finish
       
  4393     if ( iActiveProcess == ENoProcess )
       
  4394         {
       
  4395         CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() );
       
  4396         TTime schTime( SetCurrentYearMonthAndDay( settings.Time() ) );
       
  4397         
       
  4398         TTime manualBackupOrRestoreStarted = appUi->BackupOrRestoreStartTime();
       
  4399         TTime manualBackupOrRestoreEnded = appUi->BackupOrRestoreEndTime();
       
  4400         
       
  4401         if ( manualBackupOrRestoreStarted.Int64() > 0 &&
       
  4402              schTime >= manualBackupOrRestoreStarted &&
       
  4403              schTime <= manualBackupOrRestoreEnded )
       
  4404             {
       
  4405             INFO_LOG( "CFileManagerViewBase::StartSchBackupL-Backup canceled due to manual op" )
       
  4406 
       
  4407             handler.CancelBackupStarter();
       
  4408             
       
  4409             appUi->ResetBackupOrRestoreEndTime();// Cancel required only once
       
  4410             }
       
  4411         else
       
  4412             {
       
  4413             INFO_LOG( "CFileManagerViewBase::StartSchBackupL-Start backup" )
       
  4414 
       
  4415             iSchBackupPending = EFalse;
       
  4416             iActiveProcess = ESchBackupProcess;
       
  4417             iEngine.SetObserver( this );
       
  4418             handler.StartBackupWithConfirm();
       
  4419             }
       
  4420         }
       
  4421     // Ignore scheduled backup if backup or restore is in progress
       
  4422     else if ( iActiveProcess == ESchBackupProcess ||
       
  4423              iActiveProcess == EBackupProcess ||
       
  4424              iActiveProcess == ERestoreProcess )
       
  4425         {
       
  4426         INFO_LOG( "CFileManagerViewBase::StartSchBackupL-Backup canceled" )
       
  4427 
       
  4428         handler.CancelBackupStarter();
       
  4429         }
       
  4430     else
       
  4431         {
       
  4432         INFO_LOG( "CFileManagerViewBase::StartSchBackupL-Backup pending" )
       
  4433 
       
  4434         iSchBackupPending = ETrue;
       
  4435         }
       
  4436     }
       
  4437 
       
  4438 // ------------------------------------------------------------------------------
       
  4439 // CFileManagerViewBase::SchBackupFinishedL
       
  4440 //
       
  4441 // ------------------------------------------------------------------------------
       
  4442 //
       
  4443 void CFileManagerViewBase::SchBackupFinishedL()
       
  4444     {
       
  4445     FUNC_LOG
       
  4446 
       
  4447     if ( iActiveProcess == ESchBackupProcess )
       
  4448         {
       
  4449         iActiveProcess = ENoProcess;
       
  4450         iSchBackupPending = EFalse;
       
  4451         }
       
  4452     }
       
  4453 
       
  4454 #endif // RD_FILE_MANAGER_BACKUP
       
  4455 
       
  4456 // ------------------------------------------------------------------------------
       
  4457 // CFileManagerViewBase::SetCbaMskTextL
       
  4458 //
       
  4459 // ------------------------------------------------------------------------------
       
  4460 //
       
  4461 void CFileManagerViewBase::SetCbaMskTextL( const TInt aTextId )
       
  4462     {
       
  4463     HBufC* text = StringLoader::LoadLC( aTextId );
       
  4464     CEikButtonGroupContainer* cba = Cba();
       
  4465     if ( cba->ButtonCount() == KFmgrMSK )
       
  4466         {
       
  4467         TInt cmdId( cba->ButtonGroup()->CommandId( KFmgrMSK ) );
       
  4468         cba->SetCommandL( KFmgrMSK, cmdId, *text );
       
  4469         cba->DrawDeferred();
       
  4470         }
       
  4471     CleanupStack::PopAndDestroy( text );
       
  4472     }
       
  4473 
       
  4474 // ------------------------------------------------------------------------------
       
  4475 // CFileManagerViewBase::UpdateCbaL
       
  4476 //
       
  4477 // ------------------------------------------------------------------------------
       
  4478 //
       
  4479 void CFileManagerViewBase::UpdateCbaL()
       
  4480     {
       
  4481     }
       
  4482 
       
  4483 // ------------------------------------------------------------------------------
       
  4484 // CFileManagerViewBase::UpdateCommonCbaL
       
  4485 //
       
  4486 // ------------------------------------------------------------------------------
       
  4487 //
       
  4488 void CFileManagerViewBase::UpdateCommonCbaL()
       
  4489     {
       
  4490     if ( !iContainer || IsRefreshInProgress() )
       
  4491         {
       
  4492         return;
       
  4493         }
       
  4494 
       
  4495     CEikButtonGroupContainer* cba = Cba();
       
  4496 
       
  4497     if ( !iContainer->ListBoxNumberOfItems() )
       
  4498         {
       
  4499         cba->SetCommandSetL(
       
  4500             R_FILEMANAGER_SOFTKEYS_OPTIONS_BACK__EMPTY );
       
  4501         }
       
  4502     else if ( iContainer->ListBoxSelectionIndexesCount() )
       
  4503         {
       
  4504         cba->SetCommandSetL(
       
  4505             R_FILEMANAGER_SOFTKEYS_CONTEXT_OPTIONS_BACK__OPTIONS );
       
  4506         }
       
  4507     else
       
  4508         {
       
  4509         cba->SetCommandSetL(
       
  4510             R_FILEMANAGER_SOFTKEYS_OPTIONS_BACK__OPEN );
       
  4511         }
       
  4512 
       
  4513     // Restore right cancel softkey if it has been set by search field
       
  4514     TBool restoreCancel( ETrue );
       
  4515     if ( iContainer->IsSearchFieldVisible() &&
       
  4516          cba->ButtonCount() >= CEikButtonGroupContainer::ERightSoftkeyPosition )
       
  4517         {
       
  4518         restoreCancel = ( cba->ButtonGroup()->CommandId(
       
  4519             CEikButtonGroupContainer::ERightSoftkeyPosition ) == EAknSoftkeyCancel );
       
  4520         }
       
  4521     if ( !restoreCancel )
       
  4522         {
       
  4523         HBufC* cancelText = StringLoader::LoadLC( R_AVKON_SOFTKEY_CANCEL );
       
  4524         cba->SetCommandL(
       
  4525             CEikButtonGroupContainer::ERightSoftkeyPosition,
       
  4526             EAknSoftkeyCancel,
       
  4527             *cancelText );
       
  4528         CleanupStack::PopAndDestroy( cancelText );
       
  4529         }
       
  4530 
       
  4531     cba->DrawDeferred();
       
  4532     }
       
  4533 
       
  4534 // ------------------------------------------------------------------------------
       
  4535 // CFileManagerViewBase::RenameDriveL
       
  4536 //
       
  4537 // ------------------------------------------------------------------------------
       
  4538 //
       
  4539 void CFileManagerViewBase::RenameDriveL( TBool aForceDefaultName )
       
  4540     {
       
  4541     TFileManagerDriveInfo drvInfo;
       
  4542     if ( DriveInfoAtCurrentPosL( drvInfo ) < 0 )
       
  4543         {
       
  4544         return; // No drive selected
       
  4545         }
       
  4546 
       
  4547     if ( drvInfo.iState & TFileManagerDriveInfo::EDriveMassStorage )
       
  4548         {
       
  4549         return; // Name not allowed
       
  4550         }
       
  4551 
       
  4552     HBufC* drvName = HBufC::NewLC( KMaxVolumeName );
       
  4553     TPtr name( drvName->Des() );
       
  4554     // 16-bit chars are required for non western volume names
       
  4555     const TInt KMaxNonWesternVolumeName( KMaxVolumeName / 2 );
       
  4556 
       
  4557     // Setup query according to variant type, western or non western
       
  4558     TInt resId( R_FILEMANAGER_DRIVE_NAME_QUERY );
       
  4559     TInt maxLen( KMaxVolumeName );
       
  4560     if ( !FeatureManager().IsWesternVariant() )
       
  4561         {
       
  4562         resId = R_FILEMANAGER_DRIVE_NAME_QUERY_NON_WESTERN;
       
  4563         maxLen = KMaxNonWesternVolumeName;
       
  4564         }
       
  4565 
       
  4566     if ( aForceDefaultName || !drvInfo.iName.Length() )
       
  4567         {
       
  4568         HBufC* defaultName = NULL;
       
  4569         if ( drvInfo.iState & TFileManagerDriveInfo::EDriveUsbMemory )
       
  4570             {
       
  4571             defaultName = StringLoader::LoadLC(
       
  4572                 R_QTN_FMGR_USB_MEMORY_DEFAULT_NAME );
       
  4573             }
       
  4574         else
       
  4575             {
       
  4576             defaultName = StringLoader::LoadLC( R_QTN_MMC_DEFAULT_NAME );
       
  4577             }
       
  4578         if ( defaultName->Length() > maxLen )
       
  4579             {
       
  4580             name.Copy( defaultName->Des().Left( maxLen ) );
       
  4581             }
       
  4582         else
       
  4583             {
       
  4584             name.Copy( *defaultName );
       
  4585             }
       
  4586         CleanupStack::PopAndDestroy( defaultName );
       
  4587         }
       
  4588     else
       
  4589         {
       
  4590         if ( drvInfo.iName.Length() > maxLen )
       
  4591             {
       
  4592             name.Copy( drvInfo.iName.Left( maxLen ) );
       
  4593             }
       
  4594         else
       
  4595             {
       
  4596             name.Copy( drvInfo.iName );
       
  4597             }
       
  4598         }
       
  4599 
       
  4600     // Loop until canceled, accepted or an error occurs
       
  4601     TBool isDone( EFalse );
       
  4602     while( !isDone )
       
  4603         {
       
  4604         CAknTextQueryDialog* renameDlg =
       
  4605             CAknTextQueryDialog::NewL( name, CAknQueryDialog::ENoTone );
       
  4606         renameDlg->SetMaxLength( maxLen );
       
  4607         TBool ret( EFalse );
       
  4608         if ( renameDlg->ExecuteLD( resId ) )
       
  4609             {
       
  4610             ret = ETrue;
       
  4611             }
       
  4612         if( ret && name.Compare( drvInfo.iName ) )
       
  4613             {
       
  4614             TInt err( iEngine.RenameDrive( drvInfo.iDrive, name ) );
       
  4615             if( err == KErrNone )
       
  4616                 {
       
  4617                 FileManagerDlgUtils::ShowConfirmNoteL(
       
  4618                     R_QTN_FMGR_CONFIRM_MEMORY_NAME_CHANGED );
       
  4619                 RefreshDriveInfoL();
       
  4620                 isDone = ETrue;
       
  4621                 }
       
  4622             else if( err == KErrBadName )
       
  4623                 {
       
  4624                 FileManagerDlgUtils::ShowInfoNoteL(
       
  4625                     R_QTN_INVALID_DRIVE_NAME );
       
  4626                 }
       
  4627             else
       
  4628                 {
       
  4629                 FileManagerDlgUtils::ShowErrorNoteL(
       
  4630                     R_QTN_CRITICAL_ERROR );
       
  4631                 isDone = ETrue;
       
  4632                 }
       
  4633             }
       
  4634         else
       
  4635             {
       
  4636             // Canceled
       
  4637             isDone = ETrue;
       
  4638             }
       
  4639         }
       
  4640     CleanupStack::PopAndDestroy( drvName );
       
  4641     }
       
  4642 
       
  4643 // ------------------------------------------------------------------------------
       
  4644 // CFileManagerViewBase::CmdRefreshDirectoryL
       
  4645 //
       
  4646 // ------------------------------------------------------------------------------
       
  4647 //
       
  4648 void CFileManagerViewBase::CmdRefreshDirectoryL()
       
  4649     {
       
  4650     StoreIndex();
       
  4651     iEngine.SetObserver( this );
       
  4652     iEngine.ForcedRefreshDirectory();
       
  4653     }
       
  4654 
       
  4655 // ------------------------------------------------------------------------------
       
  4656 // CFileManagerViewBase::ShowEjectQueryL
       
  4657 //
       
  4658 // ------------------------------------------------------------------------------
       
  4659 //
       
  4660 void CFileManagerViewBase::ShowEjectQueryL()
       
  4661     {
       
  4662     delete iEjectQueryDialog;
       
  4663     iEjectQueryDialog = NULL;
       
  4664 
       
  4665     iEjectDone = EFalse;
       
  4666     iEjectQueryDialog = CAknQueryDialog::NewL();
       
  4667     HBufC* text = NULL;
       
  4668     TInt index( iContainer->ListBoxCurrentItemIndex() );
       
  4669     CFileManagerItemProperties* prop = iEngine.GetItemInfoLC( index );
       
  4670 #ifdef RD_MULTIPLE_DRIVE
       
  4671     text = iEngine.GetFormattedDriveNameLC(
       
  4672         prop->DriveId(),
       
  4673         R_QTN_MEMC_INFO_EJECT_MULTIPLE_DEFAULTNAME,
       
  4674         R_QTN_MEMC_INFO_EJECT_MULTIPLE );
       
  4675 #else // RD_MULTIPLE_DRIVE
       
  4676     text = StringLoader::LoadLC( R_QTN_INFO_EJECT );
       
  4677 #endif // RD_MULTIPLE_DRIVE
       
  4678     TRAP_IGNORE( iEjectQueryDialog->ExecuteLD(
       
  4679         R_FILEMANAGER_EJECT_CONFIRM_QUERY, *text ) );
       
  4680     CleanupStack::PopAndDestroy( text );
       
  4681     CleanupStack::PopAndDestroy( prop );
       
  4682     iEjectQueryDialog = NULL;
       
  4683     }
       
  4684 
       
  4685 // ------------------------------------------------------------------------------
       
  4686 // CFileManagerViewBase::IsDriveAvailable
       
  4687 //
       
  4688 // ------------------------------------------------------------------------------
       
  4689 //
       
  4690 TBool CFileManagerViewBase::IsDriveAvailable( const TDesC& aPath ) const
       
  4691     {
       
  4692     TBool ret( EFalse );
       
  4693     if ( aPath.Length() )
       
  4694         {
       
  4695         TInt drive = TDriveUnit( aPath );
       
  4696         ret = IsDriveAvailable( drive );
       
  4697         }
       
  4698     return ret;
       
  4699     }
       
  4700 
       
  4701 // ------------------------------------------------------------------------------
       
  4702 // CFileManagerViewBase::IsDriveAvailable
       
  4703 //
       
  4704 // ------------------------------------------------------------------------------
       
  4705 //
       
  4706 TBool CFileManagerViewBase::IsDriveAvailable( const TInt aDrive ) const
       
  4707     {
       
  4708     TUint32 drvState( 0 );
       
  4709     if ( iEngine.DriveState( drvState, aDrive ) != KErrNone )
       
  4710         {
       
  4711         return EFalse;
       
  4712         }
       
  4713     if ( drvState & ( TFileManagerDriveInfo::EDriveLocked |
       
  4714                       TFileManagerDriveInfo::EDriveCorrupted |
       
  4715                       TFileManagerDriveInfo::EDriveInUse ) )
       
  4716         {
       
  4717         return EFalse; // Drive is unavailable
       
  4718         }
       
  4719     if ( !( drvState & TFileManagerDriveInfo::EDriveRemote ) &&
       
  4720         !( drvState & TFileManagerDriveInfo::EDrivePresent ) )
       
  4721         {
       
  4722         return EFalse; // Drive is not present
       
  4723         }
       
  4724     return ETrue;
       
  4725     }
       
  4726 
       
  4727 // ----------------------------------------------------------------------------
       
  4728 // CFileManagerViewBase::CheckPhoneState
       
  4729 //
       
  4730 // ----------------------------------------------------------------------------
       
  4731 //
       
  4732 TBool CFileManagerViewBase::CheckPhoneState() const
       
  4733     {
       
  4734     // Check here all operations, which are supposed
       
  4735     // to prevent manual backup or restore.
       
  4736     TBool err( ETrue );
       
  4737     TInt syncErr( 0 );
       
  4738     TInt syncStat( 0 );
       
  4739     TInt burErr( 0 );
       
  4740     TInt burStat( 0 );
       
  4741     
       
  4742     // Check synchronization state
       
  4743     syncErr = RProperty::Get(
       
  4744         KPSUidDataSynchronizationInternalKeys, 
       
  4745         KDataSyncStatus, syncStat );
       
  4746         
       
  4747     // Check backup/restore (e.g. PC Suite initiated) state
       
  4748     burErr = RProperty::Get(
       
  4749         KUidSystemCategory, 
       
  4750         KUidBackupRestoreKey, burStat );
       
  4751     const TBURPartType partType = static_cast< TBURPartType >
       
  4752         ( burStat & KBURPartTypeMask );
       
  4753     
       
  4754     if ( (syncErr == KErrNone && syncStat > 0) 
       
  4755         || (burErr == KErrNone && partType != EBURUnset && partType != EBURNormal ) )
       
  4756         {
       
  4757         err = EFalse;
       
  4758         }
       
  4759     
       
  4760     return err;
       
  4761     }
       
  4762 
       
  4763 // ----------------------------------------------------------------------------
       
  4764 // CFileManagerViewBase::StopProgressDialogAndStoreValues
       
  4765 //
       
  4766 // ----------------------------------------------------------------------------
       
  4767 //
       
  4768 TBool CFileManagerViewBase::StopProgressDialogAndStoreValues()
       
  4769     {
       
  4770     TBool ret( EFalse );
       
  4771     if ( iProgressDialog && iProgressInfo )
       
  4772         {
       
  4773         CEikProgressInfo::SInfo info( iProgressInfo->Info() );
       
  4774         iProgressFinalValue = info.iFinalValue;
       
  4775         iProgressCurrentValue = iProgressInfo->CurrentValue();
       
  4776         if ( !iProgressCurrentValue && iTotalTransferredBytes <= iProgressFinalValue )
       
  4777             {
       
  4778             iProgressCurrentValue = iTotalTransferredBytes;
       
  4779             }
       
  4780         TRAP_IGNORE( iProgressDialog->ProcessFinishedL() );
       
  4781         iProgressDialog = NULL;
       
  4782         iProgressInfo = NULL;
       
  4783         ret = ETrue;
       
  4784         }
       
  4785 
       
  4786     delete iRefreshProgressDelayedStart;
       
  4787     iRefreshProgressDelayedStart = NULL;
       
  4788     delete iPeriodic;
       
  4789     iPeriodic = NULL;
       
  4790 
       
  4791     return ret;
       
  4792     }
       
  4793 
       
  4794 
       
  4795 // ----------------------------------------------------------------------------
       
  4796 // CFileManagerViewBase::CheckPostponedDirectoryRefresh
       
  4797 //
       
  4798 // ----------------------------------------------------------------------------
       
  4799 //
       
  4800 void CFileManagerViewBase::CheckPostponedDirectoryRefresh()
       
  4801     {
       
  4802     if ( iDirectoryRefreshPostponed )
       
  4803         {
       
  4804         // Delete was canceled but directory was changed during query
       
  4805         StoreIndex();
       
  4806         iEngine.SetObserver( this );
       
  4807         iEngine.RefreshDirectory();
       
  4808         }
       
  4809     iDirectoryRefreshPostponed = EFalse;
       
  4810     }
       
  4811 
       
  4812 // ----------------------------------------------------------------------------
       
  4813 // CFileManagerViewBase::DenyDirectoryRefresh
       
  4814 //
       
  4815 // ----------------------------------------------------------------------------
       
  4816 //
       
  4817 void CFileManagerViewBase::DenyDirectoryRefresh( TBool aDeny )
       
  4818     {
       
  4819     iDirectoryRefreshDenied = aDeny;
       
  4820     if ( aDeny )
       
  4821         {
       
  4822         iDirectoryRefreshPostponed = EFalse; // Reset previous value
       
  4823         }
       
  4824     }
       
  4825 
       
  4826 // ----------------------------------------------------------------------------
       
  4827 // CFileManagerViewBase::SortMenuFilteringL
       
  4828 //
       
  4829 // ----------------------------------------------------------------------------
       
  4830 //
       
  4831 void CFileManagerViewBase::SortMenuFilteringL( CEikMenuPane& aMenuPane )
       
  4832     {
       
  4833     TInt selected( EFileManagerSortByName );
       
  4834     switch ( iEngine.SortMethod() )
       
  4835         {
       
  4836         case CFileManagerEngine::EByMatch:
       
  4837             {
       
  4838             if ( iEngine.State() == CFileManagerEngine::ESearch )
       
  4839                 {
       
  4840                 selected = EFileManagerSortByMatch;
       
  4841                 }
       
  4842             break;
       
  4843             }
       
  4844         case CFileManagerEngine::EByName:
       
  4845             {
       
  4846             selected = EFileManagerSortByName;
       
  4847             break;
       
  4848             }
       
  4849         case CFileManagerEngine::EByType:
       
  4850             {
       
  4851             selected = EFileManagerSortByType;
       
  4852             break;
       
  4853             }
       
  4854         case CFileManagerEngine::EMostRecentFirst:
       
  4855             {
       
  4856             selected = EFileManagerSortMostRecentFirst;
       
  4857             break;
       
  4858             }
       
  4859         case CFileManagerEngine::ELargestFirst:
       
  4860             {
       
  4861             selected = EFileManagerSortLargestFirst;
       
  4862             break;
       
  4863             }
       
  4864         default:
       
  4865             {
       
  4866             break;
       
  4867             }
       
  4868         }
       
  4869     TInt position = 0;
       
  4870     if ( aMenuPane.MenuItemExists( selected, position ) )
       
  4871     	{
       
  4872     aMenuPane.SetItemButtonState( selected, EEikMenuItemSymbolOn );
       
  4873     	}
       
  4874     }
       
  4875 
       
  4876 // ----------------------------------------------------------------------------
       
  4877 // CFileManagerViewBase::CmdSortL
       
  4878 //
       
  4879 // ----------------------------------------------------------------------------
       
  4880 //
       
  4881 void CFileManagerViewBase::CmdSortL( TInt aCommand )
       
  4882     {
       
  4883     CFileManagerEngine::TSortMethod sortMethod( CFileManagerEngine::EByName );
       
  4884     switch ( aCommand )
       
  4885         {
       
  4886 	    case EFileManagerSortByName:
       
  4887 	        {
       
  4888 	        sortMethod = CFileManagerEngine::EByName;
       
  4889 	        break;
       
  4890 	        }
       
  4891 	    case EFileManagerSortByType:
       
  4892 	        {
       
  4893 	        sortMethod = CFileManagerEngine::EByType;
       
  4894 	        break;
       
  4895 	        }
       
  4896 	    case EFileManagerSortMostRecentFirst:
       
  4897 	        {
       
  4898 	        sortMethod = CFileManagerEngine::EMostRecentFirst;
       
  4899 	        break;
       
  4900 	        }
       
  4901 	    case EFileManagerSortLargestFirst:
       
  4902 	        {
       
  4903 	        sortMethod = CFileManagerEngine::ELargestFirst;
       
  4904 	        break;
       
  4905 	        }
       
  4906 	    case EFileManagerSortByMatch:
       
  4907 	        {
       
  4908 	        sortMethod = CFileManagerEngine::EByMatch;
       
  4909 	        break;
       
  4910 	        }
       
  4911 	    default:
       
  4912 	        {
       
  4913 	        return;
       
  4914 	        }
       
  4915         }
       
  4916     if ( iEngine.SortMethod() != sortMethod )
       
  4917         {
       
  4918         iIndex = 0;
       
  4919         if ( iContainer )
       
  4920             {
       
  4921             iContainer->SetCurrentItemIndexAfterSearch( 0 );
       
  4922             }
       
  4923         iEngine.SetCurrentIndex( 0 );
       
  4924         iEngine.SetSortMethod( sortMethod );
       
  4925         iEngine.RefreshSort();
       
  4926         }
       
  4927     }
       
  4928 
       
  4929 // -----------------------------------------------------------------------------
       
  4930 // CFileManagerViewBase::FeatureManager
       
  4931 // 
       
  4932 // -----------------------------------------------------------------------------
       
  4933 // 
       
  4934 CFileManagerFeatureManager& CFileManagerViewBase::FeatureManager() const
       
  4935     {
       
  4936     return iEngine.FeatureManager();
       
  4937     }
       
  4938 
       
  4939 // -----------------------------------------------------------------------------
       
  4940 // CFileManagerViewBase::NotifyForegroundStatusChange
       
  4941 // 
       
  4942 // -----------------------------------------------------------------------------
       
  4943 // 
       
  4944 void CFileManagerViewBase::NotifyForegroundStatusChange( TBool /*aForeground*/ )
       
  4945     {
       
  4946     }
       
  4947 
       
  4948 // -----------------------------------------------------------------------------
       
  4949 // CFileManagerViewBase::ShowDiskSpaceErrorL
       
  4950 // 
       
  4951 // -----------------------------------------------------------------------------
       
  4952 // 
       
  4953 #ifdef RD_MULTIPLE_DRIVE
       
  4954 
       
  4955 void CFileManagerViewBase::ShowDiskSpaceErrorL( const TDesC& aFolder )
       
  4956     {
       
  4957     TInt defaultNameResId( 0 );
       
  4958     TInt namedResId( 0 );
       
  4959     TInt drv( KErrNotFound );
       
  4960     if ( aFolder.Length() )
       
  4961         {
       
  4962         TFileManagerDriveInfo drvInfo;
       
  4963         drv = TDriveUnit( aFolder );
       
  4964         iEngine.GetDriveInfoL( drv, drvInfo );
       
  4965         if ( drvInfo.iState & TFileManagerDriveInfo::EDriveMassStorage )
       
  4966             {
       
  4967             defaultNameResId = R_QTN_MEMLO_NOT_ENOUGH_MASS_MEMORY;
       
  4968             }
       
  4969         else if ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable )
       
  4970             {
       
  4971             defaultNameResId = R_QTN_MEMLO_NOT_ENOUGH_MEMORY_CARD_DEFAULTNAME;
       
  4972             namedResId = R_QTN_MEMLO_NOT_ENOUGH_MEMORY_CARD_NAME;
       
  4973             }
       
  4974         else if ( !( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote ) )
       
  4975             {
       
  4976             defaultNameResId = R_QTN_MEMLO_NOT_ENOUGH_DEVICE_MEMORY;
       
  4977             }
       
  4978         }
       
  4979     if ( defaultNameResId )
       
  4980         {
       
  4981         HBufC* text = iEngine.GetFormattedDriveNameLC(
       
  4982             drv, defaultNameResId, namedResId );
       
  4983         FileManagerDlgUtils::ShowConfirmQueryWithOkL(
       
  4984             FileManagerDlgUtils::EErrorIcons, *text );
       
  4985         CleanupStack::PopAndDestroy( text );
       
  4986         }
       
  4987     else
       
  4988         {
       
  4989         Error( KErrDiskFull ); // Show general error
       
  4990         }
       
  4991     }
       
  4992 
       
  4993 #else // RD_MULTIPLE_DRIVE
       
  4994 
       
  4995 void CFileManagerViewBase::ShowDiskSpaceErrorL( const TDesC& /*aFolder*/ )
       
  4996     {
       
  4997     Error( KErrDiskFull ); // Show general error
       
  4998     }
       
  4999 
       
  5000 #endif // RD_MULTIPLE_DRIVE
       
  5001 
       
  5002 // -----------------------------------------------------------------------------
       
  5003 // CFileManagerViewBase::DoLaunchProgressDialogAsync
       
  5004 // 
       
  5005 // -----------------------------------------------------------------------------
       
  5006 // 
       
  5007 void CFileManagerViewBase::DoLaunchProgressDialogAsync()
       
  5008     {
       
  5009      // Store the bytes value to be restored after new launch
       
  5010     TInt64 prevBytes = iTotalTransferredBytes;
       
  5011 
       
  5012     // Ensure that current progress value is up to date
       
  5013     if ( iTotalTransferredBytes > iProgressCurrentValue &&
       
  5014          iTotalTransferredBytes <= iProgressFinalValue )
       
  5015         {
       
  5016         iProgressCurrentValue = iTotalTransferredBytes;
       
  5017         }
       
  5018 
       
  5019     TRAP_IGNORE( LaunchProgressDialogL(
       
  5020         iProgressFinalValue, iProgressCurrentValue, iActiveProcess, ETrue ) );
       
  5021 
       
  5022     iTotalTransferredBytes = prevBytes;
       
  5023     }
       
  5024 
       
  5025 // -----------------------------------------------------------------------------
       
  5026 // CFileManagerViewBase::LaunchProgressDialogAsync
       
  5027 // 
       
  5028 // -----------------------------------------------------------------------------
       
  5029 // 
       
  5030 TInt CFileManagerViewBase::LaunchProgressDialogAsync( TAny* aPtr )
       
  5031     {
       
  5032     static_cast< CFileManagerViewBase* >( aPtr )->DoLaunchProgressDialogAsync();
       
  5033     return KErrNone;
       
  5034     }
       
  5035 
       
  5036 // -----------------------------------------------------------------------------
       
  5037 // CFileManagerViewBase::HandleServerAppExit
       
  5038 // 
       
  5039 // -----------------------------------------------------------------------------
       
  5040 // 
       
  5041 void CFileManagerViewBase::HandleServerAppExit( TInt /*aReason*/ )
       
  5042     {
       
  5043     iEngine.SetAppExitOb( NULL );
       
  5044     iEngine.SetObserver( this );
       
  5045     iEngine.RefreshDirectory();
       
  5046     }
       
  5047 
       
  5048 // -----------------------------------------------------------------------------
       
  5049 // CFileManagerViewBase::EmptyPwd
       
  5050 // 
       
  5051 // -----------------------------------------------------------------------------
       
  5052 // 
       
  5053 void CFileManagerViewBase::EmptyPwd( TDes& aPwd )
       
  5054     {
       
  5055     aPwd.FillZ( aPwd.MaxLength( ) );
       
  5056     aPwd.Zero();
       
  5057     }
       
  5058 
       
  5059 // -----------------------------------------------------------------------------
       
  5060 // CFileManagerViewBase::ConvertCharsToPwd
       
  5061 // 
       
  5062 // -----------------------------------------------------------------------------
       
  5063 // 
       
  5064 void CFileManagerViewBase::ConvertCharsToPwd(
       
  5065         const TDesC& aWord, TDes8& aConverted )
       
  5066     {
       
  5067     // Make sure the target password is empty ( can't use the function here )
       
  5068     aConverted.FillZ( aConverted.MaxLength() );
       
  5069     aConverted.Zero();
       
  5070     TInt size( aWord.Size() );
       
  5071     if ( size )
       
  5072         {
       
  5073         if ( size > aConverted.MaxLength() )
       
  5074             {
       
  5075             size = aConverted.MaxLength();
       
  5076             }
       
  5077         aConverted.Copy( (TUint8*)aWord.Ptr(), size );
       
  5078         }
       
  5079     }
       
  5080 
       
  5081 // ------------------------------------------------------------------------------
       
  5082 // CFileManagerViewBase::DriveInfoAtCurrentPosL
       
  5083 //
       
  5084 // ------------------------------------------------------------------------------
       
  5085 //
       
  5086 TInt CFileManagerViewBase::DriveInfoAtCurrentPosL(
       
  5087         TFileManagerDriveInfo& aInfo )
       
  5088     {
       
  5089     TUid viewId( Id() );
       
  5090     if ( viewId == CFileManagerAppUi::KFileManagerMemoryStoreViewId ||
       
  5091          viewId == CFileManagerAppUi::KFileManagerFoldersViewId )
       
  5092         {
       
  5093         INFO_LOG1("CFileManagerViewBase::DriveInfoAtCurrentPosL viewId=%D", viewId.iUid)
       
  5094         // Use cached info
       
  5095         aInfo = DriveInfo();
       
  5096         return aInfo.iDrive;
       
  5097         }
       
  5098     
       
  5099     // Fetch info
       
  5100     if ( !iContainer )
       
  5101         {
       
  5102         return KErrNotFound;
       
  5103         }
       
  5104     if ( !iContainer->ListBoxNumberOfItems() )
       
  5105         {
       
  5106         return KErrNotFound;
       
  5107         }
       
  5108     CFileManagerItemProperties* prop = iEngine.GetItemInfoLC(
       
  5109         iContainer->ListBoxCurrentItemIndex() );
       
  5110     TInt ret( KErrNotFound );
       
  5111     TPtrC fullPath( prop->FullPath() );
       
  5112     if ( fullPath.Length() )
       
  5113         {
       
  5114         ret = TDriveUnit( fullPath );
       
  5115         iEngine.GetDriveInfoL( ret, aInfo );
       
  5116         }
       
  5117     CleanupStack::PopAndDestroy( prop );
       
  5118     return ret;
       
  5119     }
       
  5120 
       
  5121 //  End of File