Revision: 201025 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 15 Jul 2010 18:22:55 +0300
branchRCL_3
changeset 17 2666d9724c76
parent 15 34879f5cfc63
child 18 d4f567ce2e7c
Revision: 201025 Kit: 2010127
contacts_plat/cca_launch_api/tsrc/group/bld.inf
logsui/AppSrc/CLogsBaseView.cpp
logsui/AppSrc/CLogsRecentListView.cpp
phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CCustomFilteredContactView.h
phonebookengines/VirtualPhonebook/VPbkCntModel/src/CCustomFilteredContactView.cpp
phonebookengines/VirtualPhonebook/VPbkCntModel/src/CFilteredContactView.cpp
phonebookengines/VirtualPhonebook/VPbkCntModel/src/CFilteredGroupView.cpp
phonebookengines/VirtualPhonebook/VPbkCntModel/src/CViewBase.cpp
phonebookengines/VirtualPhonebook/VPbkVCardEng/inc/CVPbkGroupCardHandler.h
phonebookengines/VirtualPhonebook/VPbkVCardEng/inc/CVPbkImportToContactsMergeOperation.h
phonebookengines/VirtualPhonebook/VPbkVCardEng/inc/CVPbkVCardData.h
phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkGroupCardHandler.cpp
phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkImportToContactsMergeOperation.cpp
phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkImportToStoreOperation.cpp
phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkVCardData.cpp
phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkVCardImporter.cpp
phonebookui/Phonebook2/CommandsExtension/inc/CPbk2MergeConflict.h
phonebookui/Phonebook2/CommandsExtension/inc/CPbk2MergeResolver.h
phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeConflict.cpp
phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeContactsCmd.cpp
phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeResolver.cpp
phonebookui/Phonebook2/GroupExtension/src/CPguAddMembersCmd.cpp
phonebookui/Phonebook2/MMCExtension/inc/CPmuCopyFromMmcCmd.h
phonebookui/Phonebook2/MMCExtension/src/CPmuCopyFromDriveCmd.cpp
phonebookui/Phonebook2/MapExtension/inc/cpmapcmd.h
phonebookui/Phonebook2/MapExtension/src/cpmapcmd.cpp
phonebookui/Phonebook2/ServerApplication/inc/CPbk2ItemFetcher.h
phonebookui/Phonebook2/ServerApplication/inc/TPbk2ServerMessageDataRetriever.h
phonebookui/Phonebook2/ServerApplication/src/CPbk2CommAddressSelectPhase.cpp
phonebookui/Phonebook2/ServerApplication/src/CPbk2ItemFetcher.cpp
phonebookui/Phonebook2/ServerApplication/src/TPbk2ServerMessageDataRetriever.cpp
phonebookui/Phonebook2/UIControls/inc/cpbk2contactviewdoublelistboxmodel.h
phonebookui/Phonebook2/UIControls/inc/pbk2contactviewdoublelistboxdataelement.h
phonebookui/Phonebook2/UIControls/src/CPbk2AdaptiveSearchGridFiller.cpp
phonebookui/Phonebook2/UIControls/src/CPbk2ContactViewListBox.cpp
phonebookui/Phonebook2/UIControls/src/cpbk2contactviewdoublelistbox.cpp
phonebookui/Phonebook2/UIControls/src/cpbk2contactviewdoublelistboxmodel.cpp
phonebookui/Phonebook2/UIControls/src/cpbk2doublelistboxmodelcmddecorator.cpp
phonebookui/Phonebook2/UIControls/src/pbk2contactviewdoublelistboxdataelement.cpp
phonebookui/Phonebook2/UIServices/src/CPbk2AiwSelectionProvider.cpp
phonebookui/Phonebook2/USIMExtension/inc/CPsu2CopyAllToPbkCmd.h
phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimFixedDialingView.rss
phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimInformation.rss
phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimTextBuffers.rss
phonebookui/Phonebook2/USIMExtension/src/CPsu2CopyAllToPbkCmd.cpp
phonebookui/Phonebook2/USIMExtension/src/CPsu2UIExtensionPlugin.cpp
phonebookui/Phonebook2/USIMThinExtension/src/CPsu2CheckAvailabeSimStore.cpp
phonebookui/Phonebook2/USIMThinExtension/src/CPsu2CopySimContactsCmd.cpp
phonebookui/Phonebook2/USIMThinExtension/src/CPsu2ThinUIExtensionPlugin.cpp
phonebookui/Phonebook2/ccapplication/ccacontactorservice/group/ccacontactorservice.mmp
phonebookui/Phonebook2/ccapplication/ccacontactorservice/inc/ccacontactorserviceheaders.h
phonebookui/Phonebook2/ccapplication/ccacontactorservice/src/ccacontactorpopuphandler.cpp
phonebookui/Phonebook2/group/Pbk2USimExtension.mmp
phonebookui/Phonebook2/loc/phonebook2.loc
phonebookui/Phonebook2/spbcontentprovider/src/spbphonenumberparser.cpp
--- a/contacts_plat/cca_launch_api/tsrc/group/bld.inf	Mon Jun 21 15:24:27 2010 +0300
+++ b/contacts_plat/cca_launch_api/tsrc/group/bld.inf	Thu Jul 15 18:22:55 2010 +0300
@@ -17,6 +17,5 @@
 
 
 #include "../cca_launch_api/group/bld.inf"
-#include "../ut_ccapbk_contextlauncher/group/bld.inf"
 
 //  End of File
--- a/logsui/AppSrc/CLogsBaseView.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/logsui/AppSrc/CLogsBaseView.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -1352,6 +1352,7 @@
                 {
                 TInt commandId( Cba()->ButtonGroup()->CommandId(
                         CEikButtonGroupContainer::EMiddleSoftkeyPosition ) );
+                ConstructDelayedL( EFalse );               
                 ProcessCommandL( commandId );
                 break;
                 }
--- a/logsui/AppSrc/CLogsRecentListView.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/logsui/AppSrc/CLogsRecentListView.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -526,7 +526,20 @@
         {
         // Just to make sure the inputblocker is not on
         RemoveInputBlocker();
-        CurrentModel()->DoActivateL( MLogsModel::EResetAndRefresh );
+        TRAPD( err, CurrentModel()->DoActivateL( MLogsModel::EResetAndRefresh ));   
+        if( err ) 
+            {
+            iCoeEnv->HandleError( err );
+            }
+        if( err == KErrDiskFull )
+            {
+            RWsSession& wsSession = CCoeEnv::Static()->WsSession();  
+            TApaTask logsui( wsSession );
+            TInt wgId = CCoeEnv::Static()->RootWin().WindowGroupId();
+            logsui.SetWgId( wgId );
+            logsui.KillTask();  
+            return;	
+            }
         
         // By default on gaining foreground, just refresh the list. So when active applications list, 
         // keylock or some note (like when plugin in the charger) is shown the list doesn't flicker. 
@@ -848,6 +861,15 @@
                     {
                     iCoeEnv->HandleError( err );
                     }
+                if( err == KErrDiskFull )
+                    {
+                    RWsSession& wsSession = CCoeEnv::Static()->WsSession();  
+                    TApaTask logsui( wsSession );
+                    TInt wgId = CCoeEnv::Static()->RootWin().WindowGroupId();
+                    logsui.SetWgId( wgId );
+                    logsui.KillTask();  
+                    return;
+                    }
                 
                 // By default on gaining foreground, just refresh the list. So when active applications list, 
                 // keylock or some note (like when plugin in the charger) is shown the list doesn't flicker. 
--- a/phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CCustomFilteredContactView.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CCustomFilteredContactView.h	Thu Jul 15 18:22:55 2010 +0300
@@ -75,6 +75,8 @@
          */
         ~CCustomFilteredContactView();
 
+        void SetFieldTypeSelector( const MVPbkFieldTypeSelector* aFieldTypeSelector );
+        
     public: // Interface
 
         /**
--- a/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CCustomFilteredContactView.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CCustomFilteredContactView.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -69,6 +69,17 @@
     }
 
 // --------------------------------------------------------------------------
+// CCustomFilteredContactView::SetFieldTypeSelector
+// --------------------------------------------------------------------------
+//
+void CCustomFilteredContactView::SetFieldTypeSelector( 
+        const MVPbkFieldTypeSelector* aFieldTypeSelector )
+    {
+    iFieldTypeSelector = aFieldTypeSelector;
+    }
+
+
+// --------------------------------------------------------------------------
 // CCustomFilteredContactView::~CCustomFilteredContactView
 // --------------------------------------------------------------------------
 //
--- a/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CFilteredContactView.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CFilteredContactView.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -378,9 +378,26 @@
         const CFieldFactory& fieldFactory = Store().FieldFactory();
 
         // Copy construct the filter
-        iFilter = CVPbkFieldTypeSelector::NewL(
+        CVPbkFieldTypeSelector* filter = CVPbkFieldTypeSelector::NewL(
                 *aViewDefinition.FieldTypeFilter() );
-
+        if ( iFilter )
+            {
+            delete iFilter;
+            iFilter = NULL;
+            }
+        
+        iFilter = filter;
+        filter = NULL;
+        
+        // whenever a new iFilter created, set it as new fieldTypeSelector
+        // iCustomFilteredView, to avoid such case that new iFilter created
+        // but iCustomFilteredView is still the old one using the old iFilter,
+        // it will panic since the old iFilter is deleted.
+        if ( iCustomFilteredView )
+            {
+            iCustomFilteredView->SetFieldTypeSelector( iFilter );
+            }
+        
         iNativeFilter = ConvertFieldTypeFilterL
             ( *iFilter, fieldFactory, iFs, iCustomFilteringNeeded );
         }
@@ -397,9 +414,18 @@
         // Construction of the iCustomFilteredView should be done in two
         // phases. Due to that there is dependencies between views in this
         // and iCustomFilteredView class.
-        iCustomFilteredView =
-            new (ELeave) CCustomFilteredContactView( Store(), iFilter,
+
+        CCustomFilteredContactView* customFilteredView = new (ELeave) CCustomFilteredContactView( Store(), iFilter,
                 *this, aViewDefinition.ContactSelector() );
+        
+        if ( iCustomFilteredView )
+            {
+            delete iCustomFilteredView;
+            iCustomFilteredView = NULL;
+            }
+        iCustomFilteredView = customFilteredView;
+        customFilteredView = NULL;
+        
         ConstructBaseViewsL( aViewDefinition, *iCustomFilteredView,
                 aViewSortOrder );
 
@@ -642,6 +668,7 @@
         }
     else
         {
+     
         iBaseView = CContactLocalView::NewL( *iNativeObserver,
                 Store().NativeDatabase(), aViewSortOrder,
                 KVPbkDefaultContactViewPrefs );
--- a/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CFilteredGroupView.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CFilteredGroupView.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -142,9 +142,18 @@
     // Construction of the iCustomFilteredView should be done in two 
     // phases. Due to that there is dependencies between views in this 
     // and iCustomFilteredView class.
-    iCustomFilteredView = 
+    CCustomFilteredGroupView* customFilteredView = 
         new (ELeave) CCustomFilteredGroupView( Store(), iFilter, 
             *this );
+    
+    if ( iCustomFilteredView )
+        {
+        delete iCustomFilteredView;
+        iCustomFilteredView = NULL;
+        }
+    iCustomFilteredView = customFilteredView;
+    customFilteredView = NULL;
+    
     ConstructBaseViewsL( aViewDefinition, *iCustomFilteredView, 
             aViewSortOrder );
             
--- a/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CViewBase.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CViewBase.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -246,7 +246,7 @@
     {
     TInt result = KErrNotFound;
 
-    if (&aContactLink.ContactStore() == &ContactStore())
+    if (&aContactLink.ContactStore() == &ContactStore() && iView )
         {
         const CContactLink& link = static_cast<const CContactLink&>(aContactLink);
         result = iView->FindL(link.ContactId());
@@ -773,8 +773,16 @@
         const CVPbkContactViewDefinition& aViewDefinition,
         const MVPbkFieldTypeList& aSortOrder )
     {
-    iCurrentContact = CViewContact::NewL( *this, aSortOrder );
-
+    
+    CViewContact* vievContact = CViewContact::NewL( *this, aSortOrder );
+    if ( iCurrentContact )
+        {
+        delete iCurrentContact;
+        iCurrentContact = NULL;
+        }
+    iCurrentContact = vievContact;
+    vievContact = NULL;
+    
     RContactViewSortOrder viewSortOrder = CreateSortOrderL( aSortOrder );
     CleanupClosePushL( viewSortOrder );
 
@@ -795,8 +803,15 @@
 
     CleanupStack::PopAndDestroy(); // viewSortOrder
 
-    iEventLink = CContactLink::NewLC( iParentStore, KNullContactId );
-    CleanupStack::Pop( iEventLink );
+    CContactLink* contactLink= CContactLink::NewLC( iParentStore, KNullContactId );
+    CleanupStack::Pop( contactLink );
+    if ( iEventLink )
+        {
+        delete iEventLink;
+        iEventLink = NULL;
+        }
+    iEventLink = contactLink;
+    contactLink = NULL;
     }
 
 // --------------------------------------------------------------------------
--- a/phonebookengines/VirtualPhonebook/VPbkVCardEng/inc/CVPbkGroupCardHandler.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkVCardEng/inc/CVPbkGroupCardHandler.h	Thu Jul 15 18:22:55 2010 +0300
@@ -36,6 +36,7 @@
 #include "CVPbkVCardParserParamArray.h"
 #include "CVPbkVCardData.h"
 
+class MVPbkContactOperationBase;
 
 //Group Card Example
 
@@ -90,25 +91,31 @@
     /**
      * Set the contactLink as Group Store Contact
      * @param  aContactLink  VPBK contact Link
-     *								
+     * @param aSelfPointer The self pointer is set to NULL if this instance is
+     *                     deleted while this function is running.								
      */
-    void GetContactGroupStoreL(const MVPbkContactLink& aContactLink);
+    void GetContactGroupStoreL(const MVPbkContactLink& aContactLink, 
+            CVPbkGroupCardHandler** aSelfPointer = NULL);
 
     /**
      * Decodes the Current Group Card Field to add the contact to exisiting group Or New Group.
      * @param  aValue  Value parm of the Group Card Property
-     *								
+     * @param aSelfPointer The self pointer is set to NULL if this instance is
+     *                     deleted while this function is running.								
      */
-    void DecodeContactGroupInVCardL(TPtr16 aValue);
+    void DecodeContactGroupInVCardL(TPtr16 aValue, 
+            CVPbkGroupCardHandler** aSelfPointer = NULL);
 
     /**
      * Builds the Hash Table with Key as "Group Name" and "VBPK Store Pointer" as Value.
      * This table is used to Find whether a Group is existing or not in current VPBK.
      * @param  aTargetContactStore  VPBK ContactStore.
-     *								
+     * @param aSelfPointer The self pointer is set to NULL if this instance is
+     *                     deleted while this function is running.							
      */
 
-    void BuildContactGroupsHashMapL(MVPbkContactStore& aTargetContactStore);
+    void BuildContactGroupsHashMapL(MVPbkContactStore& aTargetContactStore, 
+            CVPbkGroupCardHandler** aSelfPointer = NULL);
 
     /**
      * Remvoes the Contact from all the Groups it belongs. This Api is called as part of DecodeContactGroupInVcardL() before 
@@ -131,8 +138,10 @@
     CVPbkGroupCardHandler(CVPbkVCardData& aData);
 
     //Second Phase Construction
-    void ConstructL();    
-
+    void ConstructL();
+    //Synchronizes Virtual Phonebook RetrieveContactL 
+    TBool RetrieveContactL( const MVPbkContactLink& aLink,
+            MVPbkSingleContactOperationObserver& aObserver);
 public:  
 
     //From MVPbkSingleContactOperationObserver         
@@ -178,6 +187,15 @@
     MVPbkStoreContact * iTargetStore;
     //Own: Hash Table to store Group Names.
     RPtrHashMap<TDesC16, MVPbkStoreContact> *iContactsGroupsMap;
+    //Own: The operation handle
+    MVPbkContactOperationBase* iRetrieveOp;
+    //Own: For setting client's pointer to NULL if this instance is
+    //     deleted during the nested activescheduler loop.
+    CVPbkGroupCardHandler** iSelfPtr;
+    //Own: Used for checking that has this instance deleted during
+    //     the nested activescheduler loop i.e member data can not
+    //     be accessed anymore if this instance has been deleted.
+    TBool* iDestroyed;
     };
 
 #endif // CVPbkGroupCardHandler_H
--- 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
--- a/phonebookengines/VirtualPhonebook/VPbkVCardEng/inc/CVPbkVCardData.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkVCardEng/inc/CVPbkVCardData.h	Thu Jul 15 18:22:55 2010 +0300
@@ -27,7 +27,7 @@
 class CVPbkVCardFieldTypeProperty;
 class CVPbkVCardIdNameMapping;
 class MVPbkFieldTypeList;
-class CParserVCard;
+class CVersitTlsData;
 class CVPbkContactCopyPolicyManager;
 class MVPbkContactCopyPolicy;
 class CVPbkContactManager;
@@ -118,7 +118,10 @@
         VPbkEngUtils::CTextStore* iTextStore;        
         
         //  Own: Array to hold those fields masked during a beamed export
-         CDesC8ArrayFlat* iMaskedFieldsArray;
+        CDesC8ArrayFlat* iMaskedFieldsArray;
+        // Own: A handle to singleton for performance reasons.
+        // See CVersitTlsData documentation. 
+        CVersitTlsData* iVersitTlsData;
     };
 
 #endif // CVPBKVCARDDATA_H
--- a/phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkGroupCardHandler.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkGroupCardHandler.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -67,6 +67,19 @@
 // ----------------------------------------------------------------------------
 CVPbkGroupCardHandler::~CVPbkGroupCardHandler()
     {
+    // The code that started iWait must know if this instance has been deleted.
+    if ( iDestroyed )
+        {
+        *iDestroyed = ETrue;
+        }
+    
+    if ( iSelfPtr )
+        {
+        *iSelfPtr = NULL;
+        }
+    
+    delete iRetrieveOp;
+    
     if ( iWait )
         {
         if( iWait->IsStarted() )
@@ -122,18 +135,13 @@
     CDesCArrayFlat* desArray=new (ELeave)CDesCArrayFlat(totalGroupsInContact);
     CleanupStack::PushL(desArray);
 
-    //Append all the Group Names of contact to X-CATEGORIES field value. 
-    for ( TInt m = 0 ; m < totalGroupsInContact ; m++ )
+    //Append all the Group Names of contact to X-CATEGORIES field value.
+    TBool thisDestroyed = EFalse;
+    for ( TInt m = 0 ; m < totalGroupsInContact && !thisDestroyed ; m++ )
         {                  
-        const  MVPbkContactLink& groupLink = (*groupIdArray)[m];                                             
-        iData.GetContactManager().RetrieveContactL( groupLink, *this );
-        //wait for ContactRetrieve operation to complete, to get storecontact for the current group link
-        if( ! (iWait->IsStarted()) )
-            {
-            iWait->Start();
-            }
-
-        if (iTargetStore)
+        const  MVPbkContactLink& groupLink = (*groupIdArray)[m];
+        thisDestroyed = RetrieveContactL( groupLink, *this );
+        if (!thisDestroyed && iTargetStore)
             {
             MVPbkContactGroup* contactGrp = iTargetStore->Group();
             if(contactGrp)
@@ -177,18 +185,13 @@
     groupIdsCount = groupIds->Count();    
     const MVPbkContactLink* contactLink = iStore->CreateLinkLC();
 
-    //Remove the contact from all the Groups it belongs. 
-    for(TInt i = 0;i < groupIdsCount;i++)
+    //Remove the contact from all the Groups it belongs.
+    TBool thisDestroyed = EFalse;
+    for(TInt i = 0;i < groupIdsCount && !thisDestroyed;i++)
         {
         const MVPbkContactLink& groupLink = (*groupIds)[i];
-        iData.GetContactManager().RetrieveContactL( groupLink, *this );
-        //wait for Retrieve operation to complete,to get storecontact for the current group link
-        if( ! (iWait->IsStarted()) )
-            {
-            iWait->Start();
-            }
-
-        if (iTargetStore)
+        thisDestroyed = RetrieveContactL( groupLink, *this );
+        if (!thisDestroyed && iTargetStore)
             { 
             MVPbkContactGroup* contactGrp = iTargetStore->Group();
             if(contactGrp)
@@ -235,15 +238,10 @@
         
         //Retrieve group store
         const MVPbkContactLink* grpContactLink = groupItem->CreateLinkLC();
-        iData.GetContactManager().RetrieveContactL( *grpContactLink, *this );
-        //wait for Retrieve operation to complete, to get storecontact for the current group link
-        if( ! (iWait->IsStarted()) )
-            {
-            iWait->Start();
-            }
+        TBool thisDestroyed = RetrieveContactL( *grpContactLink, *this );
         CleanupStack::PopAndDestroy();// to clean grpContactLink
 
-        if (iTargetStore)
+        if (!thisDestroyed && iTargetStore)
             {
             const MVPbkContactLink* contactLink = iStore->CreateLinkLC();
             groupItem->AddContactL(*contactLink);
@@ -263,7 +261,13 @@
                 {
                 iContactsGroupsMap = new(ELeave) RPtrHashMap<TDesC16, MVPbkStoreContact>();
                 }
-            iContactsGroupsMap->Insert(grpName, iTargetStore);
+            // iContactsGroupsMap takes the ownership of iTargetStore
+            TInt res = iContactsGroupsMap->Insert(grpName, iTargetStore);
+            if ( res != KErrNone )
+                {
+                delete iTargetStore;
+                }
+            iTargetStore = NULL;
             CleanupStack::Pop(); // To pop up grpName
             }
         }   
@@ -274,10 +278,12 @@
 // ----------------------------------------------------------------------------
 // CVPbkGroupCardHandler::DecodeContactGroupInVCardL
 // ----------------------------------------------------------------------------
-void CVPbkGroupCardHandler::DecodeContactGroupInVCardL(TPtr16 aValue)
+void CVPbkGroupCardHandler::DecodeContactGroupInVCardL(TPtr16 aValue,
+        CVPbkGroupCardHandler** aSelfPointer )
     {        
     if(iStore == NULL)
-        return; 
+        return;
+    iSelfPtr = aSelfPointer;
     const MVPbkContactLink* contactLink = iStore->CreateLinkLC();
 
     TInt newLinePos = aValue.Find(KVersitTokencrlf());
@@ -290,7 +296,8 @@
 
     DeleteContactFromGroupsL(); //Delete the contact from the Groups it belongs
 
-    while(!endGrpValue)
+    TBool destroyed = EFalse;
+    while(!endGrpValue && !destroyed)
         {        
         semiColonPos = aValue.Find( KSemiColon() );
         if(semiColonPos == KErrNotFound)
@@ -322,16 +329,26 @@
             if(groupContactItemId != NULL)
                 { 
                 storeContact->LockL(*this);
+                iDestroyed = &destroyed;
                 //wait for Lock operation to complete
                 if( ! (iWait->IsStarted()) )
                     {
                     iWait->Start();
                     }
-                groupContactItemId->AddContactL(*contactLink);
-                storeContact->CommitL(*this);  // save Group modifications.
-                if( ! (iWait->IsStarted()) )
+                if ( !destroyed )
                     {
-                    iWait->Start();
+                    iDestroyed = NULL;
+                    groupContactItemId->AddContactL(*contactLink);
+                    storeContact->CommitL(*this);  // save Group modifications.
+                    iDestroyed = &destroyed;
+                    if( ! (iWait->IsStarted()) )
+                        {
+                        iWait->Start();
+                        }
+                    if ( !destroyed )
+                        {
+                        iDestroyed = NULL;
+                        }
                     }
                 }
             else
@@ -349,8 +366,9 @@
 
     CleanupStack::PopAndDestroy(); // For contactLink 
 
-    if(iStore)
+    if(!destroyed)
         {
+        iSelfPtr = NULL;
         delete iStore;
         iStore = NULL;
         }
@@ -359,7 +377,9 @@
 // ----------------------------------------------------------------------------
 // CVPbkGroupCardHandler::BuildContactGroupsHashMapL
 // ----------------------------------------------------------------------------
-void CVPbkGroupCardHandler::BuildContactGroupsHashMapL(MVPbkContactStore& aTargetContactStore)
+void CVPbkGroupCardHandler::BuildContactGroupsHashMapL(
+        MVPbkContactStore& aTargetContactStore, 
+        CVPbkGroupCardHandler** aSelfPointer)
     {
     //Get all the Group Links in current VPBK
     MVPbkContactLinkArray* groupLinks = aTargetContactStore.ContactGroupsLC();
@@ -367,23 +387,20 @@
     if( (groupLinks == NULL || iContactsGroupsMap != NULL))
         return;
 
+    iSelfPtr = aSelfPointer;
+    
     iContactsGroupsMap = new(ELeave) RPtrHashMap<TDesC16, MVPbkStoreContact>();
 
     TInt groupCount = 0;
     groupCount = groupLinks->Count();
 
     // Get Group Name and Group store, store these values into Hash Table.
-    for(TInt i = 0;i < groupCount;i++)
+    TBool thisDestroyed = EFalse;
+    for(TInt i = 0;i < groupCount && !thisDestroyed;i++)
         {
         const MVPbkContactLink& groupLink = (*groupLinks)[i];
-        iData.GetContactManager().RetrieveContactL( groupLink, *this );
-        //wait for Retrieve operation to complete, to get storecontact for the current group link
-        if( ! (iWait->IsStarted()) )
-            {
-            iWait->Start();
-            }
-
-        if (iTargetStore)
+        thisDestroyed = RetrieveContactL( groupLink, *this );
+        if (!thisDestroyed && iTargetStore)
             {
             MVPbkContactGroup* contactGrp = iTargetStore->Group();
             if(contactGrp)
@@ -391,31 +408,65 @@
                 TPtrC16 contactGroupName;
                 contactGroupName.Set( contactGrp->GroupLabel());
                 HBufC16* grpName = contactGroupName.AllocLC();
-                iContactsGroupsMap->Insert(grpName, iTargetStore);
+                // iContactsGroupsMap takes the ownership of iTargetStore
+                TInt res = iContactsGroupsMap->Insert(grpName, iTargetStore);
+                if ( res != KErrNone )
+                    {
+                    delete iTargetStore;
+                    }
+                iTargetStore = NULL;
                 CleanupStack::Pop();  //grpName
                 }       
             }    
         }// End of for loop
 
     CleanupStack::PopAndDestroy(); //for groupLinks
+    
+    if ( !thisDestroyed )
+        {
+        iSelfPtr = NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CVPbkGroupCardHandler::RetrieveContactL
+// ----------------------------------------------------------------------------
+TBool CVPbkGroupCardHandler::RetrieveContactL( const MVPbkContactLink& aLink,
+            MVPbkSingleContactOperationObserver& aObserver)
+    {
+    delete iTargetStore;
+    iTargetStore = NULL;
+    iRetrieveOp = iData.GetContactManager().RetrieveContactL( aLink, aObserver );
+    
+    TBool destroyed = EFalse;
+    // Set iDestroyed to point to stack variable that is accessed from
+    // destructor.
+    iDestroyed = &destroyed; 
+    //wait for GetContactGroupStoreL operation to complete,to get storecontact
+    if( ! (iWait->IsStarted()) )
+        {
+        iWait->Start();
+        }
+    
+    if ( !destroyed )
+        {
+        // Reset pointer to stack variable.
+        iDestroyed = NULL;
+        delete iRetrieveOp;
+        iRetrieveOp = NULL;
+        }
+    return destroyed; 
     }
 
 // ----------------------------------------------------------------------------
 // CVPbkGroupCardHandler::VPbkSingleContactOperationComplete
 // ----------------------------------------------------------------------------
 void CVPbkGroupCardHandler::VPbkSingleContactOperationComplete(
-        MVPbkContactOperationBase& aOperation,
+        MVPbkContactOperationBase& /*aOperation*/,
         MVPbkStoreContact* aContact)
     {
     iTargetStore = aContact;
 
-    MVPbkContactOperationBase* operation = &aOperation;
-    if ( operation )
-        {
-        delete operation;
-        operation = NULL;
-        }
-
     if( iWait->IsStarted() )
         iWait->AsyncStop();
 
@@ -425,16 +476,8 @@
 // CVPbkGroupCardHandler::VPbkSingleContactOperationFailed
 // ----------------------------------------------------------------------------
 void CVPbkGroupCardHandler::VPbkSingleContactOperationFailed
-(MVPbkContactOperationBase& aOperation, TInt /*aError*/)
+(MVPbkContactOperationBase& /*aOperation*/, TInt /*aError*/)
     {
-    iTargetStore = NULL; //To Handle in Error case
-    MVPbkContactOperationBase* operation = &aOperation;
-    if ( operation )
-        {
-        delete operation;
-        operation = NULL;
-        }
-
     if( iWait->IsStarted() )
         iWait->AsyncStop();
     }
@@ -443,15 +486,20 @@
 // CVPbkGroupCardHandler::GetContactGroupStoreL
 // Retrieve the contact store of group contact
 // ----------------------------------------------------------------------------
-void CVPbkGroupCardHandler::GetContactGroupStoreL(const MVPbkContactLink& aContactLink)
+void CVPbkGroupCardHandler::GetContactGroupStoreL(
+        const MVPbkContactLink& aContactLink, 
+        CVPbkGroupCardHandler** aSelfPointer)
     {
-    iData.GetContactManager().RetrieveContactL( aContactLink, *this );
-    //wait for GetContactGroupStoreL operation to complete,to get storecontact
-    if( ! (iWait->IsStarted()) )
+    iSelfPtr = aSelfPointer;
+    delete iStore;
+    iStore = NULL;
+    if ( !RetrieveContactL( aContactLink, *this ) )
         {
-        iWait->Start();
-        }
-    iStore = iTargetStore;
+        iSelfPtr = NULL;
+        // iStore takes the ownership.
+        iStore = iTargetStore;
+        iTargetStore = NULL;
+        }        
     }
 
 // ----------------------------------------------------------------------------
