filemanager/bkupengine/src/CMMCScBkupStateArchiveOpArchiveFooter.cpp
changeset 0 6a9f87576119
equal deleted inserted replaced
-1:000000000000 0:6a9f87576119
       
     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: CMMCScBkupStateArchiveOpArchiveFooter implementation
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 #include "CMMCScBkupStateArchiveOpArchiveFooter.h"
       
    20 
       
    21 // System includes
       
    22 #include <e32std.h>
       
    23 #include <s32strm.h>
       
    24 #include <s32mem.h>
       
    25 
       
    26 // User includes
       
    27 #include "MMCScBkupLogger.h"
       
    28 #include "CMMCScBkupArchive.h"
       
    29 #include "CMMCScBkupArchiveFooter.h"
       
    30 #include "CMMCScBkupArchiveHeader.h"
       
    31 
       
    32 
       
    33 
       
    34 // ========================= MEMBER FUNCTIONS ================================
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // CMMCScBkupStateArchiveOpArchiveFooter::CMMCScBkupStateArchiveOpArchiveFooter()
       
    38 // 
       
    39 // C++ constructor.
       
    40 // ---------------------------------------------------------------------------
       
    41 CMMCScBkupStateArchiveOpArchiveFooter::CMMCScBkupStateArchiveOpArchiveFooter( MMMCScBkupDriver& aDriver )
       
    42 :   CMMCScBkupState( aDriver )
       
    43     {
       
    44     __LOG1("CMMCScBkupStateArchiveOpArchiveFooter::CMMCScBkupStateArchiveOpArchiveFooter() - 0x%08x", StateId().iUid );
       
    45     }
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // CMMCScBkupStateArchiveOpArchiveFooter::NewL()
       
    50 // 
       
    51 // 
       
    52 // ---------------------------------------------------------------------------
       
    53 CMMCScBkupStateArchiveOpArchiveFooter* CMMCScBkupStateArchiveOpArchiveFooter::NewL( MMMCScBkupDriver& aDriver )
       
    54     {
       
    55     CMMCScBkupStateArchiveOpArchiveFooter* self = new(ELeave) CMMCScBkupStateArchiveOpArchiveFooter( aDriver );
       
    56     return self;
       
    57     }
       
    58 
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CMMCScBkupStateArchiveOpArchiveFooter::StateId()
       
    62 // 
       
    63 // 
       
    64 // ---------------------------------------------------------------------------
       
    65 TMMCScBkupStateId CMMCScBkupStateArchiveOpArchiveFooter::StateId() const
       
    66     {
       
    67     return KMMCScBkupStateIdArchiveOpArchiveFooter;
       
    68     }
       
    69 
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // CMMCScBkupStateArchiveOpArchiveFooter::NextStateId()
       
    73 // 
       
    74 // 
       
    75 // ---------------------------------------------------------------------------
       
    76 TMMCScBkupStateId CMMCScBkupStateArchiveOpArchiveFooter::NextStateId() const
       
    77     {
       
    78     TMMCScBkupStateId nextState = KMMCScBkupStateIdOperationComplete;
       
    79     //
       
    80     const TMMCScBkupOperationType type = Driver().DrvOperation();
       
    81     switch(type)
       
    82         {
       
    83     case EMMCScBkupOperationTypeFullBackup:
       
    84         nextState = KMMCScBkupStateIdOperationComplete;
       
    85         break;
       
    86     case EMMCScBkupOperationTypeFullRestore:
       
    87         nextState = KMMCScBkupStateIdArchiveOpDataOwners;
       
    88         break;
       
    89     default:
       
    90         ASSERT( EFalse );
       
    91         break;
       
    92         }
       
    93     //
       
    94     return nextState;
       
    95     }
       
    96 
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CMMCScBkupStateArchiveOpArchiveFooter::PerformStateInitL()
       
   100 // 
       
   101 // 
       
   102 // ---------------------------------------------------------------------------
       
   103 void CMMCScBkupStateArchiveOpArchiveFooter::PerformStateInitL()
       
   104     {
       
   105     CompleteSelf();
       
   106     }
       
   107 
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // CMMCScBkupStateArchiveOpArchiveFooter::PerformAsynchronousStateStepL()
       
   111 // 
       
   112 // 
       
   113 // ---------------------------------------------------------------------------
       
   114 void CMMCScBkupStateArchiveOpArchiveFooter::PerformAsynchronousStateStepL()
       
   115     {
       
   116     CMMCScBkupArchive& archive = Driver().DrvArchive();
       
   117     CMMCScBkupArchiveFooter& footer = archive.Footer();
       
   118     CMMCScBkupArchiveHeader& header = archive.Header();
       
   119     //
       
   120     const TMMCScBkupOperationType type = Driver().DrvOperation();
       
   121     switch(type)
       
   122         {
       
   123     case EMMCScBkupOperationTypeFullBackup:
       
   124         __LOG("CMMCScBkupStateArchiveOpArchiveFooter::PerformAsynchronousStateStepL() - EMMCScBkupOperationTypeFullBackup - storing footer..." );
       
   125         footer.StoreL();
       
   126         break;
       
   127     case EMMCScBkupOperationTypeFullRestore:
       
   128         {
       
   129         __LOG("CMMCScBkupStateArchiveOpArchiveFooter::PerformAsynchronousStateStepL() - EMMCScBkupOperationTypeFullRestore - restoring footer..." );
       
   130 
       
   131         const TMMCScBkupArchiveVector& archiveVector = Driver().DrvADI().ADIOverallArchiveVectorInfo();
       
   132         __LOG1("CMMCScBkupStateArchiveOpArchiveFooter::PerformAsynchronousStateStepL() - overall archive length: %d", archiveVector.Length() );
       
   133 
       
   134         const TInt footerLengthFromHeader = header.FooterLength();
       
   135         __LOG1("CMMCScBkupStateArchiveOpArchiveFooter::PerformAsynchronousStateStepL() - footer length (read from header): %d", footerLengthFromHeader );
       
   136 
       
   137         const TInt footerStartingOffset = archiveVector.Length() - footerLengthFromHeader;
       
   138         __LOG1("CMMCScBkupStateArchiveOpArchiveFooter::PerformAsynchronousStateStepL() - footer starting offset: %d", footerStartingOffset );
       
   139 
       
   140         footer.RestoreL( footerStartingOffset );
       
   141 
       
   142         __LOG("CMMCScBkupStateArchiveOpArchiveFooter::PerformAsynchronousStateStepL() - restoring all indicies");
       
   143         
       
   144         // Restore all indicies
       
   145         CMMCScBkupIndexBase& indexDataOwner = footer.IndexByType(EMMCScBkupOwnerDataTypeDataOwner);
       
   146         indexDataOwner.RestoreL( Driver() );
       
   147 
       
   148         CMMCScBkupIndexBase& indexSystem = footer.IndexByType( EMMCScBkupOwnerDataTypeSystemData );
       
   149         indexSystem.RestoreL( Driver() );
       
   150 
       
   151         CMMCScBkupIndexBase& indexJava = footer.IndexByType( EMMCScBkupOwnerDataTypeJavaData );
       
   152         indexJava.RestoreL( Driver() );
       
   153 
       
   154         CMMCScBkupIndexBase& indexPassive = footer.IndexByType( EMMCScBkupOwnerDataTypePassiveData );
       
   155         indexPassive.RestoreL( Driver() );
       
   156 
       
   157         CMMCScBkupIndexBase& indexActive = footer.IndexByType( EMMCScBkupOwnerDataTypeActiveData );
       
   158         indexActive.RestoreL( Driver() );
       
   159 
       
   160         CMMCScBkupIndexBase& indexPublic = footer.IndexByType( EMMCScBkupOwnerDataTypePublicData );
       
   161         indexPublic.RestoreL( Driver() );
       
   162 
       
   163         __LOG("CMMCScBkupStateArchiveOpArchiveFooter::PerformAsynchronousStateStepL() - all indicies restored");
       
   164 
       
   165         break;
       
   166         }
       
   167     default:
       
   168         User::Leave(KErrNotSupported);
       
   169         break;
       
   170         }
       
   171     }
       
   172 
       
   173 
       
   174