serviceproviders/sapi_contacts_vpbk/contactservice/inc/contactviewobserver.h
changeset 5 989d2f495d90
child 10 fc9cf246af83
equal deleted inserted replaced
1:a36b1e19a461 5:989d2f495d90
       
     1 /*
       
     2 * Copyright (c) 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 the License "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:  View observer for getlist Service API of contactservice.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_CONTACTVIEWOBSERVER_H
       
    22 #define C_CONTACTVIEWOBSERVER_H
       
    23 
       
    24 
       
    25 #include <MVPbkContactViewObserver.h>
       
    26 #include <MVPbkContactLinkArray.h>
       
    27 #include "contactretrieveobserver.h"
       
    28 
       
    29 class CContactService;
       
    30 
       
    31 /**
       
    32   * View Flag is required so as to differentiate the callbacks, 
       
    33   * since the callback is called twice.
       
    34   */
       
    35 enum TViewFlag
       
    36     {
       
    37 	EContactDefaultView=0,
       
    38 	EContactFilteredView
       
    39     };
       
    40 
       
    41 /**
       
    42   * This class has methods for handling events after the view on a database is set.
       
    43   */
       
    44 
       
    45 class CContactViewObserver:public CBase, 
       
    46 						   public MVPbkContactViewObserver,
       
    47 						   public MCancelAsync
       
    48 {
       
    49 public:
       
    50     static CContactViewObserver* NewL(MContactCallback* aCallback, 
       
    51                                       enum TViewFlag aFlag, 
       
    52                                       CContactIter* iIter, 
       
    53                                       CContactService* aContactService,
       
    54                                       const TDesC& aStoreUri, 
       
    55                                       TOrder aSortOrder, 
       
    56                                       TInt aTransId, 
       
    57                                       CActiveSchedulerWait* aSchedulerWait);
       
    58 
       
    59 
       
    60 
       
    61 /**
       
    62   * Methods to handle Contact Database View Setup events
       
    63   */
       
    64 	void ContactViewReady( MVPbkContactViewBase& aView );
       
    65   
       
    66     void ContactViewUnavailable( MVPbkContactViewBase& aView ) ;
       
    67   
       
    68     void ContactAddedToView(MVPbkContactViewBase& aView, 
       
    69                             TInt aIndex, 
       
    70                             const MVPbkContactLink& aContactLink );
       
    71   
       
    72     void ContactRemovedFromView(MVPbkContactViewBase& aView, 
       
    73                                 TInt aIndex, 
       
    74                                 const MVPbkContactLink& aContactLink );
       
    75   
       
    76     void ContactViewError(MVPbkContactViewBase& aView, 
       
    77                           TInt aError, 
       
    78                           TBool aErrorNotified ) ;
       
    79     
       
    80 	CContactViewObserver( const TDesC& aStoreUri, 
       
    81 	                     enum TViewFlag aFlag, 
       
    82 	                     CContactIter* aIter, 
       
    83 	                     CContactService* aContactService,
       
    84 	                     MContactCallback* aCallback,
       
    85 	                     TOrder aSortOrder, 
       
    86 	                     TInt aTransId, 
       
    87 	                     CActiveSchedulerWait* aSchedulerWait);
       
    88 	
       
    89 	void ReturnDefaultView();
       
    90 
       
    91 	/*
       
    92 	 * Implementation of Cancel of MCancelAsync
       
    93 	 */
       
    94 	void Cancel();
       
    95 	
       
    96 private:
       
    97 	
       
    98 /** 
       
    99   *A method to setup the link array for the iterator to iterate over
       
   100   */
       
   101 	void SetupContactLinkArrayL(MVPbkContactViewBase& aView );
       
   102 
       
   103 private: 
       
   104 	//Store Uri 
       
   105 	const TDesC* iStoreUri;
       
   106 	
       
   107 	//Flag to determine the type of view
       
   108 	TViewFlag iFlag;
       
   109 	
       
   110 	//Iterator - Output param
       
   111 	CContactIter* iIter;
       
   112 	
       
   113 	//Callback Function
       
   114 	MContactCallback* iCallback;
       
   115 	
       
   116 	//The order in which the result shud appear
       
   117 	TOrder iSortOrder;
       
   118 	
       
   119 	//Transaction Id
       
   120 	TInt iTransId;
       
   121 	
       
   122 	//To give default view of the database
       
   123 	TBool iDefaultView;
       
   124 	
       
   125 	//For Stopping async calls
       
   126 	CActiveSchedulerWait* iSchedulerWait;
       
   127 	
       
   128 	//View handle
       
   129 	MVPbkContactViewBase* iView;
       
   130 	
       
   131 	//ContactService Handle
       
   132 	CContactService* iContactService;
       
   133 
       
   134 };
       
   135 
       
   136 #endif//C_CONTACTVIEWOBSERVER_H