--- a/phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkImportToContactsMergeOperation.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkImportToContactsMergeOperation.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -28,22 +28,26 @@
 #include <CVPbkContactManager.h>
 #include <MVPbkFieldType.h>
 #include <MVPbkContactFieldData.h>
+#include <MVPbkContactFieldUriData.h>
+#include <MVPbkContactFieldTextData.h>
 #include <MVPbkSingleContactOperationObserver.h>
+#include "CVPbkDefaultAttribute.h"
+const TInt KGranularity = 4;
 
 namespace{
-	#ifdef _DEBUG
+    #ifdef _DEBUG
        
-	enum TPanic
-		{
-		EPanicInvalidState = 1,
-		EPanicInvalidToRetrieve,
-		EPanicInvalidToLock,
-		EPanicInvalidToCommit,
-		EPanicInvalidToUpdate,
+    enum TPanic
+        {
+        EPanicInvalidState = 1,
+        EPanicInvalidToRetrieve,
+        EPanicInvalidToLock,
+        EPanicInvalidToCommit,
+        EPanicInvalidToUpdate,
         };
 
     void Panic(TPanic aPanic)
-    	{
+        {
         _LIT(KPanicCat, "CVPbkImportToContactsMergeOperation");
         User::Panic(KPanicCat, aPanic);
         }
@@ -56,15 +60,15 @@
 // ---------------------------------------------------------------------------
 //
 CVPbkImportToContactsMergeOperation::CVPbkImportToContactsMergeOperation(
-		const MVPbkContactLink& aReplaceContact,
-		MVPbkSingleContactOperationObserver& aObserver,
-		MVPbkContactStore& aTargetStore,
-		CVPbkVCardData& aData
-		)
+        const MVPbkContactLink& aReplaceContact,
+        MVPbkSingleContactOperationObserver& aObserver,
+        MVPbkContactStore& aTargetStore,
+        CVPbkVCardData& aData
+        )
         :   CActive( EPriorityStandard ),
-        	iState ( EImport ),
-        	iTargetStore( aTargetStore ),
-        	iReplaceContact( aReplaceContact ),
+            iState ( EImport ),
+            iTargetStore( aTargetStore ),
+            iReplaceContact( aReplaceContact ),
             iObserver( aObserver ),
             iData(aData)
     {
@@ -134,7 +138,16 @@
         }
     if(iVPbkOperation)
         delete iVPbkOperation;
-
+    if( iSetAttributeOperation )
+        {
+        delete iSetAttributeOperation;
+        iSetAttributeOperation = NULL;
+        }
+    if( iDefaultAttributes )
+        {
+        delete iDefaultAttributes;
+        iDefaultAttributes = NULL;
+        }
     iImportedContacts.ResetAndDestroy();
 
     CActive::Cancel();
@@ -168,56 +181,65 @@
 // ---------------------------------------------------------------------------
 //
 void CVPbkImportToContactsMergeOperation::RunL()
-	{
-	if ( iStatus == KErrNone)
-		{
-		switch( iState )
-			{
-			case ERetrieve:
-				{
-				RetrieveContactL();
-				break;
-				}				
-			case ELock:
-				{
-				LockContactL();
-				break;
-				}
-			case EReplaceFields:
-				{
-				UpdateContactL();
-				break;
-				}						
-			case ECommit:
-				{
-				CommitContactL();
-				break;
-				}
-			case EReRetrieve:
-				{
-				ReRetrieveContactL();
-				break;
-				}				
-			case EComplete:
-			    {
-
-			    if(iGroupcardHandler && ((CVPbkVCardImporter *)iOperationImpl)->IsGroupcard())
-			        {
-			        iGroupcardHandler->BuildContactGroupsHashMapL(iContact->ParentStore());
-			        const MVPbkContactLink* contact = iContact->CreateLinkLC();
-			        iGroupcardHandler->GetContactGroupStoreL(*contact);
-			        CleanupStack::PopAndDestroy(); // For contact
-			        iGroupcardHandler->DecodeContactGroupInVCardL(((CVPbkVCardImporter *)iOperationImpl)->GetGroupcardvalue());
-			        }
-			    iObserver.VPbkSingleContactOperationComplete( *this, iContact );
-			    iContact = NULL;
-			    break;
-			    }
-			default:
-				__ASSERT_DEBUG( EFalse, Panic(EPanicInvalidState) );
-			}
-		}
-	}
+    {
+    if ( iStatus == KErrNone)
+        {
+        switch( iState )
+            {
+            case ERetrieve:
+                {
+                RetrieveContactL();
+                break;
+                }
+            case    ELock:
+                {
+                LockContactL();
+                break;
+                }
+            case EUpdateContact:
+                {
+                UpdateContactL();
+                break;
+                }
+            case EReplaceFields:
+                {
+                ReplaceFieldL( *(iImportedContacts[0]), *iContact );
+                break;
+                }
+            case ESetAttributes:
+                {
+                SetNextL();
+                break;
+                }
+            case ECommit:
+                {
+                CommitContactL();
+                break;
+                }
+            case EReRetrieve:
+                {
+                ReRetrieveContactL();
+                break;
+                }
+            case EComplete:
+                {
+                if(iGroupcardHandler && ((CVPbkVCardImporter *)iOperationImpl)->IsGroupcard())
+                    {
+                    iGroupcardHandler->BuildContactGroupsHashMapL(iContact->ParentStore());
+                    const MVPbkContactLink* contact = iContact->CreateLinkLC();
+                    iGroupcardHandler->GetContactGroupStoreL(*contact);
+                    CleanupStack::PopAndDestroy(); // For contact
+                    iGroupcardHandler->DecodeContactGroupInVCardL(((CVPbkVCardImporter *)iOperationImpl)->GetGroupcardvalue());
+                    }
+                iObserver.VPbkSingleContactOperationComplete( *this, iContact );
+                iContact = NULL;
+                break;
+                }
+            default:
+                __ASSERT_DEBUG( EFalse, Panic(EPanicInvalidState) );
+            }
+        }
+    }
 
 // ---------------------------------------------------------------------------
 // CVPbkImportToContactsMergeOperation::RunError
@@ -225,10 +247,10 @@
 // ---------------------------------------------------------------------------
 //
 TInt CVPbkImportToContactsMergeOperation::RunError( TInt aError )
-	{
-	HandleError( aError );
-	return KErrNone;
-	}
+    {
+    HandleError( aError );
+    return KErrNone;
+    }
 
 // ---------------------------------------------------------------------------
 // CVPbkImportToContactsMergeOperation::DoCancel
@@ -236,10 +258,10 @@
 // ---------------------------------------------------------------------------
 //
 void CVPbkImportToContactsMergeOperation::DoCancel()
-	{
-	delete iOperationImpl;
-	iOperationImpl = NULL;
-	}
+    {
+    delete iOperationImpl;
+    iOperationImpl = NULL;
+    }
 
 // ---------------------------------------------------------------------------
 // From class MVPbkImportOperationObserver
@@ -359,25 +381,25 @@
 // ---------------------------------------------------------------------------
 //
 void CVPbkImportToContactsMergeOperation::ContactOperationCompleted(
-		TContactOpResult aResult)
-	{
-	delete aResult.iStoreContact;
-	switch( iState )
-		{
-		case ELock:
-			{
-			NextState( EReplaceFields );
-			break;
-			}
-		case ECommit:
-			{
-			NextState( EReRetrieve );
-			break;
-			}			
-		default:
-			__ASSERT_DEBUG( EFalse, Panic(EPanicInvalidState) );
-		}
-	}
+        TContactOpResult aResult)
+    {
+    delete aResult.iStoreContact;
+    switch( iState )
+        {
+        case ELock:
+            {
+            NextState( EUpdateContact );
+            break;
+            }
+        case ECommit:
+            {
+            NextState( EReRetrieve );
+            break;
+            }
+        default:
+            __ASSERT_DEBUG( EFalse, Panic(EPanicInvalidState) );
+        }
+    }
 
 // ---------------------------------------------------------------------------
 // CVPbkImportToContactsMergeOperation::ContactOperationFailed
@@ -385,112 +407,135 @@
 // ---------------------------------------------------------------------------
 //
 void CVPbkImportToContactsMergeOperation::ContactOperationFailed(
-		TContactOp /*aOpCode*/, TInt aErrorCode, TBool /*aErrorNotified*/)
-	{
-	HandleError( aErrorCode );
-	}
+        TContactOp    /*aOpCode*/, TInt aErrorCode, TBool /*aErrorNotified*/)
+    {
+    HandleError( aErrorCode );
+    }
 
 // ---------------------------------------------------------------------------
 // CVPbkImportToContactsMergeOperation::HandleError
 // ---------------------------------------------------------------------------
 //
 void CVPbkImportToContactsMergeOperation::HandleError(TInt aError)
-	{
-	iObserver.VPbkSingleContactOperationFailed( *this, aError );
-	}
+    {
+    iObserver.VPbkSingleContactOperationFailed( *this, aError );
+    }
 
 // ---------------------------------------------------------------------------
 // CVPbkImportToContactsMergeOperation::RetrieveContactL
 // ---------------------------------------------------------------------------
 //
 inline void CVPbkImportToContactsMergeOperation::RetrieveContactL()
-	{
-	iVPbkOperation = iData.GetContactManager().RetrieveContactL(iReplaceContact,*this );
-	}
+    {
+    iVPbkOperation = iData.GetContactManager().RetrieveContactL(iReplaceContact,*this );
+    }
 
 // ---------------------------------------------------------------------------
 // CVPbkImportToContactsMergeOperation::ReRetrieveContactL
 // ---------------------------------------------------------------------------
 //
 inline void CVPbkImportToContactsMergeOperation::ReRetrieveContactL()
-	{
-	__ASSERT_DEBUG( iContact, Panic(EPanicInvalidToRetrieve) );
-	
-	MVPbkContactLink* link = iContact->CreateLinkLC(); 
-	iVPbkOperation = iData.GetContactManager().RetrieveContactL( *link, *this );
-	CleanupStack::PopAndDestroy();
-	}
+    {
+    __ASSERT_DEBUG( iContact, Panic(EPanicInvalidToRetrieve) );
+    
+    MVPbkContactLink* link = iContact->CreateLinkLC(); 
+    iVPbkOperation = iData.GetContactManager().RetrieveContactL( *link, *this );
+    CleanupStack::PopAndDestroy();
+    }
 
 // ---------------------------------------------------------------------------
 // CVPbkImportToContactsMergeOperation::LockContactL
 // ---------------------------------------------------------------------------
 //
 inline void CVPbkImportToContactsMergeOperation::LockContactL()
-	{
-	__ASSERT_DEBUG( iContact, Panic(EPanicInvalidToLock) );
-	iContact->LockL( *this );
-	}
+    {
+    __ASSERT_DEBUG( iContact, Panic(EPanicInvalidToLock) );
+    iContact->LockL( *this );
+    }
 
 // ---------------------------------------------------------------------------
 // CVPbkImportToContactsMergeOperation::CommitContactL
 // ---------------------------------------------------------------------------
 //
 inline void CVPbkImportToContactsMergeOperation::CommitContactL()
-	{
-	__ASSERT_DEBUG( iContact, Panic(EPanicInvalidToCommit) );
-	
-	iContact->CommitL( *this );
-	}
+    {
+    __ASSERT_DEBUG( iContact, Panic(EPanicInvalidToCommit) );
+    
+    iContact->CommitL( *this );
+    }
 
 // ---------------------------------------------------------------------------
 // CVPbkImportToContactsMergeOperation::UpdateContactL
 // ---------------------------------------------------------------------------
 //
 inline void CVPbkImportToContactsMergeOperation::UpdateContactL()
-	{
-	__ASSERT_DEBUG( iContact, Panic(EPanicInvalidToUpdate) );
-	__ASSERT_DEBUG( iImportedContacts.Count()>0, Panic(EPanicInvalidToUpdate) );
-	__ASSERT_DEBUG( iImportedContacts[0], Panic(EPanicInvalidToUpdate) );
-	
-	TRAPD( err, ReplaceContactL( *(iImportedContacts[0]), *iContact ));
-	
-	
-	// whether commit succeds or fails, we continue,
-	// update iImportedContacts right away
-	delete iImportedContacts[0];
-	iImportedContacts.Remove(0);	
-	
-	if ( err != KErrNone )
-		{
-		HandleError( err );
-		}
-	else
-		{
-		NextState( ECommit );
-		}
-	}
+    {
+    __ASSERT_DEBUG( iContact, Panic(EPanicInvalidToUpdate) );
+    __ASSERT_DEBUG( iImportedContacts.Count()>0, Panic(EPanicInvalidToUpdate) );
+    __ASSERT_DEBUG( iImportedContacts[0], Panic(EPanicInvalidToUpdate) );
+    iContact->RemoveAllFields();
+    iCurrentFieldIndex = 0;
+    iFieldCount = iImportedContacts[0]->Fields().FieldCount();
+
+    ReplaceFieldL( *(iImportedContacts[0]), *iContact );
+    }
 
 // ---------------------------------------------------------------------------
 // From class MVPbkImportOperationObserver
 // ---------------------------------------------------------------------------
 //
