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