phonebookengines/VirtualPhonebook/VPbkVCardEng/inc/CVPbkImportToContactsMergeOperation.h
branchRCL_3
changeset 17 2666d9724c76
parent 0 e686773b3f54
--- a/phonebookengines/VirtualPhonebook/VPbkVCardEng/inc/CVPbkImportToContactsMergeOperation.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkVCardEng/inc/CVPbkImportToContactsMergeOperation.h	Thu Jul 15 18:22:55 2010 +0300
@@ -25,6 +25,8 @@
 #include <MVPbkSingleContactOperationObserver.h>
 #include <MVPbkContactObserver.h>
 #include <MVPbkContactOperation.h>
+#include <MVPbkContactAttributeManager.h>
+#include <VPbkFieldType.hrh>
 #include "MVPbkImportOperationImpl.h"
 #include "CVPbkGroupCardHandler.h"
 #include "MVPbkContactCopyObserver.h"
@@ -42,7 +44,7 @@
 class CVPbkVCardEng;
 class CVPbkVCardImporter;
 class CVPbkContactManager;
-
+class MVPbkSetAttributeObserver;
 /**
  *  An operation for Updating a contact in the store
  */
@@ -51,7 +53,8 @@
         public MVPbkContactOperation,
         public MVPbkImportOperationObserver,
         public MVPbkSingleContactOperationObserver,
-        public MVPbkContactObserver
+        public MVPbkContactObserver,
+        public MVPbkSetAttributeObserver
     {
 public:
      static CVPbkImportToContactsMergeOperation *NewL( 
@@ -62,24 +65,24 @@
              RReadStream& aSourceStream, 
              MVPbkSingleContactOperationObserver& aObserver );
 
-	/**
-	* Destructor.
-	*/
+    /**
+    * Destructor.
+    */
     ~CVPbkImportToContactsMergeOperation();
         
 protected: // CActive
-	/**
-	* From CActive. Called when asynchronous operation completes.
-	*/
+    /**
+    * From CActive. Called when asynchronous operation completes.
+    */
     void RunL();
-	/**
-	* From CActive. Called when RunL leaves.
-	*/    
+    /**
+    * From CActive. Called when RunL leaves.
+    */    
 
     TInt RunError( TInt aError );
-	/**
-	* From CActive. Cancels operation.
-	*/
+    /**
+    * From CActive. Cancels operation.
+    */
 
     void DoCancel();        
 
@@ -91,56 +94,56 @@
             MVPbkContactStore& aTargetStore,
             CVPbkVCardData & aData
             );
-	/**
-	* Second phase constructor.
-	*/
+    /**
+    * Second phase constructor.
+    */
     void ConstructL( TVPbkImportCardType aType, RReadStream& aSourceStream);
 
 public:
     // from base class MVPbkImportOperationObserver
       /**
-		* From MVPbkImportOperationObserver  
-		* Called when a contact import operation has Completed.
-		*/
+        * From MVPbkImportOperationObserver  
+        * Called when a contact import operation has Completed.
+        */
      void ContactsImported();
       /**
-		* From MVPbkImportOperationObserver  
-		* Called when a contact import operation has failed.
-		*/
+        * From MVPbkImportOperationObserver  
+        * Called when a contact import operation has failed.
+        */
      void ContactImportingFailed( TInt aError );
       /**
-		* From MVPbkImportOperationObserver  
-		* Called when a contact import operation has Completed Fully.
-		*/
+        * From MVPbkImportOperationObserver  
+        * Called when a contact import operation has Completed Fully.
+        */
      void ContactsImportingCompleted();
         
 public:
     // from base class MVPbkContactOperation
      /**
-		* From MVPbkContactOperation  
-		* Called when a contact operation has to be started
-		*/
+        * From MVPbkContactOperation  
+        * Called when a contact operation has to be started
+        */
      void StartL();
       /**
-		* From MVPbkContactOperation  
-		* Called when a contact operation has to be cancled
-		*/
+        * From MVPbkContactOperation  
+        * Called when a contact operation has to be cancled
+        */
      void Cancel();
      
 public: // from MVPbkSingleContactOperationObserver
 
-	/**
-		* From MVPbkSingleContactOperationObserver  
-		* Called when the contact operation is complete
-		* Client takes Ownership in deleting returned aContact.
-		*/
+    /**
+        * From MVPbkSingleContactOperationObserver  
+        * Called when the contact operation is complete
+        * Client takes Ownership in deleting returned aContact.
+        */
     void VPbkSingleContactOperationComplete(
                     MVPbkContactOperationBase& aOperation,
                     MVPbkStoreContact* aContact );
     /**
-		* From MVPbkSingleContactOperationObserver  
-		* Called when the contact operation fails
-		*/                
+        * From MVPbkSingleContactOperationObserver  
+        * Called when the contact operation fails
+        */                
     void VPbkSingleContactOperationFailed(
                     MVPbkContactOperationBase& aOperation, 
                     TInt aError );
