|
1 /** |
|
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Declaration of MActiveBackupDataClient and CActiveBackupClient |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 @released |
|
25 */ |
|
26 #ifndef __ACTIVEBACKUPCLIENT_H__ |
|
27 #define __ACTIVEBACKUPCLIENT_H__ |
|
28 |
|
29 #include <e32base.h> |
|
30 #include <f32file.h> |
|
31 #include <e32cmn.h> |
|
32 #include <connect/sbdefs.h> |
|
33 |
|
34 namespace conn |
|
35 { |
|
36 |
|
37 class MActiveBackupDataClient |
|
38 /** |
|
39 MActiveBackupDataClient is a Mixin to be implemented by an Active Backup client. |
|
40 The client connects to the Secure Backup Server using the CActiveBackupClient |
|
41 class and provides an instance of MActiveBackupDataClient to be called for a |
|
42 range of functions. |
|
43 |
|
44 The bulk transfer of data and snapshots is expected to be by means of shared |
|
45 heaps for performance reasons so the API is expected to change in these areas. |
|
46 |
|
47 @released |
|
48 @publishedAll |
|
49 */ |
|
50 { |
|
51 public: |
|
52 |
|
53 /** |
|
54 Empty virtual destructor to avoid memory leaks |
|
55 */ |
|
56 virtual ~MActiveBackupDataClient() {} |
|
57 |
|
58 ///// Backup Methods ///// |
|
59 |
|
60 /** |
|
61 This method informs the active backup data client that all snapshots have |
|
62 been supplied. If the client has not received a snapshot then it should |
|
63 perform a base backup. |
|
64 */ |
|
65 virtual void AllSnapshotsSuppliedL() = 0; |
|
66 |
|
67 /** |
|
68 This method receives all or part of a snapshot of data to allow calculation of an |
|
69 incremental backup. The snapshot is one that was previously supplied by the data |
|
70 owner. The snapshot data should be read from the location supplied. |
|
71 The snapshot data may be larger than the location supplied in which case the routine will |
|
72 be called repeatedly until all data has been supplied. |
|
73 |
|
74 Snapshot data will also be supplied as part of a restore operation. |
|
75 |
|
76 @param aDrive the drive being backed up |
|
77 @param aBuffer a pointer to the base of the location from whence data can be copied. |
|
78 @param aLastSection ETrue if this is the last section of snapshot data, else EFalse. |
|
79 @leave KErrNotSupported if the data owner does not support incremental backups. |
|
80 */ |
|
81 virtual void ReceiveSnapshotDataL(TDriveNumber aDrive, TDesC8& aBuffer, TBool aLastSection) = 0; |
|
82 |
|
83 /** |
|
84 This method returns the expected size of backup data that will be supplied. If an |
|
85 incremental backup is underway then this method will not be called until after |
|
86 ReceiveSnapshotDataL(). The size data will be used for the purpose of tracking progess |
|
87 during a backup. If it is inaccurate then the user may see irregular progress but the |
|
88 actual backup data will not be affected so it is acceptable to return an estimated |
|
89 value. |
|
90 |
|
91 @param aDrive the drive being backed up. |
|
92 @return the size of the data that will be returned |
|
93 */ |
|
94 virtual TUint GetExpectedDataSize(TDriveNumber aDrive) = 0; |
|
95 |
|
96 /** |
|
97 This method returns a snapshot of data to accompany a backup. The snapshot is expected |
|
98 to contain details on files / data being backed up. The format of the snapshot is only |
|
99 meaningful to the data owner. The snapshot will be supplied if the data owner is asked |
|
100 for an incremental backup and for a restore operation. The snapshot data should be |
|
101 copied to the location supplied. |
|
102 The snapshot data may be larger than the location supplied in which case the routine will |
|
103 be called repeatedly until all data has been retrieved. |
|
104 |
|
105 @param aDrive the drive being backed up |
|
106 @param aBuffer a pointer to the base of the location where data can be copied. |
|
107 @param aFinished on return ETrue if all data has been returned for this drive, else EFalse. |
|
108 @leave KErrNotSupported if the data owner does not support incremental backups. |
|
109 */ |
|
110 virtual void GetSnapshotDataL(TDriveNumber aDrive, TPtr8& aBuffer, TBool& aFinished) = 0; |
|
111 |
|
112 /** |
|
113 This method prepares the implementor to return backup data. It will be followed by a |
|
114 sequence of calls to request the actual data. |
|
115 |
|
116 @param aDrive the drive being backed up. |
|
117 */ |
|
118 virtual void InitialiseGetBackupDataL(TDriveNumber aDrive) = 0; |
|
119 |
|
120 /** |
|
121 This method requests a section of backup data. InitialiseGetBackupDataL() will have been |
|
122 called prevously to specify the drive concerned. The data returned may be base or |
|
123 incremental depending on the type of backup and the capability of the data owner. |
|
124 |
|
125 @param aBuffer a pointer to the base of the location where data can be copied. |
|
126 @param aFinished on return ETrue if all data has been returned for this drive, else EFalse. |
|
127 */ |
|
128 virtual void GetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished) = 0; |
|
129 |
|
130 ///// Restore Methods ///// |
|
131 |
|
132 /** |
|
133 This method prepares the implementor to receive base restore data for a drive. |
|
134 It will be followed by a sequence of calls to supply the actual data. |
|
135 |
|
136 @param aDrive the drive being restored. |
|
137 */ |
|
138 virtual void InitialiseRestoreBaseDataL(TDriveNumber aDrive) = 0; |
|
139 |
|
140 /** |
|
141 This method receives a section of base restore data. |
|
142 InitialiseRestoreBaseDataL() will have been called prevously to specify the drive concerned. |
|
143 |
|
144 @param aBuffer a pointer to the base of the location whence data can be read. |
|
145 @param aFinished ETrue if all data has been returned for this drive, else EFalse. |
|
146 */ |
|
147 virtual void RestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished) = 0; |
|
148 |
|
149 /** |
|
150 This method prepares the implementor to receive incremental restore data for a drive. |
|
151 It will be followed by a sequence of calls to supply the actual data. If multiple |
|
152 increments are supplied then this methid will be called before each increment. |
|
153 |
|
154 @param aDrive the drive being restored. |
|
155 */ |
|
156 virtual void InitialiseRestoreIncrementDataL(TDriveNumber aDrive) = 0; |
|
157 |
|
158 /** |
|
159 This method receives a section of increment restore data. |
|
160 InitialiseRestoreIncrementDataL() will have been called prevously to specify the |
|
161 drive concerned. |
|
162 |
|
163 @param aBuffer a pointer to the base of the location whence data can be read. |
|
164 @param aFinished ETrue if all data has been returned for this increment, else EFalse. |
|
165 */ |
|
166 virtual void RestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished) = 0; |
|
167 |
|
168 /** |
|
169 This method is called when all data to be restored has been supplied. |
|
170 |
|
171 @param aDrive the drive being restored. |
|
172 */ |
|
173 virtual void RestoreComplete(TDriveNumber aDrive) = 0; |
|
174 |
|
175 /** |
|
176 This method prepares the implementor to return backup data on behalf of another data owner. |
|
177 It will be followed by a sequence of calls to request the actual data. This method is only |
|
178 for use by a proxy data manager that backs up data on behalf of other data owners. There |
|
179 is no corresponding method for snapshots as it is assumed that a proxy data manager will |
|
180 only handle base data. |
|
181 |
|
182 @param aSID the data owner whose data is to be backed up |
|
183 @param aDrive the drive being backed up. |
|
184 */ |
|
185 virtual void InitialiseGetProxyBackupDataL(TSecureId aSID, TDriveNumber aDrive); |
|
186 |
|
187 /** |
|
188 This method prepares the implementor to receive base restore data for another data owner |
|
189 for a drive. It will be followed by a sequence of calls to supply the actual data. |
|
190 This method is only for use by a proxy data manager that restores up data on behalf of |
|
191 other data owners. There is no corresponding method for incremental data as it is assumed |
|
192 that a proxy data manager will only handle base data. |
|
193 |
|
194 @param aSID the data owner whose data is to be restored |
|
195 @param aDrive the drive being restored. |
|
196 */ |
|
197 virtual void InitialiseRestoreProxyBaseDataL(TSecureId aSID, TDriveNumber aDrive); |
|
198 |
|
199 ///// General Methods ///// |
|
200 |
|
201 /** |
|
202 This method is called if copying of data is terminated prematurely to allow the |
|
203 implementor to tidy up. The same method applies to all types of data and to backup |
|
204 and restore |
|
205 */ |
|
206 virtual void TerminateMultiStageOperation() = 0; |
|
207 |
|
208 /** |
|
209 Gets an extended interface based on a supplied uid. |
|
210 |
|
211 @param aUid Uid which identifies an extended interface |
|
212 @return Pointer to an extended interface |
|
213 */ |
|
214 virtual TAny* GetExtendedInterface(const TInt32 aUid); |
|
215 |
|
216 ///// Test Methods ///// |
|
217 /** |
|
218 Gets a 32-bit checksum for its private data. |
|
219 This routine is for test purposes. It must be implemented but an invariant checksum |
|
220 value can be provided. Some tests may cause checksum values to be compared. |
|
221 |
|
222 @param aDrive the drive containing data being checksummed |
|
223 @return the 32-bit checksum |
|
224 */ |
|
225 virtual TUint GetDataChecksum(TDriveNumber aDrive) = 0; |
|
226 }; |
|
227 |
|
228 inline void MActiveBackupDataClient::InitialiseGetProxyBackupDataL(TSecureId /*aSID*/, TDriveNumber /*aDrive*/) |
|
229 /** Initialises the proxy backup data |
|
230 |
|
231 This is not supported here. |
|
232 |
|
233 @param aSID the secure Id |
|
234 @param aDrive the driver number |
|
235 @leave KErrNotSupported Always. |
|
236 */ |
|
237 { |
|
238 User::Leave(KErrNotSupported); |
|
239 } |
|
240 |
|
241 inline void MActiveBackupDataClient::InitialiseRestoreProxyBaseDataL(TSecureId /*aSID*/, TDriveNumber /*aDrive*/) |
|
242 { |
|
243 /** Initialises the proxy backup base data |
|
244 |
|
245 This is not supported here. |
|
246 |
|
247 @param aSID the secure Id |
|
248 @param aDrive the driver number |
|
249 @leave KErrNotSupported Always. |
|
250 */ |
|
251 User::Leave(KErrNotSupported); |
|
252 } |
|
253 |
|
254 inline TAny* MActiveBackupDataClient::GetExtendedInterface(const TInt32 /*aUid*/) |
|
255 { |
|
256 return NULL; |
|
257 } |
|
258 |
|
259 |
|
260 class RABClientSession; |
|
261 class CActiveBackupCallbackHandler; |
|
262 |
|
263 class CActiveBackupClient : public CBase |
|
264 /** |
|
265 CActiveBackupClient provides a connection to the Secure Backup Server for a data owning |
|
266 process. |
|
267 |
|
268 It can be used to obtain information about an active backup or restore operation. |
|
269 It can also be used to signal to the Secure Backup Server when the data owner is ready |
|
270 for backup or restore. |
|
271 |
|
272 It is also used by data owners that implement active backup or restore to provide a |
|
273 MActiveBackupDataClient implementation. |
|
274 |
|
275 This class owns a RActiveBackupSessionImpl instance and publishes the |
|
276 public API to the outside world. The reason for this facade class is twofold: |
|
277 |
|
278 @li Hiding the implementation details of RActiveBackupSessionImpl |
|
279 |
|
280 @li Future binary compatibility |
|
281 |
|
282 @released |
|
283 @publishedAll |
|
284 */ |
|
285 { |
|
286 public: |
|
287 IMPORT_C static CActiveBackupClient* NewL(); |
|
288 |
|
289 IMPORT_C static CActiveBackupClient* NewL(MActiveBackupDataClient* aClient); |
|
290 IMPORT_C ~CActiveBackupClient(); |
|
291 IMPORT_C void BURModeInfoL(TDriveList& aDriveList, TBURPartType& aBackupType, TBackupIncType& aIncBackupType); |
|
292 IMPORT_C TBool DoesPartialBURAffectMeL(); |
|
293 IMPORT_C void ConfirmReadyForBURL(TInt aErrorCode); |
|
294 |
|
295 private: |
|
296 CActiveBackupClient(); |
|
297 void ConstructL(); |
|
298 void ConstructL(MActiveBackupDataClient* aClient); |
|
299 |
|
300 private: |
|
301 /** Pointer to the client session R class that's wrapped up by this class */ |
|
302 RABClientSession* iClientSession; |
|
303 |
|
304 /** Pointer to the Active Backup Callback Handler */ |
|
305 CActiveBackupCallbackHandler* iABCallbackHandler; |
|
306 }; |
|
307 |
|
308 } // end namespace |
|
309 |
|
310 #endif // __ACTIVEBACKUPCLIENT_H__ |
|
311 |