1 /* |
|
2 * Copyright (c) 2008-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: Header file for CMidp2BackupPlugin class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef MIDP2BACKUPPLUGIN_H |
|
20 #define MIDP2BACKUPPLUGIN_H |
|
21 |
|
22 #include "backupplugin.h" |
|
23 #include <apadef.h> |
|
24 #include "logger.h" |
|
25 |
|
26 class RDesWriteStream; |
|
27 class RDesReadStream; |
|
28 |
|
29 |
|
30 |
|
31 namespace java |
|
32 { |
|
33 namespace backup |
|
34 { |
|
35 |
|
36 class CAppArcBackupUtil; |
|
37 class CJavaVersionBackupUtil; |
|
38 class CStorageBackupUtil; |
|
39 |
|
40 |
|
41 |
|
42 /** |
|
43 * CMidp2BackupPlugin class is handling backup and restore operations |
|
44 * for MIDlets |
|
45 * |
|
46 * This class is instantiated when a BUR operation is starting. |
|
47 */ |
|
48 class CMidp2BackupPlugin : public CBackupPlugin |
|
49 { |
|
50 |
|
51 public: |
|
52 |
|
53 /** |
|
54 * Instantiates an object of this type |
|
55 */ |
|
56 static CMidp2BackupPlugin* NewL(); |
|
57 |
|
58 ~CMidp2BackupPlugin(); |
|
59 |
|
60 |
|
61 // from base class CBackupPlugin |
|
62 |
|
63 /** |
|
64 * This method is called when a backup or restore operation is |
|
65 * starting. Preparations can be done to prepare for BUR. |
|
66 * |
|
67 * @param aBackupStateValue the value of the current backup state |
|
68 */ |
|
69 void PrepareForBURL(TInt aBackupStateValue); |
|
70 |
|
71 /** |
|
72 * This method receives all or part of a snapshot of data to allow |
|
73 * calculation of an incremental backup. The snapshot is one that |
|
74 * was previously supplied by the data owner. The snapshot data |
|
75 * should be read from the location supplied. The snapshot data may |
|
76 * be larger than the location supplied in which case the routine |
|
77 * will be called repeatedly until all data has been supplied. |
|
78 * |
|
79 * Snapshot data will also be supplied as part of a restore operation |
|
80 * |
|
81 * @param aDrive the drive being backed up |
|
82 * @param aBuffer a pointer to the base of the location from whence |
|
83 * data can be copied. |
|
84 * @param aLastSection ETrue if this is the last section of snapshot |
|
85 * data, else EFalse. |
|
86 */ |
|
87 void ReceiveSnapshotDataL(TDriveNumber aDrive, |
|
88 TDesC8& aBuffer, |
|
89 TBool aLastSection); |
|
90 |
|
91 /** |
|
92 * This method returns the expected size of backup data that will be |
|
93 * supplied. If an incremental backup is underway then this method |
|
94 * will not be called until after ReceiveSnapshotDataL(). |
|
95 * The size data will be used for the purpose of tracking progess |
|
96 * during a backup. If it is inaccurate then the user may see |
|
97 * irregular progress but the actual backup data will not be |
|
98 * affected so it is acceptable to return an estimated value. |
|
99 * |
|
100 * @param aDrive the drive being backed up. |
|
101 * @return the size of the data that will be returned |
|
102 */ |
|
103 TUint GetExpectedDataSize(TDriveNumber aDrive); |
|
104 |
|
105 /** |
|
106 * This method returns a snapshot of data to accompany a backup. The |
|
107 * snapshot is expected to contain details on files / data being |
|
108 * backed up. The format of the snapshot is only meaningful to the |
|
109 * data owner. The snapshot will be supplied if the data owner is |
|
110 * asked for an incremental backup and for a restore operation. The |
|
111 * snapshot data should be copied to the location supplied. |
|
112 * |
|
113 * The snapshot data may be larger than the location supplied in |
|
114 * which case the routine will be called repeatedly until all data |
|
115 * has been retrieved. |
|
116 * |
|
117 * @param aDrive the drive being backed up |
|
118 * @param aBuffer a pointer to the base of the location where data |
|
119 * can be copied. |
|
120 * @param aFinished on return ETrue if all data has been returned |
|
121 * for this drive, else EFalse. |
|
122 */ |
|
123 void GetSnapshotDataL(TDriveNumber aDrive, |
|
124 TPtr8& aBuffer, |
|
125 TBool& aFinished); |
|
126 |
|
127 /** |
|
128 * This method prepares the implementor to return backup data. It |
|
129 * will be followed by a sequence of calls to request the actual |
|
130 * data. |
|
131 * |
|
132 * @param aDrive the drive being backed up. |
|
133 */ |
|
134 void InitialiseGetBackupDataL(TDriveNumber aDrive); |
|
135 |
|
136 /** |
|
137 * This method requests a section of backup data. |
|
138 * InitialiseGetBackupDataL() will have been called previously to |
|
139 * specify the drive concerned. The data returned may be base or |
|
140 * incremental depending on the type of backup and the capability of |
|
141 * the data owner. |
|
142 * |
|
143 * @param aBuffer a pointer to the base of the location where data |
|
144 * can be copied. |
|
145 * @param aFinished on return ETrue if all data has been returned |
|
146 * for this drive, else EFalse. |
|
147 */ |
|
148 void GetBackupDataSectionL(TPtr8& aBuffer, |
|
149 TBool& aFinished); |
|
150 |
|
151 /** |
|
152 * This method prepares the implementor to receive base restore data |
|
153 * for a drive. It will be followed by a sequence of calls to supply |
|
154 * the actual data. |
|
155 * |
|
156 * @param aDrive the drive being restored. |
|
157 */ |
|
158 void InitialiseRestoreBaseDataL(TDriveNumber aDrive); |
|
159 |
|
160 /** |
|
161 * This method receives a section of base restore data. |
|
162 * InitialiseRestoreBaseDataL() will have been called previously to |
|
163 * specify the drive concerned. |
|
164 * |
|
165 * @param aBuffer a pointer to the base of the location whence data |
|
166 * can be read. |
|
167 * @param aFinished ETrue if all data has been returned for this |
|
168 * drive, else EFalse. |
|
169 */ |
|
170 void RestoreBaseDataSectionL(TDesC8& aBuffer, |
|
171 TBool aFinished); |
|
172 |
|
173 /** |
|
174 * This method prepares the implementor to receive incremental |
|
175 * restore data for a drive. It will be followed by a sequence |
|
176 * of calls to supply the actual data. If multiple increments |
|
177 * are supplied then this methid will be called before each increment |
|
178 * |
|
179 * @param aDrive the drive being restored. |
|
180 */ |
|
181 void InitialiseRestoreIncrementDataL(TDriveNumber aDrive); |
|
182 |
|
183 /** |
|
184 * This method receives a section of increment restore data. |
|
185 * InitialiseRestoreIncrementDataL() will have been called |
|
186 * previously to specify the drive concerned. |
|
187 * |
|
188 * @param aBuffer a pointer to the base of the location whence data |
|
189 * can be read. |
|
190 * @param aFinished ETrue if all data has been returned for this |
|
191 * increment, else EFalse. |
|
192 */ |
|
193 void RestoreIncrementDataSectionL(TDesC8& aBuffer, |
|
194 TBool aFinished); |
|
195 |
|
196 /** |
|
197 * This method is called when all data to be restored has been |
|
198 * supplied. |
|
199 * |
|
200 * @param aDrive the drive being restored. |
|
201 */ |
|
202 void RestoreComplete(TDriveNumber aDrive); |
|
203 |
|
204 private: |
|
205 |
|
206 CMidp2BackupPlugin(); |
|
207 |
|
208 void ConstructL(); |
|
209 |
|
210 /** |
|
211 * This method is called to get the unique Id of the current MMC |
|
212 * |
|
213 * @return The Id of the MMC, or 0, if no MMC is inserted |
|
214 */ |
|
215 TUint MmcIdL(); |
|
216 |
|
217 /** |
|
218 * This method is called to process the content of the buffer |
|
219 * provided in active phase of restore |
|
220 * |
|
221 * @param aBuffer the buffer to process |
|
222 */ |
|
223 void ProcessBufferL(RDesReadStream& stream); |
|
224 |
|
225 /** |
|
226 * This method is called to restore the Java Registry entries |
|
227 * on the MMC, if needed |
|
228 */ |
|
229 void RestoreMmcRegistryL(); |
|
230 |
|
231 /** |
|
232 * This method creates the path for the Java Registry entries on |
|
233 * the specified MMC |
|
234 * |
|
235 * @param [out] aPathName path of the entries of the MMC |
|
236 * @param aDrive drive of the MMC |
|
237 * @param aUniqueId Unique Id of the MMC |
|
238 */ |
|
239 void CreateMmcPath(TDes& aPathName, |
|
240 TInt aDrive, |
|
241 TUint aUniqueId); |
|
242 |
|
243 /** |
|
244 * This method gets the path for the next icon file to be backed up |
|
245 * |
|
246 * @param [out] aCurrentUid Uid of the next icon |
|
247 * @param [out] aFullFileName path of the next icon |
|
248 * @return EFalse if there are no more icons in the array, ETrue |
|
249 * otherwise |
|
250 */ |
|
251 TBool NextIcon(TUid& aCurrentUid, HBufC*& aFullFileName); |
|
252 |
|
253 /** |
|
254 * Process buffer when restore state is EFirstBuffer |
|
255 * |
|
256 * @param aStream readstream of buffer to process |
|
257 * @param aBufferSpaceLeft space left of buffer to be processed |
|
258 */ |
|
259 void ProcessFirstBufferL(RDesReadStream& aStream, TInt& aBufferSpaceLeft); |
|
260 |
|
261 /** |
|
262 * Process buffer when restore state is EInIcon |
|
263 * |
|
264 * @param aStream readstream of buffer to process |
|
265 * @param aBufferSpaceLeft space left of buffer to be processed |
|
266 */ |
|
267 void ProcessInIconL(RDesReadStream& aStream, TInt& aBufferSpaceLeft); |
|
268 |
|
269 /** |
|
270 * Process buffer when restore state is EInSize |
|
271 * |
|
272 * @param aStream readstream of buffer to process |
|
273 * @param aBufferSpaceLeft space left of buffer to be processed |
|
274 */ |
|
275 void ProcessInSizeL(RDesReadStream& aStream, TInt& aBufferSpaceLeft); |
|
276 |
|
277 /** |
|
278 * Resets the array of icons to be backed up |
|
279 */ |
|
280 void ResetIconArray(); |
|
281 |
|
282 private: // data |
|
283 |
|
284 /** |
|
285 * File session |
|
286 * Own. |
|
287 */ |
|
288 RFs iFs; |
|
289 |
|
290 /** |
|
291 * AppArcBackupUtil object for AppArc operations |
|
292 * Own. |
|
293 */ |
|
294 CAppArcBackupUtil* iAppArcUtil; |
|
295 |
|
296 /** |
|
297 * StorageBackupUtil object for storage B&R |
|
298 * Own. |
|
299 */ |
|
300 CStorageBackupUtil* iStorageBackupUtil; |
|
301 /** |
|
302 * The drive that is backed up or restored currently |
|
303 * Own. |
|
304 */ |
|
305 TDriveNumber iDrive; |
|
306 |
|
307 /** |
|
308 * Id of backed up drive, gets its value from restored data |
|
309 * Own. |
|
310 */ |
|
311 TInt32 iBackupDrive; |
|
312 |
|
313 /** |
|
314 * Id of backed up MMC, gets its value from restored data |
|
315 * Own. |
|
316 */ |
|
317 TUint32 iBackupMmc; |
|
318 |
|
319 /** |
|
320 * State of streaming during restore |
|
321 * Own. |
|
322 */ |
|
323 TInt iRestoreState; |
|
324 |
|
325 /** |
|
326 * Shows if it's the first call to GetBackupDataSectionL |
|
327 * Own. |
|
328 */ |
|
329 TBool iFirstCallToGetBackupDataSection; |
|
330 |
|
331 /** |
|
332 * Shows if Backup of storage data is finished or not |
|
333 * Own. |
|
334 */ |
|
335 TBool iStorageDataBackup; |
|
336 |
|
337 /** |
|
338 * Shows if Restore of storage data is finished or not |
|
339 * Own. |
|
340 */ |
|
341 TBool iStorageDataRestore; |
|
342 |
|
343 /** |
|
344 * Shows if Java version information is already written or not |
|
345 * Own |
|
346 */ |
|
347 TBool iJavaVersionInfoWritten; |
|
348 |
|
349 /** |
|
350 * Shows if its the first call to restore data or not. |
|
351 * Own. |
|
352 */ |
|
353 TBool iFirstCallToRestoreBackupDataSection; |
|
354 |
|
355 /** |
|
356 * Stores the uids of the midlets whose icons are to be backed up. |
|
357 * Own. |
|
358 */ |
|
359 RArray<TUid> iIconUidArray; |
|
360 |
|
361 /** |
|
362 * The current index in the icon file array |
|
363 * Own. |
|
364 */ |
|
365 TInt iIconFilePointer; |
|
366 |
|
367 /** |
|
368 * Stores the current icon file for streaming |
|
369 * This descriptor will be streamed at subsequent calls of |
|
370 * GetBackupDataSectionL() |
|
371 * Own. |
|
372 */ |
|
373 HBufC8* iIconDesc; |
|
374 |
|
375 /** |
|
376 * Stores the current icon file being restored |
|
377 * Own. |
|
378 */ |
|
379 HBufC8* iRestoreIconDesc; |
|
380 |
|
381 /** |
|
382 * Size of the icon to be still read during restore |
|
383 * Own. |
|
384 */ |
|
385 TInt32 iIconFileSizeLeft; |
|
386 |
|
387 /** |
|
388 * Current index of iIconDesc |
|
389 * Own. |
|
390 */ |
|
391 TInt iIconDescIndex; |
|
392 |
|
393 /** |
|
394 * Holds the remaining bytes in the buffer |
|
395 * Own |
|
396 */ |
|
397 |
|
398 TInt iBufferSpaceLeft; |
|
399 |
|
400 /** |
|
401 * Buffer for storing data size in restore |
|
402 * Own. |
|
403 */ |
|
404 TBuf8<4> iSizeBuffer; |
|
405 }; |
|
406 |
|
407 |
|
408 |
|
409 } //namespace backup |
|
410 } //namespace java |
|
411 |
|
412 #endif // MIDP2BACKUPPLUGIN_H |
|