-inline void CVPbkImportToContactsMergeOperation::ReplaceContactL(
-		const MVPbkStoreContact& aSrc,
-		MVPbkStoreContact& aTarget )
-	{
-	aTarget.RemoveAllFields();
-	
-	const MVPbkStoreContactFieldCollection& sourceFields = aSrc.Fields();
-    const TInt sourceFieldCount = sourceFields.FieldCount();
-    for ( TInt i = 0; i < sourceFieldCount; ++i )
+void CVPbkImportToContactsMergeOperation::ReplaceFieldL(
+        const MVPbkStoreContact& aSrc,
+        MVPbkStoreContact& aTarget )
+    {
+    if( iCurrentFieldIndex < iFieldCount )
         {
-        const MVPbkFieldType* type = 
-            sourceFields.FieldAt(i).BestMatchingFieldType();
+        const MVPbkStoreContactFieldCollection& sourceFields = aSrc.Fields();
+        const MVPbkFieldType* type = sourceFields.FieldAt(iCurrentFieldIndex).BestMatchingFieldType();
         if ( type )
             {
-            CopyFieldL( sourceFields.FieldAt(i), *type, aTarget );
+            TRAPD( err,
+                CopyFieldL( sourceFields.FieldAt(iCurrentFieldIndex), *type, aTarget );
+                // Check whether the sorce field has attribute,
+                // If the sorce field has attribute, set attribute to the target contact's field
+                TInt type = EVPbkDefaultTypeUndefined + 1;
+                if( iData.AttributeManagerL().HasFieldAttributeL( CVPbkDefaultAttribute::Uid(), 
+                    sourceFields.FieldAt(iCurrentFieldIndex) ) )
+                    {
+                    GetDefaultAttributsL( sourceFields.FieldAt(iCurrentFieldIndex) );
+                    if( iDefaultAttributes && iDefaultAttributes->Count() > 0 )
+                        {
+                        SetNextL();
+                        }
+                    }
+                else
+                    {
+                    if( ++iCurrentFieldIndex < iFieldCount )
+                        {
+                        ReplaceFieldL(aSrc, aTarget);
+                        }
+                    else
+                        {
+                        delete iImportedContacts[0];
+                        iImportedContacts.Remove(0);
+                        NextState( ECommit );
+                        }
+                    }
+                );
+            if( err != KErrNone )
+                {
+                delete iImportedContacts[0];
+                iImportedContacts.Remove(0);
+                HandleError( err );
+                }
             }
         }
+    else
+        {
+        delete iImportedContacts[0];
+        iImportedContacts.Remove(0);
+        NextState( ECommit );
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -513,8 +558,80 @@
         }
     newField->FieldData().CopyL(aSourceField.FieldData());
     aTargetContact.AddFieldL(newField);
-    CleanupStack::Pop(); // newField	
-	}
+    CleanupStack::Pop(); // newField
+    }
+
+// --------------------------------------------------------------------------
+// CVPbkImportToContactsMergeOperation::GetDefaultAttributsL
+// Gets the attributes from aField.
+// --------------------------------------------------------------------------
+//
+void CVPbkImportToContactsMergeOperation::GetDefaultAttributsL( const MVPbkStoreContactField& aField )
+    {
+    delete iDefaultAttributes;
+    iDefaultAttributes = NULL;
+    iDefaultAttributes = new( ELeave ) CArrayFixFlat<TVPbkDefaultType>( KGranularity );
+    TInt type = EVPbkDefaultTypeUndefined + 1;
+    while( EVPbkLastDefaultType != type )
+        {
+        CVPbkDefaultAttribute* attr = CVPbkDefaultAttribute::NewL( (TVPbkDefaultType)type );
+        CleanupStack::PushL( attr );
+
+        if( iData.AttributeManagerL().HasFieldAttributeL( *attr, aField ) )
+            {
+            iDefaultAttributes->AppendL( (TVPbkDefaultType)type );
+            }
+        
+        CleanupStack::PopAndDestroy( attr );
+        type++;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CVPbkImportToContactsMergeOperation::NextAttribute
+// Gets next attribute from the array. The array is processed backwards.
+// --------------------------------------------------------------------------
+//
+inline TVPbkDefaultType CVPbkImportToContactsMergeOperation::NextAttribute()
+    {
+    TVPbkDefaultType attribute = EVPbkDefaultTypeUndefined;
+    TInt count = 0;
+    if ( iDefaultAttributes )
+        {
+        count = iDefaultAttributes->Count();
+        }
+
+    if ( count > 0 )
+        {
+        attribute = iDefaultAttributes->At( count - 1 ); // zero-based
+        iDefaultAttributes->Delete( count -1 ); // zero-based
+        }
+    return attribute;
+    }
+
+// --------------------------------------------------------------------------
+// CPbk2DefaultAttributeProcess::SetNextL
+// --------------------------------------------------------------------------
+//
+void CVPbkImportToContactsMergeOperation::SetNextL()
+    {
+    TVPbkDefaultType attributeType = NextAttribute();
+    if ( attributeType != EVPbkDefaultTypeUndefined )
+        {
+        delete iSetAttributeOperation;
+        iSetAttributeOperation = NULL;
+        CVPbkDefaultAttribute* attr = CVPbkDefaultAttribute::NewL( attributeType );
+        CleanupStack::PushL( attr );
+        iSetAttributeOperation = iData.AttributeManagerL().SetFieldAttributeL(iContact->Fields().FieldAt(iCurrentFieldIndex), *attr, *this);
+        CleanupStack::PopAndDestroy( attr );
+        }
+    else
+        {
+        // Finished
+        ++iCurrentFieldIndex;
+        NextState( EReplaceFields );
+        }
+    }
 
 // ---------------------------------------------------------------------------
 // CVPbkImportToContactsMergeOperation::NextState
@@ -528,4 +645,32 @@
     SetActive();
     }
 
+// --------------------------------------------------------------------------
+// CVPbkImportToContactsMergeOperation::AttributeOperationComplete
+// --------------------------------------------------------------------------
+//
+void CVPbkImportToContactsMergeOperation::AttributeOperationComplete( MVPbkContactOperationBase& aOperation )
+    {
+    if( &aOperation == iSetAttributeOperation )
+        {
+        NextState( ESetAttributes );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CVPbkImportToContactsMergeOperation::AttributeOperationFailed
+// --------------------------------------------------------------------------
+//
+void CVPbkImportToContactsMergeOperation::AttributeOperationFailed(
+        MVPbkContactOperationBase& aOperation,
+        TInt aError )
+    {
+    if( &aOperation == iSetAttributeOperation )
+        {
+        delete iImportedContacts[0];
+        iImportedContacts.Remove(0);
+        HandleError( aError );
+        }
+    }
+
 // End of file
--- a/phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkImportToStoreOperation.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkImportToStoreOperation.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -27,6 +27,7 @@
 #include <MVPbkStoreContact.h>
 #include <MVPbkContactStore.h>
 #include <MVPbkContactStoreProperties.h>
+#include <MVPbkContactStoreProperties2.h>
 #include <CVPbkContactLinkArray.h>
 #include <MVPbkContactCopyPolicy.h>
 #include <MVPbkContactLink.h>
@@ -93,11 +94,25 @@
         }
 
     iSavedContacts = CVPbkContactLinkArray::NewL();
+    
    // Handle Owncard during Sync
     if(aSync)
 	    {
-	    iOwncardHandler = CVPbkOwnCardHandler::NewL(aData);	
-	    iGroupcardHandler = CVPbkGroupCardHandler::NewL(aData);
+        MVPbkContactStoreProperties& prop = 
+                const_cast<MVPbkContactStoreProperties&>(
+                        iTargetStore.StoreProperties());
+        if ( prop.SupportsContactGroups() )
+            {
+            iGroupcardHandler = CVPbkGroupCardHandler::NewL(aData);
+            }
+        MVPbkContactStoreProperties2* prop2 = 
+                    static_cast<MVPbkContactStoreProperties2*>( 
+                            prop.ContactStorePropertiesExtension( 
+                                    KMVPbkContactStorePropertiesExtension2Uid ) );
+        if ( prop2 && prop2->SupportsOwnContact() )
+            {
+            iOwncardHandler = CVPbkOwnCardHandler::NewL(aData);
+            }
 	    }
     }
 
@@ -354,25 +369,50 @@
 	        {
 	    	iOwncardHandler->SetAsOwnContactL(aResults->At(0));
 	    	}
+		
+     TBool destroyed = EFalse;
      if(iGroupcardHandler && ((CVPbkVCardImporter *)iOperationImpl)->IsGroupcard())
          {
-         iGroupcardHandler->BuildContactGroupsHashMapL(iTargetStore);
-         iGroupcardHandler->GetContactGroupStoreL(aResults->At(0));
-         iGroupcardHandler->DecodeContactGroupInVCardL(((CVPbkVCardImporter *)iOperationImpl)->GetGroupcardvalue());
+         // CVPbkGroupCardHandler uses nested activescheduler loop to make
+         // async requests synchronous (why?). Hence it is possible that when 
+         // the execution returns from BuildContactGroupsHashMapL, 
+         // GetContactGroupStoreL or DecodeContactGroupInVCardL this instance
+         // has already been deleted and member data can not be accessed
+         // anymore. User can e.g cancel restoring contacts in which case
+         // import operation will be deleted before it is completed.
+         // Self pointer is used to check this.
+         CVPbkGroupCardHandler* groupcardHandler = iGroupcardHandler;  
+         groupcardHandler->BuildContactGroupsHashMapL(iTargetStore, &groupcardHandler);
+         if ( groupcardHandler )
+             {
+             groupcardHandler->GetContactGroupStoreL(aResults->At(0), &groupcardHandler );
+             }
+         if ( groupcardHandler )
+             {
+             groupcardHandler->DecodeContactGroupInVCardL(
+                     ((CVPbkVCardImporter *)iOperationImpl)->GetGroupcardvalue(), 
+                     &groupcardHandler);
+             }
+         else
+             {
+             destroyed = ETrue;
+             }
          }
     CleanupStack::PopAndDestroy(); // aResults
 
-    if ( curUnsavedCount == 0 )
+    if ( !destroyed )
         {
-        // Try to read the next entry, if one existed
-        iOperationImpl->StartL();
+        if ( curUnsavedCount == 0 )
+            {
+            // Try to read the next entry, if one existed
+            iOperationImpl->StartL();
+            }
+        else
+            {
+            CommitNextContactL();
+            iOperationImpl->StartL();
+            }
         }
-    else
-        {
-        CommitNextContactL();
-        iOperationImpl->StartL();
-        }
-
     }
 
 // ---------------------------------------------------------------------------
--- a/phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkVCardData.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkVCardData.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -36,6 +36,7 @@
 
 #include <barsread.h>
 #include <vcard.h>
+#include <versittls.h>
 
 namespace 
     {
@@ -126,6 +127,7 @@
         {
         User::LeaveIfError( res );
         }
+    iVersitTlsData = &CVersitTlsData::VersitTlsDataL();
     }
 
 CVPbkVCardData* CVPbkVCardData::NewL(CVPbkContactManager& aContactManager)
