filemanager/Engine/inc/CFileManagerActiveExecute.h
changeset 0 6a9f87576119
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:  Handles the copy/move operation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CFILEMANAGERACTIVEEXECUTE_H
       
    21 #define CFILEMANAGERACTIVEEXECUTE_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <f32file.h>
       
    26 #include <badesca.h>
       
    27 #include "FileManagerEngine.hrh"
       
    28 #include "MFileManagerProcessObserver.h"
       
    29 #include "MFileManagerThreadFunction.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CFileManagerEngine;
       
    33 class MFileManagerItemIterator;
       
    34 //class CMGXFileManager;
       
    35 class CFileManagerThreadWrapper;
       
    36 
       
    37 /**
       
    38 *  CFileManagerActiveExecute
       
    39 *
       
    40 *  Handles the copy and move operations.
       
    41 *
       
    42 *  @lib FileManagerEngine.lib
       
    43 *  @since 2.0
       
    44 */
       
    45 NONSHARABLE_CLASS(CFileManagerActiveExecute) : public CActive,
       
    46                                                public MFileManagerThreadFunction
       
    47 
       
    48     {
       
    49 
       
    50     public:
       
    51         
       
    52         /**
       
    53         * Overwrite file switch
       
    54         */
       
    55         enum TFileManagerSwitch
       
    56             {
       
    57             ENoOverWrite = 1,
       
    58             EOverWrite
       
    59             };
       
    60         
       
    61         /**
       
    62         * Two-phased constructor.
       
    63         * @since 2.0
       
    64         * @param aEngine    reference to CFileManagerEngine instance
       
    65         * @param aOperation defines type of operation copy or move
       
    66         * @param aObserver  reference to MFileManagerProcess implemented
       
    67         *                   instance
       
    68         * @param aIndexList list of indexes from current view which needs operation
       
    69         * @param aToFolder  folder where items are moved or copied
       
    70         * @return Newly constructed CFileManagerActiveExecute
       
    71         */
       
    72         IMPORT_C static CFileManagerActiveExecute* NewL( 
       
    73             CFileManagerEngine& aEngine,
       
    74             MFileManagerProcessObserver::TFileManagerProcess aOperation,
       
    75             MFileManagerProcessObserver& aObserver,
       
    76             CArrayFixFlat<TInt>& aIndexList,
       
    77             const TDesC& aToFolder );
       
    78 
       
    79         /**
       
    80         * Destructor
       
    81         */
       
    82         IMPORT_C ~CFileManagerActiveExecute();
       
    83         
       
    84         /**
       
    85         * Executes one operation at time, one file copy/move or directory creation
       
    86         * @since 2.0
       
    87         * @param aOverWrite Over write the file or not
       
    88         */
       
    89         IMPORT_C void ExecuteL( TFileManagerSwitch aOverWrite );
       
    90         
       
    91         /**
       
    92         * Cancel the operation
       
    93         * @since 2.0
       
    94         */
       
    95         IMPORT_C void CancelExecution();
       
    96 
       
    97         /**
       
    98         * Gets destination folder
       
    99         * @since 3.2
       
   100         */
       
   101         IMPORT_C TPtrC ToFolder();
       
   102         
       
   103     private:
       
   104         
       
   105         // From CActive
       
   106         void DoCancel();
       
   107         void RunL();
       
   108         TInt RunError(TInt aError);
       
   109         
       
   110     private:
       
   111         /**
       
   112         * C++ default constructor.
       
   113         */
       
   114         CFileManagerActiveExecute( CFileManagerEngine& aEngine,
       
   115             MFileManagerProcessObserver::TFileManagerProcess aOperation,
       
   116             MFileManagerProcessObserver& aObserver );
       
   117         
       
   118         /**
       
   119         * By default Symbian 2nd phase constructor is private.
       
   120         */
       
   121         void ConstructL( CArrayFixFlat<TInt>& aIndexList,
       
   122             const TDesC& aToFolder );
       
   123         
       
   124     private:
       
   125         
       
   126         /**
       
   127         * Item operation was succesfully carried on, move to next item
       
   128         */
       
   129         void KErrNoneActionL();
       
   130         
       
   131         /**
       
   132         * Item operation was not succesful because there was target item already
       
   133         * This function deals that situation
       
   134         */
       
   135         void KErrAlreadyExistsActionL();
       
   136         
       
   137         /**
       
   138         * Takes last folder name on other string and appends it to other
       
   139         * @param aResult Stores the result as full path
       
   140         * @param aSrc source full path which last folder name is taken
       
   141         * @param aDst target path where source last path is appended
       
   142         */
       
   143         void AddLastFolder( TDes& aResult, const TDesC& aSrc, const TDesC& aDst );
       
   144 
       
   145         /**
       
   146         * Performs a copy or move operation
       
   147         * 
       
   148         * @param aSwitch indicate destination file to be overwritten or not
       
   149         * @return system wide error code
       
   150         */
       
   151         TInt DoOperation( TInt aSwitch );
       
   152 
       
   153         /**
       
   154         * Checks if directory is empty
       
   155         * 
       
   156         * @param aDir Full path of the directory
       
   157         * @return ETrue if directory is empty, otherwise EFalse
       
   158         */
       
   159         TBool IsEmptyDir( const TDesC& aDir );
       
   160 
       
   161         /**
       
   162         * Completes operation
       
   163         * 
       
   164         * @param aError Operation result
       
   165         */
       
   166         void CompleteL( TInt aError );
       
   167 
       
   168         /**
       
   169         * Updates MG2 notifications
       
   170         * 
       
   171         * @param aForceFlush Indicates if notications are flushed
       
   172         * @param aError Indicates the result
       
   173         */
       
   174         void UpdateNotifications( TBool aFlush, TInt aError );
       
   175 
       
   176         static void AppendArrayIfNotFound(
       
   177             CDesCArray& aArray, const TDesC& aFullPath );
       
   178 
       
   179         void FlushArray( CDesCArray& aArray );
       
   180 
       
   181         void ThreadCopyOrMoveStepL();
       
   182 
       
   183         void ThreadFinalizeMoveStepL();
       
   184 
       
   185     private: // From MFileManagerThreadFunction
       
   186 
       
   187         void ThreadStepL();
       
   188 
       
   189         TBool IsThreadDone();
       
   190 
       
   191         void NotifyThreadClientL( TNotifyType aType, TInt aValue );
       
   192 
       
   193     private:
       
   194         
       
   195         // index to current CDir array
       
   196         TInt    iCurrentIndex;
       
   197         
       
   198         // Own: Source item with full path
       
   199         HBufC*  iFullPath;
       
   200         
       
   201         // Own: Destination item with full path
       
   202         HBufC*  iDestination;
       
   203         
       
   204         // Has user cancelled the operation
       
   205         TBool   iCancelled;
       
   206         
       
   207         // Source directory is empty so special operations are needed
       
   208         TBool   iEmptyDir;
       
   209         
       
   210         // Needed to get the item locations behind given index(es)
       
   211         CFileManagerEngine&             iEngine;
       
   212 
       
   213         // Ref: Shareable file server session
       
   214         RFs& iFs;
       
   215 
       
   216         // Move or copy operation
       
   217         MFileManagerProcessObserver::TFileManagerProcess    iOperation;
       
   218         
       
   219         // Own: Array of user selected items to be copied/moved
       
   220         CArrayFixFlat< TInt >*            iIndexList;
       
   221         
       
   222         // Own: user given destination folder
       
   223         HBufC*                          iToFolder;
       
   224         
       
   225         // Own: This is either CFileManagerIndexIterator or CFileManagerFileSystemIterator
       
   226         // depending of source item type, file or folder
       
   227         MFileManagerItemIterator*       iItemIterator;
       
   228         
       
   229         // Ref: File operation phases are signaled through this interface
       
   230         MFileManagerProcessObserver&    iObserver;
       
   231 
       
   232         // Ref: Current source item with full path
       
   233         // Needed for file already exist situations.
       
   234         HBufC* iSrc;
       
   235         
       
   236         // Ref: Current destination item with full path
       
   237         // Needed for file already exist situations.
       
   238         HBufC* iDst;
       
   239         
       
   240         // Total transferred bytes, used for progress note
       
   241         // except in same drive move operation
       
   242         TUint iBytesTransferredTotal;
       
   243         
       
   244         // Total transferred files, used for progress note
       
   245         // This is used if move operation is done inside drive
       
   246         TInt iFilesTransferredTotal;
       
   247         
       
   248         // Current error
       
   249         TInt iError;
       
   250 
       
   251         // Ref: MG2 update notification object
       
   252         //CMGXFileManager* iMgxFileManager;
       
   253 
       
   254         // Own: Thread wrapper for the operation
       
   255         CFileManagerThreadWrapper* iThreadWrapper;
       
   256 
       
   257         // Indicates the used operation switches
       
   258         TInt iSwitch;
       
   259 
       
   260         // Own: Buffer for storing changed items for MG2 notifications
       
   261         CDesCArray* iChangedSrcItems;
       
   262 
       
   263         // Own: Buffer for storing changed items for MG2 notifications
       
   264         CDesCArray* iChangedDstItems;
       
   265 
       
   266         // Indicates that the operation is done inside same drive
       
   267         TBool iOperationOnSameDrive;
       
   268 
       
   269         // Indicates that move operation is finalizing
       
   270         TBool iFinalizeMove;
       
   271 
       
   272         // Indicates that source of the operation is on remote drive
       
   273         TBool iIsSrcRemoteDrive;
       
   274 
       
   275         // Indicates that destination of the operation is on remote drive
       
   276         TBool iIsDstRemoteDrive;
       
   277 
       
   278         // Stores type of the current item
       
   279         TFileManagerTypeOfItem iItemType;
       
   280     };
       
   281     
       
   282 #endif // CFILEMANAGERACTIVEEXECUTE_H
       
   283     
       
   284     // End of File