Revision: 200951
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 07 Jan 2010 12:38:38 +0200
changeset 1 12c456ceeff2
parent 0 8466d47a6819
child 2 5253a20d2a1e
Revision: 200951 Kit: 201001
emailcontacts/contactactionservice/data/FscActionUtils.rss
emailservices/emailclientapi/inc/emailclientapiimpl.hrh
emailservices/emailframework/commonlib/inc/CFSMailCommon.h
emailservices/emailframework/commonlib/src/CFSMailPluginData.cpp
emailservices/emailframework/data/microsoft.svg
emailservices/emailframework/data/yahoo.svg
emailservices/emailframework/inc/emailversionnumbers.hrh
emailservices/emailserver/cmailhandlerplugin/group/cmailhandlerplugin.mmp
emailservices/emailserver/cmailhandlerplugin/inc/cmailcpsifconsts.h
emailservices/emailserver/cmailhandlerplugin/inc/cmailcpssettings.h
emailservices/emailserver/cmailhandlerplugin/inc/cmailwidgetcenrepkeys.h
emailservices/emailserver/cmailhandlerplugin/rom/cmailhandlerpluginresources.iby
emailservices/emailserver/cmailhandlerplugin/src/cmailcpshandler.cpp
emailservices/emailserver/cmailhandlerplugin/src/cmailcpsif.cpp
emailservices/emailserver/cmailhandlerplugin/src/cmailcpssettings.cpp
emailservices/emailserver/src/fsmailserver.cpp
emailservices/emailservermonitor/src/emailshutter.cpp
emailservices/emailstore/message_store/MsgStoreRfsPlugin/group/RfsMsgStorePlugin.mmp
emailservices/emailstore/message_store/MsgStoreRfsPlugin/inc/RfsMsgStorePlugin.h
emailservices/emailstore/message_store/MsgStoreRfsPlugin/src/RfsMsgStorePlugin.cpp
emailservices/emailstore/tsrc/bufferedmsgcreator_test/bwins/t_msgstoreu.def
emailservices/emailstore/tsrc/bufferedmsgcreator_test/group/bld.inf
emailservices/emailstore/tsrc/bufferedmsgcreator_test/group/t_bufferedmsgcreator.mmp
emailservices/emailstore/tsrc/bufferedmsgcreator_test/inc/containerstore.h
emailservices/emailstore/tsrc/bufferedmsgcreator_test/inc/containerstorecontentmanager.h
emailservices/emailstore/tsrc/bufferedmsgcreator_test/inc/containerstoreutils.h
emailservices/emailstore/tsrc/bufferedmsgcreator_test/inc/t_bufferedmsgcreatore.h
emailservices/emailstore/tsrc/bufferedmsgcreator_test/src/mockups.cpp
emailservices/emailstore/tsrc/bufferedmsgcreator_test/src/t_bufferedmsgcreator.cpp
emailservices/emailstore/tsrc/bufferedmsgcreator_test/src/t_bufferedmsgcreatorcases.cpp
emailservices/emailstore/tsrc/message_store_test/Bmarm/t_msgstoreU.DEF
emailservices/emailstore/tsrc/message_store_test/Bwins/t_msgstoreU.DEF
emailservices/emailstore/tsrc/message_store_test/EABI/t_msgstoreU.def
emailservices/emailstore/tsrc/message_store_test/group/bld.inf
emailservices/emailstore/tsrc/message_store_test/group/ctc_postprocess.bat
emailservices/emailstore/tsrc/message_store_test/group/ctc_preprocess.bat
emailservices/emailstore/tsrc/message_store_test/group/run_coverage_test.bat
emailservices/emailstore/tsrc/message_store_test/group/run_unit_tests.bat
emailservices/emailstore/tsrc/message_store_test/group/t_msgstore.mmp
emailservices/emailstore/tsrc/message_store_test/group/t_msgstore.pkg
emailservices/emailstore/tsrc/message_store_test/group/t_msgstore_DoxyFile.txt
emailservices/emailstore/tsrc/message_store_test/group/t_msgstore_nrm.mmp
emailservices/emailstore/tsrc/message_store_test/inc/AsyncTestCaseBase.h
emailservices/emailstore/tsrc/message_store_test/inc/ContentTests.h
emailservices/emailstore/tsrc/message_store_test/inc/DbCorruptTests.h
emailservices/emailstore/tsrc/message_store_test/inc/EncryptionTests.h
emailservices/emailstore/tsrc/message_store_test/inc/FolderTests.h
emailservices/emailstore/tsrc/message_store_test/inc/MailboxTests.h
emailservices/emailstore/tsrc/message_store_test/inc/MessageTests.h
emailservices/emailstore/tsrc/message_store_test/inc/MruTests.h
emailservices/emailstore/tsrc/message_store_test/inc/ObserverTests.h
emailservices/emailstore/tsrc/message_store_test/inc/PartTests.h
emailservices/emailstore/tsrc/message_store_test/inc/PropertyTests.h
emailservices/emailstore/tsrc/message_store_test/inc/SearchTests.h
emailservices/emailstore/tsrc/message_store_test/inc/ShutdownServerTest.h
emailservices/emailstore/tsrc/message_store_test/inc/SizeTests.h
emailservices/emailstore/tsrc/message_store_test/inc/SortTests.h
emailservices/emailstore/tsrc/message_store_test/inc/t_msgstore.h
emailservices/emailstore/tsrc/message_store_test/src/AsyncTestCaseBase.cpp
emailservices/emailstore/tsrc/message_store_test/src/ContentTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/DbCorruptTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/EncryptionTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/FolderTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/MailboxTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/MessageTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/MruTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/ObserverTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/PartTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/PropertyTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/SearchTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/ShutdownServerTest.cpp
emailservices/emailstore/tsrc/message_store_test/src/SizeTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/SortTests.cpp
emailservices/emailstore/tsrc/message_store_test/src/t_msgstore.cpp
emailservices/emailstore/tsrc/message_store_test/src/t_msgstoreCases.cpp
emailuis/emailui/data/FreestyleEmailUi.rss
emailuis/emailui/data/html/email.html
emailuis/emailui/data/html/header.js
emailuis/emailui/data/iconlist.txt
emailuis/emailui/group/FreestyleEmailUiIcons.mk
emailuis/emailui/inc/FSComposerFetchLogic.h
emailuis/emailui/inc/FreestyleEmailUi.hrh
emailuis/emailui/inc/FreestyleEmailUiAppui.h
emailuis/emailui/inc/FreestyleEmailUiFolderListVisualiser.h
emailuis/emailui/inc/FreestyleEmailUiHtmlViewerContainer.h
emailuis/emailui/inc/FreestyleEmailUiHtmlViewerView.h
emailuis/emailui/inc/FreestyleEmailUiLauncherGridVisualiser.h
emailuis/emailui/inc/FreestyleEmailUiLayoutData.h
emailuis/emailui/inc/FreestyleEmailUiLayoutHandler.h
emailuis/emailui/inc/FreestyleEmailUiMailListVisualiser.h
emailuis/emailui/inc/FreestyleEmailUiMsgDetailsVisualiser.h
emailuis/emailui/inc/FreestyleEmailUiSearchListVisualiser.h
emailuis/emailui/inc/FreestyleEmailUiTextureManager.h
emailuis/emailui/inc/FreestyleEmailUiViewBase.h
emailuis/emailui/inc/FreestyleMessageHeaderHTML.h
emailuis/emailui/inc/freestyleemailuimailboxdeleter.h
emailuis/emailui/inc/ncsaifeditor.h
emailuis/emailui/inc/ncscomposeview.h
emailuis/emailui/inc/ncseditor.h
emailuis/emailui/loc/freestyleemailui.loc
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/src/FSComposerFetchLogic.cpp
emailuis/emailui/src/FreestyleEmailDownloadInformationMediator.cpp
emailuis/emailui/src/FreestyleEmailUiAppui.cpp
emailuis/emailui/src/FreestyleEmailUiFolderListVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiHtmlViewerContainer.cpp
emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp
emailuis/emailui/src/FreestyleEmailUiLauncherGridVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiLayoutHandler.cpp
emailuis/emailui/src/FreestyleEmailUiMailListModel.cpp
emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiMailViewerRichText.cpp
emailuis/emailui/src/FreestyleEmailUiMsgDetailsVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiSearchListVisualiser.cpp
emailuis/emailui/src/FreestyleEmailUiSettingsList.cpp
emailuis/emailui/src/FreestyleEmailUiTextureManager.cpp
emailuis/emailui/src/FreestyleEmailUiUtilities.cpp
emailuis/emailui/src/FreestyleEmailUiViewBase.cpp
emailuis/emailui/src/FreestyleMessageHeaderHTML.cpp
emailuis/emailui/src/FreestyleMessageHeaderURLEventHandler.cpp
emailuis/emailui/src/freestyleemailuimailboxdeleter.cpp
emailuis/emailui/src/ncsaddressinputfield.cpp
emailuis/emailui/src/ncsaifeditor.cpp
emailuis/emailui/src/ncscomposeview.cpp
emailuis/emailui/src/ncscomposeviewcontainer.cpp
emailuis/emailui/src/ncseditor.cpp
emailuis/emailui/src/ncsheadercontainer.cpp
emailuis/emailui/src/ncssubjectfield.cpp
emailuis/uicomponents/inc/fscontrolbar.h
emailuis/uicomponents/inc/fscontrolbarmodel.h
emailuis/uicomponents/inc/fscontrolbarobserver.h
emailuis/uicomponents/inc/fscontrolbarvisualiser.h
emailuis/uicomponents/inc/fscontrolbuttonobserver.h
emailuis/uicomponents/inc/fscontrolbuttonvisualiser.h
emailuis/uicomponents/inc/fstreelistobserver.h
emailuis/uicomponents/inc/fstreevisualizerobserver.h
emailuis/uicomponents/src/fscontrolbar.cpp
emailuis/uicomponents/src/fscontrolbarmodel.cpp
emailuis/uicomponents/src/fscontrolbarvisualiser.cpp
emailuis/uicomponents/src/fscontrolbutton.cpp
emailuis/uicomponents/src/fscontrolbuttonvisualiser.cpp
emailuis/uicomponents/src/fstextviewerselectsmanager.cpp
emailuis/uicomponents/src/fstreelist.cpp
emailuis/uicomponents/src/fstreenodevisualizerbase.cpp
emailuis/uicomponents/src/fstreeplainonelineitemvisualizer.cpp
emailuis/uicomponents/src/fstreeplainonelinenodevisualizer.cpp
emailuis/uicomponents/src/fstreeplaintwolineitemvisualizer.cpp
emailuis/uicomponents/src/fstreevisualizerbase.cpp
emailuis/widget/emailwidgetsettings/conf/cmailwidget.confml
emailuis/widget/emailwidgetsettings/conf/cmailwidget_2001E272.crml
emailuis/widget/emailwidgetsettings/data/emailwidgetsettings.rss
emailuis/widget/emailwidgetsettings/data/iconlist.txt
emailuis/widget/emailwidgetsettings/group/bld.inf
emailuis/widget/emailwidgetsettings/group/emailwidgetsettings.mmp
emailuis/widget/emailwidgetsettings/inc/emailwidgetsettingslistview.h
emailuis/widget/emailwidgetsettings/inc/emailwidgetsettingsmailboxes.h
emailuis/widget/emailwidgetsettings/rom/emailwidgetsettings.iby
emailuis/widget/emailwidgetsettings/src/emailwidgetsettingslistviewcontainer.cpp
emailuis/widget/emailwidgetsettings/src/emailwidgetsettingsmailboxes.cpp
emailuis/widget/group/bld.inf
emailuis/widget/hsps/00/emailwidgetconfiguration.dtd
emailuis/widget/hsps/00/manifest.dat
emailuis/widget/loc/emailwidgetconfiguration.loc
emailuis/widget/rom/emailwidget_resources.iby
ipsservices/ipssosplugin/inc/ipsplgimap4moveremoteop.h
ipsservices/ipssosplugin/src/ipsplgimap4moveremoteop.cpp
ipsservices/ipssosplugin/src/ipsplgimap4plugin.cpp
ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp
ipsservices/ipssosplugin/src/ipsplgsearch.cpp
ipsservices/ipssossettings/src/ipssetui.cpp
ipsservices/ipssossettings/src/ipssetuifinder.cpp
meetingrequest/mrentry/inc/cesmrmeetingrequestentry.h
meetingrequest/mrentry/src/cesmrentryprocessor.cpp
meetingrequest/mrentry/src/cesmrmeetingrequestentry.cpp
meetingrequest/mrgui/data/esmrgui.rss
meetingrequest/mrgui/inc/mesmrlocationplugin.h
meetingrequest/mrgui/mrfieldbuilderplugin/inc/cesmrviewerdescriptionfield.h
meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrviewerdescriptionfield.cpp
meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrviewerattachmentsfield.cpp
meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrviewerattendeesfield.cpp
meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrviewerfromfield.cpp
meetingrequest/mrgui/mrlocationplugin/inc/cesmrlocationpluginimpl.h
meetingrequest/mrgui/mrlocationplugin/src/cesmrlocationpluginimpl.cpp
meetingrequest/mrgui/src/cesmrcontactmenuurlhandler.cpp
meetingrequest/mrgui/src/cesmreditordialog.cpp
meetingrequest/mrgui/src/cesmrlocationpluginhandler.cpp
meetingrequest/mrgui/src/cesmrmeetingtimevalidator.cpp
--- a/emailcontacts/contactactionservice/data/FscActionUtils.rss	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailcontacts/contactactionservice/data/FscActionUtils.rss	Thu Jan 07 12:38:38 2010 +0200
@@ -376,6 +376,15 @@
                 EVPbkVersitParamVOIP
                 };
             extensionName = "X-SIP";
+            },
+        VBK_FIELD_VERSIT_PROPERTY
+            {
+            name = EVPbkVersitNameX;
+            extensionName = "X-SIP";
+            },
+        VBK_FIELD_VERSIT_PROPERTY		
+            {
+            name = EVPbkVersitNameTEL;
             }
         };
     }
--- a/emailservices/emailclientapi/inc/emailclientapiimpl.hrh	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailclientapi/inc/emailclientapiimpl.hrh	Thu Jan 07 12:38:38 2010 +0200
@@ -24,4 +24,4 @@
 
 #endif // _EMAILCLIENTAPIIMPL_HRH
 
-// End of file.
\ No newline at end of file
+// End of file.
--- a/emailservices/emailframework/commonlib/inc/CFSMailCommon.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailframework/commonlib/inc/CFSMailCommon.h	Thu Jan 07 12:38:38 2010 +0200
@@ -240,11 +240,11 @@
     public:
 
     inline TFSMailMsgId( ) // constructs NULL id
-    { iPluginId.iUid = 0; iId = 0; iNullId = ETrue; };
+    { iPluginId.iUid = 0; iId = 0; iNullId = ETrue; iSeparator = EFalse; };
     inline TFSMailMsgId(TUid aPluginId, TUint aId)
-    { iPluginId = aPluginId; iId = aId; iNullId = EFalse; };
+    { iPluginId = aPluginId; iId = aId; iNullId = EFalse; iSeparator = EFalse; };
     inline TFSMailMsgId(TUint aPluginId, TUint aId)
-    { iPluginId.iUid = aPluginId; iId = aId; iNullId = EFalse; };
+    { iPluginId.iUid = aPluginId; iId = aId; iNullId = EFalse; iSeparator = EFalse; };
     inline TBool operator==(TFSMailMsgId aId) const
     { if(iNullId != aId.IsNullId()) return EFalse;
       if(iPluginId.iUid != aId.PluginId().iUid) return EFalse;
@@ -259,12 +259,14 @@
     inline TUint Id() const { return iId; };
     inline void  SetPluginId(TUid aPluginId) { iPluginId = aPluginId; iNullId = EFalse; };
     inline void  SetId(TUint aId) { iId = aId; iNullId = EFalse; };
-
+    inline void SetSeparator( TBool aSeparator ) { iSeparator = aSeparator; }
+    inline TBool IsSeparator() const { return iSeparator; }
     protected:
 
     TBool   iNullId;
     TUid    iPluginId;      // ecom implementation id
     TUint   iId;            // message, folder, mailbox id
+    TBool   iSeparator;     // if object is separator
     };
 
 /* Predefined constants for ContentTypes and parameters for ContentType and ContentDisposition */
--- a/emailservices/emailframework/commonlib/src/CFSMailPluginData.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailframework/commonlib/src/CFSMailPluginData.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -37,6 +37,7 @@
 	if(iPlugin)
 		{
 		delete iPlugin;
+		iPlugin = NULL;
 		CFSMailPlugin::Close();
 		}
 }
--- a/emailservices/emailframework/data/microsoft.svg	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailframework/data/microsoft.svg	Thu Jan 07 12:38:38 2010 +0200
@@ -1,82 +1,429 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="44" height="44" viewBox="105.585 74.074 44 44">
-<rect fill="none" height="44" width="44" x="105.585" y="74.074"/>
-<linearGradient id="SVGID_2" gradientUnits="userSpaceOnUse" x1="117.14" y1="94.11" x2="146.99" y2="94.11">
-<stop stop-color="#A5D288" offset="0"/>
-<stop stop-color="#A2D085" offset="0.27"/>
-<stop stop-color="#9BCA7D" offset="0.48"/>
-<stop stop-color="#8EC06F" offset="0.68"/>
-<stop stop-color="#7EB55D" offset="0.87"/>
-<stop stop-color="#6EAA4F" offset="1"/>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24">
+<rect fill="none" height="24" width="24"/>
+<path fill="#FFFFFF" d="M20.024,19.734c0,0.297-0.238,0.489-0.497,0.489c-0.262,0-0.49-0.185-0.49-0.483c0-0.258,0.197-0.491,0.494-0.491C19.797,19.249,20.024,19.439,20.024,19.734z M19.964,19.738c0-0.248-0.188-0.435-0.433-0.435c-0.252,0-0.438,0.187-0.438,0.435c0,0.252,0.205,0.438,0.438,0.438C19.783,20.176,19.964,19.975,19.964,19.738z M19.769,20.045h-0.106l-0.069-0.151c-0.033-0.074-0.07-0.112-0.11-0.112h-0.06v0.264h-0.088v-0.626h0.177c0.119,0,0.229,0.044,0.229,0.171c0,0.074-0.05,0.146-0.158,0.171v0.002c0.033,0.009,0.07,0.048,0.104,0.117L19.769,20.045z M19.647,19.6c0-0.066-0.034-0.106-0.145-0.106h-0.079v0.213h0.094C19.604,19.706,19.647,19.672,19.647,19.6z"/>
+<radialGradient id="SVGID_1" gradientUnits="userSpaceOnUse" cx="12.33" cy="13.53" r="9.43">
+<stop stop-color="#FFFFFF" offset="0.25"/>
+<stop stop-color="#000000" offset="1"/>
+</radialGradient>
+<path opacity="0.2" fill="url(#SVGID_1)" enable-background="new " d="M3.988,12.398c-0.017,0.01-0.026,0.008-0.038,0.04l-1.926,6.53c-0.011,0.033,0.008,0.068,0.031,0.09c0,0,0.131,0.096,0.133,0.097c0.041,0.028,0.065,0.019,0.078,0.017c3.298-1.234,5.002-0.924,7.124,0.389l0.004,0.006l0,0c0.01,0.005,0.042,0.02,0.071,0.007c0,0,0.084-0.05,0.109-0.064l0,0l0.009-0.007c0.018-0.012,0.042-0.028,0.048-0.058l0.002-0.007l0,0c0.004-0.011,1.983-6.575,1.983-6.575c0.007-0.03-0.006-0.063-0.03-0.082C9.031,11.105,6.954,11.21,3.988,12.398z M12.394,13.491c-0.038,0.026-0.135,0.091-0.152,0.141L10.313,20.1c-0.035,0.098,0.055,0.151,0.066,0.156c2.595,1.692,5.201,1.686,8.082,0.491c0.002,0,0.049-0.029,0.064-0.061c0-0.002,1.885-6.365,1.885-6.367c0.01-0.052-0.004-0.085-0.031-0.114l-0.158-0.123c-0.01-0.011-0.037-0.028-0.105-0.019c-3.7,1.216-5.648,0.668-7.571-0.587C12.505,13.455,12.458,13.447,12.394,13.491z M14.678,5.58c-0.074,0.054-0.139,0.096-0.156,0.156l-1.936,6.485c-0.017,0.067-0.006,0.105,0.06,0.149c2.486,1.691,5.264,1.702,8.062,0.487c0.027-0.009,0.053-0.034,0.066-0.062c0-0.001,1.967-6.543,1.967-6.543c0.021-0.074-0.03-0.124-0.09-0.175c-0.026-0.024-0.063-0.057-0.088-0.067c-0.055-0.024-0.108-0.017-0.124-0.007c-0.001,0-0.002,0-0.002,0l0,0c-3.356,1.343-5.374,1.029-7.61-0.439C14.768,5.54,14.74,5.542,14.678,5.58z M6.245,4.441L6.245,4.441C6.239,4.443,6.217,4.451,6.209,4.48l-1.955,6.549c-0.009,0.032,0.002,0.083,0.026,0.101c0.002,0.002,0.147,0.109,0.15,0.111c0.036,0.014,0.028,0.011,0.098-0.012c3.296-1.268,5.097-0.888,7.107,0.354c0.039,0.021,0.064,0.025,0.089,0.019l0.123-0.053c0.016-0.009,0.037-0.021,0.053-0.063l1.952-6.53c0.006-0.024,0.003-0.058-0.025-0.079C11.438,3.206,9.207,3.261,6.245,4.441z"/>
+<path fill="#FFFFFF" d="M17.984,20.216c0.02-0.011,0.051-0.038,0.061-0.063c0,0,1.875-6.541,1.877-6.543l-0.002-0.003l0,0c0.002-0.011,0.002-0.021,0.002-0.028c0-0.054-0.031-0.086-0.033-0.086c0.002,0-0.154-0.126-0.154-0.126l0,0l0,0c-0.012-0.012-0.039-0.028-0.108-0.021C19.359,13.453,16.719,20.688,17.984,20.216z M20.226,12.327c0.014-0.009,0.052-0.028,0.066-0.063l1.957-6.724c0.021-0.074-0.034-0.135-0.089-0.183c-0.092-0.093-0.152-0.097-0.215-0.074C21.873,5.362,18.964,12.428,20.226,12.327z"/>
+<radialGradient id="SVGID_2" gradientUnits="userSpaceOnUse" cx="11.6" cy="11.99" r="10.38">
+<stop stop-color="#D1E7ED" offset="0"/>
+<stop stop-color="#CDE4EC" offset="0.1"/>
+<stop stop-color="#C0DCE7" offset="0.2"/>
+<stop stop-color="#ADD0E1" offset="0.3"/>
+<stop stop-color="#3982B1" offset="0.65"/>
+<stop stop-color="#3474AA" offset="0.72"/>
+<stop stop-color="#285699" offset="0.9"/>
+<stop stop-color="#244B93" offset="1"/>
+</radialGradient>
+<path fill="url(#SVGID_2)" d="M3.534,11.72c3.933-1.621,5.839-0.756,7.543,0.403l-1.969,6.769c-1.712-1.15-3.574-2.097-7.522-0.465l1.925-6.697L3.534,11.72z"/>
+<radialGradient id="SVGID_3" gradientUnits="userSpaceOnUse" cx="11.79" cy="11.82" r="10.63">
+<stop stop-color="#D8EEED" offset="0"/>
+<stop stop-color="#98D8D7" offset="0.17"/>
+<stop stop-color="#8ED3D3" offset="0.22"/>
+<stop stop-color="#74C6CA" offset="0.31"/>
+<stop stop-color="#49B1BA" offset="0.42"/>
+<stop stop-color="#3BAAB5" offset="0.45"/>
+<stop stop-color="#2D81A4" offset="0.56"/>
+<stop stop-color="#215B94" offset="0.68"/>
+<stop stop-color="#19448B" offset="0.78"/>
+<stop stop-color="#163B87" offset="0.84"/>
+<stop stop-color="#0B317D" offset="1"/>
+</radialGradient>
+<path fill="url(#SVGID_3)" d="M1.729,18.626c0.012,0.003,0.037-0.012,0.037-0.012c0.026,0.021,0.05,0.033,0.05,0.033S1.772,18.656,1.729,18.626z"/>
+<path fill="#152469" d="M9.04,18.969c0,0,0.027,0.022,0.057,0.017l-0.118,0.069c-0.037,0.019-0.077-0.01-0.077-0.01L9.04,18.969z"/>
+<radialGradient id="SVGID_4" gradientUnits="userSpaceOnUse" cx="11.61" cy="12.07" r="10.38">
+<stop stop-color="#D8EEED" offset="0"/>
+<stop stop-color="#98D8D7" offset="0.17"/>
+<stop stop-color="#8ED3D3" offset="0.22"/>
+<stop stop-color="#74C6CA" offset="0.31"/>
+<stop stop-color="#49B1BA" offset="0.42"/>
+<stop stop-color="#3BAAB5" offset="0.45"/>
+<stop stop-color="#2D81A4" offset="0.56"/>
+<stop stop-color="#215B94" offset="0.68"/>
+<stop stop-color="#19448B" offset="0.78"/>
+<stop stop-color="#163B87" offset="0.84"/>
+<stop stop-color="#152469" offset="1"/>
+</radialGradient>
+<path fill="url(#SVGID_4)" d="M1.769,18.616c0,0-0.022,0.011-0.036,0.011l-0.129-0.101l-0.003-0.001c0.021,0.004,0.041,0.001,0.048,0.001L1.769,18.616z"/>
+<path fill="#152469" d="M9.106,18.873c0.014,0.01,0.028,0.021,0.04,0.048c-0.006,0.035-0.034,0.052-0.052,0.066c-0.024,0.005-0.058-0.019-0.058-0.019C9.054,18.954,9.086,18.931,9.106,18.873z"/>
+<path fill="#172E65" d="M1.603,18.527c-0.026-0.021-0.042-0.059-0.032-0.094l0.023-0.009c-0.009,0.05,0.028,0.086,0.052,0.102C1.646,18.527,1.626,18.535,1.603,18.527z"/>
+<radialGradient id="SVGID_5" gradientUnits="userSpaceOnUse" cx="11.6" cy="11.96" r="10.42">
+<stop stop-color="#D8EEED" offset="0"/>
+<stop stop-color="#98D8D7" offset="0.17"/>
+<stop stop-color="#8ED3D3" offset="0.22"/>
+<stop stop-color="#74C6CA" offset="0.31"/>
+<stop stop-color="#49B1BA" offset="0.42"/>
+<stop stop-color="#3BAAB5" offset="0.45"/>
+<stop stop-color="#2D81A4" offset="0.56"/>
+<stop stop-color="#215B94" offset="0.68"/>
+<stop stop-color="#19448B" offset="0.78"/>
+<stop stop-color="#163B87" offset="0.84"/>
+<stop stop-color="#0B317D" offset="1"/>
+</radialGradient>
+<path fill="url(#SVGID_5)" d="M1.761,18.609c3.757-1.468,5.44-0.668,7.152,0.433c-1.025-0.659-2.079-1.185-3.534-1.195c-0.975-0.007-2.125,0.24-3.566,0.801C1.813,18.647,1.783,18.635,1.761,18.609z"/>
+<path fill="#094B8F" d="M9.039,18.973c-1.712-1.151-3.485-2.031-7.389-0.445c-0.025-0.016-0.068-0.056-0.057-0.104c3.962-1.688,5.804-0.703,7.517,0.448C9.093,18.937,9.058,18.957,9.039,18.973z"/>
+<path fill="#094B8F" d="M9.041,18.973l-0.139,0.071c-1.711-1.1-3.443-1.862-7.133-0.429l-0.123-0.089C5.551,16.94,7.328,17.822,9.041,18.973z"/>
+<linearGradient id="SVGID_6" gradientUnits="userSpaceOnUse" x1="11.03" y1="12.31" x2="9.4" y2="18.02">
+<stop stop-color="#98D8D7" offset="0"/>
+<stop stop-color="#152469" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_6)" d="M9.106,18.876l1.971-6.754c0.022,0.015,0.034,0.024,0.044,0.038l-1.975,6.764C9.136,18.892,9.106,18.876,9.106,18.876z"/>
+<radialGradient id="SVGID_7" gradientUnits="userSpaceOnUse" cx="11.61" cy="11.96" r="10.6">
+<stop stop-color="#D8EEED" offset="0"/>
+<stop stop-color="#98D8D7" offset="0.17"/>
+<stop stop-color="#8ED3D3" offset="0.22"/>
+<stop stop-color="#74C6CA" offset="0.31"/>
+<stop stop-color="#49B1BA" offset="0.42"/>
+<stop stop-color="#3BAAB5" offset="0.45"/>
+<stop stop-color="#2D81A4" offset="0.56"/>
+<stop stop-color="#215B94" offset="0.68"/>
+<stop stop-color="#19448B" offset="0.78"/>
+<stop stop-color="#163B87" offset="0.84"/>
+<stop stop-color="#152469" offset="1"/>
+</radialGradient>
+<path fill="url(#SVGID_7)" d="M11.09,12.075h0.003c0.024,0.017,0.035,0.052,0.028,0.085v0.003c-0.012-0.011-0.021-0.024-0.044-0.04L11.09,12.075z"/>
+<polygon opacity="0.66" fill="#063367" enable-background="new " points="3.489,11.724 3.511,11.729 1.593,18.425 1.57,18.434 "/>
+<linearGradient id="SVGID_8" gradientUnits="userSpaceOnUse" x1="1.57" y1="15.19" x2="3.72" y2="15.19">
+<stop stop-color="#DEF3F1" offset="0"/>
+<stop stop-color="#5085BC" offset="1"/>
+</linearGradient>
+<path opacity="0.42" fill="url(#SVGID_8)" enable-background="new " d="M3.489,11.724l-0.09,0.321l-1.826,6.389c-0.011,0.034,0.006,0.072,0.031,0.093l0.129,0.103c0,0,0-0.003,0,0c0.017,0.01,0.034,0.015,0.047,0.018l1.943-6.735L3.72,11.906L3.511,11.73L3.489,11.724z M1.597,18.423v-0.002c0.009-0.004,0.017-0.006,0.027-0.01C1.614,18.415,1.605,18.417,1.597,18.423z M1.646,18.527c-0.013-0.01-0.028-0.021-0.04-0.037C1.618,18.506,1.634,18.518,1.646,18.527C1.646,18.526,1.646,18.526,1.646,18.527z"/>
+<linearGradient id="SVGID_9" gradientUnits="userSpaceOnUse" x1="8.93" y1="15.58" x2="11.12" y2="15.58">
+<stop stop-color="#DEF3F1" offset="0"/>
+<stop stop-color="#5085BC" offset="1"/>
+</linearGradient>
+<path opacity="0.42" fill="url(#SVGID_9)" enable-background="new " d="M11.116,12.104l-0.041,0.021l-0.163,0.161c0.001,0,0.001,0,0.001,0.001c-0.267,0.909-1.757,6.004-1.984,6.768c0.015,0.004,0.032,0.006,0.048-0.002l0.119-0.07H9.094c0.017-0.013,0.044-0.03,0.052-0.063c0,0.002,0,0.002,0,0.002l1.91-6.541l0.066-0.224c0.002-0.013,0.002-0.023,0-0.035C11.122,12.117,11.12,12.111,11.116,12.104z"/>
+<linearGradient id="SVGID_10" gradientUnits="userSpaceOnUse" x1="3.51" y1="11.53" x2="11.09" y2="11.53">
+<stop stop-color="#094992" offset="0"/>
+<stop stop-color="#8ACDE1" offset="0.67"/>
+<stop stop-color="#E6F6F9" offset="1"/>
 </linearGradient>
-<polygon fill="url(#SVGID_2)" points="117.137,83.5 117.618,79.434 146.991,86.86 143.509,108.785 141.842,108.246 "/>
-<linearGradient id="SVGID_3" gradientUnits="userSpaceOnUse" x1="123.02" y1="75" x2="148.69" y2="104.01">
-<stop stop-color="#BAD986" offset="0"/>
-<stop stop-color="#B7D884" offset="0.24"/>
-<stop stop-color="#AED27D" offset="0.43"/>
-<stop stop-color="#9FCA70" offset="0.61"/>
-<stop stop-color="#8CC15E" offset="0.78"/>
-<stop stop-color="#70B64B" offset="0.94"/>
-<stop stop-color="#63B246" offset="1"/>
+<path fill="url(#SVGID_10)" d="M11.077,12.124l-0.164,0.163c-0.566-0.378-2.131-1.349-3.896-1.204C5.583,11.2,4.32,11.661,3.722,11.91l-0.211-0.182l0.015-0.046c3.952-1.634,5.856-0.766,7.566,0.393H11.09h0.003L11.077,12.124z"/>
+<linearGradient id="SVGID_11" gradientUnits="userSpaceOnUse" x1="3.53" y1="11.68" x2="3.53" y2="11.68">
+<stop stop-color="#7D9EC4" offset="0"/>
+<stop stop-color="#151D89" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_11)" d="M3.526,11.682"/>
+<linearGradient id="SVGID_12" gradientUnits="userSpaceOnUse" x1="3.69" y1="11.66" x2="10.94" y2="11.66">
+<stop stop-color="#BAC7E1" offset="0.01"/>
+<stop stop-color="#7090C3" offset="0.22"/>
+<stop stop-color="#C8EAEF" offset="0.54"/>
+<stop stop-color="#FFFFFF" offset="1"/>
+</linearGradient>
+<path opacity="0.33" fill="url(#SVGID_12)" enable-background="new " d="M3.694,11.886c3.953-1.633,5.716-0.554,7.25,0.372l-0.03,0.029c-1.578-0.978-3.257-1.937-7.192-0.375L3.694,11.886z"/>
+<linearGradient id="SVGID_13" gradientUnits="userSpaceOnUse" x1="3.51" y1="11.45" x2="11.09" y2="11.45">
+<stop stop-color="#7090C3" offset="0.01"/>
+<stop stop-color="#C0E7ED" offset="0.54"/>
+<stop stop-color="#FFFFFF" offset="1"/>
+</linearGradient>
+<path opacity="0.33" fill="url(#SVGID_13)" enable-background="new " d="M3.526,11.682c3.952-1.634,5.779-0.8,7.567,0.394l-0.016,0.048c-1.877-1.218-3.633-2-7.566-0.395L3.526,11.682z"/>
+<radialGradient id="SVGID_14" gradientUnits="userSpaceOnUse" cx="3.5" cy="11.7" r="0.02">
+<stop stop-color="#7D9EC4" offset="0"/>
+<stop stop-color="#0A50A1" offset="1"/>
+</radialGradient>
+<path fill="url(#SVGID_14)" d="M3.511,11.729l-0.022-0.005c0.008-0.028,0.028-0.038,0.034-0.04l0.004-0.001C3.526,11.682,3.522,11.695,3.511,11.729z"/>
+<radialGradient id="SVGID_15" gradientUnits="userSpaceOnUse" cx="-1.49" cy="18.16" r="12.8">
+<stop stop-color="#D8EEED" offset="0"/>
+<stop stop-color="#98D8D7" offset="0.17"/>
+<stop stop-color="#8ED3D3" offset="0.22"/>
+<stop stop-color="#74C6CA" offset="0.31"/>
+<stop stop-color="#49B1BA" offset="0.42"/>
+<stop stop-color="#3BAAB5" offset="0.45"/>
+<stop stop-color="#359FB5" offset="0.5"/>
+<stop stop-color="#2988B4" offset="0.63"/>
+<stop stop-color="#257FB4" offset="0.71"/>
+<stop stop-color="#4161AA" offset="1"/>
+</radialGradient>
+<path opacity="0.5" fill="url(#SVGID_15)" enable-background="new " d="M9.043,18.971c-1.713-1.15-3.485-2.03-7.389-0.445c-0.026-0.015-0.068-0.054-0.058-0.105c3.963-1.688,5.804-0.702,7.518,0.449C9.096,18.935,9.062,18.956,9.043,18.971z"/>
+<radialGradient id="SVGID_16" gradientUnits="userSpaceOnUse" cx="11.59" cy="12.21" r="9.66">
+<stop stop-color="#FCF5B0" offset="0"/>
+<stop stop-color="#F7EDA0" offset="0.17"/>
+<stop stop-color="#F3E591" offset="0.28"/>
+<stop stop-color="#FCD118" offset="0.65"/>
+<stop stop-color="#F7A50C" offset="0.8"/>
+<stop stop-color="#F38603" offset="0.93"/>
+<stop stop-color="#F27B00" offset="1"/>
+</radialGradient>
+<path fill="url(#SVGID_16)" d="M12.108,12.777c1.712,1.149,3.46,1.994,7.481,0.617l-1.877,6.528c-3.945,1.633-5.839,0.71-7.548-0.449L12.108,12.777z"/>
+<linearGradient id="SVGID_17" gradientUnits="userSpaceOnUse" x1="18.01" y1="20.07" x2="17.97" y2="20.22">
+<stop stop-color="#DD980D" offset="0"/>
+<stop stop-color="#A75D0F" offset="1"/>
 </linearGradient>
-<path d="M141.933,108.094c0.915,0.92-23.651-23.688-24.616-24.655 c0.019-0.151,0.408-3.444,0.448-3.789c0.372,0.094,28.732,7.263,29.031,7.338c-0.048,0.303-3.365,21.184-3.425,21.571 C143.079,108.466,142,108.115,141.933,108.094" fill="url(#SVGID_3)"/>
-<path d="M143.032,108.61c-0.094-0.016-0.594-0.188-0.594-0.188s1.33-20.618,1.551-20.618l0.277,0.04 c0.222,0,0.4,0.179,0.4,0.4L143.032,108.61z" fill-opacity="0.24" />
-<linearGradient id="SVGID_7" gradientUnits="userSpaceOnUse" x1="114.32" y1="96.34" x2="144.22" y2="96.34">
-<stop stop-color="#FBAF4B" offset="0"/>
-<stop stop-color="#FBAD48" offset="0.31"/>
-<stop stop-color="#FAA53E" offset="0.56"/>
-<stop stop-color="#F89930" offset="0.8"/>
-<stop stop-color="#F6891F" offset="1"/>
+<path fill="url(#SVGID_17)" d="M18.047,20.155c-0.02,0.037-0.053,0.058-0.063,0.063c-0.004,0-0.004,0.002-0.004,0.002s-0.035,0.002-0.064-0.021c0.076-0.043,0.1-0.127,0.1-0.127S18.061,20.113,18.047,20.155z"/>
+<linearGradient id="SVGID_18" gradientUnits="userSpaceOnUse" x1="18.01" y1="16.86" x2="19.92" y2="16.86">
+<stop stop-color="#DEB150" offset="0"/>
+<stop stop-color="#FFF8B2" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_18)" d="M18.047,20.155c0.008-0.037-0.035-0.069-0.035-0.069l1.871-6.522c0,0,0.03,0.027,0.041,0.05L18.047,20.155z"/>
+<linearGradient id="SVGID_19" gradientUnits="userSpaceOnUse" x1="19.9" y1="13.49" x2="19.9" y2="13.62">
+<stop stop-color="#C67C0C" offset="0.01"/>
+<stop stop-color="#DD980D" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_19)" d="M19.922,13.614c0,0-0.008-0.02-0.041-0.046c0.018-0.064,0.006-0.076,0.006-0.076l0.005,0.002C19.891,13.494,19.939,13.539,19.922,13.614z"/>
+<linearGradient id="SVGID_20" gradientUnits="userSpaceOnUse" x1="19.63" y1="13.34" x2="19.7" y2="13.47">
+<stop stop-color="#FED30E" offset="0.01"/>
+<stop stop-color="#A75D0F" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_20)" d="M19.734,13.458c0,0-0.051-0.063-0.156-0.045c0.004-0.023,0.014-0.052,0.047-0.064c0.064-0.011,0.094,0.006,0.107,0.021c0.008,0.008,0.012,0.014,0.012,0.014C19.752,13.42,19.734,13.458,19.734,13.458z"/>
+<linearGradient id="SVGID_21" gradientUnits="userSpaceOnUse" x1="19.83" y1="13.45" x2="19.78" y2="13.5">
+<stop stop-color="#FED30E" offset="0.01"/>
+<stop stop-color="#A75D0F" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_21)" d="M19.732,13.368l0.156,0.126c0.01,0.041-0.008,0.083-0.008,0.083l-0.154-0.123C19.729,13.454,19.744,13.405,19.732,13.368z"/>
+<polygon opacity="0.66" fill="#B37E00" enable-background="new " points="17.844,19.965 19.727,13.444 19.885,13.569 18.016,20.09 18.01,20.107 "/>
+<linearGradient id="SVGID_22" gradientUnits="userSpaceOnUse" x1="12.09" y1="13.44" x2="19.63" y2="13.44">
+<stop stop-color="#FFF8FB" offset="0"/>
+<stop stop-color="#FEC236" offset="1"/>
 </linearGradient>
-<polygon fill="url(#SVGID_7)" points="114.318,87.056 114.516,82.685 144.223,87.005 142.486,109.992 139.294,109.096 114.347,87.143 "/>
-<linearGradient id="SVGID_8" gradientUnits="userSpaceOnUse" x1="119.66" y1="77.69" x2="147.3" y2="104.68">
-<stop stop-color="#FDC27F" offset="0"/>
-<stop stop-color="#FDC17D" offset="0.22"/>
-<stop stop-color="#FBBD76" offset="0.41"/>
-<stop stop-color="#F9B668" offset="0.57"/>
-<stop stop-color="#F7AD54" offset="0.73"/>
-<stop stop-color="#F4A138" offset="0.88"/>
-<stop stop-color="#F19720" offset="1"/>
+<path fill="url(#SVGID_22)" d="M19.584,13.42c-3.961,1.353-5.776,0.549-7.485-0.604c0.004-0.012,0.01-0.042-0.008-0.07c1.71,1.149,3.603,1.935,7.535,0.604C19.596,13.368,19.592,13.396,19.584,13.42z"/>
+<polygon fill="#D9A200" points="11.791,12.896 11.923,12.808 10.019,19.45 9.869,19.567 9.869,19.552 "/>
+<linearGradient id="SVGID_23" gradientUnits="userSpaceOnUse" x1="18.8" y1="16.71" x2="18.63" y2="16.66">
+<stop stop-color="#B37E00" offset="0"/>
+<stop stop-color="#FF9E00" offset="1"/>
+</linearGradient>
+<path opacity="0.66" fill="url(#SVGID_23)" enable-background="new " d="M17.693,19.929l1.886-6.518c0.003,0,0.007-0.006,0.011-0.006c0.098-0.011,0.145,0.042,0.145,0.042l-1.875,6.51C17.857,19.957,17.779,19.895,17.693,19.929z"/>
+<path fill="#A75D0F" d="M17.982,20.219c-3.867,1.654-6.351,0.635-8.061-0.516l0.018-0.014c1.71,1.15,4.342,2.109,7.977,0.505C17.943,20.217,17.982,20.219,17.982,20.219z"/>
+<linearGradient id="SVGID_24" gradientUnits="userSpaceOnUse" x1="17.92" y1="19.99" x2="17.84" y2="20.17">
+<stop stop-color="#FFD100" offset="0.01"/>
+<stop stop-color="#A8710A" offset="1"/>
+</linearGradient>
+<path opacity="0.66" fill="url(#SVGID_24)" enable-background="new " d="M17.857,19.955l0.158,0.136c0,0-0.021,0.077-0.109,0.112l-0.161-0.134C17.832,20.033,17.857,19.955,17.857,19.955z"/>
+<linearGradient id="SVGID_25" gradientUnits="userSpaceOnUse" x1="10.1" y1="20.18" x2="17.78" y2="20.18">
+<stop stop-color="#DD980D" offset="0"/>
+<stop stop-color="#FDDA10" offset="0.4"/>
+<stop stop-color="#DD980D" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_25)" d="M17.697,19.925c-0.016,0.1,0.082,0.163,0.082,0.163c-4.068,1.515-5.859,0.596-7.681-0.501c0.031-0.022,0.048-0.041,0.064-0.111c0.004,0.002,0.012,0.004,0.016,0.007C11.941,20.567,13.988,21.459,17.697,19.925z"/>
+<path fill="#C67C0C" d="M9.94,19.697l0.158-0.114c1.566,0.978,3.763,2.045,7.657,0.482l0.159,0.136C14.297,21.806,11.649,20.847,9.94,19.697z"/>
+<path fill="#DD980D" d="M9.954,19.701l-0.019,0.014c0,0-0.103-0.058-0.067-0.163C9.877,19.655,9.954,19.701,9.954,19.701z"/>
+<linearGradient id="SVGID_26" gradientUnits="userSpaceOnUse" x1="10.05" y1="19.64" x2="9.92" y2="19.5">
+<stop stop-color="#DD980D" offset="0.1"/>
+<stop stop-color="#FDDA10" offset="0.7"/>
+<stop stop-color="#DD980D" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_26)" d="M9.869,19.552l0.149-0.123c-0.008,0.11,0.096,0.149,0.096,0.149l-0.163,0.125C9.952,19.703,9.861,19.659,9.869,19.552z"/>
+<linearGradient id="SVGID_27" gradientUnits="userSpaceOnUse" x1="10.05" y1="19.41" x2="10.14" y2="19.57">
+<stop stop-color="#DD980D" offset="0"/>
+<stop stop-color="#FEBF0F" offset="0.4"/>
+<stop stop-color="#FED30E" offset="0.8"/>
+<stop stop-color="#DD980D" offset="1"/>
 </linearGradient>
-<path d="M139.38,108.942c0.899,0.811-23.935-21.1-24.886-21.958c0.006-0.148,0.171-3.764,0.186-4.101 c0.37,0.053,29.05,4.224,29.361,4.27c-0.023,0.313-1.679,22.211-1.709,22.618C141.98,109.671,139.451,108.961,139.38,108.942" fill="url(#SVGID_8)"/>
-<path d="M142.172,109.891c0.016,0-0.531-0.156-0.909-0.176c0,0-0.024-20.99-0.089-21.022 l0.089,0.012c0.589,0,1.066,0.544,1.066,1.214L142.172,109.891z" fill="#231F20" fill-opacity="0.23" />
-<linearGradient id="SVGID_10" gradientUnits="userSpaceOnUse" x1="111.43" y1="99.17" x2="141.47" y2="99.17">
-<stop stop-color="#74B8E5" offset="0"/>
-<stop stop-color="#56A7DB" offset="1"/>
+<path fill="url(#SVGID_27)" d="M10.006,19.434c0.053-0.021,0.103,0.004,0.159,0.037c-0.02,0.069-0.032,0.094-0.062,0.115C10.068,19.567,9.999,19.522,10.006,19.434z"/>
+<path fill="#DD980D" d="M11.948,12.751l-0.029,0.057l-0.132,0.094c0.009-0.044,0.118-0.123,0.152-0.145C11.943,12.754,11.948,12.751,11.948,12.751z"/>
+<radialGradient id="SVGID_28" gradientUnits="userSpaceOnUse" cx="11.99" cy="12.72" r="0.09">
+<stop stop-color="#FEEB71" offset="0"/>
+<stop stop-color="#DD980D" offset="1"/>
+</radialGradient>
+<path fill="url(#SVGID_28)" d="M12.096,12.815c-0.079-0.044-0.149-0.022-0.177-0.008c0.004-0.015,0.022-0.052,0.022-0.052c0.063-0.04,0.09-0.04,0.15-0.013C12.108,12.773,12.103,12.798,12.096,12.815z"/>
+<linearGradient id="SVGID_29" gradientUnits="userSpaceOnUse" x1="11.14" y1="16.15" x2="10.96" y2="16.1">
+<stop stop-color="#FEEFBB" offset="0.01"/>
+<stop stop-color="#FFBF00" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_29)" d="M10.179,19.482c-0.056-0.034-0.12-0.06-0.173-0.036l1.917-6.638c0.029-0.014,0.097-0.037,0.176,0.009L10.179,19.482z"/>
+<linearGradient id="SVGID_30" gradientUnits="userSpaceOnUse" x1="11.72" y1="13.52" x2="19.91" y2="13.52">
+<stop stop-color="#FCA859" offset="0.01"/>
+<stop stop-color="#FDC30F" offset="0.21"/>
+<stop stop-color="#B51C00" offset="1"/>
+</linearGradient>
+<path opacity="0.33" fill="url(#SVGID_30)" enable-background="new " d="M11.824,12.852c0.586,0.509,3.127,2.585,8.066,0.643l-0.156-0.126c-0.016-0.015-0.045-0.03-0.107-0.021c-3.932,1.333-5.824,0.548-7.534-0.604c0,0.002,0,0.002,0,0.002c-0.058-0.03-0.086-0.029-0.149,0.012C11.863,12.812,11.863,12.812,11.824,12.852z"/>
+<linearGradient id="SVGID_31" gradientUnits="userSpaceOnUse" x1="11.79" y1="13.62" x2="19.92" y2="13.62">
+<stop stop-color="#FFF6D8" offset="0.01"/>
+<stop stop-color="#FDDA10" offset="0.53"/>
+<stop stop-color="#F9BD0C" offset="1"/>
+</linearGradient>
+<path opacity="0.33" fill="url(#SVGID_31)" enable-background="new " d="M19.891,13.494L19.891,13.494c-4.941,1.942-7.48-0.135-8.066-0.643c-0.016,0.017-0.026,0.03-0.033,0.043v0.001l-0.002,0.007c0,0,0,0,0,0.002v-0.002v0.004c0.511,0.447,3.063,2.67,8.135,0.66C19.916,13.521,19.891,13.494,19.891,13.494z"/>
+<linearGradient id="SVGID_32" gradientUnits="userSpaceOnUse" x1="17.79" y1="20" x2="17.68" y2="19.9">
+<stop stop-color="#EAB849" offset="0"/>
+<stop stop-color="#EDC15A" offset="0.07"/>
+<stop stop-color="#F3D783" offset="0.28"/>
+<stop stop-color="#F8E8A4" offset="0.48"/>
+<stop stop-color="#FCF5BC" offset="0.67"/>
+<stop stop-color="#FEFCCA" offset="0.85"/>
+<stop stop-color="#FFFFCF" offset="1"/>
 </linearGradient>
-<polygon fill="url(#SVGID_10)" points="111.432,86.639 111.432,107.756 141.473,111.703 141.473,87.842 "/>
-<linearGradient id="SVGID_11" gradientUnits="userSpaceOnUse" x1="111.95" y1="99.09" x2="140.61" y2="99.09">
-<stop stop-color="#D8EEFB" offset="0"/>
-<stop stop-color="#A3DCEA" offset="1"/>
+<path fill="url(#SVGID_32)" d="M17.756,20.066c0,0-0.072-0.046-0.059-0.146c0.1-0.026,0.16,0.036,0.16,0.036S17.842,20.028,17.756,20.066z"/>
+<radialGradient id="SVGID_33" gradientUnits="userSpaceOnUse" cx="11.3" cy="10.89" r="9.17">
+<stop stop-color="#EFD815" offset="0"/>
+<stop stop-color="#EFD415" offset="0.11"/>
+<stop stop-color="#EDC614" offset="0.22"/>
+<stop stop-color="#EBB112" offset="0.33"/>
+<stop stop-color="#E89211" offset="0.45"/>
+<stop stop-color="#E36C0E" offset="0.57"/>
+<stop stop-color="#E04C0C" offset="0.65"/>
+<stop stop-color="#CE2907" offset="0.78"/>
+<stop stop-color="#BF0B02" offset="0.92"/>
+<stop stop-color="#B90000" offset="1"/>
+</radialGradient>
+<path fill="url(#SVGID_33)" d="M11.406,10.901C10.377,10.208,9.27,9.56,7.695,9.548c-1.037-0.007-2.273,0.288-3.844,0.936l1.945-6.74c3.946-1.631,5.843-0.706,7.555,0.452L11.406,10.901z"/>
+<path fill="#BC1B00" d="M11.402,10.898l1.948-6.702c0.021,0.013,0.028,0.023,0.04,0.038l-1.946,6.713C11.436,10.919,11.402,10.898,11.402,10.898z"/>
+<path fill="#BC1B00" d="M4.039,10.679c0.622-0.255,1.198-0.445,1.732-0.574c0.13-0.031,0.245-0.06,0.383-0.085C6.281,9.995,6.405,9.97,6.525,9.95C6.715,9.924,6.9,9.898,7.083,9.884c0.153-0.012,0.302-0.021,0.45-0.021c0.142,0,0.281,0,0.417,0.008C8.07,9.877,8.187,9.886,8.304,9.9C8.402,9.91,8.499,9.923,8.593,9.94c0.199,0.033,0.394,0.077,0.58,0.129c0.757,0.214,1.429,0.579,2.046,0.989c-0.005,0.002-0.019-0.004-0.025-0.007c-0.006-0.002-0.009-0.002-0.014-0.006c-0.835-0.529-1.731-0.99-2.838-1.126c-1.133-0.14-2.454,0.056-4.231,0.762c0,0-0.042,0.019-0.059,0.02C4.039,10.704,4.041,10.693,4.039,10.679z"/>
+<path fill="#BC1B00" d="M11.337,10.999c0,0,0.024,0.017,0.056,0.011l-0.123,0.056c-0.033,0.008-0.072-0.012-0.072-0.012L11.337,10.999z"/>
+<path fill="#B81A00" d="M4.039,10.679c0,0,0.008,0.015,0.014,0.022c-0.011,0.001-0.014,0.005-0.043-0.008c-0.005-0.002-0.01-0.006-0.015-0.01l-0.128-0.099l-0.012-0.01c0.018-0.001,0.03,0.006,0.038,0.006L4.039,10.679z"/>
+<path fill="#E82E00" d="M11.406,10.901c0.012,0.008,0.031,0.014,0.042,0.042c-0.007,0.036-0.038,0.054-0.056,0.066c-0.03,0.008-0.059-0.014-0.059-0.014C11.353,10.981,11.385,10.957,11.406,10.901z"/>
+<path fill="#E32D00" d="M3.856,10.577c-0.019-0.013-0.036-0.069-0.025-0.105l0.025-0.006c-0.011,0.048,0.02,0.104,0.047,0.121C3.904,10.586,3.885,10.597,3.856,10.577z"/>
+<linearGradient id="SVGID_34" gradientUnits="userSpaceOnUse" x1="5.78" y1="3.72" x2="5.82" y2="3.72">
+<stop stop-color="#FD7E36" offset="0"/>
+<stop stop-color="#BD6F4F" offset="1"/>
 </linearGradient>
-<polygon fill="url(#SVGID_11)" points="111.948,87.154 111.948,107.339 140.614,111.016 140.614,88.528 "/>
-<linearGradient id="SVGID_12" gradientUnits="userSpaceOnUse" x1="141.56" y1="87.76" x2="141.56" y2="111.66">
-<stop stop-color="#3686C3" offset="0"/>
-<stop stop-color="#245F98" offset="1"/>
+<path id="SVGID_37" fill="url(#SVGID_34)" d="M5.796,3.746L5.778,3.742c0.008-0.03,0.028-0.04,0.035-0.042l0.002-0.001C5.815,3.699,5.808,3.715,5.796,3.746z"/>
+<path fill="#E82E00" d="M11.339,11c-1.838-1.277-4.093-2.079-7.44-0.416l0.137,0.097c3.658-1.494,5.564-0.688,7.168,0.372L11.339,11z"/>
+<path fill="#E82E00" d="M11.337,10.999c-1.054-0.688-2.039-1.257-3.6-1.302c-1.14,0.022-2.017,0.17-3.836,0.89c-0.025-0.014-0.061-0.053-0.051-0.103c1.575-0.67,2.826-0.96,3.864-0.951c1.571,0.015,2.66,0.673,3.689,1.365C11.388,10.961,11.354,10.983,11.337,10.999z"/>
+<path fill="#E32D00" d="M5.778,3.742l0.018,0.005l-1.94,6.734c-0.004-0.003-0.023-0.007-0.023-0.007L5.778,3.742z"/>
+<linearGradient id="SVGID_35" gradientUnits="userSpaceOnUse" x1="5.79" y1="3.51" x2="13.36" y2="3.51">
+<stop stop-color="#FC2B20" offset="0"/>
+<stop stop-color="#FF590A" offset="0.24"/>
+<stop stop-color="#FB570B" offset="0.25"/>
+<stop stop-color="#E74C0E" offset="0.33"/>
+<stop stop-color="#D84511" offset="0.42"/>
+<stop stop-color="#D04013" offset="0.52"/>
+<stop stop-color="#CD3F13" offset="0.7"/>
+<stop stop-color="#D04213" offset="0.8"/>
+<stop stop-color="#D84B14" offset="0.87"/>
+<stop stop-color="#E65B16" offset="0.93"/>
+<stop stop-color="#F97219" offset="0.99"/>
+<stop stop-color="#FC7519" offset="1"/>
+</linearGradient>
+<path opacity="0.66" fill="url(#SVGID_35)" enable-background="new " d="M13.351,4.194C11.639,3.036,9.725,2.14,5.796,3.746c0.008-0.033,0.017-0.045,0.017-0.045c3.95-1.632,5.839-0.709,7.549,0.449L13.351,4.194z"/>
+<path opacity="0.33" fill="#FE8411" enable-background="new " d="M13.123,4.417c-1.394-0.904-3.236-2.04-7.164-0.435c0.008-0.033,0.019-0.05,0.019-0.05c3.948-1.633,5.807-0.389,7.159,0.435L13.123,4.417z"/>
+<g opacity="0.6">
+<linearGradient id="SVGID_36" gradientUnits="userSpaceOnUse" x1="3.86" y1="7.25" x2="5.97" y2="7.25">
+<stop stop-color="#FD7E36" offset="0"/>
+<stop stop-color="#BD6F4F" offset="1"/>
+</linearGradient>
+<path opacity="0.6" fill="url(#SVGID_36)" enable-background="new " d="M5.86,3.79c-0.011,0.004-0.05,0-0.05,0l-1.955,6.778l0.139,0.113C4,10.686,4.005,10.689,4.01,10.692c0.024,0.011,0.031,0.011,0.038,0.009l1.921-6.748l0.006-0.021L5.86,3.79z"/>
+</g>
+<linearGradient id="SVGID_38" gradientUnits="userSpaceOnUse" x1="14" y1="4.57" x2="4.22" y2="2.39">
+<stop stop-color="#FE550D" offset="0"/>
+<stop stop-color="#8C1501" offset="1"/>
+</linearGradient>
+<path opacity="0.5" fill="url(#SVGID_38)" enable-background="new " d="M13.135,4.373c0.002,0.002,0.002,0.002,0.002,0.002c0-0.002,0.002-0.002,0.002-0.004L13.135,4.373z"/>
+<linearGradient id="SVGID_39" gradientUnits="userSpaceOnUse" x1="9.57" y1="4.43" x2="9.49" y2="2.08">
+<stop stop-color="#FE550D" offset="0"/>
+<stop stop-color="#8C1501" offset="1"/>
+</linearGradient>
+<path opacity="0.5" fill="url(#SVGID_39)" enable-background="new " d="M13.182,4.219c-0.649-0.435-1.73-1.14-3.309-1.25C8.196,2.85,6.072,3.704,5.86,3.791l0.114,0.143L5.969,3.955C5.975,3.954,5.98,3.95,5.987,3.948c3.913-1.684,6.325-0.163,7.146,0.428l0.004-0.003l0.123-0.101C13.234,4.253,13.209,4.236,13.182,4.219z"/>
+<path opacity="0.5" fill="#FFF4C5" enable-background="new " d="M5.86,3.79c0.211-0.088,2.336-0.941,4.013-0.822c1.579,0.111,2.66,0.816,3.309,1.25c0.027,0.019,0.053,0.034,0.076,0.052l0.121-0.099c-0.006-0.008-0.009-0.018-0.018-0.022c-1.672-1.133-3.519-2.041-7.292-0.554C5.984,3.63,5.901,3.663,5.813,3.699l0,0L5.86,3.79z"/>
+<linearGradient id="SVGID_40" gradientUnits="userSpaceOnUse" x1="11.18" y1="7.61" x2="13.39" y2="7.61">
+<stop stop-color="#FD7E36" offset="0"/>
+<stop stop-color="#FC895B" offset="1"/>
+</linearGradient>
+<path opacity="0.6" fill="url(#SVGID_40)" enable-background="new " d="M13.361,4.151l-0.011,0.042l-0.093,0.077l-0.121,0.101c0,0.002-0.002,0.002-0.002,0.005c-0.407,1.398-1.679,5.761-1.95,6.67c0.003,0.001,0.005,0.002,0.008,0.003c0.002,0.001,0.004,0.002,0.004,0.002l0,0c0,0,0.041,0.021,0.072,0.012l0.123-0.057c-0.001,0.001-0.001,0-0.004,0.001c0.001-0.001,0.002,0,0.003-0.001c0.015-0.012,0.046-0.03,0.053-0.063l0,0v-0.001c0,0,0.001,0,0.001-0.002l0,0l1.864-6.439l0,0l0.049-0.159V4.336l0.029-0.106C13.395,4.211,13.393,4.166,13.361,4.151z"/>
+<linearGradient id="SVGID_41" gradientUnits="userSpaceOnUse" x1="3.85" y1="10.26" x2="11.41" y2="10.26">
+<stop stop-color="#FD9B20" offset="0.25"/>
+<stop stop-color="#FDB830" offset="0.34"/>
+<stop stop-color="#FDD23E" offset="0.43"/>
+<stop stop-color="#FDDB43" offset="0.49"/>
+<stop stop-color="#FE8411" offset="0.75"/>
+<stop stop-color="#FE550D" offset="1"/>
 </linearGradient>
-<polygon fill="url(#SVGID_12)" points="141.643,111.364 141.47,111.704 141.47,87.842 141.643,88.162 "/>
-<polygon fill="#CC4124" points="138.591,96.151 132.129,95.083 132.495,90.082 138.957,90.953 "/>
-<path d="M139.314,90.919c0.011,0.002,0.017,0.007,0.027,0.01l0.012-0.202c-0.015,0.002-0.027,0.006-0.043,0.004 c-0.116-0.013-0.203-0.116-0.198-0.228c0.001-0.023,0.01-0.043,0.019-0.063l-0.237-0.028c0.006,0.021,0.012,0.043,0.01,0.066 c-0.007,0.111-0.104,0.19-0.221,0.177c-0.115-0.015-0.202-0.115-0.196-0.226c0.001-0.023,0.009-0.043,0.018-0.064l-0.235-0.027 c0.007,0.022,0.012,0.044,0.011,0.066c-0.007,0.111-0.104,0.19-0.22,0.178c-0.114-0.015-0.202-0.115-0.194-0.226 c0.001-0.022,0.009-0.045,0.017-0.063l-0.232-0.028c0.007,0.021,0.011,0.045,0.011,0.067c-0.008,0.11-0.105,0.188-0.219,0.175 c-0.113-0.013-0.199-0.114-0.192-0.224c0.001-0.024,0.007-0.044,0.017-0.063l-0.232-0.027c0.007,0.021,0.012,0.042,0.01,0.064 c-0.006,0.11-0.103,0.189-0.215,0.176c-0.113-0.014-0.199-0.113-0.191-0.224c0.001-0.022,0.009-0.043,0.016-0.063l-0.229-0.026 c0.006,0.022,0.01,0.044,0.009,0.066c-0.005,0.109-0.103,0.188-0.215,0.175c-0.111-0.015-0.196-0.113-0.189-0.223 c0.002-0.022,0.01-0.044,0.019-0.063l-0.229-0.027c0.007,0.021,0.01,0.043,0.01,0.066c-0.007,0.109-0.104,0.188-0.214,0.173 c-0.111-0.013-0.195-0.112-0.188-0.222c0.002-0.022,0.01-0.042,0.019-0.062l-0.227-0.026c0.007,0.021,0.01,0.043,0.009,0.064 c-0.007,0.109-0.102,0.187-0.212,0.174c-0.11-0.014-0.193-0.112-0.187-0.221c0.002-0.021,0.01-0.042,0.017-0.063l-0.223-0.026 c0.004,0.021,0.009,0.044,0.008,0.066c-0.006,0.108-0.101,0.185-0.21,0.173c-0.109-0.014-0.192-0.111-0.185-0.22 c0.002-0.023,0.007-0.044,0.017-0.063l-0.224-0.026c0.007,0.021,0.012,0.042,0.01,0.064c-0.008,0.107-0.1,0.187-0.208,0.173 c-0.108-0.013-0.19-0.111-0.185-0.219c0.001-0.022,0.009-0.042,0.019-0.063l-0.222-0.026c0.006,0.022,0.009,0.043,0.008,0.065 c-0.006,0.107-0.1,0.185-0.207,0.172s-0.188-0.11-0.182-0.217c0.002-0.024,0.008-0.044,0.017-0.063l-0.22-0.025 c0.007,0.021,0.011,0.041,0.01,0.063c-0.008,0.108-0.101,0.185-0.207,0.171c-0.106-0.012-0.188-0.109-0.18-0.216 c0.002-0.022,0.009-0.042,0.017-0.063l-0.18-0.021c0.001,0.014,0.006,0.024,0.005,0.038c-0.008,0.106-0.101,0.183-0.207,0.171 c-0.009-0.001-0.018-0.007-0.027-0.01l-0.008,0.14c0.009,0,0.019-0.004,0.028-0.003c0.107,0.013,0.188,0.111,0.181,0.219 c-0.007,0.108-0.099,0.184-0.208,0.172c-0.009-0.001-0.017-0.007-0.027-0.01l-0.013,0.205c0.011,0,0.018-0.002,0.028,0 c0.107,0.013,0.188,0.11,0.181,0.219c-0.006,0.109-0.099,0.185-0.206,0.17c-0.011-0.001-0.018-0.006-0.028-0.008l-0.015,0.206 c0.011,0,0.021-0.004,0.029-0.003c0.106,0.016,0.188,0.113,0.183,0.222c-0.008,0.108-0.101,0.184-0.209,0.17 c-0.008-0.001-0.017-0.007-0.027-0.01l-0.013,0.208c0.009,0,0.018-0.004,0.029-0.002c0.106,0.014,0.188,0.113,0.18,0.223 c-0.007,0.107-0.099,0.183-0.206,0.167c-0.011-0.001-0.02-0.005-0.027-0.008l-0.015,0.206c0.01,0,0.02-0.003,0.028-0.002 c0.107,0.016,0.188,0.115,0.183,0.224c-0.008,0.108-0.102,0.184-0.208,0.17c-0.011-0.002-0.018-0.008-0.028-0.011l-0.013,0.209 c0.009,0,0.019-0.004,0.029-0.002c0.106,0.015,0.188,0.114,0.181,0.223c-0.008,0.109-0.1,0.186-0.207,0.169 c-0.011-0.002-0.02-0.006-0.028-0.01l-0.015,0.208c0.011,0,0.019-0.004,0.029-0.002c0.107,0.017,0.188,0.117,0.181,0.226 c-0.006,0.108-0.1,0.184-0.206,0.168c-0.012-0.001-0.019-0.008-0.028-0.011l-0.015,0.209c0.01,0,0.02-0.002,0.028-0.001 c0.108,0.016,0.19,0.116,0.183,0.225c-0.008,0.109-0.101,0.186-0.208,0.168c-0.009-0.001-0.018-0.008-0.028-0.009l-0.013,0.208 c0.011,0,0.018-0.003,0.029-0.002c0.107,0.017,0.188,0.119,0.181,0.229c-0.008,0.108-0.1,0.183-0.207,0.167 c-0.011-0.002-0.02-0.008-0.028-0.012l-0.013,0.178c0.099,0.025,0.171,0.118,0.164,0.22c-0.002,0.024-0.008,0.047-0.018,0.066 l0.221,0.035c-0.007-0.022-0.012-0.047-0.01-0.071c0.007-0.107,0.101-0.181,0.207-0.165c0.107,0.019,0.188,0.119,0.181,0.227 c-0.001,0.024-0.009,0.046-0.018,0.067l0.223,0.033c-0.007-0.021-0.012-0.045-0.01-0.069c0.008-0.108,0.1-0.182,0.207-0.166 c0.107,0.017,0.189,0.119,0.185,0.229c-0.002,0.023-0.01,0.045-0.02,0.065l0.224,0.036c-0.007-0.022-0.011-0.047-0.01-0.071 c0.008-0.109,0.102-0.184,0.21-0.166c0.109,0.017,0.191,0.118,0.185,0.228c-0.001,0.023-0.009,0.048-0.018,0.067l0.224,0.035 c-0.005-0.023-0.01-0.047-0.008-0.071c0.008-0.109,0.101-0.184,0.21-0.167c0.109,0.019,0.193,0.12,0.186,0.229 c-0.001,0.024-0.007,0.047-0.018,0.066l0.229,0.037c-0.008-0.023-0.013-0.047-0.011-0.071c0.007-0.11,0.102-0.187,0.212-0.168 c0.11,0.017,0.194,0.119,0.188,0.229c-0.002,0.024-0.008,0.048-0.019,0.068l0.23,0.037c-0.008-0.024-0.013-0.049-0.011-0.073 c0.007-0.11,0.102-0.186,0.213-0.168c0.111,0.019,0.197,0.121,0.189,0.231c-0.002,0.025-0.008,0.047-0.018,0.067l0.231,0.037 c-0.008-0.023-0.013-0.047-0.011-0.072c0.007-0.11,0.103-0.186,0.215-0.168c0.112,0.017,0.198,0.12,0.191,0.231 c-0.002,0.024-0.01,0.049-0.019,0.069l0.232,0.037c-0.008-0.025-0.011-0.05-0.01-0.074c0.005-0.111,0.104-0.187,0.217-0.169 c0.113,0.019,0.197,0.123,0.192,0.234c-0.001,0.024-0.009,0.047-0.02,0.067l0.235,0.037c-0.008-0.023-0.013-0.047-0.012-0.072 c0.008-0.111,0.104-0.188,0.219-0.17s0.202,0.122,0.194,0.234c-0.001,0.024-0.009,0.049-0.018,0.069l0.235,0.036 c-0.008-0.023-0.012-0.048-0.011-0.072c0.007-0.112,0.105-0.188,0.219-0.171c0.116,0.02,0.204,0.124,0.197,0.236 c-0.002,0.025-0.008,0.048-0.019,0.068l0.238,0.039c-0.008-0.024-0.012-0.049-0.01-0.075c0.005-0.111,0.104-0.189,0.221-0.17 c0.115,0.018,0.203,0.124,0.197,0.236c-0.002,0.025-0.009,0.048-0.019,0.07l0.242,0.037c-0.004-0.017-0.009-0.035-0.008-0.053 c0.008-0.113,0.106-0.188,0.222-0.172c0.02,0.004,0.036,0.013,0.053,0.021l0.013-0.217c-0.01-0.001-0.018,0.001-0.027,0.001 c-0.117-0.02-0.206-0.124-0.199-0.237c0.007-0.112,0.105-0.189,0.222-0.172c0.011,0.001,0.017,0.007,0.026,0.01l0.014-0.214 c-0.011,0-0.019,0.003-0.027,0.001c-0.117-0.017-0.206-0.123-0.199-0.235c0.007-0.11,0.105-0.189,0.223-0.171 c0.008,0.001,0.017,0.007,0.026,0.008l0.011-0.214c-0.008,0-0.017,0.003-0.027,0.001c-0.114-0.016-0.204-0.12-0.197-0.232 c0.005-0.112,0.105-0.189,0.222-0.174c0.01,0.002,0.018,0.007,0.027,0.01l0.012-0.213c-0.011,0-0.018,0.001-0.028,0.001 c-0.116-0.017-0.203-0.121-0.198-0.232c0.007-0.112,0.105-0.19,0.222-0.175c0.01,0.001,0.019,0.007,0.026,0.01l0.014-0.213 c-0.011,0-0.02,0.003-0.028,0.002c-0.116-0.018-0.205-0.12-0.198-0.232s0.105-0.189,0.222-0.173 c0.011,0.001,0.017,0.005,0.026,0.008l0.014-0.213c-0.011,0-0.02,0.003-0.027,0.001c-0.117-0.014-0.206-0.119-0.199-0.23 c0.007-0.11,0.105-0.189,0.222-0.174c0.009,0.002,0.017,0.008,0.026,0.009l0.012-0.213c-0.009,0-0.018,0.003-0.028,0.002 c-0.114-0.015-0.203-0.117-0.196-0.229c0.005-0.111,0.105-0.189,0.22-0.176c0.011,0.002,0.02,0.008,0.027,0.01l0.013-0.214 c-0.011,0-0.018,0.003-0.028,0.002c-0.116-0.014-0.204-0.115-0.198-0.228c0.007-0.11,0.105-0.189,0.222-0.176 c0.011,0.001,0.019,0.007,0.026,0.01l0.014-0.212c-0.011,0-0.02,0.001-0.027,0.001c-0.117-0.014-0.206-0.115-0.199-0.227 C139.1,90.984,139.198,90.906,139.314,90.919z M138.558,96.088l-6.397-1.064l0.383-4.887l6.35,0.824L138.558,96.088z" fill="#FFFFFF"/>
-<path d="M129.281,93.9c-1.055,0.178-1.858,0.011-2.746-0.474 c0.877,0.404,2.153,0.47,3.562-0.041c3.479-1.262,4.393,0.537,4.393,0.537C132.681,92.495,130.582,93.706,129.281,93.9 L129.281,93.9z M129.35,94.872c-1.055,0.176-1.858,0.009-2.745-0.476c0.878,0.404,2.152,0.472,3.562-0.039 c3.478-1.263,4.395,0.537,4.395,0.537C132.75,93.465,130.652,94.677,129.35,94.872L129.35,94.872z M129.21,92.93 c-1.055,0.176-1.859,0.009-2.746-0.476c0.877,0.404,2.152,0.471,3.562-0.039c3.478-1.262,4.394,0.536,4.394,0.536 C132.609,91.523,130.511,92.736,129.21,92.93L129.21,92.93z M129.14,91.959c-1.054,0.178-1.859,0.011-2.746-0.474 c0.877,0.404,2.153,0.47,3.562-0.041c3.479-1.263,4.396,0.536,4.396,0.536C132.54,90.552,130.441,91.764,129.14,91.959 L129.14,91.959z" fill="#446D92" fill-opacity="0.2" />
-<path d="M135.787,99.213c0,0,0,4.979,0,6.008 s-0.686,0.688-0.686,0.688s-14.084-1.508-14.934-1.717c-0.741-0.184-0.687-0.686-0.687-0.686s0-4.979,0-5.666 s0.858-0.516,0.858-0.516s13.551,1.121,14.763,1.203C135.819,98.574,135.787,99.213,135.787,99.213L135.787,99.213z" fill="#0F001F" fill-opacity="0.25" />
-<linearGradient id="SVGID_13" gradientUnits="userSpaceOnUse" x1="119.33" y1="101.42" x2="135.64" y2="101.42">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#F5F9FC" offset="1"/>
+<path opacity="0.5" fill="url(#SVGID_41)" enable-background="new " d="M11.342,10.996c-1.053-0.688-2.038-1.258-3.6-1.303c-1.141,0.023-2.017,0.169-3.834,0.89c-0.027-0.014-0.061-0.053-0.052-0.102C5.431,9.81,6.683,9.52,7.72,9.529c1.572,0.016,2.662,0.675,3.693,1.367C11.393,10.957,11.358,10.981,11.342,10.996z"/>
+<path fill="#F83503" d="M13.361,4.149h0.002c0.027,0.018,0.033,0.051,0.029,0.083l-0.004,0.004c-0.01-0.013-0.019-0.024-0.037-0.043L13.361,4.149z"/>
+<path id="SVGID_46" fill="url(#SVGID_34)" d="M5.796,3.746L5.778,3.742c0.008-0.03,0.028-0.04,0.035-0.042l0.003-0.001C5.815,3.699,5.808,3.715,5.796,3.746z"/>
+<path opacity="0.66" fill="url(#SVGID_35)" enable-background="new " d="M13.351,4.194C11.639,3.036,9.725,2.14,5.796,3.746c0.008-0.033,0.017-0.045,0.017-0.045c3.95-1.632,5.839-0.709,7.549,0.449L13.351,4.194z"/>
+<radialGradient id="SVGID_44" gradientUnits="userSpaceOnUse" cx="11.55" cy="11.9" r="10.5">
+<stop stop-color="#D1E787" offset="0.01"/>
+<stop stop-color="#CEE583" offset="0.12"/>
+<stop stop-color="#C4DE76" offset="0.25"/>
+<stop stop-color="#B3D361" offset="0.38"/>
+<stop stop-color="#9CC443" offset="0.51"/>
+<stop stop-color="#7FB01D" offset="0.64"/>
+<stop stop-color="#7BAE19" offset="0.65"/>
+<stop stop-color="#578D19" offset="0.78"/>
+<stop stop-color="#366E1A" offset="0.92"/>
+<stop stop-color="#29621A" offset="1"/>
+</radialGradient>
+<path fill="url(#SVGID_44)" d="M21.92,5.337c-3.941,1.63-5.838,0.712-7.545-0.437l-1.943,6.744c1.705,1.155,3.766,2.104,7.545,0.414L21.92,5.337z"/>
+<linearGradient id="SVGID_45" gradientUnits="userSpaceOnUse" x1="14.38" y1="5.53" x2="21.96" y2="5.53">
+<stop stop-color="#D3ED89" offset="0"/>
+<stop stop-color="#5F811B" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_45)" d="M21.912,5.343c-3.943,1.63-5.83,0.713-7.537-0.437c0.004-0.016,0.012-0.044,0-0.072c1.707,1.148,3.641,2.074,7.58,0.445C21.924,5.298,21.92,5.319,21.912,5.343z"/>
+<polygon fill="#8CAC42" points="14.074,4.987 14.215,4.887 12.291,11.571 12.143,11.688 12.143,11.674 "/>
+<linearGradient id="SVGID_47" gradientUnits="userSpaceOnUse" x1="13.42" y1="8.27" x2="13.24" y2="8.22">
+<stop stop-color="#D3ED89" offset="0.4"/>
+<stop stop-color="#5F811B" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_47)" d="M12.436,11.646c-0.06-0.034-0.104-0.102-0.156-0.081l1.929-6.678c0.029-0.012,0.104-0.037,0.176,0.018L12.436,11.646z"/>
+<path fill="#5F811B" d="M14.232,4.844l-0.02,0.047l-0.141,0.103c0.012-0.045,0.119-0.121,0.151-0.145C14.23,4.844,14.232,4.844,14.232,4.844z"/>
+<linearGradient id="SVGID_48" gradientUnits="userSpaceOnUse" x1="14.38" y1="4.86" x2="14.21" y2="4.85">
+<stop stop-color="#7AA922" offset="0"/>
+<stop stop-color="#D3ED89" offset="0.2"/>
+<stop stop-color="#D3ED89" offset="0.53"/>
+<stop stop-color="#7AA922" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_48)" d="M14.375,4.901c-0.072-0.044-0.139-0.021-0.168-0.009c0.006-0.014,0.018-0.044,0.018-0.044c0.064-0.04,0.09-0.041,0.15-0.012C14.385,4.857,14.387,4.881,14.375,4.901z"/>
+<linearGradient id="SVGID_49" gradientUnits="userSpaceOnUse" x1="20.11" y1="8.8" x2="22.22" y2="8.8">
+<stop stop-color="#7AA922" offset="0.01"/>
+<stop stop-color="#1D4A20" offset="0.17"/>
+<stop stop-color="#26551B" offset="0.38"/>
+<stop stop-color="#7AA922" offset="1"/>
+</linearGradient>
+<polygon opacity="0.81" fill="url(#SVGID_49)" enable-background="new " points="20.107,12.089 22.057,5.375 22.217,5.502 20.256,12.219 "/>
+<path fill="#476E32" d="M20.293,12.268c0.006-0.038-0.033-0.069-0.033-0.069l1.953-6.702c0,0,0.031,0.028,0.039,0.046L20.293,12.268z"/>
+<path fill="#1D3419" d="M20.229,12.33c-1.053,0.479-2.049,0.725-2.975,0.805c-1.6,0.18-2.893-0.166-3.947-0.686c-0.411-0.188-0.781-0.401-1.112-0.624l0.017-0.013c0.334,0.224,0.697,0.443,1.095,0.638c1.072,0.491,2.412,0.817,3.947,0.685c0.873-0.099,1.838-0.356,2.906-0.829C20.191,12.329,20.229,12.33,20.229,12.33z"/>
+<linearGradient id="SVGID_50" gradientUnits="userSpaceOnUse" x1="20.13" y1="12.13" x2="19.96" y2="12.12">
+<stop stop-color="#7AA922" offset="0"/>
+<stop stop-color="#D3ED89" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_50)" d="M20.025,12.208c0,0-0.076-0.067-0.064-0.166c0.105-0.025,0.17,0.037,0.17,0.037S20.109,12.173,20.025,12.208z"/>
+<linearGradient id="SVGID_51" gradientUnits="userSpaceOnUse" x1="20.2" y1="12.14" x2="20.09" y2="12.26">
+<stop stop-color="#5F811B" offset="0"/>
+<stop stop-color="#26551B" offset="1"/>
 </linearGradient>
-<path d="M135.636,99c0,0,0,4.979,0,6.008s-0.686,0.688-0.686,0.688s-14.085-1.508-14.935-1.717 c-0.741-0.184-0.687-0.687-0.687-0.687s0-4.979,0-5.665c0-0.688,0.858-0.516,0.858-0.516s13.552,1.121,14.764,1.202 C135.668,98.362,135.636,99,135.636,99L135.636,99z" fill="url(#SVGID_13)"/>
-<path d="M111.617,89.262c-0.063,0-0.123,0.002-0.185,0.002v-2.625 l30.041,1.202v9.104C134.069,92.074,123.71,89.262,111.617,89.262L111.617,89.262z" fill="#FFFFFF" fill-opacity="0.25" />
-<linearGradient id="SVGID_14" gradientUnits="userSpaceOnUse" x1="148.5" y1="107.51" x2="106.79" y2="107.51">
-<stop stop-color="#FCD959" offset="0"/>
-<stop stop-color="#FBC64A" offset="0.21"/>
-<stop stop-color="#FBCB4D" offset="0.24"/>
-<stop stop-color="#FCDB58" offset="0.35"/>
-<stop stop-color="#FCE15C" offset="0.42"/>
-<stop stop-color="#FBDC5B" offset="0.53"/>
-<stop stop-color="#F9CE55" offset="0.69"/>
-<stop stop-color="#F5B84C" offset="0.88"/>
-<stop stop-color="#F5B84C" offset="0.88"/>
-<stop stop-color="#FBDB5C" offset="1"/>
+<path fill="url(#SVGID_51)" d="M20.121,12.076l0.139,0.125c0,0-0.02,0.077-0.105,0.115l-0.146-0.125C20.096,12.155,20.121,12.076,20.121,12.076z"/>
+<linearGradient id="SVGID_52" gradientUnits="userSpaceOnUse" x1="12.36" y1="12.35" x2="20.04" y2="12.35">
+<stop stop-color="#7AA922" offset="0"/>
+<stop stop-color="#D3ED89" offset="0.4"/>
+<stop stop-color="#7AA922" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_52)" d="M19.977,12.036c-0.014,0.099,0.061,0.171,0.061,0.171c-3.939,1.631-5.971,0.673-7.679-0.484c0.031-0.021,0.037-0.021,0.055-0.093C14.117,12.787,16.697,13.597,19.977,12.036z"/>
+<path fill="#26551B" d="M12.212,11.819l0.147-0.099c1.707,1.102,3.723,2.05,7.66,0.467l0.141,0.125C16.381,13.979,13.965,13.051,12.212,11.819z"/>
+<path fill="#5F811B" d="M20.293,12.268c-0.018,0.036-0.053,0.058-0.064,0.063c-0.004,0.001-0.004,0.001-0.004,0.001s-0.027,0.005-0.064-0.021c0.078-0.041,0.1-0.127,0.1-0.127S20.305,12.224,20.293,12.268z"/>
+<path fill="#26551B" d="M12.218,11.818l-0.018,0.013c0,0-0.096-0.052-0.06-0.157C12.15,11.778,12.218,11.818,12.218,11.818z"/>
+<linearGradient id="SVGID_53" gradientUnits="userSpaceOnUse" x1="12.31" y1="11.77" x2="12.19" y2="11.63">
+<stop stop-color="#1D3A19" offset="0"/>
+<stop stop-color="#26551B" offset="0.1"/>
+<stop stop-color="#7AA922" offset="0.65"/>
+<stop stop-color="#D3ED89" offset="1"/>
+</linearGradient>
+<path fill="url(#SVGID_53)" d="M12.143,11.674l0.142-0.112c-0.008,0.107,0.084,0.152,0.084,0.152l-0.143,0.11C12.225,11.826,12.134,11.781,12.143,11.674z"/>
+<linearGradient id="SVGID_54" gradientUnits="userSpaceOnUse" x1="12.31" y1="11.55" x2="12.4" y2="11.71">
+<stop stop-color="#5F811B" offset="0"/>
+<stop stop-color="#7AA922" offset="0.4"/>
+<stop stop-color="#5F811B" offset="0.8"/>
+</linearGradient>
+<path fill="url(#SVGID_54)" d="M12.28,11.562c0.048-0.017,0.092,0.035,0.152,0.083c-0.021,0.069-0.035,0.058-0.068,0.078C12.332,11.704,12.271,11.651,12.28,11.562z"/>
+<linearGradient id="SVGID_55" gradientUnits="userSpaceOnUse" x1="22.13" y1="5.44" x2="22.15" y2="5.36">
+<stop stop-color="#5B7F30" offset="0"/>
+<stop stop-color="#D3ED89" offset="1"/>
 </linearGradient>
-<path d="M148.35,108.015c-1.304-3.304-4.799-4.506-8.053-4.504c-0.684,0-1.358,0.053-2.004,0.15 c-4.305,0.654-8.352,2.646-12.408,4.011c-3.642,1.226-7.412,1.98-11.248,1.979c-0.335,0-0.67-0.006-1.005-0.016 c-1.8-0.059-4.04-0.284-5.268-1.639c-0.478-0.524-0.672-1.141-0.673-1.784c0-0.816,0.321-1.678,0.791-2.384 c0.037-0.055,0.077-0.111,0.116-0.169c0,0,0.084-0.144-0.008-0.235c-0.091-0.092-0.234-0.001-0.234-0.001 c-1.054,0.749-1.559,2.021-1.56,3.266c0,0.29,0.027,0.577,0.082,0.858c0.313,1.63,1.542,2.705,3.01,3.265 c1.509,0.575,3.156,0.716,4.728,0.788c0.446,0.02,0.893,0.03,1.34,0.03c1.691,0,3.382-0.147,5.046-0.444 c4.259-0.762,8.247-2.509,12.264-3.95c2.519-0.903,5.514-1.979,8.329-1.979c1.125,0,2.222,0.172,3.253,0.59 c1.232,0.5,2.326,1.347,3.212,2.345c0,0,0.061,0.125,0.217,0.037C148.434,108.143,148.35,108.015,148.35,108.015z" fill="url(#SVGID_14)"/>
+<path opacity="0.72" fill="url(#SVGID_55)" enable-background="new " d="M22.229,5.432c0.002,0.026-0.016,0.067-0.016,0.067l-0.152-0.123c0,0,0.021-0.05,0.01-0.087C22.123,5.312,22.221,5.417,22.229,5.432z"/>
+<linearGradient id="SVGID_56" gradientUnits="userSpaceOnUse" x1="21.97" y1="6.52" x2="14.26" y2="4.3">
+<stop stop-color="#1D3419" offset="0"/>
+<stop stop-color="#26551B" offset="0.23"/>
+<stop stop-color="#7AA922" offset="1"/>
+</linearGradient>
+<path opacity="0.33" fill="url(#SVGID_56)" enable-background="new " d="M22.225,5.426c-0.029-0.041-0.074-0.074-0.109-0.109c-0.068-0.06-0.15-0.046-0.17-0.035l-0.002,0.001c-3.932,1.623-5.862,0.698-7.568-0.449c0.004,0.006,0.004,0.016,0.004,0.023c0-0.007,0-0.017-0.004-0.023c-0.062-0.028-0.086-0.027-0.15,0.012C14.199,4.863,14.137,4.91,14.1,4.95C14.76,5.503,17.545,7.688,22.225,5.426z M14.375,4.901L14.375,4.901L14.375,4.901C14.375,4.901,14.375,4.901,14.375,4.901L14.375,4.901c0.004-0.009,0.004-0.017,0.008-0.025C14.379,4.885,14.379,4.895,14.375,4.901z"/>
+<linearGradient id="SVGID_57" gradientUnits="userSpaceOnUse" x1="21.1" y1="8.73" x2="20.93" y2="8.68">
+<stop stop-color="#5F811B" offset="0"/>
+<stop stop-color="#75C145" offset="1"/>
+</linearGradient>
+<path opacity="0.72" fill="url(#SVGID_57)" enable-background="new " d="M19.959,12.052l1.949-6.711c0.105-0.019,0.156,0.042,0.156,0.042l-1.944,6.695C20.121,12.076,20.041,12.017,19.959,12.052z"/>
+<linearGradient id="SVGID_58" gradientUnits="userSpaceOnUse" x1="21.91" y1="5.41" x2="22.26" y2="5.41">
+<stop stop-color="#D3ED89" offset="0"/>
+<stop stop-color="#5F811B" offset="1"/>
+</linearGradient>
+<path opacity="0.6" fill="url(#SVGID_58)" enable-background="new " d="M21.912,5.343c0.006-0.025,0.01-0.037,0.033-0.061c0.02-0.011,0.102-0.025,0.17,0.035c0.064,0.062,0.166,0.131,0.137,0.225c-0.01-0.019-0.039-0.043-0.039-0.043l-0.148-0.118C22.064,5.381,22.016,5.324,21.912,5.343z"/>
+<linearGradient id="SVGID_59" gradientUnits="userSpaceOnUse" x1="21.94" y1="6.6" x2="14.24" y2="4.39">
+<stop stop-color="#93BF81" offset="0"/>
+<stop stop-color="#26551B" offset="0.23"/>
+<stop stop-color="#BDE256" offset="1"/>
+</linearGradient>
+<path opacity="0.3" fill="url(#SVGID_59)" enable-background="new " d="M14.101,4.952c-0.011,0.013-0.021,0.023-0.022,0.034l-0.002,0.002l-0.01,0.023c0.594,0.501,3.408,2.813,8.189,0.486c-0.003-0.025-0.014-0.049-0.031-0.071C17.545,7.688,14.76,5.503,14.101,4.952z"/>
+<path opacity="0.72" fill="url(#SVGID_55)" enable-background="new " d="M22.229,5.432c0.002,0.026-0.016,0.067-0.016,0.067l-0.152-0.123c0,0,0.021-0.05,0.01-0.087C22.123,5.312,22.221,5.417,22.229,5.432z"/>
+<path opacity="0.6" fill="url(#SVGID_58)" enable-background="new " d="M21.912,5.343c0.006-0.025,0.01-0.037,0.033-0.061c0.02-0.011,0.104-0.025,0.17,0.035c0.064,0.062,0.17,0.129,0.138,0.226c-0.011-0.02-0.038-0.044-0.038-0.044l-0.15-0.118C22.064,5.381,22.016,5.324,21.912,5.343z"/>
 </svg>
\ No newline at end of file
--- a/emailservices/emailframework/data/yahoo.svg	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailframework/data/yahoo.svg	Thu Jan 07 12:38:38 2010 +0200
@@ -1,101 +1,45 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="44" height="44" viewBox="36.537 17.377 44 44">
-<rect fill="none" height="44" width="44" x="36.537" y="17.377"/>
-<linearGradient id="SVGID_1" gradientUnits="userSpaceOnUse" x1="49.26" y1="25.84" x2="49.26" y2="42.11">
-<stop stop-color="#A6A6A6" offset="0"/>
-<stop stop-color="#888888" offset="0.61"/>
-<stop stop-color="#737373" offset="1"/>
-</linearGradient>
-<path d="M59.806,41.027l0.178-14.559l-0.026-0.026c-0.103-0.478-0.597-0.585-0.597-0.585H39.244 c0,0-0.623,0.075-0.637,0.771c-0.003,0.188-0.069,14.318-0.069,14.318c-0.001,0.019-0.003,0.095,0.007,0.2 c0.018,0.181,0.075,0.453,0.24,0.678c0.109,0.148,0.301,0.326,0.601,0.326l19.55,0.002c0.283,0,0.475-0.163,0.586-0.303 C59.778,41.532,59.803,41.109,59.806,41.027z" fill="url(#SVGID_1)"/>
-<linearGradient id="SVGID_2" gradientUnits="userSpaceOnUse" x1="49.23" y1="26.81" x2="49.23" y2="41.55">
-<stop stop-color="#ACC7DD" offset="0"/>
-<stop stop-color="#EDF7FF" offset="1"/>
-</linearGradient>
-<path d="M59.312,26.748l-0.117,14.193c0,0-0.012,0.545-0.401,0.545c-2.61,0-18.931-0.003-19.249-0.003 c-0.426,0-0.393-0.621-0.393-0.621l0.126-14.114H59.312" fill="url(#SVGID_2)"/>
-<g fill-opacity="0.33" stroke-opacity="0.33">
-<polygon points="58.848,40.986 40.23,40.684 47.141,32.271 52.228,32.271 "/>
-</g>
-<g fill-opacity="0.33" stroke-opacity="0.33">
-<polygon points="58.125,40.685 39.498,40.985 46.292,32.271 51.379,32.271 "/>
-</g>
-<linearGradient id="SVGID_3" gradientUnits="userSpaceOnUse" x1="49.17" y1="32.61" x2="49.17" y2="43.16">
-<stop stop-color="#D1E2EE" offset="0"/>
-<stop stop-color="#E4F3FF" offset="1"/>
-</linearGradient>
-<polygon fill="url(#SVGID_3)" points="58.848,41.323 39.498,41.322 46.717,32.608 51.803,32.608 "/>
-<path d="M57.54,41.097c0,0-3.083-0.301-8.173-0.301 s-8.184,0.301-8.184,0.301" fill="#FFFFFF" fill-opacity="0.8" />
-<path d="M39.498,41.322c0,0,5.426-5.472,6.864-7.623l-0.379-0.135 L39.498,41.322z" fill="#FFFFFF" fill-opacity="0.6" />
-<path d="M58.855,41.322l-6.354-7.763l-0.383,0.135 C53.491,35.847,58.855,41.322,58.855,41.322z" fill="#FFFFFF" fill-opacity="0.6" />
-<path d="M39.544,41.483c-0.426,0-0.393-0.621-0.393-0.621 l0.126-14.114h0.447L39.54,40.862c0,0-0.036,0.621,0.39,0.621H39.544L39.544,41.483z" fill="#FFFFFF" fill-opacity="0.4" />
-<path d="M58.407,41.486c0.149,0,0.279,0,0.386,0 c0.39,0,0.401-0.545,0.401-0.545l0.118-14.193h-0.447l-0.059,14.193C58.807,40.941,58.797,41.486,58.407,41.486z" fill="#FFFFFF" fill-opacity="0.4" />
-<g fill-opacity="0.4" stroke-opacity="0.4">
-<path d="M39.278,26.75c0,0,8.156,10.261,9.93,10.261S59.312,26.75,59.312,26.75H39.278z"/>
-</g>
-<linearGradient id="SVGID_4" gradientUnits="userSpaceOnUse" x1="49.29" y1="35.82" x2="49.29" y2="26.75">
-<stop stop-color="#EEEEEE" offset="0"/>
-<stop stop-color="#ECECEC" offset="0.02"/>
-<stop stop-color="#C7C7C7" offset="0.31"/>
-<stop stop-color="#ACACAC" offset="0.58"/>
-<stop stop-color="#9C9C9C" offset="0.82"/>
-<stop stop-color="#969696" offset="1"/>
-</linearGradient>
-<path d="M59.312,26.748H39.277c0,0,8.403,9.077,9.935,9.077 C50.743,35.825,59.312,26.748,59.312,26.748z" fill="url(#SVGID_4)"/>
-<linearGradient id="SVGID_5" gradientUnits="userSpaceOnUse" x1="49.29" y1="35.33" x2="49.29" y2="26.52">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#D5E9F7" offset="1"/>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" baseProfile="tiny" height="44px" version="1.1" viewBox="0 0 44 44" width="44px" x="0px" y="0px">
+<radialGradient cx="16.6729" cy="32.6836" gradientTransform="matrix(1 0 0 0.1855 0 26.6218)" gradientUnits="userSpaceOnUse" id="SVGID_1_" r="12.1104">
+<stop offset="0" style="stop-color:#636466"/>
+<stop offset="0.4817" style="stop-color:#636466"/>
+<stop offset="1" style="stop-color:#636466;stop-opacity:0"/>
+</radialGradient>
+<path d="M16.757,35.012c-7.248,0-12.307-1.365-12.307-2.553s5.06-1.479,12.307-1.479  c7.246,0.002,12.306,0.291,12.306,1.479S24.003,35.012,16.757,35.012z" fill="url(#SVGID_1_)"/>
+<radialGradient cx="36.9902" cy="32.4746" gradientTransform="matrix(1 0 0 0.2569 0 24.1333)" gradientUnits="userSpaceOnUse" id="SVGID_2_" r="4.0342">
+<stop offset="0" style="stop-color:#636466"/>
+<stop offset="0.3636" style="stop-color:#636466"/>
+<stop offset="1" style="stop-color:#636466;stop-opacity:0"/>
+</radialGradient>
+<path d="M37.045,31.314c1.98,0.074,3.793,0.375,3.979,1.062c0,0.702-1.664,1.167-3.906,1.108  c-2.961,0-4.122-0.41-4.159-1.053C32.906,31.643,34.661,31.229,37.045,31.314z" fill="url(#SVGID_2_)"/>
+<linearGradient gradientTransform="matrix(1 0 0 1 -144.0156 -532.127)" gradientUnits="userSpaceOnUse" id="SVGID_3_" x1="160.8359" x2="160.8359" y1="542.251" y2="562.5588">
+<stop offset="0" style="stop-color:#88449A"/>
+<stop offset="0.231" style="stop-color:#824094"/>
+<stop offset="0.5333" style="stop-color:#723684"/>
+<stop offset="0.8737" style="stop-color:#582569"/>
+<stop offset="1" style="stop-color:#4C1E5D"/>
 </linearGradient>
-<path d="M59.103,26.524c-0.118,0-19.495,0-19.611,0c-0.238,0-0.214,0.224-0.214,0.224 s8.581,8.578,9.939,8.578s10.095-8.578,10.095-8.578S59.339,26.524,59.103,26.524z" fill="url(#SVGID_5)"/>
-<path d="M59.103,26.524c-0.118,0-19.495,0-19.611,0 c-0.238,0-0.214,0.168-0.214,0.168s8.581,6.449,9.939,6.449s10.095-6.449,10.095-6.449S59.339,26.524,59.103,26.524z" fill="#FFFFFF" fill-opacity="0.8" />
-<linearGradient id="SVGID_6" gradientUnits="userSpaceOnUse" x1="58.51" y1="35.84" x2="58.51" y2="52.9">
-<stop stop-color="#8418A8" offset="0"/>
-<stop stop-color="#4A005C" offset="1"/>
-</linearGradient>
-<path d="M58.512,52.899c-6.571,0-11.161-3.509-11.161-8.533c0-5.022,4.589-8.529,11.161-8.529 c6.57,0,11.158,3.507,11.158,8.529C69.671,49.39,65.082,52.899,58.512,52.899L58.512,52.899z" fill="url(#SVGID_6)"/>
-<linearGradient id="SVGID_7" gradientUnits="userSpaceOnUse" x1="72.51" y1="48.54" x2="72.51" y2="52.62">
-<stop stop-color="#8418A8" offset="0"/>
-<stop stop-color="#4A005C" offset="1"/>
-</linearGradient>
-<polygon fill="url(#SVGID_7)" points="74.239,52.623 73.57,52.542 71.01,52.228 70.342,52.145 70.423,51.477 70.701,49.205 70.783,48.537 71.452,48.619 74.014,48.933 74.683,49.014 74.6,49.683 74.32,51.955 "/>
-<linearGradient id="SVGID_8" gradientUnits="userSpaceOnUse" x1="74.11" y1="36" x2="74.11" y2="47.87">
-<stop stop-color="#8418A8" offset="0"/>
-<stop stop-color="#4A005C" offset="1"/>
-</linearGradient>
-<polygon fill="url(#SVGID_8)" points="74.252,47.871 73.66,47.798 71.784,47.568 71.193,47.495 71.192,46.901 71.175,36.764 71.174,35.999 71.934,36.095 76.29,36.644 77.043,36.74 76.858,37.476 74.396,47.292 "/>
-<linearGradient id="SVGID_9" gradientUnits="userSpaceOnUse" x1="58.51" y1="36.51" x2="58.51" y2="52.23">
-<stop stop-color="#B340D9" offset="0"/>
-<stop stop-color="#7B0099" offset="1"/>
-</linearGradient>
-<path d="M58.513,52.226c-6.175,0-10.487-3.231-10.487-7.86c0-4.624,4.312-7.855,10.487-7.855 c6.173,0,10.485,3.231,10.485,7.855C68.998,48.995,64.686,52.226,58.513,52.226z" fill="url(#SVGID_9)"/>
-<linearGradient id="SVGID_10" gradientUnits="userSpaceOnUse" x1="72.51" y1="49.29" x2="72.51" y2="51.87">
-<stop stop-color="#B340D9" offset="0"/>
-<stop stop-color="#7B0099" offset="1"/>
+<path d="M16.821,33.165c-9.292,0-15.779-4.858-15.779-11.826c0-6.957,6.487-11.819,15.779-11.819  c9.289,0,15.777,4.862,15.777,11.819C32.6,28.305,26.109,33.165,16.821,33.165z" fill="url(#SVGID_3_)"/>
+<linearGradient gradientTransform="matrix(1 0 0 1 -144.0156 -532.127)" gradientUnits="userSpaceOnUse" id="SVGID_4_" x1="180.7793" x2="180.7793" y1="541.584" y2="566.3591">
+<stop offset="0" style="stop-color:#88449A"/>
+<stop offset="0.2697" style="stop-color:#844296"/>
+<stop offset="0.517" style="stop-color:#7A3B8B"/>
+<stop offset="0.7554" style="stop-color:#672F79"/>
+<stop offset="0.9871" style="stop-color:#4E1F5F"/>
+<stop offset="1" style="stop-color:#4C1E5D"/>
 </linearGradient>
-<polygon fill="url(#SVGID_10)" points="73.652,51.873 71.092,51.558 71.37,49.288 73.932,49.601 "/>
-<linearGradient id="SVGID_11" gradientUnits="userSpaceOnUse" x1="74.03" y1="36.76" x2="74.03" y2="47.13">
-<stop stop-color="#B340D9" offset="0"/>
-<stop stop-color="#7B0099" offset="1"/>
-</linearGradient>
-<polygon fill="url(#SVGID_11)" points="71.849,36.762 71.865,46.899 73.743,47.129 76.205,37.312 "/>
-<g fill-opacity="0.66" stroke-opacity="0.66">
-<linearGradient id="SVGID_12" gradientUnits="userSpaceOnUse" x1="58.51" y1="36.66" x2="58.51" y2="48.71">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#8A26A3" offset="1"/>
+<polygon fill="url(#SVGID_4_)" points="38.678,32.711 34.385,32.184 34.85,28.375 39.143,28.902 "/>
+<linearGradient gradientTransform="matrix(1 0 0 1 -144.0156 -532.127)" gradientUnits="userSpaceOnUse" id="SVGID_5_" x1="183.3213" x2="183.3213" y1="541.585" y2="566.3589">
+<stop offset="0" style="stop-color:#88449A"/>
+<stop offset="0.231" style="stop-color:#824094"/>
+<stop offset="0.5333" style="stop-color:#723684"/>
+<stop offset="0.8737" style="stop-color:#582569"/>
+<stop offset="1" style="stop-color:#4C1E5D"/>
 </linearGradient>
-<path d="M58.513,48.711c-4.936,0-8.382-2.479-8.382-6.028c0-3.548,3.447-6.026,8.382-6.026 c4.934,0,8.38,2.479,8.38,6.026C66.893,46.232,63.446,48.711,58.513,48.711L58.513,48.711z" fill="url(#SVGID_12)"/>
-<linearGradient id="SVGID_13" gradientUnits="userSpaceOnUse" x1="72.33" y1="49.81" x2="72.33" y2="50.82">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#8A26A3" offset="1"/>
-</linearGradient>
-<polygon fill="url(#SVGID_13)" points="72.93,50.822 71.616,50.666 71.725,49.805 73.038,49.962 "/>
-<linearGradient id="SVGID_14" gradientUnits="userSpaceOnUse" x1="73.3" y1="37.3" x2="73.3" y2="45.41">
-<stop stop-color="#FFFFFF" offset="0"/>
-<stop stop-color="#8A26A3" offset="1"/>
-</linearGradient>
-<polygon fill="url(#SVGID_14)" points="72.375,45.413 72.271,45.4 72.258,37.304 74.344,37.567 "/>
-</g>
-<path fill-opacity="0.25" d="M62.098,49.658l-0.682-0.047c-0.188-0.013-1.543-0.013-1.988-0.013h-0.654h-0.525 c-0.213,0-0.614,0.01-1.052,0.02c-0.543,0.013-1.145,0.026-1.532,0.026c-0.105,0-0.197-0.001-0.268-0.003l-0.777-0.023 l0.134-0.766l0.102-0.579l0.09-0.516l0.521-0.04c0.075-0.006,0.201-0.007,0.357-0.007c0.174-0.001,0.627-0.002,0.901-0.041 c-0.001-0.046-0.001-0.093-0.002-0.141c-0.002-0.129-0.004-0.284-0.004-0.477v-0.386c0-0.144,0-0.393-0.025-0.633 c-0.372-0.597-2.491-3.226-3.205-3.883c-0.183-0.029-0.515-0.071-0.751-0.101c-0.443-0.057-0.724-0.093-0.883-0.127l-0.518-0.111 l-0.015-0.528l-0.015-0.522l-0.013-0.427l0.38-0.193c0.179-0.09,0.375-0.105,0.775-0.105c0.169,0,0.375,0.003,0.605,0.008 l0.096,0.001c0.258,0.004,0.547,0.008,0.849,0.008c0.297,0,0.607-0.004,0.916-0.016c0.274-0.01,0.655-0.015,1.06-0.015 c0.776,0,2.015,0.02,2.273,0.049l0.686,0.08l-0.097,0.684l-0.065,0.462l-0.063,0.448l-0.44,0.109 c-0.165,0.043-0.426,0.063-0.862,0.091c0.388,0.525,0.803,1.06,1.163,1.524c0.16,0.206,0.31,0.4,0.445,0.576 c0.103-0.084,0.218-0.177,0.348-0.282c0.193-0.157,0.482-0.393,0.752-0.625c-0.162-0.021-0.29-0.035-0.341-0.037l-0.54-0.021 l-0.114-0.532l-0.109-0.594l-0.124-0.681l0.683-0.105c0.099-0.016,0.26-0.029,0.771-0.029c0.331,0,0.736,0.006,1.125,0.012 c0.352,0.005,0.69,0.01,0.946,0.01c1.148,0,2.266,0.004,2.661,0.036l1.162,0.096l-0.663,0.959l-0.386,0.56l-0.177,0.256 l-0.31,0.031c-0.148,0.016-0.897,0.178-1.18,0.239l-0.167,0.036c-0.525,0.284-2.853,2.136-3.216,2.659 c-0.023,0.149-0.037,0.368-0.037,0.589l-0.024,0.509c0.001,0.117,0.022,0.308,0.049,0.499c0.126,0.001,0.259,0.001,0.369,0.002 c0.642,0.002,0.941,0.007,1.112,0.035l0.595,0.099l-0.032,0.603l-0.032,0.607L62.098,49.658L62.098,49.658z" fill="#A02DBD"/>
-<path d="M64.631,42.427c-0.228,0.023-1.172,0.234-1.489,0.302c-0.34,0.091-3.445,2.489-3.649,3.08 c-0.045,0.204-0.067,0.517-0.067,0.812l-0.022,0.476c0,0.341,0.094,0.888,0.14,1.184c0.203,0.045,1.681,0.005,1.953,0.051 l-0.033,0.608c-0.266-0.019-2.142-0.014-3.214-0.014c-0.545,0-2.293,0.059-2.831,0.043l0.101-0.579 c0.295-0.023,1.514,0.053,1.783-0.23c0.133-0.142,0.091-0.291,0.091-1.107v-0.385c0-0.183,0-0.521-0.045-0.839 c-0.113-0.34-2.849-3.755-3.552-4.3c-0.204-0.067-1.482-0.195-1.799-0.264l-0.015-0.522c0.157-0.079,1.579,0.021,2.959-0.031 c0.906-0.033,2.976,0,3.23,0.03l-0.065,0.46c-0.273,0.069-1.582,0.094-1.922,0.185c0.883,1.313,2.282,3.007,2.735,3.664 c0.25-0.362,2.442-1.87,2.509-2.391c-0.341-0.068-1.467-0.231-1.647-0.231l-0.108-0.594c0.309-0.048,1.932,0,2.738,0 c0.696,0,2.184,0,2.606,0.035L64.631,42.427z" fill="#FFFFFF"/>
-<polygon fill="#7B0099" points="76.299,48.863 75.897,48.863 75.897,48.634 76.949,48.634 76.949,48.863 76.547,48.863 76.547,49.935 76.299,49.935 "/>
-<polygon fill="#7B0099" points="77.229,48.634 77.493,48.634 77.887,49.251 78.28,48.634 78.537,48.634 78.537,49.935 78.297,49.935 78.297,49.01 77.896,49.634 77.87,49.634 77.469,49.01 77.469,49.935 77.229,49.935 "/>
-</svg>
\ No newline at end of file
+<polygon fill="url(#SVGID_5_)" points="35.654,8.989 35.68,25.984 38.83,26.366 42.957,9.911 "/>
+<path d="M26.029,18.421c-0.348,0.036-1.766,0.354-2.242,0.456c-0.51,0.134-5.184,3.747-5.49,4.635  c-0.07,0.307-0.103,0.775-0.103,1.221l-0.036,0.715c0,0.516,0.143,1.335,0.211,1.779c0.304,0.067,2.529,0.008,2.94,0.076  l-0.051,0.916c-0.401-0.027-3.223-0.019-4.836-0.019c-0.821,0-3.452,0.089-4.259,0.062l0.151-0.869  c0.445-0.033,2.278,0.078,2.684-0.348c0.201-0.211,0.135-0.436,0.135-1.666V24.8c0-0.276,0-0.786-0.066-1.263  c-0.172-0.512-4.286-5.651-5.346-6.471c-0.306-0.101-2.229-0.291-2.708-0.394L6.99,15.885c0.241-0.118,2.377,0.031,4.455-0.048  c1.363-0.053,4.479,0,4.862,0.045l-0.098,0.691c-0.412,0.107-2.38,0.144-2.894,0.281c1.329,1.976,3.436,4.522,4.116,5.513  c0.377-0.548,3.674-2.815,3.778-3.602C20.695,18.663,19,18.42,18.73,18.42l-0.166-0.893c0.465-0.072,2.909,0,4.122,0  c1.047,0,3.285,0,3.924,0.053L26.029,18.421z" fill="#FFFFFF"/>
+<polygon fill="#DCBCDA" fill-opacity="0.5" points="36.04,11.116 36.09,9.583 42.396,10.301 41.98,11.645   41.928,11.07 36.296,10.396 " stroke-opacity="0.5"/>
+<path d="M30.77,16.643c-2.438-3.875-7.81-6.567-14.048-6.567  c-6.238,0-11.613,2.692-14.05,6.567c3.298-2.664,8.366-4.371,14.05-4.371C22.404,12.272,27.473,13.979,30.77,16.643z" fill="#DCBCDA" fill-opacity="0.5" stroke-opacity="0.5"/>
+<rect fill="none" height="44" width="44"/>
+</svg>
--- a/emailservices/emailframework/inc/emailversionnumbers.hrh	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailframework/inc/emailversionnumbers.hrh	Thu Jan 07 12:38:38 2010 +0200
@@ -12,7 +12,7 @@
 * Contributors:
 *
 * Description : Common email version number definitions
-* Version     : %version: 9 %
+* Version     : %version: 10.1.1 %
 *
 */
 
--- a/emailservices/emailserver/cmailhandlerplugin/group/cmailhandlerplugin.mmp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/group/cmailhandlerplugin.mmp	Thu Jan 07 12:38:38 2010 +0200
@@ -16,7 +16,7 @@
 */
 
 #include <platform_paths.hrh>
-#include <data_caging_paths.hrh> // Needed for ECOM_RESOURCE_DIR
+#include <data_caging_paths.hrh> // Needed for APP_RESOURCE_DIR
 
 #include "../../../../inc/emailversionnumbers.hrh" // KEmailBinaryVersionNumber
 
@@ -69,7 +69,7 @@
 #if !defined(FF_CMAIL_INTEGRATION)
 START RESOURCE                  ../data/emailwidget.rss
 HEADER
-TARGETPATH                      ECOM_RESOURCE_DIR
+TARGETPATH                      APP_RESOURCE_DIR
 LANGUAGE_IDS
 END
 #endif // FF_CMAIL_INTEGRATION
--- a/emailservices/emailserver/cmailhandlerplugin/inc/cmailcpsifconsts.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/inc/cmailcpsifconsts.h	Thu Jan 07 12:38:38 2010 +0200
@@ -34,9 +34,11 @@
 _LIT( KAt,"@");
 _LIT( KDot,".");
 _LIT( KMifPrefix, "mif(");
-_LIT( KMifPath, "z:\\resource\\apps\\cmailhandlerplugin.mif");
+// Mif file name and path, drive letter need to be parsed run time
+_LIT( KMifPath, "\\resource\\apps\\cmailhandlerplugin.mif");
 _LIT( KSpace, " ");
-_LIT( KResourceFile, "z:emailwidget.rsc" );
+// Resource file name and path, drive letter need to be parsed run time
+_LIT( KResourceFile, "\\resource\\apps\\emailwidget.rsc" );
 _LIT( KDissociated,"0");
 
 //
--- a/emailservices/emailserver/cmailhandlerplugin/inc/cmailcpssettings.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/inc/cmailcpssettings.h	Thu Jan 07 12:38:38 2010 +0200
@@ -126,7 +126,7 @@
     /**
      * 
      */
-    void GetContentId( TInt aId, TDes16& aValue );
+    TInt GetContentId( TInt aMailboxId, TInt aId, TDes16& aValue );
     
     /**
      * 
--- a/emailservices/emailserver/cmailhandlerplugin/inc/cmailwidgetcenrepkeys.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/inc/cmailwidgetcenrepkeys.h	Thu Jan 07 12:38:38 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -11,88 +11,38 @@
 *
 * Contributors:
 *
-* Description: Constants for cmailhandlerplugin Central Repository keys. 
+* Description: Constants for cmailhandlerplugin Central Repository keys.
 *
 */
 
 
-#ifndef CMAILCENREPKEYS_H
-#define CMAILCENREPKEYS_H
+#ifndef CMAILWIDGETCENREPKEYS_H
+#define CMAILWIDGETCENREPKEYS_H
 
 #include <e32std.h>
 
+// Repository Uid
+const TUid KCRUidCmailWidget                      = {0x2001E272};
+
 const TUint32 KCMailMailboxIdBase                 = 0x00000100;
 const TUint32 KCMailPluginIdBase                  = 0x00000200;
 const TUint32 KCMailWidgetContentIdBase           = 0x00000300;
 
-// Repository Uid
-const TUid KCRUidCmailWidget                      = {0x2001E272};
-
-// Keys
-
 // Constants for observing the whole repository
 const TUint32 KCmailPartialKey                    = 0x00000000;
 const TUint32 KCmailMask                          = 0x00000000;
 
-// Constants that define/specify mailbox entries
+// Constants that define internal mailbox entries
 const TUint32 KCmailPartialKeyRange               = 0x00000100;
-const TUint32 KCmailRangeMask                     = 0x00000f00;
-
-const TUint32 KCMailMailbox1                      = 0x100;
-const TUint32 KCMailMailbox2                      = 0x101;   
-const TUint32 KCMailMailbox3                      = 0x102;
-const TUint32 KCMailMailbox4                      = 0x103;
-const TUint32 KCMailMailbox5                      = 0x104;   
-const TUint32 KCMailMailbox6                      = 0x105;
-const TUint32 KCMailMailbox7                      = 0x106;
-const TUint32 KCMailMailbox8                      = 0x107;   
-const TUint32 KCMailMailbox9                      = 0x108;
-const TUint32 KCMailMailbox10                     = 0x109;
-const TUint32 KCMailMailbox11                     = 0x10a;   
-const TUint32 KCMailMailbox12                     = 0x10b;
-const TUint32 KCMailMailbox13                     = 0x10c;
-const TUint32 KCMailMailbox14                     = 0x10d;   
-const TUint32 KCMailMailbox15                     = 0x10e;
-const TUint32 KCMailMailbox16                     = 0x10f;
-const TUint32 KCMailMailbox17                     = 0x110;   
-const TUint32 KCMailMailbox18                     = 0x111;
+const TUint32 KCmailRangeMask                     = 0x0000ff00;
 
-const TUint32 KCMailPlugin1                       = 0x200;
-const TUint32 KCMailPlugin2                       = 0x201;   
-const TUint32 KCMailPlugin3                       = 0x202;
-const TUint32 KCMailPlugin4                       = 0x203;
-const TUint32 KCMailPlugin5                       = 0x204;   
-const TUint32 KCMailPlugin6                       = 0x205;
-const TUint32 KCMailPlugin7                       = 0x206;
-const TUint32 KCMailPlugin8                       = 0x207;   
-const TUint32 KCMailPlugin9                       = 0x208;
-const TUint32 KCMailPlugin10                      = 0x209;
-const TUint32 KCMailPlugin11                      = 0x20a;   
-const TUint32 KCMailPlugin12                      = 0x20b;
-const TUint32 KCMailPlugin13                      = 0x20c;
-const TUint32 KCMailPlugin14                      = 0x20d;   
-const TUint32 KCMailPlugin15                      = 0x20e;
-const TUint32 KCMailPlugin16                      = 0x20f;
-const TUint32 KCMailPlugin17                      = 0x210;   
-const TUint32 KCMailPlugin18                      = 0x211;
+// Constants that define external mailbox entries
+const TUint32 KCmailExtMailboxKeyRange            = 0x00001100;
+const TUint32 KCmailExtMailboxRangeMask           = 0x0000ff00;
 
-// Constants that assosiates Home Screen widget instances to mailbox settings
-const TUint32 KCMailWidgetContentId1              = 0x300;
-const TUint32 KCMailWidgetContentId2              = 0x301;   
-const TUint32 KCMailWidgetContentId3              = 0x302;
-const TUint32 KCMailWidgetContentId4              = 0x303;
-const TUint32 KCMailWidgetContentId5              = 0x304;   
-const TUint32 KCMailWidgetContentId6              = 0x305;
-const TUint32 KCMailWidgetContentId7              = 0x306;
-const TUint32 KCMailWidgetContentId8              = 0x307;   
-const TUint32 KCMailWidgetContentId9              = 0x308;
-const TUint32 KCMailWidgetContentId10             = 0x309;
-const TUint32 KCMailWidgetContentId11             = 0x30a;   
-const TUint32 KCMailWidgetContentId12             = 0x30b;
-const TUint32 KCMailWidgetContentId13             = 0x30c;
-const TUint32 KCMailWidgetContentId14             = 0x30d;   
-const TUint32 KCMailWidgetContentId15             = 0x30e;
-const TUint32 KCMailWidgetContentId16             = 0x30f;
-const TUint32 KCMailWidgetContentId17             = 0x310;   
-const TUint32 KCMailWidgetContentId18             = 0x311;
-#endif // CMAILCENREPKEYS_H
+// External mailboxes' base indexes
+const TUint32 KCMailExtMailboxBase                = 0x00001100;
+const TUint32 KCMailExtPluginIdOffset             = 0x00000100;
+const TUint32 KCMailExtWidgetCidOffset            = 0x00000200;
+
+#endif // CMAILWIDGETCENREPKEYS_H
--- a/emailservices/emailserver/cmailhandlerplugin/rom/cmailhandlerpluginresources.iby	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/rom/cmailhandlerpluginresources.iby	Thu Jan 07 12:38:38 2010 +0200
@@ -24,7 +24,7 @@
 
 #ifdef FF_EMAIL_FRAMEWORK
 
-data=DATAZ_\ECOM_RESOURCE_DIR\emailwidget.rsc ECOM_RESOURCE_DIR\emailwidget.rsc
+data=DATAZ_\APP_RESOURCE_DIR\emailwidget.rsc APP_RESOURCE_DIR\emailwidget.rsc
 
 #endif //FF_EMAIL_FRAMEWORK
 
--- a/emailservices/emailserver/cmailhandlerplugin/src/cmailcpshandler.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/src/cmailcpshandler.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -115,18 +115,18 @@
     // and pass it on to actual publisher interface
     iLiwIf->SetConfiguration( iSettings->Configuration() );
     
-    const TInt iiMax( iSettings->Mailboxes().Count() );
+    TInt iiMax( iSettings->Mailboxes().Count() );
     for ( TInt ii = 0; ii < iiMax; ii++ )
         {
         CFSMailBox* mailbox( NULL );
         mailbox = MailClient().GetMailBoxByUidL( iSettings->Mailboxes()[ii] );
 
-        TInt id(0);
+        TInt mailboxId(0);
         if (mailbox)
             {
-            id = mailbox->GetId().Id();
+            mailboxId = mailbox->GetId().Id();
             }
-        if ( !id )
+        if ( !mailboxId )
             {
             // Remove box from settings
             iSettings->RemoveMailboxL( ii );
@@ -136,13 +136,24 @@
         else
             {
             CleanupStack::PushL( mailbox );
-            CMailMailboxDetails* mailboxDetails = CreateMailboxDetailsL( *mailbox );
-            CleanupStack::PushL( mailboxDetails );
-            TBuf<KMaxDescLen> cid;
-            iSettings->GetContentId(id, cid);
-            mailboxDetails->SetWidgetInstance(cid);
-            iAccountsArray.AppendL( mailboxDetails );
-            CleanupStack::Pop( mailboxDetails );
+            TInt id(1);
+            while (id)
+                {
+                CMailMailboxDetails* mailboxDetails = CreateMailboxDetailsL( *mailbox );
+                CleanupStack::PushL( mailboxDetails );
+            
+                if (id > 1)
+                    {
+                    iiMax = iiMax - 1;
+                    }
+                TBuf<KMaxDescLen> cid;
+                id = iSettings->GetContentId(mailboxId, id, cid);
+                mailboxDetails->SetWidgetInstance(cid);
+                iAccountsArray.AppendL( mailboxDetails );
+    
+                CleanupStack::Pop( mailboxDetails );                
+                }
+            
             CleanupStack::PopAndDestroy( mailbox );            
             }
         }
--- a/emailservices/emailserver/cmailhandlerplugin/src/cmailcpsif.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/src/cmailcpsif.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -106,11 +106,12 @@
     // create resourcefile 
     CCoeEnv* env = CCoeEnv::Static();
     
-    TFileName resourceFile;
+    // Load resource file from the same drive where this dll is loaded from
+    TFileName dllFileName;
+    Dll::FileName( dllFileName );
     TParse parse;
-    
-    parse.Set( KResourceFile, &KDC_ECOM_RESOURCE_DIR, NULL ); 
-    resourceFile = parse.FullName();
+    User::LeaveIfError( parse.Set( KResourceFile, &dllFileName, NULL ) );
+    TFileName resourceFile( parse.FullName() );
     
     BaflUtils::NearestLanguageFile( env->FsSession(), resourceFile );
     iResourceFileOffset = env->AddResourceFileL( resourceFile );
@@ -474,47 +475,53 @@
             }
         }
 
+    // Parse mif file full path by own dll drive letter
+    TFileName dllFileName;
+    Dll::FileName( dllFileName );
+    TParse mifParse;
+    User::LeaveIfError( mifParse.Set( KMifPath, &dllFileName, NULL ) );
+
     if (!iconIds.Length())
         {
         TBuf<KMaxDescLen> id;
-        iconIds.Copy(KMifPrefix);
-        iconIds.Append(KMifPath);
-        iconIds.Append(KSpace);
-        id.Num(aBitmapId);
-        iconIds.Append(id);     
-        iconIds.Append(KSpace);
-        id.Num(aBitmapMaskId);
-        iconIds.Append(id);        
+        iconIds.Copy( KMifPrefix );
+        iconIds.Append( mifParse.FullName() );
+        iconIds.Append( KSpace );
+        id.Num( aBitmapId );
+        iconIds.Append( id );
+        iconIds.Append( KSpace );
+        id.Num( aBitmapMaskId );
+        iconIds.Append( id );
         }
 
     // The actual image publishing part starts here   
     CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL());
     CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL());
 
-    TLiwGenericParam type( KType, TLiwVariant(KCpData));
+    TLiwGenericParam type( KType, TLiwVariant( KCpData ) );
     inparam->AppendL( type );
 
     CLiwDefaultMap* pdatamap = CLiwDefaultMap::NewLC();
     CLiwDefaultMap* datamap = CLiwDefaultMap::NewLC();
 
-    pdatamap->InsertL( KPublisherId, TLiwVariant( KPubId ));
-    pdatamap->InsertL( KContentType, TLiwVariant( aContentType ));
-    pdatamap->InsertL( KContentId, TLiwVariant( aContentId ));
+    pdatamap->InsertL( KPublisherId, TLiwVariant( KPubId ) );
+    pdatamap->InsertL( KContentType, TLiwVariant( aContentType ) );
+    pdatamap->InsertL( KContentId, TLiwVariant( aContentId ) );
     
-    datamap->InsertL(aKey, TLiwVariant(iconIds));
+    datamap->InsertL( aKey, TLiwVariant(iconIds) );
 
     pdatamap->InsertL( KDataMap, TLiwVariant(datamap) );
-    TLiwGenericParam item( KItem, TLiwVariant( pdatamap ));       
+    TLiwGenericParam item( KItem, TLiwVariant( pdatamap ) );       
     inparam->AppendL( item );
     
     // Publish icon ( or remove it from widget when no id provided )
     if ( aBitmapId == KNullIcon )
         {
-        iMsgInterface->ExecuteCmdL( KDelete, *inparam, *outparam);    
+        iMsgInterface->ExecuteCmdL( KDelete, *inparam, *outparam );    
         }
     else
         {
-        iMsgInterface->ExecuteCmdL( KAdd, *inparam, *outparam);
+        iMsgInterface->ExecuteCmdL( KAdd, *inparam, *outparam );
         }
     
     CleanupStack::PopAndDestroy( datamap );
--- a/emailservices/emailserver/cmailhandlerplugin/src/cmailcpssettings.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailserver/cmailhandlerplugin/src/cmailcpssettings.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -429,20 +429,35 @@
 // CMailCpsSettings::GetContentId
 // ---------------------------------------------------------------------------
 //
-void CMailCpsSettings::GetContentId( TInt aId, TDes16& aValue )
+TInt CMailCpsSettings::GetContentId( TInt aMailboxId, TInt aId, TDes16& aValue )
     {
-    FUNC_LOG;    
+    FUNC_LOG;
+    TBool cidFound(EFalse);
+    TInt ret(0);
+    TInt found(0);
     for (TInt i = 0; i < KMaxMailboxCount; i++)
         {       
         TInt value;
         TUint32 mailboxKey(KCMailMailboxIdBase+i);
-        iCenRep->Get( mailboxKey, value );
-        if (aId == value)
+        iCenRep->Get( mailboxKey, value );     
+        if (aMailboxId == value)
             {
-            iCenRep->Get( KCMailWidgetContentIdBase+i, aValue );
-            break;
+            found++;
+            if ( !cidFound && found == aId )
+                {
+                iCenRep->Get( KCMailWidgetContentIdBase+i, aValue );
+                cidFound = ETrue;
+                }            
+            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;
     }
 
 // ---------------------------------------------------------------------------
--- a/emailservices/emailserver/src/fsmailserver.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailserver/src/fsmailserver.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -90,8 +90,6 @@
 //
 GLDEF_C TInt E32Main()
     {
-
-    
     TInt error = KErrNone;
     
     // First check that the server isn't already running
--- a/emailservices/emailservermonitor/src/emailshutter.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailservermonitor/src/emailshutter.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -54,18 +54,18 @@
 // Non-UI clients that need to be closed
 const TUid KOtherClientsToClose[] =
     {
-    { FSMailServerUidAsTInt },     // FSMailServer
-    { KPcsServerProcessUidAsTInt } // PCS server
+    { KPcsServerProcessUidAsTInt }, // PCS server
+    { FSMailServerUidAsTInt },      // FSMailServer
     };
 
 // Plugin processes that need to be closed
 const TUid KPluginProcessesToClose[] =
     {
     // MfE plugin
-    { 0x10206961 },      // KUidEasServer
-    { 0x10206970 },      // KUidEasTarmAccess
-    { 0x10206972 },      // KUidEasStartup
+    { 0x20012BEE },      // KUidEasStartup
+    { 0x20012BEC },      // KUidEasTarmAccess
     { 0x20012BD4 },      // KEasLogSenderServer
+    { 0x20012BE6 },      // KUidEasServer
     // Oz plugin
     { 0x2002136A },      // monitor
     { 0x20021367 },      // server
--- a/emailservices/emailstore/message_store/MsgStoreRfsPlugin/group/RfsMsgStorePlugin.mmp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailstore/message_store/MsgStoreRfsPlugin/group/RfsMsgStorePlugin.mmp	Thu Jan 07 12:38:38 2010 +0200
@@ -55,6 +55,8 @@
 LIBRARY    ecom.lib
 LIBRARY    efsrv.lib
 LIBRARY    platformenv.lib
+LIBRARY	   bafl.lib
+LIBRARY    estor.lib
 
 // END FILE RfsMsgStorePlugin.mmp
 
--- a/emailservices/emailstore/message_store/MsgStoreRfsPlugin/inc/RfsMsgStorePlugin.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailstore/message_store/MsgStoreRfsPlugin/inc/RfsMsgStorePlugin.h	Thu Jan 07 12:38:38 2010 +0200
@@ -56,6 +56,7 @@
     * @return   None
     */
     void ExecuteCustomCommandL( const TRfsReason aType, TDesC& aCommand );
+    TInt GetDriveL( TDriveNumber& aDrive );
 
 private:
     CRfsMsgStorePlugin();
--- a/emailservices/emailstore/message_store/MsgStoreRfsPlugin/src/RfsMsgStorePlugin.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailservices/emailstore/message_store/MsgStoreRfsPlugin/src/RfsMsgStorePlugin.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -20,6 +20,8 @@
 
 #include "RfsMsgStorePlugin.h"
 #include "EmailStoreUids.hrh"
+#include <bautils.h>  
+#include <s32file.h>
 
 // -----------------------------------------------------------------------------
 // CRfsMsgStorePlugin::NewL()
@@ -53,27 +55,25 @@
     if ( aType == ENormalRfs || aType == EDeepRfs || aType == EInitRfs )
         {
         TUint driveStatus( 0 );
-
-        if ( DriveInfo::GetDriveStatus( iFs, EDriveE, driveStatus ) == KErrNone )
+				TDriveNumber drive( EDriveC );
+     		GetDriveL( drive );
+        if ( DriveInfo::GetDriveStatus( iFs, drive, driveStatus ) == KErrNone )
             {
-            // check if internal E: drive is exists on the device
-            if ( ( driveStatus & DriveInfo::EDriveUserVisible ) &&
-                    ( driveStatus & DriveInfo::EDriveInternal )  &&
-                    ( driveStatus & DriveInfo::EDrivePresent ) )
-                {
-                // since we are dealing with internal E: drive only,
-                // it is ok to hardcoded the E: in the string
-                _LIT( KMsgStoreEDrivePrivate, "E:\\Private\\" );
-
-                TFileName msgStorePath( KMsgStoreEDrivePrivate );
-                msgStorePath.AppendNum( KUidMessageStoreExe, EHex );
-                msgStorePath.Append( KPathDelimiter );
-                CFileMan* fileManager = CFileMan::NewL( iFs );
-                // this will recursively delete all files in all directories under the msgStorePath
-                // but directories under the msgStorePath are not deleted
-                fileManager->Delete( msgStorePath, CFileMan::ERecurse );
-                delete fileManager;
-                }
+            _LIT( KPrivate, ":\\Private\\" );    
+            TChar driveChar;
+            RFs::DriveToChar(drive, driveChar);
+            TFileName msgStorePath;
+            TBuf<5> driveLetter;
+            driveLetter.Append(driveChar);
+            msgStorePath.Append(driveLetter);
+            msgStorePath.Append(KPrivate);                
+            msgStorePath.AppendNum( KUidMessageStoreExe, EHex );
+            msgStorePath.Append( KPathDelimiter );
+            CFileMan* fileManager = CFileMan::NewL( iFs );
+            // this will recursively delete all files in all directories under the msgStorePath
+            // but directories under the msgStorePath are not deleted
+            fileManager->Delete( msgStorePath, CFileMan::ERecurse );
+            delete fileManager;
             }
         }
     }
@@ -115,5 +115,47 @@
     {
     User::LeaveIfError( iFs.Connect() );
     }
+    
+// -----------------------------------------------------------------------------
+// CRfsMsgStorePlugin::GetDriveL(TDriveNumber&)
+// -----------------------------------------------------------------------------
+//
+TInt CRfsMsgStorePlugin::GetDriveL( TDriveNumber& aDrive )
+    {
+    _LIT16( KDriveToUseFile, "db_drive.cfg" );
+    TInt ret( KErrNotFound );
+    RFs fs;
+    if( fs.Connect() == KErrNone )
+        {
+        CleanupClosePushL( fs );               //+fs
+        TFileName fileName;
+        _LIT( KCDrive, "C:" );
+        _LIT( KPrivate, "Private" );   
+        fileName.Append(KCDrive());
+        fileName.Append( KPathDelimiter ); 
+        fileName.Append(KPrivate);
+        fileName.Append( KPathDelimiter );                 
+        fileName.AppendNum( KUidMessageStoreExe, EHex );
+        fileName.Append( KPathDelimiter );        
+        fileName.Append( KDriveToUseFile );
+        if( BaflUtils::FileExists( fs, fileName ) )
+            {
+            RFileReadStream reader;
+            if ( reader.Open( fs, fileName, EFileRead ) == KErrNone )
+          		{
+           		CleanupClosePushL( reader );             //+reader
+           		TUint drive = reader.ReadUint32L();
+              CleanupStack::PopAndDestroy( &reader );  //-reader
+              if(drive <=EDriveZ)
+	              {
+	           		aDrive = static_cast<TDriveNumber>( drive );
+           			ret = KErrNone;
+           			}
+           		}
+            }
+        CleanupStack::PopAndDestroy( &fs );    //-fs
+        } // end if
+    return ret;
+    }
 
 // END FILE RfsMsgStorePlugin.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/bufferedmsgcreator_test/bwins/t_msgstoreu.def	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * LibEntryL(void)
+	?SetRequirements@@YAHAAPAVCTestModuleParam@@AAK@Z @ 2 NONAME ; int SetRequirements(class CTestModuleParam * &, unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/bufferedmsgcreator_test/group/bld.inf	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,22 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTMMPFILES
+t_bufferedmsgcreator.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/bufferedmsgcreator_test/group/t_bufferedmsgcreator.mmp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  project file for Message Store unit test
+*
+*/
+
+// For OS_LAYER_SYSTEMINCLUDE
+#include <platform_paths.hrh>
+
+TARGET          t_bufferedmsgcreator.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E7
+
+CAPABILITY      ALL -TCB
+/* Remove comments and replace 0x00000000 with correct vendor id */
+// VENDORID     0x00000000
+/* Remove comments and replace 0x00000000 with correct secure id */
+SECUREID     0x20022BFE
+
+//TARGETPATH      target_path
+DEFFILE         t_bufferedmsgcreator.def
+
+USERINCLUDE     ../inc 
+USERINCLUDE     ../../../message_store/server/inc
+USERINCLUDE     ../../../message_store/common/inc 
+
+OS_LAYER_SYSTEMINCLUDE	
+SYSTEMINCLUDE   ../../../../../inc
+
+SOURCEPATH      ../src
+SOURCE          t_bufferedmsgcreator.cpp
+SOURCE          t_bufferedmsgcreatorcases.cpp
+SOURCE          mockups.cpp
+SOURCEPATH      ../../../message_store/server/src
+SOURCE          bufferedmessagecreator.cpp
+SOURCE          messagestoreutils.cpp
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib 
+LIBRARY         bafl.lib 
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY         tzclient.lib
+LIBRARY         edbms.lib
+LIBRARY         estor.lib
+
+LANG            SC
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/bufferedmsgcreator_test/inc/containerstore.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mockup Container store.
+*
+*/
+#ifndef __CONTAINER_STORE_H__
+#define __CONTAINER_STORE_H__
+
+#include "msgstoretypes.h"
+#include <e32base.h>
+
+typedef TUint TContainerId;    
+const TContainerId KContainerInvalidId = 0;
+
+class CContainerStoreContentManager;
+class CContainerStoreUtils;
+
+
+NONSHARABLE_CLASS( MContainerStoreObserver )
+    {
+    
+    };
+
+
+/**
+ * 
+ */
+NONSHARABLE_CLASS( CContainerStore ) :
+    public CBase,
+    public MContainerStoreObserver
+    
+	{
+public:
+    friend class CBufferedMessageCreator;
+    
+    static CContainerStore* NewL();
+    
+    void ConstructL();
+    
+    CContainerStore();
+    
+    ~CContainerStore();
+    
+    TContainerId CreateContainerL( TContainerId  aType,
+                                   TContainerId  aParentId, 
+                                   TContainerId  aGrandparentId, 
+                                   const TDesC8& aProperties,
+                                   TContainerId  aId = KMsgStoreInvalidId );
+
+    void CommitContainerL( TContainerId             aId,
+                           TContainerId             aParentId,
+                           TContainerId             aMailBoxId,
+                           MContainerStoreObserver* aObserver,
+                           TContainerId             aCopiedFromOriginalMsgId = KContainerInvalidId );
+    
+    void BeginDatabaseTransactionLC();
+    
+    void CommitDatabaseTransactionL();
+
+    void AllocateIdsBlockL(
+        RArray<TContainerId>& aIds,
+        TInt aBlockSize = 4 );
+
+    TBool IsEncryptionEnabled();
+		
+    CContainerStoreUtils& StoreUtils();
+    
+    CContainerStoreContentManager& ContentManager();
+    
+    const TDesC& PrivatePath() const;
+    
+    void SetLeaveAfter( TInt aLeaveAfter );
+    
+    void SimulateLeaveL();
+
+public:    
+    CContainerStoreContentManager* iContentManager;
+    CContainerStoreUtils* iUtils;
+    TContainerId iSequence;
+    TBool iInTransaction;
+    TInt iLeaveAfter;
+	};
+
+	
+#endif // __CONTAINER_STORE_H__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/bufferedmsgcreator_test/inc/containerstorecontentmanager.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mockup Container store content manager.
+*
+*/
+#ifndef __CONTAINERSTORECONTENTMANAGER_H__
+#define __CONTAINERSTORECONTENTMANAGER_H__
+
+
+#include <f32file.h>
+
+
+NONSHARABLE_CLASS( CContainerStoreContentManager ) : CBase
+    {
+public:
+
+    CContainerStoreContentManager();
+
+    void ReplaceFileWithFileL(
+        RFile& aSource,
+        const TDesC& aTarget );
+    
+    void PrependBufferAndMoveFileL(
+        const TDesC& aSource,
+        const TDesC& aTarget,
+        const TDesC8& aPrepend );
+    
+    TInt TransferContentFile(
+        TContainerId aId, 
+        const TDesC& aContentPath );
+    
+    void SetLeaveAfter( TInt aLeaveAfter );
+    
+    void SimulateLeaveL();
+
+private:
+    TInt iLeaveAfter;
+    };
+		
+#endif // __CONTAINERSTORECONTENTMANAGER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/bufferedmsgcreator_test/inc/containerstoreutils.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Mockup Container store utils.
+*
+*/
+#ifndef CONTAINERSTOREUTILS_H
+#define CONTAINERSTOREUTILS_H
+
+
+/**
+ * 
+ */
+NONSHARABLE_CLASS( CContainerStoreUtils ) :
+    public CBase
+    
+	{
+public:
+    
+    static CContainerStoreUtils* NewL();
+    
+    void ConstructL();
+    
+    CContainerStoreUtils();
+    
+    ~CContainerStoreUtils();
+    
+    const TDesC& PrivatePath() const;
+    
+    RFs& FileSystem();
+    
+    void LeaveIfLowDiskSpaceL( TUint aBytesToWrite );
+    
+public:    
+    RFs iFs;
+    RBuf iPrivatePath;
+	};
+
+	
+#endif // CONTAINERSTOREUTILS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/bufferedmsgcreator_test/inc/t_bufferedmsgcreatore.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,270 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  t_msgstore test module.
+*
+*/
+
+
+
+#ifndef T_MSGSTORE_H
+#define T_MSGSTORE_H
+
+// INCLUDES
+#include "StifTestModule.h"
+#include <StifLogger.h>
+#include <NormalHardcodedAssert.h>
+
+// CONSTANTS
+
+// MACROS
+#define TEST_MODULE_VERSION_MAJOR 0
+#define TEST_MODULE_VERSION_MINOR 0
+#define TEST_MODULE_VERSION_BUILD 0
+
+// Logging path
+_LIT( Kt_msgstoreLogPath, "\\logs\\testframework\\t_bufferedmsgcreatore\\" ); 
+// Log file
+_LIT( Kt_msgstoreLogFile, "t_bufferedmsgcreatore.txt" ); 
+_LIT( Kt_msgstoreLogFileWithTitle, "t_bufferedmsgcreatore_[%S].txt" );
+
+#define GETPTR &
+#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
+#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
+#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
+#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
+
+// FORWARD DECLARATIONS
+class Ct_bufferedmsgcreator;
+
+// DATA TYPES
+// A typedef for function that does the actual testing,
+// function is a type 
+typedef TInt (Ct_bufferedmsgcreator::* TestFunction)(TTestResult&);
+
+// CLASS DECLARATION
+
+/**
+*  An internal structure containing a test case name and
+*  the pointer to function doing the test
+*/
+class TCaseInfoInternal
+    {
+    public:
+        const TText*    iCaseName;
+        TestFunction    iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+    };
+
+// CLASS DECLARATION
+
+/**
+*  A structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class TCaseInfo
+    {
+    public:
+        TPtrC iCaseName;
+        TestFunction iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+
+    TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
+        {
+        };
+
+    };
+
+
+// CLASS DECLARATION
+
+/**
+*  This a t_msgstore class.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS(Ct_bufferedmsgcreator) : public CTestModuleBase
+    {
+    public:  // Constructors and destructor
+
+
+        /**
+        * Two-phased constructor.
+        */
+        static Ct_bufferedmsgcreator* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~Ct_bufferedmsgcreator();
+
+    public: // Functions from base classes
+
+        /**
+        * From CTestModuleBase InitL is used to initialize the 
+        *       t_msgstore. It is called once for every instance of 
+        *       TestModulet_msgstore after its creation.
+        * @since ?Series60_version
+        * @param aIniFile Initialization file for the test module (optional)
+        * @param aFirstTime Flag is true when InitL is executed for first 
+        *               created instance of t_msgstore.
+        * @return Symbian OS error code
+        */
+        TInt InitL( TFileName& aIniFile, TBool aFirstTime );
+
+        /**
+        * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
+        *   from t_msgstore. 
+        * @since ?Series60_version
+        * @param aTestCaseFile Test case file (optional)
+        * @param aTestCases  Array of TestCases returned to test framework
+        * @return Symbian OS error code
+        */
+        TInt GetTestCasesL( const TFileName& aTestCaseFile, 
+                            RPointerArray<TTestCaseInfo>& aTestCases );
+
+        /**
+        * From CTestModuleBase RunTestCaseL is used to run an individual 
+        *   test case. 
+        * @since ?Series60_version
+        * @param aCaseNumber Test case number
+        * @param aTestCaseFile Test case file (optional)
+        * @param aResult Test case result returned to test framework (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error, which is 
+        *           not reported in aResult parameter as test case failure).
+        */   
+        TInt RunTestCaseL( const TInt aCaseNumber, 
+                           const TFileName& aTestCaseFile,
+                           TTestResult& aResult );
+
+        /**
+        * From CTestModuleBase; OOMTestQueryL is used to specify is particular
+        * test case going to be executed using OOM conditions
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailureType OOM failure type (optional)
+        * @param aFirstMemFailure The first heap memory allocation failure value (optional)
+        * @param aLastMemFailure The last heap memory allocation failure value (optional)
+        * @return TBool
+        */
+        virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
+                                     const TInt /* aCaseNumber */, 
+                                     TOOMFailureType& aFailureType, 
+                                     TInt& /* aFirstMemFailure */, 
+                                     TInt& /* aLastMemFailure */ );
+
+        /**
+        * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
+        * test environment
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
+                                    const TInt /* aCaseNumber */ ); 
+
+        /**
+        * From CTestModuleBase; OOMHandleWarningL
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailNextValue FailNextValue for OOM test execution (optional)
+        * @return None
+        *
+        * User may add implementation for OOM test warning handling. Usually no
+        * implementation is required.           
+        */
+        virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
+                                        const TInt /* aCaseNumber */, 
+                                        TInt& /* aFailNextValue */); 
+
+        /**
+        * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
+        * test environment
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        *
+        */
+        virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
+                                       const TInt /* aCaseNumber */ );
+        
+        /**
+         * Method used to log version of test module
+         */
+        void SendTestModuleVersion();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        Ct_bufferedmsgcreator();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Function returning test case name and pointer to test case function.
+        * @since ?Series60_version
+        * @param aCaseNumber test case number
+        * @return TCaseInfo 
+        */
+        const TCaseInfo Case ( const TInt aCaseNumber ) const;
+
+        /**
+        * [test case declarations] - do not remove
+        */
+        //ADD NEW METHOD DEC HERE"
+
+        TInt Oom1L( TTestResult& aResult );
+        
+        TInt ErrHandling1L( TTestResult& aResult );
+        
+        TInt ErrHandling2L( TTestResult& aResult );
+        
+
+    private:    // Data
+        // Pointer to test (function) to be executed
+        TestFunction iMethod;
+
+        // Pointer to logger
+        CStifLogger * iLog; 
+
+        // Normal logger
+        CStifLogger* iStdLog;
+
+        // Test case logger
+        CStifLogger* iTCLog;
+
+        // Flag saying if test case title should be added to log file name
+        TBool iAddTestCaseTitleToLogName;
+
+        // Flag saying if version of test module was already sent
+        TBool iVersionLogged;
+
+    };
+
+#endif      // T_MSGSTORE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/bufferedmsgcreator_test/src/mockups.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,232 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+//mockups below:
+#include "containerstore.h" 
+#include "containerstorecontentmanager.h"
+#include "containerstoreutils.h"
+
+
+/*static*/ CContainerStore* CContainerStore::NewL()
+    {
+    CContainerStore* self = new (ELeave) CContainerStore;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+    
+void CContainerStore::ConstructL()
+    {
+    iContentManager = new (ELeave) CContainerStoreContentManager;
+    iUtils = CContainerStoreUtils::NewL();
+    }
+
+CContainerStore::CContainerStore() :
+    iSequence( 0 ), iInTransaction( EFalse ), iLeaveAfter( -1 )
+    {
+    }
+    
+CContainerStore::~CContainerStore()
+    {
+    delete iUtils;
+    delete iContentManager;
+    }
+    
+TContainerId CContainerStore::CreateContainerL(
+    TContainerId  aType,
+    TContainerId  aParentId, 
+    TContainerId  aGrandparentId, 
+    const TDesC8& aProperties,
+    TContainerId  aId )
+    {
+    SimulateLeaveL();
+    
+    return 0;
+    }
+
+void CContainerStore::CommitContainerL(
+    TContainerId             aId,
+    TContainerId             aParentId,
+    TContainerId             aMailBoxId,
+    MContainerStoreObserver* aObserver,
+    TContainerId             aCopiedFromOriginalMsgId )
+    {
+    SimulateLeaveL();
+    }
+    
+void CContainerStore::BeginDatabaseTransactionLC()
+    {
+    SimulateLeaveL();
+    iInTransaction = ETrue;
+    }
+    
+void CContainerStore::CommitDatabaseTransactionL()
+    {
+    SimulateLeaveL();
+    iInTransaction = EFalse;
+    }
+
+void CContainerStore::AllocateIdsBlockL(
+    RArray<TContainerId>& aIds,
+    TInt aBlockSize )
+    {
+    SimulateLeaveL();
+    for ( TInt i = 0; i < aBlockSize; ++i )
+        {
+        aIds.Append( ++iSequence );
+        }    
+    }
+
+TBool CContainerStore::IsEncryptionEnabled()
+    {
+    return EFalse;
+    }
+        
+CContainerStoreUtils& CContainerStore::StoreUtils()
+    {
+    return *iUtils;
+    }
+    
+CContainerStoreContentManager& CContainerStore::ContentManager()
+    {
+    return *iContentManager;
+    }
+    
+const TDesC& CContainerStore::PrivatePath() const
+    {
+    return iUtils->PrivatePath();
+    }
+
+void CContainerStore::SetLeaveAfter( TInt aLeaveAfter )
+    {
+    iLeaveAfter = aLeaveAfter;
+    }
+
+void CContainerStore::SimulateLeaveL()
+    {
+    if ( 0 == iLeaveAfter )
+        {
+        User::Leave( KErrGeneral );
+        }
+    else if ( 0 < iLeaveAfter )
+        {
+        --iLeaveAfter;
+        }
+    }
+
+/////////////////////////////////////
+// CContainerStoreContentManager   //
+/////////////////////////////////////
+
+CContainerStoreContentManager::CContainerStoreContentManager() :
+    iLeaveAfter( -1 )
+    {
+    
+    }
+
+void CContainerStoreContentManager::SetLeaveAfter( TInt aLeaveAfter )
+    {
+    iLeaveAfter = aLeaveAfter;
+    }
+
+void CContainerStoreContentManager::SimulateLeaveL()
+    {
+    if ( 0 == iLeaveAfter )
+        {
+        User::Leave( KErrGeneral );
+        }
+    else if ( 0 < iLeaveAfter )
+        {
+        --iLeaveAfter;
+        }
+    }
+
+void CContainerStoreContentManager::ReplaceFileWithFileL(
+    RFile& aSource,
+    const TDesC& aTarget )
+    {
+    SimulateLeaveL();
+    }
+    
+void CContainerStoreContentManager::PrependBufferAndMoveFileL(
+    const TDesC& aSource,
+    const TDesC& aTarget,
+    const TDesC8& aPrepend )
+    {
+    SimulateLeaveL();
+    }
+    
+TInt CContainerStoreContentManager::TransferContentFile(
+    TContainerId aId, 
+    const TDesC& aContentPath )
+    {
+    return KErrNone;
+    }
+
+
+///////////////////////////////
+// CContainerStoreUtils      //
+///////////////////////////////
+
+CContainerStoreUtils* CContainerStoreUtils::NewL()
+    {
+
+    CContainerStoreUtils* self = new (ELeave) CContainerStoreUtils();
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+    
+void CContainerStoreUtils::ConstructL()
+    {
+    User::LeaveIfError( iFs.Connect() );
+    
+    User::LeaveIfError( iPrivatePath.Create( KMaxPath ) );
+    iFs.PrivatePath( iPrivatePath );
+    }
+    
+CContainerStoreUtils::CContainerStoreUtils()
+    {
+    
+    }
+    
+CContainerStoreUtils::~CContainerStoreUtils()
+    {
+    iPrivatePath.Close();
+    iFs.Close();
+    }
+    
+const TDesC& CContainerStoreUtils::PrivatePath() const
+    {
+    return iPrivatePath;
+    }
+
+RFs& CContainerStoreUtils::FileSystem()
+    {
+    return iFs;
+    }
+
+void CContainerStoreUtils::LeaveIfLowDiskSpaceL( TUint aBytesToWrite )
+    {
+    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/bufferedmsgcreator_test/src/t_bufferedmsgcreator.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,443 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  t_msgstore class member functions
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <Stiftestinterface.h>
+#include "t_bufferedmsgcreatore.h"
+#include <SettingServerClient.h>
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg)  // ?description
+    {
+
+    ?code  // ?comment
+
+    // ?comment
+    ?code
+    }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::Ct_msgstore
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+Ct_bufferedmsgcreator::Ct_bufferedmsgcreator()
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::ConstructL
+// Symbian 2nd phase constructor can leave.
+//
+// Note: If OOM test case uses STIF Logger, then STIF Logger must be created
+// with static buffer size parameter (aStaticBufferSize). Otherwise Logger 
+// allocates memory from heap and therefore causes error situations with OOM 
+// testing. For more information about STIF Logger construction, see STIF Users 
+// Guide.
+// -----------------------------------------------------------------------------
+//
+void Ct_bufferedmsgcreator::ConstructL()
+    {
+    //Read logger settings to check whether test case name is to be
+    //appended to log file name.
+    RSettingServer settingServer;
+    TInt ret = settingServer.Connect();
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        }
+    // Struct to StifLogger settigs.
+    TLoggerSettings loggerSettings; 
+    // Parse StifLogger defaults from STIF initialization file.
+    ret = settingServer.GetLoggerSettings(loggerSettings);
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        } 
+    // Close Setting server session
+    settingServer.Close();
+    iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle;
+
+    iStdLog = CStifLogger::NewL( Kt_msgstoreLogPath, 
+                          Kt_msgstoreLogFile);
+    iLog = iStdLog;
+
+    // Sample how to use logging
+    _LIT( KLogStart, "t_msgstore logging starts!" );
+    iLog->Log( KLogStart );
+
+    iVersionLogged = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Ct_bufferedmsgcreator* Ct_bufferedmsgcreator::NewL()
+    {
+    Ct_bufferedmsgcreator* self = new (ELeave) Ct_bufferedmsgcreator;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+Ct_bufferedmsgcreator::~Ct_bufferedmsgcreator()
+    {
+    iLog = NULL;
+    delete iStdLog;
+    iStdLog = NULL;
+    delete iTCLog;
+    iTCLog = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::InitL
+// InitL is used to initialize the Test Module.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_bufferedmsgcreator::InitL( 
+    TFileName& /*aIniFile*/, 
+    TBool /*aFirstTime*/ )
+    {
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::GetTestCasesL
+// GetTestCases is used to inquire test cases from the Test Module. Test
+// cases are stored to array of test cases. The Test Framework will be 
+// the owner of the data in the RPointerArray after GetTestCases return
+// and it does the memory deallocation. 
+// -----------------------------------------------------------------------------
+//
+TInt Ct_bufferedmsgcreator::GetTestCasesL( 
+    const TFileName& /*aConfig*/, 
+    RPointerArray<TTestCaseInfo>& aTestCases )
+    {
+
+    // Loop through all test cases and create new
+    // TTestCaseInfo items and append items to aTestCase array    
+    for( TInt i = 0; Case(i).iMethod != NULL; i++ )
+        {
+
+        // Allocate new TTestCaseInfo from heap for a testcase definition.
+        TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
+
+        // PushL TTestCaseInfo to CleanupStack.    
+        CleanupStack::PushL( newCase );
+
+        // Set number for the testcase.
+        // When the testcase is run, this comes as a parameter to RunTestCaseL.
+        newCase->iCaseNumber = i;
+
+        // Set title for the test case. This is shown in UI to user.
+        newCase->iTitle.Copy( Case(i).iCaseName );
+
+        // Append TTestCaseInfo to the testcase array. After appended 
+        // successfully the TTestCaseInfo object is owned (and freed) 
+        // by the TestServer. 
+        User::LeaveIfError(aTestCases.Append ( newCase ) );
+
+        // Pop TTestCaseInfo from the CleanupStack.
+        CleanupStack::Pop( newCase );
+
+        }
+
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::RunTestCaseL
+// RunTestCaseL is used to run an individual test case specified 
+// by aTestCase. Test cases that can be run may be requested from 
+// Test Module by GetTestCases method before calling RunTestCase.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_bufferedmsgcreator::RunTestCaseL( 
+    const TInt aCaseNumber,   
+    const TFileName& /*aConfig*/,
+    TTestResult& aResult )
+    {
+    if(!iVersionLogged)
+    	{
+    	SendTestModuleVersion();
+    	iVersionLogged = ETrue;
+    	}
+    
+    // Return value
+    TInt execStatus = KErrNone;
+
+    // Get the pointer to test case function
+    TCaseInfo tmp = Case ( aCaseNumber );
+
+    _LIT( KLogStartTC, "Starting testcase [%S]" );
+    iLog->Log( KLogStartTC, &tmp.iCaseName);
+
+    // Check that case number was valid
+    if ( tmp.iMethod != NULL )
+        {
+        //Open new log file with test case title in file name
+        if(iAddTestCaseTitleToLogName)
+            {
+            //Delete test case logger if exists
+            if(iTCLog)
+                {
+                delete iTCLog;
+                iTCLog = NULL;
+                }
+
+            TFileName logFileName;
+            TName title;
+            TestModuleIf().GetTestCaseTitleL(title);
+        
+            logFileName.Format(Kt_msgstoreLogFileWithTitle, &title);
+
+            iTCLog = CStifLogger::NewL(Kt_msgstoreLogPath, 
+                                       logFileName);
+            iLog = iTCLog;                                       
+            }
+
+        // Valid case was found, call it via function pointer
+        iMethod = tmp.iMethod;        
+        //execStatus  = ( this->*iMethod )( aResult );
+        TRAPD(err, execStatus  = ( this->*iMethod )( aResult ));
+        if(iAddTestCaseTitleToLogName)
+            {
+            //Restore standard log and destroy test case logger
+            iLog = iStdLog;
+            delete iTCLog; //Close test case log
+            iTCLog = NULL;
+            }
+        User::LeaveIfError(err);
+        }
+    else
+        {
+        // Valid case was not found, return error.
+        execStatus = KErrNotFound;
+        }
+
+    // Return case execution status (not the result of the case execution)
+    return execStatus;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::OOMTestQueryL
+// Used to check if a particular test case should be run in OOM conditions and 
+// which memory allocations should fail.    
+// -----------------------------------------------------------------------------
+//
+TBool Ct_bufferedmsgcreator::OOMTestQueryL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt aCaseNumber, 
+                                TOOMFailureType& /* aFailureType */, 
+                                TInt& aFirstMemFailure, 
+                                TInt& aLastMemFailure ) 
+    {
+    _LIT( KLogOOMTestQueryL, "Ct_msgstore::OOMTestQueryL" );
+    iLog->Log( KLogOOMTestQueryL );     
+
+    aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation;
+    aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation;
+
+    return Case( aCaseNumber ).iIsOOMTest;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::OOMTestInitializeL
+// Used to perform the test environment setup for a particular OOM test case. 
+// Test Modules may use the initialization file to read parameters for Test 
+// Module initialization but they can also have their own configure file or 
+// some other routine to initialize themselves.  
+//
+// NOTE: User may add implementation for OOM test environment initialization.
+// Usually no implementation is required.
+// -----------------------------------------------------------------------------
+//
+void Ct_bufferedmsgcreator::OOMTestInitializeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::OOMHandleWarningL
+// In some cases the heap memory allocation should be skipped, either due to
+// problems in the OS code or components used by the code being tested, or even 
+// inside the tested components which are implemented this way on purpose (by 
+// design), so it is important to give the tester a way to bypass allocation 
+// failures.
+//
+// NOTE: User may add implementation for OOM test warning handling. Usually no
+// implementation is required.
+// -----------------------------------------------------------------------------
+//
+void Ct_bufferedmsgcreator::OOMHandleWarningL( 
+                                const TFileName& /* aTestCaseFile */,
+                                const TInt /* aCaseNumber */, 
+                                TInt& /* aFailNextValue */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::OOMTestFinalizeL
+// Used to perform the test environment cleanup for a particular OOM test case.
+//
+// NOTE: User may add implementation for OOM test environment finalization.
+// Usually no implementation is required.
+// -----------------------------------------------------------------------------
+//
+void Ct_bufferedmsgcreator::OOMTestFinalizeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+//-----------------------------------------------------------------------------
+// Ct_msgstore::SendTestModuleVersion
+// Method used to send version of test module
+//-----------------------------------------------------------------------------
+//
+void Ct_bufferedmsgcreator::SendTestModuleVersion()
+	{
+	TVersion moduleVersion;
+	moduleVersion.iMajor = TEST_MODULE_VERSION_MAJOR;
+	moduleVersion.iMinor = TEST_MODULE_VERSION_MINOR;
+	moduleVersion.iBuild = TEST_MODULE_VERSION_BUILD;
+	
+	TFileName moduleName;
+	moduleName = _L("t_msgstore.dll");
+
+	TBool newVersionOfMethod = ETrue;
+	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
+	}
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point
+// Returns: CTestModuleBase*: Pointer to Test Module object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTestModuleBase* LibEntryL()
+    {
+    return Ct_bufferedmsgcreator::NewL();
+
+    }
+
+// -----------------------------------------------------------------------------
+// SetRequirements handles test module parameters(implements evolution
+// version 1 for test module's heap and stack sizes configuring).
+// Returns: TInt: Symbian error code.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, 
+                                TUint32& /*aParameterValid*/ )
+    {
+
+    /* --------------------------------- NOTE ---------------------------------
+    USER PANICS occurs in test thread creation when:
+    1) "The panic occurs when the value of the stack size is negative."
+    2) "The panic occurs if the minimum heap size specified is less
+       than KMinHeapSize".
+       KMinHeapSize: "Functions that require a new heap to be allocated will
+       either panic, or will reset the required heap size to this value if
+       a smaller heap size is specified".
+    3) "The panic occurs if the minimum heap size specified is greater than
+       the maximum size to which the heap can grow".
+    Other:
+    1) Make sure that your hardware or Symbian OS is supporting given sizes.
+       e.g. Hardware might support only sizes that are divisible by four.
+    ------------------------------- NOTE end ------------------------------- */
+
+    // Normally STIF uses default heap and stack sizes for test thread, see:
+    // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
+    // If needed heap and stack sizes can be configured here by user. Remove
+    // comments and define sizes.
+
+/*
+    aParameterValid = KStifTestModuleParameterChanged;
+
+    CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
+    // Stack size
+    param->iTestThreadStackSize= 16384; // 16K stack
+    // Heap sizes
+    param->iTestThreadMinHeap = 4096;   // 4K heap min
+    param->iTestThreadMaxHeap = 1048576;// 1M heap max
+
+    aTestModuleParam = param;
+*/
+    return KErrNone;
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/bufferedmsgcreator_test/src/t_bufferedmsgcreatorcases.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,495 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  implementation of test cases methods.
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <e32math.h>
+#include "t_bufferedmsgcreatore.h"
+#include "containerstore.h" //mockup
+#include "containerstorecontentmanager.h" //mockup
+#include "bufferedmessagecreator.h" //real
+#include "messagestoreclientserver.h" //real
+
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+void CallSequence1L( CContainerStore& aStore, CBufferedMessageCreator& aCreator,
+    RBuf8& aMsgProps, RBuf8& aMsgProps1, RBuf8& aPartProps, RBuf8& aPartProps1,
+    RBuf8& aContent, TMsgStoreId& aSequence );
+
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg)  // ?description
+    {
+
+    ?code  // ?comment
+
+    // ?comment
+    ?code
+    }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::Case
+// Returns a test case by number.
+//
+// This function contains an array of all available test cases 
+// i.e pair of case name and test function. If case specified by parameter
+// aCaseNumber is found from array, then that item is returned.
+// 
+// The reason for this rather complicated function is to specify all the
+// test cases only in one place. It is not necessary to understand how
+// function pointers to class member functions works when adding new test
+// cases. See function body for instructions how to add new test case.
+// -----------------------------------------------------------------------------
+//
+const TCaseInfo Ct_bufferedmsgcreator::Case ( 
+    const TInt aCaseNumber ) const 
+     {
+
+    /**
+    * To add new test cases, implement new test case function and add new 
+    * line to KCases array specify the name of the case and the function 
+    * doing the test case
+    * In practice, do following
+    * 1) Make copy of existing test case function and change its name
+    *    and functionality. Note that the function must be added to 
+    *    t_msgstore.cpp file and to t_msgstore.h 
+    *    header file.
+    *
+    * 2) Add entry to following KCases array either by using:
+    *
+    * 2.1: FUNCENTRY or ENTRY macro
+    * ENTRY macro takes two parameters: test case name and test case 
+    * function name.
+    *
+    * FUNCENTRY macro takes only test case function name as a parameter and
+    * uses that as a test case name and test case function name.
+    *
+    * Or
+    *
+    * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
+    * only with OOM (Out-Of-Memory) testing!
+    *
+    * OOM_ENTRY macro takes five parameters: test case name, test case 
+    * function name, TBool which specifies is method supposed to be run using
+    * OOM conditions, TInt value for first heap memory allocation failure and 
+    * TInt value for last heap memory allocation failure.
+    * 
+    * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
+    * that as a test case name, TBool which specifies is method supposed to be
+    * run using OOM conditions, TInt value for first heap memory allocation 
+    * failure and TInt value for last heap memory allocation failure. 
+    */ 
+
+    static TCaseInfoInternal const KCases[] =
+        {
+        // [test cases entries] - do not remove
+        
+        // NOTE: When compiled to GCCE, there must be Classname::
+        // declaration in front of the method name, e.g. 
+        // Ct_msgstore::PrintTest. Otherwise the compiler
+        // gives errors.
+        ENTRY( "Oom1",              Ct_bufferedmsgcreator::Oom1L ),
+        ENTRY( "ErrHandling1",      Ct_bufferedmsgcreator::ErrHandling1L ),
+        ENTRY( "ErrHandling2",      Ct_bufferedmsgcreator::ErrHandling2L ),
+        // Example how to use OOM functionality
+        //OOM_ENTRY( "Loop test with OOM", Ct_msgstore::LoopTest, ETrue, 2, 3),
+        //OOM_FUNCENTRY( Ct_msgstore::PrintTest, ETrue, 1, 3 ),
+        };
+
+    // Verify that case number is valid
+    if( (TUint) aCaseNumber >= sizeof( KCases ) / 
+                               sizeof( TCaseInfoInternal ) )
+        {
+        // Invalid case, construct empty object
+        TCaseInfo null( (const TText*) L"" );
+        null.iMethod = NULL;
+        null.iIsOOMTest = EFalse;
+        null.iFirstMemoryAllocation = 0;
+        null.iLastMemoryAllocation = 0;
+        return null;
+        } 
+
+    // Construct TCaseInfo object and return it
+    TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
+    tmp.iMethod = KCases[ aCaseNumber ].iMethod;
+    tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
+    tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
+    tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
+    return tmp;
+
+    }
+
+// -----------------------------------------------------------------------------
+// 
+// -----------------------------------------------------------------------------
+//
+TInt Ct_bufferedmsgcreator::Oom1L( TTestResult& aResult )
+    {
+    _LIT( KFolderTests, "Oom1" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KFolderTests, KEnter );
+
+    //
+    CContainerStore* store = CContainerStore::NewL();
+    CleanupStack::PushL( store );
+    
+    CBufferedMessageCreator* creator
+        = CBufferedMessageCreator::NewL( *store ); 
+    CleanupStack::PushL( creator );
+
+    //setup
+    _LIT8( KTestProperties, "Test123,123,123" );
+    _LIT8( KTestContent, "Content123,123,123" );
+    TMsgStoreId sequence = 0;
+    
+    TMsgStoreCreateContainerCmdParams msgParams={0};
+    msgParams.iType = EMsgStoreMessageBits;
+    TMsgStoreCreateContainerCmdParams partParams={0};
+    partParams.iType = EMsgStorePartBits;
+    
+    //main loop
+    for ( TInt i = 0; i < 100; ++i )
+        {
+        RBuf8 msgProps;
+        msgProps.CreateL( KTestProperties );
+        msgProps.CleanupClosePushL();
+
+        RBuf8 msgProps1;
+        msgProps1.CreateL( KTestProperties );
+        msgProps1.CleanupClosePushL();
+
+        RBuf8 partProps;
+        partProps.CreateL( KTestProperties );
+        partProps.CleanupClosePushL();
+
+        RBuf8 partProps1;
+        partProps1.CreateL( KTestProperties );
+        partProps1.CleanupClosePushL();
+
+        RBuf8 content;
+        content.CreateL( KTestContent );
+        content.CleanupClosePushL();
+    
+        __UHEAP_SETFAIL( RAllocator::EDeterministic, i );
+
+        TRAP_IGNORE(
+            ::CallSequence1L( *store, *creator, msgProps, msgProps1, partProps,
+                 partProps1, content, sequence );
+        );
+        
+        __UHEAP_RESET;
+        
+        CleanupStack::PopAndDestroy( &content );
+        CleanupStack::Pop( &partProps1 );
+        CleanupStack::Pop( &partProps );
+        CleanupStack::Pop( &msgProps1 );
+        CleanupStack::Pop( &msgProps );
+        }
+    
+    CleanupStack::PopAndDestroy( creator );
+    CleanupStack::PopAndDestroy( store );
+    
+    TestModuleIf().Printf( 0, KFolderTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    TInt result = KErrNone;
+    _LIT( KPassDescription, "Oom1 passed" );
+    _LIT( KFailDescription, "Oom1 failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+
+TInt Ct_bufferedmsgcreator::ErrHandling1L( TTestResult& aResult )
+    {
+    _LIT( KTestName, "ErrHandling1" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KTestName, KEnter );
+
+    //
+    CContainerStore* store = CContainerStore::NewL();
+    CleanupStack::PushL( store );
+    
+    CBufferedMessageCreator* creator
+        = CBufferedMessageCreator::NewL( *store ); 
+    CleanupStack::PushL( creator );
+
+    //setup
+    _LIT8( KTestProperties, "Test123,123,123" );
+    _LIT8( KTestContent, "Content123,123,123" );
+    TMsgStoreId sequence = 0;
+    
+    //main loop
+    for ( TInt i = 0; i < 100; ++i )
+        {
+        RBuf8 msgProps;
+        msgProps.CreateL( KTestProperties );
+        msgProps.CleanupClosePushL();
+
+        RBuf8 msgProps1;
+        msgProps1.CreateL( KTestProperties );
+        msgProps1.CleanupClosePushL();
+
+        RBuf8 partProps;
+        partProps.CreateL( KTestProperties );
+        partProps.CleanupClosePushL();
+
+        RBuf8 partProps1;
+        partProps1.CreateL( KTestProperties );
+        partProps1.CleanupClosePushL();
+
+        RBuf8 content;
+        content.CreateL( KTestContent );
+        content.CleanupClosePushL();
+    
+        store->SetLeaveAfter( i );
+
+        TRAP_IGNORE(
+            ::CallSequence1L( *store, *creator, msgProps, msgProps1, partProps,
+                 partProps1, content, sequence );
+        );        
+        
+        CleanupStack::PopAndDestroy( &content );
+        CleanupStack::Pop( &partProps1 );
+        CleanupStack::Pop( &partProps );
+        CleanupStack::Pop( &msgProps1 );
+        CleanupStack::Pop( &msgProps );
+        }
+    
+    CleanupStack::PopAndDestroy( creator );
+    CleanupStack::PopAndDestroy( store );
+    
+    TestModuleIf().Printf( 0, KTestName, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    TInt result = KErrNone;
+    _LIT( KPassDescription, "ErrHandling1 passed" );
+    _LIT( KFailDescription, "ErrHandling1 failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+
+TInt Ct_bufferedmsgcreator::ErrHandling2L( TTestResult& aResult )
+    {
+    _LIT( KTestName, "ErrHandling2" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KTestName, KEnter );
+
+    //
+    CContainerStore* store = CContainerStore::NewL();
+    CleanupStack::PushL( store );
+    
+    CBufferedMessageCreator* creator
+        = CBufferedMessageCreator::NewL( *store ); 
+    CleanupStack::PushL( creator );
+
+    //setup
+    _LIT8( KTestProperties, "Test123,123,123" );
+    _LIT8( KTestContent, "Content123,123,123" );
+    TMsgStoreId sequence = 0;
+    
+    //main loop
+    for ( TInt i = 0; i < 10; ++i )
+        {
+        RBuf8 msgProps;
+        msgProps.CreateL( KTestProperties );
+        msgProps.CleanupClosePushL();
+
+        RBuf8 msgProps1;
+        msgProps1.CreateL( KTestProperties );
+        msgProps1.CleanupClosePushL();
+
+        RBuf8 partProps;
+        partProps.CreateL( KTestProperties );
+        partProps.CleanupClosePushL();
+
+        RBuf8 partProps1;
+        partProps1.CreateL( KTestProperties );
+        partProps1.CleanupClosePushL();
+
+        RBuf8 content;
+        content.CreateL( KTestContent );
+        content.CleanupClosePushL();
+    
+        store->ContentManager().SetLeaveAfter( i );
+
+        TRAP_IGNORE(
+            ::CallSequence1L( *store, *creator, msgProps, msgProps1, partProps,
+                 partProps1, content, sequence );
+        );        
+        
+        CleanupStack::PopAndDestroy( &content );
+        CleanupStack::Pop( &partProps1 );
+        CleanupStack::Pop( &partProps );
+        CleanupStack::Pop( &msgProps1 );
+        CleanupStack::Pop( &msgProps );
+        }
+    
+    CleanupStack::PopAndDestroy( creator );
+    CleanupStack::PopAndDestroy( store );
+    
+    TestModuleIf().Printf( 0, KTestName, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    TInt result = KErrNone;
+    _LIT( KPassDescription, "ErrHandling2 passed" );
+    _LIT( KFailDescription, "ErrHandling2 failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+
+void CallSequence1L( CContainerStore& aStore, CBufferedMessageCreator& aCreator,
+    RBuf8& aMsgProps, RBuf8& aMsgProps1, RBuf8& aPartProps, RBuf8& aPartProps1,
+    RBuf8& aContent, TMsgStoreId& aSequence )
+    {
+    TMsgStoreCreateContainerCmdParams msgParams={0};
+    msgParams.iType = EMsgStoreMessageBits;
+    TMsgStoreCreateContainerCmdParams partParams={0};
+    partParams.iType = EMsgStorePartBits;
+
+    msgParams.iId = ++aSequence;
+
+    aCreator.EnqueueL(
+            aStore,
+            msgParams,
+            aMsgProps );
+    
+    aCreator.AppendContentL( aStore, msgParams.iId, aContent );
+    aCreator.PrependContentL( aStore, msgParams.iId, aContent );
+    aCreator.ReplaceContentL( aStore, msgParams.iId, aContent );
+    
+    aCreator.AbandonMessageL( aStore, msgParams.iId );
+
+    partParams.iId = ++aSequence;
+    partParams.iParentId = msgParams.iId;
+
+    aCreator.EnqueueL(
+            aStore,
+            partParams,
+            aPartProps );
+    
+    aCreator.AppendContentL( aStore, partParams.iId, aContent );
+    aCreator.PrependContentL( aStore, partParams.iId, aContent );
+    aCreator.ReplaceContentL( aStore, partParams.iId, aContent );
+
+    //
+    aCreator.ResetL( aStore );
+    
+    //
+    msgParams.iId = ++aSequence;
+
+    aCreator.EnqueueL(
+            aStore,
+            msgParams,
+            aMsgProps1 );
+    
+    aCreator.AppendContentL( aStore, msgParams.iId, aContent );
+    aCreator.PrependContentL( aStore, msgParams.iId, aContent );
+    aCreator.ReplaceContentL( aStore, msgParams.iId, aContent );
+
+    partParams.iId = ++aSequence;
+    partParams.iParentId = msgParams.iId;
+
+    aCreator.EnqueueL(
+            aStore,
+            partParams,
+            aPartProps1 );
+
+    aCreator.AppendContentL( aStore, partParams.iId, aContent );
+    aCreator.PrependContentL( aStore, partParams.iId, aContent );
+    aCreator.ReplaceContentL( aStore, partParams.iId, aContent );
+    
+    //
+    aCreator.CommitMessageL( aStore, &aStore );
+    }
+
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+/*
+?type  ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg )  // ?description
+    {
+
+    ?code
+
+    }
+*/
+//  [End of File] - do not remove
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/Bmarm/t_msgstoreU.DEF	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	LibEntryL__Fv @ 1 NONAME R3UNUSED ; LibEntryL(void)
+	SetRequirements__FRP16CTestModuleParamRUl @ 2 NONAME R3UNUSED ; SetRequirements(CTestModuleParam *&, unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/Bwins/t_msgstoreU.DEF	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * __cdecl LibEntryL(void)
+	?SetRequirements@@YAHAAPAVCTestModuleParam@@AAK@Z @ 2 NONAME ; int __cdecl SetRequirements(class CTestModuleParam * &,unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/EABI/t_msgstoreU.def	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	_Z9LibEntryLv @ 1 NONAME
+	_Z15SetRequirementsRP16CTestModuleParamRm @ 2 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/group/bld.inf	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Message store unit tests build file.
+*
+*/
+
+
+
+PRJ_PLATFORMS
+// specify the platforms your component needs to be built for here
+// defaults to WINS MARM so you can ignore this if you just build these
+DEFAULT
+
+PRJ_TESTEXPORTS
+// NOTE: If using ARS requirements all export operations should be done under this.
+// 'abld test export'
+
+PRJ_EXPORTS
+// Specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in /epoc32/include
+// Example: 
+/*
+/agnmodel/inc/AGMCOMON.H
+*/
+
+PRJ_TESTMMPFILES
+t_msgstore.mmp
+
+PRJ_MMPFILES
+t_msgstore_nrm.mmp
+
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+// Example:
+/*
+/agnmodel/group/agnmodel.mmp
+#if defined(MARM)
+/agnmodel/group/agsvexe.mmp
+#endif
+*/
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/group/ctc_postprocess.bat	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,22 @@
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:  processing data collected by CTC
+rem
+
+cd ..\..\group
+REM Force Function Coverage.  The data was collected for MultiCondition Coverage, but
+REM We can just show the Function Coverage.
+call ctcpost -ff -p profile.txt
+call ctc2html -i profile.txt
+cd ..\tsrc_stif\group
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/group/ctc_preprocess.bat	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,25 @@
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:  prepare the invironment for CTC data collection
+rem
+
+cd ..\..\group
+del MON.sym
+del MON.dat
+del profile.txt
+del /q CTCHTML
+call bldmake bldfiles
+call abld reallyclean
+call ctcwrap -i m -C "EXCLUDE+*/DebugLog/*" abld build winscw udeb
+cd ..\tsrc_stif\group
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/group/run_coverage_test.bat	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,38 @@
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:  calls ctc_preprocess, run_unit_test, and ctc_post_process
+rem
+
+@echo off
+REM -------------------------------
+REM Preparing CTC Instrumentation
+REM -------------------------------
+call ctc_preprocess.bat
+
+REM -------------------------------
+REM Build test modules
+REM -------------------------------
+call bldmake bldfiles
+call abld reallyclean winscw
+call abld build winscw udeb
+
+REM -------------------------------
+REM Run the test modules
+REM -------------------------------
+call run_unit_tests.bat
+
+REM -------------------------------
+REM Post process CTC data
+REM -------------------------------
+call ctc_postprocess.bat
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/group/run_unit_tests.bat	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,17 @@
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:  invokes stiff command line interface to run the tests
+rem
+
+\epoc32\release\winscw\udeb\ATSInterface -testmodule t_msgstore -engineini c:\testframework\testframework.ini
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/group/t_msgstore.mmp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  project file for Message Store unit test
+*
+*/
+
+// For OS_LAYER_SYSTEMINCLUDE
+#include <platform_paths.hrh>
+
+TARGET          t_msgstore.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E7
+
+CAPABILITY      ALL -TCB
+/* Remove comments and replace 0x00000000 with correct vendor id */
+// VENDORID     0x00000000
+/* Remove comments and replace 0x00000000 with correct secure id */
+SECUREID     0x20022BFD
+
+//TARGETPATH      target_path
+DEFFILE         t_msgstore.def
+
+USERINCLUDE     ../inc 
+USERINCLUDE     ../../../message_store/common/inc 
+USERINCLUDE     ../../../message_store/server/inc 
+
+OS_LAYER_SYSTEMINCLUDE	
+SYSTEMINCLUDE   ../../../../../inc
+
+SOURCEPATH      ../src
+SOURCE          t_msgstore.cpp
+SOURCE          t_msgstoreCases.cpp
+SOURCE			asynctestcasebase.cpp
+SOURCE			mailboxtests.cpp
+SOURCE			propertytests.cpp
+SOURCE          FolderTests.cpp
+SOURCE          MessageTests.cpp
+SOURCE          PartTests.cpp
+SOURCE          ObserverTests.cpp
+SOURCE          ContentTests.cpp
+SOURCE          MruTests.cpp
+SOURCE          SearchTests.cpp
+SOURCE          SortTests.cpp
+SOURCE          SizeTests.cpp
+SOURCE          ShutdownServerTest.cpp
+SOURCE          DbCorruptTests.cpp
+SOURCE          EncryptionTests.cpp
+
+//RESOURCE        resource_file
+//RESOURCE        resource_file2
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib 
+LIBRARY         bafl.lib 
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY         messagestoreclient.lib
+LIBRARY         tzclient.lib
+LIBRARY         edbms.lib
+LIBRARY         estor.lib
+
+LANG            SC
+
+/*
+START WINS      
+?wins_specific_information
+END
+
+START MARM
+?marm_specific_information
+END
+*/
+// Other possible keywords:
+ 
+// DOCUMENT     ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes)
+/*
+START BITMAP ?target
+TARGETPATH   ?emulated_path_on_target_machine
+HEADER
+SOURCE       ?color_depth ?source_bitmap
+END
+*/
+// DEFFILE ?filename
+// AIF ?filename// End of File
+
+EPOCALLOWDLLDATA
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/group/t_msgstore.pkg	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,61 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:  package file for Message Store unit test 
+;
+;
+; Installation file for STIF
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x20022BFD),1,1,0,TYPE=SA
+
+; Series60 product id for S60 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Logo
+; None
+
+; Package signature - Optional
+; None
+
+; Start of Package body
+
+; Condition blocks
+; None
+
+; Options list
+; None
+
+; Install files
+"\epoc32\release\armv5\udeb\t_msgstore.dll"   -   "!:\Sys\Bin\t_msgstore.dll"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/group/t_msgstore_DoxyFile.txt	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,222 @@
+# Doxyfile 1.4.1
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME           = t_msgstore
+PROJECT_NUMBER         = 
+OUTPUT_DIRECTORY       = \t_msgstore\
+CREATE_SUBDIRS         = NO
+OUTPUT_LANGUAGE        = English
+USE_WINDOWS_ENCODING   = YES
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ABBREVIATE_BRIEF       = 
+ALWAYS_DETAILED_SEC    = NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES        = NO
+STRIP_FROM_PATH        = 
+STRIP_FROM_INC_PATH    = 
+SHORT_NAMES            = NO
+JAVADOC_AUTOBRIEF      = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP         = NO
+INHERIT_DOCS           = YES
+DISTRIBUTE_GROUP_DOC   = NO
+TAB_SIZE               = 8
+ALIASES                = 
+OPTIMIZE_OUTPUT_FOR_C  = YES
+OPTIMIZE_OUTPUT_JAVA   = NO
+SUBGROUPING            = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL            = YES
+EXTRACT_PRIVATE        = NO
+EXTRACT_STATIC         = NO
+EXTRACT_LOCAL_CLASSES  = NO
+EXTRACT_LOCAL_METHODS  = NO
+HIDE_UNDOC_MEMBERS     = NO
+HIDE_UNDOC_CLASSES     = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS      = NO
+INTERNAL_DOCS          = YES
+CASE_SENSE_NAMES       = YES
+HIDE_SCOPE_NAMES       = NO
+SHOW_INCLUDE_FILES     = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = YES
+SORT_BRIEF_DOCS        = NO
+SORT_BY_SCOPE_NAME     = NO
+GENERATE_TODOLIST      = NO
+GENERATE_TESTLIST      = NO
+GENERATE_BUGLIST       = NO
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS       = 
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES        = YES
+SHOW_DIRECTORIES       = YES
+FILE_VERSION_FILTER    = 
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = NO
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR      = YES
+WARN_NO_PARAMDOC       = NO
+WARN_FORMAT            = "$file:$line: $text"
+WARN_LOGFILE           = 
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = \t_msgstore\
+FILE_PATTERNS          = *.h \
+                         *.rh \
+                         *.hrh
+RECURSIVE              = YES
+EXCLUDE                = 
+EXCLUDE_SYMLINKS       = NO
+EXCLUDE_PATTERNS       = 
+EXAMPLE_PATH           = 
+EXAMPLE_PATTERNS       = 
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             = 
+INPUT_FILTER           = 
+FILTER_PATTERNS        = 
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER         = NO
+INLINE_SOURCES         = NO
+STRIP_CODE_COMMENTS    = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION    = YES
+VERBATIM_HEADERS       = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = NO
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          = 
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = NO
+HTML_OUTPUT            = html
+HTML_FILE_EXTENSION    = .html
+HTML_HEADER            = 
+HTML_FOOTER            = 
+HTML_STYLESHEET        = 
+HTML_ALIGN_MEMBERS     = YES
+GENERATE_HTMLHELP      = YES
+CHM_FILE               = 
+HHC_LOCATION           = 
+GENERATE_CHI           = NO
+BINARY_TOC             = YES
+TOC_EXPAND             = YES
+DISABLE_INDEX          = YES
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = YES
+TREEVIEW_WIDTH         = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         = latex
+MAKEINDEX_CMD_NAME     = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         = 
+LATEX_HEADER           = 
+PDF_HYPERLINKS         = NO
+USE_PDFLATEX           = NO
+LATEX_BATCHMODE        = NO
+LATEX_HIDE_INDICES     = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = YES
+RTF_OUTPUT             = Doc
+COMPACT_RTF            = YES
+RTF_HYPERLINKS         = YES
+RTF_STYLESHEET_FILE    = 
+RTF_EXTENSIONS_FILE    = 
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = NO
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+XML_OUTPUT             = xml
+XML_SCHEMA             = 
+XML_DTD                = 
+XML_PROGRAMLISTING     = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX = 
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = YES
+EXPAND_ONLY_PREDEF     = NO
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           = 
+INCLUDE_FILE_PATTERNS  = 
+PREDEFINED             = NONSHARABLE_CLASS
+EXPAND_AS_DEFINED      = 
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+TAGFILES               = 
+GENERATE_TAGFILE       = 
+ALLEXTERNALS           = NO
+EXTERNAL_GROUPS        = YES
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS         = YES
+HIDE_UNDOC_RELATIONS   = YES
+HAVE_DOT               = NO
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = YES
+GROUP_GRAPHS           = YES
+UML_LOOK               = NO
+TEMPLATE_RELATIONS     = YES
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+CALL_GRAPH             = NO
+GRAPHICAL_HIERARCHY    = YES
+DIRECTORY_GRAPH        = YES
+DOT_IMAGE_FORMAT       = png
+DOT_PATH               = 
+DOTFILE_DIRS           = 
+MAX_DOT_GRAPH_WIDTH    = 1024
+MAX_DOT_GRAPH_HEIGHT   = 1024
+MAX_DOT_GRAPH_DEPTH    = 0
+DOT_TRANSPARENT        = NO
+DOT_MULTI_TARGETS      = NO
+GENERATE_LEGEND        = YES
+DOT_CLEANUP            = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+SEARCHENGINE           = NO
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/group/t_msgstore_nrm.mmp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  project file for Message Store unit test
+*
+*/
+
+// For OS_LAYER_SYSTEMINCLUDE
+#include <platform_paths.hrh>
+
+TARGET          t_msgstore.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E7
+
+CAPABILITY      ALL -TCB
+/* Remove comments and replace 0x00000000 with correct vendor id */
+// VENDORID     0x00000000
+/* Remove comments and replace 0x00000000 with correct secure id */
+SECUREID     0x20022BFD
+
+//TARGETPATH      target_path
+DEFFILE         t_msgstore.def
+
+USERINCLUDE     ../inc 
+USERINCLUDE     ../../../message_store/common/inc 
+USERINCLUDE     ../../../message_store/server/inc 
+
+OS_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   ../../../../../inc
+    
+SOURCEPATH      ../src
+SOURCE          t_msgstore.cpp
+SOURCE          t_msgstoreCases.cpp
+SOURCE			asynctestcasebase.cpp
+SOURCE			mailboxtests.cpp
+SOURCE			propertytests.cpp
+SOURCE          FolderTests.cpp
+SOURCE          MessageTests.cpp
+SOURCE          PartTests.cpp
+SOURCE          ObserverTests.cpp
+SOURCE          ContentTests.cpp
+SOURCE          MruTests.cpp
+SOURCE          SearchTests.cpp
+SOURCE          SortTests.cpp
+SOURCE          SizeTests.cpp
+SOURCE          DbCorruptTests.cpp
+SOURCE          ShutdownServerTest.cpp
+SOURCE          EncryptionTests.cpp
+
+//RESOURCE        resource_file
+//RESOURCE        resource_file2
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib 
+LIBRARY         bafl.lib 
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY         messagestoreclient.lib
+LIBRARY         tzclient.lib
+LIBRARY         edbms.lib
+LIBRARY         estor.lib
+
+LANG            SC
+
+/*
+START WINS      
+?wins_specific_information
+END
+
+START MARM
+?marm_specific_information
+END
+*/
+// Other possible keywords:
+ 
+// DOCUMENT     ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes)
+/*
+START BITMAP ?target
+TARGETPATH   ?emulated_path_on_target_machine
+HEADER
+SOURCE       ?color_depth ?source_bitmap
+END
+*/
+// DEFFILE ?filename
+// AIF ?filename// End of File
+
+EPOCALLOWDLLDATA
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/AsyncTestCaseBase.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,215 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  t_ImsIdsPlugin test module.
+*
+*/
+
+
+
+#ifndef ASYNC_TESTCASE_BASE_H
+#define ASYNC_TESTCASE_BASE_H
+
+// INCLUDES
+#include "StifTestModule.h"
+#include <StifLogger.h>
+#include <NormalHardcodedAssert.h>
+#include <msgstoreapi.h>
+
+//Forward declaration
+
+class CYieldHelper : public CTimer
+    {
+    public:
+        static CYieldHelper* NewL();
+        virtual ~CYieldHelper();
+
+        void Yield( TInt aMicroSeconds );
+        
+    private:
+        CYieldHelper();
+        void ConstructL();
+        
+        // inherited from CActive
+        virtual void RunL();
+        virtual void DoCancel();
+        
+    private:
+        CActiveSchedulerWait* iYieldWait;        
+    };
+
+// CLASS DECLARATION
+class RDebugSession : public RSessionBase 
+    {
+    public:
+    
+        // SERVER MUST BE ALREADY RUNNING!
+        TInt Connect();
+
+        void Close();
+                
+        void SendBackupRestoreEventL( TUint aEvent );  
+        
+        void SendPointSecEventL( TBool aLock );
+        
+        void SimulateLowDiskSpaceL( TUint aLatency );        
+        
+        TInt GetEncryptionStateL();
+        
+        void ShutdownServerL();
+    };
+
+
+// CLASS DECLARATION
+class CAsyncTestCaseBase : public CTimer
+    {
+    public:  // Constructors and destructor
+
+        virtual ~CAsyncTestCaseBase();
+        
+        inline TInt Result() { return iResult; }
+
+    protected:
+        enum TState
+            {
+            EStateInit,
+            EStateExecute,
+            EStateDone,
+            };
+        
+        /**
+        * C++ default constructor.
+        */
+        CAsyncTestCaseBase( CStifLogger* aLogger );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        //steps for preparing the test cases
+        virtual void BeforeTestL();
+        
+        //abstract method to start executing the real test case
+        // return ETrue if execution is done
+        virtual TBool ExecuteL() = 0;
+
+        //steps for after the test cases, make sure this is always run
+        virtual void AfterTestL();
+        
+        //stop the execution
+        virtual void Stop();
+        
+        //From CTimer
+        virtual void RunL();
+        virtual TInt RunError(TInt aError);
+        virtual void DoCancel();
+        
+        void LogHeader( const TDesC& aTestType );
+        
+        void CheckCondition( const TDesC& aCondition, TBool aPassed, TBool aLog=ETrue );
+        
+        void ComparePropertiesL( const CMsgStorePropertyContainer& aProperties1, 
+                                 const CMsgStorePropertyContainer& aProperties2 );
+
+        void SimulateLowDiskSpaceL( TUint aLatency );
+        void TriggerBackupRestoreEventL( TUint aEvent );
+        void TriggerPointSecEventL( TBool aLock );
+        void ShutdownServerL();
+        void Yield( TInt aMicroSeconds  );
+        void WaitForServerToTerminate();
+        
+        TUint TestAddIntegerPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, TUint32 aValue, TBool aUseAddOrUpdate = EFalse );
+        TUint TestAddBoolPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, TBool aValue, TBool aUseAddOrUpdate = EFalse  );
+        TUint TestAddDes8PropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const TDesC8& aValue, TBool aUseAddOrUpdate = EFalse  );
+        TUint TestAddDesPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const TDesC& aValue, TBool aUseAddOrUpdate = EFalse  );
+        TUint TestAddContainerPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const CMsgStorePropertyContainer& aValue, TBool aUseAddOrUpdate = EFalse );
+        TUint TestAddTimePropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const TTime& aValue, TBool aUseAddOrUpdate = EFalse );
+        TUint TestAddAddressPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const RMsgStoreAddress& aValue, TBool aUseAddOrUpdate = EFalse );
+
+        void TestRemovePropertyL( CMsgStorePropertyContainer& aProperties, TUint aIndex );
+
+        void TestUpdateDes8PropertyL( CMsgStorePropertyContainer& aProperties, 
+                                      TUint aIndex, 
+                                      const TDesC8& aNewValue, 
+                                      TBool aUseAddOrUpdate = EFalse );
+        
+        void TestUpdateDesPropertyL( CMsgStorePropertyContainer& aProperties, 
+                                     TUint aIndex, 
+                                     const TDesC& aNewValue, 
+                                     TBool aUseAddOrUpdate = EFalse );
+        
+        void TestUpdateContainerPropertyL( CMsgStorePropertyContainer& aProperties, 
+                                           TUint aIndex, 
+                                           CMsgStorePropertyContainer& aNewValue, 
+                                           TBool aUseAddOrUpdate = EFalse );
+        
+        void TestUpdateBoolPropertyL( CMsgStorePropertyContainer& aProperties, 
+                                      TUint aIndex, 
+                                      TBool aNewValue, 
+                                      TBool aUseAddOrUpdate = EFalse );
+        
+        void TestUpdateIntegerPropertyL( CMsgStorePropertyContainer& aProperties, 
+                                         TUint aIndex, 
+                                         TUint32 aNewValue, 
+                                         TBool aUseAddOrUpdate = EFalse );
+        
+        void TestUpdateTimePropertyL( CMsgStorePropertyContainer& aProperties, 
+                                      TUint aIndex, 
+                                      const TTime& aNewValue, 
+                                      TBool aUseAddOrUpdate = EFalse );
+        
+        void TestUpdateAddressPropertyL( CMsgStorePropertyContainer& aProperties, 
+                                         TUint aIndex, 
+                                         const RMsgStoreAddress& aNewValue, 
+                                         TBool aUseAddOrUpdate = EFalse );
+        
+        void CopyDesToDes8( const TDesC& aDes, TDes8& aDes8 );
+        
+        void CreateFileL( const TDesC& aName, 
+                         TUint aTotalLength,
+                         TChar aFillChar, 
+                         const TDesC& aString, 
+                         TUint aOffset );
+        
+        void CreateRandomMessagesL( CMsgStoreMailBox* aMailBox1, 
+                                    TMsgStoreId aFolder1Id, 
+                                    TInt aCount, 
+                                    TBool aKeepIds = EFalse, 
+                                    TBool aLog = EFalse );
+        
+        void CreateRandomString( TDes& aString, TInt aLength, TInt64& aSeed );
+        
+        void SetMessageContentL( CMsgStoreMessage* aMessage, const TDesC8& aContent );
+        
+    protected:
+        // Pointer to logger
+        CStifLogger*       iLog;
+        
+        CActiveScheduler*  iActiveScheduler;
+        CMsgStore*         iMsgStore;
+        
+        TState             iState;
+        TInt               iResult;
+        TInt               iCaseId;
+        
+        RArray<TMsgStoreId> iMatches;
+        RPointerArray<CMsgStoreMessage> iMessages;
+        
+    private:
+        CYieldHelper*      iYieldHelper;
+    };
+
+#endif      // ASYNC_TESTCASE_BASE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/ContentTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef CONTENT_TESTS_H
+#define CONTENT_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+#include <msgstoreapi.h>
+
+class CContentTests : public CAsyncTestCaseBase 
+    {
+    public:  // Constructors and destructor
+
+        static CContentTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CContentTests();
+
+    private:
+        
+        CContentTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+    private:
+        
+    };
+
+#endif      // CONTENT_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/DbCorruptTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef DB_CORRUPTION_TESTS_H
+#define DB_CORRUPTION_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+#include <msgstoreapi.h>
+
+class CDbCorruptTests : public CAsyncTestCaseBase 
+    {
+    public:  // Constructors and destructor
+
+        static CDbCorruptTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CDbCorruptTests();
+
+    private:
+        
+        CDbCorruptTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+    private:
+        
+    };
+
+#endif      // DB_CORRUPTION_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/EncryptionTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef ENCRYPTION_TESTS_H
+#define ENCRYPTION_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+#include <msgstoreapi.h>
+
+class CEncryptionTests : public CAsyncTestCaseBase 
+    {
+    public:  // Constructors and destructor
+
+        static CEncryptionTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CEncryptionTests();
+
+    private:
+        
+        CEncryptionTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+        void WaitUntilEncryptDecryptCompleteL( TInt aCurrentState, CMsgStoreMailBox* aMailBox );
+        void CompareMessagesL( CMsgStoreMailBox* aMailBox );
+        void CompareAccountsL( CMsgStore* aSession, RPointerArray<CMsgStoreAccount>& aAccounts );
+        void GetSortedIdsL( CMsgStoreMailBox* aMailBox, TMsgStoreId aFolderId, TMsgStoreSortByField aSortedBy, TInt aCount, RArray<TMsgStoreId>& aSortedIds );
+        void CompareSortedIdArraysL( RArray<TMsgStoreId>& aIDs1, RArray<TMsgStoreId>& aIDs2 );
+        
+    private:
+        RArray<TPtrC8> iTestContentArray;
+        
+    };
+
+#endif      // ENCRYPTION_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/FolderTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef FOLDER_TESTS_H
+#define FOLDER_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+#include <msgstoreapi.h>
+
+class CFolderTests : public CAsyncTestCaseBase 
+    {
+    public:  // Constructors and destructor
+
+        static CFolderTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CFolderTests();
+
+    private:
+        
+        CFolderTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+        void VerifyFolderIdsL( RPointerArray<CMsgStoreFolder>& aFolders, RArray<TMsgStoreId>& aExpectedIds );
+    };
+
+#endif      // FOLDER_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/MailboxTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef MAILBOX_TESTS_H
+#define MAILBOX_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+
+class CMailboxTests : public CAsyncTestCaseBase 
+    {
+    public:  // Constructors and destructor
+
+        static CMailboxTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CMailboxTests();
+
+    private:
+        
+        CMailboxTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+        void DoListAccountsL( CMsgStore& aSession );
+    };
+
+#endif      // INIT_TESTCASE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/MessageTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef MESSAGE_TESTS_H
+#define MESSAGE_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+#include <msgstoreapi.h>
+
+class CMessageTests : public CAsyncTestCaseBase 
+    {
+    public:  // Constructors and destructor
+
+        static CMessageTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CMessageTests();
+
+    private:
+        
+        CMessageTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+        void VerifyMessageIdsL( CMsgStoreMailBox& aMailBox, TMsgStoreId aFolderId, RArray<TMsgStoreId>& expectedIds );
+        void DoMessageCountsL( CMsgStoreMailBox& aMailBox );
+        
+    };
+
+#endif      // MESSAGE_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/MruTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef MRU_TESTS_H
+#define MRU_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+#include <msgstoreapi.h>
+
+class CMruTests : public CAsyncTestCaseBase 
+    {
+    public:  // Constructors and destructor
+
+        static CMruTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CMruTests();
+
+    private:
+        
+        CMruTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+        void CompareMruArraysL( CMsgStoreMailBox* aMailBox, RPointerArray<CMsgStoreAddress>& aExpected );
+        
+    private:
+        
+    };
+
+#endif      // MRU_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/ObserverTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef OBSERVER_TESTS_H
+#define OBSERVER_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+#include <msgstoreapi.h>
+
+class CObserverTests : public CAsyncTestCaseBase, public MMsgStoreObserver, public MMsgStoreMailBoxObserver 
+    {
+    public:  // Constructors and destructor
+
+        static CObserverTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CObserverTests();
+
+    private:
+        class TObserverEvent
+            {
+            public:
+                TInt    iMailBoxId;
+                TInt    iOperation;
+                TInt    iType;
+                TInt    iId;
+                TInt    iParentId;
+                TInt    iOtherId;
+                TUint32 iFlags;
+                TBuf8<KMaxAccountNameLen>   iName;
+                TBuf8<KMaxAccountNameLen>   iNewName;
+            };
+        
+        void StartRecordingObserverEvents();
+        
+        void StopRecordingObserverEvents();
+        
+        void VerifyRecordedObserverEventsL( TBool aVerifyOrder, RArray<TObserverEvent>& aExpectedEvents );
+        
+        // inherited from MMsgStoreObserver
+        virtual void ModificationNotify( TMsgStoreId aMailBoxId, 
+                                         TMsgStoreOperation aOperation, 
+                                         TMsgStoreContainerType aType, 
+                                         TUint32 aFlags, 
+                                         TMsgStoreId aId, 
+                                         TMsgStoreId aParentId, 
+                                         TMsgStoreId aOtherId );
+        
+        virtual void SystemEventNotify( TMsgStoreSystemEvent aEvent );
+        
+        virtual void AccountEventNotify( TMsgStoreAccountEvent aEvent, 
+                                         TInt32 aOwnerId, 
+                                         const TDesC& aName, 
+                                         const TDesC& aNewName, 
+                                         TMsgStoreId aMailboxId );
+        
+        CObserverTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+    private:
+        TBool                  iRecordEvents;
+        RArray<TObserverEvent> iRecordedEvents;
+        
+        
+    };
+
+#endif      // OBSERVER_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/PartTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef PART_TESTS_H
+#define PART_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+#include <msgstoreapi.h>
+
+class CPartTests : public CAsyncTestCaseBase 
+    {
+    public:  // Constructors and destructor
+
+        static CPartTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CPartTests();
+
+    private:
+        
+        CPartTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+    };
+
+#endif      // PART_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/PropertyTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef PROPERTY_TESTS_H
+#define PROPERTY_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+
+class CPropertyTests : public CAsyncTestCaseBase 
+    {
+    public:  // Constructors and destructor
+
+        static CPropertyTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CPropertyTests();
+
+    private:
+        
+        CPropertyTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+    };
+
+#endif      // PROPERTY_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/SearchTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef SEARCH_TESTS_H
+#define SEARCH_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+#include <msgstoreapi.h>
+
+class CSearchTests : public CAsyncTestCaseBase, public MMsgStoreSearchClient
+    {
+    public:  // Constructors and destructor
+
+        static CSearchTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CSearchTests();
+
+    private:
+        
+        CSearchTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+        // inherited from MMsgStoreSearchClient        
+        virtual void MatchFound( CMsgStorePropertyContainer*& aMessage );   
+        virtual void SearchCompleted();
+
+        void ValidateSearchResults( RArray<TMsgStoreId>& aExpectedMatches, TBool aIgnoreExtra = EFalse );
+        
+        void ReplaceMessageContentWithFileL( CMsgStoreMessage* aMessage, const TDesC& KFilename );
+        
+        void SetSubjectAndAddressL( CMsgStoreMessage* aMessage, 
+                                   const TDesC& aSubject, 
+                                   const TDesC& aDisplayName, 
+                                   const TDesC& aAddress, 
+                                   const TDesC8& aAddressType );
+        
+    private:
+        
+        CMsgStoreMailBox*   iSessionToCancelSearch;
+        TBool               iSearchCompleted;
+        RArray<TMsgStoreId> iMatches;
+        RPointerArray<CMsgStoreMessage> iMessages;
+        RMsgStoreSearchCriteria*        iSearchCriteria;
+    };
+
+#endif      // SEARCH_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/ShutdownServerTest.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef SHUTDOWN_SERVER_TESTS_H
+#define SHUTDOWN_SERVER_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+#include <msgstoreapi.h>
+
+class CShutdownServerTest : public CAsyncTestCaseBase 
+    {
+    public:  // Constructors and destructor
+
+        static CShutdownServerTest* NewL( CStifLogger* aLog );
+        
+        virtual ~CShutdownServerTest();
+
+    private:
+        
+        CShutdownServerTest( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+    private:
+        
+    };
+
+#endif      // SHUTDOWN_SERVER_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/SizeTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef SIZE_TESTS_H
+#define SIZE_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+#include <msgstoreapi.h>
+
+class CSizeTests : public CAsyncTestCaseBase 
+    {
+    public:  // Constructors and destructor
+
+        static CSizeTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CSizeTests();
+
+    private:
+        
+        CSizeTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+    private:
+        
+    };
+
+#endif      // SIZE_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/SortTests.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  InitTestCase test module.
+*
+*/
+
+
+
+#ifndef SORT_TESTS_H
+#define SORT_TESTS_H
+
+// INCLUDES
+#include "AsyncTestCaseBase.h"
+#include <msgstoreapi.h>
+
+class CSortTests : public CAsyncTestCaseBase 
+    {
+    public:  // Constructors and destructor
+
+        static CSortTests* NewL( CStifLogger* aLog );
+        
+        virtual ~CSortTests();
+
+    private:
+        
+        CSortTests( CStifLogger* aLogger );
+        
+        void ConstructL();
+        
+        //from CAsyncTestCaseBase
+        TBool ExecuteL();
+        
+        void DoCreateMessagesL( TInt aMsgCount );
+        
+        TMsgStoreId CompareSortResultsL( RMsgStoreSortCriteria aCriteria, 
+                                         TMsgStoreIteratorDirection aDirection, 
+                                         const RPointerArray<CMsgStorePropertyContainer>& aResults );
+        
+                 
+    private:
+        
+    };
+
+#endif      // SORT_TESTS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/inc/t_msgstore.h	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,332 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  t_msgstore test module.
+*
+*/
+
+
+
+#ifndef T_MSGSTORE_H
+#define T_MSGSTORE_H
+
+// INCLUDES
+#include "StifTestModule.h"
+#include <StifLogger.h>
+#include <NormalHardcodedAssert.h>
+
+// CONSTANTS
+
+// MACROS
+#define TEST_MODULE_VERSION_MAJOR 0
+#define TEST_MODULE_VERSION_MINOR 0
+#define TEST_MODULE_VERSION_BUILD 0
+
+// Logging path
+_LIT( Kt_msgstoreLogPath, "\\logs\\testframework\\t_msgstore\\" ); 
+// Log file
+_LIT( Kt_msgstoreLogFile, "t_msgstore.txt" ); 
+_LIT( Kt_msgstoreLogFileWithTitle, "t_msgstore_[%S].txt" );
+
+#define GETPTR &
+#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
+#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
+#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
+#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
+
+// FORWARD DECLARATIONS
+class Ct_msgstore;
+
+// DATA TYPES
+// A typedef for function that does the actual testing,
+// function is a type 
+typedef TInt (Ct_msgstore::* TestFunction)(TTestResult&);
+
+// CLASS DECLARATION
+
+/**
+*  An internal structure containing a test case name and
+*  the pointer to function doing the test
+*/
+class TCaseInfoInternal
+    {
+    public:
+        const TText*    iCaseName;
+        TestFunction    iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+    };
+
+// CLASS DECLARATION
+
+/**
+*  A structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class TCaseInfo
+    {
+    public:
+        TPtrC iCaseName;
+        TestFunction iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+
+    TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
+        {
+        };
+
+    };
+
+
+// CLASS DECLARATION
+
+/**
+*  This a t_msgstore class.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS(Ct_msgstore) : public CTestModuleBase
+    {
+    public:  // Constructors and destructor
+
+
+        /**
+        * Two-phased constructor.
+        */
+        static Ct_msgstore* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~Ct_msgstore();
+
+    public: // Functions from base classes
+
+        /**
+        * From CTestModuleBase InitL is used to initialize the 
+        *       t_msgstore. It is called once for every instance of 
+        *       TestModulet_msgstore after its creation.
+        * @since ?Series60_version
+        * @param aIniFile Initialization file for the test module (optional)
+        * @param aFirstTime Flag is true when InitL is executed for first 
+        *               created instance of t_msgstore.
+        * @return Symbian OS error code
+        */
+        TInt InitL( TFileName& aIniFile, TBool aFirstTime );
+
+        /**
+        * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
+        *   from t_msgstore. 
+        * @since ?Series60_version
+        * @param aTestCaseFile Test case file (optional)
+        * @param aTestCases  Array of TestCases returned to test framework
+        * @return Symbian OS error code
+        */
+        TInt GetTestCasesL( const TFileName& aTestCaseFile, 
+                            RPointerArray<TTestCaseInfo>& aTestCases );
+
+        /**
+        * From CTestModuleBase RunTestCaseL is used to run an individual 
+        *   test case. 
+        * @since ?Series60_version
+        * @param aCaseNumber Test case number
+        * @param aTestCaseFile Test case file (optional)
+        * @param aResult Test case result returned to test framework (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error, which is 
+        *           not reported in aResult parameter as test case failure).
+        */   
+        TInt RunTestCaseL( const TInt aCaseNumber, 
+                           const TFileName& aTestCaseFile,
+                           TTestResult& aResult );
+
+        /**
+        * From CTestModuleBase; OOMTestQueryL is used to specify is particular
+        * test case going to be executed using OOM conditions
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailureType OOM failure type (optional)
+        * @param aFirstMemFailure The first heap memory allocation failure value (optional)
+        * @param aLastMemFailure The last heap memory allocation failure value (optional)
+        * @return TBool
+        */
+        virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
+                                     const TInt /* aCaseNumber */, 
+                                     TOOMFailureType& aFailureType, 
+                                     TInt& /* aFirstMemFailure */, 
+                                     TInt& /* aLastMemFailure */ );
+
+        /**
+        * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
+        * test environment
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
+                                    const TInt /* aCaseNumber */ ); 
+
+        /**
+        * From CTestModuleBase; OOMHandleWarningL
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailNextValue FailNextValue for OOM test execution (optional)
+        * @return None
+        *
+        * User may add implementation for OOM test warning handling. Usually no
+        * implementation is required.           
+        */
+        virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
+                                        const TInt /* aCaseNumber */, 
+                                        TInt& /* aFailNextValue */); 
+
+        /**
+        * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
+        * test environment
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        *
+        */
+        virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
+                                       const TInt /* aCaseNumber */ );
+        
+        /**
+         * Method used to log version of test module
+         */
+        void SendTestModuleVersion();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        Ct_msgstore();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Function returning test case name and pointer to test case function.
+        * @since ?Series60_version
+        * @param aCaseNumber test case number
+        * @return TCaseInfo 
+        */
+        const TCaseInfo Case ( const TInt aCaseNumber ) const;
+
+        /**
+        * [test case declarations] - do not remove
+        */
+        //ADD NEW METHOD DEC HERE"
+
+        /**
+        * Mailbox test cases.
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt MailboxTestsL( TTestResult& aResult );
+        
+        /**
+        * Property test cases.
+        */
+        TInt PropertyTestsL( TTestResult& aResult );
+
+        /**
+        * Folder test cases.
+        */
+        TInt FolderTestsL( TTestResult& aResult );
+        
+        /**
+        * Message test cases.
+        */
+        TInt MessageTestsL( TTestResult& aResult );
+        
+        /**
+        * Part test cases.
+        */
+        TInt PartTestsL( TTestResult& aResult );
+        
+        /**
+        * Observer test cases.
+        */
+        TInt ObserverTestsL( TTestResult& aResult );
+        
+        /**
+        * Content test cases.
+        */
+        TInt ContentTestsL( TTestResult& aResult );
+        
+        /**
+        * MRU Address test cases.
+        */
+        TInt MruTestsL( TTestResult& aResult );
+
+        /**
+        * Search test cases.
+        */
+        TInt SearchTestsL( TTestResult& aResult );
+        
+        /**
+        * Sort test cases.
+        */
+        TInt SortTestsL( TTestResult& aResult );
+        
+        /**
+        * Encryption test cases.
+        */
+        TInt EncryptionTestsL( TTestResult& aResult );
+
+        /**
+        * Size test cases.
+        */
+        TInt SizeTestsL( TTestResult& aResult );
+        
+        
+        /**
+        * Database Corruption test cases.
+        */
+        TInt DbCorruptTestsL( TTestResult& aResult );
+
+    private:    // Data
+        // Pointer to test (function) to be executed
+        TestFunction iMethod;
+
+        // Pointer to logger
+        CStifLogger * iLog; 
+
+        // Normal logger
+        CStifLogger* iStdLog;
+
+        // Test case logger
+        CStifLogger* iTCLog;
+
+        // Flag saying if test case title should be added to log file name
+        TBool iAddTestCaseTitleToLogName;
+
+        // Flag saying if version of test module was already sent
+        TBool iVersionLogged;
+
+    };
+
+#endif      // T_MSGSTORE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/AsyncTestCaseBase.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,1279 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <tz.h>
+#include <e32math.h>
+#include <Stiftestinterface.h>
+#include <SettingServerClient.h>
+#include "AsyncTestCaseBase.h"
+#include "messagestoreclientserver.h"
+
+const TInt KExecutionTimeout = 30*1000000;   //30 seconds timelimit for each test case
+
+//Class RDebugSession
+TInt RDebugSession::Connect()
+    {
+#ifdef _DEBUG
+    return CreateSession( KMsgStoreServerName, TVersion(KMsgStoreMajorVersion, KMsgStoreMinorVersion, KMsgStoreBuild), 3 );
+#endif    
+    }
+  
+void RDebugSession::Close()
+    {
+#ifdef _DEBUG
+    RSessionBase::Close();  //basecall
+#endif    
+    }
+
+void RDebugSession::SendBackupRestoreEventL( TUint aEvent )
+    {
+#ifdef _DEBUG
+    User::LeaveIfError( SendReceive( EMsgStoreCmdInjectBackupRestoreEvent, TIpcArgs( aEvent ) ) );
+#else
+    User::Leave(KErrNotSupported);
+#endif    
+    }
+
+void RDebugSession::SendPointSecEventL( TBool aLock )
+    {
+#ifdef _DEBUG
+    User::LeaveIfError( SendReceive( EMsgStoreCmdInjectPointSecEvent, TIpcArgs( aLock ) ) );
+#else
+    User::Leave(KErrNotSupported);
+#endif    
+    }
+
+void RDebugSession::SimulateLowDiskSpaceL( TUint aLatency )
+    {
+#ifdef _DEBUG
+    User::LeaveIfError( SendReceive( EMsgStoreCmdSimulateLowDiskSpace, TIpcArgs( aLatency ) ) );
+#else
+    User::Leave(KErrNotSupported);
+#endif    
+    }    
+
+TInt RDebugSession::GetEncryptionStateL()
+    {
+#ifdef _DEBUG
+    TPckgBuf<TInt> resultPckg(0);
+    
+    User::LeaveIfError( SendReceive( EMsgStoreCmdGetEncryptionState, TIpcArgs( &resultPckg ) ) );
+    
+    return resultPckg();
+#else
+    User::Leave(KErrNotSupported);
+#endif    
+    }
+
+void RDebugSession:: ShutdownServerL()
+    {
+#ifdef _DEBUG
+    User::LeaveIfError( SendReceive( EMsgStoreCmdShutdownServer ) );
+#else
+    User::Leave(KErrNotSupported);
+#endif    
+    }
+
+//Class CYieldHelper
+
+CYieldHelper* CYieldHelper::NewL()
+    {
+    CYieldHelper* self = new(ELeave) CYieldHelper();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CYieldHelper::CYieldHelper() : CTimer( EPriorityIdle )
+    {
+    }
+
+void CYieldHelper::ConstructL()
+    {
+    CTimer::ConstructL();
+    iYieldWait = new(ELeave) CActiveSchedulerWait();
+    CActiveScheduler::Add(this);
+    }
+
+CYieldHelper::~CYieldHelper()
+    {
+    delete iYieldWait;
+    }
+
+void CYieldHelper::Yield( TInt aMicroSeconds )
+    {
+    After( aMicroSeconds );
+    iYieldWait->Start(); 
+    }
+
+void CYieldHelper::DoCancel()
+    {
+    //DO Nothing
+    }
+
+void CYieldHelper::RunL()
+    {
+    if( iYieldWait->IsStarted() )
+        {
+        // Stop the nested active scheduler (flow-of-control will pick up immediately following the
+        // call to iWait.Start().
+        iYieldWait->AsyncStop();
+        } // end if
+    }
+
+//Class CAsyncTestCaseBase
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CAsyncTestCaseBase::CAsyncTestCaseBase( CStifLogger* aLog ) 
+: CTimer( CActive::EPriorityStandard ), iLog( aLog ), iCaseId(1)  
+    {
+    // Construct and install active scheduler
+    CActiveScheduler* iActiveScheduler = new CActiveScheduler;
+    CActiveScheduler::Replace( iActiveScheduler );
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CAsyncTestCaseBase::~CAsyncTestCaseBase()
+    {
+    Cancel();
+    iMessages.ResetAndDestroy();
+    delete iMsgStore;
+    delete iActiveScheduler;
+    delete iYieldHelper;
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CAsyncTestCaseBase::ConstructL()
+    {
+    CTimer::ConstructL();
+    CActiveScheduler::Add(this);  
+    
+    //Construct the MsgStore client session
+    iMsgStore = CMsgStore::NewL();
+    
+    iYieldHelper = CYieldHelper::NewL();
+    
+    iState = EStateInit;
+    iResult = KErrNone;
+    CTimer::After(0);
+    }
+
+
+//stop the execution
+void CAsyncTestCaseBase::Stop()
+    {
+    TRAP_IGNORE( AfterTestL() );
+    
+    _LIT( KStop, "Ending test cases... iResult=%d" );
+    iLog->Log( KStop, iResult );
+    CActiveScheduler::Stop();
+    }
+
+void CAsyncTestCaseBase::BeforeTestL()
+    {
+    _LIT( KBeforeTestLEnter, ">> BeforeTestL" );
+    iLog->Log( KBeforeTestLEnter );
+    
+    iMsgStore->WipeEverythingL();
+    
+    _LIT( KBeforeTestLExit, "<< BeforeTestL" );
+    iLog->Log( KBeforeTestLExit );
+    }
+
+void CAsyncTestCaseBase::AfterTestL()
+    {
+    _LIT( KAfterTestLEnter, ">> AfterTestL" );
+    iLog->Log( KAfterTestLEnter );
+    
+    delete iMsgStore;
+    iMsgStore = NULL;
+    
+    _LIT( KAfterTestLExit, "<< AfterTestL" );
+    iLog->Log( KAfterTestLExit );
+    }
+
+
+//From CTimer
+void CAsyncTestCaseBase::RunL()
+    {
+    if ( iStatus == KErrNone )
+        {
+        if ( iState == EStateInit )
+            {
+            BeforeTestL();
+            
+            TBool done = EFalse;
+            TRAP( iResult, done = ExecuteL() );
+            if( iResult == KErrNone )
+                {
+                if ( done )
+                    {
+                    iState = EStateDone;
+                    Stop();
+                    }
+                else
+                    {
+                    iState = EStateExecute;
+                    CTimer::After( KExecutionTimeout );
+                    }
+                }
+            else
+                {
+                iState = EStateDone;
+                Stop();
+                }
+            }
+        else if ( iState == EStateExecute )
+            {
+            //Timer has expired, error out
+            iState = EStateDone;
+            iResult = KErrTimedOut;
+            Stop();
+            }
+        }
+    else if ( iStatus != KErrCancel )
+        {
+        iState = EStateDone;
+        iResult = KErrCorrupt;
+        Stop();
+        }
+    
+    }
+
+TInt CAsyncTestCaseBase::RunError(TInt aError)
+    {
+    //log the error
+    iResult = aError;
+    return aError;
+    }
+
+void CAsyncTestCaseBase::DoCancel()
+    {
+    CTimer::DoCancel(); 
+    }
+
+void CAsyncTestCaseBase::LogHeader( const TDesC& aTestType )
+    {
+    _LIT(KDivider, "==============================================================");
+    iLog->Log( KDivider );
+    iLog->Log( _L("Executing %S Test Cases"), &aTestType );
+    iLog->Log( KDivider );
+    }
+
+void CAsyncTestCaseBase::CheckCondition( const TDesC& aCondition, TBool aPassed,  TBool aLog  )
+    {
+    if( aPassed )
+        {
+        if ( aLog )
+            {
+            iLog->Log( _L("  PASSED!  Condition: %S"), &aCondition );
+            }
+        }
+    else
+        {
+        iLog->Log( _L(  "*** FAILED!  Condition: %S"), &aCondition );     
+        User::Panic( aCondition, 1 );
+        } // end if
+    }
+
+
+void CAsyncTestCaseBase::ComparePropertiesL( const CMsgStorePropertyContainer& aProperties1, const CMsgStorePropertyContainer& aProperties2 )
+    {
+    iLog->Log( _L("  >> ComparePropertiesL") );
+    
+    TBool passed = (aProperties1.PropertyCount() == aProperties2.PropertyCount());
+    
+    for( TUint index1 = 0; index1 < aProperties1.PropertyCount(); index1++ )
+        {
+        TUint index2;
+        
+        const TPtrC8 property1Name( aProperties1.PropertyNameL(index1) );
+        
+        TBool matched = EFalse;
+        
+        if( aProperties2.FindProperty( property1Name, index2 ) )
+            {
+            TMsgStorePropertyValueType value1 = aProperties1.PropertyTypeL( index1 );
+            TMsgStorePropertyValueType value2 = aProperties2.PropertyTypeL( index2 );
+            
+            // Found
+            if( value1 != value2 )
+                {
+                iLog->Log( _L("type mismatch") );
+                }
+            else
+                {
+                switch( aProperties1.PropertyTypeL( index1 ) )
+                    {
+                    case EMsgStoreTypeBool:
+                        {
+                        const TBool property1Value = aProperties1.PropertyValueBoolL(index1);
+                        const TBool property2Value = aProperties2.PropertyValueBoolL(index2);
+                        
+                        if( property1Value == property2Value )
+                            {
+                            matched = ETrue;
+                            }
+                        else
+                            {
+                            iLog->Log( _L("  property %S value mismatch"), &property1Name );                                                         
+                            iLog->Log( _L("  expected %i"), &property1Value );                                                            
+                            iLog->Log( _L("  found %i"), &property2Value );                                                           
+                            }                                   
+                        break;
+                        }
+                    case EMsgStoreTypeUint32:
+                        {
+                        const TUint32 property1Value = aProperties1.PropertyValueUint32L(index1);
+                        const TUint32 property2Value = aProperties2.PropertyValueUint32L(index2);
+                        
+                        if( property1Value == property2Value )
+                            {
+                            matched = ETrue;
+                            }
+                        else
+                            {
+                            iLog->Log( _L("  property %S value mismatch"), &property1Name );                                                         
+                            iLog->Log( _L("  expected %i"), &property1Value );                                                            
+                            iLog->Log( _L("  found %i"), &property2Value );                                                           
+                            }                                   
+                        break;
+                        }
+                    case EMsgStoreTypeDes:
+                        {
+                        const TPtrC property1Value( aProperties1.PropertyValueDesL(index1) );
+                        const TPtrC property2Value( aProperties2.PropertyValueDesL(index2) );           
+                        
+                        if( property1Value.Compare( property2Value ) == 0 )
+                            {
+                            matched = ETrue;
+                            }
+                        else
+                            {
+                            iLog->Log( _L("  property %S value mismatch"), &property1Name );                                                         
+                            iLog->Log( _L("  expected %S"), &property1Value );                                                            
+                            iLog->Log( _L("  found %S"), &property2Value );                                                           
+                            }                                   
+                        break;
+                        }
+                    case EMsgStoreTypeDes8:
+                        {
+                        const TPtrC8 property1Value( aProperties1.PropertyValueDes8L(index1) );
+                        const TPtrC8 property2Value( aProperties2.PropertyValueDes8L(index2) );         
+                        
+                        if( property1Value.Compare( property2Value ) == 0 )
+                            {
+                            matched = ETrue;
+                            }
+                        else
+                            {
+                            iLog->Log( _L("  property %S value mismatch"), &property1Name );                                                         
+                            iLog->Log( _L("  expected %S"), &property1Value );                                                           
+                            iLog->Log( _L("  found %S"), &property2Value );                                                          
+                            }
+                        break;
+                        }
+                    case EMsgStoreTypeContainer:
+                        {
+                        CMsgStorePropertyContainer* property1Value = aProperties1.PropertyValueContainerL(index1);
+                        CMsgStorePropertyContainer* property2Value = aProperties2.PropertyValueContainerL(index2);
+
+                        ComparePropertiesL( *property1Value, *property2Value );                                                                 
+                        
+                        matched = ETrue;
+                        
+                        delete property1Value;
+                        delete property2Value;
+                        break;
+                        }                           
+                    case EMsgStoreTypeTime:
+                        {
+                        TTime time1, time2;
+                        aProperties1.PropertyValueTimeL( index1, time1 );
+                        aProperties2.PropertyValueTimeL( index2, time2 );
+                        
+                        if ( time1 == time2 )
+                            {
+                            matched = ETrue;
+                            }
+                        
+                        break;
+                        }
+                    case EMsgStoreTypeAddress:
+                        {
+                        RMsgStoreAddress addr1, addr2;
+                        
+                        aProperties1.PropertyValueAddressL( index1, addr1 );
+                        aProperties2.PropertyValueAddressL( index2, addr2 );
+                        
+                        if ( addr1.iEmailAddress == addr2.iEmailAddress && addr1.iDisplayName == addr2.iDisplayName )
+                            {
+                            matched = ETrue;
+                            }
+                        
+                        addr1.Close();
+                        addr2.Close();
+                        break;
+                        }
+
+                    } // end switch
+                    
+                } // end if
+            }
+        else
+            {
+            iLog->Log( _L("  property %S not found"), &property1Name );                  
+            }
+        
+        passed = passed && matched;
+        
+        } // end for            
+
+    TBuf<30> text;
+    text.Format( _L("compare %i properties"), aProperties1.PropertyCount() );
+    
+    CheckCondition( text, passed );
+    iLog->Log( _L("  << ComparePropertiesL") );
+    }
+
+
+TUint CAsyncTestCaseBase::TestAddIntegerPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, TUint32 aValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+
+    TUint index;
+    if( aUseAddOrUpdate )
+        {
+        index = aProperties.AddOrUpdatePropertyL( aName, aValue );          
+        }
+    else
+        {
+        index = aProperties.AddPropertyL( aName, aValue );  
+        } // end if
+    
+    TRAPD( des8Result, aProperties.PropertyValueDes8L( index ) );
+    TRAPD( desResult, aProperties.PropertyValueDesL( index ) );
+    TRAPD( containerResult, aProperties.PropertyValueContainerL( index ) );
+    TRAPD( boolResult, aProperties.PropertyValueBoolL( index ) );
+                
+    TBool passed = (aProperties.PropertyCount() == (countBefore+1) &&
+                    aProperties.PropertyNameL( index ).Compare( aName ) == 0 &&
+                    aProperties.PropertyTypeL( index ) == EMsgStoreTypeUint32 &&                        
+                    aProperties.PropertyValueUint32L( index ) == aValue &&
+                    des8Result == KErrArgument &&
+                    desResult == KErrArgument &&
+                    containerResult == KErrArgument &&
+                    boolResult == KErrArgument );
+                    
+    CheckCondition( _L("add integer property"), passed );
+    
+    return index;
+    } 
+
+TUint CAsyncTestCaseBase::TestAddBoolPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, TBool aValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TUint index;
+    if( aUseAddOrUpdate )
+        {
+        index = aProperties.AddOrUpdatePropertyL( aName, aValue );          
+        }
+    else
+        {
+        index = aProperties.AddPropertyL( aName, aValue );  
+        } // end if
+        
+    TRAPD( des8Result, aProperties.PropertyValueDes8L( index ) );
+    TRAPD( desResult, aProperties.PropertyValueDesL( index ) );
+    TRAPD( containerResult, aProperties.PropertyValueContainerL( index ) );
+    TRAPD( integerResult, aProperties.PropertyValueUint32L( index ) );
+                
+    TBool passed = (aProperties.PropertyCount() == (countBefore+1) &&
+                    aProperties.PropertyNameL( index ).Compare( aName ) == 0 &&
+                    aProperties.PropertyTypeL( index ) == EMsgStoreTypeBool &&
+                    aProperties.PropertyValueBoolL( index ) == aValue &&
+                    des8Result == KErrArgument &&
+                    desResult == KErrArgument &&
+                    containerResult == KErrArgument &&
+                    integerResult == KErrArgument );
+                    
+    CheckCondition( _L("add bool property"), passed );
+    
+    return index;
+    } 
+    
+TUint CAsyncTestCaseBase::TestAddDes8PropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const TDesC8& aValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TUint index;
+    if( aUseAddOrUpdate )
+        {
+        index = aProperties.AddOrUpdatePropertyL( aName, aValue );          
+        }
+    else
+        {
+        index = aProperties.AddPropertyL( aName, aValue );  
+        } // end if
+    
+    TRAPD( boolResult, aProperties.PropertyValueBoolL( index ) );
+    TRAPD( intResult, aProperties.PropertyValueUint32L( index ) );
+    TRAPD( desResult, aProperties.PropertyValueDesL( index ) );
+    TRAPD( containerResult, aProperties.PropertyValueContainerL( index ) );
+    
+    TBool passed = (aProperties.PropertyCount() == (countBefore+1) &&
+                    aProperties.PropertyNameL( index ).Compare( aName ) == 0 && 
+                    aProperties.PropertyTypeL( index ) == EMsgStoreTypeDes8 &&                      
+                    aProperties.PropertyValueDes8L( index ).Compare( aValue ) == 0 &&
+                    intResult == KErrArgument &&
+                    desResult == KErrArgument &&
+                    containerResult == KErrArgument &&
+                    boolResult == KErrArgument );
+                    
+    CheckCondition( _L("add des8 property"), passed );
+    
+    return index;
+    } 
+
+TUint CAsyncTestCaseBase::TestAddDesPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const TDesC& aValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TUint index;
+    if( aUseAddOrUpdate )
+        {
+        index = aProperties.AddOrUpdatePropertyL( aName, aValue );          
+        }
+    else
+        {
+        index = aProperties.AddPropertyL( aName, aValue );  
+        } // end if
+    
+    TRAPD( boolResult, aProperties.PropertyValueBoolL( index ) );
+    TRAPD( intResult, aProperties.PropertyValueUint32L( index ) );
+    TRAPD( des8Result, aProperties.PropertyValueDes8L( index ) );
+    TRAPD( containerResult, aProperties.PropertyValueContainerL( index ) );
+    
+    TBool passed = (aProperties.PropertyCount() == (countBefore+1) &&
+                    aProperties.PropertyNameL( index ).Compare( aName ) == 0 &&
+                    aProperties.PropertyTypeL( index ) == EMsgStoreTypeDes &&
+                    aProperties.PropertyValueDesL( index ).Compare( aValue ) == 0 &&
+                    intResult == KErrArgument &&
+                    des8Result == KErrArgument &&
+                    containerResult == KErrArgument &&
+                    boolResult == KErrArgument );
+                    
+    CheckCondition( _L("add des property"), passed );
+    
+    return index;
+    } 
+
+TUint CAsyncTestCaseBase::TestAddContainerPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const CMsgStorePropertyContainer& aValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TUint index;
+    if( aUseAddOrUpdate )
+        {
+        index = aProperties.AddOrUpdatePropertyL( aName, aValue );          
+        }
+    else
+        {
+        index = aProperties.AddPropertyL( aName, aValue );  
+        } // end if
+    
+    CMsgStorePropertyContainer* container = aProperties.PropertyValueContainerL( index );
+    ComparePropertiesL( aValue, *container );
+    delete container;
+                                
+    TRAPD( boolResult, aProperties.PropertyValueUint32L( index ) );
+    TRAPD( intResult, aProperties.PropertyValueUint32L( index ) );
+    TRAPD( des8Result, aProperties.PropertyValueDes8L( index ) );
+    TRAPD( desResult, aProperties.PropertyValueDesL( index ) );
+    
+    TBool passed = (aProperties.PropertyCount() == (countBefore+1) &&
+                    aProperties.PropertyNameL( index ).Compare( aName ) == 0 &&
+                    aProperties.PropertyTypeL( index ) == EMsgStoreTypeContainer &&
+                    desResult == KErrArgument &&
+                    des8Result == KErrArgument &&
+                    intResult == KErrArgument &&
+                    boolResult == KErrArgument );
+
+    CheckCondition( _L("add container property"), passed );
+    
+    return index;
+    } 
+
+TUint CAsyncTestCaseBase::TestAddTimePropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const TTime& aValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TUint index;
+    if( aUseAddOrUpdate )
+        {
+        index = aProperties.AddOrUpdatePropertyL( aName, aValue );          
+        }
+    else
+        {
+        index = aProperties.AddPropertyL( aName, aValue );  
+        } // end if
+        
+    TRAPD( des8Result, aProperties.PropertyValueDes8L( index ) );
+    TRAPD( desResult, aProperties.PropertyValueDesL( index ) );
+    TRAPD( containerResult, aProperties.PropertyValueContainerL( index ) );
+    TRAPD( integerResult, aProperties.PropertyValueUint32L( index ) );
+    TRAPD( boolResult, aProperties.PropertyValueBoolL( index ) );
+                
+    TBool passed = (aProperties.PropertyCount() == (countBefore+1) &&
+                    aProperties.PropertyNameL( index ).Compare( aName ) == 0 &&
+                    aProperties.PropertyTypeL( index ) == EMsgStoreTypeTime &&
+                    des8Result == KErrArgument &&
+                    desResult == KErrArgument &&
+                    containerResult == KErrArgument &&
+                    integerResult == KErrArgument &&
+                    boolResult == KErrArgument );
+
+    TTime time;
+    aProperties.PropertyValueTimeL( index, time );
+    
+    passed = passed && time == aValue;
+    
+    CheckCondition( _L("add time property"), passed );
+    
+    return index;
+    } 
+
+TUint CAsyncTestCaseBase::TestAddAddressPropertyL( CMsgStorePropertyContainer& aProperties, const TDesC8& aName, const RMsgStoreAddress& aValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TUint index;
+    if( aUseAddOrUpdate )
+        {
+        index = aProperties.AddOrUpdatePropertyL( aName, aValue );          
+        }
+    else
+        {
+        index = aProperties.AddPropertyL( aName, aValue );  
+        } // end if
+        
+    TRAPD( des8Result, aProperties.PropertyValueDes8L( index ) );
+    TRAPD( desResult, aProperties.PropertyValueDesL( index ) );
+    TRAPD( containerResult, aProperties.PropertyValueContainerL( index ) );
+    TRAPD( integerResult, aProperties.PropertyValueUint32L( index ) );
+    TRAPD( boolResult, aProperties.PropertyValueBoolL( index ) );
+    TTime time;
+    TRAPD( timeResult, aProperties.PropertyValueTimeL( index, time ) );
+                
+    TBool passed = (aProperties.PropertyCount() == (countBefore+1) &&
+                    aProperties.PropertyNameL( index ).Compare( aName ) == 0 &&
+                    aProperties.PropertyTypeL( index ) == EMsgStoreTypeAddress &&
+                    des8Result == KErrArgument &&
+                    desResult == KErrArgument &&
+                    containerResult == KErrArgument &&
+                    integerResult == KErrArgument &&
+                    boolResult == KErrArgument &&
+                    timeResult == KErrArgument );
+
+    RMsgStoreAddress address;
+    aProperties.PropertyValueAddressL( index, address );
+    
+    iLog->Log( _L("  passed=%d"), passed );
+    iLog->Log( _L("  email addr=%S, disp name=%S"), &address.iEmailAddress, &address.iDisplayName);
+    
+    passed = passed && (address.iEmailAddress == aValue.iEmailAddress) && (address.iDisplayName == aValue.iDisplayName);
+    
+    address.Close();
+    
+    CheckCondition( _L("add address property"), passed );
+    
+    return index;
+    } 
+
+void CAsyncTestCaseBase::TestRemovePropertyL( CMsgStorePropertyContainer& aProperties, TUint aIndex )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TBuf8<500> oldName;
+    oldName.Copy( aProperties.PropertyNameL( aIndex ) );
+    
+    aProperties.RemovePropertyL( aIndex );  
+
+    TUint index;
+    TBool found = aProperties.FindProperty( oldName, index );
+
+    TBool passed = (!found &&
+                    aProperties.PropertyCount() == (countBefore-1) );
+                    
+    CheckCondition( _L("remove property"), passed );
+    } 
+
+void CAsyncTestCaseBase::TestUpdateDes8PropertyL( CMsgStorePropertyContainer& aProperties, TUint aIndex, const TDesC8& aNewValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TBuf8<500> oldName;
+    oldName.Copy( aProperties.PropertyNameL( aIndex ) );
+    
+    if( aUseAddOrUpdate )
+        {
+        aProperties.AddOrUpdatePropertyL( aProperties.PropertyNameL(aIndex), aNewValue );           
+        }
+    else
+        {
+        aProperties.UpdatePropertyL( aIndex, aNewValue );   
+        } // end if
+    
+    TRAPD( intResult, aProperties.PropertyValueUint32L( aIndex ) );
+    TRAPD( desResult, aProperties.PropertyValueDesL( aIndex ) );
+    TRAPD( containerResult, aProperties.PropertyValueContainerL( aIndex ) );
+    TRAPD( boolResult, aProperties.PropertyValueBoolL( aIndex ) );
+    
+    TPtrC8 des8( aProperties.PropertyValueDes8L( aIndex ) );
+    
+    TBool passed = (aProperties.PropertyCount() == countBefore &&
+                    aProperties.PropertyNameL( aIndex ).Compare( oldName ) == 0 &&
+                    aProperties.PropertyTypeL( aIndex ) == EMsgStoreTypeDes8 &&                     
+                    des8.Compare( aNewValue ) == 0 &&
+                    intResult == KErrArgument &&
+                    desResult == KErrArgument &&
+                    containerResult == KErrArgument &&
+                    boolResult == KErrArgument );
+                    
+    CheckCondition( _L("update des8 property"), passed );
+    } 
+
+void CAsyncTestCaseBase::TestUpdateDesPropertyL( CMsgStorePropertyContainer& aProperties, TUint aIndex, const TDesC& aNewValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TBuf8<500> oldName;
+    oldName.Copy( aProperties.PropertyNameL( aIndex ) );
+    
+    if( aUseAddOrUpdate )
+        {
+        aProperties.AddOrUpdatePropertyL( aProperties.PropertyNameL(aIndex), aNewValue );           
+        }
+    else
+        {
+        aProperties.UpdatePropertyL( aIndex, aNewValue );   
+        } // end if
+        
+    TRAPD( intResult, aProperties.PropertyValueUint32L( aIndex ) );
+    TRAPD( des8Result, aProperties.PropertyValueDes8L( aIndex ) );
+    TRAPD( containerResult, aProperties.PropertyValueContainerL( aIndex ) );
+    TRAPD( boolResult, aProperties.PropertyValueBoolL( aIndex ) );
+
+    TPtrC des( aProperties.PropertyValueDesL( aIndex ) );
+                
+    TBool passed = (aProperties.PropertyCount() == countBefore &&
+                    aProperties.PropertyNameL( aIndex ).Compare( oldName ) == 0 &&
+                    aProperties.PropertyTypeL( aIndex ) == EMsgStoreTypeDes &&
+                    des.Compare( aNewValue ) == 0 &&
+                    intResult == KErrArgument &&
+                    des8Result == KErrArgument &&
+                    containerResult == KErrArgument &&
+                    boolResult == KErrArgument );
+                    
+    CheckCondition( _L("update string(16) property"), passed );
+    } 
+
+void CAsyncTestCaseBase::TestUpdateContainerPropertyL( CMsgStorePropertyContainer& aProperties, TUint aIndex, CMsgStorePropertyContainer& aNewValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TBuf8<500> oldName;
+    oldName.Copy( aProperties.PropertyNameL( aIndex ) );
+    
+    if( aUseAddOrUpdate )
+        {
+        aProperties.AddOrUpdatePropertyL( aProperties.PropertyNameL(aIndex), aNewValue );           
+        }
+    else
+        {
+        aProperties.UpdatePropertyL( aIndex, aNewValue );   
+        } // end if
+    
+    CMsgStorePropertyContainer* container = aProperties.PropertyValueContainerL( aIndex );
+    ComparePropertiesL( aNewValue, *container );
+    delete container;
+                                            
+    TRAPD( intResult, aProperties.PropertyValueUint32L( aIndex ) );
+    TRAPD( des8Result, aProperties.PropertyValueDes8L( aIndex ) );
+    TRAPD( desResult, aProperties.PropertyValueDesL( aIndex ) );
+    TRAPD( boolResult, aProperties.PropertyValueBoolL( aIndex ) );
+
+    TBool passed = (aProperties.PropertyCount() == countBefore &&
+                    aProperties.PropertyNameL( aIndex ).Compare( oldName ) == 0 &&
+                    aProperties.PropertyTypeL( aIndex ) == EMsgStoreTypeContainer &&
+                    intResult == KErrArgument &&
+                    des8Result == KErrArgument &&
+                    desResult == KErrArgument &&
+                    boolResult == KErrArgument );
+                    
+    CheckCondition( _L("update container property"), passed );
+    } 
+
+void CAsyncTestCaseBase::TestUpdateBoolPropertyL( CMsgStorePropertyContainer& aProperties, TUint aIndex, TBool aNewValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TBuf8<500> oldName;
+    oldName.Copy( aProperties.PropertyNameL( aIndex ) );
+    
+    if( aUseAddOrUpdate )
+        {
+        aProperties.AddOrUpdatePropertyL( aProperties.PropertyNameL(aIndex), aNewValue );           
+        }
+    else
+        {
+        aProperties.UpdatePropertyL( aIndex, aNewValue );   
+        } // end if
+    
+    TRAPD( intResult, aProperties.PropertyValueUint32L( aIndex ) );
+    TRAPD( des8Result, aProperties.PropertyValueDes8L( aIndex ) );
+    TRAPD( desResult, aProperties.PropertyValueDesL( aIndex ) );
+    TRAPD( containerResult, aProperties.PropertyValueContainerL( aIndex ) );
+                
+    TBool passed = (aProperties.PropertyCount() == countBefore &&
+                    aProperties.PropertyNameL( aIndex ).Compare( oldName ) == 0 &&
+                    aProperties.PropertyTypeL( aIndex ) == EMsgStoreTypeBool &&                     
+                    aProperties.PropertyValueBoolL( aIndex ) == aNewValue &&
+                    des8Result == KErrArgument &&
+                    desResult == KErrArgument &&
+                    containerResult == KErrArgument &&
+                    intResult == KErrArgument );
+                    
+    CheckCondition( _L("update bool property"), passed );
+    } 
+
+void CAsyncTestCaseBase::TestUpdateIntegerPropertyL( CMsgStorePropertyContainer& aProperties, TUint aIndex, TUint32 aNewValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TBuf8<500> oldName;
+    oldName.Copy( aProperties.PropertyNameL( aIndex ) );
+    
+    if( aUseAddOrUpdate )
+        {
+        aProperties.AddOrUpdatePropertyL( aProperties.PropertyNameL(aIndex), aNewValue );           
+        }
+    else
+        {
+        aProperties.UpdatePropertyL( aIndex, aNewValue );   
+        } // end if
+    
+    TRAPD( des8Result, aProperties.PropertyValueDes8L( aIndex ) );
+    TRAPD( desResult, aProperties.PropertyValueDesL( aIndex ) );
+    TRAPD( containerResult, aProperties.PropertyValueContainerL( aIndex ) );
+    TRAPD( boolResult, aProperties.PropertyValueBoolL( aIndex ) );
+                
+    TBool passed = (aProperties.PropertyCount() == countBefore &&
+                    aProperties.PropertyNameL( aIndex ).Compare( oldName ) == 0 &&
+                    aProperties.PropertyTypeL( aIndex ) == EMsgStoreTypeUint32 &&                       
+                    aProperties.PropertyValueUint32L( aIndex ) == aNewValue &&
+                    des8Result == KErrArgument &&
+                    desResult == KErrArgument &&
+                    containerResult == KErrArgument &&
+                    boolResult == KErrArgument );
+                    
+    CheckCondition( _L("update integer property"), passed );
+    } 
+
+void CAsyncTestCaseBase::TestUpdateTimePropertyL( CMsgStorePropertyContainer& aProperties, TUint aIndex, const TTime& aNewValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TBuf8<500> oldName;
+    oldName.Copy( aProperties.PropertyNameL( aIndex ) );
+    
+    if( aUseAddOrUpdate )
+        {
+        aProperties.AddOrUpdatePropertyL( aProperties.PropertyNameL(aIndex), aNewValue );           
+        }
+    else
+        {
+        aProperties.UpdatePropertyL( aIndex, aNewValue );   
+        } // end if
+    
+    TRAPD( des8Result, aProperties.PropertyValueDes8L( aIndex ) );
+    TRAPD( desResult, aProperties.PropertyValueDesL( aIndex ) );
+    TRAPD( containerResult, aProperties.PropertyValueContainerL( aIndex ) );
+    TRAPD( boolResult, aProperties.PropertyValueBoolL( aIndex ) );
+    TRAPD( intResult, aProperties.PropertyValueUint32L( aIndex ) );
+                
+    TBool passed = (aProperties.PropertyCount() == countBefore &&
+                    aProperties.PropertyNameL( aIndex ).Compare( oldName ) == 0 &&
+                    aProperties.PropertyTypeL( aIndex ) == EMsgStoreTypeTime &&                     
+                    des8Result == KErrArgument &&
+                    desResult == KErrArgument &&
+                    containerResult == KErrArgument &&
+                    boolResult == KErrArgument &&
+                    intResult == KErrArgument );
+    
+    TTime time;
+    aProperties.PropertyValueTimeL( aIndex, time );
+    
+    passed = passed && time == aNewValue;
+    
+                    
+    CheckCondition( _L("update time property"), passed );
+    } 
+
+
+void CAsyncTestCaseBase::TestUpdateAddressPropertyL( CMsgStorePropertyContainer& aProperties, TUint aIndex, const RMsgStoreAddress& aNewValue, TBool aUseAddOrUpdate )
+    {
+    TUint countBefore = aProperties.PropertyCount();
+    
+    TBuf8<500> oldName;
+    oldName.Copy( aProperties.PropertyNameL( aIndex ) );
+    
+    if( aUseAddOrUpdate )
+        {
+        aProperties.AddOrUpdatePropertyL( aProperties.PropertyNameL(aIndex), aNewValue );           
+        }
+    else
+        {
+        aProperties.UpdatePropertyL( aIndex, aNewValue );   
+        } // end if
+    
+    TRAPD( des8Result, aProperties.PropertyValueDes8L( aIndex ) );
+    TRAPD( desResult, aProperties.PropertyValueDesL( aIndex ) );
+    TRAPD( containerResult, aProperties.PropertyValueContainerL( aIndex ) );
+    TRAPD( boolResult, aProperties.PropertyValueBoolL( aIndex ) );
+    TRAPD( intResult, aProperties.PropertyValueUint32L( aIndex ) );
+    TTime time;
+    TRAPD( timeResult, aProperties.PropertyValueTimeL( aIndex, time ) );
+    
+    TBool passed = (aProperties.PropertyCount() == countBefore &&
+                    aProperties.PropertyNameL( aIndex ).Compare( oldName ) == 0 &&
+                    aProperties.PropertyTypeL( aIndex ) == EMsgStoreTypeAddress &&                      
+                    des8Result == KErrArgument &&
+                    desResult == KErrArgument &&
+                    containerResult == KErrArgument &&
+                    boolResult == KErrArgument &&
+                    intResult == KErrArgument,
+                    timeResult == KErrArgument );
+    
+    RMsgStoreAddress address;
+    aProperties.PropertyValueAddressL( aIndex, address );
+    
+    iLog->Log( _L("  email addr=%S, disp name=%S"), &address.iEmailAddress, &address.iDisplayName);
+    
+    passed = passed && (address.iEmailAddress == aNewValue.iEmailAddress) && (address.iDisplayName == aNewValue.iDisplayName);
+    
+    address.Close();
+                    
+    CheckCondition( _L("update address property"), passed );
+    } 
+
+void CAsyncTestCaseBase::CopyDesToDes8( const TDesC& aDes, TDes8& aDes8 )
+    {
+    const TUint8* ptr = reinterpret_cast<const TUint8*>( aDes.Ptr() );
+    
+    aDes8.Copy( ptr, aDes.Length() * 2 );
+    }
+
+void CAsyncTestCaseBase::SimulateLowDiskSpaceL( TUint aLatency )
+    {
+    RDebugSession session;
+    User::LeaveIfError( session.Connect() );
+    session.SimulateLowDiskSpaceL( aLatency );
+    session.Close();    
+    }
+
+void CAsyncTestCaseBase::TriggerBackupRestoreEventL( TUint aEvent )
+    {
+    RDebugSession session;
+    User::LeaveIfError( session.Connect() );
+    session.SendBackupRestoreEventL( aEvent );
+    session.Close();
+    }
+
+void CAsyncTestCaseBase::TriggerPointSecEventL( TBool aLock )
+    {
+    RDebugSession session;
+    User::LeaveIfError( session.Connect() );
+    session.SendPointSecEventL( aLock );
+    session.Close();
+    }
+
+void CAsyncTestCaseBase::ShutdownServerL()
+    {
+    RDebugSession temp;
+    User::LeaveIfError( temp.Connect() ); 
+    temp.ShutdownServerL();
+    temp.Close();
+    }
+
+void CAsyncTestCaseBase::Yield( TInt aMicroSeconds )
+    {
+    iYieldHelper->Yield( aMicroSeconds );
+    }
+
+void CAsyncTestCaseBase::CreateRandomMessagesL( CMsgStoreMailBox* aMailBox, TMsgStoreId aFolderId, TInt aCount,  TBool aKeepIds, TBool /* aLog */ )
+    {
+    iLog->Log( _L("  >> CreateRandomMessagesL, creating %d messages"), aCount );
+    
+    TTime time;
+    time.HomeTime();
+    TInt64 seed = time.Int64();
+    
+    CMsgStorePropertyContainer* properties = CMsgStorePropertyContainer::NewL();
+    CleanupStack::PushL( properties );              //+1
+    
+    RMsgStoreAddress address;
+    CleanupClosePushL( address );                   //+2
+    
+    address.iDisplayName.Create( 50 );
+    address.iEmailAddress.Create( 50 );
+    
+    TBuf<30> subject;
+    TBuf<50> realSubject;                          
+    TBuf<6> fname, lname;
+    TTime startTime;
+    
+    if ( aKeepIds )
+        {
+        iMatches.Reset();
+        }
+
+    RTz timeZoneServer;
+    User::LeaveIfError( timeZoneServer.Connect() );
+    CleanupClosePushL( timeZoneServer );             //+3
+    
+    for (TInt i = 0 ; i < aCount ; i++ )
+        {
+        TTime received;
+        received.HomeTime();
+        TTimeIntervalDays days( (i+1) % 9 );
+        TTimeIntervalHours hours( (i+1) %9 );
+        received -= days;
+        received += hours;
+        
+        timeZoneServer.ConvertToUniversalTime( received );
+        properties->AddOrUpdatePropertyL( KMsgStorePropertyReceivedAt, received );
+        
+        TUint32 flags = Math::Rand( seed );
+        properties->AddOrUpdatePropertyL( KMsgStorePropertyFlags, (TUint32) flags );
+        
+        TUint32 size = Math::Rand( seed );
+        properties->AddOrUpdatePropertyL( KMsgStorePropertyMessageSizeOnServer, (TUint32) size );
+        
+        if ( i == 0 || i % 9 == 0 )
+            {
+            CreateRandomString( subject, 30, seed );
+            CreateRandomString( fname, 6, seed );
+            CreateRandomString( lname, 6, seed );
+            }
+        
+        realSubject.SetLength(0);
+        if ( i % 5 == 0 )
+            {
+            realSubject.Copy(_L("RE: "));
+            }
+        else if ( i % 10 == 0 )
+            {
+            realSubject.Copy(_L("RE: FWD:"));
+            }
+        else if ( i % 3 == 0 )
+            {
+            realSubject.Copy(_L("R&D:"));
+            }
+        realSubject.Append( subject );
+        
+        properties->AddOrUpdatePropertyL( KMsgStorePropertySubject, realSubject );
+        
+        if ( i % 10 > 0 )
+            {
+            //skip display name for every 10 messages
+            address.iDisplayName.Format( _L("%S %S"), &fname, &lname );
+            }
+        _LIT(KDomainName, "nokia.com");
+        address.iEmailAddress.Format( _L("%S.%S@%S"), &fname, &lname, &KDomainName);
+        properties->AddOrUpdatePropertyL( KMsgStorePropertyFrom, address );
+        
+        properties->AddOrUpdatePropertyL( KMsgStorePropertyTo, address );
+        
+        if ( i == aCount - 1 )
+            {
+            startTime.HomeTime();
+            }
+        CMsgStoreMessage* msg = aMailBox->CreateMessageL( aFolderId, *properties );
+        CleanupStack::PushL( msg );
+        msg->CommitL();
+        
+        if ( i == aCount - 1 )
+            {
+            TTime endTime;
+            endTime.HomeTime();
+            // iLog->Log( _L("  PERFORMANCE: add messages #%d took %d ms"), aCount, (TInt) (endTime.MicroSecondsFrom( startTime ).Int64() / 1000)  );
+            }
+        
+#if 0        
+        if ( aLog )
+            {
+            iLog->Log( _L("  msgId=%x, flags=%x, size=%d"), msg->Id(), flags, size);
+            iLog->Log( _L("  subject=%S"), &realSubject );
+            }
+        else if ( i % 10 == 9 )
+            {
+            iLog->Log( _L("  count=%d, msgId=%x"), i+1, msg->Id() );
+            } 
+#endif
+        
+        if ( aKeepIds )
+            {
+            iMatches.Append( msg->Id() );
+            }
+            
+        CleanupStack::PopAndDestroy( msg );
+        }
+    
+    CleanupStack::PopAndDestroy( 3 );
+    
+    iLog->Log( _L("  << CreateRandomMessagesL") );
+    }
+
+void CAsyncTestCaseBase::CreateFileL( const TDesC& aName, TUint aTotalLength, TChar aFillChar, const TDesC& aString, TUint aOffset )
+    {
+    RFs   fs;
+    User::LeaveIfError( fs.Connect() );
+    RFile file;
+    User::LeaveIfError( file.Replace( fs, aName, EFileWrite ) );
+    
+    TUint currentLength = 0;
+    
+    TBuf<1000> buf;
+
+    const TUint8* buf8Ptr = reinterpret_cast<const TUint8*>( buf.Ptr() );
+    TPtrC8 buf8( buf8Ptr, 2000 );
+    
+    buf.Fill( aFillChar, 1000 );
+    while( currentLength < aOffset )
+        {
+        TUint amountToWrite = aOffset - currentLength;
+        if( amountToWrite > 1000 )
+            {
+            amountToWrite = 1000;
+            }
+        
+        file.Write( buf8, amountToWrite*2 );
+        
+        currentLength += amountToWrite;             
+        }
+    
+    buf.Copy( aString );
+    file.Write( buf8, aString.Length() * 2 );
+    currentLength += aString.Length();
+
+    buf.Fill( aFillChar, 1000 );
+    while( currentLength < aTotalLength )
+        {
+        TUint amountToWrite = aTotalLength - currentLength;
+        if( amountToWrite > 1000 )
+            {
+            amountToWrite = 1000;
+            }
+        
+        file.Write( buf8, amountToWrite*2 );
+        
+        currentLength += amountToWrite;             
+        }
+    
+    file.Close();
+    fs.Close();           
+    }
+
+
+void CAsyncTestCaseBase::CreateRandomString( TDes& aString, TInt aLength, TInt64& aSeed )
+    {
+    aString.SetLength(0);
+    for ( TInt i = 0 ; i < aLength; i++ )
+        {
+        TUint val = static_cast<TUint>(Math::Rand( aSeed ));
+        val = ( val % 52 );
+        if ( val <= 25 )
+            {
+            val += 65;
+            }
+        else
+            {
+            val += ( 97 - 26 );
+            }
+        aString.Append( TChar(val) );
+        }
+    }
+
+void CAsyncTestCaseBase::SetMessageContentL( CMsgStoreMessage* aMessage, const TDesC8& aContent )
+    {
+    CMsgStorePropertyContainer* props = CMsgStorePropertyContainer::NewL();
+    CleanupStack::PushL( props );
+    
+    CMsgStoreMessagePart* body = aMessage->AddChildPartL( *props );
+    CleanupStack::PushL( body );
+    
+    CMsgStoreMessagePart* plainTextbody = body->AddChildPartL( *props );
+    CleanupStack::PushL( plainTextbody );
+    
+    plainTextbody->ReplaceContentL( aContent );
+    
+    CleanupStack::PopAndDestroy( plainTextbody );
+    CleanupStack::PopAndDestroy( body );
+    CleanupStack::PopAndDestroy( props );
+    }
+
+void CAsyncTestCaseBase::WaitForServerToTerminate()
+    {
+    TBool done = EFalse;
+    
+    RDebugSession temp;
+    
+    while( !done )
+        {        
+        TInt err = temp.Connect(); 
+        
+        if (err == KErrNone )
+            {
+            temp.Close();
+            
+            // Still running.  Wait.
+            Yield( 1000000 );
+            }
+        else
+            {
+            done = ETrue;
+            }
+            
+        } // end if
+    
+    temp.Close();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/ContentTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,375 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+#include <BAUTILS.H>
+#include "ContentTests.h"
+//#include <ismsgstorepropertykeys.h>
+#include "messagestoreclientserver.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CContentTests* CContentTests::NewL( CStifLogger* aLog )
+    {
+    CContentTests* self = new(ELeave) CContentTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CContentTests::CContentTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CContentTests::~CContentTests()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CContentTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CContentTests::ExecuteL()
+    {
+    LogHeader( _L("Content") );
+    
+    // Create messages for later use.
+    CMsgStoreAccount* account = CMsgStoreAccount::NewLC(1234, _L("new account") );     //+1
+    CMsgStoreMailBox* mailBox1 = iMsgStore->CreateAccountL( *account );
+    CleanupStack::PushL( mailBox1 );                                                 //+2
+    
+    CMsgStorePropertyContainer* properties = CMsgStorePropertyContainer::NewL();
+    CleanupStack::PushL( properties );                                              //+3
+    
+    TMsgStoreId inbox1Id = mailBox1->CreateFolderL( mailBox1->Id(), *properties );
+    CMsgStoreFolder* inbox1 = mailBox1->FolderL( inbox1Id );
+    CleanupStack::PushL( inbox1 );                                                    //+4
+    
+    CMsgStoreMessage* message1 = mailBox1->CreateMessageL( inbox1Id, *properties );
+    CleanupStack::PushL( message1 );                                                  //+5
+    message1->CommitL();
+    
+    CMsgStoreMessage* message2 = mailBox1->CreateMessageL( inbox1Id, *properties );
+    CleanupStack::PushL( message2 );                                                  //+6
+    message2->CommitL();
+    
+    CMsgStoreMessage* message3 = mailBox1->CreateMessageL( inbox1Id, *properties );
+    CleanupStack::PushL( message3 );                                                  //+7
+    message3->CommitL();
+    
+    // BUFFER-ORIENTED TESTS
+
+    RBuf8 expectedContent;
+    RBuf8 contentBuf;
+    expectedContent.CreateL( 1000 );
+    contentBuf.CreateL( 1000 );
+    
+    iLog->Log( _L("Case %d: Fetch content to buffer before content added"), iCaseId++ );
+    
+    message1->FetchContentToBufferL( contentBuf );
+    CheckCondition( _L("no content"), (contentBuf.Length() == 0) && (message1->ContentLengthL() == 0) );
+    
+    iLog->Log( _L("Case %d: ReplaceContentL"), iCaseId++ );
+    
+    _LIT8( KContent1, "THIS IS SOME CONTENT" );
+    message1->ReplaceContentL( KContent1 );
+    CheckCondition( _L("ContentLength matches"), message1->ContentLengthL() == KContent1().Length() );
+    
+    iLog->Log( _L("Case %d: FetchContentToBufferL"), iCaseId++ );
+    
+    message1->FetchContentToBufferL( contentBuf );
+    CheckCondition( _L("content matches"), contentBuf.Compare( KContent1 ) == 0 );
+
+    iLog->Log( _L("Case %d: Fetch content with start offset"), iCaseId++ );
+    
+    message1->FetchContentToBufferL( contentBuf, 4 );
+    CheckCondition( _L("content matches"), contentBuf.Compare( KContent1().Mid( 4 ) ) == 0 );
+
+    iLog->Log( _L("Case %d: Append to content"), iCaseId++ );
+
+    _LIT8( KContent2, "MORE CONTENT" );
+    message1->AppendToContentL( KContent2 );
+    TInt contentLength = message1->ContentLengthL();
+    TInt expectedLength = KContent1().Length() + KContent2().Length();
+    CheckCondition( _L("ContentLength matches"), contentLength == expectedLength );
+
+    iLog->Log( _L("Case %d: Append null buffer to content"), iCaseId++ );
+
+    _LIT8( KNullBuffer, "" );
+    message1->AppendToContentL( KNullBuffer );
+    contentLength = message1->ContentLengthL();
+    CheckCondition( _L("ContentLength matches"), contentLength == expectedLength );
+
+    iLog->Log( _L("Case %d: Append null buffer to content"), iCaseId++ );
+    
+    expectedContent.Copy( KContent1 );
+    expectedContent.Append( KContent2 );
+    message1->FetchContentToBufferL( contentBuf );
+    CheckCondition( _L("content matches"), contentBuf.Compare( expectedContent ) == 0 );
+
+    iLog->Log( _L("Case %d: Long content"), iCaseId++ );
+    
+    expectedContent.Fill( 'C', 998 );
+    expectedContent.Insert( 0, _L8("A") );
+    expectedContent.Append( _L8("B") );
+    message1->ReplaceContentL( expectedContent );
+    message1->FetchContentToBufferL( contentBuf );
+    contentLength = message1->ContentLengthL();
+    expectedLength = expectedContent.Length();
+    TBool passed = (contentLength == expectedLength && contentBuf.Compare( expectedContent ) == 0);
+    //if( !passed )
+    //    {
+    //    __LOG_HEX_DUMP_ERROR( "expected", expectedContent )
+    //    __LOG_HEX_DUMP_ERROR( "actual", contentBuf )
+    //    }   
+    CheckCondition( _L("content matches"), passed );
+    
+    iLog->Log( _L("Case %d: Open the original content file"), iCaseId++ );
+    RFile testFile;
+    TRAPD(err, message1->OpenOriginalContentFileL( testFile ) );
+        
+        //try to read from the file
+        CheckCondition( _L("OpenOriginalContentFileL succeeded"), err == KErrNone );
+        
+        testFile.Read( contentBuf );
+        CheckCondition( _L("Content in original file"), contentBuf.Compare( expectedContent ) == 0 );
+        
+        iLog->Log( _L("Case %d: Fetch while client has original file open"), iCaseId++ );
+        
+        message1->FetchContentToBufferL( contentBuf );
+        CheckCondition( _L("Fetch while client has original file open"), contentBuf.Compare( expectedContent ) == 0 );
+        
+        iLog->Log( _L("Case %d: ContentLength while client has original file open"), iCaseId++ );
+        
+        contentLength = message1->ContentLengthL();
+        CheckCondition( _L("ContentLength while client has original file open"), contentLength == expectedLength );
+        
+        iLog->Log( _L("Case %d: ReplaceContent while client has original file open"), iCaseId++ );
+        
+        message1->ReplaceContentL( KContent1 );
+        message1->FetchContentToBufferL( contentBuf );
+        expectedContent.Copy( KContent1 );
+        CheckCondition( _L("ReplaceContent while client has original file open"), contentLength == expectedLength );
+        
+        iLog->Log( _L("Case %d: Can't Remove Content while client has original file open"), iCaseId++ );
+        
+        TRAP( err, message1->RemoveContentL() );
+        CheckCondition( _L("can't RemoveContentL"), err == KErrInUse );       
+    
+        iLog->Log( _L("Case %d: Delete message while client has original file open"), iCaseId++ );
+        //delete message while content file is locked
+        mailBox1->DeleteMessageL( message1->Id(), inbox1Id );
+        
+        iLog->Log( _L("  Wait 3 seconds for server delete handler to complete") );
+        Yield(3000000);
+        
+        iLog->Log( _L("  Create a dummy message") );
+        CMsgStoreMessage* message4 = mailBox1->CreateMessageL( inbox1Id, *properties );
+        CleanupStack::PushL( message4 );                                                         //+8
+        message4->CommitL();
+        
+        testFile.Close();
+        iLog->Log( _L("  Client closed content file") );
+        iLog->Log( _L("  delete dummy message after the file is closed, to trigger the delete handle") );
+        
+        mailBox1->DeleteMessageL( message4->Id(), inbox1Id );
+        
+        iLog->Log( _L("  Wait 3 secs for server delete handler to complete") );
+        Yield(3000000);
+    
+    CMsgStoreMessage* message5 = mailBox1->CreateMessageL( inbox1Id, *properties );
+    CleanupStack::PushL( message5 );                                                         //+9
+    message5->CommitL();
+
+    iLog->Log( _L("  Make sure other messages are not affected") );
+    
+    message2->FetchContentToBufferL( contentBuf );
+    CheckCondition( _L("no content"), (contentBuf.Length() == 0) && (message2->ContentLengthL() == 0) );
+
+    message3->FetchContentToBufferL( contentBuf );
+    CheckCondition( _L("no content"), (contentBuf.Length() == 0) && (message3->ContentLengthL() == 0) );
+
+    // FILE-ORIENTED TESTS
+
+    iLog->Log( _L("Case %d: FetchContentToFileL"), iCaseId++ );
+    _LIT( KFilename, "c:\\content_test.txt" );
+
+    expectedContent.Fill( 'C', 998 );
+    expectedContent.Insert( 0, _L8("A") );
+    expectedContent.Append( _L8("B") );
+    message5->ReplaceContentL( expectedContent );
+    
+    message5->FetchContentToFileL( KFilename );
+    
+    iLog->Log( _L("Case %d: ReplaceContentWithFileL"), iCaseId++ );
+
+    message2->ReplaceContentWithFileL( KFilename );
+
+    contentBuf.SetLength(0);            
+    message2->FetchContentToBufferL( contentBuf );
+
+    CheckCondition( _L("content matches"), contentBuf.Compare( expectedContent ) == 0 );
+
+    // REMOVE CONTENT
+    
+    iLog->Log( _L("Case %d: Remove content"), iCaseId++ );
+    
+    message5->RemoveContentL();
+    message5->FetchContentToBufferL( contentBuf );
+    
+    TInt length1 = contentBuf.Length();
+    TInt length2 = message5->ContentLengthL();
+    CheckCondition( _L("no content"), length1 == 0 && length2 == 0 );       
+
+    iLog->Log( _L("case %d: Fetch content to file with no content"), iCaseId++ );
+
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    
+    message5->FetchContentToFileL( KFilename );
+    RFile file;
+    User::LeaveIfError( file.Open( fs, KFilename, EFileRead ) );
+    TInt size;
+    User::LeaveIfError( file.Size( size ) );
+    file.Close();
+    CheckCondition( _L("file size = 0"), size == 0 );
+
+    // TESTS WITH VARIOUS CONTENT SIZES, TO DETECT FENCEPOST ERRORS   
+
+    iLog->Log( _L("Case %d: FENCEPOST ERRORS Detection"), iCaseId++ );
+    
+    // THESE SHOULD EXACTLY MATCH THE VALUES INSIDE ContainerStoreContentManager.cpp
+    const TUint KBlockSize = 64;
+    const TUint KBufferSize = 4096;            
+
+    // THESE MUST BE IN INCREASING ORDER.
+    const TInt KSizesToTest[] = 
+        {
+        0, 
+        1, 
+        KBlockSize-1, 
+        KBlockSize, 
+        KBlockSize+1, 
+        KBufferSize-1, 
+        KBufferSize,
+        KBufferSize+1, 
+        2*KBufferSize-1, 
+        2*KBufferSize, 
+        2*KBufferSize+1, 
+        5*KBufferSize-1, 
+        5*KBufferSize, 
+        5*KBufferSize+1,
+        -1
+        };
+
+    expectedContent.ReAllocL( 7*KBufferSize );
+    expectedContent.SetLength( 0 );        
+
+    contentBuf.ReAllocL( 7*KBufferSize );
+    contentBuf.SetLength( 0 );        
+
+    TBuf8<KBufferSize+1> appendBuffer;
+                        
+    TInt index = 0;
+    while( KSizesToTest[index] != -1 )
+        {
+        TInt growSizeBy = KSizesToTest[index] - expectedContent.Length();
+        expectedContent.SetLength( KSizesToTest[index] );
+        expectedContent.RightTPtr( growSizeBy ).Fill( 'A' + index );
+        
+        contentBuf.SetLength( 0 );
+        message5->ReplaceContentL( expectedContent );
+        message5->FetchContentToBufferL( contentBuf );    
+        CheckCondition( _L("content matches"), message5->ContentLengthL() == expectedContent.Length() && contentBuf.Compare( expectedContent ) == 0 );
+
+        contentBuf.SetLength( 0 );
+        BaflUtils::DeleteFile( fs, KFilename );
+        message5->FetchContentToFileL( KFilename );        
+        message2->ReplaceContentWithFileL( KFilename );
+        message2->FetchContentToBufferL( contentBuf );    
+        contentLength = message2->ContentLengthL();
+        expectedLength = expectedContent.Length();
+        CheckCondition( _L("content matches"), contentLength == expectedLength && contentBuf.Compare( expectedContent ) == 0 );
+
+        message3->ReplaceContentWithFileL( KFilename );
+
+        appendBuffer.Fill( 'w', 1 );
+        expectedContent.Append( appendBuffer );
+        message5->AppendToContentL( appendBuffer );
+        message5->FetchContentToBufferL( contentBuf );    
+        contentLength = message5->ContentLengthL();
+        expectedLength = expectedContent.Length();
+        CheckCondition( _L("content matches"), contentLength == expectedLength && contentBuf.Compare( expectedContent ) == 0 );
+            
+        appendBuffer.Fill( 'x', KBlockSize-1 );
+        expectedContent.SetLength( KSizesToTest[index] );
+        expectedContent.Append( appendBuffer );
+        message2->AppendToContentL( appendBuffer );
+        message2->FetchContentToBufferL( contentBuf );    
+        contentLength = message2->ContentLengthL();
+        expectedLength = expectedContent.Length();
+        CheckCondition( _L("content matches"), contentLength == expectedLength && contentBuf.Compare( expectedContent ) == 0 );
+            
+        appendBuffer.Fill( 'y', KBlockSize );
+        expectedContent.SetLength( KSizesToTest[index] );
+        expectedContent.Append( appendBuffer );
+        message3->AppendToContentL( appendBuffer );
+        message3->FetchContentToBufferL( contentBuf );    
+        contentLength = message3->ContentLengthL();
+        expectedLength = expectedContent.Length();
+        CheckCondition( _L("content matches"), contentLength == expectedLength && contentBuf.Compare( expectedContent ) == 0 );
+        
+        appendBuffer.Fill( 'z', KBufferSize+1 );
+        expectedContent.Append( appendBuffer );
+        message3->AppendToContentL( appendBuffer );
+        message3->FetchContentToBufferL( contentBuf );
+        contentLength  = message3->ContentLengthL();
+        expectedLength = expectedContent.Length();   
+        CheckCondition( _L("content matches"), contentLength == expectedLength && contentBuf.Compare( expectedContent ) == 0 );
+        
+        expectedContent.SetLength( KSizesToTest[index] );
+        
+        index++;
+        } // end for
+        
+    expectedContent.Close();
+    contentBuf.Close();
+        
+    fs.Close();
+
+    CleanupStack::PopAndDestroy( 9 );
+    
+    //we are done 
+    return ETrue;
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/DbCorruptTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,265 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+#include <BAUTILS.H>
+#include <S32FILE.H>
+#include <D32DBMS.H>
+#include "DbCorruptTests.h"
+#include <EmailStoreUids.hrh>
+
+//these must match those defined in ContainerStoreDefs.
+_LIT( KDbFilename, "message_store.db" );
+_LIT( KGeneralTableName,                      "G001" );
+_LIT( KGeneralTableDbSchemaVersionCol,        "G002" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CDbCorruptTests* CDbCorruptTests::NewL( CStifLogger* aLog )
+    {
+    CDbCorruptTests* self = new(ELeave) CDbCorruptTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CDbCorruptTests::CDbCorruptTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CDbCorruptTests::~CDbCorruptTests()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CDbCorruptTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CDbCorruptTests::ExecuteL()
+    {
+    LogHeader( _L("Database Corruption") );
+    
+    RFs                         fs;
+    RFile                       file;
+    CPermanentFileStore*        fileStore;
+    CMsgStorePropertyContainer* properties;
+    RDbStoreDatabase            database;
+    RDbTable                    table;
+    CDbColSet*                  colSet;
+    TUint                       unreadCount;
+    TUint                       totalCount;
+    TInt                        result;
+    TFileName                   dbFileName;
+    
+    User::LeaveIfError( fs.Connect() );
+
+    properties = CMsgStorePropertyContainer::NewL();
+
+    iLog->Log( _L("Case %d: Database file exists but is empty"), iCaseId++ );
+    
+    iLog->Log( _L("  Shutdown the server") );
+    //shutdown the server
+    ShutdownServerL();    
+    
+    // The file cannot be opened until the server has shut down, so keep trying until it is possible.
+    result = KErrInUse;
+    while( result == KErrInUse )
+        {       
+        Yield( 100000 );
+        dbFileName.Format( _L("C:\\private\\%x\\%S"), KUidMessageStoreExe, &KDbFilename );
+        result = file.Replace( fs, dbFileName, EFileWrite );
+        }
+        
+    file.Close();       
+    
+    CMsgStore* session = CMsgStore::NewL( ETrue );
+    CleanupStack::PushL( session );                                           //+1
+    
+    iLog->Log( _L("Case %d: Create Mailbox"), iCaseId++ );
+    CMsgStoreAccount* account1 = CMsgStoreAccount::NewLC( 1234, KNullDesC );   //+2
+    CMsgStoreMailBox* mailbox1 = session->CreateAccountL( *account1 );
+    CleanupStack::PushL( mailbox1 );                                           //+3
+    
+    iLog->Log( _L("Case %d: Message counts are 0"), iCaseId++ );
+    mailbox1->TotalMessageCountsL( totalCount, unreadCount );
+    CheckCondition( _L("no crash, counts are zero"), totalCount == 0 && unreadCount == 0 );
+    
+    iLog->Log( _L("Case %d: Create Folder"), iCaseId++ );
+    TMsgStoreId inbox1Id = mailbox1->CreateFolderL( mailbox1->Id(), *properties );
+    CMsgStoreFolder* inbox1 = mailbox1->FolderL( inbox1Id );
+    CleanupStack::PushL( inbox1 );                                             //+4
+    
+    iLog->Log( _L("Case %d: Create Message"), iCaseId++ );
+    CMsgStoreMessage* msg = mailbox1->CreateMessageL( inbox1Id, *properties );
+    delete msg;
+    
+    CleanupStack::PopAndDestroy(4);
+
+    //shutdown the server again
+    iLog->Log( _L("  Shutdown the server again") );
+    ShutdownServerL();    
+    
+    iLog->Log( _L("Case %d: Database file exists but contains bad content"), iCaseId++ );
+    result = KErrInUse;
+    while( result == KErrInUse )
+        {       
+        Yield( 100000 );
+        result = file.Replace( fs, dbFileName, EFileWrite );
+        }
+    
+    file.Write( _L8("RANDOM CONTENT") );
+    file.Close();       
+    
+    session = CMsgStore::NewL( ETrue );
+    CleanupStack::PushL( session );                                            //+1
+    
+    iLog->Log( _L("Case %d: Create Mailbox"), iCaseId++ );
+    account1 = CMsgStoreAccount::NewLC( 1234, KNullDesC );   //+2
+    mailbox1 = session->CreateAccountL( *account1 );
+    CleanupStack::PushL( mailbox1 );                                           //+3
+    
+    iLog->Log( _L("Case %d: Message counts are 0"), iCaseId++ );
+    mailbox1->TotalMessageCountsL( totalCount, unreadCount );
+    CheckCondition( _L("no crash, counts are zero"), totalCount == 0 && unreadCount == 0 );
+    
+    iLog->Log( _L("Case %d: Create Folder"), iCaseId++ );
+    inbox1Id = mailbox1->CreateFolderL( mailbox1->Id(), *properties );
+    inbox1 = mailbox1->FolderL( inbox1Id );
+    CleanupStack::PushL( inbox1 );                                             //+4
+    
+    iLog->Log( _L("Case %d: Create Message"), iCaseId++ );
+    msg = mailbox1->CreateMessageL( inbox1Id, *properties );
+
+    delete msg;
+    CleanupStack::PopAndDestroy(4);
+    
+    //shutdown the server again
+    iLog->Log( _L("  Shutdown the server again") );
+    ShutdownServerL();
+    
+    iLog->Log( _L("Case %d: Database file exists and contains an empty database"), iCaseId++ );
+
+    result = KErrInUse;
+    while( result == KErrInUse )
+        {       
+        Yield( 100000 );
+        TRAP( result, fileStore = CPermanentFileStore::ReplaceL( fs, dbFileName, EFileRead|EFileWrite ) );
+        }
+    
+    fileStore->SetTypeL( fileStore->Layout() );     
+    TStreamId id = database.CreateL( fileStore );   
+    fileStore->SetRootL( id );  
+    fileStore->CommitL();
+    database.Close();
+    delete fileStore;
+
+    session = CMsgStore::NewL( ETrue );
+    CleanupStack::PushL( session );                                            //+1
+    
+    iLog->Log( _L("Case %d: Create Mailbox"), iCaseId++ );
+    
+    account1 = CMsgStoreAccount::NewLC( 1234, KNullDesC );   //+2
+    mailbox1 = session->CreateAccountL( *account1 );
+    CleanupStack::PushL( mailbox1 );                                           //+3
+    
+    iLog->Log( _L("Case %d: Message counts are 0"), iCaseId++ );
+    mailbox1->TotalMessageCountsL( totalCount, unreadCount );
+    CheckCondition( _L("no crash, counts are zero"), totalCount == 0 && unreadCount == 0 );
+    
+    iLog->Log( _L("Case %d: Create Folder"), iCaseId++ );
+    inbox1Id = mailbox1->CreateFolderL( mailbox1->Id(), *properties );
+    inbox1 = mailbox1->FolderL( inbox1Id );
+    CleanupStack::PushL( inbox1 );                                             //+4
+    
+    iLog->Log( _L("Case %d: Create Message"), iCaseId++ );
+    msg = mailbox1->CreateMessageL( inbox1Id, *properties );
+    delete msg;
+    
+    CleanupStack::PopAndDestroy(4);    
+    
+    //shutdown the server again
+    iLog->Log( _L("  Shutdown the server again") );
+    ShutdownServerL();
+    
+    iLog->Log( _L("Case %d: Database schema mismatch"), iCaseId++ );
+
+    result = KErrInUse;
+    while( result == KErrInUse )
+        {       
+        Yield( 100000 );
+        TRAP( result, fileStore = CPermanentFileStore::OpenL( fs, dbFileName, EFileRead|EFileWrite ) );
+        }
+
+    database.OpenL( fileStore, fileStore->Root() );     
+    User::LeaveIfError( table.Open( database, KGeneralTableName ) );  
+    colSet = table.ColSetL();
+    TUint schemaVersionColNum = colSet->ColNo( KGeneralTableDbSchemaVersionCol );
+    delete colSet;  
+    table.FirstL();
+    table.UpdateL();
+    table.SetColL( schemaVersionColNum, 0 );
+    table.PutL();
+    table.Close();
+    database.Close();
+    delete fileStore;
+
+    session = CMsgStore::NewL( ETrue );
+    CleanupStack::PushL( session );                                            //+1
+    
+    iLog->Log( _L("Case %d: Create Mailbox"), iCaseId++ );
+    account1 = CMsgStoreAccount::NewLC( 1234, KNullDesC );                     //+2
+    mailbox1 = session->CreateAccountL( *account1 );
+    CleanupStack::PushL( mailbox1 );                                           //+3
+    
+    iLog->Log( _L("Case %d: Message counts are 0"), iCaseId++ );
+    mailbox1->TotalMessageCountsL( totalCount, unreadCount );
+    CheckCondition( _L("no crash, counts are zero"), totalCount == 0 && unreadCount == 0 );
+    
+    iLog->Log( _L("Case %d: Create Folder"), iCaseId++ );
+    inbox1Id = mailbox1->CreateFolderL( mailbox1->Id(), *properties );
+    inbox1 = mailbox1->FolderL( inbox1Id );
+    CleanupStack::PushL( inbox1 );                                             //+4
+    
+    iLog->Log( _L("Case %d: Create Message"), iCaseId++ );
+    msg = mailbox1->CreateMessageL( inbox1Id, *properties );
+
+    delete msg;
+    CleanupStack::PopAndDestroy(4);
+    
+    delete properties;      
+    fs.Close();
+    
+    //we are done 
+    return ETrue;
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/EncryptionTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,421 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+//#include <BAUTILS.H>
+#include "EncryptionTests.h"
+//#include <ismsgstorepropertykeys.h>
+//#include "messagestoreclientserver.h"
+
+// This must match that's defined in ContainerStoreDefs.h
+enum TEncryptionState
+{
+    EMsgStoreESIdle,
+    EMsgStoreESEncrypting,
+    EMsgStoreESDecrypting
+}; // end TEncryptionState
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CEncryptionTests* CEncryptionTests::NewL( CStifLogger* aLog )
+    {
+    CEncryptionTests* self = new(ELeave) CEncryptionTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CEncryptionTests::CEncryptionTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CEncryptionTests::~CEncryptionTests()
+    {
+    iTestContentArray.Reset();
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CEncryptionTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    iTestContentArray.AppendL( _L8("This is the first test content!") );
+    iTestContentArray.AppendL( _L8("This is the second test content!") );
+    iTestContentArray.AppendL( _L8("This is the first test content!") );
+    iTestContentArray.AppendL( _L8("What-ever!!!!") );
+    iTestContentArray.AppendL( _L8("ok fine!!!") );
+    iTestContentArray.AppendL( _L8("Here is a long content (>300 bytes).   Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.") );
+    iTestContentArray.AppendL( _L8("Is that long enough") );
+    iTestContentArray.AppendL( _L8("aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffff") );
+    iTestContentArray.AppendL( _L8("Here is a >300 unicode characters (> 600 bytes).   Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.  Here is a long content.") );
+    iTestContentArray.AppendL( _L8("Hi") );
+    iTestContentArray.AppendL( _L8("") );
+    iTestContentArray.AppendL( _L8("This is another test content") );
+    iTestContentArray.AppendL( _L8("How many more?") );
+    iTestContentArray.AppendL( _L8("Six more contents to go") );
+    iTestContentArray.AppendL( _L8("Five more contents to go") );
+    iTestContentArray.AppendL( _L8("     ") );
+    iTestContentArray.AppendL( _L8("Three more...") );
+    iTestContentArray.AppendL( _L8("Two more...") );
+    iTestContentArray.AppendL( _L8("One more...") );
+    iTestContentArray.AppendL( _L8("Last one! We are done") );
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CEncryptionTests::ExecuteL()
+    {
+    LogHeader( _L("Encryption") );
+    
+    iLog->Log( _L("Case %d: Testing SetPasswordL()"), iCaseId++ );
+    iMsgStore->SetPasswordL( _L("mypassword") );
+    
+    iLog->Log( _L("Case %d: Testing AuthenticatedL()"), iCaseId++ );
+    CheckCondition( _L("AuthenticatedL() is TRUE"), iMsgStore->AuthenticatedL() );
+    
+    iLog->Log( _L("Case %d: Testing HasPasswordL()"), iCaseId++ );
+    CheckCondition( _L("HasPasswordL() is TRUE"), iMsgStore->HasPasswordL() );
+    
+    iLog->Log( _L("Case %d: Create Mailboxes"), iCaseId++ );
+    RPointerArray<CMsgStoreAccount> accountArray;
+    CMsgStoreAccount* account1 = CMsgStoreAccount::NewL(1234, _L("Account 1") );
+    accountArray.Append( account1 );                                            
+    
+    CMsgStoreAccount* account2 = CMsgStoreAccount::NewL(1234, _L("") );
+    accountArray.Append( account2 );                                            
+    
+    CMsgStoreAccount* account3 = CMsgStoreAccount::NewL(5678, _L("Account 3") );
+    accountArray.Append( account3 );                                            
+    
+    CMsgStoreMailBox* mailBox1 = iMsgStore->CreateAccountL( *account1 );
+    CleanupStack::PushL( mailBox1 );                                            //+1
+    
+    CMsgStoreMailBox* mailBox2 = iMsgStore->CreateAccountL( *account2 );
+    CleanupStack::PushL( mailBox2 );                                            //+2
+    
+    CMsgStoreMailBox* mailBox3 = iMsgStore->CreateAccountL( *account3 );
+    CleanupStack::PushL( mailBox3 );                                            //+3
+    
+    CMsgStorePropertyContainer* properties = CMsgStorePropertyContainer::NewL();
+    CleanupStack::PushL( properties );                                          //+4
+    
+    properties->AddPropertyL( _L8("1"), _L("PROPERTY 1") );
+    properties->AddPropertyL( _L8("2"), 12345 );
+    properties->AddPropertyL( _L8("3"), _L8("ANOTHER PROPERTY") );
+    
+    iLog->Log( _L("Case %d: Create Folders"), iCaseId++ );
+    
+    TMsgStoreId inbox1Id = mailBox1->CreateFolderL( mailBox1->Id(), *properties );
+    TMsgStoreId sentFolderId = mailBox2->CreateFolderL( mailBox2->Id(), *properties );
+    TMsgStoreId deletedFolderId = mailBox3->CreateFolderL( mailBox3->Id(), *properties );
+    
+    iLog->Log( _L("  inbox=%x, sent=%x, deleted=%x"), inbox1Id, sentFolderId, deletedFolderId  );
+    
+    TInt msgCountPerFolder = 20;
+    
+    iLog->Log( _L("Case %d: Create messages in Inbox"), iCaseId++ );
+    //keep ids, message ids will be stored in iMatches
+    CreateRandomMessagesL( mailBox1, inbox1Id, msgCountPerFolder, ETrue ); 
+    
+    iLog->Log( _L("Case %d: Create messages in Sent folder"), iCaseId++ );
+    CreateRandomMessagesL( mailBox2, sentFolderId, msgCountPerFolder );
+    
+    iLog->Log( _L("Case %d: Create messages in Deleted folder"), iCaseId++ );
+    CreateRandomMessagesL( mailBox3, deletedFolderId, msgCountPerFolder );
+    
+    iLog->Log( _L("Case %d: Set msg contents and store them for comparison"), iCaseId++ );
+    for ( TInt i = 0 ; i < iMatches.Count() ; i++ )
+        {
+        CMsgStoreMessage* msg = mailBox1->FetchMessageL( iMatches[i], inbox1Id );
+        SetMessageContentL( msg, iTestContentArray[i] );
+        iMessages.Append( msg );
+        }
+
+    iLog->Log( _L("Case %d: Store Msg Ids Sorted by Subject and Sender for comparison"), iCaseId++ );
+    RArray<TMsgStoreId> idsSortdBySubject;
+    GetSortedIdsL( mailBox2, sentFolderId, EMsgStoreSortBySubject, msgCountPerFolder, idsSortdBySubject );
+    
+    RArray<TMsgStoreId> idsSortdByFrom;
+    GetSortedIdsL( mailBox3, deletedFolderId, EMsgStoreSortBySender, msgCountPerFolder, idsSortdByFrom );
+    
+    iLog->Log( _L("Case %d: Start Encryption"), iCaseId++ );
+    iMsgStore->EnableEncryptionL();
+    
+    iLog->Log( _L("  Wait until Encryption completes") );
+    WaitUntilEncryptDecryptCompleteL( EMsgStoreESEncrypting, mailBox1 );
+    
+    iLog->Log( _L("  Encryption completed") );
+    
+    iLog->Log( _L("Case %d: Comparing messages"), iCaseId++ );
+    CompareMessagesL( mailBox1 );
+    
+    iLog->Log( _L("Case %d: Comparing Accounts"), iCaseId++ );
+    CompareAccountsL( iMsgStore, accountArray );
+
+    iLog->Log( _L("Case %d: Comparing msg IDs sorted by Subject"), iCaseId++ );
+    RArray<TMsgStoreId> aSortedIds;
+    GetSortedIdsL( mailBox2, sentFolderId, EMsgStoreSortBySubject, msgCountPerFolder, aSortedIds );
+    CompareSortedIdArraysL( aSortedIds, idsSortdBySubject );
+    aSortedIds.Reset();
+    
+    iLog->Log( _L("Case %d: Comparing msg IDs sorted by Sender"), iCaseId++ );
+    GetSortedIdsL( mailBox3, deletedFolderId, EMsgStoreSortBySender, msgCountPerFolder, aSortedIds );
+    CompareSortedIdArraysL( aSortedIds, idsSortdByFrom );
+    aSortedIds.Reset();
+    
+    iLog->Log( _L("Case %d: Start Decryption"), iCaseId++ );
+    
+    iMsgStore->DisableEncryptionL();
+    
+    iLog->Log( _L("  Wait until Decryption completes") );
+    
+    WaitUntilEncryptDecryptCompleteL( EMsgStoreESDecrypting, mailBox1 );
+    
+    iLog->Log( _L("  Decryption completed") );
+    
+    iLog->Log( _L("Case %d: Comparing messages"), iCaseId++ );
+    CompareMessagesL( mailBox1 );
+    
+    iLog->Log( _L("Case %d: Comparing Accounts"), iCaseId++ );
+    CompareAccountsL( iMsgStore, accountArray );
+    
+    iLog->Log( _L("Case %d: Comparing msg IDs sorted by Subject"), iCaseId++ );
+    GetSortedIdsL( mailBox2, sentFolderId, EMsgStoreSortBySubject, msgCountPerFolder, aSortedIds );
+    CompareSortedIdArraysL( aSortedIds, idsSortdBySubject );
+    aSortedIds.Reset();
+    
+    iLog->Log( _L("Case %d: Comparing msg IDs sorted by Sender"), iCaseId++ );
+    GetSortedIdsL( mailBox3, deletedFolderId, EMsgStoreSortBySender, msgCountPerFolder, aSortedIds );
+    CompareSortedIdArraysL( aSortedIds, idsSortdByFrom );
+    aSortedIds.Reset();
+    
+    idsSortdBySubject.Close();
+    idsSortdByFrom.Close();
+    accountArray.ResetAndDestroy();
+    iMatches.Reset();
+    iMessages.ResetAndDestroy();
+    
+    CleanupStack::PopAndDestroy( 4 );
+    
+    //test authentication
+    iLog->Log( _L("Case %d: Test AuthenticateL"), iCaseId++ );
+    TRAPD(err, iMsgStore->AuthenticateL( _L("mypassword")) );
+    CheckCondition( _L("AuthenticateL successful"), err == KErrNone );
+    
+    iLog->Log( _L("Case %d: Test ChangePasswordL"), iCaseId++ );
+    TRAP(err, iMsgStore->ChangePasswordL( _L("mypassword"), _L("newpassword") ) );
+    CheckCondition( _L("ChangePasswordL successful"), err == KErrNone );
+        
+    iLog->Log( _L("Case %d: Test ClearAuthenticationL"), iCaseId++ );
+    TRAP(err, iMsgStore->ClearAuthenticationL() );
+    CheckCondition( _L("ClearAuthenticationL successful"), err == KErrNone );
+    
+    //we are done 
+    return ETrue;
+    }
+
+
+void CEncryptionTests::WaitUntilEncryptDecryptCompleteL( TInt aCurrentState, CMsgStoreMailBox* aMailBox )
+    {
+    RDebugSession debugSession;
+    User::LeaveIfError( debugSession.Connect() );
+    
+    TInt encryptionState = aCurrentState; 
+    TInt loopCount = 0;
+    TMsgStoreId folderId;
+    while( encryptionState !=  EMsgStoreESIdle && loopCount < 4000 )
+        {
+        Yield( 20000 );
+        loopCount++;
+        if ( loopCount % 20 == 0 )
+            {
+            encryptionState = debugSession.GetEncryptionStateL();
+            }
+        
+        if ( loopCount == 2 && encryptionState == aCurrentState )
+            {
+            iLog->Log( _L("Case %d: Testing fetch msgs while encryption/decription is in progress"), iCaseId++ );
+            CompareMessagesL( aMailBox );
+            }
+        
+        if ( loopCount == 5 && encryptionState == aCurrentState )
+            {
+            iLog->Log( _L("Case %d: Testing create msgs while encryption/decription is in progress"), iCaseId++ );
+            CMsgStorePropertyContainer* properties = CMsgStorePropertyContainer::NewL();
+            folderId = aMailBox->CreateFolderL( aMailBox->Id(), *properties);
+            delete properties;
+            CreateRandomMessagesL(aMailBox, folderId, 5);
+            }
+        
+        if ( loopCount == 8 && encryptionState == aCurrentState )
+            {
+            iLog->Log( _L("Case %d: Testing delete folder while encryption/decription is in progress"), iCaseId++ );
+            aMailBox->DeleteFolderL(folderId);
+            }
+        
+        if ( encryptionState != aCurrentState && encryptionState != EMsgStoreESIdle )
+            {
+            break;
+            }
+        }
+    
+    debugSession.Close();
+    if ( encryptionState != EMsgStoreESIdle )
+        {
+        iLog->Log( _L("  Encryption did NOT complete") );
+        User::Leave( KErrCancel );
+        }
+    }
+
+void CEncryptionTests::CompareMessagesL( CMsgStoreMailBox* aMailBox )
+    {
+    iLog->Log( _L("  >> CompareMessagesL") );
+    
+    RBuf8 contentBuf;
+    contentBuf.Create( 1024 );
+    contentBuf.CleanupClosePushL();
+    
+    for( TInt i = 0 ; i < iMessages.Count() ; i++ )
+        {
+        CMsgStoreMessage* msg = aMailBox->FetchMessageL( iMessages[i]->Id(), KMsgStoreInvalidId );
+        CleanupStack::PushL( msg );                               //+1
+        
+        ComparePropertiesL( *msg, *(iMessages[i]) );
+        
+        iLog->Log( _L("   Comparing contents...") );
+        
+        RPointerArray<CMsgStoreMessagePart> parts;
+        msg->ChildPartsL( parts );
+        CMsgStoreMessagePart* part =parts[0];
+        
+        RPointerArray<CMsgStoreMessagePart> childParts;
+        part->ChildPartsL( childParts );
+        CMsgStoreMessagePart* plain_text_part = childParts[0];
+        
+        plain_text_part->FetchContentToBufferL( contentBuf );
+        if ( contentBuf == iTestContentArray[i] )
+            {
+            iLog->Log( _L("   Contents match!") );
+            }
+        else
+            {
+            iLog->Log( _L("   Error: Contents don't match! index=%d"), i );
+            User::Leave( KErrNotFound );
+            }
+
+        childParts.ResetAndDestroy();
+        parts.ResetAndDestroy();
+        CleanupStack::PopAndDestroy( msg );
+        }
+    CleanupStack::PopAndDestroy( &contentBuf );
+    
+    iLog->Log( _L("  << CompareMessagesL - PASSED") );
+    }
+
+void CEncryptionTests::CompareAccountsL( CMsgStore* aSession, RPointerArray<CMsgStoreAccount>& aAccounts )
+    {
+    iLog->Log( _L("  >> CompareAccountsL") );
+    
+    RPointerArray<CMsgStoreAccount> accs;
+    aSession->AccountsL( accs );
+
+    CheckCondition( _L("Counts match"), accs.Count() == aAccounts.Count() );
+    
+    for ( TInt i = 0 ; i < accs.Count() ; i++ )
+        {
+        CMsgStoreAccount* acc = accs[i];
+        TBool found = EFalse;
+        for (TInt j = 0 ; !found && j < aAccounts.Count() ; j++ )
+            {
+            CMsgStoreAccount* acc2 = aAccounts[j];
+            if ( acc->Owner() == acc2->Owner() && acc->Name() == acc2->Name() )
+                {
+                found = ETrue;
+                }
+            }
+        if ( !found )
+            {
+            iLog->Log( _L("  Account:%X %S not found!"), acc->Owner(), &( acc->Name() ) );
+            User::Leave(KErrNotFound);
+            }
+        }
+    
+    accs.ResetAndDestroy();
+    
+    iLog->Log( _L("  << CompareAccountsL - PASSED") );
+    }
+
+void CEncryptionTests::GetSortedIdsL( CMsgStoreMailBox* aMailBox, TMsgStoreId aFolderId, TMsgStoreSortByField aSortedBy, TInt aCount, RArray<TMsgStoreId>& aSortedIds )
+    {
+    iLog->Log( _L("  >> GetSortedIdsL") );
+    
+    RMsgStoreSortCriteria criteria;
+    CleanupClosePushL( criteria );
+    
+    criteria.iFolderId = aFolderId;
+    criteria.AddResultPropertyL( KMsgStorePropertyFrom );
+    criteria.AddResultPropertyL( KMsgStorePropertySubject );
+    criteria.iSortBy   = aSortedBy;
+    criteria.iSortOrder = EMsgStoreSortDescending;
+    
+    CMsgStoreSortResultIterator* iterator = aMailBox->SortL( criteria ); 
+    CleanupStack::PushL( iterator );
+    
+    RPointerArray<CMsgStorePropertyContainer> results;
+    
+    iterator->NextL( KMsgStoreSortResultTop, aCount, results );
+    for ( TInt i = 0 ; i < results.Count() ; i++ )
+        {
+        TMsgStoreId msgId = results[i]->Id();
+        aSortedIds.Append( msgId );
+        }
+
+    results.ResetAndDestroy();
+    CleanupStack::PopAndDestroy( iterator );
+    CleanupStack::PopAndDestroy( &criteria );
+    
+    iLog->Log( _L("  << GetSortedIdsL") );
+    }
+
+void CEncryptionTests::CompareSortedIdArraysL( RArray<TMsgStoreId>& aIDs1, RArray<TMsgStoreId>& aIDs2 )
+    {
+    iLog->Log( _L("  >> CompareSortedIdArraysL") );
+    
+    CheckCondition(_L("Counts match"), aIDs1.Count() == aIDs2.Count() );
+    
+    for ( TInt i = 0 ; i < aIDs1.Count() ; i++ )
+        {
+        if ( aIDs1[i] != aIDs2[i] )
+            {
+            iLog->Log( _L("  Arrays don't match. Index=%d, val1=%u, val2=%u") , i, aIDs1[i], aIDs2[i] );
+            User::Leave( KErrNotFound );
+            }
+        }
+    
+    iLog->Log( _L("  << CompareSortedIdArraysL - PASSED") );
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/FolderTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,322 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <tz.h>
+#include "FolderTests.h"
+//#include <ismsgstorepropertykeys.h>
+#include "messagestoreclientserver.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CFolderTests* CFolderTests::NewL( CStifLogger* aLog )
+    {
+    CFolderTests* self = new(ELeave) CFolderTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CFolderTests::CFolderTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CFolderTests::~CFolderTests()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CFolderTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CFolderTests::ExecuteL()
+    {
+    LogHeader( _L("Folder") );
+    
+    //account 1
+    CMsgStoreAccount* account1 = CMsgStoreAccount::NewLC( 1234, KNullDesC );   //+1
+    CMsgStoreMailBox* mailBox1 = iMsgStore->CreateAccountL( *account1 );
+    CleanupStack::PushL( mailBox1 );                                           //+2
+    
+    iLog->Log( _L("Case %d: Create Top-Level folders"), iCaseId++ );
+    
+    CMsgStorePropertyContainer* properties = CMsgStorePropertyContainer::NewL();
+    CleanupStack::PushL( properties );                                         //+3
+    
+    TestAddIntegerPropertyL( *properties, _L8("INTEGER PROPERTY"), 99999 );
+    TestAddDes8PropertyL( *properties, _L8("STRING PROPERTY"), _L8("STRING VALUE") );
+    
+    TMsgStoreId folder1Id = mailBox1->CreateFolderL( mailBox1->Id(), *properties );
+    
+    CMsgStoreFolder* folder = mailBox1->FolderL( folder1Id );
+    
+    ComparePropertiesL( *properties, *folder );
+    CheckCondition( _L("parent folder ID"), folder->ParentId() ==  mailBox1->Id() );
+    delete folder;
+    
+    iLog->Log( _L("Case %d: Create local sub-folder"), iCaseId++ );
+    TMsgStoreId folder2Id = mailBox1->CreateFolderL( folder1Id, *properties, ETrue );
+    
+    folder = mailBox1->FolderL( folder2Id );
+    CheckCondition( _L("is local flag"), folder->IsLocalL() );
+    
+    ComparePropertiesL( *properties, *folder );
+    CheckCondition( _L("parent folder ID"), folder->ParentId() == folder1Id );
+    delete folder;
+    
+    iLog->Log( _L("Case %d: Move folder"), iCaseId++ );
+    TMsgStoreId folder3Id = mailBox1->CreateFolderL( mailBox1->Id(), *properties );
+    mailBox1->MoveFolderL( folder3Id, mailBox1->Id(), folder2Id );
+    
+    iLog->Log( _L("Case %d: Delete folder"), iCaseId++ );
+    mailBox1->DeleteFolderL( folder3Id );
+    
+    iLog->Log( _L("Case %d: Error - Open non-existing folder"), iCaseId++ );
+    TRAPD( err, folder = mailBox1->FolderL( folder3Id ) );  //folder should be deleted
+    CheckCondition( _L("open non-existing folder - -1"), err == KErrNotFound );
+    
+    iLog->Log( _L("Case %d: Get root folders"), iCaseId++ );
+    //get the system folders
+    TMsgStoreRootFolders rootFolders; 
+    MsgStoreFolderUtils::InitializeRootFoldersL( *mailBox1, rootFolders ); 
+    
+    RPointerArray<CMsgStoreFolder> folders;
+    mailBox1->FoldersL( folders );
+    
+    RArray<TMsgStoreId> expectedIds;
+    expectedIds.AppendL( folder1Id );
+    expectedIds.AppendL( folder2Id );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreInbox] );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreOutbox] );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreDrafts] );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreSent] );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreDeleted] );
+
+    
+    VerifyFolderIdsL( folders, expectedIds );
+    
+    for ( int i = 0 ; i < folders.Count() ; i++ )
+        {
+        iLog->Log( _L("  folderId=%d, parentId=%d"), folders[i]->Id(), folders[i]->ParentId() );
+        }
+    
+    folders.ResetAndDestroy();
+    expectedIds.Reset();
+    
+    
+    iLog->Log( _L("Case %d: Create more user defined folders, with messages in them"), iCaseId++ );
+    folder3Id = mailBox1->CreateFolderL( folder1Id, *properties );
+
+    CMsgStoreMessage* message = mailBox1->CreateMessageL( folder2Id, *properties );
+    TMsgStoreId messageId = message->Id();
+    message->CommitL();
+    delete message;
+    message = mailBox1->CreateMessageL( folder2Id, *properties );
+    message->CommitL();
+    delete message;
+    
+    TMsgStoreId folder4Id = mailBox1->CreateFolderL( folder2Id, *properties );
+    
+    message = mailBox1->CreateMessageL( folder4Id, *properties );
+    message->CommitL();
+    delete message;
+
+    TMsgStoreId folder5Id = mailBox1->CreateFolderL( folder2Id, *properties );
+
+    iLog->Log( _L("Case %d: List all folders"), iCaseId++ );
+    mailBox1->FoldersL( folders );
+    
+    expectedIds.AppendL( folder1Id );
+    expectedIds.AppendL( folder2Id );
+    expectedIds.AppendL( folder3Id );
+    expectedIds.AppendL( folder4Id );
+    expectedIds.AppendL( folder5Id );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreInbox] );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreOutbox] );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreDrafts] );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreSent] );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreDeleted] );
+    VerifyFolderIdsL( folders, expectedIds );
+    
+    folders.ResetAndDestroy();
+    
+    iLog->Log( _L("Case %d: List child folders"), iCaseId++ );
+    mailBox1->FoldersL( folder1Id, folders );
+    
+    RArray<TMsgStoreId> expectedIds2;
+    expectedIds2.AppendL( folder2Id );
+    expectedIds2.AppendL( folder3Id );
+    VerifyFolderIdsL( folders, expectedIds2 );
+    
+    folders.ResetAndDestroy();
+    expectedIds2.Reset();
+
+    iLog->Log( _L("Case %d: List child folders recursively"), iCaseId++ );
+    //list all subfolders of folder1Id
+    mailBox1->FoldersL( folder1Id, folders, ETrue );
+    
+    expectedIds2.Reset();
+    expectedIds2.AppendL( folder2Id );
+    expectedIds2.AppendL( folder3Id );
+    expectedIds2.AppendL( folder4Id );
+    expectedIds2.AppendL( folder5Id );
+    VerifyFolderIdsL( folders, expectedIds2 );
+    
+    folders.ResetAndDestroy();          
+    expectedIds2.Reset();
+
+    mailBox1->FoldersL( folder2Id, folders );
+    
+    expectedIds2.AppendL( folder4Id );
+    expectedIds2.AppendL( folder5Id );
+    VerifyFolderIdsL( folders, expectedIds2 );
+
+    folders.ResetAndDestroy();          
+    expectedIds2.Reset();
+    
+    iLog->Log( _L("Case %d: Delete user defined folder with no children"), iCaseId++ );
+    mailBox1->DeleteFolderL( folder5Id );
+
+    mailBox1->FoldersL( folders );
+    
+    expectedIds.Remove( 4 ); // folder5
+    VerifyFolderIdsL( folders, expectedIds );
+    folders.ResetAndDestroy();
+    expectedIds.Reset();
+    
+    iLog->Log( _L("Case %d: Delete user defined folder with children"), iCaseId++ );
+    mailBox1->DeleteFolderL( folder2Id );
+
+    mailBox1->FoldersL( folders );
+    
+    expectedIds.AppendL( folder1Id ); 
+    expectedIds.AppendL( folder3Id ); 
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreInbox] );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreOutbox] );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreDrafts] );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreSent] );
+    expectedIds.AppendL( rootFolders.iFolders[EMsgStoreDeleted] );
+    
+    VerifyFolderIdsL( folders, expectedIds );
+    
+    folders.ResetAndDestroy();          
+    expectedIds.Reset();
+    
+    // ERROR PATH TESTS
+    
+    iLog->Log( _L("Case %d: Error - Delete nonexistent folder"), iCaseId++ );
+    TRAPD( result, mailBox1->DeleteFolderL( folder5Id ) );
+    CheckCondition( _L("not found error"), result == KErrNotFound );
+        
+    iLog->Log( _L("Case %d: Error - Create folder in nonexistent folder"), iCaseId++ );
+    TRAP( result, mailBox1->CreateFolderL( folder5Id, *properties ) );
+    CheckCondition( _L("not found error"), result == KErrNotFound );
+        
+    iLog->Log( _L("Case %d: Error - FolderL for nonexistent folder"), iCaseId++ );
+    TRAP( result, mailBox1->FolderL( folder4Id ) );
+    CheckCondition( _L("not found error"), result == KErrNotFound );
+        
+    iLog->Log( _L("Case %d: Error - FoldersL for nonexistent parent folder"), iCaseId++ );
+    TRAP( result, mailBox1->FoldersL( folder2Id, folders ) );
+    CheckCondition( _L("not found error"), result == KErrNotFound );
+        
+    iLog->Log( _L("Case %d: Error - Create folder with wrong type for folder"), iCaseId++ );
+    TRAP( result, mailBox1->CreateFolderL( messageId, *properties ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+        
+    iLog->Log( _L("Case %d: Error - Delete folder with wrong type for folder"), iCaseId++ );
+    TRAP( result, mailBox1->DeleteFolderL( messageId ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+        
+    iLog->Log( _L("Case %d: Error - FolderL with wrong type for folder"), iCaseId++ );
+    TRAP( result, mailBox1->FolderL( messageId ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+        
+    iLog->Log( _L("Case %d: Error - FoldersL with wrong type for folder"), iCaseId++ );
+    TRAP( result, mailBox1->FoldersL( messageId, folders ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+
+    // OUT OF MEMORY ERROR PATH TESTS
+
+    iLog->Log( _L("Case %d: Error - Out of memory"), iCaseId++ );
+    for( TInt i = 0; i < 1; i++ )
+        {        
+        SimulateLowDiskSpaceL( i );
+        TRAP( result, mailBox1->CreateFolderL( folder1Id, *properties ) );
+        CheckCondition( _L("out of memory"), result == KErrNoMemory );
+        }
+        
+    CleanupStack::PopAndDestroy( 3 );
+    
+    //we are done 
+    return ETrue;
+    }
+
+void CFolderTests::VerifyFolderIdsL( RPointerArray<CMsgStoreFolder>& aFolders, RArray<TMsgStoreId>& aExpectedIds )
+    {           
+    iLog->Log( _L(" >> VerifyFolderIdsL") );
+    
+    TBool passed = (aFolders.Count() == aExpectedIds.Count() );
+    
+    for( TInt i = 0; i < aFolders.Count(); i++ )
+        {
+        TBool found = EFalse;
+        for ( TInt j = 0; j < aExpectedIds.Count() && !found; j++ )
+            {
+            found = (aFolders[i]->Id() == aExpectedIds[j]);
+            }
+        passed = passed && found;               
+        }
+
+    if( !passed )
+        {
+        for( TInt i = 0; i < aExpectedIds.Count(); i++ )
+            {                   
+            iLog->Log( _L("  expected[%i]=%x"), i, aExpectedIds[i] );
+            }
+        for( TInt i = 0; i < aFolders.Count(); i++ )
+            {                   
+            iLog->Log( _L("  found[%i]=%x"), i, aFolders[i]->Id() );
+            }               
+        }
+    
+    TBuf<30> text;
+    text.Format( _L("%i ids matched"), aFolders.Count() );
+    CheckCondition( text, passed );         
+    
+    iLog->Log( _L(" << VerifyFolderIdsL") );
+    }
+                
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/MailboxTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,292 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <tz.h>
+#include "MailboxTests.h"
+#include <msgstoreapi.h>
+//#include <ismsgstorepropertykeys.h>        
+        
+// ============================ MEMBER FUNCTIONS ===============================
+
+CMailboxTests* CMailboxTests::NewL( CStifLogger* aLog )
+    {
+    CMailboxTests* self = new(ELeave) CMailboxTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CMailboxTests::CMailboxTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CMailboxTests::~CMailboxTests()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CMailboxTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CMailboxTests::ExecuteL()
+    {
+    LogHeader( _L("Mailbox") );
+    
+    //StartRecordingObserverEvents();
+    TInt32 owner1 = 1234;
+    TInt32 owner2 = 5678;
+    _LIT(KName1, "My Account");
+    _LIT(KName2, "Your Account");
+    
+    iLog->Log( _L("Case %d: Account Object"), iCaseId++ );
+    
+    iLog->Log( _L("  Test Accounts in Memory") );
+    
+    CMsgStoreAccount* testAcc = CMsgStoreAccount::NewLC(9999, _L("test accoun"));  //+testAcc
+    CheckCondition( _L("owner id"), testAcc->Owner() == 9999 );
+    CheckCondition( _L("account name"), testAcc->Name() == _L("test accoun") );
+    
+    _LIT( KChangeAccountOwner, "  Change Account Owner" );
+    iLog->Log( KChangeAccountOwner );
+    testAcc->SetOwner( 8888 );
+    CheckCondition( _L("new owner id"), testAcc->Owner() == 8888 );
+    
+    _LIT( KChangeAccountNameLong, "  Change Account Name (long)" );
+    iLog->Log( KChangeAccountNameLong );
+    testAcc->SetNameL( _L("this is a very very long account name") );
+    CheckCondition( _L("new account name"), testAcc->Name() == _L("this is a very very long account name") );
+    
+    _LIT( KChangeAccountNameShort, "  Change Account Name (short)" );
+    iLog->Log( KChangeAccountNameShort );
+    testAcc->SetNameL( _L("sl name") );
+    CheckCondition( _L("new account name"), testAcc->Name() == _L("sl name") ) ;
+    
+    CleanupStack::PopAndDestroy( testAcc );
+    
+    iLog->Log( _L("Case %d: Create Mailboxes"), iCaseId++ );
+    
+    //account 1
+    CMsgStoreMailBox* mailBox1 = NULL;
+    CMsgStoreAccount* account1 = CMsgStoreAccount::NewLC( owner1, KNullDesC );   //+1
+    
+    TRAPD( err, mailBox1 = iMsgStore->CreateAccountL( *account1 ) );
+    
+    CleanupStack::PushL( mailBox1 );                                            //+2
+    CheckCondition( _L("Id1, empty name"), err == KErrNone );
+    
+    //mailbox 1 should be set as default mailbox now
+    iLog->Log( _L("  mailbox1Id=%d, isCorporate=%d"), mailBox1->Id(), mailBox1->IsCorporateMailbox() );
+    
+    //account 2, with propertyes
+    CMsgStoreMailBox* mailBox2 = NULL;
+    CMsgStoreAccount* account2 = CMsgStoreAccount::NewLC( owner1, KName1 );      //+3
+    
+    CMsgStorePropertyContainer* properties = CMsgStorePropertyContainer::NewL();
+    properties->AddPropertyL(_L8("mailbox property"), _L("maibox property value"));
+    
+    TUint32 aSourceId = 0x80001;
+    TUint32 feature = 0x1f;
+    properties->AddOrUpdatePropertyL( KIsPropertyEmailSourceId, aSourceId );
+    properties->AddOrUpdatePropertyL( KIsPropertyCapabilities, feature );
+    
+    mailBox2 = iMsgStore->CreateAccountL( *account2, properties );    
+   
+    CleanupStack::PushL( mailBox2 );                                            //+4
+    
+    //mailbox 1 should be set as default mailbox now
+    iLog->Log( _L("  mailbox2Id=%d, isCorporate=%d"), mailBox2->Id(), mailBox2->IsCorporateMailbox() );
+    
+    ComparePropertiesL( *mailBox2, *properties );
+    delete properties;
+    
+    //account 3
+    CMsgStoreMailBox* mailBox3 = NULL;
+    CMsgStoreAccount* account3 = CMsgStoreAccount::NewLC( owner2, KNullDesC );    //+5
+    
+    TRAP( err, mailBox3 = iMsgStore->CreateAccountL( *account3 ) );    
+    
+    CleanupStack::PushL( mailBox3 );                                            //+6
+    CheckCondition( _L("Id2, empty name"), err == KErrNone );
+    //mailbox 1 should be set as default mailbox now
+    iLog->Log( _L("  mailbox3Id=%d, isCorporate=%d"), mailBox3->Id(), mailBox3->IsCorporateMailbox() );
+    
+    //account 4
+    CMsgStoreMailBox* mailBox4 = NULL;
+    CMsgStoreAccount* account4 = CMsgStoreAccount::NewLC( owner2, KName2 );       //+7
+    
+    properties = CMsgStorePropertyContainer::NewL();
+    properties->AddOrUpdatePropertyL( KIsPropertyServerType, (TUint32)ESrvExchange );
+    
+    TRAP( err, mailBox4 = iMsgStore->CreateAccountL( *account4, properties ) );  
+    delete properties;
+    
+    CleanupStack::PushL( mailBox4 );                                              //+8
+    CheckCondition( _L("Id2, name2"), err == KErrNone );
+    iLog->Log( _L("  mailbox4Id=%d, isCorporate=%d"), mailBox4->Id(), mailBox4->IsCorporateMailbox() );
+    
+    //test account aready exists error
+    iLog->Log( _L("Case %d: Error - Test Account Exists"), iCaseId++ );
+    
+    CMsgStoreMailBox* mailBox = NULL;
+    TRAP( err, mailBox = iMsgStore->CreateAccountL( *account1 ) );    
+    delete mailBox;
+    mailBox = NULL;
+    CheckCondition( _L("account1 exists - empty name"), err == KErrAlreadyExists );
+    
+    TRAP( err, mailBox = iMsgStore->CreateAccountL( *account4 ) );    
+    delete mailBox;
+    mailBox = NULL;
+    CheckCondition( _L("account2 exists - name2"), err == KErrAlreadyExists );
+
+    DoListAccountsL( *iMsgStore );
+
+    iLog->Log( _L("Case %d: Set/Get Default Mailbox"), iCaseId++ );
+    iMsgStore->SetDefaultMailboxL( mailBox3->Id() );
+    
+    TMsgStoreId id = iMsgStore->DefaultMailboxL();
+    CheckCondition( _L("DefaultMailboxL() is now account3"), mailBox3->Id() );
+    
+    iLog->Log( _L("Case %d: Open Account by Account Object"), iCaseId++ );
+    mailBox = iMsgStore->OpenAccountL( *account1 );
+    CheckCondition( _L("open account 1"), mailBox->Id() == mailBox1->Id() );
+    iLog->Log( _L("  mailbox1Id=%d, isCorporate=%d"), mailBox->Id(), mailBox->IsCorporateMailbox() );
+    delete mailBox;
+    
+    mailBox = iMsgStore->OpenAccountL( *account2 );
+    CheckCondition( _L("open account 2"), mailBox->Id() == mailBox2->Id() );
+    iLog->Log( _L("  mailbox2Id=%d, isCorporate=%d"), mailBox->Id(), mailBox->IsCorporateMailbox() );
+    delete mailBox;
+    
+    mailBox = iMsgStore->OpenAccountL( *account3 );
+    CheckCondition( _L("open account 3"), mailBox->Id() == mailBox3->Id() );
+    iLog->Log( _L("  mailbox3Id=%d, isCorporate=%d"), mailBox->Id(), mailBox->IsCorporateMailbox() );
+    delete mailBox;
+    
+    mailBox = iMsgStore->OpenAccountL( *account4 );
+    CheckCondition( _L("open account 4"), mailBox->Id() == mailBox4->Id() );
+    iLog->Log( _L("  mailbox4Id=%d, isCorporate=%d"), mailBox->Id(), mailBox->IsCorporateMailbox() );
+    delete mailBox;
+    
+    iLog->Log( _L("Case %d: Open Account by MailBoxId"), iCaseId++ );
+    mailBox = iMsgStore->OpenAccountL( mailBox1->Id() );
+    CheckCondition( _L("open account 1 by MailBoxId"), mailBox->Id() == mailBox1->Id() );
+    delete mailBox;
+    
+    mailBox = iMsgStore->OpenAccountL( mailBox2->Id() );
+    CheckCondition( _L("open account 2 by MailBoxId"), mailBox->Id() == mailBox2->Id() );
+    //ComparePropertiesL( *mailBox, *mailBox2 );
+    delete mailBox;
+    
+    mailBox = iMsgStore->OpenAccountL( mailBox3->Id() );
+    CheckCondition( _L("open account 3 by MailBoxId"), mailBox->Id() == mailBox3->Id() );
+    //ComparePropertiesL( *mailBox, *mailBox3 );
+    delete mailBox;
+    
+    mailBox = iMsgStore->OpenAccountL( mailBox4->Id() );
+    CheckCondition( _L("open account 4 by MailBoxId"), mailBox->Id() == mailBox4->Id() );
+    //ComparePropertiesL( *mailBox, *mailBox4 );
+    delete mailBox;
+    mailBox = NULL;
+    
+    iLog->Log( _L("Case %d: Error - Open Account"), iCaseId++ );
+    iLog->Log( _L("  Open an nonexisting account - bad owner id") );
+    //Open an nonexisting account - bad owner id
+    CMsgStoreAccount* badAccount1 = CMsgStoreAccount::NewLC( 1, KName2 );             //+9
+    TRAP(err, mailBox = iMsgStore->OpenAccountL(*badAccount1) );
+    CheckCondition( _L("bad ownerId"), err==KErrNotFound );
+    
+    iLog->Log( _L("  Open an nonexisting account - bad name") );
+    //Open an nonexisting account - bad name
+    CMsgStoreAccount* badAccount2 = CMsgStoreAccount::NewLC( owner1, _L("bad name") ); //+10
+    TRAP(err, mailBox = iMsgStore->OpenAccountL(*badAccount2) );
+    CheckCondition( _L("bad name"), err==KErrNotFound );
+    
+    iLog->Log( _L("Case %d: Rename Account"), iCaseId++ );
+    
+    TRAP(err, iMsgStore->RenameAccountL( account1->Owner(), account1->Name(), _L("New acc 1")) );
+    CheckCondition( _L("rename account1"), err==KErrNone );
+    
+    TRAP(err, iMsgStore->RenameAccountL( account1->Owner(), account1->Name(), _L("New acc 1")) );
+    CheckCondition( _L("rename account1 again - should return -1"), err==KErrNotFound );
+    
+    TRAP(err, iMsgStore->RenameAccountL( account4->Owner(), account4->Name(), _L("New acc 4")) );
+    CheckCondition( _L("rename account4"), err==KErrNone );
+    
+    iLog->Log( _L("Case %d: Error - Rename Account"), iCaseId++ );
+    TRAP(err, iMsgStore->RenameAccountL( account1->Owner(), _L("New acc 1"), KName1) );
+    CheckCondition( _L("new name already exists"), err==KErrAlreadyExists );
+    
+    DoListAccountsL( *iMsgStore );
+    
+    iLog->Log( _L("Case %d: Delete Account"), iCaseId++ );
+    
+    TRAP(err, iMsgStore->DeleteAccountL(*account2));
+    CheckCondition( _L("delete account2"), err==KErrNone );
+    
+    TRAP(err, iMsgStore->DeleteAccountL(*account3));
+    CheckCondition( _L("delete account3"), err==KErrNone );
+    
+    iLog->Log( _L("Case %d: Error - Delete Account"), iCaseId++ );
+    TRAP(err, iMsgStore->DeleteAccountL(*account2));
+    CheckCondition( _L("delete account2 again - should return -1"), err==KErrNotFound );
+    
+    TRAP(err, iMsgStore->DeleteAccountL(*account4));
+    CheckCondition( _L("delete account4 using old name, should return -1"), err==KErrNotFound );
+    
+    DoListAccountsL( *iMsgStore );
+    
+    CleanupStack::PopAndDestroy( 10 );
+    
+    //we are done 
+    return ETrue;
+    }
+
+void CMailboxTests::DoListAccountsL( CMsgStore& aMsgStore )
+{
+    iLog->Log( _L("  --List Accounts--") );
+    RPointerArray<CMsgStoreAccount> accounts;
+    TRAPD( err, aMsgStore.AccountsL( accounts ) );
+    CheckCondition( _L("Accounts"), err == KErrNone );
+    
+    for ( int i = 0 ; i < accounts.Count() ; i++ )
+        {
+        CMsgStoreAccount* account = accounts[i];
+        iLog->Log( _L("  id=%i, name=%S"), account->Owner(), &account->Name() );
+        }
+    
+    accounts.ResetAndDestroy();
+}
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/MessageTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,603 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <tz.h>
+#include "MessageTests.h"
+//#include <ismsgstorepropertykeys.h>
+#include "messagestoreclientserver.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CMessageTests* CMessageTests::NewL( CStifLogger* aLog )
+    {
+    CMessageTests* self = new(ELeave) CMessageTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CMessageTests::CMessageTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CMessageTests::~CMessageTests()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CMessageTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CMessageTests::ExecuteL()
+    {
+    LogHeader( _L("Message") );
+    
+    //account 1
+    CMsgStoreAccount* account1 = CMsgStoreAccount::NewLC( 1234, KNullDesC );   //+1
+    CMsgStoreMailBox* mailBox1 = iMsgStore->CreateAccountL( *account1 );
+    CleanupStack::PushL( mailBox1 );                                           //+2
+
+    //accoun 2
+    CMsgStoreAccount* account2 = CMsgStoreAccount::NewLC( 4567, _L("Account 2") );  //+3
+    CMsgStoreMailBox* mailBox2 = iMsgStore->CreateAccountL( *account2 );
+    CleanupStack::PushL( mailBox2 );                                           //+4
+    
+    CMsgStorePropertyContainer* properties = CMsgStorePropertyContainer::NewL();
+    
+    CleanupStack::PushL( properties );                                          //+5
+    TestAddIntegerPropertyL( *properties, _L8("INTEGER PROPERTY"), 99999 );
+    TestAddDes8PropertyL( *properties, _L8("STRING PROPERTY"), _L8("STRING VALUE") );
+    TestAddDesPropertyL( *properties, _L8("name"), _L("Inbox") );
+    
+    TMsgStoreId inbox1Id = mailBox1->CreateFolderL( mailBox1->Id(), *properties );
+    CMsgStoreFolder* inbox1 = mailBox1->FolderL( inbox1Id );
+    CleanupStack::PushL( inbox1 );                                              //+6
+    
+    TMsgStoreId inbox2Id = mailBox2->CreateFolderL( mailBox2->Id(), *properties );
+    CMsgStoreFolder* inbox2 = mailBox2->FolderL( inbox2Id );
+    CleanupStack::PushL( inbox2 );                                              //+7
+    
+    //create outbox folders for mailbox1 and mailbox2
+    CMsgStorePropertyContainer* outboxProp = CMsgStorePropertyContainer::NewL();
+    CleanupStack::PushL( outboxProp );                                          //+8
+    
+    TestAddIntegerPropertyL( *outboxProp, _L8("INTEGER PROPERTY"), 99999 );
+    TestAddDes8PropertyL( *outboxProp, _L8("STRING PROPERTY"), _L8("STRING VALUE") );
+    TestAddDesPropertyL( *outboxProp, _L8("name"), _L("Outbox") );
+    
+    TMsgStoreId outbox1Id = mailBox1->CreateFolderL( mailBox1->Id(), *outboxProp );
+    CMsgStoreFolder* outbox1 = mailBox1->FolderL( outbox1Id );
+    CleanupStack::PushL( outbox1 );                                              //+9
+    
+    TMsgStoreId outbox2Id = mailBox1->CreateFolderL( mailBox2->Id(), *outboxProp );
+    CMsgStoreFolder* outbox2 = mailBox1->FolderL( outbox2Id );
+    CleanupStack::PushL( outbox2 );                                              //+10
+    
+    
+    RArray<TMsgStoreId> expectedIds;
+    
+    CMsgStorePropertyContainer* properties2 = CMsgStorePropertyContainer::NewL();
+    CleanupStack::PushL( properties2 );                                           //+11
+    TestAddIntegerPropertyL( *properties2, KMsgStorePropertyFlags, 0 );
+    TestAddIntegerPropertyL( *properties2, KMsgStorePropertyReplyBy, 1 );
+    TestAddIntegerPropertyL( *properties2, _L8("SOME INTEGER PROPERTY"), KMaxTUint32 );
+    TestAddDes8PropertyL( *properties2, _L8("SOME OTHER PROPERTY"), _L8("SOME VALUE") );
+    
+    iLog->Log( _L("Case %d: Create messages"), iCaseId++ );
+    
+    _LIT8( KTestContent, "TEST CONTENT" );
+    
+    CMsgStoreMessage* message1 = mailBox1->CreateMessageL( inbox1Id, *properties2 );
+    CleanupStack::PushL( message1 );                                             //+12
+    
+    iLog->Log( _L("Case %d: Total Message Count"), iCaseId++ );
+    
+    //get message counts
+    TUint totalCount, unreadCount;
+    mailBox1->TotalMessageCountsL( totalCount, unreadCount );
+    
+    CheckCondition( _L("Msg Not Committed. Count=0"), totalCount==0 && unreadCount==0 );
+    
+    message1->CommitL();
+    
+    mailBox1->TotalMessageCountsL( totalCount, unreadCount );
+    CheckCondition( _L("Msg Commited. Count=1"), totalCount==1 && unreadCount==1 );
+    
+    iLog->Log( _L("Case %d: Create message in a different way"), iCaseId++ );
+    CMsgStorePropertyContainer* props = CMsgStorePropertyContainer::NewL();
+    props->AddOrUpdatePropertyL( KMsgStorePropertyFlags, (TUint32) 0 );  //set the unread flag
+        
+    CMsgStoreMessage* tmpMsg = mailBox1->CreateMessageL( inbox1Id, *props );
+    
+    mailBox1->TotalMessageCountsL( totalCount, unreadCount );
+    CheckCondition( _L("Msg Not Committed. Count=1"), totalCount==1 && unreadCount==1 );
+    
+    mailBox1->TotalMessageCountsL( totalCount, unreadCount );
+    CheckCondition( _L("Msg Not Committed. Count=1"), totalCount==1 && unreadCount==1 );
+    
+    tmpMsg->CommitL();
+    
+    mailBox1->TotalMessageCountsL( totalCount, unreadCount );
+    CheckCondition( _L("Msg Commited. Count=2"), totalCount==2 && unreadCount==2 );
+    
+    iLog->Log( _L("Case %d: Delete Message"), iCaseId++ );
+    mailBox1->DeleteMessageL( tmpMsg->Id(), inbox1Id );
+    
+    delete tmpMsg;
+    
+    iLog->Log( _L("Case %d: Abandon Uncommitted Message"), iCaseId++ );
+    tmpMsg = mailBox1->CreateMessageL( inbox1Id, *props );
+    //Instead commit, abandon it
+    tmpMsg->AbandonL();
+    
+    delete tmpMsg;
+    
+    delete props;
+    
+    iLog->Log( _L("Case %d: StorePropertiesL in between create and commit"), iCaseId++ );
+    CMsgStoreMessage* message2 = mailBox1->CreateMessageL( inbox1Id, *properties2 );
+    CleanupStack::PushL( message2 );                                             //+13
+    
+    // Test StorePropertiesL in between create and commit. This is no supported
+    // for uncommitted messages.
+    TRAPD( err, message2->StorePropertiesL() );
+    // Test StorePropertyL in between create and commit.
+    TRAPD( err1, message2->StorePropertyL( 0 ) );
+    
+    CheckCondition( _L("StoreProperties failed as expected. Count=2"),
+        err==KErrNotFound && err1==KErrNotFound );    
+    message2->CommitL();
+    
+    iLog->Log( _L("Case %d: Create message in different folders/mailboxes"), iCaseId++ );
+    CMsgStoreMessage* message3 = mailBox1->CreateMessageL( outbox1Id, *properties2 );
+    CleanupStack::PushL( message3 );                                             //+14
+    message3->CommitL();
+    
+    CMsgStoreMessage* message4 = mailBox1->CreateMessageL( outbox1Id, *properties2 );
+    CleanupStack::PushL( message4 );                                             //+15
+    message4->CommitL();
+    
+    CMsgStoreMessage* message5 = mailBox2->CreateMessageL( inbox2Id, *properties2 );
+    CleanupStack::PushL( message5 );                                             //+16
+    message5->CommitL();
+    
+    CMsgStoreMessage* message6 = mailBox2->CreateMessageL( inbox2Id, *properties2 );
+    CleanupStack::PushL( message6 );                                             //+17
+    message6->CommitL();
+    
+    CMsgStoreMessage* message7 = mailBox2->CreateMessageL( outbox2Id, *properties2 );
+    CleanupStack::PushL( message7 );                                             //+18
+    message7->CommitL();
+    
+    CMsgStoreMessage* message8 = mailBox2->CreateMessageL( outbox2Id, *properties2 );
+    CleanupStack::PushL( message8 );                                             //+19
+    message8->CommitL();
+
+    message1->ReplaceContentL( KTestContent );
+    message2->ReplaceContentL( KTestContent );
+    message3->ReplaceContentL( KTestContent );
+    message4->ReplaceContentL( KTestContent );
+    message5->ReplaceContentL( KTestContent );
+    
+    iLog->Log( _L("  Verify contents of each folder") );
+    
+    expectedIds.AppendL( message1->Id() );
+    expectedIds.AppendL( message2->Id() );
+    VerifyMessageIdsL( *mailBox1, inbox1Id, expectedIds );
+    expectedIds.Reset();
+
+    expectedIds.AppendL( message3->Id() );
+    expectedIds.AppendL( message4->Id() );
+    VerifyMessageIdsL( *mailBox1, outbox1Id, expectedIds );
+    expectedIds.Reset();
+
+    expectedIds.AppendL( message5->Id() );
+    expectedIds.AppendL( message6->Id() );
+    VerifyMessageIdsL( *mailBox2, inbox2Id, expectedIds );
+    expectedIds.Reset();
+    
+    expectedIds.AppendL( message7->Id() );
+    expectedIds.AppendL( message8->Id() );
+    VerifyMessageIdsL( *mailBox2, outbox2Id, expectedIds );
+    expectedIds.Reset();
+
+    //Message counts
+    DoMessageCountsL( *mailBox1 );
+    DoMessageCountsL( *mailBox2 );
+    
+    iLog->Log( _L("Case %d: Move messages"), iCaseId++ );
+    
+    mailBox1->MoveMessageL( message1->Id(), inbox1Id, outbox1Id );
+    mailBox1->MoveMessageL( message2->Id(), inbox1Id, outbox1Id );
+    mailBox2->MoveMessageL( message7->Id(), outbox2Id, inbox2Id );
+    mailBox2->MoveMessageL( message8->Id(), outbox2Id, inbox2Id );
+
+    iLog->Log( _L("  Verify contents of each folder") );
+    
+    VerifyMessageIdsL( *mailBox1, inbox1Id, expectedIds );
+    expectedIds.Reset();
+
+    expectedIds.AppendL( message1->Id() );
+    expectedIds.AppendL( message2->Id() );
+    expectedIds.AppendL( message3->Id() );
+    expectedIds.AppendL( message4->Id() );
+    VerifyMessageIdsL( *mailBox1, outbox1->Id(), expectedIds );
+    expectedIds.Reset();
+
+    VerifyMessageIdsL( *mailBox2, outbox2->Id(), expectedIds );
+    expectedIds.Reset();
+
+    expectedIds.AppendL( message5->Id() );
+    expectedIds.AppendL( message6->Id() );
+    expectedIds.AppendL( message7->Id() );
+    expectedIds.AppendL( message8->Id() );
+    VerifyMessageIdsL( *mailBox2, inbox2->Id(), expectedIds );
+    expectedIds.Reset();
+
+    DoMessageCountsL( *mailBox1 );
+    DoMessageCountsL( *mailBox2 );
+    
+    iLog->Log( _L("Case %d: Delete messages"), iCaseId++ );
+    
+    mailBox1->DeleteMessageL( message1->Id(), outbox1Id );
+    mailBox2->DeleteMessageL( message8->Id(), inbox2Id );
+    
+    iLog->Log( _L("  Verify contents of each folder") );
+    
+    VerifyMessageIdsL( *mailBox1, inbox1Id, expectedIds );
+    expectedIds.Reset();
+    
+    expectedIds.AppendL( message2->Id() );
+    expectedIds.AppendL( message3->Id() );
+    expectedIds.AppendL( message4->Id() );
+    VerifyMessageIdsL( *mailBox1, outbox1->Id(), expectedIds );
+    expectedIds.Reset();
+    
+    VerifyMessageIdsL( *mailBox2, outbox2->Id(), expectedIds );
+    expectedIds.Reset();
+    
+    expectedIds.AppendL( message5->Id() );
+    expectedIds.AppendL( message6->Id() );
+    expectedIds.AppendL( message7->Id() );
+    VerifyMessageIdsL( *mailBox2, inbox2->Id(), expectedIds );
+    expectedIds.Reset();
+    
+    DoMessageCountsL( *mailBox1 );
+    DoMessageCountsL( *mailBox2 );
+
+    iLog->Log( _L("Case %d: Copy message"), iCaseId++ );
+    
+    TMsgStoreId newId = mailBox1->CopyMessageL( message3->Id(), outbox1->Id(), inbox1->Id() );
+    
+    iLog->Log( _L("  Delete all other messages") );
+    
+    mailBox1->DeleteMessageL( message2->Id(), outbox1->Id() );
+    mailBox1->DeleteMessageL( message3->Id(), outbox1->Id() );
+    mailBox1->DeleteMessageL( message4->Id(), outbox1->Id() );
+    mailBox2->DeleteMessageL( message5->Id(), inbox2->Id() );
+    mailBox2->DeleteMessageL( message6->Id(), inbox2->Id() );
+    mailBox2->DeleteMessageL( message7->Id(), inbox2->Id() );
+
+    iLog->Log( _L("  Verify contents of each folder") );
+    
+    expectedIds.AppendL( newId );
+    VerifyMessageIdsL( *mailBox1, inbox1->Id(), expectedIds );
+    expectedIds.Reset();
+
+    VerifyMessageIdsL( *mailBox1, outbox1->Id(), expectedIds );
+    VerifyMessageIdsL( *mailBox2, inbox2->Id(), expectedIds );
+    VerifyMessageIdsL( *mailBox2, outbox2->Id(), expectedIds );
+
+    iLog->Log( _L("  Fetch copied message") );
+    
+    CMsgStoreMessage* newMessage = mailBox1->FetchMessageL( newId, inbox1->Id() );
+    
+    iLog->Log( _L("  Verify properties and content") );
+    
+    ComparePropertiesL( *newMessage, *properties2 );
+
+    TBuf8<1000> contentBuf;
+    newMessage->FetchContentToBufferL( contentBuf );
+    CheckCondition( _L("content matches"), contentBuf.Compare( KTestContent ) == 0  );
+    
+    delete newMessage;
+    
+    iLog->Log( _L("Case %d: Message Commit"), iCaseId++ );
+    
+    CMsgStoreMessage* msg1 = mailBox1->CreateMessageL( inbox1Id, *properties );
+    CleanupStack::PushL( msg1 );                                                    //+20
+    msg1->ReplaceContentL( _L8("CONTENT1") );           
+    TInt result = KErrNone;
+    TRAP( result, mailBox1->FetchMessageL( msg1->Id(), inbox1Id ) );            
+    CheckCondition( _L("uncommitted message not found"), result == KErrNotFound );          
+    
+    CMsgStoreMessagePart* part1 = msg1->AddChildPartL( *properties );
+    part1->AppendToContentL( _L8("CONTENT2") );         
+//  TRAP( result, msg1->ChildPartL( part1->Id() ) );
+//  CheckCondition( _L("uncommitted message not found"), result == KErrNotFound );          
+    
+    _LIT( KFilename, "C:\\test_content.txt" );
+    _LIT8( KContent, "THIS IS THE CONTENT FOR THIS TEST" );
+    RFs   fs;
+    User::LeaveIfError( fs.Connect() );
+    RFile file;
+    User::LeaveIfError( file.Replace( fs, KFilename, EFileWrite ) );
+    file.Write( KContent );
+    file.Close();
+    fs.Close();
+
+//  CMsgStoreMessagePart* part2 = msg1->AddChildPartL( *properties );
+//  part2->ReplaceContentWithFileL( KFilename );
+//  TRAP( result, tmpPart = msg1->ChildPartL( part2->Id() ) );
+//  CheckCondition( _L("uncommitted message not found"), result == KErrNotFound );                              
+    
+    msg1->CommitL();
+    iLog->Log( _L("  Message committed") );
+    
+    TMsgStoreId message1Id = msg1->Id();
+    
+    iLog->Log( _L("Case %d: Fetch message in a specific folder"), iCaseId++ );
+    message2 = mailBox1->FetchMessageL( message1Id, inbox1->Id() );
+    ComparePropertiesL( *message2, *properties );
+    delete message2;
+    
+    iLog->Log( _L("Case %d: Fetch message in an unknown folder"), iCaseId++ );
+    message2 = mailBox1->FetchMessageL( message1Id, KMsgStoreInvalidId );
+    ComparePropertiesL( *message2, *properties );
+    
+    iLog->Log( _L("  Verify contents") );
+    
+    TBuf8<100> tmpBuf;
+    message2->FetchContentToBufferL( tmpBuf );
+    CheckCondition( _L("content fetched"), tmpBuf.Compare(_L8("CONTENT1")) == 0 );                              
+    
+    CMsgStoreMessagePart* part3 = msg1->ChildPartL( part1->Id() );
+    ComparePropertiesL( *part3, *properties );
+
+    part3->FetchContentToBufferL( tmpBuf );
+    CheckCondition( _L("content fetched"), tmpBuf.Compare(_L8("CONTENT2")) == 0 );                              
+    
+    delete part1;
+//    delete part2;
+    delete part3;
+    delete message2;
+    
+    // OUT OF MEMORY ERROR PATH TESTS
+
+    iLog->Log( _L("Case %d: Error - Out of memory"), iCaseId++ );
+    for( TInt i = 0; i < 4; i++ )
+        {        
+        SimulateLowDiskSpaceL( i );
+        TRAP( result, mailBox1->CopyMessageL( message1Id, inbox1Id, outbox1Id ) );
+        CheckCondition( _L("out of memory"), result == KErrNoMemory );
+        }
+        
+    // ERROR PATH TESTS
+    
+    // Nonexistent message/folder or wrong folder
+
+    iLog->Log( _L("Case %d: Error - Delete nonexistent message"), iCaseId++ );
+
+    TRAP( result, mailBox1->DeleteMessageL( message1Id, outbox1Id ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );                              
+
+    iLog->Log( _L("Case %d: Error - Move nonexistent message"), iCaseId++ );
+    
+    TRAP( result, mailBox1->MoveMessageL( message1Id, outbox1Id, inbox1Id ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );
+    
+//    __LOG_WRITE_INFO( "Replace content for nonexistent message." )
+
+//  TRAP( result, message1->ReplaceContentL( _L8("CONTENT") ) );
+//  CheckCondition( _L("not found"), result == KErrNotFound );
+    
+    iLog->Log( _L("Case %d: Error - ReplaceContentWithFileL for nonexistent message"), iCaseId++ );
+
+    TRAP( result, message1->ReplaceContentWithFileL( KFilename ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );
+    
+    iLog->Log( _L("Case %d: Error - Append to content for nonexistent message"), iCaseId++ );
+
+    TRAP( result, message1->AppendToContentL( _L8("CONTENT") ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );
+    
+    iLog->Log( _L("Case %d: Error - ContentLengthL for nonexistent message"), iCaseId++ );
+
+    TRAP( result, message1->ContentLengthL() );
+    CheckCondition( _L("not found"), result == KErrNotFound );
+    
+    iLog->Log( _L("Case %d: Error - FetchContentToBufferL for nonexistent message"), iCaseId++ );
+
+    TRAP( result, message1->FetchContentToBufferL( contentBuf ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );
+    
+    iLog->Log( _L("Case %d: Error - FetchContentToFileL for nonexistent message"), iCaseId++ );
+
+    TRAP( result, message1->FetchContentToFileL( KFilename ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );
+    
+    CMsgStoreMessage* msg3 = mailBox1->CreateMessageL( inbox1Id, *properties );
+    CleanupStack::PushL( msg3 );                                                 //+21
+    msg3->CommitL();
+
+    iLog->Log( _L("Case %d: Error - Delete message from wrong folder"), iCaseId++ );
+
+    TRAP( result, mailBox1->DeleteMessageL( msg3->Id(), outbox1Id ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );                              
+
+    iLog->Log( _L("Case %d: Error - Move message from wrong folder"), iCaseId++ );
+
+    TRAP( result, mailBox1->MoveMessageL( msg3->Id(), outbox1Id, inbox1Id ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );                              
+
+    iLog->Log( _L("Case %d: Error - Move message from nonexistent folder"), iCaseId++ );
+
+    TRAP( result, mailBox1->MoveMessageL( msg3->Id(), inbox1Id, inbox1Id + 50 ) ); 
+    CheckCondition( _L("not found"), result == KErrNotFound );                              
+
+    iLog->Log( _L("Case %d: Error - Create message in nonexistent folder"), iCaseId++ );
+
+    TRAP( result,
+        CMsgStoreMessage* msg = mailBox1->CreateMessageL( inbox1Id + 50, *properties );
+        CleanupStack::PushL( msg );
+        msg->CommitL();
+        CleanupStack::PopAndDestroy( msg );
+    );
+    CheckCondition( _L("not found"), result == KErrNotFound );                              
+
+    // Content file not found
+    iLog->Log( _L("Case %d: Error - ReplaceContentWithFileL with nonexistent file"), iCaseId++ );
+    
+    TRAP( result, msg3->ReplaceContentWithFileL( _L("c:\\some_nonexistent_file.txt") ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );
+
+    TMsgStoreId messageId = msg3->Id(); 
+
+    iLog->Log( _L("Case %d: Error - Commit message into deleted folder"), iCaseId++ );
+
+    TMsgStoreId folderId = mailBox1->CreateFolderL( inbox1Id, *properties );
+    CMsgStoreMessage* msg4 = mailBox1->CreateMessageL( folderId, *properties ); 
+    CleanupStack::PushL( msg4 );                                                 //+22
+    mailBox1->DeleteFolderL( folderId );    
+    TRAP( result, msg4->CommitL() );
+    CheckCondition( _L("not found"), result == KErrNotFound );                              
+
+    // Wrong types
+
+    iLog->Log( _L("Case %d: Error - Create message with invalid type for folder"), iCaseId++ );
+
+    TRAP( result, mailBox1->CreateMessageL( messageId, *properties ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+
+    iLog->Log( _L("Case %d: Error - Delete message with invalid type for message"), iCaseId++ );
+
+    TRAP( result, mailBox1->DeleteMessageL( folderId, folderId ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+
+    iLog->Log( _L("Case %d: Error - Delete message with invalid type for folder"), iCaseId++ );
+
+    TRAP( result, mailBox1->DeleteMessageL( messageId, messageId ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+
+    iLog->Log( _L("Case %d: Error - Move message with invalid type for message"), iCaseId++ );
+
+    TRAP( result, mailBox1->MoveMessageL( folderId, folderId, folderId ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+
+    iLog->Log( _L("Case %d: Error - Move message with invalid type for source folder"), iCaseId++ );
+
+    TRAP( result, mailBox1->MoveMessageL( messageId, messageId, folderId ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+
+    iLog->Log( _L("Case %d: Error - Move message with invalid type for destination folder"), iCaseId++ );
+
+    TRAP( result, mailBox1->MoveMessageL( messageId, folderId, messageId ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+
+    iLog->Log( _L("Case %d: Error - Fetch message with invalid type for message"), iCaseId++ );
+
+    TRAP( result, mailBox1->FetchMessageL( folderId, folderId ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+
+    CleanupStack::PopAndDestroy( 22 );
+    
+    //we are done 
+    return ETrue;
+    }
+
+void CMessageTests::VerifyMessageIdsL( CMsgStoreMailBox& aMailBox, TMsgStoreId aFolderId, RArray<TMsgStoreId>& expectedIds )
+    {   
+    iLog->Log( _L(" >> VerifyMessageIdsL") );
+            
+    RArray<TMsgStoreId> ids;
+    
+    aMailBox.MessageIdsL( aFolderId, ids );
+
+    TBool passed = (ids.Count() == expectedIds.Count() );
+    
+    for( TInt i = 0; i < ids.Count(); i++ )
+        {
+        TBool found = EFalse;
+        for ( TInt j = 0; j < expectedIds.Count() && !found; j++ )
+            {
+            found = (ids[i] == expectedIds[j]);
+            }
+        passed = passed && found;               
+        }
+    
+    if( !passed )
+        {
+        for( TInt i = 0; i < expectedIds.Count(); i++ )
+            {                   
+            iLog->Log( _L("  expected=%i"), expectedIds[i] );
+            }
+        for( TInt i = 0; i < ids.Count(); i++ )
+            {                   
+            iLog->Log( _L("  found=%i"), ids[i] );
+            }               
+        }
+    
+    TBuf<30> text;
+    text.Format( _L("%i ids matched"), ids.Count() );
+    CheckCondition( text, passed );         
+    
+    ids.Close();
+    
+    iLog->Log( _L(" << VerifyMessageIdsL") );
+    }
+                
+
+void CMessageTests::DoMessageCountsL( CMsgStoreMailBox& aMailBox )
+    {
+    iLog->Log( _L("  Message counts") );
+    
+    TUint totalCount, unreadCount;
+    aMailBox.TotalMessageCountsL( totalCount, unreadCount );
+    iLog->Log( _L("  mb=%u total=%u, unread=%u"), aMailBox.Id(), totalCount, unreadCount );
+
+    RPointerArray<CMsgStoreFolder> folders; 
+    aMailBox.FoldersL( folders );
+    
+    for ( TInt i = 0 ; i < folders.Count() ; i++ )
+        {
+        aMailBox.MessageCountsL( folders[i]->Id(), totalCount, unreadCount );
+        iLog->Log( _L("  folder=%u total=%u, unread=%u"), folders[i]->Id(), totalCount, unreadCount );
+        }
+
+    folders.ResetAndDestroy();
+    }
+
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/MruTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,260 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+//#include <BAUTILS.H>
+#include "MruTests.h"
+//#include <ismsgstorepropertykeys.h>
+#include "messagestoreclientserver.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CMruTests* CMruTests::NewL( CStifLogger* aLog )
+    {
+    CMruTests* self = new(ELeave) CMruTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CMruTests::CMruTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CMruTests::~CMruTests()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CMruTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CMruTests::ExecuteL()
+    {
+    LogHeader( _L("MRU") );
+    
+    CMsgStoreAccount* account1 = CMsgStoreAccount::NewL(1234, _L("Account 1") );
+    CleanupStack::PushL( account1 );                                            //+1
+    
+    CMsgStoreAccount* account2 = CMsgStoreAccount::NewL(1234, _L("") );
+    CleanupStack::PushL( account2 );                                            //+2
+    
+    CMsgStoreAccount* account3 = CMsgStoreAccount::NewL(5678, _L("Account 3") );
+    CleanupStack::PushL( account3 );                                            //+3
+    
+    CMsgStoreMailBox* mailBox1 = iMsgStore->CreateAccountL( *account1 );
+    CleanupStack::PushL( mailBox1 );                                            //+4
+    
+    CMsgStoreMailBox* mailBox2 = iMsgStore->CreateAccountL( *account2 );
+    CleanupStack::PushL( mailBox2 );                                            //+5
+    
+    CMsgStoreMailBox* mailBox3 = iMsgStore->CreateAccountL( *account3 );
+    CleanupStack::PushL( mailBox3 );                                            //+6
+
+    iLog->Log( _L("Case %d: Calling MruAddressesL() on empty mailbox"), iCaseId++ );
+    RPointerArray<CMsgStoreAddress> expectedArray;
+    CompareMruArraysL( mailBox2, expectedArray );
+    
+    RPointerArray<CMsgStoreAddress> inputArray;
+    
+    TBuf<100> addrBuf;
+    TBuf<100> nameBuf;
+    
+    for ( TInt i = 0 ; i < 20 ; i++ )
+        {
+        addrBuf.Format(_L("name%d@nok%d.com"), i, i );
+        nameBuf.Format(_L("Fname%d LName%d"), i, i );
+        if ( i == 3 || i == 6 )
+            {
+            nameBuf.Copy( KNullDesC );
+            }
+        CMsgStoreAddress* address = CMsgStoreAddress::NewL( addrBuf, nameBuf );
+        inputArray.Append( address );
+        expectedArray.Append( address );
+        }
+    
+    TRAPD( err, mailBox1->AddMruAddressesL( inputArray ) );
+    CheckCondition( _L("AddMruAddressesL() ok"), err == KErrNone );
+    
+    CompareMruArraysL( mailBox1, expectedArray );
+    
+    inputArray.Reset();  //do not destroy because the memory is also in the expectedArray
+   
+    iLog->Log( _L("Case %d: Add more address to the top of MRU address list"), iCaseId++ );
+    for ( TInt i = 0 ; i < 20 ; i++ )
+        {
+        addrBuf.Format(_L("new name%d@nok%d.com"), i, i );
+        nameBuf.Format(_L("new Fname%d LName%d"), i, i );
+        if ( i == 3 || i == 7 )
+            {
+            nameBuf.Copy( KNullDesC );
+            }
+        CMsgStoreAddress* address = CMsgStoreAddress::NewL( addrBuf, nameBuf );
+        inputArray.Append( address );
+        //add the new addresss to the top of the array in the correct order
+        expectedArray.Insert( address, i );
+        }
+    
+    iLog->Log( _L("Case %d: Calling AddMruAddressesL()"), iCaseId++ );
+    TRAP( err, mailBox1->AddMruAddressesL( inputArray ) );
+    CheckCondition( _L("AddMruAddressesL() ok"), err == KErrNone );
+    
+    CompareMruArraysL( mailBox1, expectedArray );
+    
+    iLog->Log( _L("Case %d: Promoting some address to top and add some to the top"), iCaseId++ );
+    inputArray.Reset();
+    for ( TInt i = 0 ; i < expectedArray.Count() ; i += 3 )
+        {
+        CMsgStoreAddress* address = expectedArray[i];
+        inputArray.Insert( address, 0 );
+        expectedArray.Remove(i);
+        expectedArray.Insert( address, 0 );
+        }
+    for ( TInt i = 40 ; i < 43 ; i++ )
+        {
+        addrBuf.Format(_L("new name%d@nok%d.com"), i, i );
+        nameBuf.Format(_L("new Fname%d LName%d"), i, i );
+        CMsgStoreAddress* address = CMsgStoreAddress::NewL( addrBuf, nameBuf );
+        inputArray.Insert(address, 5);
+        expectedArray.Insert(address, 5);
+        }
+    TRAP( err, mailBox1->AddMruAddressesL( inputArray ) );
+    CheckCondition( _L("AddMruAddressesL() ok"), err == KErrNone );
+    
+    CompareMruArraysL( mailBox1, expectedArray );
+    
+    TInt newMaxCount=30;
+    iLog->Log( _L("Case %d: Change the MaxMruAddressCount"), iCaseId++ );
+    iMsgStore->SetMaxMruAddressCountL( newMaxCount );
+    while( expectedArray.Count() > newMaxCount )
+        {
+        CMsgStoreAddress* address = expectedArray[newMaxCount];
+        expectedArray.Remove(newMaxCount);
+        delete address;
+        }
+    CompareMruArraysL( mailBox1, expectedArray );
+
+    inputArray.Reset();
+    
+    iLog->Log( _L("Case %d: Add some more to make sure only %d are returned"), iCaseId++ );
+    for ( int i = 0 ; i < 10 ; i++ )
+        {
+        addrBuf.Format(_L("newer name%d@nok%d.com"), i, i );
+        nameBuf.Format(_L("newer Fname%d LName%d"), i, i );
+        CMsgStoreAddress* address = CMsgStoreAddress::NewL( addrBuf, nameBuf );
+        inputArray.Insert(address, 0);
+        expectedArray.Insert(address, 0);
+        }
+    while( expectedArray.Count() > newMaxCount )
+        {
+        CMsgStoreAddress* address = expectedArray[newMaxCount];
+        expectedArray.Remove(newMaxCount);
+        delete address;
+        }
+    
+    TRAP( err, mailBox1->AddMruAddressesL( inputArray ) );
+    CheckCondition( _L("AddMruAddressesL() ok"), err == KErrNone );
+    
+    CompareMruArraysL( mailBox1, expectedArray );
+    
+    //__LOG_WRITE_INFO("Test Dynamic Encryption")
+    //TRAP( err, iMsgStore->EnableEncryptionL() );
+    //CheckCondition( _L("EnableEncryption() should return KErrNone or KErrAlreadyExists() ok"), err == KErrNone || err == KErrAlreadyExists);
+    //if ( err == KErrAlreadyExists )
+    //    {
+        //encryption may be still going on, make sure it's complete before calling DisableEncryption()
+    //    WaitUntilEncryptDecryptCompleteL( EMsgStoreESEncrypting, mailBox1 );
+        
+    //    __LOG_WRITE_INFO("Store is encrypted, decrypt it")
+    //    iMsgStore->DisableEncryptionL();
+    //    __LOG_WRITE_INFO("Wait for decryption to complete")
+    //    WaitUntilEncryptDecryptCompleteL( EMsgStoreESDecrypting, mailBox1 );
+    //    }
+    //else
+    //    {
+    //    __LOG_WRITE_INFO("Wait for encryption to complete")
+    //    WaitUntilEncryptDecryptCompleteL( EMsgStoreESEncrypting, mailBox1 );
+    //    }
+    
+    //__LOG_WRITE_INFO("Comparing results")
+    //CompareMruArraysL( mailBox1, expectedArray );
+    
+    //add a few more address to see if it works when encryption is turned on
+
+    inputArray.Reset();
+    
+    CleanupStack::PopAndDestroy( 6 );
+    
+    //we are done 
+    return ETrue;
+    }
+
+void CMruTests::CompareMruArraysL( CMsgStoreMailBox* aMailBox, RPointerArray<CMsgStoreAddress>& aExpected )
+    {
+    iLog->Log(_L("  >> CompareMruArraysL") );
+    
+    RPointerArray<CMsgStoreAddress> results;
+    TRAPD(err, aMailBox->MruAddressesL( results ) );
+    CheckCondition( _L("MruAddressesL() ok"), err == KErrNone );
+
+    CheckCondition( _L("same counts"), aExpected.Count() == results.Count() );
+    
+    TInt count = aExpected.Count();
+    
+    iLog->Log( _L("  comparing %d addresses"), count);
+    
+    for ( TInt i = 0 ; i < count  ; i++ )
+        {
+        CMsgStoreAddress* addr1 = aExpected[i];
+        CMsgStoreAddress* addr2 = results[i];
+        iLog->Log( _L("  i=%d, addr=%S, dispName=%S"), i, &addr2->EmailAddress(), &addr2->DisplayName() );
+        if ( addr1->EmailAddress() != addr2->EmailAddress() )
+            {
+            iLog->Log( _L("  Different email address found!! index=%d addr1=%S, addr2=%S"), i, &addr1->EmailAddress(), &addr2->EmailAddress() );
+            User::Leave( KErrNotFound );
+            }
+        if ( addr1->DisplayName() != addr2->DisplayName() )
+            {
+            iLog->Log( _L("  Different display name found!! index=%d name1=%S, name2=%S"), i, &addr1->DisplayName(), &addr2->DisplayName() );
+            User::Leave( KErrNotFound );
+            }
+        }
+    
+    results.ResetAndDestroy();
+    
+    iLog->Log(_L("  addresses all match!") );
+    
+    iLog->Log(_L("  << CompareMruArraysL") );
+    
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/ObserverTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,840 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <connect/sbdefs.h>
+#include <e32property.h>
+#include "ObserverTests.h"
+//#include <ismsgstorepropertykeys.h>
+#include "messagestoreclientserver.h"
+
+const TInt32 KOwner1 = 1234;
+const TInt32 KOwner2 = 5678;
+
+_LIT( KAccount1, "my account 1");
+_LIT( KAccount2, "my account 2");
+
+//PointSec related tests. Must match ImsPointsecMonitor.h
+// KPsUidPointsec
+// The Pointsec status as defined by TPointsecStatus
+#if 0
+const TUint KUidPointsecStatus = { 0x102070e3 };
+#endif
+
+enum TPointsecStatus
+    {
+    EPointsecRecognizerStarted = 1,
+    EPointsecInitializing,
+    EPointsecLocked,
+    EPointsecUnlocked,
+    EPointSecUnknown,              //Do not know what 5 means, ignore it for now
+    EPointSecEncryptionStarting,   //We received this while PointSec says "Encrypting Files"
+                                   //encryption is done, we received EPointSecUnlocked
+    EPointsecNotStarted = -1
+    };
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CObserverTests* CObserverTests::NewL( CStifLogger* aLog )
+    {
+    CObserverTests* self = new(ELeave) CObserverTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CObserverTests::CObserverTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CObserverTests::~CObserverTests()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CObserverTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CObserverTests::ExecuteL()
+    {
+    LogHeader( _L("Observer") );
+    
+    CMsgStore* session1 = CMsgStore::NewL();
+    CleanupStack::PushL( session1 );                                            //+1
+    CMsgStore* session2 = CMsgStore::NewL();
+    CleanupStack::PushL( session2 );                                            //+2
+
+    StartRecordingObserverEvents();         
+
+    session1->AddObserverL( this );
+    session2->AddObserverL( this );
+    
+    TObserverEvent         event;
+    RArray<TObserverEvent> expectedEvents;
+
+    iLog->Log( _L("Case %d: Create Account events"), iCaseId++ );
+    
+    CMsgStoreAccount* account1 = CMsgStoreAccount::NewLC( KOwner1, KAccount1 ); //+3
+    CMsgStoreMailBox* mailBox1 = session1->CreateAccountL( *account1 );
+    CleanupStack::PushL( mailBox1 );                                            //+4
+    
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreAccountCreated;
+    event.iType        = KMsgStoreInvalidId;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = KOwner1;
+    event.iParentId    = KMsgStoreInvalidId;
+    event.iOtherId     = KMsgStoreInvalidId;    
+    event.iName.Copy( KAccount1 );
+    event.iNewName.Copy( KNullDesC );
+    
+    expectedEvents.AppendL( event );
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+    
+    CMsgStoreAccount* account2 = CMsgStoreAccount::NewLC( KOwner2, KAccount2 ); //+5
+    CMsgStoreMailBox* mailBox2 = session2->CreateAccountL( *account2 );
+    CleanupStack::PushL( mailBox2 );                                            //+6
+
+    event.iMailBoxId   = mailBox2->Id();
+    event.iOperation   = EMsgStoreAccountCreated;
+    event.iType        = KMsgStoreInvalidId;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = KOwner2;
+    event.iParentId    = KMsgStoreInvalidId;
+    event.iOtherId     = KMsgStoreInvalidId;    
+    event.iName.Copy( KAccount2 );
+    event.iNewName.Copy( KNullDesC );
+    
+    expectedEvents.AppendL( event );
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+    
+    iLog->Log( _L("Case %d: Rename Account events"), iCaseId++ );
+    
+    session1->RenameAccountL( KOwner1, KAccount1, KAccount2 );
+    
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreAccountRenamed;
+    event.iType        = KMsgStoreInvalidId;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = KOwner1;
+    event.iParentId    = KMsgStoreInvalidId;
+    event.iOtherId     = KMsgStoreInvalidId;    
+    event.iName.Copy( KAccount1 );
+    event.iNewName.Copy( KAccount2 );
+    
+    expectedEvents.AppendL( event );
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+
+    iLog->Log( _L("Case %d: Delete Account events"), iCaseId++ );
+    
+    CMsgStoreAccount* newAccount = CMsgStoreAccount::NewLC( KOwner1, KAccount2 ); //+7
+    session1->DeleteAccountL( *newAccount );
+    
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreAccountDeleted;
+    event.iType        = KMsgStoreInvalidId;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = KOwner1;
+    event.iParentId    = KMsgStoreInvalidId;
+    event.iOtherId     = KMsgStoreInvalidId;    
+    event.iName.Copy( KAccount2 );
+    event.iNewName.Copy( KNullDesC );
+    
+    expectedEvents.AppendL( event );
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+    
+    iLog->Log( _L("Case %d: Create Account events"), iCaseId++ );
+    
+    mailBox1 = session1->CreateAccountL( *account1 );
+    CleanupStack::PushL( mailBox1 );                                            //+8
+    
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreAccountCreated;
+    event.iType        = KMsgStoreInvalidId;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = KOwner1;
+    event.iParentId    = KMsgStoreInvalidId;
+    event.iOtherId     = KMsgStoreInvalidId;    
+    event.iName.Copy( KAccount1 );
+    event.iNewName.Copy( KNullDesC );
+    
+    expectedEvents.AppendL( event );
+    
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+    
+    iLog->Log( _L("Case %d: Mailbox events"), iCaseId++ );
+    
+    mailBox1->AddObserverL( this );
+    
+    //This mailbox should NOT get any notifications for events on mailBox1
+    mailBox2->AddObserverL( this );  
+    
+    ///This mailbox should get notifications for ALL events on mailBox1
+    CMsgStoreMailBox *mailBox1_too = session2->OpenAccountL( *account1 );
+    CleanupStack::PushL( mailBox1_too );                                          //+9
+    mailBox1_too->AddObserverL( this );
+    
+    CMsgStorePropertyContainer* properties = CMsgStorePropertyContainer::NewL();
+    CleanupStack::PushL( properties );                                            //+10
+    _LIT8( KProperty1, "PROP1" );
+    _LIT8( KProperty2, "PROP2" );
+    TestAddIntegerPropertyL( *properties, KProperty1, 1 );
+    TestAddIntegerPropertyL( *properties, KProperty2, 1 );
+    
+    iLog->Log( _L("Case %d: Create Folder events"), iCaseId++ );
+    
+    TMsgStoreId folderId = mailBox1->CreateFolderL( mailBox1->Id(), *properties );
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreAdd;
+    event.iType        = EMsgStoreFolderContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = folderId;
+    event.iParentId    = mailBox1->Id();
+    event.iOtherId     = KMsgStoreRootMailBoxId;    
+    event.iName.SetLength(0);
+    event.iNewName.SetLength(0);
+    
+    expectedEvents.AppendL( event );
+
+    TMsgStoreId folder2Id = mailBox1->CreateFolderL( mailBox1->Id(), *properties );
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreAdd;
+    event.iType        = EMsgStoreFolderContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = folder2Id;
+    event.iParentId    = mailBox1->Id();
+    event.iOtherId     = KMsgStoreRootMailBoxId;    
+    event.iName.SetLength(0);
+    event.iNewName.SetLength(0);
+    
+    expectedEvents.AppendL( event );
+    
+    iLog->Log( _L("Case %d: Create Message events"), iCaseId++ );
+    
+    CMsgStoreMessage* message1 = mailBox1->CreateMessageL( folderId, *properties );
+    CleanupStack::PushL( message1 );                                                //+11
+    message1->CommitL();
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreAdd;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = message1->Id();
+    event.iParentId    = folderId;
+    event.iOtherId     = mailBox1->Id();    
+    event.iName.SetLength(0);
+    event.iNewName.SetLength(0);
+    
+    expectedEvents.AppendL( event );
+
+    TestAddIntegerPropertyL( *properties, KMsgStorePropertyFlags, 12345 );
+
+    CMsgStoreMessage* message2 = mailBox1->CreateMessageL( folderId, *properties );
+    CleanupStack::PushL( message2 );                                                //+12
+    message2->CommitL();
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreAdd;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iFlags       = 12345;
+    event.iId          = message2->Id();
+    event.iParentId    = folderId;
+    event.iOtherId     = mailBox1->Id();    
+    event.iName.SetLength(0);
+    event.iNewName.SetLength(0);
+    expectedEvents.AppendL( event );
+    
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+    
+    iLog->Log( _L("Case %d: Create Part events"), iCaseId++ );
+    
+    CMsgStoreMessagePart* part1 = message1->AddChildPartL( *properties );
+    CleanupStack::PushL( part1 );                                                    //+13
+    
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreAdd;
+    event.iType        = EMsgStorePartContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = part1->Id();
+    event.iParentId    = message1->Id();
+    event.iOtherId     = message1->ParentId();  
+    event.iName.SetLength(0);
+    event.iNewName.SetLength(0);
+    expectedEvents.AppendL( event );
+    
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+    
+    _LIT( KFilename, "C:\\test_content.txt" );
+    _LIT8( KContent, "THIS IS THE CONTENT FOR THIS TEST" );
+    RFs   fs;
+    User::LeaveIfError( fs.Connect() );
+    RFile file;
+    User::LeaveIfError( file.Replace( fs, KFilename, EFileWrite ) );
+    file.Write( KContent );
+    file.Close();
+    fs.Close();
+    
+    part1->ReplaceContentWithFileL( KFilename  );
+
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreUpdateContent;
+    event.iType        = EMsgStorePartContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = part1->Id();
+    event.iParentId    = message1->Id();
+    event.iOtherId     = message1->ParentId();  
+    event.iName.SetLength(0);
+    event.iNewName.SetLength(0);
+    
+    expectedEvents.AppendL( event );    
+    
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+    
+    // Test message creation with operations between CreateMessageL and CommitL.
+    iLog->Log( _L("Case %d: Test operations between CreateMessageL and CommitL"), iCaseId++ );
+
+    TUint index;
+    properties->FindProperty( KMsgStorePropertyFlags, index );
+    TestUpdateIntegerPropertyL( *properties, index, 99999 );
+    
+    CMsgStoreMessage* message3 = mailBox1->CreateMessageL( folderId, *properties );
+    CleanupStack::PushL( message3 );                                                      //+14
+    message3->ReplaceContentL( _L8("CONTENT") );
+    CMsgStoreMessagePart* part3 = message3->AddChildPartL( *properties );
+    part3->ReplaceContentL( _L8("NEW CONTENT" ) );
+    part3->AppendToContentL( _L8("MORE CONTENT" ) );
+    part3->ReplaceContentWithFileL( KFilename );
+    message3->CommitL();
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreAdd;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iFlags       = 99999;
+    event.iId          = message3->Id();
+    event.iParentId    = folderId;
+    event.iOtherId     = mailBox1->Id();    
+    event.iName.SetLength(0);
+    event.iNewName.SetLength(0);
+    expectedEvents.AppendL( event );
+    delete part3;
+
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+    
+    iLog->Log( _L("Case %d: Move events"), iCaseId++ );
+    
+    mailBox1->MoveMessageL( message1->Id(), folderId, folder2Id );          
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreMove;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = message1->Id();
+    event.iParentId    = folderId;
+    event.iOtherId     = folder2Id; 
+    expectedEvents.AppendL( event );
+        
+    mailBox1->MoveMessageL( message1->Id(), folder2Id, folderId );
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreMove;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iId          = message1->Id();
+    event.iParentId    = folder2Id;
+    event.iOtherId     = folderId;  
+    expectedEvents.AppendL( event );
+        
+    mailBox1->MoveMessageL( message3->Id(), folderId, folder2Id );
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreMove;
+    event.iFlags       = 99999;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iId          = message3->Id();
+    event.iParentId    = folderId;
+    event.iOtherId     = folder2Id; 
+    expectedEvents.AppendL( event );
+        
+    mailBox1->MoveMessageL( message3->Id(), folder2Id, folderId );
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreMove;
+    event.iFlags       = 99999;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iId          = message3->Id();
+    event.iParentId    = folder2Id;
+    event.iOtherId     = folderId;  
+    expectedEvents.AppendL( event );
+        
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+    
+    iLog->Log( _L("Case %d: Update properties events"), iCaseId++ );
+    
+    message1->StorePropertiesL();           
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreUpdateProperties;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = message1->Id();
+    event.iParentId    = folderId;
+    event.iOtherId     = mailBox1->Id();    
+    expectedEvents.AppendL( event );
+        
+    message2->StorePropertyL( 0 );          
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreUpdateProperties;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iFlags       = 12345;
+    event.iId          = message2->Id();
+    event.iParentId    = folderId;
+    event.iOtherId     = mailBox1->Id();    
+    expectedEvents.AppendL( event );
+    
+    CMsgStoreFolder* folder = mailBox1->FolderL( folderId );    
+    CleanupStack::PushL( folder );                                               //+15
+    folder->StorePropertiesL();         
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreUpdateProperties;
+    event.iType        = EMsgStoreFolderContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = folderId;
+    event.iParentId    = mailBox1->Id();
+    event.iOtherId     = KMsgStoreRootMailBoxId;    
+    expectedEvents.AppendL( event );                
+        
+    folder->StorePropertyL( 0 );            
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreUpdateProperties;
+    event.iType        = EMsgStoreFolderContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = folderId;
+    event.iParentId    = mailBox1->Id();
+    event.iOtherId     = KMsgStoreRootMailBoxId;    
+    expectedEvents.AppendL( event );                
+        
+    part1->StorePropertiesL();          
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreUpdateProperties;
+    event.iType        = EMsgStorePartContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = part1->Id();
+    event.iParentId    = message1->Id();
+    event.iOtherId     = folderId;  
+    expectedEvents.AppendL( event );
+    
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+    
+    iLog->Log( _L("Case %d: Update content events"), iCaseId++ );
+    
+    part1->AppendToContentL( _L8("SOME MORE CONTENT") );                            
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreUpdateContent;
+    event.iType        = EMsgStorePartContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = part1->Id();
+    event.iParentId    = message1->Id();
+    event.iOtherId     = folderId;  
+    expectedEvents.AppendL( event );
+        
+    message1->ReplaceContentL( _L8("NEW CONTENT") );                            
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreUpdateContent;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = message1->Id();
+    event.iParentId    = folderId;
+    event.iOtherId     = mailBox1->Id();    
+    expectedEvents.AppendL( event );
+        
+    message2->ReplaceContentWithFileL( KFilename );                         
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreUpdateContent;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = message2->Id();
+    event.iParentId    = folderId;
+    event.iOtherId     = mailBox1->Id();    
+    expectedEvents.AppendL( event );
+        
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+    
+    iLog->Log( _L("Case %d: Remove content events"), iCaseId++ );
+    
+    part1->RemoveContentL();
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreRemoveContent;
+    event.iType        = EMsgStorePartContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = part1->Id();
+    event.iParentId    = message1->Id();
+    event.iOtherId     = folderId;  
+    expectedEvents.AppendL( event );
+        
+    message2->RemoveContentL();                         
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreRemoveContent;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = message2->Id();
+    event.iParentId    = folderId;
+    event.iOtherId     = mailBox1->Id();    
+    expectedEvents.AppendL( event );
+        
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+        
+    iLog->Log( _L("Case %d: Copy events"), iCaseId++ );
+    
+    TMsgStoreId copyId = mailBox1_too->CopyMessageL( message1->Id(), folderId, folder2Id );
+
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreAdd;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = copyId;
+    event.iParentId    = folder2Id;
+    //Per Gypsy UI's request, when copying messages, we now send the original message id
+    // in the aOtherId field of the notification ( MotificationNotify() ). 
+    event.iOtherId     = message1->Id();    
+    expectedEvents.AppendL( event );
+        
+    VerifyRecordedObserverEventsL( EFalse, expectedEvents );            
+            
+    iLog->Log( _L("Case %d: Delete events"), iCaseId++ );
+        
+    mailBox1->DeleteMessageL( message2->Id(), folderId );
+    
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreDelete;
+    event.iType        = EMsgStoreMessageContainer;
+    event.iFlags       = 12345;
+    event.iId          = message2->Id();
+    event.iParentId    = folderId;
+    event.iOtherId     = mailBox1->Id();    
+    
+    expectedEvents.AppendL( event );
+    
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+        
+    message1->RemoveChildPartL( part1->Id() );
+    
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreDelete;
+    event.iType        = EMsgStorePartContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = part1->Id();
+    event.iParentId    = message1->Id();
+    event.iOtherId     = folderId;  
+    expectedEvents.AppendL( event );
+        
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );         
+    
+    mailBox1->DeleteFolderL( folderId );
+        
+    event.iMailBoxId   = mailBox1->Id();
+    event.iOperation   = EMsgStoreDelete;
+    event.iType        = EMsgStoreFolderContainer;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = folderId;
+    event.iParentId    = mailBox1->Id();
+    event.iOtherId     = KMsgStoreRootMailBoxId;    
+    expectedEvents.AppendL( event );
+        
+    VerifyRecordedObserverEventsL( ETrue, expectedEvents );
+
+    iLog->Log( _L("Case %d: Database wiped system event"), iCaseId++ );
+            
+    session1->WipeEverythingL();
+    
+    // one per each session         
+    event.iMailBoxId   = -1;
+    event.iOperation   = EMsgStoreDatabaseWiped;
+    event.iType        = -1;
+    event.iFlags       = (TUint32)-1;
+    event.iId          = -1;
+    event.iParentId    = -1;
+    event.iOtherId     = -1;
+    
+    expectedEvents.AppendL( event );
+    expectedEvents.AppendL( event );
+
+    VerifyRecordedObserverEventsL( EFalse, expectedEvents );            
+    
+    iLog->Log( _L("Case %d: Backup/restore system events"), iCaseId++ );
+
+    TriggerBackupRestoreEventL( conn::EBURBackupFull );
+
+    // one per each session         
+    event.iMailBoxId   = -1;
+    event.iOperation   = EMsgStoreBackupOrRestoreInProgress;
+    event.iType        = -1;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = -1;
+    event.iParentId    = -1;
+    event.iOtherId     = -1;    
+    
+    expectedEvents.AppendL( event );
+    expectedEvents.AppendL( event );
+
+    VerifyRecordedObserverEventsL( EFalse, expectedEvents );            
+    
+    
+    TriggerBackupRestoreEventL( 0 );
+
+    // one per each session         
+    event.iOperation   = EMsgStoreBackupOrRestoreCompleted;
+    expectedEvents.AppendL( event );
+    expectedEvents.AppendL( event );
+
+    VerifyRecordedObserverEventsL( EFalse, expectedEvents );            
+        
+    iLog->Log( _L("Case %d: PointSec system lock events"), iCaseId++ );
+
+    TriggerPointSecEventL( ETrue );
+
+    // one per each session         
+    event.iMailBoxId   = -1;
+    event.iOperation   = EMsgStorePointSecLockStarted;
+    event.iType        = -1;
+    event.iFlags       = KMsgStoreFlagsNotFound;
+    event.iId          = -1;
+    event.iParentId    = -1;
+    event.iOtherId     = -1;    
+    
+    expectedEvents.AppendL( event );
+    expectedEvents.AppendL( event );
+
+    VerifyRecordedObserverEventsL( EFalse, expectedEvents );            
+    
+    TriggerPointSecEventL( EFalse );
+
+    // one per each session         
+    event.iOperation   = EMsgStorePointSecLockEnded;
+    expectedEvents.AppendL( event );
+    expectedEvents.AppendL( event );
+
+    VerifyRecordedObserverEventsL( EFalse, expectedEvents );            
+        
+    
+    //Begin PointSec
+#if 0    
+    TInt rc = RProperty::Define( KPsUidPointsec, KUidPointsecStatus, RProperty::EInt );
+    rc = RProperty::Set( KPsUidPointsec, KUidPointsecStatus, EPointsecLocked );
+    event.iOperation   = EMsgStorePointSecLockStarted;
+    expectedEvents.AppendL( event );
+    expectedEvents.AppendL( event );
+
+    VerifyRecordedObserverEventsL( EFalse, expectedEvents );
+    
+    rc = RProperty::Set( KPsUidPointsec, KUidPointsecStatus, EPointsecUnlocked );
+    event.iOperation   = EMsgStorePointSecLockEnded;
+    expectedEvents.AppendL( event );
+    expectedEvents.AppendL( event );
+
+    VerifyRecordedObserverEventsL( EFalse, expectedEvents );
+#endif    
+    //End PointSec
+    
+    StopRecordingObserverEvents();
+    
+    
+    iLog->Log( _L("Case %d: Remove Mailbox Observers"), iCaseId++ );
+    mailBox1->RemoveObserverL( this );
+    mailBox2->RemoveObserverL( this );
+    
+    iLog->Log( _L("Case %d: Large number of observers on large number of sessions"), iCaseId++ );
+
+    RPointerArray<CMsgStore> sessions;
+    
+    for( TInt i = 0; i < 20; i++ )
+        {
+        CMsgStore* session = CMsgStore::NewL();
+        session->AddObserverL( this );
+        
+        sessions.AppendL( session );        
+        }
+
+    session1->WipeEverythingL();
+    
+    for( TInt i = 0; i < 20; i++ )
+        {
+        sessions[i]->RemoveObserverL( this );
+        sessions[i]->AddObserverL( this );        
+        }
+
+    session1->WipeEverythingL();
+    
+    sessions.ResetAndDestroy();
+    
+    CleanupStack::PopAndDestroy( 15 );
+    
+    //we are done 
+    return ETrue;
+    }
+
+
+void CObserverTests::StartRecordingObserverEvents()
+    {
+    iRecordEvents = ETrue;
+    }
+
+void CObserverTests::StopRecordingObserverEvents()
+    {
+    iRecordEvents = ETrue;
+    iRecordedEvents.Reset();
+    }
+
+void CObserverTests::VerifyRecordedObserverEventsL( TBool aVerifyOrder, RArray<TObserverEvent>& aExpectedEvents )
+    {
+    iLog->Log( _L("  >> VerifyRecordedObserverEventsL") );
+    
+    // Allow all events to propagate.
+    TInt loopCount = 0;
+    while( loopCount < 1000 && iRecordedEvents.Count() < aExpectedEvents.Count() )
+        {
+        Yield( 10000 );
+        loopCount++;
+        }
+
+    TBool matched = ( aExpectedEvents.Count() == iRecordedEvents.Count() );
+    
+    CheckCondition( _L("correct number of recorded events"), matched );
+    
+    TObserverEvent expectedEvent;
+    TObserverEvent recordedEvent;
+    
+    while( matched && (aExpectedEvents.Count() > 0 ) )
+        {
+        expectedEvent = aExpectedEvents[0];
+        
+        TUint highestCompareIndex = 0; 
+        if( !aVerifyOrder )
+            {
+            highestCompareIndex = iRecordedEvents.Count() - 1;
+            }
+            
+        TBool found = EFalse;
+        TUint compareIndex = 0;
+        while( !found && compareIndex <= highestCompareIndex )
+            {
+            recordedEvent = iRecordedEvents[compareIndex];
+            
+            if (recordedEvent.iMailBoxId   == expectedEvent.iMailBoxId &&
+                recordedEvent.iOperation   == expectedEvent.iOperation &&
+                recordedEvent.iType        == expectedEvent.iType      &&
+                recordedEvent.iFlags       == expectedEvent.iFlags     &&
+                recordedEvent.iId          == expectedEvent.iId        &&
+                recordedEvent.iParentId    == expectedEvent.iParentId  &&
+                recordedEvent.iOtherId     == expectedEvent.iOtherId   &&
+                recordedEvent.iName        == expectedEvent.iName      &&
+                recordedEvent.iNewName     == expectedEvent.iNewName )
+                {
+                found = ETrue;
+                iRecordedEvents.Remove( compareIndex );
+                }
+            else
+                {                   
+                compareIndex++;                     
+                } // end if
+            }
+        aExpectedEvents.Remove( 0 );
+        
+        matched = (matched && found);
+        }
+    
+    aExpectedEvents.Reset();
+    
+    CheckCondition( _L("recorded events matched"), matched );
+    
+    iLog->Log( _L("  << VerifyRecordedObserverEventsL") );
+    }
+
+void CObserverTests::ModificationNotify( TMsgStoreId aMailBoxId, TMsgStoreOperation aOperation, TMsgStoreContainerType aType, TUint32 aFlags, TMsgStoreId aId, TMsgStoreId aParentId, TMsgStoreId aOtherId )
+    {
+    iLog->Log( _L("  ModificationNotify %i"), iRecordedEvents.Count()+1 );
+    
+    if( iRecordEvents )
+        {
+        TObserverEvent event;
+        event.iMailBoxId   = aMailBoxId;
+        event.iOperation   = aOperation;
+        event.iType        = aType;
+        event.iFlags       = aFlags;
+        event.iId          = aId;
+        event.iParentId    = aParentId;
+        event.iOtherId     = aOtherId;
+        event.iName.SetLength( 0 );
+        event.iNewName.SetLength( 0 );
+        
+        iRecordedEvents.Append( event );
+        }
+    }
+        
+void CObserverTests::SystemEventNotify( TMsgStoreSystemEvent aEvent )
+    {
+    iLog->Log( _L("  >> SystemEventNotify") );
+    
+    if( iRecordEvents )
+        {
+        TObserverEvent event;
+        event.iMailBoxId   = -1;
+        event.iOperation   = aEvent;
+        event.iType        = -1;
+        event.iFlags       = KMsgStoreFlagsNotFound;
+        event.iId          = -1;
+        event.iParentId    = -1;
+        event.iOtherId     = -1;
+        event.iName.SetLength( 0 );
+        event.iNewName.SetLength( 0 );
+        
+        iRecordedEvents.Append( event );
+        }
+    
+    iLog->Log( _L("  << SystemEventNotify") );
+    }
+void CObserverTests::AccountEventNotify( TMsgStoreAccountEvent aEvent, TInt32 aOwnerId, const TDesC& aName, const TDesC& aNewName, TMsgStoreId aMailboxId )
+    {
+    iLog->Log( _L("  >> AccountEventNotify") );
+    if( iRecordEvents )
+        {
+        TObserverEvent event;
+        event.iMailBoxId   = aMailboxId;
+        event.iOperation   = aEvent;
+        event.iType        = KMsgStoreInvalidId;
+        event.iFlags       = KMsgStoreFlagsNotFound;
+        event.iId          = aOwnerId;
+        event.iParentId    = KMsgStoreInvalidId;
+        event.iOtherId     = KMsgStoreInvalidId;
+        event.iName.Copy( aName );
+        event.iNewName.Copy( aNewName );
+        
+        iRecordedEvents.Append( event );
+        }
+    iLog->Log( _L("  << AccountEventNotify") );
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/PartTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,387 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <tz.h>
+#include "PartTests.h"
+//#include <ismsgstorepropertykeys.h>
+#include "messagestoreclientserver.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CPartTests* CPartTests::NewL( CStifLogger* aLog )
+    {
+    CPartTests* self = new(ELeave) CPartTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CPartTests::CPartTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CPartTests::~CPartTests()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CPartTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CPartTests::ExecuteL()
+    {
+    LogHeader( _L("Part") );
+    
+    //account 1
+    CMsgStoreAccount* account1 = CMsgStoreAccount::NewLC( 1234, KNullDesC );   //+1
+    CMsgStoreMailBox* mailBox1 = iMsgStore->CreateAccountL( *account1 );
+    CleanupStack::PushL( mailBox1 );                                           //+2
+
+    CMsgStorePropertyContainer* properties = CMsgStorePropertyContainer::NewL();
+    CleanupStack::PushL( properties );                                              //+3
+    properties->AddPropertyL( _L8("name"), _L("some name") );
+    
+    TMsgStoreId inbox1Id = mailBox1->CreateFolderL( mailBox1->Id(), *properties );
+    CMsgStoreFolder* inbox1 = mailBox1->FolderL( inbox1Id );
+    CleanupStack::PushL( inbox1 );                                              //+4
+    
+    CMsgStoreMessage* message1 = mailBox1->CreateMessageL( inbox1Id, *properties );
+    CleanupStack::PushL( message1 );                                               //+5
+    message1->CommitL();
+    
+    RPointerArray<CMsgStoreMessagePart> parts;
+
+    iLog->Log( _L("Case %d: List parts when no parts yet"), iCaseId++ );
+    
+    message1->ChildPartsL( parts );
+    CheckCondition( _L("no parts"), parts.Count() == 0 );               
+    parts.ResetAndDestroy();
+
+    iLog->Log( _L("Case %d: Add a part with no content"), iCaseId++ );
+
+    CMsgStoreMessagePart* part = message1->AddChildPartL( *properties );
+    ComparePropertiesL( *part, *properties );
+    CheckCondition( _L("parent ID is correct"), part->ParentId() == message1->Id() );
+    
+    iLog->Log( _L("Case %d: Get ChildPart"), iCaseId++ );
+    
+    CMsgStoreMessagePart* compareMe = message1->ChildPartL( part->Id() );
+    ComparePropertiesL( *part, *compareMe );
+    CheckCondition( _L("parent ID is correct"), compareMe->ParentId() == message1->Id() );
+    
+    iLog->Log( _L("Case %d: Add a child part to a child child part"), iCaseId++ );
+    
+    CMsgStoreMessagePart* grandChild = part->AddChildPartL( *properties );
+    ComparePropertiesL( *grandChild, *properties );
+    CheckCondition( _L("grandChild's parent ID is correct"), grandChild->ParentId() == part->Id() );
+    
+    iLog->Log( _L("Case %d: Testing ChildPartL(aRecursive=ETrue)"), iCaseId++ );
+    delete compareMe;
+    compareMe = message1->ChildPartL( grandChild->Id(), ETrue );
+    ComparePropertiesL( *grandChild, *compareMe );
+    CheckCondition( _L("GrandChild's parent ID is correct"), compareMe->ParentId() == part->Id() );
+    delete compareMe;
+    
+    iLog->Log( _L("Case %d: Testing RemoveChildPartL(aRecursive=ETrue)"), iCaseId++ );
+    message1->RemoveChildPartL( grandChild->Id(), ETrue );
+    delete grandChild;    
+
+    iLog->Log( _L("  List parts") );
+    
+    message1->ChildPartsL( parts );
+    CheckCondition( _L("1 part"), parts.Count() == 1 );             
+    ComparePropertiesL( *parts[0], *properties );
+    CheckCondition( _L("parent ID is correct"), parts[0]->ParentId() == message1->Id() );
+    parts.ResetAndDestroy();
+    
+    TMsgStoreId partId = part->Id();
+    delete part;
+    
+    iLog->Log( _L("Case %d: Add an attachment with content using file path"), iCaseId++ );
+
+    _LIT( KFilename, "C:\\test_content.txt" );
+    _LIT8( KContent, "THIS IS THE CONTENT FOR THIS TEST" );
+    RFs   fs;
+    User::LeaveIfError( fs.Connect() );
+    RFile file;
+    User::LeaveIfError( file.Replace( fs, KFilename, EFileWrite ) );
+    file.Write( KContent );
+    file.Close();
+    fs.Close();
+
+    part = message1->AddChildPartL( *properties, KFilename );    //new part
+    
+    iLog->Log( _L("  List parts") );
+    
+    message1->ChildPartsL( parts );
+    CheckCondition( _L("2 parts"), parts.Count() == 2 );                
+
+    compareMe = NULL;
+    if( parts[0]->Id() == part->Id() )
+        {
+        compareMe = parts[0];               
+        }
+    else if( parts[1]->Id() == part->Id() )
+        {
+        compareMe = parts[1];                               
+        } // end if
+        
+    CheckCondition( _L("found"), compareMe != NULL );
+    CheckCondition( _L("parent ID is correct"), compareMe->ParentId() == message1->Id() );
+
+    iLog->Log( _L("  Verify content") );
+    
+    TBuf8<100> contentBuf;
+    compareMe->FetchContentToBufferL( contentBuf );
+    CheckCondition( _L("content matches"), contentBuf.Compare( KContent ) == 0 );
+
+    parts.ResetAndDestroy();
+    delete part;
+    
+    iLog->Log( _L("Case %d: Add an attachment with content using file handle"), iCaseId++ );
+    RFs   fs2;
+    User::LeaveIfError( fs2.Connect() );
+    RFile file2; 
+    fs2.ShareProtected();
+    User::LeaveIfError( file2.Open( fs2, KFilename, EFileRead ) );
+
+    part = message1->AddChildPartL( *properties, file2 );    //new part
+    
+    file2.Close();
+    fs2.Close();
+    
+    iLog->Log( _L("  List parts") );
+    
+    message1->ChildPartsL( parts );
+    CheckCondition( _L("2 parts"), parts.Count() == 3 );                
+
+    compareMe = NULL;
+    for (TInt i=0; i < parts.Count() ; i++ )
+        {
+        if( parts[i]->Id() == part->Id() )
+            {
+            compareMe = parts[i];
+            break;
+            }
+        }
+        
+    CheckCondition( _L("found"), compareMe != NULL );
+    CheckCondition( _L("parent ID is correct"), compareMe->ParentId() == message1->Id() );
+
+    iLog->Log( _L("  Verify content") );
+    
+    compareMe->FetchContentToBufferL( contentBuf );
+    CheckCondition( _L("content matches"), contentBuf.Compare( KContent ) == 0 );
+
+    parts.ResetAndDestroy();
+    
+    
+    iLog->Log( _L("Case %d: Copy part"), iCaseId++ );
+    
+    CMsgStoreMessage* message2 = mailBox1->CreateMessageL( inbox1Id, *properties );
+    CleanupStack::PushL( message2 );                                                //+6
+    message2->CommitL();
+    
+    TMsgStoreId newId = message1->CopyChildPartL( part->Id(), message2->Id() );
+
+    CMsgStoreMessagePart* newpart = message2->ChildPartL( newId );
+    ComparePropertiesL( *part, *newpart );
+
+    contentBuf.SetLength( 0 );
+    newpart->FetchContentToBufferL( contentBuf );
+    CheckCondition( _L("content matches"), contentBuf.Compare( KContent ) == 0 );
+    
+    delete newpart;
+    
+    iLog->Log( _L("Case %d: Remove parts"), iCaseId++ );
+    message1->RemoveChildPartL( part->Id() );
+    message1->RemoveChildPartL( partId );
+    
+    message1->ChildPartsL( parts );
+        
+    CheckCondition( _L("one part left"), parts.Count() == 1 );              
+    parts.ResetAndDestroy();
+    
+    delete part;
+    
+    iLog->Log( _L("Case %d: Nested parts"), iCaseId++ );
+    // put an attachment back
+    CMsgStorePropertyContainer* nestedProps = CMsgStorePropertyContainer::NewL();
+    nestedProps->AddPropertyL(_L8("prop1"), _L("value 1") );
+    
+    part = message1->AddChildPartL( *properties );          
+    CMsgStoreMessagePart* nestedPart = part->AddChildPartL( *nestedProps );
+    nestedPart->ReplaceContentL( KContent );
+    
+    CMsgStoreMessagePart* comparePart = part->ChildPartL( nestedPart->Id() );
+    ComparePropertiesL( *comparePart, *nestedProps );
+    CheckCondition( _L("content length matches"), comparePart->ContentLengthL() == nestedPart->ContentLengthL() );
+    comparePart->FetchContentToBufferL( contentBuf );
+    CheckCondition( _L("content matches"), contentBuf == KContent );
+    
+    delete comparePart;
+    
+    iLog->Log( _L("Case %d: Fetch nested part from mailBox object"), iCaseId++ );
+    
+    CMsgStoreWritablePropertyContainer* container = mailBox1->FetchPropertiesL( nestedPart->Id() );
+    ComparePropertiesL( *container, *nestedPart );
+    delete container;
+    
+    iLog->Log( _L("Case %d: Fetch part from mailBox object"), iCaseId++ );
+    
+    container = mailBox1->FetchPropertiesL( part->Id() );
+    ComparePropertiesL( *container, *part );
+    delete container;
+    
+    iLog->Log( _L("Case %d: Fetch message from mailBox object"), iCaseId++ );
+    
+    container = mailBox1->FetchPropertiesL( message1->Id() );
+    ComparePropertiesL( *container, *message1 );
+    delete container;
+    
+    iLog->Log( _L("Case %d: Fetch folder from mailBox object"), iCaseId++ );
+    
+    container = mailBox1->FetchPropertiesL( inbox1->Id() );
+    ComparePropertiesL( *container, *inbox1 );
+    delete container;
+    
+    iLog->Log( _L("Case %d: ContainerTypeById"), iCaseId++ );
+    
+    TMsgStoreContainerType contentType = mailBox1->ContainerTypeById( part->Id() );
+    CheckCondition( _L("container type is Part"), contentType == EMsgStorePartContainer );
+    
+    contentType = mailBox1->ContainerTypeById( message1->Id() );
+    CheckCondition( _L("container type is Message"), contentType == EMsgStoreMessageContainer );
+    
+    contentType = mailBox1->ContainerTypeById( inbox1->Id() );
+    CheckCondition( _L("container type is Folder"), contentType == EMsgStoreFolderContainer );
+    
+    contentType = mailBox1->ContainerTypeById( mailBox1->Id() );
+    CheckCondition( _L("container type is Mailbox"), contentType == EMsgStoreMailboxContainer );
+    
+    /******************************************************************
+     * (end of) Testing of the new CMsgStoreMailBox methods: FetchPropertiesL() and
+     * ContentTypeBuId() requested by the Mail for Exchange team
+     * ****************************************************************/
+    
+    iLog->Log( _L("Case %d: Add a message as an attachment (embedded msg)"), iCaseId++ );
+    
+    CMsgStoreMessage* nestedMsg = part->AddChildMessageL( *nestedProps );
+    nestedMsg->ReplaceContentL( KContent );
+    comparePart = part->ChildPartL( nestedMsg->Id() );
+    ComparePropertiesL( *nestedMsg, *comparePart );
+    comparePart->FetchContentToBufferL( contentBuf );
+    CheckCondition( _L("content matches"), contentBuf == KContent );
+    CheckCondition( _L("IsEmbeddedMessage()"), comparePart->IsEmbeddedMessageL() );
+
+    iLog->Log( _L("Case %d: CommitL() not supported for embedded msgs"), iCaseId++ );
+    //it should be safe to cast it to message
+    CMsgStoreMessage* castedMessage = static_cast<CMsgStoreMessage*>(comparePart);
+    //CommitL() should leave with KErrNotSupported
+    TRAPD( err, castedMessage->CommitL() );
+    CheckCondition( _L("CommitL() not supported for embedded msgs"), err = KErrNotSupported );
+    
+    iLog->Log( _L("Case %d: AbandonL() not supported for embedded msgs"), iCaseId++ );
+    TRAP( err, castedMessage->AbandonL() );
+    CheckCondition( _L("AbandonL() not supported for embedded msgs"), err = KErrNotSupported );
+    
+    RPointerArray<CMsgStoreMessagePart> nestedParts;
+    part->ChildPartsL( nestedParts );
+    CheckCondition( _L("2 nested parts"), nestedParts.Count() == 2 );
+    
+    nestedParts.ResetAndDestroy();
+    delete comparePart;
+    delete nestedMsg;
+    delete nestedPart;
+    delete part;
+    delete nestedProps;
+    
+    // ERROR PATH TESTS
+    
+    // put an attachment back
+    part = message1->AddChildPartL( *properties );          
+    CleanupStack::PushL( part );                                                //+7
+    
+    iLog->Log( _L("Case %d: Error - ChildPartL for invalid part ID"), iCaseId++ );
+    
+    TRAPD( result, message1->ChildPartL( EMsgStorePartBits | 50 ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );
+    
+    iLog->Log( _L("Case %d: Error - ChildPartL for wrong message"), iCaseId++ );
+    
+    TRAP( result, message2->ChildPartL( part->Id() ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );
+    
+    iLog->Log( _L("Case %d: Error - AddAttachmentL (content) with nonexistent file"), iCaseId++ );
+    
+    CMsgStoreMessagePart* tempPart = message2->AddChildPartL( *properties );
+    TRAP( result, tempPart->ReplaceContentWithFileL( _L("C:\\some_nonexistent_file.txt") ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );
+    delete tempPart;
+
+    iLog->Log( _L("Case %d: Error - RemoveChildPartL for invalid part ID"), iCaseId++ );
+    
+    TRAP( result, message2->RemoveChildPartL( part->Id() + 50  ) );
+    CheckCondition( _L("not found"), result == KErrNotFound );
+    
+    // wrong parameter types
+
+    iLog->Log( _L("Case %d: Error - ChildPartL with wrong type for part"), iCaseId++ );
+    
+    TRAP( result, message2->ChildPartL( message1->Id() ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+    
+    iLog->Log( _L("Case %d: Error - RemoveChildPartL with wrong type for part"), iCaseId++ );
+    
+    TRAP( result, message2->RemoveChildPartL( message1->Id() ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+    
+    // OUT OF MEMORY ERROR PATH TESTS
+
+    iLog->Log( _L("Case %d: Error - Out of memory"), iCaseId++ );
+    for( TInt i = 0; i < 1; i++ )
+        {        
+        SimulateLowDiskSpaceL( i );
+        TRAP( result, message1->AddChildPartL( *properties ) );
+        CheckCondition( _L("out of memory"), result == KErrNoMemory );
+        }
+        
+    CleanupStack::PopAndDestroy( 7 );
+    
+    //we are done 
+    return ETrue;
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/PropertyTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,413 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <tz.h>
+#include "PropertyTests.h"
+#include <msgstoreapi.h>
+//#include <ismsgstorepropertykeys.h>
+#include "messagestoreclientserver.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CPropertyTests* CPropertyTests::NewL( CStifLogger* aLog )
+    {
+    CPropertyTests* self = new(ELeave) CPropertyTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CPropertyTests::CPropertyTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CPropertyTests::~CPropertyTests()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CPropertyTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CPropertyTests::ExecuteL()
+    {
+    LogHeader( _L("Property") );
+    
+    iLog->Log( _L("Case %d: Manipulation of properties in RAM."), iCaseId++ );
+    
+    CMsgStorePropertyContainer* properties = CMsgStorePropertyContainer::NewL();
+
+    CheckCondition( _L("default IDs"), properties->Id() == KMsgStoreInvalidId && properties->ParentId() == KMsgStoreInvalidId );
+
+    // "quick" properties
+    iLog->Log( _L("Case %d: Add integer properties"), iCaseId++ );
+    TUint flagsIndex = TestAddIntegerPropertyL( *properties, KMsgStorePropertyFlags, EMsgStoreFlag_Read_Locally );
+    TestAddIntegerPropertyL( *properties, KMsgStorePropertyReplyBy, 1 );
+    TestAddIntegerPropertyL( *properties, KMsgStorePropertyCompletedAt, 2 );
+    TestAddIntegerPropertyL( *properties, KMsgStorePropertyReceivedAt, 3, ETrue );
+    
+    // integer
+    TUint intIndex1 = TestAddIntegerPropertyL( *properties, _L8("TOTALCONTENTSIZE"), 1000 );
+    TUint intIndex2 = TestAddIntegerPropertyL( *properties, _L8("RETRIEVEMORE"), ETrue );
+    TUint intIndex3 = TestAddIntegerPropertyL( *properties, _L8("ABC"), 1500 );
+
+    // bool
+    iLog->Log( _L("Case %d: Add boolean properties"), iCaseId++ );
+    TUint boolIndex1 = TestAddBoolPropertyL( *properties, _L8("BOOL1"), ETrue );
+    TUint boolIndex2 = TestAddBoolPropertyL( *properties, _L8("BOOL2"), EFalse, ETrue );
+    
+    
+    // 8-bit descriptor
+    iLog->Log( _L("Case %d: Add 8-bit descriptor properties"), iCaseId++ );
+    TUint stringIndex1 = TestAddDes8PropertyL( *properties, _L8("SOME OTHER PROPERTY"), _L8("SOME VALUE") );
+    TUint stringIndex2 = TestAddDes8PropertyL( *properties, _L8("YET ANOTHER PROPERTY"), _L8("YET ANOTHER VALUE"), ETrue );
+    
+    // 16-bit descriptor            
+    iLog->Log( _L("Case %d: Add 16-bit descriptor properties"), iCaseId++ );
+    TUint stringIndex3 = TestAddDesPropertyL( *properties, _L8("XYZ"), _L("sdfhsdgjg") );
+    TestAddDesPropertyL( *properties, _L8("XYZ1"), _L("sdfhsdgjg1"), ETrue );
+
+    // container            
+    iLog->Log( _L("Case %d: Add container properties"), iCaseId++ );
+    CMsgStorePropertyContainer* subproperties = CMsgStorePropertyContainer::NewL();
+    TestAddIntegerPropertyL( *subproperties, _L8("TOTALCONTENTSIZE"), 1000 );
+    TestAddDes8PropertyL( *subproperties, _L8("SOME OTHER PROPERTY"), _L8("SOME VALUE") );          
+    TestAddDesPropertyL( *subproperties, _L8("XYZ"), _L("sdfhsdgjg") );
+    
+    TUint containerIndex1 = TestAddContainerPropertyL( *properties, _L8("container 1"), *subproperties );
+    TUint containerIndex2 = TestAddContainerPropertyL( *properties, _L8("container 2"), *subproperties );
+    
+    delete subproperties;
+    
+    // time
+    iLog->Log( _L("Case %d: Add TTime properties"), iCaseId++ );
+    TTime time1;
+    time1.HomeTime();
+    TTime time2( 1000 );
+    
+    TUint timeIndex1 = TestAddTimePropertyL( *properties, _L8("TIME PROPERTY 1"), time1);
+    TUint timeIndex2 = TestAddTimePropertyL( *properties, _L8("TIME PROPERTY 2"), time2);
+    
+    //Address
+    iLog->Log( _L("Case %d: Add Address properties"), iCaseId++ );
+    RMsgStoreAddress address1, address2;
+    CleanupClosePushL( address1 );
+    CleanupClosePushL( address2 );
+    address1.iEmailAddress.Create(_L("myAddres1@nokia.com"));
+    address1.iDisplayName.Create(_L("My Name 1"));
+    address2.iEmailAddress.Create(_L("myAddres2@nokia.com"));
+    address2.iDisplayName.Create(_L("My Name 2"));
+    
+    TUint addressIndex1 = TestAddAddressPropertyL( *properties, _L8("ADDRESS PROPERTY 1"), address1);
+    TUint addressIndex2 = TestAddAddressPropertyL( *properties, _L8("ADDRESS PROPERTY 2"), address2);
+    
+    CleanupStack::PopAndDestroy(2);
+    
+    // Test long property names and values.
+    iLog->Log( _L("Case %d: Test long property names and values"), iCaseId++ );
+    TBuf8<255> longName;
+    RBuf8 longValue;
+    longValue.CreateL( 65535 );  // boundary case
+    
+    longName.Fill( 'N', 255 );
+    longValue.Fill( 'V', 65535 );
+    
+    TUint longIndex = TestAddDes8PropertyL( *properties, longName, longValue );
+    
+    longValue.Close();
+    
+    // Test shrinking the size of a property from long to short.
+    iLog->Log( _L("Case %d: Test shrinking the size of a property from long to short"), iCaseId++ );
+    TestUpdateDes8PropertyL( *properties, longIndex, _L8("ASDFGHJKL:") );   
+    
+    // Test growing short property back to long property.
+    iLog->Log( _L("Case %d: Test growing short property back to long property"), iCaseId++ );
+    longValue.CreateL( 70000 );
+    longValue.Fill( 'V', 70000 );
+    
+    TestUpdateDes8PropertyL( *properties, longIndex, longValue );   
+    
+    longValue.Close();      
+    
+    // Test update.         
+    subproperties = CMsgStorePropertyContainer::NewL();
+    TestAddIntegerPropertyL( *subproperties, _L8("X"), 1 );
+    
+    iLog->Log( _L("Case %d: Update boolean property"), iCaseId++ );
+    TestUpdateBoolPropertyL( *properties, boolIndex1, EFalse );
+    TestUpdateBoolPropertyL( *properties, boolIndex1, ETrue, ETrue );
+    
+    iLog->Log( _L("Case %d: Update integer property"), iCaseId++ );
+    TestUpdateIntegerPropertyL( *properties, intIndex1, 987 );
+    TestUpdateIntegerPropertyL( *properties, intIndex1, 986, ETrue );
+    
+    iLog->Log( _L("Case %d: Update 8-bit descriptor property"), iCaseId++ );
+    TestUpdateDes8PropertyL( *properties, stringIndex1, _L8("ASDFGHJKL:") );
+    TestUpdateDes8PropertyL( *properties, stringIndex1, _L8("ASDFGHJKL:1"), ETrue );
+    
+    iLog->Log( _L("Case %d: Update 16-bit descriptor property"), iCaseId++ );
+    TestUpdateDesPropertyL( *properties, stringIndex3, _L(",mxcn,mxbxcbmbnxv") );
+    TestUpdateDesPropertyL( *properties, stringIndex3, _L(",mxcn,mxbxcbmbnxv"), ETrue );
+    
+    iLog->Log( _L("Case %d: Update container property"), iCaseId++ );
+    TestUpdateContainerPropertyL( *properties, containerIndex2, *subproperties );
+
+    TestAddIntegerPropertyL( *subproperties, _L8("Y"), 2 );
+    TestUpdateContainerPropertyL( *properties, containerIndex2, *subproperties, ETrue );
+
+    delete subproperties;
+    
+    iLog->Log( _L("Case %d: Update TTime property"), iCaseId++ );
+    time2 = 1000000;
+    TestUpdateTimePropertyL( *properties, timeIndex1, time2 );
+    time2 = 1000000;
+    TestUpdateTimePropertyL( *properties, timeIndex1, time2, ETrue );
+
+    iLog->Log( _L("Case %d: Update address property"), iCaseId++ );
+    RMsgStoreAddress address3;
+    
+    CleanupClosePushL(address3);
+    
+    address3.iDisplayName.Create(_L("new name"));  
+    TestUpdateAddressPropertyL( *properties, addressIndex1, address3 );
+    address3.iEmailAddress.Create( _L("mail@com")); 
+    TestUpdateAddressPropertyL( *properties, addressIndex1, address3, ETrue );
+    
+    CleanupStack::PopAndDestroy( &address3 );
+                
+    // Test remove.
+    iLog->Log( _L("Case %d: Remove property"), iCaseId++ );
+    TestRemovePropertyL( *properties, intIndex3 );
+    TestRemovePropertyL( *properties, stringIndex3 );
+    
+    iLog->Log( _L("Case %d: Store properties as a message and verify stored message"), iCaseId++ );
+
+    CMsgStoreAccount* account = CMsgStoreAccount::NewLC(1234, _L("my account") );  //+1
+    CMsgStoreMailBox* mailBox1 = iMsgStore->CreateAccountL( *account );
+    CleanupStack::PushL( mailBox1 );                                               //+2
+    
+    TMsgStoreId folderId = mailBox1->CreateFolderL( mailBox1->Id(), *properties);
+
+    CMsgStoreMessage* message = mailBox1->CreateMessageL( folderId, *properties );
+    CleanupStack::PushL( message );                                               //+3
+    message->CommitL();
+    TMsgStoreId messageId = message->Id();
+    
+    ComparePropertiesL( *message, *properties );
+    CheckCondition( _L("IDs"), message->Id() != KMsgStoreInvalidId && message->ParentId() == folderId );
+
+    // fetch message
+    CMsgStoreMessage* message2 = mailBox1->FetchMessageL( messageId, folderId );
+    CleanupStack::PushL( message2 );                                                //+4
+    ComparePropertiesL( *message2, *message );
+    CheckCondition( _L("IDs"), message2->Id() == message->Id() && message2->ParentId() == message->ParentId() );
+
+    // fetch message without specifying parent ID
+    CMsgStoreMessage* message3 = mailBox1->FetchMessageL( messageId, KMsgStoreInvalidId );
+    CleanupStack::PushL( message3 );                                                //+5
+    ComparePropertiesL( *message3, *message );
+    CheckCondition( _L("IDs"), message3->Id() == message->Id() && message3->ParentId() == message->ParentId() );
+
+    iLog->Log( _L("Case %d: Test FetchPropertiesL"), iCaseId++ );
+    //create another message that has the same properties as message1
+    CMsgStoreMessage* message4 = mailBox1->CreateMessageL( folderId, *properties );
+    CleanupStack::PushL( message4 );                                               //+6
+    message4->CommitL();
+    RArray<TMsgStoreId> ids;
+    ids.Append( message->Id() );
+    ids.Append( message4->Id() );
+    RPointerArray<TDesC8> propNames;
+    _LIT8( KAddProp1, "ADDRESS PROPERTY 1" );
+    _LIT8( KAddProp2, "ADDRESS PROPERTY 2" );
+    propNames.Append( &KAddProp1 );
+    propNames.Append( &KAddProp2 );
+    RPointerArray<CMsgStorePropertyContainer> propArray;
+    mailBox1->FetchPropertiesL( ids, propNames, propArray );
+    CheckCondition( _L("PropertyCounts match"), ids.Count() == propArray.Count() );
+    ComparePropertiesL( *propArray[0], *propArray[1] );
+    ids.Reset();
+    propNames.Reset();
+    propArray.ResetAndDestroy();
+    
+    iLog->Log( _L("Case %d: Update message properties and store"), iCaseId++ );
+    TestAddIntegerPropertyL( *message, _L8("NEW INT PROPERTY"), 135  );         
+    TestAddDes8PropertyL( *message, _L8("NEW STRING PROPERTY"), _L8("NEW VALUE") );
+    TestUpdateIntegerPropertyL( *message, intIndex1, 17475 );
+    TestUpdateDes8PropertyL( *message, stringIndex1, _L8("zxxcvb") );
+    TestRemovePropertyL( *message, intIndex2 );
+    TestRemovePropertyL( *message, stringIndex2 );
+    
+    message->StorePropertiesL();
+
+    // fetch message
+    message2 = mailBox1->FetchMessageL( messageId, folderId );
+    ComparePropertiesL( *message2, *message );
+    CheckCondition( _L("IDs"), message2->Id() == message->Id() && message2->ParentId() == message->ParentId() );
+    delete message2;
+
+    iLog->Log( _L("Case %d: Update individual message property and store"), iCaseId++ );
+    TestUpdateIntegerPropertyL( *message, flagsIndex, 0 );
+
+    message->StorePropertyL( flagsIndex );
+    
+    // fetch message
+    message2 = mailBox1->FetchMessageL( messageId, folderId );
+    ComparePropertiesL( *message2, *message );
+    CheckCondition( _L("IDs"), message2->Id() == message->Id() && message2->ParentId() == message->ParentId() );
+    delete message2;
+
+    iLog->Log( _L("Case %d: Add property and store individually"), iCaseId++ );
+    TMsgStoreId newPropertyIndex = TestAddIntegerPropertyL( *message, _L8("A NEW INTEGER PROPERTY"), 50 );
+
+    message->StorePropertyL( newPropertyIndex );
+    
+    // fetch message
+    message2 = mailBox1->FetchMessageL( messageId, folderId );
+    ComparePropertiesL( *message2, *message );
+    CheckCondition( _L("IDs"), message2->Id() == message->Id() && message2->ParentId() == message->ParentId() );
+    delete message2;
+
+    iLog->Log( _L("Case %d: Update individual message property 64K value to short value"), iCaseId++ );
+    message->FindProperty( longName, longIndex );
+    
+    TestUpdateDes8PropertyL( *message, longIndex, _L8("SHORT VALUE AGAIN") );
+
+    message->StorePropertyL( longIndex );
+    
+    // fetch message
+    message2 = mailBox1->FetchMessageL( messageId, folderId );
+    ComparePropertiesL( *message2, *message );
+    CheckCondition( _L("IDs"), message2->Id() == message->Id() && message2->ParentId() == message->ParentId() );
+    delete message2;
+
+    iLog->Log( _L("Case %d: Update individual message property from short value to >64K value"), iCaseId++ );
+    longValue.CreateL( 70000 );
+    longValue.Fill( 'V', 70000 );
+    TestUpdateDes8PropertyL( *message, longIndex, longValue );
+
+    message->StorePropertyL( longIndex );
+    
+    longValue.Close();      
+
+    // fetch message
+    message2 = mailBox1->FetchMessageL( messageId, folderId );
+    ComparePropertiesL( *message2, *message );
+    CheckCondition( _L("IDs"), message2->Id() == message->Id() && message2->ParentId() == message->ParentId() );
+    delete message2;
+
+    // ERROR PATH TESTS
+    iLog->Log( _L("Case %d: Error - Find property that does not exist"), iCaseId++ );
+    TUint index = 500;
+    TBool found = properties->FindProperty( _L8("SOME PROPERTY THAT DOES NOT EXIST"), index );
+    CheckCondition( _L("property not found"), !found && (index == 500) );
+
+    iLog->Log( _L("Case %d: Error - PropertyNameL with an invalid index"), iCaseId++ );
+    TRAPD( result, properties->PropertyNameL( 5000 ) );
+    CheckCondition( _L("property not found"), result == KErrNotFound );
+
+    iLog->Log( _L("Case %d: Error - PropertyValueDes8L with an invalid index"), iCaseId++ );
+    TRAP( result, properties->PropertyValueDes8L( 5000 ) );
+    CheckCondition( _L("property not found"), result == KErrNotFound );
+
+    iLog->Log( _L("Case %d: Error - PropertyValueUint32L with an invalid index"), iCaseId++ );
+    TRAP( result, properties->PropertyValueUint32L( 5000 ) );
+    CheckCondition( _L("property not found"), result == KErrNotFound );
+
+    iLog->Log( _L("Case %d: Error - UpdatePropertyL (string) with an invalid index"), iCaseId++ );
+    TRAP( result, properties->UpdatePropertyL( 5000, _L8("abc") ) );
+    CheckCondition( _L("property not found"), result == KErrNotFound );
+
+    iLog->Log( _L("Case %d: Error - UpdatePropertyL (integer) with an invalid index"), iCaseId++ );
+    TRAP( result, properties->UpdatePropertyL( 5000, (TUint32)123 ) );
+    CheckCondition( _L("property not found"), result == KErrNotFound );
+
+    iLog->Log( _L("Case %d: Error - UpdatePropertyL (bool) with an invalid index"), iCaseId++ );
+    TRAP( result, properties->UpdatePropertyL( 5000, (TBool)123 ) );
+    CheckCondition( _L("property not found"), result == KErrNotFound );
+
+    iLog->Log( _L("Case %d: Error - RemovePropertyL with an invalid index"), iCaseId++ );
+    TRAP( result, properties->RemovePropertyL( 5000 ) );
+    CheckCondition( _L("property not found"), result == KErrNotFound );
+
+    iLog->Log( _L("Case %d: Error - Fetch message that does not exist"), iCaseId++ );
+    TRAP( result, message2 = mailBox1->FetchMessageL( EMsgStoreMessageBits | 50, folderId ) );
+    CheckCondition( _L("message not found"), result == KErrNotFound );
+    
+    iLog->Log( _L("Case %d: Error - Fetch message exists but is in a different folder"), iCaseId++ );
+    TRAP( result, message2 = mailBox1->FetchMessageL( messageId, folderId + 1 ) );
+    CheckCondition( _L("message not found"), result == KErrNotFound );
+    
+    iLog->Log( _L("Case %d: Error - StoreProperty with an invalid property index"), iCaseId++ );
+    TRAP( result, message->StorePropertyL( 5000 ) );
+    CheckCondition( _L("property not found"), result == KErrNotFound );
+
+    // OUT OF MEMORY ERROR PATH TESTS
+    iLog->Log( _L("Case %d: Error - Out of memory, CreateMessageL"), iCaseId++ );
+    for( TInt i = 0; i < 2; i++ )
+        {        
+        SimulateLowDiskSpaceL( i );
+        TRAP( result,
+            CMsgStoreMessage* msg = mailBox1->CreateMessageL( folderId, *properties );
+            CleanupStack::PushL( msg );
+            msg->CommitL();
+            CleanupStack::PopAndDestroy( msg );
+        );
+        CheckCondition( _L("out of memory"), result == KErrNoMemory );
+        }
+        
+    iLog->Log( _L("Case %d: Error - Out of memory, StorePropertiesL"), iCaseId++ );
+    for( TInt i = 0; i < 2; i++ )
+        {        
+        SimulateLowDiskSpaceL( i );
+        TRAP( result, message->StorePropertiesL() );
+        CheckCondition( _L("out of memory"), result == KErrNoMemory );
+        }
+        
+    iLog->Log( _L("Case %d: Error - Out of memory, StorePropertyL"), iCaseId++ );
+    for( TInt i = 0; i < 2; i++ )
+        {        
+        SimulateLowDiskSpaceL( i );
+        TRAP( result, message->StorePropertyL( 0 ) );
+        CheckCondition( _L("out of memory"), result == KErrNoMemory );
+        }
+    
+    CleanupStack::PopAndDestroy(6);
+    
+    delete properties;
+    
+    //we are done 
+    return ETrue;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/SearchTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,718 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+//#include <BAUTILS.H>
+#include "SearchTests.h"
+//#include <ismsgstorepropertykeys.h>
+//#include "messagestoreclientserver.h"
+
+_LIT(KHigh,   "High");
+_LIT(KNormal, "Normal");
+_LIT(KLow,    "Low");
+
+_LIT(KFollowUp,         "FollowUp");
+_LIT(KFollowUpComplete, "FollowUpComplete");
+_LIT(KNone,             "None");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CSearchTests* CSearchTests::NewL( CStifLogger* aLog )
+    {
+    CSearchTests* self = new(ELeave) CSearchTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CSearchTests::CSearchTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CSearchTests::~CSearchTests()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CSearchTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CSearchTests::ExecuteL()
+    {
+    LogHeader( _L("Search") );
+    
+    //account 1
+    CMsgStoreAccount* account1 = CMsgStoreAccount::NewLC( 1234, KNullDesC );   //+1
+    CMsgStoreMailBox* mailBox1 = iMsgStore->CreateAccountL( *account1 );
+    CleanupStack::PushL( mailBox1 );                                           //+2
+    
+    //NOTE: the CreateRandomMessagesL() only generage string fields with 'A' through 'Z' and 'a' though 'z'.
+    // So to avoid the ramdom message have strings that match the search criteria, the search criteria must
+    // include some non-alphabetical characters, e.g., ' ', '.', etc.
+    _LIT( KDisplayName1, "FName1 LName1" );
+    _LIT( KDisplayName2, "FName2 LName2" );
+    _LIT( KDisplayName3, "FName3 LName3" );
+    _LIT( KAddress1, "email1.addr1@yahoo.com" );
+    _LIT( KAddress2, "email2.addr2@yahoo.com" );
+    _LIT( KAddress3, "email3.addr3@yahoo.com" );
+    _LIT( KSubject1,  "Real subject 1." );
+    _LIT( KSubject2,  "Real subject 2." );
+    _LIT( KSubject3,  "Real subject 3." );
+    _LIT( KContent1, "This is the subject of a message." );
+    _LIT( KContent2, "The quick brown fox jumped over the lazy dog.  Hurray!" );
+    _LIT( KContent3, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()" );
+    
+    CMsgStorePropertyContainer* properties = CMsgStorePropertyContainer::NewL();
+    CleanupStack::PushL( properties );                                          //+3
+    
+    properties->AddPropertyL( _L8("1"), _L("PROPERTY 1") );
+    properties->AddPropertyL( _L8("2"), 12345 );
+    properties->AddPropertyL( _L8("3"), _L8("ANOTHER PROPERTY") );
+    
+    //create 3 folders, but only search 2 of them
+    TMsgStoreId inbox1Id = mailBox1->CreateFolderL( mailBox1->Id(), *properties );
+    TMsgStoreId sentFolderId = mailBox1->CreateFolderL( mailBox1->Id(), *properties );
+    TMsgStoreId deletedFolderId = mailBox1->CreateFolderL( mailBox1->Id(), *properties );
+    
+    //create messages for the 3 folders
+    TInt msgCountPerFolder = 20;
+    
+    CreateRandomMessagesL( mailBox1, inbox1Id, msgCountPerFolder );
+    CreateRandomMessagesL( mailBox1, sentFolderId, msgCountPerFolder );
+    CreateRandomMessagesL( mailBox1, deletedFolderId, msgCountPerFolder );
+    
+    //get message ids for inbox
+    RArray<TMsgStoreId> msgIds;
+    mailBox1->MessageIdsL( inbox1Id, msgIds );
+    RPointerArray<CMsgStoreMessage> inboxMsgs;
+    for ( TInt i = 0 ; i < msgCountPerFolder ; i++ )
+        {
+        inboxMsgs.Append( mailBox1->FetchMessageL( msgIds[i], inbox1Id ) );
+        }
+    msgIds.Reset();
+    
+    //get message ids for sentFolderId
+    mailBox1->MessageIdsL( sentFolderId, msgIds );
+    RPointerArray<CMsgStoreMessage> sentMsgs;
+    for ( TInt i = 0 ; i < msgCountPerFolder ; i++ )
+        {
+        sentMsgs.Append( mailBox1->FetchMessageL( msgIds[i], sentFolderId ) );
+        }
+    msgIds.Reset();
+    
+    //get message ids for deletedFolder
+    mailBox1->MessageIdsL( deletedFolderId, msgIds );
+    RPointerArray<CMsgStoreMessage> deletedMsgs;
+    for ( TInt i = 0 ; i < msgCountPerFolder ; i++ )
+        {
+        deletedMsgs.Append( mailBox1->FetchMessageL( msgIds[i], deletedFolderId ) );
+        }
+    msgIds.Close();
+    
+    TBuf8<500> contentBuf;
+
+    for ( TInt i = 0 ; i < 3 ; i++ )
+        {
+        RPointerArray<CMsgStoreMessage>* msgs;
+        if ( i == 0 )
+            {
+            msgs = &inboxMsgs;
+            }
+        else if ( i == 1 )
+            {
+            msgs = &sentMsgs;
+            }
+        else
+            {
+            msgs = &deletedMsgs;
+            }
+        CopyDesToDes8( KContent1, contentBuf );
+        SetMessageContentL( (*msgs)[0], contentBuf );
+        SetMessageContentL( (*msgs)[3], contentBuf );
+        SetMessageContentL( (*msgs)[4], contentBuf );
+    
+        CopyDesToDes8( KContent2, contentBuf );
+        SetMessageContentL( (*msgs)[1], contentBuf );
+        SetMessageContentL( (*msgs)[6], contentBuf );
+    
+        CopyDesToDes8( KContent3, contentBuf );
+        SetMessageContentL( (*msgs)[2], contentBuf );
+        SetMessageContentL( (*msgs)[5], contentBuf );
+        SetMessageContentL( (*msgs)[7], contentBuf );
+        SetMessageContentL( (*msgs)[8], contentBuf );
+        
+        SetSubjectAndAddressL( (*msgs)[11], KSubject1, KDisplayName1, KAddress1, KMsgStorePropertyTo );
+        SetSubjectAndAddressL( (*msgs)[14], KSubject1, KDisplayName1, KAddress1, KMsgStorePropertyCc );
+        SetSubjectAndAddressL( (*msgs)[17], KSubject1, KDisplayName1, KAddress1, KMsgStorePropertyBcc );
+        
+        SetSubjectAndAddressL( (*msgs)[12], KSubject2, KDisplayName2, KAddress2, KMsgStorePropertyTo );
+        SetSubjectAndAddressL( (*msgs)[15], KSubject2, KDisplayName2, KAddress2, KMsgStorePropertyCc );
+        SetSubjectAndAddressL( (*msgs)[18], KSubject2, KDisplayName2, KAddress2, KMsgStorePropertyBcc );
+        
+        SetSubjectAndAddressL( (*msgs)[13], KSubject3, KDisplayName3, KAddress3, KMsgStorePropertyTo );
+        SetSubjectAndAddressL( (*msgs)[16], KSubject3, KDisplayName3, KAddress3, KMsgStorePropertyCc );
+        //make #19 use name 3 and addr2
+        SetSubjectAndAddressL( (*msgs)[19], KSubject3, KDisplayName3, KAddress2, KMsgStorePropertyBcc );
+        
+        //add 3 TOs to message 10, 3 CCs to msg 13, and 3 BCCs to msg 16
+        RMsgStoreAddress addr;
+        CleanupClosePushL( addr );
+        addr.iDisplayName.Create(100);
+        addr.iEmailAddress.Create(100);
+        
+        addr.iDisplayName.Copy( KDisplayName1 );
+        addr.iEmailAddress.Copy( KAddress1 );
+        (*msgs)[10]->AddPropertyL( KMsgStorePropertyTo, addr ) ;
+        (*msgs)[13]->AddPropertyL( KMsgStorePropertyCc, addr ) ;
+        (*msgs)[16]->AddPropertyL( KMsgStorePropertyBcc, addr ) ;
+        
+        addr.iDisplayName.Copy( KDisplayName2 );
+        addr.iEmailAddress.Copy( KAddress2 );
+        (*msgs)[10]->AddPropertyL( KMsgStorePropertyTo, addr ) ;
+        (*msgs)[13]->AddPropertyL( KMsgStorePropertyCc, addr ) ;
+        (*msgs)[16]->AddPropertyL( KMsgStorePropertyBcc, addr ) ;
+        
+        addr.iDisplayName.Copy( KDisplayName3 );
+        addr.iEmailAddress.Copy( KAddress3 );
+        (*msgs)[10]->AddPropertyL( KMsgStorePropertyTo, addr ) ;
+        (*msgs)[13]->AddPropertyL( KMsgStorePropertyCc, addr ) ;
+        (*msgs)[16]->AddPropertyL( KMsgStorePropertyBcc, addr ) ;
+
+        (*msgs)[10]->StorePropertiesL();
+        (*msgs)[13]->StorePropertiesL();
+        (*msgs)[16]->StorePropertiesL();
+        
+        CleanupStack::PopAndDestroy( &addr );
+        }
+    
+    RArray<TMsgStoreId> expectedMatches;
+
+    RMsgStoreSearchCriteria criteria;
+    CleanupClosePushL( criteria );                                                // +4
+    iSearchCriteria = &criteria;
+    
+    criteria.AddSearchStringL( _L("no match") );
+    criteria.AddSearchStringL( _L("The") );
+    criteria.iSortBy = EMsgStoreSortByReceivedDate;
+    criteria.iSortOrder = EMsgStoreSortDescending;
+    
+    //WMT: test "global search". when no filder id is specified, all folders are searched
+    //search inbox1Id first, than sendFolderId
+    //criteria.AddFolderId( inbox1Id );
+    //criteria.AddFolderId( sentFolderId );
+    
+    criteria.AddResultPropertyL( KMsgStorePropertyReceivedAt );
+    criteria.AddResultPropertyL( KMsgStorePropertyFlags );
+    criteria.AddResultPropertyL( KMsgStorePropertyMessageSizeOnServer );
+    criteria.AddResultPropertyL( KMsgStorePropertyFrom );
+    criteria.AddResultPropertyL( KMsgStorePropertySubject );
+    
+    iLog->Log( _L("Case %d: Search for \"%S\" AND \"%S\", ordered by:%d"), iCaseId++, criteria.SearchStrings()[0], criteria.SearchStrings()[1], criteria.iSortBy );
+
+    mailBox1->SearchL( criteria, *this );            
+    ValidateSearchResults( expectedMatches );
+    
+    //search for "The", using the wild card...
+    criteria.SearchStrings().ResetAndDestroy();
+//    criteria.AddSearchStringL( _L("T?e") );
+    criteria.AddSearchStringL( _L("The ") );  //add a space to avoid random match
+    
+    iLog->Log( _L("Case %d: Search for \"%S\", ordered by:%d"), iCaseId++, criteria.SearchStrings()[0], criteria.iSortBy );
+    
+    expectedMatches.AppendL( inboxMsgs[0]->Id() );
+    expectedMatches.AppendL( inboxMsgs[3]->Id() );
+    expectedMatches.AppendL( inboxMsgs[4]->Id() );
+    expectedMatches.AppendL( inboxMsgs[1]->Id() );
+    expectedMatches.AppendL( inboxMsgs[6]->Id() );
+    expectedMatches.AppendL( sentMsgs[0]->Id() );
+    expectedMatches.AppendL( sentMsgs[3]->Id() );
+    expectedMatches.AppendL( sentMsgs[4]->Id() );
+    expectedMatches.AppendL( sentMsgs[1]->Id() );
+    expectedMatches.AppendL( sentMsgs[6]->Id() );
+    expectedMatches.AppendL( deletedMsgs[0]->Id() );
+    expectedMatches.AppendL( deletedMsgs[3]->Id() );
+    expectedMatches.AppendL( deletedMsgs[4]->Id() );
+    expectedMatches.AppendL( deletedMsgs[1]->Id() );
+    expectedMatches.AppendL( deletedMsgs[6]->Id() );
+    
+    mailBox1->SearchL( criteria, *this );
+    //call validate but ignore extra match that may be generated by the wild card
+    //because the ramdom message may happen to match the wild card
+    ValidateSearchResults( expectedMatches, ETrue );
+    
+    //change the sort order
+    criteria.iSortBy = EMsgStoreSortByFlagStatus;
+    iLog->Log( _L("Case %d: Search for \"%S\", ordered by:%d"), iCaseId++, criteria.SearchStrings()[0], criteria.iSortBy );
+    mailBox1->SearchL( criteria, *this );
+    //should have the same results as previous serach, just different sort order
+    ValidateSearchResults( expectedMatches, ETrue );
+    
+    //change the sort order again
+    criteria.iSortBy = EMsgStoreSortBySize;
+    iLog->Log( _L("Case %d: Search for \"%S\", ordered by:%d"), iCaseId++, criteria.SearchStrings()[0], criteria.iSortBy );
+    mailBox1->SearchL( criteria, *this );
+    //should have the same results as previous serach, just different sort order
+    ValidateSearchResults( expectedMatches, ETrue );
+    
+    expectedMatches.Reset();
+    
+    //search for "HURRAY!"
+    criteria.SearchStrings().ResetAndDestroy();
+    criteria.AddSearchStringL( _L("HURRAY!") );  //added '!' to avoid match random string
+    criteria.iSortBy = EMsgStoreSortBySubject;
+    
+    iLog->Log( _L("Case %d: Search for \"%S\", ordered by:%d"), iCaseId++, criteria.SearchStrings()[0], criteria.iSortBy );
+    
+    expectedMatches.AppendL( inboxMsgs[1]->Id() );
+    expectedMatches.AppendL( inboxMsgs[6]->Id() );
+    expectedMatches.AppendL( sentMsgs[1]->Id() );
+    expectedMatches.AppendL( sentMsgs[6]->Id() );
+    
+    //search inbox1Id first, than sendFolderId
+    criteria.AddFolderId( inbox1Id );
+    criteria.AddFolderId( sentFolderId );
+    
+    mailBox1->SearchL( criteria, *this );
+    ValidateSearchResults( expectedMatches );
+    
+    //change sort order
+    criteria.iSortBy = EMsgStoreSortByUnRead;
+    iLog->Log( _L("Case %d: Search for \"%S\", ordered by:%d"), iCaseId++, criteria.SearchStrings()[0], criteria.iSortBy  );
+    mailBox1->SearchL( criteria, *this );
+    //should have the same results as previous serach, just different sort order
+    ValidateSearchResults( expectedMatches );
+    expectedMatches.Reset();
+    
+    //search for "()"
+    criteria.SearchStrings().ResetAndDestroy();
+    criteria.AddSearchStringL( _L("()") );
+    criteria.iSortBy = EMsgStoreSortBySender;
+    iLog->Log( _L("Case %d: Search for \"%S\", ordered by:%d"), iCaseId++, criteria.SearchStrings()[0], criteria.iSortBy  );
+    
+    expectedMatches.AppendL( inboxMsgs[2]->Id() );
+    expectedMatches.AppendL( inboxMsgs[5]->Id() );
+    expectedMatches.AppendL( inboxMsgs[7]->Id() );
+    expectedMatches.AppendL( inboxMsgs[8]->Id() );
+    expectedMatches.AppendL( sentMsgs[2]->Id() );
+    expectedMatches.AppendL( sentMsgs[5]->Id() );
+    expectedMatches.AppendL( sentMsgs[7]->Id() );
+    expectedMatches.AppendL( sentMsgs[8]->Id() );
+    
+    mailBox1->SearchL( criteria, *this );
+    ValidateSearchResults( expectedMatches );
+
+    //Change the sort order
+    criteria.iSortBy = EMsgStoreSortByPriority;
+    iLog->Log( _L("Case %d: Search for \"%S\", ordered by:%d"), iCaseId++, criteria.SearchStrings()[0], criteria.iSortBy );
+    //should have the same results as previous serach, just different sort order
+    mailBox1->SearchL( criteria, *this );
+    ValidateSearchResults( expectedMatches );
+    
+    //Change the sort order again
+    criteria.iSortBy = EMsgStoreSortByAttachment;
+    iLog->Log( _L("Case %d: Search for \"%S\", ordered by:%d"), iCaseId++, criteria.SearchStrings()[0], criteria.iSortBy );
+    //should have the same results as previous serach, just different sort order
+    mailBox1->SearchL( criteria, *this );
+    ValidateSearchResults( expectedMatches );
+    
+    expectedMatches.Reset();
+    
+    //search subject fields
+    criteria.iSortBy = EMsgStoreSortByReceivedDate;
+    criteria.SearchStrings().ResetAndDestroy();
+    criteria.AddSearchStringL( _L("subject ") );
+    
+    iLog->Log( _L("Case %d: Search for \"%S\", ordered by:%d"), iCaseId++, criteria.SearchStrings()[0], criteria.iSortBy );
+    
+    expectedMatches.AppendL( inboxMsgs[0]->Id() );
+    expectedMatches.AppendL( inboxMsgs[3]->Id() );
+    expectedMatches.AppendL( inboxMsgs[4]->Id() );
+    expectedMatches.AppendL( sentMsgs[0]->Id() );
+    expectedMatches.AppendL( sentMsgs[3]->Id() );
+    expectedMatches.AppendL( sentMsgs[4]->Id() );
+    for (TInt i=11; i<=19; i++)
+        {
+        expectedMatches.AppendL( inboxMsgs[i]->Id() );
+        expectedMatches.AppendL( sentMsgs[i]->Id() );
+        }
+    mailBox1->SearchL( criteria, *this );
+    ValidateSearchResults( expectedMatches );
+    expectedMatches.Reset();
+    
+    //search addresses fields
+    criteria.SearchStrings().ResetAndDestroy();
+    
+    criteria.AddSearchStringL( _L("fname3") );
+    criteria.AddSearchStringL( _L("addr3") );
+    
+    iLog->Log( _L("Case %d: Search for \"%S\" AND \"%S\", ordered by:%d"), iCaseId++, criteria.SearchStrings()[0], criteria.SearchStrings()[1], criteria.iSortBy );
+    
+    expectedMatches.AppendL( inboxMsgs[10]->Id() );
+    expectedMatches.AppendL( inboxMsgs[13]->Id() );
+    expectedMatches.AppendL( inboxMsgs[16]->Id() );
+//    expectedMatches.AppendL( inboxMsgs[19]->Id() );
+    expectedMatches.AppendL( sentMsgs[10]->Id() );
+    expectedMatches.AppendL( sentMsgs[13]->Id() );
+    expectedMatches.AppendL( sentMsgs[16]->Id() );
+//    expectedMatches.AppendL( sentMsgs[19]->Id() );
+    mailBox1->SearchL( criteria, *this );
+    ValidateSearchResults( expectedMatches );
+    expectedMatches.Reset();
+    
+    //search addresses fields
+    criteria.SearchStrings().ResetAndDestroy();
+    criteria.AddSearchStringL( _L("addr2") );
+    
+    iLog->Log( _L("Case %d: Search for \"%S\", ordered by:%d"), iCaseId++, criteria.SearchStrings()[0], criteria.iSortBy );
+    
+    expectedMatches.AppendL( inboxMsgs[12]->Id() );
+    expectedMatches.AppendL( inboxMsgs[15]->Id() );
+    expectedMatches.AppendL( inboxMsgs[18]->Id() );
+    expectedMatches.AppendL( inboxMsgs[10]->Id() );
+    expectedMatches.AppendL( inboxMsgs[13]->Id() );
+    expectedMatches.AppendL( inboxMsgs[16]->Id() );
+    expectedMatches.AppendL( inboxMsgs[19]->Id() );
+    expectedMatches.AppendL( sentMsgs[12]->Id() );
+    expectedMatches.AppendL( sentMsgs[15]->Id() );
+    expectedMatches.AppendL( sentMsgs[18]->Id() );
+    expectedMatches.AppendL( sentMsgs[10]->Id() );
+    expectedMatches.AppendL( sentMsgs[13]->Id() );
+    expectedMatches.AppendL( sentMsgs[16]->Id() );
+    expectedMatches.AppendL( sentMsgs[19]->Id() );
+    mailBox1->SearchL( criteria, *this );
+    ValidateSearchResults( expectedMatches );
+    expectedMatches.Reset();
+    
+    iLog->Log( _L("Case %d: Cancel search"), iCaseId++ );
+
+    criteria.SearchStrings().ResetAndDestroy();
+    criteria.AddSearchStringL( _L("the ") );
+    mailBox1->SearchL( criteria, *this );
+    mailBox1->CancelSearch();
+    for( TInt i = 0; i < 10; i++ )
+        {                
+        Yield( 25000 );
+        }
+    CheckCondition( _L("MatchFound not called"), iMatches.Count() == 0 );
+    CheckCondition( _L("SearchCompleted not called"), !iSearchCompleted );
+    
+    iLog->Log( _L("Case %d: Cancel search during MatchFound callback"), iCaseId++ );
+    
+    iSessionToCancelSearch = mailBox1;
+    criteria.SearchStrings().ResetAndDestroy();
+    criteria.AddSearchStringL( _L("the ") );
+    mailBox1->SearchL( criteria, *this );
+    for( TInt i = 0; i < 10; i++ )
+        {                
+        Yield( 25000 );
+        }
+    CheckCondition( _L("MatchFound not called again"), iMatches.Count() == 1 );
+    CheckCondition( _L("SearchCompleted not called"), !iSearchCompleted );
+    iMatches.Reset();
+    iSessionToCancelSearch = NULL;
+    
+    iLog->Log( _L("Case %d: Large content"), iCaseId++ );
+    
+    _LIT( KFilename, "c:\\content_test.txt" );
+    _LIT( KSearchString, "this is the search string" );     
+    CreateFileL( KFilename, 13000, 'X', KSearchString, 0 );     // beginning of file
+    ReplaceMessageContentWithFileL( inboxMsgs[0], KFilename );
+    CreateFileL( KFilename, 25000, 'X', KSearchString, 15813 ); // middle
+    ReplaceMessageContentWithFileL( inboxMsgs[1], KFilename );
+    CreateFileL( KFilename, 8763, 'X', KSearchString, 8762 );   // end
+    ReplaceMessageContentWithFileL( inboxMsgs[2], KFilename );
+    
+    // THIS CONSTANT SHOULD BE KEPT CONSISTENT WITH THE SEARCH BUFFER SIZE IN CSearchHandler       
+    const TInt KSearchBufferSize = 2500;
+    CreateFileL( KFilename, 5000, 'X', KSearchString, KSearchBufferSize/2-2 ); 
+    ReplaceMessageContentWithFileL( sentMsgs[3], KFilename );
+    CreateFileL( KFilename, 7500, 'X', KSearchString, KSearchBufferSize-2 ); 
+    ReplaceMessageContentWithFileL( sentMsgs[4], KFilename );
+    
+    criteria.SearchStrings().ResetAndDestroy();
+    criteria.AddSearchStringL( KSearchString );
+    expectedMatches.AppendL( inboxMsgs[0]->Id() );
+    expectedMatches.AppendL( inboxMsgs[1]->Id() );
+    expectedMatches.AppendL( inboxMsgs[2]->Id() );
+    expectedMatches.AppendL( sentMsgs[3]->Id() );
+    expectedMatches.AppendL( sentMsgs[4]->Id() );
+    mailBox1->SearchL( criteria, *this );
+    ValidateSearchResults( expectedMatches );
+    expectedMatches.Reset();
+    
+    iLog->Log( _L("Case %d: Cleanup the search cache"), iCaseId++ ) ;
+    mailBox1->ClearSearchResultCache();
+
+    // ERROR CASES
+    
+    iLog->Log( _L("Case %d: Error - Search while another search is in progress"), iCaseId++ ) ;
+
+    mailBox1->SearchL( criteria, *this );
+    TRAPD( result, mailBox1->SearchL( criteria, *this ) );
+    CheckCondition( _L("in use error"), result == KErrInUse );
+        
+    expectedMatches.AppendL( inboxMsgs[0]->Id() );
+    expectedMatches.AppendL( inboxMsgs[1]->Id() );
+    expectedMatches.AppendL( inboxMsgs[2]->Id() );
+    expectedMatches.AppendL( sentMsgs[3]->Id() );
+    expectedMatches.AppendL( sentMsgs[4]->Id() );
+    ValidateSearchResults( expectedMatches );
+    expectedMatches.Reset();
+    
+    iLog->Log( _L("Case %d: Error - Wrong type for folder"), iCaseId++ ) ;
+    criteria.AddFolderId( 50 );
+    
+    TRAP( result,  mailBox1->SearchL( criteria, *this ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+
+    criteria.FolderIds().Reset();
+    
+    criteria.AddFolderId( inbox1Id );
+    criteria.AddFolderId( sentFolderId );
+    
+    iLog->Log( _L("Case %d: Error - Zero length search string"), iCaseId++ ) ;
+    criteria.SearchStrings().ResetAndDestroy();
+    
+    TRAP( result, mailBox1->SearchL( criteria, *this ) );
+    CheckCondition( _L("argument error"), result == KErrArgument );
+    
+    deletedMsgs.ResetAndDestroy();
+    sentMsgs.ResetAndDestroy();
+    inboxMsgs.ResetAndDestroy();
+    
+    iMatches.Reset();
+    
+    mailBox1->ClearSearchResultCache();
+    
+    CleanupStack::PopAndDestroy( 4 );    
+    //we are done 
+    return ETrue;
+    }
+
+
+void CSearchTests::MatchFound( CMsgStorePropertyContainer*& aMessage )
+    {
+    iLog->Log( _L("  >> MatchFound" ) );
+    
+    TUint index;
+    TUint flags = 0;
+    TInt err;
+    if ( aMessage->FindProperty( KMsgStorePropertyFlags, index ) )
+        {
+        TRAP( err, flags = aMessage->PropertyValueUint32L( index ) );
+        }
+    
+    TTime time;
+    if ( aMessage->FindProperty( KMsgStorePropertyReceivedAt, index ) )
+        {
+        TRAP( err, aMessage->PropertyValueTimeL( index, time ) );
+        }
+    
+    switch( iSearchCriteria->iSortBy )
+    {
+    case EMsgStoreSortByReceivedDate:
+        iLog->Log( _L("  msg=%x, folder=%x, received date=%Ld"), aMessage->Id(), aMessage->ParentId(), time.Int64());
+        break;
+        
+    case EMsgStoreSortBySender:
+        if ( aMessage->FindProperty( KMsgStorePropertyFrom, index ) )
+            {
+            RMsgStoreAddress address;
+            TRAP( err, aMessage->PropertyValueAddressL( index, address ) );
+            iLog->Log( _L("  msg=%x, folder=%x, from=%S(%S)"), aMessage->Id(), aMessage->ParentId(), &address.iDisplayName, &address.iEmailAddress );
+            address.Close();
+            }
+        else
+            {
+            iLog->Log( _L("  msg=%x folder=%x"), aMessage->Id(), aMessage->ParentId() );
+            }
+        break;
+        
+    case EMsgStoreSortBySubject:
+        if ( aMessage->FindProperty( KMsgStorePropertySubject, index ) )
+            {
+            TRAP(err, const TDesC& subject = aMessage->PropertyValueDesL( index ) ;
+                      iLog->Log( _L("  msg=%x, folder=%x, subj=%S"), aMessage->Id(), aMessage->ParentId(), &subject ) );
+            }
+        else
+            {
+            iLog->Log( _L("  msg=%x, folder=%x"), aMessage->Id(), aMessage->ParentId() );
+            }
+        break;
+        
+    case EMsgStoreSortByPriority:
+        iLog->Log( _L("  msg=%x, folre=%x, priority=%S date=%Ld"), aMessage->Id(), aMessage->ParentId(), (flags & EMsgStoreFlag_Important ? &KHigh : (flags & EMsgStoreFlag_Low ? &KLow : &KNormal )) , time.Int64() );
+        break;
+        
+    case EMsgStoreSortByFlagStatus:
+        iLog->Log( _L("  msg=%x, folder=%x, flagStatus=%S date=%Ld"), aMessage->Id(), aMessage->ParentId(), (flags & EMsgStoreFlag_FollowUp ? &KFollowUp : (flags & EMsgStoreFlag_FollowUpComplete ? &KFollowUpComplete : &KNone )), time.Int64());
+        break;
+        
+    case EMsgStoreSortByUnRead:
+        {
+        TInt readUnread = (TInt) flags & ( EMsgStoreFlag_Read | EMsgStoreFlag_Read_Locally );
+        iLog->Log( _L("  msg=%x, folder=%x, readFlag=%d date=%Ld"), aMessage->Id(), aMessage->ParentId(), readUnread, time.Int64() );
+        }
+        break;
+        
+    case EMsgStoreSortBySize:
+        {
+        TUint size = 0;
+        if ( aMessage->FindProperty( KMsgStorePropertyMessageSizeOnServer, index ) )
+            {
+            TRAP( err, size = aMessage->PropertyValueUint32L( index ) );
+            }
+        iLog->Log( _L("  msg=%x, folder=%x, size=%u date=%Ld"), aMessage->Id(), aMessage->ParentId(), size, time.Int64() );
+        }
+        break;
+        
+    case EMsgStoreSortByAttachment:
+        {
+        TBool hasAttachment = (flags & EMsgStoreFlag_Attachments > 0 );
+        iLog->Log( _L("  msg=%x, folder=%x, attachmentFlag=%d date=%Ld"), aMessage->Id(), aMessage->ParentId(), hasAttachment, time.Int64());
+        }
+        break;
+    }
+    
+    iMatches.Append( aMessage->Id() );
+    
+    if( iSessionToCancelSearch != NULL )
+        {
+        iSessionToCancelSearch->CancelSearch();
+        }
+    
+    delete aMessage;
+    aMessage = NULL;
+    
+    iLog->Log( _L("  << MatchFound" ) );
+    }
+
+void CSearchTests::SearchCompleted()
+    {           
+    iLog->Log( _L("  >> SearchCompleted, matches=%i"), iMatches.Count() );
+    iSearchCompleted = ETrue;
+    iLog->Log( _L("  << SearchCompleted" ) );
+    }   
+
+void CSearchTests::ValidateSearchResults( RArray<TMsgStoreId>& aExpectedMatches, TBool aIgnoreExtra )
+    {
+    iLog->Log( _L("  >> ValidateSearchResults" ) );
+    
+    while( !iSearchCompleted )
+        {
+        Yield( 1000 );
+        }
+
+    TBool matched = ETrue;
+    for( TInt index = 0; index < aExpectedMatches.Count(); index++ )
+        {
+        TInt foundIndex = iMatches.Find( aExpectedMatches[index] );               
+        if( foundIndex == KErrNotFound )
+            {
+            iLog->Log( _L("  %x not found"), aExpectedMatches[index] );
+            matched = EFalse;
+            }
+        }
+    
+    if( matched && !aIgnoreExtra )
+        {
+        for( TInt index = 0; index < iMatches.Count(); index++ )
+            {
+            TInt foundIndex = aExpectedMatches.Find( iMatches[index] );               
+            if( foundIndex == KErrNotFound )
+                {
+                iLog->Log( _L("  %x not expected"), iMatches[index] );
+                matched = EFalse;
+                }
+            }
+        }
+    
+    if( !matched )
+        {
+        for( TInt index = 0; index < aExpectedMatches.Count(); index++ )
+            {
+            iLog->Log( _L("  expected=%x"), aExpectedMatches[index] );
+            }
+        for( TInt index = 0; index < iMatches.Count(); index++ )
+            {
+            iLog->Log( _L("  found=%x"), iMatches[index] );
+            }                
+        }
+    
+    CheckCondition( _L("search results matched"), matched );            
+    
+    iMatches.Reset();            
+    
+    iSearchCompleted = EFalse;
+    
+    iLog->Log( _L("  << ValidateSearchResults" ) );
+    }
+
+void CSearchTests::ReplaceMessageContentWithFileL( CMsgStoreMessage* aMessage, const TDesC& aFilename )
+    {
+    RPointerArray<CMsgStoreMessagePart> parts;
+    aMessage->ChildPartsL( parts );
+    
+    CMsgStoreMessagePart* body = parts[0];
+    CMsgStoreMessagePart* plainTextPart = body;
+    
+    RPointerArray<CMsgStoreMessagePart> childParts;
+    body->ChildPartsL( childParts );
+    
+    if ( childParts.Count() > 0 )
+        {
+        plainTextPart = childParts[0];
+        }
+    
+    plainTextPart->ReplaceContentWithFileL( aFilename );
+
+    childParts.ResetAndDestroy();
+    parts.ResetAndDestroy();
+    }
+
+void CSearchTests::SetSubjectAndAddressL( CMsgStoreMessage* aMessage, const TDesC& aSubject, const TDesC& aDisplayName, const TDesC& aAddress, const TDesC8& aAddressType )
+    {
+    aMessage->AddOrUpdatePropertyL( KMsgStorePropertySubject, aSubject );
+    
+    RMsgStoreAddress addr;
+    CleanupClosePushL( addr );
+    
+    addr.iDisplayName.Create( aDisplayName );
+    addr.iEmailAddress.Create( aAddress );
+    
+    aMessage->AddOrUpdatePropertyL( aAddressType, addr );
+    
+    CleanupStack::PopAndDestroy( &addr );
+    aMessage->StorePropertiesL();
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/ShutdownServerTest.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+//#include <BAUTILS.H>
+#include "ShutdownServerTest.h"
+//#include <ismsgstorepropertykeys.h>
+//#include "messagestoreclientserver.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CShutdownServerTest* CShutdownServerTest::NewL( CStifLogger* aLog )
+    {
+    CShutdownServerTest* self = new(ELeave) CShutdownServerTest( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CShutdownServerTest::CShutdownServerTest( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CShutdownServerTest::~CShutdownServerTest()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CShutdownServerTest::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CShutdownServerTest::ExecuteL()
+    {
+    LogHeader( _L("Shutdown Server") );
+    
+    ShutdownServerL();
+    WaitForServerToTerminate();
+    
+    //we are done 
+    return ETrue;
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/SizeTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,170 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Base class for all test cases class member functions
+*
+*/
+
+
+//#include <BAUTILS.H>
+#include "SizeTests.h"
+//#include <ismsgstorepropertykeys.h>
+//#include "messagestoreclientserver.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CSizeTests* CSizeTests::NewL( CStifLogger* aLog )
+    {
+    CSizeTests* self = new(ELeave) CSizeTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CSizeTests::CSizeTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CSizeTests::~CSizeTests()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CSizeTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CSizeTests::ExecuteL()
+    {
+    LogHeader( _L("Size") );
+    
+    CMsgStoreAccount* account = CMsgStoreAccount::NewLC( 1234, KNullDesC );         //+1
+    CMsgStoreMailBox* mailBox = iMsgStore->CreateAccountL( *account );
+    CleanupStack::PushL( mailBox );                                                 //+2
+    
+    CMsgStorePropertyContainer* bigProperties = CMsgStorePropertyContainer::NewL();
+    CleanupStack::PushL( bigProperties );                                           //+3
+    
+    TBuf8<1000> buf;
+    buf.Fill( 'X', 1000 );
+    
+    // 100K properties
+    for( TInt i = 0; i < 100; i++ )
+        {
+        TBuf8<20> propertyName;
+        propertyName.Format( _L8("property%i"), &propertyName );
+        
+        bigProperties->AddPropertyL( propertyName, buf );       
+        }
+
+    iLog->Log( _L("Case %d: Create a folder with big properties"), iCaseId++ );
+    
+    
+    
+    TMsgStoreId folderId = mailBox->CreateFolderL( mailBox->Id(), *bigProperties );
+
+    CMsgStoreFolder* folder = mailBox->FolderL( folderId );
+    ComparePropertiesL( *folder, *bigProperties );
+    delete folder;
+    
+    RPointerArray<CMsgStoreFolder> folders;
+    mailBox->FoldersL( folders );
+    ComparePropertiesL( *folders[folders.Count()-1], *bigProperties );
+    folders.ResetAndDestroy();    
+
+    iLog->Log( _L("Case %d: Create a message with big properties"), iCaseId++ );
+    
+    CMsgStoreMessage* message = mailBox->CreateMessageL( folderId, *bigProperties );
+    CleanupStack::PushL( message );                                                      //+4
+    message->CommitL();
+    
+    CMsgStoreMessage* message2 = mailBox->FetchMessageL( message->Id(), folderId );
+    ComparePropertiesL( *message2, *bigProperties );
+    delete message2;
+    
+    iLog->Log( _L("Case %d: Create an attachment with big properties"), iCaseId++ );
+    
+    CMsgStoreMessagePart* attachment = message->AddChildPartL( *bigProperties );
+    CleanupStack::PushL( attachment );                                                   //+5
+
+    CMsgStoreMessagePart* attachment2 = message->AddChildPartL( *bigProperties );
+    ComparePropertiesL( *attachment2, *bigProperties );
+    delete attachment2;
+    
+    RPointerArray<CMsgStoreMessagePart> attachments;
+    message->ChildPartsL( attachments );
+    ComparePropertiesL( *attachments[0], *bigProperties );
+    attachments.ResetAndDestroy();    
+    
+    iLog->Log( _L("Case %d: Add large content to message with Appends"), iCaseId++ );
+    
+    buf.Fill( 'C', 1000 );
+    for( TInt i = 0; i < 100; i++ )
+        {       
+        message->AppendToContentL( buf );   
+        } // end for
+        
+    buf.Copy( _L8("D") );
+    message->AppendToContentL( buf );   
+    
+    iLog->Log( _L("Case %d: Fetch large content to buffer"), iCaseId++ );
+    
+    RBuf8 heapBuf;
+    heapBuf.CleanupClosePushL();                                                         //+6
+    heapBuf.CreateL( 100002 ); 
+    
+    message->FetchContentToBufferL( heapBuf );
+    
+    CheckCondition( _L( "content OK"), heapBuf.Length() == 100001 && heapBuf[0] == 'C' && 
+                                       heapBuf[99999] == 'C' && heapBuf[100000] == 'D' );
+    
+    iLog->Log( _L("Case %d: Fetch large content to file"), iCaseId++ );
+    
+    _LIT( KFilename, "c:\\content_test.txt" );
+    message->FetchContentToFileL( KFilename );
+    
+    iLog->Log( _L("Case %d: Add large content to attachment with file"), iCaseId++ );
+    
+    attachment->ReplaceContentWithFileL( KFilename );
+    
+    iLog->Log( _L("Case %d: Fetch large content to buffer"), iCaseId++ );
+    
+    heapBuf.FillZ();    
+    
+    message->FetchContentToBufferL( heapBuf );
+    
+    CheckCondition( _L( "content OK"), heapBuf.Length() == 100001 && heapBuf[0] == 'C' && 
+                                       heapBuf[99999] == 'C' && heapBuf[100000] == 'D' );
+    
+
+    CleanupStack::PopAndDestroy(6);
+    
+    //we are done 
+    return ETrue;
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/SortTests.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,854 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  implements all sorting related test cases
+*
+*/
+
+
+//#include <BAUTILS.H>
+#include <e32math.h>
+#include <tz.h>
+#include "SortTests.h"
+//#include <ismsgstorepropertykeys.h>
+//#include "messagestoreclientserver.h"
+
+const TInt32 KOwner1 = 1234;
+_LIT(KAccount1, "My Account");
+_LIT(KInbox,    "inbox");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CSortTests* CSortTests::NewL( CStifLogger* aLog )
+    {
+    CSortTests* self = new(ELeave) CSortTests( aLog );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+CSortTests::CSortTests( CStifLogger* aLog ) : CAsyncTestCaseBase( aLog ) 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CSortTests::~CSortTests()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+void CSortTests::ConstructL()
+    {
+    CAsyncTestCaseBase::ConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// ExecuteL : start executing the test case
+// -----------------------------------------------------------------------------
+TBool CSortTests::ExecuteL()
+    {
+    LogHeader( _L("Sort") );
+    
+    TInt msgCount = 200;
+    
+    iLog->Log( _L("  Create %d messages"), msgCount );
+    DoCreateMessagesL( msgCount );
+    
+    //Open Account
+    CMsgStoreAccount* account = CMsgStoreAccount::NewLC( KOwner1, KAccount1 );   //+1
+    CMsgStoreMailBox* mailBox = iMsgStore->OpenAccountL( *account );
+    CleanupStack::PushL( mailBox );                                              //+2
+    
+    TUint total, unread;
+    mailBox->TotalMessageCountsL( total, unread );
+    iLog->Log( _L("  Total msg=%u, unread=%u"), total, unread);
+    
+    RPointerArray<CMsgStoreFolder> folders;
+    
+    mailBox->FoldersL( mailBox->Id(), folders );
+    
+    TMsgStoreId inboxId = 0;
+    for ( TInt ii = 0 ; ii < folders.Count() ; ii++ )
+        {
+        CMsgStoreFolder* folder = folders[ii];
+        TUint index = 0;
+        if ( folder->FindProperty( KMsgStorePropertyName, index ) )
+            {
+            if ( folder->PropertyValueDesL( index ) == KInbox )
+                {
+                //found inbox
+                inboxId = folder->Id();
+                break;
+                }
+            }
+        }
+    folders.ResetAndDestroy();
+    
+    if ( inboxId == 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    
+    RArray<RMsgStoreSortCriteria>              criteriaArray;
+    RPointerArray<CMsgStoreSortResultIterator> iteratorArray;
+    RArray<TMsgStoreId>                        curIdArray;
+    RArray<TBool>                              hasMoreArray;
+    RArray<TMsgStoreIteratorDirection>         checkDirectionArray;
+    RArray<TInt>                               bucketSizeArray;
+    
+//    UpdateText( 2, _L("Start sorting") );
+    
+    RPointerArray<CMsgStorePropertyContainer> results;
+    
+    //test each sort by field
+    for ( TInt i = 0 ; i < 10 ; i++ )
+        {
+        RMsgStoreSortCriteria criteria;
+        criteria.iFolderId = inboxId;
+        criteria.AddResultPropertyL( KMsgStorePropertyReceivedAt );
+        criteria.AddResultPropertyL( KMsgStorePropertyFlags );
+        criteria.AddResultPropertyL( KMsgStorePropertyMessageSizeOnServer );
+        criteria.AddResultPropertyL( KMsgStorePropertyFrom );
+        criteria.AddResultPropertyL( KMsgStorePropertyTo );
+        criteria.AddResultPropertyL( KMsgStorePropertySubject );
+        
+        switch( i )
+            {
+            case 0:
+                //sort by received date
+                iLog->Log( _L("Case %d: Sort By: ReceivedData, Order: Desc"), iCaseId++ );
+                criteria.iSortBy   = EMsgStoreSortByReceivedDate;
+                criteria.iSortOrder = EMsgStoreSortDescending;
+                break;
+            
+            case 1:
+                //sort by EMsgStoreSortByPriority
+                iLog->Log( _L("Case %d: Sort By: Priority, Order: Desc/Desc"), iCaseId++ );
+                criteria.iSortBy   = EMsgStoreSortByPriority;
+                criteria.iSortOrder = EMsgStoreSortDescending;          //primary   = DESC
+                criteria.iSecondarySortOrder = EMsgStoreSortDescending; //secondary = DESC 
+                break;
+                
+            case 2:
+                //sort by EMsgStoreSortByFlagStatus
+                iLog->Log( _L("Case %d: Sort By: Flag, Order: Desc/Asc"), iCaseId++ );
+                criteria.iSortBy   = EMsgStoreSortByFlagStatus;
+                criteria.iSortOrder = EMsgStoreSortDescending;          //Primary   = DESC
+                criteria.iSecondarySortOrder = EMsgStoreSortAscending;  //secondary = ASC
+                break;
+                
+            case 3:
+                //sort by EMsgStoreSortByUnRead
+                iLog->Log( _L("Case %d: Sort By: Unread, Order: Asc/Desc"), iCaseId++ );
+                criteria.iSortBy   = EMsgStoreSortByUnRead;
+                criteria.iSortOrder = EMsgStoreSortAscending;           //Primary   = ASC
+                criteria.iSecondarySortOrder = EMsgStoreSortDescending;  //Secondary = DESC
+                break;
+                
+            case 4:
+                //sort by EMsgStoreSortByAttachment
+                iLog->Log( _L("Case %d: Sort By: Attachment, Order: Asc/Asc"), iCaseId++ );
+                criteria.iSortBy   = EMsgStoreSortByAttachment;
+                criteria.iSortOrder = EMsgStoreSortAscending;            //Primary   = ASC
+                criteria.iSecondarySortOrder = EMsgStoreSortAscending;  //Secondary = ASC
+                break;
+                
+            case 5:
+                //sort by EMsgStoreSortBySize
+                iLog->Log( _L("Case %d: Sort By: Size, Order: Desc/Desc"), iCaseId++ );
+                criteria.iSortBy   = EMsgStoreSortBySize;
+                criteria.iSortOrder = EMsgStoreSortDescending;           //Primary   = DESC
+                criteria.iSecondarySortOrder = EMsgStoreSortDescending;  //Secondary = DESC
+                break;
+                
+            case 6:
+                //sort by EMsgStoreSortBySender
+                iLog->Log( _L("Case %d: Sort By: Sender, Order: Desc/Desc"), iCaseId++ );
+                criteria.iSortBy   = EMsgStoreSortBySender;
+                criteria.iSortOrder = EMsgStoreSortDescending;           //Primary   = DESC
+                criteria.iSecondarySortOrder = EMsgStoreSortDescending;  //Secondary = DESC
+                break;
+                
+            case 7:
+                //sort by EMsgStoreSortByTo
+                iLog->Log( _L("Case %d: Sort By: Recipient, Order: Desc/Desc"), iCaseId++ );
+                criteria.iSortBy   = EMsgStoreSortByRecipient;
+                criteria.iSortOrder = EMsgStoreSortDescending;           //Primary   = DESC
+                criteria.iSecondarySortOrder = EMsgStoreSortDescending;  //Secondary = DESC
+                break;
+                
+            case 8:
+                //sort by EMsgStoreSortBySubject
+                iLog->Log( _L("Case %d: Sort By: Subject, Order: Asc/Desc"), iCaseId++ );
+                criteria.iSortBy   = EMsgStoreSortBySubject;
+                criteria.iSortOrder = EMsgStoreSortAscending;            //Primary   = ASC
+                criteria.iSecondarySortOrder = EMsgStoreSortDescending;  //Secondary = DESC
+                break;
+            
+            case 9:
+                //sort by EMsgStoreSortBySubject
+                iLog->Log( _L("Case %d: Sort By: Subject, Order: Asc/Desc"), iCaseId++ );
+                criteria.iSortBy   = EMsgStoreSortBySubject;
+                criteria.iSortOrder = EMsgStoreSortAscending;            //Primary   = ASC
+                criteria.iSecondarySortOrder = EMsgStoreSortDescending;  //Secondary = DESC
+                break;
+                
+            default:
+                break;
+            }
+        
+        criteriaArray.Append( criteria );
+        
+        //set the direction
+        TMsgStoreIteratorDirection direction = static_cast<TMsgStoreIteratorDirection>(i % 2);   //forward (next) or backward (previous)
+        checkDirectionArray.Append( direction );
+        
+        //initialize currentId, if forward, start from the top, if backward, start from the bottom
+        TMsgStoreId curId = ( direction == EMsgStoreIteratorForward ) ? KMsgStoreSortResultTop : KMsgStoreSortResultBottom ;
+        curIdArray.Append( curId );
+        
+        //initialze hasMore to true
+        hasMoreArray.Append(ETrue);
+
+        CMsgStoreSortResultIterator* iterator = mailBox->SortL( criteria, (i % 2 ? ETrue : EFalse) ); 
+        
+        for( TInt jj = 0; jj < 10; jj++ )
+            {                
+            Yield( 25000 );
+            }
+        
+        if ( i != 5 && i <= 8 )
+            {
+            iLog->Log( _L("Case %d: Test GroupCountL"), iCaseId++ );
+            
+            RArray<TUint> itemCounts;
+            CleanupClosePushL( itemCounts );
+            TInt count = iterator->GroupCountL( itemCounts );
+            iLog->Log( _L("  GroupCount=%d"), count );
+            
+            CleanupStack::PopAndDestroy( &itemCounts );
+            }
+        
+        TBool hasMore = EFalse;
+        TInt  bucketSize = 20;
+
+        //get the results
+        do {
+            results.ResetAndDestroy();
+               
+            TTime startTime;
+            startTime.HomeTime();
+            
+            TInt startId = curIdArray[i];
+               
+            if ( checkDirectionArray[i] == EMsgStoreIteratorForward )
+                {
+                
+                if ( i == 9 )
+                    {
+                    iLog->Log( _L("Case %d: Calling NextL(string)"), iCaseId++ );
+                    hasMore = iterator->NextL( _L("nzz") , bucketSize, results );
+                    }
+                else
+                    {
+                    iLog->Log( _L("Case %d: Calling NextL"), iCaseId++ );
+                    hasMore = iterator->NextL( curIdArray[i] , bucketSize, results );
+                    }
+                }
+            else
+                {
+                if ( i == 9 )
+                    {
+                    iLog->Log( _L("Case %d: Calling PreviousL(string)"), iCaseId++ );
+                    hasMore = iterator->PreviousL( _L("nzz") , bucketSize, results );
+                    }
+                else
+                    {
+                    iLog->Log( _L("Case %d: Calling PreviousL()"), iCaseId++ );
+                    hasMore = iterator->PreviousL( curIdArray[i] , bucketSize, results );
+                    }
+                }
+               
+            iLog->Log( _L("  Comparing results") );
+            curIdArray[i] = CompareSortResultsL( criteriaArray[i], checkDirectionArray[i], results );
+            
+            //TEST SkipAndNext() and SkupAndPrevioud
+            if ( i >= 0 && i <= 8 )
+                {
+                RPointerArray<CMsgStorePropertyContainer> skipResults;
+                
+                startTime.HomeTime();
+                
+                TBool hasNextGroup = ETrue;
+                if ( checkDirectionArray[i] == EMsgStoreIteratorForward )
+                    {
+                    iLog->Log( _L("Case %d: Testing SkipAndNextL()"), iCaseId++ );
+                    
+                    hasNextGroup = iterator->SkipAndNextL( startId , bucketSize, skipResults );
+                    }
+                else
+                    {
+                    iLog->Log( _L("Case %d: Testing SkipAndPreviousL()"), iCaseId++ );
+                    
+                    hasNextGroup = iterator->SkipAndPreviousL( startId, bucketSize, skipResults );
+                    }
+                iLog->Log( _L("  Skip returns %d"), hasNextGroup);
+                   
+                iLog->Log( _L("  Comparing results") );
+                CompareSortResultsL( criteriaArray[i], checkDirectionArray[i], skipResults );
+                skipResults.ResetAndDestroy();
+                }
+              
+            if ( bucketSize == 100 )
+                {
+                hasMore = EFalse;
+                }
+            else
+                {
+                bucketSize += 10;
+                }
+            
+            //add a message while there are sorting sessions
+            if ( bucketSize == 30 )
+                {
+                iLog->Log( _L("Case %d: Add messages while sort session is open"), iCaseId++ );
+                CreateRandomMessagesL( mailBox, inboxId, 2, ETrue, ETrue);
+                }
+            else if ( bucketSize == 40 )
+                {
+                //delete iMatches[0]
+                iLog->Log( _L("Case %d: Delete message while sort session is open"), iCaseId++ );
+                mailBox->DeleteMessageL( iMatches[0], inboxId );
+                }
+            else if ( bucketSize == 50 )
+                {
+                iLog->Log( _L("Case %d: Update message while sort session is open"), iCaseId++ );
+                CMsgStoreMessage* msg = mailBox->FetchMessageL( iMatches[1], inboxId );
+                CleanupStack::PushL( msg );                                                    //+msg
+                
+                TTime time;
+                time.HomeTime();
+                TInt64 seed = time.Int64();
+                
+                TInt64 date = Math::Rand( seed );
+                TTime randTime( date );
+                msg->AddOrUpdatePropertyL( KMsgStorePropertyReceivedAt, randTime );
+                
+                TUint32 flags = Math::Rand( seed );
+                msg->AddOrUpdatePropertyL( KMsgStorePropertyFlags, (TUint32) flags );
+                
+                TUint32 size = Math::Rand( seed );
+                msg->AddOrUpdatePropertyL( KMsgStorePropertyMessageSizeOnServer, (TUint32) size );
+                TBuf<30> subject;
+                CreateRandomString( subject, 30, seed );
+                msg->AddOrUpdatePropertyL( KMsgStorePropertySubject, subject );
+                
+                TBuf<6> fname, lname;
+                CreateRandomString( fname, 6, seed );
+                CreateRandomString( lname, 6, seed );
+                RMsgStoreAddress address;
+                address.iDisplayName.Create( 50 );
+                address.iEmailAddress.Create( 50 );
+                
+                address.iDisplayName.Format( _L("%S %S"), &fname, &lname );
+                address.iEmailAddress.Format( _L("%S.%S@%S"), &fname, &lname, &_L("nokia.com"));
+                msg->AddOrUpdatePropertyL( KMsgStorePropertyFrom, address );
+                
+                address.iDisplayName.Append(_L("TO"));
+                msg->AddOrUpdatePropertyL( KMsgStorePropertyTo, address );
+                
+                msg->StorePropertiesL();
+                
+                //iLog->Log( _L("  msgId=%x, flags=%x, size=%d, date=%Ld"), msg->Id(), flags, size, date );
+                //iLog->Log( _L("  subject=%S"), &subject );
+                
+                address.Close();
+                CleanupStack::PopAndDestroy( msg );
+                }
+            
+            //update iMatches[1]
+                
+        } while ( hasMore );
+        
+        
+        //testing IdsAndFlags
+        iLog->Log( _L("Case %d: Testing IdsAndFlagsL()"), iCaseId++ );
+        RArray<TMsgStoreIdAndFlag> idsAndFlags;
+        iterator->IdsAndFlagsL( idsAndFlags );
+        
+        iLog->Log( _L("  IdsAndFlagsL returned %d objects"), idsAndFlags.Count() );        
+        
+        idsAndFlags.Reset();
+        
+        //testing get sorted MessageIds
+        iLog->Log( _L("Case %d: Testing MessageIdsL()"), iCaseId++ );
+        RArray<TMsgStoreId> ids;
+        //start sorting
+        iterator->MessageIdsL( ids );        
+        
+        iLog->Log( _L("  MessageIds returned %d objects"), ids.Count() );        
+        
+        ids.Reset();
+        
+        //testing IdsAndGroupCount
+        iLog->Log( _L("Case %d: Testing IdsAndGroupCountL()"), iCaseId++ );
+        RArray<TUint> itemCounts;
+        CleanupClosePushL( itemCounts );
+        
+        iterator->IdsAndGroupCountL( ids, itemCounts );        
+        
+        iLog->Log( _L("  GroupCount=%d"), itemCounts.Count() );
+        
+        //if ( itemCounts.Count() > 0 )
+        //    {
+        //    TInt needNToBeMod8 = 8 - itemCounts.Count() % 8;
+        //    if ( needNToBeMod8 != 8 )
+        //        {
+        //        for ( TInt i = 0 ; i < needNToBeMod8 ; i++ )
+        //            {
+        //            itemCounts.Append(0);
+        //            }
+        //        }
+        //    
+        //    for ( TInt i = 0 ; i < itemCounts.Count() ; i += 8 )
+        //        {
+        //        iLog->Log( _L("  counts: %d, %d, %d, %d, %d, %d, %d, %d"), 
+        //                itemCounts[i], itemCounts[i+1], itemCounts[i+2], itemCounts[i+3],
+        //                itemCounts[i+4], itemCounts[i+5], itemCounts[i+6], itemCounts[i+7] );
+        //        }
+        //    }            
+        
+        CleanupStack::PopAndDestroy( &itemCounts );
+        
+        iLog->Log( _L("  MessageIds returned %d objects"), ids.Count() );
+        
+        ids.Reset();
+        
+        iLog->Log( _L("Case %d: Testing IndexOfL()"), iCaseId++ );
+        //add a message after the iterator has been created
+        CreateRandomMessagesL( mailBox, inboxId, 1, ETrue, ETrue );
+        TInt index = iterator->IndexOfL( iMatches[0] );
+
+        iLog->Log( _L("  id=%08x, index=%d"), iMatches[0], index);        
+        
+        delete iterator;
+        bucketSizeArray.Append( bucketSize );
+        }  //end for
+    
+    results.ResetAndDestroy();
+    iMatches.Reset();
+
+    
+    CMsgStoreAccount* account2 = CMsgStoreAccount::NewLC( 9999, _L("") );         //+3
+    CMsgStoreMailBox* mailBox2;
+    TRAPD(err, mailBox2 = iMsgStore->OpenAccountL( *account2 ) )
+    if ( err != KErrNone )
+        {
+        mailBox2 = iMsgStore->CreateAccountL( *account2 );
+        }
+    CleanupStack::PushL( mailBox2 );                                             //+4
+    CMsgStorePropertyContainer* prop2 = CMsgStorePropertyContainer::NewL();     
+    CleanupStack::PushL( prop2 );                                                //+5
+    
+    TMsgStoreId folder2;
+    
+    for ( TInt i = 0 ; i < 2 ; i++ )
+        {
+    
+        folder2 = mailBox2->CreateFolderL( mailBox2->Id(), *prop2 );
+        
+        CreateRandomMessagesL( mailBox2, folder2, 50 );
+        
+        criteriaArray[0].iFolderId = folder2;
+        criteriaArray[criteriaArray.Count()-1].iFolderId = folder2;
+        
+        CMsgStoreSortResultIterator* iterator1 = mailBox2->SortL( criteriaArray[0] ); 
+        CMsgStoreSortResultIterator* iterator2 = mailBox2->SortL( criteriaArray[criteriaArray.Count()-1] ); 
+        
+        iterator1->NextL( KMsgStoreSortResultTop, 20, results );
+        CheckCondition( _L("traverse halfway"), results.Count() == 20 );
+        results.ResetAndDestroy();
+        
+        //now we have two sort session, one traversed to half way, one not travesed yet
+        if ( i == 0 )
+            {
+            iLog->Log( _L("Case %d: Testing delete folder while iterator is open"), iCaseId++ );
+            //delete the 
+            mailBox2->DeleteFolderL( folder2 );
+            }
+        else
+            {
+            //delete the 
+            iLog->Log( _L("Case %d: Testing delete mailbox while iterator is open"), iCaseId++ );
+            iMsgStore->DeleteAccountL( *account2 );
+            }
+        
+        TBool hasMore = iterator1->NextL( KMsgStoreSortResultTop , 20, results );
+        CheckCondition( _L("hasMore==EFalse"), !hasMore );
+        CheckCondition( _L("no result"), results.Count() == 0 );
+        
+        
+        hasMore = iterator2->NextL( _L("nzz") , 20, results );
+        CheckCondition( _L("hasMore==EFalse"), !hasMore );
+        CheckCondition( _L("no result"), results.Count() == 0 );
+        
+        delete iterator1;
+        delete iterator2;
+        }
+    
+    for ( int i = 0 ; i < criteriaArray.Count() ; i++ )
+        {
+        criteriaArray[i].Close();
+        }
+    
+    criteriaArray.Close();
+    iteratorArray.ResetAndDestroy();
+    curIdArray.Close();
+    hasMoreArray.Close();
+    checkDirectionArray.Close();
+    bucketSizeArray.Close();
+    
+    CleanupStack::PopAndDestroy( 5 );
+    
+    //we are done 
+    return ETrue;
+    }
+
+
+void CSortTests::DoCreateMessagesL( TInt aMsgCount )
+    {
+    iLog->Log( _L("  >> DoCreateMessages") );
+    
+    TBool isNew = ETrue;
+    
+    CMsgStore* session = CMsgStore::NewL();                                     //+1
+    CleanupStack::PushL( session );
+
+    CMsgStoreAccount* account = CMsgStoreAccount::NewLC( KOwner1, KAccount1 );  //+2
+    CMsgStoreMailBox* mailBox = NULL;
+    TRAPD( err, mailBox = session->CreateAccountL( *account ) );
+    if ( err != KErrNone )
+        {
+        mailBox = session->OpenAccountL( *account );
+        isNew = EFalse;
+        }
+    CleanupStack::PushL( mailBox );                                            //+3
+    
+    TMsgStoreId inboxId;
+    
+    if ( isNew )
+        {
+        CMsgStorePropertyContainer* prop = CMsgStorePropertyContainer::NewL();
+        CleanupStack::PushL( prop );
+        
+        inboxId = mailBox->CreateFolderL( mailBox->Id(), *prop );
+        
+        CleanupStack::PopAndDestroy( prop );
+        
+        CMsgStoreFolder* folder = mailBox->FolderL( inboxId );
+        CleanupStack::PushL( folder );
+        
+        folder->AddPropertyL( KMsgStorePropertyName, KInbox );
+        folder->StorePropertiesL();
+        
+        CleanupStack::PopAndDestroy( folder );
+        }
+    else
+        {
+        RPointerArray<CMsgStoreFolder> folders;
+        
+        mailBox->FoldersL( mailBox->Id(), folders );
+        
+        for ( int i = 0 ; i < folders.Count() ; i++ )
+            {
+            CMsgStoreFolder* folder = folders[i];
+            TUint index = 0;
+            if ( folder->FindProperty( KMsgStorePropertyName, index ) )
+                {
+                if ( folder->PropertyValueDesL( index ) == KInbox )
+                    {
+                    //found inbox
+                    inboxId = folder->Id();
+                    break;
+                    }
+                }
+            }
+        folders.ResetAndDestroy();
+        }
+    
+    CreateRandomMessagesL( mailBox, inboxId, aMsgCount );
+    
+    CleanupStack::PopAndDestroy( 3 );
+    iLog->Log( _L("  << DoCreateMessages") );
+    }
+
+TMsgStoreId CSortTests::CompareSortResultsL( RMsgStoreSortCriteria aCriteria, 
+                                             TMsgStoreIteratorDirection aDirection, 
+                                             const RPointerArray<CMsgStorePropertyContainer>& aResults )
+    {
+    iLog->Log( _L("  >> CompareSortResultsL") );
+    iLog->Log( _L("  result count=%d"), aResults.Count() );
+    
+    TMsgStoreId lastMsgId;
+    TUint       index;
+    TInt64      curVal1, curVal2, nextVal1, nextVal2;
+    TUint       size;
+    RBuf        curString, nextString;
+    curString.Create(100);
+    nextString.Create(100);
+    TBuf<100>  timeString;
+     
+    TBool checkSecondaryOrder = EFalse;
+    TMsgStoreSortOrder compareOrder1, compareOrder2;
+    
+    if ( ( aCriteria.iSortOrder == EMsgStoreSortDescending && aDirection == EMsgStoreIteratorForward ) ||
+         ( aCriteria.iSortOrder == EMsgStoreSortAscending &&  aDirection == EMsgStoreIteratorBackward )   )
+        {
+        compareOrder1 = EMsgStoreSortDescending;
+        curVal1 = nextVal1 = KMaxTInt64;
+        curString.AppendFill(TChar('z'), 100);
+        }
+    else
+        {
+        compareOrder1 = EMsgStoreSortAscending;
+        curVal1 = nextVal1 = KMinTInt64;
+        curString.AppendFill(TChar('!'), 100);
+        }
+    
+    if ( aCriteria.iSortBy != EMsgStoreSortByReceivedDate )
+        {
+        checkSecondaryOrder = ETrue;
+        if ( ( aCriteria.iSecondarySortOrder == EMsgStoreSortDescending && aDirection == EMsgStoreIteratorForward ) ||
+             ( aCriteria.iSecondarySortOrder == EMsgStoreSortAscending &&  aDirection == EMsgStoreIteratorBackward )  )
+            {
+            compareOrder2 = EMsgStoreSortDescending;
+            curVal2 = nextVal2 = KMaxTInt64;
+            }
+        else
+            {
+            compareOrder2 = EMsgStoreSortAscending;
+            curVal2 = nextVal2 = KMinTInt64;
+            }
+        }
+    
+    RTz timeZoneServer;
+    User::LeaveIfError( timeZoneServer.Connect() );
+    CleanupClosePushL( timeZoneServer );             //+timeZoneServer
+    
+    for ( int i = 0 ; i < aResults.Count() ; i++ )
+        {
+        CMsgStorePropertyContainer* msg = aResults[i];
+        
+        CheckCondition( _L("received date property exists"), msg->FindProperty( KMsgStorePropertyReceivedAt, index ), EFalse ); 
+        TTime time;
+        msg->PropertyValueTimeL( index, time );
+        timeZoneServer.ConvertToLocalTime( time );
+        
+        CheckCondition( _L("flags property exists"), msg->FindProperty( KMsgStorePropertyFlags, index ), EFalse ); 
+        TUint32 flags;
+        flags = msg->PropertyValueUint32L( index );
+        
+        switch( aCriteria.iSortBy )
+            {
+            case EMsgStoreSortByReceivedDate:
+                time.FormatL( timeString, _L("%F%M/%D/%Y %H:%T:%S") );
+                nextVal1 = time.Int64();
+                //iLog->Log( _L("  msg id=%x, received date=%S"), msg->Id(), &timeString);
+                break;
+                
+            case EMsgStoreSortByPriority:
+                nextVal1 = 0;
+                if ( flags & EMsgStoreFlag_Important )
+                    {
+                    nextVal1 = 1;
+                    }
+                else if ( flags & EMsgStoreFlag_Low )
+                    {
+                    nextVal1 = -1;
+                    }
+                nextVal2 = time.Int64();
+                break;
+                
+            case EMsgStoreSortByFlagStatus:
+                nextVal1 = 0;
+                if ( flags & EMsgStoreFlag_FollowUp )
+                    {
+                    nextVal1 = 2;
+                    }
+                else if ( flags & EMsgStoreFlag_FollowUpComplete )
+                    {
+                    nextVal1 = 1;
+                    }
+                nextVal2 = time.Int64();
+                break;
+                
+            case EMsgStoreSortByUnRead:
+                nextVal1 = flags & ( EMsgStoreFlag_Read | EMsgStoreFlag_Read_Locally );
+                nextVal2 = time.Int64();
+                //iLog->Log( _L("  msg id=%x, readFlag=%Ld date=%Ld"), msg->Id(), nextVal1, nextVal2);
+                break;
+                
+            case EMsgStoreSortByAttachment:
+                nextVal1 = flags & EMsgStoreFlag_Attachments; 
+                nextVal2 = time.Int64();
+                //iLog->Log( _L("  msg id=%x, attachmentFlag=%Ld date=%Ld"), msg->Id(), nextVal1, nextVal2);
+                break;
+                
+            case EMsgStoreSortBySize:
+                size = 0;
+                if ( msg->FindProperty( KMsgStorePropertyMessageSizeOnServer, index ) )
+                    {
+                    size = msg->PropertyValueUint32L( index );
+                    }
+                nextVal1 = size;
+                nextVal2 = time.Int64();
+                //iLog->Log( _L("  msg id=%x, size=%Ld date=%Ld"), msg->Id(), nextVal1, nextVal2);
+                break;
+                
+            case EMsgStoreSortBySender:
+                {
+                CheckCondition( _L("from property exists"), msg->FindProperty( KMsgStorePropertyFrom, index ), EFalse ); 
+                RMsgStoreAddress address;
+                msg->PropertyValueAddressL( index, address );
+                nextString.Copy( address.iDisplayName );
+                nextString.Append( address.iEmailAddress );
+                address.Close();
+                nextVal2 = time.Int64();
+                //iLog->Log( _L("  msg id=%x, date=%Ld from=%S"), msg->Id(), nextVal2, &nextString );
+                }
+                break;
+                
+            case EMsgStoreSortByRecipient:
+                {
+                CheckCondition( _L("to property exists"), msg->FindProperty( KMsgStorePropertyTo, index ), EFalse ); 
+                RMsgStoreAddress address;
+                msg->PropertyValueAddressL( index, address );
+                nextString.Copy( address.iDisplayName );
+                nextString.Append( address.iEmailAddress );
+                address.Close();
+                nextVal2 = time.Int64();
+                //iLog->Log( _L("  msg id=%x, date=%Ld to=%S"), msg->Id(), nextVal2, &nextString );
+                }
+                break;
+                
+            case EMsgStoreSortBySubject:
+                {
+                CheckCondition( _L("subject property exists"), msg->FindProperty( KMsgStorePropertySubject, index ), EFalse ); 
+                const TDesC& subject = msg->PropertyValueDesL( index );
+                nextVal2 = time.Int64();
+                //iLog->Log( _L("  msg id=%x, date=%Ld subj=%S"), msg->Id(), nextVal2, &subject );
+                
+                //get rid of the "Alpha:" "AlphaAlpha:" "AlphaAlphaAlpha:"
+                nextString.Copy( subject );
+                TPtr16 ptr = nextString.MidTPtr(0);
+                TBool prefixFound = ETrue;
+                while ( prefixFound )
+                    {
+                    ptr.TrimLeft();
+                    TInt pos = ptr.Locate( TChar(':') );
+                    if ( pos > 0 && pos <= 3 )
+                        {
+                        for ( TInt i = 0; i < pos; i++ )
+                            {
+                            TChar ch = ptr[i];
+                            if ( !ch.IsAlpha() )
+                                {
+                                prefixFound = EFalse;
+                                break;
+                                }                    
+                            }
+                        if ( prefixFound )
+                            {
+                            ptr = ptr.Mid( pos + 1 );
+                            } 
+                        }
+                    else
+                        {
+                        prefixFound = EFalse;
+                        }
+                    }
+                
+                nextString.Copy( ptr );
+                }
+                break;
+                
+            default:
+                break;
+            }
+        
+        TInt primaryOrder = 0;
+        if ( aCriteria.iSortBy == EMsgStoreSortBySender ||
+             aCriteria.iSortBy == EMsgStoreSortByRecipient ||
+             aCriteria.iSortBy == EMsgStoreSortBySubject   )
+            {
+            primaryOrder = nextString.CompareC( curString, 1, NULL );
+            }
+        else
+            {
+            primaryOrder = ( nextVal1 < curVal1 ? -1 : ( nextVal1 == curVal1 ? 0 : 1 )  );
+            }
+        
+        if ( compareOrder1 == EMsgStoreSortDescending  )
+            {
+                CheckCondition( _L("primary order"), primaryOrder <= 0, EFalse );
+            }
+        else
+            {
+                CheckCondition( _L("primary order"), primaryOrder >= 0, EFalse );
+            }
+        
+        if ( checkSecondaryOrder && primaryOrder == 0 )
+            {
+            //compare the secondary order
+            if ( compareOrder2 == EMsgStoreSortDescending  )
+                {
+                CheckCondition( _L("2nd value order"), nextVal2 <= curVal2, EFalse );
+                }
+            else
+                {
+                CheckCondition( _L("2nd value order"), nextVal2 >= curVal2, EFalse );
+                }
+            }
+        
+        curVal1 = nextVal1;
+        curVal2 = nextVal2;
+        curString.Copy( nextString );
+        
+        if ( i == aResults.Count() - 1 )
+            {
+            lastMsgId = msg->Id();
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( &timeZoneServer );
+    
+    curString.Close();
+    nextString.Close();
+    
+    iLog->Log( _L("  << CompareSortResultsL - PASSED") );
+    
+    return lastMsgId;
+    
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/t_msgstore.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,443 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  t_msgstore class member functions
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <Stiftestinterface.h>
+#include "t_msgstore.h"
+#include <SettingServerClient.h>
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg)  // ?description
+    {
+
+    ?code  // ?comment
+
+    // ?comment
+    ?code
+    }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::Ct_msgstore
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+Ct_msgstore::Ct_msgstore()
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::ConstructL
+// Symbian 2nd phase constructor can leave.
+//
+// Note: If OOM test case uses STIF Logger, then STIF Logger must be created
+// with static buffer size parameter (aStaticBufferSize). Otherwise Logger 
+// allocates memory from heap and therefore causes error situations with OOM 
+// testing. For more information about STIF Logger construction, see STIF Users 
+// Guide.
+// -----------------------------------------------------------------------------
+//
+void Ct_msgstore::ConstructL()
+    {
+    //Read logger settings to check whether test case name is to be
+    //appended to log file name.
+    RSettingServer settingServer;
+    TInt ret = settingServer.Connect();
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        }
+    // Struct to StifLogger settigs.
+    TLoggerSettings loggerSettings; 
+    // Parse StifLogger defaults from STIF initialization file.
+    ret = settingServer.GetLoggerSettings(loggerSettings);
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        } 
+    // Close Setting server session
+    settingServer.Close();
+    iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle;
+
+    iStdLog = CStifLogger::NewL( Kt_msgstoreLogPath, 
+                          Kt_msgstoreLogFile);
+    iLog = iStdLog;
+
+    // Sample how to use logging
+    _LIT( KLogStart, "t_msgstore logging starts!" );
+    iLog->Log( KLogStart );
+
+    iVersionLogged = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Ct_msgstore* Ct_msgstore::NewL()
+    {
+    Ct_msgstore* self = new (ELeave) Ct_msgstore;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+Ct_msgstore::~Ct_msgstore()
+    {
+    iLog = NULL;
+    delete iStdLog;
+    iStdLog = NULL;
+    delete iTCLog;
+    iTCLog = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::InitL
+// InitL is used to initialize the Test Module.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::InitL( 
+    TFileName& /*aIniFile*/, 
+    TBool /*aFirstTime*/ )
+    {
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::GetTestCasesL
+// GetTestCases is used to inquire test cases from the Test Module. Test
+// cases are stored to array of test cases. The Test Framework will be 
+// the owner of the data in the RPointerArray after GetTestCases return
+// and it does the memory deallocation. 
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::GetTestCasesL( 
+    const TFileName& /*aConfig*/, 
+    RPointerArray<TTestCaseInfo>& aTestCases )
+    {
+
+    // Loop through all test cases and create new
+    // TTestCaseInfo items and append items to aTestCase array    
+    for( TInt i = 0; Case(i).iMethod != NULL; i++ )
+        {
+
+        // Allocate new TTestCaseInfo from heap for a testcase definition.
+        TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
+
+        // PushL TTestCaseInfo to CleanupStack.    
+        CleanupStack::PushL( newCase );
+
+        // Set number for the testcase.
+        // When the testcase is run, this comes as a parameter to RunTestCaseL.
+        newCase->iCaseNumber = i;
+
+        // Set title for the test case. This is shown in UI to user.
+        newCase->iTitle.Copy( Case(i).iCaseName );
+
+        // Append TTestCaseInfo to the testcase array. After appended 
+        // successfully the TTestCaseInfo object is owned (and freed) 
+        // by the TestServer. 
+        User::LeaveIfError(aTestCases.Append ( newCase ) );
+
+        // Pop TTestCaseInfo from the CleanupStack.
+        CleanupStack::Pop( newCase );
+
+        }
+
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::RunTestCaseL
+// RunTestCaseL is used to run an individual test case specified 
+// by aTestCase. Test cases that can be run may be requested from 
+// Test Module by GetTestCases method before calling RunTestCase.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::RunTestCaseL( 
+    const TInt aCaseNumber,   
+    const TFileName& /*aConfig*/,
+    TTestResult& aResult )
+    {
+    if(!iVersionLogged)
+    	{
+    	SendTestModuleVersion();
+    	iVersionLogged = ETrue;
+    	}
+    
+    // Return value
+    TInt execStatus = KErrNone;
+
+    // Get the pointer to test case function
+    TCaseInfo tmp = Case ( aCaseNumber );
+
+    _LIT( KLogStartTC, "Starting testcase [%S]" );
+    iLog->Log( KLogStartTC, &tmp.iCaseName);
+
+    // Check that case number was valid
+    if ( tmp.iMethod != NULL )
+        {
+        //Open new log file with test case title in file name
+        if(iAddTestCaseTitleToLogName)
+            {
+            //Delete test case logger if exists
+            if(iTCLog)
+                {
+                delete iTCLog;
+                iTCLog = NULL;
+                }
+
+            TFileName logFileName;
+            TName title;
+            TestModuleIf().GetTestCaseTitleL(title);
+        
+            logFileName.Format(Kt_msgstoreLogFileWithTitle, &title);
+
+            iTCLog = CStifLogger::NewL(Kt_msgstoreLogPath, 
+                                       logFileName);
+            iLog = iTCLog;                                       
+            }
+
+        // Valid case was found, call it via function pointer
+        iMethod = tmp.iMethod;        
+        //execStatus  = ( this->*iMethod )( aResult );
+        TRAPD(err, execStatus  = ( this->*iMethod )( aResult ));
+        if(iAddTestCaseTitleToLogName)
+            {
+            //Restore standard log and destroy test case logger
+            iLog = iStdLog;
+            delete iTCLog; //Close test case log
+            iTCLog = NULL;
+            }
+        User::LeaveIfError(err);
+        }
+    else
+        {
+        // Valid case was not found, return error.
+        execStatus = KErrNotFound;
+        }
+
+    // Return case execution status (not the result of the case execution)
+    return execStatus;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::OOMTestQueryL
+// Used to check if a particular test case should be run in OOM conditions and 
+// which memory allocations should fail.    
+// -----------------------------------------------------------------------------
+//
+TBool Ct_msgstore::OOMTestQueryL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt aCaseNumber, 
+                                TOOMFailureType& /* aFailureType */, 
+                                TInt& aFirstMemFailure, 
+                                TInt& aLastMemFailure ) 
+    {
+    _LIT( KLogOOMTestQueryL, "Ct_msgstore::OOMTestQueryL" );
+    iLog->Log( KLogOOMTestQueryL );     
+
+    aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation;
+    aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation;
+
+    return Case( aCaseNumber ).iIsOOMTest;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::OOMTestInitializeL
+// Used to perform the test environment setup for a particular OOM test case. 
+// Test Modules may use the initialization file to read parameters for Test 
+// Module initialization but they can also have their own configure file or 
+// some other routine to initialize themselves.  
+//
+// NOTE: User may add implementation for OOM test environment initialization.
+// Usually no implementation is required.
+// -----------------------------------------------------------------------------
+//
+void Ct_msgstore::OOMTestInitializeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::OOMHandleWarningL
+// In some cases the heap memory allocation should be skipped, either due to
+// problems in the OS code or components used by the code being tested, or even 
+// inside the tested components which are implemented this way on purpose (by 
+// design), so it is important to give the tester a way to bypass allocation 
+// failures.
+//
+// NOTE: User may add implementation for OOM test warning handling. Usually no
+// implementation is required.
+// -----------------------------------------------------------------------------
+//
+void Ct_msgstore::OOMHandleWarningL( 
+                                const TFileName& /* aTestCaseFile */,
+                                const TInt /* aCaseNumber */, 
+                                TInt& /* aFailNextValue */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::OOMTestFinalizeL
+// Used to perform the test environment cleanup for a particular OOM test case.
+//
+// NOTE: User may add implementation for OOM test environment finalization.
+// Usually no implementation is required.
+// -----------------------------------------------------------------------------
+//
+void Ct_msgstore::OOMTestFinalizeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+//-----------------------------------------------------------------------------
+// Ct_msgstore::SendTestModuleVersion
+// Method used to send version of test module
+//-----------------------------------------------------------------------------
+//
+void Ct_msgstore::SendTestModuleVersion()
+	{
+	TVersion moduleVersion;
+	moduleVersion.iMajor = TEST_MODULE_VERSION_MAJOR;
+	moduleVersion.iMinor = TEST_MODULE_VERSION_MINOR;
+	moduleVersion.iBuild = TEST_MODULE_VERSION_BUILD;
+	
+	TFileName moduleName;
+	moduleName = _L("t_msgstore.dll");
+
+	TBool newVersionOfMethod = ETrue;
+	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
+	}
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point
+// Returns: CTestModuleBase*: Pointer to Test Module object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTestModuleBase* LibEntryL()
+    {
+    return Ct_msgstore::NewL();
+
+    }
+
+// -----------------------------------------------------------------------------
+// SetRequirements handles test module parameters(implements evolution
+// version 1 for test module's heap and stack sizes configuring).
+// Returns: TInt: Symbian error code.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, 
+                                TUint32& /*aParameterValid*/ )
+    {
+
+    /* --------------------------------- NOTE ---------------------------------
+    USER PANICS occurs in test thread creation when:
+    1) "The panic occurs when the value of the stack size is negative."
+    2) "The panic occurs if the minimum heap size specified is less
+       than KMinHeapSize".
+       KMinHeapSize: "Functions that require a new heap to be allocated will
+       either panic, or will reset the required heap size to this value if
+       a smaller heap size is specified".
+    3) "The panic occurs if the minimum heap size specified is greater than
+       the maximum size to which the heap can grow".
+    Other:
+    1) Make sure that your hardware or Symbian OS is supporting given sizes.
+       e.g. Hardware might support only sizes that are divisible by four.
+    ------------------------------- NOTE end ------------------------------- */
+
+    // Normally STIF uses default heap and stack sizes for test thread, see:
+    // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
+    // If needed heap and stack sizes can be configured here by user. Remove
+    // comments and define sizes.
+
+/*
+    aParameterValid = KStifTestModuleParameterChanged;
+
+    CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
+    // Stack size
+    param->iTestThreadStackSize= 16384; // 16K stack
+    // Heap sizes
+    param->iTestThreadMinHeap = 4096;   // 4K heap min
+    param->iTestThreadMaxHeap = 1048576;// 1M heap max
+
+    aTestModuleParam = param;
+*/
+    return KErrNone;
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailstore/tsrc/message_store_test/src/t_msgstoreCases.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,629 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  implementation of test cases methods.
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <e32math.h>
+#include "t_msgstore.h"
+#include "mailboxtests.h"
+#include "propertytests.h"
+#include "foldertests.h"
+#include "messagetests.h"
+#include "parttests.h"
+#include "observertests.h"
+#include "contenttests.h"
+#include "mrutests.h"
+#include "searchtests.h"
+#include "sorttests.h"
+#include "sizetests.h"
+#include "DbCorruptTests.h"
+#include "shutdownservertest.h"
+#include "EncryptionTests.h"
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg)  // ?description
+    {
+
+    ?code  // ?comment
+
+    // ?comment
+    ?code
+    }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::Case
+// Returns a test case by number.
+//
+// This function contains an array of all available test cases 
+// i.e pair of case name and test function. If case specified by parameter
+// aCaseNumber is found from array, then that item is returned.
+// 
+// The reason for this rather complicated function is to specify all the
+// test cases only in one place. It is not necessary to understand how
+// function pointers to class member functions works when adding new test
+// cases. See function body for instructions how to add new test case.
+// -----------------------------------------------------------------------------
+//
+const TCaseInfo Ct_msgstore::Case ( 
+    const TInt aCaseNumber ) const 
+     {
+
+    /**
+    * To add new test cases, implement new test case function and add new 
+    * line to KCases array specify the name of the case and the function 
+    * doing the test case
+    * In practice, do following
+    * 1) Make copy of existing test case function and change its name
+    *    and functionality. Note that the function must be added to 
+    *    t_msgstore.cpp file and to t_msgstore.h 
+    *    header file.
+    *
+    * 2) Add entry to following KCases array either by using:
+    *
+    * 2.1: FUNCENTRY or ENTRY macro
+    * ENTRY macro takes two parameters: test case name and test case 
+    * function name.
+    *
+    * FUNCENTRY macro takes only test case function name as a parameter and
+    * uses that as a test case name and test case function name.
+    *
+    * Or
+    *
+    * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
+    * only with OOM (Out-Of-Memory) testing!
+    *
+    * OOM_ENTRY macro takes five parameters: test case name, test case 
+    * function name, TBool which specifies is method supposed to be run using
+    * OOM conditions, TInt value for first heap memory allocation failure and 
+    * TInt value for last heap memory allocation failure.
+    * 
+    * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
+    * that as a test case name, TBool which specifies is method supposed to be
+    * run using OOM conditions, TInt value for first heap memory allocation 
+    * failure and TInt value for last heap memory allocation failure. 
+    */ 
+
+    static TCaseInfoInternal const KCases[] =
+        {
+        // [test cases entries] - do not remove
+        
+        // NOTE: When compiled to GCCE, there must be Classname::
+        // declaration in front of the method name, e.g. 
+        // Ct_msgstore::PrintTest. Otherwise the compiler
+        // gives errors.
+        ENTRY( "Mailbox Tests",     Ct_msgstore::MailboxTestsL ),
+        ENTRY( "Property Tests",    Ct_msgstore::PropertyTestsL ),
+        ENTRY( "Folder Tests",      Ct_msgstore::FolderTestsL ),
+        ENTRY( "Message Tests",     Ct_msgstore::MessageTestsL ),
+        ENTRY( "Database Corruption Test", Ct_msgstore::DbCorruptTestsL ),
+        ENTRY( "Part Tests",        Ct_msgstore::PartTestsL ),
+        ENTRY( "Observer Tests",    Ct_msgstore::ObserverTestsL ),
+        ENTRY( "Content Tests",     Ct_msgstore::ContentTestsL ),
+        ENTRY( "Mru Tests",         Ct_msgstore::MruTestsL ),
+        ENTRY( "Search Tests",      Ct_msgstore::SearchTestsL ),
+        ENTRY( "Sort Tests",        Ct_msgstore::SortTestsL ),
+        ENTRY( "Encryption Tests",  Ct_msgstore::EncryptionTestsL ),
+        ENTRY( "Size Tests",        Ct_msgstore::SizeTestsL ),
+        // Example how to use OOM functionality
+        //OOM_ENTRY( "Loop test with OOM", Ct_msgstore::LoopTest, ETrue, 2, 3),
+        //OOM_FUNCENTRY( Ct_msgstore::PrintTest, ETrue, 1, 3 ),
+        };
+
+    // Verify that case number is valid
+    if( (TUint) aCaseNumber >= sizeof( KCases ) / 
+                               sizeof( TCaseInfoInternal ) )
+        {
+        // Invalid case, construct empty object
+        TCaseInfo null( (const TText*) L"" );
+        null.iMethod = NULL;
+        null.iIsOOMTest = EFalse;
+        null.iFirstMemoryAllocation = 0;
+        null.iLastMemoryAllocation = 0;
+        return null;
+        } 
+
+    // Construct TCaseInfo object and return it
+    TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
+    tmp.iMethod = KCases[ aCaseNumber ].iMethod;
+    tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
+    tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
+    tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
+    return tmp;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::MailboxTests
+// Test Mailbox operations.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::MailboxTestsL( TTestResult& aResult )
+    {
+    _LIT( KMailboxTests, "Mailbox Tests" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KMailboxTests, KEnter );
+           
+    // Run test cases
+    CMailboxTests* testCase = CMailboxTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KMailboxTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "Mailbox tests passed" );
+    _LIT( KFailDescription, "Mailbox tests failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::PropertyTests
+// Test Property related features.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::PropertyTestsL( TTestResult& aResult )
+    {
+    _LIT( KPropertyTests, "Property Tests" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KPropertyTests, KEnter );
+           
+    // Run test cases
+    CPropertyTests* testCase = CPropertyTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KPropertyTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "Property tests passed" );
+    _LIT( KFailDescription, "Property tests failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::FolderTests
+// Test Folder related features.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::FolderTestsL( TTestResult& aResult )
+    {
+    _LIT( KFolderTests, "Folder Tests" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KFolderTests, KEnter );
+           
+    // Run test cases
+    CFolderTests* testCase = CFolderTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KFolderTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "Folder tests passed" );
+    _LIT( KFailDescription, "Folder tests failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::MessageTests
+// Test Folder related features.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::MessageTestsL( TTestResult& aResult )
+    {
+    _LIT( KMessageTests, "Message Tests" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KMessageTests, KEnter );
+           
+    // Run test cases
+    CMessageTests* testCase = CMessageTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KMessageTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "Message tests passed" );
+    _LIT( KFailDescription, "Message tests failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::PartTests
+// Test Folder related features.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::PartTestsL( TTestResult& aResult )
+    {
+    _LIT( KPartTests, "Part Tests" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KPartTests, KEnter );
+           
+    // Run test cases
+    CPartTests* testCase = CPartTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KPartTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "Part tests passed" );
+    _LIT( KFailDescription, "Part tests failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::ObserverTests
+// Test Folder related features.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::ObserverTestsL( TTestResult& aResult )
+    {
+    _LIT( KObserverTests, "Observer Tests" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KObserverTests, KEnter );
+           
+    // Run test cases
+    CObserverTests* testCase = CObserverTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KObserverTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "Observer tests passed" );
+    _LIT( KFailDescription, "Observer tests failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::ContentTests
+// Test Folder related features.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::ContentTestsL( TTestResult& aResult )
+    {
+    _LIT( KContentTests, "Content Tests" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KContentTests, KEnter );
+           
+    // Run test cases
+    CContentTests* testCase = CContentTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KContentTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "Content tests passed" );
+    _LIT( KFailDescription, "Content tests failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::MruTests
+// Test Folder related features.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::MruTestsL( TTestResult& aResult )
+    {
+    _LIT( KMruTests, "Mru Tests" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KMruTests, KEnter );
+           
+    // Run test cases
+    CMruTests* testCase = CMruTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KMruTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "MRU tests passed" );
+    _LIT( KFailDescription, "MRU tests failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::SearchTests
+// Test Folder related features.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::SearchTestsL( TTestResult& aResult )
+    {
+    _LIT( KSearchTests, "Search Tests" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KSearchTests, KEnter );
+           
+    // Run test cases
+    CSearchTests* testCase = CSearchTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KSearchTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "Search tests passed" );
+    _LIT( KFailDescription, "Search tests failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::SortTests
+// Test Folder related features.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::SortTestsL( TTestResult& aResult )
+    {
+    _LIT( KSortTests, "Sort Tests" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KSortTests, KEnter );
+           
+    // Run test cases
+    CSortTests* testCase = CSortTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KSortTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "Sort tests passed" );
+    _LIT( KFailDescription, "Sort tests failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::SizeTests
+// Test Folder related features.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::EncryptionTestsL( TTestResult& aResult )
+    {
+    _LIT( KEncryptionTests, "Encryption Tests" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KEncryptionTests, KEnter );
+           
+    // Run test cases
+    CEncryptionTests* testCase = CEncryptionTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KEncryptionTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "Encryption tests passed" );
+    _LIT( KFailDescription, "Encryption tests failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::SizeTests
+// Test Folder related features.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::SizeTestsL( TTestResult& aResult )
+    {
+    _LIT( KSizeTests, "Size Tests" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KSizeTests, KEnter );
+           
+    // Run test cases
+    CSizeTests* testCase = CSizeTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KSizeTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "Size tests passed" );
+    _LIT( KFailDescription, "Size tests failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Ct_msgstore::DbCorruptTests
+// Test Folder related features.
+// -----------------------------------------------------------------------------
+//
+TInt Ct_msgstore::DbCorruptTestsL( TTestResult& aResult )
+    {
+    _LIT( KDbCorruptTests, "Database Corruption Test" );
+    _LIT( KEnter, "Enter" );
+    _LIT( KExit, "Exit" );
+
+    TestModuleIf().Printf( 0, KDbCorruptTests, KEnter );
+           
+    // Run test cases
+    CDbCorruptTests* testCase = CDbCorruptTests::NewL( iLog );
+    CActiveScheduler::Start();
+    
+    TInt result = testCase->Result();    
+    
+    delete testCase;
+    
+    TestModuleIf().Printf( 0, KDbCorruptTests, KExit );
+    
+    // Sets test case result and description(Maximum size is KStifMaxResultDes)
+    _LIT( KPassDescription, "Database Corruption Tests test passed" );
+    _LIT( KFailDescription, "Database Corruption Tests test failed" );
+    aResult.SetResult( result, (result==KErrNone ? KPassDescription : KFailDescription) );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+/*
+?type  ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg )  // ?description
+    {
+
+    ?code
+
+    }
+*/
+//  [End of File] - do not remove
--- a/emailuis/emailui/data/FreestyleEmailUi.rss	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/data/FreestyleEmailUi.rss	Thu Jan 07 12:38:38 2010 +0200
@@ -304,10 +304,9 @@
                     AVKON_BUTTON_STATE
                         {
                         helptxt = qtn_fse_message_list_options_expand_all;
-                        txt = qtn_fse_message_list_options_expand_all;
-//                        bmpfile = EMAILUI_ICON_FILE;
-//                        bmpid=EMbmFreestyleemailuiQgn_indi_tb_expand_all;
-//                        bmpmask=EMbmFreestyleemailuiQgn_indi_tb_expand_all_mask;
+                        bmpfile = EMAILUI_ICON_FILE;
+                        bmpid=EMbmFreestyleemailuiQgn_indi_tb_expand_all;
+                        bmpmask=EMbmFreestyleemailuiQgn_indi_tb_expand_all_mask;
                         }
                     };            
                 };
@@ -324,10 +323,9 @@
                     AVKON_BUTTON_STATE
                         {
                         helptxt = qtn_fse_message_list_options_collapse_all;
-                        txt = qtn_fse_message_list_options_collapse_all;
-//                        bmpfile = EMAILUI_ICON_FILE;
-//                        bmpid=EMbmFreestyleemailuiQgn_indi_tb_collapse_all;
-//                        bmpmask=EMbmFreestyleemailuiQgn_indi_tb_collapse_all_mask;
+                        bmpfile = EMAILUI_ICON_FILE;
+                        bmpid=EMbmFreestyleemailuiQgn_indi_tb_collapse_all;
+                        bmpmask=EMbmFreestyleemailuiQgn_indi_tb_collapse_all_mask;
                         }
                     };            
                 };
@@ -496,39 +494,25 @@
                                     }  
                                 };            
                             };
-                        },                                    
-                    TBAR_CTRL
-                        {
-                        type = EAknCtButton;
-                        id = EFsEmailUiTbCmdForward;
-                        control = AVKON_BUTTON
-                            {
-                            flags = KAknButtonRequestExitOnButtonUpEvent;
-                            states =
-                                {
-                                AVKON_BUTTON_STATE
-                                    {
-                                    txt = qtn_fse_tb_ext_forward;
-                                    bmpfile = EMAILUI_ICON_FILE;
-                                    bmpid=EMbmFreestyleemailuiQgn_indi_tb_email_forward;
-                                    bmpmask=EMbmFreestyleemailuiQgn_indi_tb_email_forward_mask;                        
-                                    }  
-                                };            
-                            };
-                        } 
+                        }
                     }; // eof extension items
                 }; // eof AVKON_TOOLBAR_EXTENSION control
             },
         TBAR_CTRL
             {
             type = EAknCtButton;
+            id = EFsEmailUiTbCmdForward;
             control = AVKON_BUTTON
                 {
-                flags = KAknButtonSizeFitText;
+                flags = KAknButtonRequestExitOnButtonUpEvent;
                 states =
                     {
                     AVKON_BUTTON_STATE
                         {
+                        helptxt = qtn_fse_tb_ext_forward;
+                        bmpfile = EMAILUI_ICON_FILE;
+                        bmpid=EMbmFreestyleemailuiQgn_indi_tb_email_forward;
+                        bmpmask=EMbmFreestyleemailuiQgn_indi_tb_email_forward_mask;                        
                         }  
                     };            
                 };
@@ -567,60 +551,8 @@
         {
         TBAR_CTRL
             {
-            type = EAknCtToolbarExtension;
-            id = EFsEmailUiTbCmdActions;
-            control = AVKON_TOOLBAR_EXTENSION
-                {
-                helptxt = qtn_fse_tb_actions;
-                bmpFile = EMAILUI_ICON_FILE;
-                bmpId = EMbmFreestyleemailuiQgn_indi_tb_email_extend;
-                bmpMask = EMbmFreestyleemailuiQgn_indi_tb_email_extend_mask;
-                items =
-                    {
-                    TBAR_CTRL
-                        {
-                        type = EAknCtButton;
-                        id = EFsEmailUiTbCmdReply;
-                        control = AVKON_BUTTON
-                            {
-                            flags = KAknButtonSizeFitText;
-                            states =
-                                {
-                                AVKON_BUTTON_STATE
-                                    {
-                                    txt = qtn_fse_tb_ext_reply;
-                                    bmpfile = EMAILUI_ICON_FILE;
-                                    bmpid=EMbmFreestyleemailuiQgn_indi_tb_email_reply;
-                                    bmpmask=EMbmFreestyleemailuiQgn_indi_tb_email_reply_mask;                        
-                                    }  
-                                };            
-                            };
-                        },
-                    TBAR_CTRL
-                        {
-                        type = EAknCtButton;
-                        id = EFsEmailUiTbCmdForward;
-                        control = AVKON_BUTTON
-                            {
-                            flags = KAknButtonRequestExitOnButtonUpEvent;
-                            states =
-                                {
-                                AVKON_BUTTON_STATE
-                                    {
-                                    txt = qtn_fse_tb_ext_forward;
-                                    bmpfile = EMAILUI_ICON_FILE;
-                                    bmpid=EMbmFreestyleemailuiQgn_indi_tb_email_forward;
-                                    bmpmask=EMbmFreestyleemailuiQgn_indi_tb_email_forward_mask;                        
-                                    }  
-                                };            
-                            };
-                        } 
-                    }; // eof extension items
-                }; // eof AVKON_TOOLBAR_EXTENSION control
-            },
-        TBAR_CTRL
-            {
             type = EAknCtButton;
+            id = EFsEmailUiTbCmdReply;
             control = AVKON_BUTTON
                 {
                 flags = KAknButtonSizeFitText;
@@ -628,6 +560,29 @@
                     {
                     AVKON_BUTTON_STATE
                         {
+                        helptxt = qtn_fse_tb_ext_reply;
+                        bmpfile = EMAILUI_ICON_FILE;
+                        bmpid=EMbmFreestyleemailuiQgn_indi_tb_email_reply;
+                        bmpmask=EMbmFreestyleemailuiQgn_indi_tb_email_reply_mask;                        
+                        }  
+                    };            
+                };
+            },        
+        TBAR_CTRL
+            {
+            type = EAknCtButton;
+            id = EFsEmailUiTbCmdForward;
+            control = AVKON_BUTTON
+                {
+                flags = KAknButtonRequestExitOnButtonUpEvent;
+                states =
+                    {
+                    AVKON_BUTTON_STATE
+                        {
+                        helptxt = qtn_fse_tb_ext_forward;
+                        bmpfile = EMAILUI_ICON_FILE;
+                        bmpid=EMbmFreestyleemailuiQgn_indi_tb_email_forward;
+                        bmpmask=EMbmFreestyleemailuiQgn_indi_tb_email_forward_mask;                        
                         }  
                     };            
                 };
@@ -1002,6 +957,7 @@
 RESOURCE TBUF r_freestyle_email_fetch_from_remote_query	{ buf=qtn_fse_query_no_phone_number_found_search_server; }
 RESOURCE TBUF r_freestyle_email_query_sync_status_go_online	{ buf=qtn_fse_launcher_options_go_online; }
 RESOURCE TBUF r_freestyle_email_query_sync_status_go_offline	{ buf=qtn_fse_launcher_options_go_offline; }
+RESOURCE TBUF r_freestyle_email_mail_deleted                    { buf=qtn_fse_mail_deleted_note; }
 // ** Added 26.2.2008 **
 RESOURCE TBUF r_freestyle_email_confirm_note_sending_queued		{ buf=qtn_fse_confirm_note_sending_queued; }
 RESOURCE TBUF r_freestyle_email_confirm_note_queued_until_online	{ buf=qtn_fse_confirm_note_queued_until_online; }
@@ -1157,7 +1113,7 @@
 RESOURCE TBUF r_freestyle_email_ui_dropdown_list_drafts				{ buf=qtn_fse_message_list_draft; }
 RESOURCE TBUF r_freestyle_email_ui_dropdown_list_sent				{ buf=qtn_fse_message_list_sent; }
 RESOURCE TBUF r_freestyle_email_ui_dropdown_list_deleted			{ buf=qtn_fse_message_list_deleted_items; }
-RESOURCE TBUF r_freestyle_email_ui_dropdown_list_more_folders		{ buf=gtn_cmail_command_area_select_folders; }
+RESOURCE TBUF r_freestyle_email_ui_dropdown_list_more_folders		{ buf=qtn_cmail_command_area_select_folders; }
 
 RESOURCE TBUF r_freestyle_email_ui_folder_list_message_count		{ buf=qtn_fse_folder_list_message_count; }
 RESOURCE TBUF r_freestyle_email_ui_folder_list_message_count_with_unread	{ buf=qtn_fse_folder_list_message_count_with_unread; }
@@ -2756,6 +2712,11 @@
     {
     buf = qtn_mail_launcher_settings_delete_multiple_mailboxes_query;
     }
+    
+RESOURCE TBUF r_command_area_new_email
+    {
+    buf = qtn_cmail_command_area_new;
+    }
 
 // -----------------------------------------------------------------------------
 //   r_delete_mailboxes_multi_selection_query
@@ -2831,6 +2792,24 @@
             }
         };
     }
+
+//-----------------------------------------------------------------------------
+// Stylus long tap pop-up menu in launcher grid view.
+//-----------------------------------------------------------------------------
+//
+RESOURCE STYLUS_POPUP_MENU r_stylus_popup_menu_launcher_grid_view
+    {
+    items =
+		{
+        STYLUS_POPUP_MENU_ITEM
+            {
+				// Delete mailbox.
+                txt = qtn_mail_options_delete_mailbox;
+                command = EFsEmailUiCmdDeleteSelectedMailbox; 
+            }
+        };
+    }
+
 #include "FreestyleEmailUiGlobalSettings.rssi"
 #include "FreestyleEmailUiSettingsList.rssi"
 #include "FreestyleEmailUiSendAttachmentList.rssi"
--- a/emailuis/emailui/data/html/email.html	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/data/html/email.html	Thu Jan 07 12:38:38 2010 +0200
@@ -1,10 +1,10 @@
 <html>
 
-<frameset rows="10%,*" border=0>
+<frameset rows="10%,*" border=0 id="headerBody">
 
 <frame src="header.html" >
 <frame src="temp/body.html" >
 
 </frameset>
 
-</html>
\ No newline at end of file
+</html>
--- a/emailuis/emailui/data/html/header.js	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/data/html/header.js	Thu Jan 07 12:38:38 2010 +0200
@@ -1,11 +1,13 @@
 function collapseHeader()
 	{
 	handleHeaderDisplay( "header_table", "table_initial" )
+	parent.document.getElementById('headerBody').rows = '10%,*';
 	}
 	
 function expandHeader()
 	{
 	handleHeaderDisplay( "table_initial", "header_table" )
+	parent.document.getElementById('headerBody').rows = '40%,*';
 	}
 	
 function handleHeaderDisplay( tableToHide, tableToShow )
--- a/emailuis/emailui/data/iconlist.txt	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/data/iconlist.txt	Thu Jan 07 12:38:38 2010 +0200
@@ -61,6 +61,8 @@
 -c16,8 qgn_indi_cmail_unread_replied_high_prio.svg
 -c16,8 qgn_indi_cmail_unread_replied_low_prio.svg
 -c16,8 qgn_indi_cmail_attachment.svg
+-c16,8 qgn_indi_navi_follow_up_complete.svg
+-c16,8 qgn_indi_navi_follow_up.svg
 -c16,8 qgn_indi_cmail_viewer_follow_up_complete.svg
 -c16,8 qgn_indi_cmail_viewer_follow_up.svg
 -c16,8 qgn_indi_cmail_launcher_info.svg
@@ -164,3 +166,19 @@
 -c16,8 qgn_prop_group_collapsed.svg
 -c16,8 qgn_indi_tb_email_extend.svg
 -c16,8 qgn_indi_tb_email_reply_all.svg
+-c16,8 qgn_prop_email_sort_attach_asc.svg
+-c16,8 qgn_prop_email_sort_attach_desc.svg
+-c16,8 qgn_prop_email_sort_date_asc.svg
+-c16,8 qgn_prop_email_sort_date_desc.svg 
+-c16,8 qgn_prop_email_sort_follow_asc.svg
+-c16,8 qgn_prop_email_sort_follow_desc.svg
+-c16,8 qgn_prop_email_sort_priority_asc.svg
+-c16,8 qgn_prop_email_sort_priority_desc.svg
+-c16,8 qgn_prop_email_sort_sender_asc.svg
+-c16,8 qgn_prop_email_sort_sender_desc.svg 
+-c16,8 qgn_prop_email_sort_subject_asc.svg
+-c16,8 qgn_prop_email_sort_subject_desc.svg
+-c16,8 qgn_prop_email_sort_unread_asc.svg 
+-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
--- a/emailuis/emailui/group/FreestyleEmailUiIcons.mk	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/group/FreestyleEmailUiIcons.mk	Thu Jan 07 12:38:38 2010 +0200
@@ -106,8 +106,8 @@
 	/c16,8 $(SOURCEDIR)\qgn_indi_cmail_unread_replied_high_prio.svg \
 	/c16,8 $(SOURCEDIR)\qgn_indi_cmail_unread_replied_low_prio.svg \
 	/c16,8 $(SOURCEDIR)\qgn_indi_cmail_attachment.svg \
-	/c16,8 $(SOURCEDIR)\qgn_indi_cmail_viewer_follow_up_complete.svg \
-	/c16,8 $(SOURCEDIR)\qgn_indi_cmail_viewer_follow_up.svg \
+	/c16,8 $(SOURCEDIR)\qgn_indi_navi_follow_up_complete.svg \
+	/c16,8 $(SOURCEDIR)\qgn_indi_navi_follow_up.svg \
 	/c16,8 $(SOURCEDIR)\qgn_indi_cmail_launcher_info.svg \
 	/c16,8 $(SOURCEDIR)\qgn_indi_cmail_launcher_remote_lookup.svg \
 	/c16,8 $(SOURCEDIR)\qgn_indi_cmail_launcher_inbox.svg \
--- a/emailuis/emailui/inc/FSComposerFetchLogic.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FSComposerFetchLogic.h	Thu Jan 07 12:38:38 2010 +0200
@@ -48,7 +48,9 @@
 class MComposerFetchLogicCallback
 	{
 public:
-    virtual void FetchLogicComplete( TComposerFetchState aState, TInt aError ) = 0;
+    // Returns ETrue if the corresponding CFsComposerFetchLogic object has
+    // been deleted.
+    virtual TBool FetchLogicComplete( TComposerFetchState aState, TInt aError ) = 0;
 	};
 	
 	
--- a/emailuis/emailui/inc/FreestyleEmailUi.hrh	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUi.hrh	Thu Jan 07 12:38:38 2010 +0200
@@ -121,6 +121,7 @@
     {
 	EFsEmailUiCmdOpen = 2000,
 	EFsEmailUiCmdDeleteMailbox,
+	EFsEmailUiCmdDeleteSelectedMailbox,
 	EFsEmailUiCmdExit,
 	EFsEmailUiCmdSync,
 	EFsEmailUiCmdSyncAll,
--- a/emailuis/emailui/inc/FreestyleEmailUiAppui.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiAppui.h	Thu Jan 07 12:38:38 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,11 +14,11 @@
 * Description:  FreestyleEmailUiAppUi class definition
 *
 */
- 
+
 
 #ifndef __FREESTYLEEMAILUI_APPUI_H__
 #define __FREESTYLEEMAILUI_APPUI_H__
-  
+
 // SYSTEM INCLUDES
 #include <aknViewAppUi.h>
 //<cmail> SF
@@ -48,7 +48,7 @@
 #include "FreestyleEmailUiPropertySubscriber.h"
 #include "FreestyleEmailUiConstants.h"
 
-enum TForcedStatus 
+enum TForcedStatus
 	{
     ENoForce = 0,
     EForceToSync,
@@ -142,7 +142,7 @@
     void ProcessCommandL( TInt aCommand );
 	// </cmail>
 	void HandleCommandL( TInt aCommand );
-	
+
 	// View switching functions
 	void EnterFsEmailViewL( TUid aViewId );
 	void EnterFsEmailViewL( TUid aViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage );
@@ -157,12 +157,12 @@
 	 * Tries to activate the local view where the current view was navigated from.
 	 * Activates the grid view if no other previous view available.
 	 * @return UID of the view to be activated
-	 */ 
+	 */
 	TUid ReturnToPreviousViewL( const TDesC8& aCustomMessage = KNullDesC8 );
 
 	void ReturnFromHtmlViewerL( TBool aMessageWasDeleted = EFalse );
 
-    // Clears the navigation history used with Back functionality. 
+    // Clears the navigation history used with Back functionality.
     // Thus, next call to ReturnToPreviousViewL() will return to the main grid.
     void EraseViewHistory();
 
@@ -175,7 +175,7 @@
     CFsEmailUiViewBase* PreviousActiveView();
     // Tells if plugin settings view is currently open
     TBool IsPluginSettingsViewActive();
-	
+
 	// getter to generic components
 	CFSEmailUiLayoutHandler* LayoutHandler();
 	CFreestyleEmailUiTextureManager* FsTextureManager();
@@ -183,9 +183,9 @@
 
 	// Functions used by grid and viewer
 	TInt NewEmailsInModelL();
-	TInt EmailsInModelL();	  
+	TInt EmailsInModelL();
 	TInt EmailIndexInModel();
-		
+
     /**
     * LaunchEditorL
     * Launch editor with the given address in TO-field and focus in MSG-field
@@ -193,7 +193,7 @@
     * is not transferred.
     */
 	void LaunchEditorL( CFSMailAddress* aToAddress );
-	
+
     /**
     * LaunchEditorL
     * Launch editor
@@ -201,10 +201,10 @@
     * @param aParams Editor launch parameters
     */
 	void LaunchEditorL( TEditorLaunchMode aMode, const TEditorLaunchParams& aParams );
-	
+
 	CFSMailClient* GetMailClient();
 	CFSEmailCRHandler* GetCRHandler();
-	
+
 	// Gets active mailbox pointer from the UI
 	// Ownership IS NOT transferred to the callers
 	CFSMailBox* GetActiveMailbox();
@@ -215,11 +215,11 @@
 
 	TFSMailMsgId GetActiveBoxInboxId();
 	TFSMailMsgId GetActiveMailboxId();
-	
+
     /**
     * Show folder list or sort list as control bar popup list.
-    * 
-    * @param aCurrentSortOrder Current sort order in mail list
+    *
+    * @param aCurrentSortCriteria Current sort criteria in mail list
     * @param aFolderId/Type Folder id/type of the currently active mail folder
     * @param aCallback Callback pointer to use when reporting user selection
     * @param aButton Selected control bar button, used when positioning the list
@@ -227,21 +227,21 @@
 	void ShowFolderListInPopupL( const TFSMailMsgId aFolderType,
                                  MFSEmailUiFolderListCallback* aCallback,
 								 MFsControlButtonInterface* aButton );
-	void ShowSortListInPopupL( const TFSMailSortField aCurrentSortOrder,
+	void ShowSortListInPopupL( const TFSMailSortCriteria aCurrentSortCriteria,
 	                           const TFSFolderType aFolderType,
 							   MFSEmailUiSortListCallback* aCallback,
 							   MFsControlButtonInterface* aButton );
 	void FolderPopupClosed();
-	
+
 	// Transition effects for Alf layouts, call these in doactivate and dodeactivate.
 	TBool ViewSwitchingOngoing();
-	
+
 	// Force Sync on active mailbox.
 	void SyncActiveMailBoxL();
-	
+
 	// Stop mailbox sync
 	void StopActiveMailBoxSyncL();
-	
+
 	// From sync observer
 	void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
 
@@ -249,19 +249,20 @@
      * Helper method to be called from Settings. Launches mailbox setup wizard.
      */
      void LaunchWizardL();
-    
+
     // Overriden exit
     void Exit();
 
     void ExitNow();
 
     const CFSEmailUiShortcutBinding& ShortcutBinding() const;
-   
+
     // Navigation functions, used mainly from viewer
     TBool IsNextMsgAvailable( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundNextMsgId, TFSMailMsgId& aFoundNextMsgFolder );
     TBool IsPreviousMsgAvailable( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId, TFSMailMsgId& aFoundPrevMsgFolder );
     TInt MoveToNextMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundNextMsgId );
     TInt MoveToPreviousMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId );
+    TInt MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId );
 
     /** Returns document handler. */
     CDocumentHandler& DocumentHandler();
@@ -300,41 +301,41 @@
     // MessageReader implementation
     void StartReadingEmailsL();
     TBool MessageReaderSupportsFreestyle();
-    
+
     static TBool AppUiExitOngoing();
 
-    // Meeting request viewer instance, owned by the appui	
-    CESMRIcalViewer* MrViewerInstanceL();	
+    // Meeting request viewer instance, owned by the appui
+    CESMRIcalViewer* MrViewerInstanceL();
 
     // Get Mail viewer instance, owned by the AppUi
-    CFsEmailUiHtmlViewerView& MailViewer(); 
-    
+    CFsEmailUiHtmlViewerView& MailViewer();
+
     // Get Folder list instance, owned by the AppUi
     CFSEmailUiFolderListVisualiser& FolderList();
-    
+
     // Get Launcher grid instance, owned by the AppUi
     CFSEmailUiLauncherGridVisualiser& LauncherGrid();
-    
+
     // View loading in idle
     TInt ViewLoadIdleCallbackFunctionL();
-    
+
     /**
-     * Sets the manual mailbox syncronisation/connection flag if the    
+     * Sets the manual mailbox syncronisation/connection flag if the
      * user chose to synchorise/connect mail boxes from the menu
      */
     void ManualMailBoxSync( TBool aManualMailBoxSync );
     void ManualMailBoxSyncAll( TBool aManualMailBoxSyncAll );
     void ManualMailBoxConnectAll( TBool aManualMailBoxConnectAll );
     void ManualMailBoxDisconnectAll( TBool aManualMailBoxConnectAll );
-	
-	// For showing mailbox query    
+
+	// For showing mailbox query
 	void GridStarted( TBool aStartedFromOds );
     void ShowMailboxQueryL();
-    
+
     void DoAutoConnectL();
-    
+
     CFSEmailDownloadInfoMediator* DownloadInfoMediator();
-    
+
     // <cmail>
     TDisplayMode DisplayMode() const;
     // </cmail>
@@ -348,7 +349,7 @@
 
 public: //from MFSMailEventObserver
     /**
-     * Framework event message. 
+     * Framework event message.
      * Used here to catch the events thrown from new mailbox creation process.
      *
      * @param aEvent One of pre-defined events in TFSMailEvent
@@ -357,10 +358,10 @@
      * @param aParam2 intepretation is event specific (see TFSMailEvent descriptions)
      * @param aParam3 intepretation is event specific (see TFSMailEvent descriptions)
      */
-    void EventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox, 
+    void EventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox,
                  TAny* aParam1, TAny* aParam2, TAny* aParam3);
-                 
-public:              
+
+public:
 	void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3 );
 
 public: // MIAUpdateObserver
@@ -368,7 +369,7 @@
     virtual void UpdateQueryComplete( TInt aErrorCode, TBool aUpdateNow );
     virtual void UpdateComplete( TInt aErrorCode, CIAUpdateResult* aResultDetails );
 
-public:	
+public:
 
     /**
     * StartEndKeyCapture
@@ -389,30 +390,29 @@
      * @return instance of correct navidecorator. NULL if aView doesn't match.
      */
     CAknNavigationDecorator* NaviDecoratorL( const TUid aViewId );
-    
+
 public:
-    
-    virtual void TimerEventL( CFSEmailUiGenericTimer* aTriggeredTimer );
-    
+
     /**
-    * CancelFocusRemovalTimer
-    * Cancels focus removal timer
-    */
-    void CancelFocusRemovalTimer();
-    
+     * From MFSEmailUiGenericTimerCallback.
+     * Generic timer event callback.
+     */
+    virtual void TimerEventL( CFSEmailUiGenericTimer* aTriggeredTimer );
+
     /**
-    * StartFocusRemovalTimer
-    * Starts focus removal timer
-    * @return whether or not timer was active already.
+    * Sets visibility for focus.
+    *
+    * @param aVisible EFalse if focus should be hidden.
+    * @return whether or not focus was already visible.
     */
-    TBool StartFocusRemovalTimer();
-    
+    TBool SetFocusVisibility( TBool aVisible );
+
     /**
-    * IsTimerFocusShown
-    * Used for finding out if the timer focus is already visible
-    * @return whether or not the timer focus is visible.
+    * IsFocusShown
+    * Used for finding out if focus is visible.
+    * @return whether or not the focus is visible.
     */
-    TBool IsTimerFocusShown() const;
+    TBool IsFocusShown() const;
 
 
 public: // From MFreestyleEmailUiPropertyChangedObserver.
@@ -420,45 +420,45 @@
 	void PropertyChangedL( TInt aValue );
 
 
-protected: 
+protected:
 	TKeyResponse HandleKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
     void HandleResourceChangeL(TInt aType);
-	void HandleWsEventL(const TWsEvent &aEvent, 
+	void HandleWsEventL(const TWsEvent &aEvent,
  	                    CCoeControl *aDestination);
- 	
+
  	void HandleForegroundEventL( TBool aForeground );
     MCoeMessageObserver::TMessageResponse HandleMessageL( TUint32 aClientHandleOfTargetWindowGroup,
                                                           TUid aMessageUid,
                                                           const TDesC8& aMessageParameters );
- 
+
 private:
     void DoHandleResourceChangeL(TInt aType);
 	void UpdateSettingsListModelL();
 	CAlfTexture& LoadItemIconL( TInt aUid );
-    void ProvideBitmapL(TInt aId, CFbsBitmap*& aBitmap, 
+    void ProvideBitmapL(TInt aId, CFbsBitmap*& aBitmap,
                                   CFbsBitmap*& aMaskBitmap);
-    
+
     /**
      * Helper method for launching a setup wizard, or handling data received from one.
      */
     void DoWizardStartupActionsL();
-        
+
     TBool IsViewInHistoryStack( TUid aViewId ) const;
-    
+
     void ReturnToViewL( TUid aViewId, TUid aCustomMessageId = TUid::Null(), const TDesC8& aCustomMessage = KNullDesC8 );
-    
+
     // Checks updates from IAD client
     void CheckUpdatesL();
     void AllUpdateActivitiesCompleted();
 
 	// This async callback functionality is needed because UI and app construction
-	// cannot jam while the new mailbox query has been displayed     
+	// cannot jam while the new mailbox query has been displayed
    	static TInt DisplayCreateQueryL( TAny* aSelfPtr );
    	void DisplayCreateMailboxQueryL();
-   	
+
    	// Send self to background.
    	void SendToBackground();
-    
+
    	/*
    	 * Called from ConstructL during start of application.
    	 * Constructs navipane(s) that are used by different views.
@@ -469,32 +469,26 @@
     void CreateStatusPaneIndicatorsL();
     // Delete custom status pane indicators
     void DeleteStatusPaneIndicators();
-    
-   	/*
-   	 * FocusTimerCallBack
-   	 * Called when focus removal timer expires
-   	 */
-    static TInt FocusTimerCallBack(TAny* aAny);
-    
-   	/*
-   	 * DoFocusTimerCallBack
-   	 * Called when focus removal timer expires
-   	 */
-    TInt DoFocusTimerCallBack();
-    
-   	
+
+    // Load specified resource file, file name may (and should) contain wild
+    // cards. aFilePath should contain drive letter if some specific drive
+    // is wanted to be searched first. Returns the resource file offset of the
+    // found file. Leaves if resource file not found.
+    TInt LoadResourceFileL( const TDesC& aFileName,
+                            const TDesC& aFilePath );
+
 private:
 	// ALF environment NOTE: Display removed from Alfred version
     CAlfEnv* iEnv;
-     
+
     // Pointers to current and previous active views
     CFsEmailUiViewBase* iCurrentActiveView; // not owned
     CFsEmailUiViewBase* iPreviousActiveView; // not owned
     CStack<CFsEmailUiViewBase, EFalse>* iNavigationHistory; // items not owned
- 
+
  	CFSEmailDownloadInfoMediator* iDwnldMediator;
- 
-     // Pointers to actual display control groups containing UI elements      
+
+     // Pointers to actual display control groups containing UI elements
     CAlfControlGroup* iGridControlGroup;
   	CAlfControlGroup* iMailListControlGroup;
     CAlfControlGroup* iEmailViewerControlGroup;
@@ -508,7 +502,7 @@
   	CAlfControlGroup* iSearchResultControlGroup;
   	CAlfControlGroup* iStatusIndicatorControlGroup;
   	CAlfControlGroup* iHtmlViewerControlGroup;
-  
+
  	// FS Email UI specific layout handler object
     CFSEmailUiLayoutHandler* iLayoutHandler;
 
@@ -516,13 +510,13 @@
         //<cmail> layout manager doesn't exists in cmail
 	//CFsLayoutManager* iLayoutManager;
         //</cmail>
-	
+
 	// FS Email UI specific texture mngr object
  	CFreestyleEmailUiTextureManager* iFsTextureManager;
 
 	// Main UI grid control and view
   	CFSEmailUiLauncherGrid* iMainUiGrid;
-    CFSEmailUiLauncherGridVisualiser* iMainUiGridVisualiser;	
+    CFSEmailUiLauncherGridVisualiser* iMainUiGridVisualiser;
 
 	// Mail view
 	CFSEmailUiMailListVisualiser* iMailListVisualiser;
@@ -541,11 +535,11 @@
 
 	// Folder list view
 	CFSEmailUiFolderListVisualiser* iFolderListVisualiser;
-	
+
 	// Attachment list
 	CFSEmailUiAttachmentsListVisualiser* iAttachmentListVisualiser;
 	CFreestyleEmailUiAttachmentsListControl* iAttachmentHanlerControl;
-	
+
     // Download manager removed.
 
 	// Search result list view
@@ -557,74 +551,74 @@
     // Mailclient, list of mailboxes, active mailbox and
     // latest opened folder
     CFSMailClient* iMailClient;
- 
+
  	// Active mailbox, pointer owned by the APP UI!
  	CFSMailBox* iActiveMailbox;
 
 	TFSMailMsgId iActiveBoxInboxId;
 	TFSMailMsgId iActiveMailboxId;
- 
+
 	// Mail sending progress dialog
 	CAknProgressDialog* iSendingProgressDialog;
 	CEikProgressInfo* iSendingProgressInfo;
-	
+
 	// Phonebook engine and resource handle
 	TInt iPhCltResHandle;
-	
+
 	// Central repository handler
 	CFSEmailCRHandler*	iCRHandler;
-	
+
 	// End key capture handles
 	TInt32 iEndCaptureHandle;
 	TInt32 iEndUpDownCaptureHandle;
-	
+
     CMsvSession* iMsvSession;
 
     CFSEmailUiActionMenu* iActionMenuHandler;
-    
+
 	RArray<TFSMailMsgId> iSubscribedMailBoxes;
 	RArray<TUint> iSubscribedMailBoxesIds;
-	
+
 
 	// Helper class for keyboard shortcut handling
 	CFSEmailUiShortcutBinding* iShortcutBinder;
-	
+
 	CFSEmailUiWizardObserver* iWizardObserver;
 
     CDocumentHandler* iDocumentHandler;
     CFsEmailFileHandleShutter* iFileHandleShutter;
 
 	TBool iConstructComplete;
-	
+
 	TInt iSyncStatusReqId;
-	
+
 	TBool iIsForeground;
-	
+
   	CIdle* iViewLoadIdle;
 	TCallBack* iViewLoadIdleCallback;
 	TBool iIsCaptured;
-	
-    CVPbkContactManager* iVpkContactManager; 
-    
+
+    CVPbkContactManager* iVpkContactManager;
+
     //This is used to pass needed information to messagereader
 	HBufC8* iCustomMessageToMessageReader;
-	
-	// Meeting request viewer instance	
-  	CESMRIcalViewer* iMRViewer;	
-  	
-  	// Flag to be used to disable online/offline note in automated 
+
+	// Meeting request viewer instance
+  	CESMRIcalViewer* iMRViewer;
+
+  	// Flag to be used to disable online/offline note in automated
   	// Mailbob online
   	TBool iAutomatedMailBoxOnline;
-  	
+
 	// Value indicating that msg reader is supported, KErrNone if supported.
   	TInt iMsgReaderIsSupported;
   	// For IAD
     CIAUpdate* iUpdateClient;
     CIAUpdateParameters* iUpdateParameters;
-    
+
     // For feature manager
     TBool iFeatureManagerInitialized;
-    
+
     //ETrue if user started the sync/connect all
     TBool iManualMailBoxSync;
     TBool iManualMailBoxSyncAll;
@@ -633,33 +627,33 @@
 
     // ETrue if the screen layout has chaged while the application was on background
     TBool iPendingLayoutSwitch;
-    
+
     // Startup mailbox creation query flag.
-    TBool iStartupQueryShown;	
+    TBool iStartupQueryShown;
     TBool iGridStarted;
-    TBool iGridFirstStartFromOds; 
+    TBool iGridFirstStartFromOds;
     TBool iSettingsViewActive;
     TBool iIADUpdateCompleted;
-    
-    CFSEmailUiAutosyncMonitor* iAutoSyncMonitor; 
- 
+
+    CFSEmailUiAutosyncMonitor* iAutoSyncMonitor;
+
     // Async callback for create mailbox query
-    // This is needed because query can not stop execution of UI construction      	
+    // This is needed because query can not stop execution of UI construction
     CAsyncCallBack* iNewBoxQueryAsyncCallback;
 
-    // Exit guardian. 
+    // Exit guardian.
     CEUiExitGuardian* iExitGuardian;
 
     // navipane decorator
     // (used at least in mail viewer)
     CAknNavigationDecorator* iNaviDecorator2MailViewer;
-    
+
     // Resource file offset for message editor external resources
     TInt iMsgEditorResourceOffset;
-    
+
     // Resource file offset for FSMailServer external resources
     TInt iFSMailServerResourceOffset;
-    
+
     // Custom status pane indicators
     CCustomStatuspaneIndicators* iStatusPaneIndicators;
     TBool iConnectionStatusVisible;
@@ -676,10 +670,9 @@
     // For handling the flip state.
     CFreestyleEmailUiPropertySubscriber* iPropertySubscriber;
     TBool iFlipOpen;
-    
-    // Timer for focus removal purposes. Owned
-    CPeriodic* iFocusTimer;
 
+    /// Focus visibility state
+    TBool iFocusVisible;
     };
 
 
@@ -690,7 +683,7 @@
 class CFSEmailUiAutosyncMonitor : public CActive
     {
     public:
-        enum TNetworkStatus 
+        enum TNetworkStatus
             {
             EStatusUnknown = 0,
             EHomenetwork,
@@ -704,24 +697,24 @@
             ERequestingNetworkStatus,
             EDone
             };
-            
+
         static CFSEmailUiAutosyncMonitor* NewL( CFreestyleEmailUiAppUi& aAppUi );
         ~CFSEmailUiAutosyncMonitor();
 
-    public: 
+    public:
         void StartMonitoring( );
         void StopMonitoring( );
 
-    private: 
+    private:
         void RunL();
         void DoCancel();
         TInt RunError( TInt aError );
-        
+
     private:
         CFSEmailUiAutosyncMonitor( CFreestyleEmailUiAppUi& aAppUi );
-        void ConstructL();     
+        void ConstructL();
 
-    private:  
+    private:
         TMonitoringStatus iMonitoringStatus;
         CFreestyleEmailUiAppUi& iAppUi;
         RTelServer iServer;
--- a/emailuis/emailui/inc/FreestyleEmailUiFolderListVisualiser.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiFolderListVisualiser.h	Thu Jan 07 12:38:38 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* 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"
@@ -15,12 +15,12 @@
 *
 */
 
- 
-    
+
+
 #ifndef __FREESTYLEEMAILUI_FOLDERLISTVISUALISER_H__
 #define __FREESTYLEEMAILUI_FOLDERLISTVISUALISER_H__
 
-    
+
 #include <e32base.h>
 
 //<cmail>
@@ -37,6 +37,7 @@
 class CAlfTextVisual;
 class CAlfGridLayout;
 class CAlfImageVisual;
+class CAlfShadowBorderBrush;
 class CAlfDeckLayout;
 class CAlfAnchorLayout;
 class CFSEmailUiFolderListControl;
@@ -65,11 +66,8 @@
 
 class CAlfFrameBrush;
 
-//REMOVE WHEN DONE TESTING
-//class CSimpleAOTest;
-// <cmail> Touch
-class CFSEmailUiFolderListVisualiser : public CFsEmailUiViewBase, public MFsTreeListObserver
-// </cmail>
+class CFSEmailUiFolderListVisualiser : public CFsEmailUiViewBase,
+                                       public MFsTreeListObserver
 	{
 public: // Data types
     enum TExpandCollapseType
@@ -78,7 +76,7 @@
         EFolderListCollapse,
         EFolderListAutomatic
         };
-    
+
 public: // Construction and destruction
     /**
      * Destructor
@@ -98,26 +96,20 @@
                                                  CFreestyleEmailUiAppUi& aAppUi );
 	static CFSEmailUiFolderListVisualiser* NewLC( CAlfEnv& aEnv,
                                                   CAlfControlGroup& aControlGroup,
-                                                  CFreestyleEmailUiAppUi& aAppUi );				
+                                                  CFreestyleEmailUiAppUi& aAppUi );
 
 public: // From base class CAknView
 	void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
 	void HandleCommandL( TInt aCommand );
     TUid Id() const;
-    // <cmail> Toolbar
-    /*
-    void ChildDoActivateL( const TVwsViewId& aPrevViewId,
-            TUid aCustomMessageId,
-            const TDesC8& aCustomMessage );*/            
-    // </cmail> Toolbar
-    void ChildDoDeactivate();                
+    void ChildDoDeactivate();
     void DoTransitionEffect( TBool aDirectionOut );
     void GetParentLayoutsL( RPointerArray<CAlfVisual>& aLayoutArray ) const;
 
 public: // Own public functions
-    
+
     virtual TBool HandleWsEventL( const TWsEvent& aEvent );
-    
+
     // Handle foreground event (called by FreestyleEmailUiMailListVisualiser)
     void HandleForegroundEventL();
 
@@ -133,17 +125,15 @@
      * @return ETrue if event was consumed, otherwise EFalse
      */
 	TBool OfferEventL( const TAlfEvent& aEvent );
-	
-	// <cmail> Touch
+
     /**
-     * Handling pointer events. 
+     * Handling pointer events.
      *
      * @param aEvent Event forwarded from control
      * @return ETrue if event was consumed, otherwise EFalse
      */
 	TBool HandlePointerEventL(const TAlfEvent& aEvent);
-	// </cmail>
-	
+
 	/**
 	 * Expands or collpases the currently highlighted folder
 	 */
@@ -166,23 +156,23 @@
     void ShowInPopupL( const TFSMailMsgId aFolderId,
                        MFSEmailUiFolderListCallback* aCallback,
     				   MFsControlButtonInterface* aButton = NULL );
-	
+
     /**
 	 * Quick and dirty solution to show the sort list with the same list.
 	 * Could be changed to some more elegant implementation (e.g. folder list
 	 * and sort list derive from some generic control base class that
 	 * implements the common operations), if time permits.
 	 *
-	 * @param aCurrentSortOrder Current sort order in mail list
+	 * @param aCurrentSortCriteria Current sort criteria in mail list
      * @param aFolderType Folder type of the currently visible folder in mail list
      * @param aCallback Call back to inform the result of the sort order query
      * @param aButton Control bar button from where the popup is opened
 	 */
-    void ShowSortListPopupL( const TFSMailSortField aCurrentSortOrder,
+    void ShowSortListPopupL( const TFSMailSortCriteria aCurrentSortCriteria,
                              const TFSFolderType aFolderType,
     						 MFSEmailUiSortListCallback* aCallback,
     						 MFsControlButtonInterface* aButton  = NULL );
-    
+
     /**
      * Does a horizontal scroll for the list if needed
      *
@@ -194,37 +184,42 @@
 
     /**
      * Function to check whether folder list is displaying popup
-     */ 
+     */
     TBool IsPopupShown();
 
     /**
      * Function to hide popup
-     */ 
+     */
     void HidePopupL();
-    
+
     /**
      * From MFsTreeListObserver
      */
-// <cmail> Touch
-    void TreeListEventL( const TFsTreeListEvent aEvent, 
+    void TreeListEventL( const TFsTreeListEvent aEvent,
                                     const TFsTreeItemId aId = KFsTreeNoneID );
-// </cmail>
 
 // <cmail> Receiving online/offline events
     void HandleMailBoxEventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox,
         TAny* aParam1, TAny* aParam2, TAny* aParam3 );
 // </cmail>
-// <cmail> Toolbar    
+
+    /**
+     * From CFsEmailUiViewBase
+     * This method is called from the appui when the focus state is changed.
+     *
+     * @param aVisible Indicates if focus should become visible or removed
+     */
+    void FocusVisibilityChange( TBool aVisible );
 
 private: // from
-    
+
     /**
      * @see CFsEmailUiViewBase::ChildDoActivateL
      */
     void ChildDoActivateL( const TVwsViewId& aPrevViewId,
             TUid aCustomMessageId,
             const TDesC8& aCustomMessage );
-    
+
     /**
      *  @see CFsEmailUiViewBase::OfferToolbarEventL
      */
@@ -234,9 +229,7 @@
      * @see CFsEmailUiViewBase::ToolbarResourceId
      */
     TInt ToolbarResourceId() const;
-   
-// </cmail> Toolbar    
-    
+
 private: // Private functions
 
     /**
@@ -249,19 +242,17 @@
      *         positive if first parameter is greater than second
      */
     static TInt CompareFolders( const CFSMailFolder& aFirst, const CFSMailFolder& aSecond );
-       
+
 	// Construction
 	CFSEmailUiFolderListVisualiser( CAlfEnv& aEnv, CFreestyleEmailUiAppUi &aAppUi, CAlfControlGroup& aControlGroup );
 	void ConstructL();
 	void LoadIconsL();
 
 	// Internal functions used when showing and hiding the list
-	// <cmail>
 	//void DoShowInPopupL();
 	void DoShowInPopupL( MFsControlButtonInterface* aButton,
 	        MFSEmailUiFolderListCallback* aFolderCallback,
 	        MFSEmailUiSortListCallback* aSortCallback );
-	// </cmail>
 	void PrepareFolderListL();
     void PopulateFolderListL();
     void PopulateFolderListDeferred();
@@ -270,15 +261,13 @@
 	// Recreate list content
 	void UpdateFolderListL();
 	void UpdateSortListL();
-	
+
 	// View layout handling and item position calculation
 	void UpdateListSizeAttributes();
 	void ResizeListIcons();
 	void ResizeListItemsL();
 	void AdaptScreenRectToListContent();
-	// <cmail>
 	void AdjustWidthByContent( TRect& aRect ) const;
-	// </cmail>
 	void SetAnchors();
 	void SetItemVisualizerPropertiesL( MFsTreeItemVisualizer* aItemVisualizer );
 
@@ -287,9 +276,6 @@
 	TRect RightListRectInThisResolution();
 	TRect FolderListRectInThisResolution();
 	TRect SortListRectInThisResolution();
-	// <cmail>
-	//void PopupListWidthHeightInThisResolution( TInt& aWidth, TInt& aHeight );
-	// </cmail>
 
 	// Handle the selection or cancelation of the list
 	void HandleSelectionL( TFSEmailUiCtrlBarResponse aSelection );
@@ -303,7 +289,7 @@
 	void AppendMoreFoldersL();
 	void AppendMailboxesL();
 	void AppendSeparatorLineL();
-	
+
 	// Append sort list data
 	void AppendSortListItemsL();
 
@@ -313,29 +299,29 @@
 	                        TBool aRefreshLastItem );
 	TFsTreeItemId AppendNodeFolderL( CFSMailFolder* aFolder, TFsTreeItemId aParentNode );
 	TFsTreeItemId AppendLeafFolderL( CFSMailFolder* aFolder, TFsTreeItemId aParentNode, TBool aAllowRefresh );
-	
+
 	TFsTreeItemId AppendNodeToListFromResourceL( TInt aResourceId,
 												 TFsTreeItemId aParentNode,
 												 CAlfTexture* aIcon,
 												 TUint aUnreadCnt = 0);
-	
+
 	TFsTreeItemId AppendNodeToListL( TDesC* aItemData,
 									 TFsTreeItemId aParentNode,
 									 CAlfTexture* aIcon,
 									 TUint aUnreadCnt);
 
-	TFsTreeItemId AppendItemToListFromResourceL( TInt aResourceId, 
+	TFsTreeItemId AppendItemToListFromResourceL( TInt aResourceId,
 												 TFsTreeItemId aParentNode,
 												 CAlfTexture* aIcon,
                                                  TBool aAllowRefresh,
                                                  TUint aUnreadCnt = 0);
-	
-	TFsTreeItemId AppendItemToListL( TDesC* aItemData, 
+
+	TFsTreeItemId AppendItemToListL( TDesC* aItemData,
 									 TFsTreeItemId aParentNode,
 									 CAlfTexture* aIcon,
                                      TBool aAllowRefresh,
                                      TUint aUnreadCnt = 0);
-														
+
 	void CreatePlainItemLC2( const TDesC* aItemDataBuff,
                              CFsTreePlainOneLineItemData* &aItemData,
                              CFsTreePlainOneLineItemVisualizer* &aItemVisualizer,
@@ -371,28 +357,28 @@
 	// Check wheter all list nodes are expanded or collapsed
 	TBool AllNodesCollapsed() const;
 	TBool AllNodesExpanded( TFsTreeItemId aParentNodeId = KFsTreeRootID ) const;
-	
+
 	// Recursive function to get item's root level parent
 	TFsTreeItemId GetRootParent( const TFsTreeItemId aItemId ) const;
-	
+
     void DoFirstStartL();
-    //<cmail>
     void SetHeaderTextAttributesL();
     void ConnectToMailboxL();
     void DisconnectFromMailboxL();
     TBool CbaButtonPressed( TPoint aPosition );
     void GetCbaRects( TRect& aLeftCbaRect, TRect&  aRightCbaRect );
     TBool IsAreaSideRightPaneActive();
-    //</cmail>
-	
+
 private:
-    
+
     // Array of list item infos
     RPointerArray< CFsTreePlainOneLineItemData > iListItemDatas;
-    
+
 private: // Typedefs and member variables
 	// Array type for the list icons
 	typedef RPointerArray<CAlfTexture> TFsEmailFolderListIconArray;
+	// Array type for the sort list icons
+	typedef RPointerArray<CAlfTexture> TFsEmailSortListIconArray;
 
 	// ALF environment
     CAlfEnv& iEnv;
@@ -407,15 +393,11 @@
 	CAlfImageVisual* iListBgImageVisual;
 	CAlfImageVisual* iHeaderImageVisual;
     CAlfTextVisual* iHeaderTextVisual;
-	// <cmail>
-    //CAlfImageBrush* iBackgroundBrush;
     CAlfFrameBrush* iBackgroundBrush;
-	// </cmail>
-	
-// <cmail> Touch
+    CAlfShadowBorderBrush* iShadowBrush;
+
 	// ALF visual for background
 	CAlfVisual* iFaderVisual;
-// </cmail>
 
 	// Pointers to control and model
     CFSEmailUiFolderListControl* iControl;	// not owned (owned by ALF env)
@@ -424,13 +406,13 @@
 	// Callback pointers
 	MFSEmailUiFolderListCallback* iCallback;
 	MFSEmailUiSortListCallback* iSortListCallback;
-	
+
 	// Type of the currently visible folder in mail list
 	TFSFolderType iCurrentFolderType;
-	
+
 	// Custom message ID passed in view activation
 	TUid iCustomMessageId;
-	
+
 	// List/view size attributes
    	TRect iScreenRect;
 	TRect iCtrlButtonRect;
@@ -440,12 +422,12 @@
     TInt iListSeparatorHeight;
 	TSize iListIconSize;
 	TSize iPreviousListIconSize;
-	
+
 	TPoint iPadding;
-	
+
 	// ETrue if list shown in fullscreen
 	TBool iFullScreen;
-	
+
 	// List id of the "More folders" item in folder list
 	TFsTreeItemId iMoreFoldersItemId;
 
@@ -460,20 +442,23 @@
 
 	// Folder list icons, items not owned (are owned by texture manager)
 	TFsEmailFolderListIconArray iIconArray;
+
+	// Sort list icons, items not owned (are owned by texture manager)
+	TFsEmailSortListIconArray iSortIconArray;
 	
 	// Previously selected items
 	TFSMailMsgId iLatestSelectedMoveFolderId;
     TFSMailMsgId iCurrentFolderId;
-	TFSMailSortField iCurrentSortOrder;
-	
+	TFSMailSortCriteria iCurrentSortCriteria;
+
 	// Pointers to list items (and nodes)
 	RPointerArray<MFsTreeItemVisualizer> iListItemVisulizers;
-	
+
     // Previous level in list, used in horizontal scrolling
 	TInt iPreviousListLevel;
-	
+
 	TBool iFirstStartCompleted;
-	
+
 	TBool iPopupListShown;
 
 	//For header text caption
@@ -485,12 +470,12 @@
   	TBool iWaitingToGoOnline;
     // Do we need to connect the mailbox before showing the folder list
     TBool iNoConnectNeeded;
-	
+
 	// Should we use expansion animation for the next transition effect
 	TBool iAnimateNextActivation;
-	
+
 	CAsyncCallBack* iAsyncCallback;
-	
+
 	TBool iConsumeUntilNextUpEvent;
 	};
 
--- a/emailuis/emailui/inc/FreestyleEmailUiHtmlViewerContainer.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiHtmlViewerContainer.h	Thu Jan 07 12:38:38 2010 +0200
@@ -67,6 +67,7 @@
     void Draw( const TRect& aRect ) const;
     void SizeChanged();
     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+    void HandleResourceChange(TInt aType);
 
 // from base class MBrCtlSpecialLoadObserver
 
--- a/emailuis/emailui/inc/FreestyleEmailUiHtmlViewerView.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiHtmlViewerView.h	Thu Jan 07 12:38:38 2010 +0200
@@ -291,6 +291,12 @@
 
     TFetchedType iStartAsyncFetchType;
 
+    // <cmail>
+    // Email forwarding initiated (so don't cancel fetch of message parts
+    // during deactivation).
+    TBool iForwardingMessage;
+    // </cmail>
+
     // Wait note stuff
     //<cmail>
     //CAknWaitNoteWrapper* iAsyncWaitNote;
--- a/emailuis/emailui/inc/FreestyleEmailUiLauncherGridVisualiser.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiLauncherGridVisualiser.h	Thu Jan 07 12:38:38 2010 +0200
@@ -41,11 +41,11 @@
 #include "FSEmailLauncherItem.h"
 #include "freestyleemailuimailboxdeleter.h"
 
-// FORWARD DECLARATIONS
-// <cmail> 
+// FORWARD DECLARATIONS 
 class CBrushAnimation;
-// </cmail> 
 class CFsAlfScrollbarLayout;
+class CAknStylusPopUpMenu;
+
 
 class TFSLauncherGridMailboxStatus
     {
@@ -199,7 +199,8 @@
     void MailboxDeletionComplete();
     
     
-private: // methods
+private: // New methods.
+
     CFSEmailUiLauncherGridVisualiser(CAlfEnv& aEnv, 
     					 CFSEmailUiLauncherGrid* aControl,
     					 CFreestyleEmailUiAppUi* aAppUi,
@@ -234,12 +235,19 @@
      * Reduces item's icon size.
      */
     void ResizeItemIcon( TBool aReduce );
-	
+
     /**
-     * Handles the focus removal of CFSEmailUiLauncherGridVisualiser
-     * @param aShow Indicates if focus should become visible or removed
+     * Handles the focus state changes of CFSEmailUiLauncherGridVisualiser
+     * @param aVisible Indicates if focus should become visible or removed
      */
-	void HandleTimerFocusStateChange( TBool aShow );
+	void FocusVisibilityChange( TBool aVisible );
+
+	/**
+	 * Launches and displays the pop-up menu invoked by a long tap event.
+	 * @param aItemId The ID of the item for which to open the menu.
+	 */
+	void LaunchStylusPopupMenu( const TInt aItemId );
+
 
 private: // data types
 
@@ -384,6 +392,15 @@
 
     // Mailbox deleter - handles deletion of one or more mailboxes.
     CFSEmailUiMailboxDeleter* iMailboxDeleter;
+
+    // A pop-up menu that is invoked by long tap events. Used for e.g.
+    // deleting mail boxes.
+    CAknStylusPopUpMenu* iStylusPopUpMenu;
+    TBool iStylusPopUpMenuLaunched;
+
+    // Contains the ID of a selected mailbox. Used for deleting mailboxes
+    // with long tap pop-up menu.
+    TFSMailMsgId iMailboxToDelete;
     };
 
 #endif // __FREESTYLEEMAILUI_MAINGRIDUIVISUALISER_H__
--- a/emailuis/emailui/inc/FreestyleEmailUiLayoutData.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiLayoutData.h	Thu Jan 07 12:38:38 2010 +0200
@@ -208,6 +208,9 @@
 static const TInt KListTextMarqueeStartDelay = 1500; // Milliseconds
 static const TInt KListTextMarqueeSpeedRepeats = 0;  // repeats
 
+// Border widths.
+const TInt KSelectorBorderWidth( 8 );
+
 // Compose screen specific layout constants
 // these are constants for all zoom levels
 const TInt KAifLabelMarginHorizontal = 9;
@@ -223,7 +226,8 @@
 const TInt KIconWidthAttachment = 14;
 const TInt KIconHeightAttachment = 17;
 const TInt KInputFieldRoundingRadius = 3;
-const TSize KInputFieldRoundingSize( KInputFieldRoundingRadius*2, KInputFieldRoundingRadius*2 );
+const TSize KInputFieldRoundingSize( KInputFieldRoundingRadius * 2,
+									 KInputFieldRoundingRadius * 2 );
 
 // these are defined for each zoom level
 // normal zoom level
@@ -238,6 +242,7 @@
 const TInt KIconMarginAttachmentVertical = KIconMarginPriorityVertical;
 const TInt KLabelFontHeightPx = 14;
 const TInt KEditorFontHeightPx = 17;
+
 // small zoom level
 const TInt KAifHeightSmall = 40;
 const TInt KAifLabelMarginVerticalSmall = 3;
@@ -250,6 +255,7 @@
 const TInt KIconMarginAttachmentVerticalSmall = KIconMarginPriorityVerticalSmall;
 const TInt KLabelFontHeightPxSmall = 13;
 const TInt KEditorFontHeightPxSmall = 15;
+
 // large zoom level
 const TInt KAifHeightLarge = 52;
 const TInt KAifLabelMarginVerticalLarge = 5;
@@ -333,6 +339,7 @@
 // Maximum number of contacts included in the Predictive contact search popup.
 // Number is limited to enhance performance in case of large contact DB.
 static const TInt KMaxPcsMatches = 50;
+
 // Predictive contact search popup colors
 static const TRgb KPcsPopupHighlightColor( 0,200,200 );
 static const TRgb KPcsPopupDimmedFontColor( 192,192,192 );
@@ -349,7 +356,8 @@
 static const TInt KViewerHighlightTextureSize = 1;
 static const TInt KControlBarArrowTextureXSize = 12;
 static const TInt KControlBarArrowTextureYSize = 17;
+
+
 #endif // __FREESTYLEEMAILUI_LAYOUTDATA_H__     
 
-
 // End of File
--- a/emailuis/emailui/inc/FreestyleEmailUiLayoutHandler.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiLayoutHandler.h	Thu Jan 07 12:38:38 2010 +0200
@@ -78,10 +78,10 @@
 		// One line node and item height
 		TInt OneLineListNodeHeight() const;
 		TInt OneLineListItemHeight() const;
+		TInt TwoLineListItemHeight() const;
     	// <cmail>
 		// Folder list item heigh
 		TInt FolderListOneLineItemHeight( const TBool& aFullscreen ) const;
-	    // </cmail>
 		
 		// Mail icon size
 		TSize MailIconSizeInThisResolution() const;
@@ -98,9 +98,8 @@
 		// Scroll pane list item size
 		TSize FolderListItemSizeInThisResolution( const TRect& aParent ) const;
 		
-	    // <cmail>
         // Drop down menu rect
-		TRect DropDownMenuListRect( const TDropDownMenuSide aSide ) const;
+		TRect DropDownMenuListRect( const TDropDownMenuSide aSide, TBool aStretch = ETrue ) const;
     	// </cmail>
 
 		// Folder list pane indentation in pixels
@@ -111,7 +110,7 @@
 
 		// FS Email UI fonts, returns font style. Calling
 		// View may set text visual style using SetTextStyle( CAlfTextStyle.Id() )
-		CAlfTextStyle* FSTextStyleFromIdL( TFSEmailFont aFontId ); // <cmail> const removed due to changes in method
+		CAlfTextStyle* FSTextStyleFromIdL( TFSEmailFont aFontId );
 		
 		// Control bar list padding
 		TPoint ControlBarListPadding() const;
@@ -126,11 +125,6 @@
 		// Control bar height
 		TInt ControlBarHeight() const;
 
-		// <cmail> Platform layout change
-		// Control bar text height
-		//TInt ControlBarTextHeight() const;
-		// </cmail> Platform layout change
-
 		// List fade effect times
         TInt ListFadeInEffectTime() const;
         TInt ListFadeOutEffectTime() const;
@@ -187,8 +181,7 @@
 		// List items font heigjht in twips global zoom level
 		TInt ListItemFontHeightInTwips( const TBool aPopup = EFalse ) const;
 		
- 
-		// Logical font id's for viewer fonts 		
+ 		// Logical font id's for viewer fonts 		
 		TAknLogicalFontId ViewerTitleFontAknLogicalFontId() const;
 		TAknLogicalFontId ViewerTextFontAknLogicalFontId() const;
 
@@ -272,26 +265,15 @@
 		TInt ControlBarArrowTextureXSize() const;
 		TInt ControlBarArrowTextureYSize() const;
 
-// <cmail> Use layout data instead of hardcoded values
 		TRect GetControlBarMailboxIconRect() const;
-		TPoint GetControlBarMailboxIconPos() const;
-		TSize GetControlBarMailboxIconSize() const;
-
+		TRect GetControlBarNewEmailButtonRect() const;
 		TRect GetControlBarFolderListButtonRect() const;
-		TPoint GetControlBarFolderListButtonPos() const;
-		TSize GetControlBarFolderListButtonSize() const;
-
         TRect GetControlBarSortButtonRect() const;
-        TPoint GetControlBarSortButtonPos() const;
-        TSize GetControlBarSortButtonSize() const;
-
         TRect GetControlBarConnectionIconRect() const;
-        TPoint GetControlBarConnectionIconPos() const;
-        TSize GetControlBarConnectionIconSize() const;
 
         TRect GetControlBarRect() const;
 
-        TRect GetListRect() const;
+        TRect GetListRect( TBool aControlsOnTop = EFalse ) const;
 
 		CAlfTextStyle& FSTextStyleFromLayoutL( const TAknTextComponentLayout& aLayout  );
 //<cmail>
--- a/emailuis/emailui/inc/FreestyleEmailUiMailListVisualiser.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiMailListVisualiser.h	Thu Jan 07 12:38:38 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 the License "Symbian Foundation License v1.0"
@@ -11,12 +11,12 @@
 *
 * Contributors:
 *
-* Description:  FreestyleEmailUi double line list visualiser definition 
+* Description:  FreestyleEmailUi double line list visualiser definition
 *
 */
 
- 
-    
+
+
 #ifndef __FREESTYLEEMAILUI_MAILLISTVISUALISER_H__
 #define __FREESTYLEEMAILUI_MAILLISTVISUALISER_H__
 
@@ -89,13 +89,13 @@
 
 struct STimeDateFormats
 	{
-	TDateFormat iDateFormat;	
+	TDateFormat iDateFormat;
 	TChar iDateSeparator;
 	TTimeFormat iTimeFormat;
 	TChar iTimeSeparator;
 	TLocalePos iAmPmPosition;
 	};
-	
+
 enum TMailListUiControls
 	{
 	EControlBarComponent=0,
@@ -117,9 +117,9 @@
 	};
 
 // <cmail>
-class CFSEmailUiMailListVisualiser : public CFsEmailUiViewBase, 
-									 public MFsControlBarObserver, 
-									 public MFSEmailUiFolderListCallback, 
+class CFSEmailUiMailListVisualiser : public CFsEmailUiViewBase,
+									 public MFsControlBarObserver,
+									 public MFSEmailUiFolderListCallback,
 									 public MFSEmailUiSortListCallback,
 									 public MFsTreeListObserver,
 									 public MFSEmailUiContactHandlerObserver,
@@ -136,16 +136,16 @@
 	void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
 	// Refresh the whole list
 	void RefreshL( TFSMailMsgId* aFocusToMessage = NULL );
-	// From view 
-	TUid Id() const;	
+	// From view
+	TUid Id() const;
 	// <cmail> Toolbar
 	/*void DoActivateL(const TVwsViewId& aPrevViewId,
 	                 TUid aCustomMessageId,
 	                 const TDesC8& aCustomMessage);*/
     // </cmail> Toolbar
 	TInt NewEmailsInModelL() const;
-	TInt EmailsInModelL() const;	              
-	CFSEmailUiMailListModel* Model();	
+	TInt EmailsInModelL() const;
+	CFSEmailUiMailListModel* Model();
 	// Current active folder
 	TFSMailMsgId FolderId();
 	// Dynamic variant switch, called by appui
@@ -154,100 +154,104 @@
 	// Handle foregroundevent
 	void HandleForegroundEventL();
 	// Sets softkeys
-	void SetViewSoftkeysL( TInt aResourceId );	
+	void SetViewSoftkeysL( TInt aResourceId );
 	void SetMskL();
 	// Highlighted index
 	TInt HighlightedIndex() const;
 	void SetHighlightedIndexL( TInt aWantedIndex );
 	// Event handling forwarded from control
-	TBool OfferEventL( const TAlfEvent& aEvent ); 
+	TBool OfferEventL( const TAlfEvent& aEvent );
 
     // <cmail>
 	/**
-	 * Open highlighted mail or node. 
+	 * Open highlighted mail or node.
 	 * (Touchwork: Called from touch manager)
 	 */
 	void DoHandleListItemOpenL();
 
 	/**
-     * Open folderlist or shortlist.  
+     * Open folderlist or shortlist.
      * (Touchwork: Called from touch manager)
-     * 
-     * @param TInt button id. (shortlist or folderlist) 
+     *
+     * @param TInt button id. (shortlist or folderlist)
      */
 	void DoHandleControlBarOpenL( TInt aControlBarButtonId );
 
     /**
-     * Open action menu.   
+     * Open action menu.
      * (Touchwork: Called from touch manager)
      */
 	void DoHandleListItemLongTapL();
 
     /**
-     * Get control which is currently focused.    
+     * Get control which is currently focused.
      * (Touchwork: Called from touch manager)
-     * 
+     *
      * @return TInt id of control
      */
-	TInt GetFocusedControl() const; 
+	TInt GetFocusedControl() const;
 
     /**
-     * Set control bar as focused control.   
+     * Set control bar as focused control.
      * (Touchwork: Called from touch manager)
      */
 	void SetControlBarFocusedL();
 
     /**
-     * Set tree list as focused control.   
+     * Set tree list as focused control.
      * (Touchwork: Called from touch manager)
      */
-	void SetTreeListFocusedL(); 
+	void SetTreeListFocusedL();
 
     /**
-     * Helper function for disable controls to send 
-     * any events.    
+     * Helper function for disable controls to send
+     * any events.
      * (Touchwork)
-     * 
-     * @param TBool state of controls. 
+     *
+     * @param TBool state of controls.
      */
 	void DisableMailList( TBool aValue );
 	// </cmail>
-	
+
 	// Command handling
 	void HandleCommandL(TInt aCommand);
-	// Read status 
+	// Read status
 	void ChangeReadStatusOfHighlightedL( TBool aRead );
 	void ChangeReadStatusOfMarkedL( TBool aRead );
 	void ChangeReadStatusOfIndexL( TBool aRead, TInt aIndex );
-	// Delete messages 
-	void DeleteMessagesL(); 	
+	// Delete messages
+	void DeleteMessagesL();
 	// Move to drafts
 	void MoveMessagesToDraftsL();
-	
+
 	// From base class MFSEmailUiFolderListCallback
 	// Handle folder list selection
 	void FolderSelectedL( TFSMailMsgId aSelectedFolderId,
 	 					 TFSEmailUiCtrlBarResponse aResponse );
 	void MailboxSelectedL( TFSMailMsgId aSelectedFolderId );
 	TRect FolderButtonRect();
-	
+
 	// From base class MFSEmailUiSortListCallback
 	void SortOrderChangedL( TFSMailSortField aSortField,
 	 					   TFSEmailUiCtrlBarResponse aResponse );
 	TRect SortButtonRect();
-	
+
+	// Update theme colors
+	void UpdateTheme();
+
 	// Navigation functions, used mainly from viewer
 	TBool IsNextMsgAvailable( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundNextMsgId, TFSMailMsgId& aFoundNextMsgFolder ) const;
 	TBool IsPreviousMsgAvailable( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId, TFSMailMsgId& aFoundPrevMsgFolder ) const;
 	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   
+     * Sets the manual mailbox syncronisation flag if the user chose
      * to synchorise mail box from the menu
      */
     void ManualMailBoxSync( TBool aManualMailBoxSync );
-    
+
     // Returns ETrue if mailbox is syncronizing and EFalse if not
     TBool GetLatestSyncState();
 
@@ -277,14 +281,14 @@
     * Called when CDateChangeTimer completes. This happens when either when date
     * changes or when user alters the system time. Redraws the list to ensure that
     * time stamp texts in emails and nodes are up-to-date.
-    */ 
+    */
     void NotifyDateChangedL();
 // <cmail>
     TPoint ActionMenuPosition();
 // </cmail>
-  
+
 private: // from
-    
+
     /**
      * @see CFsEmailUiViewBase::ChildDoActivateL
      */
@@ -295,9 +299,9 @@
     void GetParentLayoutsL( RPointerArray<CAlfVisual>& aLayoutArray ) const;
     /**
 	 * @see CFsEmailUiViewBase::SetStatusBarLayout
-	 */ 
+	 */
     void SetStatusBarLayout();
-    
+
 private: // Private functions
     CFSEmailUiMailListVisualiser( CAlfEnv& aEnv, CFreestyleEmailUiAppUi* aAppUi,
         CAlfControlGroup& aMailListControlGroup );
@@ -306,48 +310,49 @@
 	// Refresh funcions
     void InsertNewMessagesL( const RArray<TFSMailMsgId>& aMessages );
     void InsertNewMessageL( CFSMailMessage* aNewMessage, const TBool aAllowRefresh ); // ownership is transferred
-    
+
     void RefreshListItemsL();
     // Refresh the list order only
     void RefreshOrderL();
-    
+
     // To start refreshing asynchronously
     void RefreshDeferred( TFSMailMsgId* aFocusToMessage = NULL );
     static TInt DoRefresh( TAny* aSelfPtr );
     void CompletePendingRefresh();
-    
+
     // Create and insert one list node item according to given model item.
     // Omitting the argument aChildIdx causes the new node to be appended at the end of the list.
     TFsTreeItemId InsertNodeItemL( TInt aModelIndex, TInt aChildIndex = KErrNotFound, const TBool aAllowRefresh = EFalse );
     // Create and insert one list item according the given model item. The item is added under the given node.
     // Omitting the argument aChildIdx causes the new item to be appended as last child of the node.
     TFsTreeItemId InsertListItemL( TInt aModelIndex, TFsTreeItemId aParentNodeId, TInt aChildIdx = KErrNotFound, TBool aAllowRefresh = ETrue );
-	
+
 	// Mail model update
 	void UpdateMailListModelL();
 	void CreateModelItemsL( RPointerArray<CFSMailMessage>& aMessages );
-	
+
 	// Create title divider model item for the given message. Separator text depends on active sorting mode.
 	CFSEmailUiMailListModelItem* CreateSeparatorModelItemLC( CFSMailMessage& aMessage ) const;
-	
+
 	// Checks if the given messages belong under the same title divider. This depends on the currect sorting mode.
 	TBool MessagesBelongUnderSameSeparatorL( const CFSMailMessage& aMessage1, const CFSMailMessage& aMessage2 ) const;
-	
-	// Rescale UI	
+
+	// Rescale UI
 	void SetMailListLayoutAnchors();
 
 	// Control bar functions
 	void CreateControlBarLayoutL();
 	void ScaleControlBarL();
 	void SetSortButtonTextAndIconL();
+	HBufC* GetSortButtonTextLC();
     void HandleControlBarEvent( TFsControlBarEvent aEvent, TInt aData );
 
 	// Followup flag
 	void SetMessageFollowupFlagL();
 
 	void CreatePlainNodeL( const TDesC* aItemDataBuff,
-                           CFsTreePlainOneLineNodeData* &aItemData,   
-                           CFsTreePlainOneLineNodeVisualizer* &aNodeVisualizer ) const;                           	
+                           CFsTreePlainOneLineNodeData* &aItemData,
+                           CFsTreePlainOneLineNodeVisualizer* &aNodeVisualizer ) const;
 
 	// Move messages to folder
 	TInt MoveMsgsToFolderL( const TFSMailMsgId& aDestinationFolderId );
@@ -361,7 +366,7 @@
 	void MarkAllItemsL();
 	void UnmarkAllItemsL();
 	TInt CountMarkedItemsL();
-	
+
 	void MarkMessagesIfFoundL( const RArray<TFSMailMsgId>& aMessageIDs );
 
 	// Message deletion internal functions
@@ -371,19 +376,19 @@
 
 	// Helper functions to access model data
 	TFSMailMsgId MsgIdFromIndex( TInt aItemIdx ) const;
-	CFSMailMessage& MsgPtrFromListIdL( TFsTreeItemId aListId );	
-    const CFSMailMessage& MsgPtrFromListIdL( TFsTreeItemId aListId ) const; 
+	CFSMailMessage& MsgPtrFromListIdL( TFsTreeItemId aListId );
+    const CFSMailMessage& MsgPtrFromListIdL( TFsTreeItemId aListId ) const;
 
-	// 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;
 	TInt ModelIndexFromListId( TFsTreeItemId aItemId ) const;
-	
+
 	// Open highlighted mail
 	void OpenHighlightedMailL();
 	void OpenMailItemL( TFsTreeItemId aMailItem );
@@ -394,52 +399,52 @@
 	// Shortcut specific toggles
 	void ShortcutReadUnreadToggleL();
 	void ShortcutCollapseExpandAllToggleL();
-	
+
 	// Utility functions to check if all nodes are expanded or collapsed
 	TBool AllNodesCollapsed() const;
 	TBool AllNodesExpanded() const;
-	
+
 	// Utility functions to check if mark as read/unread options should be available in menus
 	TBool IsMarkAsReadAvailableL() const;
 	TBool IsMarkAsUnreadAvailableL() const;
-	
+
 	// Utility function to get list of entries which will be targeted by the Actions menu commands.
 	// 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();
-	
+
 	// Compose, reply, reply all and forward
 	void CreateNewMsgL();
 	void ReplyL( CFSMailMessage* aMsgPtr );
 	void ReplyAllL( CFSMailMessage* aMsgPtr );
 	void ForwardL( CFSMailMessage* aMsgPtr );
 	void DoReplyForwardL( TEditorLaunchMode aMode, CFSMailMessage* aMsgPtr = NULL );
-	
+
 	// Some misc housekeeping functions
 	void RemoveUnnecessaryNodesL();
-	void UpdateMailListSettingsL();	
+	void UpdateMailListSettingsL();
 	void UpdateMailListTimeDateSettings();
 	STimeDateFormats MailListTimeDateSettings();
 
 	// Request to update list item data from given message pointer
     void UpdateItemDataL( CFsTreePlainTwoLineItemData* aData, const CFSMailMessage* aMsgPtr );
-	
+
 	// Request to update preview pane data for list id with msg ptr
 	void UpdatePreviewPaneTextForItemL( TFsTreeItemId aListItemId, CFSMailMessage* aMsgPtr );
 	void UpdatePreviewPaneTextForItemL( CFsTreePlainTwoLineItemData* aTwoLineItemData, CFSMailMessage* aMsgPtr );
     void UpdatePreviewPaneTextIfNecessaryL( TFsTreeItemId aListItemId, TBool aUpdateItem = ETrue );
-	
+
 	// Sender/Recipient text depending on the mail folder
 	HBufC* GetListFirstTextLineL( const CFSMailMessage* aMsgPtr );
 
 	// Reload message pointer from mail client and update list item contents to match it. Item is
 	// removed if it isn't valid anymore.
 	void UpdateItemAtIndexL( TInt aIndex );
-	
+
 	// Check validity of highlighted msg and remove from list if needed
 	// EFalse indicates that mail was not valid anymore.
 	TBool CheckValidityOfHighlightedMsgL();
@@ -461,27 +466,27 @@
 
     // Gives the parent node if the item has one. Returns KErrNotFound if no parent node available.
     TFsTreeItemId ParentNode( TFsTreeItemId aItemId ) const;
-    
+
     // Either marks or unmarks the current item depending on the current marking state
     // as stored in iListMarkItemsState. Used for marking when shift is depressed while
     // scrolling. Returns ETrue if the highlighted item is markable.
     TBool DoScrollMarkUnmarkL();
-    
+
     /**
      * Mark/unmark items under current separator.
-     * 
+     *
      * @param aMarked If ETrue mark all items else unmark.
      * @param aSeparatorId Id of the separator.
      */
     void MarkItemsUnderSeparatorL( TBool aMarked, TInt aSeparatorId );
-    
+
     //When maillist is activated this method handles the connection icon change
     void ConnectionIconHandling();
-    
+
     void SetListAndCtrlBarFocusL();
-    
+
     void SetMailListItemsExtendedL();
-    
+
     void DoFirstStartL();
 
     // Called when flip state is changed
@@ -489,44 +494,58 @@
 
     /**
      * Handles the focus state changes
-     * @param aShow Indicates if focus should become visible or removed
+     * @param aVisible Indicates if focus should become visible or removed
+     */
+    void FocusVisibilityChange( TBool aVisible );
+
+    /**
+     * Update texts in command area buttons
      */
-    void HandleTimerFocusStateChange( TBool aShow );
+    void UpdateButtonTextsL();
+
+    /**
+     * Tests whether a point is inside the control.
+     *
+     * @param aControl  Control that is tested.
+     * @param aPoint    Point in display coordinates.
+     *
+     * @return  <code>ETrue</code>, if the point is inside one of the
+     *          control's visuals. Otherwise <code>EFalse</code>.
+     */
+    TBool HitTest( const CAlfControl& aControl, const TPoint& aPoint ) const;
 
 private: // data types
 
-    
+
 private: // Private objects
     // Reference to Alf environment
     CAlfEnv& iEnv;
   	// Mail list updater timer
 	// Timer delays mail update to prevent unnesessary redraw events
-	CMailListUpdater* iMailListUpdater; 
+	CMailListUpdater* iMailListUpdater;
 	// Msg moved note timer
-	CMsgMovedNoteTimer* iMsgNoteTimer; 
+	CMsgMovedNoteTimer* iMsgNoteTimer;
   	// Screen layout uses iMailListControl
 	CAlfAnchorLayout* iScreenAnchorLayout;
   	// Control bar control and layout and store visual pointer
 	CFsControlBar* iControlBarControl;
 	CAlfVisual* iControlBarVisual;
- 	CAlfDeckLayout* iControlBarLayout;  
+ 	CAlfDeckLayout* iControlBarLayout;
   	// Mail List control and layout
     CFreestyleEmailUiMailListControl* iMailListControl;
  	CAlfDeckLayout* iListLayout;
-// <cmail> this feature is waiting for title divider bg graphics
     CAlfImageVisual* iTitleDividerBgVisual;
-// </cmail>
-    CFSEmailUiMailListModel* iModel; 
+    CFSEmailUiMailListModel* iModel;
   	CFsTreeList* iMailList;
     CFsTreeVisualizerBase* iMailTreeListVisualizer;
-  	TInt iNumSlots;		
+  	TInt iNumSlots;
    	CFSMailFolder* iMailFolder;
-    TInt iNewEmailsInModel; 	
-	RArray<SMailListItem> iTreeItemArray;   
+    TInt iNewEmailsInModel;
+	RArray<SMailListItem> iTreeItemArray;
     RArray<TInt> iButtonsIds;
     TInt iFocusedControl;
     TBool iToolbarInUse;
-    TInt iListMode;    
+    TInt iListMode;
     TInt iNodesInUse;
     TInt iNewEmailButtonId;
 	TInt iFolderListButtonId;
@@ -535,9 +554,9 @@
 	MFsControlButtonInterface* iIconButton;
 	MFsControlButtonInterface* iNewEmailButton;
 	MFsControlButtonInterface* iFolderListButton;
-	MFsControlButtonInterface* iSortButton;	
-	TBool iThisViewActive;	
-	CPbkxContactActionMenu* iActionMenu;	
+	MFsControlButtonInterface* iSortButton;
+	TBool iThisViewActive;
+	CPbkxContactActionMenu* iActionMenu;
     TFSMailSortCriteria iCurrentSortCriteria;
 	// Set to indicate whether items should be marked or unmarked
 	TBool iListMarkItemsState;
@@ -564,16 +583,16 @@
 	CDateChangeTimer* iDateChangeTimer;
 	TBool iFirstStartCompleted;
 	// generic use async callback object
-	CAsyncCallBack* iAsyncCallback; 
+	CAsyncCallBack* iAsyncCallback;
 	// async callback for deferred redrawing
 	CAsyncCallBack* iAsyncRedrawer;
 	TFSMailMsgId iMsgToFocusAfterRedraw;
+	HBufC* iNewEmailText;
 
-    //<cmail>
-    CEUiEmailListTouchManager* iTouchManager; 
-    //</cmail>
-    CAknStylusPopUpMenu* iStylusPopUpMenu; 
-    
+    CEUiEmailListTouchManager* iTouchManager;
+    CAknStylusPopUpMenu* iStylusPopUpMenu;
+    TBool iStylusPopUpMenuLaunched;
+
     TBool iShowReplyAll;
   	};
 
@@ -598,7 +617,7 @@
     CAknWaitDialog* iWaitNote;
     };
 
-// Delayd note timer 
+// Delayd note timer
 class CMsgMovedNoteTimer : public CTimer
     {
 public:
@@ -626,12 +645,12 @@
     ~CDateChangeTimer();
     void Start();
     void RunL();
-    
+
 protected:
     CDateChangeTimer( CFSEmailUiMailListVisualiser& aMailListVisualiser );
-    
+
 private:
     CFSEmailUiMailListVisualiser& iMailListVisualiser;
     };
 
-#endif 
+#endif
--- a/emailuis/emailui/inc/FreestyleEmailUiMsgDetailsVisualiser.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiMsgDetailsVisualiser.h	Thu Jan 07 12:38:38 2010 +0200
@@ -300,9 +300,8 @@
     CFSEmailUiMsgDetailsControl* iControl;	// Not owned, owned by ALF env
     CFSEmailUiMsgDetailsModel* iModel;		// Owned
 
-	// Lists screen rect and item/node heights
+	// Lists screen rect and node heights
     TRect iScreenRect;
-	TInt iListItemHeight;
 	TInt iListNodeHeight;
 
 	// Nodes that can be focused at startup
--- a/emailuis/emailui/inc/FreestyleEmailUiSearchListVisualiser.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiSearchListVisualiser.h	Thu Jan 07 12:38:38 2010 +0200
@@ -112,7 +112,8 @@
     TBool IsPreviousMsgAvailable( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId, TFSMailMsgId& aFoundPrevMsgFolder ) const;
     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();
@@ -176,9 +177,9 @@
 
     /**
      * Handles the focus state changes
-     * @param aShow Indicates if focus should become visible or removed
+     * @param aVisible Indicates if focus should become visible or removed
      */
-    void HandleTimerFocusStateChange( TBool aShow );
+    void FocusVisibilityChange( TBool aVisible );
     
 private:
 	CFSEmailUiSearchListVisualiser( CFreestyleEmailUiAppUi* aAppUi, CAlfEnv& aEnv, CAlfControlGroup& aSearchListControlGroup );
--- a/emailuis/emailui/inc/FreestyleEmailUiTextureManager.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiTextureManager.h	Thu Jan 07 12:38:38 2010 +0200
@@ -49,6 +49,7 @@
 	EListTextureNodeCollapsed,
 	EListTextureControlButton,
 	EListTextureMailboxDefaultIcon,
+	EListTextureNewEmailDefaultIcon,
 	EListControlBarMailboxDefaultIcon,
 	EBackgroundTextureViewerHeading,
 	EBackgroundTextureBar,
@@ -156,8 +157,21 @@
     EFolderListDeletedItemsTexturePopup,
     EFolderListServerFoldersTexturePopup,
     EFolderListEmailAccountTexturePopup,
-         
-    
+    // SORT LIST ICONS
+    ESortListAttachmentAscTexture,
+    ESortListAttachmentDescTexture,
+    ESortListDateAscTexture,
+    ESortListDateDescTexture,
+    ESortListFollowAscTexture,
+    ESortListFollowDescTexture,
+    ESortListPriorityAscTexture,
+    ESortListPriorityDescTexture,
+    ESortListSenderAscTexture,
+    ESortListSenderDescTexture,
+    ESortListSubjectAscTexture,
+    ESortListSubjectDescTexture,
+    ESortListUnreadAscTexture,
+    ESortListUnreadDescTexture,
 
 	// STATUS INDICATOR ICONS
 	ETextureStatusFirst, // non-texture
--- a/emailuis/emailui/inc/FreestyleEmailUiViewBase.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleEmailUiViewBase.h	Thu Jan 07 12:38:38 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 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"
@@ -15,7 +15,7 @@
 *                The class is not intended for instantation.
 *
 */
- 
+
 
 #ifndef __FREESTYLEEMAILUI_VIEWBASE_H__
 #define __FREESTYLEEMAILUI_VIEWBASE_H__
@@ -42,7 +42,7 @@
         EScreenLayoutChanged,
         EOther
         };
-    
+
 public: // from CAknView
     // dummy implementation for the base class abstact functions are needed to be able to define a constructor
     TUid Id() const;
@@ -50,17 +50,17 @@
 
 // <cmail> Toolbar
 private:
-    
+
     virtual void DoActivateL( const TVwsViewId& aPrevViewId,
         TUid aCustomMessageId,
         const TDesC8& aCustomMessage );
 // </cmail> Toolbar
-	
+
     /**
     * Inherited classes should NOT override this. The should override ChildDoDeactivate() instead.
     */
     void DoDeactivate();
-    
+
 public: // new functions
     /**
     * Returns a handle to the control group assosiated to this view, as given in the class constructor.
@@ -94,7 +94,7 @@
     virtual TBool IsPreviousMsgAvailable( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId, TFSMailMsgId& aFoundPrevMsgFolder ) const;
     virtual TInt MoveToNextMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundNextMsgId );
     virtual TInt MoveToPreviousMsgL( TFSMailMsgId aCurrentMsgId, TFSMailMsgId& aFoundPreviousMsgId );
-
+    virtual TInt MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId );
     /**
      * Do the transition effect for the view if effects are enabled.
      */
@@ -104,19 +104,19 @@
      * Prepares application exit. This is called by AppUi during cleanup before AppUi's destructor
      */
 	virtual void PrepareExitL();
-	
+
 	/**
 	 * Called when flip state changes.
 	 */
 	virtual void FlipStateChangedL( TBool aKeyboardFlipOpen );
 
 	/**
-	* This method is called from the appui when the focus removal timer expires.
-	* Each inherited view should implement own method for focus removal
-	* @param aShow Indicates if focus should become visible or removed
+	* This method is called from the appui when the focus state is changed.
+	* Each inherited view should implement own method for focus handling
+	* @param aVisible Indicates if focus should become visible or removed
 	*/
-	virtual void HandleTimerFocusStateChange( TBool aShow);
-	
+	virtual void FocusVisibilityChange( TBool aVisible );
+
 protected: // methods
 
     /**
@@ -126,7 +126,7 @@
     virtual void HandleForegroundEventL();
 
     /**
-    * Inherited classes should override this instead of DoDeactivate() 
+    * Inherited classes should override this instead of DoDeactivate()
     * to do the view deactivation
     */
     virtual void ChildDoDeactivate() = 0;
@@ -135,7 +135,7 @@
      * Make control group of the view visible and set to accept input.
      */
     virtual void ActivateControlGroup( TInt aDelay = 0 );
-    
+
     /**
      * Make control group of the view invisible and set to ignore input.
      */
@@ -146,7 +146,7 @@
     * some special tricks for transition effects
     */
     virtual void DoTransitionEffect( TBool aDirectionOut );
-    
+
     /**
     * Inheriting Alfred views should override this and return their parent
     * layout(s) in array given as parameter. Default implementation
@@ -166,7 +166,7 @@
     * (some long opening view is to be opened next)
     */
     void SetNextTransitionOutLong( TBool aLongTransitionOut );
-    
+
     TBool IsNextTransitionOutLong();
 
     /**
@@ -175,14 +175,14 @@
      * It doesn't hurt to call this also from views which cannot be externally activated.
      */
     void ViewEntered( const TVwsViewId& aPrevViewId );
-    
+
     /**
      * Derived classes should call this to do backwards navigation e.g. when user
      * presses "Back" button. This returns to the previous view, and in case the view
      * was activated externally, takes FsEmail to background and brings the previous
      * application to foreground.
      */
-    virtual void NavigateBackL();    
+    virtual void NavigateBackL();
 
     /**
      * Derived classes can call this utility function to set the middle soft key
@@ -191,23 +191,23 @@
     void ChangeMskCommandL( TInt aLabelResourceId );
 
 // <cmail> Toolbar
-protected: // toobar changes    
-    
+protected: // toobar changes
+
     /**
      * @see CAknView::DoActivateL
      */
-    virtual void ChildDoActivateL( 
+    virtual void ChildDoActivateL(
             const TVwsViewId& aPrevViewId,
             TUid aCustomMessageId,
             const TDesC8& aCustomMessage ) = 0;
-    
+
     /**
      * Return view's toolbar resource id.
      */
     virtual TInt ToolbarResourceId() const;
-   
+
     /**
-     * Called when whole toolbar needs to be updated. Creates and sets new 
+     * Called when whole toolbar needs to be updated. Creates and sets new
      * toolbar by calling ToolbarResourceId() method.
      */
     void UpdateToolbarL();
@@ -217,10 +217,10 @@
      * view.
      * @param aResourceId Resource ID of the toolbar.
      * @param aDimmedItems Array of items that will be dimmed.
-     */   
+     */
     virtual void GetInitiallyDimmedItemsL( const TInt aResourceId,
             RArray<TInt>& aDimmedItems ) const;
-    
+
     /**
      * Replaces single toolbar item with item from resource file. Control
      * must be of AVKON_BUTTON type.
@@ -236,7 +236,7 @@
      * Removes single toolbar item from toolbar.
      */
     void RemoveToolbarItem( const TInt aRemoveId );
-    
+
     /**
      * Hides toolbar.
      */
@@ -251,13 +251,13 @@
      * Dim/undim toolbar item.
      */
     void SetToolbarItemDimmed( const TInt aCommandId, const TBool aDimmed );
-    
+
     /**
      * Returns ETrue if view has toolbar.
      */
     virtual TBool HasToolbar() const;
-    
-protected: // Single click changes   
+
+protected: // Single click changes
     /**
      * Return current state of the focus visibility
      * @return ETrue if the focus should be shown
@@ -269,34 +269,34 @@
 	 * Inherited classes can override this and set desired status bar layout.
 	 */
 	virtual void SetStatusBarLayout();
-	            
+
 protected: // from MAknToolbarObserver
-    
+
     /**
      * @see MAknToolbarObserver::OfferToolbarEventL
      */
     void OfferToolbarEventL( TInt aCommand );
 
 // </cmail> Toolbar
-    
+
 protected: // construction
-    
+
     CFsEmailUiViewBase( CAlfControlGroup& aControlGroup, CFreestyleEmailUiAppUi& aAppUi );
-   
+
     /**
      * Return view active status. ETrue if the view is currently activated, EFalse otherwise.
      */
     TBool IsViewActive() const;
-   
+
 private:
 
     /**
      * Sets view's active status. Private to protect calling from inherited classes.
      */
     void SetViewActive( const TBool aActive );
-           
+
 protected: // data
-    
+
     CAlfControlGroup& iControlGroup;
     CFreestyleEmailUiAppUi& iAppUi;
 
@@ -305,9 +305,9 @@
 
     // Is focus visible
     TBool iFocusVisible;
-    
+
 private: // data
-    
+
     TUid iPreviousAppUid;
     // ID of the mailbox which was active before this view was activated from an external application
     TFSMailMsgId iActiveMailboxBeforeExternalActivation;
--- a/emailuis/emailui/inc/FreestyleMessageHeaderHTML.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/FreestyleMessageHeaderHTML.h	Thu Jan 07 12:38:38 2010 +0200
@@ -32,11 +32,11 @@
 class CFreestyleMessageHeaderHTML : public CBase
     {
 public:
-    IMPORT_C static void ExportL( CFSMailMessage& aMailMessage, RWriteStream& aWriteStream );
-    IMPORT_C static void ExportL( CFSMailMessage& aMailMessage, RFile& aFile );
-    IMPORT_C static void ExportL( CFSMailMessage& aMailMessage, RFs& aFs, const TPath& aFilePath);
+    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 CFreestyleMessageHeaderHTML* NewL( CFSMailMessage& aMailMessage );
+    IMPORT_C static CFreestyleMessageHeaderHTML* NewL( CFSMailMessage& aMailMessage, TInt aVisibleWidth   );
     
     ~CFreestyleMessageHeaderHTML();
     
@@ -45,7 +45,7 @@
     IMPORT_C void ExportL( RFs& aFs, const TPath& aFilePath) const;
     
 private:
-    CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage );
+    CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage, TInt aVisibleWidth   );
     void ConstructL();
     
     void HTMLStartL( RWriteStream& aWriteStream ) const;
@@ -70,7 +70,10 @@
     
     void ExportEmailAddressesL( RWriteStream& aWriteStream, 
                                 FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType, 
-                                const RPointerArray<CFSMailAddress>& aEmailAddresses ) const;
+                                const RPointerArray<CFSMailAddress>& aEmailAddresses,
+                                const TDesC8& aRowId,
+                                const TDesC8& aTableId,
+                                TInt aHeaderTextResourceId ) const;
     
     void AddEmailAddressL( RWriteStream& aWriteStream, 
                            FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType, 
@@ -107,6 +110,7 @@
     
 private:
     CFSMailMessage& iMailMessage; 
+    TInt            iVisibleWidth;
     
     RPointerArray<CFSMailMessagePart> iAttachments;
 };
--- a/emailuis/emailui/inc/freestyleemailuimailboxdeleter.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/freestyleemailuimailboxdeleter.h	Thu Jan 07 12:38:38 2010 +0200
@@ -91,6 +91,13 @@
      */
     void DeleteMailboxL();
 
+    /**
+     * Deletes the given mailbox. Displays also a confirmation dialog.
+     * @param aMailboxId The ID of the mail box to delete.
+     */
+    void DeleteMailboxL( const TFSMailMsgId& aMailboxId );
+
+
 protected: // from MProgressDialogCallback
 
     void DialogDismissedL( TInt aButtonId );
@@ -107,7 +114,15 @@
                               MFSEmailUiMailboxDeleteObserver& aObserver  );
 
 private:
-    
+
+	/**
+	 * Returns the mailboxes that can be deleted. Note that the given array is
+	 * left in the clean up stack.
+	 * @param aMailboxes The array where the mailboxes are added to.
+	 * @return The number of deletable mailboxes found.
+	 */
+	TInt GetDeletableMailboxesLC( RPointerArray<CFSMailBox>& aMailboxes );
+
     /**
      * Deletes a single mailbox.
      * @param aMailboxes Array containing the mailbox to be deleted.
@@ -123,6 +138,12 @@
     TBool DeleteMultipleMailboxesL( const RPointerArray<CFSMailBox>& aMailboxes );
     
     /**
+     * Deletes the selected mailboxes i.e. those of which IDs are in the
+     * iMailboxesToDelete array.
+     */
+    void DoDeleteSelectedMailboxesL();
+    
+    /**
      *  Confirms mailbox deletion. Behavior depends on the number of mailboxes
      *  to be deleted. aMailboxName is not used if aCount > 1.
      *  @param aCount Number of mailboxes to be removed.
--- a/emailuis/emailui/inc/ncsaifeditor.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/ncsaifeditor.h	Thu Jan 07 12:38:38 2010 +0200
@@ -36,7 +36,7 @@
     {
 public: // constructors/destructor
     
-    CNcsAifEditor( MNcsFieldSizeObserver* aSizeObserver );
+    CNcsAifEditor( MNcsFieldSizeObserver* aSizeObserver, const TDesC& aCaptionText );
     	
     void ConstructL( const CCoeControl* aParent,
                      TInt aNumberOfLines,
@@ -47,6 +47,7 @@
 public: // from CoeControl
     
     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+    void HandlePointerEventL( const TPointerEvent& aPointerEvent );
 
 public: // from MEikEdwinObserver
     
@@ -178,7 +179,8 @@
             const CNcsAifEntry* aEntry,
             TInt& aNrOfMatchesInText,
             TInt& aNrOfMatchesInEntryArray );
-    
+    void CompleteEntryL();
+
 private: // data
 
     RPointerArray<CNcsAifEntry> iArray;
@@ -193,6 +195,8 @@
     
     // Flag indicating whether add the leftover text to the end of the field
     TBool iAddLeftover;
+    TCursorSelection  iTextSelection;
+    TBool             iPartialRemove;
 	};
 
 
--- a/emailuis/emailui/inc/ncscomposeview.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/ncscomposeview.h	Thu Jan 07 12:38:38 2010 +0200
@@ -163,7 +163,7 @@
 
 public: // from MComposerFetchLogicCallback
 
-    void FetchLogicComplete( TComposerFetchState aState, TInt aError );
+    TBool FetchLogicComplete( TComposerFetchState aState, TInt aError );
 
 public: // new functions
 
--- a/emailuis/emailui/inc/ncseditor.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/inc/ncseditor.h	Thu Jan 07 12:38:38 2010 +0200
@@ -34,14 +34,15 @@
 /**
 *  CNcsEditor
 */
-class CNcsEditor : public CEikRichTextEditor, public MNcsControl
+class CNcsEditor : public CEikRichTextEditor, public MNcsControl, public MCoeCaptionRetrieverForFep
     {
 public: // construction and destruction
     
     CNcsEditor(
         MNcsFieldSizeObserver* aSizeObserver = NULL,
         TBool aHeaderField = ETrue,
-        TNcsEditorUsage aEditorUsage = ENcsEditorDefault );
+        TNcsEditorUsage aEditorUsage = ENcsEditorDefault,
+        const TDesC& aCaptionText = TPtrC() );
     
     void ConstructL( const CCoeControl* aParent,
                      TInt aNumberOfLines,
@@ -136,8 +137,12 @@
 
     virtual void EditObserver( TInt aStart, TInt aExtent );
     
-private: // methods used internally
-    
+public: // CEikEdwin
+    TCoeInputCapabilities InputCapabilities() const;  
+public: // MCoeCaptionRetrieverForFep
+    void GetCaptionForFep(TDes& aCaption) const;
+
+private: // methods used internally    
 	// <cmail> Platform layout change 
     void UpdateFontL();
     // </cmail> Platform layout change 
@@ -181,6 +186,9 @@
     
     // Real screen rectangle
     TRect iRealRect;
+
+	// Caption text for virtual ITU-T
+    HBufC*   iCaptionText; 
     };
 
 
--- a/emailuis/emailui/loc/freestyleemailui.loc	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/loc/freestyleemailui.loc	Thu Jan 07 12:38:38 2010 +0200
@@ -2593,4 +2593,22 @@
 // l:main_sp_fs_ctrlbar_ddmenu_pane_t1 
 // r:TB9.2
 //
-#define gtn_cmail_command_area_select_folders "Select folders"
+#define qtn_cmail_command_area_select_folders "Select folders"
+
+// d:Create a new email from command area button
+// l:main_sp_fs_ctrlbar_ddmenu_pane_t1
+// r:TB9.2
+//
+#define qtn_cmail_command_area_new "New"
+
+// d:Submenu option for the 150% zoom level in HTML viewer
+// l:list_single_popup_submenu_pane_t1/opt1
+// r:5250+
+//
+#define qtn_fse_zoom_level_150_percent         "150%"
+
+// d:Mail deleted notification
+// l:popup_note_window
+// r:TB9.2
+//
+#define qtn_fse_mail_deleted_note "Mail deleted"
--- a/emailuis/emailui/sis/commonemail.pkg	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/sis/commonemail.pkg	Thu Jan 07 12:38:38 2010 +0200
@@ -52,7 +52,7 @@
 ;-----------------------------------------------------------------------------
 ; MfE plugin installed as embedded sisx-package
 ;-------------------------
-@"..\..\..\..\..\complementary\eas\sis\eas_engine.sisx",(0x20012BE9)
+@"\ext\app\eas\sis\eas_engine.sisx",(0x20012BE9)
 
 ;-----------------------------------------------------------------------------
 ; Actual common email files to be installed
@@ -132,10 +132,7 @@
 "\epoc32\release\armv5\urel\cmailhandlerplugin.dll"              - "c:\sys\bin\cmailhandlerplugin.dll"
 "\epoc32\data\Z\Resource\Plugins\cmailhandlerplugin.rsc"         - "c:\resource\plugins\cmailhandlerplugin.rsc"
 "\epoc32\data\z\resource\apps\cmailhandlerplugin.mif"            - "c:\resource\apps\cmailhandlerplugin.mif"
-
-; Change path to normal resource path (not ECom res) when fixed in cmailhandlerplugin code
-; Uncomment in TB 9.2 branch after 5250+ branched
-;"\epoc32\data\Z\Resource\Plugins\emailwidget.rsc"                - "c:\resource\plugins\emailwidget.rsc"
+"\epoc32\data\Z\resource\apps\emailwidget.rsc"                   - "c:\resource\apps\emailwidget.rsc"
 
 ; ipservices
 "\epoc32\release\armv5\urel\ipssosplugin.dll"                    - "c:\sys\bin\ipssosplugin.dll"
--- a/emailuis/emailui/sis/commonemail_loc.pkg	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/sis/commonemail_loc.pkg	Thu Jan 07 12:38:38 2010 +0200
@@ -52,7 +52,7 @@
 ;-----------------------------------------------------------------------------
 ; MfE plugin installed as embedded sisx-package
 ;-------------------------
-@"..\..\..\..\..\complementary\eas\sis\eas_engine_loc.sisx",(0x20012BE9)
+@"\ext\app\eas\sis\eas_engine_loc.sisx",(0x20012BE9)
 
 ;-----------------------------------------------------------------------------
 ; Actual common email files to be installed
@@ -135,10 +135,8 @@
 "\epoc32\release\armv5\urel\cmailhandlerplugin.dll"              - "c:\sys\bin\cmailhandlerplugin.dll"
 "\epoc32\data\Z\Resource\Plugins\cmailhandlerplugin.rsc"         - "c:\resource\plugins\cmailhandlerplugin.rsc"
 "\epoc32\data\z\resource\apps\cmailhandlerplugin.mif"            - "c:\resource\apps\cmailhandlerplugin.mif"
-
-; Change path to normal resource path (not ECom res) when fixed in cmailhandlerplugin code
-; Uncomment in TB 9.2 branch after 5250+ branched
-;"\epoc32\data\Z\Resource\Plugins\emailwidget.rsc"                - "c:\resource\plugins\emailwidget.rsc"
+; Following line is localized, so this Engineering English line is commented out
+;"\epoc32\data\Z\resource\apps\emailwidget.rsc"                   - "c:\resource\apps\emailwidget.rsc"
 
 ; ipservices
 "\epoc32\release\armv5\urel\ipssosplugin.dll"                    - "c:\sys\bin\ipssosplugin.dll"
@@ -259,6 +257,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r01"              - "c:\resource\apps\freestyleemailui.r01"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r01"         - "c:\resource\apps\gsemailsettingsplugin.r01"
     "\epoc32\data\z\resource\apps\fsmailserver.r01"                  - "c:\resource\apps\fsmailserver.r01"
+    "\epoc32\data\z\resource\apps\emailwidget.r01"                   - "c:\resource\apps\emailwidget.r01"
     "\epoc32\data\z\resource\ipssossettings.r01"                     - "c:\resource\ipssossettings.r01"
     "\epoc32\data\z\resource\apps\fscpocplugin.r01"                  - "c:\resource\apps\fscpocplugin.r01"
     "\epoc32\data\z\resource\apps\fsccallplugin.r01"                 - "c:\resource\apps\fsccallplugin.r01"
@@ -274,6 +273,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r02"              - "c:\resource\apps\freestyleemailui.r02"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r02"         - "c:\resource\apps\gsemailsettingsplugin.r02"
     "\epoc32\data\z\resource\apps\fsmailserver.r02"                  - "c:\resource\apps\fsmailserver.r02"
+    "\epoc32\data\z\resource\apps\emailwidget.r02"                   - "c:\resource\apps\emailwidget.r02"
     "\epoc32\data\z\resource\ipssossettings.r02"                     - "c:\resource\ipssossettings.r02"
     "\epoc32\data\z\resource\apps\fscpocplugin.r02"                  - "c:\resource\apps\fscpocplugin.r02"
     "\epoc32\data\z\resource\apps\fsccallplugin.r02"                 - "c:\resource\apps\fsccallplugin.r02"
@@ -289,6 +289,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r03"              - "c:\resource\apps\freestyleemailui.r03"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r03"         - "c:\resource\apps\gsemailsettingsplugin.r03"
     "\epoc32\data\z\resource\apps\fsmailserver.r03"                  - "c:\resource\apps\fsmailserver.r03"
+    "\epoc32\data\z\resource\apps\emailwidget.r03"                   - "c:\resource\apps\emailwidget.r03"
     "\epoc32\data\z\resource\ipssossettings.r03"                     - "c:\resource\ipssossettings.r03"
     "\epoc32\data\z\resource\apps\fscpocplugin.r03"                  - "c:\resource\apps\fscpocplugin.r03"
     "\epoc32\data\z\resource\apps\fsccallplugin.r03"                 - "c:\resource\apps\fsccallplugin.r03"
@@ -304,6 +305,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r04"              - "c:\resource\apps\freestyleemailui.r04"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r04"         - "c:\resource\apps\gsemailsettingsplugin.r04"
     "\epoc32\data\z\resource\apps\fsmailserver.r04"                  - "c:\resource\apps\fsmailserver.r04"
+    "\epoc32\data\z\resource\apps\emailwidget.r04"                   - "c:\resource\apps\emailwidget.r04"
     "\epoc32\data\z\resource\ipssossettings.r04"                     - "c:\resource\ipssossettings.r04"
     "\epoc32\data\z\resource\apps\fscpocplugin.r04"                  - "c:\resource\apps\fscpocplugin.r04"
     "\epoc32\data\z\resource\apps\fsccallplugin.r04"                 - "c:\resource\apps\fsccallplugin.r04"
@@ -319,6 +321,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r05"              - "c:\resource\apps\freestyleemailui.r05"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r05"         - "c:\resource\apps\gsemailsettingsplugin.r05"
     "\epoc32\data\z\resource\apps\fsmailserver.r05"                  - "c:\resource\apps\fsmailserver.r05"
+    "\epoc32\data\z\resource\apps\emailwidget.r05"                   - "c:\resource\apps\emailwidget.r05"
     "\epoc32\data\z\resource\ipssossettings.r05"                     - "c:\resource\ipssossettings.r05"
     "\epoc32\data\z\resource\apps\fscpocplugin.r05"                  - "c:\resource\apps\fscpocplugin.r05"
     "\epoc32\data\z\resource\apps\fsccallplugin.r05"                 - "c:\resource\apps\fsccallplugin.r05"
@@ -334,6 +337,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r06"              - "c:\resource\apps\freestyleemailui.r06"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r06"         - "c:\resource\apps\gsemailsettingsplugin.r06"
     "\epoc32\data\z\resource\apps\fsmailserver.r06"                  - "c:\resource\apps\fsmailserver.r06"
+    "\epoc32\data\z\resource\apps\emailwidget.r06"                   - "c:\resource\apps\emailwidget.r06"
     "\epoc32\data\z\resource\ipssossettings.r06"                     - "c:\resource\ipssossettings.r06"
     "\epoc32\data\z\resource\apps\fscpocplugin.r06"                  - "c:\resource\apps\fscpocplugin.r06"
     "\epoc32\data\z\resource\apps\fsccallplugin.r06"                 - "c:\resource\apps\fsccallplugin.r06"
@@ -349,6 +353,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r07"              - "c:\resource\apps\freestyleemailui.r07"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r07"         - "c:\resource\apps\gsemailsettingsplugin.r07"
     "\epoc32\data\z\resource\apps\fsmailserver.r07"                  - "c:\resource\apps\fsmailserver.r07"
+    "\epoc32\data\z\resource\apps\emailwidget.r07"                   - "c:\resource\apps\emailwidget.r07"
     "\epoc32\data\z\resource\ipssossettings.r07"                     - "c:\resource\ipssossettings.r07"
     "\epoc32\data\z\resource\apps\fscpocplugin.r07"                  - "c:\resource\apps\fscpocplugin.r07"
     "\epoc32\data\z\resource\apps\fsccallplugin.r07"                 - "c:\resource\apps\fsccallplugin.r07"
@@ -364,6 +369,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r08"              - "c:\resource\apps\freestyleemailui.r08"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r08"         - "c:\resource\apps\gsemailsettingsplugin.r08"
     "\epoc32\data\z\resource\apps\fsmailserver.r08"                  - "c:\resource\apps\fsmailserver.r08"
+    "\epoc32\data\z\resource\apps\emailwidget.r08"                   - "c:\resource\apps\emailwidget.r08"
     "\epoc32\data\z\resource\ipssossettings.r08"                     - "c:\resource\ipssossettings.r08"
     "\epoc32\data\z\resource\apps\fscpocplugin.r08"                  - "c:\resource\apps\fscpocplugin.r08"
     "\epoc32\data\z\resource\apps\fsccallplugin.r08"                 - "c:\resource\apps\fsccallplugin.r08"
@@ -379,6 +385,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r09"              - "c:\resource\apps\freestyleemailui.r09"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r09"         - "c:\resource\apps\gsemailsettingsplugin.r09"
     "\epoc32\data\z\resource\apps\fsmailserver.r09"                  - "c:\resource\apps\fsmailserver.r09"
+    "\epoc32\data\z\resource\apps\emailwidget.r09"                   - "c:\resource\apps\emailwidget.r09"
     "\epoc32\data\z\resource\ipssossettings.r09"                     - "c:\resource\ipssossettings.r09"
     "\epoc32\data\z\resource\apps\fscpocplugin.r09"                  - "c:\resource\apps\fscpocplugin.r09"
     "\epoc32\data\z\resource\apps\fsccallplugin.r09"                 - "c:\resource\apps\fsccallplugin.r09"
@@ -394,6 +401,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r10"              - "c:\resource\apps\freestyleemailui.r10"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r10"         - "c:\resource\apps\gsemailsettingsplugin.r10"
     "\epoc32\data\z\resource\apps\fsmailserver.r10"                  - "c:\resource\apps\fsmailserver.r10"
+    "\epoc32\data\z\resource\apps\emailwidget.r10"                   - "c:\resource\apps\emailwidget.r10"
     "\epoc32\data\z\resource\ipssossettings.r10"                     - "c:\resource\ipssossettings.r10"
     "\epoc32\data\z\resource\apps\fscpocplugin.r10"                  - "c:\resource\apps\fscpocplugin.r10"
     "\epoc32\data\z\resource\apps\fsccallplugin.r10"                 - "c:\resource\apps\fsccallplugin.r10"
@@ -409,6 +417,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r13"              - "c:\resource\apps\freestyleemailui.r13"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r13"         - "c:\resource\apps\gsemailsettingsplugin.r13"
     "\epoc32\data\z\resource\apps\fsmailserver.r13"                  - "c:\resource\apps\fsmailserver.r13"
+    "\epoc32\data\z\resource\apps\emailwidget.r13"                   - "c:\resource\apps\emailwidget.r13"
     "\epoc32\data\z\resource\ipssossettings.r13"                     - "c:\resource\ipssossettings.r13"
     "\epoc32\data\z\resource\apps\fscpocplugin.r13"                  - "c:\resource\apps\fscpocplugin.r13"
     "\epoc32\data\z\resource\apps\fsccallplugin.r13"                 - "c:\resource\apps\fsccallplugin.r13"
@@ -424,6 +433,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r14"              - "c:\resource\apps\freestyleemailui.r14"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r14"         - "c:\resource\apps\gsemailsettingsplugin.r14"
     "\epoc32\data\z\resource\apps\fsmailserver.r14"                  - "c:\resource\apps\fsmailserver.r14"
+    "\epoc32\data\z\resource\apps\emailwidget.r14"                   - "c:\resource\apps\emailwidget.r14"
     "\epoc32\data\z\resource\ipssossettings.r14"                     - "c:\resource\ipssossettings.r14"
     "\epoc32\data\z\resource\apps\fscpocplugin.r14"                  - "c:\resource\apps\fscpocplugin.r14"
     "\epoc32\data\z\resource\apps\fsccallplugin.r14"                 - "c:\resource\apps\fsccallplugin.r14"
@@ -439,6 +449,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r15"              - "c:\resource\apps\freestyleemailui.r15"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r15"         - "c:\resource\apps\gsemailsettingsplugin.r15"
     "\epoc32\data\z\resource\apps\fsmailserver.r15"                  - "c:\resource\apps\fsmailserver.r15"
+    "\epoc32\data\z\resource\apps\emailwidget.r15"                   - "c:\resource\apps\emailwidget.r15"
     "\epoc32\data\z\resource\ipssossettings.r15"                     - "c:\resource\ipssossettings.r15"
     "\epoc32\data\z\resource\apps\fscpocplugin.r15"                  - "c:\resource\apps\fscpocplugin.r15"
     "\epoc32\data\z\resource\apps\fsccallplugin.r15"                 - "c:\resource\apps\fsccallplugin.r15"
@@ -454,6 +465,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r16"              - "c:\resource\apps\freestyleemailui.r16"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r16"         - "c:\resource\apps\gsemailsettingsplugin.r16"
     "\epoc32\data\z\resource\apps\fsmailserver.r16"                  - "c:\resource\apps\fsmailserver.r16"
+    "\epoc32\data\z\resource\apps\emailwidget.r16"                   - "c:\resource\apps\emailwidget.r16"
     "\epoc32\data\z\resource\ipssossettings.r16"                     - "c:\resource\ipssossettings.r16"
     "\epoc32\data\z\resource\apps\fscpocplugin.r16"                  - "c:\resource\apps\fscpocplugin.r16"
     "\epoc32\data\z\resource\apps\fsccallplugin.r16"                 - "c:\resource\apps\fsccallplugin.r16"
@@ -469,6 +481,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r17"              - "c:\resource\apps\freestyleemailui.r17"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r17"         - "c:\resource\apps\gsemailsettingsplugin.r17"
     "\epoc32\data\z\resource\apps\fsmailserver.r17"                  - "c:\resource\apps\fsmailserver.r17"
+    "\epoc32\data\z\resource\apps\emailwidget.r17"                   - "c:\resource\apps\emailwidget.r17"
     "\epoc32\data\z\resource\ipssossettings.r17"                     - "c:\resource\ipssossettings.r17"
     "\epoc32\data\z\resource\apps\fscpocplugin.r17"                  - "c:\resource\apps\fscpocplugin.r17"
     "\epoc32\data\z\resource\apps\fsccallplugin.r17"                 - "c:\resource\apps\fsccallplugin.r17"
@@ -484,6 +497,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r18"              - "c:\resource\apps\freestyleemailui.r18"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r18"         - "c:\resource\apps\gsemailsettingsplugin.r18"
     "\epoc32\data\z\resource\apps\fsmailserver.r18"                  - "c:\resource\apps\fsmailserver.r18"
+    "\epoc32\data\z\resource\apps\emailwidget.r18"                   - "c:\resource\apps\emailwidget.r18"
     "\epoc32\data\z\resource\ipssossettings.r18"                     - "c:\resource\ipssossettings.r18"
     "\epoc32\data\z\resource\apps\fscpocplugin.r18"                  - "c:\resource\apps\fscpocplugin.r18"
     "\epoc32\data\z\resource\apps\fsccallplugin.r18"                 - "c:\resource\apps\fsccallplugin.r18"
@@ -499,6 +513,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r25"              - "c:\resource\apps\freestyleemailui.r25"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r25"         - "c:\resource\apps\gsemailsettingsplugin.r25"
     "\epoc32\data\z\resource\apps\fsmailserver.r25"                  - "c:\resource\apps\fsmailserver.r25"
+    "\epoc32\data\z\resource\apps\emailwidget.r25"                   - "c:\resource\apps\emailwidget.r25"
     "\epoc32\data\z\resource\ipssossettings.r25"                     - "c:\resource\ipssossettings.r25"
     "\epoc32\data\z\resource\apps\fscpocplugin.r25"                  - "c:\resource\apps\fscpocplugin.r25"
     "\epoc32\data\z\resource\apps\fsccallplugin.r25"                 - "c:\resource\apps\fsccallplugin.r25"
@@ -514,6 +529,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r26"              - "c:\resource\apps\freestyleemailui.r26"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r26"         - "c:\resource\apps\gsemailsettingsplugin.r26"
     "\epoc32\data\z\resource\apps\fsmailserver.r26"                  - "c:\resource\apps\fsmailserver.r26"
+    "\epoc32\data\z\resource\apps\emailwidget.r26"                   - "c:\resource\apps\emailwidget.r26"
     "\epoc32\data\z\resource\ipssossettings.r26"                     - "c:\resource\ipssossettings.r26"
     "\epoc32\data\z\resource\apps\fscpocplugin.r26"                  - "c:\resource\apps\fscpocplugin.r26"
     "\epoc32\data\z\resource\apps\fsccallplugin.r26"                 - "c:\resource\apps\fsccallplugin.r26"
@@ -529,6 +545,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r27"              - "c:\resource\apps\freestyleemailui.r27"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r27"         - "c:\resource\apps\gsemailsettingsplugin.r27"
     "\epoc32\data\z\resource\apps\fsmailserver.r27"                  - "c:\resource\apps\fsmailserver.r27"
+    "\epoc32\data\z\resource\apps\emailwidget.r27"                   - "c:\resource\apps\emailwidget.r27"
     "\epoc32\data\z\resource\ipssossettings.r27"                     - "c:\resource\ipssossettings.r27"
     "\epoc32\data\z\resource\apps\fscpocplugin.r27"                  - "c:\resource\apps\fscpocplugin.r27"
     "\epoc32\data\z\resource\apps\fsccallplugin.r27"                 - "c:\resource\apps\fsccallplugin.r27"
@@ -544,6 +561,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r28"              - "c:\resource\apps\freestyleemailui.r28"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r28"         - "c:\resource\apps\gsemailsettingsplugin.r28"
     "\epoc32\data\z\resource\apps\fsmailserver.r28"                  - "c:\resource\apps\fsmailserver.r28"
+    "\epoc32\data\z\resource\apps\emailwidget.r28"                   - "c:\resource\apps\emailwidget.r28"
     "\epoc32\data\z\resource\ipssossettings.r28"                     - "c:\resource\ipssossettings.r28"
     "\epoc32\data\z\resource\apps\fscpocplugin.r28"                  - "c:\resource\apps\fscpocplugin.r28"
     "\epoc32\data\z\resource\apps\fsccallplugin.r28"                 - "c:\resource\apps\fsccallplugin.r28"
@@ -559,6 +577,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r29"              - "c:\resource\apps\freestyleemailui.r29"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r29"         - "c:\resource\apps\gsemailsettingsplugin.r29"
     "\epoc32\data\z\resource\apps\fsmailserver.r29"                  - "c:\resource\apps\fsmailserver.r29"
+    "\epoc32\data\z\resource\apps\emailwidget.r29"                   - "c:\resource\apps\emailwidget.r29"
     "\epoc32\data\z\resource\ipssossettings.r29"                     - "c:\resource\ipssossettings.r29"
     "\epoc32\data\z\resource\apps\fscpocplugin.r29"                  - "c:\resource\apps\fscpocplugin.r29"
     "\epoc32\data\z\resource\apps\fsccallplugin.r29"                 - "c:\resource\apps\fsccallplugin.r29"
@@ -574,6 +593,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r30"              - "c:\resource\apps\freestyleemailui.r30"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r30"         - "c:\resource\apps\gsemailsettingsplugin.r30"
     "\epoc32\data\z\resource\apps\fsmailserver.r30"                  - "c:\resource\apps\fsmailserver.r30"
+    "\epoc32\data\z\resource\apps\emailwidget.r30"                   - "c:\resource\apps\emailwidget.r30"
     "\epoc32\data\z\resource\ipssossettings.r30"                     - "c:\resource\ipssossettings.r30"
     "\epoc32\data\z\resource\apps\fscpocplugin.r30"                  - "c:\resource\apps\fscpocplugin.r30"
     "\epoc32\data\z\resource\apps\fsccallplugin.r30"                 - "c:\resource\apps\fsccallplugin.r30"
@@ -589,6 +609,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r31"              - "c:\resource\apps\freestyleemailui.r31"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r31"         - "c:\resource\apps\gsemailsettingsplugin.r31"
     "\epoc32\data\z\resource\apps\fsmailserver.r31"                  - "c:\resource\apps\fsmailserver.r31"
+    "\epoc32\data\z\resource\apps\emailwidget.r31"                   - "c:\resource\apps\emailwidget.r31"
     "\epoc32\data\z\resource\ipssossettings.r31"                     - "c:\resource\ipssossettings.r31"
     "\epoc32\data\z\resource\apps\fscpocplugin.r31"                  - "c:\resource\apps\fscpocplugin.r31"
     "\epoc32\data\z\resource\apps\fsccallplugin.r31"                 - "c:\resource\apps\fsccallplugin.r31"
@@ -604,6 +625,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r32"              - "c:\resource\apps\freestyleemailui.r32"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r32"         - "c:\resource\apps\gsemailsettingsplugin.r32"
     "\epoc32\data\z\resource\apps\fsmailserver.r32"                  - "c:\resource\apps\fsmailserver.r32"
+    "\epoc32\data\z\resource\apps\emailwidget.r32"                   - "c:\resource\apps\emailwidget.r32"
     "\epoc32\data\z\resource\ipssossettings.r32"                     - "c:\resource\ipssossettings.r32"
     "\epoc32\data\z\resource\apps\fscpocplugin.r32"                  - "c:\resource\apps\fscpocplugin.r32"
     "\epoc32\data\z\resource\apps\fsccallplugin.r32"                 - "c:\resource\apps\fsccallplugin.r32"
@@ -619,6 +641,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r33"              - "c:\resource\apps\freestyleemailui.r33"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r33"         - "c:\resource\apps\gsemailsettingsplugin.r33"
     "\epoc32\data\z\resource\apps\fsmailserver.r33"                  - "c:\resource\apps\fsmailserver.r33"
+    "\epoc32\data\z\resource\apps\emailwidget.r33"                   - "c:\resource\apps\emailwidget.r33"
     "\epoc32\data\z\resource\ipssossettings.r33"                     - "c:\resource\ipssossettings.r33"
     "\epoc32\data\z\resource\apps\fscpocplugin.r33"                  - "c:\resource\apps\fscpocplugin.r33"
     "\epoc32\data\z\resource\apps\fsccallplugin.r33"                 - "c:\resource\apps\fsccallplugin.r33"
@@ -634,6 +657,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r37"              - "c:\resource\apps\freestyleemailui.r37"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r37"         - "c:\resource\apps\gsemailsettingsplugin.r37"
     "\epoc32\data\z\resource\apps\fsmailserver.r37"                  - "c:\resource\apps\fsmailserver.r37"
+    "\epoc32\data\z\resource\apps\emailwidget.r37"                   - "c:\resource\apps\emailwidget.r37"
     "\epoc32\data\z\resource\ipssossettings.r37"                     - "c:\resource\ipssossettings.r37"
     "\epoc32\data\z\resource\apps\fscpocplugin.r37"                  - "c:\resource\apps\fscpocplugin.r37"
     "\epoc32\data\z\resource\apps\fsccallplugin.r37"                 - "c:\resource\apps\fsccallplugin.r37"
@@ -649,6 +673,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r39"              - "c:\resource\apps\freestyleemailui.r39"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r39"         - "c:\resource\apps\gsemailsettingsplugin.r39"
     "\epoc32\data\z\resource\apps\fsmailserver.r39"                  - "c:\resource\apps\fsmailserver.r39"
+    "\epoc32\data\z\resource\apps\emailwidget.r39"                   - "c:\resource\apps\emailwidget.r39"
     "\epoc32\data\z\resource\ipssossettings.r39"                     - "c:\resource\ipssossettings.r39"
     "\epoc32\data\z\resource\apps\fscpocplugin.r39"                  - "c:\resource\apps\fscpocplugin.r39"
     "\epoc32\data\z\resource\apps\fsccallplugin.r39"                 - "c:\resource\apps\fsccallplugin.r39"
@@ -664,6 +689,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r42"              - "c:\resource\apps\freestyleemailui.r42"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r42"         - "c:\resource\apps\gsemailsettingsplugin.r42"
     "\epoc32\data\z\resource\apps\fsmailserver.r42"                  - "c:\resource\apps\fsmailserver.r42"
+    "\epoc32\data\z\resource\apps\emailwidget.r42"                   - "c:\resource\apps\emailwidget.r42"
     "\epoc32\data\z\resource\ipssossettings.r42"                     - "c:\resource\ipssossettings.r42"
     "\epoc32\data\z\resource\apps\fscpocplugin.r42"                  - "c:\resource\apps\fscpocplugin.r42"
     "\epoc32\data\z\resource\apps\fsccallplugin.r42"                 - "c:\resource\apps\fsccallplugin.r42"
@@ -679,6 +705,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r44"              - "c:\resource\apps\freestyleemailui.r44"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r44"         - "c:\resource\apps\gsemailsettingsplugin.r44"
     "\epoc32\data\z\resource\apps\fsmailserver.r44"                  - "c:\resource\apps\fsmailserver.r44"
+    "\epoc32\data\z\resource\apps\emailwidget.r44"                   - "c:\resource\apps\emailwidget.r44"
     "\epoc32\data\z\resource\ipssossettings.r44"                     - "c:\resource\ipssossettings.r44"
     "\epoc32\data\z\resource\apps\fscpocplugin.r44"                  - "c:\resource\apps\fscpocplugin.r44"
     "\epoc32\data\z\resource\apps\fsccallplugin.r44"                 - "c:\resource\apps\fsccallplugin.r44"
@@ -694,6 +721,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r45"              - "c:\resource\apps\freestyleemailui.r45"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r45"         - "c:\resource\apps\gsemailsettingsplugin.r45"
     "\epoc32\data\z\resource\apps\fsmailserver.r45"                  - "c:\resource\apps\fsmailserver.r45"
+    "\epoc32\data\z\resource\apps\emailwidget.r45"                   - "c:\resource\apps\emailwidget.r45"
     "\epoc32\data\z\resource\ipssossettings.r45"                     - "c:\resource\ipssossettings.r45"
     "\epoc32\data\z\resource\apps\fscpocplugin.r45"                  - "c:\resource\apps\fscpocplugin.r45"
     "\epoc32\data\z\resource\apps\fsccallplugin.r45"                 - "c:\resource\apps\fsccallplugin.r45"
@@ -709,6 +737,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r49"              - "c:\resource\apps\freestyleemailui.r49"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r49"         - "c:\resource\apps\gsemailsettingsplugin.r49"
     "\epoc32\data\z\resource\apps\fsmailserver.r49"                  - "c:\resource\apps\fsmailserver.r49"
+    "\epoc32\data\z\resource\apps\emailwidget.r49"                   - "c:\resource\apps\emailwidget.r49"
     "\epoc32\data\z\resource\ipssossettings.r49"                     - "c:\resource\ipssossettings.r49"
     "\epoc32\data\z\resource\apps\fscpocplugin.r49"                  - "c:\resource\apps\fscpocplugin.r49"
     "\epoc32\data\z\resource\apps\fsccallplugin.r49"                 - "c:\resource\apps\fsccallplugin.r49"
@@ -724,6 +753,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r50"              - "c:\resource\apps\freestyleemailui.r50"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r50"         - "c:\resource\apps\gsemailsettingsplugin.r50"
     "\epoc32\data\z\resource\apps\fsmailserver.r50"                  - "c:\resource\apps\fsmailserver.r50"
+    "\epoc32\data\z\resource\apps\emailwidget.r50"                   - "c:\resource\apps\emailwidget.r50"
     "\epoc32\data\z\resource\ipssossettings.r50"                     - "c:\resource\ipssossettings.r50"
     "\epoc32\data\z\resource\apps\fscpocplugin.r50"                  - "c:\resource\apps\fscpocplugin.r50"
     "\epoc32\data\z\resource\apps\fsccallplugin.r50"                 - "c:\resource\apps\fsccallplugin.r50"
@@ -739,6 +769,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r51"              - "c:\resource\apps\freestyleemailui.r51"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r51"         - "c:\resource\apps\gsemailsettingsplugin.r51"
     "\epoc32\data\z\resource\apps\fsmailserver.r51"                  - "c:\resource\apps\fsmailserver.r51"
+    "\epoc32\data\z\resource\apps\emailwidget.r51"                   - "c:\resource\apps\emailwidget.r51"
     "\epoc32\data\z\resource\ipssossettings.r51"                     - "c:\resource\ipssossettings.r51"
     "\epoc32\data\z\resource\apps\fscpocplugin.r51"                  - "c:\resource\apps\fscpocplugin.r51"
     "\epoc32\data\z\resource\apps\fsccallplugin.r51"                 - "c:\resource\apps\fsccallplugin.r51"
@@ -754,6 +785,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r54"              - "c:\resource\apps\freestyleemailui.r54"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r54"         - "c:\resource\apps\gsemailsettingsplugin.r54"
     "\epoc32\data\z\resource\apps\fsmailserver.r54"                  - "c:\resource\apps\fsmailserver.r54"
+    "\epoc32\data\z\resource\apps\emailwidget.r54"                   - "c:\resource\apps\emailwidget.r54"
     "\epoc32\data\z\resource\ipssossettings.r54"                     - "c:\resource\ipssossettings.r54"
     "\epoc32\data\z\resource\apps\fscpocplugin.r54"                  - "c:\resource\apps\fscpocplugin.r54"
     "\epoc32\data\z\resource\apps\fsccallplugin.r54"                 - "c:\resource\apps\fsccallplugin.r54"
@@ -769,6 +801,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r57"              - "c:\resource\apps\freestyleemailui.r57"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r57"         - "c:\resource\apps\gsemailsettingsplugin.r57"
     "\epoc32\data\z\resource\apps\fsmailserver.r57"                  - "c:\resource\apps\fsmailserver.r57"
+    "\epoc32\data\z\resource\apps\emailwidget.r57"                   - "c:\resource\apps\emailwidget.r57"
     "\epoc32\data\z\resource\ipssossettings.r57"                     - "c:\resource\ipssossettings.r57"
     "\epoc32\data\z\resource\apps\fscpocplugin.r57"                  - "c:\resource\apps\fscpocplugin.r57"
     "\epoc32\data\z\resource\apps\fsccallplugin.r57"                 - "c:\resource\apps\fsccallplugin.r57"
@@ -784,6 +817,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r59"              - "c:\resource\apps\freestyleemailui.r59"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r59"         - "c:\resource\apps\gsemailsettingsplugin.r59"
     "\epoc32\data\z\resource\apps\fsmailserver.r59"                  - "c:\resource\apps\fsmailserver.r59"
+    "\epoc32\data\z\resource\apps\emailwidget.r59"                   - "c:\resource\apps\emailwidget.r59"
     "\epoc32\data\z\resource\ipssossettings.r59"                     - "c:\resource\ipssossettings.r59"
     "\epoc32\data\z\resource\apps\fscpocplugin.r59"                  - "c:\resource\apps\fscpocplugin.r59"
     "\epoc32\data\z\resource\apps\fsccallplugin.r59"                 - "c:\resource\apps\fsccallplugin.r59"
@@ -799,6 +833,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r67"              - "c:\resource\apps\freestyleemailui.r67"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r67"         - "c:\resource\apps\gsemailsettingsplugin.r67"
     "\epoc32\data\z\resource\apps\fsmailserver.r67"                  - "c:\resource\apps\fsmailserver.r67"
+    "\epoc32\data\z\resource\apps\emailwidget.r67"                   - "c:\resource\apps\emailwidget.r67"
     "\epoc32\data\z\resource\ipssossettings.r67"                     - "c:\resource\ipssossettings.r67"
     "\epoc32\data\z\resource\apps\fscpocplugin.r67"                  - "c:\resource\apps\fscpocplugin.r67"
     "\epoc32\data\z\resource\apps\fsccallplugin.r67"                 - "c:\resource\apps\fsccallplugin.r67"
@@ -814,6 +849,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r68"              - "c:\resource\apps\freestyleemailui.r68"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r68"         - "c:\resource\apps\gsemailsettingsplugin.r68"
     "\epoc32\data\z\resource\apps\fsmailserver.r68"                  - "c:\resource\apps\fsmailserver.r68"
+    "\epoc32\data\z\resource\apps\emailwidget.r68"                   - "c:\resource\apps\emailwidget.r68"
     "\epoc32\data\z\resource\ipssossettings.r68"                     - "c:\resource\ipssossettings.r68"
     "\epoc32\data\z\resource\apps\fscpocplugin.r68"                  - "c:\resource\apps\fscpocplugin.r68"
     "\epoc32\data\z\resource\apps\fsccallplugin.r68"                 - "c:\resource\apps\fsccallplugin.r68"
@@ -829,6 +865,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r70"              - "c:\resource\apps\freestyleemailui.r70"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r70"         - "c:\resource\apps\gsemailsettingsplugin.r70"
     "\epoc32\data\z\resource\apps\fsmailserver.r70"                  - "c:\resource\apps\fsmailserver.r70"
+    "\epoc32\data\z\resource\apps\emailwidget.r70"                   - "c:\resource\apps\emailwidget.r70"
     "\epoc32\data\z\resource\ipssossettings.r70"                     - "c:\resource\ipssossettings.r70"
     "\epoc32\data\z\resource\apps\fscpocplugin.r70"                  - "c:\resource\apps\fscpocplugin.r70"
     "\epoc32\data\z\resource\apps\fsccallplugin.r70"                 - "c:\resource\apps\fsccallplugin.r70"
@@ -844,6 +881,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r76"              - "c:\resource\apps\freestyleemailui.r76"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r76"         - "c:\resource\apps\gsemailsettingsplugin.r76"
     "\epoc32\data\z\resource\apps\fsmailserver.r76"                  - "c:\resource\apps\fsmailserver.r76"
+    "\epoc32\data\z\resource\apps\emailwidget.r76"                   - "c:\resource\apps\emailwidget.r76"
     "\epoc32\data\z\resource\ipssossettings.r76"                     - "c:\resource\ipssossettings.r76"
     "\epoc32\data\z\resource\apps\fscpocplugin.r76"                  - "c:\resource\apps\fscpocplugin.r76"
     "\epoc32\data\z\resource\apps\fsccallplugin.r76"                 - "c:\resource\apps\fsccallplugin.r76"
@@ -859,6 +897,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r78"              - "c:\resource\apps\freestyleemailui.r78"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r78"         - "c:\resource\apps\gsemailsettingsplugin.r78"
     "\epoc32\data\z\resource\apps\fsmailserver.r78"                  - "c:\resource\apps\fsmailserver.r78"
+    "\epoc32\data\z\resource\apps\emailwidget.r78"                   - "c:\resource\apps\emailwidget.r78"
     "\epoc32\data\z\resource\ipssossettings.r78"                     - "c:\resource\ipssossettings.r78"
     "\epoc32\data\z\resource\apps\fscpocplugin.r78"                  - "c:\resource\apps\fscpocplugin.r78"
     "\epoc32\data\z\resource\apps\fsccallplugin.r78"                 - "c:\resource\apps\fsccallplugin.r78"
@@ -874,6 +913,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r79"              - "c:\resource\apps\freestyleemailui.r79"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r79"         - "c:\resource\apps\gsemailsettingsplugin.r79"
     "\epoc32\data\z\resource\apps\fsmailserver.r79"                  - "c:\resource\apps\fsmailserver.r79"
+    "\epoc32\data\z\resource\apps\emailwidget.r79"                   - "c:\resource\apps\emailwidget.r79"
     "\epoc32\data\z\resource\ipssossettings.r79"                     - "c:\resource\ipssossettings.r79"
     "\epoc32\data\z\resource\apps\fscpocplugin.r79"                  - "c:\resource\apps\fscpocplugin.r79"
     "\epoc32\data\z\resource\apps\fsccallplugin.r79"                 - "c:\resource\apps\fsccallplugin.r79"
@@ -889,6 +929,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r83"              - "c:\resource\apps\freestyleemailui.r83"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r83"         - "c:\resource\apps\gsemailsettingsplugin.r83"
     "\epoc32\data\z\resource\apps\fsmailserver.r83"                  - "c:\resource\apps\fsmailserver.r83"
+    "\epoc32\data\z\resource\apps\emailwidget.r83"                   - "c:\resource\apps\emailwidget.r83"
     "\epoc32\data\z\resource\ipssossettings.r83"                     - "c:\resource\ipssossettings.r83"
     "\epoc32\data\z\resource\apps\fscpocplugin.r83"                  - "c:\resource\apps\fscpocplugin.r83"
     "\epoc32\data\z\resource\apps\fsccallplugin.r83"                 - "c:\resource\apps\fsccallplugin.r83"
@@ -904,6 +945,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r93"              - "c:\resource\apps\freestyleemailui.r93"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r93"         - "c:\resource\apps\gsemailsettingsplugin.r93"
     "\epoc32\data\z\resource\apps\fsmailserver.r93"                  - "c:\resource\apps\fsmailserver.r93"
+    "\epoc32\data\z\resource\apps\emailwidget.r93"                   - "c:\resource\apps\emailwidget.r93"
     "\epoc32\data\z\resource\ipssossettings.r93"                     - "c:\resource\ipssossettings.r93"
     "\epoc32\data\z\resource\apps\fscpocplugin.r93"                  - "c:\resource\apps\fscpocplugin.r93"
     "\epoc32\data\z\resource\apps\fsccallplugin.r93"                 - "c:\resource\apps\fsccallplugin.r93"
@@ -919,6 +961,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r94"              - "c:\resource\apps\freestyleemailui.r94"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r94"         - "c:\resource\apps\gsemailsettingsplugin.r94"
     "\epoc32\data\z\resource\apps\fsmailserver.r94"                  - "c:\resource\apps\fsmailserver.r94"
+    "\epoc32\data\z\resource\apps\emailwidget.r94"                   - "c:\resource\apps\emailwidget.r94"
     "\epoc32\data\z\resource\ipssossettings.r94"                     - "c:\resource\ipssossettings.r94"
     "\epoc32\data\z\resource\apps\fscpocplugin.r94"                  - "c:\resource\apps\fscpocplugin.r94"
     "\epoc32\data\z\resource\apps\fsccallplugin.r94"                 - "c:\resource\apps\fsccallplugin.r94"
@@ -934,6 +977,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r96"              - "c:\resource\apps\freestyleemailui.r96"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r96"         - "c:\resource\apps\gsemailsettingsplugin.r96"
     "\epoc32\data\z\resource\apps\fsmailserver.r96"                  - "c:\resource\apps\fsmailserver.r96"
+    "\epoc32\data\z\resource\apps\emailwidget.r96"                   - "c:\resource\apps\emailwidget.r96"
     "\epoc32\data\z\resource\ipssossettings.r96"                     - "c:\resource\ipssossettings.r96"
     "\epoc32\data\z\resource\apps\fscpocplugin.r96"                  - "c:\resource\apps\fscpocplugin.r96"
     "\epoc32\data\z\resource\apps\fsccallplugin.r96"                 - "c:\resource\apps\fsccallplugin.r96"
@@ -949,6 +993,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r102"              - "c:\resource\apps\freestyleemailui.r102"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r102"         - "c:\resource\apps\gsemailsettingsplugin.r102"
     "\epoc32\data\z\resource\apps\fsmailserver.r102"                  - "c:\resource\apps\fsmailserver.r102"
+    "\epoc32\data\z\resource\apps\emailwidget.r102"                   - "c:\resource\apps\emailwidget.r102"
     "\epoc32\data\z\resource\ipssossettings.r102"                     - "c:\resource\ipssossettings.r102"
     "\epoc32\data\z\resource\apps\fscpocplugin.r102"                  - "c:\resource\apps\fscpocplugin.r102"
     "\epoc32\data\z\resource\apps\fsccallplugin.r102"                 - "c:\resource\apps\fsccallplugin.r102"
@@ -964,6 +1009,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r103"              - "c:\resource\apps\freestyleemailui.r103"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r103"         - "c:\resource\apps\gsemailsettingsplugin.r103"
     "\epoc32\data\z\resource\apps\fsmailserver.r103"                  - "c:\resource\apps\fsmailserver.r103"
+    "\epoc32\data\z\resource\apps\emailwidget.r103"                   - "c:\resource\apps\emailwidget.r103"
     "\epoc32\data\z\resource\ipssossettings.r103"                     - "c:\resource\ipssossettings.r103"
     "\epoc32\data\z\resource\apps\fscpocplugin.r103"                  - "c:\resource\apps\fscpocplugin.r103"
     "\epoc32\data\z\resource\apps\fsccallplugin.r103"                 - "c:\resource\apps\fsccallplugin.r103"
@@ -979,6 +1025,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r129"              - "c:\resource\apps\freestyleemailui.r129"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r129"         - "c:\resource\apps\gsemailsettingsplugin.r129"
     "\epoc32\data\z\resource\apps\fsmailserver.r129"                  - "c:\resource\apps\fsmailserver.r129"
+    "\epoc32\data\z\resource\apps\emailwidget.r129"                   - "c:\resource\apps\emailwidget.r129"
     "\epoc32\data\z\resource\ipssossettings.r129"                     - "c:\resource\ipssossettings.r129"
     "\epoc32\data\z\resource\apps\fscpocplugin.r129"                  - "c:\resource\apps\fscpocplugin.r129"
     "\epoc32\data\z\resource\apps\fsccallplugin.r129"                 - "c:\resource\apps\fsccallplugin.r129"
@@ -994,6 +1041,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r157"              - "c:\resource\apps\freestyleemailui.r157"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r157"         - "c:\resource\apps\gsemailsettingsplugin.r157"
     "\epoc32\data\z\resource\apps\fsmailserver.r157"                  - "c:\resource\apps\fsmailserver.r157"
+    "\epoc32\data\z\resource\apps\emailwidget.r157"                   - "c:\resource\apps\emailwidget.r157"
     "\epoc32\data\z\resource\ipssossettings.r157"                     - "c:\resource\ipssossettings.r157"
     "\epoc32\data\z\resource\apps\fscpocplugin.r157"                  - "c:\resource\apps\fscpocplugin.r157"
     "\epoc32\data\z\resource\apps\fsccallplugin.r157"                 - "c:\resource\apps\fsccallplugin.r157"
@@ -1009,6 +1057,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r158"              - "c:\resource\apps\freestyleemailui.r158"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r158"         - "c:\resource\apps\gsemailsettingsplugin.r158"
     "\epoc32\data\z\resource\apps\fsmailserver.r158"                  - "c:\resource\apps\fsmailserver.r158"
+    "\epoc32\data\z\resource\apps\emailwidget.r158"                   - "c:\resource\apps\emailwidget.r158"
     "\epoc32\data\z\resource\ipssossettings.r158"                     - "c:\resource\ipssossettings.r158"
     "\epoc32\data\z\resource\apps\fscpocplugin.r158"                  - "c:\resource\apps\fscpocplugin.r158"
     "\epoc32\data\z\resource\apps\fsccallplugin.r158"                 - "c:\resource\apps\fsccallplugin.r158"
@@ -1024,6 +1073,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r159"              - "c:\resource\apps\freestyleemailui.r159"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r159"         - "c:\resource\apps\gsemailsettingsplugin.r159"
     "\epoc32\data\z\resource\apps\fsmailserver.r159"                  - "c:\resource\apps\fsmailserver.r159"
+    "\epoc32\data\z\resource\apps\emailwidget.r159"                   - "c:\resource\apps\emailwidget.r159"
     "\epoc32\data\z\resource\ipssossettings.r159"                     - "c:\resource\ipssossettings.r159"
     "\epoc32\data\z\resource\apps\fscpocplugin.r159"                  - "c:\resource\apps\fscpocplugin.r159"
     "\epoc32\data\z\resource\apps\fsccallplugin.r159"                 - "c:\resource\apps\fsccallplugin.r159"
@@ -1039,6 +1089,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r160"              - "c:\resource\apps\freestyleemailui.r160"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r160"         - "c:\resource\apps\gsemailsettingsplugin.r160"
     "\epoc32\data\z\resource\apps\fsmailserver.r160"                  - "c:\resource\apps\fsmailserver.r160"
+    "\epoc32\data\z\resource\apps\emailwidget.r160"                   - "c:\resource\apps\emailwidget.r160"
     "\epoc32\data\z\resource\ipssossettings.r160"                     - "c:\resource\ipssossettings.r160"
     "\epoc32\data\z\resource\apps\fscpocplugin.r160"                  - "c:\resource\apps\fscpocplugin.r160"
     "\epoc32\data\z\resource\apps\fsccallplugin.r160"                 - "c:\resource\apps\fsccallplugin.r160"
@@ -1054,6 +1105,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r161"              - "c:\resource\apps\freestyleemailui.r161"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r161"         - "c:\resource\apps\gsemailsettingsplugin.r161"
     "\epoc32\data\z\resource\apps\fsmailserver.r161"                  - "c:\resource\apps\fsmailserver.r161"
+    "\epoc32\data\z\resource\apps\emailwidget.r161"                   - "c:\resource\apps\emailwidget.r161"
     "\epoc32\data\z\resource\ipssossettings.r161"                     - "c:\resource\ipssossettings.r161"
     "\epoc32\data\z\resource\apps\fscpocplugin.r161"                  - "c:\resource\apps\fscpocplugin.r161"
     "\epoc32\data\z\resource\apps\fsccallplugin.r161"                 - "c:\resource\apps\fsccallplugin.r161"
@@ -1069,6 +1121,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r326"              - "c:\resource\apps\freestyleemailui.r326"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r326"         - "c:\resource\apps\gsemailsettingsplugin.r326"
     "\epoc32\data\z\resource\apps\fsmailserver.r326"                  - "c:\resource\apps\fsmailserver.r326"
+    "\epoc32\data\z\resource\apps\emailwidget.r326"                   - "c:\resource\apps\emailwidget.r326"
     "\epoc32\data\z\resource\ipssossettings.r326"                     - "c:\resource\ipssossettings.r326"
     "\epoc32\data\z\resource\apps\fscpocplugin.r326"                  - "c:\resource\apps\fscpocplugin.r326"
     "\epoc32\data\z\resource\apps\fsccallplugin.r326"                 - "c:\resource\apps\fsccallplugin.r326"
@@ -1084,6 +1137,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r327"              - "c:\resource\apps\freestyleemailui.r327"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r327"         - "c:\resource\apps\gsemailsettingsplugin.r327"
     "\epoc32\data\z\resource\apps\fsmailserver.r327"                  - "c:\resource\apps\fsmailserver.r327"
+    "\epoc32\data\z\resource\apps\emailwidget.r327"                   - "c:\resource\apps\emailwidget.r327"
     "\epoc32\data\z\resource\ipssossettings.r327"                     - "c:\resource\ipssossettings.r327"
     "\epoc32\data\z\resource\apps\fscpocplugin.r327"                  - "c:\resource\apps\fscpocplugin.r327"
     "\epoc32\data\z\resource\apps\fsccallplugin.r327"                 - "c:\resource\apps\fsccallplugin.r327"
--- a/emailuis/emailui/sis/commonemail_udeb.pkg	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/sis/commonemail_udeb.pkg	Thu Jan 07 12:38:38 2010 +0200
@@ -40,7 +40,7 @@
 ;-----------------------------------------------------------------------------
 ; MfE plugin installed as embedded sisx-package
 ;-------------------------
-@"..\..\..\..\..\complementary\eas\sis\eas_engine_udeb.sisx",(0x20012BE9)
+@"\ext\app\eas\sis\eas_engine_udeb.sisx",(0x20012BE9)
 
 ;-----------------------------------------------------------------------------
 ; Actual common email files to be installed
@@ -120,10 +120,7 @@
 "\epoc32\release\armv5\udeb\cmailhandlerplugin.dll"              - "c:\sys\bin\cmailhandlerplugin.dll"
 "\epoc32\data\Z\Resource\Plugins\cmailhandlerplugin.rsc"         - "c:\resource\plugins\cmailhandlerplugin.rsc"
 "\epoc32\data\z\resource\apps\cmailhandlerplugin.mif"            - "c:\resource\apps\cmailhandlerplugin.mif"
-
-; Change path to normal resource path (not ECom res) when fixed in cmailhandlerplugin code
-; Uncomment in TB 9.2 branch after 5250+ branched
-;"\epoc32\data\Z\Resource\Plugins\emailwidget.rsc"                - "c:\resource\plugins\emailwidget.rsc"
+"\epoc32\data\Z\resource\apps\emailwidget.rsc"                   - "c:\resource\apps\emailwidget.rsc"
 
 ; ipservices
 "\epoc32\release\armv5\udeb\ipssosplugin.dll"                    - "c:\sys\bin\ipssosplugin.dll"
--- a/emailuis/emailui/sis/commonemail_udeb_loc.pkg	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/sis/commonemail_udeb_loc.pkg	Thu Jan 07 12:38:38 2010 +0200
@@ -40,7 +40,7 @@
 ;-----------------------------------------------------------------------------
 ; MfE plugin installed as embedded sisx-package
 ;-------------------------
-@"..\..\..\..\..\complementary\eas\sis\eas_engine_udeb_loc.sisx",(0x20012BE9)
+@"\ext\app\eas\sis\eas_engine_udeb_loc.sisx",(0x20012BE9)
 
 ;-----------------------------------------------------------------------------
 ; Actual common email files to be installed
@@ -123,10 +123,8 @@
 "\epoc32\release\armv5\udeb\cmailhandlerplugin.dll"              - "c:\sys\bin\cmailhandlerplugin.dll"
 "\epoc32\data\Z\Resource\Plugins\cmailhandlerplugin.rsc"         - "c:\resource\plugins\cmailhandlerplugin.rsc"
 "\epoc32\data\z\resource\apps\cmailhandlerplugin.mif"            - "c:\resource\apps\cmailhandlerplugin.mif"
-
-; Change path to normal resource path (not ECom res) when fixed in cmailhandlerplugin code
-; Uncomment in TB 9.2 branch after 5250+ branched
-;"\epoc32\data\Z\Resource\Plugins\emailwidget.rsc"                - "c:\resource\plugins\emailwidget.rsc"
+; Following line is localized, so this Engineering English line is commented out
+;"\epoc32\data\Z\resource\apps\emailwidget.rsc"                   - "c:\resource\apps\emailwidget.rsc"
 
 ; ipservices
 "\epoc32\release\armv5\udeb\ipssosplugin.dll"                    - "c:\sys\bin\ipssosplugin.dll"
@@ -247,6 +245,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r01"              - "c:\resource\apps\freestyleemailui.r01"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r01"         - "c:\resource\apps\gsemailsettingsplugin.r01"
     "\epoc32\data\z\resource\apps\fsmailserver.r01"                  - "c:\resource\apps\fsmailserver.r01"
+    "\epoc32\data\z\resource\apps\emailwidget.r01"                   - "c:\resource\apps\emailwidget.r01"
     "\epoc32\data\z\resource\ipssossettings.r01"                     - "c:\resource\ipssossettings.r01"
     "\epoc32\data\z\resource\apps\fscpocplugin.r01"                  - "c:\resource\apps\fscpocplugin.r01"
     "\epoc32\data\z\resource\apps\fsccallplugin.r01"                 - "c:\resource\apps\fsccallplugin.r01"
@@ -262,6 +261,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r02"              - "c:\resource\apps\freestyleemailui.r02"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r02"         - "c:\resource\apps\gsemailsettingsplugin.r02"
     "\epoc32\data\z\resource\apps\fsmailserver.r02"                  - "c:\resource\apps\fsmailserver.r02"
+    "\epoc32\data\z\resource\apps\emailwidget.r02"                   - "c:\resource\apps\emailwidget.r02"
     "\epoc32\data\z\resource\ipssossettings.r02"                     - "c:\resource\ipssossettings.r02"
     "\epoc32\data\z\resource\apps\fscpocplugin.r02"                  - "c:\resource\apps\fscpocplugin.r02"
     "\epoc32\data\z\resource\apps\fsccallplugin.r02"                 - "c:\resource\apps\fsccallplugin.r02"
@@ -277,6 +277,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r03"              - "c:\resource\apps\freestyleemailui.r03"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r03"         - "c:\resource\apps\gsemailsettingsplugin.r03"
     "\epoc32\data\z\resource\apps\fsmailserver.r03"                  - "c:\resource\apps\fsmailserver.r03"
+    "\epoc32\data\z\resource\apps\emailwidget.r03"                   - "c:\resource\apps\emailwidget.r03"
     "\epoc32\data\z\resource\ipssossettings.r03"                     - "c:\resource\ipssossettings.r03"
     "\epoc32\data\z\resource\apps\fscpocplugin.r03"                  - "c:\resource\apps\fscpocplugin.r03"
     "\epoc32\data\z\resource\apps\fsccallplugin.r03"                 - "c:\resource\apps\fsccallplugin.r03"
@@ -292,6 +293,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r04"              - "c:\resource\apps\freestyleemailui.r04"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r04"         - "c:\resource\apps\gsemailsettingsplugin.r04"
     "\epoc32\data\z\resource\apps\fsmailserver.r04"                  - "c:\resource\apps\fsmailserver.r04"
+    "\epoc32\data\z\resource\apps\emailwidget.r04"                   - "c:\resource\apps\emailwidget.r04"
     "\epoc32\data\z\resource\ipssossettings.r04"                     - "c:\resource\ipssossettings.r04"
     "\epoc32\data\z\resource\apps\fscpocplugin.r04"                  - "c:\resource\apps\fscpocplugin.r04"
     "\epoc32\data\z\resource\apps\fsccallplugin.r04"                 - "c:\resource\apps\fsccallplugin.r04"
@@ -307,6 +309,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r05"              - "c:\resource\apps\freestyleemailui.r05"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r05"         - "c:\resource\apps\gsemailsettingsplugin.r05"
     "\epoc32\data\z\resource\apps\fsmailserver.r05"                  - "c:\resource\apps\fsmailserver.r05"
+    "\epoc32\data\z\resource\apps\emailwidget.r05"                   - "c:\resource\apps\emailwidget.r05"
     "\epoc32\data\z\resource\ipssossettings.r05"                     - "c:\resource\ipssossettings.r05"
     "\epoc32\data\z\resource\apps\fscpocplugin.r05"                  - "c:\resource\apps\fscpocplugin.r05"
     "\epoc32\data\z\resource\apps\fsccallplugin.r05"                 - "c:\resource\apps\fsccallplugin.r05"
@@ -322,6 +325,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r06"              - "c:\resource\apps\freestyleemailui.r06"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r06"         - "c:\resource\apps\gsemailsettingsplugin.r06"
     "\epoc32\data\z\resource\apps\fsmailserver.r06"                  - "c:\resource\apps\fsmailserver.r06"
+    "\epoc32\data\z\resource\apps\emailwidget.r06"                   - "c:\resource\apps\emailwidget.r06"
     "\epoc32\data\z\resource\ipssossettings.r06"                     - "c:\resource\ipssossettings.r06"
     "\epoc32\data\z\resource\apps\fscpocplugin.r06"                  - "c:\resource\apps\fscpocplugin.r06"
     "\epoc32\data\z\resource\apps\fsccallplugin.r06"                 - "c:\resource\apps\fsccallplugin.r06"
@@ -337,6 +341,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r07"              - "c:\resource\apps\freestyleemailui.r07"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r07"         - "c:\resource\apps\gsemailsettingsplugin.r07"
     "\epoc32\data\z\resource\apps\fsmailserver.r07"                  - "c:\resource\apps\fsmailserver.r07"
+    "\epoc32\data\z\resource\apps\emailwidget.r07"                   - "c:\resource\apps\emailwidget.r07"
     "\epoc32\data\z\resource\ipssossettings.r07"                     - "c:\resource\ipssossettings.r07"
     "\epoc32\data\z\resource\apps\fscpocplugin.r07"                  - "c:\resource\apps\fscpocplugin.r07"
     "\epoc32\data\z\resource\apps\fsccallplugin.r07"                 - "c:\resource\apps\fsccallplugin.r07"
@@ -352,6 +357,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r08"              - "c:\resource\apps\freestyleemailui.r08"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r08"         - "c:\resource\apps\gsemailsettingsplugin.r08"
     "\epoc32\data\z\resource\apps\fsmailserver.r08"                  - "c:\resource\apps\fsmailserver.r08"
+    "\epoc32\data\z\resource\apps\emailwidget.r08"                   - "c:\resource\apps\emailwidget.r08"
     "\epoc32\data\z\resource\ipssossettings.r08"                     - "c:\resource\ipssossettings.r08"
     "\epoc32\data\z\resource\apps\fscpocplugin.r08"                  - "c:\resource\apps\fscpocplugin.r08"
     "\epoc32\data\z\resource\apps\fsccallplugin.r08"                 - "c:\resource\apps\fsccallplugin.r08"
@@ -367,6 +373,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r09"              - "c:\resource\apps\freestyleemailui.r09"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r09"         - "c:\resource\apps\gsemailsettingsplugin.r09"
     "\epoc32\data\z\resource\apps\fsmailserver.r09"                  - "c:\resource\apps\fsmailserver.r09"
+    "\epoc32\data\z\resource\apps\emailwidget.r09"                   - "c:\resource\apps\emailwidget.r09"
     "\epoc32\data\z\resource\ipssossettings.r09"                     - "c:\resource\ipssossettings.r09"
     "\epoc32\data\z\resource\apps\fscpocplugin.r09"                  - "c:\resource\apps\fscpocplugin.r09"
     "\epoc32\data\z\resource\apps\fsccallplugin.r09"                 - "c:\resource\apps\fsccallplugin.r09"
@@ -382,6 +389,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r10"              - "c:\resource\apps\freestyleemailui.r10"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r10"         - "c:\resource\apps\gsemailsettingsplugin.r10"
     "\epoc32\data\z\resource\apps\fsmailserver.r10"                  - "c:\resource\apps\fsmailserver.r10"
+    "\epoc32\data\z\resource\apps\emailwidget.r10"                   - "c:\resource\apps\emailwidget.r10"
     "\epoc32\data\z\resource\ipssossettings.r10"                     - "c:\resource\ipssossettings.r10"
     "\epoc32\data\z\resource\apps\fscpocplugin.r10"                  - "c:\resource\apps\fscpocplugin.r10"
     "\epoc32\data\z\resource\apps\fsccallplugin.r10"                 - "c:\resource\apps\fsccallplugin.r10"
@@ -397,6 +405,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r13"              - "c:\resource\apps\freestyleemailui.r13"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r13"         - "c:\resource\apps\gsemailsettingsplugin.r13"
     "\epoc32\data\z\resource\apps\fsmailserver.r13"                  - "c:\resource\apps\fsmailserver.r13"
+    "\epoc32\data\z\resource\apps\emailwidget.r13"                   - "c:\resource\apps\emailwidget.r13"
     "\epoc32\data\z\resource\ipssossettings.r13"                     - "c:\resource\ipssossettings.r13"
     "\epoc32\data\z\resource\apps\fscpocplugin.r13"                  - "c:\resource\apps\fscpocplugin.r13"
     "\epoc32\data\z\resource\apps\fsccallplugin.r13"                 - "c:\resource\apps\fsccallplugin.r13"
@@ -412,6 +421,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r14"              - "c:\resource\apps\freestyleemailui.r14"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r14"         - "c:\resource\apps\gsemailsettingsplugin.r14"
     "\epoc32\data\z\resource\apps\fsmailserver.r14"                  - "c:\resource\apps\fsmailserver.r14"
+    "\epoc32\data\z\resource\apps\emailwidget.r14"                   - "c:\resource\apps\emailwidget.r14"
     "\epoc32\data\z\resource\ipssossettings.r14"                     - "c:\resource\ipssossettings.r14"
     "\epoc32\data\z\resource\apps\fscpocplugin.r14"                  - "c:\resource\apps\fscpocplugin.r14"
     "\epoc32\data\z\resource\apps\fsccallplugin.r14"                 - "c:\resource\apps\fsccallplugin.r14"
@@ -427,6 +437,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r15"              - "c:\resource\apps\freestyleemailui.r15"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r15"         - "c:\resource\apps\gsemailsettingsplugin.r15"
     "\epoc32\data\z\resource\apps\fsmailserver.r15"                  - "c:\resource\apps\fsmailserver.r15"
+    "\epoc32\data\z\resource\apps\emailwidget.r15"                   - "c:\resource\apps\emailwidget.r15"
     "\epoc32\data\z\resource\ipssossettings.r15"                     - "c:\resource\ipssossettings.r15"
     "\epoc32\data\z\resource\apps\fscpocplugin.r15"                  - "c:\resource\apps\fscpocplugin.r15"
     "\epoc32\data\z\resource\apps\fsccallplugin.r15"                 - "c:\resource\apps\fsccallplugin.r15"
@@ -442,6 +453,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r16"              - "c:\resource\apps\freestyleemailui.r16"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r16"         - "c:\resource\apps\gsemailsettingsplugin.r16"
     "\epoc32\data\z\resource\apps\fsmailserver.r16"                  - "c:\resource\apps\fsmailserver.r16"
+    "\epoc32\data\z\resource\apps\emailwidget.r16"                   - "c:\resource\apps\emailwidget.r16"
     "\epoc32\data\z\resource\ipssossettings.r16"                     - "c:\resource\ipssossettings.r16"
     "\epoc32\data\z\resource\apps\fscpocplugin.r16"                  - "c:\resource\apps\fscpocplugin.r16"
     "\epoc32\data\z\resource\apps\fsccallplugin.r16"                 - "c:\resource\apps\fsccallplugin.r16"
@@ -457,6 +469,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r17"              - "c:\resource\apps\freestyleemailui.r17"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r17"         - "c:\resource\apps\gsemailsettingsplugin.r17"
     "\epoc32\data\z\resource\apps\fsmailserver.r17"                  - "c:\resource\apps\fsmailserver.r17"
+    "\epoc32\data\z\resource\apps\emailwidget.r17"                   - "c:\resource\apps\emailwidget.r17"
     "\epoc32\data\z\resource\ipssossettings.r17"                     - "c:\resource\ipssossettings.r17"
     "\epoc32\data\z\resource\apps\fscpocplugin.r17"                  - "c:\resource\apps\fscpocplugin.r17"
     "\epoc32\data\z\resource\apps\fsccallplugin.r17"                 - "c:\resource\apps\fsccallplugin.r17"
@@ -472,6 +485,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r18"              - "c:\resource\apps\freestyleemailui.r18"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r18"         - "c:\resource\apps\gsemailsettingsplugin.r18"
     "\epoc32\data\z\resource\apps\fsmailserver.r18"                  - "c:\resource\apps\fsmailserver.r18"
+    "\epoc32\data\z\resource\apps\emailwidget.r18"                   - "c:\resource\apps\emailwidget.r18"
     "\epoc32\data\z\resource\ipssossettings.r18"                     - "c:\resource\ipssossettings.r18"
     "\epoc32\data\z\resource\apps\fscpocplugin.r18"                  - "c:\resource\apps\fscpocplugin.r18"
     "\epoc32\data\z\resource\apps\fsccallplugin.r18"                 - "c:\resource\apps\fsccallplugin.r18"
@@ -487,6 +501,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r25"              - "c:\resource\apps\freestyleemailui.r25"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r25"         - "c:\resource\apps\gsemailsettingsplugin.r25"
     "\epoc32\data\z\resource\apps\fsmailserver.r25"                  - "c:\resource\apps\fsmailserver.r25"
+    "\epoc32\data\z\resource\apps\emailwidget.r25"                   - "c:\resource\apps\emailwidget.r25"
     "\epoc32\data\z\resource\ipssossettings.r25"                     - "c:\resource\ipssossettings.r25"
     "\epoc32\data\z\resource\apps\fscpocplugin.r25"                  - "c:\resource\apps\fscpocplugin.r25"
     "\epoc32\data\z\resource\apps\fsccallplugin.r25"                 - "c:\resource\apps\fsccallplugin.r25"
@@ -502,6 +517,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r26"              - "c:\resource\apps\freestyleemailui.r26"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r26"         - "c:\resource\apps\gsemailsettingsplugin.r26"
     "\epoc32\data\z\resource\apps\fsmailserver.r26"                  - "c:\resource\apps\fsmailserver.r26"
+    "\epoc32\data\z\resource\apps\emailwidget.r26"                   - "c:\resource\apps\emailwidget.r26"
     "\epoc32\data\z\resource\ipssossettings.r26"                     - "c:\resource\ipssossettings.r26"
     "\epoc32\data\z\resource\apps\fscpocplugin.r26"                  - "c:\resource\apps\fscpocplugin.r26"
     "\epoc32\data\z\resource\apps\fsccallplugin.r26"                 - "c:\resource\apps\fsccallplugin.r26"
@@ -517,6 +533,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r27"              - "c:\resource\apps\freestyleemailui.r27"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r27"         - "c:\resource\apps\gsemailsettingsplugin.r27"
     "\epoc32\data\z\resource\apps\fsmailserver.r27"                  - "c:\resource\apps\fsmailserver.r27"
+    "\epoc32\data\z\resource\apps\emailwidget.r27"                   - "c:\resource\apps\emailwidget.r27"
     "\epoc32\data\z\resource\ipssossettings.r27"                     - "c:\resource\ipssossettings.r27"
     "\epoc32\data\z\resource\apps\fscpocplugin.r27"                  - "c:\resource\apps\fscpocplugin.r27"
     "\epoc32\data\z\resource\apps\fsccallplugin.r27"                 - "c:\resource\apps\fsccallplugin.r27"
@@ -532,6 +549,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r28"              - "c:\resource\apps\freestyleemailui.r28"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r28"         - "c:\resource\apps\gsemailsettingsplugin.r28"
     "\epoc32\data\z\resource\apps\fsmailserver.r28"                  - "c:\resource\apps\fsmailserver.r28"
+    "\epoc32\data\z\resource\apps\emailwidget.r28"                   - "c:\resource\apps\emailwidget.r28"
     "\epoc32\data\z\resource\ipssossettings.r28"                     - "c:\resource\ipssossettings.r28"
     "\epoc32\data\z\resource\apps\fscpocplugin.r28"                  - "c:\resource\apps\fscpocplugin.r28"
     "\epoc32\data\z\resource\apps\fsccallplugin.r28"                 - "c:\resource\apps\fsccallplugin.r28"
@@ -547,6 +565,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r29"              - "c:\resource\apps\freestyleemailui.r29"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r29"         - "c:\resource\apps\gsemailsettingsplugin.r29"
     "\epoc32\data\z\resource\apps\fsmailserver.r29"                  - "c:\resource\apps\fsmailserver.r29"
+    "\epoc32\data\z\resource\apps\emailwidget.r29"                   - "c:\resource\apps\emailwidget.r29"
     "\epoc32\data\z\resource\ipssossettings.r29"                     - "c:\resource\ipssossettings.r29"
     "\epoc32\data\z\resource\apps\fscpocplugin.r29"                  - "c:\resource\apps\fscpocplugin.r29"
     "\epoc32\data\z\resource\apps\fsccallplugin.r29"                 - "c:\resource\apps\fsccallplugin.r29"
@@ -562,6 +581,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r30"              - "c:\resource\apps\freestyleemailui.r30"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r30"         - "c:\resource\apps\gsemailsettingsplugin.r30"
     "\epoc32\data\z\resource\apps\fsmailserver.r30"                  - "c:\resource\apps\fsmailserver.r30"
+    "\epoc32\data\z\resource\apps\emailwidget.r30"                   - "c:\resource\apps\emailwidget.r30"
     "\epoc32\data\z\resource\ipssossettings.r30"                     - "c:\resource\ipssossettings.r30"
     "\epoc32\data\z\resource\apps\fscpocplugin.r30"                  - "c:\resource\apps\fscpocplugin.r30"
     "\epoc32\data\z\resource\apps\fsccallplugin.r30"                 - "c:\resource\apps\fsccallplugin.r30"
@@ -577,6 +597,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r31"              - "c:\resource\apps\freestyleemailui.r31"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r31"         - "c:\resource\apps\gsemailsettingsplugin.r31"
     "\epoc32\data\z\resource\apps\fsmailserver.r31"                  - "c:\resource\apps\fsmailserver.r31"
+    "\epoc32\data\z\resource\apps\emailwidget.r31"                   - "c:\resource\apps\emailwidget.r31"
     "\epoc32\data\z\resource\ipssossettings.r31"                     - "c:\resource\ipssossettings.r31"
     "\epoc32\data\z\resource\apps\fscpocplugin.r31"                  - "c:\resource\apps\fscpocplugin.r31"
     "\epoc32\data\z\resource\apps\fsccallplugin.r31"                 - "c:\resource\apps\fsccallplugin.r31"
@@ -592,6 +613,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r32"              - "c:\resource\apps\freestyleemailui.r32"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r32"         - "c:\resource\apps\gsemailsettingsplugin.r32"
     "\epoc32\data\z\resource\apps\fsmailserver.r32"                  - "c:\resource\apps\fsmailserver.r32"
+    "\epoc32\data\z\resource\apps\emailwidget.r32"                   - "c:\resource\apps\emailwidget.r32"
     "\epoc32\data\z\resource\ipssossettings.r32"                     - "c:\resource\ipssossettings.r32"
     "\epoc32\data\z\resource\apps\fscpocplugin.r32"                  - "c:\resource\apps\fscpocplugin.r32"
     "\epoc32\data\z\resource\apps\fsccallplugin.r32"                 - "c:\resource\apps\fsccallplugin.r32"
@@ -607,6 +629,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r33"              - "c:\resource\apps\freestyleemailui.r33"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r33"         - "c:\resource\apps\gsemailsettingsplugin.r33"
     "\epoc32\data\z\resource\apps\fsmailserver.r33"                  - "c:\resource\apps\fsmailserver.r33"
+    "\epoc32\data\z\resource\apps\emailwidget.r33"                   - "c:\resource\apps\emailwidget.r33"
     "\epoc32\data\z\resource\ipssossettings.r33"                     - "c:\resource\ipssossettings.r33"
     "\epoc32\data\z\resource\apps\fscpocplugin.r33"                  - "c:\resource\apps\fscpocplugin.r33"
     "\epoc32\data\z\resource\apps\fsccallplugin.r33"                 - "c:\resource\apps\fsccallplugin.r33"
@@ -622,6 +645,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r37"              - "c:\resource\apps\freestyleemailui.r37"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r37"         - "c:\resource\apps\gsemailsettingsplugin.r37"
     "\epoc32\data\z\resource\apps\fsmailserver.r37"                  - "c:\resource\apps\fsmailserver.r37"
+    "\epoc32\data\z\resource\apps\emailwidget.r37"                   - "c:\resource\apps\emailwidget.r37"
     "\epoc32\data\z\resource\ipssossettings.r37"                     - "c:\resource\ipssossettings.r37"
     "\epoc32\data\z\resource\apps\fscpocplugin.r37"                  - "c:\resource\apps\fscpocplugin.r37"
     "\epoc32\data\z\resource\apps\fsccallplugin.r37"                 - "c:\resource\apps\fsccallplugin.r37"
@@ -637,6 +661,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r39"              - "c:\resource\apps\freestyleemailui.r39"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r39"         - "c:\resource\apps\gsemailsettingsplugin.r39"
     "\epoc32\data\z\resource\apps\fsmailserver.r39"                  - "c:\resource\apps\fsmailserver.r39"
+    "\epoc32\data\z\resource\apps\emailwidget.r39"                   - "c:\resource\apps\emailwidget.r39"
     "\epoc32\data\z\resource\ipssossettings.r39"                     - "c:\resource\ipssossettings.r39"
     "\epoc32\data\z\resource\apps\fscpocplugin.r39"                  - "c:\resource\apps\fscpocplugin.r39"
     "\epoc32\data\z\resource\apps\fsccallplugin.r39"                 - "c:\resource\apps\fsccallplugin.r39"
@@ -652,6 +677,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r42"              - "c:\resource\apps\freestyleemailui.r42"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r42"         - "c:\resource\apps\gsemailsettingsplugin.r42"
     "\epoc32\data\z\resource\apps\fsmailserver.r42"                  - "c:\resource\apps\fsmailserver.r42"
+    "\epoc32\data\z\resource\apps\emailwidget.r42"                   - "c:\resource\apps\emailwidget.r42"
     "\epoc32\data\z\resource\ipssossettings.r42"                     - "c:\resource\ipssossettings.r42"
     "\epoc32\data\z\resource\apps\fscpocplugin.r42"                  - "c:\resource\apps\fscpocplugin.r42"
     "\epoc32\data\z\resource\apps\fsccallplugin.r42"                 - "c:\resource\apps\fsccallplugin.r42"
@@ -667,6 +693,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r44"              - "c:\resource\apps\freestyleemailui.r44"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r44"         - "c:\resource\apps\gsemailsettingsplugin.r44"
     "\epoc32\data\z\resource\apps\fsmailserver.r44"                  - "c:\resource\apps\fsmailserver.r44"
+    "\epoc32\data\z\resource\apps\emailwidget.r44"                   - "c:\resource\apps\emailwidget.r44"
     "\epoc32\data\z\resource\ipssossettings.r44"                     - "c:\resource\ipssossettings.r44"
     "\epoc32\data\z\resource\apps\fscpocplugin.r44"                  - "c:\resource\apps\fscpocplugin.r44"
     "\epoc32\data\z\resource\apps\fsccallplugin.r44"                 - "c:\resource\apps\fsccallplugin.r44"
@@ -682,6 +709,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r45"              - "c:\resource\apps\freestyleemailui.r45"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r45"         - "c:\resource\apps\gsemailsettingsplugin.r45"
     "\epoc32\data\z\resource\apps\fsmailserver.r45"                  - "c:\resource\apps\fsmailserver.r45"
+    "\epoc32\data\z\resource\apps\emailwidget.r45"                   - "c:\resource\apps\emailwidget.r45"
     "\epoc32\data\z\resource\ipssossettings.r45"                     - "c:\resource\ipssossettings.r45"
     "\epoc32\data\z\resource\apps\fscpocplugin.r45"                  - "c:\resource\apps\fscpocplugin.r45"
     "\epoc32\data\z\resource\apps\fsccallplugin.r45"                 - "c:\resource\apps\fsccallplugin.r45"
@@ -697,6 +725,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r49"              - "c:\resource\apps\freestyleemailui.r49"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r49"         - "c:\resource\apps\gsemailsettingsplugin.r49"
     "\epoc32\data\z\resource\apps\fsmailserver.r49"                  - "c:\resource\apps\fsmailserver.r49"
+    "\epoc32\data\z\resource\apps\emailwidget.r49"                   - "c:\resource\apps\emailwidget.r49"
     "\epoc32\data\z\resource\ipssossettings.r49"                     - "c:\resource\ipssossettings.r49"
     "\epoc32\data\z\resource\apps\fscpocplugin.r49"                  - "c:\resource\apps\fscpocplugin.r49"
     "\epoc32\data\z\resource\apps\fsccallplugin.r49"                 - "c:\resource\apps\fsccallplugin.r49"
@@ -712,6 +741,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r50"              - "c:\resource\apps\freestyleemailui.r50"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r50"         - "c:\resource\apps\gsemailsettingsplugin.r50"
     "\epoc32\data\z\resource\apps\fsmailserver.r50"                  - "c:\resource\apps\fsmailserver.r50"
+    "\epoc32\data\z\resource\apps\emailwidget.r50"                   - "c:\resource\apps\emailwidget.r50"
     "\epoc32\data\z\resource\ipssossettings.r50"                     - "c:\resource\ipssossettings.r50"
     "\epoc32\data\z\resource\apps\fscpocplugin.r50"                  - "c:\resource\apps\fscpocplugin.r50"
     "\epoc32\data\z\resource\apps\fsccallplugin.r50"                 - "c:\resource\apps\fsccallplugin.r50"
@@ -727,6 +757,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r51"              - "c:\resource\apps\freestyleemailui.r51"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r51"         - "c:\resource\apps\gsemailsettingsplugin.r51"
     "\epoc32\data\z\resource\apps\fsmailserver.r51"                  - "c:\resource\apps\fsmailserver.r51"
+    "\epoc32\data\z\resource\apps\emailwidget.r51"                   - "c:\resource\apps\emailwidget.r51"
     "\epoc32\data\z\resource\ipssossettings.r51"                     - "c:\resource\ipssossettings.r51"
     "\epoc32\data\z\resource\apps\fscpocplugin.r51"                  - "c:\resource\apps\fscpocplugin.r51"
     "\epoc32\data\z\resource\apps\fsccallplugin.r51"                 - "c:\resource\apps\fsccallplugin.r51"
@@ -742,6 +773,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r54"              - "c:\resource\apps\freestyleemailui.r54"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r54"         - "c:\resource\apps\gsemailsettingsplugin.r54"
     "\epoc32\data\z\resource\apps\fsmailserver.r54"                  - "c:\resource\apps\fsmailserver.r54"
+    "\epoc32\data\z\resource\apps\emailwidget.r54"                   - "c:\resource\apps\emailwidget.r54"
     "\epoc32\data\z\resource\ipssossettings.r54"                     - "c:\resource\ipssossettings.r54"
     "\epoc32\data\z\resource\apps\fscpocplugin.r54"                  - "c:\resource\apps\fscpocplugin.r54"
     "\epoc32\data\z\resource\apps\fsccallplugin.r54"                 - "c:\resource\apps\fsccallplugin.r54"
@@ -757,6 +789,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r57"              - "c:\resource\apps\freestyleemailui.r57"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r57"         - "c:\resource\apps\gsemailsettingsplugin.r57"
     "\epoc32\data\z\resource\apps\fsmailserver.r57"                  - "c:\resource\apps\fsmailserver.r57"
+    "\epoc32\data\z\resource\apps\emailwidget.r57"                   - "c:\resource\apps\emailwidget.r57"
     "\epoc32\data\z\resource\ipssossettings.r57"                     - "c:\resource\ipssossettings.r57"
     "\epoc32\data\z\resource\apps\fscpocplugin.r57"                  - "c:\resource\apps\fscpocplugin.r57"
     "\epoc32\data\z\resource\apps\fsccallplugin.r57"                 - "c:\resource\apps\fsccallplugin.r57"
@@ -772,6 +805,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r59"              - "c:\resource\apps\freestyleemailui.r59"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r59"         - "c:\resource\apps\gsemailsettingsplugin.r59"
     "\epoc32\data\z\resource\apps\fsmailserver.r59"                  - "c:\resource\apps\fsmailserver.r59"
+    "\epoc32\data\z\resource\apps\emailwidget.r59"                   - "c:\resource\apps\emailwidget.r59"
     "\epoc32\data\z\resource\ipssossettings.r59"                     - "c:\resource\ipssossettings.r59"
     "\epoc32\data\z\resource\apps\fscpocplugin.r59"                  - "c:\resource\apps\fscpocplugin.r59"
     "\epoc32\data\z\resource\apps\fsccallplugin.r59"                 - "c:\resource\apps\fsccallplugin.r59"
@@ -787,6 +821,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r67"              - "c:\resource\apps\freestyleemailui.r67"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r67"         - "c:\resource\apps\gsemailsettingsplugin.r67"
     "\epoc32\data\z\resource\apps\fsmailserver.r67"                  - "c:\resource\apps\fsmailserver.r67"
+    "\epoc32\data\z\resource\apps\emailwidget.r67"                   - "c:\resource\apps\emailwidget.r67"
     "\epoc32\data\z\resource\ipssossettings.r67"                     - "c:\resource\ipssossettings.r67"
     "\epoc32\data\z\resource\apps\fscpocplugin.r67"                  - "c:\resource\apps\fscpocplugin.r67"
     "\epoc32\data\z\resource\apps\fsccallplugin.r67"                 - "c:\resource\apps\fsccallplugin.r67"
@@ -802,6 +837,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r68"              - "c:\resource\apps\freestyleemailui.r68"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r68"         - "c:\resource\apps\gsemailsettingsplugin.r68"
     "\epoc32\data\z\resource\apps\fsmailserver.r68"                  - "c:\resource\apps\fsmailserver.r68"
+    "\epoc32\data\z\resource\apps\emailwidget.r68"                   - "c:\resource\apps\emailwidget.r68"
     "\epoc32\data\z\resource\ipssossettings.r68"                     - "c:\resource\ipssossettings.r68"
     "\epoc32\data\z\resource\apps\fscpocplugin.r68"                  - "c:\resource\apps\fscpocplugin.r68"
     "\epoc32\data\z\resource\apps\fsccallplugin.r68"                 - "c:\resource\apps\fsccallplugin.r68"
@@ -817,6 +853,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r70"              - "c:\resource\apps\freestyleemailui.r70"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r70"         - "c:\resource\apps\gsemailsettingsplugin.r70"
     "\epoc32\data\z\resource\apps\fsmailserver.r70"                  - "c:\resource\apps\fsmailserver.r70"
+    "\epoc32\data\z\resource\apps\emailwidget.r70"                   - "c:\resource\apps\emailwidget.r70"
     "\epoc32\data\z\resource\ipssossettings.r70"                     - "c:\resource\ipssossettings.r70"
     "\epoc32\data\z\resource\apps\fscpocplugin.r70"                  - "c:\resource\apps\fscpocplugin.r70"
     "\epoc32\data\z\resource\apps\fsccallplugin.r70"                 - "c:\resource\apps\fsccallplugin.r70"
@@ -832,6 +869,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r76"              - "c:\resource\apps\freestyleemailui.r76"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r76"         - "c:\resource\apps\gsemailsettingsplugin.r76"
     "\epoc32\data\z\resource\apps\fsmailserver.r76"                  - "c:\resource\apps\fsmailserver.r76"
+    "\epoc32\data\z\resource\apps\emailwidget.r76"                   - "c:\resource\apps\emailwidget.r76"
     "\epoc32\data\z\resource\ipssossettings.r76"                     - "c:\resource\ipssossettings.r76"
     "\epoc32\data\z\resource\apps\fscpocplugin.r76"                  - "c:\resource\apps\fscpocplugin.r76"
     "\epoc32\data\z\resource\apps\fsccallplugin.r76"                 - "c:\resource\apps\fsccallplugin.r76"
@@ -847,6 +885,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r78"              - "c:\resource\apps\freestyleemailui.r78"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r78"         - "c:\resource\apps\gsemailsettingsplugin.r78"
     "\epoc32\data\z\resource\apps\fsmailserver.r78"                  - "c:\resource\apps\fsmailserver.r78"
+    "\epoc32\data\z\resource\apps\emailwidget.r78"                   - "c:\resource\apps\emailwidget.r78"
     "\epoc32\data\z\resource\ipssossettings.r78"                     - "c:\resource\ipssossettings.r78"
     "\epoc32\data\z\resource\apps\fscpocplugin.r78"                  - "c:\resource\apps\fscpocplugin.r78"
     "\epoc32\data\z\resource\apps\fsccallplugin.r78"                 - "c:\resource\apps\fsccallplugin.r78"
@@ -862,6 +901,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r79"              - "c:\resource\apps\freestyleemailui.r79"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r79"         - "c:\resource\apps\gsemailsettingsplugin.r79"
     "\epoc32\data\z\resource\apps\fsmailserver.r79"                  - "c:\resource\apps\fsmailserver.r79"
+    "\epoc32\data\z\resource\apps\emailwidget.r79"                   - "c:\resource\apps\emailwidget.r79"
     "\epoc32\data\z\resource\ipssossettings.r79"                     - "c:\resource\ipssossettings.r79"
     "\epoc32\data\z\resource\apps\fscpocplugin.r79"                  - "c:\resource\apps\fscpocplugin.r79"
     "\epoc32\data\z\resource\apps\fsccallplugin.r79"                 - "c:\resource\apps\fsccallplugin.r79"
@@ -877,6 +917,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r83"              - "c:\resource\apps\freestyleemailui.r83"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r83"         - "c:\resource\apps\gsemailsettingsplugin.r83"
     "\epoc32\data\z\resource\apps\fsmailserver.r83"                  - "c:\resource\apps\fsmailserver.r83"
+    "\epoc32\data\z\resource\apps\emailwidget.r83"                   - "c:\resource\apps\emailwidget.r83"
     "\epoc32\data\z\resource\ipssossettings.r83"                     - "c:\resource\ipssossettings.r83"
     "\epoc32\data\z\resource\apps\fscpocplugin.r83"                  - "c:\resource\apps\fscpocplugin.r83"
     "\epoc32\data\z\resource\apps\fsccallplugin.r83"                 - "c:\resource\apps\fsccallplugin.r83"
@@ -892,6 +933,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r93"              - "c:\resource\apps\freestyleemailui.r93"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r93"         - "c:\resource\apps\gsemailsettingsplugin.r93"
     "\epoc32\data\z\resource\apps\fsmailserver.r93"                  - "c:\resource\apps\fsmailserver.r93"
+    "\epoc32\data\z\resource\apps\emailwidget.r93"                   - "c:\resource\apps\emailwidget.r93"
     "\epoc32\data\z\resource\ipssossettings.r93"                     - "c:\resource\ipssossettings.r93"
     "\epoc32\data\z\resource\apps\fscpocplugin.r93"                  - "c:\resource\apps\fscpocplugin.r93"
     "\epoc32\data\z\resource\apps\fsccallplugin.r93"                 - "c:\resource\apps\fsccallplugin.r93"
@@ -907,6 +949,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r94"              - "c:\resource\apps\freestyleemailui.r94"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r94"         - "c:\resource\apps\gsemailsettingsplugin.r94"
     "\epoc32\data\z\resource\apps\fsmailserver.r94"                  - "c:\resource\apps\fsmailserver.r94"
+    "\epoc32\data\z\resource\apps\emailwidget.r94"                   - "c:\resource\apps\emailwidget.r94"
     "\epoc32\data\z\resource\ipssossettings.r94"                     - "c:\resource\ipssossettings.r94"
     "\epoc32\data\z\resource\apps\fscpocplugin.r94"                  - "c:\resource\apps\fscpocplugin.r94"
     "\epoc32\data\z\resource\apps\fsccallplugin.r94"                 - "c:\resource\apps\fsccallplugin.r94"
@@ -922,6 +965,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r96"              - "c:\resource\apps\freestyleemailui.r96"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r96"         - "c:\resource\apps\gsemailsettingsplugin.r96"
     "\epoc32\data\z\resource\apps\fsmailserver.r96"                  - "c:\resource\apps\fsmailserver.r96"
+    "\epoc32\data\z\resource\apps\emailwidget.r96"                   - "c:\resource\apps\emailwidget.r96"
     "\epoc32\data\z\resource\ipssossettings.r96"                     - "c:\resource\ipssossettings.r96"
     "\epoc32\data\z\resource\apps\fscpocplugin.r96"                  - "c:\resource\apps\fscpocplugin.r96"
     "\epoc32\data\z\resource\apps\fsccallplugin.r96"                 - "c:\resource\apps\fsccallplugin.r96"
@@ -937,6 +981,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r102"              - "c:\resource\apps\freestyleemailui.r102"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r102"         - "c:\resource\apps\gsemailsettingsplugin.r102"
     "\epoc32\data\z\resource\apps\fsmailserver.r102"                  - "c:\resource\apps\fsmailserver.r102"
+    "\epoc32\data\z\resource\apps\emailwidget.r102"                   - "c:\resource\apps\emailwidget.r102"
     "\epoc32\data\z\resource\ipssossettings.r102"                     - "c:\resource\ipssossettings.r102"
     "\epoc32\data\z\resource\apps\fscpocplugin.r102"                  - "c:\resource\apps\fscpocplugin.r102"
     "\epoc32\data\z\resource\apps\fsccallplugin.r102"                 - "c:\resource\apps\fsccallplugin.r102"
@@ -952,6 +997,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r103"              - "c:\resource\apps\freestyleemailui.r103"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r103"         - "c:\resource\apps\gsemailsettingsplugin.r103"
     "\epoc32\data\z\resource\apps\fsmailserver.r103"                  - "c:\resource\apps\fsmailserver.r103"
+    "\epoc32\data\z\resource\apps\emailwidget.r103"                   - "c:\resource\apps\emailwidget.r103"
     "\epoc32\data\z\resource\ipssossettings.r103"                     - "c:\resource\ipssossettings.r103"
     "\epoc32\data\z\resource\apps\fscpocplugin.r103"                  - "c:\resource\apps\fscpocplugin.r103"
     "\epoc32\data\z\resource\apps\fsccallplugin.r103"                 - "c:\resource\apps\fsccallplugin.r103"
@@ -967,6 +1013,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r129"              - "c:\resource\apps\freestyleemailui.r129"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r129"         - "c:\resource\apps\gsemailsettingsplugin.r129"
     "\epoc32\data\z\resource\apps\fsmailserver.r129"                  - "c:\resource\apps\fsmailserver.r129"
+    "\epoc32\data\z\resource\apps\emailwidget.r129"                   - "c:\resource\apps\emailwidget.r129"
     "\epoc32\data\z\resource\ipssossettings.r129"                     - "c:\resource\ipssossettings.r129"
     "\epoc32\data\z\resource\apps\fscpocplugin.r129"                  - "c:\resource\apps\fscpocplugin.r129"
     "\epoc32\data\z\resource\apps\fsccallplugin.r129"                 - "c:\resource\apps\fsccallplugin.r129"
@@ -982,6 +1029,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r157"              - "c:\resource\apps\freestyleemailui.r157"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r157"         - "c:\resource\apps\gsemailsettingsplugin.r157"
     "\epoc32\data\z\resource\apps\fsmailserver.r157"                  - "c:\resource\apps\fsmailserver.r157"
+    "\epoc32\data\z\resource\apps\emailwidget.r157"                   - "c:\resource\apps\emailwidget.r157"
     "\epoc32\data\z\resource\ipssossettings.r157"                     - "c:\resource\ipssossettings.r157"
     "\epoc32\data\z\resource\apps\fscpocplugin.r157"                  - "c:\resource\apps\fscpocplugin.r157"
     "\epoc32\data\z\resource\apps\fsccallplugin.r157"                 - "c:\resource\apps\fsccallplugin.r157"
@@ -997,6 +1045,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r158"              - "c:\resource\apps\freestyleemailui.r158"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r158"         - "c:\resource\apps\gsemailsettingsplugin.r158"
     "\epoc32\data\z\resource\apps\fsmailserver.r158"                  - "c:\resource\apps\fsmailserver.r158"
+    "\epoc32\data\z\resource\apps\emailwidget.r158"                   - "c:\resource\apps\emailwidget.r158"
     "\epoc32\data\z\resource\ipssossettings.r158"                     - "c:\resource\ipssossettings.r158"
     "\epoc32\data\z\resource\apps\fscpocplugin.r158"                  - "c:\resource\apps\fscpocplugin.r158"
     "\epoc32\data\z\resource\apps\fsccallplugin.r158"                 - "c:\resource\apps\fsccallplugin.r158"
@@ -1012,6 +1061,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r159"              - "c:\resource\apps\freestyleemailui.r159"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r159"         - "c:\resource\apps\gsemailsettingsplugin.r159"
     "\epoc32\data\z\resource\apps\fsmailserver.r159"                  - "c:\resource\apps\fsmailserver.r159"
+    "\epoc32\data\z\resource\apps\emailwidget.r159"                   - "c:\resource\apps\emailwidget.r159"
     "\epoc32\data\z\resource\ipssossettings.r159"                     - "c:\resource\ipssossettings.r159"
     "\epoc32\data\z\resource\apps\fscpocplugin.r159"                  - "c:\resource\apps\fscpocplugin.r159"
     "\epoc32\data\z\resource\apps\fsccallplugin.r159"                 - "c:\resource\apps\fsccallplugin.r159"
@@ -1027,6 +1077,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r160"              - "c:\resource\apps\freestyleemailui.r160"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r160"         - "c:\resource\apps\gsemailsettingsplugin.r160"
     "\epoc32\data\z\resource\apps\fsmailserver.r160"                  - "c:\resource\apps\fsmailserver.r160"
+    "\epoc32\data\z\resource\apps\emailwidget.r160"                   - "c:\resource\apps\emailwidget.r160"
     "\epoc32\data\z\resource\ipssossettings.r160"                     - "c:\resource\ipssossettings.r160"
     "\epoc32\data\z\resource\apps\fscpocplugin.r160"                  - "c:\resource\apps\fscpocplugin.r160"
     "\epoc32\data\z\resource\apps\fsccallplugin.r160"                 - "c:\resource\apps\fsccallplugin.r160"
@@ -1042,6 +1093,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r161"              - "c:\resource\apps\freestyleemailui.r161"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r161"         - "c:\resource\apps\gsemailsettingsplugin.r161"
     "\epoc32\data\z\resource\apps\fsmailserver.r161"                  - "c:\resource\apps\fsmailserver.r161"
+    "\epoc32\data\z\resource\apps\emailwidget.r161"                   - "c:\resource\apps\emailwidget.r161"
     "\epoc32\data\z\resource\ipssossettings.r161"                     - "c:\resource\ipssossettings.r161"
     "\epoc32\data\z\resource\apps\fscpocplugin.r161"                  - "c:\resource\apps\fscpocplugin.r161"
     "\epoc32\data\z\resource\apps\fsccallplugin.r161"                 - "c:\resource\apps\fsccallplugin.r161"
@@ -1057,6 +1109,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r326"              - "c:\resource\apps\freestyleemailui.r326"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r326"         - "c:\resource\apps\gsemailsettingsplugin.r326"
     "\epoc32\data\z\resource\apps\fsmailserver.r326"                  - "c:\resource\apps\fsmailserver.r326"
+    "\epoc32\data\z\resource\apps\emailwidget.r326"                   - "c:\resource\apps\emailwidget.r326"
     "\epoc32\data\z\resource\ipssossettings.r326"                     - "c:\resource\ipssossettings.r326"
     "\epoc32\data\z\resource\apps\fscpocplugin.r326"                  - "c:\resource\apps\fscpocplugin.r326"
     "\epoc32\data\z\resource\apps\fsccallplugin.r326"                 - "c:\resource\apps\fsccallplugin.r326"
@@ -1072,6 +1125,7 @@
     "\epoc32\data\z\resource\apps\freestyleemailui.r327"              - "c:\resource\apps\freestyleemailui.r327"
     "\epoc32\data\z\resource\apps\gsemailsettingsplugin.r327"         - "c:\resource\apps\gsemailsettingsplugin.r327"
     "\epoc32\data\z\resource\apps\fsmailserver.r327"                  - "c:\resource\apps\fsmailserver.r327"
+    "\epoc32\data\z\resource\apps\emailwidget.r327"                   - "c:\resource\apps\emailwidget.r327"
     "\epoc32\data\z\resource\ipssossettings.r327"                     - "c:\resource\ipssossettings.r327"
     "\epoc32\data\z\resource\apps\fscpocplugin.r327"                  - "c:\resource\apps\fscpocplugin.r327"
     "\epoc32\data\z\resource\apps\fsccallplugin.r327"                 - "c:\resource\apps\fsccallplugin.r327"
--- a/emailuis/emailui/src/FSComposerFetchLogic.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FSComposerFetchLogic.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -205,33 +205,35 @@
 	{
     FUNC_LOG;
 
-    if ( !iError && aEvent.iError )
+    // Ignore all responses when cancelling is in progress.
+    if ( !iFetchingCancelGoingOn )
         {
-        // Cancel all fetching when first error occurs
-        iError = aEvent.iError;
-        if(!iFetchingCancelGoingOn) //<cmail> if cancelling not going on, start now
+        if ( !iError && aEvent.iError )
+            {
+            // Cancel all fetching when first error occurs
+            iError = aEvent.iError;
             CancelFetchings();
-        }
+            }
+        else if ( TFsEmailUiUtility::IsCompleteOrCancelEvent( aEvent ) )
+            {
+            // Remove the completed/failed download item
+            for ( TInt i=0; i<iParts.Count(); i++ )
+                {
+                if ( iParts[i] == aPart )
+                    {
+                    iParts.Remove( i );
+                    break;
+                    }
+                }
 
-    if ( TFsEmailUiUtility::IsCompleteOrCancelEvent( aEvent ) )
-    	{
-    	// Remove the completed/failed download item
-    	for ( TInt i=0; i<iParts.Count(); i++ )
-    	    {
-    	    if ( iParts[i] == aPart )
-    	        {
-    	        iParts.Remove( i );
-    	        break;
-    	        }
-    	    }
-
-        // If last part just got removed, then move on
-        if ( !iParts.Count() )
-            {
-            Complete();
+            // If last part just got removed, then move on
+            if ( !iParts.Count() )
+                {
+                Complete();
+                }
             }
         }
-	}
+    }
 
 
 // -----------------------------------------------------------------------------
@@ -578,32 +580,28 @@
         }
 
     // message part downloads
-    //<cmail> during consecutive calls to CancelDownloadL, iParts contents don't remain same.
-    // changing this so that it works even with varying contents in iParts
-    TInt count = iParts.Count();
-    TInt currentCount = count;
-    while (count)
+    if ( iAppUi.DownloadInfoMediator() )
         {
-        TInt error( KErrNone );
-        if ( iAppUi.DownloadInfoMediator() )
-        	{
- 	        TRAP( error, iAppUi.DownloadInfoMediator()->CancelDownloadL( iParts[0].iMessagePartId ) );
- 	        currentCount = iParts.Count();
- 	        if(currentCount>=count)
- 	            iParts.Remove(0);
- 	       count = currentCount;
- 	//</cmail>
-        	}
-        if ( error )
+        // Note that we don't bother removing anything from iParts now; they
+        // will be cleaned up later.
+        for ( TInt i = iParts.Count() - 1; i >= 0; i-- )
             {
+            TRAP_IGNORE( iAppUi.DownloadInfoMediator()->CancelDownloadL( iParts[i].iMessagePartId ) );
             }
         }
+
     //<cmail>
-    if(!iRequestCompleted)
+    if( !iRequestCompleted )
         {
-        iObserver.FetchLogicComplete( iState, KErrCancel );
+        if ( iObserver.FetchLogicComplete( iState, KErrCancel ))
+            {
+            // If the observer deleted this object, don't try to do anything
+            // else.
+            return;
+            }
         iRequestCompleted = ETrue; //so that no stray events from plugins can cause panic
         }
+
     iFetchingCancelGoingOn = EFalse;
     //</cmail>
     }
--- a/emailuis/emailui/src/FreestyleEmailDownloadInformationMediator.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailDownloadInformationMediator.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -730,7 +730,7 @@
     {
 	FUNC_LOG;
 	// go through all observers
-	for ( TInt j=0; j<iObserverArray.Count(); j++)
+    for ( TInt j=iObserverArray.Count()-1; j>=0; j--)
 		{
 		// if observer is observing this message
 		if ( iObserverArray[j].iMessageId == aPart.iMessageId )
--- a/emailuis/emailui/src/FreestyleEmailUiAppui.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiAppui.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -134,10 +134,10 @@
 _LIT( KMsgReaderFsDll,"freestylemessagescanner.dll"); // DLL provided by msg reader.
 _LIT( KPhoneModuleName, "Phonetsy.tsy");
 _LIT( KPhoneName, "DefaultPhone");
-// Message editor resources
-_LIT( KMsgEditorAppUiResourceFileName, "z:msgeditorappui.rsc" );
-// FSMailServer resources
-_LIT( KFSMailServerResourceFileName, "z:fsmailserver.rsc" );
+// Message editor resource file with wild cards
+_LIT( KMsgEditorAppUiResourceFileName, "msgeditorappui.r*" );
+// FSMailServer resource file with path and wild cards
+_LIT( KFSMailServerResourceFileNameWithPath, "\\resource\\apps\\fsmailserver.r*" );
 
 // 6 seconds
 const TTimeIntervalMicroSeconds32 KIdleTimeInterval = 6000000;
@@ -152,6 +152,8 @@
 
 const TUint KConnectionStatusIconRotationInterval = 100;
 const TInt KConnectionStatusIconRotationAmount = 18;
+// Length of the drive letter descriptor (e.g. "c:")
+const TInt KDriveDescLength = 2;
 
 // ---------------------------------------------------------------------------
 // C++ constructor.
@@ -170,6 +172,44 @@
     }
 
 // ---------------------------------------------------------------------------
+// Load specified resource file, file name may (and should) contain wild cards
+// ---------------------------------------------------------------------------
+//
+TInt CFreestyleEmailUiAppUi::LoadResourceFileL(
+    const TDesC& aFileName, 
+    const TDesC& aFilePath )
+    {
+    FUNC_LOG;
+
+    TFindFile search( iCoeEnv->FsSession() );
+    CDir* dirList = NULL;
+    TInt err = search.FindWildByDir( aFileName, aFilePath, dirList );
+
+    if ( err == KErrNone )
+        {
+        // After succesfull FindWildByDir; dirList contains list of found file
+        // names and search.File() returns the drive and path of the file(s)
+        if ( dirList->Count() > 0 )
+            {
+            TParse parse;
+            parse.Set( (*dirList)[0].iName, &search.File(), NULL );
+            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
 // ---------------------------------------------------------------------------
 //
@@ -177,23 +217,19 @@
     {
     FUNC_LOG;
 
-    // for debug builds create log file directory automatically
-#ifdef _DEBUG
-    _LIT( KDebugLogDir, "c:\\logs\\FreestyleEmailUi\\" );
-    BaflUtils::EnsurePathExistsL( iEikonEnv->FsSession(), KDebugLogDir );
-#endif
-
-    // Add message editor resources (needed for ENote fetch)
-    TParse parse;
-    parse.Set( KMsgEditorAppUiResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
-    TFileName fileName( parse.FullName() );
-    BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
-    iMsgEditorResourceOffset = iEikonEnv->AddResourceFileL( fileName );
-    // Add FSMailServer resources
-    parse.Set( KFSMailServerResourceFileName, &KDC_APP_RESOURCE_DIR, NULL );
-    fileName = parse.FullName();
-    BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
-    iFSMailServerResourceOffset = iEikonEnv->AddResourceFileL( fileName );
+    // Load message editor resources (needed for ENote fetch)
+    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;
+    TFileName ownProcessName( ownProcess.FileName() );
+    ownProcess.Close();
+    iFSMailServerResourceOffset = LoadResourceFileL(
+                                      KFSMailServerResourceFileNameWithPath,
+                                      ownProcessName.LeftTPtr( KDriveDescLength ) );
     
 	// flag indicating whether we are in AppUi::ConstructL
 	// workaround for compose view loadbackgroundcontext sending skin changed events
@@ -216,7 +252,7 @@
     // state changed events. The initial state will be reported in construction
     iPropertySubscriber =
         CFreestyleEmailUiPropertySubscriber::NewL( KPSUidHWRM, KHWRMFlipStatus, *this );
-    
+
     // Create Document Handler instance
     iDocumentHandler = CDocumentHandler::NewL();
     iFileHandleShutter = CFsEmailFileHandleShutter::NewL(*iDocumentHandler);
@@ -235,7 +271,7 @@
     // Set up layouthandler
     iLayoutHandler = CFSEmailUiLayoutHandler::NewL( *iEnv );
 	iLayoutHandler->ScreenResolutionChanged();
-    
+
     // Create mail client, list mailboxes
     iMailClient = CFSMailClient::NewL();
 
@@ -248,7 +284,7 @@
 
 	// New mailbox query async callback
  	iNewBoxQueryAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
-	iNewBoxQueryAsyncCallback->Set( TCallBack( DisplayCreateQueryL, this ) ); 
+	iNewBoxQueryAsyncCallback->Set( TCallBack( DisplayCreateQueryL, this ) );
 
     iActionMenuHandler = CFSEmailUiActionMenu::NewL( this );
 
@@ -334,19 +370,18 @@
 	iWizardObserver = CFSEmailUiWizardObserver::NewL( this, iMainUiGridVisualiser );
 	iConstructComplete = ETrue;
 
+    iExitGuardian = CEUiExitGuardian::NewL( *this );
+
+    iConnectionStatusVisible = ETrue;
+    // Create custom statuspane indicators object, which shows priority and followup flags
+    CreateStatusPaneIndicatorsL();
+    iConnectionStatusIconAnimTimer = CFSEmailUiGenericTimer::NewL(this, CActive::EPriorityLow);
+
     // this includes a wait note where code running will be pending
     // until a certain callback event is received
     // -> thus keep this last in this method!
     iWizardObserver->DoWizardStartupActionsL();
-
-    iExitGuardian = CEUiExitGuardian::NewL( *this );
-    
-    iConnectionStatusVisible = ETrue;
-    // Create custom statuspane indicators object, which shows priority and followup flags
-    CreateStatusPaneIndicatorsL();
-    iConnectionStatusIconAnimTimer = CFSEmailUiGenericTimer::NewL(this, CActive::EPriorityLow);
-    iFocusTimer = CPeriodic::New(CActive::EPriorityIdle);
-   	}
+    }
 
 // Functions loads some views as delayed to reduce startup time
 TInt CFreestyleEmailUiAppUi::ViewLoadIdleCallbackFunctionL()
@@ -389,7 +424,7 @@
 CFreestyleEmailUiAppUi::~CFreestyleEmailUiAppUi()
     {
     FUNC_LOG;
-    
+
     if ( iMsgEditorResourceOffset )
         {
         iEikonEnv->DeleteResourceFile( iMsgEditorResourceOffset );
@@ -409,7 +444,7 @@
 	delete iPropertySubscriber;
 
     DeleteStatusPaneIndicators();
-    
+
 	if ( iAutoSyncMonitor )
 		{
 		iAutoSyncMonitor->StopMonitoring();
@@ -492,17 +527,10 @@
     // destroys the Download Information mediator
     // Destruction must be done here as other Tls data depends on it.
     CFSEmailDownloadInfoMediator::Destroy();
-    
+
     delete iNaviDecorator2MailViewer;
-    
+
     delete iConnectionStatusIconAnimTimer;
-    
-    if (iFocusTimer)
-    	{
-		CancelFocusRemovalTimer();
-		delete iFocusTimer;
-    	}
-    
     }
 
 
@@ -590,10 +618,10 @@
     FUNC_LOG;
     // Check if we just returned from a plugin settings view. In that case, the current active view
     // and view history must be updated here (because RetrunToPreviousViewL() has not been used).
-    if ( iSettingsViewActive ) 
+    if ( iSettingsViewActive )
         {
         iSettingsViewActive = EFalse;
-        
+
         // Set the iCurrentActiveView pointer
         if ( iNavigationHistory->IsEmpty() )
             {
@@ -662,7 +690,7 @@
 	    {
         // Message deleted, remove mail viewer from the stack
         // => view returns directly mail list (or any other view where the viewer was started from)
-        
+
 		TMailListActivationData tmp;
 		tmp.iRequestRefresh = ETrue;
 		const TPckgBuf<TMailListActivationData> pkgOut( tmp );
@@ -677,7 +705,7 @@
 TUid CFreestyleEmailUiAppUi::ReturnToPreviousViewL( const TDesC8& aCustomMessage /*= KNullDesC8*/ )
     {
     FUNC_LOG;
-    iPreviousActiveView = iCurrentActiveView;  
+    iPreviousActiveView = iCurrentActiveView;
     CFsDelayedLoader::InstanceL()->GetContactHandlerL()->Reset();
     // Set the iCurrentActiveView pointer
     if ( iNavigationHistory->IsEmpty() )
@@ -812,13 +840,13 @@
     }
 
 void CFreestyleEmailUiAppUi::ShowSortListInPopupL(
-        const TFSMailSortField aCurrentSortOrder,
+        const TFSMailSortCriteria aCurrentSortCriteria,
         const TFSFolderType aFolderType,
         MFSEmailUiSortListCallback* aCallback,
         MFsControlButtonInterface* aButton )
     {
     FUNC_LOG;
-    iFolderListVisualiser->ShowSortListPopupL( aCurrentSortOrder, aFolderType, aCallback, aButton );
+    iFolderListVisualiser->ShowSortListPopupL( aCurrentSortCriteria, aFolderType, aCallback, aButton );
 
     iCurrentActiveView->ControlGroup().SetAcceptInput( EFalse );
     iEnv->Send( TAlfGroupCommand(*iFolderListControlGroup, EAlfOpShow, &Display()), 0 );
@@ -836,15 +864,15 @@
 void CFreestyleEmailUiAppUi::ProcessCommandL( TInt aCommand )
     {
     FUNC_LOG;
-    
+
     // For a reason unknown compose view propagates a leave when the options
     // menu open -command is sent to it during the time when it has started
     // the view deactivation but not yet completed that. It causes unnecessay
-    // leave notes in a complete normal use cases in the emulator. To remove 
+    // leave notes in a complete normal use cases in the emulator. To remove
     // the notes but keep the regression risk at minimum (ie. not do any major
     // refactoring) trap the leave here. Propagate other leaves normally.
     TRAPD( err, CAknViewAppUi::ProcessCommandL( aCommand ) );
-    
+
     if ( err != KErrNcsComposeViewNotReady )
         {
         User::LeaveIfError( err );
@@ -899,7 +927,7 @@
 
     // First, prepare viewer, search list and composer for exit, destroys mailbox object before
     // This exit preparation should be moved to base class in the future.
-    if ( iMsgDetailsVisualiser ) 
+    if ( iMsgDetailsVisualiser )
         {
         iMsgDetailsVisualiser->PrepareForExit();
         }
@@ -949,7 +977,7 @@
         }
     iSubscribedMailBoxesIds.Reset();
     iSubscribedMailBoxes.Reset();
-	
+
 	if ( iMailClient )
         {
         iMailClient->RemoveObserver( *this );
@@ -1042,9 +1070,9 @@
 	const TInt KAknFullOrPartialForegroundGained = 0x10281F36;
 	const TInt KAknFullOrPartialForegroundLost   = 0x10281F37;
 	#endif
-    
+
     TBool closeMenu = EFalse;
-    
+
 	// Let folder list visualizer to handle event first because if the popup
 	// is showed, that needs to be closed when pointer click happens outside of the
 	// popup rect and also following pointer up event has to be consumed
@@ -1052,7 +1080,7 @@
         {
         return;
         }
-	
+
 	TInt key = aEvent.Key()->iScanCode;
     // <cmail>
     // to disable voice commands during creating new mail message
@@ -1079,16 +1107,16 @@
             }
 		    //} //<cmail>
 		}
-    
+
     TInt keyCode = aEvent.Key()->iCode;
-    
-    if ( EKeyQwertyOn == keyCode || 
+
+    if ( EKeyQwertyOn == keyCode ||
          EKeyQwertyOff == keyCode )
         {
-        // Close menu when keyboard is opened or closed.  
+        // Close menu when keyboard is opened or closed.
         closeMenu = ETrue;
         }
-    
+
     switch ( aEvent.Type() )
         {
         case KAknFullOrPartialForegroundLost:
@@ -1115,12 +1143,12 @@
         default:
             break;
     	}
-    
+
     // Close menu
     if ( closeMenu && iCurrentActiveView != NULL )
         {
         CEikMenuBar* menu = iCurrentActiveView->MenuBar();
-        
+
         if ( menu != NULL )
             {
             if ( menu->IsDisplayed() )
@@ -1129,7 +1157,7 @@
                 }
             }
         }
-    
+
     CAknAppUi::HandleWsEventL(aEvent, aDestination);
 	}
 
@@ -1185,8 +1213,8 @@
     //    {
     //    CAlfEnv::Static()->NotifySkinChangedL();
     //    }
-    
-    
+
+
     if( aType == KEikDynamicLayoutVariantSwitch || aType == KAknsMessageSkinChange)
         {
 	  	TRect screenRect;
@@ -1489,17 +1517,17 @@
     FUNC_LOG;
  	// Set flag
 	iAutomatedMailBoxOnline = EFalse;
-	
+
 	// Try to get the mailbox
 	CFSMailBox* newActiveBox = iMailClient->GetMailBoxByUidL( aActiveMailboxId );
 	User::LeaveIfNull( newActiveBox );
-	
+
     // Replace active mailbox of the application if getting the mailbox was succesful
     delete iActiveMailbox;
     iActiveMailbox = newActiveBox;
 
-    iActiveMailboxId = iActiveMailbox->GetId();                 
-    iActiveBoxInboxId = iActiveMailbox->GetStandardFolderId( EFSInbox ); 
+    iActiveMailboxId = iActiveMailbox->GetId();
+    iActiveBoxInboxId = iActiveMailbox->GetStandardFolderId( EFSInbox );
 
 	SubscribeMailboxL( iActiveMailboxId );
 
@@ -1567,7 +1595,7 @@
 TBool CFreestyleEmailUiAppUi::MessageReaderSupportsFreestyle()
 	{
     FUNC_LOG;
-	// Check availability of Reader if necessary. Msg reader cannot be installed 
+	// Check availability of Reader if necessary. Msg reader cannot be installed
 	// from sisx so checking is done only once. KErrGeneral at startup.
 	if ( iMsgReaderIsSupported == KErrGeneral )
 		{
@@ -1766,7 +1794,7 @@
                                      TAny* aParam1, TAny* aParam2, TAny* aParam3 )
     {
     FUNC_LOG;
-    
+
     if (iExitGuardian)
         {
         iExitGuardian->EnterLC();
@@ -1844,17 +1872,8 @@
                             {
                             ManualMailBoxSyncAll(EFalse);
                             }
-                        else if (iManualMailBoxSync)
-                            {
-                            TDesC* mbName(0);
-                            CFSMailBox* mb = GetActiveMailbox();
-                            if ( mb )
-                                {
-                                mbName = &mb->GetName();
-                                }
-                            }
                         }
-                        break;                      
+                        break;
                     case SyncError:
                         {
                         // error occured during "Connect" or "Send and receive" operation
@@ -1870,7 +1889,7 @@
                             ManualMailBoxSync( EFalse );
                             }
                         }
-                        break;                      
+                        break;
                     case FinishedSuccessfully:
                     case SyncCancelled:
                     case Idle:
@@ -1881,10 +1900,6 @@
 
        				case PushChannelOffBecauseBatteryIsLow:
     					{
-     					CFSMailBox* mb = iMailClient->GetMailBoxByUidL( aMailbox );
-    					CleanupStack::PushL( mb );
-    					TDesC* mbName = &mb->GetName();
-    		  			CleanupStack::PopAndDestroy( mb );
     					}
     					break;
         			} //switch
@@ -2054,7 +2069,19 @@
 	    }
 	return ret;
 	}
-
+	
+// Move to previous message when the current message is deleted in viewer
+TInt CFreestyleEmailUiAppUi::MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId )
+	{
+	FUNC_LOG;
+	TInt ret(KErrNotFound);
+	if ( !iNavigationHistory->IsEmpty() )
+		{
+		iNavigationHistory->Head()->MoveToPreviousMsgAfterDeleteL( aFoundPreviousMsgId );
+		}
+	return ret;		
+	}
+	
 CDocumentHandler& CFreestyleEmailUiAppUi::DocumentHandler()
 	{
     FUNC_LOG;
@@ -2172,7 +2199,7 @@
     {
     FUNC_LOG;
     iForcedConnectionStatus = aForcedStatus;
-        
+
     if ( iConnectionStatusVisible )
     	{
     	// Get connection status of the current mailbox
@@ -2193,7 +2220,7 @@
 			CAknTitlePane* titlePane = NULL;
 			TRAP_IGNORE( titlePane =
 				(CAknTitlePane*)StatusPane()->ControlL( titlePaneUid ) );
-		
+
 			// Set connection icon
 			iConnectionStatusIconAnimTimer->Stop();
 			iConnectionIconBitmap = 0;
@@ -2217,14 +2244,14 @@
 				    {
 				    TRAP_IGNORE( FsTextureManager()->ProvideBitmapL(
                         EStatusTextureConnected, iConnectionIconBitmap, iConnectionIconMask ) );
-				    }				
+				    }
 				}
 			else // EFSMailBoxOffline
 				{
 				TRAP_IGNORE( FsTextureManager()->ProvideBitmapL(
 						EStatusTextureDisconnectedGeneral, iConnectionIconBitmap, iConnectionIconMask ) );
 				}
-		
+
 			if ( iConnectionIconBitmap )
 				{
 				AknIconUtils::SetSize( iConnectionIconBitmap, iconSize, EAspectRatioNotPreserved );
@@ -2444,7 +2471,7 @@
     {
     FUNC_LOG;
     CFreestyleEmailUiAppUi* self = static_cast<CFreestyleEmailUiAppUi*>( aSelfPtr );
-    
+
     if (self->AppUiExitOngoing())
         {
         return KErrNone;
@@ -2457,14 +2484,14 @@
             return KErrNone;
             }
         }
-    
+
     TRAPD( err, self->DisplayCreateMailboxQueryL() );
-    
+
     if (err == KLeaveExit)
         {
         User::Leave(err);
         }
-    
+
     return err;
     }
 
@@ -2491,21 +2518,21 @@
     if ( task.Exists() )
         {
         // Send self to background
-        task.SendToBackground(); 
+        task.SendToBackground();
         }
 
     iSwitchingToBackground = EFalse;
     }
 
 // -----------------------------------------------------------------------------
-// 
+//
 // -----------------------------------------------------------------------------
 void CFreestyleEmailUiAppUi::ConstructNaviPaneL()
     {
     FUNC_LOG;
 
-    CAknNavigationControlContainer* naviPaneContainer = 
-        static_cast<CAknNavigationControlContainer*>( 
+    CAknNavigationControlContainer* naviPaneContainer =
+        static_cast<CAknNavigationControlContainer*>(
         StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
 
     // Following navipane is for mailviewer view
@@ -2513,27 +2540,27 @@
         {
         // Constructing a decorator with own decorated control,
         // which is (currently an empty) container.
-        CFreestyleEmailUiNaviPaneControlContainer2MailViewer* c = 
+        CFreestyleEmailUiNaviPaneControlContainer2MailViewer* c =
             CFreestyleEmailUiNaviPaneControlContainer2MailViewer::NewL();
         c->SetContainerWindowL( *naviPaneContainer );
         iNaviDecorator2MailViewer = CAknNavigationDecorator::NewL(
             naviPaneContainer,
-            c, 
+            c,
             CAknNavigationDecorator::ENotSpecified );
-        
+
         // In order to get navi arrows visible, they must be set visible AND not dimmed...
         iNaviDecorator2MailViewer->SetContainerWindowL( *naviPaneContainer );
         iNaviDecorator2MailViewer->MakeScrollButtonVisible( ETrue );
         iNaviDecorator2MailViewer->SetScrollButtonDimmed( CAknNavigationDecorator::ELeftButton, EFalse );
         iNaviDecorator2MailViewer->SetScrollButtonDimmed( CAknNavigationDecorator::ERightButton, EFalse );
-        
+
         iNaviDecorator2MailViewer->SetComponentsToInheritVisibility( ETrue );
         naviPaneContainer->PushL( *iNaviDecorator2MailViewer );
         }
     }
 
 // -----------------------------------------------------------------------------
-// 
+//
 // -----------------------------------------------------------------------------
 CAknNavigationDecorator* CFreestyleEmailUiAppUi::NaviDecoratorL(  const TUid aViewId  )
     {
@@ -2566,7 +2593,7 @@
                 CAknTitlePane* titlePane = NULL;
                 TRAP_IGNORE( titlePane =
                     (CAknTitlePane*)StatusPane()->ControlL( titlePaneUid ) );
-                
+
                 TSize iconSize = LayoutHandler()->statusPaneIconSize();
                 iConnectionStatusIconAngle += KConnectionStatusIconRotationAmount;
                 AknIconUtils::SetSizeAndRotation(iConnectionIconBitmap, iconSize, EAspectRatioNotPreserved, iConnectionStatusIconAngle);
@@ -2578,80 +2605,37 @@
     }
 
 // -----------------------------------------------------------------------------
-// CFreestyleEmailUiAppUi::CancelFocusRemovalTimer
+// CFreestyleEmailUiAppUi::SetFocusVisibility
 // -----------------------------------------------------------------------------
 
-void CFreestyleEmailUiAppUi::CancelFocusRemovalTimer()
+TBool CFreestyleEmailUiAppUi::SetFocusVisibility( TBool aVisible )
 	{
-	TBool wasActive = iFocusTimer->IsActive();
-	iFocusTimer->Cancel();
-
+	FUNC_LOG;
+	TBool oldFocusState( iFocusVisible );
+	iFocusVisible = aVisible;
 	CFsEmailUiViewBase* activeView = CurrentActiveView();
-	if( wasActive && activeView )
+	if ( /*oldFocusState != aVisible &&*/ activeView )
 		{
-		activeView->HandleTimerFocusStateChange( EFalse );
+		activeView->FocusVisibilityChange( aVisible );
 		}
-	}
-
-// -----------------------------------------------------------------------------
-// CFreestyleEmailUiAppUi::StartFocusRemovalTimer
-// -----------------------------------------------------------------------------
-
-TBool CFreestyleEmailUiAppUi::StartFocusRemovalTimer()
-	{
-	TBool wasActive = iFocusTimer->IsActive();
-	iFocusTimer->Cancel();
-	// Start the timer and calls FocusTimerCallBack when the timer expires
-	iFocusTimer->Start(KIdleTimeInterval, KIdleTimeInterval,
-			TCallBack(FocusTimerCallBack, this));
-	
-	CFsEmailUiViewBase* activeView = CurrentActiveView();
-	if ( !wasActive && activeView )
-		{
-		activeView->HandleTimerFocusStateChange( ETrue );
-		}
-	
-	return wasActive;
+	// If popup is visible inform it also.
+	if( iFolderListVisualiser && iFolderListVisualiser->IsPopupShown() )
+	    {
+	    iFolderListVisualiser->FocusVisibilityChange( aVisible );
+	    }
+	return oldFocusState;
 	}
 
 // -----------------------------------------------------------------------------
-// 
-// -----------------------------------------------------------------------------
-TInt CFreestyleEmailUiAppUi::FocusTimerCallBack(TAny* aAny)
-	{
-	CFreestyleEmailUiAppUi* self = 
-		static_cast<CFreestyleEmailUiAppUi*>( aAny );
- 
-	return self->DoFocusTimerCallBack();
-	}
-// -----------------------------------------------------------------------------
-// 
+//
 // -----------------------------------------------------------------------------
-TInt CFreestyleEmailUiAppUi::DoFocusTimerCallBack()
+TBool CFreestyleEmailUiAppUi::IsFocusShown() const
 	{
-	iFocusTimer->Cancel();
-	CFsEmailUiViewBase* activeView = CurrentActiveView();
-		
-	// Call the HandleTimerFocusStateChange of currently active so that it hides
-	// its focus.
-	if ( activeView )
-		{
-		activeView->HandleTimerFocusStateChange( EFalse );
-		}
-	
-	return KErrNone;
+	FUNC_LOG;
+	return iFocusVisible;
 	}
 
-// -----------------------------------------------------------------------------
-// 
-// -----------------------------------------------------------------------------
-TBool CFreestyleEmailUiAppUi::IsTimerFocusShown() const
-	{
-	return iFocusTimer->IsActive();
-	}
-
-
-// PUBLIC METHODS FROM MFREESTYLEEMAILUIPROPERTYCHANGEDOBSERVER 
+// PUBLIC METHODS FROM MFREESTYLEEMAILUIPROPERTYCHANGEDOBSERVER
 
 // -----------------------------------------------------------------------------
 // From MFreestyleEmailUiPropertyChangedObserver.
@@ -2669,7 +2653,7 @@
          {
          iFlipOpen = EFalse;
          }
-	
+
 	CFsEmailUiViewBase* activeView = CurrentActiveView();
 	if ( activeView )
 		{
--- a/emailuis/emailui/src/FreestyleEmailUiFolderListVisualiser.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiFolderListVisualiser.cpp	Thu Jan 07 12:38:38 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"
@@ -15,7 +15,6 @@
 *
 */
 
-
 // SYSTEM INCLUDES
 #include "emailtrace.h"
 #include <AknUtils.h>
@@ -32,6 +31,7 @@
 #include <alf/alftextvisual.h>
 #include <alf/alfcontrolgroup.h>
 #include <alf/alfbrusharray.h>
+#include <alf/alfshadowborderbrush.h>
 #include <alf/alfevent.h>
 #include <alf/alfframebrush.h>
 #include <alf/alfstatic.h>
@@ -75,9 +75,6 @@
 #include "ESMailSettingsPlugin.h"
 #include "FreestyleEmailUiStatusIndicator.h"
 
-// REMOVE WHEN DONE TESTING:
-//#include "CSimpleAOTest.h"
-
 // Defines the order of the folders in UI
 enum TFSEmailUiFolderListPriorities
 	{
@@ -103,11 +100,33 @@
     EFolderListIconEmailAccount
 	};
 
+// Defines the order of the sort list icons in the sort icon array
+enum TFsEmailUiSortListIcons
+	{
+	ESortListAttachmentAscIcon = 0,
+	ESortListAttachmentDescIcon,
+	ESortListDateAscIcon,
+	ESortListDateDescIcon,
+	ESortListFollowAscIcon,
+	ESortListFollowDescIcon,
+	ESortListPriorityAscIcon,
+	ESortListPriorityDescIcon,
+	ESortListSenderAscIcon,
+	ESortListSenderDescIcon,
+	ESortListSubjectAscIcon,
+	ESortListSubjectDescIcon,
+	ESortListUnreadAscIcon,
+	ESortListUnreadDescIcon
+	};
+
 // List level for the root folders
 static const TInt KListRootLevel( 1 );
 // List supports three levels, so basically root folder + two levels of subfolders
 static const TInt KListLastBasicLevel( KListRootLevel + 2 );
 
+const TInt KDefaultShadowBorderWidth( 15 );
+const TReal KShadowBorderOpacity( 0.08 );
+
 // Constants for drawing header text
 const TReal KFSHeaderTextBackgroundOpacity = 0.3f;
 const TAlfTimedValue KFSVisible( 1 );
@@ -149,8 +168,8 @@
 // Constructor
 // ---------------------------------------------------------------------------
 //
-CFSEmailUiFolderListVisualiser::CFSEmailUiFolderListVisualiser( CAlfEnv& aEnv, 
-                                                                CFreestyleEmailUiAppUi& aAppUi, 
+CFSEmailUiFolderListVisualiser::CFSEmailUiFolderListVisualiser( CAlfEnv& aEnv,
+                                                                CFreestyleEmailUiAppUi& aAppUi,
                                                                 CAlfControlGroup& aControlGroup )
     : CFsEmailUiViewBase( aControlGroup, aAppUi ),
       iEnv( aEnv ),
@@ -162,7 +181,7 @@
 	{
     FUNC_LOG;
 	}
-	
+
 // ---------------------------------------------------------------------------
 // Destructor
 // ---------------------------------------------------------------------------
@@ -176,15 +195,18 @@
 	delete iBackgroundBrush;
 	iBackgroundBrush = NULL;
 
+	delete iShadowBrush;
+	
 	// No need for ResetAndDestroy because list items are owned by generic list
 	iListItemVisulizers.Close();
-	
+
     //delete iNotifierTest;
-    
+
     delete iTreeList;
     iTreeList = NULL;
-    
+
     iIconArray.Close();
+    iSortIconArray.Close();
     
     if ( iAsyncCallback )
         {
@@ -218,19 +240,19 @@
     FUNC_LOG;
     iControl = CFSEmailUiFolderListControl::NewL( iEnv, *this );
     iModel = new (ELeave) CFSEmailUiFolderListModel();
-     
+
     UpdateListSizeAttributes();
     //LoadIconsL();
-   
+
     TRect mainPaneRect;
     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
     iFaderLayout = CAlfDeckLayout::AddNewL( *iControl );
     iFaderLayout->SetRect( mainPaneRect );
-    
+
     iParentLayout = CAlfAnchorLayout::AddNewL( *iControl );
     iParentLayout->SetRect( iScreenRect );
     iParentLayout->SetFlags( EAlfVisualFlagManualLayout );
-    
+
     iParentLayout->EnableBrushesL();
     SetAnchors();
 
@@ -238,13 +260,13 @@
 
     iHeaderLayout = CAlfDeckLayout::AddNewL( *iControl, iParentLayout );
     iHeaderLayout->SetFlags( EAlfVisualFlagAutomaticLocaleMirroringEnabled );
-     
+
     iHeaderTextVisual = CAlfTextVisual::AddNewL( *iControl, iHeaderLayout );
     iHeaderTextVisual->SetWrapping( CAlfTextVisual::ELineWrapTruncate );
     iHeaderTextVisual->SetTextL( KNullDesC );
-     
+
     TRgb headerTextColor( KRgbBlack );
-    AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), 
+    AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
                                headerTextColor, KAknsIIDFsTextColors, EAknsCIFsTextColorsCG10 );
     iHeaderTextVisual->SetColor( headerTextColor );
     iHeaderTextVisual->SetTextStyle( iAppUi.LayoutHandler()->
@@ -261,7 +283,7 @@
 
 	iHeaderTextVisual->SetOpacity( KFSInvisible );
 	iHeaderLayout->SetOpacity( KFSInvisible );
-	
+
     iListLayout = CAlfDeckLayout::AddNewL( *iControl, iParentLayout );
     iListLayout->SetFlags(EAlfVisualFlagLayoutUpdateNotification|EAlfVisualFlagAutomaticLocaleMirroringEnabled);
 
@@ -272,14 +294,14 @@
     iTreeVisualizer->SetFadeOutEffectTime( iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
     iTreeVisualizer->SetItemSeparatorSize( TSize(0, 0) );
     iTreeVisualizer->SetExpandCollapseAllOnLongTap( EFalse );
-     
+
     iTreeList = CFsTreeList::NewL( *iTreeVisualizer, iEnv );
-    
+
     // Compared to S60 3.2.3 in S60 5.0 Alf offers the key events in
     // opposite order.
     ControlGroup().AppendL( iControl );
-    ControlGroup().AppendL( iTreeList->TreeControl() ); 
-    
+    ControlGroup().AppendL( iTreeList->TreeControl() );
+
     iTreeList->AddObserverL(*this);
 
     iTreeList->SetLoopingType( EFsTreeListLoopingJumpToFirstLast );
@@ -296,9 +318,9 @@
     iTreeVisualizer->SetSelectorPropertiesL(
             iAppUi.FsTextureManager()->NewListSelectorBrushL(), 1.0,
             CFsTreeVisualizerBase::EFsSelectorMoveSmoothly );
-    
+
     iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
-    
+
     //iNotifierTest = CSimpleAOTest::NewL();
     iFirstStartCompleted = ETrue;
     }
@@ -312,7 +334,7 @@
 	{
     FUNC_LOG;
 	return FolderListId;
-	}			   
+	}
 
 // ---------------------------------------------------------------------------
 // CFSEmailUiFolderListVisualiser::PrepareFolderListL
@@ -335,16 +357,16 @@
 
     // Show empty screen when offline
     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
-            
+
     if( iModel->Count() == 0 )
         {
         cba->SetCommandSetL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_BACK );
         }
-        
+
     if( iMoveOrCopyInitiated )
         {
-        iTreeVisualizer->SetEmptyListTextL( KNullDesC );    
-        iTreeVisualizer->RefreshListViewL();    
+        iTreeVisualizer->SetEmptyListTextL( KNullDesC );
+        iTreeVisualizer->RefreshListViewL();
         }
 	}
 
@@ -377,19 +399,19 @@
   	iParentLayout->SetRect(iScreenRect);
 
     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
-    
+
   	if( iModel->Count() > 0 )
   	    {
         cba->SetCommandSetL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_BACK__SELECT );
   	    }
-  	    
+
     if( iMoveOrCopyInitiated )
         {
-        HBufC* emptyListText = StringLoader::LoadLC( 
+        HBufC* emptyListText = StringLoader::LoadLC(
                R_FREESTYLE_EMAIL_UI_FOLDER_LIST_NO_FOLDERS_AVAILABLE );
         iTreeVisualizer->SetEmptyListTextL( *emptyListText );
         CleanupStack::PopAndDestroy( emptyListText );
-    
+
         iTreeVisualizer->RefreshListViewL();
         }
 	}
@@ -418,7 +440,7 @@
     FUNC_LOG;
     CFSEmailUiFolderListVisualiser* self =
         static_cast< CFSEmailUiFolderListVisualiser* >( aSelfPtr );
-    TRAPD( err, 
+    TRAPD( err,
         self->PopulateFolderListL();
         if ( self->iCustomMessageId == KFolderListMoveMessage ||
              self->iCustomMessageId == KFolderListMoveMessages ||
@@ -448,7 +470,7 @@
 void CFSEmailUiFolderListVisualiser::HidePopupL()
 	{
     FUNC_LOG;
-    
+
     iParentLayout->SetRect( iCtrlButtonRect, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
 
     TAlfTimedValue bgOpacity;
@@ -511,36 +533,36 @@
 // CFSEmailUiFolderListVisualiser::DoShowInPopupL
 // ---------------------------------------------------------------------------
 //
-/*void CFSEmailUiFolderListVisualiser::DoShowInPopupL()*/
 void CFSEmailUiFolderListVisualiser::DoShowInPopupL(
         MFsControlButtonInterface* aButton,
         MFSEmailUiFolderListCallback* aFolderCallback,
         MFSEmailUiSortListCallback* aSortCallback )
 	{
     FUNC_LOG;
-        
+
     if ( ( aFolderCallback == NULL && aSortCallback == NULL ) ||
             aButton == NULL )
         {
         return;
         }
-    
+
     // In case of popup we are not moving or copying messages,
     // so there's no need to connect the mailbox
     iNoConnectNeeded = ETrue;
-    
+
     iCallback = aFolderCallback;
     iSortListCallback = aSortCallback;
     const TPoint buttonPos( aButton->Pos().Target() );
     const TSize buttonSize( aButton->Size().Target().AsSize() );
 
     // TRect from where to start the transformation effect
-    iCtrlButtonRect.SetRect( buttonPos, buttonSize );
+    TRect cbr = iAppUi.LayoutHandler()->GetControlBarRect();
+    iCtrlButtonRect.SetRect( buttonPos + cbr.iTl, buttonSize );
 
     iFullScreen = EFalse;
 
     LoadIconsL();
-    
+
     if ( !iFirstStartCompleted )
         {
         DoFirstStartL();
@@ -561,7 +583,7 @@
 	PrepareFolderListL();
     PopulateFolderListL();
 
-    const TInt paddingValue( 
+    const TInt paddingValue(
             iAppUi.LayoutHandler()->DropDownMenuListPadding() );
     const TAlfMetric paddingMetric( paddingValue );
     iParentLayout->SetPadding( paddingMetric );
@@ -576,23 +598,32 @@
         iBackgroundBrush->SetFrameRectsL( outerRect, iScreenRect );
 		}
 
-	// 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 );
-        }
+	   // 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( 
+            iEnv, TAlfMetric( KDefaultShadowBorderWidth ) );
+        iShadowBrush->SetOpacity( KShadowBorderOpacity );
+        iShadowBrush->SetLayer( EAlfBrushLayerBackground );
+        iParentLayout->Brushes()->AppendL( iShadowBrush,
+                                           EAlfDoesNotHaveOwnership );
+	    }
+
 	SetPopupSoftkeysL();
 	// SetRect need to be called also here, otherwise the list layout might
 	// be wrong in mirrored layout
-    //iParentLayout->SetRect( iScreenRect );
     iParentLayout->SetRect( iCtrlButtonRect );
-    
+
     opacity.SetValueNow( 1 );
     //opacity.SetTarget( 1, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
     iParentLayout->SetOpacity( opacity );
@@ -601,6 +632,8 @@
     iTreeList->DisableKineticScrolling( ETrue );
     iTreeList->ShowListL( ETrue );
     iTreeList->SetFocusedL( ETrue );
+    iFocusVisible = iAppUi.IsFocusShown();
+    iTreeVisualizer->SetFocusVisibility( iFocusVisible );
     iPopupListShown = ETrue;
 	}
 
@@ -624,13 +657,13 @@
 // ---------------------------------------------------------------------------
 //
 void CFSEmailUiFolderListVisualiser::ShowSortListPopupL(
-    const TFSMailSortField aCurrentSortOrder,
+    const TFSMailSortCriteria aCurrentSortCriteria,
 	const TFSFolderType aFolderType,
 	MFSEmailUiSortListCallback* aCallback,
 	MFsControlButtonInterface* aButton )
 	{
     FUNC_LOG;
-    iCurrentSortOrder = aCurrentSortOrder;
+    iCurrentSortCriteria = aCurrentSortCriteria;
     iCurrentFolderType = aFolderType;
     DoShowInPopupL( aButton, NULL, aCallback );
 	}
@@ -647,7 +680,7 @@
     iFullScreen = ETrue;
 
     LoadIconsL();
-    
+
     if ( !iFirstStartCompleted )
 	    {
 	    DoFirstStartL();
@@ -655,7 +688,7 @@
 
 	// Set title pane text
 	iAppUi.SetActiveMailboxNameToStatusPaneL();
-    
+
     // Different effect is used when opening folder selection list
     iAnimateNextActivation = ( aCustomMessageId == KFolderListSelectFolder );
 
@@ -736,7 +769,7 @@
             iTitleCaptionVisible = EFalse;
             iHeaderTextVisual->SetOpacity( KFSInvisible );
             }
-    
+
         // Set flag for moving or copying
         iMoveOrCopyInitiated = (aCustomMessageId == KFolderListMoveMessage ||
                                 aCustomMessageId == KFolderListMoveMessages ||
@@ -749,16 +782,16 @@
         viewData.Copy( aCustomMessage );
         iCallback = viewData().iCallback;
         iCurrentFolderType = viewData().iSourceFolderType;
-    
+
        	iTreeList->HideListL();
-    
+
     	// Clear padding when shown in full screen
        	const TAlfMetric padding( 0 );
     	iParentLayout->SetPadding( padding );
     	iListLayout->SetPadding( padding );
-    
+
         PrepareFolderListL();
-    
+
         // Remove need to be called for all brushes before Reset, otherwise the
         // brush resources are not completely freed from server side -> brushes
         // keep "hanging" there and make future drawing slower.
@@ -767,19 +800,19 @@
             iParentLayout->Brushes()->Remove( 0 );
             }
     	iParentLayout->Brushes()->Reset();
-    	
+
     	TAlfTimedValue layoutOpacity = iHeaderLayout->Opacity();
     	layoutOpacity.SetTarget( 1, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime()/2 );
     	iHeaderLayout->SetOpacity( layoutOpacity );
-    	
+
     	TAlfTimedValue bgImageOpacity = iListBgImageVisual->Opacity();
     	bgImageOpacity.SetTarget( 1, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime()/2 );
     	iListBgImageVisual->SetOpacity( bgImageOpacity );
-    
+
     	// Reset the variables used in horizontal scrolling
     	iPreviousListRect = iListLayout->DisplayRectTarget();
         iPreviousListLevel = KListRootLevel;
-    
+
         iParentLayout->SetRect( iScreenRect );
         iTreeList->ShowListL();
 
@@ -792,7 +825,7 @@
     CFSMailBox* mb = iAppUi.GetActiveMailbox();
     // Just in case, shouldn't happen
     User::LeaveIfNull( mb );
-    
+
     TFSMailBoxStatus onlineStatus = mb->GetMailBoxStatus();
 
     // If we are not moving or copying messages, there's no need to connect
@@ -825,6 +858,7 @@
         // is needed for this operation, so we need to connect first
         ConnectToMailboxL();
         }
+    FocusVisibilityChange( iAppUi.IsFocusShown() );
 	}
 
 // ---------------------------------------------------------------------------
@@ -858,7 +892,7 @@
     {
     return R_FREESTYLE_EMAIL_UI_TOOLBAR_FOLDER_LIST;
     }
-	
+
 // ---------------------------------------------------------------------------
 // Deactivate this view
 // ---------------------------------------------------------------------------
@@ -883,15 +917,27 @@
     FUNC_LOG;
     if ( iFirstStartCompleted ) // Safety
         {
-        for ( TInt i=0; i < iModel->Count() ; i++ )
-            {
-            CFSEmailUiFolderListItem* modelItem = iModel->ItemByIndex( i );
-            if ( modelItem && ( modelItem->iSortField == iCurrentSortOrder ) )
-                {
-                iTreeVisualizer->SetFocusedItemL( modelItem->iListId, EFalse );
-                break;          
-                }
-            }
+        for ( TInt i = 0; i < iModel->Count(); i++ )
+        	{
+        	CFSEmailUiFolderListItem* modelItem = iModel->ItemByIndex( i );
+        	if ( modelItem && ( modelItem->iSortField == iCurrentSortCriteria.iField ) )
+        		{
+        		iTreeVisualizer->SetFocusedItemL( modelItem->iListId, EFalse );
+        		break;
+        		}
+        	}
+	
+		// Bold the focused item's text
+		TInt arraySize = iListItemVisulizers.Count();
+		for( TInt i = 0; i < arraySize; i++ )
+			{
+			TFsTreeItemId id = iTreeList->FocusedItem();
+			if ( iListItemVisulizers[ i ] == &( iTreeList->ItemVisualizer( id ) ) )
+				{
+				iListItemVisulizers[i]->SetTextBold( ETrue );
+				break;
+				}
+			}
         }
     }
 
@@ -913,7 +959,7 @@
             if ( modelItem && ( modelItem->iFolderId == iCurrentFolderId ) )
                 {
                 itemToFocus = modelItem->iListId;
-                break;          
+                break;
                 }
             }
         iTreeVisualizer->SetFocusedItemL( itemToFocus, EFalse );
@@ -939,7 +985,7 @@
 	             {
 	             match = ETrue;
 	             iTreeVisualizer->SetFocusedItemL( modelItem->iListId );
-	             break;          
+	             break;
 	             }
 	         }
 
@@ -963,17 +1009,39 @@
 TBool CFSEmailUiFolderListVisualiser::OfferEventL(const TAlfEvent& aEvent)
     {
     FUNC_LOG;
-    TBool result( EFalse ); 
+    TBool result( EFalse );
     if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey )
         {
         // Swap left and right with mirrored layout
-        TInt scanCode = aEvent.KeyEvent().iScanCode;
+        TInt scanCode( aEvent.KeyEvent().iScanCode );
         if ( AknLayoutUtils::LayoutMirrored() )
             {
-            if ( scanCode == EStdKeyLeftArrow ) scanCode = EStdKeyRightArrow;
-            else if ( scanCode == EStdKeyRightArrow ) scanCode = EStdKeyLeftArrow;
+            if( scanCode == EStdKeyLeftArrow )
+                {
+                scanCode = EStdKeyRightArrow;
+                }
+            else if( scanCode == EStdKeyRightArrow )
+                {
+                scanCode = EStdKeyLeftArrow;
+                }
             }
-        
+
+        // Handle possible focus visibility change
+        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 ) )
+                {
+                return ETrue;
+                }
+            }
+
         switch ( scanCode )
             {
             case EStdKeyDevice3:	// CENTER CLICK
@@ -997,7 +1065,7 @@
             		{
             		HandleSelectionL( EFSEmailUiCtrlBarResponseSwitchList );
             		}
- 	           	}            
+ 	           	}
                 break;
 
 	        case EStdKeyRightArrow:
@@ -1017,7 +1085,7 @@
 
              default:
 	       	    // Check keyboard shortcuts.
-	       	    TInt shortcutCommand = 
+	       	    TInt shortcutCommand =
 	       	        iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(),
 	       	                                                         CFSEmailUiShortcutBinding::EContextFolderList );
 	       	    if ( shortcutCommand != KErrNotFound )
@@ -1027,27 +1095,43 @@
 	       	        }
                 break;
             }
-        }      
+        }
     return result;
     }
 
 // ---------------------------------------------------------------------------
 // CFSEmailUiFolderListVisualiser::HandlePointerEventL
 // ---------------------------------------------------------------------------
-//      
+//
 TBool CFSEmailUiFolderListVisualiser::HandlePointerEventL(const TAlfEvent& aEvent)
     {
-    // Handle pointer events to fadervisual. If the list is shown in popup, then
-    // the popup will be closed.
-    if ((aEvent.Visual() == iFaderVisual || aEvent.Visual() == iFaderLayout) && aEvent.PointerEvent().iType == TPointerEvent::EButton1Down && iPopupListShown)
+    TBool eventHandled( EFalse );
+
+    if( ( aEvent.Visual() == iFaderVisual || aEvent.Visual() == iFaderLayout ) &&
+        ( aEvent.PointerEvent().iType == TPointerEvent::EButton1Down  ) &&
+        ( iPopupListShown ) )
         {
+        iAppUi.SetFocusVisibility( EFalse );
         HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
+        eventHandled = ETrue;
         }
     else
         {
-        return iTreeList->TreeControl()->OfferEventL(aEvent);
+        // Handle pointer events to fadervisual. If the list is shown in popup,
+        // then the popup will be closed.
+        if( ( aEvent.IsPointerEvent() ) &&
+            ( aEvent.PointerEvent().iType == TPointerEvent::EButton1Up ) )
+            {
+            eventHandled = iTreeList->TreeControl()->OfferEventL(aEvent);
+            // Hide focus visibility always after pointer up event.
+            iAppUi.SetFocusVisibility( EFalse );
+            }
+        else 
+        	{
+        	eventHandled = iTreeList->TreeControl()->OfferEventL(aEvent);
+        	}
         }
-    return ETrue;     
+    return eventHandled;
     }
 
 // ---------------------------------------------------------------------------
@@ -1065,20 +1149,20 @@
             if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
         	   {
         	   // remove help support in pf5250
-        	   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
+        	   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);
         	   }
-            
+
             // OFFLINE/ONLINE MENU SELECTION
             if( iMoveOrCopyInitiated )
                 {
                 TFSMailBoxStatus onlineStatus = iAppUi.GetActiveMailbox()->GetMailBoxStatus();
-                aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, onlineStatus == EFSMailBoxOnline );                            
-                aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, onlineStatus == EFSMailBoxOffline );      
+                aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, onlineStatus == EFSMailBoxOnline );
+                aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, onlineStatus == EFSMailBoxOffline );
                 }
             else
                 {
-                aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, ETrue );                            
-                aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, ETrue );      
+                aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, ETrue );
+                aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, ETrue );
                 }
 
             // select option
@@ -1087,16 +1171,16 @@
             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, AllNodesCollapsed() );
             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() );
             }
-         
+
         // Add shortcut hints
-        iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane, 
+        iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane,
                                     CFSEmailUiShortcutBinding::EContextFolderList );
         }
 	}
 
 
 // ---------------------------------------------------------------------------
-// 
+//
 // ---------------------------------------------------------------------------
 //
 void CFSEmailUiFolderListVisualiser::HandleSelectionL( TFSEmailUiCtrlBarResponse aSelection )
@@ -1107,7 +1191,7 @@
         {
         return;
         }
-    
+
     TBool popupHiddenAlready(EFalse);
     switch( aSelection )
         {
@@ -1144,7 +1228,7 @@
 
                 iAppUi.FolderPopupClosed();
                 }
-                
+
             if ( !iFullScreen && iSortListCallback )
                 {
                 iSortListCallback->SortOrderChangedL( EFSMailDontCare, aSelection );
@@ -1184,7 +1268,7 @@
 	}
 
 // ---------------------------------------------------------------------------
-// Override the default transition effect in case full screen mode is launched 
+// Override the default transition effect in case full screen mode is launched
 // from popup mode.
 // ---------------------------------------------------------------------------
 //
@@ -1195,12 +1279,12 @@
         {
         TInt rectTransitionTime = iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime();
         TInt opacityTransitionTime = iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() / 2;
-        
+
         TAlfTimedValue opacity;
         opacity.SetValueNow( 0 );
         opacity.SetTarget( 1, opacityTransitionTime );
         iParentLayout->SetOpacity( opacity );
-        
+
         // Do animated enlargening from popup window rect to full screen rect
         iParentLayout->SetRect( FolderListRectInThisResolution() );
         iParentLayout->SetRect( iScreenRect, rectTransitionTime );
@@ -1236,6 +1320,15 @@
               {
               // Key presses
               case EAknSoftkeySelect:
+                  {
+                  // If focus is not visible, make it visible
+                  // otherwise fall through ( call HandleSelectionL )
+                  if( !iFocusVisible )
+                      {
+                      iAppUi.SetFocusVisibility( ETrue );
+                      break;
+                      }
+                  }
               case EAknSoftkeyOpen:
               case EFsEmailUiCmdOpen:
               case EFsEmailUiCmdSelect:
@@ -1243,7 +1336,7 @@
                   HandleSelectionL( EFSEmailUiCtrlBarResponseSelect );
                   }
                   break;
-                  
+
               case EAknSoftkeyBack:
               case EEikBidCancel:
                   {
@@ -1282,7 +1375,7 @@
 
               case EFsEmailUiCmdActionsExpandAll:
                   {
-                  TFsTreeItemId prevId = iTreeList->FocusedItem();    
+                  TFsTreeItemId prevId = iTreeList->FocusedItem();
                   iTreeVisualizer->ExpandAllL();
                   if ( prevId != KFsTreeRootID && prevId != KFsTreeNoneID )
                       {
@@ -1297,7 +1390,7 @@
                   activationData.iAccount = iAppUi.GetActiveMailbox()->GetId();
                   activationData.iSubviewId = 1;
                   activationData.iLaunchFolderSettings = ETrue;
-                  
+
                   TUid pluginUid = iAppUi.GetActiveMailbox()->GetSettingsUid();
                   // register plugin view if not exists so that activation can be made
                   if ( !iAppUi.View( pluginUid ) )
@@ -1305,12 +1398,12 @@
                       CESMailSettingsPlugin* plugin = CESMailSettingsPlugin::NewL( pluginUid );
                       CleanupStack::PushL( plugin );
                       iAppUi.AddViewL( plugin );
-                      CleanupStack::Pop( plugin );        
+                      CleanupStack::Pop( plugin );
                       }
                   TUid messageId = TUid::Uid( CESMailSettingsPlugin::EActivateMailSettingsSubview );
                   const TPckgBuf<CESMailSettingsPlugin::TSubViewActivationData> pluginMessagePkg( activationData );
                   iAppUi.EnterPluginSettingsViewL( pluginUid, messageId, pluginMessagePkg );
-                  
+
                   // Hide list to avoid it flashing when returning back
                   iTreeList->HideListL();
                   }
@@ -1324,7 +1417,7 @@
 
               case EFsEmailUiCmdExit:
                   {
-                  iAppUi.Exit();      
+                  iAppUi.Exit();
                   }
                   break;
 
@@ -1333,20 +1426,20 @@
                   GoToTopL();
                   }
                   break;
-                  
+
               case EFsEmailUiCmdGoToBottom:
                   {
                   GoToBottomL();
                   }
                   break;
-              
+
               case EFsEmailUiCmdPageUp:
                   {
                   TKeyEvent simEvent = { EKeyPageUp, EStdKeyPageUp, 0, 0 };
                   iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
                   }
                   break;
-                  
+
               case EFsEmailUiCmdPageDown:
                   {
                   TKeyEvent simEvent = { EKeyPageDown, EStdKeyPageDown, 0, 0 };
@@ -1361,15 +1454,15 @@
                       HandleCommandL( EFsEmailUiCmdActionsCollapseAll );
                       }
                   else
-                      {       
+                      {
                       HandleCommandL( EFsEmailUiCmdActionsExpandAll );
                       }
                   }
                   break;
-                  
+
               default:
                   break;
-              }        
+              }
          }
     }
 
@@ -1386,18 +1479,18 @@
     	{
     	return ETrue;
     	}
-    
+
     if( focusedItem == iMoreFoldersItemId )
     	{
         //HidePopupL();
         iFullScreen = ETrue;
 
-		TFolderListActivationData tmp;	
+		TFolderListActivationData tmp;
 	    tmp.iCallback = iCallback;
 		const TPckgBuf<TFolderListActivationData> pkgOut( tmp );
 
 		iAppUi.EnterFsEmailViewL( FolderListId, KFolderListSelectFolder, pkgOut );
-		
+
         return EFalse;
     	}
 
@@ -1406,20 +1499,20 @@
 		{
 		return EFalse;
 		}
-		
+
 	if( iCallback )
 		{
 		const TFSMailMsgId& selectedFolderId = modelItem->iFolderId;
 		const TFSMailMsgId& selectedMailboxId = modelItem->iMailboxId;
         if( !selectedFolderId.IsNullId() )
         	{
-    		if ( iCustomMessageId == KFolderListMoveMessage || 
+    		if ( iCustomMessageId == KFolderListMoveMessage ||
     			 iCustomMessageId == KFolderListMoveMessages ||
     		     iCustomMessageId == KFolderListCopyMessage ||
     		     iCustomMessageId == KFolderListCopyMessages )
     			{
     			iLatestSelectedMoveFolderId = selectedFolderId;
-    			}		        	
+    			}
   	       	iCallback->FolderSelectedL( selectedFolderId, EFSEmailUiCtrlBarResponseSelect );
         	}
         else if( !selectedMailboxId.IsNullId() )
@@ -1437,7 +1530,7 @@
         // same callback is not reused unintentionally.
         iSortListCallback = NULL;
 		}
-		
+
     return ETrue;
 	}
 
@@ -1446,12 +1539,12 @@
 // Append node to list by getting the item data from resource
 // ---------------------------------------------------------------------------
 //
-void CFSEmailUiFolderListVisualiser::SetHeaderTextByResourceIdL( 
+void CFSEmailUiFolderListVisualiser::SetHeaderTextByResourceIdL(
         TInt aResourceId )
 	{
     FUNC_LOG;
     if ( iFirstStartCompleted ) // Safety
-        {	
+        {
         HBufC* headingText = StringLoader::LoadLC( aResourceId );
         SetHeaderTextAttributesL();
         iHeaderTextVisual->SetTextL( *headingText );
@@ -1469,12 +1562,12 @@
 void CFSEmailUiFolderListVisualiser::SetHeaderTextAttributesL()
     {
     iHeaderTextVisual->SetOpacity( KFSVisible );
-    CAlfTextStyle* textStyle = iAppUi.LayoutHandler()->FSTextStyleFromIdL( 
+    CAlfTextStyle* textStyle = iAppUi.LayoutHandler()->FSTextStyleFromIdL(
             EFSFontTypeNormalBold );
     iHeaderTextVisual->SetTextStyle ( textStyle->Id() );
     iHeaderTextVisual->SetColor( iAppUi.LayoutHandler()->
             ListNormalStateTextSkinColor() );
-    iHeaderTextVisual->SetPadding( 
+    iHeaderTextVisual->SetPadding(
             iAppUi.LayoutHandler()->TitleCaptionPadding() );
 
     if( iHeaderTextVisual->Brushes() )
@@ -1496,11 +1589,8 @@
 //
 void CFSEmailUiFolderListVisualiser::ConnectToMailboxL()
     {
-	CFSMailBox* mb = iAppUi.GetActiveMailbox();	
-	TDesC* mbName = &mb->GetName();
-    
+	CFSMailBox* mb = iAppUi.GetActiveMailbox();
     iWaitingToGoOnline = ETrue;
-		
     mb->GoOnlineL();
     }
 
@@ -1512,7 +1602,6 @@
 void CFSEmailUiFolderListVisualiser::DisconnectFromMailboxL()
     {
     iAppUi.GetActiveMailbox()->GoOfflineL();
-    
     iWaitingToGoOnline = EFalse;
     }
 
@@ -1533,22 +1622,22 @@
             {
             // Append lines to the model
             AppendActiveMailboxFoldersL();
-            
+
             // Update toolbar button statuses.
             UpdateToolbarButtons();
             }
         else
-            {    
+            {
             //Mailboxes needed to be at the top followed by seperator
-            AppendMailboxesL();   
-            
+            AppendMailboxesL();
+
             // Append lines to the model followed by seperator
             AppendActiveMailboxFoldersL();
             AppendSeparatorLineL();
-            
-            // Append the folder list view selector            
-            AppendMoreFoldersL();            
-            }	        
+
+            // Append the folder list view selector
+            AppendMoreFoldersL();
+            }
         }
   	}
 
@@ -1567,7 +1656,7 @@
         iModel->RemoveAll();
         iMoreFoldersItemId = KFsTreeNoneID;
         // Append lines to the model
-        AppendSortListItemsL();	        
+        AppendSortListItemsL();
         }
 	}
 
@@ -1584,7 +1673,7 @@
         if( iActiveMailbox )
             {
             AppendSubfoldersL( TFSMailMsgId(), KFsTreeRootID, ETrue );
-            }     
+            }
         }
 	}
 
@@ -1608,7 +1697,7 @@
 		{
 		TDesC& nameOfFirst = aFirst.GetFolderName();
 		TDesC& nameOfSecond = aSecond.GetFolderName();
-		
+
 		return nameOfFirst.CompareC( nameOfSecond );
 		}
 	}
@@ -1646,50 +1735,99 @@
 void CFSEmailUiFolderListVisualiser::AppendSortListItemsL()
 	{
     FUNC_LOG;
-	TFsTreeItemId itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_DATE, KFsTreeRootID, NULL, EFalse );
+
+    // Select correct icon depending on the selected sort criteria
+    CAlfTexture* icon( NULL );
+    icon = iCurrentSortCriteria.iField == EFSMailSortByDate ? 
+    	   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
+		   iSortIconArray[ ESortListDateDescIcon ] : 
+		   iSortIconArray[ ESortListDateAscIcon ] : 
+		   iSortIconArray[ ESortListDateDescIcon ];
+		   
+	TFsTreeItemId itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_DATE, KFsTreeRootID, icon, EFalse );
 	iModel->AppendL( itemId, EFSMailSortByDate );
-	
+
 	switch( iCurrentFolderType )
 		{
 		case EFSSentFolder:
 		case EFSDraftsFolder:
 		case EFSOutbox:
 			{
-			itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_RECIPIENT, KFsTreeRootID, NULL, EFalse );
+		    icon = iCurrentSortCriteria.iField == EFSMailSortByRecipient ? 
+		    	   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
+				   iSortIconArray[ ESortListSenderDescIcon ] : 
+				   iSortIconArray[ ESortListSenderAscIcon ] : 
+				   iSortIconArray[ ESortListSenderDescIcon ];
+			itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_RECIPIENT, KFsTreeRootID, icon, EFalse );
 			iModel->AppendL( itemId, EFSMailSortByRecipient );
 			}
 			break;
-			
+
 		default:
 			{
-			itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_SENDER, KFsTreeRootID, NULL, EFalse );
+		    icon = iCurrentSortCriteria.iField == EFSMailSortBySender ? 
+		    	   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
+				   iSortIconArray[ ESortListSenderDescIcon ] : 
+				   iSortIconArray[ ESortListSenderAscIcon ] : 
+				   iSortIconArray[ ESortListSenderDescIcon ];
+			itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_SENDER, KFsTreeRootID, icon, EFalse );
 			iModel->AppendL( itemId, EFSMailSortBySender );
 			}
 			break;
 		}
 
-	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_SUBJECT, KFsTreeRootID, NULL, EFalse );
+	icon = iCurrentSortCriteria.iField == EFSMailSortBySubject ? 
+		   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
+		   iSortIconArray[ ESortListSubjectDescIcon ] : 
+		   iSortIconArray[ ESortListSubjectAscIcon ] : 
+		   iSortIconArray[ ESortListSubjectDescIcon ];
+	
+	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_SUBJECT, KFsTreeRootID, icon, EFalse );
 	iModel->AppendL( itemId, EFSMailSortBySubject );
 
 	if ( TFsEmailUiUtility::IsFollowUpSupported( *iAppUi.GetActiveMailbox() ) )
 		{
-		itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_FLAG, KFsTreeRootID, NULL, EFalse );
+		icon = iCurrentSortCriteria.iField == EFSMailSortByFlagStatus ? 
+			   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
+			   iSortIconArray[ ESortListFollowDescIcon ] : 
+			   iSortIconArray[ ESortListFollowAscIcon ] : 
+			   iSortIconArray[ ESortListFollowDescIcon ];
+			   
+		itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_FLAG, KFsTreeRootID, icon, EFalse );
 		iModel->AppendL( itemId, EFSMailSortByFlagStatus );
 		}
 
-	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_PRIORITY, KFsTreeRootID, NULL, EFalse );
+	icon = iCurrentSortCriteria.iField == EFSMailSortByPriority ? 
+		   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
+		   iSortIconArray[ ESortListPriorityDescIcon ] : 
+		   iSortIconArray[ ESortListPriorityAscIcon ] : 
+		   iSortIconArray[ ESortListPriorityDescIcon ];
+	
+	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_PRIORITY, KFsTreeRootID, icon, EFalse );
 	iModel->AppendL( itemId, EFSMailSortByPriority );
 
 	if ( iCurrentFolderType != EFSSentFolder &&
 		 iCurrentFolderType != EFSDraftsFolder &&
 		 iCurrentFolderType != EFSOutbox )
 		{
-		itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_UNREAD, KFsTreeRootID, NULL, EFalse );
+		icon = iCurrentSortCriteria.iField == EFSMailSortByUnread ? 
+			   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
+			   iSortIconArray[ ESortListUnreadDescIcon ] : 
+			   iSortIconArray[ ESortListUnreadAscIcon ] : 
+			   iSortIconArray[ ESortListUnreadDescIcon ];
+		
+		itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_UNREAD, KFsTreeRootID, icon, EFalse );
 		iModel->AppendL( itemId, EFSMailSortByUnread );
 		}
 
 	// Allow scroll bar refresh only for the last item
-	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_ATTACHMENT, KFsTreeRootID, NULL, ETrue );
+	icon = iCurrentSortCriteria.iField == EFSMailSortByAttachment ? 
+		   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
+		   iSortIconArray[ ESortListAttachmentDescIcon ] : 
+		   iSortIconArray[ ESortListAttachmentAscIcon ] : 
+		   iSortIconArray[ ESortListAttachmentDescIcon ];
+		   
+	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_ATTACHMENT, KFsTreeRootID, icon, ETrue );
 	iModel->AppendL( itemId, EFSMailSortByAttachment );
 	}
 
@@ -1705,7 +1843,7 @@
     CleanupResetAndDestroyClosePushL( folders );
 
 	iActiveMailbox->ListFolders( aFolder, folders );
-	
+
 	TLinearOrder<CFSMailFolder> order(
 		CFSEmailUiFolderListVisualiser::CompareFolders );
 	folders.Sort( order );
@@ -1723,7 +1861,7 @@
             folders.Remove(i);
             }
 	    }
-	
+
 	TBool allowItemRefresh = EFalse;
 	while( folders.Count() > 0 )
 		{
@@ -1796,12 +1934,12 @@
 			}
 		else
 			{
-			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_INBOX;								
+			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_INBOX;
 			// Get branded mailbox icon
 			aIcon = &iAppUi.FsTextureManager()->TextureByMailboxIdL( iActiveMailbox->GetId().PluginId(),
 																	 iActiveMailbox->GetId().Id(),
-																     iListIconSize);	
-			}		
+																     iListIconSize);
+			}
 		found = ETrue;
 		}
 	else if( aFolderType == EFSOutbox )
@@ -1814,7 +1952,7 @@
 		else
 			{
 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_OUTBOX;
-			}		
+			}
 		found = ETrue;
 		}
 	else if( aFolderType == EFSDraftsFolder )
@@ -1827,7 +1965,7 @@
 		else
 			{
 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_DRAFTS;
-			}		
+			}
 		found = ETrue;
 		}
 	else if( aFolderType == EFSSentFolder )
@@ -1853,7 +1991,7 @@
 		else
 			{
 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_DELETED;
-			}		
+			}
 		found = ETrue;
 		}
 	return found;
@@ -1867,7 +2005,7 @@
 	CFSMailFolder* aFolder ) const
 	{
     FUNC_LOG;
-	if( iCustomMessageId == KFolderListMoveMessage || 
+	if( iCustomMessageId == KFolderListMoveMessage ||
     	iCustomMessageId == KFolderListMoveMessages )
 		{
 		// When moving or copying message(s), hide Outbox from list
@@ -1926,7 +2064,7 @@
 		if( iFullScreen )
 			{
 			// For other folders get the name from the folder object
-			
+
 			nodeId = AppendNodeToListL(
 			        &aFolder->GetFolderName(),
 			        aParentNode,
@@ -1983,25 +2121,25 @@
     CleanupResetAndDestroyClosePushL( mailboxes );
 	TFSMailMsgId id;
     iAppUi.GetMailClient()->ListMailBoxes( id, mailboxes );
-    
+
     TInt count = mailboxes.Count();
 
 	while( mailboxes.Count() > 0 )
-		{		
+		{
 		if( !( mailboxes[0]->GetId() == iAppUi.GetActiveMailboxId() ) )
 			{
 			MFSMailBrandManager& brandManager = iAppUi.GetMailClient()->GetBrandManagerL();
-			
+
 			CAlfTexture* mailBoxTexture;
 			CGulIcon* mailboxIcon( NULL );
-			TRAPD( err, mailboxIcon = brandManager.GetGraphicL( EFSMailboxIcon, mailboxes[0]->GetId() ) ); 
+			TRAPD( err, mailboxIcon = brandManager.GetGraphicL( EFSMailboxIcon, mailboxes[0]->GetId() ) );
 			if ( err == KErrNone && mailboxIcon )
 				{
 				CleanupStack::PushL( mailboxIcon );
 				AknIconUtils::SetSize(mailboxIcon->Bitmap(), iListIconSize);
-			    AknIconUtils::SetSize(mailboxIcon->Mask(), iListIconSize);				
-			    
-			    // Create texture into TextureManager, If not already existing			    
+			    AknIconUtils::SetSize(mailboxIcon->Mask(), iListIconSize);
+
+			    // Create texture into TextureManager, If not already existing
 			    iAppUi.FsTextureManager()->CreateBrandedMailboxTexture( mailboxIcon,
 			    		                                                mailboxes[0]->GetId().PluginId(),
 			    		                                                mailboxes[0]->GetId().Id(),
@@ -2009,8 +2147,8 @@
 			    // Get branded mailbox icon
 			    mailBoxTexture = &iAppUi.FsTextureManager()->TextureByMailboxIdL( mailboxes[0]->GetId().PluginId(),
 			    		                                                          mailboxes[0]->GetId().Id(),
-			    		                                                          iListIconSize);	
-			    
+			    		                                                          iListIconSize);
+
 				CleanupStack::PopAndDestroy( mailboxIcon );
 				}
 			else
@@ -2037,9 +2175,9 @@
                 // to model anymore, so we need to delete it here in all cases
                 iModel->AppendL( itemId, mailboxes[0] );
                 }
-				
+
 			}
-		
+
 		delete mailboxes[0];
         mailboxes.Remove(0);
 		}
@@ -2047,8 +2185,8 @@
 	if( count > 1 )
 		{
 		AppendSeparatorLineL();
-		}		
-	
+		}
+
     CleanupStack::PopAndDestroy( &mailboxes );
 	}
 
@@ -2064,14 +2202,14 @@
 
 	CFsSeparatorVisualizer* visualizer( NULL );
     visualizer = CFsSeparatorVisualizer::NewL(*iTreeList->TreeControl());
-    
+
     // We use the default size of the separator, but we need to save it
     // here to have it available later when calculating the list height
     iListSeparatorHeight = visualizer->Size().iHeight;
-    
+
     // This should never be the last item in the list, so disable the refresh
     iTreeList->InsertItemL( *data, *visualizer, KFsTreeRootID, KErrNotFound, EFalse);
-    
+
     iModel->IncreaseSeparatorCount();
 	}
 
@@ -2114,7 +2252,7 @@
     FUNC_LOG;
     CFsTreePlainOneLineNodeData* plainItemData;
     CFsTreePlainOneLineNodeVisualizer* plainNodeVisualizer;
-    
+
     HBufC* itemDispName = HBufC::NewLC(aItemData->Length() + KFmtUnRdCntMaxLength);
     itemDispName->Des().Copy(*aItemData);
     if( aUnreadCnt > 0 )
@@ -2122,7 +2260,7 @@
         itemDispName->Des().AppendFormat(KFormatUnreadCnt, aUnreadCnt);
         }
 	CreatePlainNodeLC2( itemDispName, plainItemData, plainNodeVisualizer, aIcon );
-	
+
 	// We assume that node can never be the last item to be drawn, there will
 	// always be leaf folder under it. So we can always deny scroll bar update.
     TFsTreeItemId nodeId = iTreeList->InsertNodeL( *plainItemData, *plainNodeVisualizer, aParentNode, KErrNotFound, EFalse);
@@ -2141,7 +2279,7 @@
 // Append leaf to list by getting the item data from resource
 // ---------------------------------------------------------------------------
 //
-TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendItemToListFromResourceL( TInt aResourceId, 
+TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendItemToListFromResourceL( TInt aResourceId,
 																			 TFsTreeItemId aParentNode,
 																			 CAlfTexture* aIcon,
 																			 TBool aAllowRefresh,
@@ -2149,7 +2287,7 @@
 	{
     FUNC_LOG;
  	HBufC* headingText = StringLoader::LoadLC( aResourceId );
-
+ 	
 	TFsTreeItemId itemId = AppendItemToListL( headingText, aParentNode, aIcon, aAllowRefresh,  aUnreadCnt);
 
    	CleanupStack::PopAndDestroy( headingText );
@@ -2161,7 +2299,7 @@
 // Append leaf to list
 // ---------------------------------------------------------------------------
 //
-TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendItemToListL( TDesC* aItemData, 
+TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendItemToListL( TDesC* aItemData,
 																 TFsTreeItemId aParentNode,
 																 CAlfTexture* aIcon,
                                                                  TBool aAllowRefresh,
@@ -2170,7 +2308,7 @@
     FUNC_LOG;
     CFsTreePlainOneLineItemData* plainItemData;
     CFsTreePlainOneLineItemVisualizer* plainItemVisualizer;
-    
+
     HBufC* itemDispName = HBufC::NewLC(aItemData->Length() + KFmtUnRdCntMaxLength);
     itemDispName->Des().Copy(*aItemData);
     if( aUnreadCnt > 0 )
@@ -2178,8 +2316,8 @@
         itemDispName->Des().AppendFormat(KFormatUnreadCnt, aUnreadCnt);
         }
     CreatePlainItemLC2( itemDispName, plainItemData, plainItemVisualizer, aIcon );
-    
-    
+
+
     TFsTreeItemId itemId = iTreeList->InsertItemL( *plainItemData, *plainItemVisualizer, aParentNode, KErrNotFound, aAllowRefresh);
     CleanupStack::Pop( 2 ); // plainItemData & plainItemVisualizer
 	CleanupStack::PopAndDestroy( itemDispName );
@@ -2187,7 +2325,7 @@
 		{
 		iListItemVisulizers.Append( plainItemVisualizer );
 		}
-    
+
 	return itemId;
 	}
 
@@ -2203,7 +2341,7 @@
     FUNC_LOG;
     aItemData = CFsTreePlainOneLineItemData::NewL();
     CleanupStack::PushL( aItemData );
-    
+
     aItemData->SetDataL( *aItemDataBuff );
     if( aIcon )
     	{
@@ -2220,8 +2358,9 @@
         }
     else
         {
-        aItemVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EPopupLayout );        
+        aItemVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EPopupLayout );
         }
+
     SetItemVisualizerPropertiesL( aItemVisualizer );
 	}
 
@@ -2237,17 +2376,17 @@
     FUNC_LOG;
     aItemData = CFsTreePlainOneLineNodeData::NewL();
     CleanupStack::PushL( aItemData );
-    
+
     aItemData->SetDataL( *aItemDataBuff );
     if( aIcon )
     	{
 		aItemData->SetIconExpanded( *aIcon );
 		aItemData->SetIconCollapsed( *aIcon );
     	}
-	
+
     aNodeVisualizer = CFsTreePlainOneLineNodeVisualizer::NewL( *iTreeList->TreeControl() );
     CleanupStack::PushL( aNodeVisualizer );
-     
+
     // Set folder view specific layouts to be used
     if ( iFullScreen )
         {
@@ -2255,11 +2394,11 @@
         }
     else
         {
-        aNodeVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EPopupLayout );        
+        aNodeVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EPopupLayout );
         }
     SetItemVisualizerPropertiesL( aNodeVisualizer );
 	}
-    
+
 void CFSEmailUiFolderListVisualiser::SetItemVisualizerPropertiesL( MFsTreeItemVisualizer* aItemVisualizer )
 	{
     FUNC_LOG;
@@ -2276,7 +2415,7 @@
 
     aItemVisualizer->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();
 	// If list is in full screen, it has general list background, so we use
 	// general list text color. If it's not in full screen, we use dropdown
@@ -2290,10 +2429,10 @@
 		{
 		normalColor = iAppUi.LayoutHandler()->DropdownMenuTextColor();
 		}
-	
+
     aItemVisualizer->SetFocusedStateTextColor( focusedColor );
     aItemVisualizer->SetNormalStateTextColor( normalColor );
-	
+
 	// Set font size
     aItemVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips( !iFullScreen ) );
 	// Set node bolded
@@ -2323,7 +2462,7 @@
                 TRect popupRect( iScreenRect );
                 // translate to screen coorinates
                 popupRect.Move( iEnv.PrimaryDisplay().VisibleArea().iTl );
-                // check if the event happened outside of the popup   
+                // check if the event happened outside of the popup
                 if ( !popupRect.Contains( position ) )
                     {
                     HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
@@ -2339,7 +2478,7 @@
                 }
             eventHandled = ETrue;
             }
-        }    
+        }
     return eventHandled;
     }
 
@@ -2457,19 +2596,22 @@
         }
 	else
 		{
+        TRect cbr = iAppUi.LayoutHandler()->GetControlBarRect();
 		if( iCallback )
 			{
 			iCtrlButtonRect = iCallback->FolderButtonRect();
+            iCtrlButtonRect.Move( cbr.iTl );
 			iScreenRect = FolderListRectInThisResolution();
 			}
 		else if ( iSortListCallback )
 			{
             iCtrlButtonRect = iSortListCallback->SortButtonRect();
-			iScreenRect = SortListRectInThisResolution();
+            iCtrlButtonRect.Move( cbr.iTl );
+            iScreenRect = SortListRectInThisResolution();
 			}
 		else
 		    {
-		    // Do nothing. This happens if HandleDynamicVariantSwitch() is called while the popup list is not visible. 
+		    // Do nothing. This happens if HandleDynamicVariantSwitch() is called while the popup list is not visible.
 		    }
 		}
 	iListIconSize = iAppUi.LayoutHandler()->FolderListIconSize( !iFullScreen );
@@ -2511,8 +2653,8 @@
     FUNC_LOG;
 	iIconArray.Reset();
 	if ( iFullScreen )
-	    {	
-        // NOTE: Must be appended same order as are in TFsEmailUiFolderListIcons!	
+	    {
+        // NOTE: Must be appended same order as are in TFsEmailUiFolderListIcons!
         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxTexture ) );   			// EFolderListIconInbox
         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxSubfoldersTexture ) );	// EFolderListIconInboxSubfolders
         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListOutboxTexture ) );  			// EFolderListIconOutbox
@@ -2525,7 +2667,7 @@
 	    }
 	else
 	    {
-        // NOTE: Must be appended same order as are in TFsEmailUiFolderListIcons!   
+        // NOTE: Must be appended same order as are in TFsEmailUiFolderListIcons!
         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxTexturePopup ) );            // EFolderListIconInbox
         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxSubfoldersTexturePopup ) );  // EFolderListIconInboxSubfolders
         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListOutboxTexturePopup ) );           // EFolderListIconOutbox
@@ -2534,7 +2676,23 @@
         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListDeletedItemsTexturePopup ) );     // EFolderListIconDeleted
         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListServerFoldersTexturePopup ) );    // EFolderListIconServerFolders
         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListMoreFoldersTexturePopup ) );      // EFolderListIconMoreFolders
-        iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListEmailAccountTexturePopup ) );     // EFolderListIconEmailAccount	    
+        iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListEmailAccountTexturePopup ) );     // EFolderListIconEmailAccount
+	    
+	    // NOTE: Must be appended same order as are in TFsEmailUiSortListIcons!
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListAttachmentAscTexture ) );       // ESortListAttachmentAscIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListAttachmentDescTexture ) );      // ESortListAttachmentDescIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListDateAscTexture ) );       		 // ESortListDateAscIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListDateDescTexture ) );       	 // ESortListDateDescIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListFollowAscTexture ) );       	 // ESortListFollowAscIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListFollowDescTexture ) );        	 // ESortListFollowDescIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListPriorityAscTexture ) );         // ESortListPriorityAscIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListPriorityDescTexture ) );        // ESortListPriorityDescIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListSenderAscTexture ) );       	 // ESortListSenderAscIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListSenderDescTexture ) );       	 // ESortListSenderDescIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListSubjectAscTexture ) );       	 // ESortListSubjectAscIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListSubjectDescTexture ) );       	 // ESortListSubjectDescIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListUnreadAscTexture ) );       	 // ESortListUnreadAscIcon
+        iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListUnreadDescTexture ) );       	 // ESortListUnreadDescIcon
 	    }
 	}
 
@@ -2561,6 +2719,13 @@
 		//       array, instead those are owned by texture manager. So
 		//       those should be resized by other means. But currently
 		//       there is no way to do it (see above comment).
+		
+		// Then resize sort list icons
+		TInt arraySizeSort = iSortIconArray.Count();
+		for( TInt i = 0; i < arraySizeSort; i++ )
+			{
+			iSortIconArray[i]->Size().SetSize( iListIconSize.iWidth, iListIconSize.iHeight );
+			}
 		}
 	}
 
@@ -2586,15 +2751,15 @@
 	{
     FUNC_LOG;
     const TInt popupHeight( iScreenRect.Height() );
-    const TInt separatorHeight( iListSeparatorHeight * 
+    const TInt separatorHeight( iListSeparatorHeight *
             iModel->SeparatorCount() );
-    const TInt itemCount( iTreeList->Count() - iModel->SeparatorCount() );    
-    TInt visibleItemCount( ( popupHeight - separatorHeight ) / 
-            iListItemHeight );    
-    visibleItemCount = Min( visibleItemCount, itemCount );   
-    iScreenRect.SetHeight( visibleItemCount * iListItemHeight + 
-            separatorHeight + 
-            iAppUi.LayoutHandler()->DropDownMenuListPadding() * 2 + 
+    const TInt itemCount( iTreeList->Count() - iModel->SeparatorCount() );
+    TInt visibleItemCount( ( popupHeight - separatorHeight ) /
+            iListItemHeight );
+    visibleItemCount = Min( visibleItemCount, itemCount );
+    iScreenRect.SetHeight( visibleItemCount * iListItemHeight +
+            separatorHeight +
+            iAppUi.LayoutHandler()->DropDownMenuListPadding() * 2 +
             iAppUi.LayoutHandler()->ControlBarListPadding().iY );
 	AdjustWidthByContent( iScreenRect );
 	}
@@ -2605,17 +2770,19 @@
 //
 void CFSEmailUiFolderListVisualiser::AdjustWidthByContent( TRect& aRect ) const
     {
+    const TRect oldButtonRect( iScreenRect );
     const TInt buttonWidth( iCtrlButtonRect.Width() );
     const TInt currentWidth( aRect.Width() );
 
     // only do adjusting if the buttonWidth is smaller than current popup width
     if ( buttonWidth < currentWidth )
         {
+        TBool landscape( Layout_Meta_Data::IsLandscapeOrientation() );
         TAknLayoutRect scrollPane;
         scrollPane.LayoutRect( aRect,
                 AknLayoutScalable_Apps::sp_fs_scroll_pane_cp01( 6 ) );
         const TInt scrollPaneWidth( scrollPane.Rect().Width() );
-        
+
         TAknLayoutText textLayout;
         textLayout.LayoutText( aRect,
                 AknLayoutScalable_Apps::list_single_dyc_row_text_pane_t1( 0 ) );
@@ -2674,6 +2841,12 @@
                         aRect.Move( -aRect.iTl.iX + iCtrlButtonRect.iTl.iX, 0 );
                         }
                     }
+                
+                // Keep the right edge position unchanged
+                if( landscape )
+                    {
+                    aRect.Move( oldButtonRect.iBr.iX - aRect.iBr.iX, 0 );
+                    }
                 }
             }
         }
@@ -2698,10 +2871,10 @@
         {
         iListHeaderHeight = 0;
         }
-    
+
     TSize mainPaneSize;
     AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, mainPaneSize);
-    
+
     // Set anchor for background visual
     iParentLayout->SetAnchor(EAlfAnchorTopLeft,
                     0,
@@ -2717,7 +2890,7 @@
                     EAlfAnchorMetricAbsolute,
                     EAlfAnchorMetricAbsolute,
                     TAlfTimedPoint(mainPaneSize.iWidth,mainPaneSize.iHeight));
-    
+
 	// Set anchor for header text visual
 	iParentLayout->SetAnchor(EAlfAnchorTopLeft,
 					1,
@@ -2764,7 +2937,7 @@
     if ( topLevelCount )
         {
         TFsTreeItemId topId = iTreeList->Child(KFsTreeRootID, 0);
-        iTreeVisualizer->SetFocusedItemL( topId );            
+        iTreeVisualizer->SetFocusedItemL( topId );
         }
     }
 
@@ -2778,17 +2951,17 @@
     // There may be arbitrary number of nested sub folders. Make sure we focus
     // the bottommost visible subfolder.
     TFsTreeItemId bottomId = KFsTreeRootID;
-    
-    while ( iTreeList->IsNode(bottomId) && 
+
+    while ( iTreeList->IsNode(bottomId) &&
             iTreeList->IsExpanded(bottomId) &&
             iTreeList->CountChildren(bottomId) )
         {
         bottomId = iTreeList->Child( bottomId, iTreeList->CountChildren(bottomId)-1 );
         }
-    
+
     if ( bottomId != KFsTreeRootID )
         {
-        iTreeVisualizer->SetFocusedItemL( bottomId );            
+        iTreeVisualizer->SetFocusedItemL( bottomId );
         }
     }
 
@@ -2813,7 +2986,7 @@
     FUNC_LOG;
     TFsTreeItemId itemId = KFsTreeNoneID;
     TInt count = iTreeList->CountChildren(KFsTreeRootID);
-	
+
 	// If top level is collapsed, then everything is collapsed. There's no need
 	// to crawl any deeper in the tree hierarchy.
 	for ( TInt i=0 ; i<count ; ++i )
@@ -2825,7 +2998,7 @@
 	        return EFalse;
 	        }
 	    }
-	
+
 	return ETrue;
     }
 
@@ -2838,10 +3011,10 @@
     FUNC_LOG;
     // We must crawl through the whole tree to see, if there are any collapsed nodes
     // at any level. We do this with recursive depth-first-search.
-    
+
     TFsTreeItemId itemId = KFsTreeNoneID;
     TInt count = iTreeList->CountChildren(aParentNodeId);
-    
+
     for ( TInt i=0 ; i<count ; ++i )
         {
         itemId = iTreeList->Child( aParentNodeId, i );
@@ -2854,7 +3027,7 @@
                 }
             }
         }
-	
+
 	return ETrue;
     }
 
@@ -2875,27 +3048,27 @@
             {
             // Get the list level
             TUint level = iTreeList->Level( focusedId );
-            
+
             // Little optimisation, handle all levels up to KListLastBasicLevel
             // as root level because horizontal scroll amount is same for all
             if( level <= KListLastBasicLevel )
                 {
                 level = KListRootLevel;
                 }
-            
+
             // Recalculate the list rect only if level has changed or if
             // recalculation is forced by parameter (e.g. in case of
             // dynamic variant switch)
             if( ( level != iPreviousListLevel ) || aForceRecalculation )
                 {
                 TRect listRect = iListLayout->DisplayRectTarget();
-                
+
                 // Calulate list rect by taking x-coordinates from iScreenRect
                 // and y-coordinates from list layouts target rect (to take
                 // into account the list header)
                 listRect.SetRect( iScreenRect.iTl.iX, listRect.iTl.iY,
                                   iScreenRect.iBr.iX, listRect.iBr.iY );
-                
+
                 if( level > KListLastBasicLevel )
                     {
                     // Calculate rect according to current level
@@ -2903,7 +3076,7 @@
                     listRect.SetWidth( iScreenRect.Width() + rectChange );
                     listRect.Move( -rectChange, 0 );
                     }
-    
+
                 // Set the list rect only if it has changed from previous
                 // (because list refresh causes a little twitch)
                 if( listRect != iPreviousListRect )
@@ -2912,7 +3085,7 @@
                     iTreeVisualizer->RefreshListViewL();
                     iPreviousListRect = listRect;
                     }
-                
+
                 iPreviousListLevel = level;
                 }
             }
@@ -2977,6 +3150,16 @@
             Toolbar()->SetItemDimmed( EFsEmailUiTbCmdExpandAll, ETrue, ETrue );
             break;
             }
+        case EFsFocusVisibilityChange:
+            {
+            iAppUi.SetFocusVisibility( EFalse );
+            break;
+            }
+        default:
+            {
+            // No need to handle other events.
+            break;
+            }
         }
     }
 
@@ -2989,24 +3172,26 @@
     TFSMailMsgId aMailboxId, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
     {
     FUNC_LOG;
-    
+
     // Handle the event
-    if ( iMoveOrCopyInitiated && 
-         iFirstStartCompleted && 
+    if ( iMoveOrCopyInitiated &&
+         iFirstStartCompleted &&
          aMailboxId == iAppUi.GetActiveMailboxId() &&
-         iAppUi.CurrentActiveView() == this ) 
+         iAppUi.CurrentActiveView() == this )
         {
-		if ( aEvent == TFSEventMailboxOnline ) 
+		if ( aEvent == TFSEventMailboxOnline )
 			{
             if( iWaitingToGoOnline )
                 {
                 PrepareFolderListL();
                 PopulateFolderListL();
-                
+
                 if ( iModel->Count() )
                     {
-                    SetFocusToLatestMovedFolderL(); 
+                    SetFocusToLatestMovedFolderL();
                     }
+                iTreeList->SetFocusedL( ETrue );
+                iWaitingToGoOnline = EFalse;
                 }
 			}
    		else if ( aEvent == TFSEventMailboxOffline )
@@ -3022,6 +3207,17 @@
     }
 
 // ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CFSEmailUiFolderListVisualiser::FocusVisibilityChange( TBool aVisible )
+    {
+    FUNC_LOG;
+    CFsEmailUiViewBase::FocusVisibilityChange( aVisible );
+    iTreeVisualizer->SetFocusVisibility( aVisible );
+    }
+
+// ---------------------------------------------------------------------------
 // CbaButtonPressed
 // Check if aPosition is on CBA touch area
 // ---------------------------------------------------------------------------
@@ -3029,7 +3225,7 @@
 TBool CFSEmailUiFolderListVisualiser::CbaButtonPressed( TPoint aPosition )
     {
     TBool cbaPressed( EFalse );
-    
+
     TRect leftCbaRect = TRect();
     TRect rightCbaRect = TRect();
     GetCbaRects( leftCbaRect, rightCbaRect );
@@ -3049,7 +3245,7 @@
 //
 void CFSEmailUiFolderListVisualiser::GetCbaRects( TRect& aLeftCbaRect, TRect& aRightCbaRect )
     {
-    TBool rightPaneActive( IsAreaSideRightPaneActive() );    
+    TBool rightPaneActive( IsAreaSideRightPaneActive() );
     TBool bskLandscape( Layout_Meta_Data::IsLandscapeOrientation() &&
                         !rightPaneActive );
     TRect screen;
@@ -3058,9 +3254,9 @@
         {
         TAknWindowComponentLayout rightAreaLayout(
             AknLayoutScalable_Avkon::area_side_right_pane( 0 ) );
-            
+
         TAknLayoutRect layoutRect;
-        // Read right (top in landscape) softkey layout.      
+        // Read right (top in landscape) softkey layout.
         layoutRect.LayoutRect(
                 screen,
                 TAknWindowComponentLayout::Compose(
@@ -3068,7 +3264,7 @@
                 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane() ).LayoutLine() );
         TRect bottomSKRect( layoutRect.Rect() );
 
-        // Read left (bottom in landscape) softkey layout.       
+        // Read left (bottom in landscape) softkey layout.
         layoutRect.LayoutRect(
                 screen,
                 TAknWindowComponentLayout::Compose(
@@ -3084,10 +3280,10 @@
         layoutRect.LayoutRect(
             topSKRect,
             AknLayoutScalable_Avkon::aid_touch_sctrl_top().LayoutLine() );
-        aRightCbaRect = layoutRect.Rect();        
+        aRightCbaRect = layoutRect.Rect();
         }
     else
-        {          
+        {
         TAknWindowComponentLayout applicationWindow(
             AknLayoutScalable_Avkon::application_window( 0 ) );
         TAknLayoutRect cbarect;
@@ -3099,7 +3295,7 @@
                     AknLayoutScalable_Avkon::area_bottom_pane( bskLandscape ? 2 : 1 ),
                     AknLayoutScalable_Avkon::control_pane() ) ).LayoutLine() );
         aLeftCbaRect = cbarect.Rect();
-        }    
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -3112,8 +3308,8 @@
     // Currently the widescreen status pane layout is in use only
     // when pen input (touch) is enabled.
     TBool result = EFalse;
-    
-    if ( Layout_Meta_Data::IsLandscapeOrientation() && 
+
+    if ( Layout_Meta_Data::IsLandscapeOrientation() &&
          Layout_Meta_Data::IsPenEnabled() )
         {
         if ( iAvkonEnv->StatusPaneResIdForCurrentLayout(
--- a/emailuis/emailui/src/FreestyleEmailUiHtmlViewerContainer.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiHtmlViewerContainer.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -213,13 +213,14 @@
     // 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 );
+    CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile, iAppUi.ClientRect().Width() );
     
     // Remove all previously created files from temporary HTML folder
     EmptyTempHtmlFolderL();
 
     CFSMailMessagePart* htmlBodyPart = iMessage->HtmlBodyPartL();
 
+    TBool bodyPartAvailable( EFalse );
     if ( htmlBodyPart )
         {
         CleanupStack::PushL( htmlBodyPart );
@@ -229,6 +230,7 @@
         
         // Copy html body part to email html file
         CopyFileToHtmlFileL( htmlFile, KBodyHtmlFile, *htmlBodyPart );
+        bodyPartAvailable = ETrue;
         
         CleanupStack::PopAndDestroy( &htmlFile );
         CleanupStack::PopAndDestroy( htmlBodyPart );
@@ -254,6 +256,7 @@
             
             contentBuffer8->Des().Copy(*contentBuffer);         
             CopyFileToHtmlFileL( *contentBuffer8, KBodyHtmlFile, *textBodyPart );
+            bodyPartAvailable = ETrue;
             
             CleanupStack::PopAndDestroy( contentBuffer8 );
             CleanupStack::PopAndDestroy( contentBuffer );
@@ -262,10 +265,13 @@
 
         }
     // pass the emailHtmlFile to the browser for it to load
-    TPath emailHtmlFile;
-    emailHtmlFile.Copy( iHtmlFolderPath );
-    emailHtmlFile.Append( KMessageHtmlFile );
-    LoadContentFromFileL( emailHtmlFile );
+    if ( bodyPartAvailable )
+        {
+        TPath emailHtmlFile;
+        emailHtmlFile.Copy( iHtmlFolderPath );
+        emailHtmlFile.Append( KMessageHtmlFile );
+        LoadContentFromFileL( emailHtmlFile );
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -996,7 +1002,7 @@
 
         User::LeaveIfError( targetFile.Replace( iFs, aFileName, EFileWrite ) );
         
-	    	HBufC8* charSet = GetCharacterSetL( aHtmlBodyPart );
+        HBufC8* charSet = GetCharacterSetL( aHtmlBodyPart );
         CleanupStack::PushL( charSet );
         
         User::LeaveIfError( targetFile.Write( KHtmlHeader1 ) );
@@ -1008,24 +1014,24 @@
         // 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) ) );
-        		}
-        	else
-        		{
-        		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) ) );				                
-            		}
-          		}
+          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) ) );
+            }
+          else
+            {
+            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) ) );                        
+                }
+              }
             }
         INFO("Add end tags");
         User::LeaveIfError( targetFile.Write( KHtmlEndTags ) );
@@ -1102,3 +1108,30 @@
         TRAP_IGNORE( iBrCtlInterface->LoadDataL(KHTMLDataScheme, KHTMLEmptyContent, _L8("text/html"), uid) );
         }   
     }
+
+void CFsEmailUiHtmlViewerContainer::HandleResourceChange( TInt aType )
+	{
+	CCoeControl::HandleResourceChange( aType );
+	
+	if ( aType == CFsEmailUiViewBase::EScreenLayoutChanged )
+		{
+	    // only update header if we get a layout change from email ui
+		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, iAppUi.ClientRect().Width() ) )
+            
+            TPath emailHtmlFile;
+            emailHtmlFile.Copy( iHtmlFolderPath );
+            emailHtmlFile.Append( KMessageHtmlFile );
+            
+            TRAP_IGNORE( LoadContentFromFileL( emailHtmlFile ) )
+            
+            SetRect( iAppUi.ClientRect() );
+            }
+		}
+	}
--- a/emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -129,6 +129,7 @@
     iOpenMessages = new (ELeave) CStack<CFSMailMessage, ETrue>();
     iEmbeddedMessages = new (ELeave) CStack<CFSMailMessage, EFalse>();
     iNextOrPrevMessageSelected = EFalse; 
+    iForwardingMessage = EFalse;
     }
 
 // -----------------------------------------------------------------------------
@@ -290,6 +291,7 @@
                         iContainer->ResetContent();
                         }
 
+                    iForwardingMessage = ETrue;
                     iAppUi.LaunchEditorL( KEditorCmdForward, params );
                     }
                 }
@@ -647,7 +649,7 @@
             else{
                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );         
                 }                
-                
+            
     
             TRAPD( error, LoadContentFromMailMessageL( iOpenMessages->Head() ) );
             if ( error == KErrNotFound || error == KErrInUse || error == KErrLocked )
@@ -703,7 +705,7 @@
                 iAppUi.SetTitlePaneTextL(*emailAddress);
                 CleanupStack::PopAndDestroy(emailAddress);
                 }
-            CleanupStack::PopAndDestroy( displayName );      
+        CleanupStack::PopAndDestroy( displayName );
             }
         }
     
@@ -736,6 +738,7 @@
             }
        }
     iNextOrPrevMessageSelected = EFalse;
+    iForwardingMessage = EFalse;
     }
 
 // -----------------------------------------------------------------------------
@@ -814,8 +817,14 @@
 void CFsEmailUiHtmlViewerView::ChildDoDeactivate()
     {
     FUNC_LOG;
-    CancelFetchings();
-   
+    // 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();
+        }
+
     if ( iContainer )
         {
         HideContainer();
@@ -1036,13 +1045,13 @@
     }
 
 
-void CFsEmailUiHtmlViewerView::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType /*aType*/ )
+void CFsEmailUiHtmlViewerView::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType )
     {
     FUNC_LOG;
-
+    
     if ( iContainer )
         {
-        iContainer->SetRect( ClientRect() );
+        iContainer->HandleResourceChange( aType );
         }
     }
 
@@ -1112,22 +1121,45 @@
             HideContainer();
             iContainer->ResetContent();
             }
-
+        
         RArray<TFSMailMsgId> msgIds;
         CleanupClosePushL( msgIds );
-        msgIds.Append( iMessage->GetMessageId() );
+        TFSMailMsgId currentMsgId = iMessage->GetMessageId();    
+        msgIds.Append( currentMsgId );
         TFSMailMsgId mailBox = iMessage->GetMailBoxId();
-        TFSMailMsgId folderId = iMessage->GetFolderId();
+        TFSMailMsgId folderId = iMessage->GetFolderId();        
+ 
+		//Get the id and check if there is a previous message available 
+		TFSMailMsgId prevMsgId;
+		TFSMailMsgId prevMsgFolderId;  
+		
+		//Get the previous message if it exists
+		TBool available = iAppUi.IsPreviousMsgAvailable( currentMsgId, 
+												   prevMsgId, 
+                        		                   prevMsgFolderId );
+        
+        //Delete the message
         iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );
         CleanupStack::PopAndDestroy( &msgIds );
 
         // Notify appui of deleted mail item
-        SendEventToAppUiL( TFSEventMailDeleted );
-
+        SendEventToAppUiL( TFSEventMailDeleted ); 
+        
         if ( iAppUi.CurrentActiveView()->Id() == HtmlViewerId )
-            {
-            NavigateBackL();
-            }
+			{	
+			//Open the previous message or navigate back to list viewer
+			if ( available )
+				{
+				iAppUi.MoveToPreviousMsgAfterDeleteL( prevMsgId );				
+				}	
+			else
+				{
+				ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
+				NavigateBackL();
+				}
+			//inform user that mail is deleted	
+			TFsEmailUiUtility::ShowGlobalInfoNoteL( R_FREESTYLE_EMAIL_MAIL_DELETED );
+			}        
         }
     }
 
@@ -1140,11 +1172,10 @@
         TFSMailMsgId aMailbox, TAny* aParam1, TAny* /*aParam2*/, TAny* /*aParam3*/ )
     {
     FUNC_LOG;
-
     if ( /*iFirstStartCompleted &&*/ iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() &&
                                      aEvent == TFSEventMailDeleted && aParam1 ) // Safety, in list events that only concern active mailbox are handled
         {
-        TFSMailMsgId curMsgId = iMessage->GetMessageId();
+        TFSMailMsgId curMsgId = iMessage->GetMessageId();       
         RArray<TFSMailMsgId>* removedEntries = static_cast<RArray<TFSMailMsgId>*>( aParam1 );
         // <cmail> break-keyword should be used only in switch-clauses
         TBool cont = ETrue;
@@ -1152,13 +1183,12 @@
         for ( TInt i = 0 ; i < removedEntries->Count() && cont; i++ )
             {
             if ( curMsgId == ( *removedEntries )[i] )
-                {
-                ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
-                NavigateBackL();
+                {                
                 cont = EFalse;
-                }
-            }
+                }            
+            } 
         }
+     
     if (iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() && aEvent == TFSEventNewMail)
         {
         UpdateNaviPaneL();
@@ -1389,7 +1419,26 @@
     HBufC* textData = aEmailAddress.AllocLC();
     CFSMailBox* mailBox = iAppUi.GetMailClient()->GetMailBoxByUidL( iMessage->GetMailBoxId() );
     CleanupStack::PushL( mailBox );
+  
+    //UI options Delete and Actions dimmed in Remote Lookup.
+    const TInt resourceId(ToolbarResourceId());
+    RArray<TInt> dimmedItems;
+    CleanupClosePushL(dimmedItems);
+    GetInitiallyDimmedItemsL(resourceId, dimmedItems); // get the currently dimmed buttons
+    
+    SetToolbarItemDimmed( EFsEmailUiTbCmdActions, ETrue);
+    SetToolbarItemDimmed( EFsEmailUiTbCmdDelete, ETrue);
+        
     CFsDelayedLoader::InstanceL()->GetContactHandlerL()->LaunchRemoteLookupWithQueryL( *mailBox, *textData );
+    
+    SetToolbarItemDimmed( EFsEmailUiTbCmdActions, EFalse);
+    SetToolbarItemDimmed( EFsEmailUiTbCmdDelete, EFalse);
+   
+    for (TInt i = 0; i < dimmedItems.Count(); i++) // restore the buttons
+        {
+        SetToolbarItemDimmed(dimmedItems[i], ETrue);
+        }
+    CleanupStack::PopAndDestroy(); // dimmedItems.Close()
     CleanupStack::PopAndDestroy( mailBox );
     CleanupStack::PopAndDestroy( textData );
     }
@@ -2459,11 +2508,16 @@
         case EESMRCmdDownloadAttachment:
         case EESMRCmdDownloadAllAttachments:
             {
+            if(iAttachmentsListModel == NULL)
+                {
+                iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
+                iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );
+                }
             // Check that message has attachments to display
             if ( messagePtr->IsFlagSet( EFSMsgFlag_Attachments ) )
                 {
                 iOpResult.iResultCode = KErrNone;
-                //StartDowloadingAttachmentsL();
+                DownloadAllAttachmentsL();
                 CompletePendingMrCommand();
                 }
             }
@@ -2471,6 +2525,11 @@
         case EESMRCmdSaveAttachment:
         case EESMRCmdSaveAllAttachments:
             {
+            if(iAttachmentsListModel == NULL)
+                {
+                iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
+                iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );
+                }
             // Check that message has attachments to display
             if ( messagePtr->IsFlagSet( EFSMsgFlag_Attachments ) )
                 {
@@ -2777,21 +2836,28 @@
         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( CAknNavigationDecorator::ERightButton, EFalse );
+            naviDecorator->SetScrollButtonDimmed( nextButton, EFalse );
             }
         else
             {
-            naviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ERightButton, ETrue );
+            naviDecorator->SetScrollButtonDimmed( nextButton, ETrue );
             }
         if ( iAppUi.IsPreviousMsgAvailable( currentMsgId, tmpMsgId, tmpMsgFolderId ) )
             {
-            naviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ELeftButton, EFalse );
+            naviDecorator->SetScrollButtonDimmed( prevButton, EFalse );
             }
         else
             {
-            naviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ELeftButton, ETrue );
+            naviDecorator->SetScrollButtonDimmed( prevButton, ETrue );
             }
 
         // Set this view's navipane to the top of the navipane control stack
@@ -2847,7 +2913,12 @@
         {
         naviDecorator->SetNaviDecoratorObserver( NULL );
         }
-    if( aEventID == MAknNaviDecoratorObserver::EAknNaviDecoratorEventRightTabArrow )
+    MAknNaviDecoratorObserver::TAknNaviDecoratorEvents nextButton = MAknNaviDecoratorObserver::EAknNaviDecoratorEventRightTabArrow;
+    if (AknLayoutUtils::LayoutMirrored())
+        {
+        nextButton = MAknNaviDecoratorObserver::EAknNaviDecoratorEventLeftTabArrow;
+        }
+    if( aEventID == nextButton )
         {
         ShowNextMessageL();
         }
--- a/emailuis/emailui/src/FreestyleEmailUiLauncherGridVisualiser.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiLauncherGridVisualiser.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2009 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"
@@ -27,25 +27,21 @@
 #include <e32math.h>
 #include <FreestyleEmailUi.rsg>
 #include <touchlogicalfeedback.h>
-// <cmail> SF path changes
 #include <alf/alfutil.h>
 #include <alf/alfenv.h>
 #include <alf/alfevent.h>
 #include <alf/alftextvisual.h>
-//</cmail>
-#include <aknnotewrappers.h>  
+#include <aknnotewrappers.h>
 #include <freestyleemailui.mbg>
 #include <gulicon.h>
-//<cmail>
+#include <akntoolbar.h>
 #include "CFSMailMessage.h"
 #include <alf/alfframebrush.h>
 #include "CFSMailBox.h"
 #include "CFSMailClient.h"
-//</cmail>
 #include <hlplch.h>
 #include <akntitle.h>
 #include <centralrepository.h>
-//<cmail>
 #include <alf/alfanchorlayout.h>
 #include <alf/alfbrusharray.h>
 #include <alf/alfstatic.h>
@@ -53,16 +49,13 @@
 #include <alf/alfconstants.h>
 #include "fsalfscrollbarlayout.h"
 #include <csxhelp/cmail.hlp.hrh>
-//</cmail>
 #include <featmgr.h>
-//</cmail>
 
 #include <aknmessagequerydialog.h>
-// <cmail> Use layout data instead of hard-coded values
+#include <aknstyluspopupmenu.h>
 #include <aknlayoutscalable_avkon.cdl.h>
 #include <aknlayoutscalable_apps.cdl.h>
 #include <layoutmetadata.cdl.h>
-// </cmail>
 
 // INTERNAL INCLUDE FILES
 #include "FSEmailBuildFlags.h"
@@ -88,14 +81,12 @@
 const TInt KStartupAnimationTime = 0;
 const TReal KScaleSelected = 1.0;
 const TReal KScaleNotSelected = 0.77;
-// <cmail> Use layout data instead of hard-coded values
-// </cmail>
 
 
 CFSEmailUiLauncherGridVisualiser* CFSEmailUiLauncherGridVisualiser::NewL(CAlfEnv& aEnv,
-												 CFSEmailUiLauncherGrid* aControl, 
+												 CFSEmailUiLauncherGrid* aControl,
 												 CFreestyleEmailUiAppUi* aAppUi,
-												 CAlfControlGroup& aControlGroup, 
+												 CAlfControlGroup& aControlGroup,
 												 TInt aColumns, TInt aRows)
     {
     FUNC_LOG;
@@ -104,10 +95,10 @@
     return self;
     }
 
-CFSEmailUiLauncherGridVisualiser* CFSEmailUiLauncherGridVisualiser::NewLC(CAlfEnv& aEnv, 
-												  CFSEmailUiLauncherGrid* aControl, 
+CFSEmailUiLauncherGridVisualiser* CFSEmailUiLauncherGridVisualiser::NewLC(CAlfEnv& aEnv,
+												  CFSEmailUiLauncherGrid* aControl,
 												  CFreestyleEmailUiAppUi* aAppUi,
-												  CAlfControlGroup& aControlGroup, 
+												  CAlfControlGroup& aControlGroup,
 												  TInt aColumns, TInt aRows)
     {
     FUNC_LOG;
@@ -117,12 +108,12 @@
     return self;
     }
 
-CFSEmailUiLauncherGridVisualiser::CFSEmailUiLauncherGridVisualiser(CAlfEnv& aEnv, 
-											 CFSEmailUiLauncherGrid* aControl, 
+CFSEmailUiLauncherGridVisualiser::CFSEmailUiLauncherGridVisualiser(CAlfEnv& aEnv,
+											 CFSEmailUiLauncherGrid* aControl,
 										     CFreestyleEmailUiAppUi* aAppUi,
 										     CAlfControlGroup& aControlGroup)
     : CFsEmailUiViewBase(aControlGroup, *aAppUi),
-    iEnv( aEnv ), 
+    iEnv( aEnv ),
     iVisibleRows( 0 ),
     iVisibleColumns( 0 ),
     iRowCount( 0 ),
@@ -149,84 +140,100 @@
     iConstructionCompleted = EFalse;
     iDoubleClickLock = EFalse;
     iUiOperationLaunched = EFalse;
-    
+
     iMailboxDeleter = CFSEmailUiMailboxDeleter::NewL( *iAppUi.GetMailClient(), *this );
     }
 
+// ----------------------------------------------------------------------------
 // CFSEmailUiLauncherGridVisualiser::DoFirstStartL()
-// Purpose of this function is to do first start only when grid is
-// really needed to be shown. Implemented to make app startuo faster.
+// Purpose of this function is to do first start only when grid is really
+// needed to be shown. Implemented to make app startup faster.
+// ----------------------------------------------------------------------------
+//
 void CFSEmailUiLauncherGridVisualiser::DoFirstStartL()
     {
     FUNC_LOG;
     iPluginIdIconIdPairs.Reset();
 
-// <cmail> Use layout data instead of hard-coded values
     TRect mainPaneRect;
-    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
-    
+    AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
+									   mainPaneRect );
+
     TAknLayoutRect scrollBarRect;
-    scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar());
+    scrollBarRect.LayoutRect( mainPaneRect,
+    	AknLayoutScalable_Avkon::aid_size_touch_scroll_bar() );
     TRect gridRect = mainPaneRect;
     gridRect.iBr.iX -= scrollBarRect.Rect().Width();
-    
+
     TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
-    iVisibleRows = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastRow() + 1;
-    iVisibleColumns = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastColumn() + 1;
-// </cmail>
-    
+    iVisibleRows = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits( var ).LastRow() + 1;
+    iVisibleColumns = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits( var ).LastColumn() + 1;
+
     iStartupAnimation = ETrue;
     iCurrentLevel.iSelected = KDefaultSelection;
     CAlfTextureManager& manager = iEnv.TextureManager();
 
-    iParentLayout = CAlfDeckLayout::AddNewL(*iControl);
-    iParentLayout->SetFlags(EAlfVisualFlagLayoutUpdateNotification);
+    iParentLayout = CAlfDeckLayout::AddNewL( *iControl );
+    iParentLayout->SetFlags( EAlfVisualFlagLayoutUpdateNotification );
 
     // Widget layout divides the screen between grid and scroll bar
     iWidgetLayout = CAlfAnchorLayout::AddNewL( *iControl, iParentLayout );
-    //<cmail>
-	TSize displaySize = mainPaneRect.Size(); //iControl->DisplayArea().Size();
-    //</cmail>    
+	TSize displaySize = mainPaneRect.Size();
     iWidgetLayout->SetSize( displaySize );
-     
+
     // Constructed here, updated later, #0 item in iWidgetLayout
     ConstructScrollbarL( iWidgetLayout );
 
-    // Grid layout is constructed here, #1 item in iWidgetLayout    
-    iCurrentLevel.iGridLayout = CAlfGridLayout::AddNewL( *iControl, iVisibleColumns, iVisibleRows, iWidgetLayout );
+    // Grid layout is constructed here, #1 item in iWidgetLayout
+    iCurrentLevel.iGridLayout =
+		CAlfGridLayout::AddNewL( *iControl, iVisibleColumns, iVisibleRows,
+								 iWidgetLayout );
     iCurrentLevel.iGridLayout->EnableScrollingL( ETrue );
     iCurrentLevel.iGridLayout->SetFlags( EAlfVisualFlagAutomaticLocaleMirroringEnabled );
-     
+
     // Selector is added to iGridLayout
-    iSelector = iControl->AppendLayoutL( EAlfLayoutTypeLayout, iCurrentLevel.iGridLayout );
+    iSelector = iControl->AppendLayoutL( EAlfLayoutTypeLayout,
+										 iCurrentLevel.iGridLayout );
     iSelector->SetFlags( EAlfVisualFlagManualLayout );
-     
-    iRingMovementXFunc = CAlfTableMappingFunction::NewL(iEnv);
-    iRingMovementYFunc = CAlfTableMappingFunction::NewL(iEnv);
+
+    iRingMovementXFunc = CAlfTableMappingFunction::NewL( iEnv );
+    iRingMovementYFunc = CAlfTableMappingFunction::NewL( iEnv );
 
     TAlfTimedPoint selectorPos = iSelector->Pos();
     selectorPos.iX.SetMappingFunctionIdentifier( iRingMovementXFunc->MappingFunctionIdentifier() );
-    selectorPos.iY.SetMappingFunctionIdentifier( iRingMovementYFunc->MappingFunctionIdentifier() ); 
+    selectorPos.iY.SetMappingFunctionIdentifier( iRingMovementYFunc->MappingFunctionIdentifier() );
     iSelector->SetPos( selectorPos );
-     
+
     UpdateFocusVisibility();
     iSelectorImageVisual = CAlfImageVisual::AddNewL( *iControl, iSelector );
     iSelectorImageVisual->SetScaleMode( CAlfImageVisual::EScaleFit );
-// <cmail> Use layout data instead of hard-coded values 
+
+    // Use layout data instead of hard-coded values
     iSelectorImageVisual->SetSize( iAppUi.LayoutHandler()->SelectorVisualSizeInThisResolution() );
     TAknLayoutRect itemRect;
-    itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var,0,0));
+    itemRect.LayoutRect( gridRect,
+    	AknLayoutScalable_Apps::cell_cmail_l_pane( var, 0, 0 ) );
     iSelectorImageVisual->SetSize( itemRect.Rect().Size() );
-// </cmail>
-     
     iSelectorImageVisual->EnableBrushesL();
     CAlfFrameBrush* brush = iAppUi.FsTextureManager()->GridSelectorBrushL();
     iSelectorImageVisual->Brushes()->AppendL( brush, EAlfDoesNotHaveOwnership );
     iStartupEffectStyle = EFalse;
-  
+
     iAiwSHandler = CAiwServiceHandler::NewL();
     iAiwSHandler->AttachL( R_AIW_INTEREST_LAUNCH_SETUP_WIZARD );
 
+    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
+        }
+
     // Initial visual layout update is done when the view gets activated.
     iRefreshNeeded = ETrue;
 
@@ -246,7 +253,7 @@
     iItemIdInButtonDownEvent.iLaunchSelection = EFalse;
 
     UpdateFocusVisibility();
-    
+
 	if( !IsFocusShown() )
 		{
         // No items are focused anymore. Shrink the icon.
@@ -296,18 +303,17 @@
     delete iRingMovementYFunc;
     delete iModel;
     delete iAiwSHandler;
-    // <cmail>
     delete iScrollbar;
-    // </cmail> 
     delete iMailboxDeleter;
+    delete iStylusPopUpMenu;
     }
 
 void CFSEmailUiLauncherGridVisualiser::CreateModelL()
     {
     FUNC_LOG;
-    
+
     RArray<TBool> itemInModel;
-    CleanupClosePushL( itemInModel );    
+    CleanupClosePushL( itemInModel );
     iIconArray.Reset();
 
 	iPluginTextureId = EGridPluginIconFirst;
@@ -316,7 +322,7 @@
     delete iModel;
     iModel = NULL;
     iModel = new (ELeave) CFSEmailUiLauncherGridModel();
-    iModel->ConstructL();   
+    iModel->ConstructL();
 	CAlfTexture* iconTexture = 0;
 
 	// Get item ordering from resources
@@ -333,24 +339,24 @@
 
     TInt count = reader.ReadInt16();
 
-// <cmail> Use layout data instead of hard-coded values    
+// <cmail> Use layout data instead of hard-coded values
     TRect mainPaneRect;
     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
-    
+
     TAknLayoutRect scrollBarRect;
     scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar());
     TRect gridRect = mainPaneRect;
     gridRect.iBr.iX -= scrollBarRect.Rect().Width();
-    
+
     TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
     TAknLayoutRect itemRect;
     itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var,0,0));
-    
+
     TAknLayoutRect gridIconLRect;
     gridIconLRect.LayoutRect(itemRect.Rect(), AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var));
     TSize iconSize = gridIconLRect.Rect().Size();
 // </cmail>
-    
+
     for ( TInt itemIndex = 0; itemIndex < count; itemIndex++ )
         {
         TInt itemId = reader.ReadInt16();
@@ -358,10 +364,10 @@
             {
             case EDefaultMailboxItem:
                 {
-                
+
                 RPointerArray<CFSMailBox> mailBoxes;
                 CleanupResetAndDestroyClosePushL( mailBoxes );
-                TFSMailMsgId id; 
+                TFSMailMsgId id;
                 TInt err = iAppUi.GetMailClient()->ListMailBoxes(
                     id,
                     mailBoxes );
@@ -370,13 +376,13 @@
                     {
                     // Try to get branded graphic
                     CGulIcon* mbIcon(0);
-		         	TRAPD( err, mbIcon = brandManager.GetGraphicL( EFSMailboxIcon, mailBoxes[0]->GetId() ) ); 
+		         	TRAPD( err, mbIcon = brandManager.GetGraphicL( EFSMailboxIcon, mailBoxes[0]->GetId() ) );
 					if ( err == KErrNone && mbIcon )
 						{
 						CleanupStack::PushL( mbIcon );
 				    	AknIconUtils::SetSize(mbIcon->Bitmap(), iconSize);
-					    AknIconUtils::SetSize(mbIcon->Mask(), iconSize);				
-		
+					    AknIconUtils::SetSize(mbIcon->Mask(), iconSize);
+
 					    // Create texture into TextureManager, If not already existing
 					    // Note: size(0,0) means original icon size
 					    iAppUi.FsTextureManager()->CreateBrandedMailboxTexture( mbIcon,
@@ -390,10 +396,10 @@
 
 						CleanupStack::PopAndDestroy( mbIcon );
 						}
-					else 
+					else
 						{
-	                    iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridInboxTexture );									
-						}					                 	
+	                    iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridInboxTexture );
+						}
 
    			        iIconArray.AppendL( iconTexture );
 
@@ -405,8 +411,8 @@
                         mailBoxes[0]->GetName(),
                         *iconTexture,
                         mailBoxes[0]->GetId(),
-                        mailBoxes[0]->GetStandardFolderId( EFSInbox ) ); 						
-   			        
+                        mailBoxes[0]->GetStandardFolderId( EFSInbox ) );
+
    			        iAppUi.SubscribeMailboxL( mailBoxes[0]->GetId() );
                     }
 
@@ -417,22 +423,22 @@
                 {
                 RPointerArray<CFSMailBox> mailBoxes;
                 CleanupResetAndDestroyClosePushL( mailBoxes );
-                TFSMailMsgId id; 
+                TFSMailMsgId id;
                 TInt err = iAppUi.GetMailClient()->ListMailBoxes(
                     id,
                     mailBoxes );
-                
+
                 for ( TInt i = 1; i < mailBoxes.Count(); i++ )
                     {
                    // Try to get branded graphic
                     CGulIcon* mbIcon(0);
-		         	TRAPD( err, mbIcon = brandManager.GetGraphicL( EFSMailboxIcon,  mailBoxes[i]->GetId() ) ); 
+		         	TRAPD( err, mbIcon = brandManager.GetGraphicL( EFSMailboxIcon,  mailBoxes[i]->GetId() ) );
 					if ( err == KErrNone && mbIcon )
 						{
 						CleanupStack::PushL( mbIcon );
 				    	AknIconUtils::SetSize(mbIcon->Bitmap(), iconSize);
-					    AknIconUtils::SetSize(mbIcon->Mask(), iconSize);				
-					    
+					    AknIconUtils::SetSize(mbIcon->Mask(), iconSize);
+
 					    // Create texture into TextureManager, If not already existing
 					    iAppUi.FsTextureManager()->CreateBrandedMailboxTexture( mbIcon,
 					    		                                                 mailBoxes[i]->GetId().PluginId(),
@@ -444,11 +450,11 @@
 					    		                                                        TSize(0,0));
 						CleanupStack::PopAndDestroy( mbIcon );
 						}
-					else 
+					else
 						{
-	                    iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridInboxTexture );				
+	                    iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridInboxTexture );
 						}
-  	                iIconArray.AppendL( iconTexture );	          
+  	                iIconArray.AppendL( iconTexture );
                     // Branded mailbox name is nowadays set in new mailbox event
                     // handling, so we don't need to use brand manager here anymore.
                     iModel->AddL(
@@ -458,10 +464,10 @@
                         *iconTexture,
                         mailBoxes[i]->GetId(),
                         mailBoxes[i]->GetStandardFolderId( EFSInbox ) );
-                    
+
                     iAppUi.SubscribeMailboxL( mailBoxes[i]->GetId() );
                     }
-                    
+
                 CleanupStack::PopAndDestroy( &mailBoxes );
                 }
                 break;
@@ -469,11 +475,11 @@
                 {
                 RPointerArray<CFSMailBox> mailBoxes;
                 CleanupResetAndDestroyClosePushL( mailBoxes );
-                TFSMailMsgId id; 
+                TFSMailMsgId id;
                 TInt err = iAppUi.GetMailClient()->ListMailBoxes(
                     id,
                     mailBoxes );
-                
+
                 for ( TInt i = 0; i < mailBoxes.Count(); i++ )
                     {
                     if ( TFsEmailUiUtility::IsRemoteLookupSupported( *mailBoxes[i] ) )
@@ -496,7 +502,7 @@
                 iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridSettingsTexture );
                 iModel->AddL(EShortcut, ESettingsItem, *text, *iconTexture );
                 CleanupStack::PopAndDestroy( text );
-                iIconArray.AppendL( iconTexture );		
+                iIconArray.AppendL( iconTexture );
                 }
                 break;
             case EAddNewMailboxItem:
@@ -505,19 +511,19 @@
                 iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridAddNewBoxTexture );
                 iModel->AddL(EShortcut, EAddNewMailboxItem, *text, *iconTexture );
                 CleanupStack::PopAndDestroy( text );
-                iIconArray.AppendL( iconTexture );		
+                iIconArray.AppendL( iconTexture );
                 }
                 break;
             case EHelpItem:
                 {
-     		   // remove help support in pf5250                
+     		   // remove help support in pf5250
         	    if (! FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
         		   {
                    HBufC* text = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_GRIDITEM_HELP );
                    iconTexture = &iAppUi.FsTextureManager()->TextureByIndex( EGridHelpTexture );
                    iModel->AddL(EShortcut, EHelpItem, *text, *iconTexture );
                    CleanupStack::PopAndDestroy( text );
-                   iIconArray.AppendL( iconTexture );        		   
+                   iIconArray.AppendL( iconTexture );
         		   }
                 }
                 break;
@@ -533,7 +539,7 @@
                     if ( iLauncherItems[i]->Id() == itemId )
                         {
                         itemInModel[i] = ETrue;
-                        AddItemToModelL( iLauncherItems[i], i );                      
+                        AddItemToModelL( iLauncherItems[i], i );
                         break;
                         }
                     }
@@ -554,7 +560,7 @@
             AddItemToModelL( iLauncherItems[i], i );
             }
         }
-    
+
     CleanupStack::PopAndDestroy( &itemInModel );
 	}
 
@@ -585,14 +591,9 @@
 TUid CFSEmailUiLauncherGridVisualiser::Id() const
 	{
     FUNC_LOG;
-	return AppGridId;	
-	}			   
+	return AppGridId;
+	}
 
-// <cmail> Toolbar
-/*
-void CFSEmailUiLauncherGridVisualiser::DoActivateL(const TVwsViewId& aPrevViewId,
-                     TUid aCustomMessageId,
-                     const TDesC8& aCustomMessage)*/
 void CFSEmailUiLauncherGridVisualiser::ChildDoActivateL(const TVwsViewId& aPrevViewId,
                      TUid /*aCustomMessageId*/,
                      const TDesC8& /*aCustomMessage*/)
@@ -602,7 +603,12 @@
         {
         DoFirstStartL();
         }
-    
+
+    if( iAppUi.CurrentFixedToolbar() )
+        {
+        iAppUi.CurrentFixedToolbar()->SetToolbarVisibility( EFalse );
+        }
+
     // For initial mailbox query
 	TBool startedFromOds = EFalse;
 	// NULL wizard started parameter every time when activated again.
@@ -634,7 +640,7 @@
             {
             iAppUi.EnterFsEmailViewL( iAppUi.CurrentActiveView()->Id() );
             }
-        
+
         return;
         }
 
@@ -651,23 +657,23 @@
         }
 
     SetDefaultStatusPaneTextL();
-    
+
     // Mailbox query is called here but shown only once in appui if needed
     // doNotshowQuery is ETrue when started from wizard
   	if ( !iFirstStartComplete )
   		{
   		iFirstStartComplete = ETrue;
 	  	iAppUi.GridStarted( startedFromOds );
-	    iAppUi.ShowMailboxQueryL();  		
+	    iAppUi.ShowMailboxQueryL();
   		}
-  	// <cmail>    
+  	// <cmail>
   	else
   	    {
   	    // Ensure that FSMailServer is running, but don't do it on first
   	    // activation, as it's done anyway in AppUi's ConstructL
   	    TFsEmailUiUtility::EnsureFsMailServerIsRunning( iEikonEnv->WsSession() );
   	    }
-    
+
     if( iRowCount > iVisibleRows )
         {
         iScrollbar->MakeVisible(ETrue);
@@ -676,41 +682,38 @@
         {
         iScrollbar->MakeVisible(EFalse);
         }
-    
+
     iAppUi.HideTitlePaneConnectionStatus();
-  	
+
   	// Erase the navigation history when main grid activated. This is the default view
   	// of the application and back navigation is never possible from here. The view stack
   	// might be in inconsistent state because of some unexpected error in view switching.
   	// Erasing the history helps recovering from such situations.
   	iAppUi.EraseViewHistory();
-
+  	FocusVisibilityChange( iAppUi.IsFocusShown() );
   	UpdateFocusVisibility();
     }
-// </cmail> Toolbar
 
 void CFSEmailUiLauncherGridVisualiser::ChildDoDeactivate()
     {
     FUNC_LOG;
     iScrollbar->MakeVisible(EFalse);
-    // </cmail>
     }
 
-
 void CFSEmailUiLauncherGridVisualiser::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
 	{
     FUNC_LOG;
-    
+
 	if ( aResourceId == R_FSEMAILUI_MAINUIGRID_MENUPANE )
 		{
 	    if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
 		   {
 		   // remove help support in pf5250
-		   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
+		   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);
 		   }
-	    
+
 	    TFSLauncherGridMailboxStatus mbStatus = CheckMailboxStatusL();
-	    
+
 	    // Checks if a device has a keyboard or not.
 		if( !iKeyboardFlipOpen )
 			{
@@ -719,7 +722,7 @@
 				// If no mailboxes configured, dim all mailbox related items.
 				aMenuPane->SetItemDimmed( EFsEmailUiCmdDeleteMailbox, ETrue );
 				}
-			
+
 		   	aMenuPane->SetItemDimmed( EFsEmailUiCmdOpen, ETrue );
 		   	aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue );
 		   	aMenuPane->SetItemDimmed( EFsEmailUiCmdSyncAll, ETrue );
@@ -732,15 +735,15 @@
 			}
 		else
 			{
-		    // <cmail>	    
-		   	aMenuPane->SetItemDimmed( EFsEmailUiCmdAbout, ETrue ); 
+		    // <cmail>
+		   	aMenuPane->SetItemDimmed( EFsEmailUiCmdAbout, ETrue );
 		   	// </cmail>
-		   	
+
 		   	if( mbStatus.iMailboxCount <= 0 )
 		   	    {
 		   	    // If no mailboxes configured, dimm all mailbox related items
 		   	    aMenuPane->SetItemDimmed( EFsEmailUiCmdDeleteMailbox, ETrue );
-	            aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue);      
+	            aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue);
 	            aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue );
 	            aMenuPane->SetItemDimmed( EFsEmailUiCmdSyncAll, ETrue );
 	            aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, ETrue );
@@ -756,7 +759,7 @@
 		   	        // All mailboxes are already not syncing
 	                aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue );
 		   	        }
-		   	    
+
 	            // Handle items related to sync starting
 		   	    if( mbStatus.iMailboxesSyncing == mbStatus.iMailboxCount )
 		   	        {
@@ -774,7 +777,7 @@
 		   	        // Several mailboxes configured, dimm "Synchronise"
 	                aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue );
 		   	        }
-		   	        
+
 	            // Handle items related to online
 		   	    if( mbStatus.iMailboxesOnline == mbStatus.iMailboxCount )
 		   	        {
@@ -792,11 +795,11 @@
 	                // Several mailboxes configured, dimm "Connect"
 	                aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, ETrue );
 		   	        }
-		   	    
+
 	            // Handle pop accounts that can't sync
 	            RPointerArray<CFSMailBox> mailBoxes;
 	            CleanupResetAndDestroyClosePushL( mailBoxes );
-	            TFSMailMsgId id; 
+	            TFSMailMsgId id;
 	            bool onlyPop = true;
 	            TInt err = iAppUi.GetMailClient()->ListMailBoxes(
 	                id,
@@ -815,7 +818,7 @@
                     aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue );
                     aMenuPane->SetItemDimmed( EFsEmailUiCmdSyncAll, ETrue );
                     }
-                
+
                 CleanupStack::PopAndDestroy( &mailBoxes );
 
                 // Handle items related to offline
@@ -838,58 +841,54 @@
                 }
 
             // Add shortcut hints
-            iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane, 
-    	                             CFSEmailUiShortcutBinding::EContextMainGrid );	
+            iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane,
+    	                             CFSEmailUiShortcutBinding::EContextMainGrid );
             }
         }
 	}
 
-void CFSEmailUiLauncherGridVisualiser::HandleCommandL(TInt aCommand)
+void CFSEmailUiLauncherGridVisualiser::HandleCommandL( TInt aCommand )
     {
     FUNC_LOG;
+
     switch ( aCommand )
         {
 		case EAknSoftkeyOpen:
 			{
-			if (!iAppUi.IsTimerFocusShown())
+			if( !iAppUi.IsFocusShown() )
 				{
-				int wasActive = iAppUi.StartFocusRemovalTimer();
-
-	        	if (!wasActive)
-	        		{
-					UpdateFocusVisibility();
-					ResizeItemIcon( EFalse );
-	        		}
-				
+				// No need to handle return value
+                iAppUi.SetFocusVisibility( ETrue );
+                UpdateFocusVisibility();
+                ResizeItemIcon( EFalse );
 				break;
 				}
 			}
        	case EFsEmailUiCmdOpen:
 			{
 			SelectL();
+			break;
 			}
-			break;
-// <cmail> Hiding is disabled in Cmail
-//       	case EFsEmailUiCmdHide:
-//        	{     	
-//			TApaTaskList taskList( iEikonEnv->WsSession() );
-//			TApaTask task = taskList.FindApp( KFSEmailUiUid );
-//			if ( task.Exists() )
-//			    {
-//			    task.SendToBackground(); // Send self to background				
-//			    }
-//			}
-//			break;   
-// </cmail>
 		case EFsEmailUiCmdDeleteMailbox:
 			{
+			// Deletion by using the option menu.
 			iMailboxDeleter->DeleteMailboxL();
 			break;
-			}		
+			}
+		case EFsEmailUiCmdDeleteSelectedMailbox:
+			{
+			// Deletion by using the long tap pop-up menu.
+			iMailboxDeleter->DeleteMailboxL( iMailboxToDelete );
+
+	    	// Hide the focus.
+	        iAppUi.SetFocusVisibility( EFalse );
+	        HandleButtonReleaseEvent(); // Finishes the focus removal.
+			break;
+			}
 		case EFsEmailUiCmdSync:
         case EFsEmailUiCmdSyncAll:
 			{
-			if (aCommand == EFsEmailUiCmdSyncAll) 
+			if (aCommand == EFsEmailUiCmdSyncAll)
 				{
 			   	iAppUi.ManualMailBoxSyncAll(ETrue);
 				}
@@ -899,7 +898,7 @@
 			    }
             RPointerArray<CFSMailBox> mailBoxes;
             CleanupResetAndDestroyClosePushL( mailBoxes );
-            TFSMailMsgId id; 
+            TFSMailMsgId id;
             TInt err = iAppUi.GetMailClient()->ListMailBoxes(
                 id,
                 mailBoxes );
@@ -907,9 +906,7 @@
             for ( TInt i = 0; i < mailBoxes.Count(); i++ )
                 {
                 iAppUi.SubscribeMailboxL( mailBoxes[i]->GetId() );
-                // <cmail> 
                 mailBoxes[i]->GetMailBoxStatus();
-                // </cmail>
                 mailBoxes[i]->RefreshNowL( iAppUi );
                 }
 
@@ -920,7 +917,7 @@
 			{
             RPointerArray<CFSMailBox> mailBoxes;
             CleanupResetAndDestroyClosePushL( mailBoxes );
-            TFSMailMsgId id; 
+            TFSMailMsgId id;
             TInt err = iAppUi.GetMailClient()->ListMailBoxes(
                 id,
                 mailBoxes );
@@ -938,13 +935,13 @@
 		case EFsEmailUiCmdGoOffline:
         case EFsEmailUiCmdGoOfflineAll:
 			{
-            if (aCommand == EFsEmailUiCmdGoOfflineAll) 
+            if (aCommand == EFsEmailUiCmdGoOfflineAll)
             	{
                 iAppUi.ManualMailBoxDisconnectAll(ETrue);
             	}
             RPointerArray<CFSMailBox> mailBoxes;
             CleanupResetAndDestroyClosePushL( mailBoxes );
-            TFSMailMsgId id; 
+            TFSMailMsgId id;
             TInt err = iAppUi.GetMailClient()->ListMailBoxes(
                 id,
                 mailBoxes );
@@ -961,7 +958,7 @@
 		case EFsEmailUiCmdGoOnline:
         case EFsEmailUiCmdGoOnlineAll:
 			{
-            if (aCommand == EFsEmailUiCmdGoOnlineAll) 
+            if (aCommand == EFsEmailUiCmdGoOnlineAll)
             	{
                	iAppUi.ManualMailBoxConnectAll(ETrue);
             	}
@@ -983,7 +980,7 @@
             break;
        	case EFsEmailUiCmdAbout:
 			{
-			DisplayProductInfoL();	
+			DisplayProductInfoL();
 			}
 			break;
        	case EFsEmailUiCmdHelp:
@@ -991,9 +988,14 @@
             TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID );
 			}
 			break;
-        // <cmail>
+       	case KErrCancel:
+       		{
+        	// The pop-up menu was closed. Hide the focus.
+            iAppUi.SetFocusVisibility( EFalse );
+            HandleButtonReleaseEvent(); // Finishes the focus removal.
+       		break;
+       		}
         case EFsEmailUiCmdHide:
-        // </cmail>
         case EEikCmdExit:
         case EAknSoftkeyExit:
         case EFsEmailUiCmdExit:
@@ -1003,21 +1005,21 @@
             break;
         default:
             break;
-        }
+        } // switch ( aCommand )
     }
- 
+
 TBool CFSEmailUiLauncherGridVisualiser::OfferEventL(const TAlfEvent& aEvent)
     {
     FUNC_LOG;
     if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey )
-        {       
+        {
         // If wait note is being shown while a mailbox is being created,
         // then do not react to key presses.
         if ( iWizardWaitnoteShown )
             {
             return ETrue; // key consumed
             }
-        
+
         // Swap right and left controls in mirrored layout
         TInt scanCode = aEvent.KeyEvent().iScanCode;
         if ( AknLayoutUtils::LayoutMirrored() )
@@ -1025,17 +1027,17 @@
             if (scanCode == EStdKeyRightArrow) scanCode = EStdKeyLeftArrow;
             else if (scanCode == EStdKeyLeftArrow ) scanCode = EStdKeyRightArrow;
             }
-        
-        if ((scanCode == EStdKeyRightArrow) 
-        		|| (scanCode == EStdKeyLeftArrow) 
-        		|| (scanCode == EStdKeyUpArrow) 
+
+        if ((scanCode == EStdKeyRightArrow)
+        		|| (scanCode == EStdKeyLeftArrow)
+        		|| (scanCode == EStdKeyUpArrow)
         		|| (scanCode == EStdKeyDownArrow)
         		|| (scanCode == EStdKeyEnter)
         		|| (scanCode == EStdKeyDeviceA)
         		|| (scanCode ==EStdKeyDevice3))
         	{
-			TBool wasActive = iAppUi.StartFocusRemovalTimer();
-        	if (!wasActive)
+
+        	if ( !iAppUi.SetFocusVisibility( ETrue ) )
         		{
 				// focus is now activated. ignore key press.
 				UpdateFocusVisibility();
@@ -1043,7 +1045,7 @@
 				return ETrue;
         		}
         	}
-                
+
         switch(scanCode)
             {
             case EStdKeyRightArrow:
@@ -1062,11 +1064,11 @@
             case EStdKeyDeviceA:
             case EStdKeyDevice3:
             	HandleButtonReleaseEvent();
-                SelectL();                
+                SelectL();
                 return ETrue;
             default:
 	       	    // Check keyboard shortcuts.
-	       	    TInt shortcutCommand = 
+	       	    TInt shortcutCommand =
 	       	        iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(),
 	       	                                                         CFSEmailUiShortcutBinding::EContextMainGrid );
 	       	    if ( shortcutCommand != KErrNotFound )
@@ -1080,45 +1082,55 @@
     return EFalse; // was not consumed
     }
 
-// <cmail>
+
 // ---------------------------------------------------------------------------
 // CFSEmailUiLauncherGridVisualiser::HandlePointerEventL
 //
 // ---------------------------------------------------------------------------
-//      
-TBool CFSEmailUiLauncherGridVisualiser::HandlePointerEventL(const TAlfEvent& aEvent)
+//
+TBool CFSEmailUiLauncherGridVisualiser::HandlePointerEventL(
+	const TAlfEvent& aEvent )
     {
     FUNC_LOG;
     TBool result( EFalse );
     TInt currentlyFocused( iCurrentLevel.iSelected );
     TPointerEvent::TType type = aEvent.PointerEvent().iType;
     TInt id = FindPointedItem( aEvent );
+
     if( KErrNotFound != id )
         {
+        // The event coordinates correspond with an item.
         switch( type )
             {
             case TPointerEvent::EButton1Down:
                 {
                 iItemIdInButtonDownEvent.iItemId = id;
                 iItemIdInButtonDownEvent.iLaunchSelection = ETrue;
-				UpdateFocusVisibility();
-				
                 SetFocusedItemL( id );
+                UpdateFocusVisibility();
                 break;
                 }
             case TPointerEvent::EButton1Up:
                 {
+                if ( iStylusPopUpMenuLaunched )
+                	{
+                	// A pop-up menu was launched. Do not open the selected
+                	// item.
+                	iStylusPopUpMenuLaunched = EFalse;
+                	break;
+                	}
+
+                // Hide focus always after pointer up event.
+                iAppUi.SetFocusVisibility( EFalse );
+
                 // If key was released on item that had focus
                 // trigger selection.
                 if( iItemIdInButtonDownEvent.iItemId == id &&
                     iItemIdInButtonDownEvent.iLaunchSelection )
                     {
-                    // keyboard focus is now hidden 
-                    iAppUi.CancelFocusRemovalTimer();
-
                     HandleButtonReleaseEvent();
-
-                    // LAUNCH OPENING. This may leave if user cancels the operation
+                    // LAUNCH OPENING. This may leave if user cancels the
+                    // operation
                     SelectL();
                     }
                 else
@@ -1146,11 +1158,28 @@
                     }
                 break;
                 }
+            case TPointerEvent::EButtonRepeat:
+            	{
+            	// Long tap.
+            	// Check the type of the currently selected item.
+    			TInt itemType = iCurrentLevel.iItems[id].iId;
+
+				if ( itemType == EDefaultMailboxItem ||
+					 itemType == EOtherMailboxItems )
+    				{
+    				// The selected item is a mail box. Launch the pop-up
+    				// menu.
+    	            LaunchStylusPopupMenu( id );
+    				}
+
+            	break;
+            	}
             default:
                 {
                 break;
                 }
             }
+
         result = ETrue;
         }
     // if event do not concern any of items.
@@ -1158,6 +1187,7 @@
         {
         iItemIdInButtonDownEvent.iLaunchSelection = EFalse;
         ResizeItemIcon( ETrue );
+
         switch( type )
             {
             case TPointerEvent::EButton1Down:
@@ -1168,6 +1198,8 @@
                 }
             case TPointerEvent::EButton1Up:
                 {
+                // Hide focus always after pointer up event.
+                iAppUi.SetFocusVisibility( EFalse );
                 iItemIdInButtonDownEvent.iItemId = KErrNotFound;
                 HandleButtonReleaseEvent();
                 break;
@@ -1178,6 +1210,15 @@
                 }
             }
         }
+    else
+        {
+        if( aEvent.IsPointerEvent() && aEvent.PointerUp() )
+            {
+            // Hide focus always after pointer up event.
+            iAppUi.SetFocusVisibility( EFalse );
+            }
+        }
+
     return result;
     }
 
@@ -1185,24 +1226,24 @@
 // CFSEmailUiLauncherGridVisualiser::FindPointedItem
 //
 // ---------------------------------------------------------------------------
-//      
+//
 TInt CFSEmailUiLauncherGridVisualiser::FindPointedItem( const TAlfEvent& aEvent )
     {
     FUNC_LOG;
-    TInt result = KErrNotFound; 
-            
-    TInt count = iCurrentLevel.iItemVisualData.Count();         
+    TInt result = KErrNotFound;
+
+    TInt count = iCurrentLevel.iItemVisualData.Count();
     const TPoint pos = aEvent.PointerEvent().iParentPosition;
-    
+
     for(TInt a = 0; count > a; a++)
         {
-        const TRect rect(iCurrentLevel.iItemVisualData[a].iBase->DisplayRect());                 
+        const TRect rect(iCurrentLevel.iItemVisualData[a].iBase->DisplayRect());
         if(rect.Contains( pos ))
             {
             result = a;
-            break; 
-            }        
-        }                
+            break;
+            }
+        }
     return result;
     }
 
@@ -1210,16 +1251,15 @@
 // CFSEmailUiLauncherGridVisualiser::SetFocusedItemL
 //
 // ---------------------------------------------------------------------------
-//      
+//
 void CFSEmailUiLauncherGridVisualiser::SetFocusedItemL( TInt aId )
     {
     FUNC_LOG;
     TInt oldSelection = iCurrentLevel.iSelected;
-    
+
     HandleRowMovement( EDirectionTouch, aId );
-    
-    FocusItem( EFalse, oldSelection );             
-//    iCurrentLevel.iSelected = aId; 
+
+    FocusItem( EFalse, oldSelection );
     FocusItem( ETrue, iCurrentLevel.iSelected );
     MoveSelectorToCurrentItem( EDirectionTouch );
     }
@@ -1229,11 +1269,11 @@
     FUNC_LOG;
     // NULL double click flag just be sure that the UI does not
     // go into state that wizard cannot be started.
-    iDoubleClickLock = EFalse; 
+    iDoubleClickLock = EFalse;
     // Store old selection
     TInt oldSelection = iCurrentLevel.iSelected;
     TInt itemCount = iCurrentLevel.iItemVisualData.Count();
-    
+
     HandleRowMovement( aDir, iCurrentLevel.iSelected );
 
     // Set the correct icon focuses (i.e. enlarged)
@@ -1253,7 +1293,7 @@
     FUNC_LOG;
     // NULL double click flag just be sure that the UI does not
     // go into state that wizard cannot be started.
-    iDoubleClickLock = EFalse; 
+    iDoubleClickLock = EFalse;
     // Store old selection
     TInt oldSelection = iCurrentLevel.iSelected;
     TInt itemCount = iCurrentLevel.iItemVisualData.Count();
@@ -1291,7 +1331,7 @@
                 if ( iCurrentLevel.iSelected < 0 )
                     {
                     iCurrentLevel.iSelected += (iRowCount*iVisibleColumns);
-                    if ( iCurrentLevel.iSelected >= itemCount ) 
+                    if ( iCurrentLevel.iSelected >= itemCount )
                         {
                         // Wrapping is about to move the cursor on empty spot.
                         // To be consistent with S60 app grid, move selection to the last item.
@@ -1321,11 +1361,11 @@
 
             case EDirectionNone:
                 break;
-                
+
             case EDirectionTouch:
-                iCurrentLevel.iSelected = aSelected; 
+                iCurrentLevel.iSelected = aSelected;
                 break;
-                            
+
             }
 
         if ( iCurrentLevel.iSelected < 0 )
@@ -1344,7 +1384,7 @@
     ScrollToRow( y );
 
     }
-// </cmail>
+
 
 void CFSEmailUiLauncherGridVisualiser::MoveSelectorToCurrentItem( TDirection aDir )
     {
@@ -1363,7 +1403,7 @@
     TPoint ringWrapOffset( 0, 0 );
     const TInt KGridWrapWidth = (iVisibleColumns+2)*iColumnWidth;
     const TInt KGridWrapHeight = (iRowCount+2)*iRowHeight;
-    
+
     if ( aDir == EDirectionRight && ( targetPos.iX <= curPos.iX || iCurrentLevel.iSelected == 0 ) )
         {
         ringWrapOffset.iX = KGridWrapWidth;
@@ -1402,7 +1442,7 @@
         // Invalid item index
         return;
         }
-    
+
     if( aHasFocus && ( IsFocusShown() || iItemIdInButtonDownEvent.iItemId >= 0 ) )
         {
         TAlfTimedValue scaleValue;
@@ -1458,7 +1498,7 @@
 
 
     offset = iFirstVisibleRow * iRowHeight;
-    
+
     TAlfTimedPoint alfScrollOffset;
     alfScrollOffset.iY.SetTarget( offset , KScrollTransitionTimeMs );
     iCurrentLevel.iGridLayout->SetScrollOffset(alfScrollOffset);
@@ -1466,7 +1506,7 @@
     iScrollbarModel.SetFocusPosition(iFirstVisibleRow);
     TRAP_IGNORE( iScrollbar->SetModelL(&iScrollbarModel) );
     iScrollbar->DrawNow();
-// </cmail>    
+// </cmail>
     }
 
 void CFSEmailUiLauncherGridVisualiser::RefreshLauncherViewL()
@@ -1489,13 +1529,13 @@
             FocusItem( ETrue, iCurrentLevel.iSelected );
             }
         UpdateScrollBarRangeL();
-        }  
+        }
     }
 
 TBool CFSEmailUiLauncherGridVisualiser::UiOperationLaunched()
     {
     FUNC_LOG;
-    return iUiOperationLaunched;  
+    return iUiOperationLaunched;
     }
 
 void CFSEmailUiLauncherGridVisualiser::PopulateL( TLevel& aLevel )
@@ -1506,30 +1546,30 @@
         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    
+
+// <cmail> Use layout data instead of hard-coded values
 	    TRect mainPaneRect;
 	    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
-	    
+
 	    TAknLayoutRect scrollBarRect;
 	    scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar());
 	    TRect gridRect = mainPaneRect;
 	    gridRect.iBr.iX -= scrollBarRect.Rect().Width();
-	    
+
 	    TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
-	    
+
 	    TAknLayoutRect itemRect;
 	    itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var, 0, 0));
 
 	    TRect itemrc = itemRect.Rect();
 	    itemrc.SetRect(TPoint(0,0), itemRect.Rect().Size());
-	    
+
 	    TAknLayoutRect gridIconRect;
 	    gridIconRect.LayoutRect(itemrc, AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var));
-	    
+
 	    TAknLayoutText gridText;
 	    gridText.LayoutText(itemrc, AknLayoutScalable_Apps::cell_cmail_l_pane_t1(var));
 // </cmail>
@@ -1537,7 +1577,7 @@
         if( aLevel.iParent >= 0 )
             {
             iModel->FindChildren( aLevel.iParent, aLevel.iItems );
-            
+
             for( TInt i = 0; i < aLevel.iItems.Count(); i++ )
                 {
                 TItemVisualData newItem;
@@ -1545,7 +1585,7 @@
                 newItem.iBase = CAlfAnchorLayout::AddNewL( *iControl, aLevel.iGridLayout );
                 newItem.iBase->SetTactileFeedbackL( ETouchEventStylusDown,  ETouchFeedbackBasic );
 
-// <cmail> Use layout data instead of hard-coded values    
+// <cmail> Use layout data instead of hard-coded values
                 // Set anchors for text
                 newItem.iBase->SetAnchor(
                     EAlfAnchorTopLeft,
@@ -1589,20 +1629,20 @@
 				TRgb itemColor (KRgbGray);
 			    // text #9 application grid unfocused application title texts #215
 				if( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
-					itemColor, KAknsIIDQsnTextColors, 
+					itemColor, KAknsIIDQsnTextColors,
 					EAknsCIQsnTextColorsCG9 ) != KErrNone )
 					{
-				itemColor = gridText.Color();//iAppUi.LayoutHandler()->ListNormalStateTextSkinColor(); 
+				itemColor = gridText.Color();//iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
 					}
 				newItem.iText->SetColor(itemColor);
 // </cmail>
-					
-                newItem.iText->SetTextL( *aLevel.iItems[i].iCaption );      
-                
+
+                newItem.iText->SetTextL( *aLevel.iItems[i].iCaption );
+
                 TAlfTimedValue opacity;
                 opacity.SetValueNow ( KDefaultCaptionOpacity );
                 newItem.iText->SetOpacity( opacity );
-                
+
                 newItem.iText->SetTextStyle( iAppUi.LayoutHandler()->FSTextStyleFromLayoutL(AknLayoutScalable_Apps::cell_cmail_l_pane_t1(var)).Id() );//FSTextStyleFromIdL( EFSFontTypeSmall )->Id() );
                 newItem.iText->SetWrapping( CAlfTextVisual::ELineWrapTruncate );
                 newItem.iText->SetAlign( EAlfAlignHCenter, EAlfAlignVTop );
@@ -1612,7 +1652,7 @@
                 newItem.iImage->SetImage( TAlfImage( *aLevel.iItems[i].iIconTexture ) );
                 newItem.iImage->SetFlag( EAlfVisualFlagManualSize );
 
-// <cmail> Use layout data instead of hard-coded values  
+// <cmail> Use layout data instead of hard-coded values
                 newItem.iImage->SetSize( gridIconRect.Rect().Size() );
                 newItem.iImage->SetScale( KScaleNotSelected );
 // </cmail>
@@ -1621,7 +1661,7 @@
                 }
             }
 
-// <cmail> Use layout data instead of hard-coded values  
+// <cmail> Use layout data instead of hard-coded values
         // Set columns and rows
         //iVisibleColumns = iAppUi.LayoutHandler()->GridColumnsInThisResolution();
         //iVisibleRows = iAppUi.LayoutHandler()->GridRowsInThisResolution();
@@ -1641,7 +1681,7 @@
 		{
         iItemIdInButtonDownEvent.iItemId = KErrNotFound;
         UpdateFocusVisibility();
-	
+
 		CFSEmailLauncherItem* launcherItem =
 		    iCurrentLevel.iItems[iCurrentLevel.iSelected].iLauncherItem;
 		if ( launcherItem )
@@ -1657,12 +1697,12 @@
 				case EOtherMailboxItems:
 					{
 					TMailListActivationData tmp;
-					tmp.iFolderId = iCurrentLevel.iItems[iCurrentLevel.iSelected].iMailBoxInboxId; 
-					tmp.iMailBoxId = iCurrentLevel.iItems[iCurrentLevel.iSelected].iMailBoxId; 
+					tmp.iFolderId = iCurrentLevel.iItems[iCurrentLevel.iSelected].iMailBoxInboxId;
+					tmp.iMailBoxId = iCurrentLevel.iItems[iCurrentLevel.iSelected].iMailBoxId;
 					const TPckgBuf<TMailListActivationData> pkgOut( tmp );
 					iAppUi.ShowTitlePaneConnectionStatus();
 					iAppUi.EnterFsEmailViewL( MailListId, KStartListWithFolderId, pkgOut );
-					}				
+					}
 					break;
 				case EDirectoryItem:
 				    {
@@ -1671,14 +1711,14 @@
                     if ( !iDoubleClickLock )
                         {
                         // Lock to make sure that wizard is not started twice in a row
-                        iDoubleClickLock = ETrue; 
+                        iDoubleClickLock = ETrue;
                         RPointerArray<CFSMailBox> mailBoxes;
                         CleanupResetAndDestroyClosePushL( mailBoxes );
-                        TFSMailMsgId id; 
+                        TFSMailMsgId id;
                         TInt err = iAppUi.GetMailClient()->ListMailBoxes(
                             id,
                             mailBoxes );
-                        
+
                         // Remove mailboxes that doesn't support RCL
                         for ( TInt i = mailBoxes.Count()-1; i >= 0 ; i-- )
                             {
@@ -1705,9 +1745,9 @@
                         if ( mailBox )
                             {
                             CFsDelayedLoader::InstanceL()->GetContactHandlerL()->LaunchRemoteLookupL( *mailBox );
-                            }                    
+                            }
                         iDoubleClickLock = EFalse;
-                        CleanupStack::PopAndDestroy( &mailBoxes );                  
+                        CleanupStack::PopAndDestroy( &mailBoxes );
                         }
 				    }
 					break;
@@ -1715,7 +1755,7 @@
 	                {
 	                TInt tmp = 0;
 	                const TPckgBuf<TInt> pkgBuf( tmp );
-	      			iAppUi.EnterFsEmailViewL(  
+	      			iAppUi.EnterFsEmailViewL(
 	      					SettingsViewId,
 	      					TUid::Uid(KMailSettingsOpenMainList),
 	      					pkgBuf );
@@ -1727,7 +1767,7 @@
 	                // wizard would crash without this
 	                if ( !iDoubleClickLock )
 	                    {
-	                    iDoubleClickLock = ETrue; 
+	                    iDoubleClickLock = ETrue;
 	                    LaunchWizardL();
     	                }
 	                }
@@ -1744,9 +1784,9 @@
 	                }
 	            	break;
 				default:
-					return;	
+					return;
 				}
-		    }		
+		    }
 		}
 	}
 
@@ -1760,7 +1800,7 @@
     // Toggle safety lock always when receiving foreground back.
     if ( iFirstStartComplete && iDoubleClickLock )
         {
-        iDoubleClickLock = EFalse;        
+        iDoubleClickLock = EFalse;
         }
     }
 
@@ -1788,10 +1828,10 @@
     TInt selectedOption;
     CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &selectedOption );
     dlg->PrepareLC( R_FSEMAILUI_LAUNCHER_GRID_MAILBOX_SELECTION_DIALOG  );
-    
+
     dlg->SetItemTextArray( array );
     dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
-    
+
     CFSMailBox* mailbox = NULL;
     if( dlg->RunLD() )
         {
@@ -1802,7 +1842,7 @@
             mailbox = aMailBoxes[selectedOption];
             }
         }
-    
+
     CleanupStack::PopAndDestroy( array );
     return mailbox;
     }
@@ -1825,20 +1865,20 @@
         }
 
     iAiwSHandler->ExecuteServiceCmdL( KAiwCmdSettingWizardFsEmail.iUid,
-                                      iAiwSHandler->InParamListL(), 
+                                      iAiwSHandler->InParamListL(),
                                       iAiwSHandler->OutParamListL() );
     }
 
 void CFSEmailUiLauncherGridVisualiser::GoToInboxL( TFSMailMsgId& aMailboxId, TFSMailMsgId& aMailboxInboxId )
     {
     FUNC_LOG;
-	TMailListActivationData tmp;	
-	
+	TMailListActivationData tmp;
+
 	tmp.iMailBoxId = aMailboxId;
 	tmp.iFolderId = aMailboxInboxId;
-		
-	const TPckgBuf<TMailListActivationData> pkgOut( tmp );	
-	
+
+	const TPckgBuf<TMailListActivationData> pkgOut( tmp );
+
 	iAppUi.EnterFsEmailViewL( MailListId, KStartListWithFolderId, pkgOut );
     }
 
@@ -1851,23 +1891,23 @@
 		TRect mainPaneRect;
 	    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
 	    TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
-	    
+
 	    TAknLayoutRect scrollBarRect;
 	    scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar());
 	    TRect gridRect = mainPaneRect;
 	    gridRect.iBr.iX -= scrollBarRect.Rect().Width();
-	    
+
 	    TAknLayoutRect itemRect;
 	    itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var, 0, 0));
-	    
+
 	    TAknLayoutRect gridIconRect;
 	    gridIconRect.LayoutRect(itemRect.Rect(), AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var));
-		
+
 	   	//TInt gridIconSize = iAppUi.LayoutHandler()->GridIconSize();
 		TSize iconSize = gridIconRect.Rect().Size();
 		//iconSize.SetSize( gridIconSize, gridIconSize );
 	// </cmail>
-		
+
         // Scale bitmaps
         for( TInt i = 0 ; i < iIconArray.Count() ; i++ )
             {
@@ -1877,7 +1917,7 @@
         for ( TInt item = 0; item < iCurrentLevel.iItemVisualData.Count() ; item++ )
             {
             iCurrentLevel.iItemVisualData[item].iImage->SetSize( iconSize );
-            }        
+            }
         }
 	}
 
@@ -1894,61 +1934,61 @@
 // <cmail> Use layout data instead of hard-coded values
             TRect mainPaneRect;
             AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
-            
+
             TAknLayoutRect scrollBarRect;
             scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar());
             TRect gridRect = mainPaneRect;
             gridRect.iBr.iX -= scrollBarRect.Rect().Width();
-            
+
             TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
-            
+
             TAknLayoutRect itemRect;
             itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var, 0, 0));
-            
+
             TAknLayoutRect gridIconRect;
             gridIconRect.LayoutRect(itemRect.Rect(), AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var));
-            
+
             TSize iconSize = gridIconRect.Rect().Size();
 // </cmail>
-               
+
             const CFbsBitmap* bitmap = launcherItemIcon->Bitmap();
-            const CFbsBitmap* mask = launcherItemIcon->Mask();    
+            const CFbsBitmap* mask = launcherItemIcon->Mask();
 
 			// First add plugin id and icon id pair to array, needed in provide bitmap
 			TPluginIdIconIdPair idPair;
 			idPair.iPluginArrayIndex = aPluginArrayIndex;
-			idPair.iIconId = iPluginTextureId;	
-			iPluginIdIconIdPairs.Append( idPair );	
+			idPair.iIconId = iPluginTextureId;
+			iPluginIdIconIdPairs.Append( idPair );
 
 			// Create texture, goes to provide bitmap
-			CAlfTexture* texture = &CAlfStatic::Env().TextureManager().CreateTextureL( iPluginTextureId, this, EAlfTextureFlagDefault );		
-			// Update texture id 
-			iPluginTextureId++; // Id is updated dynamically					
+			CAlfTexture* texture = &CAlfStatic::Env().TextureManager().CreateTextureL( iPluginTextureId, this, EAlfTextureFlagDefault );
+			// Update texture id
+			iPluginTextureId++; // Id is updated dynamically
 			// Set initiel size
 // <cmail> Use layout data instead of hard-coded values
 			//TSize iconSize(iAppUi.LayoutHandler()->GridIconSize(), iAppUi.LayoutHandler()->GridIconSize() );
 // <cmail>
-  			texture->Size().SetSize( iconSize.iHeight, iconSize.iWidth );  
+  			texture->Size().SetSize( iconSize.iHeight, iconSize.iWidth );
            iModel->AddL(
                 EShortcut,
                 aItem->Id(),
                 *launcherItemText,
                 *texture,
                 0,
-                aItem );        
-	        iIconArray.AppendL( texture ); 
+                aItem );
+	        iIconArray.AppendL( texture );
             }
         else
             {
             CAlfTexture* texture = &iAppUi.FsTextureManager()->TextureByIndex( EGridInboxTexture );
-            
+
             iModel->AddL(
                 EShortcut,
                 aItem->Id(),
                 *launcherItemText,
                 *texture,
                 0,
-                aItem );         
+                aItem );
             iIconArray.AppendL( texture );
             }
 
@@ -1962,12 +2002,12 @@
     if ( iConstructionCompleted )
         {
 	    iCurrentLevel.iParent = 0;
-	    
+
 	// <cmail> Use layout data instead of hard-coded values
 	    TRect mainPaneRect;
 	    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
 	    TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
-	    
+
 	    TAknLayoutRect scrollBarRect;
 	    // <cmail>
 //	    scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar());
@@ -1975,16 +2015,16 @@
 	    // </cmail>
 	    TRect gridRect = mainPaneRect;
 	    gridRect.iBr.iX -= scrollBarRect.Rect().Width();
-	    
+
 	    TAknLayoutRect cellRect;
 	    cellRect.LayoutRect(gridRect, AknLayoutScalable_Apps::aid_size_cell_cmail_l(var, 0, 0));
-	    
+
 	    TAknLayoutRect itemRect;
 	    itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var, 0, 0));
-	    
+
 	    TAknLayoutRect gridIconRect;
 	    gridIconRect.LayoutRect(itemRect.Rect(), AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var));
-	    
+
 	    TAknLayoutRect selectorRect;
 	    selectorRect.LayoutRect(itemRect.Rect(), AknLayoutScalable_Apps::grid_highlight_pane_cp018(var));
 
@@ -1992,10 +2032,10 @@
 	    iSelectorImageVisual->SetSize( selectorRect.Rect().Size() ); // layoutHandler->SelectorVisualSizeInThisResolution() );
 
 	    TSize displaySize = mainPaneRect.Size();//iControl->DisplayArea().Size();
-	    
+
 	    TInt columns = iVisibleColumns = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastColumn() + 1; //layoutHandler->GridColumnsInThisResolution();
 	    TInt rows = iVisibleRows = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastRow() + 1; //layoutHandler->GridRowsInThisResolution();
-	    
+
 	// </cmail>
 
         iCurrentLevel.iGridLayout->SetSize( gridRect.Size() );
@@ -2016,7 +2056,7 @@
             iScrollbar->MakeVisible(EFalse);
             }
         // </cmail>
-	    
+
         TInt scrollbarTopLeftX = displaySize.iWidth - scrollbarWidth;
         TInt scrollbarTopLeftY = 0;
         TInt scrollbarBottomRightX = displaySize.iWidth;
@@ -2050,17 +2090,17 @@
             TAlfTimedPoint( scrollbarTopLeftX, scrollbarTopLeftY ) );
         iWidgetLayout->SetAnchor(
             EAlfAnchorBottomRight,
-            0, 
+            0,
             EAlfAnchorOriginLeft,
             EAlfAnchorOriginTop,
             EAlfAnchorMetricAbsolute,
             EAlfAnchorMetricAbsolute,
             TAlfTimedPoint( scrollbarBottomRightX, scrollbarBottomRightY ) );
-          
+
         // Set anchors for the grid
         iWidgetLayout->SetAnchor(
             EAlfAnchorTopLeft,
-            1, 
+            1,
             EAlfAnchorOriginLeft,
             EAlfAnchorOriginTop,
             EAlfAnchorMetricAbsolute,
@@ -2068,7 +2108,7 @@
             TAlfTimedPoint( gridTopLeftX, gridTopLeftY ) );
         iWidgetLayout->SetAnchor(
             EAlfAnchorBottomRight,
-            1, 
+            1,
             EAlfAnchorOriginLeft,
             EAlfAnchorOriginTop,
             EAlfAnchorMetricAbsolute,
@@ -2076,9 +2116,9 @@
             TAlfTimedPoint( gridBottomRightX, gridBottomRightY ) );
 
         iParentLayout->UpdateChildrenLayout();
-          
+
         TSize gridSize = iCurrentLevel.iGridLayout->Size().IntTarget().AsSize();
-        iColumnWidth = gridSize.iWidth / iVisibleColumns; 
+        iColumnWidth = gridSize.iWidth / iVisibleColumns;
         iRowHeight = gridSize.iHeight / iVisibleRows;
 
         // Selector ring wrap limits can be calculated when row and column sizes are known.
@@ -2104,9 +2144,9 @@
         iRingMovementXFuncMappingDataProvider.SetEnd((iVisibleColumns+1)*iColumnWidth);
         iRingMovementYFuncMappingDataProvider.SetStart(-iRowHeight);
         iRingMovementYFuncMappingDataProvider.SetEnd((iRowCount+1)*iRowHeight);
-        
+
         iRingMovementXFunc->SetMappingTableValues( -(iVisibleColumns+2)*iColumnWidth, (iVisibleColumns*2+2)*iColumnWidth, &iRingMovementXFuncMappingDataProvider );
-        iRingMovementYFunc->SetMappingTableValues( -(iRowCount+2)*iRowHeight, (iRowCount*2+2)*iRowHeight, &iRingMovementYFuncMappingDataProvider );      
+        iRingMovementYFunc->SetMappingTableValues( -(iRowCount+2)*iRowHeight, (iRowCount*2+2)*iRowHeight, &iRingMovementYFuncMappingDataProvider );
         }
     }
 
@@ -2123,13 +2163,13 @@
     HBufC* text_7 = StringLoader::LoadLC( R_DISCLAIMER_PART_7 );
     HBufC* text_8 = StringLoader::LoadLC( R_DISCLAIMER_PART_8 );
     HBufC* text_9 = StringLoader::LoadLC( R_DISCLAIMER_PART_9 );
-    HBufC* text_10 = StringLoader::LoadLC( R_DISCLAIMER_PART_10 );    
+    HBufC* text_10 = StringLoader::LoadLC( R_DISCLAIMER_PART_10 );
     HBufC* text_11 = StringLoader::LoadLC( R_DISCLAIMER_PART_11 );
-    
+
     //Create a buffer for dialog content
-    HBufC* text = HBufC::NewLC( text_1->Length() + text_2->Length() + text_3->Length() + 
-                                text_4->Length() + text_5->Length() + text_6->Length() + 
-                                text_7->Length() + text_8->Length() + text_9->Length() + 
+    HBufC* text = HBufC::NewLC( text_1->Length() + text_2->Length() + text_3->Length() +
+                                text_4->Length() + text_5->Length() + text_6->Length() +
+                                text_7->Length() + text_8->Length() + text_9->Length() +
                                 text_10->Length() + text_11->Length() );
     //Copy the disclaimer text parts to dialog content
     text->Des() += *text_1;
@@ -2142,8 +2182,8 @@
     text->Des() += *text_8;
     text->Des() += *text_9;
     text->Des() += *text_10;
-    text->Des() += *text_11;    
-    
+    text->Des() += *text_11;
+
     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *text );
     CleanupStack::PopAndDestroy( text );
     CleanupStack::PopAndDestroy( text_11 );
@@ -2158,21 +2198,21 @@
     CleanupStack::PopAndDestroy( text_2 );
     CleanupStack::PopAndDestroy( text_1 );
     dlg->PrepareLC( R_DISCLAIMER_MESSAGE );
-    
+
     //Create heading for the dialog, load and create the heading text
     CAknPopupHeadingPane* headingPane = dlg->Heading();
     HBufC* appName = StringLoader::LoadLC(R_FSEMAIL_APP_NAME );
     HBufC* version = StringLoader::LoadLC( R_DISCLAIMER_FSEMAIL_VERSION );
     HBufC* title = HBufC::NewLC(version->Length() + appName->Length() + 1);
-    title->Des() += *appName;    
+    title->Des() += *appName;
     title->Des() += KSpace;
     title->Des() += *version;
     headingPane->SetTextL( *title );
     CleanupStack::PopAndDestroy( title );
     CleanupStack::PopAndDestroy( version );
-    CleanupStack::PopAndDestroy( appName );  
+    CleanupStack::PopAndDestroy( appName );
     dlg->ButtonGroupContainer().SetCommandSetL( R_AVKON_SOFTKEYS_OK_EMPTY );
-    //show dialog  
+    //show dialog
     TInt ret = dlg->RunLD();
 	}
 
@@ -2185,25 +2225,23 @@
     if ( iConstructionCompleted )
         {
         iItemIdInButtonDownEvent.iItemId = KErrNotFound;
-    
-	// <cmail> Use layout data instead of hard-coded values
+
 	    TRect mainPaneRect;
 	    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
 	    TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
-	    
+
 	    TAknLayoutRect scrollBarRect;
 	    scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar());
 	    TRect gridRect = mainPaneRect;
 	    gridRect.iBr.iX -= scrollBarRect.Rect().Width();
-	    
+
 	    TAknLayoutRect cellRect;
 	    cellRect.LayoutRect(gridRect, AknLayoutScalable_Apps::aid_size_cell_cmail_l(var, 0, 0));
-	    
+
 		TSize displaySize = cellRect.Rect().Size();
-	// </cmail>
         iParentLayout->SetSize( displaySize );
-        RescaleIconsL(); 
-        VisualLayoutUpdatedL();        
+        RescaleIconsL();
+        VisualLayoutUpdatedL();
 
         UpdateFocusVisibility();
         }
@@ -2213,7 +2251,7 @@
     {
     FUNC_LOG;
     iRefreshNeeded = ETrue;
-    
+
     CFsEmailUiViewBase::HandleDynamicVariantSwitchOnBackgroundL( aType );
     }
 
@@ -2245,7 +2283,7 @@
     TRect scrollbarRect = aParent->DisplayRectTarget();
     scrollbarRect.Move(mainPaneRect.iTl);
     iScrollbar->SetRect(scrollbarRect);
-    
+
     iScrollbar->MakeVisible(EFalse);
     iScrollbar->SetModelL(&iScrollbarModel);
 	}
@@ -2253,7 +2291,7 @@
 void CFSEmailUiLauncherGridVisualiser::UpdateScrollBarRangeL()
 	{
     FUNC_LOG;
-	
+
 	iScrollbarModel.SetScrollSpan(iRowCount);
 	iScrollbarModel.SetWindowSize(iVisibleRows);
 	iScrollbarModel.SetFocusPosition(iFirstVisibleRow);
@@ -2267,7 +2305,7 @@
     const TInt KScrollTransitionTimeMs = KSelectTransitionTimeMs;
     if (aScrollBar == iScrollbar)
          {
-         
+
          switch( aEventType )
              {
              case EEikScrollHome :
@@ -2290,7 +2328,7 @@
 void CFSEmailUiLauncherGridVisualiser::UpdateLauncherItemListL()
     {
     FUNC_LOG;
-    
+
     // Read info about all implementations into infoArray
     RImplInfoPtrArray infoArray;
     CleanupResetAndDestroyClosePushL( infoArray );
@@ -2310,7 +2348,7 @@
     for ( TInt infoIndex = 0; infoIndex < infoCount; infoIndex++ )
         {
         TUid implementationUid = infoArray[infoIndex]->ImplementationUid();
-        
+
         // Check whether item can be found from current laucher items
         TBool itemFound = EFalse;
         for ( TInt itemIndex = 0; itemIndex < iLauncherItemUids.Count(); itemIndex++ )
@@ -2353,7 +2391,7 @@
     CleanupStack::PopAndDestroy( &infoArray );
     }
 
-/** 
+/**
  * Sets application title when leaving this view
  */
 void CFSEmailUiLauncherGridVisualiser::SetDefaultStatusPaneTextL()
@@ -2368,7 +2406,7 @@
     iWizardWaitnoteShown = aWaitnoteShown;
     }
 
-/** 
+/**
  * Check status of all configured mailboxes
  */
 TFSLauncherGridMailboxStatus CFSEmailUiLauncherGridVisualiser::CheckMailboxStatusL()
@@ -2376,7 +2414,7 @@
     FUNC_LOG;
     RPointerArray<CFSMailBox> mailBoxes;
     CleanupResetAndDestroyClosePushL( mailBoxes );
-    TFSMailMsgId id; 
+    TFSMailMsgId id;
     TInt err = iAppUi.GetMailClient()->ListMailBoxes(
         id,
         mailBoxes );
@@ -2385,7 +2423,7 @@
     returnStatus.iMailboxCount = mailBoxes.Count();
     // Reset counters
     returnStatus.iMailboxesOnline = returnStatus.iMailboxesOffline = returnStatus.iMailboxesSyncing = 0;
-    
+
     for ( TInt i = 0; i < mailBoxes.Count(); i++ )
         {
         // First check online/offline status
@@ -2398,7 +2436,7 @@
             {
             returnStatus.iMailboxesOnline++;
             }
-        
+
         // Then check sync state
         TSSMailSyncState latestSyncstate = mailBoxes[i]->CurrentSyncState();
         if( latestSyncstate == InboxSyncing ||
@@ -2408,12 +2446,12 @@
             returnStatus.iMailboxesSyncing++;
             }
         }
-    
+
     CleanupStack::PopAndDestroy( &mailBoxes );
     return returnStatus;
     }
 
-// Bitmap provider for grid ecom plugins icons 
+// Bitmap provider for grid ecom plugins icons
 void CFSEmailUiLauncherGridVisualiser::ProvideBitmapL(TInt aId, CFbsBitmap*& aBitmap, CFbsBitmap*& aMaskBitmap)
 	{
     FUNC_LOG;
@@ -2421,31 +2459,31 @@
     TRect mainPaneRect;
     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
     TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
-    
+
     TAknLayoutRect scrollBarRect;
     scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar());
     TRect gridRect = mainPaneRect;
     gridRect.iBr.iX -= scrollBarRect.Rect().Width();
-    
+
     TAknLayoutRect itemRect;
     itemRect.LayoutRect(gridRect, AknLayoutScalable_Apps::cell_cmail_l_pane(var, 0, 0));
-    
+
     TAknLayoutRect gridIconRect;
     gridIconRect.LayoutRect(itemRect.Rect(), AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var));
-// </cmail> 
-    
-	CAknIcon* launcherItemIcon(0);	
+// </cmail>
+
+	CAknIcon* launcherItemIcon(0);
 	for ( TInt i=0; i<iPluginIdIconIdPairs.Count(); i++ )
 		{
 		if ( aId == iPluginIdIconIdPairs[i].iIconId )
 			{
 			launcherItemIcon = iLauncherItems[iPluginIdIconIdPairs[i].iPluginArrayIndex]->Icon();
-			}		
+			}
 		}
-		
+
 	if ( launcherItemIcon )
 		{
-// <cmail> Use layout data instead of hard-coded values		
+// <cmail> Use layout data instead of hard-coded values
 		// Set bitmap size
 	    //TSize iconSize(iAppUi.LayoutHandler()->GridIconSize(), iAppUi.LayoutHandler()->GridIconSize() );
 
@@ -2460,15 +2498,15 @@
             {
             AknIconUtils::DisableCompression( launcherItemIcon->Mask());
             AknIconUtils::SetSize( launcherItemIcon->Mask(), iconSize, EAspectRatioPreserved );
-            }       
+            }
         // Create duplicate sof original for alf
         CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
-     	bitmap->Duplicate( launcherItemIcon->Bitmap()->Handle() );	    
+     	bitmap->Duplicate( launcherItemIcon->Bitmap()->Handle() );
 	    CFbsBitmap* mask = new (ELeave) CFbsBitmap;
-     	mask->Duplicate( launcherItemIcon->Mask()->Handle() );	    
-	
+     	mask->Duplicate( launcherItemIcon->Mask()->Handle() );
+
         aBitmap = bitmap;
-  		aMaskBitmap = mask; 
+  		aMaskBitmap = mask;
 		}
 	else
 		{
@@ -2483,7 +2521,7 @@
 	iDoubleClickLock = EFalse;
 	}
 
-TReal32 CFSEmailUiLauncherGridVisualiser::TRingMovementFuncMappingDataProvider::MapValue(TReal32 aValue, TInt /*aMode*/) const   
+TReal32 CFSEmailUiLauncherGridVisualiser::TRingMovementFuncMappingDataProvider::MapValue(TReal32 aValue, TInt /*aMode*/) const
     {
     FUNC_LOG;
     AlfUtil::WrapValue(aValue, iStart, iEnd);
@@ -2497,7 +2535,7 @@
         {
         TAlfTimedPoint selectorPos;
         selectorPos.iX.SetMappingFunctionIdentifier( 0 );
-        selectorPos.iY.SetMappingFunctionIdentifier( 0 ); 
+        selectorPos.iY.SetMappingFunctionIdentifier( 0 );
         iSelector->SetPos( selectorPos );
         }
     }
@@ -2507,7 +2545,7 @@
     if( iSelector )
         {
         TAlfTimedValue selectorOpacity;
-        if( IsFocusShown() || iItemIdInButtonDownEvent.iItemId >= 0 ) 
+        if( IsFocusShown() || iItemIdInButtonDownEvent.iItemId >= 0 )
             {
             selectorOpacity.SetValueNow( 1 );
             }
@@ -2527,16 +2565,39 @@
 
 void CFSEmailUiLauncherGridVisualiser::MailboxDeletionComplete()
     {
-    TRAP_IGNORE( HandleContentChangeL() );    
+    TRAP_IGNORE( HandleContentChangeL() );
     }
 
-void CFSEmailUiLauncherGridVisualiser::HandleTimerFocusStateChange( TBool aShow )
+void CFSEmailUiLauncherGridVisualiser::FocusVisibilityChange( TBool aVisible )
+	{
+    CFsEmailUiViewBase::FocusVisibilityChange( aVisible );
+    UpdateFocusVisibility();
+    ResizeItemIcon( !aVisible );
+	}
+
+
+// ----------------------------------------------------------------------------
+// LaunchStylusPopupMenuL()
+// Launches and displays the pop-up menu invoked by a long tap event.
+// ----------------------------------------------------------------------------
+//
+void CFSEmailUiLauncherGridVisualiser::LaunchStylusPopupMenu(
+	const TInt aItemId )
 	{
-    CFsEmailUiViewBase::HandleTimerFocusStateChange( aShow );
-	if (!aShow)
-		{
-		UpdateFocusVisibility();
-		ResizeItemIcon( ETrue );
-		}
+	// Get the ID of the mailbox in case the user wants to delete it.
+	iMailboxToDelete = iCurrentLevel.iItems[aItemId].iMailBoxId;
+
+	// Get the item position and use it to determine the position of the menu.
+	const TRect rect(
+		iCurrentLevel.iItemVisualData[aItemId].iBase->DisplayRect() );
+	TPoint position( rect.iTl.iX + rect.Width() / 2,
+					 rect.iTl.iY + rect.Height() / 2 );
+	iStylusPopUpMenu->SetPosition( position );
+
+	// Display the menu.
+	iStylusPopUpMenu->ShowMenu();
+	iStylusPopUpMenuLaunched = ETrue;
 	}
-// End of file
+
+
+// End of file.
--- a/emailuis/emailui/src/FreestyleEmailUiLayoutHandler.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiLayoutHandler.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -18,29 +18,24 @@
 
 // SYSTEM INCLUDE FILES
 #include "emailtrace.h"
-//#include <aknutils.h> <cmail>
-// <cmail> SF
 #include <alf/alftextstylemanager.h>
 #include <AknsUtils.h>
 #include <AknsSkinInstance.h>
 #include <alf/alfstatic.h>
 
-// <cmail> Platform layout change
 #include <aknlayoutscalable_apps.cdl.h>
 #include <aknlayoutscalable_avkon.cdl.h>
 #include <layoutmetadata.cdl.h>
-// </cmail>
 
 // For generic treelist layout data setting
-//<cmail>
 #include "fstreelist.h"
-//</cmail>
 
 // INTERNAL INCLUDE FILES
 #include "FreestyleEmailUiLayoutHandler.h"
 #include "FreestyleEmailUiLayoutData.h"
 
-// <cmail> Platform layout change
+const TInt KPopupMargin = 8;
+
 template< typename T >
 TUint32 GeneralHash( const T& aValue )
     {
@@ -52,7 +47,6 @@
     {
     return TPckgC< T >( aP1 ) == TPckgC< T >( aP2 );
     }
-// </cmail> Platform layout change
 
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::CFSEmailUiLayoutHandler
@@ -106,10 +100,7 @@
 CFSEmailUiLayoutHandler::~CFSEmailUiLayoutHandler()
     {
     FUNC_LOG;
-// <cmail> Platform layout change
     DeleteTextStyles();
-// </cmail> Platform layout change
-    // <cmail>
     if ( iNormalTextStyle != KErrNotFound )
         {
         CAlfStatic::Env().TextStyleManager().DeleteTextStyle( 
@@ -125,7 +116,6 @@
         CAlfStatic::Env().TextStyleManager().DeleteTextStyle( 
                 iSmallTextStyle );
         }
-    // </cmail>
     }
 
 // -----------------------------------------------------------------------------
@@ -147,29 +137,6 @@
 TScreenOrientation CFSEmailUiLayoutHandler::ScreenOrientation() const
     {
     FUNC_LOG;
-    /*
-    TScreenOrientation orientation = EPortrait;
-    switch ( iScreenResolution )
-        {
-        case ELowResLandscape:
-        case EQvgaLandscape:
-        case EDrLandscape:
-        case EVgaLandscape:
-        case EHvgaLandscape:
-        case EWideLandscape:
-            orientation = ELandscape;
-            break;
-        case ELowResPortrait:
-        case EQvgaPortrait:
-        case EDrPortrait:
-        case EVgaPortrait:
-        case EHvgaPortrait:
-        default:
-            orientation = EPortrait;
-            break;
-        }
-        
-    return orientation;*/
     return Layout_Meta_Data::IsLandscapeOrientation() ? ELandscape : EPortrait;
     }
 
@@ -315,14 +282,6 @@
         {
         textColor = KRgbBlack;
         }
- /*
-    // Should use EAknsCIFsTextColorsCG3 if background is white
-     if ( AknsUtils::GetCachedColor( skin, textColor,
-            KAknsIIDFsTextColors, EAknsCIFsTextColorsCG3 ) != KErrNone )
-        {
-        textColor = KRgbBlack;
-        }
-*/
     return textColor;	
 	}
 
@@ -351,104 +310,16 @@
     gridIconLRect.LayoutRect( itemRect.Rect(), AknLayoutScalable_Apps::cell_cmail_l_pane_g1( 0 ) );
     TSize iconSize = gridIconLRect.Rect().Size();
     return iconSize;
-/*    
-	TInt iconSize(0);
-	switch ( iScreenResolution )
-		{
-		case EQvgaPortrait:
-			iconSize = KGridIconSizeInQvgaPort;
-	 		break;
- 		case EQvgaLandscape:
-			iconSize = KGridIconSizeInQvgaLand;
-		 	break;
- 		case EVgaPortrait:
- 			iconSize = KGridIconSizeInVgaPort;
- 			break;
-		case EVgaLandscape:
-			iconSize = KGridIconSizeInVgaLand;
-			break;
-  		case EHvgaPortrait:
- 			iconSize = KGridIconSizeInHvgaPort;
- 			break;
-		case EHvgaLandscape:
-			iconSize = KGridIconSizeInHvgaLand;
-			break;
- 		case EWideLandscape:
-			iconSize = KGridIconSizeInWideLand;
- 			break;
- 		case EDrPortrait:
-			iconSize = KGridIconSizeInDoubleResPort;
- 			break;
- 		case EDrLandscape:
-		default:
-			iconSize = KGridIconSizeInDoubleResLand;
-			break;
-		}
-	return iconSize;*/
-// </cmail>    
 	}
 
 	
 TSize CFSEmailUiLayoutHandler::MailIconSizeInThisResolution() const
 	{
     FUNC_LOG;
-// <cmail> Use layout data instead of hard-coded values
 	TAknLayoutRect rect;
 	rect.LayoutRect( TRect( 0, 0, 0, 0 ),
 	                AknLayoutScalable_Apps::list_single_dyc_row_pane_g1( 0 ).LayoutLine() );
 	return rect.Rect().Size();
-	/*TSize mailListIconSize(0,0);
-	switch ( iScreenResolution )
-		{
-		case EQvgaPortrait:
-			mailListIconSize = KMailListIconSizeInQvgaPort;
-	 		break;
- 		case EQvgaLandscape:
-			mailListIconSize = KMailListIconSizeInQvgaLand;
-		 	break;
- 		case EVgaPortrait:
- 			mailListIconSize = KMailListIconSizeInVgaPort;
- 			break;
-		case EVgaLandscape:
-			mailListIconSize = KMailListIconSizeInVgaLand;
-			break;
-  		case EHvgaPortrait:
- 			mailListIconSize = KMailListIconSizeInHvgaPort;
- 			break;
-		case EHvgaLandscape:
-			mailListIconSize = KMailListIconSizeInHvgaLand;
-			break;
- 		case EWideLandscape:
-			mailListIconSize = KMailListIconSizeInWideLand;
- 			break;
- 		case EDrPortrait:
-			mailListIconSize = KMailListIconSizeInDoubleResPort;
- 			break;
- 		case EDrLandscape:
-		default:
-			mailListIconSize = KMailListIconSizeInDoubleResLand;
-			break;
-		}
-	TAknUiZoom zoomLevel(EAknUiZoomNormal);
-    CAknEnv::Static()->GetCurrentGlobalUiZoom( zoomLevel );
- 	switch ( zoomLevel )
-		{
-		// Make icon a little bit smaller in small zoom
-		case EAknUiZoomSmall:
-			{
-			mailListIconSize.iHeight-=2;
-			mailListIconSize.iWidth-=2;
-			}
-			break;
-		case EAknUiZoomLarge:
-		case EAknUiZoomNormal:
-		default:
-			{
-			}
-			break;
-		}
-	return mailListIconSize;*/
-// </cmail> Use layout data instead of hard-coded values
 	}
 
 
@@ -483,7 +354,7 @@
                 AknLayoutScalable_Apps::list_single_dyc_row_pane( 0 ),
                 AknLayoutScalable_Apps::list_single_dyc_row_pane_g1( 0 ) ) );
         TAknLayoutRect paneG1;
-        paneG1.LayoutRect( DropDownMenuListRect( ELeft ), g1Layout.LayoutLine() );
+        paneG1.LayoutRect( DropDownMenuListRect( ELeft, EFalse ), g1Layout.LayoutLine() );
         return paneG1.Rect().Size();        
         }
     else
@@ -503,7 +374,6 @@
         }
     }      
 
-// <cmail>
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::FolderListPaneRectInThisResolution
 // Folder list pane rect, taken from Avkon layouts
@@ -516,7 +386,6 @@
     itemRect.LayoutRect(aParent, AknLayoutScalable_Avkon::listscroll_gen_pane(0,0,0));
     return itemRect.Rect();
     }
-// </cmail>
 
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::FolderListIndentation
@@ -547,14 +416,13 @@
     return itemRect.Rect().Size();
 	}
 
-// <cmail>
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::DropDownMenuListRect
 // Selector ring image visual size
 // -----------------------------------------------------------------------------
 //
 TRect CFSEmailUiLayoutHandler::DropDownMenuListRect(
-        const TDropDownMenuSide aSide ) const
+        const TDropDownMenuSide aSide, TBool aStretch ) const
     {
     FUNC_LOG;
     TRect mainPaneRect;
@@ -562,7 +430,8 @@
             mainPaneRect );
     mainPaneRect.Move( 0, -mainPaneRect.iTl.iY );
     TInt variety( aSide == ELeft ? 0 : 1 );
-    if ( Layout_Meta_Data::IsLandscapeOrientation() )
+    TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
+    if ( landscape )
         {
         // landscape orientation variety is portrait + 2
         variety += 2;
@@ -576,10 +445,62 @@
     
     TAknLayoutRect menuPane;
     menuPane.LayoutRect( mainPaneRect, ddMenuPane.LayoutLine() );
-    return menuPane.Rect();
+    TRect rect = menuPane.Rect();
+    if ( aStretch )
+        {
+        rect.iBr.iY = mainPaneRect.iBr.iY;
+        
+        if( !landscape ) // landscape layout occupy the right side of the display
+            {
+            rect.iBr.iY -= ControlBarHeight();
+            }
+        }
+    
+    // Calculate the placement next to the button (below or left side)
+    TRect buttonRect;
+    TRect cbr = GetControlBarRect();
+    if( aSide == ELeft )
+        {
+        buttonRect = GetControlBarFolderListButtonRect();
+        }
+    else
+        {
+        buttonRect = GetControlBarSortButtonRect();
+        }
+    buttonRect.Move( cbr.iTl ); // relative to control bar
     
+    if( landscape )
+        {
+        TSize menuSize = rect.Size();
+
+        // position left from the button
+        rect.SetRect( TPoint( buttonRect.iTl.iX - menuSize.iWidth, 
+                buttonRect.Center().iY - menuSize.iHeight / 2 ), menuSize );
+        }
+    else
+        {
+        // position below the button
+        rect.Move( 0, buttonRect.iBr.iY - rect.iTl.iY );
+        }
+    
+    // keep the popup menu inside the screen area
+    if( landscape )
+        {
+        if( rect.iTl.iX < KPopupMargin )
+            {
+            rect.Move( KPopupMargin - rect.iTl.iX , 0 );
+            }
+        if( rect.iBr.iY > mainPaneRect.iBr.iY - KPopupMargin )
+            {
+            rect.Move( 0, mainPaneRect.iBr.iY - rect.iBr.iY - KPopupMargin );
+            }
+        }
+    if( rect.iTl.iY < KPopupMargin )
+        {
+        rect.iTl.iY = KPopupMargin;
+        }
+    return rect;
     }
-// </cmail>
 
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::SelectorVisualSizeInThisResolution
@@ -637,7 +558,7 @@
     TRect mainPaneRect;
     TAknLayoutRect listItem;
     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
-    listItem.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::list_single_dyc_row_pane( 0 ) );
+    listItem.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::list_single_fs_dyc_pane( 0 ) );
     return listItem.Rect().Height();
     //</cmail>
 	}
@@ -651,15 +572,22 @@
 TInt CFSEmailUiLayoutHandler::OneLineListItemHeight() const
 	{
     FUNC_LOG;
-	//<cmail>
     TRect mainPaneRect;
     TAknLayoutRect listItem;
     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
-    listItem.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::list_single_dyc_row_pane( 0 ) );
+    listItem.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::list_single_fs_dyc_pane( 0 ) );
     return listItem.Rect().Height();
-    //</cmail>
 	}
 
+TInt CFSEmailUiLayoutHandler::TwoLineListItemHeight() const
+    {
+    TRect mainPaneRect;
+    TAknLayoutRect listItem;
+    AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
+    listItem.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::list_single_fs_dyc_pane( 1 ) );
+    return listItem.Rect().Height();
+    }
+
 //<cmail>
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::FolderListOneLineItemHeight
@@ -693,33 +621,13 @@
 TInt CFSEmailUiLayoutHandler::ControlBarHeight() const
 	{
     FUNC_LOG;
-	//<cmail>
 	TRect mainPaneRect;
     TAknLayoutRect ctrlBarRect;
     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
     ctrlBarRect.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane( 0 ) );
     return ctrlBarRect.Rect().Height();
-	//</cmail>
 	}
 
-// -----------------------------------------------------------------------------
-// CFSEmailUiLayoutHandler::ControlBarHeight
-// Control bar text height in twips
-// -----------------------------------------------------------------------------
-//
-/*
-TInt CFSEmailUiLayoutHandler::ControlBarTextHeight() const
-	{
-    TRect mainPaneRect;
-    TAknLayoutText ctrlBarText;
-    TInt orientation( Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0 );
-    AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
-    ctrlBarText.LayoutText( mainPaneRect, AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_t1( orientation ) );
-    return ctrlBarText.Font()->FontSpecInTwips().iHeight;
-	}
-*/
-//</cmail>  Platform layout change
-
 // <cmail> changes to avoid unnecessary creating new text styles objects.
 CAlfTextStyle* CFSEmailUiLayoutHandler::FSTextStyleFromIdL( TFSEmailFont aFontId )
     {
@@ -1515,16 +1423,13 @@
     return layoutRect.Rect().Size();
     // </cmail> Platform layout changes
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ViewerActionMenuIconMargin
 // -----------------------------------------------------------------------------
 TInt CFSEmailUiLayoutHandler::ViewerActionMenuIconMargin() const
     {
 	FUNC_LOG;
-    // <cmail> Platform layout changes
-    /*
-    return KViewerActionMenuIconMargin;
-    */
 	if (AknLayoutUtils::LayoutMirrored())
 	    {
 	    TAknLayoutRect layoutRect;
@@ -1541,8 +1446,8 @@
         layoutRect.LayoutRect( layoutRect.Rect(), AknLayoutScalable_Apps::list_single_cmail_header_detail_pane_g2( 0 ) );
         return Abs( x - layoutRect.Rect().iBr.iX );
 	    }
-    // </cmail> Platform layout changes
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ViewerSelectorOpacity
 // -----------------------------------------------------------------------------
@@ -1551,30 +1456,19 @@
     FUNC_LOG;
     return KViewerSelectorOpacity;
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ViewerRightMarginInPixels
 // -----------------------------------------------------------------------------
 TInt CFSEmailUiLayoutHandler::ViewerRightMarginInPixels() const
 	{
 	FUNC_LOG;
-    // <cmail> Platform layout changes
-    /*
-    if ( AknLayoutUtils::LayoutMirrored() )
-        {
-        return KViewerLeftMarginWidthInPixels;
-        }
-    else
-        {
-        return KViewerRightMarginWidthInPixels;
-        }
-    */
     const TRect cmailPaneRect( ListCmailPaneRect() );
     TAknLayoutRect layoutRect;
     layoutRect.LayoutRect( cmailPaneRect, AknLayoutScalable_Apps::list_single_cmail_header_caption_pane() );
     TAknLayoutText captionTextRect;
     captionTextRect.LayoutText( layoutRect.Rect(), AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1() );
     return Abs( cmailPaneRect.iBr.iX - captionTextRect.TextRect().iBr.iX );
-    // </cmail> Platform layout changes
     }
 
 // -----------------------------------------------------------------------------
@@ -1583,24 +1477,12 @@
 TInt CFSEmailUiLayoutHandler::ViewerLeftMarginInPixels() const
 	{
 	FUNC_LOG;
-    // <cmail> Platform layout changes
-    /*
-    if ( AknLayoutUtils::LayoutMirrored() )
-        {
-        return KViewerRightMarginWidthInPixels;
-        }
-    else
-        {
-        return KViewerLeftMarginWidthInPixels;
-        }
-    */
     const TRect cmailPaneRect( ListCmailPaneRect() );
     TAknLayoutRect layoutRect;
     layoutRect.LayoutRect( cmailPaneRect, AknLayoutScalable_Apps::list_single_cmail_header_caption_pane() );
     TAknLayoutText captionTextRect;
     captionTextRect.LayoutText( layoutRect.Rect(), AknLayoutScalable_Apps::list_single_cmail_header_caption_pane_t1() );
     return Abs( cmailPaneRect.iTl.iX - captionTextRect.TextRect().iTl.iX );
-    // </cmail> Platform layout changes
     }
 
 // -----------------------------------------------------------------------------
@@ -1630,6 +1512,7 @@
 		}
 	return sizeWithCurrentResolution;
 	}
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ViewerWaterMarkPositionFromBottomRightCornerInThisResolution
 // -----------------------------------------------------------------------------
@@ -1657,6 +1540,7 @@
 		}
 	return placeFromBottomRightCorner;
 	}
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ComposerFieldBorderColor
 // -----------------------------------------------------------------------------
@@ -1673,6 +1557,7 @@
     FUNC_LOG;
     return GetSkinColor( KAknsIIDFsOtherColors, EAknsCIFsOtherColorsCG12, KRgbWhite );
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ComposerHeaderFieldTextColor
 // -----------------------------------------------------------------------------
@@ -1681,6 +1566,7 @@
     FUNC_LOG;
     return GetSkinColor( KAknsIIDFsTextColors, EAknsCIFsTextColorsCG4, KRgbBlack );
         }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ComposerBodyFieldTextColor
 // -----------------------------------------------------------------------------
@@ -1689,6 +1575,7 @@
     FUNC_LOG;
     return GetSkinColor( KAknsIIDFsTextColors, EAknsCIFsTextColorsCG3, KRgbBlack );
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ComposerDimmedTextColor
 // -----------------------------------------------------------------------------
@@ -1697,6 +1584,7 @@
     FUNC_LOG;
     return GetSkinColor( KAknsIIDFsTextColors, EAknsCIFsTextColorsCG18, KRgbGray );
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::MaxPcsMatches
 // -----------------------------------------------------------------------------
@@ -1705,6 +1593,7 @@
     FUNC_LOG;
     return KMaxPcsMatches;
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::PcsPopupHighlightColor
 // -----------------------------------------------------------------------------
@@ -1713,6 +1602,7 @@
     FUNC_LOG;
     return KPcsPopupHighlightColor;
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::PcsPopupDimmedFontColor
 // -----------------------------------------------------------------------------
@@ -1721,20 +1611,18 @@
     FUNC_LOG;
     return KPcsPopupDimmedFontColor;
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ListTextureNodeExpandedSize
 // -----------------------------------------------------------------------------
 TInt CFSEmailUiLayoutHandler::ListTextureNodeExpandedSize() const
     {
     FUNC_LOG;
-    //<cmail>
     TRect mainPaneRect;
     TAknLayoutRect listItem;
     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
     listItem.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::list_single_dyc_row_pane_g1( 0 ) );
     return listItem.Rect().Height();
-    //return KListTextureNodeExpandedSize;
-    //</cmail>
     }
 
 // -----------------------------------------------------------------------------
@@ -1765,22 +1653,18 @@
 TInt CFSEmailUiLayoutHandler::ListControlBarMailboxDefaultIconSize() const
     {
     FUNC_LOG;
-    // <cmail> Platform layout change
-    //return KListControlBarMailboxDefaultIconSize;
-    return GetControlBarMailboxIconSize().iWidth;
-    // </cmail> Platform layout change
+    return GetControlBarMailboxIconRect().Size().iWidth;
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::EMailListBarBgIconSize
 // -----------------------------------------------------------------------------
 TInt CFSEmailUiLayoutHandler::EMailListBarBgIconSize() const
     {
     FUNC_LOG;
-    // <cmail> Platform layout change
     return GetControlBarRect().Size().iHeight;
-    //return KEMailListBarBgIconSize;
-    // </cmail>
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ListTextureMailboxDefaultIconSize
 // -----------------------------------------------------------------------------
@@ -1789,24 +1673,22 @@
     FUNC_LOG;
     return KListTextureMailboxDefaultIconSize;
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::EListTextureSelectorSize
 // -----------------------------------------------------------------------------
 TInt CFSEmailUiLayoutHandler::EListTextureSelectorSize() const
     {
     FUNC_LOG;
-    // <cmail> Platform layout change
     return OneLineListItemHeight();
-    //return KEListTextureSelectorSize;
-    // </cmail>
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ListControlMenuIconSize
 // -----------------------------------------------------------------------------
 TInt CFSEmailUiLayoutHandler::ListControlMenuIconSize() const
     {
     FUNC_LOG;
-    // <cmail> Platform layout change
     TRect mainPaneRect;
     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
     mainPaneRect.Move(-mainPaneRect.iTl);
@@ -1815,13 +1697,11 @@
     TAknLayoutRect iconRect;
     iconRect.LayoutRect(controlBarRect.Rect(), AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_g1(0));
     return iconRect.Rect().Height();
-    //return KListControlMenuIconSize;
-    // </cmail>
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::AttachmentIconSize
 // -----------------------------------------------------------------------------
-// <cmail>
 TSize CFSEmailUiLayoutHandler::AttachmentIconSize() const
     {
     FUNC_LOG;
@@ -1829,9 +1709,8 @@
     rect.LayoutRect( TRect(0,0,0,0),
                     AknLayoutScalable_Apps::list_single_dyc_row_pane_g1( 0 ).LayoutLine() );
     return rect.Rect().Size();
-    //return KAttachmentIconSize;
-// </cmail>    
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ViewerHighlightTextureSize
 // -----------------------------------------------------------------------------
@@ -1840,6 +1719,7 @@
     FUNC_LOG;
     return KViewerHighlightTextureSize;
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ControlBarArrowTextureXSize
 // -----------------------------------------------------------------------------
@@ -1848,6 +1728,7 @@
     FUNC_LOG;
     return KControlBarArrowTextureXSize;
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::ControlBarArrowTextureYSize
 // -----------------------------------------------------------------------------
@@ -1856,6 +1737,7 @@
     FUNC_LOG;
     return KControlBarArrowTextureYSize;
     }
+
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::GetSkinColor
 // -----------------------------------------------------------------------------
@@ -1879,8 +1761,6 @@
     return color;    
     }
 
-// <cmail> Use layout data instead of hardcoded values
-
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::GetControlBarMailboxIconRect
 // -----------------------------------------------------------------------------
@@ -1901,25 +1781,38 @@
         {
         iconRect.LayoutRect(controlBarRect.Rect(), AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_g1(0));
         }
+    
     return iconRect.Rect();
     }
 
 // -----------------------------------------------------------------------------
-// CFSEmailUiLayoutHandler::GetControlBarMailboxIconPos
-// -----------------------------------------------------------------------------
-TPoint CFSEmailUiLayoutHandler::GetControlBarMailboxIconPos() const
+TRect CFSEmailUiLayoutHandler::GetControlBarNewEmailButtonRect() const
     {
     FUNC_LOG;
-    return GetControlBarMailboxIconRect().iTl;
-    }
-
-// -----------------------------------------------------------------------------
-// CFSEmailUiLayoutHandler::GetControlBarMailboxIconSize
-// -----------------------------------------------------------------------------
-TSize CFSEmailUiLayoutHandler::GetControlBarMailboxIconSize() const
-    {
-    FUNC_LOG;
-    return GetControlBarMailboxIconRect().Size();
+    TAknLayoutRect iconRect;
+    TRect cbr = GetControlBarRect();
+    if( Layout_Meta_Data::IsLandscapeOrientation() )
+        {
+        iconRect.LayoutRect( cbr, 
+                     AknLayoutScalable_Apps::cmail_ddmenu_btn02_pane(3) );
+        }
+    else
+        {
+        if ( AknLayoutUtils::LayoutMirrored() )
+            {
+            iconRect.LayoutRect( cbr, 
+                             AknLayoutScalable_Apps::cmail_ddmenu_btn03_pane(2) );
+            }
+        else
+            {
+            iconRect.LayoutRect( cbr, 
+                             AknLayoutScalable_Apps::cmail_ddmenu_btn01_pane(2) );
+            }
+        }
+    
+    TRect rect = iconRect.Rect();
+    rect.Move( -cbr.iTl );
+    return rect;
     }
 
 // -----------------------------------------------------------------------------
@@ -1928,39 +1821,23 @@
 TRect CFSEmailUiLayoutHandler::GetControlBarFolderListButtonRect() const
     {
     FUNC_LOG;
-    TRect mainPaneRect;
-    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
-    mainPaneRect.Move(-mainPaneRect.iTl);
-    TAknLayoutRect controlBarRect;
-    controlBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane(0));
+
     TAknLayoutRect folderListButtonRect;
-    if ( AknLayoutUtils::LayoutMirrored() )
+    TRect cbr = GetControlBarRect();
+    if( Layout_Meta_Data::IsLandscapeOrientation() )
         {
-        folderListButtonRect.LayoutRect(controlBarRect.Rect(), AknLayoutScalable_Apps::main_sp_fs_ctrlbar_button_pane_cp01(0));        
+        folderListButtonRect.LayoutRect( cbr, 
+                         AknLayoutScalable_Apps::cmail_ddmenu_btn02_pane_cp1(3) );
         }
     else
         {
-        folderListButtonRect.LayoutRect(controlBarRect.Rect(), AknLayoutScalable_Apps::main_sp_fs_ctrlbar_ddmenu_pane(0));
+        folderListButtonRect.LayoutRect( cbr, 
+                             AknLayoutScalable_Apps::cmail_ddmenu_btn02_pane(2) );
         }
-    return folderListButtonRect.Rect();
-    }
-
-// -----------------------------------------------------------------------------
-// CFSEmailUiLayoutHandler::GetControlBarFolderListButtonPos
-// -----------------------------------------------------------------------------
-TPoint CFSEmailUiLayoutHandler::GetControlBarFolderListButtonPos() const
-    {
-    FUNC_LOG;
-    return GetControlBarFolderListButtonRect().iTl;
-    }
-
-// -----------------------------------------------------------------------------
-// CFSEmailUiLayoutHandler::GetControlBarFolderListButtonSize
-// -----------------------------------------------------------------------------
-TSize CFSEmailUiLayoutHandler::GetControlBarFolderListButtonSize() const
-    {
-    FUNC_LOG;
-    return GetControlBarFolderListButtonRect().Size();
+    
+    TRect rect = folderListButtonRect.Rect();
+    rect.Move( -cbr.iTl );
+    return rect;
     }
 
 // -----------------------------------------------------------------------------
@@ -1969,39 +1846,31 @@
 TRect CFSEmailUiLayoutHandler::GetControlBarSortButtonRect() const
     {
     FUNC_LOG;
-    TRect mainPaneRect;
-    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
-    mainPaneRect.Move(-mainPaneRect.iTl);
-    TAknLayoutRect controlBarRect;
-    controlBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane(0));
+
     TAknLayoutRect sortButtonRect;
-    if ( AknLayoutUtils::LayoutMirrored() )
+    TRect cbr = GetControlBarRect();
+    if( Layout_Meta_Data::IsLandscapeOrientation() )
         {
-        sortButtonRect.LayoutRect(controlBarRect.Rect(), AknLayoutScalable_Apps::main_sp_fs_ctrlbar_ddmenu_pane(0));        
+        sortButtonRect.LayoutRect( cbr, 
+                     AknLayoutScalable_Apps::cmail_ddmenu_btn02_pane_cp2(3) );
         }
     else
         {
-        sortButtonRect.LayoutRect(controlBarRect.Rect(), AknLayoutScalable_Apps::main_sp_fs_ctrlbar_button_pane_cp01(0));
-        }    
-    return sortButtonRect.Rect();
-    }
-
-// -----------------------------------------------------------------------------
-// CFSEmailUiLayoutHandler::GetControlBarSortButtonPos
-// -----------------------------------------------------------------------------
-TPoint CFSEmailUiLayoutHandler::GetControlBarSortButtonPos() const
-    {
-    FUNC_LOG;
-    return GetControlBarSortButtonRect().iTl;
-    }
-
-// -----------------------------------------------------------------------------
-// CFSEmailUiLayoutHandler::GetControlBarSortButtonSize
-// -----------------------------------------------------------------------------
-TSize CFSEmailUiLayoutHandler::GetControlBarSortButtonSize() const
-    {
-    FUNC_LOG;
-    return GetControlBarSortButtonRect().Size();
+        if ( AknLayoutUtils::LayoutMirrored() )
+            {
+            sortButtonRect.LayoutRect( cbr, 
+                             AknLayoutScalable_Apps::cmail_ddmenu_btn01_pane(2) );
+            }
+        else
+            {
+            sortButtonRect.LayoutRect( cbr, 
+                             AknLayoutScalable_Apps::cmail_ddmenu_btn03_pane(2) );
+            }
+        }
+    
+    TRect r = sortButtonRect.Rect();
+    r.Move( -cbr.iTl );
+    return r;
     }
 
 // -----------------------------------------------------------------------------
@@ -2016,7 +1885,7 @@
     TAknLayoutRect controlBarRect;
     controlBarRect.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane(0 ) );
     TAknLayoutRect iconRect;
-    // <cmail>
+    
     if ( AknLayoutUtils::LayoutMirrored() )
         {        
         iconRect.LayoutRect( controlBarRect.Rect(), AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_g1( 0 ) );
@@ -2025,55 +1894,64 @@
         {
         iconRect.LayoutRect( controlBarRect.Rect(), AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_g2( 0 ) );
         }
-    // </cmail>
+    
     return iconRect.Rect();
     }
 
 // -----------------------------------------------------------------------------
-// CFSEmailUiLayoutHandler::GetControlBarConnectionIconPos
-// -----------------------------------------------------------------------------
-TPoint CFSEmailUiLayoutHandler::GetControlBarConnectionIconPos() const
-    {
-    FUNC_LOG;
-    return GetControlBarConnectionIconRect().iTl;
-    }
-
-// -----------------------------------------------------------------------------
-// CFSEmailUiLayoutHandler::GetControlBarConnectionIconSize
-// -----------------------------------------------------------------------------
-TSize CFSEmailUiLayoutHandler::GetControlBarConnectionIconSize() const
-    {
-    FUNC_LOG;
-    return GetControlBarConnectionIconRect().Size();
-    }
-
-// -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::GetControlBarRect
 // -----------------------------------------------------------------------------
 TRect CFSEmailUiLayoutHandler::GetControlBarRect() const
     {
     FUNC_LOG;
-    //TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; //<cmail>
+    TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 3 : 2;
+    
     TRect mainPaneRect;
     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
     mainPaneRect.Move(-mainPaneRect.iTl);
+    
+    TRect emailRect = mainPaneRect;
+    TAknLayoutRect emailPaneRect;
+    emailPaneRect.LayoutRect(mainPaneRect, 
+                    AknLayoutScalable_Apps::main_sp_fs_email_pane());
+    emailRect = emailPaneRect.Rect();
+   
     TAknLayoutRect controlBarRect;
-    controlBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane(0)); //<cmail>
-    return controlBarRect.Rect();
+    controlBarRect.LayoutRect( emailRect, 
+                    AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane(var));
+    TRect rect = controlBarRect.Rect();
+    
+    return rect;
     }
 
 // -----------------------------------------------------------------------------
-// CFSEmailUiLayoutHandler::GetControlBarRect
+// CFSEmailUiLayoutHandler::GetListRect
 // -----------------------------------------------------------------------------
-TRect CFSEmailUiLayoutHandler::GetListRect() const
+TRect CFSEmailUiLayoutHandler::GetListRect( TBool aControlsOnTop ) const
     {
     FUNC_LOG;
+    TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
+    TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 3 : 2;
+    
     TRect mainPaneRect;
     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
     mainPaneRect.Move(-mainPaneRect.iTl);
+    
     TAknLayoutRect listRect;
-    listRect.LayoutRect( mainPaneRect, AknLayoutScalable_Apps::main_sp_fs_listscroll_pane_te_cp01( 0 ) );
-    return listRect.Rect();
+    listRect.LayoutRect( mainPaneRect, 
+                        AknLayoutScalable_Apps::main_sp_fs_listscroll_pane_te_cp01( var ));
+    TRect rect = listRect.Rect();
+
+    // if control bar is required, reserve space on top of the listbox  
+    if( aControlsOnTop && landscape )
+        {
+        TAknLayoutRect listRect2;
+        listRect2.LayoutRect( mainPaneRect, 
+                        AknLayoutScalable_Apps::main_sp_fs_listscroll_pane_te_cp01( 0 ));
+        rect.Intersection(listRect2.Rect());
+        }
+    
+    return rect;
     }
 
 // -----------------------------------------------------------------------------
@@ -2082,7 +1960,6 @@
 TAknLayoutText CFSEmailUiLayoutHandler::GetSearchListHeaderTextLayout() const
     {
     FUNC_LOG;
-    //TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
     TRect mainPaneRect;
     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
     mainPaneRect.Move(-mainPaneRect.iTl);
@@ -2159,10 +2036,6 @@
     return layoutRect.Rect();
     }
 
-// </cmail> Platform layout change
-
-// <cmail> new methods
-
 // -----------------------------------------------------------------------------
 // CFSEmailUiLayoutHandler::TitleCaptionPadding
 // 
@@ -2244,7 +2117,5 @@
     return Abs( menuListPaneRect.iTl.iY - menuPaneRect.iTl.iY );
     }
 
-// </cmail> 
-
 // End of file
 
--- a/emailuis/emailui/src/FreestyleEmailUiMailListModel.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiMailListModel.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -467,11 +467,11 @@
             break;
         case EFSMailSortByUnread:
             {
-            TInt compVal1 = 1;
-            if ( message1.IsFlagSet(EFSMsgFlag_Read) ) { compVal1 = 0; }
+            TInt compVal1 = 0;
+            if ( message1.IsFlagSet(EFSMsgFlag_Read) ) { compVal1 = 1; }
 
-            TInt compVal2 = 1;
-            if ( message2.IsFlagSet(EFSMsgFlag_Read) ) { compVal2 = 0; }
+            TInt compVal2 = 0;
+            if ( message2.IsFlagSet(EFSMsgFlag_Read) ) { compVal2 = 1; }
 
             retVal = compVal1 - compVal2;
             }
--- a/emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiMailListVisualiser.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -39,22 +39,17 @@
 #include "fstreeplaintwolineitemvisualizer.h"
 #include "CFSMailCommon.h"
 #include "ceuiemaillisttouchmanager.h"
-//</cmail>
 #include "FSEmailBuildFlags.h"
-//<cmail>
 #include "cfsccontactactionmenu.h"
 #include "mfsccontactactionmenumodel.h"
-//</cmail>
 
 #include <hlplch.h>
 #include <AknIconArray.h>
-// <cmail> SF
 #include <alf/alfdecklayout.h>
 #include <alf/alfcontrolgroup.h>
 #include <alf/alfframebrush.h>
 #include <alf/alfevent.h>
 #include <alf/alfstatic.h>
-// </cmail>
 
 #include <aknnotewrappers.h>
 #include <msvapi.h>
@@ -76,6 +71,7 @@
 #include "cesmricalviewer.h"
 //</cmail>
 #include <aknstyluspopupmenu.h>
+#include <akntoolbar.h>
 
 // INTERNAL INCLUDES
 #include "FreestyleEmailUiUtilities.h"
@@ -103,15 +99,7 @@
 
 // CONST VALUES
 const TInt KControlBarTransitionTime = 250;
-//<cmail>
-//const TInt KFirstButtonStartPosX = 25;
-//const TInt KControlBarMailboxIconWidth = 20;
-//const TInt KControlButtonPosY = 3;
-//const TInt KControlButtonSeparation = 10;
-//</cmail>
 const TInt KMaxPreviewPaneLength = 60;
-//const TInt KInitialPreviewUpdate = 5;
-//const TInt KSyncIconTimerDelay = 18000;
 const TInt KMsgUpdaterTimerDelay = 2500000; // Time to update list, 2,5sec
 static const TInt KMsgDeletionWaitNoteAmount = 5;
 _LIT( KMissingPreviewDataMarker, "..." );
@@ -252,6 +240,8 @@
     iControlBarControl->SetSelectorImageL( cbSelectorBrush );
     CleanupStack::Pop( cbSelectorBrush ); // ownership transferred to control bar
 
+    iNewEmailText = StringLoader::LoadL( R_COMMAND_AREA_NEW_EMAIL );
+
     // Set menu, mark and background icons
     iMailTreeListVisualizer->SetMarkIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMarkIcon ) );
     iMailTreeListVisualizer->SetMenuIcon( iAppUi.FsTextureManager()->TextureByIndex( EListControlMenuIcon ) );
@@ -299,7 +289,8 @@
     : CFsEmailUiViewBase( aMailListControlGroup, *aAppUi ),
     iEnv( aEnv ),
     iListMarkItemsState( ETrue ), //Initlly list has no markings
-	iMoveToFolderOngoing( EFalse )
+	iMoveToFolderOngoing( EFalse ),
+	iStylusPopUpMenuLaunched( EFalse )
 	{
     FUNC_LOG;
 	}
@@ -311,7 +302,6 @@
 CFSEmailUiMailListVisualiser::~CFSEmailUiMailListVisualiser()
     {
     FUNC_LOG;
-    //<cmail>
     if ( iMailFolder )
         {
         delete iMailFolder;
@@ -320,8 +310,8 @@
 
     delete iTouchManager;
     delete iStylusPopUpMenu;
-    //</cmail>
     delete iMailList;
+    delete iNewEmailText;
 
 	// Don't construct this anywhere else than in constructor.
 	// Don't delete anywhere else thatn here to avoid NULL checks.
@@ -463,7 +453,7 @@
 	{
     FUNC_LOG;
 	// New Items
-	CFSEmailUiMailListModelItem* newItem(NULL);
+	CFSEmailUiMailListModelItem* newItem = NULL;
 
 	// Draw first separator if there are messages.
 	if ( aMessages.Count() && iNodesInUse == EListControlSeparatorEnabled )
@@ -951,11 +941,6 @@
 //
 // ---------------------------------------------------------------------------
 //
-// <cmail> Toolbar
-/*void CFSEmailUiMailListVisualiser::DoActivateL(const TVwsViewId& aPrevViewId,
-                     TUid aCustomMessageId,
-                     const TDesC8& aCustomMessage)*/
-// </cmail> Toolbar
 void CFSEmailUiMailListVisualiser::ChildDoActivateL(const TVwsViewId& aPrevViewId,
                      TUid aCustomMessageId,
                      const TDesC8& aCustomMessage)
@@ -983,6 +968,11 @@
 	    forwardNavigation = ETrue;
 	    }
 
+	if( iAppUi.CurrentFixedToolbar() )
+	    {
+        iAppUi.CurrentFixedToolbar()->SetToolbarVisibility( EFalse );
+	    }
+
     // Set control bar and list layout size always in activation
     TRect clientRect = iAppUi.ClientRect();
     iScreenAnchorLayout->SetSize( clientRect.Size() );
@@ -1167,10 +1157,9 @@
     // Check sync icon timer and sync status
     ConnectionIconHandling();
 
-// <cmail>
     iMailList->HideListL();
     iMailList->ShowListL();
-// </cmail>
+
     // REBUILD TREE LIST IF NECESSARY
     if ( refreshNeeded )
         {
@@ -1189,14 +1178,7 @@
     else
         {
         // hide & show list to force it to adept to changed screen size
-	// <cmail>
-      /*if ( iCurrentClientRect != clientRect )
-            {
-            iMailList->HideListL();
-            iMailList->ShowListL(); */
-            SetListAndCtrlBarFocusL(); // ShowListL() makes list focused and this may need to be reverted
-//          }
-	// </cmail>
+        SetListAndCtrlBarFocusL(); // ShowListL() makes list focused and this may need to be reverted
         UnmarkAllItemsL();
 
         if ( aCustomMessageId == TUid::Uid(KMailSettingsReturnFromPluginSettings) )
@@ -1221,14 +1203,20 @@
 
 	// Inform MR observer if needed, special MR case, returning from attachment list
 	iAppUi.MailViewer().CompletePendingMrCommand();
-// <cmail>
+
 	//Make sure that correct component is set to focused.
 	if ( iFocusedControl == EMailListComponent )
+	    {
 	    SetTreeListFocusedL();
+	    }
 	else
+	    {
 	    SetControlBarFocusedL();
-// </cmail>
-
+	    iControlBarControl->MakeSelectorVisible( iAppUi.IsFocusShown() );
+	    }
+	UpdateButtonTextsL();
+
+	FocusVisibilityChange( iAppUi.IsFocusShown() );
 	iAppUi.ShowTitlePaneConnectionStatus();
 	}
 
@@ -1238,10 +1226,17 @@
 //
 void CFSEmailUiMailListVisualiser::SetStatusBarLayout()
 	{
-	if ( StatusPane()->CurrentLayoutResId() !=  R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT )
+    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(  R_AVKON_STATUS_PANE_LAYOUT_IDLE_FLAT ));
+			StatusPane()->SwitchLayoutL( res ));
 		}
 	}
 
@@ -1539,6 +1534,14 @@
 				// 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
 				{
@@ -2438,9 +2441,15 @@
 
     if ( iFirstStartCompleted ) // Safety
         {
+        if ( aType == EScreenLayoutChanged )
+        	{
+            SetStatusBarLayout();
+            UpdateButtonTextsL();
+        	}
+
         if ( aType == ESkinChanged )
             {
-            iSkinChanged = ETrue;
+            UpdateTheme();
             }
         else
             {
@@ -2469,17 +2478,91 @@
 //
 // ---------------------------------------------------------------------------
 //
-void CFSEmailUiMailListVisualiser::HandleDynamicVariantSwitchOnBackgroundL( CFsEmailUiViewBase::TDynamicSwitchType aType )
+void CFSEmailUiMailListVisualiser::HandleDynamicVariantSwitchOnBackgroundL(
+        CFsEmailUiViewBase::TDynamicSwitchType aType )
     {
     FUNC_LOG;
     CFsEmailUiViewBase::HandleDynamicVariantSwitchOnBackgroundL( aType );
     if ( aType == ESkinChanged )
         {
-        iSkinChanged = ETrue;
+        UpdateTheme();
+        }
+    else if ( aType == EScreenLayoutChanged )
+        {
+        UpdateButtonTextsL();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Update texts for command area buttons
+// ---------------------------------------------------------------------------
+//
+void CFSEmailUiMailListVisualiser::UpdateButtonTextsL()
+    {
+    if ( !Layout_Meta_Data::IsLandscapeOrientation() )
+        {
+        // No texts in portrait mode
+        iNewEmailButton->SetTextL( KNullDesC() );
+        iSortButton->SetTextL( KNullDesC() );
+        }
+    else
+        {
+        // Set button text if necessary
+        HBufC* buttonText = GetSortButtonTextLC();
+        if ( buttonText )
+            {
+            iSortButton->SetTextL( *buttonText );
+            CleanupStack::PopAndDestroy( buttonText );
+            }
+
+        iNewEmailButton->SetTextL( *iNewEmailText );
         }
     }
 
 // ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+TBool CFSEmailUiMailListVisualiser::HitTest(
+        const CAlfControl& aControl, const TPoint& aPoint ) const
+    {
+    FUNC_LOG;
+    TBool contains( EFalse );
+    const TInt visualCount( aControl.VisualCount() );
+    for( TInt index( 0 ); index < visualCount && !contains; ++index )
+        {
+        TRect rect( aControl.Visual( index ).DisplayRectTarget() );
+        if( rect.Contains( aPoint ) )
+            {
+            contains = ETrue;
+            }
+        }
+    return contains;
+    }
+
+// ---------------------------------------------------------------------------
+//
+//
+// ---------------------------------------------------------------------------
+//
+void CFSEmailUiMailListVisualiser::UpdateTheme()
+    {
+    iSkinChanged = ETrue;
+
+    TRgb focusedTextColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor();
+    TRgb normalTextColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
+
+    iNewEmailButton->SetNormalTextColor( normalTextColor );
+    iNewEmailButton->SetFocusedTextColor( focusedTextColor );
+
+    iFolderListButton->SetNormalTextColor( normalTextColor );
+    iFolderListButton->SetFocusedTextColor( focusedTextColor );
+
+    iSortButton->SetNormalTextColor( normalTextColor );
+    iSortButton->SetFocusedTextColor( focusedTextColor );
+    }
+
+// ---------------------------------------------------------------------------
 // HandleForegroundEventL
 // Function checks in foregroundevent that whether settings have changed and
 // If there is a need to refresh the list.
@@ -2597,13 +2680,27 @@
     CleanupClosePushL( actionTargetItems );
     GetActionsTargetEntriesL( actionTargetItems );
 
-    switch(aCommand)
+    // Check if the focus needs to be removed.
+    if ( 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.
+   		iStylusPopUpMenuLaunched = EFalse;
+   		FocusVisibilityChange( EFalse );
+    	}
+
+    switch ( aCommand )
         {
     	case EAknSoftkeyOpen:
 		{
-		if (!iAppUi.IsTimerFocusShown())
+		if( !iAppUi.IsFocusShown() )
 			{
-			iAppUi.StartFocusRemovalTimer();
+			iAppUi.SetFocusVisibility( ETrue );
 			break;
 			}
 		}
@@ -2626,12 +2723,12 @@
        	    break;
        	case EAknSoftkeyChange:
        	    {
-    		if (!iAppUi.IsTimerFocusShown())
+    		if( !iAppUi.IsFocusShown() )
     			{
-    			iAppUi.StartFocusRemovalTimer();
+    			iAppUi.SetFocusVisibility( ETrue );
     			break;
     			}
-       	    if ( iFocusedControl == EControlBarComponent )
+       	    if( iFocusedControl == EControlBarComponent )
        	        {
        	        TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
        	        if ( focusedButtonId == iFolderListButtonId )
@@ -2642,7 +2739,7 @@
                     //</cmail>
        	            iAppUi.ShowFolderListInPopupL( FolderId(), this, iFolderListButton );
        	            }
-       	        else if ( focusedButtonId == iSortButtonId )
+       	        else if( focusedButtonId == iSortButtonId )
        	            {
        	            TFSFolderType folderType;
        	            if( iMailFolder )
@@ -2662,7 +2759,7 @@
                         //Set touchmanager not active for preventing getting events.
                         DisableMailList(ETrue);
                         //</cmail>
-                        iAppUi.ShowSortListInPopupL( iCurrentSortCriteria.iField, folderType, this, iSortButton );
+                        iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
                     // <cmail>
                     //    }
                     // </cmail>
@@ -2834,7 +2931,6 @@
 				{
 				DeleteMessagesL();
 				}
-			UnmarkAllItemsL();
 			}
             break;
 		case EFsEmailUiCmdCompose:
@@ -2920,9 +3016,9 @@
                 }
 			break;
         case EFsEmailUiCmdCollapse:
-    		if (!iAppUi.IsTimerFocusShown())
+    		if( !iAppUi.IsFocusShown() )
     			{
-    			iAppUi.StartFocusRemovalTimer();
+    			iAppUi.SetFocusVisibility( ETrue );
     			break;
     			}
             // Safety check, ignore command if the list is empty
@@ -2932,9 +3028,9 @@
                 }
             break;
         case EFsEmailUiCmdExpand:
-    		if (!iAppUi.IsTimerFocusShown())
+    		if( !iAppUi.IsFocusShown() )
     			{
-    			iAppUi.StartFocusRemovalTimer();
+    			iAppUi.SetFocusVisibility( ETrue );
     			break;
     			}
             // Safety check, ignore command if the list is empty
@@ -3005,8 +3101,6 @@
 			if ( supportsSync )
 				{
 	       		iAppUi.StopActiveMailBoxSyncL();
-	       		CFSMailBox* mb = iAppUi.GetActiveMailbox();
-				TDesC* mbName = &mb->GetName();
 				}
        		}
        		break;
@@ -3018,7 +3112,6 @@
         case EFsEmailUiCmdGoOnline:
         	{
 			CFSMailBox* mb = iAppUi.GetActiveMailbox();
-			TDesC* mbName = &mb->GetName();
             iAppUi.ManualMailBoxSync( ETrue );
         	mb->GoOnlineL();
         	}
@@ -3078,6 +3171,21 @@
 			TFSMailMsgId folderID;
 			folderID.SetNullId(); // Selection is popped up with NULL
 			MoveMsgsToFolderL( folderID );
+
+			TBool supportsSync = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaSupportsSync );
+			if ( supportsSync )
+			    {
+			    //If synchronizing is ongoing and a new sync is started we ignore it
+			    if(!GetLatestSyncState())
+			        {
+			        iAppUi.SyncActiveMailBoxL();
+
+			        // Sync the mailbox
+			        ManualMailBoxSync(ETrue);
+
+                    iAppUi.ManualMailBoxSync( ETrue );
+			        }
+			    }
 			}
 			break;
        	case EFsEmailUiCmdActionsMoveToDrafts:
@@ -3115,12 +3223,6 @@
                         {
                         HandleCommandL(EFsEmailUiCmdMarkMark);
                         }
-				    }
-				else if ( item->ModelItemType() == ETypeSeparator )
-					{
-					// Mark items.
-					MarkItemsUnderSeparatorL( ETrue, HighlightedIndex() );
-					iListMarkItemsState = ETrue; // Enable mark mode
 					}
                 }
             }
@@ -3128,6 +3230,7 @@
         case EFsEmailUiCmdGoToSwitchFolder:
             {
             iControlBarControl->SetFocusByIdL( iFolderListButtonId );
+            iControlBarControl->MakeSelectorVisible( IsFocusShown() );
             iFocusedControl = EControlBarComponent;
             iMailList->SetFocusedL( EFalse );
             }
@@ -3135,6 +3238,7 @@
         case EFsEmailUiCmdGoToSwitchSorting:
             {
             iControlBarControl->SetFocusByIdL( iSortButtonId );
+            iControlBarControl->MakeSelectorVisible( IsFocusShown() );
             iFocusedControl = EControlBarComponent;
            	iMailList->SetFocusedL( EFalse );
             }
@@ -3203,8 +3307,11 @@
        		}
 			break;
 	    default:
+	    	{
+	    	// No default action.
+	    	}
         	break;
-        }
+        } // switch ( aCommand )
     CleanupStack::PopAndDestroy( &actionTargetItems );
     }
 
@@ -3575,23 +3682,39 @@
         // Only handle key events
         if ( aEvent.IsPointerEvent() )
             {
-            switch( iFocusedControl )
+            if( aEvent.PointerDown() )
                 {
-                case EMailListComponent:
+                // If pointer down event was made on control bar area
+                // focus needs to be changed to control bar control, if it
+                // didn't already have focus.
+               if( HitTest( *iControlBarControl, aEvent.PointerEvent().iPosition ) )
                     {
-                    result = iMailList->TreeControl()->OfferEventL( aEvent );
-                    break;
+                    if( iFocusedControl != EControlBarComponent )
+                        {
+                        SetControlBarFocusedL();
+                        }
                     }
-                case EControlBarComponent:
+                else
                     {
-                    result = static_cast<CAlfControl*>(
-                        iControlBarControl )->OfferEventL( aEvent );
-                    break;
+                    // 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 )
+                        {
+                        SetTreeListFocusedL();
+                        }
                     }
-                default:
-                    {
-                    break;
-                    }
+                }
+
+            // Offer event to focused control.
+            if( iFocusedControl == EMailListComponent )
+                {
+                result = iMailList->TreeControl()->OfferEventL( aEvent );
+                }
+            else // iFocusedControl == EControlBarComponent
+                {
+                result = static_cast<CAlfControl*>(
+                    iControlBarControl )->OfferEventL( aEvent );
                 }
             }
         return result;
@@ -3601,8 +3724,14 @@
     // Swap right and left controls in mirrored layout
     if ( AknLayoutUtils::LayoutMirrored() )
         {
-        if ( scanCode == EStdKeyRightArrow ) scanCode = EStdKeyLeftArrow;
-        else if ( scanCode == EStdKeyLeftArrow ) scanCode = EStdKeyRightArrow;
+        if ( scanCode == EStdKeyRightArrow )
+            {
+            scanCode = EStdKeyLeftArrow;
+            }
+        else if ( scanCode == EStdKeyLeftArrow )
+            {
+            scanCode = EStdKeyRightArrow;
+            }
         }
 
     // Toggle mark items state when shift key is pressed or released
@@ -3705,10 +3834,9 @@
                 || (scanCode == EStdKeyDeviceA)
                 || (scanCode ==EStdKeyDevice3))
                 {
-                TBool wasActive = iAppUi.StartFocusRemovalTimer();
 
                 // If the focus was not active already, ignore the key press
-                if( !wasActive )
+                if( !iAppUi.SetFocusVisibility( ETrue ) )
                     {
                     return ETrue;
                     }
@@ -3790,7 +3918,7 @@
                                 //Set touchmanager not active for preventing getting events.
                                 DisableMailList(ETrue);
                                 //</cmail>
-                                iAppUi.ShowSortListInPopupL( iCurrentSortCriteria.iField, folderType, this, iSortButton );
+                                iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
                                 }
                             else
                                 {
@@ -3806,7 +3934,6 @@
                     break;
                 case EStdKeyLeftArrow:
                     {
-                    iControlBarControl->MakeSelectorVisible( IsFocusShown() );
                     if( iControlBarControl && iFocusedControl == EMailListComponent )
                         {
                         HandleCommandL( EFsEmailUiCmdGoToSwitchSorting );
@@ -3815,8 +3942,8 @@
                     else if( ( iControlBarControl ) &&
                              ( iFocusedControl == EControlBarComponent  ) )
                         {
-
                         TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
+                        iControlBarControl->MakeSelectorVisible( IsFocusShown() );
                         if ( focusedButtonId == iFolderListButtonId )
                             {
                             if ( iModel->Count() )
@@ -3846,7 +3973,6 @@
                     break;
                 case EStdKeyRightArrow:
                     {
-                    iControlBarControl->MakeSelectorVisible( IsFocusShown() );
                     // Show toolbar if there is data on the list
                     // <cmail>
                     if ( iFocusedControl == EMailListComponent && iModel->Count() )
@@ -3868,6 +3994,7 @@
                              ( iFocusedControl == EControlBarComponent ) )
                         {
                         TInt focusedButtonId = iControlBarControl->GetFocusedButton()->Id();
+                        iControlBarControl->MakeSelectorVisible( IsFocusShown() );
                         if ( focusedButtonId == iFolderListButtonId )
                             {
                             iFocusedControl = EControlBarComponent;
@@ -4137,7 +4264,7 @@
             {
             //Set touchmanager not active for preventing getting events.
             DisableMailList(ETrue);
-            iAppUi.ShowSortListInPopupL( iCurrentSortCriteria.iField, folderType, this, iSortButton );
+            iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
             }
         else
             {
@@ -4217,15 +4344,26 @@
 //  CFSEmailUiMailListVisualiser::HandleTimerFocusStateChange
 // -----------------------------------------------------------------------------
 //
-void CFSEmailUiMailListVisualiser::HandleTimerFocusStateChange( TBool aShow )
+void CFSEmailUiMailListVisualiser::FocusVisibilityChange( TBool aVisible )
     {
     FUNC_LOG;
-    CFsEmailUiViewBase::HandleTimerFocusStateChange( aShow );
+
+    CFsEmailUiViewBase::FocusVisibilityChange( aVisible );
+
     if( iFocusedControl == EControlBarComponent )
         {
-        iControlBarControl->MakeSelectorVisible( aShow );
+        iControlBarControl->MakeSelectorVisible( aVisible );
         }
-    iMailTreeListVisualizer->SetFocusVisibility( aShow );
+
+    if ( iStylusPopUpMenuLaunched && !aVisible )
+    	{
+    	// Do not allow to remove the focus from a list element if the pop up
+    	// menu was just launched.
+    	iStylusPopUpMenuLaunched = EFalse;
+    	return;
+    	}
+
+    iMailTreeListVisualizer->SetFocusVisibility( aVisible );
     }
 
 // ---------------------------------------------------------------------------
@@ -4445,25 +4583,43 @@
 void CFSEmailUiMailListVisualiser::HandleControlBarEvent( TFsControlBarEvent aEvent, TInt aData )
 	{
     FUNC_LOG;
-	if ( aEvent == EEventFocusLostAtBottom ||
-		 aEvent == EEventFocusLostAtSide )
-		{
-       	iFocusedControl = EMailListComponent;
-        TRAP_IGNORE( iMailList->SetFocusedL( ETrue ) );
-		}
-	else if ( aEvent == EEventFocusGained )
-		{
-		}
-	else if ( aEvent == EEventButtonPressed )
-		{
-		// Handle 2 control buttons
-		if ( aData == iFolderListButtonId )
-			{
-			}
-		else if ( aData == iSortButtonId )
-			{
-			}
-		}
+
+    switch( aEvent )
+        {
+        case EEventFocusLostAtBottom:
+        case EEventFocusLostAtSide:
+            {
+            iFocusedControl = EMailListComponent;
+            TRAP_IGNORE( iMailList->SetFocusedL( ETrue ) );
+            break;
+            }
+        case EEventFocusGained:
+            {
+            break;
+            }
+        case EEventButtonPressed:
+            {
+            // Handle 2 control buttons
+            if ( aData == iFolderListButtonId )
+                {
+                }
+            else if ( aData == iSortButtonId )
+                {
+                }
+            break;
+            }
+        case EEventFocusVisibilityChanged:
+            {
+            // Hide focus after button release
+            iAppUi.SetFocusVisibility( EFalse );
+            break;
+            }
+        default:
+            {
+            // No need to handle other events
+            break;
+            }
+        }
 	}
 
 // ---------------------------------------------------------------------------
@@ -4474,35 +4630,27 @@
 void CFSEmailUiMailListVisualiser::CreateControlBarLayoutL()
 	{
     FUNC_LOG;
-    TRect screenRect = iAppUi.ClientRect();
-  	iControlBarControl->SetWidthL( screenRect.Width() );
-    //<cmail>   ??
-    //TInt normalButtonWidth = ( screenRect.Width() - KFirstButtonStartPosX*2 - 10 ) / 2;
-    //</cmail>
-    // Mailbox icon
-  	iImageButtonId = iControlBarControl->AddButtonL( ECBTypeIconOnly );
-    iIconButton = iControlBarControl->ButtonById( iImageButtonId );
-// <cmail> Use layout data instead of hardcoded values
-    const TRect iconButtonRect( iAppUi.LayoutHandler()->GetControlBarMailboxIconRect() );
-    iIconButton->SetPos( iconButtonRect.iTl );
-    iIconButton->SetSize( iconButtonRect.Size() );
-    ControlGroup().AppendL(iIconButton->AsAlfControl());
-// </cmail>
+    iControlBarControl->SetRectL( iAppUi.LayoutHandler()->GetControlBarRect() );
+
+    // New email button
+    iNewEmailButtonId = iControlBarControl->AddButtonL( ECBTypeOneLineLabelIconA );
+    iNewEmailButton = iControlBarControl->ButtonById( iNewEmailButtonId );
+    const TRect mailButtonRect( iAppUi.LayoutHandler()->GetControlBarNewEmailButtonRect() );
+    iNewEmailButton->SetPos( mailButtonRect.iTl );
+    iNewEmailButton->SetSize( mailButtonRect.Size() );
+    ControlGroup().AppendL(iNewEmailButton->AsAlfControl());
 
     // Folder list button
-    iFolderListButtonId = iControlBarControl->AddButtonL( ECBTypeOneLineLabelIconB );
+    iFolderListButtonId = iControlBarControl->AddButtonL( ECBTypeOneLineLabelIconA );
     iFolderListButton = iControlBarControl->ButtonById( iFolderListButtonId );
-// <cmail> Use layout data instead of hardcoded values
     const TRect folderButtonRect( iAppUi.LayoutHandler()->GetControlBarFolderListButtonRect() );
     iFolderListButton->SetPos( folderButtonRect.iTl );
     iFolderListButton->SetSize( folderButtonRect.Size() );
     ControlGroup().AppendL(iFolderListButton->AsAlfControl());
-// </cmail>
 
     // Sort order button
-    iSortButtonId = iControlBarControl->AddButtonL( ECBTypeOneLineLabelIconB );
+    iSortButtonId = iControlBarControl->AddButtonL( ECBTypeOneLineLabelIconA );
     iSortButton = iControlBarControl->ButtonById( iSortButtonId );
-// <cmail> Use layout data instead of hardcoded values
     const TRect sortButtonRect( iAppUi.LayoutHandler()->GetControlBarSortButtonRect() );
     iSortButton->SetPos( sortButtonRect.iTl );
     iSortButton->SetSize( sortButtonRect.Size() );
@@ -4515,6 +4663,17 @@
         {
         horizontalAlign = EAlfAlignHRight;
         }
+
+    // Icons and sort button text
+    iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
+    iNewEmailButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListTextureNewEmailDefaultIcon ) );
+    SetSortButtonTextAndIconL();
+
+    iNewEmailButton->SetElemAlignL(
+        ECBElemIconA,
+        EAlfAlignHCenter,
+        EAlfAlignVCenter );
+
     iFolderListButton->SetElemAlignL(
         ECBElemLabelFirstLine,
         horizontalAlign,
@@ -4523,22 +4682,15 @@
         ECBElemLabelFirstLine,
         horizontalAlign,
         EAlfAlignVCenter );
+    iSortButton->SetElemAlignL(
+        ECBElemIconA,
+        EAlfAlignHCenter,
+        EAlfAlignVCenter );
 
 	// Show the buttons
-	iIconButton->ClearBackgroundColor();
-  	iIconButton->SetDimmed();
+  	iNewEmailButton->ShowButtonL();
     iFolderListButton->ShowButtonL();
     iSortButton->ShowButtonL();
-
-    // Button background images
-	iFolderListButton->ClearBackgroundColor();
- 	iSortButton->ClearBackgroundColor();
-
-	// Icons and sort button text
-	iIconButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
- 	SetSortButtonTextAndIconL();
-
-    //iControlBarControl->SetSelectorBorders(-2,-2,-2,-2 ); // CHECKLATER - commented out 'cause fixing things is hard - check later to replace (?) it
 	}
 
 // ---------------------------------------------------------------------------
@@ -4551,13 +4703,12 @@
     FUNC_LOG;
     TRect screenRect = iAppUi.ClientRect();
 
-	// First set widht and height
-	iControlBarControl->SetHeightL( iAppUi.LayoutHandler()->ControlBarHeight() );
-  	iControlBarControl->SetWidthL( screenRect.Width() );
-
-    const TRect iconButtonRect( iAppUi.LayoutHandler()->GetControlBarMailboxIconRect() );
-    iIconButton->SetPos( iconButtonRect.iTl );
-    iIconButton->SetSize( iconButtonRect.Size() );
+	// First set pos, widht and height
+  	iControlBarControl->SetRectL( iAppUi.LayoutHandler()->GetControlBarRect() );
+
+    const TRect newEmailButtonRect( iAppUi.LayoutHandler()->GetControlBarNewEmailButtonRect() );
+    iNewEmailButton->SetPos( newEmailButtonRect.iTl );
+    iNewEmailButton->SetSize( newEmailButtonRect.Size() );
 
     const TRect folderButtonRect( iAppUi.LayoutHandler()->GetControlBarFolderListButtonRect() );
   	iFolderListButton->SetPos( folderButtonRect.iTl );
@@ -4567,57 +4718,18 @@
    	iSortButton->SetPos( sortButtonRect.iTl );
     iSortButton->SetSize( sortButtonRect.Size() );
 
- 	// Bar background
-	CAlfTexture& barBg = iAppUi.FsTextureManager()->TextureByIndex( EMailListBarBgIcon );
-	TSize cbBgSize;
-	cbBgSize.SetSize( screenRect.Width(), iAppUi.LayoutHandler()->ControlBarHeight() );
-	barBg.Size().SetSize( cbBgSize.iWidth, cbBgSize.iHeight );
-	// <cmail> S60 Skin support
-	//iControlBarControl->SetBackgroundImageL( barBg );
-	//</cmail>
-
-	// Button background
-	CAlfTexture& buttonBg =  iAppUi.FsTextureManager()->TextureByIndex( EListTextureControlButton );
-	//<cmail>
-	buttonBg.Size().SetSize( iAppUi.LayoutHandler()->GetControlBarFolderListButtonSize().iWidth, iAppUi.LayoutHandler()->GetControlBarFolderListButtonSize().iHeight );
-        //</cmail>
-
-    // construct main text display window
-// <cmail> Use layout data instead of hard-coded values
-//    const CFont* font = iEikonEnv->NormalFont();
-//    TFontSpec fontSpec = font->FontSpecInTwips();
-	//fontSpec.iHeight = iAppUi.LayoutHandler()->ControlBarTextHeight();
-
 	TInt var = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
 	TAknLayoutText textLayout;
 	textLayout.LayoutText(TRect(0,0,0,0), AknLayoutScalable_Apps::main_sp_fs_ctrlbar_ddmenu_pane_t1(var));
+	iNewEmailButton->SetTextFontL( textLayout.Font()->FontSpecInTwips() );
  	iFolderListButton->SetTextFontL( textLayout.Font()->FontSpecInTwips() );
  	iSortButton->SetTextFontL( textLayout.Font()->FontSpecInTwips() );
-// </cmail>
-
-	TRgb normalStateButtonTextColor( KRgbBlack );
-    AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
-                     normalStateButtonTextColor, KAknsIIDFsTextColors, EAknsCIFsTextColorsCG6 );
-
-    iFolderListButton->SetNormalTextColor( normalStateButtonTextColor );
-    iFolderListButton->SetFocusedTextColor( iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor() );
-
-    iSortButton->SetNormalTextColor( normalStateButtonTextColor );
-    iSortButton->SetFocusedTextColor( iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor() );
-
-    CAlfImageBrush* folderBtnBrush = iAppUi.FsTextureManager()->NewControlBarButtonBgBrushLC();
- 	iFolderListButton->SetBackgroundImageL( folderBtnBrush );
- 	CleanupStack::Pop( folderBtnBrush );
-
- 	CAlfImageBrush* sortBtnBrush = iAppUi.FsTextureManager()->NewControlBarButtonBgBrushLC();
- 	iSortButton->SetBackgroundImageL( sortBtnBrush );
- 	CleanupStack::Pop( sortBtnBrush );
-
-	iIconButton->ShowButtonL();
+
+ 	UpdateTheme();
+
+	iNewEmailButton->ShowButtonL();
   	iFolderListButton->ShowButtonL();
 	iSortButton->ShowButtonL();
-
-	iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EControlBarDescendingArrowTexture ), ECBElemIconB );
 	}
 
 // ---------------------------------------------------------------------------
@@ -4628,22 +4740,112 @@
 void CFSEmailUiMailListVisualiser::SetSortButtonTextAndIconL()
 	{
     FUNC_LOG;
-	HBufC* buttonText(0);
+
+    // Set button text if necessary
+    HBufC* buttonText = GetSortButtonTextLC();
+
+	if ( !Layout_Meta_Data::IsLandscapeOrientation() )
+		{
+		if ( buttonText )
+			{
+			buttonText->Des().Zero();
+			}
+		}
+
+	if ( buttonText )
+		{
+		iSortButton->SetTextL( *buttonText );
+		}
+	CleanupStack::PopAndDestroy( buttonText );
+
+	// Set icon
+    TFSEmailUiTextures textureIndex( ETextureFirst );
+
 	switch ( iCurrentSortCriteria.iField )
 		{
 		case EFSMailSortBySubject:
 			{
-			buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_SUBJECT );
+			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+						   ESortListSubjectDescTexture :
+						   ESortListSubjectAscTexture;
 			}
 			break;
 		case EFSMailSortByAttachment:
 			{
-			buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_ATTACHMENT );
+			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+						   ESortListAttachmentDescTexture :
+						   ESortListAttachmentAscTexture;
 			}
 			break;
 		case EFSMailSortByFlagStatus:
 			{
-			buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_FLAG );
+			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+						   ESortListFollowDescTexture :
+						   ESortListFollowAscTexture;
+			}
+			break;
+		case EFSMailSortByRecipient:
+		case EFSMailSortBySender:
+			{
+			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+						   ESortListSenderDescTexture :
+						   ESortListSenderAscTexture;
+			}
+			break;
+		case EFSMailSortByPriority:
+			{
+			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+						   ESortListPriorityDescTexture :
+						   ESortListPriorityAscTexture;
+			}
+			break;
+		case EFSMailSortByUnread:
+			{
+			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+						   ESortListUnreadDescTexture :
+						   ESortListUnreadAscTexture;
+			}
+			break;
+		case EFSMailSortByDate:
+		default:
+			{
+			textureIndex = iCurrentSortCriteria.iOrder == EFSMailAscending ?
+						   ESortListDateDescTexture :
+						   ESortListDateAscTexture;
+			}
+			break;
+		}
+
+	iSortButton->SetIconL(
+			iAppUi.FsTextureManager()->TextureByIndex( textureIndex ),
+			ECBElemIconA );
+	}
+
+// ---------------------------------------------------------------------------
+//
+//
+// ---------------------------------------------------------------------------
+//
+HBufC* CFSEmailUiMailListVisualiser::GetSortButtonTextLC()
+	{
+    FUNC_LOG;
+	HBufC* buttonText( 0 );
+
+	switch ( iCurrentSortCriteria.iField )
+		{
+		case EFSMailSortBySubject:
+			{
+			buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_SUBJECT );
+			}
+			break;
+		case EFSMailSortByAttachment:
+			{
+			buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_ATTACHMENT );
+			}
+			break;
+		case EFSMailSortByFlagStatus:
+			{
+			buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_FLAG );
 			}
 			break;
 		case EFSMailSortByRecipient:
@@ -4660,47 +4862,33 @@
 				case EFSDraftsFolder:
 				case EFSOutbox:
 					{
-					buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_RECIPIENT );
+					buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_RECIPIENT );
 					}
 					break;
 				default:
-					buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_SENDER );
+					buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_SENDER );
 					break;
 				}
 			}
 			break;
 		case EFSMailSortByPriority:
 			{
-			buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_PRIORITY );
+			buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_PRIORITY );
 			}
 			break;
 		case EFSMailSortByUnread:
 			{
-			buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_UNREAD );
+			buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_UNREAD );
 			}
 			break;
 		case EFSMailSortByDate:
 		default:
 			{
-			buttonText = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_SORT_BY_DATE );
+			buttonText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_SORT_BY_DATE );
 			}
 			break;
-
 		}
-	if ( buttonText )
-		{
-		CleanupStack::PushL( buttonText );
-		iSortButton->SetTextL( *buttonText );
-		CleanupStack::PopAndDestroy( buttonText );
-		}
-	if ( iCurrentSortCriteria.iOrder == EFSMailAscending )
-		{
-		iSortButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EControlBarAscendingArrowTexture ), ECBElemIconB );
-		}
-	else
-		{
-		iSortButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EControlBarDescendingArrowTexture ), ECBElemIconB );
-		}
+	return buttonText;
 	}
 
 // ---------------------------------------------------------------------------
@@ -5345,21 +5533,21 @@
 
     if ( aListId != KFsTreeNoneID )
         {
-        // Substitute node ID with ID of its first child
-        if ( iMailList->IsNode( aListId ) && iMailList->CountChildren( aListId ) )
-            {
-            aListId = iMailList->Child( aListId, 0 );
-            }
-
         // Find corresponding message from the model
-        for ( TInt i=0 ; i<iModel->Count() ; i++ )
+        const TInt modelCount( iModel->Count() );
+        for( TInt i( 0 ) ; i < modelCount ; ++i )
             {
             CFSEmailUiMailListModelItem* item =
-                static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(i) );
-            if ( item->ModelItemType() == ETypeMailItem &&
-                 aListId == item->CorrespondingListId() )
+                static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( i ) );
+            if ( aListId == item->CorrespondingListId() )
                 {
                 msgId = item->MessagePtr().GetMessageId();
+                // if list id points to separator
+                // set flag on. This is made for improving focus handling.
+                if( item->ModelItemType() == ETypeSeparator )
+                    {
+                    msgId.SetSeparator( ETrue );
+                    }
                 break;
                 }
             }
@@ -5469,15 +5657,27 @@
 	// operator implementation; it doesn't check the iNullId flag at all.
 	if( !aMessageId.IsNullId() )
 	    {
-    	for ( TInt i=0; i<iModel->Count() ; i++ )
+	    const TInt modelCount( iModel->Count() );
+    	for ( TInt i( 0 ); i < modelCount ; ++i )
     		{
     		CFSEmailUiMailListModelItem* item =
-    			static_cast<CFSEmailUiMailListModelItem*>( iModel->Item(i) );
-    		if ( item->ModelItemType() == ETypeMailItem &&
-    		     aMessageId == item->MessagePtr().GetMessageId() )
+                static_cast<CFSEmailUiMailListModelItem*>( iModel->Item( i ) );
+    		if ( aMessageId == item->MessagePtr().GetMessageId() )
     			{
-    			idx = i;
-    			break;
+    			TModelItemType itemType = item->ModelItemType();
+    			TBool separator( aMessageId.IsSeparator() );
+
+    			// Because separator and the first message after separator
+    			// have same message id, we need to separate these cases
+    			// and that is made with separator flag which is stored to
+    			// TFSMailMsgId object. If separator flag is on item need to be
+    			// separator if it is not on item needs to be mail item.
+    			if( ( separator && itemType == ETypeSeparator ) ||
+    			    ( !separator && itemType == ETypeMailItem ) )
+                    {
+                    idx = i;
+                    break;
+                    }
     			}
     		}
         }
@@ -5610,7 +5810,7 @@
                 if ( iModel->Count() )
 </cmail> */
                     {
-                    iAppUi.ShowSortListInPopupL( iCurrentSortCriteria.iField, folderType, this, iSortButton );
+                    iAppUi.ShowSortListInPopupL( iCurrentSortCriteria, folderType, this, iSortButton );
                     }
 				}
 				return;
@@ -6377,8 +6577,10 @@
 	// Set the position for the popup
 	iStylusPopUpMenu->SetPosition( ActionMenuPosition() );
 
-	// Display the popup
+	// Display the popup and set the flag to indicate that the menu was
+	// launched.
 	iStylusPopUpMenu->ShowMenu();
+	iStylusPopUpMenuLaunched = ETrue;
 	}
 
 // ---------------------------------------------------------------------------
@@ -6631,8 +6833,6 @@
 	   					//If sync was started by user, show the synchronisation indicator
 	   					if ( iManualMailBoxSync )
 	   						{
-							CFSMailBox* mb = iAppUi.GetActiveMailbox();
-			   				TDesC* mbName = &mb->GetName();
 			   		     	ManualMailBoxSync(EFalse);
 	   						}
 		   				}
@@ -6643,17 +6843,40 @@
 		}
 	}
 
-void CFSEmailUiMailListVisualiser::TreeListEventL( const TFsTreeListEvent aEvent, const TFsTreeItemId aId )
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+//
+void CFSEmailUiMailListVisualiser::TreeListEventL(
+    const TFsTreeListEvent aEvent, const TFsTreeItemId aId )
 	{
     FUNC_LOG;
-	if ( aEvent == MFsTreeListObserver::EFsTreeListItemWillGetFocused && aId != KFsTreeNoneID )
-	    {//EFalse - do not call UpdateItem directly, new text will be drawn when item gets focus
-        UpdatePreviewPaneTextIfNecessaryL( aId, EFalse );
-	    }
-	else if ( aEvent == MFsTreeListObserver::EFsTreeListItemTouchFocused )
-	    {
-
-	    }
+    switch( aEvent )
+        {
+        case EFsTreeListItemWillGetFocused:
+            {
+            if( aId != KFsTreeNoneID )
+                {
+                UpdatePreviewPaneTextIfNecessaryL( aId, EFalse );
+                }
+            break;
+            }
+        case EFsTreeListItemTouchFocused:
+            {
+            break;
+            }
+        case EFsFocusVisibilityChange:
+            {
+            iAppUi.SetFocusVisibility( EFalse );
+            break;
+            }
+        default:
+            {
+            // Do not handle other events
+            break;
+            }
+
+        }
 	}
 
 // ---------------------------------------------------------------------------
@@ -6736,7 +6959,7 @@
 		{
 		CleanupStack::PushL( mailBoxIcon );
         //<cmail>
-		TSize defaultIconSize(iAppUi.LayoutHandler()->GetControlBarMailboxIconSize());
+		TSize defaultIconSize(iAppUi.LayoutHandler()->GetControlBarMailboxIconRect().Size());
         //</cmail>
     	AknIconUtils::SetSize(mailBoxIcon->Bitmap(), defaultIconSize);
 	    AknIconUtils::SetSize(mailBoxIcon->Mask(), defaultIconSize);
@@ -6749,12 +6972,12 @@
 	    iMailBoxIconTexture = &iAppUi.FsTextureManager()->TextureByMailboxIdL( iAppUi.GetActiveMailboxId().PluginId(),
 	    		                                                               iAppUi.GetActiveMailboxId().Id(),
 	    		                                                               defaultIconSize );
-		iIconButton->SetIconL( *iMailBoxIconTexture );
+		iFolderListButton->SetIconL( *iMailBoxIconTexture );
 		CleanupStack::PopAndDestroy( mailBoxIcon );
 		}
 	else
 		{
-		iIconButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
+		iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) );
 		}
 	}
 
@@ -6953,7 +7176,8 @@
 	    ChangeReadStatusOfHighlightedL( ETrue );
         aFoundPreviousMsgId = MsgIdFromIndex( prevIdx );
 	    ret = KErrNone;
-	    }
+	    }	
+	
 	if ( ret == KErrNone )
 		{
 		OpenHighlightedMailL();
@@ -6961,6 +7185,27 @@
 	return ret;
 	}
 
+TInt CFSEmailUiMailListVisualiser::MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId )
+	{
+	FUNC_LOG;
+	TInt ret(KErrNotFound);	
+	
+	TInt idx = ItemIndexFromMessageId( aFoundPreviousMsgId );	
+	if ( idx >= 0 )
+		{		
+		// Focus the previous message
+		iMailTreeListVisualizer->SetFocusedItemL( iTreeItemArray[idx].iListItemId, EFalse );
+		ChangeReadStatusOfHighlightedL( ETrue );
+		ret = KErrNone;		
+		}
+
+	if ( ret == KErrNone )
+		{
+		OpenHighlightedMailL();
+		}
+	
+	return ret;
+	}
 
 void CFSEmailUiMailListVisualiser::ManualMailBoxSync( TBool aManualMailBoxSync )
 	{
@@ -7014,6 +7259,11 @@
         }
     else
         {
+        if ( iStylusPopUpMenuLaunched )
+        	{
+        	return;
+        	}
+
         iMailList->SetFocusedL( EFalse );
         TInt focusedBtnId = KErrNotFound;
         MFsControlButtonInterface* focusedBtn = iControlBarControl->GetFocusedButton();
@@ -7147,7 +7397,7 @@
 	    	{
 	  		CFSEmailUiMailListModelItem* item =
 				static_cast<CFSEmailUiMailListModelItem*>(iMailListVisualiser->iModel->Item( highlightedIndexBeforeUpdate ) );
-			if ( item->ModelItemType() == ETypeMailItem )
+			if ( item && item->ModelItemType() == ETypeMailItem )
 				{
 			    msgIdBeforeRefresh = item->MessagePtr().GetMessageId();
 				}
--- a/emailuis/emailui/src/FreestyleEmailUiMailViewerRichText.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiMailViewerRichText.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -12,7 +12,7 @@
 * Contributors:
 *
 * Description: FreestyleEmailUi mail viewer rich text implementation
-* Version    : %version: 47 %
+* Version    : %version: 48 %
 *
 */
 
@@ -423,8 +423,8 @@
                 imageImage,
                 mask,
                 iconFile,
-                EMbmFreestyleemailuiQgn_indi_cmail_viewer_follow_up,
-                EMbmFreestyleemailuiQgn_indi_cmail_viewer_follow_up_mask,
+                EMbmFreestyleemailuiQgn_indi_navi_follow_up,
+                EMbmFreestyleemailuiQgn_indi_navi_follow_up_mask,
                 KRgbBlack );
 	        AknIconUtils::DisableCompression( imageImage );
 	        AknIconUtils::DisableCompression( mask );
@@ -441,8 +441,8 @@
                 imageImage,
                 mask,
                 iconFile,
-                EMbmFreestyleemailuiQgn_indi_cmail_viewer_follow_up_complete,
-                EMbmFreestyleemailuiQgn_indi_cmail_viewer_follow_up_complete_mask,
+                EMbmFreestyleemailuiQgn_indi_navi_follow_up_complete,
+                EMbmFreestyleemailuiQgn_indi_navi_follow_up_complete_mask,
                 KRgbBlack );
 	        AknIconUtils::DisableCompression( imageImage );
 	        AknIconUtils::DisableCompression( mask );
--- a/emailuis/emailui/src/FreestyleEmailUiMsgDetailsVisualiser.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiMsgDetailsVisualiser.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -12,7 +12,7 @@
 * Contributors:
 *
 *  Description : FreestyleEmailUi message details view implementation
-*  Version     : %version: 44 %
+*  Version     : %version: 45 %
 *
 */
 
@@ -1030,6 +1030,7 @@
     aItemVisualizer = CFsTreePlainOneLineItemVisualizer::NewL(*iTreeList->TreeControl());
     CleanupStack::PushL( aItemVisualizer );
 	aItemVisualizer->SetExtendable( EFalse ); // One line items are obviously not extendable
+	aItemVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EFolderLayout );
 
     SetItemVisualizerCommonProperties( *aItemVisualizer );
 	}
@@ -1049,6 +1050,7 @@
     CleanupStack::PushL( aItemVisualizer );
 	aItemVisualizer->SetExtendable( ETrue ); // All two line items are extendable
 	aItemVisualizer->SetMenu( NULL );
+	aItemVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EFolderLayout );
 
     SetItemVisualizerCommonProperties( *aItemVisualizer );
 	}
@@ -1056,17 +1058,14 @@
 void CFSEmailUiMsgDetailsVisualiser::SetItemVisualizerCommonProperties( MFsTreeItemVisualizer& aItemVisualizer )
 	{
     FUNC_LOG;
-    aItemVisualizer.SetSize(TSize(iScreenRect.Width(), iListItemHeight));
-	aItemVisualizer.SetExtendedSize(TSize(iScreenRect.Width(), 2*iListItemHeight));
+    aItemVisualizer.SetSize(TSize(iScreenRect.Width(), iAppUi.LayoutHandler()->OneLineListItemHeight()));
+	aItemVisualizer.SetExtendedSize(TSize(iScreenRect.Width(), iAppUi.LayoutHandler()->TwoLineListItemHeight()));
 
   	// Set correct skin text colors for the list items  
    	TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor();
    	TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
     aItemVisualizer.SetFocusedStateTextColor( focusedColor );
-    aItemVisualizer.SetNormalStateTextColor( normalColor );
-
-	// Set font size
-	aItemVisualizer.SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips() );		
+    aItemVisualizer.SetNormalStateTextColor( normalColor );	
 	}
 
 void CFSEmailUiMsgDetailsVisualiser::CreatePlainNodeLC2( const TDesC& aItemDataBuff,
@@ -1109,7 +1108,7 @@
 	
 	// Temporary fix for EASV-7GJFVD
 	//aNodeVisualizer.SetBackgroundColorL( iAppUi.LayoutHandler()->ListNodeBackgroundColor() );
-	
+		
 	}
 
 TFsTreeItemId CFSEmailUiMsgDetailsVisualiser::AppendHeadingToListL( TInt aResourceId )
@@ -1586,7 +1585,7 @@
         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, iScreenRect );
         iScreenRect.SetRect( 0, 0, iScreenRect.Width(), iScreenRect.Height() );
 
-        iListItemHeight = iAppUi.LayoutHandler()->OneLineListItemHeight();
+
         iListNodeHeight = iAppUi.LayoutHandler()->OneLineListNodeHeight();        
         }
 	}
--- a/emailuis/emailui/src/FreestyleEmailUiSearchListVisualiser.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiSearchListVisualiser.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -53,6 +53,7 @@
 #include <alf/alfcommand.h>
 #include <aknnotewrappers.h>
 // <cmail>
+#include <layoutmetadata.cdl.h>
 #include <aknlayoutscalable_apps.cdl.h>
 // </cmail>
 #include <featmgr.h>
@@ -431,6 +432,7 @@
 
 	// <cmail> Touch
 	iSearchList->SetFocusedL(ETrue);
+	FocusVisibilityChange( iAppUi.IsFocusShown() );
 	// </cmail>
  	}
 
@@ -734,6 +736,11 @@
     CFsEmailUiViewBase::HandleDynamicVariantSwitchL( aType );
     if ( iFirstStartCompleted ) // Safety
         {
+        if ( aType == EScreenLayoutChanged )
+            {
+            SetStatusBarLayout();
+            }
+    
         if ( iSearchTreeListVisualizer )
             {
             TRgb normalColor = iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
@@ -760,13 +767,14 @@
     }
 
 // -----------------------------------------------------------------------------
-//  CFSEmailUiSearchListVisualiser::HandleTimerFocusStateChange
+//  CFSEmailUiSearchListVisualiser::FocusVisibilityChange
 // -----------------------------------------------------------------------------
 //
-void CFSEmailUiSearchListVisualiser::HandleTimerFocusStateChange( TBool aShow )
+void CFSEmailUiSearchListVisualiser::FocusVisibilityChange(
+        TBool aVisible )
     {
-    CFsEmailUiViewBase::HandleTimerFocusStateChange( aShow );
-    iSearchTreeListVisualizer->SetFocusVisibility( aShow );
+    CFsEmailUiViewBase::FocusVisibilityChange( aVisible );
+    iSearchTreeListVisualizer->SetFocusVisibility( aVisible );
     }
 
 // ---------------------------------------------------------------------------
@@ -776,11 +784,18 @@
 //
 void CFSEmailUiSearchListVisualiser::SetStatusBarLayout()
 	{
-	if ( StatusPane()->CurrentLayoutResId() != R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT )
-		{
-		TRAP_IGNORE(
-			StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT ));
-		}
+    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 CFSEmailUiSearchListVisualiser::HandleCommandL( TInt aCommand )
@@ -909,6 +924,11 @@
 			}
             break;
         case EAknSoftkeyOpen:
+    		if (!iAppUi.IsFocusShown())
+    			{
+    			iAppUi.SetFocusVisibility( ETrue);
+    			break;
+    			}
         case EFsEmailUiCmdOpen:
         	{
  			if ( iSearchList->Count() )
@@ -1152,7 +1172,22 @@
             if ( scanCode == EStdKeyRightArrow ) scanCode = EStdKeyLeftArrow;
             else if ( scanCode == EStdKeyLeftArrow ) scanCode = EStdKeyRightArrow;
             }
-        
+        // Handle possible focus visibility change
+		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 ) )
+                {
+                return ETrue;
+                }
+            
+			}
         switch ( scanCode )
             {
             case EStdKeyDevice3: // CENTER CLICK
@@ -1242,7 +1277,6 @@
 	// There's no need to mirror anything manually here.
 	
 	// BAR BACGROUND IMAGE
-    //<cmail> platform layout changes
     TRect contBarRect = iAppUi.LayoutHandler()->GetControlBarRect();
     TPoint& tl( contBarRect.iTl );
     iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 0, 
@@ -1254,23 +1288,8 @@
         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
         TAlfTimedPoint( br.iX, br.iY ));
-    //</cmail>
-
-	// LOOKING GLASS IMAGE
-    //<cmail> search magnifier icon removed from cmail
-    /*TRect searchIconRect( iAppUi.LayoutHandler()->GetControlBarMailboxIconRect() );
-    const TPoint& tl( searchIconRect.iTl );
-    iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 1, 
-        EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
-        EAlfAnchorMetricRelativeToSize, EAlfAnchorMetricRelativeToSize,
-        TAlfTimedPoint(0, 0 ));
-    iScreenAnchorLayout->SetAnchor(EAlfAnchorBottomRight, 1, 
-        EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
-        EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
-        TAlfTimedPoint(KSearchIconWidth, iAppUi.LayoutHandler()->ControlBarHeight()));*/	
         
 	// TEXT
-    //<cmail> platform layout changes
     TRect textRect =  iAppUi.LayoutHandler()->GetSearchListHeaderTextLayout().TextRect();
     tl = textRect.iTl;
     iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 1, 
@@ -1282,10 +1301,8 @@
         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
         TAlfTimedPoint( br.iX, br.iY ));
-    //</cmail>
 
-    //<cmail> platform layout changes
-    TRect listRect = iAppUi.LayoutHandler()->GetListRect();
+    TRect listRect = iAppUi.LayoutHandler()->GetListRect( ETrue );
     iScreenAnchorLayout->SetAnchor(EAlfAnchorTopLeft, 2, 
         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
@@ -1294,7 +1311,6 @@
         EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
         EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
         TAlfTimedPoint(listRect.iBr.iX, listRect.iBr.iY));
-    //</cmail>
 	}
 
 
@@ -2282,6 +2298,7 @@
         aFoundPreviousMsgId = MsgIdFromIndex( prevIdx );
 	    ret = KErrNone;
 	    }
+	
 	if ( ret == KErrNone )
 		{
 		OpenHighlightedMailL();
@@ -2289,6 +2306,27 @@
 	return ret;
 	}
 
+TInt CFSEmailUiSearchListVisualiser::MoveToPreviousMsgAfterDeleteL( TFSMailMsgId aFoundPreviousMsgId )
+	{
+	FUNC_LOG;
+	TInt ret(KErrNotFound);	
+	
+	TInt idx = ItemIndexFromMessageId( aFoundPreviousMsgId );	
+	if ( idx >= 0 )
+		{		
+		// Focus the previous message
+		iSearchTreeListVisualizer->SetFocusedItemL( iSearchListItemArray[idx].iSearchListItemId );
+		ChangeReadStatusOfHighlightedL( ETrue );
+		ret = KErrNone;		
+		}
+
+	if ( ret == KErrNone )
+		{
+		OpenHighlightedMailL();
+		}
+	
+	return ret;
+	}
 
 	// Helper functions to get highlighted message id and folder id
 TFSMailMsgId CFSEmailUiSearchListVisualiser::HighlightedMessageFolderId()
@@ -2348,6 +2386,11 @@
             SetMskL(); 
             break;
             }            
+        case MFsTreeListObserver::EFsFocusVisibilityChange:
+        	{
+        	iAppUi.SetFocusVisibility( EFalse );
+        	break;
+        	}
         case MFsTreeListObserver::EFsTreeListItemTouchFocused:
         default:
             //Just ignore rest of events
--- a/emailuis/emailui/src/FreestyleEmailUiSettingsList.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiSettingsList.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -558,6 +558,10 @@
             iPIMListActivation = ETrue;
             SetSelectedMainListIndex( index );
             CreatePluginPIMListL( iSelectedPluginSettings );
+            // Update the title pane, needed for touch support
+            HBufC* text = CreateTitlePaneTextLC();
+            iAppUi.SetTitlePaneTextL( *text );
+            CleanupStack::PopAndDestroy( text );
             }
         else // index < 0; this should never happen
             {
@@ -1292,7 +1296,6 @@
                 {
                 // get mailbox name and insert it to listBox
                 CFSMailBox* mailBox = mailBoxes[i];
-                TDesC& name = mailBox->GetName();
                 // Does mailbox have settings plugin
                 if ( mailBox->GetSettingsUid() != TUid::Null() )
                     {
--- a/emailuis/emailui/src/FreestyleEmailUiTextureManager.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiTextureManager.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -201,25 +201,29 @@
 	{
     FUNC_LOG;
 
-	// Use FS specific skin ID if it's found, otherwise use general list highlight.
-	// This need to be checked before CHuiFrameBrush::NewL as it never leaves
-	// even if the skin ID is not found. Another option would be to try first with
-	// FS specific skin ID, TRAP SetFrameRectsL-function call, and if it leaves,
-	// then recreate frame brush with general skin ID and recall SetFrameRectsL.
+	// Use FS specific skin ID if it's found, otherwise use general list
+    // highlight. This need to be checked before CHuiFrameBrush::NewL as it
+    // never leaves even if the skin ID is not found. Another option would be
+    // to try first with FS specific skin ID, TRAP SetFrameRectsL-function
+    // call, and if it leaves, then recreate frame brush with general skin ID
+    // and recall SetFrameRectsL.
 	TAknsItemID skinId = KAknsIIDQgnFsList;
-	CAknsItemData* temp = AknsUtils::SkinInstance()->GetCachedItemData( skinId );
+	CAknsItemData* temp =
+		AknsUtils::SkinInstance()->GetCachedItemData( skinId );
+
 	if( !temp )
 		{
 		skinId = KAknsIIDQsnFrList;
 		}
 
-	CAlfFrameBrush* frameBrush(0);
+	CAlfFrameBrush* frameBrush( 0 );
 	frameBrush = CAlfFrameBrush::NewLC( *iEnv, skinId );
 
-	TRect testOuterRect(0,0,300,80);
-	TRect testInnerRect(4,4,296,76);
+	TRect outerRect( 0, 0, 300, 80 );
+	TRect innerRect( outerRect ); 
+	innerRect.Shrink( KSelectorBorderWidth, KSelectorBorderWidth );
 
-	frameBrush->SetFrameRectsL(testInnerRect, testOuterRect);
+	frameBrush->SetFrameRectsL( innerRect, outerRect );
 
 	return frameBrush;
 	}
@@ -235,15 +239,23 @@
 CAlfFrameBrush* CFreestyleEmailUiTextureManager::NewListSelectorBrushL()
     {
     FUNC_LOG;
-    if(!iNewFrameBrush)
-        {
-        iNewFrameBrush = CAlfFrameBrush::NewLC( *iEnv, KAknsIIDQsnFrList, -2, -1 );
-        CleanupStack::Pop( iNewFrameBrush ); // frameBrush
-    const TRect testOuterRect(0,0,300,80);
-    TRect testInnerRect( testOuterRect );
-    testInnerRect.Shrink( 10, 10 );
-        iNewFrameBrush->SetFrameRectsL(testInnerRect, testOuterRect);
-        }
+
+    if ( iNewFrameBrush )
+    	{
+    	// A brush is already constructed. Do return it.
+    	return iNewFrameBrush;
+    	}
+
+    iNewFrameBrush = CAlfFrameBrush::NewL( *iEnv, KAknsIIDQsnFrList,
+										   /* aEdgeOffsetX */ -2,
+										   /* aEdgeOffsetY */ -1 );
+
+    const TRect outerRect( 0, 0, 300, 80 );
+    TRect innerRect( outerRect );
+    innerRect.Shrink( 10, 10 );
+
+    iNewFrameBrush->SetFrameRectsL( innerRect, outerRect);
+
     return iNewFrameBrush;
     }
 // </cmail>
@@ -633,6 +645,16 @@
 			scalemode = EAspectRatioNotPreserved;
 			}
 			break;
+		case EListTextureNewEmailDefaultIcon:
+			{
+	        TInt tempsize = iAppUi->LayoutHandler()->ListControlBarMailboxDefaultIconSize();
+	        iconSize.SetSize( tempsize, tempsize );
+	        AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+	        	EMbmFreestyleemailuiQgn_indi_tb_email_new,
+	        	EMbmFreestyleemailuiQgn_indi_tb_email_new_mask );
+			}
+			break;
+
 		// MESSAGE TEXTURE READING STARTS HERE
 	 	//
 		case EMessageReadIcon:
@@ -1012,8 +1034,8 @@
                 bitmap,
                 mask,
                 iconFileName,
-                EMbmFreestyleemailuiQgn_indi_cmail_viewer_follow_up,
-                EMbmFreestyleemailuiQgn_indi_cmail_viewer_follow_up_mask,
+                EMbmFreestyleemailuiQgn_indi_navi_follow_up,
+                EMbmFreestyleemailuiQgn_indi_navi_follow_up_mask,
                 KRgbBlack );
 			}
 			break;
@@ -1029,8 +1051,8 @@
                 bitmap,
                 mask,
                 iconFileName,
-                EMbmFreestyleemailuiQgn_indi_cmail_viewer_follow_up_complete,
-                EMbmFreestyleemailuiQgn_indi_cmail_viewer_follow_up_complete_mask,
+                EMbmFreestyleemailuiQgn_indi_navi_follow_up_complete,
+                EMbmFreestyleemailuiQgn_indi_navi_follow_up_complete_mask,
                 KRgbBlack );
 			}
 			break;
@@ -1283,6 +1305,126 @@
 			}
 			break;
 
+		// FOLDER LIST ICON READING STOPS HERE
+		//
+			
+		// SORT LIST ICON READING STARTS HERE
+		//
+        case ESortListAttachmentAscTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_attach_asc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_attach_asc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListAttachmentAscTexture );
+			}
+			break;
+        case ESortListAttachmentDescTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_attach_desc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_attach_desc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListAttachmentDescTexture );
+			}
+			break;
+        case ESortListDateAscTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_date_asc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_date_asc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListDateAscTexture );
+			}
+			break;
+        case ESortListDateDescTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_date_desc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_date_desc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListDateDescTexture );
+			}
+			break;
+        case ESortListFollowAscTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_follow_asc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_follow_asc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListFollowAscTexture );
+			}
+			break;
+        case ESortListFollowDescTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_follow_desc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_follow_desc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListFollowDescTexture );
+			}
+			break;
+        case ESortListPriorityAscTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_priority_asc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_priority_asc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListPriorityAscTexture );
+			}
+			break;
+        case ESortListPriorityDescTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_priority_desc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_priority_desc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListPriorityDescTexture );
+			}
+			break;
+        case ESortListSenderAscTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_sender_asc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_sender_asc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListSenderAscTexture );
+			}
+			break;
+        case ESortListSenderDescTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_sender_desc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_sender_desc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListSenderDescTexture );
+			}
+			break;
+        case ESortListSubjectAscTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_subject_asc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_subject_asc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListSubjectAscTexture );
+			}
+			break;
+        case ESortListSubjectDescTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_subject_desc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_subject_desc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListSubjectDescTexture );
+			}
+			break;
+        case ESortListUnreadAscTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_unread_asc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_unread_asc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListUnreadAscTexture );
+			}
+			break;
+        case ESortListUnreadDescTexture:
+			{
+			AknIconUtils::CreateIconL( bitmap, mask, iconFileName,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_unread_desc,
+									   EMbmFreestyleemailuiQgn_prop_email_sort_unread_desc_mask );
+			iconSize = iAppUi->LayoutHandler()->FolderListIconSize( aId == ESortListUnreadDescTexture );
+			}
+			break;
+		// SORT LIST ICON READING STOPS HERE
+		//
+			
 		// ATTACHMENT ICONS STARTS HERE
 		//
         //<cmail>
@@ -1775,6 +1917,14 @@
 			break;
 		case EListTextureControlButton: ; break;
 		case EListTextureMailboxDefaultIcon: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EListTextureMailboxDefaultIcon, this, EAlfTextureFlagDefault); break;
+		case EListTextureNewEmailDefaultIcon:
+		    {
+		    iTextures[aTextureId] =
+				&CAlfStatic::Env().TextureManager().CreateTextureL(
+					EListTextureNewEmailDefaultIcon, this,
+					EAlfTextureFlagDefault ); 
+		    break;
+		    }
 		case EListControlBarMailboxDefaultIcon: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EListControlBarMailboxDefaultIcon, this, EAlfTextureFlagDefault); break;
 		case EBackgroundTextureViewerHeading: ; break;
 		case EBackgroundTextureBar: ; break;
@@ -1915,6 +2065,22 @@
         case EFolderListServerFoldersTexturePopup: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EFolderListServerFoldersTexturePopup, this, EAlfTextureFlagRetainResolution); break;
         case EFolderListEmailAccountTexturePopup: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EFolderListEmailAccountTexturePopup, this, EAlfTextureFlagRetainResolution); break;
 
+        // SORT LIST ICONS
+        case ESortListAttachmentAscTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListAttachmentAscTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListAttachmentDescTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListAttachmentDescTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListDateAscTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListDateAscTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListDateDescTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListDateDescTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListFollowAscTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListFollowAscTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListFollowDescTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListFollowDescTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListPriorityAscTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListPriorityAscTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListPriorityDescTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListPriorityDescTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListSenderAscTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListSenderAscTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListSenderDescTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListSenderDescTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListSubjectAscTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListSubjectAscTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListSubjectDescTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListSubjectDescTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListUnreadAscTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListUnreadAscTexture, this, EAlfTextureFlagRetainResolution); break;
+        case ESortListUnreadDescTexture: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( ESortListUnreadDescTexture, this, EAlfTextureFlagRetainResolution); break;
+                
 		// STATUS INDICATOR ICONS
 		case EStatusTextureSynchronising: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EStatusTextureSynchronising, this, EAlfTextureFlagRetainResolution); break;
 		case EStatusTextureConnected: iTextures[aTextureId] = &CAlfStatic::Env().TextureManager().CreateTextureL( EStatusTextureConnected, this, EAlfTextureFlagRetainResolution); break;
--- a/emailuis/emailui/src/FreestyleEmailUiUtilities.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiUtilities.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -1014,8 +1014,8 @@
         iconBitmap,
         iconMaskBitmap,
         iconFileName,
-        EMbmFreestyleemailuiQgn_indi_cmail_viewer_follow_up,
-        EMbmFreestyleemailuiQgn_indi_cmail_viewer_follow_up_mask,
+        EMbmFreestyleemailuiQgn_indi_navi_follow_up,
+        EMbmFreestyleemailuiQgn_indi_navi_follow_up_mask,
         KRgbBlack );
 	AknIconUtils::SetSize(iconBitmap, defaultIconSize );
     AknIconUtils::SetSize(iconMaskBitmap, defaultIconSize);
@@ -1034,8 +1034,8 @@
         iconBitmap,
         iconMaskBitmap,
         iconFileName,
-        EMbmFreestyleemailuiQgn_indi_cmail_viewer_follow_up_complete,
-        EMbmFreestyleemailuiQgn_indi_cmail_viewer_follow_up_complete_mask,
+        EMbmFreestyleemailuiQgn_indi_navi_follow_up_complete,
+        EMbmFreestyleemailuiQgn_indi_navi_follow_up_complete_mask,
         KRgbBlack );
 	AknIconUtils::SetSize(iconBitmap, defaultIconSize );
     AknIconUtils::SetSize(iconMaskBitmap, defaultIconSize);
--- a/emailuis/emailui/src/FreestyleEmailUiViewBase.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleEmailUiViewBase.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 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"
@@ -15,7 +15,7 @@
 *                The class is not intended for instantation.
 *
 */
- 
+
 
 // <cmail> SF
 #include "emailtrace.h"
@@ -41,7 +41,7 @@
 
 // ---------------------------------------------------------------------------
 //
-CFsEmailUiViewBase::CFsEmailUiViewBase( CAlfControlGroup& aControlGroup, 
+CFsEmailUiViewBase::CFsEmailUiViewBase( CAlfControlGroup& aControlGroup,
         CFreestyleEmailUiAppUi& aAppUi )
     : iControlGroup( aControlGroup ), iAppUi( aAppUi )
     {
@@ -67,13 +67,12 @@
 	                                  TUid aCustomMessageId,
 	                                  const TDesC8& aCustomMessage )
     {
-    FUNC_LOG;    
+    FUNC_LOG;
     SetViewActive( ETrue );
-    //<cmail>
+    SetStatusBarLayout();
     iAppUi.StatusPane()->DrawNow();
-    //</cmail>
-    iFocusVisible = iAppUi.IsTimerFocusShown();
-    
+    iFocusVisible = iAppUi.IsFocusShown();
+
     // fix view stack in case of external activation
     if ( aPrevViewId.iAppUid != KFSEmailUiUid )
         {
@@ -98,20 +97,18 @@
             }
         previousView->DoTransition( ETrue ); // fade out prev view
         }
-    
+
     // Clear the flag of long transition effect
     SetNextTransitionOutLong( EFalse );
     UpdateToolbarL();
 
-    SetStatusBarLayout();
-
     // Make sure Alfred display is of correct size (there is some problems with toolbar)
     TRect metricsRect;
     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, metricsRect);
     CAlfEnv::Static()->PrimaryDisplay().ForceSetVisibleArea(metricsRect);
-    
+
     // Finally call child classes activation method
-    TRAPD( error, ChildDoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage) );    
+    TRAPD( error, ChildDoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage) );
     if ( !error )
         {
         // View activated succesfully. Change visible control group, but not
@@ -162,7 +159,7 @@
 
 // ---------------------------------------------------------------------------
 //
-void CFsEmailUiViewBase::GetInitiallyDimmedItemsL( 
+void CFsEmailUiViewBase::GetInitiallyDimmedItemsL(
         const TInt /*aResourceId*/, RArray<TInt>& aDimmedItems ) const
     {
     FUNC_LOG;
@@ -222,21 +219,21 @@
 void CFsEmailUiViewBase::DoDeactivate()
     {
     FUNC_LOG;
-    SetViewActive( EFalse );    
+    SetViewActive( EFalse );
 
     HideToolbar();
-   
+
     // Make control group ignore input and hide it if it's not already fading out.
     DeactivateControlGroup();
 
     // do view specific deactivation
     ChildDoDeactivate();
-    
+
     // Return to another app in case this view was activated externally
     if ( iSendToBackgroundOnDeactivation )
         {
         iSendToBackgroundOnDeactivation = EFalse;
-        
+
         // Try to bring calling external app into foreground if found
         TApaTaskList taskList( iEikonEnv->WsSession() );
         TApaTask prevAppTask = taskList.FindApp( iPreviousAppUid );
@@ -271,11 +268,11 @@
 // some special tricks for transition effects
 //
 void CFsEmailUiViewBase::DoTransitionEffect( TBool aDirectionOut )
-    {  
+    {
     FUNC_LOG;
     RPointerArray<CAlfVisual> layoutArray;
     TRAP_IGNORE( GetParentLayoutsL( layoutArray ) );
-    
+
     // For views that return valid parent layout(s), use the fade effect,
     // for all other views, use the showing/hiding of control groups
     for ( TInt i = 0 ; i < layoutArray.Count() ; i++ )
@@ -290,7 +287,7 @@
                 {
                 FadeVisual( layoutArray[i], ETrue, ETrue );
                 }
-            
+
             FadeVisual( layoutArray[i], aDirectionOut );
             }
         }
@@ -315,13 +312,13 @@
         CAlfVisual* aVisual,
         TBool aFadeDirectionOut,
         TBool aImmediate /*= EFalse*/)
-    {   
+    {
     FUNC_LOG;
     // Check that we are not exiting and is fade effect activated
     if ( !iAppUi.AppUiExitOngoing() )
         {
         TInt effectTime = 0;
-        
+
         if ( !aImmediate && iAppUi.LayoutHandler() )
             {
             if( aFadeDirectionOut )
@@ -333,18 +330,18 @@
                 effectTime = iAppUi.LayoutHandler()->ViewFadeInEffectTime();
                 }
             }
-        
+
         if ( aFadeDirectionOut && IsNextTransitionOutLong() )
             {
             effectTime = effectTime * 2;
             }
-    
+
         // Initialize for out fading
         TAlfTimedValue timedValue( 0, effectTime );
         // Check value and initialze for in fading if set
         if ( !aFadeDirectionOut )
             {
-            timedValue.SetTarget( 1, effectTime ); 
+            timedValue.SetTarget( 1, effectTime );
             }
         aVisual->SetOpacity( timedValue );
         }
@@ -376,16 +373,16 @@
     if ( !iAppUi.AppUiExitOngoing() )
         {
         TAlfGroupCommand showCmd( ControlGroup(), EAlfOpShow, &iAppUi.Display() );
-        iAppUi.AlfEnv().Send( showCmd, aDelay );            
+        iAppUi.AlfEnv().Send( showCmd, aDelay );
         ControlGroup().SetAcceptInput( ETrue );
-    
+
         // Status indicator is "always on top" while visible
         /*if ( iAppUi.StatusIndicator() && iAppUi.StatusIndicator()->IsVisible() )
             {
             CAlfControlGroup& indicatorGroup = iAppUi.AlfEnv().ControlGroup( KStatusIndicatorDisplayGroup );
             TAlfGroupCommand indicShowCmd( indicatorGroup, EAlfOpShow, &iAppUi.Display() );
-            iAppUi.AlfEnv().Send( indicShowCmd, 0 );        
-            indicatorGroup.SetAcceptInput( EFalse ); 
+            iAppUi.AlfEnv().Send( indicShowCmd, 0 );
+            indicatorGroup.SetAcceptInput( EFalse );
             }*/
         }
     }
@@ -396,12 +393,12 @@
     {
     FUNC_LOG;
     const TReal32 KDelta = 0.01; // floating point comparison tolerance
-    
+
     if ( !iAppUi.AppUiExitOngoing() )
         {
         ControlGroup().SetAcceptInput( EFalse );
-    
-        // Hide the control group immediately only if it's not already faded or 
+
+        // Hide the control group immediately only if it's not already faded or
         // fading out. This is to not interfere with the cross fading effect.
         RPointerArray<CAlfVisual> layoutArray;
         TRAP_IGNORE( GetParentLayoutsL( layoutArray ) );
@@ -409,14 +406,14 @@
         TInt fadingCount = 0;
         for ( TInt i = 0 ; i < layoutCount ; ++i )
             {
-            CAlfVisual* layout = layoutArray[i]; 
+            CAlfVisual* layout = layoutArray[i];
             if ( layout && layout->Opacity().Target() < KDelta )
                 {
                 fadingCount++;
                 }
             }
         layoutArray.Close();
-        
+
         if ( !layoutCount || fadingCount != layoutCount )
             {
             iAppUi.AlfEnv().CancelCommands( &ControlGroup(), EAlfOpShow );
@@ -458,16 +455,16 @@
 void CFsEmailUiViewBase::HandleDynamicVariantSwitchL( TDynamicSwitchType aType )
     {
     FUNC_LOG;
-// <cmail> Toolbar    
+// <cmail> Toolbar
     switch (aType)
         {
         case EScreenLayoutChanged:
-            UpdateToolbarL();           
+            UpdateToolbarL();
             break;
         }
-// </cmail> Toolbar    
+// </cmail> Toolbar
     // Inherited classes should override this to react to skin and layout changes
-    
+
 #ifdef __WINSCW__
     // For emulator testing: landscape mode is "flip open"
     FlipStateChangedL(  Layout_Meta_Data::IsLandscapeOrientation() );
@@ -481,7 +478,7 @@
     FUNC_LOG;
     // Inherited classes should override this to react to skin and layout changes
     // which happen while the view is on background
-    
+
 #ifdef __WINSCW__
     // For emulator testing: landscape mode is "flip open"
     FlipStateChangedL(  Layout_Meta_Data::IsLandscapeOrientation() );
@@ -490,7 +487,7 @@
 
 // ---------------------------------------------------------------------------
 //
-TBool CFsEmailUiViewBase::IsNextMsgAvailable( TFSMailMsgId /*aCurrentMsgId*/, 
+TBool CFsEmailUiViewBase::IsNextMsgAvailable( TFSMailMsgId /*aCurrentMsgId*/,
                                               TFSMailMsgId& /*aFoundNextMsgId*/,
                                               TFSMailMsgId& /*aFoundNextMsgFolderId*/ ) const
     {
@@ -500,7 +497,7 @@
 
 // ---------------------------------------------------------------------------
 //
-TBool CFsEmailUiViewBase::IsPreviousMsgAvailable( TFSMailMsgId /*aCurrentMsgId*/, 
+TBool CFsEmailUiViewBase::IsPreviousMsgAvailable( TFSMailMsgId /*aCurrentMsgId*/,
                                                   TFSMailMsgId& /*aFoundPreviousMsgId*/,
                                                   TFSMailMsgId& /*aFoundPrevMsgFolderId*/ ) const
     {
@@ -519,13 +516,21 @@
 
 // ---------------------------------------------------------------------------
 //
-TInt CFsEmailUiViewBase::MoveToPreviousMsgL( TFSMailMsgId /*aCurrentMsgId*/, 
+TInt CFsEmailUiViewBase::MoveToPreviousMsgL( TFSMailMsgId /*aCurrentMsgId*/,
                                              TFSMailMsgId& /*aFoundPreviousMsgId*/ )
     {
     FUNC_LOG;
     return KErrNotFound;
     }
 
+// ---------------------------------------------------------------------------
+//
+TInt CFsEmailUiViewBase::MoveToPreviousMsgAfterDeleteL( TFSMailMsgId /*aFoundPreviousMsgId*/ )
+    {
+    FUNC_LOG;
+    return KErrNotFound;
+    }
+
 //---------------------------------------------------------------------------
 // Concrete view class may override
 //---------------------------------------------------------------------------
@@ -599,9 +604,9 @@
     {
     FUNC_LOG;
     CEikButtonGroupContainer* cba = Cba();
-    if ( cba ) 
+    if ( cba )
         {
-        cba->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition, 
+        cba->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition,
                             aLabelResourceId );
         cba->DrawDeferred();
         }
@@ -619,11 +624,11 @@
 
 // -----------------------------------------------------------------------------
 // CFsEmailUiViewBase::ToolbarResourceId
-// 
+//
 // -----------------------------------------------------------------------------
 TInt CFsEmailUiViewBase::ToolbarResourceId() const
     {
-    FUNC_LOG;    
+    FUNC_LOG;
     return R_FREESTYLE_EMAIL_UI_TOOLBAR_BLANK;
     }
 
@@ -675,11 +680,9 @@
 // -----------------------------------------------------------------------------
 // CFsEmailUiViewBase::HandleTimerFocusStateChange
 // -----------------------------------------------------------------------------
-void CFsEmailUiViewBase::HandleTimerFocusStateChange(TBool aShow)
+void CFsEmailUiViewBase::FocusVisibilityChange( TBool aVisible )
 	{
-    iFocusVisible = aShow;
+    iFocusVisible = aVisible;
 	}
 
-
 // end of file
-
--- a/emailuis/emailui/src/FreestyleMessageHeaderHTML.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleMessageHeaderHTML.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2007-2008 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"
@@ -46,7 +46,6 @@
 _LIT8( KBccFieldName, "bcc_field");
 _LIT8( KSentFieldName, "sent_field");
 _LIT8( KSubjectFieldName, "subject_field");
-_LIT8( KAttachmentFieldName, "attachment_field");
 
 _LIT8( KToImageName, "to_img");
 _LIT8( KCcImageName, "cc_img");
@@ -58,34 +57,36 @@
 _LIT8( KSpace8, " ");
 
 _LIT8( KMetaHeader, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" );
-const TInt KMaxEventLength = 256;
+const TInt KMaxEventLength( 256 );
+const TInt KFreestyleMessageHeaderHTMLRightMarginInPx( 10 );
+const TInt KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth( 5 );
 
-EXPORT_C CFreestyleMessageHeaderHTML* CFreestyleMessageHeaderHTML::NewL( CFSMailMessage& aMailMessage )
+EXPORT_C CFreestyleMessageHeaderHTML* CFreestyleMessageHeaderHTML::NewL( CFSMailMessage& aMailMessage, TInt aVisibleWidth   )
     {
-    CFreestyleMessageHeaderHTML* self = new (ELeave) CFreestyleMessageHeaderHTML( aMailMessage );
+    CFreestyleMessageHeaderHTML* self = new (ELeave) CFreestyleMessageHeaderHTML( aMailMessage, aVisibleWidth  );
     self->ConstructL();
     return self;
     }
 
-EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, RWriteStream& aWriteStream )
+EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, RWriteStream& aWriteStream, TInt aVisibleWidth   )
     {
-    CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage );
+    CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aVisibleWidth   );
     CleanupStack::PushL( headerHtml );
     headerHtml->ExportL( aWriteStream );
     CleanupStack::PopAndDestroy( headerHtml );
     }
 
-EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, RFile& aFile )
+EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, RFile& aFile, TInt aVisibleWidth   )
     {
-    CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage );
+    CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aVisibleWidth   );
     CleanupStack::PushL( headerHtml );
     headerHtml->ExportL( aFile );
     CleanupStack::PopAndDestroy( headerHtml );
     }
 
-EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, RFs& aFs, const TPath& aFilePath)
+EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, RFs& aFs, const TPath& aFilePath, TInt aVisibleWidth  )
     {
-    CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage );
+    CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aVisibleWidth   );
     CleanupStack::PushL( headerHtml );
     headerHtml->ExportL( aFs, aFilePath );
     CleanupStack::PopAndDestroy( headerHtml );
@@ -122,11 +123,12 @@
     CleanupStack::PopAndDestroy( &fwstream );
     }
 
-CFreestyleMessageHeaderHTML::CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage )
+CFreestyleMessageHeaderHTML::CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage,  TInt aVisibleWidth  )
     : iMailMessage( aMailMessage )
     {
-    }
-
+    iVisibleWidth = aVisibleWidth - KFreestyleMessageHeaderHTMLRightMarginInPx;
+  	}
+  	
 void CFreestyleMessageHeaderHTML::ConstructL()
     {
     iMailMessage.AttachmentListL( iAttachments );
@@ -184,10 +186,10 @@
     ExportToL( aWriteStream );
     ExportCcL( aWriteStream );
     ExportBccL( aWriteStream );
-    ExportAttachmentsL( aWriteStream );
     ExportSentTimeL( aWriteStream );
     ExportSubjectL( aWriteStream );
     EndHeaderTableL( aWriteStream );
+    ExportAttachmentsL( aWriteStream );
     HTMLBodyEndL( aWriteStream );
     }
 
@@ -198,14 +200,24 @@
     }
 void CFreestyleMessageHeaderHTML::ExportInitialTableL( RWriteStream& aWriteStream ) const
     {
-    aWriteStream.WriteL(_L8("<table id=\"table_initial\" border=\"0\" width=\"50%\">\n"));
-    aWriteStream.WriteL(_L8("<tr>\n"));
+
+    // 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"));
+    
 
-    // Add "show details" image
-    aWriteStream.WriteL(_L8("<td width=\"1\" valign=middle><image id=\"detail_img\" border=\"0\" src=\"plus.gif\" onClick=\"expandHeader()\" ></td>\n"));
-		
-		//Sent time
-    aWriteStream.WriteL(_L8("<td id=\"sent_initial\" valign=bottom>"));
+    // 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"));
+    
+    aWriteStream.WriteL(_L8("<tr>\n"));
+    
+    // add Sent time and date
+    aWriteStream.WriteL(_L8("<td id=\"sent_initial\" align=\"left\" valign=\"bottom\">"));
     
     HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &iMailMessage );
     HBufC* timeText = TFsEmailUiUtility::TimeTextFromMsgLC( &iMailMessage );
@@ -223,29 +235,32 @@
     CleanupStack::PopAndDestroy( sentTimeText );
     CleanupStack::PopAndDestroy( timeText );
     CleanupStack::PopAndDestroy( dateText );
-
-    aWriteStream.WriteL(_L8("</td>\n</tr>\n"));
-    aWriteStream.WriteL(_L8("<tr id=\"subject_initial\">\n"));
+    
+    aWriteStream.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"));
+        
+    // finish first row
+    aWriteStream.WriteL(_L8("</tr>\n"));  
+    aWriteStream.WriteL(_L8("</table></td></tr>\n"));
 
-    if ( iAttachments.Count() > 0 )
-        {
-        aWriteStream.WriteL(_L8("<td width=\"1\" align=left><image src=\""));
-        aWriteStream.WriteL(KAttachementIconGeneral);
-        aWriteStream.WriteL(_L8("\" ></td>\n"));
-        }
-    else
-        {
-        aWriteStream.WriteL(_L8("<td></td>\n"));
-        }
-    aWriteStream.WriteL(_L8("<td valign=middle><b>"));
-    //Subject
+    //=============================
+    // start second row which contains subject
+    aWriteStream.WriteL(_L8("<tr>\n"));
+    aWriteStream.WriteL(_L8("<td id=\"subject_initial\" align=\"left\"><b>"));
+
     HBufC8* subject8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iMailMessage.GetSubject() );
     CleanupStack::PushL( subject8 );
     aWriteStream.WriteL( *subject8 );
     CleanupStack::PopAndDestroy( subject8 );
 
-    aWriteStream.WriteL(_L8("</b></td>\n</tr>\n</table>\n"));
-
+    aWriteStream.WriteL(_L8("</b></td>\n"));
+    aWriteStream.WriteL(_L8("</tr>\n"));  // finish subject row
+    
+    // end table_initial
+    aWriteStream.WriteL(_L8("</table>\n"));
+        
     aWriteStream.CommitL();
     }
 void CFreestyleMessageHeaderHTML::HTMLBodyEndL( RWriteStream& aWriteStream ) const
@@ -258,7 +273,7 @@
     {
     aWriteStream.WriteL( _L8("<tr id=\"") );
     aWriteStream.WriteL( KSubjectFieldName );
-    aWriteStream.WriteL( _L8("\">\n") );
+    aWriteStream.WriteL( _L8("\">") );
 
 
     aWriteStream.WriteL( _L8("<td width=\"1\">") );
@@ -267,9 +282,11 @@
     aWriteStream.WriteL( *subjectHeadingText );
     CleanupStack::PopAndDestroy( subjectHeadingText );
     aWriteStream.WriteL( _L8("</b>") );
-    aWriteStream.WriteL( _L8("</td>\n") );
+    aWriteStream.WriteL( _L8("</td>") );
     aWriteStream.WriteL( _L8("</tr>\n") );
-    aWriteStream.WriteL( _L8("<tr>\n") );
+    
+    // subject text
+    aWriteStream.WriteL( _L8("<tr>") );
     aWriteStream.WriteL( _L8("<td>") );
 
     HBufC8* subject8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iMailMessage.GetSubject() );
@@ -277,8 +294,7 @@
     aWriteStream.WriteL( *subject8 );
     CleanupStack::PopAndDestroy( subject8 );
 
-    aWriteStream.WriteL( _L8("</td>\n") );
-
+    aWriteStream.WriteL( _L8("</td>") );
     aWriteStream.WriteL( _L8("</tr>\n") );
 
     aWriteStream.CommitL();
@@ -293,26 +309,30 @@
         {
         froms.AppendL( from );
         }
-    ExportEmailAddressesL(aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeFrom, froms );
+    ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeFrom, froms, 
+                           KFromFieldName, KFromTableName, R_FREESTYLE_EMAIL_UI_VIEWER_FROM );
     CleanupStack::PopAndDestroy( &froms );
     }
 
 void CFreestyleMessageHeaderHTML::ExportToL( RWriteStream& aWriteStream ) const
     {
     RPointerArray<CFSMailAddress>& recipients = iMailMessage.GetToRecipients();
-    ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeTo, recipients );
+    ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeTo, recipients,
+                           KToFieldName, KToTableName, R_FREESTYLE_EMAIL_UI_VIEWER_TO );
     }
 
 void CFreestyleMessageHeaderHTML::ExportCcL( RWriteStream& aWriteStream ) const
     {
     RPointerArray<CFSMailAddress>& recipients = iMailMessage.GetCCRecipients();
-    ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeCc, recipients );
+    ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeCc, recipients,
+                           KCcFieldName, KCcTableName, R_FREESTYLE_EMAIL_UI_VIEWER_CC );
     }
 
 void CFreestyleMessageHeaderHTML::ExportBccL( RWriteStream& aWriteStream ) const
     {
     RPointerArray<CFSMailAddress>& recipients = iMailMessage.GetBCCRecipients();
-    ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeBcc, recipients );
+    ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeBcc, recipients,
+                           KBccFieldName, KBccTableName, R_FREESTYLE_EMAIL_UI_VIEWER_BCC );
     }
 
 void CFreestyleMessageHeaderHTML::ExportSentTimeL( RWriteStream& aWriteStream ) const
@@ -320,7 +340,7 @@
 
     aWriteStream.WriteL( _L8("<tr id=\"") );
     aWriteStream.WriteL( KSentFieldName );
-    aWriteStream.WriteL( _L8("\">\n") );
+    aWriteStream.WriteL( _L8("\">") );
 
 
     aWriteStream.WriteL( _L8("<td width=\"1\">") );
@@ -329,10 +349,10 @@
     aWriteStream.WriteL( *sentHeadingText );
     CleanupStack::PopAndDestroy( sentHeadingText );
     aWriteStream.WriteL( _L8("</b>") );
-    aWriteStream.WriteL( _L8("</td>\n") );
+    aWriteStream.WriteL( _L8("</td>") );
     aWriteStream.WriteL( _L8("</tr>\n") );
 
-    aWriteStream.WriteL( _L8("<tr>\n") );
+    aWriteStream.WriteL( _L8("<tr>") );
     aWriteStream.WriteL( _L8("<td>") );
 
     HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &iMailMessage );
@@ -352,7 +372,7 @@
     CleanupStack::PopAndDestroy( timeText );
     CleanupStack::PopAndDestroy( dateText );
 
-    aWriteStream.WriteL( _L8("</td>\n") );
+    aWriteStream.WriteL( _L8("</td>") );
 
     aWriteStream.WriteL( _L8("</tr>\n") );
 
@@ -361,150 +381,77 @@
 
 void CFreestyleMessageHeaderHTML::ExportAttachmentsL( RWriteStream& aWriteStream ) const
     {
-    if ( iAttachments.Count() > 0 )
+
+    TInt attachmentsCount( iAttachments.Count() );
+    if ( attachmentsCount )
         {
-        aWriteStream.WriteL( _L8("<tr id=\"") );
-        aWriteStream.WriteL( KAttachmentFieldName );
-        aWriteStream.WriteL( _L8("\">\n") );
-
-        aWriteStream.WriteL( _L8("<td width=\"1\">") );
-        aWriteStream.WriteL( _L8("<b>") );
+        // 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
 
-        HBufC8* attachmentHeadingText = HeadingTextLC( R_FREESTYLE_EMAIL_UI_VIEWER_ATTACHMENT,  iAttachments.Count());
-        aWriteStream.WriteL( *attachmentHeadingText );
-        CleanupStack::PopAndDestroy( attachmentHeadingText );
-
-
-        aWriteStream.WriteL( _L8(":</b>") );
-        aWriteStream.WriteL( _L8("</td>\n") );
-        aWriteStream.WriteL( _L8("</tr>\n") );
-
-
+        // 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
+        
+        // start row
+        aWriteStream.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") );
+        
+        // start table of attachments as a table within a cell
         aWriteStream.WriteL( _L8("<td>\n") );
-        StartTableL( aWriteStream, KAttachmentTableName );
-        for (TInt i=0; i<iAttachments.Count(); i++)
+        aWriteStream.WriteL(_L8("<table id=\"table_attachments_list\" border=\"0\" width=\"100%\">\n"));
+        for (TInt i=0; i < attachmentsCount; i++)
             {
             AddAttachmentL( aWriteStream, *iAttachments[i] );
             }
-        EndTableL( aWriteStream );
+
+        aWriteStream.WriteL(_L8("</table>\n")); // end table_attachments_list
         aWriteStream.WriteL( _L8("</td>\n") );
-
+        
         aWriteStream.WriteL( _L8("</tr>\n") );
+        aWriteStream.WriteL(_L8("</table>\n")); // end attachments table
         }
     }
 
-void CFreestyleMessageHeaderHTML::ExportEmailAddressesL( RWriteStream& aWriteStream,
-        FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType,
-        const RPointerArray<CFSMailAddress>& aEmailAddresses ) const
+void CFreestyleMessageHeaderHTML::ExportEmailAddressesL( RWriteStream& aWriteStream, 
+                                                        FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType, 
+                                                        const RPointerArray<CFSMailAddress>& aEmailAddresses,
+                                                        const TDesC8& aRowId,
+                                                        const TDesC8& /*aTableId*/,
+                                                        TInt aHeaderTextResourceId ) const
     {
-    if (aEmailAddresses.Count() == 0)
-        {
-        return;
-        }
-
-    aWriteStream.WriteL( _L8("<tr id=\"") );
-    switch ( aEmailAddressType )
+    if ( aEmailAddresses.Count() )
         {
-        case FreestyleMessageHeaderURLFactory::EEmailAddressTypeFrom:
-            aWriteStream.WriteL( KFromFieldName );
-            break;
-
-        case FreestyleMessageHeaderURLFactory::EEmailAddressTypeTo:
-            aWriteStream.WriteL( KToFieldName );
-            break;
-
-        case FreestyleMessageHeaderURLFactory::EEmailAddressTypeCc:
-            aWriteStream.WriteL( KCcFieldName );
-            break;
-
-        case FreestyleMessageHeaderURLFactory::EEmailAddressTypeBcc:
-            aWriteStream.WriteL( KBccFieldName );
-            break;
-
-        default:
-            User::Leave( KErrNotSupported );
-        }
-    aWriteStream.WriteL( _L8("\">\n") );
-
-
-    aWriteStream.WriteL( _L8("<td width=\"1\">") );
-    aWriteStream.WriteL( _L8("<b>") );
-
-    switch ( aEmailAddressType )
-        {
-        case FreestyleMessageHeaderURLFactory::EEmailAddressTypeFrom:
+        // begin table row
+        aWriteStream.WriteL( _L8("<tr id=\"")); 
+        aWriteStream.WriteL( aRowId );
+        aWriteStream.WriteL( _L8("\">") );
+        
+        // heading text
+        aWriteStream.WriteL( _L8("<td><b>"));
+        HBufC8* headingText = HeadingTextLC( aHeaderTextResourceId );
+        aWriteStream.WriteL( *headingText );
+        CleanupStack::PopAndDestroy( headingText );
+        aWriteStream.WriteL( _L8("</b></td>"));
+        
+        aWriteStream.WriteL( _L8("</tr>\n") );  // end table row      
+        
+        // add addresses, one address per row
+        TInt count( aEmailAddresses.Count() );
+        for (TInt i = 0; i < count; ++i )
             {
-            HBufC8* fromHeadingText = HeadingTextLC( R_FREESTYLE_EMAIL_UI_VIEWER_FROM );
-            aWriteStream.WriteL( *fromHeadingText );
-            CleanupStack::PopAndDestroy( fromHeadingText );
+            aWriteStream.WriteL( _L8("<tr><td style=\"padding: 0px 0px 7px 0px;\">") );
+            AddEmailAddressL (aWriteStream, aEmailAddressType, *aEmailAddresses[i] );
+            aWriteStream.WriteL( _L8("</td></tr>\n") );
             }
-            break;
-
-        case FreestyleMessageHeaderURLFactory::EEmailAddressTypeTo:
-            {
-            HBufC8* toHeadingText = HeadingTextLC( R_FREESTYLE_EMAIL_UI_VIEWER_TO );
-            aWriteStream.WriteL( *toHeadingText );
-            CleanupStack::PopAndDestroy( toHeadingText );
-            }
-            break;
 
-        case FreestyleMessageHeaderURLFactory::EEmailAddressTypeCc:
-            {
-            HBufC8* ccHeadingText = HeadingTextLC( R_FREESTYLE_EMAIL_UI_VIEWER_CC );
-            aWriteStream.WriteL( *ccHeadingText );
-            CleanupStack::PopAndDestroy( ccHeadingText );
-            }
-            break;
-
-        case FreestyleMessageHeaderURLFactory::EEmailAddressTypeBcc:
-            {
-            HBufC8* bccHeadingText = HeadingTextLC( R_FREESTYLE_EMAIL_UI_VIEWER_BCC );
-            aWriteStream.WriteL( *bccHeadingText );
-            CleanupStack::PopAndDestroy( bccHeadingText );
-            }
-            break;
-
-        default:
-            User::Leave( KErrNotSupported );
+        aWriteStream.CommitL();
         }
-    aWriteStream.WriteL( _L8("</b>") );
-    aWriteStream.WriteL( _L8("</td>\n") );
-    aWriteStream.WriteL( _L8("</tr>\n") );
-
-    aWriteStream.WriteL( _L8("<tr>\n") );
-    aWriteStream.WriteL( _L8("<td>") );
-
-    switch ( aEmailAddressType )
-        {
-        case FreestyleMessageHeaderURLFactory::EEmailAddressTypeTo:
-            StartTableL( aWriteStream, KToTableName );
-            break;
-
-        case FreestyleMessageHeaderURLFactory::EEmailAddressTypeCc:
-            StartTableL( aWriteStream, KCcTableName );
-            break;
-
-        case FreestyleMessageHeaderURLFactory::EEmailAddressTypeBcc:
-            StartTableL( aWriteStream, KBccTableName );
-            break;
-        case FreestyleMessageHeaderURLFactory::EEmailAddressTypeFrom:
-            StartTableL( aWriteStream, KFromTableName );
-            break;
-
-        default:
-            User::Leave( KErrNotSupported );
-        }
-    for ( TInt i=0; i<aEmailAddresses.Count(); i++ )
-        {
-        aWriteStream.WriteL( _L8("<tr><td>") );
-        AddEmailAddressL (aWriteStream, aEmailAddressType, *aEmailAddresses[i] );
-        aWriteStream.WriteL( _L8("</td></tr>\n") );
-        }
-        
-    EndTableL( aWriteStream );    
-    aWriteStream.WriteL( _L8("</td>\n") );
-    aWriteStream.WriteL( _L8("</tr>\n") );
-    aWriteStream.CommitL();
     }
 
 void CFreestyleMessageHeaderHTML::AddEmailAddressL( RWriteStream& aWriteStream,
@@ -542,7 +489,7 @@
 
 void CFreestyleMessageHeaderHTML::AddAttachmentL( RWriteStream& aWriteStream, CFSMailMessagePart& aAttachment ) const
     {
-    aWriteStream.WriteL( _L8("<tr><td>") );
+    aWriteStream.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;
@@ -568,10 +515,10 @@
     TUint sizeInKB = size / 1024;
     
     if ( size % 1024 )
-    	{
-    	// round up
-    	++sizeInKB;
-    	}
+      {
+      // round up
+      ++sizeInKB;
+      }
     
     TBuf8<32> sizeText;
     sizeText.Append( KSpace8 );
@@ -639,12 +586,21 @@
     aWriteStream.WriteL( aTableId );
     
     // use style="display:none" so that full header table is hidden initially
-    aWriteStream.WriteL( _L8("\" border=\"0\" width=\"50%\" style=\"display: none\">\n") );
+    aWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\" style=\"display: none\">\n") );
+    
     
-    // Add "hide details" image
-    aWriteStream.WriteL(_L8("<tr>\n"));
-	  aWriteStream.WriteL(_L8("<td width=\"1\" valign=middle><image id=\"hideDetails_img\" border=\"0\" src=\"minus.gif\" onClick=\"collapseHeader()\"></td>\n"));
-	  aWriteStream.WriteL(_L8("</tr>\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();
     }
 
@@ -780,3 +736,6 @@
     aWriteStream.WriteL( _L8("</div>\n") );
     aWriteStream.CommitL();
     }
+
+
+                                
--- a/emailuis/emailui/src/FreestyleMessageHeaderURLEventHandler.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/FreestyleMessageHeaderURLEventHandler.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -191,7 +191,22 @@
     
     if ( found == KErrNotFound )
         {
-        User::Leave( KErrNotFound );
+        // Probably, only the headers were downloaded. Check if attachments 
+        // were downloaded later.
+        iAttachmentsListModel->UpdateListL( iMailMessage );
+        for (TInt i=0; i<iAttachmentsListModel->GetModel().Count(); i++)
+            {
+            if ( iAttachmentsListModel->GetModel()[i].partData.iMessagePartId.Id() == id )
+                {
+                found = i;
+                break;
+                }
+            }
+
+        if ( found == KErrNotFound )
+            {
+            User::Leave( KErrNotFound );
+            }
         }
     
     return iAttachmentsListModel->GetModel()[found];
@@ -217,7 +232,7 @@
             if ( iView.IsEmbeddedMsgSavingAllowed() || !iAttachmentsListModel->IsMessage( aAttachment ) )
                 {
                 CFSEmailUiActionMenu::AddCustomItemL( FsEActionAttachmentSave );    
-                }
+                } 
              
             }
         else
--- a/emailuis/emailui/src/freestyleemailuimailboxdeleter.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/freestyleemailuimailboxdeleter.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -81,68 +81,127 @@
 // allows the user to mark multiple mailboxes for deletion if aId is NullId.
 // ---------------------------------------------------------------------------
 //
-
 void CFSEmailUiMailboxDeleter::DeleteMailboxL()
     {
-    // Make sure that FSMailServer is running so that the mailboxes will also 
-    // be removed from MCE.
-    TFsEmailUiUtility::EnsureFsMailServerIsRunning( CCoeEnv::Static()->WsSession() );
+    iMailboxesToDelete.Reset();
 
+    // Get the deletable mailboxes.
+    RPointerArray<CFSMailBox> mailboxes;
+    const TInt mailboxCount = GetDeletableMailboxesLC( mailboxes );
+    
+    TBool res( EFalse );    
+    
+    if( mailboxCount == 1 )
+        {
+        res = DeleteSingleMailboxL( mailboxes );
+        }
+    else if( mailboxCount > 1 )
+        {
+        res = DeleteMultipleMailboxesL( mailboxes );
+        }
+
+    CleanupStack::PopAndDestroy(); // mailboxes
+    
+    if ( res )
+        {
+        DoDeleteSelectedMailboxesL();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// DeleteMailboxL()
+// Deletes the given mailbox. Displays also a confirmation dialog.
+// ---------------------------------------------------------------------------
+//
+void CFSEmailUiMailboxDeleter::DeleteMailboxL( const TFSMailMsgId& aMailboxId )
+	{
     iMailboxesToDelete.Reset();
 
-    // Get mailbox count
+    // Get the deletable mailboxes.
     RPointerArray<CFSMailBox> mailboxes;
-    CleanupResetAndDestroyClosePushL( mailboxes );
+    const TInt mailboxCount = GetDeletableMailboxesLC( mailboxes );
+
+    // Make sure that it is allowed to delete the mailbox with the given ID.
+    CFSMailBox* mailbox = NULL;
+
+    for ( TInt i( 0 ); i < mailboxCount; ++i )
+    	{
+    	mailbox = mailboxes[i];
+
+    	if ( mailbox && mailbox->GetId() == aMailboxId )
+    		{
+    		// The mailbox can be deleted.
+    		break;
+    		}
+
+    	mailbox = NULL;
+    	}
+
+    if ( !mailbox )
+    	{
+    	// Either no mailbox with the given ID exist or it is not allowed to
+    	// be deleted.
+    	// TODO Display an error message?
+    	CleanupStack::PopAndDestroy(); // mailboxes
+    	return;
+    	}
+
+    TBool response = ConfirmMailboxDeletionL( 1, mailbox->GetName() );
+    CleanupStack::PopAndDestroy(); // mailboxes
+
+    if ( !response )
+    	{
+    	// User did not confirm the deletion.
+    	return;
+    	}
     
+    iMailboxesToDelete.AppendL( aMailboxId );
+    DoDeleteSelectedMailboxesL();
+	}
+
+
+// ---------------------------------------------------------------------------
+// GetDeletableMailboxesLC()
+// Returns the mailboxes that can be deleted.
+// ---------------------------------------------------------------------------
+//
+TInt CFSEmailUiMailboxDeleter::GetDeletableMailboxesLC(
+	RPointerArray<CFSMailBox>& aMailboxes )
+	{
+    // Make sure that FSMailServer is running so that the mailboxes will also
+    // be removed from MCE.
+    TFsEmailUiUtility::EnsureFsMailServerIsRunning(
+    	CCoeEnv::Static()->WsSession() );
+
+    CleanupResetAndDestroyClosePushL( aMailboxes );
+
+    // Get the mailboxes.
     TFSMailMsgId id; 
-    User::LeaveIfError( iMailClient.ListMailBoxes( id, mailboxes ) );
-       
-    CFSMailBox* mailBox = NULL;
+    User::LeaveIfError( iMailClient.ListMailBoxes( id, aMailboxes ) );
+
+    CFSMailBox* mailbox = NULL;
     
     // Filter out mailboxes that can't be deleted.
-    for( TInt i(0); i < mailboxes.Count(); )
+    const TInt mailboxCount( aMailboxes.Count() );
+
+    for( TInt i( 0 ); i < mailboxCount; )
         {
-        mailBox = mailboxes[i];
-        if( !mailBox->HasCapability( EFSMBoxCapaCanBeDeleted ) )
+        mailbox = aMailboxes[i];
+
+        if( !mailbox->HasCapability( EFSMBoxCapaCanBeDeleted ) )
             {
-            delete mailBox;
-            mailboxes.Remove( i );
+            delete mailbox;
+            aMailboxes.Remove( i );
             }
         else
             {
             ++i;
             }
         }
-    
-    TBool res( EFalse );    
-    
-    if( mailboxes.Count() == 1 )
-        {
-        res = DeleteSingleMailboxL( mailboxes );
-        }
-    else if( mailboxes.Count() > 1 )
-        {
-        res = DeleteMultipleMailboxesL( mailboxes );
-        }
 
-    CleanupStack::PopAndDestroy(); // mailboxes
-    
-    if( res && ( iMailboxesToDelete.Count() > 0 ) )
-        {
-        // Start wait note.
-        iWaitDialog = new (ELeave) CAknWaitDialog( 
-                    (REINTERPRET_CAST(CEikDialog**, &iWaitDialog)), EFalse );
-        iWaitDialog->PrepareLC( R_FS_WAIT_NOTE_REMOVING_MAILBOX );
-        iWaitDialog->SetCallback( this );
-        iWaitDialog->RunLD();
+    return aMailboxes.Count();
+	}
 
-        // Set email indicator off.
-        TFsEmailUiUtility::ToggleEmailIconL(EFalse);
-        
-        // Delete first mailbox in queue.
-        DoDeleteNextMailboxL();        
-        }
-    }
 
 // ---------------------------------------------------------------------------
 // DeleteSingleMailboxL
@@ -162,6 +221,7 @@
     
     return res;
     }
+
 // ---------------------------------------------------------------------------
 // DeleteMultipleMailboxesL
 // ---------------------------------------------------------------------------
@@ -216,6 +276,36 @@
     return res;
     }
 
+
+// ---------------------------------------------------------------------------
+// DoDeleteSelectedMailboxesL()
+// Deletes the selected mailboxes i.e. those of which IDs are in the
+// iMailboxesToDelete array.
+// ---------------------------------------------------------------------------
+//
+void CFSEmailUiMailboxDeleter::DoDeleteSelectedMailboxesL()
+	{
+    if ( iMailboxesToDelete.Count() < 1 )
+    	{
+    	// Nothing to delete!
+    	return;
+    	}
+    
+    // Start wait note.
+    iWaitDialog = new ( ELeave ) CAknWaitDialog(
+        ( REINTERPRET_CAST( CEikDialog**, &iWaitDialog ) ), EFalse );
+    iWaitDialog->PrepareLC( R_FS_WAIT_NOTE_REMOVING_MAILBOX );
+    iWaitDialog->SetCallback( this );
+    iWaitDialog->RunLD();
+
+    // Set email indicator off.
+    TFsEmailUiUtility::ToggleEmailIconL( EFalse );
+        
+    // Delete first mailbox in queue.
+	DoDeleteNextMailboxL();
+	}
+
+
 // ---------------------------------------------------------------------------
 // CreateMarkIconLC
 // ---------------------------------------------------------------------------
--- a/emailuis/emailui/src/ncsaddressinputfield.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/ncsaddressinputfield.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -95,11 +95,12 @@
 	// Create label
 	//Load the label string
 	HBufC* aTextBuf = StringLoader::LoadLC( aLabelTextId );
-	//<cmail>
-	CreateControlsL( aTextBuf ? aTextBuf->Des() : TPtrC() );
-	//</cmail>
+
+	TPtrC captionText = aTextBuf ? aTextBuf->Des() : TPtrC();
+	CreateControlsL( captionText );
 	
-	iTextEditor = new ( ELeave ) CNcsAifEditor( iSizeObserver );
+	iTextEditor = new ( ELeave ) CNcsAifEditor( iSizeObserver,
+                                                captionText );
     // iTextEditor is not completely constructed until in SetContainerWindowL()
 
 	iTextEditor->SetPopupList(iAddressPopupList);
--- a/emailuis/emailui/src/ncsaifeditor.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/ncsaifeditor.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -219,8 +219,8 @@
 // ---------------------------------------------------------------------------
 //
 CNcsAifEditor::CNcsAifEditor(
-    MNcsFieldSizeObserver* aSizeObserver ) 
-    : CNcsEditor( aSizeObserver, ETrue, ENcsEditorAddress ), iAddressPopupList( NULL ),
+    MNcsFieldSizeObserver* aSizeObserver, const TDesC& aCaptionText ) 
+    : CNcsEditor( aSizeObserver, ETrue, ENcsEditorAddress, aCaptionText ), iAddressPopupList( NULL ),
     iAddLeftover( ETrue )
     {
     FUNC_LOG;
@@ -346,7 +346,7 @@
             
             CleanupStack::PopAndDestroy( text );            
         	}
-        
+        iTextSelection = Selection();        
         ret = CNcsEditor::OfferKeyEventL( aKeyEvent, aType );
         }
     return ret;
@@ -375,6 +375,7 @@
         }
     else if ( aEventType == MEikEdwinObserver::EEventNavigation )
         {
+        iTextSelection = Selection();
         HandleNavigationEventL();
         }
     }
@@ -396,31 +397,7 @@
     // move the cursor for us.  Then we check if it's in an entry.
     if ( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
         {
-    	// make sure there is really some text inputted 
-        TInt cursorPos( CursorPos() );
-    	
-        TCursorSelection selection = NonEntryTextAtPos( cursorPos );
-        
-        TInt length( selection.Length() );
-        
-        HBufC* text = HBufC::NewLC( length );
-        TPtr ptr = text->Des();
-        
-        if( selection.LowerPos() >= 0 )
-        	{
-			Text()->Extract( ptr, selection.LowerPos(), length );
-			ptr.Trim();
-			
-			// complete the entry
-			if( ptr.Length() > 0 )
-				{
-				Text()->InsertL( selection.HigherPos(), KCharAddressDelimeterSemiColon );
-				HandleTextChangedL();
-				HandleTextUpdateL( TCursorSelection(selection.LowerPos(), selection.HigherPos() + 1) );
-				}
-        	}
-		
-		CleanupStack::PopAndDestroy( text );
+        CompleteEntryL();
 		
         response = CNcsEditor::OfferKeyEventL( aKeyEvent,aType );
         if ( response == EKeyWasConsumed ) 
@@ -1063,8 +1040,9 @@
         {
         TInt matchesInText;
         TInt matchesInArray;
-        TInt arrayItemCurPos( iArray[i]->LowerPos() );
-        
+        TInt arrayItemLowPos( iArray[i]->LowerPos() );
+        TInt arrayItemHighPos( iArray[i]->HigherPos());
+
         GetMatchingEntryCountsL( iArray[i], matchesInText, matchesInArray );
 
         // Entry is removed if:
@@ -1074,13 +1052,18 @@
         // In b) case the correct duplicate is the one that is in current
         // cursor position (or one off due to possible whitespace).
         if ( 0 == matchesInText ||
-             ( matchesInText < matchesInArray &&
-               ( currentCursorPos == arrayItemCurPos || 
-                 (1 + currentCursorPos) == arrayItemCurPos ) ) )
+             ( matchesInText < matchesInArray ) &&
+               ( currentCursorPos >= arrayItemLowPos && 
+                 currentCursorPos <= arrayItemHighPos )) 
             {
             delete iArray[i];
             iArray.Remove(i);
             removedEntryIndex = i;
+            if ( iTextSelection.iAnchorPos != iTextSelection.iCursorPos &&
+                 iTextSelection.HigherPos() < arrayItemHighPos )
+                {
+                iPartialRemove = ETrue;
+                }
             }
         }
     
@@ -1270,16 +1253,19 @@
     const TInt entryCount = iArray.Count();
     for ( TInt ii = entryCount - 1; ii >= 0; --ii )
         {
-        TBool duplicateFound = EFalse;
-        for ( TInt jj = ii - 1; jj >= 0; --jj )
+        if ( ii > 0 )
             {
-            if ( iArray[ii]->IsSameDN( *iArray[jj] ) )
+            TBool duplicateFound = EFalse;
+            for ( TInt jj = ii - 1; jj >= 0; --jj )
                 {
-                duplicateFound = ETrue;
-                iArray[jj]->SetDupL( ETrue );
+                if ( iArray[ii]->IsSameDN( *iArray[jj] ) )
+                    {
+                    duplicateFound = ETrue;
+                    iArray[jj]->SetDupL( ETrue );
+                    }
                 }
+            iArray[ii]->SetDupL( duplicateFound );
             }
-        iArray[ii]->SetDupL( duplicateFound );
         }
     }
 
@@ -1332,9 +1318,13 @@
         
         // add line feed after new entry
         TInt cursorPos( CursorPos() );
-        Text()->InsertL( cursorPos, TChar(CEditableText::ELineBreak) );
+        if ( !iPartialRemove )
+            {
+            Text()->InsertL( cursorPos, TChar(CEditableText::ELineBreak) );
+            }
         HandleTextChangedL();
-    	SetCursorPosL( cursorPos + 1, EFalse );
+        SetCursorPosL( cursorPos + 1, EFalse );
+        iPartialRemove = EFalse;
         }
     else
         {
@@ -1604,5 +1594,78 @@
         }
     }
 
+// -----------------------------------------------------------------------------
+// CNcsAifEditor::HandlePointerEventL()
+// Handles pointer events
+// -----------------------------------------------------------------------------
+//
+void CNcsAifEditor::HandlePointerEventL( const TPointerEvent& aPointerEvent )
+    {
+    FUNC_LOG;
+    
+    if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
+        {
+        CTextLayout* textLayout = TextLayout();
+        TInt cursorPos = CursorPos();
+        TPoint touchPoint( aPointerEvent.iPosition );
+
+        //adjust touch point to mach editor coordinates
+        touchPoint.iX -= Position().iX;
+        
+        TInt pointerLineNbr = textLayout->GetLineNumber( textLayout->XyPosToDocPosL( touchPoint ));
+        TInt cursorLineNbr = textLayout->GetLineNumber( cursorPos );
+        
+        
+        if ( pointerLineNbr != cursorLineNbr )
+            {
+            CompleteEntryL();
+            
+            // We're moving to a new line.
+            CNcsAifEntry* entry = NULL;
+            entry = GetEntryAt( CursorPos() );
+            if ( entry )
+                {
+                SetSelectionL( entry->iCursorPos, entry->iAnchorPos );
+                }
+            }    
+        }
+            
+    CEikEdwin::HandlePointerEventL( aPointerEvent );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CNcsAifEditor::CompleteEntryL()
+// Adds semicolol to the of the entry
+// -----------------------------------------------------------------------------
+//
+void CNcsAifEditor::CompleteEntryL()
+    {
+    // make sure there is really some text inputted 
+    TInt cursorPos( CursorPos() );
+
+    TCursorSelection selection = NonEntryTextAtPos( cursorPos );
+
+    TInt length( selection.Length() );
+
+    HBufC* text = HBufC::NewLC( length );
+    TPtr ptr = text->Des();
+
+    if( selection.LowerPos() >= 0 )
+        {
+        Text()->Extract( ptr, selection.LowerPos(), length );
+        ptr.Trim();
+        
+        // complete the entry
+        if( ptr.Length() > 0 )
+            {
+            Text()->InsertL( selection.HigherPos(), KCharAddressDelimeterSemiColon );
+            HandleTextChangedL();
+            HandleTextUpdateL( TCursorSelection(selection.LowerPos(), selection.HigherPos() + 1) );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( text );
+    }
 // End of File
 
--- a/emailuis/emailui/src/ncscomposeview.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/ncscomposeview.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -2671,9 +2671,10 @@
 // CNcsComposeView::FetchLogicComplete
 // -----------------------------------------------------------------------------
 //
-void CNcsComposeView::FetchLogicComplete( TComposerFetchState /*aState*/, TInt aError )
+TBool CNcsComposeView::FetchLogicComplete( TComposerFetchState /*aState*/, TInt aError )
 	{
     FUNC_LOG;
+    TBool result = EFalse;
     if ( iFirstStartCompleted ) // Safety
         {
         if ( !aError )
@@ -2686,6 +2687,7 @@
             // something went wrong
             DoSafeExit(ENoSave);
             iMailFetchingErrCode = aError;
+            result = ETrue;
             }
         }
     if ( iFetchWaitDialog && !iFetchDialogCancelled )
@@ -2693,6 +2695,7 @@
         TRAP_IGNORE(iFetchWaitDialog->ProcessFinishedL());
         iFetchWaitDialog = NULL;
         }
+    return result;
 	}
 
 // -----------------------------------------------------------------------------
--- a/emailuis/emailui/src/ncscomposeviewcontainer.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/ncscomposeviewcontainer.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -760,6 +760,8 @@
         iMessageEditorMinHeigth = messageLineHeigth;
         }
 
+    UpdateFieldPosition( NULL );
+    
     TRAP_IGNORE( UpdateScrollBarL() );
     DrawNow();
     
@@ -1100,9 +1102,17 @@
     {
     FUNC_LOG;
 
+    // If in 'To' field, go to msg. field
+    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
+	pos += aText.Length();
+	iMessageField->SetCursorPosL(pos,EFalse);
 	DrawDeferred();
 
     }
@@ -1762,20 +1772,12 @@
 void CNcsComposeViewContainer::HandleLayoutChangeL()
     {
     FUNC_LOG;
-    // <cmail> Platform layout change
-    const TRect rect( NcsUtility::ListscrollPaneRect() );
+    TRect rect = iView.ClientRect();
     SetRect( rect );
-    // </cmail> Platform layout change
     if ( iHeader )
         {
         iHeader->HandleDynamicVariantSwitchL();
         }
-    // <cmail> Platform layout change
-    //TRect rect = iView.ClientRect();
-    //SetApplicationRect( rect );
-    //SetRect( rect );
-	//UpdateScreenPositionL();
-    // </cmail> Platform layout change
     UpdateScrollBarL();
     }
 
--- a/emailuis/emailui/src/ncseditor.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/ncseditor.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -42,7 +42,8 @@
 //
 CNcsEditor::CNcsEditor( MNcsFieldSizeObserver* aSizeObserver,
                         TBool aHeaderField,
-                        TNcsEditorUsage aEditorUsage ) :
+                        TNcsEditorUsage aEditorUsage,
+                        const TDesC& aCaptionText ) :
     MNcsControl( aSizeObserver ),
     iPreviousFontHeight( -1 ),
     iPreviousLineSpacingInTwips( -1 ),
@@ -50,7 +51,8 @@
     iHeaderField( aHeaderField ),
     iNcsFontType ( NcsUtility::ENcsHeaderDetailFont ),
     iEditorUsage( aEditorUsage ),
-    iRealRect( 0, 0, 0, 0 )
+    iRealRect( 0, 0, 0, 0 ),
+    iCaptionText( aCaptionText.Alloc() )
     {
     FUNC_LOG;
     }
@@ -90,6 +92,7 @@
         {
         delete iEditorCustomDrawer;        
         }
+    delete iCaptionText;
     }
 
 // -----------------------------------------------------------------------------
@@ -687,3 +690,21 @@
         iEditorCustomDrawer->UpdateLayout( GetLayout() );
         }
     }
+
+void CNcsEditor::GetCaptionForFep(TDes& aCaption) const
+    {
+    const TInt maximumLength = aCaption.MaxLength();    
+    if ( iCaptionText && (iCaptionText->Length() < maximumLength) )
+        {
+        TPtr ptr = iCaptionText->Des();
+        aCaption.Copy( ptr ); 
+        }                   
+    }
+ 
+TCoeInputCapabilities CNcsEditor::InputCapabilities() const
+    {
+    TCoeInputCapabilities caps = CEikEdwin::InputCapabilities();
+    TCoeInputCapabilities caps2 = TCoeInputCapabilities(TCoeInputCapabilities::ENone, NULL, const_cast<CNcsEditor*>(this));
+    caps.MergeWith(caps2);
+    return caps;
+    }
--- a/emailuis/emailui/src/ncsheadercontainer.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/ncsheadercontainer.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -364,15 +364,20 @@
             CCoeControl* pNewCtrl= clicked;
             
             if (pOldCtrl != pNewCtrl)
-                {           
+                {
                 // Unfocus the control
                 if ( pOldCtrl )
                     {
-                    CommitFieldL( pOldCtrl );
                     pOldCtrl->SetFocus( EFalse, ENoDrawNow );
                     }
                 pNewCtrl->SetFocus( ETrue, ENoDrawNow );
 
+                // Commit changes to previously focused field.
+                if ( pOldCtrl )
+                    {
+                    CommitFieldL( pOldCtrl );
+                    }
+
                 // If the attachments label has changed focus
                 if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField )
                     {
--- a/emailuis/emailui/src/ncssubjectfield.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/emailui/src/ncssubjectfield.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -80,13 +80,16 @@
     FUNC_LOG;
     // Create label
 	HBufC* aTextBuf = StringLoader::LoadLC( aLabelTextId );
+    TPtrC captionText = aTextBuf ? aTextBuf->Des() : TPtrC();
     iLabel = new ( ELeave ) CNcsLabel( *this, NULL );
-    iLabel->SetTextL( aTextBuf->Des() );
-	CleanupStack::PopAndDestroy( aTextBuf );
-	// S60 Skin support
+    iLabel->SetTextL( captionText );
+
+    // S60 Skin support
 	iLabel->SetBrushStyle(CWindowGc::ENullBrush);
 
-    iTextEditor = new ( ELeave ) CNcsEditor( iSizeObserver, ETrue, ENcsEditorSubject );
+    iTextEditor = new ( ELeave ) CNcsEditor( iSizeObserver, ETrue, ENcsEditorSubject, captionText );
+    CleanupStack::PopAndDestroy( aTextBuf );
+
     // iTextEditor is not completely constructed until in SetContainerWindowL()
     iFocusChangeHandler = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
     }
--- a/emailuis/uicomponents/inc/fscontrolbar.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/inc/fscontrolbar.h	Thu Jan 07 12:38:38 2010 +0200
@@ -137,6 +137,11 @@
     IMPORT_C MFsControlButtonInterface* GetFocusedButton() const;
 
     /**
+     * Set position and size
+     */
+    virtual void SetRectL( const TRect& aRect );
+    
+    /**
      * Sets height of the bar in pixels.
      *
      * @param aHeight new height of the bar.
--- a/emailuis/uicomponents/inc/fscontrolbarmodel.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/inc/fscontrolbarmodel.h	Thu Jan 07 12:38:38 2010 +0200
@@ -193,12 +193,22 @@
     void SetHeight( TInt aHeight );
 
     /**
+     * Set bar's rect
+     */
+    void SetRect( const TRect& aRect );
+    
+    /**
      * Get size of the controlbar.
      *
      * @return Size of the controlbar.
      */
     TSize Size() const;
 
+    /**
+     * Get top-left position
+     */
+    TPoint Pos() const;
+    
 private:
 
     /**
@@ -249,6 +259,10 @@
      */
     TBool iHeightUseDefault;
 
+    /**
+     * Top-left position 
+     */
+    TPoint iTl;
     };
 
 
--- a/emailuis/uicomponents/inc/fscontrolbarobserver.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/inc/fscontrolbarobserver.h	Thu Jan 07 12:38:38 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"
@@ -46,8 +46,9 @@
         EEventButton,
         // <cmail> Touch
         EEventButtonReleased,
-        EEventButtonTouched
+        EEventButtonTouched,
         // </cmail>
+        EEventFocusVisibilityChanged
         };
 
 public:
--- a/emailuis/uicomponents/inc/fscontrolbarvisualiser.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/inc/fscontrolbarvisualiser.h	Thu Jan 07 12:38:38 2010 +0200
@@ -54,8 +54,7 @@
      * @param aModel Model of control bar.
      */
     static CFsControlBarVisualiser* NewL(
-        CFsControlBar& aParentControl,
-        CFsControlBarModel& aModel );
+        CFsControlBar& aParentControl, CFsControlBarModel& aModel );
 
     /**
      * Destructor
--- a/emailuis/uicomponents/inc/fscontrolbuttonobserver.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/inc/fscontrolbuttonobserver.h	Thu Jan 07 12:38:38 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"
@@ -41,8 +41,9 @@
         // <cmail> Touch
         EEventButtonDimmStateChanged,
         EEventButtonTouchPressed,
-        EEventButtonTouchReleased
+        EEventButtonTouchReleased,
         // </cmail>
+        EFocusVisibilityChange
         };
 
 public:
--- a/emailuis/uicomponents/inc/fscontrolbuttonvisualiser.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/inc/fscontrolbuttonvisualiser.h	Thu Jan 07 12:38:38 2010 +0200
@@ -29,6 +29,8 @@
 class CAlfControl;
 class CAlfVisual;
 class CAlfLayout;
+class CAlfBrush;
+class CAlfFrameBrush;
 class CAlfTextVisual;
 class CAlfGridLayout;
 class CAlfDeckLayout;
@@ -39,6 +41,7 @@
 class CAlfTexture;
 class CAlfGradientBrush;
 class CAlfImageBrush;
+class CAlfShadowBorderBrush;
 class CFsControlButtonModel;
 class CFsControlButtonLayoutData;
 class CFsTextStyleManager;
@@ -80,6 +83,11 @@
     IMPORT_C virtual void InitializeL( CFsControlButtonModel& aButtonModel );
 
     /**
+     * Called when the colors etc should be refreshed
+     */
+    virtual void UpdateVisualThemeL();
+    
+    /**
      * Refreshes button on the display.
      */
     IMPORT_C virtual void Refresh();
@@ -455,7 +463,23 @@
      * Brush with background image.
      * Owned.
      */
-    CAlfImageBrush* iBgBrush;
+    CAlfBrush* iBgBrush;
+
+    /**
+     * Default brush for background. Owned.
+     */
+    CAlfFrameBrush* iDefaultBgBrush;
+
+	/**
+	 * ETrue if default theme background is used
+	 */
+    TBool iUseDefaultBackground;
+    
+    /**
+     * Brush for shadowed button borders.
+     * Owned.
+     */
+    CAlfShadowBorderBrush* iShadowBorderBrush;
 
     /**
      * Layout of the parent control.
@@ -520,6 +544,10 @@
      */
     TBool iDrawFocus;
 
+    /**
+     * Show dropdown shadow for buttons  
+     */
+    TBool iShowShadow;
     };
 
 
--- a/emailuis/uicomponents/inc/fstreelistobserver.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/inc/fstreelistobserver.h	Thu Jan 07 12:38:38 2010 +0200
@@ -245,9 +245,12 @@
         /**
          * Event generated when all nodes are expanded.
          */
-        EFsTreeListExpandedAll
-
+        EFsTreeListExpandedAll,
         // </cmail>
+        /**
+         * Handle focus visibility changes
+         */
+        EFsFocusVisibilityChange
         };    
 
 public:
--- a/emailuis/uicomponents/inc/fstreevisualizerobserver.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/inc/fstreevisualizerobserver.h	Thu Jan 07 12:38:38 2010 +0200
@@ -114,8 +114,12 @@
         /**
          * Event generated when all nodes are expanded.
          */
-        EFsTreeListExpandedAll
+        EFsTreeListExpandedAll,
         // </cmail>
+        /**
+         * Change focus visibility
+         */
+        EFsChangeFocusVisibility
         };    
 
 public:
--- a/emailuis/uicomponents/src/fscontrolbar.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/src/fscontrolbar.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -336,6 +336,15 @@
     iVisualiser->UpdateSizeL();
     }
 
+// ---------------------------------------------------------------------------
+// Set rect for control bar
+// ---------------------------------------------------------------------------
+//
+void CFsControlBar::SetRectL( const TRect& aRect )
+    {
+    iModel->SetRect( aRect );
+    iVisualiser->UpdateSizeL();
+    }
 
 // ---------------------------------------------------------------------------
 // Retrieves width of the bar in pixels.
@@ -616,6 +625,8 @@
                         {
                         button = iModel->PrevButton( iSelectedButton );
                         ChangeFocusL( button );
+                        // Always after keypress focus needs to be shown.
+                        MakeSelectorVisible( ETrue );
                         eventHandled = ETrue;
                         break;
                         }
@@ -624,6 +635,8 @@
                         {
                         button = iModel->NextButton( iSelectedButton );
                         ChangeFocusL( button );
+                        // Always after keypress focus needs to be shown.
+                        MakeSelectorVisible( ETrue );
                         eventHandled = ETrue;
                         break;
                         }
@@ -631,7 +644,7 @@
                     case EStdKeyDownArrow:
                         {
                         LooseFocus(
-                            MFsControlBarObserver::EEventFocusLostAtBottom );
+                                MFsControlBarObserver::EEventFocusLostAtBottom );
                         eventHandled = ETrue;
                         break;
                         }
@@ -713,6 +726,9 @@
         // <cmail> Touch
         case EEventButtonTouchReleased:
             {
+            // Notify that button is released, focus can be hidden.
+            NotifyObservers( MFsControlBarObserver::EEventFocusVisibilityChanged );
+
             if (iTouchEnabled && iTouchWasEnabled)
                 {
                 if( aButtonId > KErrNotFound )
--- a/emailuis/uicomponents/src/fscontrolbarmodel.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/src/fscontrolbarmodel.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -496,6 +496,26 @@
         }
     }
 
+// ---------------------------------------------------------------------------
+// Set new position and size
+// ---------------------------------------------------------------------------
+//
+void CFsControlBarModel::SetRect( const TRect& aRect )
+    {
+    iSize = aRect.Size();
+    iWidthUseDefault = EFalse;
+    iHeightUseDefault = EFalse;
+    iTl = aRect.iTl;
+    }
+
+// ---------------------------------------------------------------------------
+// Get top-left position of the bar
+// ---------------------------------------------------------------------------
+//
+TPoint CFsControlBarModel::Pos() const
+    {
+    return iTl;
+    }
 
 // ---------------------------------------------------------------------------
 // Sets width in pixels of controlbar and refreshes control.
--- a/emailuis/uicomponents/src/fscontrolbarvisualiser.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/src/fscontrolbarvisualiser.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -289,6 +289,7 @@
     {
     FUNC_LOG;
     iBarLayout->SetSize( iModel.Size() );
+    iBarLayout->SetPos( iModel.Pos() );
     RefreshL();
     }
 
@@ -334,7 +335,6 @@
             {
             iSelector->Brushes()->Remove( iSelector->Brushes()->Count() - 1 );
             }
-
         iSelector->Brushes()->AppendL(
             aSelectorBrush, EAlfDoesNotHaveOwnership );
         iSelector->SetOpacity( aOpacity );
@@ -395,11 +395,10 @@
         TBool aShow, TBool aFromTouch )
     {
     FUNC_LOG;
-
     TReal32 opacity( 0 );
     if( aShow )
         {
-        opacity = 1;
+        opacity = KFsSelectorOpacity;
         }
     if( iSelector )
         {
@@ -429,7 +428,7 @@
     TBool aFastDraw )
     {
     FUNC_LOG;
-    CFsControlButtonVisualiser* vis( NULL );
+    CFsControlButtonVisualiser* vis = NULL;
 
     // set selector's delay
     TInt transitionTime( aFastDraw ? 0 : iModel.SelectorTransitionTime() );
@@ -483,6 +482,7 @@
     size += TSize( KFsSelectorPaddingLeft + KFsSelectorPaddingRight,
         KFsSelectorPaddingTop + KFsSelectorPaddingBottom );
 
+    // Hides transition when item selected via touch
     if( iTouchPressed )
         {
         transitionTime = 0;
@@ -529,7 +529,7 @@
 void CFsControlBarVisualiser::HideSelector()
     {
     FUNC_LOG;
-    iLastSelectedButton = -1;
+    iLastSelectedButton = KErrNotFound;
     if ( iSelector )
         {
         // Flags used because otherwise it would generate a callback here
--- a/emailuis/uicomponents/src/fscontrolbutton.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/src/fscontrolbutton.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -614,8 +614,7 @@
                 if ( aEvent.KeyEvent().iScanCode == EStdKeyDevice3 )
                     {
                     iParent.HandleButtonEvent(
-                        MFsControlButtonObserver::EEventButtonPressed,
-                        -1 );
+                        MFsControlButtonObserver::EEventButtonPressed, -1 );
                     result = ETrue;
                     }
                 break;
@@ -643,8 +642,7 @@
                 if ( aEvent.KeyEvent().iScanCode == EStdKeyDevice3 )
                     {
                     iParent.HandleButtonEvent(
-                        MFsControlButtonObserver::EEventButtonReleased,
-                        -1 );
+                        MFsControlButtonObserver::EEventButtonReleased, -1 );
                     result = ETrue;
                     }
                 break;
--- a/emailuis/uicomponents/src/fscontrolbuttonvisualiser.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/src/fscontrolbuttonvisualiser.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -15,8 +15,6 @@
 *
 */
 
-
-//<cmail> SF
 #include "emailtrace.h"
 #include <alf/alfcontrol.h>
 #include <alf/alfdecklayout.h>
@@ -29,9 +27,9 @@
 #include <alf/alfgradientbrush.h>
 #include <alf/alfframebrush.h>
 #include <alf/alfimagebrush.h>
+#include <alf/alfshadowborderbrush.h>
 #include <alf/alfbrusharray.h>
 #include <alf/alftextstyle.h>
-//</cmail>
 #include <AknsConstants.h>
 #include <AknUtils.h>
 #include <touchlogicalfeedback.h>
@@ -44,6 +42,9 @@
 #include "fscontrolbar.h"
 
 const TInt KFsDefaultFontStyle = EAlfTextStyleNormal;
+const TInt KDefaultShadowBorderWidth( 8 );
+const TReal KShadowBorderOpacity( 0.08 );
+const TInt KButtonBorderSize( 8 );
 
 
 // ======== MEMBER FUNCTIONS ========
@@ -148,6 +149,7 @@
         }
 
     delete iBgColorBrush;
+    delete iShadowBorderBrush;
     delete iTextFontSpec;
     }
 
@@ -168,18 +170,62 @@
     if ( !iBgColorBrush )
         {
         iBgColorBrush = CAlfGradientBrush::NewL( iParent->Env() );
-        SetBackgroundColor( iButtonModel->TextColor(
-            CFsControlButtonModel::EButtonBackground ) );
-        iButtonLayout->Brushes()->AppendL(
-            iBgColorBrush, EAlfDoesNotHaveOwnership );
+        if( iShowShadow )
+            {
+            iBgColorBrush->SetOpacity( KShadowBorderOpacity ); 
+            iBgColorBrush->SetColor(KRgbBlack);
+            }
+        else
+            {
+            iBgColorBrush->SetOpacity( 0 );
+            }
+
+        iBgColorBrush->SetLayer( EAlfBrushLayerBackground );
+        iButtonLayout->Brushes()->AppendL( iBgColorBrush,
+										   EAlfDoesNotHaveOwnership );
         }
 
+    iUseDefaultBackground = ETrue;
+    
+    // Add a shadow border brush to outline the buttons with a shadowed border.
+    if ( iShowShadow && !iShadowBorderBrush )
+    	{
+    	iShadowBorderBrush = CAlfShadowBorderBrush::NewL( 
+    		iParent->Env(), TAlfMetric( KDefaultShadowBorderWidth ) );
+    	iShadowBorderBrush->SetOpacity( KShadowBorderOpacity );
+    	iShadowBorderBrush->SetLayer( EAlfBrushLayerBackground );
+    	iButtonLayout->Brushes()->AppendL( iShadowBorderBrush,
+										   EAlfDoesNotHaveOwnership );
+    	}
+
+    UpdateVisualThemeL();
+    
     // create needed visuals
     CreateButtonVisualsL();
 
     UpdateBarLayout();
     }
 
+// ---------------------------------------------------------------------------
+// CFsControlButtonVisualiser::UpdateVisualThemeL
+// ---------------------------------------------------------------------------
+//
+void CFsControlButtonVisualiser::UpdateVisualThemeL()
+    {
+    if( iUseDefaultBackground )
+        {
+        ClearBackgroundImage();
+        iDefaultBgBrush = CAlfFrameBrush::NewL( iParent->Env(), KAknsIIDQsnFrButtonTb );  
+        iBgBrush = iDefaultBgBrush;
+        iButtonLayout->Brushes()->AppendL( iBgBrush, EAlfDoesNotHaveOwnership );
+        UpdateBarLayout();
+        }
+    else if ( iBgColorBrush )
+        {
+        SetBackgroundColor( iButtonModel->TextColor(
+            CFsControlButtonModel::EButtonBackground ) );
+        }
+    }
 
 // ---------------------------------------------------------------------------
 // From class CFsControlButtonVisualiserBase.
@@ -338,9 +384,10 @@
 
     // As the ownership of the new brush is gained the pointer can't be lost.
     CleanupStack::PushL( aImage );
-    iButtonLayout->Brushes()->AppendL( aImage, EAlfDoesNotHaveOwnership );
+    iButtonLayout->Brushes()->InsertL( 0, aImage, EAlfDoesNotHaveOwnership );
     CleanupStack::Pop( aImage );
 
+    iUseDefaultBackground = EFalse;
     iBgBrush = aImage;
     }
 
@@ -365,7 +412,10 @@
 EXPORT_C void CFsControlButtonVisualiser::ClearBackgroundColor()
     {
     FUNC_LOG;
-    iBgColorBrush->SetOpacity( 0 );
+    if( iBgColorBrush )
+        {
+        iBgColorBrush->SetOpacity( 0 );
+        }
     }
 
 
@@ -389,6 +439,7 @@
             }
         delete iBgBrush;
         iBgBrush = NULL;
+        iDefaultBgBrush = NULL;
         }
     }
 
@@ -631,6 +682,16 @@
     // Same size for the content
     iButtonContentLayout->SetSize( iButtonModel->Size() );
 
+    if( iDefaultBgBrush )
+        {
+        TSize size =  iButtonModel->Size();
+        TRect fullRect = TRect( size );
+        TRect innerRect = fullRect;
+        innerRect.Shrink( KButtonBorderSize,KButtonBorderSize );
+        TRAP_IGNORE(
+                iDefaultBgBrush->SetFrameRectsL( innerRect, fullRect ); );
+        }
+    
     if ( iLabelFirstLine )
         {
         iLabelFirstLine->SetWrapping( textWrapping );
@@ -828,7 +889,7 @@
         if ( iTextStyleManager )
             {
             ResolveCharFormat( charFormat, iLabelFirstLine );
-            charFormat.iFontPresentation.iUnderline = EUnderlineOn;
+            charFormat.iFontPresentation.iUnderline = EUnderlineOff;
             TRAPD( leaveErr,
                 styleId = iTextStyleManager->GetStyleIDL( charFormat ) );
             // Use modified style if possible, otherwise use the default
@@ -850,7 +911,7 @@
         if ( iTextStyleManager )
             {
             ResolveCharFormat( charFormat, iLabelSecondLine );
-            charFormat.iFontPresentation.iUnderline = EUnderlineOn;
+            charFormat.iFontPresentation.iUnderline = EUnderlineOff;
             TRAPD( leaveErr,
                 styleId = iTextStyleManager->GetStyleIDL( charFormat ) );
             // Use modified style if possible, otherwise use the default
@@ -954,10 +1015,7 @@
         iIconAContainer =
             CAlfLayout::AddNewL( *iParent, iButtonContentLayout );
         iIconA = CAlfImageVisual::AddNewL( *iParent, iIconAContainer );
-        // <cmail> Platform layout change
-        //iIconA->SetScaleMode( CAlfImageVisual::EScaleNormal );
-        iIconA->SetScaleMode( CAlfImageVisual::EScaleFit );
-        // </cmail> Platform layout change
+        iIconA->SetScaleMode( CAlfImageVisual::EScaleFitInside );
         iIconAContainer->SetClipping( ETrue );
         }
 
@@ -1008,6 +1066,7 @@
 EXPORT_C TInt CFsControlButtonVisualiser::CalculateButtonSize()
     {
     FUNC_LOG;
+
     if ( iButtonModel->ContainsElement( ECBElemLabelFirstLine ) )
         {
         // to get correct value from ExpandRectWithContent method
@@ -1021,7 +1080,7 @@
         TRect textRect( 0, 0,
             padding.iTl.iX + padding.iBr.iX + size.iWidth,
             padding.iTl.iY + padding.iBr.iY + size.iHeight );
-
+        
         if ( iButtonModel->ContainsElement( ECBElemLabelSndLine ) )
             {
             // to get correct value from ExpandRectWithContent method
@@ -1096,7 +1155,7 @@
         return iIconBContainer->Size().Target().iX;
         }
 
-    return iButtonContentLayout->Size().Target().iX;;
+    return iButtonContentLayout->Size().Target().iX;
     }
 
 
@@ -1171,40 +1230,26 @@
                 CFsLayoutManager::EFsLmMainSpFsCtrlbarDdmenuPaneG1,
                 iconB, 1 );
             break;
-
-        //<CMAIL> As a device user, I want Message List items to follow platform layouts to be consistent with other apps
-
-        /*
-        REMOVED, Not needed anymore.
-
-        case ECBTypeTwoLinesLabelOnly:
-            text1 = TRect(0,0,60,20);
-            text2 = TRect(0,0,60,20);
-            break;
-        case ECBTypeTwoLinesLabelIconA:
-            iconA = TRect(0,0,16,16);
-            text1 = TRect(0,0,60,20);
-            text2 = TRect(0,0,60,20);
-            break;
-        case ECBTypeTwoLinesLabelIconB:
-            text1 = TRect(0,0,60,20);
-            text2 = TRect(0,0,60,20);
-            iconB = TRect(0,0,16,16);
-            break;
-        case ECBTypeTwoLinesLabelTwoIcons:
-            iconA = TRect(0,0,16,16);
-            text1 = TRect(0,0,60,20);
-            text2 = TRect(0,0,60,20);
-            iconB = TRect(0,0,16,16);
-            break;
-        */
-        //<CMAIL>
-
         default:
             break;
         }
-
-    // <cmail> Platform layout changes
+    
+    // Buttons have different sizes so adapt the used rectangle dynamically
+    TSize buttonSize = iButtonModel->Size();
+    buttonSize -= TPoint( KButtonBorderSize, KButtonBorderSize ); // shrink frame border size
+    
+    // If there is no text in the button, center the icon to the button
+    if( !iLabelFirstLine || iLabelFirstLine->Text().Length() == 0 )
+        {
+        TSize oldIconSize = iconA.Size();
+        iconA.SetRect( TPoint( 
+                iconA.iTl .iX + ( buttonSize.iWidth - oldIconSize.iWidth ) / 2, 
+                iconA.iTl .iY + ( buttonSize.iHeight - oldIconSize.iHeight ) / 2 ),
+                oldIconSize );
+        }
+    iconA.SetHeight( buttonSize.iHeight );
+    text1.SetHeight( buttonSize.iHeight );
+    
     if ( iButtonModel->ContainsElement( ECBElemIconA ) )
         {
         const TSize& size( iconA.Size() );
--- a/emailuis/uicomponents/src/fstextviewerselectsmanager.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/src/fstextviewerselectsmanager.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -107,9 +107,13 @@
                 }
 
             }
-            select->SetId( aId );
-            select->AppendVisualL( aVisual );
-            iSelects.AppendL( select );
+        
+			if (select)
+				{
+				select->SetId( aId );
+				select->AppendVisualL( aVisual );
+				iSelects.AppendL( select );
+				}
         }
     else
         {
--- a/emailuis/uicomponents/src/fstreelist.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/src/fstreelist.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -1019,7 +1019,11 @@
         break;
         }
     // </cmail>
-
+    case MFsTreeVisualizerObserver::EFsChangeFocusVisibility:
+        {
+        listEvent = MFsTreeListObserver::EFsFocusVisibilityChange;
+        break;
+        }
     default:
         {
         return;
--- a/emailuis/uicomponents/src/fstreenodevisualizerbase.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/src/fstreenodevisualizerbase.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -258,7 +258,7 @@
     FUNC_LOG;
     if ( iFlags & KFsTreeListItemManagedLayout )
         {
-        CFsLayoutManager::TFsLayoutMetrics normalSizeMetrics (CFsLayoutManager::EFsLmListSingleDycRowPane);
+        CFsLayoutManager::TFsLayoutMetrics normalSizeMetrics (CFsLayoutManager::EFsLmListSingleFsDycPane);
         TRect parentLayoutRect(0,0,0,0);
         TSize size(0,0);
         TBool retVal(EFalse);
--- a/emailuis/uicomponents/src/fstreeplainonelineitemvisualizer.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/src/fstreeplainonelineitemvisualizer.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -223,6 +223,10 @@
         }
 
     TRect currentSize = iSize;
+    if ( !IsLayoutHintSet( EFolderLayout ) )
+        {
+        CFsLayoutManager::LayoutMetricsRect(currentSize, CFsLayoutManager::EFsLmListSingleDycRowPane, currentSize);
+        }
     if (CFsLayoutManager::IsMirrored())
         {
         currentSize.iBr = currentSize.iBr - TPoint(aIndentation, 0);
@@ -572,8 +576,12 @@
                 }
                 }
 
-            iTextMarquee->StopScrolling();           
-            iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapTruncate);
+            iTextMarquee->StopScrolling();    
+            
+            if ( iTextVisual )
+            	{
+            	iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapTruncate);
+            	}
             }
         }
     }
--- a/emailuis/uicomponents/src/fstreeplainonelinenodevisualizer.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/src/fstreeplainonelinenodevisualizer.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -407,13 +407,17 @@
                 iSize );*/
         CFsLayoutManager::LayoutMetricsSize(
                 parentLayoutRect,
-                CFsLayoutManager::EFsLmListSingleDycRowPane,
+                CFsLayoutManager::EFsLmListSingleFsDycPane,
                 iSize );
         // </cmail> Platform layout change
         }
 
     //one line node is not extendable
     TRect currentSize = iSize;
+    if ( !IsLayoutHintSet( EFolderLayout ) )
+        {
+        CFsLayoutManager::LayoutMetricsRect(currentSize, CFsLayoutManager::EFsLmListSingleDycRowPane, currentSize);
+        }
     if (CFsLayoutManager::IsMirrored())
         {
         currentSize.iBr = currentSize.iBr - TPoint(aIndentation, 0);
@@ -788,7 +792,11 @@
                 }
 
             iTextMarquee->StopScrolling();
-            iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapTruncate);
+            
+            if ( iTextVisual )
+            	{
+            	iTextVisual->SetWrapping(CAlfTextVisual::ELineWrapTruncate);
+            	}
             }
         }
     }
--- a/emailuis/uicomponents/src/fstreeplaintwolineitemvisualizer.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/src/fstreeplaintwolineitemvisualizer.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -12,7 +12,7 @@
 * Contributors:
 *
 *  Description : A visualizer for data items with plain text.
-*  Version     : %version: tr1sido#12 %
+*  Version     : %version: tr1sido#14 %
 *
 */
 
@@ -305,7 +305,7 @@
     TInt exSizeVariety( 1 );
     TInt preSizeVariety( 2 );
     TInt flagIconVariety( 0 );
-    TInt flagIconRow( 0 );
+    TInt flagIconRow( 1 );
 
     
     CFsLayoutManager::TFsLayoutMetrics firstLineTextParentMetrics = 
@@ -1439,8 +1439,11 @@
         }
     else
         {
-        opacity.SetValueNow(0.0f);
-        iIconMarked->SetOpacity(opacity);
+        if (iIconMarked)
+        	{
+        	opacity.SetValueNow(0.0f);
+        	iIconMarked->SetOpacity(opacity);
+        	}
         }
 
     if ( iPreviewPaneTextVisual )
--- a/emailuis/uicomponents/src/fstreevisualizerbase.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/uicomponents/src/fstreevisualizerbase.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -19,9 +19,6 @@
 //////SYSTEM INCLUDES
 #include "emailtrace.h"
 #include <AknUtils.h>
-//<cmail> removed __FS_ALFRED_SUPPORT flag
-//#include <fsconfig.h>
-//</cmail> removed __FS_ALFRED_SUPPORT flag
 #include <StringLoader.h>
 #include <avkon.rsg> // R_AVKON_EMPTY_POPUP_LIST_TEXT
 #include <centralrepository.h>
@@ -1526,12 +1523,12 @@
 //
 void CFsTreeVisualizerBase::SetFocusVisibility( TBool aShow )
     {
-    if( iFocusVisible != aShow )
+    if ( iFocusVisible != aShow )
         {
         iFocusVisible = aShow;
         TRAP_IGNORE(
-            MakeSelectorVisibleL(aShow);
-            UpdateItemL(iFocusedItem); );
+            MakeSelectorVisibleL( aShow );
+            UpdateItemL( iFocusedItem ); );
         }
     }
 
@@ -1578,18 +1575,15 @@
                         {
                         eventHandled = ETrue;
                         iTouchPressed = EFalse;
-                        UpdateItemL( iFocusedItem );
-                        if( !IsFocusShown() )
-                            {
-                            MakeSelectorVisibleL( EFalse );
-                            }
+                        iVisualizerObserver->TreeVisualizerEventL(
+                            MFsTreeVisualizerObserver::EFsChangeFocusVisibility );
                         INFO_2( "EButton1Up (%d, %d)", pos.iX, pos.iY );
-                        if( !iDragHandler->IsFlicking() )
-                            {
-                            iPhysics->StopPhysics();
-                            }
-                        iDragHandler->PointerUp( aEvent.PointerEvent(), id );
                         }
+                    if( !iDragHandler->IsFlicking() )
+                        {
+                        iPhysics->StopPhysics();
+                        }
+                    iDragHandler->PointerUp( aEvent.PointerEvent(), id );
                     break;
                     }
                 case TPointerEvent::EDrag:
@@ -1623,6 +1617,11 @@
                     }
                 }
             }
+        else
+        	{
+        	iVisualizerObserver->TreeVisualizerEventL(
+					MFsTreeVisualizerObserver::EFsChangeFocusVisibility );
+        	}
         }
     return eventHandled;
     }
@@ -1682,34 +1681,41 @@
 // Sets the specified item as focused.
 // ---------------------------------------------------------------------------
 //
-void CFsTreeVisualizerBase::SetFocusedItemL(const TFsTreeItemId aItemId,
-        TBool /*aCheckFocus*/)
+void CFsTreeVisualizerBase::SetFocusedItemL( const TFsTreeItemId aItemId,
+		TBool /*aCheckFocus*/ )
     {
     FUNC_LOG;
     MFsTreeItemVisualizer* visualizer = NULL;
-    if (aItemId != iFocusedItem)
-        {
-        visualizer = iTreeData->ItemVisualizer(iFocusedItem);
-        if (visualizer)
+
+    if ( aItemId != iFocusedItem )
+        {
+        visualizer = iTreeData->ItemVisualizer( iFocusedItem );
+
+        if ( visualizer )
             {
-            visualizer->UpdateL(iTreeData->ItemData(iFocusedItem), EFalse,
-                    iTreeData->Level(iFocusedItem), iMarkIcon, iMenuIcon, 0);
+            visualizer->UpdateL( iTreeData->ItemData( iFocusedItem ), EFalse,
+            		iTreeData->Level( iFocusedItem ), iMarkIcon, iMenuIcon, 0 );
             }
+
         iFocusedItem = aItemId;
         }
-    visualizer = iTreeData->ItemVisualizer(iFocusedItem);
-    if (visualizer)
+
+    visualizer = iTreeData->ItemVisualizer( iFocusedItem );
+
+    if ( visualizer )
         {
         TBool focused = IsFocusShown();    
-        visualizer->UpdateL(iTreeData->ItemData(iFocusedItem), focused,
-                iTreeData->Level(iFocusedItem), iMarkIcon, iMenuIcon, 0);
-        }
-    if (iFocusedItem != KFsTreeNoneID)
+        visualizer->UpdateL( iTreeData->ItemData( iFocusedItem ), focused,
+                iTreeData->Level( iFocusedItem ), iMarkIcon, iMenuIcon, 0 );
+        }
+
+    if ( iFocusedItem != KFsTreeNoneID )
         {
         UpdateSelectorVisualL();
-        if (!iViewPort.ItemFullyVisible(iFocusedItem))
+
+        if ( !iViewPort.ItemFullyVisible( iFocusedItem ) )
             {
-            iViewPort.ScrollItemToViewL(iFocusedItem);
+            iViewPort.ScrollItemToViewL( iFocusedItem );
             }
         }
     }
@@ -2558,7 +2564,6 @@
             iWatermarkLayout->Brushes()->Reset();
             iWatermarkLayout->SetFlag(EAlfVisualChanged);
             }
-        }
 
     CAlfGradientBrush* backgroundBrush = CAlfGradientBrush::NewL(
             iOwnerControl->Env());
@@ -2566,6 +2571,7 @@
     backgroundBrush->SetColor(aColor);
 
     iWatermarkLayout->Brushes()->AppendL(backgroundBrush, EAlfHasOwnership);
+        }    
     }
 
 // ---------------------------------------------------------------------------
@@ -3616,6 +3622,7 @@
         {
         iScrollbarModel.SetFocusPosition(iViewPort.Position().iY);
         iScrollBar->SetModelL(&iScrollbarModel);
+        iScrollBar->DrawNow();
         }
     }
 
@@ -3642,6 +3649,7 @@
     iScrollbarModel.SetWindowSize(pageSize);
     iScrollbarModel.SetFocusPosition(iViewPort.Position().iY);
     iScrollBar->SetModelL(&iScrollbarModel);
+    iScrollBar->DrawNow();
 
     RArray<TInt> columns;
     CleanupClosePushL(columns);
@@ -3650,15 +3658,32 @@
             == EFsTreeVisible)
         {
         iScrollBar->SetRect(scrollPane);
-        columns.AppendL(listPane.Width());
-        columns.AppendL(scrollPane.Width());
+        if (AknLayoutUtils::LayoutMirrored())
+            {
+            columns.AppendL(scrollPane.Width());
+            columns.AppendL(listPane.Width());
+            }
+        else
+            {
+            columns.AppendL(listPane.Width());
+            columns.AppendL(scrollPane.Width());
+            }
         iComponentLayout->SetColumnsL(columns);
         iScrollBar->MakeVisible(ETrue);
         updateLayouts = ETrue;
         }
     else if (!iViewPort.IsScrollBarNeeded())
         {
-        columns.AppendL(listPane.Width());
+        if (AknLayoutUtils::LayoutMirrored())
+            {
+            columns.AppendL(0);
+            columns.AppendL(listPane.Width());
+            }
+        else
+            {
+            columns.AppendL(listPane.Width());
+            columns.AppendL(0);
+            }
         iComponentLayout->SetColumnsL(columns);
         iScrollBar->MakeVisible(EFalse);
         updateLayouts = ETrue;
@@ -3922,59 +3947,64 @@
 void CFsTreeVisualizerBase::UpdateSelectorVisualL(TInt /*aTime*/)
     {
     FUNC_LOG;
-    if (iSelectorVisual)
-        {
-        if (iFocusedItem == KFsTreeNoneID || !iFlags.IsSet(EListFocused) || !IsFocusShown())
+
+    if ( iSelectorVisual )
+        {
+        if ( iFocusedItem == KFsTreeNoneID ||
+        	 !iFlags.IsSet( EListFocused ) || !IsFocusShown() )
             {
             TAlfTimedValue opacity;
-            opacity.SetValueNow(0.0f);
-            iSelectorVisual->SetOpacity(opacity);
+            opacity.SetValueNow( 0.0f );
+            iSelectorVisual->SetOpacity( opacity );
             }
         else
             {
             //check if item is visible
-            MFsTreeItemVisualizer* vis(NULL);
-
-            iListLayout->SetFlag(EAlfVisualFlagFreezeLayout);
-            iListItemBackgroundLayout->SetFlag(EAlfVisualFlagFreezeLayout);
-
-            TRect itemRect(iViewPort.ItemRect(iFocusedItem));
-            if (itemRect.Height())
+            MFsTreeItemVisualizer* vis( NULL );
+
+            iListLayout->SetFlag( EAlfVisualFlagFreezeLayout );
+            iListItemBackgroundLayout->SetFlag( EAlfVisualFlagFreezeLayout );
+
+            TRect itemRect( iViewPort.ItemRect( iFocusedItem ) );
+
+            if ( itemRect.Height() )
                 {
                 TSize currSize;
                 currSize.iWidth = iListLayout->Size().iX.Target() - 2
                         * iListLayout->PaddingInPixels().iTl.iX;
                 currSize.iHeight = itemRect.Height();
-                iSelectorVisual->SetSize(currSize, 0);
+                iSelectorVisual->SetSize( currSize, 0 );
                 TAlfRealPoint pNow;
                 pNow.iY = itemRect.iTl.iY;
                 pNow.iX = iListLayout->PaddingInPixels().iTl.iX;
-                iSelectorVisual->SetPos(pNow, 0);
-
-                TAlfTimedValue opacity(iSelectorOpacity, 0);
-                iSelectorVisual->SetOpacity(opacity);
-                if (iMarqueeType != EFsTextMarqueeNone)
+                iSelectorVisual->SetPos( pNow, 0 );
+
+                TAlfTimedValue opacity( iSelectorOpacity, 0 );
+                iSelectorVisual->SetOpacity( opacity );
+                iFocusVisible = ETrue;
+
+                if ( iMarqueeType != EFsTextMarqueeNone )
                     {
-                    vis = iTreeData->ItemVisualizer(iFocusedItem);
-                    vis->MarqueeL(iMarqueeType, iMarqueeSpeed,
-                            iMarqueStartDelay, iMarqueCycleStartDelay,
-                            iMarqueeRepetitions);
+                    vis = iTreeData->ItemVisualizer( iFocusedItem );
+                    vis->MarqueeL( iMarqueeType, iMarqueeSpeed,
+                    		iMarqueStartDelay, iMarqueCycleStartDelay,
+                            iMarqueeRepetitions );
                     }
                 }
             else
                 {
                 TAlfTimedValue opacity;
-                opacity.SetValueNow(0.0f);
-                iSelectorVisual->SetOpacity(opacity);
+                opacity.SetValueNow( 0.0f );
+                iSelectorVisual->SetOpacity( opacity );
                 }
 
-            iListLayout->ClearFlag(EAlfVisualFlagFreezeLayout);
-            iListItemBackgroundLayout->ClearFlag(EAlfVisualFlagFreezeLayout);
+            iListLayout->ClearFlag( EAlfVisualFlagFreezeLayout );
+            iListItemBackgroundLayout->ClearFlag( EAlfVisualFlagFreezeLayout );
             }
         }
-    else if (iFocusedItem != KFsTreeNoneID && iFlags.IsSet(EListFocused))
-        {
-        MakeSelectorVisibleL(ETrue);
+    else if ( iFocusedItem != KFsTreeNoneID && iFlags.IsSet( EListFocused ) )
+        {
+        MakeSelectorVisibleL( ETrue );
         }
     }
 
@@ -4622,8 +4652,18 @@
     iComponentLayout->EnableBrushesL();
     iComponentLayout->UpdateChildrenLayout();
 
-    iListDeck = CAlfDeckLayout::AddNewL(*iOwnerControl, iComponentLayout);
-
+    if (AknLayoutUtils::LayoutMirrored())
+        {
+        iDummyScrollbar = CAlfImageVisual::AddNewL(*iOwnerControl);
+        iComponentLayout->Append(iDummyScrollbar);
+        iListDeck = CAlfDeckLayout::AddNewL(*iOwnerControl, iComponentLayout);
+        }
+    else
+        {
+        iListDeck = CAlfDeckLayout::AddNewL(*iOwnerControl, iComponentLayout);
+        iDummyScrollbar = CAlfImageVisual::AddNewL(*iOwnerControl);
+        iComponentLayout->Append(iDummyScrollbar);
+        }
     iListItemBackgroundLayout = CAlfFlowLayout::AddNewL(*iOwnerControl,
             iListDeck);
     iListItemBackgroundLayout->SetFlowDirection(CAlfFlowLayout::EFlowVertical);
@@ -4667,9 +4707,6 @@
     iScrollBar->MakeVisible(EFalse);
     iScrollBar->SetModelL(&iScrollbarModel);
 
-    iDummyScrollbar = CAlfImageVisual::AddNewL(*iOwnerControl);
-    iComponentLayout->Append(iDummyScrollbar);
-
     // </cmail>
 
     iFadeEffect = CFsFadeEffect::NewL(iOwnerControl, this, iRootLayout, 0);
@@ -5270,6 +5307,7 @@
         {
         return ETrue;
         }
+
     return EFalse;
     }
 
Binary file emailuis/widget/emailwidgetsettings/conf/cmailwidget.confml has changed
Binary file emailuis/widget/emailwidgetsettings/conf/cmailwidget_2001E272.crml has changed
--- a/emailuis/widget/emailwidgetsettings/data/emailwidgetsettings.rss	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/emailwidgetsettings/data/emailwidgetsettings.rss	Thu Jan 07 12:38:38 2010 +0200
@@ -88,7 +88,7 @@
 
 RESOURCE TBUF r_emailwidgetsettings_create_new_mailbox
     {
-    buf = "\t"qtn_hs_widget_setting_new_mailbox"\t\t";
+    buf = "0\t"qtn_hs_widget_setting_new_mailbox"\t\t";
     }
 
 // End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/widget/emailwidgetsettings/data/iconlist.txt	Thu Jan 07 12:38:38 2010 +0200
@@ -0,0 +1,2 @@
+-c16,8 qgn_indi_cmail_drop_email_account.svg
+-c16,8 qgn_prop_cmail_new_mailbox.svg
--- a/emailuis/widget/emailwidgetsettings/group/bld.inf	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/emailwidgetsettings/group/bld.inf	Thu Jan 07 12:38:38 2010 +0200
@@ -21,12 +21,19 @@
 PRJ_PLATFORMS
 DEFAULT
 
+PRJ_MMPFILES
+emailwidgetsettings.mmp
+
+PRJ_EXTENSIONS
+START EXTENSION s60/mifconv
+OPTION TARGETFILE emailwidgetsettings.mif
+OPTION HEADERFILE emailwidgetsettings.mbg
+OPTION SOURCEFILE ../data/iconlist.txt
+END
+
 PRJ_EXPORTS
 ../rom/emailwidgetsettings.iby          CORE_APP_LAYER_IBY_EXPORT_PATH(emailwidgetsettings.iby)
 ../loc/emailwidgetsettings.loc          APP_LAYER_LOC_EXPORT_PATH(emailwidgetsettings.loc)
 
 ../conf/cmailwidget.confml              APP_LAYER_CONFML(cmailwidget.confml)
 ../conf/cmailwidget_2001E272.crml       APP_LAYER_CRML(cmailwidget_2001E272.crml)
-
-PRJ_MMPFILES
-emailwidgetsettings.mmp
--- a/emailuis/widget/emailwidgetsettings/group/emailwidgetsettings.mmp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/emailwidgetsettings/group/emailwidgetsettings.mmp	Thu Jan 07 12:38:38 2010 +0200
@@ -76,5 +76,6 @@
 LIBRARY          centralrepository.lib
 LIBRARY          commonengine.lib
 LIBRARY          cmaillogger.lib
+LIBRARY          egul.lib
 
 // End of file
--- a/emailuis/widget/emailwidgetsettings/inc/emailwidgetsettingslistview.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/emailwidgetsettings/inc/emailwidgetsettingslistview.h	Thu Jan 07 12:38:38 2010 +0200
@@ -50,6 +50,11 @@
 private:
 	void CreateCbaL(MEikCommandObserver* aObserver);
 	void CreateListBoxL(MEikListBoxObserver* aObserver);
+    void SetupListIconsL();
+    void AppendIconL(
+            CArrayPtr<CGulIcon>* aIcons,
+            const TInt aFileBitmapId, 
+            const TInt aFileMaskId);
 	TInt GetSettingToAssociateL(const TDesC& aCid);
 	void LaunchEmailWizardL();
 	
@@ -60,6 +65,7 @@
 	CEikButtonGroupContainer*       iPopoutCba;
 	CEikColumnListBox*	            iListBox;
 	CDesCArrayFlat*                 iAccountNames;
+	CDesCArrayFlat*                 iDomains;
     CArrayFixFlat<TFSMailMsgId>*    iAccountIds;
 	CEmailWidgetSettingsMailboxes*  iMailboxes;
     CEikonEnv*                      iEnv;	
--- a/emailuis/widget/emailwidgetsettings/inc/emailwidgetsettingsmailboxes.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/emailwidgetsettings/inc/emailwidgetsettingsmailboxes.h	Thu Jan 07 12:38:38 2010 +0200
@@ -43,18 +43,27 @@
 
     /**
      * 
+     * @param
      * @param 
      */
     void GetMailboxIdL(TInt aNum, TFSMailMsgId& aId );
     
     /**
      * 
+     * @param
      * @param 
      */	
     void GetMailboxNameL( TInt aNum, TDes& aMailboxName );
 
     /**
      * 
+     * @param
+     * @param  
+     */
+    void GetDomainL(TInt aNum, TDes& aDomain);
+    
+    /**
+     * 
      */
     TInt MailboxCount();    
 
--- a/emailuis/widget/emailwidgetsettings/rom/emailwidgetsettings.iby	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/emailwidgetsettings/rom/emailwidgetsettings.iby	Thu Jan 07 12:38:38 2010 +0200
@@ -23,5 +23,6 @@
 file=ABI_DIR\BUILD_DIR\emailwidgetsettings.exe                          PROGRAMS_DIR\emailwidgetsettings.exe
 data=\epoc32\data\z\private\10003a3f\apps\emailwidgetsettings_reg.rsc   private\10003a3f\apps\emailwidgetsettings_reg.rsc
 data=DATAZ_\APP_RESOURCE_DIR\emailwidgetsettings.rsc                    APP_RESOURCE_DIR\emailwidgetsettings.rsc
+SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,emailwidgetsettings)
 
 #endif // EMAILWIDGETSETTINGS_IBY
--- a/emailuis/widget/emailwidgetsettings/src/emailwidgetsettingslistviewcontainer.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/emailwidgetsettings/src/emailwidgetsettingslistviewcontainer.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -20,11 +20,14 @@
 #include <eikmop.h>
 #include <bacline.h>
 #include <StringLoader.h>
+#include <akniconarray.h>
 #include <emailwidgetsettings.rsg>
+#include <emailwidgetsettings.mbg>
 
 #include "emailtrace.h"
 #include "emailwidgetsettingslistview.h"
 #include "cmailwidgetcenrepkeys.h"
+#include "CFSMailClient.h"
 
 using namespace AknLayout;
 
@@ -33,6 +36,7 @@
 const TInt KMaxDescLen = 256;
 const TUid KUidWizardApp = { 0x10281c96 };
 const TUid KUidEmailWizardView = { 0x10281C9A };
+_LIT( KMifPath, "z:\\resource\\apps\\emailwidgetsettings.mif");
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -42,6 +46,7 @@
 //
 CEmailWidgetSettingsListViewContainer::CEmailWidgetSettingsListViewContainer()
     {
+    FUNC_LOG;        
     }
 
 // ---------------------------------------------------------------------------
@@ -69,23 +74,28 @@
 //
 void CEmailWidgetSettingsListViewContainer::CreateListBoxL(MEikListBoxObserver* aObserver)
     {
+    FUNC_LOG;        
     TInt count = iMailboxes->MailboxCount();
 
-    iListBox = new(ELeave) CAknSingleStyleListBox;
+    iListBox = new(ELeave) CAknSingleGraphicStyleListBox;
     iListBox->SetContainerWindowL( *this);
     iListBox->ConstructL( this, EAknListBoxSelectionList );
     iAccountNames = new (ELeave) CDesCArrayFlat(count + 1);
+    iDomains = new (ELeave) CDesCArrayFlat(count);
     if (count)
         {
 		iAccountIds = new ( ELeave ) CArrayFixFlat<TFSMailMsgId>(count);
 		}
     for (TInt i = 0; i < count; i++)
         {
-        TBuf<KMaxDescLen> name;        
+        TBuf<KMaxDescLen> name;
+        TBuf<KMaxDescLen> domain;        
         TFSMailMsgId id;
         iMailboxes->GetMailboxNameL(i, name);
+        iMailboxes->GetDomainL(i, domain);
         iMailboxes->GetMailboxIdL(i, id);
         iAccountNames->AppendL(name);
+        iDomains->AppendL(domain);
         iAccountIds->AppendL(id);
         }
     HBufC* createNewMailbox = StringLoader::LoadLC(R_EMAILWIDGETSETTINGS_CREATE_NEW_MAILBOX);
@@ -93,12 +103,85 @@
     CleanupStack::PopAndDestroy(createNewMailbox);
     iListBox->Model()->SetItemTextArray(iAccountNames);
     
-    iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);
+    iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);   
     iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);
     iListBox->SetBorder(TGulBorder::ESingleBlack);
     iListBox->CreateScrollBarFrameL(ETrue);
     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
     iListBox->SetListBoxObserver(aObserver);
+    
+    SetupListIconsL();
+    }
+
+// ---------------------------------------------------------------------------
+// 
+// ---------------------------------------------------------------------------
+//
+void CEmailWidgetSettingsListViewContainer::SetupListIconsL()
+    {
+    FUNC_LOG;        
+    CFSMailClient* mailClient = CFSMailClient::NewL();
+    CleanupClosePushL(*mailClient);
+    MFSMailBrandManager& brandManager = mailClient->GetBrandManagerL();
+    
+    TInt count = iMailboxes->MailboxCount();
+    CArrayPtr<CGulIcon>* icons = new(ELeave) CArrayPtrFlat<CGulIcon>( count + 1 );
+    CleanupStack::PushL( icons );
+   
+    AppendIconL(icons, EMbmEmailwidgetsettingsQgn_prop_cmail_new_mailbox, 
+                       EMbmEmailwidgetsettingsQgn_prop_cmail_new_mailbox_mask);
+
+    for (TInt i = 0; i < count; i++)
+        {
+        CGulIcon* brandIcon;
+        brandIcon = brandManager.GetGraphicL( EFSMailboxIcon, iDomains->MdcaPoint(i) );
+        
+        if (brandIcon)
+            {
+            icons->AppendL(brandIcon);
+            }
+        else
+            {
+            AppendIconL(icons, EMbmEmailwidgetsettingsQgn_indi_cmail_drop_email_account, 
+                               EMbmEmailwidgetsettingsQgn_indi_cmail_drop_email_account_mask);
+            }
+        }
+
+    // clear any previous icon array
+    CAknIconArray* oldIconArray = static_cast<CAknIconArray*>(iListBox->ItemDrawer()->ColumnData()->IconArray());
+    if (oldIconArray)
+        delete oldIconArray;
+    
+    iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
+    CleanupStack::Pop(icons);
+    CleanupStack::PopAndDestroy( mailClient );
+    }
+
+// -----------------------------------------------------------------------------
+// CFeedsTopicContainer::AppendIconL
+//
+// Loads and appends an icon to the icon array.
+// -----------------------------------------------------------------------------
+//
+
+void CEmailWidgetSettingsListViewContainer::AppendIconL(
+        CArrayPtr<CGulIcon>* aIcons,
+        const TInt aFileBitmapId, 
+        const TInt aFileMaskId)
+    {
+    FUNC_LOG;
+    CGulIcon*    newIcon;
+    CFbsBitmap*  newIconBmp;
+    CFbsBitmap*  newIconMaskBmp;
+    AknIconUtils::CreateIconLC( newIconBmp, newIconMaskBmp, KMifPath,
+            aFileBitmapId,
+            aFileMaskId );   
+    newIcon = CGulIcon::NewL(newIconBmp, newIconMaskBmp);
+    CleanupStack::Pop(newIconMaskBmp);
+    CleanupStack::Pop(newIconBmp);
+    CleanupStack::PushL(newIcon);
+    aIcons->AppendL(newIcon);
+    CleanupStack::Pop(newIcon);
     }
 
 // ---------------------------------------------------------------------------
@@ -107,6 +190,7 @@
 //
 void CEmailWidgetSettingsListViewContainer::CreateCbaL( MEikCommandObserver* aObserver )
     {
+    FUNC_LOG;        
     const TSize screenSize= iCoeEnv->ScreenDevice()->SizeInPixels();
           iPopoutCba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba,
             CEikButtonGroupContainer::EHorizontal, aObserver, R_AVKON_SOFTKEYS_SELECT_CANCEL);
@@ -119,10 +203,12 @@
 //
 CEmailWidgetSettingsListViewContainer::~CEmailWidgetSettingsListViewContainer()
     {
+    FUNC_LOG;        
     delete iMailboxes;    
     delete iPopoutCba;
     delete iListBox;
     delete iAccountNames;
+    delete iDomains;
     delete iAccountIds;
     }
 
@@ -132,6 +218,7 @@
 //
 void CEmailWidgetSettingsListViewContainer::SizeChanged()
     {
+    FUNC_LOG;        
     TRect mainPaneRect;
 		AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
 		TRect listBoxRect(mainPaneRect.Size());
@@ -144,6 +231,7 @@
 //
 TInt CEmailWidgetSettingsListViewContainer::CountComponentControls() const
     {
+    FUNC_LOG;        
     return iListBox ? 1 : 0;
     }
 
@@ -153,6 +241,7 @@
 //
 CCoeControl* CEmailWidgetSettingsListViewContainer::ComponentControl(TInt /*aIndex*/) const
     {
+    FUNC_LOG;        
     return iListBox;
     }
 
@@ -162,6 +251,7 @@
 //
 TKeyResponse CEmailWidgetSettingsListViewContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
     {
+    FUNC_LOG;        
     return iListBox->OfferKeyEventL(aKeyEvent, aType);
     }
 
@@ -171,6 +261,7 @@
 //
 TSize CEmailWidgetSettingsListViewContainer::MinimumSize()
     {
+    FUNC_LOG;        
     return iEikonEnv->EikAppUi()->ClientRect().Size();
     }
 
@@ -180,6 +271,7 @@
 //
 TInt CEmailWidgetSettingsListViewContainer::CurrentIndex() const
     {
+    FUNC_LOG;        
     return iListBox->CurrentItemIndex();
     }
 
@@ -189,6 +281,7 @@
 //
 TTypeUid::Ptr CEmailWidgetSettingsListViewContainer::MopSupplyObject(TTypeUid aId)
     {
+    FUNC_LOG;        
     return SupplyMopObject(aId, iPopoutCba);
     }
 
@@ -198,6 +291,7 @@
 //
 void CEmailWidgetSettingsListViewContainer::SaveSelectedL()
     {
+    FUNC_LOG;        
     if (CurrentIndex() == iAccountNames->Count() - 1)
         {
         LaunchEmailWizardL();
@@ -280,6 +374,7 @@
 //
 void CEmailWidgetSettingsListViewContainer::LaunchEmailWizardL()
     {
+    FUNC_LOG;        
     if ( iEnv )
         {
         CCoeAppUi* appui = iEnv-> EikAppUi( );
--- a/emailuis/widget/emailwidgetsettings/src/emailwidgetsettingsmailboxes.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/emailwidgetsettings/src/emailwidgetsettingsmailboxes.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -110,12 +110,38 @@
 
     TDesC& mailboxName( mailBoxes[aNum]->GetName() );
 
+    TBuf<3>iconIndex;
+    iconIndex.AppendNum(aNum+1);
+    
+    aMailboxName.Append(iconIndex);
     aMailboxName.Append(_L("\t"));
     aMailboxName.Append(mailboxName);
     aMailboxName.Append(_L("\t"));
     aMailboxName.Append(_L("\t"));    
        
-    // Release allocated memory
+    mailBoxes.ResetAndDestroy();
+    }
+
+// ---------------------------------------------------------------------------
+// CEmailWidgetSettingsMailboxes::GetDomainL
+// ---------------------------------------------------------------------------
+//
+void CEmailWidgetSettingsMailboxes::GetDomainL(TInt aNum, TDes& aDomain)
+    {
+    FUNC_LOG;
+    // Mailboxes will be fetched to this array
+    RPointerArray<CFSMailBox> mailBoxes;
+
+    // List all mailboxes
+    TFSMailMsgId plugin;
+    iMailClient->ListMailBoxes( plugin, mailBoxes );
+
+    CFSMailAddress& ownMailAddress( mailBoxes[aNum]->OwnMailAddress( ) );
+    TDesC& mailAddress( ownMailAddress.GetEmailAddress());
+
+    aDomain.Append(mailAddress.Right(mailAddress.Length() - 
+                                     mailAddress.FindC(_L("@"))-1));
+
     mailBoxes.ResetAndDestroy();
     }
 
--- a/emailuis/widget/group/bld.inf	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/group/bld.inf	Thu Jan 07 12:38:38 2010 +0200
@@ -35,6 +35,7 @@
 ../xuikon/00/emailwidget.xml            /epoc32/data/Z/resource/homescreen/emailwidget/xuikon/emailwidget.xml
 // Variant creation still disabled (see also emailwidget.dat file)
 //../xuikon/00/emailwidget.dtd            /epoc32/data/Z/resource/homescreen/emailwidget/xuikon/emailwidget.dtd
+/epoc32/s60/icons/qgn_menu_cmail.svg    /epoc32/data/Z/resource/homescreen/emailwidget/hsps/qgn_menu_cmail.svg
 
 // Support for S60 localization
 //*****************************
--- a/emailuis/widget/hsps/00/emailwidgetconfiguration.dtd	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/hsps/00/emailwidgetconfiguration.dtd	Thu Jan 07 12:38:38 2010 +0200
@@ -28,5 +28,6 @@
 qtn_hscr_email.parents "ai_gene_pane_1"
 -->
 <!ENTITY qtn_hscr_email "Cmail widget">
+<!ENTITY qtn_hs_widget_mail_description "Informs of incoming mail messages">
 
 <!-- End of File -->
--- a/emailuis/widget/hsps/00/manifest.dat	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/hsps/00/manifest.dat	Thu Jan 07 12:38:38 2010 +0200
@@ -15,7 +15,9 @@
     <configurationuid>0x2001E272</configurationuid>
 
     <!-- description -->
+    <filelogo>qgn_menu_cmail.svg</filelogo>
     <fullname>&amp;qtn_hscr_email;</fullname>
+    <description>&amp;qtn_hs_widget_mail_description;</description>
     <shortname>EW</shortname>
     <version>1.0</version>
 
@@ -27,7 +29,7 @@
 
     <!-- Locale specific resources -->
     <localization>
-        <fileresource>EW.o0000</fileresource>
+        <fileresource tag="xuikon">EW.o0000</fileresource>
     </localization>
 
     <!-- Instances of widget per one homescreen -->	
--- a/emailuis/widget/loc/emailwidgetconfiguration.loc	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/loc/emailwidgetconfiguration.loc	Thu Jan 07 12:38:38 2010 +0200
@@ -18,8 +18,13 @@
 
 
 // d: Email widget
-// l: ai_gene_pane_1_t1
+// l: listrow_wgtman_pane_t1
 // w:
-// r: TB9.1
+// r: TB9.2
 #define qtn_hscr_email "Cmail widget"
 
+// d: Email widget
+// l: listrow_wgtman_pane_t2
+// w:
+// r: TB9.2
+#define qtn_hs_widget_mail_description "Informs of incoming mail messages"
\ No newline at end of file
--- a/emailuis/widget/rom/emailwidget_resources.iby	Thu Dec 17 08:39:21 2009 +0200
+++ b/emailuis/widget/rom/emailwidget_resources.iby	Thu Jan 07 12:38:38 2010 +0200
@@ -32,6 +32,7 @@
 // ...
 
 data=ZPRIVATE\200159c0\install\emailwidget\hsps\00\emailwidgetconfiguration.dtd \private\200159c0\install\emailwidget\hsps\00\emailwidgetconfiguration.dtd
+data=ZPRIVATE\200159c0\install\emailwidget\hsps\00\qgn_menu_cmail.svg \private\200159c0\install\emailwidget\hsps\00\qgn_menu_cmail.svg
 
 #endif //FF_EMAIL_FRAMEWORK
 #endif //FF_CMAIL_INTEGRATION
--- a/ipsservices/ipssosplugin/inc/ipsplgimap4moveremoteop.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/ipsservices/ipssosplugin/inc/ipsplgimap4moveremoteop.h	Thu Jan 07 12:38:38 2010 +0200
@@ -119,11 +119,6 @@
         */
 
         void Complete();
-        
-        /**
-        *
-        */
-        void DoMoveLocalL();
 
         /**
         *
@@ -144,7 +139,6 @@
         TDesC8*                             iMoveErrorProgress;
         TImImap4GetMailInfo                 iGetMailInfo;
         CMsvEntrySelection*                 iSelection;
-        CMsvEntrySelection*                 iLocalSel;      // Complete messages
         CMsvEntrySelection*                 iRemoteSel;     // Incomplete messages to be fetched.
         TPckgBuf<TImap4CompoundProgress>    iProgressBuf;
         TPckgBuf<TImap4SyncProgress>        iSyncProgress;
--- a/ipsservices/ipssosplugin/src/ipsplgimap4moveremoteop.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/ipsservices/ipssosplugin/src/ipsplgimap4moveremoteop.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -87,7 +87,6 @@
 CIpsPlgImap4MoveRemoteOp::~CIpsPlgImap4MoveRemoteOp()
     {
     FUNC_LOG;
-    delete iLocalSel;
     delete iRemoteSel;
     }
 
@@ -209,7 +208,7 @@
                 CompleteObserver( KErrCouldNotConnect );
                 return;
                 }
-            DoMoveLocalL();
+            DoMoveRemoteL();
             }
             break;
         case ELocalMsgs:
@@ -253,7 +252,6 @@
         User::Leave( KErrNotSupported );
         }
     // Sort messages into complete and incomplete selections.
-    iLocalSel = new(ELeave) CMsvEntrySelection;
     iRemoteSel = new(ELeave) CMsvEntrySelection;
 
     TInt err;
@@ -267,17 +265,6 @@
         err = iMsvSession.GetEntry( id, service, tEntry );
         if( KErrNone == err )
             {
-            // local move is not needed, if the message is not fetched
-            if( tEntry.Complete() )
-                {
-                if ( 0 < count )
-                    {
-                    // service id is not added to local, 
-                    // service is already
-                    // added in MoveMessagesL
-                    iLocalSel->AppendL( id );
-                    }
-                }
                 iRemoteSel->AppendL( id );
                 }
             }
@@ -291,38 +278,6 @@
     TRequestStatus* observer = &iObserverRequestStatus;
     User::RequestComplete( observer, KErrNone );
     }
-    
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-void CIpsPlgImap4MoveRemoteOp::DoMoveLocalL()
-    {
-    FUNC_LOG;
-    iState = ELocalMsgs;
-    iStatus = KRequestPending;
-    if( iLocalSel->Count() )
-        {
-        // this gets the first msg to be moved
-        CMsvEntry* cEntry = iMsvSession.GetEntryL( (*iLocalSel)[0] );
-        CleanupStack::PushL( cEntry );
-        // find the parent of the moved message...
-        TMsvId parent = cEntry->Entry().Parent();
-        // and use it as a context
-        cEntry->SetEntryL( parent );
-
-        delete iOperation;
-        iOperation = NULL;
-        iOperation = cEntry->MoveL( *iLocalSel, 
-                                    iGetMailInfo.iDestinationFolder, 
-                                    iStatus );
-        CleanupStack::PopAndDestroy( cEntry ); 
-        SetActive();
-        }
-    else
-        {
-        SetActive();
-        CompleteThis();
-        }
-    }
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
--- a/ipsservices/ipssosplugin/src/ipsplgimap4plugin.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/ipsservices/ipssosplugin/src/ipsplgimap4plugin.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -359,7 +359,7 @@
         TPckgBuf<TImImap4GetMailInfo> optionsBuf;
         TImImap4GetMailInfo& options = optionsBuf();
         options.iMaxEmailSize = KMaxTInt32;
-        options.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
+        options.iGetMailBodyParts = EGetImap4EmailHeaders;
         options.iDestinationFolder = aDestinationFolderId.Id();
 
         CIpsPlgImap4MoveRemoteOpObserver* observer =
--- a/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -190,25 +190,28 @@
             CMsvEntry* cEntry = iSession.GetEntryL( aEntry.Id() );
             CleanupStack::PushL( cEntry );
 
-            if ( cEntry && cEntry->HasStoreL() )
-                {
-                store = cEntry->ReadStoreL();
-                CleanupStack::PushL( store );
-                }
-
-            SetEnvelopeL( cEntry, store, *result );
+            if ( cEntry )
+            	{
+            	if ( cEntry->HasStoreL() )
+					{
+					store = cEntry->ReadStoreL();
+					CleanupStack::PushL( store );
+					}
 
-            // Apparently, this should be done only with
-            // EFSMsgDataStructure, but EFSMsgDataEnvelope is currently
-            // used by assuming that it reads also the content-type of
-            // the message
-            SetStructureL( cEntry, *result );
-
-            if ( store )
-                {
-                CleanupStack::PopAndDestroy( store );
-                }
-            CleanupStack::PopAndDestroy( cEntry );
+				SetEnvelopeL( cEntry, store, *result );
+	
+				// Apparently, this should be done only with
+				// EFSMsgDataStructure, but EFSMsgDataEnvelope is currently
+				// used by assuming that it reads also the content-type of
+				// the message
+				SetStructureL( cEntry, *result );
+	
+				if ( store )
+					{
+					CleanupStack::PopAndDestroy( store );
+					}
+				CleanupStack::PopAndDestroy( cEntry );
+            	}
             break;
             }
         case EFSMsgDataIdOnly:
@@ -1361,9 +1364,10 @@
             }
         result->SetMailBoxId( aMailBoxId );
         CleanupStack::PopAndDestroy(store);
+        
+        SetFetchStateL( aEntry, aMessageId.Id(), ETrue, *result );
         CleanupStack::Pop( result );
         }
-    SetFetchStateL( aEntry, aMessageId.Id(), ETrue, *result );
     CleanupStack::PopAndDestroy( cEntry );
 
     return result;
--- a/ipsservices/ipssosplugin/src/ipsplgsearch.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/ipsservices/ipssosplugin/src/ipsplgsearch.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -960,18 +960,36 @@
 void CIpsPlgSearch::CollectMessagesL()
     {
     FUNC_LOG;
+    TMsvId mailboxId = iCurrentSearch.iMailbox.Id();
+	TMsvId serviceId;
+	TMsvEntry tEntry;
+	TMsvEntry mailboxServiceEntry;
+	
     // Lets make a huge list of message id's. 
     iEmailMessages.Reset();    
     
     const TInt folders = iCurrentSearch.iFolderIds.Count();
     for ( TInt folder = 0; folder < folders; folder++ )
         {
-        iActiveEntry->SetEntryL( iCurrentSearch.iFolderIds[folder].Id() );        
+        iActiveEntry->SetEntryL( iCurrentSearch.iFolderIds[folder].Id() );  
+    	if( iActiveEntry->Entry().Parent() == KMsvLocalServiceIndexEntryIdValue )
+    		{
+    		User::LeaveIfError(
+    			iMsvSession.GetEntry( mailboxId, serviceId, tEntry ) );
+    		User::LeaveIfError(
+    		    iMsvSession.GetEntry( tEntry.iRelatedId, serviceId, mailboxServiceEntry ) );
+    		}
+    	else
+    		{
+     		serviceId = mailboxId;
+    		}
+
         const TInt msgs = iActiveEntry->Count();
         for ( TInt msg = 0; msg < msgs; msg++ )
             {
             const TMsvEntry& entry = ( *iActiveEntry )[msg];
             if ( entry.iType == KUidMsvMessageEntry &&
+            	 entry.iServiceId == serviceId &&
                  ( entry.iMtm.iUid == KSenduiMtmSmtpUidValue ||
                    entry.iMtm.iUid == iPlugin.MtmId().iUid ) )
                 {
--- a/ipsservices/ipssossettings/src/ipssetui.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/ipsservices/ipssossettings/src/ipssetui.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -36,7 +36,8 @@
 #include "ipsplgsosbaseplugin.hrh"
 
 const TInt KIpsSetOptionsMenuItemCount = 4;
-_LIT( KIpsSetUiResourceFile,"z:IpsSosSettings.rsc" );
+// Resource file name and path, drive letter need to be parsed run time
+_LIT( KIpsSetUiResourceFile, "\\resource\\IpsSosSettings.rsc" );
 
 // ============================ LOCAL FUNCTIONS ===============================
 
@@ -488,11 +489,15 @@
 void CIpsSetUi::LoadResourceL()
     {
     FUNC_LOG;
-    TFileName fileName;
+
+    // Load resource file from the same drive where this dll is loaded from
+    TFileName dllFileName;
+    Dll::FileName( dllFileName );
+
     TParse parse;
-    parse.Set( KIpsSetUiResourceFile, &KDC_RESOURCE_FILES_DIR, NULL );
-    fileName.Copy( parse.FullName() );
-
+    parse.Set( KIpsSetUiResourceFile, &dllFileName, NULL );
+    TFileName fileName( parse.FullName() );
+    
     // Attempt to load the resource
     iResourceLoader.OpenL( fileName );
     }
--- a/ipsservices/ipssossettings/src/ipssetuifinder.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/ipsservices/ipssossettings/src/ipssetuifinder.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -239,8 +239,8 @@
 
     // Check if the item is found, and that it's enough
     if ( iSearchFlags & EFinderItemFound &&
-         !iSearchFlags & EFinderSearchAll &&
-         !iSearchFlags & EFinderResourceSearch )
+         !( iSearchFlags & EFinderSearchAll ) &&
+         !( iSearchFlags & EFinderResourceSearch ) )
         {
         return EFalse;
         }
@@ -251,7 +251,7 @@
     // Check if the last item is in progress
     if ( iCurrentItem >= aMaxItems )
         {
-        if ( !iSearchFlags & EFinderItemFound )
+        if ( !( iSearchFlags & EFinderItemFound ) )
             {
             iSearchFlags |= EFinderItemFindError;
             }
@@ -411,7 +411,7 @@
         }
 
     // Check if the subfolders need to be searched
-    if ( !iSearchFlags & EFinderSearchSubFolders )
+    if ( !( iSearchFlags & EFinderSearchSubFolders ) )
         {
         return EFalse;
         }
--- a/meetingrequest/mrentry/inc/cesmrmeetingrequestentry.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrentry/inc/cesmrmeetingrequestentry.h	Thu Jan 07 12:38:38 2010 +0200
@@ -152,6 +152,7 @@
 private: // Data
     /// Own: Calendar entry
     CCalEntry* iEntry;
+    CCalEntry* iBackupEntry;
     /// Own: Forward calendar entry
     CCalEntry* iForwardEntry;
     /// Ref: Reference to mailbox utilities
--- a/meetingrequest/mrentry/src/cesmrentryprocessor.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrentry/src/cesmrentryprocessor.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -12,7 +12,7 @@
 * Contributors:
 *
 *  Description : ESMR entry processor implementation
-*  Version     : %version: tr1sido#12 %
+*  Version     : %version: e003sa40#13 %
 *
 */
 
@@ -290,7 +290,7 @@
         }
 
     // Check mail parameters
-    if ( iParams && iParams->iSpare )
+    if ( iParams )
         {
         CCalEntry* entry = &iESMREntry->Entry();
         if(entry)
--- a/meetingrequest/mrentry/src/cesmrmeetingrequestentry.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrentry/src/cesmrmeetingrequestentry.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -200,6 +200,7 @@
     delete iForwardEntry;
     delete iOrginalEntry;
     delete iParameterEntry;
+    delete iBackupEntry;
     }
 
 // ---------------------------------------------------------------------------
@@ -242,7 +243,10 @@
         aEntry,
         aEntry.MethodL(),
         ESMRHelper::ECopyFull );    
-    
+    iBackupEntry=ESMRHelper::CopyEntryL(
+            aEntry,
+            aEntry.MethodL(),
+            ESMRHelper::ECopyFull ); 
     iEntry = ESMRHelper::CopyEntryL(
         aEntry,
         aEntry.MethodL(),
@@ -450,7 +454,7 @@
         // Ownership is transferred
         CCalInstance* instance = NULL;
         TRAPD(err, instance = InstanceL() );
-        if ( KErrNotFound != err )
+        if ( KErrNotFound != err&&err!=KErrNone )
             {
             User::LeaveIfError( err );
             }
@@ -607,7 +611,10 @@
             CleanupStack::PushL( instance );
 
             CCalEntry::TMethod entryMethod( iEntry->MethodL() );
-           
+            CCalEntry* iBackupEntry=ESMRHelper::CopyEntryL(
+                    *iEntry,
+                    entryMethod,
+                    ESMRHelper::ECopyFull);
             delete iEntry; 
             iEntry = NULL;
             
@@ -649,7 +656,7 @@
                     CESMRFsMailboxUtils::NewL( iMRMailboxUtils );
             CleanupStack::PushL( fsMbUtils );
             
-            fsMbUtils->SetPhoneOwnerL( *iEntry );
+            fsMbUtils->SetPhoneOwnerL( *iBackupEntry );
             CleanupStack::PopAndDestroy( fsMbUtils );
             fsMbUtils = NULL;
             
@@ -679,6 +686,7 @@
 
             iEntry->SetDescriptionL( description );
             iOrginalEntry->SetDescriptionL( description );
+            iEntry=ESMRHelper::CopyEntryL(*iBackupEntry,iBackupEntry->MethodL(),ESMRHelper::ECopyFull);
             
             CleanupStack::PopAndDestroy(); // entries
             CleanupStack::PopAndDestroy( instance );
--- a/meetingrequest/mrgui/data/esmrgui.rss	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/data/esmrgui.rss	Thu Jan 07 12:38:38 2010 +0200
@@ -789,7 +789,7 @@
         CBA_BUTTON
             {
             id=EAknSoftkeyDone;
-            txt = text_softkey_done;
+            txt = text_softkey_cancel;
             },
         AVKON_CBA_BUTTON
             {
--- a/meetingrequest/mrgui/inc/mesmrlocationplugin.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/inc/mesmrlocationplugin.h	Thu Jan 07 12:38:38 2010 +0200
@@ -54,9 +54,10 @@
     /**
      * Shows map on the screen focused on the given location.
      *
+     * @param aLocation containing name for landmark
      * @param aLocationUrl URL containing coordinates for maps focus
      */
-    virtual void ShowOnMapL( const TDesC& aLocationUrl ) = 0;
+    virtual void ShowOnMapL( const TDesC& aLocation, const TDesC& aLocationUrl ) = 0;
 
 protected:
 
--- a/meetingrequest/mrgui/mrfieldbuilderplugin/inc/cesmrviewerdescriptionfield.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/mrfieldbuilderplugin/inc/cesmrviewerdescriptionfield.h	Thu Jan 07 12:38:38 2010 +0200
@@ -98,6 +98,12 @@
      * Own.
      */
     CESMRFeatureSettings* iFeatures;
+    
+    /**
+     * Location title.
+     * Own.
+     */
+    HBufC* iLocation;
     };
 
 #endif /* CESMRVIEWERDESCRIPTIONFIELD_H */
--- a/meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrviewerdescriptionfield.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrviewerdescriptionfield.cpp	Thu Jan 07 12:38:38 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.
@@ -71,6 +71,7 @@
     FUNC_LOG;
     delete iLocationPlugin;
     delete iFeatures;
+    delete iLocation;
     }
 
 // ---------------------------------------------------------------------------
@@ -311,7 +312,7 @@
                 {
                 const CESMRRichTextLink* link =
                     iRichTextViewer->GetSelectedLink();
-                LocationPluginL().ShowOnMapL( link->Value() );
+                LocationPluginL().ShowOnMapL( *iLocation, link->Value() );
                 }
             break;
             }
@@ -396,6 +397,11 @@
         CleanupStack::PopAndDestroy( description );
         CleanupStack::PopAndDestroy( showOnMapBuf );
         command = EESMRCmdEnableWaypointIcon;
+        
+        const TDesC& location = aEntry.Entry().LocationL();
+        delete iLocation;
+        iLocation = NULL; 
+        iLocation = location.AllocL();     
         }
     // No location url found. Other description text is added to field.
     else
--- a/meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrviewerattachmentsfield.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrviewerattachmentsfield.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -386,11 +386,7 @@
         {
         iRichTextViewer->SetFocus( aFocus );
         }
-    else
-        {
-        //need to tell action menu that focus has changed
-        iRichTextViewer->ResetActionMenuL();
-        }
+
     if ( aFocus && aFocus != iFocused )
         {
         // <cmail>
--- a/meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrviewerattendeesfield.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrviewerattendeesfield.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -530,15 +530,11 @@
                 text.Set( name );
                 }
             
-            HBufC* clippedTextHBufC = ClipTextLC( text, *font, maxLineWidth );
-            TPtr clippedText = clippedTextHBufC->Des();
-            clippedText.Trim();
-            
-            if ( clippedText.Length() > 0 )
+            if ( text.Length() > 0 )
                 {
                 CESMRRichTextLink* link = CESMRRichTextLink::NewL(
                         buffer.Length(), 
-                        clippedText.Length() + 
+                        text.Length() + 
                             KAddressDelimeterSemiColon().Length(), 
                         addr,
                         CESMRRichTextLink::ETypeEmail,
@@ -549,15 +545,13 @@
         
                 // Append text and semicolon to buffer.
                 buffer.ReAllocL( buffer.Length() +
-                                 clippedText.Length() +
+                                 text.Length() +
                                  KAddressDelimeterSemiColon().Length() + 
                                  KNewLine().Length() );
-                buffer.Append( clippedText );
+                buffer.Append( text );
                 buffer.Append( KAddressDelimeterSemiColon );
                 buffer.Append( KNewLine );
-                }
-            
-            CleanupStack::PopAndDestroy( clippedTextHBufC );
+                }            
             }
         
         // If there are more lines in use than KMaxLineCount and
--- a/meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrviewerfromfield.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrviewerfromfield.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -330,16 +330,17 @@
     if ( iRichTextViewer )
         {
         iRichTextViewer->SetFocus( aFocus );
-        }
-    if ( aFocus )
-        {
-        SetMiddleSoftKeyVisible( ETrue );
-        }
-    else
-        {
-        //need to tell action menu that focus has changed
-        iRichTextViewer->ResetActionMenuL();
-        }
+    
+		if ( aFocus )
+			{
+			SetMiddleSoftKeyVisible( ETrue );
+			}
+		else
+			{
+			//need to tell action menu that focus has changed
+			iRichTextViewer->ResetActionMenuL();
+			}
+        }    
     }
 
 // ---------------------------------------------------------------------------
--- a/meetingrequest/mrgui/mrlocationplugin/inc/cesmrlocationpluginimpl.h	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/mrlocationplugin/inc/cesmrlocationpluginimpl.h	Thu Jan 07 12:38:38 2010 +0200
@@ -58,7 +58,7 @@
 public:// from base class MESMRLocationPlugin
     void SelectFromMapL( const TDesC& aSearchQuery, const TDesC& aLocationUrl );
     void SearchFromMapL( const TDesC& aSearchQuery );
-    void ShowOnMapL( const TDesC& aLocationUrl );
+    void ShowOnMapL( const TDesC& aLocation, const TDesC& aLocationUrl );
 
 protected: // from base class CActive
 	void DoCancel();
--- a/meetingrequest/mrgui/mrlocationplugin/src/cesmrlocationpluginimpl.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/mrlocationplugin/src/cesmrlocationpluginimpl.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -224,7 +224,7 @@
 // From class MESMRLocationPlugin.
 // ---------------------------------------------------------------------------
 //
-void CESMRLocationPluginImpl::ShowOnMapL( const TDesC& aLocationUrl )
+void CESMRLocationPluginImpl::ShowOnMapL( const TDesC& aLocation, const TDesC& aLocationUrl )
 	{
     FUNC_LOG;
 	CreateMapViewL();
@@ -233,6 +233,7 @@
     RCPointerArray<CPosLandmark> landmarks;
     CleanupClosePushL( landmarks );
     CPosLandmark* landmark = iUrlParser->CreateLandmarkFromUrlL( aLocationUrl );
+    landmark->SetLandmarkNameL(aLocation);    
     CleanupStack::PushL( landmark ); 
     landmarks.AppendL( landmark );
     CleanupStack::Pop( landmark );
--- a/meetingrequest/mrgui/src/cesmrcontactmenuurlhandler.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/src/cesmrcontactmenuurlhandler.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -37,9 +37,11 @@
 #include <apgcli.h>
 #include <AknQueryDialog.h>
 #include <aknnotewrappers.h>
+#include <FeatMgr.h>
 // for intranet application opening
 #include <AiwServiceHandler.h>
 #include <data_caging_path_literals.hrh>
+#include <publicruntimeids.hrh>
 
 
 // DEBUG
@@ -240,7 +242,8 @@
     		data.iText, R_QTN_MEET_REQ_VIEWER_OPTIONS_OPEN_IN_WEB );
     aActionMenuPane->AddMenuItemL( data );
 
-    if(IsServiceAvailableL(R_INTRANET_AIW_INTEREST))
+    if(IsServiceAvailableL(R_INTRANET_AIW_INTEREST) &&
+       FeatureManager::FeatureSupported( KFeatureIdFfIntranetBrowsing ) )
         {
         data.iCommandId = command;
         command++;//dynamic command ids
@@ -294,7 +297,8 @@
         }
     command++;//next item in the dynamic list
 
-    if(IsServiceAvailableL(R_INTRANET_AIW_INTEREST))
+    if(IsServiceAvailableL(R_INTRANET_AIW_INTEREST) &&
+       FeatureManager::FeatureSupported( KFeatureIdFfIntranetBrowsing ) )
         {
         if( (aCommand == KUidOpenInIntranet.iUid) || (aCommand == command))
             {
@@ -324,7 +328,8 @@
     CreateMenuItemL( R_QTN_MEET_REQ_VIEWER_OPTIONS_OPEN_IN_WEB, 
 					 KUidOpenInBrowser);
 
-    if(IsServiceAvailableL(R_INTRANET_AIW_INTEREST))
+    if(IsServiceAvailableL(R_INTRANET_AIW_INTEREST) &&
+       FeatureManager::FeatureSupported( KFeatureIdFfIntranetBrowsing ) )
         {
         CreateMenuItemL( R_QTN_MEET_REQ_FSOPTIONS_OPEN_IN_INTRA, 
 						 KUidOpenInIntranet);
--- a/meetingrequest/mrgui/src/cesmreditordialog.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/src/cesmreditordialog.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -137,8 +137,36 @@
         }
     else
         {
-        aEntry.SetModifyingRuleL(
-                MESMRMeetingRequestEntry::EESMRThisOnly );
+        TInt result =
+                    CESMRListQuery::ExecuteL( aQueryType );
+
+                if( KErrCancel == result )
+                    {
+                    // User has cancelled selecting opening the instance
+                    User::Leave( KErrCancel );
+                    }
+
+                TESMRThisOccurenceOrSeriesQuery recurrenceModRule =
+                    static_cast<TESMRThisOccurenceOrSeriesQuery>( result );
+
+                switch( recurrenceModRule )
+                    {
+                    case EESMRThisOccurence:
+                        {
+                        aEntry.SetModifyingRuleL(
+                                MESMRMeetingRequestEntry::EESMRThisOnly );
+                        }
+                        break;
+                    case EESMRSeries:
+                        {
+                        aEntry.SetModifyingRuleL(
+                                MESMRMeetingRequestEntry::EESMRAllInSeries );
+                        }
+                        break;
+                    default:
+                        __ASSERT_DEBUG( EFalse, Panic(EESMREditDlgInvalidSeriesResult));
+                        break;
+                    }
         }
     }
 
@@ -612,7 +640,8 @@
     TRAPD( err, DoProcessCommandL( aCommand ) );
     if ( err != KErrNone &&
          err != KErrCancel &&
-         err != KErrArgument )
+         err != KErrArgument&&
+         err !=EESMRCmdSendMR)
         {
         User::Leave(err);
         }           
@@ -673,8 +702,13 @@
         case EESMRCmdCalEntryUIAddParticipants:
             {
             iView->ExternalizeL (); // no force validation
-            User::LeaveIfError( 
-            		iCallback.ProcessCommandWithResultL ( aCommand ));
+            TInt result;
+            TRAPD(err,result=iCallback.ProcessCommandWithResultL ( aCommand ))
+			if (err != EESMRCmdSendMR&&err!=KErrNone)
+				{
+				User::Leave(err);
+				}
+			User::LeaveIfError(result);
             TryExitL ( EESMRCmdForceExit );
             break;
             }
--- a/meetingrequest/mrgui/src/cesmrlocationpluginhandler.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/src/cesmrlocationpluginhandler.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -175,9 +175,10 @@
 		    TPtrC locationUrl;
 		    TInt position = iUrlParser->FindLocationUrl( description,
 		                                                 locationUrl );
+		    const TDesC& location = aEntry.Entry().LocationL();
 		    if ( position >= 0 )
 		        {
-		        LocationPluginL().ShowOnMapL( locationUrl );
+		        LocationPluginL().ShowOnMapL( location, locationUrl );
 		        }
 		    break;
 		    }
--- a/meetingrequest/mrgui/src/cesmrmeetingtimevalidator.cpp	Thu Dec 17 08:39:21 2009 +0200
+++ b/meetingrequest/mrgui/src/cesmrmeetingtimevalidator.cpp	Thu Jan 07 12:38:38 2010 +0200
@@ -397,7 +397,8 @@
 
         TTime until;
         if ( iRecurrenceValue != ERecurrenceNot &&
-             iRecurrenceValue != ERecurrenceUnknown )
+             iRecurrenceValue != ERecurrenceUnknown &&
+             iRecurrenceUntilDate && iRecurrenceUntilDate->IsVisible() )
             {
             until = RecurrenceUntilTime();