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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #if !defined(__BABACKUP_H__)
17 #define __BABACKUP_H__
23 Backup server wrapper observer interface.
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
35 /** Flags indicating how to change a file lock. */
38 /** Owner can reopen/resume writing to the file. */
40 /** Owner should stop writing to the file. */
41 EReleaseLockReadOnly =0x01,
42 /** Owner should close the file. */
43 EReleaseLockNoAccess =0x02,
46 /** Called by the server to request the file owner to change the lock on the specified
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;
54 class TBackupOperationAttributes;
56 /** Backup operation observer interface.
58 Programs should implement this interface to receive notifications when a backup
59 or restore operation either starts or ends.
61 @see CBaBackupSessionWrapper::RegisterBackupOperationObserverL()
65 class MBackupOperationObserver
68 /** Backup operation event types. */
73 /** Operation start. */
77 /** Operation aborted. */
81 /** Called when a backup or restore operation either starts or ends.
83 @param aBackupOperationAttributes Operation attributes */
84 virtual void HandleBackupOperationEventL(const TBackupOperationAttributes& aBackupOperationAttributes)=0;
86 IMPORT_C virtual void Reserved1();
91 Attributes for a backup operation.
93 @see MBackupOperationObserver
97 class TBackupOperationAttributes
100 inline TBackupOperationAttributes();
101 inline TBackupOperationAttributes(MBackupObserver::TFileLockFlags aFileFlag, MBackupOperationObserver::TOperationType aOperation);
103 /** File locking flags requested by the operation. */
104 MBackupObserver::TFileLockFlags iFileFlag;
105 /** Operation type. */
106 MBackupOperationObserver::TOperationType iOperation;
110 class RBaBackupSession;
111 class CBaLockChangeNotifier;
112 class CBaBackupOperationNotifier;
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.
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
125 class CBaBackupSessionWrapper : public CBase
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);
141 CBaBackupSessionWrapper();
144 RBaBackupSession* iBackupSession;
145 CBaLockChangeNotifier* iLockChangeNotifier;
146 TAny* iReserved; // needed to preserve BC
147 CBaBackupOperationNotifier* iBackupOperationNotifier;
152 // TBackupOperationAttributes
155 inline TBackupOperationAttributes::TBackupOperationAttributes()
156 : iFileFlag(MBackupObserver::ETakeLock), iOperation(MBackupOperationObserver::ENone)
157 /** Default constructor. */
161 inline TBackupOperationAttributes::TBackupOperationAttributes(MBackupObserver::TFileLockFlags aFileFlag, MBackupOperationObserver::TOperationType aOperation)
162 : iFileFlag(aFileFlag), iOperation(aOperation)
163 /** Constructor that specifies operation attributes.
165 @param aFileFlag File locking flags requested by the operation
166 @param aOperation Operation type */