phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CAsyncContactOperation.h
changeset 0 e686773b3f54
child 15 e8e3147d53eb
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 asynchronous contact operation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef VPBKCNTMODEL_CASYNCCONTACTOPERATION_H
       
    20 #define VPBKCNTMODEL_CASYNCCONTACTOPERATION_H
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <cntdef.h>
       
    26 #include <MVPbkContactObserver.h>
       
    27 
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CContactDatabase;
       
    31 class CContactItem;
       
    32 
       
    33 namespace VPbkEngUtils { 
       
    34 class CVPbkDiskSpaceCheck;
       
    35 } /// namespace
       
    36 
       
    37 namespace VPbkCntModel {
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 class CContactStore;
       
    41 class CContact;
       
    42 
       
    43 // CLASS DECLARATIONS
       
    44 
       
    45 /**
       
    46  * Asynchronous contact operation.
       
    47  */
       
    48 NONSHARABLE_CLASS( CAsyncContactOperation ): public CAsyncOneShot
       
    49     {
       
    50     public:  // Constructor and destructor
       
    51         /**
       
    52          * Creates a new instance of this class.
       
    53          *
       
    54 		 * @param aContactStore contact store.
       
    55          */
       
    56         static CAsyncContactOperation* NewL
       
    57             ( CContactStore& aContactStore );
       
    58 
       
    59         ~CAsyncContactOperation();
       
    60 
       
    61     public:  // New functions
       
    62         /**
       
    63          * Prepares an asynchronous contact operation.
       
    64          *
       
    65          * @param aOpCode       the operation to perform.
       
    66          * @param aContact      target contact of the operation.
       
    67          * @param aObserver     observer of the operation.
       
    68          * @exception KErrInUse if an operation is currently executing.
       
    69          * @precond aOpCode is EContactSave or EContactCommit. 
       
    70          */
       
    71         void PrepareL
       
    72             ( MVPbkContactObserver::TContactOp aOpCode, 
       
    73             const CContact& aContact, 
       
    74             MVPbkContactObserver& aObserver );
       
    75             
       
    76         /**
       
    77          * Prepares an asynchronous contact operation.
       
    78          *
       
    79          * @param aOpCode       the operation to perform.
       
    80          * @param aContactId    id of the target contact of the operation.
       
    81          * @param aObserver     observer of the operation.
       
    82          * @exception KErrInUse if an operation is currently executing.
       
    83          * @precond aOpCode is EContactSave or EContactCommit. 
       
    84          */
       
    85         void PrepareL
       
    86             ( MVPbkContactObserver::TContactOp aOpCode, 
       
    87             TContactItemId aContactId, 
       
    88             MVPbkContactObserver& aObserver );            
       
    89 
       
    90         /**
       
    91          * Executes the prepared operation. Calls the observer passed to 
       
    92          * PrepareL when the operation completes.
       
    93          */
       
    94         void Execute() { CAsyncOneShot::Call(); }
       
    95 
       
    96         /**
       
    97          * Overloaded Cancel. Determines if an async operation has finished.
       
    98          *
       
    99          * @param aContact    contact item for comparison against
       
   100          *					  iClientContact.
       
   101          */
       
   102         void Cancel( CContactItem* aContact );
       
   103         
       
   104     private:  // from CAsyncOneShot
       
   105         void DoCancel();
       
   106         void RunL();
       
   107         TInt RunError( TInt aError );
       
   108 
       
   109     private:  // Implementation
       
   110 		CAsyncContactOperation( CContactStore& aContactStore );
       
   111 		void ConstructL();
       
   112 
       
   113     private:  // Data
       
   114         ///Ref: contact store
       
   115 		CContactStore& iContactStore;
       
   116         ///Own: contact operation code
       
   117         MVPbkContactObserver::TContactOp iOpCode;
       
   118         ///Ref: client contact
       
   119         const CContact* iClientContact;
       
   120         ///Own: contact item id
       
   121         TContactItemId iTargetContactId;
       
   122         ///Ref: contact observer
       
   123         MVPbkContactObserver* iObserver;
       
   124         ///Own: file system session
       
   125         RFs iFs;
       
   126         ///Own: Disk Space Checker
       
   127         VPbkEngUtils::CVPbkDiskSpaceCheck* iDiskSpaceChecker;
       
   128     };
       
   129 
       
   130 
       
   131 } // namespace VPbkCntModel
       
   132 
       
   133 #endif  // VPBKCNTMODEL_CASYNCCONTACTOPERATION_H
       
   134 //End of file
       
   135 
       
   136