|
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 CDataOwner |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 */ |
|
25 #ifndef __DATAOWNER_H__ |
|
26 #define __DATAOWNER_H__ |
|
27 |
|
28 /// System |
|
29 #include <e32base.h> |
|
30 #include <connect/sbtypes.h> |
|
31 #include <f32file.h> |
|
32 #include <xml/contenthandler.h> // MContentHandler mix in class |
|
33 |
|
34 // Other |
|
35 #include "sbeparserproxy.h" |
|
36 #include "sbebufferhandler.h" |
|
37 #include "sbedataownermanager.h" |
|
38 |
|
39 using namespace Xml; |
|
40 |
|
41 namespace conn |
|
42 { |
|
43 |
|
44 void CleanupRPointerArray(TAny* aPtr); |
|
45 |
|
46 /** Name of Central Repository Server |
|
47 @internalTechnology |
|
48 */ |
|
49 |
|
50 _LIT(KCentRepProcessName, "centralrepositorysrv.exe"); |
|
51 _LIT8(KYes, "yes"); |
|
52 |
|
53 // Forwards |
|
54 class CABServer; |
|
55 class CDataOwnerManager; |
|
56 class CBufferFileWriter; |
|
57 class CBufferFileReader; |
|
58 class CBufferSnapshotWriter; |
|
59 class CBufferSnapshotReader; |
|
60 |
|
61 /** Enumeration to specify if a selection should be included or excluded |
|
62 @internalComponent |
|
63 */ |
|
64 enum TSelectionType |
|
65 { |
|
66 EInclude, /*<!< Is included */ |
|
67 EExclude /*!< Is excluded */ |
|
68 }; |
|
69 |
|
70 |
|
71 /** Simple class to store registraion file selections |
|
72 @internalComponent |
|
73 */ |
|
74 class CSelection : public CBase |
|
75 { |
|
76 public: |
|
77 static CSelection* NewLC(TSelectionType aType, const TDesC& aSelection); |
|
78 ~CSelection(); |
|
79 TSelectionType SelectionType() const; |
|
80 const TDesC& SelectionName() const; |
|
81 |
|
82 private: |
|
83 CSelection(TSelectionType aType); |
|
84 void ConstructL(const TDesC& aSelection); |
|
85 |
|
86 private: |
|
87 TSelectionType iType; /*<! The type of the selection */ |
|
88 HBufC* iSelection; /*<! The actual selection */ |
|
89 }; |
|
90 |
|
91 /** An RArray of selections |
|
92 @internalComponent |
|
93 */ |
|
94 typedef RPointerArray<CSelection> RSelections; |
|
95 |
|
96 /** Simple class to store passive information |
|
97 @internalComponent |
|
98 */ |
|
99 class TPassiveInformation |
|
100 { |
|
101 public: |
|
102 TPassiveInformation() : |
|
103 iSupported(EFalse), |
|
104 iSupportsSelective(EFalse), |
|
105 iDeleteBeforeRestore(EFalse), |
|
106 iBaseBackupOnly(EFalse) |
|
107 /** C++ Constructor |
|
108 */ |
|
109 {} |
|
110 public: |
|
111 TUint8 iSupported; /*<! supported */ |
|
112 TUint8 iSupportsSelective; /*<! Supports selective */ |
|
113 TUint8 iDeleteBeforeRestore; /*<! Delete before restore */ |
|
114 TUint8 iBaseBackupOnly; /*<! Base backup */ |
|
115 }; |
|
116 |
|
117 /** Simple class to store public backup information |
|
118 @internalComponent |
|
119 */ |
|
120 class TPublicInformation |
|
121 { |
|
122 public: |
|
123 TPublicInformation() : |
|
124 iSupported(EFalse), iDeleteBeforeRestore(EFalse) |
|
125 /** C++ Constructor |
|
126 */ |
|
127 {} |
|
128 public: |
|
129 TUint8 iSupported; /*<! supported */ |
|
130 TUint8 iDeleteBeforeRestore; /*<! Delete before restore */ |
|
131 }; |
|
132 |
|
133 /** Simple class to store system backup information |
|
134 @internalComponent |
|
135 */ |
|
136 class TSystemInformation |
|
137 { |
|
138 public: |
|
139 TSystemInformation() : |
|
140 iSupported(EFalse) |
|
141 /** C++ Constructor |
|
142 */ |
|
143 {} |
|
144 public: |
|
145 TUint8 iSupported; /*!< backup system files */ |
|
146 }; |
|
147 |
|
148 /** Information about proxy data owners (i.e. CentRep etc.) |
|
149 @internalComponent |
|
150 */ |
|
151 class TProxyInformation |
|
152 { |
|
153 public: |
|
154 /** C++ Constructor |
|
155 */ |
|
156 TProxyInformation() : iDataRequested(EFalse), iDataSupplied(EFalse), iOpInProgress(EFalse) |
|
157 {} |
|
158 public: |
|
159 TSecureId iSecureId; /*!< The secure ID of the proxy data manager */ |
|
160 TInt iDataRequested; /*!< Data has already been requested from this data owner. While restoring it is used for Proxy data length*/ |
|
161 TInt iDataSupplied; /*!< Data has already been supplied to this data owner. While restoring it is used for consumed/restored data length. */ |
|
162 TBool iOpInProgress; /*!< The proxy hasn't yet completed the op and is waiting a further call. While restoring it is used for proxy finished flag and 1 means proxy data finished 0 means has more data to store */ |
|
163 }; |
|
164 |
|
165 /** Simple class to store restore information |
|
166 @internalComponent |
|
167 */ |
|
168 class TRestoreInformation |
|
169 { |
|
170 public: |
|
171 /** C++ Constructor |
|
172 */ |
|
173 TRestoreInformation() : |
|
174 iSupported(EFalse), iRequiresReboot(EFalse) |
|
175 {}; |
|
176 public: |
|
177 TUint8 iSupported; /*<! supported */ |
|
178 TUint8 iRequiresReboot; /*<! requires reboot */ |
|
179 }; |
|
180 |
|
181 /** enum representing TActiveType */ |
|
182 enum TActiveType |
|
183 { |
|
184 EActiveOnly = 0, /*<! Data Owner have Active Implementaion only */ |
|
185 EActiveAndProxyImpl = 1, /*<! Data Owner have Active and Proxy Implementation */ |
|
186 EProxyImpOnly = 2, /*<! Data Owner have only Proxy Implementation */ |
|
187 }; |
|
188 |
|
189 /** Simple class to store active information |
|
190 @internalComponent |
|
191 */ |
|
192 class TActiveInformation |
|
193 { |
|
194 public: |
|
195 /** C++ Constructor |
|
196 */ |
|
197 TActiveInformation() : |
|
198 iSupported(EFalse), iRequiresDelayToPrepareData(EFalse), |
|
199 iSupportsSelective(EFalse), iSupportsIncremental(ETrue), iActiveDataOwner(EFalse), iActiveType(EActiveOnly) |
|
200 { |
|
201 } |
|
202 public: |
|
203 TUint8 iSupported; /*<! supported? */ |
|
204 TName iProcessName; /*<! Active process name */ |
|
205 TUint8 iRequiresDelayToPrepareData; /*<! Requires delay to prepare data */ |
|
206 TUint8 iSupportsSelective; /*<! Supports selective */ |
|
207 TUint8 iSupportsIncremental; /*<! Supports Incremental */ |
|
208 TUint8 iActiveDataOwner; /*<! Although we say we're active, we're not really */ |
|
209 TActiveType iActiveType; /*<! Type of the Active DO */ |
|
210 }; |
|
211 |
|
212 /** Data Owner support classes and enums */ |
|
213 |
|
214 /** |
|
215 This class holds the state of the data owner by the drive |
|
216 @internalComponent |
|
217 */ |
|
218 class TDataOwnerStateByDrive |
|
219 { |
|
220 public: |
|
221 TDataOwnerStateByDrive(TDriveNumber aDrive) : iDrive(aDrive), iPassiveSnapshotReceived(EFalse), |
|
222 iPassiveBaseDataReceived(EFalse), iPassiveIncDataReceived(EFalse), |
|
223 iPassiveSnapshotRequested(EFalse), iPassiveBaseDataRequested(EFalse), |
|
224 iPassiveIncDataRequested(EFalse), iActiveSnapshotReceived(EFalse), |
|
225 iActiveBaseDataReceived(EFalse), iActiveIncDataReceived(EFalse), |
|
226 iActiveSnapshotRequested(EFalse), iActiveBaseDataRequested(EFalse), |
|
227 iActiveIncDataRequested(EFalse), iFirstActiveTransaction(ETrue), |
|
228 iDeleteBeforeRestorePerformed(EFalse), iOpInProgress(EFalse) |
|
229 {} |
|
230 |
|
231 public: |
|
232 TDriveNumber iDrive; /*!< Record whether any snapshot data has been received */ |
|
233 TUint8 iPassiveSnapshotReceived; /*!< Record whether any snapshot data has been received */ |
|
234 TUint8 iPassiveBaseDataReceived; /*!< Record whether or not any data has been received */ |
|
235 TUint8 iPassiveIncDataReceived; /*!< Record whether or not any data has been received */ |
|
236 TUint8 iPassiveSnapshotRequested; /*!< Record whether any snapshot data has been requested */ |
|
237 TUint8 iPassiveBaseDataRequested; /*!< Record whether or not any data has been requested */ |
|
238 TUint8 iPassiveIncDataRequested; /*!< Record whether or not any data has been requested */ |
|
239 TUint8 iActiveSnapshotReceived; /*!< Record whether any snapshot data has been received */ |
|
240 TUint8 iActiveBaseDataReceived; /*!< Record whether or not any data has been received */ |
|
241 TUint8 iActiveIncDataReceived; /*!< Record whether or not any data has been received */ |
|
242 TUint8 iActiveSnapshotRequested; /*!< Record whether any snapshot data has been requested */ |
|
243 TUint8 iActiveBaseDataRequested; /*!< Record whether or not any data has been requested */ |
|
244 TUint8 iActiveIncDataRequested; /*!< Record whether or not any data has been requested */ |
|
245 TUint8 iFirstActiveTransaction; /*!< Is this the first of an active transaction sequence */ |
|
246 TUint8 iDeleteBeforeRestorePerformed; /*!< Have we performed the delete before restore */ |
|
247 TUint8 iOpInProgress; /*!< The active data owner hasn't yet completed the op and is waiting a further call */ |
|
248 }; |
|
249 |
|
250 |
|
251 /** |
|
252 This class holds the state of each proxy for a particular drive |
|
253 @internalComponent |
|
254 */ |
|
255 class TProxyStateByDrive |
|
256 { |
|
257 public: |
|
258 TProxyStateByDrive(TDriveNumber aDrive, TInt aProxy) : iDrive(aDrive), iProxy(aProxy), |
|
259 iDataRequested(EFalse), iDataSupplied(EFalse), iOpInProgress(EFalse) |
|
260 {} |
|
261 |
|
262 public: |
|
263 TDriveNumber iDrive; /*!< The drive that this state relates to */ |
|
264 TInt iProxy; /*!< The proxy that this state relates to */ |
|
265 TUint8 iDataRequested; /*!< Data has already been requested from this data owner */ |
|
266 TUint8 iDataSupplied; /*!< Data has already been supplied to this data owner */ |
|
267 TUint8 iOpInProgress; /*!< The proxy hasn't yet completed the op and is waiting a further call */ |
|
268 }; |
|
269 |
|
270 |
|
271 /** Class to store the state of the data owner |
|
272 @internalComponent |
|
273 */ |
|
274 class TDOState |
|
275 { |
|
276 public: |
|
277 TState iState; /*<! The current state of the DOM */ |
|
278 TDriveNumber iDriveNumber; /*<! The drive number for the current request */ |
|
279 TTransferDataType iTransferType; /*<! The transfer type of the current request */ |
|
280 }; |
|
281 |
|
282 |
|
283 /** Class representing the snapshot |
|
284 @internalComponent |
|
285 */ |
|
286 class CSnapshotHolder : public CBase |
|
287 { |
|
288 public: |
|
289 // Constructors |
|
290 static CSnapshotHolder* NewL(); |
|
291 static CSnapshotHolder* NewLC(); |
|
292 ~CSnapshotHolder(); |
|
293 |
|
294 // Members |
|
295 TDriveNumber iDriveNumber; |
|
296 RSnapshots iSnapshots; |
|
297 private: |
|
298 CSnapshotHolder(); |
|
299 }; |
|
300 |
|
301 /** A data owner |
|
302 |
|
303 @internalTechnology |
|
304 */ |
|
305 class CDataOwner : public CBase, public MContentHandler, public MValidationHandler |
|
306 { |
|
307 public: |
|
308 static CDataOwner* NewL(TSecureId aSID, CDataOwnerManager* apDataOwnerManager); |
|
309 static CDataOwner* NewLC(TSecureId aSID, CDataOwnerManager* pDataOwnerManager); |
|
310 ~CDataOwner(); |
|
311 |
|
312 |
|
313 // Methods |
|
314 void AddRegistrationFilesL(const TDesC& aFileName); |
|
315 void ParseFilesL(); |
|
316 void GetExpectedDataSizeL(TTransferDataType aTransferType, TDriveNumber aDriveNumber, TUint& aSize); |
|
317 void GetPublicFileListL(TDriveNumber aDriveNumber, RFileArray& aFiles); |
|
318 void GetRawPublicFileListL(TDriveNumber aDriveNumber, RRestoreFileFilterArray& aRestoreFileFilter); |
|
319 void SupplyDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TDesC8& aBuffer, |
|
320 TBool aLastSection); |
|
321 void RequestDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, TPtr8& aBuffer, |
|
322 TBool& aLastSection); |
|
323 void RestoreCompleteL(); |
|
324 void GetNextPublicFileL(TBool aReset, TDriveNumber aDriveNumber, TEntry& aEntry); |
|
325 |
|
326 // Accessors |
|
327 TSecureId SecureId() const; |
|
328 TDataOwnerStatus ReadyState(); |
|
329 void SetReadyState(TDataOwnerStatus aDataOwnerStatus); |
|
330 TCommonBURSettings CommonSettingsL(); |
|
331 TPassiveBURSettings PassiveSettingsL(); |
|
332 TActiveBURSettings ActiveSettingsL(); |
|
333 void GetDriveListL(TDriveList& aDriveList); |
|
334 void SetBackedUpAsPartial(TBool aPartial); |
|
335 TBool PartialAffectsMe() const; |
|
336 void StartProcessIfNecessaryL(); |
|
337 void BuildDriveStateArrayL(); |
|
338 void DisableSystemData(); |
|
339 TActiveInformation ActiveInformation(); |
|
340 TBool ValidFileL(const TDesC& aFileName); |
|
341 |
|
342 // MContentHandler |
|
343 void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode); |
|
344 void OnEndDocumentL(TInt aErrorCode); |
|
345 void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode); |
|
346 void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); |
|
347 void OnContentL(const TDesC8& aBytes, TInt aErrorCode); |
|
348 void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode); |
|
349 void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
350 void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
351 void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
352 void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode); |
|
353 void OnError(TInt aErrorCode); |
|
354 TAny* GetExtendedInterface(const TInt32 aUid); |
|
355 // MContentHandler |
|
356 |
|
357 private: |
|
358 // Constructors |
|
359 CDataOwner(TSecureId aSID, CDataOwnerManager* apDataOwnerManager); |
|
360 void ConstructL(); |
|
361 |
|
362 // Methods |
|
363 void PrivatePathL(const TDesC& aFileName); |
|
364 void ParseFileL(const TDesC& aFileName); |
|
365 TInt GetDrive(const TDesC& aPath) const; |
|
366 void BuildFileListL(const RSelections& aFileSelection, |
|
367 const TDriveNumber aDriveNumber, |
|
368 const TTransferDataType aTransferType, |
|
369 const TBool aIsPublic, |
|
370 RSnapshots* apSnapshot, |
|
371 RFileArray* apFileEntries, |
|
372 CDesCArray* apFileNames); |
|
373 void AddDBMSFilesL(TDriveNumber aDriveNumber, |
|
374 CDesCArray* apFileNames, |
|
375 RFileArray* apEntries); |
|
376 void ParseDirL(const TDesC& aDirName, |
|
377 const RArray<TPtrC>& aExclude, |
|
378 const TTransferDataType aTransferType, |
|
379 const TBool aIsPublic, |
|
380 RSnapshots* apSnapshots, |
|
381 RFileArray* apFileEntries, |
|
382 CDesCArray* apFileNames); |
|
383 TBool IsExcluded(const TBool aIsPublic, const TDesC& aFileName, const RArray<TPtrC>& aExclude); |
|
384 void IsNewerL(const TDesC& aFileName, const TEntry& aFile, const RSnapshots* aSnapshots, TBool& aNewer); |
|
385 RSnapshots* FindSnapshot(TDriveNumber aDriveNumber); |
|
386 void ResetState(); |
|
387 TDataOwnerStateByDrive& StateByDriveL(TDriveNumber& aDrive); |
|
388 TProxyStateByDrive& ProxyStateByDriveL(TDriveNumber& aDrive, TInt aProxy); |
|
389 void CleanupBeforeRestoreL(TDriveNumber& aDriveNumber); |
|
390 |
|
391 // Supply |
|
392 void SupplyPassiveSnapshotDataL(TDriveNumber aDriveNumber, TDesC8& aBuffer, TBool aLastSection); |
|
393 void SupplyPassiveBaseDataL(TDriveNumber aDriveNumber, TDesC8& aBuffer, TBool aLastSection); |
|
394 |
|
395 // Request |
|
396 void RequestPassiveSnapshotDataL(TDriveNumber aDriveNumber, TPtr8& aBuffer, TBool& aLastSection); |
|
397 void RequestPassiveDataL(TTransferDataType aTransferType, TDriveNumber aDriveNumber, TPtr8& aBuffer, TBool& aLastSection); |
|
398 void ProcessRequestDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, |
|
399 TPtr8& aBuffer, TBool& aLastSection); |
|
400 void ProcessSupplyDataL(TDriveNumber aDriveNumber, TTransferDataType aTransferType, |
|
401 TDesC8& aBuffer, TBool aLastSection); |
|
402 TInt AddProxyToList(TProxyInformation aProxy); |
|
403 |
|
404 |
|
405 // private methods for parsing |
|
406 private: |
|
407 // Element handlers |
|
408 void HandleBackupRegistrationL(const RAttributeArray& aAttributes); |
|
409 void HandlePathL(const TSelectionType aType, const RAttributeArray& aAttributes, const TBool aDir); |
|
410 TInt HandlePassiveBackup(const RAttributeArray& aAttributes); |
|
411 TInt HandlePublicBackup(const RAttributeArray& aAttributes); |
|
412 TInt HandleSystemBackup(const RAttributeArray& aAttributes); |
|
413 TInt HandleCenrepBackup(const RAttributeArray& aAttributes); |
|
414 TInt HandleProxyDataManager(const RAttributeArray& aAttributes); |
|
415 TInt HandleDBMSBackupL(const RAttributeArray& aAttributes); |
|
416 TInt HandleActiveBackupL(const RAttributeArray& aAttributes); |
|
417 TInt HandleRestore(const RAttributeArray& aAttributes); |
|
418 private: |
|
419 // Internal |
|
420 TDOState iState; /*<! The state of the data owner */ |
|
421 TDataOwnerStatus iStatus; /*!< Is the DO ready for operations - only relevant for active */ |
|
422 CDesCArray* iRegistrationFiles; /*<! A list of registration files for this data owner */ |
|
423 TUint8 iFilesParsed; /*<! Have we parsed the registration files */ |
|
424 TUint8 iPrimaryFile; /*<! Have we found a primary file */ |
|
425 TUint8 iBackupAsPartial; /*!< Will this DO be backed up as partial */ |
|
426 |
|
427 // Options |
|
428 TSecureId iSecureId; /*<! The data owners SID */ |
|
429 TPassiveInformation iPassiveInformation; /*<! Passive backup information */ |
|
430 TPublicInformation iPublicInformation; /*<! Public backup information */ |
|
431 TSystemInformation iSystemInformation; /*<! System backup information */ |
|
432 TActiveInformation iActiveInformation; /*<! Active information */ |
|
433 TRestoreInformation iRestoreInformation; /*<! restore information */ |
|
434 RArray<TProxyInformation> iProxyInformationArray; /*!< The various proxies that we support */ |
|
435 TBufC<KMaxPackageNameLength> iName; /*<! The data owners nice name */ |
|
436 RArray<TDataOwnerStateByDrive> iStateByDrive; /*<! Array storing the state of the DO's by drive */ |
|
437 RArray<TProxyStateByDrive> iProxyStateByDrive; /*<! Array storing the state of the proxies for each drive */ |
|
438 RArray<TUid> iDBMSSelections; /*<! Array storing the list of DBMS selections */ |
|
439 |
|
440 // Reader\Writer handlers |
|
441 CBufferFileWriter* iBufferFileWriter; /*<! Handles writing files to the buffer */ |
|
442 CBufferFileReader* iBufferFileReader; /*<! Handles reading files from the buffer */ |
|
443 CBufferSnapshotWriter* iBufferSnapshotWriter; /*<! Handles writing snapshots to the buffer */ |
|
444 CBufferSnapshotReader* iBufferSnapshotReader; /*<! Handles reading snapshots from the buffer */ |
|
445 |
|
446 // Selections |
|
447 RSelections iPassiveSelections; /*<! Passive selections */ |
|
448 RSelections iPublicSelections; /*<! Public selections */ |
|
449 |
|
450 // Snapshots |
|
451 CSnapshotHolder* iTempSnapshotHolder; /*<! Hold a temporary snapshot */ |
|
452 RPointerArray<CSnapshotHolder> iSnapshots; /*<! Stores the snapshots we have been sent */ |
|
453 |
|
454 // Resources |
|
455 CDataOwnerManager* ipDataOwnerManager; /*<! To access resources */ |
|
456 HBufC* iPrivatePath; /*<! The path to the private directory */ |
|
457 |
|
458 /* Simple enumeration: What is our current element? |
|
459 */ |
|
460 enum TCurrentElement {ENoElement = 0, // No element |
|
461 EPassive = 1, // Passive element |
|
462 EPublic = 2 // Public element |
|
463 }; |
|
464 |
|
465 TCurrentElement iCurrentElement; /*<! Current element */ |
|
466 |
|
467 RArray<RDir> iPublicDirStack; /*<! Stack of public directories for enumerating public files */ |
|
468 RPointerArray<HBufC> iPublicDirNameStack; /*<! Directory names corresponding to entries in the above stack */ |
|
469 RArray<TPtrC> iPublicExcludes; /*<! Stores list of excludes while enumerating public files */ |
|
470 TInt iPublicFileIndex; /*<! Index of current element being enumerated in public file list */ |
|
471 TInt iCurrentProxy; // Used to restore the proxy data |
|
472 |
|
473 }; |
|
474 |
|
475 } |
|
476 #endif // __DATAOWNER_H__ |