javamanager/javabackup/midp2backup_usif/src.s60/midp2backuppluginusif.h
branchRCL_3
changeset 83 26b2b12093af
parent 77 7cee158cb8cd
child 84 0553e2305d00
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
     1 /*
       
     2 * Copyright (c) 2009 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:  Header file for CMidp2BackupPlugin class with USIF changes
       
    15 *
       
    16 */
       
    17 #ifndef MIDP2BACKUPPLUGINUSIF_H_
       
    18 #define MIDP2BACKUPPLUGINUSIF_H_
       
    19 
       
    20 #include "backupplugin.h"
       
    21 #include <apadef.h>
       
    22 #include "logger.h"
       
    23 
       
    24 class RDesWriteStream;
       
    25 class RDesReadStream;
       
    26 
       
    27 namespace java
       
    28 {
       
    29 namespace backup
       
    30 {
       
    31 
       
    32 
       
    33 class CJavaVersionBackupUtil;
       
    34 class CStorageBackupUtil;
       
    35 class CScrBackupUtil;
       
    36 
       
    37 
       
    38 /**
       
    39  *  CMidp2BackupPlugin class is handling backup and restore operations
       
    40  *  for MIDlets
       
    41  *
       
    42  *  This class is instantiated when a BUR operation is starting.
       
    43  */
       
    44 class CMidp2BackupPlugin : public CBackupPlugin
       
    45 {
       
    46 
       
    47 public:
       
    48 
       
    49     /**
       
    50      * Instantiates an object of this type
       
    51      */
       
    52     static CMidp2BackupPlugin* NewL();
       
    53 
       
    54     ~CMidp2BackupPlugin();
       
    55 
       
    56 
       
    57     // from base class CBackupPlugin
       
    58 
       
    59     /**
       
    60      * This method is called when a backup or restore operation is
       
    61      * starting. Preparations can be done to prepare for BUR.
       
    62      *
       
    63      * @param aBackupStateValue the value of the current backup state
       
    64      */
       
    65     void PrepareForBURL(TInt aBackupStateValue);
       
    66 
       
    67     /**
       
    68      * This method receives all or part of a snapshot of data to allow
       
    69      * calculation of an incremental backup.  The snapshot is one that
       
    70      * was previously supplied by the data owner.  The snapshot data
       
    71      * should be read from the location supplied. The snapshot data may
       
    72      * be larger than the location supplied in which case the routine
       
    73      * will be called repeatedly until all data has been supplied.
       
    74      *
       
    75      * Snapshot data will also be supplied as part of a restore operation
       
    76      *
       
    77      * @param aDrive the drive being backed up
       
    78      * @param aBuffer a pointer to the base of the location from whence
       
    79      *        data can be copied.
       
    80      * @param aLastSection ETrue if this is the last section of snapshot
       
    81      *        data, else EFalse.
       
    82      */
       
    83     void ReceiveSnapshotDataL(TDriveNumber aDrive,
       
    84                               TDesC8& aBuffer,
       
    85                               TBool aLastSection);
       
    86 
       
    87     /**
       
    88      * This method returns the expected size of backup data that will be
       
    89      * supplied. If an incremental backup is underway then this method
       
    90      * will not be called until after ReceiveSnapshotDataL().
       
    91      * The size data will be used for the purpose of tracking progess
       
    92      * during a backup. If it is inaccurate then the user may see
       
    93      * irregular progress but the actual backup data will not be
       
    94      * affected so it is acceptable to return an estimated value.
       
    95      *
       
    96      * @param aDrive the drive being backed up.
       
    97      * @return the size of the data that will be returned
       
    98      */
       
    99     TUint GetExpectedDataSize(TDriveNumber aDrive);
       
   100 
       
   101     /**
       
   102      * This method returns a snapshot of data to accompany a backup. The
       
   103      * snapshot is expected to contain details on files / data being
       
   104      * backed up. The format of the snapshot is only meaningful to the
       
   105      * data owner. The snapshot will be supplied if the data owner is
       
   106      * asked for an incremental backup and for a restore operation. The
       
   107      * snapshot data should be copied to the location supplied.
       
   108      *
       
   109      * The snapshot data may be larger than the location supplied in
       
   110      * which case the routine will be called repeatedly until all data
       
   111      * has been retrieved.
       
   112      *
       
   113      * @param aDrive the drive being backed up
       
   114      * @param aBuffer a pointer to the base of the location where data
       
   115      *        can be copied.
       
   116      * @param aFinished on return ETrue if all data has been returned
       
   117      *        for this drive, else EFalse.
       
   118      */
       
   119     void GetSnapshotDataL(TDriveNumber aDrive,
       
   120                           TPtr8& aBuffer,
       
   121                           TBool& aFinished);
       
   122 
       
   123     /**
       
   124      * This method prepares the implementor to return backup data. It
       
   125      * will be followed by a sequence of calls to request the actual
       
   126      * data.
       
   127      *
       
   128      * @param aDrive the drive being backed up.
       
   129      */
       
   130     void InitialiseGetBackupDataL(TDriveNumber aDrive);
       
   131 
       
   132     /**
       
   133      * This method requests a section of backup data.
       
   134      * InitialiseGetBackupDataL() will have been called previously to
       
   135      * specify the drive concerned.  The data returned may be base or
       
   136      * incremental depending on the type of backup and the capability of
       
   137      * the data owner.
       
   138      *
       
   139      * @param aBuffer a pointer to the base of the location where data
       
   140      *        can be copied.
       
   141      * @param aFinished on return ETrue if all data has been returned
       
   142      *        for this drive, else EFalse.
       
   143      */
       
   144     void GetBackupDataSectionL(TPtr8& aBuffer,
       
   145                                TBool& aFinished);
       
   146 
       
   147     /**
       
   148      * This method prepares the implementor to receive base restore data
       
   149      * for a drive. It will be followed by a sequence of calls to supply
       
   150      * the actual data.
       
   151      *
       
   152      * @param aDrive the drive being restored.
       
   153      */
       
   154     void InitialiseRestoreBaseDataL(TDriveNumber aDrive);
       
   155 
       
   156     /**
       
   157      * This method receives a section of base restore data.
       
   158      * InitialiseRestoreBaseDataL() will have been called previously to
       
   159      * specify the drive concerned.
       
   160      *
       
   161      * @param aBuffer a pointer to the base of the location whence data
       
   162      *        can be read.
       
   163      * @param aFinished ETrue if all data has been returned for this
       
   164      *        drive, else EFalse.
       
   165      */
       
   166     void RestoreBaseDataSectionL(TDesC8& aBuffer,
       
   167                                  TBool aFinished);
       
   168 
       
   169     /**
       
   170      * This method prepares the implementor to receive incremental
       
   171      * restore data for a drive. It will be followed by a sequence
       
   172      * of calls to supply the actual data.  If multiple increments
       
   173      * are supplied then this methid will be called before each increment
       
   174      *
       
   175      * @param aDrive the drive being restored.
       
   176      */
       
   177     void InitialiseRestoreIncrementDataL(TDriveNumber aDrive);
       
   178 
       
   179     /**
       
   180      * This method receives a section of increment restore data.
       
   181      * InitialiseRestoreIncrementDataL() will have been called
       
   182      * previously to specify the drive concerned.
       
   183      *
       
   184      * @param aBuffer a pointer to the base of the location whence data
       
   185      *        can be read.
       
   186      * @param aFinished ETrue if all data has been returned for this
       
   187      *        increment, else EFalse.
       
   188      */
       
   189     void RestoreIncrementDataSectionL(TDesC8& aBuffer,
       
   190                                       TBool aFinished);
       
   191 
       
   192     /**
       
   193      * This method is called when all data to be restored has been
       
   194      * supplied.
       
   195      *
       
   196      * @param aDrive the drive being restored.
       
   197      */
       
   198     void RestoreComplete(TDriveNumber aDrive);
       
   199 
       
   200 private:
       
   201 
       
   202     CMidp2BackupPlugin();
       
   203 
       
   204     void ConstructL();
       
   205 
       
   206     /**
       
   207      * This method is called to get the unique Id of the current MMC
       
   208      *
       
   209      * @return The Id of the MMC, or 0, if no MMC is inserted
       
   210      */
       
   211     TUint MmcIdL();
       
   212 
       
   213     /**
       
   214      * This method is called to process the content of the buffer
       
   215      * provided in active phase of restore
       
   216      *
       
   217      * @param aBuffer the buffer to process
       
   218      */
       
   219     void ProcessBufferL(RDesReadStream& stream);
       
   220 
       
   221     /**
       
   222      * This method is called to restore the Java Registry entries
       
   223      * on the MMC, if needed
       
   224      */
       
   225     void RestoreMmcRegistryL();
       
   226 
       
   227     /**
       
   228      * This method creates the path for the Java Registry entries on
       
   229      * the specified MMC
       
   230      *
       
   231      * @param [out] aPathName path of the entries of the MMC
       
   232      * @param aDrive drive of the MMC
       
   233      * @param aUniqueId Unique Id of the MMC
       
   234      */
       
   235     void CreateMmcPath(TDes& aPathName,
       
   236                        TInt aDrive,
       
   237                        TUint aUniqueId);
       
   238 
       
   239     /**
       
   240      * This method gets the path for the next icon file to be backed up
       
   241      *
       
   242      * @param [out] aCurrentUid Uid of the next icon
       
   243      * @param [out] aFullFileName path of the next icon
       
   244      * @return EFalse if there are no more icons in the array, ETrue
       
   245      *         otherwise
       
   246      */
       
   247     //TBool NextIcon(TUid& aCurrentUid, HBufC*& aFullFileName);
       
   248 
       
   249     /**
       
   250      * Process buffer when restore state is EFirstBuffer
       
   251      *
       
   252      * @param aStream readstream of buffer to process
       
   253      * @param aBufferSpaceLeft space left of buffer to be processed
       
   254      */
       
   255    // void ProcessFirstBufferL(RDesReadStream& aStream, TInt& aBufferSpaceLeft);
       
   256 
       
   257     /**
       
   258      * Process buffer when restore state is EInIcon
       
   259      *
       
   260      * @param aStream readstream of buffer to process
       
   261      * @param aBufferSpaceLeft space left of buffer to be processed
       
   262      */
       
   263    // void ProcessInIconL(RDesReadStream& aStream, TInt& aBufferSpaceLeft);
       
   264 
       
   265     /**
       
   266      * Process buffer when restore state is EInSize
       
   267      *
       
   268      * @param aStream readstream of buffer to process
       
   269      * @param aBufferSpaceLeft space left of buffer to be processed
       
   270      */
       
   271     //void ProcessInSizeL(RDesReadStream& aStream, TInt& aBufferSpaceLeft);
       
   272 
       
   273     /**
       
   274      * Resets the array of icons to be backed up
       
   275      */
       
   276     //void ResetIconArray();
       
   277 
       
   278 private: // data
       
   279 
       
   280     /**
       
   281      * File session
       
   282      * Own.
       
   283      */
       
   284     RFs iFs;
       
   285 
       
   286     /**
       
   287      * StorageBackupUtil object for storage B&R
       
   288      * Own.
       
   289      */
       
   290     CStorageBackupUtil* iStorageBackupUtil;
       
   291     /**
       
   292      * CScrBackupUtil object for SCR B&R
       
   293      * Own.
       
   294      */
       
   295     CScrBackupUtil* iScrBackupUtil;
       
   296     /**
       
   297      * The drive that is backed up or restored currently
       
   298      * Own.
       
   299      */
       
   300     TDriveNumber iDrive;
       
   301 
       
   302     /**
       
   303      * Id of backed up drive, gets its value from restored data
       
   304      * Own.
       
   305      */
       
   306     TInt32 iBackupDrive;
       
   307 
       
   308     /**
       
   309      * Id of backed up MMC, gets its value from restored data
       
   310      * Own.
       
   311      */
       
   312     TUint32 iBackupMmc;
       
   313 
       
   314     /**
       
   315      * State of streaming during restore
       
   316      * Own.
       
   317      */
       
   318     TInt iRestoreState;
       
   319 
       
   320     /**
       
   321      * Shows if it's the first call to GetBackupDataSectionL
       
   322      * Own.
       
   323      */
       
   324     TBool iFirstCallToGetBackupDataSection;
       
   325 
       
   326     /**
       
   327      * Shows if Backup of storage data is finished or not
       
   328      * Own.
       
   329      */
       
   330     TBool iStorageDataBackup;
       
   331     /**
       
   332      * Shows if Backup of SCR is finished or not
       
   333      * Own.
       
   334      */
       
   335     TBool iScrDataBackup;
       
   336 
       
   337     /**
       
   338      * Shows if Restore of storage data is finished or not
       
   339      * Own.
       
   340      */
       
   341     TBool iStorageDataRestore;
       
   342 
       
   343     /**
       
   344      * Shows if Java version information is already written or not
       
   345      * Own
       
   346      */
       
   347     TBool iJavaVersionInfoWritten;
       
   348 
       
   349     /**
       
   350      * Shows if its the first call to restore data or not.
       
   351      * Own.
       
   352      */
       
   353     TBool iFirstCallToRestoreBackupDataSection;
       
   354 
       
   355     /**
       
   356      * Stores the uids of the midlets whose icons are to be backed up.
       
   357      * Own.
       
   358      */
       
   359     RArray<TUid> iIconUidArray;
       
   360 
       
   361     /**
       
   362      * The current index in the icon file array
       
   363      * Own.
       
   364      */
       
   365     TInt iIconFilePointer;
       
   366 
       
   367     /**
       
   368      * Stores the current icon file for streaming
       
   369      * This descriptor will be streamed at subsequent calls of
       
   370      * GetBackupDataSectionL()
       
   371      * Own.
       
   372      */
       
   373     HBufC8* iIconDesc;
       
   374 
       
   375     /**
       
   376      * Stores the current icon file being restored
       
   377      * Own.
       
   378      */
       
   379     HBufC8* iRestoreIconDesc;
       
   380 
       
   381     /**
       
   382      * Size of the icon to be still read during restore
       
   383      * Own.
       
   384      */
       
   385     TInt32 iIconFileSizeLeft;
       
   386 
       
   387     /**
       
   388      * Current index of iIconDesc
       
   389      * Own.
       
   390      */
       
   391     TInt iIconDescIndex;
       
   392 
       
   393     /**
       
   394      * Holds the remaining bytes in the buffer
       
   395      * Own
       
   396      */
       
   397 
       
   398     TInt iBufferSpaceLeft;
       
   399 
       
   400     /**
       
   401      * Buffer for storing data size in restore
       
   402      * Own.
       
   403      */
       
   404     TBuf8<4> iSizeBuffer;
       
   405 };
       
   406 
       
   407 
       
   408  
       
   409 } //namespace backup
       
   410 } //namespace java
       
   411 #endif /* MIDP2BACKUPPLUGINUSIF_H_ */