1 /* |
|
2 * Copyright (c) 2005-2008 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: CMMCScBkupEngineImpl implementation |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "CMMCScBkupEngineImpl.h" |
|
20 |
|
21 // User includes |
|
22 #include "MMCScBkupLogger.h" |
|
23 #include "CMMCScBkupState.h" |
|
24 #include "MMCScBkupSBEUtils.h" |
|
25 #include "CMMCScBkupArchive.h" |
|
26 #include "MMCScBkupOperations.h" |
|
27 #include "MMCScBkupArchiveUtils.h" |
|
28 #include "CMMCScBkupStateFactory.h" |
|
29 #include "MMCScBkupPhoneModelUtils.h" |
|
30 #include "MMMCScBkupEngineObserver.h" |
|
31 #include "CMMCScBkupFileListCollection.h" |
|
32 #include "CMMCScBkupDataOwnerCollection.h" |
|
33 #include "CMMCScBkupOperationParameters.h" |
|
34 #include "CMMCScBkupArchiveInfo.h" |
|
35 #include "BkupEngine.hrh" |
|
36 #include <pathinfo.h> |
|
37 |
|
38 // ========================= MEMBER FUNCTIONS ================================ |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CMMCScBkupEngineImpl::CMMCScBkupEngineImpl() |
|
42 // |
|
43 // C++ constructor. |
|
44 // --------------------------------------------------------------------------- |
|
45 CMMCScBkupEngineImpl::CMMCScBkupEngineImpl( RFs& aFsSession ) |
|
46 : CActive( CActive::EPriorityIdle ), |
|
47 iFsSession(aFsSession), |
|
48 iCurrentArchive(0), |
|
49 iTotalProgress(0), |
|
50 iActiveDataProcessingOngoing(EFalse) |
|
51 { |
|
52 CActiveScheduler::Add(this); |
|
53 } |
|
54 |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CMMCScBkupEngineImpl::~CMMCScBkupEngineImpl() |
|
58 // |
|
59 // Destructor. |
|
60 // --------------------------------------------------------------------------- |
|
61 CMMCScBkupEngineImpl::~CMMCScBkupEngineImpl() |
|
62 { |
|
63 Cancel(); |
|
64 // |
|
65 TRAP_IGNORE(CleanupL()); |
|
66 |
|
67 iArchives.Close(); |
|
68 iDataOwners.Close(); |
|
69 iFileLists.Close(); |
|
70 delete iSBEClient; |
|
71 } |
|
72 |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CMMCScBkupEngineImpl::ConstructL() |
|
76 // |
|
77 // Second phase constructor |
|
78 // --------------------------------------------------------------------------- |
|
79 void CMMCScBkupEngineImpl::ConstructL() |
|
80 { |
|
81 __LOG("CMMCScBkupEngineImpl::ConstructL() - START"); |
|
82 |
|
83 #ifdef MAKE_SBE_LOGGING_DIRECTORY |
|
84 _LIT( KSBELoggingDir, "C:\\Logs\\connect\\" ); |
|
85 iFsSession.MkDirAll( KSBELoggingDir ); |
|
86 #endif |
|
87 #ifdef MAKE_MMCSCBKUP_LOGGING_DIRECTORY |
|
88 iFsSession.MkDirAll( KMMCScBkupLoggingFullPath ); |
|
89 #endif |
|
90 |
|
91 __LOG("CMMCScBkupEngineImpl::ConstructL() - END"); |
|
92 } |
|
93 |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CMMCScBkupEngineImpl::NewL() |
|
97 // |
|
98 // Static constructor |
|
99 // --------------------------------------------------------------------------- |
|
100 CMMCScBkupEngineImpl* CMMCScBkupEngineImpl::NewL( RFs& aFsSession ) |
|
101 { |
|
102 CMMCScBkupEngineImpl* self = new(ELeave) CMMCScBkupEngineImpl( aFsSession ); |
|
103 CleanupStack::PushL( self ); |
|
104 self->ConstructL(); |
|
105 CleanupStack::Pop( self ); |
|
106 return self; |
|
107 } |
|
108 |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CMMCScBkupEngineImpl::StartOperationL() |
|
112 // |
|
113 // |
|
114 // --------------------------------------------------------------------------- |
|
115 void CMMCScBkupEngineImpl::StartOperationL(TMMCScBkupOperationType aOperation, MMMCScBkupEngineObserver& aObserver, CMMCScBkupOpParamsBase* aParams) |
|
116 { |
|
117 __ASSERT_DEBUG(DrvOperation() == EMMCScBkupOperationTypeIdle, User::Invariant()); // |
|
118 |
|
119 // Setup our observer - we will report progress via this interface |
|
120 iObserver = &aObserver; |
|
121 |
|
122 // Take ownership of the parameters immediately |
|
123 SetParameters(aParams); |
|
124 |
|
125 if(!iSBEClient) |
|
126 { |
|
127 __LOG("CMMCScBkupEngineImpl::ConstructL() - creating SBE client..."); |
|
128 iSBEClient = CSBEClient::NewL(); |
|
129 } |
|
130 |
|
131 #if defined(__MMCSCBKUPLOGGING_ENABLED__) |
|
132 // Create a logging directory for logging purposes and empty contents |
|
133 // in order to have the log only from last backup or restore operation |
|
134 CFileMan* fileMan = CFileMan::NewL( iFsSession ); |
|
135 CleanupStack::PushL( fileMan ); |
|
136 TParse* path = new(ELeave) TParse(); |
|
137 |
|
138 CleanupStack::PushL(path); |
|
139 path->Set(KMMCScBkupLoggingFullPathAndName, NULL, NULL); |
|
140 fileMan->Delete( path->Path(), CFileMan::ERecurse ); // Ignore error |
|
141 iFsSession.MkDirAll( path->Path() ); |
|
142 |
|
143 CleanupStack::PopAndDestroy(2, fileMan ); |
|
144 #endif |
|
145 |
|
146 // Prepare supporting objects |
|
147 PrepareObjectsL(); |
|
148 |
|
149 // Work out what to do... |
|
150 CreateFactoryL( aOperation ); |
|
151 // |
|
152 switch(aOperation) |
|
153 { |
|
154 case EMMCScBkupOperationTypeIdle: |
|
155 __ASSERT_ALWAYS(EFalse, User::Invariant()); |
|
156 break; |
|
157 case EMMCScBkupOperationTypeFullBackup: |
|
158 case EMMCScBkupOperationTypePartialBackup: |
|
159 PrepareForBackupL( DrvOperation() == EMMCScBkupOperationTypePartialBackup ); |
|
160 break; |
|
161 case EMMCScBkupOperationTypeFullRestore: |
|
162 case EMMCScBkupOperationTypePartialRestore: |
|
163 PrepareForRestoreL( DrvOperation() == EMMCScBkupOperationTypePartialRestore ); |
|
164 break; |
|
165 } |
|
166 |
|
167 // Do this last, after everything that can leave has been executed |
|
168 iOperationType = aOperation; |
|
169 |
|
170 // Notify the observer we're starting up |
|
171 NotifyObserver(MMMCScBkupEngineObserver::ECommonOperationStarting); |
|
172 } |
|
173 |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CMMCScBkupEngineImpl::ValidArchiveForRestoreL() |
|
177 // |
|
178 // |
|
179 // --------------------------------------------------------------------------- |
|
180 TBool CMMCScBkupEngineImpl::ValidArchiveForRestoreL( const TDesC& aFileName ) |
|
181 { |
|
182 const TBool valid = CMMCScBkupArchive::ValidArchiveForRestoreL( iFsSession, aFileName ); |
|
183 return valid; |
|
184 } |
|
185 |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // CMMCScBkupEngineImpl::TotalOperationSizeL() |
|
189 // |
|
190 // |
|
191 // --------------------------------------------------------------------------- |
|
192 TInt64 CMMCScBkupEngineImpl::TotalOperationSizeL() const |
|
193 { |
|
194 const TInt64 size = iDataOwners[iCurrentArchive]->TotalOperationalSizeL(); |
|
195 return size; |
|
196 } |
|
197 |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // CMMCScBkupEngineImpl::RebootRequired() |
|
201 // |
|
202 // NOTE: This method is not used in S60 3.x - Sysap handles the reboot |
|
203 // --------------------------------------------------------------------------- |
|
204 TBool CMMCScBkupEngineImpl::RebootRequired() const |
|
205 { |
|
206 // Criteria for a reboot are: |
|
207 // |
|
208 // 1) One or more data owners indicate that a reboot is necessary |
|
209 // via their backup_registration.xml files. |
|
210 // |
|
211 // 2) The current operation is some form of restore (partial or full). |
|
212 |
|
213 const TMMCScBkupOperationType currentOp = DrvOperation(); |
|
214 __LOG1("CMMCScBkupEngineImpl::RebootRequired() - operation type is: %d", currentOp); |
|
215 |
|
216 TBool singleDataOwnerNeedsReboot = EFalse; |
|
217 |
|
218 for(TInt i = 0; i < iDataOwners.Count(); i++) |
|
219 { |
|
220 singleDataOwnerNeedsReboot |= iDataOwners[i]->RebootRequired(); |
|
221 } |
|
222 |
|
223 __LOG1("CMMCScBkupEngineImpl::RebootRequired() - D.O requires reboot?: %d", singleDataOwnerNeedsReboot); |
|
224 |
|
225 const TBool rebootRequired = singleDataOwnerNeedsReboot && |
|
226 ( currentOp == EMMCScBkupOperationTypeFullRestore || |
|
227 currentOp == EMMCScBkupOperationTypePartialRestore ); |
|
228 __LOG1("CMMCScBkupEngineImpl::RebootRequired() - final rebootRequired value: %d", rebootRequired); |
|
229 |
|
230 // We return the value to the caller - the UI will display appropriate |
|
231 // UI dialogs and reset the machine as appropriate. |
|
232 return rebootRequired; |
|
233 } |
|
234 |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // CMMCScBkupEngineImpl::DrvADI() |
|
238 // |
|
239 // |
|
240 // --------------------------------------------------------------------------- |
|
241 MMMCScBkupArchiveDataInterface& CMMCScBkupEngineImpl::DrvADI() const |
|
242 { |
|
243 return iArchives[iCurrentArchive]->ADI(); |
|
244 } |
|
245 |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // CMMCScBkupEngineImpl::DrvArchive() |
|
249 // |
|
250 // |
|
251 // --------------------------------------------------------------------------- |
|
252 CMMCScBkupArchive& CMMCScBkupEngineImpl::DrvArchive() const |
|
253 { |
|
254 __ASSERT_ALWAYS(iCurrentArchive < iArchives.Count(), User::Invariant()); |
|
255 |
|
256 return *iArchives[iCurrentArchive]; |
|
257 } |
|
258 |
|
259 |
|
260 // --------------------------------------------------------------------------- |
|
261 // CMMCScBkupEngineImpl::DrvSecureBackupClient() |
|
262 // |
|
263 // |
|
264 // --------------------------------------------------------------------------- |
|
265 CSBEClient& CMMCScBkupEngineImpl::DrvSecureBackupClient() const |
|
266 { |
|
267 return *iSBEClient; |
|
268 } |
|
269 |
|
270 |
|
271 // --------------------------------------------------------------------------- |
|
272 // CMMCScBkupEngineImpl::DrvOperation() |
|
273 // |
|
274 // |
|
275 // --------------------------------------------------------------------------- |
|
276 TMMCScBkupOperationType CMMCScBkupEngineImpl::DrvOperation() const |
|
277 { |
|
278 return iOperationType; |
|
279 } |
|
280 |
|
281 |
|
282 // --------------------------------------------------------------------------- |
|
283 // CMMCScBkupEngineImpl::DrvParamsBase() |
|
284 // |
|
285 // |
|
286 // --------------------------------------------------------------------------- |
|
287 CMMCScBkupOpParamsBase& CMMCScBkupEngineImpl::DrvParamsBase() const |
|
288 { |
|
289 return *iParameters; |
|
290 } |
|
291 |
|
292 |
|
293 // --------------------------------------------------------------------------- |
|
294 // CMMCScBkupEngineImpl::DrvDataOwners() |
|
295 // |
|
296 // |
|
297 // --------------------------------------------------------------------------- |
|
298 CMMCScBkupDataOwnerCollection& CMMCScBkupEngineImpl::DrvDataOwners() const |
|
299 { |
|
300 __ASSERT_ALWAYS(iCurrentArchive < iDataOwners.Count(), User::Invariant()); |
|
301 |
|
302 return *iDataOwners[iCurrentArchive]; |
|
303 } |
|
304 |
|
305 |
|
306 // --------------------------------------------------------------------------- |
|
307 // CMMCScBkupEngineImpl::DrvDataOwnersAll() |
|
308 // |
|
309 // |
|
310 // --------------------------------------------------------------------------- |
|
311 RPointerArray<CMMCScBkupDataOwnerCollection>& CMMCScBkupEngineImpl::DrvDataOwnersAll() |
|
312 { |
|
313 return iDataOwners; |
|
314 } |
|
315 |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 // CMMCScBkupEngineImpl::DrvFileList() |
|
319 // |
|
320 // |
|
321 // --------------------------------------------------------------------------- |
|
322 CMMCScBkupFileListCollection& CMMCScBkupEngineImpl::DrvFileList() const |
|
323 { |
|
324 __ASSERT_ALWAYS(iCurrentArchive < iFileLists.Count(), User::Invariant()); |
|
325 |
|
326 return *iFileLists[iCurrentArchive]; |
|
327 } |
|
328 |
|
329 |
|
330 // --------------------------------------------------------------------------- |
|
331 // CMMCScBkupEngineImpl::DrvLastCategory() |
|
332 // |
|
333 // |
|
334 // --------------------------------------------------------------------------- |
|
335 TBool CMMCScBkupEngineImpl::DrvLastCategory() const |
|
336 { |
|
337 return ( (iCurrentArchive + 1) == iArchives.Count() ); |
|
338 } |
|
339 |
|
340 |
|
341 // --------------------------------------------------------------------------- |
|
342 // CMMCScBkupEngineImpl::DrvStoreTotalProgress() |
|
343 // |
|
344 // |
|
345 // --------------------------------------------------------------------------- |
|
346 void CMMCScBkupEngineImpl::DrvStoreTotalProgress(TInt64 aProgress) |
|
347 { |
|
348 iTotalProgress += aProgress; |
|
349 } |
|
350 |
|
351 |
|
352 // --------------------------------------------------------------------------- |
|
353 // CMMCScBkupEngineImpl::DrvTotalProgress() |
|
354 // |
|
355 // |
|
356 // --------------------------------------------------------------------------- |
|
357 TInt64 CMMCScBkupEngineImpl::DrvTotalProgress() const |
|
358 { |
|
359 return iTotalProgress; |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------------------------- |
|
363 // CMMCScBkupEngineImpl::DrvProgressHandler() |
|
364 // |
|
365 // |
|
366 // --------------------------------------------------------------------------- |
|
367 MMMCScBkupProgressObserver& CMMCScBkupEngineImpl::DrvProgressHandler() const |
|
368 { |
|
369 CMMCScBkupEngineImpl* self = const_cast< CMMCScBkupEngineImpl* > (this); |
|
370 return *self; |
|
371 } |
|
372 |
|
373 |
|
374 // --------------------------------------------------------------------------- |
|
375 // CMMCScBkupEngineImpl::MMCScBkupHandleProgress() |
|
376 // |
|
377 // |
|
378 // --------------------------------------------------------------------------- |
|
379 void CMMCScBkupEngineImpl::MMCScBkupHandleProgress( TInt aAmountCompleted ) |
|
380 { |
|
381 __ASSERT_ALWAYS( aAmountCompleted >= 0, User::Invariant() ); |
|
382 if (aAmountCompleted > 0) |
|
383 { |
|
384 __LOG1("CMMCScBkupEngineImpl::MMCScBkupHandleProgress() - amount: %d", aAmountCompleted); |
|
385 iCumulativeProgress += aAmountCompleted; |
|
386 |
|
387 // Notify the observer that we've calculated the operational size |
|
388 NotifyObserver( MMMCScBkupEngineObserver::ECommonProgress, iCumulativeProgress ); |
|
389 } |
|
390 } |
|
391 |
|
392 |
|
393 // --------------------------------------------------------------------------- |
|
394 // CMMCScBkupEngineImpl::MMCScBkupHandleProgressDomainUnderstood() |
|
395 // |
|
396 // |
|
397 // --------------------------------------------------------------------------- |
|
398 void CMMCScBkupEngineImpl::MMCScBkupHandleProgressDomainUnderstood( TInt aTotalProgressAmount ) |
|
399 { |
|
400 __LOG1("CMMCScBkupEngineImpl::MMCScBkupHandleProgressDomainUnderstood() - ##### TOTAL PROGRESS AMOUNT IS: %d", aTotalProgressAmount); |
|
401 |
|
402 // Notify the observer that we've calculated the operational size |
|
403 NotifyObserver( MMMCScBkupEngineObserver::ECommonSizeOfTaskUnderstood, aTotalProgressAmount ); |
|
404 } |
|
405 |
|
406 |
|
407 // --------------------------------------------------------------------------- |
|
408 // CMMCScBkupEngineImpl::MMCScBkupHandleFreeSpace() |
|
409 // |
|
410 // |
|
411 // --------------------------------------------------------------------------- |
|
412 TInt CMMCScBkupEngineImpl::MMCScBkupHandleFreeSpace( TInt aPercentualFree ) |
|
413 { |
|
414 TInt error(KErrNone); |
|
415 |
|
416 TRAP_IGNORE( error = iObserver->HandleBkupEngineEventL( MMMCScBkupEngineObserver::EBackupAnalysingData, aPercentualFree ) ); |
|
417 |
|
418 return error; |
|
419 } |
|
420 |
|
421 // --------------------------------------------------------------------------- |
|
422 // CMMCScBkupEngineImpl::MMCScBkupStartBackuping() |
|
423 // |
|
424 // |
|
425 // --------------------------------------------------------------------------- |
|
426 void CMMCScBkupEngineImpl::MMCScBkupStartBackuping( TBool aProceed ) |
|
427 { |
|
428 __LOG1("CMMCScBkupEngineImpl::MMCScBkupStartBackuping() - Disk space validation done, proceed %d", aProceed); |
|
429 |
|
430 if( !aProceed ) |
|
431 { |
|
432 // If there is no space to carry out backup, "restore" existing backup file, |
|
433 // so that it can still be restored. |
|
434 for(TInt i = 0; i < iArchives.Count(); i++) |
|
435 { |
|
436 iArchives[i]->RestoreOldArchive( ); |
|
437 } |
|
438 } |
|
439 else |
|
440 { |
|
441 // Clean up existing backup files. |
|
442 for(TInt i = 0; i < iArchives.Count(); i++) |
|
443 { |
|
444 iArchives[i]->DeleteOldArchive( ); |
|
445 } |
|
446 } |
|
447 } |
|
448 |
|
449 // --------------------------------------------------------------------------- |
|
450 // CMMCScBkupEngineImpl::RunL() |
|
451 // |
|
452 // |
|
453 // --------------------------------------------------------------------------- |
|
454 void CMMCScBkupEngineImpl::RunL() |
|
455 { |
|
456 __LOG(" "); |
|
457 __LOG(" "); |
|
458 if ( !CurrentStateAvailable() ) |
|
459 { |
|
460 __LOG2("CMMCScBkupEngineImpl::RunL() - START - iStatus: %d, iCurrentArchive %d", |
|
461 iStatus.Int(), iCurrentArchive); |
|
462 } |
|
463 else |
|
464 { |
|
465 __LOG3("CMMCScBkupEngineImpl::RunL() - START - iStatus: %d, state: 0x%08x, iCurrentArchive %d", |
|
466 iStatus.Int(), CurrentState().StateId().iUid, iCurrentArchive); |
|
467 } |
|
468 |
|
469 User::LeaveIfError(iStatus.Int()); |
|
470 |
|
471 // Get the state that just finished - its always the head item |
|
472 const TBool stateStepAvailable = CurrentStateAvailable(); |
|
473 __ASSERT_ALWAYS(stateStepAvailable, User::Invariant()); |
|
474 CMMCScBkupState& currentState = CurrentState(); |
|
475 |
|
476 // Store completed state id as we're about to delete the object |
|
477 // so it won't be available afterwards... |
|
478 const TMMCScBkupStateId completedState = currentState.StateId(); |
|
479 |
|
480 // Identify which state should run next. In effect each state |
|
481 // defines the overall state machine. This is required since |
|
482 // some states need to dynamically change which state is executed |
|
483 // next. A good example is the archive op for active data - when |
|
484 // one or more active data clients are not ready, then the next |
|
485 // state should be to requery their readyness. After their |
|
486 // readyness has been ascertained, then any DO's that have now |
|
487 // become ready should be archived. This process continues |
|
488 // until all Active Data owners have provided all their data. |
|
489 TMMCScBkupStateId nextState; |
|
490 |
|
491 __LOG3("CMMCScBkupEngineImpl::RunL() - iActiveDataProcessingOngoing %d, completedState 0x%08x, nextState 0x%08x", |
|
492 iActiveDataProcessingOngoing, completedState.iUid, currentState.NextStateId().iUid); |
|
493 |
|
494 // Identify should we run current state again, i.e. run that state |
|
495 // for next category. If state does not require processing of same |
|
496 // state several times, then move on to next state. |
|
497 if( currentState.CategorySpecific() != CMMCScBkupState::EStateOnce ) |
|
498 { |
|
499 // For simplicity let's collect active data for each category in row. |
|
500 // This means checking data owner status before proceeding to next category. |
|
501 if( iActiveDataProcessingOngoing ) |
|
502 { |
|
503 iActiveDataProcessingOngoing = EFalse; |
|
504 nextState = currentState.NextStateId(); |
|
505 } |
|
506 else |
|
507 { |
|
508 if( completedState == KMMCScBkupStateIdArchiveOpActiveData ) |
|
509 { |
|
510 if( currentState.NextStateId() == KMMCScBkupStateIdGetDataOwnerStatuses ) |
|
511 { |
|
512 // There is still some active data to be processed |
|
513 iActiveDataProcessingOngoing = ETrue; |
|
514 nextState = KMMCScBkupStateIdGetDataOwnerStatuses; |
|
515 } |
|
516 } |
|
517 |
|
518 if( !iActiveDataProcessingOngoing ) |
|
519 { |
|
520 if( ++iCurrentArchive < iArchives.Count() ) |
|
521 { |
|
522 nextState = completedState; |
|
523 } |
|
524 else |
|
525 { |
|
526 iCurrentArchive = 0; |
|
527 nextState = currentState.NextStateId(); |
|
528 } |
|
529 } |
|
530 } |
|
531 } |
|
532 else |
|
533 { |
|
534 iCurrentArchive = 0; |
|
535 nextState = currentState.NextStateId(); |
|
536 } |
|
537 |
|
538 if(nextState == completedState && currentState.CategorySpecific() == CMMCScBkupState::EStatePerCategoryCommon) |
|
539 { |
|
540 __LOG2("CMMCScBkupEngineImpl::RunL() - object not recreated for state: 0x%08x, iCurrentArchive %d", |
|
541 nextState.iUid, iCurrentArchive); |
|
542 } |
|
543 else |
|
544 { |
|
545 // Remove the completed state (destroys 'currentState') |
|
546 DestroyCurrentState(); |
|
547 // Identify the next state. Causes RunL to be called when the state |
|
548 // has finished executing |
|
549 __LOG2("CMMCScBkupEngineImpl::RunL() - preparing state: 0x%08x, iCurrentArchive %d", |
|
550 nextState.iUid, iCurrentArchive); |
|
551 |
|
552 PrepareNextStateL( nextState ); |
|
553 } |
|
554 |
|
555 if (CurrentStateAvailable()) |
|
556 { |
|
557 #if defined(__MMCSCBKUPLOGGING_ENABLED__) |
|
558 CMMCScBkupState& newState = CurrentState(); |
|
559 if( newState.CategorySpecific() != CMMCScBkupState::EStateOnce ) |
|
560 { |
|
561 __LOG2("CMMCScBkupEngineImpl::RunL() - executing category specific state: 0x%08x for category 0x%x", |
|
562 nextState.iUid, iArchives[iCurrentArchive]->Category().iFlags); |
|
563 } |
|
564 else |
|
565 { |
|
566 __LOG1("CMMCScBkupEngineImpl::RunL() - executing non category specific state: 0x%08x", nextState.iUid); |
|
567 } |
|
568 #endif |
|
569 ExecuteStateL(); |
|
570 } |
|
571 else |
|
572 { |
|
573 if ( iSBEClient ) |
|
574 { |
|
575 MMCScBkupSBEUtils::EndBackupOrRestoreL( *iSBEClient ); |
|
576 } |
|
577 // Signal we are about to finish, so that bkupchecker can be notified. |
|
578 NotifyObserver(MMMCScBkupEngineObserver::ECommonOperationPrepareEnded); |
|
579 // We've finished |
|
580 CleanupL(); |
|
581 NotifyObserver(MMMCScBkupEngineObserver::ECommonOperationEnded); |
|
582 // Remove observer |
|
583 iObserver = NULL; |
|
584 } |
|
585 |
|
586 __LOG3("CMMCScBkupEngineImpl::RunL() - END - nextState: 0x%08x, isActive: %d, iStatus: %d", nextState.iUid, IsActive(), iStatus.Int()); |
|
587 __LOG(" "); |
|
588 __LOG(" "); |
|
589 } |
|
590 |
|
591 |
|
592 // --------------------------------------------------------------------------- |
|
593 // CMMCScBkupEngineImpl::DoCancel() |
|
594 // |
|
595 // |
|
596 // --------------------------------------------------------------------------- |
|
597 void CMMCScBkupEngineImpl::DoCancel() |
|
598 { |
|
599 __LOG("CMMCScBkupEngineImpl::DoCancel() - START"); |
|
600 |
|
601 if (CurrentStateAvailable()) |
|
602 { |
|
603 __LOG1("CMMCScBkupEngineImpl::DoCancel() - current state is: 0x%08x", CurrentState().StateId().iUid); |
|
604 |
|
605 // Our request should be completed by the state |
|
606 CurrentState().Cancel(); |
|
607 } |
|
608 |
|
609 // Signal we are about to finish, so that bkupchecker can be notified. |
|
610 NotifyObserver(MMMCScBkupEngineObserver::ECommonOperationPrepareEnded); |
|
611 // Cleanup |
|
612 TRAP_IGNORE( CleanupL( KErrCancel ) ); |
|
613 |
|
614 // Ensure observer is informed |
|
615 NotifyObserver(MMMCScBkupEngineObserver::ECommonOperationError, KErrCancel); |
|
616 NotifyObserver(MMMCScBkupEngineObserver::ECommonOperationEnded, KErrCancel); |
|
617 // Remove observer |
|
618 iObserver = NULL; |
|
619 |
|
620 __LOG("CMMCScBkupEngineImpl::DoCancel() - END"); |
|
621 } |
|
622 |
|
623 |
|
624 // --------------------------------------------------------------------------- |
|
625 // CMMCScBkupEngineImpl::RunError() |
|
626 // |
|
627 // |
|
628 // --------------------------------------------------------------------------- |
|
629 TInt CMMCScBkupEngineImpl::RunError(TInt aError) |
|
630 { |
|
631 __LOG1("CMMCScBkupEngineImpl::RunError() - START - aError: %d", aError); |
|
632 |
|
633 // Inform observer of error |
|
634 NotifyObserver(MMMCScBkupEngineObserver::ECommonOperationError, aError); |
|
635 // Signal we are about to finish, so that bkupchecker can be notified. |
|
636 NotifyObserver(MMMCScBkupEngineObserver::ECommonOperationPrepareEnded); |
|
637 // Cleanup |
|
638 TRAP_IGNORE( CleanupL( aError ) ); |
|
639 |
|
640 // Finalize observer |
|
641 NotifyObserver(MMMCScBkupEngineObserver::ECommonOperationEnded, aError); |
|
642 // Remove observer |
|
643 iObserver = NULL; |
|
644 |
|
645 // Return KErrNone to stop the scheduler from panicking our thread |
|
646 |
|
647 __LOG("CMMCScBkupEngineImpl::RunError() - END"); |
|
648 return KErrNone; |
|
649 } |
|
650 |
|
651 |
|
652 // --------------------------------------------------------------------------- |
|
653 // CMMCScBkupEngineImpl::CompleteOwnRequest() |
|
654 // |
|
655 // |
|
656 // --------------------------------------------------------------------------- |
|
657 void CMMCScBkupEngineImpl::CompleteOwnRequest(TInt aCompletionCode, TBool aSetActive) |
|
658 { |
|
659 if (aSetActive) |
|
660 { |
|
661 SetActive(); |
|
662 } |
|
663 // |
|
664 TRequestStatus* status = &iStatus; |
|
665 User::RequestComplete(status, aCompletionCode); |
|
666 } |
|
667 |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // CMMCScBkupEngineImpl::NotifyObserver() |
|
671 // |
|
672 // |
|
673 // --------------------------------------------------------------------------- |
|
674 void CMMCScBkupEngineImpl::NotifyObserver( MMMCScBkupEngineObserver::TEvent aEvent, TInt aAssociatedData ) |
|
675 { |
|
676 if ( iObserver ) |
|
677 { |
|
678 TRAP_IGNORE( iObserver->HandleBkupEngineEventL( aEvent, aAssociatedData ) ); |
|
679 } |
|
680 } |
|
681 |
|
682 |
|
683 // --------------------------------------------------------------------------- |
|
684 // CMMCScBkupEngineImpl::PrepareForBackupL() |
|
685 // |
|
686 // |
|
687 // --------------------------------------------------------------------------- |
|
688 void CMMCScBkupEngineImpl::PrepareForBackupL( TBool aPartial ) |
|
689 { |
|
690 #ifdef DEBUGGING_DATA_TRANSFER |
|
691 CleanBackupFilesL(); |
|
692 #endif |
|
693 |
|
694 // Open the archives for writing |
|
695 for(TInt i = 0; i < iArchives.Count(); i++) |
|
696 { |
|
697 const TPtrC pArchiveName( DrvParamsBase().FileName(i) ); |
|
698 iArchives[i]->OpenForWritingL( pArchiveName ); |
|
699 } |
|
700 |
|
701 // Initialise our state model |
|
702 if ( !aPartial ) |
|
703 { |
|
704 // Starting a FULL BACKUP |
|
705 PrepareNextStateL( KMMCScBkupStateArchiveOpArchiveHeader ); |
|
706 ExecuteStateL(); |
|
707 } |
|
708 else |
|
709 { |
|
710 User::Leave( KErrNotSupported ); |
|
711 } |
|
712 } |
|
713 |
|
714 |
|
715 // --------------------------------------------------------------------------- |
|
716 // CMMCScBkupEngineImpl::PrepareForRestoreL() |
|
717 // |
|
718 // |
|
719 // --------------------------------------------------------------------------- |
|
720 void CMMCScBkupEngineImpl::PrepareForRestoreL( TBool aPartial ) |
|
721 { |
|
722 #ifdef DEBUGGING_DATA_TRANSFER |
|
723 ClearRestoreFilesL(); |
|
724 #endif |
|
725 |
|
726 // Open the archives for reading |
|
727 for(TInt i = 0; i < iArchives.Count(); i++) |
|
728 { |
|
729 const TPtrC pArchiveName( DrvParamsBase().FileName(i) ); |
|
730 iArchives[i]->OpenForReadingL( pArchiveName ); |
|
731 |
|
732 #ifdef RD_FILE_MANAGER_BACKUP |
|
733 // Validate archive content is not altered |
|
734 #if defined(__MMCSCBKUPLOGGING_ENABLED__) |
|
735 TUint32 startTime = User::NTickCount(); |
|
736 #endif |
|
737 TInt validArchiveForRestore = MMCScBkupArchiveUtils::ValidateArchiveCrcsL( iFsSession, pArchiveName ); |
|
738 #if defined(__MMCSCBKUPLOGGING_ENABLED__) |
|
739 __LOG2("CMMCScBkupEngineImpl::PrepareForRestoreL - crcs validation result %d, ticks in ms %u", |
|
740 validArchiveForRestore, User::NTickCount() - startTime); |
|
741 #endif |
|
742 if(validArchiveForRestore == EFalse) |
|
743 { |
|
744 User::Leave(KErrCorrupt); |
|
745 } |
|
746 #endif |
|
747 } |
|
748 |
|
749 // Initialise our state model |
|
750 if ( !aPartial ) |
|
751 { |
|
752 // Starting a FULL RESTORE |
|
753 PrepareNextStateL( KMMCScBkupStateArchiveOpArchiveHeader ); |
|
754 ExecuteStateL(); |
|
755 } |
|
756 else |
|
757 { |
|
758 User::Leave( KErrNotSupported ); |
|
759 } |
|
760 } |
|
761 |
|
762 |
|
763 // --------------------------------------------------------------------------- |
|
764 // CMMCScBkupEngineImpl::SetParameters() |
|
765 // |
|
766 // |
|
767 // --------------------------------------------------------------------------- |
|
768 void CMMCScBkupEngineImpl::SetParameters(CMMCScBkupOpParamsBase* aParameters) |
|
769 { |
|
770 __ASSERT_ALWAYS(aParameters != NULL, User::Invariant()); |
|
771 // |
|
772 delete iParameters; |
|
773 iParameters = aParameters; |
|
774 } |
|
775 |
|
776 |
|
777 // --------------------------------------------------------------------------- |
|
778 // CMMCScBkupEngineImpl::CreateFactoryL() |
|
779 // |
|
780 // |
|
781 // --------------------------------------------------------------------------- |
|
782 void CMMCScBkupEngineImpl::CreateFactoryL(TMMCScBkupOperationType aOperation) |
|
783 { |
|
784 __ASSERT_DEBUG(iFactory == NULL, User::Invariant()); |
|
785 // |
|
786 CMMCScBkupStateFactory* factory = CMMCScBkupStateFactory::FactoryByOperationTypeLC(aOperation); |
|
787 delete iFactory; |
|
788 iFactory = factory; |
|
789 CleanupStack::Pop( factory ); |
|
790 } |
|
791 |
|
792 |
|
793 // --------------------------------------------------------------------------- |
|
794 // CMMCScBkupEngineImpl::CurrentStateAvailable() |
|
795 // |
|
796 // |
|
797 // --------------------------------------------------------------------------- |
|
798 TBool CMMCScBkupEngineImpl::CurrentStateAvailable() const |
|
799 { |
|
800 return (iCurrentState != NULL); |
|
801 } |
|
802 |
|
803 |
|
804 // --------------------------------------------------------------------------- |
|
805 // CMMCScBkupEngineImpl::CurrentStateId() |
|
806 // |
|
807 // |
|
808 // --------------------------------------------------------------------------- |
|
809 TMMCScBkupStateId CMMCScBkupEngineImpl::CurrentStateId() const |
|
810 { |
|
811 __ASSERT_ALWAYS(CurrentStateAvailable(), User::Invariant()); |
|
812 return CurrentState().StateId(); |
|
813 } |
|
814 |
|
815 |
|
816 // --------------------------------------------------------------------------- |
|
817 // CMMCScBkupEngineImpl::CurrentState() |
|
818 // |
|
819 // |
|
820 // --------------------------------------------------------------------------- |
|
821 CMMCScBkupState& CMMCScBkupEngineImpl::CurrentState() |
|
822 { |
|
823 return *iCurrentState; |
|
824 } |
|
825 |
|
826 |
|
827 // --------------------------------------------------------------------------- |
|
828 // CMMCScBkupEngineImpl::CurrentState() |
|
829 // |
|
830 // |
|
831 // --------------------------------------------------------------------------- |
|
832 const CMMCScBkupState& CMMCScBkupEngineImpl::CurrentState() const |
|
833 { |
|
834 return *iCurrentState; |
|
835 } |
|
836 |
|
837 |
|
838 // --------------------------------------------------------------------------- |
|
839 // CMMCScBkupEngineImpl::PrepareNextStateL() |
|
840 // |
|
841 // |
|
842 // --------------------------------------------------------------------------- |
|
843 void CMMCScBkupEngineImpl::PrepareNextStateL( TMMCScBkupStateId aNextState ) |
|
844 { |
|
845 if ( aNextState != KMMCScBkupStateIdOperationComplete ) |
|
846 { |
|
847 CMMCScBkupState* nextState = iFactory->GetStateLC( aNextState, *this ); |
|
848 delete iCurrentState; |
|
849 iCurrentState = nextState; |
|
850 CleanupStack::Pop( nextState ); |
|
851 } |
|
852 } |
|
853 |
|
854 |
|
855 // --------------------------------------------------------------------------- |
|
856 // CMMCScBkupEngineImpl::DestroyCurrentState() |
|
857 // |
|
858 // |
|
859 // --------------------------------------------------------------------------- |
|
860 void CMMCScBkupEngineImpl::DestroyCurrentState() |
|
861 { |
|
862 delete iCurrentState; |
|
863 iCurrentState = NULL; |
|
864 } |
|
865 |
|
866 |
|
867 // --------------------------------------------------------------------------- |
|
868 // CMMCScBkupEngineImpl::ExecuteStateL() |
|
869 // |
|
870 // |
|
871 // --------------------------------------------------------------------------- |
|
872 void CMMCScBkupEngineImpl::ExecuteStateL() |
|
873 { |
|
874 const TBool stateStepAvailable = CurrentStateAvailable(); |
|
875 __ASSERT_ALWAYS(stateStepAvailable, User::Invariant()); |
|
876 // |
|
877 CMMCScBkupState& currentState = CurrentState(); |
|
878 // |
|
879 currentState.ExecuteL(iStatus); |
|
880 SetActive(); |
|
881 |
|
882 // RunL will now be called when the state has completed execution |
|
883 } |
|
884 |
|
885 |
|
886 // --------------------------------------------------------------------------- |
|
887 // CMMCScBkupEngineImpl::CleanupL() |
|
888 // |
|
889 // |
|
890 // --------------------------------------------------------------------------- |
|
891 void CMMCScBkupEngineImpl::CleanupL( TInt aError ) |
|
892 { |
|
893 __LOG1("CMMCScBkupEngineImpl::CleanupL() - START - aError: %d", aError); |
|
894 |
|
895 // If SBE died, then recreate |
|
896 if ( aError == KErrServerTerminated ) |
|
897 { |
|
898 __LOG("CMMCScBkupEngineImpl::CleanupL() - assuming SBE panicked - re-creating SBE session..."); |
|
899 CSBEClient* newSBEClient = CSBEClient::NewL(); |
|
900 delete iSBEClient; |
|
901 iSBEClient = newSBEClient; |
|
902 } |
|
903 |
|
904 |
|
905 __LOG("CMMCScBkupEngineImpl::CleanupL() - destroying current state..."); |
|
906 DestroyCurrentState(); |
|
907 |
|
908 const TBool backupOrRestoreUnderway = MMCScBkupSBEUtils::PhoneIsInBackupOrRestoreModeL(); |
|
909 __LOG1("CMMCScBkupEngineImpl::CleanupL() - backupOrRestoreUnderway: %d", backupOrRestoreUnderway); |
|
910 if ( backupOrRestoreUnderway && iSBEClient ) |
|
911 { |
|
912 // Must end backup or restore |
|
913 __LOG("CMMCScBkupEngineImpl::CleanupL() - ending backup or restore..."); |
|
914 MMCScBkupSBEUtils::EndBackupOrRestoreL( *iSBEClient ); |
|
915 } |
|
916 |
|
917 // Ensure the archive is closed |
|
918 if ( iArchives.Count() ) |
|
919 { |
|
920 __LOG("CMMCScBkupEngineImpl::CleanupL() - closing archives..."); |
|
921 for(TInt i = 0; i < iArchives.Count(); i++) |
|
922 { |
|
923 iArchives[i]->Close( aError ); |
|
924 } |
|
925 |
|
926 __LOG("CMMCScBkupEngineImpl::CleanupL() - reseting archive array..."); |
|
927 iArchives.ResetAndDestroy(); |
|
928 } |
|
929 |
|
930 // Destroy old parameters |
|
931 __LOG("CMMCScBkupEngineImpl::CleanupL() - destroying parameters..."); |
|
932 delete iParameters; |
|
933 iParameters = NULL; |
|
934 |
|
935 // Set back to idle |
|
936 __LOG("CMMCScBkupEngineImpl::CleanupL() - setting operation status to idle..."); |
|
937 iOperationType = EMMCScBkupOperationTypeIdle; |
|
938 |
|
939 // Dispose of our collections |
|
940 __LOG("CMMCScBkupEngineImpl::CleanupL() - destroying data owners and file lists..."); |
|
941 iDataOwners.ResetAndDestroy(); |
|
942 iFileLists.ResetAndDestroy(); |
|
943 |
|
944 // Dispose of state factory |
|
945 __LOG("CMMCScBkupEngineImpl::CleanupL() - destroying factory..."); |
|
946 delete iFactory; |
|
947 iFactory = NULL; |
|
948 |
|
949 // Reset progress |
|
950 iCumulativeProgress = 0; |
|
951 |
|
952 // Reduce memory consumption by deleting SBE client. Session will be closed |
|
953 // and SBE frees reserved (e.g. 128 kB...) memory pool. |
|
954 if(iSBEClient) |
|
955 { |
|
956 __LOG("CMMCScBkupEngineImpl::CleanupL() - deleting SBE client..."); |
|
957 delete iSBEClient; |
|
958 iSBEClient = NULL; |
|
959 } |
|
960 |
|
961 __LOG("CMMCScBkupEngineImpl::CleanupL() - END"); |
|
962 } |
|
963 |
|
964 |
|
965 // --------------------------------------------------------------------------- |
|
966 // CMMCScBkupEngineImpl::PrepareObjectsL() |
|
967 // |
|
968 // |
|
969 // --------------------------------------------------------------------------- |
|
970 void CMMCScBkupEngineImpl::PrepareObjectsL() |
|
971 { |
|
972 __LOG("CMMCScBkupEngineImpl::PrepareObjectsL() - creating objects..."); |
|
973 |
|
974 iTotalProgress = 0; |
|
975 iCurrentArchive = 0; |
|
976 |
|
977 const RMMCScBkupPointerArray<CMMCScBkupArchiveInfo>& archives = DrvParamsBase().ArchiveInfos(); |
|
978 TInt count = archives.Count(); |
|
979 |
|
980 if(count == 0) |
|
981 { |
|
982 __LOG("CMMCScBkupEngineImpl::PrepareObjectsL() - nothing to be done, leaving..."); |
|
983 User::Leave(KErrCancel); |
|
984 } |
|
985 |
|
986 for(TInt i = 0; i < count; i++) |
|
987 { |
|
988 CMMCScBkupArchive* archive; |
|
989 archive = CMMCScBkupArchive::NewL( iFsSession, DrvProgressHandler(), *this, archives[i]->Category() ); |
|
990 CleanupStack::PushL( archive ); |
|
991 iArchives.AppendL( archive ); |
|
992 CleanupStack::Pop( archive ); |
|
993 |
|
994 CMMCScBkupDataOwnerCollection* dataOwners; |
|
995 dataOwners = CMMCScBkupDataOwnerCollection::NewL( *this, archives[i]->Category() ); |
|
996 CleanupStack::PushL( dataOwners ); |
|
997 iDataOwners.AppendL( dataOwners ); |
|
998 CleanupStack::Pop( dataOwners ); |
|
999 |
|
1000 CMMCScBkupFileListCollection* fileList; |
|
1001 fileList = CMMCScBkupFileListCollection::NewL( archives[i]->Category(), iFsSession ); |
|
1002 CleanupStack::PushL( fileList ); |
|
1003 iFileLists.AppendL( fileList ); |
|
1004 CleanupStack::Pop( fileList ); |
|
1005 } |
|
1006 } |
|
1007 |
|
1008 |
|
1009 // --------------------------------------------------------------------------- |
|
1010 // CMMCScBkupEngineImpl::ListArchivesL() |
|
1011 // |
|
1012 // Provide a list of valid (both content and category do match) archives |
|
1013 // available on all drives' backup folder |
|
1014 // --------------------------------------------------------------------------- |
|
1015 void CMMCScBkupEngineImpl::ListArchivesL( |
|
1016 RPointerArray< CMMCScBkupArchiveInfo >& aArchives, |
|
1017 CMMCScBkupOpParamsBase* aParams, |
|
1018 const TUint32 aDriveAttMatch, |
|
1019 const TInt aDriveMatch ) |
|
1020 { |
|
1021 __LOG("CMMCScBkupEngineImpl::ListArchivesL() - START"); |
|
1022 |
|
1023 for(TInt i = 0; i < KMaxDrives; i++) |
|
1024 { |
|
1025 // Check is drive number allowed |
|
1026 if ( aDriveMatch != KErrNotFound && aDriveMatch != i ) |
|
1027 { |
|
1028 continue; |
|
1029 } |
|
1030 // Check are drive attributes allowed |
|
1031 TBool supported( EFalse ); |
|
1032 TDriveInfo driveInfo; |
|
1033 if ( iFsSession.Drive( driveInfo, i ) == KErrNone ) |
|
1034 { |
|
1035 if ( driveInfo.iDriveAtt & aDriveAttMatch ) |
|
1036 { |
|
1037 supported = ETrue; |
|
1038 } |
|
1039 } |
|
1040 if ( !supported ) |
|
1041 { |
|
1042 continue; |
|
1043 } |
|
1044 |
|
1045 const TDriveUnit driveUnit(i); |
|
1046 const TDriveName driveName(driveUnit.Name()); |
|
1047 CDir* pFiles = NULL; |
|
1048 TFileName path; |
|
1049 path.Append(driveName); |
|
1050 path.Append(KBackUpFolder()); |
|
1051 path.Append(KBackUpFiles()); |
|
1052 |
|
1053 // Scan for all archives |
|
1054 iFsSession.GetDir(path, KEntryAttMatchMask, ESortNone, pFiles); |
|
1055 CleanupStack::PushL(pFiles); |
|
1056 |
|
1057 if(pFiles) |
|
1058 { |
|
1059 TInt count = pFiles->Count(); |
|
1060 for (TInt x = 0; x < count; x++) |
|
1061 { |
|
1062 const TEntry& entryPtr = (*pFiles)[x]; |
|
1063 TEntry entry(entryPtr); |
|
1064 TFileName pathAndFile; |
|
1065 pathAndFile.Append(driveName); |
|
1066 pathAndFile.Append(KBackUpFolder()); |
|
1067 pathAndFile.Append(entry.iName); |
|
1068 |
|
1069 entry.iName = pathAndFile; |
|
1070 |
|
1071 // Read category information from archive |
|
1072 TBitFlags category; |
|
1073 TRAPD(err, category = MMCScBkupArchiveUtils::ReadBkUpCategoryInformationL( iFsSession, pathAndFile )); |
|
1074 |
|
1075 if(err == KErrNone) |
|
1076 { |
|
1077 // Append archive in list when valid |
|
1078 if((category.Value() & aParams->Categories().Value()) && ValidArchiveForRestoreL( pathAndFile )) |
|
1079 { |
|
1080 __LOG2("CMMCScBkupEngineImpl::ListArchivesL() - adding archive %S of category 0x%x", |
|
1081 &pathAndFile, category.Value()); |
|
1082 CMMCScBkupArchiveInfo* archiveInfo = CMMCScBkupArchiveInfo::NewLC( entry ); |
|
1083 // Set category in archive info - can be used for filtering |
|
1084 archiveInfo->SetCategory( category ); |
|
1085 // Move ownership to array |
|
1086 aArchives.AppendL(archiveInfo); |
|
1087 CleanupStack::Pop(archiveInfo); |
|
1088 } |
|
1089 else |
|
1090 { |
|
1091 __LOG3("CMMCScBkupEngineImpl::ListArchivesL() - archive %S of category 0x%x (vs. 0x%x) not included", |
|
1092 &pathAndFile, category.Value(), aParams->Categories().Value()); |
|
1093 } |
|
1094 } |
|
1095 } |
|
1096 } |
|
1097 |
|
1098 CleanupStack::PopAndDestroy(pFiles); |
|
1099 } |
|
1100 |
|
1101 __LOG("CMMCScBkupEngineImpl::ListArchivesL() - END"); |
|
1102 } |
|
1103 |
|
1104 |
|
1105 #ifdef DEBUGGING_DATA_TRANSFER |
|
1106 // --------------------------------------------------------------------------- |
|
1107 // CMMCScBkupEngineImpl::CleanBackupFilesL() |
|
1108 // |
|
1109 // |
|
1110 // --------------------------------------------------------------------------- |
|
1111 void CMMCScBkupEngineImpl::CleanBackupFilesL() |
|
1112 { |
|
1113 CFileMan* fileMan = CFileMan::NewL( iFsSession ); |
|
1114 CleanupStack::PushL( fileMan ); |
|
1115 |
|
1116 // Make directory, ignore error, ugly, functionise later on... |
|
1117 _LIT(KMMCScBkupFormatDes, "%S%S%S%S"); |
|
1118 TFileName cleanPath; |
|
1119 const TDesC& path = PathInfo::MemoryCardRootPath(); |
|
1120 |
|
1121 // |
|
1122 cleanPath.Format(KMMCScBkupFormatDes, &path, &KMMCScBkupDataTransferDebuggingPathRoot, &KMMCScBkupDataTransferDebuggingPathDataJava, &KMMCScBkupDataTransferDebuggingPathDataBackup); |
|
1123 fileMan->Delete( cleanPath, CFileMan::ERecurse ); // Ignore error |
|
1124 iFsSession.MkDirAll( cleanPath ); |
|
1125 cleanPath.Format(KMMCScBkupFormatDes, &path, &KMMCScBkupDataTransferDebuggingPathRoot, &KMMCScBkupDataTransferDebuggingPathDataSystem, &KMMCScBkupDataTransferDebuggingPathDataBackup); |
|
1126 fileMan->Delete( cleanPath, CFileMan::ERecurse ); // Ignore error |
|
1127 iFsSession.MkDirAll( cleanPath ); |
|
1128 cleanPath.Format(KMMCScBkupFormatDes, &path, &KMMCScBkupDataTransferDebuggingPathRoot, &KMMCScBkupDataTransferDebuggingPathDataPassive, &KMMCScBkupDataTransferDebuggingPathDataBackup); |
|
1129 fileMan->Delete( cleanPath, CFileMan::ERecurse ); // Ignore error |
|
1130 iFsSession.MkDirAll( cleanPath ); |
|
1131 cleanPath.Format(KMMCScBkupFormatDes, &path, &KMMCScBkupDataTransferDebuggingPathRoot, &KMMCScBkupDataTransferDebuggingPathDataActive, &KMMCScBkupDataTransferDebuggingPathDataBackup); |
|
1132 fileMan->Delete( cleanPath, CFileMan::ERecurse ); // Ignore error |
|
1133 iFsSession.MkDirAll( cleanPath ); |
|
1134 // |
|
1135 CleanupStack::PopAndDestroy( fileMan ); |
|
1136 } |
|
1137 |
|
1138 |
|
1139 // --------------------------------------------------------------------------- |
|
1140 // CMMCScBkupEngineImpl::ClearRestoreFilesL() |
|
1141 // |
|
1142 // |
|
1143 // --------------------------------------------------------------------------- |
|
1144 void CMMCScBkupEngineImpl::ClearRestoreFilesL() |
|
1145 { |
|
1146 CFileMan* fileMan = CFileMan::NewL( iFsSession ); |
|
1147 CleanupStack::PushL( fileMan ); |
|
1148 |
|
1149 // Make directory, ignore error, ugly, functionise later on... |
|
1150 _LIT(KMMCScBkupFormatDes, "%S%S%S%S"); |
|
1151 TFileName cleanPath; |
|
1152 const TDesC& path = PathInfo::MemoryCardRootPath(); |
|
1153 |
|
1154 // |
|
1155 cleanPath.Format(KMMCScBkupFormatDes, &path, &KMMCScBkupDataTransferDebuggingPathRoot, &KMMCScBkupDataTransferDebuggingPathDataJava, &KMMCScBkupDataTransferDebuggingPathDataRestore); |
|
1156 fileMan->Delete( cleanPath, CFileMan::ERecurse ); // Ignore error |
|
1157 iFsSession.MkDirAll( cleanPath ); |
|
1158 cleanPath.Format(KMMCScBkupFormatDes, &path, &KMMCScBkupDataTransferDebuggingPathRoot, &KMMCScBkupDataTransferDebuggingPathDataSystem, &KMMCScBkupDataTransferDebuggingPathDataRestore); |
|
1159 fileMan->Delete( cleanPath, CFileMan::ERecurse ); // Ignore error |
|
1160 iFsSession.MkDirAll( cleanPath ); |
|
1161 cleanPath.Format(KMMCScBkupFormatDes, &path, &KMMCScBkupDataTransferDebuggingPathRoot, &KMMCScBkupDataTransferDebuggingPathDataPassive, &KMMCScBkupDataTransferDebuggingPathDataRestore); |
|
1162 fileMan->Delete( cleanPath, CFileMan::ERecurse ); // Ignore error |
|
1163 iFsSession.MkDirAll( cleanPath ); |
|
1164 cleanPath.Format(KMMCScBkupFormatDes, &path, &KMMCScBkupDataTransferDebuggingPathRoot, &KMMCScBkupDataTransferDebuggingPathDataActive, &KMMCScBkupDataTransferDebuggingPathDataRestore); |
|
1165 fileMan->Delete( cleanPath, CFileMan::ERecurse ); // Ignore error |
|
1166 iFsSession.MkDirAll( cleanPath ); |
|
1167 // |
|
1168 CleanupStack::PopAndDestroy( fileMan ); |
|
1169 } |
|
1170 |
|
1171 #endif |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 |
|
1184 |
|
1185 |
|
1186 |
|
1187 |
|
1188 |
|
1189 |
|