sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #if !defined(__BABACKUP_H__) sl@0: #define __BABACKUP_H__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: Backup server wrapper observer interface. sl@0: sl@0: MBackupObserver defines the interface to be implemented by any code that will sl@0: hold file locks or may attempt to access files regardless of other device state sl@0: e.g. a phone app may always attempt to access the contacts database for caller id sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class MBackupObserver sl@0: { sl@0: public: sl@0: /** Flags indicating how to change a file lock. */ sl@0: enum TFileLockFlags sl@0: { sl@0: /** Owner can reopen/resume writing to the file. */ sl@0: ETakeLock =0, sl@0: /** Owner should stop writing to the file. */ sl@0: EReleaseLockReadOnly =0x01, sl@0: /** Owner should close the file. */ sl@0: EReleaseLockNoAccess =0x02, sl@0: }; sl@0: public: sl@0: /** Called by the server to request the file owner to change the lock on the specified sl@0: file. sl@0: sl@0: @param aFileName Filename of affected file sl@0: @param aFlags Flag indicating how to change the file lock */ sl@0: virtual void ChangeFileLockL(const TDesC& aFileName,TFileLockFlags aFlags)=0; sl@0: }; sl@0: sl@0: class TBackupOperationAttributes; sl@0: sl@0: /** Backup operation observer interface. sl@0: sl@0: Programs should implement this interface to receive notifications when a backup sl@0: or restore operation either starts or ends. sl@0: sl@0: @see CBaBackupSessionWrapper::RegisterBackupOperationObserverL() sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class MBackupOperationObserver sl@0: { sl@0: public: sl@0: /** Backup operation event types. */ sl@0: enum TOperationType sl@0: { sl@0: /** None. */ sl@0: ENone =0x00, sl@0: /** Operation start. */ sl@0: EStart =0x01, sl@0: /** Operation end. */ sl@0: EEnd =0x02, sl@0: /** Operation aborted. */ sl@0: EAbort =0x04, sl@0: }; sl@0: public: sl@0: /** Called when a backup or restore operation either starts or ends. sl@0: sl@0: @param aBackupOperationAttributes Operation attributes */ sl@0: virtual void HandleBackupOperationEventL(const TBackupOperationAttributes& aBackupOperationAttributes)=0; sl@0: private: sl@0: IMPORT_C virtual void Reserved1(); sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Attributes for a backup operation. sl@0: sl@0: @see MBackupOperationObserver sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class TBackupOperationAttributes sl@0: { sl@0: public: sl@0: inline TBackupOperationAttributes(); sl@0: inline TBackupOperationAttributes(MBackupObserver::TFileLockFlags aFileFlag, MBackupOperationObserver::TOperationType aOperation); sl@0: public: sl@0: /** File locking flags requested by the operation. */ sl@0: MBackupObserver::TFileLockFlags iFileFlag; sl@0: /** Operation type. */ sl@0: MBackupOperationObserver::TOperationType iOperation; sl@0: }; sl@0: sl@0: sl@0: class RBaBackupSession; sl@0: class CBaLockChangeNotifier; sl@0: class CBaBackupOperationNotifier; sl@0: sl@0: /** sl@0: CBaBackupSessionWrapper provides the APIs necessary to enable a backup or restore/install sl@0: by allowing broadcast requests for some or all files to either remain untouched or have sl@0: their locks released for an arbitrary period. sl@0: sl@0: The class should be used by both code driving a backup/install and any engines that will sl@0: hold files locks or may access files regardless of the presence of (non-system) client apps sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CBaBackupSessionWrapper : public CBase sl@0: { sl@0: public: sl@0: IMPORT_C static CBaBackupSessionWrapper* NewL(); sl@0: IMPORT_C ~CBaBackupSessionWrapper(); sl@0: IMPORT_C void RegisterFileL(const TDesC& aFileName,MBackupObserver& aObserver); sl@0: IMPORT_C void DeregisterFile(const TDesC& aFileName); sl@0: IMPORT_C void CloseAll(MBackupObserver::TFileLockFlags aFlags,TRequestStatus& aStatus); sl@0: IMPORT_C void RestartAll(); sl@0: IMPORT_C void CloseFileL(const TDesC& aFileName,MBackupObserver::TFileLockFlags aFlags); sl@0: IMPORT_C void RestartFile(const TDesC& aFileName); sl@0: IMPORT_C void RegisterBackupOperationObserverL(MBackupOperationObserver& aBackupOperationObserver); sl@0: IMPORT_C void DeRegisterBackupOperationObserver(MBackupOperationObserver& aBackupOperationObserver); sl@0: IMPORT_C TBool IsBackupOperationRunning() const; sl@0: IMPORT_C void NotifyBackupOperationL(const TBackupOperationAttributes& aBackupOperationAttributes); sl@0: private: sl@0: CBaBackupSessionWrapper(); sl@0: void ConstructL(); sl@0: private: sl@0: RBaBackupSession* iBackupSession; sl@0: CBaLockChangeNotifier* iLockChangeNotifier; sl@0: TAny* iReserved; // needed to preserve BC sl@0: CBaBackupOperationNotifier* iBackupOperationNotifier; sl@0: }; sl@0: sl@0: sl@0: // sl@0: // TBackupOperationAttributes sl@0: // sl@0: sl@0: inline TBackupOperationAttributes::TBackupOperationAttributes() sl@0: : iFileFlag(MBackupObserver::ETakeLock), iOperation(MBackupOperationObserver::ENone) sl@0: /** Default constructor. */ sl@0: { sl@0: } sl@0: sl@0: inline TBackupOperationAttributes::TBackupOperationAttributes(MBackupObserver::TFileLockFlags aFileFlag, MBackupOperationObserver::TOperationType aOperation) sl@0: : iFileFlag(aFileFlag), iOperation(aOperation) sl@0: /** Constructor that specifies operation attributes. sl@0: sl@0: @param aFileFlag File locking flags requested by the operation sl@0: @param aOperation Operation type */ sl@0: { sl@0: } sl@0: sl@0: sl@0: sl@0: #endif sl@0: