phonebookengines/VirtualPhonebook/VPbkEng/inc/CVPbkContactEasyManager.h
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:  Contact easy manager
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CVPBKCONTACTEASYMANAGER_H_
       
    20 #define CVPBKCONTACTEASYMANAGER_H_
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <MVPbkSingleContactOperationObserver.h>
       
    26 #include <MVPbkContactObserver.h>
       
    27 #include <MVPbkStoreContact.h>
       
    28 #include <MVPbkContactOperationBase.h>
       
    29 // FORWARD DECLARATIONS
       
    30 class MVPbkOperationObserver;
       
    31 class MVPbkOperationErrorObserver;
       
    32 class CVPbkContactManager;
       
    33 class CVPbkContactLinkArray;
       
    34 class MVPbkContactLinkArray;
       
    35 class MVPbkContactOperationBase;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40  * An API for easy locking and retrieving of several contacts.
       
    41  */
       
    42 NONSHARABLE_CLASS( CVPbkContactEasyManager ) : public CBase,
       
    43     public MVPbkSingleContactOperationObserver,
       
    44     public MVPbkContactObserver,
       
    45     public MVPbkContactOperationBase
       
    46     {
       
    47     public:
       
    48 
       
    49         /**
       
    50          * @param aContactManager Reference to a contact manager which already
       
    51          *        has stores opened.
       
    52          */
       
    53         static CVPbkContactEasyManager* NewL(
       
    54             CVPbkContactManager& aContactManager );
       
    55 
       
    56 	   ~CVPbkContactEasyManager();
       
    57 
       
    58     public: // new methods
       
    59         
       
    60         /**
       
    61          * Retrieves and locks contacts asynchronously.
       
    62          * The observer is informed when all the contacts have been retrieved.
       
    63          * 
       
    64          * @param aContactLinks Links for contacts that are to be retrieved.
       
    65          * 
       
    66          * @param aRetrievedContacts A reference to an array where the
       
    67          *        retrieved contacts are placed into. Ownership of the
       
    68          *        contacts is given to the owner of the array.
       
    69          * 
       
    70          * @param aObserver The observer.
       
    71          */
       
    72         void RetrieveAndLockContactsL(
       
    73             const MVPbkContactLinkArray& aContactLinks,            
       
    74             RPointerArray<MVPbkStoreContact>& aRetrievedContacts,
       
    75             MVPbkOperationObserver& aObserver,
       
    76             MVPbkOperationErrorObserver& aErrorObserver );
       
    77 
       
    78         /**
       
    79          * Cancel everything.
       
    80          * Cancelling will not clear or delete the retrieved contacts from the
       
    81          * array that was given as reference to RetrieveAndLockContactsL.
       
    82          * The client will still have ownership of those fetched contacts.
       
    83          *
       
    84          * The observer will not be called. 
       
    85          */
       
    86         void Cancel();
       
    87 
       
    88     private: // from MVPbkSingleContactOperationObserver
       
    89         void VPbkSingleContactOperationComplete(
       
    90                 MVPbkContactOperationBase& aOperation,
       
    91                 MVPbkStoreContact* aContact );
       
    92         void VPbkSingleContactOperationFailed(
       
    93                 MVPbkContactOperationBase& aOperation, 
       
    94                 TInt aError );
       
    95     private: // from MVPbkContactObserver
       
    96         void ContactOperationCompleted(
       
    97             MVPbkContactObserver::TContactOpResult aResult );
       
    98         void ContactOperationFailed(
       
    99             MVPbkContactObserver::TContactOp aOpCode,
       
   100             TInt aErrorCode, TBool aErrorNotified );
       
   101 
       
   102     private: // new methods
       
   103         void DoSingleContactOperationCompleteL(
       
   104             MVPbkStoreContact* aContact );
       
   105         void DoContactOperationCompletedL();
       
   106         static CVPbkContactLinkArray* CloneLinkArrayL(
       
   107             const MVPbkContactLinkArray& aArray );
       
   108     private:
       
   109         CVPbkContactEasyManager(CVPbkContactManager& aContactManager);
       
   110         CVPbkContactEasyManager();
       
   111     private: // data
       
   112         MVPbkOperationObserver* iObserver; // not owned
       
   113         RPointerArray<MVPbkStoreContact>* iContacts; // not owned
       
   114         CVPbkContactLinkArray* iContactLinks; // owned
       
   115         CVPbkContactManager& iContactManager;
       
   116         MVPbkContactOperationBase* iOperation; // owned
       
   117         TInt iNextContactToLock;
       
   118         TBool iCancelled;
       
   119         
       
   120         MVPbkOperationErrorObserver* iErrorObserver;
       
   121     };
       
   122 
       
   123 #endif /*CVPBKCONTACTEASYMANAGER_H_*/