Revision: 201031
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 18 Aug 2010 09:37:47 +0300
changeset 59 16ed8d08d0b1
parent 54 997a02608b3a
child 65 478bc57ad291
Revision: 201031 Kit: 201033
email_plat/email_services_api/email_services_api.h
email_plat/nmail_settings_api/nmail_settings_api.pri
email_plat/nmail_settings_api/nmapimailboxsettingsdata.h
email_plat/nmail_settings_api/nmapisettingsmanager.h
emailservices/emailcommon/src/CFSMailBox.cpp
emailservices/emailcommon/src/CFSMailFolder.cpp
emailservices/emailcommon/src/CFSMailMessagePart.cpp
emailservices/emailcommon/src/CFSMailRequestHandler.cpp
emailservices/emaildebug/inc/emailtrace.h
emailservices/emailframework/bwins/FSMailFrameworkU.DEF
emailservices/emailframework/data/fsmailbrandmanager.rss
emailservices/emailframework/data/mail_for_exchange.svg
emailservices/emailframework/eabi/FSMailFrameworkU.DEF
emailservices/emailframework/emailframework.pro
emailservices/emailframework/inc/CFSMailClient.h
emailservices/emailframework/inc/CFSMailPlugin.h
emailservices/emailframework/src/CFSMailBrand.cpp
emailservices/emailframework/src/CFSMailClient.cpp
emailservices/emailstore/base_plugin/BWINS/basepluginU.DEF
emailservices/emailstore/base_plugin/EABI/basepluginU.DEF
emailservices/emailstore/base_plugin/base_plugin.pro
emailservices/emailstore/base_plugin/inc/BasePlugin.h
emailservices/emailstore/base_plugin/inc/baseplugincommonutils.h
emailservices/emailstore/base_plugin/inc/baseplugindelayedops.h
emailservices/emailstore/base_plugin/inc/baseplugindelayedopsprivate.h
emailservices/emailstore/base_plugin/inc/nestedao.h
emailservices/emailstore/base_plugin/src/BaseMrInfoObject.cpp
emailservices/emailstore/base_plugin/src/BasePlugin.cpp
emailservices/emailstore/base_plugin/src/MailIterator.cpp
emailservices/emailstore/base_plugin/src/baseplugindelayedops.cpp
emailservices/emailstore/base_plugin/src/basepluginmisc.cpp
emailservices/emailstore/base_plugin/src/baseplugintranslator.cpp
emailservices/emailstore/base_plugin/src/nestedao.cpp
emailservices/emailstore/message_store/client/src/MsgStore.cpp
emailservices/emailstore/message_store/client/src/MsgStoreMessagePart.cpp
emailservices/emailstore/message_store/client/src/RMessageStoreSession.cpp
emailservices/emailstore/message_store/common/src/AccountsSerializer.cpp
emailservices/emailstore/message_store/debuglog/src/DebugLog.cpp
emailservices/emailstore/message_store/server/inc/ContainerStore.h
emailservices/emailstore/message_store/server/inc/ContainerStoreContainersTable.h
emailservices/emailstore/message_store/server/inc/ContainerStoreDefs.h
emailservices/emailstore/message_store/server/inc/ContainerStoreDeleteHandler.h
emailservices/emailstore/message_store/server/inc/ContainerStoreSortingTable.h
emailservices/emailstore/message_store/server/inc/MessageStoreServer.h
emailservices/emailstore/message_store/server/src/ContainerStore.cpp
emailservices/emailstore/message_store/server/src/ContainerStoreContainersTable.cpp
emailservices/emailstore/message_store/server/src/ContainerStoreDeleteHandler.cpp
emailservices/emailstore/message_store/server/src/ContainerStoreMRUAddressTable.cpp
emailservices/emailstore/message_store/server/src/ContainerStoreSearchHandler.cpp
emailservices/emailstore/message_store/server/src/ContainerStoreSortingTable.cpp
emailservices/emailstore/message_store/server/src/MessageStoreServer.cpp
emailservices/emailstore/message_store/server/src/MessageStoreSession.cpp
emailservices/emailstore/message_store/server/src/MsgStoreSortResultRowSet.cpp
emailservices/emailstore/message_store/server/src/MsgStoreStringSortResultRowSet.cpp
emailservices/nmailagent/inc/nmmailagent.h
emailservices/nmailagent/src/main.cpp
emailservices/nmailagent/src/nmmailagent.cpp
emailservices/nmclientapi/bwins/nmailclientapiu.def
emailservices/nmclientapi/eabi/nmailclientapiu.def
emailservices/nmclientapi/inc/nmapisettingsmanager_p.h
emailservices/nmclientapi/nmclientapi.pro
emailservices/nmclientapi/src/nmapimailboxsettings_p.cpp
emailservices/nmclientapi/src/nmapisettingsmanager.cpp
emailservices/nmclientapi/src/nmapisettingsmanager_p.cpp
emailservices/nmregister/src/nmmailboxregisterinterface.cpp
emailuis/nmailcpplugin/nmailcpplugin.pro
emailuis/nmailui/conf/nmmessagelistviewitem.css
emailuis/nmailui/conf/nmmessagelistviewitem.widgetml
emailuis/nmailui/conf/nmviewerheader.widgetml
emailuis/nmailui/inc/nmapplication.h
emailuis/nmailui/inc/nmattachmentpicker.h
emailuis/nmailui/inc/nmeditorcontent.h
emailuis/nmailui/inc/nmeditorheader.h
emailuis/nmailui/inc/nmeditorview.h
emailuis/nmailui/inc/nmmessagelistview.h
emailuis/nmailui/inc/nmmessagelistviewitem.h
emailuis/nmailui/inc/nmuiheaders.h
emailuis/nmailui/inc/nmviewerheader.h
emailuis/nmailui/nmailui.pro
emailuis/nmailui/nmailui.qrc
emailuis/nmailui/src/main.cpp
emailuis/nmailui/src/nmapplication.cpp
emailuis/nmailui/src/nmattachmentpicker.cpp
emailuis/nmailui/src/nmeditorcontent.cpp
emailuis/nmailui/src/nmeditorheader.cpp
emailuis/nmailui/src/nmeditorview.cpp
emailuis/nmailui/src/nmmessagelistview.cpp
emailuis/nmailui/src/nmmessagelistviewitem.cpp
emailuis/nmailui/src/nmmessagesearchlistview.cpp
emailuis/nmailui/src/nmrecipientfield.cpp
emailuis/nmailui/src/nmutilities.cpp
emailuis/nmailui/src/nmviewerheader.cpp
emailuis/nmailui/src/nmviewerserviceinterface.cpp
emailuis/nmailui/src/nmviewerview.cpp
emailuis/nmailui/src/nmviewerwebview.cpp
emailuis/nmailui/translations/mail.qm
emailuis/nmailui/translations/mail.ts
emailuis/nmailuiengine/bwins/nmailuiengineu.def
emailuis/nmailuiengine/eabi/nmailuiengineu.def
emailuis/nmailuiengine/inc/nmuiengine.h
emailuis/nmailuiengine/src/nmuiengine.cpp
emailuis/nmailuiwidgets/bwins/nmailuiwidgetsu.def
emailuis/nmailuiwidgets/inc/nmailuiwidgetsheaders.h
emailuis/nmailuiwidgets/inc/nmattachmentlistwidget.h
emailuis/nmailuiwidgets/nmailuiwidgets.pro
emailuis/nmailuiwidgets/nmailuiwidgets.qrc
emailuis/nmailuiwidgets/src/nmattachmentlistitem.cpp
emailuis/nmailuiwidgets/src/nmattachmentlistwidget.cpp
emailuis/nmailuiwidgets/src/nmeditortextedit.cpp
emailuis/nmframeworkadapter/src/nmframeworkadapter.cpp
emailuis/nmframeworkadapter/src/nmfwamessagepartsfetchingoperation.cpp
emailuis/nmhswidget/nmhswidget.pro
emailuis/nmhswidget/nmhswidget.qrc
emailuis/nmindicatorplugin/src/nmsendingindicator.cpp
emailuis/nmindicatorplugin/src/nmsyncindicator.cpp
emailuis/nmsettingui/inc/nmmailboxsettingview.h
emailuis/nmsettingui/nmsettingui.pro
emailuis/nmsettingui/nmsettingui.qrc
emailuis/nmsettingui/src/nmmailboxsettingview.cpp
emailuis/nmsettingui/src/nmsettingsviewfactory.cpp
inc/basepluginresourceloader.h
ipsservices/ipssosaoplugin/inc/IpsSosAOBaseAgent.h
ipsservices/ipssosaoplugin/inc/IpsSosAOSettingsHandler.h
ipsservices/ipssosaoplugin/inc/ipssosaopluginheaders.h
ipsservices/ipssosaoplugin/src/IpsPlgAOPluginImplementationTable.cpp
ipsservices/ipssosaoplugin/src/IpsSosAOBaseAgent.cpp
ipsservices/ipssosaoplugin/src/IpsSosAOEMNResolver.cpp
ipsservices/ipssosaoplugin/src/IpsSosAOImapAgent.cpp
ipsservices/ipssosaoplugin/src/IpsSosAOImapPopLogic.cpp
ipsservices/ipssosaoplugin/src/IpsSosAOMboxLogic.cpp
ipsservices/ipssosaoplugin/src/IpsSosAOPluginEComInterface.cpp
ipsservices/ipssosaoplugin/src/IpsSosAOPluginTimer.cpp
ipsservices/ipssosaoplugin/src/IpsSosAOPopAgent.cpp
ipsservices/ipssosaoplugin/src/IpsSosAOSchedulerUtils.cpp
ipsservices/ipssosaoplugin/src/IpsSosAOSettingsHandler.cpp
ipsservices/ipssosaoplugin/src/IpsSosAOSmtpAgent.cpp
ipsservices/ipssosaoplugin/src/IpsSosAOSmtpSendWatcher.cpp
ipsservices/ipssosaoplugin/src/IpsSosAoExtendedSettingsManager.cpp
ipsservices/ipssosplugin/inc/ipsplgeventhandler.h
ipsservices/ipssosplugin/inc/ipsplgmsgiterator.h
ipsservices/ipssosplugin/inc/ipsplgmsgkey.h
ipsservices/ipssosplugin/inc/ipsplgsearch.h
ipsservices/ipssosplugin/inc/ipsplgsearch.inl
ipsservices/ipssosplugin/inc/ipsplgsyncstatehandler.h
ipsservices/ipssosplugin/src/ipsplgdisconnectop.cpp
ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp
ipsservices/ipssosplugin/src/ipsplgimap4connectop.cpp
ipsservices/ipssosplugin/src/ipsplgimap4plugin.cpp
ipsservices/ipssosplugin/src/ipsplgmsgiterator.cpp
ipsservices/ipssosplugin/src/ipsplgmsgkey.cpp
ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp
ipsservices/ipssosplugin/src/ipsplgonlineoperation.cpp
ipsservices/ipssosplugin/src/ipsplgpop3connectop.cpp
ipsservices/ipssosplugin/src/ipsplgsearch.cpp
ipsservices/ipssosplugin/src/ipsplgsyncstatehandler.cpp
ipsservices/nmimapclientplugin/src/nmimapclientplugin.cpp
ipsservices/nmipssettings/inc/nmipssettingshelper.h
ipsservices/nmipssettings/src/nmipssettingshelper.cpp
ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp
layers.sysdef.xml
nmail.pro
--- a/email_plat/email_services_api/email_services_api.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/email_plat/email_services_api/email_services_api.h	Wed Aug 18 09:37:47 2010 +0300
@@ -25,6 +25,8 @@
 static const QString emailSendToKey = "to";
 static const QString emailSendCcKey = "cc";
 static const QString emailSendBccKey = "bcc";
+static const QString emailSendBodyTextKey = "body";
+static const QString emailSendAttachmentKey = "attachment";
 
 /*!
     Mail service name
--- a/email_plat/nmail_settings_api/nmail_settings_api.pri	Tue Jul 06 14:04:34 2010 +0300
+++ b/email_plat/nmail_settings_api/nmail_settings_api.pri	Wed Aug 18 09:37:47 2010 +0300
@@ -1,24 +1,16 @@
-#
 # Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 # All rights reserved.
 # This component and the accompanying materials are made available
 # under the terms of "Eclipse Public License v1.0"
 # which accompanies this distribution, and is available
 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
-#
 # Initial Contributors:
 # Nokia Corporation - initial contribution.
-#
 # Contributors:
-# 
 # Description:
-#
-#
+symbian*::# Build.inf rules
+BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>" \
+    "nmail_settings_api/nmapimailboxsettingsdata.h APP_LAYER_PLATFORM_EXPORT_PATH(nmapimailboxsettingsdata.h)" \
+    "nmail_settings_api/nmapimailboxsettings.h APP_LAYER_PLATFORM_EXPORT_PATH(nmapimailboxsettings.h)" \
+    "nmail_settings_api/nmapisettingsmanager.h APP_LAYER_PLATFORM_EXPORT_PATH(nmapisettingsmanager.h)"
 
-symbian*: { 
-    # Build.inf rules
-    BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>" \
-        "nmail_settings_api/nmapimailboxsettingsdata.h APP_LAYER_PLATFORM_EXPORT_PATH(nmapimailboxsettingsdata.h)" \
-	"nmail_settings_api/nmapimailboxsettings.h APP_LAYER_PLATFORM_EXPORT_PATH(nmapimailboxsettings.h)"
-    
-}
--- a/email_plat/nmail_settings_api/nmapimailboxsettingsdata.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/email_plat/nmail_settings_api/nmapimailboxsettingsdata.h	Wed Aug 18 09:37:47 2010 +0300
@@ -45,6 +45,11 @@
 const QString NmApiFetchManually = "Manual-Fetch";
 const QString NmApiUserDefined = "User-Defined";
 
+const QString EmailProfileOffsetKUTD = "KUTD";
+const QString EmailProfileOffsetSE = "SE";
+const QString EmailProfileOffsetMF = "MF";
+const QString EmailProfileOffsetUD = "UD";
+
 enum NmApiWeekDays
 {
     Mon = 0x01, Tue = 0x02, Wed = 0x04, Thu = 0x08, Fri = 0x10,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/nmail_settings_api/nmapisettingsmanager.h	Wed Aug 18 09:37:47 2010 +0300
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef NMAPISETTINGSMANAGER_H_
+#define NMAPISETTINGSMANAGER_H_
+
+#include <nmapidef.h>
+
+namespace EmailClientApi
+{
+
+class NmApiMailboxSettingsData;
+class NmApiSettingsManagerPrivate;
+class NMAPI_EXPORT NmApiSettingsManager
+{
+public:
+    NmApiSettingsManager(const quint64 mailboxId);
+    ~NmApiSettingsManager();
+
+    bool load(quint64 mailboxId, NmApiMailboxSettingsData &data);
+    bool save(const NmApiMailboxSettingsData &data);
+    
+protected:    
+    NmApiSettingsManagerPrivate *d;
+ 
+};
+
+}
+
+#endif /* NMAPISETTINGSMANAGER_H_ */
--- a/emailservices/emailcommon/src/CFSMailBox.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailcommon/src/CFSMailBox.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -654,7 +654,7 @@
             TFSMailMsgId id = iFolders[i]->GetFolderId();
             if( id != draftsFolderId && id != outboxId )
             {
-                folderIds.Append(id);
+                folderIds.AppendL(id);
             }
         }
         
--- a/emailservices/emailcommon/src/CFSMailFolder.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailcommon/src/CFSMailFolder.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -176,7 +176,7 @@
 		{
 		RArray<TFSMailMsgId> messages;
 		messages.Reset();
-		messages.Append(aMessage);
+		messages.AppendL(aMessage);
 		plugin->DeleteMessagesByUidL(GetMailBoxId(),GetFolderId(),messages);
 		messages.Close();
 		}
@@ -204,7 +204,7 @@
         
         RArray<TFSMailMsgId> messages;
         messages.Reset();
-        messages.Append(aMessage);
+        messages.AppendL(aMessage);
         
         TRAP(err,plugin->DeleteMessagesByUidL(
             GetMailBoxId(),
--- a/emailservices/emailcommon/src/CFSMailMessagePart.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailcommon/src/CFSMailMessagePart.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -570,7 +570,7 @@
         CleanupClosePushL( ids ); 
         for(TInt i=0;i<attachments.Count();i++)
             {
-            ids.Append(attachments[i]->GetPartId());
+            ids.AppendL(attachments[i]->GetPartId());
             }
         
         // remove attachment fetched contents 
@@ -1382,9 +1382,8 @@
 	TInt requestId(0);
 	if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
 		{
-		
 	    RArray<TFSMailMsgId> messageList;
-    	messageList.Append(GetPartId());
+    	messageList.AppendL(GetPartId());
 		
 	    // init async request
 	    TFSPendingRequest request = iRequestHandler->InitAsyncRequestL(	GetPartId().PluginId(),
--- a/emailservices/emailcommon/src/CFSMailRequestHandler.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailcommon/src/CFSMailRequestHandler.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -154,7 +154,7 @@
         CFSMailRequestObserver* observer = 
             CFSMailRequestObserver::NewL(*this, aOperationObserver);
         newRequest.iObserver = observer;
-        iPendingRequests.Append(newRequest);
+        iPendingRequests.AppendL(newRequest);
         
         return newRequest;
     }
@@ -231,8 +231,7 @@
     CFSMailPluginData* pluginData = new (ELeave) CFSMailPluginData;
     pluginData->iPluginId = aPluginId;
     pluginData->iPlugin = aPlugin;
-    iPluginList.Append(pluginData);             
-
+    iPluginList.AppendL(pluginData);             
     }
 
 // -----------------------------------------------------------------------------
--- a/emailservices/emaildebug/inc/emailtrace.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emaildebug/inc/emailtrace.h	Wed Aug 18 09:37:47 2010 +0300
@@ -22,6 +22,7 @@
 #include <QDebug>
 #include <QFile>
 #include <QThread>
+#include <QDateTime>
 
 /*
  * The macros NM_COMMENT_TRACES, NM_ERROR_TRACES, and NM_FUNCTION_TRACES
@@ -33,11 +34,19 @@
  * opened, the messages are printed to qDebug(). The DSC2STR() function can
  * be used to convert Symbian descriptors to QString objects.
  */
-#if defined(DEBUG) || defined(_DEBUG)
+#if defined(DEBUG) || defined(_DEBUG) || NM_COMMENT_TRACES || NM_ERROR_TRACES || NM_FUNCTION_TRACES
 
+#ifndef NM_COMMENT_TRACES
 #define NM_COMMENT_TRACES  0
+#endif
+
+#ifndef NM_ERROR_TRACES
 #define NM_ERROR_TRACES    0
+#endif
+
+#ifndef NM_FUNCTION_TRACES
 #define NM_FUNCTION_TRACES 0
+#endif
 
 #if NM_COMMENT_TRACES || NM_ERROR_TRACES || NM_FUNCTION_TRACES
 
@@ -53,8 +62,9 @@
     if (NM_LOG_TO_FILE && !file.isOpen()) {
         file.open(QIODevice::Append | QIODevice::Text);
     }
+    QDateTime dt = QDateTime::currentDateTime ();
     if (file.isWritable()) {
-        QDebug(&file).nospace() << msg << '\n';
+        QDebug(&file).nospace() << dt.toString(Qt::ISODate) << " " << msg << '\n';
     } else {
         qDebug().nospace() << "[Nmail] " << msg;
     }
--- a/emailservices/emailframework/bwins/FSMailFrameworkU.DEF	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailframework/bwins/FSMailFrameworkU.DEF	Wed Aug 18 09:37:47 2010 +0300
@@ -10,21 +10,23 @@
 	?GetTempDirL@CFSMailClient@@QAEAAVTDesC16@@XZ @ 9 NONAME ; class TDesC16 & CFSMailClient::GetTempDirL(void)
 	?GetFolderByUidL@CFSMailClient@@QAEPAVCFSMailFolder@@VTFSMailMsgId@@0@Z @ 10 NONAME ; class CFSMailFolder * CFSMailClient::GetFolderByUidL(class TFSMailMsgId, class TFSMailMsgId)
 	?ExtensionL@CFSMailClient@@UAEPAVCEmailExtension@@ABVTUid@@@Z @ 11 NONAME ; class CEmailExtension * CFSMailClient::ExtensionL(class TUid const &)
-	?NewL@CFSMailClient@@SAPAV1@H@Z @ 12 NONAME ; class CFSMailClient * CFSMailClient::NewL(int)
-	?SetMailboxName@CFSMailClient@@QAEXVTFSMailMsgId@@ABVTDesC16@@@Z @ 13 NONAME ; void CFSMailClient::SetMailboxName(class TFSMailMsgId, class TDesC16 const &)
-	?GetMessageByUidL@CFSMailClient@@QAEPAVCFSMailMessage@@VTFSMailMsgId@@00W4TFSMailDetails@@@Z @ 14 NONAME ; class CFSMailMessage * CFSMailClient::GetMessageByUidL(class TFSMailMsgId, class TFSMailMsgId, class TFSMailMsgId, enum TFSMailDetails)
-	?GetMailBoxByUidL@CFSMailClient@@QAEPAVCFSMailBox@@VTFSMailMsgId@@@Z @ 15 NONAME ; class CFSMailBox * CFSMailClient::GetMailBoxByUidL(class TFSMailMsgId)
-	?AuthenticateL@CFSMailClient@@QAEHAAVMFSMailRequestObserver@@@Z @ 16 NONAME ; int CFSMailClient::AuthenticateL(class MFSMailRequestObserver &)
-	?GetBrandManagerL@CFSMailClient@@QAEAAVMFSMailBrandManager@@XZ @ 17 NONAME ; class MFSMailBrandManager & CFSMailClient::GetBrandManagerL(void)
-	??1CFSMailClient@@EAE@XZ @ 18 NONAME ; CFSMailClient::~CFSMailClient(void)
-	?NewLC@CFSMailClient@@SAPAV1@H@Z @ 19 NONAME ; class CFSMailClient * CFSMailClient::NewLC(int)
-	?UnregisterRequestObserver@CFSMailClient@@QAEXH@Z @ 20 NONAME ; void CFSMailClient::UnregisterRequestObserver(int)
-	?RemoveObserver@CFSMailClient@@QAEXAAVMFSMailEventObserver@@@Z @ 21 NONAME ; void CFSMailClient::RemoveObserver(class MFSMailEventObserver &)
-	?SubscribeMailboxEventsL@CFSMailClient@@QAEXVTFSMailMsgId@@AAVMFSMailEventObserver@@@Z @ 22 NONAME ; void CFSMailClient::SubscribeMailboxEventsL(class TFSMailMsgId, class MFSMailEventObserver &)
-	?ListMessages@CFSMailClient@@QAEPAVMFSMailIterator@@VTFSMailMsgId@@0W4TFSMailDetails@@ABV?$RArray@VTFSMailSortCriteria@@@@@Z @ 23 NONAME ; class MFSMailIterator * CFSMailClient::ListMessages(class TFSMailMsgId, class TFSMailMsgId, enum TFSMailDetails, class RArray<class TFSMailSortCriteria> const &)
-	?UnsubscribeMailboxEvents@CFSMailClient@@QAEXVTFSMailMsgId@@AAVMFSMailEventObserver@@@Z @ 24 NONAME ; void CFSMailClient::UnsubscribeMailboxEvents(class TFSMailMsgId, class MFSMailEventObserver &)
-	?CancelAllL@CFSMailClient@@QAEXXZ @ 25 NONAME ; void CFSMailClient::CancelAllL(void)
-	?NewL@CFSMailClient@@SAPAV1@XZ @ 26 NONAME ; class CFSMailClient * CFSMailClient::NewL(void)
-	?AddObserverL@CFSMailClient@@QAEXAAVMFSMailEventObserver@@@Z @ 27 NONAME ; void CFSMailClient::AddObserverL(class MFSMailEventObserver &)
-	?IncReferenceCount@CFSMailClient@@QAEHXZ @ 28 NONAME ; int CFSMailClient::IncReferenceCount(void)
+	?PrepareMrDescriptionL@CFSMailClient@@UAEXABVTFSMailMsgId@@0@Z @ 12 NONAME ; void CFSMailClient::PrepareMrDescriptionL(class TFSMailMsgId const &, class TFSMailMsgId const &)
+	?NewL@CFSMailClient@@SAPAV1@H@Z @ 13 NONAME ; class CFSMailClient * CFSMailClient::NewL(int)
+	?SetMailboxName@CFSMailClient@@QAEXVTFSMailMsgId@@ABVTDesC16@@@Z @ 14 NONAME ; void CFSMailClient::SetMailboxName(class TFSMailMsgId, class TDesC16 const &)
+	?GetMessageByUidL@CFSMailClient@@QAEPAVCFSMailMessage@@VTFSMailMsgId@@00W4TFSMailDetails@@@Z @ 15 NONAME ; class CFSMailMessage * CFSMailClient::GetMessageByUidL(class TFSMailMsgId, class TFSMailMsgId, class TFSMailMsgId, enum TFSMailDetails)
+	?GetMailBoxByUidL@CFSMailClient@@QAEPAVCFSMailBox@@VTFSMailMsgId@@@Z @ 16 NONAME ; class CFSMailBox * CFSMailClient::GetMailBoxByUidL(class TFSMailMsgId)
+	?AuthenticateL@CFSMailClient@@QAEHAAVMFSMailRequestObserver@@@Z @ 17 NONAME ; int CFSMailClient::AuthenticateL(class MFSMailRequestObserver &)
+	?GetBrandManagerL@CFSMailClient@@QAEAAVMFSMailBrandManager@@XZ @ 18 NONAME ; class MFSMailBrandManager & CFSMailClient::GetBrandManagerL(void)
+	??1CFSMailClient@@EAE@XZ @ 19 NONAME ; CFSMailClient::~CFSMailClient(void)
+	?NewLC@CFSMailClient@@SAPAV1@H@Z @ 20 NONAME ; class CFSMailClient * CFSMailClient::NewLC(int)
+	?UnregisterRequestObserver@CFSMailClient@@QAEXH@Z @ 21 NONAME ; void CFSMailClient::UnregisterRequestObserver(int)
+	?RemoveObserver@CFSMailClient@@QAEXAAVMFSMailEventObserver@@@Z @ 22 NONAME ; void CFSMailClient::RemoveObserver(class MFSMailEventObserver &)
+	?SubscribeMailboxEventsL@CFSMailClient@@QAEXVTFSMailMsgId@@AAVMFSMailEventObserver@@@Z @ 23 NONAME ; void CFSMailClient::SubscribeMailboxEventsL(class TFSMailMsgId, class MFSMailEventObserver &)
+	?ListMessages@CFSMailClient@@QAEPAVMFSMailIterator@@VTFSMailMsgId@@0W4TFSMailDetails@@ABV?$RArray@VTFSMailSortCriteria@@@@@Z @ 24 NONAME ; class MFSMailIterator * CFSMailClient::ListMessages(class TFSMailMsgId, class TFSMailMsgId, enum TFSMailDetails, class RArray<class TFSMailSortCriteria> const &)
+	?UnsubscribeMailboxEvents@CFSMailClient@@QAEXVTFSMailMsgId@@AAVMFSMailEventObserver@@@Z @ 25 NONAME ; void CFSMailClient::UnsubscribeMailboxEvents(class TFSMailMsgId, class MFSMailEventObserver &)
+	?CancelAllL@CFSMailClient@@QAEXXZ @ 26 NONAME ; void CFSMailClient::CancelAllL(void)
+	?GetMailBoxByUidLC@CFSMailClient@@QAEPAVCFSMailBox@@VTFSMailMsgId@@@Z @ 27 NONAME ; class CFSMailBox * CFSMailClient::GetMailBoxByUidLC(class TFSMailMsgId)
+	?NewL@CFSMailClient@@SAPAV1@XZ @ 28 NONAME ; class CFSMailClient * CFSMailClient::NewL(void)
+	?AddObserverL@CFSMailClient@@QAEXAAVMFSMailEventObserver@@@Z @ 29 NONAME ; void CFSMailClient::AddObserverL(class MFSMailEventObserver &)
+	?IncReferenceCount@CFSMailClient@@QAEHXZ @ 30 NONAME ; int CFSMailClient::IncReferenceCount(void)
 
--- a/emailservices/emailframework/data/fsmailbrandmanager.rss	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailframework/data/fsmailbrandmanager.rss	Wed Aug 18 09:37:47 2010 +0300
@@ -24,9 +24,10 @@
 #include <microsoft_brand_graphics.mbg>
 #include <ovi_brand_graphics.mbg>
 #include <aol_brand_graphics.mbg>
+#include <mail_for_exchange_brand_graphics.mbg>
 
-#include "MailBrandManager.hrh"
-#include "MailBrandManager.rh"
+#include "mailbrandmanager.hrh"
+#include "mailbrandmanager.rh"
 
 // ---------------------------------------------------------
 //   
@@ -101,46 +102,82 @@
 
                 brand_id_match_strings =
                     {
-                    BRAND_MATCH_STRING { text = "*ymail.com"; },
-                    BRAND_MATCH_STRING { text = "*kimo.com"; },
-                    BRAND_MATCH_STRING { text = "*geocities.com"; },
-                    BRAND_MATCH_STRING { text = "*rocketmail.com"; },
-                    BRAND_MATCH_STRING { text = "*wans.net"; },
-                    BRAND_MATCH_STRING { text = "*wans.net"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.ca"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.cn"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.co.in"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.in"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.co.kr"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.co.uk"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.ar"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.br"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.cn"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.hk"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.mx"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.sg"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.tw"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.my"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.vn"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.ph"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.tr"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.co"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.pe"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.com.ve"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.de"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.dk"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.es"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.fr"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.gr"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.ie"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.it"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.no"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.se"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.co.id"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.co.th"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.pl"; },
-                    BRAND_MATCH_STRING { text = "*yahoo.cl"; }
+                    BRAND_MATCH_STRING { text = "*.ymail.com"; },
+                    BRAND_MATCH_STRING { text = "ymail.com"; },
+                    BRAND_MATCH_STRING { text = "*.kimo.com"; },
+                    BRAND_MATCH_STRING { text = "kimo.com"; },
+                    BRAND_MATCH_STRING { text = "*.geocities.com"; },
+                    BRAND_MATCH_STRING { text = "geocities.com"; },
+                    BRAND_MATCH_STRING { text = "*.rocketmail.com"; },
+                    BRAND_MATCH_STRING { text = "rocketmail.com"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.ca"; },
+                    BRAND_MATCH_STRING { text = "yahoo.ca"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.cn"; },
+                    BRAND_MATCH_STRING { text = "yahoo.cn"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.co.in"; },
+                    BRAND_MATCH_STRING { text = "yahoo.co.in"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.in"; },
+                    BRAND_MATCH_STRING { text = "yahoo.in"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.co.kr"; },
+                    BRAND_MATCH_STRING { text = "yahoo.co.kr"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.co.uk"; },
+                    BRAND_MATCH_STRING { text = "yahoo.co.uk"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.ar"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.ar"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.br"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.br"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.cn"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.cn"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.hk"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.hk"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.mx"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.mx"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.sg"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.sg"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.tw"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.tw"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.my"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.my"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.vn"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.vn"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.ph"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.ph"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.tr"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.tr"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.co"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.co"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.pe"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.pe"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.com.ve"; },
+                    BRAND_MATCH_STRING { text = "yahoo.com.ve"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.de"; },
+                    BRAND_MATCH_STRING { text = "yahoo.de"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.dk"; },
+                    BRAND_MATCH_STRING { text = "yahoo.dk"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.es"; },
+                    BRAND_MATCH_STRING { text = "yahoo.es"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.fr"; },
+                    BRAND_MATCH_STRING { text = "yahoo.fr"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.gr"; },
+                    BRAND_MATCH_STRING { text = "yahoo.gr"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.ie"; },
+                    BRAND_MATCH_STRING { text = "yahoo.ie"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.it"; },
+                    BRAND_MATCH_STRING { text = "yahoo.it"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.no"; },
+                    BRAND_MATCH_STRING { text = "yahoo.no"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.se"; },
+                    BRAND_MATCH_STRING { text = "yahoo.se"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.co.id"; },
+                    BRAND_MATCH_STRING { text = "yahoo.co.id"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.co.th"; },
+                    BRAND_MATCH_STRING { text = "yahoo.co.th"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.pl"; },
+                    BRAND_MATCH_STRING { text = "yahoo.pl"; },
+                    BRAND_MATCH_STRING { text = "*.yahoo.cl"; },
+                    BRAND_MATCH_STRING { text = "yahoo.cl"; }
                     };
                 
                 graphics = 
@@ -161,173 +198,6 @@
                 	red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
                 	};
                 },
-                
-          BRAND {
-                // Definition of Aol Mail brand   
-                graphics_file_path = APP_BITMAP_DIR"\\aol_brand_graphics.mif";
-
-                brand_id_match_strings =
-                {
-                    BRAND_MATCH_STRING { text = "*aol.com"; },
-                    BRAND_MATCH_STRING { text = "*aolchina.com"; },
-                    BRAND_MATCH_STRING { text = "*myaol.jp"; },
-                    BRAND_MATCH_STRING { text = "*aol.cz"; },
-                    BRAND_MATCH_STRING { text = "*aol.ch"; },
-                    BRAND_MATCH_STRING { text = "*aol.be"; },
-                    BRAND_MATCH_STRING { text = "*aol.co.nz"; },
-                    BRAND_MATCH_STRING { text = "*aol.cl"; },
-                    BRAND_MATCH_STRING { text = "*aol.kr"; },
-                    BRAND_MATCH_STRING { text = "*aol.co.uk"; },
-                    BRAND_MATCH_STRING { text = "*aol.ru"; },
-                    BRAND_MATCH_STRING { text = "*aol.com.au"; },
-                    BRAND_MATCH_STRING { text = "*aol.com.ar"; },
-                    BRAND_MATCH_STRING { text = "*aol.com.co"; },
-                    BRAND_MATCH_STRING { text = "*aol.com.ve"; },
-                    BRAND_MATCH_STRING { text = "*aol.com.mx"; },
-                    BRAND_MATCH_STRING { text = "*aol.com.tr"; },
-                    BRAND_MATCH_STRING { text = "*aol.com.br"; },
-                    BRAND_MATCH_STRING { text = "*aol.de"; },
-                    BRAND_MATCH_STRING { text = "*aol.nl"; },
-                    BRAND_MATCH_STRING { text = "*aol.es"; },
-                    BRAND_MATCH_STRING { text = "*aol.fr"; },
-                    BRAND_MATCH_STRING { text = "*aol.dk"; },
-                    BRAND_MATCH_STRING { text = "*aol.at"; },
-                    BRAND_MATCH_STRING { text = "*aol.it"; },
-                    BRAND_MATCH_STRING { text = "*aol.hk"; },
-                    BRAND_MATCH_STRING { text = "*aol.se"; },
-                    BRAND_MATCH_STRING { text = "*aol.tw"; },
-                    BRAND_MATCH_STRING { text = "*aol.jp"; }
-                    };
-                    
-                graphics = 
-                    {
-                    BRANDABLE_GRAPHIC { id = EFSMailboxIcon;
-                    icon_id = EMbmAol_brand_graphicsAol;
-                    mask_id = EMbmAol_brand_graphicsAol_mask; }                    
-                    };
-                        
-                texts = 
-                    {
-                    BRANDABLE_TEXT { id = EFSMailboxName; text = "AOL Mail"; }
-                    };
-                        
-                colors =
-                    {
-                    BRANDABLE_COLOR { id = EFSMailboxNameColor;
-                    red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
-                    };
-                },
-                    
-          BRAND {
-                    // Definition of Aol Mail brand   
-                    graphics_file_path = APP_BITMAP_DIR"\\aol_brand_graphics.mif";
-
-                    brand_id_match_strings =
-                    {
-                       BRAND_MATCH_STRING { text = "*aim.com"; }
-                    };
-                        
-                    graphics = 
-                    {
-                        BRANDABLE_GRAPHIC { id = EFSMailboxIcon;
-                        icon_id = EMbmAol_brand_graphicsAol;
-                        mask_id = EMbmAol_brand_graphicsAol_mask; }                    
-                    };
-                            
-                    texts = 
-                    {
-                        BRANDABLE_TEXT { id = EFSMailboxName; text = "AIM Mail"; }
-                    };
-                            
-                    colors =
-                    {
-                        BRANDABLE_COLOR { id = EFSMailboxNameColor;
-                        red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
-                    };
-                },
-                        
-                BRAND {
-                      // Definition of Aol Mail brand   
-                      graphics_file_path = APP_BITMAP_DIR"\\aol_brand_graphics.mif";
-
-                      brand_id_match_strings =
-                      {
-                          BRAND_MATCH_STRING { text = "*aol.pl"; }
-                      };
-                            
-                      graphics = 
-                      {
-                          BRANDABLE_GRAPHIC { id = EFSMailboxIcon;
-                          icon_id = EMbmAol_brand_graphicsAol;
-                          mask_id = EMbmAol_brand_graphicsAol_mask; }                    
-                      };
-                                
-                      texts = 
-                      {
-                          BRANDABLE_TEXT { id = EFSMailboxName; text = "AOL Poczta"; }
-                      };
-                                
-                      colors =
-                      {
-                          BRANDABLE_COLOR { id = EFSMailboxNameColor;
-                          red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
-                      };
-                  },
-                  BRAND {
-                          // Definition of Aol Mail brand   
-                          graphics_file_path = APP_BITMAP_DIR"\\aol_brand_graphics.mif";
-
-                          brand_id_match_strings =
-                          {
-                              BRAND_MATCH_STRING { text = "*aol.no"; }
-                          };
-                                
-                          graphics = 
-                          {
-                              BRANDABLE_GRAPHIC { id = EFSMailboxIcon;
-                              icon_id = EMbmAol_brand_graphicsAol;
-                              mask_id = EMbmAol_brand_graphicsAol_mask; }                    
-                          };
-                                    
-                          texts = 
-                          {
-                              BRANDABLE_TEXT { id = EFSMailboxName; text = "AOL epost"; }
-                          };
-                                    
-                          colors =
-                          {
-                              BRANDABLE_COLOR { id = EFSMailboxNameColor;
-                              red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
-                          };
-                      },
-                                
-                      BRAND {
-                            // Definition of Aol Mail brand   
-                            graphics_file_path = APP_BITMAP_DIR"\\aol_brand_graphics.mif";
-
-                            brand_id_match_strings =
-                            {
-                                BRAND_MATCH_STRING { text = "*aol.fi"; }
-                            };
-                                    
-                            graphics = 
-                            {
-                                BRANDABLE_GRAPHIC { id = EFSMailboxIcon;
-                                icon_id = EMbmAol_brand_graphicsAol;
-                                mask_id = EMbmAol_brand_graphicsAol_mask; }                    
-                            };
-                                        
-                            texts = 
-                            {
-                                BRANDABLE_TEXT { id = EFSMailboxName; text = "AOL Sähköposti"; }
-                            };
-                                        
-                            colors =
-                            {
-                                BRANDABLE_COLOR { id = EFSMailboxNameColor;
-                                red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
-                            };
-                      },
 
                 BRAND {
                     // Definition of Yahoo!7 Mail brand   
@@ -335,8 +205,10 @@
 
                     brand_id_match_strings =
                         {
-                        BRAND_MATCH_STRING { text = "*y7mail.com"; },
-                        BRAND_MATCH_STRING { text = "*yahoo.com.au"; }
+                        BRAND_MATCH_STRING { text = "*.y7mail.com"; },
+                        BRAND_MATCH_STRING { text = "y7mail.com"; },
+                        BRAND_MATCH_STRING { text = "*.yahoo.com.au"; },
+                        BRAND_MATCH_STRING { text = "yahoo.com.au"; }
                         };
                     
                     graphics = 
@@ -357,132 +229,7 @@
                         red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
                         };
                     },
-                    
-                    BRAND {
-                        // Definition of ... Yahoo! Mail brand   
-                        graphics_file_path = APP_BITMAP_DIR"\\yahoo_brand_graphics.mif";
-
-                        brand_id_match_strings =
-                            {
-                            BRAND_MATCH_STRING { text = "ameritech.net"; },
-                            BRAND_MATCH_STRING { text = "flash.net"; },
-                            BRAND_MATCH_STRING { text = "nvbell.net"; },
-                            BRAND_MATCH_STRING { text = "pacbell.net"; },
-                            BRAND_MATCH_STRING { text = "prodigy.net"; },
-                            BRAND_MATCH_STRING { text = "sbcglobal.net"; },
-                            BRAND_MATCH_STRING { text = "bellsouth.net"; },
-                            BRAND_MATCH_STRING { text = "snet.net"; },
-                            BRAND_MATCH_STRING { text = "swbell.net"; }
-                            };
-                        
-                        graphics = 
-                            {
-                            BRANDABLE_GRAPHIC { id = EFSMailboxIcon;
-                            icon_id = EMbmYahoo_brand_graphicsYahoo;
-                            mask_id = EMbmYahoo_brand_graphicsYahoo_mask; }                    
-                            };
-                            
-                        texts = 
-                            {
-                            BRANDABLE_TEXT { id = EFSMailboxName; text = "AT&T Yahoo! Mail"; }
-                            };
-                            
-                        colors =
-                            {
-                            BRANDABLE_COLOR { id = EFSMailboxNameColor;
-                            red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
-                            };
-                        },
-                        
-                        BRAND {
-                            // Definition of BT Yahoo! Mail brand   
-                            graphics_file_path = APP_BITMAP_DIR"\\yahoo_brand_graphics.mif";
-
-                            brand_id_match_strings =
-                                {
-                                BRAND_MATCH_STRING { text = "btinternet.com"; },
-                                BRAND_MATCH_STRING { text = "btopenworld.com"; },
-                                BRAND_MATCH_STRING { text = "talk21.com"; }
-                                };
-                            
-                            graphics = 
-                                {
-                                BRANDABLE_GRAPHIC { id = EFSMailboxIcon;
-                                icon_id = EMbmYahoo_brand_graphicsYahoo;
-                                mask_id = EMbmYahoo_brand_graphicsYahoo_mask; }                    
-                                };
-                                
-                            texts = 
-                                {
-                                BRANDABLE_TEXT { id = EFSMailboxName; text = "BT Yahoo! Mail"; }
-                                };
-                                
-                            colors =
-                                {
-                                BRANDABLE_COLOR { id = EFSMailboxNameColor;
-                                red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
-                                };
-                            },
-
-                            BRAND {
-                                // Definition of ... Yahoo! Mail brand   
-                                graphics_file_path = APP_BITMAP_DIR"\\yahoo_brand_graphics.mif";
-
-                                brand_id_match_strings =
-                                    {
-                                    BRAND_MATCH_STRING { text = "ort.rogers.com"; },
-                                    BRAND_MATCH_STRING { text = "nl.rogers.com"; },
-                                    BRAND_MATCH_STRING { text = "rogers.com"; },
-                                    BRAND_MATCH_STRING { text = "uat.rogers.com"; }
-                                    };
-                                
-                                graphics = 
-                                    {
-                                    BRANDABLE_GRAPHIC { id = EFSMailboxIcon;
-                                    icon_id = EMbmYahoo_brand_graphicsYahoo;
-                                    mask_id = EMbmYahoo_brand_graphicsYahoo_mask; }                    
-                                    };
-                                    
-                                texts = 
-                                    {
-                                    BRANDABLE_TEXT { id = EFSMailboxName; text = "Rogers Yahoo! Mail"; }
-                                    };
-                                    
-                                colors =
-                                    {
-                                    BRANDABLE_COLOR { id = EFSMailboxNameColor;
-                                    red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
-                                    };
-                                },
-                                
-                                BRAND {
-                                    // Definition of Verizon Yahoo! Mail brand   
-                                    graphics_file_path = APP_BITMAP_DIR"\\yahoo_brand_graphics.mif";
-
-                                    brand_id_match_strings =
-                                        {
-                                        BRAND_MATCH_STRING { text = "verizon.net"; }
-                                        };
-                                    
-                                    graphics = 
-                                        {
-                                        BRANDABLE_GRAPHIC { id = EFSMailboxIcon;
-                                        icon_id = EMbmYahoo_brand_graphicsYahoo;
-                                        mask_id = EMbmYahoo_brand_graphicsYahoo_mask; }                    
-                                        };
-                                        
-                                    texts = 
-                                        {
-                                        BRANDABLE_TEXT { id = EFSMailboxName; text = "Verizon Yahoo! Mail"; }
-                                        };
-                                        
-                                    colors =
-                                        {
-                                        BRANDABLE_COLOR { id = EFSMailboxNameColor;
-                                        red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
-                                        };
-                                    },
-                                    
+                     
                                     BRAND {
                                         // Definition of Yahoo!Xtra Mail brand   
                                         graphics_file_path = APP_BITMAP_DIR"\\yahoo_brand_graphics.mif";
@@ -517,54 +264,98 @@
 
                 brand_id_match_strings =
                         {
-                        BRAND_MATCH_STRING { text = "*msn.com"; },
-                        BRAND_MATCH_STRING { text = "*hotmail.com"; },
-                        BRAND_MATCH_STRING { text = "*hotmail.co.uk"; },
-                        BRAND_MATCH_STRING { text = "*hotmail.co.jp"; },
-                        BRAND_MATCH_STRING { text = "*hotmail-int.com"; },
-                        BRAND_MATCH_STRING { text = "*hotmail.de"; },
-                        BRAND_MATCH_STRING { text = "*hotmail.fr"; },
-                        BRAND_MATCH_STRING { text = "*hotmail.it"; },
-                        BRAND_MATCH_STRING { text = "*hotmail.nl"; },
-                        BRAND_MATCH_STRING { text = "*hotmail.es"; },
-                        BRAND_MATCH_STRING { text = "*live.com"; },
-                        BRAND_MATCH_STRING { text = "*live.at"; },
-                        BRAND_MATCH_STRING { text = "*live.be"; },
-                        BRAND_MATCH_STRING { text = "*live.ca"; },
-                        BRAND_MATCH_STRING { text = "*live.cl"; },
-                        BRAND_MATCH_STRING { text = "*live.cn"; },
-                        BRAND_MATCH_STRING { text = "*live.de"; },
-                        BRAND_MATCH_STRING { text = "*live.dk"; },
-                        BRAND_MATCH_STRING { text = "*live.fr"; },
-                        BRAND_MATCH_STRING { text = "*live.hk"; },
-                        BRAND_MATCH_STRING { text = "*live.it"; },
-                        BRAND_MATCH_STRING { text = "*live.jp"; },
-                        BRAND_MATCH_STRING { text = "*live.nl"; },
-                        BRAND_MATCH_STRING { text = "*live.no"; },
-                        BRAND_MATCH_STRING { text = "*live.ph"; },
-                        BRAND_MATCH_STRING { text = "*live.ru"; },
-                        BRAND_MATCH_STRING { text = "*live.se"; },
-                        BRAND_MATCH_STRING { text = "*live.ie"; },
-                        BRAND_MATCH_STRING { text = "*live.in"; },
-                        BRAND_MATCH_STRING { text = "*live.co.kr"; },
-                        BRAND_MATCH_STRING { text = "*live.co.uk"; },
-                        BRAND_MATCH_STRING { text = "*live.co.za"; },
-                        BRAND_MATCH_STRING { text = "*live.com.ar"; },
-                        BRAND_MATCH_STRING { text = "*live.com.au"; },
-                        BRAND_MATCH_STRING { text = "*live.com.mx"; },
-                        BRAND_MATCH_STRING { text = "*live.com.my"; },
-                        BRAND_MATCH_STRING { text = "*live.com.pe"; },
-                        BRAND_MATCH_STRING { text = "*live.com.pk"; },
-                        BRAND_MATCH_STRING { text = "*live.com.pt"; },
-                        BRAND_MATCH_STRING { text = "*live.com.sg"; },
-                        BRAND_MATCH_STRING { text = "*live.com.ve"; },
-                        BRAND_MATCH_STRING { text = "*live.com.ph"; },
-                        BRAND_MATCH_STRING { text = "*livemail.com.br"; },
-                        BRAND_MATCH_STRING { text = "*livemail.tw"; },
-                        BRAND_MATCH_STRING { text = "*mibli.com"; },
-                        BRAND_MATCH_STRING { text = "*oxicash.in"; },
-                        BRAND_MATCH_STRING { text = "*windowslive.com"; },
-                        BRAND_MATCH_STRING { text = "*windowslive.es"; }
+                        BRAND_MATCH_STRING { text = "*.msn.com"; },
+                        BRAND_MATCH_STRING { text = "msn.com"; },
+                        BRAND_MATCH_STRING { text = "*.hotmail.com"; },
+                        BRAND_MATCH_STRING { text = "hotmail.com"; },
+                        BRAND_MATCH_STRING { text = "*.hotmail.co.uk"; },
+                        BRAND_MATCH_STRING { text = "hotmail.co.uk"; },
+                        BRAND_MATCH_STRING { text = "*.hotmail.co.jp"; },
+                        BRAND_MATCH_STRING { text = "hotmail.co.jp"; },
+                        BRAND_MATCH_STRING { text = "*.hotmail-int.com"; },
+                        BRAND_MATCH_STRING { text = "hotmail-int.com"; },
+                        BRAND_MATCH_STRING { text = "*.hotmail.de"; },
+                        BRAND_MATCH_STRING { text = "hotmail.de"; },
+                        BRAND_MATCH_STRING { text = "*.hotmail.fr"; },
+                        BRAND_MATCH_STRING { text = "hotmail.fr"; },
+                        BRAND_MATCH_STRING { text = "*.hotmail.it"; },
+                        BRAND_MATCH_STRING { text = "hotmail.it"; },
+                        BRAND_MATCH_STRING { text = "*.hotmail.nl"; },
+                        BRAND_MATCH_STRING { text = "hotmail.nl"; },
+                        BRAND_MATCH_STRING { text = "*.hotmail.es"; },
+                        BRAND_MATCH_STRING { text = "hotmail.es"; },
+                        BRAND_MATCH_STRING { text = "*.live.com"; },
+                        BRAND_MATCH_STRING { text = "live.com"; },
+                        BRAND_MATCH_STRING { text = "*.live.at"; },
+                        BRAND_MATCH_STRING { text = "live.at"; },
+                        BRAND_MATCH_STRING { text = "*.live.be"; },
+                        BRAND_MATCH_STRING { text = "live.be"; },
+                        BRAND_MATCH_STRING { text = "*.live.ca"; },
+                        BRAND_MATCH_STRING { text = "live.ca"; },
+                        BRAND_MATCH_STRING { text = "*.live.cl"; },
+                        BRAND_MATCH_STRING { text = "live.cl"; },
+                        BRAND_MATCH_STRING { text = "*.live.cn"; },
+                        BRAND_MATCH_STRING { text = "live.cn"; },
+                        BRAND_MATCH_STRING { text = "*.live.de"; },
+                        BRAND_MATCH_STRING { text = "live.de"; },
+                        BRAND_MATCH_STRING { text = "*.live.dk"; },
+                        BRAND_MATCH_STRING { text = "live.dk"; },
+                        BRAND_MATCH_STRING { text = "*.live.fr"; },
+                        BRAND_MATCH_STRING { text = "live.fr"; },
+                        BRAND_MATCH_STRING { text = "*.live.hk"; },
+                        BRAND_MATCH_STRING { text = "live.hk"; },
+                        BRAND_MATCH_STRING { text = "*.live.it"; },
+                        BRAND_MATCH_STRING { text = "live.it"; },
+                        BRAND_MATCH_STRING { text = "*.live.jp"; },
+                        BRAND_MATCH_STRING { text = "live.jp"; },
+                        BRAND_MATCH_STRING { text = "*.live.nl"; },
+                        BRAND_MATCH_STRING { text = "live.nl"; },
+                        BRAND_MATCH_STRING { text = "*.live.no"; },
+                        BRAND_MATCH_STRING { text = "live.no"; },
+                        BRAND_MATCH_STRING { text = "*.live.ph"; },
+                        BRAND_MATCH_STRING { text = "live.ph"; },
+                        BRAND_MATCH_STRING { text = "*.live.ru"; },
+                        BRAND_MATCH_STRING { text = "live.ru"; },
+                        BRAND_MATCH_STRING { text = "*.live.se"; },
+                        BRAND_MATCH_STRING { text = "live.se"; },
+                        BRAND_MATCH_STRING { text = "*.live.ie"; },
+                        BRAND_MATCH_STRING { text = "live.ie"; },
+                        BRAND_MATCH_STRING { text = "*.live.in"; },
+                        BRAND_MATCH_STRING { text = "live.in"; },
+                        BRAND_MATCH_STRING { text = "*.live.co.kr"; },
+                        BRAND_MATCH_STRING { text = "live.co.kr"; },
+                        BRAND_MATCH_STRING { text = "*.live.co.uk"; },
+                        BRAND_MATCH_STRING { text = "live.co.uk"; },
+                        BRAND_MATCH_STRING { text = "*.live.co.za"; },
+                        BRAND_MATCH_STRING { text = "live.co.za"; },
+                        BRAND_MATCH_STRING { text = "*.live.com.ar"; },
+                        BRAND_MATCH_STRING { text = "live.com.ar"; },
+                        BRAND_MATCH_STRING { text = "*.live.com.au"; },
+                        BRAND_MATCH_STRING { text = "live.com.au"; },
+                        BRAND_MATCH_STRING { text = "*.live.com.mx"; },
+                        BRAND_MATCH_STRING { text = "live.com.mx"; },
+                        BRAND_MATCH_STRING { text = "*.live.com.my"; },
+                        BRAND_MATCH_STRING { text = "live.com.my"; },
+                        BRAND_MATCH_STRING { text = "*.live.com.pe"; },
+                        BRAND_MATCH_STRING { text = "live.com.pe"; },
+                        BRAND_MATCH_STRING { text = "*.live.com.pk"; },
+                        BRAND_MATCH_STRING { text = "live.com.pk"; },
+                        BRAND_MATCH_STRING { text = "*.live.com.pt"; },
+                        BRAND_MATCH_STRING { text = "live.com.pt"; },
+                        BRAND_MATCH_STRING { text = "*.live.com.sg"; },
+                        BRAND_MATCH_STRING { text = "live.com.sg"; },
+                        BRAND_MATCH_STRING { text = "*.live.com.ve"; },
+                        BRAND_MATCH_STRING { text = "live.com.ve"; },
+                        BRAND_MATCH_STRING { text = "*.live.com.ph"; },
+                        BRAND_MATCH_STRING { text = "live.com.ph"; },
+                        BRAND_MATCH_STRING { text = "*.livemail.com.br"; },
+                        BRAND_MATCH_STRING { text = "livemail.com.br"; },
+                        BRAND_MATCH_STRING { text = "*.livemail.tw"; },
+                        BRAND_MATCH_STRING { text = "livemail.tw"; },
+                        BRAND_MATCH_STRING { text = "*.windowslive.com"; },
+                        BRAND_MATCH_STRING { text = "windowslive.com"; },
+                        BRAND_MATCH_STRING { text = "*.windowslive.es"; },
+                        BRAND_MATCH_STRING { text = "windowslive.es"; }
                         };
                 
                 graphics = 
@@ -591,7 +382,8 @@
 
         	    brand_id_match_strings =
                     {
-                    BRAND_MATCH_STRING { text = "*ovi.com"; }
+                    BRAND_MATCH_STRING { text = "*.ovi.com"; },
+                    BRAND_MATCH_STRING { text = "ovi.com"; }
                     };
             
         	    graphics = 
@@ -610,6 +402,28 @@
                     {
                     BRANDABLE_COLOR { id = EFSMailboxNameColor; red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
                     };
+            },
+
+            BRAND {
+        	    // definition of Mail for Exchange brand
+        	    graphics_file_path = APP_BITMAP_DIR"\\mail_for_exchange_brand_graphics.mif";
+
+        	    brand_id_match_strings =
+                    {
+                    BRAND_MATCH_STRING { text = "Mail for Exchange"; }
+                    };
+            
+        	    graphics = 
+                    {
+                    BRANDABLE_GRAPHIC { id = EFSMailboxIcon;
+                    icon_id = EMbmMail_for_exchange_brand_graphicsMail_for_exchange;
+                    mask_id = EMbmMail_for_exchange_brand_graphicsMail_for_exchange_mask; }                    
+                    };
+
+        	    colors =
+                    {
+                    BRANDABLE_COLOR { id = EFSMailboxNameColor; red = 0xff; green = 0x30; blue = 0x20; alpha = 0xff; }
+                    };
             }
         };
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailframework/data/mail_for_exchange.svg	Wed Aug 18 09:37:47 2010 +0300
@@ -0,0 +1,78 @@
+<?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="88" height="88" viewBox="0 0 88 88">
+<rect fill="none" height="88" width="88"/>
+<polygon fill="#84A8CB" points="13.797,59.469 15.453,62.75 10.761,64.775 "/>
+<polygon fill="#7BA1C7" points="62.822,60.844 67.454,57.852 79.166,59.672 74.484,64.297 "/>
+<polygon fill="#7BA1C7" points="10.021,49.15 15.95,47.283 28.258,50.204 22.063,53.797 "/>
+<polygon fill="#9BB8D5" points="11.714,59.057 10.761,64.775 10.021,49.15 11.435,53.034 "/>
+<linearGradient id="_11" gradientUnits="userSpaceOnUse" x1="72.77" y1="62.84" x2="72.14" y2="80.04">
+<stop stop-color="#97B5D3" offset="0"/>
+<stop stop-color="#7EA4C9" offset="1"/>
+</linearGradient>
+<path d="M79.166,59.672c-2.936,9.025-9.674,13.959-13.182,16.893l8.62-13.314L79.166,59.672z" fill="url(#_11)"/>
+<polygon fill="#7BA1C7" points="12.876,56.288 14.328,60.688 10.761,64.775 11.203,58 "/>
+<polygon fill="#7BA1C7" points="15.25,54 23.313,51.859 18.859,56.875 13.844,55.891 "/>
+<polygon fill="#84A7CB" points="22.529,52.333 28.258,50.204 24.414,53.982 18.668,56.223 "/>
+<linearGradient id="_12" gradientUnits="userSpaceOnUse" x1="30.28" y1="61.64" x2="43.78" y2="69.31">
+<stop stop-color="#A0BBD7" offset="0"/>
+<stop stop-color="#7EA4C9" offset="1"/>
+</linearGradient>
+<path d="M48.67,70.793c3.58,0,6.643-0.996,8.811-2.109c-4.15,4.209-9.992,5.7-13.953,5.7 c-13.027,0-22.402-12.509-24.75-18.286l5.745-2.24C31.158,65.936,40.203,70.793,48.67,70.793z" fill="url(#_12)"/>
+<polygon fill="#90B0D0" points="11,53.781 10.021,49.15 22.529,52.333 14.453,54.641 "/>
+<polygon fill="#91B1D1" points="63.875,66.016 62.822,60.844 75.003,62.926 68.781,66.984 "/>
+<linearGradient id="_13" gradientUnits="userSpaceOnUse" x1="22.31" y1="65.7" x2="44.83" y2="68.75">
+<stop stop-color="#DDE7F1" offset="0"/>
+<stop stop-color="#C2D4E5" offset="1"/>
+</linearGradient>
+<path d="M62.822,60.844c-2.621,6.602-9.156,13.252-19.223,13.252 c-10.282,0-19.287-7.408-24.821-17.998l-5.184-0.488C15.917,59.743,25.484,78.7,43.75,78.7c13.297,0,19.408-9.746,20.422-12.669 L62.822,60.844z" fill="url(#_13)"/>
+<linearGradient id="_14" gradientUnits="userSpaceOnUse" x1="69.5" y1="70.31" x2="15.38" y2="70.31">
+<stop stop-color="#A8C1DA" offset="0"/>
+<stop stop-color="#98B6D4" offset="0.14"/>
+<stop stop-color="#97B5D3" offset="0.67"/>
+<stop stop-color="#A0BBD7" offset="1"/>
+</linearGradient>
+<path d="M75.003,62.926c-4.901,13.627-16.201,20.838-27.737,20.838 c-17.267,0-28.895-15-33.075-22.945l-1.535-3.959c8.831,15.174,18.64,24.109,32.393,24.109c11.688,0,20.42-6.422,23.295-14.047 L75.003,62.926z" fill="url(#_14)"/>
+<path d="M10.844,53.034l4.701,1.284l-1.294,1.35c3.103,5.018,11.175,22.555,30.467,22.555 c8.979,0,16.841-6.492,19.351-12.586l4.85,0.922c-3.79,10.387-15.307,14.918-23.868,14.918c-15.613,0-25.775-12.442-32.281-24.39 l-1.644,1.968L10.844,53.034z" fill="#98B6D4"/>
+<linearGradient id="_15" gradientUnits="userSpaceOnUse" x1="43.19" y1="24.29" x2="54.76" y2="58.04">
+<stop stop-color="#87AACD" offset="0"/>
+<stop stop-color="#9DB9D6" offset="0.17"/>
+<stop stop-color="#A8C1DA" offset="0.5"/>
+<stop stop-color="#A2BDD8" offset="0.76"/>
+<stop stop-color="#87AACD" offset="1"/>
+</linearGradient>
+<path d="M58.648,44.975c0,6.789-2.688,10.896-5.711,13.146c-1.797,1.335-5.822,3.345-5.822,3.345 c12.443-9.374,5.458-34.56-12.553-34.823c3.625-0.734,5.781-1.129,7.201-1.129C51.613,25.512,58.648,36.182,58.648,44.975z" fill="url(#_15)"/>
+<path d="M49.459,47.875c0,6.898-3.8,13.334-11.084,13.334c-4.325,0-14.333-5.535-14.333-18.709 c0-7.689,5.275-12.375,10.792-12.375C43.271,30.125,49.459,39.787,49.459,47.875z" fill="#98B6D4"/>
+<linearGradient id="_16" gradientUnits="userSpaceOnUse" x1="47.25" y1="34.33" x2="32.25" y2="52.33">
+<stop stop-color="#DDE7F1" offset="0"/>
+<stop stop-color="#97B5D3" offset="1"/>
+</linearGradient>
+<path d="M49.25,47.875c0,6.898-3.633,12.917-10.917,12.917c-4.325,0-14.125-5.076-14.125-18.25 c0-7.689,5.109-12.125,10.625-12.125C41.978,30.417,49.25,38.554,49.25,47.875z M35.875,26.542c-6.564,0-12.75,5.983-12.75,15.625 c0,9.617,7.249,21.167,17.708,21.167c4.284,0,12.708-3.243,12.708-15.834C53.542,35.913,44.502,26.542,35.875,26.542z" fill="url(#_16)"/>
+<path d="M46.318,46.104c0,4.533-2.313,6.504-4.754,6.504c-0.954-0.016-2.277-0.233-3.086-1.102 c-0.129,0.041-0.56,0.102-0.693,0.102c-3.618,0-5.7-4.024-5.7-7.065c0.001-1.983,1.022-4.791,3.8-4.798 c1.886,0,3.457,1.442,4.319,2.572c0.137,0.18,0.258,0.379,0.26,0.566c0.002,0.21,0.068,5.999,0.072,6.243 c0.002,0.221,0.644,0.26,0.713,0.262c1.188,0,2.484-1.259,2.524-3.605c0-4.724-4.501-9.12-8.524-9.083 c-3.271,0.03-5.488,3.223-5.509,7.067c-0.023,3.882,2.681,10.765,9.667,11.157c0.005,0.777,0.028,2.767,0.03,2.938 c-8.344-0.688-12.106-9.104-12.106-14.776c0.01-5.028,2.711-9.441,7.336-9.441C40.878,33.642,46.318,40.912,46.318,46.104z M38.082,43.448c-0.445-0.491-1.098-0.779-1.707-0.779c-1.438,0-1.866,1.331-1.866,2.269c0,2.203,1.426,3.826,3.068,3.826 c0.29,0,0.566-0.062,0.563-0.277C38.141,48.486,38.127,43.552,38.082,43.448z" fill="#4879AA"/>
+<linearGradient id="_17" gradientUnits="userSpaceOnUse" x1="23.68" y1="31.81" x2="28.74" y2="16.09">
+<stop stop-color="#97B5D3" offset="0"/>
+<stop stop-color="#7EA4C9" offset="1"/>
+</linearGradient>
+<path d="M21.841,31.093c1.517-7.152,7.593-14.731,15.543-16.523 c-12.223-1.207-19.357,8.29-21.665,16.711c0,0,0.073,1.031,0.073,1.03L21.841,31.093z" fill="url(#_17)"/>
+<linearGradient id="_18" gradientUnits="userSpaceOnUse" x1="46.98" y1="6.55" x2="62.61" y2="15.12">
+<stop stop-color="#8FB0D0" offset="0"/>
+<stop stop-color="#A0BBD7" offset="1"/>
+</linearGradient>
+<path d="M72.594,20.86C58.841,1.271,42.613,3.297,37.359,3.297 c11.892,0.92,21.475,5.828,32.032,20.813L72.594,20.86z" fill="url(#_18)"/>
+<linearGradient id="_19" gradientUnits="userSpaceOnUse" x1="69.16" y1="22.16" x2="24.08" y2="17.66">
+<stop stop-color="#DDE7F1" offset="0"/>
+<stop stop-color="#C2D4E5" offset="1"/>
+</linearGradient>
+<path d="M67.594,31.625C57.518,15.184,46.482,7.656,35.022,7.656 c-12.503,0-23.295,10.224-25.272,22.031l-1.426,2.146c2.287-17.459,15.323-28.53,27.877-28.53c14.976,0,25.434,8.804,33.017,20.477 L67.594,31.625z" fill="url(#_19)"/>
+<polygon fill="#85A8CC" points="76.529,16.32 68.609,35.047 61.375,33.172 54.84,36.833 73.666,39.793 78.023,37.797 80.902,15.665 "/>
+<polygon fill="#7CA2C8" points="69.531,27.641 76.529,16.32 73.666,39.793 69.084,35.577 "/>
+<linearGradient id="_20" gradientUnits="userSpaceOnUse" x1="12.53" y1="22" x2="64.94" y2="22">
+<stop stop-color="#A8C1DA" offset="0"/>
+<stop stop-color="#98B6D4" offset="0.14"/>
+<stop stop-color="#97B5D3" offset="0.67"/>
+<stop stop-color="#A0BBD7" offset="1"/>
+</linearGradient>
+<path d="M15.792,32.312c2.844-11.856,11.524-17.781,19.958-17.781 c12.076,0,18.857,7.519,25.261,17.316l4.885,1.809C58.951,22.865,49.361,10.346,35.05,10.346c-11.049,0-20.77,8.923-22.987,19.171 L15.792,32.312z" fill="url(#_20)"/>
+<polygon fill="#82A6CA" points="12.422,29.234 15.792,32.312 8.325,31.834 9.578,29.063 "/>
+<path d="M69.169,23.729l-1.745,6.592c-4.197-6.592-14.98-23.219-32.395-23.219 c-15.737,0-25.085,15.032-25.526,22.091l3.059,0.151c0.745-5.328,7.952-18.523,22.528-18.523c16.141,0,25.055,15.369,29.51,21.796 l-3.828-1.145l-5.933,5.361l7.396-2.13l6.961,0.985l0.897-7.997l6.437-11.371L69.169,23.729z" fill="#98B6D4"/>
+</svg>
\ No newline at end of file
--- a/emailservices/emailframework/eabi/FSMailFrameworkU.DEF	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailframework/eabi/FSMailFrameworkU.DEF	Wed Aug 18 09:37:47 2010 +0300
@@ -14,19 +14,21 @@
 	_ZN13CFSMailClient16GetMailBoxByUidLE12TFSMailMsgId @ 13 NONAME
 	_ZN13CFSMailClient16GetMessageByUidLE12TFSMailMsgIdS0_S0_14TFSMailDetails @ 14 NONAME
 	_ZN13CFSMailClient16ReleaseExtensionEP15CEmailExtension @ 15 NONAME
-	_ZN13CFSMailClient17IncReferenceCountEv @ 16 NONAME
-	_ZN13CFSMailClient19DeleteMailBoxByUidLE12TFSMailMsgIdR22MFSMailRequestObserver @ 17 NONAME
-	_ZN13CFSMailClient20DeleteMessagesByUidLE12TFSMailMsgIdS0_RK6RArrayIS0_E @ 18 NONAME
-	_ZN13CFSMailClient20WizardDataAvailableLEv @ 19 NONAME
-	_ZN13CFSMailClient23SubscribeMailboxEventsLE12TFSMailMsgIdR20MFSMailEventObserver @ 20 NONAME
-	_ZN13CFSMailClient24UnsubscribeMailboxEventsE12TFSMailMsgIdR20MFSMailEventObserver @ 21 NONAME
-	_ZN13CFSMailClient25UnregisterRequestObserverEi @ 22 NONAME
-	_ZN13CFSMailClient4NewLEi @ 23 NONAME
-	_ZN13CFSMailClient4NewLEv @ 24 NONAME
-	_ZN13CFSMailClient5CloseEv @ 25 NONAME
-	_ZN13CFSMailClient5NewLCEi @ 26 NONAME
-	_ZN13CFSMailClient7CancelLEi @ 27 NONAME
-	_ZN13CFSMailClientD0Ev @ 28 NONAME
-	_ZN13CFSMailClientD1Ev @ 29 NONAME
-	_ZN13CFSMailClientD2Ev @ 30 NONAME
+	_ZN13CFSMailClient17GetMailBoxByUidLCE12TFSMailMsgId @ 16 NONAME
+	_ZN13CFSMailClient17IncReferenceCountEv @ 17 NONAME
+	_ZN13CFSMailClient19DeleteMailBoxByUidLE12TFSMailMsgIdR22MFSMailRequestObserver @ 18 NONAME
+	_ZN13CFSMailClient20DeleteMessagesByUidLE12TFSMailMsgIdS0_RK6RArrayIS0_E @ 19 NONAME
+	_ZN13CFSMailClient20WizardDataAvailableLEv @ 20 NONAME
+	_ZN13CFSMailClient21PrepareMrDescriptionLERK12TFSMailMsgIdS2_ @ 21 NONAME
+	_ZN13CFSMailClient23SubscribeMailboxEventsLE12TFSMailMsgIdR20MFSMailEventObserver @ 22 NONAME
+	_ZN13CFSMailClient24UnsubscribeMailboxEventsE12TFSMailMsgIdR20MFSMailEventObserver @ 23 NONAME
+	_ZN13CFSMailClient25UnregisterRequestObserverEi @ 24 NONAME
+	_ZN13CFSMailClient4NewLEi @ 25 NONAME
+	_ZN13CFSMailClient4NewLEv @ 26 NONAME
+	_ZN13CFSMailClient5CloseEv @ 27 NONAME
+	_ZN13CFSMailClient5NewLCEi @ 28 NONAME
+	_ZN13CFSMailClient7CancelLEi @ 29 NONAME
+	_ZN13CFSMailClientD0Ev @ 30 NONAME
+	_ZN13CFSMailClientD1Ev @ 31 NONAME
+	_ZN13CFSMailClientD2Ev @ 32 NONAME
 
--- a/emailservices/emailframework/emailframework.pro	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailframework/emailframework.pro	Wed Aug 18 09:37:47 2010 +0300
@@ -134,6 +134,12 @@
 		"OPTION HEADERFILE yahoo_brand_graphics.mbg" \
 		"OPTION SOURCEDIR data" \
 		"OPTION SOURCES -c16,8 yahoo.svg" \
+		"END" \
+		"START EXTENSION s60/mifconv" \
+		"OPTION TARGETFILE mail_for_exchange_brand_graphics.mif" \
+		"OPTION HEADERFILE mail_for_exchange_brand_graphics.mbg" \
+		"OPTION SOURCEDIR data" \
+		"OPTION SOURCES -c16,8 mail_for_exchange.svg" \
 		"END"
 }
 
--- a/emailservices/emailframework/inc/CFSMailClient.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailframework/inc/CFSMailClient.h	Wed Aug 18 09:37:47 2010 +0300
@@ -213,10 +213,27 @@
      * returns email mailbox object related to given mailbox id
      *
      * @param aMailBoxId mailbox id
-     * @return mailbox object ( CFSMailBox ), ownership is transferred to user
+     * @return mailbox object ( CFSMailBox )
+     *         or NULL if no matching mailbox found. 
+     *         Ownership is transferred to user!
      */
      IMPORT_C CFSMailBox* GetMailBoxByUidL( const TFSMailMsgId aMailBoxId);
-                
+      	  		
+
+    /**
+     * returns email mailbox object related to given mailbox id. Otherwise 
+     * identical to GetMailBoxByUidL but mailbox object is stored to cleanup 
+     * stack.
+     *
+     * @param aMailBoxId mailbox id
+     * @return mailbox object ( CFSMailBox )
+     *         or NULL if no matching mailbox found.
+     *         CFSMailBox pointer is stored to cleanup stack (even if NULL). 
+     *         Ownership is transferred to user! 
+     */
+     IMPORT_C CFSMailBox* GetMailBoxByUidLC( const TFSMailMsgId aMailBoxId);
+
+     
     /**
      * returns email folder object related to given folder id
      *
@@ -374,6 +391,7 @@
       */
      IMPORT_C void SetMailboxName( const TFSMailMsgId aMailboxId, const TDesC& aMailboxName );
 
+
 //<qmail>
      /**
       * increments reference count to framework singleton
@@ -381,7 +399,16 @@
       */
      IMPORT_C TInt IncReferenceCount();
 //</qmail>
-
+     
+	 
+     /**
+      * Prepares and sets the MR description by converting HTML body to Plain text
+      *
+      * @param aMailboxId mailbox id
+      * @param aMessageId message id
+      */     
+     IMPORT_C virtual void PrepareMrDescriptionL( const TFSMailMsgId& aMailBoxId,
+                                                  const TFSMailMsgId& aMessageId );
 public: // from  CExtendableEmail
 
     /**
--- a/emailservices/emailframework/inc/CFSMailPlugin.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailframework/inc/CFSMailPlugin.h	Wed Aug 18 09:37:47 2010 +0300
@@ -1200,6 +1200,16 @@
       * @param aMailboxName new name for the mailbox
       */
     virtual void SetMailboxName(const TFSMailMsgId& aMailboxId, const TDesC& aMailboxName ) = 0;
+    
+    /**
+     * Prepares and sets the MR description by converting HTML body to Plain text
+     *
+     * @param aMailboxId mailbox id
+     * @param aMessageId message id
+     */     
+    virtual void PrepareMrDescriptionL( const TFSMailMsgId& /*aMailBoxId*/,
+                                        const TFSMailMsgId& /*aMessageId*/ )
+                                        { return; };
 
 protected:
 
--- a/emailservices/emailframework/src/CFSMailBrand.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailframework/src/CFSMailBrand.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -239,16 +239,32 @@
 TBool CFSMailBrand::IsMatching( const TDesC& aBrandId )
     {
     NM_FUNCTION;
-
+    const TChar KStar = '*';
+    TBool ret = EFalse;
+    TInt intRet = 0; 
     TInt count = iBrandMatchStrings.Count();
-    for(TInt i=0;i<count;i++)
+    for( TInt i=0;i<count;i++ )
         {
-        if ( aBrandId.MatchC( *iBrandMatchStrings[i] ) == KErrNone )
+        TPtrC brandMatchStringPtr = *iBrandMatchStrings[i];
+        TInt matchPos = aBrandId.MatchC( *iBrandMatchStrings[i] );
+        if ( matchPos >= 0 )
             {
-            return ETrue;
+        	TPtrC rightPartPtr = aBrandId.Right( aBrandId.Length()-matchPos );
+            TChar isStar = brandMatchStringPtr[0];
+            TInt cut = 0;
+            if ( isStar == KStar )
+                {
+                cut = 1;	
+                }
+            TPtrC matchString = brandMatchStringPtr.Right( brandMatchStringPtr.Length()-cut );
+        	intRet = rightPartPtr.CompareC( matchString );
+            if ( intRet == 0 )
+                {
+        	    ret = ETrue;
+        	    }
             }
         }
-    return EFalse;
+    return ret;
     }
 
 // -----------------------------------------------------------------------------
--- a/emailservices/emailframework/src/CFSMailClient.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailframework/src/CFSMailClient.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -37,24 +37,28 @@
 {
     NM_FUNCTION;
 
-	CFSMailClient* client = Instance();
-	if(!client)
-	{
-		client = new (ELeave) CFSMailClient();
-		CleanupStack:: PushL(client);
-		client->ConstructL(aConfiguration);
-		TInt err = Dll::SetTls(static_cast<TAny*>(client));
-		User::LeaveIfError(err);
-		}
-	else
-		{
-		CleanupStack:: PushL(client);
-		}
+    CFSMailClient* client = Instance();
+    if( !client )
+        {
+        client = new (ELeave) CFSMailClient();
+        // The new client needs to be deleted rather than closed, up until
+        // the TLS has been set properly.
+        CleanupStack::PushL( client );
+        client->ConstructL( aConfiguration );
+        TInt err = Dll::SetTls( static_cast<TAny*>( client ));
+        User::LeaveIfError( err );
+        // Now that the TLS has been set, we no longer want the new client
+        // to be deleted if there's a problem, so pop it off the cleanup
+        // stack (it will be pushed back on for closing below).
+        CleanupStack::Pop( client );
+        }
 
-	client->IncReferenceCount();
-	
-	return client;
-
+    // Increment reference count before calling CleanupClosePushL so that
+    // the reference count is correct if CleanupClosePushL leaves.
+    client->IncReferenceCount();
+    CleanupClosePushL( *client );
+    
+    return client;
 } 
 
 // -----------------------------------------------------------------------------
@@ -138,6 +142,19 @@
 }
 
 // -----------------------------------------------------------------------------
+// CFSMailClient::GetMailBoxByUidLC
+// -----------------------------------------------------------------------------
+EXPORT_C CFSMailBox* CFSMailClient::GetMailBoxByUidLC(const TFSMailMsgId aMailBoxId)
+{
+    NM_FUNCTION;
+    CFSMailBox* mailBox = GetMailBoxByUidL( aMailBoxId );
+    CleanupStack::PushL( mailBox );
+    return mailBox;
+}
+
+
+
+// -----------------------------------------------------------------------------
 // CFSMailClient::GetFolderByUidL
 // -----------------------------------------------------------------------------
 EXPORT_C CFSMailFolder* CFSMailClient::GetFolderByUidL( const TFSMailMsgId aMailBoxId,
@@ -254,7 +271,7 @@
                         mailBox = plugin->GetMailBoxByUidL(mailBoxList[ii]) );
 				    if ( mailBox )
     				    {
-                        aMailBoxes.Append( mailBox );
+                        err = aMailBoxes.Append( mailBox );
                         }
 				// </cmail>
 					if(err != KErrNone)
@@ -294,7 +311,7 @@
                         mailBox = plugin->GetMailBoxByUidL(mailBoxList[i]) );
                     if ( mailBox )
                         {
-                        aMailBoxes.Append( mailBox );
+                        err = aMailBoxes.Append( mailBox );
                         }
                 // </cmail>				
 				if(err != KErrNone)
@@ -559,7 +576,23 @@
 		plugin->SetMailboxName( aMailboxId, aMailboxName );
 		}
 	}
-	
+
+// -----------------------------------------------------------------------------
+// CFSMailClient::PrepareMrDescriptionL
+// -----------------------------------------------------------------------------
+EXPORT_C void CFSMailClient::PrepareMrDescriptionL(  const TFSMailMsgId& aMailBoxId,
+                                                     const TFSMailMsgId& aMessageId )
+    {
+    NM_FUNCTION;
+    // select plugin
+    CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid( aMessageId );
+    if ( plugin )
+        {
+        // set MR description from the plugin
+        plugin->PrepareMrDescriptionL( aMailBoxId, aMessageId );
+        }  
+    }
+
 // -----------------------------------------------------------------------------
 // CFSMailClient::Close
 // -----------------------------------------------------------------------------
--- a/emailservices/emailstore/base_plugin/BWINS/basepluginU.DEF	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/BWINS/basepluginU.DEF	Wed Aug 18 09:37:47 2010 +0300
@@ -222,4 +222,6 @@
 	?GetMailboxDisplayNameL@CBasePlugin@@IAEXIAAVRBuf16@@@Z @ 221 NONAME ; void CBasePlugin::GetMailboxDisplayNameL(unsigned int, class RBuf16 &)
 	?NewChildPartFromFileL@CBasePlugin@@UAEXABVTFSMailMsgId@@000ABVTDesC16@@1AAVMFSMailRequestObserver@@H@Z @ 222 NONAME ; void CBasePlugin::NewChildPartFromFileL(class TFSMailMsgId const &, class TFSMailMsgId const &, class TFSMailMsgId const &, class TFSMailMsgId const &, class TDesC16 const &, class TDesC16 const &, class MFSMailRequestObserver &, int)
 	?RemoveChildPartL@CBasePlugin@@UAEXABVTFSMailMsgId@@0000AAVMFSMailRequestObserver@@H@Z @ 223 NONAME ; void CBasePlugin::RemoveChildPartL(class TFSMailMsgId const &, class TFSMailMsgId const &, class TFSMailMsgId const &, class TFSMailMsgId const &, class TFSMailMsgId const &, class MFSMailRequestObserver &, int)
+	?StartOp@CDelayedOp@@QAEXXZ @ 224 NONAME ; void CDelayedOp::StartOp(void)
+	?DeleteDelayedOpsManager@CBasePlugin@@QAEXXZ @ 225 NONAME ; void CBasePlugin::DeleteDelayedOpsManager(void)
 
--- a/emailservices/emailstore/base_plugin/EABI/basepluginU.DEF	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/EABI/basepluginU.DEF	Wed Aug 18 09:37:47 2010 +0300
@@ -309,4 +309,6 @@
 	_ZThn4_NK21CBaseMrRecurrenceRule4TypeEv @ 308 NONAME
 	_ZN11CBasePlugin21NewChildPartFromFileLERK12TFSMailMsgIdS2_S2_S2_RK7TDesC16S5_R22MFSMailRequestObserveri @ 309 NONAME
 	_ZN11CBasePlugin16RemoveChildPartLERK12TFSMailMsgIdS2_S2_S2_S2_R22MFSMailRequestObserveri @ 310 NONAME
+	_ZN10CDelayedOp7StartOpEv @ 311 NONAME
+	_ZN11CBasePlugin23DeleteDelayedOpsManagerEv @ 312 NONAME
 
--- a/emailservices/emailstore/base_plugin/base_plugin.pro	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/base_plugin.pro	Wed Aug 18 09:37:47 2010 +0300
@@ -36,8 +36,8 @@
            inc/Map.h \
            inc/SafePointerArray.h \
            inc/Map.inl \
-           inc/baseplugindef.h \
-	   inc/nestedao.h
+           inc/baseplugindef.h 
+           
 SOURCES += src/BaseMrInfoObject.cpp \
            src/BasePlugin.cpp \
            src/baseplugindelayedops.cpp \
@@ -48,8 +48,7 @@
            src/basepluginparts.cpp \
            src/baseplugintranslator.cpp \
            src/MailIterator.cpp \
-	   src/basepluginresourceloader.cpp \
-	   src/nestedao.cpp
+	   src/basepluginresourceloader.cpp 
 
 LIBS += -leuser \
 		-lecom \
--- a/emailservices/emailstore/base_plugin/inc/BasePlugin.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/inc/BasePlugin.h	Wed Aug 18 09:37:47 2010 +0300
@@ -109,6 +109,11 @@
     // CFSMailPlugin //
     public:
 
+        /**
+         * This methoed must be called before destruction of 
+         * CBasePlugin derived class. To fix bug EIZU-7XVF2Z.
+         */
+         void DeleteDelayedOpsManager();
          virtual void ListMailBoxesL(
             RArray<TFSMailMsgId>& aMailboxes );
 
--- a/emailservices/emailstore/base_plugin/inc/baseplugincommonutils.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/inc/baseplugincommonutils.h	Wed Aug 18 09:37:47 2010 +0300
@@ -49,4 +49,29 @@
     CleanupResetAndDestroyClose<T>::PushL(aRef);
     }
 
+/**
+* Cleanup support for owning pointer arrays
+*/
+
+template<class T>
+class CleanupResetAndDestroy
+{
+private:
+    inline static void ResetAndDestroy( TAny *aPtr )
+    {
+    reinterpret_cast<T*>( aPtr )->ResetAndDestroy();
+    };
+public:
+    inline static void PushL( T& aItem )
+    { 
+    TCleanupItem item( &CleanupResetAndDestroy::ResetAndDestroy, &aItem );
+    CleanupStack::PushL( item );
+    };
+} ;
+
+template <class T>
+inline void CleanupResetAndDestroyPushL( T& aRef )
+    {
+    CleanupResetAndDestroy<T>::PushL( aRef );
+    }
 #endif
--- a/emailservices/emailstore/base_plugin/inc/baseplugindelayedops.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/inc/baseplugindelayedops.h	Wed Aug 18 09:37:47 2010 +0300
@@ -71,7 +71,7 @@
  * The base class for the delayed operations. All of the delayed operations must
  * derive from it.
  */
-class BASEPLUGIN_EXPORT CDelayedOp : public CAsyncOneShot
+class BASEPLUGIN_EXPORT CDelayedOp : public CActive
     {
 
 public:
@@ -82,11 +82,12 @@
         CBasePlugin& aPlugin,
         MDelayedOpsManager& aManager );
     
+	 void StartOp();
     /**
      * Derived classes must implement their asynchronous processing in this
      * method. The GetPlugin method can only be used from within this method.
      */
-    virtual void ExecuteOpL() = 0;
+    virtual TBool ExecuteOpL() = 0;
 
 protected:
     
--- a/emailservices/emailstore/base_plugin/inc/baseplugindelayedopsprivate.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/inc/baseplugindelayedopsprivate.h	Wed Aug 18 09:37:47 2010 +0300
@@ -19,7 +19,6 @@
 
 
 #include "baseplugindelayedops.h"
-#include "nestedao.h"
 
 /**
  * Lets the user enqueue and dequeue asynchronous jobs for handling
@@ -70,7 +69,7 @@
 /**
  * 
  */
-NONSHARABLE_CLASS( CDelayedDeleteMessagesOp ) : public CDelayedOp, public MDeletionHandler
+NONSHARABLE_CLASS( CDelayedDeleteMessagesOp ) : public CDelayedOp
     {
 
 public:
@@ -88,12 +87,8 @@
     virtual ~CDelayedDeleteMessagesOp();
 
     //CDelayedOp::ExecuteOpL
-    virtual void ExecuteOpL();
-    
-    //From MDeletionHandler
-    //Used to delete messages in chunks starting from aStartIndex
-    TBool DeleteMessagesInChunksL( TInt aStartIndex );
-    
+    virtual TBool ExecuteOpL();
+
 private:
 
     void ConstructL( const RArray<TFSMailMsgId>& aMessages );
@@ -112,7 +107,7 @@
     TMsgStoreId iFolderId;
     RArray<TMsgStoreId> iMessages;
     TBool iImmediateDelete;
-    TState iState;
+    TInt iIndex;
     __LOG_DECLARATION
     };
 
@@ -142,7 +137,7 @@
     virtual ~CDelayedSetContentOp();
 
     //CDelayedOp::ExecuteOpL
-    virtual void ExecuteOpL();
+    virtual TBool ExecuteOpL();
     
 private:
 
@@ -200,7 +195,7 @@
     virtual ~CDelayedMessageStorerOp();
 
     //CDelayedOp::ExecuteOpL
-    virtual void ExecuteOpL();
+    virtual TBool ExecuteOpL();
     
 private:
 
@@ -254,7 +249,7 @@
     virtual ~CDelayedMessageToSendOp();
 
     //CDelayedOp::ExecuteOpL
-    virtual void ExecuteOpL();
+    virtual TBool ExecuteOpL();
     
 private:
 
@@ -302,7 +297,7 @@
     virtual ~CDelayedAddNewOrRemoveChildPartOp();
 
     //CDelayedOp::ExecuteOpL
-    virtual void ExecuteOpL();
+    virtual TBool ExecuteOpL();
     
 private:
 
--- a/emailservices/emailstore/base_plugin/inc/nestedao.h	Tue Jul 06 14:04:34 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
-* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Class used to implement nested active object used to handle 
-* deletion of large number of messages by breaking them into smaller chunks
-*
-*/
-
-#ifndef __NESTED_AO_H__
-#define __NESTED_AO_H__
-
-//  Include Files
-
-
-#include <e32base.h>
-
-
-class MDeletionHandler
-    {
-public:
-    enum TState
-        {
-        EInProgress,
-        EFree
-        };
-    //Deletes messages from aStartIndex KSizeOfChunk at a time
-    virtual TBool DeleteMessagesInChunksL( TInt aStartIndex ) = 0;
-    };
-//Time interval between issuing 2 requests to delete messages
-const TInt KWaitIntervalInMicroSecs=500;
-//Maximum number of messages deleted in one go
-const TInt KSizeOfChunk=10;
-
-NONSHARABLE_CLASS ( CNestedAO ) : public CTimer
-    {
-    public:
-        
-        static CNestedAO* NewL( MDeletionHandler& aDeletionHandler );
-        virtual ~CNestedAO();
-        // --------------------------------------------------------------------------
-        // CNestedAO::DeleteMessagesAsync
-        // Used to delete messages asynchronously 
-        // Deleting a small number of messages at a time
-        // ------------
-        void DeleteMessagesAsync();
-        // --------------------------------------------------------------------------
-        // CNestedAO::Rc
-        // Used to return the iStatus return value
-        // ------------        
-        TInt Rc() { return iRc; }
-        
-    private:
-        CNestedAO( MDeletionHandler& aDeletionHandler );
-        void ConstructL();
-        
-        // inherited from CActive
-        virtual void RunL();
-        virtual void DoCancel();
-        // --------------------------------------------------------------------------
-        // CNestedAO::Stop
-        // Stops the scheduler from running
-        // Called after all messages are processed
-        // or in error condition
-        // ------------           
-        void Stop();
-        
-    private:
-        CActiveSchedulerWait* iNestedWait;
-        MDeletionHandler& iDeletionHandler;
-        TInt iDeletionIndex;
-        TInt iRc;
-    };
-
-
-#endif  //__NESTED_AO_H__
--- a/emailservices/emailstore/base_plugin/src/BaseMrInfoObject.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/BaseMrInfoObject.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -83,11 +83,10 @@
     iSequenceNumber = aMrInfo.MRSequenceNumberL();
     iPriority = aMrInfo.PriorityL();
 
-    iOrganizer = CBaseMrAttendee::NewL();
+    iOrganizer = CBaseMrAttendee::NewL( aMrInfo.MROrganizerL() );
 //<qmail> Commented out in 10.1
-    /*iOrganizer = CBaseMrAttendee::NewL( aMrInfo.MROrganizerL() );
     
-    RPointerArray<MMRAttendee>& attendees = aMrInfo.AttendeesL();
+    /*RPointerArray<MMRAttendee>& attendees = aMrInfo.AttendeesL();
     TInt count = attendees.Count();
     for ( TInt i = 0; i < count; i++ )
         {
@@ -96,6 +95,7 @@
         iAttendees.AppendL( attendee );
         CleanupStack::Pop( attendee );
         }*/
+
 //</qmail>
     
     iRrule = CBaseMrRecurrenceRule::NewL( aMrInfo.RecurrenceRuleL() );
--- a/emailservices/emailstore/base_plugin/src/BasePlugin.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/BasePlugin.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -130,12 +130,12 @@
 
     iReqs.ResetAndDestroy();
     iReqs.Close();
-
+//<qmail>
     // Note that all the ops in iDelayedOpReqs array (if any) have already been
     // deleted in the destructor of CDelayedOpsManager class.
     iDelayedOpReqs.Reset();
     iDelayedOpReqs.Close();
-
+//</qmail>
     ResetCache();
 
     __LOG_DESTRUCT
@@ -1253,6 +1253,15 @@
     CleanupStack::PopAndDestroy( &folders );
     }
 
+/**
+ * This methoed must be called before destruction of 
+ * CBasePlugin derived class. To fix bug EIZU-7XVF2Z.
+ */
+void CBasePlugin::DeleteDelayedOpsManager()
+    {
+    delete iDelayedOpsManager;
+    iDelayedOpsManager = NULL;
+    }
 
 /**
  *
--- a/emailservices/emailstore/base_plugin/src/MailIterator.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/MailIterator.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -134,7 +134,7 @@
         
         iPlugin.TranslateMsgStorePropsL( iMailBox, *msMsgs[i], *fsMsg );
 
-        aMessages.Append( fsMsg );
+        aMessages.AppendL( fsMsg );
         CleanupStack::Pop( fsMsg );
         }
 
@@ -184,7 +184,7 @@
 
         iPlugin.TranslateMsgStorePropsL( iMailBox, *msMsgs[i], *fsMsg );
 
-        aMessages.Append( fsMsg );
+        aMessages.AppendL( fsMsg );
         CleanupStack::Pop( fsMsg );
         }
 
--- a/emailservices/emailstore/base_plugin/src/baseplugindelayedops.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/baseplugindelayedops.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -23,7 +23,6 @@
 
 #include "baseplugindelayedops.h"
 #include "baseplugindelayedopsprivate.h"
-#include "nestedao.h"
 
 ///////////////////////////////////////////////////
 // CDelayedOp                                    //
@@ -51,9 +50,17 @@
 /**
  * 
  */
+/*public*/  void CDelayedOp::StartOp()
+    {
+    iStatus = KRequestPending;
+    SetActive();
+    TRequestStatus* pStatus = &iStatus;
+    User::RequestComplete( pStatus, KErrNone );
+    } 
 /*protected*/  CDelayedOp::CDelayedOp()
-    : CAsyncOneShot( CActive::EPriorityIdle )
+    : CActive( CActive::EPriorityIdle )
     {    
+    CActiveScheduler::Add( this );
     }
     
 /**
@@ -62,7 +69,9 @@
 /*private virtual*/  void CDelayedOp::RunL()
     {
     __LOG_ENTER_SUPPRESS( "Run" );
-    TRAPD( err, ExecuteOpL() );
+    TBool again( EFalse );
+    
+    TRAPD( err, again = ExecuteOpL() );
     
     if ( KErrNone != err )
         {
@@ -70,19 +79,27 @@
             "Error while executing delayed operation: %d.", err );
         }
     
-    //self-destroy.
-    iManager->DequeueOp( *this );
-    
-    //Remove this from iDelayedOpReqs as well.
-    for ( TInt i = 0; i < iPlugin->iDelayedOpReqs.Count(); i++ )
+    if ( again )
+        {
+        StartOp();
+        }
+    else
         {
-        if ( iPlugin->iDelayedOpReqs[i] == this )
-            {
-            iPlugin->iDelayedOpReqs.Remove( i );
-            break;
-            }
+        //self-destroy.
+        iManager->DequeueOp( *this );
+//<qmail>		
+		    //Remove this from iDelayedOpReqs as well.
+	    for ( TInt i = 0; i < iPlugin->iDelayedOpReqs.Count(); i++ )
+	        {
+	        if ( iPlugin->iDelayedOpReqs[i] == this )
+	            {
+	            iPlugin->iDelayedOpReqs.Remove( i );
+	            break;
+	            }
+	        }
+//</qmail>			
+        delete this;
         }
-    delete this;
     }
     
 /**
@@ -138,7 +155,7 @@
     {
     iDelayedOps.AppendL( aOp );
     aOp->SetContext( iPlugin, *this );        
-    aOp->Call();
+    aOp->StartOp();
     }
     
 /**
@@ -246,94 +263,6 @@
 /**
  * 
  */
-/*public virtual*/TBool CDelayedDeleteMessagesOp::DeleteMessagesInChunksL( TInt aStartIndex )
-    {
-    __LOG_ENTER( "DeleteMessagesInChunksL" );
-    TBool done=EFalse;
-    TInt endIndex;
-//<qmail>
-    TInt result(KErrNone);
-    if( aStartIndex + KSizeOfChunk < iMessages.Count() )
-        {
-            endIndex = aStartIndex + KSizeOfChunk;
-        }
-    else
-        {
-        endIndex = iMessages.Count();   
-        done=ETrue;
-        }
-    CMailboxInfo& mailBoxInfo
-        = GetPlugin().GetMailboxInfoL( iMailBoxId );
-    CMsgStoreMailBox& mailBox = mailBoxInfo();
-
-    for ( TInt i = aStartIndex; i < endIndex; ++i )
-        {
-        TMsgStoreId msgId = iMessages[i];
-        
-        if ( EFalse == iImmediateDelete )
-            {
-            //try to find the message
-            CMsgStoreMessage* theMessage = NULL;
-            theMessage = mailBox.FetchMessageL(
-                                      msgId, KMsgStoreInvalidId ) ;
-            //save parentId
-            TMsgStoreId msgParentId;
-            msgParentId =theMessage->ParentId();
-            //check if message is in deleted folder or not.
-            if ( msgParentId != mailBoxInfo.iRootFolders.iFolders[EFSDeleted] )
-                {
-            	//if not in deleted items then move it there.
-                __LOG_WRITE8_FORMAT1_INFO("Moving message 0x%X to the deleted items.", msgId );
-                TRAP(result,mailBox.MoveMessageL(
-                   msgId, KMsgStoreInvalidId,
-                   mailBoxInfo.iRootFolders.iFolders[EFSDeleted] ));
-                if(result == KErrNone)
-                    {
-                    GetPlugin().NotifyEventL( iMailBoxId, msgId, KMsgStoreInvalidId , TFSEventMailMoved, msgParentId);
-                    }
-                else
-                    {
-                    User::Leave(result);
-                    }
-                
-                }
-            else
-                {
-                //in deleted items, really delete it.
-                __LOG_WRITE8_FORMAT1_INFO( "Deleting message 0x%X.", msgId );
-
-                delete theMessage;
-                TRAP(result,mailBox.DeleteMessageL( msgId, iFolderId ));
-                if(result == KErrNone)
-                    {
-                    GetPlugin().NotifyEventL( iMailBoxId, msgId, KMsgStoreInvalidId, TFSEventMailDeleted, iFolderId );
-                    }
-                else
-                    {
-                    User::Leave(result);
-                    }
-                }
-            }
-        else
-            {        
-            TRAP(result,mailBox.DeleteMessageL( msgId, iFolderId ));
-            if(result == KErrNone)
-                {  
-                GetPlugin().NotifyEventL( iMailBoxId, msgId, KMsgStoreInvalidId, TFSEventMailDeleted, iFolderId );
-                }
-            else
-                {
-                User::Leave(result);
-                }
-            }
-//</qmail>
-        }
-    __LOG_EXIT;
-    return done;    
-    }
-/**
- * 
- */
 /*private*/
 void CDelayedDeleteMessagesOp::ConstructL(
     const RArray<TFSMailMsgId>& aMessages )
@@ -366,33 +295,104 @@
     TMsgStoreId aMailBoxId,
     TMsgStoreId aFolderId )
     :
-    iMailBoxId( aMailBoxId ), iFolderId( aFolderId ),
-    iImmediateDelete( EFalse ), iState ( EFree )
+    iMailBoxId( aMailBoxId ), iFolderId( aFolderId )
     {
     }
 
 /**
  * 
  */
-/*private*/ void CDelayedDeleteMessagesOp::ExecuteOpL()
+/*private*/ TBool CDelayedDeleteMessagesOp::ExecuteOpL()
     {
     __LOG_ENTER( "ExecuteOpL" );
-    if ( iState != EFree )
+
+    //Maximum number of messages deleted in one go
+    const TInt KNumOfDeletesBeforeYield = 30;
+
+    //<qmail>
+    TInt result(KErrNone);
+
+    TBool runAgain = ETrue;
+    TInt endIndex = iIndex + KNumOfDeletesBeforeYield;
+
+    if (endIndex >= iMessages.Count())
         {
-        //this code becomes re-entrant now because we use nested AS.
-        // so if we are already authenticating, return right away.
-        return;
+        endIndex = iMessages.Count();
+        runAgain = EFalse; // last time, no need to run again.
         }
-    iState=EInProgress;
-    CNestedAO* nestedAO = CNestedAO::NewL( *this );
-    //this is a blocking call with nested active scheduler
-    //This method makes a callback periodically to DeleteMessagesInChunks
-    //to delete the messages one chunk at a time
-    nestedAO->DeleteMessagesAsync();
-    //continue execution here
-    delete nestedAO;
-    iState = EFree;
-    __LOG_EXIT;
+
+    CMailboxInfo& mailBoxInfo = GetPlugin().GetMailboxInfoL(iMailBoxId);
+    CMsgStoreMailBox& mailBox = mailBoxInfo();
+
+    for (; iIndex < endIndex; iIndex++)
+        {
+        TMsgStoreId msgId = iMessages[iIndex];
+
+        if (EFalse == iImmediateDelete)
+            {
+            //try to find the message
+            CMsgStoreMessage* theMessage = NULL;
+            theMessage = mailBox.FetchMessageL(msgId, KMsgStoreInvalidId);
+            //save parentId
+            TMsgStoreId msgParentId;
+            msgParentId = theMessage->ParentId();
+            //check if message is in deleted or drafts folder or not.
+            if (msgParentId != mailBoxInfo.iRootFolders.iFolders[EFSDeleted] &&
+                msgParentId != mailBoxInfo.iRootFolders.iFolders[EFSDraftsFolder])
+                {
+                //if not in deleted items then move it there.
+                __LOG_WRITE8_FORMAT1_INFO("Moving message 0x%X to the deleted items.", msgId );
+                TRAP(result,mailBox.MoveMessageL(
+                                msgId, KMsgStoreInvalidId,
+                                mailBoxInfo.iRootFolders.iFolders[EFSDeleted] ));
+                if (result == KErrNone)
+                    {
+                    GetPlugin().NotifyEventL(iMailBoxId, msgId,
+                            KMsgStoreInvalidId, TFSEventMailMoved,
+                            msgParentId);
+                    }
+                else
+                    {
+                    User::Leave(result);
+                    }
+
+                }
+            else
+                {
+                //in deleted items, really delete it.
+                __LOG_WRITE8_FORMAT1_INFO( "Deleting message 0x%X.", msgId );
+
+                delete theMessage;
+                TRAP(result,mailBox.DeleteMessageL( msgId, iFolderId ));
+                if (result == KErrNone)
+                    {
+                    GetPlugin().NotifyEventL(iMailBoxId, msgId,
+                            KMsgStoreInvalidId, TFSEventMailDeleted,
+                            iFolderId);
+                    }
+                else
+                    {
+                    User::Leave(result);
+                    }
+                }
+            }
+        else
+            {
+            TRAP(result,mailBox.DeleteMessageL( msgId, iFolderId ));
+            if (result == KErrNone)
+                {
+                GetPlugin().NotifyEventL(iMailBoxId, msgId,
+                        KMsgStoreInvalidId, TFSEventMailDeleted, iFolderId);
+                }
+            else
+                {
+                User::Leave(result);
+                }
+            }
+        //</qmail>
+        } 
+		__LOG_EXIT;
+    return runAgain;
     }
 
 
@@ -465,7 +465,7 @@
 /**
  * CDelayedOp::ExecuteOpL
  */
-/*public virtual*/ void CDelayedSetContentOp::ExecuteOpL()
+/*public virtual*/ TBool CDelayedSetContentOp::ExecuteOpL()
     {
     __LOG_ENTER( "ExecuteOpL" )
 
@@ -494,6 +494,7 @@
     
     CleanupStack::PopAndDestroy( part );    
     __LOG_EXIT
+    return EFalse;
     }
 
 /**
@@ -657,7 +658,7 @@
 /**
  * 
  */
-/*private*/ void CDelayedMessageStorerOp::ExecuteOpL()
+/*private*/ TBool CDelayedMessageStorerOp::ExecuteOpL()
     {
     __LOG_ENTER( "ExecuteOpL" );
    
@@ -726,6 +727,7 @@
     
     
     __LOG_EXIT;
+	return EFalse;
     }
 
 
@@ -828,7 +830,7 @@
 /**
  * 
  */
-/*private*/ void CDelayedMessageToSendOp::ExecuteOpL()
+/*private*/ TBool CDelayedMessageToSendOp::ExecuteOpL()
     {
     __LOG_ENTER( "ExecuteOpL" );
    
@@ -850,6 +852,7 @@
 			}
     
     __LOG_EXIT;
+	return EFalse;
     }
 
 
@@ -969,7 +972,7 @@
 /**
  * 
  */
-/*private*/ void CDelayedAddNewOrRemoveChildPartOp::ExecuteOpL()
+/*private*/ TBool CDelayedAddNewOrRemoveChildPartOp::ExecuteOpL()
     {
     __LOG_ENTER( "ExecuteOpL" );
     
@@ -1010,5 +1013,6 @@
 			}
     
     __LOG_EXIT;
+    return EFalse;
     }
 //</qmail>
--- a/emailservices/emailstore/base_plugin/src/basepluginmisc.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/basepluginmisc.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -384,6 +384,7 @@
     		break;
     		}
     	}
+//<qmail>		
     count = iDelayedOpReqs.Count();
     for ( TInt i = 0; i < count; i++ )
         {
@@ -401,6 +402,7 @@
             break;
             }
         }
+//</qmail>		
     }
 
 
--- a/emailservices/emailstore/base_plugin/src/baseplugintranslator.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/baseplugintranslator.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -613,7 +613,7 @@
         if ( aCalendar.FindProperty( KMsgStorePropertyMrMonthDay, idx ) )
             {
             TUint32 monthDayNo = aCalendar.PropertyValueUint32L( idx );
-            days.Append(monthDayNo);
+            days.AppendL(monthDayNo);
             /**@ double check that when testing starts.*/
             }
             
--- a/emailservices/emailstore/base_plugin/src/nestedao.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
-* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Implementation of a nested active object used to handle deletion
-*                of large number of messages by breaking them into smaller chunks
-*
-*/
-
-//  Include Files
-//
-
-
-#include "nestedao.h"
-#include "baseplugindelayedops.h"
-#include "baseplugindelayedopsprivate.h"
-
-//Class CNestedAO
-
-// --------------------------------------------------------------------------
-//  CNestedAO::NewL
-// ------------ 
-CNestedAO* CNestedAO::NewL( MDeletionHandler& aDeletionHandler )
-    {
-    CNestedAO* self = new(ELeave) CNestedAO( aDeletionHandler );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-// --------------------------------------------------------------------------
-//  CNestedAO::CNestedAO
-// ------------ 
-CNestedAO::CNestedAO( MDeletionHandler& aDeletionHandler ) 
- : CTimer( EPriorityIdle ), iDeletionHandler( aDeletionHandler ), iRc( KErrNone )
-    {
-    }
-// --------------------------------------------------------------------------
-//  CNestedAO::ConstructL()
-// ------------ 
-void CNestedAO::ConstructL()
-    {
-    CTimer::ConstructL();
-    iNestedWait = new( ELeave ) CActiveSchedulerWait();
-    CActiveScheduler::Add( this );
-    }
-// --------------------------------------------------------------------------
-//  CNestedAO::~CNestedAO
-// ------------ 
-CNestedAO::~CNestedAO()
-    {
-    Cancel();
-    delete iNestedWait;
-    }
-// --------------------------------------------------------------------------
-// CNestedAO::DeleteMessagesAsync
-// Used to delete messages asynchronously 
-// Deleting a small number of messages at a time
-// ------------
-void CNestedAO::DeleteMessagesAsync()
-    {
-    iDeletionIndex = 0;
-    After( KWaitIntervalInMicroSecs );  //to invoke RunL after 100 microseconds
-    iNestedWait->Start(); 
-    }
-// --------------------------------------------------------------------------
-//  CNestedAO::DoCancel
-// ------------ 
-void CNestedAO::DoCancel()
-    {
-    iRc = KErrCancel;
-    Stop();
-    }
-// --------------------------------------------------------------------------
-//  CNestedAO::RunL
-// ------------    
-void CNestedAO::RunL()
-    {
-    iRc = iStatus.Int();
-    if ( iStatus.Int() == KErrNone )
-        {
-        TBool done = iDeletionHandler.DeleteMessagesInChunksL( iDeletionIndex );
-        if( !done )
-        	{
-        	//Increment deletionidex
-        	iDeletionIndex+=KSizeOfChunk;
-        	After( KWaitIntervalInMicroSecs ); 
-        	}
-        else
-        	{
-        	Stop();
-        	}
-		}
-    else
-        {
-        Stop();
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CNestedAO::Stop
-// Stops the scheduler from running
-// Called after all messages are processed
-// or in error condition
-// ------------    
-void CNestedAO::Stop()
-    {
-    if( iNestedWait->IsStarted() )
-        {
-        // Stop the nested active scheduler (flow-of-control will pick up immediately following the
-        // call to iWait.Start().
-        iNestedWait->AsyncStop();
-        } // end if
-    }
--- a/emailservices/emailstore/message_store/client/src/MsgStore.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/client/src/MsgStore.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -282,7 +282,7 @@
     for ( TInt i = 0 ; i < accounts.Count() && defaultMailboxId == KMsgStoreInvalidId ; i++ )
         {
         CMsgStoreMailBox* mb = OpenAccountL( *accounts[i] );
-        mailBoxes.Append( mb );
+        mailBoxes.AppendL( mb );
         if ( mb->IsDefaultMailbox() )
             {
             defaultMailboxId = mb->Id();
--- a/emailservices/emailstore/message_store/client/src/MsgStoreMessagePart.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/client/src/MsgStoreMessagePart.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -269,7 +269,7 @@
 							{
 							//body is not the first child, move it to the first place
 							aParts.Remove(i);
-							aParts.Insert( part, 0 );
+							aParts.InsertL( part, 0 );
 							}
 						break;
 					}
--- a/emailservices/emailstore/message_store/client/src/RMessageStoreSession.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/client/src/RMessageStoreSession.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -442,7 +442,7 @@
 	for ( int i = 0 ; i < count ; i++ )
 		{
 		CMsgStoreAccount* account = CMsgStoreAccount::NewL( ownerIds[i], *(names[i]) );
-		aAccounts.Append( account );
+		aAccounts.AppendL( account );
 		}
 	CleanupStack::PopAndDestroy( serializer );
 	CleanupStack::PopAndDestroy( &resultBuf );
@@ -525,7 +525,7 @@
         User::LeaveIfError( fs.Connect() );
         fs.ShareProtected();        
         
-        User::LeaveIfError( file.Open( fs, aContentFilename, EFileRead | EFileShareAny ) );
+        User::LeaveIfError( file.Open( fs, aContentFilename, EFileShareReadersOnly ) );
         User::LeaveIfError( file.TransferToServer( ipcArgs, KIpcArgsIndex2, KIpcArgsIndex3 ) );	    	    
 	    } // end if
 
@@ -776,7 +776,7 @@
 	const TUint KDivider = 4;
 	for( TInt count = 0; count < childrenBuf.Length() / KDivider; count++ )
 		{
-		aChildrenIds.Append( readStream.ReadUint32L() );
+		aChildrenIds.AppendL( readStream.ReadUint32L() );
 		} // end for
 		
 	CleanupStack::PopAndDestroy( &readStream );
@@ -1287,7 +1287,7 @@
             countPckg.Copy( pointer, countPckg.Length() );
             pointer += countPckg.Length();
             
-            aItemsInGroup.Append( count );        
+            aItemsInGroup.AppendL( count );        
             }
         }
     
@@ -1332,7 +1332,7 @@
             flagPckg.Copy( pointer, flagPckg.Length() );
             pointer += flagPckg.Length();
             
-            aIdsAndFlags.Append( TMsgStoreIdAndFlag( id, flag ) );        
+            aIdsAndFlags.AppendL( TMsgStoreIdAndFlag( id, flag ) );        
             }
         }
     
@@ -1387,7 +1387,7 @@
             idPckg.Copy( pointer, idPckg.Length() );
             pointer += idPckg.Length();
             
-            aMessageIds.Append( id );        
+            aMessageIds.AppendL( id );        
             }
         }
     
@@ -1425,7 +1425,7 @@
         idPckg.Copy( pointer, idPckg.Length() );
         pointer += idPckg.Length();
         
-        aMessageIds.Append( id );
+        aMessageIds.AppendL( id );
         --idCount;
         }
     
@@ -1437,7 +1437,7 @@
         countPckg.Copy( pointer, countPckg.Length() );
         pointer += countPckg.Length();
         
-        aItemsInGroup.Append( count ); 
+        aItemsInGroup.AppendL( count ); 
         --groupCount;
         }
     
@@ -1710,7 +1710,7 @@
     
         //create the address object and add it to the output array
         CMsgStoreAddress *address = CMsgStoreAddress::NewL( addrDes16, nameDes16 );
-        aAddressArray.Append( address );            
+        aAddressArray.AppendL( address );            
         } // end while          
     
     CleanupStack::PopAndDestroy( &serializedBuf );
--- a/emailservices/emailstore/message_store/common/src/AccountsSerializer.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/common/src/AccountsSerializer.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -46,8 +46,8 @@
 void CAccountsSerializer::AddAccountL( TInt32 aOwnerId, const TDesC& aName )
 	{
 	HBufC* nameCopy = aName.AllocL();
-	iNameBufArray.Append( nameCopy );
-	iOwnerIdArray.Append( aOwnerId );
+	iNameBufArray.AppendL( nameCopy );
+	iOwnerIdArray.AppendL( aOwnerId );
 	iCount++;
 	}
         
--- a/emailservices/emailstore/message_store/debuglog/src/DebugLog.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/debuglog/src/DebugLog.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -1162,7 +1162,7 @@
     CLogFileHandler* handler = NULL;
     
     // Look for the log file handler for the given directory.
-    TInt  index = 0;
+    TInt index = 0;
     while( index < iFiles.Count() && ( !handler ) )
         {
         CLogFileHandler* currentHandler = iFiles[index];
@@ -1182,7 +1182,7 @@
 
         if( handler )
             {            
-            iFiles.Append( handler );
+            iFiles.AppendL( handler );
             } // end if
         }
     
@@ -1194,11 +1194,11 @@
 		if ( copyOfName )
 		    {       
             copyOfName->Des().Copy( aObject->ClassName8() );
-            handler->iObjectNames.Append( copyOfName );
+            handler->iObjectNames.AppendL( copyOfName );
 			}
 //#endif        
 
-        handler->iObjects.Append( aObject );
+        handler->iObjects.AppendL( aObject );
 	    } // end if
 	    
 	return handler;       
@@ -1212,7 +1212,7 @@
 // ==========================================================================
 void CDebugLogTlsData::DoReleaseLogFileHandler( CLogFileHandler* aHandler, RDebugLog* aObject )
     {
-    TInt index = aHandler->iObjects.Find( aObject );
+    TInt index = aHandler->iObjects.FindL( aObject );
     
     if( index >= 0 )
         {
@@ -1224,9 +1224,8 @@
         
         if( aHandler->iObjects.Count() == 0 )
             {
+            iFiles.Remove( iFiles.Find(aHandler) );
             delete aHandler;
-            
-            iFiles.Remove( iFiles.Find(aHandler) );                        
             } // end if
         }
     else
--- a/emailservices/emailstore/message_store/server/inc/ContainerStore.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/inc/ContainerStore.h	Wed Aug 18 09:37:47 2010 +0300
@@ -428,6 +428,7 @@
         void CommitDatabaseTransactionL();
         
         const TDesC& PrivatePath();
+        TBool DeleteFromSortingTable();
         
 #ifdef _DEBUG                      
         
--- a/emailservices/emailstore/message_store/server/inc/ContainerStoreContainersTable.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/inc/ContainerStoreContainersTable.h	Wed Aug 18 09:37:47 2010 +0300
@@ -157,6 +157,8 @@
         
         TBool IsEncrypted();
         
+        TContainerId FirstChildForDeleteL( TContainerId aId, TDbBookmark& aBookmark );
+        
 	private:
 	
 	    // ===============
@@ -189,7 +191,7 @@
         void WriteUnencryptedPropertiesColumnL( const TDesC8& aProperties );
         
         void SetEncryptedL( TBool aIsEncrypted );
-
+        TContainerId GetFirstChildForDeleteL( TContainerId aId, TDbBookmark& aBookmark );
 	    // ==================
 	    // PRIVATE ATTRIBUTES
 	    // ==================
--- a/emailservices/emailstore/message_store/server/inc/ContainerStoreDefs.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/inc/ContainerStoreDefs.h	Wed Aug 18 09:37:47 2010 +0300
@@ -65,6 +65,7 @@
 _LIT( KContainersTableCountsCol,		  "C008" );
 _LIT( KContainersTableIsRowEncryptedCol,  "C009" );
 _LIT( KContainersTableIdIndex,            "C00A" );
+_LIT( KContainersTableParentIdIndex,      "C00B" );
 
 // Sorting table
 _LIT( KSortingTableName,                  "D001" );
@@ -113,6 +114,10 @@
 _LIT( KMruAddressTableMruNumIndex,        "F007" );
 _LIT( KMruAddressTableMailboxIdIndex,     "F008" );
 
+_LIT(KMarkedForDeleteTableName,                 "H001");
+_LIT(KMarkedForDeleteTableIDCol,                "H002");
+
+
 
 /** Defines the states of encryption/decryption operation 
  *  This state needs to be persisted in the db, so that if
--- a/emailservices/emailstore/message_store/server/inc/ContainerStoreDeleteHandler.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/inc/ContainerStoreDeleteHandler.h	Wed Aug 18 09:37:47 2010 +0300
@@ -46,7 +46,8 @@
         enum TState
             {
             ERetryDelete,
-            EDelete
+            EDelete,
+            EDeleteFromSortingTable
             };
         // ==============
         // PUBLIC METHODS
--- a/emailservices/emailstore/message_store/server/inc/ContainerStoreSortingTable.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/inc/ContainerStoreSortingTable.h	Wed Aug 18 09:37:47 2010 +0300
@@ -113,6 +113,7 @@
         
         TBool DecryptFirstL( TDbBookmark& aNextRow );
         TBool DecryptNextL( TDbBookmark& aNextRow );
+        TBool DeleteNextContainerMarkedForDeletionL();
         
 	private:
 
@@ -159,8 +160,11 @@
         
         TBool IsEncrypted( RDbRowSet& aRowSet );
         void SetEncryptedL( TBool aIsEncrypted );
-        
-
+        void CreateMarkedForDeletionTableL();
+        void CreateOrOpenMarkedForDeletionTableL();
+        void MarkIdForDeletionL( TContainerId aId);
+        TBool DeleteNextMessageL( TContainerId aId );
+        TBool DeleteFromMarkedForDeletionTableL();
     private:
     
         // ==================
@@ -186,7 +190,8 @@
         TInt                  iIsEncryptedColNum;
         
         TUint                 iFieldsChanged;
-	    
+        RDbTable              iMarkedForDeleteTable;
+        TInt                  iMarkedForDeleteIdColNum;
 	    __LOG_DECLARATION
     		
 	}; // end class CContainerStoreSortingTable
--- a/emailservices/emailstore/message_store/server/inc/MessageStoreServer.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/inc/MessageStoreServer.h	Wed Aug 18 09:37:47 2010 +0300
@@ -125,7 +125,7 @@
 
         static CMessageStoreServer* NewLC();
 
-        void AddSession( CMessageStoreSession* aSession );
+        void AddSessionL( CMessageStoreSession* aSession );
 
         void DropSession( CMessageStoreSession* aSession );
 
--- a/emailservices/emailstore/message_store/server/src/ContainerStore.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/ContainerStore.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -1735,15 +1735,10 @@
 // ==========================================================================
 void CContainerStore::FirstChildL( TContainerId aId, TContainerId& aFirstChildId, TDbBookmark& aBookmark )
     {
-    aFirstChildId = FirstChildL( aId );
-    
-    if( aFirstChildId != KContainerInvalidId )
-        {
-        aBookmark = iContainersTable->Bookmark();
-        } // end if
-        
-     } // end FirstChildL
-		
+    //Used to by the deletehandler to traverse the table for the lowest level child
+    aFirstChildId = iContainersTable->FirstChildForDeleteL( aId, aBookmark );       
+    } 
+
 // ==========================================================================
 // FUNCTION: SearchL
 // ==========================================================================
@@ -1773,6 +1768,7 @@
 
 // ==========================================================================
 // FUNCTION: StartSortingL
+// Will leave with KErrNotFound if the container is marked for deletion.
 // ==========================================================================
 TContainerId CContainerStore::StartSortingL( TMsgStoreSortCriteria& aSortCriteria, 
                                              RPointerArray<HBufC8>& aPropertyNames,
@@ -1781,6 +1777,13 @@
     __LOG_ENTER_SUPPRESS( "StartSortingL" )
     __LOG_WRITE_FORMAT4_INFO( "folder=%x sortField=%d order=%d, aInMemorySort=%d", aSortCriteria.iFolderId, aSortCriteria.iSortBy, aSortCriteria.iSortOrder, aInMemorySort )
 
+    //Seek to make sure the container is not markd for deletion, if the container is marked for deletion
+    //this will leave with KerrNotFound
+    TRAPD(err, iContainersTable->SeekL( aSortCriteria.iFolderId, iHierarchy )); 
+    if (err != KErrNone)
+        {
+        User::LeaveIfError(KErrNotFound);
+        }
     CMsgStoreSortResultRowSet* resultRowSet = iSortingTable->SortL( aSortCriteria, aInMemorySort );
     CleanupStack::PushL( resultRowSet );
     
@@ -1797,7 +1800,7 @@
     session.iSessionId = iNextSortSessionId++;
     session.iResultRowSet = resultRowSet ;
     
-    iSortSessions.Append( session );
+    iSortSessions.AppendL( session );
     
     CleanupStack::Pop( resultRowSet );
     
@@ -2488,6 +2491,15 @@
     iUtils->CommitDatabaseTransactionL();
     }
 
+/*
+ * Check to see there are mailboxes/folder IDs marked for deletion.
+ */
+TBool CContainerStore::DeleteFromSortingTable()
+    {
+    TBool moreToDelete = EFalse;
+    TRAP_IGNORE(moreToDelete = iSortingTable->DeleteNextContainerMarkedForDeletionL());
+    return moreToDelete;   
+    }
 /**
  * 
  */
--- a/emailservices/emailstore/message_store/server/src/ContainerStoreContainersTable.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/ContainerStoreContainersTable.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -297,9 +297,22 @@
     iIsRowEncryptedColNum  = colSet->ColNo( KContainersTableIsRowEncryptedCol );
 
 	CleanupStack::PopAndDestroy( colSet );
-	
-	// Set the table's index to the ID index.
-	User::LeaveIfError( iTable.SetIndex( KContainersTableIdIndex ) );
+
+    // make sure KContainersTableParentIdIndex exists
+    TInt err = iTable.SetIndex( KContainersTableParentIdIndex );
+    if ( err == KErrNotFound )
+        {
+        iUtils.CloseTable( iTable );
+        CreateIndexL( KContainersTableName, KContainersTableParentIdIndex, KContainersTableParentIdCol );
+        iUtils.OpenTableL( iTable, KContainersTableName );
+        }
+    else
+        {
+        User::LeaveIfError( err );
+        }
+
+    // Set the table's index to the ID index.
+    User::LeaveIfError( iTable.SetIndex( KContainersTableIdIndex ) );
 	
 	__LOG_EXIT
 	} // end OpenTableL
@@ -347,8 +360,9 @@
 	
 	// Create table index.
     CreateIndexL( KContainersTableName, KContainersTableIdIndex, KContainersTableIdCol );
-	
-	OpenTableL();
+    CreateIndexL( KContainersTableName, KContainersTableParentIdIndex, KContainersTableParentIdCol );
+
+    OpenTableL();
 	
 	__LOG_EXIT	
 	} // end CreateTableL
@@ -932,7 +946,9 @@
 	    queryString.AppendNum( toBeSearched[0] );    	    
         toBeSearched.Remove( 0 );
         
-        if ( aType == EMsgStorePartBits )
+        if ( aType == EMsgStorePartBits || 
+           ( ( aId & KContainerTypeMask ) == EMsgStoreMessageBits ) ||
+           ( ( aId & KContainerTypeMask ) == EMsgStorePartBits ) )
         	{
         	//must sort the message parts by containerId in ascending order
         	// to preserve the same order as they are created
@@ -1208,4 +1224,47 @@
     iTable.SetColL( iIsRowEncryptedColNum, static_cast<TUint8>(aIsEncrypted) );
     }
 
+/*
+ * Search based on the parent ID. This will set the index if one exists and use the find if the index does not
+ * exists which could happen for a existing DB(IAD case)
+ */
+TContainerId CContainerStoreContainersTable::FirstChildForDeleteL( TContainerId aId, TDbBookmark& aBookmark )
+    {
+    __LOG_ENTER( "FirstChildForDeleteL" )
+    __LOG_WRITE8_FORMAT1_INFO( "id=%x", aId )
 
+    TContainerId returnValue = KContainerInvalidId;
+    User::LeaveIfError( iTable.SetIndex( KContainersTableParentIdIndex ) );
+    TRAP_IGNORE( returnValue = GetFirstChildForDeleteL( aId, aBookmark ) );
+    //remember to set the index back
+    iTable.SetIndex( KContainersTableIdIndex );
+
+    __LOG_EXIT
+    return returnValue;   
+    }
+
+/*
+ * Search based on the parent ID. 
+ */
+TContainerId CContainerStoreContainersTable::GetFirstChildForDeleteL( TContainerId aId, TDbBookmark& aBookmark )
+    {
+    __LOG_ENTER( "FirstChildForDeleteL" )
+    __LOG_WRITE8_FORMAT1_INFO( "id=%x", aId )
+    
+    TContainerId returnValue = KContainerInvalidId;
+    //Index on parent id, so we can Seek, faster than Find
+    if ( !iTable.SeekL( aId ) )
+        {
+        __LOG_WRITE_INFO( "No match found" )
+        returnValue = KContainerInvalidId;
+        }
+    else
+        {
+        iTable.GetL();
+        returnValue = iTable.ColUint32( iIdColNum );
+        aBookmark = Bookmark();
+        __LOG_WRITE8_FORMAT1_INFO( "found id=%x", returnValue )
+        }
+    __LOG_EXIT
+    return returnValue;   
+    }
--- a/emailservices/emailstore/message_store/server/src/ContainerStoreDeleteHandler.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/ContainerStoreDeleteHandler.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -115,7 +115,7 @@
 // ==========================================================================
 void CDeleteHandler::FindContainerToDeleteL()
     {
-    TBool done = EFalse;
+    TBool done(EFalse);
     
     TContainerId containerId = KToBeDeletedContainers;
     if ( iState == ERetryDelete )
@@ -163,7 +163,7 @@
     // Delete the lowest node in the hierarchy.        
     TRAPD( result, FindContainerToDeleteL() );
 
-    TBool more = EFalse;    
+    TBool more ( EFalse );    
         
     if( result == KErrNone )
         {        
@@ -201,7 +201,18 @@
         {   
         if ( iState == ERetryDelete )
             {
-            iState = EDelete;
+            //next state
+            iState = EDeleteFromSortingTable;
+            more = ETrue;
+            }
+        else if(iState == EDeleteFromSortingTable)
+            {
+            //check sorting table for containers that have been marked for deletion
+            if(!iContainerStore.DeleteFromSortingTable())
+                {
+                //if nor more then set to next state
+                iState = EDelete;
+                }
             more = ETrue;
             }
         else
@@ -214,21 +225,3 @@
     return more;
     
     } // end DoNextDelete
-
-// ==========================================================================
-// FUNCTION: FinishDeletes
-// ==========================================================================
-void CDeleteHandler::FinishDeletes()
-    {
-    if( IsActive() )
-        {
-        Cancel();
-        
-        // Loop until all deletes are done.
-        while( DoNextDelete() )
-            {
-            }        
-        
-        } // end if
-    
-    } // end FinishDeletes
--- a/emailservices/emailstore/message_store/server/src/ContainerStoreMRUAddressTable.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/ContainerStoreMRUAddressTable.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -461,7 +461,7 @@
         }
     
     CMruAddressList* list = new(ELeave) CMruAddressList( aMailboxId );
-    iAddressLists.Append( list );
+    iAddressLists.AppendL( list );
     
     __LOG_EXIT
     }
@@ -619,7 +619,7 @@
         {
         TContainerId mailboxId = aMailboxIds[i];
         CMruAddressList* list = new(ELeave) CMruAddressList( mailboxId );
-        iAddressLists.Append( list );
+        iAddressLists.AppendL( list );
         
         const TUint bufSize = 100;
         TBuf<bufSize> sqlString;
--- a/emailservices/emailstore/message_store/server/src/ContainerStoreSearchHandler.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/ContainerStoreSearchHandler.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -274,13 +274,13 @@
     iFolderIds.Reset();
     for( TInt i = 0 ; i < aFolderIds.Count() ; i++ )
         {
-        iFolderIds.Append( aFolderIds[i] );
+        iFolderIds.AppendL( aFolderIds[i] );
         }
 
     iPropertyNames.ResetAndDestroy();
     for ( TInt i = 0 ; i < aPropertyNames.Count() ; i++ )
         {
-        iPropertyNames.Append( aPropertyNames[i] );
+        iPropertyNames.AppendL( aPropertyNames[i] );
         }
     aPropertyNames.Reset();
     
@@ -466,7 +466,7 @@
         __LOG_WRITE_FORMAT1_INFO( "search string =%S", &searchStringPtr );
         
         HBufC* pattern = HBufC::NewL( searchString->Length() + 2 );
-        aSearchPatterns.Append( pattern );
+        aSearchPatterns.AppendL( pattern );
         TPtr seartStringPrt( pattern->Des() );
         
         //we are using MatchC(), so we need to add * to the start and end of the search pattern
--- a/emailservices/emailstore/message_store/server/src/ContainerStoreSortingTable.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/ContainerStoreSortingTable.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -28,7 +28,6 @@
 #include "MsgStoreInMemorySortRowSet.h"
 	
 _LIT( KSelect,  "SELECT "   );
-_LIT( KDelete,  "DELETE "   );
 _LIT( KFrom,    " FROM "    );
 _LIT( KWhere,   " WHERE "   );
 _LIT( KEquals,  " = "       );
@@ -113,6 +112,7 @@
 CContainerStoreSortingTable::~CContainerStoreSortingTable()
 	{
 	iUtils.CloseTable( iTable );
+    iUtils.CloseTable (iMarkedForDeleteTable);
     iEncryptedBuffer.Close();
 	__LOG_DESTRUCT	
 	} // end destructor
@@ -148,7 +148,7 @@
 	
 	// Set the table's index to the ID index.
 	User::LeaveIfError( iTable.SetIndex( KSortingTableMessageIdIndex ) );
-
+	CreateOrOpenMarkedForDeletionTableL();
 	__LOG_EXIT	
 	}
 		
@@ -206,7 +206,6 @@
 	
 	CleanupStack::PopAndDestroy( colSet );
 	
-	// Create index for every column except for mailBoxId
 	CreateIndexL( KSortingTableName, KSortingTableMessageIdIndex,      KSortingTableMessageIdCol    );
 	CreateIndexL( KSortingTableName, KSortingTableFolderIdIndex,       KSortingTableFolderIdCol     );
     CreateIndexL( KSortingTableName, KSortingTableMailBoxIdIndex,      KSortingTableMailBoxIdCol    );
@@ -284,21 +283,9 @@
 void CContainerStoreSortingTable::DeleteMessagesByFolderIdL( TContainerId aFolderId )
 	{
 	__LOG_ENTER_SUPPRESS( "DeleteMessagesByFolderIdL" )
-	__LOG_WRITE8_FORMAT1_DEBUG3( "aFolderId=%x", aFolderId )
-	
-	TBuf<KQuerryBufSize> queryString;
-	queryString.Copy( KDelete );
-	queryString.Append( KFrom );
-	queryString.Append( KSortingTableName );
-	queryString.Append( KWhere );
-	queryString.Append( KSortingTableFolderIdCol );
-	queryString.Append( KEquals );
-	queryString.AppendNum( aFolderId );
-	
-	iUtils.Execute( queryString );
-    
-    //Notify the observer
-    iObserver.FolderDeleted( aFolderId );
+	__LOG_WRITE8_FORMAT1_DEBUG3( "aFolderId=%x", aFolderId )	
+	//Add the folder ID into the MarkedForDeleteTable to be processed in the background.
+	MarkIdForDeletionL(aFolderId);
 	}
 
 // ==========================================================================
@@ -308,20 +295,8 @@
     {
     __LOG_ENTER_SUPPRESS( "DeleteMessagesByMailBoxIdL" )
     __LOG_WRITE8_FORMAT1_DEBUG3( "aMailBoxId=%x", aMailBoxId )
-    
-    TBuf<KQuerryBufSize> queryString;
-    queryString.Copy( KDelete );
-    queryString.Append( KFrom );
-    queryString.Append( KSortingTableName );
-    queryString.Append( KWhere );
-    queryString.Append( KSortingTableMailBoxIdCol );
-    queryString.Append( KEquals );
-    queryString.AppendNum( aMailBoxId );
-    
-    iUtils.Execute( queryString );
-    
-    //Notify the observer
-    iObserver.MailBoxDeleted( aMailBoxId );
+     //Add the mailbox ID into the MarkedForDeleteTable to be processed in the background. 
+    MarkIdForDeletionL( aMailBoxId);   
     }
 
 // ==========================================================================
@@ -1245,3 +1220,142 @@
     iTable.SetColL( iIsEncryptedColNum, static_cast<TUint8>(aIsEncrypted) );
     }
 
+// ==========================================================================
+// FUNCTION: CreateMarkedForDeletionTableL
+// ==========================================================================
+void CContainerStoreSortingTable::CreateMarkedForDeletionTableL()
+    {
+    __LOG_ENTER( "CreateMarkedForDeletionTableL" )
+    
+    // Create table columns
+    CDbColSet* colSet = CDbColSet::NewLC();
+    TDbCol mailboxIdCol( KMarkedForDeleteTableIDCol, EDbColUint32 );
+    colSet->AddL( mailboxIdCol );      
+    // Create table.
+    iUtils.CreateTableL( KMarkedForDeleteTableName, *colSet );   
+    CleanupStack::PopAndDestroy( colSet );             
+    __LOG_EXIT
+    }
+
+// ==========================================================================
+// FUNCTION: CreateOrOpenMarkedForDeletionTableL
+// try to open the Table - create if not found (IAD case) and then open
+// ==========================================================================
+void CContainerStoreSortingTable::CreateOrOpenMarkedForDeletionTableL()
+    {
+    __LOG_ENTER( "OpenMarkedForDeletionTableL" )
+            
+    TRAPD(err, iUtils.OpenTableL( iMarkedForDeleteTable, KMarkedForDeleteTableName ));
+    if(err != KErrNone)
+        {
+        CreateMarkedForDeletionTableL();
+        iUtils.OpenTableL( iMarkedForDeleteTable, KMarkedForDeleteTableName );
+        }
+    CDbColSet* colSet = iMarkedForDeleteTable.ColSetL();
+    CleanupStack::PushL( colSet );
+    //Get the column number
+    iMarkedForDeleteIdColNum = colSet->ColNo( KMarkedForDeleteTableIDCol ); 
+    CleanupStack::PopAndDestroy( colSet );
+    __LOG_EXIT  
+    }
+
+// ==========================================================================
+// FUNCTION: MarkIdForDeletionL
+// Add the ID into the marked for DeletionTable.
+// ==========================================================================
+void CContainerStoreSortingTable::MarkIdForDeletionL( TContainerId aId)
+    {
+    __LOG_ENTER( "MarkIdForDeletionL" )
+    
+    __LOG_WRITE8_FORMAT1_DEBUG3( "Id=%x",aId )
+    iMarkedForDeleteTable.LastL();
+    iMarkedForDeleteTable.InsertL();   
+    iMarkedForDeleteTable.SetColL( iMarkedForDeleteIdColNum, aId );   
+    iMarkedForDeleteTable.PutL();
+    __LOG_EXIT 
+    }
+
+// ==========================================================================
+// FUNCTION: DeleteNextContainerMarkedForDeletionL
+// Use the ID in the MarkedForDeletionTable to delete items from the sorting table .
+// ==========================================================================
+TBool CContainerStoreSortingTable::DeleteNextContainerMarkedForDeletionL()
+    {
+    __LOG_ENTER( " DeleteNextContainerMarkedForDeletionL" )
+    TBool more = EFalse;
+    //set the index to mailboxID to help with seek
+    // Set the table's index to the ID index.
+    if(!iMarkedForDeleteTable.IsEmptyL())
+        {
+        iMarkedForDeleteTable.FirstL();
+        iMarkedForDeleteTable.GetL();
+        TInt deletionID =  iMarkedForDeleteTable.ColUint32(iMarkedForDeleteIdColNum);
+        //check if the ID refers to a folder or is a mailbox and set the index for the table accordingly.
+        if ( ( deletionID & EMsgStoreContainerMask ) == EMsgStoreMailBoxBits)
+            {
+            iTable.SetIndex( KSortingTableMailBoxIdIndex );
+            }
+        else if ( ( deletionID & EMsgStoreContainerMask ) == EMsgStoreFolderBits)
+            {
+            iTable.SetIndex( KSortingTableFolderIdIndex );
+            }
+        //Delete next message from the mailbox/folder
+        TRAPD(err, more = DeleteNextMessageL(deletionID));
+        if (err == KErrNone)
+            {
+            if (!more)
+                {
+                TRAP_IGNORE(more = DeleteFromMarkedForDeletionTableL());
+                }
+            }
+        //reset to the original index 
+        iTable.SetIndex( KSortingTableMessageIdIndex );
+        }
+    __LOG_EXIT
+    return more;
+    }
+
+// ==========================================================================
+// FUNCTION: DeleteNextContainerMarkedForDeletionL
+// Use the ID in the MarkedForDeletionTable to delete items from the sorting table .
+// ==========================================================================
+TBool CContainerStoreSortingTable::DeleteFromMarkedForDeletionTableL()
+    {
+    __LOG_ENTER( " DeleteFromMarkedForDeletionTableL" )
+    TBool more(EFalse);
+    // removed the row once all the messages for that ID have been deleted.
+    iMarkedForDeleteTable.DeleteL();
+    //check if there is another entry
+    if(iMarkedForDeleteTable.NextL())
+        {
+        more = ETrue;
+        }
+    __LOG_EXIT
+    return more;
+    }
+
+// ==========================================================================
+// FUNCTION: DeleteNextMessageL
+// Deletes one row where ID = aId. 
+// @ return Etrue if seek successful
+//          EFalse if seek failed which mean no more messages for the 
+//          given container ID
+// ==========================================================================
+TBool CContainerStoreSortingTable::DeleteNextMessageL( TContainerId aId )
+    {
+    __LOG_ENTER( "DeleteNextMessageL" )
+    __LOG_WRITE8_FORMAT1_DEBUG3( "aId=%x", aId )
+       
+    //Find first matching row
+    TRAPD(err, SeekL( aId ));
+    TBool more(EFalse);
+    if (err ==KErrNone)
+        {
+        iTable.GetL();   
+        iTable.DeleteL();
+        more =  ETrue;
+        }
+    __LOG_EXIT
+    return more;
+    }
+
--- a/emailservices/emailstore/message_store/server/src/MessageStoreServer.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/MessageStoreServer.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -369,10 +369,10 @@
 // A new session is being created
 // Cancel the shutdown timer if it was running
 // ==========================================================================
-void CMessageStoreServer::AddSession( CMessageStoreSession* aSession )
+void CMessageStoreServer::AddSessionL( CMessageStoreSession* aSession )
     {
     __LOG_ENTER( "AddSession" )
-    iSessions.Append( aSession );
+    iSessions.AppendL( aSession );
 
     // notify new session of current state
     TMsgStoreEvent event;
--- a/emailservices/emailstore/message_store/server/src/MessageStoreSession.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/MessageStoreSession.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -112,10 +112,16 @@
     {
     __LOG_ENTER( "CreateL" )
     
-    iServer.AddSession( this );
+    iServer.AddSessionL( this );
 
     // This could leave if a session is created while the store is unavailable.
-    TRAP_IGNORE( iServer.MessageStoreL().ObserveL( this ) );
+    TRAPD( err, iServer.MessageStoreL().ObserveL( this ) );
+    
+    if( err != KErrNone )
+    {
+        iServer.DropSession( this );
+        User::Leave( err );
+    }
     
     __LOG_EXIT
     } // end CreateL
@@ -694,12 +700,16 @@
         	event.iOtherId     = KMsgStoreInvalidId;
         	event.iFlags       = KMsgStoreFlagsNotFound;
 
-    		iEventQueue.Append( event );		
+        	// return value can be ignored because queueing is very rare
+        	// case anyway and appending T-class into RArray should succeed
+    		TInt ignore = iEventQueue.Append( event );
 		    }
 		else
 		    {
     		__LOG_WRITE_INFO( "event queued" )
-    		iEventQueue.Append( aEvent );		
+            // return value can be ignored because queueing is very rare
+            // case anyway and appending T-class into RArray should succeed
+            TInt ignore = iEventQueue.Append( aEvent );
 		    } // end if		
 		}
 	else
@@ -1064,7 +1074,7 @@
 void CMessageStoreSession::DoMatchFoundL( TContainerId aMessageId, TContainerId aFolderId, const TDesC8& aPropertyBuf )
     {
     CSearchResult* result = CSearchResult::NewL( aMessageId, aFolderId, aPropertyBuf );
-    iMatchMessages.Append( result );
+    iMatchMessages.AppendL( result );
 
     SendMatchesToClient();
     } // end MatchFound
@@ -2185,7 +2195,7 @@
     TBool inMemorySort = aMessage.Int3();
 
     TContainerId sessionId = iServer.MessageStoreL().StartSortingL( sortCriteria, iPropertyNames, inMemorySort );
-    iSortSessionIds.Append( sessionId );
+    iSortSessionIds.AppendL( sessionId );
     
     TPckg<TContainerId> sessionIdPckg( sessionId );
     aMessage.WriteL( 0, sessionIdPckg );
@@ -2582,7 +2592,7 @@
         
         CMruAddress* mruAddress = CMruAddress::NewL(0, addressDes, dispNameDes );
         
-        iMruAddressArray.Append( mruAddress );
+        iMruAddressArray.AppendL( mruAddress );
         
         } // end while
     
@@ -2724,11 +2734,12 @@
         aMessage.ReadL( aIndex, length16Pckg, position );        
         position += length16Pckg.Length();
         
-        HBufC8* buf8 = HBufC8::NewL( length16 );            
-        aArray.Append( buf8 );
+        HBufC8* buf8 = HBufC8::NewLC( length16 );            
         TPtr8 buf8Ptr( buf8->Des() );
         aMessage.ReadL( aIndex, buf8Ptr, position );
         buf8->Des().SetLength( length16 ); 
+        aArray.AppendL( buf8 );
+        CleanupStack::Pop(buf8);
         position += length16;
         } // end while
     }
@@ -2755,7 +2766,7 @@
         
         if ( readBuf.MaxLength() < length16 )
             {
-            readBuf.ReAlloc( length16 );
+            readBuf.ReAllocL( length16 );
             }
         aMessage.ReadL( aIndex, readBuf, position );
         
@@ -2763,7 +2774,9 @@
         const TUint16* valuePtr = reinterpret_cast<const TUint16*>( readBuf.Ptr() );
         TPtrC valueDes( valuePtr, length16 / 2 );  
         
-        aArray.Append( valueDes.AllocL() );
+        HBufC *p = valueDes.AllocLC();
+        aArray.AppendL( p );
+        CleanupStack::Pop( p );
         
         position += length16;
         } // end while
@@ -2784,7 +2797,7 @@
     for( position = 0; position < aMessage.GetDesLengthL( aIndex ); position += idPckg.Length() )
         {
         aMessage.ReadL( aIndex, idPckg, position );      
-        aArray.Append( id );
+        aArray.AppendL( id );
         } // end for
     }
 
--- a/emailservices/emailstore/message_store/server/src/MsgStoreSortResultRowSet.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/MsgStoreSortResultRowSet.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -396,7 +396,7 @@
             {
             ++count;
             curTotal += itemsInPreviousGroup;
-            aItemsInGroup.Append( itemsInPreviousGroup );
+            aItemsInGroup.AppendL( itemsInPreviousGroup );
             }
         } while ( hasMore );        
     
@@ -406,7 +406,7 @@
     if ( lastGroupCount > 0 )
         {
         ++count;
-        aItemsInGroup.Append( lastGroupCount );
+        aItemsInGroup.AppendL( lastGroupCount );
         }
     
     return count;
@@ -424,7 +424,7 @@
 	for ( TInt i = 0 ; i < count ; i++  )
 		{
 		iDbView.NextL();
-		aIdArray.Append( GetRowL() );
+		aIdArray.AppendL( GetRowL() );
 		}
 	}
 
@@ -462,7 +462,7 @@
     iPropertyNames.ResetAndDestroy();
     for ( int i = 0 ; i < aPropertyNames.Count() ; i++ )
         {
-        iPropertyNames.Append( aPropertyNames[i]->Des().AllocL() );
+        iPropertyNames.AppendL( aPropertyNames[i]->Des().AllocL() );
         }
     }
 
--- a/emailservices/emailstore/message_store/server/src/MsgStoreStringSortResultRowSet.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/emailstore/message_store/server/src/MsgStoreStringSortResultRowSet.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -581,13 +581,13 @@
 	        if ( nextGroupId != curGroupId )
 	        	{
 	        	//found a new group
-	            aItemsInGroup.Append( i - curPos );
+	            aItemsInGroup.AppendL( i - curPos );
 	            curPos = i;
 	            curGroupId = nextGroupId; 
 	        	}	        
 	        }
 	    //last group
-        aItemsInGroup.Append( i - curPos );
+        aItemsInGroup.AppendL( i - curPos );
     	}    
     
     return aItemsInGroup.Count();
@@ -611,7 +611,7 @@
         TRAP( err, msgId = NextL() );
 		if ( err == KErrNone )
 			{
-			aIdArray.Append( msgId );
+			aIdArray.AppendL( msgId );
 			}
 		else if ( err == KErrOverflow )
 			{
@@ -1126,8 +1126,8 @@
     
     //now we can reset to initial state
     InitState();
-    iSortedResultArray.Append( iCenterRow );
-    iSortedIdArray.Append( iCenterRow );
+    iSortedResultArray.AppendL( iCenterRow );
+    iSortedIdArray.AppendL( iCenterRow );
     
     iState = EStateSliding;
     
--- a/emailservices/nmailagent/inc/nmmailagent.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/nmailagent/inc/nmmailagent.h	Wed Aug 18 09:37:47 2010 +0300
@@ -87,15 +87,17 @@
 
     void indicatorActivated(const QString &type, const QVariantMap &data);
 
-    void valueChanged(const XQSettingsKey& key, const QVariant& value);
+    void valueChanged(const XQSettingsKey &key, const QVariant &value);
 
+    void delayedMailboxCreated(const NmId mailboxId);
+    
 private:
 
     void initMailboxStatus();
 
     bool updateUnreadCount(const NmId &mailboxId, NmMailboxInfo &mailboxInfo);
 
-    int getOutboxCount(const NmId &mailboxId);
+    int getOutboxCount(const NmId &mailboxId, const NmId &outboxId);
 
     NmMailboxInfo *getMailboxByType(const QString &type);
 
@@ -139,17 +141,26 @@
 
     bool launchMailbox(quint64 mailboxId);
 
+    void handleMessageCreatedEvent(const NmId &folderId, const QList<NmId> &messageIds,
+        const NmId &mailboxId, bool &updateNeeded, bool &activate);
+
+    void handleMessageChangedEvent(const NmId &folderId, const QList<NmId> &messageIds,
+        const NmId &mailboxId, bool &updateNeeded, bool &activate);
+
+    void handleMessageDeletedEvent(const NmId &folderId, const QList<NmId> &messageIds,
+        const NmId &mailboxId, bool &updateNeeded, bool &activate);
+
 private: // data
 
-    HbIndicator *mIndicator;
-    XQSystemToneService *mSystemTone;
-    NmDataPluginFactory *mPluginFactory;
+    HbIndicator *mIndicator; // Owned;
+    XQSystemToneService *mSystemTone; // Owned.
+    NmDataPluginFactory *mPluginFactory; // Not owned (singleton).
     QList<NmMailboxInfo*> mMailboxes;
-    CHWRMVibra *mVibra; // Owned
+    CHWRMVibra *mVibra; // Owned.
     bool mAlertToneAllowed;
     int mLastOutboxCount;
     bool mUnreadIndicatorActive;
-    XQSettingsManager *mSettingManager;
+    XQSettingsManager *mSettingManager; // Owned.
     int mSilenceMode;
 };
 
--- a/emailservices/nmailagent/src/main.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/nmailagent/src/main.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -22,9 +22,9 @@
 #include "ssastartupwatcher.h"
 
 #ifdef __WINSCW__
-const int NmStartupDelay = 14000; // 14s
+const int NmStartupDelay = 4000; // 4s
 #else
-const int NmStartupDelay = 4000; // 4s
+const int NmStartupDelay = 1000; // 1s
 #endif
 
 NmMailAgent *agent = NULL;
@@ -36,7 +36,7 @@
 {
     NM_FUNCTION;
     NM_COMMENT(QString("nmailagent: startupCallback(): status=%1").arg(status));
-    
+
     Q_UNUSED(status);
 
     // either it is an error or 'non critical startup' state has been reached
@@ -50,7 +50,7 @@
 int main(int argc, char *argv[])
 {
     NM_FUNCTION;
-    
+
     QCoreApplication app(argc, argv);
 
     agent = new NmMailAgent;
--- a/emailservices/nmailagent/src/nmmailagent.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/nmailagent/src/nmmailagent.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -1,19 +1,22 @@
 /*
-* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:
-*
-*/
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Mail agent is responsible of monitoring mail accounts. It activates
+ *              and deactivates indicator depending on received events. Mail agent is
+ *              also responsible of monitoring silence mode, playing alert tone and vibrating
+ *              phone when new mail is received.
+ *
+ */
 
 #include "emailtrace.h"
 #include "nmmailagentheaders.h"
@@ -29,7 +32,7 @@
 #include <xqsettingskey.h>
 #include <ProfileEngineInternalCRKeys.h>
 
-// CONSTS
+// CONSTANTS
 const int NmAgentIndicatorNotSet = -1;
 const int NmAgentAlertToneTimer = 60000; // 60s
 const int NmAgentDefaultVibraDuration = 1000; // 1 second
@@ -44,72 +47,78 @@
     Helper method for finding out if XQSettingsKey and XQCentralRepositorySettingsKey points to
     same key.
 
-    @param settingKey XQSettingsKey
-    @param cenrepSettingKey XQCentralRepositorySettingsKey
-    @return <code>true</code> if target, uid and key matches otherwise returns <code>false</code>
-*/
+    \param settingKey XQSettingsKey
+    \param cenrepSettingKey XQCentralRepositorySettingsKey
+    \return <code>true</code> if target, uid and key matches otherwise returns <code>false</code>
+ */
 bool keysEqual(const XQSettingsKey& settingKey, const XQCentralRepositorySettingsKey& cenrepSettingKey)
 {
     return ((settingKey.target() == cenrepSettingKey.target()) &&
-            (settingKey.uid() == cenrepSettingKey.uid()) &&
-            (settingKey.key() == cenrepSettingKey.key()));
+        (settingKey.uid() == cenrepSettingKey.uid()) &&
+        (settingKey.key() == cenrepSettingKey.key()));
 }
 
 
+
+/*!
+    \class NmMailboxInfo
+
+    \brief Main class for storing mailbox data.
+ */
+NmMailboxInfo::NmMailboxInfo()
+: mId(0),
+  mIndicatorIndex(NmAgentIndicatorNotSet),
+  mInboxFolderId(0),
+  mOutboxFolderId(0),
+  mSyncState(SyncComplete),
+  mConnectState(Disconnected),
+  mInboxCreatedMessages(0),
+  mInboxChangedMessages(0),
+  mInboxDeletedMessages(0),
+  mOutboxMails(0),
+  mActive(false),
+  mInboxActive(false)
+  {
+      NM_FUNCTION;
+  }
+
 /*!
     \class NmMailAgent
 
-    \brief Main class for receiving email events and passing them to the HbIndicator
-*/
-
-NmMailboxInfo::NmMailboxInfo()
-{
-    NM_FUNCTION;
-
-    mId = 0;
-    mIndicatorIndex = NmAgentIndicatorNotSet;
-    mSyncState = SyncComplete;
-    mConnectState = Disconnected;
-    mOutboxMails = 0;
-    mInboxFolderId = 0;
-    mOutboxFolderId = 0;
-    mInboxCreatedMessages = 0;
-    mInboxChangedMessages = 0;
-    mInboxDeletedMessages = 0;
-    mActive = false;
-    mInboxActive = false;
-}
-
+    \brief Main class for receiving email events. Activates and deactivates indicator.
+ */
 NmMailAgent::NmMailAgent() :
- mIndicator(NULL),
- mSystemTone(NULL),
- mPluginFactory(NULL),
- mVibra(NULL),
- mAlertToneAllowed(true),
- mLastOutboxCount(0),
- mUnreadIndicatorActive(false),
- mSettingManager(NULL),
- mSilenceMode(NmSilenceModeOn)  // by default silent mode is on
-{
-    NM_FUNCTION;
-}
+     mIndicator(NULL),
+     mSystemTone(NULL),
+     mPluginFactory(NULL),
+     mVibra(NULL),
+     mAlertToneAllowed(true),
+     mLastOutboxCount(0),
+     mUnreadIndicatorActive(false),
+     mSettingManager(NULL),
+     mSilenceMode(NmSilenceModeOn)  // by default silent mode is on
+     {
+     NM_FUNCTION;
+     }
 
 /*!
-    Delayed start
-*/
+    Delayed start.
+ */
 void NmMailAgent::delayedStart()
 {
     NM_FUNCTION;
 
-	if (!init()) {
-		// Initialisation failed. Quit the agent.
-		QCoreApplication::exit(1);
-	}
+    if (!init()) {
+        // Initialisation failed. Quit the agent.
+        QCoreApplication::exit(1);
+    }
 }
 
 /*!
-    Initialise the agent. \return true if succesfully started.
-*/
+    Initialise the agent.
+
+    \return true if succesfully started.
+ */
 bool NmMailAgent::init()
 {
     NM_FUNCTION;
@@ -131,9 +140,9 @@
     // Start monitoring silence mode key.
     bool monitoring(mSettingManager->startMonitoring(NmSilenceModeKey, XQSettingsManager::TypeInt));
     monitoring &= connect(mSettingManager,
-                          SIGNAL(valueChanged(const XQSettingsKey&, const QVariant&)),
+                          SIGNAL(valueChanged(const XQSettingsKey &, const QVariant &)),
                           this,
-                          SLOT(valueChanged(const XQSettingsKey&, const QVariant&)),
+                          SLOT(valueChanged(const XQSettingsKey &, const QVariant &)),
                           Qt::UniqueConnection);
 
     // If silence mode monitoring can't be started, then change silence mode on to be sure
@@ -149,32 +158,32 @@
     delete mIndicator;
     mIndicator = NULL;
     mIndicator = new HbIndicator();
-    connect(mIndicator,SIGNAL(userActivated(const QString &, const QVariantMap&)),
-        this, SLOT(indicatorActivated(const QString&, const QVariantMap&)));
+    connect(mIndicator,SIGNAL(userActivated(const QString &, const QVariantMap &)),
+        this, SLOT(indicatorActivated(const QString &, const QVariantMap &)));
 
     QList<QObject*> *plugins = mPluginFactory->pluginInstances();
 
     foreach (QObject *plugin, *plugins) {
-    	if (plugin) {
-			// Start listening events
-			connect(plugin, SIGNAL(mailboxEvent(NmMailboxEvent, const QList<NmId>&)),
-				this, SLOT(handleMailboxEvent(NmMailboxEvent, const QList<NmId> &)),
-				Qt::UniqueConnection);
+        if (plugin) {
+            // Start listening events
+            connect(plugin, SIGNAL(mailboxEvent(NmMailboxEvent, const QList<NmId> &)),
+                    this, SLOT(handleMailboxEvent(NmMailboxEvent, const QList<NmId> &)),
+                    Qt::UniqueConnection);
 
-			connect(plugin, SIGNAL(messageEvent(
-					NmMessageEvent, const NmId &, const QList<NmId> &, const NmId&)),
-				this, SLOT(handleMessageEvent(
-					NmMessageEvent, const NmId &, const QList<NmId> &, const NmId&)),
-				Qt::UniqueConnection);
+            connect(plugin, SIGNAL(messageEvent(
+                        NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)),
+                    this, SLOT(handleMessageEvent(
+                        NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)),
+                    Qt::UniqueConnection);
 
-			connect(plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent&)),
-				this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent&)),
-				Qt::UniqueConnection);
+            connect(plugin, SIGNAL(syncStateEvent(NmSyncState, const NmOperationCompletionEvent &)),
+                    this, SLOT(handleSyncStateEvent(NmSyncState, const NmOperationCompletionEvent &)),
+                Qt::UniqueConnection);
 
-			connect(plugin, SIGNAL(connectionEvent(NmConnectState, const NmId, int)),
-				this, SLOT(handleConnectionEvent(NmConnectState, const NmId, int)),
-				Qt::UniqueConnection);
-    	}
+            connect(plugin, SIGNAL(connectionEvent(NmConnectState, const NmId, int)),
+                    this, SLOT(handleConnectionEvent(NmConnectState, const NmId, int)),
+                    Qt::UniqueConnection);
+        }
     }
 
     // Construct the vibra interface instance.
@@ -188,10 +197,14 @@
     return true;
 }
 
+/*!
+    Destructor of NmMailAgent.
+ */
 NmMailAgent::~NmMailAgent()
 {
     NM_FUNCTION;
 
+    delete mIndicator;
     delete mVibra;
     delete mSystemTone;
     if (mSettingManager) {
@@ -204,8 +217,8 @@
 }
 
 /*!
-    Initialize the mailbox list with the current state
-*/
+    Initialize the mailbox list with the current state.
+ */
 void NmMailAgent::initMailboxStatus()
 {
     NM_FUNCTION;
@@ -228,12 +241,12 @@
         while (i.hasPrevious()) {
             const NmMailbox *mailbox = i.previous();
             if (mailbox) {
-                NmMailboxInfo *mailboxInfo = createMailboxInfo(*mailbox,plugin);
+                NmMailboxInfo *mailboxInfo = createMailboxInfo(*mailbox, plugin);
                 if (mailboxInfo) {
                     bool activate = updateUnreadCount(mailbox->id(), *mailboxInfo);
                     bool wasActive = isMailboxActive(mailbox->id());
                     if (activate) {
-                        if(!wasActive) {
+                        if (!wasActive) {
                             // do not activate the mailbox if it was left as hidden last time
                             activate = false;
                         }
@@ -243,13 +256,14 @@
                         }
                     }
 
-                    mailboxInfo->mOutboxMails = getOutboxCount(mailbox->id());
+                    mailboxInfo->mOutboxMails = getOutboxCount(mailbox->id(),
+                        mailboxInfo->mOutboxFolderId);
                     if (mailboxInfo->mOutboxMails > 0 && wasActive) {
                         activate = true;
                     }
 
-	                // Create indicator for visible mailboxes
-    	            updateMailboxState(mailbox->id(), activate, false);
+                    // Create indicator for visible mailboxes
+                    updateMailboxState(mailbox->id(), activate, false);
                 }
             }
         }
@@ -260,51 +274,55 @@
 }
 
 /*!
-    Get mailbox unread count in inbox folder
+    Get mailbox unread count in inbox folder.
+
     \param mailboxId id of the mailbox
     \param mailboxInfo contains the list of unread messages
     \return true if new unread mails was found
-*/
+ */
 bool NmMailAgent::updateUnreadCount(const NmId &mailboxId, NmMailboxInfo &mailboxInfo)
 {
     NM_FUNCTION;
 
     int newUnreadMessages(0);
-
     NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId);
 
     if (plugin) {
-		// get inbox folder ID
-		NmId inboxId = plugin->getStandardFolderId(
-				mailboxId, NmFolderInbox );
+        NmId inboxId = mailboxInfo.mInboxFolderId.id();
 
-		// get list of messages in inbox
-		QList<NmMessageEnvelope*> messageList;
-		plugin->listMessages(mailboxId, inboxId, messageList);
+        // Inbox folder ID may be still unknown
+        if (inboxId == 0) {
+            mailboxInfo.mInboxFolderId = plugin->getStandardFolderId(mailboxId, NmFolderInbox);
+            inboxId = mailboxInfo.mInboxFolderId.id();
+        }
+
+        // get list of messages in inbox
+        QList<NmMessageEnvelope*> messageList;
+        plugin->listMessages(mailboxId, inboxId, messageList);
 
-		QList<NmId> newUnreadMessageIdList;
-		foreach (const NmMessageEnvelope* envelope, messageList) {
-		    // if the message is not read, it is "unread"
-			if (!envelope->isRead()) {
-		        quint64 messageId = envelope->messageId().id();
-			    newUnreadMessageIdList.append(envelope->messageId());
-			    bool found(false);
-			    // Iterate through all known ids. If the id can't be found the mail is new.
-			    foreach (const NmId id, mailboxInfo.mUnreadMailIdList) {
-			        if (id.id() == messageId) {
-			            found = true;
-			            break;
-			        }
-			    }
+        QList<NmId> newUnreadMessageIdList;
+        foreach (const NmMessageEnvelope* envelope, messageList) {
+            // if the message is not read, it is "unread"
+            if (!envelope->isRead()) {
+                quint64 messageId = envelope->messageId().id();
+                newUnreadMessageIdList.append(envelope->messageId());
+                bool found(false);
+                // Iterate through all known ids. If the id can't be found the mail is new.
+                foreach (const NmId id, mailboxInfo.mUnreadMailIdList) {
+                    if (id.id() == messageId) {
+                        found = true;
+                        break;
+                    }
+                }
 
-			    if (!found) {
-			        newUnreadMessages++;
-			    }
-			}
-		}
-		qDeleteAll(messageList);
+                if (!found) {
+                    newUnreadMessages++;
+                }
+            }
+        }
+        qDeleteAll(messageList);
 
-		// Save updated list of unread message IDs
+        // Save updated list of unread message IDs
         mailboxInfo.mUnreadMailIdList = newUnreadMessageIdList;
     }
     NM_COMMENT(QString("NmMailAgent::getUnreadCount(): count=%1, new=%2").
@@ -314,28 +332,25 @@
 }
 
 /*!
-    Get mailbox count in outbox folder
+    Get mailbox count in outbox folder.
+
     \param mailboxId id of the mailbox
-    \param maxCount max number of outbox mails that is needed
+    \param outboxId Outbox folder Id
     \return number of mails in the outbox
-*/
-int NmMailAgent::getOutboxCount(const NmId &mailboxId)
+ */
+int NmMailAgent::getOutboxCount(const NmId &mailboxId, const NmId &outboxId)
 {
     NM_FUNCTION;
 
     int count(0);
-
     NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId);
 
     if (plugin) {
-		// get outbox folder ID
-		NmId outboxId = plugin->getStandardFolderId( mailboxId, NmFolderOutbox );
-
-		// get list of messages in outbox
-		QList<NmMessageEnvelope*> messageList;
-		plugin->listMessages(mailboxId, outboxId, messageList);
-		count = messageList.count();
-		qDeleteAll(messageList);
+        // get list of messages in outbox
+        QList<NmMessageEnvelope*> messageList;
+        plugin->listMessages(mailboxId, outboxId, messageList);
+        count = messageList.count();
+        qDeleteAll(messageList);
     }
     NM_COMMENT(QString("NmMailAgent::getOutboxCount(): count=%1").arg(count));
 
@@ -343,9 +358,10 @@
 }
 
 /*!
-    Get list of unread counts in active mailboxes
+    Get list of unread counts in active mailboxes.
+
 	\returns total number of unread mails
-*/
+ */
 int NmMailAgent::getTotalUnreadCount() const
 {
     NM_FUNCTION;
@@ -360,9 +376,10 @@
 }
 
 /*!
-    Update the "@" indicator state according to unread state
+    Update the "@" indicator state according to unread state.
+
     \return true if the indicator was activated
-*/
+ */
 bool NmMailAgent::updateUnreadIndicator()
 {
     NM_FUNCTION;
@@ -372,12 +389,13 @@
 }
 
 /*!
-    Update the mailbox visibility and status
+    Update the mailbox visibility and status.
+
     \param mailboxId id of the mailbox
     \param active visibility state of the mailbox
     \param refreshAlways true when the indicator should be always updated
     \return true if the mailbox state was changed
-*/
+ */
 bool NmMailAgent::updateMailboxState(const NmId &mailboxId,
     bool active, bool refreshAlways)
 {
@@ -388,7 +406,7 @@
     if (mailboxInfo->mActive != active ||
         refreshAlways) {
 
-		// store the new state to permanent storage
+        // store the new state to permanent storage
         storeMailboxActive(mailboxId, active);
 
         mailboxInfo->mActive = active;
@@ -413,12 +431,13 @@
 }
 
 /*!
-    Updates indicator status
+    Updates indicator status.
+
     \param mailboxIndex index of the item shown in indicator menu
     \param active indicator visibility state
     \param mailboxInfo information of the mailbox
     \return true if indicator was updated with no errors
-*/
+ */
 bool NmMailAgent::updateIndicator(bool active,
     const NmMailboxInfo& mailboxInfo)
 {
@@ -453,9 +472,11 @@
 }
 
 /*!
-    update the unread indicator state
+    Update the unread indicator state.
+
+    \param active if true unread indicator is activated otherwise deactivated
     \return true if the indicator was activated
-*/
+ */
 bool NmMailAgent::updateUnreadIndicator(bool active)
 {
     NM_FUNCTION;
@@ -476,9 +497,11 @@
 }
 
 /*!
-    Opens inbox view to specific mailbox
+    Opens inbox view to specific mailbox.
+
+    \param mailboxId Id of mailbox
     \return true if inbox is succesfully opened
-*/
+ */
 bool NmMailAgent::launchMailbox(quint64 mailboxId)
 {
     NM_FUNCTION;
@@ -492,7 +515,6 @@
         QList<QVariant> list;
         list.append(QVariant(mailboxId));
         request->setArguments(list);
-
         ok = request->send();
         NM_COMMENT(QString("Launch ok=%1 error=%2").arg(ok).arg(request->lastError()));
         delete request;
@@ -501,8 +523,181 @@
 }
 
 /*!
-    Get next free indicator index, starting from 0
-    @return index of the indicator that is available
+    Handles message created event.
+
+    \param folderId Id of the folder that includes the message
+    \param messageIds Message ids that are checked
+    \param mailboxId Id of the mailbox that includes the message
+    \param updateNeeded Set to <code>true</code> if update needed otherwise not touched
+    \param activate Set to <code>true</code> if activation needed otherwise not touched
+ */
+void NmMailAgent::handleMessageCreatedEvent(const NmId &folderId, const QList<NmId> &messageIds,
+    const NmId &mailboxId, bool &updateNeeded, bool &activate)
+{
+    NM_FUNCTION;
+
+    // Check the new messages to make the indicator appear earlier
+    NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
+
+    // Inbox folder ID may be still unknown
+    if (mailboxInfo->mInboxFolderId.id() == 0) {
+        NmDataPluginInterface *plugin =
+            mPluginFactory->interfaceInstance(mailboxId);
+
+        if (plugin) {
+            mailboxInfo->mInboxFolderId =
+                plugin->getStandardFolderId(mailboxId, NmFolderInbox);
+        }
+    }
+
+    if (folderId == mailboxInfo->mInboxFolderId) {
+        foreach (NmId messageId, messageIds) {
+            bool messageUnread = false;
+
+            // Check the message if we can either play a tone or if the "@" is
+            // not visible at the moment
+            if (mAlertToneAllowed || !mUnreadIndicatorActive) {
+                if (getMessageUnreadInfo(folderId, messageId, mailboxId, messageUnread)) {
+                    if (messageUnread) {
+                        mailboxInfo->mUnreadMailIdList.append(messageId);
+                        mailboxInfo->mInboxActive = true;
+                        updateMailboxState(mailboxId, true, false);
+
+                        // make the "@" appear immediatelly
+                        updateUnreadIndicator(true);
+
+                        // Play the tone as well
+                        playAlertTone();
+                    }
+                }
+            }
+        }
+    }
+
+    if (folderId==mailboxInfo->mInboxFolderId) {
+        mailboxInfo->mInboxCreatedMessages += messageIds.count();
+    }
+
+    // When created a new mail in the outbox, we are in sending state
+    if (mailboxInfo->mOutboxFolderId == folderId) {
+        // The first mail created in the outbox
+        if (mailboxInfo->mOutboxMails <= 0) {
+            NM_COMMENT("NmMailAgent: first mail in outbox");
+        }
+        // Always activate the indicator
+        activate = true;
+        updateNeeded = true;
+
+        mailboxInfo->mOutboxMails += messageIds.count();
+        updateSendIndicator();
+    }
+}
+
+
+/*!
+    Handles message changed event.
+    \sa updateUnreadCount
+
+    \param folderId Id of the folder that includes the message
+    \param messageIds Message ids that are checked
+    \param mailboxId Id of the mailbox that includes the message
+    \param updateNeeded Set to <code>true</code> if update needed otherwise not touched
+    \param activate Set result value of updateUnreadCount method
+ */
+void NmMailAgent::handleMessageChangedEvent(const NmId &folderId, 
+    const QList<NmId> &messageIds,
+    const NmId &mailboxId,
+    bool &updateNeeded, bool &activate)
+{
+    NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
+
+    // we are interested only about changes in the inbox
+    if (folderId == mailboxInfo->mInboxFolderId) {
+        mailboxInfo->mInboxChangedMessages++;
+
+        // If not currently syncronizing the mailbox, this may mean
+        // that a message was read/unread
+        if (mailboxInfo && mailboxInfo->mSyncState == SyncComplete) {
+            // If there was no unread mails in the list, do nothing
+            int oldCount(mailboxInfo->mUnreadMailIdList.count());
+            if (oldCount>0) {
+                // Check how many messages were unread earlier
+                int unreadMessages = 0;
+                foreach (NmId messageId, messageIds) {
+                    if (mailboxInfo->mUnreadMailIdList.indexOf(messageId)>=0) {
+                        unreadMessages++;
+                    }
+                }
+
+                // Could lead the count drop to 0 => mailbox will be hidden
+                if (unreadMessages > 0) {
+                    // check the unread status again
+                    activate = updateUnreadCount(mailboxId, *mailboxInfo);
+
+                    // no more unread mails in the inbox
+                    if (mailboxInfo->mUnreadMailIdList.count()==0) {
+                        NM_COMMENT("NmMailAgent:handleMessageChangedEvent - no more unread msgs");
+                        updateNeeded = true;
+                    }
+                }
+            }
+        }
+    }
+}
+
+/*!
+    Handles message deleted event.
+
+    \param folderId Id of the folder that includes the message
+    \param messageIds Message ids that are checked
+    \param mailboxId Id of the mailbox that includes the message
+    \param updateNeeded Set to <code>true</code> if update needed otherwise not touched
+    \param activate Set to <code>true</code> if activation needed otherwise not touched
+ */
+void NmMailAgent::handleMessageDeletedEvent(const NmId &folderId, const QList<NmId> &messageIds,
+    const NmId &mailboxId, bool &updateNeeded, bool &activate)
+{
+    NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
+
+    if (folderId == mailboxInfo->mInboxFolderId) {
+        mailboxInfo->mInboxDeletedMessages++;
+    }
+
+    // Deleted mails from the outbox
+    if (mailboxInfo->mOutboxFolderId == folderId) {
+        mailboxInfo->mOutboxMails -= messageIds.count();
+
+        // Sanity check for the outbox count
+        if (mailboxInfo->mOutboxMails < 0) {
+            mailboxInfo->mOutboxMails = 0;
+        }
+
+        // The last mail was now deleted
+        if (mailboxInfo->mOutboxMails == 0) {
+            NM_COMMENT("NmMailAgent: last mail deleted from outbox");
+            updateNeeded = true;
+
+            // Keep it active if there is unread mails and inbox is still active
+            if (mailboxInfo->mInboxActive &&
+                mailboxInfo->mUnreadMailIdList.count() > 0) {
+                activate = true;
+            }
+        }
+        else {
+            // Also update the indicator status if it is already shown
+            if (mailboxInfo->mActive) {
+                activate = true;
+                updateNeeded = true;
+            }
+        }
+        updateSendIndicator();
+    }
+}
+
+/*!
+    Get next free indicator index, starting from 0.
+
+    \return index of the indicator that is available
  */
 int NmMailAgent::getFreeIndicatorIndex()
 {
@@ -527,7 +722,10 @@
 /*!
     Received from NmFrameworkAdapter mailboxEvent signal
     \sa NmFrameworkAdapter
-*/
+
+    \param event Mailbox event type
+    \param mailboxIds Mailbox ids that are checked
+ */
 void NmMailAgent::handleMailboxEvent(NmMailboxEvent event, const QList<NmId> &mailboxIds)
 {
     NM_FUNCTION;
@@ -536,7 +734,15 @@
     switch(event) {
         case NmMailboxCreated:
             foreach (NmId mailboxId, mailboxIds) {
-                getMailboxInfo(mailboxId); // create a new mailbox if needed
+                NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId); // create a new mailbox if needed
+                if (!mailboxInfo) {
+                    // Unable to initialise the mailbox. Try again later.
+                    NM_COMMENT("Cannot initialise mailbox");
+
+                    qRegisterMetaType<NmId>("NmId");
+                    QMetaObject::invokeMethod(this, "delayedMailboxCreated",
+                        Qt::QueuedConnection, Q_ARG(NmId,mailboxId));
+                }
 
                 // make sure the mailbox activity data is reseted
                 deleteStoredMailboxActivity(mailboxId);
@@ -550,7 +756,7 @@
                 NmMailbox *mailbox(NULL);
                 NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId);
                 if (plugin) {
-					plugin->getMailboxById(mailboxId,mailbox);
+                    plugin->getMailboxById(mailboxId,mailbox);
                 }
                 if (mailbox && mailboxInfo) {
                     if(mailbox->name() != mailboxInfo->mName) {
@@ -581,32 +787,53 @@
 }
 
 /*!
-   Map the type name to mailbox info
-    \return NULL if no mailbox match the type
+    Called when mailbox is initialised with a delay. This may happen at least when
+    NmMailboxCreated event is received.
+
+    \param mailboxId id of the mailbox
 */
+void NmMailAgent::delayedMailboxCreated(const NmId mailboxId)
+{
+    NM_FUNCTION;
+
+    // create and subscribe to the mailbox, if not done earlier
+    getMailboxInfo(mailboxId);
+}
+
+/*!
+   Map the type name to mailbox info.
+
+   \param type Indicator type name
+   \return NULL if no mailbox match the type
+ */
 NmMailboxInfo *NmMailAgent::getMailboxByType(const QString &type)
 {
     NM_FUNCTION;
 
+    NmMailboxInfo *foundMailbox = NULL;
     foreach (NmMailboxInfo *mailbox, mMailboxes) {
         // mailbox is shown in indicators
         if (mailbox->mIndicatorIndex >= 0 && mailbox->mActive) {
             QString typeName = QString(NmMailboxIndicatorType).arg(mailbox->mIndicatorIndex);
 
             // type names match(!)
-            if(type==typeName) {
-                return mailbox;
+            if (type == typeName) {
+                foundMailbox = mailbox;
+                break;
             }
         }
     }
-    return NULL;
+    return foundMailbox;
 }
 
 /*!
     Called when indicator is clicked from the indicator menu
     - indicator will be hide from the menu
     - mailbox will be launched
-*/
+
+    \param type Indicator type name
+    \param data Data sent by indicator
+ */
 void NmMailAgent::indicatorActivated(const QString &type, const QVariantMap &data)
 {
     NM_FUNCTION;
@@ -628,10 +855,10 @@
     Called when cenrep key value has been changed.
     - only silence mode key handled
 
-    @param key changed key
-    @param value value for a key.
-*/
-void NmMailAgent::valueChanged(const XQSettingsKey& key, const QVariant& value)
+    \param key changed key
+    \param value value for a key
+ */
+void NmMailAgent::valueChanged(const XQSettingsKey &key, const QVariant &value)
 {
     NM_FUNCTION;
 
@@ -643,15 +870,19 @@
 /*!
     Received from NmFrameworkAdapter messageEvent signal
     \sa NmFrameworkAdapter
-*/
+
+    \param event Message event
+    \param folderId Folder Id
+    \param messageIds List of message Ids
+    \param mailboxId Id of the mailbox
+ */
 void NmMailAgent::handleMessageEvent(
-            NmMessageEvent event,
-            const NmId &folderId,
-            const QList<NmId> &messageIds,
-            const NmId& mailboxId)
+    NmMessageEvent event,
+    const NmId &folderId,
+    const QList<NmId> &messageIds,
+    const NmId &mailboxId)
 {
     NM_FUNCTION;
-
     NM_COMMENT(QString("NmMailAgent::handleMessageEvent(): event=%1, id=%2").
         arg(event).arg(mailboxId.id()));
 
@@ -660,120 +891,15 @@
 
     switch (event) {
         case NmMessageCreated: {
-            // Check the new messages to make the indicator appear earlier
-            NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
-            
-            // Inbox folder ID may be still unknown
-            if (mailboxInfo->mInboxFolderId.id() == 0) {
-                NmDataPluginInterface *plugin =
-                    mPluginFactory->interfaceInstance(mailboxId);
-
-                if (plugin) {
-                    mailboxInfo->mInboxFolderId =
-                        plugin->getStandardFolderId(mailboxId, NmFolderInbox);
-                }
-            }
-
-            if (folderId == mailboxInfo->mInboxFolderId) {
-                foreach (NmId messageId, messageIds) {
-                    bool messageUnread = false;
-
-                    // Check the message if we can either play a tone or if the "@" is
-                    // not visible at the moment
-                    if (mAlertToneAllowed || !mUnreadIndicatorActive) {
-                        if (getMessageUnreadInfo(folderId, messageId, mailboxId, messageUnread)) {
-                            if (messageUnread) {
-                                mailboxInfo->mUnreadMailIdList.append(messageId);
-                                mailboxInfo->mInboxActive = true;
-                                updateMailboxState(mailboxId, true, false);
-
-                                // make the "@" appear immediatelly
-                                updateUnreadIndicator(true);
-
-                                // Play the tone as well
-                                playAlertTone();
-                            }
-                        }
-                    }
-                }
-            }
-
-            if (folderId==mailboxInfo->mInboxFolderId) {
-                mailboxInfo->mInboxCreatedMessages += messageIds.count();
-            }
-
-            // When created a new mail in the outbox, we are in sending state
-            if (mailboxInfo->mOutboxFolderId == folderId) {
-                // The first mail created in the outbox
-                if (mailboxInfo->mOutboxMails <= 0) {
-					NM_COMMENT("NmMailAgent: first mail in outbox");
-                }
-                // Always activate the indicator
-                activate = true;
-                updateNeeded = true;
-
-                mailboxInfo->mOutboxMails += messageIds.count();
-				updateSendIndicator();
-            }
+            handleMessageCreatedEvent(folderId, messageIds, mailboxId, updateNeeded, activate);
             break;
         }
         case NmMessageChanged: {
-            NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
-
-            if (folderId==mailboxInfo->mInboxFolderId) {
-                mailboxInfo->mInboxChangedMessages++;
-            }
-
-            // If not currently syncronizing the mailbox, this may mean
-            // that a message was read/unread
-            if (mailboxInfo && mailboxInfo->mSyncState==SyncComplete) {
-                // check the unread status again
-                int oldCount = mailboxInfo->mUnreadMailIdList.count();
-                activate = updateUnreadCount(mailboxId, *mailboxInfo);
-
-                // new unread mails found or no more unread mails in the inbox
-                if (oldCount>0 && mailboxInfo->mUnreadMailIdList.count()==0) {
-                    updateNeeded = true;
-                }
-            }
-			break;
-		}
+            handleMessageChangedEvent(folderId, messageIds, mailboxId, updateNeeded, activate);
+            break;
+        }
         case NmMessageDeleted: {
-            NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
-
-            if (folderId==mailboxInfo->mInboxFolderId) {
-                mailboxInfo->mInboxDeletedMessages++;
-            }
-
-            // Deleted mails from the outbox
-            if (mailboxInfo->mOutboxFolderId == folderId) {
-                mailboxInfo->mOutboxMails -= messageIds.count();
-
-                // Sanity check for the outbox count
-                if (mailboxInfo->mOutboxMails < 0) {
-                    mailboxInfo->mOutboxMails = 0;
-                }
-
-                // The last mail was now deleted
-                if (mailboxInfo->mOutboxMails == 0) {
-					NM_COMMENT("NmMailAgent: last mail deleted from outbox");
-					updateNeeded = true;
-
-	                // Keep it active if there is unread mails and inbox is still active
- 				    if (mailboxInfo->mInboxActive &&
-					    mailboxInfo->mUnreadMailIdList.count() > 0) {
-					    activate = true;
-	                }
-				}
-				else {
-	                // Also update the indicator status if it is already shown
-    	            if (mailboxInfo->mActive) {
-						activate = true;
-            	        updateNeeded = true;
-					}
-				}
-				updateSendIndicator();
-            }
+            handleMessageDeletedEvent(folderId, messageIds, mailboxId, updateNeeded, activate);
             break;
         }
         default:
@@ -790,12 +916,14 @@
 }
 
 /*!
-    Received from NmFrameworkAdapter syncStateEvent signal
+    Received from NmFrameworkAdapter syncStateEvent signal.
     \sa NmFrameworkAdapter
-*/
-void NmMailAgent::handleSyncStateEvent(
-            NmSyncState state,
-            const NmOperationCompletionEvent &event)
+
+    \param state state of synchronization
+    \param event Information related to asynchronous operation
+
+ */
+void NmMailAgent::handleSyncStateEvent(NmSyncState state, const NmOperationCompletionEvent &event)
 {
     NM_FUNCTION;
     NM_COMMENT(QString("NmMailAgent::handleSyncStateEvent(): state=%1, id=%2").
@@ -813,15 +941,15 @@
         }
         else if (state==SyncComplete) {
             // Check the unread status here again
-            bool activate = updateUnreadCount(event.mMailboxId, *info);
+            bool updateMailbox = updateUnreadCount(event.mMailboxId, *info);
             int oldOutboxCount = info->mOutboxMails;
-            info->mOutboxMails = getOutboxCount(event.mMailboxId);
-            if (info->mOutboxMails > oldOutboxCount) {
+            info->mOutboxMails = getOutboxCount(event.mMailboxId, info->mOutboxFolderId);
+            int unreadMailCount(info->mUnreadMailIdList.count());
+            if (info->mOutboxMails > oldOutboxCount || unreadMailCount == 0) {
                 // new mails in outbox
-                activate = true;
+                updateMailbox = true;
             }
-            bool active = info->mUnreadMailIdList.count() ||
-                info->mOutboxMails;
+            bool active = unreadMailCount || info->mOutboxMails;
 
             // Refresh the indicator if messages created or changed
             NM_COMMENT(QString("NmMailAgent::handleSyncStateEvent(): "
@@ -833,7 +961,7 @@
 
             updateUnreadIndicator();
 
-            if (activate) {
+            if (updateMailbox) {
                 updateMailboxState(event.mMailboxId, active, refresh);
             }
         }
@@ -841,9 +969,13 @@
 }
 
 /*!
-    Received from NmFrameworkAdapter connectionState signal
+    Received from NmFrameworkAdapter connectionState signal.
     \sa NmFrameworkAdapter
-*/
+
+    \param state Connection state
+    \param mailboxId Id of the mailbox
+    \parma errorcode Error code
+ */
 void NmMailAgent::handleConnectionEvent(NmConnectState state, const NmId mailboxId, int errorcode)
 {
     NM_FUNCTION;
@@ -859,9 +991,11 @@
 }
 
 /*!
-    Remove a mailbox info entry
-    \return true if mailbox info was found
-*/
+    Remove a mailbox info entry.
+
+    \param id Id of the mailbox
+    \return true if mailbox info was found.
+ */
 bool NmMailAgent::removeMailboxInfo(const NmId &id)
 {
     NM_FUNCTION;
@@ -882,9 +1016,11 @@
 }
 
 /*!
-    Create a new mailbox info entry
+    Create a new mailbox info entry.
+
+    \param id Id of the mailbox
     \return new mailbox info object
-*/
+ */
 NmMailboxInfo *NmMailAgent::createMailboxInfo(const NmId &id)
 {
     NM_FUNCTION;
@@ -905,8 +1041,11 @@
 
 /*!
     Create a new mailbox info with given parameters
+
+    \param mailbox Mailbox which mailbox info will be created
+    \param plugin Interface to access email data
     \return new mailbox info object
-*/
+ */
 NmMailboxInfo *NmMailAgent::createMailboxInfo(const NmMailbox &mailbox, NmDataPluginInterface *plugin)
 {
     NM_FUNCTION;
@@ -939,9 +1078,12 @@
 }
 
 /*!
-    Return mailbox info class with mailbox id. If no class is found, create a new instance with given id.
+    Return mailbox info class with mailbox id. If no class is found,
+    create a new instance with given id.
+
+    \param id Id of the mailbox
     \return mailbox info object
-*/
+ */
 NmMailboxInfo *NmMailAgent::getMailboxInfo(const NmId &id)
 {
     NM_FUNCTION;
@@ -958,19 +1100,20 @@
 
 /*!
     Finds out if the message is unread.
+
     \param folderId the id of the folder that includes the message
     \param messageIds the message ids that are checked
     \param mailboxId the id of the mailbox that includes the message
     \param unreadMessage true if there was unread messages
     \return true if info fetching was successful
-*/
+ */
 bool NmMailAgent::getMessageUnreadInfo(const NmId &folderId,
     const NmId &messageId, const NmId &mailboxId, bool &unreadMessage)
 {
     NM_FUNCTION;
 
     NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId);
-    bool ok = false;
+    bool ok(false);
 
     if (plugin) {
         NmMessage *message=NULL;
@@ -988,13 +1131,14 @@
 }
 
 /*!
-    Plays email alert tone when new messages arrive
+    Plays email alert tone when new messages arrive.
+
 	\returns true if the tone was played
-*/
+ */
 bool NmMailAgent::playAlertTone()
 {
     NM_FUNCTION;
-	bool played(false);
+    bool played(false);
 
     if (mAlertToneAllowed) {
         // Play tone only if system tone service is available and
@@ -1011,15 +1155,15 @@
         // play alert only once per minute
         mAlertToneAllowed = false;
         QTimer::singleShot(NmAgentAlertToneTimer, this, SLOT(enableAlertTone()));
-		played = true;
+        played = true;
     }
 
-	return played;
+    return played;
 }
 
 /*!
-    Allows alert tune to be played again
-*/
+    Allows alert tune to be played again.
+ */
 void NmMailAgent::enableAlertTone()
 {
     NM_FUNCTION;
@@ -1028,14 +1172,14 @@
 }
 
 /*!
-    update send indicator according to outbox state
-*/
+    Update send indicator according to outbox state.
+ */
 void NmMailAgent::updateSendIndicator()
 {
     NM_FUNCTION;
 
     // Get number of mails in outboxes
-    int outboxMails = 0;
+    int outboxMails(0);
     foreach (NmMailboxInfo *mailboxInfo, mMailboxes) {
         outboxMails += mailboxInfo->mOutboxMails;
     }
@@ -1046,18 +1190,19 @@
     else if (outboxMails > mLastOutboxCount) {
         // New mails detected in outbox
 
-    	// indicator will disappear automatically after a delay
+        // indicator will disappear automatically after a delay
         mIndicator->activate(NmSendIndicatorName);
-	}
+    }
 
-	mLastOutboxCount = outboxMails;
+    mLastOutboxCount = outboxMails;
 }
 
 /*!
-    Store the mailbox active information to permanent storage
-    \param mailboxId id of the mailbox
+    Store the mailbox active information to permanent storage.
+
+    \param mailboxId Id of the mailbox
     \param active true if the mailbox is active
-*/
+ */
 void NmMailAgent::storeMailboxActive(const NmId &mailboxId, bool active)
 {
     NM_FUNCTION;
@@ -1078,9 +1223,10 @@
 
 /*!
     Get the mailbox activity state.
+
     \param mailboxId id of the mailbox
     \return true if the mailbox is active or no information was stored earlier
-*/
+ */
 bool NmMailAgent::isMailboxActive(const NmId &mailboxId)
 {
     NM_FUNCTION;
@@ -1098,15 +1244,16 @@
 }
 
 /*!
-    Delete all stored activity information for the mailbox id
+    Delete all stored activity information for the mailbox id.
+
     \param mailboxId id of the mailbox
-*/
+ */
 void NmMailAgent::deleteStoredMailboxActivity(const NmId &mailboxId)
 {
     NM_FUNCTION;
 
     // deactivation delete the key too
-    storeMailboxActive(mailboxId,false);
+    storeMailboxActive(mailboxId, false);
 }
 
 // End of file
--- a/emailservices/nmclientapi/bwins/nmailclientapiu.def	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/nmclientapi/bwins/nmailclientapiu.def	Wed Aug 18 09:37:47 2010 +0300
@@ -242,4 +242,8 @@
 	?getStaticMetaObject@NmApiMessageManager@EmailClientApi@@SAABUQMetaObject@@XZ @ 241 NONAME ; struct QMetaObject const & EmailClientApi::NmApiMessageManager::getStaticMetaObject(void)
 	?staticMetaObject@NmApiMessageManager@EmailClientApi@@2UQMetaObject@@B @ 242 NONAME ; struct QMetaObject const EmailClientApi::NmApiMessageManager::staticMetaObject
 	?qt_metacall@NmApiMailboxSettings@EmailClientApi@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 243 NONAME ; int EmailClientApi::NmApiMailboxSettings::qt_metacall(enum QMetaObject::Call, int, void * *)
+	??0NmApiSettingsManager@EmailClientApi@@QAE@_K@Z @ 244 NONAME ; EmailClientApi::NmApiSettingsManager::NmApiSettingsManager(unsigned long long)
+	?save@NmApiSettingsManager@EmailClientApi@@QAE_NABVNmApiMailboxSettingsData@2@@Z @ 245 NONAME ; bool EmailClientApi::NmApiSettingsManager::save(class EmailClientApi::NmApiMailboxSettingsData const &)
+	?load@NmApiSettingsManager@EmailClientApi@@QAE_N_KAAVNmApiMailboxSettingsData@2@@Z @ 246 NONAME ; bool EmailClientApi::NmApiSettingsManager::load(unsigned long long, class EmailClientApi::NmApiMailboxSettingsData &)
+	??1NmApiSettingsManager@EmailClientApi@@QAE@XZ @ 247 NONAME ; EmailClientApi::NmApiSettingsManager::~NmApiSettingsManager(void)
 
--- a/emailservices/nmclientapi/eabi/nmailclientapiu.def	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/nmclientapi/eabi/nmailclientapiu.def	Wed Aug 18 09:37:47 2010 +0300
@@ -251,21 +251,27 @@
 	_ZN14EmailClientApi20NmApiMailboxSettingsD0Ev @ 250 NONAME
 	_ZN14EmailClientApi20NmApiMailboxSettingsD1Ev @ 251 NONAME
 	_ZN14EmailClientApi20NmApiMailboxSettingsD2Ev @ 252 NONAME
-	_ZN14EmailClientApi24NmApiMailboxSettingsData12setMailboxIdEy @ 253 NONAME
-	_ZN14EmailClientApi24NmApiMailboxSettingsData13clearSettingsEv @ 254 NONAME
-	_ZN14EmailClientApi24NmApiMailboxSettingsData8setValueEiRK8QVariant @ 255 NONAME
-	_ZN14EmailClientApi24NmApiMailboxSettingsDataC1Ev @ 256 NONAME
-	_ZN14EmailClientApi24NmApiMailboxSettingsDataC2Ev @ 257 NONAME
-	_ZN14EmailClientApi24NmApiMailboxSettingsDataD1Ev @ 258 NONAME
-	_ZN14EmailClientApi24NmApiMailboxSettingsDataD2Ev @ 259 NONAME
-	_ZNK14EmailClientApi19NmApiMessageManager10metaObjectEv @ 260 NONAME
-	_ZNK14EmailClientApi20NmApiMailboxSettings10metaObjectEv @ 261 NONAME
-	_ZNK14EmailClientApi24NmApiMailboxSettingsData12listSettingsEv @ 262 NONAME
-	_ZNK14EmailClientApi24NmApiMailboxSettingsData12validateDataEv @ 263 NONAME
-	_ZNK14EmailClientApi24NmApiMailboxSettingsData8getValueEiR8QVariant @ 264 NONAME
-	_ZNK14EmailClientApi24NmApiMailboxSettingsData9mailboxIdEv @ 265 NONAME
-	_ZTIN14EmailClientApi19NmApiMessageManagerE @ 266 NONAME
-	_ZTIN14EmailClientApi20NmApiMailboxSettingsE @ 267 NONAME
-	_ZTVN14EmailClientApi19NmApiMessageManagerE @ 268 NONAME
-	_ZTVN14EmailClientApi20NmApiMailboxSettingsE @ 269 NONAME
+	_ZN14EmailClientApi20NmApiSettingsManager4loadEyRNS_24NmApiMailboxSettingsDataE @ 253 NONAME
+	_ZN14EmailClientApi20NmApiSettingsManager4saveERKNS_24NmApiMailboxSettingsDataE @ 254 NONAME
+	_ZN14EmailClientApi20NmApiSettingsManagerC1Ey @ 255 NONAME
+	_ZN14EmailClientApi20NmApiSettingsManagerC2Ey @ 256 NONAME
+	_ZN14EmailClientApi20NmApiSettingsManagerD1Ev @ 257 NONAME
+	_ZN14EmailClientApi20NmApiSettingsManagerD2Ev @ 258 NONAME
+	_ZN14EmailClientApi24NmApiMailboxSettingsData12setMailboxIdEy @ 259 NONAME
+	_ZN14EmailClientApi24NmApiMailboxSettingsData13clearSettingsEv @ 260 NONAME
+	_ZN14EmailClientApi24NmApiMailboxSettingsData8setValueEiRK8QVariant @ 261 NONAME
+	_ZN14EmailClientApi24NmApiMailboxSettingsDataC1Ev @ 262 NONAME
+	_ZN14EmailClientApi24NmApiMailboxSettingsDataC2Ev @ 263 NONAME
+	_ZN14EmailClientApi24NmApiMailboxSettingsDataD1Ev @ 264 NONAME
+	_ZN14EmailClientApi24NmApiMailboxSettingsDataD2Ev @ 265 NONAME
+	_ZNK14EmailClientApi19NmApiMessageManager10metaObjectEv @ 266 NONAME
+	_ZNK14EmailClientApi20NmApiMailboxSettings10metaObjectEv @ 267 NONAME
+	_ZNK14EmailClientApi24NmApiMailboxSettingsData12listSettingsEv @ 268 NONAME
+	_ZNK14EmailClientApi24NmApiMailboxSettingsData12validateDataEv @ 269 NONAME
+	_ZNK14EmailClientApi24NmApiMailboxSettingsData8getValueEiR8QVariant @ 270 NONAME
+	_ZNK14EmailClientApi24NmApiMailboxSettingsData9mailboxIdEv @ 271 NONAME
+	_ZTIN14EmailClientApi19NmApiMessageManagerE @ 272 NONAME
+	_ZTIN14EmailClientApi20NmApiMailboxSettingsE @ 273 NONAME
+	_ZTVN14EmailClientApi19NmApiMessageManagerE @ 274 NONAME
+	_ZTVN14EmailClientApi20NmApiMailboxSettingsE @ 275 NONAME
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/inc/nmapisettingsmanager_p.h	Wed Aug 18 09:37:47 2010 +0300
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef NMAPISETTINGSMANAGER_P_H_
+#define NMAPISETTINGSMANAGER_P_H_
+
+#include <QVariant>
+
+#include <nmapimailboxsettingsdata.h>
+#include <cemailaccounts.h>
+
+class CImImap4Settings;
+class CImSmtpSettings;
+class XQSettingsManager;
+class XQCentralRepositoryUtils;
+
+namespace EmailClientApi
+{
+
+class NmApiSettingsManagerPrivate
+{
+public:
+    NmApiSettingsManagerPrivate(const quint64 mailboxId);
+    ~NmApiSettingsManagerPrivate();
+
+    bool load(quint64 mailboxId, NmApiMailboxSettingsData &data);
+    bool save(const NmApiMailboxSettingsData &data);
+
+private:
+    bool writeSettingL(const NmApiMailboxSettingsData &data);
+    bool saveSettings();
+    bool readSetting(NmApiMailboxSettingsData &data);
+    bool readCenRepSetting(NmApiMailboxSettingsData &data);
+    QVariant readFromCenRep(quint32 key) const;
+    bool writeSettingToCenRep(const NmApiMailboxSettingsData &data);
+    bool writeToCenRep(quint32 key, const QVariant &value) const;
+    void setSecurity(QString securityType);
+    QString security() const;
+    QString alwaysOnlineState() const;
+    void setAlwaysOnlineState(const QVariant state);
+    void calculateMailboxOffset();
+    void calculateActiveProfileOffset();
+    qint32 convertToProfileOffset(int profile) const;
+    bool checkAccountType();
+    void initAccountL();
+
+private:
+    NmApiMailboxSettingsData *mSettingsData;
+
+    CEmailAccounts *mAccount;
+    CImPop3Settings *mPop3Settings;
+    CImImap4Settings *mImap4Settings;
+    CImSmtpSettings *mSmtpSettings;
+
+    TSmtpAccount mSmtpAccount;
+    TImapAccount mImap4Account;
+    TPopAccount mPop3Account;
+
+    QString mMailboxType;
+    qint32 mMailboxOffset;
+    qint32 mActiveProfileOffset;
+    XQSettingsManager *mQSettingsManager;
+
+    quint32 mMailboxId;
+};
+
+} //namespace EmailClientApi
+
+#endif // NMAPISETTINGSMANAGER_P_H_
--- a/emailservices/nmclientapi/nmclientapi.pro	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/nmclientapi/nmclientapi.pro	Wed Aug 18 09:37:47 2010 +0300
@@ -50,6 +50,7 @@
            nmapimessageenvelope.h \
            nmapimessagetask.h \
            nmapimessagemanager.h \
+           nmapisettingsmanager.h \
            nmapimailboxsettings.h
 
 # private headers 
@@ -67,6 +68,7 @@
            inc/nmapimessagebody_p.h \
            inc/nmapimessageenvelope_p.h \
            inc/nmapimessagemanager_p.h \
+	   inc/nmapisettingsmanager_p.h \
            inc/nmapipopimapsettingsmanager.h \
            inc/nmapiprivateclasses.h \
            inc/nmapitypesconverter.h \
@@ -96,6 +98,8 @@
            src/nmapipopimapsettingsmanager.cpp \
 	         src/nmapimessagemanager_p.cpp \
 			     src/nmapimessagemanager.cpp \
+	   src/nmapisettingsmanager_p.cpp \
+	   src/nmapisettingsmanager.cpp \
            src/nmapitypesconverter.cpp 
 
 
--- a/emailservices/nmclientapi/src/nmapimailboxsettings_p.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/nmclientapi/src/nmapimailboxsettings_p.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -16,6 +16,7 @@
  */
 
 #include "nmapiheaders.h"
+#include <nmapisettingsmanager.h>
 
 
 namespace EmailClientApi
@@ -64,16 +65,15 @@
 bool NmApiMailboxSettingsPrivate::loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data)
 {
     NM_FUNCTION;
-    Q_UNUSED(mailboxId);
-    Q_UNUSED(data);
-    return false;
+    QScopedPointer<NmApiSettingsManager> settingsManager(new NmApiSettingsManager(mailboxId));  
+    return settingsManager->load(mailboxId, data);
 }
 
 bool NmApiMailboxSettingsPrivate::saveSettings(const NmApiMailboxSettingsData &data)
 {
     NM_FUNCTION;
-    Q_UNUSED(data);
-    return false;
+    QScopedPointer<NmApiSettingsManager> settingsManager(new NmApiSettingsManager(data.mailboxId()));  
+    return settingsManager->save(data);
 }
 
 bool NmApiMailboxSettingsPrivate::createMailbox(
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapisettingsmanager.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#include <nmapisettingsmanager.h>
+#include "nmapisettingsmanager_p.h"
+#include "nmapiheaders.h"
+
+namespace EmailClientApi
+{
+
+NmApiSettingsManager::NmApiSettingsManager(const quint64 mailboxId)
+{    
+    d = new NmApiSettingsManagerPrivate(mailboxId);
+}
+
+NmApiSettingsManager::~NmApiSettingsManager()
+{    
+    delete d;
+}
+/*!     
+ Loads email settings.
+ \param mailboxId which settings are returned
+ \param data consists of keys and values of settings.
+ \return bool <true> when the setting items were found otherwise <false>.
+ */
+bool NmApiSettingsManager::load(quint64 mailboxId, NmApiMailboxSettingsData &data)
+{
+    return d->load(mailboxId, data);
+}
+
+/*!     
+ Saves email settings.
+ \param data consists of keys and values of settings.
+ \return bool <true> when the setting items were successfully saved otherwise <false>.
+ */
+bool NmApiSettingsManager::save(const NmApiMailboxSettingsData &data)
+{
+    return d->save(data);
+}
+
+} // end namespace
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapisettingsmanager_p.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -0,0 +1,782 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include <QVariant>
+#include <QList>
+
+#include <xqconversions.h>
+#include <xqsettingsmanager.h>
+#include <xqcentralrepositoryutils.h>
+#include <xqcentralrepositorysearchcriteria.h>
+
+#include <pop3set.h>
+#include <imapset.h>
+#include <smtpset.h>
+#include <iapprefs.h>
+
+#include "ipssettingkeys.h"
+#include "nmapiheaders.h"
+#include <nmapisettingsmanager.h>
+#include "nmapisettingsmanager_p.h"
+
+namespace EmailClientApi
+{
+
+NmApiSettingsManagerPrivate::NmApiSettingsManagerPrivate(const quint64 mailboxId)
+    : mAccount(0),
+    mPop3Settings(0),
+    mImap4Settings(0),
+    mSmtpSettings(0),
+    mMailboxOffset(-1),
+    mMailboxId(0)
+{
+    QT_TRAP_THROWING(mAccount = CEmailAccounts::NewL());
+    mMailboxId = (quint32)mailboxId;
+
+    mQSettingsManager = new XQSettingsManager();
+    Q_CHECK_PTR(mQSettingsManager);
+
+    checkAccountType();
+    QT_TRAP_THROWING(initAccountL());
+    calculateMailboxOffset();
+
+}
+
+NmApiSettingsManagerPrivate::~NmApiSettingsManagerPrivate()
+{
+    delete mPop3Settings;
+    delete mImap4Settings;
+    delete mSmtpSettings;
+    delete mQSettingsManager;
+    delete mAccount;
+}
+
+/*!
+ Loads QMail specific settings.
+ \param mailboxId which settings are returned
+ \param data consists of keys and values of settings.
+ \return bool <true> when the setting items were found otherwise <false>.
+ */
+bool NmApiSettingsManagerPrivate::load(quint64 mailboxId, NmApiMailboxSettingsData &data)
+{
+	mMailboxId = mailboxId;
+    return (readSetting(data) && readCenRepSetting(data));
+}
+
+/*!
+ Saves QMail specific settings.
+ \param data consists of keys and values of settings.
+ \return bool <true> when the setting items were successfully saved otherwise <false>.
+ */
+bool NmApiSettingsManagerPrivate::save(const NmApiMailboxSettingsData &data)
+{
+    TInt err(KErrNone);
+    TRAP(err, writeSettingL(data));
+    return (!err && writeSettingToCenRep(data));
+}
+
+/*!
+ Finds and returns the SMTP specific setting.
+ \param settingItem SettingItem enum of the setting to return
+ \param QVariant SettingValue of the found setting value.
+ \return bool <true> when the setting item was found otherwise <false>.
+ */
+bool NmApiSettingsManagerPrivate::readSetting(NmApiMailboxSettingsData &data)
+{
+    if (mMailboxType == NmApiMailboxTypePop) {
+        data.setValue(IncomingLoginName, XQConversions::s60Desc8ToQString(mPop3Settings->LoginName()));
+        data.setValue(IncomingPassword, XQConversions::s60Desc8ToQString(mPop3Settings->Password()));
+        data.setValue(MailboxName, XQConversions::s60DescToQString(mPop3Account.iPopAccountName));
+        data.setValue(IncomingMailServer, XQConversions::s60DescToQString(mPop3Settings->ServerAddress()));
+#if (defined SYMBIAN_EMAIL_CAPABILITY_SUPPORT)
+        data.setValue(IncomingMailUsesAuthentication, mPop3Settings->POP3Auth());
+#endif
+        data.setValue(IncomingPort, mPop3Settings->Port());
+    }
+    else if (mMailboxType  == NmApiMailboxTypeImap) {
+        data.setValue(IncomingLoginName, XQConversions::s60Desc8ToQString(mImap4Settings->LoginName()));
+        data.setValue(IncomingPassword, XQConversions::s60Desc8ToQString(mImap4Settings->Password()));
+        data.setValue(MailboxName, XQConversions::s60DescToQString(
+                mImap4Account.iImapAccountName));
+        data.setValue(IncomingMailServer, XQConversions::s60DescToQString(
+                mImap4Settings->ServerAddress()));
+#if (defined SYMBIAN_EMAIL_CAPABILITY_SUPPORT)
+        data.setValue(IncomingMailUsesAuthentication, mImap4Settings->IAMP4Auth());
+#endif
+        data.setValue(IncomingPort, mImap4Settings->Port());
+        data.setValue(FolderPath, XQConversions::s60Desc8ToQString(mImap4Settings->FolderPath()));
+    }
+
+    data.setValue(IncomingMailSecurityType, security());
+    data.setValue(MyName, XQConversions::s60DescToQString(mSmtpSettings->EmailAlias()));
+    data.setValue(EmailAlias, XQConversions::s60DescToQString(mSmtpSettings->EmailAlias()));
+    data.setValue(EmailAddress, XQConversions::s60DescToQString(mSmtpSettings->EmailAddress()));
+    data.setValue(ReplyAddress, XQConversions::s60DescToQString(mSmtpSettings->ReplyToAddress()));
+    data.setValue(OutgoingMailServer, XQConversions::s60DescToQString(mSmtpSettings->ServerAddress()));
+    data.setValue(OutgoingPort, mSmtpSettings->Port());
+    data.setValue(OutgoingLoginName, XQConversions::s60Desc8ToQString(mSmtpSettings->LoginName()));
+    data.setValue(OutgoingPassword, XQConversions::s60Desc8ToQString(mSmtpSettings->Password()));
+    data.setValue(UseOutgoingAuthentication, mSmtpSettings->SMTPAuth());
+    data.setValue(OutgoingMailUsesAuthentication, mSmtpSettings->SMTPAuth());
+    data.setValue(OutgoingSecureSockets, mSmtpSettings->SecureSockets());
+    data.setValue(OutgoingSSLWrapper, mSmtpSettings->SSLWrapper());
+    data.setValue(OutgoingMailSecurityType, XQConversions::s60Desc8ToQString(mSmtpSettings->TlsSslDomain()));
+    return true;
+}
+
+bool NmApiSettingsManagerPrivate::readCenRepSetting(NmApiMailboxSettingsData &data)
+{
+    bool ret = true;
+    QVariant tmp;
+    data.setValue(DownloadPictures, readFromCenRep(IpsServices::EmailKeyPreferenceDownloadPictures));
+    data.setValue(MessageDivider, readFromCenRep(IpsServices::EmailKeyPreferenceMessageDivider));
+
+    tmp = readFromCenRep(IpsServices::EmailKeyReceptionActiveProfile);
+    switch(tmp.toInt()){
+        case 0:
+            data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetKUTD);
+            break;
+        case 1:
+            data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetSE);
+            break;
+        case 2:
+            data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetMF);
+            break;
+        case 3:
+            data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetUD);
+            break;
+        default:
+            data.setValue(ReceptionActiveProfile, EmailClientApi::EmailProfileOffsetKUTD);
+            break;
+    };
+
+    data.setValue(ReceptionUserDefinedProfile, readFromCenRep(IpsServices::EmailKeyReceptionUserDefinedProfile));
+    data.setValue(ReceptionInboxSyncWindow, readFromCenRep(mActiveProfileOffset
+                        + IpsServices::EmailKeyReceptionInboxSyncWindow));
+    data.setValue(ReceptionGenericSyncWindowInMessages, readFromCenRep(mActiveProfileOffset
+                        + IpsServices::EmailKeyReceptionGenericSyncWindowInMessages));
+    data.setValue(ReceptionWeekDays, readFromCenRep(mActiveProfileOffset
+                        + IpsServices::EmailKeyReceptionWeekDays));
+    data.setValue(ReceptionDayStartTime, readFromCenRep(mActiveProfileOffset
+                        + IpsServices::EmailKeyReceptionDayStartTime));
+    data.setValue(ReceptionDayEndTime, readFromCenRep(mActiveProfileOffset
+                        + IpsServices::EmailKeyReceptionDayEndTime));
+    data.setValue(ReceptionRefreshPeriodDayTime, readFromCenRep(mActiveProfileOffset
+                        + IpsServices::EmailKeyReceptionRefreshPeriodDayTime));
+    data.setValue(ReceptionRefreshPeriodOther, readFromCenRep(mActiveProfileOffset
+                        + IpsServices::EmailKeyReceptionRefreshPeriodOther));
+    data.setValue(UserNameHidden, readFromCenRep(IpsServices::EmailKeyUserNameHidden));
+    data.setValue(EmailNotificationState, readFromCenRep(IpsServices::EmailKeyEMNState));
+    data.setValue(FirstEmnReceived, readFromCenRep(IpsServices::EmailKeyFirstEmnReceived));
+    data.setValue(EmnReceivedNotSynced, readFromCenRep(IpsServices::EmailKeyEmnReceivedNotSynced));
+
+    QString aolState = alwaysOnlineState();
+    if(aolState.length()>0)
+        data.setValue(AlwaysOnlineState, aolState);
+
+    data.setValue(AoLastSuccessfulUpdate, readFromCenRep(IpsServices::EmailKeyAoLastSuccessfulUpdateL));
+    data.setValue(AoLastUpdateFailed, readFromCenRep(IpsServices::EmailKeyAoLastUpdateFailed));
+    data.setValue(AoUpdateSuccessfulWithCurSettings, readFromCenRep(IpsServices::EmailKeyAoUpdateSuccessfulWithCurSettings));
+    return ret;
+}
+
+/*!
+ Writes POP3/IMAP4 specific settings.
+ \param data consists of keys and values of settings.
+ */
+bool NmApiSettingsManagerPrivate::writeSettingL(const NmApiMailboxSettingsData &data)
+{
+    HBufC *tmp = 0;
+    HBufC8 *tmp8 = 0;
+    bool ret(false);
+    int key;
+    QVariant settingValue;
+    QList<int> keylist;
+    bool aliasSet = false;
+
+    keylist = data.listSettings();
+    for (int i = 0; i < keylist.size(); i++) {
+        key = keylist[i];
+        data.getValue(key, settingValue);
+        switch (key) {
+            case IncomingLoginName: {
+                tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString());
+                if (mMailboxType == NmApiMailboxTypePop) {
+                    mPop3Settings->SetLoginNameL(*tmp8);
+                }
+                else if (mMailboxType == NmApiMailboxTypeImap) {
+                    mImap4Settings->SetLoginNameL(*tmp8);
+                    }
+                delete tmp8;
+                break;
+            }
+            case IncomingPassword: {
+                tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString());
+                if (mMailboxType == NmApiMailboxTypePop) {
+                    mPop3Settings->SetPasswordL(*tmp8);
+                }
+                else if (mMailboxType == NmApiMailboxTypeImap) {
+                    mImap4Settings->SetPasswordL(*tmp8);
+                    }
+                delete tmp8;
+                break;
+            }
+            case MailboxName: {
+                tmp = XQConversions::qStringToS60Desc(settingValue.toString());
+                if (mMailboxType == NmApiMailboxTypePop) {
+                    mPop3Account.iPopAccountName.Copy(*tmp);
+                }
+                else if (mMailboxType == NmApiMailboxTypeImap) {
+                    mImap4Account.iImapAccountName.Copy(*tmp);
+                    }
+                delete tmp;
+                break;
+            }
+            case IncomingMailServer: {
+                tmp = XQConversions::qStringToS60Desc(settingValue.toString());
+
+                if (mMailboxType == NmApiMailboxTypePop) {
+                    mPop3Settings->SetServerAddressL(*tmp);
+                }
+                else if (mMailboxType == NmApiMailboxTypeImap) {
+                    mImap4Settings->SetServerAddressL(*tmp);
+                    }
+                delete tmp;
+                break;
+            }
+            case IncomingMailUsesAuthentication: {
+#if (defined SYMBIAN_EMAIL_CAPABILITY_SUPPORT)
+
+                if (mMailboxType == NmApiMailboxTypePop) {
+                    mPop3Settings->SetPOP3Auth(settingValue.toBool());
+                }
+                else if (mMailboxType == NmApiMailboxTypeImap) {
+                    mImap4Settings->SetIAMP4Auth(settingValue.toBool());
+                }
+#endif
+                break;
+            }
+            case IncomingMailSecurityType: {
+                setSecurity(settingValue.toString());
+                break;
+            }
+            case IncomingPort: {
+                if (mMailboxType == NmApiMailboxTypePop) {
+                mPop3Settings->SetPort(settingValue.toInt());
+                }
+                else if (mMailboxType == NmApiMailboxTypeImap) {
+                    mImap4Settings->SetPort(settingValue.toInt());
+                }
+                break;
+            }
+            case OutgoingPort: {
+                mSmtpSettings->SetPort(settingValue.toInt());
+                break;
+            }
+            case IncomingSecureSockets: {
+                if (mMailboxType == NmApiMailboxTypePop) {
+                    mPop3Settings->SetSecureSockets(settingValue.toBool());
+                 }
+                 else if (mMailboxType == NmApiMailboxTypeImap) {
+                    mImap4Settings->SetSecureSockets(settingValue.toBool());
+                     }
+                break;
+            }
+            case IncomingSSLWrapper: {
+                if (mMailboxType == NmApiMailboxTypePop) {
+                    mPop3Settings->SetSSLWrapper(settingValue.toBool());
+                }
+                else if (mMailboxType == NmApiMailboxTypeImap) {
+                    mImap4Settings->SetSSLWrapper(settingValue.toBool());
+                    }
+                break;
+            }
+            case EmailAddress: {
+                tmp = XQConversions::qStringToS60Desc(settingValue.toString());
+                mSmtpSettings->SetEmailAddressL(*tmp);
+                break;
+            }
+            case ReplyAddress: {
+                tmp = XQConversions::qStringToS60Desc(settingValue.toString());
+                mSmtpSettings->SetReplyToAddressL(*tmp);
+                break;
+            }
+            case EmailAlias: {
+                QVariant tmpName;
+                if(data.getValue(MyName,tmpName)) {
+                    if(tmpName.toString()
+                        ==XQConversions::s60DescToQString(mSmtpSettings->EmailAlias())) {
+                        aliasSet = true;
+                    }
+                }
+                tmp = XQConversions::qStringToS60Desc(settingValue.toString());
+                mSmtpSettings->SetEmailAliasL(*tmp);
+                break;
+            }
+            case MyName: {
+                if(!aliasSet) {
+                tmp = XQConversions::qStringToS60Desc(settingValue.toString());
+                mSmtpSettings->SetEmailAliasL(*tmp);
+                }
+                break;
+            }
+            case OutgoingMailServer: {
+                tmp = XQConversions::qStringToS60Desc(settingValue.toString());
+                mSmtpSettings->SetServerAddressL(*tmp);
+                break;
+            }
+            case OutgoingLoginName: {
+                tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString());
+                mSmtpSettings->SetLoginNameL(*tmp8);
+                break;
+            }
+            case OutgoingPassword: {
+                tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString());
+                mSmtpSettings->SetPasswordL(*tmp8);
+                break;
+            }
+            case UseOutgoingAuthentication:
+            case OutgoingMailUsesAuthentication: {
+                mSmtpSettings->SetSMTPAuth(settingValue.toBool());
+                break;
+            }
+            case OutgoingSecureSockets: {
+                mSmtpSettings->SetSecureSockets(settingValue.toBool());
+                break;
+            }
+            case OutgoingSSLWrapper: {
+                mSmtpSettings->SetSSLWrapper(settingValue.toBool());
+                break;
+            }
+            case OutgoingMailSecurityType: {
+                tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString());
+                mSmtpSettings->SetTlsSslDomainL(*tmp8);
+                break;
+            }
+            case FolderPath: {
+                tmp8 = XQConversions::qStringToS60Desc8(settingValue.toString());
+                mImap4Settings->SetFolderPathL(*tmp8);
+                break;
+            }
+            default: {
+				break;
+            }
+        };
+    }
+    ret = saveSettings();
+    return ret;
+}
+
+/*!
+Writes settings to central repository.
+\param data consists of keys and values of settings.
+ */
+bool NmApiSettingsManagerPrivate::writeSettingToCenRep(
+    const NmApiMailboxSettingsData &data)
+{
+    int key;
+    QVariant settingValue;
+    QList<int> keylist;
+
+    keylist = data.listSettings();
+    bool ret = false;
+    if(keylist.contains(ReceptionActiveProfile)) {
+        data.getValue(ReceptionActiveProfile,settingValue);
+        QVariant profileOffset = 0;
+        if(settingValue.toString() == EmailClientApi::EmailProfileOffsetKUTD) {
+            profileOffset=0;
+        } else if(settingValue.toString() == EmailClientApi::EmailProfileOffsetSE){
+            profileOffset = 1;
+        } else if (settingValue.toString() == EmailClientApi::EmailProfileOffsetMF){
+                    profileOffset = 2;
+        } else if (settingValue.toString() == EmailClientApi::EmailProfileOffsetUD) {
+            profileOffset = 3;
+        }
+        ret = writeToCenRep(IpsServices::EmailKeyReceptionActiveProfile, profileOffset);
+        if(ret) {
+            calculateActiveProfileOffset();
+        }
+    }
+    if (ret) {
+        for (int i = 0; i < keylist.size(); i++) {
+            key = keylist[i];
+            data.getValue(key, settingValue);
+            switch (key) {
+                case DownloadPictures: {
+                    ret = writeToCenRep(IpsServices::EmailKeyPreferenceDownloadPictures,
+                        settingValue);
+                    break;
+                }
+                case MessageDivider: {
+                    ret = writeToCenRep(IpsServices::EmailKeyPreferenceMessageDivider, settingValue);
+                    break;
+                }
+                case ReceptionUserDefinedProfile: {
+                    ret = writeToCenRep(IpsServices::EmailKeyReceptionUserDefinedProfile,
+                        settingValue);
+                    break;
+                }
+                case ReceptionInboxSyncWindow: {
+                    ret = writeToCenRep(mActiveProfileOffset
+                        + IpsServices::EmailKeyReceptionInboxSyncWindow, settingValue);
+                    break;
+                }
+                case ReceptionGenericSyncWindowInMessages: {
+                    ret = writeToCenRep(mActiveProfileOffset
+                        + IpsServices::EmailKeyReceptionGenericSyncWindowInMessages, settingValue);
+                    break;
+                }
+                case ReceptionWeekDays: {
+                    ret = writeToCenRep(mActiveProfileOffset + IpsServices::EmailKeyReceptionWeekDays,
+                        settingValue);
+                    break;
+                }
+                case ReceptionDayStartTime: {
+                    ret = writeToCenRep(mActiveProfileOffset + IpsServices::EmailKeyReceptionDayStartTime,
+                        settingValue);
+                    break;
+                }
+                case ReceptionDayEndTime: {
+                    ret = writeToCenRep(mActiveProfileOffset + IpsServices::EmailKeyReceptionDayEndTime,
+                        settingValue);
+                    break;
+                }
+                case ReceptionRefreshPeriodDayTime: {
+                    ret = writeToCenRep(mActiveProfileOffset
+                        + IpsServices::EmailKeyReceptionRefreshPeriodDayTime, settingValue);
+                    break;
+                }
+                case ReceptionRefreshPeriodOther: {
+                    ret = writeToCenRep(mActiveProfileOffset
+                        + IpsServices::EmailKeyReceptionRefreshPeriodOther, settingValue);
+                    break;
+                }
+                case UserNameHidden: {
+                    ret = writeToCenRep(IpsServices::EmailKeyUserNameHidden, settingValue);
+                    break;
+                }
+                case EmailNotificationState: {
+                    ret = writeToCenRep(IpsServices::EmailKeyEMNState, settingValue);
+                    break;
+                }
+                case FirstEmnReceived: {
+                    ret = writeToCenRep(IpsServices::EmailKeyFirstEmnReceived, settingValue);
+                    break;
+                }
+                case EmnReceivedNotSynced: {
+                    ret = writeToCenRep(IpsServices::EmailKeyEmnReceivedNotSynced, settingValue);
+                    break;
+                }
+                case AlwaysOnlineState: {
+                    setAlwaysOnlineState(settingValue);
+                    break;
+                }
+                case AoLastSuccessfulUpdate: {
+                    ret = writeToCenRep(IpsServices::EmailKeyAoLastSuccessfulUpdateL, settingValue);
+                    break;
+                }
+                case AoLastUpdateFailed: {
+                    ret = writeToCenRep(IpsServices::EmailKeyAoLastUpdateFailed, settingValue);
+                    break;
+                }
+                case AoUpdateSuccessfulWithCurSettings: {
+                    ret = writeToCenRep(IpsServices::EmailKeyAoUpdateSuccessfulWithCurSettings,
+                        settingValue);
+                    break;
+                }
+                case ReceptionActiveProfile:
+                default: {
+                    break;
+                }
+            };
+        }
+    }
+    return ret;
+}
+/*!
+ Stores the POP3/IMAP4 specific settings.
+ \return bool <true> when the settings were succesfully written, otherwise <false>.
+ */
+bool NmApiSettingsManagerPrivate::saveSettings()
+{
+    bool ret(false);
+    if (mMailboxType == NmApiMailboxTypePop) {
+        TRAPD(err, mAccount->SavePopSettingsL(mPop3Account, *mPop3Settings));
+        if (err == KErrNone) {
+            ret = true;
+        }
+    }
+    else if (mMailboxType == NmApiMailboxTypeImap) {
+        TRAPD(err, mAccount->SaveImapSettingsL(mImap4Account, *mImap4Settings));
+        if (err == KErrNone) {
+            ret = true;
+        }
+    }
+    return ret;
+}
+
+/*!
+ Reads a key value from the Central Repository.
+ \param key Key identifier.
+ \return the settings value for the given key.
+ */
+QVariant NmApiSettingsManagerPrivate::readFromCenRep(quint32 key) const
+{
+    XQCentralRepositorySettingsKey settingKey(IpsServices::EmailMailboxSettingRepository,
+        mMailboxOffset + key);
+    return mQSettingsManager->readItemValue(settingKey);
+}
+
+/*!
+ Writes a key value to the Central Repository.
+ \param key Key identifier.
+ \param value The settings value for the given key.
+ \return Returns <true> if the value was succesfully written, <false> if not.
+ */
+bool NmApiSettingsManagerPrivate::writeToCenRep(quint32 key, const QVariant &value) const
+{
+    XQCentralRepositorySettingsKey settingKey(IpsServices::EmailMailboxSettingRepository,
+        mMailboxOffset + key);
+    return mQSettingsManager->writeItemValue(settingKey, value);
+}
+
+void NmApiSettingsManagerPrivate::setSecurity(QString securityType)
+{
+    if (securityType == NmApiStartTls) {
+        if (mMailboxType == NmApiMailboxTypePop) {
+            mPop3Settings->SetSecureSockets(ETrue);
+            mPop3Settings->SetSSLWrapper(EFalse);
+        }
+        else {
+            mImap4Settings->SetSecureSockets(ETrue);
+            mImap4Settings->SetSSLWrapper(EFalse);
+        }
+    }
+    else if (securityType == NmApiSSLTls) {
+        if (mMailboxType == NmApiMailboxTypePop) {
+            mPop3Settings->SetSecureSockets(EFalse);
+            mPop3Settings->SetSSLWrapper(ETrue);
+        }
+        else {
+            mImap4Settings->SetSecureSockets(EFalse);
+            mImap4Settings->SetSSLWrapper(ETrue);
+        }
+    }
+    else {
+        if (mMailboxType == NmApiMailboxTypePop) {
+            mPop3Settings->SetSecureSockets(EFalse);
+            mPop3Settings->SetSSLWrapper(EFalse);
+        }
+        else {
+            mImap4Settings->SetSecureSockets(EFalse);
+            mImap4Settings->SetSSLWrapper(EFalse);
+        }
+    }
+}
+
+QString NmApiSettingsManagerPrivate::security() const
+{
+    bool ss(false);
+    bool sslw(false);
+    QString securityType("");
+
+    if (mMailboxType == NmApiMailboxTypePop) {
+        ss = mPop3Settings->SecureSockets();
+        sslw = mPop3Settings->SSLWrapper();
+    }
+    else {
+        ss = mImap4Settings->SecureSockets();
+        sslw = mImap4Settings->SSLWrapper();
+    }
+
+    if (ss == true && sslw == false) {
+        securityType = NmApiStartTls;
+    }
+    else if (ss == false && sslw == true) {
+        securityType = NmApiSSLTls;
+    }
+    else {
+        securityType = NmApiSecurityOff;
+    }
+    return securityType;
+}
+
+/*!
+
+ */
+QString NmApiSettingsManagerPrivate::alwaysOnlineState() const
+{
+    TInt profile = IpsServices::EmailSyncProfileManualFetch;
+    QString ret = NmApiOff;
+
+    QVariant state;
+    TInt settingValue = -1;
+    state = readFromCenRep(IpsServices::EmailKeyReceptionActiveProfile);
+    settingValue = state.toInt();
+
+    if (settingValue >= 0) {
+        profile = settingValue;
+        if (profile != IpsServices::EmailSyncProfileManualFetch) {
+            ret = NmApiAlways;
+        }
+    }
+    return ret;
+}
+
+/*!
+
+ */
+void NmApiSettingsManagerPrivate::setAlwaysOnlineState(const QVariant state)
+{
+    //only allowed to switch state off, not on.
+    if (state.toString() == NmApiOff) {
+        writeToCenRep(IpsServices::EmailKeyReceptionActiveProfile,
+            IpsServices::EmailSyncProfileManualFetch);
+    }
+}
+
+void NmApiSettingsManagerPrivate::calculateMailboxOffset()
+{
+    // Find all the keys that match the criteria 0xZZZZZ000, where Z=don't care.
+    // This will give us all the keys that hold the mailbox ids, e.g. 0x00001000, 0x00002000, etc.
+    quint32 partialKey(0x00000000);
+    quint32 bitMask(0x00000FFF);
+    XQCentralRepositorySearchCriteria criteria(IpsServices::EmailMailboxSettingRepository,
+        partialKey, bitMask);
+    // Set the mailbox id is value criteria for the search.
+    criteria.setValueCriteria((int) mMailboxId);
+
+    // Find the keys.
+    XQCentralRepositoryUtils utils(*mQSettingsManager);
+    QList<XQCentralRepositorySettingsKey> foundKeys = utils.findKeys(criteria);
+
+    // We should only get one key as a result.
+    if (foundKeys.count() == 1) {
+        mMailboxOffset = foundKeys[0].key();
+        calculateActiveProfileOffset();
+    }
+    else {
+        mActiveProfileOffset = -1;
+        mMailboxOffset = -1;
+    }
+}
+
+/*!
+ Calculates the active reception schedule profile offset.
+ */
+void NmApiSettingsManagerPrivate::calculateActiveProfileOffset()
+{
+    QVariant activeProfile = readFromCenRep(IpsServices::EmailKeyReceptionActiveProfile);
+    mActiveProfileOffset = convertToProfileOffset(activeProfile.toInt());
+}
+
+/*!
+
+ */
+qint32 NmApiSettingsManagerPrivate::convertToProfileOffset(int profile) const
+{
+    quint32 profileOffset(0);
+    // Possible values are defined in ipssettingkeys.h
+    switch (profile) {
+        case 0: {
+            profileOffset = IpsServices::EmailProfileOffsetKUTD;
+            break;
+        }
+        case 1: {
+            profileOffset = IpsServices::EmailProfileOffsetSE;
+            break;
+        }
+        case 2: {
+            profileOffset = IpsServices::EmailProfileOffsetMF;
+            break;
+        }
+        case 3: {
+            profileOffset = IpsServices::EmailProfileOffsetUD;
+            break;
+        }
+        default: {
+            break;
+        }
+    };
+
+    return profileOffset;
+}
+
+bool NmApiSettingsManagerPrivate::checkAccountType()
+{
+    bool identified = false;
+
+    RArray<TImapAccount> imapAccounts;
+    CleanupClosePushL(imapAccounts);
+    TRAPD(err, mAccount->GetImapAccountsL(imapAccounts));
+    if (err == KErrNone) {
+        for (int i=0; i < imapAccounts.Count(); ++i) {
+            TImapAccount account = imapAccounts[i];
+            if (account.iImapService == mMailboxId) {
+                mImap4Account = account;
+                mMailboxType = NmApiMailboxTypeImap;
+                identified = true;
+                break;
+            }
+        }
+    }
+    CleanupStack::PopAndDestroy(&imapAccounts);
+
+    if (!identified) {
+        RArray<TPopAccount> popAccounts;
+        CleanupClosePushL(popAccounts);
+        TRAPD(err, mAccount->GetPopAccountsL(popAccounts));
+        if (err == KErrNone) {
+            for (int i = 0; i < popAccounts.Count(); ++i) {
+                TPopAccount account = popAccounts[i];
+                if (popAccounts[i].iPopService == mMailboxId) {
+                    mPop3Account = account;
+                    mMailboxType = NmApiMailboxTypePop;
+                    identified = true;
+                    break;
+                }
+            }
+        }
+        CleanupStack::PopAndDestroy(&popAccounts);
+    }
+
+    return identified;
+}
+
+void NmApiSettingsManagerPrivate::initAccountL()
+{
+    if (mMailboxType == NmApiMailboxTypePop) {
+        mPop3Settings = new(ELeave) CImPop3Settings();
+        mAccount->LoadPopSettingsL(mPop3Account, *mPop3Settings);
+    }
+    else if (mMailboxType == NmApiMailboxTypeImap) {
+        mImap4Settings = new(ELeave) CImImap4Settings();
+        mAccount->LoadImapSettingsL(mImap4Account, *mImap4Settings);
+    }
+
+    mSmtpSettings = new(ELeave) CImSmtpSettings();
+
+    if (mMailboxType == NmApiMailboxTypePop) {
+        mAccount->GetSmtpAccountL(mPop3Account.iSmtpService, mSmtpAccount);
+    }
+    else if (mMailboxType == NmApiMailboxTypeImap) {
+        mAccount->GetSmtpAccountL(mImap4Account.iSmtpService, mSmtpAccount);
+    }
+    mAccount->LoadSmtpSettingsL(mSmtpAccount, *mSmtpSettings);
+}
+
+} // end namespace
--- a/emailservices/nmregister/src/nmmailboxregisterinterface.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailservices/nmregister/src/nmmailboxregisterinterface.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -54,7 +54,7 @@
 
 //parameter values
 const QString NmPublisherName("NmMailboxRegisterInterface");
-const QString NmLaunchUri("appto://0x200255BA?activityname=EmailInboxView&accountId=");
+const QString NmLaunchUri("appto://0x200255BA?activityname=EmailInboxView");
 //URI for the defined service
 const QLatin1String interfaceUri("com.nokia.symbian.IEmailRegisterAccount");
 
--- a/emailuis/nmailcpplugin/nmailcpplugin.pro	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailcpplugin/nmailcpplugin.pro	Wed Aug 18 09:37:47 2010 +0300
@@ -70,6 +70,6 @@
 
 TARGET.CAPABILITY = All -TCB
 plugin.sources = nmailcpplugin.dll
-plugin.path = \resource\qt\plugins\controlpanel
+plugin.path = /resource/qt/plugins/controlpanel
 DEPLOYMENT += plugin
 
--- a/emailuis/nmailui/conf/nmmessagelistviewitem.css	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/conf/nmmessagelistviewitem.css	Wed Aug 18 09:37:47 2010 +0300
@@ -1,32 +1,38 @@
-NmMessageListViewItem:portrait{
+NmMessageListViewItem:portrait {
   layout:portrait;
 }
 
-NmMessageListViewItem:landscape{
+NmMessageListViewItem:landscape {
   layout:landscape;
 }
 
-NmMessageListViewItem::sender{
-  fixed-height: var(hb-param-text-height-primary);    
+NmMessageListViewItem::sender {
+  fixed-height: var(hb-param-text-height-primary);
   text-align: left;
+  text-wrap-mode: no-wrap;
 }
+
 NmMessageListViewItem::time {
-  pref-height: var(hb-param-text-height-tiny);
-  pref-width: 13un;
-  size-policy: fixed, fixed;
+  fixed-height: var(hb-param-text-height-secondary);
+  fixed-width: 12un;
   text-align: right;
+  text-wrap-mode: no-wrap;
 }
-NmMessageListViewItem::subject{
-  fixed-height: var(hb-param-text-height-secondary);    
+
+NmMessageListViewItem::subject {
+  fixed-height: var(hb-param-text-height-secondary);
   text-align: left;
+  text-wrap-mode: no-wrap;
 }
-NmMessageListViewItem::icon1::icon{
-  pref-height: var(hb-param-graphic-size-secondary);
-  pref-width: var(hb-param-graphic-size-secondary); 
-  size-policy: fixed fixed;   
+
+NmMessageListViewItem::icon1::icon {
+  alignment: right;
+  fixed-height: var(hb-param-graphic-size-primary-small);
+  fixed-width: var(hb-param-graphic-size-primary-small);
 }
-NmMessageListViewItem::icon2::icon{
-  pref-height: var(hb-param-graphic-size-secondary);
-  pref-width: var(hb-param-graphic-size-secondary);
-  size-policy: fixed fixed;    
+
+NmMessageListViewItem::icon2::icon {
+  alignment: right;
+  fixed-height: var(hb-param-graphic-size-primary-small);
+  fixed-width: var(hb-param-graphic-size-primary-small);
 }
--- a/emailuis/nmailui/conf/nmmessagelistviewitem.widgetml	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/conf/nmmessagelistviewitem.widgetml	Wed Aug 18 09:37:47 2010 +0300
@@ -4,11 +4,11 @@
       <meshitem src="sender" srcEdge="TOP" dst="" dstEdge="TOP" spacing="-var(hb-param-margin-gene-top)"/>
       <meshitem src="sender" srcEdge="LEFT" dst="" dstEdge="LEFT" spacing="-var(hb-param-margin-gene-left)"/>
       <meshitem src="sender" srcEdge="BOTTOM" dst="subject" dstEdge="TOP" spacing="var(hb-param-margin-gene-bottom)"/> 
-                 
-      <meshitem src="time" srcEdge="CENTERV" dst="sender" dstEdge="CENTERV"/>
+             
       <meshitem src="time" srcEdge="LEFT" dst="sender" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-middle-horizontal)"/>
       <meshitem src="time" srcEdge="RIGHT" dst="" dstEdge="RIGHT" spacing="var(hb-param-margin-gene-right)"/>
-       
+      <meshitem src="time" srcEdge="BOTTOM" dst="sender" dstEdge="BOTTOM" spacing="0"/> 
+             
       <meshitem src="subject" srcEdge="LEFT" dst="" dstEdge="LEFT" spacing="-var(hb-param-margin-gene-left)"/>
       <meshitem src="subject" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" spacing="var(hb-param-margin-gene-bottom)"/>
       
--- a/emailuis/nmailui/conf/nmviewerheader.widgetml	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/conf/nmviewerheader.widgetml	Wed Aug 18 09:37:47 2010 +0300
@@ -10,7 +10,7 @@
       
       <meshitem src="subject" srcEdge="LEFT" dst="" dstEdge="LEFT" spacing="-var(hb-param-margin-gene-left)"/>
       <meshitem src="subject" srcEdge="RIGHT" dst="" dstEdge="RIGHT" spacing="var(hb-param-margin-gene-right)"/> 
-      <meshitem src="subject" srcEdge="TOP" dst="sent" dstEdge="BOTTOM" spacing="var(hb-param-margin-gene-middle-vertical)"/>
+      <meshitem src="subject" srcEdge="TOP" dst="sent" dstEdge="BOTTOM" spacing="-var(hb-param-margin-gene-middle-vertical)"/>
       <meshitem src="subject" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" spacing="var(hb-param-margin-gene-bottom)"/>
       
       <meshitem src="prioicon" srcEdge="CENTERV" dst="sent" dstEdge="CENTERV"/>      
--- a/emailuis/nmailui/inc/nmapplication.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/inc/nmapplication.h	Wed Aug 18 09:37:47 2010 +0300
@@ -44,7 +44,7 @@
 {
     Q_OBJECT
 public:
-    NmApplication(QObject *parent, quint32 accountId=0);
+    NmApplication(QObject *parent, quint64 accountId=0);
     ~NmApplication();
     void enterNmUiView(NmUiStartParam *startParam);
     HbMainWindow* mainWindow();
@@ -67,7 +67,15 @@
     void createMainWindow();
     void pushView(NmBaseView *view);
     void resetViewStack();
+    void hideApplication();
+    void updateActivity();
+    
+private slots:
+    void activityActivated();
 
+signals:
+	void applicationReady();
+    
 private:
     HbMainWindow *mMainWindow;              // Owned
     QStack<NmBaseView*> *mViewStack;        // Owned
@@ -91,6 +99,7 @@
     NmId mLastOperationMailbox;
     HbMessageBox *mQueryDialog;             // Owned
     bool mBackButtonPressed;
+    NmId mCurrentMailboxId;
 };
 
 #endif // NMAPPLICATION_H
--- a/emailuis/nmailui/inc/nmattachmentpicker.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/inc/nmattachmentpicker.h	Wed Aug 18 09:37:47 2010 +0300
@@ -21,6 +21,7 @@
 #include <QObject>
 
 class XQAiwRequest;
+class HbListWidgetItem;
 
 /**
  * This class manages launching of different attachment pickers 
@@ -41,7 +42,9 @@
     void fetchOther();  
     void fetchCameraStill();
     void fetchCameraVideo();
-
+    void selectFetcher(HbListWidgetItem *listItem);
+        
+    
 signals:
     void attachmentsFetchOk(const QVariant &fileNames);
     void attachmentsFetchError(int errorCode, const QString &errorMessage);
--- a/emailuis/nmailui/inc/nmeditorcontent.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/inc/nmeditorcontent.h	Wed Aug 18 09:37:47 2010 +0300
@@ -62,6 +62,7 @@
 
 public slots:
     void setEditorContentHeight();
+    void setEditorContentWidth();
     void ensureCursorVisibility();
 
 private:
@@ -75,6 +76,7 @@
     HbWidget *mScrollAreaContents; // Not owned
     QPointF mScrollPosition;
     NmApplication &mApplication;
+    bool mNeedForWidthAdjustment;
 };
 
 #endif /* NMEDITORCONTENT_H_ */
--- a/emailuis/nmailui/inc/nmeditorheader.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/inc/nmeditorheader.h	Wed Aug 18 09:37:47 2010 +0300
@@ -29,13 +29,15 @@
 class QGraphicsLinearLayout;
 class NmRecipientField;
 class NmAttachmentList; 
+class NmAttachmentListWidget;
+class NmApplication;
 
 class NmEditorHeader : public QObject
 {
 Q_OBJECT
 
 public:
-    NmEditorHeader(QObject *parent, HbDocumentLoader *documentLoader);
+    NmEditorHeader(QObject *parent, NmApplication &application, HbDocumentLoader *documentLoader);
     virtual ~NmEditorHeader();
     qreal headerHeight() const;
     NmHtmlLineEdit *subjectEdit() const;
@@ -53,6 +55,7 @@
         const QString &fileSize,
         int result);
     void setFieldVisibility(bool isVisible);
+    void adjustHeaderWidth();
 
 private:
     void loadWidgets();
@@ -70,26 +73,30 @@
     void editorContentChanged();
     void attachmentActivated(int arrayIndex);
     void attachmentLongPressed(int arrayIndex, QPointF point);
+    void repositHeader(const QPointF &scrollPosition);
 
 private:
+    NmApplication &mApplication;
     HbDocumentLoader* mDocumentLoader;  // Not owned
     qreal mHeaderHeight;
     HbLabel *mPriorityIcon; // Not owned
     HbLabel *mFollowUpIcon; // Not owned
     bool mIconVisible;
-    NmRecipientLineEdit *mToEdit; // Not owned
-    NmRecipientLineEdit *mCcEdit; // Not owned
-    NmRecipientLineEdit *mBccEdit; // Not owned
-    NmHtmlLineEdit *mSubjectEdit; // Not owned
+    NmRecipientLineEdit *mToEdit;      // Not owned
+    NmRecipientLineEdit *mCcEdit;      // Not owned
+    NmRecipientLineEdit *mBccEdit;     // Not owned
+    NmHtmlLineEdit *mSubjectEdit;      // Not owned
     bool mRecipientFieldsEmpty;
-    QGraphicsLinearLayout *mLayout; // Not owned
+    QGraphicsLinearLayout *mLayout;    // Not owned
     NmAttachmentList *mAttachmentList; // Not owned
+    NmAttachmentListWidget *mAttachmentListWidget; // Not owned
     NmRecipientField *mToField;    // Not owned
+    HbWidget *mToWidget;           // Not owned
     NmRecipientField *mCcField;    // Not owned
-    HbWidget *mCcWidget;    // Not owned
+    HbWidget *mCcWidget;           // Not owned
     NmRecipientField *mBccField;   // Not owned
-    HbWidget *mBccWidget;    // Not owned
-    HbWidget *mSubjectWidget;    // Not owned
+    HbWidget *mBccWidget;          // Not owned
+    HbWidget *mSubjectWidget;      // Not owned
     QGraphicsLinearLayout *mSubjectLayout; // Not owned
     bool mCcBccFieldVisible;
 };
--- a/emailuis/nmailui/inc/nmeditorview.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/inc/nmeditorview.h	Wed Aug 18 09:37:47 2010 +0300
@@ -45,6 +45,7 @@
 class HbMessageBox;
 class NmAttachmentManager;
 class HbVkbHost;
+class HbListWidget;
 
 class NmEditorView : public NmBaseView,
                      public NmActionObserver,
@@ -145,6 +146,9 @@
     NmAttachmentPicker* mAttachmentPicker; // Owned    
     bool mCcBccFieldVisible;
     QPointer<HbProgressDialog> mServiceSendingDialog; // Owned.
+    bool mIsNotFetchedBefore;
+	HbListWidget *mTBExtnContentWidget;		// Owned
+	QString mHiddenPriorityName;
 };
 
 
--- a/emailuis/nmailui/inc/nmmessagelistview.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/inc/nmmessagelistview.h	Wed Aug 18 09:37:47 2010 +0300
@@ -80,6 +80,7 @@
     void setMailboxName();
     void createToolBar();
     void setFolderName();
+    void updateSyncIcon();
 
 private:
     NmApplication &mApplication;
@@ -93,7 +94,6 @@
     NmMessageListModelItem *mLongPressedItem;  // Not owned
     HbLabel *mNoMessagesLabel;              // Not owned
     HbGroupBox *mFolderLabel;               // Not owned
-    HbLabel *mSyncIcon;                     // Not owned
     QModelIndex mActivatedIndex;
     bool mViewReady;
     NmFolderType mCurrentFolderType;
--- a/emailuis/nmailui/inc/nmmessagelistviewitem.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/inc/nmmessagelistviewitem.h	Wed Aug 18 09:37:47 2010 +0300
@@ -1,19 +1,19 @@
 /*
-* 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:
-*
-*/
+ * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
 
 #ifndef NMMESSAGELISTVIEWITEM_H_
 #define NMMESSAGELISTVIEWITEM_H_
@@ -32,7 +32,7 @@
 class NmMessageListViewItem : public HbTreeViewItem
 {
     Q_OBJECT
-
+    
 public:
     explicit NmMessageListViewItem(QGraphicsItem *parent = 0);
     virtual ~NmMessageListViewItem();
@@ -40,7 +40,7 @@
     HbTreeViewItem *createItem();
     bool canSetModelIndex(const QModelIndex &index) const;
     QRectF contiguousSelectionArea() const { return QRectF(); };
-
+    
 private:
     void createMessageItemLayout();
     void setContentsToMessageItem(const NmMessageEnvelope &envelope, bool dividersActive);
@@ -49,19 +49,17 @@
     void setFonts(const QColor &colorRole, HbFontSpec &fontSpec);
     void getFontSizes();    
     QString senderFieldText(const NmMessageEnvelope &envelope);
-
+    
 private:
-    HbTextItem *mSender;                   // Owned
-    HbTextItem *mSubject;                  // Owned
-    HbTextItem *mTime;                     // Owned
-    HbLabel *mDividerTitle;                // Owned
-    HbFrameItem *mNewMsgIcon;              // Owned
-    HbIconItem *mIcon1;                    // Owned
-    HbIconItem *mIcon2;                    // Owned
+    HbTextItem *mSender;      // Owned
+    HbTextItem *mSubject;     // Owned
+    HbTextItem *mTime;        // Owned
+    HbLabel *mDividerTitle;   // Owned
+    HbFrameItem *mNewMsgIcon; // Owned
+    HbIconItem *mIcon1;       // Owned
+    HbIconItem *mIcon2;       // Owned
     qreal mPrimarySize;
     qreal mSecondarySize;
-    qreal mTinySize;
 };
 
-
 #endif /* NMMESSAGELISTVIEWITEM_H_ */
--- a/emailuis/nmailui/inc/nmuiheaders.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/inc/nmuiheaders.h	Wed Aug 18 09:37:47 2010 +0300
@@ -92,6 +92,8 @@
 #include <hbindicator.h>
 #include <hbformatdialog.h>
 #include <hbshrinkingvkbhost.h>
+#include <hbactivitymanager.h>
+#include <hbframebackground.h>
 
 #include <cntservicescontact.h>
 #include <xqservicerequest.h>
@@ -103,6 +105,8 @@
 #include <xqsharablefile.h>
 #include <fmfiledialog.h>
 #include <xqaiwdecl.h>
+#include <afstorageglobals.h>
+#include <tstasksettings.h>
 
 #include <nmcommon.h>
 
--- a/emailuis/nmailui/inc/nmviewerheader.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/inc/nmviewerheader.h	Wed Aug 18 09:37:47 2010 +0300
@@ -26,7 +26,7 @@
 class NmViewerView;
 class HbTextItem;
 class HbGroupBox;
-class HbTextEdit;
+class HbLabel;
 class HbIconItem;
 
 class NmViewerHeader : public HbWidget
@@ -43,10 +43,7 @@
     void rescaleHeader(const QSizeF layoutReso);
     void setView(NmViewerView* view);
     void updateMessageData(NmMessage* message);
-    
-private slots:    
-    void cursorPositionChanged(int oldPos, int newPos); 
-    
+       
 private:
     void loadWidgets();
     void setHeaderData();
@@ -63,7 +60,7 @@
     HbTextItem *mSent;                     // Not owned
     HbIconItem *mPrioIcon;              // Not owned
     HbGroupBox *mHeaderBox;             // not owned
-    HbTextEdit *mRecipientsBox;         // Not owned
+    HbLabel *mRecipientsBox;         // Not owned
     NmViewerView *mViewerView;          // Not owned
 
 };
--- a/emailuis/nmailui/nmailui.pro	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/nmailui.pro	Wed Aug 18 09:37:47 2010 +0300
@@ -33,6 +33,7 @@
 LIBS += -lnmailuiwidgets
 LIBS += -lnmsettingui
 LIBS += -lnmutilities
+LIBS += -ltstaskmonitorclient
 
 symbian*: {
     INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
@@ -124,3 +125,10 @@
 RESOURCES += nmmessagelistviewitem.qrc
 RESOURCES += nmviewerheader.qrc
 TRANSLATIONS = mail.ts
+
+DOCML += conf/nmeditorview.docml \
+         conf/nmmailboxlistview.docml \
+         conf/nmmailboxselectiondialog.docml \
+         conf/nmmailviewer.docml \
+         conf/nmmessagelistview.docml \
+         conf/nmmessagesearchlistview.docml
--- a/emailuis/nmailui/nmailui.qrc	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/nmailui.qrc	Wed Aug 18 09:37:47 2010 +0300
@@ -1,13 +1,13 @@
 <RCC>
-    <qresource prefix="/docml" >
-        <file alias="nmeditorview.docml" >conf/nmeditorview.docml</file>
-        <file alias="nmmailboxlistview.docml" >conf/nmmailboxlistview.docml</file>
-        <file alias="nmmailboxselectiondialog.docml" >conf/nmmailboxselectiondialog.docml</file>
-        <file alias="nmmailviewer.docml" >conf/nmmailviewer.docml</file>
-        <file alias="nmmessagelistview.docml" >conf/nmmessagelistview.docml</file>
-        <file alias="nmmessagesearchlistview.docml" >conf/nmmessagesearchlistview.docml</file>
+    <qresource prefix="/docml">
+        <file alias="nmeditorview.docml">conf/nmeditorview.docml.bin</file>
+        <file alias="nmmailboxlistview.docml">conf/nmmailboxlistview.docml.bin</file>
+        <file alias="nmmailboxselectiondialog.docml">conf/nmmailboxselectiondialog.docml.bin</file>
+        <file alias="nmmailviewer.docml">conf/nmmailviewer.docml.bin</file>
+        <file alias="nmmessagelistview.docml">conf/nmmessagelistview.docml.bin</file>
+        <file alias="nmmessagesearchlistview.docml">conf/nmmessagesearchlistview.docml.bin</file>
     </qresource>
-    <qresource prefix="/effects" >
-        <file alias="mail_send.fxml" >resources/mail_send.fxml</file>
+    <qresource prefix="/effects">
+        <file alias="mail_send.fxml">resources/mail_send.fxml</file>
     </qresource>
 </RCC>
--- a/emailuis/nmailui/src/main.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/main.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -37,11 +37,11 @@
     app.setApplicationName(hbTrId("txt_mail_title_mail"));
     
     NmApplication *nmApplication = NULL;
-    quint32 accountId = 0;
+    quint64 accountId = 0;
+    QString activateId = app.activateId();
     if (app.activateReason() == Hb::ActivationReasonActivity &&
-        app.activateId() == NmActivityName) {
-        QVariant data = app.activateParams().take("accountId");
-        QString accountIdString = data.toString();
+            activateId.startsWith(NmActivityName) ) {
+        QString accountIdString = activateId.mid(NmActivityName.length());
         accountId = accountIdString.toULongLong();
         nmApplication = new NmApplication(&app,accountId);
     } else {
--- a/emailuis/nmailui/src/nmapplication.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmapplication.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -21,15 +21,18 @@
 
 static const QString NmSendServiceName = "nmail.com.nokia.symbian.IFileShare";
 
+static const QString NmActivityName = "EmailInboxView";
+
 /*!
     \class NmApplication
     \brief Application class, creates main window and handles view switching.
 */
 
+
 /*!
     Constructor.
 */
-NmApplication::NmApplication(QObject *parent, quint32 accountId)
+NmApplication::NmApplication(QObject *parent, quint64 accountId)
 : QObject(parent),
   mMainWindow(NULL),
   mViewStack(NULL),
@@ -75,18 +78,25 @@
     
     if(accountId != 0) {
         QVariant mailbox;
-        mailbox.setValue(mUiEngine->getPluginIdByMailboxId(accountId).id());
+        mailbox.setValue(accountId);
         mMailboxServiceInterface->displayInboxByMailboxId(mailbox);
     }
     
     mEffects = new NmUiEffects(*mMainWindow);
+    
+    QObject::connect(parent, SIGNAL(activate()), this, SLOT(activityActivated()));
 }
 
+
 /*!
     Destructor.
 */
 NmApplication::~NmApplication()
 {
+    // Remove the event filter early since catching application activated/
+    // deactivated events now may cause a crash.
+    QCoreApplication::instance()->removeEventFilter(this);
+
     if (mQueryDialog) {
         delete mQueryDialog;
         mQueryDialog = NULL;
@@ -102,6 +112,7 @@
     delete mViewStack;
     
     NmIcons::freeIcons();
+
     NmUiEngine::releaseInstance(mUiEngine);
     mUiEngine = NULL;
     
@@ -122,8 +133,9 @@
         if (mNetManager->cache()) {
             mNetManager->cache()->clear();
         }
-    delete mNetManager;
-    mNetManager = NULL;
+
+        delete mNetManager;
+        mNetManager = NULL;
     }
     
     // Effects need to be deleted before MainWindow.
@@ -133,6 +145,7 @@
     delete mSettingsViewLauncher;
 }
 
+
 /*!
     Main application window creation.
 */
@@ -209,30 +222,39 @@
         // NmAttachmentListWidget::paint().
         mMainWindow->setOptimizationFlag(QGraphicsView::DontSavePainterState);    
     }
+    
+	// Install the event filter in order to receive ApplicationActivate/Deactivate
+    // events.
+    QCoreApplication::instance()->installEventFilter(this);
 }
 
+
 /*!
     Slot. React to view ready signal and call current view method.
 */
 void NmApplication::viewReady()
 {
     mViewReady = true;
+
     if (mViewStack && !mViewStack->isEmpty()) {
     	NmBaseView *currentView = mViewStack->top();
+
         if (currentView) {
             currentView->viewReady();
+            emit applicationReady();
         }
     }
 }
 
+
 /*!
-    Event filter. End key is filtered from the main window and either the
-    view takes case of the or the app is exited by default.
+    Event filter. End key is filtered from the main window and either the view
+    takes case or the app is exited by default.
 */
 bool NmApplication::eventFilter(QObject *obj, QEvent *event)
 {
     bool consumed(false);
-    
+
     if (obj && obj == mMainWindow && event && event->type() == QEvent::KeyPress) {
         QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
         if (keyEvent->key() == Qt::Key_No) {
@@ -240,6 +262,18 @@
             // Exit application if no pending operations are on-going.
         }
     }
+    else if (event && event->type() == QEvent::ApplicationActivate) {
+        NM_COMMENT("NmApplication::eventFilter ApplicationActivate");
+		// Update task switcher name & screenshot, we could have activated into some other mailbox
+        updateActivity();
+    }
+    else if (event && event->type() == QEvent::ApplicationDeactivate) {
+        NM_COMMENT("NmApplication::eventFilter ApplicationDeactivate");
+        // Update the screenshot in the taskswitcher to represent current state
+        updateActivity();
+        // hide the sync indicator when app goes to background
+        mUiEngine->enableSyncIndicator(false);
+    }
     
     if (!consumed) {
         consumed = QObject::eventFilter(obj, event);
@@ -248,6 +282,7 @@
     return consumed;
 }
 
+
 /*!
     Push view to view stack.
 */
@@ -319,6 +354,30 @@
     }
 }
 
+
+/*!
+     Hide the application
+*/
+void NmApplication::hideApplication()
+{
+    // Hide the application
+    XQServiceUtil::toBackground(true);
+
+    // hide the sync indicator as well
+    mUiEngine->enableSyncIndicator(false);
+    
+    // Hide the mail from the task switcher 
+    TsTaskSettings taskSettings;
+    taskSettings.setVisibility(false);
+    
+    // Remove also the mailbox item from the task switcher
+    HbApplication* hbApp = dynamic_cast<HbApplication*>(parent());
+    if (hbApp) {
+        hbApp->activityManager()->removeActivity(NmActivityName);
+    }
+}
+
+
 /*!
     Pop view from view stack. View object is deleted.
 */
@@ -340,6 +399,13 @@
 				}
 	        }
             mBackButtonPressed = false;
+
+            // Move the application to background if closing the message list view
+            if (topViewId == NmUiViewMessageList && mViewStack->size() == 1) {
+                hideApplication();
+                return;
+            }
+
             mViewStack->pop();
             // Call custom exit function.
             view->aboutToExitView();
@@ -394,6 +460,7 @@
     }
 }
 
+
 /*!
     Reset view stack. Remove and destroy view objects.
 */
@@ -411,6 +478,7 @@
     }
 }
 
+
 /*!
     Function activates view based on viewId parameter. If requested view is
     already open, it is requested to reload. Otherwise view object is created
@@ -422,6 +490,8 @@
     
     // Check the validity of start parameter object.
     if (startParam) {
+    
+        mCurrentMailboxId = startParam->mailboxId();
         
         if (startParam->service() && mMainWindow) {
 			// When the message list is started as a service previous views
@@ -524,6 +594,7 @@
     }
 }
 
+
 /*!
     Function can be used from views to exit the application. View stack is
     cleared. Views can connect exit menu selection to this slot.
@@ -532,6 +603,9 @@
 {
     NM_FUNCTION;
     
+    HbApplication* hbApp = dynamic_cast<HbApplication*>(parent());
+    hbApp->activityManager()->removeActivity("EmailInboxView");
+    
     delete mSendServiceInterface;
     mSendServiceInterface = NULL;
     delete mSendServiceInterface2;
@@ -546,6 +620,7 @@
     qApp->quit();
 }
 
+
 /*!
    Exit the application in the next event loop.
 */
@@ -555,6 +630,7 @@
     QMetaObject::invokeMethod(this, "exitApplication", Qt::QueuedConnection);
 }
 
+
 /*!
     Getter for main window instance.
 */
@@ -563,6 +639,7 @@
     return mMainWindow;
 }
 
+
 /*!
     Getter for main UI extension manager.
 */
@@ -571,6 +648,7 @@
     return *mExtensionManager;
 }
 
+
 /*!
     Getter for network access manager.
 */
@@ -579,6 +657,7 @@
     return *mNetManager;
 }
 
+
 /*!
     Get the screen size. Function returns curtent screen size.
 */
@@ -612,6 +691,7 @@
     return ret;
 }
 
+
 /*!
     Handles all asynchronous operation's completions at UI level.
 */
@@ -643,6 +723,7 @@
     }
 }
 
+
 /*!
     Launches settings view of the specified mailbox.
 */
@@ -663,6 +744,7 @@
     }
 }
 
+
 /*!
 	Stores the visibility state, e.g. when the service was launched.
 	\return true if the app was visible.
@@ -675,3 +757,53 @@
 	NM_COMMENT(QString("NmApplication::updateVisibilityState() : mForegroundService == %1").arg(mForegroundService));
 	return mForegroundService;
 }
+
+
+/*!
+    Update the thumbnail in the task switcher.
+*/
+void NmApplication::updateActivity()
+{
+    NmMailboxMetaData *meta = mUiEngine->mailboxById(mCurrentMailboxId);
+    HbApplication* hbApp = dynamic_cast<HbApplication*>(parent());
+
+    if (hbApp) {
+        if (meta) {
+            TsTaskSettings tasksettings;
+            tasksettings.setVisibility(false);
+            QVariantHash metadata;
+            metadata.insert(ActivityScreenshotKeyword, QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
+            metadata.insert(ActivityApplicationName, meta->name());
+            metadata.insert(ActivityVisibility, true);
+            hbApp->activityManager()->removeActivity(NmActivityName);
+            hbApp->activityManager()->addActivity(NmActivityName, QVariant(), metadata);
+        }
+        else {
+            hbApp->activityManager()->removeActivity(NmActivityName);
+            TsTaskSettings tasksettings;
+            tasksettings.setVisibility(true);
+        }
+    }
+}
+
+
+/*!
+	Switch to activated mailbox
+*/
+void NmApplication::activityActivated()
+{
+    HbApplication* hbApp = dynamic_cast<HbApplication*>(parent());
+    if (hbApp) {
+        quint64 accountId(0);
+        QString activateId = hbApp->activateId();
+        if (hbApp->activateReason() == Hb::ActivationReasonActivity &&
+                activateId.startsWith(NmActivityName) ) {
+            QString accountIdString = activateId.mid(NmActivityName.length());
+            accountId = accountIdString.toULongLong();
+            QVariant mailbox;
+            mailbox.setValue(accountId);
+            mMailboxServiceInterface->displayInboxByMailboxId(mailbox);
+        }
+    }
+}
+
--- a/emailuis/nmailui/src/nmattachmentpicker.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmattachmentpicker.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -41,32 +41,32 @@
 NmAttachmentPicker::~NmAttachmentPicker()
 {
     NM_FUNCTION;
-    
+
     delete mRequest;
 }
 
 /*!
-    Send request to start Photo picker 
+    Send request to start Photo picker
 */
 void NmAttachmentPicker::fetchImage()
 {
     NM_FUNCTION;
-    
+
     fetch(XQI_IMAGE_FETCH, XQOP_IMAGE_FETCH);
 }
 
 /*!
-    Send request to start Music picker 
+    Send request to start Music picker
 */
 void NmAttachmentPicker::fetchAudio()
 {
     NM_FUNCTION;
-    
-    fetch(XQI_MUSIC_FETCH, XQOP_MUSIC_FETCH);    
+
+    fetch(XQI_MUSIC_FETCH, XQOP_MUSIC_FETCH);
 }
 
 /*!
-    Send request to start Video picker 
+    Send request to start Video picker
 */
 void NmAttachmentPicker::fetchVideo()
 {
@@ -75,19 +75,17 @@
 }
 
 /*!
-    Send request to start general file picker 
+    Send request to start general file picker
 */
 void NmAttachmentPicker::fetchOther()
 {
     NM_FUNCTION;
-    
+
     QString path;
-    path = FmFileDialog::getSaveFileName(0, hbTrId("txt_mail_dialog_select_file"));
-    
-    if (!path.isEmpty()) {
-        QString temp = QDir::toNativeSeparators(path);
-        emit attachmentsFetchOk(QVariant(temp));    
-    }
+    path = FmFileDialog::getOpenFileName(0, hbTrId("txt_mail_dialog_select_file"));
+
+    QString temp = QDir::toNativeSeparators(path);
+    emit attachmentsFetchOk(QVariant(temp));
 }
 
 /*!
@@ -120,36 +118,36 @@
     bool allowModeSwitch(false);   //not allowed to change
     bool allowCameraSwitch(true);  //allow changes
     bool allowQualityChange(true); //allow changes
-    
+
     QVariantMap parameters;
     parameters.insert(XQCAMERA_INDEX, cameraIndex);
     parameters.insert(XQCAMERA_QUALITY, quality);
     parameters.insert(XQCAMERA_MODE_SWITCH, allowModeSwitch);
     parameters.insert(XQCAMERA_INDEX_SWITCH, allowCameraSwitch);
-    parameters.insert(XQCAMERA_QUALITY_CHANGE, allowQualityChange); 
- 
+    parameters.insert(XQCAMERA_QUALITY_CHANGE, allowQualityChange);
+
     QList<QVariant> args;
     args << mode;
     args << parameters;
-    
+
     fetch(XQI_CAMERA_CAPTURE, "capture(int,QVariantMap)", &args);
 }
 /*!
-    Construct & send appmgr request to start appropriate picker   
+    Construct & send appmgr request to start appropriate picker
     param <interface> the interface to be connected to
     param <operation> the operation of the interface
     param <args> the arguments that needed by the operation
 */
-void NmAttachmentPicker::fetch(const QString &interface, 
+void NmAttachmentPicker::fetch(const QString &interface,
     const QString &operation, const QList<QVariant> *args)
 {
     NM_FUNCTION;
-    
+
     delete mRequest;
     mRequest = NULL;
     XQApplicationManager appMgr;
     mRequest = appMgr.create(interface, operation, true);
-   
+
     if (mRequest) {
         mRequest->setSynchronous(false);
         if (args) {
@@ -160,7 +158,30 @@
 
         connect(mRequest, SIGNAL(requestError(int, const QString&)),
                 this, SIGNAL(attachmentsFetchError(int, const QString&)));
-        
+
         mRequest->send();
-    } 
+    }
 }
+
+/*!
+	Launch the correct fetcher based on the clicked list item.
+*/
+void NmAttachmentPicker::selectFetcher(HbListWidgetItem *listItem)
+{
+	QString itemText = listItem->text();
+    if (itemText == hbTrId("txt_mail_list_photo")) {
+        fetchImage();
+    }
+    else if (itemText == hbTrId("txt_mail_list_music")) {
+        fetchAudio();
+	}
+    else if (itemText == hbTrId("txt_mail_list_video")) {
+        fetchVideo();
+	}
+    else if (itemText == hbTrId("txt_mail_list_other")) {
+        QMetaObject::invokeMethod(this, "fetchOther", Qt::QueuedConnection);
+	}
+    else if (itemText == hbTrId("txt_mail_list_new_photo")) {
+        fetchCameraStill();
+	}
+}
--- a/emailuis/nmailui/src/nmeditorcontent.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmeditorcontent.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -39,16 +39,20 @@
     mEditorWidget(NULL),
     mScrollArea(NULL),
     mScrollAreaContents(NULL),
-    mApplication(application)
+    mApplication(application),
+    mNeedForWidthAdjustment(false)
 {
     NM_FUNCTION;
 
     // Construct container for the header widgets
-    mHeader = new NmEditorHeader(this, documentLoader);
+    mHeader = new NmEditorHeader(this, application, documentLoader);
 
     // Get pointer to body text area handling widget
     mEditorWidget = qobject_cast<NmEditorTextEdit *>(documentLoader->findWidget(NMUI_EDITOR_BODY));
-    
+
+    // Enable the emoticons.
+    mEditorWidget->setSmileysEnabled(true);
+
     // Set body editor to use NmEditorTextDocument
     NmEditorTextDocument *textDocument = new NmEditorTextDocument(manager);
     mEditorWidget->setDocument(textDocument); 
@@ -56,8 +60,10 @@
 
     mScrollArea = qobject_cast<NmBaseViewScrollArea *>
         (documentLoader->findWidget(NMUI_EDITOR_SCROLL_AREA));
+    
     mScrollArea->setScrollDirections(Qt::Vertical | Qt::Horizontal);
-    
+    mScrollArea->setClampingStyle(HbScrollArea::BounceBackClamping);
+        
     // Enable style picker menu item.
     mEditorWidget->setFormatDialog(new HbFormatDialog());
 
@@ -66,6 +72,12 @@
     
     // Create signal slot connections
     createConnections();
+
+    // The following line is necessary in terms of being able to add emoticons
+    // (smileys) to an empty document (mail content). Otherwise the private
+    // pointer of the QTextDocument which the smiley engine has is NULL and
+    // inserting a smiley will lead to an error.
+    mEditorWidget->setPlainText("");
 }
 
 /*!
@@ -87,10 +99,12 @@
     NM_FUNCTION;
     
     QString bodyContent;
+	QTextCursor cursor(mEditorWidget->document());
     
     // Create the "reply" header (also for forward message)
     if (editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll || 
         editorStartMode==NmUiEditorForward) {
+		bodyContent.append(QString("<style type=\"text/css\">* { color: black; }</style>"));
         bodyContent.append(NmUtilities::createReplyHeader(originalMessage.envelope()));
     }
     
@@ -103,15 +117,27 @@
         if(editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll ) {
             removeEmbeddedImages(bodyContent);
         }
-        emit setHtml(bodyContent);
+        cursor.insertHtml(bodyContent);
         mMessageBodyType = NmHTMLText;
     }
     else if (plainPart) {
         // Plain text part was present, set it to HbTextEdit
         bodyContent.append(plainPart->textContent());
-        emit setPlainText(bodyContent);
+        cursor.insertText(bodyContent);
         mMessageBodyType = NmPlainText;
+        
+		// Next we set text color for black for all current content
+        QTextCharFormat blackForeground;
+    	blackForeground = cursor.charFormat();
+    	blackForeground.setForeground(Qt::black);
+    	cursor.select(QTextCursor::Document);
+    	cursor.mergeCharFormat(blackForeground);
     }
+    // Update of the body width is done when next contentChanged signal comes from the body.
+    mNeedForWidthAdjustment = true;
+	cursor.clearSelection();
+	cursor.setPosition(0);
+	cursor.insertHtml(QString("<html><body><br><br></body></html>"));
 }  
 
 /*!
@@ -152,6 +178,14 @@
     // listen to the parent's (NmEditorView) size changes which happen eg. when VKB is opened/closed
     connect(parent(), SIGNAL(sizeChanged()), this, SLOT(ensureCursorVisibility()),
         Qt::QueuedConnection);
+
+    // Listen scroll posion change signals for header reposition.
+    connect(mScrollArea, SIGNAL(scrollPositionChanged(QPointF)),
+    		mHeader, SLOT(repositHeader(QPointF)));
+
+    // Listen content change signal for body widget width adjustment.
+    connect(mEditorWidget->document(), SIGNAL(contentsChanged()), this, 
+        SLOT(setEditorContentWidth()), Qt::QueuedConnection);
 }
 
 /*!
@@ -209,6 +243,21 @@
 }
 
 /*!
+    This slot is used to set width for the body field.
+    For some reason HbTextEdit does not set it's width, so we need to se it here.
+    This slot can be removed if HbTextEdit is fixed.
+ */
+void NmEditorContent::setEditorContentWidth()
+{
+    NM_FUNCTION;
+    
+    if (mNeedForWidthAdjustment) {
+        mNeedForWidthAdjustment = false;
+        mScrollAreaContents->setPreferredWidth(mEditorWidget->document()->idealWidth());
+    }
+}
+
+/*!
     This slot is called when the cursor visibility has to be ensured ie. the scroll position is 
     adjusted so that the cursor can be seen.
 */
--- a/emailuis/nmailui/src/nmeditorheader.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmeditorheader.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -22,6 +22,7 @@
 static const char *NMUI_EDITOR_CONTAINER = "scrollAreaContents";
 static const char *NMUI_EDITOR_SUBJECT_FIELD = "editorSubjectField";
 static const char *NMUI_EDITOR_SUBJECT_EDIT = "editorSubjectEdit";
+static const char *NMUI_EDITOR_TO_FIELD = "editorToField";
 static const char *NMUI_EDITOR_CC_FIELD = "editorCcField";
 static const char *NMUI_EDITOR_BCC_FIELD = "editorBccField";
 static const char *NMUI_EDITOR_PRIORITY_ICON = "editPriorityIcon";
@@ -39,8 +40,10 @@
 /*!
     Constructor
 */
-NmEditorHeader::NmEditorHeader(QObject *parent, HbDocumentLoader *documentLoader) :
+NmEditorHeader::NmEditorHeader(
+    QObject *parent, NmApplication &application, HbDocumentLoader *documentLoader) :
     QObject(parent),
+    mApplication(application),
     mDocumentLoader(documentLoader),
     mHeaderHeight(0),
     mIconVisible(false),
@@ -93,6 +96,8 @@
         ccEditorInterface.setUpAsLatinAlphabetOnlyEditor();
         bccEditorInterface.setUpAsLatinAlphabetOnlyEditor();
 
+        mToWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_TO_FIELD));
+        
         // Cc field is not shown by default. It needs to be both hidden and removed from the layout.
         mCcWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CC_FIELD));
         mCcWidget->hide();
@@ -113,13 +118,13 @@
         mSubjectEdit->setMaxRows(NmMaxRows);
     
         // Add attachment list
-        NmAttachmentListWidget *attachmentList = qobject_cast<NmAttachmentListWidget *>
+        mAttachmentListWidget = qobject_cast<NmAttachmentListWidget *>
             (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST));
         // Create attachment list handling object
-        mAttachmentList = new NmAttachmentList(*attachmentList);
+        mAttachmentList = new NmAttachmentList(*mAttachmentListWidget);
         mAttachmentList->setParent(this); // ownership changes
-        attachmentList->hide();
-        mLayout->removeItem(attachmentList);
+        mAttachmentListWidget->hide();
+        mLayout->removeItem(&mAttachmentList->listWidget());
     
         // Add priority icon
         mPriorityIcon = qobject_cast<HbLabel *>
@@ -253,6 +258,23 @@
 }
 
 /*!
+    Because header filds have fixed size policy. This function must be called to set
+    new width for every header field when orintation has been changed.
+ */
+void NmEditorHeader::adjustHeaderWidth()
+{
+    NM_FUNCTION;
+    
+    int newWidth = mApplication.screenSize().width();
+    mToWidget->setPreferredWidth(newWidth);
+    mCcWidget->setPreferredWidth(newWidth);
+    mBccWidget->setPreferredWidth(newWidth);
+    mSubjectWidget->setPreferredWidth(newWidth);
+    mAttachmentListWidget->setPreferredWidth(newWidth);
+    mSubjectWidget->setPreferredWidth(newWidth);
+}
+
+/*!
     Return pointer to to edit
  */
 NmRecipientLineEdit* NmEditorHeader::toEdit() const
@@ -386,11 +408,13 @@
     NM_FUNCTION;
     
     mAttachmentList->insertAttachment(fileName, fileSize, nmid);
+    
     if (!mAttachmentList->listWidget().isVisible()) {
         // attachment list is inserted just before the body widget (see docml).
         mLayout->insertItem(mLayout->count() - 1, &mAttachmentList->listWidget());
         mAttachmentList->listWidget().show();
     }
+
     sendHeaderHeightChanged();
 }
 
@@ -464,4 +488,22 @@
     // Remove selected attachment
     emit attachmentLongPressed(mAttachmentList->nmIdByIndex(arrayIndex), point);
 }
+
+/*!
+    This slot is called when scroll position has been changed.
+    Function set new positions for header fields so that header stays visible
+    when body is scrolled horizontally.
+ */
+void NmEditorHeader::repositHeader(const QPointF &scrollPosition)
+{
+    NM_FUNCTION;
     
+    QTransform tr;
+    tr.translate(scrollPosition.x(),0);
+    mToWidget->setTransform(tr);
+    mCcWidget->setTransform(tr);
+    mBccWidget->setTransform(tr);
+    mSubjectWidget->setTransform(tr);
+    mAttachmentListWidget->setTransform(tr);
+}
+
--- a/emailuis/nmailui/src/nmeditorview.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmeditorview.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -18,9 +18,14 @@
 
 // Layout file and view
 static const char *NMUI_EDITOR_VIEW_XML = ":/docml/nmeditorview.docml";
-static const char *NMUI_EDITOR_VIEW= "editorview";
+static const char *NMUI_EDITOR_VIEW = "editorview";
 
+// extension list item frame.
+static const QString NmPopupListFrame = "qtg_fr_popup_list_normal";
 static const QString NmDelimiter("; ");
+static const QString NmPriorityLow("low");
+static const QString NmPriorityNormal("normal");
+static const QString NmPriorityHigh("high");
 
 /*!
 	\class NmEditorView
@@ -52,7 +57,9 @@
       mQueryDialog(NULL),
       mAttachmentPicker(NULL),
       mCcBccFieldVisible(false),
-      mServiceSendingDialog(NULL)
+      mServiceSendingDialog(NULL),
+      mIsNotFetchedBefore(true),
+      mHiddenPriorityName(NmPriorityNormal)
 {
     NM_FUNCTION;
     
@@ -193,6 +200,7 @@
     // content widget height needs to be set according to the new orientation to get the scroll
 	// area work correctly
 	mHeaderWidget->sendDelayedHeaderHeightChanged();
+	mHeaderWidget->adjustHeaderWidth();
 }
 
 /*!
@@ -392,20 +400,24 @@
 {
     NM_FUNCTION;
     
-    if (startParam.editorStartMode() == NmUiEditorForward
-        || startParam.editorStartMode()== NmUiEditorReply
-        || startParam.editorStartMode() == NmUiEditorReplyAll) {
+    if (mIsNotFetchedBefore == true) {
+        if (startParam.editorStartMode() == NmUiEditorForward
+            || startParam.editorStartMode()== NmUiEditorReply
+            || startParam.editorStartMode() == NmUiEditorReplyAll) {
         
-        fetchProgressDialogShow();
-        mAttaManager.clearObserver();
-        mAttaManager.setObserver(this);
-        mAttaManager.fetchAllMessageParts(
-            startParam.mailboxId(),
-            startParam.folderId(),
-            startParam.messageId());
-    }
-    else {
-        startMessageCreation(startParam);
+            fetchProgressDialogShow();
+            mAttaManager.clearObserver();
+            mAttaManager.setObserver(this);
+            mAttaManager.fetchAllMessageParts(
+                startParam.mailboxId(),
+                startParam.folderId(),
+                startParam.messageId());
+        }
+        else {
+            startMessageCreation(startParam);
+        }
+        
+        mIsNotFetchedBefore = false;
     }
 }
 
@@ -890,32 +902,30 @@
                 if (extension && mAttachmentPicker) {
                     connect(mAttachmentPicker, SIGNAL(attachmentsFetchOk(const QVariant &)),
                         this, SLOT(onAttachmentReqCompleted(const QVariant &)));            
-                                                
-                    HbAction* actionPhoto = 
-                        extension->addAction(hbTrId("txt_mail_list_photo"), extension, SLOT(close()));
-                    connect(actionPhoto, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchImage()));
+                    
+                    list[i]->setToolBarExtension(extension);
                     
-                    HbAction* actionMusic = 
-                        extension->addAction(hbTrId("txt_mail_list_music"), extension, SLOT(close()));
-                    connect(actionMusic, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchAudio()));
-                    
-                    HbAction* actionVideo = 
-                        extension->addAction(hbTrId("txt_mail_list_video"), extension, SLOT(close()));
-                    connect(actionVideo, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchVideo()));
+                    //content widget to get the items to a list
+                    mTBExtnContentWidget = new HbListWidget();
+                    mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
                     
-                    HbAction* actionOther = 
-                        extension->addAction(hbTrId("txt_mail_list_other"), extension, SLOT(close()));
-                    connect(actionOther, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchOther()));
+                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_photo"));
+                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_music"));
+                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_video"));
+                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_other"));
+                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_photo"));
+                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_video"));
+                    HbListViewItem *listView = mTBExtnContentWidget->listItemPrototype();
+                    HbFrameBackground frame(NmPopupListFrame, HbFrameDrawer::NinePieces);
+                    listView->setDefaultFrame(frame);
                     
-                    HbAction* actionCameraStill = 
-                       extension->addAction(hbTrId("txt_mail_list_new_photo"), extension, SLOT(close()));
-                    connect(actionCameraStill, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchCameraStill()));
+                    connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), 
+                    		mAttachmentPicker, SLOT (selectFetcher(HbListWidgetItem*)));
             
-                    HbAction* actionCameraVideo = 
-                        extension->addAction(hbTrId("txt_mail_list_new_video"), extension, SLOT(close()));
-                    connect(actionCameraVideo, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchCameraVideo()));
+                    connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
+                            extension, SLOT(close()));
                                         
-                    list[i]->setToolBarExtension(extension);
+                    extension->setContentWidget(mTBExtnContentWidget);
                 }
             }            
         }        
@@ -952,7 +962,10 @@
     QList<NmAction*> list;
     extMngr.getActions(request, list);
     for (int i = 0; i < list.count(); i++) {
-        mPrioritySubMenu->addAction(list[i]);
+        // check what priority has already been selected and hide it from options menu
+        if (!list[i]->objectName().contains(mHiddenPriorityName)) {
+            mPrioritySubMenu->addAction(list[i]);
+        }
     }
     mPrioritySubMenu->setObjectName("editorPrioritySubMenu");
     mPrioritySubMenu->setTitle(hbTrId("txt_mail_opt_add_priority"));
@@ -1365,12 +1378,15 @@
 
     if (mMessage) {
         NmMessagePriority messagePriority = NmMessagePriorityNormal;
+        mHiddenPriorityName = NmPriorityNormal;
         
         if (priority == NmActionResponseCommandPriorityHigh) {
             messagePriority = NmMessagePriorityHigh;
+            mHiddenPriorityName = NmPriorityHigh;
         }
         else if (priority == NmActionResponseCommandPriorityLow) {
             messagePriority = NmMessagePriorityLow;
+            mHiddenPriorityName = NmPriorityLow;
         }
         mMessage->envelope().setPriority(messagePriority);
     }
--- a/emailuis/nmailui/src/nmmessagelistview.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmmessagelistview.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -23,9 +23,7 @@
 
 #include "nmuiheaders.h"
 
-const QString syncIndicatorName = "com.nokia.nmail.indicatorplugin.sync/1.0";
-
-/*! 
+/*!
 	\class NmMessageListView
 	\brief Message list view
 */
@@ -148,6 +146,8 @@
         // Menu needs one dummy item so that aboutToShow signal is emitted.
         NmAction *dummy = new NmAction(0);
         menu()->addAction(dummy);
+        // Set sync icon if needed
+        updateSyncIcon();
     }
     else {
         NM_ERROR(1,"nmailui: resource loading failed");
@@ -204,7 +204,7 @@
 */
 void NmMessageListView::initTreeView()
 {
-    NM_FUNCTION; 
+    NM_FUNCTION;
 
     // Get mailbox widget pointer and set parameters
     if (mMessageListWidget){
@@ -230,18 +230,36 @@
 
     // Check start parameter validity, message view cannot
     // be updated if given parameter is zero.
-    if (startParam&&startParam->viewId()==NmUiViewMessageList&&
+    if (startParam&&startParam->viewId()==NmUiViewMessageList &&
         startParam->folderId()!=0) {
         // Delete existing start parameter data
         delete mStartParam;
-        mStartParam=NULL;
+        mStartParam = NULL;
         // Store new start parameter data
-        mStartParam=startParam;
-        // Update the model with new parameters
+        mStartParam = startParam;
+        // Disconnect signals from previous model
+        QObject::disconnect(mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)),
+                this, SLOT(itemsAdded(const QModelIndex&,int,int)));
+        QObject::disconnect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
+                this, SLOT(itemsRemoved()));
+        QObject::disconnect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)),
+                this, SLOT(reloadViewContents(NmUiStartParam*)));
+        // Update model pointer and refresh mailbox with new model
         mMessageListModel = &mUiEngine.messageListModel(startParam->mailboxId(), startParam->folderId());
+        
         refreshList();
-        // Refresh the mailboxname
+        
+        // Refresh the mailbox name
         setMailboxName();
+        
+        // Store active folder type
+        mCurrentFolderType = mUiEngine.folderTypeById(startParam->mailboxId(),startParam->folderId());
+
+        // Update folder name
+        setFolderName();
+        
+        // Set sync icon if needed
+        updateSyncIcon();
     }
     else {
         NM_ERROR(1,"nmailui: invalid message list start parameter");
@@ -250,7 +268,7 @@
     }
 }
 
- 
+
 /*!
     Return view id
 */
@@ -269,16 +287,16 @@
     NM_FUNCTION;
 
     if (mMessageListModel) {
-        NmId mailboxId = mMessageListModel->currentMailboxId();    
+        NmId mailboxId = mMessageListModel->currentMailboxId();
         // In each refresh, e.g. in folder change the UI signals
         // lower layer about the folder that has been opened.
         if (mStartParam){
             mUiEngine.updateActiveFolder(mailboxId, mStartParam->folderId());
-            
+
             NmFolderType folderType = mUiEngine.folderTypeById(mStartParam->mailboxId(),
                                               mStartParam->folderId());
             if (folderType == NmFolderInbox) { // If the new folder is an inbox, first automatic sync should be shown
-                mIsFirstSyncInMessageList = true; 
+                mIsFirstSyncInMessageList = true;
             }
         }
 
@@ -286,11 +304,11 @@
         if (mMessageListWidget) {
             mMessageListWidget->setModel(static_cast<QStandardItemModel*>(mMessageListModel));
             QObject::connect(mMessageListModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)),
-                    this, SLOT(itemsAdded(const QModelIndex&,int,int)));
+                    this, SLOT(itemsAdded(const QModelIndex&,int,int)),Qt::UniqueConnection);
             QObject::connect(mMessageListModel, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
-                    this, SLOT(itemsRemoved()));
+                    this, SLOT(itemsRemoved()),Qt::UniqueConnection);
             QObject::connect(mMessageListModel, SIGNAL(setNewParam(NmUiStartParam*)),
-                    this, SLOT(reloadViewContents(NmUiStartParam*)));
+                    this, SLOT(reloadViewContents(NmUiStartParam*)),Qt::UniqueConnection);
 
             mPreviousModelCount=mMessageListModel->rowCount();
             if (mPreviousModelCount==0){
@@ -299,14 +317,14 @@
             else{
                 hideNoMessagesText();
             }
-        }    
+        }
     }
 }
 
 /*!
     Sync state event handling
 */
-void NmMessageListView::handleSyncStateEvent(NmSyncState syncState, const NmId & mailboxId)
+void NmMessageListView::handleSyncStateEvent(NmSyncState syncState, const NmId &mailboxId)
 {
     NM_FUNCTION;
     if (mMessageListModel && mailboxId == mMessageListModel->currentMailboxId()) {
@@ -322,15 +340,14 @@
             // Show sync icon only for the first automatic sync after opening message list.
             // Sync icon for manual sync is shown in NmUiEngine::refreshMailbox, not here.
             if (mIsFirstSyncInMessageList) {
-                HbIndicator indicator;
-                indicator.activate(syncIndicatorName, QVariant());
+				mUiEngine.enableSyncIndicator(true);
                 mIsFirstSyncInMessageList = false;
             }
         }
     }
 }
 
-/*! 
+/*!
     folder selection handling within current mailbox
 */
 void NmMessageListView::folderSelected()
@@ -350,24 +367,24 @@
         // Reload view, ownership of the startparams is passed and old startparams
         // are deleted within reloadViewContents function
         reloadViewContents(startParam);
-        //Set folder text to status bar
+        // Set folder text to status bar
         setFolderName();
     }
 }
 
 
 /*!
-    Long keypress handling 
+    Long keypress handling
 */
 void NmMessageListView::showItemContextMenu(HbAbstractViewItem *listViewItem, const QPointF &coords)
 {
     NM_FUNCTION;
-   
+
     if (listViewItem) {
         // Recreate item context menu each time it is called
         if (mItemContextMenu){
             mItemContextMenu->clearActions();
-            delete mItemContextMenu;    
+            delete mItemContextMenu;
             mItemContextMenu=NULL;
         }
         mItemContextMenu = new HbMenu();
@@ -612,7 +629,7 @@
 {
     NM_FUNCTION;
 
-    if (mStartParam&&mFolderLabel){
+    if (mStartParam && mFolderLabel){
         switch (mCurrentFolderType) {
         case NmFolderOutbox:
             {
@@ -650,7 +667,7 @@
     visible and keeps the scroll position on the top of the list.
 
     \param parent Not used.
-    \param start 
+    \param start
     \param end Not used.
 */
 void NmMessageListView::itemsAdded(const QModelIndex &parent, int start, int end)
@@ -688,7 +705,7 @@
     }
     // Store model count
     if (mMessageListModel){
-        mPreviousModelCount=mMessageListModel->rowCount();    
+        mPreviousModelCount=mMessageListModel->rowCount();
     }
 }
 
@@ -701,7 +718,7 @@
     NM_FUNCTION;
     // Store model count
     if (mMessageListModel){
-        mPreviousModelCount=mMessageListModel->rowCount();    
+        mPreviousModelCount=mMessageListModel->rowCount();
     }
     if (mPreviousModelCount == 0){
         showNoMessagesText();
@@ -734,3 +751,19 @@
     }
 }
 
+/*!
+    Updates sync icon based on sync status from the plugin.
+*/
+void NmMessageListView::updateSyncIcon()
+{
+    if (mStartParam) {
+        NmSyncState syncState = mUiEngine.syncState(mStartParam->mailboxId());
+        if (syncState==Synchronizing) {
+            mUiEngine.enableSyncIndicator(true);
+        } 
+        else {
+            mUiEngine.enableSyncIndicator(false);
+        }
+    }
+}
+
--- a/emailuis/nmailui/src/nmmessagelistviewitem.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmmessagelistviewitem.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -1,97 +1,90 @@
 /*
-* 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:
-*
-*
-*/
+ * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
 
 #include "nmuiheaders.h"
 
 /*!
     \class NmMessageListViewItem
-    \brief list view item for message list view
-*/
+    \brief List view item for message list view.
+ */
 
 static const int NmFolderTypeRole = Qt::UserRole+1; 
 
 /*!
-    Constructor
-*/
-NmMessageListViewItem::NmMessageListViewItem(QGraphicsItem *parent):
-    HbTreeViewItem(parent),
-    mSender(NULL),
-    mSubject(NULL),
-    mTime(NULL),
-    mDividerTitle(NULL),
-    mNewMsgIcon(NULL),
-    mIcon1(NULL),
-    mIcon2(NULL),
-    mPrimarySize(0),
-    mSecondarySize(0),
-    mTinySize(0)    
+    Constructor.
+ */
+NmMessageListViewItem::NmMessageListViewItem(QGraphicsItem *parent)
+: HbTreeViewItem(parent),
+  mSender(NULL),
+  mSubject(NULL),
+  mTime(NULL),
+  mDividerTitle(NULL),
+  mNewMsgIcon(NULL),
+  mIcon1(NULL),
+  mIcon2(NULL),
+  mPrimarySize(0),
+  mSecondarySize(0)   
 {
-    NM_FUNCTION;
 }
 
 /*!
-    Destruction.
-*/
+    Destructor.
+ */
 NmMessageListViewItem::~NmMessageListViewItem()
 {
-    NM_FUNCTION;
 }
 
 /*!
-*/
+    Create item.
+ */
 HbTreeViewItem *NmMessageListViewItem::createItem()
 {
-    NM_FUNCTION;
-    
     return new NmMessageListViewItem(*this);
 }
 
 /*!
-    boolean value indicating model index availability. Always true since
-    this item prototype is used for both divider and message
-*/
+    Boolean value indicating model index availability. Always true since
+    this item prototype is used for both divider and message.
+ */
 bool NmMessageListViewItem::canSetModelIndex(const QModelIndex &index) const
 {
-    NM_FUNCTION;
-    
     Q_UNUSED(index);
-    // This item class can handle all items in message list
+    // This item class can handle all items in message list.
     return true;
 }
 
 /*!
-    update child items. List calls this function whenever item is needed
+    Update child items. List calls this function whenever item is needed
     to be updated.
-*/
+ */
 void NmMessageListViewItem::updateChildItems()
 {
-    NM_FUNCTION;
-    
     // Get model pointer
     NmMessageListModelItem *msgModelItem = modelIndex().data(
-            Qt::DisplayRole).value<NmMessageListModelItem*>();
+        Qt::DisplayRole).value<NmMessageListModelItem*>();
     // Check whether item is message item or title divider
-    // and set the layout accordingly, dividers not currently used
+    // and set the layout accordingly. Dividers are not currently used.
     if (msgModelItem && msgModelItem->itemType() ==
         NmMessageListModelItem::NmMessageItemMessage){
         NmMessageListModel *model = static_cast<NmMessageListModel*>(msgModelItem->model());
         if (model){
-            // First set item layout
+            // First set item layout.
             createMessageItemLayout();
-            // Set content data to item after layout is created
+            // Set content data to item after layout is created.
             setContentsToMessageItem(msgModelItem->envelope(), model->dividersActive());
         }
     }
@@ -100,67 +93,57 @@
 
 /*!
     Set item layout.
-    Function does not take ownership of model or model item
-*/
+    Function does not take ownership of model or model item.
+ */
 void NmMessageListViewItem::createMessageItemLayout()
-{ 
-    NM_FUNCTION;
-    
+{
     getFontSizes();
-    // Create sender label and set name from widgetml
-    if (!mSender){
+    // Create sender label and set name from widgetml.
+    if (!mSender) {
         mSender = new HbTextItem(this);
         HbStyle::setItemName(mSender, "sender");
         mSender->setObjectName("ListViewItemMessageSender");
-        mSender->setTextWrapping(Hb::TextNoWrap);
     }
-    // Create time label and set name from widgetml
-    if (!mTime){
+    // Create time label and set name from widgetml.
+    if (!mTime) {
         mTime = new HbTextItem(this);
         HbStyle::setItemName(mTime, "time");
         mTime->setObjectName("ListViewItemMessageTime");
     }
-    // Create subject label and set name from widgetml
-    if (!mSubject){
+    // Create subject label and set name from widgetml.
+    if (!mSubject) {
         mSubject = new HbTextItem(this);
         HbStyle::setItemName(mSubject, "subject");
         mSubject->setObjectName("ListViewItemMessageSubject");
-        mSubject->setTextWrapping(Hb::TextNoWrap);
     }
-    // Set new message icon
+    // Set new message icon.
     if (!mNewMsgIcon) {
         mNewMsgIcon = new HbFrameItem(this);
-     }
-    // Create priority icon and set name from widgetml
-    if (!mIcon1){
+    }
+    // Create priority icon and set name from widgetml.
+    if (!mIcon1) {
         mIcon1 = new HbIconItem(this);
         HbStyle::setItemName(mIcon1, "icon1");
-        // According to layout guide, icon alignment is always right
-        mIcon1->setAlignment(Qt::AlignRight);
     }
-    // Create attachment icon and set name from widgetml
-    if (!mIcon2){
+    // Create attachment icon and set name from widgetml.
+    if (!mIcon2) {
         mIcon2 = new HbIconItem(this);
         HbStyle::setItemName(mIcon2, "icon2");
-        // According to layout guide, icon alignment is always right
-        mIcon2->setAlignment(Qt::AlignRight);
     }
     setObjectName("ListViewItemMessage");
 }
 
 /*!
-    set item text label contents, icons, etc.
-    Function does not take ownership of model or model item
+    Set item text label contents, icons, etc.
+    Function does not take ownership of model or model item.
 */
 void NmMessageListViewItem::setContentsToMessageItem(const NmMessageEnvelope &envelope, 
                                                      bool dividersActive)
 {
-    NM_FUNCTION;
-    
-    // member variables are created in previous function
-    // sender
+    // Member variables are created in previous function.
+    // Sender.
     mSender->setText(senderFieldText(envelope));
-    // time
+    // Time.
     HbExtendedLocale locale = HbExtendedLocale::system();
     QDateTime localTime = envelope.sentTime().addSecs(locale.universalTimeOffset());
     QDate sentLocalDate = localTime.date();
@@ -173,14 +156,14 @@
         QString shortDateSpec = r_qtn_date_without_year;
         mTime->setText(locale.format(sentLocalDate, shortDateSpec));
     }
-    // subject 
+    // Subject.
     QString subjectText = envelope.subject();
     if (subjectText.length()) {
         mSubject->setText(subjectText);
     } else {
         mSubject->setText(hbTrId("txt_mail_dblist_val_no_subject"));
     }
-    // priority
+    // Priority.
     bool priorityIs(false);
     mIcon1->hide();
     mIcon2->hide();
@@ -201,7 +184,7 @@
         default:
             break;
     }
-    // attachments
+    // Attachments.
     HbIconItem *attaIcon = (priorityIs ? mIcon2 : mIcon1);
     if (envelope.hasAttachments()) {
         HbIcon &icon = NmIcons::getIcon(NmIcons::NmIconAttachment);
@@ -209,12 +192,11 @@
         attaIcon->setObjectName("ListViewItemMessageIconAttachment");
         attaIcon->show();
     }
-    // message read status
+    // Message read status.
     bool msgReadStatus(envelope.isRead());
     HbFrameDrawer *drawer(NULL);
     HbStyle::setItemName(mNewMsgIcon, "msgicon");
     if (!msgReadStatus) {
-
         setFontsUnread();
         mNewMsgIcon->setObjectName("ListViewItemMessageIconUnread");
         drawer = new HbFrameDrawer("qtg_fr_list_new_item",
@@ -224,10 +206,9 @@
         mNewMsgIcon->setFrameDrawer(drawer);
         mNewMsgIcon->show();
     } else {
-
         setFontsRead();
         mNewMsgIcon->setObjectName("ListViewItemMessageIconRead");
-        drawer = new HbFrameDrawer(); // Create empty drawer
+        drawer = new HbFrameDrawer(); // Create empty drawer.
         drawer->setFillWholeRect(false);
         // Set drawer. Takes ownership of the drawer and deletes previous drawer.
         mNewMsgIcon->setFrameDrawer(drawer);
@@ -236,37 +217,31 @@
 }
 
 /*!
-    setFontsUnread
-*/
+    Set fonts unread.
+ */
 void  NmMessageListViewItem::setFontsUnread()
-{    
-    NM_FUNCTION;
-    
+{
     static QColor colorRole = HbColorScheme::color("qtc_list_item_title_normal");
     HbFontSpec fontSpec(HbFontSpec::Primary);
     setFonts(colorRole, fontSpec);
 }
 
 /*!
-    setFontsRead
-*/
+    Set fonts read.
+ */
 void  NmMessageListViewItem::setFontsRead()
 {
-    NM_FUNCTION;
-    
     static QColor colorRole = HbColorScheme::color("qtc_list_item_content_normal");
     HbFontSpec fontSpec(HbFontSpec::Secondary);
     setFonts(colorRole, fontSpec);
 }
 
 /*!
-    getFontSizes.
-*/
+    Get font sizes.
+ */
 void  NmMessageListViewItem::getFontSizes()
 {
-    NM_FUNCTION;
-    
-    // Get font sizes from style  
+    // Get font sizes from style.
     qreal currentSize;
     bool found = style()->parameter(QString("hb-param-text-height-primary"), currentSize );
     if (found) {
@@ -276,57 +251,43 @@
     if (found) {
         mSecondarySize = currentSize;
     }        
-    found = style()->parameter(QString("hb-param-text-height-tiny"), currentSize );
-    if (found) {
-        mTinySize = currentSize;
-    } 
 }
 
 /*!
-    setFonts.
-*/
+    Set fonts.
+ */
 void  NmMessageListViewItem::setFonts(const QColor &colorRole, 
         HbFontSpec &fontSpec)
 {
-    NM_FUNCTION;
-    
     // Change sizes explicitly since css is overwritten in polish now.    
     if (mSender && mSubject && mTime) {
-        
         if (mPrimarySize) {
             fontSpec.setTextHeight(mPrimarySize);
         }      
         mSender->setFontSpec(fontSpec);
         mSender->setTextColor(colorRole);
-        
         if (mSecondarySize) {
             fontSpec.setTextHeight(mSecondarySize);
         }        
         mSubject->setFontSpec(fontSpec);
         mSubject->setTextColor(colorRole);
-
-        if (mTinySize) {
-            fontSpec.setTextHeight(mTinySize);
-        } 
         mTime->setFontSpec(fontSpec);        
         mTime->setTextColor(colorRole);
     }
 }
 
 /*!
-    senderFieldText. Function returns sender field text from
-    envelope based on currently used function
-*/
+    Get sender field text. Function returns sender field text from
+    envelope based on currently used function.
+ */
 QString NmMessageListViewItem::senderFieldText(const NmMessageEnvelope &envelope)
 {
-    NM_FUNCTION;
-    
     QString ret;  
     QVariant folderType = modelIndex().data(
             NmFolderTypeRole).value<QVariant>();
     switch (folderType.toInt()) {
         // Outbox, drafts and sent folder, sender name is 
-        // replaced with first recipient from to/cc list
+        // replaced with first recipient from to/cc list.
         case NmFolderOutbox:
         case NmFolderDrafts:
         case NmFolderSent:
@@ -352,10 +313,9 @@
                     ret += addressToUse.address();                    
                 }               
             }
-            
         }
         break;    
-        // All other folders will show sender display name
+        // All other folders will show sender display name.
         default: 
         {
             QString displayName = envelope.sender().displayName();
@@ -370,4 +330,3 @@
     }
     return ret;
 }
-
--- a/emailuis/nmailui/src/nmmessagesearchlistview.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmmessagesearchlistview.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -673,6 +673,14 @@
 
         mUiEngine.search(mStartParam->mailboxId(), searchStrings);
 
+        // Hide the virtual keyboard
+        QInputContext *ic = qApp->inputContext();
+        if (ic) {
+            QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
+            ic->filterEvent(closeEvent);
+            delete closeEvent;
+        }
+        
         // Hide the "no messages" label if visible and dim the search input.
         noMessagesLabelVisibility(false);
         setSearchInputMode(NmDimmedMode);
--- a/emailuis/nmailui/src/nmrecipientfield.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmrecipientfield.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -17,9 +17,9 @@
 
 #include "nmuiheaders.h"
 
-static const QString NmContactsServiceName = "com.nokia.services.phonebookservices";
-static const QString NmContactsInterfaceName = "Fetch";
-static const QString NmContactsOperationName = "fetch(QString,QString,QString)";
+static const QString NmContactsServiceName = "phonebookservices";
+static const QString NmContactsInterfaceName = "com.nokia.symbian.IContactsFetch";
+static const QString NmContactsOperationName = "multiFetch(QString,QString)";
 
 static const int NmMaxRows = 10000;
 
@@ -36,7 +36,7 @@
     mLaunchContactsPickerButton(NULL)
 {
     NM_FUNCTION;
-    
+
     // Load the widgets from nmeditorview.docml. The names match to the definitions in that docml.
     mWidget = qobject_cast<HbWidget *>
         (mDocumentLoader.findWidget(mObjectPrefix + "Field"));
@@ -47,13 +47,13 @@
     mRecipientsEditor = qobject_cast<NmRecipientLineEdit *>
         (mDocumentLoader.findWidget(mObjectPrefix + "Edit"));
     if (mRecipientsEditor) {
-        mRecipientsEditor->setMaxRows(NmMaxRows);    
+        mRecipientsEditor->setMaxRows(NmMaxRows);
     }
 
     mLaunchContactsPickerButton = qobject_cast<HbPushButton *>
         (mDocumentLoader.findWidget(mObjectPrefix + "Button"));
     if (mLaunchContactsPickerButton) {
-        mLaunchContactsPickerButton->setIcon(NmIcons::getIcon(NmIcons::NmIconContacts));    
+        mLaunchContactsPickerButton->setIcon(NmIcons::getIcon(NmIcons::NmIconContacts));
     }
 
     createConnections();
@@ -65,7 +65,7 @@
 void NmRecipientField::createConnections()
 {
     NM_FUNCTION;
-    
+
     connect(mRecipientsEditor, SIGNAL(textChanged(const QString &)),
         this, SIGNAL(textChanged(const QString &)));
     connect(mRecipientsEditor, SIGNAL(cursorPositionChanged(int, int)),
@@ -76,7 +76,7 @@
         this, SIGNAL(selectionChanged()));
     connect(mLaunchContactsPickerButton, SIGNAL(pressed()),
             this, SIGNAL(launchContactsPickerButtonClicked()));
-    connect(mLaunchContactsPickerButton, SIGNAL(pressed()), 
+    connect(mLaunchContactsPickerButton, SIGNAL(pressed()),
             this, SLOT(launchContactsPicker()));
 }
 
@@ -95,7 +95,7 @@
 qreal NmRecipientField::height()
 {
     NM_FUNCTION;
-    
+
     return mWidget->geometry().height();
 }
 
@@ -105,7 +105,7 @@
 NmRecipientLineEdit *NmRecipientField::editor() const
 {
     NM_FUNCTION;
-    
+
     return mRecipientsEditor;
 }
 
@@ -116,7 +116,7 @@
 const QString NmRecipientField::text() const
 {
     NM_FUNCTION;
-    
+
     return mRecipientsEditor->text();
 }
 
@@ -127,7 +127,7 @@
 void NmRecipientField::setText(const QString &newText)
 {
     NM_FUNCTION;
-    
+
     if (newText != mRecipientsEditor->text()) {
         mRecipientsEditor->setText(newText);
         emit textChanged(newText);
@@ -141,36 +141,35 @@
 void NmRecipientField::launchContactsPicker()
 {
     NM_FUNCTION;
-    
+
     XQApplicationManager mAppmgr;
     XQAiwRequest *launchContactsPickerRequest;
-    
+
     bool isEmbeded = true;
-    launchContactsPickerRequest = mAppmgr.create(NmContactsServiceName, NmContactsInterfaceName, 
+    launchContactsPickerRequest = mAppmgr.create(NmContactsServiceName, NmContactsInterfaceName,
                                                  NmContactsOperationName, isEmbeded);
-    
+
     if (launchContactsPickerRequest) {
         connect(launchContactsPickerRequest, SIGNAL(requestOk(QVariant)),
                 mRecipientsEditor, SLOT(addSelectedContacts(QVariant)));
     }
     else {
-        // Failed creating request 
+        // Failed creating request
         NM_ERROR(1,"XQApplicationManager: failed creating fecth contactspicker request");
 	    return;
     }
 
-    QVariantList args; 
+    QVariantList args;
     args << hbTrId("txt_mail_select_contacts");
-    args << KCntActionEmail; 
-    args << KCntFilterDisplayAll; 
-    launchContactsPickerRequest->setArguments(args); 
-    
+    args << KCntActionEmail;
+    launchContactsPickerRequest->setArguments(args);
+
     // Send request
     if (!launchContactsPickerRequest->send()) {
-       //Failed sending request 
+       //Failed sending request
        NM_ERROR(1,"XQApplicationManager: failed sending request");
     }
-        
+
     delete launchContactsPickerRequest;
     launchContactsPickerRequest = NULL;
 }
--- a/emailuis/nmailui/src/nmutilities.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmutilities.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -264,6 +264,7 @@
     NM_FUNCTION;
 
     HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
+    messageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);  
     messageBox->setText(noteText);
     messageBox->setTimeout(HbMessageBox::NoTimeout); // Note has to be dismissed manually
     messageBox->open(receiver, member);
@@ -292,7 +293,7 @@
 {
     NM_FUNCTION;
 
-    QString ret = "<html><body><br><br>";
+    QString ret = "<html><body>";
     // Append "----- Original message ----" text
     ret+=hbTrId("txt_mail_editor_reply_original_msg");
     // Append sender
--- a/emailuis/nmailui/src/nmviewerheader.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmviewerheader.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -19,6 +19,7 @@
 #include "nmuiheaders.h"
 
 static const qreal NmHeaderLineOpacity = 0.4;
+static const int NmTextWrapWordOrAnywhere = 4;
 
 /*!
     \class NmViewerHeader
@@ -256,19 +257,12 @@
     
     if (mHeaderBox) {        // Initialize recipient box
         if (!mRecipientsBox){
-            mRecipientsBox = new HbTextEdit();
+            mRecipientsBox = new HbLabel();
             HbStyle::setItemName(mRecipientsBox, "recipients");
-            mRecipientsBox->setContextMenuFlags(0);
-            mRecipientsBox->setReadOnly(true);
             mRecipientsBox->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); 
-            // Set text wrapping for from/to/cc address fields using text document
-            QTextOption textOption = mRecipientsBox->document()->defaultTextOption();
-            textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
-            mRecipientsBox->document()->setDefaultTextOption(textOption);
+            mRecipientsBox->setTextWrapping((Hb::TextWrapping)NmTextWrapWordOrAnywhere);
         }
-        connect(mRecipientsBox, SIGNAL(cursorPositionChanged(int, int)),
-                this, SLOT(cursorPositionChanged(int, int)));
-                
+               
         // Set recipients to text edit field as html 
         NmAddress sender = mMessage->envelope().sender();               
         if (mMessage) {
@@ -276,7 +270,6 @@
                                     mMessage->envelope().toRecipients(), 
                                     mMessage->envelope().ccRecipients()));
         }
-        mRecipientsBox->setCursorVisibility(Hb::TextCursorHidden);
         mHeaderBox->setContentWidget(mRecipientsBox);
         // Set box collapsed as default
         mHeaderBox->setCollapsed(true);
@@ -295,7 +288,7 @@
     QString result;
     result.append("<html><body link=\"blue\" topmargin=\"0\" leftmargin=\"0\" marginheight=\"0\"");
     result.append("marginwidth=\"0\">");    
-    result.append("<font face=\"");
+    result.append("<font color=\"black\" face=\"");
     result.append("Nokia Sans");
     result.append("\"size=\"3\">"); 
     // Set text in HTML format based on layout direction
@@ -310,7 +303,9 @@
         int reciCount = to.count();
         for (int i=0; i < reciCount; i++) { 
             result.append(addressToDisplay(to[i]));
-            result.append(" ");
+            if (i!=reciCount-1) {
+                result.append(" ");
+            }
         } 
         reciCount = cc.count();
         if (reciCount) {
@@ -319,7 +314,9 @@
             result.append(" </b>");
             for (int i=0; i < reciCount; i++) {
                 result.append(addressToDisplay(cc[i]));
-                result.append(" "); 
+                if (i!=reciCount-1) {
+                    result.append(" ");
+                }                
             }
         }   
     }
@@ -334,7 +331,9 @@
         int reciCount = to.count();
         for (int i=0; i < reciCount; i++) { 
             result.append(addressToDisplay(to[i]));
-            result.append("; ");
+            if (i!=reciCount-1) {
+                result.append("; ");
+            }
         }
         reciCount = cc.count();
         if (reciCount) {
@@ -343,7 +342,9 @@
             result.append(" </b>");
             for (int i=0; i < reciCount; i++) {
                 result.append(addressToDisplay(cc[i]));
-                result.append("; ");
+                if (i!=reciCount-1) {
+                    result.append("; ");
+                }
             }
         }   
     } 
@@ -374,19 +375,3 @@
     return ret;
 }
 
-/*!
-    Function handles cursor position changes in header group box.
-    E.g link handler.
-*/
-void NmViewerHeader::cursorPositionChanged(int oldPos, int newPos)
-{
-    NM_FUNCTION;
-    
-    Q_UNUSED(oldPos);
-    QString string = mRecipientsBox->anchorAt(newPos); 
-    if (mViewerView&&string.contains("mailto:",Qt::CaseSensitive)){
-        QUrl url(string);     
-        mViewerView->linkClicked(url);
-    }
-}
-
--- a/emailuis/nmailui/src/nmviewerserviceinterface.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmviewerserviceinterface.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -57,10 +57,12 @@
     NM_FUNCTION;
 
     mAsyncReqId = setCurrentRequestAsync();
-
-    NmId mailboxNmId(mailboxId.toULongLong());
-    NmId messageNmId(messageId.toULongLong());
-    NmId folderNmId(folderId.toULongLong());
+    NmId mailboxNmId(0);
+    mailboxNmId = mailboxId.toULongLong();   
+    NmId messageNmId(0);
+    messageNmId = messageId.toULongLong(); 
+    NmId folderNmId(0);
+    folderNmId = folderId.toULongLong();
 
 	// Make sure the app stays background if user presses back in viewer view
 	bool visible = mApplication->updateVisibilityState();
--- a/emailuis/nmailui/src/nmviewerview.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmviewerview.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -34,6 +34,9 @@
 static const QString NmHttpsLinkScheme = "https";
 static const QString NmMailtoLinkScheme = "mailto";
 
+// Local constants
+const qreal NmZoomFactor = 1.5;
+
 /*!
 	\class NmViewerView
 	\brief Mail viewer class
@@ -182,7 +185,8 @@
                 mHeaderWidget->setView(this);
                 mHeaderWidget->rescaleHeader(mScreenSize);
                 mHeaderWidget->setMessage(mMessage);
-                mHeaderStartScenePos = mHeaderWidget->scenePos();
+                QPointF headerStartPos = mHeaderWidget->scenePos();
+                mHeaderStartScenePos = QPointF(0,headerStartPos.y());
             }
 
             // Load webview
@@ -193,7 +197,7 @@
                 QWebSettings *settings = mWebView->settings();
                 if (settings) {
                     settings->setAttribute(QWebSettings::AutoLoadImages, true);
-                    settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);   
+                    settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
                 }
                 QWebPage *page = mWebView->page();
                 if (page) {
@@ -201,6 +205,7 @@
                     if (frame) {
                         frame->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff);
                         frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
+                        frame->setTextSizeMultiplier(NmZoomFactor);
                         connect(mWebView->page()->mainFrame(),
                                 SIGNAL(contentsSizeChanged(const QSize&)),
                             this, SLOT(scaleWebViewWhenLoading(const QSize&)));  
@@ -687,7 +692,7 @@
             else {
                 mWebView->setPreferredWidth(width);
             }
-            mWebView->setPreferredHeight(height);        
+            mWebView->setMinimumHeight(height);
         }
     }
     mLatestLoadingSize = size;
@@ -701,12 +706,9 @@
     QRectF myGeometry = geometry();
     QWebPage *page = mWebView->page();
     if (mWebView && page) {
-        page->setViewportSize(myGeometry.size().toSize());
+        page->setPreferredContentsSize(myGeometry.size().toSize());
         QSizeF contentSize = page->mainFrame()->contentsSize();
-        int width = (int)contentSize.width();
-        int height = (int)contentSize.height();  
-        mWebView->setPreferredWidth(width);
-        mWebView->setPreferredHeight(height);
+        mWebView->setPreferredSize(contentSize);
     }
 }
 
--- a/emailuis/nmailui/src/nmviewerwebview.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmviewerwebview.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -29,7 +29,7 @@
     grabGesture(Qt::TapGesture);
     grabGesture(Qt::PinchGesture);
     // Prevent this widget from accepting focus.
-    setFocusPolicy(Qt::NoFocus);
+    setFocusPolicy(Qt::NoFocus); 
 }
 
 /*!
Binary file emailuis/nmailui/translations/mail.qm has changed
--- a/emailuis/nmailui/translations/mail.ts	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/translations/mail.ts	Wed Aug 18 09:37:47 2010 +0300
@@ -453,8 +453,8 @@
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_status_menu_new_mail">
-    <comment>Secondary text for status menu item: indicates the there are new mail messages</comment>        
-    <source>New Mail</source>
+    <comment>Secondary text for status menu item: indicates the there are new mail messages. We are not going to show the number of messages here. </comment>        
+    <source>New mail</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_notifdialog_sec_medium_graphic</extra-loc-layout_id>    
     <extra-loc-viewid>mail_001_d</extra-loc-viewid>
@@ -493,7 +493,7 @@
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_mail_status_menu_unset">
-    <comment>Primary text for status menu item: indicates that there are unsent messages in outbox. %[]1 is account name.</comment>        
+    <comment>Primary text for status menu item: indicates that there are unsent messages in outbox. %[]1 is account name. The number of unsent mails is not going to be shown here.</comment>        
     <source>%[]1: Unsent</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_notifdialog_pri_medium_graphic</extra-loc-layout_id>    
@@ -513,7 +513,7 @@
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_short_caption_mail">
-    <comment>Short caption text for Mail application. Name of the mail application.</comment>        
+    <comment>Short caption text for Mail application. Name of the mail application. Not in the UI, needed for B&amp;I purposes</comment>        
     <source>Mail</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_grid_applications_sec</extra-loc-layout_id>    
@@ -896,7 +896,7 @@
     <comment>Button that is shown if all the message content is not downloaded while message is opened.</comment>        
     <source>Download rest</source>
     <translation variants="no" type="unfinished"></translation>
-    <extra-loc-layout_id></extra-loc-layout_id>    
+    <extra-loc-layout_id>qtl_dataform_button_sec</extra-loc-layout_id>    
     <extra-loc-viewid>mail_002_b</extra-loc-viewid>
     <extra-loc-positionid>button</extra-loc-positionid>
     <extra-loc-feature>mail</extra-loc-feature>
@@ -923,7 +923,7 @@
     <extra-loc-blank>False</extra-loc-blank>
 </message>
 <message numerus="no" id="txt_long_caption_mail">
-    <comment>Long caption text for Mail application. Name of the mail application.</comment>        
+    <comment>Long caption text for Mail application. Name of the mail application. Not in the UI, needed for B&amp;I purposes</comment>        
     <source>Mail</source>
     <translation variants="no" type="unfinished"></translation>
     <extra-loc-layout_id>qtl_list_pri_large_graphic</extra-loc-layout_id>    
--- a/emailuis/nmailuiengine/bwins/nmailuiengineu.def	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailuiengine/bwins/nmailuiengineu.def	Wed Aug 18 09:37:47 2010 +0300
@@ -312,4 +312,5 @@
 	?qt_metacall@NmUiEngine@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 311 NONAME ; int NmUiEngine::qt_metacall(enum QMetaObject::Call, int, void * *)
 	?message@NmDataManager@@QAEPAVNmMessage@@ABVNmId@@00@Z @ 312 NONAME ; class NmMessage * NmDataManager::message(class NmId const &, class NmId const &, class NmId const &)
 	?metaObject@NmOperation@@UBEPBUQMetaObject@@XZ @ 313 NONAME ; struct QMetaObject const * NmOperation::metaObject(void) const
+	?enableSyncIndicator@NmUiEngine@@QAEX_N@Z @ 314 NONAME ; void NmUiEngine::enableSyncIndicator(bool)
 
--- a/emailuis/nmailuiengine/eabi/nmailuiengineu.def	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailuiengine/eabi/nmailuiengineu.def	Wed Aug 18 09:37:47 2010 +0300
@@ -319,4 +319,5 @@
 	_ZThn8_N18NmBaseClientPlugin10getActionsERK15NmActionRequestR5QListIP8NmActionE @ 318 NONAME
 	_ZThn8_N18NmBaseClientPluginD0Ev @ 319 NONAME
 	_ZThn8_N18NmBaseClientPluginD1Ev @ 320 NONAME
+	_ZN10NmUiEngine19enableSyncIndicatorEb @ 321 NONAME
 
--- a/emailuis/nmailuiengine/inc/nmuiengine.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailuiengine/inc/nmuiengine.h	Wed Aug 18 09:37:47 2010 +0300
@@ -56,7 +56,7 @@
     void refreshMailboxListModel();
 
     NmId getPluginIdByMailboxId(quint32 accountId);
-    
+
     NmMessageListModel &messageListModel(const NmId &mailboxId,
                                          const NmId &folderId);
 
@@ -74,24 +74,24 @@
         const NmId &folderId,
         const NmId &messageId);
 
-    QPointer<NmOperation> fetchMessagePart( 
+    QPointer<NmOperation> fetchMessagePart(
         const NmId &mailboxId,
         const NmId &folderId,
         const NmId &messageId,
         const NmId &messagePartId);
-    
-    QPointer<NmOperation> fetchMessageParts( 
+
+    QPointer<NmOperation> fetchMessageParts(
         const NmId &mailboxId,
         const NmId &folderId,
         const NmId &messageId,
         const QList<NmId> &messagePartIds);
-    
+
     XQSharableFile messagePartFile(
        const NmId &mailboxId,
        const NmId &folderId,
        const NmId &messageId,
        const NmId &messagePartId);
-    
+
     NmMailboxMetaData *mailboxById(const NmId &mailboxId);
 
     int contentToMessagePart(
@@ -131,31 +131,31 @@
     int refreshMailbox(const NmId &mailboxId);
 
     int goOnline(const NmId &mailboxId);
-    
+
     int goOffline(const NmId &mailboxId);
-    
+
     int removeMessage(const NmId &mailboxId,
                       const NmId &folderId,
                       const NmId &messageId);
-    
+
     void removeDraftMessage(NmMessage *message);
-    
+
     void saveDraftMessage(NmMessage *message,
                           const QList<NmOperation*> &preliminaryOperations);
-    
+
     void sendMessage(NmMessage *message,
                      const QList<NmOperation*> &preliminaryOperations);
 
     bool isSendingMessage() const;
 
     const NmMessage *messageBeingSent() const;
-    
+
     QPointer<NmAddAttachmentsOperation> addAttachments(
         const NmMessage &message,
         const QList<QString> &fileList);
-    
+
     QPointer<NmOperation> removeAttachment(
-        const NmMessage &message, 
+        const NmMessage &message,
         const NmId &attachmentPartId);
 
     NmSyncState syncState(const NmId& mailboxId);
@@ -166,11 +166,13 @@
                const QStringList &searchStrings);
 
     int cancelSearch(const NmId &mailboxId);
-    
+
     NmFolderType folderTypeById(NmId mailboxId, NmId folderId);
 
     void updateActiveFolder(const NmId &mailboxId, const NmId &folderId);
-    
+
+    void enableSyncIndicator(bool enabled);
+
 public slots:
 
     void handleCompletedSendOperation();
@@ -189,17 +191,17 @@
 
     void handleMessageEvent(NmMessageEvent event,
                             const NmId &folderId,
-                            const QList<NmId> &messageIds, 
+                            const QList<NmId> &messageIds,
                             const NmId& mailboxId);
-    
+
     void handleMailboxEvent(NmMailboxEvent event,
                             const QList<NmId> &mailboxIds);
 
     void handleMatchFound(const NmId &messageId, const NmId &folderId);
-    
+
     void messageEventForListModel(NmMessageEvent event,
                             const NmId &folderId,
-                            const QList<NmId> &messageIds, 
+                            const QList<NmId> &messageIds,
                             const NmId& mailboxId);
 
 
--- a/emailuis/nmailuiengine/src/nmuiengine.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailuiengine/src/nmuiengine.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -32,7 +32,7 @@
 /*!
     Constructor
 */
-NmUiEngine::NmUiEngine() 
+NmUiEngine::NmUiEngine()
 : mMailboxListModel(NULL),
   mInboxListModel(NULL),
   mMessageListModel(NULL),
@@ -43,7 +43,7 @@
   mDraftMessage(NULL)
 {
     NM_FUNCTION;
-    
+
     mPluginFactory = NmDataPluginFactory::instance();
     mDataManager = new NmDataManager();
     // Connect to the plugins to receive change notifications
@@ -56,7 +56,7 @@
                  this, SLOT(handleMailboxEvent(NmMailboxEvent, const QList<NmId> &)),
                  Qt::UniqueConnection);
             // connect message events
-            QObject::connect(plugin, 
+            QObject::connect(plugin,
                 SIGNAL(messageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId&)),
                 this, SLOT(handleMessageEvent(NmMessageEvent, const NmId &, const QList<NmId> &, const NmId &)),
                 Qt::UniqueConnection);
@@ -65,7 +65,7 @@
                 SIGNAL(connectionEvent(NmConnectState, const NmId &, const int)),
                 this,
                 SLOT(handleConnectEvent(NmConnectState, const NmId &, const int)),
-                Qt::UniqueConnection);       
+                Qt::UniqueConnection);
             // do the subscriptions also
             NmDataPluginInterface *pluginInterface = mPluginFactory->interfaceInstance(plugin);
             if (pluginInterface) {
@@ -87,10 +87,9 @@
 NmUiEngine::~NmUiEngine()
 {
     NM_FUNCTION;
-    
-    HbIndicator indicator;
-    indicator.deactivate(syncIndicatorName, QVariant());
-    
+
+    enableSyncIndicator(false);
+
     if (mMessageSearchListModel) {
         delete mMessageSearchListModel;
         mMessageSearchListModel = NULL;
@@ -137,7 +136,7 @@
     }
 
     if (mRemoveDraftOperation && mRemoveDraftOperation->isRunning()) {
-        mRemoveDraftOperation->cancelOperation();        
+        mRemoveDraftOperation->cancelOperation();
     }
 
     if (mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
@@ -161,7 +160,7 @@
 NmUiEngine *NmUiEngine::instance()
 {
     NM_FUNCTION;
-    
+
     if (!mInstance) {
     	mInstance = new NmUiEngine();
     }
@@ -175,7 +174,7 @@
 void NmUiEngine::releaseInstance(NmUiEngine *&instance)
 {
     NM_FUNCTION;
-    
+
     //can't have passed out instances if we don't have any
     if (mInstance) {
         if(instance == mInstance) {
@@ -196,14 +195,14 @@
 NmMailboxListModel &NmUiEngine::mailboxListModel()
 {
     NM_FUNCTION;
-    
+
     if (!mMailboxListModel) {
         refreshMailboxListModel(); // creates the model too
     }
-    
+
     return *mMailboxListModel;
 }
-        
+
 /*!
     Populate the list model with the mailbox and top level folder objects. The model is
     updated dynamically. Creates the model if needed.
@@ -211,10 +210,10 @@
 void NmUiEngine::refreshMailboxListModel()
 {
     NM_FUNCTION;
-    
+
     if (!mMailboxListModel) {
         mMailboxListModel = new NmMailboxListModel(*mDataManager);
-        
+
         // Connect the model to the plugins to receive change notifications
         QList<QObject*> *dataPlugins = mPluginFactory->pluginInstances();
         for (int i = 0; i < dataPlugins->count(); i++) {
@@ -227,7 +226,7 @@
     } else {
         mMailboxListModel->clear();
     }
-    
+
     QList<NmMailbox*> mailboxList;
     mDataManager->listMailboxes(mailboxList);
     mMailboxListModel->refresh(mailboxList);
@@ -238,7 +237,7 @@
 
 
 /*!
-    Returns a message list model for a folder identified by \a mailboxId and 
+    Returns a message list model for a folder identified by \a mailboxId and
     \a folderId. The model is updated dynamically. The ownership of the model
     object is not moved to the caller.
 */
@@ -252,23 +251,23 @@
     if (standardFolderId(mailboxId,NmFolderInbox)==folderId){
         isInbox=true;
     }
-    if (plugin) { 
+    if (plugin) {
         // Connect plugin message events to handler slot messageEventForListModel
-        QObject::connect(plugin, SIGNAL(messageEvent(NmMessageEvent, const NmId &, 
+        QObject::connect(plugin, SIGNAL(messageEvent(NmMessageEvent, const NmId &,
                                 const QList<NmId> &, const NmId&)),
-                                this, SLOT(messageEventForListModel(NmMessageEvent, 
+                                this, SLOT(messageEventForListModel(NmMessageEvent,
                                 const NmId &, const QList<NmId> &, const NmId&)), Qt::UniqueConnection );
         // Create inbox list model only once when entering to inbox for the first time
-        // or re-create inbox list model when mailbox has changed    
+        // or re-create inbox list model when mailbox has changed
         if ((!mInboxListModel&&isInbox)||
             (mInboxListModel&&isInbox&&mailboxId!=mInboxListModel->currentMailboxId())){
             // Delete previous model and set to NULL. Deleting model will also
-            // delete all items in model. 
+            // delete all items in model.
             if (mInboxListModel){
                 delete mInboxListModel;
                 mInboxListModel=NULL;
             }
-            // Create new inbox model 
+            // Create new inbox model
             mInboxListModel = new NmMessageListModel(*mDataManager);
             // Initial fill up of inbox list model, otherwise updated in the background
             QList<NmMessageEnvelope*> messageEnvelopeList;
@@ -288,18 +287,18 @@
                 mMessageListModel=NULL;
             }
             mMessageListModel = new NmMessageListModel(*mDataManager);
-    
-            // Fill up other model 
+
+            // Fill up other model
             QList<NmMessageEnvelope*> messageEnvelopeList;
             mDataManager->listMessages(mailboxId, folderId, messageEnvelopeList);
             mMessageListModel->refresh(mailboxId, folderId, messageEnvelopeList);
 
             while (!messageEnvelopeList.isEmpty()) {
-                delete messageEnvelopeList.takeFirst(); 
-            }             
-        }    
+                delete messageEnvelopeList.takeFirst();
+            }
+        }
     }
-     
+
     // Connect sync state changed
     if (plugin){
         QObject::connect(
@@ -309,7 +308,7 @@
     }
     NmMessageListModel* ret(NULL);
     if (isInbox){
-        ret = mInboxListModel;    
+        ret = mInboxListModel;
         // Inbox list model is queried, other model is not
         // needed anymore and memory should be freeded
         if (mMessageListModel){
@@ -318,7 +317,7 @@
         }
     }
     else {
-        ret = mMessageListModel;    
+        ret = mMessageListModel;
     }
     return *ret;
 }
@@ -334,7 +333,7 @@
 NmMessageListModel &NmUiEngine::messageListModelForSearch(const NmId &mailboxId)
 {
     NM_FUNCTION;
-    
+
     Q_UNUSED(mailboxId);
 
     if (!mMessageSearchListModel) {
@@ -364,7 +363,7 @@
 
 
 /*!
-    Get the identifier of the standard folder of a type \a folderType 
+    Get the identifier of the standard folder of a type \a folderType
     from the mailbox \a mailboxId.
 */
 NmId NmUiEngine::standardFolderId(
@@ -372,7 +371,7 @@
     NmFolderType folderType)
 {
     NM_FUNCTION;
-    
+
     NmId value;
     if (folderType != NmFolderOther) {
         NmDataPluginInterface *plugin =
@@ -394,7 +393,7 @@
                       const NmId &messageId)
 {
     NM_FUNCTION;
-    
+
     NmMessage *message = mDataManager->message(mailboxId, folderId, messageId);
     return message;
 }
@@ -407,7 +406,7 @@
     const NmId &messageId )
 {
     NM_FUNCTION;
-    
+
     QPointer<NmOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -427,7 +426,7 @@
     const NmId &messagePartId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -447,7 +446,7 @@
     const QList<NmId> &messagePartIds)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -467,7 +466,7 @@
         const NmId &messagePartId)
 {
     NM_FUNCTION;
-    
+
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
     if (plugin) {
@@ -488,7 +487,7 @@
     NmMessagePart &messagePart)
 {
     NM_FUNCTION;
-    
+
     return mDataManager->contentToMessagePart(mailboxId, folderId, messageId, messagePart);
 }
 
@@ -507,17 +506,17 @@
                                const QList<NmId> &messageIdList)
 {
     NM_FUNCTION;
-    
+
     int result(NmNotFoundError);
-    
+
     bool isInbox(false);
     if (standardFolderId(mailboxId,NmFolderInbox)==folderId){
         isInbox=true;
-    } 
+    }
     if (isInbox&&mInboxListModel){
         mInboxListModel->handleMessageEvent(NmMessageDeleted, folderId,
-                                               messageIdList, mailboxId);   
-    }   
+                                               messageIdList, mailboxId);
+    }
     else if (mMessageListModel) {
 	    mMessageListModel->handleMessageEvent(NmMessageDeleted, folderId,
                                               messageIdList, mailboxId);
@@ -559,7 +558,7 @@
         const QList<const NmMessageEnvelope*> &envelopeList)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmStoreEnvelopesOperation> operation(NULL);
     NmMessageListModel *theMessageListModel = mMessageListModel;
 
@@ -569,7 +568,7 @@
 
     if (theMessageListModel && envelopeList.count()) {
         QList<NmId> messageIdList;
-        
+
         for (int i(0); i < envelopeList.count(); i++){
             messageIdList.append(envelopeList[i]->messageId());
         }
@@ -628,7 +627,7 @@
 QPointer<NmMessageCreationOperation> NmUiEngine::createNewMessage(const NmId &mailboxId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageCreationOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -647,7 +646,7 @@
         const NmId &originalMessageId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageCreationOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -667,7 +666,7 @@
         bool replyAll)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageCreationOperation> value(NULL);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -683,7 +682,7 @@
 int NmUiEngine::saveMessage(const NmMessage &message)
 {
     NM_FUNCTION;
-    
+
     const NmId &mailboxId = message.envelope().mailboxId();
     int ret(NmNotFoundError);
     NmDataPluginInterface *plugin =
@@ -700,15 +699,14 @@
 int NmUiEngine::refreshMailbox(const NmId &mailboxId )
 {
     NM_FUNCTION;
-    
+
     int ret(NmNotFoundError);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
     if (plugin) {
         ret = plugin->refreshMailbox(mailboxId);
         if (NmNoError == ret) {
-            HbIndicator indicator;
-            indicator.activate(syncIndicatorName, QVariant());
+            enableSyncIndicator(true);
         }
     }
     return ret;
@@ -720,7 +718,7 @@
 int NmUiEngine::goOnline(const NmId &mailboxId )
 {
     NM_FUNCTION;
-    
+
     int ret(NmNotFoundError);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -736,7 +734,7 @@
 int NmUiEngine::goOffline(const NmId &mailboxId )
 {
     NM_FUNCTION;
-    
+
     int ret(NmNotFoundError);
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(mailboxId);
@@ -756,7 +754,7 @@
     const NmId &messageId)
 {
     NM_FUNCTION;
-    
+
     int result(NmNotFoundError);
     NmDataPluginInterface *plugin =
             mPluginFactory->interfaceInstance(mailboxId);
@@ -768,7 +766,7 @@
 
 
 /*!
-  Handles draft message deletion after editor has closed, takes ownership of message. 
+  Handles draft message deletion after editor has closed, takes ownership of message.
  */
 void NmUiEngine::removeDraftMessage(NmMessage *message)
 {
@@ -777,7 +775,7 @@
     if (message) {
         NmDataPluginInterface *plugin =
             mPluginFactory->interfaceInstance(message->envelope().mailboxId());
-        
+
         if (plugin) {
             // to be on the safer side:
             // we shouldn't even be here if mRemoveDraftOperation != NULL
@@ -786,15 +784,15 @@
             }
             // ownership of message changes
             mRemoveDraftOperation = plugin->removeDraftMessage(message);
-            
+
             if (mRemoveDraftOperation) {
-                connect(mRemoveDraftOperation, 
-                        SIGNAL(operationCompleted(int)), 
-                        this, 
+                connect(mRemoveDraftOperation,
+                        SIGNAL(operationCompleted(int)),
+                        this,
                         SLOT(handleCompletedRemoveDraftOperation()));
             }
         }
-    }    
+    }
 }
 
 /*!
@@ -804,41 +802,41 @@
                                   const QList<NmOperation*> &preliminaryOperations)
 {
     NM_FUNCTION;
-    
+
     if (message) {
         NmDataPluginInterface *plugin =
             mPluginFactory->interfaceInstance(message->envelope().mailboxId());
-        
+
         if (plugin) {
             // to be on the safer side:
             // we shouldn't even be here if mSaveDraftOperation != NULL
             if (mSaveDraftOperation && mSaveDraftOperation->isRunning()) {
                 mSaveDraftOperation->cancelOperation();
             }
-            
+
             mSaveDraftOperation = plugin->saveMessageWithSubparts(*message);
-            
+
             if (mSaveDraftOperation) {
-                // Ownership of message changes but saveMessageWithSubparts operation only makes a 
+                // Ownership of message changes but saveMessageWithSubparts operation only makes a
                 // copy so we handle the msg object deletion in engine. mDraftMessage is deleted
-                // in handleCompletedSaveDraftOperation once operation finishes. 
+                // in handleCompletedSaveDraftOperation once operation finishes.
                 if(mDraftMessage) {
                     delete mDraftMessage;
                     mDraftMessage = NULL;
                 }
                 mDraftMessage = message;
                 message = NULL;
-                
+
                 for (int i(0); i < preliminaryOperations.count(); i++ ) {
                     QPointer<NmOperation> op = preliminaryOperations[i];
                     mSaveDraftOperation->addPreliminaryOperation(op);
                 }
-                
-                connect(mSaveDraftOperation, 
-                        SIGNAL(operationCompleted(int)), 
-                        this, 
+
+                connect(mSaveDraftOperation,
+                        SIGNAL(operationCompleted(int)),
+                        this,
                         SLOT(handleCompletedSaveDraftOperation()));
-                
+
             }
         }
     }
@@ -850,12 +848,12 @@
 void NmUiEngine::sendMessage(NmMessage *message, const QList<NmOperation *> &preliminaryOperations)
 {
     NM_FUNCTION;
-    
+
     //First trigger message storing
     if (message) {
         NmDataPluginInterface *plugin =
             mPluginFactory->interfaceInstance(message->envelope().mailboxId());
-        
+
         if (plugin) {
             // to be on the safer side:
             // we shouldn't even be here if mSendOperation != NULL
@@ -871,10 +869,10 @@
                     QPointer<NmOperation> op = preliminaryOperations[i];
                     mSendOperation->addPreliminaryOperation(op);
                 }
-                
-                connect(mSendOperation, 
-                        SIGNAL(operationCompleted(int)), 
-                        this, 
+
+                connect(mSendOperation,
+                        SIGNAL(operationCompleted(int)),
+                        this,
                         SLOT(handleCompletedSendOperation()));
             }
         }
@@ -887,7 +885,7 @@
 bool NmUiEngine::isSendingMessage() const
 {
     NM_FUNCTION;
-    
+
     int ret(false);
     if (mSendOperation && mSendOperation->isRunning()) {
         ret = true;
@@ -901,13 +899,13 @@
 const NmMessage *NmUiEngine::messageBeingSent() const
 {
     NM_FUNCTION;
-    
+
     const NmMessage *message = NULL;
-    
+
     if (mSendOperation != NULL) {
         message = mSendOperation->getMessage();
     }
-    
+
     return message;
 }
 
@@ -920,11 +918,11 @@
     const QList<QString> &fileList)
 {
     NM_FUNCTION;
-    
+
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(message.envelope().mailboxId());
-    
-    QPointer<NmAddAttachmentsOperation> ret(NULL);    
+
+    QPointer<NmAddAttachmentsOperation> ret(NULL);
     if (plugin) {
         ret = plugin->addAttachments(message, fileList);
     }
@@ -940,11 +938,11 @@
     const NmId &attachmentPartId)
 {
     NM_FUNCTION;
-    
+
     NmDataPluginInterface *plugin =
         mPluginFactory->interfaceInstance(message.envelope().mailboxId());
-    
-    QPointer<NmOperation> ret(NULL);   
+
+    QPointer<NmOperation> ret(NULL);
     if (plugin) {
         ret = plugin->removeAttachment(message, attachmentPartId);
     }
@@ -957,7 +955,7 @@
 NmSyncState NmUiEngine::syncState(const NmId& mailboxId)
 {
     NM_FUNCTION;
-    
+
     NmDataPluginInterface *plugin =
                 mPluginFactory->interfaceInstance(mailboxId);
     if (plugin) {
@@ -974,7 +972,7 @@
 NmConnectState NmUiEngine::connectionState(const NmId& mailboxId)
 {
     NM_FUNCTION;
-    
+
     NmDataPluginInterface *plugin =
                 mPluginFactory->interfaceInstance(mailboxId);
     if (plugin) {
@@ -998,7 +996,7 @@
                        const QStringList &searchStrings)
 {
     NM_FUNCTION;
-    
+
     // Get the plugin instance.
     QObject *pluginInstance = mPluginFactory->pluginInstance(mailboxId);
 
@@ -1010,11 +1008,11 @@
 
         connect(pluginInstance, SIGNAL(matchFound(const NmId &, const NmId &)),
                 this, SLOT(handleMatchFound(const NmId &, const NmId &)),
-                Qt::UniqueConnection); 
+                Qt::UniqueConnection);
 
         connect(pluginInstance, SIGNAL(searchComplete()),
                 this, SIGNAL(searchComplete()),
-                Qt::UniqueConnection);    
+                Qt::UniqueConnection);
     }
 
     int retVal(NmNoError);
@@ -1027,7 +1025,7 @@
         // Start the search.
         retVal = pluginInterface->search(mailboxId, searchStrings);
     }
-    
+
     return retVal;
 }
 
@@ -1042,7 +1040,7 @@
 int NmUiEngine::cancelSearch(const NmId &mailboxId)
 {
     NM_FUNCTION;
-    
+
     int retVal(NmNoError);
 
     // Get the plugin interface.
@@ -1052,20 +1050,23 @@
     if (pluginInterface) {
         // Cancel the search.
         retVal = pluginInterface->cancelSearch(mailboxId);
-    }  
-    return retVal;    
+    }
+    return retVal;
 }
 
 /*!
+    Get mailbox folder type by folder id
+    \param mailboxId id of the mailbox
+    \param folderId id of the folder
     \return Folder type
 */
 NmFolderType NmUiEngine::folderTypeById(NmId mailboxId, NmId folderId)
 {
     NM_FUNCTION;
-    
+
     NmFolderType ret(NmFolderInbox);
     if (mDataManager){
-        ret = mDataManager->folderTypeById(mailboxId,folderId);    
+        ret = mDataManager->folderTypeById(mailboxId,folderId);
     }
     return ret;
 }
@@ -1078,8 +1079,8 @@
 void NmUiEngine::updateActiveFolder(const NmId &mailboxId, const NmId &folderId)
 {
     NM_FUNCTION;
-    
-    NmApplicationStateInterface *interface = 
+
+    NmApplicationStateInterface *interface =
         mPluginFactory->applicationStateInterfaceInstance(mailboxId);
     if (interface) {
         interface->updateActiveFolder(mailboxId, folderId);
@@ -1092,7 +1093,7 @@
 void NmUiEngine::handleCompletedSendOperation()
 {
     NM_FUNCTION;
-    
+
     emit sendOperationCompleted();
 }
 
@@ -1102,7 +1103,7 @@
 void NmUiEngine::handleCompletedRemoveDraftOperation()
 {
     NM_FUNCTION;
-    
+
     // draft message deletion observing not yet implemented...
 }
 
@@ -1112,7 +1113,7 @@
 void NmUiEngine::handleCompletedSaveDraftOperation()
 {
     NM_FUNCTION;
-    
+
     // delete message object since it's not needed anymore
     if(mDraftMessage) {
         delete mDraftMessage;
@@ -1126,12 +1127,12 @@
 void NmUiEngine::handleSyncStateEvent(NmSyncState syncState, const NmOperationCompletionEvent &event)
 {
     NM_FUNCTION;
-    
+
     if ( syncState == SyncComplete ) {
         // signal for reporting about (sync) operation completion status
         emit operationCompleted(event);
-        HbIndicator indicator;
-        indicator.deactivate(syncIndicatorName, QVariant());
+
+        enableSyncIndicator(false);
     }
 
     // signal for handling sync state icons
@@ -1139,23 +1140,42 @@
 }
 
 /*!
-    Emits signals based on message events coming from plugins. 
+    Enable or disable sync indicator
+
+    \param enabled true if indicator is enabled, false if disabled
+*/
+void NmUiEngine::enableSyncIndicator(bool enabled)
+{
+	NM_FUNCTION;
+
+    HbIndicator indicator;
+    if (enabled) {
+        indicator.activate(syncIndicatorName, QVariant());
+	}
+    else {
+        indicator.deactivate(syncIndicatorName, QVariant());
+	}
+}
+
+
+/*!
+    Emits signals based on message events coming from plugins.
     Currently only NmMessageDeleted is handled.
 */
 void NmUiEngine::handleMessageEvent(NmMessageEvent event,
                                     const NmId &folderId,
-                                    const QList<NmId> &messageIds, 
+                                    const QList<NmId> &messageIds,
                                     const NmId& mailboxId)
 {
     NM_FUNCTION;
-    
+
     switch (event) {
         case NmMessageDeleted:
         {
             for (int i(0); i < messageIds.count(); i++) {
                 emit messageDeleted(mailboxId, folderId, messageIds[i]);
             }
-           break; 
+           break;
         }
         default:
         break;
@@ -1163,21 +1183,21 @@
 }
 
 /*!
-    Emits signals based on mailbox events coming from plugins. 
+    Emits signals based on mailbox events coming from plugins.
     Currently only NmMailboxDeleted is handled.
 */
 void NmUiEngine::handleMailboxEvent(NmMailboxEvent event,
                                     const QList<NmId> &mailboxIds)
 {
     NM_FUNCTION;
-    
+
     switch (event) {
         case NmMailboxDeleted:
         {
             for (int i(0); i < mailboxIds.count(); i++) {
                 emit mailboxDeleted(mailboxIds[i]);
             }
-           break; 
+           break;
         }
         default:
         break;
@@ -1194,7 +1214,7 @@
 void NmUiEngine::handleMatchFound(const NmId &messageId, const NmId &folderId)
 {
     NM_FUNCTION;
-    
+
     if (!mMessageSearchListModel) {
         // No search list model!
         return;
@@ -1222,21 +1242,21 @@
 */
 void NmUiEngine::messageEventForListModel(NmMessageEvent event,
                         const NmId &folderId,
-                        const QList<NmId> &messageIds, 
+                        const QList<NmId> &messageIds,
                         const NmId& mailboxId)
 {
     NM_FUNCTION;
-    
+
     // Forward event to both list models. Models will take care of checking
     // whether event really belongs to current mailbox & folder
     if (mInboxListModel){
         mInboxListModel->handleMessageEvent(event, folderId,
-                                            messageIds, mailboxId);   
+                                            messageIds, mailboxId);
     }
     if (mMessageListModel){
         mMessageListModel->handleMessageEvent(event, folderId,
-                                              messageIds, mailboxId);    
-    }  
+                                              messageIds, mailboxId);
+    }
 }
 
 /*!
@@ -1245,13 +1265,13 @@
 void NmUiEngine::handleConnectEvent(NmConnectState connectState, const NmId &mailboxId, const int errorCode)
 {
     NM_FUNCTION;
-    
+
     // signal for connection state icon handling
     emit connectionEvent(connectState, mailboxId);
 
     // in case going offline w/ error, emit signal to UI
     if ( connectState == Disconnected && errorCode!= NmNoError ) {
-        NmOperationCompletionEvent event={NoOp, errorCode, mailboxId, 0, 0}; 
+        NmOperationCompletionEvent event={NoOp, errorCode, mailboxId, 0, 0};
         emit operationCompleted(event);
     }
 }
@@ -1262,7 +1282,7 @@
 NmId NmUiEngine::getPluginIdByMailboxId(quint32 accountId)
 {
     NM_FUNCTION;
-    
+
     NmId fullId = NULL;
     fullId.setId32(accountId);
     QList<NmId> mailboxList;
--- a/emailuis/nmailuiwidgets/bwins/nmailuiwidgetsu.def	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailuiwidgets/bwins/nmailuiwidgetsu.def	Wed Aug 18 09:37:47 2010 +0300
@@ -130,4 +130,6 @@
 	?tr@NmHtmlLineEdit@@SA?AVQString@@PBD0@Z @ 129 NONAME ; class QString NmHtmlLineEdit::tr(char const *, char const *)
 	?qt_metacall@NmHtmlLineEdit@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 130 NONAME ; int NmHtmlLineEdit::qt_metacall(enum QMetaObject::Call, int, void * *)
 	?qt_metacall@NmBaseViewScrollArea@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 131 NONAME ; int NmBaseViewScrollArea::qt_metacall(enum QMetaObject::Call, int, void * *)
+	?checkColor@NmAttachmentListWidget@@AAE?AVQColor@@XZ @ 132 NONAME ; class QColor NmAttachmentListWidget::checkColor(void)
+	?changeEvent@NmAttachmentListWidget@@MAEXPAVQEvent@@@Z @ 133 NONAME ; void NmAttachmentListWidget::changeEvent(class QEvent *)
 
--- a/emailuis/nmailuiwidgets/inc/nmailuiwidgetsheaders.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailuiwidgets/inc/nmailuiwidgetsheaders.h	Wed Aug 18 09:37:47 2010 +0300
@@ -47,6 +47,7 @@
 #include <hbinstance.h>
 #include <hbcolorscheme.h>
 #include <hbtapgesture.h>
+#include <hbevent.h>
 
 // nmail
 #include <nmaddress.h>
--- a/emailuis/nmailuiwidgets/inc/nmattachmentlistwidget.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailuiwidgets/inc/nmattachmentlistwidget.h	Wed Aug 18 09:37:47 2010 +0300
@@ -50,6 +50,9 @@
     void handleLongPressed(QPointF point);
     void handleItemActivated();
     void orientationChanged(Qt::Orientation);
+   
+protected:
+    virtual void changeEvent(QEvent *event);
 
 signals:
     void itemActivated(int index);
@@ -61,6 +64,7 @@
     int findItem(const QObject *obj);
     void insertItemToLayout(NmAttachmentListItem* item);
     void rearrangeLayout();
+    QColor checkColor();
         
 private:
     Q_DISABLE_COPY(NmAttachmentListWidget)
--- a/emailuis/nmailuiwidgets/nmailuiwidgets.pro	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailuiwidgets/nmailuiwidgets.pro	Wed Aug 18 09:37:47 2010 +0300
@@ -61,3 +61,5 @@
 }
        
 RESOURCES += nmailuiwidgets.qrc
+
+DOCML += resources/nmattachmentlistwidget.docml
--- a/emailuis/nmailuiwidgets/nmailuiwidgets.qrc	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailuiwidgets/nmailuiwidgets.qrc	Wed Aug 18 09:37:47 2010 +0300
@@ -1,9 +1,10 @@
 <RCC>
-    <qresource prefix="/" >
-        <file alias="nmattachmentlistwidget.docml" >resources/nmattachmentlistwidget.docml</file>
-        <file alias="nmattachmentlistitem.widgetml" >resources/nmattachmentlistitem.widgetml</file>
-        <file alias="nmattachmentlistitem.css" >resources/nmattachmentlistitem.css</file>
-        <file alias="nmeditortextedit.css" >resources/nmeditortextedit.css</file>
-        <file alias="nmeditortextedit.widgetml" >resources/nmeditortextedit.widgetml</file>
+    <qresource prefix="/">
+        <file alias="nmattachmentlistwidget.docml">resources/nmattachmentlistwidget.docml.bin</file>
+        <file alias="nmattachmentlistitem.widgetml">resources/nmattachmentlistitem.widgetml</file>
+        <file alias="nmattachmentlistitem.css">resources/nmattachmentlistitem.css</file>
+        <file alias="nmeditortexteditblack.css">resources/nmeditortexteditblack.css</file>
+        <file alias="nmeditortexteditblue.css">resources/nmeditortexteditblue.css</file>
+        <file alias="nmeditortextedit.widgetml">resources/nmeditortextedit.widgetml</file>
     </qresource>
 </RCC>
--- a/emailuis/nmailuiwidgets/src/nmattachmentlistitem.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailuiwidgets/src/nmattachmentlistitem.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -63,6 +63,9 @@
     NM_FUNCTION;
     
     mTextColor=color;
+    if (mTextColor.isValid() && mFileNameText){
+        mFileNameText->setTextColor(mTextColor);
+    }    
 }
 
 /*!
--- a/emailuis/nmailuiwidgets/src/nmattachmentlistwidget.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailuiwidgets/src/nmattachmentlistwidget.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -19,6 +19,7 @@
 
 static const QString FILE_PATH_DOCML = ":nmattachmentlistwidget.docml";
 static const QString ATTACHMENT_WIDGET = "nmattachmentlistwidget";
+static const QString NmAttachmentTextColor = "qtc_default_main_pane_normal";
 
 static const qreal NmItemLineOpacity = 0.4;
 
@@ -156,9 +157,7 @@
     connect(item, SIGNAL(itemLongPressed(QPointF)), this, SLOT(handleLongPressed(QPointF)));
 
     //set texts
-    if (mTextColor.isValid()){
-        item->setTextColor(mTextColor);    
-    }
+    item->setTextColor(checkColor());      
     item->setFileNameText(fileName);
     item->setFileSizeText(fileSize);
 
@@ -264,15 +263,7 @@
         
         // Use text color as a line color if set, otherwise use theme
         // normal list content color.
-        if (mTextColor.isValid()){
-            painter->setPen(mTextColor);
-        }
-        else{
-            QColor col = HbColorScheme::color("list_item_content_normal");
-            if (col.isValid()) {
-                painter->setPen(col);
-            }
-        }
+        painter->setPen(checkColor());
         painter->setOpacity(NmItemLineOpacity);
         // Draw line after each item
         int rowCount = mLayout->rowCount();
@@ -467,7 +458,7 @@
         NM_ERROR(1,"NmAttachmentListWidget::rearrangeLayout: Layout loading failed!");
         return;
     }
-
+    
     //remove all items from the layout
     int count(mLayout->count());
     for(int i = count - 1; i >= 0; --i){
@@ -475,7 +466,41 @@
     }
 
     //then add them back
+    QColor textColor = checkColor();    
     foreach(NmAttachmentListItem *item, mItemList){
+        item->setTextColor(textColor);
         insertItemToLayout(item);
     }
 }
+
+/*!
+    Helper function to set text color
+*/
+QColor NmAttachmentListWidget::checkColor()
+{
+    NM_FUNCTION;
+    
+    QColor retColor;
+
+    if (mTextColor.isValid()){
+        retColor = mTextColor;
+    }
+    else {    
+        retColor =  HbColorScheme::color(NmAttachmentTextColor);
+    }
+    return retColor;
+}
+
+/*!
+    \reimp
+*/
+
+void NmAttachmentListWidget::changeEvent(QEvent *event)
+{
+    NM_FUNCTION;
+
+    if (event->type() == HbEvent::ThemeChanged) {
+        rearrangeLayout();    
+    }
+    return HbWidgetBase::changeEvent(event);
+}
--- a/emailuis/nmailuiwidgets/src/nmeditortextedit.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailuiwidgets/src/nmeditortextedit.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -17,7 +17,8 @@
 
 #include "nmailuiwidgetsheaders.h"
 
-static const QString FILE_PATH_CSS = ":nmeditortextedit.css";
+static const QString FILE_PATH_CSS_DEFAULT = ":nmeditortexteditblack.css";
+static const QString FILE_PATH_CSS_SECONDARY = ":nmeditortexteditblue.css";
 static const QString FILE_PATH_WIDGETML = ":nmeditortextedit.widgetml";
 
 /*!
@@ -29,7 +30,7 @@
     NM_FUNCTION;
     
     HbStyleLoader::registerFilePath(FILE_PATH_WIDGETML);
-    HbStyleLoader::registerFilePath(FILE_PATH_CSS);
+    HbStyleLoader::registerFilePath(FILE_PATH_CSS_DEFAULT);
 
     mCustomTextColor = QPair<bool, QColor>(false, Qt::black);
     
@@ -43,9 +44,6 @@
     QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem (whitePixmap);
     setBackgroundItem(pixmapItem); 
     
-    // disables highlight frame for now - new api to set the frame item should be release somewhere wk26
-    setFocusHighlight(HbStyle::P_TextEdit_frame_highlight, HbWidget::FocusHighlightNone);
-    
     // Create custom palette based on the current one
     QPalette testPalette = QApplication::palette();
 
@@ -61,8 +59,6 @@
 
     // Update custom palette for this widget
     setPalette(testPalette);
-
-    connect(this, SIGNAL(contentsChanged()), this, SLOT(updateCustomTextColor()));
 }
 
 /*!
@@ -73,7 +69,12 @@
     NM_FUNCTION;
     
     HbStyleLoader::unregisterFilePath(FILE_PATH_WIDGETML);
-    HbStyleLoader::unregisterFilePath(FILE_PATH_CSS);    
+    if (mCustomTextColor.first) {
+		HbStyleLoader::unregisterFilePath(FILE_PATH_CSS_SECONDARY);    
+    }
+    else {
+		HbStyleLoader::unregisterFilePath(FILE_PATH_CSS_DEFAULT);    
+    }
 }
 
 /*!
@@ -131,11 +132,13 @@
 {   
     NM_FUNCTION;
     
-    mCustomTextColor.first = useCustom;
-    //check and set custom color
-    mCustomTextColor.first ? mCustomTextColor.second = color : 
-                             mCustomTextColor.second = mCustomTextColor.second;
-    
+    if (!mCustomTextColor.first && useCustom) {
+        HbStyleLoader::unregisterFilePath(FILE_PATH_CSS_DEFAULT);    
+        HbStyleLoader::registerFilePath(FILE_PATH_CSS_SECONDARY);
+
+        mCustomTextColor.first = useCustom;
+        mCustomTextColor.second = color;
+    }		
 }
 
 /*!
--- a/emailuis/nmframeworkadapter/src/nmframeworkadapter.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmframeworkadapter/src/nmframeworkadapter.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -113,7 +113,7 @@
 int NmFrameworkAdapter::listMailboxes(QList<NmMailbox*>& mailboxList)
 {
     NM_FUNCTION;
-    
+
     // get list of mailboxes from all plugins
     TFSMailMsgId id;
     id.SetNullId();
@@ -189,7 +189,7 @@
 int NmFrameworkAdapter::getFolderById( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder )
     {
     NM_FUNCTION;
-    
+
     TRAPD(err, getFolderByIdL( mailboxId, folderId, folder ) );
     return err;
     }
@@ -200,11 +200,11 @@
 void NmFrameworkAdapter::getFolderByIdL( const NmId& mailboxId, const NmId& folderId, NmFolder*& folder )
     {
     NM_FUNCTION;
-    
+
     CFSMailFolder* fsFolder(NULL);
 	if (mFSfw)
 		{
-    	fsFolder = mFSfw->GetFolderByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId)); 
+    	fsFolder = mFSfw->GetFolderByUidL(TFSMailMsgId(mailboxId), TFSMailMsgId(folderId));
     	if (fsFolder)
         	{
         	folder = fsFolder->GetNmFolder();
@@ -237,7 +237,7 @@
     NmMessage*& message)
 {
     NM_FUNCTION;
-    
+
     TRAPD(err, getMessageByIdL(mailboxId,folderId,messageId,message));
     return err;
 }
@@ -252,7 +252,7 @@
     NmMessage*& message)
 {
     NM_FUNCTION;
-    
+
     // select message details to be listed
     TFSMailDetails details(EFSMsgDataStructure);
 
@@ -275,10 +275,10 @@
 
 /*!
     Returns list of folders in a mailbox.
-	
+
 	\param mailboxId Id of the mailbox containing the folder.
 	\param folderList Reference to a pointer list to receive pointers to the folders.
-	
+
 	\return Error code.
  */
 int NmFrameworkAdapter::listFolders(
@@ -286,7 +286,7 @@
     QList<NmFolder*>& folderList)
 {
     NM_FUNCTION;
-    
+
     CFSMailBox* currentMailbox = NULL;
     TRAPD (err, currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId));
     if (KErrNone == err) {
@@ -316,7 +316,7 @@
      const int maxEnvelopeCount)
 {
     NM_FUNCTION;
-    
+
     if (!folder || maxEnvelopeCount < 1) {
         return;
     }
@@ -342,7 +342,7 @@
     RArray<TFSMailSortCriteria> sorting;
     CleanupClosePushL(sorting);
     sorting.Append(criteria);
-   
+
     // Get the message list from the backend.
     MFSMailIterator* iterator(NULL);
     iterator = folder->ListMessagesL(details, sorting);
@@ -382,7 +382,7 @@
         iterator = NULL;
     }
 
-    CleanupStack::PopAndDestroy(); // sorting  
+    CleanupStack::PopAndDestroy(); // sorting
 }
 
 
@@ -402,7 +402,7 @@
     QList<NmMessageEnvelope*> &messageEnvelopeList)
 {
     NM_FUNCTION;
-    
+
     TRAPD(err, listMessagesL(mailboxId,folderId,messageEnvelopeList, NmMaxItemsInMessageList));
     return err;
 }
@@ -427,7 +427,7 @@
         const int maxAmountOfEnvelopes)
 {
     NM_FUNCTION;
-    
+
     TInt err = KErrNone;
     TRAP(err, listMessagesL(mailboxId,folderId, messageEnvelopeList,maxAmountOfEnvelopes) );
     return err;
@@ -445,7 +445,7 @@
         const int maxAmountOfEnvelopes)
 {
     NM_FUNCTION;
-    
+
     // If we are requesting 0 or less mails, we can just return.
     if (maxAmountOfEnvelopes <= 0) {
         return;
@@ -466,14 +466,14 @@
     if (folder) {
         CleanupStack::PushL(folder);
         getMessagesFromFolderL(folder, messageEnvelopeList, maxAmountOfEnvelopes);
-        CleanupStack::PopAndDestroy(folder);        
+        CleanupStack::PopAndDestroy(folder);
     }
 
     CleanupStack::PopAndDestroy(mailbox);
 }
 
 
-/*! 
+/*!
     Returns list of messages from the backend for specific mailbox and folder.
 
     \param mailboxId Id of the mailbox containing the folder.
@@ -490,7 +490,7 @@
     const int maxAmountOfMessages)
 {
     NM_FUNCTION;
-    
+
     TRAPD(err, listMessagesL(mailboxId,folderId,messageList, maxAmountOfMessages));
     return err;
 }
@@ -506,7 +506,7 @@
         const int maxAmountOfEnvelopes)
 {
     NM_FUNCTION;
-    
+
     CFSMailBox * currentMailbox(NULL);
     CFSMailFolder* folder(NULL);
 
@@ -527,7 +527,7 @@
             blockSize = maxAmountOfEnvelopes;
             }
         }
-   
+
     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
     if (!currentMailbox) {
         User::Leave(KErrNotFound);
@@ -568,7 +568,7 @@
                   i += blockSize ) {
                 moreMessagesToFollow = iterator->NextL(
                     messages[i-1]->GetMessageId(), blockSize, messages);
-                
+
             }
 
             //Add all found emails to the result list
@@ -585,7 +585,7 @@
                     messageList.append(newMessage);
                 }
             }
-            
+
             CleanupStack::PopAndDestroy( &messages );
             CleanupStack::Pop(iterator);
             delete iterator;
@@ -613,7 +613,7 @@
                                const QStringList &searchStrings)
 {
     NM_FUNCTION;
-    
+
     if (!mSearchObserver) {
         mSearchObserver = new NmMailboxSearchObserver();
     }
@@ -634,14 +634,13 @@
     Cancels the search if one is ongoing.
 
     \param mailboxId The ID of the mailbox running the search.
-    
 
     \return A possible error code.
 */
 int NmFrameworkAdapter::cancelSearch(const NmId &mailboxId)
 {
     NM_FUNCTION;
-    
+
     // Get the mailbox with the given ID.
     CFSMailBox *mailbox(NULL);
     TRAPD(err, mailbox = mFSfw->GetMailBoxByUidL(mailboxId));
@@ -687,10 +686,10 @@
         mCurrentMailBox = mFSfw->GetMailBoxByUidL(mailboxId);
         }
     CEmailExtension *extension = getEMailStateExtensionL();
-    CMailboxStateExtension *stateExtension = 
-        static_cast<CMailboxStateExtension*>(extension);        
+    CMailboxStateExtension *stateExtension =
+        static_cast<CMailboxStateExtension*>(extension);
     if (stateExtension) {
-        stateExtension->NotifyActiveFolderChanged(mailboxId, folderId);    
+        stateExtension->NotifyActiveFolderChanged(mailboxId, folderId);
     }
 }
 
@@ -698,12 +697,12 @@
    function to process updateActiveFolder. This method may leave.
  */
 CEmailExtension* NmFrameworkAdapter::getEMailStateExtensionL()
-{      
+{
     if (!mStateExtension && mCurrentMailBox) {
         // This extension is owned and deleted by the plugin, so no need to
         // use release unless the extension will be relocated into extensionbase.
         mStateExtension =  mCurrentMailBox->ExtensionL(KEmailMailboxStateExtensionUid);
-    }    
+    }
     return mStateExtension;
 }
 
@@ -712,7 +711,7 @@
 
     \param mailboxId The mailbox to search from.
     \param folderIds (not used)
-    \param searchStrings The strings to search. 
+    \param searchStrings The strings to search.
     \param searchObserver The observer which gets informed about the progress
                           of the search (match found, search complete etc.)
 */
@@ -722,9 +721,9 @@
                                  NmMailboxSearchObserver &searchObserver)
 {
     NM_FUNCTION;
-    
+
     // CFSMailBox has no support for search using folder IDs.
-    Q_UNUSED(folderIds); 
+    Q_UNUSED(folderIds);
 
     // Get the mailbox with the given ID.
     CFSMailBox *mailbox(NULL);
@@ -771,7 +770,7 @@
     const NmId &messageId )
 {
     NM_FUNCTION;
-    
+
     NmOperation *oper = new NmFwaMessageFetchingOperation(mailboxId, folderId, messageId, *mFSfw);
     return oper;
 }
@@ -786,14 +785,14 @@
 
     \return An NmOperation object for the operation, ownership is transferred to caller
  */
-QPointer<NmOperation> NmFrameworkAdapter::fetchMessagePart( 
+QPointer<NmOperation> NmFrameworkAdapter::fetchMessagePart(
     const NmId &mailboxId,
     const NmId &folderId,
     const NmId &messageId,
     const NmId &messagePartId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmOperation> oper = new NmFwaMessagePartFetchingOperation(
             mailboxId, folderId, messageId, messagePartId, *mFSfw);
     return oper;
@@ -809,17 +808,17 @@
 
     \return An NmOperation object for the operation, ownership is transferred to caller
  */
-QPointer<NmOperation> NmFrameworkAdapter::fetchMessageParts( 
+QPointer<NmOperation> NmFrameworkAdapter::fetchMessageParts(
     const NmId &mailboxId,
     const NmId &folderId,
     const NmId &messageId,
     const QList<NmId> &messagePartIds)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmOperation> oper = new NmFwaMessagePartsFetchingOperation(
             mailboxId, folderId, messageId, messagePartIds, *mFSfw);
-    return oper;  
+    return oper;
 }
 
 /*!
@@ -839,23 +838,23 @@
         const NmId &messagePartId)
 {
     NM_FUNCTION;
-    
+
     XQSharableFile retFile;
     TFSMailDetails details(EFSMsgDataEnvelope);
     TFSMailMsgId fsMboxId(mailboxId);
     TFSMailMsgId fsFolderId(folderId);
     TFSMailMsgId fsMsgId(messageId);
     TFSMailMsgId fsMsgPartId(messagePartId);
-    
+
     CFSMailMessage* fsMessage = NULL;
     int error = KErrNone;
     TRAP(error, fsMessage = mFSfw->GetMessageByUidL(fsMboxId, fsFolderId,
             fsMsgId, details) );
-    
+
     CFSMailMessagePart* fsMessagePart = NULL;
     if (fsMessage && error == KErrNone) {
         TRAP(error, fsMessagePart = fsMessage->ChildPartL(fsMsgPartId) );
-        
+
     }
     if (fsMessagePart && error == KErrNone) {
         RFile file = fsMessagePart->GetContentFileL();
@@ -877,7 +876,7 @@
     NmFolderType folderType )
 {
     NM_FUNCTION;
-    
+
     TFSMailMsgId folderId;
     NmId resultId(0);
     CFSMailBox * currentMailbox(NULL);
@@ -980,7 +979,7 @@
     NmMessagePart &messagePart)
 {
     NM_FUNCTION;
-    
+
     TRAPD(err, contentToMessagePartL(mailboxId,folderId,messageId,messagePart));
     return err;
 }
@@ -995,7 +994,7 @@
     NmMessagePart &messagePart)
 {
     NM_FUNCTION;
-    
+
     CFSMailMessagePart* cfsPart = CFSMailMessagePart::NewLC(messageId,messagePart);
     cfsPart->SetMailBoxId(TFSMailMsgId(mailboxId));
     cfsPart->SetFolderId(TFSMailMsgId(folderId));
@@ -1037,8 +1036,8 @@
                 if (!codec) {
                     codec = QTextCodec::codecForName("UTF-8");
                 }
-                QString encodedStr = codec->toUnicode(msgBytes); 
-                messagePart.setTextContent(encodedStr, contentType);           
+                QString encodedStr = codec->toUnicode(msgBytes);
+                messagePart.setTextContent(encodedStr, contentType);
             }
             else {
                 messagePart.setBinaryContent(QByteArray(
@@ -1071,7 +1070,7 @@
 	const QList<NmId> &messageIdList)
 {
     NM_FUNCTION;
-    
+
     TInt err = NmNoError;
     RArray<TFSMailMsgId> messageIds;
     for (TInt i=0; i<messageIdList.size(); i++) {
@@ -1103,7 +1102,7 @@
 	const QList<const NmMessageEnvelope*> &envelopeList)
 {
     NM_FUNCTION;
-    
+
     Q_UNUSED(folderId);
 
     QPointer<NmStoreEnvelopesOperation> operation(NULL);
@@ -1134,7 +1133,7 @@
 QPointer<NmMessageCreationOperation> NmFrameworkAdapter::createNewMessage(const NmId &mailboxId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageCreationOperation> oper =
         new NmFwaMessageCreationOperation(mailboxId, *mFSfw);
     return oper;
@@ -1153,7 +1152,7 @@
     const NmId &originalMessageId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageCreationOperation> oper =
         new NmFwaForwardMessageCreationOperation(mailboxId, originalMessageId, *mFSfw);
     return oper;
@@ -1174,7 +1173,7 @@
     const bool replyAll)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageCreationOperation> oper =
         new NmFwaReplyMessageCreationOperation(mailboxId, originalMessageId, replyAll, *mFSfw);
     return oper;
@@ -1186,7 +1185,7 @@
 int NmFrameworkAdapter::saveMessage(const NmMessage &message)
 {
     NM_FUNCTION;
-    
+
     Q_UNUSED(message);
     return NmNoError;
 }
@@ -1197,7 +1196,7 @@
 QPointer<NmOperation> NmFrameworkAdapter::saveMessageWithSubparts(const NmMessage &message)
 {
     NM_FUNCTION;
-    
+
     CFSMailMessage * cfsMessage = NULL;
     QPointer<NmOperation> oper(NULL);
 
@@ -1224,7 +1223,7 @@
     TAny* param3)
 {
     NM_FUNCTION;
-    
+
     switch (aEvent) {
         // Mailbox related events:
         case TFSEventNewMailbox:
@@ -1339,7 +1338,7 @@
     const NmId& messageId)
 {
     NM_FUNCTION;
-    
+
     TRAPD(error, removeMessageL(mailboxId, folderId, messageId));
     return error;
 }
@@ -1417,7 +1416,7 @@
     const NmId& messageId)
 {
     NM_FUNCTION;
-    
+
     CFSMailFolder* folder = mFSfw->GetFolderByUidL( TFSMailMsgId(mailboxId), TFSMailMsgId(folderId));
     CleanupStack::PushL(folder);
     if ( folder ) {
@@ -1439,25 +1438,25 @@
 
     RArray<TFSMailMsgId> messages;
     RArray<TFSMailMsgId> copiedMessages;
-    
+
     CleanupClosePushL(messages);
     CleanupClosePushL(copiedMessages);
-    
+
     for (TInt i = 0; i < messageIds.count(); i++) {
         NmId tmpId(messageIds[i]);
         messages.AppendL(TFSMailMsgId(tmpId));
     }
-    
+
     CFSMailBox* mailBox = NULL;
     mailBox = mFSfw->GetMailBoxByUidL(mailboxId);
     if (mailBox) {
-        mailBox->CopyMessagesL(messages, copiedMessages, 
-            TFSMailMsgId(sourceFolderId), 
+        mailBox->CopyMessagesL(messages, copiedMessages,
+            TFSMailMsgId(sourceFolderId),
             TFSMailMsgId(destinationFolderId));
         delete mailBox;
     }
-    
-    CleanupStack::PopAndDestroy(2,&messages);    
+
+    CleanupStack::PopAndDestroy(2,&messages);
 }
 
 /*!
@@ -1467,7 +1466,7 @@
     NmMessage *message)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmMessageSendingOperation>oper = new NmFwaMessageSendingOperation(*this, message, *mFSfw);
 	return oper;
 }
@@ -1480,7 +1479,7 @@
     const QList<QString> &fileList)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmAddAttachmentsOperation>oper = new NmFwaAddAttachmentsOperation(message, fileList, *mFSfw);
     return oper;
 }
@@ -1493,7 +1492,7 @@
     const NmId &attachmentPartId)
 {
     NM_FUNCTION;
-    
+
     QPointer<NmOperation> oper = new NmFwaRemoveAttachmentOperation(message, attachmentPartId, *mFSfw);
     return oper;
 }
@@ -1504,7 +1503,7 @@
 NmSyncState NmFrameworkAdapter::syncState(const NmId& mailboxId) const
 {
     NM_FUNCTION;
-    
+
    CFSMailBox* mailBox = NULL;
    TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) );
    if (KErrNone == err && mailBox) {
@@ -1528,7 +1527,7 @@
 NmConnectState NmFrameworkAdapter::connectionState(const NmId& mailboxId) const
 {
     NM_FUNCTION;
-    
+
     CFSMailBox* mailBox = NULL;
     TRAPD(err, mailBox = mFSfw->GetMailBoxByUidL(TFSMailMsgId(mailboxId)) );
     if (KErrNone == err && mailBox) {
@@ -1554,7 +1553,7 @@
     const NmMessageEnvelope& envelope)
 {
     NM_FUNCTION;
-    
+
     NmMessage* nmMessage = new(ELeave) NmMessage( envelope );
     CFSMailMessage* message = CFSMailMessage::NewL( *nmMessage );
     delete nmMessage;
@@ -1571,7 +1570,7 @@
         NmMessagePart *nmParent)
 {
     NM_FUNCTION;
-    
+
     User::LeaveIfNull(cfsParent);
     User::LeaveIfNull(nmParent);
 
@@ -1596,7 +1595,7 @@
 int NmFrameworkAdapter::RefreshMailboxL(NmId mailboxId)
 {
     NM_FUNCTION;
-    
+
     int result(KErrNotFound);
     CFSMailBox *currentMailbox(NULL);
     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
@@ -1615,7 +1614,7 @@
 int NmFrameworkAdapter::GoOnlineL(const NmId& mailboxId)
 {
     NM_FUNCTION;
-    
+
     int result(KErrNotFound);
     CFSMailBox *currentMailbox(NULL);
     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
@@ -1634,7 +1633,7 @@
 int NmFrameworkAdapter::GoOfflineL(const NmId& mailboxId)
 {
     NM_FUNCTION;
-    
+
 	int result(KErrNotFound);
     CFSMailBox *currentMailbox(NULL);
     currentMailbox = mFSfw->GetMailBoxByUidL(mailboxId);
@@ -1653,10 +1652,12 @@
 void NmFrameworkAdapter::handleMailboxEvent( TFSMailMsgId mailbox, NmMailboxEvent event)
 {
     NM_FUNCTION;
-    
+
     QList<NmId> mailboxIds;
     NmId nmId;
-    if (event == NmMailboxDeleted) {
+    if (event == NmMailboxDeleted || 
+        event == NmMailboxCreated ||
+        event == NmMailboxChanged) {
 		nmId = mailbox.GetNmId();
     } else {
 		nmId = getMailboxIdByMailMsgId(mailbox);
@@ -1675,7 +1676,7 @@
     TFSMailMsgId mailbox)
 {
     NM_FUNCTION;
-    
+
     NmId nmMsgId(0);
     QList<NmId> messageIds;
     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
@@ -1697,7 +1698,7 @@
 void NmFrameworkAdapter::handleMailMoved(TAny* param1,TAny* param2,TAny* param3, TFSMailMsgId mailbox)
 {
     NM_FUNCTION;
-    
+
     NmId nmMsgId(0);
     QList<NmId> messageIds;
     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
@@ -1724,7 +1725,7 @@
 void NmFrameworkAdapter::handleMailCopied(TAny* param1,TAny* param2, TFSMailMsgId mailbox)
 {
     NM_FUNCTION;
-    
+
     NmId nmMsgId(0);
     QList<NmId> messageIds;
     RArray<TFSMailMsgId>* newFsEntries = reinterpret_cast<RArray<TFSMailMsgId>*> (param1);
--- a/emailuis/nmframeworkadapter/src/nmfwamessagepartsfetchingoperation.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmframeworkadapter/src/nmfwamessagepartsfetchingoperation.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -32,18 +32,18 @@
     mMailClient(mailClient), 
     mLastProgressValue(0), 
     mRequestId(0)
-
 {
     NM_FUNCTION;
     
     // Take own copy of the message part id list.
     mMessagePartIds.Reset();
     for (int i=0; i<messagePartIds.count(); ++i) {
-        mMessagePartIds.Append(
+        // let's ignore .Append return value here, the failing messages
+        // just won't be handled at this time
+        int ignore = mMessagePartIds.Append(
             NmConverter::nmIdToMailMsgId(
                 messagePartIds.at(i)));
     }
-    
 }
 
 /*!
--- a/emailuis/nmhswidget/nmhswidget.pro	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmhswidget/nmhswidget.pro	Wed Aug 18 09:37:47 2010 +0300
@@ -73,3 +73,6 @@
     
 DEPENDPATH += .
 TRANSLATIONS = mailwidget.ts
+
+DOCML += conf/nmhswidgetmail.docml \
+         conf/nmhswidget.docml
--- a/emailuis/nmhswidget/nmhswidget.qrc	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmhswidget/nmhswidget.qrc	Wed Aug 18 09:37:47 2010 +0300
@@ -1,6 +1,6 @@
 <RCC>
     <qresource prefix="/docml">
-        <file alias="nmhswidgetmail.docml">conf/nmhswidgetmail.docml</file>
-        <file alias="nmhswidget.docml">conf/nmhswidget.docml</file>
+        <file alias="nmhswidgetmail.docml">conf/nmhswidgetmail.docml.bin</file>
+        <file alias="nmhswidget.docml">conf/nmhswidget.docml.bin</file>
     </qresource>
 </RCC>
--- a/emailuis/nmindicatorplugin/src/nmsendingindicator.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmindicatorplugin/src/nmsendingindicator.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -49,7 +49,7 @@
 */
 QVariant NmSendingIndicator::indicatorData(int role) const
 {
-    if (role==DecorationNameRole) {
+    if (role==DecorationNameRole || role==MonoDecorationNameRole) {
 		// Must return non-empty to make the indicator visible
 		return " ";
 	}
--- a/emailuis/nmindicatorplugin/src/nmsyncindicator.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmindicatorplugin/src/nmsyncindicator.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -30,7 +30,7 @@
 
 QVariant NmSyncIndicator::indicatorData(int role) const
 {
-    if (role == DecorationNameRole ) {
+    if (role == DecorationNameRole || role == MonoDecorationNameRole) {
         // Must return non-empty to make the indicator visible
         return " ";
     }
--- a/emailuis/nmsettingui/inc/nmmailboxsettingview.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmsettingui/inc/nmmailboxsettingview.h	Wed Aug 18 09:37:47 2010 +0300
@@ -22,10 +22,11 @@
 #include <nmcommon.h>
 #include "nmsettingscommon.h"
 
+class QModelIndex;
+class QGraphicsItem;
 class HbDataForm;
 class HbDataFormModel;
 class NmMailboxSettingsManager;
-class QGraphicsItem;
 class NmId;
 
 
@@ -50,6 +51,7 @@
 
     void mailboxPropertyChanged(const NmId &mailboxId, QVariant property, QVariant value);
 
+    void itemPress(const QModelIndex &index);
 
 private:
 
--- a/emailuis/nmsettingui/nmsettingui.pro	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmsettingui/nmsettingui.pro	Wed Aug 18 09:37:47 2010 +0300
@@ -86,4 +86,6 @@
 
 RESOURCES += nmsettingui.qrc
 
+DOCML += conf/nmmailboxsettingview.docml
+
 # End of file.
--- a/emailuis/nmsettingui/nmsettingui.qrc	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmsettingui/nmsettingui.qrc	Wed Aug 18 09:37:47 2010 +0300
@@ -1,6 +1,6 @@
 <!DOCTYPE RCC>
 <RCC>
-    <qresource prefix="/docml" >
-        <file alias="nmmailboxsettingview.docml" >conf/nmmailboxsettingview.docml</file>
+    <qresource prefix="/docml">
+        <file alias="nmmailboxsettingview.docml">conf/nmmailboxsettingview.docml.bin</file>
     </qresource>
 </RCC>
\ No newline at end of file
--- a/emailuis/nmsettingui/src/nmmailboxsettingview.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmsettingui/src/nmmailboxsettingview.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -15,6 +15,8 @@
 *
 */
 
+#include <qinputcontext.h>
+
 #include <hbinstance.h>
 #include <hbmainwindow.h>
 #include <hbaction.h>
@@ -76,6 +78,10 @@
     }
 
     if (mForm) {
+        
+        connect(mForm, SIGNAL(pressed(QModelIndex)),
+                this, SLOT(itemPress(QModelIndex)));
+        
         // Fix for dataform item recycling.
         mForm->setItemRecycling(false);
 
@@ -163,4 +169,39 @@
     return mMailboxId;
 }
 
+/*!
+    Called when item is pressed on the view.
+
+    \param index Index to the pressed item.
+*/
+void NmMailboxSettingView::itemPress(const QModelIndex &index)
+{
+    NM_FUNCTION;
+    
+    int type(index.data(HbDataFormModelItem::ItemTypeRole).toInt());
+    
+    if (type == HbDataFormModelItem::GroupItem) {
+        // Scroll the groupitem to top if needed.
+        HbDataFormViewItem *item = static_cast<HbDataFormViewItem *>(mForm->itemByIndex(index));
+        
+        if (!item->isExpanded()) {
+            mForm->scrollTo(index, HbAbstractItemView::PositionAtTop);
+        }else {
+            // Hide the virtual keyboard
+            QInputContext *ic = qApp->inputContext();
+            if (ic) {
+                QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
+                ic->filterEvent(closeEvent);
+                delete closeEvent;
+            }
+        }
+    }
+    
+    if (type == HbDataFormModelItem::TextItem) {
+        // Turn off predictive input for line-edit.
+        HbDataFormViewItem *item = static_cast<HbDataFormViewItem *>(mForm->itemByIndex(index));
+        HbWidget *widget = item->dataItemContentWidget();
+        widget->setInputMethodHints(Qt::ImhNoPredictiveText);
+    }
+}
 // End of file.
--- a/emailuis/nmsettingui/src/nmsettingsviewfactory.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmsettingui/src/nmsettingsviewfactory.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -65,7 +65,7 @@
    mMessageBox(0)
 {
     NM_FUNCTION;
-    
+
     createMessageBox();
 }
 
@@ -93,7 +93,7 @@
      mPrevView(0), mMessageBox(0)
 {
     NM_FUNCTION;
-    
+
     createMessageBox();
 }
 
@@ -104,7 +104,7 @@
 NmSettingsViewFactory::~NmSettingsViewFactory()
 {
     NM_FUNCTION;
-    
+
     delete mSettingsManager;
     delete mMessageBox;
 }
@@ -120,7 +120,7 @@
 CpBaseSettingView *NmSettingsViewFactory::createSettingView() const
 {
     NM_FUNCTION;
-    
+
     CpBaseSettingView *view = 0;
     QList<NmMailbox *> mailboxList;
     mSettingsManager->listMailboxes(mailboxList);
@@ -161,7 +161,7 @@
                 SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)),
                 view, SLOT(mailboxPropertyChanged(const NmId &, QVariant, QVariant)));
     }
-    
+
     return view;
 }
 
@@ -176,66 +176,66 @@
                                               const QString &mailboxName) const
 {
     NM_FUNCTION;
-    
+
     // There's always at least one valid main window available.
     HbMainWindow *mainWindow = hbInstance->allMainWindows().takeFirst();
 
-    NmMailboxSettingView *currentSettingsView = 
+    NmMailboxSettingView *currentSettingsView =
         qobject_cast<NmMailboxSettingView*>(mainWindow->currentView());
-    
-    // Let's have only one same settings view at a time open, 
-    // but if some other mailboxes settings view want's to open while 
+
+    // Let's have only one same settings view at a time open,
+    // but if some other mailboxes settings view want's to open while
     // there is a settings view open let's open it also.
     if (!currentSettingsView || (currentSettingsView->mailboxId().id() != mailboxId.id())) {
         CpBaseSettingView *view =
              new NmMailboxSettingView(mailboxId, mailboxName, *mSettingsManager);
-         
+
          connect(mSettingsManager,
                  SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)),
                  view, SLOT(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)));
-     
+
          connect(mSettingsManager,
                  SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)),
                  view, SLOT(mailboxPropertyChanged(const NmId &, QVariant, QVariant)));
-     
-         // Disconnect mSettingsViewLauncher's previous connections to 
+
+         // Disconnect mSettingsViewLauncher's previous connections to
          // be sure that signals which are offered out will be sent last.
          mSettingsManager->disconnect(
              SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)),
              mSettingsViewLauncher,
              SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)));
-     
+
          mSettingsManager->disconnect(
              SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)),
              mSettingsViewLauncher,
              SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)));
-     
+
          // Reconnect mSettingsViewLauncher.
          connect(mSettingsManager,
                  SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)),
                  mSettingsViewLauncher,
                  SIGNAL(mailboxListChanged(const NmId &, NmSettings::MailboxEventType)));
-     
+
          connect(mSettingsManager,
                  SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)),
                  mSettingsViewLauncher,
                  SIGNAL(mailboxPropertyChanged(const NmId &, QVariant, QVariant)));
-     
+
          connect(mSettingsManager,
                  SIGNAL(goOnline(const NmId &)),
                  mSettingsViewLauncher,
                  SIGNAL(goOnline(const NmId &)), Qt::UniqueConnection);
-     
+
          connect(mSettingsManager,
                  SIGNAL(goOffline(const NmId &)),
                  mSettingsViewLauncher,
                  SIGNAL(goOffline(const NmId &)), Qt::UniqueConnection);
-     
+
          connect(this,
                  SIGNAL(aboutToClose()),
                  mSettingsManager,
                  SIGNAL(aboutToClose()), Qt::UniqueConnection);
-     
+
          // Create back navigation action for a view.
          HbAction *action = new HbAction(Hb::BackNaviAction, view);
          connect(action, SIGNAL(triggered()), this, SLOT(backPress()));
@@ -243,7 +243,7 @@
          mPrevView = mainWindow->currentView();
          mainWindow->addView(view);
          mainWindow->setCurrentView(view);
-    }    
+    }
 }
 
 /*!
@@ -254,7 +254,7 @@
 void NmSettingsViewFactory::backPress()
 {
     NM_FUNCTION;
-    
+
     emit aboutToClose();
     HbMainWindow *mainWindow = hbInstance->allMainWindows().takeFirst();
     QList<HbView *> views = mainWindow->views();
@@ -278,7 +278,7 @@
 void NmSettingsViewFactory::launchWizard(HbAction *action)
 {
     NM_FUNCTION;
-    
+
     if (action == mMessageBox->primaryAction()) {
         // Launch mail wizard.
         NM_COMMENT(QString("NmSettingsViewFactory::launchWizard(): launching the mail wizard"));
@@ -294,10 +294,11 @@
 void NmSettingsViewFactory::createMessageBox()
 {
     NM_FUNCTION;
-    
+
     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
     mMessageBox->setText(hbTrId("txt_mail_dialog_no_mailboxes_create_new"));
     mMessageBox->setTimeout(HbMessageBox::NoTimeout);
+    mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
 }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/basepluginresourceloader.h	Wed Aug 18 09:37:47 2010 +0300
@@ -0,0 +1,18 @@
+/*
+* 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: 
+*
+*/
+
+#include "../emailservices/emailstore/base_plugin/inc/basepluginresourceloader.h"
\ No newline at end of file
--- a/ipsservices/ipssosaoplugin/inc/IpsSosAOBaseAgent.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/inc/IpsSosAOBaseAgent.h	Wed Aug 18 09:37:47 2010 +0300
@@ -22,9 +22,6 @@
 
 #include <e32base.h> 
 #include <msvapi.h>
-#include <SendUiConsts.h>
-
-#include "ipsplgcommon.h"
 
 class CIpsSetDataApi;
 class CIpsSosAOImapSyncOp;
--- a/ipsservices/ipssosaoplugin/inc/IpsSosAOSettingsHandler.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/inc/IpsSosAOSettingsHandler.h	Wed Aug 18 09:37:47 2010 +0300
@@ -21,7 +21,6 @@
 #define IPSSOSAOSETTINGSHANDLER_H_
 
 #include <e32base.h> 
-#include <imapset.h>
 
 #include "ipsplgcommon.h"
 #include "nmipssettingitems.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ipsservices/ipssosaoplugin/inc/ipssosaopluginheaders.h	Wed Aug 18 09:37:47 2010 +0300
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     Contains mailbox specified always online logic
+*
+*/
+
+#ifndef IPSSOSAOPLUGINHEADERS_H_
+#define IPSSOSAOPLUGINHEADERS_H_
+
+// Symbian
+#include <e32base.h>
+#include <ecom/implementationproxy.h>
+#include <e32property.h>
+#include <AlwaysOnlineManagerCommon.h>
+#include <AlwaysOnlineManagerClient.h>
+#include <cemailaccounts.h>
+#include <imapcmds.h>
+#include <miutset.h>
+#include <impcmtm.h>
+#include <msvapi.h>
+#include <SendUiConsts.h>
+#include <msvids.h>
+#include <msvuids.h>
+#include <cmmanager.h>
+#include <pop3cmds.h>
+#include <popcmtm.h>
+#include <smtpset.h>
+
+// qt
+#include <qlist.h>
+
+// qt extensions
+#include <xqsettingsmanager.h>
+#include <xqcentralrepositoryutils.h>
+#include <xqcentralrepositorysearchcriteria.h>
+
+// emailcommon
+#include "CFSMailCommon.h"
+
+// emaildebug
+#include "emailtrace.h"
+
+// nmailbase
+#include "nmcommon.h"
+
+// nmipssettings
+#include "nmipssettingitems.h"
+#include "ipssettingkeys.h"
+
+// ipssosplugin
+#include "ipsplgsosbaseplugin.hrh"
+#include "ipsplgcommon.h"
+#include "ipsplgsmtpoperation.h"
+#include "ipsplgimap4populateop.h"
+
+// ipssosaoplugin
+#include "IpsSosAOBaseAgent.h"
+#include "IpsSosAOEMNResolver.h"
+#include "IpsSosAoExtendedSettingsManager.h"
+#include "IpsSosAOImapAgent.h"
+#include "IpsSosAOImapPopLogic.h"
+#include "IpsSosAOMboxLogic.h"
+#include "IpsSosAOPlugin.hrh"
+#include "IpsSosAOPluginEComInterface.h"
+#include "IpsSosAOPluginTimer.h"
+#include "IpsSosAOPopAgent.h"
+#include "IpsSosAOSchedulerUtils.h"
+#include "IpsSosAOSettingsHandler.h"
+#include "IpsSosAOSmtpAgent.h"
+#include "IpsSosAOSmtpSendWatcher.h"
+
+#endif /* IPSSOSAOPLUGINHEADERS_H_ */
--- a/ipsservices/ipssosaoplugin/src/IpsPlgAOPluginImplementationTable.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsPlgAOPluginImplementationTable.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -15,12 +15,7 @@
 *
 */
 
-
-#include "emailtrace.h"
-#include <e32base.h>
-#include <ecom/implementationproxy.h>
-
-#include "IpsSosAOPluginEComInterface.h"
+#include "ipssosaopluginheaders.h"
 
 //--------------------------------
 // Exported proxy for instantiation method resolution
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOBaseAgent.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOBaseAgent.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -16,14 +16,7 @@
 *
 */
 
-#include "emailtrace.h"
-#include <e32property.h>
-
-#include "ipsplgsosbaseplugin.hrh"
-
-#include "IpsSosAOBaseAgent.h"
-#include "IpsSosAOImapAgent.h"
-#include "IpsSosAOPopAgent.h"
+#include "ipssosaopluginheaders.h"
 
 _LIT( KIpsAOPlgPanicLit, "IpsAOPlg");
 // ----------------------------------------------------------------------------
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOEMNResolver.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOEMNResolver.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -16,15 +16,8 @@
 *
 */
 
-
 // INCLUDE FILES
-#include "emailtrace.h"
-#include <e32base.h>
-#include <AlwaysOnlineManagerCommon.h>
-
-#include "IpsSosAOEMNResolver.h"
-#include "IpsSosAOMboxLogic.h"
-#include "IpsSosAOBaseAgent.h"
+#include "ipssosaopluginheaders.h"
 
 // Literals used when trying to match a mailbox 
 // to a received EMN message
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOImapAgent.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOImapAgent.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -16,29 +16,7 @@
 *
 */
 
-
-#include "emailtrace.h"
-#include <cemailaccounts.h>
-#include <imapcmds.h>
-#include <miutset.h>
-#include <impcmtm.h>
-#include <msvapi.h>
-#include <AlwaysOnlineManagerCommon.h>
-#include "CFSMailCommon.h"
-
-#include "IpsSosAOImapAgent.h"
-#include "IpsSosAOImapPopLogic.h"
-
-
-//<QMail>
-#include "IpsSosAOSettingsHandler.h"
-
-//<qmail> removed
-//</QMail>
-
-// from ipsplugin
-#include "ipsplgimap4populateop.h"
-#include "ipsplgcommon.h"
+#include "ipssosaopluginheaders.h"
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
@@ -207,6 +185,7 @@
          case EStateFetchOnHold:
              break;
          case EStateDisconnect:
+             NM_COMMENT("CIpsSosAOImapAgent: disconnecting");
              if ( !iDoNotDisconnect )
                  {
                  CancelAllAndDisconnectL();
@@ -218,6 +197,7 @@
                  }
              break;
          case EStateCompleted:
+             NM_COMMENT("CIpsSosAOImapAgent: completed");
              TRAP_IGNORE( iOpResponse.OperationCompletedL( iError ) );
              SignalSyncCompleted( iServiceId, iError );
              iError = KErrNone;
@@ -330,6 +310,7 @@
     LoadSettingsL( );
     if ( !IsConnected() )
         {
+        NM_COMMENT("CIpsSosAOImapAgent: starting sync");
         TPckg<MMsvImapConnectionObserver*> parameter(this);
         // connect and synchronise starts background sync or idle
         CMsvEntrySelection* sel = new ( ELeave ) CMsvEntrySelection();
@@ -345,10 +326,11 @@
         }
     else
         {
+        NM_COMMENT("CIpsSosAOImapAgent: already connected do not sync");
         // do not do anything if we are connected, especially do never
         // try to sync if sync is is already started (ex. from ips plugin)
         // that cause problems with imap flags etc.
-        iError = KErrNone;
+        iError = KErrCancel;
         iState = EStateCompleted;
         SetActiveAndCompleteThis();
         }
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOImapPopLogic.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOImapPopLogic.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -16,30 +16,7 @@
 *
 */
 
-
-#include "emailtrace.h"
-#include <AlwaysOnlineManagerClient.h>
-#include <SendUiConsts.h>
-#include <msvids.h>
-#include <msvuids.h>
-
-
-// becuase of RD_IPS_AO_PLUGIN flag, can be removed
-// when flag is removed
-#include "ipsplgsosbaseplugin.hrh"
-
-#include "IpsSosAOImapPopLogic.h"
-#include "IpsSosAOMboxLogic.h"
-#include "IpsSosAOEMNResolver.h"
-//<QMail>
-
-#include "IpsSosAOSettingsHandler.h"
-#include "IpsSosAoExtendedSettingsManager.h"
-//</QMail>
-
-
-
-#include "ipsplgcommon.h"
+#include "ipssosaopluginheaders.h"
 
 //const TInt KAOSmtpStartDelaySeconds = 310;
 const TInt KIpsSosAOImapPopLogicDefGra = 1;
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOMboxLogic.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOMboxLogic.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -16,21 +16,11 @@
 *
 */
 
-//<Qmail>
-#include <cmmanager.h>
-//</Qmail>
-
-#include "emailtrace.h"
-#include "IpsSosAOMboxLogic.h"
-//<QMail>
-#include "IpsSosAOSettingsHandler.h"
-//</QMail>
-#include "IpsSosAOSchedulerUtils.h"
-#include "IpsSosAOPlugin.hrh"
-#include "IpsSosAOImapPopLogic.h"
+#include "ipssosaopluginheaders.h"
 
 //<QMail>
 const TInt KAOSecondsInMinute = 60;
+const TInt KAODefaultInboxSyncTimeSecs = 3600;
 //</QMail>
 const TInt KIpsSosAOMboxLogicMinGra = 1;
 
@@ -319,11 +309,14 @@
           ( (iIsRoaming && CanConnectIfRoamingL())||
              !iIsRoaming ) )
         {
+        NM_COMMENT("CIpsSosAOMBoxLogic: event: EEventStart");
         event = EEventNop;
         iAgent->LoadSettingsL();
         iTimer->Cancel();
+        INFO_1("CIpsSosAOMBoxLogic: timer scheduled: %d", KIpsSosAOStartDelaySeconds);
         iTimer->After( KIpsSosAOStartDelaySeconds );
         iState = EStateWaitSyncStart;
+        NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateWaitSyncStart");
         }
     
     while ( event != EEventNop && iState != EStateError )
@@ -331,14 +324,17 @@
         switch ( event )
             {
             case EEventTimerFired:
+                NM_COMMENT("CIpsSosAOMBoxLogic: event: EEventTimerFired");
                 event = HandleTimerFiredL();
               break;
             case EEventStartSync:
+                NM_COMMENT("CIpsSosAOMBoxLogic: event: EEventStartSync");
                 if ( iState == EStateWaitSyncStart )
                     {         
                     iError = KErrNone;
                     iAgent->StartSyncL();
                     iState = EStateSyncOngoing;
+                    NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateSyncOngoing");
                     }
                 else if ( iState == EStateIdleAndWaitCommands )
                     {
@@ -360,7 +356,9 @@
 					//</QMail>
                     if ( type == EAOCConnectAfter )
                         {
+                        NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateWaitSyncStart");
                         iState = EStateWaitSyncStart;
+                        INFO_1("CIpsSosAOMBoxLogic: timer scheduled: %d", seconds);
                         iTimer->After( seconds );
                         
                         SetEmnReceivedFlagL( ETrue );
@@ -370,6 +368,7 @@
                         iError = KErrNone;
                         iAgent->StartSyncL();
                         iState = EStateSyncOngoing;
+                        NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateSyncOngoing");
                         }
 					//<QMail>
                     CleanupStack::PopAndDestroy( 2, settings );
@@ -379,6 +378,7 @@
                 event = EEventNop;
                 break;
             case EEventFetchMessages:
+                NM_COMMENT("CIpsSosAOMBoxLogic: event: EEventFetchMessages");
                 if ( ( iState == EStateWaitSyncStart || 
                        iState == EStateIdleAndWaitCommands ) &&
                         iFetchMsgArray.Count() > 0 )
@@ -386,6 +386,7 @@
                     iError = KErrNone;
                     iAgent->StartFetchMessagesL( iFetchMsgArray );
                     iFetchMsgArray.Reset();
+                    NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateFetchOngoing");
                     iState = EStateFetchOngoing;
                     }
                 else 
@@ -396,16 +397,20 @@
                 event = EEventNop;
                 break;
             case EEventOperationCompleted:
+                NM_COMMENT("CIpsSosAOMBoxLogic: event: EEventOperationCompleted");
                 event = HandleOperationCompletionL();
                 break;
             case EEventSuspendOperations:
+                NM_COMMENT("CIpsSosAOMBoxLogic: event: EEventSuspendOperations");
                 SuspendOperations();
                 iState = EStateSuspended;
                 event = EEventNop;
                 break;
             case EEventContinueOperations:
+                NM_COMMENT("CIpsSosAOMBoxLogic: event: EEventContinueOperations");
                 if ( iState == EStateSuspended )
                     {
+                    INFO_1("CIpsSosAOMBoxLogic: timer scheduled: %d", KIpsSosAOContinueWaitTime);
                     iTimer->After( KIpsSosAOContinueWaitTime );
                     }
                 else
@@ -415,9 +420,11 @@
                 // ignore if in other states
                 break;
             case EEventStopAndRemoveOps:
+                NM_COMMENT("CIpsSosAOMBoxLogic: event: EEventStopAndRemoveOps");
                 // notify deletion
                 iAgent->CancelAllAndDisconnectL();
                 iTimer->Cancel();
+                NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateError");
                 iState = EStateError;
                 event = EEventNop;
                 break;
@@ -475,12 +482,14 @@
           agentState == CIpsSosAOBaseAgent::EStatePopulateOnHold ) )
         {
         iAgent->ContinueHoldOperations();
+        NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateSyncOngoing");
         iState = EStateSyncOngoing;
         }
     else if ( iState == EStateSuspended && 
             agentState == CIpsSosAOBaseAgent::EStateFetchOnHold )
         {
         iAgent->ContinueHoldOperations();
+        NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateFetchOngoing");
         iState = EStateFetchOngoing;
         }
     else
@@ -506,12 +515,18 @@
 	//</Qmail>     
     if ( iState == EStateSyncOngoing )
         {
+        INFO_1("CIpsSosAOMBoxLogic: operation completed error: %d", iError);
+        bool doSaveSyncTime = EFalse;
         if ( !( iError == KErrNone || iError == KErrCancel ) )
             {
             ++iErrorCounter;
             }
         else
             {
+            if (iError == KErrNone)
+                {
+                doSaveSyncTime = ETrue;
+                }
             iError = KErrNone;
             iErrorCounter = 0;
             }
@@ -529,6 +544,7 @@
             
             settings->SetEmnReceivedButNotSyncedFlag( EFalse );
             //</QMail>
+            NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateError");
             iState = EStateError;
             iErrorCounter = 0;
             }
@@ -542,14 +558,17 @@
             
             if ( state == IpsServices::EMailAoOff )
                 {
+                NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateIdleAndWaitCommands");
                 iState = EStateIdleAndWaitCommands;
                 }
             else
                 {
                 if( !iTimer->IsActive() )
                     {
+                    INFO_1("CIpsSosAOMBoxLogic: timer scheduled: %d", KIpsSosAOReTryInterval);
                     iTimer->After( KIpsSosAOReTryInterval );
                     }
+                NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateWaitSyncStart");
                 iState = EStateWaitSyncStart;
                 }
 
@@ -567,7 +586,10 @@
             {
             // no errors
             // update successfull sync time to settings
-            SaveSuccessfulSyncTimeL();
+            if (doSaveSyncTime)
+                {
+                SaveSuccessfulSyncTimeL();
+                }
             // and adjust timer to sync interval
             CalculateToNextIntervalL();
             }
@@ -577,6 +599,7 @@
         iError = KErrNone;
         if ( iTimer->IsActive() )
             {
+            NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateWaitSyncStart");
             iState = EStateWaitSyncStart;
             }
         else
@@ -600,11 +623,13 @@
         {
         iAgent->HoldOperations();
         }
+    NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateSuspended");
     iState = EStateSuspended;
     // set suspend watchdog, if clien not continue this
     // ensure ao logic to continue
     if ( !iTimer->IsActive() )
         {
+        INFO_1("CIpsSosAOMBoxLogic: timer scheduled: %d", KIpsSosAOSuspendWatchdogTime);
         iTimer->After( KIpsSosAOSuspendWatchdogTime );
         }
     }
@@ -649,7 +674,7 @@
     {
 	//<Qmail>
     FUNC_LOG;
-     iTimer->Cancel();
+    iTimer->Cancel();
     TMBoxLogicEvent event = EEventNop;
     TTimeIntervalSeconds secondsToConnect = CalculateScheduledSyncTimeL();
     
@@ -679,7 +704,10 @@
                     secsFromLastSync.Int() < interval ) )
                 {
                 // adjust timer to correct sync time
-                iTimer->After(interval - secsFromLastSync.Int());        
+                TInt syncAfter = interval - secsFromLastSync.Int();
+                INFO_1("CIpsSosAOMBoxLogic: timer scheduled: %d", syncAfter);
+                iTimer->After(syncAfter); 
+                NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateWaitSyncStart");
                 iState = EStateWaitSyncStart;
                 }
             else
@@ -692,6 +720,7 @@
     else if ( secondsToConnect.Int() == KErrNotFound )
         {
         // means that ao is not on (but emn is)
+        NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateIdleAndWaitCommands");
         iState = EStateIdleAndWaitCommands;
       
         if ( settings->EmnReceivedButNotSyncedFlag() )
@@ -702,7 +731,9 @@
         }
     else
         {
+        INFO_1("CIpsSosAOMBoxLogic: timer scheduled: %d", secondsToConnect);
         iTimer->After( secondsToConnect );
+        NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateWaitSyncStart");
         iState = EStateWaitSyncStart;
         
 
@@ -734,19 +765,36 @@
         CIpsSosAOSettingsHandler* settings = 
                  CIpsSosAOSettingsHandler::NewL(iSession, iMailboxId);
         CleanupStack::PushL(settings);
-        iTimer->After( 
-                settings->InboxRefreshTime() * KAOSecondsInMinute );
+        TInt inboxRefreshTime = settings->InboxRefreshTime();
+        TInt secs = inboxRefreshTime * KAOSecondsInMinute;
+        INFO_1("CIpsSosAOMBoxLogic: inboxRefreshTime: %d", inboxRefreshTime);
+        INFO_1("CIpsSosAOMBoxLogic: timer scheduled: %d", secs);
+        if (secs > 0) 
+            {
+            iTimer->After(TTimeIntervalSeconds(secs));
+            }
+        else 
+            {
+            // panic at this point when we get zero time from settings
+            __ASSERT_DEBUG( EFalse, User::Panic( KIpsSosAOPanicLit, KErrGeneral) );
+            iTimer->After(TTimeIntervalSeconds(KAODefaultInboxSyncTimeSecs));
+            }
+            
         CleanupStack::PopAndDestroy(settings);
 	   //</QMail>
+        NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateWaitSyncStart");
         iState = EStateWaitSyncStart;
         }
     else if ( interval.Int() > 0 )
         {
+        INFO_1("CIpsSosAOMBoxLogic: timer scheduled: %d", interval);
         iTimer->After( interval );
+        NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateWaitSyncStart");
         iState = EStateWaitSyncStart;
         }
     else 
         {
+        NM_COMMENT("CIpsSosAOMBoxLogic: switching state: EStateIdleAndWaitCommands");
         iState = EStateIdleAndWaitCommands;
         }
     
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOPluginEComInterface.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOPluginEComInterface.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -16,15 +16,7 @@
 *
 */
 
-#include "emailtrace.h"
-#include <e32base.h>
-
-#include <AlwaysOnlineManagerCommon.h>
-#include <AlwaysOnlineManagerClient.h>
-
-#include "IpsSosAOPluginEComInterface.h"
-#include "IpsSosAOSmtpSendWatcher.h"
-#include "IpsSosAOImapPopLogic.h"
+#include "ipssosaopluginheaders.h"
 
 const TInt KIpsSosAOPluginCommandBufferGra = 1;
 
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOPluginTimer.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOPluginTimer.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -16,10 +16,7 @@
 *
 */
 
-
-#include "emailtrace.h"
-#include "IpsSosAOPluginTimer.h"
-
+#include "ipssosaopluginheaders.h"
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOPopAgent.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOPopAgent.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -16,18 +16,7 @@
 *
 */
 
-
-
-#include "emailtrace.h"
-#include <cemailaccounts.h>
-#include <pop3cmds.h>
-#include <miutset.h>
-#include <popcmtm.h>
-#include <AlwaysOnlineManagerCommon.h>
-
-#include "IpsSosAOPopAgent.h"
-#include "IpsSosAOImapPopLogic.h"
-
+#include "ipssosaopluginheaders.h"
 
 // from settings
 //<QMail>
@@ -147,6 +136,7 @@
          case EStateFetchOnHold:
              break;
          case EStateDisconnect:
+             NM_COMMENT("CIpsSosAOPopAgent: disconnecting");
              if ( !iDoNotDisconnect )
                  {
                  CancelAllAndDisconnectL();
@@ -158,6 +148,7 @@
                  }
              break;
          case EStateCompleted:
+             NM_COMMENT("CIpsSosAOImapAgent: completed");
              TRAP_IGNORE( iOpResponse.OperationCompletedL( iError ) );
              SignalSyncCompleted( iServiceId, iError );
              ClearSignaledFlags();
@@ -270,6 +261,7 @@
     LoadSettingsL( );
     if ( !IsConnected() )
         {
+        NM_COMMENT("CIpsSosAOPopAgent: starting sync");
         TBuf8<1> dummy;
         // connect and synchronise starts background sync or idle
         iSelection->ResizeL(0);
@@ -282,6 +274,7 @@
         }
     else
         {
+        NM_COMMENT("CIpsSosAOPopAgent: already connected do not sync");
         iState = EStateCompleted;
         iError = KErrCancel;
         SetActiveAndCompleteThis();
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOSchedulerUtils.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOSchedulerUtils.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -16,13 +16,7 @@
 *
 */
 
-
-#include "emailtrace.h"
-#include "IpsSosAOSchedulerUtils.h"
-//<QMail>
-#include "IpsSosAOSettingsHandler.h"
-//</QMail>
-
+#include "ipssosaopluginheaders.h"
 
 const TInt KAOSecondsIn24Hours = 86400;
 //const TUint KAOEveryDayMask = 0x7f;
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOSettingsHandler.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOSettingsHandler.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -15,15 +15,8 @@
 *     
 *
 */
-#include "IpsSosAOSettingsHandler.h"
-#include "IpsSosAoExtendedSettingsManager.h"
-#include "nmipssettingitems.h"
-#include "ipssettingkeys.h"
-#include <SendUiConsts.h>
-#include <msvapi.h>
-#include <cemailaccounts.h>
-#include <smtpset.h>
-#include <nmcommon.h>
+
+#include "ipssosaopluginheaders.h"
 
 const TInt KAOMinutesInHour = 60;
 
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOSmtpAgent.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOSmtpAgent.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -16,18 +16,7 @@
 *
 */
 
-#include "emailtrace.h"
-#include <e32base.h>
-
-//<QMail>
-#include "CFSMailCommon.h"
-//</QMail>
-#include "IpsSosAOSmtpAgent.h"
-#include "ipsplgsmtpoperation.h"
-//<QMail>
-
-//</QMail>
-
+#include "ipssosaopluginheaders.h"
 
 #ifdef _DEBUG
 _LIT( KIpsSosAOSmtpLogicPanicLit, "AOsmtp");
--- a/ipsservices/ipssosaoplugin/src/IpsSosAOSmtpSendWatcher.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAOSmtpSendWatcher.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -16,14 +16,7 @@
 *
 */
 
-//#include <e32math.h>
-#include "emailtrace.h"
-#include <msvapi.h>
-
-#include "IpsSosAOSmtpSendWatcher.h"
-#include "IpsSosAOSmtpAgent.h"
-
-#include "ipsplgcommon.h"
+#include "ipssosaopluginheaders.h"
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
--- a/ipsservices/ipssosaoplugin/src/IpsSosAoExtendedSettingsManager.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosaoplugin/src/IpsSosAoExtendedSettingsManager.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -15,15 +15,7 @@
 *
 */
 
-#include <xqsettingsmanager.h>
-#include <xqcentralrepositoryutils.h>
-#include <xqcentralrepositorysearchcriteria.h>
-#include <qlist.h>
-
-#include "IpsSosAoExtendedSettingsManager.h"
-#include "nmipssettingitems.h"
-#include "ipssettingkeys.h"
-#include "nmcommon.h"
+#include "ipssosaopluginheaders.h"
 
 /*!
     \class NmIpsSosAoExtendedSettingsManager
--- a/ipsservices/ipssosplugin/inc/ipsplgeventhandler.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgeventhandler.h	Wed Aug 18 09:37:47 2010 +0300
@@ -180,9 +180,8 @@
      * Adds property observer, p&s (property) events are signaled to these
      * observers
      * @param aObservers interface to observer object
-     * @return error code from RProperty::Define function
      */
-    TInt RegisterPropertyObserverL( MIpsPlgPropertyObserver* aObserver );
+    void RegisterPropertyObserverL( MIpsPlgPropertyObserver* aObserver );
 
     /**
      * Removes property observer
@@ -389,7 +388,7 @@
     /**
     * Fills RArray FSMessage objects created from CMsvEntrySelection
     */
-    inline void FillFSMessageArray(
+    inline void FillFSMessageArrayL(
             RArray<TFSMailMsgId>& aFSArray,
             const CMsvEntrySelection* aSelection,
             TUint aMtmUid );
--- a/ipsservices/ipssosplugin/inc/ipsplgmsgiterator.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgmsgiterator.h	Wed Aug 18 09:37:47 2010 +0300
@@ -210,8 +210,7 @@
     CIpsPlgMsgIterator( 
         CIpsPlgSosBasePlugin& aPlugin,
         const TFSMailMsgId& aMailBoxId,
-        const TFSMailDetails aDetails,
-        const RArray<TFSMailSortCriteria>& aSorting );
+        const TFSMailDetails aDetails );
     
     void ConstructL(        
         CMsvSession& aMsvSession,
@@ -221,7 +220,10 @@
     void ConstructL(        
         CMsvEntry* aFolderEntry, 
         const RArray<TFSMailSortCriteria>& aSorting);
-
+    
+    void StoreSortCriteriaL( 
+        const RArray<TFSMailSortCriteria>& aSorting );
+    
 private: // data
 
     
@@ -236,6 +238,7 @@
      */
     CMsvEntry* iFolderEntry;
     
+    CMsvEntrySelection* iMessages;
     /**
      * Controls data to be returned
      */    
@@ -249,10 +252,10 @@
     /**
      * Sorting objects
      */    
-    TIpsPlgMsgKey*  iMsgSortKey;
-    TIpsPlgMsgSwap* iMsgSwapper;
-    TBool           iSortingOn;
-    const RArray<TFSMailSortCriteria>& iSortingCriteria;
+    TIpsPlgMsgKey*                  iMsgSortKey;
+    TIpsPlgMsgSwap*                 iMsgSwapper;
+    TBool                           iSortingOn;
+    RArray<TFSMailSortCriteria>     iSortingCriteria;
 
     /**
      * Mailbox identifier
--- a/ipsservices/ipssosplugin/inc/ipsplgmsgkey.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgmsgkey.h	Wed Aug 18 09:37:47 2010 +0300
@@ -83,7 +83,7 @@
     /**
      * Compares the subject strings omitting the reply & forward prefixes
      */
-    TInt CompareSubjectsL( const TDesC& aLeft, const TDesC& aRight ) const; // <cmail> change to leaving function
+    TInt CompareSubjects( const TDesC& aLeft, const TDesC& aRight ) const;
 
 private:
     // Folder objects the messages of which are sorted. Not owned.    
--- a/ipsservices/ipssosplugin/inc/ipsplgsearch.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgsearch.h	Wed Aug 18 09:37:47 2010 +0300
@@ -367,11 +367,16 @@
         /**
          * @param aCriteria Sorting criterias.
          */
-        TMsgContainer( 
-            const TMsvId& aId, 
+
+
+        /*TMsgContainer(
+            const TMsvId& aId,
             const TFSMailSortCriteria& aCriteria,
-            CMsvSession& aMsvSession );
-        
+            CMsvSession& aMsvSession );*/
+
+        TMsgContainer( const TMsvEntry& aEntry,
+            const TFSMailSortCriteria& aCriteria );
+
         /**
          * @param aMsgContainer MsgContainer to be compared.
          * @return ETrue, when content is greater than in parameter.
@@ -446,17 +451,19 @@
         /**
          * Entry to be used for compare operations.
          */
-        TMsvId iId;
+        //TMsvId iId;
                 
         /**
          * Reference to existing sort criteria.
          */
         const TFSMailSortCriteria& iCriteria;
         
+        TMsvEntry iEntry;
+
         /**
          * Message server session.
          */
-        CMsvSession& iMsvSession;
+        //CMsvSession& iMsvSession;
         };
 
     /**
--- a/ipsservices/ipssosplugin/inc/ipsplgsearch.inl	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgsearch.inl	Wed Aug 18 09:37:47 2010 +0300
@@ -209,7 +209,7 @@
 //
 TMsvId CIpsPlgSearch::TMsgContainer::Id() const
     {
-    return iId;
+    return iEntry.Id();
     }
 
 // End of File
--- a/ipsservices/ipssosplugin/inc/ipsplgsyncstatehandler.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/inc/ipsplgsyncstatehandler.h	Wed Aug 18 09:37:47 2010 +0300
@@ -95,7 +95,7 @@
     * @param aMailbox  id of mailbox to be append
     * @param aState state to be updated or added to mailbox
     */
-    void AppendMailboxToSyncingMailbox( TMsvId aMailbox, TInt aState );
+    void AppendMailboxToSyncingMailboxL( TMsvId aMailbox, TInt aState );
     
     TInt GetMailboxIpsState( TMsvId aMailbox );
     
--- a/ipsservices/ipssosplugin/src/ipsplgdisconnectop.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgdisconnectop.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -203,7 +203,7 @@
     {
     FUNC_LOG;
     iStatus = KRequestPending;
-    
+    NM_COMMENT("CIpsPlgDisconnectOp: doing disconnect");
     TInt cmd = (iTEntry.iMtm == KUidMsgTypePOP3) ? KPOP3MTMDisconnect : KIMAP4MTMDisconnect;
     InvokeClientMtmAsyncFunctionL( cmd, iService ); // <qmail> 1 param removed
     SetActive();
--- a/ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -154,7 +154,7 @@
         TMsvId mboxId = iMBoxObservers[i]->iMBoxId.Id();
         if ( mboxes.Find(mboxId) == KErrNotFound )
             {
-            mboxes.Append( mboxId );
+            mboxes.AppendL( mboxId );
             }
         }
 
@@ -206,7 +206,7 @@
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
-TInt CIpsPlgEventHandler::RegisterPropertyObserverL(
+void CIpsPlgEventHandler::RegisterPropertyObserverL(
         MIpsPlgPropertyObserver* aObserver )
     {
     FUNC_LOG;
@@ -221,7 +221,7 @@
                 CActive::EPriorityIdle, *this );
         }
 
-    return iPropertyObservers.Append( aObserver );
+    iPropertyObservers.AppendL( aObserver );
     }
 
 // ----------------------------------------------------------------------------
@@ -492,7 +492,7 @@
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
-inline void CIpsPlgEventHandler::FillFSMessageArray(
+inline void CIpsPlgEventHandler::FillFSMessageArrayL(
     RArray<TFSMailMsgId>& aFSArray,
     const CMsvEntrySelection* aSelection,
     TUint aMtmUid )
@@ -504,7 +504,7 @@
 
     for ( TInt i = 0; i < aSelection->Count(); i++ )
         {
-        aFSArray.Append( SymId2FsId(aSelection->At(i), aMtmUid) );
+        aFSArray.AppendL( SymId2FsId(aSelection->At(i), aMtmUid) );
         }
     }
 
@@ -694,7 +694,7 @@
             RArray<TFSMailMsgId> array(KEventGranularity);
             CleanupClosePushL( array );
 
-            FillFSMessageArray(
+            FillFSMessageArrayL(
                 array,
                 static_cast<const CMsvEntrySelection*>(aArg1),
                 tNew.iMtm.iUid );
@@ -717,7 +717,7 @@
             // set entries array pointer
             RArray<TFSMailMsgId> array(1);
             CleanupClosePushL( array );
-            array.Append( SymId2FsId( tNew ) );
+            array.AppendL( SymId2FsId( tNew ) );
             arg1 = &array;
 
             // set parent pointer
@@ -766,7 +766,7 @@
 
         RArray<TFSMailMsgId> array(KEventGranularity);
         CleanupClosePushL( array );
-        FillFSMessageArray(
+        FillFSMessageArrayL(
             array,
             static_cast<const CMsvEntrySelection*>(aArg1),
             tMoved.iMtm.iUid );
@@ -935,7 +935,7 @@
                 }
             else
                 {
-                array.Append( SymId2FsId(deletedId, tEntry.iMtm.iUid) );
+                array.AppendL( SymId2FsId(deletedId, tEntry.iMtm.iUid) );
                 arg1 = &array;
                 arg2 = &parentId;
 
@@ -992,7 +992,7 @@
 
             RArray<TFSMailMsgId> array(1);
             CleanupClosePushL( array );
-            array.Append( msg );
+            array.AppendL( msg );
             arg1 = &array;
             arg2 = &parent;
             event = TFSEventMailDeleted;
@@ -1054,7 +1054,7 @@
             }
 
         // message entry
-        array.Append( SymId2FsId( tChanged )  );
+        array.AppendL( SymId2FsId( tChanged )  );
         arg1 = &array;
 
         // parent entry
@@ -1066,7 +1066,7 @@
         {
         event = TFSEventFolderChanged;
 
-        array.Append( SymId2FsId( tChanged ) );
+        array.AppendL( SymId2FsId( tChanged ) );
         arg1 = &array;
 
         TFSMailMsgId id = SymId2FsId( *(static_cast<TMsvId*>(aArg2)), tChanged.iMtm.iUid );
@@ -1078,7 +1078,7 @@
             TInt index = iImapFolderIds.Find(tChanged.Id());
             if ( eml.LocalSubscription() && index == KErrNotFound )
                 {
-                iImapFolderIds.Append( tChanged.Id() );
+                iImapFolderIds.AppendL( tChanged.Id() );
                 }
             else if ( !eml.LocalSubscription() && index != KErrNotFound )
                 {
@@ -1482,7 +1482,7 @@
         aFSParent.SetId( aParent.Id() );
         for ( TInt i = 0; i < aDeletedIds.Count(); i++ )
             {
-            aFSDeletedArray.Append(
+            aFSDeletedArray.AppendL(
                     TFSMailMsgId( iPluginId, aDeletedIds.At(i) ) );
             }
         }
--- a/ipsservices/ipssosplugin/src/ipsplgimap4connectop.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgimap4connectop.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -339,6 +339,7 @@
     if ( iDoPlainConnect && !Connected() )
         {
         TBuf8<1> parameter;
+        NM_COMMENT("CIpsPlgImap4ConnectOp: do plain connect");
         // connect and synchronise starts background sync or idle
         iSubOperation = iBaseMtm->InvokeAsyncFunctionL(
             KIMAP4MTMConnect, *iSelection, parameter, iStatus);
@@ -348,12 +349,14 @@
         // in this point cant use "connect and do something" commands,
         // use regular sync, when new mails is populated elsewhere.
         TBuf8<1> parameter;
+        NM_COMMENT("CIpsPlgImap4ConnectOp: full sync starting");
         iSubOperation = iBaseMtm->InvokeAsyncFunctionL(
             KIMAP4MTMFullSync, *iSelection, parameter, iStatus);
         }
     else
         {
         // the used command requires an observer to be given even though we're not using it
+        NM_COMMENT("CIpsPlgImap4ConnectOp: connect and sync");
         TPckg<MMsvImapConnectionObserver*> parameter( NULL );
         iSubOperation = iBaseMtm->InvokeAsyncFunctionL(
             KIMAP4MTMConnectAndSyncCompleteAfterFullSync, 
@@ -372,6 +375,7 @@
     {
     FUNC_LOG;
     
+    NM_COMMENT("CIpsPlgImap4ConnectOp: populate all");
     // construct partial fetch info according to imap settings
     // <qmail> new function to wrap settings loading
     CImImap4Settings* settings = GetImapSettingsLC();
--- a/ipsservices/ipssosplugin/src/ipsplgimap4plugin.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgimap4plugin.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -659,7 +659,7 @@
         if( folder )
      	    {
      	    CleanupStack::PushL( folder );
-     	    aFolderList.Append( folder );
+     	    aFolderList.AppendL( folder );
      	    CleanupStack::Pop( folder );
      	    }
         
@@ -669,7 +669,7 @@
         if( folder )
      	    {
      	    CleanupStack::PushL( folder );
-     	    aFolderList.Append( folder );
+     	    aFolderList.AppendL( folder );
      	    CleanupStack::Pop( folder );
      	    } 	    
      	    
@@ -679,7 +679,7 @@
         if( folder )
      	    {
      	    CleanupStack::PushL( folder );
-     	    aFolderList.Append( folder );
+     	    aFolderList.AppendL( folder );
      	    CleanupStack::Pop( folder );
      	    } 	   
         
--- a/ipsservices/ipssosplugin/src/ipsplgmsgiterator.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgmsgiterator.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -33,8 +33,7 @@
     {
     FUNC_LOG;
     CIpsPlgMsgIterator* self = 
-        new( ELeave ) CIpsPlgMsgIterator( aPlugin, aMailboxId, aDetails, 
-            aSorting );
+        new( ELeave ) CIpsPlgMsgIterator( aPlugin, aMailboxId, aDetails );
     CleanupStack::PushL( self );
     self->ConstructL( aMsvSession, aFolderId, aSorting );
     CleanupStack::Pop( self );
@@ -53,8 +52,7 @@
     {
     FUNC_LOG;
     CIpsPlgMsgIterator* self = 
-        new( ELeave ) CIpsPlgMsgIterator( aPlugin, aMailboxId, aDetails, 
-            aSorting );
+        new( ELeave ) CIpsPlgMsgIterator( aPlugin, aMailboxId, aDetails );
     CleanupStack::PushL( self );
     self->ConstructL( aFolderEntry, aSorting );
     CleanupStack::Pop( self );
@@ -73,6 +71,8 @@
     delete iMsgMapper;
     delete iMsgSortKey;
     delete iMsgSwapper;
+    delete iMessages;
+    iSortingCriteria.Reset();
     }
 
 // ---------------------------------------------------------------------------
@@ -89,15 +89,16 @@
     TBool result = EFalse;
     TInt baseIndex;
     
-    // Messages are sorted always before reading the messages 
-    Sort();
-    
-    CMsvEntrySelection* messages = FilterMessagesL();
-    CleanupStack::PushL( messages );
+    if ( !iMessages )
+        {
+        // Messages are sorted before first reading the messages 
+        Sort();
+        iMessages = FilterMessagesL();
+        }
 
     if ( !aCurrentMessageId.IsNullId() )
         {
-        baseIndex = messages->Find( aCurrentMessageId.Id() );
+        baseIndex = iMessages->Find( aCurrentMessageId.Id() );
         
         // aCurrentMessageId is not included to the result set
         if ( baseIndex != KErrNotFound )
@@ -112,12 +113,11 @@
         }
         
     if ( ( baseIndex != KErrNotFound ) && 
-         ( baseIndex < messages->Count() ) )
+         ( baseIndex < iMessages->Count() ) )
         {
-        result = NextL(baseIndex, messages, aCount, aMessages);
+        result = NextL(baseIndex, iMessages, aCount, aMessages);
         }
 
-    CleanupStack::PopAndDestroy(messages);
     return result;
     }
 
@@ -136,20 +136,20 @@
     TInt status;
     TInt baseIndex;
     
-    // Messages are sorted always before reading the messages 
-    Sort();
+    if ( !iMessages )
+        {
+        // Messages are sorted before first reading the messages 
+        Sort();
+        iMessages = FilterMessagesL();
+        }
 
-    CMsvEntrySelection* messages = FilterMessagesL();
-    CleanupStack::PushL( messages );
-
-    status = SearchL( messages, aStartWith, baseIndex );
+    status = SearchL( iMessages, aStartWith, baseIndex );
     
     if ( status == KErrNone )
         {
-        result = NextL(baseIndex, messages, aCount, aMessages);
+        result = NextL( baseIndex, iMessages, aCount, aMessages );
         }
 
-    CleanupStack::PopAndDestroy(messages);
     return result;
     }
 
@@ -168,15 +168,16 @@
     TBool result = EFalse;
     TInt baseIndex;
     
-    // Messages are sorted always before reading the messages 
-    Sort();
-
-    CMsvEntrySelection* messages = FilterMessagesL();
-    CleanupStack::PushL(messages);
+    if ( !iMessages )
+        {
+        // Messages are sorted before first reading the messages 
+        Sort();
+        iMessages = FilterMessagesL();
+        }
 
     if ( !aCurrentMessageId.IsNullId() )
         {
-        baseIndex = messages->Find(aCurrentMessageId.Id());
+        baseIndex = iMessages->Find(aCurrentMessageId.Id());
         
         // aCurrentMessageId is not included to the result set
         if ( baseIndex != KErrNotFound )
@@ -188,7 +189,7 @@
         {
         // check whether we should start from the end of 
         // the message list in the case of a NULL ID
-        baseIndex = messages->Count() - 1;
+        baseIndex = iMessages->Count() - 1;
         }
 
     // Actually, if the matching message is the first one, baseIndex is equal
@@ -198,10 +199,9 @@
     if ( ( baseIndex != KErrNotFound ) &&
          ( baseIndex >= 0 ) )
         {
-        result = PreviousL(baseIndex, messages, aCount, aMessages);
+        result = PreviousL(baseIndex, iMessages, aCount, aMessages);
         }
 
-    CleanupStack::PopAndDestroy(messages);
     return result;
     }
 
@@ -231,14 +231,13 @@
     CMsvEntrySelection* messages = FilterMessagesL();
     CleanupStack::PushL( messages );
 
-    status = SearchL( messages, aStartWith, baseIndex );
+    status = SearchL( iMessages, aStartWith, baseIndex );
     
     if (  status == KErrNone ) 
         {
-        result = PreviousL(baseIndex, messages, aCount, aMessages);
+        result = PreviousL(baseIndex, iMessages, aCount, aMessages);
         }
 
-    CleanupStack::PopAndDestroy(messages);
     return result;
     }
 
@@ -267,7 +266,7 @@
             {
             fsMsg = iMsgMapper->GetMailMessageL( iMailboxId, entry, 
                 iRequestedDetails );
-            aMessages.Append( fsMsg );
+            aMessages.AppendL( fsMsg );
             counter++;
             }
         i++;
@@ -307,7 +306,7 @@
             {
             fsMsg = iMsgMapper->GetMailMessageL( iMailboxId, entry, 
                 iRequestedDetails );
-            aMessages.Insert( fsMsg, 0 );
+            aMessages.InsertL( fsMsg, 0 );
             counter++;
             }
         i--;
@@ -323,10 +322,9 @@
 CIpsPlgMsgIterator::CIpsPlgMsgIterator( 
     CIpsPlgSosBasePlugin& aPlugin,
     const TFSMailMsgId& aMailboxId,
-    const TFSMailDetails aDetails,
-    const RArray<TFSMailSortCriteria>& aSorting )
+    const TFSMailDetails aDetails )
     : iPlugin( aPlugin ), iRequestedDetails( aDetails ), 
-      iSortingCriteria( aSorting ), iMailboxId( aMailboxId )
+      iMailboxId( aMailboxId )
     {
     FUNC_LOG;
     // none
@@ -344,7 +342,9 @@
     {
     FUNC_LOG;
     iFolderEntry  = aMsvSession.GetEntryL( aFolderId.Id() );
-    iMsgSortKey   = new (ELeave) TIpsPlgMsgKey( *iFolderEntry, aSorting );
+    
+    StoreSortCriteriaL(aSorting);
+    iMsgSortKey   = new (ELeave) TIpsPlgMsgKey( *iFolderEntry, iSortingCriteria );
     iMsgSwapper   = new (ELeave) TIpsPlgMsgSwap( *iFolderEntry );
     iSortingOn    = 
         ( aSorting.Count() > 0 ) && ( aSorting[0].iField != EFSMailDontCare);
@@ -363,7 +363,8 @@
     {
     FUNC_LOG;
     iFolderEntry  = aFolderEntry;
-    iMsgSortKey   = new (ELeave) TIpsPlgMsgKey( *iFolderEntry, aSorting );
+    StoreSortCriteriaL(aSorting);
+    iMsgSortKey   = new (ELeave) TIpsPlgMsgKey( *iFolderEntry, iSortingCriteria );
     iMsgSwapper   = new (ELeave) TIpsPlgMsgSwap( *iFolderEntry );
     iSortingOn    = 
         ( aSorting.Count() > 0 ) && ( aSorting[0].iField != EFSMailDontCare);
@@ -482,3 +483,19 @@
 	return filteredEntries;
 	}
 
+// -----------------------------------------------------------------------------
+// stores sort criteria given by user
+// -----------------------------------------------------------------------------
+void CIpsPlgMsgIterator::StoreSortCriteriaL( 
+     const RArray<TFSMailSortCriteria>& aSorting )
+    {
+    for ( TInt i=0; i < aSorting.Count(); i++ )
+        {
+        const TFSMailSortCriteria& criteria  = aSorting[i];
+        TFSMailSortCriteria fsCriteria;
+        fsCriteria.iField = criteria.iField;
+        fsCriteria.iOrder = criteria.iOrder;
+        iSortingCriteria.AppendL(fsCriteria);
+        }
+    }
+
--- a/ipsservices/ipssosplugin/src/ipsplgmsgkey.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgmsgkey.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -104,10 +104,8 @@
                 }
             case EFSMailSortBySubject:
                 {
-                // <cmail> due to changes in CompareSubject method
-                TRAP_IGNORE( result = CompareSubjectsL( 
-                    leftEntry.iDescription, rightEntry.iDescription ) );
-                // </cmail>
+                result = CompareSubjects( leftEntry.iDescription,
+                    rightEntry.iDescription );
                 break;
                 }
             case EFSMailSortByPriority:
@@ -142,7 +140,7 @@
                 }
             case EFSMailSortByUnread:
                 {
-                // In this context, an unread message is 'greater' than
+                // In this context, an read message is 'greater' than
                 // a read one
                 if ( !leftEntry.Unread() && rightEntry.Unread() ) 
                     {
@@ -212,7 +210,7 @@
 // Strips the subject prefixes before comparing the strings
 // ---------------------------------------------------------------------------
 
-TInt TIpsPlgMsgKey::CompareSubjectsL( 
+TInt TIpsPlgMsgKey::CompareSubjects(
     const TDesC& aLeft, 
     const TDesC& aRight ) const
     {
--- a/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgmsgmapper.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -1085,7 +1085,7 @@
             childPart = GetMessagePartL( (*cEntry)[0].Id(), aMailBoxId, aMessageId );
             if( childPart )
                 {
-                aParts.Append( childPart );
+                aParts.AppendL( childPart );
                 }
             }
         }
@@ -1147,7 +1147,7 @@
         // Insert the new child part to the result array
         if ( childPart )
             {
-            aParts.Insert( childPart, position );
+            aParts.InsertL( childPart, position );
             childPart = NULL;
             }
         }
@@ -1542,11 +1542,11 @@
             mimeHeader->RestoreL( *store );
 
             TInt count = mimeHeader->ContentTypeParams().MdcaCount();
-            INFO_1("# of CT params: %d", count);
+            //INFO_1("# of CT params: %d", count);
             for ( TInt i = 0; i < count; i++ )
                 {
                 TPtrC8 key8 = mimeHeader->ContentTypeParams().MdcaPoint( i );
-                INFO_1("%S", &key8);
+                //INFO_1("%S", &key8);
                 TPtr16 keyUppercase16 = HBufC::NewLC( key8.Length() )->Des();
                 keyUppercase16.Copy( key8 );
                 keyUppercase16.UpperCase();
--- a/ipsservices/ipssosplugin/src/ipsplgonlineoperation.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgonlineoperation.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -127,6 +127,7 @@
 void CIpsPlgOnlineOperation::CompleteObserver( TInt aStatus )
     {
     FUNC_LOG;
+    NM_COMMENT("CIpsPlgOnlineOperation::CompleteObserver");
     TRequestStatus* status = &iObserverRequestStatus;
     if (status && status->Int() == KRequestPending)
         {
@@ -136,6 +137,7 @@
         //if connected, reset activitytimer. if not, there is no reason to.
         if ( Connected() )
             {
+            NM_COMMENT("CIpsPlgOnlineOperation::reseting activitytimer");
             iActivityTimer->ResetTimerOperation();
             }
         else
--- a/ipsservices/ipssosplugin/src/ipsplgpop3connectop.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgpop3connectop.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -336,6 +336,7 @@
     {
     FUNC_LOG;
     // <qmail> unnecessary: iStatus = KRequestPending;
+    NM_COMMENT("CIpsPlgPop3ConnectOp: connecting");
     InvokeClientMtmAsyncFunctionL( KPOP3MTMConnect, iService ); // <qmail> 1 param removed
     SetActive();
 
@@ -354,6 +355,7 @@
 void CIpsPlgPop3ConnectOp::DoPopulateL()
     {
     FUNC_LOG;
+    NM_COMMENT("CIpsPlgPop3ConnectOp: populating");
     // <qmail> unnecessary: iStatus = KRequestPending;
 
     // Prepare parameters and include filtering
@@ -420,6 +422,7 @@
     {
     FUNC_LOG;
     // <qmail> unnecessary: iStatus = KRequestPending;
+    NM_COMMENT("CIpsPlgPop3ConnectOp: disconnecting");
     InvokeClientMtmAsyncFunctionL( KPOP3MTMDisconnect, iService ); // <qmail> 1 param removed
     SetActive();
     }
--- a/ipsservices/ipssosplugin/src/ipsplgsearch.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgsearch.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -107,8 +107,9 @@
 // CIpsPlgSearch::TMsgContainer::TMsgContainer()
 // ---------------------------------------------------------------------------
 //
-CIpsPlgSearch::TMsgContainer::TMsgContainer( 
-    const TMsvId& aId, 
+/*
+CIpsPlgSearch::TMsgContainer::TMsgContainer(
+    const TMsvId& aId,
     const TFSMailSortCriteria& aCriteria,
     CMsvSession& aMsvSession )
     :
@@ -118,6 +119,13 @@
     {
     FUNC_LOG;
     }
+*/
+CIpsPlgSearch::TMsgContainer::TMsgContainer( const TMsvEntry& aEntry,
+    const TFSMailSortCriteria& aCriteria ) :
+    iCriteria( aCriteria ), iEntry( aEntry )
+    {
+    FUNC_LOG;
+    }
 
 // ---------------------------------------------------------------------------
 // CIpsPlgSearch::TMsgContainer::TMsgContainer()
@@ -136,12 +144,12 @@
         break;
         
     case EFSMailSortByDate:
-        result = Entry( iId ).iDate > Entry( aMsgContainer.Id() ).iDate;
+        result = iEntry.iDate > aMsgContainer.iEntry.iDate;
         break;
 
     case EFSMailSortBySender:
         {
-        HBufC* leftSender = NULL;
+        /*HBufC* leftSender = NULL;
         HBufC* rightSender = NULL;
         
         GetSenderStringsCC( 
@@ -151,13 +159,14 @@
             rightSender );
         
         result = *leftSender > *rightSender;
-        CleanupStack::PopAndDestroy( 2, leftSender ); 
+        CleanupStack::PopAndDestroy( 2, leftSender );*/
+        result = iEntry.iDetails > aMsgContainer.iEntry.iDetails;
         }
         break;
     
     case EFSMailSortBySubject:
         {
-        HBufC* leftSubject = NULL;
+        /*HBufC* leftSubject = NULL;
         HBufC* rightSubject = NULL;
         
         GetSubjectStringsCC( 
@@ -167,28 +176,29 @@
             rightSubject );
 
         result = *leftSubject > *rightSubject;
-        CleanupStack::PopAndDestroy( 2, leftSubject ); 
+        CleanupStack::PopAndDestroy( 2, leftSubject );*/
+        result = iEntry.iDescription > aMsgContainer.iEntry.iDescription;
         }
         break;
 
     case EFSMailSortByPriority:
-        result = Entry( iId ).Priority() > Entry( aMsgContainer.Id() ).Priority();        
+        result = iEntry.Priority() > aMsgContainer.iEntry.Priority();
         break;
     
     case EFSMailSortByFlagStatus:
-        result = Entry( iId ).New() > Entry( aMsgContainer.Id() ).New();
+        result = iEntry.New() > aMsgContainer.iEntry.New();
         break;
     
     case EFSMailSortByUnread:
-        result = Entry( iId ).Unread() > Entry( aMsgContainer.Id() ).Unread();
+        result = iEntry.Unread() > aMsgContainer.iEntry.Unread();
         break;
     
     case EFSMailSortBySize:
-        result = Entry( iId ).iSize > Entry( aMsgContainer.Id() ).iSize;
+        result = iEntry.iSize > aMsgContainer.iEntry.iSize;
         break;
     
     case EFSMailSortByAttachment:
-        result = Entry( iId ).iDate > Entry( aMsgContainer.Id() ).iDate;        
+        result = iEntry.iDate > aMsgContainer.iEntry.iDate;
         break;
         }
            
@@ -212,12 +222,12 @@
         break;
         
     case EFSMailSortByDate:
-        result = Entry( iId ).iDate >= Entry( aMsgContainer.Id() ).iDate;
+        result = iEntry.iDate >= aMsgContainer.iEntry.iDate;
         break;
         
     case EFSMailSortBySender:
         {
-        HBufC* leftSender = NULL;
+        /*HBufC* leftSender = NULL;
         HBufC* rightSender = NULL;
         
         GetSenderStringsCC( 
@@ -227,13 +237,14 @@
             rightSender );
         
         result = *leftSender >= *rightSender;
-        CleanupStack::PopAndDestroy( 2, leftSender ); 
+        CleanupStack::PopAndDestroy( 2, leftSender );*/
+        result = iEntry.iDetails > aMsgContainer.iEntry.iDetails;
         }
         break;
         
     case EFSMailSortBySubject:
         {
-        HBufC* leftSubject = NULL;
+        /*HBufC* leftSubject = NULL;
         HBufC* rightSubject = NULL;
         
         GetSubjectStringsCC( 
@@ -243,32 +254,33 @@
             rightSubject );
 
         result = *leftSubject >= *rightSubject;
-        CleanupStack::PopAndDestroy( 2, leftSubject ); 
+        CleanupStack::PopAndDestroy( 2, leftSubject );*/
+        result = iEntry.iDescription > aMsgContainer.iEntry.iDescription;
         }
         break;
-            
+
     case EFSMailSortByPriority:
-        result = Entry( iId ).Priority() >= Entry( aMsgContainer.Id() ).Priority();        
+        result = iEntry.Priority() >= aMsgContainer.iEntry.Priority();
         break;
-    
+
     case EFSMailSortByFlagStatus:
-        result = Entry( iId ).New() >= Entry( aMsgContainer.Id() ).New();
+        result = iEntry.New() >= aMsgContainer.iEntry.New();
         break;
-    
+
     case EFSMailSortByUnread:
-        result = Entry( iId ).Unread() >= Entry( aMsgContainer.Id() ).Unread();
+        result = iEntry.Unread() >= aMsgContainer.iEntry.Unread();
         break;
-    
+
     case EFSMailSortBySize:
-        result = Entry( iId ).iSize >= Entry( aMsgContainer.Id() ).iSize;
+        result = iEntry.iSize >= aMsgContainer.iEntry.iSize;
         break;
-    
+
     case EFSMailSortByAttachment:
-        result = Entry( iId ).iDate >= Entry( aMsgContainer.Id() ).iDate;        
+        result = iEntry.iDate >= aMsgContainer.iEntry.iDate;
         break;
         }
-        
-    return result;        
+
+    return result;
     }
 
 // ---------------------------------------------------------------------------
@@ -288,12 +300,12 @@
         break;
         
     case EFSMailSortByDate:
-        result = Entry( iId ).iDate <= Entry( aMsgContainer.Id() ).iDate;
+        result = iEntry.iDate <= aMsgContainer.iEntry.iDate;
         break;
 
     case EFSMailSortBySender:
         {
-        HBufC* leftSender = NULL;
+        /*HBufC* leftSender = NULL;
         HBufC* rightSender = NULL;
         
         GetSenderStringsCC( 
@@ -303,13 +315,14 @@
             rightSender );
         
         result = *leftSender <= *rightSender;
-        CleanupStack::PopAndDestroy( 2, leftSender ); 
+        CleanupStack::PopAndDestroy( 2, leftSender );*/
+        result = iEntry.iDetails > aMsgContainer.iEntry.iDetails;
         }
         break;
     
     case EFSMailSortBySubject:
         {
-        HBufC* leftSubject = NULL;
+        /*HBufC* leftSubject = NULL;
         HBufC* rightSubject = NULL;
         
         GetSubjectStringsCC( 
@@ -319,34 +332,36 @@
             rightSubject );
 
         result = *leftSubject <= *rightSubject;
-        CleanupStack::PopAndDestroy( 2, leftSubject ); 
+        CleanupStack::PopAndDestroy( 2, leftSubject );*/
+        result = iEntry.iDescription > aMsgContainer.iEntry.iDescription;
         }
         break;
 
     case EFSMailSortByPriority:
-        result = Entry( iId ).Priority() <= Entry( aMsgContainer.Id() ).Priority();        
+        result = iEntry.Priority() <= aMsgContainer.iEntry.Priority();
         break;
-    
+
     case EFSMailSortByFlagStatus:
-        result = Entry( iId ).New() <= Entry( aMsgContainer.Id() ).New();
+        result = iEntry.New() <= aMsgContainer.iEntry.New();
         break;
-    
+
     case EFSMailSortByUnread:
-        result = Entry( iId ).Unread() <= Entry( aMsgContainer.Id() ).Unread();
+        result = iEntry.Unread() <= aMsgContainer.iEntry.Unread();
         break;
-    
+
     case EFSMailSortBySize:
-        result = Entry( iId ).iSize <= Entry( aMsgContainer.Id() ).iSize;
+        result = iEntry.iSize <= aMsgContainer.iEntry.iSize;
         break;
-    
+
     case EFSMailSortByAttachment:
-        result = Entry( iId ).iDate <= Entry( aMsgContainer.Id() ).iDate;        
+        result = iEntry.iDate <= aMsgContainer.iEntry.iDate;
         break;
         }
         
     return result;        
     }
 
+/*
 // ---------------------------------------------------------------------------
 // CIpsPlgSearch::TMsgContainer::GetSenderStringsCC()
 // ---------------------------------------------------------------------------
@@ -386,7 +401,7 @@
     aRightSubject = entry.iDescription.Alloc();
     TRAP_IGNORE( CleanupStack::PushL( aRightSubject ) );
     }
-
+*/
 // ---------------------------------------------------------------------------
 // CIpsPlgSearch::TMsgContainer::TMsgContainer()
 // ---------------------------------------------------------------------------
@@ -395,10 +410,11 @@
     const TMsgContainer& aMsgContainer )
     {
     FUNC_LOG;
-    iId = aMsgContainer.Id();
+    iEntry = aMsgContainer.iEntry;
+    /*Id() = aMsgContainer.Id();*/
     return *this;
     }
-
+/*
 // ---------------------------------------------------------------------------
 // CIpsPlgSearch::TMsgContainer::Entry()
 // ---------------------------------------------------------------------------
@@ -423,6 +439,7 @@
     aMsvSession.GetEntry( aId, service, entry );
     return entry;
     }
+    */
 
 // ======== CLASS CIPSPLGSEARCH ========     
     
@@ -993,11 +1010,11 @@
                  ( entry.iMtm.iUid == KSenduiMtmSmtpUidValue ||
                    entry.iMtm.iUid == iPlugin.MtmId().iUid ) )
                 {
-                iEmailMessages.AppendL( TMsgContainer( 
-                    entry.Id(), iCurrentSearch.iSortCriteria, iMsvSession ) );
-                }        
+                iEmailMessages.AppendL( TMsgContainer( entry,
+                    iCurrentSearch.iSortCriteria ) );
+                }
             }
-        }    
+        }
     }
 
 //Ask client if it wants to change the search prority (i.e. to enable search for contact)
--- a/ipsservices/ipssosplugin/src/ipsplgsyncstatehandler.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgsyncstatehandler.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -73,7 +73,7 @@
     if ( ( iPlugin.PluginId() == aPluginId ) &&
         ( aEvent == KIpsSosEmailSyncStarted || aEvent == KIpsSosEmailSyncCompleted ) )
         {
-        AppendMailboxToSyncingMailbox( aMailbox, aEvent );
+        AppendMailboxToSyncingMailboxL( aMailbox, aEvent );
         }
     }
 
@@ -210,7 +210,10 @@
             {
             ipsState = KIpsSosEmailSyncCompleted;
             }
-        TInt count = iSyncingMailboxes.Append( 
+        // the next call, FindMailbox, handles the case
+        // if .Append is failing, thus the return value can
+        // be ignored
+        TInt ignore = iSyncingMailboxes.Append( 
                 TIpsMailboxState( aMailbox, ipsState ) );
         index = FindMailbox( aMailbox );
         }
@@ -237,14 +240,14 @@
 
 // ---------------------------------------------------------------------------
 // --------------------------------------------------------------------------- 
-void CIpsPlgSyncStateHandler::AppendMailboxToSyncingMailbox( 
+void CIpsPlgSyncStateHandler::AppendMailboxToSyncingMailboxL( 
         TMsvId aMailbox, TInt aState )
     {
     FUNC_LOG;
     TInt index = FindMailbox( aMailbox );
     if ( index == KErrNotFound )
         {
-        iSyncingMailboxes.Append( TIpsMailboxState( aMailbox, aState ) );
+        iSyncingMailboxes.AppendL( TIpsMailboxState( aMailbox, aState ) );
         }
     else
         {
--- a/ipsservices/nmimapclientplugin/src/nmimapclientplugin.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/nmimapclientplugin/src/nmimapclientplugin.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -83,25 +83,25 @@
             HbMenu *standardFolders = new HbMenu();
             NmAction *inboxAction = new NmAction(0);
             inboxAction->setObjectName("imapclientplugin_folders_inbox");
-            inboxAction->setText(hbTrId("txt_mail_opt_folders_inbox"));
+            inboxAction->setText(hbTrId("txt_mail_opt_folder_sub_inbox"));
             inboxAction->setCheckable(true);
             connect(inboxAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderInbox()));
             standardFolders->addAction(inboxAction);
             NmAction *outboxAction = new NmAction(0);
             outboxAction->setObjectName("imapclientplugin_folders_outbox");
-            outboxAction->setText(hbTrId("txt_mail_opt_folders_outbox"));
+            outboxAction->setText(hbTrId("txt_mail_opt_folder_sub_outbox"));
             outboxAction->setCheckable(true);
             connect(outboxAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderOutbox()));
             standardFolders->addAction(outboxAction);
             NmAction *draftsAction = new NmAction(0);
             draftsAction->setObjectName("imapclientplugin_folders_drafts");
-            draftsAction->setText(hbTrId("txt_mail_opt_folders_drafts"));
+            draftsAction->setText(hbTrId("txt_mail_opt_folder_sub_drafts"));
             draftsAction->setCheckable(true);
             connect(draftsAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderDrafts()));
             standardFolders->addAction(draftsAction);
             NmAction *sentAction = new NmAction(0);
             sentAction->setObjectName("imapclientplugin_folders_sent");
-            sentAction->setText(hbTrId("txt_mail_opt_folders_sent"));
+            sentAction->setText(hbTrId("txt_mail_opt_folder_sub_sent"));
             sentAction->setCheckable(true);
             connect(sentAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderSent()));
             standardFolders->addAction(sentAction);
@@ -132,7 +132,7 @@
             // Add folders selection with sub-menu
             NmAction *foldersAction = new NmAction(0);
             foldersAction->setObjectName("baseclientplugin_folders");
-            foldersAction->setText(hbTrId("txt_mail_opt_folders"));
+            foldersAction->setText(hbTrId("txt_mail_opt_change_folder"));
             foldersAction->setMenu(standardFolders);
             actionList.append(foldersAction);
             }
--- a/ipsservices/nmipssettings/inc/nmipssettingshelper.h	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/nmipssettings/inc/nmipssettingshelper.h	Wed Aug 18 09:37:47 2010 +0300
@@ -156,7 +156,6 @@
 	HbDataForm &mDataForm;
 	HbDataFormModel &mDataFormModel;
 	HbMessageBox *mDeleteConfirmationDialog; // Owned.
-	HbMessageBox *mDeleteInformationDialog; // Owned.
 	HbInputDialog *mIncomingPortInputDialog; // Owned.
 	HbValidator *mIncomingPortInputValidator; // Owned.
     HbInputDialog *mFolderPathInputDialog; // Owned.
--- a/ipsservices/nmipssettings/src/nmipssettingshelper.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/nmipssettings/src/nmipssettingshelper.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -23,6 +23,7 @@
 #include <HbGlobal>
 #include <HbMessageBox>
 #include <HbProgressDialog>
+#include <HbNotificationDialog>
 #include <HbInputDialog>
 #include <HbDataFormModel>
 #include <HbExtendedLocale>
@@ -92,7 +93,6 @@
   mDataForm(dataForm),
   mDataFormModel(dataFormModel),
   mDeleteConfirmationDialog(0),
-  mDeleteInformationDialog(0),
   mIncomingPortInputDialog(0),
   mIncomingPortInputValidator(0),
   mFolderPathInputDialog(0),
@@ -111,7 +111,6 @@
 {
     mContentItems.clear();
     delete mDeleteConfirmationDialog;
-    delete mDeleteInformationDialog;
     delete mIncomingPortInputDialog;
     delete mIncomingPortInputValidator;
     delete mFolderPathInputDialog;
@@ -346,10 +345,10 @@
     Creates the setting items under the Serverinfo group items user authentication.
 */
 void NmIpsSettingsHelper::createServerInfoGroupDynamicItems(bool hiddenItem)
-{   
+{
     HbDataFormModelItem *item = mContentItems.value(IpsServices::SMTPAuthentication);
     int insertIndex = mServerInfoGroupItem->indexOf(item) + 1;
-        
+
     // Username
     QVariant username;
     mSettingsManager.readSetting(IpsServices::OutgoingLoginName, username);
@@ -378,7 +377,7 @@
     mDataForm.addConnection(passwordItem, SIGNAL(editingFinished()),
                             this, SLOT(saveOutgoingPassword()));
     mServerInfoGroupItem->insertChild(insertIndex + 1, passwordItem);
-    
+
     mServerInfoDynamicItemsVisible = true;
 }
 
@@ -597,11 +596,12 @@
 void NmIpsSettingsHelper::deleteButtonPress()
 {
     if(!mDeleteConfirmationDialog) {
-        mDeleteConfirmationDialog = 
+        mDeleteConfirmationDialog =
             new HbMessageBox(HbMessageBox::MessageTypeQuestion);
         mDeleteConfirmationDialog->setText(
             hbTrId("txt_mail_dialog_do_you_want_to_delete_the_mailbox"));
         mDeleteConfirmationDialog->setTimeout(HbMessageBox::NoTimeout);
+        mDeleteConfirmationDialog->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
     }
     mDeleteConfirmationDialog->open(this, SLOT(handleMailboxDelete(HbAction *)));
 }
@@ -611,20 +611,20 @@
 */
 void NmIpsSettingsHelper::handleMailboxDelete(HbAction *action)
 {
-    if (action == mDeleteConfirmationDialog->actions().at(0)) {        
+    if (action == mDeleteConfirmationDialog->actions().at(0)) {
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = false;
-    
+
         QVariant mailboxName;
         mSettingsManager.readSetting(IpsServices::MailboxName, mailboxName);
-    
+
         // Display the progress note. Before display the note, remove the cancel
         // button.
         HbProgressDialog progressNote(HbProgressDialog::WaitDialog);
         progressNote.setText(hbTrId("txt_common_info_deleting"));
         progressNote.removeAction(progressNote.actions().at(0));
         progressNote.delayedShow();
-    
+
         if (!mSettingsManager.deleteMailbox()) {
             // The mailbox was deleted successfully.
 
@@ -633,16 +633,12 @@
 
             // Hide the progress note and display the "mailbox deleted" dialog.
             progressNote.close();
-            
-            if (!mDeleteInformationDialog) {
-                mDeleteInformationDialog = 
-                    new HbMessageBox(HbMessageBox::MessageTypeInformation);
-                mDeleteInformationDialog->setText(
-                    hbTrId("txt_mail_dpophead _1_deleted").arg(mailboxName.toString()));
-                mDeleteInformationDialog->setTimeout(HbMessageBox::NoTimeout);
-            }
-            mDeleteInformationDialog->open(this, SLOT(handleMailboxDeleteUpdate(HbAction *)));            
-            
+
+            HbNotificationDialog *note = new HbNotificationDialog();
+            QString noteText = hbTrId("txt_mail_dialog_1_deleted").arg(mailboxName.toString());
+            note->setTitle(noteText);
+            note->setAttribute(Qt::WA_DeleteOnClose);
+            note->open(this, SLOT(handleMailboxDeleteUpdate(HbAction *)));
         } else {
             // Failed to delete the mailbox!
             progressNote.close();
@@ -824,13 +820,13 @@
 void NmIpsSettingsHelper::incomingPortChange(int index)
 {
     int previousindex = getCorrectIncomingPortRadioButtonIndex();
-    
+
     if (index == IpsServices::NmIpsSettingsDefault) {
         if (index != previousindex) {
             emit goOffline(mSettingsManager.mailboxId());
             mEmitOnline = true;
             int port = mSettingsManager.determineDefaultIncomingPort();
-            mSettingsManager.writeSetting(IpsServices::IncomingPort, port);    
+            mSettingsManager.writeSetting(IpsServices::IncomingPort, port);
         }
     } else if (index == IpsServices::NmIpsSettingsUserDefined) {
         showIncomingPortInputDialog();
@@ -841,24 +837,24 @@
     Shows an input dialog for allowing the user to specify a incoming port.
 */
 void NmIpsSettingsHelper::showIncomingPortInputDialog()
-{    
+{
     // User can open the dialog multiple times, so delete the old ones first.
     delete mIncomingPortInputDialog;
     mIncomingPortInputDialog = 0;
     delete mIncomingPortInputValidator;
     mIncomingPortInputValidator = 0;
-    
+
     mIncomingPortInputDialog = new HbInputDialog();
     mIncomingPortInputDialog->setInputMode(HbInputDialog::IntInput);
     QVariant currentPort;
     mSettingsManager.readSetting(IpsServices::IncomingPort, currentPort);
     mIncomingPortInputValidator = new HbValidator();
-    mIncomingPortInputValidator->addField(new QIntValidator(0, 65535, 0), 
+    mIncomingPortInputValidator->addField(new QIntValidator(0, 65535, 0),
                         HbStringUtil::convertDigits(QString::number(currentPort.toInt())));
     mIncomingPortInputDialog->setValidator(mIncomingPortInputValidator);
     mIncomingPortInputDialog->setPromptText(
         hbTrId("txt_mailips_setlabel_incoming_port_user_defined"));
-    
+
     mIncomingPortInputDialog->open(this, SLOT(handleUserDefinedIncomingPortInput(HbAction *)));
 }
 
@@ -868,7 +864,7 @@
 void NmIpsSettingsHelper::handleUserDefinedIncomingPortInput(HbAction *action)
 {
     int previousindex = getCorrectIncomingPortRadioButtonIndex();
-    
+
     if (action == mIncomingPortInputDialog->actions().at(0)) {
         QVariant newPort = mIncomingPortInputDialog->value();
         emit goOffline(mSettingsManager.mailboxId());
@@ -882,7 +878,7 @@
 }
 
 /*!
-    Used for getting the index to display in the port radio button list 
+    Used for getting the index to display in the port radio button list
     \return index Used to set the selected value
 */
 int NmIpsSettingsHelper::getCorrectIncomingPortRadioButtonIndex()
@@ -903,9 +899,9 @@
     Saves the incoming secure connection value into database if user has changed the value.
 */
 void NmIpsSettingsHelper::incomingSecureConnectionItemChange(int index)
-{  
+{
     int previousindex = getCorrectIncomingSecureRadioButtonIndex();
-    
+
     if (previousindex != index) {
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = true;
@@ -914,17 +910,17 @@
                 mSettingsManager.writeSetting(IpsServices::IncomingSecureSockets, true);
                 mSettingsManager.writeSetting(IpsServices::IncomingSSLWrapper, false);
                 break;
-    
+
             case IpsServices::EMailSslTls: // On (SSL/TLS)
                 mSettingsManager.writeSetting(IpsServices::IncomingSecureSockets, false);
                 mSettingsManager.writeSetting(IpsServices::IncomingSSLWrapper, true);
                 break;
-    
+
             case IpsServices::EMailSecurityOff: // Off
                 mSettingsManager.writeSetting(IpsServices::IncomingSecureSockets, false);
                 mSettingsManager.writeSetting(IpsServices::IncomingSSLWrapper, false);
                 break;
-    
+
              default:
                 break;
         }
@@ -949,10 +945,10 @@
     QVariant secureSSLWrapper;
     mSettingsManager.readSetting(IpsServices::IncomingSecureSockets, secureSockets);
     mSettingsManager.readSetting(IpsServices::IncomingSSLWrapper, secureSSLWrapper);
-    
+
     IpsServices::TIpsSetDataSecurityTypes securityType = IpsServices::EMailStartTls;
     // secureSockets == True
-    if (secureSockets.toBool()) { 
+    if (secureSockets.toBool()) {
         securityType = IpsServices::EMailStartTls;
     }
     // secureSockets == False & secureSSLWrapper == True
@@ -976,10 +972,10 @@
     QVariant secureSSLWrapper;
     mSettingsManager.readSetting(IpsServices::OutgoingSecureSockets, secureSockets);
     mSettingsManager.readSetting(IpsServices::OutgoingSSLWrapper, secureSSLWrapper);
-    
+
     IpsServices::TIpsSetDataSecurityTypes securityType = IpsServices::EMailStartTls;
     // secureSockets == True
-    if (secureSockets.toBool()) { 
+    if (secureSockets.toBool()) {
         securityType = IpsServices::EMailStartTls;
     }
     // secureSockets == False & secureSSLWrapper == True
@@ -999,14 +995,14 @@
 void NmIpsSettingsHelper::folderPathChange(int index)
 {
     int previousindex = getCorrectFolderPathRadioButtonIndex();
-        
+
     if (index == IpsServices::NmIpsSettingsDefault) {
         if (index != previousindex ) {
             // Empty string sets the folder path to default.
-            mSettingsManager.writeSetting(IpsServices::FolderPath, "");    
+            mSettingsManager.writeSetting(IpsServices::FolderPath, "");
         }
     } else if (index == IpsServices::NmIpsSettingsUserDefined) {
-        showFolderPathInputDialog();       
+        showFolderPathInputDialog();
     }
 }
 
@@ -1014,19 +1010,19 @@
     Show a input dialog for allowing the user to specify a folder path.
 */
 void NmIpsSettingsHelper::showFolderPathInputDialog()
-{   
+{
     // User can open the dialog multiple times, so delete the old one first.
     delete mFolderPathInputDialog;
     mFolderPathInputDialog = 0;
-    
+
     QVariant folderPath;
     mSettingsManager.readSetting(IpsServices::FolderPath, folderPath);
-    
+
     mFolderPathInputDialog = new HbInputDialog();
     mFolderPathInputDialog->setInputMode(HbInputDialog::TextInput);
     mFolderPathInputDialog->setPromptText(hbTrId("txt_mailips_setlabel_folder_path_user_defined"));
     mFolderPathInputDialog->setValue(folderPath.toString());
-    
+
     mFolderPathInputDialog->open(this, SLOT(handleUserDefinedFolderPathInput(HbAction *)));
 }
 
@@ -1036,10 +1032,10 @@
 void NmIpsSettingsHelper::handleUserDefinedFolderPathInput(HbAction *action)
 {
     int previousindex = getCorrectFolderPathRadioButtonIndex();
-    
+
     HbDataFormModelItem *item = mContentItems.value(IpsServices::FolderPath);
-    
-    if (action == mFolderPathInputDialog->actions().at(0)) { 
+
+    if (action == mFolderPathInputDialog->actions().at(0)) {
         QVariant newFolderPath = mFolderPathInputDialog->value();
         mSettingsManager.writeSetting(IpsServices::FolderPath, newFolderPath);
         //set selected index to default if user inputed empty string.
@@ -1135,14 +1131,14 @@
 }
 
 /*!
-    Used for getting the index to display in the inbox path radio button list 
+    Used for getting the index to display in the inbox path radio button list
     \return index Used to set the selected value
 */
 int NmIpsSettingsHelper::getCorrectFolderPathRadioButtonIndex()
 {
     QVariant folderPath;
     mSettingsManager.readSetting(IpsServices::FolderPath, folderPath);
-    
+
     int index(0);
     if (folderPath.toString().isEmpty()) {
         index = IpsServices::NmIpsSettingsDefault;
@@ -1282,13 +1278,13 @@
 void NmIpsSettingsHelper::outgoingPortChange(int index)
 {
     int previousindex = getCorrectOutgoingPortRadioButtonIndex();
-    
+
     if (index == IpsServices::NmIpsSettingsDefault) {
         if (index != previousindex) {
             emit goOffline(mSettingsManager.mailboxId());
             mEmitOnline = true;
             int port = mSettingsManager.determineDefaultOutgoingPort();
-            mSettingsManager.writeSetting(IpsServices::OutgoingPort, port);    
+            mSettingsManager.writeSetting(IpsServices::OutgoingPort, port);
         }
     } else if (index == IpsServices::NmIpsSettingsUserDefined) {
         showOutgoingPortInputDialog();
@@ -1305,18 +1301,18 @@
     mOutgoingPortInputDialog = 0;
     delete mOutgoingPortInputValidator;
     mOutgoingPortInputValidator = 0;
-    
+
     mOutgoingPortInputDialog = new HbInputDialog();
     mOutgoingPortInputDialog->setInputMode(HbInputDialog::IntInput);
     QVariant currentPort;
     mSettingsManager.readSetting(IpsServices::OutgoingPort, currentPort);
     mOutgoingPortInputValidator = new HbValidator();
-    mOutgoingPortInputValidator->addField(new QIntValidator(0, 65535, 0), 
+    mOutgoingPortInputValidator->addField(new QIntValidator(0, 65535, 0),
                         HbStringUtil::convertDigits(QString::number(currentPort.toInt())));
     mOutgoingPortInputDialog->setValidator(mOutgoingPortInputValidator);
     mOutgoingPortInputDialog->setPromptText(
         hbTrId("txt_mailips_setlabel_incoming_port_user_defined"));
-    
+
     mOutgoingPortInputDialog->open(this, SLOT(handleUserDefinedOutgoingPortInput(HbAction *)));
 }
 
@@ -1327,7 +1323,7 @@
 void NmIpsSettingsHelper::handleUserDefinedOutgoingPortInput(HbAction *action)
 {
     int previousindex = getCorrectOutgoingPortRadioButtonIndex();
-    
+
     if (action == mOutgoingPortInputDialog->actions().at(0)) {
         QVariant newPort = mOutgoingPortInputDialog->value();
         emit goOffline(mSettingsManager.mailboxId());
@@ -1365,7 +1361,7 @@
 {
     QVariant outgoingPort;
     mSettingsManager.readSetting(IpsServices::OutgoingPort, outgoingPort);
-    
+
     int index = 0;
     int port = mSettingsManager.determineDefaultOutgoingPort();
     if (port == outgoingPort.toInt()) {
@@ -1399,7 +1395,7 @@
     incomingLoginName = temp.toString();
     mSettingsManager.readSetting(IpsServices::IncomingPassword, temp);
     incomingPassword = temp.toString();
-    
+
     if (outgoingAuthentication) {
         if (outgoingLoginName == incomingLoginName && outgoingPassword == incomingPassword) {
             index = IpsServices::EMailAuthSameAsIncoming;
@@ -1419,9 +1415,9 @@
     \param index Selected radio button index.
 */
 void NmIpsSettingsHelper::outgoingSecureConnectionItemChange(int index)
-{      
+{
     int previousindex = getCorrectOutgoingSecureRadioButtonIndex();
-    
+
     if (previousindex != index) {
         emit goOffline(mSettingsManager.mailboxId());
         mEmitOnline = true;
@@ -1463,7 +1459,7 @@
 void NmIpsSettingsHelper::outgoingAuthenticationChange(int index)
 {
     int previousindex = getCorrectOutgoingAuthenticationRadioButtonIndex();
-    
+
     if (previousindex != index) {
         QVariant loginName;
         QVariant loginPassword;
@@ -1478,10 +1474,10 @@
             case IpsServices::EMailAuthSameAsIncoming: // Same as Incoming
                 deleteServerInfoGroupDynamicItems();
                 mSettingsManager.writeSetting(IpsServices::SMTPAuthentication, true);
-              
+
                 mSettingsManager.readSetting(IpsServices::IncomingLoginName, loginName);
                 mSettingsManager.writeSetting(IpsServices::OutgoingLoginName, loginName);
-                
+
                 mSettingsManager.readSetting(IpsServices::IncomingPassword, loginPassword);
                 mSettingsManager.writeSetting(IpsServices::OutgoingPassword, loginPassword);
                 break;
@@ -1490,7 +1486,7 @@
                 mSettingsManager.writeSetting(IpsServices::SMTPAuthentication, true);
                 createServerInfoGroupDynamicItems(false);
                 break;
-                
+
              default:
                 break;
         }
--- a/ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/ipsservices/nmpopclientplugin/src/nmpopclientplugin.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -88,25 +88,25 @@
             HbMenu *standardFolders = new HbMenu();
             NmAction *inboxAction = new NmAction(0);
             inboxAction->setObjectName("popclientplugin_folders_inbox");
-            inboxAction->setText(hbTrId("txt_mail_opt_folders_inbox"));
+            inboxAction->setText(hbTrId("txt_mail_opt_folder_sub_inbox"));
             inboxAction->setCheckable(true);
             connect(inboxAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderInbox()));
             standardFolders->addAction(inboxAction);
             NmAction *outboxAction = new NmAction(0);
             outboxAction->setObjectName("popclientplugin_folders_outbox");
-            outboxAction->setText(hbTrId("txt_mail_opt_folders_outbox"));
+            outboxAction->setText(hbTrId("txt_mail_opt_folder_sub_outbox"));
             outboxAction->setCheckable(true);
             connect(outboxAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderOutbox()));
             standardFolders->addAction(outboxAction);
             NmAction *draftsAction = new NmAction(0);
             draftsAction->setObjectName("popclientplugin_folders_drafts");
-            draftsAction->setText(hbTrId("txt_mail_opt_folders_drafts"));
+            draftsAction->setText(hbTrId("txt_mail_opt_folder_sub_drafts"));
             draftsAction->setCheckable(true);
             connect(draftsAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderDrafts()));
             standardFolders->addAction(draftsAction);
             NmAction *sentAction = new NmAction(0);
             sentAction->setObjectName("popclientplugin_folders_sent");
-            sentAction->setText(hbTrId("txt_mail_opt_folders_sent"));
+            sentAction->setText(hbTrId("txt_mail_opt_folder_sub_sent"));
             sentAction->setCheckable(true);
             connect(sentAction, SIGNAL(triggered()), this, SLOT(switchToStandardFolderSent()));
             standardFolders->addAction(sentAction);
@@ -137,7 +137,7 @@
             // Add folders selection with sub-menu
             NmAction *foldersAction = new NmAction(0);
             foldersAction->setObjectName("baseclientplugin_folders");
-            foldersAction->setText(hbTrId("txt_mail_opt_folders"));
+            foldersAction->setText(hbTrId("txt_mail_opt_change_folder"));
             foldersAction->setMenu(standardFolders);
             actionList.append(foldersAction);
             }
--- a/layers.sysdef.xml	Tue Jul 06 14:04:34 2010 +0300
+++ b/layers.sysdef.xml	Wed Aug 18 09:37:47 2010 +0300
@@ -11,7 +11,7 @@
       </module>
 <!-- Internal code -->
       <module name="nmail_tools">
-        <unit unitID="nmail.tools" mrp="" bldFile="&layer_real_source_path;\emailuis\nmailuiengine\tsrc\tools" name="qtdemos" proFile="tools.pro" qmakeArgs="-r" filter="nmail_tools"/>
+        <unit unitID="nmail.tools" mrp="" bldFile="&layer_real_source_path;\ipsservices\nmipssettings\tsrc\tools\extendedkeygen" name="qtdemos" proFile="extendedkeygenerator.pro" qmakeArgs="-r" filter="nmail_tools"/>
      </module>
 <!-- Internal code widget-->
 <!-- temporary built from nmail.pro as a workaround to ServiceFW bug on service regisrtations, fix expected on wk18 MCL
--- a/nmail.pro	Tue Jul 06 14:04:34 2010 +0300
+++ b/nmail.pro	Wed Aug 18 09:37:47 2010 +0300
@@ -42,15 +42,14 @@
         emailservices/nmutilities
         
     # Need to remove warnings SYSTEMINCLUDE path "\epoc32\include\mw\hb\..." not found
-    system(mkdir \epoc32\include\mw\hb\hbcnf\)
-    system(mkdir \epoc32\include\mw\hb\hbservices\)
+    system(mkdir \\epoc32\\include\\mw\\hb\\hbcnf\\)
+    system(mkdir \\epoc32\\include\\mw\\hb\\hbservices\\)
     
     # Need to remove warnings SYSTEMINCLUDE path "\epoc32\include\mw\QtXmlPatterns\" not found
-    system(mkdir \epoc32\include\mw\QtXmlPatterns\)
+    system(mkdir \\epoc32\\include\\mw\\QtXmlPatterns\\)
     BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>" \
-							 "emailuis/rom/nmail.iby			CORE_APP_LAYER_IBY_EXPORT_PATH(nmail.iby)" \
-							 "emailuis/rom/nmaillanguage.iby 	LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(nmaillanguage.iby)" \    
-    
-    
+        "emailuis/rom/nmail.iby            CORE_APP_LAYER_IBY_EXPORT_PATH(nmail.iby)" \
+        "emailuis/rom/nmaillanguage.iby    LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(nmaillanguage.iby)"
 }
+
 CONFIG += ordered