phonebookengines/VirtualPhonebook/VPbkEng/src/CVPbkBatchOperation.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  An implementation for operations that needs to do a big task
       
    15 *                and report steps to observers. Can be used e.g
       
    16 *                in store domain implementation to handle multiple store
       
    17 *                operations
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #include "CVPbkBatchOperation.h"
       
    23 
       
    24 CVPbkBatchOperation::CVPbkBatchOperation(
       
    25         MVPbkBatchOperationObserver& aObserver) :
       
    26     iObserver(aObserver)
       
    27     {
       
    28     }
       
    29 
       
    30 CVPbkBatchOperation::~CVPbkBatchOperation()
       
    31     {
       
    32     }
       
    33 
       
    34 EXPORT_C CVPbkBatchOperation* CVPbkBatchOperation::NewLC(
       
    35         MVPbkBatchOperationObserver& aObserver)
       
    36     {
       
    37     CVPbkBatchOperation* self = new(ELeave) CVPbkBatchOperation(aObserver);
       
    38     CleanupStack::PushL(self);
       
    39     return self;
       
    40 	}
       
    41 
       
    42 void CVPbkBatchOperation::HandleZeroSuboperations()
       
    43     {
       
    44     // Called from the base class if there were no suboperations
       
    45     iObserver.OperationComplete( *this );
       
    46     }
       
    47     
       
    48 void CVPbkBatchOperation::StepComplete(MVPbkContactOperationBase& /*aOperation*/, TInt aStepSize)
       
    49     {
       
    50     iObserver.StepComplete(*this, aStepSize);
       
    51     }
       
    52 
       
    53 TBool CVPbkBatchOperation::StepFailed(MVPbkContactOperationBase& /*aOperation*/, TInt aStepSize, TInt aError)
       
    54     {
       
    55     return iObserver.StepFailed(*this, aStepSize, aError);
       
    56     }
       
    57 
       
    58 void CVPbkBatchOperation::OperationComplete(MVPbkContactOperationBase& /*aOperation*/)
       
    59     {
       
    60     ++iCompleteCount;
       
    61 
       
    62     if (iCompleteCount >= SubOperationCount())
       
    63         {
       
    64         iObserver.OperationComplete(*this);
       
    65         }
       
    66     }
       
    67 
       
    68 // End of File