epoc32/include/babackup.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/babackup.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/babackup.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,172 @@
     1.4 -babackup.h
     1.5 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// 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
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +//
    1.19 +
    1.20 +#if !defined(__BABACKUP_H__) 
    1.21 +#define __BABACKUP_H__
    1.22 +
    1.23 +#include <e32std.h>
    1.24 +#include <e32base.h>
    1.25 +
    1.26 +/** 
    1.27 +Backup server wrapper observer interface.
    1.28 +
    1.29 +MBackupObserver defines the interface to be implemented by any code that will
    1.30 +hold file locks or may attempt to access files regardless of other device state
    1.31 +e.g. a phone app may always attempt to access the contacts database for caller id
    1.32 +
    1.33 +@publishedAll
    1.34 +@released
    1.35 +*/
    1.36 +class MBackupObserver
    1.37 +	{
    1.38 +public:
    1.39 +/** Flags indicating how to change a file lock. */
    1.40 +	enum TFileLockFlags
    1.41 +		{
    1.42 +	/** Owner can reopen/resume writing to the file. */
    1.43 +		ETakeLock				=0,
    1.44 +	/** Owner should stop writing to the file. */
    1.45 +		EReleaseLockReadOnly	=0x01,
    1.46 +	/** Owner should close the file. */
    1.47 +		EReleaseLockNoAccess	=0x02,
    1.48 +		};
    1.49 +public:
    1.50 +	/** Called by the server to request the file owner to change the lock on the specified 
    1.51 +	file.
    1.52 +	
    1.53 +	@param aFileName Filename of affected file
    1.54 +	@param aFlags Flag indicating how to change the file lock */
    1.55 +	virtual void ChangeFileLockL(const TDesC& aFileName,TFileLockFlags aFlags)=0;
    1.56 +	};
    1.57 +
    1.58 +class TBackupOperationAttributes;
    1.59 +
    1.60 +/** Backup operation observer interface.
    1.61 +
    1.62 +Programs should implement this interface to receive notifications when a backup 
    1.63 +or restore operation either starts or ends.
    1.64 +
    1.65 +@see CBaBackupSessionWrapper::RegisterBackupOperationObserverL() 
    1.66 +@publishedAll
    1.67 +@released
    1.68 +*/
    1.69 +class MBackupOperationObserver
    1.70 +	{
    1.71 +public:
    1.72 +/** Backup operation event types. */
    1.73 +	enum TOperationType
    1.74 +		{
    1.75 +	/** None. */
    1.76 +		ENone		=0x00,
    1.77 +	/** Operation start. */
    1.78 +		EStart		=0x01,
    1.79 +	/** Operation end. */
    1.80 +		EEnd		=0x02,
    1.81 +	/** Operation aborted. */
    1.82 +		EAbort		=0x04,
    1.83 +		};
    1.84 +public:
    1.85 +	/** Called when a backup or restore operation either starts or ends.
    1.86 +	
    1.87 +	@param aBackupOperationAttributes Operation attributes */
    1.88 +	virtual void HandleBackupOperationEventL(const TBackupOperationAttributes& aBackupOperationAttributes)=0;
    1.89 +private:
    1.90 +	IMPORT_C virtual void Reserved1();
    1.91 +	};
    1.92 +
    1.93 +
    1.94 +/** 
    1.95 +Attributes for a backup operation.
    1.96 +
    1.97 +@see MBackupOperationObserver 
    1.98 +@publishedAll
    1.99 +@released
   1.100 +*/
   1.101 +class TBackupOperationAttributes
   1.102 +	{
   1.103 +public:
   1.104 +	inline TBackupOperationAttributes();
   1.105 +	inline TBackupOperationAttributes(MBackupObserver::TFileLockFlags aFileFlag, MBackupOperationObserver::TOperationType aOperation);
   1.106 +public:
   1.107 +	/** File locking flags requested by the operation. */
   1.108 +	MBackupObserver::TFileLockFlags iFileFlag;
   1.109 +	/** Operation type. */
   1.110 +	MBackupOperationObserver::TOperationType iOperation;
   1.111 +	};
   1.112 +
   1.113 +
   1.114 +class RBaBackupSession;
   1.115 +class CBaLockChangeNotifier;
   1.116 +class CBaBackupOperationNotifier;
   1.117 +
   1.118 +/**
   1.119 +CBaBackupSessionWrapper provides the APIs necessary to enable a backup or restore/install
   1.120 +by allowing broadcast requests for some or all files to either remain untouched or have
   1.121 +their locks released for an arbitrary period.
   1.122 +
   1.123 +The class should be used by both code driving a backup/install and any engines that will
   1.124 +hold files locks or may access files regardless of the presence of (non-system) client apps
   1.125 +
   1.126 +@publishedAll
   1.127 +@released
   1.128 +*/
   1.129 +class CBaBackupSessionWrapper : public CBase
   1.130 +	{
   1.131 +public:
   1.132 +	IMPORT_C static CBaBackupSessionWrapper* NewL();
   1.133 +	IMPORT_C ~CBaBackupSessionWrapper();
   1.134 +	IMPORT_C void RegisterFileL(const TDesC& aFileName,MBackupObserver& aObserver);
   1.135 +	IMPORT_C void DeregisterFile(const TDesC& aFileName);
   1.136 +	IMPORT_C void CloseAll(MBackupObserver::TFileLockFlags aFlags,TRequestStatus& aStatus);
   1.137 +	IMPORT_C void RestartAll();
   1.138 +	IMPORT_C void CloseFileL(const TDesC& aFileName,MBackupObserver::TFileLockFlags aFlags);
   1.139 +	IMPORT_C void RestartFile(const TDesC& aFileName);
   1.140 +	IMPORT_C void RegisterBackupOperationObserverL(MBackupOperationObserver& aBackupOperationObserver);
   1.141 +	IMPORT_C void DeRegisterBackupOperationObserver(MBackupOperationObserver& aBackupOperationObserver);
   1.142 +	IMPORT_C TBool IsBackupOperationRunning() const;
   1.143 +	IMPORT_C void NotifyBackupOperationL(const TBackupOperationAttributes& aBackupOperationAttributes);
   1.144 +private:
   1.145 +	CBaBackupSessionWrapper();
   1.146 +	void ConstructL();
   1.147 +private:
   1.148 +	RBaBackupSession* iBackupSession;
   1.149 +	CBaLockChangeNotifier* iLockChangeNotifier;
   1.150 +	TAny* iReserved;  // needed to preserve BC
   1.151 +	CBaBackupOperationNotifier* iBackupOperationNotifier;
   1.152 +	};
   1.153 +
   1.154 +
   1.155 +//
   1.156 +// TBackupOperationAttributes
   1.157 +//
   1.158 +
   1.159 +inline TBackupOperationAttributes::TBackupOperationAttributes()
   1.160 +	: iFileFlag(MBackupObserver::ETakeLock), iOperation(MBackupOperationObserver::ENone)
   1.161 +	/** Default constructor. */
   1.162 +	{
   1.163 +	}
   1.164 +
   1.165 +inline TBackupOperationAttributes::TBackupOperationAttributes(MBackupObserver::TFileLockFlags aFileFlag, MBackupOperationObserver::TOperationType aOperation)
   1.166 +	: iFileFlag(aFileFlag), iOperation(aOperation)
   1.167 +	/** Constructor that specifies operation attributes.
   1.168 +	
   1.169 +	@param aFileFlag File locking flags requested by the operation
   1.170 +	@param aOperation Operation type */
   1.171 +	{
   1.172 +	}
   1.173 +
   1.174 +
   1.175 +
   1.176 +#endif