Revision: 201001
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 18 Jan 2010 20:08:26 +0200
changeset 2 5253a20d2a1e
parent 1 12c456ceeff2
child 3 a4d6f1ea0416
Revision: 201001 Kit: 201003
emailservices/emailclientapi/inc/emailmessagesearch.h
emailservices/emailclientapi/src/emailmessagesearch.cpp
emailservices/emailframework/inc/MFSMailBoxSearchObserver.h
emailservices/emailserver/cmailhandlerplugin/inc/cmailcpshandler.h
emailservices/emailserver/cmailhandlerplugin/inc/cmailcpsifconsts.h
emailservices/emailserver/cmailhandlerplugin/inc/cmailcpssettings.h
emailservices/emailserver/cmailhandlerplugin/inc/cmailwidgetcenrepkeysinternal.h
emailservices/emailserver/cmailhandlerplugin/src/cmailcpshandler.cpp
emailservices/emailserver/cmailhandlerplugin/src/cmailcpsif.cpp
emailservices/emailserver/cmailhandlerplugin/src/cmailcpssettings.cpp
emailservices/emailstore/base_plugin/src/BaseMrInfoObject.cpp
emailuis/emailui/data/FreestyleEmailUi.rss
emailuis/emailui/data/html/email.html
emailuis/emailui/data/html/email_rtl.html
emailuis/emailui/data/html/follow_up.png
emailuis/emailui/data/html/follow_up_complete.png
emailuis/emailui/data/html/header.js
emailuis/emailui/data/html/todo_high_add.png
emailuis/emailui/data/html/todo_low_add.png
emailuis/emailui/data/iconlist.txt
emailuis/emailui/group/FreestyleEmailUi.mmp
emailuis/emailui/group/bld.inf
emailuis/emailui/inc/FSHtmlReloadAO.h
emailuis/emailui/inc/FreestyleEmailDownloadInformationMediator.h
emailuis/emailui/inc/FreestyleEmailUi.hrh
emailuis/emailui/inc/FreestyleEmailUiAttachmentsListVisualiser.h
emailuis/emailui/inc/FreestyleEmailUiContactHandler.h
emailuis/emailui/inc/FreestyleEmailUiFolderListVisualiser.h
emailuis/emailui/inc/FreestyleEmailUiHtmlViewerContainer.h
emailuis/emailui/inc/FreestyleEmailUiHtmlViewerView.h
emailuis/emailui/inc/FreestyleEmailUiMailListVisualiser.h
emailuis/emailui/inc/FreestyleEmailUiMsgDetailsVisualiser.h
emailuis/emailui/inc/FreestyleEmailUiSearchListVisualiser.h
emailuis/emailui/inc/FreestyleEmailUiSendAttachmentsListModel.h
emailuis/emailui/inc/FreestyleEmailUiSettingsList.h
emailuis/emailui/inc/FreestyleEmailUiSettingsListView.h
emailuis/emailui/inc/FreestyleEmailUiViewBase.h
emailuis/emailui/inc/FreestyleMessageHeaderHTML.h
emailuis/emailui/inc/FreestyleMessageHeaderURL.h
emailuis/emailui/inc/FreestyleMessageHeaderURLEventHandler.h
emailuis/emailui/inc/OverlayControl.h
emailuis/emailui/inc/ceuiemaillisttouchmanager.h
emailuis/emailui/inc/freestyleemailuimailboxdeleter.h
emailuis/emailui/inc/ncsattachmentfield.h
emailuis/emailui/inc/ncscomposeview.h
emailuis/emailui/inc/ncscomposeviewcontainer.h
emailuis/emailui/inc/ncsconstants.h
emailuis/emailui/inc/ncscontrol.h
emailuis/emailui/inc/ncsheadercontainer.h
emailuis/emailui/inc/ncsutility.h
emailuis/emailui/loc/freestyleemailui.loc
emailuis/emailui/rom/freestyleemailui.iby
emailuis/emailui/sis/commonemail.pkg
emailuis/emailui/sis/commonemail_loc.pkg
emailuis/emailui/sis/commonemail_udeb.pkg
emailuis/emailui/sis/commonemail_udeb_loc.pkg
emailuis/emailui/sis/commonemailstub.pkg
emailuis/emailui/sis/emailui.pkg
emailuis/emailui/sis/emailui_udeb.pkg
emailuis/emailui/src/FSComposerFetchLogic.cpp
emailuis/emailui/src/FSHtmlReloadAO.cpp
emailuis/emailui/src/FreestyleEmailDownloadInformationMediator.cpp
emailuis/emailui/src/FreestyleEmailUiAppui.cpp
emailuis/emailui/src/FreestyleEmailUiAttachmentsListVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiContactHandler.cpp
emailuis/emailui/src/FreestyleEmailUiFolderListVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiHtmlViewerContainer.cpp
emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp
emailuis/emailui/src/FreestyleEmailUiLauncherGrid.cpp
emailuis/emailui/src/FreestyleEmailUiLauncherGridVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiMsgDetailsVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiSearchListVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiSendAttachmentsListModel.cpp
emailuis/emailui/src/FreestyleEmailUiSettingsList.cpp
emailuis/emailui/src/FreestyleEmailUiSettingsListView.cpp
emailuis/emailui/src/FreestyleEmailUiViewBase.cpp
emailuis/emailui/src/FreestyleMessageHeaderHTML.cpp
emailuis/emailui/src/FreestyleMessageHeaderURLEventHandler.cpp
emailuis/emailui/src/OverlayControl.cpp
emailuis/emailui/src/ceuiemaillisttouchmanager.cpp
emailuis/emailui/src/freestyleemailuimailboxdeleter.cpp
emailuis/emailui/src/ncsattachmentfield.cpp
emailuis/emailui/src/ncscomposeview.cpp
emailuis/emailui/src/ncscomposeviewcontainer.cpp
emailuis/emailui/src/ncscontrol.cpp
emailuis/emailui/src/ncseditor.cpp
emailuis/emailui/src/ncsheadercontainer.cpp
emailuis/emailui/src/ncspopuplistbox.cpp
emailuis/emailui/src/ncsutility.cpp
emailuis/uicomponents/bwins/fs_generic_alfu.def
emailuis/uicomponents/eabi/fs_generic_alfU.def
emailuis/uicomponents/inc/fsactionmenu.h
emailuis/uicomponents/inc/fscontrolbar.h
emailuis/uicomponents/inc/fscontrolbarmodel.h
emailuis/uicomponents/inc/fstreelist.h
emailuis/uicomponents/inc/fstreelistobserver.h
emailuis/uicomponents/inc/fstreevisualizerbase.h
emailuis/uicomponents/inc/fstreevisualizerobserver.h
emailuis/uicomponents/src/fsactionmenu.cpp
emailuis/uicomponents/src/fscontrolbar.cpp
emailuis/uicomponents/src/fscontrolbarmodel.cpp
emailuis/uicomponents/src/fstreelist.cpp
emailuis/uicomponents/src/fstreevisualizerbase.cpp
emailuis/widget/emailwidgetsettings/conf/cmailwidget.confml
emailuis/widget/emailwidgetsettings/conf/cmailwidget_2001E272.crml
emailuis/widget/hsps/00/emailwidgetconfiguration.dtd
emailuis/widget/hsps/00/manifest.dat
emailuis/widget/xuikon/00/emailwidget.css
emailuis/widget/xuikon/00/emailwidget.xml
help/inc/cmail.hlp.hrh
ipsservices/ipssosplugin/inc/ipsplgsearch.h
ipsservices/ipssosplugin/inc/ipsplgsearchop.h
ipsservices/ipssosplugin/src/ipsplgsearch.cpp
ipsservices/ipssosplugin/src/ipsplgsearchop.cpp
ipsservices/ipssossettings/tsrc/IpsSosTestApp/data/IpsSosTestApp.rss
ipsservices/ipssossettings/tsrc/IpsSosTestApp/data/IpsSosTestApp_reg.rss
ipsservices/ipssossettings/tsrc/IpsSosTestApp/data/ipssostest.ini
ipsservices/ipssossettings/tsrc/IpsSosTestApp/group/bld.inf
ipsservices/ipssossettings/tsrc/IpsSosTestApp/group/ipssostestapp.mmp
ipsservices/ipssossettings/tsrc/IpsSosTestApp/inc/TESTAPPApp.h
ipsservices/ipssossettings/tsrc/IpsSosTestApp/inc/TESTAPPAppUi.h
ipsservices/ipssossettings/tsrc/IpsSosTestApp/inc/TESTAPPContainer.h
ipsservices/ipssossettings/tsrc/IpsSosTestApp/inc/TESTAPPDocument.h
ipsservices/ipssossettings/tsrc/IpsSosTestApp/inc/ipssostestapp.loc
ipsservices/ipssossettings/tsrc/IpsSosTestApp/inc/testapp.hrh
ipsservices/ipssossettings/tsrc/IpsSosTestApp/install/ipssostestapp.pkg
ipsservices/ipssossettings/tsrc/IpsSosTestApp/src/TESTAPPApp.cpp
ipsservices/ipssossettings/tsrc/IpsSosTestApp/src/TESTAPPAppUi.cpp
ipsservices/ipssossettings/tsrc/IpsSosTestApp/src/TESTAPPContainer.cpp
ipsservices/ipssossettings/tsrc/IpsSosTestApp/src/TESTAPPDocument.cpp
--- a/emailservices/emailclientapi/inc/emailmessagesearch.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailservices/emailclientapi/inc/emailmessagesearch.h	Mon Jan 18 20:08:26 2010 +0200
@@ -121,6 +121,14 @@
      *
      */
      virtual void SearchCompletedL();
+
+//
+    /**
+    * Asks client if search engine should change search priority 
+  	*/
+    virtual void ClientRequiredSearchPriority(TInt *apRequiredSearchPriority); 
+//
+
     
 private:
     /**
--- a/emailservices/emailclientapi/src/emailmessagesearch.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailservices/emailclientapi/src/emailmessagesearch.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -354,3 +354,13 @@
     // Search is now complete, release gate.
     iGate.Signal();
 }
+
+//
+    /**
+    * Asks client if search engine should change search priority 
+  	*/
+void CEmailMessageSearchAsync::ClientRequiredSearchPriority(TInt *apRequiredSearchPriority)
+    {
+    return;
+    } 
+//
--- a/emailservices/emailframework/inc/MFSMailBoxSearchObserver.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailservices/emailframework/inc/MFSMailBoxSearchObserver.h	Mon Jan 18 20:08:26 2010 +0200
@@ -49,6 +49,13 @@
 	*/
     virtual void SearchCompletedL() = 0;
       
+//</cmail>
+    /**
+    * server asks client if to change the search priority (i.e. when calling to contact) 
+ 	*
+ 	*/
+    virtual void ClientRequiredSearchPriority(TInt *apRequiredSearchPriority) = 0; 
+//</cmail>
     };
 
 #endif  // MFSMAILBOXSEARCHOBSERVER_H
--- a/emailservices/emailserver/cmailhandlerplugin/inc/cmailcpshandler.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/inc/cmailcpshandler.h	Mon Jan 18 20:08:26 2010 +0200
@@ -93,13 +93,18 @@
     /**
      *
      */		
-    void DissociateWidgetFromSetting( const TDesC& aContentId );    
+    void DissociateWidgetFromSettingL( const TDesC& aContentId );    
 
     /**
      *
      */     
     TInt GetMailboxCount();    
 
+    /**
+     *
+     */    
+    void ManualAccountSelectionL( const TDesC& aContentId );
+    
 protected:
     /**
      * From CFSNotificationHandlerBase
@@ -327,7 +332,12 @@
      * @return ETrue if duplicate, EFalse if new message
      */
     TBool IsDuplicate( const CMailMailboxDetails& aMailbox, const TFSMailMsgId& aMsgId );
-
+    
+    /**
+     *
+     */
+    TBool FirstBootL();
+    
 private: // data
     CEikonEnv* iEnv;
     // pointer to liw wrapper that handles actual publishing
--- a/emailservices/emailserver/cmailhandlerplugin/inc/cmailcpsifconsts.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/inc/cmailcpsifconsts.h	Mon Jan 18 20:08:26 2010 +0200
@@ -41,6 +41,9 @@
 _LIT( KResourceFile, "\\resource\\apps\\emailwidget.rsc" );
 _LIT( KDissociated,"0");
 
+_LIT(KStartSeparator, "<");
+_LIT(KEndSeparator, ">");
+
 //
 // EMAIL WIDGET SPECIFIC CONSTANTS USED IN PUBLISHING
 //
--- a/emailservices/emailserver/cmailhandlerplugin/inc/cmailcpssettings.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/inc/cmailcpssettings.h	Mon Jan 18 20:08:26 2010 +0200
@@ -121,12 +121,12 @@
     /**
      * 
      */
-    void DissociateWidgetFromSetting( const TDesC& aContentId );
+    void DissociateWidgetFromSettingL( const TDesC& aContentId );
 
     /**
      * 
      */
-    TInt GetContentId( TInt aMailboxId, TInt aId, TDes16& aValue );
+    void GetContentId( TInt aMailboxId, TInt aNext, TDes16& aValue );
     
     /**
      * 
@@ -151,9 +151,24 @@
 
     /**
      * 
-     */    
+     */
     TInt GetTotalMailboxCount();
+
+    /**
+     * 
+     */
+    TBool FindFromContentIdListL( const TDesC& aContentId );
+
+    /**
+     * 
+     */
+    void AddToContentIdListL( const TDesC& aContentId );
     
+    /**
+     * 
+     */    
+    void RemoveFromContentIdListL( const TDesC& aContentId );
+
 protected:
     /**
      * From CActive
--- a/emailservices/emailserver/cmailhandlerplugin/inc/cmailwidgetcenrepkeysinternal.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/inc/cmailwidgetcenrepkeysinternal.h	Mon Jan 18 20:08:26 2010 +0200
@@ -26,6 +26,9 @@
 // (see also constants below)
 const TUint32 KCmailCPConfiguration = 0x10000001;
 
+// Key to store content ids of added email widgets
+const TUint32 KCMailContentIdList = 0x10000002;
+
 // 1st bit: whether email content publisher listens to commands/events sent by Homescreen framework
 //     value == 0: default behaviour, events are handled as normal
 //     value != 0: publisher ignores HS events
--- a/emailservices/emailserver/cmailhandlerplugin/src/cmailcpshandler.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/src/cmailcpshandler.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -21,6 +21,8 @@
 #include <emailwidget.rsg>
 #include <AknUtils.h>
 #include <apgcli.h>
+#include <centralrepository.h>
+#include <starterdomaincrkeys.h>
 
 #include "emailtrace.h"
 #include "CFSMailClient.h"
@@ -136,24 +138,25 @@
         else
             {
             CleanupStack::PushL( mailbox );
-            TInt id(1);
-            while (id)
-                {
-                CMailMailboxDetails* mailboxDetails = CreateMailboxDetailsL( *mailbox );
-                CleanupStack::PushL( mailboxDetails );
+            CMailMailboxDetails* mailboxDetails = CreateMailboxDetailsL( *mailbox );
+            CleanupStack::PushL( mailboxDetails );
             
-                if (id > 1)
+            TBuf<KMaxDescLen> cid;
+            TInt next(1);
+
+            // Check if same mailbox is already in iAccountsArray once or more
+            for ( TInt i = 0; i < iAccountsArray.Count(); i++ )
+                {               
+                TInt id = (TInt)iAccountsArray[i]->iMailboxId.Id();
+                if (id == mailboxId)
                     {
-                    iiMax = iiMax - 1;
+                    next++;
                     }
-                TBuf<KMaxDescLen> cid;
-                id = iSettings->GetContentId(mailboxId, id, cid);
-                mailboxDetails->SetWidgetInstance(cid);
-                iAccountsArray.AppendL( mailboxDetails );
-    
-                CleanupStack::Pop( mailboxDetails );                
                 }
-            
+            iSettings->GetContentId(mailboxId, next, cid);          
+            mailboxDetails->SetWidgetInstance(cid);
+            iAccountsArray.AppendL( mailboxDetails );
+            CleanupStack::Pop( mailboxDetails );                            
             CleanupStack::PopAndDestroy( mailbox );            
             }
         }
@@ -339,6 +342,7 @@
             CFSMailFolder* folder = MailClient().GetFolderByUidL( mailBoxId, parentFolder );
             if ( !folder )
                 {
+				UpdateEmptyMessagesL( aWidgetInstance, aRow );
                 return;
                 }
             CleanupStack::PushL( folder );
@@ -1612,10 +1616,10 @@
 // CMailCpsHandler::DissociateWidget
 // ---------------------------------------------------------------------------
 //
-void CMailCpsHandler::DissociateWidgetFromSetting( const TDesC& aContentId )
+void CMailCpsHandler::DissociateWidgetFromSettingL( const TDesC& aContentId )
     {
     FUNC_LOG;
-    iSettings->DissociateWidgetFromSetting( aContentId );
+    iSettings->DissociateWidgetFromSettingL( aContentId );
     }
 
 // ---------------------------------------------------------------------------
@@ -1627,3 +1631,62 @@
     FUNC_LOG;
     return iSettings->GetTotalMailboxCount();
     }
+
+// ---------------------------------------------------------------------------
+// CMailCpsHandler::ManualAccountSelectionL
+// ---------------------------------------------------------------------------
+//
+void CMailCpsHandler::ManualAccountSelectionL( const TDesC& aContentId )
+    {
+    FUNC_LOG;
+
+    if ( FirstBootL() )
+        {
+        if (!iSettings->FindFromContentIdListL(aContentId))
+            {
+            iSettings->AddToContentIdListL(aContentId);
+            }
+        }
+    else
+        {
+        if (!iSettings->FindFromContentIdListL(aContentId))
+            {
+            iSettings->AddToContentIdListL(aContentId);
+            if (GetMailboxCount())
+                {
+                LaunchWidgetSettingsL(aContentId);
+                }
+            else
+                {
+                LaunchEmailWizardL();
+                }
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CMailCpsHandler::FirstBootL
+// ---------------------------------------------------------------------------
+TBool CMailCpsHandler::FirstBootL()
+    {
+    FUNC_LOG;
+    TInt value( 0 );
+    TBool ret(EFalse);
+
+    CRepository* repository(NULL);
+
+    TRAPD( err, repository = CRepository::NewL( KCRUidStartup ) );
+    if ( err == KErrNone )
+        {
+        err = repository->Get( KStartupFirstBoot, value );
+        }
+    delete repository;
+    
+    if (!value)
+        {
+        ret = ETrue;
+        }
+
+    return ret;
+    }
+
--- a/emailservices/emailserver/cmailhandlerplugin/src/cmailcpsif.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/src/cmailcpsif.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -768,11 +768,8 @@
                              else
                                  {
                                  iInstIdList.AppendL( contentid.AllocL() );
+                                 iMailCpsHandler->ManualAccountSelectionL(cid->Des());                                 
                                  }
-/*                             if (!alreadyAssociated)
-                                {
-                                iMailCpsHandler->LaunchWidgetSettingsL(cid->Des());
-                                }*/
                              CleanupStack::PopAndDestroy( cid );
                              }
                          else if (trigger.Compare(KDeActive16) == 0)
@@ -782,7 +779,7 @@
                              TInt widgetInstance = FindWidgetInstanceId(cid->Des());                            
                              if (!iInactive[widgetInstance])
                                  {
-                                 iMailCpsHandler->DissociateWidgetFromSetting( cid->Des() );                                 
+                                 iMailCpsHandler->DissociateWidgetFromSettingL( cid->Des() );                                 
                                  iInstIdList.Remove(widgetInstance);                                 
                                  }
                              iAllowedToPublish[widgetInstance] = EFalse;
@@ -800,7 +797,7 @@
                              // If no accounts are created launch email wizard
                              // otherwice launch widget settings app                             
                              if (iMailCpsHandler->GetMailboxCount())
-                                 {                                
+                                 {
                                  HBufC* cid = contentid.AllocLC();
                                  iMailCpsHandler->LaunchWidgetSettingsL(cid->Des());
                                  CleanupStack::PopAndDestroy( cid );                                 
--- a/emailservices/emailserver/cmailhandlerplugin/src/cmailcpssettings.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/src/cmailcpssettings.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -146,7 +146,7 @@
                 // Resolving encountered error, ignore this entry
                 ret = iCenRep->Reset( KCMailMailboxIdBase+ii );
                 ret = iCenRep->Reset( KCMailPluginIdBase+ii );
-                ret = iCenRep->Reset( KCMailMailboxIdBase+ii );
+                ret = iCenRep->Reset( KCMailWidgetContentIdBase+ii );
                 if ( ret )
                     {
                     }
@@ -399,17 +399,19 @@
     }
 
 // ---------------------------------------------------------------------------
-// CMailCpsSettings::DissociateWidgetFromSetting
+// CMailCpsSettings::DissociateWidgetFromSettingL
 // ---------------------------------------------------------------------------
 //
-void CMailCpsSettings::DissociateWidgetFromSetting( const TDesC& aContentId )
+void CMailCpsSettings::DissociateWidgetFromSettingL( const TDesC& aContentId )
     {
     FUNC_LOG;
     TUint32 key(0);
-    TUint32 mailboxKey(0);    
-    
+    TUint32 mailboxKey(0);
+
+    RemoveFromContentIdListL( aContentId );
+
     for (TInt i = 0; i < KMaxMailboxCount; i++)
-        {       
+        {
         TBuf<KMaxDescLen> value;
         TUint32 tempKey(KCMailWidgetContentIdBase+i);
         iCenRep->Get( tempKey, value );
@@ -429,11 +431,9 @@
 // CMailCpsSettings::GetContentId
 // ---------------------------------------------------------------------------
 //
-TInt CMailCpsSettings::GetContentId( TInt aMailboxId, TInt aId, TDes16& aValue )
+void CMailCpsSettings::GetContentId( TInt aMailboxId, TInt aNext, TDes16& aValue )
     {
     FUNC_LOG;
-    TBool cidFound(EFalse);
-    TInt ret(0);
     TInt found(0);
     for (TInt i = 0; i < KMaxMailboxCount; i++)
         {       
@@ -443,21 +443,13 @@
         if (aMailboxId == value)
             {
             found++;
-            if ( !cidFound && found == aId )
+            if ( found == aNext )
                 {
                 iCenRep->Get( KCMailWidgetContentIdBase+i, aValue );
-                cidFound = ETrue;
+                break;
                 }            
-            else if ( cidFound && found == aId + 1 )
-                {
-                // There is more widgets with same mailbox accounts. 
-                ret = aId + 1;
-                break;
-                }
             }
         }
-    // if there is more than one mailbox with different cid return id of next mailbox
-    return ret;
     }
 
 // ---------------------------------------------------------------------------
@@ -599,3 +591,73 @@
     return ret;
     }
 
+// ---------------------------------------------------------------------------
+// CMailCpsSettings::FindFromContentIdListL
+// ---------------------------------------------------------------------------
+//
+TBool CMailCpsSettings::FindFromContentIdListL( const TDesC& aContentId )
+    {
+    FUNC_LOG;
+    TBool ret(EFalse);
+
+    TBuf<KMaxDescLen> cid;    
+    cid.Copy(KStartSeparator);    
+    cid.Append(aContentId);
+    cid.Append(KEndSeparator);
+    
+    TBuf<KMaxDescLen> value;
+    TUint32 key(KCMailContentIdList);
+    iCenRep->Get( key, value );
+    
+    TInt result = value.Find(cid);
+    
+    if (result >= 0)
+        {
+        ret = ETrue;        
+        }
+
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// CMailCpsSettings::AddToContentIdListL
+// ---------------------------------------------------------------------------
+//
+void CMailCpsSettings::AddToContentIdListL( const TDesC& aContentId )
+    {
+    FUNC_LOG;
+    TBuf<KMaxDescLen> value;
+
+    TUint32 key(KCMailContentIdList);
+    iCenRep->Get( key, value );
+
+    value.Append(KStartSeparator);
+    value.Append(aContentId);
+    value.Append(KEndSeparator);  
+    
+    iCenRep->Set( key, value );    
+    }
+
+// ---------------------------------------------------------------------------
+// CMailCpsSettings::RemoveFromContentIdListL
+// ---------------------------------------------------------------------------
+//
+void CMailCpsSettings::RemoveFromContentIdListL( const TDesC& aContentId )
+    {
+    FUNC_LOG;
+    TBuf<KMaxDescLen> cid;
+    cid.Copy(KStartSeparator);    
+    cid.Append(aContentId);
+    cid.Append(KEndSeparator);
+    
+    TBuf<KMaxDescLen> value;
+    TUint32 key(KCMailContentIdList);
+    iCenRep->Get( key, value );
+    
+    TInt result = value.Find(cid);
+    if (result >= 0)
+        {
+        value.Delete(result, cid.Length());
+        iCenRep->Set( key, value );        
+        }
+    }
--- a/emailservices/emailstore/base_plugin/src/BaseMrInfoObject.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailservices/emailstore/base_plugin/src/BaseMrInfoObject.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -84,7 +84,7 @@
     iPriority = aMrInfo.PriorityL();
 
     iOrganizer = CBaseMrAttendee::NewL();
-    /*iOrganizer = CBaseMrAttendee::NewL( aMrInfo.MROrganizerL() );
+    iOrganizer = CBaseMrAttendee::NewL( aMrInfo.MROrganizerL() );
     
     RPointerArray<MMRAttendee>& attendees = aMrInfo.AttendeesL();
     TInt count = attendees.Count();
@@ -94,7 +94,7 @@
         CleanupStack::PushL( attendee );
         iAttendees.AppendL( attendee );
         CleanupStack::Pop( attendee );
-        }*/
+        }
     
     iRrule = CBaseMrRecurrenceRule::NewL( aMrInfo.RecurrenceRuleL() );
     /**@ copy construction for iExceptions, iAttachments.*/
--- a/emailuis/emailui/data/FreestyleEmailUi.rss	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/data/FreestyleEmailUi.rss	Mon Jan 18 20:08:26 2010 +0200
@@ -36,6 +36,10 @@
 #include <freestyleemailui.mbg>
 #define EMAILUI_ICON_FILE BITMAP_DIR"\\FreestyleEmailUi.mif"
 
+#ifndef qtn_cmail_options_moveto_folder
+#define qtn_cmail_options_moveto_folder qtn_fse_action_menu_move_message
+#endif
+
 RESOURCE RSS_SIGNATURE { }
 RESOURCE TBUF { buf = "FreestyleEmailUi"; }
 
@@ -948,6 +952,10 @@
 RESOURCE TBUF r_freestyle_email_ui_viewer_bookmark_added { buf=qtn_fse_info_note_bookmark_added; }
 RESOURCE TBUF r_freestyle_email_ui_one_attachment_saved        	{ buf=qtn_fse_info_note_one_attachment_saved; }
 RESOURCE TBUF r_freestyle_email_ui_multiple_attachment_saved    { buf=qtn_fse_info_note_multiple_attachments_saved; }
+RESOURCE TBUF r_freestyle_email_ui_viewer_followup    { buf=qtn_cmail_header_followup; }
+RESOURCE TBUF r_freestyle_email_ui_viewer_completed    { buf=qtn_cmail_header_completed; }
+RESOURCE TBUF r_freestyle_email_ui_viewer_high_prio    { buf=qtn_cmail_header_high_prio; }
+RESOURCE TBUF r_freestyle_email_ui_viewer_low_prio    { buf=qtn_cmail_header_low_prio; }
 
 // NOTES
 RESOURCE TBUF r_freestyle_email_delete_mail_note				{ buf=qtn_fse_delete_mail_note; }
@@ -1279,18 +1287,19 @@
     {
     items =
           {
-          MENU_ITEM { command = EFsEmailUiCmdActionsOpen; txt = qtn_options_open; },       
           MENU_ITEM { command = EFsEmailUiCmdCompose; txt=qtn_fse_message_list_options_compose; },
-          MENU_ITEM { command = EFsEmailUiCmdActionsEmptyDeleted; txt=qtn_fse_message_list_options_empty_deleted_items; },	   
-          MENU_ITEM { command = EFsEmailUiCmdMailActions; txt = qtn_fse_message_list_options_actions; cascade=r_fsemailui_maillist_submenu_mail_actions;},                       
-          MENU_ITEM { command = EFsEmailUiCmdMore; txt = qtn_fse_message_list_options_more; cascade=r_fsemailui_maillist_submenu_more;},                       
-          MENU_ITEM { command = EFsEmailUiCmdGoOnline; txt = qtn_fse_launcher_options_go_online; },                                  
-          MENU_ITEM { command = EFsEmailUiCmdGoOffline; txt = qtn_fse_launcher_options_go_offline; },                             
-          MENU_ITEM { command = EFsEmailUiCmdSync; txt = qtn_fse_message_list_options_send_receive; },  
-          MENU_ITEM { command = EFsEmailUiCmdCancelSync; txt = qtn_fse_message_list_options_cancel_send_receive; },  
-          MENU_ITEM { command = EFsEmailUiCmdSearch; txt = qtn_fse_message_list_options_search; },                       
-          MENU_ITEM { command = EFsEmailUiCmdReadEmail; txt = qtn_fse_message_list_options_read; },
-          MENU_ITEM { command = EFsEmailUiCmdSettings; txt = qtn_fse_message_list_options_settings; cascade=r_fsemailui_maillist_submenu_mail_settings;},  
+          MENU_ITEM { command = EFsEmailUiCmdActionsEmptyDeleted; txt=qtn_fse_message_list_options_empty_deleted_items; },
+          MENU_ITEM { command = EFsEmailUiCmdSearch; txt = qtn_fse_message_list_options_search; },
+
+          // email message specific commands
+          MENU_ITEM { command = EFsEmailUiCmdActionsReply; txt = qtn_fse_message_list_options_reply; },
+          MENU_ITEM { command = EFsEmailUiCmdActionsReplyAll; txt = qtn_fse_message_list_options_reply_all; },
+          MENU_ITEM { command = EFsEmailUiCmdActionsForward; txt = qtn_fse_message_list_options_forward; },
+          MENU_ITEM { command = EFsEmailUiCmdMailActions; txt = qtn_cmail_message_list_options_actions; cascade=r_fsemailui_maillist_submenu_mail_actions;},
+          MENU_ITEM { command = EFsEmailUiCmdSync; txt = qtn_cmail_message_list_options_send_receive; },
+          MENU_ITEM { command = EFsEmailUiCmdSubMenuMark; txt = qtn_fse_message_list_options_mark; cascade=r_fsemailui_maillist_submenu_mark;},
+          MENU_ITEM { command = EFsEmailUiCmdSubMenuUnmark; txt = qtn_fse_message_list_options_unmark; cascade=r_fsemailui_maillist_submenu_unmark;},
+          MENU_ITEM { command = EFsEmailUiCmdSettings; txt = qtn_fse_message_list_options_settings; },
           MENU_ITEM { command = EFsEmailUiCmdHelp; txt = qtn_options_help; },
           MENU_ITEM { command = EFsEmailUiCmdExit; txt = qtn_options_exit; }
           };
@@ -1300,44 +1309,32 @@
     {
     items =
         {
-        // calendar message specific commands
-        MENU_ITEM { command = EFsEmailUiCmdCalActionsAccept; txt = qtn_fse_action_menu_accept; },         
-        MENU_ITEM { command = EFsEmailUiCmdCalActionsTentative; txt = qtn_fse_action_menu_tentative; },         
-        MENU_ITEM { command = EFsEmailUiCmdCalActionsDecline; txt = qtn_fse_action_menu_decline; }, 
-        MENU_ITEM { command = EFsEmailUiCmdCalRemoveFromCalendar; txt = qtn_fse_message_list_options_remove_from_calendar; },                   
-
-        // email message specific commands
-        MENU_ITEM { command = EFsEmailUiCmdActionsReply; txt = qtn_fse_message_list_options_reply; },         
-        MENU_ITEM { command = EFsEmailUiCmdActionsReplyAll; txt = qtn_fse_message_list_options_reply_all; },         
-        MENU_ITEM { command = EFsEmailUiCmdActionsForward; txt = qtn_fse_message_list_options_forward; },      
-        
         // generic message commands
-        MENU_ITEM { command = EFsEmailUiCmdMarkAsRead; txt = qtn_fse_message_list_options_mark_read; },              
-       	MENU_ITEM { command = EFsEmailUiCmdMarkAsUnread; txt = qtn_fse_message_list_options_mark_unread; },              
-      	MENU_ITEM { command = EFsEmailUiCmdActionsMove; txt = qtn_fse_message_list_options_move_message; },              
-        MENU_ITEM { command = EFsEmailUiCmdActionsMoveToDrafts; txt = qtn_fse_message_list_options_move_to_drafts; },           
-        MENU_ITEM { command = EFsEmailUiCmdActionsDelete; txt = qtn_fse_message_list_options_delete; }              
+        MENU_ITEM { command = EFsEmailUiCmdActionsDelete; txt = qtn_fse_message_list_options_delete; },
+        MENU_ITEM { command = EFsEmailUiCmdMarkAsRead; txt = qtn_fse_message_list_options_mark_read; },
+       	MENU_ITEM { command = EFsEmailUiCmdMarkAsUnread; txt = qtn_fse_message_list_options_mark_unread; },
+      	MENU_ITEM { command = EFsEmailUiCmdActionsMove; txt = qtn_fse_message_list_options_move_message; },
+        MENU_ITEM { command = EFsEmailUiCmdActionsFlag; txt = qtn_fse_message_list_options_flag; },
+        MENU_ITEM { command = EFsEmailUiCmdActionsCollapseAll; txt = qtn_fse_message_list_options_collapse_all; },
+        MENU_ITEM { command = EFsEmailUiCmdActionsExpandAll; txt = qtn_fse_message_list_options_expand_all; }
         };
 	}
 
-RESOURCE MENU_PANE r_fsemailui_maillist_submenu_more
+RESOURCE MENU_PANE r_fsemailui_maillist_submenu_mark
     {
     items =
         {
-        MENU_ITEM { command = EFsEmailUiCmdMarkMark; txt = qtn_fse_message_list_options_mark; },         
-        MENU_ITEM { command = EFsEmailUiCmdMarkUnmark; txt = qtn_fse_message_list_options_unmark; },           
-        MENU_ITEM { command = EFsEmailUiCmdMarkMarkAll; txt = qtn_fse_message_list_options_mark_all; },         
-        MENU_ITEM { command = EFsEmailUiCmdMarkUnmarkAll; txt = qtn_fse_message_list_options_unmark_all; },         
-        MENU_ITEM { command = EFsEmailUiCmdActionsCallSender; txt = qtn_fse_message_list_options_call_sender; },              
-        MENU_ITEM { command = EFsEmailUiCmdActionsAddContact; txt = qtn_fse_viewer_options_add_to_contacts; },              
-        MENU_ITEM { command = EFsEmailUiCmdActionsCollapseAll; txt = qtn_fse_message_list_options_collapse_all; },               
-        MENU_ITEM { command = EFsEmailUiCmdActionsExpandAll; txt = qtn_fse_message_list_options_expand_all; },                
-        MENU_ITEM { command = EFsEmailUiCmdActionsFlag; txt = qtn_fse_message_list_options_flag; },      
-       	MENU_ITEM { command = EFsEmailUiCmdMessageDetails; txt = qtn_fse_message_list_options_message_details; }
+        MENU_ITEM { command = EFsEmailUiCmdMarkMark; txt = qtn_cmail_message_list_options_sub_mark; },
+        MENU_ITEM { command = EFsEmailUiCmdMarkMarkAll; txt = qtn_cmail_message_list_options_sub_mark_all; },
+        MENU_ITEM { command = EFsEmailUiCmdMarkSubAll; txt = qtn_cmail_message_list_options_sub_all; }
+        };
+	}
 
-//        ,      
-//        MENU_ITEM { command = EFsEmailUiCmdDownloadManager; txt = qtn_fse_message_list_options_download_manager; }
-
+RESOURCE MENU_PANE r_fsemailui_maillist_submenu_unmark
+    {
+    items =
+        {
+        MENU_ITEM { command = EFsEmailUiCmdUnmarkSubAll; txt = qtn_cmail_message_list_options_sub_all; }
         };
 	}
 	
@@ -1417,9 +1414,11 @@
         MENU_ITEM { command = EFsEmailUiCmdActionsReplyAll; txt = qtn_fse_message_list_options_reply_all; },         
         MENU_ITEM { command = EFsEmailUiCmdActionsForward; txt = qtn_fse_message_list_options_forward; },         
         MENU_ITEM { command = EFsEmailUiCmdActionsDelete; txt = qtn_fse_message_list_options_delete; },              
-       	MENU_ITEM { command = EFsEmailUiCmdMore; txt = qtn_fse_message_list_options_more; cascade=r_fsemailui_mailviewer_submenu_more;},                                   
-        MENU_ITEM { command = EFsEmailUiCmdPreviousMessage; txt = qtn_fse_viewer_options_previous_message; },              
-        MENU_ITEM { command = EFsEmailUiCmdNextMessage; txt = qtn_fse_viewer_options_next_message; },                    
+       	MENU_ITEM { command = EFsEmailUiCmdMarkAsUnread; txt = qtn_fse_message_list_options_mark_unread; },
+       	MENU_ITEM { command = EFsEmailUiCmdMarkAsRead; txt = qtn_fse_message_list_options_mark_read; },
+        MENU_ITEM { command = EFsEmailUiCmdActionsMoveMessage; txt = qtn_cmail_options_moveto_folder; },
+        MENU_ITEM { command = EFsEmailUiCmdActionsFlag; txt = qtn_fse_list_flag_follow_up; },
+        //MENU_ITEM { command = EFsEmailUiCmdReadEmail; txt = qtn_fse_message_list_options_read; },
         MENU_ITEM { command = EFsEmailUiCmdZoomLevel; txt = qtn_fse_zoom_level_cascade; cascade = r_fsemailui_htmlviewer_submenu_zoom_level;},                       
         MENU_ITEM { command = EFsEmailUiCmdHelp; txt = qtn_options_help; },
         MENU_ITEM { command = EFsEmailUiCmdExit; txt = text_softkey_exit; }
@@ -1432,12 +1431,6 @@
         {
         MENU_ITEM 
             {
-            command = EFsEmailUiCmdZoomSmallest; 
-            txt = qtn_fse_zoom_level_smallest;
-            flags = EEikMenuItemRadioStart;
-            },
-        MENU_ITEM 
-            {
             command = EFsEmailUiCmdZoomSmall;
             txt = qtn_fse_zoom_level_small;
             flags = EEikMenuItemRadioMiddle;
@@ -1453,6 +1446,12 @@
             command = EFsEmailUiCmdZoomLarge; 
             txt = qtn_fse_zoom_level_large;
             flags = EEikMenuItemRadioEnd;
+            },
+        MENU_ITEM
+            {
+            command = EFsEmailUiCmdZoom150Percent; 
+            txt = qtn_fse_zoom_level_150_percent;
+            flags = EEikMenuItemRadioStart;
             }
         };
     }
@@ -1816,7 +1815,7 @@
         MENU_ITEM { command = EFsEmailUiCmdNewSearch; txt = qtn_fse_message_list_options_new_search; },
         MENU_ITEM { command = EFsEmailUiCmdMailActions; txt = qtn_fse_message_list_options_actions; cascade=r_fsemailui_searchlist_submenu_actions;},                               
         MENU_ITEM { command = EFsEmailUiCmdCalActions; txt = qtn_fse_message_list_options_actions; cascade=r_fsemailui_searchlist_submenu_calevent_actions;},                               
-     		MENU_ITEM { command = EFsEmailUiCmdMore; txt = qtn_fse_message_list_options_more; cascade=r_fsemailui_searchlist_submenu_more;},   
+        MENU_ITEM { command = EFsEmailUiCmdMore; txt = qtn_fse_message_list_options_more; cascade=r_fsemailui_searchlist_submenu_more;},   
        	MENU_ITEM { command = EFsEmailUiCmdReadEmail; txt =	qtn_fse_message_list_options_read; },
         MENU_ITEM { command = EFsEmailUiCmdHelp; txt = qtn_options_help; },
         MENU_ITEM { command = EFsEmailUiCmdExit; txt = qtn_options_exit; }
@@ -1843,7 +1842,7 @@
         MENU_ITEM { command = EFsEmailUiCmdCalActionsAccept; txt = qtn_fse_action_menu_accept; },         
        	MENU_ITEM { command = EFsEmailUiCmdCalActionsTentative; txt = qtn_fse_action_menu_tentative; },         
        	MENU_ITEM { command = EFsEmailUiCmdCalActionsDecline; txt = qtn_fse_action_menu_decline; },         
-     		MENU_ITEM { command = EFsEmailUiCmdCalRemoveFromCalendar; txt = qtn_fse_message_list_options_remove_from_calendar; },        	        
+        MENU_ITEM { command = EFsEmailUiCmdCalRemoveFromCalendar; txt = qtn_fse_message_list_options_remove_from_calendar; },        	        
         MENU_ITEM { command = EFsEmailUiCmdMarkAsRead; txt = qtn_fse_message_list_options_mark_read; },              
        	MENU_ITEM { command = EFsEmailUiCmdMarkAsUnread; txt = qtn_fse_message_list_options_mark_unread; },                          
         MENU_ITEM { command = EFsEmailUiCmdActionsDeleteCalEvent; txt = qtn_fse_message_list_options_delete; }              
@@ -2810,6 +2809,137 @@
         };
     }
 
+
+//------------------------------------------------------------------------------
+// Stylus longtap popup menu in search list view
+//------------------------------------------------------------------------------
+RESOURCE STYLUS_POPUP_MENU r_stylus_popup_menu_search_list_view
+    {
+    items =
+    {
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_fse_action_menu_delete;       // Delete
+                command = EFsEmailUiCmdActionsDelete; 
+            },
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_fse_action_menu_mark_unread;  // Mark as unread
+                command = EFsEmailUiCmdMarkAsUnread; 
+            },
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_fse_action_menu_mark_read;    // Mark as read
+                command = EFsEmailUiCmdMarkAsRead;
+            }
+        };
+    }
+
+//------------------------------------------------------------------------------
+// Stylus longtap popup menu in html viewer when pressing on an email address
+//------------------------------------------------------------------------------
+RESOURCE STYLUS_POPUP_MENU r_stylus_popup_menu_html_view_email_address
+    {
+    items =
+		{
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_cmail_popup_send_email;       // Send email
+                command = EFsEmailUiCmdActionsReply; 
+            },
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_fse_viewer_options_add_to_contacts;  // Save to contacts
+                command = EFsEmailUiCmdActionsAddContact; 
+            },
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_cmail_popup_search_server;    // Search from server
+                command = EFsEmailUiCmdActionsRemoteLookup;
+            },
+       STYLUS_POPUP_MENU_ITEM
+            {
+	    txt = qtn_cmail_popup_copy_address;    // Copies the address to clipboard
+	    command = EFsEmailUiCmdActionsCopyToClipboard;
+	    }
+        };
+    }
+
+//------------------------------------------------------------------------------
+// Stylus longtap popup menu in html viewer when pressing on an attachment
+//------------------------------------------------------------------------------
+RESOURCE STYLUS_POPUP_MENU r_stylus_popup_menu_html_view_attachment
+    {
+    items =
+		{	
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_cmail_popup_open;       // Open the attachment
+                command = EFsEmailUiCmdOpenAttachment; 
+            },
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_cmail_popup_save;  // Save the attachment
+                command = EFsEmailUiCmdSave; 
+            },
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_cmail_popup_save_all;    // Save all the attachments
+                command = EFsEmailUiCmdSaveAll;
+            },
+	STYLUS_POPUP_MENU_ITEM
+	    {
+	        txt = qtn_cmail_popup_cancel_download;    // Cancel attachment downloads
+                command = EFsEmailUiCmdCancelDownload;
+            }
+        };
+    }
+
+//------------------------------------------------------------------------------
+// Stylus longtap popup menu in html viewer when pressing on a web address
+//------------------------------------------------------------------------------
+RESOURCE STYLUS_POPUP_MENU r_stylus_popup_menu_html_view_web_address
+    {
+    items =
+		{	
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_cmail_popup_open;       // Opens the web page in browser
+                command = EFsEmailUiCmdActionsOpenWeb; 
+            },
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_cmail_popup_add_bookmark;  // Add the web address to bookmarks 
+                command = EFsEmailUiCmdActionsAddBookmark; 
+            },
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_cmail_popup_copy_address;    // Copies the address to clipboard
+                command = EFsEmailUiCmdActionsCopyWWWAddressToClipboard;
+            }
+        };
+    }
+
+//------------------------------------------------------------------------------
+// Stylus longtap popup menu in compose view (mail editor) when pressing on an attachment
+//------------------------------------------------------------------------------
+RESOURCE STYLUS_POPUP_MENU r_stylus_popup_menu_compose_view_attachment
+    {
+    items =
+		{	
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_mail_stylus_popup_open;    // Open attachment
+                command = EFsEmailUiCmdOpenAttachment; 
+            },
+        STYLUS_POPUP_MENU_ITEM
+            {
+                txt = qtn_mail_stylus_popup_remove;  // Remove attachment 
+                command = EFsEmailUiCmdRemoveAttachment; 
+            }
+        };
+    }
+
 #include "FreestyleEmailUiGlobalSettings.rssi"
 #include "FreestyleEmailUiSettingsList.rssi"
 #include "FreestyleEmailUiSendAttachmentList.rssi"
--- a/emailuis/emailui/data/html/email.html	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/data/html/email.html	Mon Jan 18 20:08:26 2010 +0200
@@ -1,9 +1,7 @@
-<html>
-
 <frameset rows="10%,*" border=0 id="headerBody">
 
 <frame src="header.html" >
-<frame src="temp/body.html" >
+<frame id="body_frame" src="temp/body.html" >
 
 </frameset>
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/emailui/data/html/email_rtl.html	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,20 @@
+<html dir="rtl">
+<header>
+<script language="javascript">
+function setEmailBodyDirection()
+	{
+	var bodyFrame = document.getElementById("body_frame");
+	bodyFrame.contentWindow.document.body.dir = "rtl";
+	bodyFrame.contentWindow.document.body.align = "left"
+	}
+onload=setEmailBodyDirection;
+</script>
+</header>
+<frameset rows="10%,*" border=0>
+
+<frame src="header.html" >
+<frame id="body_frame" src="temp/body.html" >
+
+</frameset>
+
+</html>
Binary file emailuis/emailui/data/html/follow_up.png has changed
Binary file emailuis/emailui/data/html/follow_up_complete.png has changed
--- a/emailuis/emailui/data/html/header.js	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/data/html/header.js	Mon Jan 18 20:08:26 2010 +0200
@@ -15,5 +15,40 @@
 	document.getElementById(tableToShow).style.display = "";
 	document.getElementById(tableToHide).style.display = "none";
 	}
-	
-onload=collapseHeader;
\ No newline at end of file
+
+var intervalHandler;
+function fetchMoreIfAtBottom()
+   {
+   var element = parent.body_frame.document.body;
+
+   if ( element == null )
+      {
+      return;
+      }
+    
+    var viewport = parent.pageYOffset;
+    var elementHeight = element.offsetHeight;
+    var elementOffsetTop = element.offsetTop;
+    var screenHeight = screen.availHeight;
+    if ( elementOffsetTop + elementHeight - viewport < screenHeight )
+       {            
+       location.href = "cmail://body/" + viewport
+       clearInterval(intervalHandler);
+       }
+    }
+	   
+function scrollHandler()
+	{	
+	  intervalHandler = setInterval( "fetchMoreIfAtBottom()", 500);
+	} 
+				
+function init(scrollPos)
+    {
+    collapseHeader();
+    window.scrollTo(0, scrollPos);
+    //start a scrolling event which will trigger the check of bottom reached...
+    //this will take care of short document not does not need scrolling
+    scrollHandler();
+    } 
+
+//onload=init;
\ No newline at end of file
Binary file emailuis/emailui/data/html/todo_high_add.png has changed
Binary file emailuis/emailui/data/html/todo_low_add.png has changed
--- a/emailuis/emailui/data/iconlist.txt	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/data/iconlist.txt	Mon Jan 18 20:08:26 2010 +0200
@@ -182,3 +182,5 @@
 -c16,8 qgn_prop_email_sort_unread_desc.svg
 -c16,8 qgn_indi_tb_collapse_all.svg
 -c16,8 qgn_indi_tb_expand_all.svg
+-c16,8 qgn_indi_cmail_arrow_previous.svg
+-c16,8 qgn_indi_cmail_arrow_next.svg
--- a/emailuis/emailui/group/FreestyleEmailUi.mmp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/group/FreestyleEmailUi.mmp	Mon Jan 18 20:08:26 2010 +0200
@@ -111,7 +111,9 @@
 SOURCE  FreestyleAttachmentDownloadProgressBar.cpp
 SOURCE  FreestyleEmailUiPropertySubscriber.cpp
 SOURCE  freestyleemailuimailboxdeleter.cpp
-SOURCE cmailcustomstatuspaneindicators.cpp
+SOURCE  cmailcustomstatuspaneindicators.cpp
+SOURCE  OverlayControl.cpp
+SOURCE FSHtmlReloadAO.cpp
 
 SOURCEPATH      ../group
 
@@ -216,3 +218,5 @@
 LIBRARY aknphysics.lib              // for panning
 
 LIBRARY MsgEditorModel.lib
+LIBRARY touchfeedback.lib
+
--- a/emailuis/emailui/group/bld.inf	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/group/bld.inf	Mon Jan 18 20:08:26 2010 +0200
@@ -54,23 +54,39 @@
 // make the files ready for creating ROM image 
 ../data/html/attachment.gif /epoc32/data/z/private/2001E277/HtmlFile/attachment.gif
 ../data/html/email.html /epoc32/data/z/private/2001E277/HtmlFile/email.html
+../data/html/email_rtl.html /epoc32/data/z/private/2001E277/HtmlFile/email_rtl.html
 ../data/html/header.js /epoc32/data/z/private/2001E277/HtmlFile/header.js
 ../data/html/plus.gif /epoc32/data/z/private/2001E277/HtmlFile/plus.gif
 ../data/html/minus.gif /epoc32/data/z/private/2001E277/HtmlFile/minus.gif
+../data/html/follow_up.png /epoc32/data/z/private/2001E277/HtmlFile/follow_up.png
+../data/html/follow_up_complete.png /epoc32/data/z/private/2001E277/HtmlFile/follow_up_complete.png
+../data/html/todo_high_add.png /epoc32/data/z/private/2001E277/HtmlFile/todo_high_add.png
+../data/html/todo_low_add.png /epoc32/data/z/private/2001E277/HtmlFile/todo_low_add.png
+
 
 // make the files ready for udeb emulator
 ../data/html/attachment.gif /epoc32/release/winscw/udeb/z/private/2001E277/HtmlFile/attachment.gif
 ../data/html/email.html /epoc32/release/winscw/udeb/z/private/2001E277/HtmlFile/email.html
+../data/html/email_rtl.html /epoc32/release/winscw/udeb/z/private/2001E277/HtmlFile/email_rtl.html
 ../data/html/header.js /epoc32/release/winscw/udeb/z/private/2001E277/HtmlFile/header.js
 ../data/html/plus.gif /epoc32/release/winscw/udeb/z/private/2001E277/HtmlFile/plus.gif
 ../data/html/minus.gif /epoc32/release/winscw/udeb/z/private/2001E277/HtmlFile/minus.gif
+../data/html/follow_up.png /epoc32/release/winscw/udeb/z/private/2001E277/HtmlFile/follow_up.png
+../data/html/follow_up_complete.png /epoc32/release/winscw/udeb/z/private/2001E277/HtmlFile/follow_up_complete.png
+../data/html/todo_high_add.png /epoc32/release/winscw/udeb/z/private/2001E277/HtmlFile/todo_high_add.png
+../data/html/todo_low_add.png /epoc32/release/winscw/udeb/z/private/2001E277/HtmlFile/todo_low_add.png
 
 // make the files ready for urel emulator
 ../data/html/attachment.gif /epoc32/release/winscw/urel/z/private/2001E277/HtmlFile/attachment.gif
 ../data/html/email.html /epoc32/release/winscw/urel/z/private/2001E277/HtmlFile/email.html
+../data/html/email_rtl.html /epoc32/release/winscw/urel/z/private/2001E277/HtmlFile/email_rtl.html
 ../data/html/header.js /epoc32/release/winscw/urel/z/private/2001E277/HtmlFile/header.js
 ../data/html/plus.gif /epoc32/release/winscw/urel/z/private/2001E277/HtmlFile/plus.gif
 ../data/html/minus.gif /epoc32/release/winscw/urel/z/private/2001E277/HtmlFile/minus.gif
+../data/html/follow_up.png /epoc32/release/winscw/urel/z/private/2001E277/follow_up.png
+../data/html/follow_up_complete.png /epoc32/release/winscw/urel/z/private/2001E277/follow_up_complete.png
+../data/html/todo_high_add.png /epoc32/release/winscw/urel/z/private/2001E277/todo_high_add.png
+../data/html/todo_low_add.png /epoc32/release/winscw/urel/z/private/2001E277/todo_low_add.png
 
 ../sis/commonemailstub.sis          /epoc32/data/z/system/install/commonemailstub.sis
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/emailui/inc/FSHtmlReloadAO.h	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Symbian Foundation License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file defines class CFSHtmlReloadAO.
+*
+*/
+
+#ifndef FSHtmlReloadAO_H
+#define FSHtmlReloadAO_H
+
+#include <e32base.h>
+
+class CFsEmailUiHtmlViewerView;
+class CFSHtmlReloadAO : public CActive
+    {
+public:
+    static CFSHtmlReloadAO* NewL( CFsEmailUiHtmlViewerView& aView );
+    ~CFSHtmlReloadAO();
+    void ReloadPageAysnc();
+private:
+    CFSHtmlReloadAO( CFsEmailUiHtmlViewerView& aView );
+
+    void ConstructL();
+    void RunL();
+    void DoCancel();
+
+private:
+    CFsEmailUiHtmlViewerView&       iView;
+    };
+
+#endif /*FSHtmlReloadAO_H*/
--- a/emailuis/emailui/inc/FreestyleEmailDownloadInformationMediator.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailDownloadInformationMediator.h	Mon Jan 18 20:08:26 2010 +0200
@@ -209,6 +209,7 @@
 		{
 		MFSEmailDownloadInformationObserver* iObserver;
 		TFSMailMsgId iMessageId;
+        TBool iDeleted;
 		};
 
 	class TDownload
@@ -261,12 +262,28 @@
 	* @param    aCompletedCount How many attachments were succesfully downloaded.
 	*/
 	void LaunchDownloadCompleteNoteL( const TPartData& aPart, TInt aCompletedCount );
-	
+
 	/**
 	* Notify all the registered observers about a download event.
 	*/
 	void NotifyObserversL( const TFSProgress& aEvent, const TPartData& aPart );
-	
+
+	/**
+	* Notify all the registered observers for a particular message part about a download event.
+	*/
+	void NotifyPartObserversL( const TFSProgress& aEvent, const TPartData& aPart );
+
+    /**
+     * Removes deleted observers from the observer array.
+     */
+    void CleanUpObservers();
+
+    /**
+     * Safely removes an entry from the observer array in case notifications
+     * are currently in process.
+     */
+    void RemoveObserver( TInt aIdx );
+
 	/**
 	* Updates the entry in iDownloadCountArray according a progress event and gets a copy of 
 	* its data. The original entry may be removed from the array as a result.
@@ -324,6 +341,13 @@
 
 	// has there been any downloads since program started
 	TBool iDownloadsStarted;
+
+    // counter indicating how many observer notification operations are
+    // currently in progress
+    TInt iNotificationsInProgress;
+
+    // have any observers been deleted during notification
+    TBool iObserverDeleted;
     };
 
 #endif  // FSEMAILDOWNLOADINFORMATIONMEDIATOR_H
--- a/emailuis/emailui/inc/FreestyleEmailUi.hrh	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUi.hrh	Mon Jan 18 20:08:26 2010 +0200
@@ -149,6 +149,7 @@
 	EFsEmailUiCmdGoToBottom,
 	EFsEmailUiCmdGoToSwitchFolder,
 	EFsEmailUiCmdGoToSwitchSorting,
+	EFsEmailUiCmdGoToSwitchNewEmail,
 	EFsEmailUiCmdGoToActionMenu,
 	EFsEmailUiCmdMark,
 	EFsEmailUiCmdMarkMark,
@@ -189,6 +190,7 @@
 	EFsEmailUiCmdActionsOpenInIntranetBase,
 	EFsEmailUiCmdActionsAddBookmark,
 	EFsEmailUiCmdActionsCopyToClipboard,
+	EFsEmailUiCmdActionsCopyWWWAddressToClipboard,
 	EFsEmailUiCmdActionsCopyText,
 	EFsEmailUiCmdViewerFetchRestOfMessage,
 	EFsEmailUiCmdPreviousMessage,
@@ -284,10 +286,10 @@
 	EFsEmailUiCmdZoomLevel,
 	
 	// Zoom level indexes must remain last in the enumeration to enable adding new zoom levels
-	EFsEmailUiCmdZoomSmallest,
 	EFsEmailUiCmdZoomSmall,
 	EFsEmailUiCmdZoomNormal,
 	EFsEmailUiCmdZoomLarge,
+	EFsEmailUiCmdZoom150Percent,
 	
     // <cmail> Toolbar
 	EFsEmailUiTbCmdSend,
@@ -312,8 +314,13 @@
     EFsEmailUiTbCmdSaveAll,
     
     EFsEmailUiTbCmdActions,
-    EFsEmailUiTbCmdReplyAll
+    EFsEmailUiTbCmdReplyAll,
 	// </cmail> Toolbar
+
+    EFsEmailUiCmdSubMenuMark,
+    EFsEmailUiCmdSubMenuUnmark,
+    EFsEmailUiCmdMarkSubAll,
+    EFsEmailUiCmdUnmarkSubAll
   	};
 
 enum TFsEmailUiViewerOpenInIntranetCmds
--- a/emailuis/emailui/inc/FreestyleEmailUiAttachmentsListVisualiser.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiAttachmentsListVisualiser.h	Mon Jan 18 20:08:26 2010 +0200
@@ -77,7 +77,9 @@
 
     /** Handles events from the tree list. */
     // <cmail> Touch
-    void TreeListEventL( const TFsTreeListEvent aEvent, const TFsTreeItemId aId );
+    void TreeListEventL( const TFsTreeListEvent aEvent, 
+                         const TFsTreeItemId aId,
+                         const TPoint& aPoint );
     TPoint ActionMenuPosition();
     // </cmail>
     TUid Id() const;
--- a/emailuis/emailui/inc/FreestyleEmailUiContactHandler.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiContactHandler.h	Mon Jan 18 20:08:26 2010 +0200
@@ -344,6 +344,10 @@
     CFSEmailUiContactHandler( RFs& aSession );
     
     void ConstructL( RFs& aSession );
+    
+// <cmail> call observer's MFSEmailUiContactHandlerObserver::OperationErrorL( TContactHandlerCmd aCmd, TInt aError ) 
+    void ObserverOperationErrorL( TContactHandlerCmd aCmd, TInt aErrorCode );
+    
 
 private:
     
--- a/emailuis/emailui/inc/FreestyleEmailUiFolderListVisualiser.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiFolderListVisualiser.h	Mon Jan 18 20:08:26 2010 +0200
@@ -196,7 +196,8 @@
      * From MFsTreeListObserver
      */
     void TreeListEventL( const TFsTreeListEvent aEvent,
-                                    const TFsTreeItemId aId = KFsTreeNoneID );
+                         const TFsTreeItemId aId,
+                         const TPoint& aPoint );
 
 // <cmail> Receiving online/offline events
     void HandleMailBoxEventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox,
--- a/emailuis/emailui/inc/FreestyleEmailUiHtmlViewerContainer.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiHtmlViewerContainer.h	Mon Jan 18 20:08:26 2010 +0200
@@ -26,6 +26,7 @@
 #include <BrCtlLinkResolver.h>
 
 #include "FreestyleEmailDownloadInformationMediator.h"
+#include "OverlayControl.h"
 
 class CFSMailMessage;
 class CFreestyleEmailUiAppUi;
@@ -38,7 +39,9 @@
                                       public MBrCtlSpecialLoadObserver,
                                       public MBrCtlLinkResolver,
                                       public MBrCtlSoftkeysObserver,
-                                      public MFSEmailDownloadInformationObserver
+                                      public MFSEmailDownloadInformationObserver,
+                                      public MOverlayControlObserver,
+                                      public MBrCtlWindowObserver
     {
 public:
 
@@ -52,7 +55,7 @@
     void LoadContentFromFileL( const TDesC& aFileName );
     void LoadContentFromFileL( RFile& aFile );
     void LoadContentFromUrlL( const TDesC& aUrl );
-    void LoadContentFromMailMessageL( CFSMailMessage* aMailMessage );
+    void LoadContentFromMailMessageL( CFSMailMessage* aMailMessage, TBool aResetScrollPos=ETrue );
     void ResetContent();
     void CancelFetch();
     void ClearCacheAndLoadEmptyContent();
@@ -68,6 +71,7 @@
     void SizeChanged();
     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
     void HandleResourceChange(TInt aType);
+    void MakeVisible( TBool aVisible );
 
 // from base class MBrCtlSpecialLoadObserver
 
@@ -94,6 +98,18 @@
     void UpdateSoftkeyL( TBrCtlKeySoftkey aKeySoftkey, const TDesC& aLabel,
         TUint32 aCommandId, TBrCtlSoftkeyChangeReason aBrCtlSoftkeyChangeReason );
     void StopObserving();
+    
+// from MOverlayControlObserver
+    void HandleOverlayPointerEventL( COverlayControl* aControl, const TPointerEvent& aEvent );
+
+    /*
+     * Reloads the header of the opened mail.
+     */
+    void RefreshCurrentMailHeader();
+    /** Handles asynchronous reload of page for case when orientation
+     * changed
+     */
+    void ReloadPageL();
 private:
 
     // Second phase constructor.
@@ -127,6 +143,12 @@
     void DownloadAttachmentL( CFSMailMessagePart& aAttachment,
         MBrCtlLinkContent& aEmbeddedLinkContent );
     
+    // Get area for overlay button
+    TRect OverlayButtonRect( TBool aLeft );
+    
+    // Update overlay button position and visibility
+    void UpdateOverlayButtons( TBool aVisible );
+    
     void SetHTMLResourceFlagFullName();
     void EnableHTMLResourceFlagL();
     TBool HTMLResourceFlagEnabled();
@@ -139,7 +161,19 @@
     void ConvertToHTML( const TDesC8& aContent,
             const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart );
     HBufC8* GetCharacterSetL( CFSMailMessagePart& aHtmlBodyPart );
+    TBool IsMessageBodyURL(const TDesC& aUrl);
+	void CreateHyperlinksFromUrlsL( CBufBase& aSource );
+    //Returns ETrue of clicking on a link requires a browser to be launched
+    TBool NeedToLaunchBrowserL( const TDesC& aUrl );
+    //Launch the browser as a standalone app
+    void LaunchBrowserL( const TDesC& aUrl );
     
+    //from MBrCtlWindowObserver    
+    CBrCtlInterface* OpenWindowL( TDesC& aUrl, TDesC* aTargetName, 
+                                  TBool aUserInitiated, TAny* aReserved );
+    CBrCtlInterface* FindWindowL( const TDesC& aTargetName ) const;  
+    void HandleWindowCommandL( const TDesC& aTargetName, TBrCtlWindowCommand aCommand ); 
+       
 
 private: // data
 
@@ -170,6 +204,9 @@
     RArray<TPartData> iMessageParts;
     CFreestyleMessageHeaderURLEventHandler* iEventHandler;
     TBool iObservingDownload;
+    TInt iScrollPosition;
+    COverlayControl* iOverlayControlNext;
+    COverlayControl* iOverlayControlPrev;
     };
 
 
--- a/emailuis/emailui/inc/FreestyleEmailUiHtmlViewerView.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiHtmlViewerView.h	Mon Jan 18 20:08:26 2010 +0200
@@ -29,7 +29,6 @@
 #include "FreestyleEmailUiContactHandlerObserver.h"
 #include "FreestyleEmailUiAttachmentsListModel.h"
 #include <AknWaitDialog.h>
-#include <AknNaviDecoratorObserver.h>
 #include "FreestyleEmailDownloadInformationMediator.h"
 #include "FreestyleEmailUiControlBarCallback.h"
 
@@ -53,8 +52,7 @@
         public MProgressDialogCallback,
 		public MFSEmailUiFolderListCallback,
 		public MESMRIcalViewerCallback,
-    	public MESMRIcalViewerObserver,
-		public MAknNaviDecoratorObserver
+    	public MESMRIcalViewerObserver
     {
 public:
 
@@ -74,6 +72,10 @@
     */
     TUid Id() const;
 
+    void HandleStatusPaneSizeChange();
+    
+    void HandleViewRectChange();
+    
     /**
     * HandleCommandL
     * From CAknView, takes care of command handling.
@@ -82,10 +84,11 @@
     void HandleCommandL( TInt aCommand );
     
     // Handle accept/decline/tentative/remove commands given for meeting request message directly from list UI.
-	  void HandleMrCommandL( TInt aCommandId, TFSMailMsgId aMailboxId, TFSMailMsgId aFolderId, TFSMailMsgId aMessageId );
+	void HandleMrCommandL( TInt aCommandId, TFSMailMsgId aMailboxId, TFSMailMsgId aFolderId, TFSMailMsgId aMessageId );
     
-		void CompletePendingMrCommand();
-		void CancelPendingMrCommandL();
+	void CompletePendingMrCommand();
+	void CancelPendingMrCommandL();
+	
     /**
     * ChildDoDeactivate
     * From CFsEmailUiViewBase, deactivate the AknView
@@ -104,14 +107,19 @@
 
     void SetMskL();
     void PrepareForExit();
+    
 public : // for MFSMailRequestObserver
     void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
+    
 public: 
     // from MProgressDialogCallback
     void DialogDismissedL( TInt aButtonId);
     
     CFSMailMessage* CurrentMessage();
     CFSEmailUiAttachmentsListModel* CurrentAttachmentsListModel();
+    
+    // Return view area that can be used for container
+    TRect ContainerRect() const;
 
 public: 
     void HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType );
@@ -119,6 +127,7 @@
                               TFSMailMsgId aMailbox, TAny* aParam1, TAny* /*aParam2*/, TAny* /*aParam3*/ );
     
     void HandleEmailAddressCommandL( TInt aCommand, const TDesC& aEmailAddress ); 
+    void HandleWebAddressCommandL( TInt aCommand, const TDesC& aUrl );
     
     void DownloadAttachmentL( const TAttachmentData& aAttachment );
     void DownloadAllAttachmentsL();
@@ -135,6 +144,8 @@
     TFSMailMsgId ViewedMessageId(); 
     
     TBool GetAsyncFetchStatus();
+    void StartFetchingMessageL();
+    void ReloadPageL();
 public: // from MFSEmailUiContactHandlerObserver
     void OperationCompleteL( TContactHandlerCmd aCmd,
                              const RPointerArray<CFSEmailUiClsItem>& aContacts );
@@ -156,13 +167,6 @@
     void OperationCompleted( TIcalViewerOperationResult aResult );        
     void OperationError( TIcalViewerOperationResult aResult );
 	
-public: // from MAknNaviDecoratorObserver
-    
-    /**
-     * Called by navigationDecorator if navi arrows (left/right) have been pressed
-     * @aParam aEventID specifies a tapping of either left or right arrow
-     */
-    void HandleNaviDecoratorEventL( TInt aEventID );
 private: // from
     /**
      * @see CFsEmailUiViewBase::ChildDoActivateL
@@ -191,6 +195,11 @@
      * @see CFsEmailUiViewBase::NavigateBackL
      */ 
     void NavigateBackL();
+    
+    /**
+	 * @see CFsEmailUiViewBase::SetStatusBarLayout
+	 */ 
+    void SetStatusBarLayout();
 private: // New functions
     // list of different types of content
     enum TFetchedType
@@ -203,7 +212,7 @@
     void LoadContentFromFileL( const TDesC& aFileName );
     void LoadContentFromFileL( RFile& aFile );
     void LoadContentFromUrlL( const TDesC& aUrl );
-    void LoadContentFromMailMessageL( CFSMailMessage* aMailMessage );
+    void LoadContentFromMailMessageL( CFSMailMessage* aMailMessage, TBool aResetScrollPosition =ETrue );
     void DeleteMailL();
     void HideContainer();
     void ShowContainerL();
@@ -249,9 +258,12 @@
     void FolderSelectedL( TFSMailMsgId aSelectedFolderId,
                           TFSEmailUiCtrlBarResponse aResponse ); 
     
-    void UpdateNaviPaneL( TBool aForESMR = EFalse );
-    void HideNaviPane();
+    void UpdateEmailHeaderIndicators();
     TBool IsOpenedInMRViewerL();
+    void CopyCurrentToClipBoardL( const TDesC& aArgument) const;
+    void OpenLinkInBrowserL( const TDesC& aUrl) const;
+    void SaveWebAddressToFavouritesL( const TDesC& aUrl ) const;
+    void SetScrollPosition(TInt aPosition);
 private: // Constructors
     
     void ConstructL();
--- a/emailuis/emailui/inc/FreestyleEmailUiMailListVisualiser.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiMailListVisualiser.h	Mon Jan 18 20:08:26 2010 +0200
@@ -122,8 +122,7 @@
 									 public MFSEmailUiFolderListCallback,
 									 public MFSEmailUiSortListCallback,
 									 public MFsTreeListObserver,
-									 public MFSEmailUiContactHandlerObserver,
-									 public MFsActionMenuPositionGiver
+									 public MFSEmailUiContactHandlerObserver
 // </cmail>
 	{
 friend class CMailListUpdater;
@@ -181,7 +180,7 @@
      * Open action menu.
      * (Touchwork: Called from touch manager)
      */
-	void DoHandleListItemLongTapL();
+	void DoHandleListItemLongTapL( const TPoint& aPoint );
 
     /**
      * Get control which is currently focused.
@@ -245,7 +244,7 @@
 	TInt MoveToNextMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundNextMsgId );
 	TInt MoveToPreviousMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId );
 	TInt MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId );
-	
+
 	/**
      * Sets the manual mailbox syncronisation flag if the user chose
      * to synchorise mail box from the menu
@@ -267,7 +266,9 @@
 
     /** Handles tree list events. */
     // <cmail> Touch
-    void TreeListEventL( const TFsTreeListEvent aEvent, const TFsTreeItemId aId );
+    void TreeListEventL( const TFsTreeListEvent aEvent,
+                         const TFsTreeItemId aId,
+                         const TPoint& aPoint );
     // </cmail>
 
 // from base class MFSEmailUiContactHandlerObserver
@@ -283,9 +284,6 @@
     * time stamp texts in emails and nodes are up-to-date.
     */
     void NotifyDateChangedL();
-// <cmail>
-    TPoint ActionMenuPosition();
-// </cmail>
 
 private: // from
 
@@ -412,10 +410,8 @@
 	// The list contains either marked entries or the focused message entry or is empty.
 	void GetActionsTargetEntriesL( RFsTreeItemIdList& aListItems ) const;
 
-	// Action menu specific functions
-	void LaunchActionMenuL();
-	void HandleActionMenuCommandL( TActionMenuCustomItemId itemId );
-	void LaunchStylusPopupMenuL();
+	// Stylus menu specific functions
+	void LaunchStylusPopupMenuL( const TPoint& aPoint );
 
 	// Compose, reply, reply all and forward
 	void CreateNewMsgL();
@@ -514,6 +510,29 @@
      */
     TBool HitTest( const CAlfControl& aControl, const TPoint& aPoint ) const;
 
+    /**
+     * Handles arrow events in portrait mode.
+     *
+     * @param aScancode Standard scan code.
+     * @param aEvent Event.
+     * @param aShiftState Shift state.
+     *
+     * @return <code>ETrue</code>, if consumed, <code>EFalse</code> otherwise.
+     */
+    TBool HandleArrowEventInPortraitL( const TInt aScancode,
+            const TAlfEvent& aEvent, const TBool aShiftState );
+    /**
+     * Handles arrow events in landscape mode.
+     *
+     * @param aScancode Standard scan code.
+     * @param aEvent Event.
+     * @param aShiftState Shift state.
+     *
+     * @return <code>ETrue</code>, if consumed, <code>EFalse</code> otherwise.
+     */
+    TBool HandleArrowEventInLandscapeL( const TInt aScancode,
+            const TAlfEvent& aEvent, const TBool aShiftState );
+
 private: // data types
 
 
@@ -591,9 +610,13 @@
 
     CEUiEmailListTouchManager* iTouchManager;
     CAknStylusPopUpMenu* iStylusPopUpMenu;
-    TBool iStylusPopUpMenuLaunched;
+    TBool iStylusPopUpMenuVisible;
 
     TBool iShowReplyAll;
+    // Was focus visible in the ListView.
+    TBool iLastFocus;
+    //used to prevent Call application execution (on keyup of call button) when call to contact required
+    TBool iConsumeStdKeyYes_KeyUp; 
   	};
 
 
--- a/emailuis/emailui/inc/FreestyleEmailUiMsgDetailsVisualiser.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiMsgDetailsVisualiser.h	Mon Jan 18 20:08:26 2010 +0200
@@ -112,7 +112,8 @@
 public: // From MFsTreeListObserver
     
     void TreeListEventL( const TFsTreeListEvent aEvent, 
-                                        const TFsTreeItemId /*aId*/ );
+                         const TFsTreeItemId aId,
+                         const TPoint& aPoint );
     
     // From MFsActionMenuPositionGiver
     TPoint ActionMenuPosition();
--- a/emailuis/emailui/inc/FreestyleEmailUiSearchListVisualiser.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiSearchListVisualiser.h	Mon Jan 18 20:08:26 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -14,7 +14,7 @@
 * Description:  FreestyleEmailUi search result list visualisation
 *
 */
-    
+
 #ifndef __FREESTYLEEMAILUI_SEARCHLISTVISUALISER_H__
 #define __FREESTYLEEMAILUI_SEARCHLISTVISUALISER_H__
 
@@ -61,7 +61,7 @@
 class CAsyncCallBack;
 class CESMRIcalViewer;
 class CFsTreePlainTwoLineItemData;
-
+class CAknStylusPopUpMenu;
 
 struct SSearchListItem
 	{
@@ -70,11 +70,10 @@
 	MFsTreeItemVisualizer* iTreeItemVisualiser;
 	};
 
-class CFSEmailUiSearchListVisualiser : public CFsEmailUiViewBase, 
-									   public MFSMailBoxSearchObserver, 
+class CFSEmailUiSearchListVisualiser : public CFsEmailUiViewBase,
+									   public MFSMailBoxSearchObserver,
 									   //<cmail> touch
 									   public MFsTreeListObserver,
-									   public MFsActionMenuPositionGiver,
 									   //<cmail>
 									   public MFSEmailUiGenericTimerCallback,
 									   public MFSEmailUiContactHandlerObserver
@@ -83,24 +82,24 @@
 	static CFSEmailUiSearchListVisualiser* NewL(CAlfEnv& aEnv, CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aSeacrhListControlGroup);
 	static CFSEmailUiSearchListVisualiser* NewLC(CAlfEnv& aEnv, CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aSearchListControlGroup);
     virtual ~CFSEmailUiSearchListVisualiser();
-    void PrepareForExit();  
+    void PrepareForExit();
 
 public: // from CFsEmailUiViewBase
 	void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
 
-    // From view 
-	TUid Id() const;			   
+    // From view
+	TUid Id() const;
 	// <cmail> Toolbar
 	/*void DoActivateL(const TVwsViewId& aPrevViewId,
 	                 TUid aCustomMessageId,
 	                 const TDesC8& aCustomMessage);*/
     // </cmail> Toolbar
-    void ChildDoDeactivate();                
+    void ChildDoDeactivate();
     void HandleCommandL( TInt aCommand );
 
     /**
 	 * @see CFsEmailUiViewBase::SetStatusBarLayout
-	 */ 
+	 */
     void SetStatusBarLayout();
 
     // Dynamic variant switch, called by appui
@@ -113,10 +112,14 @@
     TInt MoveToNextMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundNextMsgId );
     TInt MoveToPreviousMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId );
     TInt MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId );
-    
+
 public: // from MFSMailBoxSearchObserver
     void MatchFoundL( CFSMailMessage* aMatchMessage );
     void SearchCompletedL();
+    /**
+     * server asks client if to change the search priority (when calling)
+     */
+    void ClientRequiredSearchPriority( TInt *apRequiredSearchPriority ); // <cmail>
 
 
 public: // new methods
@@ -125,12 +128,12 @@
 
 	// Mail list current model data
 	CFSEmailUiMailListModel* Model();
-	
+
 	// Event handling forwarded from control
-	TBool OfferEventL( const TAlfEvent& aEvent ); 
+	TBool OfferEventL( const TAlfEvent& aEvent );
 
 	// Used from callback
-	TInt LaunchSearchDialogL();	
+	TInt LaunchSearchDialogL();
 
 	// Used from appui to get the current index in search list
 	TInt HighlightedIndex() const;
@@ -148,29 +151,29 @@
 
 public: // From MFsTreeListObserver
     //<cmail> touch
-    void TreeListEventL( const TFsTreeListEvent aEvent, const TFsTreeItemId aId );
-    
-    // From MFsActionMenuPositionGiver
-    TPoint ActionMenuPosition();
-	//</cmail>	
-		
+    void TreeListEventL( const TFsTreeListEvent aEvent,
+                         const TFsTreeItemId aId,
+                         const TPoint& aPoint );
+
+	//</cmail>
+
 public: // From MFSEMailUiContactHandlerObserver
 
     void OperationCompleteL( TContactHandlerCmd aCmd,
         const RPointerArray<CFSEmailUiClsItem>& aContacts );
     void OperationErrorL( TContactHandlerCmd, TInt aError );
 
-// <cmail> Toolbar    
+// <cmail> Toolbar
 private: // from
-    
+
     /**
      * @see CFsEmailUiViewBase::ChildDoActivateL
      */
     void ChildDoActivateL( const TVwsViewId& aPrevViewId,
             TUid aCustomMessageId,
             const TDesC8& aCustomMessage );
-   
-// </cmail> Toolbar    
+
+// </cmail> Toolbar
 
     // Called when flip state is changed
     void FlipStateChangedL( TBool aFlipOpen );
@@ -180,7 +183,7 @@
      * @param aVisible Indicates if focus should become visible or removed
      */
     void FocusVisibilityChange( TBool aVisible );
-    
+
 private:
 	CFSEmailUiSearchListVisualiser( CFreestyleEmailUiAppUi* aAppUi, CAlfEnv& aEnv, CAlfControlGroup& aSearchListControlGroup );
 	void ConstructL();
@@ -188,7 +191,7 @@
   	void ReScaleUiL();
 	void SetSearchListLayoutAnchors();
 	void SetSearchListTopBarLayoutAnchors();
-	
+
 	void CreatePlainNodeL( const TDesC& aItemDataBuff,
                            CFsTreePlainOneLineNodeData* &aItemData,
                            CFsTreePlainOneLineNodeVisualizer* &aNodeVisualizer ) const;
@@ -199,21 +202,21 @@
 	TFSMailMsgId MsgIdFromIndex( TInt aItemIdx ) const;
 	TFSMailMsgId MsgIdFromListId( TFsTreeItemId aListId ) const;
 	CFSMailMessage& MsgPtrFromListId( TFsTreeItemId aListId );
-	
-	// Item data and visualiser helper functions 
-	MFsTreeItemData* ItemDataFromItemId( TFsTreeItemId aItemId );										
+
+	// Item data and visualiser helper functions
+	MFsTreeItemData* ItemDataFromItemId( TFsTreeItemId aItemId );
 	MFsTreeItemVisualizer* ItemVisualiserFromItemId( TFsTreeItemId aItemId );
-	
+
 	// Helpers to get the ordinal of a message in the iModel
 	TInt ItemIndexFromMessageId( const TFSMailMsgId& aMessageId ) const;
 	TInt NextMessageIndex( TInt aCurMsgIdx ) const;
 	TInt PreviousMessageIndex( TInt aCurMsgIdx ) const;
-		
+
 	//<cmail> touch
-	// Helper class for resolving touch events and actions	
-	void DoHandleActionL();	
+	// Helper class for resolving touch events and actions
+	void DoHandleActionL();
     //</cmail>
-	
+
 	// Open highlighted mail
 	void OpenHighlightedMailL();
 
@@ -228,36 +231,34 @@
 
 	// <cmail> fixed CS high cat. finding
     void ResetResultListL();
-    
+
 	void ChangeReadStatusOfHighlightedL( TInt aRead );
 
 	void CheckAndUpdateFocusedMessageL();
-	
+
 	void RemoveFocusedFromListL();
 
 	void UpdateMsgIconAndBoldingL( CFSMailMessage* aMsgPtr );
 	void UpdateMsgIconAndBoldingL( TInt aListIndex );
 
-	// Delete messages 
+	// Delete messages
 	void DeleteFocusedMessageL();
-	
-	void CallToSenderL();
-	
-	void UpdateMailListSettingsL();	
+
+	TBool CallToSenderL();
+
+	void UpdateMailListSettingsL();
 
 	void UpdatePreviewPaneTextForItemL( CFsTreePlainTwoLineItemData* aItemData, CFSMailMessage* aMsgPtr );
 	void FilterPreviewPaneTextL( TDes& aText ) const;
-	
+
 	void SetMskL();
-	
+
     void DoFirstStartL();
-	
-    void LaunchActionMenuL();
-    
-    void HandleActionMenuCommandL( TActionMenuCustomItemId itemId );
-    
+
     void SetHeaderAttributesL();
-    
+
+    void LaunchStylusPopupMenuL( const TPoint& aPoint );
+
 private:
     // Pointer to Alf environment
 	CAlfEnv* iEnv;
@@ -278,43 +279,50 @@
     	// Mail List control and layout
   	CFreestyleEmailUiSearchListControl* iSearchListControl;
  	CAlfDeckLayout* iSearchListLayout;
-    CFSEmailUiMailListModel* iModel; 
+    CFSEmailUiMailListModel* iModel;
   	CFsTreeList* iSearchList;
     CFsTreeVisualizerBase* iSearchTreeListVisualizer;
-  	TInt iNumSlots;		
+  	TInt iNumSlots;
 
-	RArray<SSearchListItem> iSearchListItemArray;   
-   
+	RArray<SSearchListItem> iSearchListItemArray;
+
 	HBufC* iLatestSearchText;
-	
+
 	TBool iThisViewActive;
 
 	TBool iSearchOngoing;
 
 	CFSEmailUiGenericTimer* iStartupCallbackTimer;
-	
+
 	RPointerArray<TDesC> iSearchStrings;
 
-	
+
 	TBool iMsgDataCouldBeChanged;
-	
-	// Previous view uid 	
+
+	// Previous view uid
 	TUid iPreviousViewUid;
-  	
-    TInt iListMode;    
+
+    TInt iListMode;
     TInt iNodesInUse;
-    
+
     TFSMailMsgId iLatestOpenedMrId;
-    
+
     TInt iSearchCount;
-    
+
 	TAknUiZoom iCurrentZoomLevel;
-  	
+
 	TBool iFirstStartCompleted;
-	
+
 	TBool iListAddedToControlGroup;  //<cmail>
 	TBool iPreparedForExit; //<cmail>
 
+    CAknStylusPopUpMenu* iStylusPopUpMenu;
+    TBool iStylusPopUpMenuVisible;
+
+	//prevents improper executing of Call application - when call to contact
+	TBool iConsumeStdKeyYes_KeyUp; 
+	// decreases search priority to enable search for contact when call to contact
+	TInt iRequiredSearchPriority; 
   	};
 
-#endif 
+#endif
--- a/emailuis/emailui/inc/FreestyleEmailUiSendAttachmentsListModel.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiSendAttachmentsListModel.h	Mon Jan 18 20:08:26 2010 +0200
@@ -189,7 +189,8 @@
 
     // <cmail> Touch
     void TreeListEventL( const TFsTreeListEvent aEvent, 
-        const TFsTreeItemId aId = KFsTreeNoneID );
+                         const TFsTreeItemId aId,
+                         const TPoint& aPoint );
     // </cmail>
 
 		
--- a/emailuis/emailui/inc/FreestyleEmailUiSettingsList.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiSettingsList.h	Mon Jan 18 20:08:26 2010 +0200
@@ -15,18 +15,15 @@
 *
 */
 
-
-
 #ifndef FSSETTINGSSYNCLIST_H
 #define FSSETTINGSSYNCLIST_H
 
 // SYSTEM INCLUDES
 #include <coecntrl.h>
 #include <e32cmn.h>
-//<cmail>
 #include "MFSMailRequestObserver.h"
-//</cmail>
 #include <AknWaitDialog.h>
+#include <aknlongtapdetector.h>
 
 // FORWARD DECLARATIONS
 class CFSMailClient;        
@@ -38,6 +35,7 @@
 
 typedef CAknSingleGraphicStyleListBox CSettingsListType;
 
+
 /**
  * Container class for CFsEmailSettingsList
  * 
@@ -47,10 +45,11 @@
     public CCoeControl, 
     public MEikListBoxObserver, 
     public MFSMailRequestObserver,
-    public MProgressDialogCallback
+    public MProgressDialogCallback,
+    public MAknLongTapDetectorCallBack
     {
-public:
-    // constructors and destructor
+public: // Constructors and destructor.
+
     static CFsEmailSettingsList* NewL( 
         const TRect& aRect, 
         const CCoeControl* aParent,
@@ -67,22 +66,50 @@
     
     virtual ~CFsEmailSettingsList();
 
-public:
-    // from base class CCoeControl
+
+private: // Construction.
+
+	void ConstructL( const TRect& aRect, const CCoeControl* aParent);
+    
+    CFsEmailSettingsList( CFreestyleEmailUiAppUi& aAppUi,
+						  CFSMailClient& aMailClient,
+						  CFsEmailSettingsListView& aView );
+
+
+public: // From base class CCoeControl.
+
     TInt CountComponentControls() const;
+
     CCoeControl* ComponentControl( TInt aIndex ) const;
 
-    TKeyResponse OfferKeyEventL( 
-            const TKeyEvent& aKeyEvent, 
-            TEventCode aType );
+    TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, 
+								 TEventCode aType );
     
     void HandleResourceChange( TInt aType );
+    
+    void HandlePointerEventL( const TPointerEvent& aPointerEvent );
+
     void AddAccountL();
-    void RemoveAccountL();
+
+    /**
+     * If confirmed by the user, will delete a mailbox.
+     * @return True if a mailbox was deleted, false otherwise.
+     */
+    TBool RemoveAccountL();
+
     void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
+
     TBool PIMSyncItemVisible();
 
-public:     
+
+public: // From MAknLongTapDetectorCallBack.
+	
+    void HandleLongTapEventL( const TPoint& aPenEventLocation, 
+							  const TPoint& aPenEventScreenLocation );
+
+
+public: // New methods.
+
     CSettingsListType* ListBox();
     
     static HBufC* CreateListBoxItemLC( 
@@ -192,8 +219,21 @@
     
     void PageUp();
     void PageDown();
-    
-public: 
+
+    /**
+     * Used to check if the currently selected item is a mailbox.
+     * @param True if the selected item is a mailbox. False otherwise.
+     */
+    TBool SelectedItemIsMailbox() const;
+
+    /**
+     * Removes the focus.
+     */
+    void ClearFocus(); 
+
+
+public:
+
     enum TControls
         {
         EListBox,
@@ -204,58 +244,65 @@
         EListBoxFirstUserImageIndex
         };  
     
-protected:
-    // from base class CCoeControl
+
+protected: // From base class CCoeControl.
+
     void SizeChanged();
-    
-protected: // from MProgressDialogCallback
+
+
+protected: // From MProgressDialogCallback.
+
     void DialogDismissedL( TInt aButtonId );
-    
-private:
-    // from base class CCoeControl
+
+
+private: // From base class CCoeControl.
+
     void Draw( const TRect& aRect ) const;
 
+
 private:
-    void ConstructL( 
-        const TRect& aRect, 
-        const CCoeControl* aParent);
-    
-    CFsEmailSettingsList(CFreestyleEmailUiAppUi& aAppUi, CFSMailClient& aMailClient, CFsEmailSettingsListView& aView );
+
     void HandleListBoxEventL( CEikListBox *aListBox, TListBoxEvent aEventType );
     void InitializeControlsL();
     void LayoutControls();
     void LoadAccountsToListL();
     void SetDefaultPIMAccountL();
     TPtrC GetMailBoxNameL( const CFSMailBox& aMailBox ) const;
-    
-private:
+
+
+private: // Data.
+
     enum TFsEmailSettingsSubViewType
         {
         EFsEmailSettingsMainListView,
         EFsEmailSettingsMailboxView,
         EFsEmailSettingsPimView
         };
-    TFsEmailSettingsSubViewType iCurrentSubView;
 
-    CSettingsListType*          iListBox;
-    CFreestyleEmailUiAppUi&     iAppUi;
-    CCoeControl*                iFocusControl;
-    CFSMailClient&              iMailClient;
-    TFSMailMsgId                iSelectedAccountInfo;
-    TUid                        iSelectedPluginSettings;
-    TInt                        iPIMSyncMailboxIndex;
-    TBool                       iPIMListActivation;
-    TBool                       iPIMServiceSettingsSelection;
-    CAknWaitDialog*             iWaitDialog;
-    TInt                        iMailboxCount;
-    TInt                        iDeleteMailboxId;
-    TInt                        iDeletedIndex;
-    TInt                        iPIMSyncCount;
-    TInt                        iSelectedSubListIndex;
-    CFsEmailSettingsListView& 	iView; 
-	// it is used to properly handle taps
-    // first tap highlights an item on the settings list, second tap selects the item
-    TInt                        iPrevSelected;
+    TFsEmailSettingsSubViewType iCurrentSubView;
+    CSettingsListType* iListBox;
+    CFreestyleEmailUiAppUi& iAppUi;
+    CCoeControl* iFocusControl;
+    CAknLongTapDetector* iLongTapDetector;
+    CFSMailClient& iMailClient;
+    TFSMailMsgId iSelectedAccountInfo;
+    TUid iSelectedPluginSettings;
+    TInt iPIMSyncMailboxIndex;
+    TBool iPIMListActivation;
+    TBool iPIMServiceSettingsSelection;
+    CAknWaitDialog* iWaitDialog;
+    TInt iMailboxCount;
+    TInt iDeleteMailboxId;
+    TInt iDeletedIndex;
+    TInt iPIMSyncCount;
+    TInt iSelectedSubListIndex;
+    CFsEmailSettingsListView& iView; 
+    TBool iLongTapEventConsumed;
+    
+	// Used to properly handle taps. First tap highlights an item on the
+    // settings list, second tap selects the item.
+    TInt iPrevSelected;
     };
-                
+
+
 #endif // FSSETTINGSSYNCLIST_H
--- a/emailuis/emailui/inc/FreestyleEmailUiSettingsListView.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiSettingsListView.h	Mon Jan 18 20:08:26 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005 - 2009 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -15,27 +15,28 @@
 *
 */
 
-
-
 #ifndef FSEMAILSETTINGSLISTVIEW_H
 #define FSEMAILSETTINGSLISTVIEW_H
 
-// SYSTEM INCLUDES
+//  SYSTEM INCLUDES
 #include <eiklbv.h>
 
+//  INTERNAL INCLUDES
 #include "FreestyleEmailUiViewBase.h"
 
-// FORWARD DECLARATIONS
+//  FORWARD DECLARATIONS
 class CFsEmailSettingsList;
 class CFSMailClient;
 class CFreestyleEmailUiAppUi;
 class CAsyncCallBack;
+class CAknStylusPopUpMenu;
+
 
 // CLASS DECLARATION
 class CFsEmailSettingsListView : public CFsEmailUiViewBase
 	{
-public:
-	// constructors and destructor
+public:	// Constructors and destructor.
+
 	static CFsEmailSettingsListView* NewL( 
 			CFSMailClient& aMailClient,
 			CFreestyleEmailUiAppUi* aAppUi,
@@ -48,64 +49,107 @@
 	
 	virtual ~CFsEmailSettingsListView();
 
-public:
-	// from base class CAknView
+
+private: // Construction.
+
+	CFsEmailSettingsListView( CAlfControlGroup& aControlGroup,
+							  CFreestyleEmailUiAppUi& aAppUi,
+							  CFSMailClient& aMailClient );
+
+    void ConstructL();
+
+
+public: // From base class CAknView.
+
+	/**
+	 * @return The UID for this view
+	 */
 	TUid Id() const;
+
+	/**
+	 * Handles commands for this view (override).
+	 * @param aCommand The ID of the command to handle.
+	 */
 	void HandleCommandL( TInt aCommand );
 
-public:
-	// set main list index in parent
+
+public: // New methods.
+
+	/**
+	 * Set the main list index in parent.
+	 * @param aIndex The index to set.
+	 */
 	void SetSelectedMainListIndex( TInt aIndex );
-	
-	// get main list index from parent
-	TInt GetSelectedMainListIndex()const;
+
+	/**
+	 * Returns the main list index from parent.
+	 * @return The list index.
+	 */
+	TInt GetSelectedMainListIndex() const;
 
 	void StartMailboxAsyncQueryL();
 
-protected:
-	// from base class CAknView
-    // <cmail> Toolbar
-    /*void DoActivateL(
-		const TVwsViewId& aPrevViewId,
-		TUid aCustomMessageId,
-		const TDesC8& aCustomMessage );*/
-    // </cmail> Toolbar
-    void ChildDoDeactivate();                
+	/**
+	 * Displays the pop-up menu.
+	 * @param aPosition The position of the pop-up menu.
+	 */
+	void DisplayStylusPopUpMenu( const TPoint& aPosition );
+	
+
+protected: // From base class CAknView.
+
+	/**
+	 * Handle status pane size change for this view (override).
+	 */
 	void HandleStatusPaneSizeChange();
-	void DynInitMenuPaneL(
-			TInt aResourceId, 
-			CEikMenuPane* aMenuPan );
+
+	void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPan );
 	
-// <cmail> Toolbar    
-private: // from
-    
+  
+protected: // From CFsEmailUiViewBase.
+
+	/**
+	 *	Handles user actions during activation of the view, 
+	 *	such as initializing the content.
+	 */
+    void ChildDoDeactivate();   
+
     /**
      * @see CFsEmailUiViewBase::ChildDoActivateL
      */
     void ChildDoActivateL( const TVwsViewId& aPrevViewId,
-            TUid aCustomMessageId,
-            const TDesC8& aCustomMessage );
-   
-// </cmail> Toolbar    
-	
-private:
-	CFsEmailSettingsListView( CAlfControlGroup& aControlGroup,
-	        CFreestyleEmailUiAppUi& aAppUi, CFSMailClient& aMailClient );
-    void ConstructL();
-    
+						   TUid aCustomMessageId,
+						   const TDesC8& aCustomMessage );
+
+
+private: // New methods.
+
 	void SetupStatusPaneL();
+
+	/** 
+	 * Sets application default title when leaving this view.
+	 */
 	void CleanupStatusPaneL();
 	
 	static TInt DisplayCreateQuery( TAny* aViewPtr );
+
 	void DisplayCreateMailboxNoteIfNeededL();	
-	
-private: 
+
+
+private: // Data.
+
 	CFsEmailSettingsList* iFsEmailSettingsList;
 	CFSMailClient& iMailClient;
 	TBool iMailboxSettings;
 	TInt iContainerListIndex;
+
 	// Async callback for create mailbox query      	
     CAsyncCallBack* iAsyncCallback;	
+
+    // A long tap detector and a pop-up menu that is invoked by long tap
+    // events. Used for e.g. deleting mail boxes.
+    CAknStylusPopUpMenu* iStylusPopUpMenu;
 	};
 
-#endif // FSEMAILSETTINGSLISTVIEW_H			
+#endif // FSEMAILSETTINGSLISTVIEW_H
+
--- a/emailuis/emailui/inc/FreestyleEmailUiViewBase.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiViewBase.h	Mon Jan 18 20:08:26 2010 +0200
@@ -317,6 +317,7 @@
     TBool iSendToBackgroundOnDeactivation;
     // View's active status
     TBool iViewActive;
+    TBool iWasActiveControlGroup;
     };
 
 #endif // __FREESTYLEEMAILUI_VIEWBASE_H__
--- a/emailuis/emailui/inc/FreestyleMessageHeaderHTML.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleMessageHeaderHTML.h	Mon Jan 18 20:08:26 2010 +0200
@@ -2,9 +2,9 @@
 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
+* under the terms of the License "Symbian Foundation License v1.0"
 * which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
@@ -19,6 +19,7 @@
 #define __CFREESTYLE_MESSAGE_HEADER_HTML_H__
 
 #include <e32base.h>
+#include <biditext.h>  
 
 #include "CFSMailMessage.h"
 #include "CFSMailAddress.h"
@@ -32,86 +33,121 @@
 class CFreestyleMessageHeaderHTML : public CBase
     {
 public:
-    IMPORT_C static void ExportL( CFSMailMessage& aMailMessage, RWriteStream& aWriteStream, TInt aVisibleWidth  );
-    IMPORT_C static void ExportL( CFSMailMessage& aMailMessage, RFile& aFile, TInt aVisibleWidth   );
-    IMPORT_C static void ExportL( CFSMailMessage& aMailMessage, RFs& aFs, const TPath& aFilePath, TInt aVisibleWidth  );
+    IMPORT_C static void ExportL( CFSMailMessage& aMailMessage, 
+                                  RWriteStream& aWriteStream, 
+                                  TInt aVisibleWidth, 
+                                  TInt aScrollPosition,
+                                  TBidiText::TDirectionality aDirectionality = TBidiText::ELeftToRight);
+    IMPORT_C static void ExportL( CFSMailMessage& aMailMessage, 
+                                  RFile& aFile, 
+                                  TInt aVisibleWidth, 
+                                  TInt aScrollPosition,
+                                  TBidiText::TDirectionality aDirectionality = TBidiText::ELeftToRight);
+    IMPORT_C static void ExportL( CFSMailMessage& aMailMessage, 
+                                  RFs& aFs, 
+                                  const TPath& aFilePath, 
+                                  TInt aVisibleWidth, 
+                                  TInt aScrollPosition,
+                                  TBidiText::TDirectionality aDirectionality = TBidiText::ELeftToRight);
     
-    IMPORT_C static CFreestyleMessageHeaderHTML* NewL( CFSMailMessage& aMailMessage, TInt aVisibleWidth   );
+    IMPORT_C static CFreestyleMessageHeaderHTML* NewL( CFSMailMessage& aMailMessage,
+                                                       RWriteStream& aWriteStream,
+                                                       TInt aVisibleWidth,
+                                                       TInt aScrollPosition,
+                                                       TBidiText::TDirectionality aDirectionality = TBidiText::ELeftToRight
+                                                       );
     
     ~CFreestyleMessageHeaderHTML();
     
-    IMPORT_C void ExportL( RWriteStream& aWriteStream ) const;
-    IMPORT_C void ExportL( RFile& aFile ) const;
-    IMPORT_C void ExportL( RFs& aFs, const TPath& aFilePath) const;
+    IMPORT_C void ExportL() const;
     
 private:
-    CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage, TInt aVisibleWidth   );
+    CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage,
+                                 RWriteStream& aWriteStream,
+                                 TInt aVisibleWidth,
+                                 TInt aScrollPosition,
+                                 TBidiText::TDirectionality aDirectionality);
     void ConstructL();
     
-    void HTMLStartL( RWriteStream& aWriteStream ) const;
-    void HTMLEndL( RWriteStream& aWriteStream ) const;
+    void HTMLStartL() const;
+    void HTMLEndL() const;
     
-    void ExportHTMLHeaderL( RWriteStream& aWriteStream ) const;
-    void HTMLHeaderStartL( RWriteStream& aWriteStream ) const;
-    void HTMLMetaL( RWriteStream& aWriteStream ) const;
-    void HTMLHeaderEndL( RWriteStream& aWriteStream ) const;
+    void ExportHTMLHeaderL() const;
+    void HTMLHeaderStartL() const;
+    void HTMLMetaL() const;
+    void HTMLHeaderEndL() const;
 
-    void ExportHTMLBodyL( RWriteStream& aWriteStream ) const;
-    void HTMLBodyStartL( RWriteStream& aWriteStream ) const;
-    void HTMLBodyEndL( RWriteStream& aWriteStream ) const;
+    void ExportHTMLBodyL() const;
+    void HTMLBodyStartL() const;
+    void HTMLBodyEndL() const;
     
-    void ExportSubjectL( RWriteStream& aWriteStream ) const;
-    void ExportFromL( RWriteStream& aWriteStream ) const;
-    void ExportToL( RWriteStream& aWriteStream ) const;
-    void ExportCcL( RWriteStream& aWriteStream ) const;
-    void ExportBccL( RWriteStream& aWriteStream ) const;
-    void ExportSentTimeL( RWriteStream& aWriteStream ) const;
-    void ExportAttachmentsL( RWriteStream& aWriteStream ) const;
+    void ExportSubjectL() const;
+    void ExportFromL() const;
+    void ExportToL() const;
+    void ExportCcL() const;
+    void ExportBccL() const;
+    void ExportSentTimeL() const;
+    void ExportAttachmentsL() const;
     
-    void ExportEmailAddressesL( RWriteStream& aWriteStream, 
-                                FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType, 
+    void ExportEmailAddressesL( FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType, 
                                 const RPointerArray<CFSMailAddress>& aEmailAddresses,
                                 const TDesC8& aRowId,
                                 const TDesC8& aTableId,
                                 TInt aHeaderTextResourceId ) const;
     
-    void AddEmailAddressL( RWriteStream& aWriteStream, 
-                           FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType, 
+    void AddEmailAddressL( FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType, 
                            const CFSMailAddress& aEmailAddress ) const;
     
-    void AddAttachmentL( RWriteStream& aWriteStream, CFSMailMessagePart& aAttachment ) const;
+    void AddAttachmentL( CFSMailMessagePart& aAttachment ) const;
 
-    void StartHyperlinkL( RWriteStream& aWriteStream, const TDesC8& aUrl ) const;
-    void EndHyperlinkL( RWriteStream& aWriteStream ) const;
+    void StartHyperlinkL( const TDesC8& aUrl ) const;
+    void EndHyperlinkL() const;
     
-    void AddImageL( RWriteStream& aWriteStream, const TDesC8& aImageUrl ) const;
-    void AddImageL( RWriteStream& aWriteStream, const TDesC8& aImageId, const TDesC8& aImageUrl, const TDesC8& aImageEvent ) const;
+    void AddImageL( const TDesC8& aImageUrl ) const;
+    void AddImageL( const TDesC8& aImageId, const TDesC8& aImageUrl, const TDesC8& aImageEvent ) const;
     
-    void StartHeaderTableL( RWriteStream& aWriteStream, const TDesC8& aTableId ) const;
-    void EndHeaderTableL( RWriteStream& aWriteStream ) const;
+    void StartHeaderTableL( const TDesC8& aTableId ) const;
+    void EndHeaderTableL() const;
 
-    void StartTableL( RWriteStream& aWriteStream, const TDesC8& aTableId ) const;
-    void EndTableL( RWriteStream& aWriteStream ) const;
+    void StartTableL( const TDesC8& aTableId ) const;
+    void EndTableL() const;
     
-    void AddShowDetailL( RWriteStream& aWriteStream ) const;
+    void AddShowDetailL() const;
     
     HBufC8* ClickImageEventL( const TDesC8& aImageName ) const;
 
-    void AddJavascriptL( RWriteStream& aWriteStream ) const;    
+    void AddJavascriptL() const;    
     
     HBufC8* HeadingTextLC( TInt aId ) const;
     HBufC8* HeadingTextLC( TInt aId, TInt aSize ) const;
     
-    void ExportInitialTableL( RWriteStream& aWriteStream ) const;
+    void ExportInitialTableL() const;
+    /**
+     * Function for generating follow up icon's HTML code.
+     * Returns NULL if no follow up flags are set.
+     *
+     * @param aShowText Whether to show icon's text after the icon or not.
+     */
+    HBufC8* HTMLHeaderFollowUpIconLC( TBool aShowText ) const;
     
-    void AddStyleSheetL( RWriteStream& aWriteStream ) const;
-    void StartDivL( RWriteStream& aWriteStream ) const;
-    void EndDivL( RWriteStream& aWriteStream ) const;
+    /**
+     * Function for generating priority icon's HTML code.
+     * Returns NULL if mail message's priority is normal.
+     *
+     * @param aShowText Whether to show icon's text after the icon or not.
+     */
+    HBufC8* HTMLHeaderPriorityIconLC( TBool aShowText ) const;
+    void AddStyleSheetL() const;
+    void StartDivL() const;
+    void EndDivL() const;
     
 private:
-    CFSMailMessage& iMailMessage; 
-    TInt            iVisibleWidth;
-    
+    CFSMailMessage&             iMailMessage; 
+    RWriteStream&               iWriteStream;
+    TInt                        iVisibleWidth;
+    TInt                        iScrollPosition;
+    TBidiText::TDirectionality  iDirectionality;
+     
     RPointerArray<CFSMailMessagePart> iAttachments;
 };
 
--- a/emailuis/emailui/inc/FreestyleMessageHeaderURL.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleMessageHeaderURL.h	Mon Jan 18 20:08:26 2010 +0200
@@ -28,6 +28,9 @@
 _LIT( KURLTypeBcc, "bcc" );
 _LIT( KURLTypeAttachment, "attachment" );
 _LIT( KURLTypeSeparator, "/" );
+_LIT( KURLHttpPrefix, "http://" );
+_LIT( KURLHttpsPrefix, "https://" );
+_LIT( KURLMailToPrefix, "mailto:" );
 
 class CFreestyleMessageHeaderURL : public CBase
     {
--- a/emailuis/emailui/inc/FreestyleMessageHeaderURLEventHandler.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/FreestyleMessageHeaderURLEventHandler.h	Mon Jan 18 20:08:26 2010 +0200
@@ -27,6 +27,8 @@
 class CFsEmailUiHtmlViewerView;
 class CFreestyleMessageHeaderURL;
 class TAttachmentData;
+class CAknStylusPopUpMenu;
+class CFSHtmlReloadAO;
 
 enum TLinkType
     {
@@ -43,7 +45,8 @@
     };
 
 class CFreestyleMessageHeaderURLEventHandler : public CBase, 
-                                               public MFreestyleMessageViewEventHandler
+                                               public MFreestyleMessageViewEventHandler,
+                                               public MEikMenuObserver
     {
 public:
     IMPORT_C static CFreestyleMessageHeaderURLEventHandler * NewL( 
@@ -52,6 +55,12 @@
     ~CFreestyleMessageHeaderURLEventHandler ();
     
     IMPORT_C TBool HandleEventL( const TDesC& aUri );
+    void DismissMenuAndReload();
+    TBool IsMenuVisible();
+    
+public: //From MEikMenuObserver
+	void ProcessCommandL(TInt aCommandId);
+	void SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/);
     
 protected:
     CFreestyleMessageHeaderURLEventHandler( CFreestyleEmailUiAppUi& aAppUi, 
@@ -62,13 +71,9 @@
     const TAttachmentData& FindAttachmentL( const CFreestyleMessageHeaderURL& aAttachmentUrl );
     void LaunchAttachmentMenuL( const TAttachmentData& aAttachment );
     void HandAttachmentActionMenuCommandL( TActionMenuCustomItemId aSelectedActionMenuItem,
-                                           const TAttachmentData& aAttachment );
-    
-    void LaunchEmailAddressMenuL( const CFreestyleMessageHeaderURL& iMessageHeaderURL );    
-    void HandleEmailAddressActionMenuCommandL( TActionMenuCustomItemId aSelectedActionMenuItem, 
-                                               const CFreestyleMessageHeaderURL& iMessageHeaderURL );
-    
-    void SaveEmailAsContactL( const TDesC& aEmailAddress );
+                                           const TAttachmentData& aAttachment );    
+    void LaunchEmailAddressMenuL( );
+    void LaunchWebAddressMenu( );
     
 private:
     CFreestyleMessageHeaderURL*     iMessageHeaderURL;
@@ -76,6 +81,13 @@
     CFsEmailUiHtmlViewerView&       iView;
     CFSMailMessage*                 iMailMessage;
     CFSEmailUiAttachmentsListModel* iAttachmentsListModel;
+    CAknStylusPopUpMenu*			iEmailAddressStylusPopup;  
+    CAknStylusPopUpMenu*			iAttachmentStylusPopup;
+    CAknStylusPopUpMenu*			iWebAddressStylusPopup;
+    HBufC* 							iUrl;
+    TBool                          iMenuVisible;
+    TBool                           iPendingReload;
+    CFSHtmlReloadAO*                iHTMLReloadAO; 
     };
 
 #endif //__CFREESTYLE_MESSAGE_HEADER_EVENTHANDLER_URL_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/emailui/inc/OverlayControl.h	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Symbian Foundation License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements overlay controls
+*
+*/
+
+#ifndef CTESTOVERLAYCONTROL_H
+#define CTESTOVERLAYCONTROL_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <coecntrl.h>
+#include <eikenv.h>
+#include <AknIconUtils.h>
+#include <freestyleemailui.mbg>
+#include "FreestyleEmailUiUtilities.h"
+
+// forward declarations.	
+class RWsSession;
+class TFsEmailUiUtility;
+
+// CLASS DECLARATION
+class COverlayControl;
+
+/**
+ * Observer for overlay control touch events
+ */
+class MOverlayControlObserver
+    {
+public:
+    virtual void HandleOverlayPointerEventL( COverlayControl* aControl, const TPointerEvent& aEvent ) = 0;
+    };
+
+/**
+ *  COverlayControl
+ */
+class COverlayControl : public CCoeControl
+	{
+public:
+	// Constructors and destructor
+
+	/**
+	 * Destructor.
+	 */
+	~COverlayControl();
+
+	/**
+	 * Two-phased constructor.
+	 * @param aParent if not NULL, parent control
+	 * @param aObserver observer for touch events
+	 * @param aRect initial size and position
+	 * @param aBitmapId bitmap to be used
+	 * @param aMaskId mask to be used
+	 */
+	static COverlayControl* NewL( CCoeControl* aParent, MOverlayControlObserver* aObserver, 
+	        const TRect& aRect, TInt aBitmapId, TInt aMaskId );
+
+	void Draw( const TRect& ) const;
+
+	void SetRect( const TRect& aRect );
+
+	void HandlePointerEventL(const TPointerEvent& aPointerEvent);
+	
+	void MakeVisible( TBool aVisible );
+
+	   /**
+	     * Update visual state
+	     * @param aButtonDown ETrue if button is in down state
+	     */
+	void UpdateButtonState( TBool aButtonDown );
+	
+private:
+
+	/**
+	 * Constructor for performing 1st stage construction
+	 * @param aObserver observer for touch events
+	 */
+	COverlayControl( MOverlayControlObserver* aObserver );
+
+	/**
+	 * EPOC default constructor for performing 2nd stage construction
+	 */
+	void ConstructL( CCoeControl* aParent, const TRect& aRect, TInt aBitmapId, TInt aMaskId );
+
+	/**
+	 * Make a copy of bitmap
+	 */
+    void CopyBitmapL( const CFbsBitmap& aSource, CFbsBitmap& aDest );
+    
+    /**
+     * Adjust alpha for the bitmap
+     * @param aBitmap bitmap to adjust
+     * @param aFactor factor to apply
+     */
+    void AdjustAlpha( CFbsBitmap& aBitmap, TReal aFactor );
+    
+    /**
+     * Update used mask according to current button state
+     */
+    void UpdateMask();
+	
+private:
+    
+	CFbsBitmap* iBitmap;
+	CFbsBitmap* iMask;
+	CFbsBitmap* iSolidMask;
+	TBool iDownState;
+	
+	MOverlayControlObserver* iObserver;
+	};
+
+#endif // CTESTOVERLAYCONTROL_H
--- a/emailuis/emailui/inc/ceuiemaillisttouchmanager.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/ceuiemaillisttouchmanager.h	Mon Jan 18 20:08:26 2010 +0200
@@ -89,8 +89,9 @@
      * @param aId Id of the node/item associated with the event. KFsTreeNoneID
      *            means that the event is not associated with a node/item.
      */
-    void TreeListEventL(const TFsTreeListEvent aEvent,
-            const TFsTreeItemId aId);
+    void TreeListEventL( const TFsTreeListEvent aEvent,
+                         const TFsTreeItemId aId,
+                         const TPoint& aPoint );
 
 private:
 
@@ -102,8 +103,9 @@
      * Helper class for handling long tap actions. 
      *
      * @since S60 v9.1
+     * @param aPoint Coordinates of the long tap event.
      */
-    void DoHandleLongTapL();
+    void DoHandleLongTapL( const TPoint& aPoint );
 
     /**
      * Helper class for handling actions. (Open viewer, expand/collapse etc.)
--- a/emailuis/emailui/inc/freestyleemailuimailboxdeleter.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/freestyleemailuimailboxdeleter.h	Mon Jan 18 20:08:26 2010 +0200
@@ -178,6 +178,11 @@
      * Deletes next mailbox in iMailboxesToDelete.
      */
     void DoDeleteNextMailboxL();
+    
+    /**
+     * Callback that calls DoDeleteNextMailboxL().
+     */
+    static TInt IdleCallbackL(TAny* aPtr);
                                           
 private: // data
 
@@ -195,6 +200,11 @@
 
     // Wait dialog
     CAknWaitDialog* iWaitDialog;
+    
+    // Idletimer. This is used in RequestResponseL() to ensure that
+    // iMailboxDeleteOperationId gets updated properly when deleting multiple
+    // mailboxes.
+    CIdle* iIdle;
         
     };
 
--- a/emailuis/emailui/inc/ncsattachmentfield.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/ncsattachmentfield.h	Mon Jan 18 20:08:26 2010 +0200
@@ -52,9 +52,11 @@
 
     TInt GetMinLabelLength() const;
     
-    void SetTextL( const TDesC& aText );
-    void SetTextL( const TDesC& aAttachmentName, const TDesC& aAttachmentSizeDesc );
+    void SetTextsLD( CDesCArray* aAttachmentNames, 
+                     CDesCArray* aAttachmentSizes );
 
+    TInt FocusedAttachmentLabelIndex();
+  
 public: // from MNcsControl
     
     TInt LineCount() const;
@@ -71,9 +73,7 @@
 
     const TDesC& GetLabelText() const;
     
-    // <cmail> Platform layout change       
     TInt LayoutLineCount() const;
-    // </cmail> Platform layout change
     
 public: // from CCoeControl
 
@@ -89,26 +89,28 @@
 
     void HandleResourceChange( TInt aType );
 
+    void HandlePointerEventL( const TPointerEvent& aPointerEvent );
+    
 private: // methods
     
-    CNcsAttachmentField( MNcsFieldSizeObserver* aSizeObserver, 
+    CNcsAttachmentField( TInt aLabelTextId,
+                         MNcsFieldSizeObserver* aSizeObserver, 
                          CNcsHeaderContainer* aParentControl );
         
-    void ConstructL( TInt aLabelTextId );
+    void ConstructL();
     
     void UpdateColors();
+    void UpdateColors( CNcsLabel* aLabel );
     
 	void UpdateFontSize();
+	void UpdateFontSize( CNcsLabel* aLabel );
 
-	// <cmail> Platform layout change 
     void LayoutControls();
 	
 	void UpdateIconPositions( const TRect& aRect );
-	// </cmail> Platform layout change 
 
-    void UpdateAttachmentTextL();
+    void UpdateAttachmentTextsL();
     
-    // <cmail> Platform layout change
     /**
      * Resizes icons 
      */
@@ -116,24 +118,24 @@
     
     TInt CreateIcons();
     void CreateIconsL();
-    // </cmail> Platform layout change
+    
+    void UpdateComponentArrayL();
+    
+    void UpdateSingleAttachmentLabelTextL( CNcsLabel* aLabel, TInt aIndex );
     
 private: // data
     
     CNcsHeaderContainer* iParentControl; // not owned
     
-    CNcsLabel* iAttachmentLabel;
+    // attachment labels (within the array) owned
+    RPointerArray<CNcsLabel> iAttachmentLabels;
     
-// <cmail> Platform layout change
-    //CFont* iLabelFont; // not owned, needs to be released in the end
-    //CFont* iEditorFont; // not owned, needs to be released in the end
     const CFont* iLabelFont; // not owned
     const CFont* iEditorFont; // not owned
-// </cmail>
     
-    HBufC* iAttachmentName;
-    HBufC* iAttachmentSizeDesc;
-        
+    CDesCArray* iAttachmentNames;
+    CDesCArray* iAttachmentSizes;
+    
     TInt iMaximumLabelLength;         
 
     TRgb iBgColor;
@@ -144,11 +146,10 @@
     CFbsBitmap* iAttachmentBitmap;
     CFbsBitmap* iAttachmentMask;
     TPoint iAttachmentIconPos;
-
-    // Action menu icon
-    CFbsBitmap* iActionMenuBitmap;
-    CFbsBitmap* iActionMenuMask;
-    TPoint iActionMenuIconPos;
+    
+    TInt iLabelTextId;
+    TInt iAttachmentLabelCount;
+    TInt iFocusedLabelIndex;
     };
 
 #endif
--- a/emailuis/emailui/inc/ncscomposeview.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/ncscomposeview.h	Mon Jan 18 20:08:26 2010 +0200
@@ -20,18 +20,16 @@
 #ifndef __CNCSCOMPOSEVIEW_H__
 #define __CNCSCOMPOSEVIEW_H__
 
-//<cmail>
 #include "CFSMailCommon.h"
 #include "MFSMailRequestObserver.h"
 #include <alf/alfenv.h>
 #include "AknServerApp.h"
 #include <AknProgressDialog.h>
 #include <MsgAttachmentUtils.h>
-//</cmail>
 
 #include "FreestyleEmailUiViewBase.h"
-#include"FreestyleEmailUiConstants.h"
-#include"FSComposerFetchLogic.h"
+#include "FreestyleEmailUiConstants.h"
+#include "FSComposerFetchLogic.h"
 #include "FreestyleEmailUi.hrh"
 #include "cmailcustomstatuspaneindicators.h"
 
@@ -51,8 +49,9 @@
 class CMsvSession;
 class CAknsLayeredBackgroundControlContext;
 class CFsAutoSaver;
-class CAknWaitDialog; //<cmail>
-class CActiveHelper; //<cmail>
+class CAknWaitDialog;
+class CActiveHelper;
+class CAknStylusPopUpMenu;
 
 
 const TInt KErrNcsComposeViewNotReady = KErrNotReady - 1000;
@@ -121,18 +120,6 @@
     * @param aCommand Command to be handled
     */
     void HandleCommandL( TInt aCommand );
-        
-    // <cmail> Toolbar
-    /**
-    * DoActivateL
-    * From CAknView, activate an AknView.
-    * @param aPrevViewId The id of the previous view
-    * @param aCustomMessageId message identifier
-    * @param aCustomMessage custom message provided when the view is changed
-    */
-    /*void DoActivateL( const TVwsViewId& aPrevViewId, TUid aCustomMessageId,
-                      const TDesC8& aCustomMessage );*/
-    // </cmail> Toolbar
 
     /**
     * ChildDoDeactivate
@@ -155,7 +142,8 @@
     * HandleDynamicVariantSwitchL
     * Recalculates component layout 
     */
-    void HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType );
+    void HandleDynamicVariantSwitchL( 
+            CFsEmailUiViewBase::TDynamicSwitchType aType );
         
 public: // from MAlfActionObserver
     	
@@ -168,19 +156,11 @@
 public: // new functions
 
     /**
-    * LaunchAttachmentActionMenuL
-    * Show action menu for the attachments line
+    * LaunchStylusPopupMenu
+    * Show stylus popup menu for the attachments line
     */
-    void LaunchAttachmentActionMenuL();
+    void LaunchStylusPopupMenu( const TPoint& aPenEventScreenLocation );
     
-	//<cmail>
-    /**
-    * DismissAttachmentActionMenuL
-    * Close action menu for the attachments line
-    */
-    void DismissAttachmentActionMenuL();
-    //</cmail>
-	
     /**
     * AttachmentsListControl
     * Returns pointer to attachment list control
@@ -200,7 +180,6 @@
     void CommitL( TBool aParseAddresses = ETrue, 
                   TFieldToCommit aFieldToCommit = EAllFields );
 
-    //<cmail>
     void DialogDismissedL( TInt aButtonId );
     
     void ShowFetchingWaitNoteL();
@@ -208,17 +187,13 @@
     TBool IsPreparedForExit();
     
     void AsyncExitL();
-    //</cmail>
     
-    // <cmail>
     void HandleContainerChangeRequiringToolbarRefresh();
-    // </cmail>
 
 protected:
 
     void ProcessCommandL( TInt aCommand );
 
-// <cmail> Toolbar    
 private: // from
     
     /**
@@ -248,7 +223,6 @@
      * Update toolbar items.
      */
     void RefreshToolbar();    
-// </cmail> Toolbar     
     
 private: // new functions
     
@@ -324,7 +298,7 @@
     void DoQuickTextL();
         
     /**
-    * DoAddAttachmentL
+    * AsyncAddAttachment
     * Add attachment file to message
     */
     static TInt AsyncAddAttachment( TAny* aSelfPtr );
@@ -353,7 +327,8 @@
     * Removes own address while doing reply all.
     * @param aAddressList The address list.
     */       
-    void RemoveOwnAddress( RPointerArray<CNcsEmailAddressObject>& aAddressList );
+    void RemoveOwnAddress( 
+            RPointerArray<CNcsEmailAddressObject>& aAddressList );
          
     /**
     * InitForwardFieldsL
@@ -364,9 +339,10 @@
     /**
     * IncludeMessageTextL
     * Inits body text when forwarding, replying, or opening draft message.
-    * @param aEnsureEmptyLineInBegin When true, the function ensures there's empty lines
-    *                                in the beginning of the message. I.e. line break(s)
-    *                                are inserted in front of any quote or signature
+    * @param aEnsureEmptyLineInBegin When true, the function ensures there's
+    *                                empty lines in the beginning of the 
+    *                                message. I.e. line break(s) are inserted
+    *                                in front of any quote or signature
     */        
     void IncludeMessageTextL( TBool aEnsureSpaceInBegin = EFalse );
         
@@ -457,14 +433,7 @@
     * Set reply/forward flag into original message if needed
     */
     void SetReplyForwardFlagL();
-        
-    /**
-    * LoadBackgroundImageAndSetBackgroundContextL
-    * Loads bg image and creates local skin item from that
-    * @param aRect Background rectangle
-    */
-//        void LoadBackgroundImageAndSetBackgroundContextL( const TRect& aRect );
-        
+         
     /**
     * MailBoxSupportsSmartReply
     * @return ETrue if mailbox supports smart reply
@@ -515,7 +484,11 @@
     * @param aMailClient Email framework client object.
     * @param aBgControl Background control.
     */
-    CNcsComposeView( CFreestyleEmailUiAppUi& aAppUi, CAlfEnv& aEnv, CAlfControlGroup& aControlGroup, CFSMailClient& aMailClient, CMsvSession& aMsvSession );
+    CNcsComposeView( CFreestyleEmailUiAppUi& aAppUi, 
+                     CAlfEnv& aEnv, 
+                     CAlfControlGroup& aControlGroup, 
+                     CFSMailClient& aMailClient, 
+                     CMsvSession& aMsvSession );
 
     /**
     * ConstructL
@@ -641,7 +614,6 @@
     
     CAknWaitDialog* iFetchWaitDialog; //<cmail>
     
-    //<cmail>
     //when some plugin makes fake sync, we need these
     TBool iFakeSyncGoingOn;
     TBool iFetchDialogCancelled;
@@ -651,16 +623,17 @@
     // we need to knwo when the method is running and block all the commands
     // during that time.
     TBool iExecutingDoExitL;
-   //</cmail>
     
     CAsyncCallBack* iAsyncAttachmentAdd;
     MsgAttachmentUtils::TMsgAttachmentFetchType iAttachmentAddType;
     
     // Status pane indicators (priority and followup)
     CCustomStatuspaneIndicators* iStatusPaneIndicators;
+    
+    // Popup menu for attachment list.
+    CAknStylusPopUpMenu* iStylusPopUpMenu;
     };
 
-//<cmail>
 /**
 * This class is used by CNcsComposeView for waiting its own async tasks.
 *  
@@ -676,7 +649,7 @@
         *
         * @return created instance of the CCacheSessionActiveHelper
         */
-        static CActiveHelper* NewL(CNcsComposeView* aComposeView );
+        static CActiveHelper* NewL( CNcsComposeView* aComposeView );
         
         /**
         * Destructor
@@ -693,7 +666,7 @@
         /**
         * Constructor
         */
-        CActiveHelper(CNcsComposeView* aSession);
+        CActiveHelper( CNcsComposeView* aSession );
 
         /**
         * Active object RunL
@@ -716,7 +689,6 @@
         CNcsComposeView* iComposeView;
             
     };
-//</cmail>
 
 #endif // CNCSCOMPOSEVIEW_H
 
--- a/emailuis/emailui/inc/ncscomposeviewcontainer.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/ncscomposeviewcontainer.h	Mon Jan 18 20:08:26 2010 +0200
@@ -29,10 +29,7 @@
 #include "ncsconstants.h"
 #include "FreestyleEmailUiContactHandlerObserver.h"
 #include "FreestyleEmailUi.hrh"
-
-//<cmail>
 #include <aknlongtapdetector.h>
-//</cmail>
 
 class CAknPhysics;
 class CNcsEditor;
@@ -76,7 +73,7 @@
 
     /**
     * Two-phased constructor.
-    * Create a CNcsComposeViewContainer object, which will draw itself to aRect
+    * Create a CNcsComposeViewContainer object, that draws itself to aRect
     * @param aView The parent view of this container.
     * @param aRect The rectangle this view will be drawn to.
     * @param aMailBox reference to current mailbox item.
@@ -105,21 +102,24 @@
     * Get addresses in TO-field.
     * @return Array of address objects.
     */
-    const RPointerArray<CNcsEmailAddressObject>& GetToFieldAddressesL( TBool aParseNow=ETrue );
+    const RPointerArray<CNcsEmailAddressObject>& 
+    GetToFieldAddressesL( TBool aParseNow=ETrue );
 
     /**
     * GetCcFieldAddressesL
     * Get addresses in CC-field.
     * @return Array of address objects.
     */
-    const RPointerArray<CNcsEmailAddressObject>& GetCcFieldAddressesL( TBool aParseNow=ETrue );
+    const RPointerArray<CNcsEmailAddressObject>& 
+    GetCcFieldAddressesL( TBool aParseNow=ETrue );
 
     /**
     * GetBccFieldAddressesL
     * Get addresses in BCC-field.
     * @return Array of address objects.
     */
-    const RPointerArray<CNcsEmailAddressObject>& GetBccFieldAddressesL( TBool aParseNow=ETrue );
+    const RPointerArray<CNcsEmailAddressObject>& 
+    GetBccFieldAddressesL( TBool aParseNow=ETrue );
 
     /**
     * GetSubjectLC
@@ -210,42 +210,48 @@
     * Set TO-field addresses.
     * @param aAddress Array of address objects.
     */
-    void SetToFieldAddressesL( RPointerArray<CNcsEmailAddressObject>& aAddress );
+    void SetToFieldAddressesL( 
+            RPointerArray<CNcsEmailAddressObject>& aAddress );
 
     /**
     * SetCcFieldAddressesL
     * Set CC-field addresses.
     * @param aAddress Array of address objects.
     */
-    void SetCcFieldAddressesL( RPointerArray<CNcsEmailAddressObject>& aAddress );
+    void SetCcFieldAddressesL( 
+            RPointerArray<CNcsEmailAddressObject>& aAddress );
 
     /**
     * SetBccFieldAddressesL
     * Set BCC-field addresses.
     * @param aAddress Array of address objects.
     */
-    void SetBccFieldAddressesL( RPointerArray<CNcsEmailAddressObject>& aAddress );
+    void SetBccFieldAddressesL( 
+            RPointerArray<CNcsEmailAddressObject>& aAddress );
 
     /**
     * AppendToFieldAddressesL
     * Append TO-field addresses.
     * @param aAddress Array of address objects.
     */
-    void AppendToFieldAddressesL( RPointerArray<CNcsEmailAddressObject>& aAddress );
+    void AppendToFieldAddressesL( 
+            RPointerArray<CNcsEmailAddressObject>& aAddress );
 
     /**
     * AppendCcFieldAddressesL
     * Append CC-field addresses.
     * @param aAddress Array of address objects.
     */
-    void AppendCcFieldAddressesL( RPointerArray<CNcsEmailAddressObject>& aAddress );
+    void AppendCcFieldAddressesL( 
+            RPointerArray<CNcsEmailAddressObject>& aAddress );
 
     /**
     * AppendBccFieldAddressesL
     * Append BCC-field addresses.
     * @param aAddress Array of address objects.
     */
-    void AppendBccFieldAddressesL( RPointerArray<CNcsEmailAddressObject>& aAddress );
+    void AppendBccFieldAddressesL( 
+            RPointerArray<CNcsEmailAddressObject>& aAddress );
 
     /**
     * SetSubjectL
@@ -278,24 +284,32 @@
     void SetMenuBar( CEikButtonGroupContainer* aMenuBar );
 
     /**
-    * SetAttachmentLabelTextL
-    * Set attachments label information.
-    * @param aText The text to be shown in the attachments label.
-    */
-    void SetAttachmentLabelTextL( const TDesC& aText );
+     * SetAttachmentLabelTextsL
+     * Set attachment label informations from arrays of file name and
+     * size informations. Some decorations may be added. 
+     * The file name will be truncated autoamtically if needed.
+     * The method takes ownership of the passed arrays.
+     * @param  aAttachmentNames Descriptor array containing file names.
+     * @param  aAttachmentSizes Descriptor array containing file sizes.
+     */
+    void SetAttachmentLabelTextsLD( CDesCArray* aAttachmentNames, 
+                                    CDesCArray* aAttachmentSizes );
 
     /**
-    * SetAttachmentLabelTextL
-    * Set attachments label information from file name and size information.
-    * Some decorations may be added. The file name will be truncated autoamtically if needed.
-    * @param    aAttachmentName     The name of the attachment to be shown
-    * @param    aAttachmentSizeDesc Descriptor containing size information about the file
-    */
-    void SetAttachmentLabelTextL( const TDesC& aAttachmentName, const TDesC& aAttachmentSizeDesc );
-
+     * FocusedAttachmentLabelIndex
+     * Returns the index of the attachment label that is currently focused
+     * @return Index of the focused attachment label.
+     */
+    TInt FocusedAttachmentLabelIndex();
+    
+    /**
+     * FixSemicolonL
+     * Fixes possibly missing semicolon in message header address fields.
+     */
     void FixSemicolonL();
     
     void HideAttachmentLabel();
+ 
     /**
     * IsCcFieldVisible
     * Test if CC-field is visible.
@@ -310,9 +324,6 @@
     */
     TBool IsBccFieldVisible() const;
 
-// <cmail> Removed unneeded IsFocusAif
-// </cmail>
-
     /**
     * IsFocusTo
     * Test if TO-field is focused.
@@ -384,15 +395,6 @@
     CRichText& BodyText();
 
     /**
-    * SetApplicationRect
-    * Sets the container rectangle.
-    * @param aRect The rectangle.
-    */
-	// <cmail>
-    // void SetApplicationRect( TRect aRect );
-	// </cmail>
-
-    /**
     * SetFocusToToField
     * Focuses the TO-field.
     */
@@ -464,10 +466,10 @@
     void HandleAttachmentsOpenCommandL();
 		
     /**
-    * LaunchAttachmentActionMenuL
+    * LaunchStylusPopupMenu
     * 
     */
-    void LaunchAttachmentActionMenuL();
+    void LaunchStylusPopupMenu( const TPoint& aPenEventScreenLocation );
     
     /**
     * AreAddressFieldsEmpty
@@ -488,10 +490,12 @@
     */
     void CommitL( TFieldToCommit aFieldToCommit = EAllFields );
 
-    //<cmail>
-    //sets up iSwitchChangeMskOff falg, which disables changes of MSK label if any popup dialog is open
+    /**
+     * SwitchChangeMskOff
+     * Sets up iSwitchChangeMskOff falg, which disables changes of MSK label
+     * if any popup dialog is open
+     */
     void SwitchChangeMskOff(TBool aTag);
-    //</cmail>
     
     /**
      * ScrollL
@@ -501,22 +505,20 @@
     
 public: // from CoeControl
 
-        /**
-        * Draw
-        * Draw this CNcsComposeViewContainer to the screen.
-        * @param aRect the rectangle of this view that needs updating
-        */
+    /**
+    * Draw
+    * Draw this CNcsComposeViewContainer to the screen.
+    * @param aRect the rectangle of this view that needs updating
+    */
     void Draw( const TRect& aRect ) const;
     
     void SetMskL();
     
-	//<cmail>
     /**
     * Handle pointer event
     * 
     */
     void HandlePointerEventL( const TPointerEvent& aPointerEvent );
-    //</cmail>
 	
     /**
     * OfferKeyEventL
@@ -553,10 +555,11 @@
     
 public: // from MEikScrollBarObserver
     
-        /**
-        * HandleScrollEventL
-        */
-    void HandleScrollEventL( CEikScrollBar* aScrollBar, TEikScrollEvent aEventType );
+    /**
+    * HandleScrollEventL
+    */
+    void HandleScrollEventL( 
+            CEikScrollBar* aScrollBar, TEikScrollEvent aEventType );
 
 public: // from MFSEmailUiContactHandlerObserver
 
@@ -570,17 +573,17 @@
 
 public: // from base class MEikEdwinSizeObserver
     
-    TBool HandleEdwinSizeEventL( CEikEdwin* aEdwin, TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize );
+    TBool HandleEdwinSizeEventL( CEikEdwin* aEdwin, 
+            TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize );
     
 public:  // from MNcsFieldSizeObserver
 
     TBool UpdateFieldSizeL();
     void UpdateFieldPosition( CCoeControl* aAnchor );
 
-    //<cmail>
 private:  //From MAknLongTapDetectorCallBack
-    void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation );
-    //</cmail>
+    void HandleLongTapEventL( const TPoint& aPenEventLocation, 
+            const TPoint& aPenEventScreenLocation );
     
 private:
     
@@ -612,9 +615,13 @@
     *                 in moving of display.
     */
     void UpdateScreenPositionL( const TUint& aKeyCode = EKeyNull );
-    //<cmail>
+
+    /**
+     * CalculateSeparatorLineSecondaryColor
+     * @return Separator line secondary color
+     */
     TRgb CalculateSeparatorLineSecondaryColor();
-    //</cmail>
+    
     void UpdatePhysicsL();
 
 private: // from MAknPhysicsObserver
@@ -622,7 +629,8 @@
    /**
     * @see MAknPhysicsObserver::ViewPositionChanged
     */
-   virtual void ViewPositionChanged( const TPoint& aNewPosition, TBool aDrawNow, TUint aFlags );
+   virtual void ViewPositionChanged( const TPoint& aNewPosition, 
+           TBool aDrawNow, TUint aFlags );
 
    /**
     * @see MAknPhysicsObserver::PhysicEmulationEnded
@@ -656,9 +664,11 @@
     */
     CCoeControl* iFocused;
     
-    //<cmail>
+    /**
+     * Long tap detector.
+     * Owned.
+     */
     CAknLongTapDetector* iLongTapDetector;
-    //</cmail>
     
     /**
     *
@@ -700,9 +710,8 @@
     CFSMailBox& iMailBox;
 		
     TAppendAddresses iAppendAddresses;
-    //<cmail>
+
     TInt iSeparatorLineYPos;
-    //</cmail>
     
     // panning related
     CAknPhysics* iPhysics;
--- a/emailuis/emailui/inc/ncsconstants.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/ncsconstants.h	Mon Jan 18 20:08:26 2010 +0200
@@ -34,6 +34,8 @@
 
 const TInt KHeaderDetailTextPaneVariety = 4;
 
+const TInt KNoAttachmentLabelFocused = -1;
+
 enum TMsgPriority 
     {
     EMsgPriorityLow,
--- a/emailuis/emailui/inc/ncscontrol.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/ncscontrol.h	Mon Jan 18 20:08:26 2010 +0200
@@ -53,12 +53,10 @@
 	virtual TInt CursorPosition() const = 0;
 	virtual void Reposition(TPoint& aPt, TInt aWidth) = 0;
     virtual const TDesC& GetLabelText() const = 0;
-    // <cmail> Platform layout change    
     virtual TInt LayoutLineCount() const = 0;
-    // </cmail> Platform layout change    
 
 protected:
-    
+
     MNcsFieldSizeObserver* iSizeObserver;
 
     };
@@ -67,9 +65,7 @@
     {
 public:
 
-    // <cmail> Plaform layout change
 	CNcsLabel( const CCoeControl& aParent, MNcsFieldSizeObserver* aSizeObserver );
-	// </cmail> Plaform layout change
 
 public:
 
@@ -80,30 +76,23 @@
 	inline virtual TInt CursorPosition() const;
 	virtual void Reposition( TPoint& aPt, TInt aWidth );    
     inline virtual const TDesC& GetLabelText() const;
-    // <cmail> Platform layout change       
     TInt LayoutLineCount() const;
-    // </cmail> Platform layout change    
+    virtual void FocusChanged( TDrawNow aDrawNow );
+    TRect TextHitAreaRect();
 
-    virtual void FocusChanged( TDrawNow aDrawNow );
-    
 protected: // methods from base class
 
     virtual void HandleResourceChange( TInt aType );    
 private: // methods used internally
 
-// <cmail> Plaform layout change
 private: // data
-    
+
     void UpdateTextColor();
-       
     const CCoeControl& iParent;
-    
-// </cmail> Plaform layout change
     };
 
 #include "ncscontrol.inl"
 
 #endif // __NCS_CONTROL_H__
 
-
 // End of File
--- a/emailuis/emailui/inc/ncsheadercontainer.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/ncsheadercontainer.h	Mon Jan 18 20:08:26 2010 +0200
@@ -20,14 +20,10 @@
 #ifndef __NCSEMAILHEADERUI_H__
 #define __NCSEMAILHEADERUI_H__
 
-//<cmail>
 #include <aknlongtapdetector.h>
-//</cmail>
 
-//<cmail>
 #include "cpbkxremotecontactlookupenv.h"
 #include "cpbkxremotecontactlookupserviceuicontext.h"
-//</cmail>
 
 #include "FreestyleEmailUi.hrh"
 #include "ncsaddressinputfield.h"
@@ -224,9 +220,9 @@
 	
 	void SetMenuBar( CEikButtonGroupContainer* aMenuBar );
 	
-	void SetAttachmentLabelTextL( const TDesC& aText );
-    void SetAttachmentLabelTextL( const TDesC& aAttachmentName, const TDesC& aAttachmentSizeDesc );
-
+    void SetAttachmentLabelTextsLD( CDesCArray* aAttachmentNames, 
+                                    CDesCArray* aAttachmentSizes );
+    TInt FocusedAttachmentLabelIndex();
     void ShowAttachmentLabelL();
 	void HideAttachmentLabel();
 
@@ -246,9 +242,6 @@
 
 	TBool IsCcFieldVisible() const;
 
-// <cmail> Removed unneeded IsFocusAif
-// </cmail>
-
 	TBool IsFocusAttachments() const;
 
 	TBool IsFocusTo() const;
@@ -286,18 +279,16 @@
 		TInt aControlId );
 
 	//Set Middlesoftkey
-	//void CNcsHeaderContainer::SetMsk();
 	void SetMskL();
 	
-	//<cmail>
 	void HandlePointerEventL( const TPointerEvent& aPointerEvent );
 	
 	void OpenPhonebookL();
 	
-	void HandleLongTapL( const TPoint& aPenEventLocation );
+	void HandleLongTap( const TPoint& aPenEventLocation, 
+						 const TPoint& aPenEventScreenLocation );
 
     TBool NeedsLongTapL( const TPoint& aPenEventLocation );
-	//</cmail>
 	
 	// Process a key event
 	TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
@@ -343,18 +334,12 @@
 
     void HandleDynamicVariantSwitchL();
 
-    //<cmail>
     // sets up iSwitchChangeMskOff falg 
     void SwitchChangeMskOff(TBool aTag);
-    // </cmail>     
     
-    // <cmail> Platform layout change    
     virtual TInt LayoutLineCount() const;
-    // </cmail> Platform layout change    
 
-// <cmail>
     TBool IsAddressInputField( const CCoeControl* aControl ) const;
-// </cmail>
 
     TBool IsRemoteSearchInprogress() const;
 private: // Function members
@@ -393,19 +378,18 @@
     * @return Selected email address object.
     */
     CNcsEmailAddressObject* ExecuteRemoteSearchL(
-        CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason& aExitReason,
+        CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason& 
+            aExitReason,
         const TDesC& aSearchText );
 
     void ChangeMskCommandL( TInt aLabelResourceId );
 
     void CommitFieldL( CCoeControl* aField );
 
-//<cmail>
 private:  //From MAknLongTapDetectorCallBack
     
-    void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation );
-
-//</cmail>
+    void HandleLongTapEventL( const TPoint& aPenEventLocation, 
+            const TPoint& aPenEventScreenLocation );
     
 private: // Data members
 
@@ -415,13 +399,9 @@
     */
     CCoeControl& iParent;
 
-    // <cmail> Platform layout change
     MNcsFieldSizeObserver& iFieldSizeObserver;
-    // </cmail> Platform layout change
     
-	//<cmail>
     CAknLongTapDetector*      iLongTapDetector;
-    //</cmail>
 	
     CEikButtonGroupContainer* iMenuBar;
     
@@ -443,16 +423,10 @@
 
 	CFSMailBox& iMailBox;
 	
-    // <cmail>
     //flag which disables changes of MSK label if any popup dialog is open
     TBool iSwitchChangeMskOff;
-    // </cmail>
-	
- 	// <cmail>
-    //CFbsBitmap* iBackgroundBitmap;
-    //CFbsBitmap* iBackgroundMask;
+
     CAknsBasicBackgroundControlContext* iBgContext;
-	// </cmail>
     
     TBool iLongTapEventConsumed;
     TBool iRALInProgress;
--- a/emailuis/emailui/inc/ncsutility.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/inc/ncsutility.h	Mon Jan 18 20:08:26 2010 +0200
@@ -22,9 +22,7 @@
 
 #include <cntitem.h>
 #include "CFSMailCommon.h"
-//<cmail>
 #include "ncsaddressinputfield.h"
-//</cmail>
 
 class CNcsEmailAddressObject;
 class CFSMailAddress;
@@ -33,12 +31,10 @@
 class CFSMailMessage;
 class CFSMailBox;
 class CFSMailClient;
-// <cmail> Platform layout change 
 class CEikLabel;
 class CEikEdwin;
 class CAknButton;
 class CCoeControl;
-// </cmail> Platform layout change 
 
 struct TNcsMeasures
 	{
@@ -61,14 +57,12 @@
 */
 class NcsUtility
     {
-// <cmail> Platform layout changes
 public:
     enum THeaderDetailIcon
         {
         EIconFront,
         EIconBack
         };
-// </cmail> Platform layout changes
 
 public:
     static void CompleteRelativePathL( const TDesC& aRelativePath, TPtr& aAbsolutePath );
@@ -107,7 +101,6 @@
 
     static CFont* GetNearestFontL( TInt aLogicalFontId, TInt aHeightPixels );
 
-// <cmail> Platform layout changes
     enum TNcsLayoutFont
         {
         ENcsHeaderCaptionFont,
@@ -116,7 +109,6 @@
         };
 
     static const CFont* GetLayoutFont( const TRect& aParent, TNcsLayoutFont aUsage );
-// </cmail> Platform layout changes
 
     static TBool IsReplyForwardQuoteReadOnly( const CFSMailBox& aMailBox );
 
@@ -131,7 +123,6 @@
     		const TFSMailMsgId& aFolderId,
     		const TFSMailMsgId& aMsgId );
 
-    // <cmail> Platform layout changes
     static TRect HeaderCaptionPaneRect( const TRect& aParent );
 
     static TRect HeaderDetailPaneRect( const TRect& aParent, const TInt aRows, TBool aSameRow = EFalse );
@@ -143,7 +134,7 @@
     static TRect ListCmailPaneRect( const TRect& aParent );
 
     static TRect ListCmailScrollbarRect( const TRect& aParent );
-    //<cmail>
+
     static TSize SeparatorSizeInThisResolution();
     static TInt ComposerLeftMarginInPixels( const TRect& aParent );
     static TInt ComposerRightMarginInPixels( const TRect& aParent );
@@ -151,20 +142,19 @@
 
     static void LayoutCaptionLabel( CEikLabel* aLabel, const TRect& aParentRect );
     
-    //<cmail>
     static void LayoutCaptionButton( CAknButton* aButton, const TRect& aParentRect);
-    //</cmail>
-    static void LayoutDetailLabel( CEikLabel* aLabel, const TRect& aParentRect );
+
+    static void LayoutDetailLabel( CEikLabel* aLabel, const TRect& aParentRect, TInt aRow = 0 );
 
     static void LayoutDetailEdwin( CEikEdwin* aEdwin, const TRect& aParentRect, const TInt aLineCount, const TBool aBackIcon );
-    //<cmail>
+
     static void LayoutDetailEdwinTouch( CEikEdwin* aEdwin, const TRect& aParentRect,
                                         const TInt aLineCount, const TBool aBackIcon  );
-    //</cmail>
+
     static TPoint HeaderControlPosition( const TRect& aParentRect, const TInt aCurrentLine );
 
     static void LayoutHeaderControl( CCoeControl* aControl, const TRect& aParentRect, const TInt aCurrentLine, const TInt aNumberOfLines );
-    //<cmail>
+
     static void LayoutBodyEdwin( CEikEdwin* aEdwin, const TRect& aParentRect, const TInt aCurrentLine, const TInt aNumberOfLines,
             TInt& aSeparatorYPosition );
     static TRgb CalculateSeparatorLineSecondaryColor( TInt aDegree, TRgb aStartColor );
--- a/emailuis/emailui/loc/freestyleemailui.loc	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/loc/freestyleemailui.loc	Mon Jan 18 20:08:26 2010 +0200
@@ -269,14 +269,14 @@
 //
 #define qtn_fse_launcher_options_cancel_sync	"Cancel synchronisation"
 
-// d:Submenu item
-// l:list_single_popup_submenu_pane_t1
+// d:Option menu item
+// l:list_single_pane_t1_cp2/opt3
 // r:TB9.1
 //
 #define qtn_fse_message_list_options_mark	"Mark"
 
-// d:Submenu item
-// l:list_single_popup_submenu_pane_t1
+// d:Option menu item
+// l:list_single_pane_t1_cp2/opt3
 // r:TB9.1
 //
 #define qtn_fse_message_list_options_unmark	"Unmark"
@@ -2612,3 +2612,123 @@
 // r:TB9.2
 //
 #define qtn_fse_mail_deleted_note "Mail deleted"
+
+// d:Submenu item
+// l:list_single_popup_submenu_pane_t1
+// r:TB9.2
+//
+#define qtn_cmail_message_list_options_sub_all	"All"
+
+// d:Submenu item
+// l:list_single_popup_submenu_pane_t1
+// r:TB9.2
+//
+#define qtn_cmail_message_list_options_sub_mark	"Mark"
+
+// d:Submenu item
+// l:list_single_popup_submenu_pane_t1
+// r:TB9.2
+//
+#define qtn_cmail_message_list_options_sub_mark_all	"All"
+
+// d:"Actions" submenu item
+// l:list_single_pane_t1_cp2/opt3
+// r:TB9.2
+//
+#define qtn_cmail_message_list_options_actions "Actions"
+
+// d:Options menu item
+// l:list_single_pane_t1_cp2
+// r:TB9.2
+//
+#define qtn_cmail_message_list_options_send_receive	"Send and receive now"
+
+// d:Options menu item for moving message to another folder
+// l:list_single_popup_submenu_pane_t1
+// r:TB9.2
+//
+#define qtn_cmail_options_moveto_folder "Move to folder"
+
+// d:Mail item follow up icon text in the list control
+// l:list_single_cmail_header_caption_pane_t1
+// r:TB9.2
+//
+#define qtn_cmail_header_followup	"Follow up"
+
+// d:Mail item follow up completed icon text in the list control
+// l:list_single_cmail_header_caption_pane_t1
+// r:TB9.2
+//
+#define qtn_cmail_header_completed	"Completed"
+
+// d:Mail item high priority icon text in the list control
+// l:list_single_cmail_header_caption_pane_t1
+// r:TB9.2
+//
+#define qtn_cmail_header_high_prio	"High priority"
+
+// d:Mail item low priority icon text in the list control
+// l:list_single_cmail_header_caption_pane_t1
+// r:TB9.2
+//
+#define qtn_cmail_header_low_prio	"Low priority"
+
+// d:Send email menu item
+// l:list_single_touch_menu_pane_t1
+// r:TB9.2
+//
+#define qtn_cmail_popup_send_email "Send email"
+
+// d:Copy to clipboard menu item
+// l:list_single_touch_menu_pane_t1
+// r:TB9.2
+//	
+#define qtn_cmail_popup_copy_address	"Copy address"
+
+// d:Searches the contact information of the person who’s the address is. 
+// l:list_single_touch_menu_pane_t1
+// r:TB9.2
+//	
+#define qtn_cmail_popup_search_server	"Search from server"
+
+// d:Opens the attachment 
+// l:list_single_touch_menu_pane_t1
+// r:TB9.2
+//	
+#define qtn_cmail_popup_open	"Open"
+
+// d:Save the attachment 
+// l:list_single_touch_menu_pane_t1
+// r:TB9.2
+//	
+#define qtn_cmail_popup_save	"Save"
+
+// d:Save all the attachments
+// l:list_single_touch_menu_pane_t1
+// r:TB9.2
+//	
+#define qtn_cmail_popup_save_all	"Save all"
+
+// d:Shown if the tapped attachment is being downloaded. Cancels the download.  
+// l:list_single_touch_menu_pane_t1
+// r:TB9.2	
+#define qtn_cmail_popup_cancel_download	"Cancel download"
+
+// d:Adds the web address to browser bookmarks.
+// l:list_single_touch_menu_pane_t1
+// r:TB9.2
+//	
+#define qtn_cmail_popup_add_bookmark	"Add to bookmarks"
+
+// d:Open attachment in compose view
+// l:list_single_touch_menu_pane_t1
+// r:TB9.2
+//
+#define qtn_mail_stylus_popup_open	"Open"
+
+// d:Remove attachment in compose view
+// l:list_single_touch_menu_pane_t1
+// r:TB9.2
+//
+#define qtn_mail_stylus_popup_remove	"Remove"
+
--- a/emailuis/emailui/rom/freestyleemailui.iby	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/rom/freestyleemailui.iby	Mon Jan 18 20:08:26 2010 +0200
@@ -35,9 +35,14 @@
 //<cmail> files for html display
 data=DATAZ_\private\2001E277\HtmlFile\attachment.gif private\2001E277\HtmlFile\attachment.gif
 data=DATAZ_\private\2001E277\HtmlFile\email.html private\2001E277\HtmlFile\email.html
+data=DATAZ_\private\2001E277\HtmlFile\email_rtl.html private\2001E277\HtmlFile\email_rtl.html
 data=DATAZ_\private\2001E277\HtmlFile\header.js private\2001E277\HtmlFile\header.js
 data=DATAZ_\private\2001E277\HtmlFile\plus.gif private\2001E277\HtmlFile\plus.gif
 data=DATAZ_\private\2001E277\HtmlFile\minus.gif private\2001E277\HtmlFile\minus.gif
+data=DATAZ_\private\2001E277\HtmlFile\follow_up.png private\2001E277\HtmlFile\follow_up.png
+data=DATAZ_\private\2001E277\HtmlFile\follow_up_complete.png private\2001E277\HtmlFile\follow_up_complete.png
+data=DATAZ_\private\2001E277\HtmlFile\todo_high_add.png private\2001E277\HtmlFile\todo_high_add.png
+data=DATAZ_\private\2001E277\HtmlFile\todo_low_add.png private\2001E277\HtmlFile\todo_low_add.png
 
 #endif //FF_EMAIL_FRAMEWORK
 
--- a/emailuis/emailui/sis/commonemail.pkg	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/sis/commonemail.pkg	Mon Jan 18 20:08:26 2010 +0200
@@ -69,9 +69,14 @@
 
 "\epoc32\data\z\private\2001E277\HtmlFile\attachment.gif"        - "c:\private\2001E277\HtmlFile\attachment.gif"
 "\epoc32\data\z\private\2001E277\HtmlFile\email.html"            - "c:\private\2001E277\HtmlFile\email.html"
+"\epoc32\data\z\private\2001E277\HtmlFile\email_rtl.html"            - "c:\private\2001E277\HtmlFile\email_rtl.html"
 "\epoc32\data\z\private\2001E277\HtmlFile\header.js"             - "c:\private\2001E277\HtmlFile\header.js"
 "\epoc32\data\z\private\2001E277\HtmlFile\plus.gif"              - "c:\private\2001E277\HtmlFile\plus.gif"
 "\epoc32\data\z\private\2001E277\HtmlFile\minus.gif"             - "c:\private\2001E277\HtmlFile\minus.gif"
+"\epoc32\data\z\private\2001E277\HtmlFile\follow_up.png"         - "c:\private\2001E277\HtmlFile\follow_up.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\follow_up_complete.png" - "c:\private\2001E277\HtmlFile\follow_up_complete.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\todo_high_add.png"     - "c:\private\2001E277\HtmlFile\todo_high_add.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\todo_low_add.png"      - "c:\private\2001E277\HtmlFile\todo_low_add.png"
 
 ; Emailuis / gsemailsettings
 "\epoc32\release\armv5\urel\GSEmailSettingsPluginDll.dll"        - "c:\sys\bin\GSEmailSettingsPluginDll.dll"
--- a/emailuis/emailui/sis/commonemail_loc.pkg	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/sis/commonemail_loc.pkg	Mon Jan 18 20:08:26 2010 +0200
@@ -73,6 +73,10 @@
 "\epoc32\data\z\private\2001E277\HtmlFile\header.js"             - "c:\private\2001E277\HtmlFile\header.js"
 "\epoc32\data\z\private\2001E277\HtmlFile\plus.gif"              - "c:\private\2001E277\HtmlFile\plus.gif"
 "\epoc32\data\z\private\2001E277\HtmlFile\minus.gif"             - "c:\private\2001E277\HtmlFile\minus.gif"
+"\epoc32\data\z\private\2001E277\HtmlFile\follow_up.png"         - "c:\private\2001E277\HtmlFile\follow_up.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\follow_up_complete.png" - "c:\private\2001E277\HtmlFile\follow_up_complete.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\todo_high_add.png"     - "c:\private\2001E277\HtmlFile\todo_high_add.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\todo_low_add.png"      - "c:\private\2001E277\HtmlFile\todo_low_add.png"
 
 ; Emailuis / gsemailsettings
 "\epoc32\release\armv5\urel\GSEmailSettingsPluginDll.dll"        - "c:\sys\bin\GSEmailSettingsPluginDll.dll"
--- a/emailuis/emailui/sis/commonemail_udeb.pkg	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/sis/commonemail_udeb.pkg	Mon Jan 18 20:08:26 2010 +0200
@@ -57,9 +57,14 @@
 
 "\epoc32\data\z\private\2001E277\HtmlFile\attachment.gif"        - "c:\private\2001E277\HtmlFile\attachment.gif"
 "\epoc32\data\z\private\2001E277\HtmlFile\email.html"            - "c:\private\2001E277\HtmlFile\email.html"
+"\epoc32\data\z\private\2001E277\HtmlFile\email_rtl.html"            - "c:\private\2001E277\HtmlFile\email_rtl.html"
 "\epoc32\data\z\private\2001E277\HtmlFile\header.js"             - "c:\private\2001E277\HtmlFile\header.js"
 "\epoc32\data\z\private\2001E277\HtmlFile\plus.gif"              - "c:\private\2001E277\HtmlFile\plus.gif"
 "\epoc32\data\z\private\2001E277\HtmlFile\minus.gif"             - "c:\private\2001E277\HtmlFile\minus.gif"
+"\epoc32\data\z\private\2001E277\HtmlFile\follow_up.png"         - "c:\private\2001E277\HtmlFile\follow_up.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\follow_up_complete.png" - "c:\private\2001E277\HtmlFile\follow_up_complete.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\todo_high_add.png"     - "c:\private\2001E277\HtmlFile\todo_high_add.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\todo_low_add.png"      - "c:\private\2001E277\HtmlFile\todo_low_add.png"
 
 ; Emailuis / gsemailsettings
 "\epoc32\release\armv5\udeb\GSEmailSettingsPluginDll.dll"        - "c:\sys\bin\GSEmailSettingsPluginDll.dll"
--- a/emailuis/emailui/sis/commonemail_udeb_loc.pkg	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/sis/commonemail_udeb_loc.pkg	Mon Jan 18 20:08:26 2010 +0200
@@ -61,6 +61,10 @@
 "\epoc32\data\z\private\2001E277\HtmlFile\header.js"             - "c:\private\2001E277\HtmlFile\header.js"
 "\epoc32\data\z\private\2001E277\HtmlFile\plus.gif"              - "c:\private\2001E277\HtmlFile\plus.gif"
 "\epoc32\data\z\private\2001E277\HtmlFile\minus.gif"             - "c:\private\2001E277\HtmlFile\minus.gif"
+"\epoc32\data\z\private\2001E277\HtmlFile\follow_up.png"         - "c:\private\2001E277\HtmlFile\follow_up.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\follow_up_complete.png" - "c:\private\2001E277\HtmlFile\follow_up_complete.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\todo_high_add.png"     - "c:\private\2001E277\HtmlFile\todo_high_add.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\todo_low_add.png"      - "c:\private\2001E277\HtmlFile\todo_low_add.png"
 
 ; Emailuis / gsemailsettings
 "\epoc32\release\armv5\udeb\GSEmailSettingsPluginDll.dll"        - "c:\sys\bin\GSEmailSettingsPluginDll.dll"
--- a/emailuis/emailui/sis/commonemailstub.pkg	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/sis/commonemailstub.pkg	Mon Jan 18 20:08:26 2010 +0200
@@ -35,9 +35,14 @@
 ""-"z:\resource\apps\freestyleemailui.mif"
 ""-"z:\private\2001E277\HtmlFile\attachment.gif"
 ""-"z:\private\2001E277\HtmlFile\email.html"
+""-"z:\private\2001E277\HtmlFile\email_rtl.html"
 ""-"z:\private\2001E277\HtmlFile\header.js"
 ""-"z:\private\2001E277\HtmlFile\plus.gif"
 ""-"z:\private\2001E277\HtmlFile\minus.gif"
+""-"z:\private\2001E277\HtmlFile\follow_up.png"
+""-"z:\private\2001E277\HtmlFile\follow_up_complete.png"
+""-"z:\private\2001E277\HtmlFile\todo_high_add.png"
+""-"z:\private\2001E277\HtmlFile\todo_low_add.png"
 
 
 ; emailuis / gsemailsettings
--- a/emailuis/emailui/sis/emailui.pkg	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/sis/emailui.pkg	Mon Jan 18 20:08:26 2010 +0200
@@ -41,9 +41,14 @@
 
 "\epoc32\data\z\private\2001E277\HtmlFile\attachment.gif"        - "c:\private\2001E277\HtmlFile\attachment.gif"
 "\epoc32\data\z\private\2001E277\HtmlFile\email.html"            - "c:\private\2001E277\HtmlFile\email.html"
+"\epoc32\data\z\private\2001E277\HtmlFile\email_rtl.html"            - "c:\private\2001E277\HtmlFile\email_rtl.html"
 "\epoc32\data\z\private\2001E277\HtmlFile\header.js"             - "c:\private\2001E277\HtmlFile\header.js"
 "\epoc32\data\z\private\2001E277\HtmlFile\plus.gif"              - "c:\private\2001E277\HtmlFile\plus.gif"
 "\epoc32\data\z\private\2001E277\HtmlFile\minus.gif"             - "c:\private\2001E277\HtmlFile\minus.gif"
+"\epoc32\data\z\private\2001E277\HtmlFile\follow_up.png"         - "c:\private\2001E277\HtmlFile\follow_up.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\follow_up_complete.png" - "c:\private\2001E277\HtmlFile\follow_up_complete.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\todo_high_add.png"     - "c:\private\2001E277\HtmlFile\todo_high_add.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\todo_low_add.png"      - "c:\private\2001E277\HtmlFile\todo_low_add.png"
 
 ; Emailuis / uicomponents
 "\epoc32\release\armv5\urel\fs_generic.dll"                      - "c:\sys\bin\fs_generic.dll"
--- a/emailuis/emailui/sis/emailui_udeb.pkg	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/sis/emailui_udeb.pkg	Mon Jan 18 20:08:26 2010 +0200
@@ -41,9 +41,14 @@
 
 "\epoc32\data\z\private\2001E277\HtmlFile\attachment.gif"        - "c:\private\2001E277\HtmlFile\attachment.gif"
 "\epoc32\data\z\private\2001E277\HtmlFile\email.html"            - "c:\private\2001E277\HtmlFile\email.html"
+"\epoc32\data\z\private\2001E277\HtmlFile\email_rtl.html"            - "c:\private\2001E277\HtmlFile\email_rtl.html"
 "\epoc32\data\z\private\2001E277\HtmlFile\header.js"             - "c:\private\2001E277\HtmlFile\header.js"
 "\epoc32\data\z\private\2001E277\HtmlFile\plus.gif"              - "c:\private\2001E277\HtmlFile\plus.gif"
 "\epoc32\data\z\private\2001E277\HtmlFile\minus.gif"             - "c:\private\2001E277\HtmlFile\minus.gif"
+"\epoc32\data\z\private\2001E277\HtmlFile\follow_up.png"         - "c:\private\2001E277\HtmlFile\follow_up.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\follow_up_complete.png" - "c:\private\2001E277\HtmlFile\follow_up_complete.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\todo_high_add.png"     - "c:\private\2001E277\HtmlFile\todo_high_add.png"
+"\epoc32\data\z\private\2001E277\HtmlFile\todo_low_add.png"      - "c:\private\2001E277\HtmlFile\todo_low_add.png"
 
 ; Emailuis / uicomponents
 "\epoc32\release\armv5\udeb\fs_generic.dll"                      - "c:\sys\bin\fs_generic.dll"
--- a/emailuis/emailui/src/FSComposerFetchLogic.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FSComposerFetchLogic.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -146,6 +146,12 @@
     {
     FUNC_LOG;
 
+    // Ignore all responses when cancelling is in progress.
+    if( iFetchingCancelGoingOn )
+        {
+        return;
+        }
+    
     iError = aEvent.iError;
 
     if ( !iError )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/emailui/src/FSHtmlReloadAO.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Symbian Foundation License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Asynchronous reloading of web page
+*
+*/
+
+
+
+#include "FSHtmlReloadAO.h"
+#include "FreestyleEmailUiHtmlViewerView.h"
+
+CFSHtmlReloadAO* CFSHtmlReloadAO::NewL(  CFsEmailUiHtmlViewerView& aView  )
+    {
+    CFSHtmlReloadAO* self = new( ELeave ) CFSHtmlReloadAO( aView );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+CFSHtmlReloadAO::CFSHtmlReloadAO( CFsEmailUiHtmlViewerView& aView  )
+        : CActive( CActive::EPriorityStandard ), iView( aView )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+CFSHtmlReloadAO::~CFSHtmlReloadAO()
+    {
+    Cancel();
+    }
+
+
+void CFSHtmlReloadAO::ReloadPageAysnc()
+    {
+    if ( !IsActive() )
+        {
+        //Complete request immediately
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, KErrNone );
+        SetActive();
+        }
+    }
+
+
+
+void CFSHtmlReloadAO::ConstructL()
+    {
+    // Do nothing
+    }
+
+// pure virtuals from CActive implemented in this derived class
+void CFSHtmlReloadAO::RunL()
+    {
+    if ( iStatus.Int() == KErrNone )
+        {
+        iView.ReloadPageL();
+        }
+    }
+
+void CFSHtmlReloadAO::DoCancel()
+    {
+    }
--- a/emailuis/emailui/src/FreestyleEmailDownloadInformationMediator.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailDownloadInformationMediator.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -44,7 +44,8 @@
 //
 CFSEmailDownloadInfoMediator::CFSEmailDownloadInfoMediator( CFSMailClient& aMailClient )
     : CActive( EPriorityNormal ), iMailClient(aMailClient),
-    iDownloadArray( KArrayGranularity, _FOFF(TDownload, iRequestId) ), iDownloadsStarted ( EFalse )
+    iDownloadArray( KArrayGranularity, _FOFF(TDownload, iRequestId) ), iDownloadsStarted ( EFalse ),
+    iNotificationsInProgress( 0 ), iObserverDeleted( EFalse )
 	{
     FUNC_LOG;
 	CActiveScheduler::Add( this );
@@ -383,11 +384,11 @@
 void CFSEmailDownloadInfoMediator::StopObserving( MFSEmailDownloadInformationObserver* aObserver, TFSMailMsgId aMessageId )
 	{
 	FUNC_LOG;
-    for (TInt i=0; i<iObserverArray.Count(); i++)
+    for (TInt i=iObserverArray.Count()-1; i>=0; i--)
     	{
    		if ( iObserverArray[i].iObserver == aObserver && iObserverArray[i].iMessageId == aMessageId )
    			{
-   			iObserverArray.Remove(i);
+            RemoveObserver(i);
    			}
     	}
 	}
@@ -395,14 +396,14 @@
 void CFSEmailDownloadInfoMediator::StopObserving( MFSEmailDownloadInformationObserver* aObserver )
 	{
 	FUNC_LOG;
-    for (TInt i=0; i<iObserverArray.Count(); i++)
+    for ( TInt i=iObserverArray.Count()-1; i>=0; i-- )
     	{
    		if ( iObserverArray[i].iObserver == aObserver )
    			{
-   			iObserverArray.Remove(i);
+   			RemoveObserver(i);
    			}
     	}
-    for (TInt i=0; i<iAllObserverArray.Count(); i++)
+    for ( TInt i=iAllObserverArray.Count()-1; i>=0; i-- )
     	{
 		if ( iAllObserverArray[i] == aObserver )
    			{
@@ -411,6 +412,23 @@
     	}
 	}
 
+void CFSEmailDownloadInfoMediator::RemoveObserver( TInt aIdx )
+    {
+    if ( iNotificationsInProgress == 0 )
+        {
+        // If we're not currently iterating over the array, remove the entry
+        // immediately.
+        iObserverArray.Remove( aIdx );
+        }
+    else
+        {
+        // We're currently iterating over the array: mark the entry as
+        // deleted and flag that we've done so.
+        iObserverArray[aIdx].iDeleted = ETrue;
+        iObserverDeleted = ETrue;
+        }
+    }
+
 void CFSEmailDownloadInfoMediator::DownloadL( TPartData aPart, TBool aCompleteNote )
 	{
 	FUNC_LOG;
@@ -725,25 +743,61 @@
 		
 	SetActive();
     }
-	
+
 void CFSEmailDownloadInfoMediator::NotifyObserversL( const TFSProgress& aEvent, const TPartData& aPart )
     {
 	FUNC_LOG;
+
+	// notify observers of this particular message part
+    iNotificationsInProgress++;
+    TRAPD( error, NotifyPartObserversL( aEvent, aPart ) );
+    if ( --iNotificationsInProgress == 0 )
+        {
+        CleanUpObservers();
+        }
+    if ( error )
+        {
+        User::Leave( error );
+        }
+
+    // send response to every 'all observer'
+    for ( TInt i=iAllObserverArray.Count()-1; i>=0; i-- )
+        {
+        iAllObserverArray[i]->RequestResponseL( aEvent, aPart );
+        }
+    }
+
+void CFSEmailDownloadInfoMediator::NotifyPartObserversL( const TFSProgress& aEvent, const TPartData& aPart )
+    {
+	FUNC_LOG;
 	// go through all observers
-    for ( TInt j=iObserverArray.Count()-1; j>=0; j--)
+    for ( TInt j=iObserverArray.Count()-1; j>=0; j-- )
 		{
 		// if observer is observing this message
-		if ( iObserverArray[j].iMessageId == aPart.iMessageId )
+		if ( !iObserverArray[j].iDeleted && iObserverArray[j].iMessageId == aPart.iMessageId )
 			{
 			// send response to observer
 			iObserverArray[j].iObserver->RequestResponseL( aEvent, aPart );
 			}
 		}
-	// send response to every 'all observer'
-	for (TInt i=0; i<iAllObserverArray.Count(); i++)
-		{
-		iAllObserverArray[i]->RequestResponseL( aEvent, aPart );
-		}
+    }
+
+void CFSEmailDownloadInfoMediator::CleanUpObservers()
+    {
+    FUNC_LOG;
+    // If one or more observers have been marked for deletion, go through
+    // the observer array and remove them.
+    if ( iObserverDeleted )
+        {
+        for ( TInt j=iObserverArray.Count()-1; j>=0; j-- )
+            {
+            if ( iObserverArray[j].iDeleted )
+                {
+                iObserverArray.Remove(j);
+                }
+            }
+        iObserverDeleted = EFalse;
+        }
     }
 
 void CFSEmailDownloadInfoMediator::RunL()
--- a/emailuis/emailui/src/FreestyleEmailUiAppui.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiAppui.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -176,7 +176,7 @@
 // ---------------------------------------------------------------------------
 //
 TInt CFreestyleEmailUiAppUi::LoadResourceFileL(
-    const TDesC& aFileName, 
+    const TDesC& aFileName,
     const TDesC& aFilePath )
     {
     FUNC_LOG;
@@ -196,19 +196,19 @@
             TFileName nearestFile( parse.FullName() );
             BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), nearestFile );
             delete dirList;
-            
+
             INFO_1( "Load resource: %S", &nearestFile );
             // Return the resource file offset if file loaded succesfully
             return iEikonEnv->AddResourceFileL( nearestFile );
             }
         delete dirList;
         }
-	
+
     // Leave if resource file is not found
     User::Leave( err );
     return 0; // To avoid compiler warnings
     }
-    
+
 // ---------------------------------------------------------------------------
 // ConstructL is called by the application framework
 // ---------------------------------------------------------------------------
@@ -221,7 +221,7 @@
     iMsgEditorResourceOffset = LoadResourceFileL(
                                    KMsgEditorAppUiResourceFileName,
                                    KDC_RESOURCE_FILES_DIR );
-    
+
     // Load FSMailServer resource file, search first the same drive from where
     // our process is loaded as FSMailServer should be installed in same drive
     RProcess ownProcess;
@@ -230,7 +230,7 @@
     iFSMailServerResourceOffset = LoadResourceFileL(
                                       KFSMailServerResourceFileNameWithPath,
                                       ownProcessName.LeftTPtr( KDriveDescLength ) );
-    
+
 	// flag indicating whether we are in AppUi::ConstructL
 	// workaround for compose view loadbackgroundcontext sending skin changed events
 	// and causing texture manager to be reconstructed many times
@@ -1120,7 +1120,13 @@
     switch ( aEvent.Type() )
         {
         case KAknFullOrPartialForegroundLost:
+            {
+            if( iCurrentActiveView )
+                {
+                iCurrentActiveView->HandleAppForegroundEventL( EFalse );
+                }
             break;
+            }
         case KAknFullOrPartialForegroundGained:
             {
             if ( iCurrentActiveView && !iSettingsViewActive )
@@ -2069,7 +2075,7 @@
 	    }
 	return ret;
 	}
-	
+
 // Move to previous message when the current message is deleted in viewer
 TInt CFreestyleEmailUiAppUi::MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId )
 	{
@@ -2079,9 +2085,9 @@
 		{
 		iNavigationHistory->Head()->MoveToPreviousMsgAfterDeleteL( aFoundPreviousMsgId );
 		}
-	return ret;		
+	return ret;
 	}
-	
+
 CDocumentHandler& CFreestyleEmailUiAppUi::DocumentHandler()
 	{
     FUNC_LOG;
@@ -2614,7 +2620,7 @@
 	TBool oldFocusState( iFocusVisible );
 	iFocusVisible = aVisible;
 	CFsEmailUiViewBase* activeView = CurrentActiveView();
-	if ( /*oldFocusState != aVisible &&*/ activeView )
+	if ( activeView )
 		{
 		activeView->FocusVisibilityChange( aVisible );
 		}
--- a/emailuis/emailui/src/FreestyleEmailUiAttachmentsListVisualiser.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiAttachmentsListVisualiser.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -975,7 +975,8 @@
 
 // <cmail> Touch
 void CFSEmailUiAttachmentsListVisualiser::TreeListEventL( const TFsTreeListEvent aEvent, 
-                                 	const TFsTreeItemId aId )
+                                 	const TFsTreeItemId aId,
+                                 	const TPoint& /*aPoint*/ )
 	{
     FUNC_LOG;
 
--- a/emailuis/emailui/src/FreestyleEmailUiContactHandler.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiContactHandler.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -683,7 +683,14 @@
 	    MVPbkStoreContact* aContact )
 	{
     FUNC_LOG;
-	TRAP_IGNORE( VPbkSingleContactOperationCompleteL( aOperation, aContact) );
+//inform also client in case of error to enable client's actions (i.e. return search priority)
+//	TRAP_IGNORE( VPbkSingleContactOperationCompleteL( aOperation, aContact) );
+    TRAPD(error, VPbkSingleContactOperationCompleteL( aOperation, aContact) );
+    if ( error != KErrNone )
+        {
+        TRAP_IGNORE(ObserverOperationErrorL( CurrentCommand(), error ));
+        }
+//
 	}
 
 void CFSEmailUiContactHandler::VPbkSingleContactOperationCompleteL(
@@ -805,6 +812,8 @@
 				}
 			else
 				{
+// user cancelled operation - inform client to enable its actions (i.e. return search priority)
+                ObserverOperationErrorL( EFindAndCallToContactByEmailL, KErrCancel );
 				iState = EContactHandlerIdle;
 				}
 			}
@@ -817,6 +826,8 @@
 	        else
 	            {
 	            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 );
 	            }
 			iState = EContactHandlerIdle;
 			}
@@ -1789,6 +1800,11 @@
 		{
 		LaunchRemoteLookupWithQueryL( *iMailBox, *iPreviousEmailAddress );
 		}
+    else // user cancelled operation inform client to enable its actions (i.e. return search priority)
+        {
+        ObserverOperationErrorL( CurrentCommand(), KErrCancel );
+        }
+
 	}
 
 TContactHandlerCmd CFSEmailUiContactHandler::CurrentCommand()
@@ -1818,5 +1834,14 @@
     {
     iHandlerObserver = NULL;
     }
-	
-	
+
+// <cmail> call observer's MFSEmailUiContactHandlerObserver::OperationErrorL( TContactHandlerCmd aCmd, TInt aError ) 
+void CFSEmailUiContactHandler::ObserverOperationErrorL( TContactHandlerCmd aCmd, TInt aErrorCode )
+    {
+    if( ( iHandlerObserver ) && ( KErrNone != aErrorCode ) )
+        {
+        iHandlerObserver->OperationErrorL( aCmd, aErrorCode ); 
+        iHandlerObserver = NULL;
+        }
+    }
+
--- a/emailuis/emailui/src/FreestyleEmailUiFolderListVisualiser.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiFolderListVisualiser.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -74,6 +74,7 @@
 #include "FreestyleEmailUiShortcutBinding.h"
 #include "ESMailSettingsPlugin.h"
 #include "FreestyleEmailUiStatusIndicator.h"
+#include <alf/alfborderbrush.h>
 
 // Defines the order of the folders in UI
 enum TFSEmailUiFolderListPriorities
@@ -248,6 +249,12 @@
     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
     iFaderLayout = CAlfDeckLayout::AddNewL( *iControl );
     iFaderLayout->SetRect( mainPaneRect );
+    // It is not possible to get PointerEvent from iFaderLayout 
+    // unless it has got something to draw (even if it is not visible)  
+	iFaderLayout->EnableBrushesL();
+    CAlfBorderBrush* borderfader = CAlfBorderBrush::NewL( iEnv, 1, 1, 1, 1 );
+	borderfader->SetOpacity(KFSInvisible);
+	iFaderLayout->Brushes()->AppendL( borderfader, EAlfHasOwnership );
 
     iParentLayout = CAlfAnchorLayout::AddNewL( *iControl );
     iParentLayout->SetRect( iScreenRect );
@@ -596,19 +603,9 @@
         TRect outerRect( iScreenRect );
         outerRect.Shrink( paddingValue, paddingValue );
         iBackgroundBrush->SetFrameRectsL( outerRect, iScreenRect );
+        iParentLayout->Brushes()->AppendL( iBackgroundBrush, EAlfDoesNotHaveOwnership );
 		}
 
-	   // Append brush if it's not yet appended. Currently this is our only
-	    // brush so if brush count is more than zero, this brush is already
-	    // appended. If other brush(es) are added later, this implementation
-	    // need to be changed.
-	    if ( iParentLayout->Brushes()->Count() == 0 )
-	        {
-	        // Keep the ownership of the brush to avoid unneeded object
-	        // deletion / reconstruction
-	        iParentLayout->Brushes()->AppendL( iBackgroundBrush, EAlfDoesNotHaveOwnership );
-	        }
-	
 	if( !iShadowBrush )
 	    {
         iShadowBrush = CAlfShadowBorderBrush::NewL( 
@@ -619,6 +616,14 @@
                                            EAlfDoesNotHaveOwnership );
 	    }
 
+      // Append brush if it's not yet appended. 
+      if ( iParentLayout->Brushes()->Count() == 0 )
+          {
+          // Keep the ownership of the brush to avoid unneeded object deletion / reconstruction
+          iParentLayout->Brushes()->InsertL( 0, iBackgroundBrush, EAlfDoesNotHaveOwnership );
+          iParentLayout->Brushes()->AppendL( iShadowBrush, EAlfDoesNotHaveOwnership );
+          }
+	
 	SetPopupSoftkeysL();
 	// SetRect need to be called also here, otherwise the list layout might
 	// be wrong in mirrored layout
@@ -3097,7 +3102,8 @@
 // ---------------------------------------------------------------------------
 //
 void CFSEmailUiFolderListVisualiser::TreeListEventL( const TFsTreeListEvent aEvent,
-                                    const TFsTreeItemId /*aId*/ )
+                                                     const TFsTreeItemId /*aId*/,
+                                                     const TPoint& /*aPoint*/ )
     {
     switch (aEvent)
         {
--- a/emailuis/emailui/src/FreestyleEmailUiHtmlViewerContainer.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiHtmlViewerContainer.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -21,13 +21,13 @@
 #include <coemain.h>
 #include <commdbconnpref.h>
 #include <bautils.h>
-
+#include <biditext.h>
 //<cmail>
 #include "CFSMailMessage.h"
 //</cmail>
 #include <brctlinterface.h>
 #include <sysutil.h>
-
+#include <SchemeHandler.h>
 
 #include "FreestyleEmailUiAppui.h"
 #include "FreestyleEmailUiUtilities.h"
@@ -47,10 +47,10 @@
 _LIT( KHeaderHtmlFile, "header.html" );
 _LIT( KBodyHtmlFile, "body.html" );
 _LIT( KMessageHtmlFile, "email.html" );
+_LIT( KMessageHtmlRTLFile, "email_rtl.html" );
 _LIT( KZDrive, "z:" );
 _LIT( KHtmlFlagFile, "html.flag" );
-
-// <cmail>
+_LIT( KURLSlash, "/");
 // Constants used in html content modification
 const TInt KMaxCharsToSearch( 200 );
 _LIT8( KStartTag, "<html" );
@@ -64,7 +64,32 @@
 _LIT8( KHTMLEmptyContent, "<HTML><BODY></BODY></HTML>");
 _LIT( KHTMLDataScheme, "data:0");
 
-// </cmail>
+
+_LIT8( KHtmlLineBreak, "<br>" );
+_LIT8( KHtmlLineBreakCRLF, "<br>\xD\xA" );
+_LIT8( KHtmlLessThan, "&lt;" );
+_LIT8( KHtmlGreaterThan, "&gt;" );
+_LIT8( KHtmlAmpersand, "&amp;" );
+_LIT8( KHtmlQuotation, "&quot;" );
+_LIT8( KHtmlLinkTag, "<a href=\"%S\">" );
+_LIT8( KHtmlLinkEndTag, "</a>" );
+_LIT( KURLTypeBody, "body");
+
+const TText8 KGreaterThan = 0x3e;
+const TText8 KLessThan = 0x3c;
+const TText8 KAmpersand = 0x26;
+const TText8 KQuotation = 0x22;
+const TText8 KCharacterSpace = 0x20;
+const TText8 KSOH = 0x01; // Start Of Heading
+const TText8 KCR = 0x0d; // Carriage Return
+const TText8 KLF = 0x0a; // Line Feed
+const TText8 KHT = 0x09; // Horizontal Tab
+const TReal KOverlayButtonMarginX = 0.01; // 1%
+const TReal KOverlayButtonMarginY = 0.01; // 1%
+const TReal KOverlayButtonSizeP = 0.15; // 15%
+const TReal KOverlayButtonSizeLs = 0.20; // 25%
+const TReal KOverlayButtonPosP = 0.88;
+const TReal KOverlayButtonPosLs = 0.85;
 
 // ---------------------------------------------------------------------------
 // Two-phased constructor.
@@ -115,6 +140,9 @@
     delete iBrCtlInterface;
     iConnection.Close();
     iSocketServer.Close();
+    
+    delete iOverlayControlNext;
+    delete iOverlayControlPrev;
     }
 
 // <cmail> Because of browser changes, followings must be performed before iAppUi.exit()
@@ -145,8 +173,7 @@
     EnsureHTMLResourceL();
     
     CreateWindowL();
-    SetRect( iAppUi.ClientRect() );
-
+    SetRect( iView.ContainerRect() );
 
     TUint brCtlCapabilities = TBrCtlDefs::ECapabilityClientResolveEmbeddedURL |
                               TBrCtlDefs::ECapabilityDisplayScrollBar |
@@ -167,9 +194,102 @@
     iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsFontSize, TBrCtlDefs::EFontSizeLevelLarger );
 
     iEventHandler = CFreestyleMessageHeaderURLEventHandler::NewL( iAppUi, iView );
+    
+    TRect nextButtonRect = OverlayButtonRect( EFalse );
+    iOverlayControlNext = COverlayControl::NewL( this, this, nextButtonRect, 
+            EMbmFreestyleemailuiQgn_indi_cmail_arrow_next, 
+            EMbmFreestyleemailuiQgn_indi_cmail_arrow_next_mask );
+
+    TRect prevButtonRect = OverlayButtonRect( ETrue );
+    iOverlayControlPrev = COverlayControl::NewL( this, this, prevButtonRect,
+            EMbmFreestyleemailuiQgn_indi_cmail_arrow_previous,
+            EMbmFreestyleemailuiQgn_indi_cmail_arrow_previous_mask );
+    iScrollPosition = 0;
     ActivateL();
     }
 
+void CFsEmailUiHtmlViewerContainer::MakeVisible( TBool aVisible )
+    {
+    UpdateOverlayButtons( aVisible );
+    CCoeControl::MakeVisible( aVisible );
+    }
+
+void CFsEmailUiHtmlViewerContainer::HandleOverlayPointerEventL( COverlayControl* aControl, 
+        const TPointerEvent& aEvent )
+    {
+    if( aEvent.iType == TPointerEvent::EButton1Up )
+        {
+        if( aControl == iOverlayControlNext )
+            {
+            iView.HandleCommandL( EFsEmailUiCmdNextMessage );
+            }
+        else if( aControl == iOverlayControlPrev )
+            {
+            iView.HandleCommandL( EFsEmailUiCmdPreviousMessage );
+            }
+        }
+    }
+
+void CFsEmailUiHtmlViewerContainer::UpdateOverlayButtons( TBool aVisible )
+    {
+    TBool nextAvailable = EFalse;
+    TBool prevAvailable = EFalse;
+    if( iMessage )
+        {
+        TFSMailMsgId currentMsgId = iMessage->GetMessageId();
+        TFSMailMsgId tmpMsgId;
+        TFSMailMsgId tmpMsgFolderId;
+        nextAvailable = iAppUi.IsNextMsgAvailable( currentMsgId, tmpMsgId, tmpMsgFolderId );
+        prevAvailable = iAppUi.IsPreviousMsgAvailable( currentMsgId, tmpMsgId, tmpMsgFolderId );
+        }
+    
+    if( iOverlayControlPrev )
+        {
+        iOverlayControlPrev->SetRect( OverlayButtonRect( ETrue ) );
+        iOverlayControlPrev->MakeVisible( aVisible && prevAvailable );
+        }
+    if( iOverlayControlNext )
+        {
+        iOverlayControlNext->SetRect( OverlayButtonRect( EFalse ) );
+        iOverlayControlNext->MakeVisible( aVisible && nextAvailable );
+        }
+    }
+
+// Get rect for button
+TRect CFsEmailUiHtmlViewerContainer::OverlayButtonRect( TBool aLeft )
+    {
+    TRect rect = Rect();
+    TSize size = rect.Size();
+    
+    TBool landscape = size.iWidth > size.iHeight;
+    TInt buttonSize;
+
+    if( landscape )
+        {
+        buttonSize = size.iHeight * KOverlayButtonSizeLs;
+        }
+    else
+        {
+        buttonSize = size.iWidth * KOverlayButtonSizeP;
+        }
+
+    rect.iBr.iY = size.iHeight * (1-KOverlayButtonMarginY);
+    
+    if( aLeft )
+        {
+        rect.iTl.iX = size.iWidth * KOverlayButtonMarginX;
+        rect.iBr.iX = rect.iTl.iX + buttonSize;
+        }
+    else
+        {
+        rect.iBr.iX = size.iWidth * (1 - KOverlayButtonMarginX);
+        rect.iTl.iX = rect.iBr.iX - buttonSize;
+        }
+    
+    rect.iTl.iY = rect.iBr.iY - buttonSize;
+    return rect;
+    }
+
 // Getter for br contro, interface
 CBrCtlInterface* CFsEmailUiHtmlViewerContainer::BrowserControlIf()
     {
@@ -200,11 +320,14 @@
 // ---------------------------------------------------------------------------
 //
 void CFsEmailUiHtmlViewerContainer::LoadContentFromMailMessageL(
-    CFSMailMessage* aMailMessage )
+    CFSMailMessage* aMailMessage, TBool aResetScrollPos )
     {
     FUNC_LOG;
     ASSERT( aMailMessage );
     iMessage = aMailMessage;
+    // Cancel any browser fetch operation, just in case the browser is still
+    // loading a previous message (since we are about to overwrite it).
+    CancelFetch();
     
     TPath headerHtmlFile;
     headerHtmlFile.Copy( iHtmlFolderPath );
@@ -213,7 +336,15 @@
     // insert email header into email.html file
     // CFreestyleMessageHeaderHTML will replace contents of email.html
     // So, no need to clear the contents
-    CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile, iAppUi.ClientRect().Width() );
+    TLanguage language = User::Language();
+    TBidiText::TDirectionality direction = TBidiText::ScriptDirectionality( language );    
+    if(aResetScrollPos)
+        {
+        iScrollPosition = 0; 
+        }
+    CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile, iAppUi.ClientRect().Width(), 
+                                            iScrollPosition,
+                                            direction);
     
     // Remove all previously created files from temporary HTML folder
     EmptyTempHtmlFolderL();
@@ -262,16 +393,24 @@
             CleanupStack::PopAndDestroy( contentBuffer );
             CleanupStack::PopAndDestroy( textBodyPart ); 
             }
-
         }
     // pass the emailHtmlFile to the browser for it to load
     if ( bodyPartAvailable )
         {
         TPath emailHtmlFile;
         emailHtmlFile.Copy( iHtmlFolderPath );
-        emailHtmlFile.Append( KMessageHtmlFile );
+        if ( direction == TBidiText::ELeftToRight )
+            {
+            emailHtmlFile.Append( KMessageHtmlFile );
+            }
+        else
+            {
+            emailHtmlFile.Append( KMessageHtmlRTLFile );
+            }
         LoadContentFromFileL( emailHtmlFile );
         }
+    
+    UpdateOverlayButtons( ETrue );
     }
 
 // ---------------------------------------------------------------------------
@@ -347,11 +486,30 @@
 void CFsEmailUiHtmlViewerContainer::SizeChanged()
     {
     FUNC_LOG;
+
+    TRect rect = Rect();
     if ( iBrCtlInterface )
         {
-        TRect rect = Rect();
         iBrCtlInterface->SetRect( rect );
         }
+    
+        if ( iMessage )
+            {
+            // update the width in header part and reload
+            TPath headerHtmlFile;
+            headerHtmlFile.Copy( iHtmlFolderPath );
+            headerHtmlFile.Append( KHeaderHtmlFile );
+                
+            TRAP_IGNORE( CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile, 
+                  rect.Width(), iScrollPosition ) )
+                
+            TPath emailHtmlFile;
+            emailHtmlFile.Copy( iHtmlFolderPath );
+            emailHtmlFile.Append( KMessageHtmlFile );
+            TRAP_IGNORE( LoadContentFromFileL( emailHtmlFile ) )
+            }
+    
+    UpdateOverlayButtons( IsVisible() );
     }
 
 // ---------------------------------------------------------------------------
@@ -490,6 +648,8 @@
         if ( iMessage )
             {
             LoadContentFromMailMessageL( iMessage );
+            
+            UpdateOverlayButtons( ETrue );
             }
         }
     else if ( aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestCancelled ||
@@ -554,7 +714,23 @@
     const TDesC& /*aCurrentUrl*/, MBrCtlLinkContent& /*aBrCtlLinkContent*/ )
     {
     FUNC_LOG;
-    return iEventHandler->HandleEventL( aUrl );
+    if (IsMessageBodyURL(aUrl))
+        {
+        iView.StartFetchingMessageL();
+        return ETrue;
+        }
+    else
+        {
+        if ( NeedToLaunchBrowserL( aUrl ) )
+            {
+            LaunchBrowserL( aUrl );
+            return ETrue;
+            }
+        else
+            {
+            return iEventHandler->HandleEventL( aUrl );
+            }     
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -987,9 +1163,11 @@
 //
 // <cmail>
 void CFsEmailUiHtmlViewerContainer::ConvertToHTML( const TDesC8& aContent,
-    const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart )
+    const TDesC& aFileName, CFSMailMessagePart& aTextBodyPart )
     {
     FUNC_LOG;
+    const TInt KBodyTextChunkSizeBytes = 1024;
+    
     if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, aContent.Size(), EDriveC ) )
          {
          // Can not write the data, there's not enough free space on disk.
@@ -997,49 +1175,334 @@
         }
     else
         {
+        CBufBase* bodyBuf = CBufSeg::NewL( KBodyTextChunkSizeBytes );
+        CleanupStack::PushL( bodyBuf );
+        
+        bodyBuf->InsertL( 0, aContent );
+        
+        TInt position( 0 );
+        TText8 previous = 0;
+        TBool EndOfString( EFalse );
+        
+        while ( !EndOfString )
+            {
+            TInt startPosition = position;
+            TPtr8 segment( bodyBuf->Ptr( startPosition ) );
+            int i = 0;
+            
+            while(i < segment.Length())
+                {
+                TInt currentPos = position + i;
+                TText8 ch = segment[i];
+                
+                switch( ch )
+                    {
+                    case KSOH:  // end of line for IMAP and POP
+                        bodyBuf->Delete( currentPos, 1 );
+                        bodyBuf->InsertL( currentPos, KHtmlLineBreakCRLF );
+                        i += KHtmlLineBreakCRLF().Length();
+                        segment.Set( bodyBuf->Ptr( startPosition ) );
+                        break;
+                    case KLF: // line feed
+                        if ( previous == KCR )
+                            {
+                            bodyBuf->InsertL( currentPos, KHtmlLineBreak );
+                            i += KHtmlLineBreak().Length();
+                            segment.Set( bodyBuf->Ptr( startPosition ) );
+                            }
+                        else
+                            {
+                            i++;
+                            }
+                        break;  
+                    case KQuotation:
+                        bodyBuf->Delete( currentPos, 1 );
+                        bodyBuf->InsertL( currentPos, KHtmlQuotation );
+                        i += KHtmlQuotation().Length();
+                        segment.Set( bodyBuf->Ptr( startPosition ) );
+                        break;
+                    case KAmpersand:
+                        bodyBuf->Delete( currentPos, 1 );
+                        bodyBuf->InsertL( currentPos, KHtmlAmpersand );
+                        i += KHtmlAmpersand().Length();
+                        segment.Set( bodyBuf->Ptr( startPosition ) );
+                        break;
+                    case KGreaterThan:
+                        bodyBuf->Delete( currentPos, 1 );
+                        bodyBuf->InsertL( currentPos, KHtmlGreaterThan );
+                        i += KHtmlGreaterThan().Length();
+                        segment.Set( bodyBuf->Ptr( startPosition ) );
+                        break;
+                    case KLessThan:
+                        bodyBuf->Delete( currentPos, 1 );
+                        bodyBuf->InsertL( currentPos, KHtmlLessThan );
+                        i += KHtmlLessThan().Length();
+                        segment.Set( bodyBuf->Ptr( startPosition ) );
+                        break;
+                    default:
+                        i++;
+                        break;
+                    }
+                previous = ch;
+                }
+            position += segment.Length();
+            if ( ( bodyBuf->Size() - position ) <= 0 )
+                {
+                EndOfString = ETrue;
+                }
+            }
+        
+        CreateHyperlinksFromUrlsL( *bodyBuf );
+        
         RFile targetFile;
         CleanupClosePushL( targetFile );
-
         User::LeaveIfError( targetFile.Replace( iFs, aFileName, EFileWrite ) );
         
-        HBufC8* charSet = GetCharacterSetL( aHtmlBodyPart );
+        HBufC8* charSet = GetCharacterSetL( aTextBodyPart );
         CleanupStack::PushL( charSet );
         
-        User::LeaveIfError( targetFile.Write( KHtmlHeader1 ) );
-        User::LeaveIfError( targetFile.Write( *charSet ) );
-        User::LeaveIfError( targetFile.Write( KHtmlHeader2 ) );
+        RBuf8 messageHeader;
+        TInt bufSize = KHtmlHeader1().Length() + charSet->Length() + KHtmlHeader2().Length();
+        messageHeader.CreateL( bufSize );
+        messageHeader.CleanupClosePushL();
+        
+        messageHeader.Append( KHtmlHeader1 );
+        messageHeader.Append( *charSet );
+        messageHeader.Append( KHtmlHeader2 );
+        
+        RFileWriteStream fileStream( targetFile );
+        fileStream.PushL();
+        fileStream.WriteL( messageHeader.Ptr(), messageHeader.Length() );
+        
+        TInt bufPos( 0 );
+        TInt bufTotalSize = bodyBuf->Size();
+        
+        while ( bufPos < bufTotalSize )
+            {
+            TInt segmentLength = bodyBuf->Ptr( bufPos ).Length();
+            fileStream.WriteL( bodyBuf->Ptr( bufPos ).Ptr(), segmentLength );
+            bufPos += segmentLength;
+            }
+
+        fileStream.CommitL();
+        
+        CleanupStack::PopAndDestroy( &fileStream );
+        CleanupStack::PopAndDestroy( &messageHeader );
         CleanupStack::PopAndDestroy( charSet );
-
+        CleanupStack::PopAndDestroy( &targetFile );
+        CleanupStack::PopAndDestroy( bodyBuf );
 
-        // Write the original content
-        for(int i=0;i<aContent.Length();i++)
-            {
-          if( i==aContent.Length()-1 )
-            {
-            aContent.Mid( i,1 ).CompareC( _L8("\x01" ) )==0 ? 
-            User::LeaveIfError( targetFile.Write( _L8("<br>") ) ):
-            User::LeaveIfError( targetFile.Write( aContent.Mid(i,1) ) );
+// </cmail>
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Finds and html formats hyperlinks in a document
+// ---------------------------------------------------------------------------
+//
+// <cmail>
+void CFsEmailUiHtmlViewerContainer::CreateHyperlinksFromUrlsL( CBufBase& aSource )
+    {
+    FUNC_LOG;
+    const TInt urlMaxLength = 2048;
+    _LIT8( KHttp, "http://" );
+    _LIT8( KHttps, "https://");
+    _LIT8( KWww, "www."); 
+    
+    TBool eos( EFalse );
+    TInt position( 0 );
+    TInt carryOverInc( 0 );
+    
+    while ( !eos )
+        {
+        while ( carryOverInc >= aSource.Ptr( position ).Length() )
+            { // Skip segments of overlapping url string
+            carryOverInc -= aSource.Ptr( position ).Length();
+            position += aSource.Ptr( position ).Length();
             }
-          else
+        
+        TPtr8 segment( aSource.Ptr( position ) );
+        TLex8 lexSegment( segment );
+        lexSegment.Inc( carryOverInc );
+        carryOverInc = 0;
+        
+        while (!lexSegment.Eos())
             {
-            if(aContent.Mid( i,1 ).CompareC( _L8("\x01" ) )==0 ||
-            aContent.Mid( i,2 ).CompareC( _L8("\x0D\x0A" ) )==0 ) 
-              {
-              User::LeaveIfError( targetFile.Write( _L8("<br>") ));
-              }
-            else
-              {
-          User::LeaveIfError( targetFile.Write( aContent.Mid(i,1) ) );                        
+            TPtrC8 nextToken( lexSegment.NextToken() );
+            TInt foundAt( KErrNotFound );
+            
+            // Find HTTP, HTTPS, or WWW link in CBufSeg segment of size 1024 bytes.
+            if ( ( ( foundAt = nextToken.FindC( KHttp ) ) != KErrNotFound ) ||
+                    (  ( foundAt = nextToken.FindC( KHttps ) ) != KErrNotFound ) ||
+                    ( ( foundAt = nextToken.FindC( KWww ) ) != KErrNotFound ) )
+                {
+                if ( !lexSegment.Eos() )
+                    { 
+                    if ( !foundAt )
+                        { // Token starts with http/https/www.x
+                        TPtrC8 url;
+                        TInt lineBreakPos( KErrNotFound );
+                        if ( ( lineBreakPos = nextToken.FindC( KHtmlLineBreak ) ) != KErrNotFound )
+                            { // Token contains html line break -> remove
+                            url.Set( nextToken.Left( lineBreakPos ) );
+                            }
+                        else
+                            {
+                            url.Set( nextToken );
+                            }
+                        
+                        if ( url.CompareC( KWww ) != KErrNone ) // if token=www., validate format 
+                            {                                   // www.x
+                            RBuf8 urlBuf;
+                            urlBuf.CreateL( KHtmlLinkTag().Length() + url.Length() * 2
+                                    + KHtmlLinkEndTag().Length() + KHtmlLineBreak().Length() );
+                            urlBuf.CleanupClosePushL();
+                            // Format html link
+                            urlBuf.AppendFormat( KHtmlLinkTag, &url );
+                            urlBuf.Append( url );
+                            urlBuf.Append( KHtmlLinkEndTag );
+                            if ( lineBreakPos != KErrNotFound )
+                                { // Add line break if removed earlier
+                                urlBuf.Append( KHtmlLineBreak );
+                                }
+                            //Test
+                            TInt nextTokenLength = nextToken.Length();
+                            TInt segOffset = lexSegment.Offset();
+                            TInt urlLength = urlBuf.Length();
+                            
+                            //Test
+                            TInt offset = lexSegment.Offset() - nextToken.Length();
+                            TLexMark8 tokenMark;
+                            // Move next character last token back
+                            lexSegment.Inc( - nextToken.Length() );
+                            lexSegment.Mark( tokenMark );
+                            aSource.Delete( offset + position, nextToken.Length() );
+                            aSource.InsertL( offset + position, urlBuf );
+                            segment.Set( aSource.Ptr( position ) );
+                            lexSegment.Assign( segment );
+                            // Set next character to the position of inserted hyperlink
+                            lexSegment.UnGetToMark( tokenMark );
+                            
+                            // If Max segment length is reached, set carry over value to 
+                            // properly set next character in following CBufSeg segment
+                            if ( ( offset + urlBuf.Length() ) >= segment.Length() )
+                                {
+                                carryOverInc = offset + urlBuf.Length() - segment.Length();
+                                while ( !lexSegment.Eos() )
+                                    { // Set to segment's end
+                                    lexSegment.NextToken(); 
+                                    }
+                                }
+                            else
+                                {
+                                lexSegment.Inc( urlBuf.Length() );
+                                }
+                            
+                            CleanupStack::PopAndDestroy( &urlBuf );
+                            }
+                        }
+                    }
+                else
+                    // Next token is end of string, here we handle the last token of a segment
+                    {
+                    _LIT8( KUrlEnd, "<" );
+                    
+                    TInt endOfUrlPos( KErrNotFound );
+                    TText8 ch = segment[ segment.Length() - 1];
+                    RBuf8 url;
+                    url.CreateL( urlMaxLength );
+                    url.CleanupClosePushL();
+                    
+                    // Find if hyperlink ends within this segment boundaries
+                    if ( ch == KSOH || ch == KCR || ch == KLF || ch == KHT || ch == KCharacterSpace )
+                        {
+                        endOfUrlPos = nextToken.Length() - 1;
+                        }
+                    else if ( ( endOfUrlPos = nextToken.Right( KHtmlLineBreak().Length() ).Find( KUrlEnd ) ) != KErrNotFound )
+                        {
+                        endOfUrlPos = nextToken.Length() - KHtmlLineBreak().Length() + endOfUrlPos;
+                        }
+                    else
+                        { // Handle hyperlink spread in multiple segments
+                        TInt nextPos = position;
+                        TPtrC8 nextSegment( aSource.Ptr( nextPos ) );
+                        TLex8 lexNextSegment( nextSegment );
+                        TPtrC8 nextNextToken( nextToken );
+                        TBool firstPass( ETrue );
+                        
+                        while ( endOfUrlPos == KErrNotFound || nextPos >= aSource.Size() )
+                            {
+                            if ( ( url.Length() + nextNextToken.Length() )  > urlMaxLength )
+                                { // URL exceeds limit of 2K, do nothing
+                                break;
+                                }
+                            
+                            url.Append( nextNextToken );
+                            if ( ( nextSegment.Length() == nextNextToken.Length() ) || firstPass )
+                                { // Token takes up the whole segment, or first pass( first segment 
+                                  // with last token where hyperlink does not end within segment's
+                                  // boundaries, move to next segment
+                                nextPos += nextSegment.Length();
+                                nextSegment.Set( aSource.Ptr( nextPos ) );
+                                lexNextSegment.Assign( nextSegment );
+                                nextNextToken.Set( lexNextSegment.NextToken() );
+                                if ( firstPass )
+                                    { 
+                                    firstPass =  EFalse;
+                                    }
+                                }
+                            else
+                                { // Last segment's token with hyperlink's end
+                                if ( ( endOfUrlPos = url.Find( KHtmlLineBreak ) ) != KErrNotFound )
+                                    { // Remove line break
+                                    url.Delete( endOfUrlPos, KHtmlLineBreak().Length() );
+                                    endOfUrlPos = nextNextToken.Length() - KHtmlLineBreak().Length();
+                                    }
+                                else
+                                    {
+                                    endOfUrlPos = nextNextToken.Length();
+                                    }  
+                                }
+                            }
+ 
+                        if ( endOfUrlPos != KErrNotFound )
+                            { // Handle hyperlink that is within 2K limit
+                            RBuf8 urlBuf;
+                            urlBuf.CreateL( KHtmlLinkTag().Length() + url.Length() * 2
+                                    + KHtmlLinkEndTag().Length() + KHtmlLineBreak().Length() );
+                            urlBuf.CleanupClosePushL();
+                            // Format html link
+                            urlBuf.AppendFormat( KHtmlLinkTag, &url );
+                            urlBuf.Append( url );
+                            urlBuf.Append( KHtmlLinkEndTag );
+                            urlBuf.Append( KHtmlLineBreak );
+                            
+                            TInt offset = lexSegment.Offset() - nextToken.Length();
+                            // Remove hyperlink from the original message body
+                            aSource.Delete( offset + position, url.Length() );
+                            // Insert html formated hyperlink
+                            aSource.InsertL( offset + position, urlBuf );
+                            segment.Set( aSource.Ptr( position ) );
+                            
+                            // Set carry on value to mark where new token should start in following segment
+                            carryOverInc = endOfUrlPos;
+                            position = nextPos;
+                            
+                            CleanupStack::PopAndDestroy( &urlBuf );
+                            }     
+                        }
+                    CleanupStack::PopAndDestroy( &url );
+                    }
                 }
-              }
             }
-        INFO("Add end tags");
-        User::LeaveIfError( targetFile.Write( KHtmlEndTags ) );
-            
+        position += segment.Length();
+        if ( ( aSource.Size() - position ) <= 0 )
+            {
+            eos = ETrue;
+            }
+        }
 
-        CleanupStack::PopAndDestroy( &targetFile );
-        }
-// </cmail>
+    
     }
 
 
@@ -1076,6 +1539,7 @@
     CleanupStack::Pop( charSet );
     return charSet;
     }
+
 void CFsEmailUiHtmlViewerContainer::StopObserving()
     {
     if( iObservingDownload )
@@ -1116,22 +1580,189 @@
 	if ( aType == CFsEmailUiViewBase::EScreenLayoutChanged )
 		{
 	    // only update header if we get a layout change from email ui
-		if ( iMessage )
+		RefreshCurrentMailHeader();
+		}
+	}
+
+void CFsEmailUiHtmlViewerContainer::RefreshCurrentMailHeader()
+	{
+	if ( iMessage )
+		{
+		// Update the width in header part and reload
+		TPath headerHtmlFile;
+		headerHtmlFile.Copy( iHtmlFolderPath );
+		headerHtmlFile.Append( KHeaderHtmlFile );
+		
+		TLanguage language = User::Language();
+		TBidiText::TDirectionality direction = TBidiText::ScriptDirectionality( language );    
+		TRAP_IGNORE( CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile, iAppUi.ClientRect().Width(), direction ) )
+		
+        TPath emailHtmlFile;
+        emailHtmlFile.Copy( iHtmlFolderPath );
+        if ( direction == TBidiText::ELeftToRight )
             {
-            // update the width in header part and reload
-            TPath headerHtmlFile;
-            headerHtmlFile.Copy( iHtmlFolderPath );
-            headerHtmlFile.Append( KHeaderHtmlFile );
-            
-            TRAP_IGNORE( CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile, iAppUi.ClientRect().Width() ) )
-            
-            TPath emailHtmlFile;
-            emailHtmlFile.Copy( iHtmlFolderPath );
             emailHtmlFile.Append( KMessageHtmlFile );
-            
-            TRAP_IGNORE( LoadContentFromFileL( emailHtmlFile ) )
-            
+            }
+        else
+            {
+            emailHtmlFile.Append( KMessageHtmlRTLFile );
+            }
+		
+        //Load page synchronously if menu invisible
+        if(!iEventHandler->IsMenuVisible())
+            {
+            TRAP_IGNORE( LoadContentFromFileL( emailHtmlFile ) );
             SetRect( iAppUi.ClientRect() );
             }
+        //Load page asynchronously after dismissing menu    
+        else
+            {
+            iEventHandler->DismissMenuAndReload();
+            }		
 		}
 	}
+
+void CFsEmailUiHtmlViewerContainer::ReloadPageL()
+    {
+    TLanguage language = User::Language();
+    TBidiText::TDirectionality direction = TBidiText::ScriptDirectionality( language );    
+    TPath emailHtmlFile;
+    emailHtmlFile.Copy( iHtmlFolderPath );
+    if ( direction == TBidiText::ELeftToRight )
+            {
+        emailHtmlFile.Append( KMessageHtmlFile );
+        }
+    else
+        {
+        emailHtmlFile.Append( KMessageHtmlRTLFile );
+        }
+    TRAP_IGNORE( LoadContentFromFileL( emailHtmlFile ) );
+    SetRect( iAppUi.ClientRect() );
+    }
+
+/**
+ * The body fetch link is cmail://body/fetch. Look for the URL separator
+ * and the presence of cmail and body on the url.
+ * @param aUrl 
+ * return ETrue for  a valid body URL
+ */
+TBool CFsEmailUiHtmlViewerContainer::IsMessageBodyURL(const TDesC& aUrl)
+    {
+    TInt index = aUrl.Find(KURLSchemeSeparator);
+    if (index == KErrNotFound)
+        {
+        return EFalse;
+        }
+    else
+        {
+        if (aUrl.Left(index).CompareF(KURLSchemeCmail) == 0)
+            {
+            TInt bodyIndex = aUrl.Find(KURLTypeBody);                      
+            if (bodyIndex == KErrNotFound)
+                {
+                return EFalse;
+                }
+            else
+                {
+                TPtrC16 data= aUrl.Mid(bodyIndex);
+                TInt separator = data.Find(KURLSlash);
+                if(separator == KErrNotFound)
+                    {
+                    return EFalse;
+                    }
+                else
+                    {
+                    TPtrC16 temp = data.Mid(separator+1);
+                    TLex lex(temp);
+                    lex.Val(iScrollPosition);                  
+                    }
+                return ETrue;
+                }
+            
+            }
+        else
+            {
+            return EFalse;
+            }
+        }
+    } 
+// ---------------------------------------------------------------------------
+// From MBrCtlWindowObserver
+// ---------------------------------------------------------------------------
+//
+CBrCtlInterface* CFsEmailUiHtmlViewerContainer::OpenWindowL( TDesC& /*aUrl*/, TDesC* /*aTargetName*/, 
+                                                             TBool /*aUserInitiated*/, TAny* /*aReserved*/ )
+    {
+    return iBrCtlInterface;
+    }
+
+// ---------------------------------------------------------------------------
+// From MBrCtlWindowObserver
+// ---------------------------------------------------------------------------
+//
+CBrCtlInterface* CFsEmailUiHtmlViewerContainer::FindWindowL( const TDesC& /*aTargetName*/ ) const
+    {
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// From MBrCtlWindowObserver
+// ---------------------------------------------------------------------------
+//
+void CFsEmailUiHtmlViewerContainer::HandleWindowCommandL( const TDesC& /*aTargetName*/, 
+                                                          TBrCtlWindowCommand /*aCommand*/ )
+    {
+    
+    }
+
+// ---------------------------------------------------------------------------
+// Check if a tap on the URL requires browser(standalone) to be launched
+// ---------------------------------------------------------------------------
+//
+TBool CFsEmailUiHtmlViewerContainer::NeedToLaunchBrowserL( const TDesC& aUrl )
+    {
+    TBool launchBrowser( ETrue );
+    // look for file:///
+    _LIT( KFileLink, "file:///");
+    
+    // This might be linking to header.html or body.html frames
+    // Ignore them.
+    if ( aUrl.Left( KFileLink().Length() ).CompareF( KFileLink ) == 0 )
+        {
+        //Now there is a chance that this could be from HTML folder
+        // Replace all slash character with backslash characters
+        HBufC* embeddedUrl = aUrl.AllocLC();
+        TPtr ptr = embeddedUrl->Des();
+        
+        _LIT( KBackslash, "\\" );
+        for ( TInt pos = ptr.Locate('/'); pos >= 0; pos = ptr.Locate('/') )
+            {
+            ptr.Replace( pos, 1, KBackslash );
+            }
+
+        // Check whether given url refers to file in the html folder
+        TInt pos = embeddedUrl->FindF( iHtmlFolderPath );
+        CleanupStack::PopAndDestroy( embeddedUrl );
+        pos >= 0 ? launchBrowser = EFalse : ETrue;        
+        }
+    // Ignore links starting with cmail://
+    else if ( aUrl.Left( KURLSchemeCmail().Length() ).CompareF( KURLSchemeCmail ) == 0 )
+        {
+        launchBrowser = EFalse;
+        }
+
+    return launchBrowser;
+    }
+
+// ---------------------------------------------------------------------------
+// Launch the browser as a standalone app
+// ---------------------------------------------------------------------------
+//
+void CFsEmailUiHtmlViewerContainer::LaunchBrowserL( const TDesC& aUrl )
+    {
+    CSchemeHandler* handler = CSchemeHandler::NewL( aUrl );
+    CleanupStack::PushL( handler );
+    handler->HandleUrlStandaloneL();
+    CleanupStack::PopAndDestroy( handler );
+    }
+
--- a/emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -26,6 +26,9 @@
 #include <AknGlobalNote.h>
 #include <aknnavi.h>
 #include <aknnavide.h>
+#include <APGCLI.H>
+#include <APMSTD.H>
+#include <FavouritesDb.h>
 //<cmail>
 #include <featmgr.h>
 #include "CFSMailMessage.h"
@@ -34,9 +37,15 @@
 #include <SchemeHandler.h> // CSchemeHandler
 #include <brctlinterface.h>
 #include <csxhelp/cmail.hlp.hrh>
+#include <baclipb.h> // for clipboard copy
+
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <txtclipboard.h>
+#endif
+
 // Meeting request
 #include <MeetingRequestUids.hrh>
-//<cmail>
+#include <layoutmetadata.cdl.h>
 #include "cesmricalviewer.h"
 #include "FreestyleEmailUiHtmlViewerView.h"
 #include "FreestyleEmailUi.hrh"
@@ -57,7 +66,7 @@
 #include <akntoolbar.h>
 // CONSTANTS
 // Zoom levels available on the UI
-const TInt KZoomLevels[] = { 50, 75, 100, 125 };
+const TInt KZoomLevels[] = { 75, 100, 125, 150 };
 const TInt KZoomLevelCount = sizeof( KZoomLevels ) / sizeof( TInt );
 
 CFsEmailUiHtmlViewerView* CFsEmailUiHtmlViewerView::NewL( 
@@ -129,7 +138,6 @@
     iOpenMessages = new (ELeave) CStack<CFSMailMessage, ETrue>();
     iEmbeddedMessages = new (ELeave) CStack<CFSMailMessage, EFalse>();
     iNextOrPrevMessageSelected = EFalse; 
-    iForwardingMessage = EFalse;
     }
 
 // -----------------------------------------------------------------------------
@@ -291,7 +299,6 @@
                         iContainer->ResetContent();
                         }
 
-                    iForwardingMessage = ETrue;
                     iAppUi.LaunchEditorL( KEditorCmdForward, params );
                     }
                 }
@@ -394,9 +401,9 @@
                  break;
             default:
                 {
-                if ( aCommand >= EFsEmailUiCmdZoomSmallest )
+                if ( aCommand >= EFsEmailUiCmdZoomSmall )
                     {
-                    TUint zoomLevelIndex = aCommand - EFsEmailUiCmdZoomSmallest;
+                    TUint zoomLevelIndex = aCommand - EFsEmailUiCmdZoomSmall;
                     SetZoomLevelIndexL( zoomLevelIndex );
                     }
                 }
@@ -522,7 +529,7 @@
         }
     else if ( iContainer ) // Container exists, make sure that it has a correct rect
         {
-        iContainer->SetRect( ClientRect() );
+        iContainer->SetRect( ContainerRect() );
         }
 
     // Check whether this activation is actually for a meeting request
@@ -595,7 +602,7 @@
 		            TPartData msgPartData( iActivationData.iMailBoxId, iActivationData.iFolderId, iActivationData.iMessageId);
 		            iAttachmentsListModel->UpdateListL( msgPartData );
                        
-            		TRAPD( error, LoadContentFromMailMessageL( iMessage ) );
+            		TRAPD( error, LoadContentFromMailMessageL( iMessage, ETrue ) );
             		if ( error == KErrNotFound || error == KErrInUse || error == KErrLocked )
             		    {
             		    bodypartNotFound = ETrue;
@@ -651,7 +658,7 @@
                 }                
             
     
-            TRAPD( error, LoadContentFromMailMessageL( iOpenMessages->Head() ) );
+            TRAPD( error, LoadContentFromMailMessageL( iOpenMessages->Head(), ETrue ) );
             if ( error == KErrNotFound || error == KErrInUse || error == KErrLocked )
                 {
                 bodypartNotFound = ETrue;
@@ -683,8 +690,6 @@
         break;
         }
     
-    UpdateNaviPaneL();
-
     CleanupStack::PopAndDestroy( &iActivationData.iFile );
     SetMskL();
     
@@ -726,7 +731,7 @@
             StartWaitedFetchingL(EMessageStructure);
             iFetchingAlready = ETrue;
             }
-        else if ( !MessagePartFullyFetchedL( type ) || bodypartNotFound )
+        else if ( bodypartNotFound )
             {
             iAsyncProcessComplete = EFalse;
             iFetchingAlready = EFalse;
@@ -738,7 +743,6 @@
             }
        }
     iNextOrPrevMessageSelected = EFalse;
-    iForwardingMessage = EFalse;
     }
 
 // -----------------------------------------------------------------------------
@@ -817,14 +821,8 @@
 void CFsEmailUiHtmlViewerView::ChildDoDeactivate()
     {
     FUNC_LOG;
-    // Don't cancel fetching the message parts when forwarding the message:
-    // it would also cancel the fetchings initiated by the forwarding,
-    // causing the forwarding to abort.
-    if ( !iForwardingMessage )
-        {
-        CancelFetchings();
-        }
-
+    CancelFetchings();
+   
     if ( iContainer )
         {
         HideContainer();
@@ -835,7 +833,6 @@
         }
     Toolbar()->SetToolbarObserver( this );
     iMessage = NULL;
-    HideNaviPane();
     }
 
 void CFsEmailUiHtmlViewerView::DoExitL()
@@ -865,7 +862,10 @@
         {
         iAppUi.DownloadInfoMediator()->StopObserving( this, iMessage->GetMessageId() );
         }
-    iContainer->StopObserving();
+    if( iContainer )
+        {
+        iContainer->StopObserving();
+        }
     CFSMailMessage* tmp = PopMessage();
     if( tmp )
         {
@@ -915,6 +915,26 @@
         }
     }
 
+// ---------------------------------------------------------------------------
+// Sets status bar layout
+// ---------------------------------------------------------------------------
+//
+void CFsEmailUiHtmlViewerView::SetStatusBarLayout()
+	{
+    TInt res = R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT;
+    if( Layout_Meta_Data::IsLandscapeOrientation() )
+        {
+        // landscape must use different layout
+        res = R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT;
+        }
+
+    if( StatusPane()->CurrentLayoutResId() != res )
+        {
+        TRAP_IGNORE(
+            StatusPane()->SwitchLayoutL( res ));
+        }
+	}
+
 void CFsEmailUiHtmlViewerView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
     {
     FUNC_LOG;
@@ -928,22 +948,80 @@
             aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
             }   
         
+        TBool toolbarExists = EFalse;
+        if( iAppUi.CurrentFixedToolbar() )
+            {
+            toolbarExists = iAppUi.CurrentFixedToolbar()->IsVisible();
+            }
+        
         // Some commands are blocked when viewing embedded message object
         // or separate HTML file.
-        const TBool blockCmds( !iMessage || iActivationData.iEmbeddedMessageMode );
-        const TBool blockReplyALLCmd( !iMessage || iActivationData.iEmbeddedMessageMode ||
+        const TBool blockCmds( !iMessage || iActivationData.iEmbeddedMessageMode || toolbarExists );
+        const TBool blockReplyALLCmd( toolbarExists || !iMessage || iActivationData.iEmbeddedMessageMode ||
                 TFsEmailUiUtility::CountRecipientsSmart( iAppUi, iMessage ) < 2 );       
         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReply, blockCmds );
         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, blockReplyALLCmd );
         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, blockCmds );
         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsDelete, blockCmds );
         
+        if( iActivationData.iEmbeddedMessageMode )
+            {
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, ETrue );
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, ETrue );
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, ETrue );
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue );
+            }
+        
         TBool hideNext = !ShowNextMessageMenuInOptions();
         TBool blockNextCmd = !iMessage || iActivationData.iEmbeddedMessageMode || hideNext;
-        aMenuPane->SetItemDimmed( EFsEmailUiCmdNextMessage, blockNextCmd );
+        TInt menuPos;
+        if( aMenuPane->MenuItemExists( EFsEmailUiCmdNextMessage, menuPos ) )
+            {
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdNextMessage, blockNextCmd );
+            }
         TBool hidePrev = !ShowPreviousMessageMenuInOptions();
         TBool blockPrevCmd = !iMessage || iActivationData.iEmbeddedMessageMode || hidePrev;
-        aMenuPane->SetItemDimmed( EFsEmailUiCmdPreviousMessage, blockPrevCmd );
+        if( aMenuPane->MenuItemExists( EFsEmailUiCmdPreviousMessage, menuPos ) )
+            {
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdPreviousMessage, blockPrevCmd );
+            }
+        
+        CFSMailFolder* currentFolder = NULL;
+        if ( iMessage )
+            {
+            TRAP_IGNORE( currentFolder = 
+                iAppUi.GetMailClient()->GetFolderByUidL(
+                        iMessage->GetMailBoxId(), 
+                        iMessage->GetFolderId() ) );
+            }
+      
+        if ( currentFolder &&
+             currentFolder->GetFolderType() != EFSOutbox )
+            {
+            // Mark as read/unread options
+            TBool messageIsRead( iMessage->IsFlagSet( EFSMsgFlag_Read ) );
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, messageIsRead );
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !messageIsRead );
+            
+            // Move to another folder option
+            aMenuPane->SetItemDimmed( 
+                    EFsEmailUiCmdActionsMoveMessage, 
+                    !iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder ) );
+
+            // Follow-up flag option
+            aMenuPane->SetItemDimmed( 
+                    EFsEmailUiCmdActionsFlag,
+                    !( iMailBox && TFsEmailUiUtility::IsFollowUpSupported( *iMailBox ) ) );
+            }
+        else
+            {
+            // In case of outbox, all these are dimmed
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, ETrue );
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, ETrue );
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, ETrue );
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue );
+            }
+        delete currentFolder;
         }
     else if ( aResourceId == R_FSEMAILUI_HTMLVIEWER_SUBMENU_ZOOM_LEVEL &&
               iContainer && iContainer->BrowserControlIf() )
@@ -1044,17 +1122,60 @@
         }
     }
 
+void CFsEmailUiHtmlViewerView::HandleStatusPaneSizeChange()
+    {
+    CFsEmailUiViewBase::HandleStatusPaneSizeChange();
+    
+    if ( iContainer )
+        {
+        iContainer->SetRect( ContainerRect() );
+        }
+    }
+
+void CFsEmailUiHtmlViewerView::HandleViewRectChange()
+    {
+    CFsEmailUiViewBase::HandleViewRectChange();
+     
+     if ( iContainer )
+         {
+         iContainer->SetRect( ContainerRect() );
+         }
+    }
 
 void CFsEmailUiHtmlViewerView::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType )
     {
     FUNC_LOG;
     
+    if ( aType == EScreenLayoutChanged )
+        {
+        SetStatusBarLayout();
+        }
+    
     if ( iContainer )
         {
+        iContainer->SetRect( ContainerRect() );
         iContainer->HandleResourceChange( aType );
         }
     }
 
+TRect  CFsEmailUiHtmlViewerView::ContainerRect() const
+    {
+    TRect rect = ClientRect();
+    
+    CAknToolbar* toolbar = iAppUi.CurrentFixedToolbar();
+    if( toolbar && toolbar->IsVisible() && Layout_Meta_Data::IsLandscapeOrientation() )
+        {
+        TPoint pos = toolbar->PositionRelativeToScreen();
+        
+        // In some LS status pane layouts the toolbar will be shown on top of the client area
+        if( pos.iX > 0 )
+            {
+            rect.iBr.iX = pos.iX;
+            }
+        }
+    return rect; 
+    }
+
 void CFsEmailUiHtmlViewerView::LoadContentFromFileL( const TDesC& aFileName )
     {
     FUNC_LOG;
@@ -1085,13 +1206,13 @@
         }
     }
 
-void CFsEmailUiHtmlViewerView::LoadContentFromMailMessageL( CFSMailMessage* aMailMessage )
+void CFsEmailUiHtmlViewerView::LoadContentFromMailMessageL( CFSMailMessage* aMailMessage, TBool aResetScrollPos )
     {
     FUNC_LOG;
 
     if ( iContainer )
         {
-        iContainer->LoadContentFromMailMessageL( aMailMessage );
+        iContainer->LoadContentFromMailMessageL( aMailMessage, aResetScrollPos );
         }
     }
 
@@ -1191,7 +1312,7 @@
      
     if (iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() && aEvent == TFSEventNewMail)
         {
-        UpdateNaviPaneL();
+        UpdateEmailHeaderIndicators();
         }
     // </cmail>
     }
@@ -1204,7 +1325,7 @@
     // Set the radio button state to match current zoom level
     if ( zoomLevelIdx >= 0 && zoomLevelIdx < KZoomLevelCount )
         {
-        TInt curZoomLevel = zoomLevelIdx + EFsEmailUiCmdZoomSmallest;
+        TInt curZoomLevel = zoomLevelIdx + EFsEmailUiCmdZoomSmall;
         aMenuPane->SetItemButtonState( curZoomLevel, EEikMenuItemSymbolOn );
         }
     }
@@ -1305,6 +1426,11 @@
                 SaveEmailAsContactL( aEmailAddress );
                 }
             break;
+            case EFsEmailUiCmdActionsAddContact:
+			   {
+			   SaveEmailAsContactL( aEmailAddress );
+			   }
+			   break;
             case EFsEmailUiCmdActionsCall:
                 {
                 CallAdressL( aEmailAddress, EFalse );
@@ -1325,6 +1451,11 @@
                 LaunchRemoteLookupL( aEmailAddress );
                 }
             break;
+            case EFsEmailUiCmdActionsCopyToClipboard:
+            	{
+            	CopyCurrentToClipBoardL( aEmailAddress );
+            	}
+            break;
             default:
                 //nothing right now?
                 break;
@@ -1332,6 +1463,33 @@
         }
     }
 
+// -----------------------------------------------------------------------------
+// CFsEmailUiHtmlViewerView::HandleWebAddressCommandL()
+// -----------------------------------------------------------------------------
+//
+void CFsEmailUiHtmlViewerView::HandleWebAddressCommandL( TInt aCommand, const TDesC& aUrl )
+    {
+    FUNC_LOG;
+    switch ( aCommand )
+    	{
+    	case EFsEmailUiCmdActionsOpenWeb:
+    		{
+    		OpenLinkInBrowserL( aUrl );
+    		break;
+    		}
+		case EFsEmailUiCmdActionsAddBookmark:
+			{
+			SaveWebAddressToFavouritesL( aUrl );
+			break;
+			}
+		case EFsEmailUiCmdActionsCopyWWWAddressToClipboard:
+			{
+			CopyCurrentToClipBoardL( aUrl );
+			break;
+			}    				
+    	}
+    }
+
 void CFsEmailUiHtmlViewerView::SaveEmailAsContactL(
     const TDesC& aEmailAddress )
     {
@@ -1707,7 +1865,7 @@
         if ( newState != EFollowUpNoChanges )
             {
             // Notify appui of changed mail item
-            UpdateNaviPaneL();
+            UpdateEmailHeaderIndicators();
             SendEventToAppUiL( TFSEventMailChanged );
             }
         }
@@ -2144,7 +2302,7 @@
                 
         if( iMessage )
             {
-            LoadContentFromMailMessageL( iMessage );  
+            LoadContentFromMailMessageL( iMessage , EFalse);  
             SetMskL();
             }
         }
@@ -2815,134 +2973,32 @@
     iMailBox = NULL;
     }
 
+void CFsEmailUiHtmlViewerView::ReloadPageL(  ) 
+    {
+    FUNC_LOG;
+    if( iContainer )
+        {
+        iContainer->ReloadPageL();
+        }
+    }
+
 TBool CFsEmailUiHtmlViewerView::GetAsyncFetchStatus()
     {
     return ( iFetchingHtmlMessageBody || iFetchingMessageStructure || iFetchingPlainTextMessageBody );
     }
     
 // ---------------------------------------------------------------------------
-// CFsEmailUiHtmlViewerView::UpdateNaviPaneL
+// CFsEmailUiHtmlViewerView::UpdateEmailHeaderIndicatorsL
 // ---------------------------------------------------------------------------
 //
-void CFsEmailUiHtmlViewerView::UpdateNaviPaneL( TBool aForESMR )
+void CFsEmailUiHtmlViewerView::UpdateEmailHeaderIndicators()
     {
     FUNC_LOG;
-    // Get navigation decorator for mail viewer
-    CAknNavigationDecorator* naviDecorator = iAppUi.NaviDecoratorL( MailViewerId );
-    if ( naviDecorator )
-        {
-        // Check if there's next and previous message available, and set
-        // the navipane arrows accordingly
-        TFSMailMsgId currentMsgId = iMessage->GetMessageId();
-        TFSMailMsgId tmpMsgId;
-        TFSMailMsgId tmpMsgFolderId;
-        CAknNavigationDecorator::TScrollButton nextButton = CAknNavigationDecorator::ERightButton;
-        CAknNavigationDecorator::TScrollButton prevButton = CAknNavigationDecorator::ELeftButton;
-        if (AknLayoutUtils::LayoutMirrored())
-            {
-            nextButton = CAknNavigationDecorator::ELeftButton;
-            prevButton = CAknNavigationDecorator::ERightButton;
-            }
-        if ( iAppUi.IsNextMsgAvailable( currentMsgId, tmpMsgId, tmpMsgFolderId ) )
-            {
-            naviDecorator->SetScrollButtonDimmed( nextButton, EFalse );
-            }
-        else
-            {
-            naviDecorator->SetScrollButtonDimmed( nextButton, ETrue );
-            }
-        if ( iAppUi.IsPreviousMsgAvailable( currentMsgId, tmpMsgId, tmpMsgFolderId ) )
-            {
-            naviDecorator->SetScrollButtonDimmed( prevButton, EFalse );
-            }
-        else
-            {
-            naviDecorator->SetScrollButtonDimmed( prevButton, ETrue );
-            }
-
-        // Set this view's navipane to the top of the navipane control stack
-        CAknNavigationControlContainer* naviPaneContainer =
-            static_cast<CAknNavigationControlContainer*>(
-            StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
-        naviPaneContainer->PushL( *naviDecorator );
-        naviDecorator->SetNaviDecoratorObserver( aForESMR ? NULL : this );
-        }
-
-    // Set priority and follow-up flags
-    CCustomStatuspaneIndicators* indicators = iAppUi.GetStatusPaneIndicatorContainer();
-    if ( indicators)
-        {
-        indicators->ShowStatusPaneIndicators();
-
-        if ( iMessage->IsFlagSet( EFSMsgFlag_Low ) )
-            {
-            indicators->SetPriorityFlag( EMsgPriorityLow );
-            }
-        else if ( iMessage->IsFlagSet( EFSMsgFlag_Important ) )
-            {
-            indicators->SetPriorityFlag( EMsgPriorityHigh );
-            }
-        else
-            {
-            indicators->SetPriorityFlag( EMsgPriorityNormal );
-            }
-
-        CCustomStatuspaneIndicators::TFollowUpFlagType flagType = CCustomStatuspaneIndicators::EFollowUpNone;
-        if (iMessage->IsFlagSet(EFSMsgFlag_FollowUp))
-            {
-            flagType = CCustomStatuspaneIndicators::EFollowUp;
-            }
-        if (iMessage->IsFlagSet(EFSMsgFlag_FollowUpComplete))
-            {
-            flagType = CCustomStatuspaneIndicators::EFollowUpComplete;
-            }
-        indicators->SetFollowUpFlag( flagType );
-        }
-
-    }
-
-// ---------------------------------------------------------------------------
-// CFsEmailUiHtmlViewerView::HandleNaviDecoratorEventL
-// ---------------------------------------------------------------------------
-//
-void CFsEmailUiHtmlViewerView::HandleNaviDecoratorEventL( TInt aEventID )
-    {
-    FUNC_LOG;
-    CAknNavigationDecorator* naviDecorator = iAppUi.NaviDecoratorL( MailViewerId );
-    if ( naviDecorator )
-        {
-        naviDecorator->SetNaviDecoratorObserver( NULL );
-        }
-    MAknNaviDecoratorObserver::TAknNaviDecoratorEvents nextButton = MAknNaviDecoratorObserver::EAknNaviDecoratorEventRightTabArrow;
-    if (AknLayoutUtils::LayoutMirrored())
-        {
-        nextButton = MAknNaviDecoratorObserver::EAknNaviDecoratorEventLeftTabArrow;
-        }
-    if( aEventID == nextButton )
-        {
-        ShowNextMessageL();
-        }
-    else
-        {
-        ShowPreviousMessageL();
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CFsEmailUiHtmlViewerView::HideNaviPane
-// -----------------------------------------------------------------------------
-void CFsEmailUiHtmlViewerView::HideNaviPane()
-    {
-    FUNC_LOG;
-    CAknNavigationControlContainer* naviPaneContainer = NULL;
-    TRAP_IGNORE( naviPaneContainer = static_cast<CAknNavigationControlContainer*>(StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ) );
-    TRAP_IGNORE( naviPaneContainer->PushDefaultL() );
-
-    CCustomStatuspaneIndicators* indicators = iAppUi.GetStatusPaneIndicatorContainer();
-    if ( indicators)
-        {
-        indicators->HideStatusPaneIndicators();
-        }
+    // Reload mail header.
+    if ( iContainer )
+    	{
+    	iContainer->RefreshCurrentMailHeader();
+    	}
     }
 
 // -----------------------------------------------------------------------------
@@ -2976,7 +3032,134 @@
     return retVal;
     }
 
+// -----------------------------------------------------------------------------
+// CFsEmailUiHtmlViewerView::CopyToClipBoardL
+// -----------------------------------------------------------------------------
+void CFsEmailUiHtmlViewerView::CopyCurrentToClipBoardL( const TDesC& aArgument ) const
+	{
+    FUNC_LOG;
+    
+    // Making sure that we are copying something to the clipboard 
+    if ( aArgument.Length() > 0 )
+        {
+        HBufC* clipBoardText = aArgument.AllocLC();
+        CClipboard* cb = CClipboard::NewForWritingLC( CCoeEnv::Static()->FsSession() );
+		cb->StreamDictionary().At( KClipboardUidTypePlainText );
+		CPlainText* plainText = CPlainText::NewL();
+		CleanupStack::PushL( plainText );
+		plainText->InsertL( 0 , *clipBoardText );
+		plainText->CopyToStoreL( cb->Store(), cb->StreamDictionary(), 0, plainText->DocumentLength() );
+		CleanupStack::PopAndDestroy( plainText );
+		cb->CommitL();
+		CleanupStack::PopAndDestroy( cb );
+		CleanupStack::PopAndDestroy( clipBoardText );     
+        }
+	}
 
+// --------------------------------------------------------------------------------
+// CFsEmailUiHtmlViewerView::OpenLinkInBrowserL
+// --------------------------------------------------------------------------------
+void CFsEmailUiHtmlViewerView::OpenLinkInBrowserL( const TDesC& aUrl ) const
+	{
+	FUNC_LOG;
+	
+	// Create session
+	RApaLsSession session;
+	User::LeaveIfError( session.Connect() );
+	CleanupClosePushL( session );
+	 
+	// Gets the default application UID for for the given MIME type
+	TUid uid;
+	TDataType dataType( _L8( "text/html" ) );
+	session.AppForDataType( dataType, uid );
+	 
+	// Runs the default application using the dataType
+	TThreadId threadId;
+	User::LeaveIfError( session.StartDocument( aUrl , dataType, threadId ) );
+	 
+	CleanupStack::PopAndDestroy(); // session
+}
+
+// --------------------------------------------------------------------------------
+// CFsEmailUiHtmlViewerView::SaveWebAddressToFavouritesL
+// --------------------------------------------------------------------------------
+void CFsEmailUiHtmlViewerView::SaveWebAddressToFavouritesL( const TDesC& aUrl ) const
+	{
+	FUNC_LOG;
+	HBufC* url = aUrl.AllocLC();
+	
+	RFavouritesSession fSession;
+	User::LeaveIfError( fSession.Connect() );
+	CleanupClosePushL( fSession );
+
+	RFavouritesDb favourites;
+	User::LeaveIfError( favourites.Open( fSession, KBrowserBookmarks ) );
+	CleanupClosePushL( favourites );
+
+	CFavouritesItem *favouritesItem = CFavouritesItem::NewLC();
+	favouritesItem->SetType( CFavouritesItem::EItem );
+	favouritesItem->SetUrlL( aUrl );
+	// Should be less than KFavouritesMaxName ( 50 )
+	if ( url->Length() > KFavouritesMaxName )
+		{
+		favouritesItem->SetNameL( url->Left( KFavouritesMaxName ) );
+		}
+	else
+		{
+		favouritesItem->SetNameL( *url );
+		}
+
+	favouritesItem->SetParentFolder( KFavouritesRootUid );
+
+	TInt error = favourites.Add( *favouritesItem, ETrue );
+
+	CleanupStack::PopAndDestroy( favouritesItem );
+	CleanupStack::PopAndDestroy( &favourites );
+	CleanupStack::PopAndDestroy( &fSession );
+
+	CleanupStack::PopAndDestroy( url );
+	
+	if ( error == KErrNone )
+		{
+		TFsEmailUiUtility::ShowInfoNoteL(
+			R_FREESTYLE_EMAIL_UI_VIEWER_BOOKMARK_ADDED, ETrue );
+		}
+	else // Error in bookmark creation, show could not complete message
+		{
+		TFsEmailUiUtility::ShowErrorNoteL(
+			R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
+		}
+	}
+
+/*
+ * Delaying the fetch for MfE till the user scrolls to the bottom of 
+ * the message. 
+ */
+void CFsEmailUiHtmlViewerView::StartFetchingMessageL()
+    {
+    CFSMailMessagePart* htmlBodyPart = iMessage->HtmlBodyPartL();
+    TFetchedType type;
+    if( htmlBodyPart )
+       {
+       type = EMessageHtmlBodyPart;
+       }
+    else
+       {
+       type = EMessagePlainTextBodyPart;
+       }
+          
+    if ( !MessagePartFullyFetchedL( type ))
+       {
+       iAsyncProcessComplete = EFalse;
+       iStartAsyncFetchType = type;
+       //check to make sure we don't kick off fetch twice for the cases where bodypart 
+       //not found(OZ)
+       if(iMessage && !GetAsyncFetchStatus())
+           {
+           StartFetchingMessagePartL( *iMessage, type );
+           }
+       }
+    }
 //////////////////////////////////////////////////////////////////////////////////////
 // CLASS IMPLEMENTATION CHANGE TO FLAG DIALOG GLOBAL NOTE
 ///////////////////////////////////////////////////////////////////////////////////
--- a/emailuis/emailui/src/FreestyleEmailUiLauncherGrid.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiLauncherGrid.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -98,23 +98,24 @@
     iVisualiser = aVisualiser;
 	}
 
-void CFSEmailUiLauncherGrid::NotifyControlVisibility( TBool  aIsVisible, CAlfDisplay& aDisplay )
+void CFSEmailUiLauncherGrid::NotifyControlVisibility( TBool  aIsVisible,
+													  CAlfDisplay& aDisplay )
     {
     FUNC_LOG;
     
-    //Add & remove extra touch events. 
-    if(aIsVisible && !iDraggingSet)
+    // Add & remove extra touch events. 
+    if( aIsVisible && !iDraggingSet )
         {
         iDraggingSet = ETrue; 
-        aDisplay.Roster().AddPointerEventObserver(EAlfPointerEventReportDrag, *this);
-        aDisplay.Roster().AddPointerEventObserver(EAlfPointerEventReportLongTap, *this);
-        aDisplay.Roster().AddPointerEventObserver(EAlfPointerEventReportUnhandled, *this);
+        aDisplay.Roster().AddPointerEventObserver( EAlfPointerEventReportDrag, *this );
+        aDisplay.Roster().AddPointerEventObserver( EAlfPointerEventReportLongTap, *this );
+        aDisplay.Roster().AddPointerEventObserver( EAlfPointerEventReportUnhandled, *this );
         }
-    else if(!aIsVisible && iDraggingSet )
+    else if( !aIsVisible && iDraggingSet )
         {
-        aDisplay.Roster().RemovePointerEventObserver(EAlfPointerEventReportDrag, *this);
-        aDisplay.Roster().RemovePointerEventObserver(EAlfPointerEventReportLongTap, *this);
-        aDisplay.Roster().RemovePointerEventObserver(EAlfPointerEventReportUnhandled, *this);        
+        aDisplay.Roster().RemovePointerEventObserver( EAlfPointerEventReportDrag, *this );
+        aDisplay.Roster().RemovePointerEventObserver( EAlfPointerEventReportLongTap, *this );
+        aDisplay.Roster().RemovePointerEventObserver( EAlfPointerEventReportUnhandled, *this );
         iDraggingSet = EFalse;
         }
     }
--- a/emailuis/emailui/src/FreestyleEmailUiLauncherGridVisualiser.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiLauncherGridVisualiser.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -715,7 +715,7 @@
 	    TFSLauncherGridMailboxStatus mbStatus = CheckMailboxStatusL();
 
 	    // Checks if a device has a keyboard or not.
-		if( !iKeyboardFlipOpen )
+		if( !IsFocusShown() )
 			{
 			if( mbStatus.iMailboxCount <= 0 )
 				{
@@ -883,6 +883,7 @@
 	    	// Hide the focus.
 	        iAppUi.SetFocusVisibility( EFalse );
 	        HandleButtonReleaseEvent(); // Finishes the focus removal.
+	        iStylusPopUpMenuLaunched = EFalse;
 			break;
 			}
 		case EFsEmailUiCmdSync:
@@ -993,6 +994,7 @@
         	// The pop-up menu was closed. Hide the focus.
             iAppUi.SetFocusVisibility( EFalse );
             HandleButtonReleaseEvent(); // Finishes the focus removal.
+	        iStylusPopUpMenuLaunched = EFalse;
        		break;
        		}
         case EFsEmailUiCmdHide:
@@ -1116,7 +1118,7 @@
                 	{
                 	// A pop-up menu was launched. Do not open the selected
                 	// item.
-                	iStylusPopUpMenuLaunched = EFalse;
+                	iItemIdInButtonDownEvent.iLaunchSelection = EFalse;
                 	break;
                 	}
 
@@ -1143,24 +1145,34 @@
                 {
                 // if pointer is moved on to other item, decrease focused
                 // item's icon.
-                if( ( currentlyFocused != id ) &&
-                    ( iItemIdInButtonDownEvent.iItemId != KErrNotFound ) )
+                if ( ( currentlyFocused != id ) &&
+                     ( iItemIdInButtonDownEvent.iItemId != KErrNotFound ) )
                     {
                     iItemIdInButtonDownEvent.iLaunchSelection = EFalse;
                     ResizeItemIcon( ETrue );
                     }
+
                 // if pointer is moved on item that has focus, increase item's
                 // icon.
-                else if( id == iItemIdInButtonDownEvent.iItemId )
+                else if ( id == iItemIdInButtonDownEvent.iItemId )
                     {
                     iItemIdInButtonDownEvent.iLaunchSelection = ETrue;
                     ResizeItemIcon( EFalse );
                     }
+
                 break;
                 }
             case TPointerEvent::EButtonRepeat:
             	{
             	// Long tap.
+                if ( currentlyFocused != id ||
+                     iItemIdInButtonDownEvent.iItemId == KErrNotFound )
+            		{
+            		// The item beneath the touch was changed during the long
+            		// tap. Thus, do not show the pop-up.
+            		break;
+            		}
+
             	// Check the type of the currently selected item.
     			TInt itemType = iCurrentLevel.iItems[id].iId;
 
@@ -1235,15 +1247,16 @@
     TInt count = iCurrentLevel.iItemVisualData.Count();
     const TPoint pos = aEvent.PointerEvent().iParentPosition;
 
-    for(TInt a = 0; count > a; a++)
+    for ( TInt a = 0; count > a; a++ )
         {
-        const TRect rect(iCurrentLevel.iItemVisualData[a].iBase->DisplayRect());
-        if(rect.Contains( pos ))
+        const TRect rect( iCurrentLevel.iItemVisualData[a].iBase->DisplayRect() );
+        if ( rect.Contains( pos ) )
             {
             result = a;
             break;
             }
         }
+
     return result;
     }
 
@@ -1285,6 +1298,7 @@
 
     // Move the selector over the newly focused icon
     MoveSelectorToCurrentItem( aDir );
+    UpdateFocusVisibility();
     }
 
 
@@ -1541,16 +1555,17 @@
 void CFSEmailUiLauncherGridVisualiser::PopulateL( TLevel& aLevel )
     {
     FUNC_LOG;
+
     if ( iConstructionCompleted )
         {
         for( TInt i = 0; i < aLevel.iItemVisualData.Count(); i++ )
             {
             aLevel.iItemVisualData[i].iBase->RemoveAndDestroyAllD();
             }
+
         aLevel.iItemVisualData.Reset();
         aLevel.iItems.Reset();
 
-// <cmail> Use layout data instead of hard-coded values
 	    TRect mainPaneRect;
 	    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
 
@@ -1572,21 +1587,19 @@
 
 	    TAknLayoutText gridText;
 	    gridText.LayoutText(itemrc, AknLayoutScalable_Apps::cell_cmail_l_pane_t1(var));
-// </cmail>
 
-        if( aLevel.iParent >= 0 )
+        if ( aLevel.iParent >= 0 )
             {
             iModel->FindChildren( aLevel.iParent, aLevel.iItems );
 
-            for( TInt i = 0; i < aLevel.iItems.Count(); i++ )
+            for ( TInt i = 0; i < aLevel.iItems.Count(); i++ )
                 {
                 TItemVisualData newItem;
 
                 newItem.iBase = CAlfAnchorLayout::AddNewL( *iControl, aLevel.iGridLayout );
                 newItem.iBase->SetTactileFeedbackL( ETouchEventStylusDown,  ETouchFeedbackBasic );
 
-// <cmail> Use layout data instead of hard-coded values
-                // Set anchors for text
+                // Set anchors for text.
                 newItem.iBase->SetAnchor(
                     EAlfAnchorTopLeft,
                     0,
@@ -1621,22 +1634,21 @@
                     EAlfAnchorMetricAbsolute,
                     EAlfAnchorMetricAbsolute,
                     TAlfTimedPoint( gridIconRect.Rect().iBr.iX, gridIconRect.Rect().iBr.iY ) ); //gridIconSize/2, gridIconSize+KTopMargin ) );
-// </cmail>
 
                 newItem.iText = CAlfTextVisual::AddNewL( *iControl, newItem.iBase );
                 newItem.iText->EnableShadow( EFalse );
-// <cmail> Use layout data instead of hard-coded values
-				TRgb itemColor (KRgbGray);
+
+				TRgb itemColor( KRgbGray );
+
 			    // text #9 application grid unfocused application title texts #215
 				if( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
 					itemColor, KAknsIIDQsnTextColors,
 					EAknsCIQsnTextColorsCG9 ) != KErrNone )
 					{
-				itemColor = gridText.Color();//iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
+					itemColor = gridText.Color();
 					}
-				newItem.iText->SetColor(itemColor);
-// </cmail>
 
+				newItem.iText->SetColor( itemColor );
                 newItem.iText->SetTextL( *aLevel.iItems[i].iCaption );
 
                 TAlfTimedValue opacity;
@@ -1652,22 +1664,17 @@
                 newItem.iImage->SetImage( TAlfImage( *aLevel.iItems[i].iIconTexture ) );
                 newItem.iImage->SetFlag( EAlfVisualFlagManualSize );
 
-// <cmail> Use layout data instead of hard-coded values
                 newItem.iImage->SetSize( gridIconRect.Rect().Size() );
                 newItem.iImage->SetScale( KScaleNotSelected );
-// </cmail>
 
                 User::LeaveIfError( aLevel.iItemVisualData.Append( newItem ) );
                 }
             }
 
-// <cmail> Use layout data instead of hard-coded values
         // Set columns and rows
-        //iVisibleColumns = iAppUi.LayoutHandler()->GridColumnsInThisResolution();
-        //iVisibleRows = iAppUi.LayoutHandler()->GridRowsInThisResolution();
         iVisibleRows = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastRow() + 1;
         iVisibleColumns = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastColumn() + 1;
-// </cmail>
+
         iRowCount = ( iCurrentLevel.iItemVisualData.Count() + iVisibleColumns - 1 ) / iVisibleColumns;
 
         aLevel.iGridLayout->MoveToFront();
@@ -2540,12 +2547,23 @@
         }
     }
 
+
+// -----------------------------------------------------------------------------
+// CFSEmailUiLauncherGridVisualiser::UpdateFocusVisibility()
+// Updates the selector and the text color of a focused item.
+// -----------------------------------------------------------------------------
+//
 void CFSEmailUiLauncherGridVisualiser::UpdateFocusVisibility()
     {
-    if( iSelector )
+    const TBool showFocus =	( IsFocusShown() ||
+							  iItemIdInButtonDownEvent.iItemId >= 0 );
+
+    // Update the selector.
+    if ( iSelector )
         {
         TAlfTimedValue selectorOpacity;
-        if( IsFocusShown() || iItemIdInButtonDownEvent.iItemId >= 0 )
+
+        if ( showFocus )
             {
             selectorOpacity.SetValueNow( 1 );
             }
@@ -2553,10 +2571,49 @@
             {
             selectorOpacity.SetValueNow( 0 );
             }
+
         iSelector->SetOpacity( selectorOpacity );
         }
+
+    // Update the text color of the previously and newly selected items. 
+	TRgb normalColor( KRgbGray );
+	TRgb focusedColor( KRgbGray );
+
+	if ( ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), normalColor,
+								      KAknsIIDQsnTextColors,
+								      EAknsCIQsnTextColorsCG9 ) != KErrNone ) ||
+		 ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), focusedColor,
+									  KAknsIIDQsnTextColors,
+									  EAknsCIQsnTextColorsCG11 ) != KErrNone ) )
+		{
+		// No colors available.
+		return;
+		}
+
+	CAlfTextVisual* textVisual = NULL;
+	const TInt itemCount( iCurrentLevel.iItemVisualData.Count() );
+
+	// Set the colors of the captions not focused to normal and if an item is
+	// focused, set the color of its caption using the highlighted theme color.
+	for ( TInt i = 0; i < itemCount; ++i )
+		{
+		textVisual = iCurrentLevel.iItemVisualData[i].iText;
+
+		if ( textVisual )
+			{
+		    if ( showFocus && iCurrentLevel.iSelected == i )
+		        {
+                textVisual->SetColor( focusedColor );
+		        }
+		    else
+		        {
+                textVisual->SetColor( normalColor );
+		        }
+			}
+		}
     }
 
+
 void CFSEmailUiLauncherGridVisualiser::FlipStateChangedL( TBool aKeyboardFlipOpen )
     {
     CFsEmailUiViewBase::FlipStateChangedL( aKeyboardFlipOpen );
--- a/emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -23,9 +23,7 @@
 #include <gulicon.h>
 #include <StringLoader.h>
 #include <FreestyleEmailUi.rsg>
-//<cmail>
 #include <featmgr.h>
-//</cmail>
 #include "CFSMailClient.h"
 #include "CFSMailBox.h"
 #include "CFSMailFolder.h"
@@ -54,22 +52,16 @@
 #include <aknnotewrappers.h>
 #include <msvapi.h>
 #include <akntitle.h>
-//<cmail>
 #include "ESMailSettingsPluginUids.hrh"
 #include "ESMailSettingsPlugin.h"
 #include "MFSMailBrandManager.h"
-//</cmail>
 #include <AknWaitDialog.h>
-// <cmail>
 #include <aknlayoutscalable_apps.cdl.h>
 #include <layoutmetadata.cdl.h>
 #include <csxhelp/cmail.hlp.hrh>
-// </cmail>
 // Meeting request
 #include <MeetingRequestUids.hrh>
-// <cmail>
 #include "cesmricalviewer.h"
-//</cmail>
 #include <aknstyluspopupmenu.h>
 #include <akntoolbar.h>
 
@@ -160,6 +152,7 @@
 
 	iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
 	iAsyncRedrawer = new (ELeave) CAsyncCallBack( CActive::EPriorityLow );
+	iLastFocus = EFalse;
  	}
 
 // CFSEmailUiMailListVisualiser::DoFirstStartL()
@@ -261,7 +254,7 @@
 		iCoeEnv->CreateResourceReaderLC( reader,
 				R_STYLUS_POPUP_MENU_MESSAGE_LIST_VIEW );
 		iStylusPopUpMenu->ConstructFromResourceL( reader );
-		CleanupStack::PopAndDestroy();
+		CleanupStack::PopAndDestroy(); // reader
         }
 
     iAppUi.LayoutHandler()->SetListMarqueeBehaviour( iMailList );
@@ -289,8 +282,8 @@
     : CFsEmailUiViewBase( aMailListControlGroup, *aAppUi ),
     iEnv( aEnv ),
     iListMarkItemsState( ETrue ), //Initlly list has no markings
-	iMoveToFolderOngoing( EFalse ),
-	iStylusPopUpMenuLaunched( EFalse )
+    iConsumeStdKeyYes_KeyUp( EFalse ), // use to prevent Call application execution if call for contact processed
+    iMoveToFolderOngoing( EFalse )
 	{
     FUNC_LOG;
 	}
@@ -1204,7 +1197,7 @@
 	// Inform MR observer if needed, special MR case, returning from attachment list
 	iAppUi.MailViewer().CompletePendingMrCommand();
 
-	//Make sure that correct component is set to focused.
+	// Make sure that correct component is set to focused.
 	if ( iFocusedControl == EMailListComponent )
 	    {
 	    SetTreeListFocusedL();
@@ -1215,7 +1208,6 @@
 	    iControlBarControl->MakeSelectorVisible( iAppUi.IsFocusShown() );
 	    }
 	UpdateButtonTextsL();
-
 	FocusVisibilityChange( iAppUi.IsFocusShown() );
 	iAppUi.ShowTitlePaneConnectionStatus();
 	}
@@ -1313,6 +1305,12 @@
     // MAIN MENU ***************************************************************************
 	if ( aResourceId == R_FSEMAILUI_MAILLIST_MENUPANE )
 		{
+		// Saves a focus visibility.
+		iLastFocus = EFalse;
+		if( iFocusedControl == EMailListComponent && IsFocusShown() )
+		    {
+		    iLastFocus = ETrue;
+		    }
 	    if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ))
 		   {
 		   // remove help support in pf5250
@@ -1320,170 +1318,33 @@
 		   }
 
 	    // Checks if a device has a keyboard or not.
-		if( !iKeyboardFlipOpen )
+		if( !iLastFocus )
     	    {
-	        aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpen, ETrue );
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue);
-	        aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue );
-            }
-
-        // OFFLINE/ONLINE MENU SELECTION
-        TFSMailBoxStatus onlineStatus = iAppUi.GetActiveMailbox()->GetMailBoxStatus();
-        aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, onlineStatus == EFSMailBoxOnline );
-        aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, onlineStatus == EFSMailBoxOffline );
-
-        // Sync/cancel sync
-        TBool supportsSync = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaSupportsSync );
-        if ( !supportsSync )
-            {
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue );
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue );
-            }
-        else if ( GetLatestSyncState() )
-            {
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue );
-            }
-        else
-            {
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue );
-            }
-
-        //MESSAGEREADER MENU SELECTION
-		if ( iAppUi.MessageReaderSupportsFreestyle() )
-			{
-			aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, EFalse );
-			}
-		else
-			{
-			aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue );
-			}
-		// Disable read in outbox and drafts
-		if ( currentFolderType == EFSDraftsFolder ||
-		     currentFolderType == EFSOutbox )
-			{
-			aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue );
-			}
-
-	    // EMPTY LIST, MOST OPTIONS ARE HIDDEN
-	    if ( !iModel->Count() || !iMailFolder )
-	        {
-	        aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpen, ETrue );
-	        aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue );
-	        aMenuPane->SetItemDimmed( EFsEmailUiCmdMore, ETrue );
-	        aMenuPane->SetItemDimmed( EFsEmailUiCmdSearch, ETrue );
-	        aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue );
-	        }
-
-	    // NO TARGET ITEMS, E.G FOCUS ON DIVIDER AND NO MARKED ITEMS, ITEM RELATED OPTIONS ARE HIDDEN
-	    else if ( !targetEntries.Count() )
-	        {
-	        aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue );
-	        aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, ETrue );
-	        }
-
-	    // Open command is available only if there's exactly one target item
-	    if ( targetEntries.Count() != 1 )
-	        {
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpen, ETrue );
-	        }
-
-	    // FOLDER SPECIFIC COMMAND HIDING
-	    // In the outbox folder, Open command is inavailable in any case
-	    if ( currentFolderType == EFSOutbox )
-	        {
-	        aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpen, ETrue );
-	        }
-
-	    // "Clear deleted folder" command is available only in Deleted folder
-	    if ( currentFolderType != EFSDeleted || !iModel->Count() )
-	        {
-	        aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsEmptyDeleted, ETrue );
-	        }
-		}
-    // MAIN MENU ***************************************************************************
-
-
-	// ACTIONS SUBMENU *********************************************************************
-	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MAIL_ACTIONS  )
-		{
-		// Actions menu should never be available when there's no marked or focused item(s)
-		__ASSERT_DEBUG( targetEntries.Count(), Panic(EFSEmailUiUnexpectedValue) );
-
-		CFSMailMessage* targetMessage = NULL;
-        if ( targetEntries.Count() == 1 )
-            {
-            targetMessage = &MsgPtrFromListIdL( targetEntries[0] );
-            }
-
-		// Meeting request mode is in use when there's exactly one target item and it's a
-		// calendar message and MRUI is available.
-		TBool showMrActions = EFalse;
-
-        if ( targetMessage && targetMessage->IsFlagSet( EFSMsgFlag_CalendarMsg ) &&
-             iAppUi.MrViewerInstanceL() &&
-             iAppUi.MrViewerInstanceL()->CanViewMessage( *targetMessage ) &&
-             currentFolderType != EFSOutbox &&
-		     currentFolderType != EFSDraftsFolder )
-		    {
-		    showMrActions = ETrue;
-		    }
-
-        // CALENDAR EVENT ACTIONS SUBMENU
-        if ( showMrActions )
-            {
             // Hide all the normal email message specific actions
             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReply, ETrue );
             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue );
             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, ETrue );
-
-            // Hide the irrelevant MR actions
-            TESMRMeetingRequestMethod mrMethod( EESMRMeetingRequestMethodUnknown );
-            if ( iAppUi.MrViewerInstanceL() )
-                {
-                TRAP_IGNORE( mrMethod = iAppUi.MrViewerInstanceL()->ResolveMeetingRequestMethodL( *targetMessage ) );
-                }
-            switch ( mrMethod )
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue);
+
+            TInt markedCount = CountMarkedItemsL();
+            // Hide mark/unmark all when not applicable
+            if ( markedCount == EmailsInModelL() ) // Hide mark all
+		       {
+		       aMenuPane->SetItemDimmed( EFsEmailUiCmdSubMenuMark, ETrue );
+		       }
+            if ( markedCount == 0 ) // Hide unmark all
+		       {
+		       aMenuPane->SetItemDimmed( EFsEmailUiCmdSubMenuUnmark, ETrue );
+		       }
+
+            }
+        else
+    	    {
+    		CFSMailMessage* targetMessage = NULL;
+            if ( targetEntries.Count() == 1 )
                 {
-                case EESMRMeetingRequestMethodRequest:
-                    {
-                    aMenuPane->SetItemDimmed(EFsEmailUiCmdCalRemoveFromCalendar, ETrue);
-                    }
-                    break;
-                case EESMRMeetingRequestMethodCancellation:
-                    {
-                    aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsAccept, ETrue);
-                    aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsTentative, ETrue);
-                    aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsDecline, ETrue);
-
-                    TBool supportsRemove = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaRemoveFromCalendar );
-                    if( !supportsRemove )
-                        {
-                        aMenuPane->SetItemDimmed(EFsEmailUiCmdCalRemoveFromCalendar, ETrue);
-                        }
-                    }
-                    break;
-                case EESMRMeetingRequestMethodResponse:
-                case EESMRMeetingRequestMethodUnknown:
-                    {
-                    aMenuPane->SetItemDimmed(EFsEmailUiCmdCalRemoveFromCalendar, ETrue);
-                    aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsAccept, ETrue);
-                    aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsTentative, ETrue);
-                    aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsDecline, ETrue);
-                    }
-                    break;
-                default:
-                    break;
+                targetMessage = &MsgPtrFromListIdL( targetEntries[0] );
                 }
-            }
-
-        // MAIL MESSAGE ACTIONS SUBMENU
-        else
-            {
-            // Hide all the calendar event options
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdCalActionsAccept, ETrue );
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdCalActionsTentative, ETrue );
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdCalActionsDecline, ETrue );
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdCalRemoveFromCalendar, ETrue );
 
             // Hide the irrelevant reply / reply all / forward commands
             TInt numRecipients(0);
@@ -1493,7 +1354,7 @@
                 numRecipients = TFsEmailUiUtility::CountRecipientsSmart( iAppUi, targetMessage );
                 }
             // All reply/forward options are hidden when multiple marked messages or folder is outbox or drafts
-            if ( targetEntries.Count() > 1 ||
+            if ( targetEntries.Count() != 1 ||
                  currentFolderType == EFSOutbox ||
                  currentFolderType == EFSDraftsFolder )
                 {
@@ -1507,8 +1368,32 @@
                 {
                 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue );
                 }
-           }
-
+
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdSubMenuUnmark, ETrue);
+            }
+
+	    // EMPTY LIST, MOST OPTIONS ARE HIDDEN
+	    if ( !iModel->Count() || !iMailFolder )
+	        {
+	        aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, ETrue );
+	        aMenuPane->SetItemDimmed( EFsEmailUiCmdSubMenuMark, ETrue );
+	        aMenuPane->SetItemDimmed( EFsEmailUiCmdSubMenuUnmark, ETrue );
+	        aMenuPane->SetItemDimmed( EFsEmailUiCmdSearch, ETrue );
+	        }
+
+	    // FOLDER SPECIFIC COMMAND HIDING
+	    // "Clear deleted folder" command is available only in Deleted folder
+	    if ( currentFolderType != EFSDeleted || !iModel->Count() )
+	        {
+	        aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsEmptyDeleted, ETrue );
+	        }
+		}
+    // MAIN MENU ***************************************************************************
+
+
+	// ACTIONS SUBMENU *********************************************************************
+	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MAIL_ACTIONS  )
+		{
         // COMMON PART OF ACTIONS SUBMENU
 		aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, !IsMarkAsReadAvailableL() );
         aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !IsMarkAsUnreadAvailableL() );
@@ -1516,57 +1401,25 @@
 		if ( !supportsMoving || !iMailFolder ) // Hide move from actions if not supported
 			{
 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, ETrue );
-			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue );
 			}
 		else
 			{
 			// Moving supported, show/hide moving options depending on the current folder
-			// First check deleted items case, IMS does not support deleted sync
-			if ( currentFolderType == EFSDeleted )
+			// Check for outbox case
+			if ( currentFolderType == EFSOutbox )
 				{
-				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue );	// Dim in deleted
-				}
-			// Then check for outbox case, move to drafts is allowed, other moves not
-			else if ( currentFolderType == EFSOutbox )
-				{
-				// move from outbox to drafts is allowed
-				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, EFalse );	// Allow in outbox
 				// moving from outbox is not allowed otherwise
 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, ETrue );
 				}
-			else if ( currentFolderType == EFSDraftsFolder )
-				{
-				// move from drafts to drafts is not allowed
-				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue );
-				// moving from drafts folder is not allowed
-				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, ETrue );
-				}
-
 			// Handle rest of the folders
 			else
 				{
-				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue );	// Dim in other folders
 				aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMove, EFalse );
 				}
 			}
-		}
-    // ACTIONS SUBMENU *********************************************************************
-
-
-	// MORE SUBMENU ************************************************************************
-	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MORE )
-		{
+
 		TInt markedCount = CountMarkedItemsL();
 
-	    // Checks if a device has a keyboard or not.
-		if( !iKeyboardFlipOpen )
-       	    {
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMark, ETrue );
-		    aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCallSender, ETrue );
-		    aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, ETrue );
-		    aMenuPane->SetItemDimmed( EFsEmailUiCmdMessageDetails, ETrue );
-	        }
-
 	    // Hide expand/collapse all when not applicable
 		if ( iNodesInUse == EListControlSeparatorDisabled || !iModel->Count() )
 			{
@@ -1579,120 +1432,49 @@
 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() );
 			}
 
-		// Some commands are available only when there's exactly one target message
-		if ( targetEntries.Count() != 1 )
-			{
-			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCallSender, ETrue );
-			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, ETrue );
-			aMenuPane->SetItemDimmed( EFsEmailUiCmdMessageDetails, ETrue );
-			}
-
-		// Hide mark/unmark all when not applicable
-		if ( markedCount == EmailsInModelL() ) // Hide mark all
-		    {
-		    aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMarkAll, ETrue );
-		    //aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkUnmarkAll, EFalse );
-		    }
-		else if ( !markedCount ) // hide unmark all
-		    {
-		    //aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMarkAll, EFalse );
-		    aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkUnmarkAll, ETrue );
-		    }
-
 		// Hide followup flagging if not applicable
 		if ( !supportsFlag || !targetEntries.Count() )
 		    {
 		    aMenuPane->SetItemDimmed(EFsEmailUiCmdActionsFlag, ETrue);
 		    }
 
-		// Hide Download Manager if no downloads present
-// <cmail> Prevent Download Manager opening with attachments
-//		if ( !iAppUi.DownloadInfoMediator() || !iAppUi.DownloadInfoMediator()->IsAnyAttachmentDownloads() )
-//		    {
-//		    aMenuPane->SetItemDimmed(EFsEmailUiCmdDownloadManager, ETrue);
-//		    }
-// </cmail>
-
-		// Availability of the mark/unmark commands depends only on the focused item
-		if ( !iMailList || iMailList->FocusedItem() == KFsTreeNoneID ||
-		     iMailList->IsNode( iMailList->FocusedItem() ) )
-		    {
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMark, ETrue );
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkUnmark, ETrue );
-		    }
-		else if ( iMailList->IsMarked( iMailList->FocusedItem() ) ) // Item was already marked
-		    {
-		    aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMark, ETrue );
-		    }
-		else
-		    {
-		    aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkUnmark, ETrue );
-		    }
-
 	    // Some commands are hidden in the outbox and drafts folders
         if ( currentFolderType == EFSOutbox ||
              currentFolderType == EFSDraftsFolder )
             {
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCallSender, ETrue );
-            aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, ETrue );
             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue );
             }
 		}
-    // MORE SUBMENU ************************************************************************
-
-
-	// SETTINGS SUBMENU ********************************************************************
-	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MAIL_SETTINGS )
+    // ACTIONS SUBMENU *********************************************************************
+
+
+	// MARK SUBMENU ************************************************************************
+	// Mark submenu show only when focus is visible
+	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MARK)
 		{
-		TUid pluginUid = iAppUi.GetActiveMailbox()->GetSettingsUid();
-
-		CESMailSettingsPlugin* settingsPlugin =
-			static_cast<CESMailSettingsPlugin*>( iAppUi.View( pluginUid ) );
-
-		if ( !settingsPlugin )
-			{
-			settingsPlugin = CESMailSettingsPlugin::NewL( pluginUid );
-			CleanupStack::PushL( settingsPlugin );
-			iAppUi.AddViewL( settingsPlugin );
-			CleanupStack::Pop( settingsPlugin ); // ownership transferred
-			}
-		TInt count( settingsPlugin->MailSettingsSubviewCount() );
-		if ( count > 0 )
-			{
-			TInt index = 0;
-			while ( index < count )
-				{
-				CEikMenuPaneItem::SData newMenuItem;
-				newMenuItem.iCommandId = EFsEmailUiCmdSettingsBaseCommandId + index;
-				newMenuItem.iCascadeId = 0;
-				newMenuItem.iFlags = 0;
-				newMenuItem.iText = settingsPlugin->MailSettingsSubviewCaption(
-		        		iAppUi.GetActiveMailboxId(),
-		        		index,
-		        		EFalse
-		        		);
-		        aMenuPane->InsertMenuItemL(
-		        		newMenuItem,
-		        		aMenuPane->NumberOfItemsInPane() );
-		        ++index;
-				}
-			}
-		else
-			{
-			// POP/IMAP mailbox settings
-			HBufC* ipsText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SETTINGS_IPS_TEXT );
-			CEikMenuPaneItem::SData newMenuItem;
-			newMenuItem.iCommandId = EFsEmailUiCmdSettingsBaseCommandId;
-			newMenuItem.iCascadeId = 0;
-			newMenuItem.iFlags = 0;
-			newMenuItem.iText = *ipsText;
-	        aMenuPane->InsertMenuItemL(
-	        		newMenuItem,
-	        		aMenuPane->NumberOfItemsInPane() );
-	        CleanupStack::PopAndDestroy( ipsText );
-			}
+	    // Checks if a device has a keyboard or not.
+		if( !iLastFocus )
+       	    {
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMark, ETrue );
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkMarkAll, ETrue );
+	        }
+         else
+       	    {
+            aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkSubAll, ETrue );
+	        }
 		}
-    // SETTINGS SUBMENU ********************************************************************
+
+    // MARK SUBMENU ************************************************************************
+
+
+	// UNMARK SUBMENU ************************************************************************
+	// Unmark submenu show only when focus is not visible
+	if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_UNMARK)
+		{
+		// Nothing to do yet
+		}
+    // UNMARK SUBMENU ************************************************************************
+
 
 	CleanupStack::PopAndDestroy( &targetEntries );
 
@@ -1831,7 +1613,14 @@
             TInt idx = ItemIndexFromMessageId( *aFocusToMessage );
             if ( idx >= 0 )
                 {
-                iMailList->SetFocusedItemL( iTreeItemArray[idx].iListItemId );
+                TFsTreeItemId itemId = iTreeItemArray[idx].iListItemId;
+                iMailList->SetFocusedItemL( itemId );
+                // If contorl bar is focused, we need to hide
+                // focus then.
+                if( iFocusedControl == EControlBarComponent )
+                    {
+                    iMailTreeListVisualizer->UpdateItemL( itemId );
+                    }
                 }
             }
 	    }
@@ -1916,7 +1705,7 @@
         iMsgToFocusAfterRedraw.SetId( 0 );
         iMsgToFocusAfterRedraw.SetNullId();
         }
-    // <cmail>
+
     if ( iAsyncRedrawer )
         {
         TCallBack asyncRefresh( DoRefresh, this );
@@ -1924,7 +1713,6 @@
         iAsyncRedrawer->Set( asyncRefresh );
         iAsyncRedrawer->CallBack();
         }
-    // </cmail>
     }
 
 // ---------------------------------------------------------------------------
@@ -1952,7 +1740,7 @@
     {
     FUNC_LOG;
 
-    if ( iAsyncRedrawer && iAsyncRedrawer->IsActive() ) //<cmail>
+    if ( iAsyncRedrawer && iAsyncRedrawer->IsActive() )
         {
         iAsyncRedrawer->Cancel();
         DoRefresh( this );
@@ -2087,9 +1875,9 @@
                                                              TBool aAllowRefresh )
     {
     FUNC_LOG;
-    TRect screenRect = iAppUi.ClientRect();
-    CFsTreePlainTwoLineItemData* itemData(0);
-    CFsTreePlainTwoLineItemVisualizer* itemVisualizer(0);
+    TRect screenRec( iAppUi.ClientRect() );
+    CFsTreePlainTwoLineItemData* itemData = NULL;
+    CFsTreePlainTwoLineItemVisualizer* itemVisualizer = NULL;
     TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor();
     TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
 
@@ -2107,12 +1895,10 @@
     itemData->SetPreviewPaneDataL( KMissingPreviewDataMarker );
 
     // Create item visualiser
-    itemVisualizer = CFsTreePlainTwoLineItemVisualizer::NewL(*iMailList->TreeControl());
+    itemVisualizer = CFsTreePlainTwoLineItemVisualizer::NewL(
+            *iMailList->TreeControl() );
     CleanupStack::PushL( itemVisualizer );
 
-    // Enable menu icon
-    itemVisualizer->SetFlags( itemVisualizer->Flags() | KFsTreeListItemHasMenu );
-
    	itemVisualizer->SetTextAlign( EAlfAlignHLocale );
 
    	TBool previewOn = ( iListMode == EListControlTypeDoubleLinePreviewOn ||
@@ -2434,7 +2220,8 @@
 //
 // ---------------------------------------------------------------------------
 //
-void CFSEmailUiMailListVisualiser::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType )
+void CFSEmailUiMailListVisualiser::HandleDynamicVariantSwitchL(
+    CFsEmailUiViewBase::TDynamicSwitchType aType )
 	{
     FUNC_LOG;
     CFsEmailUiViewBase::HandleDynamicVariantSwitchL( aType );
@@ -2542,6 +2329,319 @@
 
 // ---------------------------------------------------------------------------
 //
+// ---------------------------------------------------------------------------
+//
+TBool CFSEmailUiMailListVisualiser::HandleArrowEventInPortraitL(
+        const TInt aScancode,
+        const TAlfEvent& aEvent,
+        const TBool aShiftState )
+    {
+    FUNC_LOG;
+    TBool result( EFalse );
+
+    if( aScancode == EStdKeyLeftArrow )
+        {
+        if( ( iControlBarControl ) &&
+            ( iFocusedControl == EMailListComponent ) )
+            {
+            // Move focus to control bar (focused button is
+            // sort button).
+            HandleCommandL( EFsEmailUiCmdGoToSwitchSorting );
+            result = ETrue;
+            }
+        else if( ( iControlBarControl ) &&
+                 ( iFocusedControl == EControlBarComponent  ) )
+            {
+            TInt focusedButtonId( iControlBarControl->GetFocusedButton()->Id() );
+            if ( focusedButtonId == iNewEmailButtonId )
+                {
+                // Change focus to mail list if there are any
+                // emails in it.
+                if( iModel->Count() )
+                    {
+                    iFocusedControl = EMailListComponent;
+                    result = EFalse;
+                    }
+                // Leave focus to control bar because there are no
+                // mails in mail list.
+                else
+                    {
+                    iControlBarControl->MakeSelectorVisible( IsFocusShown() );
+                    iFocusedControl = EControlBarComponent;
+                    result = ETrue; // Do not set focus to empty list
+                    }
+                }
+            else
+                {
+                iControlBarControl->MakeSelectorVisible( IsFocusShown() );
+                iFocusedControl = EControlBarComponent;
+                result = EFalse;
+                }
+            }
+        else
+            {
+            iFocusedControl = EMailListComponent;
+            result = EFalse;
+            }
+        SetMskL();
+        }
+    else if( aScancode == EStdKeyRightArrow )
+        {
+        // Show toolbar if there is data on the list
+        const TInt modelCount( iModel->Count() );
+        TBool focusShown( IsFocusShown() );
+
+        // If control bar is focused.
+        if( ( iControlBarControl ) &&
+            ( iFocusedControl == EControlBarComponent ) )
+            {
+            TInt focusedButtonId( iControlBarControl->GetFocusedButton()->Id() );
+
+            // If sort button is focused and there are mails in mail
+            // list then focus is moved to mail list, otherwise
+            // leave focus to control bar
+            if( focusedButtonId == iSortButtonId )
+                {
+                if ( modelCount > 0 ) // Check for empty folder
+                    {
+                    iFocusedControl = EMailListComponent;
+                    result = EFalse;
+                    }
+                else
+                    {
+                    iFocusedControl = EControlBarComponent;
+                    iControlBarControl->MakeSelectorVisible( focusShown );
+                    result = ETrue; // Do not set focus to empty list
+                    }
+                }
+            else
+                {
+                iFocusedControl = EControlBarComponent;
+                iControlBarControl->MakeSelectorVisible( focusShown );
+                result = EFalse;
+                }
+            }
+        else if( ( iControlBarControl ) &&
+                 ( iFocusedControl == EMailListComponent ) )
+            {
+            HandleCommandL( EFsEmailUiCmdGoToSwitchNewEmail );
+            result = ETrue;
+            }
+        else
+            {
+            iFocusedControl = EMailListComponent;
+            result = EFalse;
+            }
+        SetMskL();
+        }
+    else if( aScancode ==  EStdKeyDownArrow )
+        {
+        const TInt itemCount( iModel->Count() );
+        if ( iFocusedControl == EMailListComponent )
+            {
+            result = iMailList->TreeControl()->OfferEventL( aEvent );
+            if ( aShiftState )
+                {
+                DoScrollMarkUnmarkL(); // marking is done after moving the cursor
+                }
+            }
+        else if( ( iFocusedControl == EControlBarComponent ) &&
+                 ( itemCount == 0 ) )
+            {
+            result = ETrue; // Do not set focus to empty list
+            }
+        else if( ( iFocusedControl == EControlBarComponent ) &&
+                 ( itemCount > 0 ) )
+            {
+            iFocusedControl = EMailListComponent;
+
+            result = iMailList->TreeControl()->OfferEventL(aEvent);
+            if ( aShiftState )
+                {
+                DoScrollMarkUnmarkL(); // marking is done after moving the cursor
+                }
+            }
+        else
+            {
+            result = EFalse;
+            }
+        SetMskL();
+        }
+    else if( aScancode == EStdKeyUpArrow )
+        {
+        iControlBarControl->MakeSelectorVisible( IsFocusShown() );
+        if ( iFocusedControl == EMailListComponent )
+            {
+            if ( HighlightedIndex() == 0 )
+                {
+                HandleCommandL( EFsEmailUiCmdGoToSwitchFolder );
+                result = ETrue;
+                }
+            else
+                {
+                result = iMailList->TreeControl()->OfferEventL( aEvent );
+                if ( aShiftState )
+                    {
+                    // marking is done after moving the cursor
+                    DoScrollMarkUnmarkL();
+                    }
+                SetMskL();
+                }
+            }
+        else if( iFocusedControl == EControlBarComponent )
+            {
+            result = ETrue;
+            }
+        else
+            {
+            result = EFalse;
+            }
+        }
+
+    return result;
+    }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TBool CFSEmailUiMailListVisualiser::HandleArrowEventInLandscapeL(
+        const TInt aScancode,
+        const TAlfEvent& aEvent,
+        const TBool aShiftState )
+    {
+    FUNC_LOG;
+    TBool result( EFalse );
+    if( aScancode == EStdKeyRightArrow )
+        {
+        if ( iFocusedControl == EMailListComponent )
+            {
+            HandleCommandL( EFsEmailUiCmdGoToSwitchFolder );
+            result = ETrue;
+            }
+        else if( iFocusedControl == EControlBarComponent )
+            {
+            iControlBarControl->MakeSelectorVisible( IsFocusShown() );
+            result = ETrue;
+            }
+        }
+    else if( aScancode == EStdKeyLeftArrow )
+        {
+        if ( iFocusedControl == EControlBarComponent )
+            {
+            const TInt modelCount( iModel->Count() );
+            if( modelCount > 0 )
+                {
+                iFocusedControl = EMailListComponent;
+                result = iMailList->TreeControl()->OfferEventL( aEvent );
+                if( aShiftState )
+                    {
+                    // marking is done after moving the cursor
+                    DoScrollMarkUnmarkL();
+                    }
+                }
+            else
+                {
+                iControlBarControl->MakeSelectorVisible( IsFocusShown() );
+                // Do not set focus to empty list
+                result = ETrue;
+                }
+            }
+        else if( iFocusedControl == EMailListComponent )
+            {
+            result = iMailList->TreeControl()->OfferEventL( aEvent );
+            if ( aShiftState )
+                {
+                // marking is done after moving the cursor
+                DoScrollMarkUnmarkL();
+                }
+           }
+        SetMskL();
+        }
+    if( aScancode == EStdKeyUpArrow )
+        {
+        if( iFocusedControl == EMailListComponent )
+            {
+            result = iMailList->TreeControl()->OfferEventL( aEvent );
+            if ( aShiftState )
+                {
+                // marking is done after moving the cursor
+                DoScrollMarkUnmarkL();
+                }
+            }
+        else if( iFocusedControl == EControlBarComponent )
+            {
+            TInt focusedButtonId( iControlBarControl->GetFocusedButton()->Id() );
+            if ( focusedButtonId == iNewEmailButtonId )
+                {
+                // Change focus to mail list if there are any
+                // mails in it.
+                if( iModel->Count() > 0 )
+                    {
+                    iFocusedControl = EMailListComponent;
+                    result = EFalse;
+                    }
+                // Leave focus to control bar because there are no
+                // mails in mail list.
+                else
+                    {
+                    // Do not set focus to empty list
+                    iControlBarControl->MakeSelectorVisible( IsFocusShown() );
+                    result = ETrue;
+                    }
+                }
+            else
+                {
+                iControlBarControl->MakeSelectorVisible( IsFocusShown() );
+                result = static_cast<CAlfControl*>( iControlBarControl )->OfferEventL( aEvent );
+                }
+            }
+        SetMskL();
+        }
+    else if( aScancode == EStdKeyDownArrow )
+        {
+        if( iFocusedControl == EMailListComponent )
+            {
+            result = iMailList->TreeControl()->OfferEventL( aEvent );
+            if( aShiftState )
+                {
+                // marking is done after moving the cursor
+                DoScrollMarkUnmarkL();
+                }
+            }
+        else if( iFocusedControl == EControlBarComponent )
+            {
+            const TInt modelCount( iModel->Count() );
+            TInt focusedButtonId( iControlBarControl->GetFocusedButton()->Id() );
+            // If sort button is focused and there are mails in mail
+            // list then focus is moved to mail list, otherwise
+            // leave focus to control bar
+            if( focusedButtonId == iSortButtonId )
+                {
+                if ( modelCount > 0 ) // Check for empty folder
+                    {
+                    iFocusedControl = EMailListComponent;
+                    result = EFalse;
+                    }
+                else
+                    {
+                    iControlBarControl->MakeSelectorVisible( IsFocusShown() );
+                    result = ETrue; // Do not set focus to empty list
+                    }
+                }
+            else
+                {
+                iControlBarControl->MakeSelectorVisible( IsFocusShown() );
+                result = static_cast<CAlfControl*>( iControlBarControl )->OfferEventL( aEvent );
+                }
+            }
+        SetMskL();
+        }
+
+    return result;
+    }
+
+// ---------------------------------------------------------------------------
 //
 // ---------------------------------------------------------------------------
 //
@@ -2681,29 +2781,34 @@
     GetActionsTargetEntriesL( actionTargetItems );
 
     // Check if the focus needs to be removed.
-    if ( aCommand == KErrCancel || aCommand == EFsEmailUiCmdActionsDelete ||
-    	 aCommand == EFsEmailUiCmdMarkAsRead ||
-    	 aCommand == EFsEmailUiCmdMarkAsUnread ||
-    	 aCommand == EFsEmailUiCmdActionsMove ||
-    	 aCommand == EFsEmailUiCmdMarkUnmarkToggle )
+    if ( ( iStylusPopUpMenuVisible ) &&
+         ( aCommand == KErrCancel ||
+           aCommand == EFsEmailUiCmdActionsDelete ||
+    	   aCommand == EFsEmailUiCmdMarkAsRead ||
+    	   aCommand == EFsEmailUiCmdMarkAsUnread ||
+    	   aCommand == EFsEmailUiCmdActionsMove ||
+    	   aCommand == EFsEmailUiCmdActionsMoveMessage ||
+    	   aCommand == EFsEmailUiCmdMarkUnmarkToggle ||
+    	   aCommand == EFsEmailUiCmdActionsCollapseAll ||
+    	   aCommand == EFsEmailUiCmdActionsExpandAll ) )
     	{
    		// We end up here if the user selects an option from the pop up menu
     	// or exits the menu by tapping outside of it's area.
     	// Remove the focus from a list item if an item is focused.
-   		iStylusPopUpMenuLaunched = EFalse;
-   		FocusVisibilityChange( EFalse );
+    	iStylusPopUpMenuVisible = EFalse;
+    	iAppUi.SetFocusVisibility( EFalse );
     	}
 
-    switch ( aCommand )
+    switch( aCommand )
         {
     	case EAknSoftkeyOpen:
-		{
-		if( !iAppUi.IsFocusShown() )
-			{
-			iAppUi.SetFocusVisibility( ETrue );
-			break;
-			}
-		}
+            {
+            if( !iAppUi.IsFocusShown() )
+                {
+                iAppUi.SetFocusVisibility( ETrue );
+                break;
+                }
+            }
        	case EAknSoftkeySelect:
        	    {
        	    if ( iFocusedControl == EMailListComponent )
@@ -3074,6 +3179,17 @@
 			UnmarkAllItemsL();
 			}
 			break;
+
+		case EFsEmailUiCmdMarkSubAll:
+			{
+			MarkAllItemsL();
+			}
+			break;
+		case EFsEmailUiCmdUnmarkSubAll:
+			{
+			UnmarkAllItemsL();
+			}
+			break;
 		case EFsEmailUiCmdReadEmail:
 			{
 			iAppUi.StartReadingEmailsL();
@@ -3224,6 +3340,13 @@
                         HandleCommandL(EFsEmailUiCmdMarkMark);
                         }
 					}
+				else if ( item && item->ModelItemType() == ETypeSeparator )
+					{
+					// Currently only mark is done since mark should activate
+					// marking mode for messages. Unmark can be done via message long tap menu.
+					TInt index = HighlightedIndex();
+					MarkItemsUnderSeparatorL( ETrue, index );
+					}
                 }
             }
             break;
@@ -3243,6 +3366,14 @@
            	iMailList->SetFocusedL( EFalse );
             }
             break;
+        case EFsEmailUiCmdGoToSwitchNewEmail:
+            {
+            iControlBarControl->SetFocusByIdL( iNewEmailButtonId );
+            iControlBarControl->MakeSelectorVisible( IsFocusShown() );
+            iFocusedControl = EControlBarComponent;
+            iMailList->SetFocusedL( EFalse );
+            break;
+            }
         case EFsEmailUiCmdCalActionsAccept:
         case EFsEmailUiCmdCalActionsTentative:
         case EFsEmailUiCmdCalActionsDecline:
@@ -3306,10 +3437,17 @@
        			}
        		}
 			break;
+        case EFsEmailUiCmdSettings:
+            {
+            TInt tmp = 0;
+            const TPckgBuf<TInt> pkgBuf( tmp );
+            iAppUi.EnterFsEmailViewL( SettingsViewId,
+                                      TUid::Uid(KMailSettingsOpenMainList), pkgBuf );
+            }
+            break;
+
+
 	    default:
-	    	{
-	    	// No default action.
-	    	}
         	break;
         } // switch ( aCommand )
     CleanupStack::PopAndDestroy( &actionTargetItems );
@@ -3428,7 +3566,7 @@
 	{
     FUNC_LOG;
     // Safety check, ignore command if the list is empty
-    if ( iMailList->Count() )
+    if ( iMailList->Count() > 0 )
         {
     	iMailTreeListVisualizer->CollapseAllL();
         }
@@ -3436,14 +3574,13 @@
 
 // ---------------------------------------------------------------------------
 //
-//
 // ---------------------------------------------------------------------------
 //
 void CFSEmailUiMailListVisualiser::ExpandAllNodesL()
 	{
     FUNC_LOG;
     // Safety check, ignore command if the list is empty
-	if ( iMailList->Count() )
+	if ( iMailList->Count() > 0 )
 	    {
     	TFsTreeItemId prevId = iMailList->FocusedItem();
     	iMailTreeListVisualizer->ExpandAllL();
@@ -3451,6 +3588,10 @@
         }
 	}
 
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
 void CFSEmailUiMailListVisualiser::ExpandOrCollapseL()
     {
     FUNC_LOG;
@@ -3590,17 +3731,7 @@
 
     if ( iFocusedControl == EControlBarComponent )
         {
-/* <cmail> Sorting enabled also for empty list
-        // Sort menu can't be opened if mail list is empty. Hide MSK label in that case.
-        if ( !listCount && iControlBarControl->GetFocusedButton() == iSortButton )
-            {
-            ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
-            }
-        else
-</cmail> */
-            {
-            ChangeMskCommandL( R_FSE_QTN_MSK_CHANGE );
-            }
+        ChangeMskCommandL( R_FSE_QTN_MSK_CHANGE );
         }
     else  if ( iFocusedControl == EMailListComponent )
         {
@@ -3672,7 +3803,7 @@
 //
 // ---------------------------------------------------------------------------
 //
-TBool CFSEmailUiMailListVisualiser::OfferEventL(const TAlfEvent& aEvent)
+TBool CFSEmailUiMailListVisualiser::OfferEventL( const TAlfEvent& aEvent )
     {
     FUNC_LOG;
     TBool result( EFalse );
@@ -3696,13 +3827,19 @@
                     }
                 else
                     {
-                    // if pointer up event was not made on control bar area
-                    // then focus need to be set to mail list component if it
-                    // didn't already have focus.
-                    if( iFocusedControl != EMailListComponent )
+                    // If pointer down event was not made on control bar area
+                    // then focus need to be set to mail list component, if it
+                    // didn't already have focus. If mail list is empty, then
+                    // focus is hidden and control bar stays as a focused item.
+                    if( ( iFocusedControl != EMailListComponent ) &&
+                        ( iMailList->Count() > 0 ) )
                         {
                         SetTreeListFocusedL();
                         }
+                    else
+                        {
+                        iAppUi.SetFocusVisibility( EFalse );
+                        }
                     }
                 }
 
@@ -3769,10 +3906,20 @@
 
     // MSK label can now be updated when shift key has been handled
     SetMskL();
+    // On KeyUp of EStdKeyYes usually Call application is called - prevent it
+    if ( iConsumeStdKeyYes_KeyUp && (aEvent.Code() == EEventKeyUp )) 
+		{
+		iConsumeStdKeyYes_KeyUp = EFalse; // in case call button was consumed elsewhere first key up enables calling Call application
+		if ( EStdKeyYes == scanCode) 
+			{
+			  result = ETrue; // consume not to switch to Call application when call to contact was processed
+			  return result;
+			}
+		}
 
     if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey )
         {
-        TBool shiftState = (aEvent.KeyEvent().iModifiers & EModifierShift );
+        TBool shiftState = ( aEvent.KeyEvent().iModifiers & EModifierShift );
 
         // Do the (un)marking if in shift state and suitable key is received
         if ( shiftState )
@@ -3826,15 +3973,14 @@
         if ( !result )
             {
             // Handle possible focus visibility change
-            if ((scanCode == EStdKeyRightArrow)
-                || (scanCode == EStdKeyLeftArrow)
-                || (scanCode == EStdKeyUpArrow)
-                || (scanCode == EStdKeyDownArrow)
-                || (scanCode == EStdKeyEnter)
-                || (scanCode == EStdKeyDeviceA)
-                || (scanCode ==EStdKeyDevice3))
+            if ( ( scanCode == EStdKeyRightArrow ) ||
+                 ( scanCode == EStdKeyLeftArrow ) ||
+                 ( scanCode == EStdKeyUpArrow ) ||
+                 ( scanCode == EStdKeyDownArrow ) ||
+                 ( scanCode == EStdKeyEnter ) ||
+                 ( scanCode == EStdKeyDeviceA ) ||
+                 ( scanCode ==EStdKeyDevice3 ) )
                 {
-
                 // If the focus was not active already, ignore the key press
                 if( !iAppUi.SetFocusVisibility( ETrue ) )
                     {
@@ -3852,10 +3998,7 @@
                     SetMskL();
                     if ( iFocusedControl == EMailListComponent )
                         {
-                        TInt modelCount(0);
-                        // <cmail>
-                        modelCount = iModel->Count();
-                        // </cmail>
+                        TInt modelCount( modelCount = iModel->Count() );
                         if ( modelCount ) // Safety check
                             {
                             CFSEmailUiMailListModelItem* item =
@@ -3887,17 +4030,15 @@
                         }
                     else
                         {
-                        TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
+                        TInt focusedButtonId( iControlBarControl->GetFocusedButton()->Id() );
                         if ( focusedButtonId == iNewEmailButtonId )
                             {
                             HandleCommandL(EFsEmailUiCmdCompose);
                             }
                         else if ( focusedButtonId == iFolderListButtonId )
                             {
-                            //<cmail>
-                            //Set touchmanager not active for preventing getting events.
-                            DisableMailList(ETrue);
-                            //</cmail>
+                            // Set touchmanager not active for preventing getting events.
+                            DisableMailList( ETrue );
                             iAppUi.ShowFolderListInPopupL( FolderId(), this, iFolderListButton );
                             }
                         else if ( focusedButtonId == iSortButtonId )
@@ -3914,10 +4055,8 @@
                             // Show sort if model has data.
                             if ( iModel->Count() )
                                 {
-                                //<cmail>
-                                //Set touchmanager not active for preventing getting events.
+                                // Set touchmanager not active for preventing getting events.
                                 DisableMailList(ETrue);
-                                //</cmail>
                                 iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
                                 }
                             else
@@ -3928,164 +4067,27 @@
                                     IsFocusShown() );
                                 }
                             }
-                        return ETrue;//iControlBar->OfferEventL( aEvent );
+                        return ETrue; // iControlBar->OfferEventL( aEvent );
                         }
                     }
                     break;
                 case EStdKeyLeftArrow:
+                case EStdKeyRightArrow:
+                case EStdKeyDownArrow:
+                case EStdKeyUpArrow:
                     {
-                    if( iControlBarControl && iFocusedControl == EMailListComponent )
-                        {
-                        HandleCommandL( EFsEmailUiCmdGoToSwitchSorting );
-                        result = ETrue;
-                        }
-                    else if( ( iControlBarControl ) &&
-                             ( iFocusedControl == EControlBarComponent  ) )
+                    if( Layout_Meta_Data::IsLandscapeOrientation() )
                         {
-                        TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
-                        iControlBarControl->MakeSelectorVisible( IsFocusShown() );
-                        if ( focusedButtonId == iFolderListButtonId )
-                            {
-                            if ( iModel->Count() )
-                                {
-                                iFocusedControl = EMailListComponent;
-                                result = EFalse;
-                                }
-                            else
-                                {
-                                iFocusedControl = EControlBarComponent;
-                                result = ETrue; // Do not set focus to empty list
-                                }
-                            }
-                        else
-                            {
-                            iFocusedControl = EControlBarComponent;
-                            result = EFalse;
-                            }
+                        result = HandleArrowEventInLandscapeL( scanCode,
+                                    aEvent, shiftState );
                         }
                     else
                         {
-                        iFocusedControl = EMailListComponent;
-                        result = EFalse;
-                        }
-                    SetMskL();
-                    }
-                    break;
-                case EStdKeyRightArrow:
-                    {
-                    // Show toolbar if there is data on the list
-                    // <cmail>
-                    if ( iFocusedControl == EMailListComponent && iModel->Count() )
-                    // </cmail>
-                        {
-                        RFsTreeItemIdList targetEntries;
-                        CleanupClosePushL( targetEntries );
-                        GetActionsTargetEntriesL( targetEntries );
-                        TInt targetCount = targetEntries.Count();
-                        CleanupStack::PopAndDestroy( &targetEntries );
-
-                        if ( targetCount )
-                            {
-                            LaunchStylusPopupMenuL();
-                            result = ETrue;
-                            }
+                        result = HandleArrowEventInPortraitL( scanCode,
+                                    aEvent, shiftState );
                         }
-                    else if( ( iControlBarControl ) &&
-                             ( iFocusedControl == EControlBarComponent ) )
-                        {
-                        TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
-                        iControlBarControl->MakeSelectorVisible( IsFocusShown() );
-                        if ( focusedButtonId == iFolderListButtonId )
-                            {
-                            iFocusedControl = EControlBarComponent;
-                            result = EFalse;
-                            }
-                        else
-                            {
-                            if ( iModel->Count() ) // Check for empty folder
-                                {
-                                iFocusedControl = EMailListComponent;
-                                result = EFalse;
-                                }
-                            else
-                                {
-                                iFocusedControl = EControlBarComponent;
-                                result = ETrue; // Do not set focus to empty list
-                                }
-                            }    					                                   ;
-                        }
-                    else
-                        {
-                        iFocusedControl = EMailListComponent;
-                        result = EFalse;
-                        }
-                    SetMskL();
-                    }
                     break;
-                case EStdKeyDownArrow:
-                    {
-                    if ( iFocusedControl == EMailListComponent )
-                        {
-                        result = iMailList->TreeControl()->OfferEventL(aEvent);
-                        if ( shiftState )
-                            {
-                            DoScrollMarkUnmarkL(); // marking is done after moving the cursor
-                            }
-                        }
-                    // <cmail>
-                    else if ( iFocusedControl == EControlBarComponent && iModel->Count() == 0 )
-                        {
-                        iControlBarControl->MakeSelectorVisible( IsFocusShown() );
-                        result = ETrue; // Do not set focus to empty list
-                        }
-                    else if ( iFocusedControl == EControlBarComponent && iModel->Count() != 0 )
-                    // </cmail>
-                        {
-                        iFocusedControl = EMailListComponent;
-
-                        result = iMailList->TreeControl()->OfferEventL(aEvent);
-                        if ( shiftState )
-                            {
-                            DoScrollMarkUnmarkL(); // marking is done after moving the cursor
-                            }
-                        }
-                    else
-                        {
-                        result = EFalse;
-                        }
-                    SetMskL();
                     }
-                    break;
-                case EStdKeyUpArrow:
-                    {
-                    iControlBarControl->MakeSelectorVisible( IsFocusShown() );
-                    if ( iFocusedControl == EMailListComponent )
-                        {
-                        if ( HighlightedIndex() == 0 )
-                            {
-                            HandleCommandL( EFsEmailUiCmdGoToSwitchFolder );
-                            result = ETrue;
-                            }
-                        else
-                            {
-                            result = iMailList->TreeControl()->OfferEventL(aEvent);
-                            if ( shiftState )
-                                {
-                                DoScrollMarkUnmarkL(); // marking is done after moving the cursor
-                                }
-                            SetMskL();
-                            }
-                        }
-                    else if (iFocusedControl == EControlBarComponent)
-                        {
-                        result = ETrue;
-                        }
-                    else
-                        {
-                        result = EFalse;
-                        }
-                    }
-                    break;
                 case EStdKeyYes:
                     {
                     if ( !iAppUi.ViewSwitchingOngoing() )
@@ -4118,6 +4120,8 @@
                                             CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL(
                                                     *mailAddress, iAppUi.GetActiveMailbox(), this, ETrue );
                                             }
+// consume following KyUp event to prevent execution of Call application when call to contact processing
+                                        iConsumeStdKeyYes_KeyUp = result = ETrue;
                                         }
                                     }
                                 }
@@ -4133,7 +4137,6 @@
                     result = ETrue;
                     }
                     break;
-               //<cmail>
                // Backspace (C key) must be handled on Key-Down instead of Key-Up
                // ( this was the reason that deleted two emails from opened mail in viewer )
                case EStdKeyBackspace:
@@ -4149,7 +4152,6 @@
                    else result = EFalse;
                    }
                    break;
-                //</cmail>
                 default:
                     {
                     if ( iFocusedControl == EMailListComponent )
@@ -4173,6 +4175,7 @@
         TInt shortcutCommand =
             iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(),
                 CFSEmailUiShortcutBinding::EContextMailList );
+
         // Hash/shift key of ITU-T and half-QWERTY keyboards is an exception case to other
         // shortcuts: it is handled only if it hasn't been used as shift modifier
         if ( (scanCode == EStdKeyHash || scanCode == EStdKeyLeftShift || scanCode == EStdKeyRightShift) &&
@@ -4181,9 +4184,11 @@
             shortcutCommand = KErrNotFound;
             }
 
-        //<cmail>  // block Backspace (C key) handle on Key-Up
-        if ( scanCode == EStdKeyBackspace) shortcutCommand = KErrNotFound; // handled on Key-Down, see above
-        //</cmail>
+        // block Backspace (C key) handle on Key-Up
+        if ( scanCode == EStdKeyBackspace )
+            {
+            shortcutCommand = KErrNotFound; // handled on Key-Down, see above
+            }
 
         if ( shortcutCommand != KErrNotFound )
             {
@@ -4199,7 +4204,6 @@
     return result;
     }
 
-//<cmail>
 // ---------------------------------------------------------------------------
 // CFSEmailUiMailListVisualiser::DoHandleListItemOpenL
 // ---------------------------------------------------------------------------
@@ -4279,7 +4283,7 @@
 // CFSEmailUiMailListVisualiser::DoHandleListItemLongTapL
 // ---------------------------------------------------------------------------
 //
-void CFSEmailUiMailListVisualiser::DoHandleListItemLongTapL()
+void CFSEmailUiMailListVisualiser::DoHandleListItemLongTapL( const TPoint& aPoint )
     {
     FUNC_LOG;
 
@@ -4289,7 +4293,7 @@
         iMailList->GetMarkedItemsL( markedEntries );
         if ( markedEntries.Count() >= 0 )
             {
-            LaunchStylusPopupMenuL();
+            LaunchStylusPopupMenuL( aPoint );
             }
         }
     }
@@ -4355,11 +4359,10 @@
         iControlBarControl->MakeSelectorVisible( aVisible );
         }
 
-    if ( iStylusPopUpMenuLaunched && !aVisible )
+    if ( iStylusPopUpMenuVisible && !aVisible )
     	{
     	// Do not allow to remove the focus from a list element if the pop up
     	// menu was just launched.
-    	iStylusPopUpMenuLaunched = EFalse;
     	return;
     	}
 
@@ -5350,6 +5353,10 @@
                 RemoveMsgItemsFromListIfFoundL( msgIds );
                 CleanupStack::PopAndDestroy( &msgIds );
 				}
+			else
+				{
+				UnmarkAllItemsL();
+				}
 			}
 		}
 	}
@@ -5415,6 +5422,10 @@
             }
         // </cmail>
         }
+    else
+    	{
+		UnmarkAllItemsL();
+    	}
 
     CleanupStack::PopAndDestroy( &markedEntries );
 	}
@@ -5805,10 +5816,10 @@
 					}
 			    iControlBarControl->SetFocusByIdL( iSortButtonId );
 			    iControlBarControl->MakeSelectorVisible( IsFocusShown() );
-/* <cmail> Sorting empty list enabled
-                // Show sort list only if maiil list is not empty
+
+			    // Sorting empty mail list disabled
+                // Show sort list only if mail list is not empty
                 if ( iModel->Count() )
-</cmail> */
                     {
                     iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
                     }
@@ -6210,317 +6221,11 @@
 	}
 
 // ---------------------------------------------------------------------------
-// LaunchActionMenuL
-// Function launches action menu based on the highlighted or marked messages
-// ---------------------------------------------------------------------------
-//
-void CFSEmailUiMailListVisualiser::LaunchActionMenuL()
-	{
-    FUNC_LOG;
-	// Get marked entries
-	RFsTreeItemIdList markedEntries;
-	CleanupClosePushL( markedEntries );
-	iMailList->GetMarkedItemsL( markedEntries );
-	TInt markedCount = markedEntries.Count();
-
-	// Remove old items from action menu
-    CFSEmailUiActionMenu::RemoveAllL();
-	// Construct item list
-    RFsEActionMenuIdList itemList;
-    CleanupClosePushL( itemList );
-	// Check support for object mail iten moving
-	TBool supportsMoving = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder );
-
-	if ( markedCount == 0 || markedCount == 1 ) // Action menu for a single item
-		{
-		// Get pointer to the single message we are dealing with
-	    TFsTreeItemId listItemId;
-	    if ( markedCount == 0 )
-	        {
-	        listItemId = iMailList->FocusedItem();
-	        }
-	    else // ( markedCount == 1)
-	        {
-	        listItemId = markedEntries[0];
-	        }
-	    CFSMailMessage* msgPtr = &MsgPtrFromListIdL( listItemId );
-
-	    if ( iMailFolder->GetFolderType() == EFSOutbox )
-			{
-			if ( supportsMoving )
-				{
-			    itemList.AppendL( FsEActionMenuMoveToDrafts );
-				}
-			}
-		else if( iMailFolder->GetFolderType() == EFSDraftsFolder )
-			{
-			// Create mark unread / mark read flag
-			if ( msgPtr->IsFlagSet( EFSMsgFlag_Read ) )
-				{
-			    itemList.AppendL( FsEActionMenuMarkUnread );
-				}
-			else
-				{
-			    itemList.AppendL( FsEActionMenuMarkRead );
-				}
-			// Add Move message item if applicable
-			if ( supportsMoving )
-				{
-				itemList.AppendL( FsEActionMenuMove );
-				}
-			}
-		else
-			{
-			// Construct menu for calendar message based on resolved mr object
-			// and whether the MRUI object is available
-			if ( msgPtr->IsFlagSet( EFSMsgFlag_CalendarMsg ) &&  iAppUi.MrViewerInstanceL() )
-				{
-			    TESMRMeetingRequestMethod mrMethod( EESMRMeetingRequestMethodUnknown );
-			    TRAP_IGNORE( mrMethod = iAppUi.MrViewerInstanceL()->ResolveMeetingRequestMethodL( *msgPtr ) );
-			    switch ( mrMethod )
-					{
-					case EESMRMeetingRequestMethodRequest:
-						{
-						if ( iMailFolder && iMailFolder->GetFolderType() != EFSOutbox &&
-							 iMailFolder->GetFolderType() != EFSDraftsFolder )
-							{
-							// No choices in outbox in outbox or drafts
-							itemList.AppendL( FsEActionMenuAccept );
-						    itemList.AppendL( FsEActionMenuTentative );
-						    itemList.AppendL( FsEActionMenuDecline );
-							}
-						}
-						break;
-					case EESMRMeetingRequestMethodCancellation:
-						{
-						// No "remove from calendar" in outbox or drafts
-						if ( iMailFolder && iMailFolder->GetFolderType() != EFSOutbox &&
-							 iMailFolder->GetFolderType() != EFSDraftsFolder )
-							{
-							TBool supportsRemove = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaRemoveFromCalendar );
-							if( supportsRemove )
-							    {
-							    itemList.AppendL( FsEActionMenuRemoveFormCal );
-							    }
-							}
-						}
-						break;
-                    case EESMRMeetingRequestMethodUnknown:
-                    case EESMRMeetingRequestMethodResponse:
-					default:
-					    {
-					    // Only "Open" options is available for responses and when MR method
-					    // cannot be resolved without opening the message (this is the case with IMAP)
-	                    itemList.AppendL( FsEActionMenuOpenCalendarEvent );
-					    }
-						break;
-					}
-				}
-			// No mrui object or message is typical mail
-			// Append normal menu commands
-			else
-				{
-			    itemList.AppendL( FsEActionMenuReply );
-			    // Show ReplyAll if more than 1 recepient
-			    TInt numRecipients(0);
-                if ( msgPtr )
-                    {
-                    //Get # of recipients
-                    numRecipients =TFsEmailUiUtility::CountRecepients( msgPtr );
-                    if ( numRecipients == 1 )
-                        {
-                        //check if the malbox ownmailaddress is same as the recipients email address. If not, then assume that the
-                        //email is a distribution list and we need to inc num of Recipients so that "Reply ALL" option appears in UI.
-                        if ( msgPtr->GetToRecipients().Count() )
-                            {
-                                if( iAppUi.GetActiveMailbox()->OwnMailAddress().GetEmailAddress().Compare(msgPtr->GetToRecipients()[0]->GetEmailAddress()) )
-                                    {
-                                    numRecipients++;
-                                    }
-                            }
-                        if ( msgPtr->GetCCRecipients().Count() )
-                            {
-                                if ( iAppUi.GetActiveMailbox()->OwnMailAddress().GetEmailAddress().Compare(msgPtr->GetCCRecipients()[0]->GetEmailAddress()) )
-                                    {
-                                    numRecipients++;
-                                    }
-                            }
-                        if( msgPtr->GetBCCRecipients().Count() )
-                            {
-                                if ( iAppUi.GetActiveMailbox()->OwnMailAddress().GetEmailAddress().Compare(msgPtr->GetBCCRecipients()[0]->GetEmailAddress()) )
-                                    {
-                                    numRecipients++;
-                                    }
-                            }
-                        }
-                    }
-
-			    if ( numRecipients > 1 )
-			        {
-	                itemList.AppendL( FsEActionMenuReplyAll );
-			        }
-			    itemList.AppendL( FsEActionMenuForward );
-				}
-
-			// Add mark as read/unread options
-			if ( IsMarkAsUnreadAvailableL() )
-				{
-			    itemList.AppendL( FsEActionMenuMarkUnread );
-				}
-			if ( IsMarkAsReadAvailableL() )
-				{
-			    itemList.AppendL( FsEActionMenuMarkRead );
-				}
-
-			// Add Move message item if applicable
-			if ( supportsMoving )
-				{
-				itemList.AppendL( FsEActionMenuMove );
-				}
-			}
-	    itemList.AppendL( FsEActionMenuDelete );
-
-		// Execute action list and handle the menu command
-		TFSMailMsgId oldMsgId = msgPtr->GetMessageId();
-
-// <cmail> Touch
-		TActionMenuCustomItemId itemId = CFSEmailUiActionMenu::ExecuteL( itemList, EFscCustom, 0, this );
-// </cmail>
-
-		// Make sure that focus or marking is still on the same item as when Action menu was launched.
-		// This is beacause message added/deleted event migh have occured and deleted the original meessage or
-	   	// resulted in complete redraw of the message list.
-        TInt newItemIdx = ItemIndexFromMessageId( oldMsgId );
-        if ( newItemIdx >= 0 ) // items still exists
-            {
-            TFsTreeItemId newItemListId = iTreeItemArray[ newItemIdx ].iListItemId;
-            if ( markedCount )
-                {
-                // Item was marked. Make sure it's marked now.
-                iMailList->MarkItemL( newItemListId, ETrue );
-                }
-            else
-                {
-                // No items were marked. Make sure the focus is on the same item as before.
-                if ( iMailList->FocusedItem() != newItemListId )
-                    {
-                    iMailList->SetFocusedItemL( newItemListId );
-                    }
-                }
-            HandleActionMenuCommandL( itemId );
-            }
-		}
-	else // Multiple items marked
-		{
-        // Add mark as read/unread options
-        if ( IsMarkAsUnreadAvailableL() )
-            {
-            itemList.AppendL( FsEActionMenuMarkUnread );
-            }
-        if ( IsMarkAsReadAvailableL() )
-            {
-            itemList.AppendL( FsEActionMenuMarkRead );
-            }
-
-		if ( iMailFolder->GetFolderType() == EFSOutbox ) // Append move to drafts in outbox
-			{
-			if ( supportsMoving )
-				{
-			    itemList.AppendL( FsEActionMenuMoveToDrafts );
-				}
-			}
-		else 	// Append move in any other cases dirtectly if supported
-			{
-			if ( supportsMoving )
-				{
-			    itemList.AppendL( FsEActionMenuMove );
-				}
-			}
-	    itemList.AppendL( FsEActionMenuDelete );
-	   	TActionMenuCustomItemId itemId = CFSEmailUiActionMenu::ExecuteL( itemList );
-		iMailList->GetMarkedItemsL( markedEntries );
-		if ( markedEntries.Count() ) // Safety check
-			{
-			HandleActionMenuCommandL( itemId );
-			}
-		}
-	CleanupStack::PopAndDestroy( &itemList );
-	CleanupStack::PopAndDestroy( &markedEntries );
-	}
-
-// ---------------------------------------------------------------------------
-// HandleActionMenuCommandL
-// Action menu command callback handler
-// ---------------------------------------------------------------------------
-//
-void CFSEmailUiMailListVisualiser::HandleActionMenuCommandL( TActionMenuCustomItemId itemId )
-	{
-    FUNC_LOG;
-	// Map each Action Menu ID to correcponding command ID.
-	TInt commandId = KErrNotFound;
-
-	switch( itemId )
-		{
-		case FsEActionMenuOpenCalendarEvent:
-		case FsEActionMenuOpen:
-		    commandId = EFsEmailUiCmdOpen;
-		    break;
-		case FsEActionMenuAccept:
-		    commandId = EFsEmailUiCmdCalActionsAccept;
-		    break;
-		case FsEActionMenuTentative:
-		    commandId = EFsEmailUiCmdCalActionsTentative;
-		    break;
-		case FsEActionMenuDecline:
-		    commandId = EFsEmailUiCmdCalActionsDecline;
-		    break;
-		case FsEActionMenuRemoveFormCal:
-		    commandId = EFsEmailUiCmdCalRemoveFromCalendar;
-		    break;
-		case FsEActionMenuMarkRead:
-		    commandId = EFsEmailUiCmdMarkAsRead;
-		    break;
-		case FsEActionMenuMarkUnread:
-		    commandId = EFsEmailUiCmdMarkAsUnread;
-			break;
-		case FsEActionMenuDelete:
-		    commandId = EFsEmailUiCmdActionsDelete;
-			break;
-		case FsEActionMenuReply:
-		    commandId = EFsEmailUiCmdActionsReply;
-			break;
-		case FsEActionMenuReplyAll:
-            commandId = EFsEmailUiCmdActionsReplyAll;
-			break;
-		case FsEActionMenuForward:
-            commandId = EFsEmailUiCmdActionsForward;
-			break;
-		case FsEActionMenuMove:
-		    commandId = EFsEmailUiCmdActionsMoveMessage;
-			break;
-		case FsEActionMenuMoveToDrafts:
-            commandId = EFsEmailUiCmdActionsMoveToDrafts;
-			break;
-		case FsEActionMenuDismissed:
-		    commandId = KErrCancel;
-		    break;
-		default:
-		    __ASSERT_DEBUG( EFalse, Panic(EFSEmailUiUnexpectedValue) );
-		    break;
-		}
-
-	if ( commandId >= 0 )
-	    {
-	    HandleCommandL( commandId );
-	    }
-	}
-
-// ---------------------------------------------------------------------------
 // LaunchStylusPopupMenuL
 // Function launches avkon stylus popup menu based on the selected message item/items
 // ---------------------------------------------------------------------------
 //
-void CFSEmailUiMailListVisualiser::LaunchStylusPopupMenuL()
+void CFSEmailUiMailListVisualiser::LaunchStylusPopupMenuL( const TPoint& aPoint )
 	{
 	// Irrelevant items for focused mail list item get dimmed at runtime
 
@@ -6575,12 +6280,12 @@
 		}
 
 	// Set the position for the popup
-	iStylusPopUpMenu->SetPosition( ActionMenuPosition() );
+	iStylusPopUpMenu->SetPosition( aPoint );
 
 	// Display the popup and set the flag to indicate that the menu was
 	// launched.
 	iStylusPopUpMenu->ShowMenu();
-	iStylusPopUpMenuLaunched = ETrue;
+	iStylusPopUpMenuVisible = ETrue;
 	}
 
 // ---------------------------------------------------------------------------
@@ -6847,8 +6552,9 @@
 //
 // ---------------------------------------------------------------------------
 //
-void CFSEmailUiMailListVisualiser::TreeListEventL(
-    const TFsTreeListEvent aEvent, const TFsTreeItemId aId )
+void CFSEmailUiMailListVisualiser::TreeListEventL( const TFsTreeListEvent aEvent,
+                                                   const TFsTreeItemId aId,
+                                                   const TPoint& /*aPoint*/ )
 	{
     FUNC_LOG;
     switch( aEvent )
@@ -7176,8 +6882,8 @@
 	    ChangeReadStatusOfHighlightedL( ETrue );
         aFoundPreviousMsgId = MsgIdFromIndex( prevIdx );
 	    ret = KErrNone;
-	    }	
-	
+	    }
+
 	if ( ret == KErrNone )
 		{
 		OpenHighlightedMailL();
@@ -7188,22 +6894,22 @@
 TInt CFSEmailUiMailListVisualiser::MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId )
 	{
 	FUNC_LOG;
-	TInt ret(KErrNotFound);	
-	
-	TInt idx = ItemIndexFromMessageId( aFoundPreviousMsgId );	
+	TInt ret(KErrNotFound);
+
+	TInt idx = ItemIndexFromMessageId( aFoundPreviousMsgId );
 	if ( idx >= 0 )
-		{		
+		{
 		// Focus the previous message
 		iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[idx].iListItemId, EFalse );
 		ChangeReadStatusOfHighlightedL( ETrue );
-		ret = KErrNone;		
+		ret = KErrNone;
 		}
 
 	if ( ret == KErrNone )
 		{
 		OpenHighlightedMailL();
 		}
-	
+
 	return ret;
 	}
 
@@ -7259,7 +6965,7 @@
         }
     else
         {
-        if ( iStylusPopUpMenuLaunched )
+        if( iStylusPopUpMenuVisible )
         	{
         	return;
         	}
@@ -7271,41 +6977,15 @@
             {
             focusedBtnId = focusedBtn->Id();
             }
-        iControlBarControl->MakeSelectorVisible( IsFocusShown() );
         iControlBarControl->SetFocusL( ETrue );
         if ( focusedBtnId != KErrNotFound )
             {
             iControlBarControl->SetFocusByIdL( focusedBtnId );
             }
+        iControlBarControl->MakeSelectorVisible( IsFocusShown() );
         }
     }
 
-// <cmail>
-// ---------------------------------------------------------------------------
-// ActionMenuPosition
-// ---------------------------------------------------------------------------
-//
-TPoint CFSEmailUiMailListVisualiser::ActionMenuPosition()
-    {
-    RFsTreeItemIdList markedEntries;
-    TRAP_IGNORE(iMailList->GetMarkedItemsL( markedEntries ));
-    TInt markedCount = markedEntries.Count();
-    TFsTreeItemId listItemId;
-    if ( markedCount == 0 )
-        {
-        listItemId = iMailList->FocusedItem();
-        }
-    else // ( markedCount == 1)
-        {
-        listItemId = markedEntries[0];
-        }
-    TAlfRealRect focusRect;
-    iMailList->GetItemDisplayRectTarget(listItemId, focusRect);
-    markedEntries.Close();
-    return focusRect.iTl;
-    }
-// </cmail>
-
 void CFSEmailUiMailListVisualiser::GetParentLayoutsL( RPointerArray<CAlfVisual>& aLayoutArray ) const
     {
     aLayoutArray.AppendL( iScreenAnchorLayout );
@@ -7635,7 +7315,20 @@
 void CDateChangeTimer::RunL()
     {
     FUNC_LOG;
-    // Update mail list and reissue the request for timer event
-    iMailListVisualiser.NotifyDateChangedL();
-    Start();
+    if ( KErrCancel == iStatus.Int() )
+        {
+        ;
+        }
+    // System time changed?
+    else if ( KErrAbort == iStatus.Int() )
+        {
+        Start();
+        }
+    // Interval is over
+    else
+        {
+        // Update mail list and reissue the request for timer event
+        TRAP_IGNORE( iMailListVisualiser.NotifyDateChangedL() );
+        Start();
+        }
     }
--- a/emailuis/emailui/src/FreestyleEmailUiMsgDetailsVisualiser.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiMsgDetailsVisualiser.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -12,7 +12,7 @@
 * Contributors:
 *
 *  Description : FreestyleEmailUi message details view implementation
-*  Version     : %version: 45 %
+*  Version     : %version: e002sa38#46 %
 *
 */
 
@@ -1751,7 +1751,8 @@
 // ---------------------------------------------------------------------------
 //
 void CFSEmailUiMsgDetailsVisualiser::TreeListEventL( const TFsTreeListEvent aEvent, 
-                                    const TFsTreeItemId /*aId*/ )
+                                    const TFsTreeItemId /*aId*/,
+                                    const TPoint& /*aPoint*/ )
     {
     switch (aEvent)
         {
--- a/emailuis/emailui/src/FreestyleEmailUiSearchListVisualiser.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiSearchListVisualiser.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -58,9 +58,9 @@
 // </cmail>
 #include <featmgr.h>
 //</cmail>
+#include <aknstyluspopupmenu.h>
 
 //<cmail>
-#include "cfsccontactactionmenu.h"
 #include "mfsccontactactionmenumodel.h"
 #include "fscontrolbar.h"
 #include "fscontrolbuttoninterface.h"
@@ -101,11 +101,14 @@
 //</cmail>
 static const TInt KItemExpansionDelay = 400;
 static const TInt KListScrollingDelay = 200;
-static const TInt KMaxPreviewPaneLength = 60; 
+static const TInt KMaxPreviewPaneLength = 60;
+
+//<cmail> define search required priorities
+#define KStandardSearchPriority   CActive::EPriorityStandard  
+#define KCallingSearchPriority   ( CActive::EPriorityIdle - 1 )
 
 
-
-CFSEmailUiSearchListVisualiser* CFSEmailUiSearchListVisualiser::NewL(CAlfEnv& aEnv, 
+CFSEmailUiSearchListVisualiser* CFSEmailUiSearchListVisualiser::NewL(CAlfEnv& aEnv,
 																 CFreestyleEmailUiAppUi* aAppUi,
 																 CAlfControlGroup& aSearchListControlGroup )
     {
@@ -115,7 +118,7 @@
     return self;
     }
 
-CFSEmailUiSearchListVisualiser* CFSEmailUiSearchListVisualiser::NewLC(CAlfEnv& aEnv, 
+CFSEmailUiSearchListVisualiser* CFSEmailUiSearchListVisualiser::NewLC(CAlfEnv& aEnv,
 																  CFreestyleEmailUiAppUi* aAppUi,
 																  CAlfControlGroup& aSearchListControlGroup)
 {
@@ -135,7 +138,7 @@
 	iThisViewActive = EFalse;
 	iFirstStartCompleted = EFalse;
    	}
-	
+
 // CFSEmailUiSearchListVisualiser::DoFirstStartL()
 // Purpose of this function is to do first start only when search list is
 // really needed to be shown. Implemented to make app startuo faster.
@@ -143,8 +146,8 @@
     {
     FUNC_LOG;
     TRect screenRect;
-    AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );   
-     
+    AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );
+
     // Create control and anchor layout
     iSearchListControl = CFreestyleEmailUiSearchListControl::NewL( *iEnv, this );
     iScreenAnchorLayout = CAlfAnchorLayout::AddNewL( *iSearchListControl );
@@ -152,7 +155,7 @@
     SetSearchListLayoutAnchors();
 
     // Create top bar layout
-    iSearchTopBarLayout = CAlfDeckLayout::AddNewL( *iSearchListControl, iScreenAnchorLayout );  
+    iSearchTopBarLayout = CAlfDeckLayout::AddNewL( *iSearchListControl, iScreenAnchorLayout );
     iBarBgVisual = CAlfImageVisual::AddNewL( *iSearchListControl, iSearchTopBarLayout );
         /*<cmail> paltform layout changes to cmail
     TAlfTimedValue barBgTextureOpacity;
@@ -167,11 +170,11 @@
     // Add bar image component
     iBarFindImage = CAlfImageVisual::AddNewL( *iSearchListControl, iScreenAnchorLayout );
     TAlfTimedValue barFindImageOpacity;
-    barFindImageOpacity.SetValueNow( 1 );   
+    barFindImageOpacity.SetValueNow( 1 );
     iBarFindImage->SetOpacity( barFindImageOpacity );
     CAlfTexture* barFindTexture = &iAppUi.FsTextureManager()->TextureByIndex( ESearchLookingGlassIcon );
     barFindTexture->Size().SetSize( 15, 15 );
-    iBarFindImage->SetImage( TAlfImage( *barFindTexture ) );    
+    iBarFindImage->SetImage( TAlfImage( *barFindTexture ) );
         */ //</cmail>
 
 	// <cmail>
@@ -180,69 +183,82 @@
     iBarTextVisual->EnableShadow(EFalse);
     iBarTextVisual->SetWrapping( CAlfTextVisual::ELineWrapTruncate );
 	// </cmail>
-	
+
 	/*<cmail> no initial text or opacity required in cmail
     HBufC* initialSearchText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_FIND_DLG_SEARCH );
-    iBarTextVisual->SetTextL( *initialSearchText );     
+    iBarTextVisual->SetTextL( *initialSearchText );
     CleanupStack::PopAndDestroy( initialSearchText );
     TAlfTimedValue barTextVisualOpacity;
     barTextVisualOpacity.SetValueNow( 1 );
     iBarTextVisual->SetOpacity( barTextVisualOpacity );
-        
+
     CAlfTextStyle* textStyle = iAppUi.LayoutHandler()->FSTextStyleFromIdL( EFSFontTypeSmallBold );
-    iBarTextVisual->SetTextStyle ( textStyle->Id() );*/ //</cmail>	
+    iBarTextVisual->SetTextStyle ( textStyle->Id() );*/ //</cmail>
     if ( !AknLayoutUtils::LayoutMirrored() )
         {
-        iBarTextVisual->SetAlign(EAlfAlignHLeft, EAlfAlignVCenter);         
+        iBarTextVisual->SetAlign(EAlfAlignHLeft, EAlfAlignVCenter);
         }
     else
         {
-        iBarTextVisual->SetAlign(EAlfAlignHRight, EAlfAlignVCenter);            
+        iBarTextVisual->SetAlign(EAlfAlignHRight, EAlfAlignVCenter);
         }
 
     // Create model
-    iModel = CFSEmailUiMailListModel::NewL( &iAppUi, ETrue );  
+    iModel = CFSEmailUiMailListModel::NewL( &iAppUi, ETrue );
 
     // Create list and append to control group and anchor layout
-    iSearchListLayout = CAlfDeckLayout::AddNewL( *iSearchListControl, iScreenAnchorLayout );  
+    iSearchListLayout = CAlfDeckLayout::AddNewL( *iSearchListControl, iScreenAnchorLayout );
     iSearchListLayout->SetSize( TSize( screenRect.Width(), screenRect.Height()-
             iAppUi.LayoutHandler()->ControlBarHeight() ) );
-    iSearchTreeListVisualizer = CFsTreeVisualizerBase::NewL(iSearchListControl, *iSearchListLayout);  
-    iSearchList = CFsTreeList::NewL(*iSearchTreeListVisualizer, *iEnv );   
+    iSearchTreeListVisualizer = CFsTreeVisualizerBase::NewL(iSearchListControl, *iSearchListLayout);
+    iSearchList = CFsTreeList::NewL(*iSearchTreeListVisualizer, *iEnv );
     iSearchList->SetScrollbarVisibilityL( EFsScrollbarHideAlways );
-  
+
     // Set mark type and icon
-    iSearchList->SetMarkTypeL( CFsTreeList::EFsTreeListMultiMarkable ); 
+    iSearchList->SetMarkTypeL( CFsTreeList::EFsTreeListMultiMarkable );
     iSearchTreeListVisualizer->SetMarkIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkIcon ) );
-    iSearchTreeListVisualizer->SetMenuIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMenuIcon ) );        
+    iSearchTreeListVisualizer->SetMenuIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMenuIcon ) );
 	iSearchTreeListVisualizer->SetFlipState( iKeyboardFlipOpen );
 	iSearchTreeListVisualizer->SetFocusVisibility( iFocusVisible );
     iSearchList->SetIndentationL(0);
 
     //<cmail> events are now offered to controls in different order
     ControlGroup().AppendL( iSearchListControl );
-    ControlGroup().AppendL( iSearchList->TreeControl() ); 
+    ControlGroup().AppendL( iSearchList->TreeControl() );
     //</cmail>
     //<cmail> touch
-    iSearchList->AddObserverL(*this); 
+    iSearchList->AddObserverL(*this);
     //</cmail>
     iSearchOngoing = EFalse;
- 
-    // Set mail list background 
+
+
+    // Initializing the default stylus long tap popup menu
+    if( !iStylusPopUpMenu )
+        {
+        TPoint point( 0, 0 );
+        iStylusPopUpMenu = CAknStylusPopUpMenu::NewL( this , point );
+        TResourceReader reader;
+        iCoeEnv->CreateResourceReaderLC( reader,
+                R_STYLUS_POPUP_MENU_SEARCH_LIST_VIEW );
+        iStylusPopUpMenu->ConstructFromResourceL( reader );
+        CleanupStack::PopAndDestroy();
+        }
+
+    // Set mail list background
     //<cmail> S60 skin support
-    //iSearchTreeListVisualizer->SetBackgroundTextureL( iAppUi.FsTextureManager()->TextureByIndex( EBackgroundTextureMailList ) );  
+    //iSearchTreeListVisualizer->SetBackgroundTextureL( iAppUi.FsTextureManager()->TextureByIndex( EBackgroundTextureMailList ) );
     //</cmail>
-  
+
     iSearchTreeListVisualizer->SetItemExpansionDelay( KItemExpansionDelay );
     iSearchList->SetScrollTime( KListScrollingDelay, 0.5 );
 
     // Set empty text
     HBufC* emptyText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_EMPTY_MSG_LIST_TEXT );
-    iSearchTreeListVisualizer->SetEmptyListTextL( *emptyText ); 
+    iSearchTreeListVisualizer->SetEmptyListTextL( *emptyText );
     CleanupStack::PopAndDestroy( emptyText );
     TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
-    iSearchTreeListVisualizer->RootNodeVisualizer()->SetNormalStateTextColor( normalColor ); 
-     
+    iSearchTreeListVisualizer->RootNodeVisualizer()->SetNormalStateTextColor( normalColor );
+
     // Create startup timer
     iStartupCallbackTimer = CFSEmailUiGenericTimer::NewL( this );
 
@@ -252,30 +268,32 @@
 
     CAlfBrush* selectorBrush = iAppUi.FsTextureManager()->ListSelectorBrushL();
     iSearchTreeListVisualizer->SetSelectorPropertiesL( selectorBrush, 1.0, CFsTreeVisualizerBase::EFsSelectorMoveSmoothly );
-  
-    iAppUi.LayoutHandler()->SetListMarqueeBehaviour( iSearchList );    
-    
+
+    iAppUi.LayoutHandler()->SetListMarqueeBehaviour( iSearchList );
+
     iFirstStartCompleted = ETrue;
    	}
 
 void CFSEmailUiSearchListVisualiser::TimerEventL( CFSEmailUiGenericTimer* /*aTriggeredTimer*/ )
 	{
     FUNC_LOG;
-	LaunchSearchDialogL();	
+	LaunchSearchDialogL();
 	}
-	
-CFSEmailUiSearchListVisualiser::CFSEmailUiSearchListVisualiser( CFreestyleEmailUiAppUi* aAppUi, 
-                                                                CAlfEnv& aEnv, 
+
+CFSEmailUiSearchListVisualiser::CFSEmailUiSearchListVisualiser( CFreestyleEmailUiAppUi* aAppUi,
+                                                                CAlfEnv& aEnv,
                                                                 CAlfControlGroup& aSearchListControlGroup )
     :CFsEmailUiViewBase( aSearchListControlGroup, *aAppUi ),
     iEnv( &aEnv ),
-    iLatestSearchText(0),
-    iListAddedToControlGroup(EFalse), //<cmail>
-    iPreparedForExit(EFalse) //<cmail>
+    iLatestSearchText( 0 ),
+    iListAddedToControlGroup( EFalse ),
+    iConsumeStdKeyYes_KeyUp( EFalse ), // for consuming the call event if call for contact processed
+    iRequiredSearchPriority( KStandardSearchPriority ),  // for search email priority decreasing
+    iPreparedForExit( EFalse )
 	{
     FUNC_LOG;
 	}
-	
+
 CFSEmailUiSearchListVisualiser::~CFSEmailUiSearchListVisualiser()
 	{
     FUNC_LOG;
@@ -285,11 +303,11 @@
     	delete iStartupCallbackTimer;
     	}
 	iSearchStrings.ResetAndDestroy();
-	iSearchListItemArray.Reset(); 
+	iSearchListItemArray.Reset();
     delete iModel;
 	delete iLatestSearchText;
 	delete iSearchList;
-
+    delete iStylusPopUpMenu;
 	}
 
 void CFSEmailUiSearchListVisualiser::PrepareForExit()
@@ -302,15 +320,16 @@
             TRAP_IGNORE(ControlGroup().AppendL( iSearchList->TreeControl() ));
         if(iSearchListControl)
         TRAP_IGNORE(ControlGroup().AppendL( iSearchListControl ));
-        iListAddedToControlGroup = ETrue;        
+        iListAddedToControlGroup = ETrue;
         }*/
     //<cmail>
     if ( iSearchOngoing )
         {
         TRAP_IGNORE( StopSearchL() );
-        }    
+        }
     delete iMailBox;
     iMailBox = NULL;
+    TRAP_IGNORE( ResetResultListL() );
     iPreparedForExit = ETrue;
     }
 
@@ -331,12 +350,12 @@
 	return ret;
 	}
 
-	
+
 TUid CFSEmailUiSearchListVisualiser::Id() const
 	{
     FUNC_LOG;
-	return SearchListViewId;	
-	}			   
+	return SearchListViewId;
+	}
 
 // <cmail> Toolbar
 /*void CFSEmailUiSearchListVisualiser::DoActivateL(const TVwsViewId& aPrevViewId,
@@ -350,16 +369,16 @@
     FUNC_LOG;
 	if ( !iFirstStartCompleted )
 	    {
-	    DoFirstStartL();	    
+	    DoFirstStartL();
 	    }
 
 	// <cmail>
     //iSearchList->SetScrollbarVisibilityL( EFsScrollbarHideAlways );
     if ( aCustomMessageId != KStartListReturnToPreviousFolder )
     	{
-    	iBarTextVisual->SetTextL(KNullDesC);	
+    	iBarTextVisual->SetTextL(KNullDesC);
     	}
-    
+
 	if ( &aCustomMessage && aCustomMessageId == KStartNewSearch )
 		{
 		// If new search, clear old search list
@@ -375,7 +394,7 @@
 	TSearchListActivationData subView;
 	TPckgBuf<TSearchListActivationData> viewData( subView );
 	viewData.Copy( aCustomMessage );
-	subView = viewData();		
+	subView = viewData();
 
 	// Update settings and set list mode according to settings
 	UpdateMailListSettingsL();
@@ -385,20 +404,20 @@
 		delete iMailBox;
 		iMailBox = NULL;
 		}
-	iMailBox = iAppUi.GetMailClient()->GetMailBoxByUidL( subView.iMailBoxId );			
+	iMailBox = iAppUi.GetMailClient()->GetMailBoxByUidL( subView.iMailBoxId );
 	// If mailbox data is not, try to get default MCE account
 	if ( !iMailBox )
 		{
 		CMsvSession* msvSession = iAppUi.GetMsvSession();
 		CFSMailClient* client = iAppUi.GetMailClient();
-		iMailBox = TFsEmailUiUtility::GetMceDefaultMailboxL( *client, *msvSession );				
+		iMailBox = TFsEmailUiUtility::GetMceDefaultMailboxL( *client, *msvSession );
 		}
-		
-	if ( iMailBox )	
+
+	if ( iMailBox )
 		{
 		iThisViewActive = ETrue;
                 //<cmail> visible/unvisible is not controlled by opacity in cmail
-		//TAlfTimedValue opacity; 
+		//TAlfTimedValue opacity;
 		//opacity.SetValueNow( 1 );
 		//iScreenAnchorLayout->SetOpacity( opacity );
                 //</cmail>
@@ -406,7 +425,7 @@
 		iSearchList->SetFocusedL(ETrue);
 		// Set empty text color
 	   	TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
-		iSearchTreeListVisualizer->RootNodeVisualizer()->SetNormalStateTextColor( normalColor );  			
+		iSearchTreeListVisualizer->RootNodeVisualizer()->SetNormalStateTextColor( normalColor );
 
 		// Launch search dialog automatically when activated
 		if ( &aCustomMessage && aCustomMessageId == KStartNewSearch )
@@ -415,15 +434,15 @@
 			// requeset async launching of the search dialog because DoActivateL must
 			// not be blocked
 			iStartupCallbackTimer->Cancel(); // just in case
-			iStartupCallbackTimer->Start( iAppUi.LayoutHandler()->ViewSlideEffectTime() );			
+			iStartupCallbackTimer->Start( iAppUi.LayoutHandler()->ViewSlideEffectTime() );
 			}
 		else if ( iModel && iModel->Count() )
 			{
 			// Need to make sure that return to this view works even if following function leaves.
-			TRAP_IGNORE( CheckAndUpdateFocusedMessageL() );		
+			TRAP_IGNORE( CheckAndUpdateFocusedMessageL() );
 			}
 		}
-    CAknEnv::Static()->GetCurrentGlobalUiZoom( iCurrentZoomLevel ); 	
+    CAknEnv::Static()->GetCurrentGlobalUiZoom( iCurrentZoomLevel );
 	// Set msk always empty when view is activated.
 	SetMskL();
 	// <cmail>
@@ -444,7 +463,7 @@
         iListAddedToControlGroup = EFalse;
         }
 	iThisViewActive = EFalse;
-	
+
     if ( !iAppUi.AppUiExitOngoing() )
         {
         if ( iSearchList->IsFocused() )
@@ -453,12 +472,12 @@
             }
         iSearchTreeListVisualizer->NotifyControlVisibilityChange( EFalse );
         }
-	}	
-	
+	}
+
 CFSEmailUiMailListModel* CFSEmailUiSearchListVisualiser::Model()
 	{
     FUNC_LOG;
-	return iModel;	
+	return iModel;
 	}
 
 void CFSEmailUiSearchListVisualiser::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane )
@@ -471,76 +490,76 @@
 		    if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
 			   {
 			   // remove help support in pf5250
-			   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
+			   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);
 			   }
-		    
-		  	CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));    
-			if ( item && item->ModelItemType() == ETypeMailItem && 
-				 item->MessagePtr().IsFlagSet( EFSMsgFlag_CalendarMsg ) ) 
+
+		  	CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
+			if ( item && item->ModelItemType() == ETypeMailItem &&
+				 item->MessagePtr().IsFlagSet( EFSMsgFlag_CalendarMsg ) )
 				{
 				// Highlighted mail is calendar msg
-				aMenuPane->SetItemDimmed(EFsEmailUiCmdMailActions, ETrue);						
-				aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActions, EFalse);				
+				aMenuPane->SetItemDimmed(EFsEmailUiCmdMailActions, ETrue);
+				aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActions, EFalse);
 				}
 			else
 				{
 				// Highlighted mail is mail msg
-				aMenuPane->SetItemDimmed(EFsEmailUiCmdMailActions, EFalse);						
-				aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActions, ETrue);	
-				}															
-			aMenuPane->SetItemDimmed(EFsEmailUiCmdOpen, EFalse);								
+				aMenuPane->SetItemDimmed(EFsEmailUiCmdMailActions, EFalse);
+				aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActions, ETrue);
+				}
+			aMenuPane->SetItemDimmed(EFsEmailUiCmdOpen, EFalse);
 			}
 		}
 	else
 		{
 		if ( aResourceId == R_FSEMAILUI_SEARCHLIST_MENUPANE )
 			{
-			
+
 		    if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ))
 			   {
 			   // remove help support in pf5250
-			   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
+			   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);
 			   }
-		    
-			aMenuPane->SetItemDimmed(EFsEmailUiCmdMore, ETrue);								
-			aMenuPane->SetItemDimmed(EFsEmailUiCmdMailActions, ETrue);								
-			aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActions, ETrue);								
-			aMenuPane->SetItemDimmed(EFsEmailUiCmdOpen, ETrue);	
-			aMenuPane->SetItemDimmed(EFsEmailUiCmdReadEmail, ETrue);								
-			}				
+
+			aMenuPane->SetItemDimmed(EFsEmailUiCmdMore, ETrue);
+			aMenuPane->SetItemDimmed(EFsEmailUiCmdMailActions, ETrue);
+			aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActions, ETrue);
+			aMenuPane->SetItemDimmed(EFsEmailUiCmdOpen, ETrue);
+			aMenuPane->SetItemDimmed(EFsEmailUiCmdReadEmail, ETrue);
+			}
 		}
-		
+
 	if ( aResourceId == R_FSEMAILUI_SEARCHLIST_SUBMENU_ACTIONS ||
 	     aResourceId == R_FSEMAILUI_SEARCHLIST_SUBMENU_CALEVENT_ACTIONS)
 		{
 		if ( iSearchList->Count() )
 			{
-		  	CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));    
+		  	CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
 			if ( item && item->ModelItemType() == ETypeMailItem )
 				{
 				CFSMailMessage* messagePtr = &item->MessagePtr();
 				if ( messagePtr && messagePtr->IsFlagSet( EFSMsgFlag_Read ) )
 					{
-					aMenuPane->SetItemDimmed(EFsEmailUiCmdMarkAsRead, ETrue);																	
+					aMenuPane->SetItemDimmed(EFsEmailUiCmdMarkAsRead, ETrue);
 					}
 				else
-					{					
-					aMenuPane->SetItemDimmed(EFsEmailUiCmdMarkAsUnread, ETrue);																	
-					}			
+					{
+					aMenuPane->SetItemDimmed(EFsEmailUiCmdMarkAsUnread, ETrue);
+					}
 				}
-			}	
-		}	
-		
+			}
+		}
+
 	if ( aResourceId == R_FSEMAILUI_SEARCHLIST_SUBMENU_CALEVENT_ACTIONS)
 		{
 		if ( iSearchList->Count() )
-			{		
-		  	CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));    
+			{
+		  	CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
 			if ( item && item->ModelItemType() == ETypeMailItem )
 				{
 				CFSMailMessage* messagePtr = &item->MessagePtr();
 				if ( messagePtr && messagePtr->IsFlagSet( EFSMsgFlag_CalendarMsg ) )
-					{											 
+					{
 				    TESMRMeetingRequestMethod mrMethod( EESMRMeetingRequestMethodUnknown );
 				    if ( iAppUi.MrViewerInstanceL() )
 				    	{
@@ -560,10 +579,10 @@
 							break;
 						case EESMRMeetingRequestMethodCancellation:
 						    {
-							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsAccept, ETrue);						
-							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsTentative, ETrue);						
-							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsDecline, ETrue);	
-							
+							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsAccept, ETrue);
+							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsTentative, ETrue);
+							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsDecline, ETrue);
+
 							TBool supportsRemove = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaRemoveFromCalendar );
 							if( !supportsRemove )
                                 {
@@ -575,36 +594,36 @@
 						case EESMRMeetingRequestMethodUnknown:
 						case EESMRMeetingRequestMethodResponse:
 						    {
-							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalRemoveFromCalendar, ETrue);						
-							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsAccept, ETrue);						
-							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsTentative, ETrue);						
+							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalRemoveFromCalendar, ETrue);
+							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsAccept, ETrue);
+							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsTentative, ETrue);
 							aMenuPane->SetItemDimmed(EFsEmailUiCmdCalActionsDecline, ETrue);
 						    }
 							break;
-						}			
-					}			
+						}
+					}
 				}
-			
+
 			}
 		}
-		
+
 
 	if ( aResourceId == R_FSEMAILUI_SEARCHLIST_SUBMENU_MORE )
 		{
 // <cmail> Prevent Download Manager opening with attachments
 //		if ( iAppUi.DownloadInfoMediator() && !iAppUi.DownloadInfoMediator()->IsAnyAttachmentDownloads() )
 //			{
-//			aMenuPane->SetItemDimmed(EFsEmailUiCmdDownloadManager, ETrue);																				
+//			aMenuPane->SetItemDimmed(EFsEmailUiCmdDownloadManager, ETrue);
 //			}
 // </cmail>
 		}
-	
-	if (aResourceId == R_FSEMAILUI_SEARCHLIST_SUBMENU_ACTIONS) 
+
+	if (aResourceId == R_FSEMAILUI_SEARCHLIST_SUBMENU_ACTIONS)
 	    {
-        CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));    
+        CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
         CFSMailMessage* messagePtr = &item->MessagePtr();
-        TInt menuIndex( 0 );   
-        
+        TInt menuIndex( 0 );
+
         //Get # of recipients
         TInt numRecipients(0);
         if ( messagePtr )
@@ -634,10 +653,10 @@
                             {
                             numRecipients++;
                             }
-                        }                
+                        }
                 }
-            
-            }                    
+
+            }
         if ( numRecipients > 1 )
             {
             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, EFalse );
@@ -647,23 +666,23 @@
             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue );
             }
 	    }
-		
+
 	if ( !iSearchOngoing && aResourceId == R_FSEMAILUI_SEARCHLIST_MENUPANE )
 		{
 	    if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ))
 		   {
 		   // remove help support in pf5250
-		   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
+		   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);
 		   }
-	    
-		aMenuPane->SetItemDimmed(EFsEmailUiCmdStopSearch, ETrue);						
+
+		aMenuPane->SetItemDimmed(EFsEmailUiCmdStopSearch, ETrue);
 		if ( iSearchCount == 0 )
 			{
-			aMenuPane->SetItemDimmed(EFsEmailUiCmdNewSearch, ETrue);		
+			aMenuPane->SetItemDimmed(EFsEmailUiCmdNewSearch, ETrue);
 			}
 		else
 			{
-			aMenuPane->SetItemDimmed(EFsEmailUiCmdSearch, ETrue);								
+			aMenuPane->SetItemDimmed(EFsEmailUiCmdSearch, ETrue);
 			}
 		}
 
@@ -672,13 +691,13 @@
 	    if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ))
 		   {
 		   // remove help support in pf5250
-		   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
+		   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);
 		   }
-	    
-		aMenuPane->SetItemDimmed(EFsEmailUiCmdSearch, ETrue);						
-		aMenuPane->SetItemDimmed(EFsEmailUiCmdNewSearch, ETrue);						
-		}		
-		
+
+		aMenuPane->SetItemDimmed(EFsEmailUiCmdSearch, ETrue);
+		aMenuPane->SetItemDimmed(EFsEmailUiCmdNewSearch, ETrue);
+		}
+
 	iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane, CFSEmailUiShortcutBinding::EContextSearchResults );
 	}
 
@@ -690,7 +709,7 @@
         if ( iModel && iModel->Count() )
              {
              // Check if zoom level has been switched and refresh items if so
-             TAknUiZoom prevZoomLevel = iCurrentZoomLevel;   
+             TAknUiZoom prevZoomLevel = iCurrentZoomLevel;
              CAknEnv::Static()->GetCurrentGlobalUiZoom( iCurrentZoomLevel );
              if ( prevZoomLevel != iCurrentZoomLevel )
                  {
@@ -698,15 +717,15 @@
                      {
                      // Set font height
                      iSearchListItemArray[i].iTreeItemVisualiser->
-                         SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() );               
+                         SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() );
                      iSearchTreeListVisualizer->UpdateItemL( iSearchListItemArray[i].iSearchListItemId );
-                     }                   
+                     }
                  }
-             }       
+             }
         }
 	}
 
-	
+
 void CFSEmailUiSearchListVisualiser::CreatePlainNodeL( const TDesC& aItemDataBuff,
                                                      CFsTreePlainOneLineNodeData* &aItemData,
                                                      CFsTreePlainOneLineNodeVisualizer* &aNodeVisualizer ) const
@@ -715,21 +734,21 @@
     aItemData = CFsTreePlainOneLineNodeData::NewL();
     aItemData->SetDataL( aItemDataBuff );
 	aItemData->SetIconExpanded( iAppUi.FsTextureManager()->TextureByIndex(EListTextureNodeExpanded) );
-    aItemData->SetIconCollapsed( iAppUi.FsTextureManager()->TextureByIndex(EListTextureNodeCollapsed) );	        
+    aItemData->SetIconCollapsed( iAppUi.FsTextureManager()->TextureByIndex(EListTextureNodeCollapsed) );
     aNodeVisualizer = CFsTreePlainOneLineNodeVisualizer::NewL( *iSearchList->TreeControl() );
    	TRect screenRect;
- 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );	
+ 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );
     TInt nodeHeight = iAppUi.LayoutHandler()->OneLineListNodeHeight();
     aNodeVisualizer->SetSize( TSize(screenRect.Width(), nodeHeight) );
     aNodeVisualizer->SetExtendable(EFalse);
-  	// Set correct skin text colors for the list items  
+  	// Set correct skin text colors for the list items
    	TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor();
    	TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
     aNodeVisualizer->SetFocusedStateTextColor( focusedColor );
-    aNodeVisualizer->SetNormalStateTextColor( normalColor );	 
+    aNodeVisualizer->SetNormalStateTextColor( normalColor );
  	}
 
-	
+
 void CFSEmailUiSearchListVisualiser::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType )
 	{
     FUNC_LOG;
@@ -740,13 +759,13 @@
             {
             SetStatusBarLayout();
             }
-    
+
         if ( iSearchTreeListVisualizer )
             {
             TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
-            iSearchTreeListVisualizer->RootNodeVisualizer()->SetNormalStateTextColor( normalColor );            
+            iSearchTreeListVisualizer->RootNodeVisualizer()->SetNormalStateTextColor( normalColor );
             }
-        ReScaleUiL();        
+        ReScaleUiL();
         }
 	}
 
@@ -774,6 +793,14 @@
         TBool aVisible )
     {
     CFsEmailUiViewBase::FocusVisibilityChange( aVisible );
+
+    if ( iStylusPopUpMenuVisible && !aVisible )
+        {
+        // Do not allow to remove the focus from a list element if the pop up
+        // menu was just launched.
+        return;
+        }
+
     iSearchTreeListVisualizer->SetFocusVisibility( aVisible );
     }
 
@@ -790,7 +817,7 @@
         // landscape must use different layout
         res = R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT;
         }
-    
+
     if ( StatusPane()->CurrentLayoutResId() !=  res )
         {
         TRAP_IGNORE(
@@ -801,6 +828,8 @@
 void CFSEmailUiSearchListVisualiser::HandleCommandL( TInt aCommand )
     {
     FUNC_LOG;
+
+
     switch ( aCommand )
         {
        	case EAknSoftkeySelect:
@@ -808,22 +837,22 @@
 			TInt modelCount(0);
 			if ( iModel )
 				{
-				modelCount = iModel->Count();				
+				modelCount = iModel->Count();
 				}
 		 	if ( modelCount ) // Safety check
 		 		{
-			  	CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));    
+			  	CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
 				if ( item && item->ModelItemType() == ETypeMailItem )
 					{
 					CFSMailMessage* messagePtr = &item->MessagePtr();
 					if ( messagePtr )
 						{
-						OpenHighlightedMailL();							
+						OpenHighlightedMailL();
 						}
 					}
 		 		}
- 			}        	
-        	break;         	
+ 			}
+        	break;
         case EAknSoftkeyBack:
 			{
 			if ( !iAppUi.ViewSwitchingOngoing())
@@ -834,18 +863,18 @@
 					}
                                 //<cmail> useless code removed
 				//HBufC* searchText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_FIND_DLG_SEARCH );
-				//iBarTextVisual->SetTextL( *searchText );		
+				//iBarTextVisual->SetTextL( *searchText );
 				//CleanupStack::PopAndDestroy( searchText );
                                 //</cmail>
 		 		TVwsViewId viewId = TVwsViewId( KFSEmailUiUid, MailListId );
-				TMailListActivationData tmp;	
+				TMailListActivationData tmp;
 				if ( iMsgDataCouldBeChanged )
 					{
 					tmp.iRequestRefresh = ETrue;
 					iMsgDataCouldBeChanged = EFalse; // List starts a new search
-					}	
-				const TPckgBuf<TMailListActivationData> pkgOut( tmp );	
-				iAppUi.ReturnToPreviousViewL( pkgOut );        								
+					}
+				const TPckgBuf<TMailListActivationData> pkgOut( tmp );
+				iAppUi.ReturnToPreviousViewL( pkgOut );
 				}
 			}
 	       	break;
@@ -860,7 +889,7 @@
 			if ( iSearchList->Count() )
 				{
 				iMsgDataCouldBeChanged = ETrue;
-		   	 	ReplyL( NULL ); // Function will check marked/highlighted msg				
+		   	 	ReplyL( NULL ); // Function will check marked/highlighted msg
 				}
 			}
             break;
@@ -881,7 +910,7 @@
 				iMsgDataCouldBeChanged = ETrue;
 				ForwardL( NULL ); // Function will check marked/highlighted msg
 				}
-			}      
+			}
             break;
 		case EFsEmailUiCmdGoToTop:
 			{
@@ -933,36 +962,36 @@
         	{
  			if ( iSearchList->Count() )
 				{
-				OpenHighlightedMailL();	       	
+				OpenHighlightedMailL();
 				}
 			}
-        	break;	
+        	break;
        	case EFsEmailUiCmdNewSearch:
         case EFsEmailUiCmdSearch:
         	{
-			LaunchSearchDialogL();						 			        		
+			LaunchSearchDialogL();
         	}
-        	break;     	        	   	        	
+        	break;
         case EFsEmailUiCmdStopSearch:
         	{
 			StopSearchL();
         	}
-        	break;  
+        	break;
        	case EFsEmailUiCmdMessageDetails:
 			{
  			if ( iSearchList->Count() )
 				{
 				CFSEmailUiMailListModelItem* item =
-					static_cast<CFSEmailUiMailListModelItem*>( Model()->Item( HighlightedIndex() ) );		
+					static_cast<CFSEmailUiMailListModelItem*>( Model()->Item( HighlightedIndex() ) );
 				CFSMailMessage& msg = item->MessagePtr();
-				
+
 	  			TMsgDetailsActivationData msgDetailsData;
 	  			msgDetailsData.iMailBoxId = msg.GetMailBoxId();
 	  			msgDetailsData.iFolderId = msg.GetFolderId();
 	  			msgDetailsData.iMessageId = msg.GetMessageId();
-				
+
 				const TPckgBuf<TMsgDetailsActivationData> pkgOut( msgDetailsData );
-				iAppUi.EnterFsEmailViewL( MsgDetailsViewId, KStartMsgDetailsToBeginning,  pkgOut);					
+				iAppUi.EnterFsEmailViewL( MsgDetailsViewId, KStartMsgDetailsToBeginning,  pkgOut);
 				}
 			}
 			break;
@@ -970,27 +999,27 @@
   			{
 			TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID );
   			}
-  			break; 
+  			break;
        	case EFsEmailUiCmdActionsCallSender:
 			{
 			if ( iSearchList->Count() )
 				{
-				CallToSenderL();		
+				CallToSenderL();
 				}
 			}
 			break;
     	case EFsEmailUiCmdActionsAddContact:
     		{
-			if ( iSearchList->Count() ) 
+			if ( iSearchList->Count() )
 				{
-			    CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));    			
+			    CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
 				if ( item && item->ModelItemType() == ETypeMailItem )
 					{
 					CFSMailAddress* fromAddress = item->MessagePtr().GetSender();
 					TDesC* emailAddress(0);
 					if ( fromAddress )
 						{
-						emailAddress = &fromAddress->GetEmailAddress();		
+						emailAddress = &fromAddress->GetEmailAddress();
 						}
 					if ( emailAddress && emailAddress->Length() )
 						{
@@ -998,19 +1027,19 @@
 						//Query to "update existing" or "Create new" --> EFALSE = user choosed "cancel"
 						if ( CFsDelayedLoader::InstanceL()->GetContactHandlerL()->AddtoContactsQueryL( aType ) )
 							{
-							CFsDelayedLoader::InstanceL()->GetContactHandlerL()->AddToContactL( 
-									*emailAddress, EContactUpdateEmail, aType, this );		
-							}										
+							CFsDelayedLoader::InstanceL()->GetContactHandlerL()->AddToContactL(
+									*emailAddress, EContactUpdateEmail, aType, this );
+							}
 						}
 					}
 				}
-    		}			
+    		}
 			break;
         case EFsEmailUiCmdMarkAsReadUnreadToggle:
             {
             if ( iSearchList->Count() )
                 {
-           		CFSEmailUiMailListModelItem* item = 
+           		CFSEmailUiMailListModelItem* item =
         			static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ));
         		if ( item && item->ModelItemType() == ETypeMailItem )
         			{
@@ -1041,37 +1070,55 @@
         case EFsEmailUiCmdCalActionsDecline:
         case EFsEmailUiCmdCalRemoveFromCalendar:
 			{
-		    CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));    			
-			if ( item && item->ModelItemType() == ETypeMailItem && 
+		    CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
+			if ( item && item->ModelItemType() == ETypeMailItem &&
 				 item->MessagePtr().IsFlagSet( EFSMsgFlag_CalendarMsg ) )
 				{
 			    ChangeReadStatusOfHighlightedL( ETrue );
-                iAppUi.MailViewer().HandleMrCommandL( aCommand, 
+                iAppUi.MailViewer().HandleMrCommandL( aCommand,
                                                        iAppUi.GetActiveMailbox()->GetId(),
                                                        item->MessagePtr().GetFolderId(),
                                                        item->MessagePtr().GetMessageId() );
-				}				
+				}
 			}
-        	break;							
+        	break;
 // <cmail> Prevent Download Manager opening with attachments
 //       	case EFsEmailUiCmdDownloadManager:
 //       		{
 //			if (iSearchOngoing)
 //				{
 //				StopSearchL();
-//				}	
-//  			iAppUi.EnterFsEmailViewL( DownloadManagerViewId );       			
-//       		}       		
+//				}
+//  			iAppUi.EnterFsEmailViewL( DownloadManagerViewId );
+//       		}
 //			break;
 // </cmail>
        	case EFsEmailUiCmdReadEmail:
 			{
 			iAppUi.StartReadingEmailsL();
-			}  			    		
+			}
 			break;
         default:
         	break;
-        }	
+        }
+
+    // Check if the focus needs to be removed after selecting an command from
+    // the stylus popup menu.
+    if ( ( iStylusPopUpMenuVisible ) &&
+         ( aCommand == KErrCancel ||
+           aCommand == EFsEmailUiCmdActionsDelete ||
+           aCommand == EFsEmailUiCmdMarkAsRead ||
+           aCommand == EFsEmailUiCmdMarkAsUnread ||
+           aCommand == EFsEmailUiCmdActionsMove ||
+           aCommand == EFsEmailUiCmdMarkUnmarkToggle ) )
+        {
+        // We end up here if the user selects an option from the pop up menu
+        // or exits the menu by tapping outside of it's area.
+        // Remove the focus from a list item if an item is focused.
+        iStylusPopUpMenuVisible = EFalse;
+        iAppUi.SetFocusVisibility( EFalse );
+        }
+
     }
 
 
@@ -1094,7 +1141,7 @@
 		if ( iSearchOngoing )
 		    {
 		    StopSearchL();
-		    }	        
+		    }
               //<cmail> make list and header visible by showing control group
 		else if( !iListAddedToControlGroup )
             {
@@ -1105,15 +1152,15 @@
 		iSearchList->SetScrollbarVisibilityL( EFsScrollbarAuto );
              //</cmail>
 		// Set searching text
-		HBufC* searchText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_FIND_DLG_SEARCHING );	
+		HBufC* searchText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_FIND_DLG_SEARCHING );
 		HBufC* finalText = HBufC::NewLC( searchText->Length() + iLatestSearchText->Length() + KSpace().Length() );
 		finalText->Des().Append( *searchText );
 		finalText->Des().Append( KSpace );
-		finalText->Des().Append( *iLatestSearchText );			
-		iBarTextVisual->SetTextL( *finalText );		
-		CleanupStack::PopAndDestroy( finalText );		
-		CleanupStack::PopAndDestroy( searchText );				
-		StartSearchL();		
+		finalText->Des().Append( *iLatestSearchText );
+		iBarTextVisual->SetTextL( *finalText );
+		CleanupStack::PopAndDestroy( finalText );
+		CleanupStack::PopAndDestroy( searchText );
+		StartSearchL();
 		}
 	return ret;
 	}
@@ -1147,7 +1194,7 @@
 			else
 				{
 				iListMode = EListControlTypeDoubleLinePreviewOn;
-				}					
+				}
 			}
 		}
 	else
@@ -1156,13 +1203,22 @@
 		iListMode = EListControlTypeDoubleLinePreviewOff;
 		}
 	}
-	
-	
+
+
 TBool CFSEmailUiSearchListVisualiser::OfferEventL(const TAlfEvent& aEvent)
     {
     FUNC_LOG;
     TBool result(EFalse);
-  
+    // On KeyUp of EStdKeyYes usually Call application is called - prevent it if call for contact was previously called
+    if ( iConsumeStdKeyYes_KeyUp && aEvent.IsKeyEvent() && (aEvent.Code() == EEventKeyUp )) 
+		{
+		iConsumeStdKeyYes_KeyUp = EFalse; // in case call button was consumed elsewhere first key up enables calling Call application
+		if ( EStdKeyYes == aEvent.KeyEvent().iScanCode) 
+			{
+			  result = ETrue; // consume not to switch to Call application when call to contact was processed
+			}
+		}
+
     if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey )
         {
         TInt scanCode = aEvent.KeyEvent().iScanCode;
@@ -1186,7 +1242,7 @@
                 {
                 return ETrue;
                 }
-            
+
 			}
         switch ( scanCode )
             {
@@ -1196,32 +1252,24 @@
                 {
                 if ( iSearchList->Count() )
                     {
-                    OpenHighlightedMailL();         		
+                    OpenHighlightedMailL();
                     }
-                result = ETrue;         	
+                result = ETrue;
                 }
                 break;
             case EStdKeyYes:
                 {
                 if ( iSearchList->Count() )
                     {
-                    CallToSenderL();				
+                    result = CallToSenderL();	
+                    iConsumeStdKeyYes_KeyUp = result;
                     }
                 }
                 break;
-            case EStdKeyRightArrow:
-                 {     
-                 if ( iSearchList->Count() )
-                      {
-                      LaunchActionMenuL();                       
-                      }                
-                 result = ETrue; 
-                 }
-                 break;
             default:
                 {
                 // check keyboard shortcuts:
-                TInt command = 
+                TInt command =
                     iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(),
                         CFSEmailUiShortcutBinding::EContextSearchResults );
                 if ( command >= 0 )
@@ -1237,8 +1285,8 @@
         {
         iSearchList->TreeControl()->OfferEventL(aEvent);
         }
-    
-    return result;   
+
+    return result;
     }
 
 
@@ -1251,20 +1299,20 @@
         SetSearchListLayoutAnchors();
         iScreenAnchorLayout->UpdateChildrenLayout();
         iSearchListLayout->UpdateChildrenLayout();
-        // Set bar text color from skin 
+        // Set bar text color from skin
         if ( iBarTextVisual )
             {
 			//<cmail>
 			SetHeaderAttributesL();
 			/*TRgb barTextColor( KRgbBlack );
-		    AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), 
+		    AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
 		                               barTextColor, KAknsIIDFsTextColors, EAknsCIFsTextColorsCG10 );
 			iBarTextVisual->SetColor( barTextColor );*/
 			//</cmail>
             }
         RefreshL();
         //iSearchTreeListVisualizer->HideList();
-        iSearchTreeListVisualizer->ShowListL();                
+        iSearchTreeListVisualizer->ShowListL();
         }
  	}
 
@@ -1275,39 +1323,39 @@
 
 	// The anchor layout mirrors itself automatically when necessary.
 	// There's no need to mirror anything manually here.
-	
+
 	// BAR BACGROUND IMAGE
     TRect contBarRect = iAppUi.LayoutHandler()->GetControlBarRect();
     TPoint& tl( contBarRect.iTl );
-    iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 0, 
+    iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 0,
         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
         TAlfTimedPoint( tl.iX, tl.iY ));
     TPoint& br( contBarRect.iBr );
-    iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 0, 
+    iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 0,
         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
         TAlfTimedPoint( br.iX, br.iY ));
-        
+
 	// TEXT
     TRect textRect =  iAppUi.LayoutHandler()->GetSearchListHeaderTextLayout().TextRect();
     tl = textRect.iTl;
-    iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 1, 
+    iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 1,
         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
         TAlfTimedPoint( tl.iX, tl.iY ));
     br = textRect.iBr;
-    iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 1, 
+    iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 1,
         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
         TAlfTimedPoint( br.iX, br.iY ));
 
     TRect listRect = iAppUi.LayoutHandler()->GetListRect( ETrue );
-    iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 2, 
+    iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 2,
         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
         TAlfTimedPoint(listRect.iTl.iX, listRect.iTl.iY));
-    iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 2, 
+    iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 2,
         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
         TAlfTimedPoint(listRect.iBr.iX, listRect.iBr.iY));
@@ -1320,24 +1368,24 @@
 	TFSMailMsgId msgId; // constructs null ID
     if ( 0 <= aItemIdx && aItemIdx < iModel->Count() )
         {
-        CFSEmailUiMailListModelItem* item = 
+        CFSEmailUiMailListModelItem* item =
     			static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(aItemIdx));
     	if ( item->ModelItemType() == ETypeMailItem )
     	    {
     	    msgId = item->MessagePtr().GetMessageId();
     	    }
         }
-        
+
     return msgId;
     }
-	
+
 TFSMailMsgId CFSEmailUiSearchListVisualiser::MsgIdFromListId( TFsTreeItemId aListId ) const
 	{
     FUNC_LOG;
 	TFSMailMsgId msgId;
 	for ( TInt i=0; i<iModel->Count();i++)
 		{
-		CFSEmailUiMailListModelItem* item = 
+		CFSEmailUiMailListModelItem* item =
 			static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(i));
 		if ( item->ModelItemType() == ETypeMailItem &&
 		     aListId == item->CorrespondingListId() )
@@ -1345,7 +1393,7 @@
 			msgId = item->MessagePtr().GetMessageId();
 			break;
 			}
-		}	
+		}
 	return msgId;
 	}
 
@@ -1355,17 +1403,17 @@
 	CFSMailMessage* msgPtr(NULL);
 	for ( TInt i=0; i<iModel->Count();i++)
 		{
-		CFSEmailUiMailListModelItem* item = 
+		CFSEmailUiMailListModelItem* item =
 			static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(i));
 		if ( aListId == item->CorrespondingListId() )
 			{
 			msgPtr = &item->MessagePtr();
 			}
 		}
-	return *msgPtr;	
+	return *msgPtr;
 	}
-	
-	// Item data and visualiser helper functions 
+
+	// Item data and visualiser helper functions
 MFsTreeItemData* CFSEmailUiSearchListVisualiser::ItemDataFromItemId( TFsTreeItemId aItemId )
 	{
     FUNC_LOG;
@@ -1380,7 +1428,7 @@
 		}
 	return itemData;
 	}
-	
+
 MFsTreeItemVisualizer* CFSEmailUiSearchListVisualiser::ItemVisualiserFromItemId( TFsTreeItemId aItemId )
 	{
     FUNC_LOG;
@@ -1401,10 +1449,10 @@
     {
     FUNC_LOG;
 	TInt idx = KErrNotFound;
-	
+
 	for ( TInt i=0; i<iModel->Count() ; i++ )
 		{
-		CFSEmailUiMailListModelItem* item = 
+		CFSEmailUiMailListModelItem* item =
 			static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(i));
 		if ( item->ModelItemType() == ETypeMailItem &&
 		     aMessageId == item->MessagePtr().GetMessageId() )
@@ -1412,49 +1460,49 @@
 			idx = i;
 			break;
 			}
-		}	
-	
+		}
+
 	return idx;
     }
-	
+
 TInt CFSEmailUiSearchListVisualiser::NextMessageIndex( TInt aCurMsgIdx ) const
     {
     FUNC_LOG;
 	TInt idx = KErrNotFound;
-	
+
 	for ( TInt i=aCurMsgIdx+1 ; i<iModel->Count() ; i++ )
 		{
-		CFSEmailUiMailListModelItem* item = 
+		CFSEmailUiMailListModelItem* item =
 			static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(i));
 		if ( item && item->ModelItemType() == ETypeMailItem )
 			{
 			idx = i;
 			break;
 			}
-		}	
-	
+		}
+
 	return idx;
     }
-	
+
 TInt CFSEmailUiSearchListVisualiser::PreviousMessageIndex( TInt aCurMsgIdx ) const
     {
     FUNC_LOG;
 	TInt idx = KErrNotFound;
-	
+
 	if ( aCurMsgIdx < iModel->Count() )
 	    {
     	for ( TInt i=aCurMsgIdx-1 ; i>=0 ; i-- )
     		{
-    		CFSEmailUiMailListModelItem* item = 
+    		CFSEmailUiMailListModelItem* item =
     			static_cast<CFSEmailUiMailListModelItem*>(iModel->Item(i));
     		if ( item && item->ModelItemType() == ETypeMailItem )
     			{
     			idx = i;
     			break;
     			}
-    		}	
+    		}
 	    }
-	
+
 	return idx;
     }
 
@@ -1465,29 +1513,29 @@
 	if (iSearchOngoing)
 		{
 		StopSearchL();
-		}		
-	
+		}
+
 	CFSEmailUiMailListModelItem* item =
 		static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) );
 	if ( item->ModelItemType() == ETypeMailItem )
 		{
 		// First make sure that the highlighted message really exists in the store
-		// Get confirmed msg ptr 
+		// Get confirmed msg ptr
 		CFSMailMessage* confirmedMsgPtr(0);
-		TRAPD( err, confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL(iAppUi.GetActiveMailboxId(), 
+		TRAPD( err, confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL(iAppUi.GetActiveMailboxId(),
 							item->MessagePtr().GetFolderId(), item->MessagePtr().GetMessageId(), EFSMsgDataEnvelope ) );
 		if ( confirmedMsgPtr && err == KErrNone )
 			{
-		 	CFSMailFolder* highlightedMsgFolder = 
+		 	CFSMailFolder* highlightedMsgFolder =
 		 		iAppUi.GetMailClient()->GetFolderByUidL( iAppUi.GetActiveMailboxId(), confirmedMsgPtr->GetFolderId() );
-			CleanupStack::PushL( highlightedMsgFolder ); 
+			CleanupStack::PushL( highlightedMsgFolder );
 			TInt msgFolderType = highlightedMsgFolder->GetFolderType();
 			TFSMailMsgId highlightedMsgFolderId = highlightedMsgFolder->GetFolderId();
-			CleanupStack::PopAndDestroy( highlightedMsgFolder );			
+			CleanupStack::PopAndDestroy( highlightedMsgFolder );
 			// Pointer confirmed, store Id and delete not needed anymore
 			TFSMailMsgId confirmedId = confirmedMsgPtr->GetMessageId();
 			delete confirmedMsgPtr;
-			
+
 			// Open to editor from drafts
 			if ( msgFolderType == EFSDraftsFolder )
 				{
@@ -1496,7 +1544,7 @@
 				params.iActivatedExternally = EFalse;
 				params.iMsgId = confirmedId;
 				params.iFolderId = highlightedMsgFolderId;
-			    iAppUi.LaunchEditorL( KEditorCmdOpen, params );						
+			    iAppUi.LaunchEditorL( KEditorCmdOpen, params );
 				}
 			else if ( msgFolderType == EFSOutbox )
 				{
@@ -1504,19 +1552,19 @@
 				}
 			else
 				{
-				THtmlViewerActivationData tmp;	
+				THtmlViewerActivationData tmp;
 				tmp.iMailBoxId = iAppUi.GetActiveMailbox()->GetId();
 				tmp.iMessageId = confirmedId;
-				tmp.iFolderId = highlightedMsgFolderId;	
-				
-				const TPckgBuf<THtmlViewerActivationData> pkgOut( tmp );	
-				ChangeReadStatusOfHighlightedL( ETrue ); 									
-				iAppUi.EnterFsEmailViewL( HtmlViewerId, KStartViewerWithMsgId, pkgOut );								
-				}					
+				tmp.iFolderId = highlightedMsgFolderId;
+
+				const TPckgBuf<THtmlViewerActivationData> pkgOut( tmp );
+				ChangeReadStatusOfHighlightedL( ETrue );
+				iAppUi.EnterFsEmailViewL( HtmlViewerId, KStartViewerWithMsgId, pkgOut );
+				}
 			}
 		else if ( err == KErrNotFound )
 			{
-			TRAP_IGNORE( CheckAndUpdateFocusedMessageL() );							
+			TRAP_IGNORE( CheckAndUpdateFocusedMessageL() );
 			}
 		}
 	}
@@ -1528,13 +1576,13 @@
     FUNC_LOG;
 	DoReplyForwardL( KEditorCmdReply, aMsgPtr );
 	}
-	
+
 void CFSEmailUiSearchListVisualiser::ReplyAllL(  CFSMailMessage* aMsgPtr )
 	{
     FUNC_LOG;
 	DoReplyForwardL( KEditorCmdReplyAll, aMsgPtr );
 	}
-	
+
 void CFSEmailUiSearchListVisualiser::ForwardL( CFSMailMessage* aMsgPtr )
 	{
     FUNC_LOG;
@@ -1548,14 +1596,14 @@
 	if ( iSearchOngoing )
 		{
 		StopSearchL();
-		} 
-    
+		}
+
     if ( iModel->Count() )
         {
        	CFSMailMessage* messagePointer = aMsgPtr;
     	if ( !messagePointer  )
     		{
-            RFsTreeItemIdList markedEntries;	
+            RFsTreeItemIdList markedEntries;
     		iSearchList->GetMarkedItemsL( markedEntries );
     		TInt markedCount = markedEntries.Count();
     		if ( markedCount == 0 )
@@ -1570,19 +1618,19 @@
     		else if ( markedCount == 1)
     			{
     			messagePointer = &MsgPtrFromListId( markedEntries[0] );
-    			}	
+    			}
     		}
     	if ( messagePointer )
     		{
     		// No reply/Forward for calendar messages, at least not in 1.0
-	   		if ( !messagePointer->IsFlagSet( EFSMsgFlag_CalendarMsg ) ) 
+	   		if ( !messagePointer->IsFlagSet( EFSMsgFlag_CalendarMsg ) )
     			{
 	    		TEditorLaunchParams params;
 	    		params.iMailboxId = iAppUi.GetActiveMailboxId();
-	    		params.iActivatedExternally = EFalse;								
+	    		params.iActivatedExternally = EFalse;
 	    		params.iMsgId = messagePointer->GetMessageId();
-	    		iAppUi.LaunchEditorL( aMode, params );			    			
-    			}      				
+	    		iAppUi.LaunchEditorL( aMode, params );
+    			}
     		}
         }
     }
@@ -1591,7 +1639,7 @@
 	{
     FUNC_LOG;
 	iSearchCount++;
-	
+
     // Reset previous results before starting new search
 	// <cmail> fixed CS high cat. finding
 	ResetResultListL();
@@ -1599,12 +1647,12 @@
     while ( !lex.Eos() )
         {
         HBufC* token = lex.NextToken().AllocLC();
-      
+
         iSearchStrings.AppendL( token );
-        
+
         CleanupStack::Pop( token );
         }
-    
+
 	TFSMailSortCriteria sortCriteria;
     sortCriteria.iField = EFSMailSortByDate;
     sortCriteria.iOrder = EFSMailDescending;
@@ -1612,7 +1660,7 @@
 	// Model and list is set to be empty, set also MSK to empty
 	SetMskL();
 	// Initialisr TextSearcher
-	
+
 	// Start search.
 	iMailBox->SearchL( iSearchStrings, sortCriteria, *this );
 	}
@@ -1622,25 +1670,31 @@
     FUNC_LOG;
 	iSearchOngoing = EFalse;
 	if ( iMailBox )
-		{		
+		{
 		iMailBox->CancelSearch();
-		}		
+		}
 	HBufC* searchText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_FIND_DLG_SEARCH_RESULTS );
 	HBufC* finalText = HBufC::NewLC( searchText->Length() + iLatestSearchText->Length() + 4 );
 	finalText->Des().Append( *searchText );
 	finalText->Des().Append( KSpace );
-	finalText->Des().Append( *iLatestSearchText );			
-	iBarTextVisual->SetTextL( *finalText );		
+	finalText->Des().Append( *iLatestSearchText );
+	iBarTextVisual->SetTextL( *finalText );
 	CleanupStack::PopAndDestroy( finalText );
-	CleanupStack::PopAndDestroy( searchText );	
+	CleanupStack::PopAndDestroy( searchText );
+	iRequiredSearchPriority = KStandardSearchPriority; // <cmail> return back
 	}
 
 void CFSEmailUiSearchListVisualiser::ResetResultListL()
     {
-	// <cmail> fixed CS high cat. finding    
     FUNC_LOG;
-    iModel->Reset();
-    iSearchList->RemoveAllL();
+    if( iModel )
+        {
+        iModel->Reset();
+        }
+    if( iSearchList )
+        {
+        iSearchList->RemoveAllL();
+        }
     iSearchListItemArray.Reset();
     iSearchStrings.ResetAndDestroy();
     }
@@ -1648,7 +1702,7 @@
 void CFSEmailUiSearchListVisualiser::MatchFoundL( CFSMailMessage* aMatchMessage )
 	{
     FUNC_LOG;
-    
+
 	if ( !iSearchList->IsFocused() )
 		{
 		iSearchList->SetFocusedL( ETrue );
@@ -1658,29 +1712,29 @@
 	// This is done because it seems that matched message objects seems to be different
 	// in some protocols than original messages
 	CleanupStack::PushL( aMatchMessage );
-	CFSMailMessage* confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), 
+	CFSMailMessage* confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(),
 						aMatchMessage->GetFolderId(), aMatchMessage->GetMessageId(), EFSMsgDataEnvelope );
 	CleanupStack::PopAndDestroy( aMatchMessage );
-	
+
 	if ( confirmedMsgPtr ) // Append item into model and list if msg pointer was confirmed
 		{
 		// Append to model
-		CFSEmailUiMailListModelItem* newItem = CFSEmailUiMailListModelItem::NewL( confirmedMsgPtr, ETypeMailItem);		    				    	
+		CFSEmailUiMailListModelItem* newItem = CFSEmailUiMailListModelItem::NewL( confirmedMsgPtr, ETypeMailItem);
 		iModel->AppendL(newItem);
 
 		// Append to list
 	   	TRect screenRect;
-	 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );	 
+	 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );
 
-		CFSMailAddress* fromAddress = confirmedMsgPtr->GetSender();		
-		TDesC* diplayName(0);
+		CFSMailAddress* fromAddress = confirmedMsgPtr->GetSender();
+		TDesC* diplayName = NULL;
 		if ( fromAddress )
 			{
-			diplayName = &fromAddress->GetDisplayName();				
+			diplayName = &fromAddress->GetDisplayName();
 			}
-			
+
 		// Set first line of data
-		HBufC* dispName(0);
+		HBufC* dispName = NULL;
 		if ( fromAddress && diplayName && diplayName->Length() != 0 )
 			{
 			dispName = HBufC::NewLC( diplayName->Length() );
@@ -1694,79 +1748,67 @@
 		else
 			{
 			dispName = HBufC::NewLC( 0 );
-			dispName->Des().Append( KNullDesC );				
+			dispName->Des().Append( KNullDesC );
 			}
-			
+
 		// Drop out unwanted characters from display name such as <> and ""
 		// And set display name data
 		if ( dispName )
 			{
-			TFsEmailUiUtility::StripDisplayName( *dispName );		
+			TFsEmailUiUtility::StripDisplayName( *dispName );
 			}
-		// Create item data and 
-		CFsTreePlainTwoLineItemData* itemData = CFsTreePlainTwoLineItemData::NewL();			
+		// Create item data and
+		CFsTreePlainTwoLineItemData* itemData = CFsTreePlainTwoLineItemData::NewL();
 
-		itemData->SetDataL( *dispName );				
+		itemData->SetDataL( *dispName );
 		CleanupStack::PopAndDestroy( dispName );
-		
+
 		// Set time text data
-		HBufC* timeText = TFsEmailUiUtility::ListMsgTimeTextFromMsgLC( confirmedMsgPtr, EFalse );			
-		itemData->SetDateTimeDataL ( *timeText );	 			
+		HBufC* timeText = TFsEmailUiUtility::ListMsgTimeTextFromMsgLC( confirmedMsgPtr, EFalse );
+		itemData->SetDateTimeDataL ( *timeText );
 		CleanupStack::PopAndDestroy();
 
 		// Set second line of data
-	
 		HBufC* subjectText = TFsEmailUiUtility::CreateSubjectTextLC( confirmedMsgPtr );
-
-		
-		    itemData->SetSecondaryDataL( *subjectText);
-	
-              
-              
-		
+		itemData->SetSecondaryDataL( *subjectText );
 		CleanupStack::PopAndDestroy( subjectText );
 
-		
 		// Set message icon
-		CAlfTexture* itemTexture = &TFsEmailUiUtility::GetMsgIcon( confirmedMsgPtr, *iAppUi.FsTextureManager() );	
+		CAlfTexture* itemTexture = &TFsEmailUiUtility::GetMsgIcon( confirmedMsgPtr, *iAppUi.FsTextureManager() );
 		itemData->SetIcon ( *itemTexture );
 	    CFsTreePlainTwoLineItemVisualizer* itemVisualizer = CFsTreePlainTwoLineItemVisualizer::NewL(*iSearchList->TreeControl());
-	   
-	    
-		itemVisualizer->SetExtendable( ETrue );     		 
+
+		itemVisualizer->SetExtendable( ETrue );
 		TInt itemHeight = iAppUi.LayoutHandler()->OneLineListItemHeight();
 
-		itemVisualizer->SetSize(TSize(screenRect.Width(), itemHeight));
-	 	itemVisualizer->SetExtendedSize(TSize(screenRect.Width(), 2*itemHeight));	 
-	    
-	 	// Set menu icon
-	 	itemVisualizer->SetFlags( itemVisualizer->Flags() | KFsTreeListItemHasMenu );
-	    
+		itemVisualizer->SetSize( TSize( screenRect.Width(), itemHeight ) );
+	 	itemVisualizer->SetExtendedSize( TSize( screenRect.Width(), 2*itemHeight ) );
+
 		// Set font height
-		itemVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() );		
+		itemVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() );
 
 		// Set font bolding
 		if ( confirmedMsgPtr->IsFlagSet( EFSMsgFlag_Read ) )
-			{	
+			{
 			itemVisualizer->SetTextBold( EFalse );
 			}
 		else
 			{
 			itemVisualizer->SetTextBold( ETrue );
-			}		
+			}
 
-	  	// Set correct skin text colors for the list items  
+	  	// Set correct skin text colors for the list items
 	   	TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor();
 	   	TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
 	    itemVisualizer->SetFocusedStateTextColor( focusedColor );
 	    itemVisualizer->SetNormalStateTextColor( normalColor );
-	    
+
 		switch ( iListMode )
 		    {
 		    case EListControlTypeDoubleLinePreviewOn:
 		    case EListControlTypeSingleLinePreviewOn:
-				itemVisualizer->SetPreviewPaneOn( ETrue ); 
-				itemVisualizer->SetPreviewPaneEnabledSize( TSize(screenRect.Width(), 3*itemHeight) ); 
+				itemVisualizer->SetPreviewPaneOn( ETrue );
+				itemVisualizer->SetPreviewPaneEnabledSize( TSize(screenRect.Width(), 3*itemHeight) );
 		        // fall through
 		    case EListControlTypeDoubleLinePreviewOff:
 		    case EListControlTypeSingleLinePreviewOff:
@@ -1778,7 +1820,7 @@
 		    }
 
 		// Update initial preview pane text for items if needed
-	  	if ( iListMode == EListControlTypeSingleLinePreviewOn || 
+	  	if ( iListMode == EListControlTypeSingleLinePreviewOn ||
 			 iListMode == EListControlTypeDoubleLinePreviewOn )
 			{
 			UpdatePreviewPaneTextForItemL( itemData, confirmedMsgPtr );
@@ -1790,35 +1832,35 @@
 			if ( confirmedMsgPtr->IsFlagSet( EFSMsgFlag_FollowUp ) )
 				{
 			 	itemData->SetFlagIcon( iAppUi.FsTextureManager()->TextureByIndex( EFollowUpFlagList ) );
-				itemVisualizer->SetFlagIconVisible( ETrue );		 		
+				itemVisualizer->SetFlagIconVisible( ETrue );
 				}
 			else if ( confirmedMsgPtr->IsFlagSet( EFSMsgFlag_FollowUpComplete ) )
 				{
 			 	itemData->SetFlagIcon( iAppUi.FsTextureManager()->TextureByIndex( EFollowUpFlagCompleteList ) );
-				itemVisualizer->SetFlagIconVisible( ETrue );				 		
+				itemVisualizer->SetFlagIconVisible( ETrue );
 				}
 			else
 				{
-		 	    itemVisualizer->SetFlagIconVisible( EFalse );			
-				}		
+		 	    itemVisualizer->SetFlagIconVisible( EFalse );
+				}
 			}
 	 	else
 	 	    {
 	 	    itemVisualizer->SetFlagIconVisible( EFalse );
 	 	    }
 
-		TFsTreeItemId itemId = iSearchList->InsertItemL( *itemData, *itemVisualizer, KFsTreeRootID );    		  
+		TFsTreeItemId itemId = iSearchList->InsertItemL( *itemData, *itemVisualizer, KFsTreeRootID );
 		if (iSearchList->FocusedItem() == KFsTreeNoneID)
 		    {
 		    iSearchList->SetFocusedItemL(itemId);
 		    }
-		
+
 		SSearchListItem searchListItem;
 		searchListItem.iSearchListItemId = itemId;
 		searchListItem.iTreeItemData = itemData;
-		searchListItem.iTreeItemVisualiser = itemVisualizer;			
+		searchListItem.iTreeItemVisualiser = itemVisualizer;
 	    iSearchListItemArray.AppendL( searchListItem );
-	    newItem->AddCorrespondingListId( itemId );      
+	    newItem->AddCorrespondingListId( itemId );
 
 		if ( iSearchList->Count() == 1 ) // Call only once, temp fix because of error in generic
 			{
@@ -1830,14 +1872,14 @@
 			else
 				{
 				// Set the extendedability and extended size
-		   		iSearchTreeListVisualizer->SetItemsAlwaysExtendedL( EFalse ); 		
-				}		
-			
+		   		iSearchTreeListVisualizer->SetItemsAlwaysExtendedL( EFalse );
+				}
+
 			// Set msk to "Open when first is found".
 			SetMskL();
-			}	
+			}
 		}
-        
+
 	}
 
 // ---------------------------------------------------------------------------
@@ -1853,7 +1895,7 @@
     if ( iFirstStartCompleted ) // Safety
         {
         CFSMailBox* activeMailbox = iAppUi.GetActiveMailbox();
-        if ( activeMailbox && aMailbox.Id() == activeMailbox->GetId().Id() ) // Safety, in list events that only concern active mailbox are handled 
+        if ( activeMailbox && aMailbox.Id() == activeMailbox->GetId().Id() ) // Safety, in list events that only concern active mailbox are handled
             {
             if ( iModel && iModel->Count() && aEvent == TFSEventMailDeleted )
                 {
@@ -1861,7 +1903,7 @@
                 if ( removedEntries && removedEntries->Count() )
                     {
                     RemoveMsgItemsFromListIfFoundL( *removedEntries );
-                    }               
+                    }
                 }
             else if ( iModel && iModel->Count() && aEvent == TFSEventMailChanged )
                 {
@@ -1870,16 +1912,16 @@
                 // Get ID of the folder that this cahnge concerns.
                 TFSMailMsgId* parentFolderId = static_cast<TFSMailMsgId*>( aParam2 );
                 for ( TInt i=0 ; i < entries->Count() ; i++)
-                    {           
+                    {
                     TFSMailMsgId entryId = (*entries)[i];
-                    CFSMailMessage* confirmedMsgPtr(0); 
-                    TRAPD( err, confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), 
+                    CFSMailMessage* confirmedMsgPtr(0);
+                    TRAPD( err, confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(),
                                             *parentFolderId, entryId, EFSMsgDataEnvelope ) );
                     if ( confirmedMsgPtr && err == KErrNone )
                         {
                         CleanupStack::PushL( confirmedMsgPtr );
                         UpdateMsgIconAndBoldingL( confirmedMsgPtr );
-                        CleanupStack::PopAndDestroy( confirmedMsgPtr ); 
+                        CleanupStack::PopAndDestroy( confirmedMsgPtr );
                         }
                     }
                 }
@@ -1891,7 +1933,7 @@
 // RemoveMsgItemsFromListIfFoundL
 // Message removing from list if found. Does not panic or return found status.
 // ---------------------------------------------------------------------------
-//	
+//
 void CFSEmailUiSearchListVisualiser::RemoveMsgItemsFromListIfFoundL( const RArray<TFSMailMsgId>& aEntryIds )
 	{
     FUNC_LOG;
@@ -1905,12 +1947,12 @@
 	        	TInt idx = ItemIndexFromMessageId( entryId );
 	        	if ( idx >= 0 )
 	        	    {
-	    			iSearchList->RemoveL( iSearchListItemArray[idx].iSearchListItemId ); // remove from list			
-	    			iSearchListItemArray.Remove( idx ); // remove from internal array.		 				 	
+	    			iSearchList->RemoveL( iSearchListItemArray[idx].iSearchListItemId ); // remove from list
+	    			iSearchListItemArray.Remove( idx ); // remove from internal array.
 	    	 		iModel->RemoveAndDestroy( idx ); // Remove from model
-	        	    }    	
+	        	    }
 	    		}
-		    }					
+		    }
 		}
 	}
 
@@ -1923,7 +1965,7 @@
 	{
     FUNC_LOG;
 	// Preview pane data update
-	if ( aMsgPtr && ( iListMode == EListControlTypeSingleLinePreviewOn || 
+	if ( aMsgPtr && ( iListMode == EListControlTypeSingleLinePreviewOn ||
 		 iListMode == EListControlTypeDoubleLinePreviewOn ) )
 		{
 		CFSMailMessagePart* textPart = aMsgPtr->PlainTextBodyPartL();
@@ -1935,12 +1977,12 @@
             HBufC* plainTextData16 = HBufC::NewLC( previewSize );
             TPtr textPtr = plainTextData16->Des();
 
-            textPart->GetContentToBufferL( textPtr, 0 ); // Zero is start offset                
-            // Crop out line feed, paragraph break, and tabulator           
+            textPart->GetContentToBufferL( textPtr, 0 ); // Zero is start offset
+            // Crop out line feed, paragraph break, and tabulator
             TFsEmailUiUtility::FilterListItemTextL( textPtr );
             aItemData->SetPreviewPaneDataL( *plainTextData16 );
 
-            CleanupStack::PopAndDestroy( plainTextData16 );                     
+            CleanupStack::PopAndDestroy( plainTextData16 );
 			}
 
 		// Else display message size in preview pane
@@ -1949,7 +1991,7 @@
 			TUint contentSize = aMsgPtr->ContentSize();
 			HBufC* sizeDesc = TFsEmailUiUtility::CreateSizeDescLC( contentSize );
 			HBufC* msgSizeText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_PREV_PANE_MSG_SIZE, *sizeDesc );
-			aItemData->SetPreviewPaneDataL( *msgSizeText ); 				
+			aItemData->SetPreviewPaneDataL( *msgSizeText );
 			CleanupStack::PopAndDestroy( msgSizeText );
 			CleanupStack::PopAndDestroy( sizeDesc );
 			}
@@ -1965,10 +2007,11 @@
 	HBufC* finalText = HBufC::NewLC( searchText->Length() + iLatestSearchText->Length() + 4 );
 	finalText->Des().Append( *searchText );
 	finalText->Des().Append( KSpace );
-	finalText->Des().Append( *iLatestSearchText );			
-	iBarTextVisual->SetTextL( *finalText );		
+	finalText->Des().Append( *iLatestSearchText );
+	iBarTextVisual->SetTextL( *finalText );
 	CleanupStack::PopAndDestroy( finalText );
-	CleanupStack::PopAndDestroy( searchText );	
+	CleanupStack::PopAndDestroy( searchText );
+	iRequiredSearchPriority = KStandardSearchPriority; //<cmail> return back
 	}
 
 
@@ -1977,9 +2020,9 @@
     FUNC_LOG;
 	if ( iSearchList->Count() )
 		{
-		CFSEmailUiMailListModelItem* selectedItem = 
+		CFSEmailUiMailListModelItem* selectedItem =
 	 		static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ));
-	 		
+
 	 	TBool wasRead = selectedItem->MessagePtr().IsFlagSet( EFSMsgFlag_Read );
 	 	if ( (wasRead && !aRead) || (!wasRead && aRead) )
 	 	    {
@@ -2001,22 +2044,22 @@
     		UpdateMsgIconAndBoldingL( HighlightedIndex() );
 	 	    }
 		}
-	} 
-	
+	}
+
 void CFSEmailUiSearchListVisualiser::CheckAndUpdateFocusedMessageL()
 	{
     FUNC_LOG;
 	if ( iModel && iModel->Count() ) // Needed safety check
 		{
 		TInt highlightedIndex = HighlightedIndex();
-		CFSEmailUiMailListModelItem* selectedItem = 
-	 		static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( highlightedIndex ));	
+		CFSEmailUiMailListModelItem* selectedItem =
+	 		static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( highlightedIndex ));
 		if ( selectedItem->ModelItemType() == ETypeMailItem )
 			{
-			CFSMailMessage* msgPtr = &selectedItem->MessagePtr();		
+			CFSMailMessage* msgPtr = &selectedItem->MessagePtr();
 			if ( msgPtr )
 				{
-				CFSMailFolder* folderPtr = 
+				CFSMailFolder* folderPtr =
 				    iAppUi.GetMailClient()->GetFolderByUidL( iAppUi.GetActiveMailboxId(), msgPtr->GetFolderId() );
 				CleanupStack::PushL( folderPtr );
 
@@ -2024,28 +2067,28 @@
 	    			{
 	    			// Pointer is not valid anymore, msg has been delete,
 	    			// so it must be removed from the search list
-	    			RemoveFocusedFromListL();    			
+	    			RemoveFocusedFromListL();
 	    			}
-	    		else 
+	    		else
 	    			{
 	    			CFSMailMessage* confirmedMsgPtr(0);
-	    			TRAPD( err, confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), 
+	    			TRAPD( err, confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(),
 	    										folderPtr->GetFolderId(), msgPtr->GetMessageId(), EFSMsgDataEnvelope ) );
 	    			if ( confirmedMsgPtr && err == KErrNone)
 	    				{
 	    				CleanupStack::PushL( confirmedMsgPtr );
 	    				UpdateMsgIconAndBoldingL( confirmedMsgPtr );
-	    				CleanupStack::PopAndDestroy( confirmedMsgPtr );	
+	    				CleanupStack::PopAndDestroy( confirmedMsgPtr );
 	    				}
 	    			else
 	    				{
-	    				RemoveFocusedFromListL();	
+	    				RemoveFocusedFromListL();
 	    				}
 	    			}
-	    			
+
 	    		CleanupStack::PopAndDestroy( folderPtr );
 				}
-			}		
+			}
 		}
 	}
 
@@ -2055,10 +2098,10 @@
 	iMsgDataCouldBeChanged = ETrue;
 	SSearchListItem item;
 	item.iSearchListItemId = iSearchList->FocusedItem();
-	TInt IndexToBeDestroyed = iSearchListItemArray.Find( item );								
-	iSearchListItemArray.Remove( IndexToBeDestroyed ); // remove from internal array.		 				 	
-	iModel->RemoveAndDestroy( IndexToBeDestroyed ); // Remove from model												
-	iSearchList->RemoveL( iSearchList->FocusedItem() );		// remove from list						
+	TInt IndexToBeDestroyed = iSearchListItemArray.Find( item );
+	iSearchListItemArray.Remove( IndexToBeDestroyed ); // remove from internal array.
+	iModel->RemoveAndDestroy( IndexToBeDestroyed ); // Remove from model
+	iSearchList->RemoveL( iSearchList->FocusedItem() );		// remove from list
 	}
 
 
@@ -2073,7 +2116,7 @@
 			{
 			CFSEmailUiMailListModelItem* item =
 				static_cast<CFSEmailUiMailListModelItem*>( Model()->Item(i) );
-			if ( item && item->ModelItemType()==ETypeMailItem && 
+			if ( item && item->ModelItemType()==ETypeMailItem &&
 				 item->MessagePtr().GetMessageId() == aMsgPtr->GetMessageId() )
 				{
 				// Update all flags
@@ -2083,12 +2126,12 @@
 				    {
     				item->MessagePtr().ResetFlag( prevFlags );
     				item->MessagePtr().SetFlag( newFlags );
-    				
-    				// Save changed flags in internal model array					
+
+    				// Save changed flags in internal model array
     				item->MessagePtr().SaveMessageL();
     				iMsgDataCouldBeChanged = ETrue;
 				    }
-				
+
 				// Update the list item graphics
 				UpdateMsgIconAndBoldingL( i );
 				break;
@@ -2108,18 +2151,18 @@
 	    if ( item && item->ModelItemType()==ETypeMailItem )
 		    {
 		    CFSMailMessage* msgPtr = &item->MessagePtr();
-		    CAlfTexture* itemTexture = &TFsEmailUiUtility::GetMsgIcon( msgPtr, *iAppUi.FsTextureManager() );	
-		    CFsTreePlainTwoLineItemData* itemData = 
+		    CAlfTexture* itemTexture = &TFsEmailUiUtility::GetMsgIcon( msgPtr, *iAppUi.FsTextureManager() );
+		    CFsTreePlainTwoLineItemData* itemData =
                 static_cast<CFsTreePlainTwoLineItemData*>( iSearchListItemArray[aListIndex].iTreeItemData );
-		    CFsTreePlainTwoLineItemVisualizer* itemVis = 
-                static_cast<CFsTreePlainTwoLineItemVisualizer*>( iSearchListItemArray[aListIndex].iTreeItemVisualiser );			
-		    itemData->SetIcon( *itemTexture );		
+		    CFsTreePlainTwoLineItemVisualizer* itemVis =
+                static_cast<CFsTreePlainTwoLineItemVisualizer*>( iSearchListItemArray[aListIndex].iTreeItemVisualiser );
+		    itemData->SetIcon( *itemTexture );
 		    if ( msgPtr->IsFlagSet( EFSMsgFlag_Read ) )
-			    {			
+			    {
 			    itemVis->SetTextBold( EFalse );
 			    }
 		    else
-			   {	
+			   {
 			   itemVis->SetTextBold( ETrue );
 			   }
 		    // Set follow up flag icon correctly
@@ -2128,29 +2171,29 @@
 			    if ( msgPtr->IsFlagSet( EFSMsgFlag_FollowUp ) )
 				    {
 			 	    itemData->SetFlagIcon( iAppUi.FsTextureManager()->TextureByIndex( EFollowUpFlagList ) );
-				    itemVis->SetFlagIconVisible( ETrue );		 		
+				    itemVis->SetFlagIconVisible( ETrue );
 				    }
 			    else if ( msgPtr->IsFlagSet( EFSMsgFlag_FollowUpComplete ) )
 				    {
 			 	    itemData->SetFlagIcon( iAppUi.FsTextureManager()->TextureByIndex( EFollowUpFlagCompleteList ) );
-				    itemVis->SetFlagIconVisible( ETrue );				 		
+				    itemVis->SetFlagIconVisible( ETrue );
 				    }
 			    else
 				    {
-		 	        itemVis->SetFlagIconVisible( EFalse );			
-				    }		
+		 	        itemVis->SetFlagIconVisible( EFalse );
+				    }
 			    }
 		    else
 		        {
 		        itemVis->SetFlagIconVisible( EFalse );
-		        }		    
+		        }
 		    iSearchTreeListVisualizer->UpdateItemL( iSearchListItemArray[aListIndex].iSearchListItemId );
 		    }
     	}
     }
-    
+
 
-// Delete messages 
+// Delete messages
 void CFSEmailUiSearchListVisualiser::DeleteFocusedMessageL()
 	{
     FUNC_LOG;
@@ -2179,32 +2222,32 @@
                okToDelete = TFsEmailUiUtility::ShowConfirmationQueryL( queryTextId, *msgSubject );
                }
             CleanupStack::PopAndDestroy( msgSubject );
-			
+
 			if ( okToDelete )
  				{
  				iMsgDataCouldBeChanged = ETrue; // Refresh
  				// Delete message from framework, and perform internal housekeeping
- 				TFSMailMsgId msgId = messagePtr.GetMessageId();					
+ 				TFSMailMsgId msgId = messagePtr.GetMessageId();
  				RArray<TFSMailMsgId> msgIds;
- 				msgIds.Append( msgId ); 			
+ 				msgIds.Append( msgId );
 				TFSMailMsgId folderId = messagePtr.GetFolderId();
-				TFSMailMsgId mailBox = iAppUi.GetActiveMailbox()->GetId(); 
-				iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );			
-	 			msgIds.Reset();						
+				TFSMailMsgId mailBox = iAppUi.GetActiveMailbox()->GetId();
+				iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );
+	 			msgIds.Reset();
 				SSearchListItem item;
 				item.iSearchListItemId = iSearchList->FocusedItem();
-				TInt IndexToBeDestroyed = iSearchListItemArray.Find( item );								
-				iSearchListItemArray.Remove( IndexToBeDestroyed ); // remove from internal array.		 				 	
-		 		iModel->RemoveAndDestroy( IndexToBeDestroyed ); // Remove from model												
-				iSearchList->RemoveL( iSearchList->FocusedItem() );		// remove from list			
-				}					
+				TInt IndexToBeDestroyed = iSearchListItemArray.Find( item );
+				iSearchListItemArray.Remove( IndexToBeDestroyed ); // remove from internal array.
+		 		iModel->RemoveAndDestroy( IndexToBeDestroyed ); // Remove from model
+				iSearchList->RemoveL( iSearchList->FocusedItem() );		// remove from list
+				}
 			}
-		}			
+		}
 	}
 
 
 // Navigation functions, used mainly from viewer
-TBool CFSEmailUiSearchListVisualiser::IsNextMsgAvailable( TFSMailMsgId aCurrentMsgId, 
+TBool CFSEmailUiSearchListVisualiser::IsNextMsgAvailable( TFSMailMsgId aCurrentMsgId,
 														  TFSMailMsgId& aFoundNextMsgId,
 														  TFSMailMsgId& aFoundNextMsgFolderId ) const
 	{
@@ -2219,26 +2262,26 @@
 	        {
 	        ret = ETrue;
 	        aFoundNextMsgId = MsgIdFromIndex(nextIdx);
-	        CFSEmailUiMailListModelItem* item = 
+	        CFSEmailUiMailListModelItem* item =
     			static_cast<CFSEmailUiMailListModelItem*>(iModel->Item( nextIdx ));
     		if ( item->ModelItemType() == ETypeMailItem )
     	  	  {
     	 	   aFoundNextMsgFolderId = item->MessagePtr().GetFolderId();
-    	 	   }	        
+    	 	   }
 	        }
 	    }
-		
+
 	return ret;
 	}
 
 
-TBool CFSEmailUiSearchListVisualiser::IsPreviousMsgAvailable( TFSMailMsgId aCurrentMsgId, 
+TBool CFSEmailUiSearchListVisualiser::IsPreviousMsgAvailable( TFSMailMsgId aCurrentMsgId,
 														  	  TFSMailMsgId& aFoundPreviousMsgId,
 														  	  TFSMailMsgId& aFoundPrevMsgFolderId ) const
 	{
     FUNC_LOG;
 	TBool ret(EFalse);
-	
+
 	TInt curIdx = ItemIndexFromMessageId( aCurrentMsgId );
 	if ( curIdx >= 0 )
 	    {
@@ -2247,15 +2290,15 @@
 	        {
 	        ret = ETrue;
 	        aFoundPreviousMsgId = MsgIdFromIndex(prevIdx);
-	     	CFSEmailUiMailListModelItem* item = 
+	     	CFSEmailUiMailListModelItem* item =
     			static_cast<CFSEmailUiMailListModelItem*>(iModel->Item( prevIdx ));
     		if ( item->ModelItemType() == ETypeMailItem )
     	  	  {
     	 	   aFoundPrevMsgFolderId = item->MessagePtr().GetFolderId();
-    	 	   }   
+    	 	   }
 	        }
 	    }
-				
+
     return ret;
 	}
 
@@ -2263,10 +2306,10 @@
 	{
     FUNC_LOG;
 	TInt ret(KErrNotFound);
-	
+
 	TInt curIdx = ItemIndexFromMessageId( aCurrentMsgId );
 	TInt nextIdx = NextMessageIndex( curIdx );
-	
+
 	if ( curIdx >= 0 && nextIdx >= 0 )
 	    {
 	    // Focus the new message
@@ -2278,7 +2321,7 @@
 	if ( ret == KErrNone )
 		{
 		OpenHighlightedMailL();
-		}		
+		}
 	return ret;
 	}
 
@@ -2286,10 +2329,10 @@
 	{
     FUNC_LOG;
 	TInt ret(KErrNotFound);
-	
+
 	TInt curIdx = ItemIndexFromMessageId( aCurrentMsgId );
 	TInt prevIdx = PreviousMessageIndex( curIdx );
-	
+
 	if ( curIdx >= 0 && prevIdx >= 0 )
 	    {
 	    // Focus the new message
@@ -2298,33 +2341,33 @@
         aFoundPreviousMsgId = MsgIdFromIndex( prevIdx );
 	    ret = KErrNone;
 	    }
-	
+
 	if ( ret == KErrNone )
 		{
 		OpenHighlightedMailL();
-		}		
+		}
 	return ret;
 	}
 
 TInt CFSEmailUiSearchListVisualiser::MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId )
 	{
 	FUNC_LOG;
-	TInt ret(KErrNotFound);	
-	
-	TInt idx = ItemIndexFromMessageId( aFoundPreviousMsgId );	
+	TInt ret(KErrNotFound);
+
+	TInt idx = ItemIndexFromMessageId( aFoundPreviousMsgId );
 	if ( idx >= 0 )
-		{		
+		{
 		// Focus the previous message
 		iSearchTreeListVisualizer->SetFocusedItemL( iSearchListItemArray[idx].iSearchListItemId );
 		ChangeReadStatusOfHighlightedL( ETrue );
-		ret = KErrNone;		
+		ret = KErrNone;
 		}
 
 	if ( ret == KErrNone )
 		{
 		OpenHighlightedMailL();
 		}
-	
+
 	return ret;
 	}
 
@@ -2335,11 +2378,11 @@
 	TFSMailMsgId ret;
  	if ( iSearchList->Count() && iModel )
 		{
-	  	CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));    
+	  	CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
 		if ( item && item->ModelItemType() == ETypeMailItem )
 			{
 			ret = item->MessagePtr().GetFolderId();
-			}			
+			}
 		}
 	return ret;
 	}
@@ -2350,11 +2393,11 @@
 	TFSMailMsgId ret;
 	if ( iSearchList->Count() && iModel )
 		{
-	  	CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));    
+	  	CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
 		if ( item && item->ModelItemType() == ETypeMailItem )
 			{
 			ret = item->MessagePtr().GetMessageId();
-			}		
+			}
 		}
 	return ret;
 	}
@@ -2366,26 +2409,28 @@
 // From MFsTreeListObserver
 // ---------------------------------------------------------------------------
 //
-void CFSEmailUiSearchListVisualiser::TreeListEventL( const TFsTreeListEvent aEvent, const TFsTreeItemId /*aId*/ )
+void CFSEmailUiSearchListVisualiser::TreeListEventL( const TFsTreeListEvent aEvent,
+                                                     const TFsTreeItemId /*aId*/,
+                                                     const TPoint& aPoint )
     {
     FUNC_LOG;
-    
+
     switch(aEvent)
         {
         case MFsTreeListObserver::EFsTreeListItemTouchAction:
-            DoHandleActionL(); 
-            break; 
+            DoHandleActionL();
+            break;
         case MFsTreeListObserver::EFsTreeListItemTouchLongTap:
             if ( iSearchList->Count() )
-                 {
-                 LaunchActionMenuL();                       
-                 }                
-            break; 
+                {
+                LaunchStylusPopupMenuL( aPoint );
+                }
+            break;
         case MFsTreeListObserver::EFsTreeListItemWillGetFocused:
             {
-            SetMskL(); 
+            SetMskL();
             break;
-            }            
+            }
         case MFsTreeListObserver::EFsFocusVisibilityChange:
         	{
         	iAppUi.SetFocusVisibility( EFalse );
@@ -2394,8 +2439,8 @@
         case MFsTreeListObserver::EFsTreeListItemTouchFocused:
         default:
             //Just ignore rest of events
-            break;             
-        }                   
+            break;
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -2405,27 +2450,27 @@
 void CFSEmailUiSearchListVisualiser::DoHandleActionL()
     {
     FUNC_LOG;
-    TInt modelCount = 0; 
-    
+    TInt modelCount = 0;
+
     if ( iModel )
         {
-        modelCount = iModel->Count();               
+        modelCount = iModel->Count();
         }
     if ( modelCount ) // Safety check
         {
-        CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));    
+        CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));
         if ( item && item->ModelItemType() == ETypeMailItem )
             {
             CFSMailMessage* messagePtr = &item->MessagePtr();
             if ( messagePtr )
                 {
-                OpenHighlightedMailL();                         
+                OpenHighlightedMailL();
                 }
             }
-        }    
+        }
     }
 
-//</cmail> 
+//</cmail>
 
 // ---------------------------------------------------------------------------
 // From MFSEmailUiContactHandlerObserver
@@ -2437,6 +2482,7 @@
     TContactHandlerCmd /*aCmd*/, const RPointerArray<CFSEmailUiClsItem>& /*aContacts*/ )
     {
     FUNC_LOG;
+    iRequiredSearchPriority = KStandardSearchPriority; //<cmail> return back
     }
 
 // ---------------------------------------------------------------------------
@@ -2448,9 +2494,10 @@
     TContactHandlerCmd /*aCmd*/, TInt /*aError*/ )
     {
     FUNC_LOG;
+    iRequiredSearchPriority = KStandardSearchPriority; //<cmail> return back
     }
 
-void CFSEmailUiSearchListVisualiser::CallToSenderL()
+TBool CFSEmailUiSearchListVisualiser::CallToSenderL()
 	{
     FUNC_LOG;
 	CFSEmailUiMailListModelItem* item =
@@ -2462,22 +2509,25 @@
 		TDesC* emailAddress(0);
 		if ( fromAddress )
 			{
-			emailAddress = &fromAddress->GetEmailAddress();		
+			emailAddress = &fromAddress->GetEmailAddress();
 			}
 		if ( emailAddress && emailAddress->Length() )
 			{
 			CFsDelayedLoader::InstanceL()->GetContactHandlerL()->
 				FindAndCallToContactByEmailL( *emailAddress,
-					iAppUi.GetActiveMailbox(), this, ETrue );									
+					iAppUi.GetActiveMailbox(), this, ETrue );
+                   iRequiredSearchPriority = KCallingSearchPriority; //decrease priority to enable search for contact
+                   return ETrue; // searching started - consume keyup event
 			}
-		}		
+		}
+  return EFalse; //no calling key up will execute Call app
 	}
 
 
 // ---------------------------------------------------------------------------
 // Logic for changing msk
 // ---------------------------------------------------------------------------
-// 
+//
 void CFSEmailUiSearchListVisualiser::SetMskL()
 	{
     FUNC_LOG;
@@ -2485,217 +2535,15 @@
 	    {
 	    if ( iSearchList && iSearchList->Count() )
 	        {
-	        ChangeMskCommandL( R_FSE_QTN_MSK_OPEN );    
+	        ChangeMskCommandL( R_FSE_QTN_MSK_OPEN );
 	        }
 	    else
 	        {
-	        ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );           
+	        ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
 	        }
 	    }
 	}
 
-
-// ---------------------------------------------------------------------------
-// LaunchActionMenuL
-// Function launches action menu based on the highlighted or marked messages
-// ---------------------------------------------------------------------------
-//
-void CFSEmailUiSearchListVisualiser::LaunchActionMenuL()
-    {
-    FUNC_LOG;
-    if ( iModel && iModel->Count() )
-        {
-        // Remove old items from action menu
-        CFSEmailUiActionMenu::RemoveAllL();
-        // Construct item list
-        RFsEActionMenuIdList itemList;
-        CleanupClosePushL( itemList );
-        
-        CFSEmailUiMailListModelItem* item = dynamic_cast<CFSEmailUiMailListModelItem*>(iModel->Item(HighlightedIndex()));    
-        // Right click action menu for calendar events
-        if ( item && item->ModelItemType() == ETypeMailItem && 
-              item->MessagePtr().IsFlagSet( EFSMsgFlag_CalendarMsg ) ) 
-             {
-             TESMRMeetingRequestMethod mrMethod( EESMRMeetingRequestMethodUnknown );
-             if ( iAppUi.MrViewerInstanceL() )
-                 {
-                 // Search must be stopped, otherwise resolve will lead to crash
-                 if ( iSearchOngoing )
-                      {
-                      StopSearchL();
-                      }
-                 mrMethod = iAppUi.MrViewerInstanceL()->ResolveMeetingRequestMethodL( item->MessagePtr() );
-                 }
-             switch ( mrMethod )
-                 {
-                 case EESMRMeetingRequestMethodRequest:
-                     itemList.AppendL( FsEActionMenuAccept );
-                     itemList.AppendL( FsEActionMenuTentative );
-                     itemList.AppendL( FsEActionMenuDecline );                      
-                     break;
-                 case EESMRMeetingRequestMethodCancellation:
-                     {
-                     TBool supportsRemove = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaRemoveFromCalendar );
-                     if( supportsRemove )
-                         {
-                         itemList.AppendL( FsEActionMenuRemoveFormCal );                                          
-                         }
-                     break;
-                     }
-                 default:
-                 case EESMRMeetingRequestMethodUnknown:
-                 case EESMRMeetingRequestMethodResponse:
-                     itemList.AppendL( FsEActionMenuOpen);
-                     break;
-                 }             
-             }
-        // Right click action menu for normal mail items
-        else
-             {
-             itemList.AppendL( FsEActionMenuReply );
-            //Get # of recipients
-            TInt numRecipients(0);
-            CFSMailMessage* messagePtr = &item->MessagePtr();
-            if ( messagePtr )
-                {
-                numRecipients =TFsEmailUiUtility::CountRecepients( messagePtr );
-                if ( numRecipients == 1 )
-                    {
-                    //check if the malbox ownmailaddress is same as the recipients email address. If not, then assume that the
-                    //email is a distribution list and we need to inc num of Recipients so that "Reply ALL" option appears in UI.
-                    if ( messagePtr->GetToRecipients().Count() )
-                        {
-                        if ( iAppUi.GetActiveMailbox()->OwnMailAddress().GetEmailAddress().Compare(messagePtr->GetToRecipients()[0]->GetEmailAddress()) )
-                            {
-                            numRecipients++;
-                            }
-                        }
-                    if ( messagePtr->GetCCRecipients().Count() )
-                        {
-                        if ( iAppUi.GetActiveMailbox()->OwnMailAddress().GetEmailAddress().Compare(messagePtr->GetCCRecipients()[0]->GetEmailAddress()) )
-                            {
-                            numRecipients++;
-                            }
-                        }
-                    if ( messagePtr->GetBCCRecipients().Count() )
-                        {
-                        if ( iAppUi.GetActiveMailbox()->OwnMailAddress().GetEmailAddress().Compare(messagePtr->GetBCCRecipients()[0]->GetEmailAddress()) )
-                            {
-                            numRecipients++;
-                            }
-                        }                
-                    }
-                
-                }
-              
-             if ( numRecipients > 1 )
-                 {
-                 itemList.AppendL( FsEActionMenuReplyAll );
-                 }          
-             itemList.AppendL( FsEActionMenuForward );            
-             }  
-        // Add mark as read/unread options
-        if ( item->MessagePtr().IsFlagSet(EFSMsgFlag_Read) )
-            {
-            itemList.AppendL( FsEActionMenuMarkUnread );
-            }
-        else 
-            {
-            itemList.AppendL( FsEActionMenuMarkRead );
-            }           
-        itemList.AppendL( FsEActionMenuDelete );     
-        
-// <cmail> Touch
-        TActionMenuCustomItemId itemId = CFSEmailUiActionMenu::ExecuteL( itemList, EFscCustom, 0, this );
-// </cmail>
-        CleanupStack::PopAndDestroy( &itemList );
-        HandleActionMenuCommandL( itemId ); 
-        }
-    }
-
-
-// <cmail>
-// ---------------------------------------------------------------------------
-// ActionMenuPosition
-// ---------------------------------------------------------------------------
-//
-TPoint CFSEmailUiSearchListVisualiser::ActionMenuPosition()
-    {
-    TAlfRealRect focusRect;
-    TFsTreeItemId listItemId = iSearchList->FocusedItem();
-    iSearchList->GetItemDisplayRectTarget(listItemId, focusRect);
-    return focusRect.iTl;
-    }
-// </cmail>
-
-
-// ---------------------------------------------------------------------------
-// HandleActionMenuCommandL
-// Action menu command callback handler
-// ---------------------------------------------------------------------------
-//
-void CFSEmailUiSearchListVisualiser::HandleActionMenuCommandL( TActionMenuCustomItemId itemId )
-    {
-    FUNC_LOG;
-    // Map each Action Menu ID to correcponding command ID.
-    TInt commandId = KErrNotFound;
-    
-    switch( itemId )
-        {
-        case FsEActionMenuOpenCalendarEvent:
-        case FsEActionMenuOpen:
-            commandId = EFsEmailUiCmdOpen;
-            break;
-        case FsEActionMenuAccept:
-            commandId = EFsEmailUiCmdCalActionsAccept;
-            break;
-        case FsEActionMenuTentative:
-            commandId = EFsEmailUiCmdCalActionsTentative;
-            break;
-        case FsEActionMenuDecline:
-            commandId = EFsEmailUiCmdCalActionsDecline;
-            break;
-        case FsEActionMenuRemoveFormCal:
-            commandId = EFsEmailUiCmdCalRemoveFromCalendar;
-            break;
-        case FsEActionMenuMarkRead:
-            commandId = EFsEmailUiCmdMarkAsRead;
-            break;
-        case FsEActionMenuMarkUnread:
-            commandId = EFsEmailUiCmdMarkAsUnread;
-            break;          
-        case FsEActionMenuDelete:
-            commandId = EFsEmailUiCmdActionsDelete;
-            break;                          
-        case FsEActionMenuReply:
-            commandId = EFsEmailUiCmdActionsReply;
-            break;
-        case FsEActionMenuReplyAll:
-            commandId = EFsEmailUiCmdActionsReplyAll;
-            break;
-        case FsEActionMenuForward:
-            commandId = EFsEmailUiCmdActionsForward;
-            break;
-        case FsEActionMenuMove:
-            commandId = EFsEmailUiCmdActionsMoveMessage;
-            break;
-        case FsEActionMenuMoveToDrafts:
-            commandId = EFsEmailUiCmdActionsMoveToDrafts;
-            break;
-        case FsEActionMenuDismissed:
-            commandId = KErrCancel;
-            break;
-        default:
-            __ASSERT_DEBUG( EFalse, Panic( EFSEmailUiUnexpectedValue ) );
-            break;
-        }
-    
-    if ( commandId >= 0 )
-        {
-        HandleCommandL( commandId );
-        }
-    }
-
 //<cmail>
 // ---------------------------------------------------------------------------
 // CFSEmailUiSearchListVisualiser::SetHeaderTextAttributesL()
@@ -2706,7 +2554,7 @@
 //
 void CFSEmailUiSearchListVisualiser::SetHeaderAttributesL()
 	{
-	// Set bar text color/style from skin	
+	// Set bar text color/style from skin
 	iBarTextVisual->SetTextStyle( iAppUi.LayoutHandler()->
 	        FSTextStyleFromLayoutL( AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_t1( 0 ) ).Id() );
 	iBarTextVisual->SetColor( iAppUi.LayoutHandler()->
@@ -2727,5 +2575,46 @@
 
 
 
+// ---------------------------------------------------------------------------
+// LaunchStylusPopupMenuL
+// Function launches avkon stylus popup menu based for the tapped item
+// ---------------------------------------------------------------------------
+//
+void CFSEmailUiSearchListVisualiser::LaunchStylusPopupMenuL( const TPoint& aPoint )
+    {
+    // Verify that the item's type is correct
+    CFSEmailUiMailListModelItem* item =
+        static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( HighlightedIndex() ) );
+    if ( item && ( item->ModelItemType() == ETypeMailItem ) )
+        {
+        // Add mark as read / unread options
+        const CFSMailMessage& message = item->MessagePtr();
+
+        TBool messageRead( message.IsFlagSet( EFSMsgFlag_Read ) );
+        iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !messageRead );
+        iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdMarkAsRead, messageRead );
+
+        // Set the position for the popup
+        iStylusPopUpMenu->SetPosition( aPoint );
+
+        // Display the popup and set the flag to indicate that the menu was
+        // launched so that list focus stays visible.
+        iStylusPopUpMenu->ShowMenu();
+        iStylusPopUpMenuVisible = ETrue;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// ClientRequiredSearchPriority
+// the email searching priority may be decreased to enable searching for contacts
+// ---------------------------------------------------------------------------
+//
+void CFSEmailUiSearchListVisualiser::ClientRequiredSearchPriority( TInt *apRequiredSearchPriority )
+    {
+    FUNC_LOG;
+    if (iRequiredSearchPriority != (*apRequiredSearchPriority))
+    *apRequiredSearchPriority = iRequiredSearchPriority; 
+    return;
+    }
 
 // End of file
--- a/emailuis/emailui/src/FreestyleEmailUiSendAttachmentsListModel.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiSendAttachmentsListModel.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -929,7 +929,8 @@
 
 void CFSEmailUiSendAttachmentsListModel::TreeListEventL( 
     const TFsTreeListEvent aEvent, 
-    const TFsTreeItemId /*aId*/ )
+    const TFsTreeItemId /*aId*/,
+    const TPoint& /*aPoint*/ )
 	{
     FUNC_LOG;
     
--- a/emailuis/emailui/src/FreestyleEmailUiSettingsList.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiSettingsList.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -29,14 +29,14 @@
 #include <aknlistquerydialog.h>
 #include <e32cmn.h>
 #include <FreestyleEmailUi.rsg>
-//<cmail>
+
 #include "CFSMailClient.h"
 #include "CFSMailBox.h"
 #include <AknGlobalConfirmationQuery.h> // confirmation
 #include <freestyleemailui.mbg> // icons
 #include "ESMailSettingsPluginUids.hrh"
 #include "ESMailSettingsPlugin.h"
-//</cmail>
+
 #include <aknnotewrappers.h> // for note
 #include <AknDialog.h> // for settings dialog
 #include <aknsettingitemlist.h> // for settings dialog
@@ -338,6 +338,11 @@
         iListBox = NULL;
         }
 
+    if ( iLongTapDetector )
+    	{
+    	delete iLongTapDetector;
+    	iLongTapDetector = NULL;
+    	}
     }
 
 // ---------------------------------------------------------------------------
@@ -391,7 +396,6 @@
     CleanupStack::PushL( self );
     self->ConstructL( aRect, aParent);
 
-
     return self;
     }
 
@@ -406,7 +410,7 @@
 //
 void CFsEmailSettingsList::ConstructL(
         const TRect& aRect,
-        const CCoeControl* aParent)
+        const CCoeControl* aParent )
     {
     FUNC_LOG;
 
@@ -423,7 +427,6 @@
     InitializeControlsL();
     SetRect( aRect );
     ActivateL();
-
     }
 
 // ---------------------------------------------------------------------------
@@ -658,6 +661,8 @@
     // event listener this class
     iListBox->SetListBoxObserver( this );
 
+    // Construct the long tap detector.
+	iLongTapDetector = CAknLongTapDetector::NewL( this );
     }
 
 
@@ -671,8 +676,31 @@
 
     CCoeControl::HandleResourceChange( aType );
     SetRect( iAvkonViewAppUi->View( SettingsViewId )->ClientRect() );
+    }
 
-    }
+
+// -----------------------------------------------------------------------------
+// CFsEmailSettingsList::HandlePointerEventL()
+// From CCoeControl.
+// -----------------------------------------------------------------------------
+//
+void CFsEmailSettingsList::HandlePointerEventL(
+	const TPointerEvent& aPointerEvent )
+	{
+    // Pass the event to the long tap detector.
+	iLongTapDetector->PointerEventL( aPointerEvent );
+
+	if ( !iLongTapEventConsumed )
+		{
+		// Call HandlePointerEventL() of the base class.
+		CCoeControl::HandlePointerEventL( aPointerEvent );
+		}
+	else
+		{
+		iLongTapEventConsumed = EFalse;
+		}
+	}
+
 
 // ---------------------------------------------------------------------------
 // Draw container contents.
@@ -724,6 +752,37 @@
     return ( iPIMSyncMailboxIndex == -1 ) ? EFalse : ETrue;
     }
 
+
+// -----------------------------------------------------------------------------
+// CFsEmailSettingsList::HandleLongTapEventL()
+// From MAknLongTapDetectorCallBack.
+// -----------------------------------------------------------------------------
+//
+void CFsEmailSettingsList::HandleLongTapEventL(
+	const TPoint& aPenEventLocation,
+	const TPoint& aPenEventScreenLocation )
+	{
+	// Get the item index based on the position of the tap event.
+	TInt itemIndex( 0 );
+	TBool itemSelected =
+		iListBox->View()->XYPosToItemIndex( aPenEventLocation,
+											itemIndex );
+
+	if ( itemSelected && itemIndex >= 0 )
+		{
+		// Update the item index based on the position of the tap event.
+		iListBox->SetCurrentItemIndex( itemIndex );
+
+		if ( SelectedItemIsMailbox() )
+			{
+			iView.DisplayStylusPopUpMenu( aPenEventScreenLocation );
+			}
+		
+		iLongTapEventConsumed = ETrue;
+		}
+	}
+
+
 // ---------------------------------------------------------------------------
 // Create a list box item for plain text
 // ---------------------------------------------------------------------------
@@ -1479,14 +1538,14 @@
     }
 
 // ---------------------------------------------------------------------------
-// RemoveAccount
-// Handle account removal from fs mail client
-// @return void
+// RemoveAccountL()
+// Handle account removal from fs mail client.
 // ---------------------------------------------------------------------------
 //
-void CFsEmailSettingsList::RemoveAccountL()
+TBool CFsEmailSettingsList::RemoveAccountL()
     {
     FUNC_LOG;
+    TBool wasDeleted( EFalse );
 
     // Make sure that FSMailServer is running, so that the mailbox is removed
     // also from MCE. Let's do it already here, so that the server has some
@@ -1496,9 +1555,10 @@
     // if item index is 0 then we are on global settings item
     // this shouldn't be happening, but just in case
     iDeletedIndex = iListBox->CurrentItemIndex();
+
     if ( iDeletedIndex == 0 )
         {
-        return;
+        return EFalse;
         }
 
     // get mailbox
@@ -1531,9 +1591,11 @@
             TFsEmailUiUtility::ToggleEmailIconL(EFalse);
             // delete mailbox and wait event (RequestResponseL)
             iDeleteMailboxId = iMailClient.DeleteMailBoxByUidL( mailBox->GetId(), *this );
+            wasDeleted = ETrue;
             }
         }
     CleanupStack::PopAndDestroy(); // mailBox
+    return wasDeleted;
     }
 
 
@@ -1709,3 +1771,43 @@
         }
     }
 
+
+// ---------------------------------------------------------------------------
+// CFsEmailSettingsList::SelectedItemIsMailbox()
+// Used to check if the currently selected item is a mailbox.
+// ---------------------------------------------------------------------------
+//
+TBool CFsEmailSettingsList::SelectedItemIsMailbox() const
+	{
+    // Check if the current view is the main level and the selected list item
+	// is a mailbox.
+	const TInt index( iListBox->CurrentItemIndex() );
+
+    if ( iCurrentSubView == EFsEmailSettingsMainListView &&
+    	 index > 0 && index <= iMailboxCount )
+    	{
+    	// Is a mailbox.
+    	return ETrue;
+    	}
+
+    // Is something else.
+    return EFalse;
+	}
+
+
+// ---------------------------------------------------------------------------
+// CFsEmailSettingsList::ClearFocus()
+// Removes the focus.
+// ---------------------------------------------------------------------------
+//
+void CFsEmailSettingsList::ClearFocus()
+	{
+	// This is not a nice way to clear the focus but unless some one comes
+	// with a better solution, this will have to do.
+	iListBox->ItemDrawer()->SetFlags( CListItemDrawer::EDisableHighlight );
+	iListBox->View()->Draw();
+	iListBox->ItemDrawer()->ClearFlags( CListItemDrawer::EDisableHighlight );
+	}
+
+
+// End of file. 
--- a/emailuis/emailui/src/FreestyleEmailUiSettingsListView.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiSettingsListView.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2007 - 2009 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -15,7 +15,6 @@
 *
 */
 
-
 // SYSTEM INCLUDES
 #include "emailtrace.h"
 #include <aknViewAppUi.h>
@@ -30,19 +29,15 @@
 #include <akncontext.h>
 #include <akntitle.h>
 #include <FreestyleEmailUi.rsg>
-//<cmail>
 #include <featmgr.h>
-//</cmail>
+#include <aknstyluspopupmenu.h>
 
 #include "CFSMailCommon.h"
 #include "CFSMailBox.h"
 #include "ESMailSettingsPlugin.h"
 #include "ESMailSettingsPluginUids.hrh"
-//</cmail>
 #include <gsfwviewuids.h> // Uids for general settings activation
-// <cmail> 
 #include <csxhelp/cmail.hlp.hrh>
-// </cmail>
 
 // LOCAL INCLUDES
 #include "FreestyleEmailUiUtilities.h"
@@ -61,15 +56,16 @@
 // code that could leave.
 // ---------------------------------------------------------------------------
 //
-CFsEmailSettingsListView::CFsEmailSettingsListView( CAlfControlGroup& aControlGroup, 
-        CFreestyleEmailUiAppUi& aAppUi, CFSMailClient& aMailClient  )
-    : CFsEmailUiViewBase( aControlGroup, aAppUi ), iMailClient( aMailClient )
+CFsEmailSettingsListView::CFsEmailSettingsListView( 
+	CAlfControlGroup& aControlGroup,
+	CFreestyleEmailUiAppUi& aAppUi,
+	CFSMailClient& aMailClient  )
+    : CFsEmailUiViewBase( aControlGroup, aAppUi ),
+      iMailClient( aMailClient ),
+      iMailboxSettings( EFalse )
 	{
     FUNC_LOG;
-
 	iFsEmailSettingsList = NULL;
-	iMailboxSettings = EFalse;
-
 	}
 
 // ---------------------------------------------------------------------------
@@ -79,11 +75,18 @@
 CFsEmailSettingsListView::~CFsEmailSettingsListView()
 	{
     FUNC_LOG;
+
    	if ( iAsyncCallback )
 		{
 		iAsyncCallback->Cancel();
 		delete iAsyncCallback;
 		}
+
+   	if ( iStylusPopUpMenu )
+   		{
+   		delete iStylusPopUpMenu;
+   		iStylusPopUpMenu = NULL;
+   		}
 	}
 
 
@@ -101,7 +104,8 @@
 	{
     FUNC_LOG;
 
-	CFsEmailSettingsListView* self = CFsEmailSettingsListView::NewLC( aMailClient, aAppUi, aControlGroup );
+	CFsEmailSettingsListView* self =
+		CFsEmailSettingsListView::NewLC( aMailClient, aAppUi, aControlGroup );
 	CleanupStack::Pop( self );
 
 	return self;
@@ -122,7 +126,8 @@
     FUNC_LOG;
 
 	CFsEmailSettingsListView* self = 
-	    new ( ELeave ) CFsEmailSettingsListView( aControlGroup, *aAppUi, aMailClient );
+	    new ( ELeave ) CFsEmailSettingsListView(
+	    	aControlGroup, *aAppUi, aMailClient );
 	CleanupStack::PushL( self );
 	self->ConstructL();
 
@@ -130,10 +135,11 @@
 	}
 
 
-/**
- * Second-phase constructor for view.  
- * Initialize contents from resource.
- */ 
+// ---------------------------------------------------------------------------
+// Second-phase constructor for view.  
+// Initialize contents from resource.
+// ---------------------------------------------------------------------------
+//
 void CFsEmailSettingsListView::ConstructL()
 	{
     FUNC_LOG;
@@ -141,16 +147,17 @@
 	BaseConstructL( R_FS_EMAIL_SETTINGS_LIST_VIEW );
 
 	iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
-	iAsyncCallback->Set( TCallBack( DisplayCreateQuery, this ) ); 
-	
+	iAsyncCallback->Set( TCallBack( DisplayCreateQuery, this ) );
 	}
 
 // -----------------------------------------------------------------------------
 // CFsEmailSettingsListView::DisplayCreateQuery
 // -----------------------------------------------------------------------------
+//
 void CFsEmailSettingsListView::StartMailboxAsyncQueryL()
 	{
     FUNC_LOG;
+
 	if ( iAsyncCallback )
 		{
 		iAsyncCallback->CallBack();
@@ -159,12 +166,29 @@
 
 
 // -----------------------------------------------------------------------------
+// CFsEmailSettingsListView::DisplayStylusPopUpMenu()
+// Displays the pop-up menu.
+// -----------------------------------------------------------------------------
+//
+void CFsEmailSettingsListView::DisplayStylusPopUpMenu( const TPoint& aPosition )
+	{
+    if ( iStylusPopUpMenu )
+    	{
+    	iStylusPopUpMenu->SetPosition( aPosition );
+    	iStylusPopUpMenu->ShowMenu();
+    	}
+	}
+
+
+// -----------------------------------------------------------------------------
 // CFsEmailSettingsListView::DisplayCreateQuery
 // -----------------------------------------------------------------------------
+//
 TInt CFsEmailSettingsListView::DisplayCreateQuery( TAny* aViewPtr )
     {
     FUNC_LOG;
-    CFsEmailSettingsListView* self = static_cast<CFsEmailSettingsListView*>( aViewPtr ); 
+    CFsEmailSettingsListView* self =
+		static_cast<CFsEmailSettingsListView*>( aViewPtr ); 
 	TRAPD( err, self->DisplayCreateMailboxNoteIfNeededL() );
     return err;
     }
@@ -172,26 +196,30 @@
 // -----------------------------------------------------------------------------
 // CFsEmailSettingsListView::DisplayCreateQueryL
 // -----------------------------------------------------------------------------
+//
 void CFsEmailSettingsListView::DisplayCreateMailboxNoteIfNeededL()
     {
     FUNC_LOG;
     User::LeaveIfNull( iFsEmailSettingsList );
     iFsEmailSettingsList->DisplayCreateMailboxNoteIfNeededL();
     }
-	
-/**
- * @return The UID for this view
- */
+
+// -----------------------------------------------------------------------------
+// CFsEmailSettingsListView::Id()
+// From CAknView.
+// -----------------------------------------------------------------------------
+//
 TUid CFsEmailSettingsListView::Id() const
 	{
     FUNC_LOG;
 	return SettingsViewId;
 	}
 
-/**
- * Handle a command for this view (override)
- * @param aCommand command id to be handled
- */
+// -----------------------------------------------------------------------------
+// CFsEmailSettingsListView::HandleCommandL()
+// From CAknView.
+// -----------------------------------------------------------------------------
+//
 void CFsEmailSettingsListView::HandleCommandL( TInt aCommand )
 	{
     FUNC_LOG;
@@ -215,6 +243,7 @@
 			    // navigate away from settings
 	            NavigateBackL();
 			    }
+
 			break;
 			}
 		case EAknSoftkeyOpen:	
@@ -225,48 +254,70 @@
 			break;
 			}
 		case EFsEmailUiCmdSettingsAddAccount:
+			{
 			iFsEmailSettingsList->AddAccountL();
 			break;
+			}
 		case EFsEmailUiCmdSettingsRemoveAccount:
+		case EFsEmailUiCmdDeleteSelectedMailbox: // From the pop-up menu.
+			{
 			iFsEmailSettingsList->RemoveAccountL();
-			break;	
+			iFsEmailSettingsList->ClearFocus();
+			break;
+			}
 		case EFsEmailUiCmdHelp:
+			{
 			TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID );
             break;
+			}
 		case EFsEmailUiCmdExit:
+			{
 			AppUi()->HandleCommandL( EEikCmdExit );
 			break;
+			}
 		case EFsEmailUiCmdGoToTop:
+			{
 		    iFsEmailSettingsList->GoToTop();
 		    break;
+			}
 		case EFsEmailUiCmdGoToBottom:
+			{
 		    iFsEmailSettingsList->GoToBottom();
 		    break;
+			}
         case EFsEmailUiCmdPageUp:
+        	{
             iFsEmailSettingsList->PageUp();
             break;
+        	}
         case EFsEmailUiCmdPageDown:
+        	{
             iFsEmailSettingsList->PageDown();
             break;
+        	}
+        case KErrCancel:
+        	{
+        	// The pop-up menu was cancelled.
+        	iFsEmailSettingsList->ClearFocus();
+        	break;
+        	}
 		default:
+			{
 			break;
-		}
+			}
+		} // switch ( aCommand )
 	}
 
-/**
- *	Handles user actions during activation of the view, 
- *	such as initializing the content.
- */
-// <cmail> Toolbar
-/*void CFsEmailSettingsListView::DoActivateL(
-        const TVwsViewId& aPrevViewId,
-        TUid aCustomMessageId,
-        const TDesC8& aCustomMessage )*/
+
+// -----------------------------------------------------------------------------
+// CFsEmailSettingsListView::ChildDoActivateL()
+// From CFsEmailUiViewBase.
+// -----------------------------------------------------------------------------
+//
 void CFsEmailSettingsListView::ChildDoActivateL(
         const TVwsViewId& aPrevViewId,
         TUid aCustomMessageId,
         const TDesC8& aCustomMessage )
-// </cmail> Toolbar
 	{
     FUNC_LOG;
     
@@ -413,13 +464,26 @@
 		}
 	// setup status pane title
     SetupStatusPaneL();
-	
+
+    if( !iStylusPopUpMenu )
+        {
+        // Construct the long tap pop-up menu.
+        TPoint point( 0, 0 );
+        iStylusPopUpMenu = CAknStylusPopUpMenu::NewL( this , point );
+		TResourceReader reader;
+		iCoeEnv->CreateResourceReaderLC( reader,
+			R_STYLUS_POPUP_MENU_LAUNCHER_GRID_VIEW );
+		iStylusPopUpMenu->ConstructFromResourceL( reader );
+		CleanupStack::PopAndDestroy(); // reader
+        }
+
 	// Make a deferred call to show the "create mailbox" query if we opened the main settings list
 	if ( aCustomMessageId.iUid == KMailSettingsOpenMainList ||
 	        aCustomMessageId.iUid == KOpenMailSettingsFromGS )
 	    {
 	    StartMailboxAsyncQueryL();
 	    }
+
 	iAppUi.HideTitlePaneConnectionStatus();
 	}
 
@@ -463,7 +527,7 @@
 
 // ---------------------------------------------------------------------------
 // DynInitMenuPaneL
-// From aknview
+// From CAknView.
 // ---------------------------------------------------------------------------
 //
 void CFsEmailSettingsListView::DynInitMenuPaneL( 
@@ -502,11 +566,11 @@
 	                             CFSEmailUiShortcutBinding::EContextSettings );	
 	}
 
-/**
- * SetupStatusPaneL
- * 
- * 
- */
+// ---------------------------------------------------------------------------
+// SetupStatusPaneL()
+// 
+// ---------------------------------------------------------------------------
+//
 void CFsEmailSettingsListView::SetupStatusPaneL()
 	{
     FUNC_LOG;
@@ -529,9 +593,11 @@
 
 	}
 
-/** 
- * Sets application default title when leaving this view
- */
+// ---------------------------------------------------------------------------
+// CleanupStatusPaneL()
+// Sets application default title when leaving this view
+// ---------------------------------------------------------------------------
+//
 void CFsEmailSettingsListView::CleanupStatusPaneL()
 	{
     FUNC_LOG;
@@ -539,9 +605,12 @@
 	}
 
 
-/** 
- * Handle status pane size change for this view (override)
- */
+// ---------------------------------------------------------------------------
+// HandleStatusPaneSizeChange()
+// From CAknView.
+// Handle status pane size change for this view (override).
+// ---------------------------------------------------------------------------
+//
 void CFsEmailSettingsListView::HandleStatusPaneSizeChange()
 	{
     FUNC_LOG;
@@ -556,3 +625,4 @@
 	}
 
 
+// End of file.
--- a/emailuis/emailui/src/FreestyleEmailUiViewBase.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiViewBase.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -445,8 +445,15 @@
         // Activate control group in case the view was activated when
         // application was being sent to background, and the control group
         // was left inactive.
-        const TInt KActivationDelay = 200; // ms
-        ActivateControlGroup( KActivationDelay );
+        if( iWasActiveControlGroup )
+            {
+            const TInt KActivationDelay = 200; // ms
+            ActivateControlGroup( KActivationDelay );
+            }
+        }
+    else
+        {
+        iWasActiveControlGroup = ControlGroup().AcceptInput();
         }
     }
 
--- a/emailuis/emailui/src/FreestyleMessageHeaderHTML.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleMessageHeaderHTML.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -2,9 +2,9 @@
 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
+* under the terms of the License "Symbian Foundation License v1.0"
 * which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
@@ -32,6 +32,10 @@
 
 _LIT8( KShowDetailIconFileName, "plus.gif");
 _LIT8( KAttachementIconGeneral, "attachment.gif");
+_LIT8( KFollowUpIconFileName, "follow_up.png");
+_LIT8( KFollowUpCompleteIconFileName, "follow_up_complete.png");
+_LIT8( KPriorityHighIconFileName, "todo_high_add.png");
+_LIT8( KPriorityLowIconFileName, "todo_low_add.png");
 
 _LIT8( KHeaderTableName, "header_table");
 _LIT8( KToTableName, "to_table");
@@ -52,44 +56,82 @@
 _LIT8( KBccImageName, "bcc_img");
 _LIT8( KAttachmentImageName, "attachment_img");
 _LIT8( KDetailImageName, "detail_img");
+_LIT8( KFollowUpImageName, "follow_up_img");
+_LIT8( KFollowUpCompleteImageName, "follow_up_complete_img");
+_LIT8( KPriorityHighImageName, "todo_high_add_img");
+_LIT8( KPriorityLowImageName, "todo_low_add_img");
 
 _LIT8( KAttachmentSizeUnit, "kb");
 _LIT8( KSpace8, " ");
 
+_LIT8( KHTMLImgTagId, "<image id=\"" );
+_LIT8( KHTMLImgTagSrcBefore, "\" border=\"0\" src=\"" );
+_LIT8( KHTMLImgTagSrcAfter, "\">" );
+
 _LIT8( KMetaHeader, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" );
 const TInt KMaxEventLength( 256 );
 const TInt KFreestyleMessageHeaderHTMLRightMarginInPx( 10 );
 const TInt KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth( 5 );
 
-EXPORT_C CFreestyleMessageHeaderHTML* CFreestyleMessageHeaderHTML::NewL( CFSMailMessage& aMailMessage, TInt aVisibleWidth   )
+EXPORT_C CFreestyleMessageHeaderHTML* CFreestyleMessageHeaderHTML::NewL( CFSMailMessage& aMailMessage, 
+                                                                         RWriteStream& aWriteStream,
+                                                                         TInt aVisibleWidth,
+                                                                         TInt aScrollPosition,
+                                                                         TBidiText::TDirectionality aDirectionality
+                                                                         )
     {
-    CFreestyleMessageHeaderHTML* self = new (ELeave) CFreestyleMessageHeaderHTML( aMailMessage, aVisibleWidth  );
+    CFreestyleMessageHeaderHTML* self = new (ELeave) CFreestyleMessageHeaderHTML( aMailMessage, aWriteStream, aVisibleWidth, aScrollPosition, aDirectionality);
     self->ConstructL();
     return self;
     }
 
-EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, RWriteStream& aWriteStream, TInt aVisibleWidth   )
+EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, 
+                                                    RWriteStream& aWriteStream, 
+                                                    TInt aVisibleWidth,
+                                                    TInt aScrollPosition,
+                                                    TBidiText::TDirectionality aDirectionality)
     {
-    CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aVisibleWidth   );
+    CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aWriteStream, aVisibleWidth, aScrollPosition, aDirectionality);
     CleanupStack::PushL( headerHtml );
-    headerHtml->ExportL( aWriteStream );
+    headerHtml->ExportL();
     CleanupStack::PopAndDestroy( headerHtml );
     }
 
-EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, RFile& aFile, TInt aVisibleWidth   )
+EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, 
+                                                    RFile& aFile, 
+                                                    TInt aVisibleWidth,
+                                                    TInt aScrollPosition,
+                                                    TBidiText::TDirectionality aDirectionality)
     {
-    CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aVisibleWidth   );
+    RFileWriteStream fwstream;
+    fwstream.Attach( aFile, 0 );
+    CleanupClosePushL( fwstream );
+    
+    CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, fwstream, aVisibleWidth, aScrollPosition, aDirectionality );
     CleanupStack::PushL( headerHtml );
-    headerHtml->ExportL( aFile );
+    headerHtml->ExportL();
     CleanupStack::PopAndDestroy( headerHtml );
+    
+    CleanupStack::PopAndDestroy( &fwstream );
     }
 
-EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, RFs& aFs, const TPath& aFilePath, TInt aVisibleWidth  )
+EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, 
+                                                    RFs& aFs, 
+                                                    const TPath& aFilePath, 
+                                                    TInt aVisibleWidth,
+                                                    TInt aScrollPosition,
+                                                    TBidiText::TDirectionality aDirectionality)
     {
-    CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aVisibleWidth   );
+    RFileWriteStream fwstream;
+    User::LeaveIfError( fwstream.Replace( aFs, aFilePath, EFileStreamText | EFileWrite) );
+    CleanupClosePushL( fwstream );
+    
+    CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, fwstream, aVisibleWidth, aScrollPosition, aDirectionality);
     CleanupStack::PushL( headerHtml );
-    headerHtml->ExportL( aFs, aFilePath );
+    headerHtml->ExportL();
     CleanupStack::PopAndDestroy( headerHtml );
+
+    CleanupStack::PopAndDestroy( &fwstream );    
     }
 
 CFreestyleMessageHeaderHTML::~CFreestyleMessageHeaderHTML()
@@ -97,127 +139,134 @@
     iAttachments.ResetAndDestroy();
     }
 
-EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( RWriteStream& aWriteStream ) const
+EXPORT_C void CFreestyleMessageHeaderHTML::ExportL() const
     {
-    HTMLStartL( aWriteStream );
-    ExportHTMLHeaderL( aWriteStream );
-    ExportHTMLBodyL( aWriteStream );
-    HTMLEndL( aWriteStream );
+    HTMLStartL();
+    ExportHTMLHeaderL();
+    ExportHTMLBodyL();
+    HTMLEndL();
     }
 
-EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( RFile& aFile ) const
+CFreestyleMessageHeaderHTML::CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage,  
+                                                          RWriteStream& aWriteStream,
+                                                          TInt aVisibleWidth,
+                                                          TInt aScrollPosition,
+                                                          TBidiText::TDirectionality aDirectionality )
+    : iMailMessage( aMailMessage ),
+    iWriteStream( aWriteStream ),
+    iVisibleWidth( aVisibleWidth - KFreestyleMessageHeaderHTMLRightMarginInPx ),
+    iScrollPosition(aScrollPosition),
+    iDirectionality( aDirectionality )
     {
-    RFileWriteStream fwstream;
-    fwstream.Attach( aFile, 0 );
-    CleanupClosePushL( fwstream );
-    ExportL( fwstream );
-    CleanupStack::PopAndDestroy( &fwstream );
     }
 
-EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( RFs& aFs, const TPath& aFilePath) const
-    {
-    RFileWriteStream fwstream;
-    User::LeaveIfError( fwstream.Replace( aFs, aFilePath, EFileStreamText | EFileWrite) );
-    CleanupClosePushL( fwstream );
-    ExportL( fwstream );
-    CleanupStack::PopAndDestroy( &fwstream );
-    }
-
-CFreestyleMessageHeaderHTML::CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage,  TInt aVisibleWidth  )
-    : iMailMessage( aMailMessage )
-    {
-    iVisibleWidth = aVisibleWidth - KFreestyleMessageHeaderHTMLRightMarginInPx;
-  	}
-  	
 void CFreestyleMessageHeaderHTML::ConstructL()
     {
     iMailMessage.AttachmentListL( iAttachments );
     }
 
-void CFreestyleMessageHeaderHTML::HTMLStartL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::HTMLStartL() const
     {
-    aWriteStream.WriteL(_L8("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n"));
-    aWriteStream.CommitL();
+    iWriteStream.WriteL(_L8("<html"));
+    if ( iDirectionality == TBidiText::ERightToLeft )
+        {
+        iWriteStream.WriteL(_L8(" dir=\"rtl\""));
+        }    
+    iWriteStream.WriteL(_L8(" xmlns=\"http://www.w3.org/1999/xhtml\">\n"));
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::HTMLEndL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::HTMLEndL() const
     {
-    aWriteStream.WriteL(_L8("</html>\n"));
-    aWriteStream.CommitL();
+    iWriteStream.WriteL(_L8("</html>\n"));
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::ExportHTMLHeaderL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::ExportHTMLHeaderL() const
     {
-    HTMLHeaderStartL( aWriteStream );
-    HTMLMetaL( aWriteStream );
-    aWriteStream.WriteL(_L8("<title>Email Header</title>\n"));
-    AddJavascriptL( aWriteStream );
-    AddStyleSheetL( aWriteStream );
-    HTMLHeaderEndL( aWriteStream );
+    HTMLHeaderStartL();
+    HTMLMetaL();
+    iWriteStream.WriteL( _L8("<title>Email Header</title>\n") );
+    AddJavascriptL();
+    AddStyleSheetL();
+    HTMLHeaderEndL();
     }
 
-void CFreestyleMessageHeaderHTML::HTMLHeaderStartL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::HTMLHeaderStartL() const
     {
-    aWriteStream.WriteL(_L8("<head>"));
-    aWriteStream.CommitL();
+    iWriteStream.WriteL(_L8("<head>"));
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::HTMLMetaL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::HTMLMetaL() const
     {
     // Html file representing email header fields, is always constructed locally
     // in the phone, and it is always of charset UTF-8 irrespective of what
     // the email html-format body is
-    aWriteStream.WriteL( KMetaHeader );
-    aWriteStream.CommitL();
+    iWriteStream.WriteL( KMetaHeader );
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::HTMLHeaderEndL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::HTMLHeaderEndL() const
     {
-    aWriteStream.WriteL(_L8("</head>\n"));
-    aWriteStream.CommitL();
+    iWriteStream.WriteL(_L8("</head>\n"));
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::ExportHTMLBodyL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::ExportHTMLBodyL() const
     {
-    HTMLBodyStartL( aWriteStream );
-    ExportInitialTableL( aWriteStream );
-    StartHeaderTableL( aWriteStream, KHeaderTableName );
-    ExportFromL( aWriteStream );
-    ExportToL( aWriteStream );
-    ExportCcL( aWriteStream );
-    ExportBccL( aWriteStream );
-    ExportSentTimeL( aWriteStream );
-    ExportSubjectL( aWriteStream );
-    EndHeaderTableL( aWriteStream );
-    ExportAttachmentsL( aWriteStream );
-    HTMLBodyEndL( aWriteStream );
+    HTMLBodyStartL();
+    ExportInitialTableL();
+    StartHeaderTableL( KHeaderTableName );
+    ExportFromL();
+    ExportToL();
+    ExportCcL();
+    ExportBccL();
+    ExportSentTimeL();
+    ExportSubjectL();
+    EndHeaderTableL();
+    ExportAttachmentsL();
+    HTMLBodyEndL();
     }
 
-void CFreestyleMessageHeaderHTML::HTMLBodyStartL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::HTMLBodyStartL() const
     {
-    aWriteStream.WriteL(_L8("<body>\n"));
-    aWriteStream.CommitL();
+    TBuf8<KFreestyleMessageHeaderHTMLRightMarginInPx> scrollPos;
+    scrollPos.AppendNum(iScrollPosition);
+    iWriteStream.WriteL(_L8("<body onLoad = init("));
+    iWriteStream.WriteL(scrollPos);
+    iWriteStream.WriteL(_L8(")>\n"));
+    iWriteStream.CommitL();
     }
-void CFreestyleMessageHeaderHTML::ExportInitialTableL( RWriteStream& aWriteStream ) const
+
+void CFreestyleMessageHeaderHTML::ExportInitialTableL() const
     {
-
     // set the width, using the visible screen width
     TBuf8<KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth> tableWidth;
     tableWidth.AppendNum( iVisibleWidth );
-    aWriteStream.WriteL(_L8("<table id=\"table_initial\" border=\"0\" width=\""));
-    aWriteStream.WriteL( tableWidth );
-    aWriteStream.WriteL( _L8("px\">\n"));
+    iWriteStream.WriteL(_L8("<table id=\"table_initial\" border=\"0\" width=\""));
+    iWriteStream.WriteL( tableWidth );
+    iWriteStream.WriteL( _L8("px\">\n"));
     
 
     // start first row: table with the sent info and the '+' icon
-    aWriteStream.WriteL(_L8("<tr><td><table id=\"table_sent_and_plus\" border=\"0\" width=\""));
-    aWriteStream.WriteL( tableWidth );
-    aWriteStream.WriteL( _L8("px\">\n"));
+    iWriteStream.WriteL(_L8("<tr><td><table id=\"table_sent_and_plus\" border=\"0\" width=\""));
+    iWriteStream.WriteL( tableWidth );
+    iWriteStream.WriteL( _L8("px\">\n"));
     
-    aWriteStream.WriteL(_L8("<tr>\n"));
+    iWriteStream.WriteL(_L8("<tr>\n"));
     
     // add Sent time and date
-    aWriteStream.WriteL(_L8("<td id=\"sent_initial\" align=\"left\" valign=\"bottom\">"));
+    iWriteStream.WriteL(_L8("<td id=\"sent_initial\""));
+    if ( iDirectionality == TBidiText::ELeftToRight )
+        {
+        iWriteStream.WriteL(_L8(" align=\"left\""));
+        }
+    else
+        {
+        iWriteStream.WriteL(_L8(" align=\"right\""));
+        }
+    iWriteStream.WriteL(_L8(" valign=\"bottom\">"));
     
     HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &iMailMessage );
     HBufC* timeText = TFsEmailUiUtility::TimeTextFromMsgLC( &iMailMessage );
@@ -230,77 +279,326 @@
     sentTimeTextPtr.Append( *timeText );
     HBufC8* sentTimeText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( sentTimeTextPtr );
     CleanupStack::PushL( sentTimeText8 );
-    aWriteStream.WriteL( *sentTimeText8 );
+    iWriteStream.WriteL( *sentTimeText8 );
     CleanupStack::PopAndDestroy( sentTimeText8 );
     CleanupStack::PopAndDestroy( sentTimeText );
     CleanupStack::PopAndDestroy( timeText );
     CleanupStack::PopAndDestroy( dateText );
     
-    aWriteStream.WriteL(_L8("</td>\n"));
+    iWriteStream.WriteL(_L8("</td>\n"));
     
     // add "show details" image on the same line as Sent time and date
-    aWriteStream.WriteL(_L8("<td width=\"1\" valign=\"top\" align=\"right\" style=\"padding: 0px 10px 0px 0px;\"><image id=\"detail_img\" border=\"0\" src=\"plus.gif\" onClick=\"expandHeader()\" ></td>\n"));
-        
+    iWriteStream.WriteL(_L8("<td width=\"1\" valign=\"top\""));
+    if ( iDirectionality == TBidiText::ELeftToRight )
+        {
+        iWriteStream.WriteL(_L8(" align=\"right\""));
+        }
+    else
+        {
+        iWriteStream.WriteL(_L8(" align=\"left\""));
+        }
+    iWriteStream.WriteL(_L8(" style=\"padding: 0px 10px 0px 0px;\"><image id=\"detail_img\" border=\"0\" src=\"plus.gif\" onClick=\"expandHeader()\" ></td>\n"));
+
+    
     // finish first row
-    aWriteStream.WriteL(_L8("</tr>\n"));  
-    aWriteStream.WriteL(_L8("</table></td></tr>\n"));
+    iWriteStream.WriteL(_L8("</tr>\n"));  
+    iWriteStream.WriteL(_L8("</table></td></tr>\n"));
 
     //=============================
     // start second row which contains subject
-    aWriteStream.WriteL(_L8("<tr>\n"));
-    aWriteStream.WriteL(_L8("<td id=\"subject_initial\" align=\"left\"><b>"));
+    iWriteStream.WriteL(_L8("<tr>\n"));
+    iWriteStream.WriteL(_L8("<td id=\"subject_initial\""));
+    if ( iDirectionality == TBidiText::ELeftToRight )
+        {
+        iWriteStream.WriteL(_L8(" align=\"left\""));
+        }
+    else
+        {
+        iWriteStream.WriteL(_L8(" align=\"right\""));
+        }
+    iWriteStream.WriteL(_L8("><b>"));
 
     HBufC8* subject8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iMailMessage.GetSubject() );
     CleanupStack::PushL( subject8 );
-    aWriteStream.WriteL( *subject8 );
+    iWriteStream.WriteL( *subject8 );
     CleanupStack::PopAndDestroy( subject8 );
-
-    aWriteStream.WriteL(_L8("</b></td>\n"));
-    aWriteStream.WriteL(_L8("</tr>\n"));  // finish subject row
+    iWriteStream.WriteL(_L8("</b>"));
+        
+    // Write icons (if necessary).
+    HBufC8* followUp = HTMLHeaderFollowUpIconLC( EFalse );
+    HBufC8* priority = HTMLHeaderPriorityIconLC( EFalse );
+        
+    if ( priority )
+        {
+        iWriteStream.WriteL( *priority );
+        CleanupStack::PopAndDestroy( priority);
+        }
+    
+    if ( followUp )
+        {
+        iWriteStream.WriteL( *followUp );
+        CleanupStack::PopAndDestroy( followUp );
+        }
+    
+    iWriteStream.WriteL(_L8("</td></tr>\n"));  // finish subject row
     
     // end table_initial
-    aWriteStream.WriteL(_L8("</table>\n"));
+    iWriteStream.WriteL(_L8("</table>\n"));
         
-    aWriteStream.CommitL();
-    }
-void CFreestyleMessageHeaderHTML::HTMLBodyEndL( RWriteStream& aWriteStream ) const
-    {
-    aWriteStream.WriteL(_L8("</body>\n"));
-    aWriteStream.CommitL();
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::ExportSubjectL( RWriteStream& aWriteStream ) const
+HBufC8* CFreestyleMessageHeaderHTML::HTMLHeaderFollowUpIconLC( TBool aShowText ) const
+    {
+    HBufC8* followUpText8( NULL );
+    HBufC8* followUpCompletedText8( NULL );
+        
+    // Reserve space with worst case scenario in mind. 
+    TInt textLength( 0 );
+    if ( aShowText )
+        {
+        // Follow up completed.
+        HBufC* followUpCompletedText = StringLoader::LoadLC( 
+                R_FREESTYLE_EMAIL_UI_VIEWER_COMPLETED );
+        followUpCompletedText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( 
+                *followUpCompletedText );
+        CleanupStack::PopAndDestroy( followUpCompletedText );
+        CleanupStack::PushL( followUpCompletedText8 );
+        
+        // Follow up.
+        HBufC* followUpText = StringLoader::LoadLC( 
+                R_FREESTYLE_EMAIL_UI_VIEWER_FOLLOWUP );
+        followUpText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( 
+                *followUpText );
+        CleanupStack::PopAndDestroy( followUpText );
+        CleanupStack::PushL( followUpText8 );
+    
+        textLength += KHTMLImgTagId().Length() +
+                      KFollowUpCompleteImageName().Length() +
+                      KHTMLImgTagSrcBefore().Length() +
+                      KFollowUpCompleteIconFileName().Length() +
+                      KHTMLImgTagSrcAfter().Length() +
+                      ( followUpText8->Length() >= followUpCompletedText8->Length() ?
+                      followUpText8->Length() : followUpCompletedText8->Length() ); 
+        }
+    else
+        {
+        // Plain icon and no text.
+        textLength += KHTMLImgTagId().Length() + 
+                      KFollowUpCompleteImageName().Length() +
+                      KHTMLImgTagSrcBefore().Length() +
+                      KFollowUpCompleteIconFileName().Length() +
+                      KHTMLImgTagSrcAfter().Length();
+        }
+
+    // Allocate space.
+    HBufC8* iconText8 = HBufC8::NewLC( textLength );    
+        
+    // Generate HTML code
+    TPtr8 iconPtr( iconText8->Des() );
+        
+    if ( iMailMessage.IsFlagSet( EFSMsgFlag_FollowUp ) )
+        {
+        iconPtr.Append( KHTMLImgTagId );
+        iconPtr.Append( KFollowUpImageName );
+        iconPtr.Append( KHTMLImgTagSrcBefore );
+        iconPtr.Append( KFollowUpIconFileName );
+        iconPtr.Append( KHTMLImgTagSrcAfter );
+        if ( aShowText && followUpText8 )
+            {
+            iconPtr.Append( followUpText8->Des() );
+            }
+        }
+    else if ( iMailMessage.IsFlagSet( EFSMsgFlag_FollowUpComplete ) )
+        {
+        iconPtr.Append( KHTMLImgTagId );
+        iconPtr.Append( KFollowUpCompleteImageName );
+        iconPtr.Append( KHTMLImgTagSrcBefore );
+        iconPtr.Append( KFollowUpCompleteIconFileName );
+        iconPtr.Append( KHTMLImgTagSrcAfter );
+        if ( aShowText && followUpCompletedText8 )
+            {
+            iconPtr.Append( followUpCompletedText8->Des() );
+            }
+        }
+    else
+        {
+        // No follow up flag set.
+        CleanupStack::PopAndDestroy( iconText8 );
+        iconText8 = NULL;
+        }
+
+    if ( aShowText )
+        {
+        if ( iconText8 )
+            {
+            CleanupStack::Pop( iconText8 );
+            }
+        CleanupStack::PopAndDestroy( followUpText8 );
+        CleanupStack::PopAndDestroy( followUpCompletedText8 );
+        if ( iconText8 )
+            {
+            CleanupStack::PushL( iconText8 );
+            }
+        }
+    
+    return iconText8;
+    }
+
+HBufC8* CFreestyleMessageHeaderHTML::HTMLHeaderPriorityIconLC( TBool aShowText ) const
     {
-    aWriteStream.WriteL( _L8("<tr id=\"") );
-    aWriteStream.WriteL( KSubjectFieldName );
-    aWriteStream.WriteL( _L8("\">") );
+    HBufC8* highPrioText8( NULL );
+    HBufC8* lowPrioText8( NULL );
+        
+    // Reserve space with worst case scenario in mind. 
+    TInt textLength( 0 );
+    if ( aShowText )
+        {
+        // High priority.
+        HBufC* highPrioText = StringLoader::LoadLC( 
+                R_FREESTYLE_EMAIL_UI_VIEWER_HIGH_PRIO );
+        highPrioText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( 
+                *highPrioText );
+        CleanupStack::PopAndDestroy( highPrioText );
+        CleanupStack::PushL( highPrioText8 );
+    
+        // Low priority.
+        HBufC* lowPrioText = StringLoader::LoadLC( 
+                R_FREESTYLE_EMAIL_UI_VIEWER_LOW_PRIO );
+        lowPrioText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( 
+                *lowPrioText );
+        CleanupStack::PopAndDestroy( lowPrioText );
+        CleanupStack::PushL( lowPrioText8 );
+            
+        textLength += KHTMLImgTagId().Length() +
+                      KPriorityHighImageName().Length() +
+                      KHTMLImgTagSrcBefore().Length() +
+                      KPriorityHighIconFileName().Length() +
+                      KHTMLImgTagSrcAfter().Length() +
+                      ( lowPrioText8->Length() >= highPrioText8->Length() ?
+                      lowPrioText8->Length() : highPrioText8->Length() ); 
+        }
+    else
+        {
+        // Plain icon and no text.
+        textLength += KHTMLImgTagId().Length() + 
+                      KPriorityHighImageName().Length() +
+                      KHTMLImgTagSrcBefore().Length() +
+                      KPriorityHighIconFileName().Length() +
+                      KHTMLImgTagSrcAfter().Length();
+        }
+
+    // Allocate space.
+    HBufC8* iconText8 = HBufC8::NewLC( textLength );    
+        
+    // Generate HTML code
+    TPtr8 iconPtr( iconText8->Des() );
+        
+    if ( iMailMessage.IsFlagSet( EFSMsgFlag_Low ) )
+        {
+        iconPtr.Append( KHTMLImgTagId );
+        iconPtr.Append( KPriorityLowImageName );
+        iconPtr.Append( KHTMLImgTagSrcBefore );
+        iconPtr.Append( KPriorityLowIconFileName );
+        iconPtr.Append( KHTMLImgTagSrcAfter );
+        if ( aShowText && lowPrioText8 )
+            {
+            iconPtr.Append( lowPrioText8->Des() );
+            }
+        }
+    else if ( iMailMessage.IsFlagSet( EFSMsgFlag_Important ) )
+        {
+        iconPtr.Append( KHTMLImgTagId );
+        iconPtr.Append( KPriorityHighImageName );
+        iconPtr.Append( KHTMLImgTagSrcBefore );
+        iconPtr.Append( KPriorityHighIconFileName );
+        iconPtr.Append( KHTMLImgTagSrcAfter );
+        if ( aShowText && highPrioText8 )
+            {
+            iconPtr.Append( highPrioText8->Des() );
+            }
+        }
+    else
+        {
+        // No priority flag set.
+        CleanupStack::PopAndDestroy( iconText8 );
+        iconText8 = NULL;
+        }
+
+    if ( aShowText )
+        {
+        if ( iconText8 )
+            {
+            CleanupStack::Pop( iconText8 );
+            }
+        CleanupStack::PopAndDestroy( lowPrioText8 );
+        CleanupStack::PopAndDestroy( highPrioText8 );
+        if ( iconText8 )
+            {
+            CleanupStack::PushL( iconText8 );
+            }
+        }
+    
+    return iconText8;
+    }
+
+void CFreestyleMessageHeaderHTML::HTMLBodyEndL() const
+    {
+    iWriteStream.WriteL(_L8("</body>\n"));
+    iWriteStream.CommitL();
+    }
+
+void CFreestyleMessageHeaderHTML::ExportSubjectL() const
+    {
+    iWriteStream.WriteL( _L8("<tr id=\"") );
+    iWriteStream.WriteL( KSubjectFieldName );
+    iWriteStream.WriteL( _L8("\">") );
 
 
-    aWriteStream.WriteL( _L8("<td width=\"1\">") );
-    aWriteStream.WriteL( _L8("<b>") );
+    iWriteStream.WriteL( _L8("<td width=\"1\">") );
+    iWriteStream.WriteL( _L8("<b>") );
     HBufC8* subjectHeadingText = HeadingTextLC( R_FREESTYLE_EMAIL_UI_VIEWER_SUBJECT );
-    aWriteStream.WriteL( *subjectHeadingText );
+    iWriteStream.WriteL( *subjectHeadingText );
     CleanupStack::PopAndDestroy( subjectHeadingText );
-    aWriteStream.WriteL( _L8("</b>") );
-    aWriteStream.WriteL( _L8("</td>") );
-    aWriteStream.WriteL( _L8("</tr>\n") );
+    iWriteStream.WriteL( _L8("</b>") );
+    iWriteStream.WriteL( _L8("</td>") );
+    iWriteStream.WriteL( _L8("</tr>\n") );
     
     // subject text
-    aWriteStream.WriteL( _L8("<tr>") );
-    aWriteStream.WriteL( _L8("<td>") );
+    iWriteStream.WriteL( _L8("<tr>") );
+    iWriteStream.WriteL( _L8("<td>") );
 
     HBufC8* subject8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iMailMessage.GetSubject() );
     CleanupStack::PushL( subject8 );
-    aWriteStream.WriteL( *subject8 );
+    iWriteStream.WriteL( *subject8 );
     CleanupStack::PopAndDestroy( subject8 );
 
-    aWriteStream.WriteL( _L8("</td>") );
-    aWriteStream.WriteL( _L8("</tr>\n") );
+    iWriteStream.WriteL( _L8("</td>") );
+    iWriteStream.WriteL( _L8("</tr>\n") );
+    // Write icons (if necessary).
+    HBufC8* followUp = HTMLHeaderFollowUpIconLC( ETrue );
+    HBufC8* priority = HTMLHeaderPriorityIconLC( ETrue );
+   
+    if ( priority )
+       {
+       iWriteStream.WriteL(_L8("<tr><td>"));
+       iWriteStream.WriteL( *priority );
+       iWriteStream.WriteL(_L8("</td></tr>"));
+       CleanupStack::PopAndDestroy( priority);
+       }
+   
+    if ( followUp )
+       {
+       iWriteStream.WriteL(_L8("<tr><td>"));
+       iWriteStream.WriteL( *followUp );
+       iWriteStream.WriteL(_L8("</td></tr>"));
+       CleanupStack::PopAndDestroy( followUp );
+       }
 
-    aWriteStream.CommitL();
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::ExportFromL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::ExportFromL() const
     {
     RPointerArray<CFSMailAddress> froms;
     CleanupClosePushL( froms );
@@ -309,51 +607,51 @@
         {
         froms.AppendL( from );
         }
-    ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeFrom, froms, 
+    ExportEmailAddressesL( FreestyleMessageHeaderURLFactory::EEmailAddressTypeFrom, froms, 
                            KFromFieldName, KFromTableName, R_FREESTYLE_EMAIL_UI_VIEWER_FROM );
     CleanupStack::PopAndDestroy( &froms );
     }
 
-void CFreestyleMessageHeaderHTML::ExportToL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::ExportToL() const
     {
     RPointerArray<CFSMailAddress>& recipients = iMailMessage.GetToRecipients();
-    ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeTo, recipients,
+    ExportEmailAddressesL( FreestyleMessageHeaderURLFactory::EEmailAddressTypeTo, recipients,
                            KToFieldName, KToTableName, R_FREESTYLE_EMAIL_UI_VIEWER_TO );
     }
 
-void CFreestyleMessageHeaderHTML::ExportCcL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::ExportCcL() const
     {
     RPointerArray<CFSMailAddress>& recipients = iMailMessage.GetCCRecipients();
-    ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeCc, recipients,
+    ExportEmailAddressesL( FreestyleMessageHeaderURLFactory::EEmailAddressTypeCc, recipients,
                            KCcFieldName, KCcTableName, R_FREESTYLE_EMAIL_UI_VIEWER_CC );
     }
 
-void CFreestyleMessageHeaderHTML::ExportBccL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::ExportBccL() const
     {
     RPointerArray<CFSMailAddress>& recipients = iMailMessage.GetBCCRecipients();
-    ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeBcc, recipients,
+    ExportEmailAddressesL( FreestyleMessageHeaderURLFactory::EEmailAddressTypeBcc, recipients,
                            KBccFieldName, KBccTableName, R_FREESTYLE_EMAIL_UI_VIEWER_BCC );
     }
 
-void CFreestyleMessageHeaderHTML::ExportSentTimeL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::ExportSentTimeL() const
     {
 
-    aWriteStream.WriteL( _L8("<tr id=\"") );
-    aWriteStream.WriteL( KSentFieldName );
-    aWriteStream.WriteL( _L8("\">") );
+    iWriteStream.WriteL( _L8("<tr id=\"") );
+    iWriteStream.WriteL( KSentFieldName );
+    iWriteStream.WriteL( _L8("\">") );
 
 
-    aWriteStream.WriteL( _L8("<td width=\"1\">") );
-    aWriteStream.WriteL( _L8("<b>") );
+    iWriteStream.WriteL( _L8("<td width=\"1\">") );
+    iWriteStream.WriteL( _L8("<b>") );
     HBufC8* sentHeadingText = HeadingTextLC( R_FREESTYLE_EMAIL_UI_VIEWER_SENT );
-    aWriteStream.WriteL( *sentHeadingText );
+    iWriteStream.WriteL( *sentHeadingText );
     CleanupStack::PopAndDestroy( sentHeadingText );
-    aWriteStream.WriteL( _L8("</b>") );
-    aWriteStream.WriteL( _L8("</td>") );
-    aWriteStream.WriteL( _L8("</tr>\n") );
+    iWriteStream.WriteL( _L8("</b>") );
+    iWriteStream.WriteL( _L8("</td>") );
+    iWriteStream.WriteL( _L8("</tr>\n") );
 
-    aWriteStream.WriteL( _L8("<tr>") );
-    aWriteStream.WriteL( _L8("<td>") );
+    iWriteStream.WriteL( _L8("<tr>") );
+    iWriteStream.WriteL( _L8("<td>") );
 
     HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &iMailMessage );
     HBufC* timeText = TFsEmailUiUtility::TimeTextFromMsgLC( &iMailMessage );
@@ -366,60 +664,68 @@
     sentTimeTextPtr.Append( *timeText );
     HBufC8* sentTimeText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( sentTimeTextPtr );
     CleanupStack::PushL( sentTimeText8 );
-    aWriteStream.WriteL( *sentTimeText8 );
+    iWriteStream.WriteL( *sentTimeText8 );
     CleanupStack::PopAndDestroy( sentTimeText8 );
     CleanupStack::PopAndDestroy( sentTimeText );
     CleanupStack::PopAndDestroy( timeText );
     CleanupStack::PopAndDestroy( dateText );
 
-    aWriteStream.WriteL( _L8("</td>") );
+    iWriteStream.WriteL( _L8("</td>") );
 
-    aWriteStream.WriteL( _L8("</tr>\n") );
+    iWriteStream.WriteL( _L8("</tr>\n") );
 
-    aWriteStream.CommitL();
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::ExportAttachmentsL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::ExportAttachmentsL() const
     {
-
-    TInt attachmentsCount( iAttachments.Count() );
-    if ( attachmentsCount )
+    TInt attachmentsCount (iAttachments.Count());
+    if ( attachmentsCount)
         {
         // The attachments table consists of one row that contains 2 cells
         // first cell contains the attachment icon
         // second cell contains a table which contains the attachments list
 
         // start attachments table
-        aWriteStream.WriteL( _L8("<table id=\"") ); 
-        aWriteStream.WriteL( KAttachmentTableName );
-        aWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\">\n") );  // width is set at 100% intentionally
+        iWriteStream.WriteL( _L8("<table id=\"") ); 
+        iWriteStream.WriteL( KAttachmentTableName );
+        iWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\">\n") );  // width is set at 100% intentionally
         
         // start row
-        aWriteStream.WriteL( _L8("<tr>\n") );
+        iWriteStream.WriteL( _L8("<tr>\n") );
           
         // add attachment icon
-        aWriteStream.WriteL( _L8("<td width=\"1\" valign=\"top\" align=\"right\"><image src=\"") );
-        aWriteStream.WriteL( KAttachementIconGeneral );
-        aWriteStream.WriteL( _L8("\" ></td>\n") );
+        iWriteStream.WriteL( _L8("<td width=\"1\" valign=\"top\"") );
+        if ( iDirectionality == TBidiText::ELeftToRight )
+            {
+            iWriteStream.WriteL(_L8(" align=\"right\""));
+            }
+        else
+            {
+            iWriteStream.WriteL(_L8(" align=\"left\""));
+            }
+        iWriteStream.WriteL( _L8("><image src=\"") );
+        
+        iWriteStream.WriteL( KAttachementIconGeneral );
+        iWriteStream.WriteL( _L8("\" ></td>\n") );
         
         // start table of attachments as a table within a cell
-        aWriteStream.WriteL( _L8("<td>\n") );
-        aWriteStream.WriteL(_L8("<table id=\"table_attachments_list\" border=\"0\" width=\"100%\">\n"));
+        iWriteStream.WriteL( _L8("<td>\n") );
+        iWriteStream.WriteL(_L8("<table id=\"table_attachments_list\" border=\"0\" width=\"100%\">\n"));
         for (TInt i=0; i < attachmentsCount; i++)
             {
-            AddAttachmentL( aWriteStream, *iAttachments[i] );
+            AddAttachmentL( *iAttachments[i] );
             }
 
-        aWriteStream.WriteL(_L8("</table>\n")); // end table_attachments_list
-        aWriteStream.WriteL( _L8("</td>\n") );
+        iWriteStream.WriteL(_L8("</table>\n")); // end table_attachments_list
+        iWriteStream.WriteL( _L8("</td>\n") );
         
-        aWriteStream.WriteL( _L8("</tr>\n") );
-        aWriteStream.WriteL(_L8("</table>\n")); // end attachments table
+        iWriteStream.WriteL( _L8("</tr>\n") );
+        iWriteStream.WriteL(_L8("</table>\n")); // end attachments table
         }
     }
 
-void CFreestyleMessageHeaderHTML::ExportEmailAddressesL( RWriteStream& aWriteStream, 
-                                                        FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType, 
+void CFreestyleMessageHeaderHTML::ExportEmailAddressesL(FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType, 
                                                         const RPointerArray<CFSMailAddress>& aEmailAddresses,
                                                         const TDesC8& aRowId,
                                                         const TDesC8& /*aTableId*/,
@@ -428,35 +734,34 @@
     if ( aEmailAddresses.Count() )
         {
         // begin table row
-        aWriteStream.WriteL( _L8("<tr id=\"")); 
-        aWriteStream.WriteL( aRowId );
-        aWriteStream.WriteL( _L8("\">") );
+        iWriteStream.WriteL( _L8("<tr id=\"")); 
+        iWriteStream.WriteL( aRowId );
+        iWriteStream.WriteL( _L8("\">") );
         
         // heading text
-        aWriteStream.WriteL( _L8("<td><b>"));
+        iWriteStream.WriteL( _L8("<td><b>"));
         HBufC8* headingText = HeadingTextLC( aHeaderTextResourceId );
-        aWriteStream.WriteL( *headingText );
+        iWriteStream.WriteL( *headingText );
         CleanupStack::PopAndDestroy( headingText );
-        aWriteStream.WriteL( _L8("</b></td>"));
+        iWriteStream.WriteL( _L8("</b></td>"));
         
-        aWriteStream.WriteL( _L8("</tr>\n") );  // end table row      
+        iWriteStream.WriteL( _L8("</tr>\n") );  // end table row      
         
         // add addresses, one address per row
         TInt count( aEmailAddresses.Count() );
         for (TInt i = 0; i < count; ++i )
             {
-            aWriteStream.WriteL( _L8("<tr><td style=\"padding: 0px 0px 7px 0px;\">") );
-            AddEmailAddressL (aWriteStream, aEmailAddressType, *aEmailAddresses[i] );
-            aWriteStream.WriteL( _L8("</td></tr>\n") );
+            iWriteStream.WriteL( _L8("<tr><td style=\"padding: 0px 0px 7px 0px;\">") );
+            AddEmailAddressL (aEmailAddressType, *aEmailAddresses[i] );
+            iWriteStream.WriteL( _L8("</td></tr>\n") );
             }
 
-        aWriteStream.CommitL();
+        iWriteStream.CommitL();
         }
     }
 
-void CFreestyleMessageHeaderHTML::AddEmailAddressL( RWriteStream& aWriteStream,
-        FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType,
-        const CFSMailAddress& aEmailAddress ) const
+void CFreestyleMessageHeaderHTML::AddEmailAddressL( FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType,
+                                                    const CFSMailAddress& aEmailAddress ) const
     {
     CFreestyleMessageHeaderURL* emailUrl = FreestyleMessageHeaderURLFactory::CreateEmailAddressUrlL( aEmailAddressType, aEmailAddress );
     CleanupStack::PushL( emailUrl );
@@ -465,7 +770,7 @@
     CleanupStack::PushL( url );
     HBufC8* url8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *url );
     CleanupStack::PushL( url8 );
-    StartHyperlinkL( aWriteStream, *url8 );
+    StartHyperlinkL( *url8 );
     CleanupStack::PopAndDestroy( url8 );
     CleanupStack::PopAndDestroy( url );
 
@@ -479,17 +784,17 @@
         displayName8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aEmailAddress.GetEmailAddress() );
         }
     CleanupStack::PushL( displayName8 );
-    aWriteStream.WriteL( *displayName8 );
+    iWriteStream.WriteL( *displayName8 );
     CleanupStack::PopAndDestroy( displayName8 );
 
-    EndHyperlinkL( aWriteStream );
+    EndHyperlinkL();
 
     CleanupStack::PopAndDestroy( emailUrl );
     }
 
-void CFreestyleMessageHeaderHTML::AddAttachmentL( RWriteStream& aWriteStream, CFSMailMessagePart& aAttachment ) const
+void CFreestyleMessageHeaderHTML::AddAttachmentL( CFSMailMessagePart& aAttachment ) const
     {
-    aWriteStream.WriteL( _L8("<tr><td style=\"padding: 0px 0px 7px 0px;\">") ); // pad bottom to allow some space between the lines
+    iWriteStream.WriteL( _L8("<tr><td style=\"padding: 0px 0px 7px 0px;\">") ); // pad bottom to allow some space between the lines
 
     TUint id = aAttachment.GetPartId().Id();
     TBuf<32> itemId;
@@ -500,7 +805,7 @@
     CleanupStack::PushL( attnUrlText );
     HBufC8* attnUrlText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *attnUrlText );
     CleanupStack::PushL( attnUrlText8 );
-    StartHyperlinkL( aWriteStream, *attnUrlText8 );
+    StartHyperlinkL( *attnUrlText8 );
     CleanupStack::PopAndDestroy( attnUrlText8 );
     CleanupStack::PopAndDestroy( attnUrlText );
     CleanupStack::PopAndDestroy( attnUrl );
@@ -508,7 +813,7 @@
     TDesC& attnName = aAttachment.AttachmentNameL();
     HBufC8* attnName8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( attnName );
     CleanupStack::PushL( attnName8 );
-    aWriteStream.WriteL( *attnName8 );
+    iWriteStream.WriteL( *attnName8 );
     CleanupStack::PopAndDestroy( attnName8 );
 
     TUint size = aAttachment.ContentSize();
@@ -527,109 +832,119 @@
     sizeText.Append( KSpace8 );
     sizeText.Append( KAttachmentSizeUnit );
     sizeText.Append( _L8(")") );
-    aWriteStream.WriteL( sizeText );
+    iWriteStream.WriteL( sizeText );
 
-    EndHyperlinkL( aWriteStream );
+    EndHyperlinkL();
 
-    aWriteStream.WriteL( _L8("</td></tr>\n") );
-    aWriteStream.CommitL();
+    iWriteStream.WriteL( _L8("</td></tr>\n") );
+    iWriteStream.CommitL();
     }
 
 
-void CFreestyleMessageHeaderHTML::StartHyperlinkL( RWriteStream& aWriteStream, const TDesC8& aUrl ) const
+void CFreestyleMessageHeaderHTML::StartHyperlinkL( const TDesC8& aUrl ) const
     {
-    aWriteStream.WriteL( _L8("<a href=\"") );
-    aWriteStream.WriteL( aUrl );
-    aWriteStream.WriteL( _L8("\">"));
-    aWriteStream.CommitL();
+    iWriteStream.WriteL( _L8("<a href=\"") );
+    iWriteStream.WriteL( aUrl );
+    iWriteStream.WriteL( _L8("\">"));
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::EndHyperlinkL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::EndHyperlinkL() const
     {
-    aWriteStream.WriteL( _L8("</a>") );
-    aWriteStream.CommitL();
+    iWriteStream.WriteL( _L8("</a>") );
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::AddImageL( RWriteStream& aWriteStream, const TDesC8& aImageUrl ) const
+void CFreestyleMessageHeaderHTML::AddImageL( const TDesC8& aImageUrl ) const
     {
-    aWriteStream.WriteL( _L8("<image border=\"0\" src=\"") );
-    aWriteStream.WriteL( aImageUrl );
-    aWriteStream.WriteL( _L8("\">"));
-    aWriteStream.CommitL();
+    iWriteStream.WriteL( _L8("<image border=\"0\" src=\"") );
+    iWriteStream.WriteL( aImageUrl );
+    iWriteStream.WriteL( _L8("\">"));
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::AddImageL( RWriteStream& aWriteStream,
-        const TDesC8& aImageId,
-        const TDesC8& aImageUrl,
-        const TDesC8& aImageEvent ) const
+void CFreestyleMessageHeaderHTML::AddImageL( const TDesC8& aImageId,
+                                             const TDesC8& aImageUrl,
+                                             const TDesC8& aImageEvent ) const
     {
-    aWriteStream.WriteL( _L8("<image id=\"") );
-    aWriteStream.WriteL( aImageId );
-    aWriteStream.WriteL( _L8("\" ") );
-    aWriteStream.WriteL( _L8("border=\"0\" src=\"") );
-    aWriteStream.WriteL( aImageUrl );
-    aWriteStream.WriteL( _L8("\" "));
-    aWriteStream.WriteL( aImageEvent );
-    aWriteStream.WriteL( _L8(">"));
-    aWriteStream.CommitL();
+    iWriteStream.WriteL( _L8("<image id=\"") );
+    iWriteStream.WriteL( aImageId );
+    iWriteStream.WriteL( _L8("\" ") );
+    iWriteStream.WriteL( _L8("border=\"0\" src=\"") );
+    iWriteStream.WriteL( aImageUrl );
+    iWriteStream.WriteL( _L8("\" "));
+    iWriteStream.WriteL( aImageEvent );
+    iWriteStream.WriteL( _L8(">"));
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::AddJavascriptL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::AddJavascriptL() const
     {
-    aWriteStream.WriteL( _L8("<script language=\"javascript\" src=\"header.js\"></script>\n"));
-    aWriteStream.CommitL();
+    iWriteStream.WriteL( _L8("<script language=\"javascript\" src=\"header.js\"></script>\n"));
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::StartHeaderTableL( RWriteStream& aWriteStream, const TDesC8& aTableId ) const
+void CFreestyleMessageHeaderHTML::StartHeaderTableL( const TDesC8& aTableId ) const
     {
-    aWriteStream.WriteL( _L8("<table id=\"") );
-    aWriteStream.WriteL( aTableId );
+    iWriteStream.WriteL( _L8("<table id=\"") );
+    iWriteStream.WriteL( aTableId );
     
     // use style="display:none" so that full header table is hidden initially
-    aWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\" style=\"display: none\">\n") );
+    iWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\" style=\"display: none\">\n") );
     
     
     TBuf8<KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth> tableWidth;
     tableWidth.AppendNum( iVisibleWidth );
 
     // Add "hide details" image as its own table with its own width
-    aWriteStream.WriteL( _L8("<tr><td>\n"));
-    aWriteStream.WriteL(_L8("<table id =\"table_minus_icon\" border=\"0\" width=\""));
-    aWriteStream.WriteL( tableWidth );
-    aWriteStream.WriteL( _L8("px\">\n"));
-    aWriteStream.WriteL( _L8("<tr>\n"));
-    aWriteStream.WriteL( _L8("<td valign=\"top\" align=\"right\" style=\"padding: 0px 10px 0px 0px;\"><image id=\"hideDetails_img\" border=\"0\" src=\"minus.gif\" onClick=\"collapseHeader()\"></td>\n"));
-    aWriteStream.WriteL( _L8("</tr>\n"));
-    aWriteStream.WriteL( _L8("</table></td></tr>\n"));
-    aWriteStream.CommitL();
-    }
+    iWriteStream.WriteL( _L8("<tr><td>\n"));
+    iWriteStream.WriteL(_L8("<table id =\"table_minus_icon\" border=\"0\" width=\""));
+    iWriteStream.WriteL( tableWidth );
+    iWriteStream.WriteL( _L8("px\">\n"));
+    iWriteStream.WriteL( _L8("<tr>\n"));
+    
+    iWriteStream.WriteL( _L8("<td valign=\"top\""));
+    if ( iDirectionality == TBidiText::ELeftToRight )
+        {
+        iWriteStream.WriteL(_L8(" align=\"right\""));
+        }
+    else
+        {
+        iWriteStream.WriteL(_L8(" align=\"left\""));
+        }
+    iWriteStream.WriteL( _L8(" style=\"padding: 0px 10px 0px 0px;\"><image id=\"hideDetails_img\" border=\"0\" src=\"minus.gif\" onClick=\"collapseHeader()\"></td>\n"));
 
-void CFreestyleMessageHeaderHTML::EndHeaderTableL( RWriteStream& aWriteStream ) const
-    {
-    EndTableL( aWriteStream );
+    iWriteStream.WriteL( _L8("</tr>\n"));
+    iWriteStream.WriteL( _L8("</table></td></tr>\n"));
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::StartTableL( RWriteStream& aWriteStream, const TDesC8& aTableId ) const
+void CFreestyleMessageHeaderHTML::EndHeaderTableL() const
     {
-    aWriteStream.WriteL( _L8("<table id=\"") );
-    aWriteStream.WriteL( aTableId );
-    aWriteStream.WriteL( _L8("\" border=\"0\">\n") );
-    aWriteStream.CommitL();
+    EndTableL();
     }
 
-void CFreestyleMessageHeaderHTML::EndTableL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::StartTableL( const TDesC8& aTableId ) const
     {
-    aWriteStream.WriteL( _L8("</table>\n") );
-    aWriteStream.CommitL();
+    iWriteStream.WriteL( _L8("<table id=\"") );
+    iWriteStream.WriteL( aTableId );
+    iWriteStream.WriteL( _L8("\" border=\"1\">\n") );
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::AddShowDetailL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::EndTableL() const
+    {
+    iWriteStream.WriteL( _L8("</table>\n") );
+    iWriteStream.CommitL();
+    }
+
+void CFreestyleMessageHeaderHTML::AddShowDetailL() const
     {
     HBufC8* event = ClickImageEventL( KDetailImageName );
     CleanupStack::PushL( event );
-    AddImageL( aWriteStream, KDetailImageName, KShowDetailIconFileName, *event );
+    AddImageL( KDetailImageName, KShowDetailIconFileName, *event );
     CleanupStack::PopAndDestroy( event );
-    aWriteStream.CommitL();
+    iWriteStream.CommitL();
     }
 
 HBufC8* CFreestyleMessageHeaderHTML::ClickImageEventL( const TDesC8& aImageName ) const
@@ -700,41 +1015,41 @@
     return headingText8;
     }
 
-void CFreestyleMessageHeaderHTML::AddStyleSheetL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::AddStyleSheetL() const
     {
     // Add an internal style sheet
     // If the style becomes numerous or complicated, consider using an external style sheet
     
-    aWriteStream.WriteL( _L8("<style type=\"text/css\">\n") );
+    iWriteStream.WriteL( _L8("<style type=\"text/css\">\n") );
     
     // define a div class "header", specifying the background color
     // for the email header part
     
     // In future, query for which background color to use
-    aWriteStream.WriteL( _L8("body { background-color: lightblue; }\n") );
+    iWriteStream.WriteL( _L8("body { background-color: lightblue; }\n") );
     
     // set font size to 75% of the default size
     // because, at the default size, the header text is too big relative to the text in the email body
     // Note: since the text in the body is too small at "normal" level, 
     // we have the text size level in the browser set to "Larger" which is 20% larger than the specified size
     // the "larger" size affects all text which includes the header.
-    aWriteStream.WriteL( _L8("td { font-family:arial,sans-serif ; font-size:75% }\n"));
+    iWriteStream.WriteL( _L8("td { font-family:arial,sans-serif ; font-size:75% }\n"));
     
-    aWriteStream.WriteL( _L8("</style>\n") );
-    aWriteStream.CommitL();
+    iWriteStream.WriteL( _L8("</style>\n") );
+    iWriteStream.CommitL();
     }
 
-void CFreestyleMessageHeaderHTML::StartDivL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::StartDivL() const
     {
     // Add div, using "header" class
-    aWriteStream.WriteL( _L8("<div class=\"header\">\n") );
-    aWriteStream.CommitL();
+    iWriteStream.WriteL( _L8("<div class=\"header\">\n") );
+    iWriteStream.CommitL();
     }
     
-void CFreestyleMessageHeaderHTML::EndDivL( RWriteStream& aWriteStream ) const
+void CFreestyleMessageHeaderHTML::EndDivL() const
     {
-    aWriteStream.WriteL( _L8("</div>\n") );
-    aWriteStream.CommitL();
+    iWriteStream.WriteL( _L8("</div>\n") );
+    iWriteStream.CommitL();
     }
 
 
--- a/emailuis/emailui/src/FreestyleMessageHeaderURLEventHandler.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/FreestyleMessageHeaderURLEventHandler.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -23,10 +23,15 @@
 #include "FreestyleEmailUiAppui.h"
 #include "FreestyleEmailUiHtmlViewerView.h"
 #include "FreestyleEmailUi.hrh"
+#include "FreestyleEmailUi.rsg"
+#include "FSHtmlReloadAO.h"
 
 #include <aknnotewrappers.h>
+#include <aknstyluspopupmenu.h>
 #include <BrCtlDefs.h>
 #include <e32std.h>
+#include <EIKMOBS.H>
+#include <coemain.h>  
 
 EXPORT_C CFreestyleMessageHeaderURLEventHandler* CFreestyleMessageHeaderURLEventHandler::NewL( 
         CFreestyleEmailUiAppUi& aAppUi, 
@@ -51,12 +56,61 @@
 
 void CFreestyleMessageHeaderURLEventHandler::ConstructL()
     {
-    iMessageHeaderURL = CFreestyleMessageHeaderURL::NewL();
+    iMessageHeaderURL = CFreestyleMessageHeaderURL::NewL();   
+    iHTMLReloadAO = CFSHtmlReloadAO::NewL(iView);
+    
+    if(!iEmailAddressStylusPopup)
+        {
+        TPoint point( 0, 0 );
+        iEmailAddressStylusPopup = CAknStylusPopUpMenu::NewL( this , point );
+		TResourceReader reader;
+		CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_EMAIL_ADDRESS );
+		iEmailAddressStylusPopup->ConstructFromResourceL( reader );
+		CleanupStack::PopAndDestroy(); //resource reader
+        }
+    
+    if( !iAttachmentStylusPopup )
+    	{
+    	TPoint point( 0, 0 );
+    	iAttachmentStylusPopup = CAknStylusPopUpMenu::NewL( this , point );
+		TResourceReader reader;
+		CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_ATTACHMENT );
+		iAttachmentStylusPopup->ConstructFromResourceL( reader );
+		CleanupStack::PopAndDestroy(); //resource reader
+    	}
+    
+    if( !iWebAddressStylusPopup )
+		{
+		TPoint point( 0, 0 );
+		iWebAddressStylusPopup = CAknStylusPopUpMenu::NewL( this , point );
+		TResourceReader reader;
+		CCoeEnv::Static()->CreateResourceReaderLC( reader, R_STYLUS_POPUP_MENU_HTML_VIEW_WEB_ADDRESS );
+		iWebAddressStylusPopup->ConstructFromResourceL( reader );
+		CleanupStack::PopAndDestroy(); //resource reader
+		}
+    
     }
 
 CFreestyleMessageHeaderURLEventHandler::~CFreestyleMessageHeaderURLEventHandler ()
     {
     delete iMessageHeaderURL;
+    delete iHTMLReloadAO; 
+    if( iEmailAddressStylusPopup )
+    	{
+		delete iEmailAddressStylusPopup; 
+    	}
+    
+    if( iAttachmentStylusPopup )
+		{
+		delete iAttachmentStylusPopup; 
+		}
+    
+    if( iWebAddressStylusPopup )
+		{
+		delete iWebAddressStylusPopup; 
+		}   
+    
+    delete iUrl;
     }
 
 EXPORT_C TBool CFreestyleMessageHeaderURLEventHandler::HandleEventL( const TDesC& aUri )
@@ -66,110 +120,112 @@
     
     if ( ! CFreestyleMessageHeaderURL::IsMessageHeaderURL( aUri ) )
         {
+        //Handle http and https links
+        if( ( aUri.FindF( KURLHttpPrefix ) ) == 0 
+        		||( aUri.FindF( KURLHttpsPrefix ) ) == 0 )
+        	{
+        	if ( iUrl )
+        		{
+        		delete iUrl;
+        		iUrl = NULL;
+        		}
+        	iUrl = aUri.AllocL();
+        	LaunchWebAddressMenu( );
+        	return ETrue;
+        	}         
+        //Link wasn't handled
         return EFalse;
         }
     else
         {
         //URL is of the message header format, hence parse it
         iMessageHeaderURL->InternalizeL( aUri );
-
+        iMenuVisible = ETrue;
         if ( ( iMessageHeaderURL->Type()->CompareF( KURLTypeTo ) == 0 )
              || ( iMessageHeaderURL->Type()->CompareF( KURLTypeFrom ) == 0 )
              || ( iMessageHeaderURL->Type()->CompareF( KURLTypeCc ) == 0 ) )
             {
-            LaunchEmailAddressMenuL( *iMessageHeaderURL );
+            LaunchEmailAddressMenuL( );
             }
 
         else if ( ( iMessageHeaderURL->Type()->CompareF( KURLTypeAttachment ) == 0 ) )
             {
             LaunchAttachmentMenuL( FindAttachmentL( *iMessageHeaderURL ) );
             }
-
+        iMenuVisible=EFalse;
+        if( iPendingReload )
+            {
+            //Load web page aysnchronously
+            iHTMLReloadAO->ReloadPageAysnc();
+            iPendingReload=EFalse;
+            }
         return ETrue;
         }
     }
 
 /*
- * Launches the menu and populates it with the appropriate menu items and handles the user
+ * Launches the avkon stylus popup and dims the inappropriate menu items and handles the user
  * menu item selection.
  * @param aType the type of the link the user selected
  */
-void CFreestyleMessageHeaderURLEventHandler::LaunchEmailAddressMenuL( 
-        const CFreestyleMessageHeaderURL& iMessageHeaderURL )
-    {
-    CFSEmailUiActionMenu::RemoveAllL();
-    
-    RArray<TActionMenuCustomItemId> uids;
-    CleanupClosePushL( uids );
-    uids.Append( FsEActionMenuCall );
-    uids.Append( FsEActionMenuCreateMessage );
-    uids.Append( FsEActionMenuCreateEmail );
-    uids.Append( FsEActionMenuContactDetails );
-    uids.Append( FsEActionMenuAddToContacts );
-
-    if ( iView.IsRemoteLookupSupportedL() )
-        {
-        uids.Append( FsEActionMenuRemoteLookup );
-        }
-
-
-    for ( TInt i = 0; i < uids.Count(); i++ )
-        {
-        CFSEmailUiActionMenu::AddCustomItemL( uids[i] ); ///here is where you add stuff
-        }
-
-    CleanupStack::PopAndDestroy( &uids );
-    TActionMenuCustomItemId menuResult = CFSEmailUiActionMenu::ExecuteL( EFscCenter );
-
-    if ( menuResult != FsEActionMenuCasItemSelectedAndExecuted &&
-            menuResult != FsEActionMenuDismissed    )
-        {
-        HandleEmailAddressActionMenuCommandL( menuResult, iMessageHeaderURL );
-        }
+void CFreestyleMessageHeaderURLEventHandler::LaunchEmailAddressMenuL()
+    {     
+    iEmailAddressStylusPopup->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, 
+											 !iView.IsRemoteLookupSupportedL() ); 
+    iEmailAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
+										   CAknStylusPopUpMenu::EPositionTypeRightBottom );
+    iEmailAddressStylusPopup->ShowMenu();
     }
 
-void CFreestyleMessageHeaderURLEventHandler::HandleEmailAddressActionMenuCommandL(
-    TActionMenuCustomItemId aSelectedActionMenuItem,
-    const CFreestyleMessageHeaderURL& iMessageHeaderURL )
-    {
-    TInt command( 0 );
-
-    switch ( aSelectedActionMenuItem )
-        {
-        case FsEActionMenuCreateEmail: // Create message
-            {
-            command = EFsEmailUiCmdActionsReply;
-            }
-        break;
-        case FsEActionMenuAddToContacts: // Add to Contacts
-            {
-            command = FsEActionMenuAddToContacts;
-            }
-        break;
-        case FsEActionMenuCall: // Call
-            {
-            command = EFsEmailUiCmdActionsCall;
-            }
-        break;
-        case FsEActionMenuCreateMessage: // Create message
-            {
-            command = EFsEmailUiCmdActionsCreateMessage;
-            }
-        break;
-        case FsEActionMenuContactDetails: // Contact details
-            {
-            command = EFsEmailUiCmdActionsContactDetails;
-            }
-        break;
-        case FsEActionMenuRemoteLookup: // Remote lookup
-            {
-            command = EFsEmailUiCmdActionsRemoteLookup;
-            }
-        break;
-        }
-
-    iView.HandleEmailAddressCommandL( command, *iMessageHeaderURL.ItemId() );
-    }
+//From MEikMenuObserver
+void CFreestyleMessageHeaderURLEventHandler::ProcessCommandL( TInt aCommand )
+	{
+	
+	switch ( aCommand )
+		{
+		case EFsEmailUiCmdActionsReply:
+		case EFsEmailUiCmdActionsAddContact:
+		case EFsEmailUiCmdActionsRemoteLookup:
+		case EFsEmailUiCmdActionsCopyToClipboard:
+			{
+			iView.HandleEmailAddressCommandL( aCommand, *iMessageHeaderURL->ItemId() );
+			break;
+			}
+			
+		case EFsEmailUiCmdCancelDownload:
+			{
+			iView.CancelAttachmentL( FindAttachmentL( *iMessageHeaderURL ) );
+			break;
+			}
+			
+		case EFsEmailUiCmdOpenAttachment:
+			{
+			iView.OpenAttachmentL( FindAttachmentL( *iMessageHeaderURL ) );
+			break;
+			}
+			
+		case EFsEmailUiCmdSave:
+			{
+			iView.SaveAttachmentL( FindAttachmentL( *iMessageHeaderURL ) );
+			break;
+			}
+			
+		case EFsEmailUiCmdSaveAll:
+			{
+			iView.SaveAllAttachmentsL( );
+			break;  	
+			}
+			
+		case EFsEmailUiCmdActionsOpenWeb:
+		case EFsEmailUiCmdActionsAddBookmark:
+		case EFsEmailUiCmdActionsCopyWWWAddressToClipboard:
+			{
+			iView.HandleWebAddressCommandL( aCommand, *iUrl );
+			break;
+			}
+			
+		}
+	}
 
 const TAttachmentData& CFreestyleMessageHeaderURLEventHandler::FindAttachmentL( 
         const CFreestyleMessageHeaderURL& aAttachmentUrl )
@@ -216,28 +272,32 @@
         const TAttachmentData& aAttachment )
     {
     ASSERT( iAppUi.DownloadInfoMediator() );
-    CFSEmailUiActionMenu::RemoveAllL();
+    
+    //Dim all item by default
+    iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdOpenAttachment, ETrue );
+    iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, ETrue );
+    iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, ETrue );
+    iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdCancelDownload, ETrue );   
 
     if ( iAppUi.DownloadInfoMediator()->IsDownloading( aAttachment.partData.iMessagePartId ) )
         {        
-        CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentCancelDownload ); 
+        iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdCancelDownload, EFalse );  
         }
     else if ( aAttachment.downloadProgress == KComplete )
         {
-        CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentOpen ); 
+        iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdOpenAttachment, EFalse );
         
         // block saving of embedded messages if needed.
         if ( iView.IsEmbeddedMsgView() )
             {
             if ( iView.IsEmbeddedMsgSavingAllowed() || !iAttachmentsListModel->IsMessage( aAttachment ) )
                 {
-                CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentSave );    
-                } 
-             
+                iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, EFalse );    
+                }              
             }
         else
             {
-            CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentSave ); 
+            iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, EFalse );
             }
         
         if ( iAttachmentsListModel->GetModel().Count() > 1 )
@@ -246,68 +306,43 @@
             // are any message type attachments. This is due to limitations of Activesync plugin.
             if( !(iView.IsEmbeddedMsgView() && iAttachmentsListModel->IsThereAnyMessageAttachments()) )
                 {
-                CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentSaveAll );            
-                }
-            
+                iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, EFalse );    
+                }            
             }         
         }
     else
         {
-        CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentOpen ); 
-        CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentSave ); 
+        iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdOpenAttachment, EFalse );
+        iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSave, EFalse ); 
         if ( iAttachmentsListModel->GetModel().Count() > 1 )
             {
-            CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentSaveAll ); 
+            iAttachmentStylusPopup->SetItemDimmed( EFsEmailUiCmdSaveAll, EFalse );
             }         
         }
-
-    TActionMenuCustomItemId menuResult = CFSEmailUiActionMenu::ExecuteL( EFscCenter );
-
-    if ( menuResult != FsEActionMenuCasItemSelectedAndExecuted &&
-            menuResult != FsEActionMenuDismissed    )
-        {
-        HandAttachmentActionMenuCommandL( menuResult, aAttachment );
-        }
+    iAttachmentStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
+    								     CAknStylusPopUpMenu::EPositionTypeRightBottom );
+    iAttachmentStylusPopup->ShowMenu();
     }
 
-void CFreestyleMessageHeaderURLEventHandler::HandAttachmentActionMenuCommandL( 
-        TActionMenuCustomItemId aSelectedActionMenuItem,
-        const TAttachmentData& aAttachment )
+//Open the Avkon stylus popup when a web address link was pressed
+void CFreestyleMessageHeaderURLEventHandler::LaunchWebAddressMenu()
     {
-    switch ( aSelectedActionMenuItem )
-        {
-        case FsEActionAttachmentCancelDownload:
-            iView.CancelAttachmentL( aAttachment );
-            break;
-            
-        case FsEActionAttachmentOpen:
-            iView.OpenAttachmentL( aAttachment );
-            break;
-            
-        case FsEActionAttachmentSave:
-            iView.SaveAttachmentL( aAttachment );
-            break;
-            
-        case FsEActionAttachmentSaveAll:
-            iView.SaveAllAttachmentsL();
-            break;
-            
-        case FsEActionAttachmentClearFetchedContent:
-            iView.RemoveAttachmentContentL( aAttachment );
-            break;
-            
-        case FsEActionAttachmentDownload:
-            iView.DownloadAttachmentL( aAttachment );
-            break;
-            
-        case FsEActionAttachmentDownloadAll:
-            iView.DownloadAllAttachmentsL();
-            break;
-            
-        case FsEActionAttachmentViewAll:
-            iView.OpenAttachmentsListViewL();
-            break;            
-        }
+    iWebAddressStylusPopup->SetPosition( iAppUi.ClientRect().Center(), 
+										   CAknStylusPopUpMenu::EPositionTypeRightBottom );
+    iWebAddressStylusPopup->ShowMenu();
     }
 
+//From MEikMenuObserver
+void CFreestyleMessageHeaderURLEventHandler::SetEmphasis(CCoeControl* /*aMenuControl*/,TBool /*aEmphasis*/)
+	{
+	}
 
+void CFreestyleMessageHeaderURLEventHandler::DismissMenuAndReload()
+    {
+        CFSEmailUiActionMenu::Dismiss(ETrue);
+        iPendingReload=ETrue;
+    }
+TBool CFreestyleMessageHeaderURLEventHandler::IsMenuVisible()
+    {
+    return iMenuVisible;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/emailui/src/OverlayControl.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,208 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Symbian Foundation License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements overlay controls
+*
+*/
+
+#include "OverlayControl.h"
+
+// CONSTS
+const TReal KSolidTransparencyFactor = 2;
+
+
+COverlayControl::COverlayControl( MOverlayControlObserver* aObserver )
+: iObserver( aObserver )
+	{
+	}
+
+COverlayControl::~COverlayControl()
+	{
+    delete iBitmap;
+    delete iMask;
+    delete iSolidMask;
+	}
+
+COverlayControl* COverlayControl::NewL( CCoeControl* aParent, MOverlayControlObserver* aObserver, 
+        const TRect& aRect, TInt aBitmapId, TInt aMaskId )
+	{
+    COverlayControl* self = new (ELeave) COverlayControl( aObserver );
+	CleanupStack::PushL( self );
+	self->ConstructL( aParent, aRect, aBitmapId, aMaskId );
+    CleanupStack::Pop( self );
+	return self;
+	}
+
+void COverlayControl::ConstructL( CCoeControl* aParent, const TRect& aRect, TInt aBitmapId, TInt aMaskId )
+	{
+	iSolidMask = new(ELeave) CFbsBitmap();
+
+    CreateWindowL( aParent );
+	
+	TFileName iconFileName;
+	TFsEmailUiUtility::GetFullIconFileNameL( iconFileName );
+	AknIconUtils::CreateIconL( iBitmap,
+							   iMask,
+							   iconFileName,
+							   aBitmapId,
+							   aMaskId );
+
+	SetRect( aRect );
+    EnableDragEvents();
+	
+	ActivateL();
+	}
+
+void COverlayControl::SetRect( const TRect& aRect )
+    {
+    if( iBitmap )
+        {
+        AknIconUtils::SetSize( iBitmap, aRect.Size() );
+        }
+    if( iMask )
+        {
+        AknIconUtils::SetSize( iMask, aRect.Size() );
+        
+        // Create a solid version of the mask, too
+        TRAP_IGNORE(
+            CopyBitmapL( *iMask, *iSolidMask );
+            AdjustAlpha( *iSolidMask, KSolidTransparencyFactor );
+            );
+        
+        UpdateMask();
+        }
+    CCoeControl::SetRect( aRect );
+    }
+
+void COverlayControl::CopyBitmapL( const CFbsBitmap& aSource, CFbsBitmap& aDest )
+    {
+    TSize size = aSource.SizeInPixels();
+    TInt dataSize = aSource.DataStride() * size.iHeight;
+    User::LeaveIfError( aDest.Create( size, aSource.DisplayMode() ) );
+    
+    CFbsBitGc* bitCtx;
+    CFbsBitmapDevice* bitDev = CFbsBitmapDevice::NewL( &aDest );
+    CleanupStack::PushL( bitDev );
+    User::LeaveIfError( bitDev->CreateContext( bitCtx ) );
+    CleanupStack::PushL( bitCtx );
+    bitCtx->BitBlt( TRect( size ).iTl, &aSource );
+    CleanupStack::PopAndDestroy( 2 ); // bitCtx, bitDev
+    }
+
+void COverlayControl::AdjustAlpha( CFbsBitmap& aBitmap, TReal aFactor )
+    {
+    aBitmap.LockHeap();
+    TUint8* data = (TUint8*)aBitmap.DataAddress();
+    TSize size = aBitmap.SizeInPixels();
+    TInt dataSize = aBitmap.DataStride() * size.iHeight;
+    for( TInt i = 0; i<dataSize; i++ )
+        {
+        // multiply each pixel by aFactor
+        if( data[i] ) 
+            {
+            TInt value = aFactor * data[ i ];
+            if( value > KMaxTUint8 ) 
+                {
+                value = KMaxTUint8;
+                }
+            data[ i ] = value;
+            }
+        }
+    aBitmap.UnlockHeap();   
+    }
+
+void COverlayControl::HandlePointerEventL( const TPointerEvent& aPointerEvent )
+    {
+    CCoeControl::HandlePointerEventL( aPointerEvent );
+
+    // Do hit test for the pointer event
+    TBool hit = EFalse;
+    
+    TSize size = Size();
+    if( aPointerEvent.iPosition.iX >= 0 && 
+         aPointerEvent.iPosition.iY >= 0 &&
+         aPointerEvent.iPosition.iX < size.iWidth && 
+         aPointerEvent.iPosition.iY < size.iHeight )
+        {
+        hit = ETrue;
+        }
+    
+    if( aPointerEvent.iType == TPointerEvent::EButton1Up )
+        {
+        SetPointerCapture( EFalse );
+        UpdateButtonState( EFalse );
+        
+        // Notify the events only if released on top of the control 
+        if( iObserver && hit )
+            {
+            // Do not let leaves disturb the system
+            TRAP_IGNORE(
+                iObserver->HandleOverlayPointerEventL( this, aPointerEvent );
+                );
+            }
+        }
+    else if( aPointerEvent.iType == TPointerEvent::EButton1Down )
+        {
+        UpdateButtonState( ETrue );
+        SetGloballyCapturing( ETrue );
+        SetPointerCapture( ETrue );
+        }
+    else if( aPointerEvent.iType == TPointerEvent::EDrag )
+        {
+        // Update the button UI according to hit result
+        UpdateButtonState( hit );
+        }
+    }
+
+void COverlayControl::UpdateButtonState( TBool aButtonDown )
+    {
+    if( iDownState != aButtonDown )
+        {
+        iDownState = aButtonDown;
+        UpdateMask();
+        }
+    }
+
+void COverlayControl::MakeVisible( TBool aVisible )
+    {
+    if( !aVisible )
+        {
+        UpdateButtonState( EFalse );
+        SetPointerCapture( EFalse );
+        }
+    CCoeControl::MakeVisible( aVisible );
+    }
+
+void COverlayControl::UpdateMask()
+    {
+    CFbsBitmap* mask = iMask;
+    if( iDownState )
+        {
+        mask = iSolidMask;
+        }
+    if( mask )
+        {
+        Window().SetTransparencyBitmap( *mask );
+        }
+    }
+
+void COverlayControl::Draw( const TRect& ) const 
+	{
+	CWindowGc& gc = SystemGc();
+
+	if( iBitmap )
+	    {
+        TSize size = iBitmap->SizeInPixels();
+        gc.BitBlt( TPoint( 0, 0 ), iBitmap );
+	    }
+	}
--- a/emailuis/emailui/src/ceuiemaillisttouchmanager.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/ceuiemaillisttouchmanager.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -98,7 +98,7 @@
 // ---------------------------------------------------------------------------
 //
 void CEUiEmailListTouchManager::TreeListEventL(const TFsTreeListEvent aEvent,
-        const TFsTreeItemId /*aId*/)
+        const TFsTreeItemId /*aId*/, const TPoint& aPoint )
     {
     FUNC_LOG;
 
@@ -112,7 +112,7 @@
             DoHandleActionL();
             break;
         case MFsTreeListObserver::EFsTreeListItemTouchLongTap:
-            DoHandleLongTapL();
+            DoHandleLongTapL( aPoint );
             break;
         case MFsTreeListObserver::EFsTreeListItemTouchFocused:
             DoHandleTreelistFocusChangeL();
@@ -153,7 +153,7 @@
 // CEUiEmailListTouchManager::DoHandleLongTapL
 // ---------------------------------------------------------------------------
 //
-void CEUiEmailListTouchManager::DoHandleLongTapL()
+void CEUiEmailListTouchManager::DoHandleLongTapL( const TPoint& aPoint )
     {
     FUNC_LOG;
 
@@ -161,7 +161,7 @@
     switch (iVisualiser.GetFocusedControl())
         {
         case EMailListComponent:
-            iVisualiser.DoHandleListItemLongTapL();
+            iVisualiser.DoHandleListItemLongTapL( aPoint );
             break;
         default:
             //Ignore rest
--- a/emailuis/emailui/src/freestyleemailuimailboxdeleter.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/freestyleemailuimailboxdeleter.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -67,12 +67,19 @@
 void CFSEmailUiMailboxDeleter::ConstructL()
     {
     FUNC_LOG;
+    iIdle = CIdle::NewL (CIdle::EPriorityIdle);
     }
 
 CFSEmailUiMailboxDeleter::~CFSEmailUiMailboxDeleter()
     {
     FUNC_LOG;
     delete iWaitDialog;
+    iMailboxesToDelete.Close();
+    if (iIdle)
+    	{
+    	iIdle->Cancel();
+    	delete iIdle;
+    	}
     }
 
 
@@ -461,7 +468,8 @@
                 if( iMailboxesToDelete.Count() > 0 )
                     {
                     // Delete next mailbox in queue.
-                    DoDeleteNextMailboxL();
+            	    iIdle->Cancel();
+            		iIdle->Start(TCallBack(IdleCallbackL,this));
                     }
                 else
                     {
@@ -502,5 +510,16 @@
     iMailboxDeleteOperationId = iMailClient.DeleteMailBoxByUidL( nextToDelete, 
                                                                  *this );
     }
+// ---------------------------------------------------------------------------
+// IdleCallback
+// ---------------------------------------------------------------------------
+//
+TInt CFSEmailUiMailboxDeleter::IdleCallbackL(TAny* aPtr)
+	{
+	TRAPD( leaveErr,
+		   static_cast<CFSEmailUiMailboxDeleter*>
+		   (aPtr)->DoDeleteNextMailboxL(); );
+	return leaveErr;
+	}
 
 // End of file
--- a/emailuis/emailui/src/ncsattachmentfield.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/ncsattachmentfield.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -22,6 +22,7 @@
 #include <AknsUtils.h>
 #include <AknsSkinInstance.h>
 #include <FreestyleEmailUi.rsg>
+#include <touchfeedback.h>
 
 #include "FreestyleEmailUiLayoutData.h"
 #include "FreestyleEmailUiAppui.h"
@@ -30,6 +31,7 @@
 #include "ncsattachmentfield.h"
 #include "ncsutility.h"
 #include "ncsheadercontainer.h"
+#include "FSEmail.pan"
 
 
 CNcsAttachmentField* CNcsAttachmentField::NewL(
@@ -39,9 +41,9 @@
     {
     FUNC_LOG;
     CNcsAttachmentField* self =
-        new ( ELeave ) CNcsAttachmentField( aSizeObserver, aParentControl );
+        new ( ELeave ) CNcsAttachmentField( aLabelTextId, aSizeObserver, aParentControl );
     CleanupStack::PushL( self );
-    self->ConstructL( aLabelTextId );
+    self->ConstructL();
     CleanupStack::Pop( self );
     return self;
     }
@@ -49,48 +51,34 @@
 CNcsAttachmentField::~CNcsAttachmentField()
     {
     FUNC_LOG;
-    delete iAttachmentLabel;
+    iAttachmentLabels.ResetAndDestroy();
 
-    delete iAttachmentName;
-    delete iAttachmentSizeDesc;
+    delete iAttachmentNames;
+    delete iAttachmentSizes;
 
     delete iAttachmentBitmap;
     delete iAttachmentMask;
-
-    delete iActionMenuBitmap;
-    delete iActionMenuMask;
     }
 
 // -----------------------------------------------------------------------------
 // CNcsAttachmentField::CNcsAttachmentField()
 // -----------------------------------------------------------------------------
 //
-CNcsAttachmentField::CNcsAttachmentField( MNcsFieldSizeObserver* aSizeObserver,
+CNcsAttachmentField::CNcsAttachmentField( TInt aLabelTextId, 
+        MNcsFieldSizeObserver* aSizeObserver,
         CNcsHeaderContainer* aParentControl ):
     MNcsControl( aSizeObserver ),
-    iParentControl( aParentControl )
+    iParentControl( aParentControl ),
+    iLabelTextId ( aLabelTextId ),
+    iFocusedLabelIndex( KNoAttachmentLabelFocused )
     {
     FUNC_LOG;
     }
 
-void CNcsAttachmentField::ConstructL( TInt aLabelTextId )
+void CNcsAttachmentField::ConstructL()
     {
-    FUNC_LOG;
-    // create title label
-	HBufC* textBuf = StringLoader::LoadLC( aLabelTextId );
-
-	// create attachment label
-    iAttachmentLabel = new ( ELeave ) CNcsLabel( *this, NULL );
-    iAttachmentLabel->SetTextL( textBuf->Des() );
-
-	CleanupStack::PopAndDestroy( textBuf );
-
-    // <cmail> Platform layout change
+    FUNC_LOG;	
 	CreateIconsL();
-	// </cmail> Platform layout change
-	
-	UpdateFontSize();
-    UpdateColors();
     }
 
 // -----------------------------------------------------------------------------
@@ -143,7 +131,6 @@
     return 0;
     }
 
-// <cmail> Platform layout change
 // -----------------------------------------------------------------------------
 // CNcsAttachmentField::Reposition()
 // -----------------------------------------------------------------------------
@@ -151,17 +138,8 @@
 void CNcsAttachmentField::Reposition(TPoint& aPt, TInt /*aWidth*/ )
     {
     FUNC_LOG;
-    /*
-	TSize sz( aWidth, MinimumHeight() );
-	if ( Rect() != TRect( aPt, sz ) )
-	    {
-		SetExtent( aPt, sz );
-	    }
-    aPt.iY += Size().iHeight;
-    */
     SetPosition( aPt );
     }
-// </cmail> Platform layout change
 
 // -----------------------------------------------------------------------------
 // CNcsAttachmentField::GetLabelText()
@@ -173,7 +151,6 @@
 	return KNullDesC;
     }
 
-// <cmail> Platform layout change
 // ---------------------------------------------------------------------------
 // CNcsAttachmentField::LayoutLineCount
 // ---------------------------------------------------------------------------
@@ -181,9 +158,8 @@
 TInt CNcsAttachmentField::LayoutLineCount() const
     {
     FUNC_LOG;
-    return ( IsVisible() ? 1 : 0 );
+    return ( IsVisible() ? iAttachmentLabelCount : 0 );
     }
-// </cmail> Platform layout change
 
 // -----------------------------------------------------------------------------
 // CNcsAttachmentField::Draw()
@@ -195,57 +171,46 @@
     CWindowGc& gc = SystemGc();
 
     // Draw text box
-    // <cmail> Drawing removed </cmail>
-
     if ( IsFocused() )
     	{
-    	// highlight for label when focused
-	    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
-	    TRgb imageColor;
-	    if( AknsUtils::GetCachedColor( skin, imageColor,
-	    		KAknsIIDFsHighlightColors, EAknsCIFsHighlightColorsCG4 ) != KErrNone )
-	        {
-		    if( AknsUtils::GetCachedColor( skin, imageColor,
-		    		KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG2 ) != KErrNone )
-		    	{
-		        imageColor = KRgbBlue;
-		    	}
-	        }
-	    
-	    gc.SetPenStyle( CGraphicsContext::ENullPen );
-	    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
-	    gc.SetBrushColor( imageColor );
+    	TBool highlighedFound( EFalse );
+    	for ( TInt i( 0 ); !highlighedFound && i<iAttachmentLabelCount; ++i )
+    	    {
+    	    if ( iAttachmentLabels[i]->IsFocused() )
+    	        {
+    	        highlighedFound = ETrue;
+    	        // highlight for label when focused
+    	        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+    	        TRgb imageColor;
+    	        if( KErrNone != AknsUtils::GetCachedColor( 
+                        skin, imageColor,
+                        KAknsIIDFsHighlightColors, 
+                        EAknsCIFsHighlightColorsCG4 ) &&
+                    KErrNone != AknsUtils::GetCachedColor(
+                        skin, imageColor,
+                        KAknsIIDQsnHighlightColors,
+                        EAknsCIQsnHighlightColorsCG2 ) )
+    	            {
+    	            imageColor = KRgbBlue;
+    	            }
 	    
-	    TRect highlightRect( iAttachmentLabel->Rect() );
+    	        gc.SetPenStyle( CGraphicsContext::ENullPen );
+    	        gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
+    	        gc.SetBrushColor( imageColor );
 
-	    TInt sizeTextInPixels = iAttachmentLabel->Font()->TextWidthInPixels( 
-									*iAttachmentLabel->Text() );
-	    
-        highlightRect.SetWidth( sizeTextInPixels );
-        highlightRect.Grow( 0, 1 );
-	    
-	    if( AknLayoutUtils::LayoutMirrored() )
-	    	{
-	    	highlightRect.Move( Rect().Size().iWidth - 
-								highlightRect.Size().iWidth - 
-								highlightRect.iTl.iX - 2, 0 );
-	    	}
-	    
-	    gc.DrawRect( highlightRect );
+    	        TRect highlightRect( 
+    	                iAttachmentLabels[i]->TextHitAreaRect() );
+    	        highlightRect.Grow( 0, 1 );
+    	        gc.DrawRect( highlightRect );
+    	        }
+    	    }
     	}
     
     // Draw icons
     gc.SetBrushStyle( CGraphicsContext::ENullBrush );
-    // <cmail> Platform layout change
-
     gc.BitBltMasked( iAttachmentIconPos, iAttachmentBitmap, 
-    		iAttachmentBitmap->SizeInPixels(), iAttachmentMask, ETrue );
-
-    if( IsFocused() )
-    	{
-        gc.BitBltMasked( iActionMenuIconPos, iActionMenuBitmap, 
-        		iActionMenuBitmap->SizeInPixels(), iActionMenuMask, ETrue );
-    	}
+    		         iAttachmentBitmap->SizeInPixels(), 
+    		         iAttachmentMask, ETrue );
     }
 
 // -----------------------------------------------------------------------------
@@ -255,14 +220,12 @@
 void CNcsAttachmentField::SizeChanged()
     {
     FUNC_LOG;
- 
     LayoutControls();
-    // </cmail> Platform laytout change
 	UpdateFontSize();
 	UpdateColors();
-    // The attachment text needs to be updated when label size changes because it
+    // The attachment texts needs to be updated when label size changes because it
 	// may now get truncated differently.
-	TRAP_IGNORE( UpdateAttachmentTextL() );
+	TRAP_IGNORE( UpdateAttachmentTextsL() );
     }
 
 // -----------------------------------------------------------------------------
@@ -272,11 +235,8 @@
 void CNcsAttachmentField::PositionChanged()
     {
     FUNC_LOG;
-    // <cmail> Platform layout change
     LayoutControls();
     UpdateColors();
-   
-    // </cmail> Platform layout change
     }
 
 // -----------------------------------------------------------------------------
@@ -286,12 +246,6 @@
 TInt CNcsAttachmentField::MinimumHeight() const
     {
     FUNC_LOG;
-    // <cmail> Platform laytout change
-    /*
-    TNcsMeasures m = NcsUtility::Measures();
-    return m.iAifHeight + m.iAttachmentExtraHeightBottom;*/
-    //return NcsUtility::MinimumHeaderSize( Rect(), 1 ).iHeight;
-    // </cmail> Platform laytout change
     return 0;
     }
 
@@ -316,7 +270,7 @@
     }
 
 // -----------------------------------------------------------------------------
-// CNcsAttachmentField::SetContainerWindowL() const
+// CNcsAttachmentField::SetContainerWindowL()
 // -----------------------------------------------------------------------------
 //
 void CNcsAttachmentField::SetContainerWindowL( const CCoeControl& aContainer )
@@ -324,129 +278,162 @@
     FUNC_LOG;
 	CCoeControl::SetContainerWindowL( aContainer );
 
-	// Create the component array
-    InitComponentArrayL();
-	CCoeControlArray& controls = Components();
-	controls.SetControlsOwnedExternally( ETrue );
-	controls.AppendLC( iAttachmentLabel );
-    CleanupStack::Pop( iAttachmentLabel );
-
-    // set label properties
-	UpdateFontSize();
-
-    // Setup text alignment according the mirrored/normal layout.
-    if ( AknLayoutUtils::LayoutMirrored() )
-        {
-        iAttachmentLabel->SetAlignment( EHRightVCenter );
-        }
-    else
-        {
-        iAttachmentLabel->SetAlignment( EHLeftVCenter );
-        }
+	UpdateComponentArrayL();
 	}
 
 // -----------------------------------------------------------------------------
-// CNcsAttachmentField::SetTextL()
+// CNcsAttachmentField::UpdateComponentArrayL()
 // -----------------------------------------------------------------------------
 //
-void CNcsAttachmentField::SetTextL( const TDesC& aText )
+void CNcsAttachmentField::UpdateComponentArrayL()
     {
     FUNC_LOG;
-    delete iAttachmentName;
-    iAttachmentName = NULL;
-    delete iAttachmentSizeDesc;
-    iAttachmentSizeDesc = NULL;
-
-    iAttachmentLabel->SetTextL( aText );
-    }
-
-// -----------------------------------------------------------------------------
-// CNcsAttachmentField::SetTextL()
-// -----------------------------------------------------------------------------
-//
-void CNcsAttachmentField::SetTextL( const TDesC& aAttachmentName, const TDesC& aAttachmentSizeDesc )
-    {
-    FUNC_LOG;
-    delete iAttachmentName;
-    iAttachmentName = NULL;
-    delete iAttachmentSizeDesc;
-    iAttachmentSizeDesc = NULL;
-
-    iAttachmentName = aAttachmentName.AllocL();
-    iAttachmentSizeDesc = aAttachmentSizeDesc.AllocL();
-    UpdateAttachmentTextL();
+    InitComponentArrayL();
+    CCoeControlArray& controls = Components();
+    TInt controlsCount( controls.Count() );
+    controls.SetControlsOwnedExternally( ETrue );
+    
+    // Create the new component array items if needed
+    if ( iAttachmentLabelCount > controlsCount )
+        {
+        // append controls for new attachment labels after the existing ones
+        for ( TInt i( controlsCount ); i<iAttachmentLabelCount; ++i )
+            {
+            controls.AppendLC( iAttachmentLabels[i] );
+            CleanupStack::Pop( iAttachmentLabels[i] );
+        
+            UpdateFontSize( iAttachmentLabels[i] );
+        
+            // Align according to mirrored layout variation
+            iAttachmentLabels[i]->SetAlignment( AknLayoutUtils::LayoutMirrored() ?
+                    EHRightVCenter : EHLeftVCenter );
+            }
+        }
+    // Remove unnecessary component array items from the end
+    else if ( iAttachmentLabelCount < controlsCount )
+        {
+        for ( TInt i( controlsCount-1 ); i>=iAttachmentLabelCount ; --i )
+            {
+            controls.Remove( iAttachmentLabels[i] );
+            }
+        }
     }
 
 // -----------------------------------------------------------------------------
-// CNcsAttachmentField::UpdateAttachmentTextL()
+// CNcsAttachmentField::SetTextsLD()
 // -----------------------------------------------------------------------------
 //
-void CNcsAttachmentField::UpdateAttachmentTextL()
+void CNcsAttachmentField::SetTextsLD( 
+    CDesCArray* aAttachmentNames, CDesCArray* aAttachmentSizes )
     {
     FUNC_LOG;
-    if ( iAttachmentName && iAttachmentSizeDesc )
+    delete iAttachmentNames; 
+    iAttachmentNames = NULL;
+    iAttachmentNames = aAttachmentNames;
+    delete iAttachmentSizes;
+    iAttachmentSizes = NULL;
+    iAttachmentSizes = aAttachmentSizes;
+
+    if ( iAttachmentNames )
         {
-        // create decorated size text including the preceeding space character
-        HBufC* decoratedSize = StringLoader::LoadLC( R_FSE_VIEWER_ATTACHMENTS_LIST_SIZE, 
-                                                     *iAttachmentSizeDesc );
-        HBufC* decoratedSizeWithSpace = HBufC::NewL( decoratedSize->Length() + 
-                                                     KSpace().Length() +
-                                                     KBidiRleStartChar().Length() +
-                                                     KBidiPdfChar().Length() );
-        decoratedSizeWithSpace->Des().Append( KSpace );
-        if ( AknLayoutUtils::LayoutMirrored() )
+        __ASSERT_DEBUG( iAttachmentNames && 
+                        iAttachmentSizes && 
+                        iAttachmentNames->Count() == iAttachmentSizes->Count(), 
+                        Panic( ENcsBasicUi ) );
+ 
+        TInt attachmentLabelCountBeforeUpdate( iAttachmentLabelCount );
+    
+        UpdateAttachmentTextsL();
+    
+        // set the focused attachment label
+        if ( iAttachmentLabelCount == 0 )
             {
-            // Put size part into embedded right-to-left block to ensure correct rendering
-            // even when name part is written from left-to-right.
-            decoratedSizeWithSpace->Des().Append( KBidiRleStartChar );
-            decoratedSizeWithSpace->Des().Append( *decoratedSize );
-            decoratedSizeWithSpace->Des().Append( KBidiPdfChar );
+            // No attachments
+            iFocusedLabelIndex = KNoAttachmentLabelFocused;
             }
-        else
+        else if ( iFocusedLabelIndex >= iAttachmentLabelCount ||
+                  attachmentLabelCountBeforeUpdate < iAttachmentLabelCount )
             {
-            decoratedSizeWithSpace->Des().Append( *decoratedSize );
+            // Set the focused index to last, we get here either if the last
+            // attachment label in list was removed or a new one was added.
+            // In either case focused should be the new last attachment label.
+            iFocusedLabelIndex = iAttachmentLabelCount-1;
             }
-        CleanupStack::PopAndDestroy( decoratedSize );
-        CleanupStack::PushL( decoratedSizeWithSpace );
-
-        // clip attachment name to fit the field so that size information has enough space too.
-        const CFont& font = *iAttachmentLabel->Font();
+        // In any other case, don't re-set the focused label index
+        }
+    else // no attachments 
+        {
+        iAttachmentLabelCount = 0;
+        iFocusedLabelIndex = KNoAttachmentLabelFocused;
+        }
+    
+    UpdateComponentArrayL();
+    LayoutControls();
+    iSizeObserver->UpdateFieldSizeL();
+    }
 
-        TInt labelWidth = iAttachmentLabel->Size().iWidth;
-        TInt sizeTextInPixels = font.TextWidthInPixels( *decoratedSizeWithSpace );
-        TInt pixelsLeftForAttachmentName = labelWidth - sizeTextInPixels;
+// -----------------------------------------------------------------------------
+// CNcsAttachmentField::FocusedAttachmentLabelIndex()
+// -----------------------------------------------------------------------------
+//
+TInt CNcsAttachmentField::FocusedAttachmentLabelIndex()
+    {
+    FUNC_LOG;
+    return iFocusedLabelIndex;
+    }
 
-        HBufC* attachmentText = NULL; // will contain the complete text
-        // safe check if the size information is too wide for some reason.
-        if ( pixelsLeftForAttachmentName < 0 )
+// -----------------------------------------------------------------------------
+// CNcsAttachmentField::UpdateAttachmentTextsL()
+// -----------------------------------------------------------------------------
+//
+void CNcsAttachmentField::UpdateAttachmentTextsL()
+    {
+    FUNC_LOG;
+    // create new array of labels. 
+    iAttachmentLabelCount = 0;
+    TInt count = iAttachmentNames->MdcaCount();
+    TInt existingLabelCount = iAttachmentLabels.Count();
+    TInt i( 0 );    
+    
+    // First, set the new texts using existing attachment labels objects
+    for ( ; i<count; ++i )
+        {
+        if ( i==existingLabelCount )
             {
-            attachmentText = HBufC::NewLC( iAttachmentName->Length() + decoratedSizeWithSpace->Length() );
-            attachmentText->Des().Append( *iAttachmentName );
-            attachmentText->Des().Append( *decoratedSizeWithSpace );
-            TPtr attachmentTextBufferModDes = attachmentText->Des();
-            AknTextUtils::ClipToFit( attachmentTextBufferModDes, font, labelWidth );
+            // no more re-usable label objects in their array.. break this 
+            // loop and continue with the next one (that creates new labels)
+            break;
             }
-        else
-            { // normal case
-            HBufC* attacmentNameBuffer = iAttachmentName->AllocLC();
-            TPtr attachmentNameBufferModDes = attacmentNameBuffer->Des();
-            AknTextUtils::ClipToFit( attachmentNameBufferModDes, font, pixelsLeftForAttachmentName );
-
-            attachmentText = HBufC::NewL( attacmentNameBuffer->Length() + decoratedSizeWithSpace->Length() );
-            attachmentText->Des().Append( *attacmentNameBuffer );
-            attachmentText->Des().Append( *decoratedSizeWithSpace );
-            CleanupStack::PopAndDestroy( attacmentNameBuffer );
-            CleanupStack::PushL( attachmentText );
+        UpdateSingleAttachmentLabelTextL( iAttachmentLabels[i], i );
+        ++iAttachmentLabelCount;
+        }
+    
+    // Create new attachment labels if needed
+    if ( i<count )
+        {
+        // stringloader used to get the initial (dummy) attachment text..
+        HBufC* textBuf = StringLoader::LoadLC( iLabelTextId );
+        
+        for ( ; i<count; ++i )
+            {
+            // create and initialize (fonts & colors) new label
+            CNcsLabel* label = new ( ELeave ) CNcsLabel( *this, NULL );
+            CleanupStack::PushL( label );
+            label->SetTextL( *textBuf );
+            UpdateFontSize( label );
+            UpdateColors( label );
+            UpdateSingleAttachmentLabelTextL( label, i );
+     
+            // append then new label to attachment label array
+            iAttachmentLabels.AppendL( label );
+            CleanupStack::Pop( label );
+            ++iAttachmentLabelCount;
             }
-
-        iAttachmentLabel->SetTextL( *attachmentText );
-
-        CleanupStack::PopAndDestroy( attachmentText );
-        CleanupStack::PopAndDestroy( decoratedSizeWithSpace );
+        CleanupStack::PopAndDestroy( textBuf );
         }
     }
 
-// <cmail> Platform layout change
+
 // -----------------------------------------------------------------------------
 // CNcsAttachmentField::ResizeIcons()
 // -----------------------------------------------------------------------------
@@ -454,20 +441,16 @@
 void CNcsAttachmentField::ResizeIcons()
     {
     FUNC_LOG;
-    const TSize frontIconSize( NcsUtility::HeaderDetailIconRect( Rect(), 1, NcsUtility::EIconFront ).Size() );
+    const TSize frontIconSize( NcsUtility::HeaderDetailIconRect( 
+            Rect(), 1, NcsUtility::EIconFront ).Size() );
     if ( frontIconSize != iAttachmentBitmap->SizeInPixels() )
         {
-        AknIconUtils::SetSize( iAttachmentBitmap, frontIconSize, EAspectRatioPreservedAndUnusedSpaceRemoved );
-        AknIconUtils::SetSize( iAttachmentMask, frontIconSize, EAspectRatioPreservedAndUnusedSpaceRemoved );
-        }
-    const TSize backIconSize( NcsUtility::HeaderDetailIconRect( Rect(), 1, NcsUtility::EIconBack ).Size() );
-    if ( backIconSize != iActionMenuBitmap->SizeInPixels() )
-        {
-        AknIconUtils::SetSize( iActionMenuBitmap, backIconSize, EAspectRatioNotPreserved  );
-        AknIconUtils::SetSize( iActionMenuMask, backIconSize, EAspectRatioNotPreserved  );
+        AknIconUtils::SetSize( iAttachmentBitmap, frontIconSize, 
+                               EAspectRatioPreservedAndUnusedSpaceRemoved );
+        AknIconUtils::SetSize( iAttachmentMask, frontIconSize, 
+                               EAspectRatioPreservedAndUnusedSpaceRemoved );
         }
     }
-// </cmail> Platform layout change
 
 // -----------------------------------------------------------------------------
 // CNcsAttachmentField::FocusChanged()
@@ -477,9 +460,11 @@
 	{
     FUNC_LOG;
 	if ( IsFocused() )
-		{
-		iAttachmentLabel->SetFocus( ETrue );
-
+	    {
+	    for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i )
+	        {
+	        iAttachmentLabels[i]->SetFocus( i==iFocusedLabelIndex );
+	        }
         // make sure that control is visible on screen
 		if ( Rect().iTl.iY < 0 )
 			{
@@ -510,10 +495,12 @@
 		}
 	else
 		{
-		iAttachmentLabel->SetFocus( EFalse );
+		for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i )
+		    {
+		    iAttachmentLabels[i]->SetFocus( EFalse );
+		    }
 		}
-
-    iAttachmentLabel->SetUnderlining( IsFocused() );
+	
     UpdateColors();
     
 	if ( aDrawNow )
@@ -532,58 +519,61 @@
 //
 void CNcsAttachmentField::UpdateColors()
     {
-    // <cmail> Platform layout change
-    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
-    TRgb textColor = KRgbBlack;
-
-    if( IsFocused() )
-    	{
-        AknsUtils::GetCachedColor(
-            skin,
-            textColor,
-            KAknsIIDQsnTextColors,
-            EAknsCIQsnTextColorsCG24 );
-    	}
-    else
-    	{
-		AknsUtils::GetCachedColor(
-			skin,
-			textColor,
-			KAknsIIDQsnTextColors,
-			EAknsCIQsnTextColorsCG6 );
-    	}
-    TRAP_IGNORE( iAttachmentLabel->OverrideColorL( 
-            EColorLabelText, textColor ) );
-
-    textColor = KRgbBlack;
-
-    TInt err = AknsUtils::GetCachedColor(
-        skin,
-        textColor,
-        KAknsIIDQsnHighlightColors,
-        EAknsCIQsnHighlightColorsCG3 );
-
-    TRAP_IGNORE( iAttachmentLabel->OverrideColorL(
-        EColorLabelTextEmphasis, textColor ) );
-
-    textColor = KRgbBlack;
-
-    err = AknsUtils::GetCachedColor(
-        skin,
-        textColor,
-        KAknsIIDQsnHighlightColors,
-        EAknsCIQsnHighlightColorsCG2 );
-
-    TRAP_IGNORE( iAttachmentLabel->OverrideColorL(
-        EColorLabelHighlightFullEmphasis, textColor ) );
-    // </cmail> Platform layout change
+    FUNC_LOG;
+    for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i )
+        {
+        UpdateColors( iAttachmentLabels[i] );
+        // currently all attachments are underlined
+        iAttachmentLabels[i]->SetUnderlining( ETrue );
+        }
+    
     CFreestyleEmailUiAppUi* appUi =
         static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
     iBorderColor = appUi->LayoutHandler()->ComposerFieldBorderColor();
     iBgColor = appUi->LayoutHandler()->ComposerFieldBackgroundColor();
     }
 
-// <cmail> Platform layout change
+// -----------------------------------------------------------------------------
+// CNcsAttachmentField::UpdateColors()
+// -----------------------------------------------------------------------------
+//
+void CNcsAttachmentField::UpdateColors( CNcsLabel* aLabel )
+    {
+    FUNC_LOG;    
+    if ( aLabel )
+        {
+        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+        TRgb labelTextColor = KRgbBlack;
+        TRgb labelEmphasisColor = KRgbBlack;
+        TRgb labelHighlightFullEmphasisColor = KRgbBlack;
+    
+        AknsUtils::GetCachedColor(
+            skin,
+            labelTextColor,
+            KAknsIIDQsnTextColors,
+            aLabel->IsFocused() ? 
+                EAknsCIQsnTextColorsCG24 : EAknsCIQsnTextColorsCG6 );
+        AknsUtils::GetCachedColor(
+            skin,
+            labelEmphasisColor,
+            KAknsIIDQsnHighlightColors,
+            EAknsCIQsnHighlightColorsCG3 );
+        AknsUtils::GetCachedColor(
+            skin,
+            labelHighlightFullEmphasisColor,
+            KAknsIIDQsnHighlightColors,
+            EAknsCIQsnHighlightColorsCG2 );
+        
+        TRAP_IGNORE( aLabel->OverrideColorL( 
+            EColorLabelText, labelTextColor ) );
+        TRAP_IGNORE( aLabel->OverrideColorL(
+            EColorLabelTextEmphasis, labelEmphasisColor ) );
+        TRAP_IGNORE( aLabel->OverrideColorL(
+            EColorLabelHighlightFullEmphasis, 
+            labelHighlightFullEmphasisColor ) );
+        }
+    }
+
 // -----------------------------------------------------------------------------
 // CNcsAttachmentField::UpdateFontSize()
 // -----------------------------------------------------------------------------
@@ -591,38 +581,29 @@
 void CNcsAttachmentField::UpdateFontSize()
 	{
     FUNC_LOG;
-    /*if ( iLabelFont )
+    if ( iAttachmentLabelCount )
         {
-        ControlEnv()->ScreenDevice()->ReleaseFont( iLabelFont );
-        iLabelFont = NULL;
+        // same font used for all labels, so just get the first one's
+        iEditorFont = NcsUtility::GetLayoutFont( 
+            iAttachmentLabels[0]->Rect(), NcsUtility::ENcsHeaderDetailFont );            
         }
-
-    if ( iEditorFont )
+    for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i )
         {
-        ControlEnv()->ScreenDevice()->ReleaseFont( iEditorFont );
-        iEditorFont = NULL;
+        iAttachmentLabels[i]->SetFont( iEditorFont );
         }
+	}
 
-    // set label properties
-	TNcsMeasures m = NcsUtility::Measures();
-	if ( !iLabelFont )
-	    {
-	    TRAP_IGNORE( iLabelFont = NcsUtility::GetNearestFontL(EAknLogicalFontPrimarySmallFont,
-	    	m.iLabelFontHeightPx) );
-	    }
-
-	iTitleLabel->SetFont( iLabelFont );
-
-	if ( !iEditorFont )
-		{
-		TRAP_IGNORE( iEditorFont = NcsUtility::GetNearestFontL(EAknLogicalFontPrimarySmallFont,
-			m.iEditorFontHeightPx) );
-		}
-
-	iAttachmentLabel->SetFont( iEditorFont );*/
-    iEditorFont = NcsUtility::GetLayoutFont( iAttachmentLabel->Rect(), NcsUtility::ENcsHeaderDetailFont );
-	iAttachmentLabel->SetFont( iEditorFont );
-	}
+// -----------------------------------------------------------------------------
+// CNcsAttachmentField::UpdateFontSize()
+// -----------------------------------------------------------------------------
+//
+void CNcsAttachmentField::UpdateFontSize( CNcsLabel* aLabel )
+    {
+    FUNC_LOG;
+    iEditorFont = NcsUtility::GetLayoutFont( 
+            aLabel->Rect(), NcsUtility::ENcsHeaderDetailFont );
+    aLabel->SetFont( iEditorFont );
+    }
 
 // -----------------------------------------------------------------------------
 // CNcsAttachmentField::LayoutControls()
@@ -632,8 +613,15 @@
     {
     FUNC_LOG;
     const TRect rect( Rect() );
-    NcsUtility::LayoutDetailLabel( iAttachmentLabel, rect );
-    UpdateIconPositions( rect );
+    for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i )
+        {
+        NcsUtility::LayoutDetailLabel( iAttachmentLabels[i], rect, i );
+        if ( i == 0 )
+            {
+            // icons need to be updated for first round only
+            UpdateIconPositions( rect );
+            }
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -643,10 +631,9 @@
 void CNcsAttachmentField::UpdateIconPositions( const TRect& aRect )
     {
     FUNC_LOG;
-    iAttachmentIconPos = NcsUtility::HeaderDetailIconRect( aRect, 1, NcsUtility::EIconFront ).iTl;
-    iActionMenuIconPos = NcsUtility::HeaderDetailIconRect( aRect, 1, NcsUtility::EIconBack ).iTl;
+    iAttachmentIconPos = NcsUtility::HeaderDetailIconRect( 
+            aRect, 1, NcsUtility::EIconFront ).iTl;
     }
-// </cmail> Platform layout change
 
 // -----------------------------------------------------------------------------
 // CNcsAttachmentField::HandleResourceChange()
@@ -661,14 +648,69 @@
         {
         UpdateFontSize();
         UpdateColors();
-        // <cmail> Platform layout change
         CreateIcons();
-        // </cmail> Platform layout change
         DrawDeferred();
         }
     }
 
-// <cmail> Platform layout change
+// -----------------------------------------------------------------------------
+// CNcsAttachmentField::HandlePointerEventL()
+// -----------------------------------------------------------------------------
+//
+void CNcsAttachmentField::HandlePointerEventL( 
+        const TPointerEvent& aPointerEvent )
+    {
+    FUNC_LOG;
+    CCoeControl::HandlePointerEventL( aPointerEvent );
+    
+    if ( Rect().Contains( aPointerEvent.iPosition ) &&
+         aPointerEvent.iType == TPointerEvent::EButton1Down )
+        {
+        TBool focusedAttachmentLabelIndexChanged( EFalse );
+        TInt i( 0 );
+        for ( ; i<iAttachmentLabelCount; ++i )
+            {
+            if ( iAttachmentLabels[i]->TextHitAreaRect().Contains( 
+                    aPointerEvent.iPosition ) )
+                {
+                // tactile feedback
+                MTouchFeedback* feedback = MTouchFeedback::Instance();
+                if ( feedback )
+                    {
+                    feedback->InstantFeedback( this, ETouchFeedbackBasic );
+                    }
+                
+                if ( iFocusedLabelIndex != i )
+                    {
+                    focusedAttachmentLabelIndexChanged = ETrue;
+                    iFocusedLabelIndex =  i;
+                    }
+                break;
+                }
+            }
+
+        if ( i == iAttachmentLabelCount )
+            {
+            // Pointer event happened outside any of the labels. 
+            // Invalidate focused label index.. this will cause the next
+            // for loop to set all label focuses to EFalse.
+            iFocusedLabelIndex = KNoAttachmentLabelFocused;
+            focusedAttachmentLabelIndexChanged = ETrue;
+            }
+
+        if ( focusedAttachmentLabelIndexChanged )
+            {
+            // only redraw if focused attachment label changed
+            for ( TInt i( 0 ); i<iAttachmentLabelCount; ++i )
+                {
+                iAttachmentLabels[i]->SetFocus( i==iFocusedLabelIndex );
+                }
+            UpdateColors();
+            DrawNow();
+            }
+        }
+    }
+
 // -----------------------------------------------------------------------------
 // CNcsAttachmentField::CreateIcons()
 // -----------------------------------------------------------------------------
@@ -687,17 +729,91 @@
 void CNcsAttachmentField::CreateIconsL()
     {
     FUNC_LOG;
-    CFreestyleEmailUiAppUi* fsAppUi = static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
+    CFreestyleEmailUiAppUi* fsAppUi = 
+        static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
     delete iAttachmentBitmap; 
     iAttachmentBitmap = NULL;
     delete iAttachmentMask; 
     iAttachmentMask = NULL;
-    fsAppUi->FsTextureManager()->ProvideBitmapL( EAttachmentIcon, iAttachmentBitmap, iAttachmentMask );
-    delete iActionMenuBitmap; 
-    iActionMenuBitmap = NULL;
-    delete iActionMenuMask; 
-    iActionMenuMask = NULL;
-    fsAppUi->FsTextureManager()->ProvideBitmapL( EListControlMenuIcon, iActionMenuBitmap, iActionMenuMask );
+    fsAppUi->FsTextureManager()->ProvideBitmapL( 
+            EAttachmentIcon, iAttachmentBitmap, iAttachmentMask );
     ResizeIcons();
     }
-// </cmail> Platform layout change
+
+// -----------------------------------------------------------------------------
+// CNcsAttachmentField::UpdateSingleAttachmentLabelTextL()
+// -----------------------------------------------------------------------------
+//
+void CNcsAttachmentField::UpdateSingleAttachmentLabelTextL( 
+        CNcsLabel* aLabel, TInt aIndex )
+    {
+    FUNC_LOG;  
+    // create decorated size text including the preceeding space character
+    HBufC* decoratedSize = StringLoader::LoadLC( 
+        R_FSE_VIEWER_ATTACHMENTS_LIST_SIZE, 
+        iAttachmentSizes->MdcaPoint( aIndex ) );
+    HBufC* decoratedSizeWithSpace = HBufC::NewL( 
+        decoratedSize->Length() + 
+        KSpace().Length() +
+        KBidiRleStartChar().Length() +
+        KBidiPdfChar().Length() );
+    decoratedSizeWithSpace->Des().Append( KSpace );
+    if ( AknLayoutUtils::LayoutMirrored() )
+        {
+        // Put size part into embedded right-to-left block to ensure 
+        // correct rendering even when name part is written from 
+        // left-to-right.
+        decoratedSizeWithSpace->Des().Append( KBidiRleStartChar );
+        decoratedSizeWithSpace->Des().Append( *decoratedSize );
+        decoratedSizeWithSpace->Des().Append( KBidiPdfChar );
+        }
+    else
+        {
+        decoratedSizeWithSpace->Des().Append( *decoratedSize );
+        }
+    CleanupStack::PopAndDestroy( decoratedSize );
+    CleanupStack::PushL( decoratedSizeWithSpace );
+    
+    // clip attachment name to fit the field so that size information has
+    // enough space too.
+    const CFont& font = *aLabel->Font();
+
+    TInt labelWidth = aLabel->Size().iWidth;
+    TInt sizeTextInPixels = 
+        font.TextWidthInPixels( *decoratedSizeWithSpace );
+    TInt pixelsLeftForAttachmentName = labelWidth - sizeTextInPixels;
+
+    HBufC* attachmentText = NULL; // will contain the complete text
+    // safe check if the size information is too wide for some reason.
+    if ( pixelsLeftForAttachmentName < 0 )
+        {
+        attachmentText = HBufC::NewLC( 
+                iAttachmentNames->MdcaPoint( aIndex ).Length() 
+                + decoratedSizeWithSpace->Length() );
+        attachmentText->Des().Append( iAttachmentNames->MdcaPoint( aIndex ) );
+        attachmentText->Des().Append( *decoratedSizeWithSpace );
+        TPtr attachmentTextBufferModDes = attachmentText->Des();
+        AknTextUtils::ClipToFit( attachmentTextBufferModDes, 
+                                 font, labelWidth );
+        }
+    else
+        { // normal case
+        HBufC* attacmentNameBuffer = 
+            iAttachmentNames->MdcaPoint( aIndex ).AllocLC();
+        TPtr attachmentNameBufferModDes = attacmentNameBuffer->Des();
+        AknTextUtils::ClipToFit( attachmentNameBufferModDes, 
+                                 font, pixelsLeftForAttachmentName );
+
+        attachmentText = HBufC::NewL( 
+                attacmentNameBuffer->Length() 
+                + decoratedSizeWithSpace->Length() );
+        attachmentText->Des().Append( *attacmentNameBuffer );
+        attachmentText->Des().Append( *decoratedSizeWithSpace );
+        CleanupStack::PopAndDestroy( attacmentNameBuffer );
+        CleanupStack::PushL( attachmentText );
+        }
+    aLabel->SetTextL( *attachmentText );
+    CleanupStack::PopAndDestroy( attachmentText );
+    CleanupStack::PopAndDestroy( decoratedSizeWithSpace );
+    }
+
--- a/emailuis/emailui/src/ncscomposeview.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/ncscomposeview.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -21,9 +21,8 @@
 #include <NpdApi.h>
 #include <StringLoader.h>
 #include <txtrich.h>
-#include <AknWaitDialog.h> //<cmail>
-#include <MsgAttachmentUtils.h>//<cmail>
-//<cmail>
+#include <AknWaitDialog.h>
+#include <MsgAttachmentUtils.h>
 #include <featmgr.h>
 #include "CFSMailBox.h"
 #include "CFSMailMessage.h"
@@ -31,14 +30,12 @@
 #include "CFSMailClient.h"
 #include "CFSMailCommon.h"
 #include <csxhelp/cmail.hlp.hrh>
-//</cmail>
-//<cmail> Touch
 #include <akntoolbar.h>
 #include <akntoolbarextension.h>
 #include <AknUtils.h>
-//</cmail> Touch
 #include <FreestyleEmailUi.rsg>
 #include <freestyleemailui.mbg>
+#include <aknstyluspopupmenu.h>
 
 #include "ncscomposeview.h"
 #include "ncscomposeviewcontainer.h"
@@ -85,8 +82,9 @@
     CFSMailClient& aMailClient, CMsvSession& aMsvSession )
     : CFsEmailUiViewBase( aSendAttachmentControlGroup, aAppUi ),
      iMailClient( aMailClient ), iOrigMessage( NULL ), iNewMessage( NULL ),
-     iMsvSession( aMsvSession ), iEnv( aEnv )
-     ,iFakeSyncGoingOn(EFalse), iFetchDialogCancelled(EFalse),iExecutingDoExitL(EFalse)//<cmail>
+     iMsvSession( aMsvSession ), iEnv( aEnv ),
+     iFakeSyncGoingOn(EFalse), iFetchDialogCancelled(EFalse),
+     iExecutingDoExitL( EFalse )
     {
     FUNC_LOG;
 
@@ -99,14 +97,16 @@
 // Two-phased constructor.
 // -----------------------------------------------------------------------------
 //
-CNcsComposeView* CNcsComposeView::NewL( CFSMailClient& aMailClient, CAlfEnv& aEnv,
-                                        CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aControlGroup,
-                                        CMsvSession& aMsvSession )
+CNcsComposeView* CNcsComposeView::NewL( 
+        CFSMailClient& aMailClient, CAlfEnv& aEnv,
+        CFreestyleEmailUiAppUi* aAppUi, CAlfControlGroup& aControlGroup,
+        CMsvSession& aMsvSession )
     {
     FUNC_LOG;
 
-    CNcsComposeView* self = CNcsComposeView::NewLC( aMailClient, aEnv, 	aAppUi,
-                                                    aControlGroup, aMsvSession );
+    CNcsComposeView* self = 
+        CNcsComposeView::NewLC( aMailClient, aEnv, 	aAppUi,
+                                aControlGroup, aMsvSession );
     CleanupStack::Pop( self );
 
     return self;
@@ -126,7 +126,8 @@
     {
     FUNC_LOG;
 
-    CNcsComposeView* self = new ( ELeave ) CNcsComposeView( *aAppUi, aEnv, aControlGroup, aMailClient, aMsvSession );
+    CNcsComposeView* self = new ( ELeave ) CNcsComposeView( 
+            *aAppUi, aEnv, aControlGroup, aMailClient, aMsvSession );
     CleanupStack::PushL( self );
     self->ConstructL();
 
@@ -146,14 +147,18 @@
     iFirstStartCompleted = EFalse;
     }
 
-// CFSEmailUiMsgDetailsVisualiser::DoFirstStartL()
+// -----------------------------------------------------------------------------
+// CNcsComposeView::DoFirstStartL()
 // Purpose of this function is to do first start only when msg details is
 // really needed to be shown. Implemented to make app startuo faster.
+// -----------------------------------------------------------------------------
+//
 void CNcsComposeView::DoFirstStartL()
     {
     FUNC_LOG;
-    // Attachment list for compose screen
-    CAlfControlGroup& attListControlGroup = iEnv.NewControlGroupL( KSendAttachmentManagerDisplayGroup ); // owned by AlfEnv
+    // Attachment list for compose screen, owned by AlfEnv
+    CAlfControlGroup& attListControlGroup = 
+        iEnv.NewControlGroupL( KSendAttachmentManagerDisplayGroup );
     CFSEmailUiSendAttachmentsListVisualiser* sendAttachmentVisualiser =
 		CFSEmailUiSendAttachmentsListVisualiser::NewLC(
             iEnv, &iAppUi, attListControlGroup );
@@ -171,9 +176,22 @@
     iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityLow );
     // msk context menu added into composer
     MenuBar()->SetContextMenuTitleResourceId( R_NCS_COMPOSE_BODY_MSK_MENUBAR );
-    iActiveHelper = CActiveHelper::NewL(this);
+    iActiveHelper = CActiveHelper::NewL( this );
 
-    iAsyncAttachmentAdd = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
+    iAsyncAttachmentAdd = 
+        new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
+    
+    // Initializing the default stylus long tap popup menu
+	if( !iStylusPopUpMenu )
+		{
+		TPoint point( 0, 0 );
+		iStylusPopUpMenu = CAknStylusPopUpMenu::NewL( this, point );
+		TResourceReader reader;
+		iCoeEnv->CreateResourceReaderLC( reader,
+				R_STYLUS_POPUP_MENU_COMPOSE_VIEW_ATTACHMENT );
+		iStylusPopUpMenu->ConstructFromResourceL( reader );
+		CleanupStack::PopAndDestroy(); // reader
+		}
     }
 
 // -----------------------------------------------------------------------------
@@ -191,16 +209,17 @@
 	    delete iAsyncCallback;
 	    }
     delete iFetchLogic;
-    if(iActiveHelper)
+    if( iActiveHelper )
         {
         iActiveHelper->Cancel();
         delete iActiveHelper;
         }
-    if (iAsyncAttachmentAdd)
+    if ( iAsyncAttachmentAdd )
         {
         iAsyncAttachmentAdd->Cancel();
         delete iAsyncAttachmentAdd;
         }
+    delete iStylusPopUpMenu;
     }
 
 void CNcsComposeView::PrepareForExit()
@@ -212,27 +231,25 @@
         TRAP_IGNORE( iDlg->OfferKeyEventL( check, EEventKey ) );
         iDlg = NULL;
 
-        iAsyncCallback->Cancel(); // cancel any outstanding callback just to be safe
+        iAsyncCallback->Cancel(); // cancel any outstanding callback
         iAsyncCallback->Set( TCallBack( AsyncExit, this ) );
         iAsyncCallback->CallBack();
         }
-    else if(iFakeSyncGoingOn || iExecutingDoExitL) //we starts this low priority active obj so that iwait in plugins finish
+    else if( iFakeSyncGoingOn || iExecutingDoExitL )
         {
+        // low priority active obj so that iwait in plugins finish
         iActiveHelper->Cancel();
         iActiveHelper->Start();
         }
     else
         {
         DoSafeExit( ESaveDraft );
-        //iAppUi.Exit();
         }
 
-    if(iFetchLogic)
+    if( iFetchLogic )
         {
         iFetchLogic->CancelFetchings();
         }
-
-    //ResetComposer(); // already done in DoExitL
     }
 
 // -----------------------------------------------------------------------------
@@ -251,24 +268,21 @@
 // Activate the Compose view
 // -----------------------------------------------------------------------------
 //
-// <cmail> Toolbar
-/*void CNcsComposeView::DoActivateL( const TVwsViewId& aPrevViewId,
-    TUid aCustomMessageId, const TDesC8& aCustomMessage )*/
 void CNcsComposeView::ChildDoActivateL( const TVwsViewId& aPrevViewId,
     TUid aCustomMessageId, const TDesC8& aCustomMessage )
-// </cmail> Toolbar
     {
     FUNC_LOG;
     if ( !iFirstStartCompleted )
         {
         DoFirstStartL();
         }
-    Toolbar()->SetDimmed(ETrue);
+    Toolbar()->SetDimmed( ETrue );
     // Set status pane indicators
     iStatusPaneIndicators = iAppUi.GetStatusPaneIndicatorContainer();
     iStatusPaneIndicators->ShowStatusPaneIndicators();
 
-    // Notify base class about view being entered unless we returned from another view
+    // Notify base class about view being entered unless 
+    // returned from another view
     if ( aCustomMessageId.iUid != KEditorCmdReturnToPrevious )
         {
         ViewEntered( aPrevViewId );
@@ -280,7 +294,8 @@
     // Get the launch parameters
     if ( aCustomMessageId.iUid == KEditorCmdReturnToPrevious )
         {
-        // Use previous launch parameters when returning to previously open message
+        // Use previous launch parameters when returning to previously 
+        // opened message
         iMailBox = iMailClient.GetMailBoxByUidL( iLaunchParams.iMailboxId );
         }
     else if ( aCustomMessage.Length() > 0 )
@@ -297,10 +312,11 @@
         iLaunchParams.iActivatedExternally = ETrue;
         }
 
-    // Inform the AppUi about external view activation to fix the view stack. Normally
-    // this happens based on the previous view AppUid in the BaseView but in case
-    // contacts action menu was used within FsEmail, this doesn' work. It doesn't
-    // hurt to call this again even if it was already called once from BaseView.
+    // Inform the AppUi about external view activation to fix the view stack.
+    // Normally this happens based on the previous view AppUid in the BaseView
+    // but in case contacts action menu was used within FsEmail, this doesn' 
+    // work. It doesn't hurt to call this again even if it was already called
+    // once from BaseView.
     if ( iLaunchParams.iActivatedExternally )
         {
         iAppUi.ViewActivatedExternallyL( Id() );
@@ -315,7 +331,8 @@
         // MSV id is passed to us when account is defined email key settings
         if ( aCustomMessageId != TUid::Null() )
             {
-            TRAP( error, iMailBox = TFsEmailUiUtility::GetMailboxForMtmIdL( iMailClient, iMsvSession, aCustomMessageId.iUid ) );
+            TRAP( error, iMailBox = TFsEmailUiUtility::GetMailboxForMtmIdL( 
+                    iMailClient, iMsvSession, aCustomMessageId.iUid ) );
             }
 
         error = KErrNone;
@@ -323,7 +340,8 @@
         // try to use mailbox set as default in MCE
         if ( !iMailBox )
             {
-            TRAP( error, iMailBox = TFsEmailUiUtility::GetMceDefaultMailboxL( iMailClient, iMsvSession ) );
+            TRAP( error, iMailBox = TFsEmailUiUtility::GetMceDefaultMailboxL(
+                    iMailClient, iMsvSession ) );
             }
 
         // use first mail account from the list
@@ -335,7 +353,8 @@
             iMailClient.ListMailBoxes( id, mailboxes );
             if ( mailboxes.Count() > 0 )
                 {
-                iMailBox = iMailClient.GetMailBoxByUidL( mailboxes[0]->GetId() );
+                iMailBox = 
+                    iMailClient.GetMailBoxByUidL( mailboxes[0]->GetId() );
                 }
             CleanupStack::PopAndDestroy( &mailboxes );
             }
@@ -362,17 +381,21 @@
         err = iMailFetchingErrCode;
         }
 
-    if ( err == KErrCancel || err == KErrCouldNotConnect || err == KErrConnectionTerminated )
+    if ( err == KErrCancel || 
+         err == KErrCouldNotConnect || 
+         err == KErrConnectionTerminated )
         {
-        // Just close composer without any notes if operation was cancelled. For connection
-        // errors, DownloadInfoMediator already shows error message, so no need to show another one.
+        // Just close composer without any notes if operation was cancelled.
+        // For connection errors, DownloadInfoMediator already shows error 
+        // message, so no need to show another one.
         ExitComposer();
         }
     else if ( err )
         {
         // some other error => show generic error note and close composer
-        if(!iAppUi.AppUiExitOngoing()) //<cmail>
-            TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
+        if( !iAppUi.AppUiExitOngoing() )
+            TFsEmailUiUtility::ShowErrorNoteL( 
+                R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
         ExitComposer();
         }
     else
@@ -382,7 +405,7 @@
         iAppUi.StartEndKeyCapture();
         iContainer->SetMskL();
         iViewReady = ETrue;
-        Toolbar()->SetDimmed(EFalse);
+        Toolbar()->SetDimmed( EFalse );
         RefreshToolbar();
         }
     }
@@ -395,10 +418,10 @@
     {
     FUNC_LOG;
     bool attachmentAddition = EFalse;
-    switch (aCommand)
+    switch ( aCommand )
         {
         case EFsEmailUiTbCmdSend:
-            if (iContainer && iContainer->AreAddressFieldsEmpty())
+            if ( iContainer && iContainer->AreAddressFieldsEmpty() )
                 {
                 RefreshToolbar();
                 }
@@ -408,7 +431,7 @@
                 }
             break;
         case EFsEmailUiTbCmdAddRecipient:
-            if (iContainer)
+            if ( iContainer )
                 {
                 iContainer->AppendAddressesL();
                 }
@@ -440,15 +463,14 @@
         default:
             break;
         }
-    if (attachmentAddition)
+    if ( attachmentAddition )
         {
-        iAsyncAttachmentAdd->Cancel(); // cancel any outstanding callback just to be safe
+        iAsyncAttachmentAdd->Cancel(); // cancel any outstanding callback
         iAsyncAttachmentAdd->Set( TCallBack( AsyncAddAttachment, this ) );
         iAsyncAttachmentAdd->CallBack();
         }
     }
 
-// <cmail> Toolbar
 // -----------------------------------------------------------------------------
 // CNcsComposeView::ToolbarResourceId()
 // -----------------------------------------------------------------------------
@@ -468,10 +490,10 @@
     {
     FUNC_LOG;
     aDimmedItems.Reset();
-    switch (aResourceId)
+    switch ( aResourceId )
         {
         case R_FREESTYLE_EMAIL_UI_TOOLBAR_MESSAGE_EDITOR:
-            aDimmedItems.AppendL(EFsEmailUiTbCmdSend);
+            aDimmedItems.AppendL( EFsEmailUiTbCmdSend );
             break;
         default:
             break;
@@ -485,14 +507,17 @@
 void CNcsComposeView::RefreshToolbar()
     {
     FUNC_LOG;
-    if (iContainer)
+    if ( iContainer )
         {
-        // DimAllOptions if remotesearch is in progress, cos it takes you in a different view
+        // DimAllOptions if remotesearch is in progress, 
+        // because it takes you into a different view
         TBool dimAllOptions = iContainer->IsRemoteSearchInprogress();
         SetToolbarItemDimmed( EFsEmailUiTbCmdExpandInsert, dimAllOptions );
         SetToolbarItemDimmed( EFsEmailUiTbCmdSend,
                 iContainer->AreAddressFieldsEmpty() );
-        if ( (iContainer->IsFocusBcc() || iContainer->IsFocusCc() || iContainer->IsFocusTo()) && !dimAllOptions )
+        if ( (iContainer->IsFocusBcc() || 
+              iContainer->IsFocusCc() || 
+              iContainer->IsFocusTo() ) && !dimAllOptions )
             {
             SetToolbarItemDimmed( EFsEmailUiTbCmdAddRecipient, EFalse );
             }
@@ -502,7 +527,6 @@
             }
         }
     }
-// </cmail> Toolbar
 
 
 // -----------------------------------------------------------------------------
@@ -547,14 +571,13 @@
     __ASSERT_DEBUG( iMailBox, Panic( ENcsBasicUi ) );
     __ASSERT_DEBUG( iNewMessage, Panic( ENcsBasicUi ) );
 
-    //<cmail>
-    //we are forbiding to change MSK label, cause popup will be opend 
-    iContainer->SwitchChangeMskOff(ETrue);
-    //</cmail>
+    //we are forbiding to change MSK label, because popup will be opened 
+    iContainer->SwitchChangeMskOff( ETrue );
     
     if ( aResourceId == R_NCS_COMPOSE_MENU )
         {
-	    if (FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ))
+	    if ( FeatureManager::FeatureSupported( 
+	            KFeatureIdFfCmailIntegration ) )
 		   {
 		   // remove help support in pf5250
 		   aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue);      
@@ -566,13 +589,15 @@
 	    	aMenuPane->DeleteMenuItem( ENcsCmdSend );
 		    }
 
-	    // If no attachments currently, delete the remove attachments menu item
+	    // If no attachments, delete the remove attachments menu item
 		CFreestyleEmailUiSendAttachmentsListControl* attachmentControl;
 		attachmentControl = AttachmentsListControl();
 		TInt count = attachmentControl->Model()->Count();
 
-        // if mail has remote attachments then attachments can't be removed via options menu
-		if ( count <= 0 || AttachmentsListControl()->Model()->HasReadOnlyAttachments() )
+        // if mail has remote attachments then attachments can't be 
+		// removed via options menu
+		if ( count <= 0 || 
+		     AttachmentsListControl()->Model()->HasReadOnlyAttachments() )
 	    	{
     		aMenuPane->DeleteMenuItem( ENcsCmdRemoveAttachment );
     		aMenuPane->DeleteMenuItem( ENcsCmdRemoveAllAttachments );
@@ -659,7 +684,8 @@
     {
     FUNC_LOG;
 
-    // Attempt to handle commands only after view is fully activated and exit has not yet been initiated.
+    // Attempt to handle commands only after view is fully activated and exit
+    // has not yet been initiated.
     if ( iViewReady && !iAppUi.ViewSwitchingOngoing() )
         {
         __ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
@@ -670,13 +696,15 @@
             {
             case ENcsCmdSend:
                 {
-                // Show query if the Subject field is empty (default text is as subject)
+                // Show query if the Subject field is empty
                 if ( iContainer->IsSubjectFieldEmpty() )
                     {
-                    TInt answer = TFsEmailUiUtility::ShowConfirmationQueryL( R_FREESTYLE_EMAIL_QUERY_NO_SUBJECT );
+                    TInt answer = TFsEmailUiUtility::ShowConfirmationQueryL(
+                            R_FREESTYLE_EMAIL_QUERY_NO_SUBJECT );
                     if ( !answer )
                         {
-                        // user didn't want to send yet -> go back to the message
+                        // user didn't want to send yet
+                        // -> go back to the message
                         return;
                         }
                     }
@@ -689,14 +717,17 @@
                     if ( !TFsEmailUiUtility::IsOfflineModeL() )
                         {
                         // when sync status is currently ONLINE
-                        confMessage = StringLoader::LoadLC( R_FREESTYLE_EMAIL_CONFIRM_NOTE_SENDING_QUEUED );
+                        confMessage = StringLoader::LoadLC( 
+                                R_FREESTYLE_EMAIL_CONFIRM_NOTE_SENDING_QUEUED );
                         }
                     else
                         {
                         // when sync status is currently OFFLINE
-                        confMessage = StringLoader::LoadLC( R_FREESTYLE_EMAIL_CONFIRM_NOTE_QUEUED_UNTIL_ONLINE );
+                        confMessage = StringLoader::LoadLC( 
+                                R_FREESTYLE_EMAIL_CONFIRM_NOTE_QUEUED_UNTIL_ONLINE );
                         }
-                    CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote( ETrue ); //waiting
+                    CAknConfirmationNote* note = 
+                        new (ELeave) CAknConfirmationNote( ETrue ); //waiting
                     note->SetTimeout( CAknNoteDialog::ELongTimeout );
                     note->ExecuteLD( *confMessage );
                     CleanupStack::PopAndDestroy( confMessage );
@@ -705,19 +736,24 @@
                 else if ( error == KErrBadName )
                 	{
                   	// sending failed because recipient address was invalid
-                	TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_CONFIRM_NOTE_INVALID_EMAIL_ADDRESS, ETrue );
+                	TFsEmailUiUtility::ShowErrorNoteL( 
+                        R_FREESTYLE_EMAIL_CONFIRM_NOTE_INVALID_EMAIL_ADDRESS,
+                        ETrue );
                 	}
                 else
                 	{
                 	// sending failed for some other reason
-                    TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_CONFIRM_NOTE_MESSAGE_NOT_SENT, ETrue );
-                	DoSafeExit(); // Exit after sending failed for other reason than KErrBadName
+                    TFsEmailUiUtility::ShowErrorNoteL( 
+                        R_FREESTYLE_EMAIL_CONFIRM_NOTE_MESSAGE_NOT_SENT,
+                        ETrue );
+                    // Exit after sending failed for other reason for other
+                    // reason than KErrBadName
+                	DoSafeExit();
                 	}
                 }
                 break;
             case ENcsCmdAddAttachment:
            	 	{
-           	 	//<cmail> Touch
                 if ( AknLayoutUtils::PenEnabled() )
                     {
                     // show the toolbar
@@ -729,15 +765,13 @@
                     }
                 else
                     {
-                    //</cmail>
                     iAttachmentAddType = MsgAttachmentUtils::EUnknown;
-                    iAsyncAttachmentAdd->Cancel(); // cancel any outstanding callback just to be safe
-                    iAsyncAttachmentAdd->Set( TCallBack( AsyncAddAttachment, this ) );
+                    iAsyncAttachmentAdd->Cancel();
+                    iAsyncAttachmentAdd->Set( 
+                            TCallBack( AsyncAddAttachment, this ) );
                     iAsyncAttachmentAdd->CallBack();
                     iContainer->SetMskL();
-                    //<cmail> Touch
                     }                
-                //</cmail>
            	 	}
                 break;
             case EFsEmailUiCmdOpenAttachment:
@@ -746,10 +780,27 @@
                 DoOpenAttachmentListL();
                 }
                 break;
-            case ENcsCmdRemoveAttachment: // remove one and only attachment
+            case ENcsCmdRemoveAttachment:
+            case EFsEmailUiCmdRemoveAttachment:
+                {
+                TInt index( iContainer->FocusedAttachmentLabelIndex() );
+                CFreestyleEmailUiSendAttachmentsListControl* ctrl =
+                    AttachmentsListControl();
+                if ( ctrl && KNoAttachmentLabelFocused != index )
+                    {
+                    ctrl->RemoveAttachmentFromListL( index );
+                    }
+                SetAttachmentLabelContentL();
+                }
+                break;
             case ENcsCmdRemoveAllAttachments:
            	 	{
-           	 	AttachmentsListControl()->RemoveAllAttachmentsL();
+           	 	CFreestyleEmailUiSendAttachmentsListControl* ctrl =
+                    AttachmentsListControl();
+           	 	if ( ctrl )
+           	 	    {
+           	 	    ctrl->RemoveAllAttachmentsL();
+           	 	    }
            	 	SetAttachmentLabelContentL();
             	}
                 break;
@@ -758,7 +809,7 @@
             	iNewMessage->ResetFlag( EFSMsgFlag_Low );
             	iNewMessage->SetFlag( EFSMsgFlag_Important );
             	iNewMessage->SaveMessageL();
-            	iStatusPaneIndicators->SetPriorityFlag(EMsgPriorityHigh);
+            	iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityHigh );
             	}
                 break;
         	case ENcsCmdPriorityNormal:
@@ -766,7 +817,7 @@
             	iNewMessage->ResetFlag( EFSMsgFlag_Low );
             	iNewMessage->ResetFlag( EFSMsgFlag_Important );
             	iNewMessage->SaveMessageL();
-            	iStatusPaneIndicators->SetPriorityFlag(EMsgPriorityNormal);
+            	iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityNormal );
     	    	}
                 break;
         	case ENcsCmdPriorityLow:
@@ -774,7 +825,7 @@
             	iNewMessage->ResetFlag( EFSMsgFlag_Important );
             	iNewMessage->SetFlag( EFSMsgFlag_Low );
             	iNewMessage->SaveMessageL();
-            	iStatusPaneIndicators->SetPriorityFlag(EMsgPriorityLow);
+            	iStatusPaneIndicators->SetPriorityFlag( EMsgPriorityLow );
     	    	}
                 break;
             case ENcsCmdShowCc:
@@ -827,14 +878,18 @@
                 if ( saveDraftError == KErrNone )
                 	{
                     // Saving successful
-                	if(!iAppUi.AppUiExitOngoing()) //<cmail>
-                	TFsEmailUiUtility::ShowInfoNoteL( R_FREESTYLE_EMAIL_CONFIRM_NOTE_SAVED_TO_DRAFTS, ETrue );
+                	if( !iAppUi.AppUiExitOngoing() )
+                	TFsEmailUiUtility::ShowInfoNoteL( 
+                        R_FREESTYLE_EMAIL_CONFIRM_NOTE_SAVED_TO_DRAFTS,
+                        ETrue );
                     }
             	else
                     {
                     // error occured in saving -> show an error message
-                    if(!iAppUi.AppUiExitOngoing()) //<cmail>
-                        TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
+                    if( !iAppUi.AppUiExitOngoing() )
+                        TFsEmailUiUtility::ShowErrorNoteL( 
+                            R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE,
+                            ETrue );
                     }
 
             	DoSafeExit( ENoSave );
@@ -862,27 +917,7 @@
                 break;
             case ENcsCmdExit:
                 {
-                // This is for a special case when SaveDeleteQuery appears and user presses immediately End key
-                // we are first checking if Queryexists ,if yes then we forward event to iDlg->offerkeyEventL and
-                // then call Asynchronously Exit method so that iDlg->OfferkeyEventL gets some time before calling
-                // Async Exit method
-                // <cmail> these things are now handeled in prepare for exit
-                /*if ( iCheckQuery )
-                    {
-                    TKeyEvent check = { EKeyEscape, EStdKeyNull, 0, 0 };
-                    TKeyResponse ret = iDlg->OfferKeyEventL(check, EEventKey );
-                    iDlg = NULL;
-
-                    iAsyncCallback->Cancel(); // cancel any outstanding callback just to be safe
-                    iAsyncCallback->Set( TCallBack( AsyncExit, this ) );
-                    iAsyncCallback->CallBack();
-                    }
-                else
-                    {
-                    DoSafeExit( ESaveDraft );*/
-                    iAppUi.Exit();
-                    //}
-                 //</cmail>
+                iAppUi.Exit();
                 }
                 break;
             default:
@@ -920,7 +955,7 @@
         User::Leave( r );
         }
 
-    // <cmail> prevent sending failure if original message is
+    // prevent sending failure if original message is
     // removed from server while replying/forwarding
 	TRAPD( flagError, SetReplyForwardFlagL() );
 
@@ -929,7 +964,6 @@
         iMailSendFailed = ETrue;
         User::Leave( flagError );
         }
-    // </cmail>
 
     iMailSent = ETrue;
 
@@ -967,18 +1001,17 @@
 
 		iDlg = new (ELeave) CAknListQueryDialog( &selectedOption );
     	iDlg->PrepareLC( R_DRAFT_QUERY_DIALOG );
-    	// CleanupStack::Pop(iDlg);
     	iDlg->SetItemTextArray( array );
     	iDlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
 
         iCheckQuery = ETrue;
         //we are forbiding to change MSK label, cause popup will be opend 
-        iContainer->SwitchChangeMskOff(ETrue);
+        iContainer->SwitchChangeMskOff( ETrue );
         TInt ret = iDlg->RunLD();
         iDlg = NULL;
 
         iCheckQuery = EFalse; 
-        iContainer->SwitchChangeMskOff(EFalse);
+        iContainer->SwitchChangeMskOff( EFalse );
 
     	if ( !ret )
     	    {
@@ -994,18 +1027,23 @@
 				if ( saveError == KErrNone )
 				    {
 				    // User wanted to save to Drafts and saving was successful
-				    if(!iAppUi.AppUiExitOngoing()) //<cmail>
-				        TFsEmailUiUtility::ShowInfoNoteL( R_FREESTYLE_EMAIL_CONFIRM_NOTE_SAVED_TO_DRAFTS, ETrue );
+				    if( !iAppUi.AppUiExitOngoing() )
+				        TFsEmailUiUtility::ShowInfoNoteL( 
+                            R_FREESTYLE_EMAIL_CONFIRM_NOTE_SAVED_TO_DRAFTS, 
+                            ETrue );
 				    }
 				else
 				    {
 
 				    // error occured in saving -> show an error message
-				    if(!iAppUi.AppUiExitOngoing()) //<cmail>
-				        TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
+				    if( !iAppUi.AppUiExitOngoing() )
+				        TFsEmailUiUtility::ShowErrorNoteL( 
+                            R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE,
+                            ETrue );
 
 				    // let's return EFalse so after completing this query
-				    // so the focus would stay in compose view (same behaviour as if Cancel was pressed )
+				    // so the focus would stay in compose view (same behaviour
+				    // as if Cancel was pressed )
 				    result = EFalse;
 				    }
 				}
@@ -1016,20 +1054,23 @@
     			if ( KErrNone != error )
     			    {
     			    }
-    	        iFakeSyncGoingOn = ETrue; //<cmail> for delete messages fake sync callscalls
+    			// for delete messages fake sync calls
+    	        iFakeSyncGoingOn = ETrue;
                 error = NcsUtility::DeleteMessage( iMailClient,
             		iMailBox->GetId(),
             		iNewMessage->GetFolderId(),
             		iNewMessage->GetMessageId() );
 
-    			if ( KErrNone == error && iMailBox->HasCapability( EFSMBoxCapaSupportsDeletedItemsFolder ) )
+    			if ( KErrNone == error && 
+    			     iMailBox->HasCapability( 
+    			             EFSMBoxCapaSupportsDeletedItemsFolder ) )
     			    {
                     error = NcsUtility::DeleteMessage( iMailClient,
                 		iMailBox->GetId(),
                 		iMailBox->GetStandardFolderId( EFSDeleted ),
                 		iNewMessage->GetMessageId() );
     			    }
-    		     iFakeSyncGoingOn = EFalse; //<cmail>
+    		     iFakeSyncGoingOn = EFalse;
 
                 if( !iAppUi.AppUiExitOngoing() )
                     {
@@ -1037,7 +1078,8 @@
                         {
                         // error occured in saving -> show an error message
                         TFsEmailUiUtility::ShowErrorNoteL( 
-                            R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
+                            R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE,
+                            ETrue );
                         }
                     else
                         {
@@ -1061,8 +1103,6 @@
     			}
                 break;
     		}
-
-    	//iCheckQuery = EFalse; //<cmail>
     	CleanupStack::PopAndDestroy( array );
         }
     else  // no question from user
@@ -1093,7 +1133,7 @@
     {
     FUNC_LOG;
 
-    CNcsComposeView* self = static_cast<CNcsComposeView*>(aSelfPtr);
+    CNcsComposeView* self = static_cast<CNcsComposeView*>( aSelfPtr );
 
     // get pointer to attachment list view
 	CFreestyleEmailUiSendAttachmentsListControl* attachmentControl;
@@ -1101,7 +1141,8 @@
 
    	// show file dialog and get file name
 	TBool ok = EFalse;
-	TRAPD( error, ok = attachmentControl->AppendAttachmentToListL(self->iAttachmentAddType) );
+	TRAPD( error, ok = attachmentControl->AppendAttachmentToListL(
+                self->iAttachmentAddType) );
 	if ( ok && error == KErrNone )
 	    {
 	    TRAPD( error, self->SetAttachmentLabelContentL() );
@@ -1121,23 +1162,27 @@
     if ( iNewMessage && TFsEmailUiUtility::IsFollowUpSupported( *iMailBox ) )
         {
         TFollowUpNewState newState =
-            TFsEmailUiUtility::SetMessageFollowupFlagL( *iNewMessage, EFalse );
+            TFsEmailUiUtility::SetMessageFollowupFlagL( 
+                    *iNewMessage, EFalse );
 
         switch ( newState )
             {
             case EFollowUp:
                 {
-                iStatusPaneIndicators->SetFollowUpFlag( CCustomStatuspaneIndicators::EFollowUp );
+                iStatusPaneIndicators->SetFollowUpFlag( 
+                        CCustomStatuspaneIndicators::EFollowUp );
                 }
                 break;
             case EFollowUpComplete:
                 {
-                iStatusPaneIndicators->SetFollowUpFlag( CCustomStatuspaneIndicators::EFollowUpComplete );
+                iStatusPaneIndicators->SetFollowUpFlag( 
+                        CCustomStatuspaneIndicators::EFollowUpComplete );
                 }
                 break;
             case EFollowUpClear:
                 {
-                iStatusPaneIndicators->SetFollowUpFlag( CCustomStatuspaneIndicators::EFollowUpNone );
+                iStatusPaneIndicators->SetFollowUpFlag( 
+                        CCustomStatuspaneIndicators::EFollowUpNone );
                 }
                 break;
             default:
@@ -1157,48 +1202,52 @@
 void CNcsComposeView::SetAttachmentLabelContentL()
     {
     FUNC_LOG;
-    if ( iFirstStartCompleted ) // Safety
+    if ( iFirstStartCompleted && iContainer )
         {
-        CFreestyleEmailUiSendAttachmentsListControl* attachmentControl;
-        attachmentControl = AttachmentsListControl();
-
+        CFreestyleEmailUiSendAttachmentsListControl* 
+            attachmentControl = AttachmentsListControl();
+        if ( !( attachmentControl && attachmentControl->Model() ) )
+            {
+            return;
+            }
+        
         // read number of attachments
         TInt count = attachmentControl->Model()->Count();
-
-        if ( count > 1 )
+        if ( count > 0 )
             {
-            TInt totalSizeInBytes = attachmentControl->Model()->TotalAttachmentSize();
-            HBufC* stringBuf = NULL;
-
-            HBufC* sizeDesc = TFsEmailUiUtility::CreateSizeDescLC( totalSizeInBytes );
-            stringBuf = StringLoader::LoadL( R_NCS_ATTACHMENTS_FIELD_TEXT,
-                                             *sizeDesc, count );
-            CleanupStack::PopAndDestroy( sizeDesc );
+            // Fill in the name and size descriptor arrays
+            CDesCArrayFlat* nameArray = new (ELeave) CDesCArrayFlat( count );
+            CleanupStack::PushL( nameArray );
+            CDesCArrayFlat* sizeArray = new (ELeave) CDesCArrayFlat( count );
+            CleanupStack::PushL( sizeArray );
 
-            CleanupStack::PushL( stringBuf );
-            iContainer->SetAttachmentLabelTextL( *stringBuf );
-            CleanupStack::PopAndDestroy( stringBuf );
+            for ( TInt i(0); i<count; ++i )
+                {
+                CFSEmailUiSendAttachmentsListModelItem* item =
+                    static_cast<CFSEmailUiSendAttachmentsListModelItem*>
+                    ( attachmentControl->Model()->Item( i ) );
+                if ( item )
+                    {
+                    nameArray->AppendL( item->FileName() );
+                    HBufC* sizeDesc = 
+                        TFsEmailUiUtility::CreateSizeDescLC( 
+                                item->FileSize() );
+                    sizeArray->AppendL( *sizeDesc );
+                    CleanupStack::PopAndDestroy( sizeDesc );
+                    }
+                }
+            iContainer->SetAttachmentLabelTextsLD( nameArray, sizeArray );
             iContainer->SetFocusToAttachmentField();
-            }
-        else if ( count == 1 )
-            {
-            CFSEmailUiSendAttachmentsListModelItem* item =
-                static_cast<CFSEmailUiSendAttachmentsListModelItem*>(
-                    attachmentControl->Model()->Item( 0 ) );
-
-            HBufC* sizeBuf = TFsEmailUiUtility::CreateSizeDescLC( item->FileSize() );
-            iContainer->SetAttachmentLabelTextL( item->FileName(), *sizeBuf );
-            CleanupStack::PopAndDestroy( sizeBuf );
-
-            iContainer->SetFocusToAttachmentField();
+            
+            CleanupStack::Pop( sizeArray );
+            CleanupStack::Pop( nameArray );
             }
         else
             {
-            iContainer->SetAttachmentLabelTextL( KNullDesC );
+            iContainer->SetAttachmentLabelTextsLD( NULL, NULL );
             iContainer->HideAttachmentLabel();
             }
         }
-
     }
 
 
@@ -1207,17 +1256,22 @@
 //
 // -----------------------------------------------------------------------------
 //
-CFreestyleEmailUiSendAttachmentsListControl* CNcsComposeView::AttachmentsListControl()
+CFreestyleEmailUiSendAttachmentsListControl* 
+CNcsComposeView::AttachmentsListControl()
 	{
     FUNC_LOG;
-    CFreestyleEmailUiSendAttachmentsListControl* attachmentControl(0);
+    CFreestyleEmailUiSendAttachmentsListControl* attachmentControl( NULL );
     if ( iFirstStartCompleted ) // Safety
         {
         CFSEmailUiSendAttachmentsListVisualiser* attachmentView =
             static_cast<CFSEmailUiSendAttachmentsListVisualiser*>(
                 iAvkonViewAppUi->View( SendAttachmentMngrViewId ) );
-        attachmentControl = static_cast<CFreestyleEmailUiSendAttachmentsListControl*>(
-            attachmentView->ViewerControl() );
+        if ( attachmentView )
+            {
+            attachmentControl = 
+                static_cast<CFreestyleEmailUiSendAttachmentsListControl*>(
+                    attachmentView->ViewerControl() );
+            }
         }
 	return attachmentControl;
 	}
@@ -1251,7 +1305,7 @@
     if ( aCustomMessageId == TUid::Uid( KEditorCmdCreateNew ) )
         {
         iOrigMessage = NULL;
-        iFakeSyncGoingOn = ETrue;//<cmail> this is actually a waited async method
+        iFakeSyncGoingOn = ETrue;
         iNewMessage = iMailBox->CreateMessageToSend();
         iFakeSyncGoingOn = EFalse;
         if ( !iNewMessage )
@@ -1260,15 +1314,17 @@
             }
         iFakeSyncGoingOn = ETrue;
         TFsEmailUiUtility::MoveMessageToDraftsL( *iMailBox, *iNewMessage );
-        iFakeSyncGoingOn = EFalse;//<cmail>
+        iFakeSyncGoingOn = EFalse;
         
-        if ( iNewMessage->GetContentType() != KFSMailContentTypeMultipartMixed )
+        if ( iNewMessage->GetContentType() != 
+             KFSMailContentTypeMultipartMixed )
             {
             iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed );
             iNewMessage->SaveMessageL();
             }
         
-        TFsEmailUiUtility::CreatePlainTextPartL( *iNewMessage, iNewMessageTextPart );
+        TFsEmailUiUtility::CreatePlainTextPartL( 
+                *iNewMessage, iNewMessageTextPart );
         IncludeMessageTextL( ETrue );
         AttachmentsListControl()->Model()->Clear();
         iContainer->SelectAllToFieldTextL();
@@ -1277,15 +1333,19 @@
               aCustomMessageId == TUid::Uid( KEditorCmdReplyAll ) )
         {
 
-        iOrigMessage = iMailClient.GetMessageByUidL( iLaunchParams.iMailboxId, iLaunchParams.iFolderId, iLaunchParams.iMsgId, EFSMsgDataStructure );
+        iOrigMessage = iMailClient.GetMessageByUidL( 
+                iLaunchParams.iMailboxId, iLaunchParams.iFolderId,
+                iLaunchParams.iMsgId, EFSMsgDataStructure );
         if ( !iOrigMessage )
             {
             User::Leave( KErrNotFound );
             }
 
         SafeDelete( iFetchLogic );
-        iFetchLogic = CFsComposerFetchLogic::NewL( iMailClient, iLaunchParams.iMailboxId,
-                iOrigMessage->GetFolderId(), iLaunchParams.iMsgId, *this, iAppUi );
+        iFetchLogic = CFsComposerFetchLogic::NewL( 
+                iMailClient, iLaunchParams.iMailboxId,
+                iOrigMessage->GetFolderId(), iLaunchParams.iMsgId, 
+                *this, iAppUi );
         ShowFetchingWaitNoteL();
         iFetchLogic->RunReplyLogicL();
 
@@ -1295,15 +1355,19 @@
     else if ( aCustomMessageId == TUid::Uid( KEditorCmdForward ) )
         {
 
-        iOrigMessage = iMailClient.GetMessageByUidL( iLaunchParams.iMailboxId, iLaunchParams.iFolderId, iLaunchParams.iMsgId, EFSMsgDataStructure );
+        iOrigMessage = iMailClient.GetMessageByUidL( 
+                iLaunchParams.iMailboxId, iLaunchParams.iFolderId, 
+                iLaunchParams.iMsgId, EFSMsgDataStructure );
         if ( !iOrigMessage )
             {
             User::Leave( KErrNotFound );
             }
 
         SafeDelete( iFetchLogic );
-        iFetchLogic = CFsComposerFetchLogic::NewL( iMailClient, iLaunchParams.iMailboxId,
-                                                   iOrigMessage->GetFolderId(), iLaunchParams.iMsgId, *this, iAppUi );
+        iFetchLogic = CFsComposerFetchLogic::NewL( 
+                iMailClient, iLaunchParams.iMailboxId,
+                iOrigMessage->GetFolderId(), iLaunchParams.iMsgId, 
+                *this, iAppUi );
         ShowFetchingWaitNoteL();
         iFetchLogic->RunForwardLogicL();
 
@@ -1311,10 +1375,13 @@
         // to CNcsComposeView::FetchLogicComplete when it is finished
         }
     else if ( aCustomMessageId == TUid::Uid( KEditorCmdOpen ) ||
-              aCustomMessageId == TUid::Uid( KEditorCmdReturnToPrevious ) ) // for now, we handle returning from attachments list just like any message opening
+              aCustomMessageId == TUid::Uid( KEditorCmdReturnToPrevious ) )
         {
-
-        iNewMessage = iMailClient.GetMessageByUidL( iLaunchParams.iMailboxId, iLaunchParams.iFolderId, iLaunchParams.iMsgId, EFSMsgDataStructure );
+        // for now, we handle returning from attachments list just like 
+        // any message opening
+        iNewMessage = iMailClient.GetMessageByUidL( 
+                iLaunchParams.iMailboxId, iLaunchParams.iFolderId, 
+                iLaunchParams.iMsgId, EFSMsgDataStructure );
         if ( !iNewMessage )
             {
             User::Leave( KErrNotFound );
@@ -1324,13 +1391,15 @@
         TInt waitNoteId = KErrNotFound;
         if ( TFsEmailUiUtility::IsMessageBodyLargeL(iNewMessage) )
             {
-            waitNoteId = TFsEmailUiUtility::ShowGlobalWaitNoteLC( R_FSE_WAIT_OPENING_TEXT );
+            waitNoteId = TFsEmailUiUtility::ShowGlobalWaitNoteLC( 
+                    R_FSE_WAIT_OPENING_TEXT );
             }
 
         iOrigMessage = NULL;
         iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed );
         iNewMessage->SaveMessageL();
-        TFsEmailUiUtility::CreatePlainTextPartL( *iNewMessage, iNewMessageTextPart );
+        TFsEmailUiUtility::CreatePlainTextPartL( 
+                *iNewMessage, iNewMessageTextPart );
         InitFieldsL();
         IncludeMessageTextL();
         AttachmentsListControl()->Model()->Clear();
@@ -1349,11 +1418,9 @@
         FUNC_LOG;
 
         iOrigMessage = NULL;
-        //<cmail> this is actually a waited async method
         iFakeSyncGoingOn = ETrue;
         iNewMessage = iMailBox->CreateMessageToSend();
         iFakeSyncGoingOn = EFalse;
-        //</cmail>
         if ( !iNewMessage )
             {
             User::Leave( KErrGeneral );
@@ -1361,14 +1428,17 @@
         iNewMessage->SetContentType( KFSMailContentTypeMultipartMixed );
         iNewMessage->SaveMessageL();
 
-        TFsEmailUiUtility::CreatePlainTextPartL( *iNewMessage, iNewMessageTextPart );
+        TFsEmailUiUtility::CreatePlainTextPartL( 
+                *iNewMessage, iNewMessageTextPart );
 
         IncludeMessageTextL( ETrue );
 
-        CFSMailAddress* toAddress = static_cast<CFSMailAddress*>( iLaunchParams.iExtra ); // not owned
+        CFSMailAddress* toAddress = 
+            static_cast<CFSMailAddress*>( iLaunchParams.iExtra ); // not owned
         RPointerArray<CNcsEmailAddressObject> toRecipients;
         CleanupResetAndDestroyClosePushL( toRecipients );
-        CNcsEmailAddressObject* ncsToAddress = NcsUtility::CreateNcsAddressL( *toAddress );
+        CNcsEmailAddressObject* ncsToAddress = 
+            NcsUtility::CreateNcsAddressL( *toAddress );
         CleanupStack::PushL( ncsToAddress );
         toRecipients.AppendL( ncsToAddress );
         CleanupStack::Pop( ncsToAddress ); // owned by toRecipients now
@@ -1390,15 +1460,17 @@
 
     __ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
 
-	HBufC* title = iEikonEnv->AllocReadResourceLC( R_NCS_QUICK_TEXT_TITLE_TEXT );
-	HBufC* buf(0);
+	HBufC* title = 
+        iEikonEnv->AllocReadResourceLC( R_NCS_QUICK_TEXT_TITLE_TEXT );
+	HBufC* buf( 0 );
 	TRAPD( err, buf = CNotepadApi::FetchTemplateL( title ) );
-	if (err == KLeaveExit)
-		{ //If end key was pressed the dialog leaves with the above error code.
-			//In that case we must leave as well or the application will become stuck
-			//as the exit will be incomplete.
-			User::Leave(err);
-		}
+	if ( err == KLeaveExit )
+	    { 
+		// If end key was pressed the dialog leaves with the above error code.
+	    // In that case we must leave as well or the application will become
+	    // stuck as the exit will be incomplete.
+	    User::Leave( err );
+	    }
 		
 	if ( buf && err == KErrNone ) // Safety check, 0 if user cancel
 		{
@@ -1449,7 +1521,8 @@
     __ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
 
     // Get TO recipients
-    RPointerArray<CFSMailAddress>& toRecipients = iNewMessage->GetToRecipients();
+    RPointerArray<CFSMailAddress>& toRecipients = 
+        iNewMessage->GetToRecipients();
     RPointerArray<CNcsEmailAddressObject> recipients;
     CleanupResetAndDestroyClosePushL( recipients );
     NcsUtility::ConvertAddressArrayL( toRecipients, recipients );
@@ -1457,13 +1530,15 @@
     CleanupStack::PopAndDestroy( &recipients );
 
     // Get CC recipients
-    RPointerArray<CFSMailAddress>& ccRecipients = iNewMessage->GetCCRecipients();
+    RPointerArray<CFSMailAddress>& ccRecipients = 
+        iNewMessage->GetCCRecipients();
     NcsUtility::ConvertAddressArrayL( ccRecipients, recipients );
     iContainer->SetCcFieldAddressesL( recipients );
     recipients.ResetAndDestroy();
 
     // Get BCC recipients
-    RPointerArray<CFSMailAddress>& bccRecipients = iNewMessage->GetBCCRecipients();
+    RPointerArray<CFSMailAddress>& bccRecipients = 
+        iNewMessage->GetBCCRecipients();
     NcsUtility::ConvertAddressArrayL( bccRecipients, recipients );
     iContainer->SetBccFieldAddressesL( recipients );
     recipients.ResetAndDestroy();
@@ -1487,7 +1562,8 @@
 //
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeView::RemoveOwnAddress( RPointerArray<CNcsEmailAddressObject>& aAddressList )
+void CNcsComposeView::RemoveOwnAddress( 
+        RPointerArray<CNcsEmailAddressObject>& aAddressList )
     {
     FUNC_LOG;
     TInt index = 0;
@@ -1509,7 +1585,8 @@
 //
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeView::IncludeMessageTextL( TBool aEnsureSpaceInBegin /*= EFalse*/ )
+void CNcsComposeView::IncludeMessageTextL( 
+        TBool aEnsureSpaceInBegin /*= EFalse*/ )
 	{
     FUNC_LOG;
 
@@ -1536,30 +1613,38 @@
             CleanupStack::PushL( body );
             }
         }
-    // If no modifications were needed, then just set body pointer to point the rawBody
+    // If no modifications were needed, then just set body pointer to point
+    // the rawBody
     if ( !body )
         {
         body = rawBody;
         rawBody = NULL;
         }
-    // Now we have possibly decorated message text in body pointer and in cleanup stack
-
-    // Divide the contents into normal body field and the read-only quote field
-    TInt readOnlyLength = iNewMessageTextPart->ReadOnlyPartSize() / 2; // convert bytes to words
-    TInt modifiableLength = body->Length() - readOnlyLength;
+    // Now we have possibly decorated message text in body pointer and
+    // in cleanup stack
 
-    // Remove one newline from the end of the modifiable body if there's read-only quote present.
-    // This is because the field boundary appears as newline on the screen. This newline
-    // is added back when saving the message.
-    TInt lfLength = KIMSLineFeed().Length();
-    if ( readOnlyLength && modifiableLength >= lfLength &&
-         body->Mid( modifiableLength-lfLength, lfLength ) == KIMSLineFeed )
-        {
-        modifiableLength -= lfLength;
-        }
-
-    iContainer->SetBodyContentL( body->Left( modifiableLength ),
-        body->Right( readOnlyLength ) );
+    // Divide the contents into normal body and the read-only quote fields
+    // Convert bytes length to words length
+    TInt readOnlyLength = iNewMessageTextPart->ReadOnlyPartSize() / 2;
+    if ( body )
+    	{
+		TInt modifiableLength = body->Length() - readOnlyLength;
+	
+		// Remove one newline from the end of the modifiable body if there's
+		// read-only quote present. This is because the field boundary appears
+		// as newline on the screen. This newline is added back when saving
+		// the message.
+		TInt lfLength = KIMSLineFeed().Length();
+		if ( readOnlyLength && modifiableLength >= lfLength &&
+			 body->Mid( modifiableLength-lfLength, lfLength ) == 
+			 KIMSLineFeed )
+			{
+			modifiableLength -= lfLength;
+			}
+	
+		iContainer->SetBodyContentL( body->Left( modifiableLength ),
+			body->Right( readOnlyLength ) );
+    	}
 
     CleanupStack::PopAndDestroy( body );
     }
@@ -1577,7 +1662,8 @@
 
 	// set subject
 	HBufC* prefix = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_FORWARD_PREFIX );
-	HBufC* formattedSubject = NcsUtility::FormatSubjectLineL( iOrigMessage->GetSubject(), *prefix );
+	HBufC* formattedSubject = NcsUtility::FormatSubjectLineL( 
+	        iOrigMessage->GetSubject(), *prefix );
 	CleanupStack::PushL( formattedSubject );
 	iContainer->SetSubjectL( *formattedSubject );
 	CleanupStack::PopAndDestroy( formattedSubject );
@@ -1647,7 +1733,8 @@
     __ASSERT_DEBUG( iContainer, Panic( ENcsBasicUi ) );
 
 	// to
- 	RPointerArray<CFSMailAddress>& toRecipients = iNewMessage->GetToRecipients();
+ 	RPointerArray<CFSMailAddress>& toRecipients = 
+        iNewMessage->GetToRecipients();
 	RPointerArray<CNcsEmailAddressObject> ncsToRecipients;
 	CleanupResetAndDestroyClosePushL( ncsToRecipients );
 	NcsUtility::ConvertAddressArrayL( toRecipients, ncsToRecipients );
@@ -1655,7 +1742,8 @@
     CleanupStack::PopAndDestroy( &ncsToRecipients );
 
 	// cc
- 	RPointerArray<CFSMailAddress>& ccRecipients = iNewMessage->GetCCRecipients();
+ 	RPointerArray<CFSMailAddress>& ccRecipients = 
+        iNewMessage->GetCCRecipients();
 	RPointerArray<CNcsEmailAddressObject> ncsCcRecipients;
     CleanupResetAndDestroyClosePushL( ncsCcRecipients );
 	NcsUtility::ConvertAddressArrayL( ccRecipients, ncsCcRecipients );
@@ -1663,7 +1751,8 @@
     CleanupStack::PopAndDestroy( &ncsCcRecipients );
 
 	// bcc
- 	RPointerArray<CFSMailAddress>& bccRecipients = iNewMessage->GetBCCRecipients();
+ 	RPointerArray<CFSMailAddress>& bccRecipients = 
+        iNewMessage->GetBCCRecipients();
 	RPointerArray<CNcsEmailAddressObject> ncsBccRecipients;
     CleanupResetAndDestroyClosePushL( ncsBccRecipients );
 	NcsUtility::ConvertAddressArrayL( bccRecipients, ncsBccRecipients );
@@ -1711,7 +1800,8 @@
 //
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeView::CommitL( TBool aParseAddresses, TFieldToCommit aFieldToCommit )
+void CNcsComposeView::CommitL( 
+        TBool aParseAddresses, TFieldToCommit aFieldToCommit )
     {
     FUNC_LOG;
     __ASSERT_DEBUG( iNewMessage, Panic( ENcsBasicUi ) );
@@ -1756,12 +1846,15 @@
 	    // get addresses from UI to MSG object
 	    RPointerArray<CFSMailAddress> toAddresses;
 	    CleanupResetAndDestroyClosePushL( toAddresses );
-	    NcsUtility::ConvertAddressArrayL( iContainer->GetToFieldAddressesL( aParseAddresses ), toAddresses );
+	    NcsUtility::ConvertAddressArrayL( 
+	            iContainer->GetToFieldAddressesL( aParseAddresses ), 
+	            toAddresses );
 	    iNewMessage->GetToRecipients().ResetAndDestroy();
 	    for ( TInt i = 0 ; i < toAddresses.Count() ; i++ )
 	    	{
 	    	iNewMessage->AppendToRecipient( toAddresses[i] );
-	        // Ownership of the message pointer was transferred from our array to iNewMessage
+	        // Ownership of the message pointer was transferred from our array
+	    	// to iNewMessage
 	        toAddresses[i] = NULL;
 	    	}
 	    CleanupStack::PopAndDestroy( &toAddresses );
@@ -1771,12 +1864,15 @@
 		{
 	    RPointerArray<CFSMailAddress> ccAddresses;
 	    CleanupResetAndDestroyClosePushL( ccAddresses );
-	    NcsUtility::ConvertAddressArrayL( iContainer->GetCcFieldAddressesL( aParseAddresses ), ccAddresses );
+	    NcsUtility::ConvertAddressArrayL( 
+	            iContainer->GetCcFieldAddressesL( aParseAddresses ), 
+	            ccAddresses );
 	    iNewMessage->GetCCRecipients().ResetAndDestroy();
 	    for ( TInt i = 0 ; i < ccAddresses.Count() ; i++ )
 	    	{
 	    	iNewMessage->AppendCCRecipient( ccAddresses[i] );
-	        // Ownership of the message pointer was transferred from our array to iNewMessage
+	        // Ownership of the message pointer was transferred from 
+	    	// our array to iNewMessage
 	        ccAddresses[i] = NULL;
 	    	}
 	    CleanupStack::PopAndDestroy( &ccAddresses );
@@ -1786,12 +1882,15 @@
 		{
 	    RPointerArray<CFSMailAddress> bccAddresses;
 	    CleanupResetAndDestroyClosePushL( bccAddresses );
-	    NcsUtility::ConvertAddressArrayL( iContainer->GetBccFieldAddressesL( aParseAddresses ), bccAddresses );
+	    NcsUtility::ConvertAddressArrayL( 
+	            iContainer->GetBccFieldAddressesL( aParseAddresses ), 
+	            bccAddresses );
 	    iNewMessage->GetBCCRecipients().ResetAndDestroy();
 	    for ( TInt i = 0; i < bccAddresses.Count() ; i++ )
 	    	{
 	    	iNewMessage->AppendBCCRecipient( bccAddresses[i] );
-	        // Ownership of the message pointer was transferred from our array to iNewMessage
+	        // Ownership of the message pointer was transferred from 
+	    	// our array to iNewMessage
 	        bccAddresses[i] = NULL;
 	    	}
 	    CleanupStack::PopAndDestroy( &bccAddresses );
@@ -1802,8 +1901,10 @@
 	    // get subject from UI to MSG object
 	    HBufC* subject = iContainer->GetSubjectLC();
 	    TPtr ptr = subject->Des();
-		// replace new line characters with spaces as Subject is normally one line only
-	    AknTextUtils::ReplaceCharacters( ptr, KLineSeparators, KReplacementChar );
+		// replace new line characters with spaces as Subject is normally
+	    // one line only
+	    AknTextUtils::ReplaceCharacters( 
+	            ptr, KLineSeparators, KReplacementChar );
 	    iNewMessage->SetSubject( *subject );
 	    CleanupStack::PopAndDestroy( subject );
 	    }
@@ -1811,7 +1912,8 @@
     if ( commitBodyField )
         {
         HBufC* body = iContainer->GetBodyContentLC();
-        TPtr bodyPtr = body->Des(); // this TPtr is needed only because of incorrect argument type in FW API, can be removed when API fixed
+        TPtr bodyPtr = body->Des(); // this TPtr is needed only because of
+        // incorrect argument type in FW API, can be removed when API fixed
         iNewMessageTextPart->SetContent( bodyPtr );
         CleanupStack::PopAndDestroy( body );
 
@@ -1855,21 +1957,19 @@
     {
     FUNC_LOG;
 
-    //<cmail>
     TBool emptyMessage = ETrue;
 
     if ( iAutoSaver && iContainer )
         {
         iAutoSaver->Enable( EFalse );
 
-        // check that there's some user input in some header field or in message body
+        // check for some user input in some header field or in message body
     	TInt attaCount = AttachmentsListControl()->Model()->Count();
         emptyMessage =  iContainer->AreAddressFieldsEmpty() &&
             iContainer->IsSubjectFieldEmpty() &&
             iContainer->GetMessageFieldLength() < 1 &&
             attaCount <= 0;
 	    }
-    //</cmail>
 
     // Consider saving the draft if the message is not completely empty
     if ( !emptyMessage )
@@ -1878,13 +1978,15 @@
             {
             TBool actionSucceeded = EFalse;
 
-            // DoSaveDraftL returns EFalse if the user query was cancelled or saving to Drafts failed
+            // DoSaveDraftL returns EFalse if the user query was cancelled
+            // or saving to Drafts failed
             TRAPD( saveDraftError, actionSucceeded = DoSaveDraftL( ETrue ) );
             if ( saveDraftError == KErrNone )
                 {
                 if ( !actionSucceeded )
                     {
-                    // return to normal action (cancel was pressed in the query)
+                    // return to normal action 
+                    // (cancel was pressed in the query)
                     iAutoSaver->Enable( ETrue );
                     return;
                     }
@@ -1898,11 +2000,13 @@
             DoSaveDraftL( EFalse );
             }
         }
-    else if ( iNewMessage ) // <cmail> message is empty; delete the draft if it has been already saved earlier
+    else if ( iNewMessage ) // message is empty 
         {
+        // delete the draft if it has been already saved earlier
         TInt err = NcsUtility::DeleteMessage( iMailClient, iMailBox->GetId(),
             iNewMessage->GetFolderId(), iNewMessage->GetMessageId() );
-        if ( !err && iMailBox->HasCapability( EFSMBoxCapaSupportsDeletedItemsFolder ) )
+        if ( !err && iMailBox->HasCapability( 
+                EFSMBoxCapaSupportsDeletedItemsFolder ) )
             {
             err = NcsUtility::DeleteMessage( iMailClient, iMailBox->GetId(),
                 iMailBox->GetStandardFolderId( EFSDeleted ),
@@ -1924,7 +2028,6 @@
             }
         }
 
-    // <cmail>
     // Clear attachment control now that message has been sent
     // othewise this will kind of leak memory by leaving attachments
     // in the list, even if they have been sent.
@@ -1934,15 +2037,12 @@
         {
         attachmentControl->Model()->Clear();
         }
-    // </cmail>
-
     ExitComposer();
-
     }
 
 // -----------------------------------------------------------------------------
 // CNcsComposeView::DoOpenAttachmentList
-// Saves current editor message to drafts and opens attachment list view
+// Opens the currently focused attachment
 // -----------------------------------------------------------------------------
 void CNcsComposeView::DoOpenAttachmentListL()
 	{
@@ -1951,138 +2051,66 @@
     CFreestyleEmailUiSendAttachmentsListControl* attachmentControl
    		= AttachmentsListControl();
 
-   	if ( attachmentControl->Model()->Count() == 1 )
-   		{
-		CFSEmailUiSendAttachmentsListModelItem* item =
-			static_cast<CFSEmailUiSendAttachmentsListModelItem*>(
-					attachmentControl->Model()->Item( 0 ) );
-		if ( !item->IsRemote() ) // we cannot open remote attachments
-		    {
-    		CFSMailMessagePart* msgPart = iNewMessage->ChildPartL( item->MailMsgPartId() );
-    		CleanupStack::PushL( msgPart );
+    TInt index( iContainer ? iContainer->FocusedAttachmentLabelIndex() 
+            : KNoAttachmentLabelFocused );
+    if ( KNoAttachmentLabelFocused != index && 
+         attachmentControl && attachmentControl->Model() )
+        {
+        CFSEmailUiSendAttachmentsListModelItem* item =
+            static_cast<CFSEmailUiSendAttachmentsListModelItem*>(
+                    attachmentControl->Model()->Item( index ) );
+            
+        if ( item && !item->IsRemote() ) // cannot open remote attachments
+            {
+            CFSMailMessagePart* msgPart = 
+                iNewMessage->ChildPartL( item->MailMsgPartId() );
+            CleanupStack::PushL( msgPart );
             TFsEmailUiUtility::OpenAttachmentL( *msgPart );
-    		CleanupStack::PopAndDestroy( msgPart );
-		    }
-   		}
-   	// open attachment list
-   	else
-   		{
-   		// set current email parameters to package buffer
-   		TEditorLaunchParams editorParams;
-   		editorParams.iMailboxId = iNewMessage->GetMailBoxId();
-   		editorParams.iMsgId = iNewMessage->GetMessageId();
-   		editorParams.iFolderId = iNewMessage->GetFolderId();
-   		editorParams.iActivatedExternally = EFalse;
-   		TPckgBuf<TEditorLaunchParams> buf( editorParams );
-
-   		// save email to drafts
-   		iAttachmentListSaveDraft = ETrue;
-   		TRAPD( saveDraftError, DoSaveDraftL( EFalse ) );
-   		if ( saveDraftError != KErrNone )
-   		    {
-   		    // error occured in saving -> show an error message
-   		    if ( !iAppUi.AppUiExitOngoing() ) //<cmail>
-   		        TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
-   		    return;
-   		    }
-
-   		// open attachment list view
-   		iAppUi.EnterFsEmailViewL(
-            SendAttachmentMngrViewId,
-            TUid::Uid( KEditorCmdOpenAttachmentsList ),
-            buf );
-   		}
-
+            CleanupStack::PopAndDestroy( msgPart );
+            }
+        }
 	}
 
 // -----------------------------------------------------------------------------
-// CNcsComposeView::LaunchAttachmentActionMenuL
-// Show action menu for the attachments line
+// CNcsComposeView::LaunchStylusPopupMenu
+// Show stylus popup menu for the attachments line
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeView::LaunchAttachmentActionMenuL()
+void CNcsComposeView::LaunchStylusPopupMenu( const TPoint& aPenEventScreenLocation )
     {
     FUNC_LOG;
-
-    // Remove old items from action menu
-    CFSEmailUiActionMenu::RemoveAllL();
-
-    // Construct item list
-    RFsEActionMenuIdList itemList;
-    CleanupClosePushL( itemList );
-
-    CFreestyleEmailUiSendAttachmentsListControl* attachmentControl =
-        AttachmentsListControl();
-    TInt count = attachmentControl->Model()->Count();
-    TBool remoteAtt = AttachmentsListControl()->Model()->HasRemoteAttachments();
-    TBool readOnlyAtt = AttachmentsListControl()->Model()->HasReadOnlyAttachments();
-
-    // Open/View all
-    if ( count == 1 && !remoteAtt )
+    
+    CFSEmailUiSendAttachmentsListModel* attachmentModel =
+        ( AttachmentsListControl() ? 
+                AttachmentsListControl()->Model() : NULL ); 
+    TInt count( attachmentModel ? attachmentModel->Count() : 0 );
+    TBool attachmentsInModel( count > 0 );
+    CFSEmailUiSendAttachmentsListModelItem* item( NULL );
+   
+    if ( attachmentsInModel )
         {
-        itemList.AppendL( FsEActionAttachmentOpen );
-        }
-    else if ( count > 1 )
-        {
-        itemList.AppendL( FsEActionAttachmentViewAll );
-        }
-
-    // Add
-    itemList.AppendL( FsEActionAttachmentAdd );
-
-    // Remove/Remove all
-    if ( !readOnlyAtt )
-        {
-        if ( count == 1 )
+        item = static_cast<CFSEmailUiSendAttachmentsListModelItem*>( 
+                attachmentModel->Item( 
+                    iContainer->FocusedAttachmentLabelIndex() ) );
+        if ( !item || item->IsRemote() )
             {
-            itemList.AppendL( FsEActionAttachmentRemove );
-            }
-        else if ( count > 1 )
-            {
-            itemList.AppendL( FsEActionAttachmentRemoveAll );
+            // Only non-remote attachments can be opened
+            iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdOpenAttachment, ETrue );
             }
         }
 
-    // Execute action list
-    TActionMenuCustomItemId itemId = CFSEmailUiActionMenu::ExecuteL( itemList );
-    CleanupStack::PopAndDestroy( &itemList );
-
-    // Handle action menu selection
-    switch ( itemId )
+    if ( !item || item->IsReadOnly() )
         {
-        case FsEActionAttachmentOpen:
-            HandleCommandL( EFsEmailUiCmdOpenAttachment );
-            break;
-        case FsEActionAttachmentViewAll:
-            HandleCommandL( EFsEmailUiCmdOpenAttachmentList );
-            break;
-        case FsEActionAttachmentRemove:
-            HandleCommandL( ENcsCmdRemoveAttachment );
-            break;
-        case FsEActionAttachmentRemoveAll:
-            HandleCommandL( ENcsCmdRemoveAllAttachments );
-            break;
-        case FsEActionAttachmentAdd:
-            HandleCommandL( ENcsCmdAddAttachment );
-            break;
-        default:
-            break;
+        // Only non-readonly attachments can be removed
+        iStylusPopUpMenu->SetItemDimmed( EFsEmailUiCmdRemoveAttachment, ETrue );
         }
 
-    }
+    // Set the position for the popup
+	iStylusPopUpMenu->SetPosition( aPenEventScreenLocation );
 
-//<cmail>
-// -----------------------------------------------------------------------------
-// CNcsComposeView::DismissAttachmentActionMenuL
-//
-// -----------------------------------------------------------------------------
-//
-void CNcsComposeView::DismissAttachmentActionMenuL()
-    {
-    FUNC_LOG;
-    CFSEmailUiActionMenu::Dismiss( ETrue );
+	// Display the popup.
+	iStylusPopUpMenu->ShowMenu();
     }
-//</cmail>
 
 // -----------------------------------------------------------------------------
 // CNcsComposeView::GetAttachmentsFromMail
@@ -2100,13 +2128,15 @@
 
 	for ( TInt i=0; i<attachments.Count(); ++i )
 		{
-        TFileType fileType = TFsEmailUiUtility::GetFileType( attachments[i]->AttachmentNameL(),
-                                                             attachments[i]->GetContentType() );
+        TFileType fileType = TFsEmailUiUtility::GetFileType( 
+                attachments[i]->AttachmentNameL(),
+                attachments[i]->GetContentType() );
 
         TBool isReadOnly = ( attachments[i]->ReadOnlyPartSize() > 0 );
         TBool isRemote = EFalse;
 
-		if ( attachments[i]->FetchedContentSize() < attachments[i]->ContentSize() )
+		if ( attachments[i]->FetchedContentSize() < 
+		     attachments[i]->ContentSize() )
 			{
 			if ( iMailBox->HasCapability( EFSMBoxCapaSmartForward ) )
 			    {
@@ -2166,7 +2196,8 @@
     __ASSERT_DEBUG( iOrigMessage, Panic( ENcsBasicUi ) );
 
 	// separator line
-	HBufC* separator = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_MESSAGE_LINE_SEPARATOR ); //1
+	HBufC* separator = 
+        StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_MESSAGE_LINE_SEPARATOR ); //1
 
 	// from line
 	RPointerArray<CNcsEmailAddressObject> senderArray;
@@ -2174,30 +2205,36 @@
     CFSMailAddress* sender = iOrigMessage->GetSender();
     if ( sender )
         {
-    	CNcsEmailAddressObject* ncsSender = NcsUtility::CreateNcsAddressL( *sender );
+    	CNcsEmailAddressObject* ncsSender = 
+            NcsUtility::CreateNcsAddressL( *sender );
     	CleanupStack::PushL( ncsSender );
 	    senderArray.AppendL( ncsSender );
 	    CleanupStack::Pop( ncsSender ); // now owned by senderArray
         }
-	HBufC* fromLine = NcsUtility::GenerateFromLineToMessageBodyL( senderArray );
+	HBufC* fromLine = 
+        NcsUtility::GenerateFromLineToMessageBodyL( senderArray );
 	CleanupStack::PopAndDestroy( &senderArray );
 	CleanupStack::PushL( fromLine ); //2
 
 	// sent line
-	HBufC* sentLine = NcsUtility::GenerateSentLineToMessageBodyL( *iOrigMessage );
+	HBufC* sentLine = 
+        NcsUtility::GenerateSentLineToMessageBodyL( *iOrigMessage );
 	CleanupStack::PushL( sentLine ); //3
 
 	// to line
 	RPointerArray<CNcsEmailAddressObject> ncsToRecipients;
 	CleanupResetAndDestroyClosePushL( ncsToRecipients );
-	RPointerArray<CFSMailAddress>& toRecipients = iOrigMessage->GetToRecipients();
+	RPointerArray<CFSMailAddress>& toRecipients = 
+        iOrigMessage->GetToRecipients();
 	NcsUtility::ConvertAddressArrayL( toRecipients, ncsToRecipients );
-	HBufC* toLine = NcsUtility::GenerateAddressLineToMessageBodyL( ncsToRecipients, NcsUtility::ERecipientTypeTo );
+	HBufC* toLine = NcsUtility::GenerateAddressLineToMessageBodyL( 
+                ncsToRecipients, NcsUtility::ERecipientTypeTo );
     CleanupStack::PopAndDestroy( &ncsToRecipients );
 	CleanupStack::PushL( toLine ); //4
 
 	// cc line
-	RPointerArray<CFSMailAddress>& ccRecipients = iOrigMessage->GetCCRecipients();
+	RPointerArray<CFSMailAddress>& ccRecipients = 
+        iOrigMessage->GetCCRecipients();
 	TBool hasCcLine = ( ccRecipients.Count() > 0 );
     HBufC* ccLine = NULL;
 	if ( hasCcLine )
@@ -2205,13 +2242,15 @@
 	    RPointerArray<CNcsEmailAddressObject> ncsCcRecipients;
 	    CleanupResetAndDestroyClosePushL( ncsCcRecipients );
 		NcsUtility::ConvertAddressArrayL( ccRecipients, ncsCcRecipients );
-		ccLine = NcsUtility::GenerateAddressLineToMessageBodyL( ncsCcRecipients, NcsUtility::ERecipientTypeCc );
+		ccLine = NcsUtility::GenerateAddressLineToMessageBodyL( 
+		        ncsCcRecipients, NcsUtility::ERecipientTypeCc );
 	    CleanupStack::PopAndDestroy( &ncsCcRecipients );
 		CleanupStack::PushL( ccLine ); //5
 		}
 
 	// subject line
-	HBufC* subjectLine = NcsUtility::GenerateSubjectLineToMessageBodyL( iOrigMessage->GetSubject() );
+	HBufC* subjectLine = NcsUtility::GenerateSubjectLineToMessageBodyL( 
+	        iOrigMessage->GetSubject() );
 	CleanupStack::PushL( subjectLine ); //6
 
     // Body
@@ -2232,7 +2271,8 @@
             {
             CleanupStack::PushL( htmlBodyPart );
 
-            HBufC* htmlData = HBufC::NewLC( htmlBodyPart->FetchedContentSize() );
+            HBufC* htmlData = 
+                HBufC::NewLC( htmlBodyPart->FetchedContentSize() );
             TPtr pointer = htmlData->Des();
             htmlBodyPart->GetContentToBufferL( pointer, 0 );
 
@@ -2338,7 +2378,8 @@
     TInt waitNoteId = KErrNotFound;
     if ( TFsEmailUiUtility::IsMessageBodyLargeL(iOrigMessage) )
         {
-        waitNoteId = TFsEmailUiUtility::ShowGlobalWaitNoteLC( R_FSE_WAIT_OPENING_TEXT );
+        waitNoteId = TFsEmailUiUtility::ShowGlobalWaitNoteLC( 
+                R_FSE_WAIT_OPENING_TEXT );
         }
 
     if ( iCustomMessageId == TUid::Uid( KEditorCmdReply ) )
@@ -2388,7 +2429,8 @@
 
 	//<cmail> this is actually a waited async method
 	iFakeSyncGoingOn = ETrue;
-    iNewMessage = iMailBox->CreateReplyMessage( iLaunchParams.iMsgId, aReplyAll, *temp );
+    iNewMessage = iMailBox->CreateReplyMessage( 
+            iLaunchParams.iMsgId, aReplyAll, *temp );
     iFakeSyncGoingOn = EFalse;
     //</cmail>
    	// Compose screen does not send cal messages, make sure
@@ -2405,7 +2447,8 @@
     	User::Leave( KErrGeneral );
     	}
     iFakeSyncGoingOn = ETrue; //<cmail>
-    TRAPD( error, TFsEmailUiUtility::MoveMessageToDraftsL( *iMailBox, *iNewMessage ) );
+    TRAPD( error, TFsEmailUiUtility::MoveMessageToDraftsL( 
+            *iMailBox, *iNewMessage ) );
     iFakeSyncGoingOn = EFalse; //</cmail>
     User::LeaveIfError( error );
 
@@ -2455,7 +2498,8 @@
     	User::Leave( KErrGeneral );
     	}
     iFakeSyncGoingOn = ETrue; //<cmail>
-    TRAPD( error, TFsEmailUiUtility::MoveMessageToDraftsL( *iMailBox, *iNewMessage ) );
+    TRAPD( error, TFsEmailUiUtility::MoveMessageToDraftsL( 
+            *iMailBox, *iNewMessage ) );
     iFakeSyncGoingOn = EFalse; //<cmail>
     User::LeaveIfError( error );
 
@@ -2465,7 +2509,8 @@
         iNewMessage->SaveMessageL();
 	    }
     
-	TFsEmailUiUtility::CreatePlainTextPartL( *iNewMessage, iNewMessageTextPart );
+	TFsEmailUiUtility::CreatePlainTextPartL( 
+	        *iNewMessage, iNewMessageTextPart );
 
     }
 
@@ -2495,14 +2540,6 @@
         {
         AppUi()->AddToStackL( iContainer );
         iContainer->SetMenuBar( Cba() );
-
-    	// <cmail>
-    	// TInt ccVisible = iCrHandler->EditorCCVisible();
-    	// iContainer->SetCcFieldVisibleL( ccVisible == 1, EFalse );
-    	// TInt bccVisible = iCrHandler->EditorBCVisible();
-    	// iContainer->SetBccFieldVisibleL( bccVisible == 1, EFalse );
-    	// </cmail>
-
         iContainer->UpdateScrollBarL();
 
         // Set title pane text
@@ -2650,8 +2687,9 @@
 
         if ( !iAppUi.AppUiExitOngoing() )
             {
-            // Simulate a new mail event to ensure that saved message becomes visible in the
-            // mail list. All protocols do not send event automatically in this case.
+            // Simulate a new mail event to ensure that saved message becomes
+            // visible in the mail list. 
+            // All protocols do not send event automatically in this case.
             RArray<TFSMailMsgId> messageIdArray;
             CleanupClosePushL( messageIdArray );
             messageIdArray.Append( iNewMessage->GetMessageId() );
@@ -2659,9 +2697,10 @@
             TFSMailMsgId mailboxId = iNewMessage->GetMailBoxId();
             iAppUi.EventL(
                 TFSEventNewMail, mailboxId, &messageIdArray, &folderId, NULL );
-            // Update displayed mail info if the mail was already created sooner
+            // Update displayed mail info if the mail was created previously
             iAppUi.EventL(
-                TFSEventMailChanged, mailboxId, &messageIdArray, &folderId, NULL );
+                TFSEventMailChanged, mailboxId, &messageIdArray, 
+                &folderId, NULL );
             CleanupStack::PopAndDestroy( &messageIdArray );
             }
         }
@@ -2671,7 +2710,8 @@
 // CNcsComposeView::FetchLogicComplete
 // -----------------------------------------------------------------------------
 //
-TBool CNcsComposeView::FetchLogicComplete( TComposerFetchState /*aState*/, TInt aError )
+TBool CNcsComposeView::FetchLogicComplete( 
+        TComposerFetchState /*aState*/, TInt aError )
 	{
     FUNC_LOG;
     TBool result = EFalse;
@@ -2685,14 +2725,14 @@
         else
             {
             // something went wrong
-            DoSafeExit(ENoSave);
+            DoSafeExit( ENoSave );
             iMailFetchingErrCode = aError;
             result = ETrue;
             }
         }
     if ( iFetchWaitDialog && !iFetchDialogCancelled )
         {
-        TRAP_IGNORE(iFetchWaitDialog->ProcessFinishedL());
+        TRAP_IGNORE( iFetchWaitDialog->ProcessFinishedL() );
         iFetchWaitDialog = NULL;
         }
     return result;
@@ -2711,7 +2751,8 @@
         iStatusPaneIndicators->HideStatusPaneIndicators();
         }
     
-    // lower flag to indicate that view is no longer able to handle user commands
+    // lower flag to indicate that view is no longer 
+    // able to handle user commands
     iViewReady = EFalse;
 
 	// view switching and alfred operations should be avoided
@@ -2722,7 +2763,8 @@
         TRAP_IGNORE( NavigateBackL() );
         }
 
-    // Cleanup message contents to prevent ChildDoDeactivate() from saving the message to drafts again
+    // Cleanup message contents to prevent ChildDoDeactivate() 
+	// from saving the message to drafts again
     ResetComposer();
 
     SafeDelete( iFetchLogic );
@@ -2791,7 +2833,8 @@
             iContainer->IsSubjectFieldEmpty() &&
             (iContainer->GetMessageFieldLength() < 1);
 
-        // save to Drafts if there's some user input in some header field or in message body
+        // save to Drafts if there's some user input in some header field 
+        // or in message body
         if ( !noAddrOrNoMesBody )
             {
             TRAPD( error, DoSaveDraftL( EFalse ) );
@@ -2800,7 +2843,8 @@
                 }
             }
 
-        // store the message IDs to launch parameters to be able to return to same message if desired
+        // store the message IDs to launch parameters to be able to return 
+        // to same message if desired
         iLaunchParams.iMsgId = iNewMessage->GetMessageId();
         iLaunchParams.iFolderId = iNewMessage->GetFolderId();
         iLaunchParams.iMailboxId = iMailBox->GetId();
@@ -2829,15 +2873,17 @@
 void CNcsComposeView::AsyncExitL()
     {
     FUNC_LOG;
-    if ( iFakeSyncGoingOn || iExecutingDoExitL ) // if some sync method is still going on, we continue waiting
+    if ( iFakeSyncGoingOn || iExecutingDoExitL )
         {
+        // if some sync method is still going on, we continue waiting
         iActiveHelper->Cancel();
         iActiveHelper->Start();
         }
     else
         {
         ExitComposer();
-        // for some strange reason composer view is stuck and only option was to call ProcessCommandL with EAknCmdExit
+        // for some strange reason composer view is stuck and only option 
+        // was to call ProcessCommandL with EAknCmdExit
         ProcessCommandL( EAknCmdExit );
         }
     }
@@ -2862,11 +2908,11 @@
         {
         if ( !iFetchWaitDialog )
             {
-            iFetchWaitDialog = new(ELeave)CAknWaitDialog(
-                       (REINTERPRET_CAST(CEikDialog**,&iFetchWaitDialog)), EFalse);
-            iFetchWaitDialog->SetCallback(this);
+            iFetchWaitDialog = new (ELeave) CAknWaitDialog(
+                reinterpret_cast<CEikDialog**>( &iFetchWaitDialog ), EFalse);
+            iFetchWaitDialog->SetCallback( this );
             iFetchDialogCancelled = EFalse;
-            iFetchWaitDialog->ExecuteLD(R_FSE_FETCHING_WAIT_DIALOG);
+            iFetchWaitDialog->ExecuteLD( R_FSE_FETCHING_WAIT_DIALOG );
             }
         }
     }
@@ -2878,7 +2924,7 @@
 void CNcsComposeView::DialogDismissedL( TInt aButtonId )
     {
     FUNC_LOG;
-    if ( (aButtonId == EAknSoftkeyCancel) && iFetchLogic )
+    if ( aButtonId == EAknSoftkeyCancel && iFetchLogic )
         {
         iFetchDialogCancelled = ETrue;
         iFetchLogic->CancelFetchings();
@@ -2887,16 +2933,16 @@
 
 TBool CNcsComposeView::IsPreparedForExit()
     {
-    return !(iFakeSyncGoingOn ||iExecutingDoExitL);
+    return !( iFakeSyncGoingOn ||iExecutingDoExitL );
     }
 
 // ---------------------------------------------------------------------------
 // CActiveHelper::NewL()
 // ---------------------------------------------------------------------------
 //
-CActiveHelper* CActiveHelper::NewL(CNcsComposeView* aSession )
+CActiveHelper* CActiveHelper::NewL( CNcsComposeView* aSession )
     {
-    CActiveHelper* self = new(ELeave) CActiveHelper(aSession);
+    CActiveHelper* self = new(ELeave) CActiveHelper( aSession );
     CleanupStack::PushL( self );
     self->ConstructL( );
     CleanupStack::Pop( self );
@@ -2919,7 +2965,7 @@
 void CActiveHelper::Start()
     {
     TRequestStatus* status = &iStatus;
-    User::RequestComplete(status,KErrNone);
+    User::RequestComplete( status, KErrNone );
     SetActive();
     }
 
@@ -2927,7 +2973,8 @@
 // CActiveHelper::CActiveHelper()
 // ---------------------------------------------------------------------------
 //
-CActiveHelper::CActiveHelper(CNcsComposeView* aSession ) : CActive(EPriorityLow)
+CActiveHelper::CActiveHelper( CNcsComposeView* aSession ) 
+    : CActive( EPriorityLow )
     {
     iComposeView = aSession;
     }
@@ -2938,7 +2985,7 @@
 //
 void CActiveHelper::RunL()
     {
-    if(iComposeView)
+    if( iComposeView )
         iComposeView->AsyncExitL();
     }
 
@@ -2957,7 +3004,6 @@
 //
 void CActiveHelper::ConstructL()
     {
-    CActiveScheduler::Add(this);
+    CActiveScheduler::Add( this );
     }
 
-//</cmail>
--- a/emailuis/emailui/src/ncscomposeviewcontainer.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/ncscomposeviewcontainer.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -75,9 +75,9 @@
 // Two-phased constructor.
 // -----------------------------------------------------------------------------
 //
-CNcsComposeViewContainer* CNcsComposeViewContainer::NewL( CNcsComposeView& aView,
-    const TRect& aRect, CFSMailBox& aMailBox, CFsAutoSaver& aAutoSaver,
-    TInt aFlags )
+CNcsComposeViewContainer* CNcsComposeViewContainer::NewL( 
+    CNcsComposeView& aView, const TRect& aRect, CFSMailBox& aMailBox, 
+    CFsAutoSaver& aAutoSaver, TInt aFlags )
     {
     FUNC_LOG;
 
@@ -101,9 +101,6 @@
 
     SetMopParent( &iView );
     CreateWindowL();
-	// <cmail>
-    // iApplicationRect = aRect;
-	// </cmail>
 
     // Setup the control array
     InitComponentArrayL();
@@ -124,9 +121,7 @@
     controls.AppendLC( iMessageField );
     CleanupStack::Pop( iMessageField );
 
-    // <cmail> Platform layout change
     iMessageField->SetNcsFontType( NcsUtility::ENcsBodytextFont );
-    // </cmail>
 
     // Listen edwin events and size events from message body field
     iMessageField->AddEdwinObserverL( this );
@@ -148,7 +143,8 @@
 
     // Create the scroll bar
     iScrollBar = new( ELeave ) CAknDoubleSpanScrollBar( this );
-    iScrollBar->ConstructL( this, this, CEikScrollBar::EVertical, aRect.Height() );
+    iScrollBar->ConstructL( 
+            this, this, CEikScrollBar::EVertical, aRect.Height() );
     iScrollBar->MakeVisible( ETrue );
     iScrollBar->SetModelL( &iScrollBarModel );
 
@@ -157,14 +153,10 @@
 
     SetRect( aRect );
 
-    //<cmail> S60 skin support
     iBgContext = CAknsBasicBackgroundControlContext::NewL(
         KAknsIIDQsnBgAreaMain, Rect(), EFalse );
-    // <cmail>
-	//iMessageField->SetSkinBackgroundControlContextL( iBgContext );
-	// </cmail>
+
     iLongTapDetector = CAknLongTapDetector::NewL( this );
-    //</cmail>
 
     UpdateScrollBarL();
 
@@ -194,10 +186,8 @@
 	delete iHeader;
     delete iScrollBar;
     delete iMessageField;
-    // <cmail>
     delete iBgContext;
 	delete iLongTapDetector;
-    // </cmail>
     delete iReadOnlyQuoteField;
     delete iReadOnlyQuote;
 
@@ -211,7 +201,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeViewContainer::FocusChanged(TDrawNow aDrawNow)
+void CNcsComposeViewContainer::FocusChanged( TDrawNow aDrawNow )
     {
     FUNC_LOG;
 
@@ -222,9 +212,8 @@
 		iFocused = iHeader;
         }
 	iFocused->SetFocus( ETrue, aDrawNow );
-	// <cmail>
 	iView.HandleContainerChangeRequiringToolbarRefresh();
-	// </cmail>
+
 	if ( aDrawNow )
 	    {
 		DrawNow();
@@ -242,20 +231,20 @@
     iHeader->SetMskL();
     }
 
-//<cmail>
-
 // -----------------------------------------------------------------------------
 // CNcsComposeViewContainer::HandlePointerEventL()
 //
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeViewContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
+void CNcsComposeViewContainer::HandlePointerEventL( 
+        const TPointerEvent& aPointerEvent )
     {
 	FUNC_LOG;
 
     CCoeControl::HandlePointerEventL( aPointerEvent );
 
-    if ( iHeader->NeedsLongTapL( aPointerEvent.iPosition ) )
+    if ( aPointerEvent.iType != TPointerEvent::EButton1Down &&
+         iHeader->NeedsLongTapL( aPointerEvent.iPosition ) )
         {
     	iLongTapDetector->PointerEventL( aPointerEvent );
         }
@@ -266,7 +255,8 @@
     		{
             // Save current and original position so that those can be used in
             // drag/scrolling calculations
-            iPreviousPosition = iOriginalPosition = aPointerEvent.iParentPosition;
+            iPreviousPosition = iOriginalPosition = 
+                aPointerEvent.iParentPosition;
             iIsDragging = EFalse;
             iIsFlicking = EFalse;
 
@@ -278,23 +268,18 @@
                 UpdatePhysicsL();
                 }            
 
-            
-			//Closes the attachment action menu, if it is open.
-			//Otherwise does nothing
-			iView.DismissAttachmentActionMenuL();
-
-            if ( iHeader->Rect().Contains(aPointerEvent.iPosition) )
+            if ( iHeader->Rect().Contains( aPointerEvent.iPosition ) )
                 {
-                if (iFocused == iMessageField)
+                if ( iFocused == iMessageField )
                     {
                     iFocused = iHeader;
                     iHeader->SetFocus( ETrue,EDrawNow );
                     iMessageField->SetFocus( EFalse, EDrawNow );
                     iHeader->MakeVisible( ETrue );
-                    CommitL(EBodyField);
+                    CommitL( EBodyField );
                     iView.HandleContainerChangeRequiringToolbarRefresh();
                     }
-                else if (iFocused == iReadOnlyQuoteField)
+                else if ( iFocused == iReadOnlyQuoteField )
                     {
                     iFocused = iMessageField;
                     iReadOnlyQuoteField->SetFocus( EFalse, EDrawNow );
@@ -302,9 +287,10 @@
                     iView.HandleContainerChangeRequiringToolbarRefresh();
                     }
                 }
-            else if (iReadOnlyQuoteField->Rect().Contains(aPointerEvent.iPosition))
+            else if ( iReadOnlyQuoteField->Rect().Contains( 
+                        aPointerEvent.iPosition ) )
                 {
-                if (iFocused == iMessageField)
+                if ( iFocused == iMessageField )
                     {
                     iFocused = iReadOnlyQuoteField;
                     iReadOnlyQuoteField->SetFocus( ETrue, EDrawNow );
@@ -312,7 +298,7 @@
                     iReadOnlyQuoteField->SetCursorPosL( 0, EFalse );
                     iView.HandleContainerChangeRequiringToolbarRefresh();
                     }
-                else if (iFocused == iHeader)
+                else if ( iFocused == iHeader )
                     {
                     iFocused = iReadOnlyQuoteField;
                     iReadOnlyQuoteField->SetFocus( ETrue, EDrawNow );
@@ -323,15 +309,14 @@
                 }
             else 
                 {
-                if (iFocused == iHeader)
+                if ( iFocused == iHeader )
                     {
                     iFocused = iMessageField;
                     iHeader->SetFocus( EFalse, EDrawNow );
                     iMessageField->SetFocus( ETrue, EDrawNow );
-                    //iMessageField->SetCursorPosL( iMessageField->TextLength(), EFalse );
                     iView.HandleContainerChangeRequiringToolbarRefresh();
                     }
-                else if (iFocused == iReadOnlyQuoteField)
+                else if ( iFocused == iReadOnlyQuoteField )
                     {
                     iFocused = iMessageField;
                     iReadOnlyQuoteField->SetFocus( EFalse, EDrawNow );
@@ -340,10 +325,9 @@
                     }
                 else 
                     {
-                    //iMessageField->SetCursorPosL( iMessageField->TextLength(), EFalse );
-                    const TRect messageFieldRect(iMessageField->Rect());
-                    if (!messageFieldRect.Contains(aPointerEvent.iPosition) && 
-                            aPointerEvent.iPosition.iY >= messageFieldRect.iTl.iY ) 
+                    const TRect messageFieldRect( iMessageField->Rect() );
+                    if ( !messageFieldRect.Contains( aPointerEvent.iPosition ) && 
+                         aPointerEvent.iPosition.iY >= messageFieldRect.iTl.iY )
                         {
                         iMessageField->OpenVirtualKeyBoardL();
                         }
@@ -357,8 +341,8 @@
     		{
             if( iIsDragging && iPhysics )
                 {
-                TPoint drag(iOriginalPosition - aPointerEvent.iParentPosition);
-                iPhysics->StartPhysics(drag, iStartTime);
+                TPoint drag( iOriginalPosition - aPointerEvent.iParentPosition );
+                iPhysics->StartPhysics( drag, iStartTime );
                 iIsFlicking = ETrue;
                 iIsDragging = EFalse;
                 }
@@ -389,11 +373,14 @@
     			
 				if( totalHeight > areaHeight )
 					{
-					// Calculate new scroll offset based on current and previous Y-positions
-					scrollOffset = topPosition + ( iPreviousPosition.iY - position.iY );
+					// 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 );
+					scrollOffset = Min( scrollOffset, 
+                                        totalHeight - areaHeight );
 					}
 
 				ScrollL( scrollOffset );
@@ -411,17 +398,21 @@
     		break;
     		}
     	}
-    
+
+    if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
+         iHeader->NeedsLongTapL( aPointerEvent.iPosition ) )
+        {
+        iLongTapDetector->PointerEventL( aPointerEvent );
+        }
     }
 
-//</cmail>
-
 // -----------------------------------------------------------------------------
 // CNcsComposeViewContainer::OfferKeyEventL()
 // Handles key events
 // -----------------------------------------------------------------------------
 //
-TKeyResponse CNcsComposeViewContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
+TKeyResponse CNcsComposeViewContainer::OfferKeyEventL( 
+        const TKeyEvent& aKeyEvent, TEventCode aType )
     {
     FUNC_LOG;
 
@@ -433,10 +424,8 @@
 
     TKeyResponse ret( EKeyWasNotConsumed );
 
-    //<cmail>
     //we are allowing to change MSK label 
-    SwitchChangeMskOff(EFalse);
-    //</cmail>
+    SwitchChangeMskOff( EFalse );
     
     if ( aKeyEvent.iCode == EKeyYes )
         {
@@ -470,7 +459,8 @@
         iView.HandleCommandL( ENcsCmdSaveDraft );
         ret = EKeyWasConsumed;
         }
-    else if ( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
+    else if ( aKeyEvent.iCode == EKeyUpArrow || 
+              aKeyEvent.iCode == EKeyDownArrow )
         {
         ret = iFocused->OfferKeyEventL( aKeyEvent, aType );
 
@@ -511,7 +501,8 @@
 // we want to scroll up the header and grow the message field.
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeViewContainer::UpdateScreenPositionL( const TUint& /*aKeyCode*/ )
+void CNcsComposeViewContainer::UpdateScreenPositionL( 
+        const TUint& /*aKeyCode*/ )
     {
     FUNC_LOG;
 
@@ -535,7 +526,8 @@
         }
     else
         {
-        // This function should be used only when focus is in body or read-only quote
+        // This function should be used only when focus is in body or
+        // read-only quote
         return;
         }
     TPoint linePos = lineRect.iTl;
@@ -555,9 +547,11 @@
         }
 
     // Check we don't scroll too low
-    if ( quotePos.iY + moveY + iReadOnlyQuoteField->Size().iHeight < screenRect.Height() )
+    if ( quotePos.iY + moveY + iReadOnlyQuoteField->Size().iHeight < 
+         screenRect.Height() )
         {
-        moveY = screenRect.Height() - quotePos.iY - iReadOnlyQuoteField->Size().iHeight;
+        moveY = screenRect.Height() - quotePos.iY - 
+            iReadOnlyQuoteField->Size().iHeight;
         }
 
     // Check we don't scroll too high
@@ -580,8 +574,6 @@
 
         iSeparatorLineYPos += moveY;
         UpdateScrollBarL();
-
-        //DrawDeferred();
         }
     }
 
@@ -590,7 +582,7 @@
 //
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeViewContainer::UpdateFieldPosition(CCoeControl* aAnchor)
+void CNcsComposeViewContainer::UpdateFieldPosition( CCoeControl* aAnchor )
     {
     FUNC_LOG;
 
@@ -598,12 +590,13 @@
 	if ( iHeader && iMessageField && iReadOnlyQuoteField )
 	    {
 	    // First, move all the controls in the header
-	    iHeader->UpdateFieldPosition(aAnchor);
+	    iHeader->UpdateFieldPosition( aAnchor );
 
 	    // Then, move the body field below the header
 	    TRect headerRect = iHeader->Rect();
 	            
-		const TSize separatorSize( NcsUtility::SeparatorSizeInThisResolution() );
+		const TSize separatorSize( 
+		        NcsUtility::SeparatorSizeInThisResolution() );
 		iSeparatorLineYPos = headerRect.iBr.iY;
 			
 		TPoint bodyPos( iMessageField->Position() );
@@ -614,7 +607,7 @@
 		quotePos.iY = iMessageField->Rect().iBr.iY;
 		iReadOnlyQuoteField->SetPosition( quotePos );
 
-	    TRAP_IGNORE(UpdateScrollBarL());
+	    TRAP_IGNORE( UpdateScrollBarL() );
 
 	    DrawDeferred();
 	    }
@@ -627,7 +620,8 @@
 // -----------------------------------------------------------------------------
 //
 
-TKeyResponse CNcsComposeViewContainer::ChangeFocusL( const TKeyEvent& aKeyEvent )
+TKeyResponse CNcsComposeViewContainer::ChangeFocusL( 
+        const TKeyEvent& aKeyEvent )
     {
     FUNC_LOG;
 
@@ -648,10 +642,11 @@
     		iHeader->SetFocus( ETrue,EDrawNow );
     		iMessageField->SetFocus( EFalse, EDrawNow );
     		iHeader->MakeVisible( ETrue );
-            CommitL(EBodyField);
+            CommitL( EBodyField );
             ret = EKeyWasConsumed;
 	        }
-	    else if ( aKeyEvent.iCode == EKeyDownArrow && iReadOnlyQuoteField->TextLength() )
+	    else if ( aKeyEvent.iCode == EKeyDownArrow && 
+	              iReadOnlyQuoteField->TextLength() )
 	        {
 	        // Focus move to read-only quote only if there is some text in it.
 	        iFocused = iReadOnlyQuoteField;
@@ -697,7 +692,6 @@
 	return EFalse;
     }
 
-// <cmail> Platform layout changes
 // -----------------------------------------------------------------------------
 // CNcsComposeViewContainer::SizeChanged()
 // set size
@@ -712,16 +706,19 @@
     TRect cmailPaneRect( NcsUtility::ListCmailPaneRect( rect ) );
 
     const TInt headerLineCount( iHeader->LayoutLineCount() );
-    const TPoint headerPos( NcsUtility::HeaderControlPosition( cmailPaneRect, 0 ) );
+    const TPoint headerPos( 
+            NcsUtility::HeaderControlPosition( cmailPaneRect, 0 ) );
     cmailPaneRect.Move( 0, iHeader->Position().iY - headerPos.iY );
 
-    NcsUtility::LayoutHeaderControl( iHeader, cmailPaneRect, 0, headerLineCount );
+    NcsUtility::LayoutHeaderControl( 
+            iHeader, cmailPaneRect, 0, headerLineCount );
 
     // do not used stored headerLineCount, because relayout above may grow or
     // shrink edit fields
+    NcsUtility::LayoutBodyEdwin( 
+            iMessageField, cmailPaneRect, iHeader->LayoutLineCount(), 
+            iMessageField->LineCount(), iSeparatorLineYPos );
     TRAP_IGNORE( iMessageField->FormatAllTextNowL() );
-    NcsUtility::LayoutBodyEdwin( iMessageField, cmailPaneRect, iHeader->LayoutLineCount(), iMessageField->LineCount(),
-            iSeparatorLineYPos );
 
     iMessageField->UpdateFontSize();
 
@@ -729,8 +726,11 @@
     if ( iReadOnlyQuoteField->TextLength() )
         {
         TInt dummySeparatorPos;
-        NcsUtility::LayoutBodyEdwin( iReadOnlyQuoteField, cmailPaneRect, headerLineCount + iMessageField->LineCount(), iReadOnlyQuoteField->LineCount(), 
-        		dummySeparatorPos );
+        NcsUtility::LayoutBodyEdwin(
+                iReadOnlyQuoteField, cmailPaneRect, 
+                iHeader->LayoutLineCount() + iMessageField->LineCount(), 
+                iReadOnlyQuoteField->LineCount(), dummySeparatorPos );
+        TRAP_IGNORE( iReadOnlyQuoteField->FormatAllTextNowL() );
         iReadOnlyQuoteField->UpdateFontSize();
         readOnlyQuoteFieldHeight = iReadOnlyQuoteField->Rect().Height();
         }
@@ -742,16 +742,19 @@
     iMessageField->SetRealRect( Rect() );
     iReadOnlyQuoteField->SetRealRect( Rect() );
     
-    TInt messageLineHeigth = NcsUtility::HeaderCaptionPaneRect( cmailPaneRect ).Height();
-    iMessageEditorMinHeigth = cmailPaneRect.Height() - iHeader->Size().iHeight -
-                              NcsUtility::SeparatorSizeInThisResolution().iHeight -
-                              readOnlyQuoteFieldHeight;
+    TInt messageLineHeigth = 
+        NcsUtility::HeaderCaptionPaneRect( cmailPaneRect ).Height();
+    iMessageEditorMinHeigth = 
+        cmailPaneRect.Height() - iHeader->Size().iHeight -
+        NcsUtility::SeparatorSizeInThisResolution().iHeight -
+        readOnlyQuoteFieldHeight;
     
     iMessageEditorMinHeigth -= iMessageEditorMinHeigth % messageLineHeigth;
     if ( iMessageEditorMinHeigth > messageLineHeigth )
         {
         TSize newSize( iMessageField->Size().iWidth,
-                       Max( iMessageField->Size().iHeight, iMessageEditorMinHeigth ));
+                       Max( iMessageField->Size().iHeight, 
+                            iMessageEditorMinHeigth ) );
             
         iMessageField->SetSize( newSize );
         }
@@ -760,13 +763,10 @@
         iMessageEditorMinHeigth = messageLineHeigth;
         }
 
-    UpdateFieldPosition( NULL );
-    
     TRAP_IGNORE( UpdateScrollBarL() );
     DrawNow();
     
     }
-// </cmail> Platform layout changes
 
 // -----------------------------------------------------------------------------
 // CNcsComposeViewContainer::Draw() const
@@ -776,7 +776,7 @@
 void CNcsComposeViewContainer::Draw( const TRect& /*aRect*/ ) const
     {
     FUNC_LOG;
-	// <cmail> S60 skin support
+
 	if ( iBgContext )
 	    {
     	CWindowGc& gc = SystemGc();
@@ -814,7 +814,7 @@
 
     // Activating the field will set the control to the end of the text
     iMessageField->ActivateL();
-    iMessageField->SetCursorPosL(0,EFalse);
+    iMessageField->SetCursorPosL( 0, EFalse );
 
     inputStream.Open( aReadOnlyQuote.Ptr(), aReadOnlyQuote.Size() );
     CleanupClosePushL( inputStream );
@@ -824,7 +824,7 @@
 
     // Activating the field will set the control to the end of the text
     iReadOnlyQuoteField->ActivateL();
-    iReadOnlyQuoteField->SetCursorPosL(0,EFalse);
+    iReadOnlyQuoteField->SetCursorPosL( 0, EFalse );
 
     // Recalculate the size of the body field
     SizeChanged();
@@ -883,9 +883,9 @@
 // CNcsComposeViewContainer::HandleScrollEventL()
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeViewContainer::HandleScrollEventL( CEikScrollBar* aScrollBar, TEikScrollEvent /*aEventType*/ )
+void CNcsComposeViewContainer::HandleScrollEventL( 
+        CEikScrollBar* aScrollBar, TEikScrollEvent /*aEventType*/ )
     {
-    // <cmail> Platform layout change
     FUNC_LOG;
     
     if( iPhysics )
@@ -912,7 +912,8 @@
 
 		for ( TInt i = 0 ; i < aContacts.Count() ; i++ )
 			{
-			CNcsEmailAddressObject* object = CNcsEmailAddressObject::NewL( aContacts[i]->DisplayName(),
+			CNcsEmailAddressObject* object = 
+                CNcsEmailAddressObject::NewL( aContacts[i]->DisplayName(),
 					aContacts[i]->EmailAddress() );
 			if ( aContacts[i]->MultipleEmails() )
 				{
@@ -944,7 +945,12 @@
 	iView.HandleContainerChangeRequiringToolbarRefresh();
 	}
 
-void CNcsComposeViewContainer::OperationErrorL( TContactHandlerCmd, TInt /*aError*/ )
+// -----------------------------------------------------------------------------
+// CNcsComposeViewContainer::OperationErrorL
+// -----------------------------------------------------------------------------
+//
+void CNcsComposeViewContainer::OperationErrorL( 
+        TContactHandlerCmd, TInt /*aError*/ )
 	{
     FUNC_LOG;
 	//Nothing to do
@@ -965,7 +971,8 @@
             {
             iAutoSaver.ReportActivity();
 
-            // Update screen position and scroll bar when text changed or cursor moved
+            // Update screen position and scroll bar when text changed
+            // or cursor moved
             UpdateScreenPositionL();
             UpdateScrollBarL();
             DrawDeferred();
@@ -1058,23 +1065,6 @@
 	}
 
 // -----------------------------------------------------------------------------
-// CNcsComposeViewContainer::SetApplicationRect()
-// -----------------------------------------------------------------------------
-//
-// <cmail>
-/*
-void CNcsComposeViewContainer::SetApplicationRect( TRect aRect )
-	{
-    FUNC_LOG;
-
-	iApplicationRect = aRect;
-
-	}
-*/
-// </cmail>
-
-
-// -----------------------------------------------------------------------------
 // CNcsComposeViewContainer::SetFocusToMessageFieldL()
 // -----------------------------------------------------------------------------
 //
@@ -1103,16 +1093,16 @@
     FUNC_LOG;
 
     // If in 'To' field, go to msg. field
-    if(!iMessageField->IsFocused())
+    if( !iMessageField->IsFocused() )
     	{
     	SetFocusToMessageFieldL();
     	}
 	TInt pos = iMessageField->CursorPos();
 	TCursorSelection selIns( pos, pos );
 	iMessageField->InsertDeleteCharsL( pos, aText, selIns );
-	//Fix for error EFTG-7Y63XG, moving cursor to the end of inserted text
+	// Fix for error EFTG-7Y63XG, moving cursor to the end of inserted text
 	pos += aText.Length();
-	iMessageField->SetCursorPosL(pos,EFalse);
+	iMessageField->SetCursorPosL( pos, EFalse );
 	DrawDeferred();
 
     }
@@ -1225,14 +1215,14 @@
 	}
 
 // -----------------------------------------------------------------------------
-// CNcsComposeViewContainer::LaunchAttachmentActionMenuL
-// Called when right-click happens in the attahcments field
+// CNcsComposeViewContainer::LaunchStylusPopupMenu
+// Called when long tap happens in the attachments field
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeViewContainer::LaunchAttachmentActionMenuL()
+void CNcsComposeViewContainer::LaunchStylusPopupMenu( const TPoint& aPenEventScreenLocation )
     {
     FUNC_LOG;
-    iView.LaunchAttachmentActionMenuL();
+    iView.LaunchStylusPopupMenu( aPenEventScreenLocation );
     }
 
 // -----------------------------------------------------------------------------
@@ -1240,7 +1230,8 @@
 //
 // -----------------------------------------------------------------------------
 //
-const RPointerArray<CNcsEmailAddressObject>& CNcsComposeViewContainer::GetToFieldAddressesL( TBool aParseNow )
+const RPointerArray<CNcsEmailAddressObject>& 
+CNcsComposeViewContainer::GetToFieldAddressesL( TBool aParseNow )
     {
     return iHeader->GetToFieldAddressesL( aParseNow );
     }
@@ -1250,7 +1241,8 @@
 //
 // -----------------------------------------------------------------------------
 //
-const RPointerArray<CNcsEmailAddressObject>& CNcsComposeViewContainer::GetCcFieldAddressesL( TBool aParseNow )
+const RPointerArray<CNcsEmailAddressObject>& 
+CNcsComposeViewContainer::GetCcFieldAddressesL( TBool aParseNow )
     {
     return iHeader->GetCcFieldAddressesL( aParseNow );
     }
@@ -1260,7 +1252,8 @@
 //
 // -----------------------------------------------------------------------------
 //
-const RPointerArray<CNcsEmailAddressObject>& CNcsComposeViewContainer::GetBccFieldAddressesL( TBool aParseNow )
+const RPointerArray<CNcsEmailAddressObject>& 
+CNcsComposeViewContainer::GetBccFieldAddressesL( TBool aParseNow )
     {
     return iHeader->GetBccFieldAddressesL( aParseNow );
     }
@@ -1298,8 +1291,6 @@
     return iHeader->IsCcFieldVisible();
     }
 
-// <cmail> Removed unneeded IsFocusAif
-// </cmail>
 
 // -----------------------------------------------------------------------------
 // CNcsComposeViewContainer::IsFocusAttachments
@@ -1478,7 +1469,6 @@
     FUNC_LOG;
 
 	iHeader->SetMenuBar(aMenuBar);
-
     }
 
 // -----------------------------------------------------------------------------
@@ -1486,12 +1476,12 @@
 //
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeViewContainer::SetToFieldAddressesL( RPointerArray<CNcsEmailAddressObject>& aAddress )
+void CNcsComposeViewContainer::SetToFieldAddressesL( 
+        RPointerArray<CNcsEmailAddressObject>& aAddress )
     {
     FUNC_LOG;
 
     iHeader->SetToFieldAddressesL(aAddress);
-
     }
 
 // -----------------------------------------------------------------------------
@@ -1499,12 +1489,12 @@
 //
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeViewContainer::SetCcFieldAddressesL( RPointerArray<CNcsEmailAddressObject>& aAddress )
+void CNcsComposeViewContainer::SetCcFieldAddressesL( 
+        RPointerArray<CNcsEmailAddressObject>& aAddress )
     {
     FUNC_LOG;
 
     iHeader->SetCcFieldAddressesL( aAddress );
-
     }
 
 // -----------------------------------------------------------------------------
@@ -1512,7 +1502,8 @@
 //
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeViewContainer::SetBccFieldAddressesL( RPointerArray<CNcsEmailAddressObject>& aAddress )
+void CNcsComposeViewContainer::SetBccFieldAddressesL( 
+        RPointerArray<CNcsEmailAddressObject>& aAddress )
     {
     FUNC_LOG;
 
@@ -1573,30 +1564,26 @@
     }
 
 // -----------------------------------------------------------------------------
-// CNcsComposeViewContainer::SetAttachmentLabelTextL
+// CNcsComposeViewContainer::SetAttachmentLabelTextsLD
 //
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeViewContainer::SetAttachmentLabelTextL( const TDesC& aText )
+void CNcsComposeViewContainer::SetAttachmentLabelTextsLD( 
+    CDesCArray* aAttachmentNames, CDesCArray* aAttachmentSizes )
     {
-    FUNC_LOG;
-
-	iHeader->SetAttachmentLabelTextL( aText );
-
+    FUNC_LOG;   
+    iHeader->SetAttachmentLabelTextsLD( aAttachmentNames, aAttachmentSizes );
     }
 
 // -----------------------------------------------------------------------------
-// CNcsComposeViewContainer::SetAttachmentLabelTextL
+// CNcsComposeViewContainer::FocusedAttachmentLabelIndex
 //
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeViewContainer::SetAttachmentLabelTextL( const TDesC& aAttachmentName,
-                                                        const TDesC& aAttachmentSizeDesc )
+TInt CNcsComposeViewContainer::FocusedAttachmentLabelIndex()
     {
-    FUNC_LOG;
-
-    iHeader->SetAttachmentLabelTextL( aAttachmentName, aAttachmentSizeDesc );
-
+    FUNC_LOG;   
+    return iHeader->FocusedAttachmentLabelIndex();
     }
 
 // -----------------------------------------------------------------------------
@@ -1735,9 +1722,7 @@
 		iMessageField->SetFocus( EFalse, EDrawNow );
 		iHeader->MakeVisible( ETrue );
     	}
-
 	iHeader->FocusAttachmentField();
-
 	}
 
 // -----------------------------------------------------------------------------
@@ -1772,8 +1757,7 @@
 void CNcsComposeViewContainer::HandleLayoutChangeL()
     {
     FUNC_LOG;
-    TRect rect = iView.ClientRect();
-    SetRect( rect );
+    SetRect( iView.ClientRect() );
     if ( iHeader )
         {
         iHeader->HandleDynamicVariantSwitchL();
@@ -1794,7 +1778,6 @@
         iHeader->HandleDynamicVariantSwitchL();
         }
 
-// <cmail>
     if ( iMessageField )
         {
         iMessageField->UpdateFontSize();
@@ -1805,7 +1788,6 @@
         iScrollBar->HandleResourceChange( KAknsMessageSkinChange );
         iScrollBar->DrawNow();
         }
-// </cmail>
     }
 
 // -----------------------------------------------------------------------------
@@ -1819,7 +1801,8 @@
     const TSize separatorSize( NcsUtility::SeparatorSizeInThisResolution() );
 	
 	TInt totalHeight( iHeader->Size().iHeight + 
-					  separatorSize.iHeight*2 + iMessageField->Size().iHeight );
+					  separatorSize.iHeight*2 + 
+					  iMessageField->Size().iHeight );
 
 	if( iReadOnlyQuoteField->IsVisible() )
 		{
@@ -1837,42 +1820,39 @@
 void CNcsComposeViewContainer::CommitL( TFieldToCommit aFieldToCommit )
     {
     FUNC_LOG;
-    iView.CommitL(ETrue,aFieldToCommit);
+    iView.CommitL( ETrue, aFieldToCommit );
     iView.HandleContainerChangeRequiringToolbarRefresh();
     }
 
-//<cmail>
 // -----------------------------------------------------------------------------
 // CNcsComposeViewContainer::SwitchChangeMskOff
-//sets up iSwitchChangeMskOff falg, which disables changes of MSK label if any popup dialog is open
+// sets up iSwitchChangeMskOff falg, which disables changes of MSK label if
+// any popup dialog is open
 // -----------------------------------------------------------------------------
 void CNcsComposeViewContainer::SwitchChangeMskOff(TBool aTag)
     {
     FUNC_LOG;
-    iHeader->SwitchChangeMskOff(aTag);
+    iHeader->SwitchChangeMskOff( aTag );
     }
-//</cmail>
 
-//<cmail>
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::HandleLongTapEventL()
 // Handles key events
 // -----------------------------------------------------------------------------
-void CNcsComposeViewContainer::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /*aPenEventScreenLocation*/ )
+void CNcsComposeViewContainer::HandleLongTapEventL( 
+        const TPoint& aPenEventLocation, 
+        const TPoint& aPenEventScreenLocation )
     {
     FUNC_LOG;
-    iHeader->HandleLongTapL( aPenEventLocation );
+    iHeader->HandleLongTap( aPenEventLocation, aPenEventScreenLocation );
     }
-//</cmail>
 
 
-//<cmail>
 void CNcsComposeViewContainer::FixSemicolonL()
 	{
     FUNC_LOG;
 	iHeader->FixSemicolonInAddressFieldsL();
 	}
-//</cmail>
 
 // ---------------------------------------------------------------------------
 // CNcsComposeViewContainer::UpdatePhysicsL()
@@ -1886,7 +1866,7 @@
         const TSize viewSize( Rect().Size() );
         // We must ensure that world size is at least the size of the view
         const TSize worldSize( viewSize.iWidth, 
-                Max(ContentTotalHeight(), viewSize.iHeight) );
+                Max( ContentTotalHeight(), viewSize.iHeight ) );
         iPhysics->InitPhysicsL( worldSize, viewSize, EFalse );
         }
     }
@@ -1900,7 +1880,8 @@
     FUNC_LOG;
 	TPoint headerPos( iHeader->Position() );
 	
-	aTargetPos = Max( 0, Min(aTargetPos, ContentTotalHeight() - Rect().Height()) );
+	aTargetPos = Max( 0, Min( aTargetPos, 
+	                          ContentTotalHeight() - Rect().Height()) );
 	
 	TInt moveY = -headerPos.iY - aTargetPos;
 	
@@ -1927,9 +1908,11 @@
 		}
 	}
 
-/**
- * @see MAknPhysicsObserver::ViewPositionChanged
- */
+// -----------------------------------------------------------------------------
+// CNcsComposeViewContainer::ViewPositionChanged
+// From MAknPhysicsObserver
+// -----------------------------------------------------------------------------
+//
 void CNcsComposeViewContainer::ViewPositionChanged(
         const TPoint& aNewPosition,
         TBool /*aDrawNow*/,
@@ -1944,18 +1927,22 @@
 		}
 	}
 
-/**
- * @see MAknPhysicsObserver::PhysicEmulationEnded
- */
+// -----------------------------------------------------------------------------
+// CNcsComposeViewContainer::PhysicEmulationEnded
+// From MAknPhysicsObserver
+// -----------------------------------------------------------------------------
+//
 void CNcsComposeViewContainer::PhysicEmulationEnded()
     {
     FUNC_LOG;
     iIsFlicking = EFalse;
     }
 
-/**
- * @see MAknPhysicsObserver::ViewPosition
- */
+// -----------------------------------------------------------------------------
+// CNcsComposeViewContainer::ViewPosition
+// From MAknPhysicsObserver
+// -----------------------------------------------------------------------------
+//
 TPoint CNcsComposeViewContainer::ViewPosition() const
     {
     FUNC_LOG;
@@ -1963,6 +1950,10 @@
     }
 
 
+// -----------------------------------------------------------------------------
+// CNcsComposeViewContainer::IsRemoteSearchInprogress
+// -----------------------------------------------------------------------------
+//
 TBool CNcsComposeViewContainer::IsRemoteSearchInprogress() const
     {
     FUNC_LOG;
--- a/emailuis/emailui/src/ncscontrol.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/ncscontrol.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -22,12 +22,11 @@
 #include <AknsSkinInstance.h>
 #include <gulcolor.h>
 #include <eikdef.h>
+#include <AknUtils.h>
 
 #include "ncscontrol.h"
 #include "FreestyleEmailUiLayoutData.h"
-// <cmail> Plaform layout change
 #include "ncsutility.h"
-// </cmail> Plaform layout change
 
 // ---------------------------------------------------------------------------
 // MNcsControl::MNcsControl
@@ -44,34 +43,22 @@
 // CNcsLabel::CNcsLabel
 // ---------------------------------------------------------------------------
 //
-// <cmail> Platform layout changes
-CNcsLabel::CNcsLabel( const CCoeControl& aParent, MNcsFieldSizeObserver* aSizeObserver ) :
+CNcsLabel::CNcsLabel( 
+        const CCoeControl& aParent, 
+        MNcsFieldSizeObserver* aSizeObserver ) :
     MNcsControl( aSizeObserver ), iParent( aParent )
     {
     FUNC_LOG;
     UpdateTextColor();
     }
-// </cmail> Platform layout changes
 
 // ---------------------------------------------------------------------------
 // CNcsLabel::Reposition
 // ---------------------------------------------------------------------------
 //
-void CNcsLabel::Reposition( TPoint& aPt, TInt /*aWidth <Cmail>*/ )
+void CNcsLabel::Reposition( TPoint& aPt, TInt /*aWidth*/ )
     {
     FUNC_LOG;
-    // <cmail> Platform layout changes
-    /*
-    TInt ht = Font()->HeightInPixels() + Font()->DescentInPixels();
-    ht += 2 * KAifLabelMarginHorizontal;
-    TSize sz( aWidth, ht );
-    if ( Rect() != TRect( aPt, sz ) )
-        {
-        SetExtent( aPt, sz );
-        }
-    aPt.iY += Size().iHeight;
-    */
-    // </cmail> Platform layout changes
     SetPosition( aPt );
     }
 
@@ -145,5 +132,28 @@
 //
 TInt CNcsLabel::LayoutLineCount() const
     {
+    FUNC_LOG;
     return IsVisible() ? 1 : 0;
     }
+
+// ---------------------------------------------------------------------------
+// CNcsLabel::TextHitAreaRect
+// ---------------------------------------------------------------------------
+//
+TRect CNcsLabel::TextHitAreaRect()
+    {
+    FUNC_LOG;
+    TRect rect;
+    if ( Font() && Text() )
+        {
+        rect = Rect();
+        rect.SetWidth( Font()->TextWidthInPixels( *Text() ) );
+        if( AknLayoutUtils::LayoutMirrored() )
+            {
+            rect.Move( Rect().Size().iWidth - 
+                       rect.Size().iWidth - 
+                       rect.iTl.iX - 2, 0 );
+            }
+        }
+    return rect;
+    }
--- a/emailuis/emailui/src/ncseditor.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/ncseditor.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -660,8 +660,8 @@
 
 void CNcsEditor::FormatAllTextNowL()
 	{
-	NotifyNewFormatL();
-	iTextView->FinishBackgroundFormattingL();
+	iLayout->SetAmountToFormat(CTextLayout::EFFormatAllText);
+	iTextView->FormatTextL();
 	}
 //</cmail>
 
--- a/emailuis/emailui/src/ncsheadercontainer.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/ncsheadercontainer.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -22,12 +22,11 @@
 #include <aknViewAppUi.h>
 #include <aknnotewrappers.h> //CAknInformationNote
 #include <FreestyleEmailUi.rsg>
-//<cmail>
+
 #include "CFSMailBox.h"
 #include <FreestyleEmailUi.rsg>
 
 #include "cpbkxremotecontactlookupserviceuicontext.h"
-//</cmail>
 
 #include "FSEmailBuildFlags.h"
 #include "ncsheadercontainer.h"
@@ -63,7 +62,8 @@
     CFSMailBox& aMailBox, TInt aFlags )
     {
     FUNC_LOG;
-    CNcsHeaderContainer* self = new ( ELeave ) CNcsHeaderContainer( aParent, aMailBox );
+    CNcsHeaderContainer* self = 
+        new ( ELeave ) CNcsHeaderContainer( aParent, aMailBox );
     CleanupStack::PushL( self );
     self->ConstructL( aFlags );
     CleanupStack::Pop( self );
@@ -77,12 +77,10 @@
 CNcsHeaderContainer::CNcsHeaderContainer(
 	CCoeControl& aParent, 
 	CFSMailBox& aMailBox ): 
-	iParent(aParent),
-    // <cmail> Platform layout change
+	iParent( aParent ),
 	iFieldSizeObserver( static_cast< CNcsComposeViewContainer& >( aParent ) ),
-    // </cmail> Platform layout change
 	iMailBox( aMailBox ),
-	iLongTapEventConsumed(EFalse)
+	iLongTapEventConsumed( EFalse )
 	{
     FUNC_LOG;
 	}
@@ -95,14 +93,11 @@
 	{
     FUNC_LOG;
     
-	SetContainerWindowL(iParent);
+	SetContainerWindowL( iParent );
     
-	CFreestyleEmailUiAppUi* fsAppUi = static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
-	// <cmail>
-	//fsAppUi->FsTextureManager()->ProvideBitmapL( EViewerTextureHeaderBackGround, iBackgroundBitmap, iBackgroundMask );
-	// </cmail>
+	CFreestyleEmailUiAppUi* fsAppUi = 
+        static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() );
 
-	// <cmail> Platform layout change
 	// Create 'To' field
 	iToField = CNcsAddressInputField::NewL( 
 		R_NCS_TO_FIELD_TEXT,
@@ -132,7 +127,6 @@
     
     iAttachmentField = CNcsAttachmentField::NewL( R_NCS_ATTACHMENT_LABEL_TEXT, 
             &iFieldSizeObserver, this );
-    // </cmail> Platform layout change
 
     // Setup the control array
     // Add all of them now so the container and parent is set correctly
@@ -168,15 +162,16 @@
 	controls.Remove( iAttachmentField );
 
 	// test whether mailbox supports remote lookup
-	TBool remoteLookupSupported = TFsEmailUiUtility::IsRemoteLookupSupported( iMailBox );
+	TBool remoteLookupSupported = 
+        TFsEmailUiUtility::IsRemoteLookupSupported( iMailBox );
 	
-	iAacListBox = CNcsPopupListBox::NewL( this, iMailBox, *this, remoteLookupSupported );
+	iAacListBox = CNcsPopupListBox::NewL( 
+	        this, iMailBox, *this, remoteLookupSupported );
 	iAacListBox->MakeVisible( EFalse );
 
-	// <cmail>
     iBgContext = CAknsBasicBackgroundControlContext::NewL(
         KAknsIIDQsnBgAreaMain, Rect(), EFalse );
-	// </cmail>
+
     iRALInProgress = EFalse;
 	}
 
@@ -192,12 +187,8 @@
 	delete iSubjectField;
     delete iAttachmentField;
 	delete iAacListBox;
-	// <cmail>
-    //delete iBackgroundBitmap;
-	//delete iBackgroundMask;
 	delete iLongTapDetector;
 	delete iBgContext;
-	// </cmail>
 	}
 
 // ---------------------------------------------------------------------------
@@ -222,7 +213,7 @@
         // Remove MSK label when header loses focus
         TRAP_IGNORE( SetMskL() );
 		}
-	else if ( IsFocused() && !focused )
+	else if ( IsFocused() && !focused && !iRALInProgress )
 		{
 		// We're gaining focus from the message body
 		// Set the focus to the last control in the control array
@@ -240,14 +231,7 @@
 void CNcsHeaderContainer::Draw( const TRect& /*aRect*/ ) const
 	{
     FUNC_LOG;
-	// <cmail> S60 Skin support
-	// Get the standard graphics context
-	//CWindowGc& gc = SystemGc();
 
-	//gc.Clear();
-	
-	// Redraw the background
-	//gc.BitBlt( iBackgroundPos, iBackgroundBitmap, iBackgroundBitmap->SizeInPixels() );
     if ( iBgContext )
         {
         CWindowGc& gc = SystemGc();
@@ -259,7 +243,6 @@
             AknsDrawUtils::Background( skin, iBgContext, this, gc, Rect() );
             }
         }
-	// </cmail>
 	}
 
 // -----------------------------------------------------------------------------
@@ -283,7 +266,7 @@
 	TInt /*aControlId*/ )
 	{
     FUNC_LOG;
-	if (aEvent == CCoeControlArray::EControlAdded) 
+	if ( aEvent == CCoeControlArray::EControlAdded ) 
 		{
 		aControl->SetContainerWindowL( iParent );
 		aControl->MakeVisible( ETrue );
@@ -294,9 +277,7 @@
 		aControl->MakeVisible( EFalse );
 		}
 	// Tell the parent to recalculate everything
-	// <cmail> Platform layout change
-	iFieldSizeObserver.UpdateFieldPosition(NULL);
-	// </cmail> Platform layout change
+	iFieldSizeObserver.UpdateFieldPosition( NULL );
 	}
 
 void CNcsHeaderContainer::SetMskL()
@@ -305,10 +286,8 @@
     CCoeControl* focused = FindFocused();
     if ( focused == iToField || focused == iCcField || focused == iBccField )
         {
-            // <cmail> additional check if we can change MSK label    
-            if(iSwitchChangeMskOff == EFalse)
+        if( iSwitchChangeMskOff == EFalse )
             {
-            // </cmail>     
             ChangeMskCommandL( R_FSE_QTN_MSK_ADD );
             }
         }
@@ -327,7 +306,6 @@
             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
             }
         }
-    // <cmail> msk context menu added into composer    
     else if ( focused == iSubjectField )
         {
         ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );       
@@ -336,34 +314,33 @@
         {
         ChangeMskCommandL( R_FSE_QTN_MSK_BODY_MENU );
         }
-    // </cmail>     
     }  
 
-//<cmail>
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::HandlePointerEventL()
 // 
 // -----------------------------------------------------------------------------
-void CNcsHeaderContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent )
+void CNcsHeaderContainer::HandlePointerEventL( 
+        const TPointerEvent& aPointerEvent )
     {
 	FUNC_LOG;
 	CCoeControl* clicked = 0;
-    for (TInt i=0; i < Components().Count(); ++i)
+    for ( TInt i=0; i < Components().Count(); ++i )
         {
-        TRect rc = Components().At(i).iControl->Rect();
-        if (rc.Contains(aPointerEvent.iPosition))
+        TRect rc = Components().At( i ).iControl->Rect();
+        if ( rc.Contains( aPointerEvent.iPosition ) )
             {
-            clicked = Components().At(i).iControl;
+            clicked = Components().At( i ).iControl;
             }
         }
-    if (clicked)
+    if ( clicked )
         {
-        if (aPointerEvent.iType == TPointerEvent::EButton1Up)
+        if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
             {
             CCoeControl* pOldCtrl = FindFocused();
             CCoeControl* pNewCtrl= clicked;
             
-            if (pOldCtrl != pNewCtrl)
+            if ( pOldCtrl != pNewCtrl )
                 {
                 // Unfocus the control
                 if ( pOldCtrl )
@@ -379,7 +356,8 @@
                     }
 
                 // If the attachments label has changed focus
-                if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField )
+                if ( pOldCtrl == iAttachmentField || 
+                     pNewCtrl == iAttachmentField )
                     {
                     DrawAttachmentFocusNow();
                     }
@@ -397,14 +375,15 @@
             
             if( pNewCtrl == iAttachmentField )
             	{
-				CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
+				CNcsComposeViewContainer& parent = 
+                    static_cast<CNcsComposeViewContainer&>( iParent );
 				parent.HandleAttachmentsOpenCommandL();
             	}          
             }
         }
-    for (TInt i=0; i < Components().Count(); ++i)
+    for ( TInt i=0; i < Components().Count(); ++i )
         {
-        Components().At(i).iControl->HandlePointerEventL(aPointerEvent);
+        Components().At( i ).iControl->HandlePointerEventL( aPointerEvent );
         }
     }
 
@@ -412,42 +391,52 @@
 // CNcsHeaderContainer::HandleLongTapL()
 // 
 // -----------------------------------------------------------------------------
-void CNcsHeaderContainer::HandleLongTapL( const TPoint& aPenEventLocation )
+void CNcsHeaderContainer::HandleLongTap( const TPoint& aPenEventLocation, 
+										  const TPoint& aPenEventScreenLocation )
     {
 	FUNC_LOG;
 	iLongTapEventConsumed = EFalse;
 	
     CCoeControl* control = FindFocused();
     TRect rect = iAttachmentField->Rect();
-    	if( iAttachmentField->IsVisible() && rect.Contains( aPenEventLocation ) )
+    	if( iAttachmentField->IsVisible() && 
+    	    rect.Contains( aPenEventLocation ) )
         {
         iLongTapEventConsumed = ETrue;
         
-        CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
-        parent.LaunchAttachmentActionMenuL();
+        CNcsComposeViewContainer& parent = 
+            static_cast<CNcsComposeViewContainer&>( iParent );
+        parent.LaunchStylusPopupMenu( aPenEventScreenLocation );
         }
     }
 
+// -----------------------------------------------------------------------------
+// CNcsHeaderContainer::NeedsLongTapL()
+// Whether long tap detection is needed or not (depends on whether touch 
+// location is within attachment field or not)
+// -----------------------------------------------------------------------------
 TBool CNcsHeaderContainer::NeedsLongTapL( const TPoint& aPenEventLocation )
     {
 	FUNC_LOG;
 
     CCoeControl* control = FindFocused();
     TRect rect = iAttachmentField->Rect();
-    TBool result(EFalse);
-	if( iAttachmentField->IsVisible() && rect.Contains( aPenEventLocation ) )
+    TBool result( EFalse );
+	if( iAttachmentField->IsVisible() && rect.Contains( aPenEventLocation ) &&
+	    KNoAttachmentLabelFocused !=
+            iAttachmentField->FocusedAttachmentLabelIndex() )
         {
         result = ETrue;
         }
     return result;    
     }
-//</cmail>
 
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::OfferKeyEventL()
 // Handles key events
 // -----------------------------------------------------------------------------
-TKeyResponse CNcsHeaderContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
+TKeyResponse CNcsHeaderContainer::OfferKeyEventL( 
+        const TKeyEvent& aKeyEvent, TEventCode aType )
     {
     FUNC_LOG;
     TKeyResponse ret( EKeyWasNotConsumed );
@@ -456,7 +445,8 @@
     
     if( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
     	{
-        if ( iAacListBox && iAacListBox->IsVisible() && !iAacListBox->IsPopupEmpty() )
+        if ( iAacListBox && iAacListBox->IsVisible() && 
+             !iAacListBox->IsPopupEmpty() )
         	{
            	return iAacListBox->OfferKeyEventL( aKeyEvent, aType );
         	}
@@ -464,7 +454,7 @@
 	        {
 		    ret = FindFocused()->OfferKeyEventL( aKeyEvent, aType );
 		    
-    		doScroll = (ret == EKeyWasConsumed); 
+    		doScroll = ( ret == EKeyWasConsumed ); 
 	        }
 
         if ( ret == EKeyWasNotConsumed ) 
@@ -479,27 +469,25 @@
         	{
         	if ( aType == EEventKey )
         	    {
-                CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
+                CNcsComposeViewContainer& parent = 
+                    static_cast<CNcsComposeViewContainer&>( iParent );
 
-                if ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iScanCode == EStdKeyEnter ||  
-                     aKeyEvent.iCode == EKeyOK || aKeyEvent.iScanCode == EStdKeyDevice3 )
+                if ( aKeyEvent.iCode == EKeyEnter || 
+                     aKeyEvent.iScanCode == EStdKeyEnter ||  
+                     aKeyEvent.iCode == EKeyOK || 
+                     aKeyEvent.iScanCode == EStdKeyDevice3 )
             	    {   
             	    // open list or attachment
             	    parent.HandleAttachmentsOpenCommandL();
             	    ret = EKeyWasConsumed;
             	    }
-            	else if ( (AknLayoutUtils::LayoutMirrored() && aKeyEvent.iCode == EKeyLeftArrow) ||
-            	          (!AknLayoutUtils::LayoutMirrored() && aKeyEvent.iCode == EKeyRightArrow) )
-        	        {
-        	        parent.LaunchAttachmentActionMenuL();
-        	        ret = EKeyWasConsumed;
-        	        }
         	    }
             }
 		else if ( IsPopupActive() && aType == EEventKey )
 			{
 			// select current
-			if( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyDevice4 || 
+			if( aKeyEvent.iCode == EKeyEnter || 
+			    aKeyEvent.iCode == EKeyDevice4 || 
 				aKeyEvent.iCode == EKeyOK )
 				{
 				DoPopupSelectL();
@@ -509,8 +497,11 @@
 		else
 		    {
 		    // Don't allow line feeds in header fields.
-		    // Could be nice if enter committed the field and moved the focus to next one
-		    if ( aType == EEventKey && (aKeyEvent.iCode == EKeyEnter || aKeyEvent.iScanCode == EStdKeyEnter) )
+		    // Could be nice if enter committed the field and moved the focus
+		    // to next one
+		    if ( aType == EEventKey && 
+		         ( aKeyEvent.iCode == EKeyEnter || 
+		           aKeyEvent.iScanCode == EStdKeyEnter) )
 		        {
 		        ret = FindFocused()->OfferKeyEventL( aKeyEvent, aType );
 		        return EKeyWasConsumed;
@@ -524,14 +515,15 @@
     		{
     		ret = focused->OfferKeyEventL( aKeyEvent, aType );
     		
-    		doScroll = (ret == EKeyWasConsumed); 
+    		doScroll = ( ret == EKeyWasConsumed ); 
     		}
     	}
 
     if( doScroll )
     	{
 		// scroll the screen if the cursor goes beyond the screen
-		CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
+		CNcsComposeViewContainer& parent = 
+            static_cast<CNcsComposeViewContainer&>( iParent );
 		
 		TInt screenPos( -Position().iY );
 		TInt cursorPos( CursorPosition() );
@@ -581,7 +573,8 @@
 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();
@@ -617,19 +610,19 @@
             static_cast<CNcsComposeViewContainer*>( &iParent );
     if ( pOldCtrl == iToField )
         {
-        container->CommitL(EToField);
+        container->CommitL( EToField );
         }
     else if ( pOldCtrl == iCcField) 
         {
-        container->CommitL(ECcField);
+        container->CommitL( ECcField );
         }
     else if ( pOldCtrl == iBccField)
         {
-        container->CommitL(EBccField);
+        container->CommitL( EBccField );
         }
     else if ( pOldCtrl == iSubjectField)
         {
-        container->CommitL(ESubjectField);
+        container->CommitL( ESubjectField );
         }
     
 	// If the attachments label has changed focus
@@ -677,8 +670,10 @@
 		}
 
 	// Then check we didn't move too much and composer still fills the whole
-	// visible area on the screen (i.e. don't scroll below the bottom of the body field)
-	CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
+	// visible area on the screen (i.e. don't scroll below the bottom of the
+	// body field)
+	CNcsComposeViewContainer& parent = 
+        static_cast<CNcsComposeViewContainer&>( iParent );
 	TInt composerHeight = parent.ContentTotalHeight();
     TInt screenHeight = parent.Rect().Height();
     if ( composerHeight <= screenHeight )
@@ -690,17 +685,17 @@
         top = Max( top, screenHeight - composerHeight );
         }
 
-    // The top edge of the header should never be lower than on the top edge of the screen.
-	// For some reason, the calculation above leads to such situation if recipient and subject
-	// fields are scrollable. If that happens, increase the top value to 0 to prevent empty
-	// space showing up above the header area.
+    // The top edge of the header should never be lower than on the top edge
+    // of the screen. For some reason, the calculation above leads to such
+    // situation if recipient and subject fields are scrollable. If that 
+    // happens, increase the top value to 0 to prevent empty space showing up
+    // above the header area.
 	top = Min( top, 0 );
 	
 	// set the new position of the container
 	SetExtent( TPoint( Rect().iTl.iX, top ), Size() );
 	}
 
-// <cmail> Platform layout change
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::SizeChanged()
 // set size
@@ -718,13 +713,12 @@
         const TInt lineCount( ToNcsControl( cur )->LayoutLineCount() );
         if ( lineCount > 0 )
             {
-            NcsUtility::LayoutHeaderControl( cur.Control<CCoeControl>(), rect, currentLine, lineCount );
-			// <cmail>
+            NcsUtility::LayoutHeaderControl( cur.Control<CCoeControl>(), 
+                    rect, currentLine, lineCount );
             // Do not use stored value lineCount because count may change
             // during layout (e.g. when orientation is changed => edit field
             // length may change => it grows or shrinks)
             currentLine += ToNcsControl( cur )->LayoutLineCount();
-			// </cmail>
             }
         } while ( cur.Next() );
         
@@ -733,7 +727,6 @@
 		iAacListBox->SetPopupMaxRect( CalculatePopupRect() );
 		}
 	}
-// </cmail> Platform layout change
 
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::PositionChanged()
@@ -753,14 +746,14 @@
 void CNcsHeaderContainer::ChangePositions()
 	{
     FUNC_LOG;
-	TPoint nextPoint(Rect().iTl);
+	TPoint nextPoint( Rect().iTl );
 
 	CCoeControl* ctrl;
 	CCoeControlArray::TCursor cur = Components().Begin();
 	do 
 		{
 		ctrl = cur.Control<CCoeControl>();
-		ctrl->SetPosition(nextPoint);
+		ctrl->SetPosition( nextPoint );
 		nextPoint.iY += ctrl->Size().iHeight;
 		} 
     while ( cur.Next() );
@@ -774,7 +767,7 @@
 TBool CNcsHeaderContainer::NeedsAifMenu() const
 	{
     FUNC_LOG;
-// <cmail>
+
 	CCoeControl* focused = FindFocused();
 
 	// Has to be an AIF field
@@ -788,7 +781,6 @@
         }
 	
 	return ret;
-// </cmail>
 	}
 
 // ---------------------------------------------------------------------------
@@ -805,34 +797,33 @@
 		CCoeControl* ctrl = cur.Control<CCoeControl>();
 		ret += ctrl->Size().iHeight;
 		} 
-	while (cur.Next());
+	while ( cur.Next() );
 	return ret;
 	}
 
 // -----------------------------------------------------------------------------
-// CNcsHeaderContainer::SetAttachmentLabelTextL()
+// CNcsHeaderContainer::SetAttachmentLabelTextsLD
+//
 // -----------------------------------------------------------------------------
-void CNcsHeaderContainer::SetAttachmentLabelTextL( const TDesC& aText )
-	{
-    FUNC_LOG;
-	if ( aText.Length() >= 1 )
-		{
-		iAttachmentField->SetTextL( aText );
-		ShowAttachmentLabelL();
-		}
+//
+void CNcsHeaderContainer::SetAttachmentLabelTextsLD( 
+    CDesCArray* aAttachmentNames, CDesCArray* aAttachmentSizes )
+    {
+    FUNC_LOG;   
+    iAttachmentField->SetTextsLD( aAttachmentNames, aAttachmentSizes );
+    ShowAttachmentLabelL();
     DrawAttachmentFocusNow();
-	}
+    }
 
 // -----------------------------------------------------------------------------
-// CNcsHeaderContainer::SetAttachmentLabelTextL()
+// CNcsHeaderContainer::FocusedAttachmentLabelIndex
+//
 // -----------------------------------------------------------------------------
-void CNcsHeaderContainer::SetAttachmentLabelTextL( const TDesC& aAttachmentName, 
-                                                   const TDesC& aAttachmentSizeDesc )
+//
+TInt CNcsHeaderContainer::FocusedAttachmentLabelIndex()
     {
     FUNC_LOG;
-    iAttachmentField->SetTextL( aAttachmentName, aAttachmentSizeDesc );
-    ShowAttachmentLabelL();
-    DrawAttachmentFocusNow();
+    return iAttachmentField->FocusedAttachmentLabelIndex();
     }
 
 // -----------------------------------------------------------------------------
@@ -848,9 +839,7 @@
         Components().InsertLC( cur, iAttachmentField );
         CleanupStack::Pop( iAttachmentField );
 
-        // <cmail> Platform layout change
         TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
-        // </cmail> Platform layout change
 
         CCoeControl* pOldCtrl = FindFocused();
         if ( pOldCtrl )
@@ -859,10 +848,7 @@
             }
 
         iAttachmentField->SetFocus( ETrue, ENoDrawNow );
-        // <cmail> Platform layout change
-        //CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
         iFieldSizeObserver.UpdateFieldPosition( iAttachmentField );
-        // </cmail> Platform layout change
         }
     }
 
@@ -902,17 +888,12 @@
 	iAttachmentField->MakeVisible( EFalse );
 	Components().Remove( iAttachmentField );
     
-	// <cmail> Platform layout change
 	TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
-	// </cmail> Platform layout change
 
     // Scroll to currently focused field
 	if ( pNewCtrl )
 	    {
-	    // <cmail> Platform layout change
-	    //CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
 	    iFieldSizeObserver.UpdateFieldPosition( pNewCtrl );
-	    // </cmail> Platform layout change	    
 	    }
 	
 	}
@@ -921,18 +902,19 @@
 // CNcsHeaderContainer::SetBccFieldVisibleL()
 // -----------------------------------------------------------------------------
 //
-void CNcsHeaderContainer::SetBccFieldVisibleL( TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) 
+void CNcsHeaderContainer::SetBccFieldVisibleL( 
+        TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) 
     {
     FUNC_LOG;
-	if (iBccField->IsVisible() == aVisible)
+	if ( iBccField->IsVisible() == aVisible )
 		{
 		return;
 		}
 
 	if ( aVisible )
 		{
-		CCoeControlArray::TCursor cur = Components().Find(iSubjectField);
-		Components().InsertLC(cur,iBccField);
+		CCoeControlArray::TCursor cur = Components().Find( iSubjectField );
+		Components().InsertLC( cur, iBccField );
 		CleanupStack::Pop( iBccField );
 
 		if ( aFocus )
@@ -951,20 +933,18 @@
 		{
 		if ( iBccField->IsFocused() )
 			{
-			CCoeControlArray::TCursor cur = Components().Find(iBccField);
-			ASSERT(cur.IsValid());
+			CCoeControlArray::TCursor cur = Components().Find( iBccField );
+			ASSERT( cur.IsValid() );
 			
-			iBccField->SetFocus(EFalse);
+			iBccField->SetFocus( EFalse );
 
-			cur.Prev(); //Get the control before this field
-			cur.Control<CCoeControl>()->SetFocus(ETrue);
+			cur.Prev(); // Get the control before this field
+			cur.Control<CCoeControl>()->SetFocus( ETrue );
 			}
 		Components().Remove( iBccField );
 		}
 
-	// <cmail> Platform layout change
     TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
-    // </cmail> Platform layout change
 
 	if ( aDrawNow == EDrawNow )
 		{
@@ -975,7 +955,8 @@
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::SetCcFieldVisibleL()
 // -----------------------------------------------------------------------------
-void CNcsHeaderContainer::SetCcFieldVisibleL( TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) 
+void CNcsHeaderContainer::SetCcFieldVisibleL( 
+        TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) 
 	{
     FUNC_LOG;
 	if ( iCcField->IsVisible() == aVisible )
@@ -985,7 +966,7 @@
 
 	if ( aVisible )
 		{
-		Components().InsertAfterLC( Components().Id(*iToField), iCcField );
+		Components().InsertAfterLC( Components().Id( *iToField ), iCcField );
 		CleanupStack::Pop( iCcField );
 
 		if ( aFocus )
@@ -1003,15 +984,13 @@
 		{
 		if( iCcField->IsFocused() )
 			{
-			iCcField->SetFocus(EFalse);
-			iToField->SetFocus(ETrue);
+			iCcField->SetFocus( EFalse );
+			iToField->SetFocus( ETrue );
 			}
-		Components().Remove(iCcField);
+		Components().Remove( iCcField );
 		}
     
-	// <cmail> Platform layout change
 	TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() );
-	// </cmail> Platform layout change
 
     if ( aDrawNow == EDrawNow )
 		{
@@ -1040,7 +1019,7 @@
 	CCoeControlArray::TCursor cur = Components().Begin();
 	do 
 		{
-        MNcsControl* ctrl = ToNcsControl(cur);
+        MNcsControl* ctrl = ToNcsControl( cur );
         cnt += ctrl->LineCount();
         } 
     while ( cur.Next() );
@@ -1058,7 +1037,7 @@
 	CCoeControlArray::TCursor cur = Components().Begin();
 	do 
 		{
-		MNcsControl* ctrl = ToNcsControl(cur);
+		MNcsControl* ctrl = ToNcsControl( cur );
 		cnt += ctrl->ScrollableLines();
 		} 
 	while ( cur.Next() );
@@ -1081,7 +1060,8 @@
 	MNcsControl* ncsCtrl = dynamic_cast<MNcsControl*>( coe );
 	// This will give the the position relative to the top of the control
 	TInt pos = ncsCtrl->CursorPosition();
-	// add the location of the top of the control relative to the top of the header.
+	// add the location of the top of the control relative to the top
+	// of the header.
 	pos += coe->Rect().iTl.iY - Rect().iTl.iY;
 	return pos;
 	}
@@ -1098,7 +1078,7 @@
 	do 
 		{
         CCoeControl* coe = cur.Control<CCoeControl>();
-        MNcsControl* ctrl = ToNcsControl(cur);
+        MNcsControl* ctrl = ToNcsControl( cur );
         if ( !coe->IsFocused() )
             {
             cnt += ctrl->LineCount();
@@ -1132,18 +1112,18 @@
 // CNcsHeaderContainer::UpdatePopupContactListL()
 // -----------------------------------------------------------------------------
 //
-void CNcsHeaderContainer::UpdatePopupContactListL( const TDesC& aMatchString, TBool /*aListAll*/ )
+void CNcsHeaderContainer::UpdatePopupContactListL( 
+        const TDesC& aMatchString, TBool /*aListAll*/ )
 	{
     FUNC_LOG;
 
-    // <cmail> do update only for address fields
+    // do update only for address fields
 	CCoeControl* focused = FindFocused();
 	
 	if ( !IsAddressInputField( focused ) )
 	    {
 	    return;
 	    }
-	// </cmail>
 	    
 	if ( aMatchString.CompareC( KNullDesC ) == 0 || 
 	     aMatchString.Compare( KAddressDelimeterSemiColon ) == 0 )
@@ -1171,15 +1151,14 @@
 void CNcsHeaderContainer::ClosePopupContactListL()
 	{
     FUNC_LOG;
-    // <cmail>
+
     if ( iAacListBox->IsVisible() )
         {
-    // </cmail>
         iAacListBox->MakeVisible( EFalse );
         ShowPopupMenuBarL( EFalse );
         
-        // The focused address field should be redrawn after the popup is closed to fix
-        // the field border.
+        // The focused address field should be redrawn after the popup is
+        // closed to fix the field border.
         if ( iToField->IsFocused() )
             {
             iToField->DrawDeferred();
@@ -1192,9 +1171,7 @@
             {
             iBccField->DrawDeferred();
             }
-    // <cmail>
         }
-    // </cmail>
 	}
 
 // ---------------------------------------------------------------------------
@@ -1227,7 +1204,6 @@
 	{
     FUNC_LOG;
 
-// <cmail>
     CCoeControl* focused = FindFocused();
 
     if ( IsAddressInputField( focused ) )
@@ -1242,8 +1218,6 @@
     	TEventCode code = EEventKey;
     	field->OfferKeyEventL( event, code );
         }
-// </cmail>
-
 	}
 
 // ---------------------------------------------------------------------------
@@ -1293,9 +1267,6 @@
 	{
     FUNC_LOG;
     // get focused control rect
-    //<cmail> Added a NULL check for FindFocused().
-    // Find out why we end up here in S60 5.0 if there is no focused
-    // item. In S60 3.2.3 this kind of situation seems not to be possible.
 	TRect popupRect;
 
     CCoeControl* focused = FindFocused();
@@ -1306,11 +1277,13 @@
 
         TRect editorRect = aifEditor->Editor()->Rect();
         
-        popupRect.iTl = TPoint( editorRect.iTl.iX - 1, editorRect.iTl.iY + aifEditor->CursorPosition() + 1 );
+        popupRect.iTl =
+            TPoint( editorRect.iTl.iX - 1, 
+                    editorRect.iTl.iY + aifEditor->CursorPosition() + 1 );
         
-        popupRect.iBr = TPoint( editorRect.iBr.iX + 1, iParent.Rect().iBr.iY );
+        popupRect.iBr = 
+            TPoint( editorRect.iBr.iX + 1, iParent.Rect().iBr.iY );
         }
-    //</cmail>
 
     return popupRect;
 	}
@@ -1326,7 +1299,6 @@
 
 	if( iAacListBox->IsRemoteLookupItemSelected() )
 		{
-// <cmail>
 		CCoeControl* focused = FindFocused();
 		
 		if ( IsAddressInputField( focused ) )
@@ -1337,9 +1309,13 @@
     		addressField = static_cast<CNcsAddressInputField*>( focused );
     		HBufC* lookupText = addressField->GetLookupTextLC();
     		CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason ex;
+    		// set focus to false for header - the focus should be on popup
+    		focused->SetFocus( EFalse, ENoDrawNow );
             CNcsEmailAddressObject* address = ExecuteRemoteSearchL(
                 ex, *lookupText );
             iRALInProgress = EFalse;
+            // set focus back to on
+            focused->SetFocus( ETrue, ENoDrawNow );
             if ( address )
                 {
                 CleanupStack::PushL( address );
@@ -1347,14 +1323,15 @@
                 CleanupStack::PopAndDestroy( address );
                 }
             CleanupStack::PopAndDestroy( lookupText );
-            CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
-            parent.FocusChanged(EDrawNow);
+            CNcsComposeViewContainer& parent = 
+                static_cast<CNcsComposeViewContainer&>( iParent );
+            parent.FocusChanged( EDrawNow );
 		    }
-// </cmail>
 		}
 	else if( !iAacListBox->IsPopupEmpty() )
 		{
-		CNcsEmailAddressObject* emailAddress  = iAacListBox->ReturnCurrentEmailAddressLC();
+		CNcsEmailAddressObject* emailAddress  = 
+            iAacListBox->ReturnCurrentEmailAddressLC();
 		if( emailAddress )
 			{
             if ( emailAddress->EmailAddress().Compare( KNullDesC ) != 0 )
@@ -1363,10 +1340,11 @@
                 }
             else
                 {           
-                // selected contact doesn't have email address, launch remote contact lookup
-                // rcl must be usable, since otherwise there couldn't be any items
-                // without email addresses
-                CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason exitReason;
+                // selected contact doesn't have email address, launch remote
+                // contact lookup rcl must be usable, since otherwise there 
+                // couldn't be any items without email addresses
+                CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason
+                    exitReason;
                 CNcsEmailAddressObject* remAddress = ExecuteRemoteSearchL(
                     exitReason,
                     emailAddress->DisplayName() );
@@ -1443,7 +1421,8 @@
 // CNcsHeaderContainer::GetToFieldAddressesL
 // ---------------------------------------------------------------------------
 //
-const RPointerArray<CNcsEmailAddressObject>& CNcsHeaderContainer::GetToFieldAddressesL( TBool aParseNow )
+const RPointerArray<CNcsEmailAddressObject>& 
+CNcsHeaderContainer::GetToFieldAddressesL( TBool aParseNow )
     {
 	return iToField->GetAddressesL( aParseNow );
     }
@@ -1452,7 +1431,8 @@
 // CNcsHeaderContainer::GetCcFieldAddressesL
 // ---------------------------------------------------------------------------
 //
-const RPointerArray<CNcsEmailAddressObject>& CNcsHeaderContainer::GetCcFieldAddressesL( TBool aParseNow )
+const RPointerArray<CNcsEmailAddressObject>& 
+CNcsHeaderContainer::GetCcFieldAddressesL( TBool aParseNow )
     {
 	return iCcField->GetAddressesL( aParseNow );
     }
@@ -1461,7 +1441,8 @@
 // CNcsHeaderContainer::GetBccFieldAddressesL
 // ---------------------------------------------------------------------------
 //
-const RPointerArray<CNcsEmailAddressObject>& CNcsHeaderContainer::GetBccFieldAddressesL( TBool aParseNow )
+const RPointerArray<CNcsEmailAddressObject>& 
+CNcsHeaderContainer::GetBccFieldAddressesL( TBool aParseNow )
     {
 	return iBccField->GetAddressesL( aParseNow );
     }
@@ -1473,9 +1454,10 @@
 HBufC* CNcsHeaderContainer::GetSubjectLC() const
     {
     FUNC_LOG;
-	HBufC* subject = HBufC::NewLC(iSubjectField->Editor()->TextLength() + 2);
+	HBufC* subject = 
+        HBufC::NewLC( iSubjectField->Editor()->TextLength() + 2 );
 	TPtr des = subject->Des();
-	iSubjectField->Editor()->GetText(des);
+	iSubjectField->Editor()->GetText( des );
 	return subject;
     }
 
@@ -1499,9 +1481,6 @@
 	return iCcField->IsVisible(); 
     }
 
-// <cmail> Unneeded IsFocusAif removed
-// </cmail>
-
 // ---------------------------------------------------------------------------
 // CNcsHeaderContainer::IsFocusAttachments
 // ---------------------------------------------------------------------------
@@ -1589,7 +1568,8 @@
 TInt CNcsHeaderContainer::GetAttachmentCount() const
     {
     FUNC_LOG;
-    CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
+    CNcsComposeViewContainer& parent = 
+        static_cast<CNcsComposeViewContainer&>( iParent );
     return parent.GetAttachmentCount();
     }
 
@@ -1600,7 +1580,8 @@
 TInt CNcsHeaderContainer::HasRemoteAttachments() const
     {
     FUNC_LOG;
-    CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent );
+    CNcsComposeViewContainer& parent = 
+        static_cast<CNcsComposeViewContainer&>( iParent );
     return parent.HasRemoteAttachments();
     }
 
@@ -1653,7 +1634,8 @@
 // CNcsHeaderContainer::SetToFieldAddressesL
 // ---------------------------------------------------------------------------
 //
-void CNcsHeaderContainer::SetToFieldAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddress )
+void CNcsHeaderContainer::SetToFieldAddressesL( 
+        const RPointerArray<CNcsEmailAddressObject>& aAddress )
     {
     FUNC_LOG;
 	iToField->SetAddressesL( aAddress );
@@ -1663,31 +1645,34 @@
 // CNcsHeaderContainer::SetCcFieldAddressesL
 // ---------------------------------------------------------------------------
 //
-void CNcsHeaderContainer::SetCcFieldAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddress )
+void CNcsHeaderContainer::SetCcFieldAddressesL( 
+        const RPointerArray<CNcsEmailAddressObject>& aAddress )
     {
     FUNC_LOG;
 	iCcField->SetAddressesL( aAddress );
-	if (!iCcField->IsEmpty())
-		SetCcFieldVisibleL(ETrue, ENoDrawNow);
+	if ( !iCcField->IsEmpty() )
+		SetCcFieldVisibleL( ETrue, ENoDrawNow );
     }
 
 // ---------------------------------------------------------------------------
 // CNcsHeaderContainer::SetBccFieldAddressesL
 // ---------------------------------------------------------------------------
 //
-void CNcsHeaderContainer::SetBccFieldAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddress )
+void CNcsHeaderContainer::SetBccFieldAddressesL( 
+        const RPointerArray<CNcsEmailAddressObject>& aAddress )
     {
     FUNC_LOG;
 	iBccField->SetAddressesL( aAddress );
-	if (!iBccField->IsEmpty())
-		SetBccFieldVisibleL(ETrue, ENoDrawNow);
+	if ( !iBccField->IsEmpty() )
+		SetBccFieldVisibleL( ETrue, ENoDrawNow );
     }
 
 // ---------------------------------------------------------------------------
 // CNcsHeaderContainer::AppendToFieldAddressesL
 // ---------------------------------------------------------------------------
 //
-void CNcsHeaderContainer::AppendToFieldAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddresses )
+void CNcsHeaderContainer::AppendToFieldAddressesL( 
+        const RPointerArray<CNcsEmailAddressObject>& aAddresses )
     {
     FUNC_LOG;
 	iToField->AppendAddressesL( aAddresses );
@@ -1697,7 +1682,8 @@
 // CNcsHeaderContainer::AppendCcFieldAddressesL
 // ---------------------------------------------------------------------------
 //
-void CNcsHeaderContainer::AppendCcFieldAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddresses )
+void CNcsHeaderContainer::AppendCcFieldAddressesL( 
+        const RPointerArray<CNcsEmailAddressObject>& aAddresses )
     {
     FUNC_LOG;
 	iCcField->AppendAddressesL( aAddresses );
@@ -1707,7 +1693,8 @@
 // CNcsHeaderContainer::AppendBccFieldAddressesL
 // ---------------------------------------------------------------------------
 //
-void CNcsHeaderContainer::AppendBccFieldAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddresses )
+void CNcsHeaderContainer::AppendBccFieldAddressesL( 
+        const RPointerArray<CNcsEmailAddressObject>& aAddresses )
     {
     FUNC_LOG;
 	iBccField->AppendAddressesL( aAddresses );
@@ -1740,7 +1727,7 @@
 void CNcsHeaderContainer::IncludeAddressL(const CNcsEmailAddressObject& aEml )
     {
     FUNC_LOG;
-// <cmail>
+
 	CCoeControl* focused = FindFocused();
 	if ( IsAddressInputField( focused ) )
 	    {
@@ -1748,7 +1735,6 @@
     	aifFocused = static_cast<CNcsAddressInputField*>( focused );
     	aifFocused->AddAddressL( aEml );
 	    }
-// </cmail>
     }
 
 // ---------------------------------------------------------------------------
@@ -1758,8 +1744,6 @@
 void CNcsHeaderContainer::IncludeAddressL()
     {
     FUNC_LOG;
-// is this methods needed at all?
-// get the curren selection from popup list if there is any?
     }
 
 // ---------------------------------------------------------------------------
@@ -1801,7 +1785,8 @@
 TBool CNcsHeaderContainer::AreAddressFieldsEmpty() const
 	{
     FUNC_LOG;
-    return (IsToFieldEmpty() && IsCcFieldEmpty() && IsBccFieldEmpty()) || iRALInProgress;
+    return ( IsToFieldEmpty() && IsCcFieldEmpty() && IsBccFieldEmpty() ) || 
+            iRALInProgress;
 	}
 
 // ---------------------------------------------------------------------------
@@ -1813,7 +1798,6 @@
     FUNC_LOG;
     }
 
-// <cmail> Platform layout change    
 // ---------------------------------------------------------------------------
 // CNcsHeaderContainer::LayoutLineCount
 // ---------------------------------------------------------------------------
@@ -1826,12 +1810,13 @@
     do
         {
         totalLineCount += ToNcsControl( cur )->LayoutLineCount();                       
-        } while ( cur.Next() );
+        } 
+    while ( cur.Next() );
+    
     return totalLineCount;
     }
-// </cmail> Platform layout change    
 
-// <cmail>
+
 // ---------------------------------------------------------------------------
 // CNcsHeaderContainer::IsAddressInputField
 // ---------------------------------------------------------------------------
@@ -1853,7 +1838,6 @@
     
     return ret;
     }
-// </cmail>
 
 // ---------------------------------------------------------------------------
 // CNcsHeaderContainer::ExecuteRemoteSearchL
@@ -1873,19 +1857,23 @@
     emailAddress.CreateL( KMaxLength );
     CleanupClosePushL( emailAddress );
 
-    TBool contactSelected = CFsDelayedLoader::InstanceL()->GetContactHandlerL()->GetNameAndEmailFromRemoteLookupL( 
-        iMailBox, aSearchText, displayname, emailAddress );
+    TBool contactSelected = 
+        CFsDelayedLoader::InstanceL()->GetContactHandlerL()->
+            GetNameAndEmailFromRemoteLookupL( 
+                iMailBox, aSearchText, displayname, emailAddress );
 
     CNcsEmailAddressObject* address = NULL;
     if ( contactSelected )
         {
         if ( !displayname.Length() )
             {
-            address = CNcsEmailAddressObject::NewL( emailAddress, emailAddress ); 
+            address = 
+                CNcsEmailAddressObject::NewL( emailAddress, emailAddress );
             }
         else
             {
-            address = CNcsEmailAddressObject::NewL( displayname, emailAddress );  
+            address = 
+                CNcsEmailAddressObject::NewL( displayname, emailAddress );
             }
         }
 
@@ -1911,16 +1899,14 @@
         }
     }
 
-//<cmail>
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::SwitchChangeMskOff
 // sets up iSwitchChangeMskOff falg 
 // -----------------------------------------------------------------------------
-void CNcsHeaderContainer::SwitchChangeMskOff(TBool aTag)
+void CNcsHeaderContainer::SwitchChangeMskOff( TBool aTag )
     {
     iSwitchChangeMskOff = aTag;
     }
-// </cmail>
 
 // -----------------------------------------------------------------------------
 // CNcsHeaderContainer::OpenPhonebookL
@@ -1928,7 +1914,8 @@
 // -----------------------------------------------------------------------------
 void CNcsHeaderContainer::OpenPhonebookL()
     {
-    CNcsComposeViewContainer* container = static_cast<CNcsComposeViewContainer*>( &iParent );
+    CNcsComposeViewContainer* container = 
+        static_cast<CNcsComposeViewContainer*>( &iParent );
     container->AppendAddressesL();
     }
 
--- a/emailuis/emailui/src/ncspopuplistbox.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/ncspopuplistbox.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -213,7 +213,8 @@
 //      
 void CNcsPopupListBox::HandleListBoxEventL( CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
     {
-    if (aEventType == EEventItemClicked)
+    if ( aEventType == EEventItemClicked || 
+    	 aEventType == EEventItemSingleClicked )
         {
         iHeaderContainer.DoPopupSelectL();
         }
--- a/emailuis/emailui/src/ncsutility.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/emailui/src/ncsutility.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -20,13 +20,11 @@
 // INCLUDE FILES
 #include "emailtrace.h"
 #include <StringLoader.h>
+#include <AknsUtils.h>
 #include <AknUtils.h>
-//<cmail>
-#include <AknsUtils.h>
 #include <AknsSkinInstance.h>
 #include <aknbutton.h>
 #include <eikedwin.h>
-//</cmail>
 #include <FreestyleEmailUi.rsg>
 #include <RPbkViewResourceFile.h>
 #include <CPbkContactEngine.h>
@@ -37,17 +35,14 @@
 #include <fbs.h>
 #include <flogger.h>
 #include <aknenv.h>	// CAknEnv
-//<cmail>
+
 #include "CFSMailBox.h"
 #include "CFSMailClient.h"
 #include "CFSMailAddress.h"
-//</cmail>
 
-//<cmail> Platform layout changes
 #include <aknlayoutscalable_apps.cdl.h>
 #include <layoutmetadata.cdl.h>
 #include <AknLayoutFont.h>
-//</cmail> Platform layout changes
 
 #include "ncsutility.h"
 #include "ncsemailaddressobject.h"
@@ -56,13 +51,11 @@
 #include "FreestyleEmailUiUtilities.h"
 #include "FreestyleEmailUiLayoutData.h"
 
-//<cmail>
 // CONSTANTS
 const TInt KFSUtilityMinColorValue = 0;
 const TInt KFSUtilityMaxColorValue = 255;
 const TInt KFSUtilityThresholdColorValue = 200;
 const TInt KFSUtilityThresholdColorMiddleValue = 127;
-//</cmail>
 
 // ========================= MEMBER FUNCTIONS ==================================
 
@@ -71,7 +64,8 @@
 // NcsUtility::CompleteRelativePathL()
 // -----------------------------------------------------------------------------
 //
-void NcsUtility::CompleteRelativePathL( const TDesC& aRelativePath, TPtr& aAbsolutePath )
+void NcsUtility::CompleteRelativePathL( 
+        const TDesC& aRelativePath, TPtr& aAbsolutePath )
 	{
     FUNC_LOG;
 
@@ -95,11 +89,13 @@
 //
 // -----------------------------------------------------------------------------
 //
-HBufC* NcsUtility::GenerateFromLineToMessageBodyL( const RPointerArray<CNcsEmailAddressObject>& aFromArray )
+HBufC* NcsUtility::GenerateFromLineToMessageBodyL( 
+        const RPointerArray<CNcsEmailAddressObject>& aFromArray )
 	{
     FUNC_LOG;
 
-    HBufC* buf = DoGenerateAddressLineToMessageBodyL( R_NCS_ENGINE_EMAIL_FROM, aFromArray );
+    HBufC* buf = DoGenerateAddressLineToMessageBodyL( 
+            R_NCS_ENGINE_EMAIL_FROM, aFromArray );
 
 	return buf;
 	}
@@ -254,7 +250,8 @@
 //
 // -----------------------------------------------------------------------------
 //
-CNcsEmailAddressObject* NcsUtility::CreateNcsAddressL( const CFSMailAddress& aFsAddress )
+CNcsEmailAddressObject* NcsUtility::CreateNcsAddressL( 
+        const CFSMailAddress& aFsAddress )
 	{
     FUNC_LOG;
 
@@ -282,7 +279,8 @@
 // Caller takes the ownership of the returned address object
 // -----------------------------------------------------------------------------
 //
-CFSMailAddress* NcsUtility::CreateFsAddressL( const CNcsEmailAddressObject& aNcsAddress )
+CFSMailAddress* NcsUtility::CreateFsAddressL( 
+        const CNcsEmailAddressObject& aNcsAddress )
 	{
     FUNC_LOG;
 
@@ -299,7 +297,8 @@
 //
 // -----------------------------------------------------------------------------
 //
-HBufC* NcsUtility::FormatSubjectLineL( const TDesC& aNewSubjectLine, const TDesC& aPrefix )
+HBufC* NcsUtility::FormatSubjectLineL( 
+        const TDesC& aNewSubjectLine, const TDesC& aPrefix )
 	{
     FUNC_LOG;
 
@@ -325,7 +324,9 @@
 
 	formattedSubjectLinePtr.Trim();
 
-	HBufC* finalSubject = HBufC::NewL( formattedSubjectLinePtr.Length() + prefixPtr.Length() + KSpace().Length() );
+	HBufC* finalSubject = HBufC::NewL( 
+	        formattedSubjectLinePtr.Length() + prefixPtr.Length() + 
+	        KSpace().Length() );
 	TPtr ptr = finalSubject->Des();
 	if ( AknLayoutUtils::LayoutMirrored() )
 		{
@@ -351,13 +352,16 @@
 //
 // -----------------------------------------------------------------------------
 //
-void NcsUtility::ConvertAddressArrayL( const RPointerArray<CFSMailAddress>& aSrc, RPointerArray<CNcsEmailAddressObject>& aDst )
+void NcsUtility::ConvertAddressArrayL( 
+        const RPointerArray<CFSMailAddress>& aSrc, 
+        RPointerArray<CNcsEmailAddressObject>& aDst )
 	{
     FUNC_LOG;
 
  	for ( TInt i=0; i<aSrc.Count(); i++ )
  		{
-		CNcsEmailAddressObject* ncsRecipient = NcsUtility::CreateNcsAddressL( *aSrc[i] );
+		CNcsEmailAddressObject* ncsRecipient = 
+            NcsUtility::CreateNcsAddressL( *aSrc[i] );
 		CleanupStack::PushL( ncsRecipient );
 		aDst.AppendL( ncsRecipient );
 		CleanupStack::Pop( ncsRecipient );
@@ -370,13 +374,16 @@
 // Caller takes the ownership of address objects pointoed in the array aDst.
 // -----------------------------------------------------------------------------
 //
-void NcsUtility::ConvertAddressArrayL( const RPointerArray<CNcsEmailAddressObject>& aSrc, RPointerArray<CFSMailAddress>& aDst )
+void NcsUtility::ConvertAddressArrayL( 
+        const RPointerArray<CNcsEmailAddressObject>& aSrc, 
+        RPointerArray<CFSMailAddress>& aDst )
 	{
     FUNC_LOG;
 
  	for ( TInt i=0; i<aSrc.Count(); i++ )
  		{
-		CFSMailAddress* fsRecipient = NcsUtility::CreateFsAddressL( *aSrc[i] );
+		CFSMailAddress* fsRecipient = 
+            NcsUtility::CreateFsAddressL( *aSrc[i] );
 		CleanupStack::PushL( fsRecipient );
 		aDst.AppendL( fsRecipient );
 		CleanupStack::Pop( fsRecipient );
@@ -391,7 +398,10 @@
 //
 // -----------------------------------------------------------------------------
 //
-void NcsUtility::LoadScalableIconL( const TDesC& aMifRelativeFileName, TInt aImgId, TInt aMaskId, CEikImage*& aIcon, CFbsBitmap*& aImage, CFbsBitmap*& aMask )
+void NcsUtility::LoadScalableIconL( 
+        const TDesC& aMifRelativeFileName, TInt aImgId, 
+        TInt aMaskId, CEikImage*& aIcon, 
+        CFbsBitmap*& aImage, CFbsBitmap*& aMask )
     {
     FUNC_LOG;
 
@@ -442,8 +452,9 @@
 // NcsUtility::IsEqualAddressArray
 // -----------------------------------------------------------------------------
 //
-TBool NcsUtility::IsEqualAddressArray( const RPointerArray<CFSMailAddress>& aAddresses1,
-                                        const RPointerArray<CFSMailAddress>& aAddresses2 )
+TBool NcsUtility::IsEqualAddressArray( 
+        const RPointerArray<CFSMailAddress>& aAddresses1,
+        const RPointerArray<CFSMailAddress>& aAddresses2 )
 	{
     FUNC_LOG;
 
@@ -453,11 +464,13 @@
 		}
     for ( TInt i=0; i<aAddresses1.Count(); i++ )
     	{
-    	if ( aAddresses1[i]->GetEmailAddress().Compare( aAddresses2[i]->GetEmailAddress() ) != 0 )
+    	if ( aAddresses1[i]->GetEmailAddress().Compare( 
+    	        aAddresses2[i]->GetEmailAddress() ) != 0 )
     		{
     		return EFalse;
     		}
-    	if ( aAddresses1[i]->GetDisplayName().Compare( aAddresses2[i]->GetDisplayName() ) != 0 )
+    	if ( aAddresses1[i]->GetDisplayName().Compare( 
+    	        aAddresses2[i]->GetDisplayName() ) != 0 )
     		{
     		return EFalse;
     		}
@@ -503,10 +516,12 @@
 			ms.iAifEditorMarginVertical = KAifEditorMarginVerticalSmall;
 			ms.iAifEditorHeight = KAifEditorHeightSmall;
 			ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottomSmall;
-			ms.iAttachmentExtraHeightBottom = KAttachmentExtraHeightBottomSmall;
+			ms.iAttachmentExtraHeightBottom = 
+                KAttachmentExtraHeightBottomSmall;
 			ms.iIconMarginPriorityVertical = KIconMarginPriorityVerticalSmall;
 			ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVerticalSmall;
-            ms.iIconMarginAttachmentVertical = KIconMarginAttachmentVerticalSmall;
+            ms.iIconMarginAttachmentVertical = 
+                KIconMarginAttachmentVerticalSmall;
 			ms.iLabelFontHeightPx = KLabelFontHeightPxSmall;
 			ms.iEditorFontHeightPx = KEditorFontHeightPxSmall;
 			}
@@ -518,10 +533,12 @@
 			ms.iAifEditorMarginVertical = KAifEditorMarginVerticalLarge;
 			ms.iAifEditorHeight = KAifEditorHeightLarge;
 			ms.iSubjectExtraHeightBottom = KSubjectExtraHeightBottomLarge;
-			ms.iAttachmentExtraHeightBottom = KAttachmentExtraHeightBottomLarge;
+			ms.iAttachmentExtraHeightBottom = 
+                KAttachmentExtraHeightBottomLarge;
 			ms.iIconMarginPriorityVertical = KIconMarginPriorityVerticalLarge;
 			ms.iIconMarginFollowUpVertical = KIconMarginFollowUpVerticalLarge;
-            ms.iIconMarginAttachmentVertical = KIconMarginAttachmentVerticalLarge;
+            ms.iIconMarginAttachmentVertical = 
+                KIconMarginAttachmentVerticalLarge;
 			ms.iLabelFontHeightPx = KLabelFontHeightPxLarge;
 			ms.iEditorFontHeightPx = KEditorFontHeightPxLarge;
 			}
@@ -541,8 +558,8 @@
 
 	// Base the font on logical font passed to us
 	const CFont* logicalFont = AknLayoutUtils::FontFromId( aLogicalFontId );
-	// Note: This font is owned by the application's system font array (where it
-	// is likely already to have been created) and does not need to be
+	// Note: This font is owned by the application's system font array (where
+	// it is likely already to have been created) and does not need to be
 	// released. It can just go out of scope.
 
 	// Extract font information
@@ -570,7 +587,8 @@
 // NcsUtility::GetLayoutFont
 // -----------------------------------------------------------------------------
 //
-const CFont* NcsUtility::GetLayoutFont(const TRect& aParent, TNcsLayoutFont aUsage )
+const CFont* NcsUtility::GetLayoutFont(
+        const TRect& aParent, TNcsLayoutFont aUsage )
     {
     FUNC_LOG;
     TAknLayoutText layoutText;
@@ -729,7 +747,6 @@
     return error;
     }
 
-// <cmail> Platform layout changes
 // -----------------------------------------------------------------------------
 // NcsUtility::HeaderCaptionPaneRect
 // -----------------------------------------------------------------------------
@@ -746,7 +763,8 @@
 // NcsUtility::HeaderDetailPaneRect
 // -----------------------------------------------------------------------------
 //
-TRect NcsUtility::HeaderDetailPaneRect( const TRect& aParent, const TInt aRows, TBool aSameRow )
+TRect NcsUtility::HeaderDetailPaneRect( 
+        const TRect& aParent, const TInt aRows, TBool aSameRow )
     {
     FUNC_LOG;
     const TInt variety( aRows == 1 ? 0 : 1 );
@@ -764,7 +782,8 @@
 // NcsUtility::HeaderDetailIconRect
 // -----------------------------------------------------------------------------
 //
-TRect NcsUtility::HeaderDetailIconRect( const TRect& aParent, const TInt aRows, const THeaderDetailIcon aIcon )
+TRect NcsUtility::HeaderDetailIconRect( 
+        const TRect& aParent, const TInt aRows, const THeaderDetailIcon aIcon )
     {
     FUNC_LOG;
     const TInt variety( aRows == 1 ? 0 : 1 );
@@ -816,7 +835,6 @@
     return listCmailPaneRect.Rect();
     }
 
-//<cmail>
 // -----------------------------------------------------------------------------
 // NcsUtility::SeparatorSizeInThisResolution
 //
@@ -894,7 +912,6 @@
     captionTextRect.LayoutText( layoutRect.Rect(), AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1() );
     return Abs( cmailPaneRect.iBr.iX - captionTextRect.TextRect().iBr.iX );
     }
-//</cmail>
 
 // -----------------------------------------------------------------------------
 // NcsUtility::ListCmailBodyPaneRect
@@ -915,14 +932,17 @@
 void NcsUtility::LayoutCaptionLabel( CEikLabel* aLabel, const TRect& aParentRect )
     {
     FUNC_LOG;
-    AknLayoutUtils::LayoutLabel( aLabel, NcsUtility::HeaderCaptionPaneRect( aParentRect ), AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1().LayoutLine() );
+    AknLayoutUtils::LayoutLabel( 
+            aLabel, NcsUtility::HeaderCaptionPaneRect( aParentRect ), 
+            AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1().LayoutLine() );
     }
 
 // -----------------------------------------------------------------------------
 // NcsUtility::LayoutCaptionLabel
 // -----------------------------------------------------------------------------
 //
-void NcsUtility::LayoutCaptionButton( CAknButton* aButton, const TRect& aParentRect)
+void NcsUtility::LayoutCaptionButton( 
+        CAknButton* aButton, const TRect& aParentRect)
     {
     FUNC_LOG;
     TAknLayoutText layoutText;
@@ -937,7 +957,8 @@
     TInt bottomMargin;
     
     // Getting editor's top and bottom margin from its layout
-    textComponentLayout = AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1(
+    textComponentLayout = 
+        AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1(
             KHeaderDetailTextPaneVariety );
     fontId = textComponentLayout.LayoutLine().FontId();
     
@@ -948,7 +969,9 @@
         HeaderDetailPaneRect( aParentRect, 1, ETrue ),
         AknLayoutScalable_Apps::bg_button_pane_cp12() );
     
-    textComponentLayout = AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t2( labelVariety );
+    textComponentLayout = 
+        AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t2( 
+                labelVariety );
     layoutText.LayoutText(
         HeaderDetailPaneRect( aParentRect, 1, ETrue ),
         textComponentLayout.LayoutLine() );
@@ -967,17 +990,22 @@
 // NcsUtility::LayoutDetailLabel
 // -----------------------------------------------------------------------------
 //
-void NcsUtility::LayoutDetailLabel( CEikLabel* aLabel, const TRect& aParentRect )
+void NcsUtility::LayoutDetailLabel( 
+        CEikLabel* aLabel, const TRect& aParentRect, TInt aRow)
     {
     FUNC_LOG;
-    AknLayoutUtils::LayoutLabel( aLabel, NcsUtility::HeaderDetailPaneRect( aParentRect, 1, ETrue ), AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( 0 ).LayoutLine() );
+    TRect rect( NcsUtility::HeaderDetailPaneRect( aParentRect, 1, ETrue ) );
+    rect.Move( 0, aRow*rect.Height() );
+    AknLayoutUtils::LayoutLabel( aLabel, rect, AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_t1( 0 ).LayoutLine() );
     }
 
 // -----------------------------------------------------------------------------
 // NcsUtility::LayoutDetailEdwin
 // -----------------------------------------------------------------------------
 //
-void NcsUtility::LayoutDetailEdwin( CEikEdwin* aEdwin, const TRect& aParentRect, const TInt aLineCount, const TBool aBackIcon  )
+void NcsUtility::LayoutDetailEdwin( 
+        CEikEdwin* aEdwin, const TRect& aParentRect, 
+        const TInt aLineCount, const TBool aBackIcon )
     {
     FUNC_LOG;
     TAknMultiLineTextLayout edwinLayout;
@@ -999,8 +1027,9 @@
 // NcsUtility::LayoutDetailEdwin
 // -----------------------------------------------------------------------------
 //
-void NcsUtility::LayoutDetailEdwinTouch( CEikEdwin* aEdwin, const TRect& aParentRect,
-                                         const TInt aLineCount, const TBool /*aBackIcon*/  )
+void NcsUtility::LayoutDetailEdwinTouch( 
+        CEikEdwin* aEdwin, const TRect& aParentRect,
+        const TInt aLineCount, const TBool /*aBackIcon*/  )
     {
     FUNC_LOG;
     TAknMultiLineTextLayout edwinLayout;
@@ -1021,7 +1050,8 @@
 // NcsUtility::HeaderControlPosition
 // -----------------------------------------------------------------------------
 //
-TPoint NcsUtility::HeaderControlPosition( const TRect& aParentRect, const TInt aCurrentLine )
+TPoint NcsUtility::HeaderControlPosition( 
+        const TRect& aParentRect, const TInt aCurrentLine )
     {
     FUNC_LOG;
     TAknLayoutRect detailPane;
@@ -1034,7 +1064,9 @@
 // NcsUtility::LayoutHeaderControl
 // -----------------------------------------------------------------------------
 //
-void NcsUtility::LayoutHeaderControl( CCoeControl* aControl, const TRect& aParentRect, const TInt aCurrentLine, const TInt aNumberOfLines )
+void NcsUtility::LayoutHeaderControl( 
+        CCoeControl* aControl, const TRect& aParentRect, 
+        const TInt aCurrentLine, const TInt aNumberOfLines )
     {
     FUNC_LOG;
     TAknLayoutRect detailPane;
@@ -1049,10 +1081,9 @@
 // NcsUtility::LayoutBodyEdwin
 // -----------------------------------------------------------------------------
 //
-//<cmail>
-void NcsUtility::LayoutBodyEdwin( CEikEdwin* aEdwin, const TRect& aParentRect, const TInt aCurrentLine, const TInt aNumberOfLines,
-        TInt& aSeparatorYPosition )
-//</cmail>
+void NcsUtility::LayoutBodyEdwin( 
+        CEikEdwin* aEdwin, const TRect& aParentRect, const TInt aCurrentLine, 
+        const TInt aNumberOfLines, TInt& aSeparatorYPosition )
     {
     FUNC_LOG;
     TAknMultiLineTextLayout edwinLayout;
@@ -1073,18 +1104,15 @@
     TAknWindowComponentLayout headerDetailPane( AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0, 0, 0 ) );
     detailPane.LayoutRect( aParentRect, TAknWindowComponentLayout::MultiLineY( headerDetailPane, aCurrentLine, 0 ) );
     bodyRect = TRect( detailPane.Rect().iTl, bodyRect.Size() );
-    //<cmail>
     aSeparatorYPosition = bodyRect.iTl.iY;
     // Since layout doesn't specify enough space between separator line
     // and editor, we add some space manually
     TInt deltaMove = NcsUtility::SeparatorSizeInThisResolution().iHeight;
     bodyRect.Move( 0, deltaMove );
-    //</cmail>
     AknLayoutUtils::LayoutEdwin( aEdwin, bodyRect, TAknTextComponentLayout::Multiline( edwinLayoutLines ), EAknsCIQsnTextColorsCG6 );
     edwinLayoutLines.Reset();
     }
 
-//<cmail>
 // -----------------------------------------------------------------------------
 // NcsUtility::CalculateSeparatorLineSecondaryColor
 //
@@ -1150,7 +1178,6 @@
     return TRgb( redValue , greenValue, blueValue );
     }
 
-// </cmail> Platform layout changes
 // -----------------------------------------------------------------------------
 // NcsUtility::CalculateMsgBodyLineColor
 //
--- a/emailuis/uicomponents/bwins/fs_generic_alfu.def	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/bwins/fs_generic_alfu.def	Mon Jan 18 20:08:26 2010 +0200
@@ -293,17 +293,17 @@
 	?ThumbSpan@CFsAlfScrollbarLayout@@QAEHW4TFsScrollbar@@@Z @ 292 NONAME ; int CFsAlfScrollbarLayout::ThumbSpan(enum TFsScrollbar)
 	?TreeControl@CFsTreeList@@QBEPAVCAlfControl@@XZ @ 293 NONAME ; class CAlfControl * CFsTreeList::TreeControl(void) const
 	?TreeVisualizer@CFsTreeList@@QBEAAVCFsTreeVisualizerBase@@XZ @ 294 NONAME ; class CFsTreeVisualizerBase & CFsTreeList::TreeVisualizer(void) const
-	?TreeVisualizerEventL@CFsTreeList@@UBEXW4TFsTreeVisualizerEvent@MFsTreeVisualizerObserver@@H@Z @ 295 NONAME ; void CFsTreeList::TreeVisualizerEventL(enum MFsTreeVisualizerObserver::TFsTreeVisualizerEvent, int) const
-	?Update@CFsAlfScrollbarLayout@@QAEXH@Z @ 296 NONAME ; void CFsAlfScrollbarLayout::Update(int)
-	?UpdateButtonSize@CFsControlButtonVisualiser@@UAEXXZ @ 297 NONAME ; void CFsControlButtonVisualiser::UpdateButtonSize(void)
-	?UpdateElementL@CFsControlButtonVisualiser@@UAEXW4TFsControlButtonElem@@@Z @ 298 NONAME ; void CFsControlButtonVisualiser::UpdateElementL(enum TFsControlButtonElem)
-	?UpdateElementsSizeL@CFsControlButtonVisualiser@@MAEXW4TFsControlButtonType@@@Z @ 299 NONAME ; void CFsControlButtonVisualiser::UpdateElementsSizeL(enum TFsControlButtonType)
-	?UpdateStatusLayout@CFsTextViewer@@QAEXXZ @ 300 NONAME ; void CFsTextViewer::UpdateStatusLayout(void)
-	?UpdateTextStyles@CFsControlButtonVisualiser@@MAEXXZ @ 301 NONAME ; void CFsControlButtonVisualiser::UpdateTextStyles(void)
-	?VisibilityMode@CFsAlfScrollbarLayout@@QAE?AW4TFsScrollbarVisibility@@W4TFsScrollbar@@@Z @ 302 NONAME ; enum TFsScrollbarVisibility CFsAlfScrollbarLayout::VisibilityMode(enum TFsScrollbar)
-	?Visual@CFsControlBar@@QAEPAVCAlfVisual@@XZ @ 303 NONAME ; class CAlfVisual * CFsControlBar::Visual(void)
-	?Width@CFsControlBar@@QBEHXZ @ 304 NONAME ; int CFsControlBar::Width(void) const
-	?MakeSelectorVisibleL@CFsTreeVisualizerBase@@QAEXH@Z @ 305 NONAME ; void CFsTreeVisualizerBase::MakeSelectorVisibleL(int)
-	?DisableKineticScrolling@CFsTreeList@@QAEXH@Z @ 306 NONAME ; void CFsTreeList::DisableKineticScrolling(int)
-	?MakeSelectorVisible@CFsControlBar@@QAEXHH@Z @ 307 NONAME ; void CFsControlBar::MakeSelectorVisible(int, int)
+	?DisableKineticScrolling@CFsTreeList@@QAEXH@Z @ 295 NONAME ; void CFsTreeList::DisableKineticScrolling(int)
+	?MakeSelectorVisible@CFsControlBar@@QAEXHH@Z @ 296 NONAME ; void CFsControlBar::MakeSelectorVisible(int, int)
+	?MakeSelectorVisibleL@CFsTreeVisualizerBase@@QAEXH@Z @ 297 NONAME ; void CFsTreeVisualizerBase::MakeSelectorVisibleL(int)
+	?TreeVisualizerEventL@CFsTreeList@@UBEXW4TFsTreeVisualizerEvent@MFsTreeVisualizerObserver@@HABVTPoint@@@Z @ 298 NONAME ; void CFsTreeList::TreeVisualizerEventL(enum MFsTreeVisualizerObserver::TFsTreeVisualizerEvent, int, class TPoint const &) const
+	?Update@CFsAlfScrollbarLayout@@QAEXH@Z @ 299 NONAME ; void CFsAlfScrollbarLayout::Update(int)
+	?UpdateButtonSize@CFsControlButtonVisualiser@@UAEXXZ @ 300 NONAME ; void CFsControlButtonVisualiser::UpdateButtonSize(void)
+	?UpdateElementL@CFsControlButtonVisualiser@@UAEXW4TFsControlButtonElem@@@Z @ 301 NONAME ; void CFsControlButtonVisualiser::UpdateElementL(enum TFsControlButtonElem)
+	?UpdateElementsSizeL@CFsControlButtonVisualiser@@MAEXW4TFsControlButtonType@@@Z @ 302 NONAME ; void CFsControlButtonVisualiser::UpdateElementsSizeL(enum TFsControlButtonType)
+	?UpdateStatusLayout@CFsTextViewer@@QAEXXZ @ 303 NONAME ; void CFsTextViewer::UpdateStatusLayout(void)
+	?UpdateTextStyles@CFsControlButtonVisualiser@@MAEXXZ @ 304 NONAME ; void CFsControlButtonVisualiser::UpdateTextStyles(void)
+	?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
 
--- a/emailuis/uicomponents/eabi/fs_generic_alfU.def	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/eabi/fs_generic_alfU.def	Mon Jan 18 20:08:26 2010 +0200
@@ -306,114 +306,114 @@
 	_ZNK11CFsTreeList16TextStyleManagerEv @ 305 NONAME
 	_ZNK11CFsTreeList17SlideOutDirectionEv @ 306 NONAME
 	_ZNK11CFsTreeList19ScrollbarVisibilityEv @ 307 NONAME
-	_ZNK11CFsTreeList20TreeVisualizerEventLEN25MFsTreeVisualizerObserver22TFsTreeVisualizerEventEi @ 308 NONAME
-	_ZNK11CFsTreeList21TextMarqueeStartDelayEv @ 309 NONAME
-	_ZNK11CFsTreeList22TextMarqueeRepetitionsEv @ 310 NONAME
-	_ZNK11CFsTreeList26TextMarqueeCycleStartDelayEv @ 311 NONAME
-	_ZNK11CFsTreeList5ChildEij @ 312 NONAME
-	_ZNK11CFsTreeList5CountEv @ 313 NONAME
-	_ZNK11CFsTreeList5LevelEi @ 314 NONAME
-	_ZNK11CFsTreeList6IsNodeEi @ 315 NONAME
-	_ZNK11CFsTreeList6ParentEi @ 316 NONAME
-	_ZNK11CFsTreeList7IsEmptyEi @ 317 NONAME
-	_ZNK11CFsTreeList8ContainsEi @ 318 NONAME
-	_ZNK11CFsTreeList8IsMarkedEi @ 319 NONAME
-	_ZNK11CFsTreeList8ItemDataEi @ 320 NONAME
-	_ZNK11CFsTreeList8MarkTypeEv @ 321 NONAME
-	_ZNK11CFsTreeList9IsFocusedEv @ 322 NONAME
-	_ZNK13CFsControlBar16GetFocusedButtonEv @ 323 NONAME
-	_ZNK13CFsControlBar5WidthEv @ 324 NONAME
-	_ZNK13CFsControlBar6HeightEv @ 325 NONAME
-	_ZNK13CFsTextViewer10GetControlEv @ 326 NONAME
-	_ZNK13CFsTextViewer17BackgroundOpacityEv @ 327 NONAME
-	_ZNK13CFsTextViewer28GetVisibleFocusedHotspotLineERi @ 328 NONAME
-	_ZNK19CFsTreeRichItemData4TextEv @ 329 NONAME
-	_ZTI10CFsTexture @ 330 NONAME ; #<TI>#
-	_ZTI10CMyPicture @ 331 NONAME ; #<TI>#
-	_ZTI11CFsRichText @ 332 NONAME ; #<TI>#
-	_ZTI11CFsTreeList @ 333 NONAME ; #<TI>#
-	_ZTI12CSmileyField @ 334 NONAME ; #<TI>#
-	_ZTI12TKeyArrayPtr @ 335 NONAME ; #<TI>#
-	_ZTI13CFsActionMenu @ 336 NONAME ; #<TI>#
-	_ZTI13CFsTextParser @ 337 NONAME ; #<TI>#
-	_ZTI13CFsTextViewer @ 338 NONAME ; #<TI>#
-	_ZTI13CNewLineField @ 339 NONAME ; #<TI>#
-	_ZTI13CPictureField @ 340 NONAME ; #<TI>#
-	_ZTI14TFsMarqueeClet @ 341 NONAME ; #<TI>#
-	_ZTI15CFsRichTextText @ 342 NONAME ; #<TI>#
-	_ZTI15CFsSmileyParser @ 343 NONAME ; #<TI>#
-	_ZTI16CFsTextureLoader @ 344 NONAME ; #<TI>#
-	_ZTI17CFsBitmapProvider @ 345 NONAME ; #<TI>#
-	_ZTI17CFsRichTextSmiley @ 346 NONAME ; #<TI>#
-	_ZTI17CFsTextViewerKeys @ 347 NONAME ; #<TI>#
-	_ZTI18CFsRichTextNewLine @ 348 NONAME ; #<TI>#
-	_ZTI18CFsRichTextPicture @ 349 NONAME ; #<TI>#
-	_ZTI18TFsTextureObserver @ 350 NONAME ; #<TI>#
-	_ZTI19CFsSmileyDictionary @ 351 NONAME ; #<TI>#
-	_ZTI19CFsTextStyleManager @ 352 NONAME ; #<TI>#
-	_ZTI19CFsTextViewerSelect @ 353 NONAME ; #<TI>#
-	_ZTI20CFsActionMenuControl @ 354 NONAME ; #<TI>#
-	_ZTI20CFsTextViewerControl @ 355 NONAME ; #<TI>#
-	_ZTI21CFsAlfScrollbarLayout @ 356 NONAME ; #<TI>#
-	_ZTI21CFsTextViewerLayouter @ 357 NONAME ; #<TI>#
-	_ZTI21CFsTextViewerSkinData @ 358 NONAME ; #<TI>#
-	_ZTI22CFsAlfTextStyleManager @ 359 NONAME ; #<TI>#
-	_ZTI22CFsTextViewerWatermark @ 360 NONAME ; #<TI>#
-	_ZTI23CFsTextViewerSelectLine @ 361 NONAME ; #<TI>#
-	_ZTI23CFsTextViewerVisualizer @ 362 NONAME ; #<TI>#
-	_ZTI24CFsTextViewerCoordinator @ 363 NONAME ; #<TI>#
-	_ZTI24CFsTextViewerSelectEmbed @ 364 NONAME ; #<TI>#
-	_ZTI25CFsTextViewerMarkFacility @ 365 NONAME ; #<TI>#
-	_ZTI26CFsControlButtonVisualiser @ 366 NONAME ; #<TI>#
-	_ZTI26CFsTextViewerSelectHotspot @ 367 NONAME ; #<TI>#
-	_ZTI27CFsTextViewerSelectsManager @ 368 NONAME ; #<TI>#
-	_ZTI27CFsTextViewerVisualizerData @ 369 NONAME ; #<TI>#
-	_ZTI31CFsTextViewerVisualizerSettings @ 370 NONAME ; #<TI>#
-	_ZTV10CFsTexture @ 371 NONAME ; #<VT>#
-	_ZTV10CMyPicture @ 372 NONAME ; #<VT>#
-	_ZTV11CFsRichText @ 373 NONAME ; #<VT>#
-	_ZTV11CFsTreeList @ 374 NONAME ; #<VT>#
-	_ZTV12CSmileyField @ 375 NONAME ; #<VT>#
-	_ZTV12TKeyArrayPtr @ 376 NONAME ; #<VT>#
-	_ZTV13CFsActionMenu @ 377 NONAME ; #<VT>#
-	_ZTV13CFsTextParser @ 378 NONAME ; #<VT>#
-	_ZTV13CFsTextViewer @ 379 NONAME ; #<VT>#
-	_ZTV13CNewLineField @ 380 NONAME ; #<VT>#
-	_ZTV13CPictureField @ 381 NONAME ; #<VT>#
-	_ZTV14TFsMarqueeClet @ 382 NONAME ; #<VT>#
-	_ZTV15CFsRichTextText @ 383 NONAME ; #<VT>#
-	_ZTV15CFsSmileyParser @ 384 NONAME ; #<VT>#
-	_ZTV16CFsTextureLoader @ 385 NONAME ; #<VT>#
-	_ZTV17CFsBitmapProvider @ 386 NONAME ; #<VT>#
-	_ZTV17CFsRichTextSmiley @ 387 NONAME ; #<VT>#
-	_ZTV17CFsTextViewerKeys @ 388 NONAME ; #<VT>#
-	_ZTV18CFsRichTextNewLine @ 389 NONAME ; #<VT>#
-	_ZTV18CFsRichTextPicture @ 390 NONAME ; #<VT>#
-	_ZTV18TFsTextureObserver @ 391 NONAME ; #<VT>#
-	_ZTV19CFsSmileyDictionary @ 392 NONAME ; #<VT>#
-	_ZTV19CFsTextStyleManager @ 393 NONAME ; #<VT>#
-	_ZTV19CFsTextViewerSelect @ 394 NONAME ; #<VT>#
-	_ZTV20CFsActionMenuControl @ 395 NONAME ; #<VT>#
-	_ZTV20CFsTextViewerControl @ 396 NONAME ; #<VT>#
-	_ZTV21CFsAlfScrollbarLayout @ 397 NONAME ; #<VT>#
-	_ZTV21CFsTextViewerLayouter @ 398 NONAME ; #<VT>#
-	_ZTV21CFsTextViewerSkinData @ 399 NONAME ; #<VT>#
-	_ZTV22CFsAlfTextStyleManager @ 400 NONAME ; #<VT>#
-	_ZTV22CFsTextViewerWatermark @ 401 NONAME ; #<VT>#
-	_ZTV23CFsTextViewerSelectLine @ 402 NONAME ; #<VT>#
-	_ZTV23CFsTextViewerVisualizer @ 403 NONAME ; #<VT>#
-	_ZTV24CFsTextViewerCoordinator @ 404 NONAME ; #<VT>#
-	_ZTV24CFsTextViewerSelectEmbed @ 405 NONAME ; #<VT>#
-	_ZTV25CFsTextViewerMarkFacility @ 406 NONAME ; #<VT>#
-	_ZTV26CFsControlButtonVisualiser @ 407 NONAME ; #<VT>#
-	_ZTV26CFsTextViewerSelectHotspot @ 408 NONAME ; #<VT>#
-	_ZTV27CFsTextViewerSelectsManager @ 409 NONAME ; #<VT>#
-	_ZTV27CFsTextViewerVisualizerData @ 410 NONAME ; #<VT>#
-	_ZTV31CFsTextViewerVisualizerSettings @ 411 NONAME ; #<VT>#
-	_ZThn32_N14CFsTreeControl11OfferEventLERK9TAlfEvent @ 412 NONAME ; #<thunk>#
-	_ZThn4_N26CFsControlButtonVisualiser23TextureLoadingCompletedER11CAlfTextureii @ 413 NONAME ; #<thunk>#
-	_ZThn4_NK11CFsTreeList20TreeVisualizerEventLEN25MFsTreeVisualizerObserver22TFsTreeVisualizerEventEi @ 414 NONAME ; #<thunk>#
-	_ZN21CFsTreeVisualizerBase20MakeSelectorVisibleLEi @ 415 NONAME
-	_ZN11CFsTreeList23DisableKineticScrollingEi @ 416 NONAME
-	_ZN13CFsControlBar19MakeSelectorVisibleEii @ 417 NONAME
+	_ZN11CFsTreeList23DisableKineticScrollingEi @ 308 NONAME
+	_ZN13CFsControlBar19MakeSelectorVisibleEii @ 309 NONAME
+	_ZN21CFsTreeVisualizerBase20MakeSelectorVisibleLEi @ 310 NONAME
+	_ZNK11CFsTreeList20TreeVisualizerEventLEN25MFsTreeVisualizerObserver22TFsTreeVisualizerEventEiRK6TPoint @ 311 NONAME
+	_ZNK11CFsTreeList21TextMarqueeStartDelayEv @ 312 NONAME
+	_ZNK11CFsTreeList22TextMarqueeRepetitionsEv @ 313 NONAME
+	_ZNK11CFsTreeList26TextMarqueeCycleStartDelayEv @ 314 NONAME
+	_ZNK11CFsTreeList5ChildEij @ 315 NONAME
+	_ZNK11CFsTreeList5CountEv @ 316 NONAME
+	_ZNK11CFsTreeList5LevelEi @ 317 NONAME
+	_ZNK11CFsTreeList6IsNodeEi @ 318 NONAME
+	_ZNK11CFsTreeList6ParentEi @ 319 NONAME
+	_ZNK11CFsTreeList7IsEmptyEi @ 320 NONAME
+	_ZNK11CFsTreeList8ContainsEi @ 321 NONAME
+	_ZNK11CFsTreeList8IsMarkedEi @ 322 NONAME
+	_ZNK11CFsTreeList8ItemDataEi @ 323 NONAME
+	_ZNK11CFsTreeList8MarkTypeEv @ 324 NONAME
+	_ZNK11CFsTreeList9IsFocusedEv @ 325 NONAME
+	_ZNK13CFsControlBar16GetFocusedButtonEv @ 326 NONAME
+	_ZNK13CFsControlBar5WidthEv @ 327 NONAME
+	_ZNK13CFsControlBar6HeightEv @ 328 NONAME
+	_ZNK13CFsTextViewer10GetControlEv @ 329 NONAME
+	_ZNK13CFsTextViewer17BackgroundOpacityEv @ 330 NONAME
+	_ZNK13CFsTextViewer28GetVisibleFocusedHotspotLineERi @ 331 NONAME
+	_ZNK19CFsTreeRichItemData4TextEv @ 332 NONAME
+	_ZTI10CFsTexture @ 333 NONAME ; #<TI>#
+	_ZTI10CMyPicture @ 334 NONAME ; #<TI>#
+	_ZTI11CFsRichText @ 335 NONAME ; #<TI>#
+	_ZTI11CFsTreeList @ 336 NONAME ; #<TI>#
+	_ZTI12CSmileyField @ 337 NONAME ; #<TI>#
+	_ZTI12TKeyArrayPtr @ 338 NONAME ; #<TI>#
+	_ZTI13CFsActionMenu @ 339 NONAME ; #<TI>#
+	_ZTI13CFsTextParser @ 340 NONAME ; #<TI>#
+	_ZTI13CFsTextViewer @ 341 NONAME ; #<TI>#
+	_ZTI13CNewLineField @ 342 NONAME ; #<TI>#
+	_ZTI13CPictureField @ 343 NONAME ; #<TI>#
+	_ZTI14TFsMarqueeClet @ 344 NONAME ; #<TI>#
+	_ZTI15CFsRichTextText @ 345 NONAME ; #<TI>#
+	_ZTI15CFsSmileyParser @ 346 NONAME ; #<TI>#
+	_ZTI16CFsTextureLoader @ 347 NONAME ; #<TI>#
+	_ZTI17CFsBitmapProvider @ 348 NONAME ; #<TI>#
+	_ZTI17CFsRichTextSmiley @ 349 NONAME ; #<TI>#
+	_ZTI17CFsTextViewerKeys @ 350 NONAME ; #<TI>#
+	_ZTI18CFsRichTextNewLine @ 351 NONAME ; #<TI>#
+	_ZTI18CFsRichTextPicture @ 352 NONAME ; #<TI>#
+	_ZTI18TFsTextureObserver @ 353 NONAME ; #<TI>#
+	_ZTI19CFsSmileyDictionary @ 354 NONAME ; #<TI>#
+	_ZTI19CFsTextStyleManager @ 355 NONAME ; #<TI>#
+	_ZTI19CFsTextViewerSelect @ 356 NONAME ; #<TI>#
+	_ZTI20CFsActionMenuControl @ 357 NONAME ; #<TI>#
+	_ZTI20CFsTextViewerControl @ 358 NONAME ; #<TI>#
+	_ZTI21CFsAlfScrollbarLayout @ 359 NONAME ; #<TI>#
+	_ZTI21CFsTextViewerLayouter @ 360 NONAME ; #<TI>#
+	_ZTI21CFsTextViewerSkinData @ 361 NONAME ; #<TI>#
+	_ZTI22CFsAlfTextStyleManager @ 362 NONAME ; #<TI>#
+	_ZTI22CFsTextViewerWatermark @ 363 NONAME ; #<TI>#
+	_ZTI23CFsTextViewerSelectLine @ 364 NONAME ; #<TI>#
+	_ZTI23CFsTextViewerVisualizer @ 365 NONAME ; #<TI>#
+	_ZTI24CFsTextViewerCoordinator @ 366 NONAME ; #<TI>#
+	_ZTI24CFsTextViewerSelectEmbed @ 367 NONAME ; #<TI>#
+	_ZTI25CFsTextViewerMarkFacility @ 368 NONAME ; #<TI>#
+	_ZTI26CFsControlButtonVisualiser @ 369 NONAME ; #<TI>#
+	_ZTI26CFsTextViewerSelectHotspot @ 370 NONAME ; #<TI>#
+	_ZTI27CFsTextViewerSelectsManager @ 371 NONAME ; #<TI>#
+	_ZTI27CFsTextViewerVisualizerData @ 372 NONAME ; #<TI>#
+	_ZTI31CFsTextViewerVisualizerSettings @ 373 NONAME ; #<TI>#
+	_ZTV10CFsTexture @ 374 NONAME ; #<VT>#
+	_ZTV10CMyPicture @ 375 NONAME ; #<VT>#
+	_ZTV11CFsRichText @ 376 NONAME ; #<VT>#
+	_ZTV11CFsTreeList @ 377 NONAME ; #<VT>#
+	_ZTV12CSmileyField @ 378 NONAME ; #<VT>#
+	_ZTV12TKeyArrayPtr @ 379 NONAME ; #<VT>#
+	_ZTV13CFsActionMenu @ 380 NONAME ; #<VT>#
+	_ZTV13CFsTextParser @ 381 NONAME ; #<VT>#
+	_ZTV13CFsTextViewer @ 382 NONAME ; #<VT>#
+	_ZTV13CNewLineField @ 383 NONAME ; #<VT>#
+	_ZTV13CPictureField @ 384 NONAME ; #<VT>#
+	_ZTV14TFsMarqueeClet @ 385 NONAME ; #<VT>#
+	_ZTV15CFsRichTextText @ 386 NONAME ; #<VT>#
+	_ZTV15CFsSmileyParser @ 387 NONAME ; #<VT>#
+	_ZTV16CFsTextureLoader @ 388 NONAME ; #<VT>#
+	_ZTV17CFsBitmapProvider @ 389 NONAME ; #<VT>#
+	_ZTV17CFsRichTextSmiley @ 390 NONAME ; #<VT>#
+	_ZTV17CFsTextViewerKeys @ 391 NONAME ; #<VT>#
+	_ZTV18CFsRichTextNewLine @ 392 NONAME ; #<VT>#
+	_ZTV18CFsRichTextPicture @ 393 NONAME ; #<VT>#
+	_ZTV18TFsTextureObserver @ 394 NONAME ; #<VT>#
+	_ZTV19CFsSmileyDictionary @ 395 NONAME ; #<VT>#
+	_ZTV19CFsTextStyleManager @ 396 NONAME ; #<VT>#
+	_ZTV19CFsTextViewerSelect @ 397 NONAME ; #<VT>#
+	_ZTV20CFsActionMenuControl @ 398 NONAME ; #<VT>#
+	_ZTV20CFsTextViewerControl @ 399 NONAME ; #<VT>#
+	_ZTV21CFsAlfScrollbarLayout @ 400 NONAME ; #<VT>#
+	_ZTV21CFsTextViewerLayouter @ 401 NONAME ; #<VT>#
+	_ZTV21CFsTextViewerSkinData @ 402 NONAME ; #<VT>#
+	_ZTV22CFsAlfTextStyleManager @ 403 NONAME ; #<VT>#
+	_ZTV22CFsTextViewerWatermark @ 404 NONAME ; #<VT>#
+	_ZTV23CFsTextViewerSelectLine @ 405 NONAME ; #<VT>#
+	_ZTV23CFsTextViewerVisualizer @ 406 NONAME ; #<VT>#
+	_ZTV24CFsTextViewerCoordinator @ 407 NONAME ; #<VT>#
+	_ZTV24CFsTextViewerSelectEmbed @ 408 NONAME ; #<VT>#
+	_ZTV25CFsTextViewerMarkFacility @ 409 NONAME ; #<VT>#
+	_ZTV26CFsControlButtonVisualiser @ 410 NONAME ; #<VT>#
+	_ZTV26CFsTextViewerSelectHotspot @ 411 NONAME ; #<VT>#
+	_ZTV27CFsTextViewerSelectsManager @ 412 NONAME ; #<VT>#
+	_ZTV27CFsTextViewerVisualizerData @ 413 NONAME ; #<VT>#
+	_ZTV31CFsTextViewerVisualizerSettings @ 414 NONAME ; #<VT>#
+	_ZThn32_N14CFsTreeControl11OfferEventLERK9TAlfEvent @ 415 NONAME ; #<thunk>#
+	_ZThn4_N26CFsControlButtonVisualiser23TextureLoadingCompletedER11CAlfTextureii @ 416 NONAME ; #<thunk>#
+	_ZThn4_NK11CFsTreeList20TreeVisualizerEventLEN25MFsTreeVisualizerObserver22TFsTreeVisualizerEventEiRK6TPoint @ 417 NONAME ; #<thunk>#
 
--- a/emailuis/uicomponents/inc/fsactionmenu.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/inc/fsactionmenu.h	Mon Jan 18 20:08:26 2010 +0200
@@ -131,7 +131,9 @@
      * through this function.
      */
     // <cmail> Touch
-    virtual void TreeListEventL( const TFsTreeListEvent aEvent, const TFsTreeItemId aId = KFsTreeNoneID );
+    virtual void TreeListEventL( const TFsTreeListEvent aEvent, 
+                                 const TFsTreeItemId aId,
+                                 const TPoint& aPoint );
     // </cmail>
     
 public: //used by Action Menu's control
--- a/emailuis/uicomponents/inc/fscontrolbar.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/inc/fscontrolbar.h	Mon Jan 18 20:08:26 2010 +0200
@@ -140,7 +140,7 @@
      * Set position and size
      */
     virtual void SetRectL( const TRect& aRect );
-    
+
     /**
      * Sets height of the bar in pixels.
      *
@@ -333,7 +333,8 @@
      * @param aButton pointer to button which schould be focused.
      * If NULL focus is lost by the control bar.
      */
-    void ChangeFocusL( CFsControlButton* aButton );
+    void ChangeFocusL(
+            CFsControlButton* aButton, TBool aMakeSelectorVisible = EFalse );
 
     /**
      * Sets needed variables when bar loses focus.
--- a/emailuis/uicomponents/inc/fscontrolbarmodel.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/inc/fscontrolbarmodel.h	Mon Jan 18 20:08:26 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -121,7 +121,7 @@
      * @param aButtonId Current button's id.
      * @return Next button after current.
      */
-    CFsControlButton* NextButton( TInt aButtonId );
+    CFsControlButton* NextButton( TInt aButtonId, TBool aLandscape = EFalse );
 
     /**
      * Retrieves button previous to the button with specified id.
@@ -129,7 +129,7 @@
      * @param aButtonId Current button's id.
      * @return Previous button after current.
      */
-    CFsControlButton* PrevButton( TInt aButtonId );
+    CFsControlButton* PrevButton( TInt aButtonId, TBool aLandscape = EFalse );
 
     /**
      * Sets focus state for control bar.
@@ -196,7 +196,7 @@
      * Set bar's rect
      */
     void SetRect( const TRect& aRect );
-    
+
     /**
      * Get size of the controlbar.
      *
@@ -208,7 +208,7 @@
      * Get top-left position
      */
     TPoint Pos() const;
-    
+
 private:
 
     /**
@@ -260,7 +260,7 @@
     TBool iHeightUseDefault;
 
     /**
-     * Top-left position 
+     * Top-left position
      */
     TPoint iTl;
     };
--- a/emailuis/uicomponents/inc/fstreelist.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/inc/fstreelist.h	Mon Jan 18 20:08:26 2010 +0200
@@ -768,11 +768,10 @@
      /**
       *
       */
-     // <cmail> Touch
      IMPORT_C virtual void TreeVisualizerEventL(
              const TFsTreeVisualizerEvent aEvent,
-             const TFsTreeItemId aId = KFsTreeNoneID ) const;
-     // </cmail>
+             const TFsTreeItemId aId,
+             const TPoint& aPoint ) const;
 
     /**
      * Gets the reference to the text style manager.
--- a/emailuis/uicomponents/inc/fstreelistobserver.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/inc/fstreelistobserver.h	Mon Jan 18 20:08:26 2010 +0200
@@ -262,10 +262,12 @@
      * @param aEvent Event which happend in the tree list.
      * @param aId Id of the node/item associated with the event. KFsTreeNoneID
      *            means that the event is not associated with a node/item.
+     * @param aPoint Event coordinates. Valid only for touch events.
      */
     // <cmail> Touch
     virtual void TreeListEventL( const TFsTreeListEvent aEvent, 
-                                const TFsTreeItemId aId = KFsTreeNoneID ) = 0;
+                                 const TFsTreeItemId aId,
+                                 const TPoint& aPoint ) = 0;
     // </cmail>
     
     };
--- a/emailuis/uicomponents/inc/fstreevisualizerbase.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/inc/fstreevisualizerbase.h	Mon Jan 18 20:08:26 2010 +0200
@@ -1928,14 +1928,14 @@
      * Sets focused item and send event of touch focusing.
      */
     void SetFocusedItemAndSendEventL( const TFsTreeItemId aItem,
-        TPointerEventType aEventType );
+        TPointerEventType aEventType, const TPoint& aPoint );
 
     /**
      * Just a wrapper for SetFocusedItemAndSendEventL which returns the
      * error code instead of leaving.
      */
     TInt SetFocusedItemAndSendEvent( const TFsTreeItemId aItem,
-        TPointerEventType aEventType );
+        TPointerEventType aEventType, const TPoint& aPoint );
 
 private: // from MAknPhysicsObserver
 
--- a/emailuis/uicomponents/inc/fstreevisualizerobserver.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/inc/fstreevisualizerobserver.h	Mon Jan 18 20:08:26 2010 +0200
@@ -131,11 +131,13 @@
      * @param aEvent Event which happend in the tree list.
      * @param aId Id of the node/item associated with the event. KFsTreeNoneID
      *            means that the event is not associated with a node/item.
+     * @param aPoint Event coordinates. Only valid for touch events.
      */
     // <cmail> Touch
     virtual void TreeVisualizerEventL( 
             const TFsTreeVisualizerEvent aEvent, 
-            const TFsTreeItemId aId = KFsTreeNoneID ) const = 0;
+            const TFsTreeItemId aId = KFsTreeNoneID,
+            const TPoint& aPoint = TPoint( 0,0 ) ) const = 0;
     // </cmail>
     
     };
--- a/emailuis/uicomponents/src/fsactionmenu.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/src/fsactionmenu.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -226,7 +226,9 @@
 // ---------------------------------------------------------------------------
 //
 // <cmail> Touch
-void CFsActionMenu::TreeListEventL( const TFsTreeListEvent aEvent, const TFsTreeItemId /*aId*/ )
+void CFsActionMenu::TreeListEventL( const TFsTreeListEvent aEvent, 
+                                    const TFsTreeItemId /*aId*/,
+                                    const TPoint& /*aPoint*/ )
     {
     FUNC_LOG;
 // </cmail>
--- a/emailuis/uicomponents/src/fscontrolbar.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/src/fscontrolbar.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -15,16 +15,17 @@
 *
 */
 
+// CLASS HEADER
+#include "fscontrolbar.h"
 
-//<cmail> SF
+// INCLUDES
 #include "emailtrace.h"
 #include <alf/alfevent.h>
 #include <alf/alfdecklayout.h>
-//</cmail>
 #include <AknsConstants.h>
 #include <AknUtils.h>
+#include <layoutmetadata.cdl.h>
 
-#include "fscontrolbar.h"
 #include "fscontrolbarmodel.h"
 #include "fscontrolbarvisualiser.h"
 #include "fscontrolbutton.h"
@@ -607,48 +608,68 @@
 
     if ( aEvent.IsKeyEvent() )
         {
-        CFsControlButton* button( NULL );
-
-        button = iModel->ButtonById( iSelectedButton );
-
+        CFsControlButton* button = iModel->ButtonById( iSelectedButton );
         if ( button && button->OfferEventL( aEvent ) )
             {
             eventHandled = ETrue;
             }
         else
             {
-            if ( EEventKey == aEvent.Code() )
+            if( EEventKey == aEvent.Code() )
                 {
-                switch ( aEvent.KeyEvent().iScanCode )
+                TBool landscape( Layout_Meta_Data::IsLandscapeOrientation() );
+                switch( aEvent.KeyEvent().iScanCode )
                     {
                     case EStdKeyLeftArrow:
                         {
-                        button = iModel->PrevButton( iSelectedButton );
-                        ChangeFocusL( button );
-                        // Always after keypress focus needs to be shown.
-                        MakeSelectorVisible( ETrue );
+                        if( landscape )
+                            {
+                            LooseFocus( MFsControlBarObserver::EEventFocusLostAtBottom );
+                            }
+                        else
+                            {
+                            button = iModel->PrevButton( iSelectedButton );
+                            ChangeFocusL( button, ETrue );
+                            }
                         eventHandled = ETrue;
                         break;
                         }
 
                     case EStdKeyRightArrow:
                         {
-                        button = iModel->NextButton( iSelectedButton );
-                        ChangeFocusL( button );
-                        // Always after keypress focus needs to be shown.
-                        MakeSelectorVisible( ETrue );
-                        eventHandled = ETrue;
+                        if( !landscape )
+                            {
+                            button = iModel->NextButton( iSelectedButton );
+                            ChangeFocusL( button, ETrue );
+                            eventHandled = ETrue;
+                            }
                         break;
                         }
 
                     case EStdKeyDownArrow:
                         {
-                        LooseFocus(
-                                MFsControlBarObserver::EEventFocusLostAtBottom );
+                        if( landscape )
+                            {
+                            button = iModel->NextButton( iSelectedButton, landscape );
+                            ChangeFocusL( button, ETrue );
+                            }
+                        else
+                            {
+                            LooseFocus( MFsControlBarObserver::EEventFocusLostAtBottom );
+                            }
                         eventHandled = ETrue;
                         break;
                         }
-
+                    case EStdKeyUpArrow:
+                        {
+                        if( landscape )
+                            {
+                            button = iModel->PrevButton( iSelectedButton, landscape );
+                            ChangeFocusL( button, ETrue );
+                            eventHandled = ETrue;
+                            }
+                        break;
+                        }
                     default:
                         {
                         eventHandled = EFalse;
@@ -687,7 +708,6 @@
     TBool eventHandled( ETrue );
     switch ( aEvent )
         {
-        // <cmail> Touch
         case EEventButtonTouchPressed:
             {
             MakeSelectorVisible( ETrue, ETrue );
@@ -708,7 +728,6 @@
                 }
             break;
             }
-        // </cmail>
 
         case EEventButtonPressed:
             {
@@ -723,7 +742,6 @@
             break;
             }
 
-        // <cmail> Touch
         case EEventButtonTouchReleased:
             {
             // Notify that button is released, focus can be hidden.
@@ -748,7 +766,6 @@
                 }
             break;
             }
-        // </cmail>
 
         case EEventButtonReleased:
             {
@@ -832,13 +849,18 @@
 // Changes focus to another button or looses focus from control bar.
 // ---------------------------------------------------------------------------
 //
-void CFsControlBar::ChangeFocusL( CFsControlButton* aButton )
+void CFsControlBar::ChangeFocusL(
+        CFsControlButton* aButton, TBool aMakeSelectorVisible )
     {
     FUNC_LOG;
     if ( aButton )
         {
         // set focus to specified button
         SetFocusByIdL( aButton->Id() );
+        if( aMakeSelectorVisible )
+            {
+            MakeSelectorVisible( ETrue );
+            }
         }
     else
         {
--- a/emailuis/uicomponents/src/fscontrolbarmodel.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/src/fscontrolbarmodel.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -276,10 +276,11 @@
 // Retrieves next focusable button.
 // ---------------------------------------------------------------------------
 //
-CFsControlButton* CFsControlBarModel::NextButton( TInt aButtonId )
+CFsControlButton* CFsControlBarModel::NextButton(
+        TInt aButtonId, TBool aLandscape )
     {
     FUNC_LOG;
-    TInt index( -1 );
+    TInt index( KErrNotFound );
     CFsControlButton* currentBtn( ButtonById( aButtonId ) );
 
     // Find current button's id.
@@ -294,7 +295,13 @@
         }
 
     // Find the next button on right.
-    TInt curPos( currentBtn->Visualiser()->Pos().Target().iX );
+    TAlfRealPoint curPosTarget( currentBtn->Visualiser()->Pos().Target() );
+    TInt curPos( curPosTarget.iX );
+    if( aLandscape )
+        {
+        curPos = curPosTarget.iY;
+        }
+
     TBool candidate( EFalse );
     TInt next( 0 );
     for ( TInt i( 0 ); iButtons.Count() > i; i++ )
@@ -305,7 +312,12 @@
             {
             continue;
             }
-        TInt btnPos( iButtons[i]->Visualiser()->Pos().Target().iX );
+        TAlfRealPoint btnPosTarget( iButtons[i]->Visualiser()->Pos().Target() );
+        TInt btnPos( btnPosTarget.iX );
+        if( aLandscape )
+            {
+            btnPos = btnPosTarget.iY;
+            }
         if ( btnPos >= curPos )
             {
             if ( btnPos == curPos )
@@ -342,10 +354,11 @@
 // Retrieves previous focusable button.
 // ---------------------------------------------------------------------------
 //
-CFsControlButton* CFsControlBarModel::PrevButton( TInt aButtonId )
+CFsControlButton* CFsControlBarModel::PrevButton(
+        TInt aButtonId, TBool aLandscape )
     {
     FUNC_LOG;
-    TInt index( -1 );
+    TInt index( KErrNotFound );
     CFsControlButton* currentBtn( ButtonById( aButtonId ) );
 
     // Find current button's id.
@@ -359,19 +372,30 @@
         buttonId++;
         }
 
-    // Find the next button on left.
-    TInt curPos( currentBtn->Visualiser()->Pos().Target().iX );
+    // Find the next button on left or up.
+    TAlfRealPoint curPosTaget( currentBtn->Visualiser()->Pos().Target() );
+
+    TInt curPos( curPosTaget.iX );
+    if( aLandscape )
+        {
+        curPos = curPosTaget.iY;
+        }
     TBool candidate( EFalse );
     TInt next( 0 );
     for ( TInt i( iButtons.Count() - 1 ); 0 <= i; i-- )
         {
-        if ( i == buttonId
-            || !iButtons[i]->IsVisible()
-            || iButtons[i]->IsDimmed() )
+        if ( ( i == buttonId ) ||
+             ( !iButtons[i]->IsVisible() ) ||
+             ( iButtons[i]->IsDimmed() ) )
             {
             continue;
             }
-        TInt btnPos( iButtons[i]->Visualiser()->Pos().Target().iX );
+        TAlfRealPoint btnPosTarget( iButtons[i]->Visualiser()->Pos().Target() );
+        TInt btnPos( btnPosTarget.iX );
+        if( aLandscape )
+            {
+            btnPos = btnPosTarget.iY;
+            }
         if ( btnPos <= curPos )
             {
             if ( btnPos == curPos )
--- a/emailuis/uicomponents/src/fstreelist.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/src/fstreelist.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -933,7 +933,8 @@
 // <cmail> Touch
 EXPORT_C void CFsTreeList::TreeVisualizerEventL(
         const TFsTreeVisualizerEvent aEvent,
-        const TFsTreeItemId aId ) const
+        const TFsTreeItemId aId,
+        const TPoint& aPoint ) const
 // </cmail>
     {
     FUNC_LOG;
@@ -1032,11 +1033,7 @@
 
     for ( TInt c = 0; c < iObservers.Count(); c++ )
         {
-        // <cmail> Touch
-        iObservers[c]->TreeListEventL(
-            listEvent,
-            aId);
-        // </cmail>
+        iObservers[c]->TreeListEventL( listEvent, aId, aPoint );
         }
     }
 
--- a/emailuis/uicomponents/src/fstreevisualizerbase.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/uicomponents/src/fstreevisualizerbase.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -12,7 +12,7 @@
  * Contributors:
  *
  *  Description : Freestyle tree list visualizer implementation
- *  
+ *
  *
  */
 
@@ -682,7 +682,7 @@
         {
         TInt top(itemRect.iTl.iY);
         top -= aPosition.iY;
-        LimitTop(top);            
+        LimitTop(top);
         if (aHint == EPositionAfterExpand)
             {
             const TInt error( iWorld.GetItemRectByIndex(
@@ -692,7 +692,7 @@
                 if (itemRect.iBr.iY - top > iSize.iHeight)
                     {
                     top += itemRect.iBr.iY - top - iSize.iHeight;
-                    LimitTop(top);            
+                    LimitTop(top);
                     }
                 }
             }
@@ -1410,11 +1410,9 @@
                     {
                     if (iVisualizerObserver)
                         {
-                        // <cmail> Touch
                         iVisualizerObserver->TreeVisualizerEventL(
                                 MFsTreeVisualizerObserver::EFsTreeKeyLeftArrow,
                                 iFocusedItem);
-                        // </cmail>
                         }
                     eventHandled = ETrue;
                     break;
@@ -1423,11 +1421,9 @@
                     {
                     if (iVisualizerObserver)
                         {
-                        // <cmail>
                         iVisualizerObserver->TreeVisualizerEventL(
                                 MFsTreeVisualizerObserver::EFsTreeKeyRightArrow,
                                 iFocusedItem);
-                        // </cmail>
                         }
                     eventHandled = ETrue;
                     break;
@@ -1451,7 +1447,6 @@
                             {
                             if (iTreeData->ItemVisualizer(iFocusedItem)->Menu())
                                 {
-                                // <cmail> Touch
                                 iVisualizerObserver->TreeVisualizerEventL(
                                         MFsTreeVisualizerObserver::EFsTreeItemWithMenuSelected,
                                         iFocusedItem);
@@ -1461,7 +1456,6 @@
                                 iVisualizerObserver->TreeVisualizerEventL(
                                         MFsTreeVisualizerObserver::EFsTreeItemSelected,
                                         iFocusedItem);
-                                // </cmail>
                                 }
                             }
                         }
@@ -1532,11 +1526,8 @@
         }
     }
 
-// <cmail> "Base class modifications for using touch"
-
 // ---------------------------------------------------------------------------
 // CFsTreeVisualizerBase::HandlePointerEventL
-//
 // ---------------------------------------------------------------------------
 //
 TBool CFsTreeVisualizerBase::HandlePointerEventL(const TAlfEvent& aEvent)
@@ -1547,8 +1538,8 @@
         TPointerEvent::TType type = aEvent.PointerEvent().iType;
         const TInt id(EventItemId(aEvent));
         INFO_1("visual: $%x", aEvent.Visual());
-        if (KErrNotFound != id || type == TPointerEvent::EDrag || 
-                type  == TPointerEvent::EButtonRepeat || 
+        if (KErrNotFound != id || type == TPointerEvent::EDrag ||
+                type  == TPointerEvent::EButtonRepeat ||
                 type  == TPointerEvent::EButton1Up)
             {
             switch (type)
@@ -1704,7 +1695,7 @@
 
     if ( visualizer )
         {
-        TBool focused = IsFocusShown();    
+        TBool focused = IsFocusShown();
         visualizer->UpdateL( iTreeData->ItemData( iFocusedItem ), focused,
                 iTreeData->Level( iFocusedItem ), iMarkIcon, iMenuIcon, 0 );
         }
@@ -1817,7 +1808,7 @@
                     itemId);
 
             TBool itemFocused( EFalse );
-            if( showFocus ) 
+            if( showFocus )
                 {
                 itemFocused = IsItemFocused(itemId);
                 }
@@ -2254,7 +2245,7 @@
     if (!nodeVisualizer->IsExpanded())
         {
         nodeVisualizer->SetExpanded(ETrue, &iTreeData->ItemData(aNodeId));
-        
+
         TFsTreeIterator treeIter = iTreeData->Iterator(aNodeId, aNodeId,
                 KFsTreeIteratorSkipHiddenFlag);
         if (treeIter.HasNext())
@@ -2276,7 +2267,7 @@
                 ApplyListSpecificValuesToItem(itemviz);
                 size = itemviz->Size();
                 iWorld.InsertL(itemId, size, index);
-                } while (treeIter.HasNext()); 
+                } while (treeIter.HasNext());
             if (iFocusedItem != KFsTreeNoneID)
                 {
                 iViewPort.ItemToPositionL(iFocusedItem, position, EFalse,
@@ -2342,49 +2333,50 @@
     FUNC_LOG;
     iWorld.BeginUpdate();
     TPoint position;
-    if (iFocusedItem != KFsTreeNoneID)
+
+    if( iFocusedItem != KFsTreeNoneID )
         {
         position = iViewPort.ItemRect(iFocusedItem).iTl;
         }
     iWorld.RemoveAllL();
-    TFsTreeIterator treeIter = iTreeData->Iterator(KFsTreeRootID,
-            KFsTreeRootID);
+    TFsTreeIterator treeIter = iTreeData->Iterator(
+        KFsTreeRootID, KFsTreeRootID );
     TFsTreeItemId itemId = KFsTreeNoneID;
     TSize size;
-    while (treeIter.HasNext())
+    while( treeIter.HasNext() )
         {
         itemId = treeIter.Next();
-        if (itemId != KFsTreeNoneID)
+        if( itemId != KFsTreeNoneID )
             {
-            if (iTreeData->IsNode(itemId))
+            if( iTreeData->IsNode( itemId ) )
                 {
                 MFsTreeNodeVisualizer* nodeviz = iTreeData->NodeVisualizer(
                         itemId);
-                nodeviz->SetExpanded(ETrue, &iTreeData->ItemData(itemId));
+                nodeviz->SetExpanded( ETrue, &iTreeData->ItemData( itemId ) );
                 size = nodeviz->Size();
                 }
             else
                 {
-                MFsTreeItemVisualizer* itemviz = iTreeData->ItemVisualizer(
-                        itemId);
+                MFsTreeItemVisualizer* itemviz =
+                    iTreeData->ItemVisualizer( itemId );
                 size = itemviz->Size();
                 }
-            iWorld.AppendL(itemId, size);
+            iWorld.AppendL( itemId, size );
             }
         }
-    if (iFocusedItem != KFsTreeNoneID)
+
+    if( iFocusedItem != KFsTreeNoneID )
         {
         iViewPort.ItemToPositionL(iFocusedItem, position, EFalse,
-                TViewPort::EPositionAfterExpand);
+                TViewPort::EPositionAfterExpand );
         }
     iWorld.EndUpdateL();
-    // <cmail>
+
     if ( iVisualizerObserver )
         {
         iVisualizerObserver->TreeVisualizerEventL(
                 MFsTreeVisualizerObserver::EFsTreeListExpandedAll );
         }
-    // </cmail>
     }
 
 // ---------------------------------------------------------------------------
@@ -2396,44 +2388,58 @@
     FUNC_LOG;
     iWorld.BeginUpdate();
     TPoint position;
-    if (iFocusedItem != KFsTreeNoneID)
-        {
-        position = iViewPort.ItemRect(iFocusedItem).iTl;
+
+    if( iFocusedItem != KFsTreeNoneID )
+        {
+        position = iViewPort.ItemRect( iFocusedItem ).iTl;
         }
     iWorld.RemoveAllL();
-    if (iTreeData->Count() > 0)
-        {
-        TUint childcount = iTreeData->CountChildren(KFsTreeRootID);
-        for (TUint i = 0; i < childcount; ++i)
+    if( iTreeData->Count() > 0 )
+        {
+        const TUint childcount = iTreeData->CountChildren( KFsTreeRootID );
+        for( TUint i( 0 ); i < childcount; ++i )
             {
-            TFsTreeItemId itemId = iTreeData->Child(KFsTreeRootID, i);
+            TFsTreeItemId itemId = iTreeData->Child( KFsTreeRootID, i );
             TSize itemSize;
-            if (iTreeData->IsNode(itemId))
+            if( iTreeData->IsNode( itemId ) )
                 {
-                MFsTreeNodeVisualizer* nodeVis(iTreeData->NodeVisualizer(
-                        itemId));
-                nodeVis->SetExpanded(EFalse, &iTreeData->ItemData(itemId));
+                MFsTreeNodeVisualizer* nodeVis =
+                    iTreeData->NodeVisualizer( itemId );
+                nodeVis->SetExpanded( EFalse, &iTreeData->ItemData( itemId ) );
                 itemSize = nodeVis->Size();
                 }
             else
                 {
-                itemSize = iTreeData->ItemVisualizer(itemId)->Size();
+                itemSize = iTreeData->ItemVisualizer( itemId )->Size();
                 }
             iWorld.AppendL(itemId, itemSize);
             }
         }
-    if (iFocusedItem != KFsTreeNoneID)
-        {
-        iViewPort.ItemToPositionL(iFocusedItem, position, EFalse);
-        }
+
+    if( iFocusedItem != KFsTreeNoneID )
+        {
+        // If item, which was selected, wasn't node, then make its parent node
+        // focused, if it doesn't have parent node or its parent is not a node
+        // then leave focus as it was.
+        if( !iTreeData->IsNode( iFocusedItem ) )
+            {
+            TFsTreeItemId parentId = iTreeData->Parent( iFocusedItem );
+            if( iTreeData->IsNode( parentId ) )
+                {
+                SetFocusedItemL( parentId );
+                position = iViewPort.ItemRect( iFocusedItem ).iTl;
+                }
+            }
+        iViewPort.ItemToPositionL( iFocusedItem, position, EFalse );
+        }
+
     iWorld.EndUpdateL();
-    // <cmail>
+
     if ( iVisualizerObserver )
         {
         iVisualizerObserver->TreeVisualizerEventL(
                 MFsTreeVisualizerObserver::EFsTreeListCollapsedAll );
         }
-    // </cmail>
     }
 
 // ---------------------------------------------------------------------------
@@ -2571,7 +2577,7 @@
     backgroundBrush->SetColor(aColor);
 
     iWatermarkLayout->Brushes()->AppendL(backgroundBrush, EAlfHasOwnership);
-        }    
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -3598,7 +3604,7 @@
         keepFocusedItemInView = iViewPort.ItemRect(iFocusedItem).Height() > 0;
         }
     iViewPort.SetSizeL(listPane.Size());
-    iWorld.Recalculate(*iTreeData);   
+    iWorld.Recalculate(*iTreeData);
     if (keepFocusedItemInView)
         {
         iViewPort.ScrollItemToViewL(iFocusedItem, EFalse);
@@ -3633,7 +3639,7 @@
 void CFsTreeVisualizerBase::UpdateScrollBarL(const TInt /*aTimeout*/)
     {
     FUNC_LOG;
-    
+
     TRect mainPaneRect;
     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
     TRect listRect(iRootLayout->DisplayRectTarget());
@@ -4044,7 +4050,7 @@
 
             iListLayout->SetFlag( EAlfVisualFlagFreezeLayout );
             iListItemBackgroundLayout->SetFlag( EAlfVisualFlagFreezeLayout );
-            
+
             iSelectorVisual = CAlfImageVisual::AddNewL(*iOwnerControl, iSelectorLayout);
             opacity.SetValueNow(0.0f);
             iSelectorVisual->SetOpacity(opacity);
@@ -4052,9 +4058,9 @@
             iSelectorVisual->EnableBrushesL();
 
             // Set the selector visual size and pos.
-            iSelectorVisual->SetFlags(EAlfVisualFlagManualLayout | 
-                    EAlfVisualFlagIgnorePointer);           
-            
+            iSelectorVisual->SetFlags(EAlfVisualFlagManualLayout |
+                    EAlfVisualFlagIgnorePointer);
+
             TRect itemRect(iViewPort.ItemRect(iFocusedItem));
             itemRect.SetWidth(iListLayout->Size().iX.Target() - 2 * iListLayout->PaddingInPixels().iTl.iX);
             if ( itemRect.Height() )
@@ -4879,7 +4885,7 @@
             CAlfLayout& visualizerLayout(visualizer->Layout());
             visualizerLayout.SetSize(tpItemSize);
             visualizerLayout.PropertySetIntegerL(KPropertyItemId(), itemId);
-            visualizer->UpdateL(iTreeData->ItemData(itemId), 
+            visualizer->UpdateL(iTreeData->ItemData(itemId),
                     IsItemFocused(itemId) && IsFocusShown(),
                     iTreeData->Level(itemId), iMarkIcon, iMenuIcon,
                     0);
@@ -4936,7 +4942,7 @@
     TTime now;
     now.HomeTime();
     TInt moveTime( now.MicroSecondsFrom( aStartTime ).Int64() );
-    if (moveTime > KFlickMaxDuration) 
+    if (moveTime > KFlickMaxDuration)
         {
         startTime = now - TTimeIntervalMicroSeconds( KFlickMaxDuration - 1 );
         aDrag.iY = aDrag.iY * KFlickMaxDuration / moveTime;
@@ -5007,10 +5013,10 @@
 // ---------------------------------------------------------------------------
 //
 TInt CFsTreeVisualizerBase::SetFocusedItemAndSendEvent(
-    const TFsTreeItemId aItemId, TPointerEventType aEventType )
+    const TFsTreeItemId aItemId, TPointerEventType aEventType, const TPoint& aPoint )
     {
     FUNC_LOG;
-    TRAPD(error, SetFocusedItemAndSendEventL( aItemId, aEventType ) );
+    TRAPD(error, SetFocusedItemAndSendEventL( aItemId, aEventType, aPoint ) );
     return error;
     }
 
@@ -5020,7 +5026,7 @@
 // ---------------------------------------------------------------------------
 //
 void CFsTreeVisualizerBase::SetFocusedItemAndSendEventL(
-        const TFsTreeItemId aItemId, TPointerEventType aEventType )
+        const TFsTreeItemId aItemId, TPointerEventType aEventType, const TPoint& aPoint )
     {
     FUNC_LOG;
 
@@ -5036,7 +5042,7 @@
         SetFocusedItemL( aItemId );
         iVisualizerObserver->TreeVisualizerEventL(
             MFsTreeVisualizerObserver::EFsTreeItemTouchFocused,
-            FocusedItem() );
+            FocusedItem(), aPoint );
 
         // If DirectTouchMode (actions happens in pointer down events)
         if( iFlags.IsSet( EDirectTouchMode ) && aEventType == EPointerDown )
@@ -5044,19 +5050,22 @@
             iTouchPressed = EFalse;
             iVisualizerObserver->TreeVisualizerEventL(
                 MFsTreeVisualizerObserver::EFsTreeItemTouchAction,
-                aItemId );
+                aItemId, aPoint );
             }
         }
     else if( aEventType == ELongTap )
         {
+        // HandlePointerEventL do not get pointer up event after long tap event
+        // so <code>iTouchPressed</code> flag needs to be reset here.
+        iTouchPressed = EFalse;
 		iVisualizerObserver->TreeVisualizerEventL(
 				MFsTreeVisualizerObserver::EFsTreeItemTouchLongTap,
-  			    aItemId );
+  			    aItemId, aPoint );
         }
     else if( aEventType == EPointerUp )
         {
         iVisualizerObserver->TreeVisualizerEventL(
-            MFsTreeVisualizerObserver::EFsTreeItemTouchAction, aItemId );
+            MFsTreeVisualizerObserver::EFsTreeItemTouchAction, aItemId, aPoint );
         }
     }
 
@@ -5106,12 +5115,12 @@
 //
 // ---------------------------------------------------------------------------
 //
-CFsTreeVisualizerBase::CDragHandler::TDragDirection 
-    CFsTreeVisualizerBase::CDragHandler::DragDirection( 
+CFsTreeVisualizerBase::CDragHandler::TDragDirection
+    CFsTreeVisualizerBase::CDragHandler::DragDirection(
         const TPoint& aCurrent, const TPoint aPrevious ) const
     {
     FUNC_LOG;
-    if (aCurrent.iY > aPrevious.iY) 
+    if (aCurrent.iY > aPrevious.iY)
         {
         return EDraggingDown;
         }
@@ -5119,7 +5128,7 @@
         {
         return EDraggingUp;
         }
-    else 
+    else
         {
         return iDragDirection;
         }
@@ -5140,7 +5149,7 @@
     iStartTime.HomeTime();
     iFlags.Set( EPointerDownReceived );
 
-    iTree.SetFocusedItemAndSendEvent( iItemId, EPointerDown );
+    iTree.SetFocusedItemAndSendEvent( iItemId, EPointerDown, iPosition );
     }
 
 // ---------------------------------------------------------------------------
@@ -5148,12 +5157,12 @@
 // ---------------------------------------------------------------------------
 //
 void CFsTreeVisualizerBase::CDragHandler::PointerRepeat(
-        const TPointerEvent& /*aEvent*/ )
+        const TPointerEvent& aEvent )
     {
     if( iItemId != KFsTreeNoneID && !IsFlicking() )
         {
         iFlags.Set( EWasRepeat );
-        iTree.SetFocusedItemAndSendEvent( iItemId, ELongTap );
+        iTree.SetFocusedItemAndSendEvent( iItemId, ELongTap, aEvent.iParentPosition );
         }
     }
 
@@ -5171,7 +5180,7 @@
         if( ( aItemId != KFsTreeNoneID ) &&
             ( iTree.FocusedItem() == aItemId  ) )
             {
-            iTree.SetFocusedItemAndSendEvent( iItemId, EPointerUp );
+            iTree.SetFocusedItemAndSendEvent( iItemId, EPointerUp, aEvent.iParentPosition );
             }
         }
     else if ( IsFlicking() )
@@ -5181,7 +5190,7 @@
         }
     else if( !iFlags.IsSet( EWasRepeat ) && iItemId != KFsTreeNoneID )
         {
-        iTree.SetFocusedItemAndSendEvent( iItemId, EPointerUp );
+        iTree.SetFocusedItemAndSendEvent( iItemId, EPointerUp, aEvent.iParentPosition );
         }
     iLastPointerPosition = iPosition = TPoint();
     iFlags.Clear( EPointerDownReceived );
@@ -5228,7 +5237,7 @@
                     - aEvent.iPosition.iY));
             }
         TDragDirection dragDirection(DragDirection(aEvent.iPosition, iLastPointerPosition));
-        const TBool dragDirectionChanged( 
+        const TBool dragDirectionChanged(
                 (dragDirection == EDraggingUp && iDragDirection == EDraggingDown ) ||
                 (dragDirection == EDraggingDown && iDragDirection == EDraggingUp ) );
         if (dragDirectionChanged)
@@ -5294,7 +5303,7 @@
     FUNC_LOG;
     CDragHandler* self = reinterpret_cast<CDragHandler*>( aPtr );
     self->iHighlightTimer->Cancel();
-    return self->iTree.SetFocusedItemAndSendEvent( self->iItemId, ELongTap );
+    return self->iTree.SetFocusedItemAndSendEvent( self->iItemId, ELongTap, self->iPosition );
     }
 
 // ---------------------------------------------------------------------------
@@ -5303,7 +5312,7 @@
 //
 TBool CFsTreeVisualizerBase::IsFocusShown()
     {
-    if( iTouchPressed || iFocusVisible ) 
+    if( iTouchPressed || iFocusVisible )
         {
         return ETrue;
         }
Binary file emailuis/widget/emailwidgetsettings/conf/cmailwidget.confml has changed
Binary file emailuis/widget/emailwidgetsettings/conf/cmailwidget_2001E272.crml has changed
--- a/emailuis/widget/hsps/00/emailwidgetconfiguration.dtd	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/widget/hsps/00/emailwidgetconfiguration.dtd	Mon Jan 18 20:08:26 2010 +0200
@@ -8,7 +8,7 @@
 <FileVersion    : >
 
 <Copyright:
-"Copyright © 2008 Nokia Corporation.
+"Copyright © 2009 Nokia Corporation.
 This material, including documentation and any related
 computer programs, is protected by copyright controlled by
 Nokia Corporation. All rights are reserved. Copying,
@@ -22,12 +22,20 @@
 
 <!--
 qtn_hscr_email.attributes
-qtn_hscr_email.layout "ai_gene_pane_1_t1"
+qtn_hscr_email.layout "listrow_wgtman_pane_t1"
 qtn_hscr_email.release "TB9.1"
 qtn_hscr_email.description "Email widget"
-qtn_hscr_email.parents "ai_gene_pane_1"
+qtn_hscr_email.parents "listrow_wgtman_pane"
 -->
 <!ENTITY qtn_hscr_email "Cmail widget">
+
+<!--
+qtn_hscr_email.attributes
+qtn_hscr_email.layout "listrow_wgtman_pane_t2"
+qtn_hscr_email.release "TB9.1"
+qtn_hscr_email.description "Email widget description"
+qtn_hscr_email.parents "listrow_wgtman_pane"
+-->
 <!ENTITY qtn_hs_widget_mail_description "Informs of incoming mail messages">
 
 <!-- End of File -->
--- a/emailuis/widget/hsps/00/manifest.dat	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/widget/hsps/00/manifest.dat	Mon Jan 18 20:08:26 2010 +0200
@@ -1,8 +1,9 @@
 <?xml version="1.0"?>
-<package version="1.0">
+<package version="2.0">
 
    <family>qhd_tch</family>
-
+   <family>vga_tch</family> 
+   
    <type>widget</type>
 
    <!-- interface uid -->
--- a/emailuis/widget/xuikon/00/emailwidget.css	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/widget/xuikon/00/emailwidget.css	Mon Jan 18 20:08:26 2010 +0200
@@ -17,7 +17,6 @@
     height: 100%;
     direction: ltr;
     block-progression: tb;
-    touchfeedback: basic;
     nav-index: appearance;	
 }
 
@@ -32,16 +31,9 @@
     height: 100%;
     direction: ltr;
     block-progression: tb;
-    touchfeedback: basic;
     nav-index: appearance;	
 }
 
-box:focus
-{
-    border-color: cyan;
-	focus-background:"SKIN(268458534 9896)";
-}
-
 box.row_container
 {
     display: block;
--- a/emailuis/widget/xuikon/00/emailwidget.xml	Thu Jan 07 12:38:38 2010 +0200
+++ b/emailuis/widget/xuikon/00/emailwidget.xml	Mon Jan 18 20:08:26 2010 +0200
@@ -14,14 +14,7 @@
         <box id="SetupContainer" focusable="true" _s60-initial-focus="1">
             <actions>
                 <action>
-                    <trigger name="stylus">
-                        <property name="eventtype" value="up" />
-                    </trigger>
                     <trigger name="activate"/>
-                    <trigger name="keyevent">
-                        <property name="scancode" value="3"/>
-                        <property name="eventtype" value="1"/>
-                    </trigger>
                     <event name="0x2001F413:CMailWidget/ct_setup_text(trigger_wizard)"/>
                 </action>
             </actions>
@@ -46,14 +39,7 @@
         
             <actions>
                 <action>
-                    <trigger name="stylus">
-                        <property name="eventtype" value="up" />
-                    </trigger>
                     <trigger name="activate"/>
-                    <trigger name="keyevent">
-                        <property name="scancode" value="3"/> <!-- enter key / EStdKeyEnter -->
-                        <property name="eventtype" value="1"/>
-                    </trigger>
                     <event name="0x2001F413:CMailWidget/ct_body_text_1(trigger_emailui)"/>
                 </action>
             </actions>
--- a/help/inc/cmail.hlp.hrh	Thu Jan 07 12:38:38 2010 +0200
+++ b/help/inc/cmail.hlp.hrh	Mon Jan 18 20:08:26 2010 +0200
@@ -2,9 +2,9 @@
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
-* under the terms of the License "Symbian Foundation License v1.0"
+* under the terms of "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
-* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
--- a/ipsservices/ipssosplugin/inc/ipsplgsearch.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/ipsservices/ipssosplugin/inc/ipsplgsearch.h	Mon Jan 18 20:08:26 2010 +0200
@@ -163,6 +163,10 @@
      */
     void CollectMessagesL();
 
+    /**
+     * server asks client if to change the search priority (when calling)
+     */
+    void ClientRequiredSearchPriority( TInt *apRequiredSearchPriority );
     
 protected:
 
--- a/ipsservices/ipssosplugin/inc/ipsplgsearchop.h	Thu Jan 07 12:38:38 2010 +0200
+++ b/ipsservices/ipssosplugin/inc/ipsplgsearchop.h	Mon Jan 18 20:08:26 2010 +0200
@@ -66,7 +66,7 @@
      * @return
      */
     void DoCancel();
-    
+
 protected:
 
     /**
@@ -225,6 +225,12 @@
      */
     CIpsPlgTextSearcher* iSearcher;  
     
+//    
+    /**
+     * Enable changing searching priority on client feedback - must be made in RunL
+     */
+    TInt iRequiredPriority;
+//    
     };
 
 #endif /* IPSPLGSEARCHOP_H */
--- a/ipsservices/ipssosplugin/src/ipsplgsearch.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/ipsservices/ipssosplugin/src/ipsplgsearch.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -999,6 +999,15 @@
             }
         }    
     }
+
+//Ask client if it wants to change the search prority (i.e. to enable search for contact)
+void CIpsPlgSearch::ClientRequiredSearchPriority( TInt *apRequiredSearchPriority )
+	{
+	FUNC_LOG;
+	if ( iObserver )
+	  iObserver->ClientRequiredSearchPriority( apRequiredSearchPriority );
+	}
+
     
 // End of File
 
--- a/ipsservices/ipssosplugin/src/ipsplgsearchop.cpp	Thu Jan 07 12:38:38 2010 +0200
+++ b/ipsservices/ipssosplugin/src/ipsplgsearchop.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -22,8 +22,10 @@
 
 /** Snippet length, for HTML tags. */
 const TInt KIpsPlgSnippetLen = 300;
+
+// changed to one mail per one RunL - for cycle in RunL was removed
 // Defines the number of mails handled in one scheduler round
-const TInt KIpsPlgSearchMailsInRound = 10;
+// const TInt KIpsPlgSearchMailsInRound = 10;
 
 // ======== CONSTRUCTORS & DESTRUCTOR ========
 
@@ -85,6 +87,7 @@
     iMessage( NULL )
     {
     FUNC_LOG;
+    iRequiredPriority = Priority(); // priority changes are enabled
     CActiveScheduler::Add( this );
     }
 
@@ -137,13 +140,12 @@
             iObserver.CollectMessagesL();
             iObserver.Sort();
             iState = ERunning;
+            iRequiredPriority = EPriorityStandard; // priority changes may be decreased
             ActivateAndComplete();
             break;
             }
         case ERunning:
             {
-            for ( TInt i(0); i < KIpsPlgSearchMailsInRound; i++ )
-                {
                 if ( NextMailL() )
                     {
                     // Mail found, read the content and search for the string.
@@ -158,9 +160,13 @@
                     FinalizeL();
                     return;
                     }
-                }
+            iState = ERunning;
+// When client wants call to contact the priority must be decreased 
+// to enable search for contact which uses idle priority
+            TInt clientRequiredPriority(iRequiredPriority);
+            iObserver.ClientRequiredSearchPriority( &clientRequiredPriority );
+            iRequiredPriority = ((clientRequiredPriority > EPriorityIdle) ? EPriorityStandard : EPriorityIdle-1);
 
-            iState = ERunning;
             ActivateAndComplete();
             break;
             }
@@ -363,6 +369,11 @@
     {
     FUNC_LOG;
     iStatus = KRequestPending; 
+// When client wants call to contact the priority must be decreased 
+// to enable search for contact made with idle priority
+    if ( Priority() != iRequiredPriority ) // <cmail>
+    	SetPriority(iRequiredPriority);
+
     SetActive();    
     TRequestStatus* status = &iStatus;
     User::RequestComplete( status, KErrNone );    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/data/IpsSosTestApp.rss	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,161 @@
+/*
+* ============================================================================
+*  Name     : ipssostestapp.rss
+*  Part of  : ipssostestapp
+* ============================================================================
+*/
+
+//  RESOURCE IDENTIFIER
+NAME    TEST // 4 letter ID
+
+//  INCLUDES
+
+#include <eikon.rh>
+#include "testapp.hrh"
+#include "ipssostestapp.loc"
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf="ipssostestapp"; }
+
+RESOURCE EIK_APP_INFO
+    {    
+    menubar=r_testapp_menubar;
+    cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT;     
+    }
+
+RESOURCE LOCALISABLE_APP_INFO r_testapp_app_info
+    {
+    short_caption = "IpsSosTestApp";                                     
+    caption_and_icon = 
+    CAPTION_AND_ICON_INFO
+        {
+        caption = "IpsSosTest";                                      
+        };
+    }
+
+//----------------------------------------------------
+//   
+//    r_testapp_hotkeys
+//    ?description
+//
+//----------------------------------------------------
+//
+RESOURCE HOTKEYS r_testapp_hotkeys
+    {
+    control=
+        {
+        HOTKEY { command=EAknCmdExit; key='e'; }
+        };
+    }
+
+//----------------------------------------------------
+//   
+//    r_testapp_menubar
+//    ?description
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_BAR r_testapp_menubar
+    {
+    titles=
+        {
+        MENU_TITLE { menu_pane=r_testapp_menu; txt="File"; }
+        };
+    }
+
+//----------------------------------------------------
+//   
+//    r_testapp_menu
+//    ?description
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_PANE r_testapp_menu
+    {
+    items=
+        {		
+		MENU_ITEM { command=ETestAppSubMenuId; txt="Run"; cascade=r_testapp_launch_sub_menu; },		
+		MENU_ITEM { command=EAknCmdExit; txt="Exit"; }        			
+        };
+    }
+    
+    
+//----------------------------------------------------
+//   
+//    r_testapp_menu
+//    ?description
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_PANE r_testapp_launch_sub_menu
+    {
+    items=
+        {
+        // TODO add submenus here
+        MENU_ITEM { command=ETest1Cmd; txt="Create settings"; },
+        MENU_ITEM { command=ETest2Cmd; txt="Launch test case"; },
+        MENU_ITEM { command=ETest3Cmd; txt="Launch recent"; }	
+        };
+    } 
+    
+//----------------------------------------------------
+//   
+//    r_number_query_dialog
+//
+//----------------------------------------------------
+//
+RESOURCE DIALOG r_number_query_dialog
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control= AVKON_DATA_QUERY
+                {
+                layout = ENumberLayout;
+                control = AVKON_INTEGER_EDWIN
+                    {
+                    min = 0;
+                    max = 99;
+                    };
+                };
+            }
+        };
+    }
+    
+//----------------------------------------------------
+//   
+//    r_text_query_dialog
+//
+//----------------------------------------------------
+//
+RESOURCE DIALOG r_text_query_dialog
+    {
+    flags=EGeneralQueryFlags;
+    buttons=R_AVKON_SOFTKEYS_OK_CANCEL;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control= AVKON_DATA_QUERY
+                {
+                layout = EDataLayout;
+		        control = EDWIN{};
+                };
+            }
+        };
+    }   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/data/IpsSosTestApp_reg.rss	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,17 @@
+
+#include <appinfo.rh>
+#include <ipssostestapp.rsg>
+#include <data_caging_paths_strings.hrh>
+
+UID2 KUidAppRegistrationResourceFile
+// <cmail> S60 UID update
+UID3 0x2001FE0F // application UID
+// </cmail> S60 UID update
+
+RESOURCE APP_REGISTRATION_INFO
+	{
+	app_file = "IpsSosTestApp";	
+    localisable_resource_file = APP_RESOURCE_DIR"\\IpsSosTestApp";
+    localisable_resource_id = R_TESTAPP_APP_INFO;
+	}
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/data/ipssostest.ini	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,37 @@
+// Spaces not allowed
+// between keys & values
+// File location c:\data\IpsSosTestCases
+
+// Allowed values: IMAP4, POP3
+Protocol=IMAP4
+
+MailboxName=Email
+
+EmailAddress=myaccount@email.com
+
+UserName=username
+
+Password=password
+
+UserAlias=alias
+
+
+// Allowed values: AlwaysAsk, UserDefined
+AccessPoint=AlwaysAsk
+
+IncomingServerAddress=emailprojects.nmp.nokia.com
+// Allowed values: Default, UserDefined
+IncomingPort=UserDefined
+
+// Allowed values: Off, Tls, Ssl
+IncomingSecurity=Off
+
+OutgoingServerAddress=emailprojects.nmp.nokia.com
+
+// Allowed values: Default, UserDefined
+OutgoingPort=Default
+
+// Allowed values: Off, Tls, Ssl
+OutgoingSecurity=Off
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/group/bld.inf	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,17 @@
+/*
+* ============================================================================
+*  Name     : bld.inf
+* ============================================================================
+*/
+
+
+PRJ_PLATFORMS
+	DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+
+ipssostestapp.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/group/ipssostestapp.mmp	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,67 @@
+/*
+* ============================================================================
+*  Name     : ipssostestapp.mmp
+
+* ============================================================================
+*/
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+#include "../../../epoc32/include/oem/defaultcaps.hrh"
+
+TARGET  ipssostestapp.exe
+TARGETTYPE  exe
+
+// <cmail> S60 UID update
+UID  0x100039CE 0x2001FE0F
+// </cmail> S60 UID update
+VENDORID        VID_DEFAULT
+CAPABILITY      ALL -TCB
+LANG     SC
+
+SOURCEPATH ../src
+SOURCE  TestAppApp.cpp
+SOURCE  TestAppAppUi.cpp
+SOURCE  TestAppDocument.cpp
+SOURCE  TestAppContainer.cpp
+
+START RESOURCE ../data/ipssostestapp.rss
+HEADER
+TARGETPATH APP_RESOURCE_DIR
+END //resource
+
+START RESOURCE ../data/ipssostestapp_reg.rss
+DEPENDS ipssostestapp.rsg
+TARGETPATH /private/10003a3f/apps
+END
+
+// <cmail>
+APP_LAYER_SYSTEMINCLUDE
+// </cmail>
+USERINCLUDE ../inc
+USERINCLUDE ../../../inc
+USERINCLUDE ..\..\..\..\..\..\ODSUtility\inc
+
+SYSTEMINCLUDE   /epoc32/include
+//<cmail>
+//<cmail>
+USERINCLUDE ../../../../../inc
+//</cmail>
+//</cmail>
+
+LIBRARY euser.lib
+LIBRARY apparc.lib
+LIBRARY cone.lib
+LIBRARY eikcore.lib
+LIBRARY eikcoctl.lib
+LIBRARY avkon.lib
+LIBRARY bafl.lib
+LIBRARY AknSkins.lib
+LIBRARY imumda.lib
+LIBRARY imcm.lib
+LIBRARY efsrv.lib
+LIBRARY estor.lib
+LIBRARY msgs.lib
+LIBRARY centralrepository.lib 
+LIBRARY odsutility.lib
+LIBRARY ipssossettings.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/inc/TESTAPPApp.h	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,49 @@
+/*
+* ============================================================================
+*  Name     : CTestAppApp from TestAppApp.h
+*  Part of  : TestApp
+* ============================================================================
+*/
+
+#ifndef TestAppAPP_H
+#define TestAppAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+// UID of the application
+// <cmail> S60 UID update
+const TUid KUidTestApp = { 0x2001FE0F };
+// </cmail> S60 UID update
+
+// CLASS DECLARATION
+
+/**
+* CTestAppApp application class.
+* Provides factory to create concrete document object.
+*
+*/
+class CTestAppApp : public CAknApplication
+    {
+
+    public: // Functions from base classes
+    private:
+
+        /**
+        * From CApaApplication, creates CTestAppDocument document object.
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+
+        /**
+        * From CApaApplication, returns application's UID (KUidTestApp).
+        * @return The value of KUidTestApp.
+        */
+        TUid AppDllUid() const;
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/inc/TESTAPPAppUi.h	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,189 @@
+/*
+* ============================================================================
+*  Name     : CTestAppAppUi from TestAppAppUi.h
+* ============================================================================
+*/
+
+#ifndef TESTAPPAPPUI_H
+#define TESTAPPAPPUI_H
+
+// INCLUDES
+#include <aknappui.h>
+#include <msvapi.h>
+#include <Imumdasettingskeys.h>
+
+// FORWARD DECLARATIONS
+class CTestAppContainer;
+
+const TInt TTestAppUiIpsBufLength = 200;
+
+// CLASS DECLARATION
+
+// Name of the ini KIpsSosTestIni
+//_LIT( KIpsSosTestFilePath, "c:\\data\\ipssostestcases\\" );
+_LIT( KIpsSosTestFilePath, "c:\\" );
+_LIT( KIpsSosTestFileName, "ipssostest" );
+_LIT( KIpsSosTestFileExtension, ".ini" );
+
+// Literals used in ini
+_LIT8( KIpsSosTestProtocol, "Protocol" );
+_LIT8( KIpsSosTestIMAP, "IMAP4" );
+_LIT8( KIpsSosTestPOP, "POP3" );
+_LIT8( KIpsSosTestMailboxName, "MailboxName" );
+_LIT8( KIpsSosTestEmailAddress, "EmailAddress" );
+_LIT8( KIpsSosTestUserName, "UserName" );
+_LIT8( KIpsSosTestPassword, "Password" );
+_LIT8( KIpsSosTestUserAlias, "UserAlias" );
+_LIT8( KIpsSosTestSignature, "Signature" );
+_LIT8( KIpsSosTestFolderPath, "FolderPath" );
+_LIT8( KIpsSosTestAccessPoint, "AccessPoint" );
+_LIT8( KIpsSosTestIncomingServerAddress, "IncomingServerAddress" );
+_LIT8( KIpsSosTestIncomingPort, "IncomingPort" );
+_LIT8( KIpsSosTestIncomingSecurity, "IncomingSecurity" );
+_LIT8( KIpsSosTestOutgoingServerAddress, "OutgoingServerAddress" );
+_LIT8( KIpsSosTestOutgoingPort, "OutgoingPort" );
+_LIT8( KIpsSosTestOutgoingSecurity, "OutgoingSecurity" );
+_LIT8( KIpsSosTestPortValueDefault, "Default" );
+_LIT8( KIpsSosTestPortValueUserDefined, "UserDefined" );
+_LIT8( KIpsSosTestAPAlwaysAsk, "AlwaysAsk" );
+_LIT8( KIpsSosTestSecurityTls, "Tls" );
+_LIT8( KIpsSosTestSecuritySsl, "Ssl" );
+
+
+// Ini-file commentline identifier
+_LIT8( KIpsSosTestIniCommentLine, "//");
+// Ini-file key value separator
+_LIT8( KIpsSosTestIniSeparator, "=");
+// Ini-file hex value identifier
+_LIT8( KIpsSosTestIniHexMark, "0x");
+
+// Used with panic if error occurs
+_LIT( KIpsSosTestPanicText, "KIpsSosTestPanic" );
+
+// Notes
+_LIT( KIpsSosTestRecentNotFound, "Recent view not found" );
+_LIT( KIpsSosTestErrorLaunching, "Error in plugin launching" );
+_LIT( KIpsSosTestErrorInWriting, "Error in settins writing" );
+_LIT( KIpsSosTestSettingsCreated, "Settings created" );
+_LIT( KIpsSosTestFileNotFound, "File not found" );              
+_LIT( KIpsSosTestErrorInReading, "Error in settings reading" );
+_LIT( KIpsSosTestUnknownValue, "Unknown settings key value");
+                                                            
+// Used as delimeter in ini-file
+const TInt KIpsSosTestLineFeed = 0x000D;
+
+// Used for removing delimeter 
+const TInt KIpsSosTestDelimeterSize = 1;
+ 
+// Max length of line in ini-file
+const TInt KIpsSosTestMaxLineLength = 128; 
+
+// Buf lenght for format
+const TInt KIpsSosTestFormatBufLength = 50;
+
+const TInt KIpsSosTestDefaultFile = 0;
+
+const TInt KIpsSosTestPortDefault = 0;
+
+const TInt KIpsSosTestAlwaysAskAp = 0;
+
+// P&S KEY and categories
+enum TIpsSosTestPropertyKeys 
+    {
+	EIpsSosTestRecentMsvId = 1
+    };    
+
+const TUid KIpsSosTestPropertyCat = {0x10012349}; 
+
+/**
+* Application UI class.
+* 
+*/
+class CTestAppAppUi : public CAknAppUi, public MMsvSessionObserver                            
+    {
+    public: // // Constructors and destructor
+        
+        /**
+        * Default constructor.
+        */      
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */      
+        ~CTestAppAppUi();
+        
+    public: //from MIdleFindObserver
+        void IdleFindCallback();
+        
+    public: // from MMsvSessionObserver
+        
+        void HandleSessionEventL(
+                TMsvSessionEvent aEvent, 
+                TAny* aArg1, 
+                TAny* aArg2, 
+                TAny* aArg3 );
+
+    private: // New functions          
+        //Put 3 pointer in CleanupStack        
+        void DebugL( TRefByValue<const TDesC> aText, ...);
+        void TimeDebugL( TTime aStartTime, TTime aEndTime );
+    private:
+        // From MEikMenuObserver
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+
+    private:
+    
+        void LaunchPluginL();
+        void WriteSettingsViaODSUtilityL();
+        void WriteSettingsToWizardCenRepL();
+        void WriteSettingsViaImumL();
+        void ReadSettingsL( TInt aFileId );
+        void DeleteAllSettingsL();
+        void SetRecentMsvIdL( TMsvId aMsvId );
+        TMsvId RecentMsvId();        
+        void ShowNoteL( const TDesC& aMessage );
+
+
+        /**
+        * From CEikAppUi, takes care of command handling.
+        * @param aCommand command to be handled
+        */
+        void HandleCommandL(TInt aCommand);
+
+        /**
+        * From CEikAppUi, handles key events.
+        * @param aKeyEvent Event to handled.
+        * @param aType Type of the key event. 
+        * @return Response code (EKeyWasConsumed, EKeyWasNotConsumed). 
+        */
+        virtual TKeyResponse HandleKeyEventL(
+            const TKeyEvent& aKeyEvent,TEventCode aType);
+
+    private: // Data
+        // Own:
+        CTestAppContainer* iAppContainer; 
+        
+        TMsvId                                  iMailboxId;
+        TInt32                                  iProtocol;
+        TBuf<TTestAppUiIpsBufLength>            iMailboxName;
+        TBuf<TTestAppUiIpsBufLength>            iEmailAddress;
+        TBuf<TTestAppUiIpsBufLength>            iIncomingServerAddress;
+        TBuf<TTestAppUiIpsBufLength>            iUserName;
+        TBuf<TTestAppUiIpsBufLength>            iPassword;
+        TBuf<TTestAppUiIpsBufLength>            iUserAlias;
+        TBuf<TTestAppUiIpsBufLength>            iSignature;
+        TBuf<TTestAppUiIpsBufLength>            iFolderPath;
+        TInt                                    iIncomingPort;
+        TBuf<TTestAppUiIpsBufLength>            iAccessPoint;
+        TInt                                    iIncomingSecurity;
+        TInt                                    iOutProtocol;
+        TBuf<TTestAppUiIpsBufLength>            iOutgoingServerAddress;
+        TInt                                    iOutgoingPort;
+        TInt                                    iOutgoingSecurity;
+
+    };
+
+#endif  // TESTAPPAPPUI_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/inc/TESTAPPContainer.h	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,66 @@
+/*
+* ============================================================================
+*  Name     : CTestAppContainer from TestAppContainer.h
+*  Part of  : TestApp
+* ============================================================================
+*/
+
+#ifndef TestAppCONTAINER_H
+#define TestAppCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <badesca.h>
+   
+// FORWARD DECLARATIONS
+class CEikTextListBox;
+class MAknsSkinInstance;
+class CAknsBasicBackgroundControlContext;
+
+
+// CLASS DECLARATION
+
+/**
+*  CTestAppContainer  container control class.
+*  
+*/
+class CTestAppContainer : public CCoeControl, MCoeControlObserver
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * EPOC default constructor.
+        * @param aRect Frame rectangle for container.
+        */
+        void ConstructL(const TRect& aRect);
+
+        /**
+        * Destructor.
+        */
+        ~CTestAppContainer();
+
+    public: // New functions
+        void AppendDataL( TDesC& buf );
+    public: // Functions from base classes
+
+    private: // Functions from base classes
+        void SizeChanged();
+        TInt CountComponentControls() const;
+        CCoeControl* ComponentControl(TInt aIndex) const;
+        void Draw(const TRect& aRect) const;
+        void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
+        
+    private: //data
+        CEikTextListBox* iListBox;
+        CDesCArrayFlat* iItems;  
+        
+        /// Ref: A pointer MAknsSkinInstance
+        MAknsSkinInstance* iSkinInstance;
+
+        /// Own: A pointer CAknBasicBackgroundControlContext
+		CAknsBasicBackgroundControlContext* iBackgroundSkinContext;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/inc/TESTAPPDocument.h	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,62 @@
+/*
+* ============================================================================
+*  Name     : CTestAppDocument from TestAppDocument.h
+*  Part of  : TestApp
+* ============================================================================
+*/
+
+#ifndef TestAppDOCUMENT_H
+#define TestAppDOCUMENT_H
+
+// INCLUDES
+#include <akndoc.h>
+   
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class  CEikAppUi;
+
+// CLASS DECLARATION
+
+/**
+*  CTestAppDocument application class.
+*/
+class CTestAppDocument : public CAknDocument
+    {
+    public: // Constructors and destructor
+        /**
+        * Two-phased constructor.
+        */
+        static CTestAppDocument* NewL(CEikApplication& aApp);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CTestAppDocument();
+
+    public: // New functions
+
+    protected:  // New functions
+
+    protected:  // Functions from base classes
+
+    private:
+
+        /**
+        * EPOC default constructor.
+        */
+        CTestAppDocument(CEikApplication& aApp);
+        void ConstructL();
+
+    private:
+
+        /**
+        * From CEikDocument, create CTestAppAppUi "App UI" object.
+        */
+        CEikAppUi* CreateAppUiL();
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/inc/ipssostestapp.loc	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,22 @@
+/*
+* ============================================================================
+*  Name     : ipssostestapp.loc
+* ============================================================================
+*/
+
+// LOCALISATION STRINGS
+
+//d:Command in options menu.
+//d:Example application spesific command.
+//l:list_single_popup_submenu_pane_1
+//
+#define qtn_appl_option_item "<App spesific menu item>"
+
+
+// example caption strings for app
+#define qtn_app_caption_string "IpsSosTestApp"
+
+#define qtn_app_short_caption_string "IpsSosTestApp"
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/inc/testapp.hrh	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,21 @@
+/*
+* ============================================================================
+*  Name     : TestApp resource header file TestApp.hrh
+* ============================================================================
+*/
+
+#ifndef TestApp_HRH
+#define TestApp_HRH
+
+enum TTestAppCommandIds
+    {    	
+	ETestAppSubMenuId,
+	ETest1Cmd,
+	ETest2Cmd,
+	ETest3Cmd
+	};
+
+
+
+
+#endif      // TestApp_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/install/ipssostestapp.pkg	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,32 @@
+;
+; Installation file for TestApp application
+;
+;Languages
+&EN
+
+;Localized Vendor Name
+%{"Nokia email EN"}
+
+;Unique Vendor name
+:"Vendor"
+;
+; UID is the app's UID
+;
+; <cmail> S60 UID update
+#{"IpsSosTestApp"},(0x2001FE0F),1,0,0  
+; </cmail> S60 UID update
+;
+;Supports Series 60 v 0.9
+;This line indicates that this installation is for the Series 60 platform v0.9
+;This line must appear _exactly_ as shown below in the sis file
+;If this line is missing or incorrect, the sis file will not be able
+;to be installed on Series 60 v0.9 platforms
+(0x101F6F88), 0, 0, 0, {"Series60ProductID"}
+;
+; Test application
+;
+"\epoc32\release\armv5\urel\IpsSosTestApp.exe"-"!:\sys\bin\IpsSosTestApp.exe"
+"\epoc32\data\Z\private\10003a3f\apps\ipssostestapp_reg.rsc"-"!:\private\10003a3f\import\apps\ipssostestapp_reg.rsc"
+"\epoc32\data\z\resource\apps\ipssostestapp.rsc"-"!:\resource\apps\ipssostestapp.rsc"
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/src/TESTAPPApp.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,46 @@
+/*
+* ============================================================================
+*  Name     : CTestAppApp from TestAppApp.cpp
+*  Part of  : TestApp
+* ============================================================================
+*/
+
+// INCLUDE FILES
+#include    "TestAppApp.h"
+#include    "TestAppDocument.h"
+
+#include <eikstart.h>
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CTestAppApp;
+    }
+
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication( NewApplication );
+    }
+
+
+// ---------------------------------------------------------
+// CTestAppApp::AppDllUid()
+// Returns application UID
+// ---------------------------------------------------------
+//
+TUid CTestAppApp::AppDllUid() const
+    {
+    return KUidTestApp;
+    }
+
+   
+// ---------------------------------------------------------
+// CTestAppApp::CreateDocumentL()
+// Creates CTestAppDocument object
+// ---------------------------------------------------------
+//
+CApaDocument* CTestAppApp::CreateDocumentL()
+    {
+    return CTestAppDocument::NewL( *this );
+    }
+// End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/src/TESTAPPAppUi.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,690 @@
+/*
+* ============================================================================
+*  Name     : CTestAppAppUi from TestAppAppUi.cpp
+*  Part of  : TestApp
+* ============================================================================
+*/
+
+// INCLUDE FILES
+#include <ipssostestapp.rsg>
+
+#include <avkon.hrh>
+#include <aknnotewrappers.h> 
+#include <e32property.h>
+#include <msvstd.h>
+#include <ImumDaSettingsData.h>
+#include <ImumDaSettingsDatacollection.h>
+#include <ImumDaMailboxServices.h>
+#include <ImumDaMailboxUtilities.h>
+#include <ImumDomainApi.h>
+#include <Imumdasettingskeys.h>
+#include <senduiconsts.h>
+#include <cemailaccounts.h>
+//#include <ODSUtility.h>
+
+#include "TestAppAppUi.h"
+#include "TestAppContainer.h"
+#include "TestApp.hrh"
+#include "ipssetdataapi.h"
+#include "ipssetwizardadapter.h"
+
+//#include "ODSConfigSettings.h"
+
+const TUid KTestAppCRUidWizardSettings   = {0x2000B112};
+
+const TInt KTestAppWizardDataPopIndicator = 0;
+const TInt KTestAppWizardDataImapIndicator = 1;
+
+const TInt KTestAppWizardDataSecurityOff = 0;
+const TInt KTestAppWizardDataSecurityTLS = 1;
+const TInt KTestAppWizardDataSecuritySSL = 2;
+
+_LIT( KTestAppFsBasicPluginStr, "fsp" );
+
+
+           
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// ----------------------------------------------------------
+// CTestAppAppUi::LaunchPluginL()
+// ----------------------------------------------------------
+//
+void CTestAppAppUi::LaunchPluginL()
+    {
+    CIpsSetDataApi::LaunchSettingsL( iMailboxId );
+    } 
+
+// ----------------------------------------------------------
+// CTestAppAppUi::WriteSettingsL()
+// ----------------------------------------------------------
+//  
+void CTestAppAppUi::HandleSessionEventL(
+        TMsvSessionEvent /*aEvent*/, 
+        TAny* /*aArg1*/, 
+        TAny* /*aArg2*/, 
+        TAny* /*aArg3*/ )
+    {
+    
+    }
+
+// ----------------------------------------------------------
+// CTestAppAppUi::WriteSettingsL()
+// ----------------------------------------------------------
+//    
+void CTestAppAppUi::WriteSettingsViaODSUtilityL()
+    {
+
+    }
+
+
+// ----------------------------------------------------------
+// CTestAppAppUi::WriteSettingsToWizardCenRepL()
+// ----------------------------------------------------------
+// 
+void CTestAppAppUi::WriteSettingsToWizardCenRepL()
+    {
+    CRepository* repository;
+    repository = CRepository::NewL( KTestAppCRUidWizardSettings );
+    CleanupStack::PushL( repository );
+    TInt error = KErrNone; 
+    error = repository->Set( CIpsSetWizardAdapter::ECRKSetupWizAccountType, 
+            KTestAppFsBasicPluginStr );
+    
+    error = repository->Set( CIpsSetWizardAdapter::ECRKMaxAccountsReached,
+            EFalse );
+    
+    
+    if ( iProtocol == KSenduiMtmImap4UidValue )
+        {
+        error = repository->Set( 
+                CIpsSetWizardAdapter::ECRKPopImapProtocolIndicatorId,
+                KTestAppWizardDataImapIndicator );
+        }
+    else if ( iProtocol == KSenduiMtmPop3UidValue )
+        {
+        error = repository->Set( 
+                CIpsSetWizardAdapter::ECRKPopImapProtocolIndicatorId,
+                KTestAppWizardDataPopIndicator );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapEmailAddressId,
+            iEmailAddress );
+    
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapUsernameId,
+            iUserName );
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapPasswordId,
+            iPassword );
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapIncomingServerId,
+            iIncomingServerAddress );
+    
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapIncomingSecurityAuthId, 0 );
+    
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapIncomingSecurityProtocolId,
+            iIncomingSecurity );
+    
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapIncomingPortId,
+            iIncomingPort );
+    
+    iOutgoingServerAddress.ZeroTerminate();
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapOutgoingServerId,
+            iOutgoingServerAddress );
+    
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapOutgoingSecurityAuthId, 0 );
+
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapOutgoingSecurityProtocolId,
+            iOutgoingSecurity );
+    
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapOutgoingPortId,
+            iOutgoingPort );
+
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapAccessPointId,
+            iAccessPoint );
+    
+    error = repository->Set( 
+            CIpsSetWizardAdapter::ECRKPopImapMailboxName,
+            iMailboxName );
+    
+    
+    CMsvSession* msvSession = CMsvSession::OpenSyncL( *this );
+    CleanupStack::PushL( msvSession );
+    CIpsSetDataApi* dataApi = CIpsSetDataApi::NewL( *msvSession );    
+    CleanupStack::PushL( dataApi );
+    
+    error = dataApi->HandleMailboxCreation( TUid::Uid(iProtocol), *msvSession );
+    
+    CleanupStack::PopAndDestroy( 3, repository );
+    }
+// ----------------------------------------------------------
+// CTestAppAppUi::WriteSettingsViaImumL()
+// ----------------------------------------------------------
+// 
+void CTestAppAppUi::WriteSettingsViaImumL()
+    {
+    CImumDomainApi* api = CreateDomainApiLC(  );
+    MImumDaMailboxServices& services = api->MailboxServicesL();
+
+    CImumDaSettingsData* settings = services.CreateSettingsDataL( KNullUid );
+    CleanupStack::PushL( settings );
+
+    
+    settings->SetAttr( TImumDaSettings::EKeyEmailAddress, iEmailAddress );
+    settings->SetAttr( TImumDaSettings::EKeyMailboxName, iMailboxName ); 
+    settings->SetAttr( TImumDaSettings::EKeyUserAlias, iUserAlias );
+    
+    TUid protocolUid = KSenduiMtmImap4Uid;  
+    if ( TImumDaSettings::EValueProtocolPop3 == iProtocol )
+        {
+        protocolUid = KSenduiMtmPop3Uid;
+        }
+    MImumDaSettingsDataCollection& incoming = settings->AddSetL( protocolUid );
+
+    incoming.SetAttr( TImumDaSettings::EKeyProtocol , iProtocol );
+    incoming.SetAttr( TImumDaSettings::EKeyAccessPoint, iAccessPoint );
+    incoming.SetAttr( TImumDaSettings::EKeyServer, iIncomingServerAddress );
+    incoming.SetAttr( TImumDaSettings::EKeyUsername, iUserName );
+    incoming.SetAttr( TImumDaSettings::EKeyPassword, iPassword );
+    incoming.SetAttr( TImumDaSettings::EKeyPort, iIncomingPort );
+    incoming.SetAttr( TImumDaSettings::EKeySecurity, iIncomingSecurity  ); 
+   
+    MImumDaSettingsDataCollection& smtpSettings = settings->AddSetL( KSenduiMtmSmtpUid );
+
+    smtpSettings.SetAttr( TImumDaSettings::EKeyProtocol, TImumDaSettings::EValueProtocolSmtp );
+    smtpSettings.SetAttr( TImumDaSettings::EKeyAccessPoint, iAccessPoint );
+    smtpSettings.SetAttr( TImumDaSettings::EKeyServer, iOutgoingServerAddress );    
+    smtpSettings.SetAttr( TImumDaSettings::EKeySecurity, iOutgoingSecurity );           
+    smtpSettings.SetAttr( TImumDaSettings::EKeyPort, iOutgoingPort ); 
+    
+    TInt error( KErrNone ) ;              
+    // this leaves if incorrect settings
+    TRAP( error, iMailboxId = services.CreateMailboxL( *settings ) );   
+    
+    CleanupStack::PopAndDestroy( 2, api );
+    if ( error == KErrNone )
+        {
+        // creation is done, save id
+        SetRecentMsvIdL( iMailboxId ); 
+        }
+    else
+        {
+        User::Leave( error );
+        }
+        
+    }
+
+// ----------------------------------------------------------
+// CTestAppAppUi::ReadSettingsL()
+// ----------------------------------------------------------
+//        
+void CTestAppAppUi::ReadSettingsL( TInt aFileId )
+    {
+    TBuf<100> fileName( KIpsSosTestFilePath );
+    fileName.Append( KIpsSosTestFileName );
+    if ( KIpsSosTestDefaultFile != aFileId )
+        {
+        fileName.AppendNum( aFileId );
+        }
+    fileName.Append( KIpsSosTestFileExtension );
+    // open the RFs
+    RFs fileSession;
+    User::LeaveIfError( fileSession.Connect() );
+    CleanupClosePushL( fileSession );   // << fileSession
+
+    // open the RFileReadStream
+    RFileReadStream fileReader;
+    User::LeaveIfError( fileReader.Open( fileSession, fileName, EFileShareExclusive ) );
+    CleanupClosePushL( fileReader );    // << fileReader
+
+    TBuf8<200> lineBuffer;
+    TChar delim( KIpsSosTestLineFeed );
+
+    TInt error( KErrNone );
+    while ( KErrNone == error ) // Expected KErrEof
+        {
+        TRAP( error, fileReader.ReadL( lineBuffer, delim ) );
+        TInt length = lineBuffer.Length();
+        if ( length )
+            {
+            // remove line feed
+            lineBuffer.Delete( length - KIpsSosTestDelimeterSize, KIpsSosTestDelimeterSize );
+            // remove spaces
+            lineBuffer.TrimAll();
+            // ignore comment lines
+            TInt comment = lineBuffer.FindF( KIpsSosTestIniCommentLine );
+            if ( KErrNotFound == comment )
+                {
+                // find keys & values
+                TInt separator = lineBuffer.FindF( KIpsSosTestIniSeparator );
+                if ( KErrNotFound != separator  )
+                    {
+                    TPtrC8 key( KNullDesC8 );
+                    TPtrC8 value( KNullDesC8 );
+                    key.Set( lineBuffer.Left( separator ) );
+                    TInt valueStart( separator );
+                    valueStart += KIpsSosTestIniSeparator().Length();
+                    value.Set( lineBuffer.Mid( valueStart ) );
+
+                    HBufC* value16 = HBufC::NewLC( value.Length() );
+                    value16->Des().Copy( value );
+                    // protocol
+                    if ( !key.CompareF( KIpsSosTestProtocol ) )
+                        {
+                        if ( !value.CompareF( KIpsSosTestPOP ) )
+                            {
+                            iProtocol = KSenduiMtmImap4UidValue;
+                            }
+                        else
+                            {
+                            iProtocol = KSenduiMtmPop3UidValue; 
+                            }
+                        }
+                    // mailbox name
+                    else if ( !key.CompareF( KIpsSosTestMailboxName ) )
+                        {
+                        iMailboxName = value16->Des();
+                        }
+                    // email address
+                    else if ( !key.CompareF( KIpsSosTestEmailAddress ) )
+                        {
+                        iEmailAddress =  value16->Des();
+                        }
+                    // user name
+                    else if ( !key.CompareF( KIpsSosTestUserName ) )
+                        {
+                        iUserName = value16->Des();
+                        }
+                    // password
+                    else if ( !key.CompareF( KIpsSosTestPassword ) )
+                        {
+                        iPassword = value16->Des();
+                        }
+                   // alias
+                   else if ( !key.CompareF( KIpsSosTestUserAlias ) )
+                        {
+                        iUserAlias =  value16->Des();
+                        }
+                    // signature
+                    else if ( !key.CompareF( KIpsSosTestSignature ) )
+                        {
+                        iSignature =  value16->Des();
+                        }
+                    // folder path
+                    else if ( !key.CompareF( KIpsSosTestFolderPath ) )
+                        {
+                        iFolderPath = value16->Des();
+                        }
+                    // access point
+                    else if ( !key.CompareF( KIpsSosTestAccessPoint ) )
+                        {
+                        if ( !value.CompareF( KIpsSosTestAPAlwaysAsk) )
+                            {
+                             
+                            iAccessPoint = _L(""); 
+                            }
+                        else
+                            {
+                            iAccessPoint = value16->Des(); 
+                            }
+                        }
+                    // incoming server
+                    else if ( !key.CompareF( KIpsSosTestIncomingServerAddress ) )
+                        {
+                        iIncomingServerAddress = value16->Des();
+                        } 
+                    // incoming port                       
+                    else if ( !key.CompareF( KIpsSosTestIncomingPort ) )
+                        {
+                        if ( !value.CompareF( KIpsSosTestPortValueDefault ) )
+                            {
+                            iIncomingPort = KIpsSosTestPortDefault; 
+                            }
+                        else
+                            {
+                            TLex8 lex( value );
+                            TInt port = 0;
+                            TInt error = lex.Val( port );
+                            iIncomingPort = port; 
+                            }
+                        } 
+                    // incoming security
+                    else if ( !key.CompareF( KIpsSosTestIncomingSecurity ) )
+                        {
+                        if ( !value.CompareF( KIpsSosTestSecurityTls ) )
+                            {
+                            iIncomingSecurity  = KTestAppWizardDataSecurityTLS;
+                            }
+                        else if ( !value.CompareF( KIpsSosTestSecuritySsl ) )
+                            {
+                            iIncomingSecurity  = KTestAppWizardDataSecuritySSL;
+                            }
+                        else 
+                            {
+                            iIncomingSecurity  = KTestAppWizardDataSecurityOff;
+                            }
+                        } 
+                    // outgoing server
+                    else if ( !key.CompareF( KIpsSosTestOutgoingServerAddress ) )
+                        {
+                        iOutgoingServerAddress =  value16->Des();
+                        } 
+                    // outgoing port
+                    else if ( !key.CompareF( KIpsSosTestOutgoingPort ) )
+                        {
+                        if ( !value.CompareF( KIpsSosTestPortValueDefault) )
+                            {
+                            iOutgoingPort = KIpsSosTestPortDefault;
+                            }
+                        else
+                            {
+                            TLex8 lex( value );
+                            TInt port = 0;
+                            TInt error = lex.Val( port );
+                            iOutgoingPort = port; 
+                            }
+                        } 
+                    // outgoing security
+                    else if ( !key.CompareF( KIpsSosTestOutgoingSecurity ) )
+                        {
+                        if ( !value.CompareF( KIpsSosTestSecurityTls ) )
+                            {
+                            iOutgoingSecurity  = KTestAppWizardDataSecurityTLS;
+                            }
+                        else if ( !value.CompareF( KIpsSosTestSecuritySsl ) )
+                            {
+                            iOutgoingSecurity  = KTestAppWizardDataSecuritySSL;
+                            }
+                        else 
+                            {
+                            iOutgoingSecurity  = KTestAppWizardDataSecurityOff;
+                            }
+                        }
+                    else
+                        {
+                        ShowNoteL( KIpsSosTestUnknownValue );
+                        }
+                    CleanupStack::PopAndDestroy( value16 );
+                    }
+                }
+            }
+        }
+        
+    // close the RFileReadStream
+    CleanupStack::PopAndDestroy( &fileReader );     // >>> fileReader
+
+    // close the RFs
+    CleanupStack::PopAndDestroy( &fileSession );    // >>> fileSession
+
+    } 
+    
+// ----------------------------------------------------------
+// CTestAppAppUi::ShowNoteL()
+// ----------------------------------------------------------
+//    
+void CTestAppAppUi::ShowNoteL( const TDesC& aMessage )
+    {
+    CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
+    informationNote->ExecuteLD( aMessage );
+    }
+
+// ----------------------------------------------------------
+// CTestAppAppUi::DeleteAllSettingsL()
+// ----------------------------------------------------------
+//            
+void CTestAppAppUi::DeleteAllSettingsL( )
+    {
+    TInt error( KErrNone );
+    CEmailAccounts* accounts = CEmailAccounts::NewLC();
+    // imap
+    RArray<TImapAccount> imapArray;
+    CleanupClosePushL( imapArray );
+    accounts->GetImapAccountsL( imapArray );
+    for ( TInt mailbox(0); mailbox < imapArray.Count(); mailbox++ )
+        {
+        TImapAccount imap = imapArray[mailbox];
+        TRAP( error, accounts->DeleteImapAccountL( imap ) );
+        }
+    CleanupStack::PopAndDestroy( &imapArray );
+    // pop
+    RArray<TPopAccount> popArray;
+    CleanupClosePushL( popArray );
+    accounts->GetPopAccountsL( popArray );
+    
+    for ( TInt mailbox(0); mailbox < popArray.Count(); mailbox++ )
+        {
+        TPopAccount pop = popArray[mailbox];;
+        TRAP( error, accounts->DeletePopAccountL( pop ) );
+        }
+    CleanupStack::PopAndDestroy( &popArray );
+    // smtp
+    RArray<TSmtpAccount> smtpArray;
+    accounts->GetSmtpAccountsL( smtpArray );
+    CleanupClosePushL( smtpArray );
+    
+    for ( TInt mailbox(0); mailbox < smtpArray.Count(); mailbox++ )
+        {
+        TSmtpAccount smtp = smtpArray[mailbox];
+        TRAP( error, accounts->DeleteSmtpAccountL( smtp ) );
+        }
+    CleanupStack::PopAndDestroy( &smtpArray );
+    
+    CleanupStack::PopAndDestroy( accounts );
+    }
+    
+// ----------------------------------------------------------
+// CTestAppAppUi::ConstructL()
+// ----------------------------------------------------------
+//
+void CTestAppAppUi::ConstructL()
+    {
+    BaseConstructL( EAknEnableSkin );
+    iAppContainer = new (ELeave) CTestAppContainer;
+    iAppContainer->SetMopParent( this );
+    iAppContainer->ConstructL( ClientRect() );
+    AddToStackL( iAppContainer );
+    }
+
+// ----------------------------------------------------
+// CTestAppAppUi::~CTestAppAppUi()
+// Destructor
+// Frees reserved resources
+// ----------------------------------------------------
+//
+CTestAppAppUi::~CTestAppAppUi()
+    {
+    if ( iAppContainer )
+        {
+        RemoveFromStack( iAppContainer );
+        delete iAppContainer;
+        }
+    }
+
+// ------------------------------------------------------------------------------
+// CTestAppAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
+//  This function is called by the EIKON framework just before it displays
+//  a menu pane. Its default implementation is empty, and by overriding it,
+//  the application can set the state of menu items dynamically according
+//  to the state of application data.
+// ------------------------------------------------------------------------------
+//
+void CTestAppAppUi::DynInitMenuPaneL(
+    TInt aResourceId, CEikMenuPane* /*aMenuPane*/ )
+    {
+    switch( aResourceId )
+        {
+        case R_TESTAPP_MENU:
+            {            
+            break;
+            }
+        default:
+            {
+            break;
+            }
+        }
+    }
+
+// ----------------------------------------------------
+// CTestAppAppUi::HandleKeyEventL(
+//     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
+// ----------------------------------------------------
+//
+TKeyResponse CTestAppAppUi::HandleKeyEventL(
+    const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
+    {
+    return EKeyWasNotConsumed;
+    }
+
+// ----------------------------------------------------
+// CTestAppAppUi::HandleCommandL(TInt aCommand)
+// ----------------------------------------------------
+//
+void CTestAppAppUi::HandleCommandL(TInt aCommand)
+    {
+    switch ( aCommand )
+        {
+        case EAknSoftkeyExit:
+        case EEikCmdExit:
+            {
+            Exit();
+            break;
+            }
+        case ETest1Cmd:
+            {
+            // read settings
+            TInt error( KErrNone );
+            TRAP( error, ReadSettingsL( KIpsSosTestDefaultFile ) );
+            if ( KErrNone != error )
+                {
+                if ( KErrNotFound == error )
+                    {
+                    ShowNoteL( KIpsSosTestFileNotFound );
+                    }
+                else
+                    {
+                    ShowNoteL( KIpsSosTestErrorInReading );
+                    }
+                return;
+                }
+            // write settings
+            TRAP( error, WriteSettingsToWizardCenRepL() );
+            if ( KErrNone != error )
+                {
+                ShowNoteL( KIpsSosTestErrorInWriting );
+                }
+            else
+                {
+                ShowNoteL( KIpsSosTestSettingsCreated );
+                }
+            break;
+            }   
+        case ETest2Cmd:
+            {
+            // query
+            TInt queryValue( KErrNotFound );
+            CAknNumberQueryDialog* dlg = CAknNumberQueryDialog::NewL( queryValue, CAknQueryDialog::ENoTone );
+            dlg->PrepareLC( R_NUMBER_QUERY_DIALOG );
+            dlg->SetPromptL( _L("Give init file id") );
+            TInt ret = dlg->RunLD();
+            TInt error( KErrNone );
+            // read settings
+            TRAP( error, ReadSettingsL( queryValue ) );
+            if ( KErrNone != error )
+                {
+                if ( KErrNotFound == error )
+                    {
+                    ShowNoteL( KIpsSosTestFileNotFound );
+                    }
+                else
+                    {
+                    ShowNoteL( KIpsSosTestErrorInReading );
+                    }
+                return;
+                }
+            // write settings
+            TRAP( error, WriteSettingsToWizardCenRepL() );
+            if ( KErrNone != error )
+                {
+                ShowNoteL( KIpsSosTestErrorInWriting );
+                return;
+                }
+            // launch plugin
+            TRAP( error, LaunchPluginL() ); 
+            if ( KErrNone != error )
+                {
+                ShowNoteL( KIpsSosTestErrorLaunching );
+                }     
+            break;
+            }
+        case ETest3Cmd:
+            {
+            TMsvId recent = RecentMsvId(); 
+            if ( KErrNotFound != recent )  
+                {
+                iMailboxId = recent;
+                // launch plugin
+                TInt error( KErrNone );
+                TRAP( error, LaunchPluginL() ); 
+                if ( KErrNone != error )
+                    {
+                    ShowNoteL( KIpsSosTestErrorLaunching );
+                    }  
+                }
+            else
+                {
+                ShowNoteL( KIpsSosTestRecentNotFound );
+                }
+            break;
+            }
+        
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+    }
+    
+// ----------------------------------------------------------
+// CTestAppAppUi::SetRecentMsvIdL()
+// ----------------------------------------------------------
+//   
+void CTestAppAppUi::SetRecentMsvIdL( TMsvId aMsvId )
+    {
+    // define integer-type property
+    TInt err = RProperty::Define( KIpsSosTestPropertyCat, EIpsSosTestRecentMsvId, RProperty::EInt );
+    if ( KErrAlreadyExists != err && KErrNone != err )
+        {
+        User::Leave( err );
+        }
+    // publish property using category and key
+    err = RProperty::Set( KIpsSosTestPropertyCat, EIpsSosTestRecentMsvId, aMsvId );
+    }
+
+// ----------------------------------------------------------
+// CTestAppAppUi::RecentMsvId()
+// ----------------------------------------------------------
+//    
+TMsvId CTestAppAppUi::RecentMsvId(  )
+    {
+    TInt recent( KErrNotFound );
+    // get property using category and key
+    TInt err = RProperty::Get( KIpsSosTestPropertyCat, EIpsSosTestRecentMsvId, recent );
+    return recent;
+    }
+    
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/src/TESTAPPContainer.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,131 @@
+/*
+* ============================================================================
+*  Name     : CTestAppContainer from TestAppContainer.h
+*  Part of  : TestApp
+*  Created  : 08.10.2004 by Jalemine
+*  Implementation notes:
+*     Initial content was generated by Series 60 AppWizard.
+*  Version  :
+*  Copyright: Digia
+* ============================================================================
+*/
+
+// INCLUDE FILES
+#include "TestAppContainer.h"
+#include <aknlists.h>
+#include <AknsUtils.h>
+#include <AppLayout.cdl.h>
+#include <AknIconUtils.h>
+#include <AknsConstants.h>
+#include <AknsDrawUtils.h>
+#include <AknsBasicBackgroundControlContext.h>
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CTestAppContainer::ConstructL(const TRect& aRect)
+// EPOC two phased constructor
+// ---------------------------------------------------------
+//
+void CTestAppContainer::ConstructL(const TRect& aRect)
+    {
+    CreateWindowL(); 
+
+    // Get the skin instance
+	iSkinInstance = AknsUtils::SkinInstance();
+
+	// Create background control context for skinning the background
+	iBackgroundSkinContext = CAknsBasicBackgroundControlContext::NewL( 
+			KAknsIIDSkinBmpMainPaneUsual, aRect, ETrue );
+    
+    iListBox = new (ELeave) CEikTextListBox;
+    iListBox->SetContainerWindowL( *this );
+    iListBox->ConstructL( this );
+
+    iItems = new( ELeave )CDesCArrayFlat( 4 );
+    iListBox->Model()->SetItemTextArray( iItems );
+    iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    iListBox->SetMopParent( this );
+
+    SetRect(aRect);
+    ActivateL();
+    }
+
+// Destructor
+CTestAppContainer::~CTestAppContainer()
+    {
+    delete iListBox;    
+    delete iBackgroundSkinContext;
+    }
+
+// ---------------------------------------------------------
+// CTestAppContainer::SizeChanged()
+// Called by framework when the view size is changed
+// ---------------------------------------------------------
+//
+void CTestAppContainer::SizeChanged()
+    {
+    iListBox->SetRect( Rect() );
+    }
+
+// ---------------------------------------------------------
+// CTestAppContainer::CountComponentControls() const
+// ---------------------------------------------------------
+//
+TInt CTestAppContainer::CountComponentControls() const
+    {
+    return 1; 
+    }
+
+// ---------------------------------------------------------
+// CTestAppContainer::AppendData
+// ---------------------------------------------------------
+//
+void CTestAppContainer::AppendDataL( TDesC& buf )
+    {
+    iItems->AppendL( buf );
+    iListBox->HandleItemAdditionL();
+    TInt focus = iItems->Count()-1;
+    if ( focus < 0 )
+        focus=0;
+    iListBox->SetCurrentItemIndexAndDraw( focus );
+    }
+
+// ---------------------------------------------------------
+// CTestAppContainer::ComponentControl(TInt aIndex) const
+// ---------------------------------------------------------
+//
+CCoeControl* CTestAppContainer::ComponentControl(TInt aIndex) const
+    {
+    switch ( aIndex )
+        {
+        case 0:
+            return iListBox;
+        default:
+            return NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// CTestAppContainer::Draw(const TRect& aRect) const
+// ---------------------------------------------------------
+//
+void CTestAppContainer::Draw(const TRect& /*aRect*/) const
+    {
+    CWindowGc& gc = SystemGc();
+	
+    AknsDrawUtils::Background( iSkinInstance, 
+        iBackgroundSkinContext, this, gc, Rect() );
+    }
+
+// ---------------------------------------------------------
+// CTestAppContainer::HandleControlEventL(
+//     CCoeControl* aControl,TCoeEvent aEventType)
+// ---------------------------------------------------------
+//
+void CTestAppContainer::HandleControlEventL(
+    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
+    {
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssossettings/tsrc/IpsSosTestApp/src/TESTAPPDocument.cpp	Mon Jan 18 20:08:26 2010 +0200
@@ -0,0 +1,52 @@
+/*
+* ============================================================================
+*  Name     : CTestAppDocument from TestAppDocument.h
+*  Part of  : TestApp
+* ============================================================================
+*/
+
+// INCLUDE FILES
+#include "TestAppDocument.h"
+#include "TestAppAppUi.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// constructor
+CTestAppDocument::CTestAppDocument(CEikApplication& aApp)
+: CAknDocument(aApp)    
+    {
+    }
+
+// destructor
+CTestAppDocument::~CTestAppDocument()
+    {
+    }
+
+// EPOC default constructor can leave.
+void CTestAppDocument::ConstructL()
+    {
+    }
+
+// Two-phased constructor.
+CTestAppDocument* CTestAppDocument::NewL(
+        CEikApplication& aApp)     // CTestAppApp reference
+    {
+    CTestAppDocument* self = new (ELeave) CTestAppDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+    
+// ----------------------------------------------------
+// CTestAppDocument::CreateAppUiL()
+// constructs CTestAppAppUi
+// ----------------------------------------------------
+//
+CEikAppUi* CTestAppDocument::CreateAppUiL()
+    {
+    return new (ELeave) CTestAppAppUi;
+    }
+
+// End of File