phonebookengines/VirtualPhonebook/VPbkEng/src/CVPbkMultiContactOperationBase.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 base class for multioperation implementations
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <CVPbkMultiContactOperationBase.h>
       
    20 
       
    21 CVPbkMultiContactOperationBase::CVPbkMultiContactOperationBase()
       
    22     {
       
    23     }
       
    24 
       
    25 CVPbkMultiContactOperationBase::~CVPbkMultiContactOperationBase()
       
    26     {
       
    27     Cancel();
       
    28     delete iIdle;
       
    29     iSubOperations.ResetAndDestroy();
       
    30     }
       
    31 
       
    32 EXPORT_C void CVPbkMultiContactOperationBase::AddSubOperationL(MVPbkContactOperation* aOperation)
       
    33     {
       
    34     User::LeaveIfError(iSubOperations.Append(aOperation));
       
    35 	}
       
    36 
       
    37 EXPORT_C TInt CVPbkMultiContactOperationBase::SubOperationCount() const
       
    38     {
       
    39     return iSubOperations.Count();
       
    40 	}
       
    41 
       
    42 void CVPbkMultiContactOperationBase::StartL()
       
    43     {
       
    44     const TInt count = iSubOperations.Count();
       
    45     for (TInt i = 0; i < count; ++i)
       
    46         {
       
    47         iSubOperations[i]->StartL();
       
    48         }
       
    49         
       
    50     if ( count == 0 )
       
    51         {
       
    52         if ( !iIdle )
       
    53             {
       
    54             iIdle = CIdle::NewL( CActive::EPriorityStandard );
       
    55             }
       
    56         iIdle->Start( TCallBack( &AsyncCallback, this ) );
       
    57         }
       
    58     }
       
    59 
       
    60 void CVPbkMultiContactOperationBase::Cancel()
       
    61     {
       
    62     const TInt count = iSubOperations.Count();
       
    63     for (TInt i = 0; i < count; ++i)
       
    64         {
       
    65         iSubOperations[i]->Cancel();
       
    66         }
       
    67     
       
    68     if ( iIdle )
       
    69         {
       
    70         iIdle->Cancel();
       
    71         }
       
    72     }
       
    73 
       
    74 TInt CVPbkMultiContactOperationBase::AsyncCallback( TAny* aThis )
       
    75     {
       
    76     CVPbkMultiContactOperationBase* self = 
       
    77         static_cast<CVPbkMultiContactOperationBase*>( aThis );
       
    78     self->HandleZeroSuboperations();
       
    79     // Don't continue
       
    80     return 0;
       
    81     }
       
    82 // End of File
       
    83