@@ -139,6 +141,10 @@
     
 CVPbkVCardData::~CVPbkVCardData()
     {
+    if (iVersitTlsData)
+        {
+        iVersitTlsData->VersitTlsDataClose();
+        }
     delete iCopyPolicyManager;
     iParamIdNameMappings.ResetAndDestroy();
     iVNameIdNameMappings.ResetAndDestroy();
--- a/phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkVCardImporter.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkVCardEng/src/CVPbkVCardImporter.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -34,6 +34,7 @@
 #include <MVPbkContactOperationBase.h>
 #include <CVPbkContactManager.h>
 #include <MVPbkStoreContactFieldCollection.h>
+#include <vpbkeng.rsg>
 
 // System includes
 #include <vcard.h>
@@ -43,7 +44,6 @@
 #include <VPbkStoreUriLiterals.h>
 _LIT8( KPropXSelf, "X-SELF" );
 _LIT8( KPropXCategories, "X-CATEGORIES");
-_LIT8( KPropXIMPP, "X-IMPP");
 _LIT(KColon, ":");
 
 CVPbkVCardImporter* CVPbkVCardImporter::NewL(
@@ -346,16 +346,19 @@
          aData.Uid() == TUid::Uid( KVersitPropertyCDesCArrayUid ) )
         {
         const TDesC& value = converter.GetDesCData( aData );
-        TInt pos = value.Find(KColon);
-        if( 0 == pos && 0 == GetCurrentProperty()->Name().Compare(KPropXIMPP()) )
+        if ( aData.FieldType().FieldTypeResId() == R_VPBK_FIELD_TYPE_IMPP )
             {
-            // If the service name is NULL and it's a IMPP field, don't save the data.
-            // e.g.:
-            // (1) If the value is YAHOO:peterpan@yahoo.com, YAHOO is the service name
-            // (2) If the value is :peterpan@yahoo.com, the service name is NULL
-            isSaved = EFalse;
+            TInt pos = value.Find(KColon);
+            if( 0 == pos )
+                {
+                // If the service name is NULL and it's a IMPP field, don't save the data.
+                // e.g.:
+                // (1) If the value is YAHOO:peterpan@yahoo.com, YAHOO is the service name
+                // (2) If the value is :peterpan@yahoo.com, the service name is NULL
+                isSaved = EFalse;
+                }
             }
-        else
+        if ( isSaved )
             {
             SaveL( aData, value );
             }
--- a/phonebookui/Phonebook2/CommandsExtension/inc/CPbk2MergeConflict.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/CommandsExtension/inc/CPbk2MergeConflict.h	Thu Jul 15 18:22:55 2010 +0300
@@ -42,6 +42,11 @@
      */
     static CPbk2MergeConflict* NewL();
     
+    /**
+     * Destructor.
+     */
+    ~CPbk2MergeConflict();
+    
 private: // Construction
     CPbk2MergeConflict();
     
@@ -55,6 +60,17 @@
     void AddFields(  
             const MVPbkStoreContactField& aFieldFirst, 
             const MVPbkStoreContactField& aFieldSecond );
+
+    /**
+     * Adds display fields into conflict. For special fields, normally not needed.
+     * If not provided normal field values used for display. Takes ownership.
+     *
+     * @param aDisplayFieldFirst     First display field.
+     * @param aDisplayFieldSecond    Second display field.
+     */
+    void AddDisplayFields(  
+            HBufC* aDisplayFieldFirst, 
+            HBufC* aDisplayFieldSecond );
     
     /**
      * Gets fields from conflict.
@@ -75,12 +91,19 @@
 
 private: // methods
     void CustomizeTextValueL( const MVPbkStoreContactField& aField, TDes& aBuf );
+    HBufC* GetContentTextLC( 
+            EPbk2ConflictedNumber aNumber, 
+            const MVPbkStoreContactField* aField );
     
 private: //Data
     // Not own: First field
     const MVPbkStoreContactField* iFieldFirst;
     // Not own: Second field
     const MVPbkStoreContactField* iFieldSecond;
+    //own: optional display value 
+    HBufC* iDisplayFieldFirst;
+    //own: optional display value 
+    HBufC* iDisplayFieldSecond;    
     // Not own: Chosen field
     const MVPbkStoreContactField* iChosenField;
     // Own: Conflict type
--- a/phonebookui/Phonebook2/CommandsExtension/inc/CPbk2MergeResolver.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/CommandsExtension/inc/CPbk2MergeResolver.h	Thu Jul 15 18:22:55 2010 +0300
@@ -131,6 +131,9 @@
     void AddConflictL( 
             const MVPbkStoreContactField& aFieldFirst,
             const MVPbkStoreContactField& aFieldSecond );
+    HBufC* SyncDisplayFieldLC(
+            const MVPbkStoreContactField& aField );
+    HBufC* LocaliseSyncDisplayFieldLC( const TDesC& aContent );
     void AddAddressConflictL( TPbk2FieldGroupId aGroupId );
     TInt FindConflictByFieldL( const MVPbkStoreContactField& aField );
     void PrintFieldL(const MVPbkStoreContactField & aField);
--- a/phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeConflict.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeConflict.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -79,6 +79,16 @@
     }
 
 // --------------------------------------------------------------------------
+// CPbk2MergeConflict::~CPbk2MergeConflict
+// --------------------------------------------------------------------------
+//
+CPbk2MergeConflict::~CPbk2MergeConflict()
+    {
+    delete iDisplayFieldFirst;
+    delete iDisplayFieldSecond;    
+    }
+
+// --------------------------------------------------------------------------
 // CPbk2MergeConflict::NewL
 // --------------------------------------------------------------------------
 //
@@ -140,6 +150,18 @@
     }
 
 // --------------------------------------------------------------------------
+// CPbk2MergeConflict::AddDisplayFields
+// --------------------------------------------------------------------------
+//
+void CPbk2MergeConflict::AddDisplayFields(  
+        HBufC* aDisplayFieldFirst, 
+        HBufC* aDisplayFieldSecond )
+    {
+    iDisplayFieldFirst = aDisplayFieldFirst;
+    iDisplayFieldSecond = aDisplayFieldSecond;
+    }
+
+// --------------------------------------------------------------------------
 // CPbk2MergeConflict::GetLabelLC
 // --------------------------------------------------------------------------
 //
@@ -159,6 +181,7 @@
     __ASSERT_ALWAYS( iFieldFirst && iFieldSecond, Panic( EPbk2NotInitialized ) );
     
     const MVPbkStoreContactField* field;
+    HBufC* retText = NULL;
     
     if( aNumber == EPbk2ConflictedFirst )
         {
@@ -169,7 +192,28 @@
         field = iFieldSecond;
         }
     
-    const MVPbkContactFieldData& data = field->FieldData();
+    //Prefer display texts if both available 
+    if( iDisplayFieldFirst && iDisplayFieldSecond )
+        {
+        retText = aNumber==EPbk2ConflictedFirst ? 
+            iDisplayFieldFirst->AllocLC() : iDisplayFieldSecond->AllocLC();
+        }
+    else
+        {
+        retText = GetContentTextLC( aNumber , field);    
+        }
+    return retText;
+    }
+
+// --------------------------------------------------------------------------
+// CPbk2MergeConflict::GetContentTextLC
+// --------------------------------------------------------------------------
+//
+HBufC* CPbk2MergeConflict::GetContentTextLC( 
+        EPbk2ConflictedNumber aNumber,
+        const MVPbkStoreContactField* aField )
+    {
+    const MVPbkContactFieldData& data = aField->FieldData();
     TVPbkFieldStorageType storageType = data.DataType();
    
     HBufC* retText = NULL;
@@ -205,7 +249,7 @@
             Panic( EPbk2UnexpectedCase );
         }
     TPtr ptr = retText->Des();
-    CustomizeTextValueL( *field, ptr );
+    CustomizeTextValueL( *aField, ptr );
     return retText;
     }
 
--- a/phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeContactsCmd.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeContactsCmd.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -39,6 +39,7 @@
 #include <CPbk2StoreProperty.h>
 #include <Pbk2StoreProperty.hrh>
 #include <Pbk2ProcessDecoratorFactory.h>
+#include <MPbk2ContactNameFormatter.h>
 
 #include <CPbk2MergeConflictsDlg.h>
 #include <CPbk2MergePhotoConflictDlg.h>
@@ -395,13 +396,8 @@
     iMergedContact = store.CreateNewContactLC();
     CleanupStack::Pop();
     
-    TInt mergedFieldsCount = iMergeResolver->CountMerged();
-    // add merged fields
-    for ( TInt i = 0; i < mergedFieldsCount; i++ )
-        {
-        MVPbkStoreContactField& field = iMergeResolver->GetMergedAt( i );
-        AddFieldToMergedContactL( field );
-        }
+    // the conflict thumbnail data's field, used for comparing
+    MVPbkStoreContactField* thumbnailPicField = NULL;
     
     TInt conflictCount = iMergeResolver->CountConflicts();
     // add conflicted fields
@@ -418,9 +414,35 @@
         for ( TInt j = 0; j < newFields; j++ )
             {
             MVPbkStoreContactField* field = fields[ j ];
+            const MVPbkFieldType* fieldType = field->BestMatchingFieldType();
+            
+            // assign value to thumnailPicField with the field's value
+            if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_THUMBNAILPIC )
+                {
+                thumbnailPicField = field;
+                }
             AddFieldToMergedContactL( *field );
+            } 
+        fields.Close();
+        }
+    
+    TInt mergedFieldsCount = iMergeResolver->CountMerged();
+        
+    // add merged fields
+    for ( TInt i = 0; i < mergedFieldsCount; i++ )
+        {
+        MVPbkStoreContactField& field = iMergeResolver->GetMergedAt( i );
+        const MVPbkFieldType* fieldType = field.BestMatchingFieldType();
+        
+        // avoid merging filePath when the two field unmatched to a contact
+        if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_CALLEROBJIMG && thumbnailPicField )
+            {
+            if ( !thumbnailPicField->ParentContact().IsSame( field.ParentContact() ) )
+                {
+                continue;
+                }
             }
-        fields.Close();
+        AddFieldToMergedContactL( field );
         }
     
     iContactToCommit = new ( ELeave ) CArrayPtrFlat<MVPbkStoreContact>( 1 );
@@ -439,25 +461,12 @@
     CleanupStack::PushL( strings );
     
     HBufC* prompt = NULL;
-    if ( (iFirstContactString->Length() > 0 || iSecondContactString->Length() > 0)
-            && iMergedContactString->Length() > 0 )
+
+    if ( ( iFirstContactString->Compare( *unnamed ) || iSecondContactString->Compare( *unnamed ) )
+            && iMergedContactString->Compare( *unnamed ) )
         {
-        if ( 0 != iFirstContactString->Length() )
-            {
-            strings->AppendL( *iFirstContactString );
-            }
-        else
-            {
-            strings->AppendL( *unnamed );
-            }
-        if ( 0 != iSecondContactString->Length() )
-            {
-            strings->AppendL( *iSecondContactString );
-            }
-        else
-            {
-            strings->AppendL( *unnamed );
-            }
+        strings->AppendL( *iFirstContactString );
+        strings->AppendL( *iSecondContactString );
         strings->AppendL( *iMergedContactString );
 
         prompt = StringLoader::LoadLC( R_QTN_PHOB_NOTE_CONTACTS_WERE_MERGED, *strings );
@@ -483,48 +492,16 @@
 //
 HBufC* CPbk2MergeContactsCmd::ContactAsStringL( MVPbkStoreContact* aStoreContact )
     {
-    _LIT(KResultFormat, "%S %S");
-    TPtrC firstName( KNullDesC() );
-    TPtrC lastName( KNullDesC() );
-	
     MVPbkStoreContactFieldCollection& fields = aStoreContact->Fields();
-    for ( TInt i(0); i < fields.FieldCount(); ++i )
+    HBufC* result = NULL;
+    const TInt KDefaultListFormatting = 
+            MPbk2ContactNameFormatter::EDisableCompanyNameSeparator;
+    result = Phonebook2::Pbk2AppUi()->
+            ApplicationServices().NameFormatter().GetContactTitleL( fields, KDefaultListFormatting );
+    if( !result )
         {
-        MVPbkStoreContactField& field = fields.FieldAt( i );
-        const MVPbkFieldType* fieldType = field.BestMatchingFieldType();
-        if ( fieldType )
-            {
-            if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_FIRSTNAME )
-                {
-                MVPbkContactFieldData& data = field.FieldData();
-                __ASSERT_DEBUG( data.DataType() == EVPbkFieldStorageTypeText, Panic( EPbk2WrongTypeOfData ) );
-                MVPbkContactFieldTextData& textData = MVPbkContactFieldTextData::Cast( data );
-                firstName.Set( textData.Text() );
-                }
-            else if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_LASTNAME )
-                {
-                MVPbkContactFieldData& data = field.FieldData();
-                __ASSERT_DEBUG( data.DataType() == EVPbkFieldStorageTypeText, Panic( EPbk2WrongTypeOfData ) );
-                MVPbkContactFieldTextData& textData = MVPbkContactFieldTextData::Cast( data );
-                lastName.Set( textData.Text() );        
-                }
-            }
-        }
-    
-    HBufC* result = NULL;
-    if ( firstName.Length() > 0 && lastName.Length() > 0 )
-        {
-        result = HBufC::NewL( firstName.Length() + lastName.Length() + KResultFormat().Length() );
-        TPtr resAsDes = result->Des();
-        resAsDes.Format( KResultFormat, &firstName, &lastName );
-        }
-    else if ( firstName.Length() > 0 )
-        {
-        result = firstName.AllocL(); 
-        }    
-    else
-        {
-        result = lastName.AllocL();
+        result = StringLoader::LoadLC( R_QTN_PHOB_UNNAMED );
+        CleanupStack::Pop( result );
         }
     return result;
     }
--- a/phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeResolver.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeResolver.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -31,6 +31,12 @@
 #include <MVPbkContactFieldDateTimeData.h>
 #include <MVPbkContactFieldUriData.h>
 #include <MVPbkContactFieldBinaryData.h>
+#include <vpbkeng.rsg>
+#include <VPbkSyncConstants.h>
+#include <Pbk2UIControls.rsg>
+
+// System includes
+#include <AknUtils.h>
 
 // Debugging headers
 #include <Pbk2Debug.h>
@@ -694,6 +700,26 @@
     CPbk2MergeConflict* conflictNew = CPbk2MergeConflict::NewL();
     CleanupStack::PushL( conflictNew );
     conflictNew->AddFields( aFieldFirst, aFieldSecond );
+
+    //For sync get possibly localised display fields 
+    if( aFieldFirst.BestMatchingFieldType()->FieldTypeResId() == R_VPBK_FIELD_TYPE_SYNCCLASS )
+        {
+        HBufC* first = SyncDisplayFieldLC( aFieldFirst );
+        if( first )
+            {    
+            HBufC* second = SyncDisplayFieldLC( aFieldSecond );
+            if( second )
+                {
+                conflictNew->AddDisplayFields( first, second );
+                CleanupStack::Pop( 2, first );    
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy( first );
+                }
+            }
+        }
+
     iConflicts.AppendL( conflictNew );
     CleanupStack::Pop( conflictNew );
     
@@ -701,6 +727,50 @@
     }
 
 // --------------------------------------------------------------------------
+// CPbk2MergeResolver::SyncDisplayFieldLC
+// --------------------------------------------------------------------------
+//
+HBufC* CPbk2MergeResolver::SyncDisplayFieldLC(
+        const MVPbkStoreContactField& aField )
+    {
+    HBufC* field = NULL;
+    TVPbkFieldStorageType dataType = aField.FieldData().DataType();
+
+    if ( dataType == EVPbkFieldStorageTypeText )
+         {
+         const MVPbkContactFieldTextData& textData =
+               MVPbkContactFieldTextData::Cast( aField.FieldData() );
+         field = LocaliseSyncDisplayFieldLC( textData.Text() );
+         }
+
+    return field;
+    }
+
+// --------------------------------------------------------------------------
+// CPbk2MergeResolver::LocaliseSyncDisplayFieldL
+// --------------------------------------------------------------------------
+//
+HBufC* CPbk2MergeResolver::LocaliseSyncDisplayFieldLC( const TDesC& aContent )
+    {
+    HBufC* txt = NULL;
+
+    if ( !aContent.CompareF( KVPbkContactSyncPublic ) )
+        {
+        txt = CCoeEnv::Static()->AllocReadResourceLC( R_QTN_CALE_CONFIDENT_PUBLIC );
+        }
+    else if ( !aContent.CompareF( KVPbkContactSyncNoSync ) )
+        {
+        txt = CCoeEnv::Static()->AllocReadResourceLC( R_QTN_CALE_CONFIDENT_NONE );
+        }
+    else
+        {
+        txt = CCoeEnv::Static()->AllocReadResourceLC( R_QTN_CALE_CONFIDENT_PRIVATE );
+        }
+
+    return txt;
+    }
+
+// --------------------------------------------------------------------------
 // CPbk2MergeResolver::AddAddressConflictL
 // --------------------------------------------------------------------------
 //
--- a/phonebookui/Phonebook2/GroupExtension/src/CPguAddMembersCmd.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/GroupExtension/src/CPguAddMembersCmd.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -114,6 +114,12 @@
         iFilteredView->RemoveObserver( *this );
         delete iFilteredView;
         }
+    else
+        {
+        Phonebook2::Pbk2AppUi()->
+            ApplicationServices().ViewSupplier().
+            AllContactsViewL()->RemoveObserver( *this );
+        }
     if( iUiControl )
         {
         iUiControl->RegisterCommand( NULL );
@@ -415,11 +421,9 @@
 // --------------------------------------------------------------------------
 //
 void CPguAddMembersCmd::ContactViewError
-        ( MVPbkContactViewBase& PBK2_DEBUG_ONLY( aView ),
+        ( MVPbkContactViewBase&/*aView */,
         TInt aError, TBool /*aErrorNotified*/ )
     {
-    __ASSERT_DEBUG( iFilteredView == &aView, Panic( EInvalidView ) );
-
     FinishCommand( aError );
     }
 
@@ -635,11 +639,23 @@
     {
     delete iFilteredView;
     iFilteredView = NULL;
-    iFilteredView = CVPbkFilteredContactView::NewL
-        ( *Phonebook2::Pbk2AppUi()->ApplicationServices().ViewSupplier().
-          AllContactsViewL(), *this, *this,
-          Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager().
-            FieldTypes() );
+    MPbk2ApplicationServices& appServices = Phonebook2::Pbk2AppUi()->ApplicationServices();
+    TInt count = KErrNotFound;
+    if ( !iContactsInGroup && iContactGroup )
+        {
+        iContactsInGroup = iContactGroup->ItemsContainedLC();
+        CleanupStack::Pop(); // iContactsInGroup
+        }
+    if ( iContactsInGroup )
+        {
+        count = iContactsInGroup->Count();
+        }
+    if ( count > 0 || count == KErrNotFound )
+        {
+        iFilteredView = CVPbkFilteredContactView::NewL
+            ( *appServices.ViewSupplier().AllContactsViewL(), *this, *this,
+                    appServices.ContactManager().FieldTypes() );
+        }
 
     DoLaunchFetchDialogL();
     }
@@ -652,8 +668,18 @@
     {
     CPbk2FetchDlg::TParams params;
     params.iResId = R_PBK2_MULTIPLE_ENTRY_FETCH_NO_GROUPS_DLG;
-    // Fetch dlg uses this view instead of AllNameslistView
-    params.iNamesListView = iFilteredView;
+    if ( iFilteredView )
+        {
+        // Fetch dlg uses this view instead of AllNameslistView
+        params.iNamesListView = iFilteredView;
+        }
+    else
+        {
+        MVPbkContactViewBase* view = Phonebook2::Pbk2AppUi()
+            ->ApplicationServices().ViewSupplier().AllContactsViewL();
+        view->AddObserverL( *this );
+        params.iNamesListView = view;
+        }
     params.iFlags = CPbk2FetchDlg::EFetchMultiple;
     params.iNaviPaneId = R_PBK2_GROUP_MEMBER_FETCH_NAVILABEL;
 
--- a/phonebookui/Phonebook2/MMCExtension/inc/CPmuCopyFromMmcCmd.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/MMCExtension/inc/CPmuCopyFromMmcCmd.h	Thu Jul 15 18:22:55 2010 +0300
@@ -32,6 +32,7 @@
 class MVPbkContactStore;
 class CVPbkVCardEng;
 class MVPbkContactOperationBase;
+class CPbk2ApplicationServices;
 
 /**
  * Phonebook 2 MMC UI extension copy from MMC command object.
@@ -124,6 +125,10 @@
         TInt iState;
         /// Own: Path to contacts in memory card
         TFileName iContactsPath;
+        /// Own: A handle to app services singleton
+        CPbk2ApplicationServices* iAppServices;
+        /// Own: ETrue if import must check duplicates.
+        TBool iCheckDuplicates;
 
     };
 
--- a/phonebookui/Phonebook2/MMCExtension/src/CPmuCopyFromDriveCmd.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/MMCExtension/src/CPmuCopyFromDriveCmd.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -28,6 +28,7 @@
 #include <MPbk2ContactNameFormatter.h>
 #include <CPbk2StoreProperty.h>
 #include <CPbk2StorePropertyArray.h>
+#include <CPbk2ApplicationServices.h>
 #include <MPbk2StoreValidityInformer.h>
 #include <MPbk2AppUi.h>
 #include <MPbk2ApplicationServices.h>
@@ -45,6 +46,7 @@
 #include <VPbkContactStoreUris.h>
 #include <MVPbkContactStoreProperties.h>
 #include <CVPbkContactStoreUriArray.h>
+#include <MVPbkContactStoreInfo.h>
 
 // System includes
 #include <pathinfo.h>
@@ -145,7 +147,8 @@
 //
 CPmuCopyFromMmcCmd::CPmuCopyFromMmcCmd( MPbk2ContactUiControl& aUiControl ) :
         CActive( EPriorityStandard ),
-        iUiControl( &aUiControl )
+        iUiControl( &aUiControl ),
+        iCheckDuplicates( ETrue )
     {
     CActiveScheduler::Add( this );
     }
@@ -163,6 +166,7 @@
     delete iDecorator;
     delete iImportOperation;
     delete iVCardEngine;
+    Release( iAppServices );
     }
 
 // --------------------------------------------------------------------------
@@ -186,18 +190,20 @@
 //
 inline void CPmuCopyFromMmcCmd::ConstructL()
     {
+    iAppServices = CPbk2ApplicationServices::InstanceL();
+    
     iVCardEngine = CVPbkVCardEng::NewL
-        ( Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager() );
+        ( iAppServices->ContactManager() );
     iDecorator = Pbk2ProcessDecoratorFactory::CreateProgressDialogDecoratorL
         ( R_PMU_COPY_PROGRESS_NOTE, EFalse );
 
+    
     CPbk2StoreConfiguration* storeConfig = CPbk2StoreConfiguration::NewL();
     CleanupStack::PushL( storeConfig );
-    iTargetStore = Phonebook2::Pbk2AppUi()->ApplicationServices().
-        ContactManager().ContactStoresL().Find(
+    iTargetStore = iAppServices->ContactManager().ContactStoresL().Find(
             storeConfig->DefaultSavingStoreL() );
-
     CleanupStack::PopAndDestroy( storeConfig );
+    iCheckDuplicates = ( iTargetStore->StoreInfo().NumberOfContactsL() > 0 );
 
     // set the default contacts path
     iContactsPath = PathInfo::MemoryCardContactsPath();
@@ -287,13 +293,11 @@
     CleanupStack::PushL( this );
 
     if ( !iTargetStore ||
-          !IsValidStoreL( Phonebook2::Pbk2AppUi()->ApplicationServices().
-            StoreValidityInformer(), iTargetStore ) )
+          !IsValidStoreL( iAppServices->StoreValidityInformer(), iTargetStore ) )
         {
         // if target store not available finish command
         ShowStoreNotAvailableNoteL
-            ( Phonebook2::Pbk2AppUi()->ApplicationServices().
-                StoreProperties() );
+            ( iAppServices->StoreProperties() );
         iCommandObserver->CommandFinished(*this);
         }
     else
@@ -304,7 +308,7 @@
             }
         else
             {
-            Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager().
+            iAppServices->ContactManager().
                 FsSession().GetDir(
                     iContactsPath,
                     KEntryAttNormal | KEntryAttMatchMask,
@@ -417,6 +421,8 @@
     {
     Cancel();
 
+    delete iImportOperation;
+    iImportOperation = NULL;
     iState = EPmuCopyFromMmcCmdComplete;
     IssueRequest();
     }
@@ -437,11 +443,22 @@
         NULL );
 
     User::LeaveIfError( 
-        iReadStream.Open( Phonebook2::Pbk2AppUi()->ApplicationServices().
-            ContactManager().FsSession(),
+        iReadStream.Open( iAppServices->ContactManager().FsSession(),
                 parse.FullName(), EFileRead ) );
-    iImportOperation =
-        iVCardEngine->ImportVCardL( *iTargetStore, iReadStream, *this );
+    
+    // Duplicate checking is one of the major performance bottlenecks in
+    // contact importing. ImportVCardForSyncL ignores the duplicate check so
+    // it is used if the target store is empty before importing.
+    if ( iCheckDuplicates )
+        {
+        iImportOperation =
+                iVCardEngine->ImportVCardL( *iTargetStore, iReadStream, *this );
+        }
+    else
+        {
+        iImportOperation =
+            iVCardEngine->ImportVCardForSyncL( *iTargetStore, iReadStream, *this );
+        }
     ++iCurrentContactIndex;
     iDecorator->ProcessAdvance( 1 );
     }
@@ -527,8 +544,7 @@
     TBool ret = EFalse;
 
     const TVPbkContactStoreUriPtr uri =
-        Phonebook2::Pbk2AppUi()->ApplicationServices().
-            StoreConfiguration().DefaultSavingStoreL();
+            iAppServices->StoreConfiguration().DefaultSavingStoreL();
 
     TVPbkContactStoreUriPtr phoneMemoryUri
         ( VPbkContactStoreUris::DefaultCntDbUri() );
--- a/phonebookui/Phonebook2/MapExtension/inc/cpmapcmd.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/MapExtension/inc/cpmapcmd.h	Thu Jul 15 18:22:55 2010 +0300
@@ -191,11 +191,11 @@
         /**
          * Updates Contact geocoordinates.
          *
-         * @param  aLocality 		object have geocoordinates.
+         * @param  aLandmark        fields returned from Maps API.
          * @param  aAddressType 	Address type.
          */
         void UpdateCoordsL(
-				TLocality& aLocality,
+                const CPosLandmark& aLandmark,
 				TVPbkFieldTypeParameter aAddressType );
         
         /**
--- a/phonebookui/Phonebook2/MapExtension/src/cpmapcmd.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/MapExtension/src/cpmapcmd.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -87,7 +87,7 @@
 _LIT( KGeoSeparator, ",");
 const TInt KGeoSeparatorLength = 1;
 const TReal32 KGeoHorizontalAccuracy = 0;
-const TInt KGeoMaxSize = 50;
+const TInt KGeoMaxSize = 60;
 const TInt KGeoFormatWidth = 11;
 
 // --------------------------------------------------------------------------
@@ -343,46 +343,50 @@
 	for( TInt idx = 0; idx < count; idx++)
 		{
 		MVPbkStoreContactField& field = arrFields.FieldAt(idx);
-		TArray<TVPbkFieldVersitProperty> arrProp = field.BestMatchingFieldType()->VersitProperties();
-		for( TInt idx2 = 0; idx2 < arrProp.Count(); idx2++)
-			{
-			if( arrProp[idx2].Name() == EVPbkVersitNameADR  )
-				{
-				if( arrProp[idx2].Parameters().Contains( EVPbkVersitParamHOME ) )
-					{
-					if( grupId == EPbk2FieldGroupIdNone )
-						{
-						grupId = EPbk2FieldGroupIdHomeAddress;
-						}
-					else if( grupId != EPbk2FieldGroupIdHomeAddress )
-						{
-						return EPbk2FieldGroupIdNone;
-						}
-					}
-				else if( arrProp[idx2].Parameters().Contains( EVPbkVersitParamWORK ) )
-					{
-					if( grupId == EPbk2FieldGroupIdNone )
-						{
-						grupId = EPbk2FieldGroupIdCompanyAddress;
-						}
-					else if( grupId != EPbk2FieldGroupIdCompanyAddress )
-						{
-						return EPbk2FieldGroupIdNone;
-						}
-					}
-				else
-					{
-					if( grupId == EPbk2FieldGroupIdNone )
-						{
-						grupId = EPbk2FieldGroupIdPostalAddress;
-						}
-					else if( grupId != EPbk2FieldGroupIdPostalAddress )
-						{
-						return EPbk2FieldGroupIdNone;
-						}
-					}
-				}
-			}
+		const MVPbkFieldType* type = field.BestMatchingFieldType();
+		if ( type )
+		    {
+            TArray<TVPbkFieldVersitProperty> arrProp = type->VersitProperties();
+            for (TInt idx2 = 0; idx2 < arrProp.Count(); idx2++ )
+                {
+                if ( arrProp[idx2].Name() == EVPbkVersitNameADR )
+                    {
+                    if ( arrProp[idx2].Parameters().Contains( EVPbkVersitParamHOME ) )
+                        {
+                        if ( grupId == EPbk2FieldGroupIdNone )
+                            {
+                            grupId = EPbk2FieldGroupIdHomeAddress;
+                            }
+                        else if ( grupId != EPbk2FieldGroupIdHomeAddress )
+                            {
+                            return EPbk2FieldGroupIdNone;
+                            }
+                        }
+                    else if ( arrProp[idx2].Parameters().Contains( EVPbkVersitParamWORK ) )
+                        {
+                        if ( grupId == EPbk2FieldGroupIdNone )
+                            {
+                            grupId = EPbk2FieldGroupIdCompanyAddress;
+                            }
+                        else if ( grupId != EPbk2FieldGroupIdCompanyAddress )
+                            {
+                            return EPbk2FieldGroupIdNone;
+                            }
+                        }
+                    else
+                        {
+                        if ( grupId == EPbk2FieldGroupIdNone )
+                            {
+                            grupId = EPbk2FieldGroupIdPostalAddress;
+                            }
+                        else if ( grupId != EPbk2FieldGroupIdPostalAddress )
+                            {
+                            return EPbk2FieldGroupIdNone;
+                            }
+                        }
+                    }
+                }
+		    }
 		}
     
 	return grupId;
@@ -686,38 +690,41 @@
 				{
 				continue;
 				}
-			
-			TArray<TVPbkFieldVersitProperty> arrProp = field.BestMatchingFieldType()->VersitProperties();
-			for( TInt idx2 = 0; idx2 < arrProp.Count(); idx2++)
-				{
-				if( arrProp[idx2].Name() == EVPbkVersitNameADR && 
-					( arrProp[idx2].Parameters().Contains(aAddressType) ||
-					  ( aAddressType == EVPbkVersitParamPREF && 
-					    !arrProp[idx2].Parameters().Contains(EVPbkVersitParamHOME) &&
-					    !arrProp[idx2].Parameters().Contains(EVPbkVersitParamWORK) ) ) )
-					{
-					if( arrProp[idx2].SubField() == EVPbkVersitSubFieldCountry )
-						{
-						aLandmark.SetPositionFieldL( EPositionFieldCountry, dataText );
-						continue;
-						}
-					else if( arrProp[idx2].SubField() == EVPbkVersitSubFieldLocality )
-						{
-						aLandmark.SetPositionFieldL( EPositionFieldCity, dataText );
-						continue;
-						}
-					else if( arrProp[idx2].SubField() == EVPbkVersitSubFieldStreet )
-						{
-						aLandmark.SetPositionFieldL( EPositionFieldStreet, dataText );
-						continue;
-						}
-					else if( arrProp[idx2].SubField() == EVPbkVersitSubFieldPostalCode )
-						{
-						aLandmark.SetPositionFieldL( EPositionFieldPostalCode, dataText );
-						continue;
-						}
-					}
-				}
+			const MVPbkFieldType* type = field.BestMatchingFieldType();
+			if ( type )
+			    {
+			    TArray<TVPbkFieldVersitProperty> arrProp = type->VersitProperties();
+                for (TInt idx2 = 0; idx2 < arrProp.Count(); idx2++ )
+                    {
+                    if ( arrProp[idx2].Name() == EVPbkVersitNameADR
+                        && (arrProp[idx2].Parameters().Contains( aAddressType )
+                            || (aAddressType == EVPbkVersitParamPREF
+                                && !arrProp[idx2].Parameters().Contains( EVPbkVersitParamHOME )
+                                && !arrProp[idx2].Parameters().Contains( EVPbkVersitParamWORK ))) )
+                        {
+                        if ( arrProp[idx2].SubField() == EVPbkVersitSubFieldCountry )
+                            {
+                            aLandmark.SetPositionFieldL( EPositionFieldCountry, dataText );
+                            continue;
+                            }
+                        else if ( arrProp[idx2].SubField() == EVPbkVersitSubFieldLocality )
+                            {
+                            aLandmark.SetPositionFieldL( EPositionFieldCity, dataText );
+                            continue;
+                            }
+                        else if ( arrProp[idx2].SubField() == EVPbkVersitSubFieldStreet )
+                            {
+                            aLandmark.SetPositionFieldL( EPositionFieldStreet, dataText );
+                            continue;
+                            }
+                        else if ( arrProp[idx2].SubField() == EVPbkVersitSubFieldPostalCode )
+                            {
+                            aLandmark.SetPositionFieldL( EPositionFieldPostalCode, dataText );
+                            continue;
+                            }
+                        }
+                    }
+			    }
 			}
 		}
 	}
@@ -811,24 +818,26 @@
 			}
 		const TDesC& dataText =
 		    MVPbkContactFieldTextData::Cast( fieldData ).Text();
-		TInt countProps =
-			field.BestMatchingFieldType()->VersitProperties().Count();
-		TArray<TVPbkFieldVersitProperty> props =
-			field.BestMatchingFieldType()->VersitProperties();
-		for ( TInt idx2 = 0; idx2 < countProps; idx2++ )
-			{
-		    if ( ( props[ idx2 ].Parameters().Contains( EVPbkVersitParamHOME ) &&
-		         aAddressType == EVPbkVersitParamHOME ) ||
-			     ( props[ idx2 ].Parameters().Contains( EVPbkVersitParamWORK ) &&
-		           aAddressType == EVPbkVersitParamWORK ) ||
-		           ( !props[ idx2 ].Parameters().Contains( EVPbkVersitParamHOME ) &&
-		             !props[ idx2 ].Parameters().Contains( EVPbkVersitParamWORK ) &&
-		             aAddressType == EVPbkVersitParamPREF ) )
-		    	{
-			    result = DoFillGeoLandmarkL( aLandmark, dataText );
-			    break;
-		    	}
-			}
+		const MVPbkFieldType* type = field.BestMatchingFieldType();
+		if ( type )
+		    {
+		    TInt countProps = type->VersitProperties().Count();
+            TArray<TVPbkFieldVersitProperty> props = type->VersitProperties();
+            for (TInt idx2 = 0; idx2 < countProps; idx2++ )
+                {
+                if ( (props[idx2].Parameters().Contains( EVPbkVersitParamHOME )
+                    && aAddressType == EVPbkVersitParamHOME)
+                    || (props[idx2].Parameters().Contains( EVPbkVersitParamWORK ) 
+                        && aAddressType == EVPbkVersitParamWORK)
+                    || (!props[idx2].Parameters().Contains( EVPbkVersitParamHOME )
+                        && !props[idx2].Parameters().Contains( EVPbkVersitParamWORK ) 
+                        && aAddressType == EVPbkVersitParamPREF) )
+                    {
+                    result = DoFillGeoLandmarkL( aLandmark, dataText );
+                    break;
+                    }
+                }
+		    }
 		}
 	return result;
 	}
@@ -846,7 +855,7 @@
 		{
 		TReal64 latitude = 0;
 		TReal64 logitude = 0;
-		TLex lexLatitude( aDataText.Left( aDataText.Length() - separator ) );
+        TLex lexLatitude( aDataText.Left( separator ) );
 		TLex lexLogitude( aDataText.Right( aDataText.Length()
 				- separator - KGeoSeparatorLength ) );
 		if ( lexLatitude.Val( latitude ) == KErrNone
@@ -855,8 +864,14 @@
 			TLocality loc( TCoordinate( latitude, logitude ),
 					KGeoHorizontalAccuracy );
 			aLandmark.SetPositionL( loc );
-			result = ETrue;
-			}
+            TInt separator2 = aDataText.Right( aDataText.Length() - separator - KGeoSeparatorLength ).Find( KGeoSeparator );
+            if(separator2 != KErrNotFound)
+                {
+                separator += separator2;
+                aLandmark.SetPositionFieldL(EPositionFieldCountryCode,aDataText.Right( aDataText.Length() - separator - (KGeoSeparatorLength * 2) ));
+                }
+            result = ETrue;
+            }
 		}
 	return result;
 	}
@@ -894,6 +909,16 @@
 		iMapView->AddLandmarksToShowL( landmarks );
 		iNoAddress = EFalse;
 		}
+    else
+        {
+        landmark->SetPositionFieldL(EPositionFieldCity,KNullDesC16);
+        TLocality tempLoc;
+        tempLoc.SetCoordinate(-0.0,-0.0);
+        landmark->SetPositionL(tempLoc);
+        
+        landmarks.AppendL( landmark );
+        iMapView->AddLandmarksToShowL( landmarks );
+        }
 
 	iMapView->SelectFromMapL( iStatus );
 	iCurrentMapLaunchedByState = EMapAssignFromMaps;
@@ -907,11 +932,13 @@
 // --------------------------------------------------------------------------
 //
 void CPmapCmd::UpdateCoordsL( 
-		TLocality& aLocality,
+        const CPosLandmark& aLandmark,
 		TVPbkFieldTypeParameter aAddressType )
 	{
-	TReal64 latitude = aLocality.Latitude();
-	TReal64 longitude = aLocality.Longitude();
+    TLocality locality;
+    aLandmark.GetPosition(locality);   
+    TReal64 latitude = locality.Latitude();
+    TReal64 longitude = locality.Longitude();
 	RBuf geoData;
 	RBuf textNumber;
 	CleanupClosePushL( geoData );
@@ -924,6 +951,14 @@
 	geoData += KGeoSeparator();
 	textNumber.Num( longitude, format );
 	geoData += textNumber;
+
+    if(aLandmark.IsPositionFieldAvailable( EPositionFieldCountryCode ))
+        {
+        TPtrC countryCode;
+        aLandmark.GetPositionField(EPositionFieldCountryCode,countryCode);
+        geoData += KGeoSeparator();
+        geoData += countryCode;
+        }
 	CleanupStack::PopAndDestroy( &textNumber );
 	
 	TBool updated = EFalse;
@@ -932,28 +967,30 @@
 	for( TInt idx = 0; idx < count; idx++)
 		{
 		MVPbkStoreContactField& field = arrFields.FieldAt(idx);
-		TInt countProps =
-		    field.BestMatchingFieldType()->VersitProperties().Count();
-		TArray<TVPbkFieldVersitProperty> props =
-		    field.BestMatchingFieldType()->VersitProperties();
-		for ( TInt idx2 = 0; idx2 < countProps; idx2++ )
-		    {
-		    if ( props[ idx2 ].Name() == EVPbkVersitNameGEO &&
-		    	 ( ( props[ idx2 ].Parameters().Contains( EVPbkVersitParamHOME ) &&
-                   aAddressType == EVPbkVersitParamHOME ) ||
-		    	   ( props[ idx2 ].Parameters().Contains( EVPbkVersitParamWORK ) &&
-                     aAddressType == EVPbkVersitParamWORK ) ||
-                     ( !props[ idx2 ].Parameters().Contains( EVPbkVersitParamHOME ) &&
-                       !props[ idx2 ].Parameters().Contains( EVPbkVersitParamWORK ) &&
-                       aAddressType == EVPbkVersitParamPREF ) ) )
-		        {
-		        MVPbkContactFieldData& fieldData = field.FieldData();
-		        MVPbkContactFieldTextData& data = 
-		            MVPbkContactFieldTextData::Cast( fieldData );
-		        data.SetTextL( geoData );
-		        updated = ETrue;
-		        break;
-		        }
+		const MVPbkFieldType* type = field.BestMatchingFieldType();
+		if ( type )
+		    {		    
+		    TInt countProps = type->VersitProperties().Count();
+            TArray<TVPbkFieldVersitProperty> props = type->VersitProperties();
+            for (TInt idx2 = 0; idx2 < countProps; idx2++ )
+                {
+                if ( props[idx2].Name() == EVPbkVersitNameGEO
+                    && ((props[idx2].Parameters().Contains( EVPbkVersitParamHOME ) 
+                        && aAddressType == EVPbkVersitParamHOME)
+                        || (props[idx2].Parameters().Contains( EVPbkVersitParamWORK ) 
+                            && aAddressType == EVPbkVersitParamWORK)
+                        || (!props[idx2].Parameters().Contains( EVPbkVersitParamHOME )
+                            && !props[idx2].Parameters().Contains( EVPbkVersitParamWORK ) 
+                            && aAddressType == EVPbkVersitParamPREF)) )
+                    {
+                    MVPbkContactFieldData& fieldData = field.FieldData();
+                    MVPbkContactFieldTextData& data =
+                        MVPbkContactFieldTextData::Cast( fieldData );
+                    data.SetTextL( geoData );
+                    updated = ETrue;
+                    break;
+                    }
+                }
 		    }
 		}
 	
@@ -1052,36 +1089,40 @@
 		for( TInt idx = 0; idx < count; idx++)
 			{
 			MVPbkStoreContactField& field = arrFields.FieldAt(idx);
-			TArray<TVPbkFieldVersitProperty> arrProp = field.BestMatchingFieldType()->VersitProperties();
-			for( TInt idx2 = 0; idx2 < arrProp.Count(); idx2++)
-				{
-				if( arrProp[idx2].Name() == EVPbkVersitNameADR && 
-					arrProp[idx2].SubField() == aVersitSubField &&
-					( arrProp[idx2].Parameters().Contains(aAddressType) ||
-					  ( aAddressType == EVPbkVersitParamPREF && 
-						!arrProp[idx2].Parameters().Contains(EVPbkVersitParamHOME) &&
-						!arrProp[idx2].Parameters().Contains(EVPbkVersitParamWORK) ) ) )
-					{
-					MVPbkContactFieldData& fieldData = field.FieldData();
-					if( fieldData.DataType() != EVPbkFieldStorageTypeText )
-						{
-						continue;
-						}
-					MVPbkContactFieldTextData& data = 
-					   MVPbkContactFieldTextData::Cast( fieldData );
-					if ( aLandmark.IsPositionFieldAvailable( aPositionField ) )
-						{
-						data.SetTextL( textData );
-						}
-					else
-						{
-						data.SetTextL( KNullDesC() );
-						}
-					
-					updated = ETrue;
-					continue;
-					}
-				}
+			const MVPbkFieldType* type = field.BestMatchingFieldType();
+			if ( type )
+			    {
+                TArray<TVPbkFieldVersitProperty> arrProp = type->VersitProperties();
+                for (TInt idx2 = 0; idx2 < arrProp.Count(); idx2++ )
+                    {
+                    if ( arrProp[idx2].Name() == EVPbkVersitNameADR
+                        && arrProp[idx2].SubField() == aVersitSubField
+                        && (arrProp[idx2].Parameters().Contains( aAddressType )
+                            || (aAddressType == EVPbkVersitParamPREF
+                                && !arrProp[idx2].Parameters().Contains( EVPbkVersitParamHOME )
+                                && !arrProp[idx2].Parameters().Contains( EVPbkVersitParamWORK ))) )
+                        {
+                        MVPbkContactFieldData& fieldData = field.FieldData();
+                        if ( fieldData.DataType() != EVPbkFieldStorageTypeText )
+                            {
+                            continue;
+                            }
+                        MVPbkContactFieldTextData& data =
+                            MVPbkContactFieldTextData::Cast( fieldData );
+                        if ( aLandmark.IsPositionFieldAvailable( aPositionField ) )
+                            {
+                            data.SetTextL( textData );
+                            }
+                        else
+                            {
+                            data.SetTextL( KNullDesC() );
+                            }
+
+                        updated = ETrue;
+                        continue;
+                        }
+                    }
+			    }
 			}
 		}
 	
@@ -1135,13 +1176,17 @@
 	for( TInt idx = 0; idx < count; idx++)
 		{
 		MVPbkStoreContactField& field = arrFields.FieldAt(idx);
-		TArray<TVPbkFieldVersitProperty> arrProp = field.BestMatchingFieldType()->VersitProperties();
-		for( TInt idx2 = 0; idx2 < arrProp.Count(); idx2++)
-			{
-			if( arrProp[idx2].Name() == EVPbkVersitNameADR  )
-				{
-				return ETrue;
-				}
+		const MVPbkFieldType* type = field.BestMatchingFieldType();
+		if ( type )
+		    {
+		    TArray<TVPbkFieldVersitProperty> arrProp = type->VersitProperties();
+		    for( TInt idx2 = 0; idx2 < arrProp.Count(); idx2++)
+			    {
+			    if( arrProp[idx2].Name() == EVPbkVersitNameADR  )
+			    	{
+				    return ETrue;
+				    }
+			    }
 			}
 		}
 	return EFalse;
@@ -1373,7 +1418,7 @@
             
             if( geocoordsExist )
                 {
-                UpdateCoordsL( locality, iAddressType );
+                UpdateCoordsL( *result, iAddressType);
                 }
             if ( !iEditorControl )
                 {
@@ -1558,7 +1603,7 @@
 
         if ( geocoordsExist )
             {
-            UpdateCoordsL( locality, iAddressType );
+            UpdateCoordsL( *result, iAddressType );
             }
         if ( !iEditorControl )
             {
--- a/phonebookui/Phonebook2/ServerApplication/inc/CPbk2ItemFetcher.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/ServerApplication/inc/CPbk2ItemFetcher.h	Thu Jul 15 18:22:55 2010 +0300
@@ -147,6 +147,8 @@
         TBool iUseDeviceConfig;
         /// Own: Communication address select phase
         MPbk2ServicePhase* iCommAddressSelectPhase;
+        /// Holds the StatusPane Id that needs to be used
+        TInt iStatusPaneId;
     };
 
 #endif // CPBK2ITEMFETCHER_H
--- a/phonebookui/Phonebook2/ServerApplication/inc/TPbk2ServerMessageDataRetriever.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/ServerApplication/inc/TPbk2ServerMessageDataRetriever.h	Thu Jul 15 18:22:55 2010 +0300
@@ -263,6 +263,16 @@
          * @return  The client orientation settings.
          */
         TInt GetOrietationTypeL(const RMessage2& aMessage ) const;
+        
+        
+        /**
+         * Gets StatusPane ID that should be used by the ServerApplication
+         *
+         * @param aMessage              The message to retrieve data from.
+         * @return  valid StatusPane ID or 0 if it was not sent.
+         */
+        TInt TPbk2ServerMessageDataRetriever::GetStatusPaneIdL
+                ( const RMessage2& aMessage ) const;
     };
 
 #endif // TPBK2SERVERMESSAGEDATARETRIEVER_H
--- a/phonebookui/Phonebook2/ServerApplication/src/CPbk2CommAddressSelectPhase.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/ServerApplication/src/CPbk2CommAddressSelectPhase.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -246,12 +246,6 @@
     
     RetrieveContactL();
     
-    CPbk2ServerAppAppUi& appUi = static_cast<CPbk2ServerAppAppUi&>
-        ( *CEikonEnv::Static()->EikAppUi() );
-
-    // Change layout back to regular
-    appUi.ChangeStatuspaneLayoutL(
-        CPbk2ServerAppAppUi::EStatusPaneLayoutUsual );
     }
 
 // --------------------------------------------------------------------------
