Revision: 201035 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 15 Sep 2010 11:52:37 +0300
branchRCL_3
changeset 73 c8382f7b54ef
parent 70 968773a0b6ef
child 80 726fba06891a
Revision: 201035 Kit: 201036
emailcontacts/contactactionservice/src/cfscactionutils.cpp
emailservices/emailframework/commonlib/inc/mmrinfoobject.h
emailservices/emailstore/base_plugin/BWINS/basepluginU.DEF
emailservices/emailstore/base_plugin/EABI/basepluginU.DEF
emailservices/emailstore/base_plugin/inc/BaseMrInfoObject.h
emailservices/emailstore/base_plugin/src/BaseMrInfoObject.cpp
emailservices/emailstore/base_plugin/src/baseplugintranslator.cpp
emailuis/emailui/data/FreestyleEmailUi.rss
emailuis/emailui/data/iconlist.txt
emailuis/emailui/inc/FreestyleEmailUiCLSListsHandler.h
emailuis/emailui/inc/FreestyleEmailUiContactHandler.h
emailuis/emailui/inc/FreestyleEmailUiLayoutHandler.h
emailuis/emailui/inc/FreestyleEmailUiTextureManager.h
emailuis/emailui/inc/FreestyleEmailUiUtilities.h
emailuis/emailui/inc/ncsaddressinputfield.h
emailuis/emailui/inc/ncsaifeditor.h
emailuis/emailui/inc/ncscomposeviewcontainer.h
emailuis/emailui/inc/ncseditor.h
emailuis/emailui/inc/ncsheadercontainer.h
emailuis/emailui/inc/ncspopuplistbox.h
emailuis/emailui/inc/ncssubjectfield.h
emailuis/emailui/src/FreestyleEmailUiCLSListsHandler.cpp
emailuis/emailui/src/FreestyleEmailUiContactHandler.cpp
emailuis/emailui/src/FreestyleEmailUiFolderListVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp
emailuis/emailui/src/FreestyleEmailUiLayoutHandler.cpp
emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiSearchListVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiTextureManager.cpp
emailuis/emailui/src/FreestyleEmailUiUtilities.cpp
emailuis/emailui/src/FreestyleEmailUiViewBase.cpp
emailuis/emailui/src/OverlayControl.cpp
emailuis/emailui/src/ncsaddressinputfield.cpp
emailuis/emailui/src/ncsaifeditor.cpp
emailuis/emailui/src/ncscomposeview.cpp
emailuis/emailui/src/ncscomposeviewcontainer.cpp
emailuis/emailui/src/ncseditor.cpp
emailuis/emailui/src/ncsheadercontainer.cpp
emailuis/emailui/src/ncspopuplistbox.cpp
emailuis/emailui/src/ncssubjectfield.cpp
emailuis/uicomponents/bwins/fs_generic_alfu.def
emailuis/uicomponents/eabi/fs_generic_alfU.def
emailuis/uicomponents/inc/fscontrolbuttonvisualiser.h
emailuis/uicomponents/inc/fsmultilineitemvisualizer.h
emailuis/uicomponents/inc/fsseparatorvisualizer.h
emailuis/uicomponents/inc/fstreeitemvisualizer.h
emailuis/uicomponents/inc/fstreeitemvisualizerbase.h
emailuis/uicomponents/inc/fstreelist.h
emailuis/uicomponents/inc/fstreenodevisualizerbase.h
emailuis/uicomponents/inc/fstreeplainonelineitemvisualizer.h
emailuis/uicomponents/inc/fstreeplainonelinenodevisualizer.h
emailuis/uicomponents/inc/fstreeplainrootvisualizer.h
emailuis/uicomponents/inc/fstreeplaintwolineitemvisualizer.h
emailuis/uicomponents/inc/fstreerichitemvisualizer.h
emailuis/uicomponents/inc/fstreevisualizerbase.h
emailuis/uicomponents/src/fscontrolbutton.cpp
emailuis/uicomponents/src/fscontrolbuttonvisualiser.cpp
emailuis/uicomponents/src/fsmultilineitemvisualizer.cpp
emailuis/uicomponents/src/fsseparatorvisualizer.cpp
emailuis/uicomponents/src/fstreeitemvisualizerbase.cpp
emailuis/uicomponents/src/fstreelist.cpp
emailuis/uicomponents/src/fstreenodevisualizerbase.cpp
emailuis/uicomponents/src/fstreeplainonelineitemvisualizer.cpp
emailuis/uicomponents/src/fstreeplainonelinenodevisualizer.cpp
emailuis/uicomponents/src/fstreeplainrootvisualizer.cpp
emailuis/uicomponents/src/fstreeplaintwolineitemvisualizer.cpp
emailuis/uicomponents/src/fstreerichitemvisualizer.cpp
emailuis/uicomponents/src/fstreevisualizerbase.cpp
ipsservices/ipssosplugin/inc/ipsplgmsgmapper.h
ipsservices/ipssosplugin/src/ipsplgmrulist.cpp
ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp
ipsservices/ipssosplugin/src/ipsplgsmtpoperation.cpp
ipsservices/ipssossettings/data/ipssetuimailsettings.ra
ipsservices/ipssossettings/loc/ipssossettings.loc
ipsservices/ipssossettings/src/ipssetdata.cpp
ipsservices/tsrc/profiletester/src/popimapprofiletester.cpp
meetingrequest/mricalviewer/src/cesmrmrinfoicalretriever.cpp
--- a/emailcontacts/contactactionservice/src/cfscactionutils.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailcontacts/contactactionservice/src/cfscactionutils.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -1246,11 +1246,18 @@
 
     if ( fieldFilter->FieldCount() == 1 )
         {
-        MVPbkStoreContactField* field = fieldFilter->FieldAtLC( 0 );
         if ( aAddSpace && aContact.Length() > 0 )
             {
-            aContact.Append( KSpace );
+            if ( aContact.Length() < KMaxLengthOfName )
+                {
+                aContact.Append( KSpace );
+                }
+            else
+                {
+                User::Leave( KErrOverflow );
+                }
             }
+        MVPbkStoreContactField* field = fieldFilter->FieldAtLC( 0 );
         TPtrC castFieldText = MVPbkContactFieldTextData::Cast( 
                 field->FieldData() ).Text();
 
@@ -1259,9 +1266,8 @@
             User::Leave( KErrOverflow );
             }
 
-        aContact.Append( MVPbkContactFieldTextData::Cast(
-                field->FieldData() ).Text() );
-        CleanupStack::PopAndDestroy(); // field
+        aContact.Append( castFieldText );
+        CleanupStack::PopAndDestroy( field );
         }
     CleanupStack::PopAndDestroy( 2 ); // fieldFilter, fieldTypeSelector    
     }
--- a/emailservices/emailframework/commonlib/inc/mmrinfoobject.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailservices/emailframework/commonlib/inc/mmrinfoobject.h	Wed Sep 15 11:52:37 2010 +0300
@@ -78,6 +78,8 @@
         EESMRInfoFieldRecurrence,
         /** Priority field */
         EESMRInfoFieldPriority,
+        /** Privacy field */
+        EESMRInfoFieldPrivacy
         };
 
     /** Definition for meeting request method */
@@ -91,12 +93,21 @@
         EMRMethodResponse
         };
 
-	enum TResponse
-		{     
-      		EMrCmdResponseAccept,
-			EMrCmdResponseTentative,
-			EMrCmdResponseDecline
-		};    
+    enum TResponse
+        {     
+            EMrCmdResponseAccept,
+            EMrCmdResponseTentative,
+            EMrCmdResponseDecline
+        };
+
+    /** MFE Client Protocol indicates the sensitivity for a meeting request. */	
+    enum TCalSensitivity
+        {
+        EMRSensitivityNormal,
+        EMRSensitivityPersonal,
+        EMRSensitivityPrivate,
+        EMRSensitivityConfidential
+        };
 
 public: // Destruction
 
@@ -324,6 +335,20 @@
      * @exception KErrNotFound, if field cannot be fetched.
      */
     virtual TUint PriorityL() const = 0;
+
+    /**
+     * Sets MR privacy.
+     * @param aPrivacy MR privacy.
+     * @exception System wide error code.
+     */    
+    virtual void SetPrivacyL( TCalSensitivity aPrivacy ) = 0;
+        
+    /**
+     * Fetches MR privacy.
+     * @return MR privacy.
+     * @exception KErrNotFound, if field cannot be fetched.
+     */
+    virtual TCalSensitivity PrivacyL() const = 0;
     
     /**
      * Fetches meeting request attachments.
--- a/emailservices/emailstore/base_plugin/BWINS/basepluginU.DEF	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailservices/emailstore/base_plugin/BWINS/basepluginU.DEF	Wed Sep 15 11:52:37 2010 +0300
@@ -195,4 +195,6 @@
 	?CalendarFileName@CBasePlugin@@MBEABVTDesC16@@XZ @ 194 NONAME ; class TDesC16 const & CBasePlugin::CalendarFileName(void) const
 	?StartOp@CDelayedOp@@QAEXXZ @ 195 NONAME ; void CDelayedOp::StartOp(void)
 	?DeleteDelayedOpsManager@CBasePlugin@@QAEXXZ @ 196 NONAME ; void CBasePlugin::DeleteDelayedOpsManager(void)
+	?PrivacyL@CBaseMrInfoObject@@UBE?AW4TCalSensitivity@MMRInfoObject@@XZ @ 197 NONAME ; enum MMRInfoObject::TCalSensitivity CBaseMrInfoObject::PrivacyL(void) const
+	?SetPrivacyL@CBaseMrInfoObject@@UAEXW4TCalSensitivity@MMRInfoObject@@@Z @ 198 NONAME ; void CBaseMrInfoObject::SetPrivacyL(enum MMRInfoObject::TCalSensitivity)
 
--- a/emailservices/emailstore/base_plugin/EABI/basepluginU.DEF	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailservices/emailstore/base_plugin/EABI/basepluginU.DEF	Wed Sep 15 11:52:37 2010 +0300
@@ -299,4 +299,8 @@
 	_ZNK11CBasePlugin16CalendarFileNameEv @ 298 NONAME
 	_ZN10CDelayedOp7StartOpEv @ 299 NONAME
 	_ZN11CBasePlugin23DeleteDelayedOpsManagerEv @ 300 NONAME
+	_ZN17CBaseMrInfoObject11SetPrivacyLEN13MMRInfoObject15TCalSensitivityE @ 301 NONAME
+	_ZNK17CBaseMrInfoObject8PrivacyLEv @ 302 NONAME
+	_ZThn4_N17CBaseMrInfoObject11SetPrivacyLEN13MMRInfoObject15TCalSensitivityE @ 303 NONAME
+	_ZThn4_NK17CBaseMrInfoObject8PrivacyLEv @ 304 NONAME
 
--- a/emailservices/emailstore/base_plugin/inc/BaseMrInfoObject.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailservices/emailstore/base_plugin/inc/BaseMrInfoObject.h	Wed Sep 15 11:52:37 2010 +0300
@@ -303,6 +303,11 @@
             TTime aRecId );
         
         IMPORT_C TTime MRRecurrenceId() const;
+        
+        IMPORT_C void SetPrivacyL(
+            TCalSensitivity aPrivacyL );
+            
+        IMPORT_C TCalSensitivity PrivacyL() const;
 
 
     protected:
@@ -314,7 +319,7 @@
         HBufC* iUid;
         HBufC* iLocation;
         HBufC* iSubject;
-        HBufC* iDescription;        
+        HBufC* iDescription;
         TTime iCreationTime;
         TTime iStartTime;
         TTime iEndTime;
@@ -322,6 +327,7 @@
         TTime iRecurrenceId;
         TInt iSequenceNumber;
         TUint iPriority;
+        TCalSensitivity iPrivacy;
         TMRMethod iMethod;
         TResponse iResponse;
     };
--- a/emailservices/emailstore/base_plugin/src/BaseMrInfoObject.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/BaseMrInfoObject.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -82,6 +82,7 @@
     
     iSequenceNumber = aMrInfo.MRSequenceNumberL();
     iPriority = aMrInfo.PriorityL();
+    iPrivacy = aMrInfo.PrivacyL();
 
     iOrganizer = CBaseMrAttendee::NewL( aMrInfo.MROrganizerL() );
     
@@ -1133,3 +1134,20 @@
         }
     	
     } //ReplyToMeetingRequestL.
+
+/**
+ *
+ */
+EXPORT_C void CBaseMrInfoObject::SetPrivacyL( MMRInfoObject::TCalSensitivity aPrivacyL )
+    {
+    iPrivacy = aPrivacyL;
+    }
+
+
+/**
+ *
+ */
+EXPORT_C MMRInfoObject::TCalSensitivity CBaseMrInfoObject::PrivacyL() const
+    {
+    return iPrivacy;
+    }
--- a/emailservices/emailstore/base_plugin/src/baseplugintranslator.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/baseplugintranslator.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -496,13 +496,14 @@
         TUint32 priority = aCalendar.PropertyValueUint32L( idx );
         mmrInfo->SetPriorityL( priority );
         }
-        
-    /**@ privacy/sensitivity missing ? */
-    /*idx = 0;
+
+    //privacy/sensitivity
+    idx = 0;
     if ( aCalendar.FindProperty( KMsgStorePropertyMrPrivate, idx ) )
         {
-        TBool private = aCalendar.PropertyValueBoolL( idx );
-        }*/
+        TUint32 privacy = aCalendar.PropertyValueUint32L( idx );
+        mmrInfo->SetPrivacyL( static_cast<MMRInfoObject::TCalSensitivity>( privacy ) );
+        }
 
     //method.
     idx = 0;
@@ -1025,12 +1026,9 @@
     calendar->AddOrUpdatePropertyL(
         KMsgStorePropertyMrPriority, static_cast<TUint32>( aSrc.PriorityL() ) );
 
-    /**@ privacy/sensitivity missing ? */
-    /*idx = 0;
-    if ( aCalendar.FindProperty( KMsgStorePropertyMrPrivate, idx ) )
-        {
-        TBool private = aCalendar.PropertyValueBoolL( idx );
-        }*/
+    //privacy/sensitivity
+    calendar->AddOrUpdatePropertyL(
+            KMsgStorePropertyMrPrivate, static_cast<TUint32>( aSrc.PrivacyL() ) );
 
     //recurrent count.
     calendar->AddOrUpdatePropertyL(
--- a/emailuis/emailui/data/FreestyleEmailUi.rss	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/data/FreestyleEmailUi.rss	Wed Sep 15 11:52:37 2010 +0300
@@ -1210,7 +1210,7 @@
 RESOURCE TBUF r_freestyle_email_ui_griditem_weather			{ buf=qtn_fsemail_griditem_weather; }
 RESOURCE TBUF r_freestyle_email_ui_griditem_settings { buf=qtn_fse_launcher_settings; }
 RESOURCE TBUF r_freestyle_email_ui_griditem_add_new_mailbox { buf=qtn_fse_launcher_add_new_mailbox; }
-RESOURCE TBUF r_freestyle_email_ui_griditem_help { buf=qtn_fse_launcher_help; }
+RESOURCE TBUF r_freestyle_email_ui_griditem_help { buf=qtn_options_help; }
 
 // ITEM IN MAIL VIEWER
 RESOURCE TBUF r_freestyle_email_ui_viewer_from					{ buf=qtn_fse_viewer_header_from; }
--- a/emailuis/emailui/data/iconlist.txt	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/data/iconlist.txt	Wed Sep 15 11:52:37 2010 +0300
@@ -195,4 +195,5 @@
 -c16,8 qgn_indi_tb_show_bcc.svg
 -c16,8 qgn_indi_tb_hide_bcc.svg
 -c16,8 qgn_indi_tb_extension.svg
--c16,8 cmail_marking_mode_bg.svg
+-c16,8 qgn_prop_checkbox_on.svg
+-c16,8 qgn_prop_checkbox_off.svg
--- a/emailuis/emailui/inc/FreestyleEmailUiCLSListsHandler.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/inc/FreestyleEmailUiCLSListsHandler.h	Wed Sep 15 11:52:37 2010 +0300
@@ -162,8 +162,8 @@
      */
 	TBool ReadCLSInfoFromMRUListIndexL( MDesCArray& aTextArray,
 										CFSEmailUiClsItem& aClsItem,
-										const TInt aCurrentMatchIndex,
-										const TInt aPreviousMatchIndex );
+										TInt aCurrentMatchIndex,
+										TInt aPreviousMatchIndex );
 
     /**
      * Searches given cls item from the given list. If duplicate is found, it is returned.
--- a/emailuis/emailui/inc/FreestyleEmailUiContactHandler.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/inc/FreestyleEmailUiContactHandler.h	Wed Sep 15 11:52:37 2010 +0300
@@ -259,15 +259,13 @@
 	 * @param aObserver = observer to collect results
 	 */
 	void GetAddressesFromPhonebookL( MFSEmailUiContactHandlerObserver* aObserver );
-	
-    // <cmail> video call
+
     /**
      * Enables/disables video call.
      *
      * @param aState ETrue for 'enable', EFalse for 'disable'
      */
     void SetVideoCall( TBool aState );
-    // </cmail>
 
 // from base class MFSEmailUiClsListsObserver
 
@@ -277,18 +275,14 @@
 // from base class MVPbkSingleContactOperationObserver
 
     void VPbkSingleContactOperationCompleteL(
-    		    MVPbkContactOperationBase& aOperation,
-    		    MVPbkStoreContact* aContact );
-    
-    
-	void VPbkSingleContactOperationComplete(
-	    MVPbkContactOperationBase& aOperation,
-	    MVPbkStoreContact* aContact );
-	
-	void VPbkSingleContactOperationFailedL(
-		    MVPbkContactOperationBase& aOperation, TInt aError );
-	void VPbkSingleContactOperationFailed(
-	    MVPbkContactOperationBase& aOperation, TInt aError );
+        MVPbkContactOperationBase& aOperation, MVPbkStoreContact* aContact );
+    void VPbkSingleContactOperationComplete(
+        MVPbkContactOperationBase& aOperation, MVPbkStoreContact* aContact );
+
+    void VPbkSingleContactOperationFailedL(
+        MVPbkContactOperationBase& aOperation, TInt aError );
+    void VPbkSingleContactOperationFailed(
+        MVPbkContactOperationBase& aOperation, TInt aError );
 
 // from base class MVPbkContactStoreListObserver
 
@@ -346,6 +340,12 @@
 // from MCCAObserver      
     void CCASimpleNotifyL( TNotifyType aType, TInt aReason );
       
+    TUid GetDetailsViewUid();
+    TUid GetDetailsAppUid();
+    TBool WasDetailsClosed();
+    void CloseContactDetailsL();
+    void ReopenContactDetailsL(RWsSession&);
+
 private:
     
     CFSEmailUiContactHandler( RFs& aSession );
@@ -354,18 +354,21 @@
     
 // <cmail> call observer's MFSEmailUiContactHandlerObserver::OperationErrorL( TContactHandlerCmd aCmd, TInt aError ) 
     void ObserverOperationErrorL( TContactHandlerCmd aCmd, TInt aErrorCode );
-    
 
 private:
-    
-	TInt SelectBetweenCsAndVoip() const;
+
+    TInt SelectBetweenCsAndVoip() const;
     void HandleCallL( const RPointerArray<CFSEmailUiClsItem>& aMatchingItems );
-    
-	void CreateMessageL( const RPointerArray<CFSEmailUiClsItem>& aMatchingItems );
-	void SendMessageL( CAiwGenericParamList& aEventParamList, TInt aServiceType );
- 	void GetSmsAddressFromPhonebookAndSendL( MVPbkContactLink* aContactLink );
-	void GetMmsAddressFromPhonebookAndSendL( MVPbkContactLink* aContactLink, TBool aIsVoiceMessage = EFalse );
- 
+
+    void CreateMessageL( const RPointerArray<CFSEmailUiClsItem>& aMatchingItems );
+    void SendMessageL( CAiwGenericParamList& aEventParamList, TInt aServiceType );
+    void GetSmsAddressFromPhonebookAndSendL( MVPbkContactLink* aContactLink );
+    void GetMmsAddressFromPhonebookAndSendL( MVPbkContactLink* aContactLink,
+        TBool aIsVoiceMessage = EFalse );
+
+    // Starts retrieving addresses from contact stores.
+    void RetrieveContactsL();
+
     TBool IsRemoteLookupSupported();
     
     void GetContactFieldsL( RArray<TInt>& aFieldIds, RPointerArray<HBufC>& aNumbers, 
@@ -456,6 +459,9 @@
     // Flag for making video call
     TBool iVideoCall;
 
+    // flag to check if it was remotely closed (using CloseContactDetailsL method)
+    TBool iContactDetailsClosed;
+    
     // connection to CCMA launcher    
     MCCAConnection* iConnection;
 
--- a/emailuis/emailui/inc/FreestyleEmailUiLayoutHandler.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/inc/FreestyleEmailUiLayoutHandler.h	Wed Sep 15 11:52:37 2010 +0300
@@ -239,6 +239,7 @@
 		//To retrieve respecitve Icon Sizes
 		TInt ListTextureNodeExpandedSize() const;
 		TInt SearchLookingGlassIconSize() const;
+		TInt SearchMarkIconSize() const;
 		TSize statusPaneIconSize() const;
 		TInt ListControlBarMailboxDefaultIconSize() const;
 		TInt EMailListBarBgIconSize() const;
--- a/emailuis/emailui/inc/FreestyleEmailUiTextureManager.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/inc/FreestyleEmailUiTextureManager.h	Wed Sep 15 11:52:37 2010 +0300
@@ -56,7 +56,8 @@
 	EBackgroundTextureBar,
 	EBackgroundTextureThumb,
 	EBackgroundTextureMailList,
-	EListControlMarkIcon,
+	EListControlMarkOnIcon,
+	EListControlMarkOffIcon,	
 	EListControlMenuIcon,
 	EMailListBarBgIcon,
 	ESearchLookingGlassIcon,
@@ -224,8 +225,6 @@
 	EAttachmentsSaveAll,
 	EAttachmentsCancelAll,
 	EAttachmentsViewAll,
-	
-    EMarkingModeBackgroundIcon,
     
 	// TEXTURE COUNT
 	ETextureCount,
@@ -287,9 +286,6 @@
 	// Get new mail list separator brush	
 	// Ownership IS transferred to caller.
 	CAlfFrameBrush* NewMailListSeparatorBgBrushLC();
-	// Get marking mode background brush	
-	// Ownership IS transferred to caller.
-	CAlfImageBrush* NewMailListMarkingModeBgBrushLC();
 	// Get new mail list separator brush	
     // Ownership IS transferred to caller.
 	CAlfImageBrush* NewControlBarListBgBrushLC();
--- a/emailuis/emailui/inc/FreestyleEmailUiUtilities.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/inc/FreestyleEmailUiUtilities.h	Wed Sep 15 11:52:37 2010 +0300
@@ -287,6 +287,11 @@
      */
     static TBool IsChineseWord( const TDesC& aWord );
     
+    /**
+     * Determines if the descriptor is a Korean word
+     */
+    static TBool IsKoreanWord( const TDesC& aWord );
+    
     // Get the icon file name including the drive letter and full path
     static void GetFullIconFileNameL( TDes& aFileName );
     
--- a/emailuis/emailui/inc/ncsaddressinputfield.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/inc/ncsaddressinputfield.h	Wed Sep 15 11:52:37 2010 +0300
@@ -126,7 +126,7 @@
         
     const RPointerArray<CNcsEmailAddressObject>& GetAddressesL( TBool aParseNow=ETrue );
         
-    void GetLineRectL( TRect& aLineRect ) const;
+    void GetLineRect( TRect& aLineRect ) const;
         
     void SetMaxLabelLength( TInt aMaxLength );
         
--- a/emailuis/emailui/inc/ncsaifeditor.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/inc/ncsaifeditor.h	Wed Sep 15 11:52:37 2010 +0300
@@ -137,6 +137,7 @@
         RPointerArray<CNcsAifEntry>& aEntries,
         TBool aDisplayList = ETrue ) const;
 
+    TInt RepositionEntries( const CNcsAifEntry* aEntry );
     void RepositionEntriesL( const CNcsAifEntry* aEntry );
 
     void CheckAndRemoveInvalidEntriesL();
@@ -168,13 +169,25 @@
      * @return  ETrue   if terminated recipient entry was found and added to array. 
      */
     TBool HandleTextUpdateL( const TCursorSelection& aSelection );
+    // Moves inputted non-entry text to separate rows apart from entries.
+    void MoveNonEntryTextToDedicatedRowsL( TUint aPosition );
+    // Prepares for text input to given cursor position.
+    void PrepareForTextInputL( TUint aPosition );
     void HandleNavigationEventL();
+
+    // Gets non-entry text at given document position.
     TCursorSelection NonEntryTextAtPos( TUint aPosition ) const;
+    // Gets non-entry text including surrounding whitespace at given position.
+    TCursorSelection NonEntryTextAndSpaceAtPos( TUint aPosition ) const;
+    // Gets non-enty text right before given document position.
     TCursorSelection NonEntryTextBeforePos( TUint aPosition ) const;
+
     TBool IsSentinel( TChar aCharacter ) const;
+    TBool IsDelimiter( TChar aCharacter ) const;
     TBool IsWhitespace( TChar aCharacter ) const;
     TBool IsNavigationKey( const TKeyEvent& aKeyEvent ) const;
     TBool IsCharacterKey( const TKeyEvent& aKeyEvent ) const;
+
     void GetMatchingEntryCountsL( 
             const CNcsAifEntry* aEntry,
             TInt& aNrOfMatchesInText,
--- a/emailuis/emailui/inc/ncscomposeviewcontainer.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/inc/ncscomposeviewcontainer.h	Wed Sep 15 11:52:37 2010 +0300
@@ -100,6 +100,12 @@
     void UpdateScrollBar();
 
     /**
+    * Updates scroll visibility.
+    * @param aVisible Whether or not to set scroll bar visible.
+    */
+    void UpdateScrollBarVisibility( TBool aVisible );
+    
+    /**
     * GetToFieldAddressesL
     * Get addresses in TO-field.
     * @return Array of address objects.
@@ -491,8 +497,10 @@
     void HandleLayoutChangeL();
     
     void HandleSkinChangeL();
-    
+
     TInt ContentTotalHeight();
+    TInt VisibleAreaHeight();
+
     /**
     * CommitL
     * Commits changes to message
@@ -523,7 +531,7 @@
      * Called when text formatting was cancelled.
      */
     void FormatAllTextCancelled();
-    
+
     /**
      * Called when text formatting is complete. 
      */
@@ -634,13 +642,13 @@
     * @return Indicates whether the key event was used by this control.
     */
     TKeyResponse ChangeFocusL( const TKeyEvent& aKeyEvent );
-        
+
     /**
-    * UpdateScreenPositionL
+    * UpdateScreenPosition
     * @param aKeyCode Needed to recognize presses of the enter key
     *                 in moving of display.
     */
-    void UpdateScreenPositionL( const TUint& aKeyCode = EKeyNull );
+    void UpdateScreenPosition( const TUint& aKeyCode = EKeyNull );
 
     /**
      * CalculateSeparatorLineSecondaryColor
@@ -772,17 +780,18 @@
      * Currently processed field - needed by async text formatting.
      */
     CNcsEditor* iProcessedField;
-    
+
     /**
      * Async text formatter.
      * Own.
      */
     CFSAsyncTextFormatter* iAsyncTextFormatter;
-    
-    /**
-     * Pane rect calculated during ChangeSize.
-     */
+
+    // Cmail pane rect, calculated during SizeChanged.
     TRect iCmailPaneRect;
+    // Header origin, calculated during SizeChanged.
+    TPoint iHeaderPos;
+
     };
 
 
--- a/emailuis/emailui/inc/ncseditor.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/inc/ncseditor.h	Wed Sep 15 11:52:37 2010 +0300
@@ -54,7 +54,7 @@
     
     void OpenVirtualKeyBoardL();
     
-    void GetLineRectL( TRect& aLineRect ) const;
+    void GetLineRect( TRect& aLineRect ) const;
         
     virtual TInt ScrollableLines() const;
     
--- a/emailuis/emailui/inc/ncsheadercontainer.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/inc/ncsheadercontainer.h	Wed Sep 15 11:52:37 2010 +0300
@@ -27,19 +27,19 @@
 #include "ncsaddressinputfield.h"
 #include "ncsfieldsizeobserver.h"
 #include "ncsconstants.h"
-
+#include "ncspopuplistbox.h"
 
 class CFSMailBox;
 class CNcsAttachmentField;
 class CNcsEmailAddressObject;
-class CNcsPopupListBox;
 class CNcsSubjectField;
 class CAknPhysics;
 
 /**
 *  CNcsHeaderContainer
 */
-class CNcsHeaderContainer : public CCoeControl, public MNcsAddressPopupList
+class CNcsHeaderContainer : public CCoeControl, public MNcsAddressPopupList,
+    public MNcsPopupListBoxObserver
     {
 
 public:
@@ -73,27 +73,37 @@
 private: // constructor/destructor
 
     /**
-    * CNcsHeaderContainer
-    * C++ constructor.
-    * @param aParent Parent control.
-    * @param aMailBox reference to current mailbox item
-    */
-	CNcsHeaderContainer( CCoeControl& aParent, CFSMailBox& aMailBox, CAknPhysics* aPhysics );
-	
-	/**
-	* ConstructL
-	* 2nd phase constructor.
-	*/
-	void ConstructL( TInt aFlags );
+     * CNcsHeaderContainer
+     * C++ constructor.
+     * @param aParent Parent control.
+     * @param aMailBox reference to current mailbox item
+     */
+    CNcsHeaderContainer( CCoeControl& aParent, CFSMailBox& aMailBox, CAknPhysics* aPhysics );
+
+    /**
+     * ConstructL
+     * 2nd phase constructor.
+     */
+    void ConstructL( TInt aFlags );
 
 public: // function members
-	
-	/**
-	* GetToFieldAddressesL
-	* Get addresses in TO-field.
-	* @return Array of addresses.
-	*/
-	const RPointerArray<CNcsEmailAddressObject>& GetToFieldAddressesL( 
+
+    /**
+     * From MNcsPopupListBoxObserver.
+     */
+    TBool PopupVisibilityChangingL( TBool aVisible );
+
+    /**
+     * From MNcsPopupListBoxObserver.
+     */
+    void PopupItemSelectedL();
+
+    /**
+     * GetToFieldAddressesL
+     * Get addresses in TO-field.
+     * @return Array of addresses.
+     */
+    const RPointerArray<CNcsEmailAddressObject>& GetToFieldAddressesL( 
         TBool aParseNow = ETrue );
 
 	/**
@@ -347,18 +357,17 @@
     TBool IsAddressInputField( const CCoeControl* aControl ) const;
 
     TBool IsRemoteSearchInprogress() const;
-    
-    /**
-     * Shows/hides cursor.
-     * 
-     * @param aShow ETrue - shows, EFalse - hides cursor.
-     */
-    void ShowCursor( TBool aShow, TDrawNow aDrawNow = ENoDrawNow );
 
     void DoScroll();
-    
+    void DoScrollFocusToTop();
+
     void SetPhysicsEmulationOngoing( TBool aPhysOngoing );
     
+    virtual void HandleResourceChange( TInt aType );
+
+    // Set origin for header's top position.
+    void SetOrigin( TPoint& aPoint );
+
 private: // Function members
 
 	void FocusChanged(TDrawNow aDrawNow);
@@ -410,47 +419,47 @@
     
 private: // Data members
 
-    /*
-    * Parent window
-    * Not Own
-    */
+    // Parent window.
     CCoeControl& iParent;
 
     MNcsFieldSizeObserver& iFieldSizeObserver;
     
     CAknLongTapDetector*      iLongTapDetector;
-	
+
     CEikButtonGroupContainer* iMenuBar;
-    
+
     CNcsAddressInputField* iToField;
-
     CNcsAddressInputField* iCcField;
-
     CNcsAddressInputField* iBccField;
 
     CNcsSubjectField* iSubjectField;
 
     CNcsAttachmentField* iAttachmentField;
 
-	// The attachments count
+    // The attachments count
     TInt iAttachmentCount;
 
-	// Address popup data members
-	CNcsPopupListBox* iAacListBox;
+    // Popup for resently used email addressses. Own.
+    CNcsPopupListBox* iAacListBox;
 
-	CFSMailBox& iMailBox;
-	
+    CFSMailBox& iMailBox;
+
     //flag which disables changes of MSK label if any popup dialog is open
     TBool iSwitchChangeMskOff;
 
     TBool iLongTapEventConsumed;
     TBool iRALInProgress;
-    
+
     // Currently focused control
     CCoeControl* iFocused;
 
     // panning related
     CAknPhysics* iPhysics;
+
+    // Header containers default top left position.
+    TPoint iOrigin;
+
+    TBool iSplitScreenVKBEnabled;
     };
 
 
--- a/emailuis/emailui/inc/ncspopuplistbox.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/inc/ncspopuplistbox.h	Wed Sep 15 11:52:37 2010 +0300
@@ -30,40 +30,66 @@
 class CAknsFrameBackgroundControlContext;
 class CFSEmailUiContactHandler;
 class CFSMailBox;
-class CNcsHeaderContainer;
 class CFSEmailUiLayoutHandler;
-class CFreestyleEmailUiAppUi; //<cmail>
+class CFreestyleEmailUiAppUi;
 
 // CLASS DECLARATION
 
 /**
+ * Observer interface to notify observer of item selection events and changes
+ * in popup's visibility.
+ */
+class MNcsPopupListBoxObserver
+    {
+public:
+
+    /**
+     * Visibility of component is changing.
+     * @param aVisible ETrue, if popup is coming visible.
+     * @return Observer should return ETrue, if visiblity change is allowed.
+     */
+    virtual TBool PopupVisibilityChangingL( TBool aVisible ) = 0;
+
+    /**
+     * Popup item is selected.
+     */
+    virtual void PopupItemSelectedL() = 0;
+
+    };
+
+
+/**
 *  CNcsPopupListBox
 */
 class CNcsPopupListBox : public CEikTextListBox, 
                          public MEikListBoxObserver,
                          public MFSEmailUiContactHandlerObserver
     {
-public: // Constructors and destructor
-
-		/*
-		* @param aMailBox reference to current mailbox item
-		*/
-    static CNcsPopupListBox* NewL( const CCoeControl* aParent, CFSMailBox& aMailBox, 
-                                   CNcsHeaderContainer& aHeaderContainer,
-                                   TBool aRemoteLookupSupported );
+public:
 
     /*
-    * @param aMailBox reference to current mailbox item
-    */
+     * @param aMailBox reference to current mailbox item
+     */
+    static CNcsPopupListBox* NewL( const CCoeControl* aParent,
+        CFSMailBox& aMailBox, MNcsPopupListBoxObserver& aObserver,
+        TBool aRemoteLookupSupported );
+
+    /*
+     * @param aMailBox reference to current mailbox item
+     */
     void ConstructL( const CCoeControl* aParent );
 
     /*
-    * 
-    *
-    * @param aText
-    */
+     * Initialises popup and begins the search.
+     * @param aText Search text.
+     */
     void InitAndSearchL( const TDesC& aText, TInt aMode = -1 );
-		
+
+    /** 
+     * Hides the popup window.
+     */
+    void ClosePopupL();
+
     // Destructor
     virtual ~CNcsPopupListBox();
 
@@ -149,7 +175,7 @@
  
     void SetScrollBarVisibilityL();
 
-    void SetRemoteLookupItemFirstToTheListL();
+    void SetRemoteLookupItemToTheListL( TInt aIndex );
 		
     enum TRemoteLookupItemMoveDirection
         {
@@ -163,13 +189,14 @@
 
 private:
 
-    CNcsPopupListBox( CNcsHeaderContainer& aHeaderContainer,
-        TBool aRemoteLookupSupported, CFSMailBox& aMailbox );
+    CNcsPopupListBox( CFSMailBox& aMailbox,
+        MNcsPopupListBoxObserver& aObserver,
+        TBool aRemoteLookupSupported );
 
     virtual void CreateItemDrawerL();
 
     void UpdateListL();
-
+    void UpdateVisibilityL( TBool aVisible );
     void UpdateTextColors();
 
     // From CCoeControl.
@@ -177,25 +204,28 @@
 
 private: // data
 
-    CNcsHeaderContainer&				iHeaderContainer;
-
+    // Background control context. Own.
     CAknsFrameBackgroundControlContext* iBackgroundContext;
-
-    RPointerArray<CFSEmailUiClsItem>	iMatchingItems;
-
-    CFSEmailUiContactHandler*			iContactHandler; // Owned
-    CFSMailBox& 						iMailBox;
+    // Items matching the current searh string. Own.
+    RPointerArray<CFSEmailUiClsItem>    iMatchingItems;
 
-    TRect								iPopupMaxRect;
-    
-    CDesCArray*							iItemTextsArray;
-    HBufC*								iCurrentSearchText;
-    TInt								iRemoteLookupItemPos;
-    
-    TBool 								iRemoteLookupSupported;
-    TBool 								iCachingInProgress;
-    
-    CFreestyleEmailUiAppUi*             iAppUi;  //<cmail>  not owned
+    // Contact handler.
+    CFSEmailUiContactHandler*           iContactHandler;
+    CFSMailBox&                         iMailBox;
+    // Observer for popup visibility changes.
+    MNcsPopupListBoxObserver&           iObserver;
+    TRect                               iPopupMaxRect;
+
+    CDesCArray*                         iItemTextsArray;
+    // Current search text. Own.
+    HBufC*                              iCurrentSearchText;
+    TInt                                iRemoteLookupItemPos;
+
+    TBool                               iRemoteLookupSupported;
+    TBool                               iCachingInProgress;
+
+    CFreestyleEmailUiAppUi*             iAppUi; // not owned
+
     };
 
 
--- a/emailuis/emailui/inc/ncssubjectfield.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/inc/ncssubjectfield.h	Wed Sep 15 11:52:37 2010 +0300
@@ -29,6 +29,7 @@
 
 
 class CEikImage;
+class CAknButton;
 class MNcsFieldSizeObserver;
 class CNcsHeaderContainer;
 class CAknPhysics;
@@ -79,11 +80,9 @@
 
     const TDesC& GetLabelText() const;
     
-    // <cmail> Platform layout change       
     TInt LayoutLineCount() const;
-    // </cmail> Platform layout change    
     
-    void GetLineRectL( TRect& aLineRect ) const;
+    void GetLineRect( TRect& aLineRect ) const;
 
     void SetMaxLabelLength( TInt aMaxLength );
 
@@ -144,23 +143,25 @@
     
     void UpdateFontSize();
     
-    //<cmail>
     void HandlePointerEventL( const TPointerEvent& aPointerEvent );
-    //</cmail>
         
 private: // data
     
     CNcsHeaderContainer* iParentControl; // not owned
     
     /*
-    * text field
+    * label
     * Own
     */
     CNcsLabel* iLabel;
-        
-// <cmail> Platform layout changes
+    
+    /**
+     * button
+     * Own
+     */
+    CAknButton* iButton;
+
     const CFont* iFont; // not owned, needs to be released in the end
-// </cmail> Platform layout changes
     
     /*
     * text field
@@ -171,16 +172,10 @@
     TInt iEditorMinimumHeight;
             
     TInt iMaximumLabelLength;         
-      	
-    TRgb iBorderColor;
-    
-    TRgb iBgColor;
     
     TBool iDrawAfterFocusChange;
    
-// <cmail> Platform layout changes
     TInt iEditorLineCount;
-// </cmail> Platform layout changes
     };
 
 #endif // CNCSSUBJECTFIELD_H
--- a/emailuis/emailui/src/FreestyleEmailUiCLSListsHandler.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/FreestyleEmailUiCLSListsHandler.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -16,19 +16,17 @@
 */
 
 #include "emailtrace.h"
-#include <eikenv.h>									// CEikonEnv
-#include <centralrepository.h>						// CRepository
-#include <AknFepInternalCRKeys.h>					// KCRUidAknFep
-//<cmail>
-#include "cfsmailbox.h"								// cfsmailbox
-//</cmail>
+#include <eikenv.h>
+#include <centralrepository.h>
+#include <AknFepInternalCRKeys.h>
+#include "cfsmailbox.h"
 #include <CPsRequestHandler.h>
 #include <CPsSettings.h>
 #include <VPbkEng.rsg>
 
-#include "FreestyleEmailUiCLSListsHandler.h"		// CFSEmailUiClsListsHandler
-#include "FreestyleEMailUiCLSMatchObserverInterface.h"// CFSEmailUiClsContactMatchObserver
-#include "FreestyleEmailUiInputModeObserver.h"		// CFSEmailUiInputModeObserver
+#include "FreestyleEmailUiCLSListsHandler.h"
+#include "FreestyleEMailUiCLSMatchObserverInterface.h"
+#include "FreestyleEmailUiInputModeObserver.h"
 #include "FreestyleEmailUiUtilities.h"
 #include "FreestyleEmailUiCLSItem.h"
 
@@ -37,7 +35,7 @@
 // CFSEmailUiClsListsHandler::NewL
 // -----------------------------------------------------------------------------
 CFSEmailUiClsListsHandler* CFSEmailUiClsListsHandler::NewL( RFs& aFs,
-    CVPbkContactManager* aContactManager )
+        CVPbkContactManager* aContactManager )
 	{
     FUNC_LOG;
 	CFSEmailUiClsListsHandler* object = 
@@ -49,10 +47,12 @@
 // -----------------------------------------------------------------------------
 // CFSEmailUiClsListsHandler::NewLC
 // -----------------------------------------------------------------------------
-CFSEmailUiClsListsHandler* CFSEmailUiClsListsHandler::NewLC( RFs& aFs, CVPbkContactManager* aContactManager )
+CFSEmailUiClsListsHandler* CFSEmailUiClsListsHandler::NewLC( 
+        RFs& aFs, CVPbkContactManager* aContactManager )
 	{
     FUNC_LOG;
-	CFSEmailUiClsListsHandler* object = new (ELeave) CFSEmailUiClsListsHandler( aFs, aContactManager );
+	CFSEmailUiClsListsHandler* object = 
+	        new (ELeave) CFSEmailUiClsListsHandler( aFs, aContactManager );
 	CleanupStack::PushL( object );
 	object->ConstructL();
 	return object;
@@ -85,52 +85,55 @@
     const RPointerArray<CFSEmailUiClsItem>& aMatches )
 	{
     FUNC_LOG;
-	for( TInt i = 0 ; i < aMatches.Count() ; ++i )
+
+    TInt matchCount = aMatches.Count();
+	for( TInt i = 0 ; i < matchCount ; ++i )
 		{
-		if( aMatches[i]->IsMruItem() )
-			{
-			// If this is MRU item, we need to check that it doesn't 
-			// already exist in iMatchingCompleteContacts
-			TInt itemIndex = FindDuplicate( *aMatches[i], iMatchingCompleteContacts );
-			if( itemIndex == KErrNotFound )
-				{
-				iMatchingMRUContacts.AppendL( aMatches[i] );
-				}
-			
-			}
-		else if( aMatches[i]->EmailAddress().Length() > 0 )
-			{
-			// If this is Phonebook item, we need to check that it doesn't 
-			// already exist in iMatchingMRUContacts
-			TInt itemIndex = FindDuplicate( *aMatches[i], iMatchingMRUContacts );
-			if( itemIndex != KErrNotFound )
-				{
-				// Found, this needs to be removed from the MRU list
-				iMatchingMRUContacts.Remove( itemIndex );
-				}
-
-			// Phonebook items are always added to the top of the list
-			iMatchingCompleteContacts.AppendL( aMatches[i] );
-			}
-		else
-			{
-			// No email, nothing to compare, so add this always to the end of the list
-			iMatchingMissingEmailContacts.AppendL( aMatches[i] );
-			}
-		}
-		
-    RPointerArray<CFSEmailUiClsItem> allMatches = ConstructOneListL( iMatchingCompleteContacts,
-                                                                      iMatchingMRUContacts,
-                                                                      iMatchingMissingEmailContacts );
+        if( aMatches[i]->IsMruItem() )
+            {
+            // MRU items are added to iMatchingMRUContacts and any already
+            // added duplicate is removed from iMatchingCompleteContacts
+            iMatchingMRUContacts.AppendL( aMatches[i] );
+            TInt itemIndex = FindDuplicate( *aMatches[i], 
+                    iMatchingCompleteContacts );
+            if ( KErrNotFound != itemIndex )
+                {
+                iMatchingCompleteContacts.Remove( itemIndex );
+                }
+            }
+        else if( aMatches[i]->EmailAddress().Length() > 0 )
+            {
+            // For Phonebook items, it is checked that it there doesn't 
+            // already exist a duplicate in iMatchingMRUContacts
+            if( KErrNotFound == 
+                FindDuplicate( *aMatches[i], iMatchingMRUContacts ) )
+                {
+                // No duplicate in iMatchingMRUContacts, 
+                // this can be appended to iMatchingCompleteContacts
+                iMatchingCompleteContacts.AppendL( aMatches[i] );
+                }
+            }
+        else
+            {
+            // No email, add always to the end of the list
+            iMatchingMissingEmailContacts.AppendL( aMatches[i] );
+            }
+        }
+	
+    RPointerArray<CFSEmailUiClsItem> allMatches = 
+            ConstructOneListL( iMatchingCompleteContacts,
+                               iMatchingMRUContacts,
+                               iMatchingMissingEmailContacts );
     CleanupResetAndDestroyClosePushL( allMatches ); // Ownership is taken
     iClsListObserver->ArrayUpdatedL( allMatches ); 
-    CleanupStack::PopAndDestroy(&allMatches ); // Array is released, destructors are called 
+    CleanupStack::PopAndDestroy( &allMatches ); 
     }
 
 // -----------------------------------------------------------------------------
 // CFSEmailUiClsListsHandler::InputModeChangedL
 // -----------------------------------------------------------------------------
-void CFSEmailUiClsListsHandler::InputModeChangedL( TKeyboardModes aNewInputMode )
+void CFSEmailUiClsListsHandler::InputModeChangedL( 
+        TKeyboardModes aNewInputMode )
 	{
     FUNC_LOG;
 	iPcsMatchObserver->SetInputMode( aNewInputMode );
@@ -168,7 +171,8 @@
 // -----------------------------------------------------------------------------
 // CFSEmailUiClsListsHandler::CFSEmailUiClsListsHandler
 // -----------------------------------------------------------------------------
-CFSEmailUiClsListsHandler::CFSEmailUiClsListsHandler( RFs& aFs, CVPbkContactManager* aContactManager ) :
+CFSEmailUiClsListsHandler::CFSEmailUiClsListsHandler( 
+        RFs& aFs, CVPbkContactManager* aContactManager ) :
 	iContactManager( aContactManager ),
 	iClsListObserver( NULL ), 
 	iFs( aFs ),
@@ -185,20 +189,19 @@
 void CFSEmailUiClsListsHandler::ConstructL()
 	{
     FUNC_LOG;
-	iRequestHandler = CPSRequestHandler::NewL();
-    
+	iRequestHandler = CPSRequestHandler::NewL();  
 	iAknFepCenRep = CRepository::NewL( KCRUidAknFep );
-	
-	iPcsMatchObserver = CFSEmailUiClsMatchObserver::NewL( *iAknFepCenRep, *this, *iRequestHandler, iContactManager );
+	iPcsMatchObserver = CFSEmailUiClsMatchObserver::NewL( 
+	        *iAknFepCenRep, *this, *iRequestHandler, iContactManager );
 	SetSearchSettingsForPcsMatchObserverL();
 	
     // Monitors inputMode changes (predictive vs. non-predictive
 	iInputObserver = CFSEmailUiInputModeObserver::NewL( *iAknFepCenRep, *this );
 
 	if( !iSearchedText )
+	    {
 		iSearchedText = KNullDesC().AllocL();
-	
-    //iRemoteLookupSupported = TFsEmailUiUtility::IsRemoteLookupSupported( *iMailBox );
+	    }
     }
 
 // -----------------------------------------------------------------------------
@@ -215,19 +218,24 @@
 // -----------------------------------------------------------------------------
 // CFSEmailUiClsListsHandler::ReadCLSInfoFromMRUListIndexL
 // -----------------------------------------------------------------------------
-TBool CFSEmailUiClsListsHandler::ReadCLSInfoFromMRUListIndexL( MDesCArray& aTextArray,
-										CFSEmailUiClsItem& aClsItem,
-										const TInt aCurrentMatchIndex, const TInt aPreviousMatchIndex )
+TBool CFSEmailUiClsListsHandler::ReadCLSInfoFromMRUListIndexL( 
+        MDesCArray& aTextArray,
+        CFSEmailUiClsItem& aClsItem,
+        TInt aCurrentMatchIndex, 
+        TInt aPreviousMatchIndex )
 	{
     FUNC_LOG;
 	TBool retVal = EFalse;	
 	// This should be even number
-	TInt currentRealItemIndex = aCurrentMatchIndex - ( aCurrentMatchIndex % 2 );
+	TInt currentRealItemIndex = 
+	        aCurrentMatchIndex - ( aCurrentMatchIndex % 2 );
 	// Here we need to check if match is found both from the display name and email address 
 	if( currentRealItemIndex != aPreviousMatchIndex )
 		{
-		aClsItem.SetDisplayNameL( aTextArray.MdcaPoint( currentRealItemIndex )  );
-		aClsItem.SetEmailAddressL( aTextArray.MdcaPoint( currentRealItemIndex + 1 )  );
+		aClsItem.SetDisplayNameL( 
+		        aTextArray.MdcaPoint( currentRealItemIndex ) );
+		aClsItem.SetEmailAddressL( 
+		        aTextArray.MdcaPoint( currentRealItemIndex + 1 ) );
 		retVal = ETrue;
 		}
 	return retVal;
@@ -237,8 +245,9 @@
 // -----------------------------------------------------------------------------
 // CFSEmailUiClsListsHandler::FindAndDestroyDuplicate
 // -----------------------------------------------------------------------------
-TInt CFSEmailUiClsListsHandler::FindDuplicate( const CFSEmailUiClsItem& aClsItem,
-		  RPointerArray<CFSEmailUiClsItem>& aContacts )
+TInt CFSEmailUiClsListsHandler::FindDuplicate( 
+        const CFSEmailUiClsItem& aClsItem,
+        RPointerArray<CFSEmailUiClsItem>& aContacts )
 	{
     FUNC_LOG;
 	// find duplicate email addresses from aContacts
@@ -261,35 +270,38 @@
 // CFSEmailUiClsListsHandler::ConstructOneListL
 // -----------------------------------------------------------------------------
 RPointerArray<CFSEmailUiClsItem> CFSEmailUiClsListsHandler::ConstructOneListL( 
-								const RPointerArray<CFSEmailUiClsItem>& aContactMatchesWithEmail,
-								const RPointerArray<CFSEmailUiClsItem>& aMRUMatches,
-								const RPointerArray<CFSEmailUiClsItem>& aContactMatchesWithoutEmail )
+        const RPointerArray<CFSEmailUiClsItem>& aContactMatchesWithEmail,
+        const RPointerArray<CFSEmailUiClsItem>& aMRUMatches,
+        const RPointerArray<CFSEmailUiClsItem>& aContactMatchesWithoutEmail )
 	{
     FUNC_LOG;
 	RPointerArray<CFSEmailUiClsItem> allMatches;
 	CleanupResetAndDestroyClosePushL( allMatches );
 	
 	// Copy all the objects from three other lists to the all matches list
+   TInt matchingMRUItemsCount = aMRUMatches.Count();
+    for ( TInt i = 0 ; i < matchingMRUItemsCount ; i++ )
+        {
+        CFSEmailUiClsItem* newClsItem = CopyClsItemLC( *aMRUMatches[i] );
+        allMatches.AppendL( newClsItem );
+        CleanupStack::Pop( newClsItem );
+        }
+
 	TInt matchingComleteItemsCount = aContactMatchesWithEmail.Count();
 	for( TInt i = 0 ; i <  matchingComleteItemsCount; i++ )
 		{
-		CFSEmailUiClsItem* newClsItem = CopyClsItemLC( *aContactMatchesWithEmail[i] );
+		CFSEmailUiClsItem* newClsItem = 
+		        CopyClsItemLC( *aContactMatchesWithEmail[i] );
 		allMatches.AppendL( newClsItem );
 		CleanupStack::Pop( newClsItem );
 		}
 
-	TInt matchingMRUItemsCount = aMRUMatches.Count();
-	for ( TInt i = 0 ; i < matchingMRUItemsCount ; i++ )
-		{
-		CFSEmailUiClsItem* newClsItem = CopyClsItemLC( *aMRUMatches[i] );
-		allMatches.AppendL( newClsItem );
-		CleanupStack::Pop( newClsItem );
-		}
-
-	TInt mathingContactItemsWithoutEmailCount = aContactMatchesWithoutEmail.Count();
+	TInt mathingContactItemsWithoutEmailCount = 
+	        aContactMatchesWithoutEmail.Count();
 	for( TInt i = 0 ; i < mathingContactItemsWithoutEmailCount ; i++ )
 		{
-		CFSEmailUiClsItem* newClsItem = CopyClsItemLC( *aContactMatchesWithoutEmail[i] );
+		CFSEmailUiClsItem* newClsItem = 
+		        CopyClsItemLC( *aContactMatchesWithoutEmail[i] );
 		allMatches.AppendL( newClsItem );
 		CleanupStack::Pop( newClsItem );
 		}
@@ -306,15 +318,15 @@
     FUNC_LOG;
     // Create predictive search settings
     CPsSettings* searchSettings = CPsSettings::NewL();
-    CleanupStack::PushL(searchSettings);
+    CleanupStack::PushL( searchSettings );
 
     RPointerArray<TDesC> databases;
-    CleanupClosePushL(databases);
+    CleanupClosePushL( databases );
 
-    HBufC* store1 = HBufC::NewLC(50);
-    store1->Des().Copy( KVPbkDefaultCntDbURI ); // To specify phone contacts store
+    HBufC* store1 = HBufC::NewLC( 50 );
+    store1->Des().Copy( KVPbkDefaultCntDbURI ); // Phone contacts store
     
-    databases.AppendL(store1);
+    databases.AppendL( store1 );
     HBufC* store2 = NULL;
     if ( iMailBox )
         {
@@ -322,7 +334,7 @@
         GetMruDatastoreUriFromMailbox( *iMailBox, *store2 );
         databases.AppendL( store2 );
         }
-    searchSettings->SetSearchUrisL(databases);
+    searchSettings->SetSearchUrisL( databases );
 
     // Set displayfields according to sort order
     RArray<TInt> sortOrder;
@@ -330,7 +342,8 @@
     iRequestHandler->GetSortOrderL( *store1, sortOrder );
     if ( sortOrder.Count() )
         {
-        iUseLastNameFirstOrder = ( sortOrder[0] == R_VPBK_FIELD_TYPE_LASTNAME );
+        iUseLastNameFirstOrder = 
+                ( sortOrder[0] == R_VPBK_FIELD_TYPE_LASTNAME );
         }
     else
         {
@@ -338,8 +351,14 @@
         }
     RArray<TInt> displayFields( 6 );
     CleanupClosePushL( displayFields );
-    displayFields.AppendL( sortOrder[0] );
-    if ( sortOrder.Count() >= 1 ) displayFields.AppendL( sortOrder[1] );
+    if ( sortOrder.Count() ) 
+        {
+        displayFields.AppendL( sortOrder[0] );
+        }
+    if ( sortOrder.Count() >= 1 ) 
+        {
+        displayFields.AppendL( sortOrder[1] );
+        }
     displayFields.AppendL( R_VPBK_FIELD_TYPE_EMAILGEN );
     displayFields.AppendL( R_VPBK_FIELD_TYPE_EMAILHOME );
     displayFields.AppendL( R_VPBK_FIELD_TYPE_EMAILWORK );
@@ -349,26 +368,22 @@
     displayFields.Close();
     sortOrder.Close();
 
-    // Set maximum for search results
-    //How many results is shown on the screen??
-    //searchSettings->SetMaxResults(const TInt aMaxResults);
-
     // Set the new search settings
-    iRequestHandler->SetSearchSettingsL(*searchSettings);	
+    iRequestHandler->SetSearchSettingsL( *searchSettings );	
 
     if ( store2 )
         {
-        CleanupStack::PopAndDestroy(store2);
+        CleanupStack::PopAndDestroy( store2 );
         }
-    CleanupStack::PopAndDestroy(store1);
-    CleanupStack::Pop(&databases);
+    CleanupStack::PopAndDestroy( store1 );
+    CleanupStack::Pop( &databases );
     databases.Close();
-    CleanupStack::PopAndDestroy(searchSettings);
+    CleanupStack::PopAndDestroy( searchSettings );
 
 	}
 
 // -----------------------------------------------------------------------------
-// CFSEmailUiClsListsHandler::isLanguageSupported()
+// CFSEmailUiClsListsHandler::IsLanguageSupported()
 // -----------------------------------------------------------------------------
 TBool CFSEmailUiClsListsHandler::IsLanguageSupportedL()
 	{
@@ -377,10 +392,14 @@
 	TLanguage lang = User::Language();
 
 	// Check for language support
-	return iRequestHandler->IsLanguageSupportedL(lang);
+	return iRequestHandler->IsLanguageSupportedL( lang );
 	}
 
-void CFSEmailUiClsListsHandler::GetMruDatastoreUriFromMailbox( CFSMailBox& aMailbox, HBufC& aUri )
+// -----------------------------------------------------------------------------
+// CFSEmailUiClsListsHandler::GetMruDatastoreUriFromMailbox()
+// -----------------------------------------------------------------------------
+void CFSEmailUiClsListsHandler::GetMruDatastoreUriFromMailbox( 
+        CFSMailBox& aMailbox, HBufC& aUri )
 	{
     FUNC_LOG;
 	aUri.Des().Copy( KDefaultMailBoxURI );
@@ -389,12 +408,19 @@
 	aUri.Des().AppendNum( aMailbox.GetId().Id() );
 	}
 
-void CFSEmailUiClsListsHandler::SetObserver( MFSEmailUiClsListsObserver* aClsListObserver )
+// -----------------------------------------------------------------------------
+// CFSEmailUiClsListsHandler::SetObserver()
+// -----------------------------------------------------------------------------
+void CFSEmailUiClsListsHandler::SetObserver( 
+        MFSEmailUiClsListsObserver* aClsListObserver )
     {
     FUNC_LOG;
     iClsListObserver = aClsListObserver;
     }
 
+// -----------------------------------------------------------------------------
+// CFSEmailUiClsListsHandler::SetCurrentMailboxL()
+// -----------------------------------------------------------------------------
 void CFSEmailUiClsListsHandler::SetCurrentMailboxL( CFSMailBox* aMailBox )
     {
     FUNC_LOG;
@@ -417,12 +443,18 @@
     	}
     }
 
+// -----------------------------------------------------------------------------
+// CFSEmailUiClsListsHandler::OperationErrorL()
+// -----------------------------------------------------------------------------
 void CFSEmailUiClsListsHandler::OperationErrorL( TInt aErrorCode )
 	{
     FUNC_LOG;
 	iClsListObserver->OperationErrorL( aErrorCode );
 	}
 
+// -----------------------------------------------------------------------------
+// CFSEmailUiClsListsHandler::UseLastNameFirstOrder()
+// -----------------------------------------------------------------------------
 TBool CFSEmailUiClsListsHandler::UseLastNameFirstOrder()
     {
     FUNC_LOG;
--- a/emailuis/emailui/src/FreestyleEmailUiContactHandler.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/FreestyleEmailUiContactHandler.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -83,7 +83,14 @@
 
 //Constants
 const TInt KInternetCallPreferred = 1;
-
+/** UID of the CCA details view plugin implementation 
+  * ( from ccappdetailsviewpluginuids.hrh ) */
+const TInt KCCADetailsViewPluginImplmentationUid = 0x200159E7;
+/**  CCA Application 
+ *  ( from ccauids.h )*/ 
+const TInt KCCAAppUID = 0x2000B609;
+/** Phonebook2 App UID */
+const TInt KPbkUID3 = 0x101f4cce;
 
 CFSEmailUiContactHandler* CFSEmailUiContactHandler::NewL( RFs& aSession )
     {
@@ -336,13 +343,11 @@
             {
             dialData->SetCallType( CAiwDialData::EAIWVoiP );            
             }
-        // <cmail> video call
         else if ( iVideoCall )
             {
             iVideoCall = EFalse;
             dialData->SetCallType( CAiwDialData::EAIWForcedVideo );
             }
-        // </cmail>
         else
             {
             dialData->SetCallType( CAiwDialData::EAIWVoice );           
@@ -354,13 +359,11 @@
             {
             dialData->SetCallType( CAiwDialData::EAIWVoiP );            
             }
-        // <cmail> video call
         else if ( iVideoCall ) 
             {
             iVideoCall = EFalse;
             dialData->SetCallType( CAiwDialData::EAIWForcedVideo );
             }
-        // </cmail>
         else
             {
             dialData->SetCallType( CAiwDialData::EAIWVoice );           
@@ -501,22 +504,22 @@
         }
     }
 
-// <cmail> video call
 // ---------------------------------------------------------------------------
 // Enables/disables video call.
 // ---------------------------------------------------------------------------
 //
 void CFSEmailUiContactHandler::SetVideoCall( TBool aState )
     {
+    FUNC_LOG;
     iVideoCall = aState;
     }
-// </cmail>
 
-/////////////////////////////////////////////////////////////////////////////
+// ---------------------------------------------------------------------------
 // CFSEmailUiContactHandler::GetSmsAddressFromPhonebookAndSendL
+// ---------------------------------------------------------------------------
 //
-/////////////////////////////////////////////////////////////////////////////
-void CFSEmailUiContactHandler::GetSmsAddressFromPhonebookAndSendL( MVPbkContactLink* aContactLink )
+void CFSEmailUiContactHandler::GetSmsAddressFromPhonebookAndSendL( 
+    MVPbkContactLink* aContactLink )
     {
     FUNC_LOG;
     if ( iState == EContactHandlerIdle )
@@ -550,12 +553,12 @@
         }
     }
 
-/////////////////////////////////////////////////////////////////////////////
+// ---------------------------------------------------------------------------
 // CFSEmailUiContactHandler::GetMmsAddressFromPhonebookAndSendL
+// ---------------------------------------------------------------------------
 //
-/////////////////////////////////////////////////////////////////////////////
-void CFSEmailUiContactHandler::GetMmsAddressFromPhonebookAndSendL( MVPbkContactLink* aContactLink,
-                                                            TBool aIsVoiceMessage )
+void CFSEmailUiContactHandler::GetMmsAddressFromPhonebookAndSendL(
+    MVPbkContactLink* aContactLink, TBool aIsVoiceMessage )
     {
     FUNC_LOG;
     if ( iState == EContactHandlerIdle )
@@ -596,10 +599,35 @@
         }
     }
 
-/////////////////////////////////////////////////////////////////////////////
+// ---------------------------------------------------------------------------
+// Retrieves the first contact in contact link set.
+// ---------------------------------------------------------------------------
+//
+void CFSEmailUiContactHandler::RetrieveContactsL()
+    {
+    FUNC_LOG;
+    if ( iLinksSet->Count() )
+        {
+        delete iCurrentLink;
+        iCurrentLink = NULL;
+
+        iCurrentLink = iLinksSet->At(0).CloneLC();
+        CleanupStack::Pop();
+
+        delete iLinkOperationFetch;
+        iLinkOperationFetch = NULL;
+
+        //Async operation, callback VPbkSingleContactOperationCompleteL
+        //Error situations: VPbkSingleContactOperationFailed
+        iLinkOperationFetch = iContactManager->RetrieveContactL( 
+            *iCurrentLink, *this );
+        }
+    }
+
+// ---------------------------------------------------------------------------
 // CFSEmailUiContactHandler::ArrayUpdatedL
+// ---------------------------------------------------------------------------
 //
-/////////////////////////////////////////////////////////////////////////////
 void CFSEmailUiContactHandler::ArrayUpdatedL(
     const RPointerArray<CFSEmailUiClsItem>& aMatchingItems )
     {
@@ -628,7 +656,7 @@
                 {
                 if ( !iSearchMatch )
                     {
-                    iSearchMatch = CFSEmailUiClsItem::NewL();           
+                    iSearchMatch = CFSEmailUiClsItem::NewL();
                     }
                 iSearchMatch->SetDisplayNameL( aMatchingItems[0]->DisplayName() );
                 iSearchMatch->SetEmailAddressL( aMatchingItems[0]->EmailAddress() );
@@ -671,9 +699,9 @@
                 {
                 iCachingInProgressError = EFalse;
                 iState = EContactHandlerIdle;
-        iHandlerObserver->OperationErrorL( ESearchContacts, aErrorCode );
-        }
-    }
+                iHandlerObserver->OperationErrorL( ESearchContacts, aErrorCode );
+                }
+            }
         else
             {
             iState = EContactHandlerIdle;
@@ -692,14 +720,12 @@
         MVPbkStoreContact* aContact )
     {
     FUNC_LOG;
-//inform also client in case of error to enable client's actions (i.e. return search priority)
-//  TRAP_IGNORE( VPbkSingleContactOperationCompleteL( aOperation, aContact) );
+    //inform also client in case of error to enable client's actions (i.e. return search priority)
     TRAPD(error, VPbkSingleContactOperationCompleteL( aOperation, aContact) );
     if ( error != KErrNone )
         {
         TRAP_IGNORE(ObserverOperationErrorL( CurrentCommand(), error ));
         }
-//
     }
 
 void CFSEmailUiContactHandler::VPbkSingleContactOperationCompleteL(
@@ -720,23 +746,28 @@
         CleanupResetAndDestroyClosePushL( emailAddresses );
         GetContactFieldsL( iFirstnameFields, firstname, aContact );
         GetContactFieldsL( iLastnameFields, lastname, aContact );
-    
+
         // Create display name, this will be used in UI.
         TInt dispNameLength = 1;
         if ( firstname.Count() ) dispNameLength += firstname[0]->Length();
         if ( lastname.Count() ) dispNameLength += lastname[0]->Length();
         HBufC* displayname = HBufC::NewLC( dispNameLength );
-        
-        if ( firstname.Count() )
+        TPtr displaynamePtr = displayname->Des();
+        if ( firstname.Count() && firstname[0]->Length() )
             {
-            displayname->Des().Copy( *firstname[0] );
-            displayname->Des().Append( KSpace );
+            displaynamePtr.Copy( *firstname[0] );
+
+            // Append space only when both firstname and lastname are present.
+            if ( lastname.Count() && lastname[0]->Length() )
+                {
+                displaynamePtr.Append( KSpace );
+                }
             }
         if ( lastname.Count() )
             {
-            displayname->Des().Append( *lastname[0] );
+            displaynamePtr.Append( *lastname[0] );
             }
-        
+
         // retrieve selected email address
         MVPbkStoreContactFieldCollection& fields = aContact->Fields();
         MVPbkBaseContactField* selectedField = fields.RetrieveField( *iCurrentLink );
@@ -810,7 +841,7 @@
         }
     
     else if ( (iLinkOperationFetch == &aOperation) && (iState == EContactHandlerCallToContactByEmail ) )
-    {   
+        {
         CleanupDeletePushL( aContact );
     
         RPointerArray<HBufC> phonenumbers;
@@ -840,7 +871,7 @@
                 }
             else
                 {
-                TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_UI_VIEWER_NO_PHONE_NUMBER );                   
+                TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_UI_VIEWER_NO_PHONE_NUMBER );
 //no phone number found - inform client to enable its actions (i.e. return search priority)
                 ObserverOperationErrorL( EFindAndCallToContactByEmailL, KErrNotFound );
                 }
@@ -848,10 +879,12 @@
             }
         
         CleanupStack::PopAndDestroy( aContact );
-    }
+        }
     // Addition to get contact for message creation.
-    else if ( (iLinkOperationFetch == &aOperation) && ( iMsgCreationHelperState == EContactHandlerGetSmsAddressFromPhonebook || 
-            iMsgCreationHelperState == EContactHandlerGetMmsAddressFromPhonebook || iMsgCreationHelperState == EContactHandlerGetVoiceMsgAddressFromPhonebook ) )
+    else if ( (iLinkOperationFetch == &aOperation) && 
+                ( iMsgCreationHelperState == EContactHandlerGetSmsAddressFromPhonebook || 
+                  iMsgCreationHelperState == EContactHandlerGetMmsAddressFromPhonebook || 
+                  iMsgCreationHelperState == EContactHandlerGetVoiceMsgAddressFromPhonebook ) )
         {
         if ( iContactForMsgCreation )
             {
@@ -916,7 +949,11 @@
         }
     }
 
-
+// ---------------------------------------------------------------------------
+// From MVPbkContactStoreListObserver.
+// Called when the opening process is complete. 
+// ---------------------------------------------------------------------------
+//
 void CFSEmailUiContactHandler::OpenComplete()
     {
     FUNC_LOG;
@@ -924,6 +961,12 @@
         {
         iOpenComplete = ETrue;
         }
+
+    if ( iState == EContactHandlerGetAddressesFromPhonebook )
+        {
+        // Start retrieving contacts when stores are opened.
+        TRAP_IGNORE( RetrieveContactsL() );
+        }
     }
 
 void CFSEmailUiContactHandler::StoreReady(MVPbkContactStore& /*aContactStore*/)
@@ -968,37 +1011,23 @@
             emptyItems.Close();
             iHandlerObserver = NULL;
             }
-        
         }
     else if ( (aCmdId == KAiwCmdSelect) && (iState == EContactHandlerGetAddressesFromPhonebook) &&
               (aEventId == KAiwEventCompleted))
         {
-
         TInt index = 0;
         const TAiwGenericParam* param =
-        aEventParamList.FindFirst(index, EGenericParamContactLinkArray);
-        if (param)
+            aEventParamList.FindFirst( index, EGenericParamContactLinkArray );
+        if ( param )
             {
             TPtrC8 contactLinks = param->Value().AsData();
-
-            iLinksSet = iContactManager->CreateLinksLC(contactLinks);
+            iLinksSet = iContactManager->CreateLinksLC( contactLinks );
             CleanupStack::Pop();
-            if ( iLinksSet->Count() )
-                {
-                delete iCurrentLink;
-                iCurrentLink = NULL;
 
-                iCurrentLink = iLinksSet->At(0).CloneLC();
-                CleanupStack::Pop();
-                //Async operation, callback VPbkSingleContactOperationCompleteL
-                //Error situations: VPbkSingleContactOperationFailed
-                iLinkOperationFetch = iContactManager->RetrieveContactL( 
-                    iLinksSet->At(0), *this );
-                }
-
+            // Open all stores before retrieving contact details.
+            // Async operation, calls OpenComplete when all stores are opened.
             iContactManager->ContactStoresL().OpenAllL( *this );
             }
-
         }
     else if ( (aCmdId == KAiwCmdSelect) && (iState == EContactHandlerGetSmsAddressFromPhonebook) &&
               (aEventId == KAiwEventCompleted))
@@ -1066,9 +1095,7 @@
     iUseSenderText(EFalse),
     iFs( aSession ),
     iCachingInProgressError(EFalse),
-    // <cmail> video call
     iVideoCall( EFalse )
-    // </cmail>
     {
     FUNC_LOG;
     }
@@ -1112,13 +1139,11 @@
             }
         else
             {
-            TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_UI_VIEWER_NO_PHONE_NUMBER );                   
+            TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_UI_VIEWER_NO_PHONE_NUMBER );
             }
-        // <cmail> video call flag needs to be cleared
         iVideoCall = EFalse;
-        // </cmail>
         iState = EContactHandlerIdle;
-        }               
+        }
     else if ( aMatchingItems.Count() > 0 ) // Call to one directly
         {
         // Create contact item in which to copy number or address, async operation.
@@ -1136,7 +1161,7 @@
         //Async operation, callback VPbkSingleContactOperationCompleteL
         //Error situations: VPbkSingleContactOperationFailed
         iLinkOperationFetch = iContactManager->RetrieveContactL(
-            *iCurrentLink, *this);
+            *iCurrentLink, *this );
         }
     }
 
@@ -1412,8 +1437,8 @@
         param->SetContactDataL( link16->Des() );
 
         // switch to details view
-        const TUid uid = TUid::Uid( 0x200159E7 ); 
-        param->SetLaunchedViewUid( uid);
+        const TUid uid = TUid::Uid( KCCADetailsViewPluginImplmentationUid ); 
+        param->SetLaunchedViewUid( uid );
 
         // Launching the  CCA application
         iConnection->LaunchAppL( *param, this );
@@ -1432,6 +1457,70 @@
     }
 
 // ---------------------------------------------------------------------------
+// Return contact details view Id 
+// ---------------------------------------------------------------------------
+//
+TUid CFSEmailUiContactHandler::GetDetailsViewUid()
+	{
+	  return TUid::Uid( KCCADetailsViewPluginImplmentationUid ); 
+	}
+
+// ---------------------------------------------------------------------------
+// Return contact detail App Id (CCAPP) 
+// ---------------------------------------------------------------------------
+//
+TUid CFSEmailUiContactHandler::GetDetailsAppUid()
+	{
+	return TUid::Uid( KCCAAppUID ); 
+	}
+ 
+// ---------------------------------------------------------------------------
+// Close Details view using CCApplication
+// ---------------------------------------------------------------------------
+//
+void CFSEmailUiContactHandler::CloseContactDetailsL()
+	{
+	 CCASimpleNotifyL( MCCAObserver::EExitEvent,0 );   
+	 iContactDetailsClosed = ETrue;
+	}
+
+// ---------------------------------------------------------------------------
+// Check if Contact Details view was closed using CloseContactDetailsL method
+// ---------------------------------------------------------------------------
+//
+TBool CFSEmailUiContactHandler::WasDetailsClosed()
+	{
+	return iContactDetailsClosed;
+	}
+
+// ---------------------------------------------------------------------------
+// Reopen Details view for last addres or bring contacts app to foreground
+// ---------------------------------------------------------------------------
+//
+void CFSEmailUiContactHandler::ReopenContactDetailsL(RWsSession& session )
+	{
+	if( iPreviousEmailAddress )
+        {
+		HBufC* emailAddress = iPreviousEmailAddress->AllocLC();
+		ShowContactDetailsL( *emailAddress, EContactUpdateEmail, NULL );
+		CleanupStack::PopAndDestroy( emailAddress );
+		iContactDetailsClosed = EFalse;
+		}
+	else // if contact wasn't open from email
+	    {
+	    // Try to bring calling external app into foreground if found
+	    TApaTaskList taskList( session );
+	    TApaTask contAppTask = taskList.FindApp( TUid::Uid( KPbkUID3 ) );
+	    if ( contAppTask.Exists() )
+	        {
+	        contAppTask.BringToForeground();
+	        iContactDetailsClosed = EFalse;
+	        }
+	    }
+	}
+
+
+// ---------------------------------------------------------------------------
 // CFSEmailUiContactHandler::FindContactLinkL
 // Searches contacts matching with the given email address
 // ---------------------------------------------------------------------------
@@ -1454,17 +1543,16 @@
     iEmailFields.Append( R_VPBK_FIELD_TYPE_EMAILGEN );
     iEmailFields.Append( R_VPBK_FIELD_TYPE_EMAILWORK );
     iEmailFields.Append( R_VPBK_FIELD_TYPE_EMAILHOME );
-    
+
     iFirstnameFields.Append( R_VPBK_FIELD_TYPE_FIRSTNAME );
     iLastnameFields.Append( R_VPBK_FIELD_TYPE_LASTNAME );
-    
+
     iPhoneNumberFields.Append( R_VPBK_FIELD_TYPE_LANDPHONEHOME );
     iPhoneNumberFields.Append( R_VPBK_FIELD_TYPE_MOBILEPHONEWORK );
     iPhoneNumberFields.Append( R_VPBK_FIELD_TYPE_MOBILEPHONEHOME );
     iPhoneNumberFields.Append( R_VPBK_FIELD_TYPE_LANDPHONEWORK );
     iPhoneNumberFields.Append( R_VPBK_FIELD_TYPE_LANDPHONEGEN );
     iPhoneNumberFields.Append( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN );
-    
     }
 
 void CFSEmailUiContactHandler::ResetFieldIds()
@@ -1478,7 +1566,7 @@
 
 
 // -----------------------------------------------------------------------------
-// CFSEmailUiContactHandler::LaunchRemoteLookupL
+// CFSEmailUiContactHandler::GetNameAndEmailFromRemoteLookupL
 // -----------------------------------------------------------------------------
 TBool CFSEmailUiContactHandler::GetNameAndEmailFromRemoteLookupL( CFSMailBox& aMailBox,
     const TDesC& aQueryString, TDes& aDisplayname, TDes& aEmailAddress )
@@ -1493,6 +1581,7 @@
          CPbkxRemoteContactLookupServiceUiContext::TResult::EExitContactSelected )
         {
         GetNameAndEmail( aDisplayname, aEmailAddress, *(result.iSelectedContactItem) );
+        delete result.iSelectedContactItem;
         return ETrue;
         } 
 
@@ -1513,7 +1602,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CFSEmailUiContactHandler::LaunchRemoteLookupL
+// CFSEmailUiContactHandler::GetNameAndNumberFromRemoteLookupL
 // -----------------------------------------------------------------------------
 HBufC* CFSEmailUiContactHandler::GetNameAndNumberFromRemoteLookupL(
     CFSMailBox& aMailBox, const TDesC& aQuery, RBuf& aPhoneNumber )
@@ -1564,6 +1653,8 @@
     FUNC_LOG;
     iContactObjects.ResetAndDestroy();
     iState = EContactHandlerIdle;
+    delete iCurrentLink;
+    iCurrentLink = NULL;
     delete iLinksSet;
     iLinksSet = NULL;
     delete iLinkOperation;
@@ -1876,7 +1967,7 @@
     iHandlerObserver = NULL;
     }
 
-// <cmail> call observer's MFSEmailUiContactHandlerObserver::OperationErrorL( TContactHandlerCmd aCmd, TInt aError ) 
+// Call observer's MFSEmailUiContactHandlerObserver::OperationErrorL( TContactHandlerCmd aCmd, TInt aError ) 
 void CFSEmailUiContactHandler::ObserverOperationErrorL( TContactHandlerCmd aCmd, TInt aErrorCode )
     {
     if( ( iHandlerObserver ) && ( KErrNone != aErrorCode ) )
--- a/emailuis/emailui/src/FreestyleEmailUiFolderListVisualiser.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/FreestyleEmailUiFolderListVisualiser.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -1794,7 +1794,7 @@
 		    	   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
 				   iSortIconArray[ ESortListSenderDescIcon ] : 
 				   iSortIconArray[ ESortListSenderAscIcon ] : 
-				   iSortIconArray[ ESortListSenderDescIcon ];
+				   iSortIconArray[ ESortListSenderAscIcon ];
 			itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_RECIPIENT, KFsTreeRootID, icon, EFalse );
 			iModel->AppendL( itemId, EFSMailSortByRecipient );
 			}
@@ -1806,7 +1806,7 @@
 		    	   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
 				   iSortIconArray[ ESortListSenderDescIcon ] : 
 				   iSortIconArray[ ESortListSenderAscIcon ] : 
-				   iSortIconArray[ ESortListSenderDescIcon ];
+				   iSortIconArray[ ESortListSenderAscIcon ];
 			itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_SENDER, KFsTreeRootID, icon, EFalse );
 			iModel->AppendL( itemId, EFSMailSortBySender );
 			}
@@ -1817,7 +1817,7 @@
 		   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
 		   iSortIconArray[ ESortListSubjectDescIcon ] : 
 		   iSortIconArray[ ESortListSubjectAscIcon ] : 
-		   iSortIconArray[ ESortListSubjectDescIcon ];
+		   iSortIconArray[ ESortListSubjectAscIcon ];
 	
 	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_SUBJECT, KFsTreeRootID, icon, EFalse );
 	iModel->AppendL( itemId, EFSMailSortBySubject );
@@ -1851,7 +1851,7 @@
 			   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
 			   iSortIconArray[ ESortListUnreadDescIcon ] : 
 			   iSortIconArray[ ESortListUnreadAscIcon ] : 
-			   iSortIconArray[ ESortListUnreadDescIcon ];
+			   iSortIconArray[ ESortListUnreadAscIcon ];
 		
 		itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_UNREAD, KFsTreeRootID, icon, EFalse );
 		iModel->AppendL( itemId, EFSMailSortByUnread );
--- a/emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -471,10 +471,18 @@
 // ---------------------------------------------------------------------------
 //  hide or show Container ( used for activation of the view )
 //
-void CFsEmailUiHtmlViewerView::FadeOut(TBool aDirectionOut )
+void CFsEmailUiHtmlViewerView::FadeOut( TBool aDirectionOut )
 	{
 	FUNC_LOG;
-	iContainer->MakeVisible(!aDirectionOut);
+	if ( !iContainer )
+		{
+        TFsEmailUiUtility::ShowErrorNoteL( 
+            R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
+		}
+	else
+		{
+	    iContainer->MakeVisible( !aDirectionOut );
+		}
 	}
 
 
@@ -863,7 +871,11 @@
         {
         iMessage = NULL;
         CancelFetchings();
-        CFsEmailUiViewBase::NavigateBackL();
+        TUid current = iAppUi.CurrentActiveView()->Id();
+        if ( current == this->Id() )
+            {
+            CFsEmailUiViewBase::NavigateBackL();
+            }
 
         if ( iContainer )
             {
--- a/emailuis/emailui/src/FreestyleEmailUiLayoutHandler.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/FreestyleEmailUiLayoutHandler.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -1101,6 +1101,27 @@
     }
 
 // -----------------------------------------------------------------------------
+// CFSEmailUiLayoutHandler::SearchMarkIconSize
+// -----------------------------------------------------------------------------
+TInt CFSEmailUiLayoutHandler::SearchMarkIconSize() const
+    {
+    FUNC_LOG;
+    TRect rect;
+    TRect iconRowParent(0,0,0,0);
+    TInt size;
+    
+    CFsLayoutManager::LayoutMetricsRect(
+        iconRowParent,
+        CFsLayoutManager::EFsLmListSingleDycRowPaneG1,
+        rect,
+        2);
+    
+    size = rect.iBr.iY - rect.iTl.iY; 
+    
+    return size;
+    }
+
+// -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::statusPaneIconSize
 // -----------------------------------------------------------------------------
 TSize CFSEmailUiLayoutHandler::statusPaneIconSize() const
--- a/emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -574,7 +574,8 @@
     iNewEmailText = StringLoader::LoadL( R_COMMAND_AREA_NEW_EMAIL );
 
     // Set menu, mark and background icons
-    iMailTreeListVisualizer->SetMarkIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkIcon ) );
+    iMailTreeListVisualizer->SetMarkOnIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkOnIcon ) );
+    iMailTreeListVisualizer->SetMarkOffIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkOffIcon ) );
     iMailTreeListVisualizer->SetMenuIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMenuIcon ) );
     iMailList->AddObserverL( *this );
     iMailList->AddObserverL( *iTouchManager );
@@ -1655,16 +1656,17 @@
         }
 
     iShowReplyAll = EFalse;
-
-	if ( !iFirstStartCompleted )
-	    {
-	    DoFirstStartL();
-	    }
+    TBool bDoFirstStartCalled( EFalse );
+    if ( !iFirstStartCompleted )
+        {
+        DoFirstStartL();
+        bDoFirstStartCalled = ETrue;
+        }
     // set when editor was called so reset is needed i.e. here (Called by DoActivate)
-   	iMailOpened = EFalse; 
+    iMailOpened = EFalse; 
 
     // Make sure that pending popup is not displayd
-	if ( iAppUi.FolderList().IsPopupShown() )
+    if ( iAppUi.FolderList().IsPopupShown() )
         {
         iAppUi.FolderList().HidePopupL();
         }
@@ -1692,18 +1694,20 @@
     SetMailListLayoutAnchors();
     //if the view is already active don't update the icons so they won't "blink" 
     //when the view is activated.
-    if(!iThisViewActive && !iMarkingMode)
+    if( !iThisViewActive && !iMarkingMode )
         {     
-        ScaleControlBarL();
         
-        // Set icons on toolbar
-        iAppUi.FsTextureManager()->ClearTextureByIndex( EListControlBarMailboxDefaultIcon );
-        iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
-        iAppUi.FsTextureManager()->ClearTextureByIndex( EListTextureCreateNewMessageIcon );
-        iNewEmailButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListTextureCreateNewMessageIcon ) );
-        iAppUi.FsTextureManager()->ClearTextureByIndex( GetSortButtonTextureIndex() );
-        iSortButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( GetSortButtonTextureIndex() ) );
-
+        ScaleControlBarL();
+        if ( !bDoFirstStartCalled ) // Don't set the icon if set by DoFirstStart()
+            { 
+            // Set icons on toolbar
+            iAppUi.FsTextureManager()->ClearTextureByIndex( EListControlBarMailboxDefaultIcon );
+            iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
+            iAppUi.FsTextureManager()->ClearTextureByIndex( EListTextureCreateNewMessageIcon );
+            iNewEmailButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListTextureCreateNewMessageIcon ) );
+            iAppUi.FsTextureManager()->ClearTextureByIndex( GetSortButtonTextureIndex() );
+            iSortButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( GetSortButtonTextureIndex() ) );
+            }
         SetListAndCtrlBarFocusL();
         }
 
@@ -2540,6 +2544,7 @@
     iMarkingMode = EFalse;    
     // Hide marking mode text on the place of drop down menus
     UpdateFolderAndMarkingModeTextsL();
+    iMailList->SetMarkingModeL( EFalse );
     UnmarkAllItemsL();
     // Change softkeys back to normal
     SetViewSoftkeysL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_BACK );
@@ -2547,8 +2552,6 @@
     CEikMenuBar* menu = iAppUi.CurrentActiveView()->MenuBar();
     menu->StopDisplayingMenuBar();
     menu->SetMenuTitleResourceId(R_FSEMAILUI_MAILLIST_MENUBAR);
-    // Change background back to normal
-    DisplayMarkingModeBgL( EFalse );   
     // Display drop down menu buttons
     iControlBarControl->SetRectL( iAppUi.LayoutHandler()->GetControlBarRect() );
     iNewEmailButton->SetDimmed( EFalse );
@@ -2570,6 +2573,7 @@
     {
     FUNC_LOG;	
     iMarkingMode = ETrue;
+    iMailList->SetMarkingModeL( ETrue );
 	iListMarkItemsState = ETrue; // shift-scrolling does marking after one item is marked
     HandleCommandL( EFsEmailUiCmdActionsExpandAll );
     // Change softkeys for marking mode
@@ -2589,8 +2593,6 @@
     iMailTreeListVisualizer->HideList();   
     SetMailListLayoutAnchors();
     iMailTreeListVisualizer->ShowListL();
-    // Change background to marking mode
-    DisplayMarkingModeBgL( ETrue );    
     }
 
 // ---------------------------------------------------------------------------
@@ -2684,26 +2686,6 @@
 //
 // ---------------------------------------------------------------------------
 //
-void CFSEmailUiMailListVisualiser::DisplayMarkingModeBgL( TBool aDisplay )
-    {
-    FUNC_LOG;
-    if (aDisplay)
-        {
-        CAlfBrush* brush = iAppUi.FsTextureManager()->NewMailListMarkingModeBgBrushLC();
-        iMailTreeListVisualizer->SetBackgroundBrushL( brush );
-        CleanupStack::Pop( brush );
-        }
-    else
-        {
-        iMailTreeListVisualizer->ClearBackground();
-        }
-    }
-
-// ---------------------------------------------------------------------------
-//
-//
-// ---------------------------------------------------------------------------
-//
 void CFSEmailUiMailListVisualiser::RefreshL( TFSMailMsgId* aFocusToMessage )
 	{
     FUNC_LOG;
@@ -5929,10 +5911,14 @@
         EAlfAlignVCenter );
 
 	// Show the buttons
-  	iNewEmailButton->ShowButtonL();
-    iFolderListButton->ShowButtonL();
-    iSortButton->ShowButtonL();
-	}
+    if( iThisViewActive || iMarkingMode )
+        {
+        iNewEmailButton->ShowButtonL();
+        iFolderListButton->ShowButtonL();
+        iSortButton->ShowButtonL();
+        }
+    // else buttons shown later in ChildDoActivete() by ScaleControlBarL()
+    }
 
 // ---------------------------------------------------------------------------
 //
@@ -6014,59 +6000,52 @@
     
     TFSEmailUiTextures textureIndex( ETextureFirst );
     switch ( iCurrentSortCriteria.iField )
-		{
-		case EFSMailSortBySubject:
-			{
-			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
-						   ESortListSubjectDescTexture :
-						   ESortListSubjectAscTexture;
-			}
-			break;
-		case EFSMailSortByAttachment:
-			{
-			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
-						   ESortListAttachmentDescTexture :
-						   ESortListAttachmentAscTexture;
-			}
-			break;
-		case EFSMailSortByFlagStatus:
-			{
-			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
-						   ESortListFollowDescTexture :
-						   ESortListFollowAscTexture;
-			}
-			break;
-		case EFSMailSortByRecipient:
-		case EFSMailSortBySender:
-			{
-			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
-						   ESortListSenderDescTexture :
-						   ESortListSenderAscTexture;
-			}
-			break;
-		case EFSMailSortByPriority:
-			{
-			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
-						   ESortListPriorityDescTexture :
-						   ESortListPriorityAscTexture;
-			}
-			break;
-		case EFSMailSortByUnread:
-			{
-			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
-						   ESortListUnreadDescTexture :
-						   ESortListUnreadAscTexture;
-			}
-			break;
-		case EFSMailSortByDate:
-		default:
-			{
-			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
-						   ESortListDateDescTexture :
-						   ESortListDateAscTexture;
-			}
-			break;
-  		}
+        {
+        case EFSMailSortBySubject:
+            {
+            textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+                ESortListSubjectAscTexture : ESortListSubjectDescTexture;
+            }
+            break;
+        case EFSMailSortByAttachment:
+            {
+            textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+                ESortListAttachmentAscTexture : ESortListAttachmentDescTexture;
+            }
+            break;
+        case EFSMailSortByFlagStatus:
+            {
+            textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+                ESortListFollowAscTexture : ESortListFollowDescTexture;
+            }
+            break;
+        case EFSMailSortByRecipient:
+        case EFSMailSortBySender:
+            {
+            textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+                ESortListSenderAscTexture : ESortListSenderDescTexture;
+            }
+            break;
+        case EFSMailSortByPriority:
+            {
+            textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+                ESortListPriorityAscTexture : ESortListPriorityDescTexture;
+            }
+            break;
+        case EFSMailSortByUnread:
+            {
+            textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+                ESortListUnreadAscTexture : ESortListUnreadDescTexture;
+            }
+            break;
+        case EFSMailSortByDate:
+        default:
+            {
+            textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+                ESortListDateAscTexture : ESortListDateDescTexture;
+            }
+            break;
+        }
     return textureIndex;
 	}
 
--- a/emailuis/emailui/src/FreestyleEmailUiSearchListVisualiser.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/FreestyleEmailUiSearchListVisualiser.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -213,7 +213,7 @@
 
     // Set mark type and icon
     iSearchList->SetMarkTypeL( CFsTreeList::EFsTreeListMultiMarkable );
-    iSearchTreeListVisualizer->SetMarkIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkIcon ) );
+    iSearchTreeListVisualizer->SetMarkOnIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkOnIcon ) );
     iSearchTreeListVisualizer->SetMenuIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMenuIcon ) );
 	iSearchTreeListVisualizer->SetFlipState( iKeyboardFlipOpen );
 	iSearchTreeListVisualizer->SetFocusVisibility( iFocusVisible );
--- a/emailuis/emailui/src/FreestyleEmailUiTextureManager.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/FreestyleEmailUiTextureManager.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -18,24 +18,16 @@
 
 
 // SYSTEM INCLUDES
-// <cmail> SF
 #include "emailtrace.h"
 #include <alf/alfstatic.h>
-// </cmail>
 #include <freestyleemailui.mbg>
 #include <AknUtils.h>
-// <cmail>
 #include <alf/alfframebrush.h>
-// </cmail>
 #include <AknsConstants.h>
-// <cmail>
 #include <alf/alfimageloaderutil.h>
-// </cmail>
 #include <avkon.mbg>
 #include <gulicon.h>
-// <cmail> S60 Skin support
 #include <AknsDrawUtils.h>
-// </cmail>
 
 // INTERNAL INCLUDES
 #include "FreestyleEmailUi.hrh"
@@ -92,12 +84,10 @@
 	delete iFrameBrush;
 	iFrameBrush = NULL;
 
-	//<cmail>
 	delete iNewFrameBrush;
 	iNewFrameBrush = NULL;
 
 	delete iTitleDividerBgBrush;
-	//</cmail>
 	}
 
 
@@ -239,7 +229,6 @@
 	return frameBrush;
 	}
 
-// <cmail>
 // -----------------------------------------------------------------------------
 // CFreestyleEmailUiTextureManager::NewListSelectorBrushL
 // NOTE: Gen UI list gets the ownership of the selector brush and deletes it
@@ -269,7 +258,6 @@
 
     return iNewFrameBrush;
     }
-// </cmail>
 
 
 // -----------------------------------------------------------------------------
@@ -359,20 +347,6 @@
 	}
 
 // -----------------------------------------------------------------------------
-// CFreestyleEmailUiTextureManager::NewMailListMarkingModeBgBrushLC
-// -----------------------------------------------------------------------------
-//
-CAlfImageBrush* CFreestyleEmailUiTextureManager::NewMailListMarkingModeBgBrushLC()
-    {
-    FUNC_LOG;
-    CAlfTexture& circle = TextureByIndex( EMarkingModeBackgroundIcon );
-    CAlfImageBrush* bgBrush = CAlfImageBrush::NewLC( *iEnv, TAlfImage(circle) );
-    bgBrush->SetLayer( EAlfBrushLayerBackground );
-    bgBrush->SetScaleMode( CAlfImageVisual::EScaleNormal );
-    return bgBrush;
-    }
-
-// -----------------------------------------------------------------------------
 // CFreestyleEmailUiTextureManager::NewControlBarListBgBrushLC
 // -----------------------------------------------------------------------------
 //
@@ -532,11 +506,7 @@
  		}
  	else if ( aId >= ETextureGridFirst ) // GRID ICONS
 		{
-// <cmail> Platform layout change
-	   	//TInt gridIconSize = iAppUi->LayoutHandler()->GridIconSize();
-		//iconSize.SetSize(  gridIconSize, gridIconSize );
 		iconSize = iAppUi->LayoutHandler()->GridIconSize();
-// </cmail>
 		}
 	else  if ( aId >= ETextureMessageFirst /*&& aId < ETextureCalendarFirst*/ ) // MESSAGE ICONS
 		{
@@ -551,7 +521,6 @@
   	CFbsBitmap* mask(0);
 	TScaleMode scalemode = EAspectRatioPreserved;
 
-// <cmaill> icons changed
 	switch ( aId )
 		{
 		// LIST TEXTURE READING STARTS HERE
@@ -625,26 +594,27 @@
 	                             EMbmFreestyleemailuiQgn_graf_cmail_list_selector_mask);
 			}
 			break;
-		case EListControlMarkIcon:
+		case EListControlMarkOnIcon:
 			{
-			// <cmail> Platform layout change
-			// Get mark icon from the skin, otherwise use default
-            AknsUtils::CreateColorIconL(
-                AknsUtils::SkinInstance(),
-                KAknsIIDQgnFsListItemSelected,
-                KAknsIIDQsnIconColors,
-                EAknsCIQsnIconColorsCG13,
-                bitmap,
-                mask,
-                //KAvkonBitmapFile,
-                iconFileName,
-                EMbmFreestyleemailuiQgn_indi_marked_add,
-                EMbmFreestyleemailuiQgn_indi_marked_add_mask,
-                KRgbBlack );
-            TInt tempsize = iAppUi->LayoutHandler()->SearchLookingGlassIconSize();
+	        AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
+	            KAknsIIDQgnFsHscrActionArrowRight, bitmap, mask, iconFileName,
+	            EMbmFreestyleemailuiQgn_prop_checkbox_on,
+	            EMbmFreestyleemailuiQgn_prop_checkbox_on_mask );			    
+            TInt tempsize = iAppUi->LayoutHandler()->SearchMarkIconSize();
             iconSize.SetSize( tempsize, tempsize );
 			scalemode = EAspectRatioNotPreserved;
-			// </cmail> Platform layout change
+			}
+			break;
+		case EListControlMarkOffIcon:
+			{
+	        AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
+	            KAknsIIDQgnFsHscrActionArrowRight, bitmap, mask, iconFileName,
+	            EMbmFreestyleemailuiQgn_prop_checkbox_off,
+	            EMbmFreestyleemailuiQgn_prop_checkbox_off_mask );			    
+
+            TInt tempsize = iAppUi->LayoutHandler()->SearchMarkIconSize();
+            iconSize.SetSize( tempsize, tempsize );
+			scalemode = EAspectRatioNotPreserved;
 			}
 			break;
 		case EListControlMenuIcon:
@@ -1886,24 +1856,6 @@
                 KRgbBlack );
 		    }
 		    break;
-        case EMarkingModeBackgroundIcon:
-            {
-            TRect mailListRect(iAppUi->LayoutHandler()->GetListRect());
-            TRect appRect;
-            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EApplicationWindow, appRect);            
-            if ( mailListRect.Width() > mailListRect.Height() )
-                {
-                iconSize.SetSize( appRect.Width(), appRect.Width() );            
-                }
-            else
-                {
-                iconSize.SetSize( appRect.Height(), appRect.Height() );            
-                }
-            AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
-                                 EMbmFreestyleemailuiCmail_marking_mode_bg,
-                                 EMbmFreestyleemailuiCmail_marking_mode_bg);
-            }            
-            break;
 		case EGridAboutTexture:
 		default:
 			// Branded mailbox icon
@@ -2110,9 +2062,14 @@
 			iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EBackgroundTextureMailList, this, EAlfTextureFlagSkinContent);
 			}
 			break;
-		case EListControlMarkIcon:
+		case EListControlMarkOnIcon:
 			{
-			iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EListControlMarkIcon, this, EAlfTextureFlagSkinContent);
+			iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EListControlMarkOnIcon, this, EAlfTextureFlagSkinContent);
+			break;
+			}
+		case EListControlMarkOffIcon:
+			{
+			iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EListControlMarkOffIcon, this, EAlfTextureFlagSkinContent);
 			break;
 			}
 		case EListControlMenuIcon:
@@ -2146,11 +2103,6 @@
 			iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EControlBarDescendingArrowTexture, this, EAlfTextureFlagSkinContent);
 			}
 			break;
-		case EMarkingModeBackgroundIcon: 
-		    {
-		    iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EMarkingModeBackgroundIcon, this, EAlfTextureFlagRetainResolution);
-		    }
-		    break;
 			
 		// MESSAGE TEXTURES
 		case EMessageReadIcon: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EMessageReadIcon, this, EAlfTextureFlagDefault); break;
--- a/emailuis/emailui/src/FreestyleEmailUiUtilities.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/FreestyleEmailUiUtilities.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -799,19 +799,29 @@
     {
     FUNC_LOG;
     CFreestyleEmailUiAppUi* appUi = (CFreestyleEmailUiAppUi*)CCoeEnv::Static()->AppUi();
-    CFSMailMessage* mailMessage = appUi->GetMailClient()->GetMessageByUidL(
+    CFSMailMessage* message = appUi->GetMailClient()->GetMessageByUidL(
         aAttachmentPart.iMailBoxId, aAttachmentPart.iFolderId,
         aAttachmentPart.iMessageId, EFSMsgDataStructure );
 
-    CleanupStack::PushL( mailMessage );
-    CFSMailMessagePart* messagePart = mailMessage->ChildPartL(
-        aAttachmentPart.iMessagePartId );
+    CleanupStack::PushL( message );
+    CFSMailMessagePart* messagePart = NULL;
+    if ( message )
+        {
+        messagePart = message->ChildPartL( aAttachmentPart.iMessagePartId );
+        }
     CleanupStack::PushL( messagePart );
 
-    OpenAttachmentL( *messagePart );
+    if ( messagePart )
+        {
+        OpenAttachmentL( *messagePart );
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
 
     CleanupStack::PopAndDestroy( messagePart );
-    CleanupStack::PopAndDestroy( mailMessage );
+    CleanupStack::PopAndDestroy( message );
     }
 
 // -----------------------------------------------------------------------------
@@ -822,8 +832,8 @@
     {
     FUNC_LOG;
     const TDesC& attName = aAttachmentPart.AttachmentNameL();
-    const TDesC* mimeType16 = &aAttachmentPart.GetContentType();
-    TFileType fileType = GetFileType( attName, *mimeType16 );
+    const TDesC& mimeType16 = aAttachmentPart.GetContentType();
+    TFileType fileType = GetFileType( attName, mimeType16 );
 
     // Check if attachment is actually an embedded message object. In that case we try to
     // open it using mail viewer.
@@ -3115,6 +3125,63 @@
     return isChineseSearchStr;
     }
 
+// ---------------------------------------------------------
+// Find if text is including Korean word  
+// ---------------------------------------------------------
+//
+TBool TFsEmailUiUtility::IsKoreanWord( const TDesC& aWord )
+    {
+    TBool isKoreanSearchStr = EFalse;
+    const TInt len = aWord.Length();
+    
+    const TUint KKoreanUnicodeHangulJamoBegin = 0x1100;
+    const TUint KKoreanUnicodeHangulJamoEnd = 0x11FF;
+    
+    for ( TInt ii = 0; ii < len; ii++ )
+        {
+        if ( (TInt) aWord[ii] >= KKoreanUnicodeHangulJamoBegin 
+             && (TInt) aWord[ii] <= KKoreanUnicodeHangulJamoEnd )
+            {
+            isKoreanSearchStr = ETrue;
+            break;
+            }
+        }
+    
+    const TUint KKoreanUnicodeHangulCompatibilityJamoBegin = 0x3130;
+    const TUint KKoreanUnicodeHangulCompatibilityJamoEnd = 0x322F;
+    
+    if ( !isKoreanSearchStr )
+        {
+        for ( TInt ii = 0; ii < len; ii++ )
+            {
+            if ( (TInt) aWord[ii] >= KKoreanUnicodeHangulCompatibilityJamoBegin 
+                 && (TInt) aWord[ii] <= KKoreanUnicodeHangulCompatibilityJamoEnd )
+                {
+                isKoreanSearchStr = ETrue;
+                break;
+                }
+            }
+        }
+    
+    const TUint KKoreanUnicodeSpanBegin = 0xAC00;
+    const TUint KKoreanUnicodeSpanEnd = 0xD7A3;
+
+    if ( !isKoreanSearchStr )
+        {
+        for ( TInt ii = 0; ii < len; ii++ )
+            {
+            if ( (TInt) aWord[ii] >= KKoreanUnicodeSpanBegin 
+                 && (TInt) aWord[ii] <= KKoreanUnicodeSpanEnd )
+                {
+                isKoreanSearchStr = ETrue;
+                break;
+                }
+            }
+        }
+    
+    return isKoreanSearchStr;
+    }
+
 
 // -----------------------------------------------------------------------------
 // TFsEmailUiUtility::GetFullIconFileNameL
--- a/emailuis/emailui/src/FreestyleEmailUiViewBase.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/FreestyleEmailUiViewBase.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -153,6 +153,22 @@
         DeactivateControlGroup();
         NavigateBackL();
         }
+    
+    if( MailEditorId != Id() )// not for editor (when sending contact via mail)
+        {
+        //Reopen Contact details view if it was closed before
+        CFSEmailUiContactHandler* contactHandler = NULL; // not owned
+        CFsDelayedLoader* delLoader = CFsDelayedLoader::InstanceL(); // not owned
+        if( delLoader )
+            {
+            contactHandler = delLoader->GetContactHandlerL();
+            
+            if( contactHandler && contactHandler->WasDetailsClosed())
+                {
+                contactHandler->ReopenContactDetailsL(iEikonEnv->WsSession());
+                }
+            }
+       }
     }
 
 // ---------------------------------------------------------------------------
@@ -630,10 +646,23 @@
 
         if ( iPreviousAppUid != KFSEmailUiUid && iPreviousAppUid != KNullUid )
             {
+            //don't send to background when back from Contact Details (CCAApp)
+            CFSEmailUiContactHandler* contactHandler(NULL); // not owned
+            CFsDelayedLoader* delLoader = CFsDelayedLoader::InstanceL(); // not owned
+            if( delLoader )
+                {
+                contactHandler = delLoader->GetContactHandlerL();
+                }
+            // for Contact Details, after contact was sent via mail, app shouldn't be sent to background
+            if( contactHandler && iPreviousAppUid == contactHandler->GetDetailsAppUid() )
+                {
+                iSendToBackgroundOnDeactivation = EFalse;
+                iAppUi.SetSwitchingToBackground( EFalse );
+                }
             // Email app should be hidden once the view gets deactivated. Note that hiding
             // should not happen before control group switching is over because that
             // may cause views of other Alfred apps to get distorted.
-            if( !iAppUi.EmbeddedAppIsPreviousApp() ) // if previous app is embedded app,
+            else if( !iAppUi.EmbeddedAppIsPreviousApp() ) // if previous app is embedded app,
                 //do not need hide FSEmail app when previous app view gets deactivated.
                 {
                 iSendToBackgroundOnDeactivation = ETrue;
--- a/emailuis/emailui/src/OverlayControl.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/OverlayControl.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -73,7 +73,7 @@
     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
         {      
         // Give feedback to user (vibration)     
-        iTouchFeedBack->InstantFeedback( this, ETouchFeedbackBasicButton );
+        iTouchFeedBack->InstantFeedback( this, ETouchFeedbackBasic );
         SetPointerCapture( ETrue );        
         }
     CCoeControl::HandlePointerEventL( aPointerEvent );
--- a/emailuis/emailui/src/ncsaddressinputfield.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/ncsaddressinputfield.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -92,23 +92,22 @@
 // -----------------------------------------------------------------------------
 //
 void CNcsAddressInputField::ConstructL( TInt aLabelTextId )
-	{
+    {
     FUNC_LOG;
-	// Create label
-	//Load the label string
-	HBufC* aTextBuf = StringLoader::LoadLC( aLabelTextId );
+    // Create label
+    //Load the label string
+    HBufC* aTextBuf = StringLoader::LoadLC( aLabelTextId );
 
-	TPtrC captionText = aTextBuf ? aTextBuf->Des() : TPtrC();
-	CreateControlsL( captionText );
-	
-	iTextEditor = new ( ELeave ) CNcsAifEditor( iSizeObserver,
-                                                captionText );
+    TPtrC captionText = aTextBuf ? aTextBuf->Des() : TPtrC();
+    CreateControlsL( captionText );
+
+    iTextEditor = new ( ELeave ) CNcsAifEditor( iSizeObserver, captionText );
     // iTextEditor is not completely constructed until in SetContainerWindowL()
 
-	iTextEditor->SetPopupList(iAddressPopupList);
+    iTextEditor->SetPopupList(iAddressPopupList);
 
-	CleanupStack::PopAndDestroy( aTextBuf );
-	}
+    CleanupStack::PopAndDestroy( aTextBuf );
+    }
 
 // ---------------------------------------------------------------------------
 // Destructor
@@ -120,15 +119,8 @@
     delete iTextEditor;
     delete iButton;
     delete iLabel;
-// <cmail> Platform layout change
-    /*if ( iFont )
-        {
-        ControlEnv()->ScreenDevice()->ReleaseFont( iFont );
-        iFont = NULL;
-        }</cmail>*/
     }
 
-//<cmail>
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::CreateControlsL()
 // -----------------------------------------------------------------------------
@@ -156,7 +148,6 @@
         iLabel->SetBrushStyle(CWindowGc::ENullBrush);
         }
     }
-//</cmail>
 
 // ---------------------------------------------------------------------------
 // SetContainerWindow
@@ -169,37 +160,34 @@
     FUNC_LOG;
     CCoeControl::SetContainerWindowL(aContainer);
 
-	InitComponentArrayL();
-	// Check if we need to construct the components
-	if (Components().Count() == 2) return;
+    InitComponentArrayL();
+    // Check if we need to construct the components
+    if (Components().Count() == 2) return;
 
-	// Load the controls into the compoent array
-	CCoeControlArray& controls = Components();
-	controls.SetControlsOwnedExternally(ETrue);
-	//<cmail>
-	if( iButton )
-	    {
-	    controls.AppendLC( iButton );
-	    CleanupStack::Pop( iButton );
-	    }
-	else
-	    {
-	    controls.AppendLC( iLabel );
-	    CleanupStack::Pop( iLabel );
-	    }
-	//</cmail>
-	controls.AppendLC(iTextEditor);
+    // Load the controls into the compoent array
+    CCoeControlArray& controls = Components();
+    controls.SetControlsOwnedExternally(ETrue);
+    //<cmail>
+    if( iButton )
+        {
+        controls.AppendLC( iButton );
+        CleanupStack::Pop( iButton );
+        }
+    else
+        {
+        controls.AppendLC( iLabel );
+        CleanupStack::Pop( iLabel );
+        }
+
+    controls.AppendLC(iTextEditor);
     CleanupStack::Pop(iTextEditor);
 
-// <cmail>
-
-	// Setup the text editor
-	iTextEditor->ConstructL( &aContainer, KMaxAddressFieldLines, 0 );
-// </cmail>
+    // Setup the text editor
+    iTextEditor->ConstructL( &aContainer, KMaxAddressFieldLines, 0 );
 
     iTextEditor->SetBorder( TGulBorder::ENone );
-	iTextEditor->SetAknEditorInputMode( EAknEditorTextInputMode );
-	iTextEditor->SetAknEditorFlags( EAknEditorFlagNoT9 | EAknEditorFlagUseSCTNumericCharmap );
+    iTextEditor->SetAknEditorInputMode( EAknEditorTextInputMode );
+    iTextEditor->SetAknEditorFlags( EAknEditorFlagNoT9 | EAknEditorFlagUseSCTNumericCharmap );
 
      CRepository* repository = NULL;
      TRAPD( err, repository = CRepository::NewL( KFreestyleEmailCenRep ) );
@@ -214,9 +202,9 @@
          }
     delete repository;
     repository = NULL;
-    
-	iTextEditor->SetAknEditorCurrentCase( EAknEditorLowerCase );
-	iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
+
+    iTextEditor->SetAknEditorCurrentCase( EAknEditorLowerCase );
+    iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
     iTextEditor->SetEdwinSizeObserver( this );
     iTextEditor->SetupEditorL();
 
@@ -266,27 +254,27 @@
 // -----------------------------------------------------------------------------
 //
 void CNcsAddressInputField::SizeChanged()
-	{
+    {
     FUNC_LOG;
 
-   	TRect rect = Rect();
- 
-   	if( AknLayoutUtils::PenEnabled() )
-   	    {
-   	    LayoutTouch();
-   	    }
-   	  else
-   	    {
-   	    LayoutNonTouch();
-   	    }
+    TRect rect = Rect();
+
+    if( AknLayoutUtils::PenEnabled() )
+        {
+        LayoutTouch();
+        }
+    else
+        {
+        LayoutNonTouch();
+        }
 
     // This needs to be bidi as in mirrored layout 
     // writing language left to right can be set. 
     // Need to set here as layout sets it also to left or right.
     iTextEditor->SetAlignment( EAknEditorAlignBidi );
-   	    
+
     UpdateFontSize();
-    
+
     if (iTextEditor->ScrollBarFrame())
         {
         TRect rc = iTextEditor->Rect();
@@ -300,38 +288,37 @@
             }
         iTextEditor->SetRect(rc);
         }
-    
+
     PositionChanged();
-	}
+    }
 
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::PositionChanged()
 // set size
 // -----------------------------------------------------------------------------
 void CNcsAddressInputField::PositionChanged()
-	{
+    {
     FUNC_LOG;
-    
+
     // keep the button in view as long as possible
     if( iButton && iParentControl->IsVisible() )
-    	{
-		const TRect rect( Rect() );
-		const TRect buttonRect( iButton->Rect() );
-		
-		TInt newButtonPos( iOriginalButtonPos.iY - iOriginalFieldPos.iY );
-		
-		if( rect.iTl.iY < 0 && newButtonPos + buttonRect.Height() < rect.iBr.iY )
-			{
-			iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos) );
-			}
-		else
-			{
-			iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos + rect.iTl.iY) );
-			}
-    	}
-	}
+        {
+        const TRect rect( Rect() );
+        const TRect buttonRect( iButton->Rect() );
+
+        TInt newButtonPos( iOriginalButtonPos.iY - iOriginalFieldPos.iY );
 
-//<cmail>
+        if( rect.iTl.iY < 0 && newButtonPos + buttonRect.Height() < rect.iBr.iY )
+            {
+            iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos) );
+            }
+        else
+            {
+            iButton->SetPosition( TPoint(iOriginalButtonPos.iX, newButtonPos + rect.iTl.iY) );
+            }
+        }
+    }
+
 // -----------------------------------------------------------------------------
 // CNcsAddressInputField::LayoutNonTouch()
 // 
@@ -361,7 +348,7 @@
 
     iTextEditor->UpdateCustomDrawer();
     }
-    
+
 // -----------------------------------------------------------------------------
 // CNcsAddressInputField::HandlePointerEventL()
 // Handles pointer events
@@ -369,38 +356,33 @@
 //
 void CNcsAddressInputField::HandlePointerEventL( const TPointerEvent& aPointerEvent )
     {
-	FUNC_LOG;
-    iTextEditor->HandlePointerEventL(aPointerEvent);
-    if( iButton )
+    FUNC_LOG;
+    CCoeControl::HandlePointerEventL( aPointerEvent );
+
+    switch ( aPointerEvent.iType )
         {
-        iButton->HandlePointerEventL( aPointerEvent );
-        }
-    iTextEditor->HandleTextChangedL();
-    
-    switch( aPointerEvent.iType )
-    	{
-    	case TPointerEvent::EButton1Down:
-    		{
+        case TPointerEvent::EButton1Down:
+            {
             // Save start position so that it can be used in
             // drag/scrolling calculations
             iStartPosition = aPointerEvent.iPosition;
             iIsDraggingStarted = EFalse;
             break;
-    		}
-    		
-    	case TPointerEvent::EDrag:
-    		{
+            }
+
+        case TPointerEvent::EDrag:
+            {
             if ( !iIsDraggingStarted && iPhysics )
                 {
                 TInt drag( iStartPosition.iY - aPointerEvent.iPosition.iY );
                 if ( Abs( drag ) > iPhysics->DragThreshold() )
                     {
-					iIsDraggingStarted = ETrue;
+                    iIsDraggingStarted = ETrue;
                     }
                 }
             break;
-    		}
-    	}
+            }
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -418,7 +400,6 @@
             }
         }
     }
-//</cmail>
 
 // -----------------------------------------------------------------------------
 // CNcsAddressInputField::OfferKeyEventL()
@@ -427,22 +408,22 @@
 //
 TKeyResponse 
 CNcsAddressInputField::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
-	{
+    {
     FUNC_LOG;
-	TKeyResponse ret( EKeyWasNotConsumed );
+    TKeyResponse ret( EKeyWasNotConsumed );
 
-	if( aKeyEvent.iCode == EKeyOK )
-		{
-		iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse );
-		iTextEditor->UpdateAddressListAllL();
-		}
-	else
-		{
-		ret = iTextEditor->OfferKeyEventL( aKeyEvent, aType );
-		}
+    if( aKeyEvent.iCode == EKeyOK )
+        {
+        iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse );
+        iTextEditor->UpdateAddressListAllL();
+        }
+    else
+        {
+        ret = iTextEditor->OfferKeyEventL( aKeyEvent, aType );
+        }
 
-	return ret;
-	}
+    return ret;
+    }
 
 // -----------------------------------------------------------------------------
 // CNcsAddressInputField::FocusChanged()
@@ -455,30 +436,6 @@
 		{
 		iTextEditor->SetFocus( ETrue, aDrawNow );
         //TRAP_IGNORE( iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse ) );
-
-        // make sure that control is visible on screen
-		if ( Rect().iTl.iY < 0 )
-			{
-			TPoint pt = TPoint( 0, 0 );
-			Reposition( pt,Rect().Width() );
-            iSizeObserver->UpdateFieldPosition( this );
-			}
-		else
-		    {
-		    TPoint pos = PositionRelativeToScreen();
-		    pos.iY += Size().iHeight;
-    	    CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice();
-    	    TPixelsAndRotation pix;
-    		screenDev->GetDefaultScreenSizeAndRotation( pix );
-    		const TInt h = pix.iPixelSize.iHeight;
-    		if ( pos.iY >= h - h / 3 )
-    		    {
-    			TPoint pt = TPoint( 0, h / 3 );
-    			Reposition( pt,Rect().Width() );
-                iSizeObserver->UpdateFieldPosition( this );
-    		    }
-		    }
-
         if ( iParentControl )
             {
             TRAP_IGNORE( iParentControl->SetMskL() );
@@ -771,10 +728,10 @@
 // CNcsAddressInputField::GetLineRectL()
 // -----------------------------------------------------------------------------
 //
-void CNcsAddressInputField::GetLineRectL( TRect& aLineRect ) const
+void CNcsAddressInputField::GetLineRect( TRect& aLineRect ) const
 	{
     FUNC_LOG;
-    return iTextEditor->GetLineRectL( aLineRect );
+    return iTextEditor->GetLineRect( aLineRect );
 	}
 
 // -----------------------------------------------------------------------------
--- a/emailuis/emailui/src/ncsaifeditor.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/ncsaifeditor.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -216,16 +216,17 @@
     }
 
 // ---------------------------------------------------------------------------
-// constructor/destructor
+// Constructor
 // ---------------------------------------------------------------------------
 //
 CNcsAifEditor::CNcsAifEditor(
     MNcsFieldSizeObserver* aSizeObserver, const TDesC& aCaptionText ) 
-    : CNcsEditor( aSizeObserver, ETrue, ENcsEditorAddress, aCaptionText ), iAddressPopupList( NULL ),
+    : CNcsEditor( aSizeObserver, ETrue, ENcsEditorAddress, aCaptionText ),
+    iAddressPopupList( NULL ),
     iAddLeftover( ETrue )
     {
     FUNC_LOG;
-	SetEdwinObserver( this );
+    SetEdwinObserver( this );
     }
 
 // ---------------------------------------------------------------------------
@@ -248,16 +249,15 @@
 CNcsAifEditor::~CNcsAifEditor()
     {
     FUNC_LOG;
-	iArray.ResetAndDestroy();
-	iAddressArray.Reset();
-	if ( iAsyncCallBack )
-	    {
-	    iAsyncCallBack->Cancel();
-	    delete iAsyncCallBack;
-	    }
+    iArray.ResetAndDestroy();
+    iAddressArray.Reset();
+    if ( iAsyncCallBack )
+        {
+        iAsyncCallBack->Cancel();
+        delete iAsyncCallBack;
+        }
     }
 
-
 // -----------------------------------------------------------------------------
 // CNcsAifEditor::CursorLineNumber() const
 // -----------------------------------------------------------------------------
@@ -311,22 +311,61 @@
         {
         ret = SetEditorSelectionL( aKeyEvent, aType );
         }
-    
+
     //when press a key down, record the coursor position
     if ( aType == EEventKeyDown )
-    	{
-    	iLastTimeCursorPos = CursorPos();
-    	}
+        {
+        iLastTimeCursorPos = CursorPos();
+        }
 
     if ( ret == EKeyWasNotConsumed )
         {
         // enter completes the address entry
-        if( aType == EEventKey && (aKeyEvent.iCode == EKeyEnter || 
-        	aKeyEvent.iScanCode == EStdKeyEnter) )
-        	{
-        	// make sure there is really some text inputted 
+        if ( aType == EEventKey && ( aKeyEvent.iCode == EKeyEnter || 
+             aKeyEvent.iScanCode == EStdKeyEnter ) )
+            {
+            // make sure there is really some text inputted 
+            const TInt cursorPos = CursorPos();
+            TCursorSelection selection = NonEntryTextAtPos( cursorPos );
+
+            const TInt length = selection.Length();
+            if ( length > 0 )
+                {
+                HBufC* text = HBufC::NewLC( length );
+                TPtr ptr = text->Des();
+                Text()->Extract( ptr, selection.LowerPos(), length );
+                ptr.Trim();
+
+                // complete the entry by adding a semicolon, 
+                // address will be added in HandleTextUpdateL
+                if ( ptr.Length() > 0 )
+                    {
+                    Text()->InsertL( cursorPos, KCharAddressDelimeterSemiColon );
+                    HandleTextChangedL();
+                    SetCursorPosL( cursorPos + 1, EFalse );
+                    iLastTimeCursorPos = CursorPos();
+                    HandleTextUpdateL();
+                    }
+
+                CleanupStack::PopAndDestroy( text );
+                }
+            }
+        else if ( IsCharacterKey( aKeyEvent ) )
+            {
+            PrepareForTextInputL( CursorPos() );
+            }
+        iTextSelection = Selection();
+        ret = CNcsEditor::OfferKeyEventL( aKeyEvent, aType );
+        }
+
+    // for Korean we need to simulate event 'text update' as FEP
+    // doesn't send it and the MRU is not shown
+    if ( User::Language() == ELangKorean )
+        {
+        if ( ret == EKeyWasNotConsumed && aType == EEventKeyUp )
+            {
             TInt cursorPos( CursorPos() );
-        	
+
             TCursorSelection selection = NonEntryTextAtPos( cursorPos );
             
             TInt length( selection.Length() );
@@ -335,20 +374,14 @@
             TPtr ptr = text->Des();
             Text()->Extract( ptr, selection.LowerPos(), length );
             ptr.Trim();
-            
-            // complete the entry by adding a semicolon, 
-            // address will be added in HandleTextUpdateL
-            if( ptr.Length() > 0 )
-            	{            
-				Text()->InsertL( cursorPos, KCharAddressDelimeterSemiColon );
-				HandleTextChangedL();
-				SetCursorPosL( cursorPos + 1, EFalse );
-            	}
-            
-            CleanupStack::PopAndDestroy( text );            
-        	}
-        iTextSelection = Selection();        
-        ret = CNcsEditor::OfferKeyEventL( aKeyEvent, aType );
+        
+            if ( TFsEmailUiUtility::IsKoreanWord( ptr ) )
+                {
+                HandleTextUpdateDeferred();
+                }
+        
+            CleanupStack::PopAndDestroy( text );
+            }
         }
     
     return ret;
@@ -400,7 +433,7 @@
     if ( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
         {
         CompleteEntryL();
-		
+
         response = CNcsEditor::OfferKeyEventL( aKeyEvent,aType );
         if ( response == EKeyWasConsumed ) 
             {
@@ -413,10 +446,11 @@
             }
         }
     // Check if the cursor is in any of the addresses
-    else if( aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyBackspace ) 
+    else if ( aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyBackspace ) 
         {
         // We're moving left, but haven't yet.
-        entry = GetEntryAt( CursorPos(), EDirectionLeft );
+        const TInt cursorPos = CursorPos();
+        entry = GetEntryAt( cursorPos, EDirectionLeft );
         if ( entry )
             {
             if ( selection.Length() && aKeyEvent.iCode == EKeyLeftArrow)
@@ -431,11 +465,25 @@
                 response = EKeyWasConsumed;
                 }
             }
+        else
+            {
+            // Complete entry, if cursor is being moved to the previous row.
+            TCursorSelection selection = NonEntryTextAndSpaceAtPos( cursorPos );
+            if ( cursorPos > 0 && selection.LowerPos() + 1 == cursorPos )
+                {
+                if ( IsDelimiter( CharAtPos( selection.LowerPos() ) ) )
+                    {
+                    CompleteEntryL();
+                    SetCursorPosL( cursorPos, EFalse );
+                    }
+                }
+            }
         }
-    else if( aKeyEvent.iCode == EKeyRightArrow || aKeyEvent.iCode == EKeyDelete )
+    else if ( aKeyEvent.iCode == EKeyRightArrow || aKeyEvent.iCode == EKeyDelete )
         {
         // We're moving right, but haven't yet.
-        entry = GetEntryAt( CursorPos(), EDirectionRight );
+        const TInt cursorPos = CursorPos();
+        entry = GetEntryAt( cursorPos, EDirectionRight );
         if ( entry )
             {
             if ( selection.Length() && aKeyEvent.iCode == EKeyRightArrow  )
@@ -450,6 +498,18 @@
                 response = EKeyWasConsumed;
                 }
             }
+        else
+            {
+            // Complete entry, if cursor is being moved to the next row.
+            TCursorSelection selection = NonEntryTextAndSpaceAtPos( cursorPos );
+            if ( cursorPos > 0 && selection.HigherPos() - 1 == cursorPos )
+                {
+                if ( IsDelimiter( CharAtPos( selection.HigherPos() - 1 ) ) )
+                    {
+                    CompleteEntryL();
+                    }
+                }
+            }
         }
     // to fix problems with updating CBA when hash key is pressed and hold
     else if ( aKeyEvent.iScanCode == EStdKeyHash ) 
@@ -507,10 +567,11 @@
                     break;
                     }
                 }
-            
+
+            SetCursorVisible( EFalse );
             ClearSelectionL();
-            
-            RepositionEntriesL( entry );
+            RepositionEntries( entry );
+            SetCursorVisible( ETrue );
 
             // The key event is set consumed only on delete and backpace
             // events, other events need to be forwarded to the editor.
@@ -529,26 +590,26 @@
 // ---------------------------------------------------------------------------
 //
 void CNcsAifEditor::DoCharChangeL()
-	{
+    {
     FUNC_LOG;
-	RecalculateEntryPositions();
+    RecalculateEntryPositions();
 
-	TChar previousChar = CharAtPos( CursorPos() - 1 );
-	TBool sentinel = ( previousChar == KCharAddressDelimeterSemiColon || 
-	    previousChar == KCharAddressDelimeterComma );
-	if ( sentinel )
+    TChar previousChar = CharAtPos( CursorPos() - 1 );
+    TBool sentinel = ( previousChar == KCharAddressDelimeterSemiColon || 
+        previousChar == KCharAddressDelimeterComma );
+    if ( sentinel )
         {
         // if comma was pressed we replace it with semicolon
-		if ( previousChar == KCharAddressDelimeterComma )
+        if ( previousChar == KCharAddressDelimeterComma )
             {
-			CPlainText* text = Text();
-			text->DeleteL( CursorPos() - 1, 1 );
-			text->InsertL( CursorPos() - 1, KCharAddressDelimeterSemiColon );
+            CPlainText* text = Text();
+            text->DeleteL( CursorPos() - 1, 1 );
+            text->InsertL( CursorPos() - 1, KCharAddressDelimeterSemiColon );
             }
-		ParseNewAddressL();
+        ParseNewAddressL();
         }
-	UpdateAddressAutoCompletionL();
-	}
+    UpdateAddressAutoCompletionL();
+    }
 
 // ---------------------------------------------------------------------------
 // CNcsAddressInputField::CharAtPos
@@ -557,15 +618,15 @@
 TChar CNcsAifEditor::CharAtPos( TInt aPos ) const
     {
     FUNC_LOG;
-	if ( aPos >= 0 && aPos < TextLength() )
+    if ( aPos >= 0 && aPos < TextLength() )
         {
-		TBuf<1> buf;
-		Text()->Extract( buf, aPos, 1 );
-		return buf[0];
+        TBuf<1> buf;
+        Text()->Extract( buf, aPos, 1 );
+        return buf[0];
         }
-	else
+    else
         {
-		return 0;
+        return 0;
         }
     }
 
@@ -584,7 +645,8 @@
 // CNcsAifEditor::AppendAddressesL()
 // -----------------------------------------------------------------------------
 //
-void CNcsAifEditor::AppendAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddresses )
+void CNcsAifEditor::AppendAddressesL( 
+    const RPointerArray<CNcsEmailAddressObject>& aAddresses )
     {
     FUNC_LOG;
     // First, add all the addresses without updating the editor text contents 
@@ -592,8 +654,13 @@
         {
         AddAddressL( *aAddresses[i], EFalse );
         }
-    // Update editor text content after all the items have been added
-    RepositionEntriesL( NULL );
+
+    // Update editor text content after all the items have been added.
+    SetCursorVisible( EFalse );
+    const TInt count = iArray.Count();
+    CNcsAifEntry* lastEntry = count ? iArray[count-1] : NULL;
+    RepositionEntries( lastEntry );
+    SetCursorVisible( ETrue );
     }
 
 // -----------------------------------------------------------------------------
@@ -602,17 +669,17 @@
 //   
 const RPointerArray<CNcsEmailAddressObject>& CNcsAifEditor::GetAddressesL()
     {
-	// Clear the existing array since it may be out of sync
-	iAddressArray.Reset();
+    // Clear the existing array since it may be out of sync
+    iAddressArray.Reset();
 
-	for ( TInt i=0 ; i<iArray.Count() ; i++ ) 
+    for ( TInt i=0; i<iArray.Count(); i++ ) 
         {
-		iAddressArray.AppendL(&iArray[i]->Address());
+        iAddressArray.AppendL( &iArray[i]->Address() );
         }
 
-	return iAddressArray;
+    return iAddressArray;
     }
-    
+
 // -----------------------------------------------------------------------------
 // CNcsAifEditor::GetEntryAt()
 // -----------------------------------------------------------------------------
@@ -710,29 +777,29 @@
 void CNcsAifEditor::ParseNewAddressL()
 	{
     FUNC_LOG;
-	HBufC* text = GetNonEntryTextLC();
-	__ASSERT_ALWAYS( text, Panic(EFSEmailUiNullPointerException) );
+    HBufC* text = GetNonEntryTextLC();
+    __ASSERT_ALWAYS( text, Panic(EFSEmailUiNullPointerException) );
 
-	if ( text->Length() )
-		{
+    if ( text->Length() )
+        {
         // if changing focus leftover text is parsed to email
         // object - we don't need to add it anymore
         iAddLeftover = EFalse;
         // check if there is a name for the email address
         HBufC* name = CFsDelayedLoader::InstanceL()->GetContactHandlerL()->GetLastSearchNameL( *text );
-	if ( name )
-		{
+        if ( name )
+            {
             CleanupStack::PushL( name );
-		AddAddressL( *name, *text, ETrue );
-		CleanupStack::PopAndDestroy( name );
-		}
-	else
-		{
-		AddAddressL( KNullDesC, *text );
-		}
-	    }
-	
-	CleanupStack::PopAndDestroy(text);
+            AddAddressL( *name, *text, ETrue );
+            CleanupStack::PopAndDestroy( name );
+            }
+        else
+            {
+            AddAddressL( KNullDesC, *text );
+            }
+        }
+
+    CleanupStack::PopAndDestroy(text);
 	}
 
 // -----------------------------------------------------------------------------
@@ -848,7 +915,8 @@
 // CNcsAifEditor::AddAddressL()
 // -----------------------------------------------------------------------------
 //
-void CNcsAifEditor::AddAddressL( const CNcsEmailAddressObject& aAddress, TBool aUpdateEditorText /*= ETrue*/ )
+void CNcsAifEditor::AddAddressL( const CNcsEmailAddressObject& aAddress,
+    TBool aUpdateEditorText /*= ETrue*/ )
     {
     FUNC_LOG;
     CNcsAifEntry* entry = CNcsAifEntry::NewL( aAddress );
@@ -866,57 +934,59 @@
     FUNC_LOG;
     CNcsAifEntry* entry = CNcsAifEntry::NewL( aDisplayName, aEmail, aDisplayFull );
     CleanupStack::PushL( entry );
-	AddAddressL( entry, aUpdateEditorText );
-	CleanupStack::Pop( entry );
+    AddAddressL( entry, aUpdateEditorText );
+    CleanupStack::Pop( entry );
     }
 
 void CNcsAifEditor::AddAddressL( CNcsAifEntry* aNewEntry, TBool aUpdateEditorText )
     {
     FUNC_LOG;
-	TInt idx;
-	
-	// Check for duplicate display names
-	for ( idx=0 ; idx<iArray.Count() ; idx++ ) 
+    TInt idx;
+
+    // Check for duplicate display names
+    for ( idx=0 ; idx<iArray.Count() ; idx++ ) 
         {
-		if ( iArray[idx]->IsSameDN(*aNewEntry) ) 
+        if ( iArray[idx]->IsSameDN(*aNewEntry) ) 
             {
-			iArray[idx]->SetDupL();
-			aNewEntry->SetDupL();
+            iArray[idx]->SetDupL();
+            aNewEntry->SetDupL();
             }
         }
 
-	// Find the location where we need to insert the address.
-	// Browse from back to forth to make last index as default index. 
-	// This ensures items remain in correct order when populating field from
-	// existing message.
-	TInt cursorPos = CursorPos();
+    // Find the location where we need to insert the address.
+    // Browse from back to forth to make last index as default index. 
+    // This ensures items remain in correct order when populating field from
+    // existing message.
+    TInt cursorPos = CursorPos();
     // if we are at the end of editor the address was
     // added from MRU list or separator was typed in
     if ( cursorPos == Text()->DocumentLength() )
         {
         iAddLeftover = EFalse;
         }
-	
-	for ( idx = iArray.Count() ; idx > 0 ; idx-- ) 
+
+    for ( idx = iArray.Count() ; idx > 0 ; idx-- ) 
         {
-		if ( cursorPos >= iArray[idx-1]->End() ) break;
+        if ( cursorPos >= iArray[idx-1]->End() ) break;
         }
-	if ( idx == iArray.Count() ) 
+    if ( idx == iArray.Count() ) 
         {
-		// Tack the address onto the end of the array
-		iArray.AppendL( aNewEntry );
+        // Tack the address onto the end of the array
+        iArray.AppendL( aNewEntry );
         }
-	else
+    else
         {
-		iArray.InsertL( aNewEntry, idx );
+        iArray.InsertL( aNewEntry, idx );
         }
-	
-	if ( aUpdateEditorText )
-	    {
-	    // Trap because we must not leave after we have taken the ownership of aNewEntry.
-	    // Otherwise douple deletion might happen.
-	    TRAP_IGNORE( RepositionEntriesL( aNewEntry ) );
-	    }
+
+    if ( aUpdateEditorText )
+        {
+        // Trap because we must not leave after we have taken the ownership of
+        // aNewEntry. Otherwise douple deletion might happen.
+        SetCursorVisible( EFalse );
+        RepositionEntries( aNewEntry );
+        SetCursorVisible( ETrue );
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -966,27 +1036,37 @@
 	}
 
 // ---------------------------------------------------------------------------
+// CNcsAifEditor::RepositionEntries()
+// ---------------------------------------------------------------------------
+//
+TInt CNcsAifEditor::RepositionEntries( const CNcsAifEntry* aPosEntry )
+    {
+    FUNC_LOG;
+    TRAPD( err, RepositionEntriesL( aPosEntry ) );
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
 // CNcsAifEditor::RepositionEntriesL()
 // ---------------------------------------------------------------------------
 //
 void CNcsAifEditor::RepositionEntriesL( const CNcsAifEntry* aPosEntry )
-	{
+    {
     FUNC_LOG;
-	TInt pos = 0;
-	CNcsAifEntry* entry;
-	for ( TInt i=0 ; i<iArray.Count() ; i++ ) 
-		{
-		entry = iArray[i];
-		pos = entry->SetPos( pos );
-		pos++; // for whitespace
-		}
+    TInt pos = 0;
+    CNcsAifEntry* entry;
+    for ( TInt i=0 ; i<iArray.Count() ; i++ ) 
+        {
+        entry = iArray[i];
+        pos = entry->SetPos( pos );
+        pos++; // for whitespace
+        }
 
-  // Reset the text
-	HBufC* text = NULL;
-	text = GetFormattedAddressListLC( iArray );
-	// fix for dissapearing text PWAN-82DNEJ	
-	SetCursorPosL( 0, EFalse ); //In case the cursor pos is invalid
-	
+    // Reset the text
+    HBufC* text = GetFormattedAddressListLC( iArray );
+    // fix for dissapearing text PWAN-82DNEJ
+    //SetCursorPosL( 0, EFalse ); //In case the cursor pos is invalid
+
     if ( iAddLeftover )
         {
         TInt lengthBefore = Text()->DocumentLength();
@@ -1001,10 +1081,10 @@
         HBufC* newText = HBufC::NewLC( text->Length() + leftover.Length() );
         TPtr newTextPtr = newText->Des();
         // add all email addresses
-        newTextPtr.Append( text->Des() );
+        newTextPtr.Append( *text );
         // add the text that was after last email object
         newTextPtr.Append( leftover );
-    
+
         SetTextL( newText );
         CleanupStack::PopAndDestroy( newText );
         CleanupStack::PopAndDestroy( textBefore );
@@ -1013,19 +1093,21 @@
         {
         SetTextL( text );
         }
+
+    if ( !aPosEntry )
+        {
+        // Set cursor at the beginning of the document.
+        SetCursorPosL( 0, EFalse );
+        }
+    else
+        {
+        // Set the cursor at the end of the given entry 
+        SetCursorPosL( aPosEntry->End(), EFalse );
+        }
+
     CleanupStack::PopAndDestroy( text );
     HandleTextChangedL();
-    
-    // Set the cursor at the end of the given entry 
-    if ( !aPosEntry )
-    	{
-	    SetCursorPosL( 0, EFalse );
-    	}
-    else
-    	{
-    	SetCursorPosL( aPosEntry->End(), EFalse );
-    	}
-	}
+    }
 
 // ---------------------------------------------------------------------------
 // CNcsAifEditor::CheckAndRemoveInvalidEntriesL()
@@ -1083,19 +1165,19 @@
 HBufC* CNcsAifEditor::GetLookupTextLC() const
     {
     FUNC_LOG;
-	HBufC* text = GetTextInHBufL();
-	
-	if (text == NULL) return NULL;
-
-	CleanupStack::PushL( text );
-	TPtr ptr( text->Des() );
-	TInt location = ptr.LocateReverse( KCharAddressDelimeterSemiColon );
-	if( location != KErrNotFound )
+    HBufC* text = GetTextInHBufL();
+    CleanupStack::PushL( text );
+    if ( text )
         {
-		ptr = ptr.RightTPtr( ptr.Length() - location -1 );
-		ptr.TrimLeft();
+        TPtr ptr( text->Des() );
+        TInt location = ptr.LocateReverse( KCharAddressDelimeterSemiColon );
+        if ( location != KErrNotFound )
+            {
+            ptr = ptr.RightTPtr( ptr.Length() - location -1 );
+            ptr.TrimLeft();
+            }
         }
-	return text;
+    return text;
     }
 
 // ---------------------------------------------------------------------------
@@ -1107,17 +1189,17 @@
     TBool aDisplayList ) const
     {
     FUNC_LOG;
-	TInt length = CalculateAddressListLength( aEntries, aDisplayList );
-	if ( length <= 0 )
+    TInt length = CalculateAddressListLength( aEntries, aDisplayList );
+    if ( length <= 0 )
         {
-		return HBufC::NewLC(0);
+        return HBufC::NewLC(0);
         }
-    
-	HBufC* buf = HBufC::NewLC( length );
-	TPtr ptr = buf->Des();
-    
-	TInt count = aEntries.Count();
-	for ( TInt i = 0; i < count; i++ )
+
+    HBufC* buf = HBufC::NewLC( length );
+    TPtr ptr = buf->Des();
+
+    TInt count = aEntries.Count();
+    for ( TInt i = 0; i < count; i++ )
         {
         if ( aDisplayList )
             {
@@ -1146,12 +1228,12 @@
 HBufC* CNcsAifEditor::GetFormattedAddressListL(
     RPointerArray<CNcsAifEntry>& aEntries,
     TBool aDisplayList ) const
-	{
+    {
     FUNC_LOG;
     HBufC* buf = GetFormattedAddressListLC( aEntries, aDisplayList );
     CleanupStack::Pop( buf );
     return buf;
-	}
+    }
 
 // ---------------------------------------------------------------------------
 // CNcsAifEditor::CalculateAddressListLength()
@@ -1202,12 +1284,12 @@
 void CNcsAifEditor::UpdateAddressAutoCompletionL()
     {
     FUNC_LOG;
-	HBufC* text = GetNonEntryTextLC();
-	__ASSERT_ALWAYS( text, Panic(EFSEmailUiNullPointerException) );
+    HBufC* text = GetNonEntryTextLC();
+    __ASSERT_ALWAYS( text, Panic(EFSEmailUiNullPointerException) );
 
-		iAddressPopupList->UpdatePopupContactListL( *text, EFalse );
-		CleanupStack::PopAndDestroy( text );
-        }
+    iAddressPopupList->UpdatePopupContactListL( *text, EFalse );
+    CleanupStack::PopAndDestroy( text );
+    }
 
 // ---------------------------------------------------------------------------
 // CNcsAifEditor::UpdateAddressAutoCompletionL()
@@ -1240,10 +1322,9 @@
 void CNcsAifEditor::UpdateAddressListAllL()
     {
     FUNC_LOG;
-	iAddressPopupList->UpdatePopupContactListL( KNullDesC, ETrue );
+    iAddressPopupList->UpdatePopupContactListL( KNullDesC, ETrue );
     }
 
-
 // ---------------------------------------------------------------------------
 // Updates the duplicate markings in the entry array.
 // ---------------------------------------------------------------------------
@@ -1306,38 +1387,23 @@
     FUNC_LOG;
     RecalculateEntryPositions();
     TCursorSelection textSelection = NonEntryTextAtPos( CursorPos() );
-    TBool newEntryCreated = EFalse;
     if ( textSelection.Length() )
         {
         // Check non-entry text for complete entries.
-        newEntryCreated = HandleTextUpdateL( textSelection );
+        const TBool newEntriesAdded = HandleTextUpdateL( textSelection );
+        if ( newEntriesAdded )
+            {
+            iAddressPopupList->ClosePopupContactListL();
+            iSizeObserver->UpdateFieldSizeL( ETrue );
+            iPartialRemove = EFalse;
+            }
+        else
+            {
+            MoveNonEntryTextToDedicatedRowsL( CursorPos() );
+            }
+        textSelection = NonEntryTextAtPos( CursorPos() );
         }
-    
-    if ( newEntryCreated )
-        {
-        iAddressPopupList->ClosePopupContactListL();
-        
-        // add line feed after new entry
-        TInt cursorPos( CursorPos() );
-        // related to PWAN-82DNEJ cursorPos shouldn't be 0 here
-        if (cursorPos == 0)
-          {
-          cursorPos = TextLength();
-          }
-          
-        if ( !iPartialRemove )
-            {
-            Text()->InsertL( cursorPos, TChar(CEditableText::ELineBreak) );
-            }
-        HandleTextChangedL();
-        SetCursorPosL( cursorPos + 1, EFalse );
-        iSizeObserver->UpdateFieldSizeL( ETrue );
-        iPartialRemove = EFalse;
-        }
-    else
-        {
-        UpdateAddressAutoCompletionL( textSelection );
-        }
+    UpdateAddressAutoCompletionL( textSelection );
     }
 
 // ---------------------------------------------------------------------------
@@ -1350,10 +1416,10 @@
     iAddLeftover = ETrue;
     TInt firstCharacter = aSelection.LowerPos();
     TInt lastCharacter = aSelection.HigherPos();
-    
+
     // get the inputted text
-    TInt length = lastCharacter - firstCharacter;
-    
+    const TInt length = lastCharacter - firstCharacter;
+
     HBufC* text = HBufC::NewLC( length );
     TPtr ptr = text->Des();
     Text()->Extract( ptr, firstCharacter, length );
@@ -1411,30 +1477,114 @@
                 }
             }
         }
-    
+
     // add email that wasn't ended with semicolon
     if ( lastSentinel != KErrNotFound )
         {
         if ( lastSentinel < end && start < end )
             {
             AddAddressL( KNullDesC(), ptr.Mid(start, end-start) );
+            entriesFound = ETrue;
             }
         }
-    
+
     CleanupStack::PopAndDestroy( text );
-        
     return entriesFound;
     }
 
 // ---------------------------------------------------------------------------
+// Moves inputted non-entry text to separate row
+// ---------------------------------------------------------------------------
+//
+void CNcsAifEditor::MoveNonEntryTextToDedicatedRowsL( TUint aPosition )
+    {
+    // Get the non-entry text and whitespace at given location
+    TCursorSelection textSelection = NonEntryTextAndSpaceAtPos( aPosition );
+    const TInt start = textSelection.LowerPos();
+    const TInt end = textSelection.HigherPos();
+    const TInt length = end - start;
+
+    const TChar lineBreak = TChar( CEditableText::ELineBreak );
+    const TChar paragraphDelimiter =
+        TChar( CEditableText::EParagraphDelimiter );
+
+    // Make sure that the inputted non-entry text is not on the same lines
+    // with existing entries.
+    if ( length )
+        {
+        HBufC* text = HBufC::NewLC( length );
+        TPtr ptr = text->Des();
+        Text()->Extract( ptr, start, length );
+
+        const TChar firstCharacter = TChar( ptr[0] );
+        const TChar lastCharacter = TChar( ptr[length-1] );
+        const TInt documentLength = Text()->DocumentLength();
+
+        TBool textChanged = EFalse;
+
+        if ( end < documentLength &&
+             lastCharacter != paragraphDelimiter &&
+             lastCharacter != lineBreak )
+            {
+            Text()->InsertL( end, lineBreak );
+            HandleTextChangedL();
+            textChanged = ETrue;
+            }
+
+        if ( start > 0 && start < end &&
+             firstCharacter != paragraphDelimiter &&
+             firstCharacter != lineBreak )
+            {
+            Text()->InsertL( start, lineBreak );
+            SetCursorVisible( EFalse );
+            HandleTextChangedL();
+            SetCursorPosL( CursorPos() + 1, EFalse );
+            SetCursorVisible( ETrue );
+            textChanged = ETrue;
+            }
+
+        if ( textChanged )
+            {
+            RecalculateEntryPositions();
+            }
+
+        CleanupStack::PopAndDestroy( text );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Prepares for text entry to given cursor position making sure that the
+// new text will not be entered on same row with existing 
+// ---------------------------------------------------------------------------
+//
+void CNcsAifEditor::PrepareForTextInputL( TUint aPosition )
+    {
+    FUNC_LOG;
+    // Get the non-entry text and whitespace at given position.
+    TCursorSelection textSelection = NonEntryTextAndSpaceAtPos( aPosition );
+    const TInt start = textSelection.LowerPos();
+    const TInt end = textSelection.HigherPos();
+    const TInt length = end - start;
+
+    const TChar lineBreak = TChar( CEditableText::ELineBreak );
+
+    if ( start > 0 && ( !length || aPosition == start ) )
+        {
+        Text()->InsertL( start, lineBreak );
+        HandleTextChangedL();
+        SetCursorPosL( start + 1, EFalse );
+        }
+    }
+
+// ---------------------------------------------------------------------------
 // Handles navigation event.
 // ---------------------------------------------------------------------------
 //
 void CNcsAifEditor::HandleNavigationEventL()
     {
     FUNC_LOG;
-    // Close the contact popup when cursor is moved withing the field to make it less distracting. 
-    // It's reopened when user types something.
+    // Close the contact popup when cursor is moved withing the field to make
+    // it less distracting. It's reopened when user types something.
     iAddressPopupList->ClosePopupContactListL();
     }
 
@@ -1445,6 +1595,51 @@
 TCursorSelection CNcsAifEditor::NonEntryTextAtPos( TUint aPosition ) const
     {
     FUNC_LOG;
+    // Get the range of non-entry text and whitespace at given position.
+    TCursorSelection text = NonEntryTextAndSpaceAtPos( aPosition );
+
+    // Get the selected text to remove whitespace
+    const TInt length = text.Length();
+
+    HBufC* selectedText = NULL;
+    TRAPD( err, selectedText = HBufC::NewL( length ) );
+
+    if( err == KErrNone )
+        {
+        TPtr ptr = selectedText->Des();
+        Text()->Extract( ptr, text.LowerPos(), length );
+
+        // trim from end
+        TInt index( length - 1 );
+
+        while( index >= 0 && IsWhitespace( ptr[index--] ) )
+            {
+            text.iCursorPos--;
+            }
+
+        // trim from begin
+        index = 0;
+
+        while( index < length && IsWhitespace( ptr[index++] ) )
+            {
+            text.iAnchorPos++;
+            }
+
+        delete selectedText;
+        selectedText = NULL;
+        }    
+
+    return text;
+    }
+
+// ---------------------------------------------------------------------------
+// Gets non-entry text including surrounding whitespace at given position.
+// ---------------------------------------------------------------------------
+//
+TCursorSelection CNcsAifEditor::NonEntryTextAndSpaceAtPos(
+    TUint aPosition ) const
+    {
+    FUNC_LOG;
     TCursorSelection text( TextLength(), 0 );
     for ( TInt ii = iArray.Count() - 1; ii >= 0; --ii )
         {
@@ -1467,37 +1662,6 @@
             }
         }
 
-    // get the selected text to remove whitespace
-    TInt length( text.Length() );    
-    
-    HBufC* selectedText = NULL;
-    TRAPD( err, selectedText = HBufC::NewL( length ) );
-    
-    if( err == KErrNone )
-    	{
-		TPtr ptr = selectedText->Des();
-		Text()->Extract( ptr, text.LowerPos(), length );
-		
-		// trim from end
-		TInt index( length - 1 );
-		
-		while( index >= 0 && IsWhitespace( ptr[index--] ) )
-			{
-			text.iCursorPos--;
-			}
-		
-		// trim from begin
-		index = 0;
-		
-		while( index < length && IsWhitespace( ptr[index++] ) )
-			{
-			text.iAnchorPos++;
-			}
-
-		delete selectedText;
-		selectedText = NULL;
-    	}    
-    	
     return text;
     }
 
@@ -1540,6 +1704,18 @@
     }
 
 // ---------------------------------------------------------------------------
+// Checks whether given character is considered as line delimiter.
+// ---------------------------------------------------------------------------
+//
+//
+TBool CNcsAifEditor::IsDelimiter( TChar aCharacter ) const
+    {
+    FUNC_LOG;
+    return ( aCharacter == TChar( CEditableText::ELineBreak) || 
+             aCharacter == TChar( CEditableText::EParagraphDelimiter) );
+    }
+
+// ---------------------------------------------------------------------------
 // Checks whether given character is considered as whitespace.
 // ---------------------------------------------------------------------------
 //
@@ -1547,8 +1723,8 @@
     {
     FUNC_LOG;
     return ( aCharacter == KCharSpace || 
-    		 aCharacter == TChar(CEditableText::ELineBreak) || 
-    		 aCharacter == TChar(CEditableText::EParagraphDelimiter) );
+             aCharacter == TChar(CEditableText::ELineBreak) || 
+             aCharacter == TChar(CEditableText::EParagraphDelimiter) );
     }
 
 // ---------------------------------------------------------------------------
@@ -1648,61 +1824,68 @@
 
         //adjust touch point to mach editor coordinates
         touchPoint.iX -= Position().iX;
-        
-        TInt pointerLineNbr = textLayout->GetLineNumber( textLayout->XyPosToDocPosL( touchPoint ));
+
+        TInt pointerLineNbr = textLayout->GetLineNumber( 
+            textLayout->XyPosToDocPosL( touchPoint ) );
         TInt cursorLineNbr = textLayout->GetLineNumber( cursorPos );
-        
-        
+
         if ( pointerLineNbr != cursorLineNbr )
             {
             CompleteEntryL();
             
             // We're moving to a new line.
-            CNcsAifEntry* entry = NULL;
-            entry = GetEntryAt( CursorPos() );
+            CNcsAifEntry* entry = GetEntryAt( CursorPos() );
             if ( entry )
                 {
                 SetSelectionL( entry->iCursorPos, entry->iAnchorPos );
                 }
-            }    
+            }
         }
-            
+
     CEikEdwin::HandlePointerEventL( aPointerEvent );
+
+    // Do not allow to insert cursor into the middle of some entry
+    CNcsAifEntry* entry = GetEntryAt( CursorPos() );
+    if ( entry )
+        {
+        SetSelectionL( entry->iCursorPos, entry->iAnchorPos );
+        }
     }
 
 
 // -----------------------------------------------------------------------------
 // CNcsAifEditor::CompleteEntryL()
-// Adds semicolol to the of the entry
+// Adds semicolon to the end of the entry.
 // -----------------------------------------------------------------------------
 //
 void CNcsAifEditor::CompleteEntryL()
     {
     // make sure there is really some text inputted 
-    TInt cursorPos( CursorPos() );
+    const TInt cursorPos = CursorPos();
 
     TCursorSelection selection = NonEntryTextAtPos( cursorPos );
-
-    TInt length( selection.Length() );
+    const TInt length =  selection.Length();
 
-    HBufC* text = HBufC::NewLC( length );
-    TPtr ptr = text->Des();
+    if ( length > 0 && selection.LowerPos() >= 0 )
+        {
+        HBufC* text = HBufC::NewLC( length );
+        TPtr ptr = text->Des();
 
-    if( selection.LowerPos() >= 0 )
-        {
         Text()->Extract( ptr, selection.LowerPos(), length );
         ptr.Trim();
-        
+
         // complete the entry
-        if( ptr.Length() > 0 )
+        if ( ptr.Length() > 0 )
             {
             Text()->InsertL( selection.HigherPos(), KCharAddressDelimeterSemiColon );
             HandleTextChangedL();
-            HandleTextUpdateL( TCursorSelection(selection.LowerPos(), selection.HigherPos() + 1) );
+            HandleTextUpdateL( TCursorSelection( selection.LowerPos(),
+                selection.HigherPos() + 1 ) );
             }
+
+        CleanupStack::PopAndDestroy( text );
         }
+    }
 
-    CleanupStack::PopAndDestroy( text );
-    }
 // End of File
 
--- a/emailuis/emailui/src/ncscomposeview.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/ncscomposeview.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -347,7 +347,19 @@
     // once from BaseView.
     if ( iLaunchParams.iActivatedExternally )
         {
-        iAppUi.ViewActivatedExternallyL( Id() );
+        //notify Contact details view to close on external activation
+        CFSEmailUiContactHandler* contactHandler = NULL; // not owned
+        CFsDelayedLoader* delLoader = CFsDelayedLoader::InstanceL(); // not owned
+        if( delLoader )
+            {
+            contactHandler = delLoader->GetContactHandlerL();
+            
+            if( contactHandler && aPrevViewId.iViewUid == contactHandler->GetDetailsViewUid() )
+                {
+                contactHandler->CloseContactDetailsL();
+                }
+            iAppUi.ViewActivatedExternallyL( Id() );
+            }
         }
 
     // Try to get the mailbox by other means if using launch parameters failed
@@ -1719,8 +1731,7 @@
         TFsEmailUiUtility::CreatePlainTextPartL( 
                 *iNewMessage, iNewMessageTextPart );
         InitFieldsL();
-        TBool spaceInBegin = ETrue;
-        IncludeMessageTextL(spaceInBegin);
+        IncludeMessageTextL();
         AttachmentsListControl()->Model()->Clear();
         GetAttachmentsFromMailL();
         SetAttachmentLabelContentL();
@@ -2520,7 +2531,13 @@
             CFSMailMessagePart* msgPart = 
                 iNewMessage->ChildPartL( item->MailMsgPartId() );
             CleanupStack::PushL( msgPart );
+            
+            //We are forbidding to change MSK label during OpenAttachmentL
+            //because dialog/popup can be open
+            iContainer->SwitchChangeMskOff( ETrue );
             TFsEmailUiUtility::OpenAttachmentL( *msgPart );
+            iContainer->SwitchChangeMskOff( EFalse );
+            
             CleanupStack::PopAndDestroy( msgPart );
             }
         }
--- a/emailuis/emailui/src/ncscomposeviewcontainer.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/ncscomposeviewcontainer.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -148,7 +148,7 @@
     // Listen edwin events and size events from smart quote field
     iReadOnlyQuoteField->AddEdwinObserverL( this );
     iReadOnlyQuoteField->SetEdwinSizeObserver( this );
-   iReadOnlyQuoteField->EnableKineticScrollingL( iPhysics );
+    iReadOnlyQuoteField->EnableKineticScrollingL( iPhysics );
 
     // Create the scroll bar
     iScrollBar = new( ELeave ) CAknDoubleSpanScrollBar( this );
@@ -199,16 +199,16 @@
         iAsyncTextFormatter->Cancel();
         delete iAsyncTextFormatter;
         }
-    
+
     if ( iContactHandler )
         {
         iContactHandler->ClearObservers();
         }
-	delete iHeader;
+    delete iHeader;
     delete iScrollBar;
     delete iMessageField;
     delete iBgContext;
-	delete iLongTapDetector;
+    delete iLongTapDetector;
     delete iReadOnlyQuoteField;
     delete iReadOnlyQuote;
 
@@ -226,33 +226,20 @@
     {
     FUNC_LOG;
 
-	if ( iFocused != iHeader &&
-	     iFocused != iMessageField &&
-	     iFocused != iReadOnlyQuoteField )
-        {
-		iFocused = iHeader;
-        }
-    if ( iFocused == iHeader )
+    if ( iFocused != iHeader &&
+         iFocused != iMessageField &&
+         iFocused != iReadOnlyQuoteField )
         {
-        iHeader->ShowCursor( IsFocused() );
-        iFocused->SetFocus( ETrue, aDrawNow );
-        }
-    else if ( iFocused == iMessageField )
-        {
-        iFocused->SetFocus( IsFocused(), aDrawNow );
-        }
-    else 
-        {
-        iFocused->SetFocus( ETrue, aDrawNow );
+        iFocused = iHeader;
         }
 
+    iFocused->SetFocus( IsFocused(), aDrawNow );
     iView.HandleContainerChangeRequiringToolbarRefresh();
 
-	if ( aDrawNow )
-	    {
-		DrawNow();
-	    }
-
+    if ( aDrawNow )
+        {
+        DrawNow();
+        }
     }
 // -----------------------------------------------------------------------------
 // CNcsComposeViewContainer::SetMskL()
@@ -274,21 +261,20 @@
         const TPointerEvent& aPointerEvent )
     {
     FUNC_LOG;
-	TBool clearSelection(EFalse);
+    TBool clearSelection(EFalse);
     if ( aPointerEvent.iType != TPointerEvent::EButton1Down &&
-         iHeader->NeedsLongTapL( aPointerEvent.iPosition ) )
+            iHeader->NeedsLongTapL( aPointerEvent.iPosition ) )
         {
-    	iLongTapDetector->PointerEventL( aPointerEvent );
+        iLongTapDetector->PointerEventL( aPointerEvent );
         }
-	   
+
     switch( aPointerEvent.iType )
-    	{
-    	case TPointerEvent::EButton1Down:
-    		{
+        {
+        case TPointerEvent::EButton1Down:
+            {
             // Save current and original position so that those can be used in
             // drag/scrolling calculations
-            iPreviousPosition = iOriginalPosition = 
-                aPointerEvent.iPosition;
+            iPreviousPosition = iOriginalPosition = aPointerEvent.iPosition;
             iIsDragging = EFalse;
             iIsFlicking = EFalse;
 
@@ -298,19 +284,19 @@
                 iPhysics->ResetFriction();
                 iStartTime.HomeTime();
                 UpdatePhysicsL();
-                }            
+                }
 
             if ( iHeader->Rect().Contains( aPointerEvent.iPosition ) )
                 {
                 if ( iFocused == iMessageField )
                     {
-					if( iMessageField->SelectionLength() )
-						{
-						iMessageField->ClearSelectionL();
-						}
+                    if( iMessageField->SelectionLength() )
+                        {
+                        iMessageField->ClearSelectionL();
+                        }
                     iMessageField->SetFocus( EFalse, ENoDrawNow );
                     iFocused = iHeader;
-                    iHeader->SetFocus( ETrue,ENoDrawNow );
+                    iHeader->SetFocus( ETrue, ENoDrawNow );
                     }
                 else if ( iFocused == iReadOnlyQuoteField )
                     {
@@ -395,45 +381,43 @@
             TPoint position = aPointerEvent.iPosition;
 
 
-           if( iPhysics )
-               {
-			   if ( iIsDragging )
-				   {
+            if ( iPhysics )
+                {
+                if ( iIsDragging )
+                    {
                     TPoint delta( 0, iPreviousPosition.iY - position.iY );
                     if ( !( iMessageField->SelectionLength() || iReadOnlyQuoteField->SelectionLength() ) )
-                    		iPhysics->RegisterPanningPosition( delta );
-				   }
+                        iPhysics->RegisterPanningPosition( delta );
+                    }
                 }
             else
                 {
-    			TInt topPosition( -iHeader->Position().iY );
-    						
-    			TInt totalHeight( ContentTotalHeight() );
+                TInt topPosition( iHeaderPos.iY - iHeader->Position().iY );
+                TInt totalHeight( ContentTotalHeight() );
+                TInt areaHeight( VisibleAreaHeight() );
+                TInt scrollOffset( 0 );
 
-    			TInt areaHeight( Rect().Size().iHeight );
-    			TInt scrollOffset( 0 );
-    			
-				if( totalHeight > areaHeight )
-					{
-					// Calculate new scroll offset based on current and
-					// previous Y-positions
-					scrollOffset = topPosition + 
-                        ( iPreviousPosition.iY - position.iY );
-					// Ensure that thumb position is in correct range
-					scrollOffset = Max( scrollOffset, 0 );
-					scrollOffset = Min( scrollOffset, 
-                                        totalHeight - areaHeight );
-					}
+                if ( totalHeight > areaHeight )
+                    {
+                    // Calculate new scroll offset based on current and
+                    // previous Y-positions
+                    scrollOffset = topPosition + 
+                            ( iPreviousPosition.iY - position.iY );
+                    // Ensure that thumb position is in correct range
+                    scrollOffset = Max( scrollOffset, 0 );
+                    scrollOffset = Min( scrollOffset, 
+                            totalHeight - areaHeight );
+                    }
 
-				Scroll( scrollOffset );
-				}
-           
-			// Save current position as previous pos for future calculations
-			iPreviousPosition = position;  
-			
-			break;
-    		}
-    		
+                Scroll( scrollOffset );
+                }
+
+            // Save current position as previous pos for future calculations
+            iPreviousPosition = position;  
+
+            break;
+            }
+
     	default:
     		{
     		// unknown event, ignored
@@ -546,18 +530,18 @@
     }
 
 // -----------------------------------------------------------------------------
-// CNcsComposeViewContainer::UpdateScreenPositionL()
+// CNcsComposeViewContainer::UpdateScreenPosition()
 // If the user scrolled down in the message field
 // we want to scroll up the header and grow the message field.
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeViewContainer::UpdateScreenPositionL( 
+void CNcsComposeViewContainer::UpdateScreenPosition( 
         const TUint& /*aKeyCode*/ )
     {
     FUNC_LOG;
 
     // get screen rectangle
-    const TRect screenRect( Rect() );
+    const TRect screenRect = iCmailPaneRect;
 
     TPoint msgPos( iMessageField->Position() );
     TPoint quotePos( iReadOnlyQuoteField->Position() );
@@ -566,12 +550,12 @@
     TRect lineRect;
     if ( iFocused == iMessageField )
         {
-        iMessageField->GetLineRectL( lineRect );
+        iMessageField->GetLineRect( lineRect );
         lineRect.Move( msgPos );
         }
     else if ( iFocused == iReadOnlyQuoteField )
         {
-        iReadOnlyQuoteField->GetLineRectL( lineRect );
+        iReadOnlyQuoteField->GetLineRect( lineRect );
         lineRect.Move( quotePos );
         }
     else
@@ -582,8 +566,8 @@
         }
     TPoint linePos = lineRect.iTl;
 
-    TInt minTargetY = lineRect.Height();
-    TInt maxTargetY = screenRect.Height() - lineRect.Height() * 2;
+    TInt minTargetY = screenRect.iTl.iY + lineRect.Height();
+    TInt maxTargetY = screenRect.iBr.iY - lineRect.Height() * 2;
 
     TInt moveY = 0;
     // if cursor goes out of screen then move the controls
@@ -598,17 +582,17 @@
 
     // Check we don't scroll too low
     if ( quotePos.iY + moveY + iReadOnlyQuoteField->Size().iHeight < 
-         screenRect.Height() )
+         screenRect.iBr.iY )
         {
-        moveY = screenRect.Height() - quotePos.iY - 
+        moveY = screenRect.iBr.iY - quotePos.iY - 
             iReadOnlyQuoteField->Size().iHeight;
         }
 
     // Check we don't scroll too high
     TPoint headerPos = iHeader->Position();
-    if ( headerPos.iY + moveY > 0 )
+    if ( headerPos.iY + moveY > iHeaderPos.iY )
         {
-        moveY = -headerPos.iY;
+        moveY = iHeaderPos.iY - headerPos.iY;
         }
 
     if ( moveY )
@@ -616,13 +600,24 @@
         headerPos.iY += moveY;
         iHeader->SetPosition( headerPos );
 
+        iSeparatorLineYPos += moveY;
+
         msgPos.iY += moveY;
         iMessageField->SetPosition( msgPos );
 
         quotePos.iY += moveY;
         iReadOnlyQuoteField->SetPosition( quotePos );
 
-        iSeparatorLineYPos += moveY;
+        const TInt bottom = Rect().iBr.iY;
+        if ( iMessageField->IsFocused() )
+            {
+            iMessageField->SetCursorVisible( msgPos.iY <= bottom );
+            }
+        else if ( iReadOnlyQuoteField->IsFocused() )
+            {
+            iReadOnlyQuoteField->SetCursorVisible( quotePos.iY <= bottom );
+            }
+
         UpdateScrollBar();
         }
     }
@@ -657,6 +652,18 @@
         quotePos.iY = iMessageField->Rect().iBr.iY;
         iReadOnlyQuoteField->SetPosition( quotePos );
 
+        const TInt bottom = Rect().iBr.iY;
+        if ( iMessageField->IsFocused() )
+            {
+            iMessageField->SetCursorVisible( bodyPos.iY <= bottom );
+            }
+        else if ( iReadOnlyQuoteField->IsFocused() )
+            {
+            iReadOnlyQuoteField->SetCursorVisible( quotePos.iY <= bottom );
+            }
+
+        TInt scrollSpan = Max( ContentTotalHeight(), VisibleAreaHeight() + 1 );
+        iScrollBarModel.SetScrollSpan( scrollSpan );
         UpdateScrollBar();
         DrawDeferred();
         }
@@ -668,7 +675,6 @@
 // Handles key events
 // -----------------------------------------------------------------------------
 //
-
 TKeyResponse CNcsComposeViewContainer::ChangeFocusL( 
         const TKeyEvent& aKeyEvent )
     {
@@ -691,7 +697,6 @@
             iHeader->SetFocus( ETrue, ENoDrawNow );
             iMessageField->SetFocus( EFalse, ENoDrawNow );
             iHeader->MakeVisible( ETrue );
-            iHeader->ShowCursor( ETrue );
             CommitL( EBodyField );
             ret = EKeyWasConsumed;
             }
@@ -717,9 +722,10 @@
 
     if ( ret == EKeyWasConsumed )
         {
-        UpdateScreenPositionL( aKeyEvent.iCode );
+        UpdateScreenPosition( aKeyEvent.iCode );
         }
 
+    DrawDeferred();
     return ret;
     }
 
@@ -747,7 +753,7 @@
 
 // -----------------------------------------------------------------------------
 // CNcsComposeViewContainer::SizeChanged()
-// set size
+// Handles container size change.
 // -----------------------------------------------------------------------------
 //
 void CNcsComposeViewContainer::SizeChanged()
@@ -759,9 +765,13 @@
     TRect cmailPaneRect( NcsUtility::ListCmailPaneRect( rect ) );
 
     const TInt headerLineCount( iHeader->LayoutLineCount() );
-    const TPoint headerPos( 
-            NcsUtility::HeaderControlPosition( cmailPaneRect, 0 ) );
-    cmailPaneRect.Move( 0, iHeader->Position().iY - headerPos.iY );
+    iHeaderPos = NcsUtility::HeaderControlPosition( cmailPaneRect, 0 );
+    iHeader->SetOrigin( iHeaderPos );
+    const TPoint currentHeaderPos = iHeader->Position();
+    if ( currentHeaderPos.iY > iHeaderPos.iY )
+        {
+        cmailPaneRect.Move( 0, currentHeaderPos.iY - iHeaderPos.iY );
+        }
     iCmailPaneRect = cmailPaneRect;
 
     NcsUtility::LayoutHeaderControl( 
@@ -801,10 +811,17 @@
         iReadOnlyQuoteField->UpdateFontSize();
         readOnlyQuoteFieldHeight = iReadOnlyQuoteField->Rect().Height();
         }
+    else
+        {
+        // Set quote field immediatelly bellow message field with zero height.
+        TRect quoteRect = iMessageField->Rect();
+        quoteRect.iTl = quoteRect.iBr;
+        iReadOnlyQuoteField->SetRect( quoteRect );
+        }
 
-    iBgContext->SetRect( Rect() );
-    iMessageField->SetRealRect( Rect() );
-    iReadOnlyQuoteField->SetRealRect( Rect() );
+    iBgContext->SetRect( rect );
+    iMessageField->SetRealRect( rect );
+    iReadOnlyQuoteField->SetRealRect( rect );
 
     TInt messageLineHeigth = 
         NcsUtility::HeaderCaptionPaneRect( cmailPaneRect ).Height();
@@ -831,20 +848,32 @@
         iMessageEditorMinHeigth = messageLineHeigth;
         }
 
-	// update some layout variables
+    // update some layout variables
     iHeaderHeight = iHeader->Rect().Height();
     TRect bodyRect = iMessageField->Rect();
+    iReadOnlyQuoteField->SetPosition( 
+        TPoint( bodyRect.iTl.iX, bodyRect.iBr.iY ) );
     TRect quoteRect = iReadOnlyQuoteField->Rect();
 
-    iTotalComposerHeight = iHeaderHeight + iSeparatorHeight * 2 + 
-							   bodyRect.Height() + quoteRect.Height();
-    
-    iVisibleAreaHeight = Rect().Height();
-        
+    iTotalComposerHeight = iHeaderHeight + iSeparatorHeight + 
+        bodyRect.Height() + quoteRect.Height();
+
+    iVisibleAreaHeight = iCmailPaneRect.Height();
+
+    // Scroll span is set always to be larger than the window size to
+    // keep the scroll bar visible.
+    TInt scrollSpan = Max( iTotalComposerHeight, iVisibleAreaHeight + 1 );
+    iScrollBarModel.SetScrollSpan( scrollSpan );
+    iScrollBarModel.SetWindowSize( iVisibleAreaHeight );
+    if ( iHeader->IsFocused() )
+        {
+        iHeader->DoScroll();
+        }
+    else
+        {
+        UpdateScreenPosition();
+        }
     UpdateScrollBar();
-
-    iScrollBarModel.SetScrollSpan( iTotalComposerHeight );
-    iScrollBarModel.SetWindowSize( iVisibleAreaHeight );
     DrawDeferred();
     }
 
@@ -959,13 +988,13 @@
         iProcessedField = iReadOnlyQuoteField;
         if ( iReadOnlyQuote )
             {
-			TInt dummySeparatorPos;
-			NcsUtility::LayoutBodyEdwin( iReadOnlyQuoteField, iCmailPaneRect, 
-					iHeader->LayoutLineCount() + iMessageField->LineCount(),
-					iReadOnlyQuoteField->LineCount(), dummySeparatorPos );
+            TInt dummySeparatorPos;
+            NcsUtility::LayoutBodyEdwin( iReadOnlyQuoteField, iCmailPaneRect, 
+                    iHeader->LayoutLineCount() + iMessageField->LineCount(),
+                    iReadOnlyQuoteField->LineCount(), dummySeparatorPos );
             iReadOnlyQuoteField->SetAlignment( EAknEditorAlignBidi );
-            
-			RMemReadStream inputStream;
+
+            RMemReadStream inputStream;
             inputStream.Open( iReadOnlyQuote->Ptr(), iReadOnlyQuote->Size() );
             TRAP_IGNORE( iReadOnlyQuoteField->RichText()->ImportTextL( 0, inputStream,
                     CPlainText::EOrganiseByParagraph ) );
@@ -1140,7 +1169,7 @@
 
             // Update screen position and scroll bar when text changed
             // or cursor moved
-            UpdateScreenPositionL();
+            UpdateScreenPosition();
             UpdateScrollBar();
             DrawDeferred();
             }
@@ -1156,9 +1185,6 @@
     {
     FUNC_LOG;
     TBool ret = ETrue;
-    
-    const TRect rect( Rect() );
-    TRect cmailPaneRect( NcsUtility::ListCmailPaneRect( rect ) );
 
     if ( aDesirableEdwinSize.iHeight < iPrevDesiredHeigth )
         {
@@ -1176,7 +1202,7 @@
                 {
                 aEdwin->SetSize( aDesirableEdwinSize );
                 }
-            }        
+            }
         }
     else
         {
@@ -1185,15 +1211,21 @@
             aEdwin->SetSize( aDesirableEdwinSize );
             }
         }
+
     if ( aEdwin == iMessageField )
         {
         // move the quote field below the body field
         TPoint quotePos = iMessageField->Position();
         quotePos.iY += iMessageField->Size().iHeight;
         iReadOnlyQuoteField->SetPosition( quotePos );
-		UpdateScreenPositionL(); 
+        UpdateScreenPosition(); 
         }
 
+    // Update scroll span and position.
+    TInt scrollSpan = Max( ContentTotalHeight(), VisibleAreaHeight() + 1 );
+    iScrollBarModel.SetScrollSpan( scrollSpan );
+    UpdateScrollBar();
+
     iPrevDesiredHeigth = aDesirableEdwinSize.iHeight;
 
     return ret;
@@ -1223,12 +1255,22 @@
     FUNC_LOG;
 
     TRect headerRect = iHeader->Rect();
-    TInt visiblePosition = -headerRect.iTl.iY;
+    TInt visiblePosition = iHeaderPos.iY - headerRect.iTl.iY;
 
     iScrollBarModel.SetFocusPosition( visiblePosition );
 
     iScrollBar->SetModel( &iScrollBarModel );
-    iScrollBar->MakeVisible( IsVisible() );
+    iScrollBar->MakeVisible( !iHeader->IsPopupActive() );
+    }
+
+// -----------------------------------------------------------------------------
+// CNcsComposeViewContainer::UpdateScrollBarVisibility()
+// -----------------------------------------------------------------------------
+//
+void CNcsComposeViewContainer::UpdateScrollBarVisibility( TBool aVisible )
+    {
+    FUNC_LOG;
+    iScrollBar->MakeVisible( aVisible );
     }
 
 // -----------------------------------------------------------------------------
@@ -1245,7 +1287,7 @@
         iMessageField->SetCursorPosL( 0, EFalse );
         iMessageField->SetFocus( ETrue, ENoDrawNow );
         iFocused = iMessageField;
-        UpdateScreenPositionL();
+        UpdateScreenPosition();
         DrawDeferred();
         }
     }
@@ -1760,9 +1802,7 @@
 void CNcsComposeViewContainer::HideAttachmentLabel()
     {
     FUNC_LOG;
-
-	iHeader->HideAttachmentLabel();
-
+    iHeader->HideAttachmentLabel();
     }
 
 // -----------------------------------------------------------------------------
@@ -1966,21 +2006,28 @@
 TInt CNcsComposeViewContainer::ContentTotalHeight()
     {
     FUNC_LOG;	
-	TInt totalHeight( iHeader->Size().iHeight + 
-	                  iSeparatorHeight * 2 + 
-					  iMessageField->Size().iHeight );
+    TInt totalHeight( iHeader->Size().iHeight + 
+        iSeparatorHeight + iMessageField->Size().iHeight );
+
+    if ( iReadOnlyQuoteField->IsVisible() )
+        {
+        totalHeight += iReadOnlyQuoteField->Size().iHeight;
+        }
 
-	if( iReadOnlyQuoteField->IsVisible() )
-		{
-		totalHeight += iReadOnlyQuoteField->Size().iHeight;
-		}	
-	
-	return totalHeight;
+    return totalHeight;
+    }
+
+// -----------------------------------------------------------------------------
+// Returns the height of visible composer area.
+// -----------------------------------------------------------------------------
+//
+TInt CNcsComposeViewContainer::VisibleAreaHeight()
+    {
+    return iVisibleAreaHeight;
     }
 
 // -----------------------------------------------------------------------------
 // CNcsComposeViewContainer::CommitL()
-//
 // -----------------------------------------------------------------------------
 //
 void CNcsComposeViewContainer::CommitL( TFieldToCommit aFieldToCommit )
@@ -2029,7 +2076,7 @@
     FUNC_LOG;
     if ( iPhysics )
         {
-        const TSize viewSize( Rect().Size() );
+        const TSize viewSize( iCmailPaneRect.Size() );
         // We must ensure that world size is at least the size of the view
         const TSize worldSize( viewSize.iWidth, 
                 Max( ContentTotalHeight(), viewSize.iHeight ) );
@@ -2044,22 +2091,23 @@
 void CNcsComposeViewContainer::Scroll( TInt aTargetPos, TBool aDrawNow )
     {
     FUNC_LOG;
-	TPoint headerPos( iHeader->Position() );
-	TInt moveY = -headerPos.iY - aTargetPos;
-	
+    TPoint headerPos = iHeader->Position();
+    const TInt currentPos = iHeaderPos.iY - headerPos.iY;
+    TInt moveY = currentPos - aTargetPos;
+
     if ( aDrawNow )
-    	{
-		moveY = iTotalMoveY + moveY;
-		iTotalMoveY = 0;
-		if ( moveY )
-			{
-			headerPos.iY += moveY;
-			iHeader->SetPosition( headerPos );
+        {
+        moveY = iTotalMoveY + moveY;
+        iTotalMoveY = 0;
+        if ( moveY )
+            {
+            headerPos.iY += moveY;
+            iHeader->SetPosition( headerPos );
 
-			// set header invisible if it is not in visible area
-			// this is done to prevent drawing of header when it is not necessary
+            // set header invisible if it is not in visible area
+            // this is done to prevent drawing of header when it is not necessary
             if ( headerPos.iY + iHeaderHeight <= KHeaderVisibilityThreshold && iHeader->IsVisible() )
-                {            
+                {
                 iHeader->MakeVisible( EFalse );
                 }
             // set header visible if it is in visible area
@@ -2067,28 +2115,35 @@
                 {
                 iHeader->MakeVisible( ETrue );
                 }
-    
-			TPoint msgPos( iMessageField->Position() );
-			msgPos.iY += moveY;
-			iMessageField->SetPosition( msgPos );
-	
-			if( iReadOnlyQuoteField->IsVisible() )
-				{
-				TPoint readOnlyPos( iReadOnlyQuoteField->Position() );
-				readOnlyPos.iY += moveY;
-				iReadOnlyQuoteField->SetPosition( readOnlyPos );
-				}
-	
-			iSeparatorLineYPos += moveY;
+
+            TPoint msgPos( iMessageField->Position() );
+            msgPos.iY += moveY;
+            iMessageField->SetPosition( msgPos );
+
+            TPoint quotePos( iReadOnlyQuoteField->Position() );
+            quotePos.iY += moveY;
+            iReadOnlyQuoteField->SetPosition( quotePos );
 
-			UpdateScrollBar();
-			DrawDeferred();
-			}
-    	}
+            const TInt bottom = Rect().iBr.iY;
+            if ( iMessageField->IsFocused() )
+                {
+                iMessageField->SetCursorVisible( msgPos.iY <= bottom );
+                }
+            else if ( iReadOnlyQuoteField->IsFocused() )
+                {
+                iReadOnlyQuoteField->SetCursorVisible( quotePos.iY <= bottom );
+                }
+
+            iSeparatorLineYPos += moveY;
+
+            UpdateScrollBar();
+            DrawDeferred();
+            }
+        }
     else
-    	{
-		iTotalMoveY += moveY;
-    	}    	
+        {
+        iTotalMoveY += moveY;
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -2133,10 +2188,10 @@
 TPoint CNcsComposeViewContainer::ViewPosition() const
     {
     FUNC_LOG;
-    return TPoint(0, -iHeader->Position().iY  + iVisibleAreaHeight / 2 );
+    TInt y = iHeaderPos.iY - iHeader->Position().iY + iVisibleAreaHeight / 2;
+    return TPoint( 0, y );
     }
 
-
 // -----------------------------------------------------------------------------
 // CNcsComposeViewContainer::IsRemoteSearchInprogress
 // -----------------------------------------------------------------------------
--- a/emailuis/emailui/src/ncseditor.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/ncseditor.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -129,11 +129,11 @@
 // CNcsEditor::GetLineRectL() const
 // -----------------------------------------------------------------------------
 //
-void CNcsEditor::GetLineRectL( TRect& aLineRect ) const
+void CNcsEditor::GetLineRect( TRect& aLineRect ) const
     {
     FUNC_LOG;
     TPoint position;
-    iLayout->DocPosToXyPosL( CursorPos(), position );
+    TRAP_IGNORE( iLayout->DocPosToXyPosL( CursorPos(), position ) );
     iLayout->GetLineRect( position.iY, aLineRect );
     }
 
@@ -670,7 +670,10 @@
 void CNcsEditor::SetPhysicsEmulationOngoing( TBool aPhysOngoing )
     {
     iPhysOngoing = aPhysOngoing;
-    this->SetCursorVisible( !aPhysOngoing );
+    if ( IsFocused() )
+        {
+        SetCursorVisible( !aPhysOngoing );
+        }
     }
 
 TBool CNcsEditor::IsPhysicsEmulationOngoing() const
--- a/emailuis/emailui/src/ncsheadercontainer.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/ncsheadercontainer.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -23,9 +23,11 @@
 #include <aknnotewrappers.h> //CAknInformationNote
 #include <FreestyleEmailUi.rsg>
 #include <aknphysics.h>
+#include <AknPriv.hrh>
 
 #include "cfsmailbox.h"
 #include <FreestyleEmailUi.rsg>
+#include <layoutmetadata.cdl.h>
 
 #include "FSEmailBuildFlags.h"
 #include "ncsheadercontainer.h"
@@ -81,7 +83,8 @@
 	iFieldSizeObserver( static_cast< CNcsComposeViewContainer& >( aParent ) ),
 	iMailBox( aMailBox ),
 	iLongTapEventConsumed( EFalse ),
-    iPhysics( aPhysics )
+    iPhysics( aPhysics ),
+    iSplitScreenVKBEnabled( EFalse )
 	{
     FUNC_LOG;
 	}
@@ -159,16 +162,15 @@
         }
 
     // initially attachments field is hidden
-	iAttachmentField->MakeVisible( EFalse );
-	controls.Remove( iAttachmentField );
+    iAttachmentField->MakeVisible( EFalse );
+    controls.Remove( iAttachmentField );
 
-	// test whether mailbox supports remote lookup
-	TBool remoteLookupSupported = 
+    // test whether mailbox supports remote lookup
+    TBool remoteLookupSupported = 
         TFsEmailUiUtility::IsRemoteLookupSupported( iMailBox );
-	
-	iAacListBox = CNcsPopupListBox::NewL( 
-	        this, iMailBox, *this, remoteLookupSupported );
-	iAacListBox->MakeVisible( EFalse );
+
+    iAacListBox = CNcsPopupListBox::NewL( 
+        this, iMailBox, *this, remoteLookupSupported );
 
     iRALInProgress = EFalse;
 
@@ -194,61 +196,86 @@
 	}
 
 // ---------------------------------------------------------------------------
+// From MNcsPopupListBoxObserver.
+// ---------------------------------------------------------------------------
+//
+TBool CNcsHeaderContainer::PopupVisibilityChangingL( TBool aVisible )
+    {
+    CNcsComposeViewContainer& parent =
+        static_cast<CNcsComposeViewContainer&>( iParent );
+
+    if ( aVisible )
+        {
+        DoScrollFocusToTop();
+        iAacListBox->SetPopupMaxRect( CalculatePopupRect() );
+        }
+    else
+        {
+        // Scroll editor top, if it can be fully displayed.
+        if ( parent.ContentTotalHeight() < parent.VisibleAreaHeight() )
+            {
+            parent.Scroll( 0, ETrue );
+            }
+        }
+
+    parent.UpdateScrollBarVisibility( !aVisible );
+    ShowPopupMenuBarL( aVisible );
+    return ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// From MNcsPopupListBoxObserver.
+// ---------------------------------------------------------------------------
+//
+void CNcsHeaderContainer::PopupItemSelectedL()
+    {
+    DoPopupSelectL();
+    }
+
+// ---------------------------------------------------------------------------
 // CNcsHeaderContainer::FocusChanged
 // ---------------------------------------------------------------------------
 //
 void CNcsHeaderContainer::FocusChanged( TDrawNow aDrawNow )
-	{
+    {
     FUNC_LOG;
-    
+
     CCoeControl* focused = iFocused;
-    
+
     if ( !focused )
         {
         focused = FindFocused();
         iFocused = focused;
         }
-    
+
     if ( !IsFocused() )
         {
         if ( focused )
             {
             // We're loosing focus (probably going to message body)
             // Commit changes and make sure no controls are focused.
-            TRAP_IGNORE( CommitFieldL( focused ) );
+            if ( iParent.IsFocused() )
+                {
+                TRAP_IGNORE( CommitFieldL( focused ) );
+                }
             focused->SetFocus( EFalse, aDrawNow );
-            iFocused = NULL;
             }
 
         // Remove MSK label when header loses focus
         TRAP_IGNORE( SetMskL() );
-		}
-	else if ( IsFocused() && !focused )
-		{
-		// We're gaining focus from the message body
-		// Set the focus to the last control in the control array
-		// (either attachment line or subject field)
-		CCoeControlArray::TCursor cur = Components().End();
-		cur.Prev();
-		cur.Control<CCoeControl>()->SetFocus( ETrue, aDrawNow );
-        iFocused = cur.Control<CCoeControl>();
-		}
-	}
-
-// ---------------------------------------------------------------------------
-// CNcsHeaderContainer::ShowCursor
-// ---------------------------------------------------------------------------
-//
-void CNcsHeaderContainer::ShowCursor( TBool aShow, TDrawNow aDrawNow )
-    {
-    CCoeControl* focused = FindFocused();
-    if ( focused )
+        }
+    else
         {
-        iFocused = focused;
-        }
-    if ( iFocused ) 
-        {
-        iFocused->SetFocus( aShow, aDrawNow );
+        if ( !focused )
+            {
+            // We're gaining focus from the message body
+            // Set the focus to the last control in the control array
+            // (either attachment line or subject field)
+            CCoeControlArray::TCursor cur = Components().End();
+            cur.Prev();
+            iFocused = cur.Control<CCoeControl>();
+            }
+        iFocused->SetFocus( ETrue, aDrawNow );
         }
     }
 
@@ -343,73 +370,91 @@
 void CNcsHeaderContainer::HandlePointerEventL( 
         const TPointerEvent& aPointerEvent )
     {
-	FUNC_LOG;
+    FUNC_LOG;
+    if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
+        {
+        CCoeControl* component = 0;
+        for ( TInt i=0; i < Components().Count(); ++i )
+            {
+            TRect rc = Components().At( i ).iControl->Rect();
+            if ( rc.Contains( aPointerEvent.iPosition ) )
+                {
+                component = Components().At( i ).iControl;
+                }
+            }
+
+        if ( component )
+            {
+            CCoeControl* pOldCtrl = FindFocused();
+            CCoeControl* pNewCtrl= component;
+
+            if ( pOldCtrl != pNewCtrl )
+                {
+                // Unfocus the control
+                if ( pOldCtrl )
+                    {
+                    pOldCtrl->SetFocus( EFalse, ENoDrawNow );
+                    }
+                pNewCtrl->SetFocus( ETrue, ENoDrawNow );
+                iFocused = pNewCtrl;
+                // Commit changes to previously focused field.
+                if ( pOldCtrl )
+                    {
+                    CommitFieldL( pOldCtrl );
+                    }
+
+                // If the attachments label has changed focus
+                if ( pOldCtrl == iAttachmentField || 
+                        pNewCtrl == iAttachmentField )
+                    {
+                    DrawAttachmentFocusNow();
+                    }
+
+                CNcsComposeViewContainer* container = 
+                        static_cast<CNcsComposeViewContainer*>( &iParent );
+                container->UpdateScrollBar();
+                }
+
+            DrawDeferred();
+            }
+        }
+
     if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
         {
-		CCoeControl* clicked = 0;
-		for ( TInt i=0; i < Components().Count(); ++i )
-			{
-			TRect rc = Components().At( i ).iControl->Rect();
-			if ( rc.Contains( aPointerEvent.iPosition ) )
-				{
-				clicked = Components().At( i ).iControl;
-				}
-			}
+        if ( iLongTapEventConsumed )
+            {
+            iLongTapEventConsumed = EFalse;
+            return;
+            }
 
-	    if ( clicked )
-	        {
-			CCoeControl* pOldCtrl = FindFocused();
-			CCoeControl* pNewCtrl= clicked;
-			
-			if ( pOldCtrl != pNewCtrl )
-				{
-				// Unfocus the control
-				if ( pOldCtrl )
-					{
-					pOldCtrl->SetFocus( EFalse, ENoDrawNow );
-					}
-				pNewCtrl->SetFocus( ETrue, ENoDrawNow );
-				iFocused = pNewCtrl;
-				// Commit changes to previously focused field.
-				if ( pOldCtrl )
-					{
-					CommitFieldL( pOldCtrl );
-					}
+        CCoeControl* component = 0;
+        for ( TInt i=0; i < Components().Count(); ++i )
+            {
+            TRect rc = Components().At( i ).iControl->Rect();
+            if ( rc.Contains( aPointerEvent.iPosition ) )
+                {
+                component = Components().At( i ).iControl;
+                }
+            }
 
-				// If the attachments label has changed focus
-				if ( pOldCtrl == iAttachmentField || 
-					 pNewCtrl == iAttachmentField )
-					{
-					DrawAttachmentFocusNow();
-					}
-				
-				CNcsComposeViewContainer* container = 
-					static_cast<CNcsComposeViewContainer*>( &iParent );
-				container->UpdateScrollBar();
-				}
-			
-			if( iLongTapEventConsumed )
-				{
-				iLongTapEventConsumed = EFalse;
-				return;
-				}        
+        if ( component && component == iFocused )
+            {
+            TBool physicsActionOngoing( EFalse );
+            if ( iPhysics && iPhysics->OngoingPhysicsAction() != CAknPhysics::EAknPhysicsActionNone )
+                {
+                physicsActionOngoing = ETrue;
+                }
 
-			TBool physicsActionOngoing( EFalse );
-			if ( iPhysics && iPhysics->OngoingPhysicsAction() != CAknPhysics::EAknPhysicsActionNone )
-			{
-                physicsActionOngoing = ETrue;
+            if ( component == iAttachmentField && !physicsActionOngoing )
+                {
+                CNcsComposeViewContainer& parent = 
+                        static_cast<CNcsComposeViewContainer&>( iParent );
+                parent.HandleAttachmentsOpenCommandL();
+                }
             }
-			
-			if( pNewCtrl == iAttachmentField && !physicsActionOngoing )
-				{
-				CNcsComposeViewContainer& parent = 
-					static_cast<CNcsComposeViewContainer&>( iParent );
-				parent.HandleAttachmentsOpenCommandL();
-				}          
-	        }
         }
 
-	CCoeControl::HandlePointerEventL( aPointerEvent );
+    CCoeControl::HandlePointerEventL( aPointerEvent );
     }
 
 // -----------------------------------------------------------------------------
@@ -466,27 +511,26 @@
     TKeyResponse ret( EKeyWasNotConsumed );
     
     TBool doScroll( EFalse );
-    
-    if( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
-    	{
+
+    if ( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
+        {
         if ( iAacListBox && iAacListBox->IsVisible() && 
              !iAacListBox->IsPopupEmpty() )
-        	{
-           	return iAacListBox->OfferKeyEventL( aKeyEvent, aType );
-        	}
+            {
+            return iAacListBox->OfferKeyEventL( aKeyEvent, aType );
+            }
         else
-	        {
-		    ret = FindFocused()->OfferKeyEventL( aKeyEvent, aType );
-		    
-    		doScroll = ( ret == EKeyWasConsumed ); 
-	        }
+            {
+            ret = FindFocused()->OfferKeyEventL( aKeyEvent, aType );
+            doScroll = ( ret == EKeyWasConsumed ); 
+            }
 
         if ( ret == EKeyWasNotConsumed ) 
-        	{
+            {
             ret = ChangeFocusL( aKeyEvent );
-        	DrawDeferred();
-        	}
-    	}
+            DrawDeferred();
+            }
+        }
     else
     	{
         if ( FindFocused() == iAttachmentField )
@@ -529,6 +573,7 @@
 		        {
 		        FindFocused()->OfferKeyEventL( aKeyEvent, aType );
 		        ret = EKeyWasConsumed;
+		        doScroll = ETrue;
 		        }
 		    }
     	}
@@ -539,7 +584,9 @@
     		{
     		ret = focused->OfferKeyEventL( aKeyEvent, aType );
     		
-    		if(aType==EEventKeyDown)
+    		if( aType == EEventKeyDown &&
+    		    aKeyEvent.iScanCode != EStdKeyUpArrow &&
+    		    aKeyEvent.iScanCode != EStdKeyDownArrow )
     		    {
     		    doScroll = ETrue; 
     		    }
@@ -563,29 +610,29 @@
 // ---------------------------------------------------------------------------
 //
 CCoeControl* CNcsHeaderContainer::FindFocused() const
-	{
+    {
     FUNC_LOG;
-	CCoeControlArray::TCursor cur = Components().Begin();
-	do 
-		{
-		if ( cur.Control<CCoeControl>()->IsFocused() )
-			{
-			return cur.Control<CCoeControl>();
-			}
-		} 
-	while ( cur.Next() );
-	return NULL;
-	}
+    CCoeControlArray::TCursor cur = Components().Begin();
+    do 
+        {
+        if ( cur.Control<CCoeControl>()->IsFocused() )
+            {
+            return cur.Control<CCoeControl>();
+            }
+        } 
+    while ( cur.Next() );
+    return NULL;
+    }
 
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::ChangeFocusL()
 // Handles key events
 // -----------------------------------------------------------------------------
 TKeyResponse CNcsHeaderContainer::ChangeFocusL( const TKeyEvent& aKeyEvent )
-	{
+    {
     FUNC_LOG;
-	ASSERT( aKeyEvent.iCode == EKeyDownArrow || 
-	        aKeyEvent.iCode == EKeyUpArrow );
+    ASSERT( aKeyEvent.iCode == EKeyDownArrow || 
+            aKeyEvent.iCode == EKeyUpArrow );
     TKeyResponse ret( EKeyWasNotConsumed );
 
     CCoeControl* pOldCtrl = FindFocused();
@@ -596,28 +643,24 @@
     //If this is the first control in the list, don't change focus
     CCoeControlArray::TCursor cur = Components().Find(pOldCtrl);
     if ( aKeyEvent.iCode == EKeyUpArrow && cur == Components().Begin() )
-    	{
-    	return ret;
-    	}
-    
+        {
+        return ret;
+        }
+
     // Unfocus the control
-	pOldCtrl->SetFocus( EFalse, ENoDrawNow );
-    
-	CCoeControl* pNewCtrl= NULL;
-    if ( aKeyEvent.iCode == EKeyDownArrow && cur.Next() ) 
-    	{
-	    pNewCtrl = cur.Control<CCoeControl>();
-		pNewCtrl->SetFocus( ETrue, ENoDrawNow );
+    pOldCtrl->SetFocus( EFalse, ENoDrawNow );
+
+    CCoeControl* pNewCtrl= NULL;
+    if ( ( aKeyEvent.iCode == EKeyDownArrow && cur.Next() ) ||
+         ( aKeyEvent.iCode == EKeyUpArrow && cur.Prev() ) )
+        {
+        pNewCtrl = cur.Control<CCoeControl>();
+        iFocused = pNewCtrl;
+        pNewCtrl->SetFocus( ETrue, ENoDrawNow );
         ret = EKeyWasConsumed;
-    	}
-    else if ( aKeyEvent.iCode == EKeyUpArrow && cur.Prev() )
-    	{
-	    pNewCtrl = cur.Control<CCoeControl>();
-		pNewCtrl->SetFocus( ETrue, ENoDrawNow );
-        ret = EKeyWasConsumed;
-    	}
+        }
 
-        CNcsComposeViewContainer* container = 
+    CNcsComposeViewContainer* container = 
             static_cast<CNcsComposeViewContainer*>( &iParent );
     if ( pOldCtrl == iToField )
         {
@@ -635,13 +678,13 @@
         {
         container->CommitL( ESubjectField );
         }
-    
-	// If the attachments label has changed focus
-	if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField )
-		{
-		DrawAttachmentFocusNow();
-		}
-	
+
+    // If the attachments label has changed focus
+    if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField )
+        {
+        DrawAttachmentFocusNow();
+        }
+
     // if focus was changed, update scroll bar
     if ( ret == EKeyWasConsumed )
         {
@@ -649,9 +692,9 @@
         DoScroll();
         }
 
-	// NOTE: If we're leaving the header (down was pushed on last control)
-	//       then we return EKeyWasNotConsumed to make sure the
-	//		 parent moves the focus to the control below this container
+    // NOTE: If we're leaving the header (down was pushed on last control)
+    //       then we return EKeyWasNotConsumed to make sure the
+    //		 parent moves the focus to the control below this container
     return ret;
 	}
 
@@ -713,9 +756,8 @@
 // set size
 // -----------------------------------------------------------------------------
 void CNcsHeaderContainer::SizeChanged()
-	{
+    {
     FUNC_LOG;
-
     const TRect rect( Rect() );
 
     TInt currentLine( 0 );
@@ -733,11 +775,11 @@
             currentLine += ToNcsControl( cur )->LayoutLineCount();
             }
         } while ( cur.Next() );
-        
-	if( iAacListBox->IsVisible() && !iAacListBox->IsPopupEmpty() )
-		{
-		iAacListBox->SetPopupMaxRect( CalculatePopupRect() );
-		}
+
+    if ( iAacListBox->IsVisible() && !iAacListBox->IsPopupEmpty() )
+        {
+        iAacListBox->SetPopupMaxRect( CalculatePopupRect() );
+        }
 	}
 
 // -----------------------------------------------------------------------------
@@ -799,22 +841,19 @@
 // ---------------------------------------------------------------------------
 //
 TInt CNcsHeaderContainer::GetToLineHeight() const
-	{
-	FUNC_LOG;
-	TInt lineHeight = 0;
-	
-	if(iToField)
-		{
-	    TRect lineRect;
-	    TRAPD(err, iToField->GetLineRectL(lineRect) );
-	   	if(err == KErrNone)
-	        {
-	        lineHeight = lineRect.iBr.iY - lineRect.iTl.iY;
-	        }
-		}
-	return lineHeight;
-	}
-      
+    {
+    FUNC_LOG;
+    TInt lineHeight = 0;
+
+    if ( iToField )
+        {
+        TRect lineRect;
+        iToField->GetLineRect( lineRect );
+        lineHeight = lineRect.Height();
+        }
+    return lineHeight;
+    }
+
 // ---------------------------------------------------------------------------
 // CNcsHeaderContainer::GetTotalHeight
 // ---------------------------------------------------------------------------
@@ -882,6 +921,7 @@
             pOldCtrl->SetFocus( EFalse, ENoDrawNow );
             }
 
+        iFocused = iAttachmentField;
         iAttachmentField->SetFocus( ETrue, ENoDrawNow );
         iFieldSizeObserver.UpdateFieldPosition( iAttachmentField );
         }
@@ -892,46 +932,46 @@
 // -----------------------------------------------------------------------------
 //
 void CNcsHeaderContainer::HideAttachmentLabel()
-	{
+    {
     FUNC_LOG;
-	// check if we are focused and in that case
-	// unfocus attachment filed and focus previous control
+    // check if we are focused and in that case
+    // unfocus attachment filed and focus previous control
     CCoeControl* pOldCtrl = FindFocused();
     CCoeControl* pNewCtrl = NULL;
-    
+
     if ( pOldCtrl == iAttachmentField )
         {
         CCoeControlArray::TCursor cur = Components().Find( pOldCtrl );
-	    pOldCtrl->SetFocus( EFalse, ENoDrawNow );
+        pOldCtrl->SetFocus( EFalse, ENoDrawNow );
 
-	    if ( cur.Prev() )
-	        {
-	        pNewCtrl = cur.Control<CCoeControl>();
-		    pNewCtrl->SetFocus( ETrue, ENoDrawNow );
-	        }
+        if ( cur.Prev() )
+            {
+            pNewCtrl = cur.Control<CCoeControl>();
+            iFocused = pNewCtrl;
+            pNewCtrl->SetFocus( ETrue, ENoDrawNow );
+            }
         }
     else
         {
         pNewCtrl = pOldCtrl; // no need to move focus
         }
 
-	if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField )
-		{
-		DrawAttachmentFocusNow();
-		}
+    if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField )
+        {
+        DrawAttachmentFocusNow();
+        }
 
-	iAttachmentField->MakeVisible( EFalse );
-	Components().Remove( iAttachmentField );
-    
-	TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
+    iAttachmentField->MakeVisible( EFalse );
+    Components().Remove( iAttachmentField );
+    TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
 
     // Scroll to currently focused field
-	if ( pNewCtrl )
-	    {
-	    iFieldSizeObserver.UpdateFieldPosition( pNewCtrl );
-	    }
-	
-	}
+    if ( pNewCtrl )
+        {
+        iFieldSizeObserver.UpdateFieldPosition( pNewCtrl );
+        }
+
+    }
 
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::SetBccFieldVisibleL()
@@ -941,100 +981,101 @@
         TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) 
     {
     FUNC_LOG;
-	if ( iBccField->IsVisible() == aVisible )
-		{
-		return;
-		}
+    if ( iBccField->IsVisible() == aVisible )
+        {
+        return;
+        }
 
-	if ( aVisible )
-		{
-		CCoeControlArray::TCursor cur = Components().Find( iSubjectField );
-		Components().InsertLC( cur, iBccField );
-		CleanupStack::Pop( iBccField );
+    if ( aVisible )
+        {
+        CCoeControlArray::TCursor cur = Components().Find( iSubjectField );
+        Components().InsertLC( cur, iBccField );
+        CleanupStack::Pop( iBccField );
 
-		if ( aFocus )
-			{
-			CCoeControl* focused = FindFocused();
+        if ( aFocus )
+            {
+            CCoeControl* focused = FindFocused();
 
-			if ( focused )
-				{
-				focused->SetFocus( EFalse );
-				}
-			iBccField->SetFocus( ETrue );
+            if ( focused )
+                {
+                focused->SetFocus( EFalse, aDrawNow );
+                }
+            iBccField->SetFocus( ETrue, aDrawNow );
             iFocused = iBccField;
-			iBccField->SelectAllTextL();
-			}
-		}
-	else
-		{
-		if ( iBccField->IsFocused() )
-			{
-			CCoeControlArray::TCursor cur = Components().Find( iBccField );
-			ASSERT( cur.IsValid() );
-			
-			iBccField->SetFocus( EFalse );
+            iBccField->SelectAllTextL();
+            }
+        }
+    else
+        {
+        if ( iBccField->IsFocused() )
+            {
+            CCoeControlArray::TCursor cur = Components().Find( iBccField );
+            ASSERT( cur.IsValid() );
 
-			cur.Prev(); // Get the control before this field
-			cur.Control<CCoeControl>()->SetFocus( ETrue );
-			}
-		Components().Remove( iBccField );
-        iFocused = iSubjectField;
-		}
+            iBccField->SetFocus( EFalse );
+
+            cur.Prev(); // Get the control before this field
+            CCoeControl* focused = cur.Control<CCoeControl>();
+            focused->SetFocus( ETrue );
+            iFocused = focused;
+            }
+        Components().Remove( iBccField );
+        }
 
     TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
 
-	if ( aDrawNow == EDrawNow )
-		{
-	    DrawDeferred();
-		}
-	}
+    if ( aDrawNow == EDrawNow )
+        {
+        DrawDeferred();
+        }
+    }
 
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::SetCcFieldVisibleL()
 // -----------------------------------------------------------------------------
 void CNcsHeaderContainer::SetCcFieldVisibleL( 
         TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) 
-	{
+    {
     FUNC_LOG;
-	if ( iCcField->IsVisible() == aVisible )
-		{
-		return;
-		}
+    if ( iCcField->IsVisible() == aVisible )
+        {
+        return;
+        }
 
-	if ( aVisible )
-		{
-		Components().InsertAfterLC( Components().Id( *iToField ), iCcField );
-		CleanupStack::Pop( iCcField );
+    if ( aVisible )
+        {
+        Components().InsertAfterLC( Components().Id( *iToField ), iCcField );
+        CleanupStack::Pop( iCcField );
 
-		if ( aFocus )
-			{
-			CCoeControl* focused = FindFocused();
-			if ( focused )
-				{
-				focused->SetFocus( EFalse );
-				}
-			iCcField->SetFocus( ETrue );
+        if ( aFocus )
+            {
+            CCoeControl* focused = FindFocused();
+            if ( focused )
+                {
+                focused->SetFocus( EFalse, aDrawNow );
+                }
+            iCcField->SetFocus( ETrue, aDrawNow );
             iFocused = iCcField;
-			iCcField->SelectAllTextL();
-			}
-		}
-	else
-		{
-		if( iCcField->IsFocused() )
-			{
-			iCcField->SetFocus( EFalse );
-			iToField->SetFocus( ETrue );
-			}
-		Components().Remove( iCcField );
-        iFocused = iToField;
-		}
-    
-	TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
+            iCcField->SelectAllTextL();
+            }
+        }
+    else
+        {
+        if( iCcField->IsFocused() )
+            {
+            iCcField->SetFocus( EFalse );
+            iToField->SetFocus( ETrue );
+            iFocused = iToField;
+            }
+        Components().Remove( iCcField );
+        }
+
+    TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
 
     if ( aDrawNow == EDrawNow )
-		{
-	    DrawDeferred();
-		}
+        {
+        DrawDeferred();
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -1157,65 +1198,63 @@
 //
 void CNcsHeaderContainer::UpdatePopupContactListL( 
         const TDesC& aMatchString, TBool /*aListAll*/ )
-	{
+    {
     FUNC_LOG;
 
     // do update only for address fields
-	CCoeControl* focused = FindFocused();
-	
-	if ( !IsAddressInputField( focused ) )
-	    {
-	    return;
-	    }
-	    
-	if ( aMatchString.CompareC( KNullDesC ) == 0 || 
-	     aMatchString.Compare( KAddressDelimeterSemiColon ) == 0 )
-		{
-		ClosePopupContactListL();
-		return;
-		}
-	
-	if( !iAacListBox->IsVisible() )
-		{
+    CCoeControl* focused = FindFocused();
+
+    if ( !IsAddressInputField( focused ) )
+        {
+        return;
+        }
+
+    if ( aMatchString.CompareC( KNullDesC ) == 0 || 
+            aMatchString.Compare( KAddressDelimeterSemiColon ) == 0 )
+        {
+        ClosePopupContactListL();
+        return;
+        }
+
+    if( !iAacListBox->IsVisible() )
+        {
         iAacListBox->SetPopupMaxRect( CalculatePopupRect() );
         iAacListBox->InitAndSearchL( aMatchString, 1 );
         iAacListBox->ActivateL();
-		}
-	else
-		{
-		iAacListBox->SetSearchTextL( aMatchString );
-		}
-	}
+        }
+    else
+        {
+        iAacListBox->SetSearchTextL( aMatchString );
+        }
+    }
 
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::ClosePopupContactListL()
 // -----------------------------------------------------------------------------
 //
 void CNcsHeaderContainer::ClosePopupContactListL()
-	{
+    {
     FUNC_LOG;
-
     if ( iAacListBox->IsVisible() )
         {
-        iAacListBox->MakeVisible( EFalse );
-        ShowPopupMenuBarL( EFalse );
-        
-        // The focused address field should be redrawn after the popup is
-        // closed to fix the field border.
-        if ( iToField->IsFocused() )
-            {
-            iToField->DrawDeferred();
-            }
-        else if ( iCcField->IsFocused() )
-            {
-            iCcField->DrawDeferred();
-            }
-        else if ( iBccField->IsFocused() )
-            {
-            iBccField->DrawDeferred();
-            }
+        iAacListBox->ClosePopupL();
+        }
+
+    // The focused address field should be redrawn after the popup is
+    // closed to fix the field border.
+    if ( iToField->IsFocused() )
+        {
+        iToField->DrawDeferred();
         }
-	}
+    else if ( iCcField->IsFocused() )
+        {
+        iCcField->DrawDeferred();
+        }
+    else if ( iBccField->IsFocused() )
+        {
+        iBccField->DrawDeferred();
+        }
+    }
 
 // ---------------------------------------------------------------------------
 // CNcsHeaderContainer::ShowPopupMenuBarL
@@ -1303,9 +1342,10 @@
 	iSubjectField->SelectAllTextL();
 	}
 
-// -----------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
 // CNcsHeaderContainer::CalculatePopupRect
-// -----------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
 TRect CNcsHeaderContainer::CalculatePopupRect()
     {
     FUNC_LOG;
@@ -1321,10 +1361,22 @@
         TPoint editorPos = aifEditor->Editor()->PositionRelativeToScreen();
         TRect editorRect = aifEditor->Editor()->Rect();
 
-        popupRect.iTl = TPoint( editorPos.iX, 
-            editorPos.iY + aifEditor->CursorPosition() + 1 );
+        // When layouts are available we'll use them. Until that these are now
+        // hardcoded!
+        TInt tlXPos = 3;
+        TInt tlYPos = editorPos.iY + aifEditor->CursorPosition() + 1;
+        
+        if ( Layout_Meta_Data::IsLandscapeOrientation() &&
+             iSplitScreenVKBEnabled )
+            {
+            tlXPos = iAvkonAppUi->ApplicationRect().Width() / 2;
+            tlYPos = 3;
+            }
+        
+        popupRect.iTl = TPoint( tlXPos, tlYPos );
 
-        popupRect.iBr = TPoint( editorPos.iX + editorRect.Width(),
+        
+        popupRect.iBr = TPoint( iAvkonAppUi->ApplicationRect().iBr.iX  - 3,
             iParent.PositionRelativeToScreen().iY + iParent.Rect().Height() );
         }
 
@@ -1340,7 +1392,7 @@
     __ASSERT_DEBUG( iAacListBox, Panic( ENcsBasicUi ) );
     __ASSERT_DEBUG( &iMailBox, Panic( ENcsBasicUi ) );
 
-	if( iAacListBox->IsRemoteLookupItemSelected() )
+	if ( iAacListBox->IsRemoteLookupItemSelected() )
 		{
 		CCoeControl* focused = FindFocused();
 		
@@ -1870,14 +1922,13 @@
     CCoeControlArray::TCursor cur = Components().Begin();
     do
         {
-        totalLineCount += ToNcsControl( cur )->LayoutLineCount();                       
+        totalLineCount += ToNcsControl( cur )->LayoutLineCount();
         } 
     while ( cur.Next() );
     
     return totalLineCount;
     }
 
-
 // ---------------------------------------------------------------------------
 // CNcsHeaderContainer::IsAddressInputField
 // ---------------------------------------------------------------------------
@@ -1981,11 +2032,11 @@
     }
 
 void CNcsHeaderContainer::FixSemicolonInAddressFieldsL()
-	{
-		iToField->FixSemicolonAtTheEndL();
-		iCcField->FixSemicolonAtTheEndL();
-		iBccField->FixSemicolonAtTheEndL();
-	}
+    {
+    iToField->FixSemicolonAtTheEndL();
+    iCcField->FixSemicolonAtTheEndL();
+    iBccField->FixSemicolonAtTheEndL();
+    }
 
 TBool CNcsHeaderContainer::IsRemoteSearchInprogress() const
     {
@@ -2022,30 +2073,58 @@
         }
     }
 
-// -----------------------------------------------------------------------------
-// CNcsHeaderContainer::DoScroll
-// -----------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+// Scrolls editor to make cursor visible, if it is outside the visible area
+// ---------------------------------------------------------------------------
 // 
 void CNcsHeaderContainer::DoScroll()
     {
     // scroll the screen if the cursor goes beyond the screen
-    CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
-    
-    TInt screenPos( -Position().iY );
-    TInt cursorPos( CursorPosition() );
-    TInt lineHeight( Rect().Height() / LineCount() );
-    TInt screenHeight( parent.Rect().Height() );
+    CNcsComposeViewContainer& parent = 
+        static_cast<CNcsComposeViewContainer&>( iParent );
 
-    if ( cursorPos - lineHeight < screenPos )
+    // Scrolling based on cursor line number can only be done when
+    // header composer and one of its fields is focused.
+    if ( IsFocused() )
         {
-        screenPos = cursorPos - lineHeight;             
+        const TRect rect = Rect();
+        const TInt screenPos =  iOrigin.iY - rect.iTl.iY;
+        const TInt screenHeight = parent.VisibleAreaHeight();
+
+        const TInt lineNumber = CursorLineNumber();
+        const TInt lineHeight = rect.Height() / LineCount();
+        const TInt linePos = lineNumber * lineHeight;
+
+        TInt targetPos = screenPos;
+        if ( linePos - lineHeight < screenPos )
+            {
+            targetPos = linePos - lineHeight;
+            }
+        else if ( linePos + lineHeight > screenPos + screenHeight )
+            {
+            targetPos = linePos + lineHeight - screenHeight;
+            }
+
+        parent.Scroll( targetPos );
         }
-    else if( cursorPos + lineHeight > screenPos + screenHeight )
-        {
-        screenPos = cursorPos + lineHeight - screenHeight;
-        }
+    }
 
-    parent.Scroll( screenPos );
+// ---------------------------------------------------------------------------
+// Scrolls focused editor line to the top of visible area.
+// ---------------------------------------------------------------------------
+//
+void CNcsHeaderContainer::DoScrollFocusToTop()
+    {
+    CNcsComposeViewContainer& parent =
+        static_cast<CNcsComposeViewContainer&>( iParent );
+
+    // Calculate the position of the focused editor line.
+    const TRect rect = Rect();
+    const TInt lineNumber = CursorLineNumber();
+    const TInt lineHeight = rect.Height() / LineCount();
+    const TInt targetPos = ( lineNumber - 1 ) * lineHeight;
+
+    parent.Scroll( targetPos );
     }
 
 // ---------------------------------------------------------------------------
@@ -2059,3 +2138,31 @@
     iBccField->SetPhysicsEmulationOngoing( aPhysOngoing );
     iSubjectField->SetPhysicsEmulationOngoing( aPhysOngoing );
     }
+
+// ---------------------------------------------------------------------------
+// CNcsHeaderContainer::HandleResourceChange
+// ---------------------------------------------------------------------------
+//
+void CNcsHeaderContainer::HandleResourceChange( TInt aType )
+    {
+    FUNC_LOG;
+    CCoeControl::HandleResourceChange( aType );
+    if ( aType == KAknSplitInputEnabled || aType == KAknSplitInputDisabled )
+        {
+        iSplitScreenVKBEnabled = ( aType == KAknSplitInputEnabled );
+        if ( iAacListBox->IsVisible() )
+            {
+            iAacListBox->SetPopupMaxRect( CalculatePopupRect() );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Set origin for header's top position.
+// ---------------------------------------------------------------------------
+//
+void CNcsHeaderContainer::SetOrigin( TPoint& aOrigin )
+    {
+    iOrigin = aOrigin;
+    }
+
--- a/emailuis/emailui/src/ncspopuplistbox.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/ncspopuplistbox.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -20,8 +20,8 @@
 #include "emailtrace.h"
 #include <eikclbd.h>
 #include <AknsFrameBackgroundControlContext.h>
-#include <FreestyleEmailUi.rsg>						// R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH
-#include <StringLoader.h>						// StringLoader
+#include <FreestyleEmailUi.rsg>
+#include <StringLoader.h>
 #include <CPbkContactEngine.h>
 #include <AknsDrawUtils.h>
 #include <AknsUtils.h>
@@ -29,10 +29,10 @@
 #include <aknlayoutscalable_avkon.cdl.h>
 
 #include "ncspopuplistbox.h"
-#include "ncsemailaddressobject.h"					// CNcsEmailAddressObject
+#include "ncsemailaddressobject.h"
 #include "ncsconstants.h"
-#include "ncsheadercontainer.h"						// CNcsHeaderContainer
-#include "FreestyleEmailUiContactHandler.h"		// CFSEmailUiClsListsHandler
+#include "ncsheadercontainer.h"
+#include "FreestyleEmailUiContactHandler.h"
 #include "ncsutility.h"
 #include "FreestyleEmailUiUtilities.h"
 #include "FreestyleEmailUiAppui.h"
@@ -49,12 +49,12 @@
 // -----------------------------------------------------------------------------
 CNcsPopupListBox* CNcsPopupListBox::NewL( const CCoeControl* aParent, 
                                           CFSMailBox& aMailBox, 
-                                          CNcsHeaderContainer& aHeaderContainer, 
+                                          MNcsPopupListBoxObserver& aObserver,
                                           TBool aRemoteLookupSupported  )
     {
     FUNC_LOG;
-    CNcsPopupListBox* self =  new (ELeave) CNcsPopupListBox( aHeaderContainer,
-        aRemoteLookupSupported, aMailBox );
+    CNcsPopupListBox* self =  new (ELeave) CNcsPopupListBox( aMailBox,
+        aObserver, aRemoteLookupSupported );
     CleanupStack::PushL( self );
     self->ConstructL( aParent );
     CleanupStack::Pop( self );
@@ -64,11 +64,10 @@
 // -----------------------------------------------------------------------------
 // CNcsPopupListBox::CNcsPopupListBox
 // -----------------------------------------------------------------------------
-CNcsPopupListBox::CNcsPopupListBox( CNcsHeaderContainer& aHeaderContainer, 
-                                    TBool aRemoteLookupSupported, 
-                                    CFSMailBox& aMailBox)
-    : iHeaderContainer( aHeaderContainer ),
-      iMailBox( aMailBox ),
+CNcsPopupListBox::CNcsPopupListBox( CFSMailBox& aMailBox,
+    MNcsPopupListBoxObserver& aObserver, TBool aRemoteLookupSupported )
+    : iMailBox( aMailBox ),
+      iObserver( aObserver ),
       iRemoteLookupSupported( aRemoteLookupSupported ),
       iCachingInProgress( EFalse ),
       iAppUi( static_cast<CFreestyleEmailUiAppUi*>( iEikonEnv->AppUi() ) )
@@ -87,11 +86,12 @@
     SetMopParent( const_cast<CCoeControl*>( aParent ) );
     User::LeaveIfError( SetParent( const_cast<CCoeControl*>( aParent ) ) );
 
-    CEikScrollBarFrame* frame = CreateScrollBarFrameL( EFalse, EFalse, ETrue );
+    CreateScrollBarFrameL( EFalse, EFalse, ETrue );
 
     CEikTextListBox::SetBorder( TGulBorder::ENone );
 
-    const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont );
+    const CFont* font = 
+            AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont );
     CEikTextListBox::SetItemHeightL( font->FontMaxHeight() + 12 );
 
     iBackgroundContext = CAknsFrameBackgroundControlContext::NewL(
@@ -105,6 +105,7 @@
         }
 
     SetListBoxObserver( this );
+    MakeVisible( EFalse );
     }
 
 // -----------------------------------------------------------------------------
@@ -121,6 +122,14 @@
     }
 
 // ---------------------------------------------------------------------------
+// Hides the popup window.
+// ---------------------------------------------------------------------------
+void CNcsPopupListBox::ClosePopupL()
+    {
+    UpdateVisibilityL( EFalse );
+    }
+
+// ---------------------------------------------------------------------------
 // CNcsPopupListBox::~CNcsPopupListBox
 // ---------------------------------------------------------------------------
 CNcsPopupListBox::~CNcsPopupListBox()
@@ -144,7 +153,7 @@
 // -----------------------------------------------------------------------------
 // CNcsPopupListBox::MopSupplyObject
 // -----------------------------------------------------------------------------
-TTypeUid::Ptr CNcsPopupListBox::MopSupplyObject(TTypeUid aId)
+TTypeUid::Ptr CNcsPopupListBox::MopSupplyObject( TTypeUid aId )
     {
     FUNC_LOG;
     if ( aId.iUid == MAknsControlContext::ETypeId )
@@ -173,15 +182,24 @@
     TRAP_IGNORE( HandleViewRectSizeChangeL() );
     }
 
+// -----------------------------------------------------------------------------
+// CNcsPopupListBox::HandleResourceChange
+// -----------------------------------------------------------------------------
+//
 void CNcsPopupListBox::HandleResourceChange( TInt aType )
     {
     FUNC_LOG;
+    CEikTextListBox::HandleResourceChange( aType );
     if ( aType == KAknsMessageSkinChange )
         {
         UpdateTextColors();
         }
     }
 
+// -----------------------------------------------------------------------------
+// CNcsPopupListBox::HandlePointerEventL
+// -----------------------------------------------------------------------------
+//
 void CNcsPopupListBox::HandlePointerEventL( const TPointerEvent& aPointerEvent )
     {
     CEikTextListBox::HandlePointerEventL( aPointerEvent );
@@ -190,7 +208,7 @@
 // -----------------------------------------------------------------------------
 // CNcsPopupListBox::OfferKeyEventL
 // -----------------------------------------------------------------------------
-//    
+//
 TKeyResponse CNcsPopupListBox::OfferKeyEventL( const TKeyEvent& aKeyEvent,
     TEventCode aType )
     {
@@ -199,27 +217,32 @@
     if( aKeyEvent.iCode == EKeyDownArrow )
         {
         MoveRemoteLookupItemL( ERemoteLookupItemDown );
-        iView->MoveCursorL( CListBoxView::ECursorNextItem, CListBoxView::ENoSelection );
+        iView->MoveCursorL( 
+                CListBoxView::ECursorNextItem, CListBoxView::ENoSelection );
 		ret = EKeyWasConsumed;
         } 
     else if( aKeyEvent.iCode == EKeyUpArrow )
         {
 		TBool stay = EFalse;
         // Move cursor separator line over
-		if ( CurrentItemIndex() - 1 > 0 && CurrentItemIndex() - 1 == iRemoteLookupItemPos )
+		if ( CurrentItemIndex() - 1 > 0 && 
+		     CurrentItemIndex() - 1 == iRemoteLookupItemPos )
 			{
 	        MoveRemoteLookupItemL( ERemoteLookupItemUp );
-	        iView->MoveCursorL( CListBoxView::ECursorPreviousItem, CListBoxView::ENoSelection );
+	        iView->MoveCursorL( CListBoxView::ECursorPreviousItem, 
+	                            CListBoxView::ENoSelection );
 			stay = ETrue;
 			}
 
         MoveRemoteLookupItemL( ERemoteLookupItemUp );
-        iView->MoveCursorL( CListBoxView::ECursorPreviousItem, CListBoxView::ENoSelection );
+        iView->MoveCursorL( CListBoxView::ECursorPreviousItem, 
+                            CListBoxView::ENoSelection );
 	    if( stay )
 			{
 	        MoveRemoteLookupItemL( ERemoteLookupItemDown );
 
-			iView->MoveCursorL( CListBoxView::ECursorNextItem, CListBoxView::ENoSelection );
+			iView->MoveCursorL( CListBoxView::ECursorNextItem, 
+			                    CListBoxView::ENoSelection );
 			}
 
 
@@ -230,9 +253,10 @@
         {
         ret = CEikListBox::OfferKeyEventL( aKeyEvent, aType );
         }
-	// call HandleItemAdditionL just in case. There might be changes on remote lookup item place.
-	// The call is here, because we don't want to have extra redraw events when the popuplist
-	// is not fully updated.
+	// call HandleItemAdditionL just in case. There might be changes on remote
+    // lookup item place.
+	// The call is here, because we don't want to have extra redraw events when
+    // the popuplist is not fully updated.
 	HandleItemAdditionL(); 
     return ret;
     }
@@ -247,7 +271,7 @@
     if ( aEventType == EEventItemClicked || 
          aEventType == EEventItemSingleClicked )
         {
-        iHeaderContainer.DoPopupSelectL();
+        iObserver.PopupItemSelectedL();
         }
     }
 
@@ -281,17 +305,24 @@
 	
 	if ( aCmd == ESearchContacts )
 		{
-		// KerrNotReady --> caching in progress, KErrNotFound --> caching not started yet
-		if ( (aError == KErrNotReady) || (aError == KErrNotFound) )
+		// KerrNotReady --> caching in progress,
+	    // KErrNotFound --> caching not started yet
+		if ( ( aError == KErrNotReady ) || ( aError == KErrNotFound ) )
 			{
-			if(!iAppUi->AppUiExitOngoing()) //<cmail>
-			    TFsEmailUiUtility::ShowInfoNoteL( R_FSE_EDITOR_INFO_BUILDING_CACHE );
+			if( !iAppUi->AppUiExitOngoing() )
+			    {
+			    TFsEmailUiUtility::ShowInfoNoteL( 
+			            R_FSE_EDITOR_INFO_BUILDING_CACHE );
+			    }
 			iCachingInProgress = ETrue;
 			}
 		if ( aError == KErrNone && iCachingInProgress )
 			{
-			if(!iAppUi->AppUiExitOngoing()) //<cmail>
-			    TFsEmailUiUtility::ShowInfoNoteL( R_FSE_EDITOR_INFO_CACHING_COMPLETED );
+			if ( !iAppUi->AppUiExitOngoing() )
+			    {
+			    TFsEmailUiUtility::ShowInfoNoteL( 
+			            R_FSE_EDITOR_INFO_CACHING_COMPLETED );
+			    }
 			iCachingInProgress = EFalse;
 			}
 		}
@@ -307,12 +338,17 @@
     delete iCurrentSearchText;
     iCurrentSearchText = NULL;
     iCurrentSearchText = aText.AllocL();
-    if ( !iCachingInProgress  )
+    if ( !iCachingInProgress )
         {
-        if ( iContactHandler  )
+        if ( iContactHandler )
             {
             iContactHandler->SearchMatchesL( aText, this, &iMailBox, aMode );
             }
+        else
+            {
+            // update list for languages which don't support PCS
+            UpdateListL();
+            }
         }
     }
 
@@ -331,15 +367,17 @@
         if ( iRemoteLookupSupported )
             {
             // calculate index of item
-            TInt index = (CurrentItemIndex() > iRemoteLookupItemPos ? CurrentItemIndex() - 1 : CurrentItemIndex());
+            TInt index = ( CurrentItemIndex() > iRemoteLookupItemPos ? 
+                CurrentItemIndex() - 1 : CurrentItemIndex() );
             clsItem = iMatchingItems[index];
             }
         else
             {
-            clsItem = iMatchingItems[CurrentItemIndex()]; // no iRemoteLookupItemPos
+            clsItem = iMatchingItems[CurrentItemIndex()];
             }
 
-        addressObject= CNcsEmailAddressObject::NewL( clsItem->DisplayName(), clsItem->EmailAddress() );
+        addressObject= CNcsEmailAddressObject::NewL( 
+                clsItem->DisplayName(), clsItem->EmailAddress() );
         CleanupStack::PushL( addressObject );
         if ( clsItem->MultipleEmails() )
             {
@@ -390,7 +428,8 @@
 // -----------------------------------------------------------------------------
 // CNcsPopupListBox::CurrentPopupClsItemsArray
 // -----------------------------------------------------------------------------
-const RPointerArray<CFSEmailUiClsItem>& CNcsPopupListBox::CurrentPopupClsItemsArray() const
+const RPointerArray<CFSEmailUiClsItem>& 
+CNcsPopupListBox::CurrentPopupClsItemsArray() const
     {
     return iMatchingItems;
     }
@@ -419,22 +458,32 @@
 void CNcsPopupListBox::SetListItemsFromArrayL()
 	{
     FUNC_LOG;
-	// reset the cursor to point to the first item
-    //iView->MoveCursorL( CListBoxView::ECursorFirstItem, CListBoxView::ENoSelection);
+
 	Reset();
 	
 	// Create totally new text array
 	CreateTextArrayAndSetToTheListboxL( ETrue );
 
+	TInt matchCount = iMatchingItems.Count();
+	// Remote lookup item's index is set as last item by default
+	// (in case of empty matching items list it is the only item)
+	TInt rmluIndex = matchCount;
+
 	// append texts to text array
-	for( TInt i=0; i < iMatchingItems.Count(); i++ )
-		{
-		iItemTextsArray->AppendL( iMatchingItems[i]->FullTextL() );
-		}
+    for( TInt i=0; i < matchCount; i++ )
+        {
+        iItemTextsArray->AppendL( iMatchingItems[i]->FullTextL() );
+        if ( iRemoteLookupSupported && 
+             rmluIndex == matchCount &&
+             iMatchingItems[i]->EmailAddress().Compare( KNullDesC ) == 0 )
+            {
+            rmluIndex = i;
+            }
+        }
 
 	// Update rmlu item
-	SetRemoteLookupItemFirstToTheListL();
-	
+	SetRemoteLookupItemToTheListL( rmluIndex );
+
 	SetPopupRect();
 	SetScrollBarVisibilityL();
 	HandleItemAdditionL();
@@ -453,13 +502,13 @@
 // -----------------------------------------------------------------------------
 // CNcsPopupListBox::RoundToItemHeight
 // -----------------------------------------------------------------------------
-TInt CNcsPopupListBox::RoundToItemHeight(const TInt aPopupHeight) const
+TInt CNcsPopupListBox::RoundToItemHeight( const TInt aPopupHeight ) const
     {
     TReal fullItems; // number of full visible items in window
-    TInt err = Math::Round(fullItems, (aPopupHeight / ItemHeight()), 0);
-    if (err == KErrNone)
+    TInt err = Math::Round( fullItems, ( aPopupHeight / ItemHeight() ), 0 );
+    if ( err == KErrNone )
         {
-        return (TInt)(fullItems * ItemHeight()); 
+        return (TInt)( fullItems * ItemHeight() ); 
         }
     return aPopupHeight; // in case of error
     }
@@ -470,79 +519,42 @@
 void CNcsPopupListBox::SetPopupRect()
     {
     FUNC_LOG;
-    // The popup width and horizontal position is adjusted so that it
-    // will be within the area specified in both layout data and the set
-    // maximum rect.
-    TAknLayoutRect editorPane;
-    editorPane.LayoutRect( iAppUi->ClientRect(),
-        TAknWindowComponentLayout::Compose(
-            TAknWindowComponentLayout::Compose(
-                AknLayoutScalable_Apps::list_cmail_pane(),
-                AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0 ) ),
-            AknLayoutScalable_Apps::list_single_cmail_header_editor_pane_bg( 4 ) ) );
-    TRect editorPaneRect = editorPane.Rect();
 
-    TRect newRect = iPopupMaxRect;
-    newRect.iTl.iX = Max( iPopupMaxRect.iTl.iX, editorPaneRect.iTl.iX );
-    newRect.iBr.iX = Min( iPopupMaxRect.iBr.iX, editorPaneRect.iBr.iX );
-
-    // Thhe popup height and vertical position is adjusted based on the
+    // The popup height and vertical position is adjusted based on the
     // available space below and above the cursor and the number of items
     // in the list.
-    const TRect rect = iPopupMaxRect;
+    TRect newRect = iPopupMaxRect;
     TAknLayoutRect subpane;
-    subpane.LayoutRect( rect, AknLayoutScalable_Avkon::bg_popup_sub_pane_g1() );
-    const TRect subpaneRect = subpane.Rect();
-
-    const TInt frameHeights = iPopupMaxRect.Height() - subpaneRect.Height();
+    subpane.LayoutRect( newRect, 
+            AknLayoutScalable_Avkon::bg_popup_sub_pane_g1() );
+    const TInt frameHeights = 
+            iPopupMaxRect.Height() - subpane.Rect().Height();
 
     // This is the total height in pixels needed to show all items
-    TInt minimumHeight = frameHeights + 
+    const TInt minimumHeight = frameHeights + 
         CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() );
 
-    CCoeControl* container = Parent()->Parent();
-    TInt containerTop = container->PositionRelativeToScreen().iY;
-    TInt containerHeight = container->Rect().Height();
-    TInt containerCenter = containerTop + containerHeight / 2;
-
     // Get height of one line in Address field
-    CNcsHeaderContainer* headerObj = static_cast<CNcsHeaderContainer* >(Parent());
-    TInt toLineHeight = headerObj->GetToLineHeight(); // height of one line height
+    TInt toLineHeight =
+            static_cast<CNcsHeaderContainer*>( Parent() )->GetToLineHeight();
     if ( toLineHeight == 0 )
         {
         toLineHeight = ItemHeight();
         }
 
     TInt newHeight = minimumHeight; // default window height
-
-    // latch listbox on the bottom of the editor field
-    if ( newRect.iTl.iY <= containerCenter ) 
-        {
-        TInt maxHeight = containerHeight - ( newRect.iTl.iY - containerTop ); 
-        newHeight = RoundToItemHeight( maxHeight - frameHeights ) + frameHeights;
-        if ( newHeight > minimumHeight )
-            {
-            newHeight = minimumHeight; // shrink window (if needed)
-            }
-        }
-    // latch listbox on the top of the editor field
-    else
+    CCoeControl* container = Parent()->Parent();
+    const TInt maxHeight = 
+            container->Rect().Height() - 
+            ( newRect.iTl.iY - container->PositionRelativeToScreen().iY );
+    newHeight = 
+            RoundToItemHeight( maxHeight - frameHeights ) + frameHeights;
+    if ( newHeight > minimumHeight )
         {
-        TInt yOffset = -minimumHeight - toLineHeight; // how much up
-        TInt newTlY = newRect.iTl.iY + yOffset;       // new Top Left Y coordinate
-        if ( newTlY >= containerTop )
-            {
-            newRect.Move( 0, yOffset );
-            }
-        else
-            {
-            // shrink height to visible area and move
-            TInt maxHeight = newRect.iTl.iY - toLineHeight - containerTop;
-            newHeight = RoundToItemHeight( maxHeight - frameHeights ) + frameHeights;
-            newRect.Move( 0, -newHeight - toLineHeight );
-            }
+        newHeight = minimumHeight; // shrink window (if needed)
         }
-    newRect.SetHeight( newHeight ); // set new height
+
+    newRect.SetHeight( newHeight );
     SetRect( newRect );
     }
 
@@ -553,10 +565,11 @@
 	{
     FUNC_LOG;
 	// This is the total height in pixels needed to show all items
-	TInt minimumHeight = CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() );
+	TInt minimumHeight =
+	        CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() );
 
 	// Show scroll bar if there is more items we can show at once.
-	if( iPopupMaxRect.Height() > minimumHeight ) 
+	if( iPopupMaxRect.Height() > minimumHeight )
 		{
 		ScrollBarFrame()->SetScrollBarVisibilityL(
 			CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); 
@@ -570,19 +583,20 @@
 
 
 // -----------------------------------------------------------------------------
-// CNcsPopupListBox::SetRemoteLookupItemFirstToTheListL
+// CNcsPopupListBox::SetRemoteLookupItemToTheListL
 // -----------------------------------------------------------------------------
-void CNcsPopupListBox::SetRemoteLookupItemFirstToTheListL()
+void CNcsPopupListBox::SetRemoteLookupItemToTheListL( TInt aIndex )
 	{
     FUNC_LOG;
 	if( iRemoteLookupSupported )
 		{
 		HBufC* rmluText = StringLoader::LoadLC( 
-		    R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, *iCurrentSearchText );
+		    R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, 
+		    *iCurrentSearchText );
 		
-		iItemTextsArray->InsertL( 0, *rmluText );
+		iItemTextsArray->InsertL( aIndex, *rmluText );
 		CleanupStack::PopAndDestroy( rmluText );
-		iRemoteLookupItemPos = 0;
+		iRemoteLookupItemPos = aIndex;
 		}
 	else
 		{
@@ -593,7 +607,8 @@
 // -----------------------------------------------------------------------------
 // CNcsPopupListBox::MoveRemoteLookupItemL
 // -----------------------------------------------------------------------------
-void CNcsPopupListBox::MoveRemoteLookupItemL( TRemoteLookupItemMoveDirection aDirection )
+void CNcsPopupListBox::MoveRemoteLookupItemL( 
+        TRemoteLookupItemMoveDirection aDirection )
 	{
     FUNC_LOG;
 	if( iRemoteLookupSupported )
@@ -618,7 +633,9 @@
 			{
 			iItemTextsArray->Delete( iRemoteLookupItemPos );
 
-			HBufC* rmluText = StringLoader::LoadLC( R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, *iCurrentSearchText );
+			HBufC* rmluText = StringLoader::LoadLC(
+			        R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH,
+			        *iCurrentSearchText );
 			
 			iItemTextsArray->InsertL( newRMLUItemIndex, *rmluText );
 			CleanupStack::PopAndDestroy( rmluText );
@@ -631,7 +648,8 @@
 // -----------------------------------------------------------------------------
 // CNcsPopupListBox::CreateTextArrayAndSetToTheListboxL
 // -----------------------------------------------------------------------------
-void CNcsPopupListBox::CreateTextArrayAndSetToTheListboxL( const TBool& aResetIfExists )
+void CNcsPopupListBox::CreateTextArrayAndSetToTheListboxL(
+        const TBool& aResetIfExists )
 	{
     FUNC_LOG;
 	if( !iItemTextsArray )
@@ -660,16 +678,16 @@
     FUNC_LOG;
     // Store a GC for later use
     iGc = &CCoeEnv::Static()->SystemGc();
-    SetGc(iGc);
+    SetGc( iGc );
     }
 
 // -----------------------------------------------------------------------------
 // CNcsListItemDrawer::DrawActualItem
 // -----------------------------------------------------------------------------
-void CNcsListItemDrawer::DrawActualItem(TInt aItemIndex,
+void CNcsListItemDrawer::DrawActualItem( TInt aItemIndex,
     const TRect& aActualItemRect, TBool aItemIsCurrent,
     TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/,
-    TBool /*aItemIsSelected*/) const
+    TBool /*aItemIsSelected*/ ) const
     {
     FUNC_LOG;
     iGc->DiscardFont();
@@ -680,7 +698,8 @@
     TInt rmluPosition = iListBox.RemoteLookupItemPos();
 
     // Sets all the attributes, like font, text color and background color.
-    const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont );
+    const CFont* font = AknLayoutUtils::FontFromId(
+            EAknLogicalFontPrimarySmallFont );
     iGc->UseFont( font );
     iGc->SetPenStyle( CGraphicsContext::ESolidPen );
     iGc->SetBrushStyle( CGraphicsContext::ENullBrush );
@@ -783,14 +802,16 @@
 		// For now, we support underlining the matching part only if the
 		//       text is written completely with left-to-right script
 		
-		// We know the text contains RTL script if the display string is not just
-		// truncated version of the original string.
+		// We know the text contains RTL script if the display string is not
+		// just truncated version of the original string.
 		TPtrC dispText = bidiText->DisplayText();
-		TInt compLength = dispText.Length() - 1; // -1 to omit the truncation character
+		// -1 to omit the truncation character
+		TInt compLength = dispText.Length() - 1;
 		TBool textContainsRtl = 
-            ( itemText.Left(compLength) != dispText.Left(compLength) );
+            ( itemText.Left( compLength ) != dispText.Left( compLength ) );
 		
-        const RArray<TPsMatchLocation>& underlines = clsItemArray[aItemIndex]->Highlights();
+        const RArray<TPsMatchLocation>& underlines = 
+                clsItemArray[aItemIndex]->Highlights();
         
 		if ( underlines.Count() > 0 && !textContainsRtl )
 			{
@@ -805,7 +826,8 @@
 					{
 					// draw letters to the start of the underlined part
 					currentTextLength = underlines[i].index - currentTextStart;
-					DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText,
+					DrawPartOfItem( textRect, *font, currentTextStart,
+                                    currentTextLength, itemText,
 									EFalse, topToBaseline );
 					}
 				else if ( currentTextStart == underlines[i].index )
@@ -813,14 +835,16 @@
 					// draw underlined letters
 					currentTextLength = underlines[i].length;
 					
-					DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText,
+					DrawPartOfItem( textRect, *font, currentTextStart,
+                                    currentTextLength, itemText,
 									ETrue, topToBaseline );
 					i++;
 					}
 				else 
 					{
-					// This is here, because PCS Engine might give you duplicate match entries,
-					// in this case we're not advancing text but we'll skip that match
+					// This is here, because PCS Engine might give you 
+				    // duplicate match entries, in this case we're not 
+                    // advancing text but we'll skip that match
 					currentTextLength = 0;
 					i++;
 					}
@@ -830,11 +854,14 @@
 				if ( i >= underlines.Count() )
 					{
 					partsLeft = EFalse;
-					// draw rest of the letters, if there are any after the last underlined part
+					// draw rest of the letters, if there are any after the
+					// last underlined part
 					if ( currentTextStart < itemText.Length() )
 						{
-						currentTextLength = itemText.Length() - currentTextStart;
-						DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText,
+						currentTextLength = 
+						        itemText.Length() - currentTextStart;
+						DrawPartOfItem( textRect, *font, currentTextStart,
+                                        currentTextLength, itemText,
 										EFalse, topToBaseline );
 						}
 					}
@@ -855,9 +882,10 @@
 // -----------------------------------------------------------------------------
 // CNcsListItemDrawer::DrawPartOfItem
 // -----------------------------------------------------------------------------
-void CNcsListItemDrawer::DrawPartOfItem( const TRect& aItemRect, const CFont& aFont,
-						 TInt aStartPos, TInt aLength, const TDesC& aDes,
-						 TBool aUnderlined, TInt aBaselineOffsetFromTop  ) const
+void CNcsListItemDrawer::DrawPartOfItem(
+        const TRect& aItemRect, const CFont& aFont,
+        TInt aStartPos, TInt aLength, const TDesC& aDes,
+        TBool aUnderlined, TInt aBaselineOffsetFromTop ) const
 	{
     FUNC_LOG;
 	if( aUnderlined )
@@ -876,24 +904,50 @@
 	}
 
 
+// ---------------------------------------------------------------------------
+// Updates popup list content.
+// ---------------------------------------------------------------------------
+//
 void CNcsPopupListBox::UpdateListL()
     {
     FUNC_LOG;
     SetListItemsFromArrayL();
 
     // Close the popup if it's empty and make sure it's visible if it's not empty.
-    if ( IsPopupEmpty() )
+    UpdateVisibilityL( !IsPopupEmpty() );
+    }
+
+// ---------------------------------------------------------------------------
+// Shows or hides popup if necessary.
+// ---------------------------------------------------------------------------
+//
+void CNcsPopupListBox::UpdateVisibilityL( TBool aVisible )
+    {
+    if ( IsVisible() != aVisible )
         {
-        iHeaderContainer.ClosePopupContactListL();
+        if ( iObserver.PopupVisibilityChangingL( aVisible ) )
+            {
+            MakeVisible( aVisible );
+            if ( aVisible )
+                {
+                UpdateScrollBarsL();
+                SetScrollBarVisibilityL();
+                // Popup is always on top (also on top of e.g. toolbar buttons)
+                DrawableWindow()->SetOrdinalPosition( 0 );
+                }
+            }
         }
-    else
+    else if ( IsVisible() )
         {
-        MakeVisible( ETrue );
         UpdateScrollBarsL();
-        iHeaderContainer.ShowPopupMenuBarL( ETrue );
+        SetScrollBarVisibilityL();
         }
     }
 
+// ---------------------------------------------------------------------------
+// Updates popup text colors.
+// ---------------------------------------------------------------------------
+//
 void CNcsPopupListBox::UpdateTextColors()
     {
     if ( iItemDrawer )
--- a/emailuis/emailui/src/ncssubjectfield.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/emailui/src/ncssubjectfield.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -21,6 +21,7 @@
 #include <AknIconUtils.h>
 #include <avkon.hrh>
 #include <eiklabel.h>
+#include <aknbutton.h>
 #include <eikimage.h>
 #include <eikenv.h>
 #include <AknsDrawUtils.h>
@@ -81,13 +82,37 @@
     // Create label
 	HBufC* aTextBuf = StringLoader::LoadLC( aLabelTextId );
     TPtrC captionText = aTextBuf ? aTextBuf->Des() : TPtrC();
-    iLabel = new ( ELeave ) CNcsLabel( *this, NULL );
-    iLabel->SetTextL( captionText );
 
-    // S60 Skin support
-	iLabel->SetBrushStyle(CWindowGc::ENullBrush);
-
-    iTextEditor = new ( ELeave ) CNcsEditor( iSizeObserver, ETrue, ENcsEditorSubject, captionText );
+    if( AknLayoutUtils::PenEnabled() )
+        {
+        // Create a frameless button that has no observer
+        // This is done like this to make Subject: field appear similar as
+        // other header fields (To:, Cc:), although it doesn't have other
+        // button-like features
+        TRect buttRect( 10, 10, 70, 100 );
+        iButton = CAknButton::NewL( NULL, NULL, NULL, NULL, 
+                                    captionText, TPtrC(), 
+                                    KAknButtonTextLeft | KAknButtonNoFrame ,
+                                    0 );
+        iButton->SetTextColorIds( 
+                KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG63 );
+        iButton->SetContainerWindowL( *iParentControl );
+        iButton->SetRect( buttRect );
+        iButton->EnableFeedback( EFalse );
+        iButton->MakeVisible( ETrue );
+        iButton->ActivateL();
+        }
+    else
+        {
+        iLabel = new ( ELeave ) CNcsLabel( *this, NULL );
+        iLabel->SetTextL( captionText );
+    
+        // S60 Skin support
+        iLabel->SetBrushStyle(CWindowGc::ENullBrush);
+        }
+    
+    iTextEditor = new ( ELeave ) CNcsEditor( 
+            iSizeObserver, ETrue, ENcsEditorSubject, captionText );
     CleanupStack::PopAndDestroy( aTextBuf );
     }
 
@@ -100,37 +125,41 @@
     FUNC_LOG;
     delete iTextEditor;
     delete iLabel;
-    // Platform layout change
-    /*if ( iFont )
-        {
-        ControlEnv()->ScreenDevice()->ReleaseFont( iFont );
-        iFont = NULL;
-        }*/
+    delete iButton;
     }
 
 // -----------------------------------------------------------------------------
 // CNcsSubjectField::SetContainerWindowL() const
 // -----------------------------------------------------------------------------
 //
-void CNcsSubjectField::SetContainerWindowL(const CCoeControl& aContainer)
+void CNcsSubjectField::SetContainerWindowL( const CCoeControl& aContainer )
 	{
     FUNC_LOG;
-	CCoeControl::SetContainerWindowL(aContainer);
+	CCoeControl::SetContainerWindowL( aContainer );
 
 	// Create the component array
     InitComponentArrayL();
 	CCoeControlArray& controls = Components();
-	controls.SetControlsOwnedExternally(ETrue);
-	controls.AppendLC(iLabel);
-	CleanupStack::Pop(iLabel);
-	controls.AppendLC(iTextEditor);
-    CleanupStack::Pop(iTextEditor);
+	controls.SetControlsOwnedExternally( ETrue );
+	if ( iButton )
+	    {
+        controls.AppendLC( iButton );
+        CleanupStack::Pop( iButton );
+	    }
+	else
+	    {
+        controls.AppendLC( iLabel );
+        CleanupStack::Pop( iLabel );
+	    }
+	controls.AppendLC( iTextEditor );
+    CleanupStack::Pop( iTextEditor );
 
     // Setup text editor
     iTextEditor->ConstructL( &aContainer, KMaxAddressFieldLines, 0 );
 	iTextEditor->SetBorder( TGulBorder::ENone );
     iTextEditor->SetAknEditorInputMode( EAknEditorTextInputMode );
-	iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
+	iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( 
+	        CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
     iTextEditor->SetEdwinSizeObserver( this );
     iTextEditor->SetupEditorL();
     // Setup label
@@ -157,7 +186,7 @@
 TInt CNcsSubjectField::GetMinLabelLength() const
 	{
     FUNC_LOG;
-    return iLabel->Font()->TextWidthInPixels( *iLabel->Text() );
+    return iLabel ? iLabel->Font()->TextWidthInPixels( *iLabel->Text() ) : 0;
 	}
 
 // -----------------------------------------------------------------------------
@@ -170,35 +199,49 @@
     FUNC_LOG;
 	
     const TRect rect( Rect() );
-    NcsUtility::LayoutCaptionLabel( iLabel, rect );
-    NcsUtility::LayoutDetailEdwinTouch( iTextEditor, rect, iEditorLineCount, EFalse );  
+    if ( iButton )
+        {
+        NcsUtility::LayoutCaptionButton( iButton, rect );
+        }
+    else
+        {
+        NcsUtility::LayoutCaptionLabel( iLabel, rect );
+        }
+
+    NcsUtility::LayoutDetailEdwinTouch( 
+            iTextEditor, rect, iEditorLineCount, EFalse );  
     
-    if (iTextEditor->ScrollBarFrame())
+    if ( iTextEditor->ScrollBarFrame() )
         {
         TRect rc = iTextEditor->Rect();
-        if (AknLayoutUtils::LayoutMirrored())
+        if ( AknLayoutUtils::LayoutMirrored() )
             {
-            rc.iTl.iX += iTextEditor->ScrollBarFrame()->ScrollBarBreadth(CEikScrollBar::EVertical);
+            rc.iTl.iX += iTextEditor->ScrollBarFrame()->ScrollBarBreadth( 
+                    CEikScrollBar::EVertical );
             }
         else
             {
-            rc.iBr.iX -= iTextEditor->ScrollBarFrame()->ScrollBarBreadth(CEikScrollBar::EVertical);
+            rc.iBr.iX -= iTextEditor->ScrollBarFrame()->ScrollBarBreadth( 
+                    CEikScrollBar::EVertical );
             }
-        iTextEditor->SetRect(rc);
+        iTextEditor->SetRect( rc );
         }
 
     // Setup text alignment according the mirrored/normal layout.
-    if ( AknLayoutUtils::LayoutMirrored() )
+    if ( iLabel )
         {
-        iLabel->SetAlignment( EHLeftVCenter );
-        iLabel->SetLabelAlignment( ELayoutAlignLeft );
+        if ( AknLayoutUtils::LayoutMirrored() )
+            {
+            iLabel->SetAlignment( EHLeftVCenter );
+            iLabel->SetLabelAlignment( ELayoutAlignLeft );
+            }
+        else
+            {
+            iLabel->SetAlignment( EHRightVCenter );
+            iLabel->SetLabelAlignment( ELayoutAlignRight );
+            }
         }
-    else
-        {
-        iLabel->SetAlignment( EHRightVCenter );
-        iLabel->SetLabelAlignment( ELayoutAlignRight );
-        }
-    
+
     // this needs to be bidi as in mirrored layout 
     // writing language left to right can be set 
     iTextEditor->SetAlignment( EAknEditorAlignBidi );
@@ -210,13 +253,12 @@
 
 // -----------------------------------------------------------------------------
 // CNcsSubjectField::PositionChanged()
-// set size
 // -----------------------------------------------------------------------------
 //
 void CNcsSubjectField::PositionChanged()
     {
     FUNC_LOG;
-    //SizeChanged();
+    // empty
     }
 
 // -----------------------------------------------------------------------------
@@ -224,7 +266,8 @@
 // Handles key events
 // -----------------------------------------------------------------------------
 //
-TKeyResponse CNcsSubjectField::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
+TKeyResponse CNcsSubjectField::OfferKeyEventL( 
+        const TKeyEvent& aKeyEvent, TEventCode aType )
     {
     FUNC_LOG;
 	TKeyResponse ret( EKeyWasNotConsumed );
@@ -240,9 +283,8 @@
 //
 void CNcsSubjectField::HandlePointerEventL( const TPointerEvent& aPointerEvent )
     {
-	FUNC_LOG;
-    iTextEditor->HandlePointerEventL( aPointerEvent );
-    iTextEditor->HandleTextChangedL();
+    FUNC_LOG;
+    CCoeControl::HandlePointerEventL( aPointerEvent );
     }
 
 // -----------------------------------------------------------------------------
@@ -250,51 +292,26 @@
 // -----------------------------------------------------------------------------
 //
 void CNcsSubjectField::FocusChanged( TDrawNow aDrawNow )
-	{
+    {
     FUNC_LOG;
-	if ( IsFocused() )
-		{
-		iTextEditor->SetFocus( ETrue );
-		//TRAP_IGNORE( iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse ) ); 
+    if ( IsFocused() )
+        {
+        iTextEditor->SetFocus( ETrue, aDrawNow );
+        if ( iParentControl )
+            {
+            TRAP_IGNORE( iParentControl->SetMskL() );
+            }
+        }
+    else
+        {
+        iTextEditor->SetFocus( EFalse, aDrawNow );
+        }
 
-		// make sure that control is visible on screen
-		if ( Rect().iTl.iY < 0 )
-			{
-			TPoint pt = TPoint( 0, 0 );
-			Reposition( pt, Rect().Width() );
-			iSizeObserver->UpdateFieldPosition( this );
-			}
-		else
-			{
-			TPoint pos = PositionRelativeToScreen();
-			pos.iY += Size().iHeight;
-			CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice();
-			TPixelsAndRotation pix;
-			screenDev->GetDefaultScreenSizeAndRotation( pix );
-			const TInt h = pix.iPixelSize.iHeight;
-			if ( pos.iY >= h - h / 3 )
-				{
-				TPoint pt = TPoint( 0, h / 3 );
-				Reposition( pt, Rect().Width() );
-				iSizeObserver->UpdateFieldPosition( this );
-				}
-			}
-
-		if ( iParentControl )
-			{
-			TRAP_IGNORE( iParentControl->SetMskL() );
-			}
-		}
-	else
-		{
-		iTextEditor->SetFocus( EFalse );
-		}
-
-	if ( aDrawNow )
-		{
-		DrawNow();
-		}
-	}
+    if ( aDrawNow )
+        {
+        DrawNow();
+        }
+    }
 
 // -----------------------------------------------------------------------------
 // CNcsSubjectField::MinimumHeight()
@@ -304,20 +321,6 @@
 TInt CNcsSubjectField::MinimumHeight()
     {
     FUNC_LOG;
-    // Platform layout changes
-    /*
-    TNcsMeasures m = NcsUtility::Measures();
-	TInt height = m.iAifHeight - m.iAifEditorHeight + iEditorMinimumHeight + m.iSubjectExtraHeightBottom;
-	TInt height2 = m.iAifHeight + m.iSubjectExtraHeightBottom;
-	// if followup icon and priority icon are both visible increase the subject field height
-	if ( iFollowUp && iPriority != EMsgPriorityNormal )
-	    {
-	    height2 += KIconHeightFollowUp;
-	    }
-    return Max( height, height2 );
-    */
-    //return NcsUtility::MinimumHeaderSize( Rect(), iEditorLineCount ).iHeight;
-    // Platform layout changes
     return 0;
     }
 
@@ -341,11 +344,12 @@
         RMemReadStream inputStream( aSubject.Ptr(), aSubject.Size() );
 	    CleanupClosePushL( inputStream );
 
-	  	iTextEditor->RichText()->ImportTextL( 0, inputStream, CPlainText::EOrganiseByParagraph );
+	  	iTextEditor->RichText()->ImportTextL( 
+	  	        0, inputStream, CPlainText::EOrganiseByParagraph );
 
 		// Activating the field will set the control to the end of the text
 	    iTextEditor->ActivateL();
-	    iTextEditor->SetCursorPosL(0,EFalse);
+	    iTextEditor->SetCursorPosL( 0, EFalse );
 
 	    CleanupStack::PopAndDestroy( &inputStream );
     	}
@@ -359,41 +363,10 @@
 	TEdwinSizeEvent /*aEventType*/, TSize aDesirableEdwinSize )
     {
     FUNC_LOG;
-    //  Platform layout chage
-    /*
     TInt ret( EFalse );
     TInt htLine = iTextEditor->GetLineHeightL();
     TInt numLinesDesired = aDesirableEdwinSize.iHeight / htLine;
-
-    if ( numLinesDesired < KMaxAddressFieldLines &&
-         iEditorMinimumHeight != aDesirableEdwinSize.iHeight )
-        {
-        iEditorMinimumHeight = aDesirableEdwinSize.iHeight;
-        iTextEditor->CreateScrollBarFrameL()->SetScjrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
-        if ( iSizeObserver )
-            {
-            ret = iSizeObserver->UpdateFieldSizeL();
-            }
-        }
-    else if ( iEditorMinimumHeight != htLine * KMaxAddressFieldLines )
-        {
-        //We may still need to resize the controll.
-        iEditorMinimumHeight = htLine * KMaxAddressFieldLines;
-        iTextEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn );
-        if ( iSizeObserver )
-            {
-            ret = iSizeObserver->UpdateFieldSizeL();
-            }
-        }
-    */
-
-    TInt ret( EFalse );
-    TInt htLine = iTextEditor->GetLineHeightL();
-    TInt numLinesDesired = aDesirableEdwinSize.iHeight / htLine;
-    // commented because of EGWG-83ECSR, no negative feedback after removing
-    //CEikScrollBarFrame& scrollBarFrame( *iTextEditor->CreateScrollBarFrameL() );
     iEditorLineCount = numLinesDesired;
-    //scrollBarFrame.SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff );
     if ( iSizeObserver )
         {
         ret = iSizeObserver->UpdateFieldSizeL();
@@ -478,7 +451,6 @@
 	return KNullDesC;
 	}
 
-// Platform layout change
 // ---------------------------------------------------------------------------
 // CNcsSubjectField::LayoutLineCount
 // ---------------------------------------------------------------------------
@@ -495,23 +467,17 @@
 void CNcsSubjectField::Reposition(TPoint& aPt, TInt /*aWidth*/)
 	{
     FUNC_LOG;
-    /*
-	const TSize size( aWidth, MinimumHeight() );
-    SetExtent( aPt, size );
-    aPt.iY += size.iHeight;
-    */
     SetPosition( aPt );
-    // Platform layout changes
 	}
 
 // -----------------------------------------------------------------------------
 // CNcsSubjectField::GetLineRectL
 // -----------------------------------------------------------------------------
-void CNcsSubjectField::GetLineRectL( TRect& aLineRect ) const
-	{
+void CNcsSubjectField::GetLineRect( TRect& aLineRect ) const
+    {
     FUNC_LOG;
-    return iTextEditor->GetLineRectL( aLineRect );
-	}
+    return iTextEditor->GetLineRect( aLineRect );
+    }
 
 // -----------------------------------------------------------------------------
 // CNcsSubjectField::SetMaxLabelLength
@@ -538,23 +504,19 @@
 void CNcsSubjectField::UpdateColors()
     {
 	FUNC_LOG;
-    // Platform layout change
-    TRgb textColor = KRgbBlack;
-    if ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor,
-        KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ) != KErrNone )
-        {
-        textColor = KRgbBlack;
+
+	if ( iLabel )
+	    {
+        TRgb textColor = KRgbBlack;
+        if ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor,
+            KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ) != KErrNone )
+            {
+            textColor = KRgbBlack;
+            }
+        TRAP_IGNORE( iLabel->OverrideColorL( EColorLabelText, textColor ) );
         }
-    TRAP_IGNORE( iLabel->OverrideColorL( EColorLabelText, textColor ) );
-    // Platform layout change
-
-    CFreestyleEmailUiAppUi* appUi =
-        static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
-    iBorderColor = appUi->LayoutHandler()->ComposerFieldBorderColor();
-    iBgColor = appUi->LayoutHandler()->ComposerFieldBackgroundColor();
     }
 
-// Platform layout changes
 // ---------------------------------------------------------------------------
 // CNcsSubjectField::UpdateFontSize()
 // ---------------------------------------------------------------------------
@@ -562,20 +524,18 @@
 void CNcsSubjectField::UpdateFontSize()
 	{
     FUNC_LOG;
-    /*if ( iFont )
+    CCoeControl* control = 
+            iButton ? ( CCoeControl* )iButton : ( CCoeControl* )iLabel;
+    iFont = NcsUtility::GetLayoutFont( 
+            control->Rect(), NcsUtility::ENcsHeaderCaptionFont );
+    if( control == iButton )
         {
-        ControlEnv()->ScreenDevice()->ReleaseFont( iFont );
-        iFont = NULL;
+        iButton->SetTextFont( iFont );
         }
-
-	TNcsMeasures m = NcsUtility::Measures();
-	if ( !iFont )
-	    {
-	    TRAP_IGNORE( iFont = NcsUtility::GetNearestFontL(EAknLogicalFontPrimarySmallFont,
-	    m.iLabelFontHeightPx) );
-	    }*/
-	iFont = NcsUtility::GetLayoutFont( iLabel->Rect(), NcsUtility::ENcsHeaderCaptionFont );
-	iLabel->SetFont( iFont );
+    else
+        {
+        iLabel->SetFont( iFont );
+        }
 	iTextEditor->UpdateFontSize();
 	UpdateColors();
 	}
@@ -593,18 +553,24 @@
         {
         UpdateFontSize();
         UpdateColors();
-        // Platform layout changes
-        iTextEditor->HandleResourceChange( aType ) ;//CreateScrollBarFrameL()->DrawScrollBarsNow();
-        // Platform layout changes
+        iTextEditor->HandleResourceChange( aType );
         }
     }
 
-void CNcsSubjectField::EnableKineticScrollingL(CAknPhysics*  aPhysics)
+// ---------------------------------------------------------------------------
+// CNcsSubjectField::EnableKineticScrollingL()
+// ---------------------------------------------------------------------------
+//
+void CNcsSubjectField::EnableKineticScrollingL( CAknPhysics*  aPhysics )
     {
-    iTextEditor->EnableKineticScrollingL(aPhysics);
+    iTextEditor->EnableKineticScrollingL( aPhysics );
     iTextEditor->TextLayout()->RestrictScrollToTopsOfLines( ETrue );
     }
 
+// ---------------------------------------------------------------------------
+// CNcsSubjectField::SetPhysicsEmulationOngoing()
+// ---------------------------------------------------------------------------
+//
 void CNcsSubjectField::SetPhysicsEmulationOngoing( TBool aPhysOngoing )
     {
     iTextEditor->SetPhysicsEmulationOngoing( aPhysOngoing );
--- a/emailuis/uicomponents/bwins/fs_generic_alfu.def	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/bwins/fs_generic_alfu.def	Wed Sep 15 11:52:37 2010 +0300
@@ -306,4 +306,5 @@
 	?VisibilityMode@CFsAlfScrollbarLayout@@QAE?AW4TFsScrollbarVisibility@@W4TFsScrollbar@@@Z @ 305 NONAME ; enum TFsScrollbarVisibility CFsAlfScrollbarLayout::VisibilityMode(enum TFsScrollbar)
 	?Visual@CFsControlBar@@QAEPAVCAlfVisual@@XZ @ 306 NONAME ; class CAlfVisual * CFsControlBar::Visual(void)
 	?Width@CFsControlBar@@QBEHXZ @ 307 NONAME ; int CFsControlBar::Width(void) const
+	?SetMarkingModeL@CFsTreeList@@QAEXH@Z @ 308 NONAME ; void CFsTreeList::SetMarkingModeL(int)
 
--- a/emailuis/uicomponents/eabi/fs_generic_alfU.def	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/eabi/fs_generic_alfU.def	Wed Sep 15 11:52:37 2010 +0300
@@ -416,4 +416,5 @@
 	_ZThn32_N14CFsTreeControl11OfferEventLERK9TAlfEvent @ 415 NONAME ; #<thunk>#
 	_ZThn4_N26CFsControlButtonVisualiser23TextureLoadingCompletedER11CAlfTextureii @ 416 NONAME ; #<thunk>#
 	_ZThn4_NK11CFsTreeList20TreeVisualizerEventLEN25MFsTreeVisualizerObserver22TFsTreeVisualizerEventEiRK6TPoint @ 417 NONAME ; #<thunk>#
+	_ZN11CFsTreeList15SetMarkingModeLEi @ 418 NONAME
 
--- a/emailuis/uicomponents/inc/fscontrolbuttonvisualiser.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fscontrolbuttonvisualiser.h	Wed Sep 15 11:52:37 2010 +0300
@@ -548,6 +548,11 @@
      * Show dropdown shadow for buttons  
      */
     TBool iShowShadow;
+
+    /**
+     * Help variable to omit unnecessary iDefaultBgBrush updates.
+     */
+    TSize iLastUpdatedButtonModelSize; 
     };
 
 
--- a/emailuis/uicomponents/inc/fsmultilineitemvisualizer.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fsmultilineitemvisualizer.h	Wed Sep 15 11:52:37 2010 +0300
@@ -169,7 +169,8 @@
     virtual void UpdateL( const MFsTreeItemData& aData,
                           TBool aFocused,
                           const TUint aLevel,
-                          CAlfTexture*& aMarkIcon,
+                          CAlfTexture*& aMarkOnIcon,
+                          CAlfTexture*& aMarkOffIcon,
                           CAlfTexture*& aMenuIcon,
                           const TUint aTimeout = 0,
                           TBool aUpdateData = ETrue);
--- a/emailuis/uicomponents/inc/fsseparatorvisualizer.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fsseparatorvisualizer.h	Wed Sep 15 11:52:37 2010 +0300
@@ -167,6 +167,8 @@
      */
     virtual void SetAlwaysExtended( TBool aAlwaysExtended );
     
+    virtual void SetMarkingMode( TBool aMarkingMode );
+    
     /**
      * From MFsTreeItemVisualizer.
      * This function returns wether an item is always in extended state.
@@ -194,7 +196,8 @@
     virtual void UpdateL( const MFsTreeItemData& aData,
                           TBool aFocused,
                           const TUint aLevel,
-                          CAlfTexture*& aMarkIcon,
+                          CAlfTexture*& aMarkOnIcon,
+                          CAlfTexture*& aMarkOffIcon,
                           CAlfTexture*& aMenuIcon,
                           const TUint aTimeout = 0,
                           TBool aUpdateData = ETrue);
--- a/emailuis/uicomponents/inc/fstreeitemvisualizer.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fstreeitemvisualizer.h	Wed Sep 15 11:52:37 2010 +0300
@@ -66,6 +66,7 @@
 const TUint32 KFsTreeListItemManagedLayout =    0x0800;
 const TUint32 KFsTreeListItemHasMenu =          0x1000;
 const TUint32 KFsTreeListItemTextBold =         0x2000;
+const TUint32 KFsTreeListMarkingMode =          0x4000;
 
 
 const TInt KFsDefaultIndentation = 20;
@@ -267,7 +268,6 @@
      */
     virtual void SetBackgroundTexture( const CAlfTexture& aTexture ) = 0;
 
-    // <cmail>
     /**
      * Sets item background brush. Ownership not transfered.
      * 
@@ -284,7 +284,6 @@
      * @return ETrue if background brush is set, EFalse otherwise.
      */
     virtual TBool GetBackgroundBrush( CAlfBrush*& aBrush ) = 0;
-    // </cmail>
     
     /**
      * Returns background texture if it's set.
@@ -393,7 +392,8 @@
     virtual void UpdateL( const MFsTreeItemData& aData,
                         TBool aFocused,
                         const TUint aLevel,
-                        CAlfTexture*& aMarkIcon,
+                        CAlfTexture*& aMarkOnIcon,
+                        CAlfTexture*& aMarkOffIcon,
                         CAlfTexture*& aMenuIcon,
                         const TUint aTimeout = 0,
                         TBool aUpdateData = ETrue) = 0;
@@ -449,6 +449,8 @@
      * @param ETrue if item should always be in extended state.
      */
     virtual void SetAlwaysExtended( TBool aAlwaysExtended ) = 0;
+
+    virtual void SetMarkingMode( TBool aMarkingMode ) = 0;
     
     /**
      * This function returns wether an item is always in extended state.
--- a/emailuis/uicomponents/inc/fstreeitemvisualizerbase.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fstreeitemvisualizerbase.h	Wed Sep 15 11:52:37 2010 +0300
@@ -20,12 +20,7 @@
 #define FSTREEITEMVISUALIZERBASE_H_
 
 #include <e32base.h>
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
-// <cmail> SF
 #include <alf/alfeventhandler.h>
-// </cmail>
 #include "fstreeitemvisualizer.h"
 #include "fslayoutmanager.h"
 
@@ -313,7 +308,6 @@
      */
     virtual void SetBackgroundTexture( const CAlfTexture& aTexture );
 
-    // <cmail>
     /**
      * From MFsTreeItemVisualizer.
      * Sets item background brush. Ownership not transfered.
@@ -331,7 +325,6 @@
      * @return ETrue if background brush is set, EFalse otherwise.
      */
     virtual TBool GetBackgroundBrush( CAlfBrush*& aBrush );
-    // </cmail>
 
     /**
      * From MFsTreeItemVisualizer.
@@ -367,6 +360,8 @@
      * @param ETrue if item should always be in extended state.
      */
     virtual void SetAlwaysExtended( TBool aAlwaysExtended );
+
+    virtual void SetMarkingMode( TBool aMarkingMode );
     
     /**
      * This function returns wether an item is always in extended state.
@@ -441,7 +436,8 @@
     virtual void UpdateL( const MFsTreeItemData& aData,
             TBool aFocused,
             const TUint aLevel,
-            CAlfTexture*& aMarkIcon,
+            CAlfTexture*& aMarkOnIcon,
+            CAlfTexture*& aMarkOffIcon,
             CAlfTexture*& aMenuIcon,
             const TUint aTimeout = 0,
             TBool aUpdateData = ETrue);
@@ -560,9 +556,7 @@
         EFsItemBackgroundNone,
         EFsItemBackgroundColor,
         EFsItemBackgroundTexture,
-    // <cmail> this feature is waiting for title divider bg graphics
         EFsItemBackgroundBrush
-    // </cmail>
         };
     
 protected:
--- a/emailuis/uicomponents/inc/fstreelist.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fstreelist.h	Wed Sep 15 11:52:37 2010 +0300
@@ -23,15 +23,9 @@
 /////SYSTEM INCLUDES
 
 //////TOOLKIT INCLUDES
-// <cmail> SF
 #include <alf/alfcontrol.h>
-// </cmail>
 
 //////PROJECT INCLUDES
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
-
 #include "fstreelistconstants.h"
 #include "fstreevisualizerbase.h"
 #include "fstreevisualizerobserver.h"
@@ -587,6 +581,14 @@
     */
     IMPORT_C CFsTreeList* ItemMenu( TFsTreeItemId aItemId );
 
+    /**
+     * Sets marking mode on\off
+     * 
+     * @param ETrue if marking mode is set on
+     */
+
+    IMPORT_C void SetMarkingModeL( const TBool aMarkingMode );
+
 public: // Visualization management
 
     /**
--- a/emailuis/uicomponents/inc/fstreenodevisualizerbase.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fstreenodevisualizerbase.h	Wed Sep 15 11:52:37 2010 +0300
@@ -22,13 +22,8 @@
 
 
 #include <e32base.h>
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
 #include <gdi.h>
-// <cmail> SF
 #include <alf/alfeventhandler.h>
-// </cmail>
 #include "fstreenodevisualizer.h"
 
 class CAlfLayout;
@@ -310,7 +305,6 @@
      */
     virtual void SetBackgroundTexture( const CAlfTexture& aTexture );
 
-    // <cmail>
     /**
      * From MFsTreeItemVisualizer.
      * Sets item background brush. Ownership not transfered.
@@ -328,7 +322,6 @@
      * @return ETrue if background brush is set, EFalse otherwise.
      */
     virtual TBool GetBackgroundBrush( CAlfBrush*& aBrush );
-    // </cmail>
 
     /**
      * From MFsTreeItemVisualizer.
@@ -364,6 +357,8 @@
      * @param ETrue if item should always be in extended state.
      */
     virtual void SetAlwaysExtended( TBool aAlwaysExtended );
+
+    virtual void SetMarkingMode( TBool aMarkingMode );
     
     /**
      * This function returns wether an item is always in extended state.
@@ -439,7 +434,8 @@
     virtual void UpdateL( const MFsTreeItemData& aData,
             TBool aFocused,
             const TUint aLevel,
-            CAlfTexture*& aMarkIcon,
+            CAlfTexture*& aMarkOnIcon,
+            CAlfTexture*& aMarkOffIcon,
             CAlfTexture*& aMenuIcon,
             const TUint aTimeout = 0,
             TBool aUpdateData = ETrue);
@@ -569,9 +565,7 @@
         EFsNodeBackgroundNone,
         EFsNodeBackgroundColor,
         EFsNodeBackgroundTexture,
-    // <cmail> this feature is waiting for title divider bg graphics
         EFsNodeBackgroundBrush       
-    // </cmail>
         };
     
 protected:
--- a/emailuis/uicomponents/inc/fstreeplainonelineitemvisualizer.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fstreeplainonelineitemvisualizer.h	Wed Sep 15 11:52:37 2010 +0300
@@ -20,12 +20,7 @@
 #define C_FSTREEPLAINONELINEITEMVISUALIZER_H
 
 #include <e32base.h>
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
-// <cmail> SF
 #include <alf/alfeventhandler.h>
-// </cmail>
 #include "fstreeitemvisualizerbase.h"
 
 class CAlfViewportLayout;
@@ -95,7 +90,8 @@
     virtual void UpdateL( const MFsTreeItemData& aData,
                           TBool aFocused,
                           const TUint aLevel,
-                          CAlfTexture*& aMarkIcon,
+                          CAlfTexture*& aMarkOnIcon,
+                          CAlfTexture*& aMarkOffIcon,
                           CAlfTexture*& aMenuIcon,
                           const TUint aTimeout = 0,
                           TBool aUpdateData = ETrue);
@@ -177,7 +173,7 @@
     /**
      * Visual for a mark icon.
      */
-    CAlfImageVisual* iIconMarked;
+    CAlfImageVisual* iIconMark;
     
     /**
      * Visual for a menu icon.
--- a/emailuis/uicomponents/inc/fstreeplainonelinenodevisualizer.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fstreeplainonelinenodevisualizer.h	Wed Sep 15 11:52:37 2010 +0300
@@ -20,10 +20,6 @@
 #define C_FSTREEPLAINONELINENODEVISUALIZER_H
 
 #include <e32base.h>
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
-
 #include "fstreenodevisualizerbase.h"
 
 class CAlfViewportLayout;
@@ -138,6 +134,8 @@
      */
     virtual void SetAlwaysExtended( TBool aAlwaysExtended );
     
+    virtual void SetMarkingMode( TBool aMarkingMode );
+    
     /**
      * From MFsTreeItemVisualizer.
      * This function returns wether an item is always in extended state.
@@ -167,7 +165,8 @@
     virtual void UpdateL( const MFsTreeItemData& aData,
                           TBool aFocused,
                           const TUint aLevel,
-                          CAlfTexture*& aMarkIcon,
+                          CAlfTexture*& aMarkOnIcon,
+                          CAlfTexture*& aMarkOffIcon,
                           CAlfTexture*& aMenuIcon,
                           const TUint aTimeout = 0,
                           TBool aUpdateData = ETrue);
--- a/emailuis/uicomponents/inc/fstreeplainrootvisualizer.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fstreeplainrootvisualizer.h	Wed Sep 15 11:52:37 2010 +0300
@@ -21,10 +21,6 @@
 
 
 #include <e32base.h>
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
-
 #include "fstreenodevisualizerbase.h"
 
 class CAlfTextVisual;
@@ -94,7 +90,8 @@
     virtual void UpdateL( const MFsTreeItemData& aData,
                   TBool aFocused,
                   const TUint aLevel,
-                  CAlfTexture*& aMarkIcon,
+                  CAlfTexture*& aMarkOnIcon,
+                  CAlfTexture*& aMarkOffIcon,
                   CAlfTexture*& aMenuIcon,                
                   const TUint aTimeout = 0,
                   TBool aUpdateData = ETrue);
--- a/emailuis/uicomponents/inc/fstreeplaintwolineitemvisualizer.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fstreeplaintwolineitemvisualizer.h	Wed Sep 15 11:52:37 2010 +0300
@@ -20,10 +20,6 @@
 #define C_FSTREEPLAINTWOLINEITEMVISUALIZER_H
 
 #include <e32base.h>
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
-
 #include "fstreeplainonelineitemvisualizer.h"
 
 class CFsTreePlainTwoLineItemData;
@@ -181,7 +177,8 @@
     virtual void UpdateL( const MFsTreeItemData& aData,
                           TBool aFocused,
                           const TUint aLevel,
-                          CAlfTexture*& aMarkIcon,
+                          CAlfTexture*& aMarkOnIcon,
+                          CAlfTexture*& aMarkOffIcon,                          
                           CAlfTexture*& aMenuIcon,
                           const TUint aTimeout = 0,
                           TBool aUpdateData = ETrue);
--- a/emailuis/uicomponents/inc/fstreerichitemvisualizer.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fstreerichitemvisualizer.h	Wed Sep 15 11:52:37 2010 +0300
@@ -22,11 +22,6 @@
 
 
 #include <e32base.h>
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
-
-
 #include "fstreeitemvisualizerbase.h"
 
 class CAlfControl;
@@ -121,7 +116,8 @@
     virtual void UpdateL( const MFsTreeItemData& aData,
                         TBool aFocused,
                         const TUint aLevel,
-                        CAlfTexture*& aMarkIcon,
+                        CAlfTexture*& aMarkOnIcon,
+                        CAlfTexture*& aMarkOffIcon,
                         CAlfTexture*& aMenuIcon,
                         const TUint aTimeout = 0,
                         TBool aUpdateData = ETrue);
--- a/emailuis/uicomponents/inc/fstreevisualizerbase.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/inc/fstreevisualizerbase.h	Wed Sep 15 11:52:37 2010 +0300
@@ -843,15 +843,27 @@
     /**
      * Sets icon for a mark sign.
      *
-     * @param aMarkIcon Icon to mark items.
+     * @param aMarkOnIcon Icon to mark items.
      */
-    virtual void SetMarkIcon( CAlfTexture& aMarkIcon );
+    virtual void SetMarkOnIcon( CAlfTexture& aMarkOnIcon );
 
     /**
-     * Returns icon used to mark items.
+     * Sets icon for a mark sign.
+     *
+     * @param aMarkOffIcon Icon to unmark items.
      */
-    virtual CAlfTexture* MarkIcon( );
-
+    virtual void SetMarkOffIcon( CAlfTexture& aMarkOffIcon );
+
+    /**
+     * Returns icon used to identify marked items.
+     */
+    virtual CAlfTexture* MarkOnIcon( );
+
+    /**
+     * Returns icon used to identify unmarked items.
+     */
+    virtual CAlfTexture* MarkOffIcon( );    
+    
     /**
      * Checks if item is marked and return status
      * @param aItemId item id to be checked
@@ -924,6 +936,14 @@
     void SetFocusedL( const TBool aFocused );
 
     /**
+     * Sets marking mode on\off
+     * 
+     * @param ETrue if marking mode is set on
+     */
+
+    void SetMarkingModeL( const TBool aMarkingMode );
+
+    /**
      *
      * @param aTexture A custom texture for the selector.
      *                 The texture is used to create an image brush.
@@ -1009,9 +1029,7 @@
      *
      * @panic EFsListPanicInvalidItemID Item with specified ID is not found.
      */
-    // <cmail>
     virtual void SetFocusedItemL( const TFsTreeItemId aItem, TBool aCheckFocus = ETrue );
-    // </cmail>
 
     /**
     * Gets item vertical position in the list
@@ -1042,9 +1060,7 @@
      *
      * @param aItemId Id of an item that will be displayed as first.
      */
-    // <cmail>
     virtual void SetFirstVisibleItemL( const TFsTreeItemId aItemId );
-    // </cmail>
 
     /**
      * Get an id of the first visible item.
@@ -1300,6 +1316,11 @@
      */
     virtual TBool IsItemsAlwaysExtended ( );
 
+    /*
+     * The function returns ETrue if marking mode is on
+     */
+    virtual TBool IsMarkingMode ( );    
+    
     /**
      * The function sets a text for empty list's view.
      * The function does not refresh the view automatically.
@@ -2171,8 +2192,13 @@
     /**
      * Icon used to mark items.
      */
-    CAlfTexture* iMarkIcon;
-
+    CAlfTexture* iMarkOnIcon;
+
+    /**
+     * Icon used to unmark items.
+     */
+    CAlfTexture* iMarkOffIcon;    
+    
     /**
      * Icon indicating that item has menu.
      */
@@ -2370,7 +2396,12 @@
          * This flag is checked when trying to focus item. Focus is ignored 
          * if list is being panned. 
          */        
-        EListPanning
+        EListPanning,
+		
+        /**
+         * Informs if marking mode is on
+         */
+        EMarkingMode
     };
 
     // Flags
--- a/emailuis/uicomponents/src/fscontrolbutton.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fscontrolbutton.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -206,8 +206,11 @@
     TFsControlButtonElem aWhich )
     {
     FUNC_LOG;
-    iModel->SetIconL( aIcon, aWhich );
-    iVisualiser->UpdateElementL( aWhich );
+    if ( iModel->Icon( aWhich ) != &aIcon ) // don't set the same icon twice
+        {
+        iModel->SetIconL( aIcon, aWhich );
+        iVisualiser->UpdateElementL( aWhich );
+        }
     }
 
 
@@ -629,7 +632,9 @@
                     iParent.HandleButtonEvent(
                         MFsControlButtonObserver::EEventButton,
                         iModel->Id() );
-                    result = ETrue;
+                    
+                    // EStdKeyDevice3 (EKeyOK) cannot be consumed here.
+                    result = EFalse;
 
                     if ( iTriggeredComponent )
                         {
--- a/emailuis/uicomponents/src/fscontrolbuttonvisualiser.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fscontrolbuttonvisualiser.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -221,7 +221,8 @@
     if( iUseDefaultBackground )
         {
         ClearBackgroundImage();
-        iDefaultBgBrush = CAlfFrameBrush::NewL( iParent->Env(), KAknsIIDQsnFrButtonTb );  
+        iDefaultBgBrush = CAlfFrameBrush::NewL( iParent->Env(), KAknsIIDQsnFrButtonTb );
+        iLastUpdatedButtonModelSize.SetSize(0,0); // prevent code skip in ClearBackgroundImage
         iBgBrush = iDefaultBgBrush;
         iButtonLayout->Brushes()->AppendL( iBgBrush, EAlfDoesNotHaveOwnership );
         UpdateBarLayout();
@@ -678,14 +679,16 @@
             }
         }
 
+    TSize size =  iButtonModel->Size();
+    
     // New size for the button background.
-    iButtonLayout->SetSize( iButtonModel->Size() );
+    iButtonLayout->SetSize( size );
     // Same size for the content
-    iButtonContentLayout->SetSize( iButtonModel->Size() );
+    iButtonContentLayout->SetSize( size );
 
-    if( iDefaultBgBrush )
+    if ( iDefaultBgBrush && size != iLastUpdatedButtonModelSize )
         {
-        TSize size =  iButtonModel->Size();
+        iLastUpdatedButtonModelSize = size;
         TRect fullRect = TRect( size );
         TRect innerRect = fullRect;
         innerRect.Shrink( KButtonBorderSize,KButtonBorderSize );
--- a/emailuis/uicomponents/src/fsmultilineitemvisualizer.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fsmultilineitemvisualizer.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -19,7 +19,6 @@
 //////SYSTEM INCLUDES
 
 //////TOOLKIT INCLUDES
-// <cmail> SF
 #include "emailtrace.h"
 #include <alf/alfenv.h>
 #include <alf/alflayout.h>
@@ -29,8 +28,6 @@
 #include <alf/alftexture.h>
 #include <alf/alfcontrol.h>
 #include <alf/alfimage.h>
-// </cmail>
-
 
 //////PROJECT INCLUDES
 #include "fsmultilineitemvisualizer.h"
@@ -339,7 +336,8 @@
 void CFsMultiLineItemVisualizer::UpdateL( const MFsTreeItemData& aData,
                                         TBool aFocused,
                                         const TUint aLevel,
-                                        CAlfTexture*& aMarkIcon,
+                                        CAlfTexture*& aMarkOnIcon,
+                                        CAlfTexture*& /*aMarkOffIcon*/,
                                         CAlfTexture*& aMenuIcon,
                                         const TUint /*aTimeout*/,
                                         TBool aUpdateData)
@@ -439,10 +437,10 @@
             iFirstLineIconVis->SetImage( TAlfImage( *data->LineIcon( 0 ) ) );                
             }
         //mark icon
-        if ( iMarkIconVis && IsMarked() && aMarkIcon )
+        if ( iMarkIconVis && IsMarked() && aMarkOnIcon )
             {
             iMarkIconVis->SetScaleMode( CAlfImageVisual::EScaleFit );
-            iMarkIconVis->SetImage( *aMarkIcon );
+            iMarkIconVis->SetImage( *aMarkOnIcon );
             }
         //menu icon
         if ( iMenuIconVis && (iFlags & KFsTreeListItemHasMenu) && aMenuIcon )
--- a/emailuis/uicomponents/src/fsseparatorvisualizer.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fsseparatorvisualizer.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -23,13 +23,13 @@
 #include "fsseparatordata.h"
 #include "fstreelist.h"
 #include "fslayoutmanager.h"
-// <cmail> SF
+
 #include <alf/alfanchorlayout.h>
 #include <alf/alfcurvepath.h>
 #include <alf/alflinevisual.h>
 #include <alf/alfenv.h>
 #include <alf/alfevent.h>
-// </cmail>
+
 
 // ======== MEMBER FUNCTIONS ========
  
@@ -218,6 +218,15 @@
     iFlags &= ~KFsTreeListItemAlwaysExtended;
     }
 
+// ---------------------------------------------------------------------------
+//
+//
+// ---------------------------------------------------------------------------
+//
+void CFsSeparatorVisualizer::SetMarkingMode( TBool /*aMarkingMode*/ )
+    {
+    FUNC_LOG;
+    }
 
 // ---------------------------------------------------------------------------
 // From class MFsTreeItemVisualizer.
@@ -278,7 +287,8 @@
 void CFsSeparatorVisualizer::UpdateL( const MFsTreeItemData& aData,
                                           TBool /*aFocused*/,
                                           const TUint aLevel,
-                                          CAlfTexture*& /*aMarkIcon*/,
+                                          CAlfTexture*& /*aMarkOnIcon*/,
+                                          CAlfTexture*& /*aMarkOffIcon*/,
                                           CAlfTexture*& /*aMenuIcon*/,
                                           const TUint /*aTimeout*/,
                                           TBool /*aUpdateData*/)
--- a/emailuis/uicomponents/src/fstreeitemvisualizerbase.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fstreeitemvisualizerbase.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -26,7 +26,6 @@
 #include "fslayoutmanager.h"
 #include "fsalftextstylemanager.h"
 
-// <cmail> SF
 #include <alf/alfgradientbrush.h>
 #include <alf/alfimagebrush.h>
 #include <alf/alfanchorlayout.h>
@@ -37,7 +36,6 @@
 #include <alf/alftextstyle.h>
 #include <alf/alftextvisual.h>
 #include <alf/alfmappingfunctions.h>
-// </cmail>
 
 // ---------------------------------------------------------------------------
 // C++ destructor.
@@ -538,7 +536,6 @@
     return retVal;
     }
 
-// <cmail>
 // ---------------------------------------------------------------------------
 // From MFsTreeItemVisualizer.
 // Sets item background brush.
@@ -568,7 +565,6 @@
 
     return retVal;
     }
-// </cmail>
   
 // ---------------------------------------------------------------------------
 // From MFsTreeItemVisualizer.
@@ -637,6 +633,24 @@
     }
 
 // ---------------------------------------------------------------------------
+// From class MFsTreeItemVisualizer.
+// Sets marking mode on/off.
+// ---------------------------------------------------------------------------
+//
+void CFsTreeItemVisualizerBase::SetMarkingMode( TBool aMarkingMode )
+    {
+    FUNC_LOG;
+    if ( aMarkingMode )
+        {
+        iFlags |= KFsTreeListMarkingMode;
+        }
+    else
+        {
+        iFlags &= ~KFsTreeListMarkingMode;
+        }
+    }
+
+// ---------------------------------------------------------------------------
 //  This function returns wether an item is always in extended state.
 // ---------------------------------------------------------------------------
 //
@@ -667,7 +681,8 @@
 void CFsTreeItemVisualizerBase::UpdateL( const MFsTreeItemData& /*aData*/,
                                           TBool /*aFocused*/,
                                           const TUint /*aLevel*/,
-                                          CAlfTexture*& /*aMarkIcon*/,
+                                          CAlfTexture*& /*aMarkOnIcon*/,
+                                          CAlfTexture*& /*aMarkOffIcon*/,
                                           CAlfTexture*& /*aMenuIcon*/,
                                           const TUint /*aTimeout*/,
                                           TBool /*aUpdateData*/)
--- a/emailuis/uicomponents/src/fstreelist.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fstreelist.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -20,15 +20,9 @@
 //////SYSTEM INCLUDES
 
 //////TOOLKIT INCLUDES
-// <cmail> SF
 #include "emailtrace.h"
 #include <alf/alfenv.h>
-// </cmail>
 
-//////PROJECT INCLUDES
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
 #include "fstreelist.h"
 #include "fstreecontrol.h"
 #include "fstree.h"
@@ -347,6 +341,16 @@
     return iListFocused;
     }
 
+//---------------------------------------------------------------------------
+// 
+//---------------------------------------------------------------------------
+EXPORT_C void CFsTreeList::SetMarkingModeL( const TBool aMarkingMode )
+    {
+    FUNC_LOG;
+    iTreeVisualizer->SetMarkingModeL( aMarkingMode );
+    }
+
+
 // ---------------------------------------------------------------------------
 //  The function sets duration of the slide-in effect.
 // ---------------------------------------------------------------------------
@@ -940,19 +944,16 @@
 //  Retrieves events from tree visualizer
 // ---------------------------------------------------------------------------
 //
-// <cmail> Touch
 EXPORT_C void CFsTreeList::TreeVisualizerEventL(
         const TFsTreeVisualizerEvent aEvent,
         const TFsTreeItemId aId,
         const TPoint& aPoint ) const
-// </cmail>
     {
     FUNC_LOG;
     MFsTreeListObserver::TFsTreeListEvent listEvent;
 
     switch ( aEvent )
     {
-    // <cmail> "Base class modifications for using touch"
     case MFsTreeVisualizerObserver::EFsTreeItemTouchAction:
         {
         listEvent = MFsTreeListObserver::EFsTreeListItemTouchAction;
@@ -968,9 +969,6 @@
         listEvent = MFsTreeListObserver::EFsTreeListItemTouchFocused;
         break;
         }
-
-    // </cmail>
-
     case MFsTreeVisualizerObserver::EFsTreeItemSelected:
         {
         listEvent = MFsTreeListObserver::EFsTreeItemSelected;
@@ -1006,8 +1004,6 @@
         listEvent = MFsTreeListObserver::EFsTreeListItemWillGetFocused;
         break;
         }
-
-    // <cmail>
     // Pass on the collapse/expand events.
     case MFsTreeVisualizerObserver::EFsTreeListItemCollapsed:
         {
@@ -1029,7 +1025,6 @@
         listEvent = MFsTreeListObserver::EFsTreeListExpandedAll;
         break;
         }
-    // </cmail>
     case MFsTreeVisualizerObserver::EFsChangeFocusVisibility:
         {
         listEvent = MFsTreeListObserver::EFsFocusVisibilityChange;
--- a/emailuis/uicomponents/src/fstreenodevisualizerbase.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fstreenodevisualizerbase.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -26,7 +26,6 @@
 #include "fslayoutmanager.h"
 #include "fsalftextstylemanager.h"
 
-// <cmail> SF
 #include <alf/alfgradientbrush.h>
 #include <alf/alfimagebrush.h>
 #include <alf/alfanchorlayout.h>
@@ -37,7 +36,6 @@
 #include <alf/alftextstyle.h>
 #include <alf/alftextvisual.h>
 #include <alf/alfmappingfunctions.h>
-// </cmail>
 
 // ---------------------------------------------------------------------------
 // C++ destructor.
@@ -534,7 +532,6 @@
     return retVal;
     }
 
-// <cmail>
 // ---------------------------------------------------------------------------
 // From MFsTreeItemVisualizer.
 // Sets item background brush.
@@ -564,7 +561,6 @@
 
     return retVal;
     }
-// </cmail>
 
 // ---------------------------------------------------------------------------
 // From MFsTreeItemVisualizer.
@@ -626,6 +622,23 @@
     }
 
 // ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CFsTreeNodeVisualizerBase::SetMarkingMode( TBool aMarkingMode )
+    {
+    FUNC_LOG;
+    if ( aMarkingMode )
+        {
+        iFlags |= KFsTreeListMarkingMode;
+        }
+    else
+        {
+        aMarkingMode &= ~KFsTreeListMarkingMode;
+        }
+    }
+
+// ---------------------------------------------------------------------------
 //  This function returns wether an item is always in extended state.
 // ---------------------------------------------------------------------------
 //
@@ -656,7 +669,8 @@
 void CFsTreeNodeVisualizerBase::UpdateL( const MFsTreeItemData& /*aData*/,
                                           TBool /*aFocused*/,
                                           const TUint /*aLevel*/,
-                                          CAlfTexture*& /*aMarkIcon*/,
+                                          CAlfTexture*& /*aMarkIconOn*/,
+                                          CAlfTexture*& /*aMarkIconOff*/,										  
                                           CAlfTexture*& /*aMenuIcon*/,
                                           const TUint /*aTimeout*/,
                                           TBool /*aUpdateData*/)
--- a/emailuis/uicomponents/src/fstreeplainonelineitemvisualizer.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fstreeplainonelineitemvisualizer.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -15,11 +15,6 @@
 *
 */
 
-
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
-
 #include "emailtrace.h"
 #include "fstreeplainonelineitemvisualizer.h"
 #include "fstreeplainonelineitemdata.h"
@@ -30,7 +25,6 @@
 #include "fsmarqueeclet.h"
 #include <touchlogicalfeedback.h>
 
-// <cmail> SF
 #include <alf/alfanchorlayout.h>
 #include <alf/alfimagevisual.h>
 #include <alf/alfviewportlayout.h>
@@ -41,7 +35,6 @@
 
 #include <alf/alfevent.h>
 #include <alf/alfmappingfunctions.h>
-// </cmail>
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -347,7 +340,7 @@
     if ( iFlags & KFsTreeListItemMarked )
         {
         TInt iconMarkedVisIndex =
-                            iLayout->FindVisual(iIconMarked);
+                            iLayout->FindVisual(iIconMark);
         if ( iconMarkedVisIndex != KErrNotFound )
             {
             iLayout->SetAnchor(EAlfAnchorTopLeft,
@@ -365,16 +358,16 @@
 
             TAlfTimedValue opacity;
             opacity.SetValueNow(1.0f);
-            iIconMarked->SetOpacity(opacity);
+            iIconMark->SetOpacity(opacity);
             }
         }
     else
         {
-        if (iIconMarked)
+        if (iIconMark)
             {
             TAlfTimedValue opacity;
             opacity.SetValueNow(0.0f);
-            iIconMarked->SetOpacity(opacity);
+            iIconMark->SetOpacity(opacity);
             }
         }
     iLayout->UpdateChildrenLayout();
@@ -407,7 +400,6 @@
             {
             iIconVisual =
                         CAlfImageVisual::AddNewL(iOwnerControl, iLayout);
-            // <cmail> aspect ratio preserved
             iIconVisual->SetScaleMode( CAlfImageVisual::EScaleFitInside);
             iIconVisual->SetFlag( EAlfVisualFlagIgnorePointer );
             }
@@ -426,11 +418,11 @@
             iTextVisual->SetFlag( EAlfVisualFlagIgnorePointer );
             }
 
-        if (!iIconMarked)
+        if (!iIconMark)
             {
-            iIconMarked = CAlfImageVisual::AddNewL(iOwnerControl, iLayout);
-            iIconMarked->SetScaleMode( CAlfImageVisual::EScaleFitInside);
-            iIconMarked->SetFlag( EAlfVisualFlagIgnorePointer );
+            iIconMark = CAlfImageVisual::AddNewL(iOwnerControl, iLayout);
+            iIconMark->SetScaleMode( CAlfImageVisual::EScaleFitInside);
+            iIconMark->SetFlag( EAlfVisualFlagIgnorePointer );
             }
 
         if (!iIconMenu)
@@ -461,7 +453,8 @@
 void CFsTreePlainOneLineItemVisualizer::UpdateL( const MFsTreeItemData& aData,
                                           TBool aFocused,
                                           const TUint aLevel,
-                                          CAlfTexture*& aMarkIcon,
+                                          CAlfTexture*& aMarkOnIcon,
+                                          CAlfTexture*& /*aMarkOffIcon*/,
                                           CAlfTexture*& aMenuIcon,
                                           const TUint /*aTimeout*/,
                                           TBool aUpdateData)
@@ -499,9 +492,7 @@
 
             if (iIconVisual && data->IsIconSet())
                 {
-                // <cmail> aspect ratio preserved
                 iIconVisual->SetScaleMode( CAlfImageVisual::EScaleFitInside );
-                // </cmail>
                 iIconVisual->SetImage( TAlfImage( data->Icon() ) );
                 }
 
@@ -566,9 +557,9 @@
             if ( IsMarked() )
                 {
                 // <cmail> aspect ratio preserved
-                iIconMarked->SetScaleMode( CAlfImageVisual::EScaleFitInside);
+                iIconMark->SetScaleMode( CAlfImageVisual::EScaleFitInside);
                 // </cmail>
-                iIconMarked->SetImage( *aMarkIcon );
+                iIconMark->SetImage( *aMarkOnIcon );
                 }
 
             if ((iFlags & KFsTreeListItemHasMenu)
@@ -630,7 +621,7 @@
         iLayout = NULL;
         iTextVisual = NULL;
         iIconVisual = NULL;
-        iIconMarked = NULL;
+        iIconMark = NULL;
         iIconMenu = NULL;
         iParentLayout = NULL;
         iViewportLayout = NULL;
--- a/emailuis/uicomponents/src/fstreeplainonelinenodevisualizer.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fstreeplainonelinenodevisualizer.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -15,11 +15,6 @@
 *
 */
 
-
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
-
 #include "emailtrace.h"
 #include "fstreeplainonelinenodevisualizer.h"
 #include "fstreeplainonelinenodedata.h"
@@ -29,7 +24,6 @@
 #include "fsmarqueeclet.h"
 #include <touchlogicalfeedback.h>
 
-// <cmail> SF
 #include <alf/alfanchorlayout.h>
 #include <alf/alfimagevisual.h>
 #include <alf/alfviewportlayout.h>
@@ -39,7 +33,6 @@
 
 #include <alf/alfevent.h>
 #include <alf/alfmappingfunctions.h>
-// </cmail>
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -193,6 +186,15 @@
     iFlags &= ~KFsTreeListItemAlwaysExtended;
     }
 
+// ---------------------------------------------------------------------------
+// From MFsTreeItemVisualizer.
+// 
+// ---------------------------------------------------------------------------
+//
+void CFsTreePlainOneLineNodeVisualizer::SetMarkingMode( TBool /*aMarkingMode*/ ) //TEJ_MMD
+    {
+    FUNC_LOG;
+    }
 
 // ---------------------------------------------------------------------------
 // From MFsTreeItemVisualizer.
@@ -587,7 +589,8 @@
 void CFsTreePlainOneLineNodeVisualizer::UpdateL( const MFsTreeItemData& aData,
                                           TBool aFocused,
                                           const TUint aLevel,
-                                          CAlfTexture*& aMarkIcon,
+                                          CAlfTexture*& aMarkOnIcon,
+                                          CAlfTexture*& /*aMarkOffIcon*/,
                                           CAlfTexture*& aMenuIcon,
                                           const TUint /*aTimeout*/,
                                           TBool aUpdateData)
@@ -622,7 +625,7 @@
 
             //update the ancors for current item settings
             const TInt indent( iTextIndentation * ( aLevel - 1 ) );
-            UpdateLayout(data, indent, aMarkIcon, aMenuIcon);
+            UpdateLayout(data, indent, aMarkOnIcon, aMenuIcon);
 
             if (iTextVisual && aUpdateData)
                 {
@@ -695,9 +698,9 @@
                     }
                 }
 
-            if ( IsMarked() && iIconMarked && aMarkIcon )
+            if ( IsMarked() && iIconMarked && aMarkOnIcon )
                 {
-                iIconMarked->SetImage( *aMarkIcon );
+                iIconMarked->SetImage( *aMarkOnIcon );
                 }
 
             if ( (iFlags & KFsTreeListItemHasMenu) && iIconMenu && aMenuIcon )
--- a/emailuis/uicomponents/src/fstreeplainrootvisualizer.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fstreeplainrootvisualizer.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -22,12 +22,11 @@
 #include "fstreeplainonelineitemdata.h"
 #include "fstreeplainrootvisualizer.h"
 #include "fstextstylemanager.h"
-// <cmail> SF
+
 #include <alf/alfcontrol.h>
 #include <alf/alfanchorlayout.h>
 #include <alf/alftextvisual.h>
 #include <alf/alftexture.h>
-// </cmail>
 
 // ======== MEMBER FUNCTIONS ========
  
@@ -117,7 +116,8 @@
 void CFsTreePlainRootVisualizer::UpdateL( const MFsTreeItemData& aData,
                                           TBool /*aFocused*/,
                                           const TUint /*aLevel*/,
-                                          CAlfTexture*& /*aMarkIcon*/,
+                                          CAlfTexture*& /*aMarkOnIcon*/,
+                                          CAlfTexture*& /*aMarkOffIcon*/,
                                           CAlfTexture*& /*aMenuIcon*/,
                                           const TUint /*aTimeout*/,
                                           TBool aUpdateData)
--- a/emailuis/uicomponents/src/fstreeplaintwolineitemvisualizer.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fstreeplaintwolineitemvisualizer.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -12,14 +12,10 @@
 * Contributors:
 *
 *  Description : A visualizer for data items with plain text.
-*  Version     : %version: tr1sido#17 %
+*  Version     : %version: tr1sido#18 %
 *
 */
 
-
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
 #include "emailtrace.h"
 #include <AknsUtils.h>
 #include <touchlogicalfeedback.h>
@@ -30,7 +26,7 @@
 #include "fslayoutmanager.h"
 #include "fstextstylemanager.h"
 #include "fsmarqueeclet.h"
-// <cmail> SF
+
 #include <alf/alfanchorlayout.h>
 #include <alf/alfimagevisual.h>
 #include <alf/alfviewportlayout.h>
@@ -38,10 +34,8 @@
 #include <alf/alfimage.h>
 #include <alf/alfenv.h>
 #include <alf/alfcontrol.h>
-
 #include <alf/alfevent.h>
 #include <alf/alfmappingfunctions.h>
-// </cmail>
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -272,7 +266,7 @@
     
     CFsLayoutManager::TFsLayoutMetrics
         mainIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG1,
-        markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG4,
+        markIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG1,
         menuIconMetrics = CFsLayoutManager::EFsLmListSingleDycRowPaneG3,
         sizeMetrics     = CFsLayoutManager::EFsLmListSingleDycRowPane,
         exSizeMetrics   = CFsLayoutManager::EFsLmListSingleFsDycPane,
@@ -343,7 +337,7 @@
 
         if (aData->IsIconSet())
             {
-            if (iFlags & KFsTreeListItemMarked)
+            if ( iFlags & KFsTreeListMarkingMode )
                 {
                 if ((iFlags & KFsTreeListItemHasMenu)
                         && (iFlags & KFsTreeListItemFocused))
@@ -402,12 +396,12 @@
                     {
                     //mainIcon + markIcon
                     mainIconMetrics =
-                        CFsLayoutManager::EFsLmListSingleDycRowPaneG1;
-                    mainIconVariety = 4;
+                        CFsLayoutManager::EFsLmListSingleDycRowPaneG2;
+                    mainIconVariety = 2;
                     markIconMetrics =
-                        CFsLayoutManager::EFsLmListSingleDycRowPaneG4;
-                    markIconVariety = 3;
-                    firstLineTextParentVariety = 4;
+                        CFsLayoutManager::EFsLmListSingleDycRowPaneG1;
+                    markIconVariety = 2;
+                    firstLineTextParentVariety = 2;
                     if (firstLineTextFields==1)
                         {
                         firstLineTextMetrics[0] =
@@ -418,10 +412,10 @@
                         {
                         firstLineTextMetrics[0] =
                             CFsLayoutManager::EFsLmListSingleDycRowTextPaneT1;
-                        firstLineTextVarieties[0] = 13;
+                        firstLineTextVarieties[0] = 11;
                         firstLineTextMetrics[1] =
                             CFsLayoutManager::EFsLmListSingleDycRowTextPaneT2;
-                        firstLineTextVarieties[1] = 4;
+                        firstLineTextVarieties[1] = 2;
                         }
                     }
                 }
@@ -652,10 +646,8 @@
                 secondLineTextVariety = 8;
                 }
             }
-        //<cmail> ???
         thirdLineTextMetrics = CFsLayoutManager::EFsLmListSingleDycRowTextPaneT1;
         thirdLineTextVariety = 4;
-        //</cmail>
         }
     else
         {
@@ -1366,51 +1358,50 @@
             }
         }
 
-    if ( IsMarked() && iIconMarked )
-        {
-        if (iIconMarked)
+    if ( iFlags & KFsTreeListMarkingMode && iIconMark )
+        {       
+
+        TRect iconRowParent = currentSize;        
+        if (markIconRow > 0)
             {
-            TRect iconRowParent = currentSize;
-            if (markIconRow > 0)
-                {
-                CFsLayoutManager::LayoutMetricsRect(currentSize, CFsLayoutManager::EFsLmListSingleDycRowPane, iconRowParent, markIconRow, markIconRow);
-                }
-            CFsLayoutManager::LayoutMetricsRect(
-                    iconRowParent,
-                    markIconMetrics,
-                    rect,
-                    markIconVariety);
-            tpMarkIconTl.SetTarget(TAlfRealPoint(rect.iTl));
-            tpMarkIconBr.SetTarget(TAlfRealPoint(rect.iBr));
+            CFsLayoutManager::LayoutMetricsRect(currentSize, CFsLayoutManager::EFsLmListSingleDycRowPane, iconRowParent, markIconRow, markIconRow);
+            }
+        CFsLayoutManager::LayoutMetricsRect(
+            iconRowParent,
+            markIconMetrics,
+            rect,
+            markIconVariety);
+
+        tpMarkIconTl.SetTarget(TAlfRealPoint(rect.iTl));			
+        tpMarkIconBr.SetTarget(TAlfRealPoint(rect.iBr));
 
-            TInt iconMarkedVisIndex =
-                                 iLayout->FindVisual(iIconMarked);
-            if ( iconMarkedVisIndex != KErrNotFound )
-                {
-                tpMarkIconTl.SetStyle(EAlfTimedValueStyleSineWave);
-                iLayout->SetAnchor(EAlfAnchorTopLeft,
-                    iconMarkedVisIndex,
-                    EAlfAnchorOriginLeft,EAlfAnchorOriginTop,
-                    EAlfAnchorMetricAbsolute,EAlfAnchorMetricAbsolute,
-                    tpMarkIconTl );
-                tpMarkIconBr.SetStyle(EAlfTimedValueStyleSineWave);
-                iLayout->SetAnchor(EAlfAnchorBottomRight,
-                    iconMarkedVisIndex,
-                    EAlfAnchorOriginLeft,EAlfAnchorOriginTop,
-                    EAlfAnchorMetricAbsolute,EAlfAnchorMetricAbsolute,
-                    tpMarkIconBr );
-                }
+        TInt iconMarkedVisIndex = iLayout->FindVisual(iIconMark);
+
+        if ( iconMarkedVisIndex != KErrNotFound )
+            {
+            tpMarkIconTl.SetStyle(EAlfTimedValueStyleSineWave);
+            iLayout->SetAnchor(EAlfAnchorTopLeft,
+                iconMarkedVisIndex,
+                EAlfAnchorOriginLeft,EAlfAnchorOriginTop,
+                EAlfAnchorMetricAbsolute,EAlfAnchorMetricAbsolute,
+                tpMarkIconTl );
+            tpMarkIconBr.SetStyle(EAlfTimedValueStyleSineWave);
+            iLayout->SetAnchor(EAlfAnchorBottomRight,
+                iconMarkedVisIndex,
+                EAlfAnchorOriginLeft,EAlfAnchorOriginTop,
+                EAlfAnchorMetricAbsolute,EAlfAnchorMetricAbsolute,
+                tpMarkIconBr );
+ 	        opacity.SetValueNow(1.0f);
+            iIconMark->SetOpacity(opacity);							
             }
-        opacity.SetValueNow(1.0f);
-        iIconMarked->SetOpacity(opacity);
         }
     else
         {
-        if (iIconMarked)
-        	{
-        	opacity.SetValueNow(0.0f);
-        	iIconMarked->SetOpacity(opacity);
-        	}
+        if (iIconMark)
+            {
+            opacity.SetValueNow(0.0f);
+            iIconMark->SetOpacity(opacity);
+            }
         }
 
     if ( iPreviewPaneTextVisual )
@@ -1450,7 +1441,6 @@
 
         }
     iLayout->UpdateChildrenLayout();
-    // </cmail>
     }
 
 // ---------------------------------------------------------------------------
@@ -1506,17 +1496,16 @@
             iSecondaryTextVisual->SetFlag( EAlfVisualFlagIgnorePointer );
             }
 
-        if (!iIconMarked)
+        if (!iIconMark)
             {
-            iIconMarked = CAlfImageVisual::AddNewL( iOwnerControl, iLayout );
-            iIconMarked->SetScaleMode( CAlfImageVisual::EScaleFit );
-            iIconMarked->SetFlag( EAlfVisualFlagIgnorePointer );
+            iIconMark = CAlfImageVisual::AddNewL( iOwnerControl, iLayout );
+            iIconMark->SetScaleMode( CAlfImageVisual::EScaleFit );
+            iIconMark->SetFlag( EAlfVisualFlagIgnorePointer );
             }
 
         if (!iIconMenu)
             {
-            iIconMenu =
-                        CAlfImageVisual::AddNewL(iOwnerControl, iLayout);
+            iIconMenu = CAlfImageVisual::AddNewL(iOwnerControl, iLayout);
             iIconMenu->SetScaleMode( CAlfImageVisual::EScaleFit );
             iIconMenu->SetFlag( EAlfVisualFlagIgnorePointer );
             }
@@ -1564,7 +1553,8 @@
 void CFsTreePlainTwoLineItemVisualizer::UpdateL( const MFsTreeItemData& aData,
                                           TBool aFocused,
                                           const TUint aLevel,
-                                          CAlfTexture*& aMarkIcon,
+                                          CAlfTexture*& aMarkOnIcon,
+                                          CAlfTexture*& aMarkOffIcon,                                          
                                           CAlfTexture*& aMenuIcon,
                                           const TUint aTimeout,
                                           TBool aUpdateData)
@@ -1746,10 +1736,15 @@
                 iDateTimeTextVisual->SetTextStyle( styleId );
                 }
 
-            if ( IsMarked() && iIconMarked && aMarkIcon )
+            if ( IsMarked() && iIconMark && aMarkOnIcon )
                 {
-                iIconMarked->SetScaleMode( CAlfImageVisual::EScaleFit );
-                iIconMarked->SetImage( *aMarkIcon );
+                iIconMark->SetScaleMode( CAlfImageVisual::EScaleFit );
+                iIconMark->SetImage( *aMarkOnIcon );
+                }
+            else if ( !IsMarked() && iIconMark && aMarkOffIcon )
+                {
+                iIconMark->SetScaleMode( CAlfImageVisual::EScaleFit );
+                iIconMark->SetImage( *aMarkOffIcon );
                 }
 
             //menu icon - visible only when item is focused
--- a/emailuis/uicomponents/src/fstreerichitemvisualizer.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fstreerichitemvisualizer.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -19,11 +19,7 @@
 
 #include "emailtrace.h"
 #include <txtrich.h>
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
 
-// <cmail> SF
 #include <alf/alfcontrol.h>
 #include <alf/alflayout.h>
 #include <alf/alfflowlayout.h>
@@ -34,7 +30,6 @@
 #include <alf/alfimagevisual.h>
 #include <alf/alfbrusharray.h>
 #include <alf/alfenv.h>
-// </cmail>
 
 #include "fstreerichitemvisualizer.h"
 #include "fstreerichitemdata.h"
@@ -505,7 +500,8 @@
     const MFsTreeItemData& aData,
     TBool /*aFocused*/,
     const TUint aLevel,
-    CAlfTexture*& aMarkIcon,
+    CAlfTexture*& aMarkOnIcon,
+    CAlfTexture*& /*aMarkOffIcon*/,
     CAlfTexture*& aMenuIcon,
     const TUint /*aTimeout*/,
     TBool aUpdateData)
@@ -534,7 +530,7 @@
             if (iFlags & KFsTreeListItemMarked)
                 {
                 iIconMarked->SetScaleMode( CAlfImageVisual::EScaleFit );
-                iIconMarked->SetImage(TAlfImage(*aMarkIcon));
+                iIconMarked->SetImage(TAlfImage(*aMarkOnIcon));
                 }
 
             if (iFlags & KFsTreeListItemHasMenu)
--- a/emailuis/uicomponents/src/fstreevisualizerbase.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/emailuis/uicomponents/src/fstreevisualizerbase.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -24,7 +24,6 @@
 #include <centralrepository.h>
 
 //////TOOLKIT INCLUDES
-// <cmail> SF
 #include <alf/alfstatic.h>
 #include <alf/alfownership.h>
 #include <alf/alfevent.h>
@@ -50,7 +49,6 @@
 //visuals
 #include <alf/alfvisual.h>
 #include <alf/alfimagevisual.h>
-// </cmail>
 
 
 //////PROJECT INCLUDES
@@ -1064,20 +1062,40 @@
 //  Sets icon for a mark sign.
 // ---------------------------------------------------------------------------
 //
-void CFsTreeVisualizerBase::SetMarkIcon(CAlfTexture& aMarkIcon)
+void CFsTreeVisualizerBase::SetMarkOnIcon(CAlfTexture& aMarkOnIcon)
     {
     FUNC_LOG;
-    iMarkIcon = &aMarkIcon;
+    iMarkOnIcon = &aMarkOnIcon;
+    }
+
+// ---------------------------------------------------------------------------
+//  Sets icon for a unmark sign.
+// ---------------------------------------------------------------------------
+//
+void CFsTreeVisualizerBase::SetMarkOffIcon(CAlfTexture& aMarkOffIcon)
+    {
+    FUNC_LOG;
+    iMarkOffIcon = &aMarkOffIcon;
     }
 
 // ---------------------------------------------------------------------------
 //  Returns icon used to mark items.
 // ---------------------------------------------------------------------------
 //
-CAlfTexture* CFsTreeVisualizerBase::MarkIcon()
+CAlfTexture* CFsTreeVisualizerBase::MarkOnIcon()
     {
     FUNC_LOG;
-    return iMarkIcon;
+    return iMarkOnIcon;
+    }
+
+// ---------------------------------------------------------------------------
+//  Returns icon used to unmark items.
+// ---------------------------------------------------------------------------
+//
+CAlfTexture* CFsTreeVisualizerBase::MarkOffIcon()
+    {
+    FUNC_LOG;
+    return iMarkOffIcon;
     }
 
 // ---------------------------------------------------------------------------
@@ -1109,7 +1127,7 @@
         data = &(iTreeData->ItemData(aItemId));
 
         vis->UpdateL(*data, IsItemFocused(aItemId) && IsFocusShown(),
-                iTreeData->Level(aItemId), iMarkIcon, iMenuIcon);
+                iTreeData->Level(aItemId), iMarkOnIcon, iMarkOffIcon, iMenuIcon);
         }
     }
 
@@ -1269,7 +1287,8 @@
                             MakeSelectorVisibleL(EFalse);
                             visualizer->UpdateL(*data, EFalse,
                                     iTreeData->Level(iFocusedItem),
-                                    iMarkIcon, iMenuIcon, iCurrentScrollSpeed);
+                                    iMarkOnIcon, iMarkOffIcon, 
+                                    iMenuIcon, iCurrentScrollSpeed);
                             }
                         }
                     }
@@ -1280,6 +1299,57 @@
     }
 
 // ---------------------------------------------------------------------------
+//  The functions sets wether all item in the list should be always in
+//  extended state or in normal state.
+// ---------------------------------------------------------------------------
+//
+void CFsTreeVisualizerBase::SetMarkingModeL( TBool aMarkingMode )
+    {
+    FUNC_LOG;
+    // Do not change this to: IsMarkingMode() != aAlwaysExtended, because
+    // it will not work. TBool is defined as TInt and thus this comparison
+    // comes out as TInt != TInt, which always evaluates true in this case.
+    if ( ( IsMarkingMode() && !aMarkingMode ) || 
+         ( !IsMarkingMode() && aMarkingMode ) )
+        {
+        iFlags.Assign(EMarkingMode, aMarkingMode);
+        TFsTreeIterator treeIter(
+                iTreeData->Iterator(KFsTreeRootID, KFsTreeRootID));
+        while (treeIter.HasNext())
+            {
+            TFsTreeItemId itemId(treeIter.Next());
+            if (itemId != KFsTreeNoneID && !iTreeData->IsNode(itemId))
+                {
+                MFsTreeItemVisualizer* itemviz(iTreeData->ItemVisualizer(itemId));
+                ApplyListSpecificValuesToItem(itemviz);
+                }
+            }
+            const TBool isUpdating(iWorld.IsUpdating());
+        if (!isUpdating)
+            {
+            iWorld.BeginUpdate();
+            }
+        iWorld.RemoveAllL();
+        treeIter = iTreeData->Iterator(KFsTreeRootID, KFsTreeRootID,
+                KFsTreeIteratorSkipCollapsedFlag);
+        while (treeIter.HasNext())
+            {
+            TFsTreeItemId itemId(treeIter.Next());
+            if (itemId != KFsTreeNoneID)
+                {
+                MFsTreeItemVisualizer* itemviz(iTreeData->ItemVisualizer(itemId));
+                iWorld.AppendL(itemId, itemviz->Size());
+                }
+            }
+        iViewPort.ClearCache();
+        if (!isUpdating)
+            {
+            iWorld.EndUpdateL();
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
 // The function sets some properties of the selector like bitmap, type
 // of movement.
 // ---------------------------------------------------------------------------
@@ -1710,7 +1780,7 @@
         if ( visualizer )
             {
             visualizer->UpdateL( iTreeData->ItemData( iFocusedItem ), EFalse,
-            		iTreeData->Level( iFocusedItem ), iMarkIcon, iMenuIcon, 0 );
+            		iTreeData->Level( iFocusedItem ), iMarkOnIcon, iMarkOffIcon, iMenuIcon, 0 );
             }
 
         iFocusedItem = aItemId;
@@ -1721,7 +1791,8 @@
     if ( visualizer )
         {
         visualizer->UpdateL( iTreeData->ItemData( iFocusedItem ), IsFocusShown(),
-                iTreeData->Level( iFocusedItem ), iMarkIcon, iMenuIcon, 0 );
+                             iTreeData->Level( iFocusedItem ), iMarkOnIcon, 
+                             iMarkOffIcon, iMenuIcon, 0 );
         }
 
     if ( iFocusedItem != KFsTreeNoneID )
@@ -1770,7 +1841,6 @@
 // Sets an item as first visible one in the list.
 // ---------------------------------------------------------------------------
 //
-// <cmail>
 void CFsTreeVisualizerBase::SetFirstVisibleItemL(const TFsTreeItemId /*aItemId*/)
     {
     FUNC_LOG;
@@ -1786,9 +1856,6 @@
     TFsTreeItemId retId = KFsTreeNoneID;
     if (iVisibleItems.Count())
         {
-        // <cmail>
-        //        TRAP_IGNORE( ClearVisibleItemsListL(EFalse) );
-        // </cmail>
         retId = iVisibleItems[0];
         }
     else
@@ -1822,7 +1889,6 @@
 // Displays the list.
 // ---------------------------------------------------------------------------
 //
-// <cmail>
 void CFsTreeVisualizerBase::ShowListL(const TBool aFadeIn,
         const TBool aSlideIn)
     {
@@ -1831,7 +1897,8 @@
     if (iTreeData->Count() == 0)
         {
         iRootVisualizer->ShowL(*iRootLayout);
-        iRootVisualizer->UpdateL(*iRootData, EFalse, 0, iMarkIcon, iMenuIcon);
+        iRootVisualizer->UpdateL(*iRootData, EFalse, 0, iMarkOnIcon, 
+                                  iMarkOffIcon, iMenuIcon);
         }
     else
         {
@@ -1846,7 +1913,7 @@
 			if ( visualizer )
 				{
 	        	visualizer->UpdateL(iTreeData->ItemData(itemId), itemFocused,
-	                iTreeData->Level(itemId), iMarkIcon, iMenuIcon,
+	                iTreeData->Level(itemId), iMarkOnIcon, iMarkOffIcon, iMenuIcon,
 	                0);
 				}
             }
@@ -1923,7 +1990,6 @@
 
     UpdateScrollBarL();
     }
-// </cmail>
 
 // ---------------------------------------------------------------------------
 // The function assures that the list view is correct.
@@ -2526,7 +2592,7 @@
             vis->UpdateL(iTreeData->ItemData(aItemId),
                     IsItemFocused(aItemId) && IsFocusShown(),
                     iTreeData->Level(aItemId),
-                    iMarkIcon, iMenuIcon, 0);
+                    iMarkOnIcon, iMarkOffIcon, iMenuIcon, 0);
             }
         }
     }
@@ -2595,6 +2661,16 @@
     }
 
 // ---------------------------------------------------------------------------
+//  The function returns if marking mode is on or off
+// ---------------------------------------------------------------------------
+//
+TBool CFsTreeVisualizerBase::IsMarkingMode()
+    {
+    FUNC_LOG;
+    return iFlags.IsSet(EMarkingMode);
+    }
+
+// ---------------------------------------------------------------------------
 // Set the background texture, clears the background color.
 // ---------------------------------------------------------------------------
 //
@@ -2730,9 +2806,7 @@
             iWatermark
                     = CFsWatermark::NewL(*iOwnerControl, *iWatermarkLayout);
             }
-        // <cmail>
         iWatermark->SetWatermarkTextureL(*aTexture);
-        // </cmail>
         }
     else
         {
@@ -2844,8 +2918,8 @@
             if (!iWorld.IsUpdating())
                 {
                 iRootVisualizer->ShowL(*iRootLayout);
-                iRootVisualizer->UpdateL(*iRootData, EFalse, 0, iMarkIcon,
-                        iMenuIcon);
+                iRootVisualizer->UpdateL(*iRootData, EFalse, 0, iMarkOnIcon,
+                        iMarkOffIcon, iMenuIcon);
                 }
             iVisibleItems.Reset();
             iWorld.RemoveAllL();
@@ -2867,7 +2941,7 @@
                 {
                 visualizer->UpdateL(iTreeData->ItemData(itemId),
                         IsItemFocused(itemId), iTreeData->Level(itemId),
-                        iMarkIcon, iMenuIcon, 0);
+                        iMarkOnIcon, iMarkOffIcon, iMenuIcon, 0);
                 }
             }
             break;
@@ -2927,7 +3001,8 @@
     if (iTreeData->Count() == 0)
         {
         iRootVisualizer->ShowL(*iRootLayout);
-        iRootVisualizer->UpdateL(*iRootData, EFalse, 0, iMarkIcon, iMenuIcon);
+        iRootVisualizer->UpdateL(*iRootData, EFalse, 0, iMarkOnIcon, 
+                iMarkOffIcon, iMenuIcon);
         }
     else
         {
@@ -3263,20 +3338,16 @@
 
     if (iVisualizationState == EFsTreeVisible && iVisualizerObserver)
         {
-            // <cmail> Touch
-            TRAP_IGNORE(iVisualizerObserver->TreeVisualizerEventL(
+        TRAP_IGNORE(iVisualizerObserver->TreeVisualizerEventL(
                             MFsTreeVisualizerObserver::EFsTreeListVisualizerShown,
                             KFsTreeNoneID ));
-        // </cmail>
         }
 
     if (iVisualizationState == EFsTreeHidden && iVisualizerObserver)
         {
-            // <cmail> Touch
-            TRAP_IGNORE(iVisualizerObserver->TreeVisualizerEventL(
+        TRAP_IGNORE(iVisualizerObserver->TreeVisualizerEventL(
                             MFsTreeVisualizerObserver::EFsTreeListVisualizerHidden,
                             KFsTreeNoneID ));
-        // </cmail>
         }
     }
 
@@ -3325,8 +3396,7 @@
 
     if (iVisualizationState == EFsTreeVisible && iVisualizerObserver)
         {
-            // <cmail> Touch
-            TRAP_IGNORE(iVisualizerObserver->TreeVisualizerEventL(
+        TRAP_IGNORE(iVisualizerObserver->TreeVisualizerEventL(
                             MFsTreeVisualizerObserver::EFsTreeListVisualizerShown,
                             KFsTreeNoneID ));
 
@@ -3334,10 +3404,9 @@
 
     if (iVisualizationState == EFsTreeHidden && iVisualizerObserver)
         {
-            TRAP_IGNORE(iVisualizerObserver->TreeVisualizerEventL(
+        TRAP_IGNORE(iVisualizerObserver->TreeVisualizerEventL(
                             MFsTreeVisualizerObserver::EFsTreeListVisualizerHidden,
                             KFsTreeNoneID ));
-        // </cmail>
         }
     }
 
@@ -3793,7 +3862,8 @@
                 {
                 visualizer->UpdateL(iTreeData->ItemData(itemId),
 					IsItemFocused(itemId) && IsFocusShown(),
-                    iTreeData->Level(itemId), iMarkIcon, iMenuIcon, 0, EFalse);
+                    iTreeData->Level(itemId), iMarkOnIcon, iMarkOffIcon,
+                    iMenuIcon, 0, EFalse);
                 }
             }
         UpdateSelectorVisualL();
@@ -3863,9 +3933,6 @@
         border->SetLayer(EAlfBrushLayerBackground);
 
         border->SetBorders(-8, -8, -8, -8);
-        //<cmail>
-        // layout values needed here (not: only used from FS action menu)
-        //</cmail>
         iBorderLayout->SetPadding(TPoint(5, 5));
 
         if (iBorderLayout->Brushes()->Count() > 0)
@@ -4547,6 +4614,8 @@
     FUNC_LOG;
     //list can have all items in extended or in a normal state
     aItemVis->SetAlwaysExtended(IsItemsAlwaysExtended());
+    
+    aItemVis->SetMarkingMode(IsMarkingMode());
 
     //global indentation in pixels for a list component
     aItemVis->SetIndentation(iLevelIndentation);
@@ -4647,8 +4716,6 @@
     return isFocused;
     }
 
-// <cmail> "Base class modifications for using touch"
-
 // ---------------------------------------------------------------------------
 //  C++ constructor.
 // ---------------------------------------------------------------------------
@@ -4694,7 +4761,6 @@
     iFlags.Assign( EPopupMode, aPopUpMode );
     iFlags.Set( EExpandCollapseOnLongTap );
     }
-// </cmail>
 
 // ---------------------------------------------------------------------------
 //  Second phase constructor.
@@ -4953,8 +5019,8 @@
     											itemId);
     			visualizer->UpdateL(iTreeData->ItemData(itemId),
     							IsItemFocused(itemId) && IsFocusShown(),
-    							iTreeData->Level(itemId), iMarkIcon, iMenuIcon,
-    							0);
+    							iTreeData->Level(itemId), iMarkOnIcon, 
+    							iMarkOffIcon, iMenuIcon, 0);
     			}
     		}
     	CleanupStack::PopAndDestroy();
@@ -5010,7 +5076,7 @@
             visualizerLayout.SetSize(tpItemSize);
         	visualizer->UpdateL(iTreeData->ItemData(itemId),
                 IsItemFocused(itemId) && IsFocusShown(),
-                iTreeData->Level(itemId), iMarkIcon, iMenuIcon,
+                iTreeData->Level(itemId), iMarkOnIcon, iMarkOffIcon, iMenuIcon,
                 0);
             visualizerLayout.PropertySetIntegerL(KPropertyItemId(), itemId);
             visualizerLayout.Brushes()->AppendL(iBorderBrush,
@@ -5467,5 +5533,3 @@
     return ( iTouchPressed || iFocusVisible ) && iFlags.IsClear( EListPanning );
     }
 
-
-// </cmail>
--- a/ipsservices/ipssosplugin/inc/ipsplgmsgmapper.h	Tue Sep 14 20:48:24 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgmsgmapper.h	Wed Sep 15 11:52:37 2010 +0300
@@ -26,6 +26,7 @@
 class CFSMailMessagePart;
 class CFSMailAddress;
 class CIpsPlgSosBasePlugin;
+class CIpsPlgMsgMapperHelper;
 
 /**
  *  
@@ -385,9 +386,91 @@
     CMsvSession& iSession;
     
     CIpsPlgSosBasePlugin& iPlugin;
-    
+    // own
+    CIpsPlgMsgMapperHelper* iMsgMapperHelper;
     };
     
+
+/*
+ * ou1cimx1#508195
+ * CIpsPlgMsgMapperHelper class for asynchronous set the attachment flag
+ * It will process the async operation one by one.
+ * This class is mainly for resolve the crashes when sync mailbox. When there have
+ * more than 50 emails with attachments need to be synchronized, and the NewMailEvent
+ * will activate a update Mailbox process, it will set the attachment flag by using
+ * ChangeL, and use CActiveSchedulerWait to change the synchronous method to asynchronous
+ * this will block the current thread. And the ChangeL only accept less than 14
+ * requests at the same time, more than 14 requests will get the KErrServerBusy(-16)
+ * from the MTM server side. Therefore using the active object to set the attachment
+ * flag asynchronized.
+ */
+
+
+NONSHARABLE_CLASS ( CIpsPlgMsgMapperHelper ) : public CActive,
+                               public MIpsPlgSingleOpWatcher
+    {
+public: 
+    /*
+     * from MIpsPlgSingleOpWatcher
+     * OpCompleted is called when operation is completed
+     */
+    void OpCompleted(
+        CIpsPlgSingleOpWatcher& aOpWatcher,
+        TInt aCompletionCode );
+        
+public:
+    /*
+     * Symbian 2nd phase construcror
+     */
+    static CIpsPlgMsgMapperHelper* NewL( CMsvSession& aSession );
+    /*
+     * Class destructor
+     */
+    ~CIpsPlgMsgMapperHelper();
+    
+public:
+    /*
+     * start the async process 
+     */
+    void StartSetAttchmentFlag();
+    
+    /*
+     * append entry's id to array
+     * @param TMsvId aId
+     * @return ETrue append success, EFalse if exist in array
+     */
+    TBool AppendMsvIdToArrayL( TMsvId aId );
+        
+    
+protected:// From base class CActive
+
+    void RunL();
+    void DoCancel();
+    TInt RunError(TInt aError);
+    
+private:
+    /*
+     * Class constructor
+     */
+    CIpsPlgMsgMapperHelper( CMsvSession& aSession );
+    /*
+     * Symbian 2nd phase construct
+     */
+    void ConstructL();
+
+private:
+    // reference to Msv Session
+    CMsvSession&    iSession;
+    // Whether or not a set flag process is pending
+    TBool   iPending;
+    // own
+    CIpsPlgSingleOpWatcher* iCurrentOperationWatcher;
+    // own
+    RArray<TMsvId>  iNeedSetAttachFlagArray;
+    // own
+    RTimer  iTimer;
+    };
+
 #include "ipsplgmsgmapper.inl"    
 
 #endif /* IPSPLGMSGMAPPER_H */
--- a/ipsservices/ipssosplugin/src/ipsplgmrulist.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgmrulist.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -246,7 +246,7 @@
             TInt start( emailAddress.LocateReverse( KIpsSmtpOperationCharLessThan ) ); 
             TInt end( emailAddress.LocateReverse( KIpsSmtpOperationCharMoreThan ) );
             
-            if ( KErrNotFound != start && KErrNotFound != end )
+            if ( KErrNotFound != start && KErrNotFound != end && start < end )
                 {
                 start += 1;
                 emailAddress.Set( aNewMruList->MdcaPoint(i + 1).Mid( start, ( end - start ) ) );
--- a/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -86,6 +86,11 @@
 CIpsPlgMsgMapper::~CIpsPlgMsgMapper()
     {
     FUNC_LOG;
+    if( iMsgMapperHelper )
+        {
+        delete iMsgMapperHelper;
+        iMsgMapperHelper = NULL;
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -107,6 +112,8 @@
 void CIpsPlgMsgMapper::ConstructL()
     {
     FUNC_LOG;
+	
+    iMsgMapperHelper = CIpsPlgMsgMapperHelper::NewL( iSession );
     }
 
 // ---------------------------------------------------------------------------
@@ -852,12 +859,14 @@
         if ( hasStore )
             {
             CMsvStore* store = cEntry->EditStoreL();
-    
             CleanupStack::PushL( store );
 
+            // For some reason, the attachment manager returns zero attachment
+            // count with pop3 protocol, when the email contains another email
+            // as an attachment. As a workaround, the attachment is set
+            // fetched with pop3 protocol.
             MMsvAttachmentManager& attMgr = store->AttachmentManagerL();
-        
-            if ( attMgr.AttachmentCount() )
+            if ( aEntry.iMtm == KSenduiMtmPop3Uid || attMgr.AttachmentCount() )
                 {
                 aMessage.SetMessagePartsStatus( EFSFull );
                 }
@@ -865,10 +874,9 @@
                 {
                 aMessage.SetMessagePartsStatus( EFSNone );
                 }
-            
+
             CleanupStack::PopAndDestroy( store );
             }
-
         CleanupStack::PopAndDestroy( cEntry );
         }
     else if ( aEntry.Id() != aMsgMainId )
@@ -1506,7 +1514,11 @@
         aMsg.SetFlag( EFSMsgFlag_Attachments );
         if ( !aEntry.Attachment() )
         	{
-        	SetAttachmentFlagL( aEntry, ETrue );
+            TBool success = iMsgMapperHelper->AppendMsvIdToArrayL( aEntry.Id() );
+            if( success )
+                {
+                iMsgMapperHelper->StartSetAttchmentFlag();
+                }
         	}
         }
 
@@ -1595,3 +1607,235 @@
     CleanupStack::PopAndDestroy( cEntry );
     }
 // </cmail>
+
+
+// ---------------------------------------------------------------------------
+// CIpsPlgMsgMapperHelper::OpCompleted
+// ---------------------------------------------------------------------------
+//
+void CIpsPlgMsgMapperHelper::OpCompleted(
+    CIpsPlgSingleOpWatcher& aOpWatcher,
+    TInt aCompletionCode )
+    {
+    FUNC_LOG;
+    
+    TInt opId = aOpWatcher.Operation().Id();
+    TMsvId completedMsvId = aOpWatcher.Operation().Service();
+    
+    if( iCurrentOperationWatcher )
+        {
+        CMsvOperation& oper = iCurrentOperationWatcher->Operation();
+        
+        //delete the iOngoingOperation when it has completed
+        if( oper.Id() == opId )
+            {
+            delete iCurrentOperationWatcher;
+            iCurrentOperationWatcher = NULL;
+            }
+        }
+    
+    //remove the completed MsvId from the iNeedSetAttachFlagArray
+    for( TInt j = 0; j < iNeedSetAttachFlagArray.Count(); ++j )
+        {
+        if( completedMsvId == iNeedSetAttachFlagArray[j] )
+            {
+            iNeedSetAttachFlagArray.Remove( j );
+            break;
+            }
+        }
+    //start next async process
+    iTimer.After( iStatus, 0 );
+    SetActive();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CIpsPlgMsgMapperHelper::NewL
+// ---------------------------------------------------------------------------
+//
+CIpsPlgMsgMapperHelper* CIpsPlgMsgMapperHelper::NewL( CMsvSession& aSession )
+    {
+    FUNC_LOG;
+    
+    CIpsPlgMsgMapperHelper* self = new (ELeave) CIpsPlgMsgMapperHelper( aSession );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CIpsPlgMsgMapperHelper::~CIpsPlgMsgMapperHelper
+// ---------------------------------------------------------------------------
+//
+CIpsPlgMsgMapperHelper::~CIpsPlgMsgMapperHelper()
+    {
+    FUNC_LOG;
+    
+    Cancel();
+    //should delete the iOngoingOperation if it not completed 
+    if( iCurrentOperationWatcher )
+        {
+        delete iCurrentOperationWatcher;
+        iCurrentOperationWatcher = NULL;
+        }
+    iNeedSetAttachFlagArray.Reset();
+    iNeedSetAttachFlagArray.Close();
+    
+    Deque();
+    iTimer.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// CIpsPlgMsgMapperHelper::CIpsPlgMsgMapperHelper
+// ---------------------------------------------------------------------------
+//
+CIpsPlgMsgMapperHelper::CIpsPlgMsgMapperHelper( CMsvSession& aSession )
+:CActive( EPriorityStandard ), iSession( aSession ), iPending( EFalse ),
+iCurrentOperationWatcher( NULL )
+    {
+    FUNC_LOG;
+    }
+
+// ---------------------------------------------------------------------------
+// CIpsPlgMsgMapperHelper::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CIpsPlgMsgMapperHelper::ConstructL()
+    {
+    FUNC_LOG;
+    
+    User::LeaveIfError( iTimer.CreateLocal() );
+    CActiveScheduler::Add(this);
+    }
+
+// inherited from CActive
+// ---------------------------------------------------------------------------
+// CIpsPlgMsgMapperHelper::RunL
+// ---------------------------------------------------------------------------
+//
+void CIpsPlgMsgMapperHelper::RunL()
+    {
+    FUNC_LOG;
+
+    User::LeaveIfError( iStatus.Int() );
+    // always start the async process from the index 0 of iNeedSetAttachFlagArray
+    TInt currentIndex = 0;
+    
+    if( iNeedSetAttachFlagArray.Count() > 0 )
+        {
+        TMsvId entry = iNeedSetAttachFlagArray[currentIndex];
+        TMsvId serviceId;
+        TMsvEmailEntry entryToBeChanged;
+        //get enty by msvid
+        TBool result = iSession.GetEntry( entry, serviceId, entryToBeChanged);
+        
+        if( entryToBeChanged.Attachment() )
+            {
+            // ignore this operation and delete when it has set the attach flag
+            iNeedSetAttachFlagArray.Remove( currentIndex );
+            iTimer.After( iStatus, 0 );
+            SetActive();
+            return;
+            }
+        
+        CIpsPlgSingleOpWatcher* opW = CIpsPlgSingleOpWatcher::NewLC( *this );
+        
+        CMsvEntry* cEntry = iSession.GetEntryL( entry );
+        CleanupStack::PushL( cEntry );
+        
+        entryToBeChanged.SetAttachment( ETrue );
+        CMsvOperation* ops = cEntry->ChangeL( entryToBeChanged, opW->iStatus );
+        CleanupStack::PopAndDestroy( cEntry );
+        
+        if( ops )
+            {
+            opW->SetOperation( ops );
+            if( iCurrentOperationWatcher )
+                {
+                delete iCurrentOperationWatcher;
+                iCurrentOperationWatcher = NULL;
+                }
+            iCurrentOperationWatcher = opW;
+            CleanupStack::Pop( opW );
+            }
+        else
+            {
+            CleanupStack::PopAndDestroy( opW ); 
+            }
+        }
+    else
+        {
+        //all these operation have processed
+        iPending = EFalse;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CIpsPlgMsgMapperHelper::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CIpsPlgMsgMapperHelper::RunError( TInt aError )
+    {
+    FUNC_LOG;
+
+    if ( KErrNone != aError )
+        {
+        Cancel();
+        }
+    return KErrNone;
+    }
+
+void CIpsPlgMsgMapperHelper::DoCancel()
+    {
+    FUNC_LOG;
+    if( iCurrentOperationWatcher )
+        {
+        iCurrentOperationWatcher->Cancel();
+        delete iCurrentOperationWatcher;
+        iCurrentOperationWatcher = NULL;
+        }
+    iTimer.Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CIpsPlgMsgMapperHelper::StartSetAttchmentFlag
+// ---------------------------------------------------------------------------
+//
+void CIpsPlgMsgMapperHelper::StartSetAttchmentFlag()
+    {    
+    FUNC_LOG;
+    //should start the ao when not in pending status
+    if( !IsActive() && !iPending )
+        {
+        iTimer.After( iStatus, 0 );
+        SetActive();
+        iPending = ETrue;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CIpsPlgMsgMapperHelper::AppendToArrayL
+// ---------------------------------------------------------------------------
+//
+TBool CIpsPlgMsgMapperHelper::AppendMsvIdToArrayL( TMsvId aId )
+    {
+    FUNC_LOG;
+
+    TInt count = iNeedSetAttachFlagArray.Count();
+    //check the MsvId if already exist in iNeedSetAttachFlagArray
+    for( TInt i = 0; i < count; ++i )
+        {
+        TMsvId id = iNeedSetAttachFlagArray[i];
+        if( id == aId )
+            {
+            return EFalse;
+            }
+        }
+    
+    iNeedSetAttachFlagArray.AppendL( aId );
+    return ETrue;
+    }
+
+
+
--- a/ipsservices/ipssosplugin/src/ipsplgsmtpoperation.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgsmtpoperation.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -435,7 +435,7 @@
         // is display name with special characters
         TInt start( fullName.LocateReverse( KIpsSmtpOperationCharLessThan ) ); 
         TInt end( fullName.LocateReverse( KIpsSmtpOperationCharMoreThan ) );
-        if ( KErrNotFound != start && KErrNotFound != end )
+        if ( KErrNotFound != start && KErrNotFound != end && start < end )
             {
             start += 1;
             fullName.Set( aRecipients[i].Mid( start, ( end - start ) ) );
--- a/ipsservices/ipssossettings/data/ipssetuimailsettings.ra	Tue Sep 14 20:48:24 2010 +0300
+++ b/ipsservices/ipssossettings/data/ipssetuimailsettings.ra	Wed Sep 15 11:52:37 2010 +0300
@@ -566,7 +566,7 @@
             {
             itemtype = EIpsSetUiItemRadioButton;
             itemid = EIpsSetUiUserAuthenticationBtnOwnForOutgoing;
-            itemlabel = qtn_fse_settings_outgoing_setting;
+            itemlabel = qtn_fse_settings_outgoing_user_authentication;
             }
         };
     }
--- a/ipsservices/ipssossettings/loc/ipssossettings.loc	Tue Sep 14 20:48:24 2010 +0300
+++ b/ipsservices/ipssossettings/loc/ipssossettings.loc	Wed Sep 15 11:52:37 2010 +0300
@@ -307,6 +307,13 @@
 //
 #define qtn_fse_settings_outgoing_no_server "No user authentication"
 
+
+// d:Radio button item in user authentication for outgoing mails selection list
+// l:list_set_graphic_pane_t1
+// r:TB9.1
+//
+#define qtn_fse_settings_outgoing_user_authentication "User authentication"
+
 // d:Setting item in Outgoing Email Settings view
 // l:list_setting_pane_t1
 // r:TB9.1
--- a/ipsservices/ipssossettings/src/ipssetdata.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/ipsservices/ipssossettings/src/ipssetdata.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -179,6 +179,22 @@
     TMsvEntry mbox = IpsSetUtils::GetMailboxEntryL( aSession, aMailboxId );
     manager->LoadEmailSettingsL( mbox, *this );
     
+    // Update signature if needed
+    HBufC* body = NULL;
+    body = HBufC::NewL( iSignature->iRichText->DocumentLength() );
+    CleanupStack::PushL( body );
+    TPtr ptr = body->Des();
+    iSignature->iRichText->Extract( ptr );
+    TInt len = ptr.Length();
+    ptr.TrimLeft();
+    len-= ptr.Length();
+    if( len )
+        {
+        // Remove leading empty line from signature
+        iSignature->iRichText->DeleteL( 0, len );
+        }
+    CleanupStack::PopAndDestroy( body );
+    
     CleanupStack::PopAndDestroy( manager );
     manager = NULL;
     }
@@ -523,11 +539,11 @@
     ret.iIAP = 0;
     if ( aIncoming )
         {
-		if (iIncomingIapPref->SNAPDefined())
-			{
-			ret.iIAP = iIncomingIapPref->SNAPPreference();
-			}
-			
+        if (iIncomingIapPref->SNAPDefined())
+            {
+            ret.iIAP = iIncomingIapPref->SNAPPreference();
+            }
+            
         if ( iIncomingIapPref->NumberOfIAPs() > 0 )
             {
             ret = iIncomingIapPref->IAPPreference(0);
@@ -826,7 +842,29 @@
     {
     FUNC_LOG;
     iSignature->iRichText->Reset();
-    iSignature->iRichText->InsertL( 0, aSignature );
+    
+    if ( aSignature.Length() )
+        {
+        TChar firstChar = aSignature[0];
+        _LIT( KNewLines, "\r\n\x2028\x2029" );
+        _LIT( KIMSLineFeed, "\r\n");
+        if ( KNewLines().Locate( firstChar ) == KErrNotFound )
+            {
+            // First character is not a new line character. Insert one.
+            HBufC* body = NULL;
+            body = HBufC::NewL( aSignature.Length() + KIMSLineFeed().Length() );
+            CleanupStack::PushL( body );
+            TPtr ptr = body->Des();
+            ptr.Append( KIMSLineFeed );
+            ptr.Append( aSignature );
+            iSignature->iRichText->InsertL( 0, ptr );
+            CleanupStack::PopAndDestroy( body );
+            }
+        else
+            {
+            iSignature->iRichText->InsertL( 0, aSignature );
+            }
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -945,18 +983,18 @@
     CleanupStack::Pop( iOutgoingIapPref );
         
     if (aIncomingIap.SNAPDefined())
-    	{
-		iIncomingIapPref->SetSNAPL(aIncomingIap.SNAPPreference());
-    	}
+        {
+        iIncomingIapPref->SetSNAPL(aIncomingIap.SNAPPreference());
+        }
     else
-    	{
-    	iIncomingIapPref->AddIAPL( aIncomingIap.IAPPreference(0) );
-    	}
+        {
+        iIncomingIapPref->AddIAPL( aIncomingIap.IAPPreference(0) );
+        }
         
     if (aOutgoingIap.SNAPDefined())
-      	{
-    	iOutgoingIapPref->SetSNAPL(aOutgoingIap.SNAPPreference());
-       	}
+        {
+        iOutgoingIapPref->SetSNAPL(aOutgoingIap.SNAPPreference());
+        }
     else
     	{
     	iOutgoingIapPref->AddIAPL( aOutgoingIap.IAPPreference(0) );
@@ -1110,12 +1148,12 @@
         }
    //<cmail>
     else if ( iProtocol == KSenduiMtmPop3Uid && aDownloadControl == CIpsSetData::EHeadersPlus )
-    	{
-    	// fix for POP that has only 2 radio (IMAP has 3) 
-    	// and the second should have value of EWholeBody instead of EHeadersPlus 
-    	size = KIpsSetDataFullBodyAndAttas; 
-    	}
-    //</cmail>	
+        {
+        // fix for POP that has only 2 radio (IMAP has 3) 
+        // and the second should have value of EWholeBody instead of EHeadersPlus 
+        size = KIpsSetDataFullBodyAndAttas; 
+        }
+    //</cmail>
     else
         {
         size = aDownloadSize;
--- a/ipsservices/tsrc/profiletester/src/popimapprofiletester.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/ipsservices/tsrc/profiletester/src/popimapprofiletester.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -2,7 +2,7 @@
  *  Name        :  popimapprofiletester.cpp
  *  Part of     :  ipsservices / ipsprofiletester 
  *  Description :: STIF test cases
- *  Version     : %version: 1 % << Don't touch! Updated by Synergy at check-out.
+ *  Version     : %version: 2 % << Don't touch! Updated by Synergy at check-out.
  *
  *  Copyright © 2010-2010 Nokia and/or its subsidiary(-ies).  All rights reserved.
  *  This material, including documentation and any related computer
@@ -49,7 +49,7 @@
 _LIT(KDraftsType,"drafts");
 _LIT(KSentType,"sent");
 // Logging path
-_LIT( KpopimapprofiletesterLogPath, "\\logs\\testframework\\popimapprofiletester\\" );
+_LIT( KpopimapprofiletesterLogPath, "\\logs\\testframework\\" );
 // Log file
 _LIT( KpopimapprofiletesterLogFile, "popimapprofiletester.txt" );
 _LIT( KpopimapprofiletesterLogFileWithTitle, "popimapprofiletester_[%S].txt" );
--- a/meetingrequest/mricalviewer/src/cesmrmrinfoicalretriever.cpp	Tue Sep 14 20:48:24 2010 +0300
+++ b/meetingrequest/mricalviewer/src/cesmrmrinfoicalretriever.cpp	Wed Sep 15 11:52:37 2010 +0300
@@ -605,6 +605,22 @@
         {
         iConvertedEntry->SetPriorityL( iMRInfoObject->PriorityL() );
         }
+    
+    if ( IsFieldSupported( iSupportedFields, MMRInfoObject::EESMRInfoFieldPrivacy ) )
+        {
+        if( iMRInfoObject->PrivacyL() == MMRInfoObject::EMRSensitivityPrivate )
+            {
+            iConvertedEntry->SetReplicationStatusL( CCalEntry::EPrivate );
+            }
+        else if( iMRInfoObject->PrivacyL() == MMRInfoObject::EMRSensitivityConfidential )
+            {
+            iConvertedEntry->SetReplicationStatusL( CCalEntry::ERestricted );
+            }
+        else
+            {
+            iConvertedEntry->SetReplicationStatusL( CCalEntry::EOpen );
+            }
+        }
     }
 
 // ---------------------------------------------------------------------------