phonebookengines/VirtualPhonebook/VPbkEng/inc/CVPbkxSPContactsOperation.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:  xSP Contact operation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef VPBKXSPCONTACTSOPERATION_H
       
    20 #define VPBKXSPCONTACTSOPERATION_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <bamdesca.h>
       
    25 #include <badesca.h>
       
    26 #include <MVPbkContactOperationBase.h>
       
    27 #include <MVPbkContactFindFromStoresObserver.h>
       
    28 #include <MVPbkOperationObserver.h>
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class MVPbkContactLinkArray;
       
    32 class CVPbkContactLinkArray;
       
    33 class CVPbkContactManager;
       
    34 class MVPbkBaseContact;
       
    35 class MVPbkStoreContact;
       
    36 class MVPbkContactStore;
       
    37 class CVPbkFieldTypeRefsList;
       
    38 
       
    39 // CLASS DECLARATION
       
    40 
       
    41 /**
       
    42  * Top contact manager operation. One class used for all operations, a new instance 
       
    43  * is created for each client request.
       
    44  */
       
    45 NONSHARABLE_CLASS( CVPbkxSPContactsOperation ) : public CActive,
       
    46     public MVPbkContactOperationBase,
       
    47     public MVPbkContactFindFromStoresObserver
       
    48     {
       
    49     public:
       
    50         /**
       
    51          * xSP contacts operation
       
    52          */
       
    53         enum TxSPOperation
       
    54             {
       
    55             EGetxSPContactLinks
       
    56             };
       
    57         
       
    58     public:
       
    59         /**
       
    60          * Creates a xSP contact manager operation that returns a array of xsp contact links. 
       
    61          * Used to fetch xSP contact links for contact.
       
    62          * 
       
    63          * @param aContactManager Contact manager which already has its stores opened.
       
    64          * @param aObserver Receives array when it's ready
       
    65          * @param aErrorObserver Error observer is notified in case of an error
       
    66          * @param aOperation Valid values EGetxSPContactLinks
       
    67          * 
       
    68          * @return Contact operation handle 
       
    69          */
       
    70         static MVPbkContactOperationBase* NewGetxSPLinksOperationL(
       
    71                 const MVPbkStoreContact& aContact,
       
    72                 CVPbkContactManager& aContactManager,
       
    73                 MVPbkOperationResultObserver<MVPbkContactLinkArray*>& aObserver,
       
    74                 MVPbkOperationErrorObserver& aErrorObserver,
       
    75                 TxSPOperation aOperation );
       
    76         
       
    77         /**
       
    78          * Destructor. Cancels any ongoing requests.
       
    79          */ 
       
    80         ~CVPbkxSPContactsOperation();
       
    81         
       
    82     private: //From CActive
       
    83         void DoCancel();
       
    84         void RunL();
       
    85         TInt RunError( TInt aError );
       
    86         
       
    87     
       
    88     private: //From MVPbkContactFindFromStoresObserver
       
    89         void FindFromStoreSucceededL( MVPbkContactStore& aStore, 
       
    90             MVPbkContactLinkArray* aResultsFromStore );
       
    91         void FindFromStoreFailed( 
       
    92                 MVPbkContactStore& aStore, TInt aError );
       
    93         void FindFromStoresOperationComplete();
       
    94                 
       
    95     private: // construction        
       
    96         static CVPbkxSPContactsOperation* NewLC(
       
    97                 const MVPbkStoreContact& aContact,
       
    98                 CVPbkContactManager& aContactManager,
       
    99                 MVPbkOperationErrorObserver& aErrorObserver,
       
   100                 TxSPOperation aOperation);
       
   101         void ConstructL();
       
   102         CVPbkxSPContactsOperation(
       
   103                 const MVPbkStoreContact& aContact,
       
   104                 CVPbkContactManager& aContactManager,
       
   105                 MVPbkOperationErrorObserver& aErrorObserver,
       
   106                 TxSPOperation aOperation);
       
   107         
       
   108     private: // new methods
       
   109         void GetIMPPDataL( );
       
   110         TBool FindUsingIdL();        
       
   111         static TInt WordParserL( TAny* aWordParserParam );        
       
   112         void ProcessContactLinksL( MVPbkContactLinkArray* aResultsFromStore );        
       
   113         void CompleteOurself();
       
   114         void NotifyResult();        
       
   115         void SubsearchCompleteL();
       
   116         void NotifyError(TInt aErr);
       
   117         void AbortWithError(TInt aErr);
       
   118                 
       
   119     private:        
       
   120         enum TxSPManagementState
       
   121             {
       
   122             EStateNone,
       
   123             EStateFind,
       
   124             EStateAbortWithError
       
   125             };
       
   126         
       
   127     private: // data
       
   128         TxSPManagementState iNextState;
       
   129         const MVPbkStoreContact& iContact; // not owned
       
   130         MVPbkContactLink* iContactLink;  //own
       
   131         CVPbkContactManager& iContactManager; // not owned
       
   132         CVPbkFieldTypeRefsList*  iFieldTypeRefList; // owned
       
   133         CVPbkContactLinkArray* iContactLinks; // owned
       
   134         MVPbkContactOperationBase* iContactOperation; // own
       
   135         CDesCArrayFlat* iXspIdArray; // own        
       
   136         
       
   137         // observers, not owned
       
   138         MVPbkOperationResultObserver<MVPbkContactLinkArray*>* iLinksObserver;
       
   139         MVPbkOperationErrorObserver* iErrorObserver;
       
   140         TInt iAbortError;
       
   141         TInt iNextXspId;
       
   142     };
       
   143 
       
   144 #endif //VPBKXSPCONTACTSOPERATION_H
       
   145 
       
   146 //End of file