filemanager/Engine/inc/CFileManagerRemovableDriveHandler.h
branchRCL_3
changeset 39 65326cf895ed
parent 0 6a9f87576119
equal deleted inserted replaced
38:491b3ed49290 39:65326cf895ed
       
     1 /*
       
     2 * Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Wraps removable drive functionality
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_FILEMANAGERREMOVABLEDRIVEHANDLER_H
       
    20 #define C_FILEMANAGERREMOVABLEDRIVEHANDLER_H
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <f32file.h>
       
    26 #include "MFileManagerProcessObserver.h"
       
    27 #include "MMMCScBkupEngineObserver.h"
       
    28 #include "CMMCScBkupArchiveInfo.h"
       
    29 #include "CFileManagerRestoreSettings.h"
       
    30 
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CMMCScBkupEngine;
       
    34 class CFileManagerUtils;
       
    35 class CFileManagerEngine;
       
    36 class CBaBackupSessionWrapper;
       
    37 class CFileManagerBackupSettings;
       
    38 
       
    39 
       
    40 // CLASS DECLARATION
       
    41 /**
       
    42 *  This class wraps removable drive functionality
       
    43 *
       
    44 *  @lib FileManagerEngine.lib
       
    45 *  @since S60 3.1
       
    46 */
       
    47 NONSHARABLE_CLASS(CFileManagerRemovableDriveHandler) :
       
    48         public CActive,
       
    49         public MMMCScBkupEngineObserver
       
    50     {
       
    51 
       
    52 public:
       
    53     /**
       
    54      * Two-phased constructor.
       
    55      */
       
    56     static CFileManagerRemovableDriveHandler* NewL(
       
    57         RFs& aFs,
       
    58         CFileManagerUtils& aUtils,
       
    59         CFileManagerEngine& aEngine );
       
    60 
       
    61     /**
       
    62      * Destructor
       
    63      */
       
    64     virtual ~CFileManagerRemovableDriveHandler();
       
    65 
       
    66 public: // New methods
       
    67     /**
       
    68      * Sets process observer for memory card operations
       
    69      * @param aObserver Pointer to observer or NULL,
       
    70      *                  ownership is not transferred
       
    71      */
       
    72     void SetObserver( MFileManagerProcessObserver* aObserver );
       
    73 
       
    74     /**
       
    75      * Starts eject process
       
    76      */
       
    77     void StartEjectL();
       
    78 
       
    79     /**
       
    80      * Starts format process
       
    81      * @param aDrive Drive number EDriveA...EDriveZ
       
    82      */
       
    83     void StartFormatL( const TInt aDrive );
       
    84 
       
    85     /**
       
    86      * Cancels ongoing process
       
    87      */
       
    88     void CancelProcess();
       
    89 
       
    90     /**
       
    91      * Checks does backup file exists
       
    92      * @return ETrue if exists. Otherwise EFalse.
       
    93      */
       
    94     TBool BackupFileExistsL( const TInt aDrive );
       
    95 
       
    96     /**
       
    97     * Starts backup process
       
    98     * @param aProcess Backup process to start
       
    99     */
       
   100     void StartBackupL(
       
   101         MFileManagerProcessObserver::TFileManagerProcess aProcess );
       
   102 
       
   103     /**
       
   104     * Starts restore process
       
   105     */
       
   106     void StartRestoreL();
       
   107 
       
   108     /**
       
   109     * Gets restore info array
       
   110     * @param aArray For storing restore info
       
   111     * @param aDrive For getting info from specific drive
       
   112     */
       
   113     void GetRestoreInfoArrayL(
       
   114         RArray< CFileManagerRestoreSettings::TInfo >& aArray,
       
   115         const TInt aDrive );
       
   116 
       
   117     /**
       
   118     * Checks is process ongoing
       
   119     */
       
   120     TBool IsProcessOngoing() const;
       
   121 
       
   122     /**
       
   123     * Gets create time of the latest backup archive
       
   124     * @param aBackupTime Stores the time
       
   125     */
       
   126     void LatestBackupTimeL( TTime& aBackupTime );
       
   127 
       
   128     /**
       
   129     * Deletes selected backups
       
   130     */
       
   131     void DeleteBackupsL();
       
   132 
       
   133 private: // From CActive
       
   134     /**
       
   135      * @see CActive
       
   136      */
       
   137     void DoCancel();
       
   138 
       
   139     /**
       
   140      * @see CActive
       
   141      */
       
   142     void RunL();
       
   143 
       
   144     /**
       
   145      * @see CActive
       
   146      */
       
   147     TInt RunError( TInt aError );
       
   148 
       
   149 private:
       
   150     /**
       
   151     * Constructors
       
   152     */
       
   153     CFileManagerRemovableDriveHandler(
       
   154         RFs& aFs,
       
   155         CFileManagerUtils& aUtils,
       
   156         CFileManagerEngine& aEngine );
       
   157 
       
   158     void ConstructL();
       
   159 
       
   160     /**
       
   161     * For periodic eject scan
       
   162     */
       
   163     static TInt EjectScanAndShutdownApps( TAny* ptr );
       
   164 
       
   165     /**
       
   166     * For periodic eject scan
       
   167     */
       
   168     void DoEjectScanAndShutdownL();
       
   169 
       
   170     /**
       
   171     * For periodic eject scan
       
   172     */
       
   173     void EjectComplete( TInt aErr );
       
   174 
       
   175     /**
       
   176     * Gets backup file name
       
   177     */
       
   178     HBufC* BackupFileNameLC( TBool aFullPath ) const;
       
   179 
       
   180     /**
       
   181     * Starts eject scan
       
   182     */
       
   183     void StartEjectScanL();
       
   184 
       
   185     void InformStartL( TInt aTotalCount );
       
   186 
       
   187     void InformUpdateL( TInt aCount );
       
   188 
       
   189     void InformFinishL( );
       
   190 
       
   191     void InformError( TInt aErr );
       
   192 
       
   193     void StartFormatProcessL();
       
   194 
       
   195     void EndFormatProcessL( TInt aErr );
       
   196 
       
   197     void CloseAppsL();
       
   198 
       
   199     void RestartAppsL();
       
   200 
       
   201     static void ResetAndDestroyArchives( TAny* aPtr );
       
   202 
       
   203     static TUint32 BkupToFmgrMask( const TUint32 aBkupMask );
       
   204 
       
   205     static TUint32 FmgrToBkupMask( const TUint32 aFmrgMask );
       
   206 
       
   207     void PublishBurStatus( TInt aType );
       
   208 
       
   209     TBool IsInternalMassStorage( TInt aDrive );
       
   210 
       
   211     void StoreVolumeNameL( TInt aDrive );
       
   212 
       
   213     void RestoreVolumeNameL( TInt aDrive );
       
   214     
       
   215     void ListArchivesL(
       
   216         RPointerArray< CMMCScBkupArchiveInfo >& aArchives,
       
   217         const CFileManagerBackupSettings& aBackupSettings );
       
   218 
       
   219 private: // From MMMCScBkupEngineObserver
       
   220     TInt HandleBkupEngineEventL(
       
   221         MMMCScBkupEngineObserver::TEvent aEvent, TInt aAssociatedData );
       
   222 
       
   223 private:    // Data
       
   224     /**
       
   225      * Backup engine
       
   226      * Own.
       
   227      */
       
   228     CMMCScBkupEngine* iBkupEngine;
       
   229 
       
   230     /**
       
   231      * Pointer to observer
       
   232      * Not own.
       
   233      */
       
   234     MFileManagerProcessObserver* iObserver;
       
   235 
       
   236     /**
       
   237      * Observed process
       
   238      */
       
   239     MFileManagerProcessObserver::TFileManagerProcess iProcess;
       
   240 
       
   241     /**
       
   242      * For file operations
       
   243      * Not own.
       
   244      */
       
   245     RFs& iFs;
       
   246 
       
   247     /**
       
   248      * For utility access
       
   249      * Not own.
       
   250      */
       
   251     CFileManagerUtils& iUtils;
       
   252 
       
   253     /**
       
   254      * For file manager engine access
       
   255      * Not own.
       
   256      */
       
   257     CFileManagerEngine& iEngine;
       
   258 
       
   259     /**
       
   260      * Last process error
       
   261      */
       
   262     TInt iLastError;
       
   263 
       
   264     /**
       
   265      * Final progress value
       
   266      */
       
   267     TInt iFinalValue;
       
   268 
       
   269     /**
       
   270      * For timed eject scanning steps
       
   271      * Own.
       
   272      */
       
   273     CPeriodic* iEjectScanPeriodic;
       
   274 
       
   275     /**
       
   276      * For eject scan round counting
       
   277      */
       
   278     TInt iEjectScanRounds;
       
   279 
       
   280     /**
       
   281      * Indicates if backup or restore is in progress
       
   282      */
       
   283     TBool iBackupRestoreInprogress;
       
   284 
       
   285     /**
       
   286      * For formatting drives
       
   287      */
       
   288     RFormat iFormatter;
       
   289 
       
   290     /**
       
   291      * For keeping track of formatting process progress
       
   292      */
       
   293     TPckgBuf< TInt > iFormatCountBuf;
       
   294 
       
   295     /**
       
   296      * For closing and restarting open files while formatting
       
   297      */
       
   298     CBaBackupSessionWrapper* iBSWrapper;
       
   299 
       
   300     /**
       
   301      * Target drive of the process
       
   302      */
       
   303     TInt iDrive;
       
   304 
       
   305     };
       
   306 
       
   307 #endif // C_FILEMANAGERREMOVABLEDRIVEHANDLER_H
       
   308             
       
   309 // End of File