filemanager/src/fmbkupengine/src/CMMCScBkupStateGetDataOwnerStatuses.cpp
branchRCL_3
changeset 39 65326cf895ed
parent 38 491b3ed49290
child 42 f5c50b8af68c
equal deleted inserted replaced
38:491b3ed49290 39:65326cf895ed
     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: CMMCScBkupStateGetDataOwnerStatuses implementation
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 #include "CMMCScBkupStateGetDataOwnerStatuses.h"
       
    20 
       
    21 // System includes
       
    22 #include <e32std.h>
       
    23 
       
    24 // User includes
       
    25 #include "MMCScBkupLogger.h"
       
    26 #include "CMMCScBkupDataOwnerInfo.h"
       
    27 #include "CMMCScBkupDataOwnerCollection.h"
       
    28 
       
    29 
       
    30 
       
    31 
       
    32 // ========================= MEMBER FUNCTIONS ================================
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // CMMCScBkupStateGetDataOwnerStatuses::CMMCScBkupStateGetDataOwnerStatuses()
       
    36 // 
       
    37 // C++ constructor.
       
    38 // ---------------------------------------------------------------------------
       
    39 CMMCScBkupStateGetDataOwnerStatuses::CMMCScBkupStateGetDataOwnerStatuses( MMMCScBkupDriver& aDriver )
       
    40 :   CMMCScBkupState( aDriver )
       
    41     {
       
    42     __LOG1("CMMCScBkupStateGetDataOwnerStatuses::CMMCScBkupStateGetDataOwnerStatuses() - 0x%08x", StateId().iUid );
       
    43     }
       
    44 
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // CMMCScBkupStateGetDataOwnerStatuses::~CMMCScBkupStateGetDataOwnerStatuses()
       
    48 // 
       
    49 // Destructor.
       
    50 // ---------------------------------------------------------------------------
       
    51 CMMCScBkupStateGetDataOwnerStatuses::~CMMCScBkupStateGetDataOwnerStatuses()
       
    52     {
       
    53     Cancel();
       
    54     //
       
    55     iStatusArray.Close();
       
    56     }
       
    57 
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CMMCScBkupStateGetDataOwnerStatuses::NewL()
       
    61 // 
       
    62 // 
       
    63 // ---------------------------------------------------------------------------
       
    64 CMMCScBkupStateGetDataOwnerStatuses* CMMCScBkupStateGetDataOwnerStatuses::NewL( MMMCScBkupDriver& aDriver )
       
    65     {
       
    66     CMMCScBkupStateGetDataOwnerStatuses* self = new(ELeave) CMMCScBkupStateGetDataOwnerStatuses( aDriver );
       
    67     return self;
       
    68     }
       
    69 
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // CMMCScBkupStateGetDataOwnerStatuses::StateId()
       
    73 // 
       
    74 // 
       
    75 // ---------------------------------------------------------------------------
       
    76 TMMCScBkupStateId CMMCScBkupStateGetDataOwnerStatuses::StateId() const
       
    77     {
       
    78     return KMMCScBkupStateIdGetDataOwnerStatuses;
       
    79     }
       
    80 
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CMMCScBkupStateGetDataOwnerStatuses::NextStateId()
       
    84 // 
       
    85 // 
       
    86 // ---------------------------------------------------------------------------
       
    87 TMMCScBkupStateId CMMCScBkupStateGetDataOwnerStatuses::NextStateId() const
       
    88     {
       
    89     return KMMCScBkupStateIdArchiveOpActiveData;
       
    90     }
       
    91 
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // CMMCScBkupStateGetDataOwnerStatuses::PerformStateInitL()
       
    95 // 
       
    96 // 
       
    97 // ---------------------------------------------------------------------------
       
    98 void CMMCScBkupStateGetDataOwnerStatuses::PerformStateInitL()
       
    99     {
       
   100     SetState( EPrearingQuery );
       
   101     CompleteSelf();
       
   102     }
       
   103 
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // CMMCScBkupStateGetDataOwnerStatuses::PerformAsynchronousStateStepL()
       
   107 // 
       
   108 // 
       
   109 // ---------------------------------------------------------------------------
       
   110 void CMMCScBkupStateGetDataOwnerStatuses::PerformAsynchronousStateStepL()
       
   111     {
       
   112     switch( State() )
       
   113         {
       
   114     case EPrearingQuery:
       
   115         PrepareQueryL();
       
   116         break;
       
   117     case EGettingStatus:
       
   118         Driver().DrvSecureBackupClient().SIDStatusL( iStatusArray );
       
   119         SetState( EProcessingResults );
       
   120         CompleteSelf();
       
   121         break;
       
   122     case EProcessingResults:
       
   123         ProcessStatusResultsL();
       
   124         break;
       
   125     default:
       
   126         ASSERT( EFalse );
       
   127         }
       
   128     }
       
   129 
       
   130 
       
   131 // ---------------------------------------------------------------------------
       
   132 // CMMCScBkupStateGetDataOwnerStatuses::PrepareQueryL()
       
   133 // 
       
   134 // 
       
   135 // ---------------------------------------------------------------------------
       
   136 void CMMCScBkupStateGetDataOwnerStatuses::PrepareQueryL()
       
   137     {
       
   138     const TDataOwnerStatus KMMCScBkupDefaultOwnerStatus = EUnset;
       
   139     const TInt KMMCScBkupDefaultOwnerStatusError = 0;
       
   140 
       
   141     // Build an array of all of the active data owners that we require
       
   142     // the statuses for.
       
   143     CMMCScBkupDataOwnerCollection& ownerCollection = Driver().DrvDataOwners();
       
   144     const TInt count = ownerCollection.Count();
       
   145     for(TInt i=0; i<count; i++)
       
   146         {
       
   147         CMMCScBkupDataOwnerInfo& owner = ownerCollection.Owner(i);
       
   148         //
       
   149         if  (owner.Owner().CommonSettings() & EActiveBUR)
       
   150             {
       
   151             const TDataOwnerAndStatus ownerStatus(
       
   152                                         owner.SecureId(),
       
   153                                         KMMCScBkupDefaultOwnerStatus,
       
   154                                         KMMCScBkupDefaultOwnerStatusError);
       
   155             iStatusArray.AppendL( ownerStatus );
       
   156             __LOG1("CMMCScBkupStateGetDataOwnerStatuses::PrepareQueryL() - DO 0x%08x *is* active", owner.SecureId().iId );
       
   157             }
       
   158         else
       
   159             {
       
   160             __LOG1("CMMCScBkupStateGetDataOwnerStatuses::PrepareQueryL() - DO 0x%08x is not active", owner.SecureId().iId );
       
   161             }
       
   162         }
       
   163 
       
   164     SetState( EGettingStatus );
       
   165     CompleteSelf();
       
   166     }
       
   167 
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // CMMCScBkupStateGetDataOwnerStatuses::ProcessStatusResultsL()
       
   171 // 
       
   172 // 
       
   173 // ---------------------------------------------------------------------------
       
   174 void CMMCScBkupStateGetDataOwnerStatuses::ProcessStatusResultsL()
       
   175     {
       
   176     CMMCScBkupDataOwnerCollection& ownerCollection = Driver().DrvDataOwners();
       
   177     const TInt count = iStatusArray.Count();
       
   178     __LOG1("CMMCScBkupStateGetDataOwnerStatuses::ProcessStatusResultsL() - received %d entries from SBE...", count );
       
   179     for(TInt i=0; i<count; i++)
       
   180         {
       
   181         const TDataOwnerAndStatus& ownerStatus = iStatusArray[i];
       
   182         __LOG4("CMMCScBkupStateGetDataOwnerStatuses::ProcessStatusResultsL() - ownerStatus[%3d] sid: 0x%08x, status: %d, err: %d", 
       
   183             i, ownerStatus.iSID.iId, ownerStatus.iStatus, ownerStatus.iDataOwnerError );
       
   184         //
       
   185         CMMCScBkupDataOwnerInfo* owner = NULL;
       
   186         TRAPD(err, owner = &ownerCollection.OwnerL( ownerStatus.iSID ));
       
   187         if  (err == KErrNone && owner)
       
   188             {
       
   189             owner->SetStatus( ownerStatus.iStatus );
       
   190             }
       
   191         }
       
   192     }
       
   193 
       
   194