Revision: 201009 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 15 Mar 2010 12:39:26 +0200
branchRCL_3
changeset 6 e8e3147d53eb
parent 5 81f8547efd4f
child 7 b3431bff8c19
Revision: 201009 Kit: 201010
ccservices/cmsservices/cmsengine/Server/group/cmsserver.mmp
ccservices/cmsservices/cmsengine/Server/inc/cmsphonebookproxy.h
ccservices/cmsservices/cmsengine/Server/inc/cmsservercontact.h
ccservices/cmsservices/cmsengine/Server/inc/cmssetvoicecalldefault.h
ccservices/cmsservices/cmsengine/Server/src/cmsphonebookproxy.cpp
ccservices/cmsservices/cmsengine/Server/src/cmsservercontact.cpp
ccservices/cmsservices/cmsengine/Server/src/cmsserversession.cpp
ccservices/cmsservices/cmsengine/Server/src/cmssetvoicecalldefault.cpp
contacts_plat/cca_launch_api/inc/mccaparameter.h
contacts_plat/group/bld.inf
contacts_plat/phonebook_2_contact_related_icon_customization_api/group/bld.inf
contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/CContactCustomIconPluginBase.h
contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/CCustomIconDecisionData.h
contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/CCustomIconDecisionData.inl
contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/CCustomIconIdMap.h
contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/CCustomIconIdMap.inl
contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/ContactCustomIconPluginDefs.h
contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/MCustomIconChangeObserver.h
contacts_plat/phonebook_2_contact_related_icon_customization_api/phonebook_2_contact_related_icon_customization_api.metaxml
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/data/Pbk2IconCustomApiTestPlugin.rss
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/data/image1.bmp
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/data/image2.bmp
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/group/Pbk2IconCustomApiTestPlugin.iby
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/group/Pbk2IconCustomApiTestPlugin.mmp
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/group/bld.inf
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/inc/CPbk2IconCustomApiTestPlugin.h
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/sis/CRICTestEcomPlugin.pkg
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/sis/make_sis_and_sign.bat
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/src/CPbk2IconCustomApiTestPlugin.cpp
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/src/CPbk2IconCustomApiTestPluginFactory.cpp
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/bwins/Pbk2IconCustomApiTestModuleu.def
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/data/Pbk2IconCustomApiTestModule.cfg
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/eabi/Pbk2IconCustomApiTestModuleu.def
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/group/Pbk2IconCustomApiTestModule.iby
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/group/Pbk2IconCustomApiTestModule.mmp
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/group/bld.inf
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/inc/CIconCustomApiTestModule.h
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/src/CIconCustomApiTestModule.cpp
contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/src/CIconCustomApiTestModuleBlocks.cpp
contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/conf/PsClientTestSuite.cfg
contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/inc/psclienttestsuitedefs.h
contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/PsClientTestSuite.cpp
contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/PsClientTestSuiteBlocks.cpp
contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/TestSuiteInputData.cpp
contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/pstestcontactshandler.cpp
contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/pstestqueryhandler.cpp
contacts_plat/predictivesearch_utils_api/inc/CPcsDefs.h
contacts_plat/virtual_phonebook_engine_api/inc/MVPbkContactViewObserver.h
phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CAsyncContactOperation.h
phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CFilteredContactView.h
phonebookengines/VirtualPhonebook/VPbkCntModel/src/CAsyncContactOperation.cpp
phonebookengines/VirtualPhonebook/VPbkCntModel/src/CFilteredContactView.cpp
phonebookengines/VirtualPhonebook/VPbkEng/inc/CVPbkCompositeContactView.h
phonebookengines/VirtualPhonebook/VPbkEng/src/CVPbkCompositeContactView.cpp
phonebookengines/VirtualPhonebook/VPbkEng/src/CVPbkFilteredContactView.cpp
phonebookengines/VirtualPhonebook/VPbkSimStore/src/CContactView.cpp
phonebookengines/contactsmodel/cntplsql/inc/persistencelayerimpl.h
phonebookengines/contactsmodel/cntplsql/src/cplcollectioniterator.cpp
phonebookengines/contactsmodel/cntsrv/src/CCntStateMachine.cpp
phonebookengines/contactsmodel/tsrc/Integration/TestStartUp/group/10003A73.txt
phonebookui/Phonebook/group/BCardEng.mmp
phonebookui/Phonebook2/BWINS/Pbk2PresentationU.DEF
phonebookui/Phonebook2/BWINS/pbk2spbcontentprovideru.def
phonebookui/Phonebook2/Commands/inc/CPbk2PrependCmd.h
phonebookui/Phonebook2/Commands/rss/Pbk2Commands.rss
phonebookui/Phonebook2/Commands/src/CPbk2AiwInterestItemCall.cpp
phonebookui/Phonebook2/Commands/src/CPbk2PrependCmd.cpp
phonebookui/Phonebook2/CommandsExtension/inc/CPbk2MergeContactsCmd.h
phonebookui/Phonebook2/CommandsExtension/inc/CPbk2SetImageCmd.h
phonebookui/Phonebook2/CommandsExtension/src/CPbk2AssignSpeedDialCmd.cpp
phonebookui/Phonebook2/CommandsExtension/src/CPbk2CopyAddressToClipboardCmd.cpp
phonebookui/Phonebook2/CommandsExtension/src/CPbk2CopyNumberToClipboardCmd.cpp
phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeConflict.cpp
phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeContactsCmd.cpp
phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeResolver.cpp
phonebookui/Phonebook2/CommandsExtension/src/CPbk2RemoveSpeedDialCmd.cpp
phonebookui/Phonebook2/CommandsExtension/src/CPbk2SetImageCmd.cpp
phonebookui/Phonebook2/EABI/Pbk2PresentationU.DEF
phonebookui/Phonebook2/EABI/pbk2spbcontentprovideru.def
phonebookui/Phonebook2/GroupExtension/rss/Pbk2GroupUiRes.rss
phonebookui/Phonebook2/GroupExtension/rss/PguListView.rss
phonebookui/Phonebook2/GroupExtension/rss/PguMembersListView.rss
phonebookui/Phonebook2/GroupExtension/src/CPguDeleteGroupCmd.cpp
phonebookui/Phonebook2/GroupExtension/src/CPguGroupMembersView.cpp
phonebookui/Phonebook2/GroupExtension/src/CPguGroupNameQueryDlg.cpp
phonebookui/Phonebook2/GroupExtension/src/CPguGroupView.cpp
phonebookui/Phonebook2/NamesListExtension/inc/Pbk2NamesListExView.h
phonebookui/Phonebook2/NamesListExtension/inc/cpbk2mycard.h
phonebookui/Phonebook2/NamesListExtension/inc/cpbk2openmycardcmd.h
phonebookui/Phonebook2/NamesListExtension/rss/Pbk2ExNamesListRes.rss
phonebookui/Phonebook2/NamesListExtension/src/NamesListExView.cpp
phonebookui/Phonebook2/NamesListExtension/src/NamesListUiExtensionPlugin.cpp
phonebookui/Phonebook2/NamesListExtension/src/cpbk2deletemycardcmd.cpp
phonebookui/Phonebook2/NamesListExtension/src/cpbk2mycard.cpp
phonebookui/Phonebook2/NamesListExtension/src/cpbk2openmycardcmd.cpp
phonebookui/Phonebook2/Presentation/src/CPbk2ImageReader.cpp
phonebookui/Phonebook2/Presentation/src/CPbk2ImageWriterBase.cpp
phonebookui/Phonebook2/Presentation/src/CPbk2PresentationContactFieldCollection.cpp
phonebookui/Phonebook2/Presentation/src/Pbk2PresentationUtils.cpp
phonebookui/Phonebook2/ServerApplication/inc/CPbk2AddressSelectPhase.h
phonebookui/Phonebook2/ServerApplication/src/CPbk2AddressSelectPhase.cpp
phonebookui/Phonebook2/UIControls/inc/cpbk2filteredviewstack.h
phonebookui/Phonebook2/UIControls/rss/Pbk2FetchDlg.rss
phonebookui/Phonebook2/UIControls/rss/Pbk2UIControls.rss
phonebookui/Phonebook2/UIControls/src/CPbk2FetchDlg.cpp
phonebookui/Phonebook2/UIControls/src/CPbk2MemoryEntryDefaultsDlg.cpp
phonebookui/Phonebook2/UIControls/src/CPbk2NamesListControl.cpp
phonebookui/Phonebook2/UIControls/src/CPbk2NamesListFilteredState.cpp
phonebookui/Phonebook2/UIControls/src/CPbk2NamesListReadyState.cpp
phonebookui/Phonebook2/UIControls/src/CPbk2ThumbnailManager.cpp
phonebookui/Phonebook2/UIControls/src/Pbk2ImageCommands.cpp
phonebookui/Phonebook2/UIControls/src/cpbk2contactviewdoublelistboxmodel.cpp
phonebookui/Phonebook2/UIControls/src/cpbk2filteredviewstack.cpp
phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimFixedDialingView.rss
phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimServiceDialingView.rss
phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimUiRes.rss
phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/inc/ccappcommlaunchercontainer.h
phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlaunchercontainer.cpp
phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherheadercontrol.cpp
phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherlpadmodel.cpp
phonebookui/Phonebook2/ccapplication/ccadetailsviewplugin/inc/ccappdetailsviewlistboxmodel.h
phonebookui/Phonebook2/ccapplication/ccadetailsviewplugin/src/ccappdetailsviewcontainer.cpp
phonebookui/Phonebook2/ccapplication/ccadetailsviewplugin/src/ccappdetailsviewlistboxmodel.cpp
phonebookui/Phonebook2/ccapplication/ccamycardplugin/group/ccappmycardplugin.mmp
phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycard.h
phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycardcontainer.h
phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycardimageloader.h
phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycardplugin.h
phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycard.cpp
phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycardcontainer.cpp
phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycardimageloader.cpp
phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycardplugin.cpp
phonebookui/Phonebook2/ccapplication/ccapp/ccapputil/src/ccappimagedecoding.cpp
phonebookui/Phonebook2/ccapplication/ccapp/src/ccapppluginloader.cpp
phonebookui/Phonebook2/group/pbk2spbcontentprovider.mmp
phonebookui/Phonebook2/inc/CPbk2FetchDlg.h
phonebookui/Phonebook2/inc/CPbk2MemoryEntryDefaultsDlg.h
phonebookui/Phonebook2/inc/CPbk2NamesListControl.h
phonebookui/Phonebook2/inc/CPbk2PresentationContactFieldCollection.h
phonebookui/Phonebook2/inc/Pbk2PresentationUtils.h
phonebookui/Phonebook2/inc/spbcontactdatamodel.h
phonebookui/Phonebook2/loc/phonebook2.loc
phonebookui/Phonebook2/loc/phonebook2ece.loc
phonebookui/Phonebook2/remotecontactlookup/contactactionservice/sendbusinesscard/data/pbk2rclsendbusinesscardpluginimpl.rss
phonebookui/Phonebook2/remotecontactlookup/engine/data/engine.rss
phonebookui/Phonebook2/remotecontactlookup/engine/src/cpbkxrclsettingitem.cpp
phonebookui/Phonebook2/remotecontactlookup/settingplugin/data/pbk2rclsettingres.rss
phonebookui/Phonebook2/spbcontentprovider/inc/spbcontactdatamodelprivate.h
phonebookui/Phonebook2/spbcontentprovider/inc/spbcontactdatamodelrow.h
phonebookui/Phonebook2/spbcontentprovider/src/spbcontactdatamodel.cpp
phonebookui/Phonebook2/spbcontentprovider/src/spbcontactdatamodelprivate.cpp
phonebookui/Phonebook2/spbcontentprovider/src/spbcontactdatamodelrow.cpp
pimprotocols/pbap/inc/pbapfolderclient.h
pimprotocols/pbap/inc/pbapserver.h
pimprotocols/pbap/inc/pbapvcardexporterutil.h
pimprotocols/pbap/server/pbapchexporter.cpp
pimprotocols/pbap/server/pbapserver.cpp
pimprotocols/pbap/server/pbapvcardexporterutil.cpp
pimprotocols/phonebooksync/Test/TE_Sync/TE_Sync_Config.txt
predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsAlgorithm1.h
predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsAlgorithm1Helper.h
predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsAlgorithm1MultiSearchHelper.h
predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsAlgorithm1Utils.h
predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsCache.h
predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsKeyMap.h
predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsPoolElement.h
predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1.cpp
predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1Helper.cpp
predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1MultiSearchHelper.cpp
predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1Utils.cpp
predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsCache.cpp
predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsKeyMap.cpp
predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsPoolElement.cpp
predictivesearch/PcsAlgorithm/Algorithm1/src/CPsDataPluginInterface.cpp
predictivesearch/PcsAlgorithm/Algorithm2/inc/CPcsPoolElement.h
predictivesearch/PcsAlgorithm/Algorithm2/src/CPcsPoolElement.cpp
predictivesearch/PcsAlgorithm/group/bld.inf
predictivesearch/PcsServer/inc/CPcsServer.h
predictivesearch/PcsServer/inc/CPcsSession.h
predictivesearch/PcsServer/src/CPcsPluginInterface.cpp
predictivesearch/PcsServer/src/CPcsServer.cpp
predictivesearch/PcsServer/src/CPcsSession.cpp
predictivesearch/PcsUtils/inc/CPcsDebug.h
predictivesearch/PcsUtils/src/CPcsDebug.cpp
predictivesearch/PcsUtils/src/CPsData.cpp
predictivesearch/PcsUtils/src/CPsQuery.cpp
predictivesearch/adapters/contacts/src/cpcscontactstore.cpp
predictivesearch/sis/makesis_udeb.bat
predictivesearch/sis/makesis_urel.bat
predictivesearch/sis/psengine_stub.SIS
predictivesearch/sis/psengine_stub.pkg
--- a/ccservices/cmsservices/cmsengine/Server/group/cmsserver.mmp	Fri Mar 12 15:41:25 2010 +0200
+++ b/ccservices/cmsservices/cmsengine/Server/group/cmsserver.mmp	Mon Mar 15 12:39:26 2010 +0200
@@ -65,7 +65,6 @@
 LIBRARY                         Pbk2Presentation.lib // nameformatter
 LIBRARY					        serviceprovidersettings.lib
 LIBRARY                         presencetrafficlights.lib
-LIBRARY                         imcm.lib 
 
 LIBRARY	 rcse.lib
 
--- a/ccservices/cmsservices/cmsengine/Server/inc/cmsphonebookproxy.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/ccservices/cmsservices/cmsengine/Server/inc/cmsphonebookproxy.h	Mon Mar 15 12:39:26 2010 +0200
@@ -186,7 +186,7 @@
         /**
         * Set default attribute for voice call
         */
-        void SetVoiceCallDefaultL();
+        void SetVoiceCallDefaultL( MVPbkStoreContact* aContact );
 
     public:
         
@@ -324,8 +324,6 @@
         CDesCArrayFlat                          ixSPStoresArray;
         /// Default setting handle
         CmsSetVoiceCallDefault*                 iSetDefault;
-        /// Store contact
-        MVPbkStoreContact*                      iContact;
     };
 
 #endif  //__CMSPHONEBOOKPROXY__
--- a/ccservices/cmsservices/cmsengine/Server/inc/cmsservercontact.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/ccservices/cmsservices/cmsengine/Server/inc/cmsservercontact.h	Mon Mar 15 12:39:26 2010 +0200
@@ -189,6 +189,11 @@
         */
         void IsTopContactL( const RMessage2& aMessage );
         
+        /**
+        * Sets default number for Voice Call
+        */
+        void SetVoiceCallDefaultL();
+        
     private:
         
         /**
--- a/ccservices/cmsservices/cmsengine/Server/inc/cmssetvoicecalldefault.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/ccservices/cmsservices/cmsengine/Server/inc/cmssetvoicecalldefault.h	Mon Mar 15 12:39:26 2010 +0200
@@ -19,12 +19,12 @@
 #define CMSSETVOICECALLDEFAULT_H_
 
 #include <e32base.h>
-#include <mvpbksinglecontactoperationobserver.h>
-#include <mvpbkcontactattributemanager.h>
-#include <mvpbkcontactstoreobserver.h>
-#include <vpbkfieldtype.hrh>
-#include <mvpbkcontactobserver.h>
-#include <mvpbkbatchoperationobserver.h>
+#include <MVPbkSingleContactOperationObserver.h>
+#include <MVPbkContactAttributeManager.h>
+#include <MVPbkContactStoreObserver.h>
+#include <VPbkFieldType.hrh>
+#include <MVPbkContactObserver.h>
+#include <MVPbkBatchOperationObserver.h>
 
 class CmsSetVoiceCallDefault: 
     public CBase,
--- a/ccservices/cmsservices/cmsengine/Server/src/cmsphonebookproxy.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/ccservices/cmsservices/cmsengine/Server/src/cmsphonebookproxy.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -408,9 +408,9 @@
 //
 // ----------------------------------------------------------
 //
-void CCmsPhonebookProxy::SetVoiceCallDefaultL()
+void CCmsPhonebookProxy::SetVoiceCallDefaultL( MVPbkStoreContact* aContact )
 	{
-	iSetDefault->SetVoiceCallDefaultL( iContact, iContactManager );
+	iSetDefault->SetVoiceCallDefaultL( aContact, iContactManager );
 	}
 
 // ----------------------------------------------------------
@@ -727,7 +727,6 @@
     PRINT( _L( "Start CCmsPhonebookProxy::VPbkSingleContactOperationComplete()" ) );
 
     ResetData();
-    iContact = aContact;
     CompleteContactRequestL( KErrNone, aContact );
     iCmsPhonebookOperationsObserver.CmsSingleContactOperationComplete( KErrNone );
 
--- a/ccservices/cmsservices/cmsengine/Server/src/cmsservercontact.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/ccservices/cmsservices/cmsengine/Server/src/cmsservercontact.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -1507,4 +1507,14 @@
         }
     iOperation = iContactManager->RetrieveContactL( *aContactLinkToFetch, *this );
     }
+
+// ----------------------------------------------------
+// CCmsServerContact::SetVoiceCallDefaultL
+// 
+// ----------------------------------------------------
+//
+void CCmsServerContact::SetVoiceCallDefaultL()
+    {
+    iCmsServer.PhonebookProxyHandle().SetVoiceCallDefaultL( iContact );
+    }
 // End of File
--- a/ccservices/cmsservices/cmsengine/Server/src/cmsserversession.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/ccservices/cmsservices/cmsengine/Server/src/cmsserversession.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -38,8 +38,13 @@
 #include <MVPbkContactFieldTextData.h>
 #include <MVPbkContactFieldUriData.h>
 #include <MVPbkContactFieldData.h>
-#include <cemailaccounts.h> // For finding out available email account counts
 #include <e32base.h>
+
+// For finding mailbox accounts
+#include <EmailInterfaceFactory.h>
+#include <MEmailMailbox.h>
+
+
 namespace {
 
 TBool IsFieldTypeVoipCapable( TInt aFieldTypeResId, TInt aVoipFlag )
@@ -482,25 +487,34 @@
                 }
             case VPbkFieldTypeSelectorFactory::EEmailEditorSelector:
             	{
-            	CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();
-            	RArray<TPopAccount> popAccounts;
-            	RArray<TImapAccount> imapAccounts;
-            	RArray<TSmtpAccount> smtpAccounts;
+            	using namespace EmailInterface;
+
+            	CEmailInterfaceFactory* factory = CEmailInterfaceFactory::NewL();
+            	CleanupStack::PushL( factory );
+            	MEmailInterface* ifPtr = factory->InterfaceL( KEmailClientApiInterface );
+            	MEmailClientApi* clientApi = static_cast<MEmailClientApi*>( ifPtr );
+            	CleanupReleasePushL( *clientApi );
             	
-            	emailAccounts->GetPopAccountsL(popAccounts);
-            	emailAccounts->GetImapAccountsL(imapAccounts);
-            	emailAccounts->GetSmtpAccountsL(smtpAccounts);
-            	CleanupStack::PopAndDestroy(emailAccounts);
+            	RMailboxPtrArray mailboxes;
+            	TRAPD( error, clientApi->GetMailboxesL( mailboxes ););
+            	TInt count = mailboxes.Count();
             	
-            	// If no mailbox exists, set availability to false
-            	if( ( popAccounts.Count() + imapAccounts.Count() + smtpAccounts.Count() ) == 0 )
+            	// Release mailboxs before releasing clientapi
+            	for ( TInt i=0; i<count; i++ )
             		{
-            		availability = EFalse;
+            		MEmailMailbox* mailbox = mailboxes[i];
+            		mailbox->Release();
             		}
             	
-            	popAccounts.Reset();
-            	imapAccounts.Reset();
-            	smtpAccounts.Reset();
+            	mailboxes.Close();
+            	
+            	CleanupStack::PopAndDestroy( 2 ); // clientApi and factory
+            	
+            	if( count == 0 )
+            	    {
+            	    availability = EFalse;
+            	    }           					            					
+                
             	break;
             	}
             default:
@@ -810,7 +824,7 @@
             }
 		case ECmsSetVoiceCallDefault:
         	{
-        	iCmsServer->PhonebookProxyHandle().SetVoiceCallDefaultL();
+        	iServerContact->SetVoiceCallDefaultL();
         	aMessage.Complete( KErrNone );
         	break;
         	}
--- a/ccservices/cmsservices/cmsengine/Server/src/cmssetvoicecalldefault.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/ccservices/cmsservices/cmsengine/Server/src/cmssetvoicecalldefault.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -16,13 +16,13 @@
 */
 
 #include <mvpbkcontactstoreproperties.h>
-#include <mvpbkcontactstore.h>
-#include <mvpbkstorecontact.h>
+#include <MVPbkContactStore.h>
+#include <MVPbkStoreContact.h>
 
-#include <cvpbkcontactmanager.h>
-#include <cvpbkdefaultattribute.h>
+#include <CVPbkContactManager.h>
+#include <CVPbkDefaultAttribute.h>
 #include <CVPbkFieldTypeSelector.h>
-#include <vpbkcontactstoreuris.h>
+#include <VPbkContactStoreUris.h>
 #include <MVPbkFieldType.h>
 #include <CVPbkContactFieldIterator.h>
 #include <VPbkFieldTypeSelectorFactory.h>
--- a/contacts_plat/cca_launch_api/inc/mccaparameter.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/contacts_plat/cca_launch_api/inc/mccaparameter.h	Mon Mar 15 12:39:26 2010 +0200
@@ -75,7 +75,8 @@
         EContactNone = 0,
         EContactId,         //Depricated; not supported anymore.
         EContactLink,
-        EContactMSISDN      //Depricated; not supported anymore.
+        EContactMSISDN,     //Depricated; not supported anymore.
+        EContactDataModel   //Internal flag for Phonebook2
         };
 
     /**
--- a/contacts_plat/group/bld.inf	Fri Mar 12 15:41:25 2010 +0200
+++ b/contacts_plat/group/bld.inf	Mon Mar 15 12:39:26 2010 +0200
@@ -58,6 +58,7 @@
 #include "../phonebook_2_commands_api/group/bld.inf"
 #include "../phonebook_2_presentation_api/group/bld.inf"
 #include "../phonebook_2_ui_utilities_api/group/bld.inf"
+#include "../phonebook_2_contact_related_icon_customization_api/group/bld.inf"
 #include "../cca_launch_api/group/bld.inf"
 #include "../cca_view_plugin_api/group/bld.inf"
 #include "../predictivesearch_client_api/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/group/bld.inf	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2008-2009 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: Exports for Phonebook 2 Contact Related Icon Customization API.
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+..\inc\CContactCustomIconPluginBase.h        APP_LAYER_PLATFORM_EXPORT_PATH(CContactCustomIconPluginBase.h)
+..\inc\ContactCustomIconPluginDefs.h         APP_LAYER_PLATFORM_EXPORT_PATH(ContactCustomIconPluginDefs.h)
+..\inc\CCustomIconDecisionData.h             APP_LAYER_PLATFORM_EXPORT_PATH(CCustomIconDecisionData.h)
+..\inc\CCustomIconDecisionData.inl           APP_LAYER_PLATFORM_EXPORT_PATH(CCustomIconDecisionData.inl)
+..\inc\CCustomIconIdMap.h                    APP_LAYER_PLATFORM_EXPORT_PATH(CCustomIconIdMap.h)
+..\inc\CCustomIconIdMap.inl                  APP_LAYER_PLATFORM_EXPORT_PATH(CCustomIconIdMap.inl)
+..\inc\MCustomIconChangeObserver.h           APP_LAYER_PLATFORM_EXPORT_PATH(MCustomIconChangeObserver.h)
+
+PRJ_MMPFILES
+// None
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/CContactCustomIconPluginBase.h	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,296 @@
+/*
+* Copyright (c) 2008-2009 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:  Defines an ECOM interface for third parties to customize
+*               contact related icons in certain platform applications.
+*/
+
+#ifndef CCONTACTICONCUSTOMPLUGINBASE_H
+#define CCONTACTICONCUSTOMPLUGINBASE_H
+
+// INCLUDES
+#include <e32base.h>
+#include <ecom\ecom.h>
+#include <ContactCustomIconPluginDefs.h>
+
+// FORWARD DECLARATIONS
+class CGulIcon;
+class CCustomIconIdMap;
+class CCustomIconDecisionData;
+class MCustomIconChangeObserver;
+
+// CONSTANTS
+
+/**
+*  Interface UID for ECOM plug-ins, which inherit from this interface.
+*  This is used in plug-in registration resource file (interface_uid). Example:
+*
+*   RESOURCE REGISTRY_INFO cs_ecom_reg_info
+*       {
+*       dll_uid = <UID_OF_ECOM_DLL>;
+*       interfaces =
+*           {
+*           INTERFACE_INFO
+*               {
+*               // Make sure to use KContactIconCustomizationInterfaceUidValue
+*               interface_uid = 0x2001E2DA;
+*
+*               implementations =
+*                   {
+*                   IMPLEMENTATION_INFO
+*                       {
+*                       implementation_uid = <...>; //  maps to IMPLEMENTATION_PROXY_ENTRY in CPP exporting plugin factory functions
+*                       version_no = 1;
+*                       display_name = "CMyContactIconCustomizationPlugin";
+*                       default_data = "";
+*                       opaque_data = "";
+*                       }
+*                   };
+*               }
+*           };
+*       }
+*/
+const TInt KContactIconCustomizationInterfaceUidValue = 0x2001E2DA;
+const TUid KContactIconCustomizationInterfaceUid =
+    { KContactIconCustomizationInterfaceUidValue };
+
+
+// CLASS DECLARATION
+
+/**
+*  Base class for contact related icon customization ECOM plugins.
+*
+*  This API allows customizing contact related icons of certain
+*  applications at runtime.
+*
+*  The API defines two roles:
+*  - Customizable entity is typically an application supporting icon
+*    customization. It is a caller of this API.
+*  - Customizer is an entity implementing ecom plug-in, a callee.
+*
+*  As a concrete example, Logs application has 'Dialled calls' view
+*  where it by default shows in each listbox row a call specific icon.
+*  Plugin can change each of the icons by implementing this API.
+*
+*  The customizer needs only one plug-in implementation, which affects
+*  multiple applications at a same time. This means the API cannot define
+*  application specific info.
+*
+*  Note that customizable entity - typically an application - has to provide
+*  a connection to Font and Bitmap server. The plug-in may fail to provide
+*  the icon (KErrCouldNotConnect), if the connection does not exist.
+*/
+class CContactCustomIconPluginBase : public CBase
+    {
+    public: // API to be implemented by ECOM plug-in
+
+        /**
+         * An icon size hint from application to plug-in. Plug-in
+         * may use this to load icons of appropriate size.
+         * @see IconsL
+         */
+        enum TIconSizeHint
+            {
+            EReallySmall,
+            ESmall,
+            EMedium,
+            EMediumLarge,
+            ELarge
+            };
+
+        /**
+         * Calling application uses this method to register itself as an observer
+         * for the plug-in state change notifications.
+         *
+         * Plug-in uses observer interface for notifying calling application
+         * about icon related changes.
+         *
+         * @param aObserver     Observer interface, implemented by calling client
+         *                      code. Ownership of the object is not transferred.
+         */
+        virtual void AddObserverL(
+                MCustomIconChangeObserver* aObserver ) = 0;
+
+        /**
+         * Calling application uses this method to deregister itself as an observer
+         * from the plug-in state change notifications.
+         *
+         * @param aObserver     Observer interface, implemented by calling client
+         *                      code. Ownership of the object is not transferred.
+         */
+        virtual void RemoveObserver(
+                MCustomIconChangeObserver* aObserver ) = 0;
+
+        /**
+         * Gets an array of custom icons from the plug-in.
+         *
+         * Application calls this method typically in its initialization phase
+         * to prepare for replacing its default icons. When it is time to show
+         * the icons, calling application may call IconChoiceL.
+         *
+         * ECOM plug-in implementation should fill in the potential icons
+         * and give each icon an identifier, which it can use later to refer
+         * to a certain icon it wants to use as replacement for application's
+         * default icon.
+         *
+         * @see CCustomIconIdMap.h
+         * @param aContext  Context of the function call. For more information
+         *                  about context semantics see CCustomIconDecisionData
+         *                  documentation.
+         * @param aSizeHint Hint for plug-in to load icons of appropriate size.
+         * @return  Icon-to-id map.
+         * @leave On typical leave level problems. Application should handle
+         *        this by ignoring ECOM plug-in functionality and continue
+         *        using its default icons.
+         */
+        virtual CCustomIconIdMap* IconsL(
+                TUid aContext,
+                TIconSizeHint aSizeHint ) = 0;
+
+        /**
+         * Application uses this method to make a choice of the icon to be
+         * displayed in certain UI condition.
+         *
+         * Note that application should have always had called the IconsL
+         * function before this gets called.
+         *
+         * ECOM plug-in implementation should use aHint parameter to make a decision
+         * which icon it wants to use.
+         *
+         * @param aHint     Hint from the application to the plug-in, which tells
+         *                  what kind of icon is being replaced. For example, the
+         *                  plug-in may want to choose the icon based on the
+         *                  phonenumber. For more details see
+         *                  CCustomIconDecisionData.h.
+         *                  Plug-in must not take ownership of the object's
+         *                  members. The instance and its members are guaranteed to
+         *                  be valid only during the method call.
+         *
+         *                  Caller must fill at least one of the members, otherwise
+         *                  plug-in can and should leave with KErrArgument.
+         *
+         * @param aIdResult Icon reference value filled by the ECOM plug-in. The id
+         *                  should be one of the ids, which were used to build the
+         *                  CCustomIconIdMap object in IconsL function. If the
+         *                  calling application cannot find an icon by aIdResult
+         *                  from the map, it should use application's default icon.
+         *
+         * @return  Return value indicating if the decision could be made.
+         *          ETrue, if the icon choice decision could be made.
+         *          EFalse, if the icon choice could not be made.
+         *          This is an indication from plug-in to application that
+         *          application should use its default icon.
+         *
+         * @leave On typical leave level problems like database access failure
+         *        or condition where application may not be able to provide the
+         *        requested functionality. It is up to application how it
+         *        handles leave from the plug-in. Recommendation is that it
+         *        ignores plug-in's functionality and uses default icons.
+         */
+        virtual TBool IconChoiceL(
+                const CCustomIconDecisionData& aHint,
+                TCustomIconId& aIdResult ) = 0;
+
+        /**
+         * Application uses this method when it dynamically needs to replace
+         * its default icon. This can typically happen at any time of the
+         * application runtime.
+         *
+         * Application should favor using the IconsL/IconChoiceL pair, if it
+         * is likely to use multiple icons and several times. This function is
+         * useful if the application needs only couple of icons only couple
+         * of times. This is discouraged for use in frequent draw requests.
+         *
+         * The plug-in implementation should use the aHint to make a decision
+         * which icon it wants to use.
+         *
+         * @param aHint     Hint from application to plug-in, which tells what
+         *                  kind of icon is being replaced. For example, the
+         *                  plug-in may want to choose the icon based on the
+         *                  phonenumber. For more details see
+         *                   CCustomIconDecisionData.h
+         *                  Plug-in must not take ownership of the object or its
+         *                  members. The instance and its members are guaranteed to
+         *                  be valid only during the method call.
+         *                  Caller must fill at least one of the members, otherwise
+         *                  plug-in can and should leave with KErrArgument.
+         *
+         * @param aSizeHint Hint for plug-in to load icon of appropriate size.
+         *
+         * @return  Icon instance. NULL, if plug-in wants to indicate it is
+         *          not willing to replace caller's default icon.
+         */
+        virtual CGulIcon* IconL(
+                const CCustomIconDecisionData& aHint,
+                TIconSizeHint aSizeHint ) = 0;
+
+        /**
+         * Application uses this method when it dynamically needs to update
+         * previously loaded custom icon. Typically this happens after
+         * application has received update notification from plug-in.
+         *
+         * @param aContext   Context of the function call. While this override
+         *                   provides known icon id rather than
+         *                   CCustomIconDecisionData, the context is given here
+         *                   separately. For more information about context
+         *                   semantics see CCustomIconDecisionData
+         *                   documentation.
+         *
+         * @param aIconId   Specifies the icon for the client to provide. This is
+         *                   valid when a known custom icon has changed and is
+         *                   being replaced.
+         *
+         * @param aSizeHint Hint for plug-in to load icon of appropriate size.
+         *
+         * @return  Icon instance. NULL, if plug-in wants to indicate it is
+         *          not willing to replace application's default icon.
+         */
+        virtual CGulIcon* IconL(
+                TUid aContext,
+                TCustomIconId aIconId,
+                TIconSizeHint aSizeHint ) = 0;
+
+        /**
+         * Factory function for getting access to extended API functionality.
+         * Uid defines the extension interface being used.
+         *
+         * @param aExtensionUid     Identifier for extension API class.
+         * @return  Extension API class, casted to one of M-interfaces defined
+         *         by this API (later). Ownership of the object is not transferred.
+         */
+        virtual TAny* ContactCustomIconExtension( TUid /*aExtensionUid*/ )
+            {
+            return NULL;
+            }
+
+    public:
+
+        /**
+         * ~CContactIconCustomPluginBase
+         *
+         * Cleans up resources, specifically notify ECOM server that this
+         * instance is being deleted.
+         */
+        inline virtual ~CContactCustomIconPluginBase()
+            {
+            REComSession::DestroyedImplementation( iDtorKey );
+            }
+
+    public:
+        /// Own: Key UID
+        TUid iDtorKey;
+    };
+
+#endif // CCONTACTICONCUSTOMPLUGINBASE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/CCustomIconDecisionData.h	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,149 @@
+/*
+* Copyright (c) 2008-2009 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:  Container for icon choice decision data.
+*/
+
+#ifndef CCUSTOMICONDECISIONDATA_H
+#define CCUSTOMICONDECISIONDATA_H
+
+// INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class MVPbkContactLink;
+
+/**
+ * Container for icon choice decision data.
+ *
+ * When an application supporting Contact Related Icon Customization API allows
+ * customization for a certain icon, it instantiates this class and passes it to
+ * the icon customization plug-in for getting a reference to the custom icon.
+ *
+ * The plug-in uses the data members of this class for its decision making. For
+ * example, it could use the iPhoneNumber to resolve a certain custom icon
+ * which is related to that phone number.
+ *
+ * Note that member values and semantics are undefined by the API. The
+ * application decides how the values are filled. Application should
+ * at least fill one of the members so that the plug-in can make meaningful
+ * icon choice decision.
+ *
+ * @see CContactIconCustomPluginBase
+ */
+class CCustomIconDecisionData : public CBase
+    {
+    public: // Construction and destruction
+
+        /**
+         * Constructor.
+         */
+        CCustomIconDecisionData();
+
+        /**
+         * Destructor.
+         */
+        ~CCustomIconDecisionData();
+
+    public: // Interface
+
+    /**
+     * Returns the context.
+     *
+     * @return  UID of the context.
+     * @see iContext
+     */
+    TUid Context() const;
+
+    /**
+     * Returns the time.
+     *
+     * @return  Time.
+     * @see iTime
+     */
+    const TTime* Time() const;
+
+    /**
+     * Returns the phone number. KNullDesC if not set.
+     *
+     * @return  Phone number.
+     */
+    TPtrC PhoneNumber() const;
+
+    /**
+     * Returns the contact link.
+     *
+     * @return  Contact link.
+     */
+    const MVPbkContactLink* ContactLinkRef() const;
+
+    /**
+     * Sets context.
+     *
+     * @param aUid  Context UID.
+     * @see iContext
+     */
+    void SetContext(
+            TUid aUid );
+
+    /**
+     * Sets the time.
+     *
+     * @param aTime     The time to set. Ownership taken.
+     * @see iTime
+     */
+    void SetTime(
+            TTime* aTime );
+
+    /**
+     * Sets the phone number.
+     *
+     * @param aPhoneNumber      The phone number to set.
+     */
+    void SetPhoneNumberL(
+            const TDesC& aPhoneNumber );
+
+    /**
+     * Sets contact link.
+     *
+     * @param aLink     The link to set. Ownership is not taken.
+     */
+    void SetContactLinkRef(
+            const MVPbkContactLink* aLink );
+
+    private: // Data
+
+        /// Own: Context property for customization.
+        /// It is up to caller how it sets this. At minimum caller should set this
+        /// value to its application UID or similar. Or, if there are several
+        /// logical application contexts, application may select different
+        /// UID for each use. Caller is allowed to set this to KNullUid.
+        TUid iContext;
+
+        /// Own: Time property for customization, optional.
+        /// For example in Logs application this could be time of the Logs event.
+        /// The time value should be Universal time.
+        TTime* iTime;
+
+        /// Own: Phonenumber property for customization, optional.
+        HBufC* iPhoneNumber;
+
+        /// Ref: Contact link
+        const MVPbkContactLink* iContactLinkRef;
+    };
+
+#include <CCustomIconDecisionData.inl>
+
+#endif // CCUSTOMICONDECISIONDATA_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/CCustomIconDecisionData.inl	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2008-2009 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:  Container for icon choice decision data.
+*/
+
+// --------------------------------------------------------------------------
+// CCustomIconDecisionData::CCustomIconDecisionData
+// --------------------------------------------------------------------------
+//
+inline CCustomIconDecisionData::CCustomIconDecisionData():
+        iContext( KNullUid )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CCustomIconDecisionData::~CCustomIconDecisionData
+// --------------------------------------------------------------------------
+//
+inline CCustomIconDecisionData::~CCustomIconDecisionData()
+    {
+    delete iTime;
+    delete iPhoneNumber;
+    }
+
+// --------------------------------------------------------------------------
+// CCustomIconDecisionData::Context
+// --------------------------------------------------------------------------
+//
+inline TUid CCustomIconDecisionData::Context() const
+    {
+    return iContext;
+    }
+
+// --------------------------------------------------------------------------
+// CCustomIconDecisionData::Time
+// --------------------------------------------------------------------------
+//
+inline const TTime* CCustomIconDecisionData::Time() const
+    {
+    return iTime;
+    }
+
+// --------------------------------------------------------------------------
+// CCustomIconDecisionData::PhoneNumber
+// --------------------------------------------------------------------------
+//
+inline TPtrC CCustomIconDecisionData::PhoneNumber() const
+    {
+    if( iPhoneNumber )
+        {
+        return *iPhoneNumber;
+        }
+    return KNullDesC();
+    }
+
+// --------------------------------------------------------------------------
+// CCustomIconDecisionData::ContactLinkRef
+// --------------------------------------------------------------------------
+//
+inline const MVPbkContactLink* CCustomIconDecisionData::ContactLinkRef() const
+    {
+    return iContactLinkRef;
+    }
+
+// --------------------------------------------------------------------------
+// CCustomIconDecisionData::SetContext
+// --------------------------------------------------------------------------
+//
+inline void CCustomIconDecisionData::SetContext( TUid aUid )
+    {
+    iContext = aUid; 
+    }
+
+// --------------------------------------------------------------------------
+// CCustomIconDecisionData::SetTime
+// --------------------------------------------------------------------------
+//
+inline void CCustomIconDecisionData::SetTime( TTime* aTime )
+    {
+    delete iTime;
+    iTime = aTime;
+    }
+
+// --------------------------------------------------------------------------
+// CCustomIconDecisionData::SetPhoneNumberL
+// --------------------------------------------------------------------------
+//
+inline void CCustomIconDecisionData::SetPhoneNumberL
+        ( const TDesC& aPhoneNumber )
+    {
+    HBufC* newNumber = aPhoneNumber.AllocL();
+    delete iPhoneNumber;
+    iPhoneNumber = newNumber;
+    }
+
+// --------------------------------------------------------------------------
+// CCustomIconDecisionData::SetContactLinkRef
+// --------------------------------------------------------------------------
+//
+inline void CCustomIconDecisionData::SetContactLinkRef
+        ( const MVPbkContactLink* aLink )
+    {
+    iContactLinkRef = aLink;
+    }
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/CCustomIconIdMap.h	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2008-2009 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:  Data container to icons and their unique identifiers.
+*/
+
+#ifndef CCUSTOMICONIDMAP_H
+#define CCUSTOMICONIDMAP_H
+
+#include <gulicon.h>
+#include <ContactCustomIconPluginDefs.h>
+
+/**
+ * Container for the icon pointer and its identifier.
+ * This is used by CCustomIconIdMap.
+ *
+ * Note that this class does not control ownership of the
+ * icon in any way.
+ */
+class TCustomIconIdMapItem
+    {
+    public: // Construction
+
+        /**
+         * Constructor.
+         */
+        TCustomIconIdMapItem();
+
+        /**
+         * Constructor.
+         *
+         * @param aIcon     Icon.
+         * @param aId       Icon id.
+         */
+        TCustomIconIdMapItem(
+                CGulIcon* aIcon,
+                TCustomIconId aId );
+
+    public: // Data
+        /// Ref: Icon
+        CGulIcon* iIconPtr;
+        /// Ref: Icon id
+        TCustomIconId iId;
+    };
+
+/**
+ * Array of custom icons and their identifiers.
+ * The class holds TCustomIconIdMapItem items.
+ *
+ * For leave covery purposes the class deletes any icons referenced in the
+ * items. If an owner of this class wants to take an ownership of an icon,
+ * it must also remove the corresponding icon item.
+ */
+class CCustomIconIdMap : public CArrayFixFlat<TCustomIconIdMapItem>
+    {
+    public: // Construction and destruction
+
+        /**
+         * Constructor.
+         *
+         * @param aGranularity  Array granularity.
+         */
+        CCustomIconIdMap( TInt aGranularity );
+
+        /**
+         * Destructor.
+         */
+        ~CCustomIconIdMap();
+
+    public: // Interface
+
+     /**
+      * Convenience method for adding an item.
+      *
+      * Use this method to add all the icons, which potentially replace
+      * original contact related icons during their life time.
+      * Note that one icon must not be added twice.
+      *
+      * aIcon may be NULL. This indicates the application that when the
+      * plug-in refers to an icon with aId, the application should
+      * use its default icon.
+      *
+      * @param aIcon    The icon instance. Ownership is taken, if the method
+      *                 does not leave. The value may be NULL.
+      *
+      * @param aId      Unique identifier for identifying an icon. Plug-in needs
+      *                 to remember the ids since application uses the id to later
+      *                 refer to an icon. The id could be for example
+      *                - unique id in database, or
+      *                - predefined enum value, if the icons are well known
+      *                  during customization build time and won't change
+      */
+     void AppendL(
+            CGulIcon* aIcon,
+            TCustomIconId aId );
+    };
+
+#include <CCustomIconIdMap.inl>
+
+#endif // CCUSTOMICONIDMAP_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/CCustomIconIdMap.inl	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2008-2009 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:  Data container to icons and their unique identifiers.
+*/
+
+// --------------------------------------------------------------------------
+// TCustomIconIdMapItem::TCustomIconIdMapItem
+// --------------------------------------------------------------------------
+//
+inline TCustomIconIdMapItem::TCustomIconIdMapItem():
+        iIconPtr( NULL ), iId( NULL )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// TCustomIconIdMapItem::TCustomIconIdMapItem
+// --------------------------------------------------------------------------
+//
+inline TCustomIconIdMapItem::TCustomIconIdMapItem
+        ( CGulIcon* aIcon, TCustomIconId aId):
+            iIconPtr( aIcon ), iId( aId )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CCustomIconIdMap::CCustomIconIdMap
+// --------------------------------------------------------------------------
+//
+inline CCustomIconIdMap::CCustomIconIdMap( TInt aGranularity ):
+        CArrayFixFlat<TCustomIconIdMapItem>( aGranularity )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CCustomIconIdMap::~CCustomIconIdMap
+// --------------------------------------------------------------------------
+//
+inline CCustomIconIdMap::~CCustomIconIdMap()
+    {
+    TInt i;
+    TInt count = Count();
+    for( i=0; i<count; i++ )
+        {
+        delete At( i ).iIconPtr;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CCustomIconIdMap::AppendL
+// --------------------------------------------------------------------------
+//
+inline void CCustomIconIdMap::AppendL( CGulIcon* aIcon, TCustomIconId aId  )
+    {
+    TCustomIconIdMapItem item( aIcon, aId );
+    CArrayFixFlat<TCustomIconIdMapItem>::AppendL( item );
+    }
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/ContactCustomIconPluginDefs.h	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2008-2009 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:  Definitions for Contact Related Icon Customization API.
+*/
+
+#ifndef CONTACTCUSTOMICONPLUGINDEFS_H
+#define CONTACTCUSTOMICONPLUGINDEFS_H
+
+// INCLUDES
+#include <e32base.h>
+
+// DEFINITIONS
+
+typedef TInt TCustomIconId;
+
+#endif // CONTACTCUSTOMICONPLUGINDEFS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/inc/MCustomIconChangeObserver.h	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2008-2009 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:  Observer interface for custom icon change events.
+*/
+
+#ifndef MCUSTOMICONCHANGEOBSERVER_H
+#define MCUSTOMICONCHANGEOBSERVER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <ContactCustomIconPluginDefs.h>
+
+// FORWARD DECLARATIONS
+class CContactCustomIconPluginBase;
+
+// CLASS DECLARATION
+
+/**
+ * Observer interface for custom icon change events.
+ */
+class MCustomIconChangeObserver
+    {
+    public: // Notifications from plug-in to client
+
+        /**
+         * Icon event type definitions
+         */
+        enum TEventType
+            {
+            /**
+             * General icon update notification indicates that some
+             * or all of the icons have changed in some manner (update,
+             * removed, added).
+             * Client app should update all custom icons.
+             */
+            EIconsMajorChange,
+
+            /**
+             * Icons have been updated.
+             */
+            EIconsUpdated,
+
+            /**
+             * Some of the icons have been removed.
+             */
+            EIconsRemoved,
+
+            /**
+             * There are new icons available.
+             */
+            EIconsAdded
+            };
+
+        /**
+         * Icon change notification event from plug-in to the client.
+         * Indicates that one or more of the icons have become invalid. Client
+         * needs to refresh its view by loading and drawing new icons.
+         *
+         * @param aPlugin       Plug-in, which initiated this notification. Plug-in
+         *                      should provide 'this' reference.
+         * @param aEventType    Event type, @see TEventType
+         * @param aIconIds      Icon id array indicating the icons, which have changed.
+         *                      While have to be given-in by plug-in, semantics of
+         *                      the parameter are loose. Specifically empty array
+         *                      means the TEventType concerns all possible icons.
+         */
+        virtual void CustomIconEvent(
+                CContactCustomIconPluginBase& aPlugin,
+                TEventType aEventType,
+                const TArray<TCustomIconId>& aIconIds ) = 0;
+
+        /**
+         * Factory function for getting access to extended notifications. Uid
+         * defines the extension interface being used.
+         *
+         * @param aNotificationUid  Identifier for an extension API class.
+         * @return  Extension class.
+         */
+        virtual TAny* IconChangeNotificationExtension(
+                    TUid /*aNotificationUid*/ )
+            {
+            return NULL;
+            }
+
+    protected: // Disabled functions
+        ~MCustomIconChangeObserver() {}
+    };
+
+#endif // MCUSTOMICONCHANGEOBSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/phonebook_2_contact_related_icon_customization_api.metaxml	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,1 @@
+<?xml version="1.0" ?><api id="9a85e051cdc4a23198e3aa18209b9a6c" dataversion="2.0">  <name>Phonebook 2 Contact Related Icon Customization API</name>  <description>Icon customization API for clients of Phonebook 2</description>  <type>c++</type>  <collection>phonebookui</collection>  <libs>    <lib name="ecom.lib" />  </libs>  <release category="platform"/>  <attributes>     <!-- This indicates wether the api provedes separate html documentation -->     <!-- or is the additional documentation generated from headers. -->     <!-- If you are unsuere then the value is "no" -->     <htmldocprovided>yes</htmldocprovided>     <adaptation>no</adaptation>  </attributes></api>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/data/Pbk2IconCustomApiTestPlugin.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2008-2009 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:
+*/
+
+// Includes
+#include "ecom\registryinfo.rh"
+
+// RESOURCE DEFINITION
+RESOURCE REGISTRY_INFO cs_ecom_reg_info
+    {
+    dll_uid = 0x2001FDE5;
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = 0x2001E2DA;
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x10208413; // randomly selected value
+                    version_no = 1;
+                    display_name = "Custom Icon test plugin";
+                    default_data = "";
+                    opaque_data = "";
+                    }
+                };
+            }
+        };
+    }
+
+// End of File
Binary file contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/data/image1.bmp has changed
Binary file contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/data/image2.bmp has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/group/Pbk2IconCustomApiTestPlugin.iby	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,24 @@
+/*
+* 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: 
+*
+*/
+#ifndef ICONCUSTOMAPITESTPLUGIN_IBY
+#define ICONCUSTOMAPITESTPLUGIN_IBY
+
+data = \epoc32\data\Z\data\test\CustIconApiTestIcons.mbm data\test\CustIconApiTestIcons.mbm
+ECOM_PLUGIN( Pbk2IconCustomApiTestPlugin.dll, Pbk2IconCustomApiTestPlugin.rsc )
+
+#endif // ICONCUSTOMAPITESTPLUGIN_IBY
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/group/Pbk2IconCustomApiTestPlugin.mmp	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2008-2009 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:
+*/
+
+#include <platform_paths.hrh>
+
+TARGET      Pbk2IconCustomApiTestPlugin.dll
+TARGETTYPE  PLUGIN
+
+UID     0x10009D8D  0x2001FDE5 
+
+// VID_DEFAULT is Nokia VID (0x101FB657)
+// VENDORID        VID_DEFAULT
+
+CAPABILITY All -TCB
+
+SOURCEPATH      ..\src
+SOURCE          CPbk2IconCustomApiTestPluginFactory.cpp
+SOURCE          CPbk2IconCustomApiTestPlugin.cpp
+
+USERINCLUDE     ..\inc
+APP_LAYER_SYSTEMINCLUDE
+
+
+LIBRARY         euser.lib 
+LIBRARY         ecom.lib 
+LIBRARY         cone.lib
+LIBRARY         eikcore.lib
+LIBRARY         fbscli.lib
+LIBRARY         egul.lib
+LIBRARY         aknicon.lib 
+LIBRARY         efsrv.lib 
+
+// ECOM resource definition
+START RESOURCE  ..\Data\Pbk2IconCustomApiTestPlugin.rss
+TARGET Pbk2IconCustomApiTestPlugin.rsc
+END  // ECOM resource definition
+
+START BITMAP   CustIconApiTestIcons.mbm
+    TARGETPATH Data\Test
+    SOURCEPATH ..\data
+    SOURCE     c16,1 image1.bmp image2.bmp
+END
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/group/bld.inf	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2008-2009 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:
+*/
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+PRJ_TESTEXPORTS
+
+PRJ_EXPORTS
+
+Pbk2IconCustomApiTestPlugin.iby \epoc32\rom\include\Pbk2IconCustomApiTestPlugin.iby
+
+PRJ_TESTMMPFILES
+
+PRJ_MMPFILES
+Pbk2IconCustomApiTestPlugin.mmp
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/inc/CPbk2IconCustomApiTestPlugin.h	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2008-2009 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:
+*/
+
+#ifndef CPBK2ICONCUSTOMAPITESTPLUGIN_H
+#define CPBK2ICONCUSTOMAPITESTPLUGIN_H
+
+// INCLUDES
+#include <CContactCustomIconPluginBase.h>
+
+// FORWARD DECLARATIONS
+class CCustomIconDecisionData;
+class CCustomIconIdMap;
+class CPeriodic;
+
+// CONSTANTS
+
+// Implementation UID of this plug-in.
+const TInt KCPbk2IconCustomApiTestPluginImplValue = 0x10208413;
+const TUid KCPbk2IconCustomApiTestPluginImpl =
+    { KCPbk2IconCustomApiTestPluginImplValue };
+
+
+// CLASS DECLARATION
+/**
+*  This is example implementation of UI customization plugin.
+*/
+class CPbk2IconCustomApiTestPlugin :
+    public CContactCustomIconPluginBase
+    {
+
+    public:
+        /**
+        * Two-phased constructor.
+        */
+        static CPbk2IconCustomApiTestPlugin* NewL();
+        ~CPbk2IconCustomApiTestPlugin();
+
+    public: // API implementation from base class
+
+        void AddObserverL( MCustomIconChangeObserver* aObserver );
+
+        void RemoveObserver( MCustomIconChangeObserver* aObserver );
+
+        CCustomIconIdMap* IconsL( TUid aContext, TIconSizeHint aSizeHint );
+
+        TBool IconChoiceL( const CCustomIconDecisionData& aHint,
+            TCustomIconId& aIdResult );
+
+        CGulIcon* IconL( const CCustomIconDecisionData& aHint,
+            TIconSizeHint aSizeHint );
+
+        CGulIcon* IconL( TCustomIconId aIconId, TIconSizeHint aSizeHint );
+
+        CGulIcon* IconL( TUid aContext,
+            TCustomIconId aIconId,
+            TIconSizeHint aSizeHint );
+
+    private: // Implementation
+
+        static TInt Tick( TAny* aObject );
+        void NotifyObserversL();
+
+    private: // Construction and destruction
+
+        /**
+        * C++ default constructor.
+        */
+        CPbk2IconCustomApiTestPlugin();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    private: // data
+
+        TInt64 iSeed;
+        RArray<MCustomIconChangeObserver*> iObservers;
+        CPeriodic* iTimer;
+    };
+
+
+#endif // CPBK2ICONCUSTOMAPITESTPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/sis/CRICTestEcomPlugin.pkg	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,34 @@
+;
+; 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: 
+;
+; CRICTestEcomPlugin.pkg
+;
+;Languages
+&EN
+;Header
+#{"CRICTestEcomPlugin"},(0x2001E2DE),1,0,0
+
+;Localised Vendor name
+%{"Nokia"}
+
+;Unique Vendor name
+:"Nokia"
+
+;The test application files
+"\epoc32\release\armv5\urel\Pbk2IconCustomApiTestPlugin.dll"-"!:\sys\bin\Pbk2IconCustomApiTestPlugin.dll"
+"\epoc32\data\z\resource\plugins\Pbk2IconCustomApiTestPlugin.rsc"-"!:\resource\plugins\Pbk2IconCustomApiTestPlugin.rsc"
+"\epoc32\data\Z\data\test\CustIconApiTestIcons.mbm"-"!:\Data\Test\CustIconApiTestIcons.mbm"
+
+(0x102032BE), 0, 0, 0, {"S60ProductID"}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/sis/make_sis_and_sign.bat	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,29 @@
+@rem
+@rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+@rem All rights reserved.
+@rem This component and the accompanying materials are made available
+@rem under the terms of "Eclipse Public License v1.0"
+@rem which accompanies this distribution, and is available
+@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@rem
+@rem Initial Contributors:
+@rem Nokia Corporation - initial contribution.
+@rem
+@rem Contributors:
+@rem
+@rem Description: 
+@rem
+@echo off
+echo.
+makesis -v CRICTestEcomPlugin.pkg
+signsis.exe CRICTestEcomPlugin.sis CRICTestEcomPlugin.sisx rd.cer rd-key.pem
+set myPassWd=World123
+set certKeyName=WorldKey.key
+set certName=WorldCert.cer
+echo.
+echo.
+
+rem makekeys -cert -expdays 10000 -password %myPassWd% -len 2048 -dname "CN=Jeffrey Noone OU=Telecom OR=Digia Plc. C=FI EM=noone@nowhere.com" %certKeyName% %certName%
+rem signsis.exe CRICTestEcomPlugin.sis CRICTestEcomPlugin.sisx %certName% %certKeyName% %myPassWd%
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/src/CPbk2IconCustomApiTestPlugin.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,368 @@
+/*
+* Copyright (c) 2008-2009 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:
+*/
+
+// INCLUDE FILES
+#include <coemain.h>
+#include <gulicon.h>
+#include <e32math.h>
+#include <fbs.h>
+#include <cntdef.h>
+#include <e32property.h>
+
+#include <CCustomIconDecisionData.h>
+#include <CCustomIconIdMap.h>
+#include <MCustomIconChangeObserver.h>
+
+#include "CPbk2IconCustomApiTestPlugin.h"
+
+#if defined(__WINS__) || defined(WINS)
+_LIT( KIconFile, "Z:\\Data\\Test\\CustIconApiTestIcons.mbm" );
+#else
+_LIT( KIconFile, "C:\\Data\\Test\\CustIconApiTestIcons.mbm" );
+#endif
+
+// Publish/Subscribe category UID of used for configuring test environment.
+// See SetPsProperty() implementation.
+const TUint KStiffPsCategoryUid = 0x1000007A;
+const TUint KIconApiTestPSPropertyCategoryUID = KStiffPsCategoryUid;
+
+
+// Publish/Subscribe keys under KIconApiTestPSPropertyCategoryUID category.
+// Make sure these are same as in Pbk2IconCustomApiTestModule.cfg
+const TInt KPsKeyIconUpdaterEnabled = 1;
+const TInt KPsKeyIconUpdaterIntervalMs = 2;
+const TInt KPsKeyNotificationEventType = 3;
+const TInt KPsKeyNotificationEmptyUidArray = 4;
+
+
+// ----------------------------------------------------------------------------
+// GetPsTestProperty
+// Read property value from Publish/Subscribe subsystem.
+// The values are set by test module dll, contacts_dom\
+//      phonebook_2_contact_related_icon_customization_api\Internal\Test
+// and are meant to configure this plug-in at runtime.
+// ----------------------------------------------------------------------------
+//
+LOCAL_C TInt GetPsTestProperty( TInt aKey, TInt& aResult )
+    {
+    TInt value;
+    TInt err = RProperty::Get(
+        TUid::Uid( KIconApiTestPSPropertyCategoryUID ),
+        aKey,
+        value );
+    if( !err )
+        {
+        aResult = value;
+        }
+    return err;
+    }
+
+// ----------------------------------------------------------------------------
+// ValidateHintL
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void ValidateHintL( const CCustomIconDecisionData& aHint )
+    {
+    // At least one of the members should have been filled by the caller
+    if( aHint.ContactLinkRef() == NULL &&
+        aHint.PhoneNumber() == KNullDesC &&
+        aHint.Time() == NULL)
+        {
+        User::Leave( KErrArgument );
+        }
+
+    }
+
+// ----------------------------------------------------------------------------
+// AppendIconToMapL
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void AppendIconToMapL( const TDesC& aMbmFileName, TInt aMbmIndex,
+    TInt aId, CCustomIconIdMap* aIconMap )
+    {
+    CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
+    CleanupStack::PushL(bitmap);
+    User::LeaveIfError( bitmap->Load( aMbmFileName, aMbmIndex ) );
+    CGulIcon* icon = CGulIcon::NewL( bitmap ); // takes ownership of bitmap
+    CleanupStack::Pop( bitmap );
+    CleanupStack::PushL( icon );
+    aIconMap->AppendL( icon, aId );            // takes ownership of icon
+    CleanupStack::Pop( ); // icon
+    }
+
+// ----------------------------------------------------------------------------
+// ESMRHelper::LocateResourceFile
+// ----------------------------------------------------------------------------
+//
+LOCAL_C TInt LocateResourceFile(
+        const TDesC& aResource,
+        const TDesC& aPath,
+        TFileName &aResourceFile)
+    {
+    RFs* fsSession;
+
+    fsSession=&CCoeEnv::Static()->FsSession();//codescanner::eikonenvstatic
+
+    TFindFile resourceFile( *fsSession );
+    TInt err = resourceFile.FindByDir(
+            aResource,
+            aPath );
+
+    if ( KErrNone == err )
+        {
+        aResourceFile.Copy( resourceFile.File() );
+        }
+
+    return err;
+    }
+
+// ----------------------------------------------------------------------------
+// CPbk2IconCustomApiTestPlugin::NewL
+// ----------------------------------------------------------------------------
+//
+CPbk2IconCustomApiTestPlugin* CPbk2IconCustomApiTestPlugin::NewL()
+    {
+    CPbk2IconCustomApiTestPlugin* self =
+        new(ELeave)CPbk2IconCustomApiTestPlugin();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CPbk2IconCustomApiTestPlugin::CPbk2IconCustomApiTestPlugin
+// ----------------------------------------------------------------------------
+//
+CPbk2IconCustomApiTestPlugin::CPbk2IconCustomApiTestPlugin()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CPbk2IconCustomApiTestPlugin::~CPbk2IconCustomApiTestPlugin
+// ----------------------------------------------------------------------------
+//
+CPbk2IconCustomApiTestPlugin::~CPbk2IconCustomApiTestPlugin()
+    {
+    iObservers.Close();
+    delete iTimer;
+    }
+
+// ----------------------------------------------------------------------------
+// CPbk2IconCustomApiTestPlugin::ConstructL
+// ----------------------------------------------------------------------------
+//
+void CPbk2IconCustomApiTestPlugin::ConstructL()
+    {
+    TTime now;
+    now.HomeTime();
+    iSeed = now.Int64();
+
+    // If the test case has defined icon update property, initialize
+    // periodical timer for generating icon update events
+    TInt psResult( EFalse );
+    if( GetPsTestProperty( KPsKeyIconUpdaterEnabled, psResult ) == KErrNone &&
+        psResult )
+        {
+        if( GetPsTestProperty(
+            KPsKeyIconUpdaterIntervalMs, psResult ) == KErrNone )
+            {
+            iTimer = CPeriodic::NewL( CActive:: EPriorityStandard );
+            TInt tickIntevalMicroseconds = 1000 * psResult;
+            iTimer->Start( tickIntevalMicroseconds,
+                tickIntevalMicroseconds,
+                TCallBack( Tick, this) );
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CPbk2IconCustomApiTestPlugin::AddObserverL
+// ----------------------------------------------------------------------------
+//
+void CPbk2IconCustomApiTestPlugin::AddObserverL(
+    MCustomIconChangeObserver* aObserver )
+    {
+    iObservers.AppendL( aObserver );
+    // Test that observer interface returns NULL extension for NULL UID.
+    if( aObserver->IconChangeNotificationExtension( KNullUid ) )
+        {
+        User::Leave( KErrGeneral );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CPbk2IconCustomApiTestPlugin::RemoveObserver
+// ----------------------------------------------------------------------------
+//
+void CPbk2IconCustomApiTestPlugin::RemoveObserver(
+    MCustomIconChangeObserver* aObserver )
+    {
+    TInt index = iObservers.Find( aObserver );
+    if( index > 0 )
+        {
+        iObservers.Remove( index );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CPbk2IconCustomApiTestPlugin::IconsL
+// ----------------------------------------------------------------------------
+//
+CCustomIconIdMap* CPbk2IconCustomApiTestPlugin::IconsL(
+    TUid /*aContext*/,
+    TIconSizeHint /*aSizeHint*/ )
+    {
+
+    CCustomIconIdMap* iconMap = new( ELeave )CCustomIconIdMap( 2 );
+    CleanupStack::PushL( iconMap );
+    
+    AppendIconToMapL( KIconFile, 0, 653, iconMap );
+    AppendIconToMapL( KIconFile, 1, 145, iconMap );
+
+    CleanupStack::Pop( iconMap );
+    return iconMap;
+    }
+
+// ----------------------------------------------------------------------------
+// CPbk2IconCustomApiTestPlugin::IconChoiceL
+// ----------------------------------------------------------------------------
+//
+TBool CPbk2IconCustomApiTestPlugin::IconChoiceL(
+    const CCustomIconDecisionData& aHint, TInt& aIdResult )
+    {
+    ValidateHintL( aHint );
+    TInt random = Math::Rand( iSeed ) % 2;
+    if( random == 0)
+        {
+        aIdResult = 653;
+        }
+    else
+        {
+        aIdResult = 145;
+        }
+    return ETrue;
+    }
+
+// ----------------------------------------------------------------------------
+// CPbk2IconCustomApiTestPlugin::IconL
+// ----------------------------------------------------------------------------
+//
+CGulIcon* CPbk2IconCustomApiTestPlugin::IconL(
+    const CCustomIconDecisionData& aHint, TIconSizeHint /*aSizeHint*/ )
+    {
+    ValidateHintL( aHint );
+    CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
+    CleanupStack::PushL( bitmap );
+    TInt context = aHint.Context().iUid;
+    const TTime* time = aHint.Time();
+    // Icon depends on context param & time, here simply whether they
+    // has bee defined..
+    if( context || time )
+        {
+        User::LeaveIfError( bitmap->Load( KIconFile, 0 ) );
+        }
+    else
+        {
+        User::LeaveIfError( bitmap->Load( KIconFile, 1 ) );
+        }
+    CGulIcon* icon = CGulIcon::NewL( bitmap ); // takes ownership of bitmap
+    CleanupStack::Pop( bitmap );
+    return icon;
+    }
+
+// ----------------------------------------------------------------------------
+// CPbk2IconCustomApiTestPlugin::IconL
+// ----------------------------------------------------------------------------
+//
+CGulIcon* CPbk2IconCustomApiTestPlugin::IconL( TUid /*aContext*/,
+    TCustomIconId aIconId,
+    TIconSizeHint /*aSizeHint*/ )
+    {
+    TInt mbmIndex = KErrNotFound;
+    if( aIconId == 653 )
+        {
+        mbmIndex = 0;
+        }
+    else if( aIconId == 145 )
+        {
+        mbmIndex = 1;
+        }
+    CGulIcon* icon = NULL;
+    if( mbmIndex != KErrNotFound )
+        {
+        CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
+        CleanupStack::PushL( bitmap );
+        
+        User::LeaveIfError( bitmap->Load( KIconFile, 0 ) );
+        icon = CGulIcon::NewL( bitmap ); // takes ownership of bitmap
+        CleanupStack::Pop( bitmap );
+        }
+    return icon;
+    }
+
+// ----------------------------------------------------------------------------
+// CPbk2IconCustomApiTestPlugin::Tick
+// ----------------------------------------------------------------------------
+//
+TInt CPbk2IconCustomApiTestPlugin::Tick( TAny* aObject )
+    {
+    // cast, and call non-static function
+    TRAP_IGNORE(((CPbk2IconCustomApiTestPlugin*)aObject)->NotifyObserversL();)
+    return ETrue; // continue ticking
+    }
+
+// ----------------------------------------------------------------------------
+// CPbk2IconCustomApiTestPlugin::NotifyObserversL
+// ----------------------------------------------------------------------------
+//
+void CPbk2IconCustomApiTestPlugin::NotifyObserversL()
+    {
+    TInt i;
+    TInt count = iObservers.Count();
+    MCustomIconChangeObserver* observer;
+    for( i=0; i<count; i++ )
+        {
+        observer = iObservers[i];
+        if( observer )
+            {
+            // Setup notification parameters from the values defined by the
+            // Publish/Subscribe system (test case being the definer)
+            // If values not found, use default values
+            TInt eventType( MCustomIconChangeObserver::EIconsMajorChange );
+            TBool emptyArray( ETrue );
+            GetPsTestProperty( KPsKeyNotificationEventType, eventType );
+            GetPsTestProperty( KPsKeyNotificationEmptyUidArray, emptyArray );
+
+            RArray<TCustomIconId> array;
+            CleanupClosePushL( array );
+            if( !emptyArray )
+                {
+                array.AppendL( TCustomIconId( 653 ) );
+                array.AppendL( TCustomIconId( 145 ) );
+                }
+            observer->CustomIconEvent( *this,
+                (MCustomIconChangeObserver::TEventType)eventType,
+                array.Array() );
+
+            CleanupStack::PopAndDestroy( &array );
+            }
+        }
+    }
+
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/TestPlugin/src/CPbk2IconCustomApiTestPluginFactory.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2008-2009 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:
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <ecom\implementationproxy.h>
+
+#include "CPbk2IconCustomApiTestPlugin.h"
+
+
+// ----------------------------------------------------------------------------
+// ImplementationTable, from ECOM architecture
+// ----------------------------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY(
+        KCPbk2IconCustomApiTestPluginImplValue,
+        CPbk2IconCustomApiTestPlugin::NewL )
+    };
+
+
+// ----------------------------------------------------------------------------
+// ImplementationGroupProxy function, from ECOM architecture. Return ECOM
+// implementations, which are registered with the ECOM resource definition.
+// ----------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
+    TInt& aTableCount )
+    {
+    aTableCount =  sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    return ImplementationTable;
+    }
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/bwins/Pbk2IconCustomApiTestModuleu.def	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/data/Pbk2IconCustomApiTestModule.cfg	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,160 @@
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Pbk2IconCustomApiTestModule.cfg
+# phonebook_2_contact_related_icon_customization_api test script for STIF
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+[Define]
+
+EReallySmall 0
+ESmall       1
+EMedium      2
+EMediumLarge 3
+ELarge       4
+
+NULL 0
+
+EPsKeyIconUpdaterEnabled 1
+EPsKeyIconUpdaterIntervalMs 2
+EPsKeyNotificationEventType 3
+EPsKeyNotificationEmptyUidArray 4
+
+TEventType::EIconsMajorChange 0
+TEventType::EIconsUpdated 1
+TEventType::EIconsRemoved 2
+TEventType::EIconsAdded 3
+
+ETrue 1
+EFalse 0
+
+// Async signal completion codes
+KUpdateSignalReceived 1
+
+[Enddefine]
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# ModTest 001: Load icons
+#
+# 
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+[Test]
+title ModTest 001: Load icons
+create Pbk2IconCustomApiTestModule client
+client LoadTestPluginL
+client LoadIconsL EMedium
+client DeleteIconsL
+delete client
+[Endtest]
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# ModTest 002: Load icon
+#
+# 
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+[Test]
+title ModTest 002: Load icon
+create Pbk2IconCustomApiTestModule client
+client LoadTestPluginL
+client LoadIconL EMedium 0501234567
+client DeleteIconL
+delete client
+[Endtest]
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# ModTest 003: Verify icon match from array
+#
+# 
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+[Test]
+title ModTest 003: Verify icon match from array
+create Pbk2IconCustomApiTestModule client
+client LoadTestPluginL
+client LoadIconsL EMedium
+client IconChoiceL 0501234567
+client DeleteIconsL
+delete client
+[Endtest]
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# ModTest 004: Major change notification twice
+#
+# Setup plugin to periodically nofity of icon change, use default update params:
+#  - event type = EIconsMajorChange
+#  - icon id array is empty
+# Register test case as observer
+# Listen to notifications (twice)
+# 
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+[Test]
+title ModTest 004: Major change notification twice
+create Pbk2IconCustomApiTestModule client
+client SetPsProperty EPsKeyIconUpdaterEnabled ETrue
+client SetPsProperty EPsKeyIconUpdaterIntervalMs 500
+client LoadTestPluginL
+client SetTestCaseAsObserverL ETrue
+client LoadIconsL EMedium
+client IconChoiceL 0501234567
+allownextresult TEventType::EIconsMajorChange
+waittestclass client
+allownextresult TEventType::EIconsMajorChange
+waittestclass client
+client SetTestCaseAsObserverL EFalse
+client DeleteIconsL
+client DeletePsProperty EPsKeyIconUpdaterEnabled
+client DeletePsProperty EPsKeyIconUpdaterIntervalMs
+delete client
+[Endtest]
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# ModTest 005: Update notification with refresh icon call
+#
+# Setup plugin to periodically nofity of icon change with params
+#    - event type is EIconsUpdated
+#    - icon id array is not empty (i.e. plug-in generates an id list)
+# Register test case as observer
+# Listen to notification from plugin
+# Request plugin for a new updated icon
+# 
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+[Test]
+title ModTest 005: Update notification with refresh icon call
+create Pbk2IconCustomApiTestModule client
+client SetPsProperty EPsKeyIconUpdaterEnabled ETrue
+client SetPsProperty EPsKeyIconUpdaterIntervalMs 500
+client SetPsProperty EPsKeyNotificationEventType TEventType::EIconsUpdated
+client SetPsProperty EPsKeyNotificationEmptyUidArray EFalse
+client LoadTestPluginL
+client SetTestCaseAsObserverL ETrue
+client LoadIconsL EMedium
+client IconChoiceL 0501234567
+allownextresult TEventType::EIconsUpdated
+waittestclass client
+client SetTestCaseAsObserverL EFalse
+client UpdateIconsWithLastIconIdsL EMedium
+client DeleteIconsL
+client DeletePsProperty EPsKeyIconUpdaterEnabled
+client DeletePsProperty EPsKeyIconUpdaterIntervalMs
+delete client
+[Endtest]
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# ModTest 006: Verify extension interface functionality
+#
+# Setup plugin to periodically nofity of icon change with params
+#    - event type is EIconsUpdated
+#    - icon id array is not empty (i.e. plug-in generates an id list)
+# Register test case as observer
+# Listen to notification from plugin
+# Request plugin for a new updated icon
+# 
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+[Test]
+title ModTest 006: Verify extension interface functionality
+create Pbk2IconCustomApiTestModule client
+client LoadTestPluginL
+client CheckIfHasExtensionL NULL EFalse 
+delete client
+[Endtest]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/eabi/Pbk2IconCustomApiTestModuleu.def	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	_Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+	_ZTI24CIconCustomApiTestModule @ 2 NONAME ; #<TI>#
+	_ZTV24CIconCustomApiTestModule @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/group/Pbk2IconCustomApiTestModule.iby	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,24 @@
+/*
+* 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: 
+*
+*/
+#ifndef ICONCUSTOMAPITESTMODULE_IBY
+#define ICONCUSTOMAPITESTMODULE_IBY
+
+data = \epoc32\winscw\c\testframework\Pbk2IconCustomApiTestModule.cfg testframework\Pbk2IconCustomApiTestModule.cfg
+file = ABI_DIR\BUILD_DIR\Pbk2IconCustomApiTestModule.dll SHARED_LIB_DIR\Pbk2IconCustomApiTestModule.dll
+
+#endif // ICONCUSTOMAPITESTMODULE_IBY
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/group/Pbk2IconCustomApiTestModule.mmp	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2008-2009 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:
+*/
+
+#include <platform_paths.hrh>
+
+TARGET          Pbk2IconCustomApiTestModule.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x2001FDE4
+
+CAPABILITY      ALL -TCB
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ..\inc
+APP_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ..\src
+SOURCE          CIconCustomApiTestModule.cpp
+SOURCE          CIconCustomApiTestModuleBlocks.cpp
+
+LIBRARY         euser.lib
+LIBRARY         ecom.lib
+LIBRARY         fbscli.lib 
+LIBRARY         stiftestinterface.lib
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/group/bld.inf	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2008-2009 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:
+*/
+
+#include "..\TestPlugin\group\bld.inf"
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+PRJ_TESTEXPORTS
+
+PRJ_EXPORTS
+..\data\Pbk2IconCustomApiTestModule.cfg      \epoc32\winscw\c\TestFramework\Pbk2IconCustomApiTestModule.cfg
+Pbk2IconCustomApiTestModule.iby              \epoc32\rom\include\Pbk2IconCustomApiTestModule.iby
+
+PRJ_TESTMMPFILES
+
+PRJ_MMPFILES
+Pbk2IconCustomApiTestModule.mmp
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/inc/CIconCustomApiTestModule.h	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2008-2009 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:
+*/
+
+#ifndef CICONCUSTOMAPITESTMODULE_H
+#define CICONCUSTOMAPITESTMODULE_H
+
+//  INCLUDES
+#include <fbs.h>
+
+#include <StifLogger.h>
+#include <StifTestModule.h>
+#include <TestScripterInternal.h>
+#include <MCustomIconChangeObserver.h>
+
+// FORWARD DECLARATIONS
+class CContactCustomIconPluginBase;
+class CCustomIconIdMap;
+class CGulIcon;
+
+// CONSTANTS
+// Logging
+_LIT( KTestModuleLogPath, "\\logs\\testframework\\" );
+_LIT( KTestModuleLogFile, "IconCustomizationApiTest.log" );
+
+
+// CLASS DECLARATION
+
+/**
+*  CIconCustomApiTestModule test class for STIF Test Framework TestScripter.
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class CIconCustomApiTestModule : public CScriptBase,
+                                 public MCustomIconChangeObserver
+    {
+    public:  // Public construction and destruction
+
+        /**
+        * Two-phased constructor.
+        */
+        static CIconCustomApiTestModule* NewL( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CIconCustomApiTestModule();
+
+    public: // Functions from base CScriptBase
+
+        /**
+        * From CScriptBase Runs a script line.
+        * @since ?Series60_version
+        * @param aItem Script line containing method name and parameters
+        * @return Symbian OS error code
+        */
+        virtual TInt RunMethodL( CStifItemParser& aItem );
+
+    public: // Functions from MCustomIconChangeObserver
+
+        /**
+         * Icon change notification handler
+         */
+        void CustomIconEvent( CContactCustomIconPluginBase& aPlugin,
+            TEventType aEventType,
+            const TArray<TCustomIconId>& aIconIds );
+
+    private: // Private construction
+
+        /**
+        * C++ default constructor.
+        */
+        CIconCustomApiTestModule( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    private: // Test methods
+
+        TInt LoadTestPluginL( CStifItemParser& aItem );
+        TInt LoadIconsL( CStifItemParser& aItem );
+        TInt LoadIconL( CStifItemParser& aItem );
+        TInt UpdateIconsWithLastIconIdsL( CStifItemParser& aItem );
+        TInt DeleteIconsL( CStifItemParser& aItem );
+        TInt DeleteIconL( CStifItemParser& aItem );
+        TInt IconChoiceL( CStifItemParser& aItem );
+        TInt SetPsProperty( CStifItemParser& aItem );
+        TInt DeletePsProperty( CStifItemParser& aItem );
+        TInt SetTestCaseAsObserverL( CStifItemParser& aItem );
+        TInt CheckIfHasExtensionL( CStifItemParser& aItem );
+
+    private: // Helpers
+        void CleanupPsKeys();
+
+    private: // Members
+        CContactCustomIconPluginBase* iTestPlugin;
+        CCustomIconIdMap* iIcons;
+        CGulIcon* iIcon;
+        RFbsSession iFbsSession; // For CFbsBitmap loading/handling support in the plugin        
+        RArray<TInt> iPublishedPsKeys;
+        MCustomIconChangeObserver::TEventType iLastEventType;
+        RArray<TCustomIconId> iLastIconIds;
+    };
+
+#endif // CICONCUSTOMAPITESTMODULE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/src/CIconCustomApiTestModule.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2008-2009 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:
+*/
+
+// INCLUDE FILES
+#include <ecom\ecom.h>
+#include <StifTestInterface.h>
+#include <CContactCustomIconPluginBase.h>
+#include <CCustomIconIdMap.h>
+#include "CIconCustomApiTestModule.h"
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::CIconCustomApiTestModule
+// ----------------------------------------------------------------------------
+//
+CIconCustomApiTestModule::CIconCustomApiTestModule
+        ( CTestModuleIf& aTestModuleIf ):
+            CScriptBase( aTestModuleIf )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::ConstructL
+// ----------------------------------------------------------------------------
+//
+void CIconCustomApiTestModule::ConstructL()
+    {
+    User::LeaveIfError( iFbsSession.Connect() );    
+    iLog = CStifLogger::NewL( KTestModuleLogPath,
+                          KTestModuleLogFile,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile,
+                          EFalse );
+    }
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::NewL
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CIconCustomApiTestModule* CIconCustomApiTestModule::NewL(
+    CTestModuleIf& aTestModuleIf )
+    {
+    CIconCustomApiTestModule* self =
+        new (ELeave) CIconCustomApiTestModule( aTestModuleIf );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::~CIconCustomApiTestModule
+// ----------------------------------------------------------------------------
+//
+CIconCustomApiTestModule::~CIconCustomApiTestModule()
+    {
+    delete iTestPlugin;
+    delete iIcons;
+    delete iIcon;
+    delete iLog;
+
+    CleanupPsKeys();
+
+    iPublishedPsKeys.Close();
+    iLastIconIds.Close();
+
+    iFbsSession.Disconnect();
+    
+    REComSession::FinalClose(); // Just in case to unload plug-ins and free
+                                // ECom stuff
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS ========================
+
+// ----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+//          Backpointer to STIF Test Framework
+// ----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL( CTestModuleIf& aTestModuleIf )
+    {
+    return ( CScriptBase* ) CIconCustomApiTestModule::NewL( aTestModuleIf );
+    }
+
+//  End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contacts_plat/phonebook_2_contact_related_icon_customization_api/tsrc/src/CIconCustomApiTestModuleBlocks.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,516 @@
+/*
+* Copyright (c) 2008-2009 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:
+*/
+
+// INCLUDE FILES
+
+#include <ecom\ecom.h>
+#include <e32property.h>
+#include <e32cmn.h>
+
+#include <StifParser.h>
+#include <StifTestInterface.h>
+
+#include <CContactCustomIconPluginBase.h>
+#include <CCustomIconIdMap.h>
+#include <CCustomIconDecisionData.h>
+
+#include "CIconCustomApiTestModule.h"
+
+_LIT( KTestPluginDisplayName, "Custom Icon test plugin" );
+
+
+const TInt KExecutableUidIndex = 0;
+
+// -----------------------------------------------------------------------------
+// CleanUpEComInfoArray
+// CleanupStack support for RImplInfoPtrArray.
+// See LoadTestPluginL how it is used
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void CleanUpEComInfoArray( TAny* aInfoArray )
+    {
+    RImplInfoPtrArray* infoArray = (static_cast<RImplInfoPtrArray*>(aInfoArray));
+    infoArray->ResetAndDestroy();
+    infoArray->Close();
+    }
+
+// ----------------------------------------------------------------------------
+// ProcessSID
+// Figure out current process SID (this should be STIFF SID)
+// ----------------------------------------------------------------------------
+//
+LOCAL_C TUid ProcessSID()
+    {
+    RProcess process;
+    TUidType type = process.Type();
+    // current process SID (STIFF executable SID = 0x1000007A)
+    TUid uid = type[KExecutableUidIndex];
+    return uid;
+    }
+
+// -----------------------------------------------------------------------------
+// BuildDecisionDataLC
+// Utility to build decision data object.
+// See LoadTestPluginL how it is used
+// -----------------------------------------------------------------------------
+//
+LOCAL_C CCustomIconDecisionData* BuildDecisionDataLC(  CStifItemParser& aItem )
+    {
+    CCustomIconDecisionData* decisionData =
+        new ( ELeave ) CCustomIconDecisionData();
+    CleanupStack::PushL( decisionData );
+
+    TUid contextParam = ProcessSID();
+
+    TTime* time = new (ELeave) TTime;
+    decisionData->SetTime( time ); // ownership taken
+    time->UniversalTime();
+
+    TPtrC phoneNumber;
+    aItem.GetNextString( phoneNumber );
+    decisionData->SetPhoneNumberL( phoneNumber );
+
+    decisionData->SetContactLinkRef( NULL );
+    decisionData->SetContext( contextParam );
+
+    return decisionData;
+    }
+
+
+// ----------------------------------------------------------------------------
+// ReplaceIconL
+// Find an icon and replace it
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void ReplaceIconL( CCustomIconIdMap* aIcons,
+    CGulIcon* aIcon, TCustomIconId aIconId )
+    {
+    TInt i;
+    TInt count = aIcons->Count();
+    TInt err( KErrNotFound );
+    for( i=0; i<count; i++ )
+        {
+        TCustomIconIdMapItem& item( (*aIcons)[i] );
+        if( item.iId == aIconId )
+            {
+            // Change the icon
+            delete item.iIconPtr;
+            item.iIconPtr = aIcon;
+            err = KErrNone;
+            break;
+            }
+        }
+    User::LeaveIfError( err );
+    }
+
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::CleanupPsKeys
+// Remove all key definitions and/or values, which have been
+// defined/set by this test module.
+// ----------------------------------------------------------------------------
+//
+void CIconCustomApiTestModule::CleanupPsKeys()
+    {
+    TInt count = iPublishedPsKeys.Count();
+    TInt i;
+    TUid sid = ProcessSID();
+    for( i=0; i<count; i++ )
+        {
+        // Ignore return value, because key may not exist
+        RProperty::Delete( sid, iPublishedPsKeys[i] );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::RunMethodL
+// Run specified method. Contains also table of test methods and their names.
+// ----------------------------------------------------------------------------
+//
+TInt CIconCustomApiTestModule::RunMethodL(
+    CStifItemParser& aItem )
+    {
+
+    static TStifFunctionInfo const KFunctions[] =
+        {
+        ENTRY( "LoadTestPluginL", CIconCustomApiTestModule::LoadTestPluginL ),
+        ENTRY( "LoadIconsL", CIconCustomApiTestModule::LoadIconsL ),
+        ENTRY( "LoadIconL", CIconCustomApiTestModule::LoadIconL ),
+        ENTRY( "UpdateIconsWithLastIconIdsL", CIconCustomApiTestModule::UpdateIconsWithLastIconIdsL ),
+        ENTRY( "DeleteIconsL", CIconCustomApiTestModule::DeleteIconsL ),
+        ENTRY( "DeleteIconL", CIconCustomApiTestModule::DeleteIconL ),
+        ENTRY( "IconChoiceL", CIconCustomApiTestModule::IconChoiceL ),
+        ENTRY( "SetPsProperty", CIconCustomApiTestModule::SetPsProperty ),
+        ENTRY( "DeletePsProperty", CIconCustomApiTestModule::DeletePsProperty ),
+        ENTRY( "SetTestCaseAsObserverL", CIconCustomApiTestModule::SetTestCaseAsObserverL ),
+        ENTRY( "CheckIfHasExtensionL", CIconCustomApiTestModule::CheckIfHasExtensionL ),
+        };
+
+    const TInt count = sizeof( KFunctions ) /
+                        sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+    }
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::CustomIconsChangedL
+// Notification handler, called by plugin.
+// ----------------------------------------------------------------------------
+//
+void CIconCustomApiTestModule::CustomIconEvent(
+            CContactCustomIconPluginBase& /*aPlugin*/,
+            TEventType aEventType,
+            const TArray<TCustomIconId>& aIconIds)
+    {
+    iLastEventType = aEventType;
+    TInt signalCode( aEventType );
+
+    TRAPD( err,
+        iLastIconIds.Reset();
+        TInt i;
+        TInt count = aIconIds.Count();
+        for( i=0; i<count; i++ )
+            {
+            iLastIconIds.AppendL( aIconIds[i] );
+            }
+        );
+    if( err )
+        {
+        signalCode = err;
+        }
+    Signal( signalCode );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::LoadTestPluginL
+// ----------------------------------------------------------------------------
+//
+TInt CIconCustomApiTestModule::LoadTestPluginL( CStifItemParser& /*aItem*/ )
+    {
+    if( iTestPlugin )
+        {
+        return KErrAlreadyExists;
+        }
+
+    CContactCustomIconPluginBase* result = NULL;
+
+    RImplInfoPtrArray implementationInfoArray;
+    TCleanupItem cleanup( CleanUpEComInfoArray, &implementationInfoArray );
+    CleanupStack::PushL( cleanup );
+
+    TUid uid( KContactIconCustomizationInterfaceUid );
+
+    REComSession::ListImplementationsL( uid,
+        implementationInfoArray );
+
+    TInt count = implementationInfoArray.Count();
+
+    for( TInt i=0; i<count; i++)
+        {
+        CImplementationInformation* info = implementationInfoArray[i];
+        if( !(info->DisplayName().Compare( KTestPluginDisplayName ) == 0) )
+            {
+            continue;
+            }
+        // Test plugin was found. Try to load it.
+        TUid pluginUid = info->ImplementationUid();
+        TRAPD( err, result = static_cast<CContactCustomIconPluginBase*>
+            (REComSession::CreateImplementationL(pluginUid,
+                                            _FOFF(CContactCustomIconPluginBase,
+                                            iDtorKey)));
+            );
+        if( err )
+            {
+            result = NULL;
+            }
+        break;
+        }
+
+    CleanupStack::PopAndDestroy(&implementationInfoArray);
+
+    iTestPlugin = result;
+
+    if( !iTestPlugin )
+        {
+        return KErrNotFound;
+        }
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::LoadIconsL
+// Load icon array
+// ----------------------------------------------------------------------------
+//
+TInt CIconCustomApiTestModule::LoadIconsL( CStifItemParser& aItem )
+    {
+    User::LeaveIfNull( iTestPlugin );
+    if( iIcons )
+        {
+        User::Leave( KErrAlreadyExists );
+        }
+
+    TInt sizeHint( 0 );
+    aItem.GetNextInt( sizeHint );
+    iIcons = iTestPlugin->IconsL(
+        ProcessSID(), // use SID as context parameter
+        (CContactCustomIconPluginBase::TIconSizeHint)sizeHint );
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::LoadIconL
+// Load individual icon
+// ----------------------------------------------------------------------------
+//
+TInt CIconCustomApiTestModule::LoadIconL( CStifItemParser& aItem )
+    {
+    User::LeaveIfNull( iTestPlugin );
+    if( iIcon )
+        {
+        User::Leave( KErrAlreadyExists );
+        }
+    TInt sizeHint( 0 );
+    aItem.GetNextInt( sizeHint );
+
+    CCustomIconDecisionData* decisionData = BuildDecisionDataLC( aItem );
+
+    iIcon = iTestPlugin->IconL( *decisionData,
+        (CContactCustomIconPluginBase::TIconSizeHint)sizeHint );
+
+    CleanupStack::PopAndDestroy( decisionData );
+    return KErrNone;
+
+    }
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::UpdateIconsWithLastIconIdsL
+// Replace current icons with new ones
+// ----------------------------------------------------------------------------
+//
+TInt CIconCustomApiTestModule::UpdateIconsWithLastIconIdsL(
+    CStifItemParser& aItem )
+    {
+    User::LeaveIfNull( iTestPlugin );
+    if( !iIcons )
+        {
+        User::Leave( KErrNotFound );
+        }
+    TInt sizeHint( 0 );
+    aItem.GetNextInt( sizeHint );
+
+    TInt i;
+    TInt count = iLastIconIds.Count();
+    CGulIcon* icon;
+    TCustomIconId iconId;
+    TUid contextParam = ProcessSID(); // use process SID as context parameter
+    for( i=0; i<count; i++ )
+        {
+        iconId = iLastIconIds[i];
+        icon = iTestPlugin->IconL( contextParam,
+            iconId,
+            (CContactCustomIconPluginBase::TIconSizeHint)sizeHint );
+        CleanupStack::PushL( icon );
+        ReplaceIconL( iIcons, icon, iconId ); // Takes ownership
+        CleanupStack::Pop( icon );
+        }
+
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::DeleteIconsL
+// Delete icon array
+// ----------------------------------------------------------------------------
+//
+TInt CIconCustomApiTestModule::DeleteIconsL( CStifItemParser& /*aItem*/ )
+    {
+    if( !iIcons )
+        {
+        User::Leave( KErrNotFound );
+        }
+    delete iIcons;
+    iIcons = NULL;
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::DeleteIconL
+// Delete individual icon instance
+// ----------------------------------------------------------------------------
+//
+TInt CIconCustomApiTestModule::DeleteIconL( CStifItemParser& /*aItem*/ )
+    {
+    if( !iIcon )
+        {
+        User::Leave( KErrNotFound );
+        }
+    delete iIcon;
+    iIcon = NULL;
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::IconChoiceL
+// Query plug-in for a icon choice to the previously given icon array
+// Expect plug-in to provide a icon or otherwise fail
+// ----------------------------------------------------------------------------
+//
+TInt CIconCustomApiTestModule::IconChoiceL( CStifItemParser& aItem )
+    {
+    User::LeaveIfNull( iTestPlugin );
+    User::LeaveIfNull( iIcons );
+
+    CCustomIconDecisionData* decisionData = BuildDecisionDataLC( aItem );
+
+    TInt iconId( 0 );
+    TBool iconFound = iTestPlugin->IconChoiceL( *decisionData, iconId );
+    if( iconFound )
+        {
+        // Plug-in gave us an icon identifier. Now check if we have the
+        // corresponding icon.
+        CGulIcon* icon = NULL;
+        TCustomIconIdMapItem item;
+        for( TInt i=0; i<iIcons->Count(); i++ )
+            {
+            item = iIcons->At( i );
+            if( item.iId == iconId )
+                {
+                icon = item.iIconPtr; // may return NULL
+                break;
+                }
+            }
+        if( !icon )
+            {
+            // icon in the icon array was NULL, or
+            // icon was not found by given icon identifier
+            //
+            User::Leave( KErrNotFound );
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+    CleanupStack::PopAndDestroy( decisionData );
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CIconCustomApiTestModule::SetPsProperty
+// Define and set publish/subscribe property. This is used for configuring
+// testing environment. For example the test plug-in reads the P/S values
+// on its initialization phase.
+// ----------------------------------------------------------------------------
+//
+TInt CIconCustomApiTestModule::SetPsProperty( CStifItemParser& aItem )
+    {
+    TInt key;
+    TInt value;
+    aItem.GetNextInt( key );
+    aItem.GetNextInt( value );
+    TSecurityPolicy readwritePolicy( TSecurityPolicy::EAlwaysPass );
+
+    TUid sid = ProcessSID();
+    TInt err = RProperty::Define(
+        sid,
+        key,
+        RProperty::EInt,
+        readwritePolicy,
+        readwritePolicy );
+
+    if(err == KErrNone || err == KErrAlreadyExists)
+        {
+        iPublishedPsKeys.Append( key );
+        err = RProperty::Set( sid, key, value );
+        }
+    return err;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CIconCustomApiTestModule::DeletePsProperty
+//
+// -----------------------------------------------------------------------------
+//
+TInt CIconCustomApiTestModule::DeletePsProperty( CStifItemParser& aItem )
+    {
+    TInt key;
+    aItem.GetNextInt( key );
+    TInt err = RProperty::Delete( ProcessSID(), key );
+    if( !err )
+        {
+        TInt index = iPublishedPsKeys.Find ( key );
+        if( index >= 0 )
+            {
+            iPublishedPsKeys.Remove( index );
+            }
+        }
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CIconCustomApiTestModule::SetTestCaseAsObserver
+//
+// -----------------------------------------------------------------------------
+//
+TInt CIconCustomApiTestModule::SetTestCaseAsObserverL( CStifItemParser& aItem )
+    {
+    TBool setAsObserver;
+    aItem.GetNextInt( setAsObserver );
+    if( setAsObserver )
+        {
+        iTestPlugin->AddObserverL( this );
+        }
+    else
+        {
+        iTestPlugin->RemoveObserver( this );
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CIconCustomApiTestModule::CheckIfHasExtensionL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CIconCustomApiTestModule::CheckIfHasExtensionL( CStifItemParser& aItem )
+    {
+    TInt extensionUid;
+    TBool expectedResult;
+    User::LeaveIfError( aItem.GetNextInt( extensionUid ) );
+    User::LeaveIfError( aItem.GetNextInt( expectedResult ) );
+    TAny* extension =
+        iTestPlugin->ContactCustomIconExtension( TUid::Uid( extensionUid ) );
+    delete extension;
+    if( expectedResult && extension ||
+        !expectedResult && !extension )
+        {
+        return KErrNone;
+        }
+    else
+        {
+        return KErrGeneral;
+        }
+    }
+
+
+
+
+//  End of File
--- a/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/conf/PsClientTestSuite.cfg	Fri Mar 12 15:41:25 2010 +0200
+++ b/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/conf/PsClientTestSuite.cfg	Mon Mar 15 12:39:26 2010 +0200
@@ -8,26 +8,40 @@
 //#                                                                            #
 //# TC_ITU: Test Case for ITUT keyboard.                                       #
 //# TC_N97: Test Case for N97 3x11 keyboard.                                   #
+//# TC_N00: Test Case for XXX 4x10 keyboard. (Phone model name not known yet)  #
+//# TC_DEA: Test Case Deactivated. Use in comments only.                       #
 //#                                                                            #
 //# NOTES:                                                                     #
 //#                                                                            #
-//# - In the ITUT keyboard the "0" and the " " are on the same key.            #
-//#   Therefore if some clients deliver a "0" in Itut (or predictive) mode,    #
+//# - In ITUT keyboard "0" and " " are on the same key.                        #
+//#   Therefore if some clients deliver a "0" in Itut predictive mode,         #
 //#   then the "0" has the double nature of a "0" and of a " " (separator).    #
 //#                                                                            #
-//# - In the N97 3x11 keyboard the "0" and the " " are different keys.         #
-//#   Therefore if some clients deliver a "0" in Itut (or predictive) mode,    #
+//# - In N97-3x11 and N00-4x10 keyboards "0" and " " are on different keys.    #
+//#   Therefore if some clients deliver a "0" in Qwerty predictive mode,       #
 //#   then the "0" has the single nature of a "0" (not a separator).           #
 //#                                                                            #
-//# - The test driver for SearchOnInputString, TC_ITU_SearchOnInputString      #
-//#   and TC_N97_SearchOnInputString is identical.                             #
-//#   The naming is different in order to comment/uncomment the test cases     #
-//#   more easily.                                                             #
+//# - The SearchOnInputString and TC_<XXX>_SearchOnInputString test            #
+//#   drivers are identical. The naming is different in order to               #
+//#   comment/uncomment the test cases more easily.                            #
+//#   XXX = [ITU, N97, N00].                                                   #
+//#                                                                            #
+//# - The SearchLookupMatchString and TC_<XXX>_SearchLookupMatchString test    #
+//#   drivers are identical. The naming is different in order to               #
+//#   comment/uncomment the test cases more easily.                            #
+//#   XXX = [ITU, N97, N00].                                                   #
 //#                                                                            #
-//# - The test driver for TestSearchingInCache, TC_ITU_TestSearchingInCache    #
-//#   and TC_N97_TestSearchingInCache is identical.                            #
-//#   The naming is different in order to comment/uncomment the test cases     #
-//#   more easily.                                                             #
+//# - The TestSearchingInCache and TC_<XXX>_TestSearchingInCache test          #
+//#   drivers are identical. The naming is different in order to               #
+//#   comment/uncomment the test cases more easily.                            #
+//#   XXX = [ITU, N97, N00].                                                   #
+//#                                                                            #
+//# - The test:                                                                #
+//#       api TC_N<XX>_SearchOnInputString "IPSTR[Fake_Test]"                  #
+//#           "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]"              #
+//#           "MATCHLOC[0:1]"                                                  #
+//#   is a fake test that succeeds always. It can be used temporarily when for #
+//#   a certain keyboard there is not KeyMap available yet.                    #
 //#                                                                            #
 //##############################################################################
 
@@ -45,7 +59,7 @@
 title SU: Start Up the Server
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[6,EItut,EAlphaSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[6,EPredictiveItuT,EAlphaSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
@@ -182,116 +196,182 @@
 
 //******************************************************************************
 [Test]
-title IS: Single word (Itut)
+title IS: Single word (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_SearchOnInputString "IPSTR[Adam]" "SQ[23,EItut,EPatternSort,5]" "RES[1,(-1:AD)]" "MATCHLOC[0:2]"
-//api TC_N97_SearchOnInputString "IPSTR[Adam]" "SQ[@-,EItut,EPatternSort,5]" "RES[1,(-1:AD)]" "MATCHLOC[0:2]"
+api TC_ITU_SearchOnInputString "IPSTR[Adam]" "SQ[23,EPredictiveItuT,EPatternSort,5]" "RES[1,(-1:AD)]" "MATCHLOC[0:2]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title IS: Multi Search (Itut)
+title IS: Single word (Predictive QWERTY)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_SearchOnInputString "IPSTR[Adam Dory Dusk]" "SQ[20303,EItut,EPatternSort,5]" "RES[1,(-1:A,-1:D)]" "MATCHLOC[0:1,5:1,10:1]"
-//api TC_N97_SearchOnInputString "IPSTR[Adam Dory Dusk]" "SQ[@ D -,EItut,EPatternSort,5]" "RES[1,(-1:A,-1:D)]" "MATCHLOC[0:1,5:1,10:1]"
+//api TC_N97_SearchOnInputString "IPSTR[Adam]" "SQ[@-,EPredictiveQwerty,EPatternSort,5]" "RES[1,(-1:AD)]" "MATCHLOC[0:2]"
+//api TC_DEA_SearchOnInputString "IPSTR[Just]" "SQ[+7,EPredictiveQwerty,EPatternSort,5]" "RES[1,(-1:JU)]" "MATCHLOC[0:2]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title IS: Multi Search (Predictive ITU-T)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_SearchOnInputString "IPSTR[Adam Dory Dusk]" "SQ[20303,EPredictiveItuT,EPatternSort,5]" "RES[1,(-1:A,-1:D)]" "MATCHLOC[0:1,5:1,10:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title IS: Single word (Qwerty)
+title IS: Multi Search (Predictive QWERTY)
 create PsClientTestSuite api
 api WriteTitleToLog
-api SearchOnInputString "IPSTR[Hull]" "SQ[hu,EQwerty,EPatternSort,5]" "RES[1,(-1:HU)]" "MATCHLOC[0:2]"
+//api TC_N97_SearchOnInputString "IPSTR[Adam Dory Dusk]" "SQ[@ D -,EPredictiveQwerty,EPatternSort,5]" "RES[1,(-1:A,-1:D)]" "MATCHLOC[0:1,5:1,10:1]"
+//api TC_DEA_SearchOnInputString "IPSTR[Just Luke Last]" "SQ[+ L *,EPredictiveQwerty,EPatternSort,5]" "RES[1,(-1:J,-1:L)]" "MATCHLOC[0:1,5:1,10:1]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title IS: Single word (Non-predictive)
+create PsClientTestSuite api
+api WriteTitleToLog
+api SearchOnInputString "IPSTR[Hull]" "SQ[hu,ENonPredictive,EPatternSort,5]" "RES[1,(-1:HU)]" "MATCHLOC[0:2]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title IS: Multi Search (Qwerty)
+title IS: Multi Search (Non-predictive)
 create PsClientTestSuite api
 api WriteTitleToLog
-api SearchOnInputString "IPSTR[Gill Monk]" "SQ[m g,EQwerty,EAlphaSort,5]" "RES[1,(-1:G,-1:M)]" "MATCHLOC[0:1,5:1]"
+api SearchOnInputString "IPSTR[Gill Monk]" "SQ[m g,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:G,-1:M)]" "MATCHLOC[0:1,5:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title IS: Single word (Mixed)
+title IS: Single word (Mixed ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_SearchOnInputString "IPSTR[Xen]" "SQ[9e,iq,EPatternSort,5]" "RES[1,(-1:XE)]" "MATCHLOC[0:2]"
-//api TC_N97_SearchOnInputString "IPSTR[Xen]" "SQ[)e,iq,EPatternSort,5]" "RES[1,(-1:XE)]" "MATCHLOC[0:2]"
+api TC_ITU_SearchOnInputString "IPSTR[Xen]" "SQ[9e,in,EPatternSort,5]" "RES[1,(-1:XE)]" "MATCHLOC[0:2]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title IS: Single word (Mixed QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_SearchOnInputString "IPSTR[Xen]" "SQ[)e,qn,EPatternSort,5]" "RES[1,(-1:XE)]" "MATCHLOC[0:2]"
+//api TC_DEA_SearchOnInputString "IPSTR[Hen]" "SQ[-e,qn,EPatternSort,5]" "RES[1,(-1:HE)]" "MATCHLOC[0:2]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title IS: Multi Search (Mixed)
+title IS: Multi Search (Mixed ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_SearchOnInputString "IPSTR[Tim Monk]" "SQ[80m6,iiqi,EAlphaSort,5]" "RES[1,(-1:MO,-1:T)]" "MATCHLOC[0:1,4:2]"
-//api TC_N97_SearchOnInputString "IPSTR[Tim Monk]" "SQ[5 m9,iiqi,EAlphaSort,5]" "RES[1,(-1:MO,-1:T)]" "MATCHLOC[0:1,4:2]"
+api TC_ITU_SearchOnInputString "IPSTR[Tim Monk]" "SQ[80m6,iini,EAlphaSort,5]" "RES[1,(-1:MO,-1:T)]" "MATCHLOC[0:1,4:2]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title IS: Single word (Itut) -> No result
+title IS: Multi Search (Mixed QWERTY)
 create PsClientTestSuite api
 api WriteTitleToLog
-api SearchOnInputString "IPSTR[Adam]" "SQ[93,EItut,EPatternSort,5]" "RES[0,]" "MATCHLOC[]"
+//api TC_N97_SearchOnInputString "IPSTR[Tim Monk]" "SQ[5 m9,qqnq,EAlphaSort,5]" "RES[1,(-1:MO,-1:T)]" "MATCHLOC[0:1,4:2]"
+//api TC_DEA_SearchOnInputString "IPSTR[Tim Monk]" "SQ[5 m9,qqnq,EAlphaSort,5]" "RES[1,(-1:MO,-1:T)]" "MATCHLOC[0:1,4:2]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title IS: Single word (Predictive ITU-T) -> No result
+create PsClientTestSuite api
+api WriteTitleToLog
+api SearchOnInputString "IPSTR[Adam]" "SQ[93,EPredictiveItuT,EPatternSort,5]" "RES[0,]" "MATCHLOC[]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title IS: Multi Search (Predictive ITU-T) -> Partial match (1)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_SearchOnInputString "IPSTR[Adam Dory Dusk]" "SQ[202,EPredictiveItuT,EAlphaSort,5]" "RES[1,(-1:A)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title IS: Multi Search (Itut) -> Partial match (1)
+title IS: Multi Search (Predictive QWERTY) -> Partial match (1)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_SearchOnInputString "IPSTR[Adam Dory Dusk]" "SQ[202,EItut,EAlphaSort,5]" "RES[1,(-1:A)]" "MATCHLOC[0:1]"
-//api TC_N97_SearchOnInputString "IPSTR[Adam Dory Dusk]" "SQ[@ @,EItut,EAlphaSort,5]" "RES[1,(-1:A)]" "MATCHLOC[0:1]"
+//api TC_N97_SearchOnInputString "IPSTR[Adam Dory Dusk]" "SQ[@ @,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(-1:A)]" "MATCHLOC[0:1]"
+//api TC_DEA_SearchOnInputString "IPSTR[Just Luke Last]" "SQ[+ +,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(-1:J)]" "MATCHLOC[0:1]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title IS: Multi Search (Predictive ITU-T) -> Partial match (2)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_SearchOnInputString "IPSTR[Tim Monk]" "SQ[808,EPredictiveItuT,EAlphaSort,5]" "RES[1,(-1:T)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title IS: Multi Search (Itut) -> Partial match (2)
+title IS: Multi Search (Predictive QWERTY) -> Partial match (2)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_SearchOnInputString "IPSTR[Tim Monk]" "SQ[808,EItut,EAlphaSort,5]" "RES[1,(-1:T)]" "MATCHLOC[0:1]"
-//api TC_N97_SearchOnInputString "IPSTR[Tim Monk]" "SQ[5 5,EItut,EAlphaSort,5]" "RES[1,(-1:T)]" "MATCHLOC[0:1]"
+//api TC_N97_SearchOnInputString "IPSTR[Tim Monk]" "SQ[5 5,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(-1:T)]" "MATCHLOC[0:1]"
+//api TC_DEA_SearchOnInputString "IPSTR[Tim Monk]" "SQ[5 5,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(-1:T)]" "MATCHLOC[0:1]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title IS: Empty String (Itut) -> No result
+title IS: Empty String (Predictive ITU-T) -> No result
 create PsClientTestSuite api
 api WriteTitleToLog
-api SearchOnInputString "IPSTR[]" "SQ[23,EItut,EPatternSort,5]" "RES[0,]" "MATCHLOC[]"
+api SearchOnInputString "IPSTR[]" "SQ[23,EPredictiveItuT,EPatternSort,5]" "RES[0,]" "MATCHLOC[]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title IS: Only spaces string (Itut)- No result
+title IS: Only spaces string (Predictive ITU-T)- No result
 create PsClientTestSuite api
 api WriteTitleToLog
-api SearchOnInputString "IPSTR[   ]" "SQ[23,EItut,EPatternSort,5]" "RES[0,]" "MATCHLOC[]"
+api SearchOnInputString "IPSTR[   ]" "SQ[23,EPredictiveItuT,EPatternSort,5]" "RES[0,]" "MATCHLOC[]"
 delete api
 [Endtest]
 
@@ -302,51 +382,101 @@
 
 //******************************************************************************
 [Test]
-title LM: Trivial
+title LM: Trivial (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_SearchLookupMatchString "IPSTR[Abc Bc 123 c]" "SQ[222022,EItut,EPatternSort,5]" "RESSTR[Abc Bc]"
-//api TC_N97_SearchLookupMatchString "IPSTR[Aa@ @A 123 a]" "SQ[aaa aa,EItut,EPatternSort,5]" "RESSTR[Aa@ @A]"
+api TC_ITU_SearchLookupMatchString "IPSTR[Abc Bc 123 c]" "SQ[222022,EPredictiveItuT,EPatternSort,5]" "RESSTR[Abc Bc]"
 delete api
 [Endtest]
 
 //******************************************************************************
 [Test]
-title LM: Single backtrack
+title LM: Trivial (Predictive QWERTY)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_SearchLookupMatchString "IPSTR[Abc Bc 123 c]" "SQ[220222,EItut,EPatternSort,5]" "RESSTR[Bc Abc]"
-//api TC_N97_SearchLookupMatchString "IPSTR[Aa@ @A 123 a]" "SQ[aa aaa,EItut,EPatternSort,5]" "RESSTR[@A Aa@]"
+//api TC_N97_SearchLookupMatchString "IPSTR[Aa@ @A 123 a]" "SQ[aaa aa,EPredictiveQwerty,EPatternSort,5]" "RESSTR[Aa@ @A]"
+//api TC_DEA_SearchLookupMatchString "IPSTR[Ll* *L 123 l]" "SQ[lll ll,EPredictiveQwerty,EPatternSort,5]" "RESSTR[Ll* *L]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+//******************************************************************************
+[Test]
+title LM: Single backtrack (Predictive ITU-T)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_SearchLookupMatchString "IPSTR[Abc Bc 123 c]" "SQ[220222,EPredictiveItuT,EPatternSort,5]" "RESSTR[Bc Abc]"
+delete api
+[Endtest]
+
+//******************************************************************************
+[Test]
+title LM: Single backtrack (Predictive QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_SearchLookupMatchString "IPSTR[Aa@ @A 123 a]" "SQ[aa aaa,EPredictiveQwerty,EPatternSort,5]" "RESSTR[@A Aa@]"
+//api TC_DEA_SearchLookupMatchString "IPSTR[Ll* *L 123 l]" "SQ[ll lll,EPredictiveQwerty,EPatternSort,5]" "RESSTR[*L Ll*]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 //******************************************************************************
 [Test]
-title LM: Double backtrack
+title LM: Double backtrack (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_SearchLookupMatchString "IPSTR[Abc Bc 123 c]" "SQ[20220222,EItut,EPatternSort,5]" "RESSTR[c Bc Abc]"
-//api TC_N97_SearchLookupMatchString "IPSTR[Aa@ @A 123 a]" "SQ[a aa aaa,EItut,EPatternSort,5]" "RESSTR[a @A Aa@]"
+api TC_ITU_SearchLookupMatchString "IPSTR[Abc Bc 123 c]" "SQ[20220222,EPredictiveItuT,EPatternSort,5]" "RESSTR[c Bc Abc]"
+delete api
+[Endtest]
+
+//******************************************************************************
+[Test]
+title LM: Double backtrack (Predictive QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_SearchLookupMatchString "IPSTR[Aa@ @A 123 a]" "SQ[a aa aaa,EPredictiveQwerty,EPatternSort,5]" "RESSTR[a @A Aa@]"
+//api TC_DEA_SearchLookupMatchString   "IPSTR[Ll* *L 123 l]" "SQ[l ll lll,EPredictiveQwerty,EPatternSort,5]" "RESSTR[l *L Ll*]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 //******************************************************************************
 [Test]
-title LM: Spaces in query and in result
+title LM: Spaces in query and in result (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_SearchLookupMatchString "IPSTR[Abc Bc 123 c]" "SQ[ 22 1 2 ,EItut,EPatternSort,5]" "RESSTR[ Ab 1 B ]"
-//api TC_N97_SearchLookupMatchString "IPSTR[Aa@ @A 123 a]" "SQ[ aa q a ,EItut,EPatternSort,5]" "RESSTR[ Aa 1 @ ]"
+api TC_ITU_SearchLookupMatchString "IPSTR[Abc Bc 123 c]" "SQ[ 22 1 2 ,EPredictiveItuT,EPatternSort,5]" "RESSTR[ Ab 1 B ]"
 delete api
 [Endtest]
 
 //******************************************************************************
 [Test]
-title LM: Not matched
+title LM: Spaces in query and in result (Predictive QWERTY)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_SearchLookupMatchString "IPSTR[Abc Bc 123 c]" "SQ[2222,EItut,EPatternSort,5]" "RESSTR[]"
-//api TC_N97_SearchLookupMatchString "IPSTR[Aa@ @A 123 a]" "SQ[aaaa,EItut,EPatternSort,5]" "RESSTR[]"
+//api TC_N97_SearchLookupMatchString "IPSTR[Aa@ @A 123 a]" "SQ[ aa q a ,EPredictiveQwerty,EPatternSort,5]" "RESSTR[ Aa 1 @ ]"
+//api TC_DEA_SearchLookupMatchString "IPSTR[Ll* *L 123 l]" "SQ[ ll q l ,EPredictiveQwerty,EPatternSort,5]" "RESSTR[ Ll 1 * ]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+//******************************************************************************
+[Test]
+title LM: Not matched (Predictive ITU-T)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_SearchLookupMatchString "IPSTR[Abc Bc 123 c]" "SQ[2222,EPredictiveItuT,EPatternSort,5]" "RESSTR[]"
+delete api
+[Endtest]
+
+//******************************************************************************
+[Test]
+title LM: Not matched (Predictive QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_SearchLookupMatchString "IPSTR[Aa@ @A 123 a]" "SQ[aaaa,EPredictiveQwerty,EPatternSort,5]" "RESSTR[]"
+//api TC_DEA_SearchLookupMatchString "IPSTR[Ll* *L 123 l]" "SQ[llll,EPredictiveQwerty,EPatternSort,5]" "RESSTR[]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
@@ -382,485 +512,787 @@
 
 //******************************************************************************
 [Test]
-title CS: Search by FirstName (Itut)
+title CS: Search by FirstName (Predictive Default)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[624374,EItut,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[!@H3/#,EItut,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+// 5.0: 3x11 Qwerty is default keyboard for N97
+// 9.2: ITU-T is default keyboard if physical keyboard is not present
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[!@H3/#,EPredictiveDefaultKeyboard,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[)aH3s-,EPredictiveDefaultKeyboard,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+api TC_N00_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[624374,EPredictiveDefaultKeyboard,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search by FirstName (Predictive ITU-T)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[624374,EPredictiveItuT,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search by FirstName (Predictive QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[!@H3/#,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[)aH3s-,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search by FirstName (Qwerty)
+title CS: Search by FirstName (Non-predictive)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[mahesh,EQwerty,EPatternSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[mahesh,ENonPredictive,EPatternSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search by FirstName (Mixed)
+title CS: Search by FirstName (Mixed Default)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[62h3,iiqi,EPatternSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[!@h3,iiqi,EPatternSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+// 5.0: 3x11 Qwerty is default keyboard for N97
+// 9.2: ITU-T is default keyboard if physical keyboard is not present
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[!@h3,ddnd,EPatternSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[)ah3,ddnd,EPatternSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+api TC_N00_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[62h3,ddnd,EPatternSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search by LastName (Itut)
+title CS: Search by FirstName (Mixed ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[3672479,EItut,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[-94@8/2,EItut,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[62h3,iini,EPatternSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search by FirstName (Mixed QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[!@h3,qqnq,EPatternSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[)ah3,qqnq,EPatternSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search by LastName (Qwerty)
+title CS: Search by FirstName (Predictive ITU-T and QWERTY) - Double Keyboard
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[doraiswamy,EQwerty,EPatternSort,8]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[!2H37#,qiqiiq,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[)2H37-,qiqiiq,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
-//****************************************************************************
+//******************************************************************************
 [Test]
-title CS: Search by LastName (Mixed)
+title CS: Search by LastName (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[ve558,qqiii,EAlphaSort,5]" "RES[1,(FN:ravi kiran,LN:velkud,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[ve:;7,qqiii,EAlphaSort,5]" "RES[1,(FN:ravi kiran,LN:velkud,CN:Nokia)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[3672479,EPredictiveItuT,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search by LastName (Predictive QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[-94@8/2,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[d94a8s2,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search by CompanyName (Itut)
+title CS: Search by LastName (Non-predictive)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[doraiswamy,ENonPredictive,EPatternSort,8]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+//****************************************************************************
+[Test]
+title CS: Search by LastName (Mixed ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[66867,EItut,EAlphaSort,5]" "RES[1,(FN:chiru,LN:devi,CN:motorola)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[!9594,EItut,EAlphaSort,5]" "RES[1,(FN:chiru,LN:devi,CN:motorola)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[ve558,nniii,EAlphaSort,5]" "RES[1,(FN:ravi kiran,LN:velkud,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+[Test]
+title CS: Search by LastName (Mixed QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[ve:;7,nnqqq,EAlphaSort,5]" "RES[1,(FN:ravi kiran,LN:velkud,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[ve*#7,nnqqq,EAlphaSort,5]" "RES[1,(FN:ravi kiran,LN:velkud,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search by CompanyName (Qwerty)
+title CS: Search by CompanyName (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[motor,EQwerty,EPatternSort,8]" "RES[1,(FN:chiru,LN:devi,CN:motorola)]"
-delete api
-[Endtest]
-
-
-//****************************************************************************
-[Test]
-title CS: Search by CompanyName (Mixed)
-create PsClientTestSuite api
-api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[mo867,qqiii,EAlphaSort,5]" "RES[1,(FN:chiru,LN:devi,CN:motorola)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[mo594,qqiii,EAlphaSort,5]" "RES[1,(FN:chiru,LN:devi,CN:motorola)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[66867,EPredictiveItuT,EAlphaSort,5]" "RES[1,(FN:chiru,LN:devi,CN:motorola)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multiple words contact (Itut)
+title CS: Search by CompanyName (Predictive QWERTY)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5472,EItut,EPatternSort,5]" "RES[1,(FN:ravi kiran,LN:velkud,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[;84@,EItut,EPatternSort,5]" "RES[1,(FN:ravi kiran,LN:velkud,CN:Nokia)]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[!9594,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:chiru,LN:devi,CN:motorola)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[)9594,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:chiru,LN:devi,CN:motorola)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multiple (very many) words contact (Itut)
+title CS: Search by CompanyName (Non-predictive)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[motor,ENonPredictive,EPatternSort,8]" "RES[1,(FN:chiru,LN:devi,CN:motorola)]"
+delete api
+[Endtest]
+
+
+//****************************************************************************
+[Test]
+title CS: Search by CompanyName (Mixed ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[529,EItut,EAlphaSort,5]" "RES[1,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[*@6,EItut,EAlphaSort,5]" "RES[1,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[mo867,nniii,EAlphaSort,5]" "RES[1,(FN:chiru,LN:devi,CN:motorola)]"
+delete api
+[Endtest]
+
+
+//****************************************************************************
+[Test]
+title CS: Search by CompanyName (Mixed QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[mo594,nnqqq,EAlphaSort,5]" "RES[1,(FN:chiru,LN:devi,CN:motorola)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[mo594,nnqqq,EAlphaSort,5]" "RES[1,(FN:chiru,LN:devi,CN:motorola)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multiple words contact with same initials (Itut)
+title CS: Multiple words contact (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5727,EItut,EPatternSort,5]" "RES[1,(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[:0%/,EItut,EPatternSort,5]" "RES[1,(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5472,EPredictiveItuT,EPatternSort,5]" "RES[1,(FN:ravi kiran,LN:velkud,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multiple words contact with same initials (Qwerty)
+title CS: Multiple words contact (Predictive QWERTY)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[lpcs,EQwerty,EAlphaSort,5]" "RES[1,(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[;84@,EPredictiveQwerty,EPatternSort,5]" "RES[1,(FN:ravi kiran,LN:velkud,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[#84a,EPredictiveQwerty,EPatternSort,5]" "RES[1,(FN:ravi kiran,LN:velkud,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multiple (very many) words contact (Predictive ITU-T)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[529,EPredictiveItuT,EAlphaSort,5]" "RES[1,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multiple words contact with same initials (Mixed)
+title CS: Multiple (very many) words contact (Predictive QWERTY)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[l7c7,qiqi,EPatternSort,5]" "RES[1,(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[l0c/,qiqi,EPatternSort,5]" "RES[1,(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[*@6,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+a6,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Itut)
+title CS: Multiple words contact with same initials (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[44055,EItut,EAlphaSort,5]" "RES[1,(FN:ghi,LN:jkl,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[=# *;,EItut,EAlphaSort,5]" "RES[1,(FN:ghi,LN:jkl,CN:Nokia)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5727,EPredictiveItuT,EPatternSort,5]" "RES[1,(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multiple words contact with same initials (Predictive QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[:0%/,EPredictiveQwerty,EPatternSort,5]" "RES[1,(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[*0cs,EPredictiveQwerty,EPatternSort,5]" "RES[1,(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Itut) - Space as sep
+title CS: Multiple words contact with same initials (Non-predictive)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[8 56,EItut,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5 *9,EItut,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[lpcs,ENonPredictive,EAlphaSort,5]" "RES[1,(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multiple words contact with same initials (Mixed ITU-T)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[l7c7,nini,EPatternSort,5]" "RES[1,(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Itut) - 0 as sep
+title CS: Multiple words contact with same initials (Mixed QWERTY)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[8056,EItut,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[50*9,EItut,EAlphaSort,5]" "RES[0,]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[l0c/,nqnq,EPatternSort,5]" "RES[1,(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[l0cs,nqnq,EPatternSort,5]" "RES[1,(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Itut) - 0 and space as sep
+title CS: Multi Search (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[80 56,EItut,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[50 *9,EItut,EAlphaSort,5]" "RES[0,]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[44055,EPredictiveItuT,EAlphaSort,5]" "RES[1,(FN:ghi,LN:jkl,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multi Search (Predictive QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[=# *;,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:ghi,LN:jkl,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[G- +#,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:ghi,LN:jkl,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Qwerty) - Space as sep
+title CS: Multi Search (Predictive ITU-T) - Space as sep
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j t,EQwerty,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[8 56,EPredictiveItuT,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multi Search (Predictive QWERTY) - Space as sep
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5 *9,EPredictiveQwerty,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5 +9,EPredictiveQwerty,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Qwerty) - 0 as NON sep (Qwerty 0)
+title CS: Multi Search (Predictive ITU-T) - 0 as sep
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j0t,EQwerty,EAlphaSort,5]" "RES[0,]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j0t,EQwerty,EAlphaSort,5]" "RES[0,]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[8056,EPredictiveItuT,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Mixed) mode - Space as sep
+title CS: Multi Search (Predictive QWERTY) - 0 as sep
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j6 8i,qiqiq,EPatternSort,5]" "RES[1,(FN:Tim,LN:Jones,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j9 5i,qiqiq,EPatternSort,5]" "RES[1,(FN:Tim,LN:Jones,CN:Nokia)]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[50*9,EPredictiveQwerty,EAlphaSort,5]" "RES[0,]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[50+9,EPredictiveQwerty,EAlphaSort,5]" "RES[0,]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Mixed) - 0 as sep
+title CS: Multi Search (Predictive ITU-T) - 0 and space as sep
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j608i,qiiiq,EAlphaSort,5]" "RES[1,(FN:Tim,LN:Jones,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j905i,qiiiq,EAlphaSort,5]" "RES[0,]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[80 56,EPredictiveItuT,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multi Search (Predictive QWERTY) - 0 and space as sep
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[50 *9,EPredictiveQwerty,EAlphaSort,5]" "RES[0,]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[50 +9,EPredictiveQwerty,EAlphaSort,5]" "RES[0,]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Mixed) - 0 as NON sep (Qwerty 0)
+title CS: Multi Search (Non-predictive) - Space as sep
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j608i,qiqiq,EAlphaSort,5]" "RES[0,]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j905i,qiqiq,EAlphaSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j t,ENonPredictive,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Mixed) - 0 and space as sep
+title CS: Multi Search (Non-predictive) - 0 as NON sep (Qwerty 0)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j60 8i,qiiiiq,EAlphaSort,5]" "RES[1,(FN:Tim,LN:Jones,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j90 5i,qiiiiq,EAlphaSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j0t,ENonPredictive,EAlphaSort,5]" "RES[0,]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multi Search (Mixed ITU-T) - Space as sep
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j6 8i,ninin,EPatternSort,5]" "RES[1,(FN:Tim,LN:Jones,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Itut) -> more than one result
+title CS: Multi Search (Mixed QWERTY) - Space as sep
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[807,EItut,EPatternSort,5]" "RES[2,(FN:ravi kiran,LN:velkud,CN:Nokia)(FN:mno,LN:pqr TheGr,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[& 4,EItut,EPatternSort,5]" "RES[2,(FN:ravi kiran,LN:velkud,CN:Nokia)(FN:4four,LN:&ampli,CN:Nokia)]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j9 5i,nqnqn,EPatternSort,5]" "RES[1,(FN:Tim,LN:Jones,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j9 5i,nqnqn,EPatternSort,5]" "RES[1,(FN:Tim,LN:Jones,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multi Search (Mixed ITU-T) - 0 as sep
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j608i,niiin,EAlphaSort,5]" "RES[1,(FN:Tim,LN:Jones,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search Contact starting with + (Itut)
+title CS: Multi Search (Mixed QWERTY) - 0 as sep
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+25536,EItut,EAlphaSort,5]" "RES[1,(FN:+allen,LN:good,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+@::3?,EItut,EAlphaSort,5]" "RES[1,(FN:+allen,LN:good,CN:Nokia)]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j905i,nqqqn,EAlphaSort,5]" "RES[0,]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j905i,nqqqn,EAlphaSort,5]" "RES[0,]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search contact starting with + (Qwerty)
+title CS: Multi Search (Mixed ITU-T) - 0 as NON sep (Qwerty 0)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+allen,EQwerty,EPatternSort,5]" "RES[1,(FN:+allen,LN:good,CN:Nokia)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j608i,ninin,EAlphaSort,5]" "RES[0,]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multi Search (Mixed QWERTY) - 0 as NON sep (Qwerty 0)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j905i,nqnqn,EAlphaSort,5]" "RES[0,]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j905i,nqnqn,EAlphaSort,5]" "RES[0,]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search with + (Itut)
+title CS: Multi Search (Mixed ITU-T) - 0 and space as sep
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+0+,EItut,EAlphaSort,5]" "RES[1,(FN:@ravi four,LN:!belkud five)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+ +,EItut,EAlphaSort,5]" "RES[1,(FN:@ravi four,LN:!belkud five)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j60 8i,niiiin,EAlphaSort,5]" "RES[1,(FN:Tim,LN:Jones,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Itut) -> No result
+title CS: Multi Search (Mixed QWERTY) - 0 and space as sep
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[209,EItut,EAlphaSort,5]" "RES[0,]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j90 5i,nqqqqn,EAlphaSort,5]" "RES[0,]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[j90 5i,nqqqqn,EAlphaSort,5]" "RES[0,]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multi Search (Predictive ITU-T) -> more than one result
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[807,EPredictiveItuT,EPatternSort,5]" "RES[2,(FN:ravi kiran,LN:velkud,CN:Nokia)(FN:mno,LN:pqr TheGr,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multi Search (Predictive QWERTY) -> more than one result
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[& 4,EPredictiveQwerty,EPatternSort,5]" "RES[2,(FN:ravi kiran,LN:velkud,CN:Nokia)(FN:4four,LN:&ampli,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[( 4,EPredictiveQwerty,EPatternSort,5]" "RES[2,(FN:ravi kiran,LN:velkud,CN:Nokia)(FN:4four,LN:&ampli,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Itut) - Query with more than 2 words
+title CS: Search Contact starting with + (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[805606,EItut,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5 *9 ?,EItut,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+25536,EPredictiveItuT,EAlphaSort,5]" "RES[1,(FN:+allen,LN:good,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search Contact starting with + (Predictive QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+@::3?,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:+allen,LN:good,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+a**3(,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:+allen,LN:good,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search (Itut) -> No result
+title CS: Search contact starting with + (Non-predictive)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[42423262374,EItut,EAlphaSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+allen,ENonPredictive,EPatternSort,5]" "RES[1,(FN:+allen,LN:good,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search (Qwerty) -> No result
+title CS: Multi Search with + (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[deepakrsrs,EQwerty,EPatternSort,5]" "RES[0,]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+0+,EPredictiveItuT,EAlphaSort,5]" "RES[1,(FN:@ravi four,LN:!belkud five)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search (Mixed) -> No result
+title CS: Multi Search with + (Predictive QWERTY)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[dee789srs,qqqiiiqqq,EAlphaSort,5]" "RES[0,]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+ +,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:@ravi four,LN:!belkud five)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+ 5,EPredictiveQwerty,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multi Search (Predictive ITU-T) -> No result
+create PsClientTestSuite api
+api WriteTitleToLog
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[209,EPredictiveItuT,EAlphaSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Itut) -> No result
+title CS: Multi Search (Predictive ITU-T) - Query with more than 2 words
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[4242 3262374,EItut,EPatternSort,5]" "RES[0,]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[805606,EPredictiveItuT,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Qwerty) -> No result
+title CS: Multi Search (Predictive QWERTY) - Query with more than 2 words
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[deepa krsrs,EQwerty,EAlphaSort,5]" "RES[0,]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5 *9 ?,EPredictiveQwerty,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5 +9 (,EPredictiveQwerty,EAlphaSort,5]" "RES[2,(FN:Tim,LN:Jones,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search (Predictive ITU-T) -> No result
+create PsClientTestSuite api
+api WriteTitleToLog
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[42423262374,EPredictiveItuT,EAlphaSort,5]" "RES[0,]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search (Non-predictive) -> No result
+create PsClientTestSuite api
+api WriteTitleToLog
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[deepakrsrs,ENonPredictive,EPatternSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Mixed) -> No result
+title CS: Search (Mixed ITU-T) -> No result
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[dee78 9srs,qqqiiiiqqq,EPatternSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[dee789srs,nnniiinnn,EAlphaSort,5]" "RES[0,]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multi Search (Predictive ITU-T) -> No result
+create PsClientTestSuite api
+api WriteTitleToLog
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[4242 3262374,EPredictiveItuT,EPatternSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Wrong URI (Itut) -> No result
+title CS: Multi Search (Non-predictive) -> No result
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:Wronguricontacts.cdb]" "SQ[5,EItut,EAlphaSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[deepa krsrs,ENonPredictive,EAlphaSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Wrong URI (Itut) -> No result
+title CS: Multi Search (Mixed ITU-T) -> No result
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:Wronguricontacts.cdb]" "SQ[t,EQwerty,EAlphaSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[dee78 9srs,nnniiiinnn,EPatternSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Wrong URI (Mixed) -> No result
+title CS: Wrong URI (Predictive ITU-T) -> No result
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:Wronguricontacts.cdb]" "SQ[dee7809srs,qqqiiiiqqq,EPatternSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:Wronguricontacts.cdb]" "SQ[5,EPredictiveItuT,EAlphaSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Filter Display Fields (Itut)
+title CS: Wrong URI (Non-predictive) -> No result
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "DISP[28]" "SQ[624374,EItut,EPatternSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:Wronguricontacts.cdb]" "SQ[t,ENonPredictive,EAlphaSort,5]" "RES[0,]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Wrong URI (Mixed ITU-T) -> No result
+create PsClientTestSuite api
+api WriteTitleToLog
+api TestSearchingInCache "URI[cntdb:\/\/c:Wronguricontacts.cdb]" "SQ[dee7809srs,nnniiiinnn,EPatternSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Filter Display Fields (Qwerty)
+title CS: Filter Display Fields (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "DISP[28]" "SQ[mahesh,EQwerty,EPatternSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "DISP[28]" "SQ[624374,EPredictiveItuT,EPatternSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Filter Display Fields (Mixed)
+title CS: Filter Display Fields (Non-predictive)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "DISP[28]" "SQ[ma43sh,qqiiqq,EPatternSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "DISP[28]" "SQ[mahesh,ENonPredictive,EPatternSort,5]" "RES[0,]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Filter Display Fields (Mixed ITU-T)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "DISP[28]" "SQ[ma43sh,nniinn,EPatternSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Qwerty) - Filter Display Fields
+title CS: Multi Search (Non-predictive) - Filter Display Fields
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "DISP[28]" "SQ[ravi velkud,EQwerty,EAlphaSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "DISP[28]" "SQ[ravi velkud,ENonPredictive,EAlphaSort,5]" "RES[0,]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Groups Search (Predictive ITU-T)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb]" "SQ[8434768,EPredictiveItuT,EPatternSort,5]" "RES[1,(FN:TheGroup)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Groups Search (Itut)
+title CS: Groups Search (Predictive QWERTY)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb]" "SQ[8434768,EItut,EPatternSort,5]" "RES[1,(FN:TheGroup)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb]" "SQ[5#3=497,EItut,EPatternSort,5]" "RES[1,(FN:TheGroup)]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb]" "SQ[5#3=497,EPredictiveQwerty,EPatternSort,5]" "RES[1,(FN:TheGroup)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb]" "SQ[5-3G497,EPredictiveQwerty,EPatternSort,5]" "RES[1,(FN:TheGroup)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Groups Search (Qwerty)
+title CS: Groups Search (Non-predictive)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb]" "SQ[TheGrou,EQwerty,EPatternSort,5]" "RES[1,(FN:TheGroup)]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb]" "SQ[TheGrou,ENonPredictive,EPatternSort,5]" "RES[1,(FN:TheGroup)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Groups Search (Mixed)
+title CS: Groups Search (Mixed ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb]" "SQ[843g7o8,iiiqiqi,EAlphaSort,5]" "RES[1,(FN:TheGroup)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb]" "SQ[5#3g4o7,iiiqiqi,EAlphaSort,5]" "RES[1,(FN:TheGroup)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb]" "SQ[843g7o8,iiinini,EAlphaSort,5]" "RES[1,(FN:TheGroup)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Groups Search (Mixed QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb]" "SQ[5#3g4o7,qqqnqnq,EAlphaSort,5]" "RES[1,(FN:TheGroup)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb]" "SQ[5-3g4o7,qqqnqnq,EAlphaSort,5]" "RES[1,(FN:TheGroup)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
@@ -870,7 +1302,7 @@
 title CS: Search in more than one group -> No result
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb?id=3221,cntdb:\/\/c:contacts.gdb?id=1132]" "SQ[624374,EItut,EPatternSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb?id=3221,cntdb:\/\/c:contacts.gdb?id=1132]" "SQ[624374,EPredictiveItuT,EPatternSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
@@ -880,18 +1312,39 @@
 title CS: Search in non-existing group ID -> No result
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb?id=3221]" "SQ[624374,EItut,EPatternSort,5]" "RES[0,]"
+api TestSearchingInCache "URI[cntdb:\/\/c:contacts.gdb?id=3221]" "SQ[624374,EPredictiveItuT,EPatternSort,5]" "RES[0,]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Multi Search (Predictive ITU-T) Scandinavian chars - space as sep 
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[Ä78 Ö,EPredictiveItuT,EAlphaSort,5]" "RES[1,(FN:Ästrid,LN:Öhlm,CN:Åppres)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Multi Search (Itut) Scandinavian chars - space as sep 
+title CS: Multi Search (Predictive QWERTY) Scandinavian chars - space as sep 
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[Ä78 Ö,EItut,EAlphaSort,5]" "RES[1,(FN:Ästrid,LN:Öhlm,CN:Åppres)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[Ä/5 Ö,EItut,EAlphaSort,5]" "RES[1,(FN:Ästrid,LN:Öhlm,CN:Åppres)]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[Ä/5 Ö,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:Ästrid,LN:Öhlm,CN:Åppres)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[ÄS5 Ö,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:Ästrid,LN:Öhlm,CN:Åppres)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search special chars - Pattern Sort
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[1,EPredictiveItuT,EPatternSort,5]" "RES[4,(FN:@ravi four,LN:!belkud five)(FN:yz,LN:123,CN:Nokia)(FN:+allen,LN:good,CN:Nokia)(FN:4four,LN:&ampli,CN:Nokia)]"
 delete api
 [Endtest]
 
@@ -902,63 +1355,120 @@
 create PsClientTestSuite api
 api WriteTitleToLog
 // The following test is not really applicable test for non-ITUT keyboard
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[1,EItut,EPatternSort,5]" "RES[4,(FN:@ravi four,LN:!belkud five)(FN:yz,LN:123,CN:Nokia)(FN:+allen,LN:good,CN:Nokia)(FN:4four,LN:&ampli,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[! @,EItut,EPatternSort,5]" "RES[1,(FN:@ravi four,LN:!belkud five)]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[! @,EPredictiveQwerty,EPatternSort,5]" "RES[1,(FN:@ravi four,LN:!belkud five)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[! @,EPredictiveQwerty,EPatternSort,5]" "RES[1,(FN:@ravi four,LN:!belkud five)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search special chars (Predictive ITU-T) - Alpha Sort
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[1,EPredictiveItuT,EAlphaSort,5]" "RES[4,(FN:yz,LN:123,CN:Nokia)(FN:@ravi four,LN:!belkud five)(FN:+allen,LN:good,CN:Nokia)(FN:4four,LN:&ampli,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search special chars - Alpha Sort
+title CS: Search special chars (Predictive QWERTY) - Alpha Sort
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[1,EItut,EAlphaSort,5]" "RES[4,(FN:yz,LN:123,CN:Nokia)(FN:@ravi four,LN:!belkud five)(FN:+allen,LN:good,CN:Nokia)(FN:4four,LN:&ampli,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[! @,EItut,EAlphaSort,5]" "RES[1,(FN:@ravi four,LN:!belkud five)]"
+// The following test is not really applicable test for non-ITUT keyboard
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[! @,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:@ravi four,LN:!belkud five)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[! @,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:@ravi four,LN:!belkud five)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search contact starting with 0 (Predictive ITU-T)
+create PsClientTestSuite api
+api WriteTitleToLog
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[0642,EPredictiveItuT,EAlphaSort,5]" "RES[1,(FN:0Nick,LN:0Jack,CN:0Sam)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search contact starting with 0 (Predictive QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[0?8%,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:0Nick,LN:0Jack,CN:0Sam)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[0(8c,EPredictiveQwerty,EAlphaSort,5]" "RES[1,(FN:0Nick,LN:0Jack,CN:0Sam)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search contact starting with 0
+title CS: Search in multiple data stores (Predictive ITU-T)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[0642,EItut,EAlphaSort,5]" "RES[1,(FN:0Nick,LN:0Jack,CN:0Sam)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[0?8%,EItut,EAlphaSort,5]" "RES[1,(FN:0Nick,LN:0Jack,CN:0Sam)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb,cntdb:\/\/c:contacts.gdb]" "SQ[8434,EPredictiveItuT,EAlphaSort,5]" "RES[2,(FN:TheGroup)(FN:mno,LN:pqr TheGr,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search in multiple data stores (Predictive QWERTY)
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb,cntdb:\/\/c:contacts.gdb]" "SQ[5#3=,EPredictiveQwerty,EAlphaSort,5]" "RES[2,(FN:TheGroup)(FN:mno,LN:pqr TheGr,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb,cntdb:\/\/c:contacts.gdb]" "SQ[5-3G,EPredictiveQwerty,EAlphaSort,5]" "RES[2,(FN:TheGroup)(FN:mno,LN:pqr TheGr,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search in multiple data stores
+title CS: Search (Predictive ITU-T) - Alpha Sort -> Truncate result
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb,cntdb:\/\/c:contacts.gdb]" "SQ[8434,EItut,EAlphaSort,5]" "RES[2,(FN:TheGroup)(FN:mno,LN:pqr TheGr,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb,cntdb:\/\/c:contacts.gdb]" "SQ[5#3=,EItut,EAlphaSort,5]" "RES[2,(FN:TheGroup)(FN:mno,LN:pqr TheGr,CN:Nokia)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5,EPredictiveItuT,EAlphaSort,3]" "RES[3,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)(FN:ghi,LN:jkl,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search (Itut) - Alpha Sort -> Truncate result
+title CS: Search (Predictive QWERTY) - Alpha Sort -> Truncate result
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5,EItut,EAlphaSort,3]" "RES[3,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)(FN:ghi,LN:jkl,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[*,EItut,EAlphaSort,3]" "RES[3,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)(FN:ghi,LN:jkl,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[*,EPredictiveQwerty,EAlphaSort,3]" "RES[3,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)(FN:ghi,LN:jkl,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+,EPredictiveQwerty,EAlphaSort,3]" "RES[3,(FN:+allen,LN:good,CN:Nokia)(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)(FN:ghi,LN:jkl,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title CS: Search (Itut) - Pattern Sort -> Truncate result
+title CS: Search (Predictive ITU-T) - Pattern Sort -> Truncate result
 create PsClientTestSuite api
 api WriteTitleToLog
-api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5,EItut,EPatternSort,3]" "RES[3,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)(FN:ghi,LN:jkl,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
-//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[*,EItut,EPatternSort,3]" "RES[3,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)(FN:ghi,LN:jkl,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+api TC_ITU_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[5,EPredictiveItuT,EPatternSort,3]" "RES[3,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)(FN:ghi,LN:jkl,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+delete api
+[Endtest]
+
+
+//******************************************************************************
+[Test]
+title CS: Search (Predictive QWERTY) - Pattern Sort -> Truncate result
+create PsClientTestSuite api
+api WriteTitleToLog
+//api TC_N97_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[*,EPredictiveQwerty,EPatternSort,3]" "RES[3,(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)(FN:ghi,LN:jkl,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)]"
+//api TC_DEA_TestSearchingInCache "URI[cntdb:\/\/c:contacts.cdb]" "SQ[+,EPredictiveQwerty,EPatternSort,3]" "RES[3,(FN:+allen,LN:good,CN:Nokia)(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)(FN:ghi,LN:jkl,CN:Nokia)]"
+api TC_N00_SearchOnInputString "IPSTR[Fake_Test]" "SQ[F,ENonPredictive,EAlphaSort,5]" "RES[1,(-1:F)]" "MATCHLOC[0:1]"
 delete api
 [Endtest]
 
@@ -968,7 +1478,7 @@
 title Cancel search 
 create PsClientTestSuite api
 api WriteTitleToLog
-api CancelSearch "URI[cntdb:\/\/c:contacts.cdb]" "SQ[624374,EItut,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
+api CancelSearch "URI[cntdb:\/\/c:contacts.cdb]" "SQ[624374,EPredictiveItuT,EAlphaSort,5]" "RES[1,(FN:mahesh,LN:doraiswamy,CN:Nokia)]"
 delete api
 [Endtest]
 
@@ -980,10 +1490,10 @@
 
 //******************************************************************************
 [Test]
-title GS: Search FirstName in group (Qwerty)
+title GS: Search FirstName in group (Non-predictive)
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingWithInGroup "SrchInGroup[TheGroup]" "SQ[abc,EQwerty,EAlphaSort,5]" "RES[1,(FN:abc,LN:def,CN:Nokia)]"
+api TestSearchingWithInGroup "SrchInGroup[TheGroup]" "SQ[abc,ENonPredictive,EAlphaSort,5]" "RES[1,(FN:abc,LN:def,CN:Nokia)]"
 delete api
 [Endtest]
 
@@ -993,17 +1503,17 @@
 title GS: Search in group - Empty Query
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingWithInGroup "SrchInGroup[TheGroup]" "SQ[,EQwerty,EAlphaSort,5]" "RES[3,(FN:abc,LN:def,CN:Nokia)(FN:ghi,LN:jkl,CN:Nokia)(FN:mno,LN:pqr TheGr,CN:Nokia)]"
+api TestSearchingWithInGroup "SrchInGroup[TheGroup]" "SQ[,ENonPredictive,EAlphaSort,5]" "RES[3,(FN:abc,LN:def,CN:Nokia)(FN:ghi,LN:jkl,CN:Nokia)(FN:mno,LN:pqr TheGr,CN:Nokia)]"
 delete api
 [Endtest]
 
 
 //******************************************************************************
 [Test]
-title GS: Search in group (Qwerty) - Empty Query -> No result
+title GS: Search in group (Non-predictive) - Empty Query -> No result
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingWithInGroup "SrchInGroup[TheGroup]" "SQ[afdsbc,EQwerty,EPatternSort,5]" "RES[0,]"
+api TestSearchingWithInGroup "SrchInGroup[TheGroup]" "SQ[afdsbc,ENonPredictive,EPatternSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
@@ -1013,7 +1523,7 @@
 title GS: Search in non-existing group
 create PsClientTestSuite api
 api WriteTitleToLog
-api TestSearchingWithInGroup "SrchInGroup[TheNonExistantGroup]" "SQ[abc,EQwerty,EAlphaSort,5]" "RES[0,]"
+api TestSearchingWithInGroup "SrchInGroup[TheNonExistantGroup]" "SQ[abc,ENonPredictive,EAlphaSort,5]" "RES[0,]"
 delete api
 [Endtest]
 
@@ -1058,7 +1568,7 @@
 title Mi: Marked contacts
 create PsClientTestSuite api
 api WriteTitleToLog
-api AddMarkedContactsTest "URI[cntdb:\/\/c:contacts.cdb]" "SQ[624374,EItut,EAlphaSort,25]" "RES[19,(FN:Pcs,LN:,CN:)(FN:0Nick,LN:0Jack,CN:0Sam)(FN:yz,LN:123,CN:Nokia)(FN:@ravi four,LN:!belkud five)(FN:4four,LN:&ampli,CN:Nokia)(FN:abc,LN:def,CN:Nokia)(FN:chiru,LN:devi,CN:motorola)(FN:mahesh,LN:doraiswamy,CN:Nokia)(FN:+allen,LN:good,CN:Nokia)(FN:ghi,LN:jkl,CN:Nokia)(FN:Tim,LN:Jones,CN:Nokia)(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)(FN:a0r,LN:pqr,CN:Nokia)(FN:mno,LN:pqr TheGr,CN:Nokia)(FN:M0hn,LN:Time,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)(FN:ravi kiran,LN:velkud,CN:Nokia)(FN:Ästrid,LN:Öhlm,CN:Åppres)]"
+api AddMarkedContactsTest "URI[cntdb:\/\/c:contacts.cdb]" "SQ[624374,EPredictiveItuT,EAlphaSort,25]" "RES[19,(FN:Pcs,LN:,CN:)(FN:0Nick,LN:0Jack,CN:0Sam)(FN:yz,LN:123,CN:Nokia)(FN:@ravi four,LN:!belkud five)(FN:4four,LN:&ampli,CN:Nokia)(FN:abc,LN:def,CN:Nokia)(FN:chiru,LN:devi,CN:motorola)(FN:mahesh,LN:doraiswamy,CN:Nokia)(FN:+allen,LN:good,CN:Nokia)(FN:ghi,LN:jkl,CN:Nokia)(FN:Tim,LN:Jones,CN:Nokia)(FN:a b c d e f g Jay,LN:L Gee,CN:Nokia India)(FN:Lpcsillet,LN:Lpcsucy,CN:Lpcsush)(FN:a0r,LN:pqr,CN:Nokia)(FN:mno,LN:pqr TheGr,CN:Nokia)(FN:M0hn,LN:Time,CN:Nokia)(FN:John,LN:Tom,CN:Nokia)(FN:ravi kiran,LN:velkud,CN:Nokia)(FN:Ästrid,LN:Öhlm,CN:Åppres)]"
 delete api
 [Endtest]
 
--- a/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/inc/psclienttestsuitedefs.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/inc/psclienttestsuitedefs.h	Mon Mar 15 12:39:26 2010 +0200
@@ -40,15 +40,26 @@
  * parameters in the psclientapitest.cfg file. 
  */
  
- // Keyboard modes
-_LIT(KItut,        "EItut");
-_LIT(KQwerty,      "EQwerty");
+// Keyboard modes for query
+_LIT(KItut,                      "EItut");   // Deprecated
+_LIT(KQwerty,                    "EQwerty"); // Deprecated
+_LIT(KPredictiveItuT,            "EPredictiveItuT");
+_LIT(KPredictiveQwerty,          "EPredictiveQwerty");
+_LIT(KPredictiveDefaultKeyboard, "EPredictiveDefaultKeyboard");
+_LIT(KNonPredictive,             "ENonPredictive");
+_LIT(KWrongKeyboardMode,         "EWrongKeyBoardMode");
+
+// Keyboard modes for query-item
+_LIT(KPredictiveItuTCode,        "i");
+_LIT(KPredictiveQwertyCode,      "q");
+_LIT(KPredictiveDefaultCode,     "d");
+_LIT(KNonPredictiveCode,         "n");
+
+// Sort Modes
 _LIT(KPatternSort, "EPatternSort");
 _LIT(KAlphaSort,   "EAlphaSort");
 
-_LIT(KWrongKeyboardMode, "EWrongKeyBoardMode");
-
-//True/False
+// True/False
 _LIT(KTrue,  "ETrue");
 _LIT(KFalse, "EFalse");
 
--- a/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/PsClientTestSuite.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/PsClientTestSuite.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -44,6 +44,11 @@
 //
 void CPsClientTestSuite::ConstructL()
 {
+    // Local timer for block fetch delay. This is created as first step to 
+    // ensure that the handle is valid in destructor, even if some other
+    // step of construction fails and leaves.
+    iTimer.CreateLocal();
+
     //Read logger settings to check whether test case name is to be
     //appended to log file name.
     RSettingServer settingServer;
@@ -91,9 +96,6 @@
     iPsClientHandler = CPSRequestHandler::NewL();
     iPsClientHandler->AddObserverL(this); 
 	iCurrentOperation = EDefaultCase;
-	
-	// Local timer for block fetch delay
-    iTimer.CreateLocal();
 }
 
 // -----------------------------------------------------------------------------
--- a/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/PsClientTestSuiteBlocks.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/PsClientTestSuiteBlocks.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -55,33 +55,36 @@
         // First string is the function name used in TestScripter script file.
         // Second is the actual implementation member function.
 
-        ENTRY( "WriteTitleToLog",              CPsClientTestSuite::WriteTitleToLog ),
-        ENTRY( "CreateContactsInPhone",        CPsClientTestSuite::CreateContactsL ),
-	    ENTRY( "ADDGroups",                    CPsClientTestSuite::CreateGroupsInPhoneL ),
-	    ENTRY( "DeleteAllContactsInPhonebook", CPsClientTestSuite::DeleteAllContactsInPhonebookL ),
-        ENTRY( "SearchOnInputString",          CPsClientTestSuite::SearchOnInputStringL ),
-        ENTRY( "TC_ITU_SearchOnInputString",   CPsClientTestSuite::SearchOnInputStringL ), // For easy handling of .cgf file
-        ENTRY( "TC_N97_SearchOnInputString",   CPsClientTestSuite::SearchOnInputStringL ), // For easy handling of .cgf file
-        ENTRY( "SearchLookupMatchString",      CPsClientTestSuite::SearchLookupMatchStringL ),
-        ENTRY( "TC_ITU_SearchLookupMatchString",CPsClientTestSuite::SearchLookupMatchStringL ), // For easy handling of .cgf file
-        ENTRY( "TC_N97_SearchLookupMatchString",CPsClientTestSuite::SearchLookupMatchStringL ), // For easy handling of .cgf file
-        ENTRY( "TestSearchingInCache",         CPsClientTestSuite::SearchCacheL ),
-        ENTRY( "TC_ITU_TestSearchingInCache",  CPsClientTestSuite::SearchCacheL ), // For easy handling of .cgf file
-        ENTRY( "TC_N97_TestSearchingInCache",  CPsClientTestSuite::SearchCacheL ), // For easy handling of .cgf file
-	    ENTRY( "CheckCachingStatus",           CPsClientTestSuite::CheckCachingStatusL ),
-	    ENTRY( "CheckVersion",                 CPsClientTestSuite::CheckVersion),
-	    ENTRY( "CheckLanguageSupport",         CPsClientTestSuite::TestIsLanguageSupportedL),
-	    ENTRY( "GetAllContents",               CPsClientTestSuite::GetAllContentsL),
-	    ENTRY( "TestSortOrder",                CPsClientTestSuite::TestSortOrderL),
-	    ENTRY( "TestSortOrderErrCaseL",        CPsClientTestSuite::TestSortOrderErrCaseL),	    
-	    ENTRY( "TestSearchingWithInGroup",     CPsClientTestSuite::SearchWithInGroupL),
-	    ENTRY( "ConvertToVpbkLink",            CPsClientTestSuite::ConvertToVpbkLinkL), 
-	    ENTRY( "RemoveObserver",               CPsClientTestSuite::RemoveObserverL ),
-	    ENTRY( "ShutDown",                     CPsClientTestSuite::ShutDownL ),
-	    ENTRY( "AddMarkedContactsTest",        CPsClientTestSuite::AddMarkedContactsTestL ),
-	    ENTRY( "TestDataOrder",                CPsClientTestSuite::TestDataOrderL ),
-	    ENTRY( "TestDataOrderForErrL",         CPsClientTestSuite::TestDataOrderForErrL ),
-	    ENTRY( "CancelSearch",                 CPsClientTestSuite::CancelSearchL )
+        ENTRY( "WriteTitleToLog",                CPsClientTestSuite::WriteTitleToLog ),
+        ENTRY( "CreateContactsInPhone",          CPsClientTestSuite::CreateContactsL ),
+	    ENTRY( "ADDGroups",                      CPsClientTestSuite::CreateGroupsInPhoneL ),
+	    ENTRY( "DeleteAllContactsInPhonebook",   CPsClientTestSuite::DeleteAllContactsInPhonebookL ),
+        ENTRY( "SearchOnInputString",            CPsClientTestSuite::SearchOnInputStringL ),
+        ENTRY( "TC_ITU_SearchOnInputString",     CPsClientTestSuite::SearchOnInputStringL ), // For easy handling of .cgf file
+        ENTRY( "TC_N97_SearchOnInputString",     CPsClientTestSuite::SearchOnInputStringL ), // For easy handling of .cgf file
+        ENTRY( "TC_N00_SearchOnInputString",     CPsClientTestSuite::SearchOnInputStringL ), // For easy handling of .cgf file
+        ENTRY( "SearchLookupMatchString",        CPsClientTestSuite::SearchLookupMatchStringL ),
+        ENTRY( "TC_ITU_SearchLookupMatchString", CPsClientTestSuite::SearchLookupMatchStringL ), // For easy handling of .cgf file
+        ENTRY( "TC_N97_SearchLookupMatchString", CPsClientTestSuite::SearchLookupMatchStringL ), // For easy handling of .cgf file
+        ENTRY( "TC_N00_SearchLookupMatchString", CPsClientTestSuite::SearchLookupMatchStringL ), // For easy handling of .cgf file
+        ENTRY( "TestSearchingInCache",           CPsClientTestSuite::SearchCacheL ),
+        ENTRY( "TC_ITU_TestSearchingInCache",    CPsClientTestSuite::SearchCacheL ), // For easy handling of .cgf file
+        ENTRY( "TC_N97_TestSearchingInCache",    CPsClientTestSuite::SearchCacheL ), // For easy handling of .cgf file
+        ENTRY( "TC_N00_TestSearchingInCache",    CPsClientTestSuite::SearchCacheL ), // For easy handling of .cgf file
+	    ENTRY( "CheckCachingStatus",             CPsClientTestSuite::CheckCachingStatusL ),
+	    ENTRY( "CheckVersion",                   CPsClientTestSuite::CheckVersion),
+	    ENTRY( "CheckLanguageSupport",           CPsClientTestSuite::TestIsLanguageSupportedL),
+	    ENTRY( "GetAllContents",                 CPsClientTestSuite::GetAllContentsL),
+	    ENTRY( "TestSortOrder",                  CPsClientTestSuite::TestSortOrderL),
+	    ENTRY( "TestSortOrderErrCaseL",          CPsClientTestSuite::TestSortOrderErrCaseL),	    
+	    ENTRY( "TestSearchingWithInGroup",       CPsClientTestSuite::SearchWithInGroupL),
+	    ENTRY( "ConvertToVpbkLink",              CPsClientTestSuite::ConvertToVpbkLinkL), 
+	    ENTRY( "RemoveObserver",                 CPsClientTestSuite::RemoveObserverL ),
+	    ENTRY( "ShutDown",                       CPsClientTestSuite::ShutDownL ),
+	    ENTRY( "AddMarkedContactsTest",          CPsClientTestSuite::AddMarkedContactsTestL ),
+	    ENTRY( "TestDataOrder",                  CPsClientTestSuite::TestDataOrderL ),
+	    ENTRY( "TestDataOrderForErrL",           CPsClientTestSuite::TestDataOrderForErrL ),
+	    ENTRY( "CancelSearch",                   CPsClientTestSuite::CancelSearchL )
         };
 
     const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo );
--- a/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/TestSuiteInputData.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/TestSuiteInputData.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -615,32 +615,59 @@
 	TKeyboardModes keyboardMode = EModeUndefined;
 
     // Check the keyboard mode
-	if(iKeyboardModeBuf->Des().Compare(KItut) == 0)
+	if(iKeyboardModeBuf->Compare(KItut) == 0)
 	{
 	    keyboardMode = EItut;
 	}
-	else if (iKeyboardModeBuf->Des().Compare(KQwerty) == 0)
+	else if (iKeyboardModeBuf->Compare(KQwerty) == 0)
 	{
 	    keyboardMode = EQwerty;
 	}
+	else if (iKeyboardModeBuf->Compare(KPredictiveItuT) == 0)
+	{
+		keyboardMode = EPredictiveItuT;
+	}
+	else if (iKeyboardModeBuf->Compare(KPredictiveQwerty) == 0)
+	{
+		keyboardMode = EPredictiveQwerty;
+	}
+	else if (iKeyboardModeBuf->Compare(KPredictiveDefaultKeyboard) == 0)
+	{
+		keyboardMode = EPredictiveDefaultKeyboard;
+	}
+	else if (iKeyboardModeBuf->Compare(KNonPredictive) == 0)
+	{
+		keyboardMode = ENonPredictive;
+	}
 
 	else // mixed mode
 	{
 		// convert the search query to the required format
-		_LIT(KCode,"i");
 		for(TInt i = 0; i < aQueryBuf.Length(); i++)
 		{
 			CPsQueryItem* item = CPsQueryItem::NewL();
 	    	item->SetCharacter(aQueryBuf[i]); // set search character
 	    	
 	    	// set the keyboard mode
-	    	if( (iKeyboardModeBuf->Des().Mid(i,1)).Compare(KCode) == 0)
+	    	if( (iKeyboardModeBuf->Des().Mid(i,1)).Compare(KPredictiveItuTCode) == 0)
  			{
- 				item->SetMode(EItut);
+ 				item->SetMode(EPredictiveItuT);
  			}
+            else if( (iKeyboardModeBuf->Des().Mid(i,1)).Compare(KPredictiveQwertyCode) == 0)
+            {
+                item->SetMode(EPredictiveQwerty);
+            }
+            else if( (iKeyboardModeBuf->Des().Mid(i,1)).Compare(KPredictiveDefaultCode) == 0)
+            {
+                item->SetMode(EPredictiveDefaultKeyboard);
+            }
+            else if( (iKeyboardModeBuf->Des().Mid(i,1)).Compare(KNonPredictiveCode) == 0)
+            {
+                item->SetMode(ENonPredictive);
+            }
  			else 
  			{
- 				item->SetMode(EQwerty);
+ 				item->SetMode(EModeUndefined);
  			}
  			
  			aPsQuery.AppendL(*item);
--- a/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/pstestcontactshandler.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/pstestcontactshandler.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -52,11 +52,11 @@
 // ---------------------------------------------------------------------------------
 // 1st phase constructor
 // ---------------------------------------------------------------------------------
-CPcsTestContactsHandler* CPcsTestContactsHandler::NewL(TBool SimStoreOnly)
+CPcsTestContactsHandler* CPcsTestContactsHandler::NewL(TBool aSimStoreOnly)
 {
 	CPcsTestContactsHandler* self = new ( ELeave ) CPcsTestContactsHandler();
 	CleanupStack::PushL( self );
-	self->ConstructL(SimStoreOnly);
+	self->ConstructL(aSimStoreOnly);
 	CleanupStack::Pop( self );
 	
 	return self;
@@ -77,13 +77,13 @@
 // ---------------------------------------------------------------------------------
 // 2nd phase constructor
 // ---------------------------------------------------------------------------------
-void CPcsTestContactsHandler::ConstructL(TBool SimStoreOnly)
+void CPcsTestContactsHandler::ConstructL(TBool aSimStoreOnly)
 {
 	iOperationComplete = EFalse;
 
 	// initialize virtual phonebook with phonebook and sim contact uris.
 	CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
-	if(SimStoreOnly)
+	if(aSimStoreOnly)
 	{
 		uriArray->AppendL( TVPbkContactStoreUriPtr( VPbkContactStoreUris::SimGlobalAdnUri() ) );
 	}
@@ -103,7 +103,7 @@
 
 	// Open al the stores
 	iContactManager->ContactStoresL().OpenAllL( *this );
-	if(SimStoreOnly)
+	if(aSimStoreOnly)
 	{
 		iStore = iContactManager->ContactStoresL().Find( TVPbkContactStoreUriPtr( VPbkContactStoreUris::SimGlobalAdnUri() ) );
 	}
--- a/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/pstestqueryhandler.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/contacts_plat/predictivesearch_client_api/tsrc/PsClientTestSuite/src/pstestqueryhandler.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -208,20 +208,6 @@
 	 	{
 	 		item->SetMode(aMode);	 		
 	 	}
-	 	/*
-	 	else 
-	 	{
-	 		_LIT(KCode,"i");
- 			if( (iKeyboardModeString.Mid(i,1)).Compare(KCode) == 0)
- 			{
- 				item->SetMode(EItut);
- 			}
- 			else 
- 			{
- 				item->SetMode(EQwerty);
- 			}
-	 	}
-	 	*/
 		iPsQuery->AppendL(*item);			
 	}
 	
--- a/contacts_plat/predictivesearch_utils_api/inc/CPcsDefs.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/contacts_plat/predictivesearch_utils_api/inc/CPcsDefs.h	Mon Mar 15 12:39:26 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2007 - 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"
@@ -67,9 +67,38 @@
  */
 enum TKeyboardModes
 {
-   EItut,
-   EQwerty,
-   EModeUndefined
+    /**
+     * Predictive matching mode with default keyboard. 
+     * The key mappings used are either those of the first available
+     * hardware keyboard or those of virtual-ITU-T if no hardware keyboard
+     * is available.
+     */
+    EPredictiveDefaultKeyboard = 0,
+    
+    /**
+     * Non-predictive matching mode.
+     * Keyboard mappings of any kind are not used. Entered characters are
+     * matched just as themselves, but using locale specific tolerant
+     * matching rules (i.e. the collated comparison).
+     */
+    ENonPredictive = 1,
+    
+    /**
+     * Predictive matching using 12-key ITU-T keymappings.
+     */
+    EPredictiveItuT = 2,
+    
+    /**
+     * Predictive matching using hardware QWERTY key mappings.
+     * Also half-QWERTY is here considered as QWERTY.
+     */
+    EPredictiveQwerty = 3,
+    
+    // These modes are provided for backward source and binary compatibility.
+    EItut = EPredictiveDefaultKeyboard,  //! deprecated
+    EQwerty = ENonPredictive,            //! deprecated
+    
+    EModeUndefined = -1
 };
 
 /**
@@ -117,11 +146,11 @@
 /**
  * Data Stores Constants 
  */
-_LIT(KVPbkDefaultCntDbURI, "cntdb://c:contacts.cdb"); //Phone Store
+_LIT(KVPbkDefaultCntDbURI, "cntdb://c:contacts.cdb"); // Phone Store
 _LIT(KVPbkSimGlobalAdnURI, "sim://global_adn");       // SIM ADN Store
 _LIT(KVPbkSimGlobalFdnURI, "sim://global_fdn");       // SIM FDN Store
 _LIT(KVPbkSimGlobalSdnURI, "sim://global_sdn");       // SIM SDN Store
-_LIT(KVPbkDefaultGrpDbURI, "cntdb://c:contacts.gdb"); // groups Store
+_LIT(KVPbkDefaultGrpDbURI, "cntdb://c:contacts.gdb"); // Groups Store
 
 /**
  * Data Structure to identify the matched locations
@@ -129,9 +158,9 @@
 struct TPsMatchLocation
 {
 	public:
-		TInt index;   						  // starting index for the match sequence
-		TInt length;  						  // lenght of the match sequence
-		TBidiText::TDirectionality direction; // directionality for the sequence
+		TInt index;   						  // Starting index for the match sequence
+		TInt length;  						  // Lenght of the match sequence
+		TBidiText::TDirectionality direction; // Directionality for the sequence
 };
 
 /**
--- a/contacts_plat/virtual_phonebook_engine_api/inc/MVPbkContactViewObserver.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/contacts_plat/virtual_phonebook_engine_api/inc/MVPbkContactViewObserver.h	Mon Mar 15 12:39:26 2010 +0200
@@ -39,8 +39,8 @@
     {
     public: // Interface
         /**
-         * Called when a view is ready for use. 
-         * 
+         * Called when a view is ready for use.
+         *
          * This function may also be called if view is already ready. Then
          * it means that the view has been updated and the observer have
          * to take this into account.
@@ -51,8 +51,8 @@
                 MVPbkContactViewBase& aView ) = 0;
 
         /**
-         * Called when a view is unavailable for a while. 
-         * 
+         * Called when a view is unavailable for a while.
+         *
          * When the view is again available ContactViewReady will be called.
          * The contents of the view may change completely while it is
          * unavailable.
@@ -71,8 +71,8 @@
          *                     valid only during the functio call.
          */
         virtual void ContactAddedToView(
-                MVPbkContactViewBase& aView, 
-                TInt aIndex, 
+                MVPbkContactViewBase& aView,
+                TInt aIndex,
                 const MVPbkContactLink& aContactLink ) = 0;
 
         /**
@@ -84,8 +84,8 @@
          *                      valid only during this function call.
          */
         virtual void ContactRemovedFromView(
-                MVPbkContactViewBase& aView, 
-                TInt aIndex, 
+                MVPbkContactViewBase& aView,
+                TInt aIndex,
                 const MVPbkContactLink& aContactLink ) = 0;
 
         /**
@@ -97,13 +97,13 @@
          *
          * @param aView A contact view sending the event.
          * @param aError An error code of the failure.
-         * @param aErrorNotified  ETrue if the implementation has already 
+         * @param aErrorNotified  ETrue if the implementation has already
          *                        notified user about the error using e.g
          *                        an ECOM plug-in, EFalse otherwise.
          */
         virtual void ContactViewError(
-                MVPbkContactViewBase& aView, 
-                TInt aError, 
+                MVPbkContactViewBase& aView,
+                TInt aError,
                 TBool aErrorNotified ) = 0;
 
         /**
@@ -112,7 +112,7 @@
          * @param aExtensionUid no extensions defined currently.
          * @return an extension point for this interface or NULL.
          */
-        virtual TAny* ContactViewObserverExtension(TUid /*aExtensionUid*/) 
+        virtual TAny* ContactViewObserverExtension(TUid /*aExtensionUid*/)
                 { return NULL; }
 
     protected: // Destructor
@@ -120,6 +120,32 @@
 
     };
 
+
+
+/// Use this UID to access base contact extension 2.
+// Used as a parameter to ContactViewObserverExtension() method.
+const TUid KVPbkContactViewObserverExtension2Uid = { 2 };
+
+/**
+ * This class is an extension to MVPbkContactViewObserver.
+ *
+ * @see MVPbkContactViewObserver
+ *
+ */
+class MVPbkContactViewObserverExtension
+    {
+    protected:  // Destructor
+        virtual ~MVPbkContactViewObserverExtension() { }
+
+    public:
+
+        /**
+         * Called when filtered contact removed from view
+         */
+        virtual void FilteredContactRemovedFromView( MVPbkContactViewBase& aView ) = 0;
+    };
+
+
 #endif  // MVPBKCONTACTVIEWOBSERVER_H
 
 // End of File
--- a/phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CAsyncContactOperation.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CAsyncContactOperation.h	Mon Mar 15 12:39:26 2010 +0200
@@ -29,6 +29,7 @@
 // FORWARD DECLARATIONS
 class CContactDatabase;
 class CContactItem;
+class CContactItemViewDef;
 
 namespace VPbkEngUtils { 
 class CVPbkDiskSpaceCheck;
@@ -125,6 +126,9 @@
         RFs iFs;
         ///Own: Disk Space Checker
         VPbkEngUtils::CVPbkDiskSpaceCheck* iDiskSpaceChecker;
+        
+        ///Own: for giving CContactItemViewDef to OpenContactLX
+        CContactItemViewDef* iViewDef;
     };
 
 
--- a/phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CFilteredContactView.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CFilteredContactView.h	Mon Mar 15 12:39:26 2010 +0200
@@ -35,11 +35,12 @@
 
 /**
  * Virtual phonebook filtered contact view. This class filters contacts
- * based on field types. 
+ * based on field types.
  */
-NONSHARABLE_CLASS( CFilteredContactView ): 
+NONSHARABLE_CLASS( CFilteredContactView ):
         public CViewBase,
-        public MVPbkContactViewObserver
+        public MVPbkContactViewObserver,
+        public MVPbkContactViewObserverExtension
     {
     public: // Constructor and destructor
 
@@ -56,7 +57,7 @@
         static CFilteredContactView* NewLC(
                 const CVPbkContactViewDefinition& aViewDefinition,
                 MVPbkContactViewObserver& aObserver,
-                CContactStore& aParentStore, 
+                CContactStore& aParentStore,
                 const MVPbkFieldTypeList& aSortOrder,
                 RFs& aFs );
         /**
@@ -80,17 +81,22 @@
         void ContactViewUnavailable(
                 MVPbkContactViewBase& aView );
         void ContactAddedToView(
-                MVPbkContactViewBase& aView, 
-                TInt aIndex, 
+                MVPbkContactViewBase& aView,
+                TInt aIndex,
                 const MVPbkContactLink& aContactLink );
         void ContactRemovedFromView(
-                MVPbkContactViewBase& aView, 
-                TInt aIndex, 
+                MVPbkContactViewBase& aView,
+                TInt aIndex,
                 const MVPbkContactLink& aContactLink );
         void ContactViewError(
-                MVPbkContactViewBase& aView, 
-                TInt aError, 
+                MVPbkContactViewBase& aView,
+                TInt aError,
                 TBool aErrorNotified );
+        TAny* ContactViewObserverExtension( TUid aExtensionUid );
+
+    private: // From MVPbkContactViewObserverExtension
+		void FilteredContactRemovedFromView(
+				MVPbkContactViewBase& aView );
 
     private: // Implementation
         CFilteredContactView(
--- a/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CAsyncContactOperation.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CAsyncContactOperation.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -55,6 +55,7 @@
     CActive::Cancel();
     delete iDiskSpaceChecker;
     iFs.Close();
+    delete iViewDef;
     }
     
 void CAsyncContactOperation::ConstructL()
@@ -67,6 +68,13 @@
     User::LeaveIfError( iFs.CharToDrive
         ( ptr[0], drive) );
     iDiskSpaceChecker = VPbkEngUtils::CVPbkDiskSpaceCheck::NewL( iFs, drive );
+    
+    iViewDef = CContactItemViewDef::NewL(
+                      CContactItemViewDef::EIncludeFields, 
+                      CContactItemViewDef::EMaskHiddenFields);
+
+    iViewDef->AddL( KUidContactFieldMatchAll );
+    
     }    
 
 void CAsyncContactOperation::PrepareL
@@ -134,10 +142,11 @@
             }
 
         case MVPbkContactObserver::EContactReadAndLock:
-            {
+            {          
             CContactItem* ci = 
-                iContactStore.NativeDatabase().OpenContactLX( iTargetContactId );
+                iContactStore.NativeDatabase().OpenContactLX( iTargetContactId, *iViewDef );
             CleanupStack::PushL( ci );
+            
             CContact* contact = CContact::NewL( iContactStore, ci );
             result.iStoreContact = contact;
             contact->SetModified();
@@ -156,7 +165,7 @@
             if( iClientContact )
             	{
             	CContactItem* ci = iContactStore.NativeDatabase().OpenContactLX(
-            			iClientContact->NativeContact()->Id() );
+            			iClientContact->NativeContact()->Id(), *iViewDef );
 	            CleanupStack::PushL( ci );
 	            const_cast<CContact*>( iClientContact )->SetContact( ci );
 	            const_cast<CContact*>( iClientContact )->SetModified();
--- a/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CFilteredContactView.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CFilteredContactView.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -87,10 +87,10 @@
 
         { R_CNTMODEL_NATIVE_FILTER_ASSISTANT_PHONE_NUMBER,
           CContactDatabase::EPhonable },
-          
+
         { R_CNTMODEL_NATIVE_FILTER_TOP_CONTACT,
           CContactDatabase::ECustomFilter2 },
-          
+
         /// This has to be the last
         { KLastElement,
           CContactDatabase::EUnfiltered }
@@ -147,10 +147,10 @@
                 {
                 TBool versitIsMatched = matchingProperty->Matches(
                        aFilterType->VersitProperties()[matchPriority]);
-                TBool excludedParmaterIsMatched = 
+                TBool excludedParmaterIsMatched =
                        aFilterType->ExcludedParameters().
                            ContainsAll(aFieldType.ExcludedParameters());
-                // if the FilterType is matched the Versit Property and 
+                // if the FilterType is matched the Versit Property and
                 // the excludeParameter of FiledType, it needn't custom filter.
                 if ( versitIsMatched && excludedParmaterIsMatched )
                     {
@@ -314,13 +314,13 @@
     if ( iFilteredView )
         {
         //after iFilteredView->Close( *iNativeObserver )
-        //both iFilteredView and iBaseView are deleted 
+        //both iFilteredView and iBaseView are deleted
         iFilteredView->Close( *iNativeObserver );
         }
     else if ( iBaseView )
         {
         //but iBaseView's pointer is still not NULL
-        //make sure iBaseView is unable to call its member function	
+        //make sure iBaseView is unable to call its member function
         iBaseView->Close( *iNativeObserver );
         }
     }
@@ -378,7 +378,7 @@
         const CFieldFactory& fieldFactory = Store().FieldFactory();
 
         // Copy construct the filter
-        iFilter = CVPbkFieldTypeSelector::NewL( 
+        iFilter = CVPbkFieldTypeSelector::NewL(
                 *aViewDefinition.FieldTypeFilter() );
 
         iNativeFilter = ConvertFieldTypeFilterL
@@ -394,20 +394,20 @@
         {
         // Stop observing the base view, the custom view
         // will observe it and report back
-        // Construction of the iCustomFilteredView should be done in two 
-        // phases. Due to that there is dependencies between views in this 
+        // 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, 
+        iCustomFilteredView =
+            new (ELeave) CCustomFilteredContactView( Store(), iFilter,
                 *this, aViewDefinition.ContactSelector() );
-        ConstructBaseViewsL( aViewDefinition, *iCustomFilteredView, 
+        ConstructBaseViewsL( aViewDefinition, *iCustomFilteredView,
                 aViewSortOrder );
 
         if ( iFilteredView )
             {
             iBaseView->Close( *iCustomFilteredView );
-            }                
-                
+            }
+
         iCustomFilteredView->ConstructL
             ( aViewDefinition, *this, *iSortOrder, *iView );
 
@@ -440,21 +440,21 @@
 // CFilteredContactView::DoChangeSortOrderL
 // --------------------------------------------------------------------------
 //
-TBool CFilteredContactView::DoChangeSortOrderL( 
+TBool CFilteredContactView::DoChangeSortOrderL(
         const CVPbkContactViewDefinition& aViewDefinition,
 		RContactViewSortOrder& aSortOrder )
     {
     TBool canBeChanged = ETrue;
     if ( iRemoteView )
         {
-        if ( RemoteViewName( aViewDefinition ).Compare( 
+        if ( RemoteViewName( aViewDefinition ).Compare(
                 KVPbkAllContactsViewName ) == 0 )
             {
             // Set Contacts Model default view setting only if client
             // is using KVPbkAllContactsViewName shared view.
             NamedRemoteViewViewDefinitionStoreUtility::
                 SetNamedRemoteViewViewDefinitionL(
-                    KVPbkAllContactsViewName, aSortOrder, 
+                    KVPbkAllContactsViewName, aSortOrder,
                     KVPbkDefaultContactViewPrefs);
             }
         iRemoteView->ChangeSortOrderL( aSortOrder );
@@ -464,7 +464,7 @@
         // CContactLocalView doesn't support ChangeSortOrderL
         canBeChanged = EFalse;
         }
-        
+
     return canBeChanged;
     }
 
@@ -477,7 +477,7 @@
     {
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
         ("CFilteredContactView::ContactViewReady(0x%x)"), &aView);
-    
+
     /* when custom filtering view is used, MVPbkContactViewObserver doesn't support
      * sortOrder changed notification, CViewBase will send viewReady instead,
      * use it to keep sort order up to date */
@@ -529,11 +529,11 @@
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
         ("CFilteredContactView::ContactAddedToView(0x%x)"), &aView);
 
-    VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, 
+    VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink,
         iObservers,
         &MVPbkContactViewObserver::ContactAddedToView,
         &MVPbkContactViewObserver::ContactViewError );
-    VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, 
+    VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink,
         iFilteringObservers,
         &MVPbkContactViewObserver::ContactAddedToView,
         &MVPbkContactViewObserver::ContactViewError );
@@ -550,11 +550,11 @@
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
         ("CFilteredContactView::ContactRemovedFromView(0x%x)"), &aView);
 
-    VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, 
+    VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink,
         iObservers,
         &MVPbkContactViewObserver::ContactRemovedFromView,
         &MVPbkContactViewObserver::ContactViewError );
-    VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink, 
+    VPbkEng::SendViewEventToObservers( *this, aIndex, aContactLink,
         iFilteringObservers,
         &MVPbkContactViewObserver::ContactRemovedFromView,
         &MVPbkContactViewObserver::ContactViewError );
@@ -573,11 +573,53 @@
 
     VPbkEng::SendEventToObservers( *this, aError, aErrorNotified, iObservers,
         &MVPbkContactViewObserver::ContactViewError );
-    VPbkEng::SendEventToObservers( *this, aError, aErrorNotified, 
+    VPbkEng::SendEventToObservers( *this, aError, aErrorNotified,
         iFilteringObservers, &MVPbkContactViewObserver::ContactViewError );
     }
 
 // --------------------------------------------------------------------------
+// CFilteredContactView::ContactViewObserverExtension
+// --------------------------------------------------------------------------
+//
+TAny* CFilteredContactView::ContactViewObserverExtension( TUid aExtensionUid )
+    {
+    if( aExtensionUid == KVPbkContactViewObserverExtension2Uid )
+        {
+        return static_cast<MVPbkContactViewObserverExtension*>( this );
+        }
+    return NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CFilteredContactView::FilteredContactRemovedFromView
+// --------------------------------------------------------------------------
+//
+void CFilteredContactView::FilteredContactRemovedFromView(
+		MVPbkContactViewBase& aView )
+    {
+    const TInt count = iObservers.Count();
+
+    for( TInt i = 0; i < count; i++ )
+        {
+        MVPbkContactViewObserver* observer = iObservers[i];
+
+        TAny* extension = observer->ContactViewObserverExtension(
+              KVPbkContactViewObserverExtension2Uid );
+
+        if( extension )
+            {
+            MVPbkContactViewObserverExtension* contactViewExtension =
+                  static_cast<MVPbkContactViewObserverExtension*>( extension );
+
+            if( contactViewExtension )
+                {
+                contactViewExtension->FilteredContactRemovedFromView( aView );
+                }
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
 // CFilteredContactView::ConstructBaseViewsL
 // --------------------------------------------------------------------------
 //
@@ -591,23 +633,23 @@
     // Construct the all contacts view first
     if ( RemoteViewDefinition( aViewDefinition ) )
         {
-        iRemoteView = CContactNamedRemoteView::NewL( 
-                *iNativeObserver, RemoteViewName( aViewDefinition ), 
-                Store().NativeDatabase(), aViewSortOrder, 
+        iRemoteView = CContactNamedRemoteView::NewL(
+                *iNativeObserver, RemoteViewName( aViewDefinition ),
+                Store().NativeDatabase(), aViewSortOrder,
                 KVPbkDefaultContactViewPrefs );
-                
+
         iBaseView = iRemoteView;
         }
     else
         {
-        iBaseView = CContactLocalView::NewL( *iNativeObserver, 
-                Store().NativeDatabase(), aViewSortOrder, 
+        iBaseView = CContactLocalView::NewL( *iNativeObserver,
+                Store().NativeDatabase(), aViewSortOrder,
                 KVPbkDefaultContactViewPrefs );
         }
-    
+
     // Set base class view pointer
     iView = iBaseView;
-    
+
     // If there is a native filter, construct a native filtered view
     if ( iNativeFilter > 0 )
         {
--- a/phonebookengines/VirtualPhonebook/VPbkEng/inc/CVPbkCompositeContactView.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookengines/VirtualPhonebook/VPbkEng/inc/CVPbkCompositeContactView.h	Mon Mar 15 12:39:26 2010 +0200
@@ -40,10 +40,11 @@
  * Composite contact views can be used to compose a view from
  * multiple sub views.
  */
-NONSHARABLE_CLASS(CVPbkCompositeContactView) : 
+NONSHARABLE_CLASS(CVPbkCompositeContactView) :
         public CBase,
         public MVPbkContactViewBase,
         public MVPbkContactViewObserver,
+        public MVPbkContactViewObserverExtension,
         protected MVPbkContactViewFiltering,
         public MVPbkContactViewBaseChildAccessExtension
 	{
@@ -65,7 +66,7 @@
          */
         void AddSubViewL(
                 MVPbkContactViewBase* aSubView, TInt  aViewId = KVPbkDefaultViewId);
-        
+
         /**
          * ActualContactCountL returns the number of contact's in subviews.
          * It might be that all subview events haven't
@@ -75,21 +76,21 @@
          * @return the contact count calculated from subviews.
          */
         TInt ActualContactCountL() const;
-        
+
         /**
          * @return The number of contacts in iContactMapping
          */
         inline TInt CompositeContactCountL() const;
-        
+
         /**
          * If the parent of this view is also a composite view
          * it calls this to configure this view as an internal view
          * that has no external observers.
          */
         void ApplyInternalCompositePolicyL();
-        
+
         void SetViewId(TInt aViewId);
-        
+
     private: // Abstract interface for composite implementations
         /**
          * Builds view mapping.
@@ -133,8 +134,8 @@
         TInt IndexOfBookmarkL(
                 const MVPbkContactBookmark& aContactBookmark ) const;
         MVPbkContactViewFiltering* ViewFiltering();
-        TAny* ContactViewBaseExtension(TUid aExtensionUid); 
-            
+        TAny* ContactViewBaseExtension(TUid aExtensionUid);
+
     private: // From MVPbkContactViewObserver
         void ContactViewReady(
                 MVPbkContactViewBase& aView );
@@ -152,6 +153,11 @@
                 MVPbkContactViewBase& aView,
                 TInt aError,
                 TBool aErrorNotified);
+        TAny* ContactViewObserverExtension( TUid aExtensionUid );
+
+    private: // From MVPbkContactViewObserverExtension
+        void FilteredContactRemovedFromView(
+			 	MVPbkContactViewBase& aView );
 
     private: // From MVPbkContactViewFiltering
         /// Composite implementations must implement this
@@ -159,7 +165,7 @@
             MVPbkContactViewObserver& aObserver,
             const MDesCArray& aFindWords,
             const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts ) = 0;
-        void UpdateFilterL( 
+        void UpdateFilterL(
             const MDesCArray& aFindWords,
             const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts );
 
@@ -171,7 +177,7 @@
 
     protected: // Types
         class CSubViewData;
-                
+
         /**
          * Contact mapping structure. Mapping supports 128 subviews
          * and over 8 million contacts per sub view.
@@ -182,7 +188,7 @@
             TInt iViewIndex: 8;
             /// Own: Contact index
             TInt iContactIndex: 24;
-            };                          
+            };
 
     protected: // Implementation
         CVPbkCompositeContactView();
@@ -194,7 +200,7 @@
         TBool IsCompositeReady() const;
         /// Returns the composite's view policy.
         MVPbkCompositeContactViewPolicy& CompositePolicy() const;
-        
+
     private: // Implementation
         TInt FindSubViewIndex(MVPbkContactViewBase& aView) const;
         TBool AllSubViewsKnown() const;
@@ -217,7 +223,7 @@
         void SendViewUnavailableEvent();
         void SendViewErrorEvent( TInt aError, TBool aErrorNotified );
         void UpdateSortOrderL();
-            
+
     protected: // Data
         /// Own: Array of subviews
         RPointerArray<CSubViewData> iSubViews;
@@ -266,7 +272,7 @@
          * @param aState    View state.
          */
         CSubViewData(TViewState aState) : iState( aState ) {}
-            
+
         /**
          * Destructor.
          */
@@ -288,29 +294,29 @@
 /**
  * Internal interface for different behavior of exterior and interior
  * composite views.
- */ 
+ */
 NONSHARABLE_CLASS(MVPbkCompositeContactViewPolicy)
     {
-    public: 
+    public:
         /**
          * Destructor
          */
         virtual ~MVPbkCompositeContactViewPolicy() {}
-        
+
         /**
          * Handles contact added & removed events.
          */
-        virtual void HandleViewEventsL( 
+        virtual void HandleViewEventsL(
             CVPbkEventArrayItem::TViewEventType aEvent,
             MVPbkContactViewBase& aSubview,
-            TInt aIndex, const 
+            TInt aIndex, const
             MVPbkContactLink& aContactLink ) = 0;
-        
-        /** 
+
+        /**
          * Reset policy if it has cached data.
          */
         virtual void Reset() = 0;
-        
+
         /**
          * Returns the contact count in composite or 0 if
          * composite is not up to date with leaf views.
@@ -318,11 +324,11 @@
          * @return aCompositeCount or 0.
          */
         virtual TInt ContactCountL() const = 0;
-        
+
         /**
          * Returns ETrue if this is an internal composite policy
          * @return ETrue if this is an internal composite policy
-         */ 
+         */
         virtual TBool InternalPolicy() const = 0;
     };
 
@@ -338,22 +344,22 @@
                 CVPbkCompositeContactView& aCompositeView,
                 RPointerArray<MVPbkContactViewObserver>& aObservers );
         ~CVPbkExternalCompositeViewPolicy();
-        
+
     private: // From MVPbkCompositeContactViewPolicy
-        void HandleViewEventsL( 
+        void HandleViewEventsL(
             CVPbkEventArrayItem::TViewEventType aEvent,
             MVPbkContactViewBase& aSubview,
-            TInt aIndex, const 
+            TInt aIndex, const
             MVPbkContactLink& aContactLink );
         void Reset();
         TInt ContactCountL() const;
         TBool InternalPolicy() const;
-    
+
     private: // Implementation
         CVPbkExternalCompositeViewPolicy(
             CVPbkCompositeContactView& aCompositeView,
             RPointerArray<MVPbkContactViewObserver>& aObservers );
-        
+
     private: // Data
         /// Ref: The parent of this policy
         CVPbkCompositeContactView& iCompositeView;
@@ -374,22 +380,22 @@
         static CVPbkInternalCompositeViewPolicy* NewL(
                 CVPbkCompositeContactView& aCompositeView,
                 RPointerArray<MVPbkContactViewObserver>& aObservers );
-        
+
     private: // From MVPbkCompositeContactViewPolicy
-        void HandleViewEventsL( 
+        void HandleViewEventsL(
             CVPbkEventArrayItem::TViewEventType aEvent,
             MVPbkContactViewBase& aSubview,
-            TInt aIndex, const 
+            TInt aIndex, const
             MVPbkContactLink& aContactLink );
         void Reset();
         TInt ContactCountL() const;
         TBool InternalPolicy() const;
-    
+
     private: // Implementation
         CVPbkInternalCompositeViewPolicy(
             CVPbkCompositeContactView& aCompositeView,
             RPointerArray<MVPbkContactViewObserver>& aObservers );
-        
+
     private: // Data
         /// Ref: The parent of this policy
         CVPbkCompositeContactView& iCompositeView;
--- a/phonebookengines/VirtualPhonebook/VPbkEng/src/CVPbkCompositeContactView.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookengines/VirtualPhonebook/VPbkEng/src/CVPbkCompositeContactView.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -36,7 +36,7 @@
         {
         EPanicLogic_CreateBookmarkLC = 3
         };
-        
+
     void Panic(TPanic aPanic)
         {
         _LIT(KPanicCat, "CVPbkCompositeContactView");
@@ -56,7 +56,7 @@
 // --------------------------------------------------------------------------
 //
 template <class NotifyFunc>
-void SendEventToObservers( MVPbkContactViewBase& aView, 
+void SendEventToObservers( MVPbkContactViewBase& aView,
         RPointerArray<MVPbkContactViewObserver>& aObservers,
         NotifyFunc aNotifyFunc )
     {
@@ -73,7 +73,7 @@
 // --------------------------------------------------------------------------
 //
 template <class NotifyFunc, class ParamType1, class ParamType2>
-void SendEventToObservers( MVPbkContactViewBase& aView, 
+void SendEventToObservers( MVPbkContactViewBase& aView,
         RPointerArray<MVPbkContactViewObserver>& aObservers,
         NotifyFunc aNotifyFunc, ParamType1 aParam1, const ParamType2& aParam2 )
     {
@@ -111,7 +111,7 @@
 // --------------------------------------------------------------------------
 //
 CVPbkCompositeContactView::~CVPbkCompositeContactView()
-    {    
+    {
     delete iCompositePolicy;
     delete iSortOrder;
     iSubViews.ResetAndDestroy();
@@ -130,7 +130,7 @@
     iSortOrder = CVPbkSortOrder::NewL(aSortOrder);
 
     // Always apply internal policy
-    iCompositePolicy = 
+    iCompositePolicy =
             CVPbkInternalCompositeViewPolicy::NewL( *this, iObservers );
 
     // External policy's view event buffering mechanism does not work when
@@ -154,11 +154,11 @@
     subViewData->iView = aSubView;
     subViewData->iViewId = aViewId;
     }
-        
+
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::ActualContactCountL
 // --------------------------------------------------------------------------
-//        
+//
 TInt CVPbkCompositeContactView::ActualContactCountL() const
     {
     const TInt subViewCount = iSubViews.Count();
@@ -173,7 +173,7 @@
                 // CVPbkCompositeContactView is VPbkEng internal
                 // and EVPbkCompositeView type view is always
                 // derived from CVPbkCompositeContactView.
-                contactCount += static_cast<CVPbkCompositeContactView*>( 
+                contactCount += static_cast<CVPbkCompositeContactView*>(
                     iSubViews[i]->iView )->ActualContactCountL();
                 }
             else
@@ -188,18 +188,18 @@
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::ApplyInternalCompositePolicyL
 // --------------------------------------------------------------------------
-//        
+//
 void CVPbkCompositeContactView::ApplyInternalCompositePolicyL()
     {
     if ( !iCompositePolicy || !iCompositePolicy->InternalPolicy() )
         {
-        MVPbkCompositeContactViewPolicy* newPolicy = 
+        MVPbkCompositeContactViewPolicy* newPolicy =
                 CVPbkInternalCompositeViewPolicy::NewL( *this, iObservers );
         delete iCompositePolicy;
         iCompositePolicy = newPolicy;
         }
     }
-    
+
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::Type
 // Returns view type.
@@ -230,7 +230,7 @@
             iSubViews[i]->iView->ChangeSortOrderL(aSortOrder);
             }
         }
-    
+
     // Create new sort order and take it in use
     MVPbkFieldTypeList* sortOrder = CVPbkSortOrder::NewL(aSortOrder);
     delete iSortOrder;
@@ -330,9 +330,9 @@
         TInt index = KErrNotFound;
         if (iSubViews[i]->iState == CSubViewData::EReady)
             {
-            index = iSubViews[i]->iView->IndexOfLinkL(aContactLink);        
-            }        
-            
+            index = iSubViews[i]->iView->IndexOfLinkL(aContactLink);
+            }
+
         if (index != KErrNotFound)
             {
             // Establish contact mapping for view and contact index
@@ -361,13 +361,13 @@
         User::Leave( err );
         }
 
-    TRAP(err, 
+    TRAP(err,
         {
         VPbkEngUtils::MAsyncCallback* notifyObserver =
             VPbkEngUtils::CreateAsyncCallbackLC(
-                *this, 
-                &CVPbkCompositeContactView::DoAddObserverL, 
-                &CVPbkCompositeContactView::AddObserverError, 
+                *this,
+                &CVPbkCompositeContactView::DoAddObserverL,
+                &CVPbkCompositeContactView::AddObserverError,
                 aObserver);
         iAsyncOperation.CallbackL(notifyObserver);
         CleanupStack::Pop(notifyObserver);
@@ -410,7 +410,7 @@
         }
     return result;
     }
-    
+
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::MatchContactStoreDomain
 // Check does any of the subviews match given contact store domain.
@@ -438,9 +438,9 @@
 MVPbkContactBookmark* CVPbkCompositeContactView::CreateBookmarkLC
         (TInt aIndex) const
     {
-    __ASSERT_ALWAYS( aIndex >= 0, 
+    __ASSERT_ALWAYS( aIndex >= 0,
         VPbkError::Panic( VPbkError::EInvalidContactIndex ) );
-    __ASSERT_DEBUG(ContactCountL() > aIndex, 
+    __ASSERT_DEBUG(ContactCountL() > aIndex,
             Panic(EPanicLogic_CreateBookmarkLC));
 
     const TContactMapping& mapping = iContactMapping[aIndex];
@@ -459,7 +459,7 @@
     TIdentityRelation<TContactMapping> comparisonOperator(
         &CVPbkCompositeContactView::CompareMappings);
     TInt result = KErrNotFound;
-    
+
     // Search the bookmark from all the subviews
     const TInt subViewCount = iSubViews.Count();
     for (TInt i = 0; i < subViewCount; ++i)
@@ -470,7 +470,7 @@
             {
             index = iSubViews[i]->iView->IndexOfBookmarkL(aContactBookmark);
             }
-            
+
         if (index != KErrNotFound)
             {
             // Establish contact mapping for view and contact index
@@ -551,7 +551,7 @@
     {
     TInt compositeIndex = HandleContactAddition(aView, aIndex);
 
-    TRAPD( error, iCompositePolicy->HandleViewEventsL( 
+    TRAPD( error, iCompositePolicy->HandleViewEventsL(
         CVPbkEventArrayItem::EAdded, aView, compositeIndex, aContactLink ) );
     if ( error != KErrNone )
         {
@@ -571,8 +571,8 @@
     {
     TInt compositeIndex( KErrNotFound );
     compositeIndex = HandleContactRemoval(aView, aIndex);
-    TRAPD( error, iCompositePolicy->HandleViewEventsL( 
-        CVPbkEventArrayItem::ERemoved, aView, compositeIndex, 
+    TRAPD( error, iCompositePolicy->HandleViewEventsL(
+        CVPbkEventArrayItem::ERemoved, aView, compositeIndex,
             aContactLink ) );
     if ( error != KErrNone )
         {
@@ -593,17 +593,59 @@
     }
 
 // --------------------------------------------------------------------------
+// CVPbkCompositeContactView::ContactViewObserverExtension
+// --------------------------------------------------------------------------
+//
+TAny* CVPbkCompositeContactView::ContactViewObserverExtension( TUid aExtensionUid )
+    {
+    if( aExtensionUid == KVPbkContactViewObserverExtension2Uid )
+        {
+        return static_cast<MVPbkContactViewObserverExtension*>( this );
+        }
+    return NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CVPbkCompositeContactView::FilteredContactRemovedFromView
+// --------------------------------------------------------------------------
+//
+void CVPbkCompositeContactView::FilteredContactRemovedFromView(
+		MVPbkContactViewBase& aView )
+    {
+    const TInt count = iObservers.Count();
+
+    for( TInt i = 0; i < count; i++ )
+        {
+        MVPbkContactViewObserver* observer = iObservers[i];
+
+        TAny* extension = observer->ContactViewObserverExtension(
+              KVPbkContactViewObserverExtension2Uid );
+
+        if( extension )
+            {
+            MVPbkContactViewObserverExtension* contactViewExtension =
+                  static_cast<MVPbkContactViewObserverExtension*>( extension );
+
+            if( contactViewExtension )
+                {
+                contactViewExtension->FilteredContactRemovedFromView( aView );
+                }
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
 // CVPbkCompositeContactView::UpdateFilterL
 // --------------------------------------------------------------------------
-//    
-void CVPbkCompositeContactView::UpdateFilterL( 
+//
+void CVPbkCompositeContactView::UpdateFilterL(
         const MDesCArray& aFindWords,
         const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts )
     {
     const TInt count = iSubViews.Count();
     for( TInt i = 0; i < count; ++i )
         {
-        MVPbkContactViewFiltering* filtering = 
+        MVPbkContactViewFiltering* filtering =
             iSubViews[i]->iView->ViewFiltering();
         // Check if the subview supports filtering.
         if ( filtering )
@@ -618,7 +660,7 @@
             // On the other hand a client can still use this view while it's
             // updating itself so in that point of view the composite is not
             // in unknown state but in update state.
-            iSubViews[i]->iState = CSubViewData::ENotKnown;            
+            iSubViews[i]->iState = CSubViewData::ENotKnown;
             }
         }
     }
@@ -639,7 +681,7 @@
     const TInt count = iSubViews.Count();
     for (TInt i = 0; i < count; ++i)
         {
-        view=iSubViews[i]->iView; 
+        view=iSubViews[i]->iView;
         if (iSubViews[i]->iViewId == aId)
            {
            return view;
@@ -655,7 +697,7 @@
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::SendViewReadyEvent
 // --------------------------------------------------------------------------
-//         
+//
 void CVPbkCompositeContactView::SendViewReadyEvent()
     {
     VPBK_DEBUG_PRINT( VPBK_DEBUG_STRING(
@@ -669,7 +711,7 @@
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::SendViewUnavailableEvent
 // --------------------------------------------------------------------------
-//        
+//
 void CVPbkCompositeContactView::SendViewUnavailableEvent()
     {
     VPBK_DEBUG_PRINT( VPBK_DEBUG_STRING(
@@ -684,13 +726,13 @@
 // CVPbkCompositeContactView::SendViewErrorEvent
 // --------------------------------------------------------------------------
 //
-void CVPbkCompositeContactView::SendViewErrorEvent( TInt aError, 
+void CVPbkCompositeContactView::SendViewErrorEvent( TInt aError,
         TBool aErrorNotified )
     {
-    SendEventToObservers(*this, iObservers, 
+    SendEventToObservers(*this, iObservers,
         &MVPbkContactViewObserver::ContactViewError, aError, aErrorNotified);
     }
-    
+
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::CompareMappings
 // --------------------------------------------------------------------------
@@ -717,8 +759,8 @@
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::CompositePolicy
 // --------------------------------------------------------------------------
-//        
-MVPbkCompositeContactViewPolicy& 
+//
+MVPbkCompositeContactViewPolicy&
         CVPbkCompositeContactView::CompositePolicy() const
     {
     return *iCompositePolicy;
@@ -788,7 +830,7 @@
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::ResetContactMapping
 // --------------------------------------------------------------------------
-//    
+//
 void CVPbkCompositeContactView::ResetContactMapping()
     {
     iContactMapping.Reset();
@@ -798,7 +840,7 @@
 // CVPbkCompositeContactView::RemoveContactMappingsFromView
 // --------------------------------------------------------------------------
 //
-void CVPbkCompositeContactView::RemoveContactMappingsFromView( 
+void CVPbkCompositeContactView::RemoveContactMappingsFromView(
         MVPbkContactViewBase& aView )
     {
     TInt subviewIndex = FindSubViewIndex( aView );
@@ -819,12 +861,12 @@
 // CVPbkCompositeContactView::HandleContactViewReadyL
 // --------------------------------------------------------------------------
 //
-void CVPbkCompositeContactView::HandleContactViewReadyL( 
+void CVPbkCompositeContactView::HandleContactViewReadyL(
         MVPbkContactViewBase& aView )
     {
     VPBK_DEBUG_PRINT( VPBK_DEBUG_STRING(
         "CVPbkCompositeContactView::HandleContactViewReadyL(0x%x)"), this );
-    
+
     // Find matching subview and set its state to ready
     TInt subViewIndex = FindSubViewIndex(aView);
     if (subViewIndex != KErrNotFound)
@@ -834,7 +876,7 @@
 
     // Check that composite's sort order up to date with subviews.
     UpdateSortOrderL();
-    
+
     // If composite is ready, build view mapping and notify observers
     if ( IsCompositeReady() )
         {
@@ -842,19 +884,19 @@
         DoBuildContactMappingL();
         VPBK_PROFILE_END(VPbkProfile::ECompositeContactViewMapping);
         SendViewReadyEvent();
-        }    
+        }
     }
 
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::HandleContactViewUnavailableL
 // --------------------------------------------------------------------------
 //
-void CVPbkCompositeContactView::HandleContactViewUnavailableL( 
+void CVPbkCompositeContactView::HandleContactViewUnavailableL(
         MVPbkContactViewBase& aView )
     {
     VPBK_DEBUG_PRINT( VPBK_DEBUG_STRING(
         "CVPbkCompositeContactView::ContactViewUnavailable(0x%x)"), this );
-    
+
     // Find matching subview and set its state
     TInt subViewIndex = FindSubViewIndex(aView);
     if (subViewIndex != KErrNotFound)
@@ -881,7 +923,7 @@
         else
             {
             // Composite is still under construction.
-            
+
             // Dont't send event here because the state of the composite is
             // not yet known and sending event can cause problems for client
             // e.g unwanted changes in the UI state.
@@ -889,7 +931,7 @@
             }
         }
     }
-    
+
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::CVPbkCompositeContactView
 // --------------------------------------------------------------------------
@@ -898,7 +940,7 @@
         ( MVPbkContactViewBase& aView, TInt aIndex )
     {
     TInt index = KErrNotFound;
-    
+
     // Find correct subview
     TInt subViewIndex = FindSubViewIndex( aView );
     if ( subViewIndex != KErrNotFound )
@@ -911,9 +953,9 @@
         mapping.iContactIndex = aIndex;
         // Find the composite index by comparing the two mappings
         index = iContactMapping.Find( mapping, comparisonOperator );
-        
+
         if ( index > KErrNotFound )
-            {            
+            {
             // Loop through the rest of the contacts of the subview
             // and modify their global contact mapping information
             for (TInt i = index; i < iContactMapping.Count(); ++i)
@@ -936,7 +978,7 @@
         }
     return index;
     }
-        
+
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::HandleContactAddition
 // --------------------------------------------------------------------------
@@ -945,7 +987,7 @@
         (MVPbkContactViewBase& aView, TInt aIndex)
     {
     TInt index = KErrNotFound;
-    
+
     // Find correct subview
     TInt subViewIndex = FindSubViewIndex(aView);
     if (subViewIndex != KErrNotFound)
@@ -956,7 +998,7 @@
             {
             index = err;
             }
-        else 
+        else
         	{
         	// We have to fix the indexes of all the succeeding
             // contacts in the view where the contact addition took place
@@ -971,7 +1013,7 @@
         }
     return index;
     }
-    
+
 // --------------------------------------------------------------------------
 // CVPbkCompositeContactView::DoAddObserverL
 // Notifies composite view readiness to observer.
@@ -986,9 +1028,9 @@
     if ( iObservers.FindInAddressOrder( &aObserver ) != KErrNotFound )
         {
         if( IsCompositeReady() )
-            {            
-            // If this view is ready and there was no error tell it to the observer            
-            aObserver.ContactViewReady(*this);            
+            {
+            // If this view is ready and there was no error tell it to the observer
+            aObserver.ContactViewReady(*this);
             }
         else if ( AllSubViewsKnown() )
             {
@@ -1023,7 +1065,7 @@
 void CVPbkCompositeContactView::UpdateSortOrderL()
     {
     const MVPbkFieldTypeList* sortOrder = NULL;
-    
+
     // Inspect the sort order of subviews. If all ready subviews have
     // same sort order then update composite's sort order.
     // This is done because subviews can be shared views whose sort order
@@ -1034,18 +1076,18 @@
         {
         if ( iSubViews[i]->iState == CSubViewData::EReady )
             {
-            const MVPbkFieldTypeList& curViewsOrder = 
+            const MVPbkFieldTypeList& curViewsOrder =
                     iSubViews[i]->iView->SortOrder();
             if ( sortOrder )
                 {
-                subViewsHaveSameOrder = 
+                subViewsHaveSameOrder =
                     VPbkFieldTypeList::IsSame( *sortOrder, curViewsOrder );
                 }
             sortOrder = &curViewsOrder;
             }
         }
-        
-    if ( subViewsHaveSameOrder && sortOrder && 
+
+    if ( subViewsHaveSameOrder && sortOrder &&
          !VPbkFieldTypeList::IsSame( *sortOrder, *iSortOrder ) )
         {
         CVPbkSortOrder* newOrder = CVPbkSortOrder::NewL( *sortOrder );
@@ -1053,23 +1095,23 @@
         iSortOrder = newOrder;
         }
     }
-    
+
 void CVPbkCompositeContactView::SetViewId(TInt aViewId)
     {
     iViewId = aViewId;
-    }   
+    }
 // --------------------------------------------------------------------------
 // CVPbkExternalCompositeViewPolicy::CVPbkExternalCompositeViewPolicy
 // --------------------------------------------------------------------------
 //
-CVPbkExternalCompositeViewPolicy::CVPbkExternalCompositeViewPolicy( 
+CVPbkExternalCompositeViewPolicy::CVPbkExternalCompositeViewPolicy(
         CVPbkCompositeContactView& aCompositeView,
         RPointerArray<MVPbkContactViewObserver>& aObservers )
         :   iCompositeView( aCompositeView ),
             iObservers( aObservers )
     {
     }
-    
+
 // --------------------------------------------------------------------------
 // CVPbkExternalCompositeViewPolicy::NewL
 // --------------------------------------------------------------------------
@@ -1078,8 +1120,8 @@
         CVPbkCompositeContactView& aCompositeView,
         RPointerArray<MVPbkContactViewObserver>& aObservers )
     {
-    CVPbkExternalCompositeViewPolicy* self = 
-        new ( ELeave ) CVPbkExternalCompositeViewPolicy( aCompositeView, 
+    CVPbkExternalCompositeViewPolicy* self =
+        new ( ELeave ) CVPbkExternalCompositeViewPolicy( aCompositeView,
             aObservers );
     return self;
     }
@@ -1087,7 +1129,7 @@
 // --------------------------------------------------------------------------
 // CVPbkExternalCompositeViewPolicy::~CVPbkExternalCompositeViewPolicy
 // --------------------------------------------------------------------------
-//    
+//
 CVPbkExternalCompositeViewPolicy::~CVPbkExternalCompositeViewPolicy()
     {
     iEventArray.ResetAndDestroy();
@@ -1096,20 +1138,20 @@
 // --------------------------------------------------------------------------
 // CVPbkExternalCompositeViewPolicy::HandleViewEventsL
 // --------------------------------------------------------------------------
-//    
-void CVPbkExternalCompositeViewPolicy::HandleViewEventsL( 
+//
+void CVPbkExternalCompositeViewPolicy::HandleViewEventsL(
         CVPbkEventArrayItem::TViewEventType aEvent,
         MVPbkContactViewBase& /*aSubview*/,
-        TInt aIndex, const 
+        TInt aIndex, const
         MVPbkContactLink& aContactLink )
-    {        
+    {
     // Append all view events to proper event array.
-    CVPbkEventArrayItem* item = 
+    CVPbkEventArrayItem* item =
         CVPbkEventArrayItem::NewLC( aIndex, aContactLink, aEvent );
-            
+
     iEventArray.AppendL( item );
     CleanupStack::Pop(); // item
-    
+
     // Check if the composite is up to date. Note that if the underlying
     // native store view resides in a separate process or thread,
     // this check may "accidentally" pass whilst the native view is still
@@ -1121,30 +1163,30 @@
     // The count of zero might be in severe contradiction with the
     // view events the client just received.
     // If the native view resides in the  same process, there are no risks.
-    if (iCompositeView.CompositeContactCountL() == 
+    if (iCompositeView.CompositeContactCountL() ==
             iCompositeView.ActualContactCountL() )
         {
         // Composite mapping is valid according to contact counts. Flush
         // the event cache.
         TInt eventCount( iEventArray.Count() );
-                          
+
         for( TInt i = 0; i < eventCount; ++i )
             {
             if ( iEventArray[ i ]->Event() == CVPbkEventArrayItem::ERemoved )
                 {
                 SendEventToObservers( iCompositeView, iObservers,
                     &MVPbkContactViewObserver::ContactRemovedFromView,
-                    iEventArray[ i ]->Index(), 
-                    *iEventArray[ i ]->Link() ); 
+                    iEventArray[ i ]->Index(),
+                    *iEventArray[ i ]->Link() );
                 }
             else
                 {
                 SendEventToObservers( iCompositeView, iObservers,
                     &MVPbkContactViewObserver::ContactAddedToView,
-                    iEventArray[ i ]->Index(), 
-                    *iEventArray[ i ]->Link() );                                                
-                }            
-            }                   
+                    iEventArray[ i ]->Index(),
+                    *iEventArray[ i ]->Link() );
+                }
+            }
         iEventArray.ResetAndDestroy();
         }
     }
@@ -1152,7 +1194,7 @@
 // --------------------------------------------------------------------------
 // CVPbkExternalCompositeViewPolicy::Reset
 // --------------------------------------------------------------------------
-//    
+//
 void CVPbkExternalCompositeViewPolicy::Reset()
     {
     iEventArray.ResetAndDestroy();
@@ -1161,11 +1203,11 @@
 // --------------------------------------------------------------------------
 // CVPbkExternalCompositeViewPolicy::ContactCountL
 // --------------------------------------------------------------------------
-//    
+//
 TInt CVPbkExternalCompositeViewPolicy::ContactCountL() const
     {
     TInt compositeCount = iCompositeView.CompositeContactCountL();
-    
+
     if ( compositeCount != iCompositeView.ActualContactCountL() )
         {
         // If composite count is different as the contact count in subviews
@@ -1181,7 +1223,7 @@
 // --------------------------------------------------------------------------
 // CVPbkExternalCompositeViewPolicy::InternalPolicy
 // --------------------------------------------------------------------------
-//    
+//
 TBool CVPbkExternalCompositeViewPolicy::InternalPolicy() const
     {
     return EFalse;
@@ -1191,14 +1233,14 @@
 // CVPbkInternalCompositeViewPolicy::CVPbkInternalCompositeViewPolicy
 // --------------------------------------------------------------------------
 //
-CVPbkInternalCompositeViewPolicy::CVPbkInternalCompositeViewPolicy( 
+CVPbkInternalCompositeViewPolicy::CVPbkInternalCompositeViewPolicy(
         CVPbkCompositeContactView& aCompositeView,
         RPointerArray<MVPbkContactViewObserver>& aObservers )
         :   iCompositeView( aCompositeView ),
             iObservers( aObservers )
     {
     }
-    
+
 // --------------------------------------------------------------------------
 // CVPbkInternalCompositeViewPolicy::NewL
 // --------------------------------------------------------------------------
@@ -1207,8 +1249,8 @@
         CVPbkCompositeContactView& aCompositeView,
         RPointerArray<MVPbkContactViewObserver>& aObservers )
     {
-    CVPbkInternalCompositeViewPolicy* self = 
-        new ( ELeave ) CVPbkInternalCompositeViewPolicy( aCompositeView, 
+    CVPbkInternalCompositeViewPolicy* self =
+        new ( ELeave ) CVPbkInternalCompositeViewPolicy( aCompositeView,
             aObservers );
     return self;
     }
@@ -1217,41 +1259,41 @@
 // CVPbkInternalCompositeViewPolicy::HandleViewEventsL
 // --------------------------------------------------------------------------
 //
-void CVPbkInternalCompositeViewPolicy::HandleViewEventsL( 
+void CVPbkInternalCompositeViewPolicy::HandleViewEventsL(
         CVPbkEventArrayItem::TViewEventType aEvent,
         MVPbkContactViewBase& /*aSubview*/,
-        TInt aIndex, const 
+        TInt aIndex, const
         MVPbkContactLink& aContactLink )
     {
     if ( aEvent == CVPbkEventArrayItem::ERemoved )
         {
         SendEventToObservers( iCompositeView, iObservers,
             &MVPbkContactViewObserver::ContactRemovedFromView,
-            aIndex, 
-            aContactLink ); 
+            aIndex,
+            aContactLink );
         }
     else
         {
         SendEventToObservers( iCompositeView, iObservers,
             &MVPbkContactViewObserver::ContactAddedToView,
-            aIndex, 
-            aContactLink ); 
-        }            
+            aIndex,
+            aContactLink );
+        }
     }
 
 // --------------------------------------------------------------------------
 // CVPbkInternalCompositeViewPolicy::Reset
 // --------------------------------------------------------------------------
-//    
+//
 void CVPbkInternalCompositeViewPolicy::Reset()
     {
     // No cached data to reset
     }
-    
+
 // --------------------------------------------------------------------------
 // CVPbkInternalCompositeViewPolicy::ContactCountL
 // --------------------------------------------------------------------------
-//    
+//
 TInt CVPbkInternalCompositeViewPolicy::ContactCountL() const
     {
     return iCompositeView.CompositeContactCountL();
@@ -1260,10 +1302,10 @@
 // --------------------------------------------------------------------------
 // CVPbkInternalCompositeViewPolicy::InternalPolicy
 // --------------------------------------------------------------------------
-//    
+//
 TBool CVPbkInternalCompositeViewPolicy::InternalPolicy() const
     {
     return ETrue;
     }
-    
+
 // End of File
--- a/phonebookengines/VirtualPhonebook/VPbkEng/src/CVPbkFilteredContactView.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookengines/VirtualPhonebook/VPbkEng/src/CVPbkFilteredContactView.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -35,7 +35,7 @@
 // ---------------------------------------------------------------------------
 // Event sending function for one reference parameter
 // ---------------------------------------------------------------------------
-// 
+//
 template <class NotifyFunc>
 void SendEventToObservers(MVPbkContactViewBase& aView,
                           RPointerArray<MVPbkContactViewObserver>& iObservers,
@@ -52,7 +52,7 @@
 // ---------------------------------------------------------------------------
 // Event sending functions for 3 parameters
 // ---------------------------------------------------------------------------
-// 
+//
 template <class NotifyFunc, class ParamType1, class ParamType2>
 void SendEventToObservers(MVPbkContactViewBase& aView,
                           RPointerArray<MVPbkContactViewObserver>& iObservers,
@@ -73,7 +73,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::CVPbkFilteredContactView
 // ---------------------------------------------------------------------------
-// 
+//
 CVPbkFilteredContactView::CVPbkFilteredContactView(
         MVPbkContactViewBase& aBaseView,
         MVPbkContactSelector& aContactSelector,
@@ -88,8 +88,8 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::ConstructL
 // ---------------------------------------------------------------------------
-// 
-inline void CVPbkFilteredContactView::ConstructL( 
+//
+inline void CVPbkFilteredContactView::ConstructL(
         MVPbkContactViewObserver& aObserver )
     {
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
@@ -106,7 +106,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::NewL
 // ---------------------------------------------------------------------------
-// 
+//
 EXPORT_C CVPbkFilteredContactView* CVPbkFilteredContactView::NewL(
         MVPbkContactViewBase& aBaseView,
         MVPbkContactViewObserver& aObserver,
@@ -123,12 +123,12 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::NewL
 // ---------------------------------------------------------------------------
-//     
+//
 EXPORT_C CVPbkFilteredContactView* CVPbkFilteredContactView::NewL(
         MVPbkContactViewBase& aBaseView,
         MVPbkContactViewObserver& aObserver,
         MVPbkContactSelector& aContactSelector,
-        const MVPbkFieldTypeList& aMasterFieldTypeList )    
+        const MVPbkFieldTypeList& aMasterFieldTypeList )
     {
     CVPbkFilteredContactView* self = new(ELeave) CVPbkFilteredContactView
         (aBaseView, aContactSelector, &aMasterFieldTypeList );
@@ -141,7 +141,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::~CVPbkFilteredContactView
 // ---------------------------------------------------------------------------
-// 
+//
 CVPbkFilteredContactView::~CVPbkFilteredContactView()
     {
     iObservers.Close();
@@ -153,7 +153,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::Type
 // ---------------------------------------------------------------------------
-// 
+//
 TVPbkContactViewType CVPbkFilteredContactView::Type() const
     {
     return iBaseView.Type();
@@ -162,7 +162,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::ChangeSortOrderL
 // ---------------------------------------------------------------------------
-// 
+//
 void CVPbkFilteredContactView::ChangeSortOrderL(
         const MVPbkFieldTypeList& aSortOrder )
     {
@@ -175,7 +175,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::SortOrder
 // ---------------------------------------------------------------------------
-// 
+//
 const MVPbkFieldTypeList& CVPbkFilteredContactView::SortOrder() const
     {
     return iBaseView.SortOrder();
@@ -184,7 +184,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::RefreshL
 // ---------------------------------------------------------------------------
-// 
+//
 void CVPbkFilteredContactView::RefreshL()
     {
     iBaseView.RefreshL();
@@ -193,7 +193,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::ContactCountL
 // ---------------------------------------------------------------------------
-// 
+//
 TInt CVPbkFilteredContactView::ContactCountL() const
     {
     return iContactMapping.Count();
@@ -202,7 +202,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::ContactAtL
 // ---------------------------------------------------------------------------
-// 
+//
 const MVPbkViewContact& CVPbkFilteredContactView::ContactAtL(
         TInt aIndex ) const
     {
@@ -219,7 +219,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::CreateLinkLC
 // ---------------------------------------------------------------------------
-// 
+//
 MVPbkContactLink* CVPbkFilteredContactView::CreateLinkLC( TInt aIndex ) const
     {
     __ASSERT_ALWAYS( aIndex >= 0,
@@ -235,7 +235,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::IndexOfLinkL
 // ---------------------------------------------------------------------------
-// 
+//
 TInt CVPbkFilteredContactView::IndexOfLinkL(
         const MVPbkContactLink& aContactLink ) const
     {
@@ -246,8 +246,8 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::AddObserverL
 // ---------------------------------------------------------------------------
-// 
-void CVPbkFilteredContactView::AddObserverL( 
+//
+void CVPbkFilteredContactView::AddObserverL(
         MVPbkContactViewObserver& aObserver )
     {
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
@@ -274,20 +274,20 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::DoAddObserverL
 // ---------------------------------------------------------------------------
-// 
+//
 void CVPbkFilteredContactView::DoAddObserverL(
         MVPbkContactViewObserver& aObserver )
     {
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
         ("CVPbkFilteredContactView::DoAddObserverL(0x%x)"), &aObserver);
-    
+
 // Check if aObserver is still observer of this view
     if ( iObservers.FindInAddressOrder( &aObserver ) != KErrNotFound )
         {
         if (iIsReady)
             {
             VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
-            ("CVPbkFilteredContactView::DoAddObserverL(0x%x) contact view ready"), 
+            ("CVPbkFilteredContactView::DoAddObserverL(0x%x) contact view ready"),
                 &aObserver);
 
             // If this view is ready and there was no error,
@@ -305,7 +305,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::AddObserverError
 // ---------------------------------------------------------------------------
-// 
+//
 void CVPbkFilteredContactView::AddObserverError(
         MVPbkContactViewObserver& aObserver, TInt aError )
     {
@@ -318,7 +318,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::RemoveObserver
 // ---------------------------------------------------------------------------
-// 
+//
 void CVPbkFilteredContactView::RemoveObserver(
         MVPbkContactViewObserver& aObserver )
     {
@@ -335,7 +335,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::MatchContactStore
 // ---------------------------------------------------------------------------
-// 
+//
 TBool CVPbkFilteredContactView::MatchContactStore(
         const TDesC& aContactStoreUri ) const
     {
@@ -345,7 +345,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::MatchContactStoreDomain
 // ---------------------------------------------------------------------------
-// 
+//
 TBool CVPbkFilteredContactView::MatchContactStoreDomain(
         const TDesC& aContactStoreDomain ) const
     {
@@ -355,11 +355,11 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::CreateBookmarkLC
 // ---------------------------------------------------------------------------
-// 
+//
 MVPbkContactBookmark* CVPbkFilteredContactView::CreateBookmarkLC(
         TInt aIndex ) const
     {
-    __ASSERT_ALWAYS( aIndex >= 0, 
+    __ASSERT_ALWAYS( aIndex >= 0,
         VPbkError::Panic( VPbkError::EInvalidContactIndex ) );
 
     return iBaseView.ContactAtL(iContactMapping[aIndex]).CreateBookmarkLC();
@@ -368,7 +368,7 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::IndexOfBookmarkL
 // ---------------------------------------------------------------------------
-// 
+//
 TInt CVPbkFilteredContactView::IndexOfBookmarkL(
         const MVPbkContactBookmark& aContactBookmark ) const
     {
@@ -379,54 +379,54 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::ViewFiltering
 // ---------------------------------------------------------------------------
-//         
+//
 MVPbkContactViewFiltering* CVPbkFilteredContactView::ViewFiltering()
-    {   
+    {
     if ( iMasterFieldTypeList )
         {
         return this;
-        }    
-    return NULL;        
+        }
+    return NULL;
     }
 
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::CreateFilteredViewLC
 // ---------------------------------------------------------------------------
-//    
-MVPbkContactViewBase* CVPbkFilteredContactView::CreateFilteredViewLC( 
+//
+MVPbkContactViewBase* CVPbkFilteredContactView::CreateFilteredViewLC(
         MVPbkContactViewObserver& aObserver,
         const MDesCArray& aFindWords,
         const MVPbkContactBookmarkCollection* aAlwaysIncludedContacts )
     {
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
         ("CVPbkFilteredContactView::CreateFilteredViewLC(0x%x)"), this);
-        
+
     if ( iMasterFieldTypeList )
         {
-        return CVPbkFindView::NewLC( *this, 
-                                     aObserver, 
-                                     aFindWords, 
+        return CVPbkFindView::NewLC( *this,
+                                     aObserver,
+                                     aFindWords,
                                      aAlwaysIncludedContacts,
                                      *iMasterFieldTypeList );
         }
-    return NULL;  
+    return NULL;
     }
 
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::UpdateFilterL
 // ---------------------------------------------------------------------------
-// 
-void CVPbkFilteredContactView::UpdateFilterL( 
+//
+void CVPbkFilteredContactView::UpdateFilterL(
         const MDesCArray& /*aFindWords*/,
         const MVPbkContactBookmarkCollection* /*aAlwaysIncludedContacts*/ )
     {
     User::Leave( KErrNotSupported );
     }
-    
+
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::BuildViewMappingL
 // ---------------------------------------------------------------------------
-//         
+//
 void CVPbkFilteredContactView::BuildViewMappingL()
     {
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
@@ -442,7 +442,7 @@
             iContactMapping.AppendL(i);
             }
         }
-    
+
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
         ("CVPbkFilteredContactView::BuildViewMappingL(0x%x) end"), this);
     }
@@ -450,14 +450,14 @@
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::HandleBuildViewMapping
 // ---------------------------------------------------------------------------
-//         
+//
 void CVPbkFilteredContactView::HandleBuildViewMapping()
     {
     TRAPD( res, BuildViewMappingL() );
     if ( res == KErrNone )
         {
         // Mapping was succesfully built. Send ready event
-        SendEventToObservers( *this, iObservers, 
+        SendEventToObservers( *this, iObservers,
             &MVPbkContactViewObserver::ContactViewReady );
         }
     else
@@ -468,12 +468,12 @@
             &MVPbkContactViewObserver::ContactViewError, res, EFalse );
         }
     }
-    
+
 // ---------------------------------------------------------------------------
 // From class MVPbkContactViewBase.
 // CVPbkFilteredContactView::ContactViewReady
 // ---------------------------------------------------------------------------
-//         
+//
 void CVPbkFilteredContactView::ContactViewReady( MVPbkContactViewBase& aView )
     {
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
@@ -481,7 +481,7 @@
 
     iIsReady = ETrue;
     HandleBuildViewMapping();
-    
+
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
         ("CVPbkFilteredContactView::ContactViewReady(0x%x) end"), &aView);
     }
@@ -490,8 +490,8 @@
 // From class MVPbkContactViewBase.
 // CVPbkFilteredContactView::ContactViewUnavailable
 // ---------------------------------------------------------------------------
-//         
-void CVPbkFilteredContactView::ContactViewUnavailable( 
+//
+void CVPbkFilteredContactView::ContactViewUnavailable(
         MVPbkContactViewBase& aView )
     {
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
@@ -509,8 +509,8 @@
 // From class MVPbkContactViewBase.
 // CVPbkFilteredContactView::ContactViewError
 // ---------------------------------------------------------------------------
-//         
-void CVPbkFilteredContactView::ContactViewError( MVPbkContactViewBase& aView, 
+//
+void CVPbkFilteredContactView::ContactViewError( MVPbkContactViewBase& aView,
         TInt aError, TBool aErrorNotified )
     {
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
@@ -528,14 +528,14 @@
 // From class MVPbkContactViewBase.
 // CVPbkFilteredContactView::ContactAddedToView
 // ---------------------------------------------------------------------------
-//         
+//
 void CVPbkFilteredContactView::ContactAddedToView
         (MVPbkContactViewBase& /*aView*/, TInt aIndex,
         const MVPbkContactLink& aContactLink)
     {
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
         ("CVPbkFilteredContactView::ContactAddedToView(0x%x %d)"), this, aIndex);
-    
+
     TInt filteredIndex(0);
     TRAPD( res, filteredIndex = UpdateViewMappingAfterAddingL( aIndex ) );
     if ( res == KErrNone )
@@ -545,7 +545,7 @@
             // Mapping was succesfully updated and the new contact
             // belongs to the filtered view.
             SendEventToObservers( *this, iObservers,
-                &MVPbkContactViewObserver::ContactAddedToView, filteredIndex, 
+                &MVPbkContactViewObserver::ContactAddedToView, filteredIndex,
                 aContactLink );
             }
         }
@@ -563,35 +563,58 @@
 // From class MVPbkContactViewBase.
 // CVPbkFilteredContactView::ContactRemovedFromView
 // ---------------------------------------------------------------------------
-//         
+//
 void CVPbkFilteredContactView::ContactRemovedFromView(
-        MVPbkContactViewBase& /*aView*/, TInt aIndex, 
+        MVPbkContactViewBase& /*aView*/, TInt aIndex,
         const MVPbkContactLink& aContactLink)
     {
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
         ("CVPbkFilteredContactView::ContactRemovedFromView(0x%x %d)"), this, aIndex);
-    
+
     const TInt filteredIndex = UpdateViewMappingAfterDeleting( aIndex );
     if ( filteredIndex != KErrNotFound )
         {
         // Mapping was succesfully updated and the contact removed from the mapping
         SendEventToObservers( *this, iObservers,
-            &MVPbkContactViewObserver::ContactRemovedFromView, filteredIndex, 
+            &MVPbkContactViewObserver::ContactRemovedFromView, filteredIndex,
             aContactLink );
         }
+    else
+        {
+        const TInt count = iObservers.Count();
+
+        for( TInt i = 0; i < count; i++ )
+           {
+           MVPbkContactViewObserver* observer = iObservers[i];
+         
+           TAny* extension = observer->ContactViewObserverExtension(
+                   KVPbkContactViewObserverExtension2Uid );
+
+           if( extension )
+               {
+               MVPbkContactViewObserverExtension* contactViewExtension =
+                       static_cast<MVPbkContactViewObserverExtension*>( extension );
+
+               if( contactViewExtension )
+                   {
+                   contactViewExtension->FilteredContactRemovedFromView( *this );
+                   }
+               }
+           }
+        }
 
     VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING
-        ("CVPbkFilteredContactView::ContactRemovedFromView(0x%x)"), this);    
+        ("CVPbkFilteredContactView::ContactRemovedFromView(0x%x)"), this);
     }
 
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::UpdateViewMappingAfterAdding
 //
-// Update the mapping when a new contact is added to the base view 
-// Returns its mapped index if it is added to the mapping 
+// Update the mapping when a new contact is added to the base view
+// Returns its mapped index if it is added to the mapping
 // or KErrNotFound if it's filtered out
 // ---------------------------------------------------------------------------
-//  
+//
 TInt CVPbkFilteredContactView::UpdateViewMappingAfterAddingL( TInt aBaseIndex )
 	{
 	// first update the mapping for all elements which > aBaseIndex
@@ -614,35 +637,35 @@
 		{
 		filteredIndex = KErrNotFound;
 		}
-	
+
 	return filteredIndex;
 	}
 
 // ---------------------------------------------------------------------------
 // CVPbkFilteredContactView::UpdateViewMappingAfterDeleting
 //
-// Update the mapping when a new contact is deleted from the base view 
-// Returns its mapped index if it was removed from the mapping 
+// Update the mapping when a new contact is deleted from the base view
+// Returns its mapped index if it was removed from the mapping
 // or KErrNotFound otherwise
 // ---------------------------------------------------------------------------
-//  
+//
 TInt CVPbkFilteredContactView::UpdateViewMappingAfterDeleting( TInt aBaseIndex )
 	{
     // if the contact is in mappings, filteredIndex contains its index
     // otherwise, the index of the next element greater than aIndex
 	TInt filteredIndex;
 	const TInt err = iContactMapping.FindInOrder( aBaseIndex, filteredIndex );
-	
+
     // mapping should be updated in any case even if deleted contact
     // is not in the mapping
-    // because all items in the mappings which > aIndex should be updated 
+    // because all items in the mappings which > aIndex should be updated
     for ( TInt i = filteredIndex; i < iContactMapping.Count(); ++i )
         {
         // Subtract one because one contact was deleted
         // from the list before the current index
         --iContactMapping[i];
         }
-    
+
     if ( err == KErrNone )
     	{
     	iContactMapping.Remove( filteredIndex );
@@ -651,7 +674,7 @@
     	{
     	filteredIndex = KErrNotFound;
     	}
-    
+
     return filteredIndex;
 	}
 
--- a/phonebookengines/VirtualPhonebook/VPbkSimStore/src/CContactView.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookengines/VirtualPhonebook/VPbkSimStore/src/CContactView.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -393,9 +393,14 @@
 //
 const MVPbkViewContact& CContactView::ContactAtL( TInt aIndex ) const
     {
-    __ASSERT_ALWAYS( aIndex >= 0, 
+    __ASSERT_ALWAYS( aIndex >= KErrNotFound, 
         VPbkError::Panic( VPbkError::EInvalidContactIndex ) );
-    if ( aIndex >= iNativeView->CountL() )
+
+    if( aIndex == KErrNotFound)
+	    {
+		User::Leave( KErrNotFound );	
+        }
+    else if ( aIndex >= iNativeView->CountL() )
         {
         User::Leave( KErrArgument );
         }
--- a/phonebookengines/contactsmodel/cntplsql/inc/persistencelayerimpl.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookengines/contactsmodel/cntplsql/inc/persistencelayerimpl.h	Mon Mar 15 12:39:26 2010 +0200
@@ -178,6 +178,7 @@
 	void FindAsyncInitL(const TDesC& aText,CContactItemFieldDef* aFieldDef);
 	void FindAsyncTextDefInitL(const CDesCArray& aWords,CContactTextDef* aTextDef);
 	CContactIdArray* FindAsyncL(TBool& aMoreToGo, TUint aSessionId);
+	void Reset();
 
 	TBool UsesIdentityFieldsOnly(TInt aFindFlags);
 	void ConstructBitwiseFlagsFromTextDef(TInt& aFindFlags,TInt& aIdentityColumnsCount,const CContactTextDef* aTextDef);
@@ -194,7 +195,7 @@
 	TBool PerformIdFindIterationL(CContactIdArray *aIdsFound, RSqlStatement aStatement);
 	TBool FindL(CContactIdArray *aIdsFound, const TDesC& aText,const CContactItemFieldDef *aFieldDef, RSqlStatement aStatement, TUint aSessionId);
 	CContactIdArray* FilterDatabaseL(CCntFilter& aFilter);
-	void Reset();
+
 	TInt MaximumSizeOfIdentitySearchSyntax();
 	TInt ApproximateSizeOfSearchString();
 	void doAppendFieldsToSearchString(HBufC* aOrderFields) const;
@@ -233,6 +234,9 @@
 	RSqlStatement			selectEmailStatement;
 	RSqlStatement			selectSIPStatement;
 	RSqlStatement			selectIdFromIdentityStatement;
+	
+	//The flag for RSqlstatements
+    TBool iRSqlstatementsWorking;
 	};
 
 // Forward class reference.
--- a/phonebookengines/contactsmodel/cntplsql/src/cplcollectioniterator.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookengines/contactsmodel/cntplsql/src/cplcollectioniterator.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -63,7 +63,7 @@
 	EFindCompanyNamePronunciation
 	};
 
-// Collation level that ignore accents (i.e. 'a' == 'ä').
+// Collation level that ignore accents (i.e. 'a' == '?).
 const TInt KCollationLevel= 0;
 
 //
@@ -419,7 +419,7 @@
 */
 CPlCollection::CPlCollection(CPplContactsFile& aContactsFile)
 	: 
-	iContactsFile(aContactsFile)
+	iContactsFile( aContactsFile ), iRSqlstatementsWorking( EFalse )
 	{
 	}
 	
@@ -1249,6 +1249,11 @@
 */
 void CPlCollection::Reset()
 	{
+	if ( !iRSqlstatementsWorking )
+        {
+        //If RSqlstatements was reseted, don't reset it again.
+        return;
+        }
 	// Could introduce methods specific to the find operation such that this
 	// method is called only if an asynchronous find has taken place. 
 	delete iFieldDef;
@@ -1272,6 +1277,7 @@
 	selectEmailStatement.Close();
 	selectSIPStatement.Close();
 	selectIdFromIdentityStatement.Close();
+	iRSqlstatementsWorking = EFalse;
 	}
 
 
@@ -1291,6 +1297,7 @@
 	// Persistence Layer CPlCollection is not deleted but Reset()'s the member
 	// variables for iterative FindAsyncL() calls.
 	Reset();
+	iRSqlstatementsWorking = ETrue;
 	iText = CreateFindTextL(aText);
 	iFieldDef = aFieldDef;
 	iOriginalText = aText.AllocL();
@@ -1430,7 +1437,7 @@
 	// Persistence Layer CPlCollection is not deleted but Reset()'s the member
 	// variables for iterative FindAsyncL() calls.
 	Reset();
-
+    iRSqlstatementsWorking = ETrue;
 	iFindWords = new(ELeave) CDesCArrayFlat(5);
 	iFindWords2 = new(ELeave) CDesCArrayFlat(5);
 	for(TInt loop = 0;loop < aWords.MdcaCount();++loop)
--- a/phonebookengines/contactsmodel/cntsrv/src/CCntStateMachine.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookengines/contactsmodel/cntsrv/src/CCntStateMachine.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -72,6 +72,7 @@
 void CState::TransactionStartLC(TUint aSessionId)
 	{
 	iCurrentTransactionSessionId = aSessionId;
+	iPersistenceLayer.FactoryL().GetCollectorL().Reset();
 	iPersistenceLayer.TransactionManager().StartTransactionL();
 	CleanupStack::PushL(TCleanupItem(CState::CleanupTransactionRollback, this));
 	}
@@ -1682,6 +1683,7 @@
 	if (iSessionId == 0)
 		{
 		iSessionId = aRequest->SessionId();
+		iPersistenceLayer.FactoryL().GetCollectorL().Reset();
 		iPersistenceLayer.TransactionManager().StartTransactionL();
 		iTimeOut->Start();
 		aRequest->Complete();
--- a/phonebookengines/contactsmodel/tsrc/Integration/TestStartUp/group/10003A73.txt	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookengines/contactsmodel/tsrc/Integration/TestStartUp/group/10003A73.txt	Mon Mar 15 12:39:26 2010 +0200
@@ -1,7 +1,7 @@
-# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 # All rights reserved.
 # This component and the accompanying materials are made available
-# under the terms of the License "Eclipse Public License v1.0"
+# 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".
 #
--- a/phonebookui/Phonebook/group/BCardEng.mmp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook/group/BCardEng.mmp	Mon Mar 15 12:39:26 2010 +0200
@@ -59,7 +59,7 @@
 APP_LAYER_SYSTEMINCLUDE // macro that defines the platform system includes
 
 // .def file name
-DEFFILE         BCARDENG.DEF
+DEFFILE         BCardEng.def
 
 // Dependencies to system components
 LIBRARY         euser.lib bafl.lib estor.lib    // User libraries
--- a/phonebookui/Phonebook2/BWINS/Pbk2PresentationU.DEF	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/BWINS/Pbk2PresentationU.DEF	Mon Mar 15 12:39:26 2010 +0200
@@ -168,4 +168,5 @@
 	?RefreshDataL@CPbk2ServiceManager@@QAEXXZ @ 167 NONAME ; void CPbk2ServiceManager::RefreshDataL(void)
 	?CreateContactViewForStoresLC@CPbk2ContactViewBuilder@@QBEPAVMVPbkContactViewBase@@ABVCVPbkContactStoreUriArray@@AAVMVPbkContactViewObserver@@ABVMVPbkFieldTypeList@@PAVCVPbkFieldTypeSelector@@KPAVMVPbkContactSelector@@@Z @ 168 NONAME ; class MVPbkContactViewBase * CPbk2ContactViewBuilder::CreateContactViewForStoresLC(class CVPbkContactStoreUriArray const &, class MVPbkContactViewObserver &, class MVPbkFieldTypeList const &, class CVPbkFieldTypeSelector *, unsigned long, class MVPbkContactSelector *) const
 	?CropImageL@Pbk2PresentationImageUtils@@SAXAAVCFbsBitmap@@W4TCroppingMode@1@ABVTSize@@@Z @ 169 NONAME ; void Pbk2PresentationImageUtils::CropImageL(class CFbsBitmap &, enum Pbk2PresentationImageUtils::TCroppingMode, class TSize const &)
+	?FieldIndexOfStoreField@CPbk2PresentationContactFieldCollection@@QBEHH@Z @ 170 NONAME ; int CPbk2PresentationContactFieldCollection::FieldIndexOfStoreField(int) const
 
--- a/phonebookui/Phonebook2/BWINS/pbk2spbcontentprovideru.def	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/BWINS/pbk2spbcontentprovideru.def	Mon Mar 15 12:39:26 2010 +0200
@@ -4,4 +4,17 @@
 	?NewL@CSpbContentProvider@@SAPAV1@AAVCVPbkContactManager@@AAVCPbk2StoreManager@@J@Z @ 3 NONAME ; class CSpbContentProvider * CSpbContentProvider::NewL(class CVPbkContactManager &, class CPbk2StoreManager &, long)
 	?CreateServiceIconLC@CSpbContentProvider@@QAEPAVCGulIcon@@ABVTPbk2IconId@@@Z @ 4 NONAME ; class CGulIcon * CSpbContentProvider::CreateServiceIconLC(class TPbk2IconId const &)
 	?GetContentL@CSpbContentProvider@@QAEXAAVMVPbkContactLink@@AAPAVHBufC16@@AAVTPbk2IconId@@AAW4TSpbContentType@1@@Z @ 5 NONAME ; void CSpbContentProvider::GetContentL(class MVPbkContactLink &, class HBufC16 * &, class TPbk2IconId &, enum CSpbContentProvider::TSpbContentType &)
+	?Text@CSpbContactDataModel@@QBE?AVTPtrC16@@W4TTextTypes@1@@Z @ 6 NONAME ; class TPtrC16 CSpbContactDataModel::Text(enum CSpbContactDataModel::TTextTypes) const
+	?ExternalizeL@CSpbContactDataModel@@QBEXAAVRWriteStream@@@Z @ 7 NONAME ; void CSpbContactDataModel::ExternalizeL(class RWriteStream &) const
+	?NewL@CSpbContactDataModel@@SAPAV1@AAVCVPbkContactManager@@AAVCCoeEnv@@HPAVMPbk2ClipListBoxText@@@Z @ 8 NONAME ; class CSpbContactDataModel * CSpbContactDataModel::NewL(class CVPbkContactManager &, class CCoeEnv &, int, class MPbk2ClipListBoxText *)
+	?SetDataL@CSpbContactDataModel@@QAEXABVCPbk2PresentationContact@@PBVCPbk2IconArray@@@Z @ 9 NONAME ; void CSpbContactDataModel::SetDataL(class CPbk2PresentationContact const &, class CPbk2IconArray const *)
+	?ContactLink@CSpbContactDataModel@@QAEPAVMVPbkContactLink@@XZ @ 10 NONAME ; class MVPbkContactLink * CSpbContactDataModel::ContactLink(void)
+	?PresentationFieldIndex@CSpbContactDataModel@@QAEHH@Z @ 11 NONAME ; int CSpbContactDataModel::PresentationFieldIndex(int)
+	?Reset@CSpbContactDataModel@@QAEXXZ @ 12 NONAME ; void CSpbContactDataModel::Reset(void)
+	?SetClipListBoxText@CSpbContactDataModel@@QAEXPAVMPbk2ClipListBoxText@@@Z @ 13 NONAME ; void CSpbContactDataModel::SetClipListBoxText(class MPbk2ClipListBoxText *)
+	?UpdateIconsL@CSpbContactDataModel@@QAEXABVCPbk2IconArray@@@Z @ 14 NONAME ; void CSpbContactDataModel::UpdateIconsL(class CPbk2IconArray const &)
+	?IsEmpty@CSpbContactDataModel@@QAEHXZ @ 15 NONAME ; int CSpbContactDataModel::IsEmpty(void)
+	?InternalizeL@CSpbContactDataModel@@QAEXAAVRReadStream@@@Z @ 16 NONAME ; void CSpbContactDataModel::InternalizeL(class RReadStream &)
+	?Data@CSpbContactDataModel@@QBE?AVTPtrC8@@W4TBinaryTypes@1@@Z @ 17 NONAME ; class TPtrC8 CSpbContactDataModel::Data(enum CSpbContactDataModel::TBinaryTypes) const
+	?ListBoxModel@CSpbContactDataModel@@QAEAAVMDesC16Array@@XZ @ 18 NONAME ; class MDesC16Array & CSpbContactDataModel::ListBoxModel(void)
 
--- a/phonebookui/Phonebook2/Commands/inc/CPbk2PrependCmd.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/Commands/inc/CPbk2PrependCmd.h	Mon Mar 15 12:39:26 2010 +0200
@@ -88,7 +88,7 @@
         void ExecuteDlgL();
         CPbk2PresentationContact* CreatePresentationContactLC();
         TInt ToStoreFieldIndexL( TInt aPresIndex );
-        TInt MaxLengthOfEditorL( TInt aFieldIndex );
+        TInt MaxLengthOfEditorL( TInt aFieldStoreIndex );
                         
     private: // Data
         /// Ref: UI control
--- a/phonebookui/Phonebook2/Commands/rss/Pbk2Commands.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/Commands/rss/Pbk2Commands.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -110,7 +110,7 @@
             control = AVKON_NOTE
                 {
                 layout = EProgressLayout;
-                singular_label = qtn_phob_note_clearing_pb;
+                singular_label = qtn_fldr_deleting_wait_note;
                 imagefile = AVKON_ICON_FILE;
                 imageid   = qgn_note_erased;
                 imagemask = qgn_note_erased_mask;
--- a/phonebookui/Phonebook2/Commands/src/CPbk2AiwInterestItemCall.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/Commands/src/CPbk2AiwInterestItemCall.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -528,10 +528,6 @@
                     iAppUi->ApplicationServices().ContactManager().FieldTypes());
             
             CleanupStack::PushL( actionTypeSelector );
-            iSelector->SetDefaultPrioritiesLC
-                        ( defaultPrioritiesArray,
-                          *aStoreContact,
-                          VPbkFieldTypeSelectorFactory::EVOIPCallSelector );
             }
         // Normal voice calls
 		else
@@ -542,12 +538,14 @@
                     iAppUi->ApplicationServices().ContactManager().FieldTypes());
             
             CleanupStack::PushL( actionTypeSelector );
-            iSelector->SetDefaultPrioritiesLC
-                        ( defaultPrioritiesArray,
-                          *aStoreContact,
-                          VPbkFieldTypeSelectorFactory::EVoiceCallSelector );
             }
         
+        // Set default according to priority rule
+        iSelector->SetDefaultPrioritiesLC
+		            ( defaultPrioritiesArray,
+		              *aStoreContact );
+
+        
         params.iCommMethod = action;
         params.SetDefaultPriorities( defaultPrioritiesArray );
 
--- a/phonebookui/Phonebook2/Commands/src/CPbk2PrependCmd.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/Commands/src/CPbk2PrependCmd.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -170,8 +170,7 @@
         // get field text (phone no)
         TInt fieldIndex( iUiControl->FocusedFieldIndex() );
         MVPbkStoreContactField* field =
-            iStoreContact->Fields().FieldAtLC(
-                ToStoreFieldIndexL( fieldIndex ) );
+            iStoreContact->Fields().FieldAtLC( fieldIndex );
         TPtrC phoneNo =
             MVPbkContactFieldTextData::Cast( field->FieldData() ).Text();
         HBufC* number = HBufC::NewLC( KBufferSize );
@@ -261,16 +260,22 @@
 // CPbk2PrependCmd::MaxLengthOfEditorL
 // --------------------------------------------------------------------------
 //
-TInt CPbk2PrependCmd::MaxLengthOfEditorL( TInt aFieldIndex )
+TInt CPbk2PrependCmd::MaxLengthOfEditorL( TInt aFieldStoreIndex )
     {
     TInt maxLength( KErrNotFound );
     CPbk2PresentationContact* presentationContact =
         CreatePresentationContactLC();
+    
+    TInt fieldIndex = KErrNotFound;
+     
+    fieldIndex = presentationContact->PresentationFields().FieldIndexOfStoreField( aFieldStoreIndex );
 
     __ASSERT_DEBUG( presentationContact->PresentationFields().FieldCount() >
-                    aFieldIndex, Panic( EMaxLengthOfEditorL_OOB ) );
+                       fieldIndex, Panic( EMaxLengthOfEditorL_OOB ) );
+    
+    __ASSERT_DEBUG( fieldIndex > KErrNotFound, Panic( EMaxLengthOfEditorL_OOB ) );
 
-    maxLength = presentationContact->PresentationFields().At( aFieldIndex ).
+    maxLength = presentationContact->PresentationFields().At( fieldIndex ).
                 MaxDataLength();
 
     CleanupStack::PopAndDestroy( presentationContact );
--- a/phonebookui/Phonebook2/CommandsExtension/inc/CPbk2MergeContactsCmd.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/CommandsExtension/inc/CPbk2MergeContactsCmd.h	Mon Mar 15 12:39:26 2010 +0200
@@ -277,15 +277,18 @@
     /// Own: Waiting note
     MPbk2ProcessDecorator* iWaitDecorator;
     
-	/// Own: string for ending note
+    /// Own: string for ending note
     HBufC* iFirstContactString;
-	
-	/// Own: string for ending note
+    
+    /// Own: string for ending note
     HBufC* iSecondContactString;
-	
-	/// Own: string for ending note
+    	
+    /// Own: string for ending note
     HBufC* iMergedContactString;
     
+    /// Own: Timer used to delay contact's deletion after new contact creation
+    /// it ensures that all filtered views are updated before deleting contacts
+    RTimer iTimer;
     };
 
 #endif // CPBK2MERGECONTACTSCMD_H
--- a/phonebookui/Phonebook2/CommandsExtension/inc/CPbk2SetImageCmd.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/CommandsExtension/inc/CPbk2SetImageCmd.h	Mon Mar 15 12:39:26 2010 +0200
@@ -26,6 +26,7 @@
 #include <MMGFetchVerifier.h>             // MMGFetchVerifier
 #include <MediaFileTypes.hrh>
 #include <badesca.h>
+#include <AknProgressDialog.h>
 
 
 // FORWARD DECLARATIONS
@@ -39,8 +40,9 @@
  */
 NONSHARABLE_CLASS(CPbk2SetImageCmd) : 
         public CPbk2ImageCmdBase,
+        public MProgressDialogCallback,
         private MPbk2ImageSetObserver,
-        private MMGFetchVerifier
+        private MMGFetchVerifier        
     {
     public:  // Constructors and destructor
         /**
@@ -74,10 +76,12 @@
                 MPbk2ImageOperation& aOperation,
                 TInt aError);
 
+    private: // from MProgressDialogCallback
+        void DialogDismissedL( TInt aButtonId );
+        
     private: // from MMGFetchVerifier
         TBool VerifySelectionL(
-                const MDesCArray* aSelectedFiles);
-        
+                const MDesCArray* aSelectedFiles);        
     private:  // Implementation
         CPbk2SetImageCmd(
                 MPbk2ContactUiControl& aUiControl);
@@ -87,13 +91,20 @@
         void SetImageRefL(
                 const TDesC& aFileName);
         
+        TBool DoVerifySelectionL(
+                const MDesCArray* aSelectedFiles);
+        void ShowErrorNoteL();
+        
     private:    // Data
         /// Own: image set operation
         MPbk2ImageOperation* iImageOperation;
         /// Own: wait note dialog
         CAknWaitDialog* iWaitNote;
         /// Own: DRM support
-        CPbk2DrmManager* iDrmManager;
+        CPbk2DrmManager* iDrmManager;        
+        TBool iVerificationFailed;
+        TBool iImageSetFailed;
+        TInt iImageSetError;
     };
 
 #endif // CPBK2SETIMAGECMD_H
--- a/phonebookui/Phonebook2/CommandsExtension/src/CPbk2AssignSpeedDialCmd.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/CommandsExtension/src/CPbk2AssignSpeedDialCmd.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -379,17 +379,7 @@
 MVPbkStoreContactField* CPbk2AssignSpeedDialCmd::FocusedFieldLC
         ( MVPbkStoreContact& aStoreContact )
     {
-    TInt index = KErrNotFound;
-    CPbk2PresentationContact* presentationContact =
-        CPbk2PresentationContact::NewL( aStoreContact,
-            iAppServices->FieldProperties() );
-    CleanupStack::PushL( presentationContact );
-
-    index = presentationContact->PresentationFields().StoreIndexOfField(
-                iUiControl->FocusedFieldIndex() );
-
-    CleanupStack::PopAndDestroy( presentationContact );
-
+    TInt index = iUiControl->FocusedFieldIndex();
     if ( index != KErrNotFound )
         {
         // Use FieldAtLC to avoid the unvalidity of the field after new
--- a/phonebookui/Phonebook2/CommandsExtension/src/CPbk2CopyAddressToClipboardCmd.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/CommandsExtension/src/CPbk2CopyAddressToClipboardCmd.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -230,18 +230,12 @@
     ( MVPbkStoreContact& aStoreContact )
     {
     TInt index = KErrNotFound;
-    CPbk2PresentationContact* presentationContact = 
-        CPbk2PresentationContact::NewL( aStoreContact,
-            iAppServices->FieldProperties() );
-    CleanupStack::PushL( presentationContact );
-
+    
     if (iUiControl)
         {
-        index = presentationContact->PresentationFields().StoreIndexOfField( 
-                iUiControl->FocusedFieldIndex() );
+        index = iUiControl->FocusedFieldIndex();
         }
-    CleanupStack::PopAndDestroy( presentationContact );
-    
+
     if ( index != KErrNotFound )
         {
         // Use FieldAtLC to avoid the unvalidity of the field after new
--- a/phonebookui/Phonebook2/CommandsExtension/src/CPbk2CopyNumberToClipboardCmd.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/CommandsExtension/src/CPbk2CopyNumberToClipboardCmd.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -211,19 +211,7 @@
 MVPbkStoreContactField* CPbk2CopyNumberToClipboardCmd::FocusedFieldLC
     ( MVPbkStoreContact& aStoreContact )
     {
-    TInt index = KErrNotFound;
-    CPbk2PresentationContact* presentationContact = 
-        CPbk2PresentationContact::NewL( aStoreContact,
-            iAppServices->FieldProperties() );
-    CleanupStack::PushL( presentationContact );
-
-    if (iUiControl)
-        {
-        index = presentationContact->PresentationFields().StoreIndexOfField( 
-                iUiControl->FocusedFieldIndex() );
-        }
-    CleanupStack::PopAndDestroy( presentationContact );
-    
+    TInt index = iUiControl->FocusedFieldIndex();
     if ( index != KErrNotFound )
         {
         // Use FieldAtLC to avoid the unvalidity of the field after new
--- a/phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeConflict.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeConflict.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -114,25 +114,26 @@
     iFieldSecond = &aFieldSecond;
     
     const MVPbkFieldType* fieldType = aFieldFirst.BestMatchingFieldType();
-    __ASSERT_ALWAYS( fieldType, Panic( EPbk2FieldTypeNotExists ) );
-
-    if( fieldType->NonVersitType() == EVPbkNonVersitTypeCodImage )
-        {
-        iConflictType = EPbk2ConflictTypeImage;
-        }
-    else
-        {
-        TArray<TVPbkFieldVersitProperty> versitPropArr = fieldType->VersitProperties();
-        TInt count = versitPropArr.Count();
-    
-        for( TInt idx = 0; idx < count; idx++ )
+    if ( fieldType )
+        {            
+        if( fieldType->NonVersitType() == EVPbkNonVersitTypeCodImage )
+            {
+            iConflictType = EPbk2ConflictTypeImage;
+            }
+        else
             {
-            TVPbkFieldVersitProperty versitProp = versitPropArr[idx];
-            if( versitProp.Name() == EVPbkVersitNameLOGO ||
-                versitProp.Name() == EVPbkVersitNamePHOTO )
+            TArray<TVPbkFieldVersitProperty> versitPropArr = fieldType->VersitProperties();
+            TInt count = versitPropArr.Count();
+        
+            for( TInt idx = 0; idx < count; idx++ )
                 {
-                iConflictType = EPbk2ConflictTypeImage;
-                break;
+                TVPbkFieldVersitProperty versitProp = versitPropArr[idx];
+                if( versitProp.Name() == EVPbkVersitNameLOGO ||
+                    versitProp.Name() == EVPbkVersitNamePHOTO )
+                    {
+                    iConflictType = EPbk2ConflictTypeImage;
+                    break;
+                    }
                 }
             }
         }
@@ -248,16 +249,19 @@
 void CPbk2MergeConflict::CustomizeTextValueL( const MVPbkStoreContactField& aField, TDes& aBuf )
     {
     const MVPbkFieldType* fieldType= aField.BestMatchingFieldType();
-    TVPbkNonVersitFieldType nonVersitType = fieldType->NonVersitType();
-    if ( nonVersitType == EVPbkNonVersitTypeRingTone )
+    if ( fieldType )
         {
-        TParsePtr fileName = TParsePtr( aBuf );
-        if ( fileName.NamePresent() )
+        TVPbkNonVersitFieldType nonVersitType = fieldType->NonVersitType();
+        if ( nonVersitType == EVPbkNonVersitTypeRingTone )
             {
-            TPtrC namePtr = fileName.Name();
-            HBufC* name = namePtr.AllocL();
-            aBuf.Copy( *name );
-            delete name;
+            TParsePtr fileName = TParsePtr( aBuf );
+            if ( fileName.NamePresent() )
+                {
+                TPtrC namePtr = fileName.Name();
+                HBufC* name = namePtr.AllocL();
+                aBuf.Copy( *name );
+                delete name;
+                }
             }
         }
     }
--- a/phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeContactsCmd.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeContactsCmd.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -76,6 +76,8 @@
 
 const TInt KFirstContact = 0;
 const TInt KSecondContact = 1;
+const TInt KAmountToMerge = 2;
+const TInt KDeletionDelay = 1000000; // 1s
 
 _LIT( KLocalStore, "cntdb://c:contacts.cdb" );
 
@@ -129,6 +131,8 @@
         }
 
     CleanAfterFetching();
+    iTimer.Cancel();
+    iTimer.Close();
     delete iFirstContactString;
     delete iSecondContactString;
     delete iMergedContactString;
@@ -202,6 +206,7 @@
     iContactManager = &Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager();
     iAppServices = CPbk2ApplicationServices::InstanceL();
     iPhotoConflictIndex = KErrNotFound;
+    User::LeaveIfError( iTimer.CreateLocal() );
     }
     
 // --------------------------------------------------------------------------
@@ -487,19 +492,23 @@
     for ( TInt i(0); i < fields.FieldCount(); ++i )
         {
         MVPbkStoreContactField& field = fields.FieldAt( i );
-        if ( field.BestMatchingFieldType()->FieldTypeResId() == R_VPBK_FIELD_TYPE_FIRSTNAME )
+        const MVPbkFieldType* fieldType = field.BestMatchingFieldType();
+        if ( fieldType )
             {
-            MVPbkContactFieldData& data = field.FieldData();
-            __ASSERT_DEBUG( data.DataType() == EVPbkFieldStorageTypeText, Panic( EPbk2WrongTypeOfData ) );
-            MVPbkContactFieldTextData& textData = MVPbkContactFieldTextData::Cast( data );
-            firstName.Set( textData.Text() );
-            }
-        else if ( field.BestMatchingFieldType()->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() );        
+            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() );        
+                }
             }
         }
     
@@ -640,6 +649,7 @@
     params.iResId = R_PBK2_MULTIPLE_ENTRY_FETCH_NO_GROUPS_DLG;
     params.iCbaId = R_PBK2_SOFTKEYS_MERGE_BACK_MARK;
     params.iNaviPaneId = R_PBK2_MERGE_CONTACTS_FETCH_NAVILABEL;
+    params.iMinSelection = KAmountToMerge;
     
     CPbk2StorePropertyArray& storeProperties =
         Phonebook2::Pbk2AppUi()->ApplicationServices().StoreProperties();
@@ -753,10 +763,19 @@
 //
 void CPbk2MergeContactsCmd::StartNext( TPhase aPhase )
     {
-    __ASSERT_DEBUG( !IsActive(), Panic( EPbk2WronglyActivated ));    
-    iNextPhase = aPhase;    
-    TRequestStatus* status = &iStatus;
-    User::RequestComplete(status, KErrNone);
+    __ASSERT_DEBUG( !IsActive(), Panic( EPbk2WronglyActivated )); 
+    
+    iNextPhase = aPhase;
+    
+    if ( iNextPhase == EPhaseGetGroups )
+        {
+        iTimer.After( iStatus, KDeletionDelay ); 
+        }
+    else
+        {
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, KErrNone );
+        }
     SetActive();
     }
 
@@ -1236,19 +1255,22 @@
             conflict.GetFieldsL( firstField, secondField );
             
             const MVPbkFieldType* fieldType = firstField->BestMatchingFieldType();
-            TArray<TVPbkFieldVersitProperty> versitPropArr = fieldType->VersitProperties();
-            TInt count = versitPropArr.Count();
-        
-            for( TInt idx = 0; idx < count; idx++ )
+            if ( fieldType )
                 {
-                TVPbkFieldVersitProperty versitProp = versitPropArr[idx];
-                if( versitProp.Name() == EVPbkVersitNamePHOTO )
+                TArray<TVPbkFieldVersitProperty> versitPropArr = fieldType->VersitProperties();
+                TInt count = versitPropArr.Count();
+            
+                for( TInt idx = 0; idx < count; idx++ )
                     {
-                    if ( firstField->FieldData().DataType() == EVPbkFieldStorageTypeBinary && 
-                            secondField->FieldData().DataType() == EVPbkFieldStorageTypeBinary )
+                    TVPbkFieldVersitProperty versitProp = versitPropArr[idx];
+                    if( versitProp.Name() == EVPbkVersitNamePHOTO )
                         {
-                        iPhotoConflictIndex = i;
-                        break;
+                        if ( firstField->FieldData().DataType() == EVPbkFieldStorageTypeBinary && 
+                                secondField->FieldData().DataType() == EVPbkFieldStorageTypeBinary )
+                            {
+                            iPhotoConflictIndex = i;
+                            break;
+                            }
                         }
                     }
                 }
--- a/phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeResolver.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/CommandsExtension/src/CPbk2MergeResolver.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -285,17 +285,18 @@
         const MVPbkStoreContactField& aField )
     {
     const MVPbkFieldType* fieldType = aField.BestMatchingFieldType();
-    __ASSERT_ALWAYS( fieldType, Panic( EPbk2FieldTypeNotExists ) );
-    TArray<TVPbkFieldVersitProperty> versitProp = fieldType->VersitProperties();
-    
-    TBool topContact = EFalse;
+    TBool topContact( EFalse );
     
-    for( TInt idx = 0; idx < versitProp.Count() && !topContact; idx++ )
+    if ( fieldType )
         {
-        TVPbkFieldVersitProperty versitPropFirst = versitProp[idx];
-        if( versitPropFirst.Name() == EVPbkVersitNameTopContact )
+        TArray<TVPbkFieldVersitProperty> versitProp = fieldType->VersitProperties();        
+        for( TInt idx = 0; idx < versitProp.Count() && !topContact; idx++ )
             {
-            topContact = ETrue;
+            TVPbkFieldVersitProperty versitPropFirst = versitProp[idx];
+            if( versitPropFirst.Name() == EVPbkVersitNameTopContact )
+                {
+                topContact = ETrue;
+                }
             }
         }
     
@@ -524,18 +525,20 @@
 TBool CPbk2MergeResolver::AddressField( const MVPbkStoreContactField& aField )
     {
     const MVPbkFieldType* fieldType = aField.BestMatchingFieldType();
-    __ASSERT_ALWAYS( fieldType, Panic( EPbk2FieldTypeNotExists ) );
-    TArray<TVPbkFieldVersitProperty> versitProp = fieldType->VersitProperties();
-    
-    TBool address = EFalse;
+    TBool address( EFalse );
     
-    for( TInt idx = 0; idx < versitProp.Count() && !address; idx++ )
+    if ( fieldType )
         {
-        TVPbkFieldVersitProperty versitPropFirst = versitProp[idx];
-        if( versitPropFirst.Name() == EVPbkVersitNameADR ||
-            versitPropFirst.Name() == EVPbkVersitNameGEO )
+        TArray<TVPbkFieldVersitProperty> versitProp = fieldType->VersitProperties();
+        
+        for( TInt idx = 0; idx < versitProp.Count() && !address; idx++ )
             {
-            address = ETrue;
+            TVPbkFieldVersitProperty versitPropFirst = versitProp[idx];
+            if( versitPropFirst.Name() == EVPbkVersitNameADR ||
+                versitPropFirst.Name() == EVPbkVersitNameGEO )
+                {
+                address = ETrue;
+                }
             }
         }
     
@@ -630,30 +633,29 @@
         const MVPbkStoreContactField& aFieldFirst,
         const MVPbkStoreContactField& aFieldSecond )
     {
+    TBool retCompare( EFalse );
     const MVPbkFieldType* fieldTypeFirst = aFieldFirst.BestMatchingFieldType();
-    __ASSERT_ALWAYS( fieldTypeFirst, Panic( EPbk2FieldTypeNotExists ) );
-    
-    const MVPbkFieldType* fieldTypeSecond = aFieldSecond.BestMatchingFieldType();
-    __ASSERT_ALWAYS( fieldTypeSecond, Panic( EPbk2FieldTypeNotExists ) );
-    
-    TArray<TVPbkFieldVersitProperty> versitPropArrFirst = fieldTypeFirst->VersitProperties();
-    TArray<TVPbkFieldVersitProperty> versitPropArrSecond = fieldTypeSecond->VersitProperties();
+    const MVPbkFieldType* fieldTypeSecond = aFieldSecond.BestMatchingFieldType();    
     
-    TInt countFirst = versitPropArrFirst.Count();
-    TInt countSecond = versitPropArrSecond.Count();
-
-    TBool retCompare = EFalse;
-    
-    for( TInt idxFirst = 0; idxFirst < countFirst && !retCompare; idxFirst++ )
+    if ( fieldTypeFirst && fieldTypeSecond )
         {
-        TVPbkFieldVersitProperty versitPropFirst = versitPropArrFirst[idxFirst];
-        for( TInt idxSecond = 0; idxSecond < countSecond; idxSecond++ )
+        TArray<TVPbkFieldVersitProperty> versitPropArrFirst = fieldTypeFirst->VersitProperties();
+        TArray<TVPbkFieldVersitProperty> versitPropArrSecond = fieldTypeSecond->VersitProperties();
+        
+        TInt countFirst = versitPropArrFirst.Count();
+        TInt countSecond = versitPropArrSecond.Count();    
+        
+        for( TInt idxFirst = 0; idxFirst < countFirst && !retCompare; idxFirst++ )
             {
-            TVPbkFieldVersitProperty versitPropSecond = versitPropArrSecond[idxSecond];
-            if( versitPropFirst.SubField() == versitPropSecond.SubField() )
+            TVPbkFieldVersitProperty versitPropFirst = versitPropArrFirst[idxFirst];
+            for( TInt idxSecond = 0; idxSecond < countSecond; idxSecond++ )
                 {
-                retCompare = ETrue;
-                break;
+                TVPbkFieldVersitProperty versitPropSecond = versitPropArrSecond[idxSecond];
+                if( versitPropFirst.SubField() == versitPropSecond.SubField() )
+                    {
+                    retCompare = ETrue;
+                    break;
+                    }
                 }
             }
         }
@@ -669,13 +671,16 @@
         const MVPbkStoreContactField& aFieldFirst,
         const MVPbkStoreContactField& aFieldSecond )
     {
-    const MVPbkFieldType* fieldTypeFirst = aFieldFirst.BestMatchingFieldType();
-    __ASSERT_ALWAYS( fieldTypeFirst, Panic( EPbk2FieldTypeNotExists ) );
+    TBool isSame( EFalse );    
+    const MVPbkFieldType* fieldTypeFirst = aFieldFirst.BestMatchingFieldType();  
+    const MVPbkFieldType* fieldTypeSecond = aFieldSecond.BestMatchingFieldType();    
     
-    const MVPbkFieldType* fieldTypeSecond = aFieldSecond.BestMatchingFieldType();
-    __ASSERT_ALWAYS( fieldTypeSecond, Panic( EPbk2FieldTypeNotExists ) );
+    if ( fieldTypeFirst && fieldTypeSecond )
+        {
+        isSame = fieldTypeFirst->IsSame( *fieldTypeSecond );
+        }
     
-    return fieldTypeFirst->IsSame( *fieldTypeSecond );
+    return isSame;
     }
 
 // --------------------------------------------------------------------------
--- a/phonebookui/Phonebook2/CommandsExtension/src/CPbk2RemoveSpeedDialCmd.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/CommandsExtension/src/CPbk2RemoveSpeedDialCmd.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -255,14 +255,12 @@
         {    
         TInt index = KErrNotFound;
         TInt err = KErrNone;
+        
         if (iUiControl)
-            {            
-            // Convert presentation index to store index.
-            TRAP( err, 
-                index = ToStoreFieldIndexL( iUiControl->FocusedFieldIndex(), 
-                	iStoreContact ) );
+            {
+            index = iUiControl->FocusedFieldIndex();
             }
-
+    
         if ( index != KErrNotFound )
             {
             MVPbkStoreContactField& field = 
@@ -405,10 +403,9 @@
     const MVPbkStoreContact* storeContact =
             iUiControl->FocusedStoreContact();
 
-    // Convert presentation index to store index.
-    TInt index( ToStoreFieldIndexL(
-                    iUiControl->FocusedFieldIndex(),
-                    storeContact ) );
+   
+    TInt index = iUiControl->FocusedFieldIndex();
+
 
     if ( index != KErrNotFound )
         {
--- a/phonebookui/Phonebook2/CommandsExtension/src/CPbk2SetImageCmd.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/CommandsExtension/src/CPbk2SetImageCmd.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -31,6 +31,7 @@
 #include <RPbk2LocalizedResourceFile.h>
 #include <CPbk2DriveSpaceCheck.h>
 #include <CPbk2AppUiBase.h>
+#include <Pbk2CmdExtRes.rsg>
 
 // Virtual Phonebook
 #include <MVPbkStoreContact.h>
@@ -131,18 +132,22 @@
 TBool CPbk2SetImageCmd::ExecuteCommandL()
     {
     TBool result = EFalse;
+    iImageSetFailed = EFalse;
     Cancel();
     
     // fetch image from media gallery
     CDesCArray* selectedFile = new(ELeave) CDesCArrayFlat( 1 );
     CleanupStack::PushL( selectedFile );
-    TBool res( EFalse );
+    TBool res( EFalse );    
+    
     res = MGFetchL( *selectedFile, EImageFile, EFalse, this );
     
-    if ( res && selectedFile->Count() > 0 )
+    if ( !iVerificationFailed && res && selectedFile->Count() > 0 )
         {
         iWaitNote = new(ELeave) CAknWaitDialog( 
                 reinterpret_cast<CEikDialog**>( &iWaitNote ), ETrue );
+        
+        iWaitNote->SetCallback( this );
         iWaitNote->ExecuteLD( R_QTN_GEN_NOTE_FETCHING );
        
         TPtrC fileName = (*selectedFile)[0];
@@ -193,13 +198,13 @@
     {
     __ASSERT_DEBUG( &aOperation == iImageOperation, 
         Panic( EPanicPreCond_Pbk2ImageSetFailed ) );
-
+       
     delete iImageOperation;
     iImageOperation = NULL;
-
-	DismissWaitNote();
-
-	ProcessDismissed( aError );
+    
+    iImageSetFailed = ETrue;
+    iImageSetError = aError;
+	DismissWaitNote();			
     }
 
 // --------------------------------------------------------------------------
@@ -216,18 +221,60 @@
 			{
 			delete iWaitNote;
 			iWaitNote = NULL;
+			
+			if( iImageSetFailed )
+                {
+                ShowErrorNoteL();
+                }
 			}
 		}
 	}
 
 // --------------------------------------------------------------------------
+// CPbk2SetImageCmd::DialogDismissedL
+// --------------------------------------------------------------------------
+//  
+void CPbk2SetImageCmd::DialogDismissedL( TInt /*aButtonId*/ )
+    {
+    if( iImageSetFailed )
+        {
+        ShowErrorNoteL();
+        }
+    }
+
+// --------------------------------------------------------------------------
 // CPbk2SetImageCmd::VerifySelectionL
 // --------------------------------------------------------------------------
 //	
 TBool CPbk2SetImageCmd::VerifySelectionL
         (const MDesCArray* aSelectedFiles)
-    {
-    TBool result = EFalse;
+    {    
+    iVerificationFailed = EFalse;
+    TBool ret = ETrue;
+    
+    TRAPD( err, ret = DoVerifySelectionL( aSelectedFiles ) );
+    
+    if( err != KErrNone )
+        {
+        iVerificationFailed = ETrue;
+        ShowErrorNoteL();    
+        } 
+      
+    // Selection is always accepted if the image is not drm protected.
+    // Image fetch dialog functionality is always same in spite of error 
+    // type (DRM check, ImageDecoder, etc. errors) Dialog is always closed.    
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// CPbk2SetImageCmd::DoVerifySelectionL
+// --------------------------------------------------------------------------
+//  
+TBool CPbk2SetImageCmd::DoVerifySelectionL
+        (const MDesCArray* aSelectedFiles)
+    {    
+    TBool ret = ETrue;
+    
     if ( aSelectedFiles && aSelectedFiles->MdcaCount() > 0 )
         {
         // DRM for phonebook image fetch
@@ -235,27 +282,44 @@
         TBool isProtected( ETrue );
         User::LeaveIfError( 
             iDrmManager->IsProtectedFile( fileName, isProtected ) );
+        
         if ( isProtected )
-            {
-			RPbk2LocalizedResourceFile resFile( *CCoeEnv::Static() );
-			resFile.OpenLC( 
-			    KPbk2RomFileDrive, 
-				KDC_RESOURCE_FILES_DIR, 
-				Pbk2PresentationUtils::PresentationResourceFile() );
+            {        
+            ret = EFalse; 
+            RPbk2LocalizedResourceFile resFile( *CCoeEnv::Static() );
+            resFile.OpenLC( 
+                KPbk2RomFileDrive, 
+                KDC_RESOURCE_FILES_DIR, 
+                Pbk2PresentationUtils::PresentationResourceFile() );
             // show user copyright note
             HBufC* prompt = 
                 CCoeEnv::Static()->AllocReadResourceLC( R_PBK2_QTN_DRM_NOT_ALLOWED );
             CAknInformationNote* dlg = new(ELeave) CAknInformationNote( ETrue );
             dlg->ExecuteLD( *prompt );
             CleanupStack::PopAndDestroy( 2 ); // resFile, prompt
-            }
-        else
-            {
-            result = ETrue;
-            }
-        }
-        
-    return result;
+            }                
+        }   
+    
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// CPbk2SetImageCmd::ShowErrorNoteL
+// --------------------------------------------------------------------------
+//
+void CPbk2SetImageCmd::ShowErrorNoteL()
+    {               
+    HBufC* prompt = StringLoader::LoadLC( R_QTN_ALBUM_ERR_FORMAT_UNKNOWN );
+    CAknInformationNote* dlg = new ( ELeave ) CAknInformationNote( ETrue );
+    dlg->ExecuteLD( *prompt );
+    CleanupStack::PopAndDestroy( prompt );
+    
+    if( iImageSetFailed )
+        {        
+        ProcessDismissed( iImageSetError );
+        iImageSetFailed = EFalse;      
+        iImageSetError = KErrNone;
+        }      
     }
 
 // --------------------------------------------------------------------------
@@ -324,6 +388,7 @@
         }
     
     TBool result( EFalse );
+            
     // run image fetch dialog
     TRAPD(error, result = MGFetch::RunL( aSelectedFiles, 
             aMediaType, 
--- a/phonebookui/Phonebook2/EABI/Pbk2PresentationU.DEF	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/EABI/Pbk2PresentationU.DEF	Mon Mar 15 12:39:26 2010 +0200
@@ -213,4 +213,5 @@
 	_ZN19CPbk2ServiceManager12RefreshDataLEv @ 212 NONAME
 	_ZNK23CPbk2ContactViewBuilder28CreateContactViewForStoresLCERK25CVPbkContactStoreUriArrayR24MVPbkContactViewObserverRK18MVPbkFieldTypeListP22CVPbkFieldTypeSelectormP20MVPbkContactSelector @ 213 NONAME
 	_ZN26Pbk2PresentationImageUtils10CropImageLER10CFbsBitmapNS_13TCroppingModeERK5TSize @ 214 NONAME
+	_ZNK39CPbk2PresentationContactFieldCollection22FieldIndexOfStoreFieldEi @ 215 NONAME
 
--- a/phonebookui/Phonebook2/EABI/pbk2spbcontentprovideru.def	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/EABI/pbk2spbcontentprovideru.def	Mon Mar 15 12:39:26 2010 +0200
@@ -4,4 +4,19 @@
 	_ZN19CSpbContentProvider14RemoveObserverER27MSpbContentProviderObserver @ 3 NONAME
 	_ZN19CSpbContentProvider19CreateServiceIconLCERK11TPbk2IconId @ 4 NONAME
 	_ZN19CSpbContentProvider4NewLER19CVPbkContactManagerR17CPbk2StoreManagerl @ 5 NONAME
+	_ZN20CSpbContactDataModel11ContactLinkEv @ 6 NONAME
+	_ZN20CSpbContactDataModel12InternalizeLER11RReadStream @ 7 NONAME
+	_ZN20CSpbContactDataModel12ListBoxModelEv @ 8 NONAME
+	_ZN20CSpbContactDataModel12UpdateIconsLERK14CPbk2IconArray @ 9 NONAME
+	_ZN20CSpbContactDataModel18SetClipListBoxTextEP20MPbk2ClipListBoxText @ 10 NONAME
+	_ZN20CSpbContactDataModel22PresentationFieldIndexEi @ 11 NONAME
+	_ZN20CSpbContactDataModel4NewLER19CVPbkContactManagerR7CCoeEnviP20MPbk2ClipListBoxText @ 12 NONAME
+	_ZN20CSpbContactDataModel5ResetEv @ 13 NONAME
+	_ZN20CSpbContactDataModel7IsEmptyEv @ 14 NONAME
+	_ZN20CSpbContactDataModel8SetDataLERK24CPbk2PresentationContactPK14CPbk2IconArray @ 15 NONAME
+	_ZNK20CSpbContactDataModel12ExternalizeLER12RWriteStream @ 16 NONAME
+	_ZNK20CSpbContactDataModel4DataENS_12TBinaryTypesE @ 17 NONAME
+	_ZNK20CSpbContactDataModel4TextENS_10TTextTypesE @ 18 NONAME
+	_ZTI20CSpbContactDataModel @ 19 NONAME
+	_ZTV20CSpbContactDataModel @ 20 NONAME
 
--- a/phonebookui/Phonebook2/GroupExtension/rss/Pbk2GroupUiRes.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/GroupExtension/rss/Pbk2GroupUiRes.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -11,15 +11,56 @@
 *
 * Contributors:
 *
-* Description:  Phonebook 2 Group UI Extension resources.
+* Description:  Phonebook 2 Group UI Extension touchable UI resources.
 *
 */
 
 
-#ifdef RD_SCALABLE_UI_V2
-    #include "PguTouchableResources.rss"
-#else
-    #include "pgunontouchableresources.rss"
-#endif // RD_SCALABLE_UI_V2
+// INCLUDES
+#include <avkon.loc>
+#include <uikon.rh>
+#include <eikon.rh>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.mbg>
+#include <AvkonIcons.hrh>
+#include <Pbk2UIControls.rsg>
+#include <Pbk2UIControls.rh>
+#include <Pbk2UIControls.hrh>
+#include <Pbk2Commands.hrh>
+#include <Pbk2Commands.rsg>
+#include <phonebook2.loc>
+#include "Pbk2GroupUi.hrh"
+#include "Pbk2UIExtension.rh"
+#include "Pbk2ExtensionUID.h"
+#include <Pbk2IconInfo.rh>
+#include <Pbk2Icons.hrh>
+#include <Pbk2UID.h>
+#include <Pbk2IconId.rh>
+#include <Pbk2ViewGraph.rh>
+#include <Pbk2ViewId.hrh>
+#include <Pbk2ViewInfo.hrh>
+
+// --------------------------------------------------------------------------
+// Resource identifier
+// --------------------------------------------------------------------------
+//
+NAME P2GU   // From Phonebook 2 Group UI
+
+// --------------------------------------------------------------------------
+// Standard resource signature
+// --------------------------------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE { }
+
+// Additional include files
+#include "PguInformation.rss"
+#include "PguTextBuffers.rss"
+#include "PguCbaResources.rss"
+#include "PguListView.rss"
+#include "PguMembersListViewBase.rss"
+#include "PguMembersListView.rss"
+#include "PguMembersFetchDlg.rss"
+#include "PguDialogResources.rss"
 
 // End of File
--- a/phonebookui/Phonebook2/GroupExtension/rss/PguListView.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/GroupExtension/rss/PguListView.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -160,37 +160,6 @@
         };
 	defaultIconId = PHONEBOOK2_ICON_ID {};
     }       
-
-// --------------------------------------------------------------------------
-// Group List View's stylus popup menu
-// --------------------------------------------------------------------------
-//
-RESOURCE STYLUS_POPUP_MENU r_phonebook2_groupslist_stylus_menu
-    {
-    items =
-        {
-        STYLUS_POPUP_MENU_ITEM
-            {
-            txt = qtn_phob_longtap_message;
-            command = EPbk2CmdWriteGroup;
-            },
-        STYLUS_POPUP_MENU_ITEM
-            {
-            txt = qtn_phob_longtap_delete;
-            command = EPbk2CmdRemoveGroup;
-            },
-        STYLUS_POPUP_MENU_ITEM
-            {
-            txt = qtn_phob_longtap_rename;
-            command = EPbk2CmdRenameGroup;
-            },
-        STYLUS_POPUP_MENU_ITEM
-            {
-            txt = qtn_phob_longtap_tone;
-            command = EPbk2CmdSetToneToGroup;
-            }
-        };
-    }
     
 // --------------------------------------------------------------------------
 // Group display order definition
--- a/phonebookui/Phonebook2/GroupExtension/rss/PguMembersListView.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/GroupExtension/rss/PguMembersListView.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2007 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"
@@ -11,14 +11,16 @@
 *
 * Contributors:
 *
-* Description:  Phonebook 2 Group UI Extension group members view resources.
+* Description: 
+*     This file contains all the resources for Touch UI enabled Phonebook 2
+*     groups list view.
 *
 */
 
 
-// --------------------------------------------------------------------------
+// ---------------------------------------------------------
 // Groups Members View's control
-// --------------------------------------------------------------------------
+// ---------------------------------------------------------
 //
 RESOURCE PBK2_CONTACT_CONTROL r_pbk2_groupmembers_control
     {
@@ -26,7 +28,7 @@
             KPbk2ContactViewListControlFindBox;
     listbox = LISTBOX
         {
-        flags = EAknListBoxLoopScrolling|EAknListBoxMarkableList|EAknListBoxShiftEnterMarks;
+        flags = EAknListBoxStylusMarkableList|EAknListBoxLoopScrolling;        
         };
     iconArray = R_PBK2_FIELDTYPE_ICONS;
     emptyIconId = PHONEBOOK2_ICON_ID
@@ -34,14 +36,7 @@
         ownerUid = KPbk2UID3;
         id = EPbk2qgn_prop_nrtyp_empty;
         };
-    defaultIconId = PHONEBOOK2_ICON_ID {};
+	defaultIconId = PHONEBOOK2_ICON_ID {};
     }
 
-
-// --------------------------------------------------------------------------
-// Dummy Groups Members View's stylus popup menus. Not used, but IDs needed.
-// --------------------------------------------------------------------------
-//
-RESOURCE STYLUS_POPUP_MENU r_phonebook2_groupmembers_unmarked_stylus_menu {}
-
 // End of File
--- a/phonebookui/Phonebook2/GroupExtension/src/CPguDeleteGroupCmd.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/GroupExtension/src/CPguDeleteGroupCmd.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -466,23 +466,11 @@
     TInt queryResult = 0;
     MVPbkContactLinkArray* items = iContactGroup->ItemsContainedLC();
 
-    // The query depends on whether there are contacts in the group
-    if ( items->Count() > 0 )
-        {
-        HBufC* prompt = StringLoader::LoadLC(
-            R_PBK2_QTN_FLDR_DEL_FULL_GROUPS_QUERY );
-        CAknQueryDialog* dlg = CAknQueryDialog::NewL();
-        queryResult = dlg->ExecuteLD(
-            R_PBK2_GENERAL_CONFIRMATION_QUERY, *prompt );
-        CleanupStack::PopAndDestroy( prompt );
-        }
-    else
-        {
-        CPbk2GeneralConfirmationQuery* query =
-            CPbk2GeneralConfirmationQuery::NewL();
-        queryResult = query->ExecuteLD(
-            *iContactGroup, R_QTN_QUERY_COMMON_CONF_DELETE, MPbk2ContactNameFormatter::EPreserveAllOriginalSpaces );
-        }
+    // Show the query "Delete X” "( X is the group name ).
+    CPbk2GeneralConfirmationQuery* query =
+        CPbk2GeneralConfirmationQuery::NewL();
+    queryResult = query->ExecuteLD(
+        *iContactGroup, R_QTN_QUERY_COMMON_CONF_DELETE, MPbk2ContactNameFormatter::EPreserveAllOriginalSpaces );
 
     if ( queryResult )
         {
--- a/phonebookui/Phonebook2/GroupExtension/src/CPguGroupMembersView.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/GroupExtension/src/CPguGroupMembersView.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -1924,35 +1924,13 @@
 void CPguGroupMembersView::CGroupMembersAllGroupsReady::HandlePointerEventL
         ( const TPointerEvent& aPointerEvent )
     {
-
-
     if ( AknLayoutUtils::PenEnabled() )
         {
         if ( iPointerEventInspector->FocusableItemPointed() && iContainer && !(iControl->ContactsMarked()))
             {
             iContainer->LongTapDetectorL().PointerEventL( aPointerEvent );
             }
-            
-
-
-        if ( iControl->NumberOfContacts()==0) 
-            {       
-            if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
-                {
-                MTouchFeedback* feedback = MTouchFeedback::Instance();
-                if ( feedback )
-                    {
-                    feedback->InstantFeedback( ETouchFeedbackBasic );
-                    }
-                }
-            else if  ( aPointerEvent.iType == TPointerEvent::EButton1Up )       
-                {
-                ShowContextMenuL();
-                }
-            }
-
         }
-
     }
     
     
--- a/phonebookui/Phonebook2/GroupExtension/src/CPguGroupNameQueryDlg.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/GroupExtension/src/CPguGroupNameQueryDlg.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -167,24 +167,11 @@
 //
 void CPguGroupNameQueryDlg::UpdateGroupTitleL()
     {
-    TBool found = EFalse;
     HBufC* groupTitle;
-    for ( TInt number = 1; !found; ++number )
-        {
-        groupTitle = StringLoader::LoadLC
-            ( R_PHONEBOOK2_QTN_FLDR_DEFAULT_GROUP_NAME, number );
-
-        // Convert the digits if necessary
-        TPtr ptr = groupTitle->Des();
-        AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );
-
-        if ( !ContainsL( *groupTitle ) )
-            {
-            Text().Copy( *groupTitle );
-            found = ETrue;
-            }
-        CleanupStack::PopAndDestroy( groupTitle );
-        }
+    TInt newGroupNumber = iGroupsListView.ContactCountL() + 1;
+    groupTitle = StringLoader::LoadL( R_PHONEBOOK2_QTN_FLDR_DEFAULT_GROUP_NAME, newGroupNumber );
+    Text().Copy( *groupTitle );
+    delete groupTitle;
     }
 
 // --------------------------------------------------------------------------
--- a/phonebookui/Phonebook2/GroupExtension/src/CPguGroupView.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/GroupExtension/src/CPguGroupView.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -507,7 +507,11 @@
                 }
             break;
             }
-
+        case R_PHONEBOOK2_INFO_MENU:
+            {
+            // menu always visible in group view
+            break;
+            }
         default:
             {
             // Phonebook 2 menu filtering happens in Commands
--- a/phonebookui/Phonebook2/NamesListExtension/inc/Pbk2NamesListExView.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/NamesListExtension/inc/Pbk2NamesListExView.h	Mon Mar 15 12:39:26 2010 +0200
@@ -184,6 +184,7 @@
                 TAny* aSelf );
         void DimItem( CEikMenuPane* aMenuPane, TInt aCmd );
         void ShowContextMenuL();
+        // void ProcessEmptyAreaClickL();        
         void AddCommandItemsToContainerL();
         TBool NeedToHideToolbar(TInt aCurrentCommand);
         TBool IsPhoneMemoryUsedL() const;
--- a/phonebookui/Phonebook2/NamesListExtension/inc/cpbk2mycard.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/NamesListExtension/inc/cpbk2mycard.h	Mon Mar 15 12:39:26 2010 +0200
@@ -84,6 +84,10 @@
     	 */
     	MVPbkStoreContact* MyCardStoreContact() const;
     	
+    	/**
+    	 * Contact manager used by mycard
+    	 */
+    	CVPbkContactManager& ContactManager();
         
     private: // From MVPbkSingleContactLinkOperationObserver
         void VPbkSingleContactLinkOperationComplete(
--- a/phonebookui/Phonebook2/NamesListExtension/inc/cpbk2openmycardcmd.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/NamesListExtension/inc/cpbk2openmycardcmd.h	Mon Mar 15 12:39:26 2010 +0200
@@ -25,6 +25,10 @@
 
 // FORWARD DECLARATIONS
 class MPbk2ContactUiControl;
+class CPbk2FieldPropertyArray;
+class CPbk2StoreSpecificFieldPropertyArray;
+class CPbk2PresentationContact;
+class CPbk2MyCard;
 
 //Cca
 class MCCAParameter;
@@ -49,6 +53,7 @@
          */
         static CPbk2OpenMyCardCmd* NewL(
             MCCAConnection*& aCCAConnection,
+            CPbk2MyCard* aMyCard,
             MPbk2ContactUiControl* aUiControl = NULL );
 
         /**
@@ -67,6 +72,7 @@
     private: //Construction
         CPbk2OpenMyCardCmd(
             MPbk2ContactUiControl* aUiControl,
+            CPbk2MyCard* aMyCard,
             MCCAConnection*& aCCAConnection );
         void ConstructL();
 
@@ -74,6 +80,11 @@
 
         void LaunchCcaL(); // Sync
 		void IssueRequest();
+		
+		/**
+		 * Create presentation contact from mycard.
+		 */
+		CPbk2PresentationContact* PresentationContactL();
 
     private: // From CActive
         void RunL();
@@ -100,6 +111,14 @@
         TProcessState iState;
         /// Requested view uid for CCA 
         TUid iViewUid;
+        /// Not own. My card instance
+        CPbk2MyCard* iMyCard;
+        /// Own. Field properties for presentation contact
+        CPbk2FieldPropertyArray* iFieldProperties;
+        /// Own. Field properties for presentation contact
+        CPbk2StoreSpecificFieldPropertyArray* iSpecificFieldProperties;
+        /// Own. Presentation contact of mycard
+        CPbk2PresentationContact* iPresentationContact;
     };
 
 #endif // CPBK2OPENMYCARDCMD_H
--- a/phonebookui/Phonebook2/NamesListExtension/rss/Pbk2ExNamesListRes.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/NamesListExtension/rss/Pbk2ExNamesListRes.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -27,6 +27,7 @@
 #include <phonebook2ece.loc>
 #include <phonebook2ece.mbg>
 #include <phonebook2.loc>
+#include <VPbkFieldType.rh>
 
 //pbk2
 #include <Pbk2UIExtension.rh>
@@ -404,4 +405,43 @@
         };
     }
 
+// --------------------------------------------------------------------------
+// r_pbk2_mycard_field_clip_selector
+// --------------------------------------------------------------------------
+//
+RESOURCE VPBK_FIELD_TYPE_SELECTOR r_pbk2_mycard_field_clip_selector
+{
+    versitProperties =
+    {
+        // email fields
+        VBK_FIELD_VERSIT_PROPERTY
+        {
+            name = EVPbkVersitNameEMAIL;
+        },
+        // SIP fields (POC, SWIS, VoIP, etc.)
+        VBK_FIELD_VERSIT_PROPERTY
+        {
+            name = EVPbkVersitNameX;
+            extensionName = "X-SIP";
+        },
+        // xSP fields
+        VBK_FIELD_VERSIT_PROPERTY
+        {
+            name = EVPbkVersitNameIMPP;
+        },
+        // telephone
+        VBK_FIELD_VERSIT_PROPERTY
+        {
+            name = EVPbkVersitNameTEL;
+        },
+        // telephone
+        VBK_FIELD_VERSIT_PROPERTY
+        {
+            name = EVPbkVersitNameX;
+            extensionName = "X-ASSISTANT-TEL";
+        }
+    };
+}
+
+
 // EOF
--- a/phonebookui/Phonebook2/NamesListExtension/src/NamesListExView.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/NamesListExtension/src/NamesListExView.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -939,6 +939,15 @@
                 ShowContextMenuL();
                 break;
                 }
+#if 0            	
+            case EEventEmptyAreaClicked:  //An empty area of non-empty listbox was clicked 
+            case EEventEmptyListClicked:  //An empty listbox was clicked                
+                {
+                ProcessEmptyAreaClickL();
+                break;
+                }     
+#endif                
+
             case EEventItemClicked: //Happens after focus changed
             break;
 
@@ -993,10 +1002,20 @@
 
     if ( AknLayoutUtils::PenEnabled() )
         {
-        if ( iContainer && !iControl->ContactsMarked() && iPointerEventInspector->FocusableItemPointed() )
-            {
-            iContainer->LongTapDetectorL().PointerEventL( aPointerEvent );
-            }
+// Longtap detection is currently not needed here 
+#if 0  
+    // If at some point we need to enable longtap detection here, then need
+    // to implement a way to prevent passing the event to longtap detector 
+    // when a command item is tapped. Because command items should not have the 
+    // longtap animation.
+    if ( iContainer 
+            && <tapped item is not a command item> // <-- implement this logic by any means 
+            && !iControl->ContactsMarked() && iPointerEventInspector->FocusableItemPointed() )
+        {
+        iContainer->LongTapDetectorL().PointerEventL( aPointerEvent );
+        }
+#endif  
+            
 // ece has stylus menu for empty state, no need to initiate touch feedback
 // context menu disabled as well
 #if 0
@@ -1069,6 +1088,35 @@
         }
     }
 
+#if 0
+// --------------------------------------------------------------------------
+// CPbk2NamesListExView::ProcessEmptyAreaClickL
+// --------------------------------------------------------------------------
+//
+void CPbk2NamesListExView::ProcessEmptyAreaClickL()
+    {
+    if ( iStylusPopupMenuLaunched )
+         {
+         // Absorb EButton1Up event if we already launched the stylus
+         // popup menu
+         iStylusPopupMenuLaunched = EFalse;
+         }
+    else if ( !iPointerEventInspector->SearchFieldPointed() &&
+              !iSelectionModifierUsed )
+        {
+        if ( iControl->NumberOfContacts() == 0 ) 
+            {
+            MTouchFeedback* feedback = MTouchFeedback::Instance();
+            if ( feedback )
+                   {
+                   feedback->InstantFeedback( ETouchFeedbackBasic );
+                   }			
+            HandleCommandL( EPbk2CmdCreateNew );
+            }
+        }    
+    }
+#endif
+
 // --------------------------------------------------------------------------
 // CPbk2NamesListExView::GetViewSpecificMenuFilteringFlagsL
 // --------------------------------------------------------------------------
@@ -1652,7 +1700,7 @@
         const TPoint& /*aPenEventLocation*/,
         const TPoint& /*aPenEventScreenLocation*/ )
     {
-//no implementation needed for single tap
+//no implementation needed currently
     }
 
 // --------------------------------------------------------------------------
--- a/phonebookui/Phonebook2/NamesListExtension/src/NamesListUiExtensionPlugin.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/NamesListExtension/src/NamesListUiExtensionPlugin.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -587,8 +587,9 @@
         case EPbk2CmdOpenMyCard:    // fallthrough
         case EPbk2CmdSelectMyCard:
 			{
-            result = CPbk2OpenMyCardCmd::NewL( 
+			result = CPbk2OpenMyCardCmd::NewL( 
                 const_cast<MCCAConnection*&>( iCCAConnection ),
+                iNamesListExViewRef ? iNamesListExViewRef->MyCard() : NULL,
                 &aUiControl );
 			break;
 			}
--- a/phonebookui/Phonebook2/NamesListExtension/src/cpbk2deletemycardcmd.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/NamesListExtension/src/cpbk2deletemycardcmd.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -240,7 +240,13 @@
     TInt /*aStepSize*/,
     TInt aError )
     {
-    ProcessDismissed( aError );
+    ProcessDismissed( aError );   
+    
+    if ( aError == KErrInUse )
+        {                                                             
+        CCoeEnv::Static()->HandleError( KErrInUse );    
+        }
+    
     return EFalse;
     }
 
--- a/phonebookui/Phonebook2/NamesListExtension/src/cpbk2mycard.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/NamesListExtension/src/cpbk2mycard.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -110,8 +110,6 @@
 //
 CPbk2MyCard::~CPbk2MyCard()
     {
-	
-	
 	delete iThumbBitmap;
 	delete iMyCardStoreContact;
 	delete iImageManager;
@@ -123,7 +121,6 @@
         {
         iPhoneStore->Close(*this);
         }
-    
     }
 
 // --------------------------------------------------------------------------
@@ -219,6 +216,15 @@
     }
 
 // --------------------------------------------------------------------------
+// CPbk2MyCard::ContactManager
+// --------------------------------------------------------------------------
+//
+CVPbkContactManager& CPbk2MyCard::ContactManager()
+    {
+    return *iContactManager;
+    }
+	
+// --------------------------------------------------------------------------
 // CPbk2MyCard::VPbkSingleContactLinkOperationComplete
 // --------------------------------------------------------------------------
 //
--- a/phonebookui/Phonebook2/NamesListExtension/src/cpbk2openmycardcmd.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/NamesListExtension/src/cpbk2openmycardcmd.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -18,16 +18,27 @@
 
 // INCLUDE FILES
 #include "cpbk2openmycardcmd.h"
+#include "cpbk2mycard.h"
 #include <CPbk2NamesListControl.h>
 #include <MPbk2CommandObserver.h>
 #include <MVPbkBaseContact.h>
 #include <ccappmycardpluginuids.hrh>
+#include <spbcontactdatamodel.h>
+#include <pbk2exnameslistres.rsg>
+#include <CPbk2FieldPropertyArray.h>
+#include <CPbk2StoreSpecificFieldPropertyArray.h>
+#include <CPbk2PresentationContact.h>
+#include <CPbk2StorePropertyArray.h>
+#include <MVPbkContactStoreProperties.h>
+#include <MVPbkContactStore.h>
 
 //Cca
 #include <mccaparameter.h>
 #include <mccaconnection.h>
 #include <ccafactory.h>
 
+#include <s32mem.h>
+
 // Debugging headers
 #include <Pbk2Debug.h>
 #include <Pbk2Profile.h>
@@ -38,11 +49,13 @@
 //
 CPbk2OpenMyCardCmd::CPbk2OpenMyCardCmd(
     MPbk2ContactUiControl* aUiControl,
+    CPbk2MyCard* aMyCard,
     MCCAConnection*& aCCAConnection ) :
         CActive( EPriorityStandard ),
         iUiControl( aUiControl ),
         iConnectionRef(aCCAConnection),
-        iViewUid( TUid::Uid( KCCAMyCardPluginImplmentationUid ) ) // default mycard view
+        iViewUid( TUid::Uid( KCCAMyCardPluginImplmentationUid ) ), // default mycard view
+        iMyCard( aMyCard )
     {
     CActiveScheduler::Add( this );
     }
@@ -61,6 +74,9 @@
         {
         iUiControl->RegisterCommand( NULL );
         }
+    delete iPresentationContact;
+    delete iSpecificFieldProperties;
+    delete iFieldProperties;
     }
 
 // --------------------------------------------------------------------------
@@ -69,10 +85,11 @@
 //
 CPbk2OpenMyCardCmd* CPbk2OpenMyCardCmd::NewL(
     MCCAConnection*& aCCAConnection,
+    CPbk2MyCard* aMyCard,
     MPbk2ContactUiControl* aUiControl )
     {
-    CPbk2OpenMyCardCmd* self = new ( ELeave ) CPbk2OpenMyCardCmd
-        ( aUiControl, aCCAConnection );
+    CPbk2OpenMyCardCmd* self = new ( ELeave ) CPbk2OpenMyCardCmd(
+        aUiControl, aMyCard, aCCAConnection );
     CleanupStack::PushL( self );
     self->ConstructL();
     CleanupStack::Pop( self );
@@ -146,6 +163,41 @@
     CleanupClosePushL( *parameter );
     parameter->SetConnectionFlag( MCCAParameter::ENormal );
     parameter->SetLaunchedViewUid( iViewUid );
+    
+    if( iMyCard )
+        {
+        // Speed up mycard launching by constructing the view model here.
+        // This information is not mandatory for mycard launching however.
+        CBufFlat* buffer = CBufFlat::NewL( KKilo );
+        CleanupStack::PushL( buffer );
+        RBufWriteStream stream( *buffer );
+        CleanupClosePushL( stream );
+
+        // create model and dump it into stream
+        CSpbContactDataModel* model = CSpbContactDataModel::NewL( 
+            iMyCard->ContactManager(), *CCoeEnv::Static(), 
+            R_PBK2_MYCARD_FIELD_CLIP_SELECTOR );
+        CleanupStack::PushL( model );
+
+        if( iMyCard->MyCardState() == CPbk2MyCard::EExisting )
+            {
+            // preset contact data model to contain my cards data.
+            CPbk2PresentationContact* contact = PresentationContactL();
+            if( contact )
+                {
+                model->SetDataL( *contact, NULL );
+                }
+            }
+        model->ExternalizeL( stream );
+        CleanupStack::PopAndDestroy( 2, &stream ); // model
+
+        // set model dump as parameter
+        TPtrC8 buf( buffer->Ptr( 0 ) );
+        TPtrC16 data( (TUint16*)buf.Ptr(), ( buf.Size() + 1 ) / 2 );
+        parameter->SetContactDataFlag( MCCAParameter::EContactDataModel );
+        parameter->SetContactDataL( data );
+        CleanupStack::PopAndDestroy( buffer ); 
+        }
 
     // Sync call
     iConnectionRef->LaunchAppL( *parameter );
@@ -166,6 +218,59 @@
     SetActive();
     }
 
+// ---------------------------------------------------------------------------
+// CPbk2OpenMyCardCmd::PresentationContactL
+// ---------------------------------------------------------------------------
+//
+CPbk2PresentationContact* CPbk2OpenMyCardCmd::PresentationContactL()
+    {
+    if( !iPresentationContact )
+        {
+        if( !iMyCard )
+            {
+            return NULL;
+            }
+            
+        MVPbkStoreContact* storeContact = iMyCard->MyCardStoreContact();
+        if( !storeContact )
+            {
+            return NULL;
+            }
+        
+        const MVPbkContactStoreProperties& storeProperties =
+            storeContact->ParentStore().StoreProperties();
+        const MVPbkFieldTypeList& supportedFieldTypes =
+            storeProperties.SupportedFields();
+    
+        if( !iFieldProperties )
+            {
+            iFieldProperties = CPbk2FieldPropertyArray::NewL(
+                supportedFieldTypes, CCoeEnv::Static()->FsSession() );
+            }
+    
+        // Create a field property list of the supported
+        // field types of the used store
+        CPbk2StorePropertyArray* pbk2StoreProperties = CPbk2StorePropertyArray::NewL();
+        CleanupStack::PushL( pbk2StoreProperties );
+    
+        if( !iSpecificFieldProperties )
+            {
+            iSpecificFieldProperties = CPbk2StoreSpecificFieldPropertyArray::NewL(
+                *iFieldProperties,
+                *pbk2StoreProperties,
+                supportedFieldTypes,
+                storeContact->ParentStore() );
+            }
+    
+        iPresentationContact = CPbk2PresentationContact::NewL( 
+            *storeContact, *iSpecificFieldProperties );
+        
+        CleanupStack::PopAndDestroy( pbk2StoreProperties );
+        }
+    return iPresentationContact;
+    }
+
+
 // --------------------------------------------------------------------------
 // CPbk2OpenMyCardCmd::IssueRequest
 // --------------------------------------------------------------------------
--- a/phonebookui/Phonebook2/Presentation/src/CPbk2ImageReader.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/Presentation/src/CPbk2ImageReader.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -23,7 +23,6 @@
 // From Phonebook2
 #include "MPbk2ImageReaderObserver.h"
 #include "TPbk2ImageManagerParams.h"
-#include <Pbk2CmdExtRes.rsg>
 #include "Pbk2PresentationUtils.h"
 
 // From Virtual Phonebook
@@ -106,7 +105,6 @@
     return (((aVal%aDiv)>0) ? (TInt)((aVal/aDiv)+1):(TInt)(aVal/aDiv));
     }
 
-
 /**
  * Calculates the the size based on divider. Uses Ceil function for ceiling
  * the calculated size.
@@ -165,7 +163,6 @@
 
     return resSize;
     }
-
 }  // namespace
 
 
@@ -230,12 +227,13 @@
     InitReadL(aParams);
     delete iImageDecoder;
     iImageDecoder = NULL;
-    iImageDecoder = CImageDecoder::FileNewL(iFsSession, aFileName);
+               
+    TRAPD( err, iImageDecoder = CImageDecoder::FileNewL( iFsSession, aFileName ) );
 
     // Make the open phase asynchronous as well by signaling own iStatus
     iState = EStateOpenImage;
     TRequestStatus* status = &iStatus;
-    User::RequestComplete(status, KErrNone);
+    User::RequestComplete( status, err );            
     SetActive();
     }
 
@@ -249,12 +247,12 @@
     InitReadL(aParams);
     delete iImageDecoder;
     iImageDecoder = NULL;
-    iImageDecoder = CImageDecoder::DataNewL(iFsSession, aBuffer);
-
+    TRAPD( err, iImageDecoder = CImageDecoder::DataNewL( iFsSession, aBuffer ) );
+    
     // Make the open phase asynchronous as well by signaling own iStatus
     iState = EStateOpenImage;
     TRequestStatus* status = &iStatus;
-    User::RequestComplete(status, KErrNone);
+    User::RequestComplete( status, err );
     SetActive();
     }
 
@@ -285,16 +283,12 @@
     iMimeString = HBufC8::NewL(KMaxMimeTypeLength);
     TPtr8 mimePtr = iMimeString->Des();
     
-    TRAPD( err, CImageDecoder::GetMimeTypeFileL(iFsSession, aFileName, mimePtr) );
-    	
-    if( err == KErrNotFound )
+    TRAPD( err, CImageDecoder::GetMimeTypeFileL( iFsSession, aFileName, mimePtr ) );
+    	    
+    if( err != KErrNone )
         {
-        HBufC* prompt = StringLoader::LoadLC( R_QTN_ALBUM_ERR_FORMAT_UNKNOWN );
-        CAknInformationNote* dlg = new ( ELeave ) CAknInformationNote( ETrue );
-        dlg->ExecuteLD( *prompt );
-        CleanupStack::PopAndDestroy( prompt );
-        User::Leave( err );
-        }    		
+        iObserver.ImageReadFailed( *this, err );           
+        }    
     }
 
 // --------------------------------------------------------------------------
@@ -307,7 +301,12 @@
     iMimeString = NULL;
     iMimeString = HBufC8::NewL(KMaxMimeTypeLength);
     TPtr8 mimePtr = iMimeString->Des();
-    CImageDecoder::GetMimeTypeDataL(aBuffer, mimePtr);
+    TRAPD( err, CImageDecoder::GetMimeTypeDataL( aBuffer, mimePtr ) );
+        
+    if( err != KErrNone )
+        {
+        iObserver.ImageReadFailed( *this, err );           
+        }    
     }
 
 // --------------------------------------------------------------------------
@@ -393,7 +392,6 @@
     SetActive();
     }
 
-
 // --------------------------------------------------------------------------
 // CPbk2ImageReader::CropImageToSquareL
 // --------------------------------------------------------------------------
@@ -405,12 +403,11 @@
 		{
         Pbk2PresentationImageUtils::CropImageL( 
                 *iBitmap, 
-                Pbk2PresentationImageUtils::ELandscapeOptimizedCropping, 
+                Pbk2PresentationImageUtils::EOptimizedCropping, 
                 iParams.iSize );
 		}
 	}
 
-
 // --------------------------------------------------------------------------
 // CPbk2ImageReader::ScaleBitmapL
 // --------------------------------------------------------------------------
@@ -524,6 +521,7 @@
 void CPbk2ImageReader::RunL()
     {
     TInt status = iStatus.Int();
+        
     switch (status)
         {
         case KErrNone:
@@ -541,7 +539,7 @@
             break;
             }
         default:
-            {
+            {                              
             // Jpeg2000 decoder might need more heap than Phonebook can 
             // provide, the situation is handled so, that "Feature not 
             // supported" -note is shown if memory runs out when decoding 
@@ -555,6 +553,7 @@
             // image is tried to be decoded.
             if ( status == KErrNoMemory )            
                 {
+                
                 TUid imageType;
                 TUid imageSubType;
                 iImageDecoder->ImageType(iParams.iFrameNumber, 
@@ -565,7 +564,8 @@
                     {
                     status = KErrNotSupported;
                     }
-                }            
+                }                   
+            
             iObserver.ImageReadFailed(*this, status);
             break;
             }
--- a/phonebookui/Phonebook2/Presentation/src/CPbk2ImageWriterBase.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/Presentation/src/CPbk2ImageWriterBase.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -321,7 +321,7 @@
     
     Pbk2PresentationImageUtils::CropImageL( 
             *iBitmap, 
-            Pbk2PresentationImageUtils::ELandscapeOptimizedCropping, 
+            Pbk2PresentationImageUtils::EOptimizedCropping, 
             ImageSize() );
     
     if (iBitmap->SizeInPixels() <= ImageSize())
--- a/phonebookui/Phonebook2/Presentation/src/CPbk2PresentationContactFieldCollection.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/Presentation/src/CPbk2PresentationContactFieldCollection.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -316,6 +316,32 @@
     }
     
 // --------------------------------------------------------------------------
+// CPbk2PresentationContactFieldCollection::FieldIndexOfStoreField
+// --------------------------------------------------------------------------
+//  
+EXPORT_C TInt CPbk2PresentationContactFieldCollection::FieldIndexOfStoreField(
+    TInt aStoreFieldIndex) const
+    { 
+    __ASSERT_DEBUG(aStoreFieldIndex >= 0 && 
+            aStoreFieldIndex < iFieldCollection.FieldCount(),
+        Panic(EGetStoreContactIndex_PreCond));
+   
+    const TInt count = iFields.Count();
+    const MVPbkStoreContactField& collectionField = iFieldCollection.FieldAt( aStoreFieldIndex );
+    for (TInt i = 0; i < count; ++i)
+        {
+        MVPbkStoreContactField& field = iFields[i]->StoreField();
+        if ( field.IsSame( collectionField ) )
+            {
+            return i;
+            }
+        }
+    __ASSERT_DEBUG(EFalse, Panic(EGetStoreContactIndex_PostCond));
+    return KErrNotFound;
+    }
+    
+
+// --------------------------------------------------------------------------
 // CPbk2PresentationContactFieldCollection::ParentContact
 // --------------------------------------------------------------------------
 //
--- a/phonebookui/Phonebook2/Presentation/src/Pbk2PresentationUtils.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/Presentation/src/Pbk2PresentationUtils.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -238,32 +238,38 @@
         const TSize& aTargetSize  )
     {
     const TSize sourceSize( aBitmap.SizeInPixels() );
-    // crop the image only if the width is bigger than height 
+    // crop the image only if the width is bigger than height
+    TBool landscape( ETrue );
     if( sourceSize.iHeight >= sourceSize.iWidth )
         {
-        // no cropping
-        return;
+        // portrait image
+        landscape = EFalse;
         }
     // take the shorter side
-    const TInt sideSize( sourceSize.iHeight );   
-    TInt sideSizeW( sourceSize.iHeight );   
-    if( ELandscapeOptimizedCropping &&
-        sideSizeW < aTargetSize.iWidth )
+    const TInt sideSizeH( 
+            landscape ? sourceSize.iHeight : sourceSize.iWidth );
+    const TInt targetSizeW( 
+            landscape ? aTargetSize.iWidth : aTargetSize.iHeight );
+    TInt sideSizeW( sideSizeH );   
+    if( EOptimizedCropping == aCroppingMode &&
+        sideSizeW < targetSizeW )
         {
-        sideSizeW = aTargetSize.iWidth;
-        if( sideSizeW >= sourceSize.iWidth )
+        sideSizeW = targetSizeW;
+        if( sideSizeW >= 
+                ( landscape ? sourceSize.iWidth : sourceSize.iHeight ) )
             {
             return; // no cropping
             }
         }
     
     // set target size
-    const TSize targetSize( sideSizeW, sideSize );
+    const TSize targetSize( landscape? 
+            TSize(sideSizeW, sideSizeH ): TSize( sideSizeH, sideSizeW ) );
 
     // crop from both sides
-    const TRect targetRect( TPoint( ( sourceSize.iWidth - targetSize.iWidth ) / 2,
-                              ( sourceSize.iHeight - targetSize.iHeight ) / 2 ),
-                              targetSize );
+    const TPoint targetPoint( ( sourceSize.iWidth - targetSize.iWidth ) / 2,
+                              ( sourceSize.iHeight - targetSize.iHeight ) / 2 );
+    const TRect targetRect( targetPoint, targetSize );
     
     // create new bitmap
     CFbsBitmap* target = new( ELeave ) CFbsBitmap;
@@ -280,7 +286,8 @@
     TInt targetY = 0;
     for (; startPoint.iY < targetRect.iBr.iY; ++startPoint.iY )
         {
-        aBitmap.GetScanLine( scanLinePtr, startPoint, targetSize.iWidth, displayMode );
+        aBitmap.GetScanLine( 
+                scanLinePtr, startPoint, targetSize.iWidth, displayMode );
         target->SetScanLine( scanLinePtr, targetY++ );
         }
 
--- a/phonebookui/Phonebook2/ServerApplication/inc/CPbk2AddressSelectPhase.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ServerApplication/inc/CPbk2AddressSelectPhase.h	Mon Mar 15 12:39:26 2010 +0200
@@ -154,6 +154,9 @@
         TInt iTitleResId;
         /// Ref: Eikon enviroment
         CEikonEnv* iEikenv;
+        ///Bool to denote whether the Current Obj has been deleted or not
+		///Doesnt Own
+        TBool *iThisPtrDestroyed;
     };
 
 #endif // CPBK2ADDRESSSELECTPHASE_H
--- a/phonebookui/Phonebook2/ServerApplication/src/CPbk2AddressSelectPhase.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ServerApplication/src/CPbk2AddressSelectPhase.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -94,6 +94,10 @@
     delete iContactLinks;
     delete iResults;
     delete iDealer;
+    if ( iThisPtrDestroyed )
+        {
+        *iThisPtrDestroyed = ETrue;
+        }
     }
 
 // --------------------------------------------------------------------------
@@ -408,10 +412,21 @@
         ( &iAddressSelectEliminator );
 
     appUi.StoreManager().RegisterStoreEventsL( *this );
+    
+    TBool amIDestroyed( EFalse );
+    iThisPtrDestroyed = &amIDestroyed;    
+    
     MVPbkStoreContactField* resultField = addressSelect->ExecuteLD();
     appUi.StoreManager().DeregisterStoreEvents( *this );
     CleanupStack::PopAndDestroy(); // reader
 
+    if ( amIDestroyed )
+        {        
+        return;
+        }
+    
+    //Reset
+    iThisPtrDestroyed = NULL;
     if ( resultField )
         {
         CleanupDeletePushL(resultField);
--- a/phonebookui/Phonebook2/UIControls/inc/cpbk2filteredviewstack.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/UIControls/inc/cpbk2filteredviewstack.h	Mon Mar 15 12:39:26 2010 +0200
@@ -32,7 +32,7 @@
 class CElementStack;
 
 // CLASS DECLARATION
- 
+
 /**
  * A stack for the base view and filtered views that can be used
  * as a contact view. MVPbkContactViewBase reuqests are forwarded
@@ -44,10 +44,11 @@
  */
 NONSHARABLE_CLASS(CPbk2FilteredViewStack) : public CBase,
                                             public MPbk2FilteredViewStack,
+                                            public MVPbkContactViewObserverExtension,
                                             private MVPbkContactViewObserver
     {
     public: // Constructors and destructor
-            
+
         /**
          * Creates a new instance of this class.
          *
@@ -67,29 +68,29 @@
 
 
         void UpdateFilterL(
-                const MDesCArray& aFindStrings, 
+                const MDesCArray& aFindStrings,
                 const MVPbkContactBookmarkCollection* aAlwaysincluded,
                 TBool aAlwaysIncludedChanged );
-        
+
         void Reset();
-     
+
         MVPbkContactViewBase& BaseView() const;
-        
-  
+
+
         void SetNewBaseViewL(
                 MVPbkContactViewBase& aBaseView );
-        
-        
+
+
         TInt Level() const;
 
-        void AddStackObserverL( 
+        void AddStackObserverL(
                 MPbk2FilteredViewStackObserver& aStackObserver );
-        
- 
-        void RemoveStackObserver( 
+
+
+        void RemoveStackObserver(
                 MPbk2FilteredViewStackObserver& aStackObserver );
-        
-    
+
+
     public:  // From MVPbkContactViewBase
         TVPbkContactViewType Type() const;
         void ChangeSortOrderL(
@@ -109,7 +110,7 @@
                 MVPbkContactViewObserver& aObserver );
         TBool MatchContactStore(
                 const TDesC& aContactStoreUri ) const;
-        TBool MatchContactStoreDomain( 
+        TBool MatchContactStoreDomain(
                 const TDesC& aContactStoreDomain ) const;
         MVPbkContactBookmark* CreateBookmarkLC(
                 TInt aIndex ) const;
@@ -134,6 +135,11 @@
                 MVPbkContactViewBase& aView,
                 TInt aError,
                 TBool aErrorNotified );
+        TAny* ContactViewObserverExtension(TUid aExtensionUid );
+
+    private: // From MVPbkContactViewObserverExtension
+        void FilteredContactRemovedFromView(
+			 MVPbkContactViewBase& aView );
 
     private: // Implementation
         CPbk2FilteredViewStack();
@@ -146,7 +152,7 @@
         void UpdateStackL();
         class CCallback;
         void DoAddObserverL(
-                MVPbkContactViewObserver& aObserver, 
+                MVPbkContactViewObserver& aObserver,
                 CCallback& aCallback );
         void DoAddObserverError(
                 TInt aError,
@@ -163,7 +169,7 @@
                 const MDesCArray& aStringArray,
                 TInt aLevel );
         TBool IsElementsUnderDestruction();
-                
+
     private: // Data
         /// Own: the stacked views that are currently used
         CElementStack* iViewStack;
@@ -179,7 +185,7 @@
         RPointerArray<CCallback> iCallbacks;
         /// Own: Contact find policy
         CVPbkContactFindPolicy* iFindPolicy;
- 
+
  #ifdef _DEBUG
         void __DbgTestInvariant() const;
  #endif // _DEBUG
--- a/phonebookui/Phonebook2/UIControls/rss/Pbk2FetchDlg.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/UIControls/rss/Pbk2FetchDlg.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -16,7 +16,7 @@
 */
 
 
-#include <pbk2icons.hrh>
+#include <Pbk2Icons.hrh>
 
 // --------------------------------------------------------------------------
 // Navi pane label for single entry fetch
@@ -50,7 +50,7 @@
 RESOURCE PBK2_FETCH_DIALOG r_pbk2_multiple_entry_fetch_dlg
     {
     dialog = r_pbk2_multiple_entry_fetch_control_dlg;
-    cba = r_pbk2_softkeys_ok_back_ok;
+    cba = r_pbk2_softkeys_ok_back_mark;
     emptyCba = r_pbk2_softkeys_empty_back_empty;
     }
 
@@ -61,7 +61,7 @@
 RESOURCE PBK2_FETCH_DIALOG r_pbk2_multiple_entry_fetch_no_groups_dlg
     {
     dialog = r_pbk2_multiple_entry_fetch_no_groups_control_dlg;
-    cba = r_pbk2_softkeys_ok_back_ok;
+    cba = r_pbk2_softkeys_ok_back_mark;
     emptyCba = r_pbk2_softkeys_empty_back_empty;
     }
 
@@ -148,20 +148,21 @@
             {
             id = ECtrlFetchNamesList;
             bmpfile = phonebook2_mbm_file_location;
-            bmpid = qgn_prop_nrtyp_empty; // Tab skinning handles icons
-            bmpmask = qgn_prop_nrtyp_empty_mask; // Tab skinning handles icons
+            bmpid = qgn_prop_pb_all_tab2;
+            bmpmask = qgn_prop_pb_all_tab2_mask;
             lines = r_pbk2_multiple_entry_fetch_contactview;
             },
         PAGE
             {
             id = ECtrlFetchGroupsList;
             bmpfile = phonebook2_mbm_file_location;
-            bmpid = qgn_prop_nrtyp_empty; // Tab skinning handles icons
-            bmpmask = qgn_prop_nrtyp_empty_mask; // Tab skinning handles icons
+            bmpid = qgn_prop_group_tab2;
+            bmpmask = qgn_prop_group_tab2_mask;
             lines = r_pbk2_multiple_entry_fetch_groupsview;
             }
         };
     }
+
 // --------------------------------------------------------------------------
 // Multiple entry fetch without groups dialog pages
 // --------------------------------------------------------------------------
@@ -201,7 +202,7 @@
                         KPbk2ContactViewListControlFindBox;
                 listbox = LISTBOX
                     {
-                    flags = EAknListBoxMultiselectionList |
+                    flags = EAknListBoxStylusMultiselectionList |
                             EAknListBoxLoopScrolling;
                     };
                 iconArray = r_pbk2_checkbox_icons;
@@ -239,7 +240,7 @@
                 flags = KPbk2ContactViewListControlUpdateContextPane;
                 listbox = LISTBOX
                     {
-                    flags = EAknListBoxMultiselectionList |
+                    flags = EAknListBoxStylusMultiselectionList |
                             EAknListBoxLoopScrolling;
                     };
                 iconArray = r_pbk2_checkbox_icons;
--- a/phonebookui/Phonebook2/UIControls/rss/Pbk2UIControls.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/UIControls/rss/Pbk2UIControls.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -16,10 +16,89 @@
 */
 
 
-#ifndef RD_SCALABLE_UI_V2
-#include "pbk2nontouchableuicontrols.rss"
-#else
-#include "Pbk2TouchableUIControls.rss"
-#endif // RD_SCALABLE_UI_V2
+// RESOURCE IDENTIFIER
+NAME    CPUC  // From Phonebook 2 UI Controls
+
+// INCLUDES
+#include <eikon.rh>
+#include <eikon.rsg>
+#include <avkon.rsg>
+#include <avkon.hrh>
+#include <avkon.rh>
+#include <AvkonIcons.hrh>
+#include "Pbk2IconId.hrh"
+#include "Pbk2IconArrayId.hrh"
+#include "Pbk2UIControls.hrh"
+#include "Pbk2UIControls.rh"
+#include <Pbk2IconInfo.rh>
+#include <Pbk2IconId.rh>
+#include <Pbk2UID.h>
+#include <phonebook2.loc>
+#include <phonebook2ece.loc>
+
+// RESOURCE DEFINITIONS
+
+// --------------------------------------------------------------------------
+// Standard resource signature
+// --------------------------------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE { }
 
+// --------------------------------------------------------------------------
+// Names list control
+// --------------------------------------------------------------------------
+//
+RESOURCE PBK2_CONTACT_CONTROL r_pbk2_names_list_control
+    {
+    flags = KPbk2ContactViewListControlUpdateContextPane |
+            KPbk2ContactViewListControlFindBox;
+    listbox = LISTBOX
+        {
+        flags = EAknListBoxStylusMarkableList | EAknListBoxLoopScrolling;
+        };
+    iconArray = r_pbk2_contact_list_icons;
+    emptyIconId = PHONEBOOK2_ICON_ID
+        {
+        ownerUid = KPbk2UID3;
+        id = EPbk2qgn_prop_nrtyp_empty;
+        };
+    defaultIconId = PHONEBOOK2_ICON_ID {};
+    }
+
+// --------------------------------------------------------------------------
+// Contact info control
+// --------------------------------------------------------------------------
+//
+RESOURCE PBK2_CONTACT_CONTROL r_pbk2_contact_info_control
+    {
+    flags = KPbk2ContactInfoControlUpdateStatusPane;
+    listbox = LISTBOX
+        {
+        flags = EAknListBoxSelectionList;
+        };
+    iconArray = r_pbk2_fieldtype_icons;
+    emptyIconId = PHONEBOOK2_ICON_ID
+        {
+        ownerUid = KPbk2UID3;
+        id = EPbk2qgn_prop_nrtyp_empty;
+        };
+    defaultIconId = PHONEBOOK2_ICON_ID {};
+    }
+
+// Additional resource files
+#include "Pbk2UIControlsTextBuffers.rss"
+#include "Pbk2CbaResources.rss"
+#include "Pbk2QueryResources.rss"
+#include "Pbk2ContactEditorDlg.rss"
+#include "Pbk2Selectors.rss"
+#include "Pbk2AddressSelect.rss"
+#include "Pbk2FetchDlg.rss"
+#include "Pbk2PrependDlg.rss"
+#include "Pbk2StoreInfo.rss"
+#include "Pbk2Settings.rss"
+#include "Pbk2IconResources.rss"
+#include "Pbk2ThumbnailControl.rss"
+#include "Pbk2GeneralNotes.rss"
+#include "ToneCmds.rss"
+#include "Pbk2MergeContacts.rss"
 // End of File
--- a/phonebookui/Phonebook2/UIControls/src/CPbk2FetchDlg.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/UIControls/src/CPbk2FetchDlg.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -71,6 +71,7 @@
 
 const TInt KPbk2MSKControlId( CEikButtonGroupContainer::EMiddleSoftkeyPosition );
 const TInt KFirstElement = 0;
+const TInt KDefaultMinSelection = 1;
 
 enum TPanicCode
     {
@@ -100,7 +101,8 @@
         iGroupsListView( NULL ),
         iCbaId( 0 ),
         iNaviPaneId( 0 ),
-        iExitCallback( NULL )
+        iExitCallback( NULL ),
+        iMinSelection( KDefaultMinSelection )
     {
     }
 
@@ -492,6 +494,13 @@
             iPages->FocusedContactL();
         if ( focusedContact )
             {
+            if ( !( iParams.iFlags & EFetchMultiple ) )
+                {
+                delete iFocusedContactLink;
+                iFocusedContactLink = NULL;
+                iFocusedContactLink = focusedContact->CreateLinkLC();
+                CleanupStack::Pop(); // iFocusedContactLink
+                }
             MVPbkContactLink* link = focusedContact->CreateLinkLC();
             SelectContactL( *link, selectContact );
             CleanupStack::PopAndDestroy(); // link
@@ -821,8 +830,7 @@
 void CPbk2FetchDlg::ContactSelected
         ( const MVPbkContactLink& aLink, TBool aSelected )
     {
-    if ( aSelected && iFocusedContactLink &&
-         iFocusedContactLink->IsSame( aLink ) )
+    if ( aSelected && iFocusedContactLink && iFocusedContactLink->IsSame( aLink ) )
         {
         // Deleting focused contact link that next time single fetch
         // also fetches the contact.
@@ -836,6 +844,10 @@
             delete this;
             }
         }
+    else
+        {
+        TRAP_IGNORE( UpdateCbasL() );
+        }
     }
 
 // --------------------------------------------------------------------------
@@ -920,7 +932,7 @@
 //
 void CPbk2FetchDlg::UpdateCbasL()
     {
-    if (iResults && iPages &&  iPages->CurrentPage().DlgPageReady() &&
+    if ( iResults && iPages &&  iPages->CurrentPage().DlgPageReady() &&
          !iPages->CurrentPage().DlgPageEmpty() )
         {
         // Use user defined CBA parameter if exist
@@ -939,6 +951,21 @@
             SetCbaCommandSetL( R_PBK2_SOFTKEYS_OK_BACK_OK );
             }
     
+        if ( iParams.iFlags & EFetchMultiple )
+            {
+            CEikButtonGroupContainer& cba = ButtonGroupContainer();
+            if ( iResults->Count() < iParams.iMinSelection )
+                {
+                cba.MakeCommandVisibleByPosition
+                    ( CEikButtonGroupContainer::ELeftSoftkeyPosition, EFalse );
+                }
+            else
+                {
+                cba.MakeCommandVisibleByPosition
+                    ( CEikButtonGroupContainer::ELeftSoftkeyPosition, ETrue );
+                }
+            }
+        
         MVPbkContactLink* link = NULL;
         TBool contactSelected = EFalse;
         //Used the TRAPD to catch the exception when the contact can't be found in DB. 
@@ -1085,23 +1112,20 @@
         {
         // Focused contact must be returned if no contacts yet selected,
         // and the focused contact selection is not already on its way
-        if ( FetchDlgSelection().Count() == 0 )
+        if ( FetchDlgSelection().Count() == 0 && !( iParams.iFlags & EFetchMultiple ) )
             {
-            const MVPbkBaseContact* focusedContact =
-                iPages->FocusedContactL();
+            const MVPbkBaseContact* focusedContact = iPages->FocusedContactL();    
             if ( focusedContact )
                 {
                 delete iFocusedContactLink;
                 iFocusedContactLink = NULL;
                 iFocusedContactLink = focusedContact->CreateLinkLC();
                 CleanupStack::Pop(); // iFocusedContactLink
-
                 if ( iParams.iFlags & EFetchSingle )
                     {
                     // Clean result if this is single fetch.
                     iResults->ResetAndDestroy();
                     }
-
                 SelectContactL( *iFocusedContactLink, ETrue );
                 }
 
--- a/phonebookui/Phonebook2/UIControls/src/CPbk2MemoryEntryDefaultsDlg.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/UIControls/src/CPbk2MemoryEntryDefaultsDlg.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -59,6 +59,10 @@
 #include <aknlists.h>
 #include <aknPopup.h>
 
+// For checking mailbox accounts
+#include <EmailInterfaceFactory.h>
+#include <MEmailMailbox.h>
+
 // Debugging headers
 #include <Pbk2Debug.h>
 
@@ -798,11 +802,13 @@
     {
     TBool ret(ETrue);
 
-    // Skip the line if Email field not supported
-    if ( aSelectorID == VPbkFieldTypeSelectorFactory::EEmailEditorSelector &&
-         !FeatureManager::FeatureSupported( KFeatureIdEmailUi ) )
+    // Skip the line if Email field not supported or having no mailbox
+    if ( aSelectorID == VPbkFieldTypeSelectorFactory::EEmailEditorSelector )
         {
-        ret = EFalse;
+        if ( !FeatureManager::FeatureSupported( KFeatureIdEmailUi ) || !HasMailboxAccountsL() )
+        	{
+        	ret = EFalse;
+        	}
         }
     // Do not add video fields if they are not enabled
     else if ( ( aSelectorID == VPbkFieldTypeSelectorFactory::EVideoCallSelector ) &&
@@ -827,6 +833,41 @@
     }
 
 // --------------------------------------------------------------------------
+// CPbk2MemoryEntryDefaultsDlg::HasMailboxAccountsL
+// --------------------------------------------------------------------------
+//
+TBool CPbk2MemoryEntryDefaultsDlg::HasMailboxAccountsL() const
+	{
+	using namespace EmailInterface;
+
+	TBool result = EFalse;
+	CEmailInterfaceFactory* factory = CEmailInterfaceFactory::NewL();
+	CleanupStack::PushL( factory );
+	MEmailInterface* ifPtr = factory->InterfaceL( KEmailClientApiInterface );
+	MEmailClientApi* clientApi = static_cast<MEmailClientApi*>( ifPtr );
+	CleanupReleasePushL( *clientApi );
+	
+	// Get mailboxs
+	RMailboxPtrArray mailboxes;
+	clientApi->GetMailboxesL( mailboxes );
+	TInt count = mailboxes.Count();	
+	if ( count > 0 )
+		{
+		result = ETrue;
+		}
+	
+	// Release mailboxs before releasing clientapi
+	for ( TInt i=0; i<count; i++ )
+		{
+		MEmailMailbox* mailbox = mailboxes[i];
+		mailbox->Release();
+		}	
+	mailboxes.Close();	
+	CleanupStack::PopAndDestroy( 2 ); // clientApi and factory
+	
+	return result;
+	}
+// --------------------------------------------------------------------------
 // CPbk2MemoryEntryDefaultsDlg::IsAvailable
 // --------------------------------------------------------------------------
 //
--- a/phonebookui/Phonebook2/UIControls/src/CPbk2NamesListControl.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/UIControls/src/CPbk2NamesListControl.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -276,8 +276,8 @@
  * Background Task Handler.
  */
 NONSHARABLE_CLASS(CPbk2NamesListControlBgTask) : public CActive
-    {    
-    
+    {
+
     public:
         CPbk2NamesListControlBgTask( CPbk2NamesListControl& aControl );
         ~CPbk2NamesListControlBgTask();
@@ -285,7 +285,7 @@
         void AddEvent( CPbk2NamesListControl::TPbk2NamesListBgEvents aEvent );
         void ClearAllEvents();
         void RemoveEvent( CPbk2NamesListControl::TPbk2NamesListBgEvents aEvent );
-        
+
     private: // From CActive
         void DoCancel();
         void RunL();
@@ -293,8 +293,8 @@
 
     private:
         //Owns
-        RArray <CPbk2NamesListControl::TPbk2NamesListBgEvents> iEventQueue;  
-        
+        RArray <CPbk2NamesListControl::TPbk2NamesListBgEvents> iEventQueue;
+
         //doesnt Own
         CPbk2NamesListControl& iControl;
     };
@@ -316,35 +316,35 @@
          */
        ~CPbk2HandleMassUpdate();
 
-    public: 
+    public:
         /**
          * Call this function after each update event.
          * @return  ETrue if this event is part of a mass update.
-         */	
+         */
        TBool MassUpdateCheckThis();
 
         /**
          * Call this function to check if mass update process is ongoing.
          * @return  ETrue if mass update process is ongoing.
-         */	   
+         */
        TBool MassUpdateDetected();
-       
-    private: 
+
+    private:
         CPbk2HandleMassUpdate(CEikListBox& iListBox);
         void ConstructL();
-        TBool HandleMassUpdateCheckL(); 
+        TBool HandleMassUpdateCheckL();
         void HandleMassUpdateCheckReset();
         void HandleMassUpdateDone();
-        static TInt HandleMassUpdateTimerCallBack(TAny* aAny);        
+        static TInt HandleMassUpdateTimerCallBack(TAny* aAny);
 
-    private: 
+    private:
 		CEikListBox& iListBox;
         TBool iHandleMassUpdate;
         TTime iHandleMassUpdateFirst;
-        TTime iHandleMassUpdatePrev;        
+        TTime iHandleMassUpdatePrev;
         TInt  iHandleMassUpdateCount;
-        CPeriodic* iHandleMassUpdateTimer;      
-		CAknWaitDialog*  iHandleMassUpdateDialog;		
+        CPeriodic* iHandleMassUpdateTimer;
+		CAknWaitDialog*  iHandleMassUpdateDialog;
     };
 
 // --------------------------------------------------------------------------
@@ -643,9 +643,9 @@
 CPbk2HandleMassUpdate::~CPbk2HandleMassUpdate()
     {
     delete iHandleMassUpdateDialog;
-    delete iHandleMassUpdateTimer;    
+    delete iHandleMassUpdateTimer;
     }
-    
+
 // --------------------------------------------------------------------------
 // CPbk2HandleMassUpdate::CPbk2HandleMassUpdate
 // --------------------------------------------------------------------------
@@ -653,8 +653,8 @@
 CPbk2HandleMassUpdate::CPbk2HandleMassUpdate(CEikListBox& aListBox) :
     iListBox(aListBox)
     {
-    }	
-	
+    }
+
 // --------------------------------------------------------------------------
 // CPbk2HandleMassUpdate::ConstructL
 // --------------------------------------------------------------------------
@@ -662,7 +662,7 @@
 void CPbk2HandleMassUpdate::ConstructL()
     {
     iHandleMassUpdateTimer = CPeriodic::NewL( CActive::EPriorityIdle );
-    }    
+    }
 
 // --------------------------------------------------------------------------
 // CPbk2HandleMassUpdate::HandleMassUpdateCheckThis
@@ -675,29 +675,29 @@
 TBool CPbk2HandleMassUpdate::MassUpdateCheckThis()
     {
     TBool ret(EFalse);
-    const TInt KNbrUpdBeforeMassCheck(5); 
+    const TInt KNbrUpdBeforeMassCheck(5);
     iHandleMassUpdateTimer->Cancel();
 
-    if( iHandleMassUpdateCount > KNbrUpdBeforeMassCheck ) 
+    if( iHandleMassUpdateCount > KNbrUpdBeforeMassCheck )
         {
         //candidates to be checked are they continual of a mass update
         TRAP_IGNORE(ret = HandleMassUpdateCheckL());
         }
-    else if( iHandleMassUpdateCount > 0 ) 
+    else if( iHandleMassUpdateCount > 0 )
         {
-        //Subsequent updates that are handled normally even if 
+        //Subsequent updates that are handled normally even if
         // they would be first ones in a mass update burst
         iHandleMassUpdateCount++;
         iHandleMassUpdatePrev.UniversalTime();
-        }    
+        }
     else
         {
         //very first update, set time & counter
-        HandleMassUpdateCheckReset();       
+        HandleMassUpdateCheckReset();
         }
     return ret;
     }
-	
+
 // --------------------------------------------------------------------------
 // CPbk2HandleMassUpdate::MassUpdateDetected
 // --------------------------------------------------------------------------
@@ -714,16 +714,16 @@
 TBool CPbk2HandleMassUpdate::HandleMassUpdateCheckL()
     {
     //KDeltaAverage time per update to be considered as mass
-    //update. One occasional update can take KDeltaMax time as long as 
-    //average time not exeeded (therefore timeout for the very first updates in 
-    //practice is also KDeltaAverage).  
-    const TInt64 KDeltaAverage(2000000); 
-    const TInt64 KDeltaMax(KDeltaAverage * 2);     
-    const TTimeIntervalMicroSeconds KMaxPrev(KDeltaMax);  
+    //update. One occasional update can take KDeltaMax time as long as
+    //average time not exeeded (therefore timeout for the very first updates in
+    //practice is also KDeltaAverage).
+    const TInt64 KDeltaAverage(2000000);
+    const TInt64 KDeltaMax(KDeltaAverage * 2);
+    const TTimeIntervalMicroSeconds KMaxPrev(KDeltaMax);
     TBool ret(EFalse);
 
     TTime now;
-    now.UniversalTime();    
+    now.UniversalTime();
     TTimeIntervalMicroSeconds fs = now.MicroSecondsFrom(iHandleMassUpdateFirst);
     TTimeIntervalMicroSeconds ps = now.MicroSecondsFrom(iHandleMassUpdatePrev);
     TTimeIntervalMicroSeconds maxCumu(KDeltaAverage * iHandleMassUpdateCount);
@@ -731,21 +731,21 @@
     if( fs < maxCumu && ps < KMaxPrev )
         {
         //mass update burst ongoing
-        iHandleMassUpdate=ETrue;        
+        iHandleMassUpdate=ETrue;
         iHandleMassUpdateCount++;
-        iHandleMassUpdatePrev.UniversalTime();   
+        iHandleMassUpdatePrev.UniversalTime();
         iListBox.UpdateScrollBarsL();
-		
+
         if( !iHandleMassUpdateDialog )
             {
             iHandleMassUpdateDialog = new(ELeave) CAknWaitDialog
                 (reinterpret_cast<CEikDialog**>(&iHandleMassUpdateDialog), EFalse);
             iHandleMassUpdateDialog->SetTone(CAknNoteDialog::ENoTone);
-            iHandleMassUpdateDialog->ExecuteLD(R_QTN_GEN_NOTE_SYNCHRONIZING_PROGRESS);  
-			//ExecuteLD above handles validity of pointer iHandleMassUpdateDialog plus 
+            iHandleMassUpdateDialog->ExecuteLD(R_QTN_GEN_NOTE_SYNCHRONIZING_PROGRESS);
+			//ExecuteLD above handles validity of pointer iHandleMassUpdateDialog plus
 			//cleanupstack
             }
-			
+
         TCallBack callback(HandleMassUpdateTimerCallBack, this);
         TTimeIntervalMicroSeconds32 delta32(KDeltaMax);
         iHandleMassUpdateTimer->Start( delta32, delta32, callback );
@@ -753,9 +753,9 @@
         }
     else if(iHandleMassUpdate)
         {
-        //mass update burst ended    
+        //mass update burst ended
         HandleMassUpdateDone();
-        ret = ETrue;        
+        ret = ETrue;
         }
     else
         {
@@ -771,10 +771,10 @@
 //
 void CPbk2HandleMassUpdate::HandleMassUpdateCheckReset()
     {
-    iHandleMassUpdate=EFalse;        
+    iHandleMassUpdate=EFalse;
     iHandleMassUpdateCount = 1;  //set as first candidate for next burst
     iHandleMassUpdateFirst.UniversalTime();
-    iHandleMassUpdatePrev=iHandleMassUpdateFirst;    
+    iHandleMassUpdatePrev=iHandleMassUpdateFirst;
     }
 
 // ----------------------------------------------------------------------------
@@ -784,7 +784,7 @@
 TInt CPbk2HandleMassUpdate::HandleMassUpdateTimerCallBack(TAny* aAny)
     {
     CPbk2HandleMassUpdate* self = static_cast<CPbk2HandleMassUpdate*>( aAny );
-    self->iHandleMassUpdateTimer->Cancel();    
+    self->iHandleMassUpdateTimer->Cancel();
     self->HandleMassUpdateDone();
     return KErrNone;
     }
@@ -795,19 +795,19 @@
 //
 void CPbk2HandleMassUpdate::HandleMassUpdateDone()
     {
-    if( iHandleMassUpdateDialog ) 
+    if( iHandleMassUpdateDialog )
         {
         TRAP_IGNORE(iHandleMassUpdateDialog->ProcessFinishedL());
         //The below 2 lines just in case... ProcessFinishedL already took care of these
-        delete iHandleMassUpdateDialog;     
+        delete iHandleMassUpdateDialog;
         iHandleMassUpdateDialog = NULL;
         }
 
-    HandleMassUpdateCheckReset();        
+    HandleMassUpdateCheckReset();
     iListBox.SetCurrentItemIndex(0);
     iListBox.SetTopItemIndex(0);
     }
-	
+
 ///////////////////////// End of helper classes /////////////////////////////
 
 
@@ -858,13 +858,13 @@
 CPbk2NamesListControl::~CPbk2NamesListControl()
     {
     ClearMarkedContactsInfo();
-    
+
     if (iBgTask)
-        {    
+        {
         delete iBgTask;
         iBgTask = NULL;
         }
-    
+
     if ( iViewStack && iStackObserver )
         {
         iViewStack->RemoveStackObserver( *iStackObserver );
@@ -875,7 +875,7 @@
         TRAP_IGNORE( iThumbManager->SetContactViewL( NULL ) );
         iThumbManager->RemoveObserver();
         }
-    
+
     if (iCommand)
         {
         // inform the command that the control is deleted
@@ -952,6 +952,10 @@
 
 // --------------------------------------------------------------------------
 // CPbk2NamesListControl::ConstructL
+//
+// Note that NewL (and hence ConstructL) will not be called when custom control  
+// constructed. Instead public constructor and ConstructFromResourceL are 
+// called (happens when ServerApp launches custom fetch dialog)
 // --------------------------------------------------------------------------
 //
 inline void CPbk2NamesListControl::ConstructL(
@@ -971,7 +975,6 @@
     CleanupStack::PopAndDestroy(); // resReader
     FeatureManager::InitializeLibL();
     iFeatureManagerInitilized = ETrue;
-	iCheckMassUpdate = CPbk2HandleMassUpdate::NewL(*iListBox); //iListbox created in ConstructFromResourceL
     }
 
 // --------------------------------------------------------------------------
@@ -1028,7 +1031,7 @@
             iThumbManager = CPbk2ThumbnailManager::NewL( iContactManager );
             iOwnThumbManager = ETrue;
             }
-    
+
         iDoubleListBox = CPbk2ContactViewDoubleListBox::NewL
             ( *this, aReader, iContactManager,
             *iViewStack, iNameFormatter, iStoreProperties,
@@ -1059,14 +1062,14 @@
     iListBox->SetListBoxObserver(this);
     iUiExtension->SetContactUiControlUpdate( this );
     // set command item updater
-    TAny* ext = iUiExtension->ContactUiControlExtensionExtension( 
+    TAny* ext = iUiExtension->ContactUiControlExtensionExtension(
         TUid::Uid( KPbk2ContactUiControlExtensionExtensionUID ) );
     if( ext )
         {
         static_cast<MPbk2ContactUiControlDoubleListboxExtension*>(ext)->
             SetCommandItemUpdater( this );
         }
-    
+
     if ( iListBox->Flags() & KPbk2ContactViewListControlFindBox )
         {
         // Create a find box
@@ -1108,6 +1111,7 @@
     iCurrentState = &iStateFactory->ActivateStartupStateL( iCurrentState );
 
     iBgTask = new (ELeave) CPbk2NamesListControlBgTask( *this );
+    iCheckMassUpdate = CPbk2HandleMassUpdate::NewL(*iListBox); //iListbox created above    
     
     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING
         ("CPbk2NamesListControl::ConstructFromResourceL end"));
@@ -1163,9 +1167,9 @@
     const TInt firstContactIndex = 0;
     // Best effort: try to reset the focus.
     TRAP_IGNORE( iCurrentState->SetFocusedContactIndexL( firstContactIndex ) );
-    //scroll listbox into beginning (ignore focus that may be below promotion items)      
+    //scroll listbox into beginning (ignore focus that may be below promotion items)
     iListBox->SetTopItemIndex(firstContactIndex);
-    
+
     // Switch to the background state. This enables the next state to avtivate fully (ActivateStateL()) once phonebook
     // comes from the background.
     TRAP_IGNORE( iCurrentState = &iStateFactory->ActivateHiddenStateL( iCurrentState ); );
@@ -1957,7 +1961,7 @@
 
     if (&aView == iViewStack)
         {
-        if( !iCheckMassUpdate->MassUpdateDetected() ) 
+        if( !iCheckMassUpdate->MassUpdateDetected() )
             {
             TRAPD(err, DoHandleContactAdditionL(aIndex));
             HandleError(err);
@@ -2006,6 +2010,29 @@
     }
 
 // --------------------------------------------------------------------------
+// CPbk2NamesListControl::ContactViewObserverExtension
+// --------------------------------------------------------------------------
+//
+TAny* CPbk2NamesListControl::ContactViewObserverExtension( TUid aExtensionUid )
+    {
+    if( aExtensionUid == KVPbkContactViewObserverExtension2Uid )
+        {
+        return static_cast<MVPbkContactViewObserverExtension*>( this );
+        }
+    return NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CPbk2NamesListControl::FilteredContactRemovedFromView
+// --------------------------------------------------------------------------
+//
+void CPbk2NamesListControl::FilteredContactRemovedFromView(
+		MVPbkContactViewBase& /*aView*/ )
+    {    
+    DrawDeferred();
+    }
+
+// --------------------------------------------------------------------------
 // CPbk2NamesListControl::FocusedItemPointed
 // --------------------------------------------------------------------------
 //
@@ -2095,7 +2122,7 @@
                 {
                 iListBox->RedrawItem( i );
                 break; // only one command with same id
-                }   
+                }
             }
         }
     }
@@ -2158,16 +2185,16 @@
 //
 void CPbk2NamesListControl::DoHandleContactAdditionL( TInt aIndex )
     {
-	//Prevent messing with focus with always-on when Phonebook hidden in 
-	//reseted state. Otherwise background-added contacts will change focus. 
+	//Prevent messing with focus with always-on when Phonebook hidden in
+	//reseted state. Otherwise background-added contacts will change focus.
 	//This would cause Phonebook not to look like freshly started when opened again.
-	//And also make sure foreground-added contact will show the new contact 
+	//And also make sure foreground-added contact will show the new contact
 	//even though the focus is not seen.
     if( (static_cast<CPbk2AppUi*>(
             CEikonEnv::Static()->AppUi()))->IsForeground() )
         {
-        SelectAndChangeReadyStateL(); 
-        }        
+        SelectAndChangeReadyStateL();
+        }
 
     if( !iCheckMassUpdate->MassUpdateDetected() )
         {
@@ -2379,9 +2406,9 @@
 
             }
         }
-    
+
     // To avoid slow redraw of the scrollbar, make sure it gets drawn. Fixes MJAA-7ZGHRH.
-    aScrollBar->DrawNow(); 
+    aScrollBar->DrawNow();
     }
 // --------------------------------------------------------------------------
 // CPbk2NamesListControl::HandleListBoxEventL
@@ -2446,16 +2473,16 @@
         iSearchFilter->HandleForegroundEventL( aForeground );
         }
     }
-        
+
 // ---------------------------------------------------------------------------
 // CPbk2NamesListControl::StoreMarkedContactsAndResetViewL
 // ---------------------------------------------------------------------------
 //
 void CPbk2NamesListControl::StoreMarkedContactsAndResetViewL()
-    {  
+    {
     delete iSelectedLinkArray;
     iSelectedLinkArray = NULL;
-    
+
     iSelectedLinkArray = iCurrentState->SelectedContactsL();
     }
 
@@ -2465,16 +2492,16 @@
 // ---------------------------------------------------------------------------
 //
 void CPbk2NamesListControl::RestoreMarkedContactsL()
-    {    
+    {
     //Set the Marked Contacts
     if ( iSelectedLinkArray )
         {
         for ( TInt index = 0; index<iSelectedLinkArray->Count(); index++ )
             {
             iCurrentState->SetSelectedContactL( iSelectedLinkArray->At(index), ETrue );
-            }        
-        }    
-    
+            }
+        }
+
     delete iSelectedLinkArray;
     iSelectedLinkArray = NULL;
     }
@@ -2484,7 +2511,7 @@
 // ---------------------------------------------------------------------------
 //
 void CPbk2NamesListControl::ClearMarkedContactsInfo()
-    {   
+    {
     if ( iBgTask )
         {
         iBgTask->ClearAllEvents();
@@ -2543,7 +2570,7 @@
 // ---------------------------------------------------------------------------
 //
 void CPbk2NamesListControlBgTask::DoCancel()
-    {    
+    {
     }
 
 // ---------------------------------------------------------------------------
@@ -2552,7 +2579,7 @@
 //
 void CPbk2NamesListControlBgTask::RunL()
     {
-    
+
     if ( iEventQueue.Count() )
         {
         switch ( iEventQueue[0] )
@@ -2561,14 +2588,14 @@
                 iControl.StoreMarkedContactsAndResetViewL();
                 iEventQueue.Remove( 0 );
                 break;
-                
+
             case CPbk2NamesListControl::EStateRestoreMarkedContacts:
                 iControl.RestoreMarkedContactsL();
                 iEventQueue.Remove( 0 );
                 break;
-            
-            case CPbk2NamesListControl::EStateBgTaskEmpty :    
-            default:            
+
+            case CPbk2NamesListControl::EStateBgTaskEmpty :
+            default:
                 iControl.ClearMarkedContactsInfo();
                 break;
             }
@@ -2580,7 +2607,7 @@
 // ---------------------------------------------------------------------------
 //
 TInt CPbk2NamesListControlBgTask::RunError(TInt /*aError*/)
-    {    
+    {
     return KErrNone;
     }
 
@@ -2610,14 +2637,14 @@
         {
         if ( aEvent == iEventQueue[index] )
             {
-            iEventQueue.Remove( index );      
+            iEventQueue.Remove( index );
             if ( 0 == index )
                 {
-                Cancel(); 
+                Cancel();
                 }
             break;
             }
-        }    
+        }
     }
 
 
--- a/phonebookui/Phonebook2/UIControls/src/CPbk2NamesListFilteredState.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/UIControls/src/CPbk2NamesListFilteredState.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -183,6 +183,15 @@
 void CPbk2NamesListFilteredState::DeactivateState()
     {
     AllowCommandsToShowThemselves( EFalse );  
+    
+    // Stop creating adaptive search grid.
+    if (iAdaptiveSearchGridFiller)
+        {
+        if (iAdaptiveSearchGridFiller->IsActive())
+            {
+            iAdaptiveSearchGridFiller->StopFilling();
+            }
+        }
     }
 
 // --------------------------------------------------------------------------
--- a/phonebookui/Phonebook2/UIControls/src/CPbk2NamesListReadyState.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/UIControls/src/CPbk2NamesListReadyState.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -319,6 +319,14 @@
 
     AllowCommandsToShowThemselves( EFalse );  
     HideThumbnail();
+    // Stop creating adaptive search grid.
+    if (iAdaptiveSearchGridFiller)
+        {
+        if (iAdaptiveSearchGridFiller->IsActive())
+            {
+            iAdaptiveSearchGridFiller->StopFilling();
+            }
+        }
     }
 
 // --------------------------------------------------------------------------
--- a/phonebookui/Phonebook2/UIControls/src/CPbk2ThumbnailManager.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/UIControls/src/CPbk2ThumbnailManager.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -355,6 +355,12 @@
 //
 CPbk2ThumbnailManager::~CPbk2ThumbnailManager()
 	{
+    if( iView )
+        {
+        iView->RemoveObserver(*this );
+        iView->RemoveStackObserver( *this ); 
+        }    
+    
 	delete iInProgressItemToBeRemoved;
 	delete iThumbOperation;
     delete iManager;
@@ -590,6 +596,12 @@
 //
 void CPbk2ThumbnailManager::SetContactViewL( MPbk2FilteredViewStack* aView )
     {
+    if( iView )
+        {
+        iView->RemoveObserver(*this );
+        iView->RemoveStackObserver( *this ); 
+        }    
+    
     iView = aView;
     if( iView )
         {
@@ -859,7 +871,7 @@
 	// contact has no image or error occured, move to next contact
 	if( err )
 		{
-		if ( iLoadingQueue.Count() )
+		if ( !iInProgressItemToBeRemoved && iLoadingQueue.Count() )
 		    {
             if( iObserver )
                 {
--- a/phonebookui/Phonebook2/UIControls/src/Pbk2ImageCommands.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/UIControls/src/Pbk2ImageCommands.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -63,6 +63,7 @@
 #include <Pbk2CmdExtRes.rsg>
 #include <sysutil.h>
 #include <CPbk2ApplicationServices.h>
+#include <AknProgressDialog.h>
 
 /// Unnamed namespace for local definitions
 namespace {
@@ -116,6 +117,7 @@
     public CBase,
 	public MPbk2BaseCommand,
     private MPbk2ImageSetObserver,
+    public MProgressDialogCallback,
     private MMGFetchVerifier
 	{
 	public:
@@ -131,6 +133,9 @@
 	            MPbk2ImageOperation& aOperation,
 	            TInt aError);
 	
+	private: // from MProgressDialogCallback
+	        void DialogDismissedL( TInt aButtonId );
+	        
 	private: // from MMGFetchVerifier
 	    TBool VerifySelectionL(
 	            const MDesCArray* aSelectedFiles);
@@ -141,6 +146,9 @@
 		void DismissWaitNote();
 		void SetImageRefL( MVPbkStoreContact* aContact,
 				const TDesC& aFileName);
+		TBool DoVerifySelectionL(
+		        const MDesCArray* aSelectedFiles);
+		void ShowErrorNoteL();
 		
 	private:
         /// Own: image set operation
@@ -161,6 +169,9 @@
         MPbk2ImageFieldObserver* iObserver;
         // Ref:
         CPbk2ApplicationServices* iServices;	
+        TBool iVerificationFailed;
+        TBool iImageSetFailed;
+        TBool iImageSetError;
 	};
 
 CSetImageCmd* CSetImageCmd::NewL()
@@ -183,24 +194,27 @@
 
 void CSetImageCmd::ExecuteL( MVPbkStoreContact* aContact,MPbk2ImageFieldObserver* aObserver )
 	{
+    iImageSetFailed = EFalse;
     iObserver=aObserver;
     CDesCArray* selectedFile = new(ELeave) CDesCArrayFlat(
             KSelectedFilesDefaultGranularity );
     CleanupStack::PushL( selectedFile );
 	TBool res( EFalse );
-	
+		
 	// run image fetch dialog
-	res = MGFetch::RunL( *selectedFile, 
+ 	res = MGFetch::RunL( *selectedFile, 
 	        EImageFile, 
 	        EFalse, /* multiselection */
 	        this /* provide MMGFetchVerifier interface to check DRM */);
-
-	if ( res && selectedFile->Count() > 0 )
+ 	        
+    if ( !iVerificationFailed && res && selectedFile->Count() > 0 )
         {
         if (iWaitNote==NULL)
             {
             iWaitNote =new(ELeave) CAknWaitDialog(reinterpret_cast<CEikDialog**>( &iWaitNote ),ETrue );
             }
+        iWaitNote->SetCallback( this );
+        
         // doesn't delete waitNote
         iWaitNote->ExecuteLD( R_QTN_GEN_NOTE_FETCHING );
 
@@ -211,17 +225,15 @@
         iImageFilename=NULL;
         // store these for later use
         iImageFilename=fileName.AllocL();
-        iContact=aContact;
+        iContact=aContact;        
         
-        
-        // write data to thumbnail field
+        // write data to thumbnail field        
         iImageOperation = 
             iImageManager->SetImageAsyncL(
-                *aContact, *iThumbnailFieldType, *this, fileName );
-                
-        }
-
-    CleanupStack::PopAndDestroy( selectedFile );	
+                *aContact, *iThumbnailFieldType, *this, fileName );                                       
+        }        
+ 	
+    CleanupStack::PopAndDestroy( selectedFile );
 	}
 
 CSetImageCmd::CSetImageCmd()
@@ -263,6 +275,11 @@
 		{
 		delete iWaitNote;
 		iWaitNote = NULL;
+		
+		if( iImageSetFailed )
+            {
+            ShowErrorNoteL();
+            }
 		}
 	}
 
@@ -279,8 +296,7 @@
     if (iObserver)
         {
         iObserver->ImageLoadingComplete();
-        }
-	
+        }	
     }
 
 // --------------------------------------------------------------------------
@@ -289,19 +305,14 @@
 //
 void CSetImageCmd::Pbk2ImageSetFailed
         ( MPbk2ImageOperation& /*aOperation*/, TInt aError )
-    {
+    {        
     delete iImageOperation;
     iImageOperation = NULL;
-	DismissWaitNote();
-    if (iObserver)
-        {
-        iObserver->ImageLoadingFailed();
-        }
-	
-	if ( aError != KErrNone )
-		{
-		CCoeEnv::Static()->HandleError( aError );
-		}
+    
+    iImageSetFailed = ETrue;
+    iImageSetError = aError;
+    
+	DismissWaitNote();    		   		
     }
 
 void CSetImageCmd::SetImageRefL( MVPbkStoreContact* aContact,
@@ -337,42 +348,108 @@
     }
 
 // --------------------------------------------------------------------------
-// DRM check for image fetch dialog
+// CSetImageCmd::DialogDismissedL
+// --------------------------------------------------------------------------
+//  
+void CSetImageCmd::DialogDismissedL( TInt /*aButtonId*/ )
+    {
+    if( iImageSetFailed )
+        {
+        ShowErrorNoteL();
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CSetImageCmd::VerifySelectionL
 // --------------------------------------------------------------------------
 //	
 TBool CSetImageCmd::VerifySelectionL
-        (const MDesCArray* aSelectedFiles)
+    (const MDesCArray* aSelectedFiles)
     {
-    TBool result = EFalse;
+    iVerificationFailed = EFalse;
+    TBool ret = ETrue;
+       
+    TRAPD( err, ret = DoVerifySelectionL( aSelectedFiles ) );
+    
+    if( err != KErrNone )
+       {
+       iVerificationFailed = ETrue;
+       ShowErrorNoteL();    
+       } 
+    
+    // Selection is always accepted if the image is not drm protected.
+    // Image fetch dialog functionality is always same in spite of error 
+    // type (DRM check, ImageDecoder, etc. errors) Dialog is always closed.    
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// CSetImageCmd::DoVerifySelectionL
+// --------------------------------------------------------------------------
+//  
+TBool CSetImageCmd::DoVerifySelectionL
+    (const MDesCArray* aSelectedFiles)
+    {     
+    TBool ret = ETrue;
+    
     if ( aSelectedFiles && aSelectedFiles->MdcaCount() > 0 )
-        {
+        {    
         // DRM for phonebook image fetch
         TPtrC fileName = aSelectedFiles->MdcaPoint( 0 );
+                
         TBool isProtected( ETrue );
         User::LeaveIfError( 
             iDrmManager->IsProtectedFile( fileName, isProtected ) );
+                
         if ( isProtected )
-            {
+            {        
+            ret = EFalse;
+            
 			RPbk2LocalizedResourceFile resFile( *CCoeEnv::Static() );
 			resFile.OpenLC( 
 			    KPbk2RomFileDrive, 
 				KDC_RESOURCE_FILES_DIR, 
 				Pbk2PresentationUtils::PresentationResourceFile() );
             // show user copyright note
+						
             HBufC* prompt = 
                 CCoeEnv::Static()->AllocReadResourceLC( R_PBK2_QTN_DRM_NOT_ALLOWED );
             CAknInformationNote* dlg = new(ELeave) CAknInformationNote( ETrue );
             dlg->ExecuteLD( *prompt );
             CleanupStack::PopAndDestroy( 2 ); // resFile, prompt
-            }
-        else
-            {
-            result = ETrue;
-            }
-        }
+            }        
+        }  
+    
+    return ret;
+    }	
+
+// --------------------------------------------------------------------------
+// CSetImageCmd::ShowErrorNoteL
+// --------------------------------------------------------------------------
+//
+void CSetImageCmd::ShowErrorNoteL()
+    {                     
+    HBufC* prompt = StringLoader::LoadLC( R_QTN_ALBUM_ERR_FORMAT_UNKNOWN );
+    CAknInformationNote* dlg = new ( ELeave ) CAknInformationNote( ETrue );
+    dlg->ExecuteLD( *prompt );
+    CleanupStack::PopAndDestroy( prompt );
+    
+    if( iImageSetFailed )
+        {
+        iImageSetFailed = EFalse;
         
-    return result;
-    }	
+        if (iObserver)
+           {
+           iObserver->ImageLoadingFailed();
+           }
+       
+       if ( iImageSetError != KErrNone )
+           {
+           CCoeEnv::Static()->HandleError( iImageSetError );
+           iImageSetError = KErrNone;
+           }
+        }    
+    }
 
 // --------------------------------------------------------------------------
 // Starts external image viewer via doc.handler and waits for its exit
--- a/phonebookui/Phonebook2/UIControls/src/cpbk2contactviewdoublelistboxmodel.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/UIControls/src/cpbk2contactviewdoublelistboxmodel.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -198,7 +198,7 @@
 
     // Clip secondary text if it's a phone number 
     if( MPbk2DoubleListboxDataElement::ETypePhoneNumber == 
-        element->TextType( MPbk2DoubleListboxDataElement::EStatusText ) )
+        element->TextType( MPbk2DoubleListboxDataElement::EStatusText ) && iClipListBoxText )
         {
         TPtr secondary( element->TextPtr( 
             MPbk2DoubleListboxDataElement::EStatusText ) );
--- a/phonebookui/Phonebook2/UIControls/src/cpbk2filteredviewstack.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/UIControls/src/cpbk2filteredviewstack.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -484,7 +484,7 @@
 //
 void CElementStack::Reset()
     {
-    // Stack's elements need to destroy vice versa, 
+    // Stack's elements need to destroy vice versa,
     // because views in elements are always linked to previous view.
     // Like BaseView<-FindView<-RefineView<-RefineView...
     const TInt count( iStack.Count() );
@@ -565,7 +565,7 @@
 CPbk2FilteredViewStack::CCallback::CCallback(
         CPbk2FilteredViewStack& aViewStack,
         MVPbkContactViewObserver& aObserver, AddObserverL aAddObserverFuncL,
-        AddObserverError aAddObserverErrorFunc ) : 
+        AddObserverError aAddObserverErrorFunc ) :
             CActive( EPriorityStandard ),
             iViewStack( aViewStack ),
             iObserver( aObserver ),
@@ -707,7 +707,7 @@
         TBool aAlwaysIncludedChanged )
     {
     PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING(
-        "CPbk2FilteredViewStack::UpdateFilterL: topview(0x%x), always=%x"), 
+        "CPbk2FilteredViewStack::UpdateFilterL: topview(0x%x), always=%x"),
         &TopView(), aAlwaysincluded );
 
 
@@ -809,7 +809,7 @@
             if ( IsElementsUnderDestruction() )
                 {
                 UpdateStackL();
-                }            
+                }
             }
         }
 
@@ -1242,6 +1242,48 @@
     }
 
 // --------------------------------------------------------------------------
+// CPbk2FilteredViewStack::ContactViewObserverExtension
+// --------------------------------------------------------------------------
+//
+TAny* CPbk2FilteredViewStack::ContactViewObserverExtension( TUid aExtensionUid )
+    {
+    if( aExtensionUid == KVPbkContactViewObserverExtension2Uid )
+        {
+        return static_cast<MVPbkContactViewObserverExtension*>( this );
+        }
+    return NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CPbk2FilteredViewStack::FilteredContactRemovedFromView
+// --------------------------------------------------------------------------
+//
+void CPbk2FilteredViewStack::FilteredContactRemovedFromView(
+		MVPbkContactViewBase& aView )
+    {
+    const TInt count = iViewObservers.Count();
+
+    for( TInt i = 0; i < count; i++ )
+       {
+       MVPbkContactViewObserver* observer = iViewObservers[i];
+
+       TAny* extension = observer->ContactViewObserverExtension(
+               KVPbkContactViewObserverExtension2Uid );
+
+       if( extension )
+           {
+           MVPbkContactViewObserverExtension* contactViewExtension =
+                   static_cast<MVPbkContactViewObserverExtension*>( extension );
+
+           if( contactViewExtension )
+               {
+               contactViewExtension->FilteredContactRemovedFromView( aView );
+               }
+           }
+       }
+    }
+
+// --------------------------------------------------------------------------
 // CPbk2FilteredViewStack::TopElement
 // --------------------------------------------------------------------------
 //
@@ -1276,12 +1318,12 @@
     // Check first if the aView is the base view.
     if ( iBaseViewElement->View() == &aView )
         {
-        if ( iBaseViewElement->ViewState() == 
+        if ( iBaseViewElement->ViewState() ==
                 MPbk2FilteredViewStackElement::EUndefined )
             {
             // The Base view is changed.
-            SendBaseViewChangedEvent();            
-            }  
+            SendBaseViewChangedEvent();
+            }
 
         iBaseViewElement->SetViewState(
             MPbk2FilteredViewStackElement::EReady );
@@ -1546,7 +1588,7 @@
 // --------------------------------------------------------------------------
 // CPbk2FilteredViewStack::SendBaseViewChangedEvent
 // --------------------------------------------------------------------------
-//    
+//
 void CPbk2FilteredViewStack::SendBaseViewChangedEvent()
     {
     const TInt count = iStackObservers.Count();
--- a/phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimFixedDialingView.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimFixedDialingView.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -11,7 +11,7 @@
 *
 * Contributors:
 *
-* Description:  Phonebook 2 fixed dialing view definition.
+* Description:  Phonebook 2 touchable fixed dialing view definition.
 *
 */
 
@@ -28,7 +28,7 @@
     }
 
 // --------------------------------------------------------------------------
-// View definition
+// Avkon view definition
 // --------------------------------------------------------------------------
 //
 RESOURCE AVKON_VIEW r_psu2_fixed_dialing_appview
@@ -63,7 +63,7 @@
             },
         MENU_TITLE
             {
-            menu_pane = R_PHONEBOOK2_CALL_MENU;
+            menu_pane = R_PHONEBOOK2_STYLUS_CALL_MENU;
             },
         MENU_TITLE
             {
@@ -73,7 +73,7 @@
     }
 
 // --------------------------------------------------------------------------
-// Context menubar
+// Context menu bar
 // --------------------------------------------------------------------------
 //
 RESOURCE MENU_BAR r_psu2_fixed_dialing_context_menubar
@@ -82,6 +82,10 @@
         {
         MENU_TITLE
             {
+            menu_pane = R_PHONEBOOK2_MARKABLE_LIST_CONTEXT_MENU;
+            },                
+        MENU_TITLE
+            {
             menu_pane = r_psu2_fixed_dialing_copy_context_menupane;
             },
         MENU_TITLE
@@ -90,11 +94,45 @@
             },
         MENU_TITLE
             {
-            menu_pane = R_AVKON_MENUPANE_MARKABLE_LIST;
+            menu_pane = r_psu2_fixed_dialing_delete_menupane;
+            }
+        };
+    }
+
+// --------------------------------------------------------------------------
+// Menu pane
+// --------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_psu2_fixed_dialing_menupane
+    {
+    items=
+        {
+        MENU_ITEM
+            {
+            command = EPsu2CmdActivateFDN;
+            txt = qtn_fdn_activate_fdn;
             },
-        MENU_TITLE
+        MENU_ITEM
+            {
+            command = EPsu2CmdDeactivateFDN;
+            txt = qtn_fdn_deactivate_fdn;
+            },
+        MENU_ITEM
             {
-            menu_pane = r_psu2_fixed_dialing_delete_menupane;
+            command = EPsu2CmdNewContact;
+            txt = qtn_simp_opt_entry_create;
+            },
+        MENU_ITEM
+            {
+            command = EPbk2CmdEditMe;
+            txt = qtn_phob_opt_entry_edit;
+            flags = EEikMenuItemSpecific;
+            },
+        MENU_ITEM
+            {
+            command = EPbk2CmdDeleteMe;
+            txt = qtn_phob_opt_entry_delete;
+            flags = EEikMenuItemSpecific;
             }
         };
     }
@@ -111,6 +149,7 @@
             {
             command = EPsu2CmdOpenFixedDialingInfoView;
             txt = qtn_simp_opt_entry_view;
+            flags = EEikMenuItemAction; 
             }
         };
     }
@@ -148,42 +187,6 @@
     }
 
 // --------------------------------------------------------------------------
-// Menu pane
-// --------------------------------------------------------------------------
-//
-RESOURCE MENU_PANE r_psu2_fixed_dialing_menupane
-    {
-    items=
-        {
-        MENU_ITEM
-            {
-            command = EPsu2CmdActivateFDN;
-            txt = qtn_fdn_activate_fdn;
-            },
-        MENU_ITEM
-            {
-            command = EPsu2CmdDeactivateFDN;
-            txt = qtn_fdn_deactivate_fdn;
-            },
-        MENU_ITEM
-            {
-            command = EPsu2CmdNewContact;
-            txt = qtn_simp_opt_entry_create;
-            },
-        MENU_ITEM
-            {
-            command = EPbk2CmdEditMe;
-            txt = qtn_phob_opt_entry_edit;
-            },
-        MENU_ITEM
-            {
-            command = EPbk2CmdDeleteMe;
-            txt = qtn_phob_opt_entry_delete;
-            }
-        };
-    }
-
-// --------------------------------------------------------------------------
 // Copy menu pane
 // --------------------------------------------------------------------------
 //
@@ -195,6 +198,7 @@
             {
             command = EPbk2CmdCopy;
             txt = qtn_simp_opt_copy_to_pb;
+            flags = EEikMenuItemSpecific;
             },
         MENU_ITEM
             {
@@ -230,16 +234,16 @@
 //
 RESOURCE PBK2_CONTACT_CONTROL r_psu2_fixed_dialing_name_list_control
     {
-    /// Flags
+    // Flags
     flags = KPbk2ContactViewListControlUpdateContextPane | KPbk2ContactViewListControlFindBox;
-    /// Listbox resource
+    // Listbox resource
     listbox = LISTBOX
         {
-        flags = EAknListBoxMarkableList|EAknListBoxLoopScrolling|EAknListBoxShiftEnterMarks;
+        flags = EAknListBoxStylusMarkableList|EAknListBoxLoopScrolling;
         };
-    /// Optional link to an icon array resource, see PBK2_ICON_ARRAY
+    // Optional link to an icon array resource, see PBK2_ICON_ARRAY
     iconArray = R_PBK2_FIELDTYPE_ICONS;
-    /// Empty icon id in iconArray(s)
+    // Empty icon id in iconArray(s)
     emptyIconId = PHONEBOOK2_ICON_ID
         {
         ownerUid = KPbk2UID3;
@@ -285,7 +289,7 @@
 RESOURCE DIALOG r_psu2_fdn_numberquery_dialog
     {
     flags=  EAknGeneralQueryFlags;
-    buttons=R_PBK2_SOFTKEYS_CALL_CANCEL_CALL;
+    buttons=R_AVKON_SOFTKEYS_CALL_CANCEL__CALL;
     items=
         {
         DLG_LINE
@@ -312,6 +316,14 @@
     {
     items =
         {
+        /// Top contact indicator / Top contact internal order        
+        VPBK_FIELD_TYPE_MAPPING
+            {
+            versitProperty = VBK_FIELD_VERSIT_PROPERTY
+                {
+                name = EVPbkVersitNameTopContact;
+                };
+            },                
         // Last name
         VPBK_FIELD_TYPE_MAPPING
             {
@@ -377,20 +389,17 @@
     {
     versitProperties =
         {
-        /// Last name
+        // Last name
         VBK_FIELD_VERSIT_PROPERTY
             {
             name = EVPbkVersitNameN;
             subField = EVPbkVersitSubFieldFamilyName;
             },
-        /// SIM GSM number = general mobile
+        // SIM GSM number = general mobile
         VBK_FIELD_VERSIT_PROPERTY
             {
             name = EVPbkVersitNameTEL;
-            parameters =
-                {
-                EVPbkVersitParamCELL
-                };
+            parameters = { EVPbkVersitParamCELL };
             }
         };
     nonVersitType =
--- a/phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimServiceDialingView.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimServiceDialingView.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -11,11 +11,11 @@
 *
 * Contributors:
 *
-* Description:  Phonebook 2 service dialing view definition.
+* Description:  Phonebook 2 touchable service dialing view definition.
 *
 */
 
-
+ 
 // --------------------------------------------------------------------------
 // SDN contact view
 // --------------------------------------------------------------------------
@@ -38,7 +38,7 @@
     }
 
 // --------------------------------------------------------------------------
-// Menu bar
+// Service dialing view menu bar
 // --------------------------------------------------------------------------
 //
 RESOURCE MENU_BAR r_psu2_service_dialing_menubar
@@ -69,7 +69,7 @@
     }
 
 // --------------------------------------------------------------------------
-// Context menu bar
+// Service dialing view context menu bar
 // --------------------------------------------------------------------------
 //
 RESOURCE MENU_BAR r_psu2_service_dialing_context_menubar
@@ -130,7 +130,7 @@
     // Listbox resource
     listbox = LISTBOX
         {
-        flags = EAknListBoxMarkableList|EAknListBoxLoopScrolling|EAknListBoxShiftEnterMarks;
+        flags = EAknListBoxStylusMarkableList|EAknListBoxLoopScrolling;
         };
     // Optional link to an icon array resource, see PBK2_ICON_ARRAY
     iconArray = R_PBK2_FIELDTYPE_ICONS;
--- a/phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimUiRes.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/USIMExtension/rss/Pbk2USimUiRes.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2007 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"
@@ -11,16 +11,72 @@
 *
 * Contributors:
 *
-* Description: 
-*     This file contains all the resources for Pbk2USimUI module.
+* Description:  Phonebook 2 USIM UI extension resource definitions.
 *
 */
 
 
-#ifdef RD_SCALABLE_UI_V2
-    #include "Pbk2USimTouchableUiRes.rss"
-#else
-    #include "pbk2usimnontouchableuires.rss"
-#endif // RD_SCALABLE_UI_V2
+// RESOURCE IDENTIFIER
+NAME    P2UU  // From Phonebook 2 USIM UI
+
+// Phonebook 2
+#include "Pbk2USimUI.hrh"
+#include "Pbk2USimUI.rh"
+#include <Pbk2USimUI.hrh>
+#include <Pbk2Icons.hrh>
+#include <Pbk2IconArrayId.hrh>
+#include <Pbk2Commands.rsg>
+#include <Pbk2UIControls.rsg>
+#include <Pbk2UIControls.rh>
+#include <Pbk2UIControls.hrh>
+#include <Pbk2IconInfo.rh>
+#include <Pbk2StoreProperty.rh>
+#include <Pbk2FieldProperty.hrh>
+#include <Pbk2FieldProperty.rh>
+#include <Pbk2StoreProperty.hrh>
+#include <Pbk2ContactView.hrh>
+#include <Pbk2StoreInfo.hrh>
+#include <Pbk2UID.h>
+#include <Pbk2UIExtension.rh>
+#include <Pbk2ViewGraph.rh>
+#include <Pbk2ExtensionUID.h>
+#include <Pbk2ViewId.hrh>
+#include <Pbk2IconId.rh>
+#include <psu2.mbg>
+#include <phonebook2.loc>
+
+// Virtual Phonebook
+#include <VPbkContactView.rh>
+#include <VPbkFieldType.rh>
+#include <VPbkStoreUriDefinitions.hrh>
+#include <VPbkEng.rsg>
+#include <VPbkFieldType.hrh>
+
+// System includes
+#include <avkon.loc>
+#include <uikon.rh>
+#include <eikon.rh>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.mbg>
+#include <avkon.hrh>
+#include <AvkonIcons.hrh>
+
+// --------------------------------------------------------------------------
+// Standard resource signature
+// --------------------------------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE { }
+    
+// Additional resource files
+#include "Pbk2USimInformation.rss"
+#include "Pbk2USimCbaResources.rss"
+#include "Pbk2USimTextBuffers.rss"
+#include "Pbk2USimSimCopy.rss"
+#include "Pbk2USimOwnNumberView.rss"
+#include "Pbk2USimServiceDialingView.rss"
+#include "Pbk2USimFixedDialingView.rss"
+#include "Pbk2USimFixedDialingInfoView.rss"
+#include "Pbk2USimServiceDialingInfoView.rss"
 
 // End of File
--- a/phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/inc/ccappcommlaunchercontainer.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/inc/ccappcommlaunchercontainer.h	Mon Mar 15 12:39:26 2010 +0200
@@ -355,6 +355,9 @@
      * Own.
      */
 	CCCaFactoryExtensionNotifier* iFactoryExtensionNotifier;
+	
+	
+	TBool iLongTap;
     };
 
 #endif // __CCAPPCOMMALAUNCHERCONTAINER_H
--- a/phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlaunchercontainer.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlaunchercontainer.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -60,7 +60,7 @@
 // ----------------------------------------------------------------------------
 //
 CCCAppCommLauncherContainer::~CCCAppCommLauncherContainer()
-    {
+    {    
     delete iListBox;
     delete iBackground;
     delete iModel;
@@ -166,7 +166,7 @@
     // Get the skin background for the view
     iBackground = CAknsBasicBackgroundControlContext::NewL(
         KAknsIIDQsnBgAreaMain, TRect(0, 0, 0, 0), EFalse);
-    LongTapDetectorL();
+    LongTapDetectorL();    
     }
 
 // ----------------------------------------------------------------------------
@@ -473,22 +473,32 @@
         
             VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector
                 contactActionType = iPlugin.Container().SelectedCommunicationMethod();
-            CCAContactorService::TCSParameter param(
-                contactActionType,
-                *iPlugin.ContactHandler().ContactIdentifierLC(),//contactlinkarray
-                paramFlag, 
-                fullName );
-        
-            if ( contactActionType == VPbkFieldTypeSelectorFactory::EVoiceCallSelector ||
-                contactActionType == VPbkFieldTypeSelectorFactory::EVideoCallSelector ||
-                contactActionType == VPbkFieldTypeSelectorFactory::EVOIPCallSelector )
+            
+            if ( !iLongTap && contactActionType
+                            == VPbkFieldTypeSelectorFactory::EFindOnMapSelector )
+                {  
+                iLongTap = ETrue;    
+                DoShowMapCmdL( (TPbk2CommandId)EPbk2ExtensionShowOnMap );
+                }
+            else
                 {
-                iPlugin.StartTimerL();
+                CCAContactorService::TCSParameter param(
+                    contactActionType,
+                    *iPlugin.ContactHandler().ContactIdentifierLC(),//contactlinkarray
+                    paramFlag, 
+                    fullName );
+            
+                if ( contactActionType == VPbkFieldTypeSelectorFactory::EVoiceCallSelector ||
+                    contactActionType == VPbkFieldTypeSelectorFactory::EVideoCallSelector ||
+                    contactActionType == VPbkFieldTypeSelectorFactory::EVOIPCallSelector )
+                    {
+                    iPlugin.StartTimerL();
+                    }
+            
+                contactorService->ExecuteServiceL( param );
+    
+                CleanupStack::PopAndDestroy( 1 );// contactlinkarray
                 }
-        
-            contactorService->ExecuteServiceL( param );
-
-            CleanupStack::PopAndDestroy( 1 );// contactlinkarray
             }
         }
     }
@@ -539,7 +549,14 @@
         if ( contactActionType
         		== VPbkFieldTypeSelectorFactory::EFindOnMapSelector )
         	{
-        	DoShowMapCmdL( (TPbk2CommandId)EPbk2ExtensionShowOnMap );
+            if ( !iLongTap )
+                {
+                DoShowMapCmdL( (TPbk2CommandId)EPbk2ExtensionShowOnMap );
+                }
+            else
+                {
+                iLongTap = EFalse;
+                }
         	}
         else
         	{
@@ -749,10 +766,12 @@
         iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin );
     	}
 
+   
     iPbkCmd->ExecutePbk2CmdShowMapL(
             iPlugin.ContactHandler().ContactIdentifierLC(), aCommandId );
 
     CleanupStack::PopAndDestroy( 1 ); // ContactIdentifierLC
+   
     }
 
 // --------------------------------------------------------------------------
@@ -852,4 +871,5 @@
     
     }
 
+
 // End of File
--- a/phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherheadercontrol.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherheadercontrol.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -174,31 +174,13 @@
 //
 void CCCAppCommLauncherHeaderControl::SizeChanged()
     {    
-    const TInt isLandscape = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
+    // No variation anymore in layout for portrait/landscape/statusbutton/
+    // no statusbutton (iStatusButtonVisibility) combinations (options 0,1,2). 
+    // Always use option 0.
+    //const TInt isLandscape = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
     const TRect rect(Rect());
+    TInt option(0);    
     
-    /**
-     * Option0 (w button, lsc)
-     * Option2 (w/o button, lsc)
-     * Option0 (w button, prt)
-     * Option1 (w/o button, prt)
-     */
-   
-    // (w/o button)
-    TInt option( isLandscape ? 2 : 1 );
-    if( iStatusButtonVisibility )
-        {
-        // (w button)
-        if( isLandscape )
-            {
-            option = 0;
-            }
-        else
-            {
-            option = 0;
-            }
-        }    
-   
     FavoriteIconSizeChanged();
     
     AknLayoutUtils::LayoutImage(
@@ -709,24 +691,13 @@
      {
      //Set the size for the Favorite Icon
      //This code must be in Sync with SizeChanged() code
-     const TInt isLandscape = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
+
+     // No variation anymore in layout for portrait/landscape/statusbutton/
+     // no statusbutton (iStatusButtonVisibility) combinations (options 0,1,2). 
+     // Always use option 0.
+     //const TInt isLandscape = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
      const TRect rect(Rect());
-     
-     // (w/o button)
-     TInt option( isLandscape ? 2 : 1 );
-     if( iStatusButtonVisibility )
-         {
-         // (w button)
-         if( isLandscape )
-             {
-             option = 0;
-             }
-         else
-             {
-             option = 0;
-             }
-         }    
-    
+     TInt option( 0 );
      AknLayoutUtils::LayoutImage(
              iFavContactIcon, rect, AknLayoutScalable_Apps::phob2_cc_data_pane_g2(option));
              
--- a/phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherlpadmodel.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherlpadmodel.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -37,6 +37,7 @@
 #include <cbsbitmap.h>
 #include <AknIconUtils.h>
 
+#include <AknBidiTextUtils.h>
 
 namespace {
 
@@ -246,7 +247,17 @@
         {
         TPtr textPtr(iTextBuf->Des());
         textPtr.Zero();
-        textPtr.Copy(iButtonDataArray[ aIndex ].iPopupText);
+        TPtrC popupText;        
+        TRAPD( error, popupText.Set( const_cast <CCCAppCommLauncherLPadModel*>(this)->TextForPopUpL( aIndex ) ) );
+        if ( KErrNone == error )
+            {
+            textPtr.Copy( popupText );
+            }
+        else
+            {
+            textPtr.Copy( iButtonDataArray[ aIndex ].iPopupText );
+            }
+        
         if ( iButtonDataArray[ aIndex ].iClipFromBegining )
         	{
         	// Clip for second row text
@@ -1487,14 +1498,36 @@
 {
     CAknDoubleLargeStyleListBox* listbox =
         static_cast<CAknDoubleLargeStyleListBox*>(&iListBox);
-
-    return AknTextUtils::ClipToFit(
+    TBool result = EFalse;
+    if ( IfShowMultiIcon( aItemIndex ) )
+        {
+        TRect mainPane = iPlugin.ClientRect();
+        TAknLayoutRect listLayoutRect;
+        listLayoutRect.LayoutRect(
+            mainPane,
+            AknLayoutScalable_Apps::list_double_large_graphic_phob2_cc_pane_g3(0).LayoutLine() );
+        TInt multiIconWidth(listLayoutRect.Rect().Width());
+        const TInt KCalculationErrors = 1;
+        CFormattedCellListBoxData *data = listbox->ItemDrawer()->FormattedCellData();
+        const CFont *font = data->Font(listbox->ItemDrawer()->Properties(aItemIndex), aSubCellNumber);
+        TSize cellsize = data->SubCellSize(aSubCellNumber);
+        TMargins margin = data->SubCellMargins(aSubCellNumber);
+        TInt width = cellsize.iWidth - margin.iLeft - margin.iRight - 
+                        multiIconWidth - KAknBidiExtraSpacePerLine - KCalculationErrors;
+        TInt clipgap = data->SubCellTextClipGap(aSubCellNumber);
+        result = AknTextUtils::ClipToFit(
+            aBuffer, *font, width, AknTextUtils::EClipFromBeginning, width + clipgap);
+        }
+    else
+        {
+        result = AknTextUtils::ClipToFit(
         aBuffer,
         AknTextUtils::EClipFromBeginning,
         listbox,
         aItemIndex,
         aSubCellNumber);
 }
-
+    return result;
+    }
 
 // End of File
--- a/phonebookui/Phonebook2/ccapplication/ccadetailsviewplugin/inc/ccappdetailsviewlistboxmodel.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccadetailsviewplugin/inc/ccappdetailsviewlistboxmodel.h	Mon Mar 15 12:39:26 2010 +0200
@@ -208,6 +208,14 @@
     void SetInitialFocusIndex(TInt aIndex);
     
     /**
+      * Set focused list item index by store field index
+      * 
+      * @param aIndex, a field index in store
+      * @retrun actually focused list item
+      */
+    TInt FindFocusListIndexByStoreIndex(TInt aIndex);
+    
+    /**
      *
      */
     MVPbkBaseContactField* FocusedFieldLC();
--- a/phonebookui/Phonebook2/ccapplication/ccadetailsviewplugin/src/ccappdetailsviewcontainer.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccadetailsviewplugin/src/ccappdetailsviewcontainer.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -588,7 +588,7 @@
     // PreCond:
     __ASSERT_DEBUG(iListBoxModel, Panic(EPanicPreCond_FocusedFieldIndex));
 
-    return iListBoxModel->FocusedListIndex();
+    return iListBoxModel->FocusedFieldIndex();
 }
 
 // --------------------------------------------------------------------------
@@ -597,7 +597,8 @@
 //
 void CCCAppDetailsViewContainer::SetFocusedFieldIndex(TInt aIndex)
 {
-    iListBoxModel->SetInitialFocusIndex(aIndex);
+    TInt focusedItemIndex = iListBoxModel->FindFocusListIndexByStoreIndex( aIndex );
+    iListBoxModel->SetInitialFocusIndex(focusedItemIndex);
 }
 
 // --------------------------------------------------------------------------
--- a/phonebookui/Phonebook2/ccapplication/ccadetailsviewplugin/src/ccappdetailsviewlistboxmodel.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccadetailsviewplugin/src/ccappdetailsviewlistboxmodel.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -383,6 +383,26 @@
     }
 }
 
+TInt CCCAppDetailsViewListBoxModel::FindFocusListIndexByStoreIndex(TInt aIndex)
+    {
+    TInt fieldIndex = iPresentationContact->PresentationFields().FieldIndexOfStoreField( aIndex );
+    
+    TInt focusListIndex = KErrNotFound;
+    
+    TInt count = iInxToPresentationIdx.Count();
+    
+    for ( TInt i = 0; i < count && focusListIndex == KErrNotFound; i++ )
+        {
+        TInt *index = iInxToPresentationIdx.Find( i );
+        if ( index && *index >= KErrNone && *index == fieldIndex )
+            {
+            focusListIndex = i;
+            }
+        }
+    return focusListIndex;
+    }
+
+
 // --------------------------------------------------------------------------
 // CCCAppDetailsViewListBoxModel::FocusedFieldLC
 // --------------------------------------------------------------------------
--- a/phonebookui/Phonebook2/ccapplication/ccamycardplugin/group/ccappmycardplugin.mmp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccamycardplugin/group/ccappmycardplugin.mmp	Mon Mar 15 12:39:26 2010 +0200
@@ -34,8 +34,6 @@
 SOURCE          ccappmycardcontainer.cpp
 SOURCE          ccappmycard.cpp
 SOURCE          ccappmycardheadercontrol.cpp
-SOURCE          ccappmycardlistboxmodel.cpp
-SOURCE          ccappmycardlistboxrow.cpp
 SOURCE          ccappmycardimageloader.cpp
 
 
@@ -89,6 +87,9 @@
 LIBRARY         touchfeedback.lib 
 LIBRARY         centralrepository.lib
 
+LIBRARY         estor.lib
+LIBRARY         efsrv.lib
+
 DEBUGLIBRARY    flogger.lib
 
 // End of File
--- a/phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycard.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycard.h	Mon Mar 15 12:39:26 2010 +0200
@@ -39,6 +39,7 @@
 class CPbk2ApplicationServices;
 class CCCAppMyCardPlugin;	
 class MPbk2DialogEliminator;
+class CTimerCallBack;
 
 /**
  * MyCard Observer class
@@ -51,8 +52,12 @@
      */
     enum TEvent
         {
+        /// Undefined event
         EEventNull = 0,
-        EEventContactLoaded
+        /// Contact loaded for the first time
+        EEventContactLoaded,
+        /// Contact has been changed
+        EEventContactChanged
         };
     
     /**
@@ -152,6 +157,26 @@
      */
     void RemoveObserver( MMyCardObserver* aObserver );
 
+    /**
+     * Set contact link. If link is provided it will be used instead of resolving
+     * the own contact link from contact store. This should be called before call to
+     * FetchMyCardL().
+     * 
+     * @param aLink contact link 
+     */
+    void SetLinkL( const MVPbkContactLink& aLink );
+    
+    /**
+     * Start fetching the data of own contact and observe it's changing.
+     */
+    void FetchMyCardL();
+    
+    /**
+     * Force MyCard to open editor and create new own contact once the 
+     * contact store is opened. This should be called before calling FetchMyCardL.
+     */
+    void ForceCreateMyCard();
+    
 private: // from MVPbkContactStoreObserver
      void StoreReady(MVPbkContactStore& aContactStore);
      void StoreUnavailable(MVPbkContactStore& aContactStore, 
@@ -230,6 +255,11 @@
      */
     static TInt ExitDlgL( TAny* aPtr );
     
+    /**
+     * Async callback function for opening stores.
+     */
+    static TInt OpenStoresL( TAny* aPtr );
+
     /*
      * Closes the CCA
      */
@@ -270,6 +300,14 @@
 	TInt iFocusedFieldIndex;	
 	/// Now own. Editor dialog eliminator
 	MPbk2DialogEliminator* iEditorEliminator;
+	/// Current event
+	MMyCardObserver::TEvent iEvent;
+	/// Own. Store opener callback
+	CTimerCallBack* iStoreCallBack;
+	/// Force editor flag
+	TBool iForceCreateMyCard;
+	// Flag for editor state
+	TBool iDialogIsRunning;
 	};
 
 #endif // CCAPPMYCARD_H
--- a/phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycardcontainer.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycardcontainer.h	Mon Mar 15 12:39:26 2010 +0200
@@ -25,6 +25,7 @@
 #include "ccappmycard.h"
 #include "ccappmycardimageloader.h"
 #include <MPbk2ContactUiControl.h>
+#include <MPbk2ClipListBoxText.h>
 #include <aknlongtapdetector.h>
 #include "ccappmycardheadercontrol.h"
 
@@ -34,13 +35,14 @@
 class CCCAppMyCardHeaderControl;
 class CAknsBasicBackgroundControlContext;
 class CAknFormDoubleGraphicStyleListBox;
-class CCCAppMyCardListBoxModel;
+class CSpbContactDataModel;
 class CCCAppStatusControl;
 class CPbk2ApplicationServices;
 class CSpbContentProvider;
 class MCCAViewLauncher;
 class CCCAExtensionFactory;
 class CCCaFactoryExtensionNotifier;
+class CPbk2IconArray;
 
 /**
  * Class implementing CCAppMyCard -container for UI controls
@@ -57,7 +59,8 @@
     public MPbk2ContactUiControl,
     public MCCAStatusControlObserver,
     public MMyCardHeaderControlObserver,
-    public MAknLongTapDetectorCallBack
+    public MAknLongTapDetectorCallBack,
+    public MPbk2ClipListBoxText
     {
 public: // constructor and destructor
 
@@ -114,6 +117,11 @@
         TEventCode aType );
 
     /**
+     * From CCoeControl
+     */
+    void GetHelpContext(TCoeHelpContext& aContext) const;
+    
+    /**
      * From MMyCardObserver
      */
     void MyCardEventL( MMyCardObserver::TEvent aEvent );
@@ -159,6 +167,14 @@
     */
     void HandlePointerEventL( const TPointerEvent& aPointerEvent );
 
+    /**
+     * From MPbk2ClipListBoxText
+     */
+    TBool ClipFromBeginning(
+        TDes& aBuffer,
+        TInt aItemIndex,
+        TInt aSubCellNumber);
+
     
 public: // New
 
@@ -294,7 +310,7 @@
      * Reference to listbox model
      * Not own.
      */
-    CCCAppMyCardListBoxModel* iModel;
+    CSpbContactDataModel& iModel;
 
     /**
      * Contact image loader
@@ -348,6 +364,11 @@
      * Flag for checking if Stylys opened 
      */
     TBool iLongTapHandled;    
+    
+    /**
+     * Not own. Listbox's icon array
+     */
+    CPbk2IconArray* iIconArray;
     };
 
 #endif // CCAPPMYCARDCONTAINER_H
--- a/phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycardimageloader.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycardimageloader.h	Mon Mar 15 12:39:26 2010 +0200
@@ -87,6 +87,20 @@
     void LoadContactImageL( 
             MVPbkStoreContact& aContact, 
             const TSize& aThumbnailSize );
+    
+    /**
+     * Start loading contacts image. Will cancel any previous requests.
+     * Once loading is complete the new image is delivered to observer 
+     * with a call to MMyCardImageLoaderObserver::ThumbnailReady.
+     * 
+     * @param aImageData source data for the image
+     * @param aImageFileName filename of the image
+     */
+    void LoadImageL( 
+        const TDesC8& aImageData,
+        const TDesC& aImageFileName,
+        const TSize& aThumbnailSize );
+    
     void ResizeImageL( const TSize& aThumbnailSize );
     
 private:    // From MCCAppImageDecodingObserver
--- a/phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycardplugin.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccamycardplugin/inc/ccappmycardplugin.h	Mon Mar 15 12:39:26 2010 +0200
@@ -28,7 +28,7 @@
 class CAiwServiceHandler;
 class CCCAppMyCardContainer;
 class CPbk2CommandHandler;
-
+class CSpbContactDataModel;
 
 /**
  *  Class implementing CCCAppViewPluginBase interface. This is
@@ -66,6 +66,11 @@
      */
     CCCAppMyCard& MyCard();
     
+    /**
+     * MyCard's contact data model
+     */
+    CSpbContactDataModel& Model();
+    
     /*
      * Edit my card fields
      * 
@@ -73,6 +78,13 @@
      */
     void EditL( TInt aFocusedFieldIndex );
     
+    /*
+    * Handle error code
+    * @aError System wide error code
+    */
+    void HandleError( TInt aError );
+       
+    
 public: 
 
 // from base class CCCAppViewPluginBase
@@ -187,8 +199,7 @@
      * Creates command handler if not created, and returns pointer to it.
      */
     CPbk2CommandHandler* CommandHandlerL();
-    
-      
+           
 private: // constructors
     
     /**
@@ -220,6 +231,9 @@
     
     // Own. Command handler
     CPbk2CommandHandler* iCommandHandler;
+    
+    // Own. MyCard contact model
+    CSpbContactDataModel* iModel;
     };
 
 #endif // CCAPPMYCARDPLUGIN_H
--- a/phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycard.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycard.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -23,6 +23,8 @@
 #include <coemain.h>
 #include <f32file.h>
 #include <avkon.hrh>
+#include <eikenv.h>
+#include <aknViewAppUi.h>
 
 // Virtual phonebook
 #include <CVPbkContactManager.h>
@@ -50,15 +52,87 @@
 #include <CPbk2SortOrderManager.h>
 #include <Pbk2ContactNameFormatterFactory.h>
 #include <MPbk2ContactNameFormatter.h>
-#include <CPbk2ApplicationServices.h>	
+#include <CPbk2ApplicationServices.h>
 #include <CPbk2StoreManager.h>
-#include <CPbk2StoreConfiguration.h>	
+#include <CPbk2StoreConfiguration.h>
 #include <CPbk2ContactEditorDlg.h>
 #include <MVPbkBaseContactField.h>
+
 // internal
 #include "ccappmycardplugin.h"
 #include <ccappmycardpluginrsc.rsg>
 
+/**
+ * Helper class for making delayed callbacks
+ * @see public methods of CTimer for help
+ */
+class CTimerCallBack : public CTimer
+    {
+public:
+    /**
+     * @param aCallBack called when CTimer is due to run
+     * @param aPriority priority of CTimer
+     */
+    static CTimerCallBack* NewL(
+        const TCallBack& aCallBack,
+        CActive::TPriority aPriority = CActive::EPriorityIdle );
+
+protected: // From CActive
+    void RunL();
+    TInt RunError( TInt /*aError*/ );
+
+protected:
+    CTimerCallBack( const TCallBack& aCallBack, CActive::TPriority aPriority );
+
+private: // data
+    TCallBack iCallBack;
+    };
+
+
+// ---------------------------------------------------------------------------
+// CTimerCallBack::NewL
+// ---------------------------------------------------------------------------
+//
+CTimerCallBack* CTimerCallBack::NewL(
+    const TCallBack& aCallBack,
+    CActive::TPriority aPriority )
+    {
+    CTimerCallBack* self = new(ELeave) CTimerCallBack( aCallBack, aPriority );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CTimerCallBack::RunL
+// ---------------------------------------------------------------------------
+//
+CTimerCallBack::CTimerCallBack( const TCallBack& aCallBack, CActive::TPriority aPriority ) :
+    CTimer( aPriority ), iCallBack( aCallBack )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CTimerCallBack::RunL
+// ---------------------------------------------------------------------------
+//
+void CTimerCallBack::RunL()
+    {
+    iCallBack.CallBack();
+    }
+
+// ---------------------------------------------------------------------------
+// CTimerCallBack::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CTimerCallBack::RunError( TInt /*aError*/ )
+    {
+    // Leaves in RunL are ignored
+    return KErrNone;
+    }
+
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -69,12 +143,12 @@
 CCCAppMyCard* CCCAppMyCard::NewL( CCCAppMyCardPlugin& aPlugin, RFs* aFs )
     {
     CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCard::NewL()"));
-    
+
     CCCAppMyCard* self = new ( ELeave ) CCCAppMyCard( aPlugin );
     CleanupStack::PushL( self );
     self->ConstructL(aFs);
     CleanupStack::Pop( self );
-    
+
     CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::NewL()"));
     return self;
     }
@@ -94,7 +168,7 @@
     delete iMyCardContact;
     delete iFieldProperties;
     delete iSpecificFieldProperties;
-    
+
     iObservers.Reset();
 
     if( iAppServices )
@@ -102,10 +176,11 @@
 	   iAppServices->StoreManager().DeregisterStoreEvents(*this);
 	   }
 	Release(iAppServices);
-    
+
 	delete iCloseCallBack;
     delete iCreateCallBack;
     delete iDlgCloseCallBack;
+    delete iStoreCallBack;
 
 	CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::~CCCAppMyCard()"));
     }
@@ -115,7 +190,8 @@
 // ---------------------------------------------------------------------------
 //
 inline CCCAppMyCard::CCCAppMyCard( CCCAppMyCardPlugin& aPlugin )
-: iPlugin( aPlugin )
+: iPlugin( aPlugin ), iEvent( MMyCardObserver::EEventContactLoaded )
+
 	{
     }
 
@@ -127,19 +203,17 @@
     {
     // Get the AppServices instance
 	iAppServices = CPbk2ApplicationServices::InstanceL();
-	
+
 	CPbk2StoreManager& storeManager = iAppServices->StoreManager();
 	iVPbkContactManager = &iAppServices->ContactManager();
 	storeManager.RegisterStoreEventsL( *this );
 	storeManager.EnsureDefaultSavingStoreIncludedL();
-	// open stores
-	storeManager.OpenStoresL();
-	
-	iCloseCallBack = new(ELeave) CAsyncCallBack( 
-        TCallBack( CloseCcaL, this ), CActive::EPriorityIdle );	
-    iCreateCallBack = new(ELeave) CAsyncCallBack( 
-        TCallBack( CreateMyCardContact, this ), CActive::EPriorityHigh );  
-    iDlgCloseCallBack = new(ELeave) CAsyncCallBack( 
+
+	iCloseCallBack = new(ELeave) CAsyncCallBack(
+        TCallBack( CloseCcaL, this ), CActive::EPriorityIdle );
+    iCreateCallBack = new(ELeave) CAsyncCallBack(
+        TCallBack( CreateMyCardContact, this ), CActive::EPriorityHigh );
+    iDlgCloseCallBack = new(ELeave) CAsyncCallBack(
         TCallBack( ExitDlgL, this ), CActive::EPriorityHigh );
 	}
 
@@ -156,23 +230,23 @@
             // own contact not loaded
             User::Leave( KErrNotReady );
             }
-        
+
         const MVPbkContactStoreProperties& storeProperties =
             iMyCardContact->ParentStore().StoreProperties();
         const MVPbkFieldTypeList& supportedFieldTypes =
             storeProperties.SupportedFields();
-    
+
         if( !iFieldProperties )
             {
             iFieldProperties = CPbk2FieldPropertyArray::NewL(
                 supportedFieldTypes, iVPbkContactManager->FsSession() );
             }
-    
+
         // Create a field property list of the supported
         // field types of the used store
         CPbk2StorePropertyArray* pbk2StoreProperties = CPbk2StorePropertyArray::NewL();
         CleanupStack::PushL( pbk2StoreProperties );
-    
+
         if( !iSpecificFieldProperties )
             {
             iSpecificFieldProperties = CPbk2StoreSpecificFieldPropertyArray::NewL(
@@ -182,12 +256,12 @@
                 iMyCardContact->ParentStore() );
             }
 
-        iPresentationContact = CPbk2PresentationContact::NewL( 
+        iPresentationContact = CPbk2PresentationContact::NewL(
             *iMyCardContact, *iSpecificFieldProperties );
-        
+
         CleanupStack::PopAndDestroy( pbk2StoreProperties );
         }
-    
+
     return *iPresentationContact;
     }
 
@@ -243,7 +317,7 @@
             iObservers.AppendL( aObserver );
             if( iMyCardContact )
                 {
-                aObserver->MyCardEventL( MMyCardObserver::EEventContactLoaded ); 
+                aObserver->MyCardEventL( MMyCardObserver::EEventContactLoaded );
                 }
             }
         }
@@ -263,6 +337,44 @@
     }
 
 // ---------------------------------------------------------------------------
+// CCCAppMyCard::SetLinkL
+// ---------------------------------------------------------------------------
+//
+void CCCAppMyCard::SetLinkL( const MVPbkContactLink& aLink )
+    {
+    MVPbkContactLink* link = aLink.CloneLC();
+    CleanupStack::Pop(); // link
+    delete iMyCard;
+    iMyCard = link;
+    }
+
+// ---------------------------------------------------------------------------
+// CCCAppMyCard::FetchMyCardL
+// ---------------------------------------------------------------------------
+//
+void CCCAppMyCard::FetchMyCardL()
+    {
+    if( !iStoreCallBack )
+        {
+        iStoreCallBack = CTimerCallBack::NewL(
+            TCallBack( &CCCAppMyCard::OpenStoresL, this ) );
+
+        // 200 ms delay before open. Used to prevent system jamming before the
+        // UI is drawn, so that launching of mycard feels a lot faster.
+        iStoreCallBack->After( 200e3 );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CCCAppMyCard::ForceCreateMyCard
+// ---------------------------------------------------------------------------
+//
+void CCCAppMyCard::ForceCreateMyCard()
+    {
+    iForceCreateMyCard = ETrue;
+    }
+
+// ---------------------------------------------------------------------------
 // CCCAppMyCard::NotifyObservers
 // ---------------------------------------------------------------------------
 //
@@ -274,7 +386,7 @@
         TRAPD( err, iObservers[i]->MyCardEventL( aEvent ) );
         if( err )
             {
-            CCA_DP(KMyCardLogFile, 
+            CCA_DP(KMyCardLogFile,
                 CCA_L("<-CCCAppMyCard::NotifyObservers notify error (%d)"), err );
             }
         }
@@ -286,23 +398,23 @@
 //
 void CCCAppMyCard::LoadContact()
     {
-    CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCard::LoadContact()"));    
+    CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCard::LoadContact()"));
 
     if( !iFetchOperation && iMyCard )
         {
-        TRAPD( err, iFetchOperation = 
+        TRAPD( err, iFetchOperation =
             iVPbkContactManager->RetrieveContactL( *iMyCard, *this ) );
         if( err )
             {
-            // Cannot load own contact from VPbk  
-            CCA_DP(KMyCardLogFile, 
-                CCA_L("  CCCAppMyCard::LoadContact load error = %d"), err ); 
-    
-            // TODO: How is this handled. show error on UI?
+            // Cannot load own contact from VPbk
+            CCA_DP(KMyCardLogFile,
+                CCA_L("  CCCAppMyCard::LoadContact load error = %d"), err );
+
+            iPlugin.HandleError( err );
             }
         }
-    
-    CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::LoadContact()"));    
+
+    CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::LoadContact()"));
     }
 
 // ---------------------------------------------------------------------------
@@ -312,19 +424,35 @@
 void CCCAppMyCard::StoreReady( MVPbkContactStore& aContactStore )
 	{
     CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCard::StoreReady()"));
-    
-    // MyCard is always created to contact model. So we check that event was
-    // from the correct store.
-    const MVPbkContactStoreProperties& storeProperties = 
-				aContactStore.StoreProperties();
-    TVPbkContactStoreUriPtr uri = storeProperties.Uri();
-    TInt isSame = uri.Compare( VPbkContactStoreUris::DefaultCntDbUri(), 
-    		TVPbkContactStoreUriPtr::EContactStoreUriAllComponents );
-	if( isSame == 0 )
-		{				
+
+	const MVPbkContactStoreProperties& storeProperties =
+		aContactStore.StoreProperties();
+	TVPbkContactStoreUriPtr uri = storeProperties.Uri();
+	TInt isSame = uri.Compare( VPbkContactStoreUris::DefaultCntDbUri(),
+		TVPbkContactStoreUriPtr::EContactStoreUriAllComponents );
+
+	if( isSame != 0 )
+		{
+		return;
+		}
+
+    if( iMyCard )
+        {
+        // if link is already available then use that
+        LoadContact();
+        }
+    else if( iForceCreateMyCard )
+        {
+        // launch editor because we don't have mycard
+        iCreateCallBack->Call();
+        }
+    else
+        {
+        // MyCard is always created to contact model. So we check that event was
+        // from the correct store.
 		delete iOperation;
 		iOperation = NULL;
-		
+
 		MVPbkContactStore2* phoneStoreExtension =
 			static_cast<MVPbkContactStore2*>(aContactStore.ContactStoreExtension(KMVPbkContactStoreExtension2Uid));
 		if ( phoneStoreExtension )
@@ -332,11 +460,11 @@
 			TRAPD( err, iOperation = phoneStoreExtension->OwnContactLinkL(*this) );
 			if( err )
 				{
-				// TODO: how is this handled?
+                iPlugin.HandleError( err );
 				}
 			}
-		}
-    CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::StoreReady()"));    
+        }
+    CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::StoreReady()"));
 	}
 
 // ---------------------------------------------------------------------------
@@ -344,10 +472,10 @@
 // ---------------------------------------------------------------------------
 //
 void CCCAppMyCard::StoreUnavailable(
-		MVPbkContactStore& /*aContactStore*/, 
+		MVPbkContactStore& /*aContactStore*/,
         TInt /*aReason*/)
 	{
-    CCA_DP(KMyCardLogFile, CCA_L("  CCCAppMyCard::StoreUnavailable()"));    
+    CCA_DP(KMyCardLogFile, CCA_L("  CCCAppMyCard::StoreUnavailable()"));
 	}
 
 // ---------------------------------------------------------------------------
@@ -355,23 +483,36 @@
 // ---------------------------------------------------------------------------
 //
 void CCCAppMyCard::HandleStoreEventL(
-        MVPbkContactStore& /*aContactStore*/, 
+        MVPbkContactStore& /*aContactStore*/,
         TVPbkContactStoreEvent aStoreEvent )
 	{
-    CCA_DP(KMyCardLogFile, 
-        CCA_L("->CCCAppMyCard::HandleStoreEventL Event = %d"), 
+    CCA_DP(KMyCardLogFile,
+        CCA_L("->CCCAppMyCard::HandleStoreEventL Event = %d"),
         aStoreEvent.iEventType );
-    
+
     if( aStoreEvent.iEventType == TVPbkContactStoreEvent::EContactChanged )
         {
         if( iMyCard && aStoreEvent.iContactLink->IsSame( *iMyCard ) )
             {
             // Own contact has changed. Reload contact to update content
+            iEvent = MMyCardObserver::EEventContactChanged;
             LoadContact();
             }
         }
+    else if( aStoreEvent.iEventType == TVPbkContactStoreEvent::EContactDeleted )
+        {
+        if( iMyCard && aStoreEvent.iContactLink->IsSame( *iMyCard ) )
+            {
+            if( !iDialogIsRunning )
+                {
+                CEikAppUi* aEikAppUi = CEikonEnv::Static()->EikAppUi();
+                CAknViewAppUi* appUi = static_cast<CAknViewAppUi*> ( aEikAppUi );
+                appUi->RunAppShutter();
+                }
+            }
+        }
 
-    CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::HandleStoreEventL()") ); 
+    CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::HandleStoreEventL()") );
 	}
 
 // ---------------------------------------------------------------------------
@@ -382,15 +523,15 @@
         MVPbkContactOperationBase& /*aOperation*/,
         MVPbkContactLink* aLink )
 	{
-    CCA_DP(KMyCardLogFile, 
+    CCA_DP(KMyCardLogFile,
         CCA_L("->CCCAppMyCard::VPbkSingleContactLinkOperationComplete()") );
-    
+
     delete iMyCard;
 	iMyCard = aLink;
-	
+
 	LoadContact();
 
-	CCA_DP(KMyCardLogFile, 
+	CCA_DP(KMyCardLogFile,
         CCA_L("<-CCCAppMyCard::VPbkSingleContactLinkOperationComplete()") );
 	}
 
@@ -415,9 +556,9 @@
         // launch contact editor
         iCreateCallBack->Call();
         }
-	if( error )
+	if( error != KErrNone && error != KErrNotFound )
 	    {
-	    // TODO handle error
+        iPlugin.HandleError( error );
 	    }
 	
 	CCA_DP(KMyCardLogFile, 
@@ -433,6 +574,12 @@
 	CCCAppMyCard* self = static_cast<CCCAppMyCard*>( aPtr );
 	TRAPD( err, self->LaunchContactEditorL( TPbk2ContactEditorParams::ENewContact | 
         TPbk2ContactEditorParams::EOwnContact ) );
+	
+	if( err != KErrNone )
+        {
+        self->iPlugin.HandleError( err );
+        }
+	
 	return err;
 	}
 
@@ -476,6 +623,8 @@
         CleanupStack::Pop( title );
         iEditorEliminator = dlg;
         dlg->ResetWhenDestroyed( &iEditorEliminator );
+        
+        iDialogIsRunning = ETrue;
         dlg->ExecuteLD();
         }
 	
@@ -523,6 +672,7 @@
         }
     
     delete aEditedContact; // ignore given contact
+    iDialogIsRunning = EFalse;
 	}
 
 // ---------------------------------------------------------------------------
@@ -535,6 +685,7 @@
 	// Editing was cancelled, go back to phonebook
 	delete aEditedContact;	
 	iCloseCallBack->Call();
+	iDialogIsRunning = EFalse;
 	}
 
 // ---------------------------------------------------------------------------
@@ -543,6 +694,7 @@
 //
 void CCCAppMyCard::ContactEditingAborted()
 	{
+    iDialogIsRunning = EFalse;
 	// Editing was aborted -> move to pb2
 	}
 
@@ -587,6 +739,17 @@
     }
 
 // ---------------------------------------------------------------------------
+// CCCAppMyCard::OpenStoresL
+// ---------------------------------------------------------------------------
+//
+TInt CCCAppMyCard::OpenStoresL( TAny* aPtr )
+    {
+    CCCAppMyCard* self = static_cast<CCCAppMyCard*>( aPtr );
+    self->iAppServices->StoreManager().OpenStoresL();
+    return 0;
+    }
+
+// ---------------------------------------------------------------------------
 // CCCAppMyCard::DoCloseCCaL
 // ---------------------------------------------------------------------------
 //
@@ -611,17 +774,13 @@
             TPbk2ContactEditorParams::EOwnContact) );
     	if( err != KErrNone )
 			{
-			//TODO handle errors
+            iPlugin.HandleError( err );
 			}
     	}    
     else if( aResult.iOpCode == MVPbkContactObserver::EContactDelete )
     	{
 		iCloseCallBack->Call();
-    	}
-    else
-    	{
-    	//TODO handle errors
-    	}
+    	}   
         
     CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCard::ContactOperationCompleted()")); 
     }
@@ -631,9 +790,12 @@
 // ---------------------------------------------------------------------------
 //
 void CCCAppMyCard::ContactOperationFailed(
-    TContactOp /*aOpCode*/, TInt /*aErrorCode*/, TBool /*aErrorNotified*/)    
+    TContactOp aOpCode, TInt aErrorCode, TBool /*aErrorNotified*/ )    
     {
-    // TODO handle error
+    if ( aErrorCode != KErrNone )          
+        {                                  
+        iPlugin.HandleError( aErrorCode );    
+        }        
     }
 
 // ---------------------------------------------------------------------------
@@ -657,7 +819,7 @@
     delete iPresentationContact;
     iPresentationContact = NULL;
     
-    NotifyObservers( MMyCardObserver::EEventContactLoaded );
+    NotifyObservers( iEvent );
 
     CCA_DP(KMyCardLogFile, 
         CCA_L("<-CCCAppMyCard::VPbkSingleContactOperationComplete()"));    
@@ -681,7 +843,10 @@
     delete iOperation;
     iOperation = NULL;
     
-    // TODO: How to handle loading error?
+    if( aError != KErrNone )
+        {
+        iPlugin.HandleError( aError );
+        }
 
     CCA_DP(KMyCardLogFile, 
         CCA_L("<-CCCAppMyCard::VPbkSingleContactOperationFailed()") );    
--- a/phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycardcontainer.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycardcontainer.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -25,6 +25,7 @@
 #include <AknsDrawUtils.h>
 #include <AknsBasicBackgroundControlContext.h>
 #include <AknUtils.h>
+#include <s32mem.h>
 
 #include <MPbk2ContactNameFormatter.h>
 #include <MVPbkStoreContact.h>
@@ -39,13 +40,15 @@
 #include "ccappmycardcontainer.h"
 #include "ccappmycardcommon.h"
 #include "ccappmycardheadercontrol.h"
-#include "ccappmycardlistboxmodel.h"
 #include "ccappmycardplugin.h"
 #include "ccafactoryextensionnotifier.h"
-#include "spbcontentprovider.h"
+
+#include <spbcontentprovider.h>
+#include <spbcontactdatamodel.h> 
 
 #include <MVPbkContactFieldTextData.h>
 #include <ccaextensionfactory.hrh>
+#include <mccaparameter.h>
 
 #include <aknlayoutscalable_avkon.cdl.h>
 #include <layoutmetadata.cdl.h>
@@ -65,18 +68,22 @@
 #include <pbk2nameordercenrep.h>
 #include <centralrepository.h>
 #include <Phonebook2PrivateCRKeys.h>
+#include <CPbk2PresentationContact.h>
+#include <CPbk2PresentationContactFieldCollection.h>
 
 #include <CPbk2ApplicationServices.h>
 #include <CPbk2ServiceManager.h>
 #include <TPbk2IconId.h>
 #include <CPbk2IconInfo.h>
+#include <csxhelp/phob.hlp.hrh>
+#include <Pbk2UID.h>
 
+#include <f32file.h>
 
 // unnamed namespace
 namespace
 {
 _LIT( KMyCardIconDefaultFileName, "\\resource\\apps\\phonebook2ece.mif" );
-const TText KLineChange = '\n';
 const TInt KSubComponentCount = 2;
 const TInt KNumberOfContacts = 1;
 const TInt KNoContacts = 0;
@@ -93,6 +100,7 @@
 CCCAppMyCardContainer::CCCAppMyCardContainer(
     CCCAppMyCardPlugin& aPlugin ) :
     iPlugin( aPlugin ),
+    iModel( aPlugin.Model() ),
     iNameOrder(KPbk2UiSpecNameOrderFirstNameLastName)
     {
     }
@@ -103,6 +111,7 @@
 //
 CCCAppMyCardContainer::~CCCAppMyCardContainer()
     {
+    iModel.SetClipListBoxText( NULL );
 	iPlugin.MyCard().RemoveObserver( this );
 	delete iBackground;
     delete iHeaderCtrl;
@@ -136,7 +145,8 @@
     iListBox = new(ELeave) CAknFormDoubleGraphicStyleListBox;
     iListBox->ConstructL( this, EAknListBoxSelectionList );
     iListBox->SetContainerWindowL( *this );
-
+    iListBox->EnableStretching( EFalse );
+    
     // Setup listbox
     iListBox->View()->SetListEmptyTextL( KNullDesC );
     iListBox->CreateScrollBarFrameL( ETrue );
@@ -147,7 +157,7 @@
     // Create icons for listbox.
     TResourceReader reader;
     iCoeEnv->CreateResourceReaderLC( reader, R_PBK2_FIELDTYPE_ICONS );
-    CPbk2IconArray* iconArray = CPbk2IconArray::NewL( reader );
+    iIconArray = CPbk2IconArray::NewL( reader );
   
     // Calculate preferred size for xsp service icons.
     TRect mainPane;
@@ -181,20 +191,23 @@
             TPbk2IconId id = TPbk2IconId( uid, service.iBitmapId );
             CPbk2IconInfo* info = CPbk2IconInfo::NewLC(
                id, service.iBitmap, service.iMask, size );
-            iconArray->AppendIconL( info );
+            iIconArray->AppendIconL( info );
             CleanupStack::Pop( info );
             }        
         }
     
     Release( appServices );
         
-    iListBox->ItemDrawer()->ColumnData()->SetIconArray( iconArray );
+    iListBox->ItemDrawer()->ColumnData()->SetIconArray( iIconArray );
     CleanupStack::PopAndDestroy(); // reader
 
-    // Create listbox model
-    iModel = CCCAppMyCardListBoxModel::NewL(
-        iPlugin.MyCard(), *iCoeEnv, *iListBox, *iconArray );
-    iListBox->Model()->SetItemTextArray( iModel );
+    // setup model
+    iModel.SetClipListBoxText( this );
+    iModel.UpdateIconsL( *iIconArray );
+    SetNameForHeaderControlL();
+    
+    iListBox->Model()->SetItemTextArray( &iModel.ListBoxModel() );
+    iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
 
     // Get the skin background for the view
     iBackground = CAknsBasicBackgroundControlContext::NewL(
@@ -373,7 +386,30 @@
 	delete iDetailsPopup;
 	iDetailsPopup = NULL;
 	
-	if( iImageLoader )
+	if( !iImageLoader )
+	    {
+        if( !iModel.IsEmpty() )
+            {
+            TPtrC8 data( iModel.Data( CSpbContactDataModel::EDataImageContent ) );
+            TInt err = KErrNotFound;
+            if( data.Length() )
+                {
+                // thumbnail image in model -> load it
+                TPtrC file( iModel.Text( CSpbContactDataModel::ETextImageFileName ) );
+                TRAP( err, 
+                    iImageLoader = CCCAppMyCardImageLoader::NewL( *this );
+                    iImageLoader->LoadImageL( data, file, iHeaderCtrl->ThumbnailSize() );
+                    );
+                }
+            
+            if( err )
+                {
+                // no thumbnail image available -> load default
+                ThumbnailLoadError( KErrNotFound ); 
+                }
+            }
+	    }
+	else
 	    {
         TRAP_IGNORE( iImageLoader->ResizeImageL(iHeaderCtrl->ThumbnailSize()));
 	    }
@@ -489,11 +525,18 @@
 //
 void CCCAppMyCardContainer::MyCardEventL( MMyCardObserver::TEvent aEvent )
     {
-    if( aEvent == MMyCardObserver::EEventContactLoaded )
-        {    
+    if( aEvent == MMyCardObserver::EEventContactChanged ||
+        ( aEvent == MMyCardObserver::EEventContactLoaded && iModel.IsEmpty() ) )
+        {   
+        CCCAppMyCard& mycard = iPlugin.MyCard();
+
+        iModel.SetDataL( mycard.PresentationContactL(), iIconArray );
+        if( iListBox )
+            {
+            iListBox->HandleItemAdditionL();
+            }
+          
         // Set own contact name
-        CCCAppMyCard& mycard = iPlugin.MyCard();
-          
         SetNameForHeaderControlL();
         
         // start loading image
@@ -526,9 +569,9 @@
     {
     // takes ownership
     TRAPD( err, iHeaderCtrl->SetPortraitBitmapL( aThumbnail ) );
-    if( err )
+    if( err != KErrNone )
         {
-        // TODO: how to handle? ignore? show note?
+        iPlugin.HandleError( err );
         }
     // Contact Image set. Set the flag.
     iMyCardImageSet = ETrue;
@@ -724,11 +767,13 @@
 //
 TInt CCCAppMyCardContainer::FocusedFieldIndex() const
 	{
-	if( iModel )
-		{
-		return iModel->FieldIndex( iListBox->CurrentItemIndex() );
-		}
-	return KErrNotFound;
+    TInt index = KErrNotFound;
+    TRAP_IGNORE( 
+        CPbk2PresentationContact& contact = iPlugin.MyCard().PresentationContactL();
+        index = contact.PresentationFields().StoreIndexOfField( 
+            iModel.PresentationFieldIndex( iListBox->CurrentItemIndex() ) );
+        );
+	return index;
 	}
 
 // --------------------------------------------------------------------------
@@ -1008,52 +1053,24 @@
 //
 void CCCAppMyCardContainer::SetNameForHeaderControlL()
 	{
-    // Set own contact name
-    CCCAppMyCard& mycard = iPlugin.MyCard();
-    // Get the myCard store and the field set 
-    MVPbkStoreContact& storeContact = mycard.StoreContact();
-    MVPbkStoreContactFieldCollection& fields = storeContact.Fields();
-                    
-    TInt fieldCount = fields.FieldCount();                           
-    
-    TPtrC firstName( KNullDesC );
-    TPtrC lastName( KNullDesC );
-    
-    // Check all the fields and store first and last name
-    for ( TInt i = 0; i < fieldCount;  ++i )
-    	{
-		MVPbkStoreContactField& field = fields.FieldAt( i );	
-		const MVPbkFieldType* fieldType = field.BestMatchingFieldType();
-		
-		if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_FIRSTNAME )
-			{
-			MVPbkContactFieldData& contactField = field.FieldData();            
-			firstName.Set( MVPbkContactFieldTextData::Cast(contactField).Text());
-			}
-		
-		if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_LASTNAME )
-			{
-			MVPbkContactFieldData& contactField = field.FieldData();			            
-			lastName.Set( MVPbkContactFieldTextData::Cast(contactField).Text());
-			}		
-    	}
-    
+    TPtrC fname( iModel.Text( CSpbContactDataModel::ETextFirstName ) );
+    TPtrC lname( iModel.Text( CSpbContactDataModel::ETextLastName ) );
     switch ( iNameOrder )
         {
         case KPbk2UiSpecNameOrderFirstNameLastName:
             {
-            iHeaderCtrl->SetLabel1TextL( firstName );
-            iHeaderCtrl->SetLabel2TextL( lastName );
+            iHeaderCtrl->SetLabel1TextL( fname );
+            iHeaderCtrl->SetLabel2TextL( lname );
             break;
             }
         case KPbk2UiSpecNameOrderLastNameFirstName: // FALL THROUGH
         default:
             {
-            iHeaderCtrl->SetLabel2TextL( firstName );
-            iHeaderCtrl->SetLabel1TextL( lastName );
+            iHeaderCtrl->SetLabel2TextL( fname );
+            iHeaderCtrl->SetLabel1TextL( lname );
             break;
             }
-        }    
+        }
 	}
 
 //------------------------------------------------------------------------------
@@ -1072,10 +1089,15 @@
         CleanupStack::PopAndDestroy(); // reader
         }
     
-    // MyCard image has been set. Dim optiosn menu items accordingly
+    // MyCard image has been set. Dim option menu items accordingly
     if( iMyCardImageSet )
-        {
-        iImageSelectionPopup->SetItemDimmed(ECCAppMyCardCmdStylusViewImageCmd, EFalse);
+        {        
+        // If the image has been deleted in the memory, "view image" should be hidden.
+        TPtrC imageFileName( iModel.Text( CSpbContactDataModel::ETextImageFileName ) );                        
+        RFs& fs( iCoeEnv->FsSession() );
+        TEntry entry;
+        iImageSelectionPopup->SetItemDimmed( ECCAppMyCardCmdStylusViewImageCmd, 
+                ( fs.Entry( imageFileName , entry ) == KErrNone ) ? EFalse : ETrue );                                                    
         iImageSelectionPopup->SetItemDimmed(ECCAppMyCardCmdStylusChangeImageCmd, EFalse);
         iImageSelectionPopup->SetItemDimmed(ECCAppMyCardCmdStylusRemoveImageCmd, EFalse);
         iImageSelectionPopup->SetItemDimmed(ECCAppMyCardCmdStylusAddImageCmd, ETrue);
@@ -1147,6 +1169,21 @@
     CCoeControl::HandlePointerEventL( aPointerEvent );              
     }
 
+// --------------------------------------------------------------------------
+// CCCAppMyCardContainer::ClipFromBeginning
+// --------------------------------------------------------------------------
+//
+TBool CCCAppMyCardContainer::ClipFromBeginning(
+    TDes& aBuffer, TInt aItemIndex, TInt aSubCellNumber )
+    {
+    if( iListBox )
+        {   
+        return AknTextUtils::ClipToFit( aBuffer, AknTextUtils::EClipFromBeginning,
+            iListBox, aItemIndex, aSubCellNumber );
+        }
+    return EFalse;
+    }
+
 // ---------------------------------------------------------------------------
 // CCCAppCommLauncherContainer::PosToScreenCoordinates
 // ---------------------------------------------------------------------------
@@ -1158,4 +1195,14 @@
      aPos += leftUpperPos;
      }
 
+// ----------------------------------------------------------------------------
+// CCCAppMyCardContainer::GetHelpContext()
+// ----------------------------------------------------------------------------
+//
+void CCCAppMyCardContainer::GetHelpContext(TCoeHelpContext& aContext) const
+    {
+    aContext.iMajor.iUid = KPbk2UID3;
+    aContext.iContext = KHLP_CCA_MY_CARD;
+    }
+
 // End of File
--- a/phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycardimageloader.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycardimageloader.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -103,17 +103,20 @@
         MVPbkStoreContactField& field = fields.FieldAt( i );    
         const MVPbkFieldType* fieldType = field.BestMatchingFieldType();
         
-        if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_THUMBNAILPIC )
+        if ( fieldType )
             {
-            MVPbkContactFieldData& contactField = field.FieldData(); 
-            iImageBuffer = 
-                MVPbkContactFieldBinaryData::Cast(contactField).BinaryData().AllocL();
-            }
-        
-        if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_CALLEROBJIMG )
-            {
-            MVPbkContactFieldData& contactField = field.FieldData();                        
-            iImageFileName = MVPbkContactFieldTextData::Cast(contactField).Text().AllocL();
+            if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_THUMBNAILPIC )
+                {
+                MVPbkContactFieldData& contactField = field.FieldData(); 
+                iImageBuffer = 
+                    MVPbkContactFieldBinaryData::Cast(contactField).BinaryData().AllocL();
+                }
+            
+            if ( fieldType->FieldTypeResId() == R_VPBK_FIELD_TYPE_CALLEROBJIMG )
+                {
+                MVPbkContactFieldData& contactField = field.FieldData();                        
+                iImageFileName = MVPbkContactFieldTextData::Cast(contactField).Text().AllocL();
+                }
             }
         }
         
@@ -142,6 +145,34 @@
     }
 
 // ---------------------------------------------------------------------------
+// CCCAppMyCardImageLoader::LoadImageL
+// ---------------------------------------------------------------------------
+//
+void CCCAppMyCardImageLoader::LoadImageL( 
+    const TDesC8& aImageData,
+    const TDesC& aImageFileName,
+    const TSize& aThumbnailSize )
+    {
+    CCA_DP(KMyCardLogFile, 
+        CCA_L("->CCCAppMyCardImageLoader::LoadImageL()"));
+
+    delete iImageDecoding;
+    iImageDecoding = NULL;
+    
+    RFs& fs = CEikonEnv::Static()->FsSession();
+    iImageDecoding = CCCAppImageDecoding::NewL(
+            *this, 
+            fs, 
+            aImageData.AllocLC(), 
+            aImageFileName.AllocLC() );
+    CleanupStack::Pop( 2 ); // imagedata, imagefilename
+    iImageDecoding->StartL( aThumbnailSize );      
+
+    CCA_DP(KMyCardLogFile, 
+        CCA_L("<-CCCAppMyCardImageLoader::LoadImageL()"));
+    }
+
+// ---------------------------------------------------------------------------
 // CCCAppMyCardImageLoader::ResizeImageL
 // ---------------------------------------------------------------------------
 //
--- a/phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycardplugin.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccamycardplugin/src/ccappmycardplugin.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -22,6 +22,7 @@
 #include "ccappmycardpluginuids.hrh"
 #include "ccappmycard.h"
 #include "ccappmycard.hrh"
+#include <spbcontactdatamodel.h>
 #include <ccappmycardpluginrsc.rsg>
 #include <Pbk2UIControls.rsg>
 #include <data_caging_path_literals.hrh>
@@ -34,6 +35,7 @@
 #include <AiwContactAssignDataTypes.h>
 #include <avkon.hrh>
 #include <aknappui.h>
+#include <s32mem.h>
 #include <CPbk2CommandHandler.h>
 #include <Pbk2Commands.hrh>		//pbk2cmdsend
 #include <Pbk2DataCaging.hrh>	
@@ -43,6 +45,9 @@
 #include <CPbk2PresentationContactFieldCollection.h>
 #include <StringLoader.h>
 #include <AknQueryDialog.h>
+#include <mccapppluginparameter.h>
+#include <mccaparameter.h>
+#include <CVPbkContactManager.h>
 
 // ---------------------------------------------------------------------------
 // Constants
@@ -94,6 +99,8 @@
     
     iCommandsResourceFile.Close();
     
+    delete iModel;
+
     delete iMyCard;
     
     delete iCommandHandler;
@@ -138,15 +145,61 @@
     }
 
 // ---------------------------------------------------------------------------
+// CCCAppMyCardPlugin::Model
+// ---------------------------------------------------------------------------
+//
+CSpbContactDataModel& CCCAppMyCardPlugin::Model()
+    {
+    return *iModel;
+    }
+
+// ---------------------------------------------------------------------------
 // CCCAppMyCardPlugin::PreparePluginViewL
 // ---------------------------------------------------------------------------
 //
 void CCCAppMyCardPlugin::PreparePluginViewL(
-    MCCAppPluginParameter& /*aPluginParameter*/ )
+    MCCAppPluginParameter& aPluginParameter )
     {
     CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardPlugin::PreparePluginViewL()"));
 
+    iModel = CSpbContactDataModel::NewL( 
+        iMyCard->ContactManager(), *iCoeEnv, R_MYCARD_CLIP_FIELD_SELECTOR );
+    
     BaseConstructL( R_CCAMYCARD_VIEW );
+    MCCAParameter& param = aPluginParameter.CCAppLaunchParameter();
+    if( param.ContactDataFlag() == MCCAParameter::EContactLink )
+        {
+        HBufC& data = param.ContactDataL();
+        HBufC8* data8 = HBufC8::NewLC( data.Size() );
+        data8->Des().Copy( data );
+        CVPbkContactLinkArray* array = CVPbkContactLinkArray::NewLC( 
+            *data8, iMyCard->ContactManager().ContactStoresL() );
+        if( array->Count() )
+            {
+            iMyCard->SetLinkL( array->At( 0 ) );
+            }
+        CleanupStack::PopAndDestroy( 2 ); // data, array
+        }
+    else if( param.ContactDataFlag() == MCCAParameter::EContactDataModel )
+        {
+        HBufC& cntData = param.ContactDataL();
+        TPtrC8 data( (TUint8*)cntData.Ptr(), cntData.Size() );
+        RDesReadStream stream( data );
+        CleanupClosePushL( stream );
+        iModel->InternalizeL( stream );
+        CleanupStack::PopAndDestroy(); // strean
+
+        MVPbkContactLink* link = iModel->ContactLink();
+        if( link )
+            {
+            iMyCard->SetLinkL( *link );
+            }
+        else
+            {
+            // model without a link means that mycard does not exist.
+            iMyCard->ForceCreateMyCard();
+            }
+        }
     
     CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardPlugin::PreparePluginViewL()"));
     }
@@ -171,6 +224,8 @@
     SetTitleL( *title );
     CleanupStack::PopAndDestroy( title );
     
+    iMyCard->FetchMyCardL();
+    
     CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardPlugin::DoActivateL()"));
     }
 
@@ -299,6 +354,14 @@
 	iMyCard->EditContactL(  aFocusedFieldIndex );
 	}
 
+// ---------------------------------------------------------------------------
+// CCCAppMyCardPlugin::HandleError
+// ---------------------------------------------------------------------------
+//
+void CCCAppMyCardPlugin::HandleError( TInt aError )
+    {
+    CCoeEnv::Static()->HandleError( aError );
+    }
 
 // ---------------------------------------------------------------------------
 // CCCAppMyCardPlugin::NewContainerL
@@ -395,32 +458,39 @@
 //
 void CCCAppMyCardPlugin::ProcessCommandL(TInt aCommandId)
      {
+     TInt err = KErrNone;
+     
      switch(aCommandId)
          {
-         case ECCAppMyCardCmdStylusViewImageCmd:
-             ViewImageCmdL();
-             break;
+         case ECCAppMyCardCmdStylusViewImageCmd:             
+             TRAP( err, ViewImageCmdL() );             
+             break;             
              
          case ECCAppMyCardCmdStylusChangeImageCmd:
-             ChangeImageCmdL();
+             TRAP( err, ChangeImageCmdL() );             
              break;
              
          case ECCAppMyCardCmdStylusRemoveImageCmd:
-             RemoveImageCmdL();
+             TRAP( err, RemoveImageCmdL() );             
              break;
              
          case ECCAppMyCardCmdStylusAddImageCmd:
-             AddImageCmdL();
+             TRAP( err, AddImageCmdL() );             
              break;
              
          case ECCAppMyCardCmdStylusCopyDetailCmd:             
-              CopyDetailL();
+              TRAP( err, CopyDetailL() );              
               break;                        
              
          default:
         	 CAknView::ProcessCommandL(aCommandId);
              break;
          }
+     
+      if( err != KErrNone )
+         {
+         HandleError( err );
+         }
      }
 
 // --------------------------------------------------------------------------- 
@@ -467,4 +537,5 @@
     {
     CommandHandlerL()->HandleCommandL( EPbk2CmdCopyDetail, *iOwnContainer, NULL );
     }
+
 // End of File
--- a/phonebookui/Phonebook2/ccapplication/ccapp/ccapputil/src/ccappimagedecoding.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccapp/ccapputil/src/ccappimagedecoding.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -206,7 +206,7 @@
     TSize dummy;
     Pbk2PresentationImageUtils::CropImageL(
             *iBitmap, 
-            Pbk2PresentationImageUtils::ELandscapeCropping, 
+            Pbk2PresentationImageUtils::ECropping, 
             dummy );
     }
 
--- a/phonebookui/Phonebook2/ccapplication/ccapp/src/ccapppluginloader.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/ccapplication/ccapp/src/ccapppluginloader.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -23,7 +23,7 @@
 #include <mccapluginfactory.h>
 
 #include <cpbk2applicationservices.h>
-#include <cvpbkcontactmanager.h>
+#include <CVPbkContactManager.h>
 #include <MVPbkContactStoreProperties.h>
 #include <VPbkContactStoreUris.h>
 #include <TVPbkContactStoreUriPtr.h>
--- a/phonebookui/Phonebook2/group/pbk2spbcontentprovider.mmp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/group/pbk2spbcontentprovider.mmp	Mon Mar 15 12:39:26 2010 +0200
@@ -41,6 +41,10 @@
 SOURCE          spbphonenumberparser.cpp
 SOURCE          spbcontactstorelistener.cpp
 
+SOURCE          spbcontactdatamodel.cpp
+SOURCE          spbcontactdatamodelprivate.cpp
+SOURCE          spbcontactdatamodelrow.cpp
+
 // Resources
 
 // Include paths
@@ -52,11 +56,14 @@
 LIBRARY         bafl.lib
 LIBRARY         egul.lib 
 LIBRARY         ecom.lib
+LIBRARY         cone.lib
+LIBRARY         estor.lib 
 
 LIBRARY         featmgr.lib
 LIBRARY         vpbkeng.lib
 LIBRARY         bsclient.lib
 LIBRARY         pbk2presentation.lib
+LIBRARY         pbk2commonui.lib
 LIBRARY         presencecacheclient2.lib
 LIBRARY         presencecacheutils.lib
 
--- a/phonebookui/Phonebook2/inc/CPbk2FetchDlg.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/inc/CPbk2FetchDlg.h	Mon Mar 15 12:39:26 2010 +0200
@@ -123,6 +123,9 @@
                 TInt iNaviPaneId;
                 /// Ref: Exit callback
                 MPbk2ExitCallback* iExitCallback;
+                /// Own: SK1 is invisible till user selects defined amount of entries
+                /// default is 1 if not defined by user
+                TInt iMinSelection;
             };
 
     public: // Construction and destruction
--- a/phonebookui/Phonebook2/inc/CPbk2MemoryEntryDefaultsDlg.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/inc/CPbk2MemoryEntryDefaultsDlg.h	Mon Mar 15 12:39:26 2010 +0200
@@ -99,6 +99,7 @@
                 TInt& aIndex ) const;
         TBool IsSupported(
                 const VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aSelectorID ) const;
+        TBool HasMailboxAccountsL() const;
         TBool IsAvailableL(
                 const VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aSelectorID ) const;
         void SetDefaultL(
--- a/phonebookui/Phonebook2/inc/CPbk2NamesListControl.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/inc/CPbk2NamesListControl.h	Mon Mar 15 12:39:26 2010 +0200
@@ -77,7 +77,8 @@
                               public MAdaptiveSearchTextObserver,
                               public MEikListBoxObserver,
                               public MPbk2ControlContainerForegroundEventObserver,
-                              public MPbk2CommandItemUpdater
+                              public MPbk2CommandItemUpdater,
+                              public MVPbkContactViewObserverExtension 
     {
     public: // Enumerations
 
@@ -347,7 +348,11 @@
                 MVPbkContactViewBase& aView,
                 TInt aError,
                 TBool aErrorNotified );
-
+        TAny* ContactViewObserverExtension(TUid aExtensionUid );
+                  
+    private: // From MVPbkContactViewUpdateObserver        
+          void FilteredContactRemovedFromView( MVPbkContactViewBase& aView );
+                  
     public: // From MPbk2PointerEventInspector
         TBool FocusedItemPointed();
         TBool FocusableItemPointed();
--- a/phonebookui/Phonebook2/inc/CPbk2PresentationContactFieldCollection.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/inc/CPbk2PresentationContactFieldCollection.h	Mon Mar 15 12:39:26 2010 +0200
@@ -111,6 +111,14 @@
                 TInt aFieldIndex ) const;
 
         /**
+         * get index if field by store field index
+         * 
+         * @param aStoreFieldIndex, a store field's index
+         * @return the index of the field.
+         */
+        IMPORT_C TInt FieldIndexOfStoreField( TInt aStoreFieldIndex ) const;
+        
+        /**
          * Returns the field properties.
          *
          * @return  Field properties.
--- a/phonebookui/Phonebook2/inc/Pbk2PresentationUtils.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/inc/Pbk2PresentationUtils.h	Mon Mar 15 12:39:26 2010 +0200
@@ -126,13 +126,13 @@
 public:
     enum TCroppingMode
         {
-        /// Landscape image is cropped to square, target size is not used
-        ELandscapeCropping                  = 0x0,
+        /// Image is cropped to square, target size is not used
+        ECropping                  = 0x0,
         /**
-         * Landscape image is cropped to square and optimized to target size.
-         * Cropped bitmap minimum width is aTargetSize width. 
+         * Image is cropped to square and optimized to target size.
+         * Cropped bitmap minimum width/height is aTargetSize width/height. 
          */
-        ELandscapeOptimizedCropping
+        EOptimizedCropping
         };
     
     IMPORT_C static void CropImageL( 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phonebookui/Phonebook2/inc/spbcontactdatamodel.h	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,176 @@
+/*
+* 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:  Contact model class
+*
+*/
+
+#ifndef CSPBCONTACTDATAMODEL_H
+#define CSPBCONTACTDATAMODEL_H
+
+// INCLUDES
+#include <e32base.h>
+#include <bamdesca.h>
+
+// FORWARD DECLARATIONS
+class CPbk2IconArray;
+class CPbk2PresentationContact;
+class CCoeEnv;
+class MVPbkContactLink;
+class MPbk2ClipListBoxText;
+class CSpbContactDataModelPrivate;
+class CVPbkContactManager;
+class RWriteStream;
+class RReadStream;
+
+/**
+ *  Contact data model class
+ *
+ *  @lib pbk2spbcontentprovider.dll
+ *  @since S60 9.2
+ */
+class CSpbContactDataModel : public CBase
+{
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aCntManager Contact manager
+     * @param aCoeEnv UI control environment
+     * @param aFieldTypeSelectorRes field type selector. 
+     *        Used to determine fields that get clipped from the beginning.
+     * @param aClip listbox text clipper
+     * @param aIconArray Listbox's icon array
+     */
+    IMPORT_C static CSpbContactDataModel* NewL(
+        CVPbkContactManager& aCntManager,
+        CCoeEnv& aCoeEnv,
+        TInt aFieldTypeSelectorRes,
+        MPbk2ClipListBoxText* aClip = NULL );
+
+    /**
+     * Destructor.
+     */
+    ~CSpbContactDataModel();
+    
+
+public: // data types
+    
+    /// Text types (16-bit) 
+    enum TTextTypes
+        {
+        /// Contact's first name
+        ETextFirstName,
+        /// Contact's last name
+        ETextLastName,
+        /// Filename of contact's image
+        ETextImageFileName,
+        };
+    
+    /// Data types (8-bit)
+    enum TBinaryTypes
+        {
+        /// Thumbnail data of contact 
+        EDataImageContent
+        };
+    
+public: // New methods
+    
+    /**
+     * Get Presentation Field index for field at aIndex
+     * 
+     * @param aListIndex Listbox row index
+     * @return Presentation field index shown at aListIndex  
+     */
+    IMPORT_C TInt PresentationFieldIndex( TInt aListIndex );
+
+    /**
+     * Externalize model into stream
+     */
+    IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
+    
+    /**
+     * Internalize model from stream. 
+     * Any previous data will be deleted.
+     */
+    IMPORT_C void InternalizeL( RReadStream& aStream );
+    
+    /**
+     * Sets the models content according to given contact. 
+     * Any previous data will be deleted.
+     *  
+     * @param aContact new contact
+     * @param aIconArray icon array that holds the field icons (can be NULL)
+     */
+    IMPORT_C void SetDataL( 
+        const CPbk2PresentationContact& aContact,
+        const CPbk2IconArray* aIconArray );
+    
+    /**
+     * Reset Model's content.
+     */
+    IMPORT_C void Reset();
+    
+    /**
+     * Getter for text elements
+     * 
+     * @param aType text id
+     */
+    IMPORT_C TPtrC Text( TTextTypes aType ) const;
+
+    /**
+     * Getter for data (binary) elements
+     * 
+     * @param aType element id
+     */
+    IMPORT_C TPtrC8 Data( TBinaryTypes aType ) const;
+    
+    /**
+     * Update icon indexes according to aIconArray.
+     * 
+     * @param aIconArray new icon array
+     */
+    IMPORT_C void UpdateIconsL( const CPbk2IconArray& aIconArray );
+
+    /**
+     * Set list box clipper for the model. Used to clip long list text.
+     * 
+     * @param aClip text clipper 
+     */
+    IMPORT_C void SetClipListBoxText( MPbk2ClipListBoxText* aClip );
+    
+    /**
+     * Link of the active contact. Link refers to contact set with SetDataL().
+     */
+    IMPORT_C MVPbkContactLink* ContactLink();
+    
+    /**
+     * Check if model is empty
+     */
+    IMPORT_C TBool IsEmpty();
+
+    /**
+     * Listbox model of the contact's details.
+     */
+    IMPORT_C MDesCArray& ListBoxModel();
+    
+private: // data
+
+    /// Own. Private implementation
+    CSpbContactDataModelPrivate* iImpl;
+};
+
+#endif // CSPBCONTACTDATAMODEL_H
+
+// End of File
--- a/phonebookui/Phonebook2/loc/phonebook2.loc	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/loc/phonebook2.loc	Mon Mar 15 12:39:26 2010 +0200
@@ -415,9 +415,9 @@
 #define qtn_phob_opt_speed_dial_remove          "Remove speed dial"
 
 //d:Options list text for sending business card of a memory entry
-//l:list_single_pane_t1_cp2/opt3
+//l:list_single_pane_t1_cp2
 //
-#define qtn_bcard_opt_send_entry_via            "Send contact"
+#define qtn_bcard_opt_send_entry_via            "Send as business card"
 
 //d:Options list text for displaying information about phonebook memory
 //l:list_single_pane_t1_cp2/opt3
@@ -2283,54 +2283,6 @@
 //
 #define qtn_phob_protected_tone "Protected file. Cannot be selected as ringing tone"
 
-//d:Shown in long tap menu of names list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.0 
-#define qtn_phob_longtap_copy	"Copy"
-
-//d:Shown in long tap menu of names list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.0 
-#define qtn_phob_longtap_send "Send business card" 
-
-//d:Shown in long tap menu of names list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.0 
-#define qtn_phob_longtap_delete "Delete" 
-
-//d:Shown in long tap menu of groups list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.0 
-#define qtn_phob_longtap_message "Create message" 
-
-//d:Shown in long tap menu of groups list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.0 
-#define qtn_phob_longtap_rename "Rename" 
-
-//d:Shown in long tap menu of groups list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.0 
-#define qtn_phob_longtap_tone "Ringing tone" 
-
-//d:Shown in long tap menu of group members list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.0 
-#define qtn_phob_longtap_rem_from_grp "Remove from group" 
-
-//d:Shown in long tap menu of group memebers list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.0 
-#define qtn_phob_longtap_is_in_grp "Belongs to groups" 
-
 //d:Data value "According to profile" shown when no contact specific ringing tone is selected
 //l:list_form_graphic_pane_t1
 //w:
--- a/phonebookui/Phonebook2/loc/phonebook2ece.loc	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/loc/phonebook2ece.loc	Mon Mar 15 12:39:26 2010 +0200
@@ -137,53 +137,22 @@
 #define qtn_xsp_skype "Skype" 
 
 //d:label for "Add Favorities" promotion text in nameslist
-//l: list_single_graphic_pane_t1
+//l:list_single_graphic_pane_t1
 //r:5.01
 #define qtn_phob_add_top_contacts "Add Favorities"
 
-//d:Shown in long tap menu of names list
-//l: list_single_touch_menu_pane_t1
+//d:Shown in options menu of names list and details view
+//l:list_single_pane_t1_cp2
 //w:
 //r:5.2
 #define qtn_phob_opt_call "Call"
 
-//d:Shown in long tap menu of names list
-//l: list_single_touch_menu_pane_t1
+//d:Shown in options menu of names list
+//l:list_single_pane_t1_cp2
 //w:
 //r:5.2
 #define qtn_phob_opt_send_message "Send message"
 
-//d:Shown in long tap menu of names list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.01
-#define qtn_phob_longtap_create "New" 
-
-//d:Shown in long tap menu of names list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.01
-#define qtn_phob_longtap_edit "Edit" 
-
-//d:Shown in long tap menu of names list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.01
-#define qtn_phob_longtap_add_favourites "Assign as favorite"
-
-//d:Shown in long tap menu of names list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.01
-#define qtn_phob_longtap_drop_favourites "Unassign favorite"
-
-//d:Shown in long tap menu of names list 
-//l: list_single_touch_menu_pane_t1 
-//w: 
-//r:5.01
-#define qtn_phob_longtap_move "Rearrange favorites"
-
-
 //d:Label text for unknown memory entry item
 //l:list_single_graphic_pane_t1_cp2
 //w: 
@@ -316,16 +285,17 @@
 //
 #define qtn_cca_multiple_accounts "%N accounts"
 
-
-//----------------------------------------------------------------------------
-// cmscontactor
-//----------------------------------------------------------------------------
+// d:Prompt text for select number/address popup
+// l:heading_pane_t1
+// r:5.0
+//
+#define qtn_cca_popup_call "Call:"
 
 // d:Prompt text for select number/address popup
 // l:heading_pane_t1
 // r:5.0
 //
-#define qtn_cca_popup_call "Call:"
+#define qtn_cca_popup_voice_call "Voice call:"
 
 // d:Prompt text for select number/address popup
 // l:heading_pane_t1
@@ -387,6 +357,7 @@
 // r:5.2
 //
 #define qtn_cca_popup_voip_call_single_service "%U call:"
+
 //----------------------------------------------------------------------------
 // Other
 //----------------------------------------------------------------------------
@@ -916,7 +887,7 @@
 //l:phob2_cc_button_pane
 //r:9.2
 //
-#define qtn_cca_ftu_discover "Discover %U on Ovi"
+#define qtn_cca_ftu_discover "See what %U is up to"
 
 //d:Default string for MyCard status button when the social information text
 //d:cannot be displayed.
--- a/phonebookui/Phonebook2/remotecontactlookup/contactactionservice/sendbusinesscard/data/pbk2rclsendbusinesscardpluginimpl.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/remotecontactlookup/contactactionservice/sendbusinesscard/data/pbk2rclsendbusinesscardpluginimpl.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -41,7 +41,7 @@
 
 RESOURCE TBUF { buf = ""; }
 
-RESOURCE TBUF r_fs_action_send_businsess_card  { buf = qtn_phob_longtap_send; }
+RESOURCE TBUF r_fs_action_send_businsess_card  { buf = qtn_bcard_opt_send_entry_via; }
 
 
 // -----------------------------------------------------------------------------
@@ -52,11 +52,11 @@
 //
 RESOURCE LOCALISABLE_APP_INFO r_fssendbcplugin_localisable_app_info
     {
-    short_caption = qtn_phob_longtap_send;
+    short_caption = qtn_bcard_opt_send_entry_via;
     caption_and_icon = 
     CAPTION_AND_ICON_INFO
         {
-        caption = qtn_phob_longtap_send;
+        caption = qtn_bcard_opt_send_entry_via;
         number_of_icons = 1;
         icon_file = "\\resource\\apps\\pbk2rclsendbusinesscardplugin.mif";
         };
--- a/phonebookui/Phonebook2/remotecontactlookup/engine/data/engine.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/remotecontactlookup/engine/data/engine.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -68,12 +68,6 @@
 
 RESOURCE TBUF r_qtn_rcl_add_recipient_action_menu_text { buf = qtn_fs_action_recipient; }
 
-RESOURCE TBUF r_qtn_phob_set_server_search { buf = qtn_phob_set_server_search; }
-
-RESOURCE TBUF r_qtn_rcl_setting_rcl_server_none { buf = qtn_fs_setting_rcl_server_none; }
-
-RESOURCE TBUF r_qtn_rcl_setting_rcl_not_defined { buf = qtn_fs_setting_rcl_not_defined; }
-
 RESOURCE TBUF r_qtn_rcl_replace_existing_detail_note { buf = qtn_rcl_replace_existing_detail_note; }
 
 RESOURCE TBUF r_qtn_rcl_title_server_contacts { buf = qtn_rcl_title_server_contacts; }
--- a/phonebookui/Phonebook2/remotecontactlookup/engine/src/cpbkxrclsettingitem.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/remotecontactlookup/engine/src/cpbkxrclsettingitem.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -18,6 +18,8 @@
 
 #include "emailtrace.h"
 #include <pbk2rclengine.rsg>
+#include <pbk2rclsettingres.rsg> 
+
 #include <ecom/ecom.h>
 #include "cpbkxremotecontactlookupprotocoladapter.h"
 #include <cpbkxremotecontactlookupprotocolaccount.h>
--- a/phonebookui/Phonebook2/remotecontactlookup/settingplugin/data/pbk2rclsettingres.rss	Fri Mar 12 15:41:25 2010 +0200
+++ b/phonebookui/Phonebook2/remotecontactlookup/settingplugin/data/pbk2rclsettingres.rss	Mon Mar 15 12:39:26 2010 +0200
@@ -22,6 +22,8 @@
 
 #include <Pbk2UIExtension.rh>
 #include <Pbk2ExtensionUID.h>
+#include <phonebook2rcl.loc> 
+#include "../../../inc/Pbk2InternalUID.h"   //KFscRclSettingExtensionImplementationUID from pbk2internaluid.h
 
 // --------------------------------------------------------------------------
 // Resource identifier
@@ -35,7 +37,55 @@
 //
 RESOURCE RSS_SIGNATURE { }
 
-// Additional include files
-#include "fscrclsettinginformation.rss"
+// --------------------------------------------------------------------------
+// r_fsc_rcl_setting_extension_information
+// Extension information
+// --------------------------------------------------------------------------
+//
+RESOURCE PHONEBOOK2_EXTENSION_INFORMATION r_fsc_rcl_setting_extension_information
+    {
+    version = 0;
+    implementationUid = KFscRclSettingExtensionImplementationUID;
+    loadingPolicy = KPbk2LoadOnSettingsExecution;  
+    
+    // NO Commands
+    menuCommandRange = PHONEBOOK2_EXTENSION_RANGE
+        {
+        firstId = 0;
+        lastId  = 0;
+        };   
+    
+    overwrittenCommands = {};
+    
+    extensionMenus = {};
+    }
+    
+// ---------------------------------------------------------
+// The RCL settings list
+// ---------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_ITEM_LIST r_rcl_setting_list
+    {
+    title = "Settings";
+    }
+
+// ---------------------------------------------------------
+// Strings shown by RCL settings plugin in Phonebook2 settings
+// ---------------------------------------------------------
+//
+RESOURCE TBUF r_qtn_phob_set_server_search 
+     {
+     buf = qtn_phob_set_server_search;
+     }
+     
+RESOURCE TBUF r_qtn_rcl_setting_rcl_server_none 
+    {
+    buf = qtn_fs_setting_rcl_server_none;
+    }
+    
+RESOURCE TBUF r_qtn_rcl_setting_rcl_not_defined 
+    {
+    buf = qtn_fs_setting_rcl_not_defined;
+    }
 
 // End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phonebookui/Phonebook2/spbcontentprovider/inc/spbcontactdatamodelprivate.h	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,253 @@
+/*
+* Copyright (c) 2009 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:  Contact model class for MyCard
+*
+*/
+
+#ifndef CSPBCONTACTDATAMODELPRIVATE_H
+#define CSPBCONTACTDATAMODELPRIVATE_H
+
+// INCLUDES
+#include <e32base.h>
+#include <badesca.h>
+#include "spbcontactdatamodel.h"
+
+// FORWARD DECLARATIONS
+class MVPbkContactFieldData;
+class MVPbkBaseContactField;
+class MVPbkFieldType;
+class MVPbkContactLink;
+
+class MPbk2ClipListBoxText;
+class CPbk2PresentationContactField;
+class CPbk2PresentationContactFieldCollection;
+class CPbk2IconArray;
+class CPbk2PresentationContact;
+
+class CSpbContactDataModelRow;
+
+class CEikListBox;
+class CCoeEnv;
+
+/**
+ * Listbox model class for MyCard details list
+ *
+ *
+ *  @lib pbk2spbcontentprovider.dll
+ *  @since S60 9.2
+ */
+NONSHARABLE_CLASS( CSpbContactDataModelPrivate ) : public CBase, public MDesCArray
+{
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * 
+     * @param aCntManager
+     * @param aCoeEnv UI control environment
+     * @param aFieldTypeSelectorRes
+     * @param aClip
+     * @param aIconArray Listbox's icon array
+     */
+    static CSpbContactDataModelPrivate* NewL(
+        CVPbkContactManager& aCntManager,
+        CCoeEnv& aCoeEnv,
+        TInt aFieldTypeSelectorRes,
+        MPbk2ClipListBoxText* aClip = NULL );
+
+    /**
+     * Destructor.
+     */
+    ~CSpbContactDataModelPrivate();
+ 
+public: // "From" CSpbContactDataModel
+    
+    TInt PresentationFieldIndex( TInt aListIndex );
+    void ExternalizeL( RWriteStream& aStream ) const;
+    void InternalizeL( RReadStream& aStream );
+    void SetDataL( 
+        const CPbk2PresentationContact& aContact, 
+        const CPbk2IconArray* aIconArray );
+    void Reset();
+    TPtrC Text( CSpbContactDataModel::TTextTypes aType ) const;
+    TPtrC8 Data( CSpbContactDataModel::TBinaryTypes aType ) const;
+    void UpdateIconsL( const CPbk2IconArray& aIconArray );
+    void SetClipListBoxText( MPbk2ClipListBoxText* aClip );
+    MVPbkContactLink* ContactLink();   
+    TBool IsEmpty();
+
+public: // From MDesCArray
+    
+    TInt MdcaCount() const;
+    TPtrC MdcaPoint(TInt aIndex) const;
+    
+private: // private construction
+
+    /**
+     * Constructor
+     */
+    CSpbContactDataModelPrivate(
+        CVPbkContactManager& aCntManager,
+        CCoeEnv& aCoeEnv,
+        TInt aFieldTypeSelectorRes,
+        MPbk2ClipListBoxText* aClip );
+
+    /**
+     * 2nd constructor
+     */
+    void ConstructL();
+
+
+private: // new implementation
+
+    /**
+     * Get label for contact field
+     */
+    HBufC* GetLabelLC(const CPbk2PresentationContactField& aField);
+
+    /**
+     * Should field aFieldType be hidden
+     */
+    TBool IsHiddenField(const MVPbkFieldType* aFieldType);
+
+    /**
+     * Field type tester
+     */
+    TBool IsFieldTypeL( const MVPbkFieldType& aFieldType, TInt aSelectorResId);
+
+    /**
+     * Format generic text -type field
+     */
+    void HandleTextTypeFieldL(
+        const MVPbkFieldType& aFieldType,
+        const MVPbkContactFieldData& aFieldData,
+        CSpbContactDataModelRow* aRow );
+
+    /**
+     * Format Date -type field
+     */
+    void HandleDateTimeTypeFieldL(
+        const MVPbkContactFieldData& aFieldData,
+        CSpbContactDataModelRow* aRow);
+
+    /**
+     * Format URI -type field
+     */
+    void HandleUriTypeFieldL(
+        const MVPbkFieldType& aFieldType,
+        const MVPbkContactFieldData& aFieldData,
+        CSpbContactDataModelRow* aRow);
+
+    /**
+     * Expand column and line buffers to be sufficient for aRow
+     */
+    void ExpandBuffersL(CSpbContactDataModelRow* aRow);
+
+    /**
+     * Expand column buffer to aRequiredLength
+     * 
+     * @return new column buffer
+     */
+    TPtr ExpandColumnBufferL(TInt aRequiredLength);
+
+    /**
+     * 
+     */
+    void ExternalizeDataL( RWriteStream& aStream, const TDesC16& aData ) const;
+    void ExternalizeDataL( RWriteStream& aStream, const TDesC8& aData ) const;
+    
+    /**
+     * 
+     */
+    void InternalizeDataL( RReadStream& aStream, HBufC16*& aData );
+    void InternalizeDataL( RReadStream& aStream, HBufC8*& aData );
+    
+private: // data
+
+    /**
+     * Reference to control environment.
+     * Not own.
+     */
+    CCoeEnv& iCoeEnv;
+    
+    /**
+     * 
+     * Not own.
+     */
+    CVPbkContactManager& iCntManager;
+    
+    /**
+     * Reference to listbox clipper.
+     * Not own.
+     */
+    MPbk2ClipListBoxText* iClip;
+
+    /**
+     * Text row array.
+     * Own.
+     */
+    CArrayPtrFlat<CSpbContactDataModelRow> iRows;
+
+    /**
+     * Buffer for storing one formatted listbox row.
+     * Own.
+     */
+    HBufC* iLineBuf;
+
+    /**
+     * Buffer for storing one formatted listbox column.
+     * Own.
+     */
+    HBufC* iColumnBuf;
+    
+    /**
+     * Own: Map current index to Presentation Contact index
+     */
+    RArray<TInt> iListIndxToPresentationIndx;
+
+    /**
+     * Field type selector resource
+     */
+    TInt iFieldTypeRes;
+
+    /**
+     * Own. Image data buffer
+     */
+    HBufC8* iImageBuffer;
+    
+    /**
+     * Own. Contact's image filename
+     */
+    HBufC* iImageFileName;
+    
+    /**
+     * Own. Contact's last name
+     */
+    HBufC* iLastName;
+    
+    /**
+     * Own. Contact's first name
+     */
+    HBufC* iFirstName;
+    
+    /**
+     * Own. Current contact of model
+     */
+    MVPbkContactLink* iContactLink;
+};
+
+#endif // CSPBCONTACTDATAMODELPRIVATE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phonebookui/Phonebook2/spbcontentprovider/inc/spbcontactdatamodelrow.h	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2009 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:  Listbox model row contact model
+*
+*/
+
+#ifndef CSPBCONTACTDATAMODELROW_H
+#define CSPBCONTACTDATAMODELROW_H
+
+#include <e32base.h>
+#include <TPbk2IconId.h>
+
+class RWriteStream;
+class RReadStream;
+
+
+/**
+ * MyCard view list box model row.
+ *
+ */
+NONSHARABLE_CLASS( CSpbContactDataModelRow ) : public CBase
+{
+public: // Constructors and destructor
+
+    /**
+     * Creates a new instance of this class.
+     *
+     * @return  A new instance of this class.
+     */
+    static CSpbContactDataModelRow* NewL();
+
+    /**
+     * Destructor.
+     */
+    ~CSpbContactDataModelRow();
+
+public: // Interface
+
+    /**
+     * Returns the number of columns in this row.
+     *
+     * @return  Number of columns in this row.
+     */
+    TInt ColumnCount() const;
+
+    /**
+     * Returns the descriptor at the given position.
+     *
+     * @param aColumnIndex  Column index.
+     * @return  The descriptor at the given index.
+     */
+    TPtrC At(TInt aColumnIndex) const;
+
+    /**
+     * Appends a given column to the row.
+     *
+     * @param aColumnText   Column to append.
+     */
+    void AppendColumnL(const TDesC& aColumnText);
+
+    /**
+     * replace column's text with a new one.
+     *
+     * @param aIndex        Column index
+     * @param aColumnText   new text
+     */
+    void ReplaceColumnL( TInt aIndex, const TDesC& aColumnText );
+    
+    /**
+     * Is clip required.
+     */
+    TBool IsClipRequired() const;
+
+    /**
+     * Clip text from beginning if field is numeric field or e-mail field.
+     */
+    void SetClipRequired(TBool aFlag);
+
+    /**
+     * Returns the total descriptor length of all the columns.
+     *
+     * @return  Total row length.
+     */
+    TInt TotalLength() const;
+
+    /**
+     * Returns the maximum column length of this row.
+     *
+     * @return  Maximum column length.
+     */
+    TInt MaxColumnLength() const;
+
+    /**
+     * Externalize row into stream
+     */
+    void ExternalizeL( RWriteStream& aStream ) const;
+    
+    /**
+     * Internalize row from stream
+     */
+    void InternalizeL( RReadStream& aStream );
+    
+    /**
+     * 
+     */
+    const TPbk2IconId& Icon();
+    
+    /**
+     * 
+     */
+    void SetIcon( const TPbk2IconId& aIcon );
+    
+private: // Implementation
+
+    CSpbContactDataModelRow();
+
+private: // Data
+
+    /// Own: Column array
+    RPointerArray<HBufC> iColumns;
+
+    /// Is clip required.
+    TBool iClipBeginning;
+    
+    /// Icon ID
+    TPbk2IconId iIcon;
+};
+
+#endif //CSPBCONTACTDATAMODELROW_H
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phonebookui/Phonebook2/spbcontentprovider/src/spbcontactdatamodel.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2009 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:  Contact model class for MyCard
+ *
+ */
+
+#include "spbcontactdatamodel.h"
+#include "spbcontactdatamodelprivate.h"
+
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModel::NewL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CSpbContactDataModel* CSpbContactDataModel::NewL( 
+    CVPbkContactManager& aCntManager,
+    CCoeEnv& aCoeEnv,
+    TInt aFieldTypeSelectorRes,
+    MPbk2ClipListBoxText* aClip )
+    {
+    CSpbContactDataModel* self = new (ELeave) CSpbContactDataModel;
+    CleanupStack::PushL(self);
+    self->iImpl = CSpbContactDataModelPrivate::NewL( 
+        aCntManager, aCoeEnv, aFieldTypeSelectorRes, aClip );
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModel::~CSpbContactDataModel
+// ---------------------------------------------------------------------------
+//
+CSpbContactDataModel::~CSpbContactDataModel()
+    {
+    delete iImpl;
+    }
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModel::PresentationFieldIndex
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CSpbContactDataModel::PresentationFieldIndex( TInt aListIndex )
+    {
+    return iImpl->PresentationFieldIndex( aListIndex );
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModel::ExternalizeL
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CSpbContactDataModel::ExternalizeL( RWriteStream& aStream ) const
+    {
+    iImpl->ExternalizeL( aStream );
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModel::InternalizeL
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CSpbContactDataModel::InternalizeL( RReadStream& aStream )
+    {
+    iImpl->InternalizeL( aStream );
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModel::SetDataL
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CSpbContactDataModel::SetDataL( 
+    const CPbk2PresentationContact& aContact,
+    const CPbk2IconArray* aIconArray )
+    {
+    iImpl->SetDataL( aContact, aIconArray );
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModel::ContactLink
+// --------------------------------------------------------------------------
+//
+EXPORT_C MVPbkContactLink* CSpbContactDataModel::ContactLink()
+    {
+    return iImpl->ContactLink();
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModel::IsEmpty
+// --------------------------------------------------------------------------
+//
+EXPORT_C TBool CSpbContactDataModel::IsEmpty()
+    {
+    return iImpl->IsEmpty();
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModel::Reset
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CSpbContactDataModel::Reset()
+    {
+    iImpl->Reset();
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModel::Text
+// --------------------------------------------------------------------------
+//
+EXPORT_C TPtrC CSpbContactDataModel::Text( TTextTypes aType ) const
+    {
+    return iImpl->Text( aType );
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModel::Data
+// --------------------------------------------------------------------------
+//
+EXPORT_C TPtrC8 CSpbContactDataModel::Data( TBinaryTypes aType ) const
+    {
+    return iImpl->Data( aType );
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModel::SetIconArrayL
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CSpbContactDataModel::UpdateIconsL( const CPbk2IconArray& aIconArray )
+    {
+    iImpl->UpdateIconsL( aIconArray );
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModel::SetClipListBoxText
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CSpbContactDataModel::SetClipListBoxText( MPbk2ClipListBoxText* aClip )
+    {
+    iImpl->SetClipListBoxText( aClip );
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModel::ListBoxModel
+// --------------------------------------------------------------------------
+//
+EXPORT_C MDesCArray& CSpbContactDataModel::ListBoxModel()
+    {
+    return *iImpl;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phonebookui/Phonebook2/spbcontentprovider/src/spbcontactdatamodelprivate.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,735 @@
+/*
+ * Copyright (c) 2009 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:  Contact model class for MyCard
+ *
+ */
+
+#include <TPbk2StoreContactAnalyzer.h>
+#include <Pbk2UIControls.rsg>
+#include <Pbk2PresentationUtils.h>
+#include <CPbk2PresentationContact.h>
+#include <CPbk2PresentationContactField.h>
+#include <CPbk2PresentationContactFieldCollection.h>
+#include <CPbk2IconArray.h>
+#include <MPbk2FieldProperty.h>
+#include <MPbk2ClipListBoxText.h>
+
+#include <CVPbkContactManager.h>
+#include <MVPbkContactLink.h>
+#include <MVPbkFieldType.h>
+#include <MVPbkContactFieldTextData.h>
+#include <MVPbkContactFieldUriData.h>
+#include <MVPbkContactFieldDateTimeData.h>
+#include <MVPbkContactFieldBinaryData.h>
+#include <MVPbkContactFieldData.h>
+#include <VPbkUtils.h>
+#include <VPbkEng.rsg>
+
+#include <aknlists.h>
+#include <avkon.rsg>
+
+#include "spbcontactdatamodelprivate.h"
+#include "spbcontactdatamodelrow.h"
+
+/// CONSTANTS
+namespace {
+
+/// Granularity of the row array
+const TInt KRowArrayGranularity = 4;
+
+/// Initial buffer size for temporary text buffers
+const TInt KBufferSize = 256;
+
+/// Disallowed characters in column text
+_LIT( KCharsToReplace, "\t" );
+
+/// Replacement character for invalid or graphical column characters
+_LIT( KReplacementChars, " " );
+const TText KReplacedChars = ' ';
+
+/// Content colum index
+const TInt KContentColumnIndex = 2;
+
+/// Column  separator
+const TText KColumnSeparator = '\t';
+
+};
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::NewL
+// ---------------------------------------------------------------------------
+//
+CSpbContactDataModelPrivate* CSpbContactDataModelPrivate::NewL( 
+    CVPbkContactManager& aCntManager,
+    CCoeEnv& aCoeEnv,
+    TInt aFieldTypeSelectorRes,
+    MPbk2ClipListBoxText* aClip )
+    {
+    CSpbContactDataModelPrivate* self = new (ELeave) CSpbContactDataModelPrivate(
+        aCntManager, aCoeEnv, aFieldTypeSelectorRes, aClip );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::~CSpbContactDataModelPrivate
+// ---------------------------------------------------------------------------
+//
+CSpbContactDataModelPrivate::~CSpbContactDataModelPrivate()
+    {
+    iRows.ResetAndDestroy();
+    delete iLineBuf;
+    delete iColumnBuf;
+    iListIndxToPresentationIndx.Reset();
+    delete iImageBuffer;
+    delete iImageFileName;
+    delete iLastName;
+    delete iFirstName;
+    delete iContactLink;
+    }
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::CSpbContactDataModelPrivate
+// ---------------------------------------------------------------------------
+//
+CSpbContactDataModelPrivate::CSpbContactDataModelPrivate(
+    CVPbkContactManager& aCntManager,
+    CCoeEnv& aCoeEnv,
+    TInt aFieldTypeSelectorRes,
+    MPbk2ClipListBoxText* aClip ) :        
+        iCoeEnv(aCoeEnv),
+        iCntManager(aCntManager),
+        iClip(aClip),
+        iRows(KRowArrayGranularity),
+        iFieldTypeRes(aFieldTypeSelectorRes)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::ConstructL()
+    {
+    iLineBuf = HBufC::NewL(KBufferSize);
+    iColumnBuf = HBufC::NewL(KBufferSize);
+    }
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::MdcaCount
+// ---------------------------------------------------------------------------
+//
+TInt CSpbContactDataModelPrivate::MdcaCount() const
+    {
+    return iRows.Count();
+    }
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::MdcaPoint
+// ---------------------------------------------------------------------------
+//
+TPtrC CSpbContactDataModelPrivate::MdcaPoint(TInt aIndex) const
+    {
+    TPtr rowText( iLineBuf->Des() );
+    rowText.Zero();
+
+    const CSpbContactDataModelRow& row = *iRows[aIndex];
+    const TInt columnCount = row.ColumnCount();
+
+    for( TInt index = 0; index < columnCount; ++index )
+        {
+        TPtr columnText( iColumnBuf->Des() );
+        columnText.Copy( row.At(index) );
+
+        // Clip the column if required
+        if( index == KContentColumnIndex && 
+            row.IsClipRequired() &&
+            iClip )
+            {
+            iClip->ClipFromBeginning( columnText, aIndex, index );
+            }
+ 
+        // Append the column and separator to the formatted row
+        rowText.Append( columnText );
+        rowText.Append( KColumnSeparator );
+        }
+
+    return rowText;
+    }
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::PresentationFieldIndex
+// ---------------------------------------------------------------------------
+//
+TInt CSpbContactDataModelPrivate::PresentationFieldIndex( TInt aListIndex )
+    {
+    return iListIndxToPresentationIndx[ aListIndex ];
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::ExternalizeL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::ExternalizeL( RWriteStream& aStream ) const
+    {
+    // write rows
+    const TInt rowCount = iRows.Count();
+    aStream.WriteInt32L( rowCount );
+    for( TInt i = 0; i < rowCount; ++i )
+        {
+        iRows[i]->ExternalizeL( aStream );
+        }
+    
+    // write field indexes
+    const TInt indxCount = iListIndxToPresentationIndx.Count();
+    aStream.WriteInt32L( indxCount );
+    for( TInt i = 0; i < indxCount; ++i )
+        {
+        aStream.WriteInt32L( iListIndxToPresentationIndx[i] );
+        }
+    
+    // write other data
+    ExternalizeDataL( aStream, Text( CSpbContactDataModel::ETextFirstName ) );
+    ExternalizeDataL( aStream, Text( CSpbContactDataModel::ETextLastName ) );
+    ExternalizeDataL( aStream, Text( CSpbContactDataModel::ETextImageFileName ) );
+    ExternalizeDataL( aStream, Data( CSpbContactDataModel::EDataImageContent ) );
+    
+    if( iContactLink )
+        {
+        aStream.WriteInt8L( ETrue );
+        HBufC8* link = iContactLink->PackLC();
+        aStream.WriteL( *link );
+        CleanupStack::PopAndDestroy( link );
+        }
+    else
+        {
+        aStream.WriteInt8L( EFalse );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::InternalizeL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::InternalizeL( RReadStream& aStream )
+    {
+    Reset();
+    
+    // read rows
+    const TInt count = aStream.ReadInt32L();
+    for( TInt i = 0; i < count; ++i )
+        {
+        CSpbContactDataModelRow* row = CSpbContactDataModelRow::NewL();
+        CleanupStack::PushL( row );
+        row->InternalizeL( aStream );
+        iRows.AppendL( row );
+        CleanupStack::Pop( row );
+        ExpandBuffersL( row );
+        }    
+
+    // read field indexes
+    const TInt indxCount = aStream.ReadInt32L();
+    for( TInt i = 0; i < indxCount; ++i )
+        {
+        iListIndxToPresentationIndx.AppendL( aStream.ReadInt32L() );
+        }
+
+    // read other data
+    InternalizeDataL( aStream, iFirstName );
+    InternalizeDataL( aStream, iLastName );
+    InternalizeDataL( aStream, iImageFileName );
+    InternalizeDataL( aStream, iImageBuffer );
+
+    // read contact link if provided
+    if( aStream.ReadInt8L() )
+        {
+        CVPbkContactLinkArray* links = 
+            CVPbkContactLinkArray::NewLC( aStream, iCntManager.ContactStoresL() );
+        if( links->Count() )
+            {
+            // only first link used
+            delete iContactLink;
+            iContactLink = NULL;
+            iContactLink = links->At( 0 ).CloneLC();
+            CleanupStack::Pop(); // link
+            }
+        CleanupStack::PopAndDestroy( links );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::SetDataL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::SetDataL( 
+    const CPbk2PresentationContact& aContact,
+    const CPbk2IconArray* aIconArray )
+    {
+    Reset();
+
+    // save link
+    MVPbkContactLink* link = aContact.CreateLinkLC();
+    delete iContactLink;
+    iContactLink = link;
+    CleanupStack::Pop(); // link
+    
+    const CPbk2PresentationContactFieldCollection& fields = 
+        aContact.PresentationFields();
+    const TInt fieldCount = fields.FieldCount();
+    const TInt count1 = fields.ParentStoreContact().Fields().FieldCount();
+    for (TInt index = 0; index < fieldCount; index++)
+        {
+        CPbk2PresentationContactField& field = fields.At(index);
+        const MVPbkContactFieldData& fieldData = field.FieldData();
+
+        // Get master field type list and match field's type against it
+        const MVPbkFieldType* fieldType = VPbkUtils::MatchFieldType(
+                iCntManager.FieldTypes(), field );
+        TInt typeRes = fieldType->FieldTypeResId();
+        
+        // Handle special field types
+        switch( typeRes )
+            {
+            case R_VPBK_FIELD_TYPE_THUMBNAILPIC:
+                {
+                delete iImageBuffer;
+                iImageBuffer = NULL;
+                iImageBuffer = MVPbkContactFieldBinaryData::Cast(fieldData).BinaryData().AllocL();
+                break;
+                }
+            case R_VPBK_FIELD_TYPE_CALLEROBJIMG:
+                {
+                delete iImageFileName;
+                iImageFileName = NULL;
+                iImageFileName = MVPbkContactFieldTextData::Cast(fieldData).Text().AllocL();
+                break;
+                }
+            case R_VPBK_FIELD_TYPE_FIRSTNAME:
+                {        
+                delete iFirstName;
+                iFirstName = NULL;
+                iFirstName = MVPbkContactFieldTextData::Cast(fieldData).Text().AllocL();
+                break;
+                }
+            case R_VPBK_FIELD_TYPE_LASTNAME:
+                { 
+                delete iLastName;
+                iLastName = NULL;
+                iLastName = MVPbkContactFieldTextData::Cast(fieldData).Text().AllocL();
+                break;
+                }       
+            }
+
+        // Handle details list fields
+        if( field.IsEditable() && fieldType && !IsHiddenField(fieldType) )
+            {
+            HBufC* label = GetLabelLC( field );
+
+            if( label->Length() )
+                {
+                CSpbContactDataModelRow* row =
+                        CSpbContactDataModelRow::NewL();
+                CleanupStack::PushL(row);
+
+                // Add icon
+                TBuf<20> buffer; // 20 should be enough for icon index
+                const TPbk2IconId& icon = field.FieldProperty().IconId();
+                if( aIconArray )
+                    {
+                    TInt iconIndex = aIconArray->FindIcon( icon );
+                    if( iconIndex != KErrNotFound)
+                        {
+                        buffer.AppendNum(iconIndex);
+                        }
+                    }
+                row->SetIcon( icon );
+                row->AppendColumnL(buffer);
+
+                // add label.
+                row->AppendColumnL(*label);
+
+                // Add current index to Presentation Contact index array 
+                iListIndxToPresentationIndx.AppendL( index );
+
+                // add field content.
+                switch (fieldData.DataType() )
+                    {
+                    case EVPbkFieldStorageTypeText:
+                        {
+                        HandleTextTypeFieldL( *fieldType, fieldData, row);
+                        break;
+                        }
+                    case EVPbkFieldStorageTypeDateTime:
+                        {
+                        HandleDateTimeTypeFieldL(fieldData, row);
+                        break;
+                        }
+                    case EVPbkFieldStorageTypeUri:
+                        {
+                        HandleUriTypeFieldL( *fieldType, fieldData, row);
+                        break;
+                        }
+                    }
+
+                // Expand row formatting buffer if required
+                ExpandBuffersL(row);
+
+                // Add the row if data ok to show to user.
+                iRows.AppendL(row);
+                CleanupStack::Pop(row);
+                }
+
+            CleanupStack::PopAndDestroy(label);
+            }
+        } // for
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::ContactLink
+// --------------------------------------------------------------------------
+//
+MVPbkContactLink* CSpbContactDataModelPrivate::ContactLink()
+    {
+    return iContactLink;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::IsEmpty
+// --------------------------------------------------------------------------
+//
+TBool CSpbContactDataModelPrivate::IsEmpty()
+    {
+    return !iImageBuffer && !iImageFileName && 
+        !iFirstName && !iLastName && iRows.Count() == 0; 
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::IsHiddenField
+// --------------------------------------------------------------------------
+//
+TBool CSpbContactDataModelPrivate::IsHiddenField(const MVPbkFieldType* aFieldType)
+    {
+    TInt resId = aFieldType->FieldTypeResId();
+    return ( resId == R_VPBK_FIELD_TYPE_SYNCCLASS ||
+             resId == R_VPBK_FIELD_TYPE_CALLEROBJIMG );
+    }
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::IsFieldTypeL
+// ---------------------------------------------------------------------------
+//
+TBool CSpbContactDataModelPrivate::IsFieldTypeL(
+    const MVPbkFieldType& aFieldType, TInt aSelectorResId )
+    {
+    TPbk2StoreContactAnalyzer analyzer( iCntManager, NULL );
+    return analyzer.IsFieldTypeIncludedL( aFieldType, aSelectorResId );
+    }
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::HandleTextTypeFieldL
+// ---------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::HandleTextTypeFieldL( 
+    const MVPbkFieldType& aFieldType,
+    const MVPbkContactFieldData& aFieldData, 
+    CSpbContactDataModelRow* aRow )
+    {
+    // Check if clipping is required
+    if( IsFieldTypeL( aFieldType, iFieldTypeRes ) )
+        {
+        aRow->SetClipRequired( ETrue );
+        }
+    
+    TPtrC fieldText = MVPbkContactFieldTextData::Cast(aFieldData).Text();
+    TPtr columnBuf( ExpandColumnBufferL( fieldText.Length() ) );
+    columnBuf.Zero();
+
+    // replace listbox separator characters.
+    Pbk2PresentationUtils::AppendAndReplaceChars( columnBuf, fieldText,
+            KCharsToReplace, KReplacementChars );
+
+    // Replace characters that can not be displayed correctly.
+    Pbk2PresentationUtils::ReplaceNonGraphicCharacters( columnBuf, KReplacedChars );
+
+    aRow->AppendColumnL( columnBuf );
+    }
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::HandleDateTimeTypeFieldL
+// ---------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::HandleDateTimeTypeFieldL(
+    const MVPbkContactFieldData& aFieldData, CSpbContactDataModelRow* aRow)
+    {
+    const MVPbkContactFieldDateTimeData& date =
+            MVPbkContactFieldDateTimeData::Cast(aFieldData);
+
+    HBufC* dateFormat = 
+        iCoeEnv.AllocReadResourceLC( R_QTN_DATE_USUAL_WITH_ZERO );
+
+    TLocale locale;
+    TBuf<64> dateBuffer;
+    TTime time( date.DateTime() );
+    time.FormatL( dateBuffer, *dateFormat, locale );
+    CleanupStack::PopAndDestroy( dateFormat );
+
+    aRow->AppendColumnL( dateBuffer );
+    }
+
+// ---------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::HandleUriTypeFieldL
+// ---------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::HandleUriTypeFieldL(
+    const MVPbkFieldType& aFieldType,
+    const MVPbkContactFieldData& aFieldData, CSpbContactDataModelRow* aRow)
+    {
+    if ( IsFieldTypeL( aFieldType, iFieldTypeRes ) )
+        {
+        aRow->SetClipRequired( ETrue );
+        }
+    
+    TPtrC uri = MVPbkContactFieldUriData::Cast( aFieldData ).Text();
+    TPtr columnBuf( ExpandColumnBufferL( uri.Length() ) );
+    columnBuf.Copy( uri );
+    
+    // Replace characters that can not be displayed correctly.
+    Pbk2PresentationUtils::ReplaceNonGraphicCharacters( columnBuf, KReplacedChars );
+    
+    aRow->AppendColumnL( columnBuf );
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::ExpandBuffersL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::ExpandBuffersL(CSpbContactDataModelRow* aRow)
+    {
+    // Row formatting buffer
+    const TInt rowLength = aRow->TotalLength() + aRow->ColumnCount(); // for separator characters
+
+    if( rowLength > iLineBuf->Des().MaxLength() )
+        {
+        iLineBuf = iLineBuf->ReAllocL(rowLength);
+        }
+
+    ExpandColumnBufferL( aRow->MaxColumnLength() );
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::ExpandColumnBufferL
+// --------------------------------------------------------------------------
+//
+TPtr CSpbContactDataModelPrivate::ExpandColumnBufferL(TInt aRequiredLength)
+    {
+    if( aRequiredLength > iColumnBuf->Des().MaxLength() )
+        {
+        iColumnBuf = iColumnBuf->ReAllocL(aRequiredLength);
+        }
+
+    return iColumnBuf->Des();
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::Reset
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::Reset()
+    {
+    iRows.ResetAndDestroy();
+    iListIndxToPresentationIndx.Reset();
+    
+    delete iImageBuffer;
+    iImageBuffer = NULL;
+    delete iImageFileName;
+    iImageFileName = NULL;
+    delete iLastName;
+    iLastName = NULL;
+    delete iFirstName;
+    iFirstName = NULL;
+    delete iContactLink;
+    iContactLink = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::Text
+// --------------------------------------------------------------------------
+//
+TPtrC CSpbContactDataModelPrivate::Text( 
+    CSpbContactDataModel::TTextTypes aType ) const
+    {
+    switch( aType )
+        {
+        case CSpbContactDataModel::ETextImageFileName:
+            {
+            return iImageFileName ? *iImageFileName : KNullDesC();
+            }
+        case CSpbContactDataModel::ETextFirstName:
+            {
+            return iFirstName ? *iFirstName : KNullDesC();
+            }
+        case CSpbContactDataModel::ETextLastName:
+            {
+            return iLastName ? *iLastName : KNullDesC();
+            }
+        }
+    return KNullDesC();    
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::Data
+// --------------------------------------------------------------------------
+//
+TPtrC8 CSpbContactDataModelPrivate::Data( 
+    CSpbContactDataModel::TBinaryTypes aType ) const
+    {
+    switch( aType )
+        {
+        case CSpbContactDataModel::EDataImageContent:
+            {
+            return iImageBuffer ? *iImageBuffer : KNullDesC8();
+            }
+        }
+    return KNullDesC8();
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::UpdateIconsL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::UpdateIconsL( const CPbk2IconArray& aIconArray )
+    {
+    // locate and set icon indexes for new icon array 
+    const TInt count = iRows.Count();
+    for( TInt i = 0; i < count; ++i )
+        {
+        // find and set icon indexes according to current icon array
+        CSpbContactDataModelRow* row = iRows[i];
+        if( row->ColumnCount() )
+            {
+            TInt index = aIconArray.FindIcon( row->Icon() );
+            if( index != KErrNotFound )
+                {
+                TBuf<20> buf;
+                buf.Num( index );
+                row->ReplaceColumnL( 0, buf );
+                }
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::SetClipListBoxText
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::SetClipListBoxText( MPbk2ClipListBoxText* aClip )
+    {
+    iClip = aClip;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::GetLabelLC
+// --------------------------------------------------------------------------
+//
+HBufC* CSpbContactDataModelPrivate::GetLabelLC(
+        const CPbk2PresentationContactField& aField)
+    {
+    TPtr columnBuf( ExpandColumnBufferL( aField.FieldLabel().Length() ) );
+    columnBuf.Zero();
+
+    // replace listbox separator characters.
+    Pbk2PresentationUtils::AppendAndReplaceChars( columnBuf,
+        aField.FieldLabel(), KCharsToReplace, KReplacementChars );
+
+    // Replace characters that can not be displayed correctly
+    Pbk2PresentationUtils::ReplaceNonGraphicCharacters( 
+        columnBuf, KReplacedChars );
+
+    HBufC* data = HBufC::NewLC( columnBuf.Length() );
+    data->Des().Append( columnBuf );
+
+    return data;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::ExternalizeDataL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::ExternalizeDataL( 
+    RWriteStream& aStream, const TDesC8& aData ) const
+    {
+    const TInt length = aData.Length();
+    aStream.WriteInt32L( length );
+    if( length )
+        {
+        aStream.WriteL( aData, length );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::ExternalizeDataL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::ExternalizeDataL( 
+    RWriteStream& aStream, const TDesC16& aData ) const
+    {
+    const TInt length = aData.Length();
+    aStream.WriteInt32L( length );
+    if( length )
+        {
+        aStream.WriteL( aData, length );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::InternalizeDataL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::InternalizeDataL( RReadStream& aStream, HBufC8*& aData )
+    {
+    const TInt length = aStream.ReadInt32L();
+    HBufC8* buf = NULL;
+    if( length )
+        {
+        buf = HBufC8::NewLC( length );
+        TPtr8 ptr( buf->Des() );
+        aStream.ReadL( ptr, length );
+        CleanupStack::Pop( buf );
+        }
+    delete aData;
+    aData = buf;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelPrivate::InternalizeDataL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelPrivate::InternalizeDataL( RReadStream& aStream, HBufC16*& aData )
+    {
+    const TInt length = aStream.ReadInt32L();
+    HBufC16* buf = NULL;
+    if( length )
+        {
+        buf = HBufC16::NewLC( length );
+        TPtr16 ptr( buf->Des() );
+        aStream.ReadL( ptr, length );
+        CleanupStack::Pop( buf );
+        }
+    delete aData;
+    aData = buf;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/phonebookui/Phonebook2/spbcontentprovider/src/spbcontactdatamodelrow.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2009 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:  Listbox model row contact model
+ *
+ */
+
+#include "spbcontactdatamodelrow.h"
+#include <s32strm.h>
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::CSpbContactDataModelRow
+// --------------------------------------------------------------------------
+//
+inline CSpbContactDataModelRow::CSpbContactDataModelRow()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::~CSpbContactDataModelRow
+// --------------------------------------------------------------------------
+//
+CSpbContactDataModelRow::~CSpbContactDataModelRow()
+    {
+    iColumns.ResetAndDestroy();
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::NewL
+// --------------------------------------------------------------------------
+//
+CSpbContactDataModelRow* CSpbContactDataModelRow::NewL()
+    {
+    return new (ELeave) CSpbContactDataModelRow;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::ColumnCount
+// --------------------------------------------------------------------------
+//
+TInt CSpbContactDataModelRow::ColumnCount() const
+    {
+    return iColumns.Count();
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::At
+// --------------------------------------------------------------------------
+//
+TPtrC CSpbContactDataModelRow::At(TInt aColumnIndex) const
+    {
+    return *iColumns[aColumnIndex];
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::AppendColumnL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelRow::AppendColumnL(const TDesC& aColumnText)
+    {
+    HBufC* buf = aColumnText.AllocLC();
+    iColumns.AppendL( buf );
+    CleanupStack::Pop( buf );
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::ReplaceColumnL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelRow::ReplaceColumnL( 
+    TInt aIndex, const TDesC& aColumnText )
+    {
+    HBufC* buf = aColumnText.AllocL();
+    HBufC*& old = iColumns[aIndex];
+    delete old;
+    old = buf;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::IsClipRequired
+// --------------------------------------------------------------------------
+//
+TBool CSpbContactDataModelRow::IsClipRequired() const
+    {
+    return iClipBeginning;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::SetClipRequired
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelRow::SetClipRequired(TBool aFlag)
+    {
+    iClipBeginning = aFlag;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::Icon
+// --------------------------------------------------------------------------
+//
+const TPbk2IconId& CSpbContactDataModelRow::Icon()
+    {
+    return iIcon;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::SetIcon
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelRow::SetIcon( const TPbk2IconId& aIcon )
+    {
+    iIcon = aIcon;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::TotalLength
+// --------------------------------------------------------------------------
+//
+TInt CSpbContactDataModelRow::TotalLength() const
+    {
+    TInt result = 0;
+    const TInt count = iColumns.Count();
+    for (TInt i = 0; i < count; ++i)
+        {
+        result += At(i).Length();
+        }
+    return result;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::MaxColumnLength
+// --------------------------------------------------------------------------
+//
+TInt CSpbContactDataModelRow::MaxColumnLength() const
+    {
+    TInt result = 0;
+    const TInt count = iColumns.Count();
+    for (TInt i = 0; i < count; ++i)
+        {
+        result = Max(result, At(i).Length());
+        }
+    return result;
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::ExternalizeL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelRow::ExternalizeL( RWriteStream& aStream ) const
+    {
+    const TInt count = iColumns.Count();
+    aStream.WriteInt8L( iClipBeginning );
+    aStream.WriteL( (TUint8*)(&iIcon), sizeof( TPbk2IconId ) );
+
+    aStream.WriteInt32L( count );
+    for (TInt i = 0; i < count; ++i)
+        {
+        HBufC* text = iColumns[i]; 
+        aStream.WriteInt32L( text->Length() );
+        aStream.WriteL( *text );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CSpbContactDataModelRow::InternalizeL
+// --------------------------------------------------------------------------
+//
+void CSpbContactDataModelRow::InternalizeL( RReadStream& aStream )
+    {
+    iColumns.ResetAndDestroy();
+
+    iClipBeginning = aStream.ReadInt8L();
+    aStream.ReadL( (TUint8*)(&iIcon), sizeof( TPbk2IconId ) );
+    
+    const TInt count = aStream.ReadInt32L();
+    for (TInt i = 0; i < count; ++i)
+        {
+        const TInt length = aStream.ReadInt32L();
+        HBufC* buffer = HBufC::NewLC( length );
+        TPtr column( buffer->Des() );
+        aStream.ReadL( column, length );
+        iColumns.AppendL( buffer );
+        CleanupStack::Pop( buffer );
+        }
+    }
+
+// End of File
--- a/pimprotocols/pbap/inc/pbapfolderclient.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/pimprotocols/pbap/inc/pbapfolderclient.h	Mon Mar 15 12:39:26 2010 +0200
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-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"
@@ -23,6 +23,7 @@
 class MPbapErrorReporter;
 class CPbapContactDbViews;
 class CPbapLogWrapper;
+class CPbapVCardExporterUtil;
 
 class MVirtualFolderClient
 	{
@@ -32,6 +33,7 @@
 	virtual MPbapErrorReporter& ErrorReporter() =0;
 	virtual CPbapContactDbViews& ContactDbViews() =0;
 	virtual CPbapLogWrapper& LogClient() const =0;
+	virtual CPbapVCardExporterUtil& ExporterUtil() = 0;
 	};
 
 #endif //PBAPFOLDERCLIENT_H
--- a/pimprotocols/pbap/inc/pbapserver.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/pimprotocols/pbap/inc/pbapserver.h	Mon Mar 15 12:39:26 2010 +0200
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-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"
@@ -36,6 +36,7 @@
 class RFs;
 class CPbapLogWrapper;
 class CPbapAuthPasswordGetter;
+class CPbapVCardExporterUtil;
 
 
 const TUint KPbapServerShutdownDelay = 5000000;
@@ -149,7 +150,8 @@
 	virtual MPbapErrorReporter& ErrorReporter();
 	virtual CPbapContactDbViews& ContactDbViews();
 	virtual CPbapLogWrapper& LogClient() const;
-
+	virtual CPbapVCardExporterUtil& ExporterUtil();
+	
 private:
 	// from MPbapExporter
 	virtual void StartExport();
--- a/pimprotocols/pbap/inc/pbapvcardexporterutil.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/pimprotocols/pbap/inc/pbapvcardexporterutil.h	Mon Mar 15 12:39:26 2010 +0200
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-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"
@@ -52,6 +52,7 @@
 						TVCardVersion aFormat, TUint64 aFilter);
 	void ExportEmptyVCardL(RWriteStream& aWriteStream, TVCardVersion aFormat);
 
+	TContactItemId FindContactIdFromNumberL(const TDesC& aNumber);
 public:
 	/**
 	PBAP clients are supposed to provide any information regarding the contact item represented by aContactId.
@@ -74,6 +75,7 @@
  	CContactDatabase& 	iDatabase;
 	CPbapLogWrapper*	iLogWrapper;
 	const CLogEvent*	iLogEvent;
+	TContactItemId		iLogEventContactId;
 	TVCardVersion 		iFormat;
 	TUint64			iFilter;	
 	RTz                 	iTzClient;
--- a/pimprotocols/pbap/server/pbapchexporter.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/pimprotocols/pbap/server/pbapchexporter.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-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"
@@ -239,6 +239,14 @@
 		TInt handle = aEventIndex + 1; // call history handles start from 1
 
 		TContactItemId contactId = aEvent.Contact();
+		
+		if (contactId == KNullContactId && aEvent.RemoteParty() != KNullDesC)
+			{
+			// The S60 phonebook uses the remote party for the name, so if there isn't a name
+			// there won't be a contact, so we only look up the contact if there is a Remote Party
+			contactId = iClient.ExporterUtil().FindContactIdFromNumberL(aEvent.Number());
+			}
+		
 		if (contactId != KNullContactId)
 			{
 			// a contact is associated with the log event so read its name from the database
--- a/pimprotocols/pbap/server/pbapserver.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/pimprotocols/pbap/server/pbapserver.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-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"
@@ -401,6 +401,11 @@
 	return *static_cast<MPbapExporter*>(this);
 	}
 
+/*virtual*/ CPbapVCardExporterUtil& CPbapServer::ExporterUtil()
+	{
+	LOG_FUNC
+	return *iVCardExporter;
+	}
 
 /*virtual*/ MPbapErrorReporter& CPbapServer::ErrorReporter()
 	{
--- a/pimprotocols/pbap/server/pbapvcardexporterutil.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/pimprotocols/pbap/server/pbapvcardexporterutil.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-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"
@@ -107,11 +107,19 @@
 	LOG_FUNC
 	TContactItemId contactId = aLogEvent.Contact();	
 	
+	if (contactId == KNullContactId && aLogEvent.RemoteParty() != KNullDesC)
+		{
+		// The S60 phonebook uses the remote party for the name, so if there isn't a name
+		// there won't be a contact, so we only look up the contact if there is a Remote Party
+		contactId = FindContactIdFromNumberL(aLogEvent.Number());
+		}
+	
 	if (ContactExistsL(contactId))
 		{
 		// store the log event, format and filter parameters to use in the callback
 		// from the contacts vCard converter
 		iLogEvent = &aLogEvent;
+		iLogEventContactId = contactId;
 		iFormat = aFormat;
 		iFilter = aFilter;
 	
@@ -150,6 +158,22 @@
 		}
 	}
 
+TContactItemId CPbapVCardExporterUtil::FindContactIdFromNumberL(const TDesC& aNumber)
+	{
+	TContactItemId ret = KNullContactId;
+	CContactItemFieldDef* fieldDef;
+	fieldDef = new(ELeave) CContactItemFieldDef;
+	CleanupStack::PushL(fieldDef);
+	fieldDef->AppendL(KUidContactFieldPhoneNumber);
+	CContactIdArray* contactIdArray = iDatabase.FindLC(aNumber, fieldDef);
+	if (contactIdArray->Count() > 0)
+		{
+		ret = (*contactIdArray)[0];
+		}
+	CleanupStack::PopAndDestroy(2); // contactIdArray, fieldDef
+	return ret;
+	}
+
 /**
 Writes a vCard to the stream containing only the mandatory properties defined in the PBAP specification
 with all properties set to empty (null) values
@@ -181,7 +205,7 @@
 														CArrayPtr<CParserProperty>* aPropertyList)
 	{
 	LOG_FUNC
-	if(iLogEvent && iLogEvent->Contact() == aContactId)
+	if(iLogEvent && iLogEventContactId == aContactId)
 		{
 		CParserProperty* property;
 
--- a/pimprotocols/phonebooksync/Test/TE_Sync/TE_Sync_Config.txt	Fri Mar 12 15:41:25 2010 +0200
+++ b/pimprotocols/phonebooksync/Test/TE_Sync/TE_Sync_Config.txt	Mon Mar 15 12:39:26 2010 +0200
@@ -1,7 +1,7 @@
 # Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
 # All rights reserved.
 # This component and the accompanying materials are made available
-# under the terms of the License "Eclipse Public License v1.0"
+# 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".
 #
--- a/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsAlgorithm1.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsAlgorithm1.h	Mon Mar 15 12:39:26 2010 +0200
@@ -160,7 +160,7 @@
 		/**
 		* Returns the array index of cache (in iPcsCache) for a datastore
 		*/
-		TInt GetCacheIndex(TDesC& aDataStore);	
+		TInt GetCacheIndex(const TDesC& aDataStore);	
 
 		/** 
 		* Return the cache instance at a specific array index
@@ -176,7 +176,7 @@
 		inline CPcsKeyMap* GetKeyMap() 
 		{ 
 			return iKeyMap; 
-		};
+		}
         
 		
 	private:
@@ -209,38 +209,38 @@
 		void DoSearchL ( const CPsSettings& aPcsSettings,
 						 CPsQuery& aCondition,
 						 RPointerArray<CPsData>& searchResults,
-	                     RPointerArray<CPsPattern>& searchSeqs );		                       
-							                       
+	                     RPointerArray<CPsPattern>& searchSeqs );
+		
 		/**                
 		* Search function helper
 		*/
 		void DoSearchInputL ( CPsQuery& aQuery,
-						 	  TDesC& aData,
-							  RPointerArray<TDesC>& searchSeqs,
-							  RArray<TPsMatchLocation>& aMatchLocation );	 
-						                    		                       
+						 	  const TDesC& aData,
+							  RPointerArray<TDesC>& aSearchSeqs,
+							  RArray<TPsMatchLocation>& aMatchLocation );
+		
 		/**
 		* Returns the index corresponding a URI in iDataStoreUri
 		*/
-		TInt FindStoreUri ( TDesC& aDataStoreUri );
+		TInt FindStoreUri ( const TDesC& aDataStoreUri );
 
 		/**
 		* Function to return all cached content
 		*/
-		void GetAllContentsL ( const CPsSettings& aPcsSettings,	                    
-		                       RPointerArray<CPsData>& searchResults );
+		void GetAllContentsL ( const CPsSettings& aPcsSettings,
+		                       RPointerArray<CPsData>& aSearchResults );
 		    
 		/**
 		* Checks if search is on groups
-        * Return ETrue if there is a valid group URI        
+        * Return ETrue if there is a valid group URI
 		*/
 		TBool IsGroupSearchL ( CPsSettings& aSettings,
-		                       RArray<TInt>& aGroupIdArray );						 
+		                       RArray<TInt>& aGroupIdArray );
 
         /**
         * Utility function to replace groups uri with that of contacts uri
         */
-        void ReplaceGroupsUriL ( CPsSettings& aSettings );							 
+        void ReplaceGroupsUriL ( CPsSettings& aSettings );
 
 		/**
 		* Filters the search results array for groups
@@ -250,40 +250,40 @@
 
         /**
         * Get the list of contact ids that belong to a group.
-        */							 	           
+        */
 		void GetContactsInGroupL ( TInt aGroupId, 
                                    RArray<TInt>& aGroupContactIds );
-                                                						
+        
 		/**
 		* Read sort order for a data store from the central repository
 		* @param aURI - The data store URI for which sort order is required
 		* @param aSortOrder - The persisted sort order from the cenrep
 		*/
-		void ReadSortOrderFromCenRepL ( TDesC& aURI, 
-		                               RArray<TInt>& aSortOrder );
+		void ReadSortOrderFromCenRepL ( const TDesC& aURI, 
+		                                RArray<TInt>& aSortOrder );
 
 		/** Write sort order for a data store to the central repository
 		* @param aURI - The data store URI for which sort order is to be persisted
 		* @param aSortOrder - The sort order to be persisted	
 		*/
-		void WriteSortOrderToCenRepL ( TDesC& aURI, 
-		                              RArray<TInt>& aSortOrder );	
+		void WriteSortOrderToCenRepL ( const TDesC& aURI, 
+		                               RArray<TInt>& aSortOrder );	
 		                         								
 		/**
 		* Utility function that sets the caching error value
-		*/                             
-		void SetCachingError ( TDesC& aDataStore, 
-		                       TInt aError );	
+		*/
+		void SetCachingError ( const TDesC& aDataStore, 
+		                       TInt aError );
 
 		/**
 		* Write the content required by client 
 		*/
-		CPsClientData* WriteClientDataL ( CPsData& aPsData );	
+		CPsClientData* WriteClientDataL ( CPsData& aPsData );
 			
 		/**
 		* Function to return data base URI for an internal identifier
-		*/		                     
-		TDesC& GetUriForIdL( TUint8 aUriId );		
+		*/
+		const TDesC& GetUriForIdL( TUint8 aUriId );
 		
         /**
         * launch plugins by idle
@@ -294,7 +294,7 @@
         * launch plugins
         */
          static TInt DoLaunchPluginsL(TAny* aPtr);
-									
+
     private:
     
 		/**
@@ -317,7 +317,7 @@
 		/**
 		* Data plugin interface. Owned
 		*/
-		CPsDataPluginInterface *iPsDataPluginInterface;
+		CPsDataPluginInterface* iPsDataPluginInterface;
 
 		/**
 		* Instance of algorithm helper. Owned
--- a/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsAlgorithm1Helper.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsAlgorithm1Helper.h	Mon Mar 15 12:39:26 2010 +0200
@@ -93,16 +93,16 @@
          */
         void SearchSingleL(const CPsSettings& aSettings,
                            CPsQuery& aPsQuery,
-                           TBool isGroupSearch,
+                           TBool aIsGroupSearch,
                            RArray<TInt>& aContactsInGroup,
-                           RPointerArray<CPsData>& searchResults,
-                           RPointerArray<CPsPattern>& searchSeqs );
+                           RPointerArray<CPsData>& aSearchResults,
+                           RPointerArray<CPsPattern>& aSearchSeqs );
 
         /**
          * Funciton to search matching sequences in the input text.
          */
         void SearchMatchSeqL(CPsQuery& aPsQuery,
-                             TDesC& aData,
+                             const TDesC& aData,
                              RPointerArray<TDesC>& aMatchSet,
                              RArray<TPsMatchLocation>& aMatchLocation );
 
--- a/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsAlgorithm1MultiSearchHelper.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsAlgorithm1MultiSearchHelper.h	Mon Mar 15 12:39:26 2010 +0200
@@ -66,10 +66,10 @@
 		 * Filter subset results for multi query mode. 
 		 */
         void  FilterResultsMultiL(CPcsAlgorithm1FilterHelper* aAlgorithmFilterHelper,
-        						  RPointerArray<CPcsPoolElement>& searchSet,
-		                          RPointerArray<CPsQuery>& searchQuery,
+        						  RPointerArray<CPcsPoolElement>& aSearchSet,
+		                          RPointerArray<CPsQuery>& aSearchQuery,
 		                          TUint8 aFilteredDataMatch,
-		                          TBool isGroupSearch,
+		                          TBool aIsGroupSearch,
 		                          RArray<TInt>& aContactsInGroup);
 
     public:
@@ -80,10 +80,10 @@
 		 */
 		void  SearchMultiL(const CPsSettings& aSettings,
 		                   RPointerArray<CPsQuery>& aQuery,
-		                   TBool isGroupSearch,
+		                   TBool aIsGroupSearch,
 		                   RArray<TInt>& aContactsInGroup,
-		                   RPointerArray<CPsData>& searchResults,
-		                   RPointerArray<CPsPattern>& searchSeqs );		
+		                   RPointerArray<CPsData>& aSearchResults,
+		                   RPointerArray<CPsPattern>& aSearchSeqs );		
 
 		/**
 		 * Funtion to Search matching sequences for multi query
--- a/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsAlgorithm1Utils.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsAlgorithm1Utils.h	Mon Mar 15 12:39:26 2010 +0200
@@ -21,15 +21,17 @@
 
 // INCLUDE FILES
 
+#include <e32base.h>
 #include <e32hashtab.h>
 
-#include "CPsData.h"
-#include "CPsQuery.h"
 
 // FORWARD DECLARATION
+class CPsData;
+class CPsQuery;
 
 typedef RPointerArray<CPsData> CPSDATA_R_PTR_ARRAY;
 
+
 // CLASS DECLARATION
 class CPcsAlgorithm1Utils : public CBase
 {
@@ -48,7 +50,7 @@
 		/**
 		 * Compare by length.
 		 */
-		static TBool CompareByLength(const HBufC& aFirst, const HBufC& aSecond);
+		static TInt CompareByLength(const HBufC& aFirst, const HBufC& aSecond);
 
 		/**
 		 * Compare strings exactly case sensitively.
@@ -58,7 +60,7 @@
 		/**
 		 * Compare strings with collate rules depending on locale.
 		 */
-		static TBool CompareCollate(const TDesC& aFirst, const TDesC& aSecond);
+		static TInt CompareCollate(const TDesC& aFirst, const TDesC& aSecond);
 
 		/**
 		 * Compare for keys and strings:
@@ -75,28 +77,46 @@
 		static TBool MyCompareK(const TDesC& aLeft, const TDesC& aRight, CPsQuery& aPsQuery);
 
 		/**
-         * Customized CompareC         
-         */					
-        static TInt MyCompareC(const TDesC& aLeft, const TDesC& aRight); 					       
+         * Customized CompareC
+         */
+        static TInt MyCompareC(const TDesC& aLeft, const TDesC& aRight);
 		
         
         /**
          * TLinearOrder rule for comparison of data objects
          */
         static TInt CompareDataBySortOrderL(const CPsData& aObject1,
-                                           const CPsData& aObject2);
+                                            const CPsData& aObject2);
 
         /**
          * Trim off all white spaces and special chars
-         */                                   
+         */
         static void MyTrim(TDes& aString);
         
         
         /**
          * Check if the input URI is of contact search in a group template form
-         */                                   
+         */
         static TBool IsGroupUri(TDesC& aURI);
                                     
 };
+
+
+// CleanupStack helpers for item owning RPointerArrays
+template <class T>
+class CleanupResetAndDestroy
+    {
+public:
+    inline static void PushL(T& aRef)
+        { CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef)); }
+private:
+    inline static void ResetAndDestroy(TAny *aPtr)
+        { static_cast<T*>(aPtr)->ResetAndDestroy(); }
+    };
+
+template <class T>
+inline void CleanupResetAndDestroyPushL(T& aRef)
+    { CleanupResetAndDestroy<T>::PushL(aRef); }
+
 #endif // C_PCS_ALGORITHM_1_UTILS
     
--- a/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsCache.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsCache.h	Mon Mar 15 12:39:26 2010 +0200
@@ -37,7 +37,7 @@
 		/**
 		* Two phase construction
 		*/
-		static CPcsCache* NewL(TDesC& aURI, CPcsKeyMap& aKeyMap, TUint8 aUriId);
+		static CPcsCache* NewL(const TDesC& aURI, CPcsKeyMap& aKeyMap, TUint8 aUriId);
 
 		/**
 		* Virtual destructor
@@ -72,7 +72,7 @@
 		/**
 		* Removes all data elements from the cache
 		*/
-		void RemoveAllFromCacheL();
+		void RemoveAllFromCache();
 
 		/**
 		* Sets data fields to the cache
@@ -133,60 +133,60 @@
 		/**
 		* Second phase constructor
 		*/
-		void ConstructL(TDesC& aURI, CPcsKeyMap& aKeyMap, TUint8 aUriId);
+		void ConstructL(const TDesC& aURI, CPcsKeyMap& aKeyMap, TUint8 aUriId);
 
 		/**
 		* Utility function to add a contact to the pool
 		*/
-		void AddToPoolL(TInt& aInfo, CPsData& data);
+		void AddToPoolL(TUint64& aPoolMap, CPsData& aData);
 
 		/**
 		* Utility function 
 		*/
-		void SetPoolMap(TInt& aPoolMap, TInt aPoolId);
+		void SetPoolMap(TUint64& aPoolMap, TInt aArrayIndex);
 
 		/**
 		* Utility function 
 		*/
-		TBool GetPoolMap(TInt& aPoolMap, TInt arrayIndex);
+		TBool GetPoolMap(TUint64& aPoolMap, TInt aArrayIndex);
 
         /**
          * Utility function
          */
         void ComputeIndexOrder();
+        
 	private:    
 
-
 		/*
 		* Array of key maps
 		*/
 		typedef RPointerArray<CPcsPoolElement> R_PTR_ARRAY;
-		RPointerArray<R_PTR_ARRAY> keyArr;     
+		RPointerArray<R_PTR_ARRAY> iKeyArr;
 
 		/*
 		* Hashmaps to remember the location of a contact in the pools
 		*/
-		RHashMap<TInt, TInt> cacheInfo;			
+		RHashMap<TInt, TUint64> iCacheInfo;
 
 		/*
 		* Master pool of all contacts in this cache
 		*/
-		RPointerArray<CPsData> masterPool;	
+		RPointerArray<CPsData> iMasterPool;	
 		
 	    /*
 	    * Master pool backup of all contacts in this cache when sortorder changed
 	    */
-	    RPointerArray<CPsData> masterPoolBackup;  
+	    RPointerArray<CPsData> iMasterPoolBackup;
 
 		/*
 		* Not owned
 		*/
-		CPcsKeyMap* keyMap;		
+		CPcsKeyMap* iKeyMap;
 
 		/**
 		* Owned. Refer to the database URI this cache is for.
 		*/
-		HBufC* iURI;	
+		HBufC* iURI;
 
 		/**
 		* Internal URI id for this cache
--- a/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsKeyMap.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsKeyMap.h	Mon Mar 15 12:39:26 2010 +0200
@@ -20,12 +20,15 @@
 
 // INCLUDES
 #include <e32base.h>
-#include <PtiEngine.h>
-#include <PtiKeyMappings.h>
+#include <PtiDefs.h>
 #include <AvkonInternalCRKeys.h>
 #include <e32property.h>
+#include <CPcsDefs.h>
 
 class CPsQuery;
+class CPtiEngine;
+class CPtiCoreLanguage;
+
 
 class TKeyMappingData
     {
@@ -70,34 +73,29 @@
          */
         virtual ~CPcsKeyMap();
 
-		/**
-		 * Convert functions to get the key string from query and/or chars string
-		 */
-		void GetMixedKeyStringForQueryL(CPsQuery& aSrcQuery, TDes& aDestStr);
-		void GetMixedKeyStringForDataL(CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr);
-		
-		/**
-		 * Returns true if the character is mapped to the key
-		 */
-		TBool CharacterForKeyMappingExists(TKeyMappingData& aKeyMap, const TUint aIntChar);
+        static TBool IsModePredictive( TKeyboardModes aKbMode );
 
-#ifdef _DEBUG
-		/**
-		 * Check potential error conditions for KeyForCharacterMultiMatch
-		 */
-		void CheckPotentialErrorConditions(RArray<TInt>& aPoolIndexArr, const TChar& aChar);
-#endif // _DEBUG
+        /**
+         * Convert functions to get the key string from query and/or chars string
+         */
+        void GetMixedKeyStringForQueryL(CPsQuery& aSrcQuery, TDes& aDestStr) const;
+        void GetMixedKeyStringForDataL(CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr) const;
+
+        /**
+         * Returns true if the character is mapped to the key
+         */
+        TBool CharacterForKeyMappingExists(TKeyMappingData& aKeyMap, TUint aIntChar) const;
 
         /**
          * Returns the numeric key id corresponding to a specific character
          * Considers possible multiple matches for some phone variants
          */
-        TPtiKey KeyForCharacterMultiMatch(const TChar& aChar);
+        TPtiKey KeyForCharacterMultiMatch( const TChar& aChar, TKeyboardModes aKbMode ) const;
 
         /**
          * Returns true if the characters "0" and " " are on the same key
          */
-        TBool GetSpaceAndZeroOnSameKey();
+        TBool GetSpaceAndZeroOnSameKey( TKeyboardModes aKbMode );
 
         /**
          * Returns true if this language is supported
@@ -105,14 +103,9 @@
         TBool IsLanguageSupported(TInt aLang);
 
         /**
-         * Returns the pool Id for a key
-         */
-        TInt PoolIdForKey(const TPtiKey aKey);
-
-        /**
          * Returns the pool Id for a character
          */
-        TInt PoolIdForCharacter(const TChar& aChar);
+        TInt PoolIdForCharacter(const TChar& aChar, TKeyboardModes aKbMode);
 
         /**
          * Returns total number of pools
@@ -132,47 +125,94 @@
         void ConstructL();
 
         /**
-         * Helper functions to get Key Mappings and Key Mappings Data depending
-         * on keyboard type
+         * Select keyboard types according to available physical keyboard(s)
          */
-        MPtiKeyMappings* GetKeyboardKeyMapping(CPtiCoreLanguage& aCurrLanguage);
-        CPtiKeyMapData* GetKeyMapData(CPtiCoreLanguage& aCurrLanguage);
+        void SetupKeyboardTypesL();
 
         /**
-         * Helper functions to construct Key List for different keyboards
+         * Returns the pool Id for a key
          */
-        void AppendEntryWithFakeKeyToKeyList();
-        void CreateKeyListFromITUTHardcodedKeys();
-        void CreateKeyListFromKeyBindingTable( CPtiEngine* aPtiEngine );
-        void CreateKeyListL( CPtiEngine* aPtiEngine );
+        TInt PoolIdForKey(const TPtiKey aKey, TKeyboardModes aKbMode);
 
         /**
          * Helper function to construct Key Mappings
          */
-        void CreateKeyMappingL();
+        void CreateKeyMappingL( TKeyboardModes aKbMode );
+
+        /**
+         * Create list of PTI keys for the given keyboard type
+         */
+        void CreateKeyListFromKeyBindingTable( RArray<TPtiKey>& aKeyArray, TPtiKeyboardType aKbType, CPtiEngine* aPtiEngine );
+
+        /**
+         * Add a non-existing key ID in the end of given array
+         */
+        void AppendEntryWithFakeKeyToKeyList( RArray<TPtiKey>& aKeyArray );
 
         /**
          * Helper functions to populate Keyboard Key Mappings (Characters for
-         * all Keys) for the Active Language
+         * all Keys) for the given Language
          */
-        void AddKeyMappingForActiveLanguageL(CPtiEngine* aPtiEngine, TLanguage aLanguage);
-        void GetCharactersForKey(MPtiKeyMappings& aPtiKeyMappings,
+        void AddKeyMappingForLanguageL( CPtiEngine* aPtiEngine, 
+                                        TLanguage aLanguage,
+                                        TPtiKeyboardType aKbType,
+                                        const RArray<TPtiKey>& aPtiKeys,
+                                        RPointerArray<TKeyMappingData>& aResultMapping );
+        void GetCharactersForKey( CPtiCoreLanguage& aPtiLanguage,
+                                  TPtiKeyboardType aKbType,
+                                  TPtiKey aKey,
+                                  TPtiTextCase aTextCase,
+                                  TDes& aResult );
+        void AddCharactersToKey( CPtiCoreLanguage& aPtiLanguage,
+                                 TPtiKeyboardType aKbType,
                                  TPtiKey aKey,
                                  TPtiTextCase aTextCase,
-                                 TDes& aResult);
-        void AddCharactersToKey(MPtiKeyMappings& aPtiKeyMappings,
-                                TPtiKey aKey,
-                                TPtiTextCase aTextCase,
-                                TKeyMappingData& aKeyDataList,
-                                RArray<TUint>& aKeyMapLang,
-                                TBool& aIsSingleCharForKey,
-                                TUint& aSingleChar);
+                                 TKeyMappingData& aKeyDataList,
+                                 RArray<TUint>& aKeyMapLang,
+                                 TBool& aIsSingleCharForKey,
+                                 TUint& aSingleChar );
 
         /**
          * Sets attribute to true if the characters "0" and " " are on the same key
          */
         void SetSpaceAndZeroOnSameKey();
 
+        /**
+         * Gets predictive keyboard mapping data for given match mode.
+         * @param   aKbMode      Matching mode for which data is asked. 
+         * @param   aPtiKeys     On return, will point to the array of PtiKeys for the given mode.
+         * @param   aKeyMappings On return, will point to key mapping array for the given mode.
+         * @param   aKbType      On return, will hold the keyboard type for the given mode.
+         */
+        void GetPredictiveKeyboardData( TKeyboardModes aKbMode, 
+                                        RArray<TPtiKey>*& aPtiKeys, 
+                                        RPointerArray<TKeyMappingData>*& aKeyMappings, 
+                                        TPtiKeyboardType& aKbType );
+        /**
+         * Constant overload of the GetPredictiveKeyboardData function.
+         */
+        void GetPredictiveKeyboardData( TKeyboardModes aKbMode, 
+                                        const RArray<TPtiKey>*& aPtiKeys, 
+                                        const RPointerArray<TKeyMappingData>*& aKeyMappings, 
+                                        TPtiKeyboardType& aKbType ) const;
+
+        /**
+         * Resolve keyboard mode to "ITU-T predictive" or "QWERTY predictive".
+         */
+        TKeyboardModes ResolveKeyboardMode( TKeyboardModes aKbMode,
+                                            TKeyboardModes aKbModeToResolve ) const;
+
+
+#ifdef _DEBUG
+        /**
+         * Check potential error conditions for KeyForCharacterMultiMatch
+         */
+        void CheckPotentialErrorConditions(const RArray<TInt>& aPoolIndexArr, 
+                                           const TChar& aChar,
+                                           const RArray<TPtiKey>& aPtiKeys,
+                                           const RPointerArray<TKeyMappingData>& aKeyMappings) const;
+#endif // _DEBUG
+
     private:
 
         /**
@@ -186,24 +226,54 @@
         TLanguage iUILanguage;
 
         /**
-         * Flag to indicate if Phone is Chinese variant
+         * Type of keyboard used in ITU-T search mode. Typically this is
+         * standard ITU-T 12-key keypad.
+         */
+        TPtiKeyboardType iItutKeyboardType;
+        
+        /**
+         * Type of keyboard used in QWERTY search mode. Typically this is either
+         * 3x11 or 4x10 QWERTY or EPtiKeyboardNone if there's no any kind of
+         * QWERTY available. This may also be half-QWERTY.
          */
-        RArray<TPtiKey> iKeysArr;
+        TPtiKeyboardType iQwertyKeyboardType;
+
+        /**
+         * Type of keyboard used in Default Preditive search mode. This will
+         * point to ITU-T or QWERTY keypad.
+         */
+        TKeyboardModes iPredictiveDefaultKeyboardMode;
+
+        /**
+         * Pti keys of ITU-T mode
+         */
+        RArray<TPtiKey> iItutKeys;
 
         /**
-         * Contains all the keys and the characters mapped to each key own
+         * Pti keys of QWERTY mode
          */
-        RPointerArray<TKeyMappingData> iKeyMapPtrArr;
+        RArray<TPtiKey> iQwertyKeys;
+
+        /**
+         * Contains all the keys and the characters mapped to each key in ITU-T mode. Owned.
+         */
+        RPointerArray<TKeyMappingData> iItutKeyMaps;
 
         /**
-         * Type of keyboard for example, half-qwerty, 4x10 qwerty etc
+         * Contains all the keys and the characters mapped to each key in QWERTY mode. Owned.
          */
-        TPtiKeyboardType iKeyboardType;
+        RPointerArray<TKeyMappingData> iQwertyKeyMaps;
+
+        /**
+         * True if "0" and " " are on the same key in the ITU-T mode
+         */
+        TBool iSpaceAndZeroOnSameKeyOnItut;
         
         /**
-         * True if "0" and " " are on the same key
+         * True if "0" and " " are on the same key in the QWERTY mode
          */
-        TBool iSpaceAndZeroOnSameKey;
+        TBool iSpaceAndZeroOnSameKeyOnQwerty;
+
 };
 
 #endif // __CPCS_KEY_MAP_H__
--- a/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsPoolElement.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/inc/CPcsPoolElement.h	Mon Mar 15 12:39:26 2010 +0200
@@ -44,7 +44,7 @@
 		/**
 		 * Clears the data match element attribute
 		 */	
-		void ClearDataMatchAttribute();				
+		void ClearDataMatchAttribute();
 				
 		/**
 		 * Checks if data matched
@@ -60,9 +60,10 @@
 		 * Return the CPsData object of this pool element
 		 */
 		CPsData* GetPsData();
+		
 		/**
-		  * Compares the two Pool Elements and returms the comparison value.
-		  * It takes care of language variance too.
+		 * Compares the two Pool Elements and returms the comparison value.
+		 * It takes care of language variance too.
 		 */
 		 static TInt CompareByData ( const CPcsPoolElement& aObject1, 
 					     const CPcsPoolElement& aObject2 );
@@ -85,7 +86,7 @@
          * Pointer to contact data
          * Not owned.
          */
-         CPsData* psData;
+         CPsData* iPsData;
          
 		/*
 		 * This attribute indicates due to which
@@ -100,7 +101,7 @@
 		 * Bit 6 = Not used
 		 * Bit 7 = Not used
 		 */
-		TInt8     iDataMatchAttribute;		
+		TUint8 iDataMatchAttribute;
 };
 
 #endif // __CPCS_POOL_ELEMENT_H__
--- a/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -30,7 +30,7 @@
 #include "CPsDataPluginInterface.h"
 #include "CPcsDefs.h"
 
-const TInt KSpace = 32;
+const TText KSpace = ' ';
 
 // UID used for Publish and Subscribe mechanism
 // This should be same as the one defined in CPsPropertyHandler.cpp
@@ -95,15 +95,16 @@
     }
     
     // Initialize key map and pti engine
-    //keyMap = CPcsKeyMap::NewL();
+    //iKeyMap = CPcsKeyMap::NewL();
     TInt keyMapErr = KErrNone;
     TRAP( keyMapErr, iKeyMap = CPcsKeyMap::NewL());
     if ( keyMapErr != KErrNone )
     {
-    PRINT ( _L("**********************************************."));
-    PRINT1 ( _L("CPcsAlgorithm1::ConstructL() KeyMap construction error. The keymap crashed with error code %d."),keyMapErr );
-    PRINT ( _L("Please check the keypad/language for which keymap got crashed.") );
-    PRINT ( _L("**********************************************."));
+        PRINT ( _L("**********************************************."));
+        PRINT1( _L("CPcsAlgorithm1::ConstructL() KeyMap construction error. The keymap crashed with error code %d."),keyMapErr );
+        PRINT ( _L("Please check the keypad/language for which keymap got crashed.") );
+        PRINT ( _L("**********************************************."));
+        User::Leave( keyMapErr ); // we can't go on without a key map; constructing cache needs it
     }
     
     // Initialize helpers
@@ -185,7 +186,8 @@
 
 // ----------------------------------------------------------------------------
 // CPcsAlgorithm1::ReplaceZeroWithSpaceL
-// Replace all '0's in a search query with " "s
+// Replace all "0"s in a search query with " "s if those characters are on
+// the same key.
 // ----------------------------------------------------------------------------
 TBool  CPcsAlgorithm1::ReplaceZeroWithSpaceL(CPsQuery& aQuery)
 {   
@@ -195,43 +197,33 @@
 
     TBool queryModified = EFalse;    
 
-    if (iKeyMap->GetSpaceAndZeroOnSameKey())
-    {
-        /* In phones like E52 and E55, where the "0" and the " " characters are on
-         * the same key, then the "0"s EItut have to be considered as possible
-         * separators.
-         */
+    /* In phones like E52 and E55, where the "0" and the " " characters are on
+     * the same key, the "0"s have to be considered as possible separators.
+     *
+     * In phones like N97 and E72, where the "0" and the " " characters are on
+     * different keys, the "0"s must not be considered as possible separators.
+     */
 
-        // Skip initial "0"s, they are not replaced into spaces
-        TInt skipIndex = 0;
-        while ( (skipIndex < aQuery.Count()) && 
-                (aQuery.GetItemAtL(skipIndex).Character().GetNumericValue() == 0) )
-        {
-            skipIndex++;
-        }
-        
-        // Replace remaining EItut "0"s into spaces
-        TChar space(KSpace);    
-        for ( TInt index = skipIndex; index < aQuery.Count(); index++ )
+    // Skip initial "0"s, they are not replaced into spaces
+    TInt skipIndex = 0;
+    while ( (skipIndex < aQuery.Count()) && 
+            (aQuery.GetItemAtL(skipIndex).Character().GetNumericValue() == 0) )
+    {
+        skipIndex++;
+    }
+    
+    // Replace remaining "0"s into spaces in case they are entered with a keyboard
+    // that has "0" and " " on the same key.
+    for ( TInt index = skipIndex; index < aQuery.Count(); index++ )
+    {
+        CPsQueryItem& item = aQuery.GetItemAtL(index);
+
+        if ( iKeyMap->GetSpaceAndZeroOnSameKey( item.Mode() ) &&
+             item.Character().GetNumericValue() == 0 )
         {
-            CPsQueryItem& item = aQuery.GetItemAtL(index);
-    
-            if ( item.Character().GetNumericValue() == 0 &&
-                 item.Mode() == EItut )
-            {
-                item.SetCharacter(space);
-                queryModified = ETrue;
-            }
-        }    
-    }
-    else
-    {
-        /* In phones like N97 and E72, where the "0" and the " " characters are on
-         * a different key, then the "0" EItut does not have to be considered as a
-         * possible separator.
-         */
-        
-        PRINT ( _L("CPcsAlgorithm1::ReplaceZeroWithSpaceL: \"0\" and \" \" are on different keys, not attepting to replace") );
+            item.SetCharacter(KSpace);
+            queryModified = ETrue;
+        }
     }
     
     //PRINTQUERY ( _L("CPcsAlgorithm1::ReplaceZeroWithSpaceL (AFTER): "), aQuery );
@@ -256,12 +248,13 @@
 	
 	__LATENCY_MARK ( _L("CPcsAlgorithm1::PerformSearchL") );
 
-	RPointerArray<CPsQuery> query;
-	
 	// Local arrays to hold the search results 
 	RPointerArray<CPsData> tempSearchResults;
+	CleanupClosePushL( tempSearchResults );
     RPointerArray<CPsData> tempSearchResultsIni;
+    CleanupClosePushL( tempSearchResultsIni );
     RPointerArray<CPsData> tempSearchResultsMod;
+    CleanupClosePushL( tempSearchResultsMod );
 
     // ----------------------- Perform the basic search -----------------------
 	/* Even before replacing zeroes with spaces the query can have multiple words
@@ -345,7 +338,7 @@
 	else
 	{
 		// Copy all the contents from tempSearchResults to the results stream
-		for(int i = 0; i < resultSet; i++)
+		for(TInt i = 0; i < resultSet; i++)
 		{
 			aSearchResults.Append(WriteClientDataL(*(tempSearchResults[i])));
 		}
@@ -353,9 +346,9 @@
 	// ------------------------------------------------------------------------
 
     // Cleanup local results array
-	tempSearchResults.Reset();    // Don't destroy
-    tempSearchResultsIni.Reset(); // Don't destroy
-    tempSearchResultsMod.Reset(); // Don't destroy
+    CleanupStack::PopAndDestroy( &tempSearchResultsMod ); // Close, don't destroy
+    CleanupStack::PopAndDestroy( &tempSearchResultsIni ); // Close, don't destroy
+    CleanupStack::PopAndDestroy( &tempSearchResults );    // Close, don't destroy
 
 	__LATENCY_MARKEND ( _L("CPcsAlgorithm1::PerformSearchL") );
 
@@ -545,8 +538,8 @@
 // ----------------------------------------------------------------------------
 void  CPcsAlgorithm1::DoSearchL(const CPsSettings& aSettings,
 								CPsQuery& aQuery,
-								RPointerArray<CPsData>& searchResults,
-								RPointerArray<CPsPattern>& searchSeqs )
+								RPointerArray<CPsData>& aSearchResults,
+								RPointerArray<CPsPattern>& aSearchSeqs )
 {
     PRINT ( _L("Enter CPcsAlgorithm1::DoSearchL") );
 
@@ -554,10 +547,13 @@
     
     // -(0)----------------- Check if group search is required ---------------    
     RArray<TInt> contactsInGroup;
+    CleanupClosePushL( contactsInGroup );
     RArray<TInt> groupIdArray;
+    CleanupClosePushL( groupIdArray );
     
     // Create a new settings instance
     CPsSettings *tempSettings = aSettings.CloneL();
+    CleanupStack::PushL( tempSettings );
     
     TBool isGroupSearch = IsGroupSearchL(*tempSettings, groupIdArray);
     
@@ -570,33 +566,32 @@
     	GetContactsInGroupL ( groupIdArray[0], contactsInGroup );
     }
     
-   	groupIdArray.Close();
-   	
     // -----------------------------------------------------------------------
         
     // Extract query list. 
     RPointerArray<CPsQuery> queryList = iMultiSearchHelper->MultiQueryL(aQuery);
+    CleanupResetAndDestroyPushL( queryList );
     PRINTQUERYLIST ( _L("CPcsAlgorithm1::DoSearchL: "), queryList );
 
-    // (1)-------------------- No query return all contacts -------------------    
+    // (1)-------------------- No query return all contacts -------------------
     if ( queryList.Count() == 0 )
     {
-    	GetAllContentsL(*tempSettings, searchResults);   
+    	GetAllContentsL(*tempSettings, aSearchResults);
     	
     	if ( isGroupSearch ) 
     	{
-    		FilterSearchResultsForGroupsL ( contactsInGroup, searchResults );
+    		FilterSearchResultsForGroupsL( contactsInGroup, aSearchResults );
     	}
     }
     // ------------------------------------------------------------------------
 
     // (2)-------------------- Perform a single query search ------------------
-    else if ( queryList.Count() == 1 ) // single qwery
+    else if ( queryList.Count() == 1 ) // single query
     {
         PRINT ( _L("CPcsAlgorithm1::DoSearchL: Query received is Single. Performing a SingleSearch") );
 
         iHelper->SearchSingleL(*tempSettings, *queryList[0], isGroupSearch,
-                               contactsInGroup, searchResults, searchSeqs);
+                               contactsInGroup, aSearchResults, aSearchSeqs);
     }
     // ------------------------------------------------------------------------
 
@@ -607,17 +602,16 @@
 
 		// Search results
 		iMultiSearchHelper->SearchMultiL(*tempSettings, queryList, isGroupSearch,
-		                                 contactsInGroup, searchResults, searchSeqs);
+		                                 contactsInGroup, aSearchResults, aSearchSeqs);
     }
     // -------------------------------------------------------------------------
 
     // Cleanup
-    delete tempSettings;
-    tempSettings = NULL;
     
-    groupIdArray.Close();
-    contactsInGroup.Close();
-	queryList.ResetAndDestroy();
+    CleanupStack::PopAndDestroy( &queryList ); // ResetAndDestroy
+    CleanupStack::PopAndDestroy( tempSettings );
+    CleanupStack::PopAndDestroy( &groupIdArray ); // Close
+    CleanupStack::PopAndDestroy( &contactsInGroup ); // Close
 
 	__LATENCY_MARKEND ( _L("CPcsAlgorithm1::DoSearchL") );
 
@@ -629,7 +623,7 @@
 // Search function helper
 // ----------------------------------------------------------------------------
 void  CPcsAlgorithm1::DoSearchInputL(CPsQuery& aQuery,
-		                             TDesC& aData,
+		                             const TDesC& aData,
 		                             RPointerArray<TDesC>& aMatchSet,
 		                             RArray<TPsMatchLocation>& aMatchLocation )
 {
@@ -736,19 +730,14 @@
 	
     CPcsCache* cache = iPcsCache[dataStoreIndex];
     	
-	TRAPD(err, cache->RemoveAllFromCacheL());
-	
-	if ( err != KErrNone )
-	{
-		SetCachingError(aDataStore, err);
-	}
+	cache->RemoveAllFromCache();
 }
 
 // ----------------------------------------------------------------------------
 // CPcsAlgorithm1::GetCacheIndex
 // Return the cache index for a data store
 // ----------------------------------------------------------------------------
-TInt CPcsAlgorithm1::GetCacheIndex(TDesC& aDataStore)
+TInt CPcsAlgorithm1::GetCacheIndex(const TDesC& aDataStore)
 {
     for ( int i = 0; i < iPcsCache.Count(); i++ )
     {
@@ -781,13 +770,13 @@
 	{
 		SetCachingError(aDataStore, err);
 		return;
-	}	
+	}
 	
 	// Increment the cachecount
 	iCacheCount++;
 	
-    RArray<TInt> dataFields;        	   
-    TRAP(err, iPsDataPluginInterface->GetSupportedDataFieldsL(cache->GetURI(), dataFields));   
+    RArray<TInt> dataFields;
+    TRAP(err, iPsDataPluginInterface->GetSupportedDataFieldsL(cache->GetURI(), dataFields));
 	if ( err != KErrNone )
 	{
 		SetCachingError(aDataStore, err);
@@ -860,7 +849,7 @@
 // CPcsAlgorithm1::GetUriForIdL
 // Get the URI string for this internal id
 // ----------------------------------------------------------------------------
-TDesC& CPcsAlgorithm1::GetUriForIdL(TUint8 aUriId)
+const TDesC& CPcsAlgorithm1::GetUriForIdL(TUint8 aUriId)
 {
     TBool found = EFalse;
     TInt i = 0;
@@ -886,7 +875,7 @@
 // CPcsAlgorithm1::FindStoreUri
 // Checks if this store exists
 // ----------------------------------------------------------------------------
-TInt CPcsAlgorithm1::FindStoreUri ( TDesC& aDataStore )
+TInt CPcsAlgorithm1::FindStoreUri ( const TDesC& aDataStore )
 {
     for ( int i = 0; i < iPcsCache.Count(); i++ )
     {
@@ -961,14 +950,12 @@
 // CPcsAlgorithm1::SetCachingError
 // Updates cachinge error
 // ----------------------------------------------------------------------------
-void CPcsAlgorithm1::SetCachingError(TDesC& aDataStore, TInt aError)
+void CPcsAlgorithm1::SetCachingError(const TDesC& aDataStore, TInt aError)
 {
-	TBuf<KBufferMaxLen> store;
-	store.Copy(aDataStore);
-	PRINT2 ( _L("SetCachingError::URI %S ERROR %d"), &store, aError );
+	PRINT2 ( _L("SetCachingError::URI %S ERROR %d"), &aDataStore, aError );
 
 	iCacheError = aError;
-	RProperty::Set(KCStatus,1,iCacheError );
+	RProperty::Set( KCStatus,1,iCacheError );
 }
 
 // ----------------------------------------------------------------------------
@@ -982,46 +969,50 @@
     
     PRINT ( _L("Enter CPcsAlgorithm1::GetAllContentsL") );   
     
-    // Get the data stores
-    RPointerArray<TDesC> aDataStores;
-    aSettings.SearchUrisL(aDataStores);
-
     // To hold array of results from different data stores
     typedef RPointerArray<CPsData> CPSDATA_R_PTR_ARRAY;
-    RPointerArray<CPSDATA_R_PTR_ARRAY> iSearchResultsArr;
+    RPointerArray<CPSDATA_R_PTR_ARRAY> searchResultsArr;
+    CleanupResetAndDestroyPushL( searchResultsArr );
+    // TODO: Here's still a potential memory leak if a leave happens. The child
+    // arrays of searchResultsArr are not Reset in that case. The CPsData objects
+    // may leak as well. Handling this safely is somewhat complicated because some of
+    // the CPsData objects may already be transferred to ownership of aResults array
+    // at the time the leave happens, and those items must not be deleted.
     
+    // Get the data stores
+    RPointerArray<TDesC> dataStores;
+    CleanupResetAndDestroyPushL( dataStores );
+    aSettings.SearchUrisL(dataStores);
+
     // Get all contacts for each data store
-    for ( int dsIndex = 0; 
-          dsIndex < aDataStores.Count(); 
+    for ( TInt dsIndex = 0; 
+          dsIndex < dataStores.Count(); 
           dsIndex++ )
     {	        	
         RPointerArray<CPsData> *temp = new (ELeave) RPointerArray<CPsData>();
-        iSearchResultsArr.Append(temp);
+        searchResultsArr.Append(temp);
         
-        TInt arrayIndex = GetCacheIndex(*(aDataStores[dsIndex]));
+        TInt arrayIndex = GetCacheIndex(*(dataStores[dsIndex]));
         
 		if ( arrayIndex < 0 ) continue;
 		
 		CPcsCache* cache = GetCache(arrayIndex);
         	      
-        cache->GetAllContentsL(*(iSearchResultsArr[dsIndex]));
-    }	   		   
-    	    	         	
-    aDataStores.ResetAndDestroy();    
+        cache->GetAllContentsL(*(searchResultsArr[dsIndex]));
+    }
+    
+    CleanupStack::PopAndDestroy( &dataStores ); // ResetAndDestroy
   
     // Merge the results from different data stores
-    CPcsAlgorithm1Utils::FormCompleteSearchResultsL(iSearchResultsArr,
+    CPcsAlgorithm1Utils::FormCompleteSearchResultsL(searchResultsArr,
     												aResults);
   
     // Cleanup the local arrays
-    for(TInt i = 0; i < iSearchResultsArr.Count(); i++)
+    for(TInt i = 0; i < searchResultsArr.Count(); i++)
     {
-    	iSearchResultsArr[i]->Reset();
-    	delete iSearchResultsArr[i];
-    	iSearchResultsArr[i] = NULL;
-    }    
-    
-    iSearchResultsArr.Reset();    
+    	searchResultsArr[i]->Reset();
+    }
+    CleanupStack::PopAndDestroy( &searchResultsArr ); // ResetAndDestroy
 
     PRINT1 ( _L("Number of results = %d"), aResults.Count() );
    
@@ -1044,18 +1035,18 @@
      
     // Get the current URIs defined in settings    
     RPointerArray<TDesC> searchUris;
+    CleanupResetAndDestroyPushL( searchUris );
     aSettings.SearchUrisL(searchUris);
     
     if ( aGroupIdArray.Count() && (searchUris.Count() > aGroupIdArray.Count() ) )
     {
     	// There is an error, either there are more than one groups
     	// or the settings contain a combination of group/non-group Uris
-    	searchUris.ResetAndDestroy();
     	aGroupIdArray.Close();
     	User::Leave(KErrArgument); 
     }
     
-    searchUris.ResetAndDestroy();
+    CleanupStack::PopAndDestroy( &searchUris ); // ResetAndDestroy
         
     PRINT ( _L("End CPcsAlgorithm1::IsGroupSearchL") );    
     
@@ -1069,18 +1060,19 @@
 // CPcsAlgorithm1::ReplaceGroupsUriL
 // Replace groups uri to contacts uri
 // ----------------------------------------------------------------------------
-void CPcsAlgorithm1::ReplaceGroupsUriL ( CPsSettings& aSettings )
+void CPcsAlgorithm1::ReplaceGroupsUriL( CPsSettings& aSettings )
 {
-	RPointerArray<TDesC> uri; 
+	RPointerArray<TDesC> uri;
+	CleanupResetAndDestroyPushL( uri );
     
     // Set contacts db uri
-	HBufC* cntdb = HBufC::NewL(KBufferMaxLen);
-	cntdb->Des().Copy(KVPbkDefaultCntDbURI);
-	uri.Append(cntdb);
+	HBufC* cntdb = KVPbkDefaultCntDbURI().AllocLC();
+	uri.AppendL(cntdb);
+	CleanupStack::Pop( cntdb ); // ownership transferred
 	aSettings.SetSearchUrisL(uri);
 	
 	// Cleanup
-	uri.ResetAndDestroy();
+	CleanupStack::PopAndDestroy( &uri ); // ResetAndDestroy
 }
 
 // ----------------------------------------------------------------------------
@@ -1119,27 +1111,20 @@
 // CPcsAlgorithm1::GetContactsInGroupL
 // Recover contacts that belong to a group
 // ----------------------------------------------------------------------------
-void CPcsAlgorithm1::GetContactsInGroupL ( TInt aGroupId, 
-                                           RArray<TInt>& aGroupContactIds )
+void CPcsAlgorithm1::GetContactsInGroupL( TInt aGroupId, 
+                                          RArray<TInt>& aGroupContactIds )
 {	    
     // Clear results array
     aGroupContactIds.Reset();
     
-    // Groups URI
-    HBufC* groupURI = HBufC::NewL(50);
-    groupURI->Des().Copy(KVPbkDefaultGrpDbURI);
-       
-    // Cache Index   
-    TInt cacheIndex = GetCacheIndex(*groupURI);
-    
-    // Cleanup
-    delete groupURI;
-    groupURI = NULL;
+    // Cache Index for group database
+    TInt cacheIndex = GetCacheIndex(KVPbkDefaultGrpDbURI);
     
     // Get the groups contact ids 
 	if ( cacheIndex != -1 )
 	{
 		RPointerArray<CPsData> groups;
+		CleanupClosePushL( groups );
 		
 		// Get all groups
 		iPcsCache[cacheIndex]->GetAllContentsL(groups);
@@ -1154,7 +1139,7 @@
 			}		
 		}
 		
-		groups.Reset();	
+		CleanupStack::PopAndDestroy( &groups ); // Close
 	}
 }
 
@@ -1263,7 +1248,7 @@
     if ( aSortOrder.Count() == mySortOrder.Count() )    
     {
          TBool same = ETrue;
-         for ( int i = 0; i < mySortOrder.Count(); i++ )	
+         for ( TInt i = 0; i < mySortOrder.Count(); i++ )	
          {
             if ( mySortOrder[i] != aSortOrder[i] )
      		{
@@ -1308,7 +1293,7 @@
 // Read the persisted sort order from the central repository
 // Persisted sort order is of form URI Field1 Field2 Field3 .. FieldN (space delimited)
 // ---------------------------------------------------------------------------------
-void CPcsAlgorithm1::ReadSortOrderFromCenRepL(TDesC& aURI, 
+void CPcsAlgorithm1::ReadSortOrderFromCenRepL(const TDesC& aURI, 
                                               RArray<TInt>& aSortOrder)
 {
     PRINT ( _L("Enter CPcsAlgorithm1::ReadSortOrderFromCenRepL.") );
@@ -1343,7 +1328,7 @@
 		        // Extract the sort order
 		        token.Set(lex.NextToken());
 		        
-				while ( token.Length() != 0 )				
+				while ( token.Length() != 0 )
 				{	
 				    TLex lex1(token);
 				    
@@ -1353,16 +1338,16 @@
 					if ( KErrNone == err )
 					{
 						aSortOrder.Append(intVal);
-					}				    	        		    				    
+					}
 				    
 					// Next token
-					token.Set(lex.NextToken());				
+					token.Set(lex.NextToken());
 				}	
 				
 				break;
-		    }		    		    
+		    }
 	    }
-	    		
+	
     }
     
     delete repository;
@@ -1374,12 +1359,12 @@
 // Write the sort order into the central repository
 // Persisted sort order is of form URI Field1 Field2 Field3 .. FieldN (space delimited)
 // ---------------------------------------------------------------------------------
-void CPcsAlgorithm1::WriteSortOrderToCenRepL(TDesC& aURI, 
+void CPcsAlgorithm1::WriteSortOrderToCenRepL(const TDesC& aURI, 
                                              RArray<TInt>& aSortOrder)
 {   
     PRINT ( _L("Enter CPcsAlgorithm1::WriteSortOrderToCenRepL.") );
 
-    CRepository *repository = CRepository::NewL( KCRUidPSSortOrder );
+    CRepository *repository = CRepository::NewLC( KCRUidPSSortOrder );
 
 	// Check if there an entry for this URI in cenrep
 	TBuf<KCRMaxLen> str;
@@ -1444,7 +1429,7 @@
 	}
 
     // Persist the sort order
-	HBufC* str1 = HBufC::NewL(KCRMaxLen);
+	HBufC* str1 = HBufC::NewLC(KCRMaxLen);
 	TPtr ptr(str1->Des());
 
 	// Append the URI
@@ -1452,7 +1437,7 @@
 	ptr.Append(KSpace);
 
 	// Append the sort order fields
-	for ( int j = 0; j < aSortOrder.Count(); j++ )
+	for ( TInt j = 0; j < aSortOrder.Count(); j++ )
 	{
 		ptr.AppendNum(aSortOrder[j]);
 	    ptr.Append(KSpace);
@@ -1463,9 +1448,9 @@
 
 	User::LeaveIfError(err);
 
-	delete str1;   	
+	CleanupStack::PopAndDestroy( str1 );
   
-    delete repository;
+    CleanupStack::PopAndDestroy( repository );
      
     PRINT ( _L("End CPcsAlgorithm1::WriteSortOrderToCenRepL.") );
 }
@@ -1530,15 +1515,17 @@
     User::LeaveIfError( Dll::SetTls(&iPcsCache) );
     
     // Initialize cache
-    RPointerArray<TDesC> dataStores;    
+    RPointerArray<TDesC> dataStores;
+    CleanupClosePushL( dataStores );
     
     iPsDataPluginInterface->GetAllSupportedDataStoresL(dataStores);
         
-    for ( int dIndex = 0; dIndex < dataStores.Count(); dIndex++ )
-    {
-    AddDataStore(*(dataStores[dIndex]));
-    }
-    dataStores.Reset();
+    for ( TInt dIndex = 0; dIndex < dataStores.Count(); dIndex++ )
+        {
+        AddDataStore(*(dataStores[dIndex]));
+        }
+    
+    CleanupStack::PopAndDestroy( &dataStores ); // Close
     }
 // End of file
 
--- a/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1Helper.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1Helper.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -90,12 +90,12 @@
 // CPcsAlgorithm1Helper::SearchSingleL
 // Search function for query in ITU-T mode, QWERTY mode, or Mixed (ITU-T and QWERTY) mode.
 // ----------------------------------------------------------------------------
-void  CPcsAlgorithm1Helper::SearchSingleL(const CPsSettings& aSettings,
-                                       CPsQuery& aPsQuery,
-                                       TBool isSearchInGroup,
-                                       RArray<TInt>& aContactsInGroup,
-                                       RPointerArray<CPsData>& searchResults,
-                                       RPointerArray<CPsPattern>& searchSeqs )
+void  CPcsAlgorithm1Helper::SearchSingleL( const CPsSettings& aSettings,
+                                           CPsQuery& aPsQuery,
+                                           TBool aIsSearchInGroup,
+                                           RArray<TInt>& aContactsInGroup,
+                                           RPointerArray<CPsData>& aSearchResults,
+                                           RPointerArray<CPsPattern>& aSearchSeqs )
 {
     PRINT ( _L("Enter CPcsAlgorithm1Helper::SearchSingleL") );
 
@@ -104,39 +104,45 @@
     // Create filtering helper for the required sort type
     TSortType sortType = aSettings.GetSortType();
     CPcsAlgorithm1FilterHelper* filterHelper = CPcsAlgorithm1FilterHelper::NewL(sortType);
-
-    // Search based on first character
-    TInt numValue = iKeyMap->PoolIdForCharacter(aPsQuery.GetItemAtL(0).Character());
+    CleanupStack::PushL( filterHelper );
+    
+    // Search from cache based on first character
+    const CPsQueryItem& firstCharItem = aPsQuery.GetItemAtL(0);
+    TInt cachePoolId = iKeyMap->PoolIdForCharacter( firstCharItem.Character(), firstCharItem.Mode() );
 
     // Reset the result set array for new search
     iSearchResultsArr.ResetAndDestroy();
 
     // Get the data stores
-    RPointerArray<TDesC> aDataStores;
-    aSettings.SearchUrisL(aDataStores);
+    RPointerArray<TDesC> dataStores;
+    CleanupResetAndDestroyPushL( dataStores );
+    aSettings.SearchUrisL(dataStores);
 
     // Get the required display fields from the client
     RArray<TInt> requiredDataFields;
+    CleanupClosePushL( requiredDataFields );
     aSettings.DisplayFieldsL(requiredDataFields);
 
     // Perform search for each required data store
     RPointerArray<CPcsPoolElement> elements;
+    CleanupClosePushL( elements );
 
-    for ( int dsIndex = 0;
-          dsIndex < aDataStores.Count();
+    for ( TInt dsIndex = 0; 
+          dsIndex < dataStores.Count();
           dsIndex++ )
     {
         RPointerArray<CPsData> *temp = new (ELeave) RPointerArray<CPsData> ();
         iSearchResultsArr.Append(temp);
 
         // Get the contents for this data store
-        TInt arrayIndex = iAlgorithm->GetCacheIndex(*(aDataStores[dsIndex]));
+        TInt arrayIndex = iAlgorithm->GetCacheIndex(*(dataStores[dsIndex]));
         if ( arrayIndex < 0 ) continue;
         CPcsCache* cache = iAlgorithm->GetCache(arrayIndex);
-        cache->GetContactsForKeyL(numValue,elements);
+        cache->GetContactsForKeyL(cachePoolId, elements);
 
         // Get the supported data fields for this data store
         RArray<TInt> supportedDataFields;
+        CleanupClosePushL( supportedDataFields );
         cache->GetDataFields(supportedDataFields);
 
         // Get the filtered data fields for this data store
@@ -148,7 +154,7 @@
                              elements,
                              aPsQuery,
                              filteredDataMatch,
-                             isSearchInGroup,
+                             aIsSearchInGroup,
                              aContactsInGroup);
 
         // If alphabetical sorting, get the results for this datastore
@@ -158,40 +164,39 @@
         }
 
         elements.Reset();
-        supportedDataFields.Reset();
+        CleanupStack::PopAndDestroy( &supportedDataFields ); // Close
     }
 
-    aDataStores.ResetAndDestroy();
-    requiredDataFields.Reset();
+    CleanupStack::PopAndDestroy( &elements );           // Close
+    CleanupStack::PopAndDestroy( &requiredDataFields ); // Close
+    CleanupStack::PopAndDestroy( &dataStores );         // ResetAndDestroy
 
     // If alphabetical sorting, merge the result sets of all datastores
     if ( sortType == EAlphabetical )
     {
         // Merge the result sets of individual datastores alphabetically
         CPcsAlgorithm1Utils::FormCompleteSearchResultsL(iSearchResultsArr,
-                                                        searchResults);
+                                                        aSearchResults);
     }
     else
     {
         // Results are already sorted pattern based
-        filterHelper->GetResults(searchResults);
+        filterHelper->GetResults(aSearchResults);
     }
 
     // Get the sorted match sequence list
-    filterHelper->GetPatternsL(searchSeqs);
+    filterHelper->GetPatternsL(aSearchSeqs);
 
-    PRINT1 ( _L("CPcsAlgorithm1Helper::SearchSingleL: Number of search results = %d"), searchResults.Count() );
+    PRINT1 ( _L("CPcsAlgorithm1Helper::SearchSingleL: Number of search results = %d"), aSearchResults.Count() );
 
     // Cleanup
     for ( TInt i = 0; i < iSearchResultsArr.Count(); i++ )
     {
         iSearchResultsArr[i]->Reset();
-        delete iSearchResultsArr[i];
-        iSearchResultsArr[i] = NULL;
     }
-    iSearchResultsArr.Reset();
+    iSearchResultsArr.ResetAndDestroy();
 
-    delete filterHelper;
+    CleanupStack::PopAndDestroy( filterHelper );
 
     __LATENCY_MARKEND ( _L("CPcsAlgorithm1Helper::SearchSingleL") );
 
@@ -203,10 +208,10 @@
 // Subset search function
 // ----------------------------------------------------------------------------
 void  CPcsAlgorithm1Helper::FilterResultsSingleL(CPcsAlgorithm1FilterHelper* aAlgorithmFilterHelper,
-                                                 RPointerArray<CPcsPoolElement>& searchSet,
+                                                 RPointerArray<CPcsPoolElement>& aSearchSet,
                                                  CPsQuery& aPsQuery,
                                                  TUint8 aFilteredDataMatch,
-                                                 TBool isSearchInGroup,
+                                                 TBool aIsSearchInGroup,
                                                  RArray<TInt>& aContactsInGroup)
 {
     PRINT ( _L("Enter CPcsAlgorithm1Helper::FilterResultsSingleL") );
@@ -223,22 +228,22 @@
              &queryAsDes );      
 
     // Parse thru each search set elements and filter the results
-    for ( TInt index = 0; index < searchSet.Count(); index++ )
+    for ( TInt index = 0; index < aSearchSet.Count(); index++ )
     {
-        CPcsPoolElement* poolElement = static_cast<CPcsPoolElement*>(searchSet[index]);
+        CPcsPoolElement* poolElement = static_cast<CPcsPoolElement*>(aSearchSet[index]);
         CPsData* psData = poolElement->GetPsData();
         psData->ClearDataMatches();
         RPointerArray<TDesC> tempMatchSeq;
+        CleanupResetAndDestroyPushL( tempMatchSeq );
         TBool isAdded = EFalse;
 
         // Parse thru each data and filter the results
         for ( TInt dataIndex = 0; dataIndex < psData->DataElementCount(); dataIndex++ )
         {
             // Filter off data fields not required in search
-            TReal bitIndex;
-            Math::Pow(bitIndex, 2, dataIndex);
+            TUint8 bitIndex = 1 << dataIndex;
 
-            TUint8 filter = (TUint8)bitIndex & aFilteredDataMatch;
+            TUint8 filter = bitIndex & aFilteredDataMatch;
             if ( filter == 0x0 )
             {
                 // Move to next data
@@ -247,7 +252,7 @@
 
             if ( poolElement->IsDataMatch(dataIndex) )
             {
-                TLex lex(psData->Data(dataIndex)->Des());
+                TLex lex( *psData->Data(dataIndex) );
 
                 // First word
                 TPtrC token = lex.NextToken();
@@ -274,11 +279,11 @@
                         if ( tempMatchSeq.Find(seq, rule) == KErrNotFound )
                         {
                             tempMatchSeq.Append(seq);
-                            CleanupStack::Pop();
+                            CleanupStack::Pop(seq);
                         }
                         else
                         {
-                            CleanupStack::PopAndDestroy();
+                            CleanupStack::PopAndDestroy(seq);
                         }
                     }
                     // Next word
@@ -290,7 +295,7 @@
         // Add the result
         if ( isAdded )
         {
-            if ( isSearchInGroup )
+            if ( aIsSearchInGroup )
             {
                 if ( aContactsInGroup.Find(psData->Id()) != KErrNotFound )
                 {
@@ -305,7 +310,7 @@
 
         // Cleanup the match sequence array as
         // they are stored in pattern details structure
-        tempMatchSeq.ResetAndDestroy();
+        CleanupStack::PopAndDestroy( &tempMatchSeq ); // ResetAndDestroy
     }
 
     __LATENCY_MARKEND ( _L("CPcsAlgorithm1Helper::FilterResultsSingleL") );
@@ -318,7 +323,7 @@
 // Funciton to search matching sequences in the input text
 // ----------------------------------------------------------------------------
 void  CPcsAlgorithm1Helper::SearchMatchSeqL(CPsQuery& aPsQuery,
-                                            TDesC& aData,
+                                            const TDesC& aData,
                                             RPointerArray<TDesC>& aMatchSet,
                                             RArray<TPsMatchLocation>& aMatchLocation )
 {
@@ -411,16 +416,14 @@
 {
     TUint8 filteredMatch = 0x0;
 
-    for ( int i = 0; i < aSupportedDataFields.Count(); i++ )
+    for ( TInt i = 0; i < aSupportedDataFields.Count(); i++ )
     {
-        for ( int j = 0; j < aRequiredDataFields.Count(); j++ )
+        for ( TInt j = 0; j < aRequiredDataFields.Count(); j++ )
         {
             if ( aSupportedDataFields[i] == aRequiredDataFields[j] )
             {
-                TReal val;
-                Math::Pow(val, 2, i);
-
-                filteredMatch |= (TUint8)val;
+                TUint8 val = 1 << i;
+                filteredMatch |= val;
             }
         }
     }
--- a/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1MultiSearchHelper.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1MultiSearchHelper.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -23,6 +23,16 @@
 #include <collate.h>
 #include <biditext.h>
 
+
+#ifdef _DEBUG
+_LIT( KPanicMultiSearchHelper, "CPcsAlgorithm1MultiSearchHelper" );
+static void Panic( TInt aReason )
+    {
+    User::Panic( KPanicMultiSearchHelper, aReason );
+    }
+#endif
+
+
 // ============================== MEMBER FUNCTIONS ============================
 
 // ----------------------------------------------------------------------------
@@ -96,10 +106,10 @@
 // ----------------------------------------------------------------------------
 void  CPcsAlgorithm1MultiSearchHelper::SearchMultiL(const CPsSettings& aSettings,
 	                                     RPointerArray<CPsQuery>& aPsQuery,
-	                                     TBool isSearchInGroup,
+	                                     TBool aIsSearchInGroup,
 	                                     RArray<TInt>& aContactsInGroup,
-	                                     RPointerArray<CPsData>& searchResults,
-	                                     RPointerArray<CPsPattern>& searchSeqs )
+	                                     RPointerArray<CPsData>& aSearchResults,
+	                                     RPointerArray<CPsPattern>& aSearchSeqs )
 {
     PRINT ( _L("Enter CPcsAlgorithm1MultiSearchHelper::SearchMultiL") );
 
@@ -110,50 +120,56 @@
     // Create CPcsAlgorithm1FilterHelper object to be used for filtering the results
 	TSortType sortType = aSettings.GetSortType();
     CPcsAlgorithm1FilterHelper* filterHelper = CPcsAlgorithm1FilterHelper::NewL(sortType);
+    CleanupStack::PushL( filterHelper );
     RPointerArray<CPcsPoolElement> elements;
+    CleanupClosePushL( elements );
     
-    iMultiSearchResultsArr.ResetAndDestroy();  
+    iMultiSearchResultsArr.ResetAndDestroy();
     
     // Get the data stores  
-    RPointerArray<TDesC> aDataStores;
-    aSettings.SearchUrisL(aDataStores);
+    RPointerArray<TDesC> dataStores;
+    CleanupResetAndDestroyPushL( dataStores );
+    aSettings.SearchUrisL(dataStores);
           
     // Get the required display fields from the client
     RArray<TInt> requiredDataFields;
+    CleanupClosePushL( requiredDataFields );
     aSettings.DisplayFieldsL(requiredDataFields);
 
-    // Search based on first character of 1st item in query list
-    TInt numValue = iKeyMap->PoolIdForCharacter(aPsQuery[0]->GetItemAtL(0).Character());
+    // Search from cache based on first character of 1st item in query list
+    const CPsQueryItem& firstCharItem = aPsQuery[0]->GetItemAtL(0);
+    TInt cachePoolId = iKeyMap->PoolIdForCharacter( firstCharItem.Character(), firstCharItem.Mode() );
 
     // Get the elements from all the databases
-    for ( int dsIndex = 0; 
-			dsIndex < aDataStores.Count(); 
+    for ( TInt dsIndex = 0; 
+			dsIndex < dataStores.Count(); 
 			dsIndex++ )
 	{
 	    RPointerArray<CPsData> *temp = new (ELeave) RPointerArray<CPsData> ();
 	    iMultiSearchResultsArr.Append(temp);
 	    
 	    // Get the contents for this data store
-	    TInt arrayIndex = iAlgorithm->GetCacheIndex(*(aDataStores[dsIndex]));					    
-		if ( arrayIndex < 0 ) continue;		
-		CPcsCache* cache = iAlgorithm->GetCache(arrayIndex);	    		   
-	    cache->GetContactsForKeyL(numValue,elements);
+	    TInt arrayIndex = iAlgorithm->GetCacheIndex(*(dataStores[dsIndex]));
+		if ( arrayIndex < 0 ) continue;
+		CPcsCache* cache = iAlgorithm->GetCache(arrayIndex);
+	    cache->GetContactsForKeyL(cachePoolId, elements);
 		
 	    // Get the supported data fields for this data store
         RArray<TInt> supportedDataFields;
+        CleanupClosePushL( supportedDataFields );
 		cache->GetDataFields(supportedDataFields);
 		
-		// Get the filtered data fields for this data store    		
+		// Get the filtered data fields for this data store
 		TUint8 filteredDataMatch = FilterDataFieldsL(requiredDataFields, 
 		                                             supportedDataFields);
 
 	    // Filter the results now
 	    FilterResultsMultiL(filterHelper,
-                            elements,
-                            aPsQuery,
-                            filteredDataMatch,
-                            isSearchInGroup,
-                            aContactsInGroup);	
+	    			   elements, 
+		               aPsQuery, 
+		               filteredDataMatch,
+		               aIsSearchInGroup,
+		               aContactsInGroup);
 	    
 		// If alphabetical sorting, get the results for this datastore               
 		if ( sortType == EAlphabetical )
@@ -162,28 +178,28 @@
 		}
 		
 	    elements.Reset();
-	    supportedDataFields.Reset();
+	    CleanupStack::PopAndDestroy( &supportedDataFields ); // Close
 	}
-	aDataStores.ResetAndDestroy();
-    requiredDataFields.Reset(); 
+    CleanupStack::PopAndDestroy( &requiredDataFields ); // Close
+    CleanupStack::PopAndDestroy( &dataStores );         // ResetAndDestroy
 	
 	// If alphabetical sorting, merge the result sets of all datastores
   	if ( sortType == EAlphabetical )
   	{
   		// Form the complete searchResults array
     	CPcsAlgorithm1Utils::FormCompleteSearchResultsL(iMultiSearchResultsArr,
-    											   	    searchResults);
+    											   	    aSearchResults);
   	}
   	else
   	{
   		// Results are already sorted patternbased
-  		filterHelper->GetResults(searchResults);
+  		filterHelper->GetResults(aSearchResults);
   	}
   
   	// Get the sorted match sequence list
-	filterHelper->GetPatternsL(searchSeqs);
+	filterHelper->GetPatternsL(aSearchSeqs);
 	
-	PRINT1 ( _L("CPcsAlgorithm1MultiSearchHelper::SearchMultiL: Number of search results = %d"), searchResults.Count() ); 
+	PRINT1 ( _L("CPcsAlgorithm1MultiSearchHelper::SearchMultiL: Number of search results = %d"), aSearchResults.Count() );
              
 	// Cleanup             
     for(TInt i = 0; i < iMultiSearchResultsArr.Count(); i++)
@@ -194,7 +210,8 @@
     }
     
     iMultiSearchResultsArr.Reset();
-    delete filterHelper;
+    CleanupStack::PopAndDestroy( &elements ); // Close
+    CleanupStack::PopAndDestroy( filterHelper );
    
     __LATENCY_MARKEND ( _L("CPcsAlgorithm1MultiSearchHelper::SearchMultiL") );
 
@@ -411,16 +428,14 @@
 {
     PRINT ( _L("Enter CPcsAlgorithm1MultiSearchHelper::ConvertQueryToListL") );
 
-    for ( int queryIndex = 0; queryIndex < aSearchQuery.Count(); queryIndex++ )
+    for ( TInt queryIndex = 0; queryIndex < aSearchQuery.Count(); queryIndex++ )
     {
         TBuf<KPsQueryMaxLen> dataWithKeys;
         iKeyMap->GetMixedKeyStringForQueryL( *aSearchQuery[queryIndex], dataWithKeys );
 
-        HBufC* dWKToAppend = HBufC::NewL(KPsQueryMaxLen);
-        TPtr tPtr(dWKToAppend->Des());
-        tPtr.Copy(dataWithKeys);
-
-        aQueryList.Append( dWKToAppend );
+        HBufC* dWKToAppend = dataWithKeys.AllocLC();
+        aQueryList.AppendL( dWKToAppend );
+        CleanupStack::Pop( dWKToAppend ); // ownership transfered
     }
 
     PRINT ( _L("End CPcsAlgorithm1MultiSearchHelper::ConvertQueryToListL") );
@@ -432,10 +447,10 @@
 // ----------------------------------------------------------------------------
 void  CPcsAlgorithm1MultiSearchHelper::FilterResultsMultiL(
         CPcsAlgorithm1FilterHelper* aAlgorithmFilterHelper,
-        RPointerArray<CPcsPoolElement>& searchSet,
-        RPointerArray<CPsQuery>& searchQuery,
+        RPointerArray<CPcsPoolElement>& aSearchSet,
+        RPointerArray<CPsQuery>& aSearchQuery,
         TUint8 aFilteredDataMatch,
-        TBool isSearchInGroup,
+        TBool aIsSearchInGroup,
         RArray<TInt>& aContactsInGroup)
 {
     PRINT ( _L("Enter CPcsAlgorithm1MultiSearchHelper::FilterResultsMultiL") );
@@ -443,9 +458,11 @@
     __LATENCY_MARK ( _L("CPcsAlgorithm1MultiSearchHelper::FilterResultsMultiL") );
 
     // Convert the individual queries to string form
-    RPointerArray<HBufC> queryList;    
-    RPointerArray<HBufC> tempqueryList;   
-    ConvertQueryToListL(searchQuery, queryList);
+    RPointerArray<HBufC> queryList;
+    CleanupResetAndDestroyPushL( queryList );
+    RPointerArray<HBufC> tempqueryList;
+    CleanupClosePushL( tempqueryList );
+    ConvertQueryToListL(aSearchQuery, queryList);
     
     // Remember a temporary copy of query list
     // since we sort the queries
@@ -459,17 +476,18 @@
 	queryList.Sort(rule);
 	
     // To hold the match results
-    RPointerArray<TDesC> tmpMatchSet;  
+    RPointerArray<TDesC> tmpMatchSet;
+    CleanupResetAndDestroyPushL( tmpMatchSet );
        
     // Parse thru each search set elements and filter the results    
-	for ( int index = 0; index < searchSet.Count(); index++ )
+	for ( TInt index = 0; index < aSearchSet.Count(); index++ )
 	{
-	    CPcsPoolElement* poolElement = static_cast<CPcsPoolElement*>(searchSet[index]);
+	    CPcsPoolElement* poolElement = static_cast<CPcsPoolElement*>(aSearchSet[index]);
 		CPsData* psData = poolElement->GetPsData();
 		psData->ClearDataMatches();
 		
 		TBool isMatch = ETrue;		
-		TUint8 wordMatches = 0;
+		TInt wordMatches = 0;
 		
 		// Reset iWordMatches to zero 
 		ClearWordMatches();
@@ -483,20 +501,22 @@
 		    // Get the original query mode corresponding to this query
 		    TInt modeIndex = tempqueryList.Find(tmpQuery);
 		    
-		    for ( TInt dataIndex = 0; dataIndex < psData->DataElementCount(); dataIndex++ )
+		    TInt dataCount = psData->DataElementCount();
+		    __ASSERT_DEBUG( dataCount < MAX_DATA_FIELDS, Panic(KErrOverflow) );
+		    
+		    for ( TInt dataIndex = 0; dataIndex < dataCount; dataIndex++ )
 		    {
 		        // Filter off data fields not required in search
-		        TReal bitIndex;
-		        Math::Pow(bitIndex, 2, dataIndex);
+                TUint8 bitIndex = 1 << dataIndex;
 
-                TUint8 filter = (TUint8)bitIndex & aFilteredDataMatch;     		         
+                TUint8 filter = bitIndex & aFilteredDataMatch;
 		        if ( filter == 0x0 )
 		        {
 		            // Move to next data
 		        	continue;
 		        }
 		       	
-		        TInt wordIndex = -1;			     
+		        TInt wordIndex = -1;
 			    
 			    TLex lex(psData->Data(dataIndex)->Des());
 			    
@@ -505,23 +525,23 @@
 			    
 			    // Search thru multiple words
 			    while ( tmpData.Length() != 0 ) 
-			    {			      
-			        wordIndex++;			         				  
+			    {
+			        wordIndex++;
 			     	
-			     	TBuf<KPsQueryMaxLen> data; 
+			     	TBuf<KPsQueryMaxLen> data;
 
 	                // Convert the data to required form (mode specific)
-	                iKeyMap->GetMixedKeyStringForDataL(*searchQuery[modeIndex], tmpData, data);
+	                iKeyMap->GetMixedKeyStringForDataL(*aSearchQuery[modeIndex], tmpData, data);
 
 				    // Compare the data against query
-                    if ( CPcsAlgorithm1Utils::MyCompareKeyAndString(data, *tmpQuery, *searchQuery[modeIndex]) )
+                    if ( CPcsAlgorithm1Utils::MyCompareKeyAndString(data, *tmpQuery, *aSearchQuery[modeIndex]) )
 				    {
-				        psData->SetDataMatch(dataIndex);				        			        
+				        psData->SetDataMatch(dataIndex);
 
 				        // Perform two checks.
 				        // 1. Ensure that the word is not matched against any previous query
 				        // 2. If it is the first match to the query
-				        TBool isWordMatch = IsWordMatch(dataIndex, wordIndex);				        
+				        TBool isWordMatch = IsWordMatch(dataIndex, wordIndex);
 
 				        // Check if the current word is not matched to any query
 		                if( !isWordMatch )
@@ -536,18 +556,18 @@
 
 					        // Extract matched character sequence and fill in temp array
 							TInt len = tmpQuery->Length();
-							HBufC* seq = HBufC::NewL(len);
-							*seq = tmpData.Mid(0, len);
+							HBufC* seq = tmpData.Left(len).AllocLC();
 							
 							seq->Des().UpperCase();
 							TIdentityRelation<TDesC> searchRule(CPcsAlgorithm1Utils::CompareExact);
 							if ( tmpMatchSet.Find(seq, searchRule) == KErrNotFound )
 							{
-                                tmpMatchSet.Append(seq);
+                                tmpMatchSet.AppendL(seq);
+                                CleanupStack::Pop(seq);
 							}
 							else
 							{ 
-                                delete seq;
+                                CleanupStack::PopAndDestroy(seq);
 								seq = NULL;
 							}
 						}
@@ -555,7 +575,7 @@
 				     
 				    // Next word
 				    tmpData.Set(lex.NextToken());
-			    }			     
+			    }
 		    }
 		    
 		    // No data element matches the query. Ignore this result.
@@ -568,9 +588,9 @@
 		
 		// If match add the element to the result set
 		//  And before adding to the result set, check if there is atleast one match per query
-		if (( isMatch ) && ( wordMatches >= queryList.Count()))
+		if ( isMatch && wordMatches >= queryList.Count() )
 		{
-			if ( isSearchInGroup )
+			if ( aIsSearchInGroup )
 			{
 				if ( aContactsInGroup.Find(psData->Id()) != KErrNotFound )
 				{
@@ -585,12 +605,13 @@
 	    
 	    // Cleanup the match sequence array as 
 		// they are stored in pattern details structure
-		tmpMatchSet.ResetAndDestroy();       
+		tmpMatchSet.ResetAndDestroy();
 	}
 	
 	// Free the query list
-	queryList.ResetAndDestroy();
-	tempqueryList.Reset();
+	CleanupStack::PopAndDestroy( &tmpMatchSet );   // ResetAndDestroy
+    CleanupStack::PopAndDestroy( &tempqueryList ); // Close
+	CleanupStack::PopAndDestroy( &queryList );     // ResetAndDestroy
 
 	__LATENCY_MARKEND ( _L("CPcsAlgorithm1MultiSearchHelper::FilterResultsMultiL") );
 
@@ -600,12 +621,10 @@
 // ----------------------------------------------------------------------------
 // CPcsAlgorithm1MultiSearchHelper::SetWordMap()
 // ----------------------------------------------------------------------------
-void CPcsAlgorithm1MultiSearchHelper::SetWordMap( TInt aIndex, TInt aPosition)
+void CPcsAlgorithm1MultiSearchHelper::SetWordMap(TInt aIndex, TInt aPosition)
 {
-    TReal val;
-	Math::Pow(val, 2, aPosition);
-
-	iWordMatches[aIndex] |= (TUint8)val;
+    TUint8 val = 1 << aPosition;
+    iWordMatches[aIndex] |= val;
 }
 
 // ----------------------------------------------------------------------------
@@ -613,10 +632,8 @@
 // ----------------------------------------------------------------------------
 TBool CPcsAlgorithm1MultiSearchHelper::IsWordMatch(TInt aDataIndex, TInt aWordIndex)
 {
-    TReal val;
-	Math::Pow(val, 2, aWordIndex);
-
-	return(iWordMatches[aDataIndex] & (TUint8)val);
+    TUint8 val = 1 << aWordIndex;
+    return (iWordMatches[aDataIndex] & val);
 }
 
 // ----------------------------------------------------------------------------
@@ -638,20 +655,20 @@
 TInt CPcsAlgorithm1MultiSearchHelper::CountMultiQueryWordsL(CPsQuery& aQuery)
 {    
     TInt wordCount = 0;
-    TBool newWord = true;
+    TBool newWord = ETrue;
 
     for (TInt i = 0; i < aQuery.Count(); i++ )
     {
         if ( aQuery.GetItemAtL(i).Character().IsSpace() )
         {
-            newWord = true;
+            newWord = ETrue;
         }
         else
         {
             if ( newWord )
             {
                 wordCount++;
-                newWord = false;
+                newWord = EFalse;
             }
         }
     }
@@ -677,12 +694,12 @@
 	
     for (TInt beg = 0; beg < textLength; beg++)
     {
-        // Skip separators before next word	                
+        // Skip separators before next word
         if ( !aQuery.GetItemAtL(beg).Character().IsSpace() )
         {
             // Scan the end of the word
             TInt end = beg+1;
-            while (end < textLength &&                  
+            while (end < textLength &&
                    !aQuery.GetItemAtL(end).Character().IsSpace())
             {
                 end++;
@@ -695,7 +712,7 @@
                 CPsQueryItem* item = CPsQueryItem::NewL();
                 item->SetCharacter(aQuery.GetItemAtL(i).Character());
                 item->SetMode(aQuery.GetItemAtL(i).Mode());
-            	newQuery->AppendL(*item);
+                newQuery->AppendL(*item);
             }
             query.Append(newQuery);
             
@@ -719,16 +736,14 @@
 {
     TUint8 filteredMatch = 0x0;
     
-	for ( int i = 0; i < aSupportedDataFields.Count(); i++ )
+	for ( TInt i = 0; i < aSupportedDataFields.Count(); i++ )
 	{
-		for ( int j = 0; j < aRequiredDataFields.Count(); j++ )
+		for ( TInt j = 0; j < aRequiredDataFields.Count(); j++ )
 		{
 			if ( aSupportedDataFields[i] == aRequiredDataFields[j] )
 			{
-				TReal val;
-			    Math::Pow(val, 2, i);
-			    
-			    filteredMatch |= (TUint8)val;	
+                TUint8 val = 1 << i;
+			    filteredMatch |= val;
 			}
 		}
 	}
--- a/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1Utils.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1Utils.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -21,6 +21,7 @@
 #include "CPsData.h"
 #include "CPcsDefs.h"
 #include "CPcsCache.h"
+#include "CPsQuery.h"
 #include "CPsQueryItem.h"
 
 #include <collate.h>
@@ -38,7 +39,7 @@
 // Merges all the respective data store result sets to single set in sorted order.
 // ----------------------------------------------------------------------------
 void CPcsAlgorithm1Utils::FormCompleteSearchResultsL(RPointerArray<CPSDATA_R_PTR_ARRAY>& aSearchResultsArr, 
-												     RPointerArray<CPsData>& SearchResults)
+												     RPointerArray<CPsData>& aSearchResults)
 {
 	TInt maxIndex = 0;
     TInt maxValue = aSearchResultsArr[maxIndex]->Count();
@@ -57,7 +58,7 @@
     // Assign the largets array to searchresults 
     for(TInt i = 0; i < aSearchResultsArr[maxIndex]->Count(); i++)
     {
-    	SearchResults.Append((*(aSearchResultsArr[maxIndex]))[i]);
+    	aSearchResults.Append((*(aSearchResultsArr[maxIndex]))[i]);
     }
     
     // Merge the remaining result arrays to the largest array in sequential order
@@ -69,7 +70,7 @@
     		TInt numElements = (aSearchResultsArr[i])->Count();
     		for( TInt j = 0; j < numElements; j++)
     		{
-    			SearchResults.InsertInOrderAllowRepeatsL((*(aSearchResultsArr[i]))[j], rule);
+    			aSearchResults.InsertInOrderAllowRepeatsL((*(aSearchResultsArr[i]))[j], rule);
     		}
     	}
     }
@@ -79,9 +80,9 @@
 // CPcsAlgorithm1Utils::CompareByLength()
 // Compare by length.
 // ----------------------------------------------------------------------------
-TBool CPcsAlgorithm1Utils::CompareByLength ( const HBufC& aFirst, const HBufC& aSecond )
+TInt CPcsAlgorithm1Utils::CompareByLength ( const HBufC& aFirst, const HBufC& aSecond )
 {
-   return ( aFirst.Length() > aSecond.Length() );
+    return ( aFirst.Length() - aSecond.Length() );
 }
 
 // ----------------------------------------------------------------------------
@@ -97,7 +98,7 @@
 // CPcsAlgorithm1Utils::CompareCollate()
 // Compare strings with collate rules depending on locale.
 // ----------------------------------------------------------------------------
-TBool CPcsAlgorithm1Utils::CompareCollate ( const TDesC& aFirst, const TDesC& aSecond )
+TInt CPcsAlgorithm1Utils::CompareCollate ( const TDesC& aFirst, const TDesC& aSecond )
 {
     return CPcsAlgorithm1Utils::MyCompareC(aFirst, aSecond);
 }
@@ -144,7 +145,8 @@
         for ( TInt i = 0; i < aPsQuery.Count(); i++ )
             {
             CPsQueryItem& currentItem = aPsQuery.GetItemAtL(i);
-            if ( (currentItem.Mode() == EItut) && (aLeft[i] != aRight[i]) )
+            if ( (CPcsKeyMap::IsModePredictive(currentItem.Mode()))
+                 && (aLeft[i] != aRight[i]) )
                 {
                 comparison = EFalse;
                 break;
@@ -273,23 +275,23 @@
         }
     }
     
-    aString.TrimAll();        
+    aString.TrimAll();
 }
 
 // ----------------------------------------------------------------------------
 // CPcsAlgorithm1Utils::IsGroupUri()
 // Check if the input URI is of contact search in a group template form
-// ----------------------------------------------------------------------------                         
+// ----------------------------------------------------------------------------
 TBool CPcsAlgorithm1Utils::IsGroupUri(TDesC& aURI)
 {
-	TBuf<255> uri(aURI);
+    TBuf<255> uri(aURI);
     uri.LowerCase();
     
     TInt index = uri.FindF(KGroupIdUri);
     
     if ( index == KErrNotFound )
     {
-	    return EFalse;
+        return EFalse;
     }
     
     return ETrue;
--- a/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsCache.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsCache.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -37,7 +37,7 @@
 // CPcsCache::NewL
 // Two Phase Construction
 // ----------------------------------------------------------------------------
-CPcsCache* CPcsCache::NewL(TDesC& aURI, CPcsKeyMap& aKeyMap, TUint8 aUriId)
+CPcsCache* CPcsCache::NewL(const TDesC& aURI, CPcsKeyMap& aKeyMap, TUint8 aUriId)
 {
     PRINT ( _L("Enter CPcsCache::NewL") );
     
@@ -68,7 +68,7 @@
 // CPcsCache::ConstructL
 // 2nd Phase Constructor
 // ----------------------------------------------------------------------------
-void CPcsCache::ConstructL(TDesC& aURI, CPcsKeyMap& aKeyMap, TUint8 aUriId)
+void CPcsCache::ConstructL(const TDesC& aURI, CPcsKeyMap& aKeyMap, TUint8 aUriId)
 {
     PRINT ( _L("Enter CPcsCache::ConstructL") );
     
@@ -77,13 +77,13 @@
     //Update the caching status for this cache
     iCacheStatus = ECachingNotStarted;
     
-    keyMap = &aKeyMap;        
+    iKeyMap = &aKeyMap;        
 
-    // Populate keyArr
+    // Populate iKeyArr
     for(TInt i= 0; i <aKeyMap.PoolCount();i++ )
         {
         RPointerArray<CPcsPoolElement> *keyMap = new (ELeave) RPointerArray<CPcsPoolElement>(1);
-        keyArr.InsertL(keyMap,i);
+        iKeyArr.InsertL(keyMap,i);
         }
    
     
@@ -98,90 +98,17 @@
 {
     PRINT ( _L("Enter CPcsCache::~CPcsCache") );
 
-    if ( iURI )
-       delete iURI;
-    
-    // Loop thru cache info and free and the data elements
-    THashMapIter<TInt, TInt> iter(cacheInfo);
-    
-    do
-    {
-    	TInt* id = const_cast<TInt*>(iter.NextKey());
-    	
-    	if ( id == NULL )
-    	     break;
-            
-	    TInt* poolMap = iter.CurrentValue();            
-	    
-	    if ( poolMap == NULL )        
-	    {
-	    	continue;
-	    }
-
-        CPsData *data = NULL;	    	
-	    for ( int keyIndex = 0; keyIndex < keyArr.Count(); keyIndex++ )
-	    {
-	        TBool present = GetPoolMap(*poolMap, keyIndex); 
-	        
-	        if ( ! present )
-	        {
-	        	continue;
-	        }
+    delete iURI;
 
-	        RPointerArray<CPcsPoolElement> tmpKeyMap = *(keyArr[keyIndex]);
-	        for ( int arrayIndex = 0; 
-	              arrayIndex < tmpKeyMap.Count();
-	              arrayIndex++ )
-	        {
-			    CPcsPoolElement *element = tmpKeyMap[arrayIndex];
-			    TInt localId = element->GetPsData()->Id();
-			    if ( *id == localId )
-			    {
-			        data = element->GetPsData();
-			    	delete element;
-			    	keyArr[keyIndex]->Remove(arrayIndex);  
-			    }  
-	        }      	
-	    };   
-	    
-	    // Remove this element from master pool
-	    for ( int arrayIndex = 0; 
-	              arrayIndex < masterPool.Count();
-	              arrayIndex++ )
-	    {
-		    CPsData *dataElement = masterPool[arrayIndex];
-		    TInt localId = dataElement->Id();
-		    if ( *id == localId )
-		    {
-		    	masterPool.Remove(arrayIndex);  
-		    }  
-	    }   
-	    
-	    if( data )
-	    {
-	    	delete data;
-	    }
-     
-    }
-    while (1);
-
-    for(TInt i= 0; i <keyArr.Count();i++ )
-            {
-             keyArr[i]->ResetAndDestroy();
-             delete keyArr[i];
-             keyArr[i] = NULL;
-            }
-    
-	masterPool.ResetAndDestroy();
-	
-	cacheInfo.Close();
-
-    keyArr.Reset();
+    RemoveAllFromCache(); // cleans up iMasterPool and iCacheInfo
+   
+    iKeyArr.ResetAndDestroy();
     iDataFields.Reset();
     iSortOrder.Reset();
     iIndexOrder.Reset();
-	
-	PRINT ( _L("End CPcsCache::~CPcsCache") );
+    iMasterPoolBackup.Close();
+
+    PRINT ( _L("End CPcsCache::~CPcsCache") );
 }
  
 // ----------------------------------------------------------------------------
@@ -192,8 +119,8 @@
 {
     PRINT ( _L("Enter CPcsCache::GetContactsForKeyL") );
         	
-	RPointerArray<CPcsPoolElement> arr = *keyArr[aKeyId];
-	for ( int i = 0; i < arr.Count(); i++ )
+	const RPointerArray<CPcsPoolElement>& arr = *iKeyArr[aKeyId];
+	for ( TInt i = 0; i < arr.Count(); i++ )
 	{
 		CPcsPoolElement* value = arr[i];
         aData.AppendL(value);
@@ -210,9 +137,9 @@
 {
     PRINT ( _L("Enter CPcsCache::GetAllContentsL") );
         	
-	for ( int i = 0; i < masterPool.Count(); i++ )
+	for ( TInt i = 0; i < iMasterPool.Count(); i++ )
 	{
-		CPsData* value = masterPool[i];
+		CPsData* value = iMasterPool[i];
         aData.AppendL(value);
 	}
     
@@ -224,86 +151,101 @@
 // CPcsCache::AddToPool
 // Adds a contact to cache
 // ----------------------------------------------------------------------------
-void CPcsCache::AddToPoolL(TInt& aPoolMap, CPsData& aData)
+void CPcsCache::AddToPoolL(TUint64& aPoolMap, CPsData& aData)
 {	
      // Temp hash to remember the location of pool elements
      // First TInt  = Pool 
      // Second TInt = Location in the pool
      // Required for memory optimization so that more than one pool
      // element doesn't get added for the same data
-     RHashMap<TInt, TInt> elementHash;     
+     RHashMap<TInt, TInt> elementHash;
+     CleanupClosePushL( elementHash );
      TLinearOrder<CPcsPoolElement> rule( CPcsPoolElement::CompareByData );
               
-     // Parse thru each data element    
-     for ( int dataIndex = 0; dataIndex < aData.DataElementCount(); dataIndex++ )
+     // Parse thru each data element
+     for ( TInt dataIndex = 0; dataIndex < aData.DataElementCount(); dataIndex++ )
      {     	
-     	// Stores first key for each word
-		RArray<TUint> firstKey;
+     	// Find store all the pool IDs where this contact should be
+		RArray<TUint> poolIds;
+		CleanupClosePushL( poolIds );
 		
 		// Recover the first character
 		if ( aData.Data(dataIndex) && aData.Data(dataIndex)->Length() != 0 )
 		{
-		    // Split the data into words	
+		    // Split the data into words
 		    CWords* words = CWords::NewLC(*aData.Data(dataIndex));
   
 		    // Store the first numeric key for each word
-		    for ( int i = 0; i < words->MdcaCount(); i++ )
+		    for ( TInt i = 0; i < words->MdcaCount(); i++ )
 		    {
 		    	TChar firstChar = (words->MdcaPoint(i))[0];
-		    	firstKey.Append(firstChar);
+		    	
+		    	// Pool ID according to ITU-T mappings
+		    	TInt itutPoolId = iKeyMap->PoolIdForCharacter(firstChar, EPredictiveItuT);
+		    	if ( itutPoolId != KErrNotFound )
+		    	    {
+                    poolIds.Append(itutPoolId);
+		    	    }
+		    	
+		    	// Pool ID according to QWERTY mappings
+                TInt qwertyPoolId = iKeyMap->PoolIdForCharacter(firstChar, EPredictiveQwerty);
+                if ( qwertyPoolId != KErrNotFound )
+                    {
+                    poolIds.Append(qwertyPoolId);
+                    }
 		    }
 		    
 		    CleanupStack::PopAndDestroy(words); 
 		}
 		
-		for ( TInt wordIndex = 0; wordIndex < firstKey.Count(); wordIndex++ )
-		{		
-		    TInt arrayIndex =keyMap->PoolIdForCharacter(firstKey[wordIndex]);
-					
+		for ( TInt poolIdIndex = 0; poolIdIndex < poolIds.Count(); poolIdIndex++ )
+		{
+            TUint poolId = poolIds[ poolIdIndex ];
 		    CPcsPoolElement* element = NULL;
 		    
 		    // Check if an element already exists in the pool for this data
 		    TInt* loc = NULL;
-		    loc = elementHash.Find(arrayIndex);
+		    loc = elementHash.Find(poolId);
 		    if ( loc != NULL )
 		    {
 		        // Exists. Then recover ...
-		        RPointerArray<CPcsPoolElement> tmpKeyMap = *(keyArr[arrayIndex]);
+		        const RPointerArray<CPcsPoolElement>& tmpKeyMap = *(iKeyArr[poolId]);
 		    	element = tmpKeyMap[*loc];
 		    }
 		
 			if ( element == NULL ) // Pool element doesn't exist. Create new ...
 			{
 		        element = CPcsPoolElement::NewL(aData);
+		        CleanupStack::PushL( element );
 		    	element->ClearDataMatchAttribute();
 				element->SetDataMatch(dataIndex);
 				
 				// Insert to pool
-				keyArr[arrayIndex]->InsertInOrderAllowRepeatsL(element, rule);
-				TInt index = keyArr[arrayIndex]->FindInOrderL(element, rule);
+				iKeyArr[poolId]->InsertInOrderAllowRepeatsL(element, rule);
+				CleanupStack::Pop( element ); // ownership transferred
+				TInt index = iKeyArr[poolId]->FindInOrderL(element, rule);
 				
-				// Set the bit for this pool					
-				SetPoolMap(aPoolMap, arrayIndex);												
+				// Set the bit for this pool
+				SetPoolMap(aPoolMap, poolId);
 				
 				// Store the array index in the temp hash
-				elementHash.InsertL(arrayIndex, index  );				
-	        }		        
+				elementHash.InsertL(poolId, index);
+	        }
 	        else // Pool element exists. Just alter the data match attribute
 	        {
 	        	element->SetDataMatch(dataIndex);
 	        	
-	            // Set the bit for this pool					
-				SetPoolMap(aPoolMap, arrayIndex);	
+	            // Set the bit for this pool
+				SetPoolMap(aPoolMap, poolId);
 	        }
-
 			
 		} // for 2 loop
 		
-		firstKey.Reset();
+		CleanupStack::PopAndDestroy( &poolIds );
 		
      } // for 1 loop
      
-     elementHash.Close();
+     CleanupStack::PopAndDestroy( &elementHash );
 }
 
 // ---------------------------------------------------------------------
@@ -313,19 +255,19 @@
 void CPcsCache::AddToCacheL( CPsData& aData )
 {
     // Protect against duplicate items getting added
-    if ( cacheInfo.Find(aData.Id()) != NULL )
+    if ( iCacheInfo.Find(aData.Id()) != NULL )
     {
-    	return;
-    }   
+        return;
+    }
     
-    // Include this element in the pool     
-    TInt poolMap = 0;
-	AddToPoolL(poolMap, aData);	
-    cacheInfo.InsertL(aData.Id(), poolMap); 
-    
-    // Include this element in master pool        
+    // Include this element in the pool
+    TUint64 poolMap = 0;
+    AddToPoolL(poolMap, aData);
+    iCacheInfo.InsertL(aData.Id(), poolMap);
+
+    // Include this element in master pool
     TLinearOrder<CPsData> rule( CPcsAlgorithm1Utils::CompareDataBySortOrderL );
-    masterPool.InsertInOrderAllowRepeatsL(&aData, rule);   
+    iMasterPool.InsertInOrderAllowRepeatsL(&aData, rule);
 }
 
 // ---------------------------------------------------------------------
@@ -336,15 +278,15 @@
 {
     CPsData *data = NULL;
             
-    TInt* poolMap = cacheInfo.Find(aItemId);            
+    TUint64* poolMap = iCacheInfo.Find(aItemId);
     
-    if ( poolMap == NULL )        
+    if ( poolMap == NULL )
     {
     	return;
     }
     
     // Remove this element from pools
-    for ( int keyIndex = 0; keyIndex < keyArr.Count(); keyIndex++ )
+    for ( TInt keyIndex = 0; keyIndex < iKeyArr.Count(); keyIndex++ )
     {
         TBool present = GetPoolMap(*poolMap, keyIndex); 
         
@@ -353,8 +295,8 @@
         	continue;
         }
 
-        RPointerArray<CPcsPoolElement> tmpKeyMap = *(keyArr[keyIndex]);
-        for ( int arrayIndex = 0; 
+        const RPointerArray<CPcsPoolElement>& tmpKeyMap = *(iKeyArr[keyIndex]);
+        for ( TInt arrayIndex = 0; 
               arrayIndex < tmpKeyMap.Count();
               arrayIndex++ )
         {
@@ -364,21 +306,21 @@
 		    {
 		        data = element->GetPsData();
 		    	delete element;
-		    	keyArr[keyIndex]->Remove(arrayIndex);  
+		    	iKeyArr[keyIndex]->Remove(arrayIndex);  
 		    }  
         }      	
     };   
     
     // Remove this element from master pool
-    for ( int arrayIndex = 0; 
-              arrayIndex < masterPool.Count();
+    for ( TInt arrayIndex = 0; 
+              arrayIndex < iMasterPool.Count();
               arrayIndex++ )
     {
-	    CPsData *dataElement = masterPool[arrayIndex];
+	    CPsData *dataElement = iMasterPool[arrayIndex];
 	    TInt id = dataElement->Id();
 	    if ( id == aItemId )
 	    {
-	    	masterPool.Remove(arrayIndex);  
+	    	iMasterPool.Remove(arrayIndex);  
 	    }  
     }      	
      
@@ -390,52 +332,48 @@
     }
 
     // Clear up cache information
-    cacheInfo.Remove(aItemId);    
+    iCacheInfo.Remove(aItemId);    
 }
 
 // ---------------------------------------------------------------------
-// CPcsCache::RemoveAllFromCacheL
+// CPcsCache::RemoveAllFromCache
 // 
 // ---------------------------------------------------------------------
-void CPcsCache::RemoveAllFromCacheL()
+void CPcsCache::RemoveAllFromCache()
 {
-    PRINT ( _L("Enter CPcsCache::RemoveAllFromCacheL") );
+    PRINT ( _L("Enter CPcsCache::RemoveAllFromCache") );
     
+    for ( TInt i = 0 ; i < iKeyArr.Count() ; i++ )
+        {
+        iKeyArr[i]->ResetAndDestroy();
+        }
 	
-    for(TInt i= 0; i <keyArr.Count();i++ )
-            {
-            keyArr[i]->ResetAndDestroy();
-            
-            }
+	iMasterPool.ResetAndDestroy();
+	iCacheInfo.Close();
 	
-	masterPool.ResetAndDestroy();
-	cacheInfo.Close();
-	
-	PRINT ( _L("End CPcsCache::RemoveAllFromCacheL") );
+	PRINT ( _L("End CPcsCache::RemoveAllFromCache") );
 }
 
 // ---------------------------------------------------------------------
 // CPcsCache::SetPoolMap
 // 
 // ---------------------------------------------------------------------
-void CPcsCache::SetPoolMap(TInt& aPoolMap, TInt arrayIndex)
+void CPcsCache::SetPoolMap(TUint64& aPoolMap, TInt aArrayIndex)
 {
-	TReal val;
-	Math::Pow(val, 2, arrayIndex);
-
-	aPoolMap |= (TInt)val;	
+    __ASSERT_DEBUG( aArrayIndex < 64, User::Panic(_L("CPcsCache"), KErrOverflow ) );
+    TUint64 val = 1 << aArrayIndex;
+    aPoolMap |= val;
 }
 
 // ---------------------------------------------------------------------
 // CPcsCache::GetPoolMap
 // 
 // ---------------------------------------------------------------------
-TBool CPcsCache::GetPoolMap(TInt& aPoolMap, TInt arrayIndex)
+TBool CPcsCache::GetPoolMap(TUint64& aPoolMap, TInt aArrayIndex)
 {
-	TReal val;
-	Math::Pow(val, 2, arrayIndex);
-
-	return (aPoolMap & (TInt)val);
+    __ASSERT_DEBUG( aArrayIndex < 64, User::Panic(_L("CPcsCache"), KErrOverflow ) );
+    TUint64 val = 1 << aArrayIndex;
+    return (aPoolMap & val);
 }
 
 // ---------------------------------------------------------------------
@@ -564,9 +502,9 @@
 {   
     iIndexOrder.Reset();
     
-	for ( int i = 0; i < iSortOrder.Count(); i++ )
+	for ( TInt i = 0; i < iSortOrder.Count(); i++ )
 	{
-		for ( int j = 0; j < iDataFields.Count(); j++ )
+		for ( TInt j = 0; j < iDataFields.Count(); j++ )
 		{
 			if ( iSortOrder[i] == iDataFields[j] )
 			{
@@ -583,24 +521,24 @@
 // ---------------------------------------------------------------------
 void CPcsCache::ResortdataInPoolsL()
     {
-    // copy masterPool data into masterPoolBackup
-    for (TInt i = 0; i < masterPool.Count(); i++ )
+    // copy iMasterPool data into iMasterPoolBackup
+    for (TInt i = 0; i < iMasterPool.Count(); i++ )
         {
-        masterPoolBackup.Append( masterPool[i] );
+        iMasterPoolBackup.Append( iMasterPool[i] );
         }
     //Now reset the key array
-    for (TInt i = 0; i < keyArr.Count(); i++ )
+    for (TInt i = 0; i < iKeyArr.Count(); i++ )
         {
-        keyArr[i]->ResetAndDestroy();
+        iKeyArr[i]->ResetAndDestroy();
         }
-    masterPool.Reset();
-    cacheInfo.Close();
-    //now add data again from the masterPoolBackup
-    for (TInt i = 0; i < masterPoolBackup.Count(); i++ )
+    iMasterPool.Reset();
+    iCacheInfo.Close();
+    //now add data again from the iMasterPoolBackup
+    for (TInt i = 0; i < iMasterPoolBackup.Count(); i++ )
         {
-        CPsData* temp = static_cast<CPsData*>(masterPoolBackup[i]);
+        CPsData* temp = iMasterPoolBackup[i];
         AddToCacheL( *temp );
         }
-    masterPoolBackup.Reset();
+    iMasterPoolBackup.Reset();
     } 
 // End of file
--- a/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsKeyMap.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsKeyMap.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -21,8 +21,7 @@
 #include "CPcsKeyMap.h"
 #include <CPcsDefs.h>
 #include <bldvariant.hrh>
-#include <PtiDefs.h>
-#include <PtiKeyMappings.h>
+#include <PtiEngine.h>
 #include <PtiKeyMapData.h>
 #include <AknFepInternalCRKeys.h>
 #include <AvkonInternalCRKeys.h>
@@ -40,6 +39,8 @@
         EPanicPreCond_MultipleUIPriorityMatching = 2,
         EPanicPreCond_MultipleEnglishPriorityMatching = 3,
         EPanicPreCond_MultipleOthersPriorityMatching = 4,
+        EPanic_OverflowInPoolIndex = 5,
+        EPanic_InvalidKeyboardType = 6
    };
 
     void Panic(TInt aReason)
@@ -95,52 +96,13 @@
     iLanguageNotSupported.Append(ELangPrcChinese);
     iLanguageNotSupported.Append(ELangHongKongChinese);
     iLanguageNotSupported.Append(ELangTaiwanChinese);
-
-#ifdef RD_INTELLIGENT_TEXT_INPUT
-
-    TInt physicalKeyboard = 0;
-    CRepository* aknFepRepository = CRepository::NewL( KCRUidAknFep );
-    aknFepRepository->Get( KAknFepPhysicalKeyboards, physicalKeyboard );
-    delete aknFepRepository;
-
-    PRINT1 ( _L("CPcsKeyMap::ConstructL: Physical keyboard support flag = 0x%02X"), physicalKeyboard );
-
-    // Constants follow the definition of KAknFepPhysicalKeyboards
-    const TInt ptiKeyboard12Key = 0x01;
-    //const TInt ptiKeyboardQwerty4x12 = 0x02;    // Not used at the moment
-    const TInt ptiKeyboardQwerty4x10 = 0x04;
-    const TInt ptiKeyboardQwerty3x11 = 0x08;
-    const TInt ptiKeyboardHalfQwerty = 0x10;
-    //const TInt ptiKeyboardCustomQwerty = 0x20;  // Not used at the moment
+    iLanguageNotSupported.Append(ELangKorean);
 
-    // The following if contains the order of precedence given for keyboards
-    // i.e. one phone has both "ITUT 12 Key" and "Qwerty 4x10" physical keyboards
-    if ( physicalKeyboard & ptiKeyboard12Key )
-        {
-        iKeyboardType = EPtiKeyboard12Key;
-        }
-    else if ( physicalKeyboard & ptiKeyboardHalfQwerty )
-        {
-        iKeyboardType = EPtiKeyboardHalfQwerty;
-        }
-    else if ( physicalKeyboard & ptiKeyboardQwerty4x10 )
-        {
-        iKeyboardType = EPtiKeyboardQwerty4x10;
-        }
-    else if ( physicalKeyboard & ptiKeyboardQwerty3x11 )
-        {
-        iKeyboardType = EPtiKeyboardQwerty3x11;
-        }
-    else
-#endif // RD_INTELLIGENT_TEXT_INPUT
-        {
-        iKeyboardType = EPtiKeyboard12Key; // default
-        }
-
-    PRINT1 ( _L("CPcsKeyMap::ConstructL: Keyboard chosen for Predictive Search = %d"), iKeyboardType );
+    SetupKeyboardTypesL();
 
     // Create structure for holding characters<-->key mappings
-    CreateKeyMappingL();
+    CreateKeyMappingL( EPredictiveItuT );
+    CreateKeyMappingL( EPredictiveQwerty );
 
     // Sets attribute for holding info if "0" and " " are on the same key
     // Needed for decision if the "0" should be considered as a possible separator
@@ -162,40 +124,83 @@
     // Cleanup local arrays
     iLanguageNotSupported.Reset();
 
-    for (TInt i = 0; i < PoolCount(); i++)
+    for (TInt i = 0; i < iItutKeyMaps.Count(); i++)
+        {
+        for (TInt j = 0; j < TKeyMappingData::EKeyMapNumberArr; j++)
+            {
+            iItutKeyMaps[i]->iKeyMapCharArr[j].Close();
+            }
+        }
+    iItutKeyMaps.ResetAndDestroy();
+    
+    for (TInt i = 0; i < iQwertyKeyMaps.Count(); i++)
         {
         for (TInt j = 0; j < TKeyMappingData::EKeyMapNumberArr; j++)
             {
-            iKeyMapPtrArr[i]->iKeyMapCharArr[j].Close();
+            iQwertyKeyMaps[i]->iKeyMapCharArr[j].Close();
             }
         }
-    iKeyMapPtrArr.ResetAndDestroy();
-    iKeysArr.Close();
+    iQwertyKeyMaps.ResetAndDestroy();
+    
+    iItutKeys.Close();
+    iQwertyKeys.Close();
 
     PRINT ( _L("End CPcsKeyMap::~CPcsKeyMap") );
     }
 
 // ----------------------------------------------------------------------------
+// CPcsKeyMap::IsModePredictive
+// 
+// ----------------------------------------------------------------------------
+TBool CPcsKeyMap::IsModePredictive( TKeyboardModes aKbMode )
+    {
+    return ( (EPredictiveDefaultKeyboard == aKbMode) ||
+             (EPredictiveItuT == aKbMode) ||
+             (EPredictiveQwerty == aKbMode) );
+    }
+
+// ----------------------------------------------------------------------------
+// CPcsKeyMap::ResolveKeyboardMode
+// Resolve EPredictiveDefaultKeyboard or ENonPredictive mode to EPredictiveItuT
+// or EPredictiveQwerty mode
+// ----------------------------------------------------------------------------
+TKeyboardModes CPcsKeyMap::ResolveKeyboardMode( TKeyboardModes aKbMode,
+                                                TKeyboardModes aKbModeToResolve ) const
+    {    
+    // Substitute "default predictive" mode with actual mode
+    if ( (aKbMode == aKbModeToResolve) &&
+         ((aKbMode == ENonPredictive) || (aKbMode == EPredictiveDefaultKeyboard)) )
+        {
+        return iPredictiveDefaultKeyboardMode;
+        }
+    else
+        {
+        return aKbMode;
+        }
+    }
+
+// ----------------------------------------------------------------------------
 // CPcsKeyMap::GetMixedKeyStringForQueryL
 // aDestStr will have the length as the number of items in aSrcQuery.
 // ----------------------------------------------------------------------------
-void CPcsKeyMap::GetMixedKeyStringForQueryL(CPsQuery& aSrcQuery, TDes& aDestStr)
-{
+void CPcsKeyMap::GetMixedKeyStringForQueryL(
+        CPsQuery& aSrcQuery, TDes& aDestStr) const
+    {
     PRINT ( _L("Enter CPcsKeyMap::GetMixedKeyStringForQueryL") ); 
 
     GetMixedKeyStringForDataL( aSrcQuery, aSrcQuery.QueryAsStringLC(), aDestStr );
     CleanupStack::PopAndDestroy(); //result of QueryAsStringLC
 
     PRINT ( _L("End CPcsKeyMap::GetMixedKeyStringForQueryL") );
-}
+    }
 
 // ----------------------------------------------------------------------------
 // CPcsKeyMap::GetMixedKeyStringForDataL
 // aDestStr will have the same length as aSrcData. aSrcQuery can be shorter.
 // ----------------------------------------------------------------------------
 void CPcsKeyMap::GetMixedKeyStringForDataL(
-        CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr)
-{
+        CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr) const
+    {
     PRINT ( _L("Enter CPcsKeyMap::GetMixedKeyStringForDataL") );
 
     for ( TInt i = 0; i < aSrcData.Length(); ++i )
@@ -205,32 +210,19 @@
         if ( i < aSrcQuery.Count() )
             {
             CPsQueryItem& currentItem = aSrcQuery.GetItemAtL(i);
-            switch ( currentItem.Mode() )
+            TPtiKey key = KeyForCharacterMultiMatch( aSrcData[i], currentItem.Mode() );
+            // If a character is not mapped to any key or it's entered in non-predictive mode,
+            // then append the character.
+            if ( EPtiKeyNone == key )
                 {
-                case EItut:
-                    {
-                    TPtiKey key = KeyForCharacterMultiMatch(aSrcData[i]);
-                    // If a character is not mapped to numeric key append the character
-                    if ( EPtiKeyNone == key )
-                        {
-                        PRINT3 ( _L("CPcsKeyMap::GetMixedKeyStringForDataL: Char at index %d not mapped to a key, appending char '%c' (#%d)"),
-                                 i, (TUint) character, (TUint) character );
+                PRINT3 ( _L("CPcsKeyMap::GetMixedKeyStringForDataL: Char at index %d not mapped to a key, appending char '%c' (#%d)"),
+                         i, (TUint) character, (TUint) character );
 
-                        aDestStr.Append( character );
-                        }
-                    else 
-                        {
-                        aDestStr.Append( key );
-                        }
-                    }
-                    break;
-                case EQwerty:
-                    //fall through
-                default:
-                    PRINT2 ( _L("CPcsKeyMap::GetMixedKeyStringForDataL: Char '%c' (#%d) is taken exact (non predictive in query)"),
-                            (TUint) character, (TUint) character );
-                    aDestStr.Append( character );
-                    break;
+                aDestStr.Append( character );
+                }
+            else 
+                {
+                aDestStr.Append( key );
                 }
             }
         else
@@ -246,13 +238,14 @@
              &aDestStr );
 
     PRINT ( _L("End CPcsKeyMap::GetMixedKeyStringForDataL") );
-}
+    }
 
 // ----------------------------------------------------------------------------
 // CPcsKeyMap::CharacterForKeyMappingExists
 // Returns true if the character is mapped to the key
 // ----------------------------------------------------------------------------
-TBool CPcsKeyMap::CharacterForKeyMappingExists(TKeyMappingData& aKeyMap, const TUint aIntChar)
+TBool CPcsKeyMap::CharacterForKeyMappingExists(
+        TKeyMappingData& aKeyMap, TUint aIntChar) const
     {
     TBool found = EFalse;
     
@@ -274,7 +267,10 @@
 // CPcsKeyMap::CheckPotentialErrorConditions
 //
 // ----------------------------------------------------------------------------
-void CPcsKeyMap::CheckPotentialErrorConditions(RArray<TInt>& aPoolIndexArr, const TChar& aChar)
+void CPcsKeyMap::CheckPotentialErrorConditions(const RArray<TInt>& aPoolIndexArr, 
+                                               const TChar& aChar,
+                                               const RArray<TPtiKey>& aPtiKeys,
+                                               const RPointerArray<TKeyMappingData>& aKeyMappings) const
     {
     PRINT ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: ===================================================") );
     PRINT ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: Checking potential error conditions") );
@@ -294,10 +290,10 @@
         countArr[j] = 0;
         for ( TInt i = 0; i < aPoolIndexArr.Count(); i++ )
             {
-            if ( KErrNotFound != iKeyMapPtrArr[aPoolIndexArr[i]]->iKeyMapCharArr[j].Find((TUint) aChar) )
+            if ( KErrNotFound != aKeyMappings[aPoolIndexArr[i]]->iKeyMapCharArr[j].Find((TUint) aChar) )
                 {
-                PRINT5 ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: Char '%c' (#%d) %S for pool %d with key '%c'"),
-                        (TUint) aChar, (TUint) aChar, &charArrStr[j], aPoolIndexArr[i], iKeysArr[aPoolIndexArr[i]] );
+                PRINT5 ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: Char '%c' (0x%04X) %S for pool %d with key '%c'"),
+                        (TUint) aChar, (TUint) aChar, &charArrStr[j], aPoolIndexArr[i], aPtiKeys[aPoolIndexArr[i]] );
                 countArr[j]++;
                 }
             }
@@ -306,11 +302,17 @@
     PRINT ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: ===================================================") );
     
 #ifdef __WINS__
+    /*
+    The reference 4x10 QWERTY mappings of 9.2 emulator have each number mapped to two keys.
+    That kind of mappings can't be handled correctly, so panic in debug would basically be correct.
+    However, assertions are commented out for now to be able to do some testing.
+    
     // Check in debug mode if we have wrong situations
-    __ASSERT_DEBUG( (countArr[TKeyMappingData::EKeyMapSingleCharArr]  > 1), Panic(EPanicPreCond_MultipleSingleCharMatching) );
-    __ASSERT_DEBUG( (countArr[TKeyMappingData::EKeyMapUILangArr]      > 1), Panic(EPanicPreCond_MultipleUIPriorityMatching) );
-    __ASSERT_DEBUG( (countArr[TKeyMappingData::EKeyMapEnglishLangArr] > 1), Panic(EPanicPreCond_MultipleEnglishPriorityMatching) );
-    __ASSERT_DEBUG( (countArr[TKeyMappingData::EKeyMapOthersLangArr]  > 1), Panic(EPanicPreCond_MultipleOthersPriorityMatching) );
+    __ASSERT_DEBUG( (countArr[TKeyMappingData::EKeyMapSingleCharArr]  <= 1), Panic(EPanicPreCond_MultipleSingleCharMatching) );
+    __ASSERT_DEBUG( (countArr[TKeyMappingData::EKeyMapUILangArr]      <= 1), Panic(EPanicPreCond_MultipleUIPriorityMatching) );
+    __ASSERT_DEBUG( (countArr[TKeyMappingData::EKeyMapEnglishLangArr] <= 1), Panic(EPanicPreCond_MultipleEnglishPriorityMatching) );
+    __ASSERT_DEBUG( (countArr[TKeyMappingData::EKeyMapOthersLangArr]  <= 1), Panic(EPanicPreCond_MultipleOthersPriorityMatching) );
+    */
 #endif // __WINS__
     }
 #endif // _DEBUG        
@@ -329,18 +331,33 @@
 //   - 4th choice: choose the 1st pool that has the char mapped for the English language.
 //   - 5th choice: choose the 1st pool that has the char mapped for the Other languages.
 // ----------------------------------------------------------------------------
-TPtiKey CPcsKeyMap::KeyForCharacterMultiMatch(const TChar& aChar)
-    {
+TPtiKey CPcsKeyMap::KeyForCharacterMultiMatch( const TChar& aChar, TKeyboardModes aKbMode ) const
+    {    
+    aKbMode = ResolveKeyboardMode( aKbMode, EPredictiveDefaultKeyboard ); 
+
+    // Select key arrays to use according to keyboard mode
+    const RArray<TPtiKey>* ptiKeyArray;
+    const RPointerArray<TKeyMappingData>* keyMappingArray;
+    TPtiKeyboardType kbType;
+    GetPredictiveKeyboardData( aKbMode, ptiKeyArray, keyMappingArray, kbType );
+    if ( !ptiKeyArray || !keyMappingArray || ptiKeyArray->Count() == 0 )
+        {
+        // No mappings available. This may be, for example, because aKbMode is non-predictive.
+        // Return no mapping in that case to indicate that character should be treated in
+        // non-predictive way.
+        return EPtiKeyNone;
+        }
+    
     // Set an array of pool index matches (more matches are possible)
     RArray<TInt> poolIndexArr;
-    for ( TInt i = 0; i < PoolCount(); i++ )
+    for ( TInt i = 0; i < keyMappingArray->Count(); i++ )
         {
-        if ( CharacterForKeyMappingExists(*iKeyMapPtrArr[i], (TUint) aChar) )
+        if ( CharacterForKeyMappingExists(*(*keyMappingArray)[i], (TUint) aChar) )
             {
             poolIndexArr.Append(i);
 
-            PRINT4 ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: Char '%c' (#%d) found in pool %d with key '%c'"),
-                    (TUint) aChar, (TUint) aChar, i, iKeysArr[i] );
+            PRINT4 ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: Char '%c' (0x%04X) found in pool %d with key '%c'"),
+                    (TUint) aChar, (TUint) aChar, i, (*ptiKeyArray)[i] );
             }
         }
 
@@ -353,7 +370,7 @@
     // Character not found in any pool
     if ( poolIndexArr.Count() == 0 )
         {
-        PRINT2 ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: Char '%c' (#%d) NOT found in all pools"),
+        PRINT2 ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: Char '%c' (0x%04X) NOT found from any pool"),
                  (TUint) aChar, (TUint) aChar );
         }
 
@@ -363,7 +380,7 @@
         poolIndex = poolIndexArr[0];
 
         PRINT2 ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: Chosen (for unique match) pool %d with key '%c'"),
-                poolIndex, iKeysArr[poolIndex] );
+                poolIndex, (*ptiKeyArray)[poolIndex] );
         }
 
     /* Character found in more pools, this can happen in some known conditions:
@@ -389,11 +406,11 @@
          * this piece of code shall be removed.
          * With "client" it is referred to MCL contacts client.
          */
-        if (EPtiKeyboard12Key == iKeyboardType)
+        if (EPtiKeyboard12Key == kbType)
             {
             for ( TInt i = 0; i < poolIndexArr.Count() ; i++ )
                 {
-                if ( EPtiKey1 == iKeysArr[poolIndexArr[i]] )
+                if ( EPtiKey1 == (*ptiKeyArray)[poolIndexArr[i]] )
                     {
                     poolIndexArr.Remove(i);
     
@@ -406,12 +423,12 @@
                 poolIndex = poolIndexArr[0];
 
                 PRINT2 ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: Chosen (for unique match after removing key '1') pool %d with key '%c'"),
-                        poolIndex, iKeysArr[poolIndex] );
+                        poolIndex, (*ptiKeyArray)[poolIndex] );
                 }
             }
 
 #ifdef _DEBUG
-        CheckPotentialErrorConditions(poolIndexArr, aChar);
+        CheckPotentialErrorConditions(poolIndexArr, aChar, *ptiKeyArray, *keyMappingArray);
 #endif // _DEBUG        
 
         // Search the char in the char arrays in priority order, the 1st match is taken
@@ -423,7 +440,7 @@
 
                 for ( TInt i = 0; i < poolIndexArr.Count(); i++ )
                     {
-                    TInt position = iKeyMapPtrArr[poolIndexArr[i]]->iKeyMapCharArr[j].Find((TUint) aChar);
+                    TInt position = (*keyMappingArray)[poolIndexArr[i]]->iKeyMapCharArr[j].Find((TUint) aChar);
                     if ( KErrNotFound != position )
                         {
                         // Get the key that has the char in the leftmost index.
@@ -440,7 +457,6 @@
                                 poolIndex = poolIndexArr[i];
                                 positionLeftMostOnKeys = position;
                                 }
-
                             }
                         // Get the 1st key that has the char mapped to it
                         else
@@ -448,7 +464,7 @@
                             poolIndex = poolIndexArr[i];
                     
                             PRINT3 ( _L("CPcsKeyMap::KeyForCharacterMultiMatch: Chosen (for multi match - char arr: %d) pool %d with key '%c'"),
-                                     j, poolIndex, iKeysArr[poolIndex] );
+                                     j, poolIndex, (*ptiKeyArray)[poolIndex] );
                         
                             break;
                             }
@@ -463,7 +479,7 @@
     TPtiKey key = EPtiKeyNone;
     if ( KErrNotFound != poolIndex )
         {
-        key = iKeysArr[poolIndex];
+        key = (*ptiKeyArray)[poolIndex];
         }
     
     poolIndexArr.Close();
@@ -474,16 +490,40 @@
 // CPcsKeyMap::PoolIdForKey
 //
 // ----------------------------------------------------------------------------
-TInt CPcsKeyMap::PoolIdForKey(const TPtiKey aKey)
+TInt CPcsKeyMap::PoolIdForKey(const TPtiKey aKey, TKeyboardModes aKbMode)
     {
-    TInt poolId = iKeysArr.Find(aKey);
+    aKbMode = ResolveKeyboardMode( aKbMode, EPredictiveDefaultKeyboard ); 
 
-    // IF the key is not found, then it should go to the special pool,
-    // which is the last pool of iKeyMapPtrArr
-    if (KErrNotFound == poolId)
+    // From logical point of view, the Pool ID is an index of the key in
+    // an array which is formed by concatenating QWERTY keys array in the end
+    // of the ITU-T keys array.
+    TInt poolId = KErrNotFound;
+    if ( aKbMode == EPredictiveItuT && iItutKeys.Count() )
         {
-        poolId = PoolCount() - 1;
+        poolId = iItutKeys.Find(aKey);
+        // IF the key is not found, then it should go to the special pool,
+        // which is the pool of the dummy key in the ITU-T keys array
+        if (KErrNotFound == poolId)
+            {
+            poolId = iItutKeys.Count() - 1;
+            }
         }
+    else if ( aKbMode == EPredictiveQwerty && iQwertyKeys.Count() )
+        {
+        poolId = iQwertyKeys.Find(aKey);
+        // IF the key is not found, then it should go to the special pool,
+        // which is the pool of the dummy key in the QWERTY keys array
+        if (KErrNotFound == poolId)
+            {
+            poolId = iQwertyKeys.Count() - 1;
+            }
+        // Pools of QWERTY keys come after pools of ITU-T keys
+        poolId += iItutKeys.Count();
+        }
+
+    // Pool ID must never exceed value 63, because CPcsCache class
+    // stores these values as bitmask into 64 bit variable.
+    __ASSERT_DEBUG( poolId < 64, Panic(EPanic_OverflowInPoolIndex) );
 
     return poolId;
     }
@@ -492,11 +532,18 @@
 // CPcsKeyMap::PoolIdForCharacter
 //
 // ----------------------------------------------------------------------------
-TInt CPcsKeyMap::PoolIdForCharacter(const TChar& aChar)
+TInt CPcsKeyMap::PoolIdForCharacter(const TChar& aChar, TKeyboardModes aKbMode)
     {
-    TPtiKey key = KeyForCharacterMultiMatch(aChar);
+    // Pools are formed according the predictive keyboard mapping(s).
+    // When selecting pool for non-predictive mode, we use the pool of the
+    // default keyboard. The non-predictive matches should be a sub set of the
+    // predictive matches of the default keyboard, although strictly speaking,
+    // there' no guarantee for this.
+    aKbMode = ResolveKeyboardMode( aKbMode, ENonPredictive ); 
 
-    TInt poolId = PoolIdForKey(key);
+    TPtiKey key = KeyForCharacterMultiMatch( aChar, aKbMode );
+
+    TInt poolId = (key == EPtiKeyNone) ? KErrNotFound : PoolIdForKey(key, aKbMode);
 
     return poolId;
     }
@@ -507,7 +554,7 @@
 // ----------------------------------------------------------------------------
 TInt CPcsKeyMap::PoolCount()
     {
-    return iKeyMapPtrArr.Count();
+    return iItutKeyMaps.Count() + iQwertyKeyMaps.Count();
     }
 
 // ----------------------------------------------------------------------------
@@ -516,148 +563,153 @@
 // ----------------------------------------------------------------------------
 void CPcsKeyMap::SetSpaceAndZeroOnSameKey()
     {
-    const TInt KSpace = 32; // ASCII for " "
-    const TInt KZero  = 48; // ASCII for "0"
+    PRINT ( _L("Enter CPcsKeyMap::SetSpaceAndZeroOnSameKey") );
+
+    static const TInt KSpace = 0x20; // ASCII for " "
+    static const TInt KZero  = 0x30; // ASCII for "0"
 
     TChar charSpace(KSpace);
     TChar charZero(KZero);
 
-    TPtiKey keySpace = KeyForCharacterMultiMatch(charSpace);
-    TPtiKey keyZero = KeyForCharacterMultiMatch(charZero);
+    TPtiKey keySpace;
+    TPtiKey keyZero;
+	
+    // ITU-T mode
+    keySpace = KeyForCharacterMultiMatch(charSpace, EPredictiveItuT);
+    keyZero = KeyForCharacterMultiMatch(charZero, EPredictiveItuT);
+    iSpaceAndZeroOnSameKeyOnItut = (keySpace == keyZero && keyZero != EPtiKeyNone);
+    PRINT1 ( _L("CPcsKeyMap::iSpaceAndZeroOnSameKeyOnItut = %d"), iSpaceAndZeroOnSameKeyOnItut );
+    
+    // QWERTY mode
+    keySpace = KeyForCharacterMultiMatch(charSpace, EPredictiveQwerty);
+    keyZero = KeyForCharacterMultiMatch(charZero, EPredictiveQwerty);
+    iSpaceAndZeroOnSameKeyOnQwerty = (keySpace == keyZero && keyZero != EPtiKeyNone);
+    PRINT1 ( _L("CPcsKeyMap::iSpaceAndZeroOnSameKeyOnQwerty = %d"), iSpaceAndZeroOnSameKeyOnQwerty );
 
-    iSpaceAndZeroOnSameKey = (keySpace == keyZero);
+    PRINT ( _L("CPcsKeyMap::SetSpaceAndZeroOnSameKey") );
     }
 
 // ----------------------------------------------------------------------------
 // CPcsKeyMap::GetSpaceAndZeroOnSameKey
 // 
 // ----------------------------------------------------------------------------
-TBool CPcsKeyMap::GetSpaceAndZeroOnSameKey()
+TBool CPcsKeyMap::GetSpaceAndZeroOnSameKey( TKeyboardModes aKbMode )
     {
-    return iSpaceAndZeroOnSameKey;
+    TBool result = EFalse;
+
+    aKbMode = ResolveKeyboardMode( aKbMode, EPredictiveDefaultKeyboard );
+
+    if ( aKbMode == EPredictiveItuT )
+        {
+        result = iSpaceAndZeroOnSameKeyOnItut;
+        }
+    else if ( aKbMode == EPredictiveQwerty )
+        {
+        result = iSpaceAndZeroOnSameKeyOnQwerty;
+        }
+
+    return result;
     }
 
 // ----------------------------------------------------------------------------
-// CPcsKeyMap::GetKeyboardKeyMapping
-// Helper function to get Key Mappings depending on keyboard type
-// ----------------------------------------------------------------------------
-MPtiKeyMappings* CPcsKeyMap::GetKeyboardKeyMapping(CPtiCoreLanguage& aCurrLanguage)
-    {
-    MPtiKeyMappings* ptiKeyMappings;
-
-    switch ( iKeyboardType )
-        {
-        case EPtiKeyboardQwerty4x12:
-        case EPtiKeyboardQwerty4x10:
-        case EPtiKeyboardQwerty3x11:
-        case EPtiKeyboardCustomQwerty:
-            ptiKeyMappings = aCurrLanguage.GetQwertyKeymappings();
-            break;
-
-        case EPtiKeyboard12Key:
-            ptiKeyMappings = aCurrLanguage.GetKeymappings();
-            break;
-
-        case EPtiKeyboardHalfQwerty:
-            ptiKeyMappings = aCurrLanguage.GetHalfQwertyKeymappings();
-            break;
-
-        default:
-            ptiKeyMappings = aCurrLanguage.GetKeymappings();
-            break;
-        }
-
-    return ptiKeyMappings;
-    }
-
+// CPcsKeyMap::SetupKeyboardTypesL
+// Initialise the keyboard type variables
 // ----------------------------------------------------------------------------
-// CPcsKeyMap::GetKeyMapData
-//
-// ----------------------------------------------------------------------------
-CPtiKeyMapData* CPcsKeyMap::GetKeyMapData(CPtiCoreLanguage& aCurrLanguage)
+void CPcsKeyMap::SetupKeyboardTypesL()
     {
-    MPtiKeyMappings* ptiKeyMappings = GetKeyboardKeyMapping( aCurrLanguage );
+    TInt physicalKeyboard = 0;
+    CRepository* aknFepRepository = CRepository::NewL( KCRUidAknFep );
+    aknFepRepository->Get( KAknFepPhysicalKeyboards, physicalKeyboard );
+    delete aknFepRepository;
+
+    PRINT1 ( _L("CPcsKeyMap::SetupKeyboardTypesL: Physical keyboard support flag = 0x%02X"), physicalKeyboard );
 
-    CPtiKeyMapData* keyMapData;
+    // Constants follow the definition of KAknFepPhysicalKeyboards
+    const TInt KPtiKeyboard12Key = 0x01;
+    const TInt KPtiKeyboardQwerty4x12 = 0x02;
+    const TInt KPtiKeyboardQwerty4x10 = 0x04;
+    const TInt KPtiKeyboardQwerty3x11 = 0x08;
+    const TInt KPtiKeyboardHalfQwerty = 0x10;
+    const TInt KPtiKeyboardCustomQwerty = 0x20; 
 
-    switch ( iKeyboardType )
+    // Setup ITU-T mode first.
+    // Use always 12-key mode since all the supported devices should have at least
+    // virtual ITU-T available.
+    iItutKeyboardType = EPtiKeyboard12Key;
+    // TODO: ITU-T type could be set to "none" if device does not have either
+    // virtual keypad or hardware ITU-T available. This could be decided according
+    // some cenrep value, feature flag, device model, or platform version.
+    
+    // Then setup QWERTY mode. On real-life devices there should never
+    // be more than one QWERTY keyboard available but on emulator there can be several.
+    // Use the first one found in the following precedence
+    if ( physicalKeyboard & KPtiKeyboardQwerty3x11 )
         {
-        case EPtiKeyboardQwerty4x12:
-        case EPtiKeyboardQwerty4x10:
-        case EPtiKeyboardQwerty3x11:
-        case EPtiKeyboardCustomQwerty:
-            keyMapData = static_cast<CPtiQwertyKeyMappings*>(ptiKeyMappings)->KeyMapData();
-            break;
-
-        case EPtiKeyboard12Key:
-            keyMapData = static_cast<CPtiKeyMappings*>(ptiKeyMappings)->KeyMapData();
-            break;
-
-        case EPtiKeyboardHalfQwerty:
-            keyMapData = static_cast<CPtiHalfQwertyKeyMappings*>(ptiKeyMappings)->KeyMapData();
-            break;
-
-        default:
-            keyMapData = static_cast<CPtiKeyMappings*>(ptiKeyMappings)->KeyMapData();
-            break;
+        iQwertyKeyboardType = EPtiKeyboardQwerty3x11;
+        }
+    else if ( physicalKeyboard & KPtiKeyboardQwerty4x10 )
+        {
+        iQwertyKeyboardType = EPtiKeyboardQwerty4x10;
+        }
+    else if ( physicalKeyboard & KPtiKeyboardQwerty4x12 )
+        {
+        iQwertyKeyboardType = EPtiKeyboardQwerty4x12;
+        }
+    else if ( physicalKeyboard & KPtiKeyboardCustomQwerty )
+        {
+        iQwertyKeyboardType = EPtiKeyboardCustomQwerty;
         }
-
-    return keyMapData;
+    else if ( physicalKeyboard & KPtiKeyboardHalfQwerty )
+        {
+        iQwertyKeyboardType = EPtiKeyboardHalfQwerty;
+        }
+    else
+        {
+        iQwertyKeyboardType = EPtiKeyboardNone;
+        }
+    
+    // Set the Default Predictive keyboard mode
+    iPredictiveDefaultKeyboardMode = ( 
+            (physicalKeyboard & KPtiKeyboard12Key) || (iQwertyKeyboardType == EPtiKeyboardNone) ?
+                EPredictiveItuT : EPredictiveQwerty );
+    
+    PRINT1 ( _L("CPcsKeyMap::SetupKeyboardTypesL: ITU-T Keyboard chosen for Predictive Search = %d"), iItutKeyboardType );
+    PRINT1 ( _L("CPcsKeyMap::SetupKeyboardTypesL: QWERTY Keyboard chosen for Predictive Search = %d"), iQwertyKeyboardType );
     }
 
 // ----------------------------------------------------------------------------
 // CPcsKeyMap::AppendEntryWithFakeKeyToKeyList
 // Add pool with unused id for for key
 // ----------------------------------------------------------------------------
-void CPcsKeyMap::AppendEntryWithFakeKeyToKeyList()
+void CPcsKeyMap::AppendEntryWithFakeKeyToKeyList( RArray<TPtiKey>& aKeyArray )
     {
     TUint keyUInt = (TUint) EPtiKeyNone + 1;
 
-    while ( KErrNotFound != iKeysArr.Find( (TPtiKey) keyUInt) )
+    while ( KErrNotFound != aKeyArray.Find( (TPtiKey) keyUInt) )
         {
         keyUInt++;
         }
 
     TPtiKey key = (TPtiKey) keyUInt;
-    iKeysArr.Append( key );
+    aKeyArray.Append( key );
 
     // This should always be the last one in the array
     PRINT2 ( _L("CPcsKeyMap::AppendEntryWithFakeKeyToKeyList: Added additional last pool %d with key id #%d"),
-             iKeysArr.Count()-1, key );
-    }
-
-// ----------------------------------------------------------------------------
-// CPcsKeyMap::CreateKeyMapFromITUTHardcodedKeys
-//
-// ----------------------------------------------------------------------------
-void CPcsKeyMap::CreateKeyListFromITUTHardcodedKeys()
-    {
-    PRINT ( _L("Enter CPcsKeyMap::CreateKeyListFromITUTHardcodedKeys") );
-
-    iKeysArr.Append( EPtiKey0 );
-    iKeysArr.Append( EPtiKey1 );
-    iKeysArr.Append( EPtiKey2 );
-    iKeysArr.Append( EPtiKey3 );
-    iKeysArr.Append( EPtiKey4 );
-    iKeysArr.Append( EPtiKey5 );
-    iKeysArr.Append( EPtiKey6 );
-    iKeysArr.Append( EPtiKey7 );
-    iKeysArr.Append( EPtiKey8 );
-    iKeysArr.Append( EPtiKey9 );
-
-    AppendEntryWithFakeKeyToKeyList();
-
-    PRINT ( _L("End CPcsKeyMap::CreateKeyListFromITUTHardcodedKeys") );
+            aKeyArray.Count()-1, key );
     }
 
 // ----------------------------------------------------------------------------
 // CPcsKeyMap::CreateKeyMapFromKeyBindingTable
 //
 // ----------------------------------------------------------------------------
-void CPcsKeyMap::CreateKeyListFromKeyBindingTable( CPtiEngine* aPtiEngine )
+void CPcsKeyMap::CreateKeyListFromKeyBindingTable( RArray<TPtiKey>& aKeyArray, 
+        TPtiKeyboardType aKbType, CPtiEngine* aPtiEngine )
     {
     PRINT ( _L("Enter CPcsKeyMap::CreateKeyListFromKeyBindingTable") );
 
+    PRINT1 ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: Creating KeyList for TPtiKeyboardType=%d"),
+             aKbType  );
+
     // Get the user language
     TLanguage keyMapLanguage = iUILanguage;
     PRINT1 ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: Current User Language is %d"),
@@ -685,8 +737,19 @@
 
     if (currLanguage)
         {
+        TInt langCode = currLanguage->LanguageCode();
+        TRAP_IGNORE( aPtiEngine->ActivateLanguageL( langCode ) );
+        const CPtiKeyMapData* keyMapData = currLanguage->RawKeyMapData();
+        const TPtiKeyBinding* table = NULL;
         TInt numItems = 0;
-        const TPtiKeyBinding* table = GetKeyMapData(*currLanguage)->KeyBindingTable(iKeyboardType, numItems);
+        if ( keyMapData )
+            {
+            table = keyMapData->KeyBindingTable(aKbType, numItems);
+            }
+        else
+            {
+            PRINT1( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: #### Failed to get RawKeyMapData for language %d ####"), langCode );
+            }
         
         PRINT1 ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: Num of Items in KeyBindingTable is %d"), numItems );
 
@@ -700,11 +763,16 @@
                 // Only for one of the casing to avoid repetitions
                 if ( (EPtiKeyNone != key) && (EPtiCaseLower == table[i].iCase) )
                     {
-                    PRINT3 ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: Adding pool %d with key '%c' (%d)"),
-                            iKeysArr.Count(), key, key );
-                    iKeysArr.Append( key );
+                    PRINT3 ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: Adding pool %d with key '%c' (0x%02X)"),
+                            aKeyArray.Count(), key, key );
+                    aKeyArray.Append( key );
                     }
                 }
+            // Add a fake key at the end if the KeyList is not empty
+            if (aKeyArray.Count() > 0)
+                {
+                AppendEntryWithFakeKeyToKeyList(aKeyArray);
+                }
             }
         else
             {
@@ -716,149 +784,131 @@
         PRINT ( _L("CPcsKeyMap::CreateKeyListFromKeyBindingTable: ##### Failed to create Key List (Language) #####") );
         }
 
-    AppendEntryWithFakeKeyToKeyList();
-
     PRINT ( _L("End CPcsKeyMap::CreateKeyListFromKeyBindingTable") );
 }
 
 // ----------------------------------------------------------------------------
-// CPcsKeyMap::CreateKeyListL
-//
-// ----------------------------------------------------------------------------
-void CPcsKeyMap::CreateKeyListL( CPtiEngine* aPtiEngine )
-    {
-    PRINT ( _L("Enter CPcsKeyMap::CreateKeyListL") );
-
-    switch ( iKeyboardType )
-        {
-        case EPtiKeyboardQwerty4x12:
-        case EPtiKeyboardQwerty4x10:
-        case EPtiKeyboardQwerty3x11:
-        case EPtiKeyboardCustomQwerty:
-            CreateKeyListFromKeyBindingTable( aPtiEngine );
-            break;
-
-        case EPtiKeyboard12Key:
-            CreateKeyListFromITUTHardcodedKeys( );
-            break;
-
-        case EPtiKeyboardHalfQwerty:
-            CreateKeyListFromKeyBindingTable( aPtiEngine );
-            break;
-
-        default:
-            CreateKeyListFromKeyBindingTable( aPtiEngine );
-            break;
-        }
-
-    PRINT ( _L("End CPcsKeyMap::CreateKeyListL") );
-    }
-
-// ----------------------------------------------------------------------------
 // CPcsKeyMap::IsLanguageSupported
 // Returns ETrue if this language is supported
 // ----------------------------------------------------------------------------
 TBool CPcsKeyMap::IsLanguageSupported(TInt aLang)
     {
-    return (KErrNotFound == iLanguageNotSupported.Find((TLanguage) aLang));
+    TBool supported = 
+#ifdef __WINS__
+            // Only few languages for emulator 
+            ( ELangEnglish == aLang || 
+              ELangRussian == aLang || 
+              ELangHebrew == aLang || 
+              ELangFinnish == aLang ) &&
+#endif // __WINS__
+            ( KErrNotFound == iLanguageNotSupported.Find((TLanguage)aLang) );
+                
+    return supported;
     }
 
 // ----------------------------------------------------------------------------
 // CPcsKeyMap::CreateKeyMappingL
 //
 // ----------------------------------------------------------------------------
-void CPcsKeyMap::CreateKeyMappingL()
+void CPcsKeyMap::CreateKeyMappingL( TKeyboardModes aKbMode )
     {
     PRINT ( _L("Enter CPcsKeyMap::CreateKeyMappingL") );
 
+    __ASSERT_DEBUG( (aKbMode==EPredictiveItuT || aKbMode==EPredictiveQwerty),
+                    Panic(EPanic_InvalidKeyboardType) );
+
+    // Select the arrays we are operating on
+    RArray<TPtiKey>* ptiKeysArray;
+    RPointerArray<TKeyMappingData>* keyMappingArray;
+    TPtiKeyboardType kbType;
+    GetPredictiveKeyboardData( aKbMode, ptiKeysArray, keyMappingArray, kbType );
+    if ( kbType == EPtiKeyboardNone )
+        {
+        PRINT1( _L("CPcsKeyMap::CreateKeyMappingL: ##### No Keyboard available for mode %d => skipping #####"), aKbMode );
+        return;
+        }
+    
     // Instantiate the engine
     CPtiEngine* ptiEngine = CPtiEngine::NewL(ETrue);
     CleanupStack::PushL( ptiEngine );
 
-    ptiEngine->SetKeyboardType( iKeyboardType );
-
-    CreateKeyListL( ptiEngine );
-
-    // Now add the keymap arrays to hold the keymap data
-    for (TInt i = 0; i < iKeysArr.Count(); i++)
-    {
-        TKeyMappingData *keyData = new(ELeave) TKeyMappingData;
-        iKeyMapPtrArr.Append(keyData);
-    }
+    ptiEngine->SetKeyboardType( kbType );
 
-    // Get the available Languages on the phone
-    RArray<TInt> LanguagesOnThisPhone;
-    ptiEngine->GetAvailableLanguagesL(LanguagesOnThisPhone);
-    PRINT2 ( _L("CPcsKeyMap::CreateKeyMappingL: Languages on this phone %d, maximum is set to %d"),
-             LanguagesOnThisPhone.Count(), KMaxNbrOfLangKeymapping );
-    
-    // Remove the non-supported languages
-    for (TInt i = 0; i < LanguagesOnThisPhone.Count(); /* do not increment i */)
-        {
-        if ( (IsLanguageSupported(LanguagesOnThisPhone[i]))
-#ifdef __WINS__
-             && (ELangEnglish == LanguagesOnThisPhone[i]) // Only English for emulator 
-#endif // __WINS__
-           )
-            {
-            i++;
-            }
-        else
-            {
-            PRINT1 ( _L("CPcsKeyMap::CreateKeyMappingL: Removing not supported Language %d"),
-                     LanguagesOnThisPhone[i] );
-            LanguagesOnThisPhone.Remove(i);
-            }
-        }
+    CreateKeyListFromKeyBindingTable( *ptiKeysArray, kbType, ptiEngine );
 
-    // Set current UI language as 1st language and English as 2nd language,
-    // if present in AvailableLanguages
-    TInt langIndex;
-    if ( KErrNotFound != (langIndex = LanguagesOnThisPhone.Find(ELangEnglish)) )
+    if ( ptiKeysArray->Count() > 0 )
         {
-        LanguagesOnThisPhone.Remove(langIndex);
-        LanguagesOnThisPhone.Insert(ELangEnglish, 0);
-        }
-    if ( KErrNotFound != (langIndex = LanguagesOnThisPhone.Find(iUILanguage)) )
-        {
-        LanguagesOnThisPhone.Remove(langIndex);
-        LanguagesOnThisPhone.Insert(iUILanguage, 0);
-        }
-
-    // Set max number of languages for Key Map
-    TInt count = LanguagesOnThisPhone.Count();
-    if (count > KMaxNbrOfLangKeymapping)
-        {
-        PRINT2 ( _L("CPcsKeyMap::CreateKeyMappingL: Supported Languages on this phone %d, limiting to %d"),
-                 count, KMaxNbrOfLangKeymapping );
-        count = KMaxNbrOfLangKeymapping;
+        // Now add the keymap arrays to hold the keymap data
+        for (TInt i = 0; i < ptiKeysArray->Count(); i++)
+            {
+            TKeyMappingData *keyData = new(ELeave) TKeyMappingData;
+            keyMappingArray->Append(keyData);
+            }
+    
+        // Get the available Languages on the phone
+        RArray<TInt> languagesOnThisPhone;
+        CleanupClosePushL( languagesOnThisPhone );
+        ptiEngine->GetAvailableLanguagesL(languagesOnThisPhone);
+        PRINT2 ( _L("CPcsKeyMap::CreateKeyMappingL: Languages on this phone %d, maximum is set to %d"),
+                 languagesOnThisPhone.Count(), KMaxNbrOfLangKeymapping );
+        
+        // Remove the non-supported languages
+        for (TInt i = 0; i < languagesOnThisPhone.Count(); /* do not increment i */)
+            {
+            if ( IsLanguageSupported(languagesOnThisPhone[i]) )
+                {
+                i++;
+                }
+            else
+                {
+                PRINT1 ( _L("CPcsKeyMap::CreateKeyMappingL: Removing not supported Language %d"),
+                         languagesOnThisPhone[i] );
+                languagesOnThisPhone.Remove(i);
+                }
+            }
+    
+        // Set current UI language as 1st language and English as 2nd language,
+        // if present in AvailableLanguages
+        TInt langIndex;
+        if ( KErrNotFound != (langIndex = languagesOnThisPhone.Find(ELangEnglish)) )
+            {
+            languagesOnThisPhone.Remove(langIndex);
+            languagesOnThisPhone.Insert(ELangEnglish, 0);
+            }
+        if ( KErrNotFound != (langIndex = languagesOnThisPhone.Find(iUILanguage)) )
+            {
+            languagesOnThisPhone.Remove(langIndex);
+            languagesOnThisPhone.Insert(iUILanguage, 0);
+            }
+    
+        // Set max number of languages for Key Map
+        TInt count = languagesOnThisPhone.Count();
+        if (count > KMaxNbrOfLangKeymapping)
+            {
+            PRINT2 ( _L("CPcsKeyMap::CreateKeyMappingL: Supported Languages on this phone %d, limiting to %d"),
+                     count, KMaxNbrOfLangKeymapping );
+            count = KMaxNbrOfLangKeymapping;
+            }
+    
+        // Add Key Map for the languages
+        for (TInt i = 0; i < count; i++)
+            {
+            TLanguage languageToUse = (TLanguage) languagesOnThisPhone[i];
+    
+            PRINT1 ( _L("CPcsKeyMap::CreateKeyMappingL: Constructing Key Map for Language %d"), languageToUse );
+            TRAPD( leaveCode, AddKeyMappingForLanguageL(ptiEngine, languageToUse, kbType, *ptiKeysArray, *keyMappingArray) );
+            if ( leaveCode )
+                {
+                PRINT2 ( _L("CPcsKeyMap::CreateKeyMappingL: ##### Adding mappings for language %d failed, leave code = %d #####"),
+                         languageToUse, leaveCode );
+                }
+    
+            PRINT ( _L("CPcsKeyMap::CreateKeyMappingL: ===================================================") );
+            }
+    
+        CleanupStack::PopAndDestroy( &languagesOnThisPhone );
         }
 
-    // Add Key Map for the languages
-    for (TInt i = 0; i < count; i++)
-        {
-        TLanguage languageToUse = (TLanguage) LanguagesOnThisPhone[i];
-
-        PRINT1 ( _L("CPcsKeyMap::CreateKeyMappingL: Constructing Key Map for Language %d"), languageToUse );
-        TInt errStatus = ptiEngine->ActivateLanguageL(languageToUse);
-        if (KErrNone == errStatus)
-            {
-            TRAP_IGNORE(AddKeyMappingForActiveLanguageL(ptiEngine, languageToUse));
-            }
-        else
-            {
-            PRINT1 ( _L("CPcsKeyMap::CreateKeyMappingL: ##### Unable to activate Language %d #####"),
-                     languageToUse );
-            }
-
-        // Close the currently activated language
-        ptiEngine->CloseCurrentLanguageL();
-
-        PRINT ( _L("CPcsKeyMap::CreateKeyMappingL: ===================================================") );
-        }
-
-    LanguagesOnThisPhone.Close();
-
     CleanupStack::PopAndDestroy( ptiEngine );
 
     PRINT ( _L("End CPcsKeyMap::CreateKeyMappingL") );
@@ -868,110 +918,107 @@
 // CPcsKeyMap::AddKeyMappingForActiveLanguageL
 //
 // ----------------------------------------------------------------------------
-void CPcsKeyMap::AddKeyMappingForActiveLanguageL(CPtiEngine* aPtiEngine, TLanguage aLanguage)
+void CPcsKeyMap::AddKeyMappingForLanguageL(
+        CPtiEngine* aPtiEngine, 
+        TLanguage aLanguage,
+        TPtiKeyboardType aKbType,
+        const RArray<TPtiKey>& aPtiKeys,
+        RPointerArray<TKeyMappingData>& aResultMapping )
 {
-    PRINT ( _L("Enter CPcsKeyMap::AddKeyMappingForActiveLanguageL") );
+    PRINT ( _L("Enter CPcsKeyMap::AddKeyMappingForLanguageL") );
+
+    TInt err = aPtiEngine->ActivateLanguageL( aLanguage );
+    if ( err )
+        {
+        PRINT2 ( _L("##### CPcsKeyMap::AddKeyMappingForLanguageL failed to activate language %d, error=%d) #####"),
+                aLanguage, err );
+        User::Leave( err );
+        }
 
     // Make a language object based on the language
-    CPtiCoreLanguage* activeLanguage = static_cast<CPtiCoreLanguage*>(aPtiEngine->GetLanguage( aLanguage ));
-
-    if (activeLanguage)
-        {
-        // Get the keyboard Mappings for the Active Language
-        MPtiKeyMappings* ptiKeyMappings = GetKeyboardKeyMapping( *activeLanguage );
+    CPtiCoreLanguage* language = static_cast<CPtiCoreLanguage*>(aPtiEngine->GetLanguage( aLanguage ));
 
-        for (TInt i = 0; i < PoolCount() - 1; i++)
+    if (language)
+        {
+        for (TInt i = 0; i < aResultMapping.Count() - 1; i++)
             {
-            TPtiKey key = iKeysArr[i];
+            TPtiKey key = aPtiKeys[i];
 
-            PRINT ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: ===================================================") );
-            PRINT4 ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: Adding characters for Key '%c' (%d) at Pool %d and Language %d"),
-                     (TInt) key, (TInt) key, PoolIdForKey(key), aLanguage );
+            PRINT ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: ===================================================") );
+            PRINT4 ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: Adding chars for Key '%c' (0x%02X) for Keyboard Type %d and Language %d"),
+                     key, key, aKbType, aLanguage );
 
             // Get the pointer to the language class (UI, English, Others)
             RArray<TUint>* keyMapLang;
             if (aLanguage == iUILanguage)
                 {
-                keyMapLang = &(iKeyMapPtrArr[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapUILangArr]);
-                PRINT1 ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: Language %d is the UI language"), aLanguage );
+                keyMapLang = &(aResultMapping[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapUILangArr]);
+                PRINT1 ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: Language %d is the UI language"), aLanguage );
                 }
             else if (aLanguage == ELangEnglish)
                 {
                 // If (iUILanguage == ELangEnglish) ok to be in previous if case
-                keyMapLang = &(iKeyMapPtrArr[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapEnglishLangArr]);
-                PRINT1 ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: Language %d is English language"), aLanguage );
+                keyMapLang = &(aResultMapping[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapEnglishLangArr]);
+                PRINT1 ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: Language %d is English language"), aLanguage );
                 }
             else
                 {
-                keyMapLang = &(iKeyMapPtrArr[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapOthersLangArr]);
-                PRINT1 ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: Language %d is in the Other languages"), aLanguage );
+                keyMapLang = &(aResultMapping[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapOthersLangArr]);
+                PRINT1 ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: Language %d is in the Other languages"), aLanguage );
                 }
             
-            PRINT ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: ---------------------------------------------------") );
+            PRINT ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: ---------------------------------------------------") );
 
             TBool isSingleCharForKey = ETrue;
             TUint singleChar = 0;
 
             // EPtiCaseUpper must be the 1st TPtiTextCase for iUILanguage
-            AddCharactersToKey( *ptiKeyMappings, key, EPtiCaseUpper, *iKeyMapPtrArr[i], *keyMapLang, isSingleCharForKey, singleChar );
-            AddCharactersToKey( *ptiKeyMappings, key, EPtiCaseLower, *iKeyMapPtrArr[i], *keyMapLang, isSingleCharForKey, singleChar );
+            AddCharactersToKey( *language, aKbType, key, EPtiCaseUpper, *aResultMapping[i], *keyMapLang, isSingleCharForKey, singleChar );
+            AddCharactersToKey( *language, aKbType, key, EPtiCaseLower, *aResultMapping[i], *keyMapLang, isSingleCharForKey, singleChar );
 
             // 1. No other TPtiTextCase values for ITUT keyboard
             // 2. No language variants handling for ITUT keyboard
-            if ( EPtiKeyboard12Key != iKeyboardType )
+            if ( EPtiKeyboard12Key != aKbType )
                 {
-                AddCharactersToKey( *ptiKeyMappings, key, EPtiCaseFnLower,  *iKeyMapPtrArr[i], *keyMapLang, isSingleCharForKey, singleChar );
-                AddCharactersToKey( *ptiKeyMappings, key, EPtiCaseFnUpper,  *iKeyMapPtrArr[i], *keyMapLang, isSingleCharForKey, singleChar );
-                AddCharactersToKey( *ptiKeyMappings, key, EPtiCaseChrLower, *iKeyMapPtrArr[i], *keyMapLang, isSingleCharForKey, singleChar );
-                AddCharactersToKey( *ptiKeyMappings, key, EPtiCaseChrUpper, *iKeyMapPtrArr[i], *keyMapLang, isSingleCharForKey, singleChar );
+                AddCharactersToKey( *language, aKbType, key, EPtiCaseFnLower,  *aResultMapping[i], *keyMapLang, isSingleCharForKey, singleChar );
+                AddCharactersToKey( *language, aKbType, key, EPtiCaseFnUpper,  *aResultMapping[i], *keyMapLang, isSingleCharForKey, singleChar );
+                AddCharactersToKey( *language, aKbType, key, EPtiCaseChrLower, *aResultMapping[i], *keyMapLang, isSingleCharForKey, singleChar );
+                AddCharactersToKey( *language, aKbType, key, EPtiCaseChrUpper, *aResultMapping[i], *keyMapLang, isSingleCharForKey, singleChar );
 
                 // Support for key guessing given the char in some phone language variants
                 if ( (isSingleCharForKey) && (0 != singleChar) )
                     {
-                    iKeyMapPtrArr[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapSingleCharArr].Append(singleChar); // singleChar is in LowerCase
-                    iKeyMapPtrArr[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapSingleCharArr].Append(User::UpperCase(singleChar));
+                    aResultMapping[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapSingleCharArr].Append(singleChar); // singleChar is in LowerCase
+                    aResultMapping[i]->iKeyMapCharArr[TKeyMappingData::EKeyMapSingleCharArr].Append(User::UpperCase(singleChar));
 
-                    PRINT ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: ---------------------------------------------------") );
-                    PRINT5 ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: For Language %d and key '%c' of pool %d single char is '%c' (#%d)"),
-                            aLanguage, (TInt) key, i, singleChar, singleChar );
+                    PRINT ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: ---------------------------------------------------") );
+                    PRINT5 ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: For Language %d and key '%c' of pool %d single char is '%c' (0x%04X)"),
+                            aLanguage, key, i, singleChar, singleChar );
                     }
                 }
             }
-        PRINT ( _L("CPcsKeyMap::AddKeyMappingForActiveLanguageL: ===================================================") );
+        PRINT ( _L("CPcsKeyMap::AddKeyMappingForLanguageL: ===================================================") );
         }
 
-    PRINT ( _L("End CPcsKeyMap::AddKeyMappingForActiveLanguageL") );
+    PRINT ( _L("End CPcsKeyMap::AddKeyMappingForLanguageL") );
 }
 
 // ----------------------------------------------------------------------------
 // CPcsKeyMap::GetCharactersForKey
 //
 // ----------------------------------------------------------------------------
-void CPcsKeyMap::GetCharactersForKey(MPtiKeyMappings& aPtiKeyMappings,
+void CPcsKeyMap::GetCharactersForKey(CPtiCoreLanguage& aPtiLanguage,
+                                     TPtiKeyboardType aKbType,
                                      TPtiKey aKey,
                                      TPtiTextCase aTextCase,
                                      TDes& aResult)
     {
-    switch ( iKeyboardType )
+    const CPtiKeyMapData* keyMapData = aPtiLanguage.RawKeyMapData();
+    if  ( keyMapData )
         {
-        case EPtiKeyboardQwerty4x12:
-        case EPtiKeyboardQwerty4x10:
-        case EPtiKeyboardQwerty3x11:
-        case EPtiKeyboardCustomQwerty:
-            (static_cast<CPtiQwertyKeyMappings*>(&aPtiKeyMappings))->GetDataForKey(aKey, aResult, aTextCase);
-            break;
-
-        case EPtiKeyboard12Key:
-            (static_cast<CPtiKeyMappings*>(&aPtiKeyMappings))->GetDataForKey(aKey, aResult, aTextCase);
-            break;
-
-        case EPtiKeyboardHalfQwerty:
-            (static_cast<CPtiHalfQwertyKeyMappings*>(&aPtiKeyMappings))->GetDataForKey(aKey, aResult, aTextCase);
-            break;
-
-        default:
-            (static_cast<CPtiKeyMappings*>(&aPtiKeyMappings))->GetDataForKey(aKey, aResult, aTextCase);
-            break;
+        TPtrC dataPtr = keyMapData->DataForKey( aKbType, aKey, aTextCase );
+        // truncate results if supplied buffer is not large enough
+        aResult = dataPtr.Left( aResult.MaxLength() );
         }
     }
 
@@ -979,7 +1026,8 @@
 // CPcsKeyMap::AddDataForKeyL
 //
 // ----------------------------------------------------------------------------
-void CPcsKeyMap::AddCharactersToKey(MPtiKeyMappings& aPtiKeyMappings,
+void CPcsKeyMap::AddCharactersToKey(CPtiCoreLanguage& aPtiLanguage,
+                                    TPtiKeyboardType aKbType,
                                     TPtiKey aKey,
                                     TPtiTextCase aTextCase,
                                     TKeyMappingData& aKeyDataList,
@@ -990,37 +1038,38 @@
     PRINT ( _L("Enter CPcsKeyMap::AddCharactersToKey") );
 
     TBuf<255> result;
-    GetCharactersForKey(aPtiKeyMappings, aKey, aTextCase, result);
+    GetCharactersForKey(aPtiLanguage, aKbType, aKey, aTextCase, result);
 
-    PRINT3 ( _L("CPcsKeyMap::AddCharactersToKey: Get mapping chars for Key '%c' (%d) and TextCase %d"),
-             (TInt) aKey, (TInt) aKey, aTextCase );
+    PRINT3 ( _L("CPcsKeyMap::AddCharactersToKey: Get mapping chars for Key '%c' (0x%02X) and TextCase %d"),
+             aKey, aKey, aTextCase );
     PRINT1 ( _L("CPcsKeyMap::AddCharactersToKey: Got chars: \"%S\""), &result );
 
     for ( TInt i = 0; i < result.Length(); i++ )
         {
-        if ( !CharacterForKeyMappingExists(aKeyDataList, (TUint) result[i]) )
+        TText character = result[i];
+        if ( !CharacterForKeyMappingExists(aKeyDataList, character ) )
             {
-            PRINT1 ( _L("CPcsKeyMap::AddCharactersToKey: ----- Appending char to list: '%c'"), result[i] );
-            aKeyMapLang.Append(result[i]);
+            PRINT2 ( _L("CPcsKeyMap::AddCharactersToKey: ----- Appending char to list: '%c' (0x%04X)"), character, character );
+            aKeyMapLang.Append(character);
             }
         else
             {
-            PRINT1 ( _L("CPcsKeyMap::AddCharactersToKey: ***** NOT Appending char to list: '%c'"), result[i] );
+            PRINT2 ( _L("CPcsKeyMap::AddCharactersToKey: ***** NOT Appending char to list: '%c' (0x%04X)"), character, character );
             }
 
         // No language variants handling for ITUT keyboard
-        if ( EPtiKeyboard12Key != iKeyboardType )
+        if ( EPtiKeyboard12Key != aKbType )
             {
             // Support for key guessing given the char in some phone language variants
             if ( aIsSingleCharForKey )
                 {
                 if ( 0 == aSingleChar )
                     {
-                    aSingleChar = User::LowerCase(result[i]);
+                    aSingleChar = User::LowerCase(character);
                     }
                 else
                     {
-                    TInt newChar = User::LowerCase(result[i]);
+                    TInt newChar = User::LowerCase(character);
                     if (newChar != aSingleChar)
                         {
                         aSingleChar = 0;
@@ -1036,4 +1085,85 @@
     PRINT ( _L("End CPcsKeyMap::AddCharactersToKey") );
     }
 
+// ----------------------------------------------------------------------------
+// CPcsKeyMap::GetPredictiveKeyboardData
+//
+// ----------------------------------------------------------------------------
+void CPcsKeyMap::GetPredictiveKeyboardData( TKeyboardModes aKbMode, 
+                                            RArray<TPtiKey>*& aPtiKeys, 
+                                            RPointerArray<TKeyMappingData>*& aKeyMappings, 
+                                            TPtiKeyboardType& aKbType )
+    {
+    // Get the data from constant version of this function
+    const RArray<TPtiKey>* constKeys;
+    const RPointerArray<TKeyMappingData>* constMappings;
+    GetPredictiveKeyboardData( aKbMode, constKeys, constMappings, aKbType );
+    
+    // Convert pointers to non-const
+    aPtiKeys = const_cast< RArray<TPtiKey>* >( constKeys );
+    aKeyMappings = const_cast< RPointerArray<TKeyMappingData>* >( constMappings );
+    }
+
+// ----------------------------------------------------------------------------
+// CPcsKeyMap::GetPredictiveKeyboardData
+//
+// ----------------------------------------------------------------------------
+void CPcsKeyMap::GetPredictiveKeyboardData( TKeyboardModes aKbMode, 
+                                            const RArray<TPtiKey>*& aPtiKeys, 
+                                            const RPointerArray<TKeyMappingData>*& aKeyMappings, 
+                                            TPtiKeyboardType& aKbType ) const
+    {
+    PRINT1 ( _L("CPcsKeyMap::GetPredictiveKeyboardData: aKbMode=%d "), aKbMode );
+    
+    // EPredictiveItuT or EPredictiveQwerty mode to ENonPredictive mode if keyboard is not mapped
+    if ( aKbMode == EPredictiveItuT && iItutKeyboardType == EPtiKeyboardNone )
+        {
+        aKbMode = ENonPredictive;    
+        }
+    if ( aKbMode == EPredictiveQwerty && iQwertyKeyboardType == EPtiKeyboardNone )
+        {
+        aKbMode = ENonPredictive;    
+        }
+
+    // Get Predictive Keyboard Data
+    switch (aKbMode)
+        {
+        case EPredictiveItuT:
+            {
+            aPtiKeys = &iItutKeys;
+            aKeyMappings = &iItutKeyMaps;
+            aKbType = iItutKeyboardType;
+            break;
+            }
+
+        case EPredictiveQwerty:
+            {
+            aPtiKeys = &iQwertyKeys;
+            aKeyMappings = &iQwertyKeyMaps;
+            aKbType = iQwertyKeyboardType;
+            break;
+            }
+
+        case ENonPredictive:
+            {
+            aPtiKeys = NULL;
+            aKeyMappings = NULL;
+            aKbType = EPtiKeyboardNone;
+            break;
+            }
+
+        // EPredictiveDefaultKeyboard must have been resolved previously
+        // to EPredictiveItuT or EPredictiveQwerty mode
+        case EPredictiveDefaultKeyboard: 
+        default:
+            {
+            aPtiKeys = NULL;
+            aKeyMappings = NULL;
+            aKbType = EPtiKeyboardNone;
+            __ASSERT_DEBUG( EFalse, Panic( EPanic_InvalidKeyboardType ) );
+            break;
+            }
+        }
+    }
+
 // End of file
--- a/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsPoolElement.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsPoolElement.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -51,7 +51,7 @@
 // ----------------------------------------------------------------------------
 void CPcsPoolElement::ConstructL(CPsData& aPsData)
 {
-     psData = &aPsData;
+     iPsData = &aPsData;
 }
 
 // ----------------------------------------------------------------------------
@@ -70,30 +70,29 @@
 // ----------------------------------------------------------------------------
 CPsData* CPcsPoolElement::GetPsData()
 {
-	return psData;
+	return iPsData;
 }
 
 // ----------------------------------------------------------------------------
 // CPcsPoolElement::CompareByData
 // Calls CPsData::CompareByData to compare CPsData objects
-// 
 // ----------------------------------------------------------------------------
 TInt CPcsPoolElement::CompareByData ( const CPcsPoolElement& aObject1,  const CPcsPoolElement& aObject2 )
 {
-  CPsData *data1 = const_cast<CPcsPoolElement&> (aObject1).GetPsData();
-  CPsData *data2 = const_cast<CPcsPoolElement&> (aObject2).GetPsData();  
-  return (CPcsAlgorithm1Utils::CompareDataBySortOrderL(*(data1), *(data2)));
+    CPsData *data1 = const_cast<CPcsPoolElement&> (aObject1).GetPsData();
+    CPsData *data2 = const_cast<CPcsPoolElement&> (aObject2).GetPsData();  
+    return (CPcsAlgorithm1Utils::CompareDataBySortOrderL(*(data1), *(data2)));
 }
 
+// ----------------------------------------------------------------------------
 // CPcsPoolElement::IsDataMatch
 // 
 // ----------------------------------------------------------------------------		
-TBool CPcsPoolElement::IsDataMatch (TInt aIndex)
+TBool CPcsPoolElement::IsDataMatch(TInt aIndex)
 {
-	TReal val;
-	Math::Pow(val, 2, aIndex);
-
-	return(iDataMatchAttribute & (TUint8)val);	
+    __ASSERT_DEBUG( aIndex < 8, User::Panic( _L("CPcsPoolElement"), KErrOverflow ) );
+    TUint8 val = 1 << aIndex;
+    return (iDataMatchAttribute & val);
 }
 
 // ----------------------------------------------------------------------------
@@ -102,10 +101,9 @@
 // ----------------------------------------------------------------------------
 void CPcsPoolElement::SetDataMatch(TInt aIndex)
 {
-	TReal val;
-	Math::Pow(val, 2, aIndex);
-
-	iDataMatchAttribute |= (TUint8)val;	
+    __ASSERT_DEBUG( aIndex < 8, User::Panic( _L("CPcsPoolElement"), KErrOverflow ) );
+    TUint8 val = 1 << aIndex;
+    iDataMatchAttribute |= val;
 }
 
 // ----------------------------------------------------------------------------
--- a/predictivesearch/PcsAlgorithm/Algorithm1/src/CPsDataPluginInterface.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/src/CPsDataPluginInterface.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -221,19 +221,20 @@
     PRINT ( _L("Enter CPsDataPluginInterface::GetAllSupportedDataStoresL") );
    
     for ( TInt idx = 0; idx < iPsDataPluginInstances.Count(); idx++ )
-    {   
-       RPointerArray<TDesC> aDataStores;    
-       iPsDataPluginInstances[idx]->GetSupportedDataStoresL(aDataStores);
+    {
+       RPointerArray<TDesC> dataStores;
+       CleanupClosePushL( dataStores );
+       iPsDataPluginInstances[idx]->GetSupportedDataStoresL(dataStores);
        
-       for( TInt i(0); i<aDataStores.Count(); i++)
-       {       	
-	       	if( aDataStores[i]->Compare(aUri) == 0)
+       for ( TInt i(0); i<dataStores.Count(); i++)
+       {
+	       	if ( dataStores[i]->Compare(aUri) == 0)
 	       	{
 	       		iPsDataPluginInstances[idx]->GetSupportedDataFieldsL(aDataFields);
 	       		break;
-	       	}    	
+	       	}
        }
-       aDataStores.Reset();
+       CleanupStack::PopAndDestroy( &dataStores ); // Close
     }
     
     PRINT ( _L("End CPsDataPluginInterface::GetAllSupportedDataStoresL") );
--- a/predictivesearch/PcsAlgorithm/Algorithm2/inc/CPcsPoolElement.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm2/inc/CPcsPoolElement.h	Mon Mar 15 12:39:26 2010 +0200
@@ -85,7 +85,7 @@
      * Pointer to contact data
      * Not owned.
      */
-    CPsData* psData;
+    CPsData* iPsData;
 
     /*
      * This attribute indicates due to which
--- a/predictivesearch/PcsAlgorithm/Algorithm2/src/CPcsPoolElement.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/Algorithm2/src/CPcsPoolElement.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -50,7 +50,7 @@
 // ----------------------------------------------------------------------------
 void CPcsPoolElement::ConstructL(CPsData& aPsData)
 {
-     psData = &aPsData;
+     iPsData = &aPsData;
 }
 
 // ----------------------------------------------------------------------------
@@ -69,7 +69,7 @@
 // ----------------------------------------------------------------------------
 CPsData* CPcsPoolElement::GetPsData()
 {
-	return psData;
+	return iPsData;
 }
 
 // ----------------------------------------------------------------------------
--- a/predictivesearch/PcsAlgorithm/group/bld.inf	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsAlgorithm/group/bld.inf	Mon Mar 15 12:39:26 2010 +0200
@@ -26,5 +26,5 @@
 // Generic configuration interface for component cenrep settings  
 // .crml files contain implementation specifics for cenrep data
 ../conf/predictivesearch_sortorder.confml                  APP_LAYER_CONFML(predictivesearch_sortorder.confml)
-../conf/predictivesearch_sortorder_2000B5C5.crml 	        APP_LAYER_CRML(predictivesearch_sortorder_2000B5C5.crml)
+../conf/predictivesearch_sortorder_2000B5C5.crml           APP_LAYER_CRML(predictivesearch_sortorder_2000B5C5.crml)
 
--- a/predictivesearch/PcsServer/inc/CPcsServer.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsServer/inc/CPcsServer.h	Mon Mar 15 12:39:26 2010 +0200
@@ -79,7 +79,7 @@
         /**
          * A PCS algorithm instance (owned)
          */
-    	CPcsPluginInterface* pcs;
+    	CPcsPluginInterface* iPcs;
 };
 
 #endif // End of file
--- a/predictivesearch/PcsServer/inc/CPcsSession.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsServer/inc/CPcsSession.h	Mon Mar 15 12:39:26 2010 +0200
@@ -24,6 +24,7 @@
 
 // FORWARD DECLARATIONS
 class CPcsServer;
+class CPsQuery;
 
 /**
  * Represents a session (version 2) for a client thread on 
@@ -119,6 +120,11 @@
 		 */
 		void ShutdownServerL(const RMessage2& aMessage);
 
+		/**
+		 * Utility function for reading search query from message
+		 */
+		static CPsQuery* ReadQueryLC( TInt aParam, const RMessage2& aMessage );
+		
     private:
     
         /**
--- a/predictivesearch/PcsServer/src/CPcsPluginInterface.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsServer/src/CPcsPluginInterface.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -117,6 +117,7 @@
 	        
 	        PRINT ( _L("------------- PCS Algorithm Details -----------"));
 	        PRINT1 ( _L("Name: %S"), &(info.DisplayName()) );
+	        PRINT1_BOOT_PERFORMANCE ( _L("Name: %S"), &(info.DisplayName()) );
 	        PRINT1 ( _L("UID: %X"), impUid.iUid );
 	        iAlgorithmInUse.iUid = impUid.iUid;
 	        PRINT ( _L("-----------------------------------------------"));
--- a/predictivesearch/PcsServer/src/CPcsServer.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsServer/src/CPcsServer.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -67,7 +67,7 @@
 {  
 	PRINT ( _L("Enter CPcsServer::ConstructL") );
 	
-	pcs = CPcsPluginInterface::NewL();
+	iPcs = CPcsPluginInterface::NewL();
     
 	// Check if the phone is chinese feature id installed
 	TBool isChineseVariant = IsChineseFeatureInitilizedL();
@@ -79,7 +79,7 @@
 	    // Chinese variant phones. Use Algorithm 2
 	    PRINT ( _L("Enter CPcsServer::ConstructL() - Chinese Variant Phone Algorithm Instantiated") );
 	    TBuf<KAlgorithmNameMaxLen> algorithmName(KPcsAlgorithm_Chinese);
-	    pcs->InstantiateAlgorithmL(algorithmName);
+	    iPcs->InstantiateAlgorithmL(algorithmName);
 	    
 	    
 	    }
@@ -89,7 +89,7 @@
 	    PRINT ( _L("Enter CPcsServer::ConstructL() - NON-Chinese Variant Phone Algorithm Instantiated") );
 	    TBuf<KAlgorithmNameMaxLen> algorithmName(KPcsAlgorithm_NonChinese);
 	   // TBuf<KAlgorithmNameMaxLen> algorithmName(KPcsAlgorithm_Chinese);
-	    pcs->InstantiateAlgorithmL(algorithmName);
+	    iPcs->InstantiateAlgorithmL(algorithmName);
 	    
 	    }
   
@@ -103,11 +103,7 @@
 CPcsServer::~CPcsServer()
 {
 	PRINT ( _L("Enter CPcsServer::~CPcsServer") );
-	if(pcs)
-	{
-	  delete pcs;
-	  pcs=NULL;
-	}  	
+	delete iPcs;
 	PRINT ( _L("End CPcsServer::~CPcsServer") );
 }
 
@@ -137,7 +133,7 @@
 // ----------------------------------------------------------------------------
 CPcsPluginInterface* CPcsServer::PluginInterface()
 {
-	return pcs;
+	return iPcs;
 };
 
 // ----------------------------------------------------------------------------
--- a/predictivesearch/PcsServer/src/CPcsSession.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsServer/src/CPcsSession.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -82,12 +82,7 @@
 {
 	PRINT ( _L("Enter CPcsSession::~CPcsSession") );
 
-	if ( iSettings )
-	{
-		delete iSettings;
-		iSettings = NULL;
-	}
-	
+	delete iSettings;
 	delete iDes;
 
 	PRINT ( _L("End CPcsSession::~CPcsSession") );
@@ -151,7 +146,7 @@
         case ESearchMatchString:
             PRINT ( _L("Received function ESearchMatchString") );
             SearchMatchStringL(aMessage);
-            break;    	    
+            break;
 
     	case ELangSupport:
 			PRINT ( _L("Received function ELangSupport") );
@@ -247,25 +242,19 @@
         // -------------------------------------------------------------
 
 	    // Read search query from the message
-	    HBufC8* searchQuery = HBufC8::NewLC(KBufferMaxLen);
-
-	    TPtr8 searchQueryPtr(searchQuery->Des());
-        aMessage.ReadL(0, searchQueryPtr);
-
-	    // Stream over the buffer
-	    RDesReadStream searchQueryStream(searchQueryPtr);
-	    searchQueryStream.PushL();
-
-	    // Query object
-	    CPsQuery* psQuery = CPsQuery::NewL();
-
-	    psQuery->InternalizeL(searchQueryStream);
-
-	    // searchQueryStream, searchQuery
-	    CleanupStack::PopAndDestroy(2, searchQuery);
+	    CPsQuery* psQuery = ReadQueryLC( 0, aMessage );
 
 	    // -------------------------------------------------------------
 
+        RPointerArray<CPsClientData>  searchResults;
+        RPointerArray<CPsPattern>     searchSeqs;
+
+        iServer->PluginInterface()->PerformSearchL(*iSettings,
+                                                   *psQuery,
+                                                   searchResults,
+                                                   searchSeqs);
+        CleanupStack::PopAndDestroy( psQuery );
+
 		// Dynamic data buffer
 	    CBufFlat* buf = CBufFlat::NewL(KBufferMaxLen);
 	    CleanupStack::PushL(buf);
@@ -274,20 +263,11 @@
 	    RBufWriteStream stream(*buf);
 	    stream.PushL();
 
-        RPointerArray<CPsClientData>  searchResults;
-	    RPointerArray<CPsPattern>     searchSeqs;
-
-
-		iServer->PluginInterface()->PerformSearchL(*iSettings,
-		                                           *psQuery,
-		                                           searchResults,
-		                                           searchSeqs);
-
         // Write the number of contacts
 	    stream.WriteInt32L(searchResults.Count());
 
 	    // Write the contacts
-	    for ( int i = 0; i < searchResults.Count(); i++ )
+	    for ( TInt i = 0; i < searchResults.Count(); i++ )
 	    {
 	        searchResults[i]->ExternalizeL(stream);
 	    }
@@ -296,7 +276,7 @@
 	    stream.WriteInt32L(searchSeqs.Count());
 
 	    // Write the seqs
-	    for ( int j = 0; j < searchSeqs.Count(); j++ )
+	    for ( TInt j = 0; j < searchSeqs.Count(); j++ )
 	    {
 	        searchSeqs[j]->ExternalizeL(stream);
 	    }
@@ -304,16 +284,15 @@
 	    // Cleanup
 	    searchResults.ResetAndDestroy();
 	    searchSeqs.ResetAndDestroy();
-	    delete psQuery;
 
         // Results are already packed in the stream
         stream.CommitL();
 
         // Create a heap descriptor from the buffer
-	    iDes = HBufC8::NewL(buf->Size());
-	    TPtr8 ptr(iDes->Des());
-	    buf->Read(0, ptr, buf->Size());
-
+        delete iDes;
+        iDes = NULL;
+	    iDes = buf->Ptr(0).AllocL();
+	    
 	    CleanupStack::PopAndDestroy(2, buf); // buf, stream
     }
 
@@ -370,21 +349,7 @@
     // -------------------------------------------------------------
 
     // Read search query from the message
-    HBufC8* searchQuery = HBufC8::NewLC(KBufferMaxLen);
-
-    TPtr8 searchQueryPtr(searchQuery->Des());
-    aMessage.ReadL(0, searchQueryPtr);
-
-    // Stream over the buffer
-    RDesReadStream searchQueryStream(searchQueryPtr);
-    searchQueryStream.PushL();
-
-    // Query object
-    CPsQuery* psQuery = CPsQuery::NewL();
-    psQuery->InternalizeL(searchQueryStream);
-
-    // searchQueryStream, searchQuery
-    CleanupStack::PopAndDestroy(2, searchQuery);
+    CPsQuery* psQuery = ReadQueryLC( 0, aMessage );
 
     // -------------------------------------------------------------
 
@@ -405,24 +370,16 @@
 
     // searchQueryStream, searchQuery
     CleanupStack::PopAndDestroy(2, searchData);
+    CleanupStack::PushL( data );
 
     // -------------------------------------------------------------
 
-	// Dynamic data buffer
-    CBufFlat* buf = CBufFlat::NewL(KBufferMaxLen);
-    CleanupStack::PushL(buf);
-
-    // Stream over the buffer
-    RBufWriteStream stream(*buf);
-    stream.PushL();
-
     // To hold the matches
     RPointerArray<TDesC> searchSeqs;
 
     // To hold matched location
     RArray<TPsMatchLocation> sequenceLoc;
 
-
 	iServer->PluginInterface()->SearchInputL(*psQuery,
 	                                         *data,
 	                                         searchSeqs,
@@ -430,15 +387,24 @@
 
 
     // Delete the search query and search data
-    delete psQuery;
-    delete data;
+	CleanupStack::PopAndDestroy( data );
+    CleanupStack::PopAndDestroy( psQuery );
+
+    // --------- create write stream ---------------------------
+    // Dynamic data buffer
+    CBufFlat* buf = CBufFlat::NewL(KBufferMaxLen);
+    CleanupStack::PushL(buf);
+
+    // Stream over the buffer
+    RBufWriteStream stream(*buf);
+    stream.PushL();
 
     // --------- write match sequence ---------------------------
     // Write the number of match seqs
     stream.WriteUint16L(searchSeqs.Count());
 
     // Write the matches
-    for ( int j = 0; j < searchSeqs.Count(); j++ )
+    for ( TInt j = 0; j < searchSeqs.Count(); j++ )
     {
         TInt length = searchSeqs[j]->Length();
 
@@ -476,14 +442,10 @@
 
     stream.CommitL();
 
-    // Create a heap descriptor from the buffer
-    HBufC8* des = HBufC8::NewLC(buf->Size());
-    TPtr8 ptr(des->Des());
-    buf->Read(0, ptr, buf->Size());
-
-	aMessage.Write(2, *des);
+	aMessage.Write(2, buf->Ptr(0));
 	aMessage.Complete(KErrNone);
-	CleanupStack::PopAndDestroy(3, buf); // buf, stream, des
+	
+	CleanupStack::PopAndDestroy(2, buf); // buf, stream
 	
     PRINT ( _L("End CPcsSession::SearchInputL") );
     __LATENCY_MARKEND ( _L("CPcsSession::SearchInputL") );
@@ -501,22 +463,14 @@
 
     // -------------------------------------------------------------
 
-    // Read search query from the message
-    HBufC8* searchQuery = HBufC8::NewLC(KBufferMaxLen);
-
-    TPtr8 searchQueryPtr(searchQuery->Des());
-    aMessage.ReadL(0, searchQueryPtr);
+    // Create result buffer
+    HBufC* des = HBufC::NewLC(KBufferMaxLen);
+    TPtr ptr(des->Des());
+    
+    // -------------------------------------------------------------
 
-    // Stream over the buffer
-    RDesReadStream searchQueryStream(searchQueryPtr);
-    searchQueryStream.PushL();
-
-    // Query object
-    CPsQuery* psQuery = CPsQuery::NewL();
-    psQuery->InternalizeL(searchQueryStream);
-
-    // searchQueryStream, searchQuery
-    CleanupStack::PopAndDestroy(2, searchQuery);
+    // Read search query from the message
+    CPsQuery* psQuery = ReadQueryLC( 0, aMessage );
 
     // -------------------------------------------------------------
 
@@ -537,29 +491,22 @@
 
     // searchQueryStream, searchQuery
     CleanupStack::PopAndDestroy(2, searchData);
+    CleanupStack::PushL( data );
 
     // -------------------------------------------------------------
 
-    // Dynamic data buffer
-    CBufFlat* buf = CBufFlat::NewL(KBufferMaxLen);
-    CleanupStack::PushL(buf);
-
-    // Create a heap descriptor from the buffer
-    HBufC* des = HBufC::NewLC(KBufferMaxLen);
-    TPtr ptr(des->Des());
-    
     iServer->PluginInterface()->SearchMatchStringL(*psQuery,
-                                             *data,
-                                             ptr);
+                                                   *data,
+                                                   ptr);
 
 
     // Delete the search query and search data
-    delete psQuery;
-    delete data;
+    CleanupStack::PopAndDestroy( data );
+    CleanupStack::PopAndDestroy( psQuery );
 
     aMessage.Write(2, *des);
     aMessage.Complete(KErrNone);
-    CleanupStack::PopAndDestroy(2, buf); // buf, des
+    CleanupStack::PopAndDestroy(des);
     
     PRINT ( _L("End CPcsSession::SearchMatchStringL") );
     __LATENCY_MARKEND ( _L("CPcsSession::SearchMatchStringL") );
@@ -613,14 +560,9 @@
 
     // --------------------------------------------------------------
 
-    // Create a heap descriptor from the buffer
-    HBufC8* des = HBufC8::NewLC(buffer1->Size());
-    TPtr8 ptr(des->Des());
-    buffer1->Read(0, ptr, buffer1->Size());
-
-	aMessage.Write(1, *des);
+	aMessage.Write(1, buffer1->Ptr(0));
 	aMessage.Complete(KErrNone);
-	CleanupStack::PopAndDestroy(3, buffer1); // buffer1, stream1, des
+	CleanupStack::PopAndDestroy(2, buffer1); // buffer1, stream1
 
 	PRINT ( _L("End CPcsSession::IsLanguageSupportedL") );
 }
@@ -680,7 +622,7 @@
 	stream1.WriteUint16L(fieldCount);
 
 	// Pack the fields
-	for ( int i = 0; i < fieldCount; i++ )
+	for ( TInt i = 0; i < fieldCount; i++ )
 	{
 		stream1.WriteUint16L(dataOrder[i]);
 	}
@@ -689,14 +631,9 @@
 
     // --------------------------------------------------------------
 
-    // Create a heap descriptor from the buffer
-    HBufC8* des = HBufC8::NewLC(buffer1->Size());
-    TPtr8 ptr(des->Des());
-    buffer1->Read(0, ptr, buffer1->Size());
-
-	aMessage.Write(1, *des);
+	aMessage.Write(1, buffer1->Ptr(0));
 	aMessage.Complete(KErrNone);
-	CleanupStack::PopAndDestroy(4, &dataOrder); // des, stream1, buffer1, dataOrder
+	CleanupStack::PopAndDestroy(3, &dataOrder); // stream1, buffer1, dataOrder
 
     PRINT ( _L("End CPcsSession::GetDataOrderL") );
 }
@@ -725,7 +662,10 @@
 	TInt uriSize = stream.ReadUint16L();
 
     // URI
-    HBufC* uri = HBufC::NewLC(stream, uriSize);
+    HBufC* uri = HBufC::NewL(stream, uriSize);
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buffer );
+    CleanupStack::PushL( uri );
 
     // --------------------------------------------------------------
 
@@ -733,8 +673,7 @@
     RArray<TInt> sortOrder;
     iServer->PluginInterface()->GetSortOrderL(*uri, sortOrder);
     
-    // uri, stream, buffer
-    CleanupStack::PopAndDestroy(3, buffer);
+    CleanupStack::PopAndDestroy( uri );
     
     CleanupClosePushL( sortOrder );
     
@@ -753,7 +692,7 @@
 	stream1.WriteUint16L(fieldCount);
 
 	// Pack the fields
-	for ( int i = 0; i < fieldCount; i++ )
+	for ( TInt i = 0; i < fieldCount; i++ )
 	{
 		stream1.WriteUint16L(sortOrder[i]);
 	}
@@ -762,14 +701,9 @@
 
     // --------------------------------------------------------------
 
-    // Create a heap descriptor from the buffer
-    HBufC8* des = HBufC8::NewLC(buffer1->Size());
-    TPtr8 ptr(des->Des());
-    buffer1->Read(0, ptr, buffer1->Size());
-
-	aMessage.Write(1, *des);
+	aMessage.Write(1, buffer1->Ptr(0));
 	aMessage.Complete(KErrNone);
-	CleanupStack::PopAndDestroy(4, &sortOrder); // des, buffer1, stream1, sortOrder
+	CleanupStack::PopAndDestroy(3, &sortOrder); // buffer1, stream1, sortOrder
 
     PRINT ( _L("End CPcsSession::GetSortOrderL") );
 }
@@ -799,27 +733,26 @@
 
     // URI
     HBufC* uri = HBufC::NewLC(stream, uriSize);
-    CleanupStack::Pop(); // uri
 
     // Number of data fields
     TInt fieldCount = stream.ReadUint16L();
     RArray<TInt> sortOrder;
+    CleanupClosePushL( sortOrder );
 
-    for ( int i = 0; i < fieldCount; i++ )
+    for ( TInt i = 0; i < fieldCount; i++ )
     {
-    	sortOrder.Append(stream.ReadUint16L());
+    	sortOrder.AppendL(stream.ReadUint16L());
     }
 
-    // stream, buffer
-    CleanupStack::PopAndDestroy(2, buffer);
-
     // --------------------------------------------------------------
 
     // Set the sort order
     iServer->PluginInterface()->ChangeSortOrderL(*uri, sortOrder);
 
-    delete uri;
-    sortOrder.Reset();
+    CleanupStack::PopAndDestroy( &sortOrder ); // Close
+    CleanupStack::PopAndDestroy( uri );
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buffer );
 
     // --------------------------------------------------------------
 
@@ -841,3 +774,33 @@
 
 	PRINT ( _L("End CPcsSession::ShutdownServerL") );
 }
+
+// ----------------------------------------------------------------------------
+// CPcsSession::ReadQueryLC
+//
+// ----------------------------------------------------------------------------
+CPsQuery* CPcsSession::ReadQueryLC( TInt aParam, const RMessage2& aMessage )
+{
+    TInt size = aMessage.GetDesLength( aParam );
+    HBufC8* tempBuf = HBufC8::NewLC( size );
+
+    TPtr8 ptr( tempBuf->Des() );
+    aMessage.ReadL( aParam, ptr );
+
+    // Stream over the buffer
+    RDesReadStream stream( ptr );
+    stream.PushL();
+
+    // Query object
+    CPsQuery* psQuery = CPsQuery::NewL();
+    CleanupStack::PushL( psQuery );
+
+    psQuery->InternalizeL( stream );
+
+    CleanupStack::Pop( psQuery ); // temporarily
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( tempBuf );
+    CleanupStack::PushL( psQuery );
+    
+    return psQuery;
+}
--- a/predictivesearch/PcsUtils/inc/CPcsDebug.h	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsUtils/inc/CPcsDebug.h	Mon Mar 15 12:39:26 2010 +0200
@@ -24,11 +24,15 @@
 #include <f32file.h>
 
 
-#ifdef _DEBUG
+//==============================================================================
+// winscw udeb
+//------------------------------------------------------------------------------
 
 #ifdef __WINS__
+#ifdef _DEBUG
+
 #define PRINT( txt )                                \
-    { TBuf<512> __buf; __buf.Format(txt);                          RDebug::Print( _L("[PCS] %S"), &__buf );  }
+    { TBuf<512> __buf; __buf.Format(txt);                          RDebug::Print( _L("[PCS] %S"), &__buf ); }
 #define PRINT1( txt, arg1 )                         \
     { TBuf<512> __buf; __buf.Format(txt,arg1);                     RDebug::Print( _L("[PCS] %S"), &__buf ); }
 #define PRINT2( txt, arg1, arg2 )                   \
@@ -39,8 +43,18 @@
     { TBuf<512> __buf; __buf.Format(txt, arg1,arg2,arg3,arg4);     RDebug::Print( _L("[PCS] %S"), &__buf ); }
 #define PRINT5( txt, arg1, arg2, arg3, arg4, arg5 ) \
     { TBuf<512> __buf; __buf.Format(txt,arg1,arg2,arg3,arg4,arg5); RDebug::Print( _L("[PCS] %S"), &__buf ); }
+#define PRINT_BOOT_PERFORMANCE( txt )
+#define PRINT1_BOOT_PERFORMANCE( txt, arg1 )
 
-#else
+#endif // _DEBUG
+#endif // __WINS__
+
+//==============================================================================
+// armv5 udeb
+//------------------------------------------------------------------------------
+
+#ifndef __WINS__
+#ifdef _DEBUG
 
 #include <flogger.h>
 
@@ -48,6 +62,22 @@
 _LIT(KLogDir,         "Pcs");
 _LIT(KLogFile,        "PcsServer.txt");
 
+//#define __BOOT_PERFORMANCE
+#ifdef __BOOT_PERFORMANCE // Boot Peformance logs only
+
+#define PRINT( txt )
+#define PRINT1( txt, arg1 )
+#define PRINT2( txt, arg1, arg2 )
+#define PRINT3( txt, arg1, arg2, arg3 )
+#define PRINT4( txt, arg1, arg2, arg3, arg4 )
+#define PRINT5( txt, arg1, arg2, arg3, arg4, arg5 )
+#define PRINT_BOOT_PERFORMANCE( txt )                                \
+    RFileLogger::Write(KLogDir,KLogFile,EFileLoggingModeAppend,txt);
+#define PRINT1_BOOT_PERFORMANCE( txt, arg1 )                         \
+    RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1);
+
+#else
+
 #define PRINT( txt )                                \
     RFileLogger::Write(KLogDir,KLogFile,EFileLoggingModeAppend,txt);
 #define PRINT1( txt, arg1 )                         \
@@ -60,10 +90,19 @@
     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1,arg2,arg3,arg4);
 #define PRINT5( txt, arg1, arg2, arg3, arg4, arg5 ) \
     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1,arg2,arg3,arg4,arg5);
+#define PRINT_BOOT_PERFORMANCE( txt )
+#define PRINT1_BOOT_PERFORMANCE( txt, arg1 )
+
+#endif // __BOOT_PERFORMANCE
 
 #endif // __WINS__
+#endif // _DEBUG
 
-#else
+//==============================================================================
+// winscw urel AND armv5 urel
+//------------------------------------------------------------------------------
+
+#ifndef _DEBUG
 
 #define PRINT( txt )
 #define PRINT1( txt, arg1 )
@@ -71,23 +110,24 @@
 #define PRINT3( txt, arg1, arg2, arg3 )
 #define PRINT4( txt, arg1, arg2, arg3, arg4 )
 #define PRINT5( txt, arg1, arg2, arg3, arg4, arg5 )
+#define PRINT_BOOT_PERFORMANCE( txt )
+#define PRINT1_BOOT_PERFORMANCE( txt, arg1 )
 
 #endif // _DEBUG
 
+//==============================================================================
+
+
 #ifdef _DEBUG
-
 #define PRINTQUERY( txt, queryArg )         CPcsDebug::PrintQueryL(txt, queryArg);
 #define PRINTQUERYLIST( txt, queryListArg ) CPcsDebug::PrintQueryListL(txt, queryListArg);
 #define PRINTMATCHLOC( txt, matchLocsArg )  CPcsDebug::PrintMatchLoc(txt, matchLocsArg);
 #define PRINTMATCHSET( txt, matchSetArg )   CPcsDebug::PrintMatchSet(txt, matchSetArg);
-
 #else
-
 #define PRINTQUERY( txt, queryArg )
 #define PRINTQUERYLIST( txt, queryListArg )
 #define PRINTMATCHLOC( txt, matchLocsArg )
 #define PRINTMATCHSET( txt, matchSetArg )
-
 #endif // _DEBUG
 
 #define __LATENCY_MARK( str )     CPcsDebugWrapper::__LatencyMarkStartL(str);
--- a/predictivesearch/PcsUtils/src/CPcsDebug.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsUtils/src/CPcsDebug.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -150,7 +150,7 @@
 }
 
 // ----------------------------------------------------------------------------
-// CPcsDebug::PrintQuery
+// CPcsDebug::PrintQueryL
 // Prints the query as array of query items (query items cannot be spaces)
 // Used only for debugging
 // ----------------------------------------------------------------------------
@@ -158,19 +158,31 @@
 {
     for ( TInt i = 0; i < aQuery.Count(); i++ )
     {
-        TUint inputKey = aQuery.GetItemAtL(i).Character().GetUpperCase();
+        CPsQueryItem& item = aQuery.GetItemAtL(i);
+        TUint inputKey = item.Character().GetUpperCase();
         TBuf<2> buffer;
         buffer.Format(_L("%c"), inputKey);
-        switch ( aQuery.GetItemAtL(i).Mode() )
+        switch ( item.Mode() )
         {
-            case EItut:
-                PRINT3 ( _L("%SQuery[%d].{Character.Up=%S, Mode=EItut}"), &aPreTxt, i, &buffer);
+            case ENonPredictive:
+                PRINT3 ( _L("%SQuery[%d].{Character.Up=%S, Mode=ENonPredictive}"),
+                         &aPreTxt, i, &buffer);
+                break;
+            case EPredictiveDefaultKeyboard:
+                PRINT3 ( _L("%SQuery[%d].{Character.Up=%S, Mode=EPredictiveDefaultKeyboard}"),
+                         &aPreTxt, i, &buffer);
                 break;
-            case EQwerty:
-                PRINT3 ( _L("%SQuery[%d].{Character.Up=%S, Mode=EQwerty}"), &aPreTxt, i, &buffer);
-                break;          
+            case EPredictiveItuT:
+                PRINT3 ( _L("%SQuery[%d].{Character.Up=%S, Mode=EPredictiveItuT}"),
+                         &aPreTxt, i, &buffer);
+                break;
+            case EPredictiveQwerty:
+                PRINT3 ( _L("%SQuery[%d].{Character.Up=%S, Mode=EPredictiveQwerty}"),
+                         &aPreTxt, i, &buffer);
+                break;
             default:
-                PRINT3 ( _L("%SQuery[%d].{Character.Up=%S, Mode=EModeUndefined}"), &aPreTxt, i, &buffer);
+                PRINT4 ( _L("%SQuery[%d].{Character.Up=%S, Mode=%d (Error}"),
+                         &aPreTxt, i, &buffer, item.Mode());
                 break;
         }
     }
--- a/predictivesearch/PcsUtils/src/CPsData.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsUtils/src/CPsData.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -24,6 +24,7 @@
 
 #include "CPsData.h"
 #include "CPcsDefs.h"
+
 // ============================== MEMBER FUNCTIONS ============================
 
 
@@ -324,7 +325,7 @@
         if( !compareRes )
             {
             break;
-			}
+            }
         }
     return compareRes;
 }
@@ -342,18 +343,17 @@
 	
 	return EFalse;
 }
-				     
+
 
 // ----------------------------------------------------------------------------
 // CPsData::IsDataMatch
 // Return TRUE if data is matched for predictive search
 // ----------------------------------------------------------------------------		
 EXPORT_C TBool CPsData::IsDataMatch(TInt aIndex)
-{	
-    TReal val;
-	Math::Pow(val, 2, aIndex);
-
-	return(iDataMatches & (TUint8)val);
+{
+    __ASSERT_DEBUG( aIndex < 8, User::Panic( _L("CPsData"), KErrOverflow ) );
+    TUint8 val = 1 << aIndex;
+    return (iDataMatches & val);
 }
 
 // ----------------------------------------------------------------------------
@@ -370,11 +370,10 @@
 // 
 // ----------------------------------------------------------------------------
 EXPORT_C void CPsData::SetDataMatch(TInt aIndex)
-{	
-    TReal val;
-	Math::Pow(val, 2, aIndex);
-
-	iDataMatches |= (TUint8)val;
+{
+    __ASSERT_DEBUG( aIndex < 8, User::Panic( _L("CPsData"), KErrOverflow ) );
+    TUint8 val = 1 << aIndex;
+    iDataMatches |= val;
 }
 
 // ----------------------------------------------------------------------------
--- a/predictivesearch/PcsUtils/src/CPsQuery.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/PcsUtils/src/CPsQuery.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -178,7 +178,7 @@
 }
 
 // ----------------------------------------------------------------------------
-// Deprecated: Use CPcsDebug::PrintQuery 
+// Deprecated: Use CPcsDebug::PrintQuery
 // CPsQuery::PrintQuery
 // Prints the query as array of query items (query items cannot be spaces)
 // Used only for debugging
@@ -193,14 +193,25 @@
 		buffer.Format(_L("%c"), inputKey);
 	    switch(iSearchQuery[i]->Mode())
 	    {
-	    	case EItut:
-	    	    PRINT2 ( _L("Character at index %d: '%S' (ITU-T)"), i, &buffer);
+	    	case EPredictiveDefaultKeyboard:
+	    	    PRINT2 ( _L("Character at index %d: '%S' (EPredictiveDefaultKeyboard)"),
+	    	             i, &buffer);
+	    	    break;
+	    	case ENonPredictive:
+	    	    PRINT2 ( _L("Character at index %d: '%S' (ENonPredictive)"),
+	    	             i, &buffer);
 	    	    break;
-	    	case EQwerty:
-                PRINT2 ( _L("Character at index %d: '%S' (QWERTY)"), i, &buffer);
-	    	    break;	    	
+	    	case EPredictiveItuT:
+	    	    PRINT2 ( _L("Character at index %d: '%S' (EPredictiveItuT)"),
+	    	             i, &buffer);
+	    	    break;
+	    	case EPredictiveQwerty:
+	    	    PRINT2 ( _L("Character at index %d: '%S' (EPredictiveQwerty)"),
+	    	             i, &buffer);
+	    	    break;
 	    	default:
-                PRINT2 ( _L("Character at index %d: '%S' (mode=?)"), i, &buffer);
+	    	    PRINT3 ( _L("Character at index %d: '%S' (mode=%d)"),
+	    	             i, &buffer, iSearchQuery[i]->Mode());
 	    	    break;
 	    }
 	}
@@ -213,7 +224,7 @@
 EXPORT_C void CPsQuery::ExternalizeL(RWriteStream& aStream) const
 {	
     aStream.WriteUint8L(iSearchQuery.Count()); // Number of query items
-	for ( int index = 0; index < iSearchQuery.Count(); index++ )
+	for ( TInt index = 0; index < iSearchQuery.Count(); index++ )
 	{
 		(iSearchQuery[index])->ExternalizeL(aStream);
 	}
@@ -229,7 +240,7 @@
     TInt numQueryItems = aStream.ReadUint8L();
     
     // Internalize each item
-    for ( int index = 0; index < numQueryItems; index++ )
+    for ( TInt index = 0; index < numQueryItems; index++ )
     {
         CPsQueryItem *item = CPsQueryItem::NewL();
         item->InternalizeL(aStream);
--- a/predictivesearch/adapters/contacts/src/cpcscontactstore.cpp	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/adapters/contacts/src/cpcscontactstore.cpp	Mon Mar 15 12:39:26 2010 +0200
@@ -792,6 +792,7 @@
 	   						
 	   	case EComplete:
 		    PRINT ( _L("Contacts Caching FINISHED") );
+		    PRINT_BOOT_PERFORMANCE ( _L("Contacts Caching FINISHED") );
 		    break;
     }
 }
--- a/predictivesearch/sis/makesis_udeb.bat	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/sis/makesis_udeb.bat	Mon Mar 15 12:39:26 2010 +0200
@@ -14,6 +14,5 @@
 rem Description:
 rem
 
-
 makesis pcs_udeb.pkg
-signsis pcs_udeb.sis  pcs.sisx rd.cer rd-key.pem
+signsis pcs_udeb.sis pcs_udeb.sisx rd.cer rd-key.pem
--- a/predictivesearch/sis/makesis_urel.bat	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/sis/makesis_urel.bat	Mon Mar 15 12:39:26 2010 +0200
@@ -30,7 +30,7 @@
 @echo on
 
 makesis cenrep.pkg
-signsis cenrep.sis  cenrep.sisx rd.cer rd-key.pem
+signsis cenrep.sis cenrep.sisx rd.cer rd-key.pem
 
 makesis pcs_urel.pkg
-signsis pcs_urel.sis  pcs.sisx rd.cer rd-key.pem
+signsis pcs_urel.sis pcs_urel.sisx rd.cer rd-key.pem
Binary file predictivesearch/sis/psengine_stub.SIS has changed
--- a/predictivesearch/sis/psengine_stub.pkg	Fri Mar 12 15:41:25 2010 +0200
+++ b/predictivesearch/sis/psengine_stub.pkg	Mon Mar 15 12:39:26 2010 +0200
@@ -37,4 +37,5 @@
 
 ""-"z:\resource\plugins\pscontactdatastore.r*"
 ""-"z:\resource\plugins\PcsAlgorithm1.r*"
+""-"z:\resource\plugins\PcsAlgorithm2.r*"
 ""-"z:\resource\contactsort.r*"