phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CCommitContactsOperation.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002-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:  The virtual phonebook commit contacts operation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CCOMMITCONTACTSOPERATION_H
       
    21 #define CCOMMITCONTACTSOPERATION_H
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <e32base.h>
       
    25 #include <MVPbkContactOperation.h>
       
    26 #include <MVPbkContactObserver.h>
       
    27 
       
    28 // FORWARD DECLARAIONS
       
    29 class MVPbkBatchOperationObserver;
       
    30 
       
    31 namespace VPbkCntModel {
       
    32 
       
    33 // FORWARD DECLARAIONS
       
    34 class CContactStore;
       
    35 class CContact;
       
    36 
       
    37 NONSHARABLE_CLASS( CCommitContactsOperation ): 
       
    38         public CActive,
       
    39         public MVPbkContactOperation,
       
    40         public MVPbkContactObserver
       
    41     {
       
    42     public:
       
    43         /**
       
    44         * Two-phased constructor.
       
    45         * @param aContactStore the store that is used by the operation
       
    46         * @param aContacts virtual phonebook contacts
       
    47         * @param aObserver an observer to notify while commiting
       
    48         *
       
    49         * @return a new instance of this class
       
    50         */
       
    51         static CCommitContactsOperation* NewL(
       
    52                 CContactStore& aContactStore, 
       
    53                 const TArray<CContact*> aContacts, 
       
    54                 MVPbkBatchOperationObserver& aObserver );
       
    55         ~CCommitContactsOperation();
       
    56 
       
    57     private: // From CActive
       
    58         void RunL();
       
    59         TInt RunError( TInt aError );
       
    60         void DoCancel();
       
    61 
       
    62     private: // From MVPbkContactOperation
       
    63         void StartL();
       
    64         void Cancel();
       
    65 
       
    66     private: // MVPbkContactObserver
       
    67         void ContactOperationCompleted( TContactOpResult aResult );
       
    68         void ContactOperationFailed( TContactOp aOpCode, TInt aErrorCode, 
       
    69                                     TBool aErrorNotified );
       
    70 
       
    71     private: // Implementation
       
    72         CCommitContactsOperation(
       
    73                 CContactStore& aContactStore, 
       
    74                 MVPbkBatchOperationObserver& aObserver );
       
    75         void ConstructL( const TArray<CContact*>& aContacts );
       
    76         void NextStepL();
       
    77         void IssueRequest();
       
    78 
       
    79     private: // Data
       
    80         /// Ref: The store that is used by the operation
       
    81         CContactStore& iContactStore;
       
    82         /// Ref: an observer to notify while commiting
       
    83         MVPbkBatchOperationObserver& iObserver;
       
    84         /// Own: Contacts
       
    85         RPointerArray<CContact> iContacts;
       
    86         /// Operation state
       
    87         enum TState
       
    88             {
       
    89             ECommit,
       
    90             EComplete
       
    91             };
       
    92         TState iState;
       
    93     };
       
    94 
       
    95 } // namespace VPbkCntModel
       
    96 
       
    97 #endif // CCOMMITCONTACTSOPERATION_H
       
    98 
       
    99 //End of file