|
1 /* |
|
2 * Copyright (c) 2005 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: Interface for the DRMBackup service |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef DRMBACKUP_H |
|
20 #define DRMBACKUP_H |
|
21 |
|
22 // INCLUDES |
|
23 |
|
24 #include <e32base.h> // CBase |
|
25 #include <abclient.h> |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // MACROS |
|
30 |
|
31 // DATA TYPES |
|
32 |
|
33 // FUNCTION PROTOTYPES |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class CDRMContextDB; |
|
37 class CDRMRightsDB; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * CDRMBackup implements the Active Backup required by |
|
43 * - DRM Rights Database |
|
44 * - ROAP |
|
45 * |
|
46 * |
|
47 * |
|
48 * @lib rightsserver.exe |
|
49 * @since 3.0 |
|
50 */ |
|
51 |
|
52 class CDRMBackup : public CBase, |
|
53 public conn::MActiveBackupDataClient |
|
54 { |
|
55 public: |
|
56 |
|
57 /** |
|
58 * NewLC |
|
59 * |
|
60 * Creates an instance of the CDRMBackup class and returns a pointer to it |
|
61 * The function leaves the object into the cleanup stack |
|
62 * |
|
63 * @since 3.0 |
|
64 * @param aRightsDatabase : CDRMRightsDB object for backing it up |
|
65 * @param aContextDatabase : CDRMContextDB object for backing it up |
|
66 * @param aFileServer : file server instance |
|
67 * @return Functional CDRMClock object, Function leaves if an error occurs. |
|
68 */ |
|
69 static CDRMBackup* NewLC( CDRMRightsDB* aRightsDatabase, |
|
70 RFs& aFileServer ); |
|
71 |
|
72 /** |
|
73 * NewL |
|
74 * |
|
75 * Creates an instance of the CDRMBackup class and returns a pointer to it |
|
76 * |
|
77 * @since 3.0 |
|
78 * @param aRightsDatabase : CDRMRightsDB object for backing it up |
|
79 * @param aContextDatabase : CDRMContextDB object for backing it up |
|
80 * @param aFileServer : file server instance |
|
81 * @return Functional CDRMClock object, Function leaves if an error occurs. |
|
82 */ |
|
83 static CDRMBackup* NewL( CDRMRightsDB* aDRMRightsDB, |
|
84 RFs& aFileServer ); |
|
85 |
|
86 /** |
|
87 * Destructor |
|
88 */ |
|
89 virtual ~CDRMBackup(); |
|
90 |
|
91 |
|
92 |
|
93 public: // Inherited from MActiveBackupDataClient |
|
94 |
|
95 |
|
96 |
|
97 /** |
|
98 This method informs the active backup data client that all snapshots have |
|
99 been supplied. If the client has not received a snapshot then it should |
|
100 perform a base backup. |
|
101 */ |
|
102 virtual void AllSnapshotsSuppliedL(); |
|
103 |
|
104 /** |
|
105 This method receives all or part of a snapshot of data to allow calculation of an |
|
106 incremental backup. The snapshot is one that was previously supplied by the data |
|
107 owner. The snapshot data should be read from the location supplied. |
|
108 The snapshot data may be larger than the location supplied in which case the routine will |
|
109 be called repeatedly until all data has been supplied. |
|
110 |
|
111 Snapshot data will also be supplied as part of a restore operation. |
|
112 |
|
113 @param aDrive the drive being backed up |
|
114 @param aBuffer a pointer to the base of the location from whence data can be copied. |
|
115 @param aLastSection ETrue if this is the last section of snapshot data, else EFalse. |
|
116 @leave KErrNotSupported if the data owner does not support incremental backups. |
|
117 */ |
|
118 virtual void ReceiveSnapshotDataL(TDriveNumber aDrive, TDesC8& aBuffer, TBool aLastSection); |
|
119 |
|
120 /** |
|
121 This method returns the expected size of backup data that will be supplied. If an |
|
122 incremental backup is underway then this method will not be called until after |
|
123 ReceiveSnapshotDataL(). The size data will be used for the purpose of tracking progess |
|
124 during a backup. If it is inaccurate then the user may see irregular progress but the |
|
125 actual backup data will not be affected so it is acceptable to return an estimated |
|
126 value. |
|
127 |
|
128 @param aDrive the drive being backed up. |
|
129 @return the size of the data that will be returned |
|
130 */ |
|
131 virtual TUint GetExpectedDataSize(TDriveNumber aDrive); |
|
132 |
|
133 /** |
|
134 This method returns a snapshot of data to accompany a backup. The snapshot is expected |
|
135 to contain details on files / data being backed up. The format of the snapshot is only |
|
136 meaningful to the data owner. The snapshot will be supplied if the data owner is asked |
|
137 for an incremental backup and for a restore operation. The snapshot data should be |
|
138 copied to the location supplied. |
|
139 The snapshot data may be larger than the location supplied in which case the routine will |
|
140 be called repeatedly until all data has been retrieved. |
|
141 |
|
142 @param aDrive the drive being backed up |
|
143 @param aBuffer a pointer to the base of the location where data can be copied. |
|
144 @param aFinished on return ETrue if all data has been returned for this drive, else EFalse. |
|
145 @leave KErrNotSupported if the data owner does not support incremental backups. |
|
146 */ |
|
147 virtual void GetSnapshotDataL(TDriveNumber aDrive, TPtr8& aBuffer, TBool& aFinished); |
|
148 |
|
149 /** |
|
150 This method prepares the implementor to return backup data. It will be followed by a |
|
151 sequence of calls to request the actual data. |
|
152 |
|
153 @param aDrive the drive being backed up. |
|
154 */ |
|
155 virtual void InitialiseGetBackupDataL(TDriveNumber aDrive); |
|
156 |
|
157 /** |
|
158 This method requests a section of backup data. InitialiseGetBackupDataL() will have been |
|
159 called prevously to specify the drive concerned. The data returned may be base or |
|
160 incremental depending on the type of backup and the capability of the data owner. |
|
161 |
|
162 @param aBuffer a pointer to the base of the location where data can be copied. |
|
163 @param aFinished on return ETrue if all data has been returned for this drive, else EFalse. |
|
164 */ |
|
165 virtual void GetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished); |
|
166 |
|
167 ///// Restore Methods ///// |
|
168 |
|
169 /** |
|
170 This method prepares the implementor to receive base restore data for a drive. |
|
171 It will be followed by a sequence of calls to supply the actual data. |
|
172 |
|
173 @param aDrive the drive being restored. |
|
174 */ |
|
175 virtual void InitialiseRestoreBaseDataL(TDriveNumber aDrive); |
|
176 |
|
177 /** |
|
178 This method receives a section of base restore data. |
|
179 InitialiseRestoreBaseDataL() will have been called prevously to specify the drive concerned. |
|
180 |
|
181 @param aBuffer a pointer to the base of the location whence data can be read. |
|
182 @param aFinished ETrue if all data has been returned for this drive, else EFalse. |
|
183 */ |
|
184 virtual void RestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished); |
|
185 |
|
186 /** |
|
187 This method prepares the implementor to receive incremental restore data for a drive. |
|
188 It will be followed by a sequence of calls to supply the actual data. If multiple |
|
189 increments are supplied then this methid will be called before each increment. |
|
190 |
|
191 @param aDrive the drive being restored. |
|
192 */ |
|
193 virtual void InitialiseRestoreIncrementDataL(TDriveNumber aDrive); |
|
194 |
|
195 /** |
|
196 This method receives a section of increment restore data. |
|
197 InitialiseRestoreIncrementDataL() will have been called prevously to specify the |
|
198 drive concerned. |
|
199 |
|
200 @param aBuffer a pointer to the base of the location whence data can be read. |
|
201 @param aFinished ETrue if all data has been returned for this increment, else EFalse. |
|
202 */ |
|
203 virtual void RestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished); |
|
204 |
|
205 /** |
|
206 This method is called when all data to be restored has been supplied. |
|
207 |
|
208 @param aDrive the drive being restored. |
|
209 */ |
|
210 virtual void RestoreComplete(TDriveNumber aDrive); |
|
211 |
|
212 ///// General Methods ///// |
|
213 |
|
214 /** |
|
215 This method is called if copying of data is terminated prematurely to allow the |
|
216 implementor to tidy up. The same method applies to all types of data and to backup |
|
217 and restore |
|
218 */ |
|
219 virtual void TerminateMultiStageOperation(); |
|
220 |
|
221 ///// Test Methods ///// |
|
222 /** |
|
223 Gets a 32-bit checksum for its private data. |
|
224 This routine is for test purposes. It must be implemented but an invariant checksum |
|
225 value can be provided. Some tests may cause checksum values to be compared. |
|
226 |
|
227 @param aDrive the drive containing data being checksummed |
|
228 @return the 32-bit checksum |
|
229 */ |
|
230 virtual TUint GetDataChecksum(TDriveNumber aDrive); |
|
231 |
|
232 /** |
|
233 * PerformCleanup |
|
234 * |
|
235 * Delete the backup files and free other relevant resources |
|
236 * |
|
237 * @since 3.0 |
|
238 * @return none |
|
239 */ |
|
240 void PerformCleanup( TBool aUdt = EFalse ); |
|
241 |
|
242 |
|
243 private: |
|
244 /** |
|
245 * Default Constructor - First phase |
|
246 */ |
|
247 CDRMBackup( CDRMRightsDB* aRightsDatabase, |
|
248 RFs& aFileServer ); |
|
249 |
|
250 /** |
|
251 * ConstructL |
|
252 * |
|
253 * Second phase constructor |
|
254 * |
|
255 * @since 3.0 |
|
256 * @return Leaves if an error occurs |
|
257 */ |
|
258 void ConstructL(); |
|
259 |
|
260 /** |
|
261 * CreateRightsBackupFile |
|
262 * |
|
263 * Create the encrypted rights db backup file |
|
264 * |
|
265 * @since 3.0 |
|
266 * @return return a Symbian OS error code if an error occurs |
|
267 */ |
|
268 void CreateRightsBackupFileL(); |
|
269 |
|
270 /** |
|
271 * CreateContextBackupFile |
|
272 * |
|
273 * Create the encrypted context db backup file |
|
274 * |
|
275 * @since 3.0 |
|
276 * @return returns a Symbian OS error code if an error occurs |
|
277 */ |
|
278 void CreateContextBackupFileL(); |
|
279 |
|
280 /** |
|
281 * PerformRightsMerge |
|
282 * |
|
283 * Merge in the encrypted rights db backup file |
|
284 * |
|
285 * @since 3.0 |
|
286 * @return return a Symbian OS error code if an error occurs |
|
287 */ |
|
288 void PerformRightsMergeL(); |
|
289 |
|
290 /** |
|
291 * PerformContextMerge(); |
|
292 * |
|
293 * Merge in the encrypted context db backup file |
|
294 * |
|
295 * @since 3.0 |
|
296 * @return returns a Symbian OS error code if an error occurs |
|
297 */ |
|
298 void PerformContextMergeL(); |
|
299 |
|
300 private: // Variables |
|
301 |
|
302 // File server session |
|
303 RFs& iFileServer; |
|
304 |
|
305 // Rights database instance |
|
306 CDRMRightsDB* iDRMRightsDB; |
|
307 |
|
308 // file handle of the file used for rights db backup |
|
309 RFile iRightsBackupFile; |
|
310 |
|
311 // name of the file used for rights db backup |
|
312 TFileName iRightsFileName; |
|
313 |
|
314 // size of the file |
|
315 TInt iRightsFileSize; |
|
316 |
|
317 // file handle of the file used for context db backup |
|
318 RFile iContextBackupFile; |
|
319 |
|
320 // name of the file used for context db backup |
|
321 TFileName iContextFileName; |
|
322 |
|
323 // size of the file |
|
324 TInt iContextFileSize; |
|
325 |
|
326 // the position in the file |
|
327 TInt iPosition; |
|
328 |
|
329 // buffer to read the size of data |
|
330 TBuf8<4> iSizeBuffer; |
|
331 |
|
332 // how much data has been read to the iSizeBuffer |
|
333 TInt8 iReadData; |
|
334 |
|
335 // internal status of the object |
|
336 TInt iStatus; |
|
337 |
|
338 }; |
|
339 #endif // DRMBACKUP_H |
|
340 |
|
341 // End of File |