epoc32/include/babackup.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 babackup.h
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #if !defined(__BABACKUP_H__) 
       
    17 #define __BABACKUP_H__
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <e32base.h>
       
    21 
       
    22 /** 
       
    23 Backup server wrapper observer interface.
       
    24 
       
    25 MBackupObserver defines the interface to be implemented by any code that will
       
    26 hold file locks or may attempt to access files regardless of other device state
       
    27 e.g. a phone app may always attempt to access the contacts database for caller id
       
    28 
       
    29 @publishedAll
       
    30 @released
       
    31 */
       
    32 class MBackupObserver
       
    33 	{
       
    34 public:
       
    35 /** Flags indicating how to change a file lock. */
       
    36 	enum TFileLockFlags
       
    37 		{
       
    38 	/** Owner can reopen/resume writing to the file. */
       
    39 		ETakeLock				=0,
       
    40 	/** Owner should stop writing to the file. */
       
    41 		EReleaseLockReadOnly	=0x01,
       
    42 	/** Owner should close the file. */
       
    43 		EReleaseLockNoAccess	=0x02,
       
    44 		};
       
    45 public:
       
    46 	/** Called by the server to request the file owner to change the lock on the specified 
       
    47 	file.
       
    48 	
       
    49 	@param aFileName Filename of affected file
       
    50 	@param aFlags Flag indicating how to change the file lock */
       
    51 	virtual void ChangeFileLockL(const TDesC& aFileName,TFileLockFlags aFlags)=0;
       
    52 	};
       
    53 
       
    54 class TBackupOperationAttributes;
       
    55 
       
    56 /** Backup operation observer interface.
       
    57 
       
    58 Programs should implement this interface to receive notifications when a backup 
       
    59 or restore operation either starts or ends.
       
    60 
       
    61 @see CBaBackupSessionWrapper::RegisterBackupOperationObserverL() 
       
    62 @publishedAll
       
    63 @released
       
    64 */
       
    65 class MBackupOperationObserver
       
    66 	{
       
    67 public:
       
    68 /** Backup operation event types. */
       
    69 	enum TOperationType
       
    70 		{
       
    71 	/** None. */
       
    72 		ENone		=0x00,
       
    73 	/** Operation start. */
       
    74 		EStart		=0x01,
       
    75 	/** Operation end. */
       
    76 		EEnd		=0x02,
       
    77 	/** Operation aborted. */
       
    78 		EAbort		=0x04,
       
    79 		};
       
    80 public:
       
    81 	/** Called when a backup or restore operation either starts or ends.
       
    82 	
       
    83 	@param aBackupOperationAttributes Operation attributes */
       
    84 	virtual void HandleBackupOperationEventL(const TBackupOperationAttributes& aBackupOperationAttributes)=0;
       
    85 private:
       
    86 	IMPORT_C virtual void Reserved1();
       
    87 	};
       
    88 
       
    89 
       
    90 /** 
       
    91 Attributes for a backup operation.
       
    92 
       
    93 @see MBackupOperationObserver 
       
    94 @publishedAll
       
    95 @released
       
    96 */
       
    97 class TBackupOperationAttributes
       
    98 	{
       
    99 public:
       
   100 	inline TBackupOperationAttributes();
       
   101 	inline TBackupOperationAttributes(MBackupObserver::TFileLockFlags aFileFlag, MBackupOperationObserver::TOperationType aOperation);
       
   102 public:
       
   103 	/** File locking flags requested by the operation. */
       
   104 	MBackupObserver::TFileLockFlags iFileFlag;
       
   105 	/** Operation type. */
       
   106 	MBackupOperationObserver::TOperationType iOperation;
       
   107 	};
       
   108 
       
   109 
       
   110 class RBaBackupSession;
       
   111 class CBaLockChangeNotifier;
       
   112 class CBaBackupOperationNotifier;
       
   113 
       
   114 /**
       
   115 CBaBackupSessionWrapper provides the APIs necessary to enable a backup or restore/install
       
   116 by allowing broadcast requests for some or all files to either remain untouched or have
       
   117 their locks released for an arbitrary period.
       
   118 
       
   119 The class should be used by both code driving a backup/install and any engines that will
       
   120 hold files locks or may access files regardless of the presence of (non-system) client apps
       
   121 
       
   122 @publishedAll
       
   123 @released
       
   124 */
       
   125 class CBaBackupSessionWrapper : public CBase
       
   126 	{
       
   127 public:
       
   128 	IMPORT_C static CBaBackupSessionWrapper* NewL();
       
   129 	IMPORT_C ~CBaBackupSessionWrapper();
       
   130 	IMPORT_C void RegisterFileL(const TDesC& aFileName,MBackupObserver& aObserver);
       
   131 	IMPORT_C void DeregisterFile(const TDesC& aFileName);
       
   132 	IMPORT_C void CloseAll(MBackupObserver::TFileLockFlags aFlags,TRequestStatus& aStatus);
       
   133 	IMPORT_C void RestartAll();
       
   134 	IMPORT_C void CloseFileL(const TDesC& aFileName,MBackupObserver::TFileLockFlags aFlags);
       
   135 	IMPORT_C void RestartFile(const TDesC& aFileName);
       
   136 	IMPORT_C void RegisterBackupOperationObserverL(MBackupOperationObserver& aBackupOperationObserver);
       
   137 	IMPORT_C void DeRegisterBackupOperationObserver(MBackupOperationObserver& aBackupOperationObserver);
       
   138 	IMPORT_C TBool IsBackupOperationRunning() const;
       
   139 	IMPORT_C void NotifyBackupOperationL(const TBackupOperationAttributes& aBackupOperationAttributes);
       
   140 private:
       
   141 	CBaBackupSessionWrapper();
       
   142 	void ConstructL();
       
   143 private:
       
   144 	RBaBackupSession* iBackupSession;
       
   145 	CBaLockChangeNotifier* iLockChangeNotifier;
       
   146 	TAny* iReserved;  // needed to preserve BC
       
   147 	CBaBackupOperationNotifier* iBackupOperationNotifier;
       
   148 	};
       
   149 
       
   150 
       
   151 //
       
   152 // TBackupOperationAttributes
       
   153 //
       
   154 
       
   155 inline TBackupOperationAttributes::TBackupOperationAttributes()
       
   156 	: iFileFlag(MBackupObserver::ETakeLock), iOperation(MBackupOperationObserver::ENone)
       
   157 	/** Default constructor. */
       
   158 	{
       
   159 	}
       
   160 
       
   161 inline TBackupOperationAttributes::TBackupOperationAttributes(MBackupObserver::TFileLockFlags aFileFlag, MBackupOperationObserver::TOperationType aOperation)
       
   162 	: iFileFlag(aFileFlag), iOperation(aOperation)
       
   163 	/** Constructor that specifies operation attributes.
       
   164 	
       
   165 	@param aFileFlag File locking flags requested by the operation
       
   166 	@param aOperation Operation type */
       
   167 	{
       
   168 	}
       
   169 
       
   170 
       
   171 
       
   172 #endif