--- a/phonebookui/Phonebook2/ServerApplication/src/CPbk2ItemFetcher.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/ServerApplication/src/CPbk2ItemFetcher.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -74,6 +74,23 @@
     titlePaneOperator.SetTitlePaneL( titlePaneText ); // takes ownership
     }
 
+
+/**
+ * Change the StatusPane layout to use the mentioned StatusPane ID.
+ *
+ * @param aStatusPaneId     StatusPane ID
+ */
+void SetStatusPaneL( TInt aStatusPaneId )
+    {
+    CEikStatusPane* statusPane =
+            CEikonEnv::Static()->AppUiFactory()->StatusPane();
+    
+    if ( statusPane && 0 != aStatusPaneId )
+        {
+        statusPane->SwitchLayoutL( aStatusPaneId );        
+        }                    
+    }
+
 struct TMap
     {
     TAiwCommAddressSelectType aiwType;
@@ -205,7 +222,8 @@
         ( MPbk2UiServiceObserver& aObserver,
           TPbk2FetchType aFetchType ) :
             iObserver( aObserver ),
-            iFetchType( aFetchType )
+            iFetchType( aFetchType ),
+            iStatusPaneId( 0 )
     {
     PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING
         ("CPbk2ItemFetcher::CPbk2ItemFetcher()") );
@@ -263,6 +281,8 @@
 
     // Set title pane
     SetTitlePaneL( dataRetriever, flags, aMessage );
+    
+    iStatusPaneId = dataRetriever.GetStatusPaneIdL( aMessage );
 
     iPreselectedContacts = dataRetriever.GetPreselectedContactLinksL
         ( aMessage, appUi.ApplicationServices().ContactManager() );
@@ -675,6 +695,9 @@
     delete iCommAddressSelectPhase;
     iCommAddressSelectPhase = NULL;
     
+    //Restore the appropriate StatusPane
+    SetStatusPaneL( iStatusPaneId );
+    
     if ( iCommAddressSelectType != VPbkFieldTypeSelectorFactory::EEmptySelector )
         {
         iCommAddressSelectPhase = CPbk2CommAddressSelectPhase::NewL
--- a/phonebookui/Phonebook2/ServerApplication/src/TPbk2ServerMessageDataRetriever.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/ServerApplication/src/TPbk2ServerMessageDataRetriever.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -64,6 +64,7 @@
 const TInt KAddressSelectFilterBuffer( 2 );
 const TInt KContactViewFilterBuffer( 3 );
 const TInt KTitlePaneTextPosition( 4 );
+const TInt KStatusPaneIdPosition( 5 );
 const TInt KDefaultPrioritiesPosition( 2 );
 const TInt KOrientationType( 5 );
 
@@ -511,6 +512,7 @@
 
         CleanupStack::PopAndDestroy( &readStream );
         CleanupStack::PopAndDestroy( configuration );
+        
         }
 
     return titlePaneText;
@@ -910,5 +912,41 @@
         }
     return orientationType;
     }
+
+// --------------------------------------------------------------------------
+// TPbk2ServerMessageDataRetriever::GetStatusPaneIdL
+// --------------------------------------------------------------------------
+//
+TInt TPbk2ServerMessageDataRetriever::GetStatusPaneIdL
+        ( const RMessage2& aMessage ) const
+    {
+    TInt statusPaneId( 0 );
+    HBufC8* statusPaneIdInText = NULL;
+    TInt length = aMessage.GetDesLengthL( KConfigurationPackageSlot );
+    
+    if ( length > 0 )
+        {
+        HBufC8* configuration = HBufC8::NewLC( length );
+        TPtr8 ptr = configuration->Des();
+        aMessage.ReadL( KConfigurationPackageSlot, ptr );
+        RDesReadStream readStream( ptr );
+        readStream.PushL();
+
+        TRAPD( error, Pbk2IPCPackage::InternalizeL
+            ( statusPaneIdInText, readStream, KStatusPaneIdPosition ) );        
+        
+        if ( KErrNone == error && statusPaneIdInText )
+            {
+            TLex8 aLex(*statusPaneIdInText);        
+            error = aLex.Val( statusPaneId );
+            delete statusPaneIdInText;
+            }
+            
+        CleanupStack::PopAndDestroy( &readStream );
+        CleanupStack::PopAndDestroy( configuration );
+        }
+
+    return statusPaneId;
+    }
     
 // End of File
--- a/phonebookui/Phonebook2/UIControls/inc/cpbk2contactviewdoublelistboxmodel.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/UIControls/inc/cpbk2contactviewdoublelistboxmodel.h	Thu Jul 15 18:22:55 2010 +0300
@@ -26,8 +26,6 @@
 class CPbk2ThumbnailManager;
 class MPbk2ContactUiControlDoubleListboxExtension;
 class CPbk2ContactViewDoubleListboxDataElement;
-class CDataElementCache;
-class MPbk2FilteredViewStack;
 
 // CLASS DECLARATION
 
