|
1 /* |
|
2 * Copyright (c) 2010 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 the License "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: Active callback for Backup/Restore observer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <bautils.h> |
|
20 |
|
21 #include "hsbackuprestoreactivecallback.h" |
|
22 #include "hsbackuprestoreobserver.h" |
|
23 |
|
24 /*! |
|
25 \class CHsBURActiveCallback |
|
26 \ingroup group_hsdomainmodel |
|
27 \brief B&R active callback. |
|
28 Home screen active callback in backup/restore. |
|
29 */ |
|
30 |
|
31 /*! |
|
32 Constructor. |
|
33 \a observer Backup restore observer |
|
34 */ |
|
35 CHsBURActiveCallback* CHsBURActiveCallback::NewL(HsBackupRestoreObserver* observer) |
|
36 { |
|
37 CHsBURActiveCallback* self = |
|
38 new( ELeave ) CHsBURActiveCallback(observer); |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop( self ); |
|
42 |
|
43 return self; |
|
44 } |
|
45 |
|
46 /*! |
|
47 Destructor. |
|
48 */ |
|
49 CHsBURActiveCallback::~CHsBURActiveCallback() |
|
50 { |
|
51 } |
|
52 |
|
53 /*! |
|
54 This method informs the active backup data client that all |
|
55 snapshots have been supplied. If the client has not |
|
56 received a snapshot then it should perform a base backup. |
|
57 Inform that all data has been backed up or restored. |
|
58 */ |
|
59 void CHsBURActiveCallback::AllSnapshotsSuppliedL() |
|
60 { |
|
61 // No implementation needed. Must not leave |
|
62 } |
|
63 |
|
64 /*! |
|
65 This method receives all or part of a snapshot of data to allow |
|
66 calculation of an incremental backup. The snapshot is one that |
|
67 was previously supplied by the data owner. The snapshot data |
|
68 should be read from the location supplied. The snapshot data may |
|
69 be larger than the location supplied in which case the routine |
|
70 will be called repeatedly until all data has been supplied. |
|
71 |
|
72 Snapshot data will also be supplied as part of a restore operation |
|
73 |
|
74 @param aDrive the drive being backed up |
|
75 @param aBuffer a pointer to the base of the location from whence |
|
76 data can be copied. |
|
77 @param aLastSection ETrue if this is the last section of snapshot |
|
78 data, else EFalse. |
|
79 |
|
80 Not supported. |
|
81 */ |
|
82 void CHsBURActiveCallback::ReceiveSnapshotDataL( |
|
83 TDriveNumber /*aDrive*/, TDesC8& /*aBuffer*/, TBool /*aLastSection*/) |
|
84 { |
|
85 // No implementation needed |
|
86 User::Leave( KErrNotSupported ); |
|
87 } |
|
88 |
|
89 /*! |
|
90 This method returns the expected size of backup data that will be |
|
91 supplied. If an incremental backup is underway then this method |
|
92 then this method will not be called until after |
|
93 ReceiveSnapshotDataL(). The size data will be used for the purpose |
|
94 of tracking progess during a backup. If it is inaccurate then the |
|
95 user may see irregular progress but the actual backup data will |
|
96 not be affected so it is acceptable to return an estimated value. |
|
97 |
|
98 @param aDrive the drive being backed up. |
|
99 @return the size of the data that will be returned |
|
100 |
|
101 Make a guess about data size. |
|
102 */ |
|
103 TUint CHsBURActiveCallback::GetExpectedDataSize( |
|
104 TDriveNumber /*aDrive*/) |
|
105 { |
|
106 // No implementation needed |
|
107 return 0; |
|
108 } |
|
109 |
|
110 /*! |
|
111 This method returns a snapshot of data to accompany a backup. The |
|
112 snapshot is expected to contain details on files / data being |
|
113 backed up. The format of the snapshot is only meaningful to the |
|
114 data owner. The snapshot will be supplied if the data owner is |
|
115 asked for an incremental backup and for a restore operation. The |
|
116 snapshot data should be copied to the location supplied. |
|
117 |
|
118 The snapshot data may be larger than the location supplied in |
|
119 which case the routine will be called repeatedly until all data |
|
120 has been retrieved. |
|
121 |
|
122 @param aDrive the drive being backed up |
|
123 @param aBuffer a pointer to the base of the location where data |
|
124 can be copied. |
|
125 @param aFinished on return ETrue if all data has been returned |
|
126 for this drive, else EFalse. |
|
127 |
|
128 Not supported. |
|
129 */ |
|
130 void CHsBURActiveCallback::GetSnapshotDataL( |
|
131 TDriveNumber /*aDrive*/, TPtr8& /*aBuffer*/, TBool& /*aFinished*/) |
|
132 { |
|
133 // No implementation needed |
|
134 User::Leave( KErrNotSupported ); |
|
135 } |
|
136 |
|
137 /*! |
|
138 This method prepares the implementor to return backup data. It |
|
139 will be followed by a sequence of calls to request the actual |
|
140 data. |
|
141 |
|
142 @param aDrive the drive being backed up. |
|
143 |
|
144 Initialize for backup. |
|
145 */ |
|
146 void CHsBURActiveCallback::InitialiseGetBackupDataL( |
|
147 TDriveNumber /*aDrive*/) |
|
148 { |
|
149 iObserver->backupRestoreStarted(); |
|
150 } |
|
151 |
|
152 /*! |
|
153 This method requests a section of backup data. |
|
154 InitialiseGetBackupDataL() will have been called previously to |
|
155 specify the drive concerned. The data returned may be base or |
|
156 incremental depending on the type of backup and the capability of |
|
157 the data owner. |
|
158 |
|
159 @param aBuffer a pointer to the base of the location where data |
|
160 can be copied. |
|
161 @param aFinished on return ETrue if all data has been returned |
|
162 for this drive, else EFalse. |
|
163 */ |
|
164 void CHsBURActiveCallback::GetBackupDataSectionL( |
|
165 TPtr8& /*aBuffer*/, TBool& aFinished) |
|
166 { |
|
167 // No data for active backup |
|
168 aFinished = ETrue; |
|
169 } |
|
170 |
|
171 /*! |
|
172 This method prepares the implementor to receive base restore data |
|
173 for a drive. It will be followed by a sequence of calls to supply |
|
174 the actual data. |
|
175 |
|
176 @param aDrive the drive being restored. |
|
177 |
|
178 Initialize restore. |
|
179 */ |
|
180 void CHsBURActiveCallback::InitialiseRestoreBaseDataL( |
|
181 TDriveNumber /*aDrive*/ ) |
|
182 { |
|
183 // No implementation needed |
|
184 User::Leave( KErrNotSupported ); |
|
185 } |
|
186 |
|
187 /*! |
|
188 This method receives a section of base restore data. |
|
189 InitialiseRestoreBaseDataL() will have been called previously to |
|
190 specify the drive concerned. |
|
191 |
|
192 @param aBuffer a pointer to the base of the location whence data |
|
193 can be read. |
|
194 @param aFinished ETrue if all data has been returned for this |
|
195 drive, else EFalse. |
|
196 |
|
197 Run state machine for restore. Receive stream from BUR engine and turn it |
|
198 to file(s). |
|
199 */ |
|
200 void CHsBURActiveCallback::RestoreBaseDataSectionL( |
|
201 TDesC8& /*aBuffer*/, TBool /*aFinished*/ ) |
|
202 { |
|
203 // No implementation needed |
|
204 User::Leave( KErrNotSupported ); |
|
205 } |
|
206 |
|
207 /*! |
|
208 This method prepares the implementor to receive incremental |
|
209 restore data for a drive. It will be followed by a sequence |
|
210 of calls to supply the actual data. If multiple increments |
|
211 are supplied then this methid will be called before each increment |
|
212 |
|
213 @param aDrive the drive being restored. |
|
214 |
|
215 Not supported. |
|
216 */ |
|
217 void CHsBURActiveCallback::InitialiseRestoreIncrementDataL( |
|
218 TDriveNumber /*aDrive*/) |
|
219 { |
|
220 // No implementation needed |
|
221 User::Leave( KErrNotSupported ); |
|
222 } |
|
223 |
|
224 /*! |
|
225 This method receives a section of increment restore data. |
|
226 InitialiseRestoreIncrementDataL() will have been called |
|
227 previously to specify the drive concerned. |
|
228 |
|
229 @param aBuffer a pointer to the base of the location whence data |
|
230 can be read. |
|
231 @param aFinished ETrue if all data has been returned for this |
|
232 increment, else EFalse. |
|
233 |
|
234 Not supported. |
|
235 */ |
|
236 void CHsBURActiveCallback::RestoreIncrementDataSectionL( |
|
237 TDesC8& /*aBuffer*/, TBool /*aFinished*/) |
|
238 { |
|
239 // No implementation needed |
|
240 User::Leave( KErrNotSupported ); |
|
241 } |
|
242 |
|
243 /*! |
|
244 This method is called when all data to be restored has been |
|
245 supplied. |
|
246 |
|
247 @param aDrive the drive being restored. |
|
248 |
|
249 Called when restore is complete - sets data back to initial state. |
|
250 */ |
|
251 void CHsBURActiveCallback::RestoreComplete(TDriveNumber /*aDrive*/) |
|
252 { |
|
253 // No implementation needed |
|
254 } |
|
255 |
|
256 /*! |
|
257 This method is called if copying of data is terminated prematurely |
|
258 to allow the implementor to tidy up. The same method applies to |
|
259 all types of data and to backup and restore. |
|
260 Tidy up when operation is over. |
|
261 */ |
|
262 void CHsBURActiveCallback::TerminateMultiStageOperation() |
|
263 { |
|
264 // No implementation needed |
|
265 } |
|
266 |
|
267 /*! |
|
268 Gets a 32-bit checksum for its private data. |
|
269 This routine is for test purposes. It must be implemented but an |
|
270 invariant checksum value can be provided. Some tests may cause |
|
271 checksum values to be compared. |
|
272 |
|
273 @param aDrive the drive containing data being checksummed |
|
274 @return the 32-bit checksum |
|
275 */ |
|
276 TUint CHsBURActiveCallback::GetDataChecksum(TDriveNumber /*aDrive*/) |
|
277 { |
|
278 // No implementation needed |
|
279 return 0; |
|
280 } |
|
281 |
|
282 /*! |
|
283 C++ constructor. |
|
284 */ |
|
285 CHsBURActiveCallback::CHsBURActiveCallback(HsBackupRestoreObserver* observer) |
|
286 { |
|
287 iObserver = observer; |
|
288 } |
|
289 |
|
290 /*! |
|
291 2nd phase constructor. |
|
292 */ |
|
293 void CHsBURActiveCallback::ConstructL() |
|
294 { |
|
295 } |
|
296 |
|
297 // End of file |