|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @internalTechnology |
|
18 */ |
|
19 |
|
20 #ifndef BACKUP_H |
|
21 #define BACKUP_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <f32file.h> |
|
25 #include <e32property.h> |
|
26 #include <connect/abclient.h> |
|
27 #include "sessnotf.h" |
|
28 #include "srvrepos_noc.h" |
|
29 #include "rstrepos.h" |
|
30 |
|
31 typedef RPointerArray<CRestoredRepository> RRestoredRepositoriesArray ; |
|
32 |
|
33 using namespace conn ; |
|
34 |
|
35 const TUint KArbitraryNumber = 1024 ; |
|
36 const TUint32 KBackupStreamVersion = 1 ; |
|
37 |
|
38 // Bitfield representing backup stream features present in the |
|
39 // incoming backup stream. |
|
40 enum TBackupExtensions |
|
41 { |
|
42 ENoBackupExtensions = 0x00000000, |
|
43 EDeletedKeysSupported = 0x00000001, |
|
44 EInstalledKeysSupported = 0x00000002 |
|
45 }; |
|
46 |
|
47 // Backup stream extension features supported by this version of central |
|
48 // repository backup/restore - OR together bitwise values defined in |
|
49 // TBackupExtensions to get correct value! |
|
50 const TUint32 KBackupExtensionsSupported = EDeletedKeysSupported | EInstalledKeysSupported; |
|
51 |
|
52 class TRepositoryBackupStreamHeader |
|
53 { |
|
54 public : |
|
55 inline TRepositoryBackupStreamHeader(TStreamId aIndexStreamId) ; |
|
56 inline TRepositoryBackupStreamHeader(); |
|
57 inline void ExternalizeL(RWriteStream& aStream) const; |
|
58 inline void InternalizeL(RReadStream& aStream); |
|
59 inline TUid getUid(); |
|
60 inline TStreamId getIndexStreamId() ; |
|
61 inline TUint32 getVersion(); |
|
62 inline TUint32 getBackupExtensionsSupported(); |
|
63 |
|
64 private : |
|
65 TUid iBackupStreamUid ; |
|
66 TUint32 iBackupStreamVersion ; |
|
67 TStreamId iIndexStreamId ; |
|
68 TUint32 iBackupExtensionsSupported ; |
|
69 |
|
70 // Reserved for future expansion |
|
71 TUint32 iReserved1 ; |
|
72 TUint32 iReserved2 ; |
|
73 TUint32 iReserved3 ; |
|
74 TUint32 iReserved4 ; |
|
75 }; |
|
76 |
|
77 // |
|
78 // Backup stream index class - Used to hold association between a UID (in |
|
79 // our case the UID of a repository) and a stream ID - Can't use CStreamDictionary |
|
80 // because that only lets you retrieve stream IDs by a (previously known) UID rather |
|
81 // than iterate through its contents retrieving UID/StreamID pairs... |
|
82 // |
|
83 |
|
84 class TRepositoryBackupStreamIndexElement |
|
85 { |
|
86 |
|
87 public : |
|
88 inline void Set (TUid aUid, TStreamId aSettingsStream, TStreamId aDeletedSettingsStream, TStreamId aInstalledSettingsStream) ; |
|
89 inline void SetDeletedSettingsStream (TStreamId aDeletedSettingsStream) ; |
|
90 inline void Get (TUid& aUid, TStreamId& aSettingsStreamId, TStreamId& aDeletedSettingsStreamId, TStreamId& aInstalledSettingsStream) ; |
|
91 inline void GetDeletedSettingsStream (TStreamId& aDeletedSettingsStream) ; |
|
92 inline void ExternalizeL(RWriteStream& aStream) const; |
|
93 inline void InternalizeL(RReadStream& aStream, TUint32 aBackupStreamExtensions = ENoBackupExtensions); |
|
94 |
|
95 private: |
|
96 TUid iUid ; |
|
97 TStreamId iSettingsStream ; |
|
98 TStreamId iDeletedSettingsStream ; |
|
99 TStreamId iInstalledSettingsStream ; |
|
100 }; |
|
101 |
|
102 class CRepositoryBackupStreamIndex : public CBase |
|
103 { |
|
104 public: |
|
105 inline static CRepositoryBackupStreamIndex* NewL() ; |
|
106 inline static CRepositoryBackupStreamIndex* NewLC(); |
|
107 inline ~CRepositoryBackupStreamIndex(); |
|
108 inline void Close(void) ; |
|
109 |
|
110 void AddL(TUid aUid, TStreamId aSettingStreamId, TStreamId aDeletedSettingsStreamId, TStreamId aInstalledSettingsStreamId) ; |
|
111 TInt GetNext(TUid& aUid, TStreamId& aSettingsStreamId, TStreamId& aDeletedSettingsStreamId, TStreamId& aInstalledSettingsStreamId) ; |
|
112 inline void Reset(); |
|
113 inline void ExternalizeL(RWriteStream& aStream) const; |
|
114 inline void InternalizeL(RReadStream& aStream, TUint32 aBackupStreamExtensions = ENoBackupExtensions); |
|
115 |
|
116 private: |
|
117 inline CRepositoryBackupStreamIndex(){} ; |
|
118 |
|
119 private: |
|
120 TInt iIndex ; |
|
121 RArray<TRepositoryBackupStreamIndexElement> iStreamIndex ; |
|
122 }; |
|
123 |
|
124 |
|
125 enum TRepositoryBackupState |
|
126 { |
|
127 ENoBackupActivty, |
|
128 EBackupInProgress, |
|
129 ERestoreInProgress |
|
130 }; |
|
131 |
|
132 // |
|
133 // Backup client class. |
|
134 // |
|
135 // Has Active object functionality to monitor the state of the publish and subscribe |
|
136 // flags associated with backup and restore and also implements MActiveBackupDataClient |
|
137 // to perform active backup according to the "proxy data holder" model. |
|
138 // |
|
139 class CRepositoryBackupClient : public CActive, public MActiveBackupDataClient |
|
140 { |
|
141 public: |
|
142 static CRepositoryBackupClient* NewL(RFs& aFs); |
|
143 static CRepositoryBackupClient* NewLC(RFs& aFs); |
|
144 inline static TRepositoryBackupState GetBackupStatus(void) {return iBackupStatus;} ; |
|
145 |
|
146 CRepositoryBackupClient(RFs& aFs); |
|
147 ~CRepositoryBackupClient(); |
|
148 void ConstructL(); |
|
149 void StartL(); |
|
150 void NotifyChange(); |
|
151 |
|
152 // Implementations of virtual functions inherited from MActiveBackupDataClient |
|
153 void AllSnapshotsSuppliedL(); |
|
154 void ReceiveSnapshotDataL(TDriveNumber aDrive, TDesC8& aBuffer, TBool aLastSection); |
|
155 TUint GetExpectedDataSize(TDriveNumber aDrive); |
|
156 void GetSnapshotDataL(TDriveNumber aDrive, TPtr8& aBuffer, TBool& aFinished); |
|
157 void InitialiseGetBackupDataL(TDriveNumber aDrive); |
|
158 void GetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished); |
|
159 |
|
160 void InitialiseGetProxyBackupDataL(TSecureId aSID, TDriveNumber aDrive) ; |
|
161 void InitialiseRestoreProxyBaseDataL(TSecureId aSID, TDriveNumber aDrive) ; |
|
162 |
|
163 void InitialiseRestoreBaseDataL(TDriveNumber aDrive); |
|
164 void RestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished); |
|
165 void InitialiseRestoreIncrementDataL(TDriveNumber aDrive); |
|
166 void RestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished); |
|
167 void RestoreComplete(TDriveNumber aDrive); |
|
168 |
|
169 void TerminateMultiStageOperation(); |
|
170 TUint GetDataChecksum(TDriveNumber aDrive); |
|
171 void CompleteOwnerIdLookupTableL(); |
|
172 |
|
173 private: |
|
174 // Usual active object stuff |
|
175 void RunL() ; |
|
176 void DoCancel() ; |
|
177 TInt RunError(TInt aError) ; |
|
178 |
|
179 void TestBURstatusL(void) ; |
|
180 |
|
181 // Leaving version of RestoreComplete to make it a bit easier |
|
182 // for us to handle cleanup... |
|
183 void RestoreCompleteL(); |
|
184 |
|
185 TInt AddRestoredRepositoryL(TUid aUid); |
|
186 |
|
187 private: |
|
188 enum TBackupDirectoryScan |
|
189 { |
|
190 EScanRom, |
|
191 EScanInstall, |
|
192 EScanPersist |
|
193 }; |
|
194 |
|
195 private: |
|
196 // Used to open a repository for backup and/or restore |
|
197 CServerRepository* iRepository ; |
|
198 |
|
199 CSessionNotifier* iNotifier ; |
|
200 |
|
201 // Used to subscribe to Backup/Restore flag |
|
202 RProperty iBackupRestoreProperty ; |
|
203 |
|
204 // File server session used to get directory listings |
|
205 RFs& iFs; |
|
206 RFile iFile ; |
|
207 |
|
208 // Secure ID being restored |
|
209 TSecureId iSid ; |
|
210 |
|
211 // Active backup client to register with BUR engine |
|
212 CActiveBackupClient* iActiveBackupClient ; |
|
213 |
|
214 TBool iRomScanDone; |
|
215 // Current state (backup in proress, restore in progress, etc, etc, etc) |
|
216 static TRepositoryBackupState iBackupStatus ; |
|
217 |
|
218 // Features supported by Backup Stream |
|
219 TUint32 iBackupExtensionsSupported ; |
|
220 |
|
221 // The list of the restored repositories |
|
222 RRestoredRepositoriesArray iRestoredRepositoriesArray ; |
|
223 }; |
|
224 |
|
225 |
|
226 #include "backup.inl" |
|
227 |
|
228 #endif // BACKUP_H |