@@ -47,8 +45,7 @@
      */
      static CPbk2ContactViewDoubleListBoxModel* NewL(
             CPbk2ContactViewListBoxModel::TParams& aParams,
-            CPbk2ThumbnailManager& aThumbManager,
-            MPbk2FilteredViewStack& aFilteredViewStack );
+            CPbk2ThumbnailManager& aThumbManager );
 
     /**
      * Destructor.
@@ -64,8 +61,7 @@
      */
     CPbk2ContactViewDoubleListBoxModel(
         CPbk2ContactViewListBoxModel::TParams& aParams,
-        CPbk2ThumbnailManager& aThumbManager,
-        MPbk2FilteredViewStack& aFilteredViewStack );
+        CPbk2ThumbnailManager& aThumbManager );
 
 protected: // new 
     
@@ -93,17 +89,15 @@
      */
     void AppendIconIndexIfFound( const TPbk2IconId& aIconId ) const;
 
-    void FormatBufferForElementDataL(
-        CPbk2ContactViewDoubleListboxDataElement& aDataElement, 
-        TInt aIndex ) const;
-
     void AppendThumbnailL( 
             CPbk2ContactViewDoubleListboxDataElement& aDataElement, 
-            TInt aIndex ) const;
+            TInt aIndex,
+            const MVPbkContactLink& aLink ) const;
     
     void FetchDataFromExtension(
             CPbk2ContactViewDoubleListboxDataElement& aDataElement,
-            TInt aIndex ) const;
+            TInt aIndex,
+            const MVPbkContactLink& aLink ) const;
     
 public: // From CPbk2ContactViewListBoxModel
     void FormatBufferL( 
@@ -120,11 +114,6 @@
 	/// Ref
 	MPbk2ContactUiControlDoubleListboxExtension* iDoubleListExtensionPoint;
 	
-	/// Own:
-	CDataElementCache* iDataElementCache;
-	
-	/// Ref
-	MPbk2FilteredViewStack& iFilteredViewStack;
     };
 
 #endif // CPBK2CONTACTVIEWDOUBLELISTBOXMODEL_H
--- a/phonebookui/Phonebook2/UIControls/inc/pbk2contactviewdoublelistboxdataelement.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/UIControls/inc/pbk2contactviewdoublelistboxdataelement.h	Thu Jul 15 18:22:55 2010 +0300
@@ -25,7 +25,6 @@
 #include <TPbk2IconId.h>
 
 //FORWARD
-class MVPbkContactLink;
 
 // CLASS DECLARATION
 
@@ -38,15 +37,11 @@
         public MPbk2DoubleListboxDataElement
     {
 public: // constructor and destructor
-    static CPbk2ContactViewDoubleListboxDataElement* NewL(
-            MVPbkContactLink* aLink = NULL,
-            TInt aListIndex = KErrNotFound );
+    static CPbk2ContactViewDoubleListboxDataElement* NewLC();
     ~CPbk2ContactViewDoubleListboxDataElement();
 
     TPtr TextPtr(
             MPbk2DoubleListboxDataElement::TTextDataElementItems aIndex) const;
-    inline const MVPbkContactLink* ContactLink();
-    inline TInt ListIndex();
     
 public: // from MPbk2DoubleListboxDataElement
     const TPbk2IconId& IconId( 
@@ -64,7 +59,7 @@
             HBufC* aBuffer,
             MPbk2DoubleListboxDataElement::TTextDataType aType );
 private:
-    inline CPbk2ContactViewDoubleListboxDataElement(TInt aListIndex);
+    inline CPbk2ContactViewDoubleListboxDataElement();
     inline void ConstructL();
 
 private:
@@ -73,24 +68,8 @@
     TFixedArray<TTextDataType, 2 > iTextType;
     /// Own
     HBufC* iEmptyBuffer;
-    /// Own: for data cache
-    MVPbkContactLink* iLink;
-    /// for data cache
-    TInt iListIndex;
     };
 
-inline const MVPbkContactLink* 
-CPbk2ContactViewDoubleListboxDataElement::ContactLink()
-    {
-    return iLink;
-    }
-
-inline TInt CPbk2ContactViewDoubleListboxDataElement::ListIndex()
-    {
-    return iListIndex;
-    }
-
-
 #endif // PBK2CONTACTVIEWDOUBLELISTBOXDATAELEMENT_H
 
 // End of File
