webengine/widgetbackuprestore/Inc/WidgetActiveCallback.h
changeset 0 dd21522fd290
child 26 cb62a4f66ebe
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "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:  Widget's active callback in WidgetBackupRestore.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef WIDGETACTIVECALLBACK_H
       
    20 #define WIDGETACTIVECALLBACK_H
       
    21 
       
    22 #include <e32base.h>    // CBase
       
    23 #include <abclient.h>
       
    24 #ifdef _DEBUG
       
    25 #include <flogger.h>
       
    26 #endif
       
    27 
       
    28 class CWidgetInstaller;
       
    29 
       
    30 /**
       
    31  *  Widget's active callback in backup/restore.
       
    32  *
       
    33  *  @lib widgetbackuprestore.exe
       
    34  *  @since S60 v3.2
       
    35  */
       
    36 NONSHARABLE_CLASS(CWidgetActiveCallback) : public CBase, public conn::MActiveBackupDataClient
       
    37     {
       
    38 public:
       
    39 
       
    40     IMPORT_C static  CWidgetActiveCallback* NewL();
       
    41 
       
    42     virtual ~CWidgetActiveCallback();
       
    43 
       
    44 // new functions
       
    45 
       
    46     /**
       
    47     * CleanupBackupDataL
       
    48     *
       
    49     * Delete the temporary files
       
    50     *
       
    51     * @since  3.2
       
    52     * @return none
       
    53     */	 
       
    54     void CleanupBackupDataL();
       
    55     
       
    56 
       
    57 // from base class MActiveBackupDataClient
       
    58 
       
    59     /**
       
    60      * This method informs the active backup data client that all 
       
    61      * snapshots have been supplied. If the client has not
       
    62      * received a snapshot then it should perform a base backup
       
    63      */
       
    64     virtual void AllSnapshotsSuppliedL();
       
    65 
       
    66     /**
       
    67      * This method receives all or part of a snapshot of data to allow 
       
    68      * calculation of an incremental backup.  The snapshot is one that
       
    69      * was previously supplied by the data owner.  The snapshot data 
       
    70      * should be read from the location supplied. The snapshot data may
       
    71      * be larger than the location supplied in which case the routine 
       
    72      * will be called repeatedly until all data has been supplied.
       
    73      *
       
    74      * Snapshot data will also be supplied as part of a restore operation
       
    75      *        
       
    76      * @param aDrive the drive being backed up
       
    77      * @param aBuffer a pointer to the base of the location from whence 
       
    78      *        data can be copied.
       
    79      * @param aLastSection ETrue if this is the last section of snapshot 
       
    80      *        data, else EFalse.
       
    81      */
       
    82     virtual void ReceiveSnapshotDataL(
       
    83         TDriveNumber aDrive, TDesC8& aBuffer, TBool aLastSection);
       
    84 
       
    85     /**
       
    86      * This method returns the expected size of backup data that will be
       
    87      * supplied. If an incremental backup is underway then this method
       
    88      * then this method will not be called until after 
       
    89      * ReceiveSnapshotDataL(). The size data will be used for the purpose
       
    90      * of tracking progess during a backup. If it is inaccurate then the
       
    91      * user may see irregular progress but the actual backup data will 
       
    92      * not be affected so it is acceptable to return an estimated value.
       
    93      *
       
    94      * @param aDrive the drive being backed up.
       
    95      * @return the size of the data that will be returned
       
    96      */
       
    97     virtual TUint GetExpectedDataSize(TDriveNumber aDrive);
       
    98 
       
    99     /**
       
   100      * This method returns a snapshot of data to accompany a backup. The 
       
   101      * snapshot is expected to contain details on files / data being 
       
   102      * backed up. The format of the snapshot is only meaningful to the
       
   103      * data owner. The snapshot will be supplied if the data owner is 
       
   104      * asked for an incremental backup and for a restore operation. The 
       
   105      * snapshot data should be copied to the location supplied.
       
   106      *
       
   107      * The snapshot data may be larger than the location supplied in 
       
   108      * which case the routine will be called repeatedly until all data
       
   109      * has been retrieved.
       
   110      *
       
   111      * @param aDrive the drive being backed up
       
   112      * @param aBuffer a pointer to the base of the location where data 
       
   113      *        can be copied.
       
   114      * @param aFinished on return ETrue if all data has been returned 
       
   115      *        for this drive, else EFalse.
       
   116      */
       
   117     virtual void GetSnapshotDataL( 
       
   118         TDriveNumber aDrive, TPtr8& aBuffer, TBool& aFinished);
       
   119 
       
   120     /**
       
   121      * This method prepares the implementor to return backup data. It 
       
   122      * will be followed by a sequence of calls to request the actual 
       
   123      * data.
       
   124      *        
       
   125      * @param aDrive the drive being backed up.
       
   126      */
       
   127     virtual void InitialiseGetBackupDataL(TDriveNumber aDrive);
       
   128 
       
   129     /**
       
   130      * This method requests a section of backup data.  
       
   131      * InitialiseGetBackupDataL() will have been called previously to
       
   132      * specify the drive concerned.  The data returned may be base or
       
   133      * incremental depending on the type of backup and the capability of
       
   134      * the data owner.
       
   135      *
       
   136      * @param aBuffer a pointer to the base of the location where data 
       
   137      *        can be copied.
       
   138      * @param aFinished on return ETrue if all data has been returned 
       
   139      *        for this drive, else EFalse.
       
   140      */
       
   141     virtual void GetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished);
       
   142 
       
   143     /**
       
   144      * This method prepares the implementor to receive base restore data
       
   145      * for a drive. It will be followed by a sequence of calls to supply
       
   146      * the actual data.
       
   147      *
       
   148      * @param aDrive the drive being restored.
       
   149      */
       
   150     virtual void InitialiseRestoreBaseDataL(TDriveNumber aDrive);
       
   151 
       
   152     /**
       
   153      * This method receives a section of base restore data.
       
   154      * InitialiseRestoreBaseDataL() will have been called previously to 
       
   155      * specify the drive concerned.
       
   156      *
       
   157      * @param aBuffer a pointer to the base of the location whence data
       
   158      *        can be read.
       
   159      * @param aFinished ETrue if all data has been returned for this 
       
   160      *        drive, else EFalse.
       
   161      */
       
   162     virtual void RestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished);
       
   163 
       
   164     /**
       
   165      * This method prepares the implementor to receive incremental 
       
   166      * restore data for a drive. It will be followed by a sequence 
       
   167      * of calls to supply the actual data.  If multiple increments
       
   168      * are supplied then this methid will be called before each increment
       
   169      *
       
   170      * @param aDrive the drive being restored.
       
   171      */
       
   172     virtual void InitialiseRestoreIncrementDataL(TDriveNumber aDrive);
       
   173 
       
   174     /**
       
   175      * This method receives a section of increment restore data.
       
   176      * InitialiseRestoreIncrementDataL() will have been called 
       
   177      * previously to specify the drive concerned.
       
   178      *
       
   179      * @param aBuffer a pointer to the base of the location whence data 
       
   180      *        can be read.
       
   181      * @param aFinished ETrue if all data has been returned for this 
       
   182      *        increment, else EFalse.
       
   183      */
       
   184     virtual void RestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished);
       
   185 
       
   186     /**
       
   187      * This method is called when all data to be restored has been 
       
   188      * supplied.
       
   189      *
       
   190      * @param aDrive the drive being restored.
       
   191      */
       
   192     virtual void RestoreComplete(TDriveNumber aDrive);   
       
   193 
       
   194     /**
       
   195      * This method is called if copying of data is terminated prematurely 
       
   196      * to allow the implementor to tidy up.  The same method applies to 
       
   197      * all types of data and to backup and restore.
       
   198      */
       
   199     virtual void TerminateMultiStageOperation();
       
   200 
       
   201     /**
       
   202      * Gets a 32-bit checksum for its private data.
       
   203      * This routine is for test purposes.  It must be implemented but an
       
   204      * invariant checksum value can be provided.  Some tests may cause 
       
   205      * checksum values to be compared.
       
   206      *
       
   207      * @param aDrive the drive containing data being checksummed
       
   208      * @return the 32-bit checksum
       
   209      */
       
   210     virtual TUint GetDataChecksum(TDriveNumber aDrive);
       
   211 
       
   212 private:
       
   213 
       
   214     CWidgetActiveCallback();
       
   215 
       
   216     void ConstructL();
       
   217 
       
   218     /**
       
   219     * This method is called when a backup operation is starting.
       
   220     * Preparations can be done to prepare for BUR.
       
   221     * Copy private area from widget ui to widget registry.
       
   222     */
       
   223     void PrepareBackupDataL();
       
   224 
       
   225     /**
       
   226     * Perform installation.
       
   227     * @since 3.2
       
   228     */
       
   229     void InstallL();
       
   230 
       
   231 private: // data
       
   232 
       
   233     /**
       
   234      * File system session.
       
   235      */
       
   236     RFs iFs;
       
   237 
       
   238     HBufC16* iPathBUR;
       
   239 
       
   240 #ifdef _DEBUG
       
   241     RFileLogger             iFileLogger;
       
   242     TBool                   iCanLog;
       
   243 #endif
       
   244     };
       
   245 
       
   246 #endif // WIDGETACTIVECALLBACK_H
       
   247