|
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 Types and Constants for Secure Backup and Restore |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 */ |
|
25 #ifndef __SBTYPES_H__ |
|
26 #define __SBTYPES_H__ |
|
27 |
|
28 #include <connect/sbdefs.h> |
|
29 #include <e32cmn.h> |
|
30 #include <f32file.h> |
|
31 #include <connect/sbexternalisablearray.h> |
|
32 |
|
33 class RApaLsSession; |
|
34 |
|
35 namespace conn |
|
36 { |
|
37 /** Maximum length of package name |
|
38 @released |
|
39 @publishedPartner |
|
40 */ |
|
41 const TInt KMaxPackageNameLength = 128; // Arbitrary name length |
|
42 |
|
43 /** Length of the 128 bit Java hash in bytes |
|
44 @released |
|
45 @publishedPartner |
|
46 */ |
|
47 const TInt KJavaIdLength = 16; |
|
48 |
|
49 /** Used for unpacking unicode descriptors |
|
50 @released |
|
51 @publishedPartner |
|
52 */ |
|
53 #ifdef UNICODE |
|
54 const TInt KCharWidthInBytes = 2; |
|
55 #else |
|
56 const TInt KCharWidthInBytes = 1; |
|
57 #endif // UNICODE |
|
58 |
|
59 /** |
|
60 @released |
|
61 @publishedPartner |
|
62 */ |
|
63 typedef TBufC<KMaxPackageNameLength> TPackageName; |
|
64 |
|
65 enum TCommonBUROptions |
|
66 /** |
|
67 The passive backup options |
|
68 |
|
69 @released |
|
70 @publishedPartner |
|
71 */ |
|
72 { |
|
73 ENoOptions = 0x00000000, /*!< 0x00000000: no common options selected */ |
|
74 EActiveBUR = 0x00000001, /*!< 0x00000001: Does the data owner do active backup / restore? */ |
|
75 EPassiveBUR = 0x00000002, /*!< 0x00000002: Does the data owner do passive backup / restore? */ |
|
76 EHasSystemFiles = 0x00000004, /*!< 0x00000004: Does the data owner want system files backed up? */ |
|
77 ESupportsSelective = 0x00000008, /*!< 0x00000008: Can the data owner do BUR selectively? */ |
|
78 ERequiresReboot = 0x00000010 /*!< 0x00000010: Does the data owner require reboot after restore? */ |
|
79 }; |
|
80 |
|
81 enum TPassiveBUROptions |
|
82 /** |
|
83 The passive backup options |
|
84 |
|
85 @released |
|
86 @publishedPartner |
|
87 */ |
|
88 { |
|
89 ENoPassiveOptions = 0x00000000, /*!< 0x00000000: no passive options selected */ |
|
90 EHasPublicFiles = 0x00000001, /*!< 0x00000001: data owner has public files to BUR ? */ |
|
91 EDeleteBeforeRestore = 0x00000002, /*!< 0x00000002: data owner requires a delete before restore ? */ |
|
92 EPassiveSupportsInc = 0x00000004 /*!< 0x00000004: data owner supports incremental BUR ? */ |
|
93 }; |
|
94 |
|
95 enum TActiveBUROptions |
|
96 /** |
|
97 The active backup options |
|
98 |
|
99 @released |
|
100 @publishedPartner |
|
101 */ |
|
102 { |
|
103 ENoActiveOptions = 0x00000000, /*!< 0x00000000: no active backup options selected */ |
|
104 EDelayToPrepareData = 0x00000001, /*!< 0x00000001: data owner slow to prepare active data */ |
|
105 EActiveSupportsInc = 0x00000002 /*!< 0x00000002: data owner supports incremental BUR ? */ |
|
106 }; |
|
107 |
|
108 /** Common BUR Settings |
|
109 This structure will store the common backup and restore options for a SID |
|
110 @released |
|
111 @publishedPartner |
|
112 */ |
|
113 typedef TUint32 TCommonBURSettings; |
|
114 |
|
115 /** Passive BUR Settings |
|
116 This structure will store the passive backup and restore options for a SID |
|
117 @released |
|
118 @publishedPartner |
|
119 */ |
|
120 typedef TUint32 TPassiveBURSettings; |
|
121 |
|
122 /** Active BUR Settings |
|
123 This structure will store the active backup and restore options for a SID |
|
124 @released |
|
125 @publishedPartner |
|
126 */ |
|
127 typedef TUint32 TActiveBURSettings; |
|
128 |
|
129 class TRestoreFileFilter |
|
130 /** |
|
131 TRestoreFileFilter packages up a file or directory name and an include or exclude flag. |
|
132 |
|
133 This type is used when telling a client during a restore operation which public files are |
|
134 to be restored for a specific data owner. |
|
135 |
|
136 @released |
|
137 @publishedPartner |
|
138 */ |
|
139 { |
|
140 public: |
|
141 /** |
|
142 Constructor |
|
143 |
|
144 @param aInclude ETrue if the file or directory is to be |
|
145 included, EFalse for exclusion |
|
146 @param aName The name of the file or directory (directory |
|
147 names end with a slash) |
|
148 */ |
|
149 TRestoreFileFilter(TBool aInclude, const TFileName& aName) |
|
150 : iInclude(aInclude), iName(aName) {} |
|
151 public: |
|
152 TBool iInclude ; /*!< ETrue if the file or directory is to be included, EFalse for exclusion */ |
|
153 TFileName iName; /*!< The name of the file or directory (directory names end with a slash) */ |
|
154 }; |
|
155 |
|
156 /** Array of TEntry objects |
|
157 @released |
|
158 @publishedPartner |
|
159 */ |
|
160 typedef RExternalisableArray<TEntry> RFileArray; |
|
161 |
|
162 /** Array of TRestoreFileFilter objects |
|
163 @released |
|
164 @publishedPartner |
|
165 */ |
|
166 typedef RExternalisableArray<TRestoreFileFilter> RRestoreFileFilterArray; |
|
167 |
|
168 /** Array of TSecureId objects |
|
169 @released |
|
170 @publishedPartner |
|
171 */ |
|
172 typedef RExternalisableArray<TSecureId> RSIDArray; |
|
173 |
|
174 enum TDataOwnerStatus |
|
175 /** |
|
176 TDataOwnerStatus encapsulates the status of a data owner. |
|
177 |
|
178 @released |
|
179 @publishedPartner |
|
180 */ |
|
181 { |
|
182 EUnset = 0, /*!< 0x00000000: Unset - allows creation of object without incorrect status */ |
|
183 EDataOwnerNotFound = 1, /*!< 0x00000001: Data owner not found in registration files */ |
|
184 EDataOwnerReady = 2, /*!< 0x00000002: Data owner ready for backup / restore */ |
|
185 EDataOwnerNotReady = 3, /*!< 0x00000003: Data owner not yet ready for backup / restore */ |
|
186 EDataOwnerFailed = 4, /*!< 0x00000004: Data owner failed to become ready */ |
|
187 EDataOwnerNotConnected = 5, /*!< 0x00000005: Data owner alive, but not fully ready */ |
|
188 EDataOwnerReadyNoImpl = 6 /*!< 0x00000006: Data owner ready for backup / restore but does not provide callback implementation */ |
|
189 }; |
|
190 |
|
191 class TDataOwnerAndStatus |
|
192 /** |
|
193 TDataOwnerAndStatus encapsulates the identity and status of a data owner. |
|
194 Access to members is direct. |
|
195 |
|
196 @released |
|
197 @publishedPartner |
|
198 */ |
|
199 { |
|
200 public: |
|
201 /** |
|
202 Constructor |
|
203 |
|
204 @param aSID Data owner secure id - identifies the data owner |
|
205 @param aStatus Status of the data owner |
|
206 @param aDataOwnerError Error code if data owner failed to be ready |
|
207 or KErrNone |
|
208 */ |
|
209 TDataOwnerAndStatus(TSecureId aSID, TDataOwnerStatus aStatus, TInt aDataOwnerError) |
|
210 : iSID(aSID), iStatus(aStatus), iDataOwnerError(aDataOwnerError) {} |
|
211 public: |
|
212 TSecureId iSID; /*!< Data owner secure id - identifies the data owner */ |
|
213 TDataOwnerStatus iStatus; /*!< Status of the data owner */ |
|
214 TInt iDataOwnerError; /*!< Error code if data owner failed to be ready or KErrNone */ |
|
215 }; |
|
216 |
|
217 /** Array of data owners with their status |
|
218 @released |
|
219 @publishedPartner |
|
220 */ |
|
221 typedef RExternalisableArray<TDataOwnerAndStatus> RSIDStatusArray; |
|
222 |
|
223 enum TBackupDataType |
|
224 /** |
|
225 TBackupDataType indicates whether a specific data stream or operation relates to active or |
|
226 passive backup or restore. A specific data owner can use both active and passive and so we |
|
227 need to differentiate between operations. |
|
228 |
|
229 @released |
|
230 @publishedPartner |
|
231 */ |
|
232 { |
|
233 EActive = 0, /*!< 0x00000000: The backup or restore operation is active rather than passive */ |
|
234 EPassive = 1 /*!< 0x00000001: The backup or restore operation is passive rather than active */ |
|
235 }; |
|
236 |
|
237 enum TTransferDataType |
|
238 /** |
|
239 TTransferDataType indicates the type of data being transferred from the Secure Backup |
|
240 Engine to the Secure Backup Server or vice versa. |
|
241 |
|
242 @released |
|
243 @publishedPartner |
|
244 */ |
|
245 { |
|
246 ERegistrationData = 0, /*!< 0x00000000: deprecated */ |
|
247 EPassiveSnapshotData = 1, /*!< 0x00000001: The data is a snapshot for passive backup that includes file details*/ |
|
248 EPassiveBaseData = 2, /*!< 0x00000002: The data is passively backup up private data with no previous history */ |
|
249 EPassiveIncrementalData = 3, /*!< 0x00000003: The data is passively backed up private data as an increment on a previous base backup */ |
|
250 EActiveSnapshotData = 4, /*!< 0x00000004: The data is a snapshot for active backup that includes file details*/ |
|
251 EActiveBaseData = 5, /*!< 0x00000005: The data is actively backup up private data with no previous history */ |
|
252 EActiveIncrementalData = 6, /*!< 0x00000006: The data is actively backed up private data as an increment on a previous base backup */ |
|
253 ECentralRepositoryData = 7, /*!< 0x00000007: deprecated */ |
|
254 EPublicFileListing = 8, /*!< 0x00000008: An externalised list of public file entries belonging to a single data owner */ |
|
255 }; |
|
256 |
|
257 enum TSBDerivedType |
|
258 /** |
|
259 Used to identify the derived type that the base generic type represents |
|
260 |
|
261 @deprecated |
|
262 @publishedPartner |
|
263 */ |
|
264 { |
|
265 ESIDDerivedType = 0, /*!< 0x00000000: SID derived type */ |
|
266 EPackageDerivedType = 1, /*!< 0x00000001: Package derived type */ |
|
267 ESIDTransferDerivedType = 2, /*!< 0x00000002: SID data transfer derived type */ |
|
268 EPackageTransferDerivedType = 3, /*!< 0x00000003: Package data transfer derived type */ |
|
269 EJavaDerivedType = 4, /*!< 0x00000004: Java ID derived type */ |
|
270 EJavaTransferDerivedType = 5, /*!< 0x00000005: Java ID derived type */ |
|
271 }; |
|
272 |
|
273 /** |
|
274 Maximum number of derived types specified in TSBDerivedType |
|
275 |
|
276 @released |
|
277 @publishedPartner |
|
278 */ |
|
279 const TUint KMaxDerivedTypes = 6; |
|
280 |
|
281 enum TPackageDataType |
|
282 /** |
|
283 TPackageDataType indicates the type of package data being |
|
284 transferred from the Secure Backup Engine to the Secure Backup |
|
285 Server or vice versa. |
|
286 |
|
287 @deprecated |
|
288 @publishedPartner |
|
289 */ |
|
290 { |
|
291 ESystemData = 0, /*!< 0x00000000: The data is system files (typically executables or resource files) */ |
|
292 ESystemSnapshotData = 1, /*!< 0x00000001: The data is a snapshot for system files */ |
|
293 }; |
|
294 |
|
295 enum TJavaTransferType |
|
296 /** |
|
297 This enum defines the type of Java data that is being transferred and can indicate either a MIDlet |
|
298 suite archive (Jad/Jar etc.) or data for an installed MIDlet suite |
|
299 |
|
300 @released |
|
301 @publishedPartner |
|
302 */ |
|
303 { |
|
304 EJavaMIDlet = 0, |
|
305 EJavaMIDletData = 1, |
|
306 }; |
|
307 |
|
308 enum TTransferDirection |
|
309 /** |
|
310 TTransferDirection indicates whether a (just completed) data transfer is from the |
|
311 Secure Backup Server to a data owner or vice versa. |
|
312 |
|
313 @released |
|
314 @publishedPartner |
|
315 */ |
|
316 { |
|
317 EServerToDataOwner = 0, /*!< 0x00000000: The transfer is from the Secure Backup Server to a data owner */ |
|
318 EDataOwnerToServer = 1/*!< 0x00000001: The transfer is from a data owner to the Secure Backup Server */ |
|
319 }; |
|
320 |
|
321 /** Generic Data Type is a class for representing any type of data owner so that it |
|
322 may be passed through a common interface |
|
323 |
|
324 <H2>Introduction</H2> |
|
325 |
|
326 The CSBEClient Secure backup interface class is designed to perform backup operations |
|
327 on many different types of data owners. This presents a problem in that the interfaces |
|
328 sometimes require arguments that are specific to the data type in question. In addition, |
|
329 we can't predict the new data types that may appear in future, therefore a "generic" data |
|
330 type was proposed that could be passed through interfaces as a base class and contained |
|
331 enough information to enable Runtime Type Identification (RTTI) to be performed. |
|
332 |
|
333 This approach means that only one interface needs to be maintained for each backup |
|
334 operation whilst still allowing the Secure Backup Engine to determine which type was |
|
335 originally sent by a PC client. |
|
336 |
|
337 As well as acting as an identifier for different Data Owner's (DO's), it was decided |
|
338 to extend the usage of the class to identify Data Owner's Data as each DO may require |
|
339 specific information to identify data being transferred (such as finished flags etc.) |
|
340 |
|
341 The identifier is transparent to the user of CSBEClient, meaning that it can be |
|
342 extracted directly from the message sent by the PC into a generic type and passed through |
|
343 to the SBEngine without being instantiated as a derived class. |
|
344 |
|
345 <H2>Usage</H2> |
|
346 |
|
347 The general usage of the generic data type is to extract it from a PC sent message as a |
|
348 CSBGenericDataType object using CSBGenericDataType::NewL(const TDesC8& aDes). |
|
349 |
|
350 There are a few conventions that have been followed within the Secure Backup component |
|
351 that a developer must bear in mind: |
|
352 |
|
353 @li Ownership of the CSBGenericDataType, CSBGenericTransferType or derived |
|
354 object is generally passed between interfaces and as such it is the resposibility |
|
355 of the receiving function to delete it. Unless otherwise stated in the documentation |
|
356 for an interface, this is assumed to be the case; |
|
357 |
|
358 @li When a CSBGenericDataType or CSBGenericTransferType is to be converted into |
|
359 a derived type, it must be passed in as a parameter to the constructor of the derived |
|
360 type. It must not be downcasted as it may never have been a derived type, and the |
|
361 derived types contain extra member data; |
|
362 |
|
363 In order to convert a base type to a derived type, a method CSBGenericDataType::DerivedTypeL() |
|
364 that returns a conn::TSBDerivedType can be called to query the base object for it's derived type. |
|
365 |
|
366 A typical mechanism would be to use a switch statement, switching on the return value of |
|
367 DerivedTypeL() and taking appropriate action with regards to creating a derived object. |
|
368 |
|
369 <H2>Internal Operation</H2> |
|
370 |
|
371 <H3>Initialisation</H3> |
|
372 |
|
373 CSBGenericDataType is underneath basically a descriptor buffer. All accessor functions |
|
374 simply extract and pack values from this descriptor. This means that the type can be |
|
375 safely transferred via IPC between processes and safely transferred between a device |
|
376 and a PC independently of communications bearer or transport. |
|
377 |
|
378 The base class CSBGenericDataType has ownership of the data buffer, iDataBuffer, used |
|
379 to store the member data in and in order to keep the derived classes atomic, a running |
|
380 total size variable is updated by the C++ constructors of each class in the inheritence |
|
381 chain. Because of Symbian's static NewL idiom, all C++ constructors are executed before |
|
382 CSBGenericDataType::ConstructL() is called to instantiate the buffer, hence the size |
|
383 can be guaranteed to be big enough to hold all of the derived type's data. |
|
384 |
|
385 In order to ensure that the derived types know whereabouts in the descriptor to extract |
|
386 and pack values, an initialisation routine, InitialiseL(TInt& aOffset), is implemented |
|
387 by each class. Each class is responsible for calling it's parents InitialiseL(), before |
|
388 initialising itself and passing in an offset. The job of the initialisation method is |
|
389 to walk the descriptor, storing the offset's of it's member data. The offset is a |
|
390 reference and is hence updated so that the child class begins unpacking after the parents |
|
391 data ends. In this way, each class is atomic apart from having to explicitly scope it's |
|
392 parent's InitialiseL() method. |
|
393 |
|
394 <H3>Accessing Data</H3> |
|
395 |
|
396 Data is accessed by the use of packing and unpacking bytes directly from the descriptor |
|
397 using the UnpackType, PackType and associated function templates. These will be unpacked |
|
398 in the endianness of the system and therefore the PC will have to ensure that this |
|
399 is taken into account when packing the type into the message. |
|
400 |
|
401 Although this method suffers in terms of performance, for the reasons of platform |
|
402 independence, this is the most reliable method of packing/unpacking. |
|
403 |
|
404 <H2>Byte Structure</H2> |
|
405 |
|
406 All child classes have their data following on from the parent classes so that the parent |
|
407 classes may remain atomic with respect to the structure of their data. The binary structure |
|
408 of this data type inside the descriptor buffer is as follows. Note that the endianness of |
|
409 the data types specified below is determined by the platform and the PC must pack accordingly: |
|
410 |
|
411 <table border="1"> |
|
412 <tr> |
|
413 <td>TSBDerivedType [4-bytes]</td> |
|
414 </tr> |
|
415 </table> |
|
416 |
|
417 |
|
418 @deprecated |
|
419 @publishedPartner |
|
420 */ |
|
421 class CSBGenericDataType : public CBase |
|
422 { |
|
423 public: |
|
424 IMPORT_C static CSBGenericDataType* NewL(const TDesC8& aDes); |
|
425 IMPORT_C ~CSBGenericDataType(); |
|
426 IMPORT_C const TDesC8& Externalise() const; |
|
427 IMPORT_C TSBDerivedType DerivedTypeL() const; |
|
428 |
|
429 protected: |
|
430 CSBGenericDataType(); |
|
431 void ConstructL(const TDesC8& aDes); |
|
432 void BaseConstructL(); |
|
433 virtual void InitialiseL(TInt& aOffset); |
|
434 void UnpackDescriptorTypeAdvance(TDesC16& aDes, TInt& aOffset); |
|
435 void UnpackDescriptorTypeAdvance(TDesC8& aDes, TInt& aOffset); |
|
436 void UnpackTPtrAdvance(TPtrC16& aDes, TInt& aOffset); |
|
437 void UnpackTPtrAdvance(TPtrC8& aDes, TInt& aOffset); |
|
438 void PackDescriptorTypeAdvance(const TDesC16& aDes, TInt& aOffset); |
|
439 void PackDescriptorTypeAdvance(const TDesC8& aDes, TInt& aOffset); |
|
440 |
|
441 protected: |
|
442 /** the data buffer */ |
|
443 HBufC8* iDataBuffer; |
|
444 |
|
445 /** Cumulative size of the derived type. All ctors in the inheritence tree increment |
|
446 with their size */ |
|
447 TInt iSize; |
|
448 |
|
449 /** the derived type */ |
|
450 TInt iDerivedTypeOffset; |
|
451 }; |
|
452 |
|
453 template<class T> inline void UnpackType(T& aType, TDesC8& aDes, TInt aOffset) |
|
454 /** |
|
455 Templated function to copy a simple type from a specified position in aDes |
|
456 defined by aOffset. aOffset is not updated on return. |
|
457 |
|
458 @param aType This pointer is set with the pointer to the type in aDes |
|
459 @param aDes The buffer that contains the type T pointed to by aPtr |
|
460 @param aOffset The running index of where the following type begins. Updated by ExtractPointer |
|
461 */ |
|
462 { |
|
463 // Set the position at which to finish copying |
|
464 TInt endOffset = aOffset + sizeof(T); |
|
465 |
|
466 TUint8* pRawType = reinterpret_cast<TUint8*>(&aType); |
|
467 TUint8* pRawSource = const_cast<TUint8*>(aDes.Ptr()) + aOffset; |
|
468 |
|
469 for (TInt offset = aOffset; offset < endOffset; offset++) |
|
470 { |
|
471 *pRawType++ = *pRawSource++; |
|
472 } |
|
473 } |
|
474 |
|
475 template<class T> inline void UnpackTypeAdvance(T& aType, TDesC8& aDes, TInt& aOffset) |
|
476 /** |
|
477 Templated function to copy a simple type from a specified position in aDes |
|
478 defined by aOffset. aOffset is advanced so that on return, the new |
|
479 offset is stored enabling the next call to UnpackType() to point at the position |
|
480 following this type. |
|
481 |
|
482 @param aType This pointer is set with the pointer to the type in aDes |
|
483 @param aDes The buffer that contains the type T pointed to by aPtr |
|
484 @param aOffset The running index of where the following type begins. Updated by ExtractPointer |
|
485 */ |
|
486 { |
|
487 // Set the position at which to finish copying |
|
488 TInt endOffset = aOffset + sizeof(T); |
|
489 |
|
490 TUint8* pRawType = reinterpret_cast<TUint8*>(&aType); |
|
491 TUint8* pRawSource = const_cast<TUint8*>(aDes.Ptr()) + aOffset; |
|
492 |
|
493 for (; aOffset < endOffset; aOffset++) |
|
494 { |
|
495 *pRawType++ = *pRawSource++; |
|
496 } |
|
497 } |
|
498 |
|
499 template<> inline void UnpackTypeAdvance(TDriveList& aType, TDesC8& aDes, TInt& aOffset) |
|
500 /** |
|
501 Templated function to copy a simple type from a specified position in aDes |
|
502 defined by aOffset. aOffset is advanced so that on return, the new |
|
503 offset is stored enabling the next call to UnpackType() to point at the position |
|
504 following this type. |
|
505 |
|
506 @param aType This pointer is set with the pointer to the type in aDes |
|
507 @param aDes The buffer that contains the type T pointed to by aPtr |
|
508 @param aOffset The running index of where the following type begins. Updated by ExtractPointer |
|
509 */ |
|
510 { |
|
511 TUint8* pRawSource = const_cast<TUint8*>(aDes.Ptr()) + aOffset; |
|
512 |
|
513 aType.SetMax(); |
|
514 |
|
515 for (TInt index = 0; index < KMaxDrives; index++) |
|
516 { |
|
517 aType[index] = *pRawSource++; |
|
518 } |
|
519 |
|
520 aOffset += KMaxDrives; |
|
521 } |
|
522 |
|
523 template<class T> inline void PackType(T& aType, TDesC8& aDes, TInt aOffset) |
|
524 /** |
|
525 Templated function to copy a simple type into a specified position in aDes |
|
526 defined by aOffset. aOffset is not advanced as a result of this operation |
|
527 |
|
528 @param aType This object is overwritten with the flattened type in aDes |
|
529 @param aDes The buffer that contains the type T pointed to by aPtr |
|
530 @param aOffset The running index of where the following type begins. Updated by ExtractPointer |
|
531 |
|
532 @return The new offset after packing the data type |
|
533 */ |
|
534 { |
|
535 // Set the position at which to finish copying |
|
536 TInt endOffset = aOffset + sizeof(T); |
|
537 |
|
538 TUint8* pRawType = reinterpret_cast<TUint8*>(&aType); |
|
539 TUint8* pRawBuf = const_cast<TUint8*>(aDes.Ptr()) + aOffset; |
|
540 |
|
541 for (TInt offset = aOffset; offset < endOffset; offset++) |
|
542 { |
|
543 *pRawBuf++ = *pRawType++; |
|
544 } |
|
545 } |
|
546 |
|
547 template<class T> inline void PackTypeAdvance(T& aType, TDesC8& aDes, TInt& aOffset) |
|
548 /** |
|
549 Templated function to copy a simple type into a specified position in aDes |
|
550 defined by aOffset. aOffset is updated to reflect the advance along aDes |
|
551 |
|
552 @param aType This object is overwritten with the flattened type in aDes |
|
553 @param aDes The buffer that contains the type T pointed to by aPtr |
|
554 @param aOffset The running index of where the following type begins. Updated by ExtractPointer |
|
555 |
|
556 @return The new offset after packing the data type |
|
557 */ |
|
558 { |
|
559 // Set the position at which to finish copying |
|
560 TInt endOffset = aOffset + sizeof(T); |
|
561 |
|
562 TUint8* pRawType = reinterpret_cast<TUint8*>(&aType); |
|
563 TUint8* pRawBuf = const_cast<TUint8*>(aDes.Ptr() + aOffset); |
|
564 |
|
565 for (; aOffset < endOffset; aOffset++) |
|
566 { |
|
567 *pRawBuf++ = *pRawType++; |
|
568 } |
|
569 } |
|
570 |
|
571 |
|
572 /** Generic Data Type representing a data owner identified by a SecureId |
|
573 |
|
574 <H2>Byte Structure</H2> |
|
575 |
|
576 All child classes have their data following on from the parent classes so that the parent |
|
577 classes may remain atomic with respect to the structure of their data. The binary structure |
|
578 of this data type inside the descriptor buffer is as follows. Note that the endianness of |
|
579 the data types specified below is determined by the platform and the PC must pack accordingly: |
|
580 |
|
581 <table border="1"> |
|
582 <tr> |
|
583 <td>TSBDerivedType [4-bytes]</td> |
|
584 <td>TSecureId [4-bytes]</td> |
|
585 </tr> |
|
586 </table> |
|
587 |
|
588 @deprecated |
|
589 @publishedPartner |
|
590 */ |
|
591 class CSBSecureId : public CSBGenericDataType |
|
592 { |
|
593 public: |
|
594 IMPORT_C static CSBSecureId* NewL(TSecureId aSecureId); |
|
595 IMPORT_C static CSBSecureId* NewL(CSBGenericDataType* aGenericDataType); |
|
596 IMPORT_C ~CSBSecureId(); |
|
597 IMPORT_C TSecureId SecureIdL() const; |
|
598 |
|
599 protected: |
|
600 void InitialiseL(TInt& aOffset); |
|
601 |
|
602 private: |
|
603 CSBSecureId(); |
|
604 void ConstructL(TSecureId aSecureId); |
|
605 void ConstructL(CSBGenericDataType* aGenericDataType); |
|
606 |
|
607 private: |
|
608 /** the secure identifier */ |
|
609 TInt iSecureIdOffset; |
|
610 }; |
|
611 |
|
612 /** Generic Data Type representing a data owner identified by a Package Id, Secure Id and |
|
613 Package Name. Package Id's are used to represent multiple SID's installed under a single |
|
614 package. There would potentially be several CSBPackageId's associated with a package, each |
|
615 detailing a single SID. |
|
616 |
|
617 <H2>Byte Structure</H2> |
|
618 |
|
619 All child classes have their data following on from the parent classes so that the parent |
|
620 classes may remain atomic with respect to the structure of their data. The binary structure |
|
621 of this data type inside the descriptor buffer is as follows. Note that the endianness of |
|
622 the data types specified below is determined by the platform and the PC must pack accordingly: |
|
623 |
|
624 <table border="1"> |
|
625 <tr> |
|
626 <td>TSBDerivedType [4-bytes]</td> |
|
627 <td>TUid [4-bytes]</td> |
|
628 <td>TSecureId [4-bytes]</td> |
|
629 <td>Pkg name length [4-bytes]</td> |
|
630 <td>Pkg name data [variable]</td> |
|
631 </tr> |
|
632 </table> |
|
633 |
|
634 @deprecated |
|
635 @publishedPartner |
|
636 */ |
|
637 class CSBPackageId : public CSBGenericDataType |
|
638 { |
|
639 public: |
|
640 IMPORT_C static CSBPackageId* NewL(TUid aPackageId, TSecureId aSecureId, const TDesC& aPackageName); |
|
641 IMPORT_C static CSBPackageId* NewL(CSBGenericDataType* aGenericDataType); |
|
642 IMPORT_C ~CSBPackageId(); |
|
643 IMPORT_C TUid PackageIdL() const; |
|
644 IMPORT_C TSecureId SecureIdL() const; |
|
645 IMPORT_C TPackageName PackageNameL() const; |
|
646 |
|
647 protected: |
|
648 void InitialiseL(TInt& aOffset); |
|
649 void InitialiseL(TInt& aOffset, TInt aPackageNameLength); |
|
650 |
|
651 private: |
|
652 CSBPackageId(); |
|
653 void ConstructL(TUid aPackageId, TSecureId aSecureId, const TDesC& aPackageName); |
|
654 void ConstructL(CSBGenericDataType* aGenericDataType); |
|
655 |
|
656 private: |
|
657 /** the package identifier */ |
|
658 TInt iPackageIdOffset; |
|
659 /** the secure identifier */ |
|
660 TInt iSecureIdOffset; |
|
661 /** user-readable name for the package */ |
|
662 TInt iPackageNameOffset; |
|
663 }; |
|
664 |
|
665 /** Generic Transfer Type |
|
666 |
|
667 This is also a semi-abstract class similar to the CSBGenericDataType in that logically it may |
|
668 only be instantiated by being internalised from a descriptor. This class and classes that derive |
|
669 from it are intended to identify a data transfer to or from a particular data owner. |
|
670 |
|
671 <H2>Byte Structure</H2> |
|
672 |
|
673 All child classes have their data following on from the parent classes so that the parent |
|
674 classes may remain atomic with respect to the structure of their data. The binary structure |
|
675 of this data type inside the descriptor buffer is as follows. Note that the endianness of |
|
676 the data types specified below is determined by the platform and the PC must pack accordingly: |
|
677 |
|
678 <table border="1"> |
|
679 <tr> |
|
680 <td>TSBDerivedType [4-bytes]</td> |
|
681 <td>TDriveNumber [4-bytes]</td> |
|
682 </tr> |
|
683 </table> |
|
684 |
|
685 @deprecated |
|
686 @publishedPartner |
|
687 */ |
|
688 class CSBGenericTransferType : public CSBGenericDataType |
|
689 { |
|
690 public: |
|
691 IMPORT_C static CSBGenericTransferType* NewL(const TDesC8& aDes); |
|
692 IMPORT_C ~CSBGenericTransferType(); |
|
693 IMPORT_C TDriveNumber DriveNumberL() const; |
|
694 |
|
695 protected: |
|
696 CSBGenericTransferType(); |
|
697 virtual void InitialiseL(TInt& aOffset); |
|
698 |
|
699 protected: |
|
700 /** the drive number */ |
|
701 TInt iDriveNumberOffset; |
|
702 }; |
|
703 |
|
704 /** SID Transfer type is used to identify data associated with a particular SID |
|
705 |
|
706 <H2>Byte Structure</H2> |
|
707 |
|
708 All child classes have their data following on from the parent classes so that the parent |
|
709 classes may remain atomic with respect to the structure of their data. The binary structure |
|
710 of this data type inside the descriptor buffer is as follows. Note that the endianness of |
|
711 the data types specified below is determined by the platform and the PC must pack accordingly: |
|
712 |
|
713 <table border="1"> |
|
714 <tr> |
|
715 <td>TSBDerivedType [4-bytes]</td> |
|
716 <td>TDriveNumber [4-bytes]</td> |
|
717 <td>TSecureId [4-bytes]</td> |
|
718 <td>TTransferDataType [4-bytes]</td> |
|
719 </tr> |
|
720 </table> |
|
721 |
|
722 @deprecated |
|
723 @publishedPartner |
|
724 */ |
|
725 class CSBSIDTransferType : public CSBGenericTransferType |
|
726 { |
|
727 public: |
|
728 IMPORT_C static CSBSIDTransferType* NewL(TSecureId aSecureId, TDriveNumber aDriveNumber, TTransferDataType aTransferDataType); |
|
729 IMPORT_C static CSBSIDTransferType* NewL(CSBGenericTransferType* aGenericTransferType); |
|
730 IMPORT_C ~CSBSIDTransferType(); |
|
731 IMPORT_C TSecureId SecureIdL() const; |
|
732 IMPORT_C TTransferDataType DataTypeL() const; |
|
733 |
|
734 protected: |
|
735 void InitialiseL(TInt& aOffset); |
|
736 |
|
737 private: |
|
738 CSBSIDTransferType(); |
|
739 void ConstructL(TSecureId aSecureId, TDriveNumber aDriveNumber, TTransferDataType aTransferDataType); |
|
740 void ConstructL(CSBGenericTransferType* aGenericTransferType); |
|
741 |
|
742 private: |
|
743 /** the secure identifier */ |
|
744 TInt iSecureIdOffset; |
|
745 /** the transfer data type */ |
|
746 TInt iTransferDataTypeOffset; |
|
747 }; |
|
748 |
|
749 /** Package Transfer Type is used to identify data related to a particular Package ID |
|
750 |
|
751 <H2>Byte Structure</H2> |
|
752 |
|
753 All child classes have their data following on from the parent classes so that the parent |
|
754 classes may remain atomic with respect to the structure of their data. The binary structure |
|
755 of this data type inside the descriptor buffer is as follows. Note that the endianness of |
|
756 the data types specified below is determined by the platform and the PC must pack accordingly: |
|
757 |
|
758 <table border="1"> |
|
759 <tr> |
|
760 <td>TSBDerivedType [4-bytes]</td> |
|
761 <td>TDriveNumber [4-bytes]</td> |
|
762 <td>TUid [4-bytes]</td> |
|
763 <td>TPackageDataType [4-bytes]</td> |
|
764 </tr> |
|
765 </table> |
|
766 |
|
767 @deprecated |
|
768 @publishedPartner |
|
769 */ |
|
770 class CSBPackageTransferType : public CSBGenericTransferType |
|
771 { |
|
772 public: |
|
773 IMPORT_C static CSBPackageTransferType* NewL(TUid aPackageId, TDriveNumber aDriveNUmber, TPackageDataType aPackageDataType); |
|
774 IMPORT_C static CSBPackageTransferType* NewL(CSBGenericTransferType* aGenericTransferType); |
|
775 IMPORT_C ~CSBPackageTransferType(); |
|
776 IMPORT_C TUid PackageIdL() const; |
|
777 IMPORT_C TPackageDataType DataTypeL() const; |
|
778 |
|
779 protected: |
|
780 void InitialiseL(TInt& aOffset); |
|
781 |
|
782 private: |
|
783 CSBPackageTransferType(); |
|
784 void ConstructL(TUid aPackageId, TDriveNumber aDriveNumber, TPackageDataType aPackageDataType); |
|
785 void ConstructL(CSBGenericTransferType* aGenericTransferType); |
|
786 |
|
787 private: |
|
788 /** the package identifier */ |
|
789 TInt iPackageIdOffset; |
|
790 /** the package data type */ |
|
791 TInt iPackageDataTypeOffset; |
|
792 }; |
|
793 |
|
794 class CDataOwnerInfo : public CBase |
|
795 /** |
|
796 CDataOwnerInfo packages up information for the backup / restore client on an |
|
797 individual data owner. |
|
798 |
|
799 Access to the data members is direct. |
|
800 |
|
801 @deprecated |
|
802 @publishedPartner |
|
803 */ |
|
804 { |
|
805 public: |
|
806 IMPORT_C static CDataOwnerInfo* NewL( CSBGenericDataType* aGenericDataType, |
|
807 TCommonBURSettings aCommonSettings, |
|
808 TPassiveBURSettings aPassiveSettings, |
|
809 TActiveBURSettings aActiveSettings, |
|
810 const TDriveList& aDriveList ); |
|
811 |
|
812 IMPORT_C static CDataOwnerInfo* NewL ( const TDesC8& aFlatDataOwnerInfo ); |
|
813 IMPORT_C ~CDataOwnerInfo(); |
|
814 IMPORT_C CSBGenericDataType& Identifier(); |
|
815 IMPORT_C const CSBGenericDataType& Identifier() const; |
|
816 IMPORT_C TCommonBURSettings CommonSettings() const; |
|
817 IMPORT_C TPassiveBURSettings PassiveSettings() const; |
|
818 IMPORT_C TActiveBURSettings ActiveSettings() const; |
|
819 IMPORT_C TDriveList& DriveList(); |
|
820 IMPORT_C const TDriveList& DriveList() const; |
|
821 IMPORT_C HBufC8* ExternaliseL(); |
|
822 IMPORT_C TInt Size() const; |
|
823 IMPORT_C HBufC8* ExternaliseLC(); |
|
824 |
|
825 private: |
|
826 CDataOwnerInfo(); |
|
827 void ConstructL(CSBGenericDataType* aGenericDataType, TCommonBURSettings aCommonSettings, |
|
828 TPassiveBURSettings aPassiveSettings, TActiveBURSettings aActiveSettings, |
|
829 const TDriveList& aDriveList); |
|
830 void ConstructL(const TDesC8& aFlatDataOwnerInfo); |
|
831 |
|
832 private: |
|
833 CSBGenericDataType* iGenericDataType; /*!< generic data type object */ |
|
834 TCommonBURSettings iCommonBURSettings; /*!< flags for storing common backup and restore settings */ |
|
835 TPassiveBURSettings iPassiveBURSettings; /*!< flags for storing passive backup and restore settings */ |
|
836 TActiveBURSettings iActiveBURSettings; /*!< flags for storing active backup and restore settings */ |
|
837 TDriveList iDriveList; /*!< List of drives that the data owner has data on */ |
|
838 }; |
|
839 |
|
840 /** Generic Data Type representing a MIDlet data owner identified by a Suite Name, Vendor Name, |
|
841 Version and a unique MIDlet Suite Hash. The Suite Hash should be used as the unique identifier for |
|
842 the MIDlet suite. |
|
843 |
|
844 <H2>Byte Structure</H2> |
|
845 |
|
846 All child classes have their data following on from the parent classes so that the parent |
|
847 classes may remain atomic with respect to the structure of their data. The binary structure |
|
848 of this data type inside the descriptor buffer is as follows. Note that the endianness of |
|
849 the data types specified below is determined by the platform and the PC must pack accordingly: |
|
850 |
|
851 <table border="1"> |
|
852 <tr> |
|
853 <td>TSBDerivedType [4-bytes]</td> |
|
854 <td>MIDlet suite name length [4-bytes]</td> |
|
855 <td>MIDlet suite name [2*length]</td> |
|
856 <td>MIDlet suite vendor length [4-bytes]</td> |
|
857 <td>MIDlet suite vendor [2*length]</td> |
|
858 <td>MIDlet suite version length [4-bytes]</td> |
|
859 <td>MIDlet suite version [2*length]</td> |
|
860 <td>MIDlet suite hash length [4-bytes] (should be 32)</td> |
|
861 <td>MIDlet suite hash [2*length]</td> |
|
862 </tr> |
|
863 </table> |
|
864 |
|
865 @deprecated |
|
866 @publishedPartner |
|
867 */ |
|
868 class CSBJavaId : public CSBGenericDataType |
|
869 { |
|
870 public: |
|
871 IMPORT_C static CSBJavaId* NewL(const TDesC& aSuiteName, const TDesC& aSuiteVendor,const TDesC& aSuiteVersion, const TDesC& aSuiteHash); |
|
872 IMPORT_C static CSBJavaId* NewL(CSBGenericDataType* aGenericDataType); |
|
873 IMPORT_C ~CSBJavaId(); |
|
874 IMPORT_C const TDesC& SuiteNameL() const; |
|
875 IMPORT_C const TDesC& SuiteVendorL() const; |
|
876 IMPORT_C const TDesC& SuiteVersionL() const; |
|
877 IMPORT_C const TDesC& SuiteHashL() const; |
|
878 |
|
879 protected: |
|
880 void InitialiseL(TInt& aOffset); |
|
881 void InitialiseL(TInt& aOffset, const TDesC& aSuiteName, const TDesC& aSuiteVendor,const TDesC& aSuiteVersion, const TDesC& aSuiteHash); |
|
882 |
|
883 private: |
|
884 CSBJavaId(); |
|
885 CSBJavaId(const TDesC& aSuiteName, const TDesC& aSuiteVendor,const TDesC& aSuiteVersion, const TDesC& aSuiteHash); |
|
886 void ConstructL(const TDesC& aSuiteName, const TDesC& aSuiteVendor,const TDesC& aSuiteVersion, const TDesC& aSuiteHash); |
|
887 void ConstructFromExistingL(CSBGenericDataType* aGenericDataType); |
|
888 |
|
889 private: |
|
890 /** The MIDlet suite Name */ |
|
891 TPtrC iSuiteName; |
|
892 |
|
893 /** The MIDlet suite Vendor */ |
|
894 TPtrC iSuiteVendor; |
|
895 |
|
896 /** The MIDlet suite Version */ |
|
897 TPtrC iSuiteVersion; |
|
898 |
|
899 /** The MIDlet suite Hash */ |
|
900 TPtrC iSuiteHash; |
|
901 }; |
|
902 |
|
903 /** The Java Transfer Type identifies types of data belonging to particular MIDlet suites (identified |
|
904 by the Suite Hash) |
|
905 |
|
906 <H2>Byte Structure</H2> |
|
907 |
|
908 All child classes have their data following on from the parent classes so that the parent |
|
909 classes may remain atomic with respect to the structure of their data. The binary structure |
|
910 of this data type inside the descriptor buffer is as follows. Note that the endianness of |
|
911 the data types specified below is determined by the platform and the PC must pack accordingly: |
|
912 |
|
913 <table border="1"> |
|
914 <tr> |
|
915 <td>TSBDerivedType [4-bytes]</td> |
|
916 <td>TDriveNumber [4-bytes]</td> |
|
917 <td>TJavaTransferType [4-bytes]</td> |
|
918 <td>MIDlet suite hash length [4-bytes] (should be 32)</td> |
|
919 <td>MIDlet suite hash [2*length]</td> |
|
920 </tr> |
|
921 </table> |
|
922 |
|
923 @deprecated |
|
924 @publishedPartner |
|
925 */ |
|
926 class CSBJavaTransferType : public CSBGenericTransferType |
|
927 { |
|
928 public: |
|
929 IMPORT_C static CSBJavaTransferType* NewL(const TDesC& aSuiteHash, TDriveNumber aDriveNumber, TJavaTransferType aTransferDataType); |
|
930 IMPORT_C static CSBJavaTransferType* NewL(CSBGenericTransferType* aGenericTransferType); |
|
931 IMPORT_C ~CSBJavaTransferType(); |
|
932 IMPORT_C const TDesC& SuiteHashL() const; |
|
933 IMPORT_C TJavaTransferType DataTypeL() const; |
|
934 |
|
935 protected: |
|
936 void InitialiseL(TInt& aOffset); |
|
937 void InitialiseL(TInt& aOffset, const TDesC& aSuiteHash, TDriveNumber aDriveNumber, |
|
938 TJavaTransferType aTransferDataType); |
|
939 |
|
940 private: |
|
941 CSBJavaTransferType(); |
|
942 CSBJavaTransferType(const TDesC& aSuiteHash); |
|
943 void ConstructL(const TDesC& aSuiteHash, TDriveNumber aDriveNumber, TJavaTransferType aTransferDataType); |
|
944 void ConstructL(CSBGenericTransferType* aGenericTransferType); |
|
945 |
|
946 private: |
|
947 /** The MIDlet suite Hash */ |
|
948 TPtrC iSuiteHash; |
|
949 |
|
950 /** the transfer data type */ |
|
951 TInt iTransferDataTypeOffset; |
|
952 }; |
|
953 |
|
954 class CSBEFileEntry : public CBase |
|
955 /** This class is a more memory efficient heap based externalisable version of |
|
956 TEntry containing just the information required for public backup. |
|
957 TEntry contains a TFileName which is a modifiable descriptor of 512 bytes |
|
958 and therefore takes up needless memory. CSBEFileEntry on the other hand occupies |
|
959 only as much RAM as is required to represent the name and path of the file that |
|
960 it represents. |
|
961 @deprecated |
|
962 @publishedPartner |
|
963 */ |
|
964 { |
|
965 public: |
|
966 IMPORT_C static CSBEFileEntry* NewLC(const TEntry& aEntry, RApaLsSession& aSession); |
|
967 IMPORT_C static CSBEFileEntry* NewLC(const TDesC8& aStream, TInt& aBytesRead); |
|
968 IMPORT_C ~CSBEFileEntry(); |
|
969 IMPORT_C HBufC8* ExternaliseLC() const; |
|
970 IMPORT_C TUint FileAttributes() const; |
|
971 IMPORT_C TInt FileSize() const; |
|
972 IMPORT_C TTime LastModified() const; |
|
973 IMPORT_C TDesC16& Filename() const; |
|
974 IMPORT_C TDesC16& MIMEType() const; |
|
975 IMPORT_C TUidType& MIMEUid(); |
|
976 private: |
|
977 void ConstructL(const TEntry& aEntry, RApaLsSession& aSession); |
|
978 void InternaliseL(const TDesC8& aStream, TInt& aBytesRead); |
|
979 CSBEFileEntry(); |
|
980 CSBEFileEntry(const TEntry& aEntry); |
|
981 TUint16 CalculatePackedSize() const; |
|
982 private: |
|
983 /** |
|
984 The individual bits within this byte indicate which attributes |
|
985 have been set. |
|
986 |
|
987 @see KEntryAttNormal |
|
988 @see KEntryAttReadOnly |
|
989 @see KEntryAttHidden |
|
990 @see KEntryAttSystem |
|
991 */ |
|
992 TUint iAtt; |
|
993 |
|
994 /** |
|
995 The size of the file in bytes. |
|
996 */ |
|
997 TInt iSize; |
|
998 |
|
999 /** |
|
1000 The system time of last modification, in universal time. |
|
1001 */ |
|
1002 TTime iModified; |
|
1003 |
|
1004 /** |
|
1005 The textual version of the file's UIDtype |
|
1006 */ |
|
1007 HBufC* iType; |
|
1008 |
|
1009 /** |
|
1010 Array of UID Types corresponding to this file |
|
1011 */ |
|
1012 TUidType iUidType; |
|
1013 |
|
1014 /** |
|
1015 Path and name of the file |
|
1016 */ |
|
1017 HBufC* iFilename; |
|
1018 }; |
|
1019 } // end namespace |
|
1020 #endif |