predictivesearch/adapters/contacts/inc/cpcscontactfetch.h
branchRCL_3
changeset 21 b3431bff8c19
parent 0 e686773b3f54
child 64 c1e8ba0c2b16
equal deleted inserted replaced
15:e8e3147d53eb 21:b3431bff8c19
    25 #include <e32std.h>
    25 #include <e32std.h>
    26 #include <e32cmn.h>
    26 #include <e32cmn.h>
    27 #include <MVPbkContactStoreListObserver.h>
    27 #include <MVPbkContactStoreListObserver.h>
    28 #include <MVPbkContactFindFromStoresObserver.h>
    28 #include <MVPbkContactFindFromStoresObserver.h>
    29 #include <MVPbkSingleContactOperationObserver.h>
    29 #include <MVPbkSingleContactOperationObserver.h>
    30 #include <MVPbkContactViewObserver.h>
    30 
    31 #include <CVPbkContactLinkArray.h>
    31 // USER INCLUDES
    32 
       
    33 // USER INCLUDES 
       
    34 #include "mdatastoreobserver.h"
    32 #include "mdatastoreobserver.h"
    35 #include "cpcscontactstore.h"
    33 #include "cpcscontactstore.h"
    36 #include "PSContactsAdapterInternalCRKeys.h"
    34 #include "PSContactsAdapterInternalCRKeys.h"
    37 
    35 
    38 // FORWARD DECLARATIONS
    36 // FORWARD DECLARATIONS
    39 class CPsData;
       
    40 class CVPbkContactManager;
    37 class CVPbkContactManager;
    41 class CVPbkContactStoreUriArray;
       
    42 class CVPbkContactLinkArray;
       
    43 class MVPbkContactOperationBase;
       
    44 class MVPbkContactLinkArray;
       
    45 class MVPbkBaseContact;
       
    46 class CVPbkFieldTypeRefsList;
       
    47 class MVPbkContactViewObserver;
       
    48 
    38 
    49 
    39 
    50 /**
    40 /**
    51  *  This class is the contact fetch class. 
    41  *  This class is the contact fetch class.
    52  *  This class manages all the data stores defined. 
    42  *  This class manages all the data stores defined.
    53  *  @lib pscontactsadapter.lib
    43  *  @lib pscontactsadapter.lib
    54  */
    44  */
    55 class CPcsContactFetch: public CActive,
    45 class CPcsContactFetch: public CActive,
    56                         public MVPbkContactStoreListObserver
    46                         public MVPbkContactStoreListObserver
    57 
    47 
    58                           
    48 
    59 {	
    49 {
    60 	public:
    50     public:
    61 
    51 
    62 			/**
    52             /**
    63 			* 1st phase constructor 
    53              * 1st phase constructor
    64 			* @return returns pointer to the constructed object of type CPcsContactFetch
    54              * @return returns pointer to the constructed object of type CPcsContactFetch
    65 			*/
    55              */
    66 			static CPcsContactFetch* NewL();
    56             static CPcsContactFetch* NewL();
    67 
    57 
    68 			/**
    58             /**
    69 			* Destructor
    59              * Destructor
    70 			*/
    60              */
    71 			virtual ~CPcsContactFetch();
    61             virtual ~CPcsContactFetch();
    72    
    62 
    73 	public:
    63     public:
    74 	
    64 
    75 			// From base class MVPbkContactStoreListObserver
    65             // From base class MVPbkContactStoreListObserver
    76 
    66 
    77 			/**
    67             /**
    78 			* From MVPbkContactStoreListObserver  
    68              * From MVPbkContactStoreListObserver
    79 			* Called when the opening process is complete, ie. all stores have been reported
    69              * Called when the opening process is complete, ie. all stores have been reported
    80 			* either failed or successfully opened.
    70              * either failed or successfully opened.
    81 			*/
    71              */
    82 			void OpenComplete();  
    72             void OpenComplete();
    83 
    73 
    84 			/**
    74             /**
    85 			* From MVPbkContactStoreListObserver  
    75              * From MVPbkContactStoreListObserver
    86 			* Called when a contact store is ready to use.
    76              * Called when a contact store is ready to use.
    87 			* @param aContactStore - The store that became available.
    77              * @param aContactStore - The store that became available.
    88 			*/
    78              */
    89 			void StoreReady(MVPbkContactStore& aContactStore);
    79             void StoreReady(MVPbkContactStore& aContactStore);
    90 
    80 
    91 			/**
    81             /**
    92 			* From MVPbkContactStoreListObserver  
    82              * From MVPbkContactStoreListObserver
    93 			* Called when a contact store becomes unavailable.
    83              * Called when a contact store becomes unavailable.
    94 			* Client may inspect the reason of the unavailability and decide whether or not
    84              * Client may inspect the reason of the unavailability and decide whether or not
    95 			* it will keep the store opened (ie. listen to the store events).
    85              * it will keep the store opened (ie. listen to the store events).
    96 			* @param aContactStore - The store that became unavailable.
    86              * @param aContactStore - The store that became unavailable.
    97 			* @param aReason - The reason why the store is unavailable.
    87              * @param aReason - The reason why the store is unavailable.
    98 			*                This is one of the system wide error codes.
    88              *                  This is one of the system wide error codes.
    99 			*/
    89              */
   100 			void StoreUnavailable(MVPbkContactStore& aContactStore, TInt aReason);
    90             void StoreUnavailable(MVPbkContactStore& aContactStore, TInt aReason);
   101 
    91 
   102 			/**
    92             /**
   103 			* From MVPbkContactStoreListObserver  
    93              * From MVPbkContactStoreListObserver
   104 			* Called when changes occur in the contact store i.e contact 
    94              * Called when changes occur in the contact store i.e contact
   105 			* added/deleted, group added/deleted etc.
    95              * added/deleted, group added/deleted etc.
   106 			* @see TVPbkContactStoreEvent
    96              * @see TVPbkContactStoreEvent
   107 			* @param aContactStore - The store the event occurred in.
    97              * @param aContactStore - The store the event occurred in.
   108 			* @param aStoreEvent - Event that has occured.
    98              * @param aStoreEvent - Event that has occured.
   109 			*/
    99              */
   110 			void HandleStoreEventL(
   100             void HandleStoreEventL(
   111 			        MVPbkContactStore& aContactStore, 
   101                     MVPbkContactStore& aContactStore,
   112 			        TVPbkContactStoreEvent aStoreEvent);
   102                     TVPbkContactStoreEvent aStoreEvent);
   113 	    
   103 
   114 	public:
   104     public:
   115 		 	/**
   105             /**
   116 		    * Gets the supported data stores URIs
   106              * Gets the supported data stores URIs
   117 		    * @param aDataStoresURIs supported data stores URIs
   107              * @param aDataStoresURIs supported data stores URIs
   118 		    */  
   108              */
   119 		    void GetSupportedDataStoresL( RPointerArray<TDesC> &aDataStoresURIs );
   109             void GetSupportedDataStoresL( RPointerArray<TDesC> &aDataStoresURIs );
   120 		    
   110 
   121 		    /**
   111             /**
   122 		    * Checks if the data store is supported by this adapter
   112              * Checks if the data store is supported by this adapter
   123 		    * @param aDataStoreURI - The datastore to be checked
   113              * @param aDataStoreURI - The datastore to be checked
   124 		    * @return ETrue if this store is supported
   114              * @return ETrue if this store is supported
   125 		    */
   115              */
   126 		    TBool IsDataStoresSupportedL( TDesC& aDataStoreURI );
   116             TBool IsDataStoresSupportedL( TDesC& aDataStoreURI );
   127 
   117 
   128 			/**
   118             /**
   129 			* Initiate data fetch from the contacts adapter
   119              * Initiate data fetch from the contacts adapter
   130 			* @param aDataStoreURI - The store from which data is requested
   120              * @param aDataStoreURI - The store from which data is requested
   131 			*/
   121              */
   132 			void RequestForDataL(TDesC& aDataStoreURI);
   122             void RequestForDataL(TDesC& aDataStoreURI);
   133 
   123 
   134 			/**
   124             /**
   135 			* Set the observer to receive the fetched results
   125              * Set the observer to receive the fetched results
   136 			* @param aObserver - Observer to receive the contacts data
   126              * @param aObserver - Observer to receive the contacts data
   137 			*/
   127              */
   138 			void SetObserver(MDataStoreObserver& aObserver);
   128             void SetObserver(MDataStoreObserver& aObserver);
   139 	
   129 
   140 	public:
   130     public:
   141 			/**
   131             /**
   142 		    * Gets the supported data fields 
   132              * Gets the supported data fields
   143 		    * @param aDataFields - supported data fields         
   133              * @param aDataFields - supported data fields
   144 		    */ 
   134              */
   145 			void GetSupportedDataFieldsL(RArray<TInt> &aDataFields );
   135             void GetSupportedDataFieldsL(RArray<TInt> &aDataFields );
   146 			
   136 
   147 	protected: 
   137     protected:
   148 
   138 
   149 			// From base class CActive
   139             // From base class CActive
   150 
   140 
   151 			/**
   141             /**
   152 			* From CActive
   142              * From CActive
   153 			* Implements cancellation of an outstanding request.
   143              * Implements cancellation of an outstanding request.
   154 			* This function is called as part of the active object's Cancel().
   144              * This function is called as part of the active object's Cancel().
   155 			*/
   145              */
   156 			void DoCancel() ;
   146             void DoCancel();
   157 
   147 
   158 			/**
   148             /**
   159 			* From CActive
   149              * From CActive
   160 			* Handles an active object's request completion event.
   150              * Handles an active object's request completion event.
   161 			*
   151              *
   162 			* The function is called by the active scheduler when a request
   152              * The function is called by the active scheduler when a request
   163 			* completion event occurs, i.e. after the active scheduler's
   153              * completion event occurs, i.e. after the active scheduler's
   164 			* WaitForAnyRequest() function completes.
   154              * WaitForAnyRequest() function completes.
   165 			*
   155              *
   166 			* Before calling this active object's RunL() function, the active scheduler 
   156              * Before calling this active object's RunL() function, the active scheduler
   167 			* has:
   157              * has:
   168 			* 	
   158              *
   169 			* 1. decided that this is the highest priority active object with
   159              * 1. decided that this is the highest priority active object with
   170 			*   a completed request
   160              *   a completed request
   171 			*
   161              *
   172 			* 2. marked this active object's request as complete (i.e. the request is no 
   162              * 2. marked this active object's request as complete (i.e. the request is no
   173 			*   longer outstanding)
   163              *   longer outstanding)
   174 			*
   164              *
   175 			* RunL() runs under a trap harness in the active scheduler. If it leaves,
   165              * RunL() runs under a trap harness in the active scheduler. If it leaves,
   176 			* then the active scheduler calls RunError() to handle the leave.
   166              * then the active scheduler calls RunError() to handle the leave.
   177 			*
   167              *
   178 			* Note that once the active scheduler's Start() function has been called, 
   168              * Note that once the active scheduler's Start() function has been called,
   179 			* all user code is run under one of the program's active object's RunL() or 
   169              * all user code is run under one of the program's active object's RunL() or
   180 			* RunError() functions.
   170              * RunError() functions.
   181 			*/
   171              */
   182 			void RunL();
   172             void RunL();
   183 
   173 
   184 				
   174 
   185 			/**
   175             /**
   186 			* From CActive 
   176              * From CActive
   187 			* If the RunL function leaves,
   177              * If the RunL function leaves,
   188 			* then the active scheduler calls RunError() to handle the leave.
   178              * then the active scheduler calls RunError() to handle the leave.
   189 			* @param aError - The error code
   179              * @param aError - The error code
   190 			*/
   180              */
   191 			TInt RunError( TInt aError );
   181             TInt RunError( TInt aError );
   192 		
   182 
   193 	private:	
   183     private:
   194 	
   184 
   195 			/**
   185             /**
   196 			* Constructor
   186              * Constructor
   197 			*/
   187              */
   198 			CPcsContactFetch();
   188             CPcsContactFetch();
   199 
   189 
   200 			/** 
   190             /**
   201 			* 2nd phase constructor
   191              * 2nd phase constructor
   202 			*/
   192              */
   203 			void ConstructL();
   193             void ConstructL();
   204 
   194 
   205 			/**
   195             /**
   206 			* Fetches the data from a particular contact 
   196              * Creates the substore
   207 			* @param aContact - The contact from database 
   197              * @param aDataStoreURI - The store for which substore is to be created
   208 			* @param aPhoneData - The contact in CPsData format 
   198              */
   209 			*/
   199              void CreateSubStoresL(TDesC& aDataStoreURI);
   210 			void  GetDataForSingleContactL ( MVPbkBaseContact& aContact,CPsData* aPhoneData );
   200 
   211 
   201             /**
   212 
   202              * Reads the configured URIs from the central repository
   213 			/**
   203              */
   214 			* Creates the substore 
       
   215 			* @param aDataStoreURI - The store for which substore is to be created
       
   216 			*/
       
   217  			void CreateSubStoresL(TDesC& aDataStoreURI);
       
   218             
       
   219             
       
   220             /**
       
   221 			* Reads the configured URIs from the central repository
       
   222 			*/
       
   223             void ReadUrisFromCenrepL();
   204             void ReadUrisFromCenrepL();
   224             
   205 
   225 	private:
   206     private:
   226 	
   207 
   227 	        /**
   208             /**
   228 			 * Holds the observer object to communicate add/modify/delete of contacts
   209              * Holds the observer object to communicate add/modify/delete of contacts
   229 			 * Not owned.
   210              * Not owned.
   230 			 */
   211              */
   231 			MDataStoreObserver* iObserver;
   212             MDataStoreObserver* iObserver;
   232 	    
   213 
   233 	    	/**
   214             /**
   234              * Owns an instance of active scheduler wait
   215              * Owns an instance of active scheduler wait
   235              */
   216              */
   236     	    CActiveSchedulerWait *iWait;
   217             CActiveSchedulerWait *iWait;
   237     	      
   218 
   238 			/**
   219             /**
   239 			 * Flags for store operations
   220              * Flags for store operations
   240 			 */
   221              */
   241 			TBool   iAtLeastOneStoreReady; 
   222             TBool iAtLeastOneStoreReady;
   242 			TBool   iNoContactStoreAvailable;
   223             TBool iNoContactStoreAvailable;
   243 			TBool   iRequestForData;
   224             TBool iRequestForData;
   244 			TBool   iSubStoreCreated;
   225             TBool iSubStoreCreated;
   245 
   226 
   246 			/**
   227             /**
   247 			 * The contact manager for accessing the phone contacts
   228              * The contact manager for accessing the phone contacts
   248 			 * Own.  
   229              * Own.
   249 			 */
   230              */
   250 			CVPbkContactManager*  iContactManager;		
   231             CVPbkContactManager*  iContactManager;
   251 
   232 
   252 			/**
   233             /**
   253              * Uris(data stores) read from the central repository
   234              * Uris(data stores) read from the central repository
   254              */
   235              */
   255     	    RPointerArray<HBufC> iUriFromCenrep;
   236             RPointerArray<HBufC> iUriFromCenrep;
   256 
   237 
   257 			/**
   238             /**
   258              * Data stores instances
   239              * Data stores instances
   259              */
   240              */
   260     	    RPointerArray<CPcsContactStore> iAllDataStores;
   241             RPointerArray<CPcsContactStore> iAllDataStores;
   261    
       
   262 };
   242 };
   263 
   243 
   264 #endif // C_PCS_CONTACT_FETCH_H
   244 #endif // C_PCS_CONTACT_FETCH_H