1 /* |
|
2 * Copyright (c) 2005 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: CMMCScBkupStateArchiveOpPassiveData implementation |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "CMMCScBkupStateArchiveOpPassiveData.h" |
|
20 |
|
21 // User includes |
|
22 #include "MMCScBkupLogger.h" |
|
23 #include "MMCScBkupSBEUtils.h" |
|
24 #include "CMMCScBkupArchive.h" |
|
25 #include "CMMCScBkupArchiveFooter.h" |
|
26 #include "CMMCScBkupDataOwnerInfo.h" |
|
27 #include "CMMCScBkupDataOwnerCollection.h" |
|
28 #include "CMMCScBkupIndexWithIdentifier.h" |
|
29 #include "MMMCScBkupArchiveDataInterface.h" |
|
30 |
|
31 |
|
32 |
|
33 // ========================= MEMBER FUNCTIONS ================================ |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CMMCScBkupStateArchiveOpPassiveData::CMMCScBkupStateArchiveOpPassiveData() |
|
37 // |
|
38 // C++ constructor. |
|
39 // --------------------------------------------------------------------------- |
|
40 CMMCScBkupStateArchiveOpPassiveData::CMMCScBkupStateArchiveOpPassiveData( MMMCScBkupDriver& aDriver ) |
|
41 : CMMCScBkupStateOpAware( aDriver ), iIndexValueCurrent( -1 ) |
|
42 { |
|
43 __LOG1("CMMCScBkupStateArchiveOpPassiveData::CMMCScBkupStateArchiveOpPassiveData() - 0x%08x", StateId().iUid ); |
|
44 } |
|
45 |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CMMCScBkupStateArchiveOpPassiveData::~CMMCScBkupStateArchiveOpPassiveData() |
|
49 // |
|
50 // Destructor. |
|
51 // --------------------------------------------------------------------------- |
|
52 CMMCScBkupStateArchiveOpPassiveData::~CMMCScBkupStateArchiveOpPassiveData() |
|
53 { |
|
54 Cancel(); |
|
55 // |
|
56 delete iBackupTransferObject; |
|
57 delete iRestoreTransferObject; |
|
58 } |
|
59 |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CMMCScBkupStateArchiveOpPassiveData::NewL() |
|
63 // |
|
64 // |
|
65 // --------------------------------------------------------------------------- |
|
66 CMMCScBkupStateArchiveOpPassiveData* CMMCScBkupStateArchiveOpPassiveData::NewL( MMMCScBkupDriver& aDriver ) |
|
67 { |
|
68 CMMCScBkupStateArchiveOpPassiveData* self = new(ELeave) CMMCScBkupStateArchiveOpPassiveData( aDriver ); |
|
69 return self; |
|
70 } |
|
71 |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CMMCScBkupStateArchiveOpPassiveData::StateId() |
|
75 // |
|
76 // |
|
77 // --------------------------------------------------------------------------- |
|
78 TMMCScBkupStateId CMMCScBkupStateArchiveOpPassiveData::StateId() const |
|
79 { |
|
80 return KMMCScBkupStateIdArchiveOpPassiveData; |
|
81 } |
|
82 |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CMMCScBkupStateArchiveOpPassiveData::NextStateBackupId() |
|
86 // |
|
87 // |
|
88 // --------------------------------------------------------------------------- |
|
89 TMMCScBkupStateId CMMCScBkupStateArchiveOpPassiveData::NextStateBackupId( TBool /*aPartial*/ ) const |
|
90 { |
|
91 return KMMCScBkupStateIdArchiveOpDataOwners; |
|
92 } |
|
93 |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CMMCScBkupStateArchiveOpPassiveData::NextStateRestoreId() |
|
97 // |
|
98 // |
|
99 // --------------------------------------------------------------------------- |
|
100 TMMCScBkupStateId CMMCScBkupStateArchiveOpPassiveData::NextStateRestoreId( TBool /*aPartial*/ ) const |
|
101 { |
|
102 return KMMCScBkupStateIdGetDataOwnerStatuses; |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CMMCScBkupStateArchiveOpPassiveData::PerformStateInitBackupL() |
|
108 // |
|
109 // |
|
110 // --------------------------------------------------------------------------- |
|
111 void CMMCScBkupStateArchiveOpPassiveData::PerformStateInitBackupL( TBool /*aPartial*/ ) |
|
112 { |
|
113 __DEBUG_TESTING_SKIP_BACKUP_PAS_DATA; |
|
114 |
|
115 iBackupTransferObject = CMMCScBkupWriteDataTransferRequest<TTransferDataType>::NewL( |
|
116 Driver(), |
|
117 *this, |
|
118 EMMCScBkupOwnerDataTypePassiveData, |
|
119 ESIDTransferDerivedType, |
|
120 Driver().DrvParamsBase().PassiveTransferType() |
|
121 ); |
|
122 CompleteSelf(); |
|
123 } |
|
124 |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CMMCScBkupStateArchiveOpPassiveData::PerformStateInitRestoreL() |
|
128 // |
|
129 // |
|
130 // --------------------------------------------------------------------------- |
|
131 void CMMCScBkupStateArchiveOpPassiveData::PerformStateInitRestoreL( TBool /*aPartial*/ ) |
|
132 { |
|
133 __DEBUG_TESTING_SKIP_RESTORE_PAS_DATA; |
|
134 |
|
135 iRestoreTransferObject = CMMCScBkupReadDataTransferRequest< TTransferDataType >::NewL( |
|
136 Driver(), |
|
137 EMMCScBkupOwnerDataTypePassiveData, |
|
138 Driver().DrvParamsBase().PassiveTransferType() |
|
139 ); |
|
140 |
|
141 CompleteSelf(); |
|
142 } |
|
143 |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousStateStepBackupL() |
|
147 // |
|
148 // |
|
149 // --------------------------------------------------------------------------- |
|
150 void CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousStateStepBackupL( TBool /*aPartial*/ ) |
|
151 { |
|
152 CMMCScBkupDataOwnerCollection& dataOwners = Driver().DrvDataOwners(); |
|
153 const TInt count = dataOwners.Count(); |
|
154 // |
|
155 while ( ++iIndexValueCurrent < count ) |
|
156 { |
|
157 CMMCScBkupDataOwnerInfo& owner = dataOwners.Owner( iIndexValueCurrent ); |
|
158 // |
|
159 if ( owner.CompletionStatus( EMMCScBkupOwnerDataTypePassiveData ) == EFalse ) |
|
160 { |
|
161 __LOG1("CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousStateStepBackupL() - trying to backup DO 0x%08x", owner.SecureId().iId ); |
|
162 |
|
163 // Request all the passive data (on all supported drives) for this |
|
164 // particular data owner |
|
165 __ASSERT_ALWAYS( iBackupTransferObject->IsActive() == EFalse, User::Invariant() ); |
|
166 // |
|
167 iBackupTransferObject->RequestL( owner, |
|
168 iStatus, |
|
169 Driver().DrvParamsBase().DriveAndOperations() ); |
|
170 SetActive(); |
|
171 break; // while loop |
|
172 } |
|
173 } |
|
174 } |
|
175 |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousStateStepRestoreL() |
|
179 // |
|
180 // |
|
181 // --------------------------------------------------------------------------- |
|
182 void CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousStateStepRestoreL( TBool /*aPartial*/ ) |
|
183 { |
|
184 CMMCScBkupIndexBase& indexBase = Driver().DrvArchive().Footer().IndexByType( EMMCScBkupOwnerDataTypePassiveData ); |
|
185 CMMCScBkupIndexWithIdentifier< TSecureId>& index = static_cast< CMMCScBkupIndexWithIdentifier<TSecureId>& >( indexBase ); |
|
186 const TInt count = index.Count(); |
|
187 // |
|
188 if ( ++iIndexValueCurrent < count ) |
|
189 { |
|
190 const CMMCScBkupIndexEntry<TSecureId>& entry = index.At( iIndexValueCurrent ); |
|
191 const RArray<TMMCScBkupArchiveDriveAndVector>& subEntries = entry.Entries(); |
|
192 |
|
193 // Get the associated data owner |
|
194 CMMCScBkupDataOwnerCollection& dataOwners = Driver().DrvDataOwners(); |
|
195 CMMCScBkupDataOwnerInfo& owner = dataOwners.OwnerL( entry.Identifier() ); |
|
196 |
|
197 if ( owner.CompletionStatus( EMMCScBkupOwnerDataTypePassiveData ) == EFalse ) |
|
198 { |
|
199 __LOG1("CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousStateStepRestoreL() - trying to restore DO 0x%08x", owner.SecureId().iId ); |
|
200 |
|
201 |
|
202 // Request all the registration data (on all supported drives) for this |
|
203 // particular data owner |
|
204 __ASSERT_ALWAYS( iRestoreTransferObject->IsActive() == EFalse, User::Invariant() ); |
|
205 // |
|
206 __LOG1("CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousStateStepRestoreL() - trying to restore PASSIVE DATA for SID: 0x%08x", owner.SecureId().iId ); |
|
207 // |
|
208 iRestoreTransferObject->RequestL( owner, |
|
209 iStatus, |
|
210 subEntries ); |
|
211 SetActive(); |
|
212 } |
|
213 else |
|
214 { |
|
215 CompleteSelf(); |
|
216 } |
|
217 } |
|
218 } |
|
219 |
|
220 |
|
221 // --------------------------------------------------------------------------- |
|
222 // CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousErrorCleanupBackup() |
|
223 // |
|
224 // |
|
225 // --------------------------------------------------------------------------- |
|
226 TBool CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousErrorCleanupBackup( TBool /*aPartial*/, TInt aError ) |
|
227 { |
|
228 (void) aError; |
|
229 __LOG1("CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousErrorCleanupBackup() - **** - error: %d", aError ); |
|
230 |
|
231 // Reset state and move to next item. Treat the current (badly behaving) item |
|
232 // as completed/processed. |
|
233 CMMCScBkupDataOwnerCollection& dataOwners = Driver().DrvDataOwners(); |
|
234 if ( iIndexValueCurrent < dataOwners.Count() ) |
|
235 { |
|
236 CMMCScBkupDataOwnerInfo& owner = dataOwners.Owner( iIndexValueCurrent ); |
|
237 owner.SetCompletionStatus( EMMCScBkupOwnerDataTypePassiveData, ETrue ); |
|
238 |
|
239 __LOGFILE1("CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousErrorCleanupBackup() - **** - PASSIVE data skipped for SID: 0x%08x", owner.SecureId().iId ); |
|
240 } |
|
241 |
|
242 CompleteSelf(); |
|
243 return ETrue; |
|
244 } |
|
245 |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousErrorCleanupRestore() |
|
249 // |
|
250 // |
|
251 // --------------------------------------------------------------------------- |
|
252 TBool CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousErrorCleanupRestore( TBool /*aPartial*/, TInt aError ) |
|
253 { |
|
254 (void) aError; |
|
255 __LOGFILE1("CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousErrorCleanupRestore() - **** - error: %d", aError ); |
|
256 |
|
257 CompleteSelf(); |
|
258 return ETrue; |
|
259 } |
|
260 |
|
261 |
|
262 // --------------------------------------------------------------------------- |
|
263 // CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousCancellation() |
|
264 // |
|
265 // |
|
266 // --------------------------------------------------------------------------- |
|
267 void CMMCScBkupStateArchiveOpPassiveData::PerformAsynchronousCancellation() |
|
268 { |
|
269 if (iBackupTransferObject) |
|
270 { |
|
271 iBackupTransferObject->Cancel(); |
|
272 } |
|
273 if (iRestoreTransferObject) |
|
274 { |
|
275 iRestoreTransferObject->Cancel(); |
|
276 } |
|
277 } |
|
278 |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // CMMCScBkupStateArchiveOpPassiveData::PerformLastRightsBackupL() |
|
282 // |
|
283 // |
|
284 // --------------------------------------------------------------------------- |
|
285 void CMMCScBkupStateArchiveOpPassiveData::PerformLastRightsBackupL( TBool /*aPartial*/ ) |
|
286 { |
|
287 CMMCScBkupIndexBase& index = Driver().DrvArchive().Footer().IndexByType(EMMCScBkupOwnerDataTypePassiveData); |
|
288 index.StoreL(Driver()); |
|
289 } |
|
290 |
|
291 |
|
292 // --------------------------------------------------------------------------- |
|
293 // CMMCScBkupStateArchiveOpPassiveData::AddIndexRecordL() |
|
294 // |
|
295 // |
|
296 // --------------------------------------------------------------------------- |
|
297 void CMMCScBkupStateArchiveOpPassiveData::AddIndexRecordL( CMMCScBkupArchiveFooter& aFooter, CMMCScBkupDataOwnerInfo& aDataOwner, const TMMCScBkupArchiveVector& aInfo, TDriveNumber aDrive ) |
|
298 { |
|
299 CMMCScBkupIndexBase& indexBase = aFooter.IndexByType( EMMCScBkupOwnerDataTypePassiveData ); |
|
300 CMMCScBkupIndexWithIdentifier< TSecureId>& index = static_cast< CMMCScBkupIndexWithIdentifier< TSecureId>& >( indexBase ); |
|
301 // |
|
302 index.AddIndexRecordL( aInfo, aDrive, aDataOwner.SecureId() ); |
|
303 __LOG3("CMMCScBkupStateArchiveOpPassiveData::AddIndexRecordL() - offset: %6d, length: %6d, secureId: 0x%08x", aInfo.Offset(), aInfo.Length(), aDataOwner.SecureId().iId ); |
|
304 } |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|