|
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 CPackageDataTransfer |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 */ |
|
25 |
|
26 #ifndef __PACKAGEDATATRANSFER_H__ |
|
27 #define __PACKAGEDATATRANSFER_H__ |
|
28 |
|
29 // System |
|
30 #include <e32base.h> |
|
31 #include <connect/sbtypes.h> |
|
32 #include <swi/sisregistryentry.h> |
|
33 #include <swi/sisregistrysession.h> |
|
34 #include <swi/backuprestore.h> |
|
35 |
|
36 // MContentHandler mix in class |
|
37 #include <xml/contenthandler.h> |
|
38 |
|
39 #include "sbebufferhandler.h" |
|
40 #include "sbedataownermanager.h" |
|
41 #include "sbedataowner.h" |
|
42 |
|
43 namespace conn |
|
44 { |
|
45 using namespace Swi; |
|
46 // Forwards |
|
47 class CSnapshotHolder; |
|
48 |
|
49 /** Class to store the state of the data owner |
|
50 @internalComponent |
|
51 */ |
|
52 class TPDState |
|
53 { |
|
54 public: |
|
55 TState iState; /*<! The current state of the DOM */ |
|
56 TDriveNumber iDriveNumber; /*<! The drive number for the current request */ |
|
57 TPackageDataType iTransferType; /*<! The transfer type of the current request */ |
|
58 }; |
|
59 |
|
60 /** A Package data owner |
|
61 |
|
62 @internalComponent |
|
63 */ |
|
64 class CPackageDataTransfer : public CBase, public MContentHandler |
|
65 { |
|
66 public: |
|
67 static CPackageDataTransfer* NewL(TUid aPid, CDataOwnerManager* aDOM); |
|
68 static CPackageDataTransfer* NewLC(TUid aPid, CDataOwnerManager* aDOM); |
|
69 ~CPackageDataTransfer(); |
|
70 |
|
71 static TInt Compare(const CPackageDataTransfer& aFirst, const CPackageDataTransfer& aSecond); |
|
72 static TBool Match(const CPackageDataTransfer& aFirst, const CPackageDataTransfer& aSecond); |
|
73 |
|
74 void GetExpectedDataSizeL(TPackageDataType aTransferType, TDriveNumber aDriveNumber, TUint& aSize); |
|
75 void SupplyDataL(TDriveNumber aDriveNumber, TPackageDataType aTransferType, TDesC8& aBuffer, |
|
76 TBool aLastSection); |
|
77 void RequestDataL(TDriveNumber aDriveNumber, TPackageDataType aTransferType, TPtr8& aBuffer, |
|
78 TBool& aLastSection); |
|
79 TUid PackageId() const; |
|
80 TCommonBURSettings CommonSettingsL(); |
|
81 TPassiveBURSettings PassiveSettingsL(); |
|
82 TActiveBURSettings ActiveSettingsL(); |
|
83 void GetDriveListL(TDriveList& aDriveList); |
|
84 void ParseL(); |
|
85 void SetRegistrationFileL(const TDesC& aFileName); |
|
86 |
|
87 void GetPublicFileListL(TDriveNumber aDriveNumber, RFileArray& aFiles); |
|
88 void GetRawPublicFileListL(TDriveNumber aDriveNumber, RRestoreFileFilterArray& aRestoreFileFilter); |
|
89 |
|
90 // MContentHandler |
|
91 void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode); |
|
92 void OnEndDocumentL(TInt aErrorCode); |
|
93 void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode); |
|
94 void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); |
|
95 void OnContentL(const TDesC8& aBytes, TInt aErrorCode); |
|
96 void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode); |
|
97 void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
98 void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
99 void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
100 void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode); |
|
101 void OnError(TInt aErrorCode); |
|
102 TAny* GetExtendedInterface(const TInt32 aUid); |
|
103 // MContentHandler |
|
104 |
|
105 |
|
106 private: |
|
107 CPackageDataTransfer(TUid aPid, CDataOwnerManager* aDOM); |
|
108 void ConstructL(); |
|
109 |
|
110 void BuildPackageFileList(); |
|
111 void WriteData(TAny* aItem, TPtr8& aBuffer, TInt aSize); |
|
112 void ReadData(TAny* aItem, const TDesC8& aBuffer, TInt aSize); |
|
113 void DoSupplyDataL(TDriveNumber aDriveNumber, const TDesC8& aBuffer, TBool aLastSection); |
|
114 void SupplySnapshotL(TDriveNumber aDriveNumber, const TDesC8& aBuffer, TBool aLastSection); |
|
115 void DoRequestDataL(TDriveNumber aDriveNumber, TPtr8& aBuffer, TBool& aLastSection); |
|
116 void RequestSnapshotL(TDriveNumber aDriveNumber, TPtr8& aBuffer, TBool& aLastSection); |
|
117 void SupplyFileDataL( const TDesC8& aBuffer, TBool aLastSection); |
|
118 void Cleanup(); |
|
119 TBool IsDataOnDrive(TDriveNumber aDrive); |
|
120 |
|
121 void ParseDirL(const TDesC& aDirName, const RArray<TPtrC>& aExclude, RFileArray& apFileEntries); |
|
122 TBool IsExcluded(const TBool aIsPublic, const TDesC& aFileName, const RArray<TPtrC>& aExclude); |
|
123 |
|
124 // Element handlers |
|
125 void HandleBackupRegistrationL(const RAttributeArray& aAttributes); |
|
126 void HandlePathL(const TSelectionType aType, const RAttributeArray& aAttributes, const TBool aDir); |
|
127 |
|
128 TInt HandlePublicBackup(const RAttributeArray& aAttributes); |
|
129 TInt HandleSystemBackup(const RAttributeArray& aAttributes); |
|
130 |
|
131 private: |
|
132 TUint8 iGotFileName; /*<! Have we got the filename */ |
|
133 TUint8 iFixedHeaderRead; /*<! Have we got the header information */ |
|
134 TUint8 iFileNameRead; /*<! Is the filename read */ |
|
135 RFile iFileHandle; /*<! The file handle */ |
|
136 TUint8 iFileOpen; /*<! Is the file open */ |
|
137 TFileFixedHeader iFixedHeader; /*<! The fixed header */ |
|
138 HBufC* iFileName; /*<! The file name */ |
|
139 HBufC* iTempFileName; /*<! A tempory filename */ |
|
140 TPDState iState; /*<! The state of the object */ |
|
141 RFs iFs; /*<! File system handle to use */ |
|
142 CBufferSnapshotReader* iBufferSnapshotReader; /*<! Handles writing snapshots to the buffer */ |
|
143 CBufferFileWriter* iBufferFileWriter; /*<! Handles reading files from the buffer */ |
|
144 CBufferSnapshotWriter* iBufferSnapshotWriter; /*<! Handles reading snapshots from the buffer */ |
|
145 TUid iPackageID; /*<! The package id */ |
|
146 RRestoreSession iSWIRestore; /*<! Handle to software restore */ |
|
147 RBackupSession iSWIBackup; /*<! Handle to backup session */ |
|
148 |
|
149 // Snapshots |
|
150 CSnapshotHolder* iSnapshot; /*<! Holds a tempory snapshot */ |
|
151 TDriveList iDriveList; /*<! Drives on which pages exists */ |
|
152 RPointerArray<HBufC> iFiles; /*<! System files */ |
|
153 HBufC8* iMetaData; /*<! Meta data for a package */ |
|
154 TPublicInformation iPublicInformation; /*<! Public backup information */ |
|
155 TSystemInformation iSystemInformation; /*<! System backup information */ |
|
156 |
|
157 ///////// FOR Parsing //////////////// |
|
158 |
|
159 /* Simple enumeration: What is our current element? |
|
160 */ |
|
161 enum TCurrentElement {ENoElement = 0, // No element |
|
162 EPassive = 1, // Passive element |
|
163 EPublic = 2 // Public element |
|
164 }; |
|
165 |
|
166 TCurrentElement iCurrentElement; /*<! Current element */ |
|
167 |
|
168 RSelections iPublicSelections; /*<! Public selections */ |
|
169 HBufC* iRegistrationFile; /*<! Path to registration file */ |
|
170 CDataOwnerManager* ipDataOwnerManager; /*<! To access resources */ |
|
171 TUint8 iRestored; /*<! Used for speed optimization if we already restored this package */ |
|
172 TUint iBytesRead; /*<! Number of bytes read */ |
|
173 TInt iMetaDataSize; /*<! Meta Data Size */ |
|
174 TInt iMetaDataLeft; /*<! Meta Data Size left to write */ |
|
175 }; |
|
176 } // namespace conn |
|
177 |
|
178 |
|
179 |
|
180 #endif __PACKAGEDATATRANSFER_H__ |