--- a/predictivesearch/adapters/contacts/inc/cpcscontactstore.h Mon Mar 15 12:39:26 2010 +0200
+++ b/predictivesearch/adapters/contacts/inc/cpcscontactstore.h Wed Mar 31 21:13:53 2010 +0300
@@ -29,322 +29,335 @@
#include <MVPbkSingleContactOperationObserver.h>
#include <MVPbkContactViewObserver.h>
#include <CVPbkContactManager.h>
-#include <CVPbkContactLinkArray.h>
-// USER INCLUDES
+// USER INCLUDES
#include "mdatastoreobserver.h"
#include "PSContactsAdapterInternalCRKeys.h"
// FORWARD DECLARATIONS
class CPsData;
class CVPbkContactManager;
-class CVPbkContactStoreUriArray;
class CVPbkContactLinkArray;
class MVPbkContactOperationBase;
-class MVPbkContactLinkArray;
class MVPbkBaseContact;
class CVPbkFieldTypeRefsList;
-class CVPbkFieldTypeRefsList;
class MVPbkContactViewObserver;
+class CPbk2SortOrderManager;
+
/**
-* States involved in fetching the contacts
-*/
+ * States involved in fetching the contacts
+ */
enum
{
- ECreateView,
- EFetchContactBlock,
- EComplete
+ ECreateView,
+ EFetchContactBlock,
+ EComplete
};
/**
- * This class represents the data store for the contacts
+ * This class represents the data store for the contacts
* Each data store (phonecontacts, simcontact, group contacts) is an
* instance of this class
* @lib pscontactsadapter.lib
*/
-class CPcsContactStore: public CActive,
+class CPcsContactStore: public CActive,
public MVPbkSingleContactOperationObserver,
public MVPbkContactViewObserver
-
-{
- public:
+
+{
+ public:
+
+ /**
+ * 2 phase construction
+ * @param aContactManager - the contact manager
+ * @param aObserver - observer for receiving data
+ * @param aUri - the data store uri
+ * @return returns pointer to the constructed object of type CPcsContactStore
+ */
+ static CPcsContactStore* NewL(CVPbkContactManager& aContactManager,
+ MDataStoreObserver& aObserver,
+ const TDesC& aUri);
- /**
- * 2 phase construction
- * @param aContactManager - the contact manager
- * @param aObserver - observer for receiving data
- * @param aUri - the data store uri
- * @return returns pointer to the constructed object of type CPcsContactStore
- */
- static CPcsContactStore* NewL(CVPbkContactManager& aContactManager,
- MDataStoreObserver& aObserver,
- const TDesC& aUri);
+ /**
+ * Destructor
+ */
+ virtual ~CPcsContactStore();
+
+ /**
+ * Handles store events (contact/group addition/modification/deletion etc.)
+ * @param aContactStore - the contact store
+ * @param aStoreEvent - store event
+ */
+ void HandleStoreEventL(MVPbkContactStore& aContactStore,
+ TVPbkContactStoreEvent aStoreEvent);
+
+ /**
+ * Gets the store Uri
+ * @return - the store uri supported by this instance
+ */
+ TDesC& GetStoreUri();
+
+ public:
+
+ // From base class MVPbkSingleContactOperationObserver
- /**
- * Destructor
- */
- virtual ~CPcsContactStore();
-
- /**
- * Handles store events (contact/group addition/modification/deletion etc.)
- * @param aContactStore - the contact store
- * @param aStoreEvent - store event
- */
- void HandleStoreEventL(MVPbkContactStore& aContactStore,
- TVPbkContactStoreEvent aStoreEvent);
-
- /**
- * Gets the store Uri
- * @return - the store uri supported by this instance
- */
- TDesC& GetStoreUri();
-
- public:
-
- // From base class MVPbkSingleContactOperationObserver
-
- /**
- * From MVPbkSingleContactOperationObserver
- * Called when operation is completed.
- *
- * @param aOperation the completed operation.
- * @param aContact the contact returned by the operation.
- * Client must take the ownership immediately.
- *
- * !!! NOTICE !!!
- * If you use Cleanupstack for MVPbkStoreContact
- * Use MVPbkStoreContact::PushL or
- * CleanupDeletePushL from e32base.h.
- * (Do Not Use CleanupStack::PushL(TAny*) because
- * then the virtual destructor of the M-class
- * won't be called when the object is deleted).
- */
- void VPbkSingleContactOperationComplete(
- MVPbkContactOperationBase& aOperation,
- MVPbkStoreContact* aContact );
+ /**
+ * From MVPbkSingleContactOperationObserver
+ * Called when operation is completed.
+ *
+ * @param aOperation the completed operation.
+ * @param aContact the contact returned by the operation.
+ * Client must take the ownership immediately.
+ *
+ * !!! NOTICE !!!
+ * If you use Cleanupstack for MVPbkStoreContact
+ * Use MVPbkStoreContact::PushL or
+ * CleanupDeletePushL from e32base.h.
+ * (Do Not Use CleanupStack::PushL(TAny*) because
+ * then the virtual destructor of the M-class
+ * won't be called when the object is deleted).
+ */
+ void VPbkSingleContactOperationComplete(
+ MVPbkContactOperationBase& aOperation,
+ MVPbkStoreContact* aContact );
- /**
- * From MVPbkSingleContactOperationObserver
- * Called if the operation fails.
- *
- * @param aOperation the failed operation.
- * @param aError error code of the failure.
- */
- void VPbkSingleContactOperationFailed(
- MVPbkContactOperationBase& aOperation,
- TInt aError );
-
- public :
+ /**
+ * From MVPbkSingleContactOperationObserver
+ * Called if the operation fails.
+ *
+ * @param aOperation the failed operation.
+ * @param aError error code of the failure.
+ */
+ void VPbkSingleContactOperationFailed(
+ MVPbkContactOperationBase& aOperation,
+ TInt aError );
+
+ public :
+
+ // From base class MVPbkContactViewObserver
+
+ void ContactViewReady(
+ MVPbkContactViewBase& aView );
- // From base class MVPbkContactViewObserver
+ void ContactViewUnavailable(
+ MVPbkContactViewBase& aView );
+
+ void ContactAddedToView(
+ MVPbkContactViewBase& aView,
+ TInt aIndex,
+ const MVPbkContactLink& aContactLink );
+
+ void ContactRemovedFromView(
+ MVPbkContactViewBase& aView,
+ TInt aIndex,
+ const MVPbkContactLink& aContactLink );
+
+ void ContactViewError(
+ MVPbkContactViewBase& aView,
+ TInt aError,
+ TBool aErrorNotified );
- void ContactViewReady(
- MVPbkContactViewBase& aView ) ;
-
- void ContactViewUnavailable(
- MVPbkContactViewBase& aView ) ;
-
- void ContactAddedToView(
- MVPbkContactViewBase& aView,
- TInt aIndex,
- const MVPbkContactLink& aContactLink );
-
- void ContactRemovedFromView(
- MVPbkContactViewBase& aView,
- TInt aIndex,
- const MVPbkContactLink& aContactLink ) ;
-
- void ContactViewError(
- MVPbkContactViewBase& aView,
- TInt aError,
- TBool aErrorNotified ) ;
-
-
- protected:
+ protected:
+
+ // From base class CActive
+
+ /**
+ * From CActive
+ * Implements cancellation of an outstanding request.
+ *
+ * This function is called as part of the active object's Cancel().
+ */
+ void DoCancel();
- // From base class CActive
+ /**
+ * From CActive
+ * Handles an active object's request completion event.
+ *
+ * The function is called by the active scheduler when a request
+ * completion event occurs, i.e. after the active scheduler's
+ * WaitForAnyRequest() function completes.
+ *
+ * Before calling this active object's RunL() function, the active scheduler
+ * has:
+ *
+ * 1. decided that this is the highest priority active object with
+ * a completed request
+ *
+ * 2. marked this active object's request as complete (i.e. the request is no
+ * longer outstanding)
+ *
+ * RunL() runs under a trap harness in the active scheduler. If it leaves,
+ * then the active scheduler calls RunError() to handle the leave.
+ *
+ * Note that once the active scheduler's Start() function has been called,
+ * all user code is run under one of the program's active object's RunL() or
+ * RunError() functions.
+ */
+ void RunL();
- /**
- * From CActive
- * Implements cancellation of an outstanding request.
- *
- * This function is called as part of the active object's Cancel().
- */
- void DoCancel() ;
+ /**
+ * From CActive
+ * If the RunL function leaves,
+ * then the active scheduler calls RunError() to handle the leave.
+ * @param aError - The error code
+ */
+ TInt RunError( TInt aError );
- /**
- * From CActive
- * Handles an active object's request completion event.
- *
- * The function is called by the active scheduler when a request
- * completion event occurs, i.e. after the active scheduler's
- * WaitForAnyRequest() function completes.
- *
- * Before calling this active object's RunL() function, the active scheduler
- * has:
- *
- * 1. decided that this is the highest priority active object with
- * a completed request
- *
- * 2. marked this active object's request as complete (i.e. the request is no
- * longer outstanding)
- *
- * RunL() runs under a trap harness in the active scheduler. If it leaves,
- * then the active scheduler calls RunError() to handle the leave.
- *
- * Note that once the active scheduler's Start() function has been called,
- * all user code is run under one of the program's active object's RunL() or
- * RunError() functions.
- */
- void RunL();
+ private:
+
+ /**
+ * Constructor
+ */
+ CPcsContactStore();
+
+ /**
+ * 2nd phase constructor
+ */
+ void ConstructL(CVPbkContactManager& aContactManager, MDataStoreObserver& aObserver,const TDesC& aUri);
+
+ /**
+ * Handles the operations for a single contact after it is fetched
+ * @param aContact - The contact from database
+ */
+ void HandleRetrievedContactL(MVPbkStoreContact* aContact);
-
- /**
- * From CActive
- * If the RunL function leaves,
- * then the active scheduler calls RunError() to handle the leave.
- * @param aError - The error code
- */
- TInt RunError( TInt aError );
-
- private:
-
- /**
- * Constructor
- */
- CPcsContactStore();
+ /**
+ * Fetches the data from a particular contact
+ * @param aContact - The contact from database
+ *
+ */
+ void GetDataForSingleContactL ( MVPbkBaseContact& aContact, CPsData* aPhoneData );
- /**
- * 2nd phase constructor
- */
- void ConstructL(CVPbkContactManager& aContactManager,MDataStoreObserver& aObserver,const TDesC& aUri);
-
- /**
- * Handles the operations for a single contact after it is fetched
- * @param aContact - The contact from database
- */
- void HandleRetrievedContactL(MVPbkStoreContact* aContact);
+ /**
+ * Add the data from contact fields
+ * @param aContact - The contact from database
+ * @param afieldtype - Field to be added
+ * @param aPhoneData - the contact data in PS format
+ */
+ void AddContactFieldsL(MVPbkBaseContact& aContact, TInt afieldtype, CPsData* aPhoneData);
- /**
- * Fetches the data from a particular contact
- * @param aContact - The contact from database
- *
- */
- void GetDataForSingleContactL ( MVPbkBaseContact& aContact,CPsData* aPhoneData );
-
- /**
- * Add the data from contact fields
- * @param aContact - The contact from database
- * @param afieldtype - Field to be added
- * @param aPhoneData - the contact data in PS format
- */
- void AddContactFieldsL(MVPbkBaseContact& aContact,TInt afieldtype,CPsData* aPhoneData);
+ /**
+ * Fetches the data from contact links from the view
+ */
+ void FetchlinksL();
- /**
- * Fetches the data from contact links from the view
- */
- void FetchlinksL();
-
- /**
- * Reads the fields to cache from the central repository
- */
+ /**
+ * Reads the fields to cache from the central repository
+ */
void ReadFieldsToCacheFromCenrepL();
-
- /**
- * Creates a cacheId corresponding to sim Id Array Index
- * @param - aSimId - The sim id
- */
+
+ /**
+ * Creates a cacheId corresponding to sim Id Array Index
+ * @param - aSimId - The sim id
+ */
TInt CreateCacheIDfromSimArrayIndex(TInt aSimId);
- /**
- * Creates the contact fetch view
- */
- void CreateContactFetchViewL();
- /**
- * Issues request to active object to call RunL method
- */
- void IssueRequest();
-
- /**
- * Creates a sort order depending on the fields specified in the cenrep
- * @param aMasterList - aMasterList (i.e list containing all the vpbk fields)
- */
- void CreateSortOrderL(const MVPbkFieldTypeList& aMasterList);
-
- private:
-
-
- /**
- * Flags for store operations
- */
- TInt iAllContactLinksCount;
- TInt iFetchedContactCount;
- TBool iContactViewReady;
- /**
- * Variable to store the next state for the RunL to take appropriate action
- */
- TInt iNextState;
-
- /**
- * The contact manager for accessing the phone contacts
- * Not Own.
- */
- CVPbkContactManager* iContactManager;
+ /**
+ * Creates the contact fetch view
+ */
+ void CreateContactFetchViewL();
+
+ /**
+ * Issues request to active object to call RunL method
+ */
+ void IssueRequest();
+
+ /**
+ * Creates a sort order depending on the fields specified in the cenrep
+ * @param aMasterList - aMasterList (i.e list containing all the vpbk fields)
+ */
+ void CreateSortOrderL(const MVPbkFieldTypeList& aMasterList);
+
+ /**
+ * Checks if contact is my card
+ */
+ TBool IsMyCard( const MVPbkBaseContact& aContact );
+
+ private:
+
- /**
- * Holds a view base instance
- * Own.
- */
- MVPbkContactViewBase* iContactViewBase;
+ /**
+ * Flags for store operations
+ */
+ TInt iAllContactLinksCount;
+ TInt iFetchedContactCount;
+ TBool iContactViewReady;
+
+ /**
+ * Variable to store the next state for the RunL to take appropriate action
+ */
+ TInt iNextState;
- /**
- * Holds a contact operation
- * Own.
- */
- MVPbkContactOperationBase* iOp;
+ /**
+ * The contact manager for accessing the phone contacts
+ * Not Own.
+ */
+ CVPbkContactManager* iContactManager;
+
+ /**
+ * Holds a view base instance
+ * Own.
+ */
+ MVPbkContactViewBase* iContactViewBase;
/**
- * Owns an instance of active scheduler wait
- */
- CActiveSchedulerWait *iWait;
-
- /**
- * data fields to be cached(read from the central repository)
- */
- RArray<TInt> iFieldsToCache;
-
- /**
- * Array of contact links
- */
- CVPbkContactLinkArray *iSimContactItems;
-
+ * Holds a contact operation
+ * Own.
+ */
+ MVPbkContactOperationBase* iOp;
+
+ /**
+ * Owns an instance of active scheduler wait
+ */
+ CActiveSchedulerWait *iWait;
+
/**
- * Holds the observer object to communicate add/modify/delete of contacts
- * Not owned.
- */
- MDataStoreObserver* iObserver;
-
- /**
- * Contacts Database URI
- */
+ * data fields to be cached(read from the central repository)
+ */
+ RArray<TInt> iFieldsToCache;
+
+ /**
+ * Array of contact links
+ */
+ CVPbkContactLinkArray *iSimContactItems;
+
+ /**
+ * Holds the observer object to communicate add/modify/delete of contacts
+ * Not owned.
+ */
+ MDataStoreObserver* iObserver;
+
+ /**
+ * Contacts Database URI
+ */
HBufC* iUri;
- /**
- * File session
- */
+ /**
+ * File session
+ */
RFs iFs;
+
+ /**
+ * RTimer variable to set the timer before RunL calls any function.
+ * This is required to allow other threads to run since contact fetch
+ * is CPU intensive task.
+ */
+ RTimer iTimer;
+
+ /**
+ * Holds the sort order fields
+ */
+ CVPbkFieldTypeRefsList *iSortOrder;
/**
- * RTimer variable to set the timer before RunL calls any function.
- * This is required to allow other threads to run since contact fetch
- * is CPU intensive task.
- */
- RTimer iTimer;
+ * Holds MyCard supported status
+ */
+ TBool iMyCardSupported;
+
/**
- * Holds the sort order fields
- */
- CVPbkFieldTypeRefsList *iSortOrder;
-
+ * Own. Sort order for all contacts view
+ */
+ CPbk2SortOrderManager* iSortOrderMan;
};
#endif // C_PCS_CONTACT_STORE_H