--- a/phonebookui/Phonebook2/UIControls/src/CPbk2AdaptiveSearchGridFiller.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/UIControls/src/CPbk2AdaptiveSearchGridFiller.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -777,9 +777,18 @@
     {
     TBool result = ETrue;
     const TInt fieldCount = aContact.Fields().FieldCount();
-    for ( TInt i = ENameFirstPart; i <= ENameSecondPart && i < fieldCount; ++i)
-        {     
-        const MVPbkBaseContactField& field = aContact.Fields().FieldAt( i );
+    if ( fieldCount > ENameCompanyPart )
+        {
+        const MVPbkBaseContactField& field = aContact.Fields().FieldAt( ENameCompanyPart );
+        if ( iNameFormatter.IsTitleField( field ) )
+            {
+            return EFalse;
+            }
+        }
+   
+    if ( fieldCount > ENameFirstPart ) 
+        {
+        const MVPbkBaseContactField& field = aContact.Fields().FieldAt( ENameFirstPart );
         if ( iNameFormatter.IsTitleField( field ) )
             {
             const MVPbkContactFieldData& fieldData = field.FieldData();
@@ -799,7 +808,6 @@
                     if ( firstNonSpaceChar != length )
                         {
                         result = EFalse;
-                        break;
                         }
                     }   
                 }
--- a/phonebookui/Phonebook2/UIControls/src/CPbk2ContactViewListBox.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/UIControls/src/CPbk2ContactViewListBox.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -58,6 +58,8 @@
 
 // LOCAL FUNCTIONS
 
+_LIT( KTabChar, "\t" );
+
 /**
  * Returns icon array from given list box.
  *
@@ -702,14 +704,20 @@
         textLayout.LayoutText(layout.Rect(), AknLayoutScalable_Apps::popup_navstr_preview_pane_t1(0).LayoutLine());
 
         TPtrC desc(Model()->ItemTextArray()->MdcaPoint(View()->TopItemIndex()));
+		
+        //Add "if-clause" to avaid the error that argument of Mid() out of range.
+        TInt index = desc.Find( KTabChar );
+        if ( index != KErrNotFound && index < desc.Length()-1 )
+            {
+            HBufC* buf = desc.Mid( index + 1, 1 ).AllocL();           
 
-        HBufC* buf = desc.Mid(desc.Find(_L("\t")) + 1, 1).AllocL();
-        TPtr textPtr = buf->Des();
-        textPtr.UpperCase();
-        
-        textLayout.DrawText(*gc, textPtr, ETrue, normal );
-        
-        delete buf;
+            TPtr textPtr = buf->Des();
+            textPtr.UpperCase();
+
+            textLayout.DrawText( *gc, textPtr, ETrue, normal );
+
+            delete buf;
+            }
         }
     }
 // End of File
--- a/phonebookui/Phonebook2/UIControls/src/cpbk2contactviewdoublelistbox.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/UIControls/src/cpbk2contactviewdoublelistbox.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -125,7 +125,7 @@
         		CPbk2ContactViewListBoxModel::TParams params )
 	{
 	return CPbk2ContactViewDoubleListBoxModel::NewL( 
-	        params, iThumbManager, iView );
+	        params, iThumbManager );
 	}
 
 
--- a/phonebookui/Phonebook2/UIControls/src/cpbk2contactviewdoublelistboxmodel.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/UIControls/src/cpbk2contactviewdoublelistboxmodel.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -64,273 +64,17 @@
 // -> max length for name data is 100 and max lenght for status data is 100
 // rest 56 are reserved for icon data
 const TInt KMaxTxtLength = 100;
-
-const TInt KDataElementCacheSize = 20;
 }
 
-/**
- * Cache for data elements, cache is made to avoid performance problems that 
- * caused in cases when avkon implementation calls multiple times MdcaPoint function with same index
- * Cached items must be deleted when there is any change in contact list.
- */
-NONSHARABLE_CLASS( CDataElementCache ) : 
-        public CBase,
-        public MVPbkContactViewObserver,
-        public MPbk2FilteredViewStackObserver
-    {
-public:
-    static CDataElementCache* NewL(MPbk2FilteredViewStack& aView);
-    ~CDataElementCache();
-
-    void AppendL( CPbk2ContactViewDoubleListboxDataElement* aDataElement );
-    CPbk2ContactViewDoubleListboxDataElement* Element( TInt aListIndex );
-    
-private:    // From MVPbkContactViewObserver
-     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 );
-
-private:    // From MPbk2FilteredViewStackObserver
-      void TopViewChangedL(
-              MVPbkContactViewBase& aOldView );
-      void TopViewUpdatedL();
-      void BaseViewChangedL();
-      void ViewStackError(
-              TInt aError );
-      void ContactAddedToBaseView( 
-              MVPbkContactViewBase& aBaseView,
-              TInt aIndex,
-              const MVPbkContactLink& aContactLink ); 
-     
-private:
-    inline CDataElementCache( MPbk2FilteredViewStack& aView );
-    inline void ConstructL();
-    inline void Reset();
-
-private:    
-    RPointerArray<CPbk2ContactViewDoubleListboxDataElement> iCache;
-    MPbk2FilteredViewStack& iView;
-    };
-
-// --------------------------------------------------------------------------
-// CDataElementCache::NewL
-// --------------------------------------------------------------------------
-//
-CDataElementCache* CDataElementCache::NewL( MPbk2FilteredViewStack& aView )
-    {
-    CDataElementCache* self = new (ELeave) CDataElementCache(aView);
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::CDataElementCache
-// --------------------------------------------------------------------------
-//
-inline CDataElementCache::CDataElementCache( MPbk2FilteredViewStack& aView )
-: iCache( KDataElementCacheSize ), 
-  iView( aView )
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::ConstructL
-// --------------------------------------------------------------------------
-//
-inline void CDataElementCache::ConstructL()
-    {
-    iView.AddObserverL(*this);
-    iView.AddStackObserverL(*this);
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::~CDataElementCache
-// --------------------------------------------------------------------------
-//
-CDataElementCache::~CDataElementCache()
-    {
-    Reset();
-    iView.RemoveObserver(*this);
-    iView.RemoveStackObserver(*this);
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::AppendL
-// --------------------------------------------------------------------------
-//
-void CDataElementCache::AppendL( 
-        CPbk2ContactViewDoubleListboxDataElement* aDataElement )
-    {
-    iCache.InsertL( aDataElement, 0 );
-    const TInt cacheItemCount( iCache.Count() );
-    if( cacheItemCount > KDataElementCacheSize )
-        {
-        delete iCache[cacheItemCount - 1];
-        iCache.Remove(cacheItemCount - 1);
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::Reset
-// --------------------------------------------------------------------------
-//
-inline void CDataElementCache::Reset()
-    {
-    iCache.ResetAndDestroy();
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::Element
-// --------------------------------------------------------------------------
-//
-CPbk2ContactViewDoubleListboxDataElement* 
-CDataElementCache::Element( TInt aListIndex )
-    {
-    const TInt cacheItemCount( iCache.Count() );
-    for( TInt i = 0 ; i < cacheItemCount ; ++i )
-        {
-        CPbk2ContactViewDoubleListboxDataElement* p = iCache[i];
-        if( p->ListIndex() == aListIndex )
-            {
-            return p;
-            }
-        }
-    return NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::ContactViewReady
-// --------------------------------------------------------------------------
-//
-void CDataElementCache::ContactViewReady(
-        MVPbkContactViewBase& /*aView*/ )
-    {
-    Reset();
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::ContactViewUnavailable
-// --------------------------------------------------------------------------
-//
-void CDataElementCache::ContactViewUnavailable(
-        MVPbkContactViewBase& /*aView*/ )
-    {
-    Reset();
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::ContactAddedToView
-// --------------------------------------------------------------------------
-//
-void CDataElementCache::ContactAddedToView(
-        MVPbkContactViewBase& /*aView*/,
-        TInt /*aIndex*/,
-        const MVPbkContactLink& /*aContactLink*/ )
-    {
-    Reset();
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::ContactRemovedFromView
-// --------------------------------------------------------------------------
-//
-void CDataElementCache::ContactRemovedFromView(
-        MVPbkContactViewBase& /*aView*/,
-        TInt /*aIndex*/,
-        const MVPbkContactLink& /*aContactLink*/ )
-    {
-    Reset();
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::ContactViewError
-// --------------------------------------------------------------------------
-//
-void CDataElementCache::ContactViewError(
-        MVPbkContactViewBase& /*aView*/,
-        TInt /*aError*/,
-        TBool /*aErrorNotified*/ )
-    {
-    Reset();
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::TopViewChangedL
-// --------------------------------------------------------------------------
-//
-void CDataElementCache::TopViewChangedL(
-        MVPbkContactViewBase& /*aOldView*/ )
-    {
-    Reset();
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::TopViewUpdatedL
-// --------------------------------------------------------------------------
-//
-void CDataElementCache::TopViewUpdatedL()
-    {
-    Reset();
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::BaseViewChangedL
-// --------------------------------------------------------------------------
-//
-void CDataElementCache::BaseViewChangedL()
-    {
-    Reset();
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::ViewStackError
-// --------------------------------------------------------------------------
-//
-void CDataElementCache::ViewStackError(
-        TInt /*aError*/ )
-    {
-    Reset();
-    }
-
-// --------------------------------------------------------------------------
-// CDataElementCache::ContactAddedToBaseView
-// --------------------------------------------------------------------------
-//
-void CDataElementCache::ContactAddedToBaseView( 
-        MVPbkContactViewBase& /*aBaseView*/,
-        TInt /*aIndex*/,
-        const MVPbkContactLink& /*aContactLink*/ ) 
-    {
-    Reset();
-    }
-
-
 // --------------------------------------------------------------------------
 // CPbk2ContactViewDoubleListBoxModel::CPbk2ContactViewDoubleListBoxModel
 // --------------------------------------------------------------------------
 //
 CPbk2ContactViewDoubleListBoxModel::CPbk2ContactViewDoubleListBoxModel(
     CPbk2ContactViewListBoxModel::TParams& aParams,
-    CPbk2ThumbnailManager& aThumbManager,
-    MPbk2FilteredViewStack& aFilteredViewStack ) :
+    CPbk2ThumbnailManager& aThumbManager ) :
     CPbk2ContactViewListBoxModel( aParams ),
-    iThumbManager( aThumbManager ),
-    iFilteredViewStack( aFilteredViewStack )
+    iThumbManager( aThumbManager )
     {
     TAny* object = aParams.iUiExtension->ContactUiControlExtensionExtension
             ( TUid::Uid( KPbk2ContactUiControlExtensionExtensionUID ) );
@@ -344,7 +88,6 @@
 //
 CPbk2ContactViewDoubleListBoxModel::~CPbk2ContactViewDoubleListBoxModel()
     {
-    delete iDataElementCache;
     }
 
 // --------------------------------------------------------------------------
@@ -353,16 +96,14 @@
 //
 CPbk2ContactViewDoubleListBoxModel* CPbk2ContactViewDoubleListBoxModel::NewL(
     CPbk2ContactViewListBoxModel::TParams& aParams,
-    CPbk2ThumbnailManager& aThumbManager,
-    MPbk2FilteredViewStack& aFilteredViewStack )
+    CPbk2ThumbnailManager& aThumbManager )
     {
     CPbk2ContactViewDoubleListBoxModel* self =
         new ( ELeave ) CPbk2ContactViewDoubleListBoxModel( 
-                aParams, aThumbManager, aFilteredViewStack );
+		    aParams, aThumbManager );
 
     CleanupStack::PushL(self);
     self->ConstructL( aParams.iStoreProperties, aParams.iUiExtension );
-    self->iDataElementCache = CDataElementCache::NewL( aFilteredViewStack );
     CleanupStack::Pop();
     return self;
     }
@@ -376,17 +117,9 @@
     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
         ("CPbk2ContactViewDoubleListBoxModel::FormatBufferL(0x%x,%d), begin"),
         this);
-    CPbk2ContactViewDoubleListboxDataElement* element = 
-            iDataElementCache->Element( aIndex );
-    if( element )
-        {
-        FormatBufferForElementDataL(*element, aIndex);
-        }
-    else
-        {
-        const MVPbkViewContact& contact = iView->ContactAtL(aIndex);
-        FormatBufferForContactL(contact, aIndex );
-        }
+
+    const MVPbkViewContact& contact = iView->ContactAtL(aIndex);
+    FormatBufferForContactL(contact, aIndex );
     
     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
         ("CPbk2ContactViewDoubleListBoxModel::FormatBufferL(0x%x,%d), end"),
@@ -395,12 +128,13 @@
 
 
 // --------------------------------------------------------------------------
-// CPbk2ContactViewDoubleListBoxModel::FormatBufferForElementDataL
+// CPbk2ContactViewDoubleListBoxModel::FetchDataFromExtension
 // --------------------------------------------------------------------------
 //
 void CPbk2ContactViewDoubleListBoxModel::FetchDataFromExtension(
         CPbk2ContactViewDoubleListboxDataElement& aDataElement,
-        TInt aIndex ) const
+        TInt aIndex,
+        const MVPbkContactLink& aLink ) const
     {
     // Get element data from extension
     // 
@@ -408,12 +142,12 @@
         {
         TRAPD( err, 
             iDoubleListExtensionPoint->FormatDataL( 
-                    *(aDataElement.ContactLink()), aDataElement ) );
+                    aLink, aDataElement ) );
         if( err )
             {
             // extension's errors are ignored.  
             PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING(
-            "CPbk2ContactViewDoubleListBoxModel::FormatBufferForElementDataL format error %d"),
+            "CPbk2ContactViewDoubleListBoxModel::FetchDataFromExtension format error %d"),
                 err );
             }
         }
@@ -431,40 +165,6 @@
     }
 
 // --------------------------------------------------------------------------
-// CPbk2ContactViewDoubleListBoxModel::FormatBufferForElementDataL
-// --------------------------------------------------------------------------
-//
-void CPbk2ContactViewDoubleListBoxModel::FormatBufferForElementDataL(
-    CPbk2ContactViewDoubleListboxDataElement& aDataElement, 
-    TInt aIndex ) const
-    {
-    FetchDataFromExtension(aDataElement, aIndex);
-
-    // start fill the new buffer for the avkon list
-    iBuffer.Zero();
-
-    AppendThumbnailL( aDataElement, aIndex );
-    
-    // The cached element needs to be updated when the presence icon is changed
-    RArray<TPbk2IconId> ids;
-    CleanupClosePushL( ids );    
-    const MVPbkViewContact& contact = iView->ContactAtL( aIndex );
-    iContactIcons->GetIconIdsForContactL( contact, ids );
-
-    // If no icon was found, append an empty icon
-    if( ids.Count() == 0 )
-        {
-        ids.Append( iEmptyIconId );
-        }
-    
-    aDataElement.SetIconId( MPbk2DoubleListboxDataElement::EMainIcon, ids[ 0 ] );
-    CleanupStack::PopAndDestroy( &ids );
-    
-    // Format line buffer based on element's content
-    FormatBufferFromElement( aDataElement );
-    }
-
-// --------------------------------------------------------------------------
 // CPbk2ContactViewDoubleListBoxModel::FormatBufferForContactL
 // --------------------------------------------------------------------------
 //
@@ -472,14 +172,8 @@
     const MVPbkViewContact& aViewContact, 
     TInt aIndex ) const
     {
-    MVPbkContactLink* link = aViewContact.CreateLinkLC();
     CPbk2ContactViewDoubleListboxDataElement* element = 
-        CPbk2ContactViewDoubleListboxDataElement::NewL( link, aIndex );
-    if( link )
-        {
-        CleanupStack::Pop();    // link
-        }
-    CleanupStack::PushL( element );
+        CPbk2ContactViewDoubleListboxDataElement::NewLC();
 
     // get data for element
     // get user name
@@ -529,19 +223,20 @@
     element->SetIconId( MPbk2DoubleListboxDataElement::EMainIcon, ids[0] );
     CleanupStack::PopAndDestroy( &ids );
 
+    MVPbkContactLink* link = aViewContact.CreateLinkLC();
+    
     // Get element data from extension
-    FetchDataFromExtension( *element, aIndex );
+    FetchDataFromExtension( *element, aIndex, *link );
 
     // start format data for the avkon list
     iBuffer.Zero();
     
-    AppendThumbnailL( *element, aIndex );
+    AppendThumbnailL( *element, aIndex, *link );
     
     // Format line buffer based on element's content
     FormatBufferFromElement( *element );
     
-    iDataElementCache->AppendL( element );
-    CleanupStack::Pop( element ); 
+    CleanupStack::PopAndDestroy( 2, element ); // link, element
     }
 
 // --------------------------------------------------------------------------
@@ -576,12 +271,13 @@
 //
 void CPbk2ContactViewDoubleListBoxModel::AppendThumbnailL( 
         CPbk2ContactViewDoubleListboxDataElement& aDataElement, 
-        TInt aIndex ) const
+        TInt aIndex,
+        const MVPbkContactLink& aLink ) const
     {
     // (1) Add thumbnail icon
     //
     TInt index = iThumbManager.GetPbkIconIndexL( 
-            aIndex, *(aDataElement.ContactLink()) );
+            aIndex, aLink );
     if( index != KErrNotFound )
         {
         iBuffer.AppendNum( index );
--- a/phonebookui/Phonebook2/UIControls/src/cpbk2doublelistboxmodelcmddecorator.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/UIControls/src/cpbk2doublelistboxmodelcmddecorator.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -42,7 +42,8 @@
 		TPbk2IconId aDefaultIconId )
 	{
 	CPbk2DoubleListboxModelCmdDecorator* self = 
-				new(ELeave)CPbk2DoubleListboxModelCmdDecorator( aIconArray, aEmptyIconId, aDefaultIconId);
+				new(ELeave)CPbk2DoubleListboxModelCmdDecorator( 
+				        aIconArray, aEmptyIconId, aDefaultIconId);
 	CleanupStack::PushL( self );
 	self->ConstructL();
 	CleanupStack::Pop();
@@ -60,8 +61,6 @@
 		TPbk2IconId aDefaultIconId )
 : CPbk2ListboxModelCmdDecorator( aIconArray, aEmptyIconId, aDefaultIconId )
 	{
-
-
 	}
 
 // --------------------------------------------------------------------------
@@ -80,7 +79,8 @@
 void CPbk2DoubleListboxModelCmdDecorator::ConstructL()
     {
     CPbk2ListboxModelCmdDecorator::ConstructL();
-    iElement = CPbk2ContactViewDoubleListboxDataElement::NewL();
+    iElement = CPbk2ContactViewDoubleListboxDataElement::NewLC();
+    CleanupStack::Pop( iElement );
     }
 
 // --------------------------------------------------------------------------
@@ -103,7 +103,8 @@
 		TPtrC name( item.NameForUi() );
 		
 		//check if we have a mycard command item
-		TAny* object = item.ControlCmdItemExtension( TUid::Uid( KPbk2ControlCmdItemExtensionUID ) );
+		TAny* object = item.ControlCmdItemExtension( 
+		        TUid::Uid( KPbk2ControlCmdItemExtensionUID ) );
 		if(  object )
 			{
 			MPbk2DoubleListboxCmdItemExtension* extension = 
@@ -116,13 +117,16 @@
 				//   [trailing icon]
 				
 				// fetch status text
-				iElement->SetText( MPbk2DoubleListboxDataElement::EStatusText, NULL, 
+				iElement->SetText( 
+				        MPbk2DoubleListboxDataElement::EStatusText, 
+				        NULL, 
 				        MPbk2DoubleListboxDataElement::ETypeGenericText );
                 TRAPD( err, extension->FormatDataL( *iElement ) );
 				if( !err )
 				    {
 					// get icon index
-					iconIndex = iIconArray.FindIcon( iElement->IconId( MPbk2DoubleListboxDataElement::EThumbnail ) );
+					iconIndex = iIconArray.FindIcon( iElement->IconId( 
+					        MPbk2DoubleListboxDataElement::EThumbnail ) );
 					// if icon is not found, use default
 					if( iconIndex < 0 )
 						{
@@ -133,7 +137,8 @@
 					iBuffer.Append( name );
 				
 					// status
-                    TPtr status( iElement->TextPtr( MPbk2DoubleListboxDataElement::EStatusText ) );
+                    TPtr status( iElement->TextPtr( 
+                            MPbk2DoubleListboxDataElement::EStatusText ) );
                     //if status text exists
                     if( status.Compare( KNullDesC ) != 0 )
                         {
--- a/phonebookui/Phonebook2/UIControls/src/pbk2contactviewdoublelistboxdataelement.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/UIControls/src/pbk2contactviewdoublelistboxdataelement.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -15,23 +15,19 @@
 */
 
 #include "pbk2contactviewdoublelistboxdataelement.h"
-#include <MVPbkContactLink.h>
 
 // --------------------------------------------------------------------------
 // CPbk2ContactViewDoubleListboxDataElement::NewLC
 // --------------------------------------------------------------------------
 //
-CPbk2ContactViewDoubleListboxDataElement* CPbk2ContactViewDoubleListboxDataElement::NewL(
-        MVPbkContactLink* aLink,
-        TInt aListIndex)
+CPbk2ContactViewDoubleListboxDataElement* 
+CPbk2ContactViewDoubleListboxDataElement::NewLC()
     {
     CPbk2ContactViewDoubleListboxDataElement* self =
-        new ( ELeave ) CPbk2ContactViewDoubleListboxDataElement(aListIndex);
+        new ( ELeave ) CPbk2ContactViewDoubleListboxDataElement();
 
     CleanupStack::PushL(self);
     self->ConstructL();
-    self->iLink = aLink;
-    CleanupStack::Pop(self);
     return self;
     }
 
@@ -39,9 +35,7 @@
 // CPbk2ContactViewDoubleListboxDataElement::CPbk2ContactViewDoubleListboxDataElement
 // --------------------------------------------------------------------------
 //
-inline CPbk2ContactViewDoubleListboxDataElement::CPbk2ContactViewDoubleListboxDataElement(
-        TInt aListIndex)
-: iListIndex( aListIndex )    
+inline CPbk2ContactViewDoubleListboxDataElement::CPbk2ContactViewDoubleListboxDataElement()
     {
     iTexts.Reset();
     iIcons.Reset();
@@ -65,7 +59,6 @@
     {
     iTexts.DeleteAll();
     delete iEmptyBuffer;
-    delete iLink;
     }
 
 // --------------------------------------------------------------------------
--- a/phonebookui/Phonebook2/UIServices/src/CPbk2AiwSelectionProvider.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/UIServices/src/CPbk2AiwSelectionProvider.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -328,6 +328,11 @@
         ( EGenericParamContactLinkArray, aInParamList );
     CleanupStack::PushL( linkBuffer );
 
+    // StatusPane Id
+    HBufC8* statusPaneId = PackParameterToBufferL
+        ( EGenericParamUnspecified, aInParamList );
+    CleanupStack::PushL( statusPaneId );
+        
     // Title pane
     HBufC* titlePaneText = ClientTitlePaneL();
     CleanupStack::PushL( titlePaneText );
@@ -340,6 +345,7 @@
     length += Pbk2IPCPackage::CountPackageSize( iDefaultPrioritiesBuffer );
     length += Pbk2IPCPackage::CountPackageSize( iContactViewFilterBuffer );
     length += Pbk2IPCPackage::CountPackageSize( titlePaneText );
+    length += Pbk2IPCPackage::CountPackageSize( statusPaneId );
 
     delete iConfigurationPackage;
     iConfigurationPackage = NULL;
@@ -353,10 +359,11 @@
     Pbk2IPCPackage::ExternalizeL( iDefaultPrioritiesBuffer, writeStream );
     Pbk2IPCPackage::ExternalizeL( iContactViewFilterBuffer, writeStream );
     Pbk2IPCPackage::ExternalizeL( titlePaneText, writeStream );
+    Pbk2IPCPackage::ExternalizeL( statusPaneId, writeStream );
     writeStream.CommitL();
 
     CleanupStack::PopAndDestroy( &writeStream );
-    CleanupStack::PopAndDestroy( 3 ); // titlePaneText, linkBuffer,
+    CleanupStack::PopAndDestroy( 4 ); // titlePaneText, statusPaneId, linkBuffer,
                                       // storeUriBuffer
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phonebookui/Phonebook2/USIMExtension/inc/CPsu2CopyAllToPbkCmd.h	Thu Jul 15 18:22:55 2010 +0300
@@ -0,0 +1,185 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Phonebook 2 copy "new SIM" contacts to phone memory.
+*
+*/
+
+
+#ifndef CPSU2COPYALLTOPBKCMD_H
+#define CPSU2COPYALLTOPBKCMD_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <MPbk2Command.h>
+#include <MVPbkContactStoreObserver.h>
+#include <MVPbkContactViewObserver.h>
+#include <MVPbkBatchOperationObserver.h>
+#include <MPbk2ProcessDecorator.h>
+#include <RPbk2LocalizedResourceFile.h>
+
+// FORWARD DECLARATIONS
+class MVPbkContactStore;
+class CVPbkContactStoreUriArray;
+class MVPbkContactView;
+class CVPbkContactLinkArray;
+class CVPbkContactCopier;
+class CVPbkContactLinkArray;
+
+// CLASS DECLARATION
+
+/**
+ * Phonebook 2 copy "new SIM" contacts to phone memory.
+ */
+class CPsu2CopyAllToPbkCmd : public CActive,
+                                public MPbk2Command,
+                                private MVPbkContactStoreObserver,
+                                private MVPbkContactViewObserver,
+                                private MVPbkBatchOperationObserver,
+                                private MPbk2ProcessDecoratorObserver
+    {
+    public: // Constructors and destructor
+    
+        /**
+         * Creates a new instance of this class.
+         * @return  A new instance of this class.
+         */
+        static CPsu2CopyAllToPbkCmd* NewL( );
+
+        /**
+         * Destructor.
+         */
+        ~CPsu2CopyAllToPbkCmd();
+
+    private: // From CActive
+        void RunL();
+        void DoCancel();
+        TInt RunError(
+                TInt aError );
+
+    public: // From MPbk2Command
+        void ExecuteLD();
+        void AddObserver(
+                MPbk2CommandObserver& aObserver );
+        void ResetUiControl(
+                MPbk2ContactUiControl& aUiControl );
+
+    private: // From MVPbkContactStoreObserver
+        void StoreReady(
+                MVPbkContactStore& aContactStore );
+        void StoreUnavailable(
+                MVPbkContactStore& aContactStore,
+                TInt aReason );
+        void HandleStoreEventL(
+                MVPbkContactStore& aContactStore,
+                TVPbkContactStoreEvent aStoreEvent );
+
+    private: // From MVPbkContactViewObserver
+        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 );
+
+    private: // From MVPbkBatchOperationObserver
+        void StepComplete(
+                MVPbkContactOperationBase& aOperation,
+                TInt aStepSize );
+        TBool StepFailed(
+                MVPbkContactOperationBase& aOperation,
+                TInt aStepSize,
+                TInt aError );
+        void OperationComplete(
+                MVPbkContactOperationBase& aOperation );
+
+    private: // From MPbk2ProcessDecoratorObserver
+        void ProcessDismissed(
+                TInt aCancelCode );
+
+    private: // Implementation
+        /// Tasks
+        enum TNextTask
+            {
+            EOpenStores,
+            ECheckSimStorePrerequisites,
+            ELaunchCopyAllSIMContactsQueryL,
+            ECreateSimViews,
+            ECopyContacts,
+            EComplete
+            };
+    
+        CPsu2CopyAllToPbkCmd( );
+        void ConstructL();
+        void OpenStoresL();
+        void CheckSimStorePrerequisitesL();
+        void LaunchCopyAllSIMContactsQueryL();
+        void CreateSimViewsL();
+        void CopyContactsL();
+        void ShowResultsL();
+        void Complete();
+        void CompleteWithError(
+                TInt aError );
+        void CloseStores();
+        
+        void Finish( TInt aReason );
+        
+        void StartNext( TNextTask aNextTask );
+  
+
+    private: // Data
+        /// Ref: Command observer
+        MPbk2CommandObserver* iCommandObserver;
+        /// Own: Decorator for the process
+        MPbk2ProcessDecorator* iDecorator;
+        TBool iDecoratorShown;
+        /// Own: Indicates next task
+        TInt iNextTask;
+        /// Own: URI array that contains the SIM source stores
+        CVPbkContactStoreUriArray* iValidSourceStoreUris;
+        /// Ref: Array of source store references
+        RPointerArray<MVPbkContactStore> iSourceStores;
+        /// Target store reference
+        MVPbkContactStore* iTargetStore;
+        /// Own: Counter for opened SIM stores and views
+        TInt iCounter;
+        /// Own: Array of SIM contact views
+        RPointerArray<MVPbkContactView> iSourceViews;
+        /// Own: Source contact links
+        CVPbkContactLinkArray* iSourceContactLinks;
+        /// Own: Copy operation
+        MVPbkContactOperationBase* iCopyOperation;
+        /// Own: Number of successfully copied contacts
+        TInt iCopiedSuccessfully;
+        /// Own: The virtual phonebook contact copier
+        CVPbkContactCopier* iCopier;
+        /// Own: An array for copy results
+        CVPbkContactLinkArray* iCopiedContacts;
+        /// Own: If there is just one contact being copied, store the title
+        /// for copy results note
+        HBufC* iTheOnlyContactTitle;
+    };
+
+#endif // CPSU2COPYALLTOPBKCMD_H
+
+// End of File
--- a/phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimFixedDialingView.rss	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimFixedDialingView.rss	Thu Jul 15 18:22:55 2010 +0300
@@ -302,6 +302,9 @@
                 label = qtn_fdn_enter_number_to_call;
                 control= EDWIN
                     {
+                    numeric_keymap = EAknEditorStandardNumberModeKeymap;
+                    allowed_input_modes = EAknEditorNumericInputMode;
+                    default_input_mode = EAknEditorNumericInputMode;
                     };
                 };
             }
--- a/phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimInformation.rss	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimInformation.rss	Thu Jul 15 18:22:55 2010 +0300
@@ -19,6 +19,7 @@
 #include "Pbk2USIMUIUID.h"
 #include <Pbk2ContentIdentifiers.hrh>
 
+
 // --------------------------------------------------------------------------
 // Extension information
 // --------------------------------------------------------------------------
@@ -53,7 +54,7 @@
             parentMenu = R_PHONEBOOK2_NAMESLIST_OTHER_MEMORIES_MENU_PLACEHOLDER;
             prevCommand = EPbk2CmdOtherMemoriesPlaceholderFirst;
             menuPane = r_psu2_sim_memory_menu_pane;
-            },
+            },     
         PHONEBOOK2_EXTENSION_MENU_RESOURCE
             {
             // Name list view: "My numbers" menu item
@@ -64,6 +65,16 @@
             prevCommand = EPsu2CmdFirstSimMemoryMenuItem;
             menuPane = r_psu2_sim_memory_own_number_menu_pane;
             },
+       PHONEBOOK2_EXTENSION_MENU_RESOURCE
+            {
+            // Name list view: "Copy all to phone" menu item
+            version = 0;
+            viewId = EPbk2NamesListViewId;
+            menuFilteringFlags = 0;
+            parentMenu = r_psu2_cascading_sim_memory_menu_pane;
+            prevCommand = EPsu2CmdLaunchOwnNumberView;
+            menuPane = r_psu2_sim_memory_copy_all_to_phonememory;
+            },    
         PHONEBOOK2_EXTENSION_MENU_RESOURCE
             {
             // Name list view: "Service dialing numbers" menu item
@@ -71,7 +82,7 @@
             viewId = EPbk2NamesListViewId;
             menuFilteringFlags = 0;
             parentMenu = r_psu2_cascading_sim_memory_menu_pane;
-            prevCommand = EPsu2CmdLaunchOwnNumberView;
+            prevCommand = EPsu2CmdCopyToContacts; 
             menuPane = r_psu2_sim_memory_sdn_menu_pane;
             },
         PHONEBOOK2_EXTENSION_MENU_RESOURCE
@@ -163,6 +174,23 @@
     }
 
 // --------------------------------------------------------------------------
+// Copy all SIM contacts menu pane
+// --------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_psu2_sim_memory_copy_all_to_phonememory
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = EPsu2CmdCopyToContacts;
+            txt = qtn_phob_opt_sub_copy_all; 
+            }
+        };
+    }
+
+
+// --------------------------------------------------------------------------
 // Own/My numbers launch menu pane
 // --------------------------------------------------------------------------
 //
--- a/phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimTextBuffers.rss	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimTextBuffers.rss	Thu Jul 15 18:22:55 2010 +0300
@@ -147,4 +147,12 @@
     txt = "1234567890*+pw#";
     }    
 
+// --------------------------------------------------------------------------
+// Copy all SIM query text
+// --------------------------------------------------------------------------
+//
+RESOURCE TBUF r_qtn_simp_note_copy_all_sim
+    {
+    buf = qtn_simp_note_copy_all_sim;
+    }
 // End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phonebookui/Phonebook2/USIMExtension/src/CPsu2CopyAllToPbkCmd.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -0,0 +1,697 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Phonebook 2 copy all SIM contacts to phone memory.
+*
+* NOTE: Contains a lot of similar code that in CPsu2CopySimContactsCmd.
+* Reason is that there is no clear place to share common SIM related code between 
+* USIMThinExtension.dll and USIMExtension.dll. This is a potential place for 
+* future refactoring. 
+*/
+
+
+// INCLUDE FILES
+#include "CPsu2CopyAllToPbkCmd.h"
+
+// Phonebook 2
+#include <MPbk2CommandObserver.h>
+#include <CPbk2StoreConfiguration.h>
+#include <CPbk2StorePropertyArray.h>
+#include <CPbk2StoreProperty.h>
+#include <CPbk2StoreViewDefinition.h>
+#include <CPbk2SortOrderManager.h>
+#include <Pbk2ProcessDecoratorFactory.h>
+#include <Pbk2UID.h>
+/// Use R_PBK2_GENERAL_CONFIRMATION_QUERY from UI controls
+/// As a core components UiControl's resource file is loaded in core Pbk2
+#include <Pbk2UIControls.rsg>
+#include <Pbk2USimUIRes.rsg>
+/// Use R_GENERAL_COPY_PROGRESS_NOTE from Commands
+/// As a core components Command's resource file is loaded in core Pbk2
+#include <Pbk2Commands.rsg>
+#include <Pbk2DataCaging.hrh>
+#include <MPbk2AppUi.h>
+#include <MPbk2ApplicationServices.h>
+#include <MPbk2StoreValidityInformer.h>
+
+// Virtual Phonebook
+#include <MVPbkContactStoreProperties.h>
+#include <CVPbkContactManager.h>
+#include <MVPbkContactStore.h>
+#include <MVPbkStoreContact.h>
+#include <MVPbkFieldType.h>
+#include <VPbkContactStoreUris.h>
+#include <CVPbkContactStoreUriArray.h>
+
+#include <MVPbkContactStoreList.h>
+#include <MVPbkContactStoreInfo.h>
+#include <MVPbkContactView.h>
+#include <CVPbkContactLinkArray.h>
+#include <MVPbkContactOperationBase.h>
+#include <CVPbkContactCopier.h>
+
+#include <TPsu2SimCopyResults.h>
+#include <MPbk2ContactNameFormatter.h>
+
+// System includes
+#include <AknQueryDialog.h>
+#include <e32property.h>
+#include <StringLoader.h>
+#include <e32cmn.h>
+#include <e32capability.h>
+
+// Debugging headers
+#include <Pbk2Debug.h>
+
+/// Unnamed namespace for local definitions
+namespace {
+
+
+const TInt KTargetStoresCount = 1;
+
+#ifdef _DEBUG
+enum TPanicCode
+    {
+    EStorePropertyNotFound_CreateSimViewsL
+    };
+
+void Panic(TInt aReason)
+    {
+    _LIT(KPanicText, "CPsu2CopyAllToPbkCmd");
+    User::Panic(KPanicText, aReason);
+    }
+#endif // _DEBUG
+
+
+} /// namespace
+
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::CPsu2CopyAllToPbkCmd
+// --------------------------------------------------------------------------
+//
+CPsu2CopyAllToPbkCmd::CPsu2CopyAllToPbkCmd() 
+    : CActive( EPriorityStandard ) 
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::~CPsu2CopyAllToPbkCmd
+// --------------------------------------------------------------------------
+//
+CPsu2CopyAllToPbkCmd::~CPsu2CopyAllToPbkCmd()
+    {
+    Cancel();
+    delete iDecorator;
+    delete iCopyOperation;
+    delete iCopier;
+    delete iCopiedContacts;
+    delete iValidSourceStoreUris;
+    iSourceViews.ResetAndDestroy();
+    CloseStores();
+    delete iSourceContactLinks;
+    iSourceStores.Close();
+    delete iTheOnlyContactTitle;
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::NewL
+// --------------------------------------------------------------------------
+//
+CPsu2CopyAllToPbkCmd* CPsu2CopyAllToPbkCmd::NewL()
+    {
+    CPsu2CopyAllToPbkCmd* self =
+        new( ELeave ) CPsu2CopyAllToPbkCmd( );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::ConstructL
+// Symbian 2nd phase constructor can leave.
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+
+    iValidSourceStoreUris = CVPbkContactStoreUriArray::NewL();
+    iValidSourceStoreUris->AppendL( 
+            VPbkContactStoreUris::SimGlobalSdnUri() );  
+    iValidSourceStoreUris->AppendL( 
+            VPbkContactStoreUris::SimGlobalAdnUri() );  
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::RunL
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::RunL()
+    {
+    PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
+        ("CPsu2CopyAllToPbkCmd::RunL res %d task %d"),
+        iStatus.Int(), iNextTask);
+    
+    switch ( iNextTask )
+        {
+        case EOpenStores:
+            {
+            OpenStoresL();
+            break;
+            }
+        case ECheckSimStorePrerequisites:
+            {
+            CheckSimStorePrerequisitesL();
+            break;
+            }
+        case ELaunchCopyAllSIMContactsQueryL:
+            {
+            LaunchCopyAllSIMContactsQueryL();
+            break;
+            }
+        case ECreateSimViews:
+            {
+            CreateSimViewsL();
+            break;
+            }
+        case ECopyContacts:
+            {
+            CopyContactsL();
+            break;
+            }
+        case EComplete: // FALLTHROUGH
+        default:
+            {
+            Complete();
+            break;
+            }
+        }
+    }
+   
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::DoCancel
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::DoCancel()
+    {
+    // Nothing to do here
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::RunError
+// --------------------------------------------------------------------------
+//
+TInt CPsu2CopyAllToPbkCmd::RunError( TInt aError )
+    {
+    Finish( aError );
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::ExecuteLD
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::ExecuteLD()
+    {
+    StartNext( EOpenStores );
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::AddObserver
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::AddObserver( MPbk2CommandObserver& aObserver )
+    {
+    iCommandObserver = &aObserver;
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::ResetUiControl
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::ResetUiControl
+        ( MPbk2ContactUiControl& /*aUiControl*/ )
+    {
+    // Do nothing
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::StoreReady
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::StoreReady
+        ( MVPbkContactStore& /*aContactStore*/)
+    {
+    ++iCounter;
+    // KTargetStoresCount = 1, as we are always copying to phone memory
+    if ( iNextTask == EOpenStores &&
+         iSourceStores.Count() + KTargetStoresCount == iCounter ) 
+        {
+        StartNext(ECheckSimStorePrerequisites); 
+        }
+    
+    // iNextTask == EOpenStores above
+    //    --> ignore the case where a store later becomes ready and command is 
+    //        already in later phases
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::StoreUnavailable
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::StoreUnavailable
+        ( MVPbkContactStore& aContactStore,  TInt /*aReason*/ )
+    {
+    // Remove URI
+    iValidSourceStoreUris->Remove( aContactStore.StoreProperties().Uri() );
+
+    // Remove store
+    const TInt count = iSourceStores.Count();
+    TBool storeRemoved = EFalse;
+    for ( TInt i = 0; i < count && !storeRemoved; ++i )
+        {
+        if ( iSourceStores[i] == &aContactStore )
+            {
+            iSourceStores[i]->Close( *this ); 
+            iSourceStores.Remove( i );
+            storeRemoved = ETrue;
+            }
+        }
+
+    // If already moved on to next phase, ignore store becoming unavailable
+    // let the ContactViewError or StepFailed handle this 
+    if ( iNextTask == EOpenStores)
+        {
+        // If all source stores failed to open -> complete command
+        if ( iSourceStores.Count() == 0 )
+            {  
+            StartNext( EComplete );
+            }
+        // All available stores are open
+        else if ( iSourceStores.Count() + KTargetStoresCount == iCounter )
+            {
+            StartNext( ECheckSimStorePrerequisites );
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::HandleStoreEventL
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::HandleStoreEventL
+        ( MVPbkContactStore& /*aContactStore*/,
+          TVPbkContactStoreEvent /*aStoreEvent*/ )
+    {
+    // Nothing to be done here
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::ContactViewReady
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::ContactViewReady
+        ( MVPbkContactViewBase& /*aView*/)
+    {
+    ++iCounter;
+    if ( iSourceViews.Count() == iCounter )
+        {
+        StartNext( ECopyContacts );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::ContactViewUnavailable
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::ContactViewUnavailable
+        ( MVPbkContactViewBase& /*aView*/ )
+    {
+    // Nothing to be done here, wait view ready events
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::ContactAddedToView
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::ContactAddedToView
+        ( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/,
+          const MVPbkContactLink& /*aContactLink*/ )
+    {
+    // Nothing to be done here
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::ContactRemovedFromView
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::ContactRemovedFromView
+        ( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/,
+          const MVPbkContactLink& /*aContactLink*/ )
+    {
+    // Nothing to be done here
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::ContactViewError
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::ContactViewError
+        ( MVPbkContactViewBase& /*aView*/, TInt aError,
+          TBool /*aErrorNotified*/ )
+    { 
+    Finish( aError );
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::StepComplete
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::StepComplete
+        ( MVPbkContactOperationBase& /*aOperation*/, TInt aStepSize )
+    {
+    iCopiedSuccessfully += aStepSize;
+    iDecorator->ProcessAdvance( aStepSize );
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::StepFailed
+// --------------------------------------------------------------------------
+//
+TBool CPsu2CopyAllToPbkCmd::StepFailed
+        ( MVPbkContactOperationBase& /*aOperation*/, TInt /*aStepSize*/,
+          TInt aError )
+    {
+    Finish( aError );
+    
+    return EFalse;
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::OperationComplete
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::OperationComplete
+        ( MVPbkContactOperationBase& /*aOperation*/ )
+    {
+    // Decorator calls ProcessDismissed
+    iDecorator->ProcessStopped();
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::ProcessDismissed
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::ProcessDismissed( TInt /*aCancelCode*/ )
+    {
+    iDecoratorShown = EFalse;
+    Cancel();
+    delete iCopyOperation;
+    iCopyOperation = NULL;
+    StartNext( EComplete );
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::OpenStoresL
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::OpenStoresL()
+    {
+    // Load and open source stores to contact manager
+    const TInt count = iValidSourceStoreUris->Count();
+    for ( TInt i = 0; i < count; ++i )
+        {
+        Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager().
+            LoadContactStoreL( (*iValidSourceStoreUris)[i] );
+        MVPbkContactStore* source =
+            Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager().
+                ContactStoresL().Find( (*iValidSourceStoreUris)[i] );
+       if ( source )          
+            {    
+            iSourceStores.AppendL( source );
+            source->OpenL( *this );
+            }
+        }
+    
+    // Also make sure the target store is always loaded and opened
+    Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager().
+                LoadContactStoreL( VPbkContactStoreUris::DefaultCntDbUri() );
+    iTargetStore = Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager().
+                       ContactStoresL().Find( VPbkContactStoreUris::DefaultCntDbUri() );         
+    iTargetStore->OpenL( *this );
+    
+    // Next: wait for StoreReady and/or StoreUnavailable notifications
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::CheckSimStorePrerequisitesL
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::CheckSimStorePrerequisitesL()
+    {
+    // If there are no contacts to copy then do nothing
+    TInt sourceContactCount = 0;
+    const TInt count = iSourceStores.Count();
+    for ( TInt i = 0; i < count; ++i )
+        {
+        sourceContactCount +=
+            iSourceStores[i]->StoreInfo().NumberOfContactsL();
+        }
+
+    if ( sourceContactCount > 0 )
+        {    
+        StartNext ( ELaunchCopyAllSIMContactsQueryL );
+        }
+    else
+    	{
+        StartNext ( EComplete );
+    	}
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::LaunchCopyAllSIMContactsQueryL
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::LaunchCopyAllSIMContactsQueryL()
+    {
+    HBufC* text = StringLoader::LoadLC( R_QTN_SIMP_NOTE_COPY_ALL_SIM );
+
+    CAknQueryDialog* dlg = CAknQueryDialog::NewL();
+    TInt ret = dlg->ExecuteLD( R_PBK2_GENERAL_CONFIRMATION_QUERY, *text );
+ 	     	
+    CleanupStack::PopAndDestroy( text );
+    
+    StartNext ( ret ? ECreateSimViews : EComplete );    
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::CreateSimViewsL
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::CreateSimViewsL()
+    {
+    // Set views ready counter to zero
+    iCounter = 0;
+
+    const TInt count = iSourceStores.Count();
+    for ( TInt i = 0; i < count; ++i )
+        {
+        // Find store property
+        const CPbk2StoreProperty* prop =
+            Phonebook2::Pbk2AppUi()->ApplicationServices().StoreProperties().
+                FindProperty( iSourceStores[i]->StoreProperties().Uri() );
+        __ASSERT_DEBUG( prop,
+            Panic( EStorePropertyNotFound_CreateSimViewsL ) );
+        // Get Virtual Phonebook view definition
+        // There is only one view defintion for SIM stores
+        // -> take the first one
+        const CVPbkContactViewDefinition& viewDef =
+            (prop->Views())[0]->ViewDefinition();
+        MVPbkContactView* view = iSourceStores[i]->CreateViewLC(
+            viewDef,
+            *this,
+            Phonebook2::Pbk2AppUi()->ApplicationServices().
+                SortOrderManager().SortOrder() );
+        iSourceViews.AppendL( view );
+        CleanupStack::Pop(); // view
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::CopyContactsL
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::CopyContactsL()
+    {
+    if ( !iCopier )
+        {
+        iCopier = CVPbkContactCopier::NewL
+            ( Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager() );
+        }
+    
+    // Create an array for source contact links
+    if ( !iSourceContactLinks )
+        {
+        iSourceContactLinks = CVPbkContactLinkArray::NewL();
+        }
+
+    if ( !iCopiedContacts )
+        {
+        iCopiedContacts = CVPbkContactLinkArray::NewL();
+        }
+    
+    // Create links to the contacts that are copied
+    const TInt viewCount = iSourceViews.Count();
+    
+    for ( TInt i = 0; i < viewCount; ++i )
+        {
+        const TInt contactCount = iSourceViews[i]->ContactCountL();
+        for( TInt j = 0; j < contactCount; ++j )
+            {
+            // store the first contact's title, if only one contact copied,
+            // show the name of that single contact in the results note.
+            if ( j == 0 )
+                {
+                iTheOnlyContactTitle = Phonebook2::Pbk2AppUi()->ApplicationServices().
+                        NameFormatter().GetContactTitleL(
+                                iSourceViews[i]->ContactAtL(j).Fields(),
+                                MPbk2ContactNameFormatter::EPreserveLeadingSpaces);
+                }
+            // create link
+            MVPbkContactLink* link =
+                iSourceViews[i]->ContactAtL(j).CreateLinkLC();
+            iSourceContactLinks->AppendL( link );
+            CleanupStack::Pop(); // link
+            }
+        }
+
+    // Views can be destroyed now because links have been created
+    iSourceViews.ResetAndDestroy();
+
+    // Get target store
+    MVPbkContactStore* targetStore =
+        Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager().
+            ContactStoresL().Find( VPbkContactStoreUris::DefaultCntDbUri() );
+   
+    
+    if (targetStore)
+        {
+        // Start copying
+        iDecorator = Pbk2ProcessDecoratorFactory::CreateProgressDialogDecoratorL
+                ( R_GENERAL_COPY_PROGRESS_NOTE, EFalse );
+        iDecorator->SetObserver( *this );
+     
+        iCopiedContacts->ResetAndDestroy();      
+        iCopyOperation = iCopier->CopyContactsL(
+                CVPbkContactCopier::EVPbkUsePlatformSpecificDuplicatePolicy,
+                *iSourceContactLinks, targetStore, *iCopiedContacts, *this );
+
+        // Show progress note
+        iDecorator->ProcessStartedL( iSourceContactLinks->Count() );
+        iDecoratorShown = ETrue;
+        }
+    else
+        {
+        StartNext( EComplete );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::ShowResultsL
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::ShowResultsL()
+    {
+
+    if (iSourceContactLinks->Count() == 1 && iTheOnlyContactTitle)
+        {
+        TPsu2SimCopyResults  results(
+                iCopiedSuccessfully, iTheOnlyContactTitle->Des() );
+        results.ShowNoteL();
+        }
+    else 
+        {
+        TPsu2SimCopyResults  results(
+                iCopiedSuccessfully, iSourceContactLinks->Count() );
+        results.ShowNoteL();
+        }
+   
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::Complete   
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::Complete()
+    {    
+    if ( iSourceContactLinks )
+        {
+        TRAP_IGNORE( ShowResultsL() );
+        }
+    
+    iCommandObserver->CommandFinished( *this );
+    }
+
+// ---------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::Finish
+// ---------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::Finish( TInt aReason )
+    {
+    if ( aReason != KErrNone && aReason != KErrCancel )
+        {
+        CCoeEnv::Static()->HandleError( aReason );
+        }
+    
+    if (iDecorator && iDecoratorShown)
+        {
+        // Decorator calls ProcessDismissed --> StartNext( EComplete );
+        iDecorator->ProcessStopped();
+        }
+    else
+        {
+        StartNext( EComplete );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::StartNext
+// ---------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::StartNext( TNextTask aNextTask )
+    {
+    iNextTask = aNextTask;
+    
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrNone );
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------
+// CPsu2CopyAllToPbkCmd::CloseStores
+// --------------------------------------------------------------------------
+//
+void CPsu2CopyAllToPbkCmd::CloseStores()
+    {
+    const TInt count = iSourceStores.Count();
+    for ( TInt i = 0; i < count; ++i )
+        {
+        iSourceStores[i]->Close( *this );
+        }
+    
+    iTargetStore->Close( *this );
+    }
+
+//  End of File
--- a/phonebookui/Phonebook2/USIMExtension/src/CPsu2UIExtensionPlugin.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/USIMExtension/src/CPsu2UIExtensionPlugin.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -31,6 +31,8 @@
 #include "CPsu2ServiceDialingInfoView.h"
 #include "CPsu2FixedDialingInfoView.h"
 #include "CPsu2ContactEditorExtension.h"
+#include "CPsu2CopyAllToPbkCmd.h"
+
 #include <MPbk2ContactUiControl.h>
 #include <CPbk2StorePropertyArray.h>
 #include <CPbk2AppViewBase.h>
@@ -58,6 +60,8 @@
 #include <csxhelp/phob.hlp.hrh>
 #include <avkon.hrh>
 
+#include <MPbk2CommandHandler.h>
+
 // --------------------------------------------------------------------------
 // CPsu2UIExtensionPlugin::CPsu2UIExtensionPlugin
 // --------------------------------------------------------------------------
@@ -246,8 +250,12 @@
             result = CPsu2CopyFromPbkCmd::NewL( *target, aUiControl, const_cast<CPsu2UIExtensionPlugin*>( this ) );
             break;
             }
+        case EPsu2CmdCopyToContacts:
+            {
+            result = CPsu2CopyAllToPbkCmd::NewL();
+            }
         }
-
+  
     return result;
     }
 
--- a/phonebookui/Phonebook2/USIMThinExtension/src/CPsu2CheckAvailabeSimStore.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/USIMThinExtension/src/CPsu2CheckAvailabeSimStore.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -77,6 +77,8 @@
         VPbkContactStoreUris::SimGlobalOwnNumberUri() );
     iValidSourceStoreUris->AppendL( 
         VPbkContactStoreUris::SimGlobalSdnUri() );  
+    iValidSourceStoreUris->AppendL( 
+           VPbkContactStoreUris::SimGlobalAdnUri() );  
         
     iStoreList = &Phonebook2::Pbk2AppUi()->ApplicationServices().
                     ContactManager().ContactStoresL();
--- a/phonebookui/Phonebook2/USIMThinExtension/src/CPsu2CopySimContactsCmd.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/USIMThinExtension/src/CPsu2CopySimContactsCmd.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -13,6 +13,11 @@
 *
 * Description:  Phonebook 2 copy "new SIM" contacts to phone memory.
 *
+* NOTE: CPsu2CopySimContactsCmd contains a lot of similar code to this class.
+* Reason is that there is no clear place to share common SIM related code between 
+* USIMThinExtension.dll and USIMExtension.dll. This is a potential place for
+* future refactoring. 
+*
 */
 
 
--- a/phonebookui/Phonebook2/USIMThinExtension/src/CPsu2ThinUIExtensionPlugin.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/USIMThinExtension/src/CPsu2ThinUIExtensionPlugin.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -171,6 +171,14 @@
                 // "Fixed Dialing" item
                 DimMenuItem( *aMenuPane, EPsu2CmdLaunchFixedDialingView );
                 }
+            if ( iStoreChecker &&
+                 !iStoreChecker->IsContactsAvailabe( 
+                         VPbkContactStoreUris::SimGlobalAdnUri())  && 
+                 !iStoreChecker->IsContactsAvailabe(
+                         VPbkContactStoreUris::SimGlobalSdnUri())   )
+                {
+                DimMenuItem( *aMenuPane, EPsu2CmdCopyToContacts );
+                }
             break;
             }
         default:
--- a/phonebookui/Phonebook2/ccapplication/ccacontactorservice/group/ccacontactorservice.mmp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/ccapplication/ccacontactorservice/group/ccacontactorservice.mmp	Thu Jul 15 18:22:55 2010 +0300
@@ -57,7 +57,7 @@
 APP_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE         /epoc32/include/ecom
 
-LIBRARY               cone.lib
+LIBRARY               cone.lib eikcore.lib eikcoctl.lib
 LIBRARY               ws32.lib
 LIBRARY               euser.lib
 LIBRARY               efsrv.lib
--- a/phonebookui/Phonebook2/ccapplication/ccacontactorservice/inc/ccacontactorserviceheaders.h	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/ccapplication/ccacontactorservice/inc/ccacontactorserviceheaders.h	Thu Jul 15 18:22:55 2010 +0300
@@ -22,6 +22,7 @@
 // Constants
 #include <e32cons.h>
 #define KCCAContactorServiceLoggerFile CCA_L("ccacontactorservice.txt")
+#define KCCAMAXBUFFSIZE 100
 _LIT( KCCAContactorServiceResourceFileName, "\\resource\\ccacontactorservicersc.rsc" );
 _LIT( KColon, ":" );
 
--- a/phonebookui/Phonebook2/ccapplication/ccacontactorservice/src/ccacontactorpopuphandler.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/ccapplication/ccacontactorservice/src/ccacontactorpopuphandler.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -88,6 +88,27 @@
     // Set contactlink
     inParamList.AppendL(TAiwGenericParam(EGenericParamContactLinkArray,
         TAiwVariant(aContactLinkArray)));
+    
+    //Append the current status pane id
+    //this will also be used by Pbk2ServerApplication
+    //This is kind of a new implementation which will pave way
+    //for the applications to use the required statuspane that they
+    //prefer. 
+    //since its not feasible to add any new AIW functionality
+    //we will follow this approach.
+    CEikStatusPane* statusPane =
+            CEikonEnv::Static()->AppUiFactory()->StatusPane();
+    
+    if ( statusPane )
+        {
+        TInt currentstatuspane = statusPane->CurrentLayoutResId();        
+        TBuf<KCCAMAXBUFFSIZE> numBuf;
+        numBuf.AppendNum( currentstatuspane );
+        
+        inParamList.AppendL(TAiwGenericParam(EGenericParamUnspecified,
+                    TAiwVariant( numBuf )));
+        }
+        
 
     iServiceHandler->ExecuteServiceCmdL(KAiwCmdSelect, inParamList,
         iServiceHandler->OutParamListL(), 0, this);
--- a/phonebookui/Phonebook2/group/Pbk2USimExtension.mmp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/group/Pbk2USimExtension.mmp	Thu Jul 15 18:22:55 2010 +0300
@@ -43,6 +43,7 @@
 SOURCE          CPsu2CopyToSimCmd.cpp
 SOURCE          CPsu2LaunchViewCmd.cpp
 SOURCE          CPsu2CopyFromPbkCmd.cpp
+SOURCE          CPsu2CopyAllToPbkCmd.cpp
 
 // Views
 SOURCE          CPsu2NameListViewBase.cpp
--- a/phonebookui/Phonebook2/loc/phonebook2.loc	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/loc/phonebook2.loc	Thu Jul 15 18:22:55 2010 +0300
@@ -1721,13 +1721,20 @@
 //
 #define qtn_phob_note_contacts_hidden       "Contacts created to memory: %U"
 
-//d:Prompt text for copying the context of the SIM to Phonebook.
+//d:Prompt text for copying the context of the SIM to Phonebook when a new 
+//d:SIM card is detected
 //l:popup_note_window
 //w:
 //r:3.1
 //
 #define qtn_simp_note_new_sim_copy          "New SIM inserted. Copy SIM numbers to Phonebook?"
 
+//d:Prompt text for copying the context of the SIM to Phonebook.
+//l:popup_note_window
+//r:5.2
+//
+#define qtn_simp_note_copy_all_sim          "Copy all SIM contacts to Phone memory?"
+
 //d:Prompt for default Message number.
 //l:list_double_pane_t1_cp2
 //w:
@@ -2288,4 +2295,12 @@
 //w:
 //r:5.01
 #define qtn_phob_field_no_personal_tone "According to profile"
+
+
+//d:"Sim memory" sub menu item text for copying all SIM contacts to phonememory
+//l:list_single_popup_submenu_pane_t1
+//r:5.2
+//
+#define qtn_phob_opt_sub_copy_all "Copy all to phone"
+
 // End of File
--- a/phonebookui/Phonebook2/spbcontentprovider/src/spbphonenumberparser.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/spbcontentprovider/src/spbphonenumberparser.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -157,7 +157,6 @@
                         //default number found
                         number.CreateL( textData->Text() );
                         hasDefaultNumberField = ETrue;
-                        break;
                         }
                     const TPtrC phoneNumber( textData->Text() );
                     // we need count phonenumbers same way how this is implemented in CCA
@@ -180,12 +179,17 @@
         {
             number.CreateL( (*phoneNumberArray)[0] );
         }
-
+    
     CleanupStack::PopAndDestroy( phoneNumberArray );
     CleanupStack::PopAndDestroy( attribute );
-	
-    // no number was found
-    if( numberCount > 1 )
+    
+    if( hasDefaultNumberField || numberCount <= 1 )
+        {
+        // inform the observer
+        iContent.PhoneNumberUpdatedL( 
+            number, CSpbContentProvider::ETypePhoneNumber );
+        }
+    else
         {
         // contact has multiple numbers and no default
         TBuf<12> count;
@@ -193,13 +197,7 @@
         iContent.PhoneNumberUpdatedL( 
             count, CSpbContentProvider::ETypePhoneNumberMultiple );
         }
-    else
-        {
-        // inform the observer
-        iContent.PhoneNumberUpdatedL( 
-            number, CSpbContentProvider::ETypePhoneNumber );
-        }
-
+    
     number.Close();
     }