@@ -148,25 +151,45 @@
 
     // from MVPbkContactObserver
     /**
-		* From MVPbkContactObserver  
-		* Called when a contact operation has succesfully completed.
-		* Client takes Ownership in deleting returned aResult.
-		*/
+        * From MVPbkContactObserver  
+        * Called when a contact operation has succesfully completed.
+        * Client takes Ownership in deleting returned aResult.
+        */
     void ContactOperationCompleted(TContactOpResult aResult);
     /**
-		* From MVPbkContactObserver  
-		* Called when a contact operation has failed.
-		*/
+        * From MVPbkContactObserver  
+        * Called when a contact operation has failed.
+        */
     void ContactOperationFailed
                 (TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified);
     
+
+private:
+
+    // from MVPbkSetAttributeObserver
+    /**
+        * From MVPbkSetAttributeObserver  
+        * Called when a set attribute operation has succesfully completed.
+        * Client takes Ownership in deleting returned aResult.
+        */
+    void AttributeOperationComplete( MVPbkContactOperationBase& aOperation );
+    /**
+        * From MVPbkSetAttributeObserver  
+        * Called when a set attribute operation has failed.
+        */
+    void AttributeOperationFailed(
+            MVPbkContactOperationBase& aOperation,
+            TInt aError );
+    
 private: // types
-	enum TState
-		{
+    enum TState
+        {
         EImport,
         ERetrieve,
         ELock,
+        EUpdateContact,
         EReplaceFields,
+        ESetAttributes,
         ECommit,
         EReRetrieve, //Reload contact to have valid lastmodified datetime
         EComplete
@@ -174,61 +197,81 @@
 
 private:    
     void NextState( TState aNextState );
-	/**
-	* Retrive the contact to be updated
-	*/
+    /**
+    * Retrive the contact to be updated
+    */
     void RetrieveContactL();
-	/**
-	* Lock the contact for editing
-	*/
+    /**
+    * Lock the contact for editing
+    */
     void LockContactL();
     /**
-	* Commit the updated contact
-	*/
+    * Commit the updated contact
+    */
     void CommitContactL();
-	/**
-	* Update imported contacts
-	*/
+    /**
+    * Update imported contacts
+    */
     void UpdateContactL();
-	/**
-	* Retrieve the contact after updation
-	*/
+    /**
+    * Retrieve the contact after updation
+    */
     void ReRetrieveContactL();
     
     void HandleError(TInt aError);
     void HandleContactReplacing(MVPbkStoreContact* aContact);
-	/**
-	* Replace the fields of target contact
-	*/
-    void ReplaceContactL( const MVPbkStoreContact& aSrc, MVPbkStoreContact& aTarget );
-	/**
-	* Copy the fields of source contact to target contact
-	*/
+    /**
+    * Replace the fields of target contact
+    */
+    void ReplaceFieldL( const MVPbkStoreContact& aSrc, MVPbkStoreContact& aTarget );
+    /**
+    * Copy the fields of source contact to target contact
+    */
     void CopyFieldL( const MVPbkStoreContactField& aSourceField,
-    		const MVPbkFieldType& aType,
+            const MVPbkFieldType& aType,
             MVPbkStoreContact& aTargetContact );
-    
+    /**
+    * Gets the attributes from aField
+    */
+    void GetDefaultAttributsL( const MVPbkStoreContactField& aField );
+    /**
+    * Return the attribute which is to be set
+    */
+    TVPbkDefaultType NextAttribute();
+    /**
+    * Set the attribute to the target contect field
+    */
+    void SetNextL();
+
 private: // data
-	/// Own: state
-	TState iState;
+    /// Own: state
+    TState iState;
     /// Own: the imported contacts
     RPointerArray<MVPbkStoreContact> iImportedContacts;
     /// Own: the implementation of the import operation
     MVPbkImportOperationImpl* iOperationImpl;
     /// Ref: the target store of the operation
     MVPbkContactStore& iTargetStore;
-    //Ref: Vcard Data
+    /// Ref: Vcard Data
     CVPbkVCardData& iData;
-	/// Ref: contact to replace
-	const MVPbkContactLink& iReplaceContact;
+    /// Ref: contact to replace
+    const MVPbkContactLink& iReplaceContact;
     /// Own: current contact
     MVPbkStoreContact* iContact;
     /// Ref: client that waits importing
     MVPbkSingleContactOperationObserver& iObserver;
     /// Own: the operation for import and retrieve
     MVPbkContactOperationBase* iVPbkOperation;
-    //Own: Group Card Handler
+    /// Own: Group Card Handler
     CVPbkGroupCardHandler* iGroupcardHandler;
+    /// Own: the operation for set attribute
+    MVPbkContactOperationBase* iSetAttributeOperation;
+    /// Own: the array of one field's attributes
+    CArrayFixFlat<TVPbkDefaultType>* iDefaultAttributes;
+    /// The index of the current operated field 
+    TInt iCurrentFieldIndex;
+    /// The field count of the source contact
+    TInt iFieldCount;
     };
 
 #endif